r237336 - [AST] hasAttr followed by getAttr isn't efficient

David Majnemer david.majnemer at gmail.com
Wed May 13 22:19:21 PDT 2015


Author: majnemer
Date: Thu May 14 00:19:20 2015
New Revision: 237336

URL: http://llvm.org/viewvc/llvm-project?rev=237336&view=rev
Log:
[AST] hasAttr followed by getAttr isn't efficient

Just use getAttr because we are interested in the attribute's contents.

Modified:
    cfe/trunk/lib/AST/Decl.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=237336&r1=237335&r2=237336&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu May 14 00:19:20 2015
@@ -1915,10 +1915,13 @@ VarDecl::isThisDeclarationADefinition(AS
   if (hasInit())
     return Definition;
 
-  if (hasAttr<AliasAttr>() ||
-      (hasAttr<SelectAnyAttr>() && !getAttr<SelectAnyAttr>()->isInherited()))
+  if (hasAttr<AliasAttr>())
     return Definition;
 
+  if (const auto *SAA = getAttr<SelectAnyAttr>())
+    if (!SAA->isInherited())
+      return Definition;
+
   // A variable template specialization (other than a static data member
   // template or an explicit specialization) is a declaration until we
   // instantiate its initializer.





More information about the cfe-commits mailing list