summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Fix false positive in -Wunused-variable when a ctor call make involve cleanups.David Blaikie2012-10-241-0/+2
| | | | llvm-svn: 166625
* Add a new warning -Wmissing-variable-declarations, to warn about variablesEli Friedman2012-10-231-0/+11
| | | | | | | | | defined without a previous declaration. This is similar to -Wmissing-prototypes, but for variables instead of functions. Patch by Ed Schouten. llvm-svn: 166498
* Rework implementation of DR1492: Apply the resolution to operator delete too,Richard Smith2012-10-201-0/+14
| | | | | | | | | | | | since it also has an implicit exception specification. Downgrade the error to an extwarn, since at least for operator delete, system headers like to declare it as 'noexcept' whereas the implicit definition does not have an explicit exception specification. Move the exception specification for user-declared 'operator delete' functions from the type-as-written into the type, to reflect reality and to allow us to detect whether there was an implicit exception spec or not. llvm-svn: 166372
* Allow objc_requires_super to be used to check class methods as well.Jordan Rose2012-10-191-10/+3
| | | | | | | | | | | | | Also, unify ObjCShouldCallSuperDealloc and ObjCShouldCallSuperFinalize. The two have identical behavior and will never be active at the same time. There's one last simplification now, which is that if we see a call to [super foo] and we are currently in a method named 'foo', we will /unconditionally/ clear the ObjCShouldCallSuper flag, rather than check first to see if we're in a method where calling super is required. There's no reason to pay the extra lookup price here. llvm-svn: 166285
* Implement C++ 10.3p16 - overrides involving deleted functions must match.David Blaikie2012-10-171-11/+38
| | | | | | | Only deleted functions may override deleted functions and non-deleted functions may only override non-deleted functions. llvm-svn: 166082
* Fix warnings introduced by r165826.DeLesley Hutchins2012-10-121-0/+2
| | | | llvm-svn: 165829
* Thread-safety analysis: support multiple thread-safety attributes onDeLesley Hutchins2012-10-121-0/+17
| | | | | | declarations. llvm-svn: 165826
* Fix typo correction of one qualified name to another.David Blaikie2012-10-121-3/+9
| | | | | | | | | | | | | | When suggesting "foo::bar" as a correction for "fob::bar" we mistakenly replaced only "bar" with "foo::bar" producing "fob::foo::bar" which was broken. This corrects that replacement in as many places as I could find & provides test cases for all those cases I could find a test case for. There are a couple that don't seem to be reachable (one looks entirely dead, the other just doesn't seem to ever get called with a namespace to namespace change). Review by Richard Smith ( http://llvm-reviews.chandlerc.com/D57 ). llvm-svn: 165817
* When storing the C++ overridden methods, store them once for theArgyrios Kyrtzidis2012-10-091-1/+2
| | | | | | canonical method; avoid storing them again for an out-of-line definition. llvm-svn: 165472
* Fixed FunctionTypeLoc source range.Abramo Bagnara2012-10-041-6/+21
| | | | llvm-svn: 165259
* Fixed ParamDecl source range for implicit typed k&r parameters.Abramo Bagnara2012-10-041-0/+3
| | | | llvm-svn: 165256
* Fix scope location when parsing GNU attributes.Michael Han2012-10-041-2/+1
| | | | | | | | For GNU attributes, instead of reusing attribute source location for the scope location, use SourceLocation() since GNU attributes don not have scope tokens. llvm-svn: 165234
* Change how the SelfReferenceChecker handles MemberExpr. Instead of treatingRichard Trieu2012-10-031-11/+39
| | | | | | | each one separately, process a stack of MemberExpr's as a single unit so that static calls and member access will not be warned on. llvm-svn: 165074
* Tweak diagnostic text to indicate that __weak on a local variable is only ↵Ted Kremenek2012-10-021-1/+3
| | | | | | | | allowed for ARC. Fixes <rdar://problem/12407705> llvm-svn: 164990
* PR13978: A 'decltype' DeclSpec has an expression representation, not a typeRichard Smith2012-10-011-1/+1
| | | | | | | representation. Fix crash if it appears in the return type of a member function definition. llvm-svn: 164967
* Cleaning up the self initialization checker.Richard Trieu2012-10-011-31/+38
| | | | | | | | | | | -Allow Sema to do more processing on the initial Expr before checking it. -Remove the special conditions in HandleExpr() -Move the code so that only one call site is needed. -Removed the function from Sema and only call it locally. -Warn on potentially evaluated reference variables, not just casts to r-values. -Update tests. llvm-svn: 164951
* Move the 'find macro by spelling' infrastructure to the Preprocessor class andDmitri Gribenko2012-09-291-1/+1
| | | | | | | use it to suggest appropriate macro for __attribute__((deprecated)) in -Wdocumentation-deprecated-sync. llvm-svn: 164892
* Add a warning (off by default) for repeated use of the same weak property.Jordan Rose2012-09-281-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The motivating example: if (self.weakProp) use(self.weakProp); As with any non-atomic test-then-use, it is possible a weak property to be non-nil at the 'if', but be deallocated by the time it is used. The correct way to write this example is as follows: id tmp = self.weakProp; if (tmp) use(tmp); The warning is controlled by -Warc-repeated-use-of-receiver, and uses the property name and base to determine if the same property on the same object is being accessed multiple times. In cases where the base is more complicated than just a single Decl (e.g. 'foo.bar.weakProp'), it picks a Decl for some degree of uniquing and reports the problem under a subflag, -Warc-maybe-repeated-use-of-receiver. This gives a way to tune the aggressiveness of the warning for a particular project. The warning is not on by default because it is not flow-sensitive and thus may have a higher-than-acceptable rate of false positives, though it is less noisy than -Wreceiver-is-weak. On the other hand, it will not warn about some cases that may be legitimate issues that -Wreceiver-is-weak will catch, and it does not attempt to reason about methods returning weak values. Even though this is not a real "analysis-based" check I've put the bug emission code in AnalysisBasedWarnings for two reasons: (1) to run on every kind of code body (function, method, block, or lambda), and (2) to suggest that it may be enhanced by flow-sensitive analysis in the future. The second (smaller) half of this work is to extend it to weak locals and weak ivars. This should use most of the same infrastructure. Part of <rdar://problem/12280249> llvm-svn: 164854
* Revert 'Fix a typo 'iff' => 'if''. iff is an abreviation of if and only if. ↵Sylvestre Ledru2012-09-271-2/+2
| | | | | | See: http://en.wikipedia.org/wiki/If_and_only_if Commit 164766 llvm-svn: 164769
* Fix a typo 'iff' => 'if'Sylvestre Ledru2012-09-271-2/+2
| | | | llvm-svn: 164766
* Fix for r163013 regression and further __interface enhancement.John McCall2012-09-251-5/+6
| | | | | | Patch by Andy Gibbs! llvm-svn: 164590
* Make warnings about uninitialized fields include the field name.Hans Wennborg2012-09-211-3/+1
| | | | | | | | | | | This makes the wording more informative, and consistent with the other warnings about uninitialized variables. Also, me and David who reviewed this couldn't figure out why we would need to do a lookup to get the name of the variable; so just print the name directly. llvm-svn: 164366
* Include types when a definition's type differs from a prior declaration.David Blaikie2012-09-201-1/+1
| | | | | | | | | | | | | This is some really old code (took me a while to find the test cases) & the diagnostic text is slightly incorrect (it should really only apply to re/declarations/, redefinitions are an error regardless of whether the types match). Not sure if anyone cares about it, though. For now this just makes the diagnostic more clear in less obvious cases where the type of a declaration might not be explicitly written (eg: because it uses decltype) llvm-svn: 164313
* Handle lambdas where the lambda-declarator is an explicit "(void)". PR13854.Eli Friedman2012-09-201-15/+17
| | | | llvm-svn: 164274
* Per discussion on cfe-dev, remove -Wunique-enums entirely. ThereTed Kremenek2012-09-181-230/+0
| | | | | | | | is no compelling argument that this is a generally useful warning, and imposes a strong stylistic argument on code beyond what it was intended to find warnings in. llvm-svn: 164083
* -Warc-retain-cycles: warn at variable initialization as well as assignment.Jordan Rose2012-09-151-1/+5
| | | | | | | | | | | | | | | | | | Specifically, this should warn: __block block_t a = ^{ a(); }; Furthermore, this case which previously warned now does not, since the value of 'b' is captured before the assignment occurs: block_t b; // not __block b = ^{ b(); }; (This will of course warn under -Wuninitialized, as before.) <rdar://problem/11015883> llvm-svn: 163962
* objective-C arc: remove -Warc-abi in its entirety.Fariborz Jahanian2012-09-141-36/+0
| | | | | | // rdar://10554025 llvm-svn: 163917
* Fix warning on qualified typedef with 'unused' attribute, from Jason Haslam!Douglas Gregor2012-09-141-1/+1
| | | | llvm-svn: 163874
* Promote the warning about extra qualification on a declaration from aDouglas Gregor2012-09-131-1/+2
| | | | | | | | warning to an error. C++ bans it, and both GCC and EDG diagnose it as an error. Microsoft allows it, so we still warn in Microsoft mode. Fixes <rdar://problem/11135644>. llvm-svn: 163831
* objective-C: Improving diagnostocs for missing call toFariborz Jahanian2012-09-101-2/+2
| | | | | | super's annotated methods. // rdar://6386358 llvm-svn: 163517
* objective-C: introduce __attribute((objc_requires_super)) on methodFariborz Jahanian2012-09-071-1/+2
| | | | | | | | in classes. Use it to flag those method implementations which don't contain call to 'super' if they have 'super' class and it has the method with this attribute set. This is wip. // rdar://6386358 llvm-svn: 163434
* refactoring + objective-C specific test for my last patch.Fariborz Jahanian2012-09-061-5/+1
| | | | | | // rdar://12233989 llvm-svn: 163338
* Dont cast away const needlessly. Found by gcc48 -Wcast-qual.Roman Divacky2012-09-061-2/+2
| | | | llvm-svn: 163325
OpenPOWER on IntegriCloud