Devirtualize DeclaratorDecl::getInnerLocStart() and TagDecl::getInnerLocStart().
llvm-svn: 125754
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 0b07d13..8c55d0e 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -969,6 +969,20 @@
}
}
+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 @@
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 @@
// 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);
}