Index: llvm/include/llvm/IR/DebugInfoMetadata.h =================================================================== --- llvm/include/llvm/IR/DebugInfoMetadata.h +++ llvm/include/llvm/IR/DebugInfoMetadata.h @@ -618,7 +618,9 @@ return StringRefChecksum; } Optional getSource() const { - return Source ? Optional((*Source)->getString()) : None; + if (!Source || !*Source) + return None; + return Optional((*Source)->getString()); } MDString *getRawFilename() const { return getOperandAs(0); }