summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* PR24440: Do not silently discard a fold-expression appearing as the operand ↵Richard Smith2017-02-151-0/+7
| | | | | | of a cast-expression. llvm-svn: 295224
* Fix spelling mistake - paramater -> parameter. NFCI.Simon Pilgrim2017-02-151-2/+2
| | | | llvm-svn: 295183
* Removed stale comment. NFC.Serge Pavlov2017-02-151-2/+0
| | | | | | | The case of extern inline functions in GNU89 mode is now handled in `canRedefineFunction`, which has appropriate comment. llvm-svn: 295167
* [Sema] Disallow returning a __block variable via a move.Akira Hatanaka2017-02-151-3/+5
| | | | | | | | | | | | | | | r274291 made changes to prefer calling a move constructor to calling a copy constructor when returning from a function. This caused programs to crash when a __block variable in the heap was moved out and used later. This commit fixes the bug by disallowing moving out of __block variables implicitly. rdar://problem/28181080 Differential Revision: https://reviews.llvm.org/D29908 llvm-svn: 295150
* Fix assertion failure due to implicit special member lookup lacking a source ↵Richard Smith2017-02-151-4/+7
| | | | | | location. llvm-svn: 295149
* [VLA] Handle VLA size expression in a full-expression context.Tim Shen2017-02-142-2/+11
| | | | | | | | | | | | | | | | Summary: Previously the cleanups (e.g. dtor calls) are inserted into the outer scope (e.g. function body scope), instead of it's own scope. After the fix, the cleanups are inserted right after getting the size value. This fixes pr30306. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24333 llvm-svn: 295123
* Canonicalize implicit deduction guide parameter types when forming a deductionRichard Smith2017-02-141-9/+19
| | | | | | | | | | | | guide from a constructor. The purpose of this change is to avoid triggering instantiation of the class when substituting back into the deduction guide if it uses a typedef member. We will still instantiate the class if the constructor (explicitly or implicitly, directly or indirectly) uses the current instantiation in a way that we can't canonicalize out, but that seems unavoidable. llvm-svn: 295016
* [c++1z] Synthesize implicit deduction guides from constructors on demand. RankRichard Smith2017-02-146-69/+462
| | | | | | | | | | | | | | | | | | | such guides below explicit ones, and ensure that references to the class's template parameters are not treated as forwarding references. We make a few tweaks to the wording in the current standard: 1) The constructor parameter list is copied faithfully to the deduction guide, without losing default arguments or a varargs ellipsis (which the standard wording loses by omission). 2) If the class template declares no constructors, we add a T() -> T<...> guide (which will only ever work if T has default arguments for all non-pack template parameters). 3) If the class template declares nothing that looks like a copy or move constructor, we add a T(T<...>) -> T<...> guide. #2 and #3 follow from the "pretend we had a class type with these constructors" philosophy for deduction guides. llvm-svn: 295007
* [CodeCompletion] Code complete the '__auto_type' keywordAlex Lorenz2017-02-131-2/+3
| | | | | | rdar://29219185 llvm-svn: 295003
* [CodeCompletion] Code complete the missing C++11 keywordsAlex Lorenz2017-02-131-11/+74
| | | | | | | | | | | | | | | | | | | | | | | | This commit adds context sensitive code completion support for the C++11 keywords that currently don't have completion results. The following keywords are supported by this patch: alignas constexpr static_assert noexcept (as a function/method qualifier) thread_local The following special identifiers are also supported: final (as a method qualifier or class qualifier) override rdar://29219185 Differential Revision: https://reviews.llvm.org/D28286 llvm-svn: 295001
* [coroutines] NFC: Refactor Sema::CoroutineBodyStmt construction.Gor Nishanov2017-02-131-78/+159
| | | | | | | | | | | | | | | | | | | Summary: Sema::CheckCompletedCoroutineBody was growing unwieldy with building all of the substatements. Also, constructors for CoroutineBodyStmt had way too many parameters. Instead, CoroutineBodyStmt now defines CtorArgs structure with all of the required construction parameters. CheckCompleteCoroutineBody delegates construction of individual substatements to short functions one per each substatement. Also, added a drive-by fix of initializing CoroutinePromise to nullptr in ScopeInfo.h. And addressed the FIXME that wanted to tail allocate extra room at the end of the CoroutineBodyStmt to hold parameter move expressions. (The comment was longer that the code that implemented tail allocation). Reviewers: rsmith, EricWF Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D28835 llvm-svn: 294933
* Revert r294910 and recommit r294861 and r294862 with a target triple to ↵Aaron Ballman2017-02-121-4/+5
| | | | | | hopefully appease the bots. llvm-svn: 294911
* Revert "Attributes on K&R C functions should not cause incompatible..."Renato Golin2017-02-121-5/+4
| | | | | | | | | | | | | | | | ...function type with a redeclaration having the same attribute. Fixing this introduced a secondary problem where we were assuming that K&R functions could not be attributed types when reporting old-style function definitions that are not preceded by a prototype." Also Revert "Hopefully fixes a compile error introduced by r294861." This reverts commit r294862, r294861, as they bork the ARM builds and haven't fix it back. Also, please, short commit titles, long commit decsriptions... llvm-svn: 294910
* Attributes on K&R C functions should not cause incompatible function type ↵Aaron Ballman2017-02-111-4/+5
| | | | | | | | with a redeclaration having the same attribute. Fixing this introduced a secondary problem where we were assuming that K&R functions could not be attributed types when reporting old-style function definitions that are not preceded by a prototype. This patch fixes PR31020. llvm-svn: 294861
* Sema: simplify conditional execution (NFC)Saleem Abdulrasool2017-02-111-4/+1
| | | | | | | The conditional cast is unnecessary since we know that it will always succeed. NFC. llvm-svn: 294853
* Make helpers static. NFC.Benjamin Kramer2017-02-111-2/+2
| | | | llvm-svn: 294838
* [c++1z] Diagnose attempts to use variables with deduced class templateRichard Smith2017-02-104-9/+7
| | | | | | specialization types from within their own initializers. llvm-svn: 294796
* [c++1z] Require an initializer for deduced class template specialization types.Richard Smith2017-02-101-9/+9
| | | | | | | | It's actually meaningful and useful to allow such variables to have no initializer, but we are strictly following the standard here until the C++ committee reaches consensus on allowing this. llvm-svn: 294785
* [c++1z] Enforce restriction that deduction guide is declared in the same ↵Richard Smith2017-02-102-1/+45
| | | | | | scope as its template. llvm-svn: 294778
* [c++1z] Disallow deduction guides with deduced types that don't ↵Richard Smith2017-02-101-3/+37
| | | | | | syntactically match the template being deduced. llvm-svn: 294773
* [c++1z] In class template argument deduction, all declarators must deduce ↵Richard Smith2017-02-101-6/+7
| | | | | | the same type (just like with auto deduction). llvm-svn: 294700
* [Concepts] Class template associated constraintsHubert Tong2017-02-101-1/+52
| | | | | | | | | | | | | | | | Summary: This adds associated constraints as a property of class templates. An error is produced if redeclarations are not similarly constrained. Reviewers: rsmith, faisalv, aaron.ballman Reviewed By: rsmith Subscribers: cfe-commits, nwilson Differential Revision: https://reviews.llvm.org/D25674 llvm-svn: 294697
* [c++1z] P0512R0: support for 'explicit' specifier on deduction-guides.Richard Smith2017-02-104-10/+26
| | | | llvm-svn: 294693
* Disallow explicit instantiation and explicit specialization for deduction ↵Richard Smith2017-02-092-1/+17
| | | | | | guides. llvm-svn: 294641
* Rename IsExplicitSpecialization -> IsMemberSpecialization when we're talkingRichard Smith2017-02-093-48/+46
| | | | | | about member specializations to avoid ambiguous and confusing terminology. llvm-svn: 294622
* [c++1z] P0091R3: Basic support for deducing class template arguments via ↵Richard Smith2017-02-096-125/+382
| | | | | | deduction-guides. llvm-svn: 294613
* More fixes for places where 'decltype(auto)' is permitted in the C++ grammar ↵Richard Smith2017-02-082-10/+24
| | | | | | but makes no sense. llvm-svn: 294509
* [AVR] Add support for the 'interrupt' and 'naked' attributesDylan McKay2017-02-081-0/+32
| | | | | | | | | | | | | | | | Summary: This teaches clang how to parse and lower the 'interrupt' and 'naked' attributes. This allows interrupt signal handlers to be written. Reviewers: aaron.ballman Subscribers: malcolm.parsons, cfe-commits Differential Revision: https://reviews.llvm.org/D28451 llvm-svn: 294402
* Sema: add warning for c++ member variable shadowingSaleem Abdulrasool2017-02-081-0/+55
| | | | | | | | | | Add a warning for shadowed variables across records. Referencing a shadow'ed variable may not give the desired variable. Add an optional warning for the shadowing. Patch by James Sun! llvm-svn: 294401
* Diagnose an attempt to give a deduction-guide a function body.Richard Smith2017-02-081-0/+3
| | | | llvm-svn: 294397
* P0091R3: Improved syntactic checking of deduction-guides.Richard Smith2017-02-083-29/+125
| | | | llvm-svn: 294395
* [OpenCL] Accept logical NOT for pointer types in CL1.1Anastasia Stulova2017-02-071-1/+1
| | | | | | | | | Fix for bug 30217 - incorrect error given for logical NOT operation with a pointer type: corrected sema check and improved related tests. Review: D29038 llvm-svn: 294313
* P0091R3: Implement basic parsing support for C++17 deduction-guides.Richard Smith2017-02-076-21/+95
| | | | | | | | | | | We model deduction-guides as functions with a new kind of name that identifies the template whose deduction they guide; the bulk of this patch is adding the new name kind. This gives us a clean way to attach an extensible list of guides to a class template in a way that doesn't require any special handling in AST files etc (and we're going to need these functions we come to performing deduction). llvm-svn: 294266
* PR31846: Don't replace 'auto' type with a template parameter type in a ↵Richard Smith2017-02-042-34/+34
| | | | | | | | generic lambda until after we've checked whether 'auto' is valid in the current language mode. llvm-svn: 294078
* [Sema][ObjC++] Typo correction should handle ivars and propertiesAlex Lorenz2017-02-032-16/+9
| | | | | | | | | | | | | | | | After r260016 and r260017 disabled typo correction for ivars and properties clang didn't report errors about unresolved identifier in the base of ivar and property ref expressions. This meant that clang invoked CodeGen on invalid AST which then caused a crash. This commit re-enables typo correction for ivars and properites, and fixes the PR25113 & PR26486 (that were originally fixed in r260017 and r260016) in a different manner by transforming the Objective-C ivar reference expression with 'IsFreeIvar' preserved. rdar://30310772 llvm-svn: 294008
* Repoint 'missing typename' diagnostic to the location where 'typename' ↵Richard Smith2017-02-011-1/+1
| | | | | | should be added. llvm-svn: 293817
* Fix hole in our enforcement of rule requiring 'typename' prior to a dependentRichard Smith2017-02-011-15/+36
| | | | | | | | | | | name. If the dependent name happened to end in a template-id (X<T>::Y<U>), we would fail to notice that the 'typename' keyword is missing when resolving it to a type. It turns out that GCC has a similar bug. If this shows up in much real code, we can easily downgrade this to an ExtWarn. llvm-svn: 293815
* [Sema][ObjC] Don't pass a DeclRefExpr that doesn't reference a VarDeclAkira Hatanaka2017-02-011-5/+5
| | | | | | | | | | to WeakObjectProfileTy's constructor. This fixes an assertion failure in WeakObjectProfileTy's constructor. rdar://problem/30112633 llvm-svn: 293808
* Drop 'dllimport' when redeclaring inline function template without the ↵Hans Wennborg2017-02-011-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | attribute (PR31695) For non-template dllimport functions, MSVC allows providing an inline definition without spelling out the attribute again. In the example below, f remains a dllimport function. __declspec(dllimport) int f(); inline int f() { return 42; } int useit() { return f(); } However, for a function template, not putting dllimport on the redeclaration causes it to be dropped. In the example below, f is not dllimport. template <typename> __declspec(dllimport) int f(); template <typename> inline int f() { return 42; } int useit() { return f<int>(); } This patch makes Clang match MSVC for the second example. MSVC does not warn about the attribute being dropped in the example above, but I think we should. (MSVC does warn if the inline keyword isn't used.) Differential Revision: https://reviews.llvm.org/D29152 llvm-svn: 293800
* Remove apparently-unnecessary copy of constructor lookup result.Richard Smith2017-02-011-9/+1
| | | | | | | | | | | Contrary to the comment, DeclContext intends to guarantee that the lookup results for a particular name will be stable across non-AST-mutating operations, so a copy here should not be necessary. Further, if a copy *is* necessary, the other four instances of this pattern within this file would also be wrong, and we have no evidence of any problems with them; if this change unearths problems, we should fix all the instances of this pattern. llvm-svn: 293740
* [Sema] Transform a templated name before looking it up inAkira Hatanaka2017-01-312-3/+13
| | | | | | | | | | | | FindInstantiatedDecl or passing it to RebuildMemberExpr. This fixes PR30361. rdar://problem/17341274 Differential Revision: https://reviews.llvm.org/D24969 llvm-svn: 293678
* Extend -Wcast-calling-convention to warn on declarations as well as definitionsReid Kleckner2017-01-311-4/+3
| | | | | | | | | My original warning was very conservative and I never revisited the heuristics that were used. This would have caught http://crbug.com/687251 at compile time. llvm-svn: 293677
* Revert r293585 "Add better ODR checking for modules."Sam McCall2017-01-311-4/+1
| | | | | | | | | | | We're seeing what we believe are false positives. (It's hard to tell with the available diagnostics, and I'm not sure how to reduce them yet). I'll send Richard reproduction details offline. djasper/chandlerc suggested this should be a warning for now, to make rolling it out feasible. llvm-svn: 293611
* Add better ODR checking for modules.Richard Trieu2017-01-311-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When objects are imported for modules, there is a chance that a name collision will cause an ODR violation. Previously, only a small number of such violations were detected. This patch provides a stronger check based on AST nodes. The information needed to uniquely identify an object is taked from the AST and put into a one-dimensional byte stream. This stream is then hashed to give a value to represent the object, which is stored with the other object data in the module. When modules are loaded, and Decl's are merged, the hash values of the two Decl's are compared. Only Decl's with matched hash values will be merged. Mismatch hashes will generate a module error, and if possible, point to the first difference between the two objects. The transform from AST to byte stream is a modified depth first algorithm. Due to references between some AST nodes, a pure depth first algorithm could generate loops. For Stmt nodes, a straight depth first processing occurs. For Type and Decl nodes, they are replaced with an index number and only on first visit will these nodes be processed. As an optimization, boolean values are saved and stored together in reverse order at the end of the byte stream to lower the ammount of data that needs to be hashed. Compile time impact was measured at 1.5-2.0% during module building, and negligible during builds without module building. Differential Revision: https://reviews.llvm.org/D21675 llvm-svn: 293585
* Towards P0091R3: parsing support for class template argument deduction in ↵Richard Smith2017-01-305-69/+184
| | | | | | | | | typename-specifiers. This reinstates r293455, reverted in r293455, with a fix for cv-qualifier handling on dependent typename-specifiers. llvm-svn: 293544
* Revert r293455, which breaks v8 with a spurious error. Testcase added.Sam McCall2017-01-305-129/+31
| | | | | | | | | | | | Summary: Revert r293455, which breaks v8 with a spurious error. Testcase added. Reviewers: klimek Subscribers: cfe-commits, rsmith Differential Revision: https://reviews.llvm.org/D29271 llvm-svn: 293473
* Prototype of modules codegenDavid Blaikie2017-01-301-0/+9
| | | | | | | | | | | | | | | | | | | | | First pass at generating weak definitions of inline functions from module files (& skipping (-O0) or emitting available_externally (optimizations) definitions where those modules are used). External functions defined in modules are emitted into the modular object file as well (this may turn an existing ODR violation (if that module were imported into multiple translations) into valid/linkable code). Internal symbols (static functions, for example) are not correctly supported yet. The symbol will be produced, internal, in the modular object - unreferenceable from the users. Reviewers: rsmith Differential Revision: https://reviews.llvm.org/D28845 llvm-svn: 293456
* Towards P0091R3: parsing support for class template argument deduction in ↵Richard Smith2017-01-305-31/+129
| | | | | | typename-specifiers. llvm-svn: 293455
* Switch the template specialization kind for a non-defining declaration of aRichard Smith2017-01-281-15/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | non-template function instantiated from a friend declaration in a class template from TSK_ImplicitInstantiation to TSK_Undeclared. It doesn't make sense for a non-template function to be flagged as being instantiated from a template; that property really belongs to the entity as a whole and not an individual declaration of it. There's some history here: * r137934 started marking these functions as instantiations in order to work around an issue where we might instantiate a class template while we're still parsing its member definitions, and would otherwise fail to instantiate the friend definition * r177003 fixed the same issue but for friend templates, but did so by making the friends claim to be definitions even before we'd parsed their actual bodies; this made the r137934 change redundant * r293558 worked around a problem caused by the marking of a non-template function as a template instantiation in r137934 This change reverts the code changes from r293358 and r137934 and retains all the tests. llvm-svn: 293367
* Change how we handle diagnose_if attributes.George Burgess IV2017-01-285-219/+127
| | | | | | | | | | | | | This patch changes how we handle argument-dependent `diagnose_if` attributes. In particular, we now check them in the same place that we check for things like passing NULL to Nonnull args, etc. This is basically better in every way than how we were handling them before. :) This fixes PR31638, PR31639, and PR31640. Differential Revision: https://reviews.llvm.org/D28889 llvm-svn: 293360
OpenPOWER on IntegriCloud