]> granicus.if.org Git - clang/commitdiff
CIndex: add support for static_assert
authorOlivier Goffart <ogoffart@woboq.com>
Thu, 9 Jun 2016 16:15:55 +0000 (16:15 +0000)
committerOlivier Goffart <ogoffart@woboq.com>
Thu, 9 Jun 2016 16:15:55 +0000 (16:15 +0000)
Differential Revision: http://reviews.llvm.org/D18080

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272273 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang-c/Index.h
lib/Sema/SemaCodeComplete.cpp
tools/libclang/CIndex.cpp
tools/libclang/CursorVisitor.h

index 4691af76b763847feb142e372c5bfcfb58b64d9e..1762148dbc566c007d82214cf64a7f7b0f0cf85a 100644 (file)
@@ -2359,8 +2359,12 @@ enum CXCursorKind {
    */
   CXCursor_ModuleImportDecl              = 600,
   CXCursor_TypeAliasTemplateDecl         = 601,
+  /**
+   * \brief A static_assert or _Static_assert node
+   */
+  CXCursor_StaticAssert                  = 602,
   CXCursor_FirstExtraDecl                = CXCursor_ModuleImportDecl,
-  CXCursor_LastExtraDecl                 = CXCursor_TypeAliasTemplateDecl,
+  CXCursor_LastExtraDecl                 = CXCursor_StaticAssert,
 
   /**
    * \brief A code completion overload candidate.
index ef14660135b39b0649b488022383ad3107699c6d..2b226b8e7559e0e7b66d9b280423637543aacb60 100644 (file)
@@ -3044,6 +3044,7 @@ CXCursorKind clang::getCursorKindForDecl(const Decl *D) {
     case Decl::ClassTemplatePartialSpecialization:
       return CXCursor_ClassTemplatePartialSpecialization;
     case Decl::UsingDirective:     return CXCursor_UsingDirective;
+    case Decl::StaticAssert:       return CXCursor_StaticAssert;
     case Decl::TranslationUnit:    return CXCursor_TranslationUnit;
       
     case Decl::Using:
index 23e50d6761be672c036b0e2614d2c17cc86a30bb..4a1badb68d52403fdfae304e9f093bd1f1291677 100644 (file)
@@ -1230,6 +1230,14 @@ bool CursorVisitor::VisitUnresolvedUsingTypenameDecl(
   return false;
 }
 
+bool CursorVisitor::VisitStaticAssertDecl(StaticAssertDecl *D) {
+  if (Visit(MakeCXCursor(D->getAssertExpr(), StmtParent, TU, RegionOfInterest)))
+    return true;
+  if (Visit(MakeCXCursor(D->getMessage(), StmtParent, TU, RegionOfInterest)))
+    return true;
+  return false;
+}
+
 bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {
   switch (Name.getName().getNameKind()) {
   case clang::DeclarationName::Identifier:
@@ -4822,6 +4830,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
       return cxstring::createRef("OverloadCandidate");
   case CXCursor_TypeAliasTemplateDecl:
       return cxstring::createRef("TypeAliasTemplateDecl");
+  case CXCursor_StaticAssert:
+      return cxstring::createRef("StaticAssert");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");
index 3e5b0c9120c54355ee42b01921f6f833685d108b..356251d425ce7421bb7eae9541e9f2b9aa3c863e 100644 (file)
@@ -238,6 +238,7 @@ public:
   bool VisitUsingDecl(UsingDecl *D);
   bool VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
   bool VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
+  bool VisitStaticAssertDecl(StaticAssertDecl *D);
   
   // Name visitor
   bool VisitDeclarationNameInfo(DeclarationNameInfo Name);