Skip to content

Commit 41eecb2

Browse files
committed
merge main into amd-staging
Change-Id: I9f149e38a0c56fa75f92f96cb39cacad1894792d
2 parents d1b462d + 5f254eb commit 41eecb2

File tree

157 files changed

+22544
-8683
lines changed

Some content is hidden

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

157 files changed

+22544
-8683
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ jobs:
185185
std_modules: 'OFF'
186186
# Use a larger machine for MSAN to avoid timeout and memory allocation issues.
187187
- config: 'generic-msan'
188-
machine: libcxx-runners-32-set
188+
machine: libcxx-runners-8-set
189189
std_modules: 'OFF'
190190
runs-on: ${{ matrix.machine }}
191191
steps:

clang/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,23 @@ endif()
167167
include(CheckIncludeFile)
168168
check_include_file(sys/resource.h CLANG_HAVE_RLIMITS)
169169

170+
# This check requires _GNU_SOURCE on linux
171+
check_include_file(dlfcn.h CLANG_HAVE_DLFCN_H)
172+
if( CLANG_HAVE_DLFCN_H )
173+
include(CheckLibraryExists)
174+
include(CheckSymbolExists)
175+
check_library_exists(dl dlopen "" HAVE_LIBDL)
176+
if( HAVE_LIBDL )
177+
list(APPEND CMAKE_REQUIRED_LIBRARIES dl)
178+
endif()
179+
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
180+
check_symbol_exists(dladdr dlfcn.h CLANG_HAVE_DLADDR)
181+
list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
182+
if( HAVE_LIBDL )
183+
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES dl)
184+
endif()
185+
endif()
186+
170187
set(CLANG_RESOURCE_DIR "" CACHE STRING
171188
"Relative directory from the Clang binary to its resource files.")
172189

clang/include/clang/Config/config.h.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@
6060
/* Define if we have sys/resource.h (rlimits) */
6161
#cmakedefine CLANG_HAVE_RLIMITS ${CLANG_HAVE_RLIMITS}
6262

63+
/* Define if we have dlfcn.h */
64+
#cmakedefine CLANG_HAVE_DLFCN_H ${CLANG_HAVE_DLFCN_H}
65+
66+
/* Define if dladdr() is available on this platform. */
67+
#cmakedefine CLANG_HAVE_DLADDR ${CLANG_HAVE_DLADDR}
68+
6369
/* Linker version detected at compile time. */
6470
#cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}"
6571

clang/lib/AST/ASTImporter.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7826,6 +7826,18 @@ ExpectedStmt ASTNodeImporter::VisitExplicitCastExpr(ExplicitCastExpr *E) {
78267826
*ToLParenLocOrErr, OCE->getBridgeKind(), E->getCastKind(),
78277827
*ToBridgeKeywordLocOrErr, ToTypeInfoAsWritten, ToSubExpr);
78287828
}
7829+
case Stmt::BuiltinBitCastExprClass: {
7830+
auto *BBC = cast<BuiltinBitCastExpr>(E);
7831+
ExpectedSLoc ToKWLocOrErr = import(BBC->getBeginLoc());
7832+
if (!ToKWLocOrErr)
7833+
return ToKWLocOrErr.takeError();
7834+
ExpectedSLoc ToRParenLocOrErr = import(BBC->getEndLoc());
7835+
if (!ToRParenLocOrErr)
7836+
return ToRParenLocOrErr.takeError();
7837+
return new (Importer.getToContext()) BuiltinBitCastExpr(
7838+
ToType, E->getValueKind(), E->getCastKind(), ToSubExpr,
7839+
ToTypeInfoAsWritten, *ToKWLocOrErr, *ToRParenLocOrErr);
7840+
}
78297841
default:
78307842
llvm_unreachable("Cast expression of unsupported type!");
78317843
return make_error<ASTImportError>(ASTImportError::UnsupportedConstruct);
@@ -9103,6 +9115,12 @@ Expected<Attr *> ASTImporter::Import(const Attr *FromAttr) {
91039115
break;
91049116
}
91059117

