summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Improvements to vexing-parse warnings. Make the no-parameters case moreRichard Smith2012-07-301-55/+3
| | | | | | | | | | | | | accurate by asking the parser whether there was an ambiguity rather than trying to reverse-engineer it from the DeclSpec. Make the with-parameters case have better diagnostics by using semantic information to drive the warning, improving the diagnostics and adding a fixit. Patch by Nikola Smiljanic. Some minor changes by me to suppress diagnostics for declarations of the form 'T (*x)(...)', which seem to have a very high false positive rate, and to reduce indentation in 'warnAboutAmbiguousFunction'. llvm-svn: 160998
* Use the location of the copy assignment when diagnosing classes that are ↵Benjamin Kramer2012-07-301-4/+3
| | | | | | nontrivial because of it. llvm-svn: 160962
* Final piece of core issue 1330: delay computing the exception specification ofRichard Smith2012-07-271-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a defaulted special member function until the exception specification is needed (using the same criteria used for the delayed instantiation of exception specifications for function temploids). EST_Delayed is now EST_Unevaluated (using 1330's terminology), and, like EST_Uninstantiated, carries a pointer to the FunctionDecl which will be used to resolve the exception specification. This is enabled for all C++ modes: it's a little faster in the case where the exception specification isn't used, allows our C++11-in-C++98 extensions to work, and is still correct for C++98, since in that mode the computation of the exception specification can't fail. The diagnostics here aren't great (in particular, we should include implicit evaluation of exception specifications for defaulted special members in the template instantiation backtraces), but they're not much worse than before. Our approach to the problem of cycles between in-class initializers and the exception specification for a defaulted default constructor is modified a little by this change -- we now reject any odr-use of a defaulted default constructor if that constructor uses an in-class initializer and the use is in an in-class initialzer which is declared lexically earlier. This is a closer approximation to the current draft solution in core issue 1351, but isn't an exact match (but the current draft wording isn't reasonable, so that's to be expected). llvm-svn: 160847
* Disable the warning for missing prototypes for OpenCL kernels. Includes ↵Tanya Lattner2012-07-261-0/+4
| | | | | | testcase. llvm-svn: 160766
* Tweak warning text for returning incomplete type from extern "C" functions.Hans Wennborg2012-07-241-4/+5
| | | | | | | | | | A warning was added in r150128 for returning non-C compatible user-defined types from functions with C linkage. This makes the text more clear for the case when the type isn't decidedly non-C compatible, but incomplete. llvm-svn: 160681
* When we have an Objective-C object with non-trivial lifetime in aDouglas Gregor2012-07-231-1/+1
| | | | | | | | structor class under ARC, that struct/class does not have a trivial move constructor or move assignment operator. Fixes the rest of <rdar://problem/11738725>. llvm-svn: 160615
* Reset the layout of an ObjC class if we see an ivar in a categoryEric Christopher2012-07-191-0/+17
| | | | | | | | or implementation since we've now got a different layout. Fixes rdar://11842763 llvm-svn: 160526
* Removing a spurious comment, no functionality changes.Aaron Ballman2012-07-191-5/+0
| | | | llvm-svn: 160522
* Relaxed enumeration constant naming rules for scoped enumerators so they no ↵Aaron Ballman2012-07-191-6/+12
| | | | | | longer emit a diagnostic when the enumeration's name matches that of the class. Fixes PR13128. llvm-svn: 160490
* Merge visibility from previous decls before looking at visibility pragma. ThisRafael Espindola2012-07-171-4/+4
| | | | | | | is a bit fuzzy, but matches gcc behavior and existing code bases seem to depend on it. llvm-svn: 160364
* Record visibility pragmas when we see a tag declaration. We might use itRafael Espindola2012-07-171-0/+4
| | | | | | to build a type before seeing the definition. llvm-svn: 160339
* Without this patch clang warns onRafael Espindola2012-07-151-6/+36
| | | | | | | | | | | | | | | | | | | | | struct __attribute__((visibility("hidden"))) zed { }; struct __attribute__((visibility("hidden"))) zed; Which is a bit silly and got a lot noisier now that we correctly handle visibility pragmas. This patch fixes that and also has some extra quality improvements: * We now produce an error instead of a warning for struct __attribute__((visibility("hidden"))) zed { }; struct __attribute__((visibility("default"))) zed; * The "after definition" warning now points to the new attribute that is ignored instead of pointing to the declaration. llvm-svn: 160227
* Make const the argument of getDefinition.Rafael Espindola2012-07-151-4/+4
| | | | llvm-svn: 160226
* Use llvm::APSInt::isSameValue to compare for the same value.Eric Christopher2012-07-151-1/+1
| | | | | | Finishes rdar://11875995 llvm-svn: 160225
* Provide a special-case diagnostic when two class member functions instantiateRichard Smith2012-07-131-11/+16
| | | | | | | to the same signature. Fix a bug in the type printer which would cause this diagnostic to print wonderful types like 'const const int *'. llvm-svn: 160161
* Attaching comments to declarations during parsing: handle more Objective-C ↵Dmitri Gribenko2012-07-131-1/+0
| | | | | | declarations. llvm-svn: 160156
* Process #pragma visibility early in the parsing of class definitions. FixesRafael Espindola2012-07-121-4/+4
| | | | | | pr13338. llvm-svn: 160105
* Enable comment parsing and semantic analysis to emit diagnostics. A fewDmitri Gribenko2012-07-111-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | diagnostics implemented -- see testcases. I created a new TableGen file for comment diagnostics, DiagnosticCommentKinds.td, because comment diagnostics don't logically fit into AST diagnostics file. But I don't feel strongly about it. This also implements support for self-closing HTML tags in comment lexer and parser (for example, <br />). In order to issue precise diagnostics CommentSema needs to know the declaration the comment is attached to. There is no easy way to find a decl by comment, so we match comments and decls in lockstep: after parsing one declgroup we check if we have any new, not yet attached comments. If we do -- then we do the usual comment-finding process. It is interesting that this automatically handles trailing comments. We pick up not only comments that precede the declaration, but also comments that *follow* the declaration -- thanks to the lookahead in the lexer: after parsing the declgroup we've consumed the semicolon and looked ahead through comments. Added -Wdocumentation-html flag for semantic HTML errors to allow the user to disable only HTML warnings (but not HTML parse errors, which we emit as warnings in -Wdocumentation). llvm-svn: 160078
* Handle #pragma visibility in explicit specializations and enums.Rafael Espindola2012-07-111-6/+4
| | | | llvm-svn: 160057
* Don't process #pragma visibility during instantiation. The visibility of theRafael Espindola2012-07-111-1/+2
| | | | | | | instantiation depends on the template, its arguments and parameters, but not where it is instantiated. llvm-svn: 160034
* PR13293: Defer deduction of an auto type with a dependent declarator, such ↵Richard Smith2012-07-081-1/+4
| | | | | | as "auto (*f)(T t)". llvm-svn: 159908
* In blocks, only pretend that enum constants have enum type if necessary.Jordan Rose2012-07-021-1/+6
| | | | | | | | | | | | | | | | | | In C, enum constants have the type of the enum's underlying integer type, rather than the type of the enum. (This is not true in C++.) Thus, when a block's return type is inferred from an enum constant, it is incompatible with expressions that return the enum type. In r158899, I told block returns to pretend that enum constants have enum type, like in C++. Doug Gregor pointed out that this can break existing code. Now, we don't check the types of return statements until the end of the block. This lets us go back and add implicit casts in blocks with mixed enum constants and enum-typed expressions. <rdar://problem/11662489> (again) llvm-svn: 159591
* In Sema::ClassifyName, try to avoid nonsensical corrections toKaelyn Uhrain2012-06-291-0/+13
| | | | | | keywords when doing type correction. llvm-svn: 159464
* Add a fix-it hint note to -Wunique-enum to suggest that the last element getsRichard Trieu2012-06-291-0/+7
| | | | | | initialized with the next to last element to silence the warning. llvm-svn: 159458
* Make explicit specializations at class scope workNico Weber2012-06-251-4/+7
| | | | | | | for non-type template parameters in microsoft mode. PR12709. llvm-svn: 159147
* Perform typo correction for base class specifiers.Kaelyn Uhrain2012-06-221-5/+7
| | | | llvm-svn: 159046
* Documentation cleanup: making \param docs match the code.James Dennett2012-06-221-1/+1
| | | | llvm-svn: 158982
* Documentation cleanup:James Dennett2012-06-221-2/+2
| | | | | | | | | | | | | | | * Primarily fixed \param commands with names not matching any actual parameters of the documented functions. In many cases this consists just of fixing up the parameter name in the \param to match the code, in some it means deleting obsolete documentation and occasionally it means documenting the parameter that has replaced the older one that was documented, which sometimes means some simple reverse-engineering of the docs from the implementation; * Fixed \param ParamName [out] to the correct format with [out] before the parameter name; * Fixed some \brief summaries. llvm-svn: 158980
* Restructure how the driver communicates information about theJohn McCall2012-06-201-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | target Objective-C runtime down to the frontend: break this down into a single target runtime kind and version, and compute all the relevant information from that. This makes it relatively painless to add support for new runtimes to the compiler. Make the new -cc1 flag, -fobjc-runtime=blah-x.y.z, available at the driver level as a better and more general alternative to -fgnu-runtime and -fnext-runtime. This new concept of an Objective-C runtime also encompasses what we were previously separating out as the "Objective-C ABI", so fragile vs. non-fragile runtimes are now really modelled as different kinds of runtime, paving the way for better overall differentiation. As a sort of special case, continue to accept the -cc1 flag -fobjc-runtime-has-weak, as a sop to PLCompatibilityWeak. I won't go so far as to say "no functionality change", even ignoring the new driver flag, but subtle changes in driver semantics are almost certainly not intended. llvm-svn: 158793
* Extend the support for cl-std to include 1.2.Tanya Lattner2012-06-191-0/+17
| | | | | | | Add error checking for the static qualifier which is now allowed in certain situations for OpenCL 1.2. Use the CL version to turn on this feature. Added test case for 1.2 static storage class feature. llvm-svn: 158759
* Don't warn about address-to-member used as part of initialisation, ifJoerg Sonnenberger2012-06-171-1/+1
| | | | | | the member expression is in parentheses. llvm-svn: 158651
* Explicitly build __builtin_va_list.Meador Inge2012-06-161-2/+0
| | | | | | | The target specific __builtin_va_list types are now explicitly built instead of injecting strings into the preprocessor input. llvm-svn: 158592
* [AST/libclang] Fix the selector locations that are reported for aArgyrios Kyrtzidis2012-06-161-2/+0
| | | | | | | | | | | | | | | | | | | | | | method definition that has its '{' attached to the method name without a space. With a method like: -(id)meth{ ..... } the logic in ObjCMethodDecl that determined the selector locations got confused because it was initialized based on an end location for '{' but that end location changed to '}' after the method was finished. Fix this by having an immutable end location for the declarator and for getLocEnd() get the end location from the body itself. Fixes rdar://11659739. llvm-svn: 158583
* Recover when correcting an unknown type name to a keyword like "struct".Kaelyn Uhrain2012-06-151-12/+16
| | | | llvm-svn: 158573
* Move isCXXSimpleTypeSpecifier from Parser to Sema and tweak it for wider use.Kaelyn Uhrain2012-06-151-0/+36
| | | | llvm-svn: 158572
* If parsing a trailing-return-type fails, don't pretend we didn't have one atRichard Smith2012-06-121-1/+1
| | | | | | all. Suppresses follow-on errors mentioned in PR13074. llvm-svn: 158348
* PR13064: Store whether an in-class initializer uses direct or copyRichard Smith2012-06-101-7/+9
| | | | | | | initialization, and use that information to produce the right kind of initialization during template instantiation. llvm-svn: 158288
* Warn in ObjC++ when an 'auto' variable deduces type 'id'.Jordan Rose2012-06-081-0/+11
| | | | | | | | | | | | | | | | | | | | This could happen for cases like this: - (NSArray *)getAllNames:(NSArray *)images { NSMutableArray *results = [NSMutableArray array]; for (auto img in images) { [results addObject:img.name]; } return results; } Here the property access will fail because 'img' has type 'id', rather than, say, NSImage. This warning will not fire in templated code, since the 'id' could have come from a template parameter. llvm-svn: 158239
* Allow friend declarations of defaulted special member functions. OnlyRichard Smith2012-06-081-1/+1
| | | | | | definitions of such members are prohibited, not mere declarations. llvm-svn: 158186
* Teach the FixIt in DiagnoseInvalidRedeclaration how to replace the writtenKaelyn Uhrain2012-06-071-5/+9
| | | | | | | nested name specifiers in addition to the function's identifier when the correction has a different nested name specifier. llvm-svn: 158178
* Ignore corrections to functions with bodies when deciding whichKaelyn Uhrain2012-06-071-9/+27
| | | | | | correction to use for an invalid function redeclaration. llvm-svn: 158177
* Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie2012-06-061-2/+2
| | | | | | | | | | | | | | value_type In addition, I've made the pointer and reference typedef 'void' rather than T* just so they can't get misused. I would've omitted them entirely but std::distance likes them to be there even if it doesn't use them. This rolls back r155808 and r155869. Review by Doug Gregor incorporating feedback from Chandler Carruth. llvm-svn: 158104
* objective-c: merge deprecated/unavailable attributes toFariborz Jahanian2012-06-051-5/+2
| | | | | | | the overriding deprecated/unavailable method. // rdar://11475360 llvm-svn: 158022
* Disable -Wunique-enum for anonymous enums.David Blaikie2012-05-301-2/+4
| | | | | | | | | | | | | This is a large class of false positives where anonymous enums are used to declare constants (see Clang's Diagnostics.h for example). A small number of true positives could probably be found in this bucket by still warning if the anonymous enum is used in a declarator (enum { ... } x;) but so far we don't believe this to be a source of significant benefit so I haven't bothered to preserve those cases. General offline review/acknowledgment by rtrieu. llvm-svn: 157713
* Add new -Wunique-enum which will warn on enums which all elements have theRichard Trieu2012-05-301-0/+43
| | | | | | | | | | | | same value and were initialized with literals. Clang will warn on code like this: enum A { FIRST = 1, SECOND = 1 }; llvm-svn: 157666
* Fix indentation.David Blaikie2012-05-261-3/+3
| | | | llvm-svn: 157510
* Centralize the handling of the "attribute declaration must precede definition"Rafael Espindola2012-05-181-23/+21
| | | | | | | warning. This also makes us warn on tags, which, ironically, is the only case gcc warns on. llvm-svn: 157039
* A selector match between two Objective-C methods does *not* guaranteeDouglas Gregor2012-05-171-2/+3
| | | | | | | | that the methods have the same number of parameters, although we certainly assumed this in many places. Objective-C can be insane sometimes. Fixes <rdar://problem/11460990>. llvm-svn: 157025
* Remove word 'block' from option and diagnostic I addedFariborz Jahanian2012-05-151-1/+1
| | | | | | in r156825. llvm-svn: 156831
* objective-c nonfragile abi: discourage ivar declarationsFariborz Jahanian2012-05-151-1/+5
| | | | | | | in @interface by issuing warning (off by default) under opt'ed in flag -Winterface-block-ivar. // rdar://10763173 llvm-svn: 156825
OpenPOWER on IntegriCloud