[clang] [verify] Improve the error messages with multiple active prefixes (PR #126068)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 6 05:50:23 PST 2025
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 39be2d0266f1aa229a79c47d81b004c8c2079362 105e5467662248ea2eb41edcfe0ce9a0cc97d044 --extensions cpp,c,h -- clang/test/Frontend/verify-mulptiple-prefixes.c clang/include/clang/Frontend/VerifyDiagnosticConsumer.h clang/lib/Frontend/VerifyDiagnosticConsumer.cpp clang/test/Frontend/verify.c clang/test/Frontend/verify3.c
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index 443f991e1a..6de19d6899 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -107,8 +107,9 @@ public:
class RegexDirective : public Directive {
public:
RegexDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
- StringRef Spelling, bool MatchAnyFileAndLine, bool MatchAnyLine,
- StringRef Text, unsigned Min, unsigned Max, StringRef RegexStr)
+ StringRef Spelling, bool MatchAnyFileAndLine,
+ bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max,
+ StringRef RegexStr)
: Directive(DirectiveLoc, DiagnosticLoc, Spelling, MatchAnyFileAndLine,
MatchAnyLine, Text, Min, Max),
Regex(RegexStr) {}
@@ -485,10 +486,12 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM,
continue;
if (NoDiag) {
- if (State.Status == VerifyDiagnosticConsumer::HasOtherExpectedDirectives) {
+ if (State.Status ==
+ VerifyDiagnosticConsumer::HasOtherExpectedDirectives) {
Diags.Report(Pos, diag::err_verify_invalid_no_diags)
<< D.Spelling << /*IsExpectedNoDiagnostics=*/true;
- } else if (State.Status != VerifyDiagnosticConsumer::HasExpectedNoDiagnostics) {
+ } else if (State.Status !=
+ VerifyDiagnosticConsumer::HasExpectedNoDiagnostics) {
State.Status = VerifyDiagnosticConsumer::HasExpectedNoDiagnostics;
State.FirstNoDiagnosticsDirective = D.Spelling;
}
@@ -862,8 +865,8 @@ static bool findDirectives(SourceManager &SM, FileID FID,
VerifyDiagnosticConsumer::MarkerTracker Markers(SM.getDiagnostics());
// Find first directive.
- if (ParseDirective(Comment, nullptr, SM, nullptr, Tok.getLocation(),
- State, Markers))
+ if (ParseDirective(Comment, nullptr, SM, nullptr, Tok.getLocation(), State,
+ Markers))
return true;
}
return false;
@@ -893,7 +896,8 @@ static unsigned PrintUnexpected(DiagnosticsEngine &Diags, SourceManager *SourceM
OS << ": " << I->second;
}
- const bool IsSinglePrefix = Diags.getDiagnosticOptions().VerifyPrefixes.size() == 1;
+ const bool IsSinglePrefix =
+ Diags.getDiagnosticOptions().VerifyPrefixes.size() == 1;
std::string Prefix = *Diags.getDiagnosticOptions().VerifyPrefixes.begin();
Diags.Report(diag::err_verify_inconsistent_diags).setForceEmit()
<< IsSinglePrefix << Prefix << Kind << /*Unexpected=*/true << OS.str();
@@ -1152,13 +1156,11 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() {
ED.Reset();
}
-std::unique_ptr<Directive> Directive::create(bool RegexKind,
- SourceLocation DirectiveLoc,
- SourceLocation DiagnosticLoc,
- StringRef Spelling,
- bool MatchAnyFileAndLine,
- bool MatchAnyLine, StringRef Text,
- unsigned Min, unsigned Max) {
+std::unique_ptr<Directive>
+Directive::create(bool RegexKind, SourceLocation DirectiveLoc,
+ SourceLocation DiagnosticLoc, StringRef Spelling,
+ bool MatchAnyFileAndLine, bool MatchAnyLine, StringRef Text,
+ unsigned Min, unsigned Max) {
if (!RegexKind)
return std::make_unique<StandardDirective>(DirectiveLoc, DiagnosticLoc,
Spelling, MatchAnyFileAndLine,
``````````
</details>
https://github.com/llvm/llvm-project/pull/126068
More information about the cfe-commits
mailing list