diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 4691af76b763847feb142e372c5bfcfb58b64d9e..1762148dbc566c007d82214cf64a7f7b0f0cf85a 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -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. diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index ef14660135b39b0649b488022383ad3107699c6d..2b226b8e7559e0e7b66d9b280423637543aacb60 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -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: diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 23e50d6761be672c036b0e2614d2c17cc86a30bb..4a1badb68d52403fdfae304e9f093bd1f1291677 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -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"); diff --git a/tools/libclang/CursorVisitor.h b/tools/libclang/CursorVisitor.h index 3e5b0c9120c54355ee42b01921f6f833685d108b..356251d425ce7421bb7eae9541e9f2b9aa3c863e 100644 --- a/tools/libclang/CursorVisitor.h +++ b/tools/libclang/CursorVisitor.h @@ -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);