Skip to content

Commit 2a2be38

Browse files
committed
Merge branch 'main' into amd-trunk-dev
2 parents e14ed94 + 54a6798 commit 2a2be38

File tree

128 files changed

+5808
-650
lines changed

Some content is hidden

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

128 files changed

+5808
-650
lines changed

bolt/lib/Rewrite/RewriteInstance.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -2306,9 +2306,13 @@ void RewriteInstance::processRelocations() {
23062306
return;
23072307

23082308
for (const SectionRef &Section : InputFile->sections()) {
2309-
if (cantFail(Section.getRelocatedSection()) != InputFile->section_end() &&
2310-
!BinarySection(*BC, Section).isAllocatable())
2311-
readRelocations(Section);
2309+
section_iterator SecIter = cantFail(Section.getRelocatedSection());
2310+
if (SecIter == InputFile->section_end())
2311+
continue;
2312+
if (BinarySection(*BC, Section).isAllocatable())
2313+
continue;
2314+
2315+
readRelocations(Section);
23122316
}
23132317

23142318
if (NumFailedRelocations)

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

+26-20
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,14 @@ class RenamerClangTidyCheckPPCallbacks : public PPCallbacks {
169169
return;
170170
if (SM.isWrittenInCommandLineFile(MacroNameTok.getLocation()))
171171
return;
172-
Check->checkMacro(SM, MacroNameTok, Info);
172+
Check->checkMacro(MacroNameTok, Info, SM);
173173
}
174174

175175
/// MacroExpands calls expandMacro for macros in the main file
176176
void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
177177
SourceRange /*Range*/,
178178
const MacroArgs * /*Args*/) override {
179-
Check->expandMacro(MacroNameTok, MD.getMacroInfo());
179+
Check->expandMacro(MacroNameTok, MD.getMacroInfo(), SM);
180180
}
181181

