diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-02-17 17:39:40 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-02-17 17:39:40 +0000 |
commit | afdfdc05fe8b2442713f0150a5985a9c6d852cee (patch) | |
tree | 08ad36bd1d1452d83caefa4accdd4a9f183c6df3 | |
parent | 2a96bf5e66731bb54dff3e4aadfbbced83377530 (diff) |
Devirtualize DeclaratorDecl::getInnerLocStart() and TagDecl::getInnerLocStart().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125754 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/Decl.h | 5 | ||||
-rw-r--r-- | include/clang/AST/DeclTemplate.h | 3 | ||||
-rw-r--r-- | lib/AST/Decl.cpp | 32 | ||||
-rw-r--r-- | lib/AST/DeclTemplate.cpp | 7 |
4 files changed, 27 insertions, 20 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index ba7699e1a6..32706d6c90 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -538,7 +538,7 @@ public: /// getInnerLocStart - Return SourceLocation representing start of source /// range ignoring outer template declarations. - virtual SourceLocation getInnerLocStart() const { return getLocation(); } + SourceLocation getInnerLocStart() const; /// getOuterLocStart - Return SourceLocation representing start of source /// range taking into account any outer template declarations. @@ -686,7 +686,6 @@ public: QualType T, TypeSourceInfo *TInfo, StorageClass S, StorageClass SCAsWritten); - virtual SourceLocation getInnerLocStart() const; SourceRange getSourceRange() const; StorageClass getStorageClass() const { return (StorageClass)SClass; } @@ -2065,7 +2064,7 @@ public: /// getInnerLocStart - Return SourceLocation representing start of source /// range ignoring outer template declarations. - virtual SourceLocation getInnerLocStart() const { return TagKeywordLoc; } + SourceLocation getInnerLocStart() const; /// getOuterLocStart - Return SourceLocation representing start of source /// range taking into account any outer template declarations. diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index 28a40fbbb4..573dd47274 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -1041,7 +1041,6 @@ public: using TemplateParmPosition::setPosition; using TemplateParmPosition::getIndex; - SourceLocation getInnerLocStart() const; SourceRange getSourceRange() const; /// \brief Determine whether this template parameter has a default @@ -1468,8 +1467,6 @@ public: return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation(); } - SourceLocation getInnerLocStart() const { return getTemplateKeywordLoc(); } - void Profile(llvm::FoldingSetNodeID &ID) const { Profile(ID, TemplateArgs->data(), TemplateArgs->size(), getASTContext()); } diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 0b07d13cba..8c55d0e7ab 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -969,6 +969,20 @@ void DeclaratorDecl::setQualifierInfo(NestedNameSpecifier *Qualifier, } } +SourceLocation DeclaratorDecl::getInnerLocStart() const { + if (const VarDecl *Var = dyn_cast<VarDecl>(this)) { + SourceLocation Start = Var->getTypeSpecStartLoc(); + if (Start.isValid()) + return Start; + } else if (const NonTypeTemplateParmDecl *NTTP + = dyn_cast<NonTypeTemplateParmDecl>(this)) { + SourceLocation Start = NTTP->getTypeSpecStartLoc(); + if (Start.isValid()) + return Start; + } + return getLocation(); +} + SourceLocation DeclaratorDecl::getOuterLocStart() const { return getTemplateOrInnerLocStart(this); } @@ -1029,13 +1043,6 @@ void VarDecl::setStorageClass(StorageClass SC) { SClass = SC; } -SourceLocation VarDecl::getInnerLocStart() const { - SourceLocation Start = getTypeSpecStartLoc(); - if (Start.isInvalid()) - Start = getLocation(); - return Start; -} - SourceRange VarDecl::getSourceRange() const { if (getInit()) return SourceRange(getOuterLocStart(), getInit()->getLocEnd()); @@ -1959,6 +1966,17 @@ unsigned FieldDecl::getFieldIndex() const { // TagDecl Implementation //===----------------------------------------------------------------------===// +SourceLocation TagDecl::getInnerLocStart() const { + if (const ClassTemplateSpecializationDecl *Spec + = dyn_cast<ClassTemplateSpecializationDecl>(this)) { + SourceLocation Start = Spec->getTemplateKeywordLoc(); + if (Start.isValid()) + return Start; + } + + return getTagKeywordLoc(); +} + SourceLocation TagDecl::getOuterLocStart() const { return getTemplateOrInnerLocStart(this); } diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp index 2aa446bcd3..980a373778 100644 --- a/lib/AST/DeclTemplate.cpp +++ b/lib/AST/DeclTemplate.cpp @@ -455,13 +455,6 @@ NonTypeTemplateParmDecl::Create(const ASTContext &C, DeclContext *DC, ExpandedTInfos); } -SourceLocation NonTypeTemplateParmDecl::getInnerLocStart() const { - SourceLocation Start = getTypeSpecStartLoc(); - if (Start.isInvalid()) - Start = getLocation(); - return Start; -} - SourceRange NonTypeTemplateParmDecl::getSourceRange() const { return SourceRange(getOuterLocStart(), getLocation()); } |