diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-10-11 19:58:38 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-10-11 19:58:38 +0000 |
commit | 659837e0ce0f73c7fdd5941854be3500db2f4013 (patch) | |
tree | e554d7dbe056decd00ae557bae3a0ee0991f9e5d /tools | |
parent | 1d82b1a33bcfe85f4834fb6920517ed07e9355d3 (diff) | |
download | clang-659837e0ce0f73c7fdd5941854be3500db2f4013.tar.gz clang-659837e0ce0f73c7fdd5941854be3500db2f4013.tar.bz2 clang-659837e0ce0f73c7fdd5941854be3500db2f4013.tar.xz |
[libclang] Introduce clang_Type_getCXXRefQualifier whichexposes ref-qualifier information of function type.
Patch by Che-Liang Chiou!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192493 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/c-index-test/c-index-test.c | 5 | ||||
-rw-r--r-- | tools/libclang/CXType.cpp | 18 | ||||
-rw-r--r-- | tools/libclang/libclang.exports | 1 |
3 files changed, 24 insertions, 0 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index 2e8b58bff4..90a65282f4 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -1160,6 +1160,7 @@ static enum CXChildVisitResult PrintType(CXCursor cursor, CXCursor p, CXClientData d) { if (!clang_isInvalid(clang_getCursorKind(cursor))) { CXType T = clang_getCursorType(cursor); + enum CXRefQualifierKind RQ = clang_Type_getCXXRefQualifier(T); PrintCursor(cursor, NULL); PrintTypeAndTypeKind(T, " [type=%s] [typekind=%s]"); if (clang_isConstQualifiedType(T)) @@ -1168,6 +1169,10 @@ static enum CXChildVisitResult PrintType(CXCursor cursor, CXCursor p, printf(" volatile"); if (clang_isRestrictQualifiedType(T)) printf(" restrict"); + if (RQ == CXRefQualifier_LValue) + printf(" lvalue-ref-qualifier"); + if (RQ == CXRefQualifier_RValue) + printf(" rvalue-ref-qualifier"); /* Print the canonical type if it is different. */ { CXType CT = clang_getCanonicalType(T); diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp index 9233e975f6..1e2cb18984 100644 --- a/tools/libclang/CXType.cpp +++ b/tools/libclang/CXType.cpp @@ -816,6 +816,24 @@ long long clang_Type_getOffsetOf(CXType PT, const char *S) { return CXTypeLayoutError_InvalidFieldName; } +enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T) { + QualType QT = GetQualType(T); + if (QT.isNull()) + return CXRefQualifier_None; + const FunctionProtoType *FD = QT->getAs<FunctionProtoType>(); + if (!FD) + return CXRefQualifier_None; + switch (FD->getRefQualifier()) { + case RQ_None: + return CXRefQualifier_None; + case RQ_LValue: + return CXRefQualifier_LValue; + case RQ_RValue: + return CXRefQualifier_RValue; + } + return CXRefQualifier_None; +} + unsigned clang_Cursor_isBitField(CXCursor C) { if (!clang_isDeclaration(C.kind)) return 0; diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports index 6f6e39228d..9bf26c979d 100644 --- a/tools/libclang/libclang.exports +++ b/tools/libclang/libclang.exports @@ -64,6 +64,7 @@ clang_Type_getAlignOf clang_Type_getClassType clang_Type_getSizeOf clang_Type_getOffsetOf +clang_Type_getCXXRefQualifier clang_VerbatimBlockLineComment_getText clang_VerbatimLineComment_getText clang_HTMLTagComment_getAsString |