[clang] Remove misleading assertion in FullSourceLoc
authorJan Svoboda <jan_svoboda@apple.com>
Fri, 6 Aug 2021 12:46:41 +0000 (14:46 +0200)
committerJan Svoboda <jan_svoboda@apple.com>
Fri, 6 Aug 2021 12:48:28 +0000 (14:48 +0200)
commit4aafd5f00c2a772337ec065d4542ef158453a343
treea807fe44818e6a1bb155c49432d8245ea0b8d0e5
parent3709822d2602b8b7db2d9bcc0e856f676582f25d
[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
clang/include/clang/Basic/SourceLocation.h
clang/test/Modules/Inputs/explicit-build-diags/a.h [new file with mode: 0644]
clang/test/Modules/Inputs/explicit-build-diags/module.modulemap [new file with mode: 0644]
clang/test/Modules/explicit-build-diags.cpp [new file with mode: 0644]