aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Parse/DeclSpec.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-25 21:45:23 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-25 21:45:23 +0000
commitdb422dffb720ff41d0b60e228f45c685600ffa9e (patch)
tree347abefb53d70d332ac3bdf0fe1097a4c69137a0 /include/clang/Parse/DeclSpec.h
parent699a07d8a0b1579c5178b3baf4bcf9edb6b38108 (diff)
Declarators can now properly represent template-ids, e.g., for
template void f<int>(int); ~~~~~~ Previously, we silently dropped the template arguments. With this change, we now use the template arguments (when available) as the explicitly-specified template arguments used to aid template argument deduction for explicit template instantiations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82806 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Parse/DeclSpec.h')
-rw-r--r--include/clang/Parse/DeclSpec.h38
1 files changed, 35 insertions, 3 deletions
diff --git a/include/clang/Parse/DeclSpec.h b/include/clang/Parse/DeclSpec.h
index b7d90e477e..7ecbf7db7b 100644
--- a/include/clang/Parse/DeclSpec.h
+++ b/include/clang/Parse/DeclSpec.h
@@ -794,8 +794,10 @@ public:
DK_Constructor, // A C++ constructor (identifier is the class name)
DK_Destructor, // A C++ destructor (identifier is ~class name)
DK_Operator, // A C++ overloaded operator name
- DK_Conversion // A C++ conversion function (identifier is
+ DK_Conversion, // A C++ conversion function (identifier is
// "operator " then the type name)
+ DK_TemplateId // A C++ template-id naming a function template
+ // specialization.
};
private:
@@ -839,6 +841,10 @@ private:
/// When Kind is DK_Operator, this is the actual overloaded
/// operator that this declarator names.
OverloadedOperatorKind OperatorKind;
+
+ /// When Kind is DK_TemplateId, this is the template-id annotation that
+ /// contains the template and its template arguments.
+ TemplateIdAnnotation *TemplateId;
};
/// InlineParams - This is a local array used for the first function decl
@@ -916,6 +922,10 @@ public:
Identifier = 0;
IdentifierLoc = SourceLocation();
Range = DS.getSourceRange();
+
+ if (Kind == DK_TemplateId)
+ TemplateId->Destroy();
+
Kind = DK_Abstract;
for (unsigned i = 0, e = DeclTypeInfo.size(); i != e; ++i)
@@ -1023,6 +1033,16 @@ public:
SetRangeEnd(EndLoc);
}
+ /// \brief Set this declaration to be a C++ template-id, which includes the
+ /// template (or set of function templates) along with template arguments.
+ void setTemplateId(TemplateIdAnnotation *TemplateId) {
+ assert(TemplateId && "NULL template-id provided to declarator?");
+ IdentifierLoc = TemplateId->TemplateNameLoc;
+ Kind = DK_TemplateId;
+ SetRangeEnd(TemplateId->RAngleLoc);
+ this->TemplateId = TemplateId;
+ }
+
/// AddTypeInfo - Add a chunk to this declarator. Also extend the range to
/// EndLoc, which should be the last token of the chunk.
void AddTypeInfo(const DeclaratorChunk &TI, SourceLocation EndLoc) {
@@ -1085,10 +1105,22 @@ public:
void setExtension(bool Val = true) { Extension = Val; }
bool getExtension() const { return Extension; }
- ActionBase::TypeTy *getDeclaratorIdType() const { return Type; }
+ ActionBase::TypeTy *getDeclaratorIdType() const {
+ assert((Kind == DK_Constructor || Kind == DK_Destructor ||
+ Kind == DK_Conversion) && "Declarator kind does not have a type");
+ return Type;
+ }
- OverloadedOperatorKind getOverloadedOperator() const { return OperatorKind; }
+ OverloadedOperatorKind getOverloadedOperator() const {
+ assert(Kind == DK_Operator && "Declarator is not an overloaded operator");
+ return OperatorKind;
+ }
+ TemplateIdAnnotation *getTemplateId() {
+ assert(Kind == DK_TemplateId && "Declarator is not a template-id");
+ return TemplateId;
+ }
+
void setInvalidType(bool Val = true) { InvalidType = Val; }
bool isInvalidType() const {
return InvalidType || DS.getTypeSpecType() == DeclSpec::TST_error;