[cfe-commits] r90413 - in /cfe/trunk: include/clang/Basic/DiagnosticFrontendKinds.td include/clang/Driver/CC1Options.td include/clang/Frontend/FrontendOptions.h lib/Frontend/CompilerInvocation.cpp tools/clang-cc/clang-cc.cpp
Daniel Dunbar
daniel at zuster.org
Wed Dec 2 21:11:05 PST 2009
Author: ddunbar
Date: Wed Dec 2 23:11:05 2009
New Revision: 90413
URL: http://llvm.org/viewvc/llvm-project?rev=90413&view=rev
Log:
Add clang -cc1 -load option.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=90413&r1=90412&r2=90413&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Wed Dec 2 23:11:05 2009
@@ -39,6 +39,8 @@
"could not remap from missing file '%0'">, DefaultFatal;
def err_fe_unable_to_load_pch : Error<
"unable to load PCH file">;
+def err_fe_unable_to_load_plugin : Error<
+ "unable to load plugin '%0': '%1'">;
def err_verify_bogus_characters : Error<
"bogus characters before '{{' in expected string">;
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=90413&r1=90412&r2=90413&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Wed Dec 2 23:11:05 2009
@@ -205,6 +205,8 @@
def fixit_at : Separate<"-fixit-at">, MetaVarName<"source-location">,
HelpText<"Perform Fix-It modifications at the given source location">;
def o : Separate<"-o">, MetaVarName<"path">, HelpText<"Specify output file">;
+def load : Separate<"-load">, MetaVarName<"dsopath">,
+ HelpText<"Load the named plugin (dynamic shared object)">;
def plugin : Separate<"-plugin">,
HelpText<"Use the named plugin action (use \"help\" to list available options)">;
Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=90413&r1=90412&r2=90413&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Wed Dec 2 23:11:05 2009
@@ -105,6 +105,9 @@
/// The name of the action to run when using a plugin action.
std::string ActionName;
+ /// The list of plugins to load.
+ std::vector<std::string> Plugins;
+
public:
FrontendOptions() {
DebugCodeCompletionPrinter = 1;
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=90413&r1=90412&r2=90413&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Dec 2 23:11:05 2009
@@ -345,6 +345,10 @@
Res.push_back("-plugin");
Res.push_back(Opts.ActionName);
}
+ for (unsigned i = 0, e = Opts.Plugins.size(); i != e; ++i) {
+ Res.push_back("-load");
+ Res.push_back(Opts.Plugins[i]);
+ }
}
static void HeaderSearchOptsToArgs(const HeaderSearchOptions &Opts,
@@ -877,6 +881,7 @@
}
Opts.OutputFile = getLastArgValue(Args, OPT_o);
+ Opts.Plugins = getAllArgValues(Args, OPT_load);
Opts.RelocatablePCH = Args.hasArg(OPT_relocatable_pch);
Opts.ShowMacrosInCodeCompletion = Args.hasArg(OPT_code_completion_macros);
Opts.ShowStats = Args.hasArg(OPT_print_stats);
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=90413&r1=90412&r2=90413&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Wed Dec 2 23:11:05 2009
@@ -42,6 +42,7 @@
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/System/DynamicLibrary.h"
#include "llvm/System/Host.h"
#include "llvm/System/Path.h"
#include "llvm/System/Signals.h"
@@ -299,7 +300,8 @@
Clang.getDiagnostics(), argv[0]))
return 1;
#else
- // Buffer diagnostics from argument parsing.
+ // Buffer diagnostics from argument parsing so that we can output them using a
+ // well formed diagnostic object.
TextDiagnosticBuffer DiagsBuffer;
Diagnostic Diags(&DiagsBuffer);
@@ -321,6 +323,15 @@
DiagsBuffer.FlushDiagnostics(Clang.getDiagnostics());
+ // Load any requested plugins.
+ for (unsigned i = 0,
+ e = Clang.getFrontendOpts().Plugins.size(); i != e; ++i) {
+ const std::string &Path = Clang.getFrontendOpts().Plugins[i];
+ std::string Error;
+ if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error))
+ Diags.Report(diag::err_fe_unable_to_load_plugin) << Path << Error;
+ }
+
// If there were any errors in processing arguments, exit now.
if (Clang.getDiagnostics().getNumErrors())
return 1;
More information about the cfe-commits
mailing list