[cfe-commits] r90128 - /cfe/trunk/tools/clang-cc/clang-cc.cpp
Daniel Dunbar
daniel at zuster.org
Mon Nov 30 00:42:11 PST 2009
Author: ddunbar
Date: Mon Nov 30 02:42:10 2009
New Revision: 90128
URL: http://llvm.org/viewvc/llvm-project?rev=90128&view=rev
Log:
clang-cc: Add code (currently disabled) for parsing arguments using clang -cc1 functionality instead of LLVM's CommandLine.
- It works and passes test suite, but I want to polish and test a wee bit more before making the switch.
Modified:
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=90128&r1=90127&r2=90128&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Mon Nov 30 02:42:10 2009
@@ -31,6 +31,7 @@
#include "clang/Frontend/FrontendActions.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/FrontendPluginRegistry.h"
+#include "clang/Frontend/TextDiagnosticBuffer.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Frontend/VerifyDiagnosticsClient.h"
#include "llvm/LLVMContext.h"
@@ -273,6 +274,7 @@
llvm::InitializeAllTargets();
llvm::InitializeAllAsmPrinters();
+#if 1
llvm::cl::ParseCommandLineOptions(argc, argv,
"LLVM 'Clang' Compiler: http://clang.llvm.org\n");
@@ -296,6 +298,33 @@
if (!ConstructCompilerInvocation(Clang.getInvocation(),
Clang.getDiagnostics(), argv[0]))
return 1;
+#else
+ // Buffer diagnostics from argument parsing.
+ TextDiagnosticBuffer DiagsBuffer;
+ Diagnostic Diags(&DiagsBuffer);
+
+ CompilerInvocation::CreateFromArgs(Clang.getInvocation(),
+ (const char**) argv + 1,
+ (const char**) argv + argc, argv[0],
+ (void*)(intptr_t) GetBuiltinIncludePath,
+ Diags);
+
+ // Create the actual diagnostics engine.
+ Clang.createDiagnostics(argc, argv);
+ if (!Clang.hasDiagnostics())
+ return 1;
+
+ // Set an error handler, so that any LLVM backend diagnostics go through our
+ // error handler.
+ llvm::llvm_install_error_handler(LLVMErrorHandler,
+ static_cast<void*>(&Clang.getDiagnostics()));
+
+ DiagsBuffer.FlushDiagnostics(Clang.getDiagnostics());
+
+ // If there were any errors in processing arguments, exit now.
+ if (Clang.getDiagnostics().getNumErrors())
+ return 1;
+#endif
// Create the target instance.
Clang.setTarget(TargetInfo::CreateTargetInfo(Clang.getDiagnostics(),
More information about the cfe-commits
mailing list