Issue 184542
Summary [C++20] [Modules] Maybe confusing diagnostics for suggesting #include for header in module file
Labels clang:modules
Assignees ChuanqiXu9
Reporter ChuanqiXu9
    Minmal Reproducer:

```C++
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++23 %t/mod.cppm -emit-reduced-module-interface -o %t/mod.pcm
// RUN: %clang_cc1 -std=c++23 %t/user.cpp -fprebuilt-module-path=%t -verify -fsyntax-only


//--- header.h
#ifndef HEADER_H
#define HEADER_H

inline void foo() {}
// Make sure foo() won't be optimized out.
inline void bar() { foo(); }

#endif

//--- mod.cppm
module;
#include "header.h"
export module mod;
export using ::bar;

//--- user.cpp
import mod;
void test() {
 foo(); // Suggests: missing '#include "header.h"';
}
```

The compiler said "missing #include". Not wrong. This is the reason why I didn't fix this for a long time. And also, for the past few years, I didn't heard a user complaining this to me.

But, when coding with AI, I told AI to use import. AI did. But compilation fails and clang said "missing #include". Then AI switches to #include smartly. But this is not what I want.

After all, in the new AI era, the diagnostic are much more important. All of us agree and believe diagnostic are important. But it shows it is more important than we thought. 


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to