mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 09:16:08 +00:00
[clang] Reformat cindex. NFC.
to reduce spurios changes in patches after clang-formatting them. In particular, these files contain long enums that clang-format reformats in their entirety if e.g. an element is added. Reviews having this problem include https://reviews.llvm.org/D76342 and https://reviews.llvm.org/D71447.
This commit is contained in:
parent
a32b94c6c3
commit
7520cf03ee
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -58,39 +58,36 @@ CXCursor MakeCXCursor(const clang::Stmt *S, const clang::Decl *Parent,
|
||||
CXCursor MakeCXCursorInvalid(CXCursorKind K, CXTranslationUnit TU = nullptr);
|
||||
|
||||
/// Create an Objective-C superclass reference at the given location.
|
||||
CXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super,
|
||||
SourceLocation Loc,
|
||||
CXTranslationUnit TU);
|
||||
CXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super,
|
||||
SourceLocation Loc, CXTranslationUnit TU);
|
||||
|
||||
/// Unpack an ObjCSuperClassRef cursor into the interface it references
|
||||
/// and optionally the location where the reference occurred.
|
||||
std::pair<const ObjCInterfaceDecl *, SourceLocation>
|
||||
getCursorObjCSuperClassRef(CXCursor C);
|
||||
getCursorObjCSuperClassRef(CXCursor C);
|
||||
|
||||
/// Create an Objective-C protocol reference at the given location.
|
||||
CXCursor MakeCursorObjCProtocolRef(const ObjCProtocolDecl *Proto,
|
||||
SourceLocation Loc,
|
||||
CXTranslationUnit TU);
|
||||
SourceLocation Loc, CXTranslationUnit TU);
|
||||
|
||||
/// Unpack an ObjCProtocolRef cursor into the protocol it references
|
||||
/// and optionally the location where the reference occurred.
|
||||
std::pair<const ObjCProtocolDecl *, SourceLocation>
|
||||
getCursorObjCProtocolRef(CXCursor C);
|
||||
getCursorObjCProtocolRef(CXCursor C);
|
||||
|
||||
/// Create an Objective-C class reference at the given location.
|
||||
CXCursor MakeCursorObjCClassRef(const ObjCInterfaceDecl *Class,
|
||||
SourceLocation Loc,
|
||||
CXTranslationUnit TU);
|
||||
SourceLocation Loc, CXTranslationUnit TU);
|
||||
|
||||
/// Unpack an ObjCClassRef cursor into the class it references
|
||||
/// and optionally the location where the reference occurred.
|
||||
std::pair<const ObjCInterfaceDecl *, SourceLocation>
|
||||
getCursorObjCClassRef(CXCursor C);
|
||||
getCursorObjCClassRef(CXCursor C);
|
||||
|
||||
/// Create a type reference at the given location.
|
||||
CXCursor MakeCursorTypeRef(const TypeDecl *Type, SourceLocation Loc,
|
||||
CXTranslationUnit TU);
|
||||
|
||||
|
||||
/// Unpack a TypeRef cursor into the class it references
|
||||
/// and optionally the location where the reference occurred.
|
||||
std::pair<const TypeDecl *, SourceLocation> getCursorTypeRef(CXCursor C);
|
||||
@ -102,9 +99,9 @@ CXCursor MakeCursorTemplateRef(const TemplateDecl *Template, SourceLocation Loc,
|
||||
/// Unpack a TemplateRef cursor into the template it references and
|
||||
/// the location where the reference occurred.
|
||||
std::pair<const TemplateDecl *, SourceLocation>
|
||||
getCursorTemplateRef(CXCursor C);
|
||||
getCursorTemplateRef(CXCursor C);
|
||||
|
||||
/// Create a reference to a namespace or namespace alias at the given
|
||||
/// Create a reference to a namespace or namespace alias at the given
|
||||
/// location.
|
||||
CXCursor MakeCursorNamespaceRef(const NamedDecl *NS, SourceLocation Loc,
|
||||
CXTranslationUnit TU);
|
||||
@ -114,7 +111,7 @@ CXCursor MakeCursorNamespaceRef(const NamedDecl *NS, SourceLocation Loc,
|
||||
std::pair<const NamedDecl *, SourceLocation> getCursorNamespaceRef(CXCursor C);
|
||||
|
||||
/// Create a reference to a variable at the given location.
|
||||
CXCursor MakeCursorVariableRef(const VarDecl *Var, SourceLocation Loc,
|
||||
CXCursor MakeCursorVariableRef(const VarDecl *Var, SourceLocation Loc,
|
||||
CXTranslationUnit TU);
|
||||
|
||||
/// Unpack a VariableRef cursor into the variable it references and the
|
||||
@ -122,10 +119,10 @@ CXCursor MakeCursorVariableRef(const VarDecl *Var, SourceLocation Loc,
|
||||
std::pair<const VarDecl *, SourceLocation> getCursorVariableRef(CXCursor C);
|
||||
|
||||
/// Create a reference to a field at the given location.
|
||||
CXCursor MakeCursorMemberRef(const FieldDecl *Field, SourceLocation Loc,
|
||||
CXCursor MakeCursorMemberRef(const FieldDecl *Field, SourceLocation Loc,
|
||||
CXTranslationUnit TU);
|
||||
|
||||
/// Unpack a MemberRef cursor into the field it references and the
|
||||
/// Unpack a MemberRef cursor into the field it references and the
|
||||
/// location where the reference occurred.
|
||||
std::pair<const FieldDecl *, SourceLocation> getCursorMemberRef(CXCursor C);
|
||||
|
||||
@ -223,7 +220,7 @@ CXCursor MakeCursorOverloadedDeclRef(const Decl *D, SourceLocation Location,
|
||||
CXTranslationUnit TU);
|
||||
|
||||
/// Create a overloaded declaration reference cursor for a template name.
|
||||
CXCursor MakeCursorOverloadedDeclRef(TemplateName Template,
|
||||
CXCursor MakeCursorOverloadedDeclRef(TemplateName Template,
|
||||
SourceLocation Location,
|
||||
CXTranslationUnit TU);
|
||||
|
||||
@ -235,7 +232,7 @@ typedef llvm::PointerUnion<const OverloadExpr *, const Decl *,
|
||||
/// Unpack an overloaded declaration reference into an expression,
|
||||
/// declaration, or template name along with the source location.
|
||||
std::pair<OverloadedDeclRefStorage, SourceLocation>
|
||||
getCursorOverloadedDeclRef(CXCursor C);
|
||||
getCursorOverloadedDeclRef(CXCursor C);
|
||||
|
||||
const Decl *getCursorDecl(CXCursor Cursor);
|
||||
const Expr *getCursorExpr(CXCursor Cursor);
|
||||
@ -284,14 +281,13 @@ bool getDeclCursorUSR(const Decl *D, SmallVectorImpl<char> &Buf);
|
||||
|
||||
bool operator==(CXCursor X, CXCursor Y);
|
||||
|
||||
inline bool operator!=(CXCursor X, CXCursor Y) {
|
||||
return !(X == Y);
|
||||
}
|
||||
inline bool operator!=(CXCursor X, CXCursor Y) { return !(X == Y); }
|
||||
|
||||
/// Return true if the cursor represents a declaration that is the
|
||||
/// first in a declaration group.
|
||||
bool isFirstInDeclGroup(CXCursor C);
|
||||
|
||||
}} // end namespace: clang::cxcursor
|
||||
} // namespace cxcursor
|
||||
} // namespace clang
|
||||
|
||||
#endif
|
||||
|
@ -16,43 +16,52 @@
|
||||
#include "clang/AST/TypeLocVisitor.h"
|
||||
|
||||
namespace clang {
|
||||
class PreprocessingRecord;
|
||||
class ASTUnit;
|
||||
class PreprocessingRecord;
|
||||
class ASTUnit;
|
||||
|
||||
namespace cxcursor {
|
||||
|
||||
class VisitorJob {
|
||||
public:
|
||||
enum Kind { DeclVisitKind, StmtVisitKind, MemberExprPartsKind,
|
||||
TypeLocVisitKind, OverloadExprPartsKind,
|
||||
DeclRefExprPartsKind, LabelRefVisitKind,
|
||||
ExplicitTemplateArgsVisitKind,
|
||||
NestedNameSpecifierLocVisitKind,
|
||||
DeclarationNameInfoVisitKind,
|
||||
MemberRefVisitKind, SizeOfPackExprPartsKind,
|
||||
LambdaExprPartsKind, PostChildrenVisitKind };
|
||||
enum Kind {
|
||||
DeclVisitKind,
|
||||
StmtVisitKind,
|
||||
MemberExprPartsKind,
|
||||
TypeLocVisitKind,
|
||||
OverloadExprPartsKind,
|
||||
DeclRefExprPartsKind,
|
||||
LabelRefVisitKind,
|
||||
ExplicitTemplateArgsVisitKind,
|
||||
NestedNameSpecifierLocVisitKind,
|
||||
DeclarationNameInfoVisitKind,
|
||||
MemberRefVisitKind,
|
||||
SizeOfPackExprPartsKind,
|
||||
LambdaExprPartsKind,
|
||||
PostChildrenVisitKind
|
||||
};
|
||||
|
||||
protected:
|
||||
const void *data[3];
|
||||
CXCursor parent;
|
||||
Kind K;
|
||||
VisitorJob(CXCursor C, Kind k, const void *d1, const void *d2 = nullptr,
|
||||
const void *d3 = nullptr)
|
||||
: parent(C), K(k) {
|
||||
: parent(C), K(k) {
|
||||
data[0] = d1;
|
||||
data[1] = d2;
|
||||
data[2] = d3;
|
||||
}
|
||||
|
||||
public:
|
||||
Kind getKind() const { return K; }
|
||||
const CXCursor &getParent() const { return parent; }
|
||||
};
|
||||
|
||||
|
||||
typedef SmallVector<VisitorJob, 10> VisitorWorkList;
|
||||
|
||||
// Cursor visitor.
|
||||
class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
|
||||
public TypeLocVisitor<CursorVisitor, bool>
|
||||
{
|
||||
public TypeLocVisitor<CursorVisitor, bool> {
|
||||
public:
|
||||
/// Callback called after child nodes of a cursor have been visited.
|
||||
/// Return true to break visitation or false to continue.
|
||||
@ -79,14 +88,14 @@ private:
|
||||
/// The opaque client data, to be passed along to the visitor.
|
||||
CXClientData ClientData;
|
||||
|
||||
/// Whether we should visit the preprocessing record entries last,
|
||||
/// Whether we should visit the preprocessing record entries last,
|
||||
/// after visiting other declarations.
|
||||
bool VisitPreprocessorLast;
|
||||
|
||||
/// Whether we should visit declarations or preprocessing record
|
||||
/// entries that are #included inside the \arg RegionOfInterest.
|
||||
bool VisitIncludedEntities;
|
||||
|
||||
|
||||
/// When valid, a source range to which the cursor should restrict
|
||||
/// its search.
|
||||
SourceRange RegionOfInterest;
|
||||
@ -103,8 +112,8 @@ private:
|
||||
SmallVectorImpl<Decl *>::iterator FileDE_current;
|
||||
|
||||
// Cache of pre-allocated worklists for data-recursion walk of Stmts.
|
||||
SmallVector<VisitorWorkList*, 5> WorkListFreeList;
|
||||
SmallVector<VisitorWorkList*, 5> WorkListCache;
|
||||
SmallVector<VisitorWorkList *, 5> WorkListFreeList;
|
||||
SmallVector<VisitorWorkList *, 5> WorkListCache;
|
||||
|
||||
using DeclVisitor<CursorVisitor, bool>::Visit;
|
||||
using TypeLocVisitor<CursorVisitor, bool>::Visit;
|
||||
@ -123,10 +132,8 @@ private:
|
||||
CXCursor OldParent;
|
||||
|
||||
public:
|
||||
SetParentRAII(CXCursor &Parent, const Decl *&StmtParent,
|
||||
CXCursor NewParent)
|
||||
: Parent(Parent), StmtParent(StmtParent), OldParent(Parent)
|
||||
{
|
||||
SetParentRAII(CXCursor &Parent, const Decl *&StmtParent, CXCursor NewParent)
|
||||
: Parent(Parent), StmtParent(StmtParent), OldParent(Parent) {
|
||||
Parent = NewParent;
|
||||
if (clang_isDeclaration(Parent.kind))
|
||||
StmtParent = getCursorDecl(Parent);
|
||||
@ -141,21 +148,17 @@ private:
|
||||
|
||||
public:
|
||||
CursorVisitor(CXTranslationUnit TU, CXCursorVisitor Visitor,
|
||||
CXClientData ClientData,
|
||||
bool VisitPreprocessorLast,
|
||||
CXClientData ClientData, bool VisitPreprocessorLast,
|
||||
bool VisitIncludedPreprocessingEntries = false,
|
||||
SourceRange RegionOfInterest = SourceRange(),
|
||||
bool VisitDeclsOnly = false,
|
||||
PostChildrenVisitorTy PostChildrenVisitor = nullptr)
|
||||
: TU(TU), AU(cxtu::getASTUnit(TU)),
|
||||
Visitor(Visitor), PostChildrenVisitor(PostChildrenVisitor),
|
||||
ClientData(ClientData),
|
||||
VisitPreprocessorLast(VisitPreprocessorLast),
|
||||
VisitIncludedEntities(VisitIncludedPreprocessingEntries),
|
||||
RegionOfInterest(RegionOfInterest),
|
||||
VisitDeclsOnly(VisitDeclsOnly),
|
||||
DI_current(nullptr), FileDI_current(nullptr)
|
||||
{
|
||||
: TU(TU), AU(cxtu::getASTUnit(TU)), Visitor(Visitor),
|
||||
PostChildrenVisitor(PostChildrenVisitor), ClientData(ClientData),
|
||||
VisitPreprocessorLast(VisitPreprocessorLast),
|
||||
VisitIncludedEntities(VisitIncludedPreprocessingEntries),
|
||||
RegionOfInterest(RegionOfInterest), VisitDeclsOnly(VisitDeclsOnly),
|
||||
DI_current(nullptr), FileDI_current(nullptr) {
|
||||
Parent.kind = CXCursor_NoDeclFound;
|
||||
Parent.data[0] = nullptr;
|
||||
Parent.data[1] = nullptr;
|
||||
@ -165,8 +168,9 @@ public:
|
||||
|
||||
~CursorVisitor() {
|
||||
// Free the pre-allocated worklists for data-recursion.
|
||||
for (SmallVectorImpl<VisitorWorkList*>::iterator
|
||||
I = WorkListCache.begin(), E = WorkListCache.end(); I != E; ++I) {
|
||||
for (SmallVectorImpl<VisitorWorkList *>::iterator I = WorkListCache.begin(),
|
||||
E = WorkListCache.end();
|
||||
I != E; ++I) {
|
||||
delete *I;
|
||||
}
|
||||
}
|
||||
@ -179,14 +183,12 @@ public:
|
||||
/// Visit declarations and preprocessed entities for the file region
|
||||
/// designated by \see RegionOfInterest.
|
||||
bool visitFileRegion();
|
||||
|
||||
|
||||
bool visitPreprocessedEntitiesInRegion();
|
||||
|
||||
bool shouldVisitIncludedEntities() const {
|
||||
return VisitIncludedEntities;
|
||||
}
|
||||
bool shouldVisitIncludedEntities() const { return VisitIncludedEntities; }
|
||||
|
||||
template<typename InputIterator>
|
||||
template <typename InputIterator>
|
||||
bool visitPreprocessedEntities(InputIterator First, InputIterator Last,
|
||||
PreprocessingRecord &PPRec,
|
||||
FileID FID = FileID());
|
||||
@ -206,7 +208,7 @@ public:
|
||||
bool VisitTagDecl(TagDecl *D);
|
||||
bool VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D);
|
||||
bool VisitClassTemplatePartialSpecializationDecl(
|
||||
ClassTemplatePartialSpecializationDecl *D);
|
||||
ClassTemplatePartialSpecializationDecl *D);
|
||||
bool VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D);
|
||||
bool VisitEnumConstantDecl(EnumConstantDecl *D);
|
||||
bool VisitDeclaratorDecl(DeclaratorDecl *DD);
|
||||
@ -244,16 +246,15 @@ public:
|
||||
bool VisitDeclarationNameInfo(DeclarationNameInfo Name);
|
||||
bool VisitNestedNameSpecifier(NestedNameSpecifier *NNS, SourceRange Range);
|
||||
bool VisitNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS);
|
||||
|
||||
|
||||
// Template visitors
|
||||
bool VisitTemplateParameters(const TemplateParameterList *Params);
|
||||
bool VisitTemplateName(TemplateName Name, SourceLocation Loc);
|
||||
bool VisitTemplateArgumentLoc(const TemplateArgumentLoc &TAL);
|
||||
|
||||
|
||||
// Type visitors
|
||||
#define ABSTRACT_TYPELOC(CLASS, PARENT)
|
||||
#define TYPELOC(CLASS, PARENT) \
|
||||
bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
|
||||
#define TYPELOC(CLASS, PARENT) bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
|
||||
#include "clang/AST/TypeLocNodes.def"
|
||||
|
||||
bool VisitTagTypeLoc(TagTypeLoc TL);
|
||||
@ -270,8 +271,7 @@ private:
|
||||
Optional<bool> handleDeclForVisitation(const Decl *D);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace cxcursor
|
||||
} // namespace clang
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user