This revision was automatically updated to reflect the committed changes.
Closed by commit rC338808: [libclang 3/8] Add support for AttributedType
(authored by mwu, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D49081?vs=154609&id=158909#toc
Repository:
rC Clang
https://reviews.llvm.org/D49081
Files:
include/clang-c/Index.h
tools/libclang/CXType.cpp
tools/libclang/libclang.exports
Index: include/clang-c/Index.h
===================================================================
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -1331,7 +1331,12 @@
*
* The function bodies of the main file are not skipped.
*/
- CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800
+ CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800,
+
+ /**
+ * Used to indicate that attributed types should be included in CXType.
+ */
+ CXTranslationUnit_IncludeAttributedTypes = 0x1000
};
/**
@@ -3268,7 +3273,8 @@
CXType_OCLReserveID = 160,
CXType_ObjCObject = 161,
- CXType_ObjCTypeParam = 162
+ CXType_ObjCTypeParam = 162,
+ CXType_Attributed = 163
};
/**
@@ -3818,6 +3824,13 @@
CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
/**
+ * Return the type that was modified by this attributed type.
+ *
+ * If the type is not an attributed type, an invalid type is returned.
+ */
+CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);
+
+/**
* Return the offset of the field represented by the Cursor.
*
* If the cursor is not a field declaration, -1 is returned.
Index: tools/libclang/libclang.exports
===================================================================
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -103,6 +103,7 @@
clang_Type_getObjCProtocolDecl
clang_Type_getNumObjCTypeArgs
clang_Type_getObjCTypeArg
+clang_Type_getModifiedType
clang_VerbatimBlockLineComment_getText
clang_VerbatimLineComment_getText
clang_HTMLTagComment_getAsString
Index: tools/libclang/CXType.cpp
===================================================================
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -112,6 +112,7 @@
TKCASE(Auto);
TKCASE(Elaborated);
TKCASE(Pipe);
+ TKCASE(Attributed);
default:
return CXType_Unexposed;
}
@@ -125,7 +126,9 @@
if (TU && !T.isNull()) {
// Handle attributed types as the original type
if (auto *ATT = T->getAs<AttributedType>()) {
- return MakeCXType(ATT->getModifiedType(), TU);
+ if (!(TU->ParsingOptions & CXTranslationUnit_IncludeAttributedTypes)) {
+ return MakeCXType(ATT->getModifiedType(), TU);
+ }
}
// Handle paren types as the original type
if (auto *PTT = T->getAs<ParenType>()) {
@@ -591,6 +594,7 @@
TKIND(Auto);
TKIND(Elaborated);
TKIND(Pipe);
+ TKIND(Attributed);
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) TKIND(Id);
#include "clang/Basic/OpenCLImageTypes.def"
#undef IMAGE_TYPE
@@ -996,6 +1000,17 @@
return CXTypeLayoutError_InvalidFieldName;
}
+CXType clang_Type_getModifiedType(CXType CT) {
+ QualType T = GetQualType(CT);
+ if (T.isNull())
+ return MakeCXType(QualType(), GetTU(CT));
+
+ if (auto *ATT = T->getAs<AttributedType>())
+ return MakeCXType(ATT->getModifiedType(), GetTU(CT));
+
+ return MakeCXType(QualType(), GetTU(CT));
+}
+
long long clang_Cursor_getOffsetOfField(CXCursor C) {
if (clang_isDeclaration(C.kind)) {
// we need to validate the parent type
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits