diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -618,7 +618,7 @@ return StringRefChecksum; } Optional getSource() const { - return Source ? Optional((*Source)->getString()) : None; + return (Source && *Source) ? Optional((*Source)->getString()) : None; } MDString *getRawFilename() const { return getOperandAs(0); }