Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions clang/lib/Index/USRGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "clang/Index/USRGeneration.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/DeclVisitor.h"
#include "clang/Basic/FileManager.h"
Expand Down Expand Up @@ -368,14 +369,14 @@ void USRGenerator::VisitTemplateTemplateParmDecl(
}

void USRGenerator::VisitNamespaceDecl(const NamespaceDecl *D) {
if (IgnoreResults)
return;
VisitDeclContext(D->getDeclContext());
if (D->isAnonymousNamespace()) {
Out << "@aN";
return;
}

VisitDeclContext(D->getDeclContext());
if (!IgnoreResults)
Out << "@N@" << D->getName();
Out << "@N@" << D->getName();
}

void USRGenerator::VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
Expand Down
14 changes: 14 additions & 0 deletions clang/test/Index/USR/decl-context.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: c-index-test core -print-source-symbols -- -std=c++20 %s | FileCheck %s

namespace ns {
namespace {
struct Foo {};
// CHECK: [[@LINE-1]]:8 | struct/C | Foo | c:decl-context.cpp@N@ns@aN@S@Foo
}
}
namespace ns2 {
namespace {
struct Foo {};
// CHECK: [[@LINE-1]]:8 | struct/C | Foo | c:decl-context.cpp@N@ns2@aN@S@Foo
}
}