Skip to content

Commit cc23d36

Browse files
committed
StaticAnalyzer fixes for clang 21
1 parent e54f1b8 commit cc23d36

File tree

3 files changed

+41
-9
lines changed

3 files changed

+41
-9
lines changed

TauAnalysis/MCEmbeddingTools/plugins/MuonDetCleaner.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ uint32_t MuonDetCleaner<RPCDetId, RPCRecHit>::getRawDetId(const RPCRecHit &recHi
256256

257257
template <typename T1, typename T2>
258258
bool MuonDetCleaner<T1, T2>::checkrecHit(const TrackingRecHit &recHit) {
259-
edm::LogError("TauEmbedding") << "!!!! Please add the checkrecHit for the individual class templates " assert(0);
259+
edm::LogError("TauEmbedding") << "!!!! Please add the checkrecHit for the individual class templates ";
260+
assert(0);
260261
}
261262

262263
template <>
@@ -335,4 +336,4 @@ DEFINE_FWK_MODULE(CSCRecHitColCleaner);
335336
DEFINE_FWK_MODULE(DTRecHitColCleaner);
336337
DEFINE_FWK_MODULE(RPCRecHitColCleaner);
337338
DEFINE_FWK_MODULE(CSCSegmentColCleaner);
338-
DEFINE_FWK_MODULE(DTRecSegment4DColCleaner);
339+
DEFINE_FWK_MODULE(DTRecSegment4DColCleaner);

Utilities/StaticAnalyzers/src/CmsSupport.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ std::string clangcms::support::getQualifiedName(const clang::NamedDecl &d) {
5454
LangOpts.CPlusPlus = true;
5555
PrintingPolicy Policy(LangOpts);
5656
Policy.FullyQualifiedName = true;
57+
#if LLVM_VERSION_MAJOR >= 21
58+
Policy.PrintAsCanonical = true;
59+
#else
5760
Policy.PrintCanonicalTypes = true;
61+
#endif
5862
const DeclContext *ctx = d.getDeclContext();
5963
if (ctx->isFunctionOrMethod() && isa<NamedDecl>(ctx)) {
6064
// This is a local variable.
@@ -177,14 +181,21 @@ bool clangcms::support::isDataClass(const std::string &name) {
177181
const std::string tname("/src/Utilities/StaticAnalyzers/scripts/bloom.bin");
178182
const std::string fname1 = lname + tname;
179183
const std::string fname2 = rname + tname;
180-
if (!(FM.getFile(fname1) || FM.getFile(fname2))) {
184+
#if LLVM_VERSION_MAJOR >= 21
185+
auto FE1 = FM.getFileRef(fname1);
186+
auto FE2 = FM.getFileRef(fname2);
187+
#else
188+
auto FE1 = FM.getFile(fname1);
189+
auto FE2 = FM.getFile(fname2);
190+
#endif
191+
if (FE1) {
192+
iname = fname1;
193+
} else if (FE2) {
194+
iname = fname2;
195+
} else {
181196
llvm::errs() << "\n\nChecker cannot find bloom filter file" << fname1 << " or " << fname2 << "\n\n\n";
182197
exit(1);
183198
}
184-
if (FM.getFile(fname1))
185-
iname = fname1;
186-
else
187-
iname = fname2;
188199
}
189200

190201
CMS_SA_ALLOW static scaling_bloom_t *blmflt = new_scaling_bloom_from_file(CAPACITY, ERROR_RATE, iname.c_str());

Utilities/StaticAnalyzers/src/FunctionChecker.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ namespace clangcms {
107107
llvm::raw_string_ostream os(buf);
108108
os << "function '" << dname << "' accesses or modifies non-const static local variable '" << svname << "'.\n";
109109
BR.EmitBasicReport(D,
110+
#if LLVM_VERSION_MAJOR >= 21
111+
Checker->getName(),
112+
#else
110113
Checker->getCheckerName(),
114+
#endif
111115
"non-const static local variable accessed or modified",
112116
"ThreadSafety",
113117
os.str(),
@@ -123,7 +127,11 @@ namespace clangcms {
123127
os << "function '" << dname << "' accesses or modifies non-const static member data variable '" << svname
124128
<< "'.\n";
125129
BR.EmitBasicReport(D,
130+
#if LLVM_VERSION_MAJOR >= 21
131+
Checker->getName(),
132+
#else
126133
Checker->getCheckerName(),
134+
#endif
127135
"non-const static local variable accessed or modified",
128136
"ThreadSafety",
129137
os.str(),
@@ -138,7 +146,11 @@ namespace clangcms {
138146
llvm::raw_string_ostream os(buf);
139147
os << "function '" << dname << "' accesses or modifies non-const global static variable '" << svname << "'.\n";
140148
BR.EmitBasicReport(D,
149+
#if LLVM_VERSION_MAJOR >= 21
150+
Checker->getName(),
151+
#else
141152
Checker->getCheckerName(),
153+
#endif
142154
"non-const static local variable accessed or modified",
143155
"ThreadSafety",
144156
os.str(),
@@ -178,8 +190,16 @@ namespace clangcms {
178190
"'COMMONBLOCK'.\n";
179191
clang::ento::PathDiagnosticLocation FDLoc =
180192
clang::ento::PathDiagnosticLocation::createBegin(FD, BR.getSourceManager());
181-
BR.EmitBasicReport(
182-
FD, this->getCheckerName(), "COMMONBLOCK variable accessed or modified", "ThreadSafety", os.str(), FDLoc);
193+
BR.EmitBasicReport(FD,
194+
#if LLVM_VERSION_MAJOR >= 21
195+
this->getName(),
196+
#else
197+
this->getCheckerName(),
198+
#endif
199+
"COMMONBLOCK variable accessed or modified",
200+
"ThreadSafety",
201+
os.str(),
202+
FDLoc);
183203
std::string ostring = "function '" + dname + "' static variable 'COMMONBLOCK'.\n";
184204
std::string tname = "function-checker.txt.unsorted";
185205
support::writeLog(ostring, tname);

0 commit comments

Comments
 (0)