[cfe-dev] Custom tool doesn't parse successfully

Daniel Dilts via cfe-dev cfe-dev at lists.llvm.org
Tue Nov 10 12:02:43 PST 2015


I have tracked this a little further.  In ToolInvocation::run() I see that
CC1Args for clang-tidy has "-resource-dir
D:\WorkingDir\build\MyTool\trunk\llvmbuild\Debug\bin\..\lib\clang\3.8.0",
which directory exists.  CC1Args for my tool has "-resource-dir
D:\WorkingDir\build\MyTool\Debug\..\lib\clang\3.8.0", which does not exist.

I assume that this difference has something to do with the build system.
My CMake file to build my tool looks like this (fragment):

set(BUILD_SHARED_LIBS OFF)
add_subdirectory(${CMAKE_BINARY_DIR}/${CLANG_VERSION}/llvm
${CMAKE_BINARY_DIR}/${CLANG_VERSION}/llvmbuild EXCLUDE_FROM_ALL)
set(BUILD_SHARED_LIBS ${TMP_BUILD_SHARED_LIBS})

include_directories(${CMAKE_BINARY_DIR}/${CLANG_VERSION}/llvm/tools/clang/include
                    ${CMAKE_BINARY_DIR}/${CLANG_VERSION}/llvm/include

${CMAKE_BINARY_DIR}/${CLANG_VERSION}/llvmbuild/tools/clang/include
                    ${CMAKE_BINARY_DIR}/${CLANG_VERSION}/llvmbuild/include

${CMAKE_BINARY_DIR}/${CLANG_VERSION}/llvm/utils/unittest/googletest/include
                    )

add_library(Lib${ToolName} SHARED
            ${ToolSources}
            ${ToolSourceHeaders}
            ${ToolIncludeHeaders}
            )
add_executable(${ToolName}
               Source/Main.cpp
               )

target_link_libraries(Lib${ToolName}
                      clangTooling
                      )



On Tue, Nov 10, 2015 at 11:14 AM, Daniel Dilts <diltsman at gmail.com> wrote:

> The main function for my custom tool looks like this:
> CommonOptionsParser optionsParser(argc, argv, gMyToolCategory);
> RefactoringTool tool(optionsParser.getCompilations(),
> optionsParser.getSourcePathList());
> MyToolActionFactory factory{tool};
> auto a = tool.runAndSave(&factory);
>
> In ClangTool::run(), when I get to the line
> "assert(!CommandLine.empty());" I see that the CompileCommand and
> CommandLine variables in my custom tool match those from clang-tidy built
> from the same source.  The only difference is CommandLine[0], which names
> my tool rather than clang-tidy.
>
> What is confusing me is that the behavior of Invocation.run() differs
> between the two programs.  In clang-tidy it runs perfectly (no warnings, no
> errors).  In my tool I get a lot of errors of the form:
> C:\Program Files (x86)\Microsoft Visual Studio
> 14.0\VC\include\immintrin.h(764,28) :  error:
>       invalid token in macro parameter list
> #define _mm256_loadu2_m128(/* float const* */ hiaddr, \
>
> It seems that there must be something that I am missing when checking to
> see if my program is executing in a similar manner to clang-tidy.  What
> other variables, functions, etc. should I check to try to debug my problem?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151110/423eb6cc/attachment.html>


More information about the cfe-dev mailing list