aboutsummaryrefslogtreecommitdiff
path: root/include/clang/AST/RecursiveASTVisitor.h
AgeCommit message (Collapse)Author
2010-08-30Revert my user-defined literal commits - r1124{58,60,67} pendingSean Hunt
some issues being sorted out. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112493 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-29Implement C++0x user-defined string literals.Sean Hunt
The extra data stored on user-defined literal Tokens is stored in extra allocated memory, which is managed by the PreprocessorLexer because there isn't a better place to put it that makes sure it gets deallocated, but only after it's used up. My testing has shown no significant slowdown as a result, but independent testing would be appreciated. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112458 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-25GCC didn't care for my attempt at API compatibility, so brute-force everythingJohn McCall
to the new constants. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112047 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-13Zap unused UnaryOperator::OffsetOf.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110996 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-10Added TypeLocs to VAArgExpr node.Abramo Bagnara
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110666 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-10Added TypeLocs to TypesCompatibleExpr node.Abramo Bagnara
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110663 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-31Iterate typeloc's for class bases.Nick Lewycky
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109961 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-28 Add proper callbacks for DeclStmt -- we weren't recursing onCraig Silverstein
the decls. This was just an oversight before; one we didn't catch because lots of information in a DeclStmt was also being traversed (redundantly) elsewhere. Once DeclStmt was cleaned up, I could clean up some of the redundant traversals found elswhere as well -- in particular, traversing the declarations inside a function as part of the function callback (instead of as part of the CompoundExpr callback that constitutes the body of the function). The old way was really weird, and led to some parts of local variable declarations (but not all) being visited twice. That is now resolved. I also was able to simplify the traversers for IfStmt/WhileStmt/etc, which used to have redundant calls to work around the fact DeclStmt wasn't working properly. While in the area, I fixed up a few more recursion-ordering issues. I try to hold to the principle that RecursiveASTVisitor visits objects in the source code in the same order they're typed. So the return-type of a variable comes before the variable-name. This still isn't perfect, but we're closer to that. Reviewed by chandlerc and wan. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109590 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-26Add source location information to C++ base specifiers.Nick Lewycky
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109396 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-22Don't crash when an explicit template instantiation has no user-writtenNick Lewycky
arguments. This happens in clang itself where template: template <typename T> T const *getAs(); gets specialized with: template<> inline clang::TypedefType const *getAs() { ... } and there's no TemplateArgumentList. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109127 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-16Fix typeid the same way I fixed sizeof. Sad I had missed it before.Craig Silverstein
Reviewed by chandlerc git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108557 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-16Fix up some of the visiting for array types -- we weren't good aboutCraig Silverstein
getting array indices before -- and for some of the builtin operators: sizeof, offsetof, unaryops like __is_enum. Also fix the function visitor to visit exception types in function parameters. Reviewed by wan and chandlerc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108533 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12We should not be recursing over the shadow definitions in UsingDecl --Craig Silverstein
they're not something the user typed (at least, not here). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108212 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-09Move traverseunqualifiedtypeloc over to the 'main' typeloc tree.Craig Silverstein
Note that this is a move -- we pretend that we were really looking at the unqualified typeloc all along -- rather than a recursion, so we don't follow the normal CRTP plan of going through getDerived().TraverseTypeLoc. If we did, we'd be traversing twice for the same type (once as a QualifiedTypeLoc version of the type, once as an UnqualifiedTypeLoc version of the type), which in effect means we'd call VisitTypeLoc twice with the 'same' type. This solves that problem, at the cost of never seeing the qualified version of the type (unless the client subclasses TraverseQualifiedTypeLoc themselves). It's not a perfect solution. A perfect solution probably requires making QualifiedTypeLoc a wrapper around TypeLoc -- like QualType is a wrapper around Type* -- rather than being its own class in the type hierarchy. Reviewed by wan. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107973 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-08Makes RecursiveASTVisitor traverse the type of a temporary objectZhanyong Wan
created via T() where T is a class type. Reviewed by chandlerc and csilvers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107911 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-08Reinstate the fix for PR7556. A silly use of isTrivial() wasDouglas Gregor
suppressing copies of objects with trivial copy constructors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107857 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-07Revert r107828 and r107827, the fix for PR7556, which seems to beDouglas Gregor
breaking bootstrap on Linux. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107837 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-07Rename CXXZeroInitValueExpr to CXXScalarValueInitExpr, to reflect itsDouglas Gregor
newly-narrowed scope. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107828 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-07Changes how the TypeLoc traverser invokes the Type traverser: before,Zhanyong Wan
VisitFooTypeLoc() calls VisitFooType(); now, TraverseFooTypeLoc() calls WalkUpFromFooType(). This allows clients that override WalkUpFromFooType() to continue to work. It also preserves the property that Visit*() in the base visitor class is a no-op (s.t. a subclass doesn't have to call Base::Visit*() when overriding Visit*()). Also fixes some typos in comments. Also added a missing getDerived() inside TraverseQualifiedTypeLoc(). The call is needed in case a subclass overrides TraverseTypeLoc(). Reviewed by nlewycky and csilvers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107816 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-07Avoid double-traversing for QualifiedTypeLoc -- we were callingCraig Silverstein
VisitTypeLoc twice for qualified types, once for the qualified form and once for the unqualified (though they looked the same by the time we got to visittypeloc). Now only visit once, which matches previous behavior. Reviewed by nlewycky git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107754 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-04Add TypeLoc traversal to the RecursiveASTVisitor! Because the TypeLocs don'tNick Lewycky
contain all the same information that their Types do, we will fall back to traversing the Types instead. The default TypeLoc visitor calls the matching Type visitor so that existing clients should continue to work with no change. Also adds element traversal to the ExtVectorType. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107592 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-02Make RecursiveASTVisitor traverse function parameter types in a functionZhanyong Wan
prototype declaration. Reviewed by chandlerc and csilvers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107511 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-02Don't visit implicitly defined functions (default constructors and theCraig Silverstein
like). Our goal with this visitor is to visit exactly what people type. Reviewed by chandlerc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107497 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-01Handle typedef function declarations correctly, such asCraig Silverstein
typedef int (*Myfunc)(int); Myfunc func; Reviewed by chandlerc git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107450 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30Fix RecursiveASTVisitor to traverse the ctor initializer list beforeZhanyong Wan
traversing the ctor body when traversing a CXXConstructorDecl. Reviewed by chandlerc and csilvers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107304 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-29A few prettifications. Also renamed TraverseInitializer toCraig Silverstein
TraverseConstructorInitializer, to be a bit clearer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107102 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-28Fix up ClassTemplateSpecializationDecl: For implicit instantiationsCraig Silverstein
("set<int> x;"), we don't want to recurse at all, since the instatiated class isn't written in the source code anywhere. (Note the instatiated *type* -- set<int> -- is written, and will still get a callback of TemplateSpecializationType). For explicit instantiations ("template set<int>;"), we do need a callback, since this is the only callback that's made for this instantiation. We use getTypeAsWritten() to distinguish. We will still need to figure out how to handle template specializations, which probably are still not quite correct. Reviewed by chandlerc git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107098 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-28Add support for traversing initializer lists (in constructors), whichCraig Silverstein
we ignoring before. To give access to the names on the initializer, which aren't a type or an expr or a decl, I've introduced a new TraverseInitializer. By default, it just traverses on the expr that the name is being initialized to. Reviewed by chandlerc. Tested via clang's 'make test'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107008 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17Improves RecursiveASTVisitor:Zhanyong Wan
* refactors code in DEF_TRAVERSE_DECL() into TraverseDeclContextHelper() to reduce code bloat and facilitate reuse. * makes the order of traversing a FunctionDecl (including its subclasses)'s children more natural: before the function parameters are visited after the function body; now they are visited after the function type and before the function body. * fixes a double count for function return type and arguments. Reviewed by chandlerc and csilvers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106236 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17Some fixes to type-visiting -- a few places where the type-name wasCraig Silverstein
explicitly typed in the source, but we weren't recursing on it. One is new <type>, the other is <type>() (eg int()). I also fixed the initializer parsing to parse on the syntactic initializer list, not the semantic. Usually they'll be identical, so this won't affect much in practice, but keeps the AST as a syntax-tree visitor. Reviewed by chandlerc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106218 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16Test commit by adding a blank comment line.Zhanyong Wan
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106114 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-11preprocessor directives in macro arguments aren't standard,Chris Lattner
hopefully this unbreaks msvc git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105826 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-11Add a few FIXMEs: recursing over shadow decls, and semantics vsCraig Silverstein
syntactic iterating over initializer exprs. No functional change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105825 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-11Improve readability with TRY_TO, remove a redundant comment, and fix one aspectChandler Carruth
of the recursion on VarDecls. Patch by Craig Silverstein. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105803 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-11Split DependentNameType into two types. DependentNameType represents theJohn McCall
case of an elaborated-type-specifier like 'typename A<T>::foo', and DependentTemplateSpecializationType represents the case of an elaborated-type-specifier like 'typename A<T>::template B<T>'. The TypeLoc representation of a DependentTST conveniently exactly matches that of an ElaboratedType wrapping a TST. Kill off the explicit rebuild methods for RebuildInCurrentInstantiation; the standard implementations work fine because the nested name specifier is computable in the newly-entered context. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105801 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-10Avoid repeating the list of operators twice in RecursiveASTVisitor throughChandler Carruth
a set of preprocessor macros. Patch by Zhanyong Wan. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105796 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-10Tweak a comment on the visitor to clarify one order of visit issue. Patch fromChandler Carruth
Zhanyong Wan. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105795 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-10Another chunk of the new RecursiveASTVisitor implementation: switch the returnChandler Carruth
value semantics such that we recurse while the visitors return true, and halt as soon as one returns false. Patch by csilvers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105787 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-09Major redesign of the RecursiveASTVisitor. This implements the majority of theChandler Carruth
new design discussed on cfe-dev, with further steps in that direction to come. It is already much more complete than the previous visitor. Patch by Zhanyong and Craig with 80 column wraps and one missing declaration added by me. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105709 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-30Convert DeclNodes to use TableGen.Sean Hunt
The macros required for DeclNodes use have changed to match the use of StmtNodes. The FooFirst enumerator constants have been named firstFoo to match usage elsewhere. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105165 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-21Outdent this file by 2 spaces per the coding standards, and also clean upNick Lewycky
whitespace at the end of lines since I'm already touching the whole file anyways. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104403 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-21Teach the RecursiveASTVisitor to enter parts of the AST previously missed.Chandler Carruth
Factor its implementation to ease the addition of these custom edges to traverse. With this patch we get initializer expressions, block bodies, type source info, and function argument, result, and exception types. There are probably still some more missed edges. While we're here, clean up and flesh out a bunch of comments. Patch by Zhanyong Wan; I've done a cursory review, but further review appreciated. This is fast becoming one of the most important public APIs to the AST. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104315 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-18Switch over the tablegen to use much prettier range technologySean Hunt
Also rename ABSTRACT to ABSTRACT_STMT, in keeping with the other .def files git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104017 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-17Add a 'Base' type to RecursiveASTVisitor to make recursing easier and documentNick Lewycky
how you're supposed to use it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103993 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-15Substantially alter the design of the Objective C type AST by introducingJohn McCall
ObjCObjectType, which is basically just a pair of one of {primitive-id, primitive-Class, user-defined @class} with a list of protocols. An ObjCObjectPointerType is therefore just a pointer which always points to one of these types (possibly sugared). ObjCInterfaceType is now just a kind of ObjCObjectType which happens to not carry any protocols. Alter a rather large number of use sites to use ObjCObjectType instead of ObjCInterfaceType. Store an ObjCInterfaceType as a pointer on the decl rather than hashing them in a FoldingSet. Remove some number of methods that are no longer used, at least after this patch. By simplifying ObjCObjectPointerType, we are now able to easily remove and apply pointers to Objective-C types, which is crucial for a certain kind of ObjC++ metaprogramming common in WebKit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103870 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-11Merged Elaborated and QualifiedName types.Abramo Bagnara
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103517 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-07When we encounter a non-dependent type during template instantiation,Douglas Gregor
mark any declarations we see inside of that type as "referenced". Fixes PR7079. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103323 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-07Introduce a recursive AST visitor that makes it trivial to recursivelyDouglas Gregor
walk an entire AST, including all of the types, declarations, statements, and expressions, and allowing one to easily override the behavior of the walk at any particular node kind. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103308 91177308-0d34-0410-b5e6-96231b3b80d8