[cfe-commits] r125754 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/AST/DeclTemplate.h lib/AST/Decl.cpp lib/AST/DeclTemplate.cpp
Douglas Gregor
dgregor at apple.com
Thu Feb 17 09:39:40 PST 2011
Author: dgregor
Date: Thu Feb 17 11:39:40 2011
New Revision: 125754
URL: http://llvm.org/viewvc/llvm-project?rev=125754&view=rev
Log:
Devirtualize DeclaratorDecl::getInnerLocStart() and TagDecl::getInnerLocStart().
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=125754&r1=125753&r2=125754&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu Feb 17 11:39:40 2011
@@ -538,7 +538,7 @@
/// 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 @@
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 @@
/// 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.
Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=125754&r1=125753&r2=125754&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Thu Feb 17 11:39:40 2011
@@ -1041,7 +1041,6 @@
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 @@
return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation();
}
- SourceLocation getInnerLocStart() const { return getTemplateKeywordLoc(); }
-
void Profile(llvm::FoldingSetNodeID &ID) const {
Profile(ID, TemplateArgs->data(), TemplateArgs->size(), getASTContext());
}
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=125754&r1=125753&r2=125754&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Feb 17 11:39:40 2011
@@ -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);
}
Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=125754&r1=125753&r2=125754&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Thu Feb 17 11:39:40 2011
@@ -455,13 +455,6 @@
ExpandedTInfos);
}
-SourceLocation NonTypeTemplateParmDecl::getInnerLocStart() const {
- SourceLocation Start = getTypeSpecStartLoc();
- if (Start.isInvalid())
- Start = getLocation();
- return Start;
-}
-
SourceRange NonTypeTemplateParmDecl::getSourceRange() const {
return SourceRange(getOuterLocStart(), getLocation());
}
More information about the cfe-commits
mailing list