]> granicus.if.org Git - clang/blobdiff - lib/Tooling/CommonOptionsParser.cpp
Make ArgumentsAdjuster an std::function.
[clang] / lib / Tooling / CommonOptionsParser.cpp
index f16a6be8d0c97aaaf951158122e074bd1f7579f6..91c74a4c3359741a51602d9c32224482ebdcd190 100644 (file)
@@ -60,8 +60,8 @@ public:
       std::unique_ptr<CompilationDatabase> Compilations)
       : Compilations(std::move(Compilations)) {}
 
-  void appendArgumentsAdjuster(std::unique_ptr<ArgumentsAdjuster> Adjuster) {
-    Adjusters.push_back(std::move(Adjuster));
+  void appendArgumentsAdjuster(ArgumentsAdjuster Adjuster) {
+    Adjusters.push_back(Adjuster);
   }
 
   std::vector<CompileCommand>
@@ -79,13 +79,13 @@ public:
 
 private:
   std::unique_ptr<CompilationDatabase> Compilations;
-  std::vector<std::unique_ptr<ArgumentsAdjuster>> Adjusters;
+  std::vector<ArgumentsAdjuster> Adjusters;
 
   std::vector<CompileCommand>
   adjustCommands(std::vector<CompileCommand> Commands) const {
     for (CompileCommand &Command : Commands)
       for (const auto &Adjuster : Adjusters)
-        Command.CommandLine = Adjuster->Adjust(Command.CommandLine);
+        Command.CommandLine = Adjuster(Command.CommandLine);
     return Commands;
   }
 };
@@ -142,10 +142,8 @@ CommonOptionsParser::CommonOptionsParser(int &argc, const char **argv,
       llvm::make_unique<ArgumentsAdjustingCompilations>(
           std::move(Compilations));
   AdjustingCompilations->appendArgumentsAdjuster(
-      llvm::make_unique<InsertArgumentAdjuster>(ArgsBefore,
-                                                InsertArgumentAdjuster::BEGIN));
+      getInsertArgumentAdjuster(ArgsBefore, ArgumentInsertPosition::BEGIN));
   AdjustingCompilations->appendArgumentsAdjuster(
-      llvm::make_unique<InsertArgumentAdjuster>(ArgsAfter,
-                                                InsertArgumentAdjuster::END));
+      getInsertArgumentAdjuster(ArgsAfter, ArgumentInsertPosition::END));
   Compilations = std::move(AdjustingCompilations);
 }