summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [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
* Enable DLL attribute propagation on explicit instantiation definitions (PR23770)Hans Wennborg2015-06-091-0/+7
| | | | | | | | This is a follow-up to r225570 which enabled adding DLL attributes when a class template goes from explicit instantiation declaration to explicit instantiation definition. llvm-svn: 239375
* MinGW: don't allow adding DLL attribute if template already has explicit ↵Hans Wennborg2015-06-091-1/+5
| | | | | | | | instantiation declaration This is a follow-up to r238266 which failed to take MinGW into account. llvm-svn: 239374
* clang-cl: Handle dll attributes in explicit class template specialization ↵Hans Wennborg2015-05-271-1/+10
| | | | | | | | | | definitions (PR23667) Previously, we wouldn't call checkDLLAttribute() after the class template specialization definition if the class template was already instantiated by an explicit class template specialization declaration. llvm-svn: 238266
* [modules] Support merging a parsed default argument with an imported hidden ↵Richard Smith2015-05-201-0/+4
| | | | | | one for non-type and template template parameters too. llvm-svn: 237815
* [modules] Support merging a parsed default function/template argument with ↵Richard Smith2015-05-201-0/+3
| | | | | | an imported but hidden one. llvm-svn: 237814
* [modules] Support for merging a parsed class template specialization ↵Richard Smith2015-05-181-2/+11
| | | | | | definition into an imported but hidden definition. llvm-svn: 237612
* [modules] Suport for merging a parsed enum definition into an existing ↵Richard Smith2015-05-071-9/+4
| | | | | | imported but not visible definition. llvm-svn: 236690
* [modules] Handle defining a class template on top of an existing ↵Richard Smith2015-03-271-1/+20
| | | | | | imported-but-not-visible definition. llvm-svn: 233341
* [Modules] Preserve source order for the map of late parsed templates.Chandler Carruth2015-03-261-1/+1
| | | | | | | | | | | | | | | | | | | | Clang was inserting these into a dense map. While it never iterated the dense map during normal compilation, it did when emitting a module. Fix this by using a standard MapVector to preserve the order in which we encounter the late parsed templates. I suspect this still isn't ideal, as we don't seem to remove things from this map even when we mark the templates as no longer late parsed. But I don't know enough about this particular extension to craft a nice, subtle test case covering this. I've managed to get the stress test to at least do some late parsing and demonstrate the core problem here. This patch fixes the test and provides deterministic behavior which is a strict improvement over the prior state. I've cleaned up some of the code here as well to be explicit about inserting when that is what is actually going on. llvm-svn: 233264
* [MSVC] Explicit specializations can be declared in any namespace (fix for ↵Alexey Bataev2015-03-201-5/+7
| | | | | | | | | | | | | | http://llvm.org/PR13738) MS compiler emits no errors in case of explicit specializations outside declaration enclosing namespaces, even when language extensions are disabled. The patch is to suppress errors and emit extension warnings if explicit specializations are not declared in the corresponding namespaces. This fixes PR13738. Patch by Alexey Frolov. Differential Revision: http://reviews.llvm.org/D8283 llvm-svn: 232800
* Wrap to 80 cols by removing trailing whitespace. No behavior change.Nico Weber2015-01-301-1/+1
| | | | llvm-svn: 227553
* When checking the template argument list, use a copy of that list for changesRichard Trieu2015-01-241-22/+34
| | | | | | | | | | | | | | | | | | | and only update the orginal list on a valid arugment list. When checking an individual expression template argument, and conversions are required, update the expression in the template argument. Since template arguments are speculatively checked, the copying of the template argument list prevents updating the template arguments when the list does not match the template. Additionally, clean up the integer checking code in the template diffing code. The code performs unneccessary conversions from APSInt to APInt. Fixes PR21758. This essentially reverts r224770 to recommits r224667 and r224668 with extra changes to prevent the template instantiation problems seen in PR22006. A test to catch the discovered problem is also added. llvm-svn: 226983
* Warn about dllexported explicit class template instantiation declarations ↵Hans Wennborg2015-01-151-3/+21
| | | | | | | | | | | | | | | (PR22035) Clang would previously become confused and crash here. It does not make a lot of sense to export these, so warning seems appropriate. MSVC will export some member functions for this kind of specializations, whereas MinGW ignores the dllexport-edness. The latter behaviour seems better. Differential Revision: http://reviews.llvm.org/D6984 llvm-svn: 226208
* 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
* 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
OpenPOWER on IntegriCloud