[clang] [CIR] Fix a crash when source location is unknown (PR #185059)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 6 10:05:35 PST 2026
================
@@ -113,9 +113,14 @@ mlir::Location CIRGenFunction::getLoc(SourceLocation srcLoc) {
return mlir::FileLineColLoc::get(builder.getStringAttr(filename),
pLoc.getLine(), pLoc.getColumn());
}
- // Do our best...
+ // We expect to have a currSrcLoc set, so we assert here, but it isn't
+ // critical for the correctness of compilation, so in non-assert builds
+ // we fallback on using an unknown location.
assert(currSrcLoc && "expected to inherit some source location");
- return *currSrcLoc;
+ if (currSrcLoc)
+ return *currSrcLoc;
+ // We're brave, but time to give up.
----------------
erichkeane wrote:
I see this comment came from below, but lol :D
https://github.com/llvm/llvm-project/pull/185059
More information about the cfe-commits
mailing list