Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoBump] Merge with 5901d400 (May 28) (54) #314

Merged
merged 23 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fea7399
[clang] Fix a warning
kazutakahirata May 28, 2024
273777e
clang:: to llvm::; NFC
AaronBallman May 28, 2024
259caad
[Clang] Fix an assertion failure when checking invalid `this` (#93490)
a-tarasyuk May 28, 2024
234cc40
[LAA] Limit no-overlap check to at least one loop-invariant accesses.
fhahn May 28, 2024
d582958
Revert "[Legalizer] Check full condition for UMIN and UMAX just like …
AZero13 May 28, 2024
42944e4
Add SBAddressRange and SBAddressRangeList to SB API (#92014)
mbucko May 28, 2024
79c7342
[gn build] Port 42944e460082
llvmgnsyncbot May 28, 2024
7bea41e
LoopIdiomRecognize: strip bad TODO (NFC) (#92890)
artagnon May 28, 2024
16a5fd3
DAG: Use flags in isLegalToCombineMinNumMaxNum (#93555)
arsenm May 28, 2024
b963931
[lld-macho][ObjC] Implement category merging into base class (#92448)
alx32 May 28, 2024
d1d863c
[lldb] Remove lldbassert in AppleObjCTypeEncodingParser (#93332)
JDevlieghere May 28, 2024
f69b6d2
[lldb] Add missing semicolon (NFC)
JDevlieghere May 28, 2024
c09787b
[OMPT] Set default values for tsan function pointers (#93568)
FLZ101 May 28, 2024
ef67f31
[SCEV] Compute symbolic max backedge taken count in BTI directly. (NFC)
fhahn May 28, 2024
0b2094c
[Clang] [NFC] Remove debug printing
Sirraide May 28, 2024
f089996
[clang][Sema] Don't emit 'declared here' note for builtin functions w…
JOE1994 May 28, 2024
73e22ff
[Reassociate] Preserve NSW flags after expr tree rewriting (#93105)
akshayrdeodhar May 28, 2024
9983592
[mlir][sparse] remove sparse encoding propagation pass. (#93593)
May 28, 2024
196a080
DAG: Handle fminnum_ieee/fmaxnum_ieee in basic legalization
arsenm May 28, 2024
08de0b3
[WebAssembly] Add tests for EH/SjLj option errors (#93583)
aheejin May 28, 2024
d33864d
[polly] Fix cppcheck SA comment reported in #91235 (#93505)
kartcq May 28, 2024
5901d40
[C] Disallow declarations where a statement is required (#92908)
AaronBallman May 28, 2024
9b0657c
[AutoBump] Merge with 5901d400 (May 28)
mgehre-amd Aug 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ Improvements to Clang's diagnostics
- Clang emits a ``-Wparentheses`` warning for expressions with consecutive comparisons like ``x < y < z``.
Fixes #GH20456.

- Clang no longer emits a "declared here" note for a builtin function that has no declaration in source.
Fixes #GH93369.

Improvements to Clang's time-trace
----------------------------------

Expand Down Expand Up @@ -629,6 +632,9 @@ Bug Fixes in This Version
- ``__is_array`` and ``__is_bounded_array`` no longer return ``true`` for
zero-sized arrays. Fixes (#GH54705).

- Correctly reject declarations where a statement is required in C.
Fixes #GH92775

Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -803,6 +809,7 @@ Bug Fixes to C++ Support
with the same parameters not to be diagnosed. (Fixes #GH93456).
- Clang now diagnoses unexpanded parameter packs in attributes. (Fixes #GH93269).
- Clang now allows ``@$``` in raw string literals. Fixes (#GH93130).
- Fix an assertion failure when checking invalid ``this`` usage in the wrong context. (Fixes #GH91536).

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
9 changes: 6 additions & 3 deletions clang/include/clang/Parse/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,15 +467,18 @@ class Parser : public CodeCompletionHandler {

/// Flags describing a context in which we're parsing a statement.
enum class ParsedStmtContext {
/// This context permits declarations in language modes where declarations
/// are not statements.
AllowDeclarationsInC = 0x1,
/// This context permits standalone OpenMP directives.
AllowStandaloneOpenMPDirectives = 0x1,
AllowStandaloneOpenMPDirectives = 0x2,
/// This context is at the top level of a GNU statement expression.
InStmtExpr = 0x2,
InStmtExpr = 0x4,

/// The context of a regular substatement.
SubStmt = 0,
/// The context of a compound-statement.
Compound = AllowStandaloneOpenMPDirectives,
Compound = AllowDeclarationsInC | AllowStandaloneOpenMPDirectives,

LLVM_MARK_AS_BITMASK_ENUM(InStmtExpr)
};
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/APValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ QualType APValue::LValueBase::getType() const {
// For a materialized temporary, the type of the temporary we materialized
// may not be the type of the expression.
if (const MaterializeTemporaryExpr *MTE =
clang::dyn_cast<MaterializeTemporaryExpr>(Base)) {
llvm::dyn_cast<MaterializeTemporaryExpr>(Base)) {
SmallVector<const Expr *, 2> CommaLHSs;
SmallVector<SubobjectAdjustment, 2> Adjustments;
const Expr *Temp = MTE->getSubExpr();
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Analysis/MacroExpansionContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#define DEBUG_TYPE "macro-expansion-context"

static void dumpTokenInto(const clang::Preprocessor &PP, clang::raw_ostream &OS,
static void dumpTokenInto(const clang::Preprocessor &PP, llvm::raw_ostream &OS,
clang::Token Tok);

namespace clang {
Expand Down
10 changes: 9 additions & 1 deletion clang/lib/Parse/ParseStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,15 @@ StmtResult Parser::ParseStatementOrDeclarationAfterAttributes(
auto IsStmtAttr = [](ParsedAttr &Attr) { return Attr.isStmtAttr(); };
bool AllAttrsAreStmtAttrs = llvm::all_of(CXX11Attrs, IsStmtAttr) &&
llvm::all_of(GNUAttrs, IsStmtAttr);
if (((GNUAttributeLoc.isValid() && !(HaveAttrs && AllAttrsAreStmtAttrs)) ||
// In C, the grammar production for statement (C23 6.8.1p1) does not allow
// for declarations, which is different from C++ (C++23 [stmt.pre]p1). So
// in C++, we always allow a declaration, but in C we need to check whether
// we're in a statement context that allows declarations. e.g., in C, the
// following is invalid: if (1) int x;
if ((getLangOpts().CPlusPlus || getLangOpts().MicrosoftExt ||
(StmtCtx & ParsedStmtContext::AllowDeclarationsInC) !=
ParsedStmtContext()) &&
((GNUAttributeLoc.isValid() && !(HaveAttrs && AllAttrsAreStmtAttrs)) ||
isDeclarationStatement())) {
SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
DeclGroupPtrTy Decl;
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1444,10 +1444,10 @@ bool Sema::CheckCXXThisType(SourceLocation Loc, QualType Type) {
// category are defined within such member functions as they are within
// an implicit object member function).
DeclContext *DC = getFunctionLevelDeclContext();
if (const auto *Method = dyn_cast<CXXMethodDecl>(DC);
Method && Method->isExplicitObjectMemberFunction()) {
const auto *Method = dyn_cast<CXXMethodDecl>(DC);
if (Method && Method->isExplicitObjectMemberFunction()) {
Diag(Loc, diag::err_invalid_this_use) << 1;
} else if (isLambdaCallWithExplicitObjectParameter(CurContext)) {
} else if (Method && isLambdaCallWithExplicitObjectParameter(CurContext)) {
Diag(Loc, diag::err_invalid_this_use) << 1;
} else {
Diag(Loc, diag::err_invalid_this_use) << 0;
Expand Down
10 changes: 10 additions & 0 deletions clang/lib/Sema/SemaLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5897,6 +5897,16 @@ void Sema::diagnoseTypo(const TypoCorrection &Correction,

NamedDecl *ChosenDecl =
Correction.isKeyword() ? nullptr : Correction.getFoundDecl();

// For builtin functions which aren't declared anywhere in source,
// don't emit the "declared here" note.
if (const auto *FD = dyn_cast_if_present<FunctionDecl>(ChosenDecl);
FD && FD->getBuiltinID() &&
PrevNote.getDiagID() == diag::note_previous_decl &&
Correction.getCorrectionRange().getBegin() == FD->getBeginLoc()) {
ChosenDecl = nullptr;
}

if (PrevNote.getDiagID() && ChosenDecl)
Diag(ChosenDecl->getLocation(), PrevNote)
<< CorrectedQuotedStr << (ErrorRecovery ? FixItHint() : FixTypo);
Expand Down
4 changes: 1 addition & 3 deletions clang/lib/Sema/SemaStmtAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,10 +684,8 @@ ExprResult Sema::ActOnCXXAssumeAttr(Stmt *St, const ParsedAttr &A,
}

if (!getLangOpts().CPlusPlus23 &&
A.getSyntax() == AttributeCommonInfo::AS_CXX11) {
llvm::dbgs() << "Syntax: " << int(A.getSyntax()) << "\n";
A.getSyntax() == AttributeCommonInfo::AS_CXX11)
Diag(A.getLoc(), diag::ext_cxx23_attr) << A << Range;
}

return Assumption;
}
Expand Down
3 changes: 2 additions & 1 deletion clang/test/C/C99/block-scopes.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

enum {a, b};
void different(void) {
if (sizeof(enum {b, a}) != sizeof(int))
if (sizeof(enum {b, a}) != sizeof(int)) {
_Static_assert(a == 1, "");
}
/* In C89, the 'b' found here would have been from the enum declaration in
* the controlling expression of the selection statement, not from the global
* declaration. In C99 and later, that enumeration is scoped to the 'if'
Expand Down
39 changes: 39 additions & 0 deletions clang/test/Parser/decls.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic

// Test that we can parse declarations at global scope.
int v;

void func(void) {
// Test that we can parse declarations within a compound statement.
int a;
{
int b;
}

int z = ({ // expected-warning {{use of GNU statement expression extension}}
// Test that we can parse declarations within a GNU statement expression.
int w = 12;
w;
});

// Test that we diagnose declarations where a statement is required.
// See GH92775.
if (1)
int x; // expected-error {{expected expression}}
for (;;)
int c; // expected-error {{expected expression}}

label:
int y; // expected-warning {{label followed by a declaration is a C23 extension}}

// Test that lookup works as expected.
(void)a;
(void)v;
(void)z;
(void)b; // expected-error {{use of undeclared identifier 'b'}}
(void)w; // expected-error {{use of undeclared identifier 'w'}}
(void)x; // expected-error {{use of undeclared identifier 'x'}}
(void)c; // expected-error {{use of undeclared identifier 'c'}}
(void)y;
}

3 changes: 1 addition & 2 deletions clang/test/SemaCXX/invalid-if-constexpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ namespace GH61885 {
void similar() { // expected-note {{'similar' declared here}}
if constexpr (similer<>) {} // expected-error {{use of undeclared identifier 'similer'; did you mean 'similar'?}}
}
void a() { if constexpr (__adl_swap<>) {}} // expected-error{{use of undeclared identifier '__adl_swap'; did you mean '__sync_swap'?}} \
// expected-note {{'__sync_swap' declared here}}
void a() { if constexpr (__adl_swap<>) {}} // expected-error{{use of undeclared identifier '__adl_swap'; did you mean '__sync_swap'?}}

int AA() { return true;} // expected-note {{'AA' declared here}}

Expand Down
4 changes: 4 additions & 0 deletions clang/test/SemaCXX/invalid-this-in-lambda.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s

decltype([]()->decltype(this) { }) a; // expected-error {{invalid use of 'this' outside of a non-static member function}}

8 changes: 8 additions & 0 deletions clang/test/SemaCXX/typo-correction-builtin-func.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s

// Test that clang does not emit 'declared here' note for builtin functions that don't have a declaration in source.

void t0() {
constexpr float A = __builtin_isinfinity(); // expected-error {{use of undeclared identifier '__builtin_isinfinity'; did you mean '__builtin_isfinite'?}}
// expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
}
6 changes: 4 additions & 2 deletions clang/test/SemaOpenACC/parallel-loc-and-stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ int foo3;

void func() {
// FIXME: Should we disallow this on declarations, or consider this to be on
// the initialization?
// the initialization? This is currently rejected in C because
// Parser::ParseOpenACCDirectiveStmt() calls ParseStatement() and passes the
// statement context as "SubStmt" which does not allow for a declaration in C.
#pragma acc parallel
int foo;
int foo; // expected-error {{expected expression}}

#pragma acc parallel
{
Expand Down
8 changes: 0 additions & 8 deletions clang/unittests/Interpreter/IncrementalProcessingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ using namespace clang;

namespace {

static bool HostSupportsJit() {
auto J = llvm::orc::LLJITBuilder().create();
if (J)
return true;
LLVMConsumeError(llvm::wrap(J.takeError()));
return false;
}

// Incremental processing produces several modules, all using the same "main
// file". Make sure CodeGen can cope with that, e.g. for static initializers.
const char TestProgram1[] = "extern \"C\" int funcForProg1() { return 17; }\n"
Expand Down
Loading