[all-commits] [llvm/llvm-project] 4aafd5: [clang] Remove misleading assertion in FullSourceLoc

Jan Svoboda via All-commits all-commits at lists.llvm.org
Fri Aug 6 05:48:41 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4aafd5f00c2a772337ec065d4542ef158453a343
      https://github.com/llvm/llvm-project/commit/4aafd5f00c2a772337ec065d4542ef158453a343
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2021-08-06 (Fri, 06 Aug 2021)

  Changed paths:
    M clang/include/clang/Basic/SourceLocation.h
    A clang/test/Modules/Inputs/explicit-build-diags/a.h
    A clang/test/Modules/Inputs/explicit-build-diags/module.modulemap
    A clang/test/Modules/explicit-build-diags.cpp

  Log Message:
  -----------
  [clang] Remove misleading assertion in FullSourceLoc

D31709 added an assertion was added to `FullSourceLoc::hasManager()` that ensured a valid `SourceLocation` is always paired with a `SourceManager`, and missing `SourceManager` is always paired with an invalid `SourceLocation`.

This appears to be incorrect, since clients never cared about constructing `FullSourceLoc` to uphold that invariant, or always checking `isValid()` before calling `hasManager()`.

The assertion started failing when serializing diagnostics pointing into an explicit module. Explicit modules don't have valid `SourceLocation` for the `import` statement, since they are "imported" from the command-line argument `-fmodule-name=x.pcm`.

This patch removes the assertion, since `FullSourceLoc` was never intended to uphold any kind of invariants between the validity of `SourceLocation` and presence of `SourceManager`.

Reviewed By: arphaman

Differential Revision: https://reviews.llvm.org/D106862




More information about the All-commits mailing list