[cfe-users] parsing a windows source

folkert via cfe-users cfe-users at lists.llvm.org
Thu Jul 21 13:58:38 PDT 2016


Hi,

I would like to parse a windows source. Using clang/llvm and
preferably under Linux.

I'm using:

        std::vector<std::string> arguments;

        arguments.push_back("-fms-compatibility");
        arguments.push_back("-fms-extensions");
        arguments.push_back("-Wno-error=invalid-token-paste");
        arguments.push_back("-fdelayed-template-parsing");
        arguments.push_back("-DWIN32");
        arguments.push_back("-D_WIN32");
        arguments.push_back("-D_WINDOWS");
        arguments.push_back("-D_DEBUG");
        arguments.push_back("-D_CRTDBG_MAP_ALLOC");
        arguments.push_back("-D_UNICODE");
        arguments.push_back("-DUNICODE");
        arguments.push_back("-D_AFXDLL");
        arguments.push_back("-D_DLL");
        arguments.push_back("-fmsc-version=1600");
        arguments.push_back("-fcxx-exceptions");
        arguments.push_back("-fexceptions");
        arguments.push_back("-D_M_AMD64=1");
        arguments.push_back("-D_M_X64=1");
        arguments.push_back("-I.");

        arguments.push_back("-isystem=/C/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include");
        arguments.push_back("-I/C/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include");
        arguments.push_back("-isystem=/C/Program Files (x86)/Microsoft Visual Studio 10.0/VC/crt/src");
        arguments.push_back("-I/C/Program Files (x86)/Microsoft Visual Studio 10.0/VC/crt/src");
        arguments.push_back("-I/C/Program Files (x86)/Microsoft Visual Studio 10.0/VC/atlmfc/include");
        arguments.push_back("-isystem=/C/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Include");
        arguments.push_back("-I/C/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Include");

	// buf contains source to parse
        llvm::Twine code(buf);

        FindNamedClassAction *fnca = new FindNamedClassAction(root);

        clang::tooling::runToolOnCodeWithArgs(fnca, code, arguments, llvm::Twine(fname));

This gives:

In file included from /C/Source.cpp:12:
In file included from /C/StdAfx.h:2:
In file included from /C/01StdAfx.h:47:
In file included from /C/Program Files (x86)/Microsoft Visual Studio 10.0/VC/atlmfc/include/afx.h:54:
In file included from /C/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include/new.h:22:
In file included from /C/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include/new:6:
In file included from /C/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include/exception:7:
In file included from /C/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include/xstddef:6:
In file included from /C/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include/yvals.h:6:
/C/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include/crtdefs.h:402:29: error: typedef redefinition with
different types ('unsigned int' vs 'unsigned long')
typedef _W64 unsigned int   size_t;
                            ^
/C/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include/crtdefs.h:543:2: warning: __declspec attribute
'dllimport' is not supported [-Wignored-attributes]
 _CRTIMP void __cdecl _invalid_parameter(_In_opt_z_ const wchar_t *,
_In_opt_z_ const wchar_t *, _In_opt_z_ const wchar_t *, unsigned int,
uintptr_t);
 ^
/C/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include/crtdefs.h:18:28: note: expanded from macro '_CRTIMP'
#define _CRTIMP __declspec(dllimport)
                           ^
[skipped a bit]

/C/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Include/winnt.h:455:9: error: unknown type name
'PNZWCH'
typedef PNZWCH PNZTCH;
        ^


How can I fix this? Is it a missing compile-flag?


Folkert van Heusden

-- 
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com



More information about the cfe-users mailing list