Changeset View
Standalone View
clang/include/clang/AST/Attr.h
Show First 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
public: | public: | ||||
// Implement isa/cast/dyncast/etc. | // Implement isa/cast/dyncast/etc. | ||||
static bool classof(const Attr *A) { | static bool classof(const Attr *A) { | ||||
return A->getKind() >= attr::FirstInheritableParamAttr && | return A->getKind() >= attr::FirstInheritableParamAttr && | ||||
A->getKind() <= attr::LastInheritableParamAttr; | A->getKind() <= attr::LastInheritableParamAttr; | ||||
} | } | ||||
}; | }; | ||||
class HLSLAnnotationAttr : public InheritableAttr { | |||||
aaron.ballman: Is this intended to be used only for parameters (that's how I read the summary for the patch)? | |||||
Sadly these attributes are valid in places that aren’t parameters. For example, they can be applied on the members of a struct. When specifying an HLSL entry we require semantics for all scalar variables in the signature so that the we can match up the parameters from driver and user-provided values, but the parameters can be scalars or user defined structs. For example: struct Pupper { int Legs : SomeAnnotation; int Ears : SomeOtherAnnotation; } ... void main(Pupper P) {...} // valid as an entry We also allow these annotations (and require them) on return types for entry functions: int main(...) : SomeAnnotation {...} Where this all gets really special is that entry functions as passed to drivers have a void(void) signature, but entry functions with the source-specified signature can be called. I'm trying to handle those cases in D131203 by generating the user-written function as is with C++ mangling, and generating a non-mangled void(void) wrapper that calls the underlying function after populating the annotation values. It is an incomplete implementation, but a starting point. beanz: Sadly these attributes are valid in places that aren’t parameters. For example, they can be… | |||||
Not Done ReplyInline ActionsOh, thank you for the explanation!
Well that should be fun if you have code that cares about the address of the function, depending on which address you happen to get. But you don't allow pointers IIRC, so maybe you're "safe"? aaron.ballman: Oh, thank you for the explanation!
> Where this all gets really special is that entry… | |||||
I _think_ taking the address of the function should consistently give the address of the mangled function since the AST will resolve using C++ mangling rules. I hope that would be the expected behavior even if we exposed pointers in the future since the void(void) entry should only ever be the hardware start point. I'm sure I'm wrong about this and will regret this speculation in the future... beanz: I _think_ taking the address of the function should consistently give the address of the… | |||||
Not Done ReplyInline ActionsKeep in mind that we have things like __builtin_frame_address() which exposes "this function" and "calling function" to the caller in ways that may be surprising. That said, if someone is using those kinds of tricks to inspect the identity of a function, I'm not certain how sympathetic I am to their plight in this case. aaron.ballman: Keep in mind that we have things like `__builtin_frame_address()` which exposes "this function"… | |||||
protected: | |||||
HLSLAnnotationAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, | |||||
attr::Kind AK, bool IsLateParsed, | |||||
bool InheritEvenIfAlreadyPresent) | |||||
Not Done ReplyInline ActionsFormatting looks off here, you should run the patch through clang-format. aaron.ballman: Formatting looks off here, you should run the patch through clang-format. | |||||
: InheritableAttr(Context, CommonInfo, AK, IsLateParsed, | |||||
InheritEvenIfAlreadyPresent) {} | |||||
public: | |||||
// Implement isa/cast/dyncast/etc. | |||||
static bool classof(const Attr *A) { | |||||
return A->getKind() >= attr::FirstHLSLAnnotationAttr && | |||||
A->getKind() <= attr::LastHLSLAnnotationAttr; | |||||
} | |||||
}; | |||||
/// A parameter attribute which changes the argument-passing ABI rule | /// A parameter attribute which changes the argument-passing ABI rule | ||||
/// for the parameter. | /// for the parameter. | ||||
class ParameterABIAttr : public InheritableParamAttr { | class ParameterABIAttr : public InheritableParamAttr { | ||||
protected: | protected: | ||||
ParameterABIAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, | ParameterABIAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo, | ||||
attr::Kind AK, bool IsLateParsed, | attr::Kind AK, bool IsLateParsed, | ||||
bool InheritEvenIfAlreadyPresent) | bool InheritEvenIfAlreadyPresent) | ||||
: InheritableParamAttr(Context, CommonInfo, AK, IsLateParsed, | : InheritableParamAttr(Context, CommonInfo, AK, IsLateParsed, | ||||
▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines |
Is this intended to be used only for parameters (that's how I read the summary for the patch)? If so, why is this not inheriting from InheritableParamAttr?