Skip to content

Commit 5a4bef0

Browse files
committed
merge main into amd-staging
revert: breaks build of hipRuntime, need hipRuntime fix 51ad290 [Clang] Improve diagnostic on `[[nodiscard]]` attribute (llvm#112521) Change-Id: I316909ee244ab7482d13add3a8b938af2187031e
2 parents 1ef01ee + b24acc0 commit 5a4bef0

File tree

378 files changed

+10980
-3921
lines changed

Some content is hidden

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

378 files changed

+10980
-3921
lines changed

.github/new-issues-labeler.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@
2727

2828
'bolt':
2929
- '/\bbolt(?!\-)\b/i'
30+
31+
'infra:commit-access-request':
32+
- '/Request Commit Access/'

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5791,42 +5791,64 @@ void RewriteInstance::writeEHFrameHeader() {
57915791
LLVM_DEBUG(dbgs() << "BOLT: writing a new " << getEHFrameHdrSectionName()
57925792
<< '\n');
57935793

5794-
NextAvailableAddress =
5795-
appendPadding(Out->os(), NextAvailableAddress, EHFrameHdrAlign);
5794+
// Try to overwrite the original .eh_frame_hdr if the size permits.
5795+
uint64_t EHFrameHdrOutputAddress = 0;
5796+
uint64_t EHFrameHdrFileOffset = 0;
5797+
std::vector<char> NewEHFrameHdr;
5798+
BinarySection *OldEHFrameHdrSection = getSection(getEHFrameHdrSectionName());
5799+
if (OldEHFrameHdrSection) {
5800+
NewEHFrameHdr = CFIRdWrt->generateEHFrameHeader(
5801+
RelocatedEHFrame, NewEHFrame, OldEHFrameHdrSection->getAddress());
5802+
if (NewEHFrameHdr.size() <= OldEHFrameHdrSection->getSize()) {
5803+
BC->outs() << "BOLT-INFO: rewriting " << getEHFrameHdrSectionName()
5804+
<< " in-place\n";
5805+
EHFrameHdrOutputAddress = OldEHFrameHdrSection->getAddress();
5806+
EHFrameHdrFileOffset = OldEHFrameHdrSection->getInputFileOffset();
5807+
} else {
5808+
OldEHFrameHdrSection->setOutputName(getOrgSecPrefix() +
5809+
getEHFrameHdrSectionName());
5810+
OldEHFrameHdrSection = nullptr;
5811+
}
5812+
}
57965813

5797-
const uint64_t EHFrameHdrOutputAddress = NextAvailableAddress;
5798-
const uint64_t EHFrameHdrFileOffset =
5799-
getFileOffsetForAddress(NextAvailableAddress);
5814+
// If there was not enough space, allocate more memory for .eh_frame_hdr.
5815+
if (!OldEHFrameHdrSection) {
5816+
NextAvailableAddress =
5817+
appendPadding(Out->os(), NextAvailableAddress, EHFrameHdrAlign);
58005818

5801-
std::vector<char> NewEHFrameHdr = CFIRdWrt->generateEHFrameHeader(
5802-
RelocatedEHFrame, NewEHFrame, EHFrameHdrOutputAddress);
5819+
EHFrameHdrOutputAddress = NextAvailableAddress;
5820+
EHFrameHdrFileOffset = getFileOffsetForAddress(NextAvailableAddress);
5821+
5822+
NewEHFrameHdr = CFIRdWrt->generateEHFrameHeader(
5823+
RelocatedEHFrame, NewEHFrame, EHFrameHdrOutputAddress);
5824+
5825+
NextAvailableAddress += NewEHFrameHdr.size();
5826+
if (!BC->BOLTReserved.empty() &&
5827+
(NextAvailableAddress > BC->BOLTReserved.end())) {
5828+
BC->errs() << "BOLT-ERROR: unable to fit " << getEHFrameHdrSectionName()
5829+
<< " into reserved space\n";
5830+
exit(1);
5831+
}
5832+
5833+
// Create a new entry in the section header table.
5834+
const unsigned Flags = BinarySection::getFlags(/*IsReadOnly=*/true,
5835+
/*IsText=*/false,
5836+
/*IsAllocatable=*/true);
5837+
BinarySection &EHFrameHdrSec = BC->registerOrUpdateSection(
5838+
getNewSecPrefix() + getEHFrameHdrSectionName(), ELF::SHT_PROGBITS,
5839+
Flags, nullptr, NewEHFrameHdr.size(), /*Alignment=*/1);
5840+
EHFrameHdrSec.setOutputFileOffset(EHFrameHdrFileOffset);
5841+
EHFrameHdrSec.setOutputAddress(EHFrameHdrOutputAddress);
5842+
EHFrameHdrSec.setOutputName(getEHFrameHdrSectionName());
5843+
}
58035844

58045845
Out->os().seek(EHFrameHdrFileOffset);
58055846
Out->os().write(NewEHFrameHdr.data(), NewEHFrameHdr.size());
58065847

5807-
const unsigned Flags = BinarySection::getFlags(/*IsReadOnly=*/true,
5808-
/*IsText=*/false,
5809-
/*IsAllocatable=*/true);
5810-
BinarySection *OldEHFrameHdrSection = getSection(getEHFrameHdrSectionName());
5848+
// Pad the contents if overwriting in-place.
58115849
if (OldEHFrameHdrSection)
5812-
OldEHFrameHdrSection->setOutputName(getOrgSecPrefix() +
5813-
getEHFrameHdrSectionName());
5814-
5815-
BinarySection &EHFrameHdrSec = BC->registerOrUpdateSection(
5816-
getNewSecPrefix() + getEHFrameHdrSectionName(), ELF::SHT_PROGBITS, Flags,
5817-
nullptr, NewEHFrameHdr.size(), /*Alignment=*/1);
5818-
EHFrameHdrSec.setOutputFileOffset(EHFrameHdrFileOffset);
5819-
EHFrameHdrSec.setOutputAddress(EHFrameHdrOutputAddress);
5820-
EHFrameHdrSec.setOutputName(getEHFrameHdrSectionName());
5821-
5822-
NextAvailableAddress += EHFrameHdrSec.getOutputSize();
5823-
5824-
if (!BC->BOLTReserved.empty() &&
5825-
(NextAvailableAddress > BC->BOLTReserved.end())) {
5826-
BC->errs() << "BOLT-ERROR: unable to fit " << getEHFrameHdrSectionName()
5827-
<< " into reserved space\n";
5828-
exit(1);
5829-
}
5850+
Out->os().write_zeros(OldEHFrameHdrSection->getSize() -
5851+
NewEHFrameHdr.size());
58305852

58315853
// Merge new .eh_frame with the relocated original so that gdb can locate all
58325854
// FDEs.

bolt/test/eh-frame-hdr.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Check that llvm-bolt overwrites .eh_frame_hdr in-place.
2+
3+
REQUIRES: system-linux
4+
5+
RUN: %clang %cflags %p/Inputs/hello.c -o %t -Wl,-q
6+
RUN: llvm-bolt %t -o %t.bolt --use-old-text \
7+
RUN: | FileCheck %s --check-prefix=CHECK-BOLT
8+
RUN: llvm-readelf -WS %t.bolt | FileCheck %s
9+
10+
CHECK-BOLT: rewriting .eh_frame_hdr in-place
11+
12+
CHECK-NOT: .bolt.org.eh_frame_hdr

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace {
2020

2121
AST_MATCHER_P(FunctionDecl, isEnabled, llvm::StringSet<>,
2222
FunctionsThatShouldNotThrow) {
23-
return FunctionsThatShouldNotThrow.count(Node.getNameAsString()) > 0;
23+
return FunctionsThatShouldNotThrow.contains(Node.getNameAsString());
2424
}
2525

2626
AST_MATCHER(FunctionDecl, isExplicitThrow) {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ ExceptionAnalyzer::ExceptionInfo::filterIgnoredExceptions(
418418
if (TD->getDeclName().isIdentifier()) {
419419
if ((IgnoreBadAlloc &&
420420
(TD->getName() == "bad_alloc" && TD->isInStdNamespace())) ||
421-
(IgnoredTypes.count(TD->getName()) > 0))
421+
(IgnoredTypes.contains(TD->getName())))
422422
TypesToDelete.push_back(T);
423423
}
424424
}
@@ -449,7 +449,8 @@ void ExceptionAnalyzer::ExceptionInfo::reevaluateBehaviour() {
449449
ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::throwsException(
450450
const FunctionDecl *Func, const ExceptionInfo::Throwables &Caught,
451451
llvm::SmallSet<const FunctionDecl *, 32> &CallStack) {
452-
if (!Func || CallStack.count(Func) || (!CallStack.empty() && !canThrow(Func)))
452+
if (!Func || CallStack.contains(Func) ||
453+
(!CallStack.empty() && !canThrow(Func)))
453454
return ExceptionInfo::createNonThrowing();
454455

455456
if (const Stmt *Body = Func->getBody()) {
@@ -507,7 +508,7 @@ ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::throwsException(
507508
for (unsigned I = 0; I < Try->getNumHandlers(); ++I) {
508509
const CXXCatchStmt *Catch = Try->getHandler(I);
509510

510-
// Everything is catched through 'catch(...)'.
511+
// Everything is caught through 'catch(...)'.
511512
if (!Catch->getExceptionDecl()) {
512513
ExceptionInfo Rethrown = throwsException(
513514
Catch->getHandlerBlock(), Uncaught.getExceptionTypes(), CallStack);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ class ExceptionAnalyzer {
101101
/// Recalculate the 'Behaviour' for example after filtering.
102102
void reevaluateBehaviour();
103103

104-
/// Keep track if the entity related to this 'ExceptionInfo' can in princple
105-
/// throw, if it's unknown or if it won't throw.
104+
/// Keep track if the entity related to this 'ExceptionInfo' can in
105+
/// principle throw, if it's unknown or if it won't throw.
106106
State Behaviour;
107107

108108
/// Keep track if the entity contains any unknown elements to keep track

clang-tools-extra/clangd/Protocol.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,35 @@ bool fromJSON(const llvm::json::Value &Params, ClientCapabilities &R,
511511
if (auto EditsNearCursor = Completion->getBoolean("editsNearCursor"))
512512
R.CompletionFixes |= *EditsNearCursor;
513513
}
514+
if (auto *References = TextDocument->getObject("references")) {
515+
if (auto ContainerSupport = References->getBoolean("container")) {
516+
R.ReferenceContainer |= *ContainerSupport;
517+
}
518+
}
519+
if (auto *Diagnostics = TextDocument->getObject("publishDiagnostics")) {
520+
if (auto CodeActions = Diagnostics->getBoolean("codeActionsInline")) {
521+
R.DiagnosticFixes |= *CodeActions;
522+
}
523+
}
524+
if (auto *InactiveRegions =
525+
TextDocument->getObject("inactiveRegionsCapabilities")) {
526+
if (auto InactiveRegionsSupport =
527+
InactiveRegions->getBoolean("inactiveRegions")) {
528+
R.InactiveRegions |= *InactiveRegionsSupport;
529+
}
530+
}
531+
}
532+
if (auto *Window = Experimental->getObject("window")) {
533+
if (auto Implicit =
534+
Window->getBoolean("implicitWorkDoneProgressCreate")) {
535+
R.ImplicitProgressCreation |= *Implicit;
536+
}
537+
}
538+
if (auto *OffsetEncoding = Experimental->get("offsetEncoding")) {
539+
R.offsetEncoding.emplace();
540+
if (!fromJSON(*OffsetEncoding, *R.offsetEncoding,
541+
P.field("offsetEncoding")))
542+
return false;
514543
}
515544
}
516545

clang-tools-extra/clangd/Protocol.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ struct ClientCapabilities {
452452
std::optional<SymbolKindBitset> WorkspaceSymbolKinds;
453453

454454
/// Whether the client accepts diagnostics with codeActions attached inline.
455+
/// This is a clangd extension.
455456
/// textDocument.publishDiagnostics.codeActionsInline.
456457
bool DiagnosticFixes = false;
457458

@@ -475,6 +476,7 @@ struct ClientCapabilities {
475476

476477
/// Client supports displaying a container string for results of
477478
/// textDocument/reference (clangd extension)
479+
/// textDocument.references.container
478480
bool ReferenceContainer = false;
479481

480482
/// Client supports hierarchical document symbols.
@@ -563,6 +565,7 @@ struct ClientCapabilities {
563565

564566
/// Whether the client supports the textDocument/inactiveRegions
565567
/// notification. This is a clangd extension.
568+
/// textDocument.inactiveRegionsCapabilities.inactiveRegions
566569
bool InactiveRegions = false;
567570
};
568571
bool fromJSON(const llvm::json::Value &, ClientCapabilities &,

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include "llvm/ADT/StringRef.h"
6464
#include "llvm/Support/Casting.h"
6565
#include "llvm/Support/Error.h"
66+
#include "llvm/Support/ErrorHandling.h"
6667
#include "llvm/Support/Path.h"
6768
#include "llvm/Support/raw_ostream.h"
6869
#include <optional>
@@ -2275,7 +2276,7 @@ incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index) {
22752276
// Initially store the ranges in a map keyed by SymbolID of the caller.
22762277
// This allows us to group different calls with the same caller
22772278
// into the same CallHierarchyIncomingCall.
2278-
llvm::DenseMap<SymbolID, std::vector<Range>> CallsIn;
2279+
llvm::DenseMap<SymbolID, std::vector<Location>> CallsIn;
22792280
// We can populate the ranges based on a refs request only. As we do so, we
22802281
// also accumulate the container IDs into a lookup request.
22812282
LookupRequest ContainerLookup;
@@ -2285,7 +2286,7 @@ incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index) {
22852286
elog("incomingCalls failed to convert location: {0}", Loc.takeError());
22862287
return;
22872288
}
2288-
CallsIn[R.Container].push_back(Loc->range);
2289+
CallsIn[R.Container].push_back(*Loc);
22892290

22902291
ContainerLookup.IDs.insert(R.Container);
22912292
});
@@ -2294,9 +2295,21 @@ incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index) {
22942295
Index->lookup(ContainerLookup, [&](const Symbol &Caller) {
22952296
auto It = CallsIn.find(Caller.ID);
22962297
assert(It != CallsIn.end());
2297-
if (auto CHI = symbolToCallHierarchyItem(Caller, Item.uri.file()))
2298+
if (auto CHI = symbolToCallHierarchyItem(Caller, Item.uri.file())) {
2299+
std::vector<Range> FromRanges;
2300+
for (const Location &L : It->second) {
2301+
if (L.uri != CHI->uri) {
2302+
// Call location not in same file as caller.
2303+
// This can happen in some edge cases. There's not much we can do,
2304+
// since the protocol only allows returning ranges interpreted as
2305+
// being in the caller's file.
2306+
continue;
2307+
}
2308+
FromRanges.push_back(L.range);
2309+
}
22982310
Results.push_back(
2299-
CallHierarchyIncomingCall{std::move(*CHI), std::move(It->second)});
2311+
CallHierarchyIncomingCall{std::move(*CHI), std::move(FromRanges)});
2312+
}
23002313
});
23012314
// Sort results by name of container.
23022315
llvm::sort(Results, [](const CallHierarchyIncomingCall &A,

0 commit comments

Comments
 (0)