[PATCH] Use -std=c++11 when no arguments are provided.
Guillaume Papin
guillaume.papin at epitech.eu
Fri Aug 9 03:21:04 PDT 2013
================
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));
----------------
I'm not sure a vector is necessary here, an array of strings should be sufficient.
================
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"
----------------
I believe this should disappear.
================
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(
----------------
Theses options need more documentation. It used to be documented by the CommonOptionParser extra-help.
================
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));
+ }
+ }
----------------
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...>
http://llvm-reviews.chandlerc.com/D1337
More information about the cfe-commits
mailing list