[cfe-users] finding in which function/method/scope a Decl is in, the parent so to say

2016-11-11 Thread folkert via cfe-users
Hi, How can I find the parent of a VarDecl? The scope it is in. E.g. function/method or a global. Folkert van Heusden ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

Re: [cfe-users] the case of the missing label in the switch/case

2016-11-09 Thread folkert via cfe-users
The problem is that you were using CaseStmt::getRHS instead of CaseStmt::getSubStmt. No idea what getRHS is supposed to return then. On Wed, Nov 09, 2016 at 09:53:28AM +0100, folkert via cfe-users wrote: > Hi, > > I maybe very well not understanding something but it looks lik

[cfe-users] the case of the missing label in the switch/case

2016-11-09 Thread folkert via cfe-users
Hi, I maybe very well not understanding something but it looks like a label targetted by a goto, in a switch statement, gets missing: if I iterate through the ast and emit all the stmt/expr/decls, then no label-type is emitted. #include void myfunc(int a) { switch(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 and

[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 #

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 -> getNameInf

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 a

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

2016-09-13 Thread folkert via cfe-users
Hi, Finding the name and position of a function/method is easy: 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

[cfe-users] splitting a type

2016-09-08 Thread folkert via cfe-users
Hi, When I retrieve CastExpr::getType().getAsString() then I can get something like: const mytype_t *const ** Can I also somehow retrieve this tokenized? Folkert van Heusden -- -- Phone: +31-6-41278122, PGP-key: 1F28D8AE, ww

[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 doe

Re: [cfe-users] uniquely identifying names

2016-08-31 Thread folkert via cfe-users
ch time it defines a > >> > different function, but all those functions would appear to be defined on > >> > the same line/file of that included file - or a macro that defines > >> > multiple > >> > functions - both can be resolved by looking at

Re: [cfe-users] uniquely identifying names

2016-08-30 Thread folkert via cfe-users
tions, etc)) > > On Fri, Aug 26, 2016 at 5:11 AM folkert via cfe-users < > cfe-users@lists.llvm.org> wrote: > > > 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

[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 func

[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 Traverse...-me

[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* c

[cfe-users] parsing a windows source

2016-07-21 Thread folkert via cfe-users
Hi, I would like to parse a windows source. Using clang/llvm and preferably under Linux. I'm using: std::vector arguments; arguments.push_back("-fms-compatibility"); arguments.push_back("-fms-extensions"); arguments.push_back("-Wno-error=invalid-token-paste");

Re: [cfe-users] link order for libtooling

2016-07-15 Thread folkert via cfe-users
gt; return rso.str(); > } > > It shoudl work for any C or C++ declaration. > > Thank you, > > [0] https://github.com/esbmc/esbmc > [1] > https://github.com/esbmc/esbmc/blob/master/scripts/build-aux/m4/ax_clang.m4 > [2] > https://github.com/esbmc/esbmc/blob/master/s

[cfe-users] link order for libtooling

2016-07-14 Thread folkert via cfe-users
Hi, What is the order of the clang libraries when linking? Currently I'm doing: clang++ -fno-rtti `llvm-config --cxxflags` \ iterate.cpp \ `llvm-config --ldflags --libs --system-libs` \ -I/usr/lib/llvm-3.8/include -ggdb3 -std=c++11 -I/usr/include/llvm-3.8/llvm/Support -L

Re: [cfe-users] binary operator

2016-07-13 Thread folkert via cfe-users
> > 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. > > > > You can call BinaryOperator::getOpcode, which will return an Opcode, > which is a typedef of th

Re: [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. > > You can call BinaryOperator::getOpcode, which will return an Opcode, > which is a typedef of t

[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: +31-6-4127812