CheckerInfoList Checkers;
llvm::StringMap<size_t> PackageSizes;
+ /// Contains all (Dependendent checker, Dependency) pairs. We need this, as
+ /// we'll resolve dependencies after all checkers were added first.
+ llvm::SmallVector<std::pair<StringRef, StringRef>, 0> Dependencies;
+
+ void resolveDependencies();
+
DiagnosticsEngine &Diags;
AnalyzerOptions &AnOpts;
const LangOptions &LangOpts;
#undef CHECKER_DEPENDENCY
#undef GET_CHECKER_DEPENDENCIES
+ resolveDependencies();
+
// Parse '-analyzer-checker' and '-analyzer-disable-checker' options from the
// command line.
for (const std::pair<std::string, bool> &Opt : AnOpts.CheckersControlList) {
}
}
-void CheckerRegistry::addDependency(StringRef FullName, StringRef Dependency) {
- auto CheckerIt = binaryFind(Checkers, FullName);
- assert(CheckerIt != Checkers.end() && CheckerIt->FullName == FullName &&
- "Failed to find the checker while attempting to set up its "
- "dependencies!");
+void CheckerRegistry::resolveDependencies() {
+ for (const std::pair<StringRef, StringRef> &Entry : Dependencies) {
+ auto CheckerIt = binaryFind(Checkers, Entry.first);
+ assert(CheckerIt != Checkers.end() && CheckerIt->FullName == Entry.first &&
+ "Failed to find the checker while attempting to set up its "
+ "dependencies!");
- auto DependencyIt = binaryFind(Checkers, Dependency);
- assert(DependencyIt != Checkers.end() &&
- DependencyIt->FullName == Dependency &&
- "Failed to find the dependency of a checker!");
+ auto DependencyIt = binaryFind(Checkers, Entry.second);
+ assert(DependencyIt != Checkers.end() &&
+ DependencyIt->FullName == Entry.second &&
+ "Failed to find the dependency of a checker!");
+
+ CheckerIt->Dependencies.emplace_back(&*DependencyIt);
+ }
- CheckerIt->Dependencies.emplace_back(&*DependencyIt);
+ Dependencies.clear();
+}
+
+void CheckerRegistry::addDependency(StringRef FullName, StringRef Dependency) {
+ Dependencies.emplace_back(FullName, Dependency);
}
void CheckerRegistry::initializeManager(CheckerManager &CheckerMgr) const {
// RUN: %clang_analyze_cc1 %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-checker=nullability.NullReturnedFromNonnull
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN: -analyzer-checker=osx.cocoa.RetainCount \
+// RUN: -analyzer-list-enabled-checkers \
+// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-ENABLED
+
+// CHECK-IMPLICITLY-ENABLED: osx.cocoa.RetainCountBase
+// CHECK-IMPLICITLY-ENABLED: osx.cocoa.RetainCount
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN: -analyzer-checker=osx.cocoa.RetainCount \
+// RUN: -analyzer-disable-checker=osx.cocoa.RetainCountBase \
+// RUN: -analyzer-list-enabled-checkers \
+// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-DISABLED
+
+// CHECK-IMPLICITLY-DISABLED-NOT: osx.cocoa.RetainCountBase
+// CHECK-IMPLICITLY-DISABLED-NOT: osx.cocoa.RetainCount