Граф коммитов

210 Коммитов

Автор SHA1 Сообщение Дата
Manuel Klimek e579328ec9 Insert interception point onStartOfTranslationUnit.
Often users of the ASTMatchers want to add tasks that are done once per
translation unit, for example, cleaning up caches. Combined with the
interception point for the end of source file one can add to the factory
creation, this covers the cases we've seen users need.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167271 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-02 01:31:03 +00:00
Argyrios Kyrtzidis cfa1caa926 Make the FilenameRange of the InclusionDirective callback more accurate,
preserve the macro location of the range end if the filename came from a macro.

Patch by Kim Gräsman!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167239 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-01 17:52:58 +00:00
Daniel Jasper d1ce3c178b Implement descendant matchers for NestedNamespecifiers
This implements has(), hasDescendant(), forEach() and
forEachDescendant() for NestedNameSpecifier and NestedNameSpecifierLoc
matchers.

Review: http://llvm-reviews.chandlerc.com/D86

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167017 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-30 15:42:00 +00:00
Daniel Jasper 452abbc76b Fix ASTMatchersTests to not create an overloaded-virtual warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166921 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-29 10:48:25 +00:00
Daniel Jasper a267cf6f87 Implement has(), hasDescendant(), forEach() and forEachDescendant() for
Types, QualTypes and TypeLocs.

Review: http://llvm-reviews.chandlerc.com/D83

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166917 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-29 10:14:44 +00:00
NAKAMURA Takumi d9a2d5bdb7 unittests/ToolingTest.cpp: Suppress newFrontendActionFactory.InjectsEndOfSourceFileCallback on Win32 for now. Investigating.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166674 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-25 09:38:41 +00:00
Manuel Klimek 9fb6b27e6d Adds the possibility to inject a callback that's called after each translation unit is processed.
This is important when one wants to deduplicate results during one run over a translation unit by pointer identity of AST nodes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166671 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-25 08:49:11 +00:00
Douglas Gregor 36a16498ff Teach the preprocessor to hold onto the preprocessor options.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166599 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24 17:46:57 +00:00
Douglas Gregor b0985c86f7 Update unit tests for HeaderSearch change
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166584 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24 16:24:38 +00:00
Manuel Klimek 3e2aa99e99 Adds the possibility to run ASTMatchFinder over arbitrary AST nodes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166567 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24 14:47:44 +00:00
Douglas Gregor f27762b1be Tweak include order
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166521 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-23 23:13:50 +00:00
Douglas Gregor 99eb4a7920 Buildbot debugging is fun
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166516 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-23 22:55:10 +00:00
Douglas Gregor 16a4abf5d9 One last unit-test fix
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166513 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-23 22:43:37 +00:00
Douglas Gregor 3aeb34f563 More unit-test fixes
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166511 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-23 22:38:58 +00:00
Douglas Gregor 8e02361163 Fixup unit tests for DiagnosticOptions change
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166509 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-23 22:31:51 +00:00
Daniel Jasper c711af2ddb Make hasDeclaration() matcher work inside the memberExpr() matcher.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166479 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-23 15:46:39 +00:00
Manuel Klimek 70b9db9879 Implements the thisExpr matcher.
Patch by Gabor Horvath.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166477 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-23 10:40:50 +00:00
Daniel Jasper c99a3ad8c2 Implement hasParent()-matcher.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166421 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-22 16:26:51 +00:00
Fariborz Jahanian 262e60c1cc [doc parsing] use getParamName to access parameter
for current(rewritten) comment and getParamNameAsWritten
to access param name coming with \param marker.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166231 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-18 21:42:42 +00:00
Fariborz Jahanian a7a68b61e8 Patch for decl printer test of objective-c methods.
Patch by Dmitri Gribenko.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166209 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-18 19:12:17 +00:00
Daniel Jasper 1802daf853 Fix tests, which accidentally matched implicit code on specific
platforms to make buildbots happy.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166100 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-17 13:35:36 +00:00
Daniel Jasper ce62007526 First version of matchers for Types and TypeLocs.
Review: http://llvm-reviews.chandlerc.com/D47

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166094 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-17 08:52:59 +00:00
Douglas Gregor 07f8cf4ec3 Fix the handling of target options in our unit tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166079 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-17 00:11:35 +00:00
Fariborz Jahanian 6553c686cb structured document comment: patch to provide comment for overriding function
template when comment is comming from overridden declaration. 
// rdar://12378793


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165953 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-15 18:58:50 +00:00
Fariborz Jahanian bf967be66e [Doc parsing] This patch searches overridden objc/c++
methods looking for documentation on a particular base
class inherited by any method that overrides the base class.
In case of redeclaration, as when objc method is defined
in the implementation, it also looks up for documentation
in class/class extension being redeclared.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165643 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-10 18:34:52 +00:00
Daniel Jasper 3201da38bd CompilationDatabaseTest: Fix another Windows path issue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165425 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-08 20:32:51 +00:00
Daniel Jasper 8a5e8c35e1 CompilationDatabase: Use //net paths for tests, as they should be
considered absolute on all platforms.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165422 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-08 20:08:25 +00:00
Daniel Jasper 2dbe2fa7eb FileNameMatchTrie: Use StringRef instead of Twines where possible.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165412 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-08 18:31:54 +00:00
Daniel Jasper d3420c906e Support symlinks and relative paths in complilation databases.
Review: http://llvm-reviews.chandlerc.com/D30

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165392 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-08 16:08:15 +00:00
Daniel Jasper 1a00fee393 Fix ASTMatchersTests in configurations where
"#include <initializer_list>" is unavailable for whatever reason.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164944 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-01 15:05:34 +00:00
Daniel Jasper 31f7c08a0d Add matchers for selected C++11 features.
Patch by Gábor Horváth.
Review: http://llvm-reviews.chandlerc.com/D46

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164943 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-01 13:40:41 +00:00
Daniel Jasper aaa8e45b8e Fix refersToDeclaration()-matcher and add missing test case. This was
broken as of r164656 as TemplateArgument::getAsDecl() now asserts
instead of returning NULL for other template arugment kinds.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164896 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-29 15:55:18 +00:00
Dmitri Gribenko 1952354bd3 Move the 'find macro by spelling' infrastructure to the Preprocessor class and
use it to suggest appropriate macro for __attribute__((deprecated)) in
-Wdocumentation-deprecated-sync.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164892 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-29 11:40:46 +00:00
NAKAMURA Takumi 11e141d616 unittests/AST/StmtPrinterTest.cpp: Suppress a LP64-assumed test, "0x100000000i128 => 4294967296L", for now.
LONG_MAX is 2147483647L on common 32 bit and LLP64 (Windows x64).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164478 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-24 00:34:18 +00:00
Dmitri Gribenko 525394e6c2 As a followup for r164303, add some tests for printing literals that test
printing directly rather than through a complicated machinery of ObjC rewriter.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164477 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-23 20:29:07 +00:00
Daniel Jasper b54b7646b2 Add some matchers for basic AST nodes.
Patch by Gábor Horváth.
Review: http://llvm-reviews.chandlerc.com/D45

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164304 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-20 14:12:57 +00:00
Daniel Jasper 08f0c53175 Fix isDerivedFrom matcher.
Without this patch, the isDerivedFrom matcher asserts in the
"assert(ClassDecl != NULL);" in the new test, as a
DependentTemplateSpecilizationType is not a sub-type of
TemplateSpecializationType and also does not offer getAsCXXRecordDecl().

