summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
* fix pr18645. Correct logic concerning 'T &&' deduction against lvalues.Nathan Sidwell2015-01-101-30/+17
| | | | llvm-svn: 225587
* Add a new warning, -Wself-move, to Clang.Richard Trieu2015-01-101-1/+87
| | | | | | | | -Wself-move is similiar to -Wself-assign. This warning is triggered when a value is attempted to be moved to itself. See r221008 for a bug that would have been caught with this warning. llvm-svn: 225581
* Fix temporary lifetime extension from an initializer using braced "functional"Richard Smith2015-01-101-7/+7
| | | | | | cast notation T{...} when T is a reference type. llvm-svn: 225571
* Sema: Don't crash when variable is redefined as a constexpr functionDavid Majnemer2015-01-091-1/+1
| | | | | | | | | We have a diagnostic describing that constexpr changed in C++14 when compiling in C++11 mode. While doing this, it examines the previous declaration and assumes that it is a function. However it is possible, in the context of error recovery, for this to not be the case. llvm-svn: 225518
* Parse: Don't crash when namespace is in GNU statement exprDavid Majnemer2015-01-091-5/+0
| | | | | | | | | | | Parser::ParseNamespace can get a little confused when it found itself inside a compound statement inside of a non-static data member initializer. Try to determine that the statement expression's scope makes sense before trying to parse it's contents. llvm-svn: 225514
* Fix crash in typo correction while correcting enum within a struct in COlivier Goffart2015-01-091-2/+4
| | | | llvm-svn: 225513
* Sema: RecordDecl shouldn't have a FunctionDecl as a DeclDavid Majnemer2015-01-091-1/+6
| | | | | | | RecordDecls should have things like CXXMethodDecls or FriendDecls as a decl but not things like FunctionDecls. llvm-svn: 225511
* Sema: Don't crash when specializing a global scope function in a classDavid Majnemer2015-01-091-1/+1
| | | | | | | | We assumed that class-scope specializations would result in a CXXMethodDecl for that class. However, globally qualified functions will result in normal FunctionDecls. llvm-svn: 225508
* Sema: Remove some dead code from CreateNewFunctionDeclDavid Majnemer2015-01-091-3/+0
| | | | | | | The same code is already in Sema::ActOnFunctionDeclarator, the only caller of CreateNewFunctionDecl. llvm-svn: 225506
* PR22117: Fix a case where we would get confused about which function parameterRichard Smith2015-01-092-7/+29
| | | | | | | | | | we're instantiating, if there's a ParmVarDecl within a FunctionDecl context that is not a parameter of that function. Add some asserts to catch this kind of issue more generally, and fix another bug exposed by those asserts where we were missing a local instantiation scope around substitution of explicitly-specified template arguments. llvm-svn: 225490
* Don't invent a '$auto-x-y' name for auto types in generic lambdas. This is noRichard Smith2015-01-091-11/+2
| | | | | | | | | better than the 'template-parameter-x-y' name that we'd get in AST printing, and is worse in several ways (it's harder to distinguish it from a user-supplied name, it's wrong after substituting some number of outer levels, it wastes time and space constructing an IdentifierInfo, ...). llvm-svn: 225489
* Wrap to 80 columns. No behavior change.Nico Weber2015-01-071-29/+20
| | | | llvm-svn: 225414
* Handle OpaqueValueExprs more intelligently in the TransformTypos treeKaelyn Takata2015-01-072-1/+9
| | | | | | | | | | | | transform. Also diagnose typos in the initializer of an invalid C++ declaration. Both issues were hit using the same line of test code, depending on whether the code was treated as C or C++. Fixes PR22092. llvm-svn: 225389
* Fix grammar-o in comment.Nico Weber2015-01-061-1/+1
| | | | llvm-svn: 225324
* Sema: analyze I,J,K,M,N,O constraintsSaleem Abdulrasool2015-01-061-0/+14
| | | | | | | | | | Add additional constraint checking for target specific behaviour for inline assembly constraints. We would previously silently let all arguments through for these constraints. In cases where the constraints were violated, we could end up failing to select instructions and triggering assertions or worse, silently ignoring instructions. llvm-svn: 225244
* Wrap to 80 columns, no behavior change.Nico Weber2015-01-041-4/+7
| | | | llvm-svn: 225128
* Document that GetTypeForDeclarator() cannot return a null type.Nico Weber2015-01-041-13/+12
| | | | | | | | | | | | | Also add a few asserts for this. The existing code assumes this in a bunch of places already (see e.g. the assert at the top of ParseTypedefDecl(), and there are many unchecked calls on the result of GetTypeForDeclarator()), and from looking through the code this should always be true from what I can tell. This allows removing ASTContext::getNullTypeSourceInfo() too as that's now unused. No behavior change intended. llvm-svn: 225125
* Crash less enthusiasticially on _Atomic or __restrict__ on invalid types.Nico Weber2015-01-041-0/+6
| | | | | | | | | | Many places in Sema cannot handle isNull() types. This is fine, because in most places the type building code recovers by falling back to IntTy. In GetFullTypeForDeclarator(), this is done at the end of the getNumTypeObjects() loop body. This function calls BuildQualifiedType() before this fallback is done though, so it explicitly needs to check for isNull() types. llvm-svn: 225124
* Instantiation of a CXXMethodDecl may fail when the parameter type cannot be ↵Nick Lewycky2015-01-021-2/+4
| | | | | | | | | | | | instantiated. Do not crash in this case. Fixes PR22040! The FIXME in the test is caused by TemplateDeclInstantiator::VisitCXXRecordDecl returning a nullptr instead of creating an invalid decl. This is a common pattern across all of TemplateDeclInstantiator, so I'm not comfortable changing it. The reason it's not invalid in the class template is due to support for an MSVC extension, see r137573. llvm-svn: 225071
* Remove a comment that appears a second time 22 lines further down.Nico Weber2014-12-301-3/+0
| | | | llvm-svn: 225004
* Don't crash on an invalid trailing return type on a function before a '...'Nico Weber2014-12-301-5/+5
| | | | | | | | | | | | clang tries to produce a helpful diagnostic for the traiilng '...', but the code that r216778 added for this doesn't expect an invalid trailing return type. Add code to explicitly handle this. Having explicit code for this but not for other things looks a bit strange, but trailing return types are special in that they have a separate existence bit in addition to the type (see r158348). llvm-svn: 224974
* Sema: Permit array l-values in asm output operandsDavid Majnemer2014-12-291-0/+3
| | | | | | | | GCC permits array l-values in asm output operands even though they aren't modifiable l-values. We used to permit it but this behavior regressed in r224916. llvm-svn: 224918
* Sema: Only permit permit modifiable l-values as asm output paramsDavid Majnemer2014-12-291-14/+42
| | | | | | | | | | Functions are l-values in C++ but shouldn't be available as output parameters in inline assembly. Neither should overloaded function l-values. This fixes PR21949. llvm-svn: 224916
* Sema: Don't crash when solitary :: token appears before { in struct defDavid Majnemer2014-12-291-1/+1
| | | | | | | | hasDeclaratorForAnonDecl, getDeclaratorForAnonDecl and getTypedefNameForAnonDecl are expected to handle the case where NamedDeclOrQualifier holds the wrong type or nothing at all. llvm-svn: 224912
* Sema: Forbid inconsistent constraint alternativesDavid Majnemer2014-12-291-0/+20
| | | | | | Verify that asm constraints have the same number of alternatives llvm-svn: 224911
* Sema: Variable templates cannot be static bitfield membersDavid Majnemer2014-12-281-1/+1
| | | | | | | We correctly forbid variables but not variable templates. Diagnose this case instead of crashing. llvm-svn: 224905
* Sema: Permit an atomic type to be initialized by the same atomic typeDavid Majnemer2014-12-281-1/+5
| | | | | | | | | We forgot a conversion step when initializing an atomic type with an rvalue of the same type. This fixes PR22043. llvm-svn: 224902
* Sema: Don't crash when an inject class name has a nested redefinitionDavid Majnemer2014-12-281-3/+2
| | | | | | | | | We expected the type of a TagDecl to be a TagType, not an InjectedClassNameType. Introduced a helper method, Type::getAsTagDecl, to abstract away the difference; redefine Type::getAsCXXRecordDecl to be in terms of it. llvm-svn: 224898
* Objective-C: Tweak unavailability warning.Nico Weber2014-12-271-1/+1
| | | | | | | Don't warn when a selector has an unavailable and an available variant, and the first also has an implementation. llvm-svn: 224881
* [x86] Add range checking to the constant argument of cmpps/pd/ss/sd builtinas.Craig Topper2014-12-271-4/+8
| | | | llvm-svn: 224880
* Address review feedback on r221933.Nico Weber2014-12-273-74/+83
| | | | | | | | | | | Remove ObjCMethodList::Count, instead store a "has more than one decl" bit in the low bit of the ObjCMethodDecl pointer, using a PointerIntPair. Most of this patch is replacing ".Method" with ".getMethod()". No intended behavior change. llvm-svn: 224876
* WIPDavid Majnemer2014-12-261-16/+16
| | | | llvm-svn: 224843
* This reverts commit r224668 and r224667.Rafael Espindola2014-12-231-7/+0
| | | | | | | | | | r224667 broke bootstrap on Fedora 20 X86_64 (at least). See pr22006 for the details. r224668 depends on r224667. llvm-svn: 224770
* Fix for PR21758Richard Trieu2014-12-201-0/+7
| | | | | | | | | When a non-type template argument expression needs a conversion to change it into the argument type, preserve that information by remaking the TemplateArgument with an expression that has those conversions. Also a small fix to template type diffing to handle the extra conversions in some cases. llvm-svn: 224667
* Don't drop attributes when checking explicit specializations.Nico Weber2014-12-191-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider a template class with attributes on a method, and an explicit specialization of that method: template <int> struct A { void foo() final; }; template <> void A<0>::foo() {} In this example, the attribute is `final`, but it might also be an __attribute__((visibility("foo"))), noreturn, inline, etc. clang's current behavior is to strip all attributes, which for some attributes is wrong (the snippet above allows a subclass of A<0> to override the final method, for example) and for others disagrees with gcc. So stop dropping attributes. r95845 added this code without a test case, and r176728 added the code for dropping attributes on parameters (with tests, but they still pass). As an additional wrinkle, do drop dllimport and dllexport, since that's how these two attributes work. (This is covered by existing tests.) Fixes PR21942. The approach is by Richard Smith, initial analysis and typing was done by me. With this, clang also matches GCC and EDG on all attributes Richard tested. llvm-svn: 224651
* DR1048: drop top-level cv-qualifiers when deducing the return type of aRichard Smith2014-12-192-3/+12
| | | | | | lambda-expression in C++11, to match the C++14 rules. llvm-svn: 224620
* Attributes accepting an EnumArgument are allowed to pass a string literal, ↵Aaron Ballman2014-12-191-2/+8
| | | | | | | | or an identifier. VariadicEnumArguments now behave consistently instead of only accepting a string literal. This change affects the only attribute accepting a variadic enumeration: callable_when. llvm-svn: 224582
* PR21969: Improve diagnostics for a conversion function that has any pieces of aRichard Smith2014-12-191-4/+88
| | | | | | declared return type (including a trailing-return-type in C++14). llvm-svn: 224561
* [c Sema]. Patch fixes pointer-bool-conversion warning on C codeFariborz Jahanian2014-12-181-2/+2
| | | | | | | | when source range is incorrect causing the warning to be issued when it should not because expression is in a macro. rdar://19256338 llvm-svn: 224549
* Revert "Don't build invalid AST nodes during recovery"Reid Kleckner2014-12-181-1/+1
| | | | | | | | | | | This reverts commit r224451. It caused us to reject some valid existing code. This code appears to run in non-error cases as well as error cases. If the scope of a DependentScopeDeclRefExpr is still incomplete it probably means we still have more instantiation to do. llvm-svn: 224526
* Fix diagnostic for static methods referencing fields from using declsReid Kleckner2014-12-181-2/+4
| | | | | | | | | | | | Previously we thought the instance member was a function, not a field, and we'd say something silly like: t.cpp:4:27: error: call to non-static member function without an object argument static int f() { return n; } ^ Noticed in PR21923. llvm-svn: 224480
* Don't assume friended C++ method decls have qualifiersReid Kleckner2014-12-171-2/+2
| | | | | | | | | | | There are a few cases where unqualified lookup can find C++ methods. Unfortunately, none of them seem to have illegal access paths, so I can't excercise the diagnostic source range code that I am changing here. Fixes PR21851, which was a crash on valid. llvm-svn: 224471
* Adding a -Wunused-value warning for expressions with side effects used in an ↵Aaron Ballman2014-12-174-3/+42
| | | | | | unevaluated expression context, such as sizeof(), or decltype(). Also adds a similar warning when the expression passed to typeid() *is* evaluated, since it is equally likely that the user would expect the expression operand to be unevaluated in that case. llvm-svn: 224465
* [c++1z] Fixes for generalized non-type template argument support: check forRichard Smith2014-12-171-42/+45
| | | | | | | | exact type match for deduced template arguments, and be sure to produce correct canonical TemplateArgument representations to enable correct redeclaration matching. llvm-svn: 224456
* Don't build invalid AST nodes during recoveryReid Kleckner2014-12-171-1/+1
| | | | | | | | | | | | | | A DependentScopeDeclRefExpr should always have a nested name specifier. During template instantiation, if we found that the named context was incomplete, we would previously build a DependentScopeDeclRefExpr with an empty qualifier. This error recovery path has been asserting for some time. The other error codepaths use ExprError, so we can do the same. Fixes PR21864. llvm-svn: 224451
* Sema: Don't dyn_cast a null pointer in CheckUsingDeclQualifierDavid Majnemer2014-12-171-1/+1
| | | | | | | | | This code was written with the intent that a pointer could be null but we dyn_cast'd it anyway. Change the dyn_cast to a dyn_cast_or_null. This fixes PR21933. llvm-svn: 224411
* DR1684: a constexpr member function need not be a member of a literal class ↵Richard Smith2014-12-161-36/+0
| | | | | | type. llvm-svn: 224388
* Try typo correction on all initialization arguments and be lessKaelyn Takata2014-12-161-7/+5
| | | | | | | | | pessimistic about when to do so. This also fixes PR21905 as the initialization argument was no longer viewed as being type dependent due to the TypoExpr being type-cast. llvm-svn: 224386
* Look at whether TransformTypos returned a different Expr instead of looking ↵Nick Lewycky2014-12-161-1/+2
| | | | | | | | at the number of uncorrected typos before and after. Correcting one typo may produce an expression with another TypoExpr in it, leading to matching counts even though a typo was corrected. Fixes PR21925! llvm-svn: 224380
* Fix typo in comment. NFC.Nick Lewycky2014-12-161-1/+1
| | | | llvm-svn: 224377
OpenPOWER on IntegriCloud