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

42 Коммитов

Автор SHA1 Сообщение Дата
Daniel Dunbar bb3503a146 Document that CompilerInvocation::createDiagnostics keeps a reference to the DiagnosticOptions, and update callers to make sure they don't pass in a temporary.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90704 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-06 09:56:30 +00:00
Daniel Dunbar 5262fda30b Fix ASTUnit to allows require a (persistent) Diagnostic object be provided; propogate and simplify.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90379 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-03 01:45:44 +00:00
Daniel Dunbar 467f030960 Normalize CIndex/c-index-test/index-test link lines in the hopes it will fix
*something*.
 - We really need to fix how LLVM's build systems manage
   linking. Pretty-please-someone-else-do-this? :)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90350 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 21:47:55 +00:00
Daniel Dunbar 7b55668db7 Add ASTUnit::LoadFromCommandLine, which creates an ASTUnit out of a list of
(clang/driver) command line arguments (including the source file).
 - The arguments are expected to include the source file.

 - The idea is that even though this is a somewhat odd API, its the form which
   many tools can most easily use (for example, by interposing with the compiler).

Also, switch index-test's -ast-from-source to use this entry point, and provide
a -arg command line argument which can be used to test that the command line
arguments are handled correctly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90288 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 03:23:45 +00:00
Nuno Lopes 360f075fc6 fix build on linux
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90229 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-01 12:49:04 +00:00
Daniel Dunbar 521bf9c529 Add ASTUnit::LoadFromCompilerInvocation, which does what it says.
Also, add an -ast-from-source option to index-test which allows index-test to
run on source files directly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90223 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-01 09:51:01 +00:00
Steve Naroff 36c4464ba6 Move Diagnostic/DiagClient/FileManager from Indexer => ASTUnit.
Removing this shared data should enable clang_createTranslationUnit/clang_createTranslationUnitFromSourceFile to be run from multiple threads (related to <rdar://problem/7303432>).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84499 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-19 14:34:22 +00:00
Argyrios Kyrtzidis f4526e3fd4 Modify ASTLocation and apart from being a Decl or Stmt, allow it to also be:
-A NamedDecl reference
-A TypeLoc

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83095 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-29 19:44:27 +00:00
Daniel Dunbar 31b87d8006 Change ASTUnit to take the Diagnostic as an argument, the client should have control of this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82430 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 03:03:39 +00:00
Daniel Dunbar a39075952c Add Diagnostic to Indexer, and have it keep its own FileManager instead of taking an external reference (which was leaked in the case of the CIndex library).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82429 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 03:03:22 +00:00
Mike Stump 1eb4433ac4 Remove tabs, and whitespace cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81346 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-09 15:08:12 +00:00
Steve Naroff 50398199fb Lot's of little changes to get the C-based indexing API going...
Work in progress.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80367 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-28 15:28:48 +00:00
Daniel Dunbar 8165ced072 Don't install wpa or index-test tools.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79557 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-20 18:45:52 +00:00
Chris Lattner 797c3c4f5d fix a couple of problems with section attributes:
1. Passing something that isn't a string used to cause:
   "argument to annotate attribute was not a string literal"
  make it say "section attribute" instead.

2. Fix the location of the above message to point to the
   bad argument instead of the section token.

3. Implement rdar://4341926, by diagnosing invalid section
   specifiers in the frontend rather than letting them slip all
   the way to the assembler (a QoI win).

An example of #3 is that we used to produce something like this:

/var/folders/n7/n7Yno9ihEm894640nJdSQU+++TI/-Tmp-//ccFPFGtT.s:2:Expected comma after segment-name
/var/folders/n7/n7Yno9ihEm894640nJdSQU+++TI/-Tmp-//ccFPFGtT.s:2:Rest of line ignored. 1st junk character valued 46 (.).

Daniel improved clang to use llvm_report_error, so now we got:

$ clang t.c -c
fatal error: error in backend: Global variable 'x' has an invalid section specifier 'sadf': mach-o section specifier
      requires a segment and section separated by a comma.

with no loc info.  Now we get:

$ clang t.c -fsyntax-only
t.c:4:30: error: argument to 'section' attribute is not valid for this target: mach-o section specifier requires a segment
      and section separated by a comma
int x __attribute__((section("sadf")));
                             ^

which is nice :)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78586 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-10 19:03:04 +00:00
Argyrios Kyrtzidis 19b732a546 Add support for ObjC message expressions, in the Analyzer:
-Accept an ObjC method and find all message expressions that this method may respond to.
-Accept an ObjC message expression and find all methods that may respond to it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77551 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-30 00:03:55 +00:00
Argyrios Kyrtzidis 87bcb504f6 Support ObjC methods as Entities.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77547 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 23:41:46 +00:00
Argyrios Kyrtzidis 0f3984809f Add TranslationUnit::getSelectorMap().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77542 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 23:41:08 +00:00
Argyrios Kyrtzidis 7f4656eb6b -Introduce the idx::Analyzer class used for getting indexing information, like finding
references of a declaration across translation units.

-Modify the index-test tool to use it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77536 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 23:40:14 +00:00
Argyrios Kyrtzidis 768a6c94a5 Add getDeclReferenceMap() to the abstract interface of TranslationUnit class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77530 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 23:39:18 +00:00
Argyrios Kyrtzidis 94431b5b4c Introduce a helper template for the Handler classes and use it instead
of the iterator of the Indexer class.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77528 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 23:39:03 +00:00
Argyrios Kyrtzidis b17dc46c79 -Make IndexProvider an abstract interface for getting indexing information.
-Introduce Indexer as an IndexProvider implementation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77524 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 23:38:21 +00:00
Argyrios Kyrtzidis f7cf15ca3c Change the semantics for Entity.
Entity can now refer to declarations that are not visible outside the translation unit.
It is a wrapper of a pointer union, it's either a Decl* for declarations that don't
"cross" translation units, or an EntityImpl* which is associated with the specific "visible" Decl.

