summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add -Wobjc-string-compare under -Wobjc-literal-compare.Jordan Rose2012-07-171-9/+22
| | | | | | | | | Suggested by Ted, since string literal comparison is at least slightly more sensible than comparison of runtime literals. (Ambiguous language on developer.apple.com implies that strings are guaranteed to be uniqued within a translation unit and possibly across a linked binary.) llvm-svn: 160378
* Now that -Wobjc-literal-compare is a warning, put the fixit on a note.Jordan Rose2012-07-171-100/+66
| | | | | | | | Recovering as if the user had actually called -isEqual: is a bit too far from the semantics of the program as written, /even though/ it's probably what they intended. llvm-svn: 160377
* PR13365: Fix code which was trying to treat an array of DeducedTemplateArgumentRichard Smith2012-07-161-2/+3
| | | | | | | | as an array of its base class TemplateArgument. Switch the const TemplateArgument* parameters of InstantiatingTemplate's constructors to ArrayRef<TemplateArgument> to prevent this from happening again in the future. llvm-svn: 160245
* Downgrade the "direct comparison" error for ObjC literals to a warning.Jordan Rose2012-07-091-7/+17
| | | | | | | | | | | Chris pointed out that while the comparison is certainly problematic and does not have well-defined behavior, it isn't any worse than some of the other abuses that we merely warn about and doesn't need to make the compilation fail. Revert the release notes change (r159766) now that this is just a new warning. llvm-svn: 159939
* PR9793: Treat substitution as an instantiation step for the purpose of theRichard Smith2012-07-081-0/+2
| | | | | | | | -ftemplate-depth limit. There are various ways to get an infinite (or merely huge) stack of substitutions with no intervening instantiations. This is also consistent with gcc's behavior. llvm-svn: 159907
* Rename -Wself-assign-memvar to -Wself-assign-field to improve local ↵Nico Weber2012-07-031-8/+8
| | | | | | | | consistency a bit. (cf -Wunused-private-field and several other existing -field diagnostics.) llvm-svn: 159633
* In blocks, only pretend that enum constants have enum type if necessary.Jordan Rose2012-07-021-2/+10
| | | | | | | | | | | | | | | | | | 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
* Change condition to be the same as in SemaTemplateInstantiate.Nico Weber2012-06-291-1/+1
| | | | | | No functionality change. llvm-svn: 159436
* Warn on self-assignment to member variables. PR13104.Nico Weber2012-06-281-1/+24
| | | | llvm-svn: 159394
* Refactoring after r159290: don't hold onto and check a misleading QualType.Richard Smith2012-06-271-4/+3
| | | | llvm-svn: 159292
* Check for non-POD vararg argument type after default argument promotion, notRichard Smith2012-06-271-1/+1
| | | | | | before, so we don't incorrectly think arguments of function type are non-POD. llvm-svn: 159290
* Implement John McCall's review of r159212 other than the this pointer notRafael Espindola2012-06-271-2/+3
| | | | | | being updated. Will fix that in a second. llvm-svn: 159280
* Fix a crash I introduced in r159212.Rafael Espindola2012-06-271-0/+2
| | | | llvm-svn: 159279
* During codegen of a virtual call we would extract any casts in the expressionRafael Espindola2012-06-261-0/+16
| | | | | | | | to see if we had an underlying final class or method, but we would then use the cast type to do the call, resulting in a direct call to the wrong method. llvm-svn: 159212
* Unrevert r158887, reverted in r158949, along with a fix for the bug whichRichard Smith2012-06-251-73/+101
| | | | | | | | | | | | | | | | | | | | resulted in it being reverted. A test for that bug was added in r158950. Original comment: If an object (such as a std::string) with an appropriate c_str() member function is passed to a variadic function in a position where a format string indicates that c_str()'s return type is desired, provide a note suggesting that the user may have intended to call the c_str() member. Factor the non-POD-vararg checking out of DefaultVariadicArgumentPromotion and move it to SemaChecking in order to facilitate this. Factor the call checking out of function call checking and block call checking, and extend it to cover constructor calls too. Patch by Sam Panzer! llvm-svn: 159159
* Support L__FUNCTION__ in microsoft mode, PR11789Nico Weber2012-06-231-1/+5
| | | | | | | | | | Heavily based on a patch from Aaron Wishnick <aaron.s.wishnick@gmail.com>. I'll clean up the duplicated function in CodeGen as a follow-up, later today or tomorrow. llvm-svn: 159060
* Show fixit for unqualified calls to methods of dependent basesNico Weber2012-06-221-28/+32
| | | | | | | | when the calling site is a member function template. Effectively reverts r111675. llvm-svn: 159004
* Revert r158887. This fixes pr13168.Rafael Espindola2012-06-211-101/+73
| | | | | | | | Revert "If an object (such as a std::string) with an appropriate c_str() member function" This reverts commit 7d96f6106bfbd85b1af06f34fdbf2834aad0e47e. llvm-svn: 158949
* Don't warn for -Wstatic-in-inline if the used function is also inline.Jordan Rose2012-06-211-7/+15
| | | | | | | | | | | | | | | | | | Also, don't warn if the used function is __attribute__((const)), in which case it's not supposed to use global variables anyway. The inline-in-inline thing is a heuristic, and one that's possibly incorrect fairly often because the function being inlined could definitely use global variables. However, even some C standard library functions are written using other (trivial) static-inline functions in the headers, and we definitely don't want to be warning on that (or on anything that /uses/ these trivial inline functions). So we're using "inlined" as a marker for "fairly trivial". (Note that __attribute__((pure)) does /not/ guarantee safety like ((const), because ((const)) does not guarantee that global variables are not being used, and the warning is about globals not being shared across TUs.) llvm-svn: 158898
* If an object (such as a std::string) with an appropriate c_str() member functionRichard Smith2012-06-211-73/+101
| | | | | | | | | | | | | | | is passed to a variadic function in a position where a format string indicates that c_str()'s return type is desired, provide a note suggesting that the user may have intended to call the c_str() member. Factor the non-POD-vararg checking out of DefaultVariadicArgumentPromotion and move it to SemaChecking in order to facilitate this. Factor the call checking out of function call checking and block call checking, and extend it to cover constructor calls too. Patch by Sam Panzer! llvm-svn: 158887
* Allow unqualified lookup of non-dependent member functionsNico Weber2012-06-201-4/+2
| | | | | | | | | | in microsoft mode. Fixes PR12701. The code for this was already in 2 of the 3 branches of a conditional and missing in the 3rd branch, so lift it above the conditional. llvm-svn: 158842
* Remove -Winternal-linkage-in-inline in C++.Jordan Rose2012-06-201-58/+16
| | | | | | | | | | | | | | | | It's very easy for anonymous external linkage to propagate in C++ through return types and parameter types. Likewise, it's possible that a template containing an inline function is only used with parameters that have internal linkage. Actually diagnosing where the internal linkage comes from is fairly difficult (both to locate and then to print nicely). Finally, since we only have one translation unit available, we can't even prove that any of this violates the ODR. This warning needs better-defined behavior in C++ before it can really go in. Rewording of the C warning (which /is/ specified by C99) coming shortly. llvm-svn: 158836
* Restructure how the driver communicates information about theJohn McCall2012-06-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Change -Winternal-linkage-in-inline from ExtWarn to Warning in C++.Jordan Rose2012-06-181-8/+16
| | | | | | | | | | Per post-commit review, it's not appropriate to use ExtWarn in C++, because we can't prove that the inline function will actually be defined in more than one place (and thus we can't prove that this violates the ODR). This removes the warning entirely from uses in the main source file in C++. llvm-svn: 158689
* Support -Winternal-linkage-in-inline in C++ code.Jordan Rose2012-06-181-36/+98
| | | | | | | | This includes treating anonymous namespaces like internal linkage, and allowing const variables to be used even if internal. The whole thing's been broken out into a separate function to avoid nested ifs. llvm-svn: 158683
* Allow internal decls in inline functions if the function is in the main file.Jordan Rose2012-06-181-1/+7
| | | | | | | | | | | This handles the very common case of people writing inline functions in their main source files and not tagging them as inline. These cases should still behave as the user intended. (The diagnostic is still emitted as an extension.) I'm reworking this code anyway to account for C++'s equivalent restriction in [basic.def.odr]p6, but this should get some bots back to green. llvm-svn: 158666
* Fix Sema and IRGen for atomic compound assignment so it has the right ↵Eli Friedman2012-06-161-45/+20
| | | | | | | | semantics when promotions are involved. (As far as I can tell, this only affects some edge cases.) llvm-svn: 158591
* Warn when a static variable is referenced in a non-static inline function.Jordan Rose2012-06-151-0/+32
| | | | | | | | | | | | | This is explicitly forbidden in C99 6.7.4p3. This is /not/ forbidden in C++, probably because by default file-scope const/constexpr variables have internal linkage, while functions have external linkage. There's also the issue of anonymous namespaces to consider. Nevertheless, there should probably be a similar warning, since the semantics of inlining a function that references a variable with internal linkage do not seem well-defined. <rdar://problem/11577619> llvm-svn: 158531
* Check the parameter lists and return type of both blocks and lambdasDouglas Gregor2012-06-151-1/+14
| | | | | | | for unexpanded parameter packs. Fixes the crash-on-invalid in PR13117. llvm-svn: 158525
* PR13064: Store whether an in-class initializer uses direct or copyRichard Smith2012-06-101-1/+1
| | | | | | | initialization, and use that information to produce the right kind of initialization during template instantiation. llvm-svn: 158288
* Disallow using ObjC literals in direct comparisons (== and friends).Jordan Rose2012-06-081-0/+157
| | | | | | | | | | | | | | | Objective-C literals conceptually always create new objects, but may be optimized by the compiler or runtime (constant folding, singletons, etc). Comparing addresses of these objects is relying on this optimization behavior, which is really an implementation detail. In the case of == and !=, offer a fixit to a call to -isEqual:, if the method is available. This fixit is directly on the error so that it is automatically applied. Most of the time, this is really a newbie mistake, hence the fixit. llvm-svn: 158230
* Plug a long standing memory leak in TemplateArgument.Benjamin Kramer2012-06-071-1/+1
| | | | | | | | | | | | | | | The integral APSInt value is now stored in a decomposed form and the backing store for large values is allocated via the ASTContext. This way its not leaked as TemplateArguments are never destructed when they are allocated in the ASTContext. Since the integral data is immutable it is now shared between instances, making copying TemplateArguments a trivial operation. Currently getting the integral data out of a TemplateArgument requires creating a new APSInt object. This is cheap when the value is small but can be expensive if it's not. If this turns out to be an issue a more efficient accessor could be added. llvm-svn: 158150
* Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie2012-06-061-3/+3
| | | | | | | | | | | | | | 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
* Add a warning for when an array-to-pointer decay is performed on an arrayRichard Smith2012-06-041-0/+1
| | | | | | | | | | | | | | | temporary or an array subobject of a class temporary, and the resulting value is used to initialize a pointer which outlives the temporary. Such a pointer is always left dangling after the initialization completes and the array's lifetime ends. In order to detect this situation, this change also adds an LValueClassification of LV_ArrayTemporary for temporaries of array type which aren't subobjects of class temporaries. These occur in C++11 T{...} and GNU C++ (T){...} expressions, when T is an array type. Previously we treated the former as a generic prvalue and the latter as a class temporary. llvm-svn: 157955
* Improve fixit for comparison operator on lhs of bitwise operator.Nico Weber2012-06-031-1/+1
| | | | | | | | | | | | | | | | Before: test.cc:2:18: note: place parentheses around the == expression to silence this warning if (0 == flags & 0xdd) ^ ( ) Now: test.cc:2:18: note: place parentheses around the == expression to silence this warning if (0 == flags & 0xdd) ^ ( ) llvm-svn: 157897
* Remove some extra braces.Eric Christopher2012-05-301-3/+2
| | | | llvm-svn: 157667
* Fix PR12960 by not attempting to correct cases when we're not actually ↵David Blaikie2012-05-281-1/+2
| | | | | | | | | | instantiatiating a template. This comes up in the begin/end calls of a range-for (see the included test case). Other suggestions are welcome, though this seems to do the trick without regressing anything. llvm-svn: 157553
* Add a warning to diagnose statements in C++ like "*(volatile int*)x;". ↵Eli Friedman2012-05-241-2/+2
| | | | | | Conceptually, this is part of -Wunused-value, but I added a separate flag -Wunused-volatile-lvalue so it doesn't get turned off by accident with -Wno-unused-value. I also made a few minor improvements to existing unused value warnings in the process. <rdar://problem/11516811>. llvm-svn: 157362
* Clean up r156925, so that we only mark the capturing DeclRefExpr of aDouglas Gregor2012-05-161-4/+6
| | | | | | | | | lambda as referring to a local in an enclosing scope if we're in the enclosing scope of the lambda (not it's function call operator). Also, turn the test into an IR generation test, since that's where the crashes occurred. Really fixes PR12746 / <rdar://problem/11465120>. llvm-svn: 156926
* Fix code generation of variables reference expressions when mixingDouglas Gregor2012-05-161-1/+1
| | | | | | | blocks and lambdas, based heavily on a patch from Meador Inge. Fixes PR12746 / <rdar://problem/11465120>. llvm-svn: 156925
* Don't warn when NULL is used within a macro but its conversion is outside a ↵David Blaikie2012-05-151-1/+1
| | | | | | | | | | | | | | | | | | macro. This fixes the included test case & was reported by Nico Weber. It's a little bit nasty using the difference in the conversion context, but seems to me like a not unreasonable solution. I did have to fix up the conversion context for conditional operators (it seems correct to me to include the context for which we're actually doing the comparison - across all the nested conditionals, rather than the innermost conditional which might not actually have the problematic implicit conversion at all) and template default arguments (this is a bit of a hack, since we don't have the source location of the '=' anymore, so I just used the start of the parameter - open to suggestions there) llvm-svn: 156861
* Further improvement to wording of overload resolution diagnostics, and includingRichard Smith2012-05-151-8/+18
| | | | | | the sole parameter name in the diagnostic in more cases. Patch by Terry Long! llvm-svn: 156807
* PR11857: When the wrong number of arguments are provided for a functionRichard Smith2012-05-111-5/+12
| | | | | | | which expects exactly one argument, include the name of the argument in the diagnostic text. Patch by Terry Long! llvm-svn: 156607
* Move Sema::VerifyIntegerConstantExpression() andDouglas Gregor2012-05-041-30/+144
| | | | | | | | Sema::ConvertToIntegralOrEnumerationType() from PartialDiagnostics to abstract "diagnoser" classes. Not much of a win here, but we're -several PartialDiagnostics. llvm-svn: 156217
* Move Sema::RequireNonAbstractType() off of PartialDiagnostic.Douglas Gregor2012-05-041-3/+3
| | | | llvm-svn: 156180
* Switch RequireLiteralType() off of PartialDiagnostic.Douglas Gregor2012-05-041-1/+1
| | | | llvm-svn: 156178
* Move Sema::RequireCompleteType() and Sema::RequireCompleteExprType()Douglas Gregor2012-05-041-37/+42
| | | | | | | | | | | off PartialDiagnostic. PartialDiagnostic is rather heavyweight for something that is in the critical path and is rarely used. So, switch over to an abstract-class-based callback mechanism that delays most of the work until a diagnostic is actually produced. Good for ~11k code size reduction in the compiler and 1% speedup in -fsyntax-only on the code in <rdar://problem/11004361>. llvm-svn: 156176
* Add support for full-width 128-bit integer literals.Stephen Canon2012-05-031-2/+17
| | | | llvm-svn: 156123
* Workaround a miscompile in 483.xalancbmk while we figure it out.David Blaikie2012-05-011-1/+0
| | | | llvm-svn: 155938
* Fix PR12378: provide conversion warnings on default args of function templatesDavid Blaikie2012-04-301-2/+4
| | | | | | | | | | | | | Apparently we weren't checking default arguments when they were instantiated. This adds the check, fixes the lack of instantiation caching (which seems like it was mostly implemented but just missed the last step), and avoids implementing non-dependent default args (for non-dependent parameter types) as uninstantiated default arguments (so that we don't warn once for every instantiation when it's not instantiation dependent). Reviewed by Richard Smith. llvm-svn: 155838
OpenPOWER on IntegriCloud