Skip to content

Commit afa84e1

Browse files
committed
Merge branch 'main' into amd-trunk-dev
2 parents 8634cb1 + 7f9d348 commit afa84e1

File tree

4,426 files changed

+163551
-66522
lines changed

Some content is hidden

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

4,426 files changed

+163551
-66522
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jobs:
7979
path: |
8080
**/test-results.xml
8181
**/*.abilist
82+
**/CMakeConfigureLog.yaml
8283
**/CMakeError.log
8384
**/CMakeOutput.log
8485
**/crash_diagnostics/*
@@ -123,6 +124,7 @@ jobs:
123124
path: |
124125
**/test-results.xml
125126
**/*.abilist
127+
**/CMakeConfigureLog.yaml
126128
**/CMakeError.log
127129
**/CMakeOutput.log
128130
**/crash_diagnostics/*
@@ -188,6 +190,7 @@ jobs:
188190
path: |
189191
**/test-results.xml
190192
**/*.abilist
193+
**/CMakeConfigureLog.yaml
191194
**/CMakeError.log
192195
**/CMakeOutput.log
193196
**/crash_diagnostics/*
@@ -230,6 +233,7 @@ jobs:
230233
path: |
231234
**/test-results.xml
232235
**/*.abilist
236+
**/CMakeConfigureLog.yaml
233237
**/CMakeError.log
234238
**/CMakeOutput.log
235239
**/crash_diagnostics/*

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,6 +2577,7 @@ struct CFISnapshot {
25772577
case MCCFIInstruction::OpAdjustCfaOffset:
25782578
case MCCFIInstruction::OpWindowSave:
25792579
case MCCFIInstruction::OpNegateRAState:
2580+
case MCCFIInstruction::OpNegateRAStateWithPC:
25802581
case MCCFIInstruction::OpLLVMDefAspaceCfa:
25812582
case MCCFIInstruction::OpLabel:
25822583
llvm_unreachable("unsupported CFI opcode");
@@ -2715,6 +2716,7 @@ struct CFISnapshotDiff : public CFISnapshot {
27152716
case MCCFIInstruction::OpAdjustCfaOffset:
27162717
case MCCFIInstruction::OpWindowSave:
27172718
case MCCFIInstruction::OpNegateRAState:
2719+
case MCCFIInstruction::OpNegateRAStateWithPC:
27182720
case MCCFIInstruction::OpLLVMDefAspaceCfa:
27192721
case MCCFIInstruction::OpLabel:
27202722
llvm_unreachable("unsupported CFI opcode");
@@ -2864,6 +2866,7 @@ BinaryFunction::unwindCFIState(int32_t FromState, int32_t ToState,
28642866
case MCCFIInstruction::OpAdjustCfaOffset:
28652867
case MCCFIInstruction::OpWindowSave:
28662868
case MCCFIInstruction::OpNegateRAState:
2869+
case MCCFIInstruction::OpNegateRAStateWithPC:
28672870
case MCCFIInstruction::OpLLVMDefAspaceCfa:
28682871
case MCCFIInstruction::OpLabel:
28692872
llvm_unreachable("unsupported CFI opcode");

bolt/lib/Core/HashUtilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ std::string hashBlockLoose(BinaryContext &BC, const BinaryBasicBlock &BB) {
145145
continue;
146146
}
147147

148-
std::string Mnemonic = BC.InstPrinter->getMnemonic(&Inst).first;
148+
std::string Mnemonic = BC.InstPrinter->getMnemonic(Inst).first;
149149
llvm::erase_if(Mnemonic, [](unsigned char ch) { return std::isspace(ch); });
150150
Opcodes.insert(Mnemonic);
151151
}

clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,33 +78,44 @@ void IdDependentBackwardBranchCheck::registerMatchers(MatchFinder *Finder) {
7878

7979
IdDependentBackwardBranchCheck::IdDependencyRecord *
8080
IdDependentBackwardBranchCheck::hasIdDepVar(const Expr *Expression) {
81+
if (!Expression)
82+
return nullptr;
83+
8184
if (const auto *Declaration = dyn_cast<DeclRefExpr>(Expression)) {
8285
// It is a DeclRefExpr, so check if it's an ID-dependent variable.
83-
const auto *CheckVariable = dyn_cast<VarDecl>(Declaration->getDecl());
86+
const auto *CheckVariable =
87+
dyn_cast_if_present<VarDecl>(Declaration->getDecl());
88+
if (!CheckVariable)
89+
return nullptr;
8490
auto FoundVariable = IdDepVarsMap.find(CheckVariable);
8591
if (FoundVariable == IdDepVarsMap.end())
8692
return nullptr;
8793
return &(FoundVariable->second);
8894
}
8995
for (const auto *Child : Expression->children())
90-
if (const auto *ChildExpression = dyn_cast<Expr>(Child))
96+
if (const auto *ChildExpression = dyn_cast_if_present<Expr>(Child))
9197
if (IdDependencyRecord *Result = hasIdDepVar(ChildExpression))
9298
return Result;
9399
return nullptr;
94100
}
95101

96102
IdDependentBackwardBranchCheck::IdDependencyRecord *
97103
IdDependentBackwardBranchCheck::hasIdDepField(const Expr *Expression) {
104+
if (!Expression)
105+
return nullptr;
106+
98107
if (const auto *MemberExpression = dyn_cast<MemberExpr>(Expression)) {
99108
const auto *CheckField =
100-
dyn_cast<FieldDecl>(MemberExpression->getMemberDecl());
109+
dyn_cast_if_present<FieldDecl>(MemberExpression->getMemberDecl());
110+
if (!CheckField)
111+
return nullptr;
101112
auto FoundField = IdDepFieldsMap.find(CheckField);
102113
if (FoundField == IdDepFieldsMap.end())
103114
return nullptr;
104115
return &(FoundField->second);
105116
}
106117
for (const auto *Child : Expression->children())
107-
if (const auto *ChildExpression = dyn_cast<Expr>(Child))
118+
if (const auto *ChildExpression = dyn_cast_if_present<Expr>(Child))
108119
if (IdDependencyRecord *Result = hasIdDepField(ChildExpression))
109120
return Result;
110121
return nullptr;

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

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "ReturnConstRefFromParameterCheck.h"
10+
#include "clang/AST/Expr.h"
1011
#include "clang/ASTMatchers/ASTMatchFinder.h"
1112
#include "clang/ASTMatchers/ASTMatchers.h"
1213

@@ -15,19 +16,24 @@ using namespace clang::ast_matchers;
1516
namespace clang::tidy::bugprone {
1617

1718
void ReturnConstRefFromParameterCheck::registerMatchers(MatchFinder *Finder) {
19+
const auto DRef = ignoringParens(
20+
declRefExpr(
21+
to(parmVarDecl(hasType(hasCanonicalType(
22+
qualType(lValueReferenceType(pointee(
23+
qualType(isConstQualified()))))
24+
.bind("type"))))
25+
.bind("param")))
26+
.bind("dref"));
27+
const auto Func =
28+
functionDecl(hasReturnTypeLoc(loc(
29+
qualType(hasCanonicalType(equalsBoundNode("type"))))))
30+
.bind("func");
31+
32+
Finder->addMatcher(returnStmt(hasReturnValue(DRef), hasAncestor(Func)), this);
1833
Finder->addMatcher(
19-
returnStmt(
20-
hasReturnValue(declRefExpr(
21-
to(parmVarDecl(hasType(hasCanonicalType(
22-
qualType(lValueReferenceType(pointee(
23-
qualType(isConstQualified()))))
24-
.bind("type"))))
25-
.bind("param")))),
26-
hasAncestor(
27-
functionDecl(hasReturnTypeLoc(loc(qualType(
28-
hasCanonicalType(equalsBoundNode("type"))))))
29-
.bind("func")))
30-
.bind("ret"),
34+
returnStmt(hasReturnValue(ignoringParens(conditionalOperator(
35+
eachOf(hasTrueExpression(DRef), hasFalseExpression(DRef)),
36+
hasAncestor(Func))))),
3137
this);
3238
}
3339

@@ -85,8 +91,8 @@ void ReturnConstRefFromParameterCheck::check(
8591
const MatchFinder::MatchResult &Result) {
8692
const auto *FD = Result.Nodes.getNodeAs<FunctionDecl>("func");
8793
const auto *PD = Result.Nodes.getNodeAs<ParmVarDecl>("param");
88-
const auto *R = Result.Nodes.getNodeAs<ReturnStmt>("ret");
89-
const SourceRange Range = R->getRetValue()->getSourceRange();
94+
const auto *DRef = Result.Nodes.getNodeAs<DeclRefExpr>("dref");
95+
const SourceRange Range = DRef->getSourceRange();
9096
if (Range.isInvalid())
9197
return;
9298

clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,13 @@ unsigned getNumberOfDesignated(const InitListExpr *SyntacticInitList) {
8080
});
8181
}
8282

83-
AST_MATCHER(CXXRecordDecl, isAggregate) { return Node.isAggregate(); }
83+
AST_MATCHER(CXXRecordDecl, isAggregate) {
84+
return Node.hasDefinition() && Node.isAggregate();
85+
}
8486

85-
AST_MATCHER(CXXRecordDecl, isPOD) { return Node.isPOD(); }
87+
AST_MATCHER(CXXRecordDecl, isPOD) {
88+
return Node.hasDefinition() && Node.isPOD();
89+
}
8690

8791
AST_MATCHER(InitListExpr, isFullyDesignated) {
8892
if (const InitListExpr *SyntacticForm =

clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ struct CognitiveComplexity final {
126126
// Limit of 25 is the "upstream"'s default.
127127
static constexpr unsigned DefaultLimit = 25U;
128128

129-
// Based on the publicly-avaliable numbers for some big open-source projects
129+
// Based on the publicly-available numbers for some big open-source projects
130130
// https://sonarcloud.io/projects?languages=c%2Ccpp&size=5 we can estimate:
131131
// value ~20 would result in no allocs for 98% of functions, ~12 for 96%, ~10
132132
// for 91%, ~8 for 88%, ~6 for 84%, ~4 for 77%, ~2 for 64%, and ~1 for 37%.

clang-tools-extra/clangd/ModulesBuilder.cpp

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "clang/Frontend/FrontendAction.h"
1313
#include "clang/Frontend/FrontendActions.h"
1414
#include "clang/Serialization/ASTReader.h"
15+
#include "clang/Serialization/InMemoryModuleCache.h"
1516

1617
namespace clang {
1718
namespace clangd {
@@ -127,50 +128,68 @@ struct ModuleFile {
127128
std::string ModuleFilePath;
128129
};
129130

130-
bool IsModuleFileUpToDate(
131-
PathRef ModuleFilePath,
132-
const PrerequisiteModules &RequisiteModules) {
133-
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
134-
CompilerInstance::createDiagnostics(new DiagnosticOptions());
135-
131+
bool IsModuleFileUpToDate(PathRef ModuleFilePath,
132+
const PrerequisiteModules &RequisiteModules,
133+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
136134
auto HSOpts = std::make_shared<HeaderSearchOptions>();
137135
RequisiteModules.adjustHeaderSearchOptions(*HSOpts);
138136
HSOpts->ForceCheckCXX20ModulesInputFiles = true;
139137
HSOpts->ValidateASTInputFilesContent = true;
140138

139+
clang::clangd::IgnoreDiagnostics IgnoreDiags;
140+
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
141+
CompilerInstance::createDiagnostics(new DiagnosticOptions, &IgnoreDiags,
142+
/*ShouldOwnClient=*/false);
143+
144+
LangOptions LangOpts;
145+
LangOpts.SkipODRCheckInGMF = true;
146+
147+
FileManager FileMgr(FileSystemOptions(), VFS);
148+
149+
SourceManager SourceMgr(*Diags, FileMgr);
150+
151+
HeaderSearch HeaderInfo(HSOpts, SourceMgr, *Diags, LangOpts,
152+
/*Target=*/nullptr);
153+
154+
TrivialModuleLoader ModuleLoader;
155+
Preprocessor PP(std::make_shared<PreprocessorOptions>(), *Diags, LangOpts,
156+
SourceMgr, HeaderInfo, ModuleLoader);
157+
158+
IntrusiveRefCntPtr<InMemoryModuleCache> ModuleCache = new InMemoryModuleCache;
141159
PCHContainerOperations PCHOperations;
142-
std::unique_ptr<ASTUnit> Unit = ASTUnit::LoadFromASTFile(
143-
ModuleFilePath.str(), PCHOperations.getRawReader(), ASTUnit::LoadASTOnly,
144-
Diags, FileSystemOptions(), std::move(HSOpts));
160+
ASTReader Reader(PP, *ModuleCache, /*ASTContext=*/nullptr,
161+
PCHOperations.getRawReader(), {});
145162

