Commit Graph

5136 Commits

Author SHA1 Message Date
Ted Kremenek bfd28fd596 Refactor 'PostStmt' and 'PreStmt' to subclass a common parent 'StmtPoint'.
Educate GRExprEngine::VisitGraph() about 'PreStmt'.

Mark the constructor of 'PostStmt' to be explicit, preventing implicit
conversions and the selection of the wrong 'generateNode' method in
GRStmtNodeBuilder.

Constify a bunch of arguments, which falls out of the changes to ProgramPoint.

llvm-svn: 76809
2009-07-22 22:35:28 +00:00
Ted Kremenek b8725e2099 Use SaveAndRestore in 'clang/Analysis/Support/SaveAndRestore.h'
llvm-svn: 76800
2009-07-22 21:52:10 +00:00
Ted Kremenek 5b9b066aeb Add AssumeDual method.
llvm-svn: 76798
2009-07-22 21:51:00 +00:00
Eli Friedman 3af2a77717 Fix the parsing of default arguments for inline member function
definitions.

I'm not very familiar with this code, so please review.

llvm-svn: 76796
2009-07-22 21:45:50 +00:00
Ted Kremenek b1c170e64b Make 'SaveAndRestore' and friends reusable classes in libAnalysis.
llvm-svn: 76795
2009-07-22 21:45:16 +00:00
Ted Kremenek 49513ccaec Add support for registering 'Checker' objects with GRExprEngine.
Add a 'previsit' stage (that dispatches to registered Checkers) when evaluating the effects of CallExprs.

llvm-svn: 76794
2009-07-22 21:43:51 +00:00
Ted Kremenek 63fc4352b6 Add new 'Checker' and 'CheckerVisitor' classes, which represent a more powerful
interface to plug in domain-specific checker logic than the current
GRSimpleAPICheck interface. The new 'Checker' interface can actually generate
new nodes, allowing it to modify the state and refine the analysis (which
GRSimpleAPIChecks could not).

llvm-svn: 76793
2009-07-22 21:42:34 +00:00
Ted Kremenek 2776079844 Add support for 'PreStmt' program points to GRCoreEngine and GRStmtNodeBuilder.
llvm-svn: 76792
2009-07-22 21:40:46 +00:00
Ted Kremenek 8a2cb9cede Add 'PreStmt' program point. This will be used to represent checking for
preconditions (in GRExprEngine) before the statement itself is evaluated.

llvm-svn: 76791
2009-07-22 21:39:25 +00:00
Ted Kremenek 0af7e85bf7 Implement operator= for ExplodedNodeSet.
llvm-svn: 76790
2009-07-22 21:38:15 +00:00
Mike Stump aa19375206 Make -Wreturn-type be part of -Wmost and therefore -Wall.
llvm-svn: 76784
2009-07-22 21:00:27 +00:00
Douglas Gregor 8a27391190 "This patch implements the restrictions on union members detailed in
[class.union]p1", from John McCall!

llvm-svn: 76766
2009-07-22 18:25:24 +00:00
Ted Kremenek f1282074c3 Move bug reporter "visitors" to their own file and make them part of the public
BugReporter API.  No real functionality change.

llvm-svn: 76760
2009-07-22 17:55:28 +00:00
Douglas Gregor b09f3d82cc Implement parsing and semantic analysis for out-of-line definitions of static
data members of class templates. We don't instantiate the definitions yet,
however.

llvm-svn: 76756
2009-07-22 17:18:37 +00:00
Mike Stump 7a5eaf6dd4 Add some documentation, to make it so the next person doens't select
the wrong function.  :-)

llvm-svn: 76752
2009-07-22 16:55:20 +00:00
Steve Naroff 51d4f79ffa Fix <rdar://problem/6770276> Support Class<Proto> syntax.
llvm-svn: 76741
2009-07-22 16:07:01 +00:00
Ted Kremenek 952a004298 Restructure ProgramPoint to have the 'Kind' value be its own instance
variable.  This gives us much more flexibility with defining more
ProgramPoints, which is the direction we are heading.  The removal of
various bit-mangling of pointers also cleans up the logic.

llvm-svn: 76721
2009-07-22 04:38:22 +00:00
Fariborz Jahanian 891436d54c Minor mod. per Doug's comment.
llvm-svn: 76708
2009-07-22 00:42:46 +00:00
Douglas Gregor 168190d822 Complain if we're entering the context of a dependent nested-name-specifier but
cannot match that nested-name-specifier to a class template or class template
partial specialization.

llvm-svn: 76704
2009-07-22 00:28:09 +00:00
Douglas Gregor d8d297c0ac Basic parsing and semantic analysis for out-of-line definitions of the
member functions of class templates, e.g.,

  template<typename T> 
  struct X {
    void f(T);
  };

  template<typename T> X<T>::f(T) { /* ... */ }

llvm-svn: 76692
2009-07-21 23:53:31 +00:00
Fariborz Jahanian aee31ac316 Patch to accomodate Doug's comment on default
destruction of base/members for each destructor AST.

llvm-svn: 76663
2009-07-21 22:36:06 +00:00
Ted Kremenek 4fd8f73c93 Update stale comment.
llvm-svn: 76644
2009-07-21 21:09:31 +00:00
Ted Kremenek ac7c7240f0 Fix PR 4594 by refactoring almost all casting logic from GRExprEngine::VisitCast
to SValuator::EvalCast. In the process, the StoreManagers now use this new cast
machinery, and the hack in GRExprEngine::EvalBind to handle implicit casts
involving OSAtomicCompareAndSwap and friends has been removed (and replaced with
logic closer to the logic specific to those functions).

llvm-svn: 76641
2009-07-21 21:03:30 +00:00
Daniel Dunbar 08e41d65a2 driver: Print --version on stdout, to match gcc.
- Patch by Jean-Daniel Dupas

llvm-svn: 76632
2009-07-21 20:06:58 +00:00
Douglas Gregor ddbf4e0c2c Make Sema::ActOnCXXEnterDeclaratorScope robust against failures to compute
the declaration context, as occurs with out-of-line class template member
definitions.

llvm-svn: 76622
2009-07-21 18:59:28 +00:00
Fariborz Jahanian b154ecafa6 Diagnose when a destructor uses a unrelated class type as its name.
llvm-svn: 76577
2009-07-21 15:28:50 +00:00
Douglas Gregor 82fe3e3398 Add the location of the tag keyword into TagDecl. From Enea
Zaffanella, with tweaks from Abramo Bagnara.

llvm-svn: 76576
2009-07-21 14:46:17 +00:00
Argyrios Kyrtzidis 8274ad5281 Remove the ASTContext parameter from Entity::getPrintableName().
llvm-svn: 76546
2009-07-21 07:52:21 +00:00
Argyrios Kyrtzidis 11982922be Add an assert for safety check.
llvm-svn: 76539
2009-07-21 06:48:06 +00:00
Argyrios Kyrtzidis 1a176f0b96 Fix a crash that occurs in this C++ case:
struct foo {
  static bool value;
};
bool (foo::value); // crash because of parens

llvm-svn: 76538
2009-07-21 06:43:26 +00:00
Argyrios Kyrtzidis 3b4e2a7621 Keep only canonical Decls in Entities.
llvm-svn: 76532
2009-07-21 02:10:32 +00:00
Argyrios Kyrtzidis 05ac8276cf 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.

llvm-svn: 76515
2009-07-21 00:07:06 +00:00
Argyrios Kyrtzidis a8cf0beeef Implement the virtual getNextRedeclaration() for ObjCMethodDecl.
If it's in an ObjCContainerDecl, its "redeclaration" is the method definition in the corresponding ObjCImplDecl.
If it's in an ObjCImplDecl, its "redeclaration" is the method in the interface.

llvm-svn: 76512
2009-07-21 00:06:36 +00:00
Argyrios Kyrtzidis 60e9b7cf58 Add an assertion for the return value of Decl::getNextRedeclaration().
llvm-svn: 76511
2009-07-21 00:06:27 +00:00
Argyrios Kyrtzidis 1559d67b7a Remove the ObjCCategoryImpls vector from Sema class.
Use ObjCInterfaceDecl::getCategoryClassMethod() and ObjCInterfaceDecl::getCategoryInstanceMethod() for the same functionality.

llvm-svn: 76510
2009-07-21 00:06:20 +00:00
Argyrios Kyrtzidis 6d9fab7619 - Introduce ASTContext::getObjCImplementation() and ASTContext::setObjCImplementation() which use a DenseMap to associate
an interface/category with its implementation (if one exists).

- Introduce ObjCInterfaceDecl::get/setImplementation() and ObjCCategoryDecl::get/setImplementation() that use the above methods.

- Add a compiler error for when a category is reimplemented.

llvm-svn: 76508
2009-07-21 00:05:53 +00:00
Mike Stump 0d76d075e4 Add yet more analysis for CFGs involving conditionals that are actually constant.
llvm-svn: 76500
2009-07-20 23:24:15 +00:00
Fariborz Jahanian c0656de03d Improve message for bad destructor decl. Per Doug's comment.
llvm-svn: 76494
2009-07-20 22:41:12 +00:00
Douglas Gregor d12df6b160 Reuse VarDecl::Init to store the default argument of a ParmVarDecl,
reducing the size of ParmVarDecl by one pointer. Also means that we'll 
properly (de-)serialize default arguments in C++ PCH files.

llvm-svn: 76487
2009-07-20 22:03:28 +00:00
Mike Stump 17051250ad Remove an apparently unused forward class decl.
llvm-svn: 76476
2009-07-20 21:23:55 +00:00
Ted Kremenek 619eece347 Update DataflowSolver to handle the case where a successor/predecessor block
could be NULL. This allows the solver to handle optimized CFGs where branches
can be determined during CFG-construction to be infeasible.

llvm-svn: 76452
2009-07-20 18:52:34 +00:00
Douglas Gregor 47d2859b3e Improve GCC compatibility by allowing static tentative definitions of
incomplete type (with a warning), from Enea Zaffanella!

llvm-svn: 76451
2009-07-20 18:46:59 +00:00
Ted Kremenek af9f362840 Enhance GRBranchNodeBuilderImpl (part of GRCoreEngine) to understand the case
where the true or false CFGBlock* for a branch could be NULL. This will handle
the case where we can determine during CFG construction that a branch is
infeasible.

llvm-svn: 76450
2009-07-20 18:44:36 +00:00
Fariborz Jahanian 4041dfc360 Issue a more descriptive diagnostics when mis-declaring
a destructor.

llvm-svn: 76436
2009-07-20 17:43:15 +00:00
Ted Kremenek 291e8f770e Improve debug pretty-printing for ObjCIVarRegions.
llvm-svn: 76380
2009-07-19 20:36:24 +00:00
Chris Lattner 9662cd3227 enhance the goto checker to reject jumps across __block variable definitions.
llvm-svn: 76376
2009-07-19 20:17:11 +00:00
Anders Carlsson 27b50135ee Rename NextOffset to DataSize, which better matches the Itanium C++ ABI
llvm-svn: 76339
2009-07-18 21:26:44 +00:00
Anders Carlsson a4267a654b Migrate over to the record layout builder.
llvm-svn: 76338
2009-07-18 21:19:52 +00:00
Argyrios Kyrtzidis d6bf03c272 Introduce ASTLocation::getReferencedDecl(), for getting the declaration that the ASTLocation references.
llvm-svn: 76336
2009-07-18 21:17:58 +00:00
Anders Carlsson 4f51628b02 More layout builder work.
llvm-svn: 76333
2009-07-18 20:50:59 +00:00
Anders Carlsson 7947433411 Add a new ASTRecordLayoutBuilder class. Not used yet.
llvm-svn: 76330
2009-07-18 20:20:21 +00:00
Anders Carlsson 15b73deeea Revert r75641.
llvm-svn: 76327
2009-07-18 19:43:29 +00:00
Steve Naroff c277ad10f0 Remove ObjCQualifiedInterfaceType:-)
llvm-svn: 76321
2009-07-18 15:33:26 +00:00
Argyrios Kyrtzidis fd16798b1f Fix a comment.
llvm-svn: 76299
2009-07-18 08:50:48 +00:00
Argyrios Kyrtzidis 05898da9cb 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.
llvm-svn: 76298
2009-07-18 08:50:35 +00:00
Argyrios Kyrtzidis fad334ce5b Introduce the Redeclarable template class, which serves as a base type defining the common interface for Decls that can be redeclared.
Make FunctionDecl and VarDecl use it.

llvm-svn: 76297
2009-07-18 08:50:13 +00:00
Argyrios Kyrtzidis 91ff94d6d9 Remove getFirstDeclaration/getLatestDeclaration from FunctionDecl and VarDecl.
Their usefulness is questionable since redecl_iterator was introduced.

llvm-svn: 76275
2009-07-18 00:34:35 +00:00
Argyrios Kyrtzidis 6b7e376160 Remove ASTContext::getCanonicalDecl() and use Decl::getCanonicalDecl in its place.
llvm-svn: 76274
2009-07-18 00:34:25 +00:00
Argyrios Kyrtzidis 5614aef776 Move the functionality of ASTContext::getCanonicalDecl(), into a virtual method Decl::getCanonicalDecl().
llvm-svn: 76273
2009-07-18 00:34:07 +00:00
Argyrios Kyrtzidis 02675dc49d Set ObjCMethodDecl's EndLoc to the '}' when it's a definition.
llvm-svn: 76269
2009-07-18 00:33:33 +00:00
Argyrios Kyrtzidis ce55b2e543 Add getSourceRange() methods for ObjC Decls.
llvm-svn: 76267
2009-07-18 00:33:08 +00:00
Ted Kremenek 8a286fbdb9 Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methods
until Doug Gregor's Type smart pointer code lands (or more discussion occurs).
These methods just call the new Type::getAs<XXX> methods, so we still have
reduced implementation redundancy. Having explicit getAsXXXType() methods makes
it easier to set breakpoints in the debugger.

llvm-svn: 76193
2009-07-17 17:50:17 +00:00
Zhongxing Xu 9d05213899 Rename Entity::getName() to Entity::getPrintableName() to make its purpose
more obvious.

llvm-svn: 76167
2009-07-17 07:49:44 +00:00
Zhongxing Xu 3436f58e40 As suggested by Argyrios, revert r76159 and make "FindImmediateParent"
a public static method of ASTLocation.

llvm-svn: 76166
2009-07-17 07:36:20 +00:00
Zhongxing Xu 3c8fa978ad Refactor code into a new CallExpr::getDirectCallee() method. Simplify some
code with the new method.

llvm-svn: 76164
2009-07-17 07:29:51 +00:00
Zhongxing Xu d25ea831b2 Relax the assertion in ASTLocation's ctor: if the decl is not the immediate
parent of the stmt, find the immediate parent for the stmt.

This is because sometimes we cannot get the immediate decl of the stmt when
creating the ASTLocation. We can only get a parent of the stmt.

llvm-svn: 76159
2009-07-17 06:58:08 +00:00
Zhongxing Xu 6c1b35a0ef CallGraph:
- add IfStmt visitor.
 - print information only when a function has callee. Otherwise its ASTContext
   map is NULL.

llvm-svn: 76156
2009-07-17 05:49:16 +00:00
Ted Kremenek b825c0ddc5 Replaced Type::getAsLValueReferenceType(), Type::getAsRValueReferenceType(), Type::getAsMemberPointerType(), Type::getAsTagType(), and Type::getAsRecordType() with their Type::getAs<XXX> equivalents.
llvm-svn: 76139
2009-07-17 01:20:38 +00:00
Argyrios Kyrtzidis c6756ab0ae ObjCCategoryImplDecl and ObjCImplementation do not derive directly from DeclContext but from a new abstract ObjCImplDecl.
Reflect this change on the "DeclContext hierarchy".

llvm-svn: 76137
2009-07-17 01:19:49 +00:00
Ted Kremenek 3d486f08cb Replace Type::getAsReferenceType() with Type::getAs<ReferenceType>().
llvm-svn: 76132
2009-07-17 01:01:15 +00:00
Ted Kremenek e3fb4b6524 Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.
This method is intended to eventually replace the individual
Type::getAsXXXType<> methods.

The motivation behind this change is twofold:

1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of
them are basically copy-and-paste.

2) By centralizing the implementation of the getAs<Type> logic we can more
smoothly move over to Doug Gregor's proposed canonical type smart pointer
scheme.

Along with this patch:

a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>.
b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>.

llvm-svn: 76098
2009-07-16 19:58:26 +00:00
Ted Kremenek 6796fbd2e8 Move the source-level CFG from libAST to libAnalysis.
llvm-svn: 76092
2009-07-16 18:13:04 +00:00
Steve Naroff fac5bc9264 Cleanup a couple loops and improve a comment (based on feedback from Fariborz).
llvm-svn: 76078
2009-07-16 16:21:02 +00:00
Steve Naroff 79d1215d83 Remove ASTContext::isObjCObjectPointerType().
Convert all clients to use the new predicate on Type.

