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 | adff3ae3c8e9f3c2bf5caae0d1cb7484fa1b1ff6 (patch) | |
tree | b00d289afaa9cec066077044c581f9b4737dd191 /clang/tools | |
parent | a9767aed802937e772c327fdc4416c5ae4e81b80 (diff) | |
download | llvm-adff3ae3c8e9f3c2bf5caae0d1cb7484fa1b1ff6.zip llvm-adff3ae3c8e9f3c2bf5caae0d1cb7484fa1b1ff6.tar.gz llvm-adff3ae3c8e9f3c2bf5caae0d1cb7484fa1b1ff6.tar.bz2 |
[libclang] Introduce clang_Type_getCXXRefQualifier whichexposes ref-qualifier information of function type.
Patch by Che-Liang Chiou!
llvm-svn: 192493
Diffstat (limited to 'clang/tools')
-rw-r--r-- | clang/tools/c-index-test/c-index-test.c | 5 | ||||
-rw-r--r-- | clang/tools/libclang/CXType.cpp | 18 | ||||
-rw-r--r-- | clang/tools/libclang/libclang.exports | 1 |
3 files changed, 24 insertions, 0 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index 2e8b58b..90a6528 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/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/clang/tools/libclang/CXType.cpp b/clang/tools/libclang/CXType.cpp index 9233e97..1e2cb18 100644 --- a/clang/tools/libclang/CXType.cpp +++ b/clang/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/clang/tools/libclang/libclang.exports b/clang/tools/libclang/libclang.exports index 6f6e392..9bf26c9 100644 --- a/clang/tools/libclang/libclang.exports +++ b/clang/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 |