ChuanqiXu9 wrote:

> > > Trying to make a reproducer.
> > 
> > 
> > Hi @ChuanqiXu9, were you able to get a minimal reproducer?
> 
> I was trying and interrupted by other stuffs. I'll try to make it in two 
> weeks.

It is super hard to get a minimal reproducer. So I debugged a little bit and to 
reveal the issue more easily.

For clang/include/clang/Serialization/ASTReader.h 
ASTReader::ReadSourceLocation, we should change it to:

```
SourceLocation Result =
    TranslateSourceLocation(*OwningModuleFile, Loc);
if (Result.isMacroID()) {
  bool Invalid = false;
  const SrcMgr::SLocEntry &Entry =
      SourceMgr.getSLocEntry(SourceMgr.getFileID(Result), &Invalid);
  if (!Invalid && Entry.isFile())
    llvm_unreachable("serialized MacroID translated to FileInfo");
}
return Result;
```

then use the following test:

```
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/q.h \
// RUN:     -I%t -Wno-experimental-header-units -o %t/q.pcm
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/a.h \
// RUN:     -I%t -fmodule-file=%t/q.pcm \
// RUN:     -Wno-experimental-header-units -o %t/a.pcm
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/b.h \
// RUN:     -I%t -fmodule-file=%t/a.pcm \
// RUN:     -Wno-experimental-header-units -o %t/b.pcm
// RUN: ulimit -c 0 && not --crash %clang_cc1 -std=c++20 -fsyntax-only \
// RUN:     %t/use.cpp -I%t -fmodule-file=%t/b.pcm \
// RUN:     -Wno-experimental-header-units

//--- dup.h
#define DECL(name) template <class T> struct name { T value; };

//--- q.h
#include "dup.h"

//--- a.h
import "q.h";
#include "dup.h"
DECL(Box)

//--- b.h
import "a.h";
using Alias = Box<int>;

//--- use.cpp
import "b.h";
Alias value;
int main() { return value.value; }
``` 
```

https://github.com/llvm/llvm-project/pull/209795
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to