Skip to content

Commit

Permalink
[Clang][Attr] rename btf_tag to btf_decl_tag
Browse files Browse the repository at this point in the history
Current btf_tag is applied to declaration only.
Per discussion in https://reviews.llvm.org/D111199,
we plan to introduce btf_type_tag attribute for types.
So rename btf_tag to btf_decl_tag to make it easily
differentiable from btf_type_tag.

Differential Revision: https://reviews.llvm.org/D111588
  • Loading branch information
yonghong-song committed Oct 12, 2021
1 parent ef64361 commit a162b67
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 75 deletions.
8 changes: 4 additions & 4 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1836,11 +1836,11 @@ def BPFPreserveAccessIndex : InheritableAttr,
let LangOpts = [COnly];
}

def BTFTag : InheritableAttr {
let Spellings = [Clang<"btf_tag">];
let Args = [StringArgument<"BTFTag">];
def BTFDeclTag : InheritableAttr {
let Spellings = [Clang<"btf_decl_tag">];
let Args = [StringArgument<"BTFDeclTag">];
let Subjects = SubjectList<[Var, Function, Record, Field], ErrorDiag>;
let Documentation = [BTFTagDocs];
let Documentation = [BTFDeclTagDocs];
let LangOpts = [COnly];
}

Expand Down
8 changes: 4 additions & 4 deletions clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -2011,12 +2011,12 @@ preserving struct or union member access debuginfo indices of this
struct or union, similar to clang ``__builtin_preserve_access_index()``.
}];
}
def BTFTagDocs : Documentation {
def BTFDeclTagDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
Clang supports the ``__attribute__((btf_tag("ARGUMENT")))`` attribute for all
targets. This attribute may be attached to a struct/union, struct/union field,
function, function parameter or variable declaration. If -g is specified,
Clang supports the ``__attribute__((btf_decl_tag("ARGUMENT")))`` attribute for
all targets. This attribute may be attached to a struct/union, struct/union
field, function, function parameter or variable declaration. If -g is specified,
the ``ARGUMENT`` info will be preserved in IR and be emitted to dwarf.
For BPF targets, the ``ARGUMENT`` info will be emitted to .BTF ELF section too.
}];
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -3390,7 +3390,7 @@ class Sema final {
EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL);
EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D,
const EnforceTCBLeafAttr &AL);
BTFTagAttr *mergeBTFTagAttr(Decl *D, const BTFTagAttr &AL);
BTFDeclTagAttr *mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL);

