GrammaTech / clang-mutate

Manipulate C-family ASTs with Clang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assertion failed in any test cases if clang/llvm are compiled from source as a debug build

lioujheyu opened this issue · comments

commented

Error message

clang-mutate: /home/jliou4/llvm-4/tools/clang/lib/Basic/SourceManager.cpp:975:
Assertion Loc.isMacroID() && "Not a macro expansion loc!" failed.

Call stack

Only a few of them on the top are listed

libc.so.6!__GI___assert_fail(const char * assertion, const char * file, unsigned int line, const char * function) (/build/glibc-Cl5G7W/glibc-2.23/assert/assert.c:101)
clang::SourceManager::getImmediateExpansionRange(const clang::SourceManager * const this, clang::SourceLocation Loc) (/share/home/jliou4/llvm-4/tools/clang/lib/Basic/SourceManager.cpp:975)
Utils::contains_macro<clang::Stmt>(clang::Stmt * clang_obj, clang::SourceManager & sm) (/share/home/jliou4/genetic-programming/clang-mutate/Utils.h:129)
clang_mutate::Requirements::gatherMacro(clang_mutate::Requirements * this, clang::Stmt * stmt) 

Steps of reproduce

Environment

  • Ubuntu 16.04
  • gcc 5.3
  • Clang/llvm 4.0 or 7.0 from the Head of master branch had been tested. They must be compiled from source. Installing the preinstall binary from Ubuntu package repository(Which is clang/llvm 4.0) or building Clang/LLVM as Release build won't cause this assertion failed. Probably because of the llvm-sepcific variable LLVM_ENABLE_ASSERTIONS:BOOL

Steps

  1. Get Clang/llvm from source and build them with the following command
cmake -DCMAKE_BUILD_TYPE:STRING=Debug ../
make -j
  1. Compile and test clang-mutate with
clang-mutate etc/array-initializer.c -ids --

@lioujheyu Thanks for the report. Unfortunately, we do not currently support non-release builds of clang; however, if you can suggest a patch to remedy this issue we would be happy to apply it. Regrettably, this may be tedious and difficult; much of the code related to macro handling depends on the release behavior of getImmediateExpansionRange and associated macro-related routines. I suspect much of this code would need to be wrapped in isMacroID() checks to avoid triggering this assertion.