Version: git master (using KDE 4.6.1) OS: Linux Because KDevelop C++ parser lacks sunderstanding of size_t type which is used in containers declarations, it fails to parse usual operator[] declarations and thus does not show completion in code like this: "vec[i]." Reproducible: Didn't try Steps to Reproduce: example: class A{ public: void f(); }; //typedef int size_t; // if uncomment this, parsing works class Container{ public: A& operator[](size_t i); A at(size_t i); }; void main(){ Container c; c[0].f(); // ^ there is no completion support here c.at(i).f(); // ^ but here it works } There are the same problems with ptrdiff_t type
Hm, formatting in bug input form differ from formatting in final bug window correct locations of markers, of course, is following: void main(){ Container c; c[0].f(); // ^ there is no completion support here c.at(i).f(); // ^ but here it works }
size_t is not a C++ default type, see also: http://www.cplusplus.com/reference/clibrary/cstring/size_t/ for ptrdiff_t see http://www.cplusplus.com/reference/clibrary/cstddef/ptrdiff_t/ so supposedly including that header should make kdevelop work properly. but it doesn#t for me, lets investigate...
reason is the extension cache in the language controller, since cstddef has no extension the file contents won't be taken into account when looking at the mime type, I'll start discussion on this and improve the situation. thanks for the report, I wonder why we have not spotted this sooner.
For me including of ant of headers that define size_t also does not help. I forgot to add it to the example because in real world it obviously included some how by container's include file and KDevelop doesn't see size_t definition neverheless
The reason are (probably) problems in the preprocessor. Should be workaroundable by pushing the "Reparse ..." button in the "Problems" toolview.
The source of the problem is probably such an ugly construct: #ifndef HAVE_SIZE_T typedef unsigned int size_t; #endif And at some point, the file will be updated with "HAVE_SIZE_T" set, because it was included multiple times, or something like that. The exact issue needs some more research, and as first, a way to reliable reproduce the issue.
I mean this: #ifndef HAVE_SIZE_T typedef unsigned int size_t; #define HAVE_SIZE_T #endif
this example works for me, note the "using namespace std;" and the include of "cstddef". ~~~~~~ #include <cstddef> using namespace std; class A{ public: void f(); }; //typedef int size_t; // if uncomment this, parsing works class Container{ public: A& operator[](size_t i); A at(size_t i); }; void main(){ Container c; c[0].f(); // ^ there is no completion support here c.at(1).f(); // ^ but here it works } ~~~~~~ if it's still not working for anyone, please give us a way to reproduce it.
ah but if you use std::vector [0].f() will fail because kdev only "sees" the const& version of operator[] and hides the non-const method foo() then...
Git commit 50b8d362e01e0ed3fed8e875902e1595be31bb41 by Milian Wolff. Committed on 28/02/2012 at 20:23. Pushed by mwolff into branch '4.3'. properly take constness during overload resolution into account we prefer non-const overloads to const ones if we are accessing a non-const object now, this is also what g++ does by default as far as I can see M +13 -0 languages/cpp/cppduchain/expressionvisitor.cpp M +9 -4 languages/cpp/cppduchain/overloadresolution.cpp M +14 -2 languages/cpp/cppduchain/overloadresolution.h M +12 -3 languages/cpp/cppduchain/overloadresolutionhelper.cpp M +8 -1 languages/cpp/cppduchain/overloadresolutionhelper.h M +78 -0 languages/cpp/cppduchain/tests/test_expressionparser.cpp M +2 -0 languages/cpp/cppduchain/tests/test_expressionparser.h M +15 -1 languages/cpp/cppduchain/viablefunctions.cpp M +4 -1 languages/cpp/cppduchain/viablefunctions.h http://commits.kde.org/kdevelop/50b8d362e01e0ed3fed8e875902e1595be31bb41
Git commit 3a546dd106794dc12ce0cf6893b02142f566d2b3 by Milian Wolff. Committed on 28/02/2012 at 20:21. Pushed by mwolff into branch '4.3'. properly take constness during code completion into account - when accessing a const object, only show const methods - when accessign a non-const object, prefer non-const overloads to the const ones, but still show const methods if they are not overloaded M +11 -9 languages/cpp/codecompletion/context.cpp M +2 -2 languages/cpp/codecompletion/context.h M +40 -7 languages/cpp/cppduchain/cppduchain.cpp M +13 -5 languages/cpp/cppduchain/cppduchain.h M +52 -0 languages/cpp/tests/test_cppcodecompletion.cpp M +1 -0 languages/cpp/tests/test_cppcodecompletion.h http://commits.kde.org/kdevelop/3a546dd106794dc12ce0cf6893b02142f566d2b3
Moving all the bugs from the CPP Parser. It was not well defined the difference between it and C++ Language Support and people kept reporting in both places indistinctively