forked from OSchip/llvm-project
libclang: change return type of getCursorDecl() to 'const Decl *'
llvm-svn: 173278
This commit is contained in:
parent
fe0483dbea
commit
d15bb30dba
|
|
@ -165,7 +165,7 @@ bool CursorVisitor::Visit(CXCursor Cursor, bool CheckedRegionOfInterest) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (clang_isDeclaration(Cursor.kind)) {
|
if (clang_isDeclaration(Cursor.kind)) {
|
||||||
Decl *D = getCursorDecl(Cursor);
|
const Decl *D = getCursorDecl(Cursor);
|
||||||
if (!D) {
|
if (!D) {
|
||||||
assert(0 && "Invalid declaration cursor");
|
assert(0 && "Invalid declaration cursor");
|
||||||
return true; // abort.
|
return true; // abort.
|
||||||
|
|
@ -463,7 +463,7 @@ bool CursorVisitor::VisitChildren(CXCursor Cursor) {
|
||||||
SetParentRAII SetParent(Parent, StmtParent, Cursor);
|
SetParentRAII SetParent(Parent, StmtParent, Cursor);
|
||||||
|
|
||||||
if (clang_isDeclaration(Cursor.kind)) {
|
if (clang_isDeclaration(Cursor.kind)) {
|
||||||
Decl *D = getCursorDecl(Cursor);
|
Decl *D = const_cast<Decl *>(getCursorDecl(Cursor));
|
||||||
if (!D)
|
if (!D)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -2966,17 +2966,17 @@ unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file) {
|
||||||
// CXCursor Operations.
|
// CXCursor Operations.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
static Decl *getDeclFromExpr(Stmt *E) {
|
static const Decl *getDeclFromExpr(const Stmt *E) {
|
||||||
if (ImplicitCastExpr *CE = dyn_cast<ImplicitCastExpr>(E))
|
if (const ImplicitCastExpr *CE = dyn_cast<ImplicitCastExpr>(E))
|
||||||
return getDeclFromExpr(CE->getSubExpr());
|
return getDeclFromExpr(CE->getSubExpr());
|
||||||
|
|
||||||
if (DeclRefExpr *RefExpr = dyn_cast<DeclRefExpr>(E))
|
if (const DeclRefExpr *RefExpr = dyn_cast<DeclRefExpr>(E))
|
||||||
return RefExpr->getDecl();
|
return RefExpr->getDecl();
|
||||||
if (MemberExpr *ME = dyn_cast<MemberExpr>(E))
|
if (const MemberExpr *ME = dyn_cast<MemberExpr>(E))
|
||||||
return ME->getMemberDecl();
|
return ME->getMemberDecl();
|
||||||
if (ObjCIvarRefExpr *RE = dyn_cast<ObjCIvarRefExpr>(E))
|
if (const ObjCIvarRefExpr *RE = dyn_cast<ObjCIvarRefExpr>(E))
|
||||||
return RE->getDecl();
|
return RE->getDecl();
|
||||||
if (ObjCPropertyRefExpr *PRE = dyn_cast<ObjCPropertyRefExpr>(E)) {
|
if (const ObjCPropertyRefExpr *PRE = dyn_cast<ObjCPropertyRefExpr>(E)) {
|
||||||
if (PRE->isExplicitProperty())
|
if (PRE->isExplicitProperty())
|
||||||
return PRE->getExplicitProperty();
|
return PRE->getExplicitProperty();
|
||||||
// It could be messaging both getter and setter as in:
|
// It could be messaging both getter and setter as in:
|
||||||
|
|
@ -2987,26 +2987,26 @@ static Decl *getDeclFromExpr(Stmt *E) {
|
||||||
return PRE->getImplicitPropertySetter();
|
return PRE->getImplicitPropertySetter();
|
||||||
return PRE->getImplicitPropertyGetter();
|
return PRE->getImplicitPropertyGetter();
|
||||||
}
|
}
|
||||||
if (PseudoObjectExpr *POE = dyn_cast<PseudoObjectExpr>(E))
|
if (const PseudoObjectExpr *POE = dyn_cast<PseudoObjectExpr>(E))
|
||||||
return getDeclFromExpr(POE->getSyntacticForm());
|
return getDeclFromExpr(POE->getSyntacticForm());
|
||||||
if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(E))
|
if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(E))
|
||||||
if (Expr *Src = OVE->getSourceExpr())
|
if (Expr *Src = OVE->getSourceExpr())
|
||||||
return getDeclFromExpr(Src);
|
return getDeclFromExpr(Src);
|
||||||
|
|
||||||
if (CallExpr *CE = dyn_cast<CallExpr>(E))
|
if (const CallExpr *CE = dyn_cast<CallExpr>(E))
|
||||||
return getDeclFromExpr(CE->getCallee());
|
return getDeclFromExpr(CE->getCallee());
|
||||||
if (CXXConstructExpr *CE = dyn_cast<CXXConstructExpr>(E))
|
if (const CXXConstructExpr *CE = dyn_cast<CXXConstructExpr>(E))
|
||||||
if (!CE->isElidable())
|
if (!CE->isElidable())
|
||||||
return CE->getConstructor();
|
return CE->getConstructor();
|
||||||
if (ObjCMessageExpr *OME = dyn_cast<ObjCMessageExpr>(E))
|
if (const ObjCMessageExpr *OME = dyn_cast<ObjCMessageExpr>(E))
|
||||||
return OME->getMethodDecl();
|
return OME->getMethodDecl();
|
||||||
|
|
||||||
if (ObjCProtocolExpr *PE = dyn_cast<ObjCProtocolExpr>(E))
|
if (const ObjCProtocolExpr *PE = dyn_cast<ObjCProtocolExpr>(E))
|
||||||
return PE->getProtocol();
|
return PE->getProtocol();
|
||||||
if (SubstNonTypeTemplateParmPackExpr *NTTP
|
if (const SubstNonTypeTemplateParmPackExpr *NTTP
|
||||||
= dyn_cast<SubstNonTypeTemplateParmPackExpr>(E))
|
= dyn_cast<SubstNonTypeTemplateParmPackExpr>(E))
|
||||||
return NTTP->getParameterPack();
|
return NTTP->getParameterPack();
|
||||||
if (SizeOfPackExpr *SizeOfPack = dyn_cast<SizeOfPackExpr>(E))
|
if (const SizeOfPackExpr *SizeOfPack = dyn_cast<SizeOfPackExpr>(E))
|
||||||
if (isa<NonTypeTemplateParmDecl>(SizeOfPack->getPack()) ||
|
if (isa<NonTypeTemplateParmDecl>(SizeOfPack->getPack()) ||
|
||||||
isa<ParmVarDecl>(SizeOfPack->getPack()))
|
isa<ParmVarDecl>(SizeOfPack->getPack()))
|
||||||
return SizeOfPack->getPack();
|
return SizeOfPack->getPack();
|
||||||
|
|
@ -3081,27 +3081,28 @@ unsigned clang_visitChildrenWithBlock(CXCursor parent,
|
||||||
return clang_visitChildren(parent, visitWithBlock, block);
|
return clang_visitChildren(parent, visitWithBlock, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CXString getDeclSpelling(Decl *D) {
|
static CXString getDeclSpelling(const Decl *D) {
|
||||||
if (!D)
|
if (!D)
|
||||||
return createCXString("");
|
return createCXString("");
|
||||||
|
|
||||||
NamedDecl *ND = dyn_cast<NamedDecl>(D);
|
const NamedDecl *ND = dyn_cast<NamedDecl>(D);
|
||||||
if (!ND) {
|
if (!ND) {
|
||||||
if (ObjCPropertyImplDecl *PropImpl =dyn_cast<ObjCPropertyImplDecl>(D))
|
if (const ObjCPropertyImplDecl *PropImpl =
|
||||||
|
dyn_cast<ObjCPropertyImplDecl>(D))
|
||||||
if (ObjCPropertyDecl *Property = PropImpl->getPropertyDecl())
|
if (ObjCPropertyDecl *Property = PropImpl->getPropertyDecl())
|
||||||
return createCXString(Property->getIdentifier()->getName());
|
return createCXString(Property->getIdentifier()->getName());
|
||||||
|
|
||||||
if (ImportDecl *ImportD = dyn_cast<ImportDecl>(D))
|
if (const ImportDecl *ImportD = dyn_cast<ImportDecl>(D))
|
||||||
if (Module *Mod = ImportD->getImportedModule())
|
if (Module *Mod = ImportD->getImportedModule())
|
||||||
return createCXString(Mod->getFullModuleName());
|
return createCXString(Mod->getFullModuleName());
|
||||||
|
|
||||||
return createCXString("");
|
return createCXString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(ND))
|
if (const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(ND))
|
||||||
return createCXString(OMD->getSelector().getAsString());
|
return createCXString(OMD->getSelector().getAsString());
|
||||||
|
|
||||||
if (ObjCCategoryImplDecl *CIMP = dyn_cast<ObjCCategoryImplDecl>(ND))
|
if (const ObjCCategoryImplDecl *CIMP = dyn_cast<ObjCCategoryImplDecl>(ND))
|
||||||
// No, this isn't the same as the code below. getIdentifier() is non-virtual
|
// No, this isn't the same as the code below. getIdentifier() is non-virtual
|
||||||
// and returns different names. NamedDecl returns the class name and
|
// and returns different names. NamedDecl returns the class name and
|
||||||
// ObjCCategoryImplDecl returns the category name.
|
// ObjCCategoryImplDecl returns the category name.
|
||||||
|
|
@ -3177,12 +3178,12 @@ CXString clang_getCursorSpelling(CXCursor C) {
|
||||||
|
|
||||||
case CXCursor_OverloadedDeclRef: {
|
case CXCursor_OverloadedDeclRef: {
|
||||||
OverloadedDeclRefStorage Storage = getCursorOverloadedDeclRef(C).first;
|
OverloadedDeclRefStorage Storage = getCursorOverloadedDeclRef(C).first;
|
||||||
if (Decl *D = Storage.dyn_cast<Decl *>()) {
|
if (const Decl *D = Storage.dyn_cast<const Decl *>()) {
|
||||||
if (NamedDecl *ND = dyn_cast<NamedDecl>(D))
|
if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
|
||||||
return createCXString(ND->getNameAsString());
|
return createCXString(ND->getNameAsString());
|
||||||
return createCXString("");
|
return createCXString("");
|
||||||
}
|
}
|
||||||
if (OverloadExpr *E = Storage.dyn_cast<OverloadExpr *>())
|
if (const OverloadExpr *E = Storage.dyn_cast<const OverloadExpr *>())
|
||||||
return createCXString(E->getName().getAsString());
|
return createCXString(E->getName().getAsString());
|
||||||
OverloadedTemplateStorage *Ovl
|
OverloadedTemplateStorage *Ovl
|
||||||
= Storage.get<OverloadedTemplateStorage*>();
|
= Storage.get<OverloadedTemplateStorage*>();
|
||||||
|
|
@ -3204,7 +3205,7 @@ CXString clang_getCursorSpelling(CXCursor C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clang_isExpression(C.kind)) {
|
if (clang_isExpression(C.kind)) {
|
||||||
Decl *D = getDeclFromExpr(getCursorExpr(C));
|
const Decl *D = getDeclFromExpr(getCursorExpr(C));
|
||||||
if (D)
|
if (D)
|
||||||
return getDeclSpelling(D);
|
return getDeclSpelling(D);
|
||||||
return createCXString("");
|
return createCXString("");
|
||||||
|
|
@ -3275,7 +3276,7 @@ CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor C,
|
||||||
|
|
||||||
if (C.kind == CXCursor_ObjCInstanceMethodDecl ||
|
if (C.kind == CXCursor_ObjCInstanceMethodDecl ||
|
||||||
C.kind == CXCursor_ObjCClassMethodDecl) {
|
C.kind == CXCursor_ObjCClassMethodDecl) {
|
||||||
if (ObjCMethodDecl *
|
if (const ObjCMethodDecl *
|
||||||
MD = dyn_cast_or_null<ObjCMethodDecl>(getCursorDecl(C))) {
|
MD = dyn_cast_or_null<ObjCMethodDecl>(getCursorDecl(C))) {
|
||||||
if (pieceIndex >= MD->getNumSelectorLocs())
|
if (pieceIndex >= MD->getNumSelectorLocs())
|
||||||
return clang_getNullRange();
|
return clang_getNullRange();
|
||||||
|
|
@ -3287,10 +3288,10 @@ CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor C,
|
||||||
C.kind == CXCursor_ObjCCategoryImplDecl) {
|
C.kind == CXCursor_ObjCCategoryImplDecl) {
|
||||||
if (pieceIndex > 0)
|
if (pieceIndex > 0)
|
||||||
return clang_getNullRange();
|
return clang_getNullRange();
|
||||||
if (ObjCCategoryDecl *
|
if (const ObjCCategoryDecl *
|
||||||
CD = dyn_cast_or_null<ObjCCategoryDecl>(getCursorDecl(C)))
|
CD = dyn_cast_or_null<ObjCCategoryDecl>(getCursorDecl(C)))
|
||||||
return cxloc::translateSourceRange(Ctx, CD->getCategoryNameLoc());
|
return cxloc::translateSourceRange(Ctx, CD->getCategoryNameLoc());
|
||||||
if (ObjCCategoryImplDecl *
|
if (const ObjCCategoryImplDecl *
|
||||||
CID = dyn_cast_or_null<ObjCCategoryImplDecl>(getCursorDecl(C)))
|
CID = dyn_cast_or_null<ObjCCategoryImplDecl>(getCursorDecl(C)))
|
||||||
return cxloc::translateSourceRange(Ctx, CID->getCategoryNameLoc());
|
return cxloc::translateSourceRange(Ctx, CID->getCategoryNameLoc());
|
||||||
}
|
}
|
||||||
|
|
@ -3298,7 +3299,8 @@ CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor C,
|
||||||
if (C.kind == CXCursor_ModuleImportDecl) {
|
if (C.kind == CXCursor_ModuleImportDecl) {
|
||||||
if (pieceIndex > 0)
|
if (pieceIndex > 0)
|
||||||
return clang_getNullRange();
|
return clang_getNullRange();
|
||||||
if (ImportDecl *ImportD = dyn_cast_or_null<ImportDecl>(getCursorDecl(C))) {
|
if (const ImportDecl *ImportD =
|
||||||
|
dyn_cast_or_null<ImportDecl>(getCursorDecl(C))) {
|
||||||
ArrayRef<SourceLocation> Locs = ImportD->getIdentifierLocs();
|
ArrayRef<SourceLocation> Locs = ImportD->getIdentifierLocs();
|
||||||
if (!Locs.empty())
|
if (!Locs.empty())
|
||||||
return cxloc::translateSourceRange(Ctx,
|
return cxloc::translateSourceRange(Ctx,
|
||||||
|
|
@ -3330,15 +3332,15 @@ CXString clang_getCursorDisplayName(CXCursor C) {
|
||||||
if (!clang_isDeclaration(C.kind))
|
if (!clang_isDeclaration(C.kind))
|
||||||
return clang_getCursorSpelling(C);
|
return clang_getCursorSpelling(C);
|
||||||
|
|
||||||
Decl *D = getCursorDecl(C);
|
const Decl *D = getCursorDecl(C);
|
||||||
if (!D)
|
if (!D)
|
||||||
return createCXString("");
|
return createCXString("");
|
||||||
|
|
||||||
PrintingPolicy Policy = getCursorContext(C).getPrintingPolicy();
|
PrintingPolicy Policy = getCursorContext(C).getPrintingPolicy();
|
||||||
if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(D))
|
if (const FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(D))
|
||||||
D = FunTmpl->getTemplatedDecl();
|
D = FunTmpl->getTemplatedDecl();
|
||||||
|
|
||||||
if (FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
|
if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
|
||||||
SmallString<64> Str;
|
SmallString<64> Str;
|
||||||
llvm::raw_svector_ostream OS(Str);
|
llvm::raw_svector_ostream OS(Str);
|
||||||
OS << *Function;
|
OS << *Function;
|
||||||
|
|
@ -3360,7 +3362,7 @@ CXString clang_getCursorDisplayName(CXCursor C) {
|
||||||
return createCXString(OS.str());
|
return createCXString(OS.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ClassTemplateDecl *ClassTemplate = dyn_cast<ClassTemplateDecl>(D)) {
|
if (const ClassTemplateDecl *ClassTemplate = dyn_cast<ClassTemplateDecl>(D)) {
|
||||||
SmallString<64> Str;
|
SmallString<64> Str;
|
||||||
llvm::raw_svector_ostream OS(Str);
|
llvm::raw_svector_ostream OS(Str);
|
||||||
OS << *ClassTemplate;
|
OS << *ClassTemplate;
|
||||||
|
|
@ -3391,7 +3393,7 @@ CXString clang_getCursorDisplayName(CXCursor C) {
|
||||||
return createCXString(OS.str());
|
return createCXString(OS.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ClassTemplateSpecializationDecl *ClassSpec
|
if (const ClassTemplateSpecializationDecl *ClassSpec
|
||||||
= dyn_cast<ClassTemplateSpecializationDecl>(D)) {
|
= dyn_cast<ClassTemplateSpecializationDecl>(D)) {
|
||||||
// If the type was explicitly written, use that.
|
// If the type was explicitly written, use that.
|
||||||
if (TypeSourceInfo *TSInfo = ClassSpec->getTypeAsWritten())
|
if (TypeSourceInfo *TSInfo = ClassSpec->getTypeAsWritten())
|
||||||
|
|
@ -3738,12 +3740,12 @@ static enum CXChildVisitResult GetCursorVisitor(CXCursor cursor,
|
||||||
|
|
||||||
if (clang_isDeclaration(cursor.kind)) {
|
if (clang_isDeclaration(cursor.kind)) {
|
||||||
// Avoid having the implicit methods override the property decls.
|
// Avoid having the implicit methods override the property decls.
|
||||||
if (ObjCMethodDecl *MD
|
if (const ObjCMethodDecl *MD
|
||||||
= dyn_cast_or_null<ObjCMethodDecl>(getCursorDecl(cursor))) {
|
= dyn_cast_or_null<ObjCMethodDecl>(getCursorDecl(cursor))) {
|
||||||
if (MD->isImplicit())
|
if (MD->isImplicit())
|
||||||
return CXChildVisit_Break;
|
return CXChildVisit_Break;
|
||||||
|
|
||||||
} else if (ObjCInterfaceDecl *ID
|
} else if (const ObjCInterfaceDecl *ID
|
||||||
= dyn_cast_or_null<ObjCInterfaceDecl>(getCursorDecl(cursor))) {
|
= dyn_cast_or_null<ObjCInterfaceDecl>(getCursorDecl(cursor))) {
|
||||||
// Check that when we have multiple @class references in the same line,
|
// Check that when we have multiple @class references in the same line,
|
||||||
// that later ones do not override the previous ones.
|
// that later ones do not override the previous ones.
|
||||||
|
|
@ -3753,7 +3755,7 @@ static enum CXChildVisitResult GetCursorVisitor(CXCursor cursor,
|
||||||
// 'Foo' even though the cursor location was at 'Foo'.
|
// 'Foo' even though the cursor location was at 'Foo'.
|
||||||
if (BestCursor->kind == CXCursor_ObjCInterfaceDecl ||
|
if (BestCursor->kind == CXCursor_ObjCInterfaceDecl ||
|
||||||
BestCursor->kind == CXCursor_ObjCClassRef)
|
BestCursor->kind == CXCursor_ObjCClassRef)
|
||||||
if (ObjCInterfaceDecl *PrevID
|
if (const ObjCInterfaceDecl *PrevID
|
||||||
= dyn_cast_or_null<ObjCInterfaceDecl>(getCursorDecl(*BestCursor))){
|
= dyn_cast_or_null<ObjCInterfaceDecl>(getCursorDecl(*BestCursor))){
|
||||||
if (PrevID != ID &&
|
if (PrevID != ID &&
|
||||||
!PrevID->isThisDeclarationADefinition() &&
|
!PrevID->isThisDeclarationADefinition() &&
|
||||||
|
|
@ -3761,7 +3763,7 @@ static enum CXChildVisitResult GetCursorVisitor(CXCursor cursor,
|
||||||
return CXChildVisit_Break;
|
return CXChildVisit_Break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (DeclaratorDecl *DD
|
} else if (const DeclaratorDecl *DD
|
||||||
= dyn_cast_or_null<DeclaratorDecl>(getCursorDecl(cursor))) {
|
= dyn_cast_or_null<DeclaratorDecl>(getCursorDecl(cursor))) {
|
||||||
SourceLocation StartLoc = DD->getSourceRange().getBegin();
|
SourceLocation StartLoc = DD->getSourceRange().getBegin();
|
||||||
// Check that when we have multiple declarators in the same line,
|
// Check that when we have multiple declarators in the same line,
|
||||||
|
|
@ -3774,7 +3776,7 @@ static enum CXChildVisitResult GetCursorVisitor(CXCursor cursor,
|
||||||
return CXChildVisit_Break;
|
return CXChildVisit_Break;
|
||||||
Data->VisitedDeclaratorDeclStartLoc = StartLoc;
|
Data->VisitedDeclaratorDeclStartLoc = StartLoc;
|
||||||
|
|
||||||
} else if (ObjCPropertyImplDecl *PropImp
|
} else if (const ObjCPropertyImplDecl *PropImp
|
||||||
= dyn_cast_or_null<ObjCPropertyImplDecl>(getCursorDecl(cursor))) {
|
= dyn_cast_or_null<ObjCPropertyImplDecl>(getCursorDecl(cursor))) {
|
||||||
(void)PropImp;
|
(void)PropImp;
|
||||||
// Check that when we have multiple @synthesize in the same line,
|
// Check that when we have multiple @synthesize in the same line,
|
||||||
|
|
@ -3791,7 +3793,7 @@ static enum CXChildVisitResult GetCursorVisitor(CXCursor cursor,
|
||||||
|
|
||||||
if (clang_isExpression(cursor.kind) &&
|
if (clang_isExpression(cursor.kind) &&
|
||||||
clang_isDeclaration(BestCursor->kind)) {
|
clang_isDeclaration(BestCursor->kind)) {
|
||||||
if (Decl *D = getCursorDecl(*BestCursor)) {
|
if (const Decl *D = getCursorDecl(*BestCursor)) {
|
||||||
// Avoid having the cursor of an expression replace the declaration cursor
|
// Avoid having the cursor of an expression replace the declaration cursor
|
||||||
// when the expression source range overlaps the declaration range.
|
// when the expression source range overlaps the declaration range.
|
||||||
// This can happen for C++ constructor expressions whose range generally
|
// This can happen for C++ constructor expressions whose range generally
|
||||||
|
|
@ -4064,7 +4066,7 @@ CXSourceLocation clang_getCursorLocation(CXCursor C) {
|
||||||
if (!clang_isDeclaration(C.kind))
|
if (!clang_isDeclaration(C.kind))
|
||||||
return clang_getNullLocation();
|
return clang_getNullLocation();
|
||||||
|
|
||||||
Decl *D = getCursorDecl(C);
|
const Decl *D = getCursorDecl(C);
|
||||||
if (!D)
|
if (!D)
|
||||||
return clang_getNullLocation();
|
return clang_getNullLocation();
|
||||||
|
|
||||||
|
|
@ -4074,13 +4076,13 @@ CXSourceLocation clang_getCursorLocation(CXCursor C) {
|
||||||
// ranges when accounting for the type-specifier. We use context
|
// ranges when accounting for the type-specifier. We use context
|
||||||
// stored in the CXCursor to determine if the VarDecl is in a DeclGroup,
|
// stored in the CXCursor to determine if the VarDecl is in a DeclGroup,
|
||||||
// and if so, whether it is the first decl.
|
// and if so, whether it is the first decl.
|
||||||
if (VarDecl *VD = dyn_cast<VarDecl>(D)) {
|
if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
|
||||||
if (!cxcursor::isFirstInDeclGroup(C))
|
if (!cxcursor::isFirstInDeclGroup(C))
|
||||||
Loc = VD->getLocation();
|
Loc = VD->getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
// For ObjC methods, give the start location of the method name.
|
// For ObjC methods, give the start location of the method name.
|
||||||
if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
|
if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
|
||||||
Loc = MD->getSelectorStartLoc();
|
Loc = MD->getSelectorStartLoc();
|
||||||
|
|
||||||
return cxloc::translateSourceLocation(getCursorContext(C), Loc);
|
return cxloc::translateSourceLocation(getCursorContext(C), Loc);
|
||||||
|
|
@ -4197,7 +4199,7 @@ static SourceRange getRawCursorExtent(CXCursor C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clang_isDeclaration(C.kind)) {
|
if (clang_isDeclaration(C.kind)) {
|
||||||
Decl *D = cxcursor::getCursorDecl(C);
|
const Decl *D = cxcursor::getCursorDecl(C);
|
||||||
if (!D)
|
if (!D)
|
||||||
return SourceRange();
|
return SourceRange();
|
||||||
|
|
||||||
|
|
@ -4207,7 +4209,7 @@ static SourceRange getRawCursorExtent(CXCursor C) {
|
||||||
// ranges when accounting for the type-specifier. We use context
|
// ranges when accounting for the type-specifier. We use context
|
||||||
// stored in the CXCursor to determine if the VarDecl is in a DeclGroup,
|
// stored in the CXCursor to determine if the VarDecl is in a DeclGroup,
|
||||||
// and if so, whether it is the first decl.
|
// and if so, whether it is the first decl.
|
||||||
if (VarDecl *VD = dyn_cast<VarDecl>(D)) {
|
if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
|
||||||
if (!cxcursor::isFirstInDeclGroup(C))
|
if (!cxcursor::isFirstInDeclGroup(C))
|
||||||
R.setBegin(VD->getLocation());
|
R.setBegin(VD->getLocation());
|
||||||
}
|
}
|
||||||
|
|
@ -4220,7 +4222,7 @@ static SourceRange getRawCursorExtent(CXCursor C) {
|
||||||
/// the decl-specifier-seq for declarations.
|
/// the decl-specifier-seq for declarations.
|
||||||
static SourceRange getFullCursorExtent(CXCursor C, SourceManager &SrcMgr) {
|
static SourceRange getFullCursorExtent(CXCursor C, SourceManager &SrcMgr) {
|
||||||
if (clang_isDeclaration(C.kind)) {
|
if (clang_isDeclaration(C.kind)) {
|
||||||
Decl *D = cxcursor::getCursorDecl(C);
|
const Decl *D = cxcursor::getCursorDecl(C);
|
||||||
if (!D)
|
if (!D)
|
||||||
return SourceRange();
|
return SourceRange();
|
||||||
|
|
||||||
|
|
@ -4232,7 +4234,7 @@ static SourceRange getFullCursorExtent(CXCursor C, SourceManager &SrcMgr) {
|
||||||
if (const DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) {
|
if (const DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) {
|
||||||
if (TypeSourceInfo *TI = DD->getTypeSourceInfo())
|
if (TypeSourceInfo *TI = DD->getTypeSourceInfo())
|
||||||
StartLoc = TI->getTypeLoc().getLocStart();
|
StartLoc = TI->getTypeLoc().getLocStart();
|
||||||
} else if (TypedefDecl *Typedef = dyn_cast<TypedefDecl>(D)) {
|
} else if (const TypedefDecl *Typedef = dyn_cast<TypedefDecl>(D)) {
|
||||||
if (TypeSourceInfo *TI = Typedef->getTypeSourceInfo())
|
if (TypeSourceInfo *TI = Typedef->getTypeSourceInfo())
|
||||||
StartLoc = TI->getTypeLoc().getLocStart();
|
StartLoc = TI->getTypeLoc().getLocStart();
|
||||||
}
|
}
|
||||||
|
|
@ -4246,7 +4248,7 @@ static SourceRange getFullCursorExtent(CXCursor C, SourceManager &SrcMgr) {
|
||||||
// ranges when accounting for the type-specifier. We use context
|
// ranges when accounting for the type-specifier. We use context
|
||||||
// stored in the CXCursor to determine if the VarDecl is in a DeclGroup,
|
// stored in the CXCursor to determine if the VarDecl is in a DeclGroup,
|
||||||
// and if so, whether it is the first decl.
|
// and if so, whether it is the first decl.
|
||||||
if (VarDecl *VD = dyn_cast<VarDecl>(D)) {
|
if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
|
||||||
if (!cxcursor::isFirstInDeclGroup(C))
|
if (!cxcursor::isFirstInDeclGroup(C))
|
||||||
R.setBegin(VD->getLocation());
|
R.setBegin(VD->getLocation());
|
||||||
}
|
}
|
||||||
|
|
@ -4273,12 +4275,13 @@ CXCursor clang_getCursorReferenced(CXCursor C) {
|
||||||
|
|
||||||
CXTranslationUnit tu = getCursorTU(C);
|
CXTranslationUnit tu = getCursorTU(C);
|
||||||
if (clang_isDeclaration(C.kind)) {
|
if (clang_isDeclaration(C.kind)) {
|
||||||
Decl *D = getCursorDecl(C);
|
const Decl *D = getCursorDecl(C);
|
||||||
if (!D)
|
if (!D)
|
||||||
return clang_getNullCursor();
|
return clang_getNullCursor();
|
||||||
if (UsingDecl *Using = dyn_cast<UsingDecl>(D))
|
if (const UsingDecl *Using = dyn_cast<UsingDecl>(D))
|
||||||
return MakeCursorOverloadedDeclRef(Using, D->getLocation(), tu);
|
return MakeCursorOverloadedDeclRef(Using, D->getLocation(), tu);
|
||||||
if (ObjCPropertyImplDecl *PropImpl =dyn_cast<ObjCPropertyImplDecl>(D))
|
if (const ObjCPropertyImplDecl *PropImpl =
|
||||||
|
dyn_cast<ObjCPropertyImplDecl>(D))
|
||||||
if (ObjCPropertyDecl *Property = PropImpl->getPropertyDecl())
|
if (ObjCPropertyDecl *Property = PropImpl->getPropertyDecl())
|
||||||
return MakeCXCursor(Property, tu);
|
return MakeCXCursor(Property, tu);
|
||||||
|
|
||||||
|
|
@ -4286,8 +4289,8 @@ CXCursor clang_getCursorReferenced(CXCursor C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clang_isExpression(C.kind)) {
|
if (clang_isExpression(C.kind)) {
|
||||||
Expr *E = getCursorExpr(C);
|
const Expr *E = getCursorExpr(C);
|
||||||
Decl *D = getDeclFromExpr(E);
|
const Decl *D = getDeclFromExpr(E);
|
||||||
if (D) {
|
if (D) {
|
||||||
CXCursor declCursor = MakeCXCursor(D, tu);
|
CXCursor declCursor = MakeCXCursor(D, tu);
|
||||||
declCursor = getSelectorIdentifierCursor(getSelectorIdentifierIndex(C),
|
declCursor = getSelectorIdentifierCursor(getSelectorIdentifierIndex(C),
|
||||||
|
|
@ -4295,7 +4298,7 @@ CXCursor clang_getCursorReferenced(CXCursor C) {
|
||||||
return declCursor;
|
return declCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OverloadExpr *Ovl = dyn_cast_or_null<OverloadExpr>(E))
|
if (const OverloadExpr *Ovl = dyn_cast_or_null<OverloadExpr>(E))
|
||||||
return MakeCursorOverloadedDeclRef(Ovl, tu);
|
return MakeCursorOverloadedDeclRef(Ovl, tu);
|
||||||
|
|
||||||
return clang_getNullCursor();
|
return clang_getNullCursor();
|
||||||
|
|
@ -4395,7 +4398,7 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
|
||||||
if (!clang_isDeclaration(C.kind))
|
if (!clang_isDeclaration(C.kind))
|
||||||
return clang_getNullCursor();
|
return clang_getNullCursor();
|
||||||
|
|
||||||
Decl *D = getCursorDecl(C);
|
const Decl *D = getCursorDecl(C);
|
||||||
if (!D)
|
if (!D)
|
||||||
return clang_getNullCursor();
|
return clang_getNullCursor();
|
||||||
|
|
||||||
|
|
@ -4468,7 +4471,7 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
|
||||||
|
|
||||||
case Decl::Var: {
|
case Decl::Var: {
|
||||||
// Ask the variable if it has a definition.
|
// Ask the variable if it has a definition.
|
||||||
if (VarDecl *Def = cast<VarDecl>(D)->getDefinition())
|
if (const VarDecl *Def = cast<VarDecl>(D)->getDefinition())
|
||||||
return MakeCXCursor(Def, TU);
|
return MakeCXCursor(Def, TU);
|
||||||
return clang_getNullCursor();
|
return clang_getNullCursor();
|
||||||
}
|
}
|
||||||
|
|
@ -4498,14 +4501,14 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
|
||||||
TU));
|
TU));
|
||||||
|
|
||||||
case Decl::ObjCMethod: {
|
case Decl::ObjCMethod: {
|
||||||
ObjCMethodDecl *Method = cast<ObjCMethodDecl>(D);
|
const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(D);
|
||||||
if (Method->isThisDeclarationADefinition())
|
if (Method->isThisDeclarationADefinition())
|
||||||
return C;
|
return C;
|
||||||
|
|
||||||
// Dig out the method definition in the associated
|
// Dig out the method definition in the associated
|
||||||
// @implementation, if we have it.
|
// @implementation, if we have it.
|
||||||
// FIXME: The ASTs should make finding the definition easier.
|
// FIXME: The ASTs should make finding the definition easier.
|
||||||
if (ObjCInterfaceDecl *Class
|
if (const ObjCInterfaceDecl *Class
|
||||||
= dyn_cast<ObjCInterfaceDecl>(Method->getDeclContext()))
|
= dyn_cast<ObjCInterfaceDecl>(Method->getDeclContext()))
|
||||||
if (ObjCImplementationDecl *ClassImpl = Class->getImplementation())
|
if (ObjCImplementationDecl *ClassImpl = Class->getImplementation())
|
||||||
if (ObjCMethodDecl *Def = ClassImpl->getMethod(Method->getSelector(),
|
if (ObjCMethodDecl *Def = ClassImpl->getMethod(Method->getSelector(),
|
||||||
|
|
@ -4523,7 +4526,7 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
|
||||||
return clang_getNullCursor();
|
return clang_getNullCursor();
|
||||||
|
|
||||||
case Decl::ObjCProtocol:
|
case Decl::ObjCProtocol:
|
||||||
if (ObjCProtocolDecl *Def = cast<ObjCProtocolDecl>(D)->getDefinition())
|
if (const ObjCProtocolDecl *Def = cast<ObjCProtocolDecl>(D)->getDefinition())
|
||||||
return MakeCXCursor(Def, TU);
|
return MakeCXCursor(Def, TU);
|
||||||
return clang_getNullCursor();
|
return clang_getNullCursor();
|
||||||
|
|
||||||
|
|
@ -4533,9 +4536,9 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
|
||||||
// reference to an Objective-C class, produce the @interface as
|
// reference to an Objective-C class, produce the @interface as
|
||||||
// the definition; when we were provided with the interface,
|
// the definition; when we were provided with the interface,
|
||||||
// produce the @implementation as the definition.
|
// produce the @implementation as the definition.
|
||||||
ObjCInterfaceDecl *IFace = cast<ObjCInterfaceDecl>(D);
|
const ObjCInterfaceDecl *IFace = cast<ObjCInterfaceDecl>(D);
|
||||||
if (WasReference) {
|
if (WasReference) {
|
||||||
if (ObjCInterfaceDecl *Def = IFace->getDefinition())
|
if (const ObjCInterfaceDecl *Def = IFace->getDefinition())
|
||||||
return MakeCXCursor(Def, TU);
|
return MakeCXCursor(Def, TU);
|
||||||
} else if (ObjCImplementationDecl *Impl = IFace->getImplementation())
|
} else if (ObjCImplementationDecl *Impl = IFace->getImplementation())
|
||||||
return MakeCXCursor(Impl, TU);
|
return MakeCXCursor(Impl, TU);
|
||||||
|
|
@ -4548,9 +4551,9 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
|
||||||
return clang_getNullCursor();
|
return clang_getNullCursor();
|
||||||
|
|
||||||
case Decl::ObjCCompatibleAlias:
|
case Decl::ObjCCompatibleAlias:
|
||||||
if (ObjCInterfaceDecl *Class
|
if (const ObjCInterfaceDecl *Class
|
||||||
= cast<ObjCCompatibleAliasDecl>(D)->getClassInterface())
|
= cast<ObjCCompatibleAliasDecl>(D)->getClassInterface())
|
||||||
if (ObjCInterfaceDecl *Def = Class->getDefinition())
|
if (const ObjCInterfaceDecl *Def = Class->getDefinition())
|
||||||
return MakeCXCursor(Def, TU);
|
return MakeCXCursor(Def, TU);
|
||||||
|
|
||||||
return clang_getNullCursor();
|
return clang_getNullCursor();
|
||||||
|
|
@ -4580,13 +4583,13 @@ CXCursor clang_getCanonicalCursor(CXCursor C) {
|
||||||
if (!clang_isDeclaration(C.kind))
|
if (!clang_isDeclaration(C.kind))
|
||||||
return C;
|
return C;
|
||||||
|
|
||||||
if (Decl *D = getCursorDecl(C)) {
|
if (const Decl *D = getCursorDecl(C)) {
|
||||||
if (ObjCCategoryImplDecl *CatImplD = dyn_cast<ObjCCategoryImplDecl>(D))
|
if (const ObjCCategoryImplDecl *CatImplD = dyn_cast<ObjCCategoryImplDecl>(D))
|
||||||
if (ObjCCategoryDecl *CatD = CatImplD->getCategoryDecl())
|
if (ObjCCategoryDecl *CatD = CatImplD->getCategoryDecl())
|
||||||
return MakeCXCursor(CatD, getCursorTU(C));
|
return MakeCXCursor(CatD, getCursorTU(C));
|
||||||
|
|
||||||
if (ObjCImplDecl *ImplD = dyn_cast<ObjCImplDecl>(D))
|
if (const ObjCImplDecl *ImplD = dyn_cast<ObjCImplDecl>(D))
|
||||||
if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface())
|
if (const ObjCInterfaceDecl *IFD = ImplD->getClassInterface())
|
||||||
return MakeCXCursor(IFD, getCursorTU(C));
|
return MakeCXCursor(IFD, getCursorTU(C));
|
||||||
|
|
||||||
return MakeCXCursor(D->getCanonicalDecl(), getCursorTU(C));
|
return MakeCXCursor(D->getCanonicalDecl(), getCursorTU(C));
|
||||||
|
|
@ -4604,15 +4607,15 @@ unsigned clang_getNumOverloadedDecls(CXCursor C) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
OverloadedDeclRefStorage Storage = getCursorOverloadedDeclRef(C).first;
|
OverloadedDeclRefStorage Storage = getCursorOverloadedDeclRef(C).first;
|
||||||
if (OverloadExpr *E = Storage.dyn_cast<OverloadExpr *>())
|
if (const OverloadExpr *E = Storage.dyn_cast<const OverloadExpr *>())
|
||||||
return E->getNumDecls();
|
return E->getNumDecls();
|
||||||
|
|
||||||
if (OverloadedTemplateStorage *S
|
if (OverloadedTemplateStorage *S
|
||||||
= Storage.dyn_cast<OverloadedTemplateStorage*>())
|
= Storage.dyn_cast<OverloadedTemplateStorage*>())
|
||||||
return S->size();
|
return S->size();
|
||||||
|
|
||||||
Decl *D = Storage.get<Decl*>();
|
const Decl *D = Storage.get<const Decl *>();
|
||||||
if (UsingDecl *Using = dyn_cast<UsingDecl>(D))
|
if (const UsingDecl *Using = dyn_cast<UsingDecl>(D))
|
||||||
return Using->shadow_size();
|
return Using->shadow_size();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -4627,15 +4630,15 @@ CXCursor clang_getOverloadedDecl(CXCursor cursor, unsigned index) {
|
||||||
|
|
||||||
CXTranslationUnit TU = getCursorTU(cursor);
|
CXTranslationUnit TU = getCursorTU(cursor);
|
||||||
OverloadedDeclRefStorage Storage = getCursorOverloadedDeclRef(cursor).first;
|
OverloadedDeclRefStorage Storage = getCursorOverloadedDeclRef(cursor).first;
|
||||||
if (OverloadExpr *E = Storage.dyn_cast<OverloadExpr *>())
|
if (const OverloadExpr *E = Storage.dyn_cast<const OverloadExpr *>())
|
||||||
return MakeCXCursor(E->decls_begin()[index], TU);
|
return MakeCXCursor(E->decls_begin()[index], TU);
|
||||||
|
|
||||||
if (OverloadedTemplateStorage *S
|
if (OverloadedTemplateStorage *S
|
||||||
= Storage.dyn_cast<OverloadedTemplateStorage*>())
|
= Storage.dyn_cast<OverloadedTemplateStorage*>())
|
||||||
return MakeCXCursor(S->begin()[index], TU);
|
return MakeCXCursor(S->begin()[index], TU);
|
||||||
|
|
||||||
Decl *D = Storage.get<Decl*>();
|
const Decl *D = Storage.get<const Decl *>();
|
||||||
if (UsingDecl *Using = dyn_cast<UsingDecl>(D)) {
|
if (const UsingDecl *Using = dyn_cast<UsingDecl>(D)) {
|
||||||
// FIXME: This is, unfortunately, linear time.
|
// FIXME: This is, unfortunately, linear time.
|
||||||
UsingDecl::shadow_iterator Pos = Using->shadow_begin();
|
UsingDecl::shadow_iterator Pos = Using->shadow_begin();
|
||||||
std::advance(Pos, index);
|
std::advance(Pos, index);
|
||||||
|
|
@ -4653,8 +4656,7 @@ void clang_getDefinitionSpellingAndExtent(CXCursor C,
|
||||||
unsigned *endLine,
|
unsigned *endLine,
|
||||||
unsigned *endColumn) {
|
unsigned *endColumn) {
|
||||||
assert(getCursorDecl(C) && "CXCursor has null decl");
|
assert(getCursorDecl(C) && "CXCursor has null decl");
|
||||||
NamedDecl *ND = static_cast<NamedDecl *>(getCursorDecl(C));
|
const FunctionDecl *FD = dyn_cast<FunctionDecl>(getCursorDecl(C));
|
||||||
FunctionDecl *FD = dyn_cast<FunctionDecl>(ND);
|
|
||||||
CompoundStmt *Body = dyn_cast<CompoundStmt>(FD->getBody());
|
CompoundStmt *Body = dyn_cast<CompoundStmt>(FD->getBody());
|
||||||
|
|
||||||
SourceManager &SM = FD->getASTContext().getSourceManager();
|
SourceManager &SM = FD->getASTContext().getSourceManager();
|
||||||
|
|
@ -5067,19 +5069,19 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) {
|
||||||
if (!HasContextSensitiveKeywords) {
|
if (!HasContextSensitiveKeywords) {
|
||||||
// Objective-C properties can have context-sensitive keywords.
|
// Objective-C properties can have context-sensitive keywords.
|
||||||
if (cursor.kind == CXCursor_ObjCPropertyDecl) {
|
if (cursor.kind == CXCursor_ObjCPropertyDecl) {
|
||||||
if (ObjCPropertyDecl *Property
|
if (const ObjCPropertyDecl *Property
|
||||||
= dyn_cast_or_null<ObjCPropertyDecl>(getCursorDecl(cursor)))
|
= dyn_cast_or_null<ObjCPropertyDecl>(getCursorDecl(cursor)))
|
||||||
HasContextSensitiveKeywords = Property->getPropertyAttributesAsWritten() != 0;
|
HasContextSensitiveKeywords = Property->getPropertyAttributesAsWritten() != 0;
|
||||||
}
|
}
|
||||||
// Objective-C methods can have context-sensitive keywords.
|
// Objective-C methods can have context-sensitive keywords.
|
||||||
else if (cursor.kind == CXCursor_ObjCInstanceMethodDecl ||
|
else if (cursor.kind == CXCursor_ObjCInstanceMethodDecl ||
|
||||||
cursor.kind == CXCursor_ObjCClassMethodDecl) {
|
cursor.kind == CXCursor_ObjCClassMethodDecl) {
|
||||||
if (ObjCMethodDecl *Method
|
if (const ObjCMethodDecl *Method
|
||||||
= dyn_cast_or_null<ObjCMethodDecl>(getCursorDecl(cursor))) {
|
= dyn_cast_or_null<ObjCMethodDecl>(getCursorDecl(cursor))) {
|
||||||
if (Method->getObjCDeclQualifier())
|
if (Method->getObjCDeclQualifier())
|
||||||
HasContextSensitiveKeywords = true;
|
HasContextSensitiveKeywords = true;
|
||||||
else {
|
else {
|
||||||
for (ObjCMethodDecl::param_iterator P = Method->param_begin(),
|
for (ObjCMethodDecl::param_const_iterator P = Method->param_begin(),
|
||||||
PEnd = Method->param_end();
|
PEnd = Method->param_end();
|
||||||
P != PEnd; ++P) {
|
P != PEnd; ++P) {
|
||||||
if ((*P)->getObjCDeclQualifier()) {
|
if ((*P)->getObjCDeclQualifier()) {
|
||||||
|
|
@ -5092,7 +5094,7 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) {
|
||||||
}
|
}
|
||||||
// C++ methods can have context-sensitive keywords.
|
// C++ methods can have context-sensitive keywords.
|
||||||
else if (cursor.kind == CXCursor_CXXMethod) {
|
else if (cursor.kind == CXCursor_CXXMethod) {
|
||||||
if (CXXMethodDecl *Method
|
if (const CXXMethodDecl *Method
|
||||||
= dyn_cast_or_null<CXXMethodDecl>(getCursorDecl(cursor))) {
|
= dyn_cast_or_null<CXXMethodDecl>(getCursorDecl(cursor))) {
|
||||||
if (Method->hasAttr<FinalAttr>() || Method->hasAttr<OverrideAttr>())
|
if (Method->hasAttr<FinalAttr>() || Method->hasAttr<OverrideAttr>())
|
||||||
HasContextSensitiveKeywords = true;
|
HasContextSensitiveKeywords = true;
|
||||||
|
|
@ -5103,7 +5105,7 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) {
|
||||||
cursor.kind == CXCursor_ClassDecl ||
|
cursor.kind == CXCursor_ClassDecl ||
|
||||||
cursor.kind == CXCursor_ClassTemplate ||
|
cursor.kind == CXCursor_ClassTemplate ||
|
||||||
cursor.kind == CXCursor_ClassTemplatePartialSpecialization) {
|
cursor.kind == CXCursor_ClassTemplatePartialSpecialization) {
|
||||||
if (Decl *D = getCursorDecl(cursor))
|
if (const Decl *D = getCursorDecl(cursor))
|
||||||
if (D->hasAttr<FinalAttr>())
|
if (D->hasAttr<FinalAttr>())
|
||||||
HasContextSensitiveKeywords = true;
|
HasContextSensitiveKeywords = true;
|
||||||
}
|
}
|
||||||
|
|
@ -5497,7 +5499,7 @@ static void clang_annotateTokensImpl(void *UserData) {
|
||||||
|
|
||||||
if (Cursors[I].kind == CXCursor_ObjCPropertyDecl) {
|
if (Cursors[I].kind == CXCursor_ObjCPropertyDecl) {
|
||||||
IdentifierInfo *II = static_cast<IdentifierInfo *>(Tokens[I].ptr_data);
|
IdentifierInfo *II = static_cast<IdentifierInfo *>(Tokens[I].ptr_data);
|
||||||
if (ObjCPropertyDecl *Property
|
if (const ObjCPropertyDecl *Property
|
||||||
= dyn_cast_or_null<ObjCPropertyDecl>(getCursorDecl(Cursors[I]))) {
|
= dyn_cast_or_null<ObjCPropertyDecl>(getCursorDecl(Cursors[I]))) {
|
||||||
if (Property->getPropertyAttributesAsWritten() != 0 &&
|
if (Property->getPropertyAttributesAsWritten() != 0 &&
|
||||||
llvm::StringSwitch<bool>(II->getName())
|
llvm::StringSwitch<bool>(II->getName())
|
||||||
|
|
@ -5590,8 +5592,8 @@ CXLinkageKind clang_getCursorLinkage(CXCursor cursor) {
|
||||||
if (!clang_isDeclaration(cursor.kind))
|
if (!clang_isDeclaration(cursor.kind))
|
||||||
return CXLinkage_Invalid;
|
return CXLinkage_Invalid;
|
||||||
|
|
||||||
Decl *D = cxcursor::getCursorDecl(cursor);
|
const Decl *D = cxcursor::getCursorDecl(cursor);
|
||||||
if (NamedDecl *ND = dyn_cast_or_null<NamedDecl>(D))
|
if (const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(D))
|
||||||
switch (ND->getLinkage()) {
|
switch (ND->getLinkage()) {
|
||||||
case NoLinkage: return CXLinkage_NoLinkage;
|
case NoLinkage: return CXLinkage_NoLinkage;
|
||||||
case InternalLinkage: return CXLinkage_Internal;
|
case InternalLinkage: return CXLinkage_Internal;
|
||||||
|
|
@ -5660,7 +5662,7 @@ extern "C" {
|
||||||
|
|
||||||
enum CXAvailabilityKind clang_getCursorAvailability(CXCursor cursor) {
|
enum CXAvailabilityKind clang_getCursorAvailability(CXCursor cursor) {
|
||||||
if (clang_isDeclaration(cursor.kind))
|
if (clang_isDeclaration(cursor.kind))
|
||||||
if (Decl *D = cxcursor::getCursorDecl(cursor)) {
|
if (const Decl *D = cxcursor::getCursorDecl(cursor)) {
|
||||||
if (isa<FunctionDecl>(D) && cast<FunctionDecl>(D)->isDeleted())
|
if (isa<FunctionDecl>(D) && cast<FunctionDecl>(D)->isDeleted())
|
||||||
return CXAvailability_Available;
|
return CXAvailability_Available;
|
||||||
|
|
||||||
|
|
@ -5717,7 +5719,7 @@ int clang_getCursorPlatformAvailability(CXCursor cursor,
|
||||||
if (!clang_isDeclaration(cursor.kind))
|
if (!clang_isDeclaration(cursor.kind))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Decl *D = cxcursor::getCursorDecl(cursor);
|
const Decl *D = cxcursor::getCursorDecl(cursor);
|
||||||
if (!D)
|
if (!D)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
@ -5774,15 +5776,15 @@ CXLanguageKind clang_getCursorLanguage(CXCursor cursor) {
|
||||||
/// \brief If the given cursor is the "templated" declaration
|
/// \brief If the given cursor is the "templated" declaration
|
||||||
/// descibing a class or function template, return the class or
|
/// descibing a class or function template, return the class or
|
||||||
/// function template.
|
/// function template.
|
||||||
static Decl *maybeGetTemplateCursor(Decl *D) {
|
static const Decl *maybeGetTemplateCursor(const Decl *D) {
|
||||||
if (!D)
|
if (!D)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
|
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
|
||||||
if (FunctionTemplateDecl *FunTmpl = FD->getDescribedFunctionTemplate())
|
if (FunctionTemplateDecl *FunTmpl = FD->getDescribedFunctionTemplate())
|
||||||
return FunTmpl;
|
return FunTmpl;
|
||||||
|
|
||||||
if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D))
|
if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D))
|
||||||
if (ClassTemplateDecl *ClassTmpl = RD->getDescribedClassTemplate())
|
if (ClassTemplateDecl *ClassTmpl = RD->getDescribedClassTemplate())
|
||||||
return ClassTmpl;
|
return ClassTmpl;
|
||||||
|
|
||||||
|
|
@ -5791,8 +5793,8 @@ static Decl *maybeGetTemplateCursor(Decl *D) {
|
||||||
|
|
||||||
CXCursor clang_getCursorSemanticParent(CXCursor cursor) {
|
CXCursor clang_getCursorSemanticParent(CXCursor cursor) {
|
||||||
if (clang_isDeclaration(cursor.kind)) {
|
if (clang_isDeclaration(cursor.kind)) {
|
||||||
if (Decl *D = getCursorDecl(cursor)) {
|
if (const Decl *D = getCursorDecl(cursor)) {
|
||||||
DeclContext *DC = D->getDeclContext();
|
const DeclContext *DC = D->getDeclContext();
|
||||||
if (!DC)
|
if (!DC)
|
||||||
return clang_getNullCursor();
|
return clang_getNullCursor();
|
||||||
|
|
||||||
|
|
@ -5802,7 +5804,7 @@ CXCursor clang_getCursorSemanticParent(CXCursor cursor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clang_isStatement(cursor.kind) || clang_isExpression(cursor.kind)) {
|
if (clang_isStatement(cursor.kind) || clang_isExpression(cursor.kind)) {
|
||||||
if (Decl *D = getCursorDecl(cursor))
|
if (const Decl *D = getCursorDecl(cursor))
|
||||||
return MakeCXCursor(D, getCursorTU(cursor));
|
return MakeCXCursor(D, getCursorTU(cursor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5811,8 +5813,8 @@ CXCursor clang_getCursorSemanticParent(CXCursor cursor) {
|
||||||
|
|
||||||
CXCursor clang_getCursorLexicalParent(CXCursor cursor) {
|
CXCursor clang_getCursorLexicalParent(CXCursor cursor) {
|
||||||
if (clang_isDeclaration(cursor.kind)) {
|
if (clang_isDeclaration(cursor.kind)) {
|
||||||
if (Decl *D = getCursorDecl(cursor)) {
|
if (const Decl *D = getCursorDecl(cursor)) {
|
||||||
DeclContext *DC = D->getLexicalDeclContext();
|
const DeclContext *DC = D->getLexicalDeclContext();
|
||||||
if (!DC)
|
if (!DC)
|
||||||
return clang_getNullCursor();
|
return clang_getNullCursor();
|
||||||
|
|
||||||
|
|
@ -5894,7 +5896,8 @@ CXComment clang_Cursor_getParsedComment(CXCursor C) {
|
||||||
|
|
||||||
CXModule clang_Cursor_getModule(CXCursor C) {
|
CXModule clang_Cursor_getModule(CXCursor C) {
|
||||||
if (C.kind == CXCursor_ModuleImportDecl) {
|
if (C.kind == CXCursor_ModuleImportDecl) {
|
||||||
if (ImportDecl *ImportD = dyn_cast_or_null<ImportDecl>(getCursorDecl(C)))
|
if (const ImportDecl *ImportD =
|
||||||
|
dyn_cast_or_null<ImportDecl>(getCursorDecl(C)))
|
||||||
return ImportD->getImportedModule();
|
return ImportD->getImportedModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5951,9 +5954,10 @@ unsigned clang_CXXMethod_isStatic(CXCursor C) {
|
||||||
if (!clang_isDeclaration(C.kind))
|
if (!clang_isDeclaration(C.kind))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CXXMethodDecl *Method = 0;
|
const CXXMethodDecl *Method = 0;
|
||||||
Decl *D = cxcursor::getCursorDecl(C);
|
const Decl *D = cxcursor::getCursorDecl(C);
|
||||||
if (FunctionTemplateDecl *FunTmpl = dyn_cast_or_null<FunctionTemplateDecl>(D))
|
if (const FunctionTemplateDecl *FunTmpl =
|
||||||
|
dyn_cast_or_null<FunctionTemplateDecl>(D))
|
||||||
Method = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl());
|
Method = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl());
|
||||||
else
|
else
|
||||||
Method = dyn_cast_or_null<CXXMethodDecl>(D);
|
Method = dyn_cast_or_null<CXXMethodDecl>(D);
|
||||||
|
|
@ -5964,9 +5968,10 @@ unsigned clang_CXXMethod_isVirtual(CXCursor C) {
|
||||||
if (!clang_isDeclaration(C.kind))
|
if (!clang_isDeclaration(C.kind))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CXXMethodDecl *Method = 0;
|
const CXXMethodDecl *Method = 0;
|
||||||
Decl *D = cxcursor::getCursorDecl(C);
|
const Decl *D = cxcursor::getCursorDecl(C);
|
||||||
if (FunctionTemplateDecl *FunTmpl = dyn_cast_or_null<FunctionTemplateDecl>(D))
|
if (const FunctionTemplateDecl *FunTmpl =
|
||||||
|
dyn_cast_or_null<FunctionTemplateDecl>(D))
|
||||||
Method = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl());
|
Method = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl());
|
||||||
else
|
else
|
||||||
Method = dyn_cast_or_null<CXXMethodDecl>(D);
|
Method = dyn_cast_or_null<CXXMethodDecl>(D);
|
||||||
|
|
|
||||||
|
|
@ -56,13 +56,13 @@ enum CXCursorKind clang_getTemplateCursorKind(CXCursor C) {
|
||||||
switch (C.kind) {
|
switch (C.kind) {
|
||||||
case CXCursor_ClassTemplate:
|
case CXCursor_ClassTemplate:
|
||||||
case CXCursor_FunctionTemplate:
|
case CXCursor_FunctionTemplate:
|
||||||
if (TemplateDecl *Template
|
if (const TemplateDecl *Template
|
||||||
= dyn_cast_or_null<TemplateDecl>(getCursorDecl(C)))
|
= dyn_cast_or_null<TemplateDecl>(getCursorDecl(C)))
|
||||||
return MakeCXCursor(Template->getTemplatedDecl(), getCursorTU(C)).kind;
|
return MakeCXCursor(Template->getTemplatedDecl(), getCursorTU(C)).kind;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CXCursor_ClassTemplatePartialSpecialization:
|
case CXCursor_ClassTemplatePartialSpecialization:
|
||||||
if (ClassTemplateSpecializationDecl *PartialSpec
|
if (const ClassTemplateSpecializationDecl *PartialSpec
|
||||||
= dyn_cast_or_null<ClassTemplatePartialSpecializationDecl>(
|
= dyn_cast_or_null<ClassTemplatePartialSpecializationDecl>(
|
||||||
getCursorDecl(C))) {
|
getCursorDecl(C))) {
|
||||||
switch (PartialSpec->getTagKind()) {
|
switch (PartialSpec->getTagKind()) {
|
||||||
|
|
@ -86,16 +86,16 @@ CXCursor clang_getSpecializedCursorTemplate(CXCursor C) {
|
||||||
if (!clang_isDeclaration(C.kind))
|
if (!clang_isDeclaration(C.kind))
|
||||||
return clang_getNullCursor();
|
return clang_getNullCursor();
|
||||||
|
|
||||||
Decl *D = getCursorDecl(C);
|
const Decl *D = getCursorDecl(C);
|
||||||
if (!D)
|
if (!D)
|
||||||
return clang_getNullCursor();
|
return clang_getNullCursor();
|
||||||
|
|
||||||
Decl *Template = 0;
|
Decl *Template = 0;
|
||||||
if (CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(D)) {
|
if (const CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(D)) {
|
||||||
if (ClassTemplatePartialSpecializationDecl *PartialSpec
|
if (const ClassTemplatePartialSpecializationDecl *PartialSpec
|
||||||
= dyn_cast<ClassTemplatePartialSpecializationDecl>(CXXRecord))
|
= dyn_cast<ClassTemplatePartialSpecializationDecl>(CXXRecord))
|
||||||
Template = PartialSpec->getSpecializedTemplate();
|
Template = PartialSpec->getSpecializedTemplate();
|
||||||
else if (ClassTemplateSpecializationDecl *ClassSpec
|
else if (const ClassTemplateSpecializationDecl *ClassSpec
|
||||||
= dyn_cast<ClassTemplateSpecializationDecl>(CXXRecord)) {
|
= dyn_cast<ClassTemplateSpecializationDecl>(CXXRecord)) {
|
||||||
llvm::PointerUnion<ClassTemplateDecl *,
|
llvm::PointerUnion<ClassTemplateDecl *,
|
||||||
ClassTemplatePartialSpecializationDecl *> Result
|
ClassTemplatePartialSpecializationDecl *> Result
|
||||||
|
|
@ -107,14 +107,14 @@ CXCursor clang_getSpecializedCursorTemplate(CXCursor C) {
|
||||||
|
|
||||||
} else
|
} else
|
||||||
Template = CXXRecord->getInstantiatedFromMemberClass();
|
Template = CXXRecord->getInstantiatedFromMemberClass();
|
||||||
} else if (FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
|
} else if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
|
||||||
Template = Function->getPrimaryTemplate();
|
Template = Function->getPrimaryTemplate();
|
||||||
if (!Template)
|
if (!Template)
|
||||||
Template = Function->getInstantiatedFromMemberFunction();
|
Template = Function->getInstantiatedFromMemberFunction();
|
||||||
} else if (VarDecl *Var = dyn_cast<VarDecl>(D)) {
|
} else if (const VarDecl *Var = dyn_cast<VarDecl>(D)) {
|
||||||
if (Var->isStaticDataMember())
|
if (Var->isStaticDataMember())
|
||||||
Template = Var->getInstantiatedFromStaticDataMember();
|
Template = Var->getInstantiatedFromStaticDataMember();
|
||||||
} else if (RedeclarableTemplateDecl *Tmpl
|
} else if (const RedeclarableTemplateDecl *Tmpl
|
||||||
= dyn_cast<RedeclarableTemplateDecl>(D))
|
= dyn_cast<RedeclarableTemplateDecl>(D))
|
||||||
Template = Tmpl->getInstantiatedFromMemberTemplate();
|
Template = Tmpl->getInstantiatedFromMemberTemplate();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ using namespace cxcursor;
|
||||||
using namespace cxindex;
|
using namespace cxindex;
|
||||||
|
|
||||||
static void getTopOverriddenMethods(CXTranslationUnit TU,
|
static void getTopOverriddenMethods(CXTranslationUnit TU,
|
||||||
Decl *D,
|
const Decl *D,
|
||||||
SmallVectorImpl<Decl *> &Methods) {
|
SmallVectorImpl<const Decl *> &Methods) {
|
||||||
if (!D)
|
if (!D)
|
||||||
return;
|
return;
|
||||||
if (!isa<ObjCMethodDecl>(D) && !isa<CXXMethodDecl>(D))
|
if (!isa<ObjCMethodDecl>(D) && !isa<CXXMethodDecl>(D))
|
||||||
|
|
@ -46,15 +46,15 @@ namespace {
|
||||||
struct FindFileIdRefVisitData {
|
struct FindFileIdRefVisitData {
|
||||||
CXTranslationUnit TU;
|
CXTranslationUnit TU;
|
||||||
FileID FID;
|
FileID FID;
|
||||||
Decl *Dcl;
|
const Decl *Dcl;
|
||||||
int SelectorIdIdx;
|
int SelectorIdIdx;
|
||||||
CXCursorAndRangeVisitor visitor;
|
CXCursorAndRangeVisitor visitor;
|
||||||
|
|
||||||
typedef SmallVector<Decl *, 8> TopMethodsTy;
|
typedef SmallVector<const Decl *, 8> TopMethodsTy;
|
||||||
TopMethodsTy TopMethods;
|
TopMethodsTy TopMethods;
|
||||||
|
|
||||||
FindFileIdRefVisitData(CXTranslationUnit TU, FileID FID,
|
FindFileIdRefVisitData(CXTranslationUnit TU, FileID FID,
|
||||||
Decl *D, int selectorIdIdx,
|
const Decl *D, int selectorIdIdx,
|
||||||
CXCursorAndRangeVisitor visitor)
|
CXCursorAndRangeVisitor visitor)
|
||||||
: TU(TU), FID(FID), SelectorIdIdx(selectorIdIdx), visitor(visitor) {
|
: TU(TU), FID(FID), SelectorIdIdx(selectorIdIdx), visitor(visitor) {
|
||||||
Dcl = getCanonical(D);
|
Dcl = getCanonical(D);
|
||||||
|
|
@ -76,24 +76,25 @@ struct FindFileIdRefVisitData {
|
||||||
///
|
///
|
||||||
/// we consider the canonical decl of the constructor decl to be the class
|
/// we consider the canonical decl of the constructor decl to be the class
|
||||||
/// itself, so both 'C' can be highlighted.
|
/// itself, so both 'C' can be highlighted.
|
||||||
Decl *getCanonical(Decl *D) const {
|
const Decl *getCanonical(const Decl *D) const {
|
||||||
if (!D)
|
if (!D)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
D = D->getCanonicalDecl();
|
D = D->getCanonicalDecl();
|
||||||
|
|
||||||
if (ObjCImplDecl *ImplD = dyn_cast<ObjCImplDecl>(D)) {
|
if (const ObjCImplDecl *ImplD = dyn_cast<ObjCImplDecl>(D)) {
|
||||||
if (ImplD->getClassInterface())
|
if (ImplD->getClassInterface())
|
||||||
return getCanonical(ImplD->getClassInterface());
|
return getCanonical(ImplD->getClassInterface());
|
||||||
|
|
||||||
} else if (CXXConstructorDecl *CXXCtorD = dyn_cast<CXXConstructorDecl>(D)) {
|
} else if (const CXXConstructorDecl *CXXCtorD =
|
||||||
|
dyn_cast<CXXConstructorDecl>(D)) {
|
||||||
return getCanonical(CXXCtorD->getParent());
|
return getCanonical(CXXCtorD->getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
return D;
|
return D;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isHit(Decl *D) const {
|
bool isHit(const Decl *D) const {
|
||||||
if (!D)
|
if (!D)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -108,7 +109,7 @@ struct FindFileIdRefVisitData {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isOverriddingMethod(Decl *D) const {
|
bool isOverriddingMethod(const Decl *D) const {
|
||||||
if (std::find(TopMethods.begin(), TopMethods.end(), D) !=
|
if (std::find(TopMethods.begin(), TopMethods.end(), D) !=
|
||||||
TopMethods.end())
|
TopMethods.end())
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -150,7 +151,7 @@ static enum CXChildVisitResult findFileIdRefVisit(CXCursor cursor,
|
||||||
if (!clang_isDeclaration(declCursor.kind))
|
if (!clang_isDeclaration(declCursor.kind))
|
||||||
return CXChildVisit_Recurse;
|
return CXChildVisit_Recurse;
|
||||||
|
|
||||||
Decl *D = cxcursor::getCursorDecl(declCursor);
|
const Decl *D = cxcursor::getCursorDecl(declCursor);
|
||||||
if (!D)
|
if (!D)
|
||||||
return CXChildVisit_Continue;
|
return CXChildVisit_Continue;
|
||||||
|
|
||||||
|
|
@ -218,7 +219,7 @@ static void findIdRefsInFile(CXTranslationUnit TU, CXCursor declCursor,
|
||||||
SourceManager &SM = Unit->getSourceManager();
|
SourceManager &SM = Unit->getSourceManager();
|
||||||
|
|
||||||
FileID FID = SM.translateFile(File);
|
FileID FID = SM.translateFile(File);
|
||||||
Decl *Dcl = cxcursor::getCursorDecl(declCursor);
|
const Decl *Dcl = cxcursor::getCursorDecl(declCursor);
|
||||||
if (!Dcl)
|
if (!Dcl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -226,7 +227,7 @@ static void findIdRefsInFile(CXTranslationUnit TU, CXCursor declCursor,
|
||||||
cxcursor::getSelectorIdentifierIndex(declCursor),
|
cxcursor::getSelectorIdentifierIndex(declCursor),
|
||||||
Visitor);
|
Visitor);
|
||||||
|
|
||||||
if (DeclContext *DC = Dcl->getParentFunctionOrMethod()) {
|
if (const DeclContext *DC = Dcl->getParentFunctionOrMethod()) {
|
||||||
clang_visitChildren(cxcursor::MakeCXCursor(cast<Decl>(DC), TU),
|
clang_visitChildren(cxcursor::MakeCXCursor(cast<Decl>(DC), TU),
|
||||||
findFileIdRefVisit, &data);
|
findFileIdRefVisit, &data);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -821,7 +821,7 @@ CXString clang_getCursorUSR(CXCursor C) {
|
||||||
const CXCursorKind &K = clang_getCursorKind(C);
|
const CXCursorKind &K = clang_getCursorKind(C);
|
||||||
|
|
||||||
if (clang_isDeclaration(K)) {
|
if (clang_isDeclaration(K)) {
|
||||||
Decl *D = cxcursor::getCursorDecl(C);
|
const Decl *D = cxcursor::getCursorDecl(C);
|
||||||
if (!D)
|
if (!D)
|
||||||
return createCXString("");
|
return createCXString("");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -730,7 +730,7 @@ cxcursor::getCursorLabelRef(CXCursor C) {
|
||||||
reinterpret_cast<uintptr_t>(C.data[1])));
|
reinterpret_cast<uintptr_t>(C.data[1])));
|
||||||
}
|
}
|
||||||
|
|
||||||
CXCursor cxcursor::MakeCursorOverloadedDeclRef(OverloadExpr *E,
|
CXCursor cxcursor::MakeCursorOverloadedDeclRef(const OverloadExpr *E,
|
||||||
CXTranslationUnit TU) {
|
CXTranslationUnit TU) {
|
||||||
assert(E && TU && "Invalid arguments!");
|
assert(E && TU && "Invalid arguments!");
|
||||||
OverloadedDeclRefStorage Storage(E);
|
OverloadedDeclRefStorage Storage(E);
|
||||||
|
|
@ -742,7 +742,7 @@ CXCursor cxcursor::MakeCursorOverloadedDeclRef(OverloadExpr *E,
|
||||||
return C;
|
return C;
|
||||||
}
|
}
|
||||||
|
|
||||||
CXCursor cxcursor::MakeCursorOverloadedDeclRef(Decl *D,
|
CXCursor cxcursor::MakeCursorOverloadedDeclRef(const Decl *D,
|
||||||
SourceLocation Loc,
|
SourceLocation Loc,
|
||||||
CXTranslationUnit TU) {
|
CXTranslationUnit TU) {
|
||||||
assert(D && TU && "Invalid arguments!");
|
assert(D && TU && "Invalid arguments!");
|
||||||
|
|
@ -777,8 +777,8 @@ cxcursor::getCursorOverloadedDeclRef(CXCursor C) {
|
||||||
reinterpret_cast<uintptr_t>(C.data[1])));
|
reinterpret_cast<uintptr_t>(C.data[1])));
|
||||||
}
|
}
|
||||||
|
|
||||||
Decl *cxcursor::getCursorDecl(CXCursor Cursor) {
|
const Decl *cxcursor::getCursorDecl(CXCursor Cursor) {
|
||||||
return static_cast<Decl*>(const_cast<void*>(Cursor.data[0]));
|
return static_cast<const Decl *>(Cursor.data[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Expr *cxcursor::getCursorExpr(CXCursor Cursor) {
|
Expr *cxcursor::getCursorExpr(CXCursor Cursor) {
|
||||||
|
|
@ -943,7 +943,7 @@ CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor cursor) {
|
||||||
|
|
||||||
int clang_Cursor_getNumArguments(CXCursor C) {
|
int clang_Cursor_getNumArguments(CXCursor C) {
|
||||||
if (clang_isDeclaration(C.kind)) {
|
if (clang_isDeclaration(C.kind)) {
|
||||||
Decl *D = cxcursor::getCursorDecl(C);
|
const Decl *D = cxcursor::getCursorDecl(C);
|
||||||
if (const ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(D))
|
if (const ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(D))
|
||||||
return MD->param_size();
|
return MD->param_size();
|
||||||
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
|
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
|
||||||
|
|
@ -955,12 +955,12 @@ int clang_Cursor_getNumArguments(CXCursor C) {
|
||||||
|
|
||||||
CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i) {
|
CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i) {
|
||||||
if (clang_isDeclaration(C.kind)) {
|
if (clang_isDeclaration(C.kind)) {
|
||||||
Decl *D = cxcursor::getCursorDecl(C);
|
const Decl *D = cxcursor::getCursorDecl(C);
|
||||||
if (ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(D)) {
|
if (const ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(D)) {
|
||||||
if (i < MD->param_size())
|
if (i < MD->param_size())
|
||||||
return cxcursor::MakeCXCursor(MD->param_begin()[i],
|
return cxcursor::MakeCXCursor(MD->param_begin()[i],
|
||||||
cxcursor::getCursorTU(C));
|
cxcursor::getCursorTU(C));
|
||||||
} else if (FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) {
|
} else if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) {
|
||||||
if (i < FD->param_size())
|
if (i < FD->param_size())
|
||||||
return cxcursor::MakeCXCursor(FD->param_begin()[i],
|
return cxcursor::MakeCXCursor(FD->param_begin()[i],
|
||||||
cxcursor::getCursorTU(C));
|
cxcursor::getCursorTU(C));
|
||||||
|
|
@ -1039,8 +1039,8 @@ unsigned clang_CXCursorSet_insert(CXCursorSet set, CXCursor cursor) {
|
||||||
CXCompletionString clang_getCursorCompletionString(CXCursor cursor) {
|
CXCompletionString clang_getCursorCompletionString(CXCursor cursor) {
|
||||||
enum CXCursorKind kind = clang_getCursorKind(cursor);
|
enum CXCursorKind kind = clang_getCursorKind(cursor);
|
||||||
if (clang_isDeclaration(kind)) {
|
if (clang_isDeclaration(kind)) {
|
||||||
Decl *decl = getCursorDecl(cursor);
|
const Decl *decl = getCursorDecl(cursor);
|
||||||
if (NamedDecl *namedDecl = dyn_cast_or_null<NamedDecl>(decl)) {
|
if (const NamedDecl *namedDecl = dyn_cast_or_null<NamedDecl>(decl)) {
|
||||||
ASTUnit *unit = getCursorASTUnit(cursor);
|
ASTUnit *unit = getCursorASTUnit(cursor);
|
||||||
CodeCompletionResult Result(namedDecl);
|
CodeCompletionResult Result(namedDecl);
|
||||||
CodeCompletionString *String
|
CodeCompletionString *String
|
||||||
|
|
|
||||||
|
|
@ -219,10 +219,11 @@ CXCursor MakeCursorLabelRef(LabelStmt *Label, SourceLocation Loc,
|
||||||
std::pair<const LabelStmt *, SourceLocation> getCursorLabelRef(CXCursor C);
|
std::pair<const LabelStmt *, SourceLocation> getCursorLabelRef(CXCursor C);
|
||||||
|
|
||||||
/// \brief Create a overloaded declaration reference cursor for an expression.
|
/// \brief Create a overloaded declaration reference cursor for an expression.
|
||||||
CXCursor MakeCursorOverloadedDeclRef(OverloadExpr *E, CXTranslationUnit TU);
|
CXCursor MakeCursorOverloadedDeclRef(const OverloadExpr *E,
|
||||||
|
CXTranslationUnit TU);
|
||||||
|
|
||||||
/// \brief Create a overloaded declaration reference cursor for a declaration.
|
/// \brief Create a overloaded declaration reference cursor for a declaration.
|
||||||
CXCursor MakeCursorOverloadedDeclRef(Decl *D, SourceLocation Location,
|
CXCursor MakeCursorOverloadedDeclRef(const Decl *D, SourceLocation Location,
|
||||||
CXTranslationUnit TU);
|
CXTranslationUnit TU);
|
||||||
|
|
||||||
/// \brief Create a overloaded declaration reference cursor for a template name.
|
/// \brief Create a overloaded declaration reference cursor for a template name.
|
||||||
|
|
@ -231,7 +232,7 @@ CXCursor MakeCursorOverloadedDeclRef(TemplateName Template,
|
||||||
CXTranslationUnit TU);
|
CXTranslationUnit TU);
|
||||||
|
|
||||||
/// \brief Internal storage for an overloaded declaration reference cursor;
|
/// \brief Internal storage for an overloaded declaration reference cursor;
|
||||||
typedef llvm::PointerUnion3<OverloadExpr *, Decl *,
|
typedef llvm::PointerUnion3<const OverloadExpr *, const Decl *,
|
||||||
OverloadedTemplateStorage *>
|
OverloadedTemplateStorage *>
|
||||||
OverloadedDeclRefStorage;
|
OverloadedDeclRefStorage;
|
||||||
|
|
||||||
|
|
@ -240,7 +241,7 @@ typedef llvm::PointerUnion3<OverloadExpr *, Decl *,
|
||||||
std::pair<OverloadedDeclRefStorage, SourceLocation>
|
std::pair<OverloadedDeclRefStorage, SourceLocation>
|
||||||
getCursorOverloadedDeclRef(CXCursor C);
|
getCursorOverloadedDeclRef(CXCursor C);
|
||||||
|
|
||||||
Decl *getCursorDecl(CXCursor Cursor);
|
const Decl *getCursorDecl(CXCursor Cursor);
|
||||||
Expr *getCursorExpr(CXCursor Cursor);
|
Expr *getCursorExpr(CXCursor Cursor);
|
||||||
Stmt *getCursorStmt(CXCursor Cursor);
|
Stmt *getCursorStmt(CXCursor Cursor);
|
||||||
Attr *getCursorAttr(CXCursor Cursor);
|
Attr *getCursorAttr(CXCursor Cursor);
|
||||||
|
|
|
||||||
|
|
@ -141,19 +141,19 @@ CXType clang_getCursorType(CXCursor C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clang_isDeclaration(C.kind)) {
|
if (clang_isDeclaration(C.kind)) {
|
||||||
Decl *D = cxcursor::getCursorDecl(C);
|
const Decl *D = cxcursor::getCursorDecl(C);
|
||||||
if (!D)
|
if (!D)
|
||||||
return MakeCXType(QualType(), TU);
|
return MakeCXType(QualType(), TU);
|
||||||
|
|
||||||
if (TypeDecl *TD = dyn_cast<TypeDecl>(D))
|
if (const TypeDecl *TD = dyn_cast<TypeDecl>(D))
|
||||||
return MakeCXType(Context.getTypeDeclType(TD), TU);
|
return MakeCXType(Context.getTypeDeclType(TD), TU);
|
||||||
if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D))
|
if (const ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D))
|
||||||
return MakeCXType(Context.getObjCInterfaceType(ID), TU);
|
return MakeCXType(Context.getObjCInterfaceType(ID), TU);
|
||||||
if (ValueDecl *VD = dyn_cast<ValueDecl>(D))
|
if (const ValueDecl *VD = dyn_cast<ValueDecl>(D))
|
||||||
return MakeCXType(VD->getType(), TU);
|
return MakeCXType(VD->getType(), TU);
|
||||||
if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(D))
|
if (const ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(D))
|
||||||
return MakeCXType(PD->getType(), TU);
|
return MakeCXType(PD->getType(), TU);
|
||||||
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
|
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
|
||||||
return MakeCXType(FD->getType(), TU);
|
return MakeCXType(FD->getType(), TU);
|
||||||
return MakeCXType(QualType(), TU);
|
return MakeCXType(QualType(), TU);
|
||||||
}
|
}
|
||||||
|
|
@ -205,9 +205,9 @@ CXType clang_getTypedefDeclUnderlyingType(CXCursor C) {
|
||||||
CXTranslationUnit TU = cxcursor::getCursorTU(C);
|
CXTranslationUnit TU = cxcursor::getCursorTU(C);
|
||||||
|
|
||||||
if (clang_isDeclaration(C.kind)) {
|
if (clang_isDeclaration(C.kind)) {
|
||||||
Decl *D = cxcursor::getCursorDecl(C);
|
const Decl *D = cxcursor::getCursorDecl(C);
|
||||||
|
|
||||||
if (TypedefNameDecl *TD = dyn_cast_or_null<TypedefNameDecl>(D)) {
|
if (const TypedefNameDecl *TD = dyn_cast_or_null<TypedefNameDecl>(D)) {
|
||||||
QualType T = TD->getUnderlyingType();
|
QualType T = TD->getUnderlyingType();
|
||||||
return MakeCXType(T, TU);
|
return MakeCXType(T, TU);
|
||||||
}
|
}
|
||||||
|
|
@ -223,9 +223,9 @@ CXType clang_getEnumDeclIntegerType(CXCursor C) {
|
||||||
CXTranslationUnit TU = cxcursor::getCursorTU(C);
|
CXTranslationUnit TU = cxcursor::getCursorTU(C);
|
||||||
|
|
||||||
if (clang_isDeclaration(C.kind)) {
|
if (clang_isDeclaration(C.kind)) {
|
||||||
Decl *D = cxcursor::getCursorDecl(C);
|
const Decl *D = cxcursor::getCursorDecl(C);
|
||||||
|
|
||||||
if (EnumDecl *TD = dyn_cast_or_null<EnumDecl>(D)) {
|
if (const EnumDecl *TD = dyn_cast_or_null<EnumDecl>(D)) {
|
||||||
QualType T = TD->getIntegerType();
|
QualType T = TD->getIntegerType();
|
||||||
return MakeCXType(T, TU);
|
return MakeCXType(T, TU);
|
||||||
}
|
}
|
||||||
|
|
@ -240,9 +240,9 @@ long long clang_getEnumConstantDeclValue(CXCursor C) {
|
||||||
using namespace cxcursor;
|
using namespace cxcursor;
|
||||||
|
|
||||||
if (clang_isDeclaration(C.kind)) {
|
if (clang_isDeclaration(C.kind)) {
|
||||||
Decl *D = cxcursor::getCursorDecl(C);
|
const Decl *D = cxcursor::getCursorDecl(C);
|
||||||
|
|
||||||
if (EnumConstantDecl *TD = dyn_cast_or_null<EnumConstantDecl>(D)) {
|
if (const EnumConstantDecl *TD = dyn_cast_or_null<EnumConstantDecl>(D)) {
|
||||||
return TD->getInitVal().getSExtValue();
|
return TD->getInitVal().getSExtValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -256,9 +256,9 @@ unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C) {
|
||||||
using namespace cxcursor;
|
using namespace cxcursor;
|
||||||
|
|
||||||
if (clang_isDeclaration(C.kind)) {
|
if (clang_isDeclaration(C.kind)) {
|
||||||
Decl *D = cxcursor::getCursorDecl(C);
|
const Decl *D = cxcursor::getCursorDecl(C);
|
||||||
|
|
||||||
if (EnumConstantDecl *TD = dyn_cast_or_null<EnumConstantDecl>(D)) {
|
if (const EnumConstantDecl *TD = dyn_cast_or_null<EnumConstantDecl>(D)) {
|
||||||
return TD->getInitVal().getZExtValue();
|
return TD->getInitVal().getZExtValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -272,9 +272,9 @@ int clang_getFieldDeclBitWidth(CXCursor C) {
|
||||||
using namespace cxcursor;
|
using namespace cxcursor;
|
||||||
|
|
||||||
if (clang_isDeclaration(C.kind)) {
|
if (clang_isDeclaration(C.kind)) {
|
||||||
Decl *D = getCursorDecl(C);
|
const Decl *D = getCursorDecl(C);
|
||||||
|
|
||||||
if (FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
|
if (const FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
|
||||||
if (FD->isBitField())
|
if (FD->isBitField())
|
||||||
return FD->getBitWidthValue(getCursorContext(C));
|
return FD->getBitWidthValue(getCursorContext(C));
|
||||||
}
|
}
|
||||||
|
|
@ -536,7 +536,7 @@ CXType clang_getResultType(CXType X) {
|
||||||
|
|
||||||
CXType clang_getCursorResultType(CXCursor C) {
|
CXType clang_getCursorResultType(CXCursor C) {
|
||||||
if (clang_isDeclaration(C.kind)) {
|
if (clang_isDeclaration(C.kind)) {
|
||||||
Decl *D = cxcursor::getCursorDecl(C);
|
const Decl *D = cxcursor::getCursorDecl(C);
|
||||||
if (const ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(D))
|
if (const ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(D))
|
||||||
return MakeCXType(MD->getResultType(), cxcursor::getCursorTU(C));
|
return MakeCXType(MD->getResultType(), cxcursor::getCursorTU(C));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ private:
|
||||||
|
|
||||||
/// \brief The declaration that serves at the parent of any statement or
|
/// \brief The declaration that serves at the parent of any statement or
|
||||||
/// expression nodes.
|
/// expression nodes.
|
||||||
Decl *StmtParent;
|
const Decl *StmtParent;
|
||||||
|
|
||||||
/// \brief The visitor function.
|
/// \brief The visitor function.
|
||||||
CXCursorVisitor Visitor;
|
CXCursorVisitor Visitor;
|
||||||
|
|
@ -119,11 +119,12 @@ private:
|
||||||
|
|
||||||
class SetParentRAII {
|
class SetParentRAII {
|
||||||
CXCursor &Parent;
|
CXCursor &Parent;
|
||||||
Decl *&StmtParent;
|
const Decl *&StmtParent;
|
||||||
CXCursor OldParent;
|
CXCursor OldParent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SetParentRAII(CXCursor &Parent, Decl *&StmtParent, CXCursor NewParent)
|
SetParentRAII(CXCursor &Parent, const Decl *&StmtParent,
|
||||||
|
CXCursor NewParent)
|
||||||
: Parent(Parent), StmtParent(StmtParent), OldParent(Parent)
|
: Parent(Parent), StmtParent(StmtParent), OldParent(Parent)
|
||||||
{
|
{
|
||||||
Parent = NewParent;
|
Parent = NewParent;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue