Skip to content

Commit 96d4e6e

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:8c26e473e703 into amd-gfx:7ca00a97cbc3
Local branch amd-gfx 7ca00a9 Merged main:210e8984fe15 into amd-gfx:b56415c184f2 Remote branch main 8c26e47 [LLParser] Merge xor constantexpr parsing with add/mul/shl/lshr/ashr. (llvm#67371)
2 parents 7ca00a9 + 8c26e47 commit 96d4e6e

File tree

64 files changed

+1102
-990
lines changed

Some content is hidden

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

64 files changed

+1102
-990
lines changed

clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ void ImplementationInNamespaceCheck::check(
3131
const MatchFinder::MatchResult &Result) {
3232
const auto *MatchedDecl =
3333
Result.Nodes.getNodeAs<Decl>("child_of_translation_unit");
34-
MatchedDecl->dump();
3534
const auto *NS = dyn_cast<NamespaceDecl>(MatchedDecl);
3635
if (NS == nullptr || NS->isAnonymousNamespace()) {
3736
diag(MatchedDecl->getLocation(),

clang/lib/Format/NamespaceEndCommentsFixer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ bool validEndComment(const FormatToken *RBraceTok, StringRef NamespaceName,
170170
// Valid namespace end comments don't need to be edited.
171171
static const llvm::Regex NamespaceCommentPattern =
172172
llvm::Regex("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
173-
"namespace( +([a-zA-Z0-9:_]+))?\\.? *(\\*/)?$",
173+
"namespace( +([a-zA-Z0-9:_ ]+))?\\.? *(\\*/)?$",
174174
llvm::Regex::IgnoreCase);
175175
static const llvm::Regex NamespaceMacroCommentPattern =
176176
llvm::Regex("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
@@ -189,7 +189,7 @@ bool validEndComment(const FormatToken *RBraceTok, StringRef NamespaceName,
189189
// Comment does not match regex.
190190
return false;
191191
}
192-
StringRef NamespaceNameInComment = Groups.size() > 5 ? Groups[5] : "";
192+
StringRef NamespaceNameInComment = Groups.size() > 5 ? Groups[5].rtrim() : "";
193193
// Anonymous namespace comments must not mention a namespace name.
194194
if (NamespaceName.empty() && !NamespaceNameInComment.empty())
195195
return false;

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3144,8 +3144,12 @@ static FormatToken *getFunctionName(const AnnotatedLine &Line) {
31443144
}
31453145

31463146
// Make sure the name is followed by a pair of parentheses.
3147-
if (Name)
3148-
return Tok->is(tok::l_paren) && Tok->MatchingParen ? Name : nullptr;
3147+
if (Name) {
3148+
return Tok->is(tok::l_paren) && Tok->isNot(TT_FunctionTypeLParen) &&
3149+
Tok->MatchingParen
3150+
? Name
3151+
: nullptr;
3152+
}
31493153

31503154
// Skip keywords that may precede the constructor/destructor name.
31513155
if (Tok->isOneOf(tok::kw_friend, tok::kw_inline, tok::kw_virtual,

clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -658,42 +658,27 @@ TEST_F(NamespaceEndCommentsFixerTest,
658658
}
659659

660660
TEST_F(NamespaceEndCommentsFixerTest, KeepsValidEndComment) {
661-
EXPECT_EQ("namespace {\n"
662-
"int i;\n"
663-
"} // end anonymous namespace",
664-
fixNamespaceEndComments("namespace {\n"
665-
"int i;\n"
666-
"} // end anonymous namespace"));
667-
EXPECT_EQ("namespace A {\n"
668-
"int i;\n"
669-
"} /* end of namespace A */",
670-
fixNamespaceEndComments("namespace A {\n"
671-
"int i;\n"
672-
"} /* end of namespace A */"));
673-
EXPECT_EQ("namespace A {\n"
674-
"int i;\n"
675-
"} // namespace A",
676-
fixNamespaceEndComments("namespace A {\n"
677-
"int i;\n"
678-
"} // namespace A"));
679-
EXPECT_EQ("namespace A::B {\n"
680-
"int i;\n"
681-
"} // end namespace A::B",
682-
fixNamespaceEndComments("namespace A::B {\n"
683-
"int i;\n"
684-
"} // end namespace A::B"));
685-
EXPECT_EQ("namespace A {\n"
686-
"int i;\n"
687-
"}; // end namespace A",
688-
fixNamespaceEndComments("namespace A {\n"
689-
"int i;\n"
690-
"}; // end namespace A"));
691-
EXPECT_EQ("namespace {\n"
692-
"int i;\n"
693-
"}; /* unnamed namespace */",
694-
fixNamespaceEndComments("namespace {\n"
695-
"int i;\n"
696-
"}; /* unnamed namespace */"));
661+
EXPECT_TRUE(isFormatted("namespace {\n"
662+
"int i;\n"
663+
"} // end anonymous namespace"));
664+
EXPECT_TRUE(isFormatted("namespace A {\n"
665+
"int i;\n"
666+
"} /* end of namespace A */"));
667+
EXPECT_TRUE(isFormatted("namespace A {\n"
668+
"int i;\n"
669+
"} // namespace A"));
670+
EXPECT_TRUE(isFormatted("namespace A::B {\n"
671+
"int i;\n"
672+
"} // end namespace A::B"));
673+
EXPECT_TRUE(isFormatted("namespace A {\n"
674+
"int i;\n"
675+
"}; // end namespace A"));
676+
EXPECT_TRUE(isFormatted("namespace {\n"
677+
"int i;\n"
678+
"}; /* unnamed namespace */"));
679+
EXPECT_TRUE(isFormatted("namespace a::inline b {\n"
680+
"int c;\n"
681+
"}; // namespace a::inline b"));
697682
}
698683

699684
TEST_F(NamespaceEndCommentsFixerTest, KeepsValidMacroEndComment) {

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,13 @@ TEST_F(TokenAnnotatorTest, UnderstandsFunctionDeclarationNames) {
16551655
"FOO Foo();");
16561656
ASSERT_EQ(Tokens.size(), 11u) << Tokens;
16571657
EXPECT_TOKEN(Tokens[6], tok::identifier, TT_FunctionDeclarationName);
1658+
1659+
Tokens = annotate("struct Foo {\n"
1660+
" Bar (*func)();\n"
1661+
"};");
1662+
ASSERT_EQ(Tokens.size(), 14u) << Tokens;
1663+
EXPECT_TOKEN(Tokens[3], tok::identifier, TT_Unknown);
1664+
EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_FunctionTypeLParen);
16581665
}
16591666

16601667
TEST_F(TokenAnnotatorTest, UnderstandsC11GenericSelection) {

compiler-rt/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,16 @@ bool __sanitizer_symbolize_code(const char *ModuleName, uint64_t ModuleOffset,
7676
auto ResOrErr = getDefaultSymbolizer()->symbolizeInlinedCode(
7777
ModuleName,
7878
{ModuleOffset, llvm::object::SectionedAddress::UndefSection});
79-
Printer->print(Request,
80-
ResOrErr ? ResOrErr.get() : llvm::DIInliningInfo());
79+
if (!ResOrErr)
80+
return false;
81+
Printer->print(Request, ResOrErr.get());
8182
} else {
8283
auto ResOrErr = getDefaultSymbolizer()->symbolizeCode(
8384
ModuleName,
8485
{ModuleOffset, llvm::object::SectionedAddress::UndefSection});
85-
Printer->print(Request, ResOrErr ? ResOrErr.get() : llvm::DILineInfo());
86+
if (!ResOrErr)
87+
return false;
88+
Printer->print(Request, ResOrErr.get());
8689
}
8790
}
8891
return __sanitizer::internal_snprintf(Buffer, MaxLength, "%s",
@@ -104,7 +107,9 @@ bool __sanitizer_symbolize_data(const char *ModuleName, uint64_t ModuleOffset,
104107
auto ResOrErr = getDefaultSymbolizer()->symbolizeData(
105108
ModuleName,
106109
{ModuleOffset, llvm::object::SectionedAddress::UndefSection});
107-
Printer->print(Request, ResOrErr ? ResOrErr.get() : llvm::DIGlobal());
110+
if (!ResOrErr)
111+
return false;
112+
Printer->print(Request, ResOrErr.get());
108113
}
109114
return __sanitizer::internal_snprintf(Buffer, MaxLength, "%s",
110115
Result.c_str()) < MaxLength;

flang/lib/Lower/OpenACC.cpp

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ static constexpr std::int64_t starCst = -1;
3535
static unsigned routineCounter = 0;
3636
static constexpr llvm::StringRef accRoutinePrefix = "acc_routine_";
3737
static constexpr llvm::StringRef accPrivateInitName = "acc.private.init";
38+
static constexpr llvm::StringRef accReductionInitName = "acc.reduction.init";
3839

3940
static mlir::Location
4041
genOperandLocation(Fortran::lower::AbstractConverter &converter,
@@ -344,6 +345,16 @@ static void genDataExitOperations(fir::FirOpBuilder &builder,
344345
}
345346
}
346347

348+
fir::ShapeOp genShapeOp(mlir::OpBuilder &builder, fir::SequenceType seqTy,
349+
mlir::Location loc) {
350+
llvm::SmallVector<mlir::Value> extents;
351+
mlir::Type idxTy = builder.getIndexType();
352+
for (auto extent : seqTy.getShape())
353+
extents.push_back(builder.create<mlir::arith::ConstantOp>(
354+
loc, idxTy, builder.getIntegerAttr(idxTy, extent)));
355+
return builder.create<fir::ShapeOp>(loc, extents);
356+
}
357+
347358
template <typename RecipeOp>
348359
static void genPrivateLikeInitRegion(mlir::OpBuilder &builder, RecipeOp recipe,
349360
mlir::Type ty, mlir::Location loc) {
@@ -361,12 +372,7 @@ static void genPrivateLikeInitRegion(mlir::OpBuilder &builder, RecipeOp recipe,
361372
TODO(loc, "private recipe of array with dynamic extents");
362373
if (fir::isa_trivial(seqTy.getEleTy())) {
363374
auto alloca = builder.create<fir::AllocaOp>(loc, seqTy);
364-
llvm::SmallVector<mlir::Value> extents;
365-
mlir::Type idxTy = builder.getIndexType();
366-
for (auto extent : seqTy.getShape())
367-
extents.push_back(builder.create<mlir::arith::ConstantOp>(
368-
loc, idxTy, builder.getIntegerAttr(idxTy, extent)));
369-
auto shapeOp = builder.create<fir::ShapeOp>(loc, extents);
375+
auto shapeOp = genShapeOp(builder, seqTy, loc);
370376
auto declareOp = builder.create<hlfir::DeclareOp>(
371377
loc, alloca, accPrivateInitName, shapeOp,
372378
llvm::ArrayRef<mlir::Value>{}, fir::FortranVariableFlagsAttr{});
@@ -708,14 +714,21 @@ static mlir::Value genReductionInitRegion(fir::FirOpBuilder &builder,
708714
mlir::Value initValue = getReductionInitValue(builder, loc, ty, op);
709715
if (fir::isa_trivial(ty)) {
710716
mlir::Value alloca = builder.create<fir::AllocaOp>(loc, ty);
717+
auto declareOp = builder.create<hlfir::DeclareOp>(
718+
loc, alloca, accReductionInitName, /*shape=*/nullptr,
719+
llvm::ArrayRef<mlir::Value>{}, fir::FortranVariableFlagsAttr{});
711720
builder.create<fir::StoreOp>(loc, builder.createConvert(loc, ty, initValue),
712-
alloca);
713-
return alloca;
721+
declareOp.getBase());
722+
return declareOp.getBase();
714723
} else if (auto seqTy = mlir::dyn_cast_or_null<fir::SequenceType>(ty)) {
715724
if (seqTy.hasDynamicExtents())
716725
TODO(loc, "private recipe of array with dynamic extents");
717726
if (fir::isa_trivial(seqTy.getEleTy())) {
718727
mlir::Value alloca = builder.create<fir::AllocaOp>(loc, seqTy);
728+
auto shapeOp = genShapeOp(builder, seqTy, loc);
729+
auto declareOp = builder.create<hlfir::DeclareOp>(
730+
loc, alloca, accReductionInitName, shapeOp,
731+
llvm::ArrayRef<mlir::Value>{}, fir::FortranVariableFlagsAttr{});
719732
mlir::Type idxTy = builder.getIndexType();
720733
mlir::Type refTy = fir::ReferenceType::get(seqTy.getEleTy());
721734
llvm::SmallVector<fir::DoLoopOp> loops;
@@ -730,10 +743,11 @@ static mlir::Value genReductionInitRegion(fir::FirOpBuilder &builder,
730743
loops.push_back(loop);
731744
ivs.push_back(loop.getInductionVar());
732745
}
733-
auto coord = builder.create<fir::CoordinateOp>(loc, refTy, alloca, ivs);
746+
auto coord = builder.create<fir::CoordinateOp>(loc, refTy,
747+
declareOp.getBase(), ivs);
734748
builder.create<fir::StoreOp>(loc, initValue, coord);
735749
builder.setInsertionPointAfter(loops[0]);
736-
return alloca;
750+
return declareOp.getBase();
737751
}
738752
}
739753
llvm::report_fatal_error("Unsupported OpenACC reduction type");

0 commit comments

Comments
 (0)