Skip to content

Commit ea634ac

Browse files
committed
[APINotes] Do not require spelling out inline namespaces
rdar://113403829
1 parent 9059c3c commit ea634ac

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

clang/lib/Sema/SemaAPINotes.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,8 @@ void Sema::ProcessAPINotes(Decl *D) {
824824
{
825825
auto CurrentNamespace = NamespaceContext;
826826
while (CurrentNamespace) {
827-
NamespaceStack.push(CurrentNamespace);
827+
if (!CurrentNamespace->isInlineNamespace())
828+
NamespaceStack.push(CurrentNamespace);
828829
CurrentNamespace =
829830
dyn_cast<NamespaceDecl>(CurrentNamespace->getParent());
830831
}

clang/test/APINotes/Inputs/Headers/Namespaces.apinotes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
---
22
Name: Namespaces
3+
Globals:
4+
- Name: varInInlineNamespace
5+
SwiftName: swiftVarInInlineNamespace
36
Functions:
47
- Name: funcInNamespace
58
SwiftName: inWrongContext()
9+
- Name: funcInInlineNamespace
10+
SwiftName: swiftFuncInInlineNamespace()
611
Tags:
712
- Name: char_box
813
SwiftName: InWrongContext
@@ -42,3 +47,7 @@ Namespaces:
4247
Globals:
4348
- Name: varInNestedNamespace
4449
SwiftName: swiftAnotherVarInNestedNamespace
50+
- Name: InlineNamespace1
51+
Functions:
52+
- Name: funcInInlineNamespace
53+
SwiftName: shouldNotSpellOutInlineNamespaces()

clang/test/APINotes/Inputs/Headers/Namespaces.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ namespace Namespace1 {
3232
typedef int my_typedef;
3333
using my_using_decl = int;
3434
}
35+
36+
inline namespace InlineNamespace1 {
37+
static int varInInlineNamespace = 3;
38+
void funcInInlineNamespace();
39+
}

clang/test/APINotes/namespaces.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
// RUN: %clang_cc1 -fmodules -fblocks -fimplicit-module-maps -fmodules-cache-path=%t/ModulesCache/CxxInterop -fdisable-module-hash -fapinotes-modules -fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -ast-dump -ast-dump-filter Namespace1::Nested1::char_box -x objective-c++ | FileCheck -check-prefix=CHECK-STRUCT-IN-NESTED-NAMESPACE %s
1111
// RUN: %clang_cc1 -fmodules -fblocks -fimplicit-module-maps -fmodules-cache-path=%t/ModulesCache/CxxInterop -fdisable-module-hash -fapinotes-modules -fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -ast-dump -ast-dump-filter Namespace1::Nested1::funcInNestedNamespace -x objective-c++ | FileCheck -check-prefix=CHECK-FUNC-IN-NESTED-NAMESPACE %s
1212
// RUN: %clang_cc1 -fmodules -fblocks -fimplicit-module-maps -fmodules-cache-path=%t/ModulesCache/CxxInterop -fdisable-module-hash -fapinotes-modules -fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -ast-dump -ast-dump-filter Namespace1::Nested1::Namespace1::char_box -x objective-c++ | FileCheck -check-prefix=CHECK-STRUCT-IN-DEEP-NESTED-NAMESPACE %s
13+
// RUN: %clang_cc1 -fmodules -fblocks -fimplicit-module-maps -fmodules-cache-path=%t/ModulesCache/CxxInterop -fdisable-module-hash -fapinotes-modules -fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -ast-dump -ast-dump-filter varInInlineNamespace -x objective-c++ | FileCheck -check-prefix=CHECK-GLOBAL-IN-INLINE-NAMESPACE %s
14+
// RUN: %clang_cc1 -fmodules -fblocks -fimplicit-module-maps -fmodules-cache-path=%t/ModulesCache/CxxInterop -fdisable-module-hash -fapinotes-modules -fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -ast-dump -ast-dump-filter funcInInlineNamespace -x objective-c++ | FileCheck -check-prefix=CHECK-FUNC-IN-INLINE-NAMESPACE %s
1315

1416
#import <Namespaces.h>
1517

@@ -56,3 +58,12 @@
5658
// CHECK-STRUCT-IN-DEEP-NESTED-NAMESPACE: Dumping Namespace1::Nested1::Namespace1::char_box:
5759
// CHECK-STRUCT-IN-DEEP-NESTED-NAMESPACE-NEXT: CXXRecordDecl {{.+}} imported in Namespaces <undeserialized declarations> struct char_box
5860
// CHECK-STRUCT-IN-DEEP-NESTED-NAMESPACE: SwiftNameAttr {{.+}} <<invalid sloc>> "DeepNestedCharBox"
61+
62+
// CHECK-GLOBAL-IN-INLINE-NAMESPACE: Dumping varInInlineNamespace:
63+
// CHECK-GLOBAL-IN-INLINE-NAMESPACE-NEXT: VarDecl {{.+}} imported in Namespaces varInInlineNamespace 'int' static cinit
64+
// CHECK-GLOBAL-IN-INLINE-NAMESPACE-NEXT: IntegerLiteral {{.+}} 'int' 3
65+
// CHECK-GLOBAL-IN-INLINE-NAMESPACE-NEXT: SwiftNameAttr {{.+}} <<invalid sloc>> "swiftVarInInlineNamespace"
66+
67+
// CHECK-FUNC-IN-INLINE-NAMESPACE: Dumping funcInInlineNamespace:
68+
// CHECK-FUNC-IN-INLINE-NAMESPACE-NEXT: FunctionDecl {{.+}} imported in Namespaces funcInInlineNamespace 'void ()'
69+
// CHECK-FUNC-IN-INLINE-NAMESPACE-NEXT: SwiftNameAttr {{.+}} <<invalid sloc>> "swiftFuncInInlineNamespace()"

0 commit comments

Comments
 (0)