summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [AST] Use ArrayRef in more interfacesDavid Majnemer2016-07-071-9/+5
| | | | | | | | | ArrayRef is a little better than passing around a pointer/length pair. No functional change is intended. llvm-svn: 274732
* [AST] Use ArrayRef in more interfacesDavid Majnemer2016-07-031-21/+13
| | | | | | | | ArrayRef is a little better than passing around a pointer/length pair. No functional change is intended. llvm-svn: 274475
* [Feature] Add a builtin for indexing into parameter packs. Patch by Louis ↵Eric Fiselier2016-07-011-1/+25
| | | | | | | | | | | | | Dionne. This patch adds a __nth_element builtin that allows fetching the n-th type of a parameter pack with very little compile-time overhead. The patch was inspired by r252036 and r252115 by David Majnemer, which add a similar __make_integer_seq builtin for efficiently creating a std::integer_sequence. Reviewed as D15421. http://reviews.llvm.org/D15421 llvm-svn: 274316
* Fix PR28100 - Allow redeclarations of deleted explicit specializations.Faisal Vali2016-06-141-6/+14
| | | | | | | | | | | | See https://llvm.org/bugs/show_bug.cgi?id=28100. In r266561 when I implemented allowing explicit specializations of function templates to override deleted status, I mistakenly assumed (and hence introduced a violable assertion) that when an explicit specialization was being declared, the corresponding specialization of the most specialized function template that it would get linked to would always be the one that was implicitly generated - and so if it was marked as 'deleted' it must have inherited it from the primary template and so should be safe to reset its deleted status, and set it to being an explicit specialization. Obviously during redeclaration of a deleted explicit specialization, in order to avoid a recursive reset, we need to check that the previous specialization is not an explicit specialization (instead of assuming and asserting it) and that it hasn't been referenced, and so only then is it safe to reset its 'deleted' status. All regression tests pass. Thanks to Zhendong Su for reporting the bug and David Majnemer for tracking it to my commit r266561, and promptly bringing it to my attention. llvm-svn: 272631
* Fix recognition of shadowed template parameterSerge Pavlov2016-06-101-6/+8
| | | | | | | | | | | | | | | | | | | | | | | Crash reported in PR28023 is caused by the fact that non-type template parameters are found by tag name lookup. In the code provided in that PR: template<int V> struct A { struct B { template <int> friend struct V; }; }; the template parameter V is found when lookup for redeclarations of 'struct V' is made. Latter on the error about shadowing of 'V' is emitted but the semantic context of 'struct V' is already determined wrong: 'struct A' instead of translation unit. The fix moves the check for shadowing toward the beginning of the method and thus prevents from wrong context calculations. This change fixes PR28023. llvm-svn: 272366
* Re-commit r270748 "clang-cl: Treat dllimport explicit template instantiation ↵Hans Wennborg2016-05-261-2/+31
| | | | | | | | | | definitions as declarations (PR27810, PR27811)" Also make explicit instantiation decls not apply to nested classes when targeting MSVC. That dll attributes are not inherited by inner classes might be the explanation for MSVC's behaviour here. llvm-svn: 270897
* Revert r270748 "clang-cl: Treat dllimport explicit template instantiation ↵Hans Wennborg2016-05-251-31/+2
| | | | | | | | | definitions as declarations (PR27810, PR27811)" It seems to have broken the sanitizer-windows bot. Reverting while investigating. llvm-svn: 270754
* clang-cl: Treat dllimport explicit template instantiation definitions as ↵Hans Wennborg2016-05-251-2/+31
| | | | | | | | | | | declarations (PR27810, PR27811) This matches what MSVC does, and should make compiles faster by avoiding to unnecessarily emit a lot of code. Differential Revision: http://reviews.llvm.org/D20608 llvm-svn: 270748
* Properly track the found declaration (possibly a using-declaration) whenRichard Smith2016-05-241-2/+7
| | | | | | handling an explicit member specialization. llvm-svn: 270514
* Preserve the FoundDecl when performing overload resolution for constructors.Richard Smith2016-05-111-7/+9
| | | | | | | | | This is in preparation for C++ P0136R1, which switches the model for inheriting constructors over from synthesizing a constructor to finding base class constructors (via using shadow decls) when looking for derived class constructors. llvm-svn: 269231
* [modules] Enforce the rules that an explicit or partial specialization must beRichard Smith2016-05-051-4/+154
| | | | | | | | declared before it is used. Because we don't use normal name lookup to find these, the normal code to filter out non-visible names from name lookup results does not apply. llvm-svn: 268585
* [Concepts] Pass requires-clause to ActOnTemplateParameterList; NFCHubert Tong2016-04-291-3/+6
| | | | | | | | | | | | | | Summary: Prepare to store requires-clause expression for access via TemplateParameterList. Reviewers: aaron.ballman, faisalv, rsmith Subscribers: cfe-commits, nwilson Differential Revision: http://reviews.llvm.org/D19220 llvm-svn: 268081
* Implement CWG 941 - explicit specializations of deleted function templatesFaisal Vali2016-04-171-0/+14
| | | | | | | | | | | | | | | | | | | template<class T> void f(T) = delete; template<> void f(int); // OK. f(3); // OK Implementation strategy: When an explicit specialization of a function template, a member function template or a member function of a class template is declared, clang first implicitly instantiates the declaration of a specialization from the templated-entity being explicitly specialized (since their signatures must be the same) and then links the explicit specialization being declared as a redeclaration of the aforementioned specialization. The problem was that when clang 'implicitly instantiates' the initial specialization, it marks the corresponding FunctionDecl as deleted if the corresponding templated-entity was deleted, rather than waiting to see whether the explicit specialization being declared provides a non-deleted body. (The eager marking of delete has advantages during overload resolution I suppose, where we don't have to try and instantiate a definition of the function to see if it is deleted). The present fix entails recognizing that when clang knows that an explicit specialization is being declared (for whichever templated-entity), the prior implicit instantiation should not inherit the 'deleted' status, and so we reset it to false. I suppose an alternative fix (amongst others) could consider creating a new context (ExplicitSpecializationDeclarationSubstitution or some such) that is checked during template-argument-deduction and final substitution, and avoid inheriting the deleted status during declaration substitution. But while conceptually cleaner, that would be a slightly more involved change (as could be some of the other alternatives: such as avoid tagging implicit specializations as deleted, and check their primary templates for the deleted status where needed), and so I chose a different path. Hopefully it'll prove to not be a bad choice. llvm-svn: 266561
* [Concepts] Implement subsection [dcl.spec.concept]p7 of the Concepts TSNathan Wilson2016-04-091-0/+28
| | | | | | | | | | | | Summary: A program shall not declare an explicit instantiation (14.8.2), an explicit specialization (14.8.3), or a partial specialization of a concept definition. Reviewers: rsmith, hubert.reinterpretcast, faisalv, aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18221 llvm-svn: 265868
* Fix a crash on invalid with template handlingRichard Trieu2016-04-051-6/+12
| | | | | | | | This is a fix for https://llvm.org/bugs/show_bug.cgi?id=25561 which was a crash on invalid. Change the handling of invalid decls to have a catch-all case to prevent unexpecting decls from triggering an assertion. llvm-svn: 265467
* [NFC] Tweak diagnostic for template template arguments, to include template ↵Faisal Vali2016-03-261-2/+2
| | | | | | | | aliases. The prior diagnostic (err_template_arg_not_class_template) would state that the template argument to a template template parameter can only be a class template, when it can also be a template alias. The newly renamed diagnostic (err_template_arg_not_valid_template) mentions template aliases. llvm-svn: 264522
* Allow sizeof(UnrelatedClass::field) in C++11 class template methodsReid Kleckner2016-03-111-3/+16
| | | | | | | | | | | | | | | | | This feature works outside of templates by forming a DeclRefExpr to a FieldDecl instead of a MemberExpr, which requires a base object in addition to the FieldDecl. Previously, while building up the template AST before instantiation, we formed a CXXDependentScopeMemberExpr, which always instantiates to a MemberExpr. Now, in unevaluated contexts we form a DependentScopeDeclRefExpr, which is a more flexible node that can instantiate to either a MemberExpr or a DeclRefExpr depending on lookup results. Fixes PR26893. llvm-svn: 263279
* [dllexport] Sort out emission order of delayed exported classesReid Kleckner2016-02-261-0/+6
| | | | | | | | | | | | | | | | Relands r260194 with a fix. If we have a template that transitions from an extern template to an explicitly instantiated dllexport template, we would add that class to the delayed exported class list without flushing it. For explicit instantiations, we can just flush the list of delayed classes immediately. We don't have to worry about the bug fixed in r260194 in this case because explicit instantiations can only occur at file and namespace scope. Fixes PR26490. llvm-svn: 262056
* Removed unused local variableSerge Pavlov2016-02-191-3/+0
| | | | llvm-svn: 261323
* Fix remaining Clang-tidy readability-redundant-control-flow warnings; other ↵Eugene Zelenko2016-02-121-9/+8
| | | | | | | | minor fixes. Differential revision: http://reviews.llvm.org/D17218 llvm-svn: 260757
* [Concepts] Implement a portion of Concepts TS[dcl.spec.concept]p1 byNathan Wilson2016-02-081-0/+9
| | | | | | | | | | | | | | diagnosing when 'concept' is specified on a function or template specialization. Since a concept can only be applied to a function or variable template, the concept bit is stored in TemplateDecl as a PointerIntPair. Reviewers: rsmith, faisalv, aaron.ballman, hubert.reinterpretcast Differential Revision: http://reviews.llvm.org/D13357 llvm-svn: 260074
* Fix PR26134: When substituting into default template arguments, keep ↵Faisal Vali2016-01-191-1/+0
| | | | | | | | | | | | | | | CurContext unchanged. Or, do not set Sema's CurContext to the template declaration's when substituting into default template arguments of said template declaration. If we do push the template declaration context on to Sema, and the template declaration is at namespace scope, Sema can get confused and try and do odr analysis when substituting into default template arguments, even though the substitution could be occurring within a dependent context. I'm not sure why this was being done, perhaps there was concern that if a default template argument referred to a previous template parameter, it might not be found during substitution - but all regression tests pass, and I can't craft a test that would cause it to fails (if some one does, please inform me, and i'll craft a different fix for the PR). This patch removes a single line of code, but unfortunately adds more than it removes, because of the tests. Some day I still hope to commit a patch that removes far more lines than it adds, while leaving clang better for it ;) Sorry that r253590 ("Change the expression evaluation context from Unevaluated to ConstantEvaluated while substituting into non-type template argument defaults") caused the PR! llvm-svn: 258110
* OpaquePtr: Use nullptr construction for ParsedType OpaquePtr typedefDavid Blaikie2016-01-151-1/+1
| | | | llvm-svn: 257958
* [OpenCL] Pipe type supportXiuli Pan2016-01-091-0/+4
| | | | | | | | | | | | | | | Summary: Support for OpenCL 2.0 pipe type. This is a bug-fix version for bader's patch reviews.llvm.org/D14441 Reviewers: pekka.jaaskelainen, Anastasia Subscribers: bader, Anastasia, cfe-commits Differential Revision: http://reviews.llvm.org/D15603 llvm-svn: 257254
* Properly track that a character literal is UTF-8, and pretty print the ↵Aaron Ballman2016-01-071-0/+2
| | | | | | prefix properly. llvm-svn: 257097
* Teach typo correction to properly handle mapping declarations to theirRichard Smith2015-12-291-2/+2
| | | | | | | | | | underlying decls. Preserve the found declaration throughout, and only map to the underlying declaration when we want to check whether it's the right kind. This allows us to provide the right source location for the found declaration, and prepares for the possibility of underlying decls with a different name from the found decl. llvm-svn: 256575
* ArrayRef-ize TemplateParameterList. NFCDavid Majnemer2015-12-271-4/+5
| | | | llvm-svn: 256463
* [Sema] ArrayRef-ize ActOnTemplateParameterList. NFCCraig Topper2015-12-241-3/+3
| | | | llvm-svn: 256400
* Split RequireCompleteType into a function that actually requires that the typeRichard Smith2015-12-181-1/+1
| | | | | | | | | | | | | | | | | | | is complete (with an error produced if not) and a function that merely queries whether the type is complete. Either way we'll trigger instantiation if necessary, but only the former will diagnose and recover from missing module imports. The intent of this change is to prevent a class of bugs where code would call RequireCompleteType(..., 0) and then ignore the result. With modules, we must check the return value and use it to determine whether the definition of the type is visible. This also fixes a debug info quality issue: calls to isCompleteType do not trigger the emission of debug information for a type in limited-debug-info mode. This allows us to avoid emitting debug information for type definitions in more cases where we believe it is safe to do so. llvm-svn: 256049
* Add the `pass_object_size` attribute to clang.George Burgess IV2015-12-021-2/+4
| | | | | | | | | | | | | `pass_object_size` is our way of enabling `__builtin_object_size` to produce high quality results without requiring inlining to happen everywhere. A link to the design doc for this attribute is available at the Differential review link below. Differential Revision: http://reviews.llvm.org/D13263 llvm-svn: 254554
* Change the expression evaluation context from Unevaluated to ↵Faisal Vali2015-11-191-1/+2
| | | | | | | | | | | | ConstantEvaluated while substituting into non-type template argument defaults. Also address a typo from a prior patch that performed a similar fix during Parsing of default non-type template arguments. I left the RAII ExpressionEvaluationContext variable Name as Unevaluated though we had switched the context to ConstantEvaluated. There should be no functionality change here - since when expression evaluation context is popped off, for the most part these two contexts currently behave similarly in regards to lambda diagnostics and odr-use tracking. Like its parsing counterpart, this patch presages the advent of constexpr lambda patches... llvm-svn: 253590
* [Sema] Don't work around a malformed ASTDavid Majnemer2015-11-181-1/+11
| | | | | | | | | | | | We created a malformed TemplateSpecializationType: it was dependent but had a RecordType as it's canonical type. This would lead getAs to crash. r249090 worked around this but we should fix this for real by providing a more appropriate template specialization type as the canonical type. This fixes PR24246. llvm-svn: 253495
* [Sema] Implement __make_integer_seqDavid Majnemer2015-11-041-1/+58
| | | | | | | | | | | | | | | | | | This new builtin template allows for incredibly fast instantiations of templates like std::integer_sequence. Performance numbers follow: My work station has 64 GB of ram + 20 Xeon Cores at 2.8 GHz. __make_integer_seq<std::integer_sequence, int, 90000> takes 0.25 seconds. std::make_integer_sequence<int, 90000> takes unbound time, it is still running. Clang is consuming gigabytes of memory. Differential Revision: http://reviews.llvm.org/D13786 llvm-svn: 252036
* PR24921: checking explicitly-specified template arguments when matching aRichard Smith2015-10-021-6/+15
| | | | | | | partial specialization can perform conversions on the argument. Be sure we start again from the original argument when checking each possible template. llvm-svn: 249114
* Simplify logic introduced in r247464.David Majnemer2015-09-111-3/+3
| | | | llvm-svn: 247472
* [MS ABI] Select an inheritance model in template argumentsDavid Majnemer2015-09-111-3/+5
| | | | | | | | | | | | We used to only select an inheritance model if the pointer to member was nullptr. Instead, select a model regardless of the member pointer's value. N.B. This bug was exposed by making member pointers report true for isIncompleteType but has been latent since the member pointer scheme's inception. llvm-svn: 247464
* [sema] Fix assertion hit when using libclang to index a particular C++ ↵Argyrios Kyrtzidis2015-09-111-2/+7
| | | | | | | | snippet involving templates. Assertion hit was in ClassTemplateSpecializationDecl::getSourceRange(). llvm-svn: 247373
* [modules] When we see a definition of a function for which we already have aRichard Smith2015-08-211-18/+0
| | | | | | | non-visible definition, skip the new definition to avoid ending up with a function with multiple definitions. llvm-svn: 245664
* PR24483: Delete some dead/incorrect code that triggered assertions.Richard Smith2015-08-201-19/+0
| | | | llvm-svn: 245609
* [AST] ArrayRefize template param list info setters. No functionality change ↵Benjamin Kramer2015-08-051-8/+6
| | | | | | intended. llvm-svn: 244028
* [AST] ArrayRefize template argument packs. No functionality change intended.Benjamin Kramer2015-08-051-10/+6
| | | | llvm-svn: 244026
* Sema: Allow null names to be passed in to isAcceptableTagRedeclarationJustin Bogner2015-07-101-4/+4
| | | | | | | | | | | | | It's possible for TagRedeclarations to involve decls without a name, ie, anonymous enums. We hit some undefined behaviour if we bind these null names to the reference here. We never dereference the name, so it's harmless if it's null - make it a pointer to allow that. Fixes the Modules/submodules-merge-defs.cpp test under ubsan. llvm-svn: 241963
* PR24030, PR24033: Consistently check whether a new declaration conflicts withRichard Smith2015-07-061-3/+18
| | | | | | | | | | an existing using shadow declaration if they define entities of the same kind in different namespaces. We'd previously check this consistently if the using-declaration came after the other declaration, but not if it came before. llvm-svn: 241428
* DR1909: Diagnose all invalid cases of a class member sharing its name with ↵Richard Smith2015-07-061-0/+10
| | | | | | the class. llvm-svn: 241425
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-3/+3
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-3/+3
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* [modules] Improve diagnostic for a template-id that's invalid because a defaultRichard Smith2015-06-171-3/+35
| | | | | | argument is not visible. llvm-svn: 239934
* [modules] Don't allow use of non-visible (inherited) default template arguments.Richard Smith2015-06-101-6/+6
| | | | llvm-svn: 239487
* [modules] Track all default template arguments for a given parameter acrossRichard Smith2015-06-101-12/+5
| | | | | | | modules, and allow use of a default template argument if any of the parameters providing it is visible. llvm-svn: 239485
* Refactor storage of default template arguments.Richard Smith2015-06-101-16/+6
| | | | | | | This is just a preparatory step towards fixing visibility for default template arguments in modules builds. llvm-svn: 239447
OpenPOWER on IntegriCloud