using namespace clang;
static CompilerInvocation *
-createCompilerInvocation(StringRef& Path, DiagnosticsEngine& Diags)
+createCompilerInvocation(llvm::opt::ArgStringList CFlags, StringRef& Path,
+ DiagnosticsEngine& Diags)
{
llvm::opt::ArgStringList CCArgs {
"-cc1",
"-Wno-unused-value",
"-Wno-pointer-sign",
"-x", "c"};
+
+ CCArgs.append(CFlags.begin(), CFlags.end());
CompilerInvocation *CI = tooling::newInvocation(&Diags, CCArgs);
FrontendOptions& Opts = CI->getFrontendOpts();
}
static std::unique_ptr<llvm::Module>
-getModuleFromSource(StringRef Path,
- IntrusiveRefCntPtr<vfs::FileSystem> VFS)
+getModuleFromSource(llvm::opt::ArgStringList CFlags,
+ StringRef Path, IntrusiveRefCntPtr<vfs::FileSystem> VFS)
{
CompilerInstance Clang;
Clang.createDiagnostics();
Clang.setVirtualFileSystem(&*VFS);
IntrusiveRefCntPtr<CompilerInvocation> CI =
- createCompilerInvocation(Path, Clang.getDiagnostics());
+ createCompilerInvocation(std::move(CFlags), Path,
+ Clang.getDiagnostics());
Clang.setInvocation(&*CI);
std::unique_ptr<CodeGenAction> Act(new EmitLLVMOnlyAction(&*LLVMCtx));
}
std::unique_ptr<llvm::Module>
-getModuleFromSource(StringRef Name, StringRef Content)
+getModuleFromSource(llvm::opt::ArgStringList CFlags,
+ StringRef Name, StringRef Content)
{
using namespace vfs;
OverlayFS->pushOverlay(MemFS);
MemFS->addFile(Twine(Name), 0, llvm::MemoryBuffer::getMemBuffer(Content));
- return getModuleFromSource(Name, OverlayFS);
+ return getModuleFromSource(std::move(CFlags), Name, OverlayFS);
}
std::unique_ptr<llvm::Module>
-getModuleFromSource(StringRef Path)
+getModuleFromSource(llvm::opt::ArgStringList CFlags, StringRef Path)
{
IntrusiveRefCntPtr<vfs::FileSystem> VFS(vfs::getRealFileSystem());
- return getModuleFromSource(Path, VFS);
+ return getModuleFromSource(std::move(CFlags), Path, VFS);
}
}
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
+#include "llvm/Option/Option.h"
#include <memory>
+
namespace perf {
using namespace llvm;
std::unique_ptr<Module>
-getModuleFromSource(StringRef Name, StringRef Content);
+getModuleFromSource(opt::ArgStringList CFlags,
+ StringRef Name, StringRef Content);
std::unique_ptr<Module>
-getModuleFromSource(StringRef Path);
+getModuleFromSource(opt::ArgStringList CFlags,
+ StringRef Path);
}
#endif