Skip to content

Commit 587f210

Browse files
committed
Merge branch 'main' into merge-functions
2 parents 3df9ca1 + 6927a43 commit 587f210

File tree

148 files changed

+2314
-339
lines changed

Some content is hidden

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

148 files changed

+2314
-339
lines changed

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));

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,51 @@ TEST(CallHierarchy, CallInLocalVarDecl) {
446446
AllOf(from(withName("caller3")), fromRanges(Source.range("call3")))));
447447
}
448448

449+
TEST(CallHierarchy, HierarchyOnField) {
450+
// Tests that the call hierarchy works on fields.
451+
Annotations Source(R"cpp(
452+
struct Vars {
453+
int v^ar1 = 1;
454+
};
455+
void caller() {
456+
Vars values;
457+
values.$Callee[[var1]];
458+
}
459+
)cpp");
460+
TestTU TU = TestTU::withCode(Source.code());
461+
auto AST = TU.build();
462+
auto Index = TU.index();
463+
464+
std::vector<CallHierarchyItem> Items =
465+
prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
466+
ASSERT_THAT(Items, ElementsAre(withName("var1")));
467+
auto IncomingLevel1 = incomingCalls(Items[0], Index.get());
468+
ASSERT_THAT(IncomingLevel1,
469+
ElementsAre(AllOf(from(withName("caller")),
470+
fromRanges(Source.range("Callee")))));
471+
}
472+
473+
TEST(CallHierarchy, HierarchyOnVar) {
474+
// Tests that the call hierarchy works on non-local variables.
475+
Annotations Source(R"cpp(
476+
int v^ar = 1;
477+
void caller() {
478+
$Callee[[var]];
479+
}
480+
)cpp");
481+
TestTU TU = TestTU::withCode(Source.code());
482+
auto AST = TU.build();
483+
auto Index = TU.index();
484+
485+
std::vector<CallHierarchyItem> Items =
486+
prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
487+
ASSERT_THAT(Items, ElementsAre(withName("var")));
488+
auto IncomingLevel1 = incomingCalls(Items[0], Index.get());
489+
ASSERT_THAT(IncomingLevel1,
490+
ElementsAre(AllOf(from(withName("caller")),
491+
fromRanges(Source.range("Callee")))));
492+
}
493+
449494
} // namespace
450495
} // namespace clangd
451496
} // namespace clang

clang/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ If you're interested in more (including how to build Clang) it is best to read t
1616

1717
* Information on the LLVM project: http://llvm.org/
1818

19-
* If you have questions or comments about Clang, a great place to disucss them is on the Clang forums:    
19+
* If you have questions or comments about Clang, a great place to discuss them is on the Clang forums:    
2020

