[llvm] [LLVM][Verifier] Improve diagnostic messages for Intrinsics in Verifier (PR #185641)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 10 06:04:38 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- llvm/include/llvm/IR/IntrinsicDiagnostics.h llvm/lib/IR/IntrinsicDiagnostics.cpp llvm/lib/IR/NVVMIntrinsicDiagnostics.cpp llvm/lib/AsmParser/LLParser.cpp llvm/lib/IR/Verifier.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index aa735abc4..d01047f58 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -358,8 +358,7 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
FunctionType *ExpFTy = nullptr;
if (!Intrinsic::isOverloaded(IID)) {
SmallVector<Type *, 4> OverloadTys;
- ExpFTy =
- Intrinsic::getType(M->getContext(), IID, OverloadTys);
+ ExpFTy = Intrinsic::getType(M->getContext(), IID, OverloadTys);
}
std::string Msg = "invalid intrinsic signature";
raw_string_ostream SS(Msg);
diff --git a/llvm/lib/IR/IntrinsicDiagnostics.cpp b/llvm/lib/IR/IntrinsicDiagnostics.cpp
index 1d374dd4e..f776e5e2b 100644
--- a/llvm/lib/IR/IntrinsicDiagnostics.cpp
+++ b/llvm/lib/IR/IntrinsicDiagnostics.cpp
@@ -21,9 +21,10 @@ void IntrinsicDiagnosticsProvider::registerProvider(
getProviders().push_back(P);
}
-void IntrinsicDiagnosticsProvider::querySignatureMismatch(
- StringRef IntrName, FunctionType *DeclFTy, FunctionType *CallFTy,
- raw_ostream &OS) {
+void IntrinsicDiagnosticsProvider::querySignatureMismatch(StringRef IntrName,
+ FunctionType *DeclFTy,
+ FunctionType *CallFTy,
+ raw_ostream &OS) {
for (auto *P : getProviders())
P->getSignatureMismatch(IntrName, DeclFTy, CallFTy, OS);
}
@@ -42,10 +43,9 @@ void IntrinsicDiagnosticsProvider::queryArgTypeMismatch(StringRef IntrName,
P->getArgTypeMismatch(IntrName, IFTy, OS);
}
-void IntrinsicDiagnosticsProvider::queryParserMismatch(StringRef IntrName,
- FunctionType *CallFTy,
- FunctionType *ExpectedFTy,
- raw_ostream &OS) {
+void IntrinsicDiagnosticsProvider::queryParserMismatch(
+ StringRef IntrName, FunctionType *CallFTy, FunctionType *ExpectedFTy,
+ raw_ostream &OS) {
for (auto *P : getProviders())
P->getParserMismatch(IntrName, CallFTy, ExpectedFTy, OS);
}
diff --git a/llvm/lib/IR/NVVMIntrinsicDiagnostics.cpp b/llvm/lib/IR/NVVMIntrinsicDiagnostics.cpp
index 6b68cb889..7d3a45ad6 100644
--- a/llvm/lib/IR/NVVMIntrinsicDiagnostics.cpp
+++ b/llvm/lib/IR/NVVMIntrinsicDiagnostics.cpp
@@ -48,8 +48,7 @@ public:
OS << ")";
} else if (DeclFTy->getNumParams() != CallFTy->getNumParams()) {
OS << "\nwrong number of arguments (expected " << DeclFTy->getNumParams()
- << ", got " << CallFTy->getNumParams()
- << "), expected signature: ";
+ << ", got " << CallFTy->getNumParams() << "), expected signature: ";
DeclFTy->print(OS);
OS << ", got signature: ";
CallFTy->print(OS);
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index ef6a129ad..d713c97a8 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -3871,8 +3871,8 @@ void Verifier::visitCallBase(CallBase &Call) {
if (DeclFTy != FTy) {
std::string Msg = "Intrinsic called with incompatible signature";
raw_string_ostream SS(Msg);
- IntrinsicDiagnosticsProvider::querySignatureMismatch(
- Callee->getName(), DeclFTy, FTy, SS);
+ IntrinsicDiagnosticsProvider::querySignatureMismatch(Callee->getName(),
+ DeclFTy, FTy, SS);
CheckFailed(Msg, Call);
return;
}
@@ -5867,16 +5867,15 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
if (Res == Intrinsic::MatchIntrinsicTypes_NoMatchRet) {
std::string Msg = "Intrinsic has incorrect return type!";
raw_string_ostream SS(Msg);
- IntrinsicDiagnosticsProvider::queryReturnTypeMismatch(
- IF->getName(), IFTy, SS);
+ IntrinsicDiagnosticsProvider::queryReturnTypeMismatch(IF->getName(), IFTy,
+ SS);
CheckFailed(Msg, IF);
return;
}
if (Res == Intrinsic::MatchIntrinsicTypes_NoMatchArg) {
std::string Msg = "Intrinsic has incorrect argument type!";
raw_string_ostream SS(Msg);
- IntrinsicDiagnosticsProvider::queryArgTypeMismatch(
- IF->getName(), IFTy, SS);
+ IntrinsicDiagnosticsProvider::queryArgTypeMismatch(IF->getName(), IFTy, SS);
CheckFailed(Msg, IF);
return;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/185641
More information about the llvm-commits
mailing list