[cfe-dev] D52529: Propose to delete -print-decl-contexts

Fāng-ruì Sòng via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 1 15:50:23 PDT 2018


clang++ -fsyntax-only -Xclang -print-decl-contexts a.cc
clang++ -fsyntax-only -Xclang -ast-dump a.cc

-print-decl-contexts (DeclContextPrinter) is a cc1 option that dumps
AST nodes in the following manner:

// lib/Frontend/ASTConsumers.cpp
    case Decl::Using:
      Out << "<using> " << *cast<UsingDecl>(I) << "\n";
      break;
    case Decl::UsingShadow:
      Out << "<using shadow> " << *cast<UsingShadowDecl>(I) << "\n";
      break;

It lacks handling of many AST nodes which will lead to llvm_unreachable() crash.

    default:
      Out << "DeclKind: " << DK << '"' << I << "\"\n";
      llvm_unreachable("decl unhandled");

I tried handling other cases with clang/AST/DeclNodes.inc but then
realized that deleting it might be better as it is a rarely used
feature (not actively maintained and easy to crash). Its functionality
is mostly covered by -ast-dump (which is a bit verbose)
-ast-dump-lookups -ast-list

I have sent out D52529 for deleting -print-decl-contexts and will commit
it if nobody opposes.


-- 
宋方睿


More information about the cfe-dev mailing list