]> granicus.if.org Git - clang/commitdiff
[AST] hasAttr followed by getAttr isn't efficient
authorDavid Majnemer <david.majnemer@gmail.com>
Thu, 14 May 2015 05:19:20 +0000 (05:19 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Thu, 14 May 2015 05:19:20 +0000 (05:19 +0000)
Just use getAttr because we are interested in the attribute's contents.

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

lib/AST/Decl.cpp

index 173e22f06961d1f0cd7124f6cbc1f288bbe7f13d..5d5ef96cfd25c4c2b69c9139d424549089260367 100644 (file)
@@ -1915,10 +1915,13 @@ VarDecl::isThisDeclarationADefinition(ASTContext &C) const {
   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.