You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

216 lines
6.6 KiB
Diff

diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index c51dfb1598b..e99ffcbaabb 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -3665,6 +3665,22 @@ CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
*/
CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
+/**
+ * \brief Return 1 if the CXType is a final class type, and 0 otherwise.
+ */
+CINDEX_LINKAGE unsigned clang_isFinalType(CXType T);
+
+/**
+ * \bried Return 1 if the CXType is an abstract class type, and 0 otherwise.
+ */
+CINDEX_LINKAGE unsigned clang_isAbstractType(CXType T);
+
+/**
+ * \brief Return 1 if the CXType is a noexcept C++ function or method pointer,
+ * and 0 otherwise.
+ */
+CINDEX_LINKAGE unsigned clang_isNoexcept(CXType C);
+
/**
* Retrieve the type of a parameter of a function type.
*
@@ -4547,6 +4563,12 @@ CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
*/
CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
+/**
+ * \brief Determine if a C++ function or method has been deleted with
+ * '= delete'.
+ */
+CINDEX_LINKAGE unsigned clang_CXX_isDeleted(CXCursor C);
+
/**
* @}
*/
@@ -4605,6 +4627,12 @@ CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
*/
CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
+/**
+ * \brief Determine if a C++ member function or member function template method
+ * overrides a virtual method from one of the base classes.
+ */
+CINDEX_LINKAGE unsigned clang_CXXMethod_isOverride(CXCursor C);
+
/**
* \param Module a module object.
*
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index b792db2852a..96a0a88060d 100644
--- a/include/clang/Basic/Attr.td
+++ b/include/clang/Basic/Attr.td
@@ -669,6 +669,7 @@ def Annotate : InheritableParamAttr {
// '#pragma clang attribute' even though it has no subject list.
let PragmaAttributeSupport = 1;
let Documentation = [Undocumented];
+ let InheritEvenIfAlreadyPresent = 1;
}
def ARMInterrupt : InheritableAttr, TargetSpecificAttr<TargetARM> {
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index a9c3077e5fa..eb6e17bb254 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -710,12 +710,12 @@ bool CursorVisitor::VisitClassTemplateSpecializationDecl(
case TSK_Undeclared:
case TSK_ImplicitInstantiation:
// Nothing to visit
- return false;
-
+ // return false;
+
case TSK_ExplicitInstantiationDeclaration:
case TSK_ExplicitInstantiationDefinition:
- break;
-
+ // break;
+
case TSK_ExplicitSpecialization:
ShouldVisitBody = true;
break;
@@ -940,9 +940,16 @@ bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) {
// before visiting these template parameters.
if (VisitTemplateParameters(D->getTemplateParameters()))
return true;
-
+
auto* CD = D->getTemplatedDecl();
- return VisitAttributes(CD) || VisitCXXRecordDecl(CD);
+ if (VisitAttributes(CD) || VisitCXXRecordDecl(CD))
+ return true;
+
+ for (auto DIt = D->spec_begin(), DE = D->spec_end(); DIt != DE; ++DIt)
+ if (Visit(MakeCXCursor(*DIt, TU)))
+ return true;
+
+ return false;
}
bool CursorVisitor::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
@@ -8293,6 +8300,15 @@ CXFile clang_Module_getTopLevelHeader(CXTranslationUnit TU,
// C++ AST instrospection.
//===----------------------------------------------------------------------===//
+unsigned clang_CXX_isDeleted(CXCursor C) {
+ if (!clang_isDeclaration(C.kind))
+ return 0;
+
+ const Decl *D = cxcursor::getCursorDecl(C);
+ const FunctionDecl *Function = D->getAsFunction();
+ return (Function && Function->isDeleted()) ? 1 : 0;
+}
+
unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C) {
if (!clang_isDeclaration(C.kind))
return 0;
@@ -8414,6 +8430,16 @@ unsigned clang_EnumDecl_isScoped(CXCursor C) {
return (Enum && Enum->isScoped()) ? 1 : 0;
}
+unsigned clang_CXXMethod_isOverride(CXCursor C) {
+ if (!clang_isDeclaration(C.kind))
+ return 0;
+
+ const Decl *D = cxcursor::getCursorDecl(C);
+ const CXXMethodDecl *Method =
+ D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : nullptr;
+ return (Method && Method->size_overridden_methods()) ? 1 : 0;
+}
+
//===----------------------------------------------------------------------===//
// Attribute introspection.
//===----------------------------------------------------------------------===//
diff --git a/clang/tools/libclang/CXType.cpp b/clang/tools/libclang/CXType.cpp
index b8009ddc1c1..3cda0f983b5 100644
--- a/tools/libclang/CXType.cpp
+++ b/tools/libclang/CXType.cpp
@@ -781,6 +781,42 @@ unsigned clang_isPODType(CXType X) {
return T.isPODType(cxtu::getASTUnit(TU)->getASTContext()) ? 1 : 0;
}
+unsigned clang_isFinalType(CXType X) {
+ QualType T = GetQualType(X);
+ if (T.isNull())
+ return 0;
+
+ const CXXRecordDecl *RecordDecl = T->getAsCXXRecordDecl();
+ if (!RecordDecl)
+ return 0;
+
+ return RecordDecl->getAttr<FinalAttr>() ? 1 : 0;
+}
+
+unsigned clang_isAbstractType(CXType X) {
+ QualType T = GetQualType(X);
+ if (T.isNull())
+ return 0;
+
+ const CXXRecordDecl *RecordDecl = T->getAsCXXRecordDecl();
+ if (!RecordDecl)
+ return 0;
+
+ return RecordDecl->isAbstract() ? 1 : 0;
+}
+
+unsigned clang_isNoexcept(CXType X) {
+ QualType T = GetQualType(X);
+ if (T.isNull())
+ return 0;
+
+ const FunctionProtoType *Proto = T->getAs<FunctionProtoType>();
+ if (!Proto)
+ return 0;
+
+ return Proto->hasNoexceptExceptionSpec() ? 1 : 0;
+}
+
CXType clang_getElementType(CXType CT) {
QualType ET = QualType();
QualType T = GetQualType(CT);
diff --git a/clang/tools/libclang/libclang.exports b/clang/tools/libclang/libclang.exports
index 2c4b083a594..61dcf984ab5 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -3,6 +3,7 @@ clang_CXCursorSet_insert
clang_CXIndex_getGlobalOptions
clang_CXIndex_setGlobalOptions
clang_CXIndex_setInvocationEmissionPathOption
+clang_CXX_isDeleted
clang_CXXConstructor_isConvertingConstructor
clang_CXXConstructor_isCopyConstructor
clang_CXXConstructor_isDefaultConstructor
@@ -14,6 +15,7 @@ clang_CXXMethod_isPureVirtual
clang_CXXMethod_isStatic
clang_CXXMethod_isVirtual
clang_CXXRecord_isAbstract
+clang_CXXMethod_isOverride
clang_EnumDecl_isScoped
clang_Cursor_getArgument
clang_Cursor_getNumTemplateArguments
@@ -312,6 +314,9 @@ clang_isFileMultipleIncludeGuarded
clang_isFunctionTypeVariadic
clang_isInvalid
clang_isPODType
+clang_isFinalType
+clang_isAbstractType
+clang_isNoexcept
clang_isPreprocessing
clang_isReference
clang_isRestrictQualifiedType