Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Frontend/CompilerInstance.cpp
Show All 33 Lines | |||||
#include "clang/Lex/PreprocessorOptions.h" | #include "clang/Lex/PreprocessorOptions.h" | ||||
#include "clang/Sema/CodeCompleteConsumer.h" | #include "clang/Sema/CodeCompleteConsumer.h" | ||||
#include "clang/Sema/Sema.h" | #include "clang/Sema/Sema.h" | ||||
#include "clang/Serialization/ASTReader.h" | #include "clang/Serialization/ASTReader.h" | ||||
#include "clang/Serialization/GlobalModuleIndex.h" | #include "clang/Serialization/GlobalModuleIndex.h" | ||||
#include "clang/Serialization/InMemoryModuleCache.h" | #include "clang/Serialization/InMemoryModuleCache.h" | ||||
#include "llvm/ADT/ScopeExit.h" | #include "llvm/ADT/ScopeExit.h" | ||||
#include "llvm/ADT/Statistic.h" | #include "llvm/ADT/Statistic.h" | ||||
#include "llvm/Passes/PassPlugin.h" | |||||
#include "llvm/Passes/PassPluginRegistry.h" | |||||
#include "llvm/Support/BuryPointer.h" | #include "llvm/Support/BuryPointer.h" | ||||
#include "llvm/Support/CrashRecoveryContext.h" | #include "llvm/Support/CrashRecoveryContext.h" | ||||
#include "llvm/Support/Errc.h" | #include "llvm/Support/Errc.h" | ||||
#include "llvm/Support/FileSystem.h" | #include "llvm/Support/FileSystem.h" | ||||
#include "llvm/Support/Host.h" | #include "llvm/Support/Host.h" | ||||
#include "llvm/Support/LockFileManager.h" | #include "llvm/Support/LockFileManager.h" | ||||
#include "llvm/Support/MemoryBuffer.h" | #include "llvm/Support/MemoryBuffer.h" | ||||
#include "llvm/Support/Path.h" | #include "llvm/Support/Path.h" | ||||
▲ Show 20 Lines • Show All 1,041 Lines • ▼ Show 20 Lines | void CompilerInstance::LoadRequestedPlugins() { | ||||
// Load any requested plugins. | // Load any requested plugins. | ||||
for (const std::string &Path : getFrontendOpts().Plugins) { | for (const std::string &Path : getFrontendOpts().Plugins) { | ||||
std::string Error; | std::string Error; | ||||
if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error)) | if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error)) | ||||
getDiagnostics().Report(diag::err_fe_unable_to_load_plugin) | getDiagnostics().Report(diag::err_fe_unable_to_load_plugin) | ||||
<< Path << Error; | << Path << Error; | ||||
} | } | ||||
// Load the pass plugins right away, so that they can register their options. | |||||
for (auto &PluginPath : getCodeGenOpts().PassPlugins) { | |||||
auto LoadedPassPlugin = llvm::PassPlugin::Load(PluginPath); | |||||
if (LoadedPassPlugin) { | |||||
llvm::PassPluginRegistry::addPlugin(std::move(LoadedPassPlugin.get())); | |||||
} else { | |||||
getDiagnostics().Report(diag::err_fe_unable_to_load_plugin) | |||||
<< PluginPath << toString(LoadedPassPlugin.takeError()); | |||||
} | |||||
} | |||||
// Check if any of the loaded plugins replaces the main AST action | // Check if any of the loaded plugins replaces the main AST action | ||||
for (const FrontendPluginRegistry::entry &Plugin : | for (const FrontendPluginRegistry::entry &Plugin : | ||||
FrontendPluginRegistry::entries()) { | FrontendPluginRegistry::entries()) { | ||||
std::unique_ptr<PluginASTAction> P(Plugin.instantiate()); | std::unique_ptr<PluginASTAction> P(Plugin.instantiate()); | ||||
if (P->getActionType() == PluginASTAction::ReplaceAction) { | if (P->getActionType() == PluginASTAction::ReplaceAction) { | ||||
getFrontendOpts().ProgramAction = clang::frontend::PluginAction; | getFrontendOpts().ProgramAction = clang::frontend::PluginAction; | ||||
getFrontendOpts().ActionName = Plugin.getName().str(); | getFrontendOpts().ActionName = Plugin.getName().str(); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 1,192 Lines • Show Last 20 Lines |