[NFC] Add and use AttributeList::removeFnAttributes()
authorArthur Eubanks <aeubanks@google.com>
Tue, 24 Aug 2021 16:53:39 +0000 (09:53 -0700)
committerArthur Eubanks <aeubanks@google.com>
Tue, 24 Aug 2021 16:53:39 +0000 (09:53 -0700)
llvm/include/llvm/IR/Attributes.h
llvm/lib/AsmParser/LLParser.cpp

index d6237e3..0c77110 100644 (file)
@@ -594,6 +594,12 @@ public:
     return removeAttributes(C, FunctionIndex, AttrsToRemove);
   }
 
+  /// Remove the attributes at the function index from this
+  /// attribute list. Returns a new list because attribute lists are immutable.
+  LLVM_NODISCARD AttributeList removeFnAttributes(LLVMContext &C) const {
+    return removeAttributes(C, FunctionIndex);
+  }
+
   /// Remove the specified attribute at the return value index from this
   /// attribute list. Returns a new list because attribute lists are immutable.
   LLVM_NODISCARD AttributeList
index c24917c..d9af4ca 100644 (file)
@@ -141,7 +141,7 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
     if (Function *Fn = dyn_cast<Function>(V)) {
       AttributeList AS = Fn->getAttributes();
       AttrBuilder FnAttrs(AS.getFnAttrs());
-      AS = AS.removeAttributes(Context, AttributeList::FunctionIndex);
+      AS = AS.removeFnAttributes(Context);
 
       FnAttrs.merge(B);
 
@@ -157,21 +157,21 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
     } else if (CallInst *CI = dyn_cast<CallInst>(V)) {
       AttributeList AS = CI->getAttributes();
       AttrBuilder FnAttrs(AS.getFnAttrs());
-      AS = AS.removeAttributes(Context, AttributeList::FunctionIndex);
+      AS = AS.removeFnAttributes(Context);
       FnAttrs.merge(B);
       AS = AS.addFnAttributes(Context, AttributeSet::get(Context, FnAttrs));
       CI->setAttributes(AS);
     } else if (InvokeInst *II = dyn_cast<InvokeInst>(V)) {
       AttributeList AS = II->getAttributes();
       AttrBuilder FnAttrs(AS.getFnAttrs());
-      AS = AS.removeAttributes(Context, AttributeList::FunctionIndex);
+      AS = AS.removeFnAttributes(Context);
       FnAttrs.merge(B);
       AS = AS.addFnAttributes(Context, AttributeSet::get(Context, FnAttrs));
       II->setAttributes(AS);
     } else if (CallBrInst *CBI = dyn_cast<CallBrInst>(V)) {
       AttributeList AS = CBI->getAttributes();
       AttrBuilder FnAttrs(AS.getFnAttrs());
-      AS = AS.removeAttributes(Context, AttributeList::FunctionIndex);
+      AS = AS.removeFnAttributes(Context);
       FnAttrs.merge(B);
       AS = AS.addFnAttributes(Context, AttributeSet::get(Context, FnAttrs));
       CBI->setAttributes(AS);