From: Benjamin Kramer Date: Tue, 6 Mar 2012 18:07:25 +0000 (+0000) Subject: NamespaceDecl: Call non-virtual method inside virtual method, not the other way round. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=81e722e2c1195a90825ceaaa90f4a14b7df09b41;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152124 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 25b6d79804..8715067ce6 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -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 {