Add libclang functions to determine the const/volatile/restrict
qualifiers on a CXType. Patch from Stefan Seefeld, test by me.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124377 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index 7238f4a..be3a079 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -568,6 +568,12 @@
CXString S = clang_getTypeKindSpelling(T.kind);
PrintCursor(cursor);
printf(" typekind=%s", clang_getCString(S));
+ if (clang_isConstQualifiedType(T))
+ printf(" const");
+ if (clang_isVolatileQualifiedType(T))
+ printf(" volatile");
+ if (clang_isRestrictQualifiedType(T))
+ printf(" restrict");
clang_disposeString(S);
/* Print the canonical type if it is different. */
{
diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp
index 7b603c0..9332672 100644
--- a/tools/libclang/CXType.cpp
+++ b/tools/libclang/CXType.cpp
@@ -186,6 +186,21 @@
return MakeCXType(AU->getASTContext().getCanonicalType(T), TU);
}
+unsigned clang_isConstQualifiedType(CXType CT) {
+ QualType T = GetQualType(CT);
+ return T.isLocalConstQualified();
+}
+
+unsigned clang_isVolatileQualifiedType(CXType CT) {
+ QualType T = GetQualType(CT);
+ return T.isLocalVolatileQualified();
+}
+
+unsigned clang_isRestrictQualifiedType(CXType CT) {
+ QualType T = GetQualType(CT);
+ return T.isLocalRestrictQualified();
+}
+
CXType clang_getPointeeType(CXType CT) {
QualType T = GetQualType(CT);
const Type *TP = T.getTypePtrOrNull();
diff --git a/tools/libclang/libclang.darwin.exports b/tools/libclang/libclang.darwin.exports
index 1792312..7614544 100644
--- a/tools/libclang/libclang.darwin.exports
+++ b/tools/libclang/libclang.darwin.exports
@@ -109,16 +109,19 @@
_clang_getTypeKindSpelling
_clang_hashCursor
_clang_isCursorDefinition
+_clang_isConstQualifiedType
_clang_isDeclaration
_clang_isExpression
_clang_isInvalid
_clang_isPODType
_clang_isPreprocessing
_clang_isReference
+_clang_isRestrictQualifiedType
_clang_isStatement
_clang_isTranslationUnit
_clang_isUnexposed
_clang_isVirtualBase
+_clang_isVolatileQualifiedType
_clang_parseTranslationUnit
_clang_reparseTranslationUnit
_clang_saveTranslationUnit
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index c5415e3..c2f0587 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -108,6 +108,7 @@
clang_getTypeDeclaration
clang_getTypeKindSpelling
clang_hashCursor
+clang_isConstQualifiedType
clang_isCursorDefinition
clang_isDeclaration
clang_isExpression
@@ -115,10 +116,12 @@
clang_isPODType
clang_isPreprocessing
clang_isReference
+clang_isRestrictQualifiedType
clang_isStatement
clang_isTranslationUnit
clang_isUnexposed
clang_isVirtualBase
+clang_isVolatileQualifiedType
clang_parseTranslationUnit
clang_reparseTranslationUnit
clang_saveTranslationUnit