[clang] [clang][Sema] Suggest/Hint Standard Library Include File (PR #146227)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 1 08:27:38 PDT 2025
================
@@ -554,6 +563,11 @@ bool Parser::ParseOptionalCXXScopeSpecifier(
break;
}
+ if (FailedNesatedNameBuilding && Tok.getKind() == tok::identifier) {
----------------
Mr-Anyone wrote:
I completed agree with you for the fact that this is really ugly code here.
The problem I am trying to solve here is when there is no declaration for the `std` namespace.
```cpp
// this is the entire file
void some_func(){
std::cout << "some func has been called" << std::endl;
}
```
Here building the nested name will fail because there is no namespace std being defined anywhere, so a name lookup for `cout` is never performed (as far as I can tell, there could be something I am missing here). I am not sure if there is an easy fix to that in Sema level.
However, something like the following would work cause the suggestion to trigger. It is okay if I revert this file?
```cpp
namespace std {};
// this is the entire file
void some_func(){
std::cout << "some func has been called" << std::endl;
}
```
https://github.com/llvm/llvm-project/pull/146227
More information about the cfe-commits
mailing list