aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-05-06 23:38:21 +0000
committerTed Kremenek <kremenek@apple.com>2010-05-06 23:38:21 +0000
commit8f06e0e9fec3ca501e5fb129f413adbfc88e82f8 (patch)
treee60c9b896d8ee340522892d827676d71cc61feb9
parenta97badf8a59368d69dea7e24b18e72c482f055a0 (diff)
Add CXCursor support for C++ namespaces.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103211 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang-c/Index.h5
-rw-r--r--tools/libclang/CIndex.cpp7
-rw-r--r--tools/libclang/CXCursor.cpp1
3 files changed, 11 insertions, 2 deletions
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 1bf5a4688a..8e6542e40c 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -700,11 +700,12 @@ enum CXCursorKind {
CXCursor_ObjCCategoryImplDecl = 19,
/** \brief A typedef */
CXCursor_TypedefDecl = 20,
-
/** \brief A C++ class method. */
CXCursor_CXXMethod = 21,
+ /** \brief A C++ namespace. */
+ CXCursor_Namespace = 22,
- CXCursor_LastDecl = 21,
+ CXCursor_LastDecl = CXCursor_Namespace,
/* References */
CXCursor_FirstRef = 40, /* Decl references */
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index ef802f574b..f221d16af2 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -285,6 +285,7 @@ public:
// FIXME: ObjCCompatibleAliasDecl requires aliased-class locations.
bool VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D);
bool VisitObjCClassDecl(ObjCClassDecl *D);
+ bool VisitNamespaceDecl(NamespaceDecl *D);
// Type visitors
// FIXME: QualifiedTypeLoc doesn't provide any location information
@@ -722,6 +723,10 @@ bool CursorVisitor::VisitObjCClassDecl(ObjCClassDecl *D) {
return false;
}
+bool CursorVisitor::VisitNamespaceDecl(NamespaceDecl *D) {
+ return VisitDeclContext(D);
+}
+
bool CursorVisitor::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
ASTContext &Context = TU->getASTContext();
@@ -1638,6 +1643,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
return createCXString("macro definition");
case CXCursor_MacroInstantiation:
return createCXString("macro instantiation");
+ case CXCursor_Namespace:
+ return createCXString("Namespace");
}
llvm_unreachable("Unhandled CXCursorKind");
diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp
index c8eb482377..df20d26072 100644
--- a/tools/libclang/CXCursor.cpp
+++ b/tools/libclang/CXCursor.cpp
@@ -56,6 +56,7 @@ static CXCursorKind GetCursorKind(Decl *D) {
case Decl::ParmVar: return CXCursor_ParmDecl;
case Decl::Typedef: return CXCursor_TypedefDecl;
case Decl::Var: return CXCursor_VarDecl;
+ case Decl::Namespace: return CXCursor_Namespace;
default:
if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
switch (TD->getTagKind()) {