Issue |
120388
|
Summary |
Suggest include file for popular standard functions
|
Labels |
enhancement,
clang:frontend,
clang:diagnostics
|
Assignees |
|
Reporter |
tbaederr
|
If, e.g. write:
```c++
int main() {
std::cout << "Hello world\n";
}
```
I think it would be nice for the compiler to suggest importing `<iostream>`. If I later write
```c++
#include <iostream>
int main() {
std::cout << "Hello world\n";
int a = 0, b = 0;
std::memcpy(&a, &b, 4);
}
```
it would be nice if it suggested importing `<cstring>`. I think a simple internal list of popular functions would be enough, we don't need to get fancy here.
I don't know if this collides with functionality that clangd or similar tools already provide though.
Popular D compilers have similar functionality:
```console
~ » cat test.d
void main() {
writeln("hello world");
}
~ » ldc2 test.d
test.d(7): Error: `writeln` is not defined, perhaps `import std.stdio;` is needed?
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs