]> granicus.if.org Git - clang/commitdiff
Devirtualize DeclaratorDecl::getInnerLocStart() and TagDecl::getInnerLocStart().
authorDouglas Gregor <dgregor@apple.com>
Thu, 17 Feb 2011 17:39:40 +0000 (17:39 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 17 Feb 2011 17:39:40 +0000 (17:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125754 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h
include/clang/AST/DeclTemplate.h
lib/AST/Decl.cpp
lib/AST/DeclTemplate.cpp

index ba7699e1a68820418ddf1d5194a8553decd66f0b..32706d6c9012647f52808c2ac262faece561e1fc 100644 (file)
@@ -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.
index 28a40fbbb466b4c6a01370c0d0afc1746250ddec..573dd47274c4db4307a37571b3e31842ab0c88ee 100644 (file)
@@ -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());
   }
index 0b07d13cba309509b3abefb6951368677c1f13b7..8c55d0e7abfafc47716c86ab76f356c5abf704fa 100644 (file)
@@ -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);
 }
index 2aa446bcd31cba30ba6b9dba9682503052ba109e..980a373778fec2e68330b35217d568b2955a42cc 100644 (file)
@@ -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());
 }