//
//===----------------------------------------------------------------------===//
//
-// This file defines a '-dot-cfg' analysis pass, which emits the
-// cfg.<fnname>.dot file for each function in the program, with a graph of the
-// CFG for that function.
+// This file defines a `-dot-cfg` analysis pass, which emits the
+// `<prefix>.<fnname>.dot` file for each function in the program, with a graph
+// of the CFG for that function. The default value for `<prefix>` is `cfg` but
+// can be customized as needed.
//
// The other main feature of this file is that it implements the
// Function::viewCFG method, which is useful for debugging passes which operate
cl::desc("The name of a function (or its substring)"
" whose CFG is viewed/printed."));
+static cl::opt<std::string> CFGDotFilenamePrefix(
+ "cfg-dot-filename-prefix", cl::Hidden,
+ cl::desc("The prefix used for the CFG dot file names."));
+
namespace {
struct CFGViewerLegacyPass : public FunctionPass {
static char ID; // Pass identifcation, replacement for typeid
static void writeCFGToDotFile(Function &F, bool CFGOnly = false) {
if (!CFGFuncName.empty() && !F.getName().contains(CFGFuncName))
return;
- std::string Filename = ("cfg." + F.getName() + ".dot").str();
+ std::string Filename =
+ (CFGDotFilenamePrefix + "." + F.getName() + ".dot").str();
errs() << "Writing '" << Filename << "'...";
std::error_code EC;