C++ 使用libendAction分析调用约定的函数时出错

C++ 使用libendAction分析调用约定的函数时出错,c++,clang,llvm,libtooling,C++,Clang,Llvm,Libtooling,我正在使用Libtooling解析Windows SDK头,但在获取函数调用约定时存在问题,Libtooling总是为WINAPI返回\u cdell或\u stdcall调用约定,这是Win32 API的默认调用约定 这是一个输入示例 VOID __stdcall TestFunction (_In_ BOOLEAN is_valid); 这是myRecursiveASTVisitor的my函数Visitor函数 virtual bool VisitFunctionDecl(clan

我正在使用Libtooling解析Windows SDK头,但在获取函数调用约定时存在问题,Libtooling总是为
WINAPI
返回
\u cdell
\u stdcall
调用约定,这是Win32 API的默认调用约定

这是一个输入示例

VOID
__stdcall
TestFunction (_In_ BOOLEAN is_valid);
这是my
RecursiveASTVisitor的my函数Visitor函数

    virtual bool VisitFunctionDecl(clang::FunctionDecl *func)
    {
        // ...
        if (m_AstContext->getSourceManager().isInMainFile(func->getLocation()))
        {
            if (func->hasAttrs())
            {
                auto stdcall = func->hasAttr<StdCallAttr>(); // always return False
            }

            const clang::FunctionProtoType * prototype = func->getType()->getAs<FunctionProtoType>();
            if (prototype)
            {
                auto stdcall = prototype->hasAttr(attr::Kind::StdCall); // always return False

                errs() << clang::FunctionType::getNameForCallConv(prototype->getCallConv()).str() << " "; // always return cdecl
            }


            func->dumpColor(); // But there is __attribute__((stdcall)) in dumped output!

        }

        // ...
    }
出于兼容性原因,我也使用/不使用此选项运行它,但没有任何区别:-(

有什么想法吗

更新

我发现了这个问题,这是因为#Clang的default compile config。它是64位的(在64位工具链中),在64位模式下不能与
\uu stdcall
一起工作 如果我使用32位版本(或-m32选项),那么它将正常工作


知道为什么会在64位模式下发生吗?

From:
在ARM和x64处理器上,编译器接受并忽略stdcall;在ARM和x64架构上,按照惯例,参数尽可能在寄存器中传递,随后的参数在堆栈上传递。
@500 InternalServerError我知道,但如果编译器忽略将
\uuu stdcall
转换为64位,然后它应该变成
\uu fastcall
或类似的东西,而不是
\uu cdell
。从:
在ARM和x64处理器上,编译器接受并忽略stdcall;在ARM和x64体系结构上,按照惯例,参数尽可能在寄存器中传递,后续参数为pa在堆栈上进行调用。
@500 InternalServerError我知道,但是如果编译器忽略了64位的
\uuuu stdcall
,那么它应该变成
\uuu fastcall
或类似的东西,而不是
\uu cdell
^
FunctionDecl 0x218c95bb6f0 <C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\winnt.h:430:14, C:\ExampleInput.h:18:36> col:1 TestFunction 'void (BOOLEAN) __attribute__((stdcall))':'void (BOOLEAN)'
`-ParmVarDecl 0x218c95bb5c0 <col:20, col:28> col:28 is_valid 'BOOLEAN':'unsigned char'
-fms-compatibility 
-fms-extensions 
-fms-compatibility-version=19