182182
private:
@@ -187,7 +187,7 @@ class RenamerClangTidyCheckPPCallbacks : public PPCallbacks {
187187
class RenamerClangTidyVisitor
188188
: public RecursiveASTVisitor<RenamerClangTidyVisitor> {
189189
public:
190-
RenamerClangTidyVisitor(RenamerClangTidyCheck *Check, const SourceManager *SM,
190+
RenamerClangTidyVisitor(RenamerClangTidyCheck *Check, const SourceManager &SM,
191191
bool AggressiveDependentMemberLookup)
192192
: Check(Check), SM(SM),
193193
AggressiveDependentMemberLookup(AggressiveDependentMemberLookup) {}
@@ -258,7 +258,7 @@ class RenamerClangTidyVisitor
258258
// Fix overridden methods
259259
if (const auto *Method = dyn_cast<CXXMethodDecl>(Decl)) {
260260
if (const CXXMethodDecl *Overridden = getOverrideMethod(Method)) {
261-
Check->addUsage(Overridden, Method->getLocation());
261+
Check->addUsage(Overridden, Method->getLocation(), SM);
262262
return true; // Don't try to add the actual decl as a Failure.
263263
}
264264
}
@@ -268,7 +268,7 @@ class RenamerClangTidyVisitor
268268
if (isa<ClassTemplateSpecializationDecl>(Decl))
269269
return true;
270270

271-
Check->checkNamedDecl(Decl, *SM);
271+
Check->checkNamedDecl(Decl, SM);
272272
return true;
273273
}
274274

@@ -385,7 +385,7 @@ class RenamerClangTidyVisitor
385385

386386
private:
387387
RenamerClangTidyCheck *Check;
388-
const SourceManager *SM;
388+
const SourceManager &SM;
389389
const bool AggressiveDependentMemberLookup;
390390
};
391391

@@ -415,7 +415,7 @@ void RenamerClangTidyCheck::registerPPCallbacks(
415415

416416
void RenamerClangTidyCheck::addUsage(
417417
const RenamerClangTidyCheck::NamingCheckId &Decl, SourceRange Range,
418-
const SourceManager *SourceMgr) {
418+
const SourceManager &SourceMgr) {
419419
// Do nothing if the provided range is invalid.
420420
if (Range.isInvalid())
421421
return;
@@ -425,8 +425,7 @@ void RenamerClangTidyCheck::addUsage(
425425
// spelling location to different source locations, and we only want to fix
426426
// the token once, before it is expanded by the macro.
427427
SourceLocation FixLocation = Range.getBegin();
428-
if (SourceMgr)
429-
FixLocation = SourceMgr->getSpellingLoc(FixLocation);
428+
FixLocation = SourceMgr.getSpellingLoc(FixLocation);
430429
if (FixLocation.isInvalid())
431430
return;
432431

@@ -440,15 +439,15 @@ void RenamerClangTidyCheck::addUsage(
440439
if (!Failure.shouldFix())
441440
return;
442441

443-
if (SourceMgr && SourceMgr->isWrittenInScratchSpace(FixLocation))
442+
if (SourceMgr.isWrittenInScratchSpace(FixLocation))
444443
Failure.FixStatus = RenamerClangTidyCheck::ShouldFixStatus::InsideMacro;
445444

446-
if (!utils::rangeCanBeFixed(Range, SourceMgr))
445+
if (!utils::rangeCanBeFixed(Range, &SourceMgr))
447446
Failure.FixStatus = RenamerClangTidyCheck::ShouldFixStatus::InsideMacro;
448447
}
449448

450449
void RenamerClangTidyCheck::addUsage(const NamedDecl *Decl, SourceRange Range,
451-
const SourceManager *SourceMgr) {
450+
const SourceManager &SourceMgr) {
452451
// Don't keep track for non-identifier names.
453452
auto *II = Decl->getIdentifier();
454453
if (!II)
@@ -489,18 +488,24 @@ void RenamerClangTidyCheck::checkNamedDecl(const NamedDecl *Decl,
489488
}
490489

491490
Failure.Info = std::move(Info);
492-
addUsage(Decl, Range, &SourceMgr);
491+
addUsage(Decl, Range, SourceMgr);
493492
}
494493

495494
void RenamerClangTidyCheck::check(const MatchFinder::MatchResult &Result) {
496-
RenamerClangTidyVisitor Visitor(this, Result.SourceManager,
495+
if (!Result.SourceManager) {
496+
// In principle SourceManager is not null but going only by the definition
497+
// of MatchResult it must be handled. Cannot rename anything without a
498+
// SourceManager.
499+
return;
500+
}
501+
RenamerClangTidyVisitor Visitor(this, *Result.SourceManager,
497502
AggressiveDependentMemberLookup);
498503
Visitor.TraverseAST(*Result.Context);
499504
}
500505

501-
void RenamerClangTidyCheck::checkMacro(const SourceManager &SourceMgr,
502-
const Token &MacroNameTok,
503-
const MacroInfo *MI) {
506+
void RenamerClangTidyCheck::checkMacro(const Token &MacroNameTok,
507+
const MacroInfo *MI,
508+
const SourceManager &SourceMgr) {
504509
std::optional<FailureInfo> MaybeFailure =
505510
getMacroFailureInfo(MacroNameTok, SourceMgr);
506511
if (!MaybeFailure)
@@ -515,11 +520,12 @@ void RenamerClangTidyCheck::checkMacro(const SourceManager &SourceMgr,
515520
Failure.FixStatus = ShouldFixStatus::FixInvalidIdentifier;
516521

517522
Failure.Info = std::move(Info);
518-
addUsage(ID, Range);
523+
addUsage(ID, Range, SourceMgr);
519524
}
520525

521526
void RenamerClangTidyCheck::expandMacro(const Token &MacroNameTok,
522-
const MacroInfo *MI) {
527+
const MacroInfo *MI,
528+
const SourceManager &SourceMgr) {
523529
StringRef Name = MacroNameTok.getIdentifierInfo()->getName();
524530
NamingCheckId ID(MI->getDefinitionLoc(), Name);
525531

@@ -528,7 +534,7 @@ void RenamerClangTidyCheck::expandMacro(const Token &MacroNameTok,
528534
return;
529535

530536
SourceRange Range(MacroNameTok.getLocation(), MacroNameTok.getEndLoc());
531-
addUsage(ID, Range);
537+
addUsage(ID, Range, SourceMgr);
532538
}
533539

534540
static std::string

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,19 @@ class RenamerClangTidyCheck : public ClangTidyCheck {
108108
llvm::DenseMap<NamingCheckId, NamingCheckFailure>;
109109

110110
/// Check Macros for style violations.
111-
void checkMacro(const SourceManager &SourceMgr, const Token &MacroNameTok,
112-
const MacroInfo *MI);
111+
void checkMacro(const Token &MacroNameTok, const MacroInfo *MI,
112+
const SourceManager &SourceMgr);
113113

114114
/// Add a usage of a macro if it already has a violation.
115-
void expandMacro(const Token &MacroNameTok, const MacroInfo *MI);
115+
void expandMacro(const Token &MacroNameTok, const MacroInfo *MI,
116+
const SourceManager &SourceMgr);
116117

117118
void addUsage(const RenamerClangTidyCheck::NamingCheckId &Decl,
118-
SourceRange Range, const SourceManager *SourceMgr = nullptr);
119+
SourceRange Range, const SourceManager &SourceMgr);
119120

120121
/// Convenience method when the usage to be added is a NamedDecl.
121122
void addUsage(const NamedDecl *Decl, SourceRange Range,
122-
const SourceManager *SourceMgr = nullptr);
123+
const SourceManager &SourceMgr);
123124

124125
void checkNamedDecl(const NamedDecl *Decl, const SourceManager &SourceMgr);
125126

clang/include/clang/AST/ASTNodeTraverser.h

+8
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,14 @@ class ASTNodeTraverser
932932
Visit(TArg);
933933
}
934934

935+
void VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *Node) {
936+
Visit(Node->getExpr());
937+
}
938+
939+
void VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *Node) {
940+
Visit(Node->getExpr());
941+
}
942+
935943
// Implements Visit methods for Attrs.
936944
#include "clang/AST/AttrNodeTraverse.inc"
937945
};

clang/include/clang/AST/JSONNodeDumper.h

+2
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ class JSONNodeDumper
310310
void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *MTE);
311311
void VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *ME);
312312
void VisitRequiresExpr(const RequiresExpr *RE);
313+
void VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *Node);
314+
void VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *Node);
313315

