[cfe-dev] Extracting the include tree from a source file
broeksema at kde.org
Mon Nov 15 14:19:42 CST 2010
Nico Weber wrote:
> On Mon, Nov 15, 2010 at 8:33 PM, Bertjan Broeksema
> <broeksema at kde.org> wrote:
>> Nico Weber wrote:
>> Thanks for the quick reply!
>>> Call InitializePreprocessor to add defines. To fix the crash, add
>>> calls to BeginSourceFile()/EndSourceFile() (see
>>> https://github.com/nico/clangtut/blob/master/tut03_pp.cpp ).
>> Yes, I'm a step closer now, it indeed doesn't crash anymore when an error
>> occurs. However, I still have the problem that system includes are not
>> found. In this particular case stddef.h. I am somewhat assuming that it
>> shouldn't be needed to add paths like:
>> /usr/include/linux (for stddef.h)
>> clang++ (the command line tool), seems to have these paths available as
>> it is able to preprocess the same file I'm testing with, without
>> complaining about not finding stddef.h
> All these are added in InitHeaderSearch::AddDefaultCIncludePaths()
> and friends in lib/Frontend/InitHeaderSearch.cpp. Maybe step through
> that code for your binary and for clang and check which branches are
> taken in both cases.
Found two problems, the first was obvious: I didn't set any language enabled
in LanguageOptions -> langOption.CPlusPlus = true; Doh!
The second, I've a recent Gentoo system and the following path is missing in
// Gentoo amd64 gcc 4.4.4
"x86_64-pc-linux-gnu", "32", "", triple);
More information about the cfe-dev