summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateInstantiateDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Adds `-ftime-trace` option to clang that produces Chrome `chrome://tracing` ↵Anton Afanasyev2019-03-301-0/+5
| | | | | | | | | | | | | | compatible JSON profiling output dumps. This change adds hierarchical "time trace" profiling blocks that can be visualized in Chrome, in a "flame chart" style. Each profiling block can have a "detail" string that for example indicates the file being processed, template name being instantiated, function being optimized etc. This is taken from GitHub PR: https://github.com/aras-p/llvm-project-20170507/pull/2 Patch by Aras Pranckevičius. Differential Revision: https://reviews.llvm.org/D58675 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@357340 91177308-0d34-0410-b5e6-96231b3b80d8
* Recommit "Support attribute used in member funcs of class templates"Rafael Auler2019-03-201-0/+14
| | | | | | | | | | | | | | | | | | | | This diff previously exposed a bug in LLVM's IRLinker, breaking buildbots that tried to self-host LLVM with monolithic LTO. The bug is now in LLVM by D59552 Original commit message: As PR17480 describes, clang does not support the used attribute for member functions of class templates. This means that if the member function is not used, its definition is never instantiated. This patch changes clang to emit the definition if it has the used attribute. Test Plan: Added a testcase Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D56928 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356598 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove an assert in template pack deduction during nested instantiation.Richard Trieu2019-03-151-18/+18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356231 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP 5.0]Initial support for 'allocator' clause.Alexey Bataev2019-03-121-2/+13
| | | | | | | Added parsing/sema analysis/serialization/deserialization for the 'allocator' clause of the 'allocate' directive. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355952 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Recommit "Support attribute used in member funcs of class templates""Rafael Auler2019-03-081-14/+0
| | | | | | | | | There is nontrivial bug caused in lld that I need to further investigate. Meanwhile, I'll revert this. This reverts commit 8297e93480c636dc90fd14653c5a66406193363f. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355721 91177308-0d34-0410-b5e6-96231b3b80d8
* Recommit "Support attribute used in member funcs of class templates"Rafael Auler2019-03-071-0/+14
| | | | | | | | | | | | | | | | | | | | The patch originally broke code that was incompatible with GCC, but we want to follow GCC behavior here according to the discussion in https://reviews.llvm.org/D58216 Original commit message: As PR17480 describes, clang does not support the used attribute for member functions of class templates. This means that if the member function is not used, its definition is never instantiated. This patch changes clang to emit the definition if it has the used attribute. Test Plan: Added a testcase Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D56928 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355627 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP 5.0]Add initial support for 'allocate' directive.Alexey Bataev2019-03-071-0/+15
| | | | | | | Added parsing/sema analysis/serialization/deserialization support for 'allocate' directive. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355614 91177308-0d34-0410-b5e6-96231b3b80d8
* [AMDGPU] Allow using integral non-type template parametersMichael Liao2019-02-261-0/+57
| | | | | | | | | | | | | | | | | | | Summary: - Allow using integral non-type template parameters in the following attributes __attribute__((amdgpu_flat_work_group_size(<min>, <max>))) __attribute__((amdgpu_waves_per_eu(<min>[, <max>]))) Reviewers: kzhuravl, yaxunl Subscribers: jvesely, wdng, nhaehnle, dstuttard, tpr, t-tye, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58623 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354909 91177308-0d34-0410-b5e6-96231b3b80d8
* [OpenMP 5.0] Parsing/sema support for map clause with mapper modifier.Michael Kruse2019-02-191-4/+12
| | | | | | | | | | | | | | | | | | | This patch implements the parsing and sema support for OpenMP map clauses with potential user-defined mapper attached. User defined mapper is a new feature in OpenMP 5.0. A map clause can have an explicit or implicit associated mapper, which instructs the compiler to generate extra data mapping. An example is shown below: struct S { int len; int *d; }; #pragma omp declare mapper(id: struct S s) map(s, s.d[0:s.len]) struct S ss; #pragma omp target map(mapper(id) tofrom: ss) // use the mapper with name 'id' to map ss Contributed-by: Lingda Li <lildmh@gmail.com> Differential Revision: https://reviews.llvm.org/D58074 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354347 91177308-0d34-0410-b5e6-96231b3b80d8
* [OpenMP 5.0] Parsing/sema support for "omp declare mapper" directive.Michael Kruse2019-02-011-1/+83
| | | | | | | | | | | | | | | | | This patch implements parsing and sema for "omp declare mapper" directive. User defined mapper, i.e., declare mapper directive, is a new feature in OpenMP 5.0. It is introduced to extend existing map clauses for the purpose of simplifying the copy of complex data structures between host and device (i.e., deep copy). An example is shown below: struct S { int len; int *d; }; #pragma omp declare mapper(struct S s) map(s, s.d[0:s.len]) // Memory region that d points to is also mapped using this mapper. Contributed-by: Lingda Li <lildmh@gmail.com> Differential Revision: https://reviews.llvm.org/D56326 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352906 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Support attribute used in member funcs of class templates"Rafael Auler2019-01-311-14/+0
| | | | | | This reverts commit 352740: broke swift build git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352748 91177308-0d34-0410-b5e6-96231b3b80d8
* Support attribute used in member funcs of class templatesRafael Auler2019-01-311-0/+14
| | | | | | | | | | | | | | | | Summary: As PR17480 describes, clang does not support the used attribute for member functions of class templates. This means that if the member function is not used, its definition is never instantiated. This patch changes clang to emit the definition if it has the used attribute. Test Plan: Added a testcase Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D56928 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352740 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename getTypeQualifiers to getMethodQualifiers.Anastasia Stulova2019-01-281-1/+1
| | | | | | | | | | Use more descriptive name for the method qualifiers getter. Differential Revision: https://reviews.llvm.org/D56792 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352349 91177308-0d34-0410-b5e6-96231b3b80d8
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
* Remember to instantiate explicit template argument lists in a friendRichard Smith2019-01-111-11/+73
| | | | | | | | | | | | | | | function declaration. We'd previously often just drop these on the floor, and friend redeclaration matching would usually (but not always) figure out the right redeclaration anyway. Also, don't try to match a dependent friend function template specialization to a template until instantiation, and don't forget to reject qualified friend declarations in dependent contexts that don't name an already-declared entity. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@350915 91177308-0d34-0410-b5e6-96231b3b80d8
* [OpenCL] Add generic AS to 'this' pointerMikael Nilsson2018-12-131-5/+5
| | | | | | | | | | | | | | Address spaces are cast into generic before invoking the constructor. Added support for a trailing Qualifiers object in FunctionProtoType. Note: This recommits the previously reverted patch, but now it is commited together with a fix for lldb. Differential Revision: https://reviews.llvm.org/D54862 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349019 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[OpenCL] Add generic AS to 'this' pointer"Mikael Nilsson2018-12-121-5/+5
| | | | | | | | Reverting because the patch broke lldb. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348931 91177308-0d34-0410-b5e6-96231b3b80d8
* [OpenCL] Add generic AS to 'this' pointerMikael Nilsson2018-12-121-5/+5
| | | | | | | | | | | Address spaces are cast into generic before invoking the constructor. Added support for a trailing Qualifiers object in FunctionProtoType. Differential Revision: https://reviews.llvm.org/D54862 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348927 91177308-0d34-0410-b5e6-96231b3b80d8
* Diagnose friend function template redefinitions.Serge Pavlov2018-12-061-1/+3
| | | | | | | | | | | | | | | Friend function template defined in a class template becomes available if the enclosing class template is instantiated. Until the function template is used, it does not have a body, but still is considered a definition for the purpose of redeclaration checks. This change modifies redefinition check so that it can find the friend function template definitions in instantiated classes. Differential Revision: http://reviews.llvm.org/D21508 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348473 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix crash if an in-class explicit function specialization has explicitRichard Smith2018-12-041-10/+12
| | | | | | template arguments referring to template paramaeters. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348313 91177308-0d34-0410-b5e6-96231b3b80d8
* [attributes] Add a family of OS_CONSUMED, OS_RETURNS and OS_RETURNS_RETAINED ↵George Karpenkov2018-11-301-5/+20
| | | | | | | | | | | | | | | | | | | | | attributes The addition adds three attributes for communicating ownership, analogous to existing NS_ and CF_ attributes. The attributes are meant to be used for communicating ownership of all objects in XNU (Darwin kernel) and all of the kernel modules. The ownership model there is very similar, but still different from the Foundation model, so we think that introducing a new family of attributes is appropriate. The addition required a sizeable refactoring of the existing code for CF_ and NS_ ownership attributes, due to tight coupling and the fact that differentiating between the types was previously done using a boolean. Differential Revision: https://reviews.llvm.org/D54912 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347947 91177308-0d34-0410-b5e6-96231b3b80d8
* Follow-up to r345699: Call CheckStaticLocalForDllExport later for templatesHans Wennborg2018-10-311-3/+3
| | | | | | | | Calling it too early might cause dllimport to get inherited onto the VarDecl before the initializer got attached. See the test case for an example where this broke things. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345709 91177308-0d34-0410-b5e6-96231b3b80d8
* [clang-cl] Inherit dllexport to static locals also in template ↵Hans Wennborg2018-10-311-0/+3
| | | | | | | | | | | | | | | | instantiations (PR39496) In the course of D51340, @takuto.ikuta discovered that Clang fails to put dllexport/import attributes on static locals during template instantiation. For regular functions, this happens in Sema::FinalizeDeclaration(), however for template instantiations we need to do something in or around TemplateDeclInstantiator::VisitVarDecl(). This patch does that, and extracts the code to a utility function. Differential Revision: https://reviews.llvm.org/D53870 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345699 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] Add support for OMP5 requires directive + unified_address clauseKelvin Li2018-09-261-0/+5
| | | | | | | | | | Add support for OMP5.0 requires directive and unified_address clause. Patches to follow will include support for additional clauses. Differential Revision: https://reviews.llvm.org/D52359 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343063 91177308-0d34-0410-b5e6-96231b3b80d8
* [clang] Make sure attributes on member classes are applied properlyLouis Dionne2018-09-141-0/+6
| | | | | | | | | | | | | | | | | | | | | | | Summary: Attributes on member classes of class templates and member class templates of class templates are not currently instantiated. This was discovered by Richard Smith here: http://lists.llvm.org/pipermail/cfe-dev/2018-September/059291.html This commit makes sure that attributes are instantiated properly. This commit does not fix the broken behavior for member partial and explicit specializations of class templates. PR38913 Reviewers: rsmith Subscribers: dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D51997 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342238 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] Fix PR38903: Crash on instantiation of the non-dependentAlexey Bataev2018-09-131-32/+47
| | | | | | | | | | | declare reduction. If the declare reduction construct with the non-dependent type is defined in the template construct, the compiler might crash on the template instantition. Reworked the whole instantiation scheme for the declare reduction constructs to fix this problem correctly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342151 91177308-0d34-0410-b5e6-96231b3b80d8
* Consistently create a new declaration when merging a pre-existing butRichard Smith2018-09-121-1/+1
| | | | | | | | | | | | | | | | hidden definition with a would-be-parsed redefinition. This permits a bunch of cleanups. In particular, we no longer need to take merged definitions into account when checking declaration visibility, only when checking definition visibility, which makes certain visibility checks take linear instead of quadratic time. We could also now remove the UPD_DECL_EXPORTED update record and track on each declaration whether it was demoted from a definition (as we already do for variables), but I'm not doing that in this patch to keep the changes here simpler. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342018 91177308-0d34-0410-b5e6-96231b3b80d8
* PR38627: Fix handling of exception specification adjustment forRichard Smith2018-09-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | destructors. We previously tried to patch up the exception specification after completing the class, which went wrong when the exception specification was needed within the class body (in particular, by a friend redeclaration of the destructor in a nested class). We now mark the destructor as having a not-yet-computed exception specification immediately after creating it. This requires delaying various checks against the exception specification (where we'd previously have just got the wrong exception specification, and now find we have an exception specification that we can't compute yet) when those checks fire while the class is being defined. This also exposed an issue that we were missing a CodeSynthesisContext for computation of exception specifications (otherwise we'd fail to make the module containing the definition of the class visible when computing its members' exception specs). Adding that incidentally also gives us a diagnostic quality improvement. This has also exposed an pre-existing problem: making the exception specification evaluation context a non-SFINAE context (as it should be) results in a bootstrap failure; PR38850 filed for this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341499 91177308-0d34-0410-b5e6-96231b3b80d8
* Enforce instantiation of template multiversion functionsErich Keane2018-08-131-4/+14
| | | | | | | | | | Multiversioned member functions inside of a template type were not properly being emitted. The solution to this is to simply ensure that their bodies are correctly evaluated/assigned during template instantiation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339597 91177308-0d34-0410-b5e6-96231b3b80d8
* Port getLocEnd -> getEndLocStephen Kelly2018-08-091-12/+9
| | | | | | | | | | Reviewers: teemperor! Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50351 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339386 91177308-0d34-0410-b5e6-96231b3b80d8
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-43/+29
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339385 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove trailing spaceFangrui Song2018-07-301-8/+8
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338291 91177308-0d34-0410-b5e6-96231b3b80d8
* AttributeList de-listifying:Erich Keane2018-07-121-3/+3
| | | | | | | | | | | | | Basically, "AttributeList" loses all list-like mechanisms, ParsedAttributes is switched to use a TinyPtrVector (and a ParsedAttributesView is created to have a non-allocating attributes list). DeclaratorChunk gets the later kind, Declarator/DeclSpec keep ParsedAttributes. Iterators are added to the ParsedAttribute types so that for-loops work. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336945 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r335019 "Update NRVO logic to support early return (Attempt 2)"Taiju Tsuiki2018-06-191-3/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335022 91177308-0d34-0410-b5e6-96231b3b80d8
* Update NRVO logic to support early return (Attempt 2)Taiju Tsuiki2018-06-191-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is the second attempt of r333500 (Update NRVO logic to support early return). The previous one was reverted for a miscompilation for an incorrect NRVO set up on templates such as: ``` struct Foo {}; template <typename T> T bar() { T t; if (false) return T(); return t; } ``` Where, `t` is marked as non-NRVO variable before its instantiation. However, while its instantiation, it's left an NRVO candidate, turned into an NRVO variable later. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D47586 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335019 91177308-0d34-0410-b5e6-96231b3b80d8
* [CUDA] Check initializers of instantiated template variables.Artem Belevich2018-06-061-0/+3
| | | | | | | | | We were already performing checks on non-template variables, but the checks on templated ones were missing. Differential Revision: https://reviews.llvm.org/D45231 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334143 91177308-0d34-0410-b5e6-96231b3b80d8
* PR34520: after instantiating a non-templated member deduction guide, don't ↵Richard Smith2018-05-301-1/+4
| | | | | | forget to push it into the class scope. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333589 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-13/+13
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331834 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert rC330794 and some dependent tiny bug fixes Faisal Vali2018-04-261-5/+0
| | | | | | | | | | | | | | | | | | See Richard's humbling feedback here: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226482.html http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226486.html Wish I'd had the patience to solicit the feedback prior to committing :) Sorry for the noise guys. Thank you Richard for being the steward that clang deserves! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330888 91177308-0d34-0410-b5e6-96231b3b80d8
* [c++2a] [concepts] Add rudimentary parsing support for template concept ↵Faisal Vali2018-04-251-0/+5
| | | | | | | | | | | | | | | declarations This patch is a tweak of changyu's patch: https://reviews.llvm.org/D40381. It differs in that the recognition of the 'concept' token is moved into the machinery that recognizes declaration-specifiers - this allows us to leverage the attribute handling machinery more seamlessly. See the test file to get a sense of the basic parsing that this patch supports. There is much more work to be done before concepts are usable... Thanks Changyu! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330794 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[CUDA] Check initializers of instantiated template variables."Artem Belevich2018-04-041-3/+0
| | | | | | | This (temporarily) reverts commit r329127 due to the problems it exposed in TensorFlow. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329229 91177308-0d34-0410-b5e6-96231b3b80d8
* [CUDA] Check initializers of instantiated template variables.Artem Belevich2018-04-031-0/+3
| | | | | | | | | We were already performing checks on non-template variables, but the checks on templated ones were missing. Differential Revision: https://reviews.llvm.org/D45231 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329127 91177308-0d34-0410-b5e6-96231b3b80d8
* [ast] Do not auto-initialize Objective-C for-loop variables in Objective-C++ ↵George Karpenkov2018-03-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in templatized code under ARC The AST for the fragment ``` @interface I @end template <typename> void decode(I *p) { for (I *k in p) {} } void decode(I *p) { decode<int>(p); } ``` differs heavily when templatized and non-templatized: ``` |-FunctionTemplateDecl 0x7fbfe0863940 <line:4:1, line:7:1> line:5:6 decode | |-TemplateTypeParmDecl 0x7fbfe0863690 <line:4:11> col:11 typename depth 0 index 0 | |-FunctionDecl 0x7fbfe08638a0 <line:5:1, line:7:1> line:5:6 decode 'void (I *__strong)' | | |-ParmVarDecl 0x7fbfe08637a0 <col:13, col:16> col:16 referenced p 'I *__strong' | | `-CompoundStmt 0x7fbfe0863b88 <col:19, line:7:1> | |   `-ObjCForCollectionStmt 0x7fbfe0863b50 <line:6:3, col:20> | |     |-DeclStmt 0x7fbfe0863a50 <col:8, col:13> | |     | `-VarDecl 0x7fbfe08639f0 <col:8, col:11> col:11 k 'I *const __strong' | |     |-ImplicitCastExpr 0x7fbfe0863a90 <col:16> 'I *' <LValueToRValue> | |     | `-DeclRefExpr 0x7fbfe0863a68 <col:16> 'I *__strong' lvalue ParmVar 0x7fbfe08637a0 'p' 'I *__strong' | |     `-CompoundStmt 0x7fbfe0863b78 <col:19, col:20> | `-FunctionDecl 0x7fbfe0863f80 <line:5:1, line:7:1> line:5:6 used decode 'void (I *__strong)' |   |-TemplateArgument type 'int' |   |-ParmVarDecl 0x7fbfe0863ef8 <col:13, col:16> col:16 used p 'I *__strong' |   `-CompoundStmt 0x7fbfe0890cf0 <col:19, line:7:1> |     `-ObjCForCollectionStmt 0x7fbfe0890cc8 <line:6:3, col:20> |       |-DeclStmt 0x7fbfe0890c70 <col:8, col:13> |       | `-VarDecl 0x7fbfe0890c00 <col:8, col:11> col:11 k 'I *__strong' callinit |       |   `-ImplicitValueInitExpr 0x7fbfe0890c60 <<invalid sloc>> 'I *__strong' |       |-ImplicitCastExpr 0x7fbfe0890cb0 <col:16> 'I *' <LValueToRValue> |       | `-DeclRefExpr 0x7fbfe0890c88 <col:16> 'I *__strong' lvalue ParmVar 0x7fbfe0863ef8 'p' 'I *__strong' |       `-CompoundStmt 0x7fbfe0863b78 <col:19, col:20> ``` Note how in the instantiated version ImplicitValueInitExpr unexpectedly appears. While objects are auto-initialized under ARC, it does not make sense to have an initializer for a for-loop variable, and it makes even less sense to have such a different AST for instantiated and non-instantiated version. Digging deeper, I have found that there are two separate Sema* files for dealing with templates and for dealing with non-templatized code. In a non-templatized version, an initialization was performed only for variables which are not loop variables for an Objective-C loop and not variables for a C++ for-in loop: ```   if (FRI && (Tok.is(tok::colon) || isTokIdentifier_in())) {     bool IsForRangeLoop = false;     if (TryConsumeToken(tok::colon, FRI->ColonLoc)) {       IsForRangeLoop = true;       if (Tok.is(tok::l_brace))         FRI->RangeExpr = ParseBraceInitializer();       else         FRI->RangeExpr = ParseExpression();     }     Decl *ThisDecl = Actions.ActOnDeclarator(getCurScope(), D);     if (IsForRangeLoop)       Actions.ActOnCXXForRangeDecl(ThisDecl);     Actions.FinalizeDeclaration(ThisDecl);     D.complete(ThisDecl);     return Actions.FinalizeDeclaratorGroup(getCurScope(), DS, ThisDecl);   }   SmallVector<Decl *, 8> DeclsInGroup;   Decl *FirstDecl = ParseDeclarationAfterDeclaratorAndAttributes(       D, ParsedTemplateInfo(), FRI); ``` However the code in SemaTemplateInstantiateDecl was inconsistent, guarding only against C++ for-in loops. rdar://38391075 Differential Revision: https://reviews.llvm.org/D44989 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328749 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS] Fix late-parsed template infinite loop in eager instantiationReid Kleckner2018-03-261-2/+2
| | | | | | | | | | | | | | | | | | Summary: This fixes PR33561 and PR34185. Don't store pending template instantiations for late-parsed templates in the normal PendingInstantiations queue. Instead, use a separate list that will only be parsed and instantiated at end of TU when late template parsing actually works and doesn't infinite loop. Reviewers: rsmith, thakis, hans Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44846 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328567 91177308-0d34-0410-b5e6-96231b3b80d8
* Sink PrettyDeclStackTrace down to the AST libraryJordan Rose2018-03-231-5/+5
| | | | | | | ...and add some very basic stack trace entries for module building. This would have helped track down rdar://problem/38434694 sooner. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328276 91177308-0d34-0410-b5e6-96231b3b80d8
* Properly construct `inline` members without initializersGeorge Burgess IV2018-03-201-1/+3
| | | | | | | | | | | | | Digging through commit logs, it appears the checks in this block predate `inline` class variables. With them, we fail to emit dynamic initializers for members that don't have an explicit initializer, and we won't go out of our way to instantiate the class denoted by `Var->getType()`. Fixes PR35599. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327945 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement C++ DR727, which permits explicit specializations at class scope.Richard Smith2018-03-161-0/+3
| | | | | | | | | | More generally, this permits a template to be specialized in any scope in which it could be defined, so this also supersedes DR44 and DR374 (the latter of which we previously only implemented in C++11 mode onwards due to unclarity as to whether it was a DR). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327705 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactoring code around move/copy initialization. NFC.Richard Trieu2018-03-151-1/+1
| | | | | | | | | | | | | Use an enum parameter instead of a bool for more control on how the copy elision functions work. Extract the move initialization code from the move or copy initialization block. Patch by: Arthur O'Dwyer Differential Revision: https://reviews.llvm.org/D43898 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327598 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sema] Pop function scope when instantiating a func with skipped bodyIlya Biryukov2018-03-141-6/+6
| | | | | | | | | | | | | | | | | | | | | Summary: By calling ActOnFinishFunctionBody(). Previously we were only calling ActOnSkippedFunctionBody, which didn't pop the function scope. This causes a crash when running on our internal code. No test-case, though, since I couldn't come up with a small example in reasonable time. The bug was introduced in r321174. Reviewers: bkramer, sammccall, sepavloff, aaron.ballman Reviewed By: sammccall, aaron.ballman Subscribers: aaron.ballman, cfe-commits Differential Revision: https://reviews.llvm.org/D44439 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327504 91177308-0d34-0410-b5e6-96231b3b80d8
* Reland "[Attr] Fix parameter indexing for several attributes"Joel E. Denny2018-03-131-1/+2
| | | | | | | | | Relands r326602 (reverted in r326862) with new test and fix for PR36620. Differential Revision: https://reviews.llvm.org/D43248 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327405 91177308-0d34-0410-b5e6-96231b3b80d8