File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -247,6 +247,10 @@ class DocumentOutline {
247
247
enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };
248
248
249
249
void traverseDecl (Decl *D, std::vector<DocumentSymbol> &Results) {
250
+ // Skip symbols which do not originate from the main file.
251
+ if (!isInsideMainFile (D->getLocation (), AST.getSourceManager ()))
252
+ return ;
253
+
250
254
if (auto *Templ = llvm::dyn_cast<TemplateDecl>(D)) {
251
255
// TemplatedDecl might be null, e.g. concepts.
252
256
if (auto *TD = Templ->getTemplatedDecl ())
Original file line number Diff line number Diff line change @@ -523,11 +523,13 @@ TEST(DocumentSymbols, InHeaderFile) {
523
523
}
524
524
)cpp" ;
525
525
TU.Code = R"cpp(
526
+ int i; // declaration to finish preamble
526
527
#include "bar.h"
527
528
int test() {
528
529
}
529
530
)cpp" ;
530
- EXPECT_THAT (getSymbols (TU.build ()), ElementsAre (WithName (" test" )));
531
+ EXPECT_THAT (getSymbols (TU.build ()),
532
+ ElementsAre (WithName (" i" ), WithName (" test" )));
531
533
}
532
534
533
535
TEST (DocumentSymbols, Template) {
You can’t perform that action at this time.
0 commit comments