[llvm] [MIR] Replace bespoke DIExpression parser (PR #96827)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 27 02:05:59 PDT 2024
================
@@ -224,3 +225,19 @@ Type *llvm::parseTypeAtBeginning(StringRef Asm, unsigned &Read,
return nullptr;
return Ty;
}
+
+DIExpression *llvm::parseDIExpressionAtBeginning(StringRef Asm, unsigned &Read,
+ SMDiagnostic &Err,
+ const Module &M,
+ const SlotMapping *Slots) {
+ SourceMgr SM;
+ std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Asm);
+ SM.AddNewSourceBuffer(std::move(Buf), SMLoc());
+ MDNode *MD;
+ if (LLParser(Asm, SM, Err, const_cast<Module *>(&M), nullptr, M.getContext())
+ .parseDIExpressionAtBeginning(MD, Read, Slots))
+ return nullptr;
+ if (auto *Expr = dyn_cast<DIExpression>(MD))
+ return Expr;
+ return nullptr;
----------------
OCHyams wrote:
```suggestion
return dyn_cast<DIExpression>(MD);
```
https://github.com/llvm/llvm-project/pull/96827
More information about the llvm-commits
mailing list