[cfe-dev] Trouble understand DeclContext

David Fontaine via cfe-dev cfe-dev at lists.llvm.org
Wed Feb 8 15:53:28 PST 2017


On 02/08/2017 12:37 AM, Stephan Bergmann via cfe-dev wrote:
> On 02/08/2017 12:53 AM, David Fontaine via cfe-dev wrote:
>> Purely from a semantic perspective, hanging ParmVarDecls off of a
>> VarDecl or FieldDecl seems the correct solution for function pointer
>> parameters.  Going through the type information and the redeclaration
>> chain seems highly unfortunate even if it might be less code motion.
>
> And if such a ParmVarDecl is of function pointer type, you'd 
> recursively hang any ParmVarDecls off that ParmVarDecl?
Correct.  That structure would directly mirror the input source.

> But what about a FunctionDecl whose return type is a function pointer 
> type?
I hadn't considered that case.

int (*ugh(int x))(int y);

For my specific use case, I'm fine with x being in the AST and y not 
(exactly as it is today), because the attributes I'm interested in 
(-Wthread-safety) apply to declarations, not types.  (Are there 
attributes that apply to types?  I don't actually know this.)

If we wanted to "fix" this case as well, then the way I see it, clang 
would need to understand that individual occurrences of _types_ (at 
least, function types) can themselves contain nested declarations.  
Which sounds like a far more drastic change than making VarDecl and 
FieldDecl inherit DeclContext.

> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------



More information about the cfe-dev mailing list