summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix up various builtin declaration of objc_msgSend familiesFariborz Jahanian2013-01-041-0/+20
| | | | | | | to match those foung in objc.h an avoid spurious warnings. // rdar://12489098 llvm-svn: 171492
* Warn on unused auto variables.Rafael Espindola2013-01-031-2/+3
| | | | | | | | To do so we have to wait until we know that the type of a variable has been deduced. Sema::FinalizeDeclaration is the first callback that is used for decl with or without initializers. llvm-svn: 171458
* Use early returns to reduce indentation.Rafael Espindola2013-01-031-31/+34
| | | | llvm-svn: 171457
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-021-12/+12
| | | | llvm-svn: 171367
* Use hasCLanguageLinkage when warning about non C return types.Rafael Espindola2012-12-301-1/+1
| | | | llvm-svn: 171263
* Reject overloading of two static extern C functions.Rafael Espindola2012-12-281-28/+2
| | | | | | | | This patch moves hasCLanguageLinkage to be VarDecl and FunctionDecl methods so that they can be used from SemaOverload.cpp and then fixes the logic in Sema::IsOverload. llvm-svn: 171193
* Implement dcl.link paragraph 5.Rafael Espindola2012-12-271-0/+40
| | | | | | | The language linkage of redeclarations must match. GCC was already reporting an error for this. llvm-svn: 171139
* Add 171048 back but invalidate the cache of all redeclarations when settingRafael Espindola2012-12-251-3/+7
| | | | | | | | | | | | | | | | | | the body of a functions. The problem was that hasBody looks at the entire chain and causes problems to -fvisibility-inlines-hidden if the cache was not invalidated. Original message: Cache visibility of decls. This unifies the linkage and visibility caching. I first implemented this when working on pr13844, but the previous fixes removed the performance advantage of this one. This is still a step in the right direction for making linkage and visibility cheap to use. llvm-svn: 171053
* Revert r171048, "Cache visibility of decls."NAKAMURA Takumi2012-12-251-7/+3
| | | | | | It broke stage2. llvm-svn: 171050
* Cache visibility of decls.Rafael Espindola2012-12-251-3/+7
| | | | | | | | | | | This unifies the linkage and visibility caching. I first implemented this when working on pr13844, but the previous fixes removed the performance advantage of this one. This is still a step in the right direction for making linkage and visibility cheap to use. llvm-svn: 171048
* Move a declaration closer to its use. No functionality change.Nico Weber2012-12-231-2/+2
| | | | llvm-svn: 170992
* Add back -Wduplicate-enum which I mistakenly removed.Ted Kremenek2012-12-221-0/+178
| | | | | | | | | | | | This was removed with -Wunique-enum, which is still removed. The corresponding thread on cfe-comments for that warning is here: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-September/024224.html If we get specific user feedback for -Wduplicate-enum we can evaluate whether or not to keep it. llvm-svn: 170974
* Don't eagerly emit a global static merged with a local extern.Rafael Espindola2012-12-211-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | When we are visiting the extern declaration of 'i' in static int i = 99; int foo() { extern int i; return i; } We should not try to handle it as if it was an function static. That is, we must consider the written storage class. Fixing this then exposes that the assert in EmitGlobalVarDeclLValue and the if leading to its call are not completely accurate. They were passing before because the second decl was marked as having external storage. I changed them to check the linkage, which I find easier to understand. Last but not least, there is something strange going on with cuda and opencl. My guess is that the linkage computation for these languages needs to be audited, but I didn't want to change that in this patch so I just updated the storage classes to keep the current behavior. Thanks to Reed Kotler for reporting this. llvm-svn: 170827
* Revert "Warn if a __weak variable is initialized with an Objective-C object ↵Ted Kremenek2012-12-201-18/+1
| | | | | | | | literal." Per code feedback, I want to see if there is a more general way to do this. llvm-svn: 170777
* Warn if a __weak variable is initialized with an Objective-C object literal.Ted Kremenek2012-12-201-1/+18
| | | | | | | | | Such variables may immediately become nil or may have unpredictable behavior. Fixes <rdar://problem/12569201>. llvm-svn: 170763
* Revert r170500. It over-zealously converted *ALL* things named Attributes, ↵Bill Wendling2012-12-201-1/+1
| | | | | | which is wrong here. llvm-svn: 170721
* Rename the 'Attributes' class to 'Attribute'. It's going to represent a ↵Bill Wendling2012-12-191-1/+1
| | | | | | single attribute in the future. llvm-svn: 170500
* Change DeclContextLookup(Const)Result to (Mutable)ArrayRef<NamedDecl*>, as ↵David Blaikie2012-12-191-3/+3
| | | | | | | | | | | | | | | per review discussion in r170365 This does limit these typedefs to being sequences, but no current usage requires them to be contiguous (we could expand this to a more general iterator pair range concept at some point). Also, it'd be nice if SmallVector were constructible directly from an ArrayRef but this is a bit tricky since ArrayRef depends on SmallVectorBaseImpl for the inverse conversion. (& generalizing over all range-like things, while nice, would require some nontrivial SFINAE I haven't thought about yet) llvm-svn: 170482
* Merge storage classes even when contexts don't match.Rafael Espindola2012-12-181-2/+1
| | | | | | | | This fixes the storage class of extern decls that are merged with file level statics. The patch also fixes the linkage computation so that they are considered internal. llvm-svn: 170406
* The underlying type for an enum should be an integer type, not another enum.Eli Friedman2012-12-181-1/+5
| | | | | | | | (This change only affects ObjC.) <rdar://problem/12857117>. llvm-svn: 170402
* When warning about a missing prototype because a function declaration is ↵Anders Carlsson2012-12-181-2/+19
| | | | | | missing 'void', insert a fixit to add the void. llvm-svn: 170399
* IdentifierResolver: Remove an unnecessary include and an unused parameter.Nico Weber2012-12-171-1/+1
| | | | llvm-svn: 170297
* Have Sema::ActOnStartOfFunctionDef return the declaration that was passed it.Argyrios Kyrtzidis2012-12-141-2/+2
| | | | | | | | | | | | | | | | | | | | This fixes the missing warning here: struct S { template <typename T> void meth() { char arr[3]; arr[4] = 0; // warning: array index 4 is past the end of the array } }; template <typename T> void func() { char arr[3]; arr[4] = 0; // no warning } llvm-svn: 170180
* Using CanQualType::getAs<ArrayType> is unsafe; fix the code currently using it,Eli Friedman2012-12-131-10/+8
| | | | | | and make sure additional uses don't get introduced. <rdar://problem/12858424>. llvm-svn: 170081
* Speeds up parsing of global declarations in cases where the warningManuel Klimek2012-12-121-1/+4
| | | | | | | | | | is switched of by about 0.8% (tested with int i<N>). Additionally, this puts computing the diagnostic class into the hot path more when parsing, in preparation for upcoming optimizations in this area. llvm-svn: 169976
* Virtual method overrides can no longer have mismatched calling conventions. ↵Aaron Ballman2012-12-091-0/+1
| | | | | | This fixes PR14339. llvm-svn: 169705
* Properly compute triviality for explicitly-defaulted or deleted special members.Richard Smith2012-12-081-182/+3
| | | | | | | | | | | | | | Remove pre-standard restriction on explicitly-defaulted copy constructors with 'incorrect' parameter types, and instead just make those special members non-trivial as the standard requires. This required making CXXRecordDecl correctly handle classes which have both a trivial and a non-trivial special member of the same kind. This also fixes PR13217 by reimplementing DiagnoseNontrivial in terms of the new triviality computation technology. llvm-svn: 169667
* Fix analysis based warnings so that all warnings are emitted when compilingDeLesley Hutchins2012-12-071-1/+3
| | | | | | | | | with -Werror. Previously, compiling with -Werror would emit only the first warning in a compilation unit, because clang assumes that once an error occurs, further analysis is unlikely to return valid results. However, warnings that have been upgraded to errors should not be treated as "errors" in this sense. llvm-svn: 169649
* Add a bit on FunctionDecl/ObjCMethodDecl to indicate if there was a bodyArgyrios Kyrtzidis2012-12-061-0/+8
| | | | | | that was skipped by the parser. llvm-svn: 169531
* In C++, if we hit an error in the class-head, don't try to parse the class body.Richard Smith2012-12-051-1/+3
| | | | | | | Our error recovery path may have made the class anonymous, and that has a pretty disastrous impact on any attempt to parse a class body containing constructors. llvm-svn: 169374
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-14/+13
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Merge function types in C.Rafael Espindola2012-11-291-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Among other differences, GCC accepts typedef int IA[]; typedef int A10[10]; static A10 *f(void); static IA *f(void); void g(void) { (void)sizeof(*f()); } but clang used to reject it with: invalid application of 'sizeof' to an incomplete type 'IA' (aka 'int []') The intention of c99's 6.2.7 seems to be that we should use the composite type and accept as gcc does. Doing the type merging required some extra fixes: * Use the type from the function type in initializations, even if an parameter is available. * Fix the merging of the noreturn attribute in function types. * Make CodeGen handle the fact that an parameter type can be different from the corresponding type in the function type. llvm-svn: 168895
* Don't return a pointer to an UnresolvedSetImpl in the CXXRecordDecl interface,Argyrios Kyrtzidis2012-11-281-4/+4
| | | | | | expose only the iterators instead. llvm-svn: 168770
* Allow an ASTConsumer to selectively skip function bodies while parsing. PatchRichard Smith2012-11-271-0/+3
| | | | | | by Olivier Goffart! llvm-svn: 168726
* Add r168519 back, but with a fix to also merge the used flag in variables.Rafael Espindola2012-11-251-0/+8
| | | | llvm-svn: 168564
* Revert r168519, "Merge used flags so that we don't have to iterate on ↵NAKAMURA Takumi2012-11-241-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | isUsed. With this change" It brought bunch of (possibly false) warnings. llvm/unittests/VMCore/PassManagerTest.cpp:60:22: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration] char ModuleNDNM::ID=0; ^ llvm/unittests/VMCore/PassManagerTest.cpp:86:22: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration] char ModuleNDM2::ID=0; ^ llvm/unittests/VMCore/PassManagerTest.cpp:106:21: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration] char ModuleDNM::ID=0; ^ llvm/unittests/VMCore/PassManagerTest.cpp:217:16: warning: variable 'initcount' is not needed and will not be emitted [-Wunneeded-internal-declaration] int LPass::initcount=0; ^ llvm/unittests/VMCore/PassManagerTest.cpp:218:16: warning: variable 'fincount' is not needed and will not be emitted [-Wunneeded-internal-declaration] int LPass::fincount=0; ^ llvm/unittests/VMCore/PassManagerTest.cpp:259:16: warning: variable 'inited' is not needed and will not be emitted [-Wunneeded-internal-declaration] int BPass::inited=0; ^ llvm/unittests/VMCore/PassManagerTest.cpp:260:16: warning: variable 'fin' is not needed and will not be emitted [-Wunneeded-internal-declaration] int BPass::fin=0; ^ llvm/unittests/VMCore/PassManagerTest.cpp:283:24: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration] char OnTheFlyTest::ID=0; ^ 8 warnings generated. llvm-svn: 168549
* Merge used flags so that we don't have to iterate on isUsed. With this changeRafael Espindola2012-11-231-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | "clang -cc1 -fsyntax-only" on the preprocessed output of #define M extern int a; #define M2 M M #define M4 M2 M2 #define M8 M4 M4 #define M16 M8 M8 #define M32 M16 M16 #define M64 M32 M32 #define M128 M64 M64 #define M256 M128 M128 #define M512 M256 M256 #define M1024 M512 M512 #define M2048 M1024 M1024 #define M4096 M2048 M2048 #define M8192 M4096 M4096 #define M16384 M8192 M8192 M16384 goes from 2.994s to 1.416s. GCC is at 0.022s, so we still have a long way to go. llvm-svn: 168519
* PR14381: Never skip constexpr function bodies when code-completing. We may needRichard Smith2012-11-191-0/+16
| | | | | | them in order to parse the rest of the file. llvm-svn: 168327
* A step towards sorting out handling of triviality of special members in C++11.Richard Smith2012-11-161-13/+22
| | | | | | | | | | | | | | Separate out the notions of 'has a trivial special member' and 'has a non-trivial special member', and use them appropriately. These are not opposites of one another (there might be no special member, or in C++11 there might be a trivial one and a non-trivial one). The CXXRecordDecl predicates continue to produce incorrect results, but do so in fewer cases now, and they document the cases where they might be wrong. No functionality changes are intended here (they will come when the predicates start producing the right answers...). llvm-svn: 168119
* Provide the correct mangling and linkage for certain unnamed nested classes.David Blaikie2012-11-141-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | This corrects the mangling and linkage of classes (& their member functions) in cases like this: struct foo { struct { void func() { ... } } x; }; we were accidentally giving this nested unnamed struct 'no' linkage where it should've had the linkage of the outer class. The mangling was incorrecty too, mangling as TU-wide unnamed type mangling of $_X rather than class-scoped mangling of UtX_. This also fixes -Wunused-member-function which would incorrectly diagnose 'func' as unused due to it having no linkage & thus appearing to be TU-local when in fact it might be correctly used in another TU. Similar mangling should be applied to function local classes in similar cases but I've deferred that for a subsequent patch. Review/discussion by Richard Smith, John McCall, & especially Eli Friedman. llvm-svn: 167906
* For classes that have the warn_unused_result attribute, don't apply theKaelyn Uhrain2012-11-131-1/+5
| | | | | | | attribute to the class' methods even when they return an instance of the class (e.g. assignment operators). llvm-svn: 167873
* Enable C++11 attribute syntax for warn_unused_result and allow it to beKaelyn Uhrain2012-11-121-0/+8
| | | | | | | | | | | | | applied to CXXRecordDecls, where functions with that return type will inherit the warn_unused_result attribute. Also includes a tiny fix (with no discernable behavior change for existing code) to re-sync AttributeDeclKind enum and err_attribute_wrong_decl_type with warn_attribute_wrong_decl_type since the enum is used with both diagnostic messages to chose the correct description. llvm-svn: 167783
* PR13788: Don't perform checks on the initializer of a dependently-typedRichard Smith2012-11-091-4/+3
| | | | | | | | | variable. Previously we didn't notice the type was dependent if the only dependence came from an array bound. Patch by Brian Brooks! llvm-svn: 167642
* Avoid to write function name in comment. Thanks to Dmitri Gribenko.Abramo Bagnara2012-11-081-7/+6
| | | | llvm-svn: 167588
* Readded line removed by mistake.Abramo Bagnara2012-11-081-0/+1
| | | | llvm-svn: 167587
* Fixed converted ConstantArrayTypeLoc range. Added a missing testcase for ↵Abramo Bagnara2012-11-081-19/+71
| | | | | | ConstructorDecl source range. llvm-svn: 167583
* Partially roll back r166898; it exposed a bug in the standard.Richard Smith2012-10-291-1/+2
| | | | | | | | | | | | | The problem is as follows: C++11 has contexts which are not potentially-evaluated, and yet in which we are required or encouraged to perform constant evaluation. In such contexts, we are not permitted to implicitly define special member functions for literal types, therefore we cannot evalaute those constant expressions. Punt on this in one more context for now by skipping checking constexpr variable initializers if they occur in dependent contexts. llvm-svn: 166956
* Revert functional part of r166896 and just suppress ↵Richard Smith2012-10-281-8/+7
| | | | | | -Wunneeded-internal-declaration for reference types for now. This needs more work; the cases we currently miss are a bit random. llvm-svn: 166899
* When determining whether to try evaluating the initializer of a variable, checkRichard Smith2012-10-281-1/+1
| | | | | | | | | whether the initializer is value-dependent rather than whether we are in a dependent context. This allows us to detect some errors sooner, and fixes a crash-on-invalid if a dependent type leaks out to a non-dependent context in error recovery. llvm-svn: 166898
* In -Wunneeded-internal-declaration, suppress the warning for variables whichRichard Smith2012-10-281-1/+8
| | | | | | | | might have been used in constant expressions, rather than suppressing it for variables which are const. The important thing here is that such variables can have their values used without actually being marked as 'used'. llvm-svn: 166896
OpenPOWER on IntegriCloud