r215773 - ArrayRef'ize
Sean Silva
chisophugis at gmail.com
Fri Aug 15 14:38:36 PDT 2014
Author: silvas
Date: Fri Aug 15 16:38:36 2014
New Revision: 215773
URL: http://llvm.org/viewvc/llvm-project?rev=215773&view=rev
Log:
ArrayRef'ize
I've shied away from ArrayRef'izing CompilerInvocation::CreateFromArgs
in this commit because that is a less localized change.
Modified:
cfe/trunk/tools/driver/cc1_main.cpp
cfe/trunk/tools/driver/cc1as_main.cpp
cfe/trunk/tools/driver/driver.cpp
Modified: cfe/trunk/tools/driver/cc1_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1_main.cpp?rev=215773&r1=215772&r2=215773&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1_main.cpp Fri Aug 15 16:38:36 2014
@@ -63,8 +63,7 @@ void initializePollyPasses(llvm::PassReg
}
#endif
-int cc1_main(const char **ArgBegin, const char **ArgEnd,
- const char *Argv0, void *MainAddr) {
+int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
std::unique_ptr<CompilerInstance> Clang(new CompilerInstance());
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
@@ -84,9 +83,8 @@ int cc1_main(const char **ArgBegin, cons
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
TextDiagnosticBuffer *DiagsBuffer = new TextDiagnosticBuffer;
DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagsBuffer);
- bool Success;
- Success = CompilerInvocation::CreateFromArgs(Clang->getInvocation(),
- ArgBegin, ArgEnd, Diags);
+ bool Success = CompilerInvocation::CreateFromArgs(
+ Clang->getInvocation(), Argv.begin(), Argv.end(), Diags);
// Infer the builtin include path if unspecified.
if (Clang->getHeaderSearchOpts().UseBuiltinIncludes &&
Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=215773&r1=215772&r2=215773&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Fri Aug 15 16:38:36 2014
@@ -141,15 +141,15 @@ public:
DwarfVersion = 3;
}
- static bool CreateFromArgs(AssemblerInvocation &Res, const char **ArgBegin,
- const char **ArgEnd, DiagnosticsEngine &Diags);
+ static bool CreateFromArgs(AssemblerInvocation &Res,
+ ArrayRef<const char *> Argv,
+ DiagnosticsEngine &Diags);
};
}
bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
- const char **ArgBegin,
- const char **ArgEnd,
+ ArrayRef<const char *> Argv,
DiagnosticsEngine &Diags) {
bool Success = true;
@@ -159,7 +159,7 @@ bool AssemblerInvocation::CreateFromArgs
const unsigned IncludedFlagsBitmask = options::CC1AsOption;
unsigned MissingArgIndex, MissingArgCount;
std::unique_ptr<InputArgList> Args(
- OptTbl->ParseArgs(ArgBegin, ArgEnd, MissingArgIndex, MissingArgCount,
+ OptTbl->ParseArgs(Argv.begin(), Argv.end(), MissingArgIndex, MissingArgCount,
IncludedFlagsBitmask));
// Check for missing argument error.
@@ -420,11 +420,10 @@ static void LLVMErrorHandler(void *UserD
exit(1);
}
-int cc1as_main(const char **ArgBegin, const char **ArgEnd,
- const char *Argv0, void *MainAddr) {
+int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
// Print a stack trace if we signal out.
sys::PrintStackTraceOnErrorSignal();
- PrettyStackTraceProgram X(ArgEnd - ArgBegin, ArgBegin);
+ PrettyStackTraceProgram X(Argv.size(), Argv.data());
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
// Initialize targets and assembly printers/parsers.
@@ -447,7 +446,7 @@ int cc1as_main(const char **ArgBegin, co
// Parse the arguments.
AssemblerInvocation Asm;
- if (!AssemblerInvocation::CreateFromArgs(Asm, ArgBegin, ArgEnd, Diags))
+ if (!AssemblerInvocation::CreateFromArgs(Asm, Argv, Diags))
return 1;
if (Asm.ShowHelp) {
Modified: cfe/trunk/tools/driver/driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=215773&r1=215772&r2=215773&view=diff
==============================================================================
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Fri Aug 15 16:38:36 2014
@@ -187,10 +187,10 @@ static void ApplyQAOverride(SmallVectorI
}
}
-extern int cc1_main(const char **ArgBegin, const char **ArgEnd,
- const char *Argv0, void *MainAddr);
-extern int cc1as_main(const char **ArgBegin, const char **ArgEnd,
- const char *Argv0, void *MainAddr);
+extern int cc1_main(ArrayRef<const char *> Argv, const char *Argv0,
+ void *MainAddr);
+extern int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0,
+ void *MainAddr);
static void ParseProgName(SmallVectorImpl<const char *> &ArgVector,
std::set<std::string> &SavedStrings,
@@ -357,13 +357,12 @@ static void SetInstallDir(SmallVectorImp
TheDriver.setInstalledDir(InstalledPath);
}
-static int HandleCC1Tool(SmallVectorImpl<const char *> &argv, StringRef Tool) {
+static int HandleCC1Tool(ArrayRef<const char *> argv, StringRef Tool) {
+ void *GetExecutablePathVP = (void *)(intptr_t) GetExecutablePath;
if (Tool == "")
- return cc1_main(argv.data()+2, argv.data()+argv.size(), argv[0],
- (void*) (intptr_t) GetExecutablePath);
+ return cc1_main(argv.slice(2), argv[0], GetExecutablePathVP);
if (Tool == "as")
- return cc1as_main(argv.data()+2, argv.data()+argv.size(), argv[0],
- (void*) (intptr_t) GetExecutablePath);
+ return cc1as_main(argv.slice(2), argv[0], GetExecutablePathVP);
// Reject unknown tools.
llvm::errs() << "error: unknown integrated tool '" << Tool << "'\n";
More information about the cfe-commits
mailing list