Skip to content

Commit 9ec6ae0

Browse files
authored
merge main into amd-staging (llvm#1358)
2 parents d7dccc2 + 23a1f69 commit 9ec6ae0

Some content is hidden

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

59 files changed

+1632
-1195
lines changed

clang/lib/AST/NestedNameSpecifier.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ NestedNameSpecifier::translateToType(const ASTContext &Context) const {
289289
// These are not representable as types.
290290
return nullptr;
291291
}
292+
llvm_unreachable("Unhandled SpecifierKind enum");
292293
}
293294

294295
/// Print this nested name specifier to the given output

clang/lib/Driver/Job.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,7 @@ void Command::buildArgvForResponseFile(
143143
return;
144144
}
145145

146-
llvm::StringSet<> Inputs;
147-
for (const auto *InputName : InputFileList)
148-
Inputs.insert(InputName);
146+
llvm::StringSet<> Inputs(llvm::from_range, InputFileList);
149147
Out.push_back(Executable);
150148

151149
if (PrependArg)

clang/lib/Driver/Multilib.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ void Multilib::print(raw_ostream &OS) const {
6060
bool Multilib::operator==(const Multilib &Other) const {
6161
// Check whether the flags sets match
6262
// allowing for the match to be order invariant
63-
llvm::StringSet<> MyFlags;
64-
for (const auto &Flag : Flags)
65-
MyFlags.insert(Flag);
63+
llvm::StringSet<> MyFlags(llvm::from_range, Flags);
6664

6765
for (const auto &Flag : Other.Flags)
6866
if (!MyFlags.contains(Flag))
@@ -272,9 +270,7 @@ bool MultilibSet::select(
272270

273271
llvm::StringSet<>
274272
MultilibSet::expandFlags(const Multilib::flags_list &InFlags) const {
275-
llvm::StringSet<> Result;
276-
for (const auto &F : InFlags)
277-
Result.insert(F);
273+
llvm::StringSet<> Result(llvm::from_range, InFlags);
278274
for (const FlagMatcher &M : FlagMatchers) {
279275
std::string RegexString(M.Match);
280276

clang/lib/Format/Format.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,10 +2123,14 @@ std::error_code parseConfiguration(llvm::MemoryBufferRef Config,
21232123
FormatStyle::FormatStyleSet StyleSet;
21242124
bool LanguageFound = false;
21252125
for (const FormatStyle &Style : llvm::reverse(Styles)) {
2126-
if (Style.Language != FormatStyle::LK_None)
2126+
const auto Lang = Style.Language;
2127+
if (Lang != FormatStyle::LK_None)
21272128
StyleSet.Add(Style);
2128-
if (Style.Language == Language)
2129+
if (Lang == Language ||
2130+
// For backward compatibility.
2131+
(Lang == FormatStyle::LK_Cpp && Language == FormatStyle::LK_C)) {
21292132
LanguageFound = true;
2133+
}
21302134
}
21312135
if (!LanguageFound) {
21322136
if (Styles.empty() || Styles[0].Language != FormatStyle::LK_None)
@@ -2166,8 +2170,14 @@ FormatStyle::FormatStyleSet::Get(FormatStyle::LanguageKind Language) const {
21662170
if (!Styles)
21672171
return std::nullopt;
21682172
auto It = Styles->find(Language);
2169-
if (It == Styles->end())
2170-
return std::nullopt;
2173+
if (It == Styles->end()) {
2174+
if (Language != FormatStyle::LK_C)
2175+
return std::nullopt;
2176+
// For backward compatibility.
2177+
It = Styles->find(FormatStyle::LK_Cpp);
2178+
if (It == Styles->end())
2179+
return std::nullopt;
2180+
}
21712181
FormatStyle Style = It->second;
21722182
Style.StyleSet = *this;
21732183
return Style;

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,7 @@ class AnnotatingParser {
253253
// FIXME: This is getting out of hand, write a decent parser.
254254
if (MaybeAngles && InExpr && !Line.startsWith(tok::kw_template) &&
255255
Prev.is(TT_BinaryOperator) &&
256-
(Prev.isOneOf(tok::pipepipe, tok::ampamp) ||
257-
Prev.getPrecedence() == prec::Equality)) {
256+
Prev.isOneOf(tok::pipepipe, tok::ampamp)) {
258257
MaybeAngles = false;
259258
}
260259
if (Prev.isOneOf(tok::question, tok::colon) && !Style.isProto())

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ ParsedType Sema::getInheritingConstructorName(CXXScopeSpec &SS,
6060
SourceLocation NameLoc,
6161
const IdentifierInfo &Name) {
6262
NestedNameSpecifier *NNS = SS.getScopeRep();
63-
if (const IdentifierInfo *II = NNS->getAsIdentifier())
63+
if ([[maybe_unused]] const IdentifierInfo *II = NNS->getAsIdentifier())
6464
assert(II == &Name && "not a constructor name");
6565

6666
QualType Type(NNS->translateToType(Context), 0);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Test that adding a new unused decl within reduced BMI may not produce a transitive change.
2+
//
3+
// RUN: rm -rf %t
4+
// RUN: split-file %s %t
5+
//
6+
// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/A.cppm -o %t/A.pcm
7+
// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/B.cppm -o %t/B.pcm \
8+
// RUN: -fmodule-file=A=%t/A.pcm
9+
//
10+
// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/A.v1.cppm -o %t/A.v1.pcm
11+
// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/B.cppm -o %t/B.v1.pcm \
12+
// RUN: -fmodule-file=A=%t/A.v1.pcm
13+
//
14+
// RUN: not diff %t/B.pcm %t/B.v1.pcm &> /dev/null
15+
16+
//--- A.cppm
17+
export module A;
18+
export int a() { return 44; }
19+
20+
//--- A.v1.cppm
21+
export module A;
22+
export int a() { return 44; }
23+
int a_impl() { return 48; }
24+
25+
//--- B.cppm
26+
export module B;
27+
import A;
28+
export inline int b = a();

clang/test/Preprocessor/riscv-target-features.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@
214214
// CHECK-A-EXT: __riscv_atomic 1
215215

216216
// RUN: %clang --target=riscv32-unknown-linux-gnu \
217-
// RUN: -march=rv32ib -x c -E -dM %s \
217+
// RUN: -march=rv32ib -E -dM %s \
218218
// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
219219
// RUN: %clang --target=riscv64-unknown-linux-gnu \
220-
// RUN: -march=rv64ib -x c -E -dM %s \
220+
// RUN: -march=rv64ib -E -dM %s \
221221
// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
222222
// CHECK-B-EXT: __riscv_b 1000000{{$}}
223223
// CHECK-B-EXT: __riscv_zba 1000000{{$}}
@@ -793,9 +793,9 @@
793793
// RUN: -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s
794794
// CHECK-ZALRSC-EXT: __riscv_zalrsc 1000000{{$}}
795795

796-
// RUN: %clang --target=riscv32 -march=rv32izama16b -x c -E -dM %s \
796+
// RUN: %clang --target=riscv32 -march=rv32izama16b -E -dM %s \
797797
// RUN: -o - | FileCheck --check-prefix=CHECK-ZAMA16B-EXT %s
798-
// RUN: %clang --target=riscv64 -march=rv64izama16b -x c -E -dM %s \
798+
// RUN: %clang --target=riscv64 -march=rv64izama16b -E -dM %s \
799799
// RUN: -o - | FileCheck --check-prefix=CHECK-ZAMA16B-EXT %s
800800
// CHECK-ZAMA16B-EXT: __riscv_zama16b 1000000{{$}}
801801

clang/unittests/Format/ConfigParseTest.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,26 @@ TEST(ConfigParseTest, ParsesConfigurationWithLanguages) {
12301230
IndentWidth, 56u);
12311231
}
12321232

1233+
TEST(ConfigParseTest, AllowCppForC) {
1234+
FormatStyle Style = {};
1235+
Style.Language = FormatStyle::LK_C;
1236+
EXPECT_EQ(parseConfiguration("Language: Cpp", &Style), ParseError::Success);
1237+
1238+
CHECK_PARSE("---\n"
1239+
"IndentWidth: 4\n"
1240+
"---\n"
1241+
"Language: Cpp\n"
1242+
"IndentWidth: 8\n",
1243+
IndentWidth, 8u);
1244+
1245+
EXPECT_EQ(parseConfiguration("---\n"
1246+
"Language: ObjC\n"
1247+
"---\n"
1248+
"Language: Cpp\n",
1249+
&Style),
1250+
ParseError::Success);
1251+
}
1252+
12331253
TEST(ConfigParseTest, UsesLanguageForBasedOnStyle) {
12341254
FormatStyle Style = {};
12351255
Style.Language = FormatStyle::LK_JavaScript;

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,8 +720,9 @@ TEST_F(TokenAnnotatorTest, UnderstandsNonTemplateAngleBrackets) {
720720

721721
Tokens = annotate("return A < B != A > B;");
722722
ASSERT_EQ(Tokens.size(), 10u) << Tokens;
723-
EXPECT_TOKEN(Tokens[2], tok::less, TT_BinaryOperator);
724-
EXPECT_TOKEN(Tokens[6], tok::greater, TT_BinaryOperator);
723+
// FIXME:
724+
// EXPECT_TOKEN(Tokens[2], tok::less, TT_BinaryOperator);
725+
// EXPECT_TOKEN(Tokens[6], tok::greater, TT_BinaryOperator);
725726

726727
Tokens = annotate("ratio{-1, 2} < ratio{-1, 3} == -1 / 3 > -1 / 2;");
727728
ASSERT_EQ(Tokens.size(), 27u) << Tokens;
@@ -3836,6 +3837,16 @@ TEST_F(TokenAnnotatorTest, TemplateInstantiation) {
38363837
ASSERT_EQ(Tokens.size(), 24u) << Tokens;
38373838
EXPECT_TOKEN(Tokens[6], tok::less, TT_TemplateOpener);
38383839
EXPECT_TOKEN(Tokens[18], tok::greater, TT_TemplateCloser);
3840+
3841+
Tokens = annotate(
3842+
"std::uint16_t kMTU = std::conditional<\n"
3843+
" kTypeKind == KindA,\n"
3844+
" std::integral_constant<std::uint16_t, kIoSockMtu>>::type::value;");
3845+
ASSERT_EQ(Tokens.size(), 30u) << Tokens;
3846+
EXPECT_TOKEN(Tokens[8], tok::less, TT_TemplateOpener);
3847+
EXPECT_TOKEN(Tokens[16], tok::less, TT_TemplateOpener);
3848+
EXPECT_TOKEN(Tokens[22], tok::greater, TT_TemplateCloser);
3849+
EXPECT_TOKEN(Tokens[23], tok::greater, TT_TemplateCloser);
38393850
}
38403851

38413852
TEST_F(TokenAnnotatorTest, VariableTemplate) {

0 commit comments

Comments
 (0)