summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
* Consolidating the notion of a GNU attribute parameter with the attribute ↵Aaron Ballman2013-08-314-232/+213
| | | | | | argument list. llvm-svn: 189711
* Consumed analysis: add 'consumable' class attribute.DeLesley Hutchins2013-08-301-15/+60
| | | | | | | | | | | | Patch by chris.wailes@gmail.com Adds the 'consumable' attribute that can be attached to classes. This replaces the previous method of scanning a class's methods to see if any of them have consumed analysis attributes attached to them. If consumed analysis attributes are attached to methods of a class that isn't marked 'consumable' a warning is generated. llvm-svn: 189702
* Sema: avoid reuse of Exprs when synthesizing operator=Pavel Labath2013-08-301-94/+197
| | | | | | | | | | | | | | | | | | Summary: Previously, Sema was reusing parts of the AST when synthesizing an assignment operator, turning it into a AS-dag. This caused problems for the static analyzer, which assumed an expression appears in the tree only once. Here I make sure to always create a fresh Expr, when inserting something into the AST, fixing PR16745 in the process. Reviewers: doug.gregor CC: cfe-commits, jordan_rose Differential Revision: http://llvm-reviews.chandlerc.com/D1425 llvm-svn: 189659
* Add ms_abi and sysv_abi attribute handling.Charles Davis2013-08-302-1/+31
| | | | | | Based on a patch by Benno Rice! llvm-svn: 189644
* Adjust clang for change to APFloat::toString.Eli Friedman2013-08-291-1/+9
| | | | | | | | I changed the diagnostic printing code because it's probably better to cut off a digit from DBL_MAX than to print something like 1.300000001 when the user wrote 1.3. llvm-svn: 189625
* Removed useless default branch of switch statement.Serge Pavlov2013-08-291-3/+0
| | | | | | The problem was caught by sanitizer build. llvm-svn: 189575
* Change return type of Sema::DiagnoseAmbiguousLookup from bool to void.Serge Pavlov2013-08-291-13/+8
| | | | | | The function always returned true value, which was never used. llvm-svn: 189571
* Remove Inheritable/NonInheritable flags from ProcessDeclAttributes. They don'tRichard Smith2013-08-292-54/+22
| | | | | | do anything useful. llvm-svn: 189548
* Sema: Subst type default template args earlierDavid Majnemer2013-08-282-36/+68
| | | | | | | | | | | | | | | | | Summary: We would not perform substitution at an appropriate point, allowing strange results to appear. We would accepts things that we shouldn't or mangle things incorrectly. Note that this hasn't fixed the other cases like template-template parameters or non-type template parameters. Reviewers: doug.gregor, rjmccall, rsmith Reviewed By: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1507 llvm-svn: 189540
* Mode is now handled as a non-inheritable attribute, and CUDADevice & ↵Aaron Ballman2013-08-281-5/+4
| | | | | | CUDAHost are now handled as inheritable attributes. In all three cases, this makes the processing behavior more consistent with the declared behavior in Attr.td. llvm-svn: 189532
* Improve error for assignment to incomplete class.Eli Friedman2013-08-281-0/+5
| | | | | | PR7681. llvm-svn: 189510
* Delete CC_Default and use the target default CC everywhereReid Kleckner2013-08-275-115/+188
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Makes functions with implicit calling convention compatible with function types with a matching explicit calling convention. This fixes things like calls to qsort(), which has an explicit __cdecl attribute on the comparator in Windows headers. Clang will now infer the calling convention from the declarator. There are two cases when the CC must be adjusted during redeclaration: 1. When defining a non-inline static method. 2. When redeclaring a function with an implicit or mismatched convention. Fixes PR13457, and allows clang to compile CommandLine.cpp for the Microsoft C++ ABI. Excellent test cases provided by Alexander Zinenko! Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D1231 llvm-svn: 189412
* Cleanup of OpaquePtr. No functionality changes.Serge Pavlov2013-08-276-11/+11
| | | | | | | | - Some documenation were added. - Usages of OpaquePtr<A>.getAsVal<A>() were replaced by OpaquePtr<A>.get(). - Methods getAs and getAsVal were renamed to getPtrTo and getPtrAs respectively. llvm-svn: 189346
* Simplify a bit.Rafael Espindola2013-08-261-13/+8
| | | | | | | | | | | | | This follows from computeKeyFunction having: // Template instantiations don't have key functions,see Itanium C++ ABI 5.2.6. // Same behavior as GCC. TemplateSpecializationKind TSK = RD->getTemplateSpecializationKind(); if (TSK == TSK_ImplicitInstantiation || TSK == TSK_ExplicitInstantiationDefinition) return 0; llvm-svn: 189287
* Since r179585, __declspec(property) has gotten special treatment as an ↵Aaron Ballman2013-08-261-1/+0
| | | | | | attribute where it is not processed as part of the typical Sema attribute functionality. Specifying this attribute as being "ignored" because there is no sema handler for it as a Decl attribute, and no AST node generated for it. llvm-svn: 189284
* Handle predefined expression for a captured statementWei Pan2013-08-261-0/+2
| | | | | | | | | | | - __func__ or __FUNCTION__ returns captured statement's parent function name, not the one compiler generated. Differential Revision: http://llvm-reviews.chandlerc.com/D1491 Reviewed by bkramer llvm-svn: 189219
* Add a FIXME.Richard Smith2013-08-231-0/+1
| | | | llvm-svn: 189153
* A clean-up pass, exploring the unification of traversals of class, variable ↵Larisse Voufo2013-08-232-6/+19
| | | | | | and function templates. llvm-svn: 189152
* Use pop_back_val() instead of both back() and pop_back().Robert Wilhelm2013-08-238-26/+15
| | | | | | No functionality change intended. llvm-svn: 189112
* Sema: Properly support Microsoft-mode template argumentsDavid Majnemer2013-08-231-95/+148
| | | | | | | | | | | | | | | | | | | | | | | | Summary: There were two things known to be wrong with our implementation of MSVC mode template arguments: - We didn't properly handle __uuidof/CXXUuidofExpr and skipped all type checking completely. - We didn't allow for MSVC's extension of allowing certain constant "foldable" expressions from showing up in template arguments. They allow various casts dereference and address-of operations. We can make it more general as we find further peculiarities but this is the known extent. Reviewers: rsmith, doug.gregor, rjmccall Reviewed By: doug.gregor CC: cfe-commits, rnk Differential Revision: http://llvm-reviews.chandlerc.com/D1444 llvm-svn: 189087
* Remove SequenceNumber from class/variable template partial specializations.Richard Smith2013-08-222-12/+4
| | | | | | | | This was only used to ensure that the traversal order was the same as the insertion order, but that guarantee was already being provided by the use of a FoldingSetVector. llvm-svn: 189075
* Update to consumed analysis.DeLesley Hutchins2013-08-221-4/+3
| | | | | | | | | | | Patch by chris.wailes@gmail.com. The following functionality was added: * The same functionality is now supported for both CXXOperatorCallExprs and CXXMemberCallExprs. * Factored out some code in StmtVisitor. * Removed variables from the state map when their destructors are encountered. * Started adding documentation for the consumed analysis attributes. llvm-svn: 189059
* Revert "Implement a rudimentary form of generic lambdas."Manuel Klimek2013-08-229-313/+85
| | | | | | This reverts commit 606f5d7a99b11957e057e4cd1f55f931f66a42c7. llvm-svn: 189004
* Revert "Remove some unused variables identified by Juergen Ributzka *I need ↵Manuel Klimek2013-08-221-0/+1
| | | | | | | | to turn on this warning in Visual C++ - sorry!*" This reverts commit d01d0b63d87ac465f15ce1d6b56bf3faf4525769. llvm-svn: 189003
* const'ify Sema::ActOnCXXTryBlock byRobert Wilhelm2013-08-222-10/+6
| | | | | | | | changing Parameter from MutableArrayRef to ArrayRef. No functionality change intended. llvm-svn: 188994
* Remove some unused variables identified by Juergen Ributzka *I need to turn ↵Faisal Vali2013-08-221-1/+0
| | | | | | on this warning in Visual C++ - sorry!* llvm-svn: 188979
* Implement a rudimentary form of generic lambdas.Faisal Vali2013-08-229-85/+313
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, the following features are not included in this commit: - any sort of capturing within generic lambdas - nested lambdas - conversion operator for captureless lambdas - ensuring all visitors are generic lambda aware As an example of what compiles: template <class F1, class F2> struct overload : F1, F2 { using F1::operator(); using F2::operator(); overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } }; auto Recursive = [](auto Self, auto h, auto ... rest) { return 1 + Self(Self, rest...); }; auto Base = [](auto Self, auto h) { return 1; }; overload<decltype(Base), decltype(Recursive)> O(Base, Recursive); int num_params = O(O, 5, 3, "abc", 3.14, 'a'); Please see attached tests for more examples. Some implementation notes: - Add a new Declarator context => LambdaExprParameterContext to clang::Declarator to allow the use of 'auto' in declaring generic lambda parameters - Augment AutoType's constructor (similar to how variadic template-type-parameters ala TemplateTypeParmDecl are implemented) to accept an IsParameterPack to encode a generic lambda parameter pack. - Add various helpers to CXXRecordDecl to facilitate identifying and querying a closure class - LambdaScopeInfo (which maintains the current lambda's Sema state) was augmented to house the current depth of the template being parsed (id est the Parser calls Sema::RecordParsingTemplateParameterDepth) so that Sema::ActOnLambdaAutoParameter may use it to create the appropriate list of corresponding TemplateTypeParmDecl for each auto parameter identified within the generic lambda (also stored within the current LambdaScopeInfo). Additionally, a TemplateParameterList data-member was added to hold the invented TemplateParameterList AST node which will be much more useful once we teach TreeTransform how to transform generic lambdas. - SemaLambda.h was added to hold some common lambda utility functions (this file is likely to grow ...) - Teach Sema::ActOnStartOfFunctionDef to check whether it is being called to instantiate a generic lambda's call operator, and if so, push an appropriately prepared LambdaScopeInfo object on the stack. - Teach Sema::ActOnStartOfLambdaDefinition to set the return type of a lambda without a trailing return type to 'auto' in C++1y mode, and teach the return type deduction machinery in SemaStmt.cpp to process either C++11 and C++14 lambda's correctly depending on the flag. - various tests were added - but much more will be needed. A greatful thanks to all reviewers including Eli Friedman, James Dennett and the ever illuminating Richard Smith. And yet I am certain that I have allowed unidentified bugs to creep in; bugs, that I will do my best to slay, once identified! Thanks! llvm-svn: 188977
* Refactor for clarity and simplicity.Larisse Voufo2013-08-223-69/+59
| | | | llvm-svn: 188974
* Improve support for static data member templates. This revision still has at ↵Larisse Voufo2013-08-223-28/+21
| | | | | | least one bug, as it does not respect the variable template specialization hierarchy well. llvm-svn: 188969
* Split isFromMainFile into two functions.Eli Friedman2013-08-224-5/+5
| | | | | | | | | Basically, isInMainFile considers line markers, and isWrittenInMainFile doesn't. Distinguishing between the two is useful when dealing with files which are preprocessed files or rewritten with -frewrite-includes (so we don't, for example, print useless warnings). llvm-svn: 188968
* Updated the consumed analysis warnings to use a more standardized diagnostic.Aaron Ballman2013-08-211-8/+8
| | | | | | Patch thanks to Christian Wailes! llvm-svn: 188940
* Removed unnecessary asserts.Aaron Ballman2013-08-211-38/+0
| | | | | | Patch thanks to Christian Wailes! llvm-svn: 188934
* Fix the end sourcelocation of the call expression in a member access whenNick Lewycky2013-08-211-4/+3
| | | | | | recovering by adding empty parenthesis. Fixes PR16676! llvm-svn: 188920
* Sema: Use the right type for PredefinedExpr when it's in a lambda.Benjamin Kramer2013-08-211-8/+8
| | | | | | | | | | | | | 1. We now print the return type of lambdas and return type deduced functions as "auto". Trailing return types with decltype print the underlying type. 2. Use the lambda or block scope for the PredefinedExpr type instead of the parent function. This fixes PR16946, a strange mismatch between type of the expression and the actual result. 3. Verify the type in CodeGen. 4. The type for blocks is still wrong. They are numbered and the name is not known until CodeGen. llvm-svn: 188900
* If we find an error in the range expression in a range-based for loop, and theRichard Smith2013-08-211-7/+34
| | | | | | | loop variable has a type containing 'auto', set the declaration to be invalid (because we couldn't deduce its type) to prevent follow-on errors. llvm-svn: 188853
* During typo correction, check for an exact match in an unimported module. If weRichard Smith2013-08-201-8/+116
| | | | | | find one, then report the error as a missing import instead of as a typo. llvm-svn: 188821
* Handle init lists and _Atomic fields.Eli Friedman2013-08-191-1/+5
| | | | | | Fixes PR16931. llvm-svn: 188718
* PR16727: don't try to evaluate a potentially value-dependent expression whenRichard Smith2013-08-191-2/+4
| | | | | | checking for missing parens in &&/|| expressions. llvm-svn: 188716
* const'ify Sema::ActOnCompoundStmt byRobert Wilhelm2013-08-192-19/+12
| | | | | | | | changing Parameter of Sema::ActOnCompoundStmt from MutableArrayRef to ArrayRef. No functionality change intended. llvm-svn: 188705
* Omit llvm:: before makeArrayRef. We have using directive in this file.Robert Wilhelm2013-08-191-10/+5
| | | | llvm-svn: 188659
* Sema: Remove dead code in CheckTemplateArgumentAddressOfObjectOrFunctionDavid Majnemer2013-08-191-8/+0
| | | | | | | | | | | | | | | | Summary: DeclRefExpr::getDecl gives us back a ValueDecl, this isa<> check will never fire. Reviewers: eli.friedman, doug.gregor, majnemer Reviewed By: majnemer CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1434 llvm-svn: 188647
* Fix a use-after-free found in libclang when doing code completion. TheChandler Carruth2013-08-181-3/+9
| | | | | | | | | | | | loop processing the candidates can cause new declerations to be added to the context, invalidating lookup_result. To avoid that, make a copy of the list of declarations to iterate over. I don't have a way to check in a test case for this as it involves a giant pile of source code and a generated PCH file used to accelerate code completion, all of this running under ASan. llvm-svn: 188623
* Refactor all diagnosing of TypoCorrections through a common function, inRichard Smith2013-08-1712-397/+272
| | | | | | | preparation for teaching this function how to diagnose a correction that includes importing a module. llvm-svn: 188602
* Don't reject attribute used in an "extern const" variable definition.Rafael Espindola2013-08-162-1/+8
| | | | | | | Before this patch we would warn and drop the attribute in extern const char test3[] __attribute__((used)) = ""; llvm-svn: 188588
* Parse: Do not 'HandleTopLevelDecl' on templated functions.David Majnemer2013-08-161-1/+1
| | | | | | | | | | | | | | | | Summary: HandleTopLevelDecl on a templated function leads us to try and mangle it. Reviewers: rsmith Reviewed By: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1412 llvm-svn: 188536
* Don't allow unary negation on scoped enums.Eli Friedman2013-08-161-3/+0
| | | | | | PR16900. llvm-svn: 188511
* Properly track l-paren of a CXXFucntionalCastExpr.Eli Friedman2013-08-153-5/+6
| | | | | | | | | | In addition to storing more useful information in the AST, this fixes a semantic check in template instantiation which checks whether the l-paren location is valid. Fixes PR16903. llvm-svn: 188495
* ObjectiveC [Sema]. This patch makes sure that all inheritedFariborz Jahanian2013-08-141-0/+10
| | | | | | | | | | properties (direct or indirect) setter/getter (or declared methods as well) are seen by the method implementation type matching logic before declaration of method in super class is seen. This fixes the warning coming out of that method mismatch. // rdar://14650159 llvm-svn: 188438
* PR16875: The return type of a dependent function type is visible when it'sRichard Smith2013-08-144-15/+47
| | | | | | | | | | | referenced as a member of the current instantiation. In that case, deduce the type of the function to a dependent type rather than exposing an undeduced auto type to the rest of the current instantiation. The standard doesn't really say that the type is dependent in this case; I'll bring this up with CWG. llvm-svn: 188410
* Bug fix: note diagnosis on expression narrowing should say "variable ↵Larisse Voufo2013-08-141-1/+3
| | | | | | template" instead of "static data member" when appropriate llvm-svn: 188409
OpenPOWER on IntegriCloud