summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merging r213834:Bill Wendling2014-08-041-3/+6
| | | | | | | | | | | | | | ------------------------------------------------------------------------ r213834 | rsmith | 2014-07-23 19:27:39 -0700 (Wed, 23 Jul 2014) | 4 lines Take the canonical type when forming a canonical template argument with 'nullptr' value. Fixes profiling of such template arguments to always give the same value. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_35@214751 91177308-0d34-0410-b5e6-96231b3b80d8
* PR20356: Fix all Sema warnings with mismatched ext_/warn_ versusRichard Smith2014-07-191-1/+1
| | | | | | | | | ExtWarn/Warnings. Mostly the name of the warning was changed to match the semantics, but in the PR20356 cases, the warning was about valid code, so the diagnostic was changed from ExtWarn to Warning instead. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213443 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix FriendDecl source location and range for class templates and function ↵Nikola Smiljanic2014-07-171-4/+4
| | | | | | declarations that don't start with 'friend' keyword. Add more unittests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213220 91177308-0d34-0410-b5e6-96231b3b80d8
* Sema: Allow dllimport entities in template args for mingwDavid Majnemer2014-06-261-19/+26
| | | | | | | | | | | | | | Previously dllimport variables inside of template arguments relied on not using the C++11 codepath when -fms-compatibility was set. While this allowed us to achieve compatibility with MSVC, it did so at the expense of MingW. Instead, try to use the DeclRefExpr we dig out of the template argument. If it has the dllimport attribute, accept it and skip the C++11 null-pointer check. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211766 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert some function arguments to use ArrayRef.Craig Topper2014-06-261-16/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211764 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't allow dllimport variables in constant initializersHans Wennborg2014-06-251-1/+1
| | | | | | | | | | | | | | | | | This is a follow-up to David's r211677. For the following code, we would end up referring to 'foo' in the initializer for 'arr', and then fail to link, because 'foo' is dllimport and needs to be accessed through the __imp_?foo. __declspec(dllimport) extern const char foo[]; const char* f() { static const char* const arr[] = { foo }; return arr[0]; } Differential Revision: http://reviews.llvm.org/D4299 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211736 91177308-0d34-0410-b5e6-96231b3b80d8
* Hide the concept of diagnostic levels from lex, parse and semaAlp Toker2014-06-151-6/+11
| | | | | | | | | | | | | | | | The compilation pipeline doesn't actually need to know about the high-level concept of diagnostic mappings, and hiding the final computed level presents several simplifications and other potential benefits. The only exceptions are opportunistic checks to see whether expensive code paths can be avoided for diagnostics that are guaranteed to be ignored at a certain SourceLocation. This commit formalizes that invariant by introducing and using DiagnosticsEngine::isIgnored() in place of individual level checks throughout lex, parse and sema. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211005 91177308-0d34-0410-b5e6-96231b3b80d8
* Recover from missing 'typename' in sizeof(T::InnerType)Reid Kleckner2014-06-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: 'sizeof' is a UnaryExprOrTypeTrait, and it can contain either a type or an expression. This change threads a RecoveryTSI parameter through the layers between TransformUnaryExprOrTypeTrait the point at which we look up the type. If lookup finds a single type result after instantiation, we now build TypeSourceInfo for it just like a normal transformation would. This fixes the last error in the hello world ATL app that I've been working with, and it now links and runs with clang. Please try it and file bugs! Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4108 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210855 91177308-0d34-0410-b5e6-96231b3b80d8
* Recover from missing typenames on template args for MSVC compatibilityReid Kleckner2014-06-101-10/+34
| | | | | | | | | | | | | While matching a non-type template argument against a known template type parameter we now modify the AST's TemplateArgumentLoc to assume the user wrote typename. Under -fms-compatibility, we downgrade our diagnostic from an error to an extwarn. Reviewed by: rsmith Differential Revision: http://reviews.llvm.org/D4049 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210607 91177308-0d34-0410-b5e6-96231b3b80d8
* PR14841: If partial substitution of explicitly-specified template argumentsRichard Smith2014-06-061-0/+11
| | | | | | | | | results in a template having too many arguments, but all the trailing arguments are packs, that's OK if we have a partial pack substitution: the trailing pack expansions may end up empty. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210350 91177308-0d34-0410-b5e6-96231b3b80d8
* PR11306 - Variadic template fix-it suggestion. Recover from misplaced or ↵Nikola Smiljanic2014-06-061-3/+4
| | | | | | redundant ellipsis in parameter pack. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210304 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactoring. Remove Owned method from Sema.Nikola Smiljanic2014-05-291-32/+23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209812 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-13/+13
| | | | | | takeAs to getAs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209800 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-64/+68
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209613 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] If a referenced-but-not-instantiated class template specializationRichard Smith2014-05-231-18/+1
| | | | | | | | | | | gets explicitly specialized, don't reuse the previous class template specialization declaration as a new declaration. The benefit here is fairly marginal, it harms source fidelity, and this is horrible to model if the specialization was imported from another module (without this change, it asserts or worse). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209552 91177308-0d34-0410-b5e6-96231b3b80d8
* Permit duplicate explicit class instantiations if MSVCCompat is enabledWill Wilson2014-05-091-2/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208402 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR19169 [Crash on invalid attempting to specialize a template method as ↵Karthik Bhat2014-05-081-2/+11
| | | | | | | | | | a template variable]. A template declaration of a template name can be null in case we have a dependent name or a set of function templates. Hence use dyn_cast_or_null instead of dyn_cast. Also improve the diagnostic emitted in this case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208313 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bunch of mislayered clang/Lex includes from SemaAlp Toker2014-05-031-4/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207896 91177308-0d34-0410-b5e6-96231b3b80d8
* If we see an explicit instantiation declaration or definition of a functionRichard Smith2014-04-241-1/+6
| | | | | | | | | | | | | | after we've already instantiated a definition for the function, pass it to the ASTConsumer again so that it knows the specialization kind has changed and can update the function's linkage. This only matters if we instantiate the definition of the function before we reach the end of the TU; this can happen in at least three different ways: C++11 constexpr functions, C++14 deduced return types, and functions instantiated within modules. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207152 91177308-0d34-0410-b5e6-96231b3b80d8
* Initial implementation of -modules-earch-all option, for searching for ↵John Thompson2014-04-231-1/+2
| | | | | | symbols in non-imported modules. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206977 91177308-0d34-0410-b5e6-96231b3b80d8
* SemaTemplate.cpp: Rework r206451. Removing an argument was really bad idea.NAKAMURA Takumi2014-04-171-4/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206452 91177308-0d34-0410-b5e6-96231b3b80d8
* SemaTemplate.cpp: Appease msvc to get rid of default argument in lambda ↵NAKAMURA Takumi2014-04-171-2/+2
| | | | | | | | definition. clang\lib\Sema\SemaTemplate.cpp(1826) : error C2064: term does not evaluate to a function taking 1 arguments git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206451 91177308-0d34-0410-b5e6-96231b3b80d8
* PR19340: If we see a declaration of a member of an unspecialized class templateRichard Smith2014-04-171-39/+46
| | | | | | | | that looks like it might be an explicit specialization, don't recover as an explicit specialization (bypassing the check that would reject that). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206444 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor all the checking for missing 'template<>'s when a declaration has aRichard Smith2014-04-171-38/+60
| | | | | | | template-id after its scope specifier into a single place. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206442 91177308-0d34-0410-b5e6-96231b3b80d8
* Render anonymous entities as '(anonymous <thing>)' (and lambdas as '(lambda ↵David Blaikie2014-04-021-2/+2
| | | | | | | | | | | | at ... )') For namespaces, this is consistent with mangling and GCC's debug info behavior. For structs, GCC uses <anonymous struct> but we prefer consistency between all anonymous entities but don't want to confuse them with template arguments, etc, so we'll just go with parens in all cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205398 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing FunctionProtoType iterators param_type_begin() and ↵Aaron Ballman2014-03-171-4/+2
| | | | | | param_type_end() with iterator_range param_types(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204045 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-121-3/+3
| | | | | | class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203640 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing FunctionDecl iterators param_begin() and param_end() with ↵Aaron Ballman2014-03-071-4/+2
| | | | | | iterator_range params(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203248 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove accidentally-committed debugging statement. Thanks to Faisal Vali forRichard Smith2014-02-211-1/+0
| | | | | | | spotting this! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201871 91177308-0d34-0410-b5e6-96231b3b80d8
* PR16519, PR18009: When checking a partial specialization for uses of its ownRichard Smith2014-02-091-31/+94
| | | | | | | | | | | template parameters, don't look for parameters of outer templates. If a problem is found in a default template argument, point the diagnostic at the partial specialization (with a note pointing at the default argument) instead of pointing it at the default argument and leaving it unclear which partial specialization os problematic. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201031 91177308-0d34-0410-b5e6-96231b3b80d8
* MS ABI: Tweak pointer-to-member mangling/inheritance model selectionDavid Majnemer2014-02-061-0/+3
| | | | | | | | | | | | | Properly determine the inheritance model when dealing with nullptr: - If a nullptr template argument is being checked against pointer-to-member parameter, nail down an inheritance model. N.B. We will chose an inheritance model even if we won't ultimately choose the template to instantiate! Cooky, right? - Null pointer-to-datamembers have a virtual base table offset of -1, not zero. Previously, we chose an offset of 0. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200920 91177308-0d34-0410-b5e6-96231b3b80d8
* PR17846, PR17848: don't build a VarTemplateSpecializationDecl for a use of aRichard Smith2014-02-031-4/+7
| | | | | | | variable template until we know what the template arguments actually are. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200714 91177308-0d34-0410-b5e6-96231b3b80d8
* Sema: Reject templates in all extern "C" contexts.Benjamin Kramer2014-02-021-5/+6
| | | | | | | Otherwise we'd accept them if the LinkageDecl was not the direct parent DeclContext. PR17968. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200641 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-3/+3
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200082 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker2014-01-201-4/+4
| | | | | | | | | | | | | | | | | Fix a perennial source of confusion in the clang type system: Declarations and function prototypes have parameters to which arguments are supplied, so calling these 'arguments' was a stretch even in C mode, let alone C++ where default arguments, templates and overloading make the distinction important to get right. Readability win across the board, especially in the casting, ADL and overloading implementations which make a lot more sense at a glance now. Will keep an eye on the builders and update dependent projects shortly. No functional change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199686 91177308-0d34-0410-b5e6-96231b3b80d8
* Clean up variable template handling a bit, and correct the behavior of nameRichard Smith2014-01-161-6/+11
| | | | | | | lookup when declaring a variable template specialization. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199438 91177308-0d34-0410-b5e6-96231b3b80d8
* PR18401: Fix assert by implementing the current proposed direction of coreRichard Smith2014-01-091-15/+19
| | | | | | | | issue 1430. Don't allow a pack expansion to be used as an argument to an alias template unless the corresponding parameter is a parameter pack. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198833 91177308-0d34-0410-b5e6-96231b3b80d8
* PR18234: Mark a tag definition as invalid early if it appears in aRichard Smith2014-01-081-1/+2
| | | | | | | | | type-specifier in C++. Some checks will assert in this case otherwise (in particular, the access specifier may be missing if this happens inside a class definition, due to a violation of an AST invariant). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198721 91177308-0d34-0410-b5e6-96231b3b80d8
* Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth2014-01-071-1/+1
| | | | | | | encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198686 91177308-0d34-0410-b5e6-96231b3b80d8
* It turns out the problem was a bit more wide-spread. Removing a lot of ↵Aaron Ballman2014-01-031-11/+7
| | | | | | | | unneeded typecasts. getScopeRep() already returns a NestedNameSpecifier. No functional changes intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198414 91177308-0d34-0410-b5e6-96231b3b80d8
* PR18246: When performing template argument deduction to decide which templateRichard Smith2013-12-141-3/+3
| | | | | | | | | | | is specialized by an explicit specialization, start from the first declaration in case we've got a member of a class template (redeclarations might not number the template parameters the same way). Our recover here is still far from ideal. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197305 91177308-0d34-0410-b5e6-96231b3b80d8
* Take into consideration calling convention when processing specializations.Rafael Espindola2013-12-101-1/+4
| | | | | | This fixes pr18141. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196855 91177308-0d34-0410-b5e6-96231b3b80d8
* Sema: Enforce C++11 pointer-to-member template arguments should rulesDavid Majnemer2013-12-101-3/+1
| | | | | | | | | | | | | The standard is pretty clear on what it allows inside of template arguments for non-type template parameters of pointer-to-member. They must be of the form &qualified-id and cannot come from sources like constexpr VarDecls or things of that nature. This fixes PR18192. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196852 91177308-0d34-0410-b5e6-96231b3b80d8
* Give a more appropriate diagnostic when a template specialization orRichard Smith2013-12-071-31/+33
| | | | | | | | instantiation appears in a non-enclosing namespace (the previous diagnostic talked about the C++98 rule even in C++11 mode). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196642 91177308-0d34-0410-b5e6-96231b3b80d8
* Per [dcl.meaning]p1, a name in an inline namespace can be redeclared using aRichard Smith2013-12-051-1/+2
| | | | | | | | name from the enclosing namespace set if the name is specified as a qualified-id. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196464 91177308-0d34-0410-b5e6-96231b3b80d8
* Reject template-ids containing literal-operator-ids that have a dependentRichard Smith2013-12-051-2/+1
| | | | | | | | | | nested-name-specifier, rather than crashing. (In fact, reject all literal-operator-ids that have a non-namespace nested-name-specifier). The grammar doesn't allow these in some cases, and in other cases does allow them but instantiation will always fail. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196443 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix crash if a dependent template-id was assumed to be a type but instantiatesRichard Smith2013-12-041-1/+2
| | | | | | | to a variable template specialization. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196337 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix several crash-on-invalids when using template-ids that aren'tRichard Smith2013-12-041-1/+1
| | | | | | | simple-template-ids (eg, 'operator+<int>') in weird places. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196333 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle CC and NoReturn when instantiating members of class templates.Rafael Espindola2013-12-011-1/+2
| | | | | | | | Before we were considering them only when instantiating templates. This fixes pr18033. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196050 91177308-0d34-0410-b5e6-96231b3b80d8
* Sema: Instantiate local class and their members appropriatelyDavid Majnemer2013-11-271-1/+4
| | | | | | | | | | | | We would fail to instantiate them when the surrounding function was instantiated. Instantiate the class and add it's members to the list of pending instantiations, they should be resolved when we are finished with the function's body. This fixes PR9685. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195827 91177308-0d34-0410-b5e6-96231b3b80d8