Issue 170084
Summary [clang][modules] Cannot get layout of forward declarations
Labels clang:modules, crash-on-valid
Assignees
Reporter hahnjo
    In https://github.com/llvm/llvm-project/pull/133057#issuecomment-3590912856, @alexfh helpfully reduced internal code which triggers a crash with the proposed changes in that PR. However, I noticed that the reduced example already fails on current `main`, which likely means that the changes expose a pre-existing bug. Converted to lit, the reproducer is the following (simplified even some more):
```c++
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
// RUN: cd %t

// RUN: %clang_cc1 -fmodule-name=stl -fno-cxx-modules -emit-module -fmodules -xc++ stl.cppmap -o stl.pcm
// RUN: %clang_cc1 -fmodule-name=d -fno-cxx-modules -emit-module -fmodules -fmodule-file=stl.pcm -xc++ d.cppmap -o d.pcm
// RUN: %clang_cc1 -fmodule-name=b -fno-cxx-modules -emit-module -fmodules -fmodule-file=stl.pcm -xc++ b.cppmap -o b.pcm
// RUN: %clang_cc1 -fmodule-name=a -fno-cxx-modules -emit-module -fmodules -fmodule-file=stl.pcm -fmodule-file=d.pcm -fmodule-file=b.pcm -xc++ a.cppmap -o a.pcm
// RUN: %clang_cc1 -fno-cxx-modules -fmodules -fmodule-file=a.pcm -emit-llvm -o /dev/null main.cpp

//--- a.cppmap
module "a" {
header "a.h"
}

//--- a.h
#include "b.h"
namespace {
void a(absl::set<char> c) {
 absl::set<int> b;
  c.end();
  c.contains();
}
}  // namespace

//--- b.cppmap
module "b" {
header "b.h"
}

//--- b.h
#include "c.h"
void b() { absl::set<char> x; }

//--- c.h
#include "stl.h"
namespace absl {
template <typename>
class set {
 public:
 struct iterator {
    void u() const;
  };
  iterator end() const { return {}; }
  void contains() const { end().u(); }
  pair<iterator> e();
};
} // namespace absl

//--- d.cppmap
module "d" {
header "d.h"
}

//--- d.h
#include "c.h"
void d() { absl::set<char> x; }

//--- stl.cppmap
module "stl" {
header "stl.h"
}

//--- stl.h
#ifndef _STL_H_
#define _STL_H_
template <class>
struct pair;
#endif

//--- main.cpp
// expected-no-diagnostics
#include "c.h"
void f(absl::set<char> o) { o.contains(); }
```

git-bisect points to 91cdd35008e9ab32dffb7e401cdd7313b3461892 after which there had already been #154840, but this issue seems different. @mizvekov 

FYI @ChuanqiXu9 @vgvassilev this blocks #133057 for the moment.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to