相关疑难解决方法(0)

如何通过clang工具访问已解析的C ++ 11属性

此答案表明,lang修订版165082应该保留AST中所有已解析的属性。

我首先认为这是指将保留所有属性,但是事实并非如此:

$ clang++ -v
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix

$ cat att.cpp 
void f [[noreturn, foo]] () {}

$ clang++ att.cpp -Xclang -ast-dump -fsyntax-only -std=c++11
att.cpp:1:20: warning: unknown attribute 'foo' ignored [-Wattributes]
void f [[noreturn, foo]] () {}
                   ^
att.cpp:1:30: warning: function declared 'noreturn' should not return [-Winvalid-noreturn]
void f [[noreturn, foo]] () {}
                             ^
TranslationUnitDecl 0x102021cd0 <<invalid sloc>>
|-TypedefDecl 0x102022210 <<invalid sloc>> __int128_t '__int128' …
Run Code Online (Sandbox Code Playgroud)

attributes clang c++11

5
推荐指数
1
解决办法
1388
查看次数

标签 统计

attributes ×1

c++11 ×1

clang ×1