Skip to content

Commit bb826cc

Browse files
author
Jenkins
committed
merge main into amd-staging
Change-Id: I2f3d73781e886a95b45475b485aa6521fb9188b3
2 parents a595ff6 + f2441b0 commit bb826cc

File tree

63 files changed

+1407
-274
lines changed

Some content is hidden

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

63 files changed

+1407
-274
lines changed

clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,10 @@ class CyclicDependencyCallbacks : public PPCallbacks {
139139

140140
auto CurrentIt = Files.rbegin();
141141
do {
142-
Check.diag(CurrentIt->Loc, "'%0' included from here", DiagnosticIDs::Note)
143-
<< CurrentIt->Name;
142+
if (CurrentIt->Loc.isValid())
143+
Check.diag(CurrentIt->Loc, "'%0' included from here",
144+
DiagnosticIDs::Note)
145+
<< CurrentIt->Name;
144146
} while (CurrentIt++ != It);
145147
}
146148

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ Changes in existing checks
317317
Additionally, the option `UseHeaderFileExtensions` is removed, so that the
318318
check uses the `HeaderFileExtensions` option unconditionally.
319319

320+
- Improved :doc:`misc-header-include-cycle
321+
<clang-tidy/checks/misc/header-include-cycle>` check by avoiding crash for self
322+
include cycles.
323+
320324
- Improved :doc:`misc-unused-using-decls
321325
<clang-tidy/checks/misc/unused-using-decls>` check by replacing the local
322326
option `HeaderFileExtensions` by the global option of the same name.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: not clang-tidy %s -checks='-*,misc-header-include-cycle'
2+
3+
#include "header-include-cycle.self.cpp"

clang/include/clang/Basic/DiagnosticOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class DiagnosticOptions : public RefCountedBase<DiagnosticOptions>{
124124
/// default).
125125
std::vector<std::string> VerifyPrefixes;
126126

127-
/// The list of -Wsystem-header-in-module=... options used to override
127+
/// The list of -Wsystem-headers-in-module=... options used to override
128128
/// whether -Wsystem-headers is enabled on a per-module basis.
129129
std::vector<std::string> SystemHeaderWarningsModules;
130130

clang/lib/Driver/ToolChains/Arch/RISCV.cpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ static void getRISCFeaturesFromMcpu(const Driver &D, const Arg *A,
6767
D.Diag(clang::diag::err_drv_unsupported_option_argument)
6868
<< A->getSpelling() << Mcpu;
6969
}
70-
71-
if (llvm::RISCV::hasFastUnalignedAccess(Mcpu)) {
72-
Features.push_back("+unaligned-scalar-mem");
73-
Features.push_back("+unaligned-vector-mem");
74-
}
7570
}
7671

7772
void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
@@ -82,6 +77,8 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
8277
if (!getArchFeatures(D, MArch, Features, Args))
8378
return;
8479

80+
bool CPUFastUnaligned = false;
81+
8582
// If users give march and mcpu, get std extension feature from MArch
8683
// and other features (ex. mirco architecture feature) from mcpu
8784
if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
@@ -90,6 +87,9 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
9087
CPU = llvm::sys::getHostCPUName();
9188

9289
getRISCFeaturesFromMcpu(D, A, Triple, CPU, Features);
90+
91+
if (llvm::RISCV::hasFastUnalignedAccess(CPU))
92+
CPUFastUnaligned = true;
9393
}
9494

9595
// Handle features corresponding to "-ffixed-X" options
@@ -169,18 +169,23 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
169169
Features.push_back("-relax");
170170
}
171171

