Changeset View
Changeset View
Standalone View
Standalone View
plugins/clang/duchain/builder.cpp
Show First 20 Lines • Show All 1026 Lines • ▼ Show 20 Line(s) | 1026 | if (CK == CXCursor_VarDecl) | |||
---|---|---|---|---|---|
1027 | decl->setStatic(true); | 1027 | decl->setStatic(true); | ||
1028 | decl->setAccessPolicy(CursorKindTraits::kdevAccessPolicy(clang_getCXXAccessSpecifier(cursor))); | 1028 | decl->setAccessPolicy(CursorKindTraits::kdevAccessPolicy(clang_getCXXAccessSpecifier(cursor))); | ||
1029 | 1029 | | |||
1030 | #if CINDEX_VERSION_MINOR >= 32 | 1030 | #if CINDEX_VERSION_MINOR >= 32 | ||
1031 | decl->setMutable(clang_CXXField_isMutable(cursor)); | 1031 | decl->setMutable(clang_CXXField_isMutable(cursor)); | ||
1032 | #endif | 1032 | #endif | ||
1033 | 1033 | | |||
1034 | #if CINDEX_VERSION_MINOR >= 30 | 1034 | #if CINDEX_VERSION_MINOR >= 30 | ||
1035 | if (!jsonTestRun()) { | | |||
1036 | auto offset = clang_Cursor_getOffsetOfField(cursor); | 1035 | auto offset = clang_Cursor_getOffsetOfField(cursor); | ||
1037 | if (offset >= 0) { // don't add this info to the json tests, it invalidates the comment structure | 1036 | if (offset >= 0) { // don't add this info to the json tests, it invalidates the comment structure | ||
1038 | auto type = clang_getCursorType(cursor); | 1037 | auto type = clang_getCursorType(cursor); | ||
1039 | auto sizeOf = clang_Type_getSizeOf(type); | 1038 | auto sizeOf = clang_Type_getSizeOf(type); | ||
1040 | auto alignedTo = clang_Type_getAlignOf(type); | 1039 | auto alignOf = clang_Type_getAlignOf(type); | ||
1041 | const auto byteOffset = offset / 8; | 1040 | | ||
1042 | const auto bitOffset = offset % 8; | 1041 | if (sizeOf >= 0) | ||
1043 | const QString byteOffsetStr = i18np("1 Byte", "%1 Bytes", byteOffset); | 1042 | decl->setSizeOf(sizeOf); | ||
1044 | const QString bitOffsetStr = bitOffset ? i18np("1 Bit", "%1 Bits", bitOffset) : QString(); | 1043 | if (offset >= 0) | ||
1045 | const QString offsetStr = bitOffset ? i18nc("%1: bytes, %2: bits", "%1, %2", byteOffsetStr, bitOffsetStr) : byteOffsetStr; | 1044 | decl->setBitOffsetOf(offset); | ||
1046 | 1045 | if (alignOf >= 0) | |||
1047 | decl->setComment(decl->comment() | 1046 | decl->setAlignOf(alignOf); | ||
1048 | + i18n("<p>offset in parent: %1; " | | |||
1049 | "size: %2 Bytes; " | | |||
1050 | "aligned to: %3 Bytes</p>", offsetStr, sizeOf, alignedTo).toUtf8()); | | |||
1051 | } | | |||
1052 | } | 1047 | } | ||
1053 | #endif | 1048 | #endif | ||
1054 | } | 1049 | } | ||
1055 | 1050 | | |||
1056 | template<CXCursorKind CK, EnableIf<CursorKindTraits::isClassTemplate(CK)>> | 1051 | template<CXCursorKind CK, EnableIf<CursorKindTraits::isClassTemplate(CK)>> | ||
1057 | void Visitor::setDeclData(CXCursor cursor, ClassDeclaration* decl) const | 1052 | void Visitor::setDeclData(CXCursor cursor, ClassDeclaration* decl) const | ||
1058 | { | 1053 | { | ||
1059 | CXCursorKind kind = clang_getTemplateCursorKind(cursor); | 1054 | CXCursorKind kind = clang_getTemplateCursorKind(cursor); | ||
Show All 14 Lines | 1065 | { | |||
1074 | setDeclData<CK>(cursor, static_cast<ClassMemberDeclaration*>(decl)); | 1069 | setDeclData<CK>(cursor, static_cast<ClassMemberDeclaration*>(decl)); | ||
1075 | if (CK == CXCursor_UnionDecl) | 1070 | if (CK == CXCursor_UnionDecl) | ||
1076 | decl->setClassType(ClassDeclarationData::Union); | 1071 | decl->setClassType(ClassDeclarationData::Union); | ||
1077 | if (CK == CXCursor_StructDecl) | 1072 | if (CK == CXCursor_StructDecl) | ||
1078 | decl->setClassType(ClassDeclarationData::Struct); | 1073 | decl->setClassType(ClassDeclarationData::Struct); | ||
1079 | if (clang_isCursorDefinition(cursor)) { | 1074 | if (clang_isCursorDefinition(cursor)) { | ||
1080 | decl->setDeclarationIsDefinition(true); | 1075 | decl->setDeclarationIsDefinition(true); | ||
1081 | } | 1076 | } | ||
1082 | if (!jsonTestRun()) { // don't add this info to the json tests, it invalidates the comment structure | 1077 | | ||
1078 | #if CINDEX_VERSION_MINOR >= 30 | ||||
1083 | auto type = clang_getCursorType(cursor); | 1079 | auto type = clang_getCursorType(cursor); | ||
1084 | auto sizeOf = clang_Type_getSizeOf(type); | 1080 | auto sizeOf = clang_Type_getSizeOf(type); | ||
1085 | auto alignOf = clang_Type_getAlignOf(type); | 1081 | auto alignOf = clang_Type_getAlignOf(type); | ||
1086 | if (sizeOf >= 0 && alignOf >= 0) { | 1082 | | ||
1087 | decl->setComment(decl->comment() | 1083 | if (sizeOf >= 0) | ||
1088 | + i18n("<p>size: %1 Bytes; " | 1084 | decl->setSizeOf(sizeOf); | ||
1089 | "aligned to: %2 Bytes</p>", sizeOf, alignOf).toUtf8()); | 1085 | if (alignOf >= 0) | ||
1090 | } | 1086 | decl->setAlignOf(alignOf); | ||
1091 | } | 1087 | #endif | ||
1092 | } | 1088 | } | ||
1093 | 1089 | | |||
1094 | template<CXCursorKind CK> | 1090 | template<CXCursorKind CK> | ||
1095 | void Visitor::setDeclData(CXCursor cursor, AbstractFunctionDeclaration* decl) const | 1091 | void Visitor::setDeclData(CXCursor cursor, AbstractFunctionDeclaration* decl) const | ||
1096 | { | 1092 | { | ||
1097 | if (m_update) { | 1093 | if (m_update) { | ||
1098 | decl->clearDefaultParameters(); | 1094 | decl->clearDefaultParameters(); | ||
1099 | } | 1095 | } | ||
▲ Show 20 Lines • Show All 491 Lines • Show Last 20 Lines |