I am not sure why this did not cause problems before. It is now (after
the changed implementation of isDerivedFrom) easier to write a matcher
that actually gets into this branch of the code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164127 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-18 14:17:42 +00:00
Daniel Jasper e6d2a96cc9 Add missing matcher for C-style cast expressions.
Patch by Gábor Horváth.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164123 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-18 13:36:17 +00:00
Daniel Jasper 3680b4f749 Make all VariadicDynCast-Expr-matchers StatementMatchers
Having Expr-subclass-matchers being VariadicDynCast-Expr-matchers does
not provide additional type safety and just makes using them harder. In
the clang AST, expressions are always statements and an expression
matcher can be used anywhere, a statement matcher is expected. Any given
matcher definition still has at least one noun.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164121 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-18 13:09:13 +00:00
Dmitri Gribenko 8c05da3fd8 Comment parsing: don't parse comment marker followed by a digit as a command
since no Doxygen command starts with a digit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163909 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-14 16:35:35 +00:00
Daniel Jasper a756443319 Create initial support for matching and binding NestedNameSpecifier(Loc)s.
Review: http://llvm-reviews.chandlerc.com/D39

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163794 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-13 13:11:25 +00:00
Daniel Jasper 63d88728d8 Rename isA to isSameOrDerivedFrom.
There are two evils we can choose from:
- Name overlap between isA-matcher and llvm::isa<>()
- Bad name for what the isA-matcher currently does

