[all-commits] [llvm/llvm-project] 324d1b: [Clang] Report an error and crash on source locati...

Ilya Biryukov via All-commits all-commits at lists.llvm.org
Mon Oct 23 05:29:13 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 324d1bb35aefec737ef381d98211f7771c4b0ab5
      https://github.com/llvm/llvm-project/commit/324d1bb35aefec737ef381d98211f7771c4b0ab5
  Author: Ilya Biryukov <ibiryukov at google.com>
  Date:   2023-10-23 (Mon, 23 Oct 2023)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticCommonKinds.td
    M clang/lib/Basic/SourceManager.cpp
    M clang/test/Lexer/SourceLocationsOverflow.c

  Log Message:
  -----------
  [Clang] Report an error and crash on source location exhaustion in macros (#69908)

`createExpansionLocImpl` has an assert that checks if we ran out of
source locations. We have observed this happening on real code and in
release builds the assertion does not fire and the compiler just keeps
running indefinitely without giving any indication that something went
wrong.

Diagnose this problem and reliably crash to make sure the problem is
easy to detect.

I have also tried:
- returning invalid source locations,
- reporting sloc address space usage on error.

Both caused the compiler to run indefinitely. It would be nice to dig
further why that happens, but until then crashing seems like a better
alternative.




More information about the All-commits mailing list