CIndex: add support for static_assert

Differential Revision: http://reviews.llvm.org/D18080

llvm-svn: 272273
This commit is contained in:
Olivier Goffart 2016-06-09 16:15:55 +00:00
parent 2da0cba5fb
commit 81978014c5
4 changed files with 17 additions and 1 deletions

View 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.

View 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:

View 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");

View 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);