Skip to content

Commit d733d4e

Browse files
andrurogerzcompnerd
authored andcommitted
properly position annotation on qualified record declarations
1 parent add2723 commit d733d4e

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

Sources/idt/idt.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,9 @@ class visitor : public clang::RecursiveASTVisitor<visitor> {
436436
// Insert the annotation immediately before the tag name, which is the
437437
// position returned by getLocation.
438438
clang::LangOptions LO = RD->getASTContext().getLangOpts();
439-
clang::SourceLocation SLoc = RD->getLocation();
439+
clang::SourceLocation SLoc = RD->getQualifier()
440+
? RD->getQualifierLoc().getBeginLoc()
441+
: RD->getLocation();
440442
const clang::SourceLocation location =
441443
context_.getFullLoc(SLoc).getExpansionLoc();
442444
unexported_public_interface(RD, location)

Tests/QualifiedRecordNames.hh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %idt --export-macro=IDT_TEST_ABI %s 2>&1 | %FileCheck %s
2+
3+
namespace ContainerNamespace {
4+
// CHECK-NOT: QualifiedRecordNames.hh:[[@LINE+1]]:{{.*}}
5+
struct QualifiedNameClass;
6+
}
7+
8+
// CHECK: QualifiedRecordNames.hh:[[@LINE+1]]:8: remark: unexported public interface 'QualifiedNameClass'
9+
struct ContainerNamespace::QualifiedNameClass {
10+
// CHECK-NOT: QualifiedRecordNames.hh:[[@LINE-1]]:{{.*}}
11+
12+
// CHECK-NOT: QualifiedRecordNames.hh:[[@LINE+1]]:{{.*}}
13+
virtual void method();
14+
};
15+
16+
// CHECK-NOT: QualifiedRecordNames.hh:[[@LINE+1]]:{{.*}}
17+
struct ContainerClass {
18+
// CHECK-NOT: QualifiedRecordNames.hh:[[@LINE+1]]:{{.*}}
19+
struct QualifiedNameClass;
20+
};
21+
22+
// CHECK: QualifiedRecordNames.hh:[[@LINE+1]]:8: remark: unexported public interface 'QualifiedNameClass'
23+
struct ContainerClass::QualifiedNameClass {
24+
// CHECK-NOT: QualifiedRecordNames.hh:[[@LINE-1]]:{{.*}}
25+
26+
// CHECK-NOT: QualifiedRecordNames.hh:[[@LINE+1]]:{{.*}}
27+
virtual void method();
28+
};
29+

0 commit comments

Comments
 (0)