mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-14 14:56:47 +00:00
[index] Expose FriendDecl
Differential Revision: https://reviews.llvm.org/D26285 llvm-svn: 285984
This commit is contained in:
parent
6232e4d5d9
commit
d211c648b9
@ -32,7 +32,7 @@
|
||||
* compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
|
||||
*/
|
||||
#define CINDEX_VERSION_MAJOR 0
|
||||
#define CINDEX_VERSION_MINOR 35
|
||||
#define CINDEX_VERSION_MINOR 36
|
||||
|
||||
#define CINDEX_VERSION_ENCODE(major, minor) ( \
|
||||
((major) * 10000) \
|
||||
@ -2404,8 +2404,12 @@ enum CXCursorKind {
|
||||
* \brief A static_assert or _Static_assert node
|
||||
*/
|
||||
CXCursor_StaticAssert = 602,
|
||||
/**
|
||||
* \brief a friend declaration.
|
||||
*/
|
||||
CXCursor_FriendDecl = 603,
|
||||
CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
|
||||
CXCursor_LastExtraDecl = CXCursor_StaticAssert,
|
||||
CXCursor_LastExtraDecl = CXCursor_FriendDecl,
|
||||
|
||||
/**
|
||||
* \brief A code completion overload candidate.
|
||||
|
@ -3100,6 +3100,7 @@ CXCursorKind clang::getCursorKindForDecl(const Decl *D) {
|
||||
return CXCursor_ClassTemplatePartialSpecialization;
|
||||
case Decl::UsingDirective: return CXCursor_UsingDirective;
|
||||
case Decl::StaticAssert: return CXCursor_StaticAssert;
|
||||
case Decl::Friend: return CXCursor_FriendDecl;
|
||||
case Decl::TranslationUnit: return CXCursor_TranslationUnit;
|
||||
|
||||
case Decl::Using:
|
||||
|
@ -18,13 +18,18 @@ private:
|
||||
|
||||
virtual void virtualMemberFunction();
|
||||
virtual void pureVirtualMemberFunction() = 0;
|
||||
|
||||
friend void friendFunction();
|
||||
template <typename T>
|
||||
friend void friendFunctionTemplate();
|
||||
friend class F;
|
||||
};
|
||||
|
||||
X::X(int value) {
|
||||
}
|
||||
|
||||
// RUN: c-index-test -test-load-source all %s | FileCheck %s
|
||||
// CHECK: load-classes.cpp:3:8: StructDecl=X:3:8 (Definition) Extent=[3:1 - 21:2]
|
||||
// CHECK: load-classes.cpp:3:8: StructDecl=X:3:8 (Definition) Extent=[3:1 - 26:2]
|
||||
// CHECK: load-classes.cpp:4:3: CXXConstructor=X:4:3 (converting constructor) Extent=[4:3 - 4:15] [access=public]
|
||||
// FIXME: missing TypeRef in the constructor name
|
||||
// CHECK: load-classes.cpp:4:9: ParmDecl=value:4:9 (Definition) Extent=[4:5 - 4:14]
|
||||
@ -46,7 +51,14 @@ X::X(int value) {
|
||||
// CHECK: load-classes.cpp:16:21: TemplateTypeParameter=T:16:21 (Definition) Extent=[16:12 - 16:22] [access=public]
|
||||
// CHECK: load-classes.cpp:19:16: CXXMethod=virtualMemberFunction:19:16 (virtual) Extent=[19:3 - 19:39] [access=private]
|
||||
// CHECK: load-classes.cpp:20:16: CXXMethod=pureVirtualMemberFunction:20:16 (virtual) (pure) Extent=[20:3 - 20:47] [access=private]
|
||||
// CHECK: load-classes.cpp:23:4: CXXConstructor=X:23:4 (Definition) (converting constructor) Extent=[23:1 - 24:2] [access=public]
|
||||
// CHECK: load-classes.cpp:23:1: TypeRef=struct X:3:8 Extent=[23:1 - 23:2]
|
||||
// CHECK: load-classes.cpp:23:10: ParmDecl=value:23:10 (Definition) Extent=[23:6 - 23:15]
|
||||
// CHECK: load-classes.cpp:23:17: CompoundStmt= Extent=[23:17 - 24:2]
|
||||
// CHECK: load-classes.cpp:22:15: FriendDecl=:22:15 Extent=[22:3 - 22:31] [access=public]
|
||||
// CHECK: load-classes.cpp:22:15: FunctionDecl=friendFunction:22:15 Extent=[22:3 - 22:31] [access=public]
|
||||
// CHECK: load-classes.cpp:24:15: FriendDecl=:24:15 Extent=[23:3 - 24:39] [access=public]
|
||||
// CHECK: load-classes.cpp:24:15: FunctionTemplate=friendFunctionTemplate:24:15 Extent=[23:3 - 24:39] [access=public]
|
||||
// CHECK: load-classes.cpp:23:22: TemplateTypeParameter=T:23:22 (Definition) Extent=[23:13 - 23:23] [access=public]
|
||||
// CHECK: load-classes.cpp:25:10: FriendDecl=:25:10 Extent=[25:3 - 25:17] [access=public]
|
||||
// CHECK: load-classes.cpp:25:16: TypeRef=class F:25:16 Extent=[25:16 - 25:17]
|
||||
// CHECK: load-classes.cpp:28:4: CXXConstructor=X:28:4 (Definition) (converting constructor) Extent=[28:1 - 29:2] [access=public]
|
||||
// CHECK: load-classes.cpp:28:1: TypeRef=struct X:3:8 Extent=[28:1 - 28:2]
|
||||
// CHECK: load-classes.cpp:28:10: ParmDecl=value:28:10 (Definition) Extent=[28:6 - 28:15]
|
||||
// CHECK: load-classes.cpp:28:17: CompoundStmt= Extent=[28:17 - 29:2]
|
||||
|
@ -1249,6 +1249,17 @@ bool CursorVisitor::VisitStaticAssertDecl(StaticAssertDecl *D) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CursorVisitor::VisitFriendDecl(FriendDecl *D) {
|
||||
if (NamedDecl *FriendD = D->getFriendDecl()) {
|
||||
if (Visit(MakeCXCursor(FriendD, TU, RegionOfInterest)))
|
||||
return true;
|
||||
} else if (TypeSourceInfo *TI = D->getFriendType()) {
|
||||
if (Visit(TI->getTypeLoc()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {
|
||||
switch (Name.getName().getNameKind()) {
|
||||
case clang::DeclarationName::Identifier:
|
||||
@ -4923,6 +4934,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
|
||||
return cxstring::createRef("TypeAliasTemplateDecl");
|
||||
case CXCursor_StaticAssert:
|
||||
return cxstring::createRef("StaticAssert");
|
||||
case CXCursor_FriendDecl:
|
||||
return cxstring::createRef("FriendDecl");
|
||||
}
|
||||
|
||||
llvm_unreachable("Unhandled CXCursorKind");
|
||||
|
@ -239,7 +239,8 @@ public:
|
||||
bool VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
|
||||
bool VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
|
||||
bool VisitStaticAssertDecl(StaticAssertDecl *D);
|
||||
|
||||
bool VisitFriendDecl(FriendDecl *D);
|
||||
|
||||
// Name visitor
|
||||
bool VisitDeclarationNameInfo(DeclarationNameInfo Name);
|
||||
bool VisitNestedNameSpecifier(NestedNameSpecifier *NNS, SourceRange Range);
|
||||
|
Loading…
x
Reference in New Issue
Block a user