[clang] [Clang] [NFC] Tablegen component diags headers (PR #134777)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 7 20:56:30 PDT 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 HEAD~1 HEAD --extensions h,cpp -- clang/include/clang/Basic/DiagnosticAST.h clang/include/clang/Basic/DiagnosticAnalysis.h clang/include/clang/Basic/DiagnosticComment.h clang/include/clang/Basic/DiagnosticCrossTU.h clang/include/clang/Basic/DiagnosticDriver.h clang/include/clang/Basic/DiagnosticFrontend.h clang/include/clang/Basic/DiagnosticIDs.h clang/include/clang/Basic/DiagnosticInstallAPI.h clang/include/clang/Basic/DiagnosticLex.h clang/include/clang/Basic/DiagnosticParse.h clang/include/clang/Basic/DiagnosticRefactoring.h clang/include/clang/Basic/DiagnosticSema.h clang/include/clang/Basic/DiagnosticSerialization.h clang/utils/TableGen/ClangDiagnosticsEmitter.cpp clang/utils/TableGen/TableGen.cpp clang/utils/TableGen/TableGenBackends.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/Basic/DiagnosticIDs.h b/clang/include/clang/Basic/DiagnosticIDs.h
index 80d52a0d0..83891ff11 100644
--- a/clang/include/clang/Basic/DiagnosticIDs.h
+++ b/clang/include/clang/Basic/DiagnosticIDs.h
@@ -92,83 +92,86 @@ namespace clang {
Remark ///< A diagnostic that indicates normal progress through
///< compilation.
};
- } // end namespace diag
-} // end namespace clang
+ } // end namespace diag
+ } // end namespace clang
-// This has to be included *after* the DIAG_START_ enums above are defined.
+ // This has to be included *after* the DIAG_START_ enums above are defined.
#include "clang/Basic/DiagnosticCommonInterface.inc"
-namespace clang {
-class DiagnosticMapping {
- LLVM_PREFERRED_TYPE(diag::Severity)
- unsigned Severity : 3;
- LLVM_PREFERRED_TYPE(bool)
- unsigned IsUser : 1;
- LLVM_PREFERRED_TYPE(bool)
- unsigned IsPragma : 1;
- LLVM_PREFERRED_TYPE(bool)
- unsigned HasNoWarningAsError : 1;
- LLVM_PREFERRED_TYPE(bool)
- unsigned HasNoErrorAsFatal : 1;
- LLVM_PREFERRED_TYPE(bool)
- unsigned WasUpgradedFromWarning : 1;
-
-public:
- static DiagnosticMapping Make(diag::Severity Severity, bool IsUser,
- bool IsPragma) {
- DiagnosticMapping Result;
- Result.Severity = (unsigned)Severity;
- Result.IsUser = IsUser;
- Result.IsPragma = IsPragma;
- Result.HasNoWarningAsError = 0;
- Result.HasNoErrorAsFatal = 0;
- Result.WasUpgradedFromWarning = 0;
- return Result;
- }
+ namespace clang {
+ class DiagnosticMapping {
+ LLVM_PREFERRED_TYPE(diag::Severity)
+ unsigned Severity : 3;
+ LLVM_PREFERRED_TYPE(bool)
+ unsigned IsUser : 1;
+ LLVM_PREFERRED_TYPE(bool)
+ unsigned IsPragma : 1;
+ LLVM_PREFERRED_TYPE(bool)
+ unsigned HasNoWarningAsError : 1;
+ LLVM_PREFERRED_TYPE(bool)
+ unsigned HasNoErrorAsFatal : 1;
+ LLVM_PREFERRED_TYPE(bool)
+ unsigned WasUpgradedFromWarning : 1;
+
+ public:
+ static DiagnosticMapping Make(diag::Severity Severity, bool IsUser,
+ bool IsPragma) {
+ DiagnosticMapping Result;
+ Result.Severity = (unsigned)Severity;
+ Result.IsUser = IsUser;
+ Result.IsPragma = IsPragma;
+ Result.HasNoWarningAsError = 0;
+ Result.HasNoErrorAsFatal = 0;
+ Result.WasUpgradedFromWarning = 0;
+ return Result;
+ }
- diag::Severity getSeverity() const { return (diag::Severity)Severity; }
- void setSeverity(diag::Severity Value) { Severity = (unsigned)Value; }
+ diag::Severity getSeverity() const { return (diag::Severity)Severity; }
+ void setSeverity(diag::Severity Value) { Severity = (unsigned)Value; }
- bool isUser() const { return IsUser; }
- bool isPragma() const { return IsPragma; }
+ bool isUser() const { return IsUser; }
+ bool isPragma() const { return IsPragma; }
- bool isErrorOrFatal() const {
- return getSeverity() == diag::Severity::Error ||
- getSeverity() == diag::Severity::Fatal;
- }
+ bool isErrorOrFatal() const {
+ return getSeverity() == diag::Severity::Error ||
+ getSeverity() == diag::Severity::Fatal;
+ }
- bool hasNoWarningAsError() const { return HasNoWarningAsError; }
- void setNoWarningAsError(bool Value) { HasNoWarningAsError = Value; }
+ bool hasNoWarningAsError() const { return HasNoWarningAsError; }
+ void setNoWarningAsError(bool Value) { HasNoWarningAsError = Value; }
- bool hasNoErrorAsFatal() const { return HasNoErrorAsFatal; }
- void setNoErrorAsFatal(bool Value) { HasNoErrorAsFatal = Value; }
+ bool hasNoErrorAsFatal() const { return HasNoErrorAsFatal; }
+ void setNoErrorAsFatal(bool Value) { HasNoErrorAsFatal = Value; }
- /// Whether this mapping attempted to map the diagnostic to a warning, but
- /// was overruled because the diagnostic was already mapped to an error or
- /// fatal error.
- bool wasUpgradedFromWarning() const { return WasUpgradedFromWarning; }
- void setUpgradedFromWarning(bool Value) { WasUpgradedFromWarning = Value; }
+ /// Whether this mapping attempted to map the diagnostic to a warning, but
+ /// was overruled because the diagnostic was already mapped to an error or
+ /// fatal error.
+ bool wasUpgradedFromWarning() const { return WasUpgradedFromWarning; }
+ void setUpgradedFromWarning(bool Value) {
+ WasUpgradedFromWarning = Value;
+ }
- /// Serialize this mapping as a raw integer.
- unsigned serialize() const {
- return (IsUser << 7) | (IsPragma << 6) | (HasNoWarningAsError << 5) |
- (HasNoErrorAsFatal << 4) | (WasUpgradedFromWarning << 3) | Severity;
- }
- /// Deserialize a mapping.
- static DiagnosticMapping deserialize(unsigned Bits) {
- DiagnosticMapping Result;
- Result.IsUser = (Bits >> 7) & 1;
- Result.IsPragma = (Bits >> 6) & 1;
- Result.HasNoWarningAsError = (Bits >> 5) & 1;
- Result.HasNoErrorAsFatal = (Bits >> 4) & 1;
- Result.WasUpgradedFromWarning = (Bits >> 3) & 1;
- Result.Severity = Bits & 0x7;
- return Result;
- }
+ /// Serialize this mapping as a raw integer.
+ unsigned serialize() const {
+ return (IsUser << 7) | (IsPragma << 6) | (HasNoWarningAsError << 5) |
+ (HasNoErrorAsFatal << 4) | (WasUpgradedFromWarning << 3) |
+ Severity;
+ }
+ /// Deserialize a mapping.
+ static DiagnosticMapping deserialize(unsigned Bits) {
+ DiagnosticMapping Result;
+ Result.IsUser = (Bits >> 7) & 1;
+ Result.IsPragma = (Bits >> 6) & 1;
+ Result.HasNoWarningAsError = (Bits >> 5) & 1;
+ Result.HasNoErrorAsFatal = (Bits >> 4) & 1;
+ Result.WasUpgradedFromWarning = (Bits >> 3) & 1;
+ Result.Severity = Bits & 0x7;
+ return Result;
+ }
- bool operator==(DiagnosticMapping Other) const {
- return serialize() == Other.serialize();
- }
+ bool operator==(DiagnosticMapping Other) const {
+ return serialize() == Other.serialize();
+ }
};
/// Used for handling and querying diagnostic IDs.
@@ -502,6 +505,6 @@ private:
friend class DiagnosticsEngine;
};
-} // end namespace clang
+} // end namespace clang
#endif
``````````
</details>
https://github.com/llvm/llvm-project/pull/134777
More information about the cfe-commits
mailing list