[cfe-dev] Can a Clang plugin see names of source files?

Arthur O'Dwyer arthur at push.am
Fri Apr 6 12:16:46 PDT 2012

On Fri, Apr 6, 2012 at 8:02 AM, Nico Weber <thakis at chromium.org> wrote:
> Hi,
> chromium's style plugin does this, see
> ChromeClassTester::InBannedDirectory in
> http://src.chromium.org/viewvc/chrome/trunk/src/tools/clang/plugins/ChromeClassTester.cpp?view=markup

Ah, I totally missed that the "factory" method
PluginASTAction::CreateASTConsumer() takes an argument of type
CompilerInstance& and can pass it along into the ASTConsumer at
construction time. That makes everything a *lot* easier! ;)

And CreateASTConsumer() *also* takes a string argument that holds the
name of the top-level input file, which was exactly the other piece of
information I needed.

[I think I'm well on my way now. I still don't understand the
difference between ASTConsumer::HandleTopLevelDecl() and
ASTConsumer::HandleInterestingDecl(), but since the latter never
triggers on my source code at all, I'm guessing that I can ignore it.]


More information about the cfe-dev mailing list