Included is a test case for handling fields across translation units.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76515 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-21 00:07:06 +00:00
Argyrios Kyrtzidis ec930d3d81 Add '\n' to the end of error message.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76506 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-21 00:05:10 +00:00
Argyrios Kyrtzidis dc50c64c13 Introduce ASTLocation::getReferencedDecl(), for getting the declaration that the ASTLocation references.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76336 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 21:17:58 +00:00
Argyrios Kyrtzidis 1e4bc09988 Introduce a redecl_iterator in Decl class, so that we can do a "iterate over all declarations of the same decl" without knowing the exact type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76298 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-18 08:50:35 +00:00
Argyrios Kyrtzidis c7377632d0 Handle redeclarations properly at the index-test tool.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75605 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 03:20:31 +00:00
Argyrios Kyrtzidis be125444cf For index-test, if the ASTLocation points at a CallExpr, get a Decl out of it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75599 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 03:19:30 +00:00
Argyrios Kyrtzidis 12585542f5 Handle struct fields through the index-test tool.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75596 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-14 03:18:40 +00:00
Zhongxing Xu 96bac6b48e Fix comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74896 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-07 07:14:55 +00:00
Argyrios Kyrtzidis 44994051ca Use the "ASTLocation nomenclature" (instead of the ASTNode one) in index-test.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74863 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 21:35:26 +00:00
Argyrios Kyrtzidis 755c6b4215 Some changes to ASTLocation's methods
-Change hasStmt() to isStmt()
-Add isDecl()
-Add getSourceRange()

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74862 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 21:35:20 +00:00
Argyrios Kyrtzidis 818e15b89f Move the 'ResolveLocationInAST' function from the Frontend library to the Index library.
Also, cut down its comments; more comments will be added to ASTLocation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74860 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 21:35:02 +00:00
Argyrios Kyrtzidis ccbcb70ee9 Move ASTLocation and DeclReferenceMap from the AST library to the Index library.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74859 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 21:34:47 +00:00
Argyrios Kyrtzidis 874012b1fb Rename 'ASTNode' -> 'ASTLocation'.
ASTLocation is a much better name for its intended purpose which to represent a "point" into the AST.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74858 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 21:34:20 +00:00
Argyrios Kyrtzidis 7b332d9ada Make use of the Index library through the index-test tool.
'index-test' is now able to provide additional info for a Decl, through multiple AST files:
-Find declarations
-Find definitions
-Find references

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74803 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-05 22:22:35 +00:00
Argyrios Kyrtzidis 49dd5851c4 Make use of ASTNode for return value of clang::ResolveLocationInAST() and in the index-test tool.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74798 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-05 22:21:40 +00:00
Douglas Gregor 2e22253e03 Add support for retrieving the Doxygen comment associated with a given
declaration in the AST. 

The new ASTContext::getCommentForDecl function searches for a comment
that is attached to the given declaration, and returns that comment, 
which may be composed of several comment blocks.

Comments are always available in an AST. However, to avoid harming
performance, we don't actually parse the comments. Rather, we keep the
source ranges of all of the comments within a large, sorted vector,
then lazily extract comments via a binary search in that vector only
when needed (which never occurs in a "normal" compile).

Comments are written to a precompiled header/AST file as a blob of
source ranges. That blob is only lazily loaded when one requests a
comment for a declaration (this never occurs in a "normal" compile). 

The indexer testbed now supports comment extraction. When the
-point-at location points to a declaration with a Doxygen-style
comment, the indexer testbed prints the associated comment
block(s). See test/Index/comments.c for an example.

Some notes:
  - We don't actually attempt to parse the comment blocks themselves,
  beyond identifying them as Doxygen comment blocks to associate them
  with a declaration.
  - We won't find comment blocks that aren't adjacent to the
  declaration, because we start our search based on the location of
  the declaration.
  - We don't go through the necessary hops to find, for example,
  whether some redeclaration of a declaration has comments when our
  current declaration does not. Similarly, we don't attempt to
  associate a \param Foo marker in a function body comment with the
  parameter named Foo (although that is certainly possible).
  - Verification of my "no performance impact" claims is still "to be
  done".



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74704 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-02 17:08:52 +00:00
Chris Lattner e4f2142d00 Key decisions about 'bool' vs '_Bool' to be based on a new flag in langoptions.
This is simple enough, but then I thought it would be nice to make PrintingPolicy
get a LangOptions so that various things can key off "bool" and "C++" independently.
This spiraled out of control.  There are many fixme's, but I think things are slightly
better than they were before.

One thing that can be improved: CFG should probably have an ASTContext pointer in it,
which would simplify its clients.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74493 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 01:26:17 +00:00
Argyrios Kyrtzidis 512230c49b Remove redundant leftover code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74433 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-29 17:38:09 +00:00
Argyrios Kyrtzidis 119b7feb01 Check that index-test uses an up-to-date AST file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74214 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 22:15:12 +00:00
Argyrios Kyrtzidis 6e4a86ddad Add some comments and clean-up some leftover code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74207 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 21:54:50 +00:00
Argyrios Kyrtzidis 30b983b5b3 Introduce tools/index-test.
This tool will be the test bed for indexing related operations. It basically reads PCH files passed by the command line and performs various operations.

Currently it can accept a file:line:column which resolves to a declaration/statement and displays some information about them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74198 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 18:22:52 +00:00