The enum PrimitiveType represents, according to the comment, "the C++
built-in types.". However, it does not contain values for C++'s "long"
or "unsigned long", and the parser converts long to int. This is not
correct, and is a problem with 64bit support.
This patch adds Long and ULong values to PrimitiveType, and adds those
to all the switch-cases all around the code. For now Long and ULong are
handled exactly like Int and UInt, so this patch does not change
behavior.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
C++ types cannot be converted to C# types without knowing details of the
target (e.g. what is the size of "long") and
PrimitiveTypeExtensions.ConvertToType does not handle that correctly.
However, ConvertToType is not used anywhere, so let's just remove it so
that no one will use the method.
We could also fix the method, but it's an extension method for
PrimitiveType, and I don't think such an extension method should be used
for the task, as you would also need to pass it information about the
target system.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
Fix the following warning by renaming ParserResult::Parser to
CodeParser.
In file included from ../../../src/CppParser/Parser.h:16:0,
from ../../../src/CppParser/Comments.cpp:8:
../../../src/CppParser/CppParser.h:86:13: warning: declaration of ‘CppSharp::CppParser::Parser* CppSharp::CppParser::ParserResult::Parser’ [-fpermissive]
Parser* Parser;
^
../../../src/CppParser/CppParser.h:73:8: warning: changes meaning of ‘Parser’ from ‘struct CppSharp::CppParser::Parser’ [-fpermissive]
struct Parser;
^
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
Fix the following warning by renaming RawComment::FullComment to
FullCommentBlock.
In file included from ../../../src/CppParser/AST.cpp:8:0:
../../../src/CppParser/AST.h:783:18: warning: declaration of ‘CppSharp::CppParser::AST::FullComment* CppSharp::CppParser::AST::RawComment::FullComment’ [-fpermissive]
FullComment* FullComment;
^
../../../src/CppParser/AST.h:760:15: warning: changes meaning of ‘FullComment’ from ‘struct CppSharp::CppParser::AST::FullComment’ [-fpermissive]
struct CS_API FullComment : public Comment
^
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
Fix the following warning by renaming RawComment::RawCommentKind to
Kind.
In file included from ../../../src/CppParser/AST.cpp:8:0:
../../../src/CppParser/AST.h:780:20: warning: declaration of ‘CppSharp::CppParser::AST::RawCommentKind CppSharp::CppParser::AST::RawComment::RawCommentKind’ [-fpermissive]
RawCommentKind RawCommentKind;
^
../../../src/CppParser/AST.h:765:13: warning: changes meaning of ‘RawCommentKind’ from ‘enum class CppSharp::CppParser::AST::RawCommentKind’ [-fpermissive]
enum struct RawCommentKind
^
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
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>
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>
DriverOptions.Is32Bit is used to decide whether to use 4 or 8 byte
pointer size in VTable calculations.
Instead of having a settable Is32Bit property, use
TargetInfo.PointerWidth for this. This allows us to remove the whole
Is32Bit property, and the IS_64_BIT define.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
Fix the following warning by removing the new keyword:
src/AST/Type.cs(230,25): warning CS0109: The member `CppSharp.AST.PointerType.IsReference' does not hide an inherited member. The new keyword is not required
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
Fix the following warning:
ParserGen.cs(208,26): warning CS0618: `CppSharp.AST.Declaration.Ignore' is obsolete: `Replace set by ExplicitlyIgnore(). Replace get by GenerationKind == GenerationKind.None.'
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
Move windows bindings to i686-pc-win32, the same way as osx bindings are
(and linux bindings will be).
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
Linux is case-sensitive with filenames, and as the NUnit library files
are lowercase, we need to use lowercase in the build files also.
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.
Normalized all the line endings with:
git rm --cached -r .
git reset --hard
git add .
git commit -m "Normalize all the line endings"
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
Fix the following warnings:
../../../src/CppParser/CppParser.cpp: In destructor ‘CppSharp::CppParser::ParserResult::~ParserResul
t()’:
../../../src/CppParser/CppParser.cpp:49:12: warning: possible problem detected in invocation of dele
te operator: [enabled by default]
delete Parser;
^
../../../src/CppParser/CppParser.cpp:49:12: warning: invalid use of incomplete type ‘struct CppSharp::CppParser::Parser’ [enabled by default]
In file included from ../../../src/CppParser/CppParser.cpp:8:0:
../../../src/CppParser/CppParser.h:73:8: warning: forward declaration of ‘struct CppSharp::CppParser::Parser’ [enabled by default]
struct Parser;
^
../../../src/CppParser/CppParser.cpp:49:12: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined
delete Parser;
^
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
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.