172-
// Android requires fast unaligned access on RISCV64.
173-
if (Triple.isAndroid()) {
172+
// If -mstrict-align or -mno-strict-align is passed, use it. Otherwise, the
173+
// unaligned-*-mem is enabled if the CPU supports it or the target is
174+
// Android.
175+
if (const Arg *A = Args.getLastArg(options::OPT_mno_strict_align,
176+
options::OPT_mstrict_align)) {
177+
if (A->getOption().matches(options::OPT_mno_strict_align)) {
178+
Features.push_back("+unaligned-scalar-mem");
179+
Features.push_back("+unaligned-vector-mem");
180+
} else {
181+
Features.push_back("-unaligned-scalar-mem");
182+
Features.push_back("-unaligned-vector-mem");
183+
}
184+
} else if (CPUFastUnaligned || Triple.isAndroid()) {
174185
Features.push_back("+unaligned-scalar-mem");
175186
Features.push_back("+unaligned-vector-mem");
176187
}
177188

178-
// -mstrict-align is default, unless -mno-strict-align is specified.
179-
AddTargetFeature(Args, Features, options::OPT_mno_strict_align,
180-
options::OPT_mstrict_align, "unaligned-scalar-mem");
181-
AddTargetFeature(Args, Features, options::OPT_mno_strict_align,
182-
options::OPT_mstrict_align, "unaligned-vector-mem");
183-
184189
// Now add any that the user explicitly requested on the command line,
185190
// which may override the defaults.
186191
handleTargetFeaturesGroup(D, Triple, Args, Features,

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
17121712
(!Previous || Previous->isNot(tok::kw_return) ||
17131713
(Style.Language != FormatStyle::LK_Java && PrecedenceLevel > 0)) &&
17141714
(Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign ||
1715-
PrecedenceLevel != prec::Comma || Current.NestingLevel == 0) &&
1715+
PrecedenceLevel > prec::Comma || Current.NestingLevel == 0) &&
17161716
(!Style.isTableGen() ||
17171717
(Previous && Previous->isOneOf(TT_TableGenDAGArgListComma,
17181718
TT_TableGenDAGArgListCommaToBreak)))) {

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,8 @@ class AnnotatingParser {
13581358
Line.First->startsSequence(tok::kw_export, Keywords.kw_module) ||
13591359
Line.First->startsSequence(tok::kw_export, Keywords.kw_import)) {
13601360
Tok->setType(TT_ModulePartitionColon);
1361+
} else if (Line.First->is(tok::kw_asm)) {
1362+
Tok->setType(TT_InlineASMColon);
13611363
} else if (Contexts.back().ColonIsDictLiteral || Style.isProto()) {
13621364
Tok->setType(TT_DictLiteral);
13631365
if (Style.Language == FormatStyle::LK_TextProto) {
@@ -1425,13 +1427,6 @@ class AnnotatingParser {
14251427
// This handles a special macro in ObjC code where selectors including
14261428
// the colon are passed as macro arguments.
14271429
Tok->setType(TT_ObjCMethodExpr);
1428-
} else if (Contexts.back().ContextKind == tok::l_paren &&
1429-
!Line.InPragmaDirective) {
1430-
if (Style.isTableGen() && Contexts.back().IsTableGenDAGArg) {
1431-
Tok->setType(TT_TableGenDAGArgListColon);
1432-
break;
1433-
}
1434-
Tok->setType(TT_InlineASMColon);
14351430
}
14361431
break;
14371432
case tok::pipe:

clang/test/Interpreter/pretty-print.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// RUN: cat %s | clang-repl -Xcc -xc | FileCheck %s
44
// RUN: cat %s | clang-repl -Xcc -std=c++11 | FileCheck %s
55

6+
// Fails with `Symbols not found: [ __clang_Interpreter_SetValueNoAlloc ]`.
7+
// UNSUPPORTED: hwasan
8+
69
const char* c_str = "Hello, world!"; c_str
710

811
// CHECK: Not implement yet.

clang/tools/clang-format/ClangFormat.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,7 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) {
509509
if (OutputXML || DryRun) {
510510
if (DryRun)
511511
return emitReplacementWarnings(Replaces, AssumedFileName, Code);
512-
else
513-
outputXML(Replaces, FormatChanges, Status, Cursor, CursorPosition);
512+
outputXML(Replaces, FormatChanges, Status, Cursor, CursorPosition);
514513
} else {
515514
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
516515
new llvm::vfs::InMemoryFileSystem);

clang/unittests/Format/FormatTest.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9241,6 +9241,14 @@ TEST_F(FormatTest, AlignsAfterOpenBracket) {
92419241
" b));",
92429242
Style);
92439243

9244+
Style.ColumnLimit = 30;
9245+
verifyFormat("for (int foo = 0; foo < FOO;\n"
9246+
" ++foo) {\n"
9247+
" bar(foo);\n"
9248+
"}",
9249+
Style);
9250+
Style.ColumnLimit = 80;
9251+
92449252
Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
92459253
Style.BinPackArguments = false;
92469254
Style.BinPackParameters = false;

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,12 +1496,82 @@ TEST_F(TokenAnnotatorTest, RequiresDoesNotChangeParsingOfTheRest) {
14961496

14971497
TEST_F(TokenAnnotatorTest, UnderstandsAsm) {
14981498
auto Tokens = annotate("__asm{\n"
1499-
"a:\n"
1500-
"};");
1501-
ASSERT_EQ(Tokens.size(), 7u) << Tokens;
1499+
"\"a\":\n"
1500+
": x\n"
1501+
":};");
1502+
ASSERT_EQ(Tokens.size(), 10u) << Tokens;
15021503
EXPECT_TOKEN(Tokens[0], tok::kw_asm, TT_Unknown);
15031504
EXPECT_TOKEN(Tokens[1], tok::l_brace, TT_InlineASMBrace);
1504-
EXPECT_TOKEN(Tokens[4], tok::r_brace, TT_InlineASMBrace);
1505+
EXPECT_TOKEN(Tokens[3], tok::colon, TT_InlineASMColon);
1506+
EXPECT_TOKEN(Tokens[4], tok::colon, TT_InlineASMColon);
1507+
EXPECT_TOKEN(Tokens[6], tok::colon, TT_InlineASMColon);
1508+
EXPECT_TOKEN(Tokens[7], tok::r_brace, TT_InlineASMBrace);
1509+
1510+
Tokens = annotate("__asm(\n"
1511+
"\"a\":\n"
1512+
": x\n"
1513+
":);");
1514+
ASSERT_EQ(Tokens.size(), 10u) << Tokens;
1515+
EXPECT_TOKEN(Tokens[0], tok::kw_asm, TT_Unknown);
1516+
EXPECT_TOKEN(Tokens[3], tok::colon, TT_InlineASMColon);
1517+
EXPECT_TOKEN(Tokens[4], tok::colon, TT_InlineASMColon);
1518+
EXPECT_TOKEN(Tokens[6], tok::colon, TT_InlineASMColon);
1519+
1520+
Tokens = annotate("asm volatile (\n"
1521+
"\"a_label:\"\n"
1522+
":\n"
1523+
": x\n"
1524+
":);");
1525+
ASSERT_EQ(Tokens.size(), 11u) << Tokens;
1526+
EXPECT_TOKEN(Tokens[0], tok::kw_asm, TT_Unknown);
1527+
EXPECT_TOKEN(Tokens[4], tok::colon, TT_InlineASMColon);
1528+
EXPECT_TOKEN(Tokens[5], tok::colon, TT_InlineASMColon);
1529+
EXPECT_TOKEN(Tokens[7], tok::colon, TT_InlineASMColon);
1530+
1531+
Tokens = annotate("__asm__(\n"
1532+
"\"a_label:\"\n"
1533+
": x\n"
1534+
":\n"
1535+
": y);");
1536+
ASSERT_EQ(Tokens.size(), 11u) << Tokens;
1537+
EXPECT_TOKEN(Tokens[0], tok::kw_asm, TT_Unknown);
1538+
EXPECT_TOKEN(Tokens[3], tok::colon, TT_InlineASMColon);
1539+
EXPECT_TOKEN(Tokens[5], tok::colon, TT_InlineASMColon);
1540+
EXPECT_TOKEN(Tokens[6], tok::colon, TT_InlineASMColon);
1541+
1542+
Tokens = annotate("__asm volatile (\n"
1543+
"\"a_label:\"\n"
1544+
"\"a b c(%%x)\"\n"
1545+
":\n"
1546+
": x\n"
1547+
":);");
1548+
ASSERT_EQ(Tokens.size(), 12u) << Tokens;
1549+
EXPECT_TOKEN(Tokens[0], tok::kw_asm, TT_Unknown);
1550+
EXPECT_TOKEN(Tokens[5], tok::colon, TT_InlineASMColon);
1551+
EXPECT_TOKEN(Tokens[6], tok::colon, TT_InlineASMColon);
1552+
EXPECT_TOKEN(Tokens[8], tok::colon, TT_InlineASMColon);
1553+
1554+
Tokens = annotate("asm(\n"
1555+
"\"insn\"\n"
1556+
": \"=r\" (var1), \"=&r\" (value)\n"
1557+
":\n"
1558+
": \"memory\");");
1559+
ASSERT_EQ(Tokens.size(), 19u) << Tokens;
1560+
EXPECT_TOKEN(Tokens[0], tok::kw_asm, TT_Unknown);
1561+
EXPECT_TOKEN(Tokens[3], tok::colon, TT_InlineASMColon);
1562+
EXPECT_TOKEN(Tokens[13], tok::colon, TT_InlineASMColon);
1563+
EXPECT_TOKEN(Tokens[14], tok::colon, TT_InlineASMColon);
1564+
1565+
Tokens = annotate("__asm__ volatile (\n"
1566+
"\"ldr r1, [r0, %%[sym]]\"\n"
1567+
":\n"
1568+
": [sym] \"J\" (aaaaa(aaaa, aaaa))\n"
1569+
");");
1570+
ASSERT_EQ(Tokens.size(), 21u) << Tokens;
1571+
EXPECT_TOKEN(Tokens[0], tok::kw_asm, TT_Unknown);
1572+
EXPECT_TOKEN(Tokens[4], tok::colon, TT_InlineASMColon);
1573+
EXPECT_TOKEN(Tokens[5], tok::colon, TT_InlineASMColon);
1574+
EXPECT_TOKEN(Tokens[6], tok::l_square, TT_InlineASMSymbolicNameLSquare);
15051575
}
15061576

15071577
TEST_F(TokenAnnotatorTest, UnderstandsObjCBlock) {

compiler-rt/lib/sanitizer_common/sanitizer_bitvector.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,23 +321,23 @@ class TwoLevelBitVector {
321321
};
322322

323323
private:
324-
void check(uptr idx) const { CHECK_LE(idx, size()); }
324+
void check(uptr idx) const { CHECK_LT(idx, size()); }
325325

326326
uptr idx0(uptr idx) const {
327327
uptr res = idx / (BV::kSize * BV::kSize);
328-
CHECK_LE(res, kLevel1Size);
328+
CHECK_LT(res, kLevel1Size);
329329
return res;
330330
}
331331

332332
uptr idx1(uptr idx) const {
333333
uptr res = (idx / BV::kSize) % BV::kSize;
334-
CHECK_LE(res, BV::kSize);
334+
CHECK_LT(res, BV::kSize);
335335
return res;
336336
}
337337

338338
uptr idx2(uptr idx) const {
339339
uptr res = idx % BV::kSize;
340-
CHECK_LE(res, BV::kSize);
340+
CHECK_LT(res, BV::kSize);
341341
return res;
342342
}
343343

compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
# undef MAP_NORESERVE
5555
# define MAP_NORESERVE 0
5656
extern const Elf_Auxinfo *__elf_aux_vector;
57+
extern "C" int __sys_sigaction(int signum, const struct sigaction *act,
58+
struct sigaction *oldact);
5759
# endif
5860

5961
# if SANITIZER_NETBSD
@@ -93,12 +95,22 @@ SANITIZER_WEAK_ATTRIBUTE int real_sigaction(int signum, const void *act,
9395
void *oldact);
9496

9597
int internal_sigaction(int signum, const void *act, void *oldact) {
96-
# if !SANITIZER_GO
98+
# if SANITIZER_FREEBSD
99+
// On FreeBSD, call the sigaction syscall directly (part of libsys in FreeBSD
100+
// 15) since the libc version goes via a global interposing table. Due to
101+
// library initialization order the table can be relocated after the call to
102+
// InitializeDeadlySignals() which then crashes when dereferencing the
103+
// uninitialized pointer in libc.
104+
return __sys_sigaction(signum, (const struct sigaction *)act,
105+
(struct sigaction *)oldact);
106+
# else
107+
# if !SANITIZER_GO
97108
if (&real_sigaction)
98109
return real_sigaction(signum, act, oldact);
99-
# endif
110+
# endif
100111
return sigaction(signum, (const struct sigaction *)act,
101112
(struct sigaction *)oldact);
113+
# endif
102114
}
103115

104116
void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,

compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,17 @@ const uptr kAllocatorSpace = ~(uptr)0;
6969
const uptr kAllocatorSize = 0x2000000000ULL; // 128G.
7070
static const u64 kAddressSpaceSize = 1ULL << 38;
7171
typedef VeryDenseSizeClassMap SizeClassMap;
72-
#else
72+
# elif SANITIZER_APPLE
7373
static const uptr kAllocatorSpace = 0x700000000000ULL;
7474
static const uptr kAllocatorSize = 0x010000000000ULL; // 1T.
7575
static const u64 kAddressSpaceSize = 1ULL << 47;
7676
typedef DefaultSizeClassMap SizeClassMap;
77-
#endif
77+
# else
78+
static const uptr kAllocatorSpace = 0x500000000000ULL;
79+
static const uptr kAllocatorSize = 0x010000000000ULL; // 1T.
80+
static const u64 kAddressSpaceSize = 1ULL << 47;
81+
typedef DefaultSizeClassMap SizeClassMap;
82+
# endif
7883

7984
template <typename AddressSpaceViewTy>
8085
struct AP64 { // Allocator Params. Short name for shorter demangled names..

compiler-rt/test/dfsan/sscanf.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %clang_dfsan %s -o %t && %run %t
2+
// XFAIL: *
3+
4+
#include <assert.h>
5+
#include <stdio.h>
6+
7+
int main(int argc, char *argv[]) {
8+
char buf[256] = "10000000000-100000000000 rw-p 00000000 00:00 0";
9+
long rss = 0;
10+
// This test exposes a bug in DFSan's sscanf, that leads to flakiness
11+
// in release_shadow_space.c (see
12+
// https://github.com/llvm/llvm-project/issues/91287)
13+
if (sscanf(buf, "Garbage text before, %ld, Garbage text after", &rss) == 1) {
14+
printf("Error: matched %ld\n", rss);
15+
return 1;
16+
}
17+
18+
return 0;
19+
}

libc/src/stdlib/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ add_entrypoint_object(
416416
libc.src.__support.OSUtil.osutil
417417
)
418418

419+
# TODO: Move all exit functions to linux specific
420+
421+
if (TARGET libc.src.__support.threads.mutex)
419422
add_object_library(
420423
exit_handler
421424
SRCS
@@ -432,6 +435,7 @@ add_object_library(
432435
libc.src.__support.fixedvector
433436
libc.src.__support.threads.mutex
434437
)
438+
endif()
435439

436440
add_entrypoint_object(
437441
atexit

0 commit comments

Comments
 (0)