]> granicus.if.org Git - clang/commitdiff
[libclang] Forward isInline for NamespaceDecl to libclang
authorNikolai Kosjar <nikolai.kosjar@qt.io>
Fri, 10 May 2019 13:58:34 +0000 (13:58 +0000)
committerNikolai Kosjar <nikolai.kosjar@qt.io>
Fri, 10 May 2019 13:58:34 +0000 (13:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360428 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang-c/Index.h
test/Index/print-type.cpp
tools/c-index-test/c-index-test.c
tools/libclang/CXType.cpp
tools/libclang/libclang.exports

index 24b865cbaf3b1962b4c4e10f1a1497daf7c47562..7982d65bf234a68d9825898d57d4fccccb9b0217 100644 (file)
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 56
+#define CINDEX_VERSION_MINOR 57
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
       ((major) * 10000)                       \
@@ -3932,6 +3932,12 @@ CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
  */
 CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);
 
+/**
+ * Determine whether the given cursor represents an inline namespace
+ * declaration.
+ */
+CINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C);
+
 enum CXRefQualifierKind {
   /** No ref-qualifier was provided. */
   CXRefQualifier_None = 0,
index 17bae2e9c30793e61c4201a9ba49e40f96ef7780..32d1185eecb93dc068df8afd72c766b2660254db 100644 (file)
@@ -90,6 +90,8 @@ class X {
 namespace {
   int a;
 }
+
+inline namespace InlineNS {}
 // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] [isPOD=0]
@@ -204,3 +206,4 @@ namespace {
 // CHECK: UnionDecl=:86:3 (Definition) [type=X::(anonymous union at {{.*}}print-type.cpp:86:3)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1]
 // CHECK: EnumDecl=:87:3 (Definition) [type=X::(anonymous enum at {{.*}}print-type.cpp:87:3)] [typekind=Enum] [isPOD=1] [isAnon=1]
 // CHECK: Namespace=:90:11 (Definition) [type=] [typekind=Invalid] [isPOD=0] [isAnon=1]
+// CHECK: Namespace=InlineNS:94:18 (Definition) [type=] [typekind=Invalid] [isPOD=0] [isAnonRecDecl=0] [isInlineNamespace=1]
index 17b773c63664897dae2c76dca7235c6adeebe29e..42fd0bbef09486a69b75fb21e54638dc44af9b9e 100644 (file)
@@ -1671,6 +1671,13 @@ static enum CXChildVisitResult PrintType(CXCursor cursor, CXCursor p,
       printf(" [isAnonRecDecl=%d]", isAnonRecDecl);
     }
 
+    /* Print if it is an inline namespace decl */
+    {
+      unsigned isInlineNamespace = clang_Cursor_isInlineNamespace(cursor);
+      if (isInlineNamespace != 0)
+        printf(" [isInlineNamespace=%d]", isInlineNamespace);
+    }
+
     printf("\n");
   }
   return CXChildVisit_Recurse;
index 47a9bb9c1d20c783cb3135e5d81eeb3dd090e2bd..c7ac57238223c14acad69c7d2d5889b6e336cfae 100644 (file)
@@ -1271,6 +1271,14 @@ unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C){
   return 0;
 }
 
+unsigned clang_Cursor_isInlineNamespace(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+    return 0;
+  const Decl *D = cxcursor::getCursorDecl(C);
+  const NamespaceDecl *ND = dyn_cast_or_null<NamespaceDecl>(D);
+  return ND ? ND->isInline() : 0;
+}
+
 CXType clang_Type_getNamedType(CXType CT){
   QualType T = GetQualType(CT);
   const Type *TP = T.getTypePtrOrNull();
index 1d3cd5cd145dde9b987a57b1ad1402a5af28f675..3c76090d64f11e91adf5a0e52316837bef15c00b 100644 (file)
@@ -43,6 +43,7 @@ clang_Cursor_isAnonymousRecordDecl
 clang_Cursor_isBitField
 clang_Cursor_isDynamicCall
 clang_Cursor_isExternalSymbol
+clang_Cursor_isInlineNamespace
 clang_Cursor_isNull
 clang_Cursor_isObjCOptional
 clang_Cursor_isVariadic