[llvm] [IR] Add Attribute::getValueAsParsedInteger helper (PR #194713)

JP Hafer via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 29 07:09:07 PDT 2026


================
@@ -409,6 +409,14 @@ StringRef Attribute::getValueAsString() const {
   return pImpl->getValueAsString();
 }
 
+uint64_t Attribute::getValueAsParsedInteger(uint64_t Default) const {
+  if (!isStringAttribute())
+    return Default;
+  uint64_t Result = Default;
+  getValueAsString().getAsInteger(0, Result);
----------------
jph-13 wrote:

`Attribute` doesn't carry an `LLVMContext`, so as I understand it, it can't emit diagnostics like the `Function` version. The callers here are post-verifier merge functions, thus the silent-default semantics — but happy to change the design if you'd prefer something stricter.

https://github.com/llvm/llvm-project/pull/194713


More information about the llvm-commits mailing list