summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Sema.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Rename PCHReader to ASTReader.Sebastian Redl2010-08-181-2/+2
| | | | llvm-svn: 111467
* Rename -Wunused-method -> -Wunused-member-function.Argyrios Kyrtzidis2010-08-171-1/+1
| | | | llvm-svn: 111305
* Introduce -Wunused-method option for warning on unused class methods in ↵Argyrios Kyrtzidis2010-08-171-1/+3
| | | | | | | | | anonymous namespace. This option is not part of the Unused diagnostic group until the warnings on llvm codebase are fixed and we are ready to turn it on. Suggestion by Daniel. llvm-svn: 111298
* Commit improved version of 111026 & 111027.Argyrios Kyrtzidis2010-08-151-9/+53
| | | | | | | | | | | | | | | | | | | | Unused warnings for functions: -static functions -functions in anonymous namespace -class methods in anonymous namespace -class method specializations in anonymous namespace -function specializations in anonymous namespace Unused warnings for variables: -static variables -variables in anonymous namespace -static data members in anonymous namespace -static data members specializations in anonymous namespace Reveals lots of opportunities for dead code removal in llvm codebase that will interest my esteemed colleagues. llvm-svn: 111086
* Implement caching of code-completion results for macro definitionsDouglas Gregor2010-08-131-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | when the CXTranslationUnit_CacheCompletionResults option is given to clang_parseTranslationUnit(). Essentially, we compute code-completion results for macro definitions after we have parsed the file, then store an ASTContext-agnostic version of those results (completion string, cursor kind, priority, and active contexts) in the ASTUnit. When performing code completion in that ASTUnit, we splice the macro definition results into the results provided by the actual code-completion (which has had macros turned off) before libclang gets those results. We use completion context information to only splice in those results that make sense for that context. With a completion involving all of the macros from Cocoa.h and a few other system libraries (totally ~8500 macro definitions) living in a precompiled header, we get about a 9% performance improvement from code completion, since we no longer have to deserialize all of the macro definitions from the precompiled header. Note that macro definitions are merely the canary; the cache is designed to also support other top-level declarations, which should be a bigger performance win. That optimization will be next. Note also that there is no mechanism for determining when to throw away the cache and recompute its contents. llvm-svn: 111051
* Revert 111026 & 111027, build breakage.Argyrios Kyrtzidis2010-08-131-53/+9
| | | | llvm-svn: 111036
* The unused warnings extravaganza continues. Warn for:Argyrios Kyrtzidis2010-08-131-7/+29
| | | | | | | | | -static variables -variables in anonymous namespace (fixes rdar://7794535) -static data members in anonymous namespace -static data members specializations in anonymous namespace llvm-svn: 111027
* Expand the unused warnings for functions. Warn for:Argyrios Kyrtzidis2010-08-131-7/+29
| | | | | | | | | | -static function declarations -functions in anonymous namespace -class methods in anonymous namespace -class method specializations in anonymous namespace -function specializations in anonymous namespace llvm-svn: 111026
* Change Sema's UnusedStaticFuncs to UnusedFileScopedDecls to allow also ↵Argyrios Kyrtzidis2010-08-131-13/+15
| | | | | | | | keeping track of unused file scoped variables. This is only preparation, currently only static function definitions are tracked, as before. llvm-svn: 111025
* Teach ASTUnit to hold on to the Sema object and ASTConsumer that areDouglas Gregor2010-08-131-1/+1
| | | | | | | | used when parsing (or re-parsing) a file. Also, when loading a precompiled header into ASTUnit, create a Sema object that holds onto semantic-analysis information. llvm-svn: 111003
* Add a ParseAST overload that takes a Sema object, so that the callerDouglas Gregor2010-08-121-3/+26
| | | | | | | | | can create (and hold on to) the Sema object. Also, move Sema-related initialization/finalization with its various consumers and external sources into the Sema constructor and destructor, rather than placing it in ParseAST. llvm-svn: 110973
* Fixing the build isn't good enough; back out r110956 and r110953.John McCall2010-08-121-22/+1
| | | | llvm-svn: 110958
* dgregor should write code that compiles.John McCall2010-08-121-3/+3
| | | | llvm-svn: 110956
* Add a ParseAST overload that takes a Sema object, so that the callerDouglas Gregor2010-08-121-0/+21
| | | | | | | | | can create (and hold on to) the Sema object. Also, move Sema-related initialization/finalization with its various consumers and external sources into the Sema constructor and destructor, rather than placing it in ParseAST. llvm-svn: 110952
* Move Sema's headers into include/clang/Sema, renaming a few along the way.Douglas Gregor2010-08-121-1/+1
| | | | llvm-svn: 110945
* Speculatively revert r110610 " Make ObjCInterfaceDecl redeclarable,Douglas Gregor2010-08-111-1/+1
| | | | | | | | and create separate decl nodes for forward declarations and the definition," which appears to be causing significant Objective-C breakage. llvm-svn: 110803
* - Make ObjCInterfaceDecl redeclarable, and create separate decl nodes for ↵Sebastian Redl2010-08-091-1/+1
| | | | | | | | | | forward declarations and the definition. - Eagerly create ObjCInterfaceTypes for declarations. - The two above changes lead to a 0.5% increase in memory use and no speed regression when parsing Cocoa.h. On the other hand, now chained PCH works when there's a forward declaration in one PCH and the interface definition in another. - Add HandleInterestingDecl to ASTConsumer. PCHReader passes the "interesting" decls it finds to this function instead of HandleTopLevelDecl. The default implementation forwards to HandleTopLevelDecl, but ASTUnit's handler for example ignores them. This fixes a potential crash when lazy loading of PCH data would cause ASTUnit's "top level" declaration collection to change while being iterated. llvm-svn: 110610
* Store inheritance paths after CastExprs instead of inside them.John McCall2010-08-071-4/+4
| | | | | | | | | | | | | | | This takes some trickery since CastExpr has subclasses (and indeed, is abstract). Also, smoosh the CastKind into the bitfield from Expr. Drops two words of storage from Expr in the common case of expressions which don't need inheritance paths. Avoids a separate allocation and another word of overhead in cases needing inheritance paths. Also has the advantage of not leaking memory, since destructors for AST nodes are never run. llvm-svn: 110507
* Store the pending implicit instantiations in the PCH and perform them at the ↵Argyrios Kyrtzidis2010-08-051-20/+23
| | | | | | | | end of the translation unit that included the PCH, as God intended. llvm-svn: 110324
* Support #pragma weak for PCH.Argyrios Kyrtzidis2010-08-051-3/+3
| | | | llvm-svn: 110323
* Implement #pragma GCC visibility.Eli Friedman2010-08-051-1/+2
| | | | llvm-svn: 110315
* Read/write in PCH Sema's StdNamespace and StdBadAlloc and use a LazyDeclPtr ↵Argyrios Kyrtzidis2010-08-021-2/+1
| | | | | | for them that will deserialize them when needed. llvm-svn: 110031
* Only run the jump-checker if there's a branch-protected scope *and* there'sJohn McCall2010-08-011-1/+4
| | | | | | | | | | a switch or goto somewhere in the function. Indirect gotos trigger the jump-checker regardless, because the conditions there are slightly more elaborate and it's too marginal a case to be worth optimizing. Turns off the jump-checker in a lot of cases in C++. rdar://problem/7702918 llvm-svn: 109962
* Remove the vast majority of the Destroy methods from the AST library,Douglas Gregor2010-07-251-2/+0
| | | | | | since we aren't going to be calling them ever. llvm-svn: 109377
* Update ImplicitCastExpr to be able to represent an XValue.Sebastian Redl2010-07-201-4/+14
| | | | llvm-svn: 108807
* When looking for an entity's Scope, don't consider scopes that can't contain ↵Sebastian Redl2010-07-081-3/+6
| | | | | | declarations. Fixes PR7594. llvm-svn: 107927
* Don't try to install the __[u]int128_t identifier if it is already installed ↵Argyrios Kyrtzidis2010-07-041-1/+3
| | | | | | | | | | by PCHReader. Currently, adding it to visible decls of a PCH'ed translation unit has no effect because adding visible decls before deserialization has no effect (the decls won't be visible). This will be fixed in a future commit; then it will force deserialization of visible decls, so avoid pointlessly installing it. llvm-svn: 107595
* Move the "current scope" state from the Parser into Action. ThisDouglas Gregor2010-07-021-0/+25
| | | | | | | | | | | | | | allows Sema some limited access to the current scope, which we only use in one way: when Sema is performing some kind of declaration that is not directly driven by the parser (e.g., due to template instantiatio or lazy declaration of a member), we can find the Scope associated with a DeclContext, if that DeclContext is still in the process of being parsed. Use this to make the implicit declaration of special member functions in a C++ class more "scope-less", rather than using the NULL Scope hack. llvm-svn: 107491
* Partial fix for PR7267 based on comments by John McCall on an earlier patch.Chandler Carruth2010-06-281-2/+2
| | | | | | | | | | | | | | | | | | This is more targeted, as it simply provides toggle actions for the parser to turn access checking on and off. We then use these to suppress access checking only while we parse the template-id (included scope specifier) of an explicit instantiation and explicit specialization of a class template. The specialization behavior is an extension, as it seems likely a defect that the standard did not exempt them as it does explicit instantiations. This allows the very common practice of specializing trait classes to work for private, internal types. This doesn't address instantiating or specializing function templates, although those apparently already partially work. The naming and style for the Action layer isn't my favorite, comments and suggestions would be appreciated there. llvm-svn: 106993
* Given Decl::isUsed() a flag indicating when to consider the "used"Douglas Gregor2010-06-171-1/+2
| | | | | | | | | attribute as part of the calculation. Sema::MarkDeclReferenced(), and a few other places, want only to consider the "used" bit to determine, e.g, whether to perform template instantiation. Fixes a linkage issue with Boost.Serialization. llvm-svn: 106252
* Alter the ExternalASTSource interface to permit by-name lookups. PCH ↵John McCall2010-06-011-0/+4
| | | | | | | | | | | | | | continues to bring in the entire lookup table at once. Also, give ExternalSemaSource's vtable a home. This is important because otherwise any reference to it will cause RTTI to be emitted, and since clang is compiled with -fno-rtti, that RTTI will contain unresolved references (to ExternalASTSource's RTTI). So this change makes it possible to subclass ExternalSemaSource from projects compiled with RTTI, as long as the subclass's home is compiled with -fno-rtti. llvm-svn: 105268
* A more minimal fix for PR6762.John McCall2010-05-281-0/+2
| | | | llvm-svn: 104991
* When determining whether we can use "this", make sure to look throughDouglas Gregor2010-05-221-1/+1
| | | | | | | enum contexts (along with block contexts, which we already did). Fixes PR7196. llvm-svn: 104444
* Substantially alter the design of the Objective C type AST by introducingJohn McCall2010-05-151-5/+6
| | | | | | | | | | | | | | | | | | | | | ObjCObjectType, which is basically just a pair of one of {primitive-id, primitive-Class, user-defined @class} with a list of protocols. An ObjCObjectPointerType is therefore just a pointer which always points to one of these types (possibly sugared). ObjCInterfaceType is now just a kind of ObjCObjectType which happens to not carry any protocols. Alter a rather large number of use sites to use ObjCObjectType instead of ObjCInterfaceType. Store an ObjCInterfaceType as a pointer on the decl rather than hashing them in a FoldingSet. Remove some number of methods that are no longer used, at least after this patch. By simplifying ObjCObjectPointerType, we are now able to easily remove and apply pointers to Objective-C types, which is crucial for a certain kind of ObjC++ metaprogramming common in WebKit. llvm-svn: 103870
* Implement semantic analysis and an AST representation for the namedDouglas Gregor2010-05-151-0/+1
| | | | | | | | | | | | return value optimization. Sema marks return statements with their NRVO candidates (which may or may not end up using the NRVO), then, at the end of a function body, computes and marks those variables that can be allocated into the return slot. I've checked this locally with some debugging statements (not committed), but there won't be any tests until CodeGen comes along. llvm-svn: 103865
* Rework when and how vtables are emitted, by tracking where vtables areDouglas Gregor2010-05-131-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "used" (e.g., we will refer to the vtable in the generated code) and when they are defined (i.e., because we've seen the key function definition). Previously, we were effectively tracking "potential definitions" rather than uses, so we were a bit too eager about emitting vtables for classes without key functions. The new scheme: - For every use of a vtable, Sema calls MarkVTableUsed() to indicate the use. For example, this occurs when calling a virtual member function of the class, defining a constructor of that class type, dynamic_cast'ing from that type to a derived class, casting to/through a virtual base class, etc. - For every definition of a vtable, Sema calls MarkVTableUsed() to indicate the definition. This happens at the end of the translation unit for classes whose key function has been defined (so we can delay computation of the key function; see PR6564), and will also occur with explicit template instantiation definitions. - For every vtable defined/used, we mark all of the virtual member functions of that vtable as defined/used, unless we know that the key function is in another translation unit. This instantiates virtual member functions when needed. - At the end of the translation unit, Sema tells CodeGen (via the ASTConsumer) which vtables must be defined (CodeGen will define them) and which may be used (for which CodeGen will define the vtables lazily). From a language perspective, both the old and the new schemes are permissible: we're allowed to instantiate virtual member functions whenever we want per the standard. However, all other C++ compilers were more lazy than we were, and our eagerness was both a performance issue (we instantiated too much) and a portability problem (we broke Boost test cases, which now pass). Notes: (1) There's a ton of churn in the tests, because the order in which vtables get emitted to IR has changed. I've tried to isolate some of the larger tests from these issues. (2) Some diagnostics related to implicitly-instantiated/implicitly-defined virtual member functions have moved to the point of first use/definition. It's better this way. (3) I could use a review of the places where we MarkVTableUsed, to see if I missed any place where the language effectively requires a vtable. Fixes PR7114 and PR6564. llvm-svn: 103718
* Delete a dead function at sabre's request.Chandler Carruth2010-05-131-11/+0
| | | | llvm-svn: 103705
* Merged Elaborated and QualifiedName types.Abramo Bagnara2010-05-111-2/+2
| | | | llvm-svn: 103517
* Rearchitect -Wconversion and -Wsign-compare. Instead of computing themJohn McCall2010-05-061-2/+0
| | | | | | | | | | | | | | "bottom-up" when implicit casts and comparisons are inserted, compute them "top-down" when the full expression is finished. Makes it easier to coordinate warnings and thus implement -Wconversion for signedness conversions without double-warning with -Wsign-compare. Also makes it possible to realize that a signedness conversion is okay because the context is performing the inverse conversion. Also simplifies some logic that was trying to calculate the ultimate comparison/result type and getting it wrong. Also fixes a problem with the C++ explicit casts which are often "implemented" in the AST with a series of implicit cast expressions. llvm-svn: 103174
* Add base paths to CK_UncheckedDerivedToBase and CK_DerivedToBaseMemberPointer.Anders Carlsson2010-04-241-2/+1
| | | | llvm-svn: 102260
* CastExpr should not hold a pointer to the base path. More cleanup.Anders Carlsson2010-04-241-3/+2
| | | | llvm-svn: 102249
* Rename InheritancePath to BasePath, rename CastExpr::CXXBaseVector to ↵Anders Carlsson2010-04-241-4/+3
| | | | | | CXXBaseSpecifierArray. More to come. llvm-svn: 102245
* Add an InheritancePath parameter to the ImplicitCastExpr constructor.Anders Carlsson2010-04-231-2/+6
| | | | llvm-svn: 102218
* Remove all "used" static functions *after* we have performed all ofDouglas Gregor2010-04-091-8/+7
| | | | | | | | | the implicit template instantiations we need to perform. Otherwise, we end up erroneously diagnosing static functions as used if they were only used within an implicit template instantiation. Fixes a bunch of spurious failures when building Clang with Clang. llvm-svn: 100872
* Teach the diagnostic engine to provide more detailed information aboutDouglas Gregor2010-03-251-0/+24
| | | | | | | | | how to handle a diagnostic during template argument deduction, which may be "substitution failure", "suppress", or "report". This keeps us from, e.g., emitting warnings while performing template argument deduction. llvm-svn: 99560
* Only perform CFG-based warnings on 'static inline' functions thatTed Kremenek2010-03-231-1/+2
| | | | | | | are called (transitively) by regular functions/blocks within a translation untion. llvm-svn: 99233
* Remove the capture, serialization, and deserialization of commentDouglas Gregor2010-03-191-5/+0
| | | | | | | | ranges as part of the ASTContext. This code is not and was never used, but contributes ~250k to the size of the Cocoa.h precompiled header. llvm-svn: 99007
* Keep an explicit stack of function and block scopes, each element ofDouglas Gregor2010-03-011-4/+60
| | | | | | | | | | | | | | | | | | | | which has the label map, switch statement stack, etc. Previously, we had a single set of maps in Sema (for the function) along with a stack of block scopes. However, this lead to funky behavior with nested functions, e.g., in the member functions of local classes. The explicit-stack approach is far cleaner, and we retain a 1-element cache so that we're not malloc/free'ing every time we enter a function. Fixes PR6382. Also, tweaked the unused-variable warning suppression logic to look at errors within a given Scope rather than within a given function. The prior code wasn't looking at the right number-of-errors count when dealing with blocks, since the block's count would be deallocated before we got to ActOnPopScope. This approach works with nested blocks/functions, and gives tighter error recovery. llvm-svn: 97518
* Implement jump checking for initialized c++ variables, implementingChris Lattner2010-03-011-0/+2
| | | | | | | | | | | | | | | | | | a fixme and PR6451. Only perform jump checking if the containing function has no errors, and add the infrastructure needed to do this. On the testcase in the PR, we produce: t.cc:6:3: error: illegal goto into protected scope goto later; ^ t.cc:7:5: note: jump bypasses variable initialization X x; ^ llvm-svn: 97497
* Implementing unused function warning.Tanya Lattner2010-02-121-0/+15
| | | | llvm-svn: 95940
OpenPOWER on IntegriCloud