Skip to content

Commit f3ccd5c

Browse files
committed
Revert "Warn on RequiresCapability attribute mismatch"
This reverts commit 5f41173.
1 parent 1c11725 commit f3ccd5c

File tree

4 files changed

+1
-48
lines changed

4 files changed

+1
-48
lines changed

clang/include/clang/Analysis/Analyses/ThreadSafety.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ namespace clang {
2626
class AnalysisDeclContext;
2727
class FunctionDecl;
2828
class NamedDecl;
29-
class Attr;
3029

3130
namespace threadSafety {
3231

@@ -231,9 +230,6 @@ class ThreadSafetyHandler {
231230
/// Warn that there is a cycle in acquired_before/after dependencies.
232231
virtual void handleBeforeAfterCycle(Name L1Name, SourceLocation Loc) {}
233232

234-
virtual void handleAttributeMismatch(const FunctionDecl *FD1,
235-
const FunctionDecl *FD2) {}
236-
237233
/// Called by the analysis when starting analysis of a function.
238234
/// Used to issue suggestions for changes to annotations.
239235
virtual void enterFunction(const FunctionDecl *FD) {}

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4031,9 +4031,7 @@ def warn_acquired_before : Warning<
40314031
def warn_acquired_before_after_cycle : Warning<
40324032
"cycle in acquired_before/after dependencies, starting with '%0'">,
40334033
InGroup<ThreadSafetyAnalysis>, DefaultIgnore;
4034-
def warn_attribute_mismatch : Warning<
4035-
"attribute mismatch between function definition and declaration of %0">,
4036-
InGroup<ThreadSafetyAnalysis>, DefaultIgnore;
4034+
40374035

40384036
// Thread safety warnings negative capabilities
40394037
def warn_acquire_requires_negative_cap : Warning<

clang/lib/Analysis/ThreadSafety.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,37 +2263,6 @@ static bool neverReturns(const CFGBlock *B) {
22632263
return false;
22642264
}
22652265

2266-
template <typename AttrT>
2267-
static SmallVector<const Expr *> collectAttrArgs(const FunctionDecl *FD) {
2268-
SmallVector<const Expr *> Args;
2269-
for (const AttrT *A : FD->specific_attrs<AttrT>()) {
2270-
for (const Expr *E : A->args())
2271-
Args.push_back(E);
2272-
}
2273-
2274-
return Args;
2275-
}
2276-
2277-
static void diagnoseMismatchedFunctionAttrs(const FunctionDecl *FD,
2278-
ThreadSafetyHandler &Handler) {
2279-
assert(FD);
2280-
FD = FD->getDefinition();
2281-
assert(FD);
2282-
auto FDArgs = collectAttrArgs<RequiresCapabilityAttr>(FD);
2283-
2284-
for (const FunctionDecl *D = FD->getPreviousDecl(); D;
2285-
D = D->getPreviousDecl()) {
2286-
auto DArgs = collectAttrArgs<RequiresCapabilityAttr>(D);
2287-
2288-
for (const Expr *E : FDArgs) {
2289-
if (!llvm::is_contained(DArgs, E)) {
2290-
// FD requires E, but D doesn't.
2291-
Handler.handleAttributeMismatch(FD, D);
2292-
}
2293-
}
2294-
}
2295-
}
2296-
22972266
/// Check a function's CFG for thread-safety violations.
22982267
///
22992268
/// We traverse the blocks in the CFG, compute the set of mutexes that are held
@@ -2313,9 +2282,6 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
23132282
const NamedDecl *D = walker.getDecl();
23142283
CurrentFunction = dyn_cast<FunctionDecl>(D);
23152284

2316-
if (CurrentFunction)
2317-
diagnoseMismatchedFunctionAttrs(CurrentFunction, Handler);
2318-
23192285
if (D->hasAttr<NoThreadSafetyAnalysisAttr>())
23202286
return;
23212287

clang/lib/Sema/AnalysisBasedWarnings.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,13 +2073,6 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
20732073
Warnings.emplace_back(std::move(Warning), getNotes());
20742074
}
20752075

2076-
void handleAttributeMismatch(const FunctionDecl *FD1,
2077-
const FunctionDecl *FD2) override {
2078-
PartialDiagnosticAt Warning(FD2->getLocation(),
2079-
S.PDiag(diag::warn_attribute_mismatch) << FD1);
2080-
Warnings.emplace_back(std::move(Warning), getNotes());
2081-
}
2082-
20832076
void enterFunction(const FunctionDecl* FD) override {
20842077
CurrentFunction = FD;
20852078
}

0 commit comments

Comments
 (0)