Skip to content

Commit 3e5db7b

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into fixdincorrectdelofctoronsomeunionspart2
2 parents af9639f + 87fadb3 commit 3e5db7b

File tree

724 files changed

+37182
-11256
lines changed

Some content is hidden

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

724 files changed

+37182
-11256
lines changed

.github/new-prs-labeler.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,26 @@ backend:PowerPC:
846846
- clang/lib/Driver/ToolChains/Arch/PPC.*
847847
- clang/test/CodeGen/PowerPC/**
848848

849+
backend:SystemZ:
850+
- llvm/include/llvm/BinaryFormat/ELFRelocs/SystemZ*
851+
- llvm/include/llvm/BinaryFormat/GOFF.h
852+
- llvm/include/llvm/IR/IntrinsicsSystemZ.td
853+
- llvm/lib/Target/SystemZ/**
854+
- llvm/test/Analysis/**/SystemZ/**
855+
- llvm/test/CodeGen/SystemZ/**
856+
- llvm/test/DebugInfo/SystemZ/**
857+
- llvm/test/ExecutionEngine/**/SystemZ/**
858+
- llvm/test/MC/Disassembler/SystemZ/**
859+
- llvm/test/MC/GOFF/**
860+
- llvm/test/MC/SystemZ/**
861+
- llvm/test/Transforms/**/SystemZ/**
862+
- clang/include/clang/Basic/BuiltinsSystemZ.*
863+
- clang/lib/Basic/Targets/SystemZ.*
864+
- clang/lib/CodeGen/Targets/SystemZ.cpp
865+
- clang/lib/Driver/ToolChains/ZOS*
866+
- clang/lib/Driver/ToolChains/Arch/SystemZ.*
867+
- clang/test/CodeGen/SystemZ/**
868+
849869
third-party:unittests:
850870
- third-party/unittests/**
851871

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class DIEBuilder {
124124
std::vector<std::unique_ptr<DIEAbbrev>> Abbreviations;
125125
BinaryContext &BC;
126126
DWARFContext *DwarfContext{nullptr};
127-
bool IsDWO{false};
127+
DWARFUnit *SkeletonCU{nullptr};
128128
uint64_t UnitSize{0};
129129
llvm::DenseSet<uint64_t> AllProcessed;
130130

@@ -264,8 +264,12 @@ class DIEBuilder {
264264
/// current Section.
265265
DIE *constructDIEFast(DWARFDie &DDie, DWARFUnit &U, uint32_t UnitId);
266266

267+
/// Returns true if this DIEBUilder is for DWO Unit.
268+
bool isDWO() const { return SkeletonCU != nullptr; }
269+
267270
public:
268-
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext, bool IsDWO = false);
271+
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext,
272+
DWARFUnit *SkeletonCU = nullptr);
269273

270274
/// Returns enum to what we are currently processing.
271275
ProcessingType getCurrentProcessingState() { return getState().Type; }

bolt/include/bolt/Core/DebugData.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,16 @@ class DebugStrOffsetsWriter {
450450
return std::move(StrOffsetsBuffer);
451451
}
452452

453-
private:
454453
/// Initializes Buffer and Stream.
455454
void initialize(DWARFUnit &Unit);
456455

456+
/// Clear data.
457+
void clear() {
458+
IndexToAddressMap.clear();
459+
StrOffsets.clear();
460+
}
461+
462+
private:
457463
std::unique_ptr<DebugStrOffsetsBufferVector> StrOffsetsBuffer;
458464
std::unique_ptr<raw_svector_ostream> StrOffsetsStream;
459465
std::map<uint32_t, uint32_t> IndexToAddressMap;

bolt/lib/Core/DIEBuilder.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ void DIEBuilder::constructFromUnit(DWARFUnit &DU) {
179179
}
180180

181181
DIEBuilder::DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext,
182-
bool IsDWO)
183-
: BC(BC), DwarfContext(DwarfContext), IsDWO(IsDWO) {}
182+
DWARFUnit *SkeletonCU)
183+
: BC(BC), DwarfContext(DwarfContext), SkeletonCU(SkeletonCU) {}
184184

185185
static unsigned int getCUNum(DWARFContext *DwarfContext, bool IsDWO) {
186186
unsigned int CUNum = IsDWO ? DwarfContext->getNumDWOCompileUnits()
@@ -204,11 +204,11 @@ void DIEBuilder::buildTypeUnits(DebugStrOffsetsWriter *StrOffsetWriter,
204204
true);
205205
}
206206
}
207-
const unsigned int CUNum = getCUNum(DwarfContext, IsDWO);
207+
const unsigned int CUNum = getCUNum(DwarfContext, isDWO());
208208
getState().CloneUnitCtxMap.resize(CUNum);
209209
DWARFContext::unit_iterator_range CU4TURanges =
210-
IsDWO ? DwarfContext->dwo_types_section_units()
211-
: DwarfContext->types_section_units();
210+
isDWO() ? DwarfContext->dwo_types_section_units()
211+
: DwarfContext->types_section_units();
212212

213213
getState().Type = ProcessingType::DWARF4TUs;
214214
for (std::unique_ptr<DWARFUnit> &DU : CU4TURanges)
@@ -218,8 +218,8 @@ void DIEBuilder::buildTypeUnits(DebugStrOffsetsWriter *StrOffsetWriter,
218218
constructFromUnit(*DU.get());
219219

220220
DWARFContext::unit_iterator_range CURanges =
221-
IsDWO ? DwarfContext->dwo_info_section_units()
222-
: DwarfContext->info_section_units();
221+
isDWO() ? DwarfContext->dwo_info_section_units()
222+
: DwarfContext->info_section_units();
223223

224224
// This handles DWARF4 CUs and DWARF5 CU/TUs.
225225
// Creating a vector so that for reference handling only DWARF5 CU/TUs are
@@ -242,11 +242,11 @@ void DIEBuilder::buildCompileUnits(const bool Init) {
242242
if (Init)
243243
BuilderState.reset(new State());
244244

245-
unsigned int CUNum = getCUNum(DwarfContext, IsDWO);
245+
unsigned int CUNum = getCUNum(DwarfContext, isDWO());
246246
getState().CloneUnitCtxMap.resize(CUNum);
247247
DWARFContext::unit_iterator_range CURanges =
248-
IsDWO ? DwarfContext->dwo_info_section_units()
249-
: DwarfContext->info_section_units();
248+
isDWO() ? DwarfContext->dwo_info_section_units()
249+
: DwarfContext->info_section_units();
250250

251251
// This handles DWARF4 CUs and DWARF5 CU/TUs.
252252
// Creating a vector so that for reference handling only DWARF5 CU/TUs are

bolt/lib/Core/DebugData.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,7 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit,
909909
}
910910

911911
StrOffsetSectionWasModified = false;
912-
IndexToAddressMap.clear();
913-
StrOffsets.clear();
912+
clear();
914913
}
915914

916915
void DebugStrWriter::create() {

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ void DWARFRewriter::updateDebugInfo() {
709709
: LegacyRangesSectionWriter.get();
710710
// Skipping CUs that failed to load.
711711
if (SplitCU) {
712-
DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), true);
712+
DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), Unit);
713713
DWODIEBuilder.buildDWOUnit(**SplitCU);
714714
std::string DWOName = updateDWONameCompDir(
715715
*Unit, *DIEBlder, *DIEBlder->getUnitDIEbyUnit(*Unit));

clang-tools-extra/clangd/refactor/Rename.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,18 @@ renameWithinFile(ParsedAST &AST, const NamedDecl &RenameDecl,
811811
continue;
812812
Locs.push_back(RenameLoc);
813813
}
814-
if (const auto *MD = dyn_cast<ObjCMethodDecl>(&RenameDecl))
815-
return renameObjCMethodWithinFile(AST, MD, NewName, std::move(Locs));
814+
if (const auto *MD = dyn_cast<ObjCMethodDecl>(&RenameDecl)) {
815+
// The custom ObjC selector logic doesn't handle the zero arg selector
816+
// case, as it relies on parsing selectors via the trailing `:`.
817+
// We also choose to use regular rename logic for the single-arg selectors
818+
// as the AST/Index has the right locations in that case.
819+
if (MD->getSelector().getNumArgs() > 1)
820+
return renameObjCMethodWithinFile(AST, MD, NewName, std::move(Locs));
821+
822+
// Eat trailing : for single argument methods since they're actually
823+
// considered a separate token during rename.
824+
NewName.consume_back(":");
825+
}
816826
for (const auto &Loc : Locs) {
817827
if (auto Err = FilteredChanges.add(tooling::Replacement(
818828
SM, CharSourceRange::getTokenRange(Loc), NewName)))
@@ -930,10 +940,9 @@ renameOutsideFile(const NamedDecl &RenameDecl, llvm::StringRef MainFilePath,
930940
std::optional<Selector> Selector = std::nullopt;
931941
llvm::SmallVector<llvm::StringRef, 8> NewNames;
932942
if (const auto *MD = dyn_cast<ObjCMethodDecl>(&RenameDecl)) {
933-
if (MD->getSelector().getNumArgs() > 1) {
934-
RenameIdentifier = MD->getSelector().getNameForSlot(0).str();
943+
RenameIdentifier = MD->getSelector().getNameForSlot(0).str();
944+
if (MD->getSelector().getNumArgs() > 1)
935945
Selector = MD->getSelector();
936-
}
937946
}
938947
NewName.split(NewNames, ":");
939948

clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "ClangdServer.h"
1212
#include "ConfigProvider.h"
1313
#include "Diagnostics.h"
14+
#include "Feature.h"
1415
#include "FeatureModule.h"
1516
#include "LSPBinder.h"
1617
#include "LSPClient.h"
@@ -198,6 +199,9 @@ TEST_F(LSPTest, RecordsLatencies) {
198199
// clang-tidy's renames are converted to clangd's internal rename functionality,
199200
// see clangd#1589 and clangd#741
200201
TEST_F(LSPTest, ClangTidyRename) {
202+
// This test requires clang-tidy checks to be linked in.
203+
if (!CLANGD_TIDY_CHECKS)
204+
return;
201205
Annotations Header(R"cpp(
202206
void [[foo]]();
203207
)cpp");
@@ -214,7 +218,9 @@ TEST_F(LSPTest, ClangTidyRename) {
214218
Client.didOpen("foo.hpp", Header.code());
215219
Client.didOpen("foo.cpp", Source.code());
216220

217-
auto RenameDiag = Client.diagnostics("foo.cpp").value().at(0);
221+
auto Diags = Client.diagnostics("foo.cpp");
222+
ASSERT_TRUE(Diags && !Diags->empty());
223+
auto RenameDiag = Diags->front();
218224

219225
auto RenameCommand =
220226
(*Client

clang-tools-extra/clangd/unittests/RenameTests.cpp

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,6 +1943,144 @@ TEST(CrossFileRenameTests, WithUpToDateIndex) {
19431943
}
19441944
}
19451945

1946+
TEST(CrossFileRenameTests, ObjC) {
1947+
MockCompilationDatabase CDB;
1948+
CDB.ExtraClangFlags = {"-xobjective-c"};
1949+
// rename is runnning on all "^" points in FooH.
1950+
struct Case {
1951+
llvm::StringRef FooH;
1952+
llvm::StringRef FooM;
1953+
llvm::StringRef NewName;
1954+
llvm::StringRef ExpectedFooH;
1955+
llvm::StringRef ExpectedFooM;
1956+
};
1957+
Case Cases[] = {// --- Zero arg selector
1958+
{
1959+
// Input
1960+
R"cpp(
1961+
@interface Foo
1962+
- (int)performA^ction;
1963+
@end
1964+
)cpp",
1965+
R"cpp(
1966+
@implementation Foo
1967+
- (int)performAction {
1968+
[self performAction];
1969+
}
1970+
@end
1971+
)cpp",
1972+
// New name
1973+
"performNewAction",
1974+
// Expected
1975+
R"cpp(
1976+
@interface Foo
1977+
- (int)performNewAction;
1978+
@end
1979+
)cpp",
1980+
R"cpp(
1981+
@implementation Foo
1982+
- (int)performNewAction {
1983+
[self performNewAction];
1984+
}
1985+
@end
1986+
)cpp",
1987+
},
1988+
// --- Single arg selector
1989+
{
1990+
// Input
1991+
R"cpp(
1992+
@interface Foo
1993+
- (int)performA^ction:(int)action;
1994+
@end
1995+
)cpp",
1996+
R"cpp(
1997+
@implementation Foo
1998+
- (int)performAction:(int)action {
1999+
[self performAction:action];
2000+
}
2001+
@end
2002+
)cpp",
2003+
// New name
2004+
"performNewAction:",
2005+
// Expected
2006+
R"cpp(
2007+
@interface Foo
2008+
- (int)performNewAction:(int)action;
2009+
@end
2010+
)cpp",
2011+
R"cpp(
2012+
@implementation Foo
2013+
- (int)performNewAction:(int)action {
2014+
[self performNewAction:action];
2015+
}
2016+
@end
2017+
)cpp",
2018+
},
2019+
// --- Multi arg selector
2020+
{
2021+
// Input
2022+
R"cpp(
2023+
@interface Foo
2024+
- (int)performA^ction:(int)action with:(int)value;
2025+
@end
2026+
)cpp",
2027+
R"cpp(
2028+
@implementation Foo
2029+
- (int)performAction:(int)action with:(int)value {
2030+
[self performAction:action with:value];
2031+
}
2032+
@end
2033+
)cpp",
2034+
// New name
2035+
"performNewAction:by:",
2036+
// Expected
2037+
R"cpp(
2038+
@interface Foo
2039+
- (int)performNewAction:(int)action by:(int)value;
2040+
@end
2041+
)cpp",
2042+
R"cpp(
2043+
@implementation Foo
2044+
- (int)performNewAction:(int)action by:(int)value {
2045+
[self performNewAction:action by:value];
2046+
}
2047+
@end
2048+
)cpp",
2049+
}};
2050+
2051+
trace::TestTracer Tracer;
2052+
for (const auto &T : Cases) {
2053+
SCOPED_TRACE(T.FooH);
2054+
Annotations FooH(T.FooH);
2055+
Annotations FooM(T.FooM);
2056+
std::string FooHPath = testPath("foo.h");
2057+
std::string FooMPath = testPath("foo.m");
2058+
2059+
MockFS FS;
2060+
FS.Files[FooHPath] = std::string(FooH.code());
2061+
FS.Files[FooMPath] = std::string(FooM.code());
2062+
2063+
auto ServerOpts = ClangdServer::optsForTest();
2064+
ServerOpts.BuildDynamicSymbolIndex = true;
2065+
ClangdServer Server(CDB, FS, ServerOpts);
2066+
2067+
// Add all files to clangd server to make sure the dynamic index has been
2068+
// built.
2069+
runAddDocument(Server, FooHPath, FooH.code());
2070+
runAddDocument(Server, FooMPath, FooM.code());
2071+
2072+
for (const auto &RenamePos : FooH.points()) {
2073+
EXPECT_THAT(Tracer.takeMetric("rename_files"), SizeIs(0));
2074+
auto FileEditsList =
2075+
llvm::cantFail(runRename(Server, FooHPath, RenamePos, T.NewName, {}));
2076+
EXPECT_THAT(Tracer.takeMetric("rename_files"), ElementsAre(2));
2077+
EXPECT_THAT(applyEdits(std::move(FileEditsList.GlobalChanges)),
2078+
UnorderedElementsAre(Pair(Eq(FooHPath), Eq(T.ExpectedFooH)),
2079+
Pair(Eq(FooMPath), Eq(T.ExpectedFooM))));
2080+
}
2081+
}
2082+
}
2083+
19462084
TEST(CrossFileRenameTests, CrossFileOnLocalSymbol) {
19472085
// cross-file rename should work for function-local symbols, even there is no
19482086
// index provided.

clang-tools-extra/include-cleaner/lib/WalkAST.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
128128

129129
bool VisitDeclRefExpr(DeclRefExpr *DRE) {
130130
auto *FD = DRE->getFoundDecl();
131+
// Prefer the underlying decl if FoundDecl isn't a shadow decl, e.g:
132+
// - For templates, found-decl is always primary template, but we want the
133+
// specializaiton itself.
134+
if (!llvm::isa<UsingShadowDecl>(FD))
135+
FD = DRE->getDecl();
131136
// For refs to non-meber-like decls, use the found decl.
132137
// For member-like decls, we should have a reference from the qualifier to
133138
// the container decl instead, which is preferred as it'll handle

0 commit comments

Comments
 (0)