314316
void VisitObjCEncodeExpr(const ObjCEncodeExpr *OEE);
315317
void VisitObjCMessageExpr(const ObjCMessageExpr *OME);

clang/include/clang/Driver/Options.td

+2-1
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,8 @@ def hip_link : Flag<["--"], "hip-link">, Group<opencl_Group>,
13411341
HelpText<"Link clang-offload-bundler bundles for HIP">;
13421342
def no_hip_rt: Flag<["-"], "no-hip-rt">, Group<hip_Group>,
13431343
HelpText<"Do not link against HIP runtime libraries">;
1344-
def rocm_path_EQ : Joined<["--"], "rocm-path=">, Group<hip_Group>,
1344+
def rocm_path_EQ : Joined<["--"], "rocm-path=">,
1345+
Visibility<[FlangOption]>, Group<hip_Group>,
13451346
HelpText<"ROCm installation path, used for finding and automatically linking required bitcode libraries.">;
13461347
def hip_path_EQ : Joined<["--"], "hip-path=">, Group<hip_Group>,
13471348
HelpText<"HIP runtime installation path, used for finding HIP version and adding HIP include path.">;

clang/lib/AST/JSONNodeDumper.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,14 @@ void JSONNodeDumper::VisitMaterializeTemporaryExpr(
15761576
attributeOnlyIfTrue("boundToLValueRef", MTE->isBoundToLvalueReference());
15771577
}
15781578

