libclang's Indexer assertion on translation unit in large C++ codebase

Hi all,

I’m currently trying to run libclang’s indexer over parts of an existing (large) codebase (that has never seen clang before) in order to run some metrics. I’ve got it working for some scenarios but in the process of getting it working I’ve run into a failed assertion in clang’s AST code that I’m not sure how to track down. This problem only seems to exist when I try to run the indexer over parts of the real codebase; simple test CPP files work fine. As you’ll see by the message, I’m using the python bindings for libclang, and I have my own locally built libclang.dll built under VS2010.

Program: c:\Python27-32\python.exe
File: E:\llvm\tools\clang\include\clang/AST/DeclCXX.h
Line: 522
Expression: DefinitionData && “queried property of class with no definition”


libclang: crash detected during parsing: {
‘source_filename’ : ‘(null)’
‘command_line_args’ : [‘u:\Code\Services\MyService\MyService.cpp’],
‘unsaved_files’ : ,
‘options’ : 0,

I’m not entirely sure how to track this down and figure out if I’m doing something wrong. I’m just trying to run the indexer over a single translation unit (a single CPP file) but that CPP file includes all of our normal core headers, etc. which I think may be the problem. By this point I’m very familiar with how the Python bindings work/wrap the libclang code, and I have my IDE set up for working with libclang code, so if you need me to poke around or add some sort of diagnostic code I can.


Daniel Jennings
GW2 Gameplay Programmer

This looks like Clang crashing during parsing. Can you reproduce the problem with preprocessed input? If so, please open a bug report so we can track down the issue.

  - Doug

Are you actually doing anything besides loading the file when it
crashes? It's possible you've just run into a parser crash...
granted, those aren't especially common, but it's a possibility. You
might want to try and see if you get a crash by invoking clang itself
on the file in question; if you can, please see .


I’ll try preprocessing the file before running it through the parser to see if I can reproduce it.

Thanks for the help!

I preprocessed the file using VS2008 (which is what we compile our projects in naturally) and ran that through libclang’s indexer and got a different assertion:

Program: c:\Python27-32\python.exe

File: E:\llvm\include\llvm/Support/Casting.h
Line: 194
Expression: isa(Val) && “cast() argument of incompatible type!”

Unfortunately the preprocessed file is 740kb, which isn’t very usable when it comes to figuring out what’s going on in the file, so I might have to try a different project and trim it down as much as possible, which might be difficult, to figure it out.

Delta can reduce preprocessed files fairly easily:

  • Doug