summaryrefslogtreecommitdiff
path: root/lib/AsmParser/Parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AsmParser/Parser.cpp')
-rw-r--r--lib/AsmParser/Parser.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp
index 9145a54f2a7b..4e55e62ecf5c 100644
--- a/lib/AsmParser/Parser.cpp
+++ b/lib/AsmParser/Parser.cpp
@@ -66,3 +66,15 @@ std::unique_ptr<Module> llvm::parseAssemblyString(StringRef AsmString,
MemoryBufferRef F(AsmString, "<string>");
return parseAssembly(F, Err, Context, Slots);
}
+
+Constant *llvm::parseConstantValue(StringRef Asm, SMDiagnostic &Err,
+ const Module &M, const SlotMapping *Slots) {
+ SourceMgr SM;
+ std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Asm);
+ SM.AddNewSourceBuffer(std::move(Buf), SMLoc());
+ Constant *C;
+ if (LLParser(Asm, SM, Err, const_cast<Module *>(&M))
+ .parseStandaloneConstantValue(C, Slots))
+ return nullptr;
+ return C;
+}