Skip to content

Commit c0b7bd7

Browse files
authored
Merge branch 'main' into inbelic/gep
2 parents 132af9e + f76c132 commit c0b7bd7

File tree

111 files changed

+2914
-659
lines changed

Some content is hidden

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

111 files changed

+2914
-659
lines changed

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,8 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
640640
Insts[1].addOperand(MCOperand::createImm(0));
641641
Insts[1].addOperand(MCOperand::createImm(0));
642642
setOperandToSymbolRef(Insts[1], /* OpNum */ 2, Target, 0, Ctx,
643-
ELF::R_AARCH64_ADD_ABS_LO12_NC);
643+
isLDRXl(LDRInst) ? ELF::R_AARCH64_LDST64_ABS_LO12_NC
644+
: ELF::R_AARCH64_LDST32_ABS_LO12_NC);
644645
return Insts;
645646
}
646647

clang/include/clang/Basic/IdentifierTable.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,57 @@ class LangOptions;
4646
class MultiKeywordSelector;
4747
class SourceLocation;
4848

49+
/// Constants for TokenKinds.def
50+
enum TokenKey : unsigned {
51+
KEYC99 = 0x1,
52+
KEYCXX = 0x2,
53+
KEYCXX11 = 0x4,
54+
KEYGNU = 0x8,
55+
KEYMS = 0x10,
56+
BOOLSUPPORT = 0x20,
57+
KEYALTIVEC = 0x40,
58+
KEYNOCXX = 0x80,
59+
KEYBORLAND = 0x100,
60+
KEYOPENCLC = 0x200,
61+
KEYC23 = 0x400,
62+
KEYNOMS18 = 0x800,
63+
KEYNOOPENCL = 0x1000,
64+
WCHARSUPPORT = 0x2000,
65+
HALFSUPPORT = 0x4000,
66+
CHAR8SUPPORT = 0x8000,
67+
KEYOBJC = 0x10000,
68+
KEYZVECTOR = 0x20000,
69+
KEYCOROUTINES = 0x40000,
70+
KEYMODULES = 0x80000,
71+
KEYCXX20 = 0x100000,
72+
KEYOPENCLCXX = 0x200000,
73+
KEYMSCOMPAT = 0x400000,
74+
KEYSYCL = 0x800000,
75+
KEYCUDA = 0x1000000,
76+
KEYZOS = 0x2000000,
77+
KEYNOZOS = 0x4000000,
78+
KEYHLSL = 0x8000000,
79+
KEYFIXEDPOINT = 0x10000000,
80+
KEYMAX = KEYFIXEDPOINT, // The maximum key
81+
KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX20,
82+
KEYALL = (KEYMAX | (KEYMAX - 1)) & ~KEYNOMS18 & ~KEYNOOPENCL &
83+
~KEYNOZOS // KEYNOMS18, KEYNOOPENCL, KEYNOZOS are excluded.
84+
};
85+
86+
/// How a keyword is treated in the selected standard. This enum is ordered
87+
/// intentionally so that the value that 'wins' is the most 'permissive'.
88+
enum KeywordStatus {
89+
KS_Unknown, // Not yet calculated. Used when figuring out the status.
90+
KS_Disabled, // Disabled
91+
KS_Future, // Is a keyword in future standard
92+
KS_Extension, // Is an extension
93+
KS_Enabled, // Enabled
94+
};
95+
96+
/// Translates flags as specified in TokenKinds.def into keyword status
97+
/// in the given language standard.
98+
KeywordStatus getKeywordStatus(const LangOptions &LangOpts, unsigned Flags);
99+
49100
enum class ReservedIdentifierStatus {
50101
NotReserved = 0,
51102
StartsWithUnderscoreAtGlobalScope,

clang/include/clang/Basic/SourceManager.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,10 +1409,15 @@ class SourceManager : public RefCountedBase<SourceManager> {
14091409
/// before calling this method.
14101410
unsigned getColumnNumber(FileID FID, unsigned FilePos,
14111411
bool *Invalid = nullptr) const;
1412+
unsigned getColumnNumber(SourceLocation Loc, bool *Invalid = nullptr) const;
14121413
unsigned getSpellingColumnNumber(SourceLocation Loc,
1413-
bool *Invalid = nullptr) const;
1414+
bool *Invalid = nullptr) const {
1415+
return getColumnNumber(getSpellingLoc(Loc), Invalid);
1416+
}
14141417
unsigned getExpansionColumnNumber(SourceLocation Loc,
1415-
bool *Invalid = nullptr) const;
1418+
bool *Invalid = nullptr) const {
1419+
return getColumnNumber(getExpansionLoc(Loc), Invalid);
1420+
}
14161421
unsigned getPresumedColumnNumber(SourceLocation Loc,
14171422
bool *Invalid = nullptr) const;
14181423

