clang-8.0-u3.patch (6773B)
1 diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h 2 index c51dfb1598b..e99ffcbaabb 100644 3 --- a/include/clang-c/Index.h 4 +++ b/include/clang-c/Index.h 5 @@ -3665,6 +3665,22 @@ CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T); 6 */ 7 CINDEX_LINKAGE int clang_getNumArgTypes(CXType T); 8 9 +/** 10 + * \brief Return 1 if the CXType is a final class type, and 0 otherwise. 11 + */ 12 +CINDEX_LINKAGE unsigned clang_isFinalType(CXType T); 13 + 14 +/** 15 + * \bried Return 1 if the CXType is an abstract class type, and 0 otherwise. 16 + */ 17 +CINDEX_LINKAGE unsigned clang_isAbstractType(CXType T); 18 + 19 +/** 20 + * \brief Return 1 if the CXType is a noexcept C++ function or method pointer, 21 + * and 0 otherwise. 22 + */ 23 +CINDEX_LINKAGE unsigned clang_isNoexcept(CXType C); 24 + 25 /** 26 * Retrieve the type of a parameter of a function type. 27 * 28 @@ -4547,6 +4563,12 @@ CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C); 29 */ 30 CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C); 31 32 +/** 33 + * \brief Determine if a C++ function or method has been deleted with 34 + * '= delete'. 35 + */ 36 +CINDEX_LINKAGE unsigned clang_CXX_isDeleted(CXCursor C); 37 + 38 /** 39 * @} 40 */ 41 @@ -4605,6 +4627,12 @@ CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile); 42 */ 43 CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module); 44 45 +/** 46 + * \brief Determine if a C++ member function or member function template method 47 + * overrides a virtual method from one of the base classes. 48 + */ 49 +CINDEX_LINKAGE unsigned clang_CXXMethod_isOverride(CXCursor C); 50 + 51 /** 52 * \param Module a module object. 53 * 54 diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td 55 index b792db2852a..96a0a88060d 100644 56 --- a/include/clang/Basic/Attr.td 57 +++ b/include/clang/Basic/Attr.td 58 @@ -669,6 +669,7 @@ def Annotate : InheritableParamAttr { 59 // '#pragma clang attribute' even though it has no subject list. 60 let PragmaAttributeSupport = 1; 61 let Documentation = [Undocumented]; 62 + let InheritEvenIfAlreadyPresent = 1; 63 } 64 65 def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> { 66 diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp 67 index a9c3077e5fa..eb6e17bb254 100644 68 --- a/tools/libclang/CIndex.cpp 69 +++ b/tools/libclang/CIndex.cpp 70 @@ -710,12 +710,12 @@ bool CursorVisitor::VisitClassTemplateSpecializationDecl( 71 case TSK_Undeclared: 72 case TSK_ImplicitInstantiation: 73 // Nothing to visit 74 - return false; 75 - 76 + // return false; 77 + 78 case TSK_ExplicitInstantiationDeclaration: 79 case TSK_ExplicitInstantiationDefinition: 80 - break; 81 - 82 + // break; 83 + 84 case TSK_ExplicitSpecialization: 85 ShouldVisitBody = true; 86 break; 87 @@ -940,9 +940,16 @@ bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) { 88 // before visiting these template parameters. 89 if (VisitTemplateParameters(D->getTemplateParameters())) 90 return true; 91 - 92 + 93 auto* CD = D->getTemplatedDecl(); 94 - return VisitAttributes(CD) || VisitCXXRecordDecl(CD); 95 + if (VisitAttributes(CD) || VisitCXXRecordDecl(CD)) 96 + return true; 97 + 98 + for (auto DIt = D->spec_begin(), DE = D->spec_end(); DIt != DE; ++DIt) 99 + if (Visit(MakeCXCursor(*DIt, TU))) 100 + return true; 101 + 102 + return false; 103 } 104 105 bool CursorVisitor::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { 106 @@ -8293,6 +8300,15 @@ CXFile clang_Module_getTopLevelHeader(CXTranslationUnit TU, 107 // C++ AST instrospection. 108 //===----------------------------------------------------------------------===// 109 110 +unsigned clang_CXX_isDeleted(CXCursor C) { 111 + if (!clang_isDeclaration(C.kind)) 112 + return 0; 113 + 114 + const Decl *D = cxcursor::getCursorDecl(C); 115 + const FunctionDecl *Function = D->getAsFunction(); 116 + return (Function && Function->isDeleted()) ? 1 : 0; 117 +} 118 + 119 unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C) { 120 if (!clang_isDeclaration(C.kind)) 121 return 0; 122 @@ -8414,6 +8430,16 @@ unsigned clang_EnumDecl_isScoped(CXCursor C) { 123 return (Enum && Enum->isScoped()) ? 1 : 0; 124 } 125 126 +unsigned clang_CXXMethod_isOverride(CXCursor C) { 127 + if (!clang_isDeclaration(C.kind)) 128 + return 0; 129 + 130 + const Decl *D = cxcursor::getCursorDecl(C); 131 + const CXXMethodDecl *Method = 132 + D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : nullptr; 133 + return (Method && Method->size_overridden_methods()) ? 1 : 0; 134 +} 135 + 136 //===----------------------------------------------------------------------===// 137 // Attribute introspection. 138 //===----------------------------------------------------------------------===// 139 diff --git a/clang/tools/libclang/CXType.cpp b/clang/tools/libclang/CXType.cpp 140 index b8009ddc1c1..3cda0f983b5 100644 141 --- a/tools/libclang/CXType.cpp 142 +++ b/tools/libclang/CXType.cpp 143 @@ -781,6 +781,42 @@ unsigned clang_isPODType(CXType X) { 144 return T.isPODType(cxtu::getASTUnit(TU)->getASTContext()) ? 1 : 0; 145 } 146 147 +unsigned clang_isFinalType(CXType X) { 148 + QualType T = GetQualType(X); 149 + if (T.isNull()) 150 + return 0; 151 + 152 + const CXXRecordDecl *RecordDecl = T->getAsCXXRecordDecl(); 153 + if (!RecordDecl) 154 + return 0; 155 + 156 + return RecordDecl->getAttr<FinalAttr>() ? 1 : 0; 157 +} 158 + 159 +unsigned clang_isAbstractType(CXType X) { 160 + QualType T = GetQualType(X); 161 + if (T.isNull()) 162 + return 0; 163 + 164 + const CXXRecordDecl *RecordDecl = T->getAsCXXRecordDecl(); 165 + if (!RecordDecl) 166 + return 0; 167 + 168 + return RecordDecl->isAbstract() ? 1 : 0; 169 +} 170 + 171 +unsigned clang_isNoexcept(CXType X) { 172 + QualType T = GetQualType(X); 173 + if (T.isNull()) 174 + return 0; 175 + 176 + const FunctionProtoType *Proto = T->getAs<FunctionProtoType>(); 177 + if (!Proto) 178 + return 0; 179 + 180 + return Proto->hasNoexceptExceptionSpec() ? 1 : 0; 181 +} 182 + 183 CXType clang_getElementType(CXType CT) { 184 QualType ET = QualType(); 185 QualType T = GetQualType(CT); 186 diff --git a/clang/tools/libclang/libclang.exports b/clang/tools/libclang/libclang.exports 187 index 2c4b083a594..61dcf984ab5 100644 188 --- a/tools/libclang/libclang.exports 189 +++ b/tools/libclang/libclang.exports 190 @@ -3,6 +3,7 @@ clang_CXCursorSet_insert 191 clang_CXIndex_getGlobalOptions 192 clang_CXIndex_setGlobalOptions 193 clang_CXIndex_setInvocationEmissionPathOption 194 +clang_CXX_isDeleted 195 clang_CXXConstructor_isConvertingConstructor 196 clang_CXXConstructor_isCopyConstructor 197 clang_CXXConstructor_isDefaultConstructor 198 @@ -14,6 +15,7 @@ clang_CXXMethod_isPureVirtual 199 clang_CXXMethod_isStatic 200 clang_CXXMethod_isVirtual 201 clang_CXXRecord_isAbstract 202 +clang_CXXMethod_isOverride 203 clang_EnumDecl_isScoped 204 clang_Cursor_getArgument 205 clang_Cursor_getNumTemplateArguments 206 @@ -312,6 +314,9 @@ clang_isFileMultipleIncludeGuarded 207 clang_isFunctionTypeVariadic 208 clang_isInvalid 209 clang_isPODType 210 +clang_isFinalType 211 +clang_isAbstractType 212 +clang_isNoexcept 213 clang_isPreprocessing 214 clang_isReference 215 clang_isRestrictQualifiedType