Commit Graph

7090 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis fe37cc831b Introduce the 'Index' library.
Its purpose is to provide the basic infrastructure for cross-translation-unit analysis like indexing, refactoring, etc.

Currently it is very "primitive" and with no type-names support. It can provide functionality like
"show me all references of this function from these translation units".

llvm-svn: 74802
2009-07-05 22:22:19 +00:00
Argyrios Kyrtzidis e568a9792f Introduce the DeclReferenceMap class inside the AST library.
DeclReferenceMap (similar to ParentMap) is a helper class for mapping Decls to the AST nodes that reference them.
A client will initialize it by passing an ASTContext to its constructor and later use it to iterate over
the references of a Decl.
References are mapped and retrieved using the primary declaration (Decl::getPrimaryDecl()) of a particular Decl.

llvm-svn: 74801
2009-07-05 22:22:06 +00:00
Argyrios Kyrtzidis 02dd4f9389 Introduce the virtual method Decl::getPrimaryDecl().
When a Decl subclass can have multiple re-declarations in the same declaration context (like FunctionDecl),
getPrimaryDecl() will return a particular Decl that all of them will point to as the "primary" declaration.

llvm-svn: 74800
2009-07-05 22:21:56 +00:00
Argyrios Kyrtzidis cdfe1f210b Avoid re-checking the parameters of a function, when trying to resolve a location.
llvm-svn: 74799
2009-07-05 22:21:46 +00:00
Argyrios Kyrtzidis a4d36d5a58 Make use of ASTNode for return value of clang::ResolveLocationInAST() and in the index-test tool.
llvm-svn: 74798
2009-07-05 22:21:40 +00:00
Argyrios Kyrtzidis 97e10d64e8 Introduce ASTNode class into the AST library.
ASTNode is an immutable pair of a Decl and Stmt. If Stmt is not null, Decl should be its immediate parent.

llvm-svn: 74797
2009-07-05 22:21:28 +00:00
Argyrios Kyrtzidis 62afb198be Do an early check for function definition.
llvm-svn: 74796
2009-07-05 22:21:17 +00:00
Eli Friedman e3aa454e2f Per PR4506, fix the type of size_t on OpenBSD.
llvm-svn: 74795
2009-07-05 18:47:56 +00:00
Sebastian Redl 4f4d7b5d8e Catch function redeclarations with incompatible exception specifications.
llvm-svn: 74787
2009-07-04 11:39:00 +00:00
Fariborz Jahanian bacbed9d75 This fixes the case where the wrong symbol is emitted leading to linking errors when you reference a class before defining it (GNU runtime).
Patch by David Chisnall.

llvm-svn: 74772
2009-07-03 15:10:14 +00:00
Zhongxing Xu 61e6692993 remove utility methods that are not very useful.
llvm-svn: 74762
2009-07-03 06:11:41 +00:00
Eli Friedman fb36b02591 Add an intermediate typedef for __builtin_va_tag to make it a bit easier
to deal with for AST pretty-printing/rewriting.  Patch by Abramo 
Bagnara.

llvm-svn: 74752
2009-07-03 00:45:06 +00:00
Ted Kremenek 194f46a11a Remove unused method.
llvm-svn: 74751
2009-07-03 00:41:09 +00:00
Ted Kremenek 24c8513022 BasicStoreManager: Use SymbolManager::canSymbolicate() to determine if a variable can be symbolicated.
llvm-svn: 74750
2009-07-03 00:36:16 +00:00
Ted Kremenek 0b0f206efa Fix a horrible CFG bug reported in <rdar://problem/7027684>. The wrong successor
block would get hooked up in some cases when processing empty compound
statements.

llvm-svn: 74743
2009-07-03 00:10:50 +00:00
Ted Kremenek 06cc0e31b2 Replace guarded calls in RegionStoreManager to
ValueManager::getRegionValueSymbolVal() with unguarded calls to
ValueManager::getRegionValueSymbolValOrUnknown(). This changes centralizes the
decision of what values to symbolicate in SymbolManager rather than having it
scatter in RegionStoreManager.

llvm-svn: 74730
2009-07-02 22:16:42 +00:00
Ted Kremenek 725b4a3a51 Enhance RegionStore to lazily symbolicate fields and array elements for
structures passed-by-value as function arguments.

llvm-svn: 74729
2009-07-02 22:02:15 +00:00
Fariborz Jahanian 9fa077c626 Patch to allocate list of bases in CXXRecordDecl
using ASTContxt allocation.

