Skip to content

Commit

Permalink
Add an option to specify the output labelmap file name.
Browse files Browse the repository at this point in the history
Change-Id: Idfeb2593adffe818079529093dbeae142fe863b6
  • Loading branch information
yaoyuannnn committed Jun 20, 2019
1 parent e150e62 commit 3192381
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ast-pass/GetLabeledStmts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ using namespace llvm;
// Declaring here because CommonOptionsParser requires this one in LLVM 3.5.
// http://llvm.org/docs/CommandLine.html#grouping-options-into-categories
cl::OptionCategory GetLabelStmtsCat("GetLabelStmts options");
static cl::opt<std::string> OutputFileName("output",
cl::desc("Specify output filename"),
cl::value_desc("filename"),
cl::init("labelmap"));

// A class containing all the labels and caller information for a function.
class FunctionInfo {
Expand Down Expand Up @@ -93,7 +97,7 @@ class FunctionInfo {

// Maps pairs of (func_name, label_name) to line numbers.
static std::map<std::string, FunctionInfo> labelMap;
static const std::string outputFileName = "labelmap";
static std::string outputFileName;

class LabeledStmtVisitor : public RecursiveASTVisitor<LabeledStmtVisitor> {
private:
Expand Down Expand Up @@ -307,6 +311,7 @@ static void cleanup() {
int main(int argc, const char** argv) {
CommonOptionsParser op(argc, argv, GetLabelStmtsCat);
ClangTool Tool(op.getCompilations(), op.getSourcePathList());
outputFileName = OutputFileName.getValue();
cleanup();

std::unique_ptr<FrontendActionFactory>
Expand Down

0 comments on commit 3192381

Please sign in to comment.