summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-17 17:39:40 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-17 17:39:40 +0000
commitfe590dfa84c0b42836289dcce28d950dee230d8e (patch)
treea7e65016889a6d012d4dfb63da9b8be4d8f82cd4 /clang/lib
parent0f60574fd708ae310d221706a925d76e82679464 (diff)
downloadbcm5719-llvm-fe590dfa84c0b42836289dcce28d950dee230d8e.tar.gz
bcm5719-llvm-fe590dfa84c0b42836289dcce28d950dee230d8e.zip
Devirtualize DeclaratorDecl::getInnerLocStart() and TagDecl::getInnerLocStart().
llvm-svn: 125754
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/Decl.cpp32
-rw-r--r--clang/lib/AST/DeclTemplate.cpp7
2 files changed, 25 insertions, 14 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 0b07d13cba3..8c55d0e7abf 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/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/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 2aa446bcd31..980a373778f 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/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());
}
OpenPOWER on IntegriCloud