[PATCH] Use -std=c++11 when no arguments are provided.

Ariel Bernal ariel.j.bernal at intel.com
Fri Aug 9 10:43:14 PDT 2013



================
Comment at: cpp11-migrate/tool/Cpp11Migrate.cpp:25
@@ -24,3 +24,3 @@
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
----------------
Guillaume Papin wrote:
> I believe this should disappear.
yes

================
Comment at: cpp11-migrate/tool/Cpp11Migrate.cpp:39-42
@@ -38,2 +38,6 @@
 static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
+static cl::opt<std::string> BuildPath(
+    "p", cl::desc("Build Path"), cl::Optional);
+static cl::list<std::string> SourcePaths(
+    cl::Positional, cl::desc("<source0> [... <sourceN>]"), cl::OneOrMore);
 static cl::extrahelp MoreHelp(
----------------
Guillaume Papin wrote:
> Theses options need more documentation. It used to be documented by the CommonOptionParser extra-help.
Those options are still documented by the HelpMessage, I don't see any extra-help in CommonOptionParser.

================
Comment at: cpp11-migrate/tool/Cpp11Migrate.cpp:242-243
@@ +241,4 @@
+      if (!Compilations) {
+        std::vector<std::string> CommandLine;
+        CommandLine.push_back("-std=c++11");
+        Compilations.reset(new FixedCompilationDatabase(".", CommandLine));
----------------
Guillaume Papin wrote:
> I'm not sure a vector is necessary here, an array of strings should be sufficient.
yes sure.

================
Comment at: cpp11-migrate/tool/Cpp11Migrate.cpp:247-249
@@ +246,5 @@
+    }
+    if (!Compilations) {
+      llvm::report_fatal_error(ErrorMessage);
+    }
+  }
----------------
Edwin Vane wrote:
> Single-line if statement has no braces.
no problem

================
Comment at: cpp11-migrate/tool/Cpp11Migrate.cpp:241-245
@@ +240,7 @@
+      // a new FixedCompilationDatabase with c++11 support.
+      if (!Compilations) {
+        std::vector<std::string> CommandLine;
+        CommandLine.push_back("-std=c++11");
+        Compilations.reset(new FixedCompilationDatabase(".", CommandLine));
+      }
+    }
----------------
Guillaume Papin wrote:
> I don't think it's correct to handle the option that way.
> What happens if `--` is not specified on the command line, neither is `-p` but a sub-directory contains a compilation database? Unless I'm mistaken this compilation database will be loaded.
> 
> If think you want something like:
> 
>   OwningPtr<CompilationDatabase> Compilations(
>       FixedCompilationDatabase::loadFromCommandLine(argc, argv));
>   cl::ParseCommandLineOptions(argc, argv);
>   if (BuildPath.getNumOccurrences() == 0)
>     // <add c++11 FixedCompilationDatabase here...>
>   else
>     // <handle BuildPath...>
If -- is not specified then it means that it is not a FixedCompilationDatabase and then Compilations will be empty. if also -p is not specified then BuildPath will be empty. if a compilation database can not be detected from source (SourcePaths[0]) then we add c++11. We only add c++11 if the user doesn't specify a compilation database. Do you think there is another case?


http://llvm-reviews.chandlerc.com/D1337



More information about the cfe-commits mailing list