[clang] [clang] Warn on mismatched RequiresCapability attributes (PR #67520)
Aaron Puchert via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 12 09:08:09 PST 2024
================
@@ -2073,6 +2073,18 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
Warnings.emplace_back(std::move(Warning), getNotes());
}
+ void handleAttributeMismatch(const NamedDecl *ThisDecl,
+ const NamedDecl *PrevDecl) override {
+ PartialDiagnosticAt Warning(ThisDecl->getLocation(),
+ S.PDiag(diag::warn_attribute_mismatch)
+ << ThisDecl);
+ Warnings.emplace_back(std::move(Warning), getNotes());
+
+ PartialDiagnosticAt Note(PrevDecl->getLocation(),
+ S.PDiag(diag::note_previous_decl) << PrevDecl);
+ Warnings.emplace_back(std::move(Note), getNotes());
----------------
aaronpuchert wrote:
The problem is likely here. You shouldn't add the note as a warning, but as a note to the corresponding warning:
```suggestion
PartialDiagnosticAt Note(PrevDecl->getLocation(),
S.PDiag(diag::note_previous_decl) << PrevDecl);
Warnings.emplace_back(std::move(Warning), getNotes(Note));
```
https://github.com/llvm/llvm-project/pull/67520
More information about the cfe-commits
mailing list