[cfe-commits] r152124 - /cfe/trunk/include/clang/AST/Decl.h

Benjamin Kramer benny.kra at googlemail.com
Tue Mar 6 10:07:25 PST 2012


Author: d0k
Date: Tue Mar  6 12:07:25 2012
New Revision: 152124

URL: http://llvm.org/viewvc/llvm-project?rev=152124&view=rev
Log:
NamespaceDecl: Call non-virtual method inside virtual method, not the other way round.

Moves the virtual call out of a hot path during lookup, no other functionality change.

Modified:
    cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=152124&r1=152123&r2=152124&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Mar  6 12:07:25 2012
@@ -451,12 +451,18 @@
 
   /// \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 @@
 
   /// 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 {





More information about the cfe-commits mailing list