Skip to content

Commit a103b8d

Browse files
authored
Merge branch 'main' into fix-147333
2 parents b8f51c5 + 98262e5 commit a103b8d

File tree

5 files changed

+98
-20
lines changed

5 files changed

+98
-20
lines changed

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,34 +1182,43 @@ void UnwrappedLineParser::parsePPDefine() {
11821182
if (MaybeIncludeGuard && !eof())
11831183
IncludeGuard = IG_Rejected;
11841184

1185-
if (FormatTok->Tok.getKind() == tok::l_paren &&
1186-
!FormatTok->hasWhitespaceBefore()) {
1185+
if (FormatTok->is(tok::l_paren) && !FormatTok->hasWhitespaceBefore())
11871186
parseParens();
1188-
}
11891187
if (Style.IndentPPDirectives != FormatStyle::PPDIS_None)
11901188
Line->Level += PPBranchLevel + 1;
11911189
addUnwrappedLine();
11921190
++Line->Level;
11931191

11941192
Line->PPLevel = PPBranchLevel + (IncludeGuard == IG_Defined ? 0 : 1);
11951193
assert((int)Line->PPLevel >= 0);
1194+
1195+
if (eof())
1196+
return;
1197+
11961198
Line->InMacroBody = true;
11971199

1198-
if (Style.SkipMacroDefinitionBody) {
1199-
while (!eof()) {
1200-
FormatTok->Finalized = true;
1201-
FormatTok = Tokens->getNextToken();
1202-
}
1203-
addUnwrappedLine();
1200+
if (!Style.SkipMacroDefinitionBody) {
1201+
// Errors during a preprocessor directive can only affect the layout of the
1202+
// preprocessor directive, and thus we ignore them. An alternative approach
1203+
// would be to use the same approach we use on the file level (no
1204+
// re-indentation if there was a structural error) within the macro
1205+
// definition.
1206+
parseFile();
12041207
return;
12051208
}
12061209

1207-
// Errors during a preprocessor directive can only affect the layout of the
1208-
// preprocessor directive, and thus we ignore them. An alternative approach
1209-
// would be to use the same approach we use on the file level (no
1210-
// re-indentation if there was a structural error) within the macro
1211-
// definition.
1212-
parseFile();
1210+
if (auto *Prev = Tokens->getPreviousToken(); Prev->is(tok::comment) &&
1211+
Prev->NewlinesBefore > 0 &&
1212+
!Prev->HasUnescapedNewline) {
1213+
Prev->Finalized = true;
1214+
}
1215+
1216+
do {
1217+
FormatTok->Finalized = true;
1218+
FormatTok = Tokens->getNextToken();
1219+
} while (!eof());
1220+
1221+
addUnwrappedLine();
12131222
}
12141223

12151224
void UnwrappedLineParser::parsePPPragma() {

clang/unittests/Format/FormatTest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26022,6 +26022,10 @@ TEST_F(FormatTest, SkipMacroDefinitionBody) {
2602226022
" A a \\\n "
2602326023
" A a",
2602426024
Style);
26025+
verifyNoChange("#define MY_MACRO \\\n"
26026+
" /* comment */ \\\n"
26027+
" 1",
26028+
Style);
2602526029
}
2602626030

2602726031
TEST_F(FormatTest, VeryLongNamespaceCommentSplit) {
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// RUN: llvm-tblgen -gen-disassembler -I %p/../../../include %s | FileCheck %s
2+
3+
include "llvm/Target/Target.td"
4+
5+
class Enc {
6+
int Size = 2;
7+
bits<16> Inst;
8+
}
9+
10+
class EncSHIFT<bits<2> opc> : Enc {
11+
bits<6> shamt;
12+
let Inst{15...14} = {0, 0};
13+
let Inst{13...12} = opc;
14+
let Inst{11...6} = shamt;
15+
}
16+
17+
class EncNOP<bits<2> opc> : Enc {
18+
let Inst{15...14} = {0, 0};
19+
let Inst{13...12} = opc;
20+
let Inst{11...6} = {0, 0, 0, 0, 0, 0};
21+
}
22+
23+
def ShAmtOp : Operand<i32> {
24+
let DecoderMethod = "decodeShAmt";
25+
let hasCompleteDecoder = false;
26+
}
27+
28+
class I<dag out_ops, dag in_ops> : Instruction {
29+
let InOperandList = in_ops;
30+
let OutOperandList = out_ops;
31+
}
32+
33+
// CHECK: /* 0 */ MCD::OPC_ExtractField, 12, 4, // Inst{15-12} ...
34+
// CHECK-NEXT: /* 3 */ MCD::OPC_FilterValue, 0, 14, 0, // Skip to: 21
35+
// CHECK-NEXT: /* 7 */ MCD::OPC_CheckField, 6, 6, 0, 4, 0, // Skip to: 17
36+
// CHECK-NEXT: /* 13 */ MCD::OPC_Decode, {{[0-9]+}}, 2, 0, // Opcode: {{.*}}:NOP
37+
// CHECK-NEXT: /* 17 */ MCD::OPC_TryDecodeOrFail, {{[0-9]+}}, 2, 1,
38+
// CHECK-NEXT: /* 21 */ MCD::OPC_FilterValue, 1, 14, 0, // Skip to: 39
39+
// CHECK-NEXT: /* 25 */ MCD::OPC_CheckField, 6, 6, 0, 4, 0, // Skip to: 35
40+
// CHECK-NEXT: /* 31 */ MCD::OPC_Decode, {{[0-9]+}}, 2, 0, // Opcode: {{.*}}:NOP
41+
// CHECK-NEXT: /* 35 */ MCD::OPC_TryDecodeOrFail, {{[0-9]+}}, 2, 1,
42+
// CHECK-NEXT: /* 39 */ MCD::OPC_FilterValue, 2, 14, 0, // Skip to: 57
43+
// CHECK-NEXT: /* 43 */ MCD::OPC_CheckField, 6, 6, 0, 4, 0, // Skip to: 53
44+
// CHECK-NEXT: /* 49 */ MCD::OPC_Decode, {{[0-9]+}}, 2, 0, // Opcode: {{.*}}:NOP
45+
// CHECK-NEXT: /* 53 */ MCD::OPC_TryDecodeOrFail, {{[0-9]+}}, 2, 1,
46+
// CHECK-NEXT: /* 57 */ MCD::OPC_FilterValueOrFail, 3,
47+
// CHECK-NEXT: /* 59 */ MCD::OPC_CheckField, 6, 6, 0, 4, 0, // Skip to: 69
48+
// CHECK-NEXT: /* 65 */ MCD::OPC_Decode, {{[0-9]+}}, 2, 0, // Opcode: {{.*}}:NOP
49+
// CHECK-NEXT: /* 69 */ MCD::OPC_TryDecodeOrFail, {{[0-9]+}}, 2, 1,
50+
// CHECK-NEXT: /* 73 */ MCD::OPC_Fail,
51+
52+
class SHIFT<bits<2> opc> : I<(outs), (ins ShAmtOp:$shamt)>, EncSHIFT<opc>;
53+
def SHIFT0 : SHIFT<0>;
54+
def SHIFT1 : SHIFT<1>;
55+
def SHIFT2 : SHIFT<2>;
56+
def SHIFT3 : SHIFT<3>;
57+
58+
def NOP : I<(outs), (ins)>, EncNOP<0>;
59+
def : AdditionalEncoding<NOP>, EncNOP<1>;
60+
def : AdditionalEncoding<NOP>, EncNOP<2>;
61+
def : AdditionalEncoding<NOP>, EncNOP<3>;
62+
63+
def II : InstrInfo;
64+
65+
def MyTarget : Target {
66+
let InstructionSet = II;
67+
}

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,7 +2495,9 @@ void DecoderEmitter::parseInstructionEncodings() {
24952495
++NumEncodingsOmitted;
24962496
continue;
24972497
}
2498+
unsigned EncodingID = Encodings.size();
24982499
Encodings.emplace_back(EncodingDef, &Target.getInstruction(InstDef));
2500+
EncodingIDsByHwMode[DefaultMode].push_back(EncodingID);
24992501
}
25002502

25012503
// Do some statistics.

orc-rt/lib/executor/RTTI.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file is a part of the ORC runtime support library.
10-
//
11-
// Note:
12-
// This source file was adapted from lib/Support/ExtensibleRTTI.cpp, however
13-
// the data structures are not shared and the code need not be kept in sync.
9+
// Contains the implementation of APIs in the orc-rt/RTTI.h header.
1410
//
1511
//===----------------------------------------------------------------------===//
1612

0 commit comments

Comments
 (0)