[clang] [Clang] Report an error and crash on source location exhaustion in macros (PR #69908)
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 23 03:00:05 PDT 2023
================
@@ -663,10 +663,13 @@ SourceManager::createExpansionLocImpl(const ExpansionInfo &Info,
return SourceLocation::getMacroLoc(LoadedOffset);
}
LocalSLocEntryTable.push_back(SLocEntry::get(NextLocalOffset, Info));
- // FIXME: Produce a proper diagnostic for this case.
- assert(NextLocalOffset + Length + 1 > NextLocalOffset &&
- NextLocalOffset + Length + 1 <= CurrentLoadedOffset &&
- "Ran out of source locations!");
+ if (NextLocalOffset + Length + 1 <= NextLocalOffset ||
+ NextLocalOffset + Length + 1 > CurrentLoadedOffset) {
+ Diag.Report(Info.getExpansionLocStart(), diag::err_expansions_too_large);
+ Diag.Report(Info.getExpansionLocStart(), diag::remark_sloc_usage);
+ noteSLocAddressSpaceUsage(Diag);
+ return SourceLocation();
----------------
sam-mccall wrote:
you're not crashing here?
https://github.com/llvm/llvm-project/pull/69908
More information about the cfe-commits
mailing list