Skip to content

Commit 6bc5341

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:74cb1f9f51e5 into amd-gfx:437902434321
Local branch amd-gfx 4379024 Merged main:38376dee9222 into amd-gfx:08c2ed5c52de Remote branch main 74cb1f9 [PowerPC] Use MCRegister. NFC
2 parents 4379024 + 74cb1f9 commit 6bc5341

File tree

79 files changed

+1489
-467
lines changed

Some content is hidden

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

79 files changed

+1489
-467
lines changed

clang/include/clang/AST/DeclBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ class alignas(8) Decl {
492492
/// perform non-Decl specific checks based on the object's type and strict
493493
/// flex array level.
494494
static bool isFlexibleArrayMemberLike(
495-
ASTContext &Context, const Decl *D, QualType Ty,
495+
const ASTContext &Context, const Decl *D, QualType Ty,
496496
LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel,
497497
bool IgnoreTemplateOrMacroSubstitution);
498498

clang/include/clang/AST/Expr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ class Expr : public ValueStmt {
542542
/// When IgnoreTemplateOrMacroSubstitution is set, it doesn't consider sizes
543543
/// resulting from the substitution of a macro or a template as special sizes.
544544
bool isFlexibleArrayMemberLike(
545-
ASTContext &Context,
545+
const ASTContext &Context,
546546
LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel,
547547
bool IgnoreTemplateOrMacroSubstitution = false) const;
548548

clang/lib/AST/DeclBase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ bool Decl::isFileContextDecl() const {
438438
}
439439

440440
bool Decl::isFlexibleArrayMemberLike(
441-
ASTContext &Ctx, const Decl *D, QualType Ty,
441+
const ASTContext &Ctx, const Decl *D, QualType Ty,
442442
LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel,
443443
bool IgnoreTemplateOrMacroSubstitution) {
444444
// For compatibility with existing code, we treat arrays of length 0 or

clang/lib/AST/Expr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ bool Expr::isKnownToHaveBooleanValue(bool Semantic) const {
203203
}
204204

205205
bool Expr::isFlexibleArrayMemberLike(
206-
ASTContext &Ctx,
206+
const ASTContext &Ctx,
207207
LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel,
208208
bool IgnoreTemplateOrMacroSubstitution) const {
209209
const Expr *E = IgnoreParens();

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,11 @@ void TextNodeDumper::VisitEnumDecl(const EnumDecl *D) {
21892189
OS << " __module_private__";
21902190
if (D->isFixed())
21912191
dumpType(D->getIntegerType());
2192+
2193+
if (const auto *Instance = D->getInstantiatedFromMemberEnum()) {
2194+
OS << " instantiated_from";
2195+
dumpPointer(Instance);
2196+
}
21922197
}
21932198

21942199
void TextNodeDumper::VisitRecordDecl(const RecordDecl *D) {

clang/test/AST/ast-dump-decl.cpp

Lines changed: 111 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ class testEnumDecl {
1515
enum TestEnumDeclFixed : int;
1616
};
1717
// CHECK: EnumDecl{{.*}} class TestEnumDeclScoped 'int'
18+
// CHECK-NOT: instantiated_from
1819
// CHECK: EnumDecl{{.*}} TestEnumDeclFixed 'int'
20+
// CHECK-NOT: instantiated_from
1921

2022
class testFieldDecl {
2123
int TestFieldDeclInit = 0;
@@ -328,9 +330,9 @@ namespace testClassTemplateDecl {
328330
// CHECK-NEXT: | | `-Destructor irrelevant non_trivial user_declared{{$}}
329331
// CHECK-NEXT: | |-CXXRecordDecl 0x{{.+}} <col:24, col:30> col:30 implicit referenced class TestClassTemplate{{$}}
330332
// CHECK-NEXT: | |-AccessSpecDecl 0x{{.+}} <line:[[@LINE-50]]:3, col:9> col:3 public{{$}}
331-
// CHECK-NEXT: | |-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-50]]:5, col:23> col:5 TestClassTemplate<T> 'void ()'{{$}}
332-
// CHECK-NEXT: | |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-50]]:5, col:24> col:5 ~TestClassTemplate<T> 'void ()' not_selected{{$}}
333-
// CHECK-NEXT: | |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-50]]:5, col:11> col:9 j 'int ()'{{$}}
333+
// CHECK-NEXT: | |-CXXConstructorDecl 0x[[#%x,TEMPLATE_CONSTRUCTOR_DECL:]] <line:[[@LINE-50]]:5, col:23> col:5 TestClassTemplate<T> 'void ()'{{$}}
334+
// CHECK-NEXT: | |-CXXDestructorDecl 0x[[#%x,TEMPLATE_DESTRUCTOR_DECL:]] <line:[[@LINE-50]]:5, col:24> col:5 ~TestClassTemplate<T> 'void ()' not_selected{{$}}
335+
// CHECK-NEXT: | |-CXXMethodDecl 0x[[#%x,TEMPLATE_METHOD_DECL:]] <line:[[@LINE-50]]:5, col:11> col:9 j 'int ()'{{$}}
334336
// CHECK-NEXT: | `-FieldDecl 0x{{.+}} <line:[[@LINE-50]]:5, col:9> col:9 i 'int'{{$}}
335337
// CHECK-NEXT: |-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-56]]:3, line:[[@LINE-50]]:3> line:[[@LINE-56]]:30 class TestClassTemplate definition implicit_instantiation{{$}}
336338
// CHECK-NEXT: | |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init{{$}}
@@ -345,9 +347,9 @@ namespace testClassTemplateDecl {
345347
// CHECK-NEXT: | | `-CXXRecord 0x{{.+}} 'A'{{$}}
346348
// CHECK-NEXT: | |-CXXRecordDecl 0x{{.+}} <col:24, col:30> col:30 implicit class TestClassTemplate{{$}}
347349
// CHECK-NEXT: | |-AccessSpecDecl 0x{{.+}} <line:[[@LINE-67]]:3, col:9> col:3 public{{$}}
348-
// CHECK-NEXT: | |-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:23> col:5 used TestClassTemplate 'void ()' implicit_instantiation instantiated_from {{0x[^ ]+}}{{$}}
349-
// CHECK-NEXT: | |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:24> col:5 used ~TestClassTemplate 'void () noexcept' implicit_instantiation instantiated_from {{0x[^ ]+}}{{$}}
350-
// CHECK-NEXT: | |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:11> col:9 j 'int ()' implicit_instantiation instantiated_from {{0x[^ ]+}}{{$}}
350+
// CHECK-NEXT: | |-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:23> col:5 used TestClassTemplate 'void ()' implicit_instantiation instantiated_from 0x[[#TEMPLATE_CONSTRUCTOR_DECL]]{{$}}
351+
// CHECK-NEXT: | |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:24> col:5 used ~TestClassTemplate 'void () noexcept' implicit_instantiation instantiated_from 0x[[#TEMPLATE_DESTRUCTOR_DECL]]{{$}}
352+
// CHECK-NEXT: | |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:11> col:9 j 'int ()' implicit_instantiation instantiated_from 0x[[#TEMPLATE_METHOD_DECL]]{{$}}
351353
// CHECK-NEXT: | |-FieldDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:9> col:9 i 'int'{{$}}
352354
// CHECK-NEXT: | `-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-73]]:30> col:30 implicit constexpr TestClassTemplate 'void (const TestClassTemplate<A> &)' inline default trivial noexcept-unevaluated 0x{{.+}}{{$}}
353355
// CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} <col:30> col:30 'const TestClassTemplate<A> &'{{$}}
@@ -487,6 +489,109 @@ namespace testClassTemplateDecl {
487489
// CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} <col:41, col:48> col:48 implicit struct TestTemplateTemplateDefaultType{{$}}
488490

489491

492+
namespace testClassTemplateDecl {
493+
template<typename T> struct TestClassTemplateWithScopedMemberEnum {
494+
enum class E1 : T { A, B, C, D };
495+
enum class E2 : int { A, B, C, D };
496+
enum class E3 : T;
497+
enum class E4 : int;
498+
};
499+
500+
template struct TestClassTemplateWithScopedMemberEnum<unsigned>;
501+
502+
TestClassTemplateWithScopedMemberEnum<int> TestClassTemplateWithScopedMemberEnumObject;
503+
}
504+
505+
// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-12]]:3, line:[[@LINE-7]]:3> line:[[@LINE-12]]:31 TestClassTemplateWithScopedMemberEnum
506+
// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 referenced typename depth 0 index 0 T
507+
// CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <col:24, line:[[@LINE-9]]:3> line:[[@LINE-14]]:31 struct TestClassTemplateWithScopedMemberEnum definition
508+
// CHECK: | |-EnumDecl 0x[[#%x,SCOPED_MEMBER_ENUM_E1:]] <line:[[@LINE-14]]:5, col:36> col:16 class E1 'T'
509+
// CHECK-NEXT: | | |-EnumConstantDecl 0x{{.+}} <col:25> col:25 A 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum::E1'
510+
// CHECK-NEXT: | | |-EnumConstantDecl 0x{{.+}} <col:28> col:28 B 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum::E1'
511+
// CHECK-NEXT: | | |-EnumConstantDecl 0x{{.+}} <col:31> col:31 C 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum::E1'
512+
// CHECK-NEXT: | | `-EnumConstantDecl 0x{{.+}} <col:34> col:34 D 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum::E1'
513+
// CHECK-NEXT: | |-EnumDecl 0x[[#%x,SCOPED_MEMBER_ENUM_E2:]] <line:[[@LINE-18]]:5, col:38> col:16 class E2 'int'
514+
// CHECK-NEXT: | | |-EnumConstantDecl 0x{{.+}} <col:27> col:27 A 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum::E2'
515+
// CHECK-NEXT: | | |-EnumConstantDecl 0x{{.+}} <col:30> col:30 B 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum::E2'
516+
// CHECK-NEXT: | | |-EnumConstantDecl 0x{{.+}} <col:33> col:33 C 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum::E2'
517+
// CHECK-NEXT: | | `-EnumConstantDecl 0x{{.+}} <col:36> col:36 D 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum::E2'
518+
// CHECK-NEXT: | |-EnumDecl 0x[[#%x,SCOPED_MEMBER_ENUM_E3:]] <line:[[@LINE-22]]:5, col:21> col:16 class E3 'T'
519+
// CHECK-NEXT: | `-EnumDecl 0x[[#%x,SCOPED_MEMBER_ENUM_E4:]] <line:[[@LINE-22]]:5, col:21> col:16 class E4 'int'
520+
// CHECK-NEXT: |-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplateWithScopedMemberEnum'
521+
// CHECK-NEXT: `-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-28]]:3, line:[[@LINE-23]]:3> line:[[@LINE-28]]:31 struct TestClassTemplateWithScopedMemberEnum definition implicit_instantiation
522+
// CHECK: |-TemplateArgument type 'int'
523+
// CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'int'
524+
// CHECK: |-EnumDecl 0x{{.+}} <line:[[@LINE-30]]:5, col:21> col:16 class E1 'int' instantiated_from 0x[[#SCOPED_MEMBER_ENUM_E1]]{{$}}
525+
// CHECK-NEXT: |-EnumDecl 0x{{.+}} <line:[[@LINE-30]]:5, col:21> col:16 class E2 'int' instantiated_from 0x[[#SCOPED_MEMBER_ENUM_E2]]{{$}}
526+
// CHECK-NEXT: |-EnumDecl 0x{{.+}} <line:[[@LINE-30]]:5, col:21> col:16 class E3 'int' instantiated_from 0x[[#SCOPED_MEMBER_ENUM_E3]]{{$}}
527+
// CHECK-NEXT: |-EnumDecl 0x{{.+}} <line:[[@LINE-30]]:5, col:21> col:16 class E4 'int' instantiated_from 0x[[#SCOPED_MEMBER_ENUM_E4]]{{$}}
528+
529+
// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-29]]:3, col:65> col:19 struct TestClassTemplateWithScopedMemberEnum definition explicit_instantiation_definition
530+
// CHECK: |-TemplateArgument type 'unsigned int'
531+
// CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'unsigned int'
532+
// CHECK: |-EnumDecl 0x{{.+}} <line:[[@LINE-38]]:5, col:21> col:16 class E1 'unsigned int' instantiated_from 0x[[#SCOPED_MEMBER_ENUM_E1]]{{$}}
533+
// CHECK-NEXT: | |-EnumConstantDecl 0x{{.+}} <col:25> col:25 A 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum<unsigned int>::E1'
534+
// CHECK-NEXT: | |-EnumConstantDecl 0x{{.+}} <col:28> col:28 B 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum<unsigned int>::E1'
535+
// CHECK-NEXT: | |-EnumConstantDecl 0x{{.+}} <col:31> col:31 C 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum<unsigned int>::E1'
536+
// CHECK-NEXT: | `-EnumConstantDecl 0x{{.+}} <col:34> col:34 D 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum<unsigned int>::E1'
537+
// CHECK-NEXT: |-EnumDecl 0x{{.+}} <line:[[@LINE-42]]:5, col:21> col:16 class E2 'int' instantiated_from 0x[[#SCOPED_MEMBER_ENUM_E2]]{{$}}
538+
// CHECK-NEXT: | |-EnumConstantDecl 0x{{.+}} <col:27> col:27 A 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum<unsigned int>::E2'
539+
// CHECK-NEXT: | |-EnumConstantDecl 0x{{.+}} <col:30> col:30 B 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum<unsigned int>::E2'
540+
// CHECK-NEXT: | |-EnumConstantDecl 0x{{.+}} <col:33> col:33 C 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum<unsigned int>::E2'
541+
// CHECK-NEXT: | `-EnumConstantDecl 0x{{.+}} <col:36> col:36 D 'testClassTemplateDecl::TestClassTemplateWithScopedMemberEnum<unsigned int>::E2'
542+
// CHECK-NEXT: |-EnumDecl 0x{{.+}} <line:[[@LINE-46]]:5, col:21> col:16 class E3 'unsigned int' instantiated_from 0x[[#SCOPED_MEMBER_ENUM_E3]]{{$}}
543+
// CHECK-NEXT: `-EnumDecl 0x{{.+}} <line:[[@LINE-46]]:5, col:21> col:16 class E4 'int' instantiated_from 0x[[#SCOPED_MEMBER_ENUM_E4]]{{$}}
544+
545+
546+
547+
548+
namespace testClassTemplateDecl {
549+
template<typename T> struct TestClassTemplateWithUnscopedMemberEnum {
550+
enum E1 : T { E1_A, E1_B, E1_C, E1_D };
551+
enum E2 : int { E2_A, E2_B, E2_C, E2_D };
552+
enum E3 : T;
553+
enum E4 : int;
554+
};
555+
556+
template struct TestClassTemplateWithUnscopedMemberEnum<unsigned>;
557+
558+
TestClassTemplateWithUnscopedMemberEnum<unsigned> TestClassTemplateWithUnscopedMemberEnumObject;
559+
}
560+
561+
// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-12]]:3, line:[[@LINE-7]]:3> line:[[@LINE-12]]:31 TestClassTemplateWithUnscopedMemberEnum
562+
// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 referenced typename depth 0 index 0 T
563+
// CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <col:24, line:[[@LINE-9]]:3> line:[[@LINE-14]]:31 struct TestClassTemplateWithUnscopedMemberEnum definition
564+
// CHECK: | |-EnumDecl 0x[[#%x,UNSCOPED_MEMBER_ENUM_E1:]] <line:[[@LINE-14]]:5, col:42> col:10 E1 'T'
565+
// CHECK-NEXT: | | |-EnumConstantDecl 0x{{.+}} <col:19> col:19 E1_A 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum::E1'
566+
// CHECK-NEXT: | | |-EnumConstantDecl 0x{{.+}} <col:25> col:25 E1_B 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum::E1'
567+
// CHECK-NEXT: | | |-EnumConstantDecl 0x{{.+}} <col:31> col:31 E1_C 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum::E1'
568+
// CHECK-NEXT: | | `-EnumConstantDecl 0x{{.+}} <col:37> col:37 E1_D 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum::E1'
569+
// CHECK-NEXT: | |-EnumDecl 0x[[#%x,UNSCOPED_MEMBER_ENUM_E2:]] <line:[[@LINE-18]]:5, col:44> col:10 E2 'int'
570+
// CHECK-NEXT: | | |-EnumConstantDecl 0x{{.+}} <col:21> col:21 E2_A 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum::E2'
571+
// CHECK-NEXT: | | |-EnumConstantDecl 0x{{.+}} <col:27> col:27 E2_B 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum::E2'
572+
// CHECK-NEXT: | | |-EnumConstantDecl 0x{{.+}} <col:33> col:33 E2_C 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum::E2'
573+
// CHECK-NEXT: | | `-EnumConstantDecl 0x{{.+}} <col:39> col:39 E2_D 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum::E2'
574+
// CHECK-NEXT: | |-EnumDecl 0x[[#%x,UNSCOPED_MEMBER_ENUM_E3:]] <line:[[@LINE-22]]:5, col:15> col:10 E3 'T'
575+
// CHECK-NEXT: | `-EnumDecl 0x[[#%x,UNSCOPED_MEMBER_ENUM_E4:]] <line:[[@LINE-22]]:5, col:15> col:10 E4 'int'
576+
// CHECK-NEXT: `-ClassTemplateSpecialization {{.+}} 'TestClassTemplateWithUnscopedMemberEnum'
577+
578+
// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-22]]:3, col:67> col:19 struct TestClassTemplateWithUnscopedMemberEnum definition explicit_instantiation_definition
579+
// CHECK: |-TemplateArgument type 'unsigned int'
580+
// CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'unsigned int'
581+
// CHECK: |-EnumDecl 0x{{.+}} <line:[[@LINE-31]]:5, col:15> col:10 E1 'unsigned int' instantiated_from 0x[[#UNSCOPED_MEMBER_ENUM_E1]]{{$}}
582+
// CHECK-NEXT: | |-EnumConstantDecl 0x{{.+}} <col:19> col:19 E1_A 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum<unsigned int>::E1'
583+
// CHECK-NEXT: | |-EnumConstantDecl 0x{{.+}} <col:25> col:25 E1_B 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum<unsigned int>::E1'
584+
// CHECK-NEXT: | |-EnumConstantDecl 0x{{.+}} <col:31> col:31 E1_C 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum<unsigned int>::E1'
585+
// CHECK-NEXT: | `-EnumConstantDecl 0x{{.+}} <col:37> col:37 E1_D 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum<unsigned int>::E1'
586+
// CHECK-NEXT: |-EnumDecl 0x{{.+}} <line:[[@LINE-35]]:5, col:15> col:10 E2 'int' instantiated_from 0x[[#UNSCOPED_MEMBER_ENUM_E2]]{{$}}
587+
// CHECK-NEXT: | |-EnumConstantDecl 0x{{.+}} <col:21> col:21 E2_A 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum<unsigned int>::E2'
588+
// CHECK-NEXT: | |-EnumConstantDecl 0x{{.+}} <col:27> col:27 E2_B 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum<unsigned int>::E2'
589+
// CHECK-NEXT: | |-EnumConstantDecl 0x{{.+}} <col:33> col:33 E2_C 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum<unsigned int>::E2'
590+
// CHECK-NEXT: | `-EnumConstantDecl 0x{{.+}} <col:39> col:39 E2_D 'testClassTemplateDecl::TestClassTemplateWithUnscopedMemberEnum<unsigned int>::E2'
591+
// CHECK-NEXT: |-EnumDecl 0x{{.+}} <line:[[@LINE-39]]:5, col:15> col:10 E3 'unsigned int' instantiated_from 0x[[#UNSCOPED_MEMBER_ENUM_E3]]{{$}}
592+
// CHECK-NEXT: |-EnumDecl 0x{{.+}} <line:[[@LINE-39]]:5, col:15> col:10 E4 'int' instantiated_from 0x[[#UNSCOPED_MEMBER_ENUM_E4]]{{$}}
593+
594+
490595
// PR15220 dump instantiation only once
491596
namespace testCanonicalTemplate {
492597
class A {};

flang/include/flang/Lower/AbstractConverter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ class AbstractConverter {
314314
mangleName(const Fortran::semantics::DerivedTypeSpec &) = 0;
315315
/// Unique a compiler generated name (add a containing scope specific prefix)
316316
virtual std::string mangleName(std::string &) = 0;
317+
/// Unique a compiler generated name (add a provided scope specific prefix)
318+
virtual std::string mangleName(std::string &, const semantics::Scope &) = 0;
317319
/// Return the field name for a derived type component inside a fir.record
318320
/// type.
319321
virtual std::string

flang/lib/Lower/Bridge.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,11 @@ class FirConverter : public Fortran::lower::AbstractConverter {
10491049
return Fortran::lower::mangle::mangleName(name, getCurrentScope(),
10501050
scopeBlockIdMap);
10511051
}
1052+
std::string
1053+
mangleName(std::string &name,
1054+
const Fortran::semantics::Scope &myScope) override final {
1055+
return Fortran::lower::mangle::mangleName(name, myScope, scopeBlockIdMap);
1056+
}
10521057
std::string getRecordTypeFieldName(
10531058
const Fortran::semantics::Symbol &component) override final {
10541059
return Fortran::lower::mangle::getRecordTypeFieldName(component,

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3119,7 +3119,51 @@ static void
31193119
genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
31203120
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
31213121
const parser::OpenMPDeclareMapperConstruct &declareMapperConstruct) {
3122-
TODO(converter.getCurrentLocation(), "OpenMPDeclareMapperConstruct");
3122+
mlir::Location loc = converter.genLocation(declareMapperConstruct.source);
3123+
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
3124+
lower::StatementContext stmtCtx;
3125+
const auto &spec =
3126+
std::get<parser::OmpMapperSpecifier>(declareMapperConstruct.t);
3127+
const auto &mapperName{std::get<std::optional<parser::Name>>(spec.t)};
3128+
const auto &varType{std::get<parser::TypeSpec>(spec.t)};
3129+
const auto &varName{std::get<parser::Name>(spec.t)};
3130+
assert(varType.declTypeSpec->category() ==
3131+
semantics::DeclTypeSpec::Category::TypeDerived &&
3132+
"Expected derived type");
3133+
3134+
std::string mapperNameStr;
3135+
if (mapperName.has_value()) {
3136+
mapperNameStr = mapperName->ToString();
3137+
mapperNameStr =
3138+
converter.mangleName(mapperNameStr, mapperName->symbol->owner());
3139+
} else {
3140+
mapperNameStr =
3141+
varType.declTypeSpec->derivedTypeSpec().name().ToString() + ".default";
3142+
mapperNameStr = converter.mangleName(
3143+
mapperNameStr, *varType.declTypeSpec->derivedTypeSpec().GetScope());
3144+
}
3145+
3146+
// Save current insertion point before moving to the module scope to create
3147+
// the DeclareMapperOp
3148+
mlir::OpBuilder::InsertionGuard guard(firOpBuilder);
3149+
3150+
firOpBuilder.setInsertionPointToStart(converter.getModuleOp().getBody());
3151+
auto mlirType = converter.genType(varType.declTypeSpec->derivedTypeSpec());
3152+
auto declMapperOp = firOpBuilder.create<mlir::omp::DeclareMapperOp>(
3153+
loc, mapperNameStr, mlirType);
3154+
auto &region = declMapperOp.getRegion();
3155+
firOpBuilder.createBlock(&region);
3156+
auto varVal = region.addArgument(firOpBuilder.getRefType(mlirType), loc);
3157+
converter.bindSymbol(*varName.symbol, varVal);
3158+
3159+
// Populate the declareMapper region with the map information.
3160+
mlir::omp::DeclareMapperInfoOperands clauseOps;
3161+
const auto *clauseList{
3162+
parser::Unwrap<parser::OmpClauseList>(declareMapperConstruct.t)};
3163+
List<Clause> clauses = makeClauses(*clauseList, semaCtx);
3164+
ClauseProcessor cp(converter, semaCtx, clauses);
3165+
cp.processMap(loc, stmtCtx, clauseOps);
3166+
firOpBuilder.create<mlir::omp::DeclareMapperInfoOp>(loc, clauseOps.mapVars);
31233167
}
31243168

31253169
static void

flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ class MapInfoFinalizationPass
464464
for (auto *user : mapOp->getUsers()) {
465465
if (llvm::isa<mlir::omp::TargetOp, mlir::omp::TargetDataOp,
466466
mlir::omp::TargetUpdateOp, mlir::omp::TargetExitDataOp,
467-
mlir::omp::TargetEnterDataOp>(user))
467+
mlir::omp::TargetEnterDataOp,
468+
mlir::omp::DeclareMapperInfoOp>(user))
468469
return user;
469470

470471
if (auto mapUser = llvm::dyn_cast<mlir::omp::MapInfoOp>(user))
@@ -497,7 +498,9 @@ class MapInfoFinalizationPass
497498
// ourselves to the possibility of race conditions while this pass
498499
// undergoes frequent re-iteration for the near future. So we loop
499500
// over function in the module and then map.info inside of those.
500-
getOperation()->walk([&](mlir::func::FuncOp func) {
501+
getOperation()->walk([&](mlir::Operation *func) {
502+
if (!mlir::isa<mlir::func::FuncOp, mlir::omp::DeclareMapperOp>(func))
503+
return;
501504
// clear all local allocations we made for any boxes in any prior
502505
// iterations from previous function scopes.
503506
localBoxAllocas.clear();

0 commit comments

Comments
 (0)