summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Use llvm::SmallVector instead of std::vector.Ted Kremenek2010-03-121-2/+3
| | | | llvm-svn: 98397
* Maintain type source information for functions through templateJohn McCall2010-03-111-0/+1
| | | | | | | | | | | instantiation. Based on a patch by Enea Zaffanella! I found a way to reduce some of the redundancy between TreeTransform's "standard" FunctionProtoType transformation and TemplateInstantiator's override, and I killed off the old SubstFunctionType by adding type source info for the last cases where we were creating FunctionDecls without TSI (at least that get passed through template instantiation). llvm-svn: 98252
* Create a new InjectedClassNameType to represent bare-word references to the John McCall2010-03-101-18/+1
| | | | | | | | | | | | | injected class name of a class template or class template partial specialization. This is a non-canonical type; the canonical type is still a template specialization type. This becomes the TypeForDecl of the pattern declaration, which cleans up some amount of code (and complicates some other parts, but whatever). Fixes PR6326 and probably a few others, primarily by re-establishing a few invariants about TypeLoc sizes. llvm-svn: 98134
* In C++98/03, an uninitialized variable that has POD class type will beDouglas Gregor2010-03-081-15/+29
| | | | | | | | | uninitialized. This seems not to be the case in C++0x, where we still call the (trivial) default constructor for a POD class (!). Previously, we had implemented only the C++0x rules; now we implement both. Fixes PR6536. llvm-svn: 97928
* Fix for PR6294: we should only delay recording nested dynamic classes if theyEli Friedman2010-03-071-1/+1
| | | | | | | are lexically nested. Othewise, we never end up recording semantically nested classes. llvm-svn: 97900
* Diagnose the declaration of enum templates. Also, be a bit moreDouglas Gregor2010-03-021-3/+4
| | | | | | careful about value-dependent enumerators. Fixes PR5786. llvm-svn: 97570
* Keep an explicit stack of function and block scopes, each element ofDouglas Gregor2010-03-011-26/+32
| | | | | | | | | | | | | | | | | | | | 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
* Fix the lookup of names used in a friend declaration to not attempt toChandler Carruth2010-03-011-2/+3
| | | | | | | re-declare them. This fixes PR6317. Also add the beginnings of an interesting test case for p1 of [class.friend] which also covers PR6317. llvm-svn: 97499
* fix PR5933: don't warn about unused variables if a function has other errors ↵Chris Lattner2010-03-011-1/+2
| | | | | | in it. llvm-svn: 97498
* Implement jump checking for initialized c++ variables, implementingChris Lattner2010-03-011-4/+11
| | | | | | | | | | | | | | | | | | 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
* Fix a really trivial crasher and begin fleshing out one of the namespace testChandler Carruth2010-02-251-4/+7
| | | | | | cases. llvm-svn: 97134
* More Sema check for ivars in class continuation.Fariborz Jahanian2010-02-231-15/+2
| | | | llvm-svn: 97002
* Early support for declaring ivars in class extensions. wip.Fariborz Jahanian2010-02-221-0/+13
| | | | llvm-svn: 96819
* Add 'previous declaration is here' note for param redefinition Chris Lattner2010-02-221-3/+2
| | | | | | | | | | | | | errors, e.g.: t.c:1:21: error: redefinition of parameter 'x' int test(int x, int x); ^ t.c:1:14: note: previous declaration is here int test(int x, int x); ^ llvm-svn: 96769
* Eliminate the default arguments to ASTContext::getFunctionType(),Douglas Gregor2010-02-211-3/+9
| | | | | | | | fixing up a few callers that thought they were propagating NoReturn information but were in fact saying something about exception specifications. llvm-svn: 96766
* Make Decl::isOutOfLine() virtual, and use that to determine when definitionsChandler Carruth2010-02-211-8/+9
| | | | | | | are for out of line declarations more easily. This simplifies the logic and handles the case of out-of-line class definitions correctly. Fixes PR6107. llvm-svn: 96729
* Don't warn about functions redeclared without the dllimport attribute whenTed Kremenek2010-02-211-1/+5
| | | | | | -fms-extensions is enabled. Fixes <rdar://problem/7669559>. llvm-svn: 96721
* Patch removes IVars list from ObjCInterfaceDecl andFariborz Jahanian2010-02-191-1/+0
| | | | | | instead relies on their DeclContext for iteration, etc. llvm-svn: 96638
* Allow redefinitions of extern inline functions in GNU89 mode, just as GCCCharles Davis2010-02-181-2/+18
| | | | | | does. Fixes PR5253. llvm-svn: 96553
* When diagnosing enumerator values outside of the range of 'int', beDouglas Gregor2010-02-171-1/+1
| | | | | | | sure that we get the "too large" vs. "too small" part of the diagnostic correct. llvm-svn: 96524
* Do not add functions marked with the unused attribute to the list of unused ↵Tanya Lattner2010-02-171-1/+1
| | | | | | functions to warn about. Update test case. llvm-svn: 96452
* Complain if block-literal expression's parameter name isFariborz Jahanian2010-02-121-0/+1
| | | | | | missing (in c/objc mode). Fixes radar 7528255. llvm-svn: 96017
* Implementing unused function warning.Tanya Lattner2010-02-121-0/+9
| | | | llvm-svn: 95940
* Remove use of 'std::string' from Attr objects, using instead a byteTed Kremenek2010-02-111-7/+7
| | | | | | | | | array allocated using the allocator in ASTContext. This addresses these strings getting leaked when using a BumpPtrAllocator (in ASTContext). Fixes: <rdar://problem/7636765> llvm-svn: 95853
* Eliminate a bunch of unnecessary ASTContexts from members functions ofDouglas Gregor2010-02-111-10/+9
| | | | | | Decl subclasses. No functionality change. llvm-svn: 95841
* Eliminate the ASTContext parameter from RecordDecl::getDefinition()Douglas Gregor2010-02-111-1/+1
| | | | | | | and CXXRecordDecl::getDefinition(); it's totally unnecessary. No functionality change. llvm-svn: 95836
* Migrate the mish-mash of declaration checks inDouglas Gregor2010-02-091-173/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Sema::ActOnUninitializedDecl over to InitializationSequence (with default initialization), eliminating redundancy. More importantly, we now check that a const definition in C++ has an initilizer, which was an #if 0'd code for many, many months. A few other tweaks were needed to get everything working again: - Fix all of the places in the testsuite where we defined const objects without initializers (now that we diagnose this issue) - Teach instantiation of static data members to find the previous declaration, so that we build proper redeclaration chains. Previously, we had the redeclaration chain but built it too late to be useful, because... - Teach instantiation of static data member definitions not to try to check an initializer if a previous declaration already had an initializer. This makes sure that we don't complain about static const data members with in-class initializers and out-of-line definitions. - Move all of the incomplete-type checking logic out of Sema::FinalizeDeclaratorGroup; it makes more sense in ActOnUnitializedDecl. There may still be a few places where we can improve these diagnostics. I'll address that as a separate commit. llvm-svn: 95657
* Silence GCC warning and stay in 80 cols.Benjamin Kramer2010-02-061-4/+5
| | | | llvm-svn: 95494
* Implement a warning diagnostic for weak vtables. Fixes PR6116.Anders Carlsson2010-02-061-2/+9
| | | | llvm-svn: 95472
* Standardize the parsing of function type attributes in a way thatJohn McCall2010-02-051-13/+16
| | | | | | | | | | | | follows (as conservatively as possible) gcc's current behavior: attributes written on return types that don't apply there are applied to the function instead, etc. Only parse CC attributes as type attributes, not as decl attributes; don't accepet noreturn as a decl attribute on ValueDecls, either (it still needs to apply to other decls, like blocks). Consistently consume CC/noreturn information throughout codegen; enforce this by removing their default values in CodeGenTypes::getFunctionInfo(). llvm-svn: 95436
* A dependent initializer with zero arguments should return a NULLDouglas Gregor2010-02-051-1/+2
| | | | | | | initializer (for no initialization) rather than a ParenListExpr with zero arguments in it. llvm-svn: 95382
* A function declarator with a non-identifier name in an anonymous classDouglas Gregor2010-02-051-1/+2
| | | | | | is a constructor for that class, right? Fixes PR6238. llvm-svn: 95367
* Extract a common structure for holding information about the definitionJohn McCall2010-02-041-6/+20
| | | | | | | | of a C++ record. Exposed a lot of problems where various routines were silently doing The Wrong Thing (or The Acceptable Thing in The Wrong Order) when presented with a non-definition. Also cuts down on memory usage. llvm-svn: 95330
* Allow calling convention attributes to apply to types. Patch by Chip Davis!John McCall2010-02-041-0/+35
| | | | llvm-svn: 95291
* Don't do an expensive definition check where a cheap 'is this C?' check ↵Sebastian Redl2010-02-031-1/+2
| | | | | | suffices. llvm-svn: 95188
* Simplify setting of DeclContext for @catch variableFariborz Jahanian2010-02-031-9/+1
| | | | | | (per Doug's comment). llvm-svn: 95169
* Fix DeclContext of an objective-c @catch variableFariborz Jahanian2010-02-031-0/+13
| | | | | | declaration. Fixes radar 7590273. llvm-svn: 95164
* Implement promotion for enumeration types.Douglas Gregor2010-02-021-15/+11
| | | | | | | | | | | | | | | | | | | | | | | | | WHAT!?! It turns out that Type::isPromotableIntegerType() was not considering enumeration types to be promotable, so we would never do the promotion despite having properly computed the promotion type when the enum was defined. Various operations on values of enum type just "worked" because we could still compute the integer rank of an enum type; the oddity, however, is that operations such as "add an enum and an unsigned" would often have an enum result type (!). The bug actually showed up as a spurious -Wformat diagnostic (<rdar://problem/7595366>), but in theory it could cause miscompiles. In this commit: - Enum types with a promotion type of "int" or "unsigned int" are promotable. - Tweaked the computation of promotable types for enums - For all of the ABIs, treat enum types the same way as their underlying types (*not* their promotion types) for argument passing and return values - Extend the ABI tester with support for enumeration types llvm-svn: 95117
* Check for redefinitions in MergeVarDecl. This finds redefinitions of globals ↵Sebastian Redl2010-02-021-0/+11
| | | | | | without an initializer in C++ and thus fixes PR5451. llvm-svn: 95098
* Mark dtors for parameter variables and eliminate some redundant type munging.John McCall2010-02-021-3/+3
| | | | llvm-svn: 95079
* Improve handling of enumerator values for C and C++, including:Douglas Gregor2010-02-011-39/+133
| | | | | | | | | | | | | | | | | - In C++, prior to the closing '}', set the type of enumerators based on the type of their initializer. Don't perform unary conversions on the enumerator values. - In C++, handle overflow when an enumerator has no initializer and its value cannot be represented in the type of the previous enumerator. - In C, handle overflow more gracefully, by complaining and then falling back to the C++ rules. - In C, if the enumerator value is representable in an int, convert the expression to the type 'int'. Fixes PR5854 and PR4515. llvm-svn: 95031
* In C++, an initializer on a variable doesn't necessarily mean it's the ↵Sebastian Redl2010-02-011-5/+5
| | | | | | definition. With that in mind, rename getDefinition to getAnyInitializer (to distinguish it from getInit) and reimplement it in terms of isThisDeclarationADefinition. Update all code to use this new function. llvm-svn: 94999
* Add VarDecl::isThisDeclarationADefinition(), which properly encapsulates the ↵Sebastian Redl2010-01-311-23/+4
| | | | | | logic for when a variable declaration is a (possibly tentativ) definition. Add a few functions building on this, and shift C tentative definition handling over to this new functionality. This shift also kills the Sema::TentativeDefinitions map and instead simply stores all declarations in the renamed list. The correct handling for multiple tentative definitions is instead shifted to the final walk of the list. llvm-svn: 94968
* Implement access control for overloaded functions. Suppress access controlJohn McCall2010-01-271-0/+1
| | | | | | | diagnostics in "early" lookups, such as during typename checks and when building unresolved lookup expressions. llvm-svn: 94647
* Split libAnalysis into two libraries: libAnalysis and libChecker.Ted Kremenek2010-01-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | (1) libAnalysis is a generic analysis library that can be used by Sema. It defines the CFG, basic dataflow analysis primitives, and inexpensive flow-sensitive analyses (e.g. LiveVariables). (2) libChecker contains the guts of the static analyzer, incuding the path-sensitive analysis engine and domain-specific checks. Now any clients that want to use the frontend to build their own tools don't need to link in the entire static analyzer. This change exposes various obvious cleanups that can be made to the layout of files and headers in libChecker. More changes pending. :) This change also exposed a layering violation between AnalysisContext and MemRegion. BlockInvocationContext shouldn't explicitly know about BlockDataRegions. For now I've removed the BlockDataRegion* from BlockInvocationContext (removing context-sensitivity; although this wasn't used yet). We need to have a better way to extend BlockInvocationContext (and any LocationContext) to add context-sensitivty. llvm-svn: 94406
* Implement [dcl.fct.spec]p6.Anders Carlsson2010-01-241-0/+22
| | | | llvm-svn: 94365
* Implement elementary access control.John McCall2010-01-231-1/+3
| | | | llvm-svn: 94268
* Patch fixes a lookup bug in c++'s anonymous union memberFariborz Jahanian2010-01-221-1/+7
| | | | | | lookup. Fixes radar 7562438. llvm-svn: 94191
* Create function, block, and template parameters in the context of theJohn McCall2010-01-221-2/+7
| | | | | | | | | translation unit. This is temporary for function and block parameters; template parameters can just stay this way, since Templates aren't DeclContexts. This gives us the nice property that everything created in a record DC should have access in C++. llvm-svn: 94122
* Speed up compilation by avoiding generating exceptional edges fromMike Stump2010-01-211-1/+3
| | | | | | | | | | | | | CallExprs as those edges help cause a n^2 explosion in the number of destructor calls. Other consumers, such as static analysis, that would like to have more a more complete CFG can select the inclusion of those edges as CFG build time. This also fixes up the two compilation users of CFGs to be tolerant of having or not having those edges. All catch code is assumed be to live if we didn't generate the exceptional edges for CallExprs. llvm-svn: 94074
OpenPOWER on IntegriCloud