2121
[Clang Frontend - LLVM Discussion Forums](https://discourse.llvm.org/c/clang/)
2222

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2259,7 +2259,7 @@ the configuration (without a prefix: ``Auto``).
22592259
**BraceWrapping** (``BraceWrappingFlags``) :versionbadge:`clang-format 3.8` :ref:`<BraceWrapping>`
22602260
Control of individual brace wrapping cases.
22612261

2262-
If ``BreakBeforeBraces`` is set to ``BS_Custom``, use this to specify how
2262+
If ``BreakBeforeBraces`` is set to ``Custom``, use this to specify how
22632263
each individual brace case should be handled. Otherwise, this is ignored.
22642264

22652265
.. code-block:: yaml

clang/include/clang/Format/Format.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,7 @@ struct FormatStyle {
15691569

15701570
/// Control of individual brace wrapping cases.
15711571
///
1572-
/// If ``BreakBeforeBraces`` is set to ``BS_Custom``, use this to specify how
1572+
/// If ``BreakBeforeBraces`` is set to ``Custom``, use this to specify how
15731573
/// each individual brace case should be handled. Otherwise, this is ignored.
15741574
/// \code{.yaml}
15751575
/// # Example of usage:

clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,39 +83,33 @@ static void swapBytes(std::byte *M, size_t N) {
8383
/// have indeterminate value.
8484
/// All offsets are in bits.
8585
struct BitcastBuffer {
86-
llvm::BitVector Data;
86+
size_t SizeInBits = 0;
87+
llvm::SmallVector<std::byte> Data;
8788

8889
BitcastBuffer() = default;
8990

90-
size_t size() const { return Data.size(); }
91+
size_t size() const { return SizeInBits; }
9192

92-
const std::byte *data() const {
93-
unsigned NBytes = Data.size() / 8;
94-
unsigned BitVectorWordSize = sizeof(uintptr_t);
95-
bool FullWord = (NBytes % BitVectorWordSize == 0);
96-
97-
// llvm::BitVector uses 64-bit fields internally, so when we have
98-
// fewer bytes than that, we need to compensate for that on
99-
// big endian hosts.
100-
unsigned DataPlus;
101-
if (llvm::sys::IsBigEndianHost)
102-
DataPlus = BitVectorWordSize - (NBytes % BitVectorWordSize);
103-
else
104-
DataPlus = 0;
105-
106-
return reinterpret_cast<const std::byte *>(Data.getData().data()) +
107-
(FullWord ? 0 : DataPlus);
108-
}
93+
const std::byte *data() const { return Data.data(); }
10994

11095
bool allInitialized() const {
11196
// FIXME: Implement.
11297
return true;
11398
}
11499

100+
bool atByteBoundary() const { return (Data.size() * 8) == SizeInBits; }
101+
102+
void pushBit(bool Value) {
103+
if (atByteBoundary())
104+
Data.push_back(std::byte{0});
105+
106+
if (Value)
107+
Data.back() |= (std::byte{1} << (SizeInBits % 8));
108+
++SizeInBits;
109+
}
110+
115111
void pushData(const std::byte *data, size_t BitOffset, size_t BitWidth,
116112
bool BigEndianTarget) {
117-
Data.reserve(BitOffset + BitWidth);
118-
119113
bool OnlyFullBytes = BitWidth % 8 == 0;
120114
unsigned NBytes = BitWidth / 8;
121115

@@ -125,7 +119,7 @@ struct BitcastBuffer {
125119
std::byte B =
126120
BigEndianTarget ? data[NBytes - OnlyFullBytes - I] : data[I];
127121
for (unsigned X = 0; X != 8; ++X) {
128-
Data.push_back(bitof(B, X));
122+
pushBit(bitof(B, X));
129123
++BitsHandled;
130124
}
131125
}
@@ -137,7 +131,7 @@ struct BitcastBuffer {
137131
assert((BitWidth - BitsHandled) < 8);
138132
std::byte B = BigEndianTarget ? data[0] : data[NBytes];
139133
for (size_t I = 0, E = (BitWidth - BitsHandled); I != E; ++I) {
140-
Data.push_back(bitof(B, I));
134+
pushBit(bitof(B, I));
141135
++BitsHandled;
142136
}
143137

@@ -363,5 +357,8 @@ bool clang::interp::DoBitCast(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
363357
HasIndeterminateBits = !Buffer.allInitialized();
364358
std::memcpy(Buff, Buffer.data(), BuffSize);
365359

360+
if (llvm::sys::IsBigEndianHost)
361+
swapBytes(Buff, BuffSize);
362+
366363
return Success;
367364
}

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ class AnnotatingParser {
12591259

12601260
bool parseConditional() {
12611261
while (CurrentToken) {
1262-
if (CurrentToken->is(tok::colon)) {
1262+
if (CurrentToken->is(tok::colon) && CurrentToken->is(TT_Unknown)) {
12631263
CurrentToken->setType(TT_ConditionalExpr);
12641264
next();
12651265
return true;

clang/test/AST/ByteCode/builtin-bit-cast.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ constexpr bool operator==(const struct bits<N, T, P>& lhs, const struct bits<N,
7474
#ifdef __SIZEOF_INT128__
7575
static_assert(check_round_trip<__int128_t>((__int128_t)34));
7676
static_assert(check_round_trip<__int128_t>((__int128_t)-34));
77+
78+
constexpr unsigned char OneBit[] = {
79+
0x1, 0x0, 0x0, 0x0,
80+
0x0, 0x0, 0x0, 0x0,
81+
0x0, 0x0, 0x0, 0x0,
82+
0x0, 0x0, 0x0, 0x0,
83+
};
84+
constexpr __int128_t One = 1;
85+
constexpr __int128_t Expected = One << 120;
86+
static_assert(__builtin_bit_cast(__int128_t, OneBit) == (LITTLE_END ? 1 : Expected));
87+
7788
#endif
7889

7990

clang/unittests/Format/FormatTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24393,6 +24393,8 @@ TEST_F(FormatTest, DisableRegions) {
2439324393
TEST_F(FormatTest, DoNotCrashOnInvalidInput) {
2439424394
format("? ) =");
2439524395
verifyNoCrash("#define a\\\n /**/}");
24396+
verifyNoCrash(" tst %o5 ! are we doing the gray case?\n"
24397+
"LY52: ! [internal]");
2439624398
}
2439724399

2439824400
TEST_F(FormatTest, FormatsTableGenCode) {

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,14 @@ if(LLVM_LIBC_INCLUDE_SCUDO)
356356
endif()
357357

358358
set(TARGET_LIBM_ENTRYPOINTS
359+
# complex.h entrypoints
360+
libc.src.complex.creal
361+
libc.src.complex.crealf
362+
libc.src.complex.creall
363+
libc.src.complex.cimag
364+
libc.src.complex.cimagf
365+
libc.src.complex.cimagl
366+
359367
# fenv.h entrypoints
360368
libc.src.fenv.feclearexcept
361369
libc.src.fenv.fedisableexcept
@@ -603,6 +611,10 @@ set(TARGET_LIBM_ENTRYPOINTS
603611

604612
if(LIBC_TYPES_HAS_FLOAT16)
605613
list(APPEND TARGET_LIBM_ENTRYPOINTS
614+
# complex.h C23 _Complex _Float16 entrypoints
615+
# libc.src.complex.crealf16
616+
# libc.src.complex.cimagf16
617+
606618
# math.h C23 _Float16 entrypoints
607619
libc.src.math.canonicalizef16
608620
libc.src.math.ceilf16
@@ -704,6 +716,10 @@ endif()
704716

705717
if(LIBC_TYPES_HAS_FLOAT128)
706718
list(APPEND TARGET_LIBM_ENTRYPOINTS
719+
# complex.h C23 _Complex _Float128 entrypoints
720+
libc.src.complex.crealf128
721+
libc.src.complex.cimagf128
722+
707723
# math.h C23 _Float128 entrypoints
708724
libc.src.math.canonicalizef128
709725
libc.src.math.ceilf128

0 commit comments

Comments
 (0)