[cfe-users] Expr objects and Evaluate*

2016-08-01 Thread folkert via cfe-users
Hi, I have an Expr object. How can I know if I can invoke EvaluateAsBooleanCondition, EvaluateAsRValue, EvaluateAsInt and EvaluateAsFloat ? Because if I just call them on any Expr object, I get assertions like: llvm/tools/clang/include/clang/AST/Type.h:612: const clang::ExtQualsTypeCommonBase*

[cfe-users] traversing the ast using libtooling

2016-08-04 Thread folkert via cfe-users
Hi, When I want to walk over the complete ast and visit each node (by using a RecursiveASTVisitor<...>), do I need to implement all of TraverseDecl, TraverseStmt and TraverseType? Because with all of those it looks like some code is processed twice. Second question: there are other

[cfe-users] binary operator

2016-07-12 Thread folkert via cfe-users
Hi, When iterating through the AST I encounter BinaryOperator-s, part of an IfStmt. My question now is: how can I find which operator it is? E.g. ==, >=, etc. I'm using libclang. Folkert van Heusden -- -- Phone:

[cfe-users] diagnostics

2016-08-31 Thread folkert via cfe-users
Hi, Something strange is happening while parsing using std::unique_ptr au = clang::tooling::buildASTFromCodeWithArgs(code, arguments, llvm::Twine(argv[i])); I get a lot of errors and warning written to stderr (how can I stop that apart from redirecting fd 2 to /dev/null?) but the following

Re: [cfe-users] finding the source position (range) of a variable name

2016-09-14 Thread folkert via cfe-users
The problem can be reproduced with this small example code: http://files.slimwinnen.nl/n-nns.tgz Just run make and then ./parse and you'll see it saying that "! NO NestedNameSpecifier". The test-code is test.cpp and the file it parses is example.cpp. > > DeclarationNameInfo dni = fd ->

Re: [cfe-users] finding the source position (range) of a variable name

2016-09-14 Thread folkert via cfe-users
> DeclarationNameInfo dni = fd -> getNameInfo(); > SourceRange dniSr = dni.getSourceRange(); // dniSr is position and length of > name in source file > std::string name = dni.getName().getAsString(); // name of function/method > > But how can I get this information for variables? Both the name

[cfe-users] dissecting the type of a VarDecl

2016-09-16 Thread folkert via cfe-users
Hi, I have a VarDecl instance for which I want to dissect the type. E.g. a const int a would be a const, an int and the name a / std::vector would be namespace std, vector and so on. The first one is easy but the second one: I have no idea where to begin. Sofar I have the following: #include

[cfe-users] uniquely identifying names

2016-08-26 Thread folkert via cfe-users
Hi, The Sun java compiler allows you to (from java) walk the AST and investigate it. Each token is stored in an object. Each object has a hash() method which uniquely identifies it. Now I was wondering: can I do so with the LLVM tooling as well? I could of course if I want to identify e.g. a

[cfe-users] finding source-range of a macro-parameter name

2016-10-17 Thread folkert via cfe-users
Hi, Given: #define W(A) while(A) void myfunc() { W(1) { } } I would like retrieve a string for the "1" parameter of the while-macro. Usually I would use: Lexer::getSourceText(CharSourceRange::getCharRange(sr), sm, LangOptions(), 0); (with 'sr' being a SourceRange