File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 14
14
#include " SourceCode.h"
15
15
#include " index/Index.h"
16
16
#include " support/Logger.h"
17
+ #include " clang/AST/DeclFriend.h"
17
18
#include " clang/AST/DeclTemplate.h"
18
19
#include " clang/Index/IndexSymbol.h"
19
20
#include " llvm/ADT/ArrayRef.h"
@@ -391,6 +392,17 @@ class DocumentOutline {
391
392
D = TD;
392
393
}
393
394
395
+ // FriendDecls don't act as DeclContexts, but they might wrap a function
396
+ // definition that won't be visible through other means in the AST. Hence
397
+ // unwrap it here instead.
398
+ if (auto *Friend = llvm::dyn_cast<FriendDecl>(D)) {
399
+ if (auto *Func =
400
+ llvm::dyn_cast_or_null<FunctionDecl>(Friend->getFriendDecl ())) {
401
+ if (Func->isThisDeclarationADefinition ())
402
+ D = Func;
403
+ }
404
+ }
405
+
394
406
VisitKind Visit = shouldVisit (D);
395
407
if (Visit == VisitKind::No)
396
408
return ;
Original file line number Diff line number Diff line change @@ -335,6 +335,7 @@ TEST(DocumentSymbols, BasicSymbols) {
335
335
Foo(int a) {}
336
336
void $decl[[f]]();
337
337
friend void f1();
338
+ friend void f2() {}
338
339
friend class Friend;
339
340
Foo& operator=(const Foo&);
340
341
~Foo();
@@ -346,7 +347,7 @@ TEST(DocumentSymbols, BasicSymbols) {
346
347
};
347
348
348
349
void f1();
349
- inline void f2() {}
350
+ void f2();
350
351
static const int KInt = 2;
351
352
const char* kStr = "123";
352
353
@@ -386,6 +387,8 @@ TEST(DocumentSymbols, BasicSymbols) {
386
387
withDetail (" (int)" ), children ()),
387
388
AllOf (withName (" f" ), withKind (SymbolKind::Method),
388
389
withDetail (" void ()" ), children ()),
390
+ AllOf (withName (" f2" ), withKind (SymbolKind::Function),
391
+ withDetail (" void ()" ), children ()),
389
392
AllOf (withName (" operator=" ), withKind (SymbolKind::Method),
390
393
withDetail (" Foo &(const Foo &)" ), children ()),
391
394
AllOf (withName (" ~Foo" ), withKind (SymbolKind::Constructor),
You can’t perform that action at this time.
0 commit comments