summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Support for C1x _Atomic specifier (see testcase). This is primarily being ↵Eli Friedman2011-10-061-0/+4
| | | | | | | | committed at the moment to help support C++0x <atomic>, but it should be a solid base for implementing the full specification of C1x _Atomic. Thanks to Jeffrey Yasskin for the thorough review! llvm-svn: 141330
* Fixed source range for template implicit instantiations.Abramo Bagnara2011-10-031-1/+1
| | | | llvm-svn: 141018
* Only print _Bool as 'bool' when 'bool' is defined as an object-likeDouglas Gregor2011-09-271-1/+1
| | | | | | macro whose only replacement token is '_Bool'. llvm-svn: 140656
* When 'bool' is not a built-in type but is defined as a macro, printDouglas Gregor2011-09-271-1/+1
| | | | | | | 'bool' rather than '_Bool' within types, to make things a bit more readable. Fixes <rdar://problem/10063263>. llvm-svn: 140650
* Get rid of useless helper Sema::CastCategory.Eli Friedman2011-09-271-2/+4
| | | | llvm-svn: 140642
* Removing a bunch of dead returns/breaks after llvm_unreachables.David Blaikie2011-09-231-5/+0
| | | | llvm-svn: 140407
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-5/+6
| | | | llvm-svn: 140367
* Don't use TemplateArgumentListInfo inside AST nodes because it may leak.Argyrios Kyrtzidis2011-09-221-3/+1
| | | | | | Use ASTTemplateArgumentListInfo instead. llvm-svn: 140331
* Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear ↵Francois Pichet2011-09-171-3/+3
| | | | | | | | that this flag must be used only for Microsoft extensions and not emulation; to avoid confusion with the new LangOptions::MicrosoftMode flag. Many of the code now under LangOptions::MicrosoftExt will eventually be moved under the LangOptions::MicrosoftMode flag. llvm-svn: 139987
* Specializations cannot be module-hidden. Diagnose attempts to do so.Douglas Gregor2011-09-091-0/+6
| | | | llvm-svn: 139406
* __module_private__ is inherited by redeclarations of an entity, andDouglas Gregor2011-09-091-5/+10
| | | | | | must also be present of the first declaration of that entity. llvm-svn: 139384
* Propagate __module_private__ from previous declarations to laterDouglas Gregor2011-09-091-3/+5
| | | | | | declarations. llvm-svn: 139380
* Changed references of BaseTy, MemInitTy, CXXScopeTy, TemplateParamsTy to ↵Richard Trieu2011-09-091-2/+2
| | | | | | CXXBaseSpecifier, CXXCtorInitializer, NestedNameSpecifier, TemplateParameterList and removed their typedefs. llvm-svn: 139350
* Modules: introduce the __module_private__ declaration specifier, whichDouglas Gregor2011-09-091-4/+8
| | | | | | | indicates that a declaration is only visible within the module it is declared in. llvm-svn: 139348
* Fix a crash-on-invalid.Matt Beaumont-Gay2011-08-251-1/+1
| | | | | | | | Much to everyone's surprise, the default constructor for TypeResult produces an instance with Invalid == false. This seems like a decision we may want to revisit. llvm-svn: 138601
* Implement function template specialization at class scope extension in ↵Francois Pichet2011-08-141-3/+12
| | | | | | | | | | | | | | | | | Microsoft mode. A new AST node is introduced: ClassScopeFunctionSpecialization. This node holds a FunctionDecl that is not yet specialized; then during the class template instantiation the ClassScopeFunctionSpecialization will spawn the actual function specialization. Example: template <class T> class A { public: template <class U> void f(U p) { } template <> void f(int p) { } // <== class scope specialization }; This extension is necessary to parse MSVC standard C++ headers, MFC and ATL code. BTW, with this feature in, clang can parse (-fsyntax-only) all the MSVC 2010 standard header files without any error. llvm-svn: 137573
* When performing the lookup in the current scope for a member access toDouglas Gregor2011-08-101-1/+3
| | | | | | | | | | | | a member template, e.g., x.f<int> if we have found a template in the type of x, but the lookup in the current scope is ambiguous, just ignore the lookup in the current scope. Fixes <rdar://problem/9915664>. llvm-svn: 137255
* Make sure to canonicalize the argument type of a non-type templateDouglas Gregor2011-08-091-2/+3
| | | | | | argument of enumeration type when checking template arguments. Fixes PR10579. llvm-svn: 137101
* Add support for C++0x unicode string and character literals, from Craig Topper!Douglas Gregor2011-07-271-3/+15
| | | | llvm-svn: 136210
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-14/+14
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Restore the C-style cast hack for enum template arguments,John McCall2011-07-151-1/+10
| | | | | | | | which is required given the current setup for template argument deduction substitution validation, and add a test case to make sure we don't break it in the future. llvm-svn: 135262
* Create a new expression node, SubstNonTypeTemplateParmExpr,John McCall2011-07-151-30/+24
| | | | | | | | to represent a fully-substituted non-type template parameter. This should improve source fidelity, as well as being generically useful for diagnostics and such. llvm-svn: 135243
* Random cleanup:Francois Pichet2011-07-081-8/+7
| | | | | | | - fix a comment. - Remove an unnecessary { } block. llvm-svn: 134690
* Introduce the notion of instantiation dependence into Clang's AST. ADouglas Gregor2011-07-011-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | type/expression/template argument/etc. is instantiation-dependent if it somehow involves a template parameter, even if it doesn't meet the requirements for the more common kinds of dependence (dependent type, type-dependent expression, value-dependent expression). When we see an instantiation-dependent type, we know we always need to perform substitution into that instantiation-dependent type. This keeps us from short-circuiting evaluation in places where we shouldn't, and lets us properly implement C++0x [temp.type]p2. In theory, this would also allow us to properly mangle instantiation-dependent-but-not-dependent decltype types per the Itanium C++ ABI, but we aren't quite there because we still mangle based on the canonical type in cases like, e.g., template<unsigned> struct A { }; template<typename T> void f(A<sizeof(sizeof(decltype(T() + T())))>) { } template void f<int>(A<sizeof(sizeof(int))>); and therefore get the wrong answer. llvm-svn: 134225
* Preserve that a TemplateName was arrived at by substitutingJohn McCall2011-06-301-1/+2
| | | | | | | | | | | for a template template parameter. Uses to follow. I've also made the uniquing of SubstTemplateTemplateParmPacks use a ContextualFoldingSet as a minor space efficiency. llvm-svn: 134137
* Add support for C++ namespace-aware typo correction, e.g., correctingDouglas Gregor2011-06-281-10/+15
| | | | | | | | | | | | | | | vector<int> to std::vector<int> Patch by Kaelyn Uhrain, with minor tweaks + PCH support from me. Fixes PR5776/<rdar://problem/8652971>. Thanks Kaelyn! llvm-svn: 134007
* Objective-ARC++: infer template type arguments ofDouglas Gregor2011-06-171-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | ownership-unqualified retainable object type as __strong. This allows us to write, e.g., std::vector<id> and we'll infer that the vector's element types have __strong ownership semantics, which is far nicer than requiring: std::vector<__strong id> Note that we allow one to override the ownership qualifier of a substituted template type parameter, e.g., given template<typename T> struct X { typedef __weak T type; }; X<id> is treated the same as X<__strong id>. At instantiation type, the __weak in "__weak T" overrides the (inferred or specified) __strong on the template argument type, so that we can still provide metaprogramming transformations. This is part of <rdar://problem/9595486>. llvm-svn: 133303
* Automatic Reference Counting.John McCall2011-06-151-4/+11
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* When performing substitution of default template template parametersDouglas Gregor2011-06-151-10/+0
| | | | | | | | | | before the template parameters have acquired a proper context (e.g., because the enclosing context has yet to be built), provide empty parameter lists for all outer template parameter scopes to inhibit any substitution for those template parameters. Fixes PR9643 / <rdar://problem/9251019>. llvm-svn: 133055
* Made changes to how 'struct'/'class' mismatches are handled in ↵Richard Trieu2011-06-101-4/+6
| | | | | | | | | | | | | | | | | -Wmismatched-tags. - Removed fix-it hints from template instaniations since changes to the templates are rarely helpful. - Changed the caret in template instaniations from the class/struct name to the class/struct keyword, matching the other warnings. - Do not offer fix-it hints when multiple declarations disagree. Warnings are still given. - Once a definition is found, offer a fix-it hint to all previous declarations with wrong tag. - Declarations that disagree with a previous definition will get a fix-it hint to change the declaration. llvm-svn: 132831
* Diagnose the condition in C++ [temp.expl.spec]p16 that prohibitsDouglas Gregor2011-06-061-0/+37
| | | | | | | specializing a member of an unspecialized template, and recover from such errors without crashing. Fixes PR10024 / <rdar://problem/9509761>. llvm-svn: 132677
* Revert r132544. Accidental commit. I got confused with the Tortoise SVN menu.Francois Pichet2011-06-031-2/+0
| | | | llvm-svn: 132546
* (no commit message)Francois Pichet2011-06-031-0/+2
| | | | llvm-svn: 132544
* When checking the instantiation of a default template argument againstDouglas Gregor2011-06-031-9/+14
| | | | | | | | | | | | | | | the template parameter, perform the checking as a "specified" template argument rather than a "deduced" template argument; the latter implies stricter type checking that is not permitted for default template arguments. Also, cleanup our handling of substitution of explicit template arguments for a function template. We were actually performing some substitution of default arguments at this point! Fixes PR10069. llvm-svn: 132529
* Fix an incorrect warning about explicit template specializations forDouglas Gregor2011-06-011-1/+1
| | | | | | nested types, from Michael Han! llvm-svn: 132431
* Objective-C doesn't consider the use of incomplete types as methodDouglas Gregor2011-05-271-0/+10
| | | | | | | | | | | | | | parameter types to be ill-formed. However, it relies on the completeness of method parameter types when producing metadata, e.g., for a protocol, leading IR generating to crash in such cases. Since there's no real way to tighten down the semantics of Objective-C here without breaking existing code, do something safe but lame: suppress the generation of metadata when this happens. Fixes <rdar://problem/9123036>. llvm-svn: 132171
* Implement a new type node, UnaryTransformType, designed to represent aAlexis Hunt2011-05-241-0/+5
| | | | | | | | type that turns one type into another. This is used as the basis to implement __underlying_type properly - with TypeSourceInfo and proper behavior in the face of templates. llvm-svn: 132017
* Audit and finish the implementation of C++0x nullptr, fixing twoDouglas Gregor2011-05-211-5/+17
| | | | | | | | | | | | | | minor issues along the way: - Non-type template parameters of type 'std::nullptr_t' were not permitted. - We didn't properly introduce built-in operators for nullptr ==, !=, <, <=, >=, or > as candidate functions . To my knowledge, there's only one (minor but annoying) part of nullptr that hasn't been implemented: catching a thrown 'nullptr' as a pointer or pointer-to-member, per C++0x [except.handle]p4. llvm-svn: 131813
* Diagnose the presence of storage-class-specifiers on explicitDouglas Gregor2011-05-211-3/+13
| | | | | | instantiations and specializations. Fixes <rdar://problem/9126453> and PR8700. llvm-svn: 131802
* Introduce Type::isSignedIntegerOrEnumerationType() andDouglas Gregor2011-05-201-4/+4
| | | | | | | | | | | | | Type::isUnsignedIntegerOrEnumerationType(), which are like Type::isSignedIntegerType() and Type::isUnsignedIntegerType() but also consider the underlying type of a C++0x scoped enumeration type. Audited all callers to the existing functions, switching those that need to also handle scoped enumeration types (e.g., those that deal with constant values) over to the new functions. Fixes PR9923 / <rdar://problem/9447851>. llvm-svn: 131735
* When checking a set of template parameter lists against aDouglas Gregor2011-05-151-2/+7
| | | | | | | | | nested-name-specifier, re-evaluate the nested-name-specifier as if we were entering that context (which we did!), so that we'll resolve a template-id to a particular class template partial specialization. Fixes PR9913. llvm-svn: 131383
* Revert 131347. It asserts if the specialization in within a class template:Francois Pichet2011-05-141-6/+3
| | | | | | | | | | | | template<class U> struct X1 { template<class T> void f(T*); template<> void f(int*) { } }; Won't be so simple. I need to think more about it. llvm-svn: 131362
* In Microsoft mode, allow template function explicit specialization at class ↵Francois Pichet2011-05-141-3/+6
| | | | | | | | | | | | | | scope. Necessary to parse MFC and MSVC standard lib code. Example: struct X { template<class T> void f(T) { } template<> void f(int) { } } llvm-svn: 131347
* PR9908: Fix the broken fix for PR9902 to get the template argument lists in ↵Richard Smith2011-05-141-1/+1
| | | | | | | | the right order. Also, don't reject alias templates in all ElaboratedTypes: some ElaboratedTypes do not correspond to elaborated-type-specifiers. llvm-svn: 131342
* Teach the template parameter dependency checker used when matchingDouglas Gregor2011-05-131-0/+4
| | | | | | | | template parameter lists to scope specifiers for friend declarations about injected class name types. Fixes the g++.dg/template/memfriend5.C regression in the GCC testsuite. llvm-svn: 131272
* Fix PR9902: correctly substitute alias templates within the template in ↵Richard Smith2011-05-121-0/+3
| | | | | | which they are defined: provide an empty list of arguments for each containing template context during substitution. llvm-svn: 131211
* When checking for the necessary 'template<>' headers based on theDouglas Gregor2011-05-111-4/+10
| | | | | | | | | | nested of an out-of-line declaration, only require a 'template<>' header for each enclosing class template that hasn't been previously specialized; previously, we were requiring 'template<>' for enclosing class templates and members of class templates that hadn't been previously specialized. Fixes <rdar://problem/9422013>. llvm-svn: 131207
* Reimplement Sema::MatchTemplateParametersToScopeSpecifier() based onDouglas Gregor2011-05-101-147/+273
| | | | | | | | | | | | | | | | | | the semantic context referenced by the nested-name-specifier rather than the syntactic form of the nested-name-specifier. The previous incarnation was based on my complete misunderstanding of C++ [temp.expl.spec]. The latest C++0x working draft clarifies the requirements here, and this rewrite is intended to follow that. Along the way, improve source location information in the diagnostics. For example, if we report that a specific type needs or doesn't need a 'template<>' header, we dig out that type in the nested-name-specifier and highlight its range. Fixes: PR5907, PR9421, PR8277, PR8708, PR9482, PR9668, PR9877, and <rdar://problem/9135379>. llvm-svn: 131138
* Implement support for C++0x alias templates.Richard Smith2011-05-051-19/+65
| | | | llvm-svn: 130953
* When converting an integral template argument value to a non-typeDouglas Gregor2011-05-041-15/+22
| | | | | | | template parameter of type 'bool', force the value to be zero or one. Fixes <rdar://problem/9169404>. llvm-svn: 130873
OpenPOWER on IntegriCloud