void mergeDeclAttributes(NamedDecl *New, Decl *Old,
AvailabilityMergeKind AMK = AMK_Redeclaration);
Expand Down
24 changes: 12 additions & 12 deletions clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ llvm::DIType *CGDebugInfo::createBitFieldType(const FieldDecl *BitFieldDecl,
Offset = BitFieldInfo.StorageSize - BitFieldInfo.Size - Offset;
uint64_t OffsetInBits = StorageOffsetInBits + Offset;
llvm::DINode::DIFlags Flags = getAccessFlag(BitFieldDecl->getAccess(), RD);
llvm::DINodeArray Annotations = CollectBTFTagAnnotations(BitFieldDecl);
llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(BitFieldDecl);
return DBuilder.createBitFieldMemberType(
RecordTy, Name, File, Line, SizeInBits, OffsetInBits, StorageOffsetInBits,
Flags, DebugType, Annotations);
Expand Down Expand Up @@ -1541,7 +1541,7 @@ void CGDebugInfo::CollectRecordNormalField(
FieldType = createBitFieldType(field, RecordTy, RD);
} else {
auto Align = getDeclAlignIfRequired(field, CGM.getContext());
llvm::DINodeArray Annotations = CollectBTFTagAnnotations(field);
llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(field);
FieldType =
createFieldType(name, type, field->getLocation(), field->getAccess(),
OffsetInBits, Align, tunit, RecordTy, RD, Annotations);
Expand Down Expand Up @@ -2141,15 +2141,15 @@ llvm::DINodeArray CGDebugInfo::CollectCXXTemplateParams(const RecordDecl *RD,
return CollectTemplateParams(GetTemplateArgs(RD), Unit);
}

llvm::DINodeArray CGDebugInfo::CollectBTFTagAnnotations(const Decl *D) {
if (!D->hasAttr<BTFTagAttr>())
llvm::DINodeArray CGDebugInfo::CollectBTFDeclTagAnnotations(const Decl *D) {
if (!D->hasAttr<BTFDeclTagAttr>())
return nullptr;

SmallVector<llvm::Metadata *, 4> Annotations;
for (const auto *I : D->specific_attrs<BTFTagAttr>()) {
for (const auto *I : D->specific_attrs<BTFDeclTagAttr>()) {
llvm::Metadata *Ops[2] = {
llvm::MDString::get(CGM.getLLVMContext(), StringRef("btf_tag")),
llvm::MDString::get(CGM.getLLVMContext(), I->getBTFTag())};
llvm::MDString::get(CGM.getLLVMContext(), StringRef("btf_decl_tag")),
llvm::MDString::get(CGM.getLLVMContext(), I->getBTFDeclTag())};
Annotations.push_back(llvm::MDNode::get(CGM.getLLVMContext(), Ops));
}
return DBuilder.getOrCreateArray(Annotations);
Expand Down Expand Up @@ -3527,7 +3527,7 @@ llvm::DICompositeType *CGDebugInfo::CreateLimitedType(const RecordType *Ty) {
Flags |= llvm::DINode::FlagExportSymbols;
}

llvm::DINodeArray Annotations = CollectBTFTagAnnotations(D);
llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(D);
llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(
getTagForRecord(RD), RDName, RDContext, DefUnit, Line, 0, Size, Align,
Flags, Identifier, Annotations);
Expand Down Expand Up @@ -4047,7 +4047,7 @@ void CGDebugInfo::emitFunctionStart(GlobalDecl GD, SourceLocation Loc,
Decl = isa<ObjCMethodDecl>(D)
? getObjCMethodDeclaration(D, DIFnType, LineNo, Flags, SPFlags)
: getFunctionDeclaration(D);
Annotations = CollectBTFTagAnnotations(D);
Annotations = CollectBTFDeclTagAnnotations(D);
}

// FIXME: The function declaration we're constructing here is mostly reusing
Expand Down Expand Up @@ -4117,7 +4117,7 @@ void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
if (CGM.getLangOpts().Optimize)
SPFlags |= llvm::DISubprogram::SPFlagOptimized;

llvm::DINodeArray Annotations = CollectBTFTagAnnotations(D);
llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(D);
llvm::DISubprogram *SP = DBuilder.createFunction(
FDContext, Name, LinkageName, Unit, LineNo,
getOrCreateFunctionType(D, FnType, Unit), ScopeLine, Flags, SPFlags,
Expand Down Expand Up @@ -4458,7 +4458,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
// Create the descriptor for the variable.
llvm::DILocalVariable *D = nullptr;
if (ArgNo) {
llvm::DINodeArray Annotations = CollectBTFTagAnnotations(VD);
llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(VD);
D = DBuilder.createParameterVariable(Scope, Name, *ArgNo, Unit, Line, Ty,
CGM.getLangOpts().Optimize, Flags,
Annotations);
Expand Down Expand Up @@ -5079,7 +5079,7 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
}
AppendAddressSpaceXDeref(AddressSpace, Expr);

llvm::DINodeArray Annotations = CollectBTFTagAnnotations(D);
llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(D);
GVE = DBuilder.createGlobalVariableExpression(
DContext, DeclName, LinkageName, Unit, LineNo, getOrCreateType(T, Unit),
Var->hasLocalLinkage(), true,
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/CGDebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ class CGDebugInfo {
llvm::DINodeArray CollectCXXTemplateParams(const RecordDecl *TS,
llvm::DIFile *F);

/// A helper function to collect debug info for btf_tag annotations.
llvm::DINodeArray CollectBTFTagAnnotations(const Decl *D);
/// A helper function to collect debug info for btf_decl_tag annotations.
llvm::DINodeArray CollectBTFDeclTagAnnotations(const Decl *D);

llvm::DIType *createFieldType(StringRef name, QualType type,
SourceLocation loc, AccessSpecifier AS,
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2679,8 +2679,8 @@ static bool mergeDeclAttribute(Sema &S, NamedDecl *D,
NewAttr = S.mergeEnforceTCBAttr(D, *TCBA);
else if (const auto *TCBLA = dyn_cast<EnforceTCBLeafAttr>(Attr))
NewAttr = S.mergeEnforceTCBLeafAttr(D, *TCBLA);
else if (const auto *BTFA = dyn_cast<BTFTagAttr>(Attr))
NewAttr = S.mergeBTFTagAttr(D, *BTFA);
else if (const auto *BTFA = dyn_cast<BTFDeclTagAttr>(Attr))
NewAttr = S.mergeBTFDeclTagAttr(D, *BTFA);
else if (Attr->shouldInheritEvenIfAlreadyPresent() || !DeclHasAttr(D, Attr))
NewAttr = cast<InheritableAttr>(Attr->clone(S.Context));

Expand Down
22 changes: 11 additions & 11 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6887,28 +6887,28 @@ static void handleBPFPreserveAccessIndexAttr(Sema &S, Decl *D,
Rec->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, AL));
}

static bool hasBTFTagAttr(Decl *D, StringRef Tag) {
for (const auto *I : D->specific_attrs<BTFTagAttr>()) {
if (I->getBTFTag() == Tag)
static bool hasBTFDeclTagAttr(Decl *D, StringRef Tag) {
for (const auto *I : D->specific_attrs<BTFDeclTagAttr>()) {
if (I->getBTFDeclTag() == Tag)
return true;
}
return false;
}

static void handleBTFTagAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
static void handleBTFDeclTagAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
StringRef Str;
if (!S.checkStringLiteralArgumentAttr(AL, 0, Str))
return;
if (hasBTFTagAttr(D, Str))
if (hasBTFDeclTagAttr(D, Str))
return;

D->addAttr(::new (S.Context) BTFTagAttr(S.Context, AL, Str));
D->addAttr(::new (S.Context) BTFDeclTagAttr(S.Context, AL, Str));
}

BTFTagAttr *Sema::mergeBTFTagAttr(Decl *D, const BTFTagAttr &AL) {
if (hasBTFTagAttr(D, AL.getBTFTag()))
BTFDeclTagAttr *Sema::mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL) {
if (hasBTFDeclTagAttr(D, AL.getBTFDeclTag()))
return nullptr;
return ::new (Context) BTFTagAttr(Context, AL, AL.getBTFTag());
return ::new (Context) BTFDeclTagAttr(Context, AL, AL.getBTFDeclTag());
}

static void handleWebAssemblyExportNameAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
Expand Down Expand Up @@ -7947,8 +7947,8 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
case ParsedAttr::AT_BPFPreserveAccessIndex:
handleBPFPreserveAccessIndexAttr(S, D, AL);
break;
case ParsedAttr::AT_BTFTag:
handleBTFTagAttr(S, D, AL);
case ParsedAttr::AT_BTFDeclTag:
handleBTFDeclTagAttr(S, D, AL);
break;
case ParsedAttr::AT_WebAssemblyExportName:
handleWebAssemblyExportNameAttr(S, D, AL);
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CodeGen/attr-btf_tag-dicomposite-2.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// REQUIRES: x86-registered-target
// RUN: %clang -target x86_64 -g -S -emit-llvm -o - %s | FileCheck %s

#define __tag1 __attribute__((btf_tag("tag1")))
#define __tag2 __attribute__((btf_tag("tag2")))
#define __tag1 __attribute__((btf_decl_tag("tag1")))
#define __tag2 __attribute__((btf_decl_tag("tag2")))

struct __tag1 __tag2 t1;

Expand Down
8 changes: 4 additions & 4 deletions clang/test/CodeGen/attr-btf_tag-dicomposite.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// REQUIRES: x86-registered-target
// RUN: %clang -target x86_64 -g -S -emit-llvm -o - %s | FileCheck %s

#define __tag1 __attribute__((btf_tag("tag1")))
#define __tag2 __attribute__((btf_tag("tag2")))
#define __tag1 __attribute__((btf_decl_tag("tag1")))
#define __tag2 __attribute__((btf_decl_tag("tag2")))

struct __tag1 __tag2 t1;
struct t1 {
Expand All @@ -15,8 +15,8 @@ int foo(struct t1 *arg) {

// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", file: ![[#]], line: [[#]], size: 32, elements: ![[#]], annotations: ![[ANNOT:[0-9]+]])
// CHECK: ![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]}
// CHECK: ![[TAG1]] = !{!"btf_tag", !"tag1"}
// CHECK: ![[TAG2]] = !{!"btf_tag", !"tag2"}
// CHECK: ![[TAG1]] = !{!"btf_decl_tag", !"tag1"}
// CHECK: ![[TAG2]] = !{!"btf_decl_tag", !"tag2"}

struct __tag1 t2;
struct __tag2 t2 {
Expand Down
8 changes: 4 additions & 4 deletions clang/test/CodeGen/attr-btf_tag-diglobalvariable.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// REQUIRES: x86-registered-target
// RUN: %clang -target x86_64 -g -S -emit-llvm -o - %s | FileCheck %s

#define __tag1 __attribute__((btf_tag("tag1")))
#define __tag2 __attribute__((btf_tag("tag2")))
#define __tag1 __attribute__((btf_decl_tag("tag1")))
#define __tag2 __attribute__((btf_decl_tag("tag2")))

struct t1 {
int a;
Expand All @@ -15,8 +15,8 @@ struct t1 g2;
// CHECK: distinct !DIGlobalVariable(name: "g1", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[#]], isLocal: false, isDefinition: true, annotations: ![[ANNOT:[0-9]+]])
// CHECK: distinct !DIGlobalVariable(name: "g2", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[#]], isLocal: false, isDefinition: true, annotations: ![[ANNOT]])
// CHECK: ![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]}
// CHECK: ![[TAG1]] = !{!"btf_tag", !"tag1"}
// CHECK: ![[TAG2]] = !{!"btf_tag", !"tag2"}
// CHECK: ![[TAG1]] = !{!"btf_decl_tag", !"tag1"}
// CHECK: ![[TAG2]] = !{!"btf_decl_tag", !"tag2"}

extern struct t1 g3 __tag1;
struct t1 g3 __tag2;
Expand Down
8 changes: 4 additions & 4 deletions clang/test/CodeGen/attr-btf_tag-disubprogram-callsite.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// REQUIRES: x86-registered-target
// RUN: %clang -target x86_64 -g -S -O2 -emit-llvm -o - %s | FileCheck %s

#define __tag1 __attribute__((btf_tag("tag1")))
#define __tag2 __attribute__((btf_tag("tag2")))
#define __tag1 __attribute__((btf_decl_tag("tag1")))
#define __tag2 __attribute__((btf_decl_tag("tag2")))

struct t1 {
int a;
Expand All @@ -15,5 +15,5 @@ int foo2(struct t1 *arg) {

// CHECK: ![[#]] = !DISubprogram(name: "foo", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[#]], flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: ![[#]], annotations: ![[ANNOT:[0-9]+]])
// CHECK: ![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]}
// CHECK: ![[TAG1]] = !{!"btf_tag", !"tag1"}
// CHECK: ![[TAG2]] = !{!"btf_tag", !"tag2"}
// CHECK: ![[TAG1]] = !{!"btf_decl_tag", !"tag1"}
// CHECK: ![[TAG2]] = !{!"btf_decl_tag", !"tag2"}
8 changes: 4 additions & 4 deletions clang/test/CodeGen/attr-btf_tag-disubprogram.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// REQUIRES: x86-registered-target
// RUN: %clang -target x86_64 -g -S -emit-llvm -o - %s | FileCheck %s

#define __tag1 __attribute__((btf_tag("tag1")))
#define __tag2 __attribute__((btf_tag("tag2")))
#define __tag1 __attribute__((btf_decl_tag("tag1")))
#define __tag2 __attribute__((btf_decl_tag("tag2")))

struct t1 {
int a;
Expand All @@ -14,8 +14,8 @@ int __tag1 __tag2 foo(struct t1 *arg) {

// CHECK: distinct !DISubprogram(name: "foo", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[#]], scopeLine: [[#]], flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], retainedNodes: ![[#]], annotations: ![[ANNOT:[0-9]+]])
// CHECK: ![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]}
// CHECK: ![[TAG1]] = !{!"btf_tag", !"tag1"}
// CHECK: ![[TAG2]] = !{!"btf_tag", !"tag2"}
// CHECK: ![[TAG1]] = !{!"btf_decl_tag", !"tag1"}
// CHECK: ![[TAG2]] = !{!"btf_decl_tag", !"tag2"}

int __tag1 __tag2 foo2(struct t1 *arg);
int foo2(struct t1 *arg) {
Expand Down
8 changes: 4 additions & 4 deletions clang/test/CodeGen/attr-btf_tag-field.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// REQUIRES: x86-registered-target
// RUN: %clang -target x86_64 -g -S -emit-llvm -o - %s | FileCheck %s

#define __tag1 __attribute__((btf_tag("tag1")))
#define __tag2 __attribute__((btf_tag("tag2")))
#define __tag1 __attribute__((btf_decl_tag("tag1")))
#define __tag2 __attribute__((btf_decl_tag("tag2")))

struct t1 {
int a __tag1 __tag2;
Expand All @@ -21,7 +21,7 @@ int foo2(struct t2 *arg) {
}
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "a", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[#]], size: 32, annotations: ![[ANNOT:[0-9]+]])
// CHECK: ![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]}
// CHECK: ![[TAG1]] = !{!"btf_tag", !"tag1"}
// CHECK: ![[TAG2]] = !{!"btf_tag", !"tag2"}
// CHECK: ![[TAG1]] = !{!"btf_decl_tag", !"tag1"}
// CHECK: ![[TAG2]] = !{!"btf_decl_tag", !"tag2"}

// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "b", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[#]], size: 1, flags: DIFlagBitField, extraData: i64 0, annotations: ![[ANNOT]])
8 changes: 4 additions & 4 deletions clang/test/CodeGen/attr-btf_tag-parameter.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// REQUIRES: x86-registered-target
// RUN: %clang -target x86_64 -g -S -emit-llvm -o - %s | FileCheck %s

#define __tag1 __attribute__((btf_tag("tag1")))
#define __tag2 __attribute__((btf_tag("tag2")))
#define __tag1 __attribute__((btf_decl_tag("tag1")))
#define __tag2 __attribute__((btf_decl_tag("tag2")))

struct t1 {
int a;
Expand All @@ -14,5 +14,5 @@ int foo(struct t1 __tag1 __tag2 *arg) {

// CHECK: !DILocalVariable(name: "arg", arg: 1, scope: ![[#]], file: ![[#]], line: [[#]], type: ![[#]], annotations: ![[ANNOT:[0-9]+]])
// CHECK: ![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]}
// CHECK: ![[TAG1]] = !{!"btf_tag", !"tag1"}
// CHECK: ![[TAG2]] = !{!"btf_tag", !"tag2"}
// CHECK: ![[TAG1]] = !{!"btf_decl_tag", !"tag1"}
// CHECK: ![[TAG2]] = !{!"btf_decl_tag", !"tag2"}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// CHECK-NEXT: Assumption (SubjectMatchRule_function, SubjectMatchRule_objc_method)
// CHECK-NEXT: Availability ((SubjectMatchRule_record, SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, SubjectMatchRule_function, SubjectMatchRule_namespace, SubjectMatchRule_objc_category, SubjectMatchRule_objc_implementation, SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, SubjectMatchRule_record, SubjectMatchRule_type_alias, SubjectMatchRule_variable))
// CHECK-NEXT: BPFPreserveAccessIndex (SubjectMatchRule_record)
// CHECK-NEXT: BTFTag (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record, SubjectMatchRule_field)
// CHECK-NEXT: BTFDeclTag (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record, SubjectMatchRule_field)
// CHECK-NEXT: BuiltinAlias (SubjectMatchRule_function)
// CHECK-NEXT: CFAuditedTransfer (SubjectMatchRule_function)
// CHECK-NEXT: CFConsumed (SubjectMatchRule_variable_is_parameter)
Expand Down
24 changes: 12 additions & 12 deletions clang/test/Sema/attr-btf_tag.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// RUN: %clang_cc1 -x c -triple x86_64-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s

#define __tag1 __attribute__((btf_tag("tag1")))
#define __tag2 __attribute__((btf_tag("tag2")))
#define __tag3 __attribute__((btf_tag("tag3")))
#define __tag1 __attribute__((btf_decl_tag("tag1")))
#define __tag2 __attribute__((btf_decl_tag("tag2")))
#define __tag3 __attribute__((btf_decl_tag("tag3")))

#define __tag_no_arg __attribute__((btf_tag()))
#define __tag_2_arg __attribute__((btf_tag("tag1", "tag2")))
#define __invalid __attribute__((btf_tag(1)))
#define __tag_no_arg __attribute__((btf_decl_tag()))
#define __tag_2_arg __attribute__((btf_decl_tag("tag1", "tag2")))
#define __invalid __attribute__((btf_decl_tag(1)))

struct __tag1 __tag2 t1;
struct t1 {
Expand All @@ -19,21 +19,21 @@ struct __tag2 __tag3 t2 {
};

int g1 __tag1;
int g2 __tag_no_arg; // expected-error {{'btf_tag' attribute takes one argument}}
int g3 __tag_2_arg; // expected-error {{'btf_tag' attribute takes one argument}}
int i1 __invalid; // expected-error {{'btf_tag' attribute requires a string}}
int g2 __tag_no_arg; // expected-error {{'btf_decl_tag' attribute takes one argument}}
int g3 __tag_2_arg; // expected-error {{'btf_decl_tag' attribute takes one argument}}
int i1 __invalid; // expected-error {{'btf_decl_tag' attribute requires a string}}

enum e1 {
E1
} __tag1; // expected-error {{'btf_tag' attribute only applies to variables, functions, structs, unions, classes, and non-static data members}}
} __tag1; // expected-error {{'btf_decl_tag' attribute only applies to variables, functions, structs, unions, classes, and non-static data members}}

enum e2 {
E2
} __tag_no_arg; // expected-error {{'btf_tag' attribute only applies to variables, functions, structs, unions, classes, and non-static data members}}
} __tag_no_arg; // expected-error {{'btf_decl_tag' attribute only applies to variables, functions, structs, unions, classes, and non-static data members}}

enum e3 {
E3
} __tag_2_arg; // expected-error {{'btf_tag' attribute only applies to variables, functions, structs, unions, classes, and non-static data members}}
} __tag_2_arg; // expected-error {{'btf_decl_tag' attribute only applies to variables, functions, structs, unions, classes, and non-static data members}}

int __tag1 __tag2 foo(struct t1 *arg, struct t2 *arg2);
int __tag2 __tag3 foo(struct t1 *arg, struct t2 *arg2);
Expand Down

0 comments on commit a162b67

Please sign in to comment.