yonghong-song updated this revision to Diff 411182. yonghong-song added a comment.
fix clang-format issues. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D120296/new/ https://reviews.llvm.org/D120296 Files: clang/include/clang/AST/ASTContext.h clang/include/clang/AST/Type.h clang/lib/AST/ASTContext.cpp clang/lib/Sema/SemaType.cpp clang/test/CodeGen/attr-btf_type_tag-similar-type.c
Index: clang/test/CodeGen/attr-btf_type_tag-similar-type.c =================================================================== --- /dev/null +++ clang/test/CodeGen/attr-btf_type_tag-similar-type.c @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s + +struct map_value { + int __attribute__((btf_type_tag("tag1"))) __attribute__((btf_type_tag("tag3"))) *a; + int __attribute__((btf_type_tag("tag2"))) __attribute__((btf_type_tag("tag4"))) *b; +}; + +struct map_value *func(void); + +int test(struct map_value *arg) +{ + return *arg->a; +} + +// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "map_value", file: ![[#]], line: [[#]], size: [[#]], elements: ![[L14:[0-9]+]] +// CHECK: ![[L14]] = !{![[L15:[0-9]+]], ![[L20:[0-9]+]]} +// CHECK: ![[L15]] = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[L16:[0-9]+]] +// CHECK: ![[L16]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[#]], size: [[#]], annotations: ![[L17:[0-9]+]] +// CHECK: ![[L17]] = !{![[L18:[0-9]+]], ![[L19:[0-9]+]]} +// CHECK: ![[L18]] = !{!"btf_type_tag", !"tag1"} +// CHECK: ![[L19]] = !{!"btf_type_tag", !"tag3"} +// CHECK: ![[L20]] = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[L21:[0-9]+]] +// CHECK: ![[L21:[0-9]+]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[#]], size: [[#]], annotations: ![[L22:[0-9]+]] +// CHECK: ![[L22]] = !{![[L23:[0-9]+]], ![[L24:[0-9]+]]} +// CHECK: ![[L23]] = !{!"btf_type_tag", !"tag2"} +// CHECK: ![[L24]] = !{!"btf_type_tag", !"tag4"} Index: clang/lib/Sema/SemaType.cpp =================================================================== --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -258,9 +258,10 @@ /// Get an attributed type for the given attribute, and remember the Attr /// object so that we can attach it to the AttributedTypeLoc. QualType getAttributedType(Attr *A, QualType ModifiedType, - QualType EquivType) { - QualType T = - sema.Context.getAttributedType(A->getKind(), ModifiedType, EquivType); + QualType EquivType, + StringRef ExtraInfo = StringRef()) { + QualType T = sema.Context.getAttributedType(A->getKind(), ModifiedType, + EquivType, ExtraInfo); AttrsForTypes.push_back({cast<AttributedType>(T.getTypePtr()), A}); AttrsForTypesSorted = false; return T; @@ -6553,8 +6554,9 @@ ASTContext &Ctx = S.Context; StringRef BTFTypeTag = StrLiteral->getString(); - Type = State.getAttributedType( - ::new (Ctx) BTFTypeTagAttr(Ctx, Attr, BTFTypeTag), Type, Type); + Type = + State.getAttributedType(::new (Ctx) BTFTypeTagAttr(Ctx, Attr, BTFTypeTag), + Type, Type, BTFTypeTag); } /// HandleAddressSpaceTypeAttribute - Process an address_space attribute on the Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -4665,9 +4665,11 @@ QualType ASTContext::getAttributedType(attr::Kind attrKind, QualType modifiedType, - QualType equivalentType) { + QualType equivalentType, + StringRef extraInfo) { llvm::FoldingSetNodeID id; - AttributedType::Profile(id, attrKind, modifiedType, equivalentType); + AttributedType::Profile(id, attrKind, modifiedType, equivalentType, + extraInfo); void *insertPos = nullptr; AttributedType *type = AttributedTypes.FindNodeOrInsertPos(id, insertPos); Index: clang/include/clang/AST/Type.h =================================================================== --- clang/include/clang/AST/Type.h +++ clang/include/clang/AST/Type.h @@ -4775,10 +4775,12 @@ } static void Profile(llvm::FoldingSetNodeID &ID, Kind attrKind, - QualType modified, QualType equivalent) { + QualType modified, QualType equivalent, + StringRef extraInfo = StringRef()) { ID.AddInteger(attrKind); ID.AddPointer(modified.getAsOpaquePtr()); ID.AddPointer(equivalent.getAsOpaquePtr()); + ID.AddString(extraInfo); } static bool classof(const Type *T) { Index: clang/include/clang/AST/ASTContext.h =================================================================== --- clang/include/clang/AST/ASTContext.h +++ clang/include/clang/AST/ASTContext.h @@ -1588,9 +1588,9 @@ QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const; - QualType getAttributedType(attr::Kind attrKind, - QualType modifiedType, - QualType equivalentType); + QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, + QualType equivalentType, + StringRef extraInfo = StringRef()); QualType getSubstTemplateTypeParmType(const TemplateTypeParmType *Replaced, QualType Replacement) const;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits