Commit Graph

7217 Commits

Author SHA1 Message Date
Douglas Gregor 0086a5a3bb Introduce the notion of "Relocatable" precompiled headers, which are built
with a particular system root directory and can be used with a different
system root directory when the headers it depends on have been installed.
Relocatable precompiled headers rewrite the file names of the headers used
when generating the PCH file into the corresponding file names of the 
headers available when using the PCH file.

Addresses <rdar://problem/7001604>.

llvm-svn: 74885
2009-07-07 00:12:59 +00:00
Ted Kremenek 97213bac53 NewCastRegion: Handle casts *from* pointers to incomplete structs to other types.
llvm-svn: 74884
2009-07-06 23:47:19 +00:00
Ted Kremenek 0ee2913215 Fix 80 col violation.
llvm-svn: 74877
2009-07-06 22:59:23 +00:00
Ted Kremenek 309d3c6db0 Restructure NewCastRegion to use a switch statement that dispatches off the
region type. This better shows the logic of the method and allows the compiler
to check if we didn't handle a specific region kind.

llvm-svn: 74876
2009-07-06 22:56:37 +00:00
Ted Kremenek f45778f425 Fix 80 col violation.
llvm-svn: 74875
2009-07-06 22:40:36 +00:00
Ted Kremenek bb5a62d46e NewCastRegion: Handle casts to any Objective-C pointer, not just qualified ids.
llvm-svn: 74874
2009-07-06 22:39:40 +00:00
Ted Kremenek 83b5ccbecf Implement FIXME.
llvm-svn: 74872
2009-07-06 22:34:50 +00:00
Ted Kremenek c5ab3a0eab StoreManager::NewCastRegion:
- Refactor logic that creates ElementRegions into a help method 'MakeElementRegion'.
- Fix crash due to not handling StringRegions.  Casts of StringRegions now
  result in a new ElementRegion layered on the original StringRegion.

llvm-svn: 74867
2009-07-06 22:23:45 +00:00
Ted Kremenek eea8c29aa3 Make 'BasicStoreManager' + 'NewCastRegion' testable from the command line using '-analyzer-store=basic-new-cast'.
llvm-svn: 74865
2009-07-06 21:58:46 +00:00
Argyrios Kyrtzidis 26e8b9c9c1 Update CMake files.
llvm-svn: 74864
2009-07-06 21:38:29 +00:00
Argyrios Kyrtzidis b8020f0833 Some changes to ASTLocation's methods
-Change hasStmt() to isStmt()
-Add isDecl()
-Add getSourceRange()

llvm-svn: 74862
2009-07-06 21:35:20 +00:00
Argyrios Kyrtzidis f24249554b Move the 'ResolveLocationInAST' function from the Frontend library to the Index library.
Also, cut down its comments; more comments will be added to ASTLocation.

llvm-svn: 74860
2009-07-06 21:35:02 +00:00
Argyrios Kyrtzidis 63afa49add Move ASTLocation and DeclReferenceMap from the AST library to the Index library.
llvm-svn: 74859
2009-07-06 21:34:47 +00:00
Argyrios Kyrtzidis b0048027ba Rename 'ASTNode' -> 'ASTLocation'.
ASTLocation is a much better name for its intended purpose which to represent a "point" into the AST.

llvm-svn: 74858
2009-07-06 21:34:20 +00:00
Ted Kremenek 9848b557c8 NewCastRegion:
- Have test for 'CodeTextRegion' dominate other region tests.
- Use 'getAsRecordType' instead of isa<RecordType>

llvm-svn: 74853
2009-07-06 21:01:16 +00:00
Ted Kremenek 3ad4b3bca3 Fix loop so that 'continue' statements actually cause the loop to iterate.
llvm-svn: 74852
2009-07-06 20:53:52 +00:00
Ted Kremenek 9e010e11c3 Move the new 'CastRegion' implementation from RegionStoreManager to StoreManager
(its superclass). This will allow us to experiment with using the new CastRegion
with BasicStoreManager, and gradually phase out the old implementation.

llvm-svn: 74851
2009-07-06 20:21:51 +00:00
Douglas Gregor e64c196868 Fix a problem with false diagnostics when comparing distinct NULL pointer types, from David Majnemer
llvm-svn: 74850
2009-07-06 20:14:23 +00:00
Douglas Gregor 1342e84c17 Fix PR 4489, a crash in PCH loading that occurs when loading the name
of a top-level declaration loads another top-level declaration of the
same name whose type depends on the first declaration having been
completed. This commit breaks the circular dependency by delaying
loads of top-level declarations triggered by loading a name until we
are no longer recursively loading types or declarations.

llvm-svn: 74847
2009-07-06 18:54:52 +00:00
Ted Kremenek 0578e43862 Fix <rdar://problem/7033733>. The CF_RETURNS_RETAINED attribute should work if the return type on an Objective-C method is a CF type reference, not just an Objective-C object reference.
llvm-svn: 74841
2009-07-06 18:30:43 +00:00
Douglas Gregor dce892e128 Parsing fix for out-of-line constructors, from Piotr Rak
llvm-svn: 74833
2009-07-06 16:40:48 +00:00
Douglas Gregor 04318256b7 Keep track of the Expr used to describe the size of an array type,
from Enea Zaffanella!

llvm-svn: 74831
2009-07-06 15:59:29 +00:00
Douglas Gregor 19623dc075 Fix bitfield promotion in the presence of explicit casts, from Abrama Bagnara.
llvm-svn: 74830
2009-07-06 15:38:40 +00:00
Zhongxing Xu e1a3ace8ab Further cleanup of region invalidation code. No functionality change.
llvm-svn: 74816
2009-07-06 06:01:24 +00:00
Zhongxing Xu 1fb1cf4e26 Start to gradually move region invalidation code into store manager.
No functionality change. 

llvm-svn: 74812
2009-07-06 03:41:27 +00:00
Eli Friedman c131d3b5a2 Fix for PR4502: add calculation of the integer conversion rank for
wchar_t.

llvm-svn: 74808
2009-07-05 23:44:27 +00:00
Eli Friedman 245f229df4 More tweaks to types for OpenBSD. Patch by Jonathan Gray.
llvm-svn: 74805
2009-07-05 22:31:18 +00:00
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
Ted Kremenek 58d8190417 Fix: <rdar://problem/7021553> clang -fsyntax-only crashes (in ParseDeclarationSpecifiers ... from ParseObjCTypeName)
Another case where we should use SmallVector::data() instead of taking the
address of element 0 of a SmallVector when the SmallVector has no elements.

llvm-svn: 74556
2009-06-30 22:19:00 +00:00
Fariborz Jahanian cae5482f6c Diagnose multiple initialization of anonymous union
fields in the ctor-initializer list.

llvm-svn: 74554
2009-06-30 21:52:59 +00:00
Ted Kremenek 8fd187986d Combine two conditional branches into one. No functionality change.
llvm-svn: 74552
2009-06-30 20:24:11 +00:00
Fariborz Jahanian 7baa71e2dd More diagnostics related to initialization of direct bases
in ctor-initializer list.

llvm-svn: 74541
2009-06-30 17:34:52 +00:00
Douglas Gregor dda7ced32e When recursively instantiating function templates, keep track of the
instantiation stack so that we provide a full instantiation
backtrace. Previously, we performed all of the instantiations implied
by the recursion, but each looked like a "top-level" instantiation.

The included test case tests the previous fix for the instantiation of
DeclRefExprs. Note that the "instantiated from" diagnostics still
don't tell us which template arguments we're instantiating with.

llvm-svn: 74540
2009-06-30 17:20:14 +00:00
Torok Edwin b2b37c62d0 Reapply r74532, and inherit from OSTargetInfo instead of from Target.
'make test' passes now.

llvm-svn: 74539
2009-06-30 17:10:35 +00:00
Torok Edwin 4e0541649b Revert 74532 till I figure out why it breaks a bunch of tests.
llvm-svn: 74536
2009-06-30 17:00:25 +00:00
Fariborz Jahanian 5f12b5386c Compute ending of iterator in for-loop once.
llvm-svn: 74533
2009-06-30 16:36:53 +00:00
Torok Edwin 45d60b5bc3 Use templates instead of creating a new class for each OS/Target combination.
This unifies all the targets supported by an OS into a template.
It also cleans up the differences between the darwin targets.
Also __LP64__ wasn't needed for *BSD, since x86-64 target defines it anyway.

llvm-svn: 74532
2009-06-30 16:30:17 +00:00
Douglas Gregor 3256d04d22 Refactor ActOnDeclarationNameExpr into a "parsing action" part and a
"semantic analysis" part. Use the "semantic analysis" part when
performing template instantiation on a DeclRefExpr, rather than an ad
hoc list of rules to construct DeclRefExprs from the instantiation.

A test case for this change will come in with a large commit, which
illustrates what I was actually trying to work on.

llvm-svn: 74528
2009-06-30 15:47:41 +00:00
Zhongxing Xu 703db197e3 Instead of r74522, use another approach to fix xfail_regionstore_wine_crash.c.
Mark the super region of the binding of block level expr in the Environment
as live.

