[cfe-dev] Proposal: Add a tooling helper to simplify fully qualified names when possible

Daniel Cheng dcheng at google.com
Wed Nov 14 06:01:16 PST 2012

I recently wrote a small tool to do some automated refactoring. During
that work, I ended up writing some helper functions to "simplify"
fully qualified names, i.e. if you're already in namespace a::b, you
can refer to a::b::C as "C" rather than using the fully qualified
name. I'm wondering if there'd be interest in upstreaming this
functionality into Clang, as I believe this would be a generally
useful utility.

Currently, I have the following signature:

// Attempts to find the most concise way to refer to 'symbol' in the given
// context. 'symbol' should be a fully qualified name.
string SimplifySymbol(
    const clang::ASTContext& ast_context,
    const clang::DeclContext* context,
    const string& symbol);  // I think this should probably be a
NamedDecl* to prevent ambiguities

Do other people feel this sort of thing would be helpful, and if so,
where would it belong? It seems like it ought to be a member of
NamedDecl or DeclContext, but I'm new to Clang development, so I'm
interested in feedback and comments. Thanks!


More information about the cfe-dev mailing list