Skip to content

Commit 40a9cb2

Browse files
authored
Merge branch 'main' into update-qual-wg-docs
2 parents 52d8efc + be4cd9f commit 40a9cb2

File tree

479 files changed

+4045
-1335
lines changed

Some content is hidden

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

479 files changed

+4045
-1335
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5545,7 +5545,6 @@ bool Compiler<Emitter>::visitCXXForRangeStmt(const CXXForRangeStmt *S) {
55455545
const Stmt *BeginStmt = S->getBeginStmt();
55465546
const Stmt *RangeStmt = S->getRangeStmt();
55475547
const Stmt *EndStmt = S->getEndStmt();
5548-
const VarDecl *LoopVar = S->getLoopVariable();
55495548

55505549
LabelTy EndLabel = this->getLabel();
55515550
LabelTy CondLabel = this->getLabel();
@@ -5570,7 +5569,7 @@ bool Compiler<Emitter>::visitCXXForRangeStmt(const CXXForRangeStmt *S) {
55705569
if (!this->jumpFalse(EndLabel))
55715570
return false;
55725571

5573-
if (!this->visitVarDecl(LoopVar))
5572+
if (!this->visitDeclStmt(S->getLoopVarStmt(), /*EvaluateConditionDecl=*/true))
55745573
return false;
55755574

55765575
// Body.

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,9 @@ static bool interp__builtin_overflowop(InterpState &S, CodePtr OpPC,
861861

862862
// Write Result to ResultPtr and put Overflow on the stack.
863863
assignInteger(S, ResultPtr, ResultT, Result);
864-
ResultPtr.initialize();
864+
if (ResultPtr.canBeInitialized())
865+
ResultPtr.initialize();
866+
865867
assert(Call->getDirectCallee()->getReturnType()->isBooleanType());
866868
S.Stk.push<Boolean>(Overflow);
867869
return true;

clang/lib/AST/ByteCode/Pointer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const {
207207

208208
bool UsePath = true;
209209
if (const ValueDecl *VD = getDeclDesc()->asValueDecl();
210-
VD && VD->getType()->isLValueReferenceType())
210+
VD && VD->getType()->isReferenceType())
211211
UsePath = false;
212212

213213
// Build the path into the object.

clang/lib/Format/Format.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3582,7 +3582,7 @@ tooling::Replacements sortJavaImports(const FormatStyle &Style, StringRef Code,
35823582
ImportsInBlock.push_back(
35833583
{Identifier, Line, Prev, AssociatedCommentLines, IsStatic});
35843584
AssociatedCommentLines.clear();
3585-
} else if (Trimmed.size() > 0 && !ImportsInBlock.empty()) {
3585+
} else if (!Trimmed.empty() && !ImportsInBlock.empty()) {
35863586
// Associating comments within the imports with the nearest import below
35873587
AssociatedCommentLines.push_back(Line);
35883588
}

clang/lib/Format/FormatTokenLexer.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,8 +1371,7 @@ FormatToken *FormatTokenLexer::getNextToken() {
13711371
} else if (FormatTok->TokenText == "``") {
13721372
FormatTok->Tok.setIdentifierInfo(nullptr);
13731373
FormatTok->Tok.setKind(tok::hashhash);
1374-
} else if (Tokens.size() > 0 &&
1375-
Tokens.back()->is(Keywords.kw_apostrophe) &&
1374+
} else if (!Tokens.empty() && Tokens.back()->is(Keywords.kw_apostrophe) &&
13761375
NumberBase.match(FormatTok->TokenText, &Matches)) {
13771376
// In Verilog in a based number literal like `'b10`, there may be
13781377
// whitespace between `'b` and `10`. Therefore we handle the base and
@@ -1420,7 +1419,7 @@ FormatToken *FormatTokenLexer::getNextToken() {
14201419
tryParseJavaTextBlock();
14211420
}
14221421

1423-
if (Style.isVerilog() && Tokens.size() > 0 &&
1422+
if (Style.isVerilog() && !Tokens.empty() &&
14241423
Tokens.back()->is(TT_VerilogNumberBase) &&
14251424
FormatTok->Tok.isOneOf(tok::identifier, tok::question)) {
14261425
// Mark the number following a base like `'h?a0` as a number.
@@ -1454,9 +1453,9 @@ FormatToken *FormatTokenLexer::getNextToken() {
14541453
if (Style.isCpp()) {
14551454
auto *Identifier = FormatTok->Tok.getIdentifierInfo();
14561455
auto it = Macros.find(Identifier);
1457-
if (!(Tokens.size() > 0 && Tokens.back()->Tok.getIdentifierInfo() &&
1458-
Tokens.back()->Tok.getIdentifierInfo()->getPPKeywordID() ==
1459-
tok::pp_define) &&
1456+
if ((Tokens.empty() || !Tokens.back()->Tok.getIdentifierInfo() ||
1457+
Tokens.back()->Tok.getIdentifierInfo()->getPPKeywordID() !=
1458+
tok::pp_define) &&
14601459
it != Macros.end()) {
14611460
FormatTok->setType(it->second);
14621461
if (it->second == TT_IfMacro) {

clang/lib/Format/QualifierAlignmentFixer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ bool isPossibleMacro(const FormatToken *Tok) {
640640
return false;
641641

642642
const auto Text = Tok->TokenText;
643-
assert(Text.size() > 0);
643+
assert(!Text.empty());
644644

645645
// T,K,U,V likely could be template arguments
646646
if (Text.size() == 1)

clang/lib/Format/UnwrappedLineFormatter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,6 @@ class LineJoiner {
223223
tryFitMultipleLinesInOne(LevelIndentTracker &IndentTracker,
224224
ArrayRef<AnnotatedLine *>::const_iterator I,
225225
ArrayRef<AnnotatedLine *>::const_iterator E) {
226-
const unsigned Indent = IndentTracker.getIndent();
227-
228226
// Can't join the last line with anything.
229227
if (I + 1 == E)
230228
return 0;
@@ -240,6 +238,7 @@ class LineJoiner {
240238
return 0;
241239
}
242240

241+
const auto Indent = IndentTracker.getIndent();
243242
if (Style.ColumnLimit > 0 && Indent > Style.ColumnLimit)
244243
return 0;
245244

@@ -1090,7 +1089,7 @@ class LineFormatter {
10901089
const FormatToken *LBrace = State.NextToken->getPreviousNonComment();
10911090
bool HasLBrace = LBrace && LBrace->is(tok::l_brace) && LBrace->is(BK_Block);
10921091
FormatToken &Previous = *State.NextToken->Previous;
1093-
if (Previous.Children.size() == 0 || (!HasLBrace && !LBrace->MacroParent)) {
1092+
if (Previous.Children.empty() || (!HasLBrace && !LBrace->MacroParent)) {
10941093
// The previous token does not open a block. Nothing to do. We don't
10951094
// assert so that we can simply call this function for all tokens.
10961095
return true;

clang/lib/Format/WhitespaceManager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
314314

315315
for (unsigned i = Start; i != End; ++i) {
316316
auto &CurrentChange = Changes[i];
317-
if (ScopeStack.size() != 0 &&
317+
if (!ScopeStack.empty() &&
318318
CurrentChange.indentAndNestingLevel() <
319319
Changes[ScopeStack.back()].indentAndNestingLevel()) {
320320
ScopeStack.pop_back();
@@ -332,7 +332,7 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
332332
ScopeStack.push_back(i);
333333
}
334334

335-
bool InsideNestedScope = ScopeStack.size() != 0;
335+
bool InsideNestedScope = !ScopeStack.empty();
336336
bool ContinuedStringLiteral = i > Start &&
337337
CurrentChange.Tok->is(tok::string_literal) &&
338338
Changes[i - 1].Tok->is(tok::string_literal);
@@ -1048,7 +1048,7 @@ void WhitespaceManager::alignChainedConditionals() {
10481048
return C.Tok->is(TT_ConditionalExpr) &&
10491049
((C.Tok->is(tok::question) && !C.NewlinesBefore) ||
10501050
(C.Tok->is(tok::colon) && C.Tok->Next &&
1051-
(C.Tok->Next->FakeLParens.size() == 0 ||
1051+
(C.Tok->Next->FakeLParens.empty() ||
10521052
C.Tok->Next->FakeLParens.back() != prec::Conditional)));
10531053
},
10541054
Changes, /*StartAt=*/0);
@@ -1057,7 +1057,7 @@ void WhitespaceManager::alignChainedConditionals() {
10571057
FormatToken *Previous = C.Tok->getPreviousNonComment();
10581058
return C.NewlinesBefore && Previous && Previous->is(TT_ConditionalExpr) &&
10591059
(Previous->is(tok::colon) &&
1060-
(C.Tok->FakeLParens.size() == 0 ||
1060+
(C.Tok->FakeLParens.empty() ||
10611061
C.Tok->FakeLParens.back() != prec::Conditional));
10621062
};
10631063
// Ensure we keep alignment of wrapped operands with non-wrapped operands

clang/lib/Serialization/ASTReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9682,7 +9682,7 @@ ModuleFile *ASTReader::getLocalModuleFile(ModuleFile &M, unsigned ID) const {
96829682
// It's a prefix (preamble, PCH, ...). Look it up by index.
96839683
int IndexFromEnd = static_cast<int>(ID >> 1);
96849684
assert(IndexFromEnd && "got reference to unknown module file");
9685-
return getModuleManager().pch_modules().end()[-static_cast<int>(IndexFromEnd)];
9685+
return getModuleManager().pch_modules().end()[-IndexFromEnd];
96869686
}
96879687
}
96889688

clang/test/AST/ByteCode/builtin-functions.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,4 +1753,12 @@ namespace I128Mul {
17531753
}
17541754
#endif
17551755

1756+
namespace InitParam {
1757+
constexpr int foo(int a) {
1758+
__builtin_mul_overflow(20, 10, &a);
1759+
return a;
1760+
}
1761+
static_assert(foo(10) == 200);
1762+
}
1763+
17561764
#endif

0 commit comments

Comments
 (0)