Skip to content

Commit 61e3690

Browse files
Merge branch 'main' into vinay-issue-119281
2 parents 9e7c2f8 + bb59eb8 commit 61e3690

File tree

223 files changed

+2588
-1329
lines changed

Some content is hidden

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

223 files changed

+2588
-1329
lines changed

clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class UnusedUsingDeclsCheck : public ClangTidyCheck {
5151
std::vector<UsingDeclContext> Contexts;
5252
llvm::SmallPtrSet<const Decl *, 32> UsingTargetDeclsCache;
5353

54-
StringRef RawStringHeaderFileExtensions;
5554
FileExtensionsSet HeaderFileExtensions;
5655
};
5756

clang/include/clang/AST/DeclTemplate.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,11 @@ class DefaultArgStorage {
367367
if (!isSet())
368368
ValueOrInherited = InheritedFrom;
369369
else if ([[maybe_unused]] auto *D =
370-
ValueOrInherited.template dyn_cast<ParmDecl *>()) {
370+
dyn_cast<ParmDecl *>(ValueOrInherited)) {
371371
assert(C.isSameDefaultTemplateArgument(D, InheritedFrom));
372372
ValueOrInherited =
373373
new (allocateDefaultArgStorageChain(C)) Chain{InheritedFrom, get()};
374-
} else if (auto *Inherited =
375-
ValueOrInherited.template dyn_cast<Chain *>()) {
374+
} else if (auto *Inherited = dyn_cast<Chain *>(ValueOrInherited)) {
376375
assert(C.isSameDefaultTemplateArgument(Inherited->PrevDeclWithDefaultArg,
377376
InheritedFrom));
378377
Inherited->PrevDeclWithDefaultArg = InheritedFrom;

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6194,60 +6194,67 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
61946194
return revisit(VD);
61956195
}
61966196

6197-
if (D != InitializingDecl) {
6198-
// Try to lazily visit (or emit dummy pointers for) declarations
6199-
// we haven't seen yet.
6200-
if (Ctx.getLangOpts().CPlusPlus) {
6201-
if (const auto *VD = dyn_cast<VarDecl>(D)) {
6202-
const auto typeShouldBeVisited = [&](QualType T) -> bool {
6203-
if (T.isConstant(Ctx.getASTContext()))
6204-
return true;
6205-
return T->isReferenceType();
6206-
};
6197+
// Avoid infinite recursion.
6198+
if (D == InitializingDecl)
6199+
return this->emitDummyPtr(D, E);
6200+
6201+
// Try to lazily visit (or emit dummy pointers for) declarations
6202+
// we haven't seen yet.
6203+
// For C.
6204+
if (!Ctx.getLangOpts().CPlusPlus) {
6205+
if (const auto *VD = dyn_cast<VarDecl>(D);
6206+
VD && VD->getAnyInitializer() &&
6207+
VD->getType().isConstant(Ctx.getASTContext()) && !VD->isWeak())
6208+
return revisit(VD);
6209+
return this->emitDummyPtr(D, E);
6210+
}
62076211

6208-
// DecompositionDecls are just proxies for us.
6209-
if (isa<DecompositionDecl>(VD))
6210-
return revisit(VD);
6211-
6212-
if ((VD->hasGlobalStorage() || VD->isStaticDataMember()) &&
6213-
typeShouldBeVisited(VD->getType())) {
6214-
if (const Expr *Init = VD->getAnyInitializer();
6215-
Init && !Init->isValueDependent()) {
6216-
// Whether or not the evaluation is successul doesn't really matter
6217-
// here -- we will create a global variable in any case, and that
6218-
// will have the state of initializer evaluation attached.
6219-
APValue V;
6220-
SmallVector<PartialDiagnosticAt> Notes;
6221-
(void)Init->EvaluateAsInitializer(V, Ctx.getASTContext(), VD, Notes,
6222-
true);
6223-
return this->visitDeclRef(D, E);
6224-
}
6225-
return revisit(VD);
6226-
}
6212+
// ... and C++.
6213+
const auto *VD = dyn_cast<VarDecl>(D);
6214+
if (!VD)
6215+
return this->emitDummyPtr(D, E);
62276216

6228-
// FIXME: The evaluateValue() check here is a little ridiculous, since
6229-
// it will ultimately call into Context::evaluateAsInitializer(). In
6230-
// other words, we're evaluating the initializer, just to know if we can
6231-
// evaluate the initializer.
6232-
if (VD->isLocalVarDecl() && typeShouldBeVisited(VD->getType()) &&
6233-
VD->getInit() && !VD->getInit()->isValueDependent()) {
6217+
const auto typeShouldBeVisited = [&](QualType T) -> bool {
6218+
if (T.isConstant(Ctx.getASTContext()))
6219+
return true;
6220+
return T->isReferenceType();
6221+
};
62346222

6235-
if (VD->evaluateValue())
6236-
return revisit(VD);
6223+
// DecompositionDecls are just proxies for us.
6224+
if (isa<DecompositionDecl>(VD))
6225+
return revisit(VD);
6226+
6227+
if ((VD->hasGlobalStorage() || VD->isStaticDataMember()) &&
6228+
typeShouldBeVisited(VD->getType())) {
6229+
if (const Expr *Init = VD->getAnyInitializer();
6230+
Init && !Init->isValueDependent()) {
6231+
// Whether or not the evaluation is successul doesn't really matter
6232+
// here -- we will create a global variable in any case, and that
6233+
// will have the state of initializer evaluation attached.
6234+
APValue V;
6235+
SmallVector<PartialDiagnosticAt> Notes;
6236+
(void)Init->EvaluateAsInitializer(V, Ctx.getASTContext(), VD, Notes,
6237+
true);
6238+
return this->visitDeclRef(D, E);
6239+
}
6240+
return revisit(VD);
6241+
}
6242+
6243+
// FIXME: The evaluateValue() check here is a little ridiculous, since
6244+
// it will ultimately call into Context::evaluateAsInitializer(). In
6245+
// other words, we're evaluating the initializer, just to know if we can
6246+
// evaluate the initializer.
6247+
if (VD->isLocalVarDecl() && typeShouldBeVisited(VD->getType()) &&
6248+
VD->getInit() && !VD->getInit()->isValueDependent()) {
6249+
6250+
if (VD->evaluateValue())
6251+
return revisit(VD);
62376252

6238-
if (!D->getType()->isReferenceType())
6239-
return this->emitDummyPtr(D, E);
6253+
if (!D->getType()->isReferenceType())
6254+
return this->emitDummyPtr(D, E);
62406255

6241-
return this->emitInvalidDeclRef(cast<DeclRefExpr>(E),
6242-
/*InitializerFailed=*/true, E);
6243-
}
6244-
}
6245-
} else {
6246-
if (const auto *VD = dyn_cast<VarDecl>(D);
6247-
VD && VD->getAnyInitializer() &&
6248-
VD->getType().isConstant(Ctx.getASTContext()) && !VD->isWeak())
6249-
return revisit(VD);
6250-
}
6256+
return this->emitInvalidDeclRef(cast<DeclRefExpr>(E),
6257+
/*InitializerFailed=*/true, E);
62516258
}
62526259

62536260
return this->emitDummyPtr(D, E);

clang/lib/AST/ByteCode/Program.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ unsigned Program::getOrCreateDummy(const DeclTy &D) {
155155

156156
QualType QT;
157157
bool IsWeak = false;
158-
if (const auto *E = D.dyn_cast<const Expr *>()) {
158+
if (const auto *E = dyn_cast<const Expr *>(D)) {
159159
QT = E->getType();
160160
} else {
161161
const ValueDecl *VD = cast<ValueDecl>(cast<const Decl *>(D));

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ static bool startsNextOperand(const FormatToken &Current) {
148148
static bool mustBreakBinaryOperation(const FormatToken &Current,
149149
const FormatStyle &Style) {
150150
return Style.BreakBinaryOperations != FormatStyle::BBO_Never &&
151+
Current.CanBreakBefore &&
151152
(Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None
152153
? startsNextOperand
153154
: isAlignableBinaryOperator)(Current);

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,14 +503,14 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
503503
auto *NextTok = Tokens->getNextNonComment();
504504

505505
if (!Line->InMacroBody && !Style.isTableGen()) {
506-
// Skip PPDirective lines and comments.
506+
// Skip PPDirective lines (except macro definitions) and comments.
507507
while (NextTok->is(tok::hash)) {
508508
NextTok = Tokens->getNextToken();
509-
if (NextTok->is(tok::pp_not_keyword))
509+
if (NextTok->isOneOf(tok::pp_not_keyword, tok::pp_define))
510510
break;
511511
do {
512512
NextTok = Tokens->getNextToken();
513-
} while (!NextTok->HasUnescapedNewline && NextTok->isNot(tok::eof));
513+
} while (NextTok->NewlinesBefore == 0 && NextTok->isNot(tok::eof));
514514

515515
while (NextTok->is(tok::comment))
516516
NextTok = Tokens->getNextToken();

clang/test/ARCMT/autoreleases.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ id test2(A* val) {
6969
return val;
7070
}
7171

72-
id test3(void) {
72+
void test3(void) {
7373
id a = [[A alloc] init];
7474
[a autorelease];
7575
}

clang/test/ARCMT/autoreleases.m.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ id test2(A* val) {
6464
return val;
6565
}
6666

67-
id test3(void) {
67+
void test3(void) {
6868
id a = [[A alloc] init];
6969
}

clang/test/ARCMT/retains.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ @implementation Foo
2121

2222
@synthesize bar;
2323

24-
-(id)something {}
24+
-(id)something { return (id)0; }
2525

2626
-(id)test:(id)obj {
2727
id x = self.bar;

clang/test/ARCMT/retains.m.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ id IhaveSideEffect(void);
2121

2222
@synthesize bar;
2323

24-
-(id)something {}
24+
-(id)something { return (id)0; }
2525

2626
-(id)test:(id)obj {
2727
id x = self.bar;

0 commit comments

Comments
 (0)