]> granicus.if.org Git - clang/commitdiff
NamespaceDecl: Call non-virtual method inside virtual method, not the other way round.
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 6 Mar 2012 18:07:25 +0000 (18:07 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 6 Mar 2012 18:07:25 +0000 (18:07 +0000)
Moves the virtual call out of a hot path during lookup, no other functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152124 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h

index 25b6d7980459c1e962350c94e6039d1aae3d0a22..8715067ce659c6ea1c8acebcc4d05d33c3a97de1 100644 (file)
@@ -451,12 +451,18 @@ public:
 
   /// \brief Get the original (first) namespace declaration.
   NamespaceDecl *getOriginalNamespace() {
-    return getCanonicalDecl();
+    if (isFirstDeclaration())
+      return this;
+
+    return AnonOrFirstNamespaceAndInline.getPointer();
   }
 
   /// \brief Get the original (first) namespace declaration.
   const NamespaceDecl *getOriginalNamespace() const {
-    return getCanonicalDecl();
+    if (isFirstDeclaration())
+      return this;
+
+    return AnonOrFirstNamespaceAndInline.getPointer();
   }
 
   /// \brief Return true if this declaration is an original (first) declaration
@@ -478,16 +484,10 @@ public:
 
   /// Retrieves the canonical declaration of this namespace.
   NamespaceDecl *getCanonicalDecl() {
-    if (isFirstDeclaration())
-      return this;
-    
-    return AnonOrFirstNamespaceAndInline.getPointer();
+    return getOriginalNamespace();
   }
   const NamespaceDecl *getCanonicalDecl() const {
-    if (isFirstDeclaration())
-      return this;
-    
-    return AnonOrFirstNamespaceAndInline.getPointer();
+    return getOriginalNamespace();
   }
   
   virtual SourceRange getSourceRange() const {