1579+
void JSONNodeDumper::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *Node) {
1580+
attributeOnlyIfTrue("hasRewrittenInit", Node->hasRewrittenInit());
1581+
}
1582+
1583+
void JSONNodeDumper::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *Node) {
1584+
attributeOnlyIfTrue("hasRewrittenInit", Node->hasRewrittenInit());
1585+
}
1586+
15791587
void JSONNodeDumper::VisitCXXDependentScopeMemberExpr(
15801588
const CXXDependentScopeMemberExpr *DSME) {
15811589
JOS.attribute("isArrow", DSME->isArrow());

clang/lib/AST/TextNodeDumper.cpp

+2-12
Original file line numberDiff line numberDiff line change
@@ -1450,23 +1450,13 @@ void TextNodeDumper::VisitExpressionTraitExpr(const ExpressionTraitExpr *Node) {
14501450
}
14511451

14521452
void TextNodeDumper::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *Node) {
1453-
if (Node->hasRewrittenInit()) {
1453+
if (Node->hasRewrittenInit())
14541454
OS << " has rewritten init";
1455-
AddChild([=] {
1456-
ColorScope Color(OS, ShowColors, StmtColor);
1457-
Visit(Node->getExpr());
1458-
});
1459-
}
14601455
}
14611456

14621457
void TextNodeDumper::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *Node) {
1463-
if (Node->hasRewrittenInit()) {
1458+
if (Node->hasRewrittenInit())
14641459
OS << " has rewritten init";
1465-
AddChild([=] {
1466-
ColorScope Color(OS, ShowColors, StmtColor);
1467-
Visit(Node->getExpr());
1468-
});
1469-
}
14701460
}
14711461

14721462
void TextNodeDumper::VisitMaterializeTemporaryExpr(

clang/lib/CodeGen/CGCall.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -4124,7 +4124,8 @@ static bool isProvablyNull(llvm::Value *addr) {
41244124
}
41254125

41264126
static bool isProvablyNonNull(Address Addr, CodeGenFunction &CGF) {
4127-
return llvm::isKnownNonZero(Addr.getBasePointer(), CGF.CGM.getDataLayout());
4127+
return llvm::isKnownNonZero(Addr.getBasePointer(), /*Depth=*/0,
4128+
CGF.CGM.getDataLayout());
41284129
}
41294130

41304131
/// Emit the actual writing-back of a writeback.

clang/lib/Headers/CMakeLists.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -437,14 +437,14 @@ foreach( f ${generated_files} )
437437
endforeach( f )
438438

439439
function(add_header_target target_name file_list)
440-
add_custom_target(${target_name} DEPENDS ${file_list})
440+
add_library(${target_name} INTERFACE ${file_list})
441441
set_target_properties(${target_name} PROPERTIES
442442
FOLDER "Misc"
443443
RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
444444
endfunction()
445445

446446
# The catch-all clang-resource-headers target
447-
add_custom_target("clang-resource-headers" ALL DEPENDS ${out_files})
447+
add_library(clang-resource-headers INTERFACE ${out_files})
448448
set_target_properties("clang-resource-headers" PROPERTIES
449449
FOLDER "Misc"
450450
RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
@@ -501,6 +501,10 @@ add_header_target("windows-resource-headers" ${windows_only_files})
501501
add_header_target("utility-resource-headers" ${utility_files})
502502

503503
get_clang_resource_dir(header_install_dir SUBDIR include)
504+
target_include_directories(clang-resource-headers INTERFACE
505+
$<BUILD_INTERFACE:${output_dir}>
506+
$<INSTALL_INTERFACE:${header_install_dir}>)
507+
set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS clang-resource-headers)
504508

505509
#############################################################
506510
# Install rules for the catch-all clang-resource-headers target

clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,10 @@ const CXXRecordDecl *getCXXRecordDecl(ProgramStateRef State,
770770
Type = RefT->getPointeeType();
771771
}
772772

773+
if (const auto *PtrT = Type->getAs<PointerType>()) {
774+
Type = PtrT->getPointeeType();
775+
}
776+
773777
return Type->getUnqualifiedDesugaredType()->getAsCXXRecordDecl();
774778
}
775779

0 commit comments

Comments
 (0)