llvm-svn: 74717
2009-07-02 18:26:15 +00:00
Ted Kremenek df67d426d9 StoreManagers: Use 'hasGlobalsStorage()' and 'hasParametersStorage()' instead of
directly consulting if a VarDecl is an implicit or actual parameter, a global,
etc.

llvm-svn: 74716
2009-07-02 18:25:09 +00:00
Ted Kremenek 7e4a9a02c3 Add a separate MemSpaceRegion for function/method arguments passed on the stack.
This will simplify the logic of StoreManagers that want to specially reason
about the values of parameters.

llvm-svn: 74715
2009-07-02 18:14:59 +00:00
Ted Kremenek df15d29f17 Remove commented methods. Add MemRegion::printStdErr().
llvm-svn: 74709
2009-07-02 17:24:10 +00:00
Douglas Gregor c6d5edd2ed 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".

llvm-svn: 74704
2009-07-02 17:08:52 +00:00
Douglas Gregor 1554825e20 Look through vector types when determining the base type of a type for declarator printing. Bug found via the PCH tester
llvm-svn: 74672
2009-07-01 23:58:14 +00:00
Fariborz Jahanian 5c6af0a998 Use Destroy for member initializer list clean up.
Per Doug's comments. Doug please review.

llvm-svn: 74666
2009-07-01 23:35:25 +00:00
Ted Kremenek 873db25879 Minor code cleanup: pull variables into scope of 'if' statement, limiting their
actual lifetime to their logical lifetime.

llvm-svn: 74665
2009-07-01 23:30:34 +00:00
Douglas Gregor e4d00dd7f6 Fix PR 4489, a PCH crash during de-serialization.
llvm-svn: 74664
2009-07-01 23:29:14 +00:00
Ted Kremenek 55e07efeed Add a FIXME to RegionStore, do some minor code cleanup, and get RegionStore to
pass misc-ps.m. Currently RegionStore/BasicStore don't do any special reasoning
about clang-style vectors, so we should return UnknownVal (in all cases) when
accessing their values via an array.

llvm-svn: 74660
2009-07-01 23:19:52 +00:00
Owen Anderson ecaeaa81b1 Update for changes in LLVM. Hopefully this is the last one for a while.
llvm-svn: 74657
2009-07-01 23:14:14 +00:00
Douglas Gregor ff6cbdf806 Keep track of more information within the template instantiation stack, e.g.,
by distinguishing between substitution that occurs for template
argument deduction vs. explicitly-specifiad template arguments. This
is used both to improve diagnostics and to make sure we only provide
SFINAE in those cases where SFINAE should apply.

In addition, deal with the sticky issue where SFINAE only considers
substitution of template arguments into the *type* of a function
template; we need to issue hard errors beyond this point, as
test/SemaTemplate/operator-template.cpp illustrates.

llvm-svn: 74651
2009-07-01 22:01:06 +00:00
Owen Anderson 03200753ee Hold the LLVMContext by reference instead of by pointer.
llvm-svn: 74642
2009-07-01 21:23:16 +00:00
Fariborz Jahanian 52337414b7 Updated CXXConstructorDecl AST node for ctor-initilaizer list.
No change in functionality.

llvm-svn: 74639
2009-07-01 21:05:43 +00:00
Daniel Dunbar df4a58edd8 Fix thinko in r74506, test condition for floats was inverted.
- Refactored slightly to make control flow more obvious.

llvm-svn: 74637
2009-07-01 20:37:45 +00:00
Daniel Dunbar 82ef1abf43 Driver: Mark some Compilation members const.
llvm-svn: 74636
2009-07-01 20:30:52 +00:00
Daniel Dunbar 38bfda6ab5 Driver: Move Compilation::Execute to Driver::ExecuteCompilation.
- The Compilation is just a helper class, it shouldn't have that amount of
   logic in it.

 - No functionality change.

llvm-svn: 74634
2009-07-01 20:03:04 +00:00
Fariborz Jahanian c1fc3ec878 Patch to implement template types in ctor-initializer list.
Also has fix for bugzilla-4469.

llvm-svn: 74631
2009-07-01 19:21:19 +00:00
Daniel Dunbar aa246cafaa Driver: Improve diagnostics for failed commands.
- Not all tools give good error messages, and sometimes the tool can fail w/o
   any error (for example, when signalled).

 - We suppress this message when the failing command is the compiler and it
   failed normally (exit code == 1), under the assumption that it gave a good
   diagnostic.

For example, for a linker failure we now get:
--
ddunbar@lordcrumb:tmp$ clang a.c b.c
ld: duplicate symbol _x in /var/folders/cl/clrOX6SaG+moCeRKEI4PtU+++TI/-Tmp-/cc-bXYITq.o and /var/folders/cl/clrOX6SaG+moCeRKEI4PtU+++TI/-Tmp-/cc-6uK4jD.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
--