llvm-svn: 76076
2009-07-16 15:41:00 +00:00
Chris Lattner 3afa3e1d91 codegen string literals using private linkage now like llvm-gcc, eliminating
some target hooks.

llvm-svn: 75895
2009-07-16 05:03:48 +00:00
Ted Kremenek c7b1dade86 Move RegionStoreManager over to using new
ValueManager::makeArrayIndex()/convertArrayIndex() methods.  This
handles yet another crash case when reasoning about array indices of
different bitwidth and signedness.

llvm-svn: 75884
2009-07-16 01:33:37 +00:00
Ted Kremenek f267a15c8d Two changes:
(1) Moved the SValuator object from GRExprEngine to ValueManager.  This
   allows ValueManager to use the SValuator when creating SVals.

(2) Added ValueManager::makeArrayIndex() and
    ValueManager::convertToArrayIndex(), two SVal creation methods
    that will help RegionStoreManager always have a consistent set of
    SVals with the same integer size and type when reasoning about
    array indices.

llvm-svn: 75882
2009-07-16 01:32:00 +00:00
Fariborz Jahanian 41136eec6b Generate error on declaration containing 'static' and '__attribute__((weak))'
Patch by Ryan Flynn

llvm-svn: 75879
2009-07-16 01:12:24 +00:00
Zhongxing Xu bc6eb71f31 Commit the initial implementation of call graph building.
llvm-svn: 75873
2009-07-16 00:54:12 +00:00
Fariborz Jahanian 30324d68b1 Fixed a stinko which caused an ast-print test failure.
llvm-svn: 75861
2009-07-15 23:39:31 +00:00
Fariborz Jahanian 16094c2467 Added ASTs to destructor decl AST for default destruction of object's
base/members.

llvm-svn: 75849
2009-07-15 22:34:08 +00:00
Steve Naroff da44a40b64 Remove default argument, since it isn't being used (suggested by Fariborz).
llvm-svn: 75815
2009-07-15 19:34:04 +00:00
Steve Naroff 8206de760b Add a "t".
llvm-svn: 75810
2009-07-15 18:50:21 +00:00
Steve Naroff 1329fa0ed9 Implement the ObjC pseudo built-in types as clang "BuiltinType's". I say pseudo built-in types, since Sema still injects a typedef for recognition (i.e. they aren't truly built-ins from a parser perspective).
This removes the static data/methods on ObjCObjectPointerType while preserving the nice API (no need to fiddle with ASTContext:-).

This patch also adds Type::isObjCBuiltinType().

This should be the last fairly large patch related to recrafting the ObjC type system. The follow-on patches should be fairly small.

llvm-svn: 75808
2009-07-15 18:40:39 +00:00
Zhongxing Xu 12b1d137c2 Add getName() method to Entity.
llvm-svn: 75740
2009-07-15 04:39:21 +00:00
Ted Kremenek e6fea68c46 More test cases revealed that the logic in StoreManager::InvalidateRegion() needs more finesse when handling the invalidation of pointers. Pointers that were invalidated as integers could later cause problems for clients using them as pointers. It is easier for us to model a symbolic value as a pointer rather than modeling a non-symbolic value as a pointer.
This patch causes:
- StoreManager::InvalidateRegion() to not used the casted type of a region if
  it would cause a pointer type to be invalidated as a non-pointer type.
- Pushes RegionStore::RetrieveElement() further by handling retrievals from
  symbolic arrays that have been invalidated.  This uses the new SymbolDerived
  construct that was recently introduced.
  
The result is that the failing test in misc-ps-region-store-x86_64.m now passes.
Both misc-ps-region-store-x86_64.m and misc-ps-region-store-i386.m contain a
test case that motivated this change.

llvm-svn: 75730
2009-07-15 02:31:43 +00:00
Ted Kremenek c6c2157836 Introduced the notion of a "derived symbol" using the class SymbolDerived.
SymbolDerived allows us to model symbolic values that are related to other
symbols via a region hierarchy. For example, SymbolDerived can be used to model
individual values of a symbolic array.

llvm-svn: 75728
2009-07-15 02:27:32 +00:00
Eli Friedman bb0d9a5129 Remove -ftraditional option, which gcc doesn't actually support. Make
using -traditional and -traditional-cpp with clang an error because 
it's unsupported in clang and causes a significant change in the 
semantics of the language.

llvm-svn: 75690
2009-07-14 21:58:17 +00:00
Steve Naroff 6b712a7ba1 Introduce Type::isAnyPointerType() and convert all clients (suggested by Chris).
I don't love the name, however it simplifies the code and is a worthwhile change. If/when we come up with a better name, we can do a search/replace.

llvm-svn: 75650
2009-07-14 18:25:06 +00:00
Fariborz Jahanian 49c81799b0 Patch to build AST for ctor's initializer list according to
semantics of order of construction [class.init].

llvm-svn: 75649
2009-07-14 18:24:21 +00:00
Anders Carlsson 466fd0a16d Rename RecordLayout.h to ASTRecordLayout.h
llvm-svn: 75641
2009-07-14 17:29:11 +00:00
Steve Naroff 5ec6ff7678 Add a "TypeSpecStartLoc" to FieldDecl. Patch contributed by Enea Zaffanella.
Note: One day, it might be useful to consider adding this info to DeclGroup (as the comments in FunctionDecl/VarDecl suggest). For now, I think this works fine. I considered moving this to ValueDecl (a common ancestor of FunctionDecl/VarDecl/FieldDecl), however this would add overhead to EnumConstantDecl (which would burn memory and isn't necessary).
llvm-svn: 75635
2009-07-14 14:58:18 +00:00
Alisdair Meredith a9ad47d94c Basic support for C++0x unicode types. Support for literals will follow in an incremental patch
llvm-svn: 75622
2009-07-14 06:30:34 +00:00
Argyrios Kyrtzidis 1506d9bc25 Introduce redecl_iterator, used for iterating over the redeclarations of a FunctionDecl or VarDecl.
It iterates over all the redeclarations, regardless of the starting point. For example:

1) int f();
2) int f();
3) int f();