llvm-svn: 74525
2009-06-30 13:00:53 +00:00
Zhongxing Xu e205d43c75 When retrieving element region, if its super region has binding, return
unknown for it.

Mark the super region of a live region as live, if the live region is pointed
to by a live pointer variable.

These fixes xfail_regionstore_wine_crash.c.

llvm-svn: 74524
2009-06-30 12:32:59 +00:00
Zhongxing Xu d29e74e658 Block level expr should be visited. Otherwise variables in init expr of
DeclStmt would be dead before the DeclStmt.
For example:
int x = 0;
int y = x;
'x' would be dead before 'int y = x'.

llvm-svn: 74522
2009-06-30 12:11:58 +00:00
Zhongxing Xu d0a246fd08 add utility method.
llvm-svn: 74521
2009-06-30 11:52:40 +00:00
Zhongxing Xu 5df79c6642 remove dead code.
llvm-svn: 74517
2009-06-30 07:50:26 +00:00
Zhongxing Xu 6377a98774 We do not require the super region of element region be typed. So do not
create TypedViewRegion for it.

llvm-svn: 74516
2009-06-30 07:41:27 +00:00
Chris Lattner d466ea1b08 Implement PR4175, catching some questionable comparisons. Patch by
David Majnemer!

llvm-svn: 74513
2009-06-30 06:24:05 +00:00
Argyrios Kyrtzidis cfbfe78e9e De-ASTContext-ify DeclContext.
Remove ASTContext parameter from DeclContext's methods. This change cascaded down to other Decl's methods and changes to call sites started "escalating".
Timings using pre-tokenized "cocoa.h" showed only a ~1% increase in time run between and after this commit.

llvm-svn: 74506
2009-06-30 02:36:12 +00:00
Argyrios Kyrtzidis ddcd132a5b Remove the ASTContext parameter from the getBody() methods of Decl and subclasses.
Timings showed no significant difference before and after the commit.

llvm-svn: 74504
2009-06-30 02:35:26 +00:00
Argyrios Kyrtzidis 8a803cc351 Remove the ASTContext parameter from the printing related methods of Decl.
llvm-svn: 74503
2009-06-30 02:35:04 +00:00
Argyrios Kyrtzidis 4e1a72b37b Decl::getTranslationUnitDecl() should return itself when the Decl is a TranslationUnitDecl.
llvm-svn: 74502
2009-06-30 02:34:53 +00:00
Argyrios Kyrtzidis b4b64ca752 Remove the ASTContext parameter from the attribute-related methods of Decl.
The implementations of these methods can Use Decl::getASTContext() to get the ASTContext.

This commit touches a lot of files since call sites for these methods are everywhere.
I used pre-tokenized "carbon.h" and "cocoa.h" headers to do some timings, and there was no real time difference between before the commit and after it.

llvm-svn: 74501
2009-06-30 02:34:44 +00:00
Chris Lattner c61089a6c2 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.

llvm-svn: 74493
2009-06-30 01:26:17 +00:00
Fariborz Jahanian e853bfa970 Take care of Chris's comments.
llvm-svn: 74486
2009-06-30 00:17:27 +00:00
Anders Carlsson 124f34c150 Make an error message more clear.
llvm-svn: 74481
2009-06-30 00:06:57 +00:00
Fariborz Jahanian 651185bf47 A more detailed diagnosis of ill-formed ctor-initializer
list.

llvm-svn: 74480
2009-06-30 00:02:17 +00:00
Daniel Dunbar 86e35b3aba Use true/false instead of 1/0.
llvm-svn: 74479
2009-06-29 23:58:47 +00:00
Anders Carlsson 074a18a8fd Improvements to decltype. We now don't crash anymore when the expr is an overloaded function decl.
llvm-svn: 74472
2009-06-29 22:58:55 +00:00
Daniel Dunbar 302ab13b1a Don't define __KPRINTF_ATTRIBUTE__ unconditionally on OpenBSD.
llvm-svn: 74467
2009-06-29 22:45:37 +00:00
Douglas Gregor e8925dbc1d Improve code generation for function template specializations:
- Track implicit instantiations vs. the not-yet-supported explicit
  specializations
  - Give implicit instantiations of function templates (and member
  functions of class templates) linkonce_odr linkage.
  - Improve name mangling for function template specializations,
  including the template arguments of the instantiation and the return
  type of the function.

Note that our name-mangling is improved, but not correct: we still
don't mangle substitutions, although the manglings we produce can be
demangled.

llvm-svn: 74466
2009-06-29 22:39:32 +00:00
Fariborz Jahanian 2be8bf44cd Diagnose multiple initialzation of data-member/base
in the ctor-initializer list. More to come.