After some discussion we have agreed to go with the latter evil.

Review: http://llvm-reviews.chandlerc.com/D40

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163740 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-12 21:14:15 +00:00
Dmitri Gribenko e4330a302a Comment AST: TableGen'ize all command lists in CommentCommandTraits.cpp.
Now we have a list of all commands.  This is a good thing in itself, but it
also enables us to easily implement typo correction for command names.

With this change we have objects that contain information about each command,
so it makes sense to resolve command name just once during lexing (currently we
store command names as strings and do a linear search every time some property
value is needed).  Thus comment token and AST nodes were changed to contain a
command ID -- index into a tables of builtin and registered commands.  Unknown
commands are registered during parsing and thus are also uniformly assigned an
ID.  Using an ID instead of a StringRef is also a nice memory optimization
since ID is a small integer that fits into a common bitfield in Comment class.

This change implies that to get any information about a command (even a command
name) we need a CommandTraits object to resolve the command ID to CommandInfo*.
Currently a fresh temporary CommandTraits object is created whenever it is
needed since it does not have any state.  But with this change it has state --
new commands can be registered, so a CommandTraits object was added to
ASTContext.

Also, in libclang CXComment has to be expanded to include a CXTranslationUnit
so that all functions working on comment AST nodes can get a CommandTraits
object.  This breaks binary compatibility of CXComment APIs.

Now clang_FullComment_getAsXML(CXTranslationUnit TU, CXComment CXC) doesn't
need TU parameter anymore, so it was removed.  This is a source-incompatible
change for this C API.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163540 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-10 20:32:42 +00:00
Daniel Jasper 76dafa7e64 Change the behavior of the isDerivedFrom-matcher to not match on the
class itself. This caused some confusion (intuitively, a class is not
derived from itself) and makes it hard to write certain matchers, e.g.
"match and bind any pair of base and subclass".

The original behavior can be achieved with a new isA-matcher.  Similar
to all other matchers, this matcher has the same behavior and name as
the corresponding AST-entity - in this case the isa<>() function.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163385 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-07 12:48:17 +00:00
Manuel Klimek 579b120038 Implements hasAncestor.
Implements the hasAncestor matcher. This builds
on the previous patch that introduced DynTypedNode to build up
a parent map for an additional degree of freedom in the AST traversal.

The map is only built once we hit an hasAncestor matcher, in order
to not slow down matching for cases where this is not needed.

We could implement some speed-ups for special cases, like building up
the parent map as we go and only building up the full map if we break
out of the already visited part of the tree, but that is probably
not going to be worth it, and would make the code significantly more
complex.

Major TODOs are:
- implement hasParent
- implement type traversal
- implement memoization in hasAncestor

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163382 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-07 09:26:10 +00:00
Manuel Klimek a78d0d6203 Introduces DynTypedMatcher as a new concept that replaces the UntypedBaseMatcher and TypedMatcher.
Due to DynTypedNode the basic dynamically typed matcher interface can now be simplified.

Also switches the traversal interfaces to use DynTypedNode;
this is in preperation for the hasAncestor implementation, and
also allows us to need fewer changes when we want to add new
nodes to traverse, thus making the code a little more decoupled.

Main design concerns: I went back towards the original design
of getNodeAs to return a pointer, and switched DynTypedNode::get
to always return a pointer (in case of value types like QualType
the pointer points into the storage of DynTypedNode, thus allowing
us to treat all the nodes the same from the point of view of a
user of the DynTypedNodes.

Adding the QualType implementation for DynTypedNode was needed
for the recursive traversal interface changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163212 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-05 12:12:07 +00:00
Ted Kremenek 305c613af6 Split library clangRewrite into clangRewriteCore and clangRewriteFrontend.
This is similar to how we divide up the StaticAnalyzer libraries to separate
core functionality to what is clearly associated with Frontend actions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163050 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-01 05:09:24 +00:00
Dmitri Gribenko af503a6f21 Remove the useless CommentOptions class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162986 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-31 10:35:30 +00:00
Dmitri Gribenko 976f118dc5 DeclPrinter tests: simplify the code by using the new runToolOnCodeWithArgs
function from Tooling.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162976 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-31 03:23:26 +00:00
Dmitri Gribenko 44470efba5 DeclPrinter tests: since now some platforms use C++11 by default, make it
explicitly visible in test cases which language variant is used.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162974 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-31 03:05:44 +00:00