There are multiple places in the parser which do something similar to
this:
Foo *ptr = 0;
if (...) {
Foo val = ...;
ptr = &val;
}
func(ptr);
In other words, the code takes a pointer to a local variable, and the
pointer is used even after the local variable's scope has ended.
This causes a crash on Linux. For some reason this works fine on Windows
+ Visual studio.
This patchs moves the variable ("val" in the above example) to outer
scopes, so that its life time is extended to cover the use.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
Fix trivial switch/case compile warnings like the one below by adding default
case where suitable, or adding the missing cases when that makes more sense.
enumerator 'LastPreprocessingDirective' in switch of enum 'clang::PreprocessedEntity::EntityKind' is not handled
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
Use forward declarations to avoid the need to include lots of clang headers.
This drops the compilation time for CppParser from 17.8 seconds to 14.1 seconds
for me.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
For an example of what can trigger it:
template<typename _CharT, typename _Traits = char_traits<_CharT>,
typename _Alloc = allocator<_CharT> >
class basic_string;
extern template class basic_string<char>;
Signed-off-by: Elias Holzer <elias@vvvv.org>
* Use clangIndex to identify declarations across translation units.
* Added new Find*ByUSR methods and removed unused Find*(IntPtr) methods.
* Added Depth/Index and IsParameterPack fields to TemplateParameterType.
* Fixed member initialization issues in C++ Method class.
* Added AST tests for function and class templates.
* All tests pass with new and old parser.
Fix the compilation warnings with gcc:
../../../src/CppParser/Parser.cpp: In member function ‘CppSharp::CppParser::AST::DeclarationContext*
CppSharp::CppParser::Parser::GetNamespace(clang::Decl*, clang::DeclContext*)’:
../../../src/CppParser/Parser.cpp:1119:68: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘llvm::StringRef’ [-Wformat=]
printf("Unhandled declaration context kind: %s\n", Kind);
^
../../../src/CppParser/Parser.cpp: In member function ‘CppSharp::CppParser::AST::Declaration* CppSharp::CppParser::Parser::WalkDeclaration(clang::Decl*, bool, bool)’:
../../../src/CppParser/Parser.cpp:2430:51: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘llvm::StringRef’ [-Wformat=]
Debug(" %s (line %u)\n", FileName, LineNo);
^
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
* Implemented missing parts in regards to class templates.
* Fixed couple of class member initialization issues in C++ AST classes.
* Make code more look alike so it's easier to compare them.
* All tests pass now with old and new parser. Especially the nasty STL one with the ostream typedef.
This fixes some non-deterministic behavior in the new parser but it means we are keeping around all the memory for parsing until the end of the process. This is a bit messy right now but at least we keep the API compatible between parsers. After all the new parser bugs are squashed, this will be reworked.
Clang reports a wrong source range for function parameters and since we already process them specially we should not process them in HandleDeclaration too, else we get duplicated entities.
Basically we need to lock in the MS inheritance model in a record when it appears as part of a member pointer type else we get some fun Clang code gen internals assert.