if you have the (2) FunctionDecl and call redecls_begin/redecls_end to iterate, you'll get this sequence:
(2)
(1)
(3)

The motivation to introduce this was that, previously, if (3) was a function definition,
and you called getBody() at (2), it would not return it, since getBody() iterated over the previous declarations only,
so it would only check (2) and (1).

llvm-svn: 75604
2009-07-14 03:20:21 +00:00
Argyrios Kyrtzidis 0736c5ca3b Introduce FunctionDecl::getLatestDeclaration() and VarDecl::getLatestDeclaration().
For multiple redeclarations they return the last one.

Also, add some non const versions of methods.

llvm-svn: 75603
2009-07-14 03:20:08 +00:00
Argyrios Kyrtzidis ef17c07bf6 Introduce FunctionDecl::getFirstDeclaration() and VarDecl::getFirstDeclaration().
For multiple redeclarations they return the first one.

llvm-svn: 75602
2009-07-14 03:19:57 +00:00
Argyrios Kyrtzidis eeaaead736 Read/write a CXXOperatorCallExpr from/to PCH files.
llvm-svn: 75598
2009-07-14 03:19:21 +00:00
Argyrios Kyrtzidis 23e1f1d6be Pass the right brace SourceLocation from the Parser to the TagDecls.
llvm-svn: 75591
2009-07-14 03:17:52 +00:00
Argyrios Kyrtzidis 575fa05991 Add the SourceLocation for the right brace in TagDecl.
llvm-svn: 75590
2009-07-14 03:17:17 +00:00
Zhongxing Xu 170e816eff Instead of recovering from a wrong invalidation, this patch aims to
invalidate the region correctly. It uses the cast-to type to invalidate 
the region when available. To avoid invalid cast-to type like 'void*' or 'id',
region store now only records non-generic casts of regions.

llvm-svn: 75580
2009-07-14 01:12:46 +00:00
Ted Kremenek a6904ff7f9 Tidy pretty-printing for SVals, using 'dump()' instead of 'printStdErr()', and implementing operator<< support for llvm::raw_ostream.
llvm-svn: 75560
2009-07-13 23:53:06 +00:00
Ted Kremenek eabdd984b1 Change pretty-printing API for SymExprs and MemRegions to use a naming convention and style similar to other elements in Clang.
llvm-svn: 75548
2009-07-13 23:31:04 +00:00
Steve Naroff 2efbbe3531 - Improve comment for Type::getPointeeType().
- Remove a couple redundant casts/returns.
- Fix 80 column violations for all getAsStringInternal() methods.

llvm-svn: 75485
2009-07-13 19:06:52 +00:00
Daniel Dunbar 2e5be09280 Match declaration to definition.
llvm-svn: 75441
2009-07-12 23:52:11 +00:00
Daniel Dunbar 593c36c1c8 Match declaration to definition.
llvm-svn: 75439
2009-07-12 22:53:49 +00:00
Chris Lattner 000628da61 fix typo in file headers.
llvm-svn: 75436
2009-07-12 22:31:02 +00:00
Chris Lattner c638161d38 improve comments.
llvm-svn: 75435
2009-07-12 22:29:59 +00:00
Chris Lattner fb42a1820f add push/pop semantics for diagnostics. Patch by Louis Gerbarg!
llvm-svn: 75431
2009-07-12 21:18:45 +00:00
Anders Carlsson ae01993a12 Implement more of C++0x 'auto'. A variable with an auto type specifier must have an initializer. Also, move some tests around to match the C++0x draft better.
llvm-svn: 75322
2009-07-11 00:34:39 +00:00
Steve Naroff 7cae42b07a This patch includes a conceptually simple, but very intrusive/pervasive change.
The idea is to segregate Objective-C "object" pointers from general C pointers (utilizing the recently added ObjCObjectPointerType). The fun starts in Sema::GetTypeForDeclarator(), where "SomeInterface *" is now represented by a single AST node (rather than a PointerType whose Pointee is an ObjCInterfaceType). Since a significant amount of code assumed ObjC object pointers where based on C pointers/structs, this patch is very tedious. It should also explain why it is hard to accomplish this in smaller, self-contained patches.

This patch does most of the "heavy lifting" related to moving from PointerType->ObjCObjectPointerType. It doesn't include all potential "cleanups". The good news is additional cleanups can be done later (some are noted in the code). This patch is so large that I didn't want to include any changes that are purely aesthetic.

By making the ObjC types truly built-in, they are much easier to work with (and require fewer "hacks"). For example, there is no need for ASTContext::isObjCIdStructType() or ASTContext::isObjCClassStructType()! We believe this change (and the follow-up cleanups) will pay dividends over time. 

Given the amount of code change, I do expect some fallout from this change (though it does pass all of the clang tests). If you notice any problems, please let us know asap! Thanks.

llvm-svn: 75314
2009-07-10 23:34:53 +00:00
Fariborz Jahanian 3554b5a37c Patch to build list of inherited virtual base classes
in their order of construction for each class and use it 
to to check on propery order of base class construction 
under -Wreorder option.