@@ -1423,8 +1428,15 @@ class SourceManager : public RefCountedBase<SourceManager> {
14231428
/// MemoryBuffer, so this is not cheap: use only when about to emit a
14241429
/// diagnostic.
14251430
unsigned getLineNumber(FileID FID, unsigned FilePos, bool *Invalid = nullptr) const;
1426-
unsigned getSpellingLineNumber(SourceLocation Loc, bool *Invalid = nullptr) const;
1427-
unsigned getExpansionLineNumber(SourceLocation Loc, bool *Invalid = nullptr) const;
1431+
unsigned getLineNumber(SourceLocation Loc, bool *Invalid = nullptr) const;
1432+
unsigned getSpellingLineNumber(SourceLocation Loc,
1433+
bool *Invalid = nullptr) const {
1434+
return getLineNumber(getSpellingLoc(Loc), Invalid);
1435+
}
1436+
unsigned getExpansionLineNumber(SourceLocation Loc,
1437+
bool *Invalid = nullptr) const {
1438+
return getLineNumber(getExpansionLoc(Loc), Invalid);
1439+
}
14281440
unsigned getPresumedLineNumber(SourceLocation Loc, bool *Invalid = nullptr) const;
14291441

14301442
/// Return the filename or buffer identifier of the buffer the

clang/lib/Basic/IdentifierTable.cpp

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -77,57 +77,6 @@ IdentifierTable::IdentifierTable(const LangOptions &LangOpts,
7777
// Language Keyword Implementation
7878
//===----------------------------------------------------------------------===//
7979

80-
// Constants for TokenKinds.def
81-
namespace {
82-
83-
enum TokenKey : unsigned {
84-
KEYC99 = 0x1,
85-
KEYCXX = 0x2,
86-
KEYCXX11 = 0x4,
87-
KEYGNU = 0x8,
88-
KEYMS = 0x10,
89-
BOOLSUPPORT = 0x20,
90-
KEYALTIVEC = 0x40,
91-
KEYNOCXX = 0x80,
92-
KEYBORLAND = 0x100,
93-
KEYOPENCLC = 0x200,
94-
KEYC23 = 0x400,
95-
KEYNOMS18 = 0x800,
96-
KEYNOOPENCL = 0x1000,
97-
WCHARSUPPORT = 0x2000,
98-
HALFSUPPORT = 0x4000,
99-
CHAR8SUPPORT = 0x8000,
100-
KEYOBJC = 0x10000,
101-
KEYZVECTOR = 0x20000,
102-
KEYCOROUTINES = 0x40000,
103-
KEYMODULES = 0x80000,
104-
KEYCXX20 = 0x100000,
105-
KEYOPENCLCXX = 0x200000,
106-
KEYMSCOMPAT = 0x400000,
107-
KEYSYCL = 0x800000,
108-
KEYCUDA = 0x1000000,
109-
KEYZOS = 0x2000000,
110-
KEYNOZOS = 0x4000000,
111-
KEYHLSL = 0x8000000,
112-
KEYFIXEDPOINT = 0x10000000,
113-
KEYMAX = KEYFIXEDPOINT, // The maximum key
114-
KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX20,
115-
KEYALL = (KEYMAX | (KEYMAX - 1)) & ~KEYNOMS18 & ~KEYNOOPENCL &
116-
~KEYNOZOS // KEYNOMS18, KEYNOOPENCL, KEYNOZOS are excluded.
117-
};
118-
119-
/// How a keyword is treated in the selected standard. This enum is ordered
120-
/// intentionally so that the value that 'wins' is the most 'permissive'.
121-
enum KeywordStatus {
122-
KS_Unknown, // Not yet calculated. Used when figuring out the status.
123-
KS_Disabled, // Disabled
124-
KS_Future, // Is a keyword in future standard
125-
KS_Extension, // Is an extension
126-
KS_Enabled, // Enabled
127-
};
128-
129-
} // namespace
130-
13180
// This works on a single TokenKey flag and checks the LangOpts to get the
13281
// KeywordStatus based exclusively on this flag, so that it can be merged in
13382
// getKeywordStatus. Most should be enabled/disabled, but some might imply
@@ -220,9 +169,7 @@ static KeywordStatus getKeywordStatusHelper(const LangOptions &LangOpts,
220169
}
221170
}
222171

223-
/// Translates flags as specified in TokenKinds.def into keyword status
224-
/// in the given language standard.
225-
static KeywordStatus getKeywordStatus(const LangOptions &LangOpts,
172+
KeywordStatus clang::getKeywordStatus(const LangOptions &LangOpts,
226173
unsigned Flags) {
227174
// KEYALL means always enabled, so special case this one.
228175
if (Flags == KEYALL) return KS_Enabled;

clang/lib/Basic/SourceManager.cpp

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,17 +1159,11 @@ static bool isInvalid(LocType Loc, bool *Invalid) {
11591159
return MyInvalid;
11601160
}
11611161

1162-
unsigned SourceManager::getSpellingColumnNumber(SourceLocation Loc,
1163-
bool *Invalid) const {
1164-
if (isInvalid(Loc, Invalid)) return 0;
1165-
FileIDAndOffset LocInfo = getDecomposedSpellingLoc(Loc);
1166-
return getColumnNumber(LocInfo.first, LocInfo.second, Invalid);
1167-
}
1168-
1169-
unsigned SourceManager::getExpansionColumnNumber(SourceLocation Loc,
1170-
bool *Invalid) const {
1162+
unsigned SourceManager::getColumnNumber(SourceLocation Loc,
1163+
bool *Invalid) const {
1164+
assert(Loc.isFileID());
11711165
if (isInvalid(Loc, Invalid)) return 0;
1172-
FileIDAndOffset LocInfo = getDecomposedExpansionLoc(Loc);
1166+
FileIDAndOffset LocInfo = getDecomposedLoc(Loc);
11731167
return getColumnNumber(LocInfo.first, LocInfo.second, Invalid);
11741168
}
11751169

@@ -1367,18 +1361,13 @@ unsigned SourceManager::getLineNumber(FileID FID, unsigned FilePos,
13671361
return LineNo;
13681362
}
13691363

1370-
unsigned SourceManager::getSpellingLineNumber(SourceLocation Loc,
1371-
bool *Invalid) const {
1372-
if (isInvalid(Loc, Invalid)) return 0;
1373-
FileIDAndOffset LocInfo = getDecomposedSpellingLoc(Loc);
1374-
return getLineNumber(LocInfo.first, LocInfo.second);
1375-
}
1376-
unsigned SourceManager::getExpansionLineNumber(SourceLocation Loc,
1377-
bool *Invalid) const {
1364+
unsigned SourceManager::getLineNumber(SourceLocation Loc, bool *Invalid) const {
1365+
assert(Loc.isFileID());
13781366
if (isInvalid(Loc, Invalid)) return 0;
1379-
FileIDAndOffset LocInfo = getDecomposedExpansionLoc(Loc);
1367+
FileIDAndOffset LocInfo = getDecomposedLoc(Loc);
13801368
return getLineNumber(LocInfo.first, LocInfo.second);
13811369
}
1370+
13821371
unsigned SourceManager::getPresumedLineNumber(SourceLocation Loc,
13831372
bool *Invalid) const {
13841373
PresumedLoc PLoc = getPresumedLoc(Loc);

clang/lib/Format/UnwrappedLineFormatter.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ class LineJoiner {
285285
if (Tok && Tok->is(tok::kw_typedef))
286286
Tok = Tok->getNextNonComment();
287287
if (Tok && Tok->isOneOf(tok::kw_class, tok::kw_struct, tok::kw_union,
288-
tok::kw_extern, Keywords.kw_interface)) {
288+
tok::kw_extern, Keywords.kw_interface,
289+
Keywords.kw_record)) {
289290
return !Style.BraceWrapping.SplitEmptyRecord && EmptyBlock
290291
? tryMergeSimpleBlock(I, E, Limit)
291292
: 0;
@@ -498,7 +499,8 @@ class LineJoiner {
498499
ShouldMerge = Style.AllowShortEnumsOnASingleLine;
499500
} else if (TheLine->Last->is(TT_CompoundRequirementLBrace)) {
500501
ShouldMerge = Style.AllowShortCompoundRequirementOnASingleLine;
501-
} else if (TheLine->Last->isOneOf(TT_ClassLBrace, TT_StructLBrace)) {
502+
} else if (TheLine->Last->isOneOf(TT_ClassLBrace, TT_StructLBrace,
503+
TT_RecordLBrace)) {
502504
// NOTE: We use AfterClass (whereas AfterStruct exists) for both classes
503505
// and structs, but it seems that wrapping is still handled correctly
504506
// elsewhere.
@@ -507,7 +509,7 @@ class LineJoiner {
507509
!Style.BraceWrapping.SplitEmptyRecord);
508510
} else if (TheLine->InPPDirective ||
509511
TheLine->First->isNoneOf(tok::kw_class, tok::kw_enum,
510-
tok::kw_struct)) {
512+
tok::kw_struct, Keywords.kw_record)) {
511513
// Try to merge a block with left brace unwrapped that wasn't yet
512514
// covered.
513515
ShouldMerge = !Style.BraceWrapping.AfterFunction ||

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,11 @@ static bool isIIFE(const UnwrappedLine &Line,
948948
}
949949

950950
static bool ShouldBreakBeforeBrace(const FormatStyle &Style,
951-
const FormatToken &InitialToken) {
951+
const FormatToken &InitialToken,
952+
const bool IsJavaRecord) {
953+
if (IsJavaRecord)
954+
return Style.BraceWrapping.AfterClass;
955+
952956
tok::TokenKind Kind = InitialToken.Tok.getKind();
953957
if (InitialToken.is(TT_NamespaceMacro))
954958
Kind = tok::kw_namespace;
@@ -3200,7 +3204,7 @@ void UnwrappedLineParser::parseNamespace() {
32003204
if (FormatTok->is(tok::l_brace)) {
32013205
FormatTok->setFinalizedType(TT_NamespaceLBrace);
32023206

3203-
if (ShouldBreakBeforeBrace(Style, InitialToken))
3207+
if (ShouldBreakBeforeBrace(Style, InitialToken, /*IsJavaRecord=*/false))
32043208
addUnwrappedLine();
32053209

32063210
unsigned AddLevels =
@@ -3865,7 +3869,7 @@ bool UnwrappedLineParser::parseEnum() {
38653869
}
38663870

38673871
if (!Style.AllowShortEnumsOnASingleLine &&
3868-
ShouldBreakBeforeBrace(Style, InitialToken)) {
3872+
ShouldBreakBeforeBrace(Style, InitialToken, /*IsJavaRecord=*/false)) {
38693873
addUnwrappedLine();
38703874
}
38713875
// Parse enum body.
@@ -4160,7 +4164,7 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr, bool IsJavaRecord) {
41604164
if (ParseAsExpr) {
41614165
parseChildBlock();
41624166
} else {
4163-
if (ShouldBreakBeforeBrace(Style, InitialToken))
4167+
if (ShouldBreakBeforeBrace(Style, InitialToken, IsJavaRecord))
41644168
addUnwrappedLine();
41654169

41664170
unsigned AddLevels = Style.IndentAccessModifiers ? 2u : 1u;

clang/unittests/Format/FormatTestJava.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,19 @@ TEST_F(FormatTestJava, TextBlock) {
848848
" Pat Q. Smith");
849849
}
850850

851+
TEST_F(FormatTestJava, BreakAfterRecord) {
852+
auto Style = getLLVMStyle(FormatStyle::LK_Java);
853+
Style.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_Never;
854+
Style.BreakBeforeBraces = FormatStyle::BS_Custom;
855+
Style.BraceWrapping.AfterClass = true;
856+
Style.BraceWrapping.SplitEmptyRecord = true;
857+
858+
verifyFormat("public record Foo(int i)\n"
859+
"{\n"
860+
"}",
861+
"public record Foo(int i) {}", Style);
862+
}
863+
851864
} // namespace
852865
} // namespace test
853866
} // namespace format

libc/src/__support/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ add_header_library(
161161
HDRS
162162
wctype_utils.h
163163
DEPENDS
164+
libc.hdr.types.wchar_t
164165
libc.hdr.types.wint_t
165166
)
166167

0 commit comments

Comments
 (0)