Skip to content

Commit cfdb15a

Browse files
authored
merge main into amd-staging (llvm#811)
2 parents 17d3551 + 806baca commit cfdb15a

File tree

291 files changed

+12067
-7097
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

291 files changed

+12067
-7097
lines changed

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ ClangTidyASTConsumerFactory::createASTConsumer(
462462
std::unique_ptr<ento::AnalysisASTConsumer> AnalysisConsumer =
463463
ento::CreateAnalysisConsumer(Compiler);
464464
AnalysisConsumer->AddDiagnosticConsumer(
465-
new AnalyzerDiagnosticConsumer(Context));
465+
std::make_unique<AnalyzerDiagnosticConsumer>(Context));
466466
Consumers.push_back(std::move(AnalysisConsumer));
467467
}
468468
#endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER

clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ clang_target_link_libraries(clangTidyBugproneModule
117117
clangASTMatchers
118118
clangBasic
119119
clangLex
120+
clangSema
120121
clangTooling
121122
clangTransformer
122123
)

clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "clang/Basic/Diagnostic.h"
2121
#include "clang/Basic/SourceLocation.h"
2222
#include "clang/Lex/Lexer.h"
23+
#include "clang/Sema/HeuristicResolver.h"
2324
#include "llvm/ADT/STLExtras.h"
2425
#include "llvm/ADT/SmallVector.h"
2526
#include "llvm/Support/Casting.h"
@@ -125,8 +126,8 @@ void StandaloneEmptyCheck::check(const MatchFinder::MatchResult &Result) {
125126
DeclarationName Name =
126127
Context.DeclarationNames.getIdentifier(&Context.Idents.get("clear"));
127128

128-
auto Candidates = MemberCall->getRecordDecl()->lookupDependentName(
129-
Name, [](const NamedDecl *ND) {
129+
auto Candidates = HeuristicResolver(Context).lookupDependentName(
130+
MemberCall->getRecordDecl(), Name, [](const NamedDecl *ND) {
130131
return isa<CXXMethodDecl>(ND) &&
131132
llvm::cast<CXXMethodDecl>(ND)->getMinRequiredArguments() ==
132133
0 &&
@@ -174,8 +175,8 @@ void StandaloneEmptyCheck::check(const MatchFinder::MatchResult &Result) {
174175
DeclarationName Name =
175176
Context.DeclarationNames.getIdentifier(&Context.Idents.get("clear"));
176177

177-
auto Candidates =
178-
ArgRecordDecl->lookupDependentName(Name, [](const NamedDecl *ND) {
178+
auto Candidates = HeuristicResolver(Context).lookupDependentName(
179+
ArgRecordDecl, Name, [](const NamedDecl *ND) {
179180
return isa<CXXMethodDecl>(ND) &&
180181
llvm::cast<CXXMethodDecl>(ND)->getMinRequiredArguments() ==
181182
0 &&

clang/include/clang/Analysis/AnalysisDeclContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ class AnalysisDeclContextManager {
451451
bool synthesizeBodies = false, bool addStaticInitBranches = false,
452452
bool addCXXNewAllocator = true, bool addRichCXXConstructors = true,
453453
bool markElidedCXXConstructors = true, bool addVirtualBaseBranches = true,
454-
CodeInjector *injector = nullptr);
454+
std::unique_ptr<CodeInjector> injector = nullptr);
455455

456456
AnalysisDeclContext *getContext(const Decl *D);
457457

clang/include/clang/Sema/HeuristicResolver.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ class HeuristicResolver {
6969
QualType
7070
resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS) const;
7171

72+
// Perform an imprecise lookup of a dependent name in `RD`.
73+
// This function does not follow strict semantic rules and should be used
74+
// only when lookup rules can be relaxed, e.g. indexing.
75+
std::vector<const NamedDecl *>
76+
lookupDependentName(CXXRecordDecl *RD, DeclarationName Name,
77+
llvm::function_ref<bool(const NamedDecl *ND)> Filter);
78+
7279
// Given the type T of a dependent expression that appears of the LHS of a
7380
// "->", heuristically find a corresponding pointee type in whose scope we
7481
// could look up the name appearing on the RHS.

clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,14 @@ ANALYZER_OPTION(
483483
"behavior, set the option to 0.",
484484
5)
485485

486+
ANALYZER_OPTION(
487+
unsigned, RegionStoreMaxBindingFanOut, "region-store-max-binding-fanout",
488+
"This option limits how many sub-bindings a single binding operation can "
489+
"scatter into. For example, binding an array would scatter into binding "
490+
"each individual element. Setting this to zero means unlimited, but then "
491+
"modelling large array initializers may take proportional time to their "
492+
"size.", 128)
493+
486494
//===----------------------------------------------------------------------===//
487495
// String analyzer options.
488496
//===----------------------------------------------------------------------===//

clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,8 @@ class BugReporterData {
570570
public:
571571
virtual ~BugReporterData() = default;
572572

573-
virtual ArrayRef<PathDiagnosticConsumer*> getPathDiagnosticConsumers() = 0;
573+
virtual ArrayRef<std::unique_ptr<PathDiagnosticConsumer>>
574+
getPathDiagnosticConsumers() = 0;
574575
virtual ASTContext &getASTContext() = 0;
575576
virtual SourceManager &getSourceManager() = 0;
576577
virtual AnalyzerOptions &getAnalyzerOptions() = 0;
@@ -608,7 +609,8 @@ class BugReporter {
608609
/// Generate and flush diagnostics for all bug reports.
609610
void FlushReports();
610611

611-
ArrayRef<PathDiagnosticConsumer*> getPathDiagnosticConsumers() {
612+
ArrayRef<std::unique_ptr<PathDiagnosticConsumer>>
613+
getPathDiagnosticConsumers() {
612614
return D.getPathDiagnosticConsumers();
613615
}
614616

@@ -670,9 +672,10 @@ class BugReporter {
670672
protected:
671673
/// Generate the diagnostics for the given bug report.
672674
virtual std::unique_ptr<DiagnosticForConsumerMapTy>
673-
generateDiagnosticForConsumerMap(BugReport *exampleReport,
674-
ArrayRef<PathDiagnosticConsumer *> consumers,
675-
ArrayRef<BugReport *> bugReports);
675+
generateDiagnosticForConsumerMap(
676+
BugReport *exampleReport,
677+
ArrayRef<std::unique_ptr<PathDiagnosticConsumer>> consumers,
678+
ArrayRef<BugReport *> bugReports);
676679
};
677680

678681
/// GRBugReporter is used for generating path-sensitive reports.
@@ -684,10 +687,11 @@ class PathSensitiveBugReporter final : public BugReporter {
684687
SmallVectorImpl<BugReport *> &bugReports) override;
685688

686689
/// Generate the diagnostics for the given bug report.
687-
std::unique_ptr<DiagnosticForConsumerMapTy>
688-
generateDiagnosticForConsumerMap(BugReport *exampleReport,
689-
ArrayRef<PathDiagnosticConsumer *> consumers,
690-
ArrayRef<BugReport *> bugReports) override;
690+
std::unique_ptr<DiagnosticForConsumerMapTy> generateDiagnosticForConsumerMap(
691+
BugReport *exampleReport,
692+
ArrayRef<std::unique_ptr<PathDiagnosticConsumer>> consumers,
693+
ArrayRef<BugReport *> bugReports) override;
694+
691695
public:
692696
PathSensitiveBugReporter(BugReporterData& d, ExprEngine& eng)
693697
: BugReporter(d), Eng(eng) {}
@@ -706,7 +710,7 @@ class PathSensitiveBugReporter final : public BugReporter {
706710
/// Iterates through the bug reports within a single equivalence class,
707711
/// stops at a first non-invalidated report.
708712
std::unique_ptr<DiagnosticForConsumerMapTy> generatePathDiagnostics(
709-
ArrayRef<PathDiagnosticConsumer *> consumers,
713+
ArrayRef<std::unique_ptr<PathDiagnosticConsumer>> consumers,
710714
ArrayRef<PathSensitiveBugReport *> &bugReports);
711715

712716
void emitReport(std::unique_ptr<BugReport> R) override;

clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class CrossTranslationUnitContext;
3030
namespace ento {
3131

3232
class PathDiagnosticConsumer;
33-
typedef std::vector<PathDiagnosticConsumer*> PathDiagnosticConsumers;
33+
using PathDiagnosticConsumers =
34+
std::vector<std::unique_ptr<PathDiagnosticConsumer>>;
3435

3536
#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN) \
3637
void CREATEFN(PathDiagnosticConsumerOptions Diagopts, \

clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ class AnalysisManager : public BugReporterData {
4747
AnalyzerOptions &options;
4848

4949
AnalysisManager(ASTContext &ctx, Preprocessor &PP,
50-
const PathDiagnosticConsumers &Consumers,
50+
PathDiagnosticConsumers Consumers,
5151
StoreManagerCreator storemgr,
5252
ConstraintManagerCreator constraintmgr,
5353
CheckerManager *checkerMgr, AnalyzerOptions &Options,
54-
CodeInjector *injector = nullptr);
54+
std::unique_ptr<CodeInjector> injector = nullptr);
5555

5656
~AnalysisManager() override;
5757

@@ -91,7 +91,8 @@ class AnalysisManager : public BugReporterData {
9191
return LangOpts;
9292
}
9393

94-
ArrayRef<PathDiagnosticConsumer*> getPathDiagnosticConsumers() override {
94+
ArrayRef<std::unique_ptr<PathDiagnosticConsumer>>
95+
getPathDiagnosticConsumers() override {
9596
return PathConsumers;
9697
}
9798

clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,13 +659,13 @@ class ExprEngine {
659659
SVal Loc, SVal Val,
660660
const LocationContext *LCtx);
661661

662+
public:
662663
/// A simple wrapper when you only need to notify checkers of pointer-escape
663664
/// of some values.
664665
ProgramStateRef escapeValues(ProgramStateRef State, ArrayRef<SVal> Vs,
665666
PointerEscapeKind K,
666667
const CallEvent *Call = nullptr) const;
667668

668-
public:
669669
// FIXME: 'tag' should be removed, and a LocationContext should be used
670670
// instead.
671671
// FIXME: Comment on the meaning of the arguments, when 'St' may not

0 commit comments

Comments
 (0)