9118+
case attr::AlignValue: {
9119+
auto *From = cast<AlignValueAttr>(FromAttr);
9120+
AI.importAttr(From, AI.importArg(From->getAlignment()).value());
9121+
break;
9122+
}
9123+
91069124
case attr::Format: {
91079125
const auto *From = cast<FormatAttr>(FromAttr);
91089126
AI.importAttr(From, Import(From->getType()), From->getFormatIdx(),

clang/lib/Format/Format.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,9 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
16981698
/*BasedOnStyle=*/"google",
16991699
},
17001700
};
1701+
GoogleStyle.AttributeMacros.push_back("GUARDED_BY");
1702+
GoogleStyle.AttributeMacros.push_back("ABSL_GUARDED_BY");
1703+
17011704
GoogleStyle.SpacesBeforeTrailingComments = 2;
17021705
GoogleStyle.Standard = FormatStyle::LS_Auto;
17031706

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,8 +1650,10 @@ void UnwrappedLineParser::parseStructuralElement(
16501650
return;
16511651
}
16521652
// In Verilog labels can be any expression, so we don't do them here.
1653-
if (!Style.isVerilog() && Tokens->peekNextToken()->is(tok::colon) &&
1654-
!Line->MustBeDeclaration) {
1653+
// JS doesn't have macros, and within classes colons indicate fields, not
1654+
// labels.
1655+
if (!Style.isJavaScript() && !Style.isVerilog() &&
1656+
Tokens->peekNextToken()->is(tok::colon) && !Line->MustBeDeclaration) {
16551657
nextToken();
16561658
Line->Tokens.begin()->Tok->MustBreakBefore = true;
16571659
FormatTok->setFinalizedType(TT_GotoLabelColon);

clang/lib/Sema/SemaInit.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "clang/Sema/EnterExpressionEvaluationContext.h"
2626
#include "clang/Sema/Initialization.h"
2727
#include "clang/Sema/Lookup.h"
28+
#include "clang/Sema/Ownership.h"
2829
#include "clang/Sema/SemaInternal.h"
2930
#include "llvm/ADT/APInt.h"
3031
#include "llvm/ADT/FoldingSet.h"
@@ -5429,18 +5430,12 @@ static void TryOrBuildParenListInitialization(
54295430
auto HandleInitializedEntity = [&](const InitializedEntity &SubEntity,
54305431
const InitializationKind &SubKind,
54315432
Expr *Arg, Expr **InitExpr = nullptr) {
5432-
InitializationSequence IS = [&]() {
5433-
if (Arg)
5434-
return InitializationSequence(S, SubEntity, SubKind, Arg);
5435-
return InitializationSequence(S, SubEntity, SubKind, std::nullopt);
5436-
}();
5433+
InitializationSequence IS = InitializationSequence(
5434+
S, SubEntity, SubKind, Arg ? MultiExprArg(Arg) : std::nullopt);
54375435

54385436
if (IS.Failed()) {
54395437
if (!VerifyOnly) {
5440-
if (Arg)
5441-
IS.Diagnose(S, SubEntity, SubKind, Arg);
5442-
else
5443-
IS.Diagnose(S, SubEntity, SubKind, std::nullopt);
5438+
IS.Diagnose(S, SubEntity, SubKind, Arg ? ArrayRef(Arg) : std::nullopt);
54445439
} else {
54455440
Sequence.SetFailed(
54465441
InitializationSequence::FK_ParenthesizedListInitFailed);
@@ -5450,10 +5445,8 @@ static void TryOrBuildParenListInitialization(
54505445
}
54515446
if (!VerifyOnly) {
54525447
ExprResult ER;
5453-
if (Arg)
5454-
ER = IS.Perform(S, SubEntity, SubKind, Arg);
5455-
else
5456-
ER = IS.Perform(S, SubEntity, SubKind, std::nullopt);
5448+
ER = IS.Perform(S, SubEntity, SubKind,
5449+
Arg ? MultiExprArg(Arg) : std::nullopt);
54575450
if (InitExpr)
54585451
*InitExpr = ER.get();
54595452
else
@@ -5519,6 +5512,14 @@ static void TryOrBuildParenListInitialization(
55195512
} else if (auto *RT = Entity.getType()->getAs<RecordType>()) {
55205513
bool IsUnion = RT->isUnionType();
55215514
const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
5515+
if (RD->isInvalidDecl()) {
5516+
// Exit early to avoid confusion when processing members.
5517+
// We do the same for braced list initialization in
5518+
// `CheckStructUnionTypes`.
5519+
Sequence.SetFailed(
5520+
clang::InitializationSequence::FK_ParenthesizedListInitFailed);
5521+
return;
5522+
}
55225523

55235524
if (!IsUnion) {
55245525
for (const CXXBaseSpecifier &Base : RD->bases()) {

clang/lib/Sema/SemaStmt.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,9 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
12711271

12721272
bool CaseListIsErroneous = false;
12731273

1274+
// FIXME: We'd better diagnose missing or duplicate default labels even
1275+
// in the dependent case. Because default labels themselves are never
1276+
// dependent.
12741277
for (SwitchCase *SC = SS->getSwitchCaseList(); SC && !HasDependentValue;
12751278
SC = SC->getNextSwitchCase()) {
12761279

@@ -1341,6 +1344,10 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
13411344
assert(!HasConstantCond ||
13421345
(ConstantCondValue.getBitWidth() == CondWidth &&
13431346
ConstantCondValue.isSigned() == CondIsSigned));
1347+
#if NEEDS_PATCH_FOR_SWITCH
1348+
//[clang][Sema] Add -Wswitch-default warning option (#73077)
1349+
Diag(SwitchLoc, diag::warn_switch_default);
1350+
#endif
13441351
}
13451352
bool ShouldCheckConstantCond = HasConstantCond;
13461353

clang/lib/Serialization/ASTReaderStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2007,7 +2007,7 @@ void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
20072007
E->QualifierLoc = Record.readNestedNameSpecifierLoc();
20082008
// not ImplicitAccess
20092009
if (CurrentUnpackingBits->getNextBit())
2010-
E->Base = Record.readSubExpr();
2010+
E->Base = Record.readSubExpr();
20112011
else
20122012
E->Base = nullptr;
20132013

clang/test/Driver/aarch64-v95a.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@
2525
// RUN: %clang -target aarch64 -march=armv9.5a+pauth-lr -### -c %s 2>&1 | FileCheck -check-prefix=V95A-PAUTHLR %s
2626
// RUN: %clang -target aarch64 -march=armv9.5-a+pauth-lr -### -c %s 2>&1 | FileCheck -check-prefix=V95A-PAUTHLR %s
2727
// V95A-PAUTHLR: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+neon" "-target-feature" "+v9.5a" "-target-feature" "+pauth-lr"
28+
29+
// RUN: %clang -target aarch64 -march=armv9.5a+tlbiw -### -c %s 2>&1 | FileCheck -check-prefix=V95A-TLBIW %s
30+
// RUN: %clang -target aarch64 -march=armv9.5-a+tlbiw -### -c %s 2>&1 | FileCheck -check-prefix=V95A-TLBIW %s
31+
// V95A-TLBIW: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+neon" "-target-feature" "+v9.5a" "-target-feature" "+tlbiw"

clang/test/Sema/switch-default.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wswitch-default %s
2+
3+
// XFAIL: *
4+
5+
int f1(int a) {
6+
switch (a) { // expected-warning {{'switch' missing 'default' label}}
7+
case 1: a++; break;
8+
case 2: a += 2; break;
9+
}
10+
return a;
11+
}
12+
13+
int f2(int a) {
14+
switch (a) { // no-warning
15+
default:
16+
;
17+
}
18+
return a;
19+
}
20+
21+
// Warn even completely covered Enum cases(GCC compatibility).
22+
enum E { A, B };
23+
enum E check_enum(enum E e) {
24+
switch (e) { // expected-warning {{'switch' missing 'default' label}}
25+
case A: break;
26+
case B: break;
27+
}
28+
return e;
29+
}
30+
31+
template<typename Index>
32+
int t1(Index i)
33+
{
34+
switch (i) { // expected-warning {{'switch' missing 'default' label}}
35+
case 0: return 0;
36+
case 1: return 1;
37+
}
38+
return 0;
39+
}
40+
41+
template<typename Index>
42+
int t2(Index i)
43+
{
44+
switch (i) { // no-warning
45+
case 0: return 0;
46+
case 1: return 1;
47+
default: return 2;
48+
}
49+
return 0;
50+
}
51+
52+
int main() {
53+
return t1(1); // expected-note {{in instantiation of function template specialization 't1<int>' requested here}}
54+
}
55+

clang/test/SemaCXX/crash-GH76228.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %clang_cc1 -std=c++20 -verify %s
2+
// Check we don't crash on incomplete members and bases when handling parenthesized initialization.
3+
class incomplete; // expected-note@-0 3 {{forward declaration of 'incomplete'}}
4+
struct foo {
5+
int a;
6+
incomplete b;
7+
// expected-error@-1 {{incomplete type}}
8+
};
9+
foo a1(0);
10+
11+
struct one_int {
12+
int a;
13+
};
14+
struct bar : one_int, incomplete {};
15+
// expected-error@-1 {{incomplete type}}
16+
bar a2(0);
17+
18+
incomplete a3[3](1,2,3);
19+
// expected-error@-1 {{incomplete type}}
20+
21+
struct qux : foo {
22+
};
23+
qux a4(0);
24+
25+
struct fred {
26+
foo a[3];
27+
};
28+
fred a5(0);

clang/test/SemaCXX/paren-list-agg-init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ int test() {
289289
// used to crash
290290
S a(0, 1);
291291
S b(0);
292-
S c(0, 0, 1); // beforecxx20-warning {{aggregate initialization of type 'S' from a parenthesized list of values is a C++20 extension}}
292+
S c(0, 0, 1);
293293

294294
S d {0, 1};
295295
S e {0};

clang/tools/libclang/CIndexer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
#include "CXString.h"
1515
#include "clang/Basic/LLVM.h"
1616
#include "clang/Basic/Version.h"
17+
#include "clang/Config/config.h"
1718
#include "clang/Driver/Driver.h"
1819
#include "llvm/ADT/STLExtras.h"
1920
#include "llvm/ADT/SmallString.h"
20-
#include "llvm/Config/llvm-config.h"
2121
#include "llvm/Support/FileSystem.h"
2222
#include "llvm/Support/MD5.h"
2323
#include "llvm/Support/Path.h"
@@ -127,7 +127,7 @@ const std::string &CIndexer::getClangResourcesPath() {
127127
getClangResourcesPathImplAIX(LibClangPath);
128128
#else
129129
bool PathFound = false;
130-
#if defined(HAVE_DLFCN_H) && defined(HAVE_DLADDR)
130+
#if defined(CLANG_HAVE_DLFCN_H) && defined(CLANG_HAVE_DLADDR)
131131
Dl_info info;
132132
// This silly cast below avoids a C++ warning.
133133
if (dladdr((void *)(uintptr_t)clang_createTranslationUnit, &info) != 0) {

0 commit comments

Comments
 (0)