llvm-svn: 75270
2009-07-10 20:13:23 +00:00
Anders Carlsson ea1cfb415b Fix a problem that Eli noticed, and that Doug helped me fix.
llvm-svn: 75265
2009-07-10 19:20:26 +00:00
Ted Kremenek da98f732cb Rename potentially ambiguous member template 'getRegion' to 'getSubRegion' to hopefully resolve template lookup ambiguities on some compilers.
llvm-svn: 75253
2009-07-10 16:51:45 +00:00
Ted Kremenek f66557978e Switch BasicStoreManager to use the new CastRegion implementation by default,
and replace the 'clang-cc' option '-analyzer-store=basic-new-cast' with
'-analyzer-store=basic-old-cast'. We'll keep the old CastRegion implementation
around for a little while for regression testing.

llvm-svn: 75209
2009-07-10 00:41:58 +00:00
Fariborz Jahanian 5582f231f2 don't crash if class is using itself as its super class.
llvm-svn: 75178
2009-07-09 22:08:26 +00:00
Fariborz Jahanian 341583c3ac Sema check on out of order object initialization of
class object's base and members under -Wreorder flag.

llvm-svn: 75168
2009-07-09 19:59:47 +00:00
Anders Carlsson 03f89b1828 Store the isAddressOfOperand in the UnresolvedDeclRefExpr, so that we can pass it when instantiating the expr. Fixes another member pointer bug.
llvm-svn: 75075
2009-07-09 00:05:08 +00:00
Douglas Gregor b257e4fff8 Implement the simple form of overload resolution used when taking the
address of an overloaded function (which may involve both functions
and function templates). 

llvm-svn: 75069
2009-07-08 23:33:52 +00:00
Ted Kremenek 8ee3dd7cc5 Fix: <rdar://problem/7034511> ValueManager::makeIntVal(uint64_t X, QualType T) should return a 'Loc' when 'T' is a pointer
llvm-svn: 75062
2009-07-08 22:42:46 +00:00
Anders Carlsson 0b675f5ad5 It's not allowed to form member pointers to members that have reference type. Add a test for this and the rest of [dcl.mptr]p3.
llvm-svn: 75054
2009-07-08 21:45:58 +00:00
Douglas Gregor 79ca34de78 Bump the PCH version number
llvm-svn: 75049
2009-07-08 21:07:44 +00:00
Chris Lattner 26670dcba1 fix PR4513, a build problem with VC++, patch by James Abbatiello!
llvm-svn: 75013
2009-07-08 16:24:37 +00:00
Douglas Gregor be759256b9 Fix a corner case with argument-dependent lookup and overloaded function sets.
llvm-svn: 74999
2009-07-08 10:57:20 +00:00
Argyrios Kyrtzidis d8ffadcd82 Initialize the ConstantArraySizeAsWritten field of PrintingPolicy class.
It contained garbage since the constructor didn't initialize it and caused test/Sema/array-constraint.c to randomly fail.

llvm-svn: 74989
2009-07-08 02:17:42 +00:00
Fariborz Jahanian 5f21d2f69a Implemented memmove_collectable API for Next runtime
when struct variables with GC'able members are copied into.
Will provide a test case later.

llvm-svn: 74984
2009-07-08 01:18:33 +00:00
Douglas Gregor abd6813ff9 The canonical type of typeof or decltype with a dependent type is itself,
not Context.DependentTy. I'll let Anders check in the test case for this one...

llvm-svn: 74975
2009-07-08 00:03:05 +00:00
Sebastian Redl 86be854fa8 Implement checking of exception spec compatibility for overriding virtual functions.
llvm-svn: 74943
2009-07-07 20:29:57 +00:00
Anders Carlsson 1f9648da17 Some (most) type trait expressions require that the argument passed in is a complete type.
llvm-svn: 74937
2009-07-07 19:06:02 +00:00
Douglas Gregor 27821cee82 Make ASTContext explicitly keep track of the declaration for the C
FILE type, rather than using name lookup to find FILE within the
translation unit. Within precompiled headers, FILE is treated as yet
another "special type" (like __builtin_va_list).

This change should provide a performance improvement (not verified),
since the lookup into the translation unit declaration 
forces the (otherwise unneeded) construction of a large hash table.
More importantly, with precompiled headers, the construction
of that table requires deserializing most of the top-level
declarations from the precompiled header, which are then unused.

Fixes PR 4509.

llvm-svn: 74911
2009-07-07 16:35:42 +00:00
Fariborz Jahanian 003a880c41 A few change per Doug's feedback.
- Fariborz

llvm-svn: 74909
2009-07-07 16:24:08 +00:00
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 fdf5d802a8 Unbreak build by including header.
llvm-svn: 74870
2009-07-06 22:26:23 +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 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 b89c4cba7d Add some comments to the ASTLocation class.
llvm-svn: 74861
2009-07-06 21:35:09 +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 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 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
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
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 45b5302eaa AllocaRegion and SymbolicRegion are both boundable.
llvm-svn: 74815
2009-07-06 05:34:56 +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
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 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
Zhongxing Xu 66db13b7ac CompoundLiteralRegion is boundable when it is not in the file scope.
llvm-svn: 74788
2009-07-04 11:43:03 +00:00
Sebastian Redl 4f4d7b5d8e Catch function redeclarations with incompatible exception specifications.
llvm-svn: 74787
2009-07-04 11:39:00 +00:00
Zhongxing Xu 108f89cbfa StringRegion is not boundable.
llvm-svn: 74786
2009-07-04 11:31:53 +00:00
Zhongxing Xu 61e6692993 remove utility methods that are not very useful.
llvm-svn: 74762
2009-07-03 06:11:41 +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
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
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
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 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
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
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
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
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
Zhongxing Xu d0a246fd08 add utility method.
llvm-svn: 74521
2009-06-30 11:52:40 +00:00
Zhongxing Xu 41bbd51c33 add utility methods.
llvm-svn: 74520
2009-06-30 11:50:39 +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 e3d025995c Introduce DeclContext::getParentASTContext().
It's not getASTContext() to avoid "getASTContext is ambiguous" compiler errors for subclasses of both Decl and DeclContext.

