================
@@ -141,16 +143,41 @@ std::vector<Diag> generateMissingIncludeDiagnostics(
          AST.getPreprocessor().getHeaderSearchInfo(), MainFile});
 
     llvm::StringRef HeaderRef{Spelling};
-    bool Angled = HeaderRef.starts_with("<");
+
+    bool IsAngled = false;
----------------
kadircet wrote:

we shouldn't be matching against `HeaderRef`, but instead matching against 
`ResolvedPath` and only when `SymbolWithMissingInclude.Providers.front().kind() 
== Physical`

nit:
```cpp
bool Angled = HeaderRef.starts_with("<");
if (SymbolWithMissingInclude.Providers.front().kind() == ..Physical) {
    for (auto &Filter : Angled ? QuotedHeaders : AngledHeaders) {
      if (Filter(ResolvedPath)) {
        Angled = !Angled;
        break;
      }
    }
}
....
std::optional<tooling::Replacement> Replacement = HeaderIncludes.insert(
        HeaderRef.trim("\"<>"), Angled, tooling::IncludeDirective::Include);
```

[logic in the include 
inserter](https://github.com/llvm/llvm-project/blob/3033f202f6707937cd28c2473479db134993f96f/clang-tools-extra/clangd/Headers.cpp#L307)
 seem to have the same bug (we should match against paths, not spellings).

https://github.com/llvm/llvm-project/pull/140594
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to