llvm-svn: 74465
2009-06-29 22:33:26 +00:00
Anders Carlsson d7a1bc4466 Remove some dead code
llvm-svn: 74460
2009-06-29 21:39:57 +00:00
Douglas Gregor 8f5d4423ca Keep track of function template specializations, to eliminate
redundant, implicit instantiations of function templates and provide a
place where we can hang function template specializations.

llvm-svn: 74454
2009-06-29 20:59:39 +00:00
Daniel Dunbar 10de9e6602 OpenBSD support.
- Patch by Jonathan Gray!

llvm-svn: 74453
2009-06-29 20:52:51 +00:00
Argyrios Kyrtzidis 743e7db794 -Keep a reference to the ASTContext inside the TranslationUnitDecl.
-Introduce Decl::getASTContext() which returns the reference from the TranslationUnitDecl that it is contained in.

The general idea is that Decls can point to their own ASTContext so that it is no longer required to "manually" keep track and make sure that you pass the correct ASTContext to Decls' methods, e.g. methods like Decl::getAttrs should eventually not require a ASTContext parameter.

llvm-svn: 74434
2009-06-29 17:38:40 +00:00
Chris Lattner e4edb8e818 Fix the FloatingLiteral API to take the isexact flag by value instead of
by pointer.

llvm-svn: 74432
2009-06-29 17:34:55 +00:00
Douglas Gregor 70d83e27a4 Move FunctionDecl::TemplateSpecializationInfo out into its own class,
FunctionTemplateSpecializationInfo, in DeclTemplate.h. No functionality change.

llvm-svn: 74431
2009-06-29 17:30:29 +00:00
Steve Naroff 8d9cc9ebc1 Remove ASTContext::getObjCQualifiedIdType().
Convert clients to use ASTContext::getObjCObjectPointerType().

llvm-svn: 74424
2009-06-29 16:22:52 +00:00
Zhongxing Xu 4744d560b8 Invalidate the alloca region by setting its default value to conjured symbol.
llvm-svn: 74419
2009-06-29 06:43:40 +00:00
Bill Wendling 1835107ed0 Make the StackProtector bitfield use enums instead of obscure numbers.
llvm-svn: 74414
2009-06-28 23:01:01 +00:00
Anders Carlsson b012ca92ac Move the check for vprintf* functions inside of SemaCheckStringLiteral. Fixes PR4470.
llvm-svn: 74413
2009-06-28 19:55:58 +00:00
Nate Begeman 886448d694 Fix incorrect AST's being produced, noticed by Eli.
The issue this was working around is no longer present in TOT clang.

llvm-svn: 74411
2009-06-28 19:12:57 +00:00
Zhongxing Xu 0628f539a8 Adjust retrieve handler priority. If a field is of array type, it should be
handled by RetrieveArray().

llvm-svn: 74409
2009-06-28 14:16:39 +00:00
Zhongxing Xu 6f610707cf Invalidate a field of struct type by setting its default value to conjured
symbol.

llvm-svn: 74408
2009-06-28 13:59:24 +00:00
Zhongxing Xu d260db1238 Do not crash on binding concrete integer location.
llvm-svn: 74407
2009-06-28 10:16:11 +00:00
Zhongxing Xu f7a6de3a12 Simplify some code. As in region store, we always expect the location is a
memregion.

llvm-svn: 74406
2009-06-28 09:26:15 +00:00
Bill Wendling d63bbadbef Add stack protector support to clang. This generates the 'ssp' and 'sspreq'
function attributes. There are predefined macros that are defined when stack
protectors are used: __SSP__=1 with -fstack-protector and __SSP_ALL__=2 with
-fstack-protector-all.

llvm-svn: 74405
2009-06-28 07:36:13 +00:00
Nate Begeman bd956c4290 OpenCL 1.0 support:
Handle rules for ExtVector + ExtVector and ExtVector + Scalar operations. 
Fix problem Eli noticed where we were allowing pointer types to be splatted to
vector elements.

llvm-svn: 74404
2009-06-28 02:36:38 +00:00
Nate Begeman c8961a424d Implement feedback from Eli re: the purpose of lax vector conversions
llvm-svn: 74397
2009-06-27 22:05:55 +00:00
Douglas Gregor 15448f8d23 Improve support for overloaded operator templates.
llvm-svn: 74390
2009-06-27 21:05:07 +00:00
Eli Friedman 5e774b1333 Fix the parser error hanlding for __builtin_offsetof to actually print
out an error for a malformed __builtin_offsetof.

llvm-svn: 74388
2009-06-27 20:38:33 +00:00
Fariborz Jahanian 3fe6b61b23 Renamed MarcDestructorReferenced -> MarkDestructorReferenced
llvm-svn: 74386
2009-06-27 15:05:11 +00:00
Eli Friedman d95e1cda9e Fix screwup with my previous patch which broke tests. (The patch is
making sure we return true when annotating a function template with 
explicit template arguments, but not when we don't annotate anything.)

llvm-svn: 74383
2009-06-27 08:17:02 +00:00
Eli Friedman 9fe1bb40ae Fix a crash with constructs like x<false>() in C++. No testcase because
it doesn't actually work yet; we just error out a bit more gracefully.

llvm-svn: 74381
2009-06-27 06:24:06 +00:00
Eli Friedman 173e0b7a96 Fix a bogus error overloading an operator where the only class
parameter has a dependent type.

llvm-svn: 74380
2009-06-27 05:59:59 +00:00
Anders Carlsson f0a7f3b089 Implement support for the format_arg attribute. Fixes PR4442.
llvm-svn: 74369
2009-06-27 04:05:33 +00:00
Anders Carlsson 74d7f0dd65 Make it possible for using decls to point to operators. Fixes PR4441.
llvm-svn: 74362
2009-06-27 00:27:47 +00:00
Ted Kremenek 8e5f6951eb Remove the last 'GetXXX' methods from GRStateManager.
llvm-svn: 74361
2009-06-27 00:24:54 +00:00
Fariborz Jahanian 24a175b37c Patch to mark destructors when they are used.
llvm-svn: 74359
2009-06-26 23:49:16 +00:00
Anders Carlsson bae2737202 Fix test.
llvm-svn: 74358
2009-06-26 23:44:14 +00:00
Douglas Gregor fc516c93c1 Set the rest of the flags we need to perform template argument
deduction using a base class of the argument type. No actual
functionality change; this is just a hook.

llvm-svn: 74356
2009-06-26 23:27:24 +00:00
Douglas Gregor cf0b47d179 During template argument deduction from a function call, allow
deduction from pointer and pointer-to-member types to work even in the
presence of a qualification conversion (C++ [temp.deduct.type]p3
bullet 2). 

llvm-svn: 74354
2009-06-26 23:10:12 +00:00
Anders Carlsson 94ff77a356 More auto work.
llvm-svn: 74339
2009-06-26 22:18:59 +00:00
Douglas Gregor febe45a727 A little template argument deduction test uncovered an "oops". As part
of template instantiation, we were dropping cv-qualifiers on the
instantiated type in a few places. This change reshuffles the
type-instantiation code a little bit so that there's a single place
where we add qualifiers to the instantiated type, so that we won't end
up with this same bug in the future.

llvm-svn: 74331
2009-06-26 21:40:05 +00:00
Nate Begeman ea12f6ebb5 OpenCL 1.0 Support: fix a bug with lvalue swizzles
llvm-svn: 74324
2009-06-26 21:12:50 +00:00
Douglas Gregor 705c900d23 Template argument deduction is no longer responsible for checking
non-dependent parameter types. Instead, class template partial
specializations perform a final check of all of the instantiated
arguments. This model is cleaner, and works better for function
templates where the "final check" occurs during overload resolution.

Also, cope with cv-qualifiers when the parameter type was originally a
reference type, so that the deduced argument can be more qualified
than the transformed argument.

llvm-svn: 74323
2009-06-26 20:57:09 +00:00
Anders Carlsson 6bd992d1c3 Can't have arrays of auto.
llvm-svn: 74314
2009-06-26 19:33:28 +00:00
Anders Carlsson 364035d1a8 An auto variable can't appear in its own initializer.
llvm-svn: 74312
2009-06-26 19:16:07 +00:00
Anders Carlsson 082acded44 Implement enough of the 'auto' keyword so we can claim to support N2546.
llvm-svn: 74307
2009-06-26 18:41:36 +00:00
Devang Patel 2872df839d typo
llvm-svn: 74305
2009-06-26 18:33:42 +00:00
Devang Patel 0d425350b2 Revrt PR4228 fix for now.
llvm-svn: 74304
2009-06-26 18:32:22 +00:00
Daniel Dunbar c7d0e6525d Simplify, and fix a possible crash (never happens however, because we don't ever
take this path with non-builtin floating point types).

llvm-svn: 74303
2009-06-26 18:32:06 +00:00
Douglas Gregor cceb97559e Improve template argument deduction for reference parameters when
deducing template arguments from a function call. Plus, add a bunch of
tests.

llvm-svn: 74301
2009-06-26 18:27:22 +00:00