[clang-tools-extra] [clangd] Harden incomingCalls() against possible misinterpretation of a range as pertaining to the wrong file (PR #111616)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 22 03:06:01 PDT 2024
================
@@ -2292,9 +2289,26 @@ incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index) {
Index->lookup(ContainerLookup, [&](const Symbol &Caller) {
auto It = CallsIn.find(Caller.ID);
assert(It != CallsIn.end());
- if (auto CHI = symbolToCallHierarchyItem(Caller, Item.uri.file()))
+ if (auto CHI = symbolToCallHierarchyItem(Caller, Item.uri.file())) {
+ SymbolLocation CallerLoc =
+ Caller.Definition ? Caller.Definition : Caller.CanonicalDeclaration;
+ std::vector<Range> FromRanges;
+ for (const SymbolLocation &L : It->second) {
+ if (StringRef{L.FileURI} != StringRef{CallerLoc.FileURI}) {
+ elog("incomingCalls: call location not in same file as caller, this "
----------------
hokein wrote:
I think this case is possible.
```
// t.h
#pragma once
#define abc2 void test4() {
// t.cc
#include "./t.h"
void func();
abc
func();
}
```
calling call-hierarchy for `func()`.
https://github.com/llvm/llvm-project/pull/111616
More information about the cfe-commits
mailing list