146-
if (!Unit)
147-
return false;
163+
// We don't need any listener here. By default it will use a validator
164+
// listener.
165+
Reader.setListener(nullptr);
148166

149-
auto Reader = Unit->getASTReader();
150-
if (!Reader)
167+
if (Reader.ReadAST(ModuleFilePath, serialization::MK_MainFile,
168+
SourceLocation(),
169+
ASTReader::ARR_None) != ASTReader::Success)
151170
return false;
152171

153172
bool UpToDate = true;
154-
Reader->getModuleManager().visit([&](serialization::ModuleFile &MF) -> bool {
155-
Reader->visitInputFiles(
173+
Reader.getModuleManager().visit([&](serialization::ModuleFile &MF) -> bool {
174+
Reader.visitInputFiles(
156175
MF, /*IncludeSystem=*/false, /*Complain=*/false,
157176
[&](const serialization::InputFile &IF, bool isSystem) {
158177
if (!IF.getFile() || IF.isOutOfDate())
159178
UpToDate = false;
160179
});
161-
162180
return !UpToDate;
163181
});
164-
165182
return UpToDate;
166183
}
167184

168185
bool IsModuleFilesUpToDate(
169186
llvm::SmallVector<PathRef> ModuleFilePaths,
170-
const PrerequisiteModules &RequisiteModules) {
171-
return llvm::all_of(ModuleFilePaths, [&RequisiteModules](auto ModuleFilePath) {
172-
return IsModuleFileUpToDate(ModuleFilePath, RequisiteModules);
173-
});
187+
const PrerequisiteModules &RequisiteModules,
188+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
189+
return llvm::all_of(
190+
ModuleFilePaths, [&RequisiteModules, VFS](auto ModuleFilePath) {
191+
return IsModuleFileUpToDate(ModuleFilePath, RequisiteModules, VFS);
192+
});
174193
}
175194

176195
// StandalonePrerequisiteModules - stands for PrerequisiteModules for which all
@@ -347,7 +366,7 @@ bool StandalonePrerequisiteModules::canReuse(
347366
SmallVector<StringRef> BMIPaths;
348367
for (auto &MF : RequiredModules)
349368
BMIPaths.push_back(MF.ModuleFilePath);
350-
return IsModuleFilesUpToDate(BMIPaths, *this);
369+
return IsModuleFilesUpToDate(BMIPaths, *this, VFS);
351370
}
352371

353372
} // namespace clangd

clang-tools-extra/clangd/Protocol.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,16 @@ bool fromJSON(const llvm::json::Value &Params, ClientCapabilities &R,
504504
P.field("offsetEncoding")))
505505
return false;
506506
}
507+
508+
if (auto *Experimental = O->getObject("experimental")) {
509+
if (auto *TextDocument = Experimental->getObject("textDocument")) {
510+
if (auto *Completion = TextDocument->getObject("completion")) {
511+
if (auto EditsNearCursor = Completion->getBoolean("editsNearCursor"))
512+
R.CompletionFixes |= *EditsNearCursor;
513+
}
514+
}
515+
}
516+
507517
return true;
508518
}
509519

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2238,7 +2238,10 @@ prepareCallHierarchy(ParsedAST &AST, Position Pos, PathRef TUPath) {
22382238
for (const NamedDecl *Decl : getDeclAtPosition(AST, *Loc, {})) {
22392239
if (!(isa<DeclContext>(Decl) &&
22402240
cast<DeclContext>(Decl)->isFunctionOrMethod()) &&
2241-
Decl->getKind() != Decl::Kind::FunctionTemplate)
2241+
Decl->getKind() != Decl::Kind::FunctionTemplate &&
2242+
!(Decl->getKind() == Decl::Kind::Var &&
2243+
!cast<VarDecl>(Decl)->isLocalVarDecl()) &&
2244+
Decl->getKind() != Decl::Kind::Field)
22422245
continue;
22432246
if (auto CHI = declToCallHierarchyItem(*Decl, AST.tuPath()))
22442247
Result.emplace_back(std::move(*CHI));

0 commit comments

Comments
 (0)