aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-11 17:02:10 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-11 17:02:10 +0000
commit04b6748ee90649069ee79464317ae6cd6aca317d (patch)
treeb60c695cbcaf69bb02bb30c91bdfc15a1ed25167 /tools
parent1407bee187d7b964d5293ac8bf4f7a490c78cec6 (diff)
[libclang] Have clang_getCXXAccessSpecifier() also return the access control of a C++ declaration within its parent scope.
Suggested by Stefan Seefeld. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179297 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/c-index-test/c-index-test.c17
-rw-r--r--tools/libclang/CIndexCXX.cpp2
2 files changed, 18 insertions, 1 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index e97cb30589..b77c88de58 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -934,6 +934,23 @@ enum CXChildVisitResult FilteredPrintingVisitor(CXCursor Cursor,
GetCursorSource(Cursor), line, column);
PrintCursor(Cursor, &Data->ValidationData);
PrintCursorExtent(Cursor);
+ if (clang_isDeclaration(Cursor.kind)) {
+ enum CX_CXXAccessSpecifier access = clang_getCXXAccessSpecifier(Cursor);
+ const char *accessStr = 0;
+
+ switch (access) {
+ case CX_CXXInvalidAccessSpecifier: break;
+ case CX_CXXPublic:
+ accessStr = "public"; break;
+ case CX_CXXProtected:
+ accessStr = "protected"; break;
+ case CX_CXXPrivate:
+ accessStr = "private"; break;
+ }
+
+ if (accessStr)
+ printf(" [access=%s]", accessStr);
+ }
printf("\n");
return CXChildVisit_Recurse;
}
diff --git a/tools/libclang/CIndexCXX.cpp b/tools/libclang/CIndexCXX.cpp
index c68dde7c2c..a3d236446f 100644
--- a/tools/libclang/CIndexCXX.cpp
+++ b/tools/libclang/CIndexCXX.cpp
@@ -33,7 +33,7 @@ unsigned clang_isVirtualBase(CXCursor C) {
enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor C) {
AccessSpecifier spec = AS_none;
- if (C.kind == CXCursor_CXXAccessSpecifier)
+ if (C.kind == CXCursor_CXXAccessSpecifier || clang_isDeclaration(C.kind))
spec = getCursorDecl(C)->getAccess();
else if (C.kind == CXCursor_CXXBaseSpecifier)
spec = getCursorCXXBaseSpecifier(C)->getAccessSpecifier();