For a compiler crash we get:
--
ddunbar@lordcrumb:tmp$ clang t.i
Assertion failed: (CGT.getTargetData().getTypeAllocSizeInBits(STy) == RL.getSize()), function layoutStructFields, file CodeGenTypes.cpp, line 573.
0   clang-cc          0x0000000100f1f1f1 PrintStackTrace(void*) + 38
... stack trace and virtual stack trace follow ...
clang: error: compiler command failed due to signal 6 (use -v to see invocation)
--

But for a regular compilation failure we get the usual:
--
ddunbar@lordcrumb:tmp$ clang c.c
c.c:1:6: error: invalid token after top level declarator
int x
     ^
1 diagnostic generated.
--

 - No test case, not amenable to non-executable testing. :/

 - <rdar://problem/6945613>

llvm-svn: 74629
2009-07-01 19:14:39 +00:00
Daniel Dunbar 126b3a103e Driver: Add Source argument for Commands to hold the Action which caused a
Command to be generated, to support more advanced diagnostics.
 - No functionality change.

llvm-svn: 74627
2009-07-01 19:02:28 +00:00
Sebastian Redl df718773f7 Add header search path for Gentoo stable, x86_64 version.
llvm-svn: 74626
2009-07-01 18:59:43 +00:00
Owen Anderson d9dd77ff6c Update for LLVMContext+Module change.
llvm-svn: 74615
2009-07-01 17:00:06 +00:00
Douglas Gregor c05d2a11d7 Two fixes to make Clang build on Visual C++ (again), from Alisdair Meredith.
llvm-svn: 74606
2009-07-01 15:12:53 +00:00
Steve Naroff 05efa97d38 Rework Sema::CheckConditionalOperands(). No functionality change.
This was necessary to simplify some other changes I'm making (wrt ObjC type cleanups).

The idea is to separate the constraint checks for block pointers, ObjC pointers, and C pointers (the previous code combined them into one clause).

Note: This routine will be further simplified when I integrate the ObjC type cleanups (forthcoming).
llvm-svn: 74604
2009-07-01 14:36:47 +00:00
Nate Begeman ef1a7fa89d Implement Eli's feedback for vecto constant expressions;
For ExtVectorType, initializer is splatted to all elements.
For VectorType, initializer is bitcast to vector type.

Verified that for VectorType, output is identical to gcc.

llvm-svn: 74600
2009-07-01 07:50:47 +00:00
Chris Lattner 3dd1b4b6f2 use new and simplified LLVM APIs. Patch by Jay Foad!
llvm-svn: 74585
2009-07-01 04:13:52 +00:00
Eli Friedman 2857ccbaa7 Fix for PR4192: fix the definition of int64_t on x86_64 Linux.
Note that I'm guessing that *BSD and Solaris do the same thing as Linux 
here, but it's quite possible I'm wrong; if the following testcase 
gives an error on x86-64 with gcc for any of those operating systems, please
tell me:

#include <stdint.h>

int64_t x; long x;

llvm-svn: 74583
2009-07-01 03:36:11 +00:00
Zhongxing Xu b4ce4fc4ee add fixme.
llvm-svn: 74581
2009-07-01 02:12:57 +00:00
Douglas Gregor e3f1f350ff Cope with explicitly-specified function template arguments when there
are fewer template arguments than there are template parameters for
that function.

llvm-svn: 74578
2009-07-01 00:28:38 +00:00
Douglas Gregor 89026b5018 When explicit template arguments are provided for a function call,
substitute those template arguments into the function parameter types
prior to template argument deduction. There's still a bit of work to
do to make this work properly when only some of the template arguments
are specified.

llvm-svn: 74576
2009-06-30 23:57:56 +00:00
Fariborz Jahanian 302bb6661f Patch to support optional nested-name-specifier in in ctor-initializer
list.

llvm-svn: 74571
2009-06-30 23:26:25 +00:00
Douglas Gregor a727cb98a4 Preliminary parsing and ASTs for template-ids that refer to function
templates, such as make<int&>. These template-ids are only barely
functional for function calls; much more to come.

llvm-svn: 74563
2009-06-30 22:34:41 +00:00
Ted Kremenek aff66a8a19 Update old CastRegion logic to not assume that ElementRegion's super region is a
TypedRegion. While we plan on removing this code at some point, it serves as a
good reference implementation for use with BasicStore until we are sure the new
CastRegion logic (in RegionStore.cpp) is correct.

llvm-svn: 74559
2009-06-30 22:31:23 +00:00