[cfe-dev] Missing NoReturnAttr in the AST?

Gábor Márton via cfe-dev cfe-dev at lists.llvm.org
Fri Oct 4 03:11:55 PDT 2019


I've found that the GCC __attribute__((noreturn)) is part of the type, and
not parsed into a separate AST node like the C++11 [[noreturn]] or the GNU
__attribute__((analyzer_noreturn)).
To query the GCC __attribute__((noreturn)) we can use
FunctionType::getNoReturnAttr().

Why do we have these differences, with these attributes, why was the GCC
noreturn uplifted into the Type?

Thanks,
Gabor

On Fri, Oct 4, 2019 at 11:40 AM Gábor Márton <martongabesz at gmail.com> wrote:

> Hi,
>
> Having a source file (/tmp/attr.cpp)
>   void f() __attribute__((analyzer_noreturn));
>   void g() __attribute__((noreturn));
>   [[gnu::noreturn]] void h(void);
> Generates the following AST, when clang -cc1 -ast-dump /tmp/attr.cpp is
> used
>   |-FunctionDecl 0x18a5178 </tmp/attr.cpp:1:1, col:43> col:6 f 'void ()'
>   | `-AnalyzerNoReturnAttr 0x18a5218 <col:25>
>   |-FunctionDecl 0x18a5308 <line:2:1, col:34> col:6 g 'void ()
> __attribute__((noreturn))'
>   `-FunctionDecl 0x18a5440 <line:3:19, col:30> col:24 h 'void ()
> __attribute__((noreturn))'
>
> I.e. the NoReturnAttr node is missing. This is very confusing, when
> compared to the AnalyzerNoReturnAttr, which is there.
> The only difference in Attr.td is that noreturn has GCC spelling, while
> analyzer_noreturn has GNU spelling.
> What am I missing to have a NoReturnAttr node? Do I have to specify a
> special extra flag for CC1 to enable GCC attributes?
>
> Thanks,
> Gabor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20191004/abe7edd5/attachment.html>


More information about the cfe-dev mailing list