llvm-svn: 74505
2009-06-30 02:35:38 +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 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
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
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
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 25d710ee50 The default answer for isBoundable() should be false.
llvm-svn: 74418
2009-06-29 05:44:14 +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
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
Douglas Gregor 15448f8d23 Improve support for overloaded operator templates.
llvm-svn: 74390
2009-06-27 21:05:07 +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 94ff77a356 More auto work.
llvm-svn: 74339
2009-06-26 22:18:59 +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
Nate Begeman f275870014 OpenCL 1.0 support: attributes
llvm-svn: 74280
2009-06-26 06:32:41 +00:00
Anders Carlsson 6915bf6158 Add NamedDecl::getUnderlyingDecl that can see through UsingDecl and ObjCCompatibleAliasDecl.
llvm-svn: 74279
2009-06-26 06:29:23 +00:00
Anders Carlsson f057cb2310 See through UsingDecls in more places.
llvm-svn: 74269
2009-06-26 05:26:50 +00:00
Zhongxing Xu 3d0fc146f9 Fix build break.
llvm-svn: 74267
2009-06-26 05:13:13 +00:00
Chris Lattner 5558e9fc55 fix PR4452, a crash on invalid. The error recovery is still terrible in this case
but at least we don't crash :)

llvm-svn: 74264
2009-06-26 04:27:47 +00:00
Nate Begeman c69b740df4 OpenCL 1.0 support: explicit casts to ext-vector types
llvm-svn: 74247
2009-06-26 00:50:28 +00:00
Ted Kremenek 27433af0ee Add missing header file.
llvm-svn: 74233
2009-06-26 00:15:05 +00:00
Douglas Gregor 4adbc6d947 Implicit instantiation for function template specializations.
For a FunctionDecl that has been instantiated due to template argument
deduction, we now store the primary template from which it was
instantiated and the deduced template arguments. From this
information, we can instantiate the body of the function template.

llvm-svn: 74232
2009-06-26 00:10:03 +00:00
Ted Kremenek 1642bdaaa5 Introduce a new concept to the static analyzer: SValuator.
GRTransferFuncs had the conflated role of both constructing SVals (symbolic
expressions) as well as handling checker-specific logic. Now SValuator has the
role of constructing SVals from expressions and GRTransferFuncs just handles
checker-specific logic. The motivation is by separating these two concepts we
will be able to much more easily create richer constraint-generating logic
without coupling it to the main checker transfer function logic.

We now have one implementation of SValuator: SimpleSValuator.

SimpleSValuator is essentially the SVal-related logic that was in GRSimpleVals
(which is removed in this patch). This includes the logic for EvalBinOp,
EvalCast, etc. Because SValuator has a narrower role than the old
GRTransferFuncs, the interfaces are much simpler, and so is the implementation
of SimpleSValuator compared to GRSimpleVals. I also did a line-by-line review of
SVal-related logic in GRSimpleVals and cleaned it up while moving it over to
SimpleSValuator.

As a consequence of removing GRSimpleVals, there is no longer a
'-checker-simple' option. The '-checker-cfref' did everything that option did
but also ran the retain/release checker. Of course a user may not always wish to
run the retain/release checker, nor do we wish core analysis logic buried in the
checker-specific logic. The next step is to refactor the logic in CFRefCount.cpp
to separate out these pieces into the core analysis engine.

llvm-svn: 74229
2009-06-26 00:05:51 +00:00
Nate Begeman 8b68d6fb83 OpenCL 1.0 Support: support "bool, true, false" tokens when compiling for OpenCL
llvm-svn: 74224
2009-06-25 23:25:15 +00:00
Nate Begeman 9d90579b6d PCH support for OpenCL language options
llvm-svn: 74220
2009-06-25 22:57:40 +00:00
Nate Begeman 95f48a5d87 OpenCL 1.0 patch 2/N: Language options & file extension
llvm-svn: 74217
2009-06-25 22:43:10 +00:00
Douglas Gregor ad3f2fcf43 Improved semantic analysis and AST respresentation for function
templates.

For example, this now type-checks (but does not instantiate the body
of deref<int>):

  template<typename T> T& deref(T* t) { return *t; }

  void test(int *ip) {
    int &ir = deref(ip);
  }

Specific changes/additions:
  * Template argument deduction from a call to a function template.
  * Instantiation of a function template specializations (just the
  declarations) from the template arguments deduced from a call.
  * FunctionTemplateDecls are stored directly in declaration contexts
  and found via name lookup (all forms), rather than finding the
  FunctionDecl and then realizing it is a template. This is
  responsible for most of the churn, since some of the core
  declaration matching and lookup code assumes that all functions are
  FunctionDecls.

llvm-svn: 74213
2009-06-25 22:08:12 +00:00
Fariborz Jahanian 41f792735f Patch to diagnose and Mark use of implicit default assignment operator.
llvm-svn: 74205
2009-06-25 21:45:19 +00:00
Nate Begeman 0359e12208 OpenCL 1.0 Support, patch 1/N: upper case swizzle operator and hex element index.
llvm-svn: 74202
2009-06-25 21:06:09 +00:00
Argyrios Kyrtzidis 7c59162edd Introduce the ResolveLocationInAST function which takes an ASTContext and a SourceLocation and it resolves it into a <Decl*, Stmt*> pair.
Decl* is the declaration associated with this source location and Stmt* is the statement/expression that the location points to.
If the location does not point to a statement node, Stmt* is null.

ResolveLocationInAST (along with converting a file:line:column triplet to a SourceLocation) will be useful for an IDE client and for clang's test suite.

llvm-svn: 74197
2009-06-25 18:22:41 +00:00
Ted Kremenek 799bb6e178 Remove uses of std::ostream from libAnalysis.
llvm-svn: 74136
2009-06-24 23:06:47 +00:00
Ted Kremenek 2c6a7b2776 Remove GRStateManager::GetSValAsScalarOrLoc()/GetSVal().
llvm-svn: 74128
2009-06-24 22:15:30 +00:00
Anders Carlsson 81df7b89de Add a DecltypeType type.
llvm-svn: 74099
2009-06-24 19:06:50 +00:00
Anders Carlsson 74948d0701 Parse the C++0x decltype specifier.
llvm-svn: 74086
2009-06-24 17:47:40 +00:00
Douglas Gregor 17a7c1297a Make sure that the template parameter lists get from the parser down to ActOnFunctionDeclarator for function template definitions
llvm-svn: 74040
2009-06-24 00:54:41 +00:00
Anders Carlsson d2e8adfc75 Support for [class.local]p4.
llvm-svn: 74030
2009-06-24 00:28:53 +00:00
Anders Carlsson 946b86d91a [class.local] p1 and p3. Also, add back the xcodeproj file.
llvm-svn: 74027
2009-06-24 00:10:43 +00:00
Douglas Gregor b52fabb2a8 Start propagating template parameter lists to the right places to
handle function templates. There's no actual code for function
templates yet, but at least we complain about typedef templates.

llvm-svn: 74021
2009-06-23 23:11:28 +00:00
Argyrios Kyrtzidis 33661d9f16 Introduce SourceManager::ísBeforeInTranslationUnit() which can compare 2 source locations and determine which one comes before the other, relative to the translation unit.
llvm-svn: 74014
2009-06-23 22:01:48 +00:00
Argyrios Kyrtzidis 25ee5db366 Move the command line source location parsing from clang-cc.cpp into "include/Frontend/CommandLineSourceLoc.h".
llvm-svn: 74012
2009-06-23 22:01:39 +00:00
Ted Kremenek 4cf427a8ae Fix build.
llvm-svn: 74009
2009-06-23 21:50:16 +00:00
Ted Kremenek 8cf2021012 Remove GRStateManager::getRegion/getSelfRegion().
llvm-svn: 74006
2009-06-23 21:37:46 +00:00
Ted Kremenek 7df5691d2d Remove GRStateManager::BindLoc() and GRStateManager::Unbind().
llvm-svn: 73996
2009-06-23 20:38:51 +00:00
Ted Kremenek 59ee3f5079 Remove GRStateManager::BindDecl() and GRStateManager::BindDeclWithInit().
llvm-svn: 73995
2009-06-23 20:27:53 +00:00
Ted Kremenek 2d99f97c17 - Add MemRegion::getMemorySpace()
- Change implementation of MemRegion::hasStackStorage()/hasHeapStorage() to use
  'getMemorySpace()'.  This avoids a double traversal up the region hierarchy
  and is simpler.
- Add MemRegion::hasHeapOrStackStorage() as a slightly more efficient
  alternative to 'hasStackStorage() || hasHeapStorage()'.

llvm-svn: 73977
2009-06-23 18:17:08 +00:00
Ted Kremenek 404b132dc0 Move 'hasStackStorage()' and 'hasHeapStorage()' from MemRegionManager to MemRegion.
llvm-svn: 73973
2009-06-23 18:05:21 +00:00
Ted Kremenek ae01dc73af API cleanup: move more methods from GRStateManager to GRState.
llvm-svn: 73968
2009-06-23 17:55:07 +00:00
Zhongxing Xu 7718ae4701 Move all factory methods from SVal to ValueManager. API cleanup!
llvm-svn: 73954
2009-06-23 09:02:15 +00:00
Zhongxing Xu 0808f70912 Split ValueManager method definitions into its own source file.
No functionality change.

llvm-svn: 73952
2009-06-23 06:22:22 +00:00
Zhongxing Xu d09b5205ef ValueManager::makeNonLoc -> ValueManager::makeIntVal
Clean up code with ValueManager.

llvm-svn: 73951
2009-06-23 06:13:19 +00:00
Zhongxing Xu b7cf95957d Instead of setting the default value of the array region, bind the rest of the
array elements to 0 explicitly. Create 0 values with the element type.

llvm-svn: 73946
2009-06-23 05:23:38 +00:00
Zhongxing Xu cbfc7d6c2e MemRegionManager: Migrate logic for getCodeTextRegion() over to using
trait-based MemRegion creation.

llvm-svn: 73941
2009-06-23 03:50:30 +00:00
Zhongxing Xu 1a195b264f Remove duplicated methods.
llvm-svn: 73940
2009-06-23 02:51:21 +00:00
Anders Carlsson 5947ddfb55 Check in a new template argument list builder that should work better for variadic templates.
llvm-svn: 73937
2009-06-23 01:26:57 +00:00
Chris Lattner e2170edfbb switch Warnings.cpp to use the diagnostics machinery to print diagnostics, not *fprintf*!
Among other things, this makes the warning about unknown warning options mappable.
For example:

$ clang t.c -Werror -Wfoo
error: unknown warning option '-Wfoo' [-Wunknown-warning-option]

For another thing, they are properly color coded now too :)

llvm-svn: 73936
2009-06-23 01:20:39 +00:00