2010-01-16 04:35:54 +08:00
|
|
|
//===- CXCursor.h - Routines for manipulating CXCursors -------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines routines for manipulating CXCursors.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CLANG_CXCURSOR_H
|
2010-01-26 05:09:34 +08:00
|
|
|
#define LLVM_CLANG_CXCURSOR_H
|
2010-01-16 04:35:54 +08:00
|
|
|
|
|
|
|
#include "clang-c/Index.h"
|
2010-01-16 22:00:32 +08:00
|
|
|
#include "clang/Basic/SourceLocation.h"
|
2010-09-14 06:52:57 +08:00
|
|
|
#include "llvm/ADT/PointerUnion.h"
|
2010-01-16 22:00:32 +08:00
|
|
|
#include <utility>
|
2010-01-16 04:35:54 +08:00
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
|
2010-01-19 07:41:10 +08:00
|
|
|
class ASTContext;
|
2010-01-21 07:57:43 +08:00
|
|
|
class ASTUnit;
|
2010-02-18 11:09:07 +08:00
|
|
|
class Attr;
|
2010-08-28 05:34:58 +08:00
|
|
|
class CXXBaseSpecifier;
|
2010-01-16 04:35:54 +08:00
|
|
|
class Decl;
|
2010-01-16 05:56:13 +08:00
|
|
|
class Expr;
|
2010-09-10 05:42:20 +08:00
|
|
|
class FieldDecl;
|
2010-10-21 06:00:55 +08:00
|
|
|
class InclusionDirective;
|
2010-09-10 08:22:18 +08:00
|
|
|
class LabelStmt;
|
2010-03-19 02:04:21 +08:00
|
|
|
class MacroDefinition;
|
Introduce the notion of a "preprocessing record", which keeps track of
the macro definitions and macro instantiations that are found
during preprocessing. Preprocessing records are *not* generated by
default; rather, we provide a PPCallbacks subclass that hooks into the
existing callback mechanism to record this activity.
The only client of preprocessing records is CIndex, which keeps track
of macro definitions and instantations so that they can be exposed via
cursors. At present, only token annotation uses these facilities, and
only for macro instantiations; both will change in the near
future. However, with this change, token annotation properly annotates
macro instantiations that do not produce any tokens and instantiations
of macros that are later undef'd, improving our consistency.
Preprocessing directives that are not macro definitions are still
handled by clang_annotateTokens() via re-lexing, so that we don't have
to track every preprocessing directive in the preprocessing record.
Performance impact of preprocessing records is still TBD, although it
is limited to CIndex and therefore out of the path of the main compiler.
llvm-svn: 98836
2010-03-19 01:52:52 +08:00
|
|
|
class MacroInstantiation;
|
2010-01-16 05:56:13 +08:00
|
|
|
class NamedDecl;
|
2010-01-16 22:00:32 +08:00
|
|
|
class ObjCInterfaceDecl;
|
2010-01-16 23:44:18 +08:00
|
|
|
class ObjCProtocolDecl;
|
2010-09-14 06:52:57 +08:00
|
|
|
class OverloadedTemplateStorage;
|
|
|
|
class OverloadExpr;
|
2010-01-16 04:35:54 +08:00
|
|
|
class Stmt;
|
2010-09-01 04:37:03 +08:00
|
|
|
class TemplateDecl;
|
2010-09-14 06:52:57 +08:00
|
|
|
class TemplateName;
|
2010-01-22 00:28:34 +08:00
|
|
|
class TypeDecl;
|
2010-09-14 06:52:57 +08:00
|
|
|
|
2010-01-16 04:35:54 +08:00
|
|
|
namespace cxcursor {
|
|
|
|
|
2010-02-18 11:09:07 +08:00
|
|
|
CXCursor MakeCXCursor(const clang::Attr *A, clang::Decl *Parent, ASTUnit *TU);
|
2010-01-21 07:57:43 +08:00
|
|
|
CXCursor MakeCXCursor(clang::Decl *D, ASTUnit *TU);
|
2010-02-18 11:09:07 +08:00
|
|
|
CXCursor MakeCXCursor(clang::Stmt *S, clang::Decl *Parent, ASTUnit *TU);
|
|
|
|
CXCursor MakeCXCursorInvalid(CXCursorKind K);
|
2010-01-16 04:35:54 +08:00
|
|
|
|
2010-01-16 22:00:32 +08:00
|
|
|
/// \brief Create an Objective-C superclass reference at the given location.
|
|
|
|
CXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super,
|
2010-01-21 07:57:43 +08:00
|
|
|
SourceLocation Loc,
|
|
|
|
ASTUnit *TU);
|
2010-01-16 22:00:32 +08:00
|
|
|
|
|
|
|
/// \brief Unpack an ObjCSuperClassRef cursor into the interface it references
|
|
|
|
/// and optionally the location where the reference occurred.
|
|
|
|
std::pair<ObjCInterfaceDecl *, SourceLocation>
|
2010-01-16 23:44:18 +08:00
|
|
|
getCursorObjCSuperClassRef(CXCursor C);
|
|
|
|
|
|
|
|
/// \brief Create an Objective-C protocol reference at the given location.
|
2010-01-21 07:57:43 +08:00
|
|
|
CXCursor MakeCursorObjCProtocolRef(ObjCProtocolDecl *Proto, SourceLocation Loc,
|
|
|
|
ASTUnit *TU);
|
2010-01-16 23:44:18 +08:00
|
|
|
|
|
|
|
/// \brief Unpack an ObjCProtocolRef cursor into the protocol it references
|
|
|
|
/// and optionally the location where the reference occurred.
|
|
|
|
std::pair<ObjCProtocolDecl *, SourceLocation>
|
|
|
|
getCursorObjCProtocolRef(CXCursor C);
|
2010-01-16 22:00:32 +08:00
|
|
|
|
2010-01-17 01:14:40 +08:00
|
|
|
/// \brief Create an Objective-C class reference at the given location.
|
2010-01-21 07:57:43 +08:00
|
|
|
CXCursor MakeCursorObjCClassRef(ObjCInterfaceDecl *Class, SourceLocation Loc,
|
|
|
|
ASTUnit *TU);
|
2010-01-17 01:14:40 +08:00
|
|
|
|
|
|
|
/// \brief Unpack an ObjCClassRef cursor into the class it references
|
|
|
|
/// and optionally the location where the reference occurred.
|
|
|
|
std::pair<ObjCInterfaceDecl *, SourceLocation>
|
|
|
|
getCursorObjCClassRef(CXCursor C);
|
|
|
|
|
2010-01-22 00:28:34 +08:00
|
|
|
/// \brief Create a type reference at the given location.
|
|
|
|
CXCursor MakeCursorTypeRef(TypeDecl *Type, SourceLocation Loc, ASTUnit *TU);
|
2010-09-01 04:37:03 +08:00
|
|
|
|
2010-01-22 00:28:34 +08:00
|
|
|
/// \brief Unpack a TypeRef cursor into the class it references
|
|
|
|
/// and optionally the location where the reference occurred.
|
|
|
|
std::pair<TypeDecl *, SourceLocation> getCursorTypeRef(CXCursor C);
|
|
|
|
|
2010-09-01 04:37:03 +08:00
|
|
|
/// \brief Create a reference to a template at the given location.
|
|
|
|
CXCursor MakeCursorTemplateRef(TemplateDecl *Template, SourceLocation Loc,
|
|
|
|
ASTUnit *TU);
|
|
|
|
|
|
|
|
/// \brief Unpack a TemplateRef cursor into the template it references and
|
|
|
|
/// the location where the reference occurred.
|
|
|
|
std::pair<TemplateDecl *, SourceLocation> getCursorTemplateRef(CXCursor C);
|
2010-09-01 07:48:11 +08:00
|
|
|
|
|
|
|
/// \brief Create a reference to a namespace or namespace alias at the given
|
|
|
|
/// location.
|
|
|
|
CXCursor MakeCursorNamespaceRef(NamedDecl *NS, SourceLocation Loc, ASTUnit *TU);
|
|
|
|
|
|
|
|
/// \brief Unpack a NamespaceRef cursor into the namespace or namespace alias
|
|
|
|
/// it references and the location where the reference occurred.
|
|
|
|
std::pair<NamedDecl *, SourceLocation> getCursorNamespaceRef(CXCursor C);
|
|
|
|
|
2010-09-10 05:42:20 +08:00
|
|
|
/// \brief Create a reference to a field at the given location.
|
|
|
|
CXCursor MakeCursorMemberRef(FieldDecl *Field, SourceLocation Loc,
|
|
|
|
ASTUnit *TU);
|
|
|
|
|
|
|
|
/// \brief Unpack a MemberRef cursor into the field it references and the
|
|
|
|
/// location where the reference occurred.
|
|
|
|
std::pair<FieldDecl *, SourceLocation> getCursorMemberRef(CXCursor C);
|
|
|
|
|
2010-08-28 05:34:58 +08:00
|
|
|
/// \brief Create a CXX base specifier cursor.
|
|
|
|
CXCursor MakeCursorCXXBaseSpecifier(CXXBaseSpecifier *B, ASTUnit *TU);
|
|
|
|
|
|
|
|
/// \brief Unpack a CXXBaseSpecifier cursor into a CXXBaseSpecifier.
|
|
|
|
CXXBaseSpecifier *getCursorCXXBaseSpecifier(CXCursor C);
|
|
|
|
|
2010-03-18 08:42:48 +08:00
|
|
|
/// \brief Create a preprocessing directive cursor.
|
|
|
|
CXCursor MakePreprocessingDirectiveCursor(SourceRange Range, ASTUnit *TU);
|
|
|
|
|
|
|
|
/// \brief Unpack a given preprocessing directive to retrieve its source range.
|
|
|
|
SourceRange getCursorPreprocessingDirective(CXCursor C);
|
2010-03-18 23:23:44 +08:00
|
|
|
|
2010-03-19 02:04:21 +08:00
|
|
|
/// \brief Create a macro definition cursor.
|
|
|
|
CXCursor MakeMacroDefinitionCursor(MacroDefinition *, ASTUnit *TU);
|
|
|
|
|
|
|
|
/// \brief Unpack a given macro definition cursor to retrieve its
|
|
|
|
/// source range.
|
|
|
|
MacroDefinition *getCursorMacroDefinition(CXCursor C);
|
|
|
|
|
2010-03-18 23:23:44 +08:00
|
|
|
/// \brief Create a macro instantiation cursor.
|
Introduce the notion of a "preprocessing record", which keeps track of
the macro definitions and macro instantiations that are found
during preprocessing. Preprocessing records are *not* generated by
default; rather, we provide a PPCallbacks subclass that hooks into the
existing callback mechanism to record this activity.
The only client of preprocessing records is CIndex, which keeps track
of macro definitions and instantations so that they can be exposed via
cursors. At present, only token annotation uses these facilities, and
only for macro instantiations; both will change in the near
future. However, with this change, token annotation properly annotates
macro instantiations that do not produce any tokens and instantiations
of macros that are later undef'd, improving our consistency.
Preprocessing directives that are not macro definitions are still
handled by clang_annotateTokens() via re-lexing, so that we don't have
to track every preprocessing directive in the preprocessing record.
Performance impact of preprocessing records is still TBD, although it
is limited to CIndex and therefore out of the path of the main compiler.
llvm-svn: 98836
2010-03-19 01:52:52 +08:00
|
|
|
CXCursor MakeMacroInstantiationCursor(MacroInstantiation *, ASTUnit *TU);
|
2010-03-18 23:23:44 +08:00
|
|
|
|
|
|
|
/// \brief Unpack a given macro instantiation cursor to retrieve its
|
|
|
|
/// source range.
|
Introduce the notion of a "preprocessing record", which keeps track of
the macro definitions and macro instantiations that are found
during preprocessing. Preprocessing records are *not* generated by
default; rather, we provide a PPCallbacks subclass that hooks into the
existing callback mechanism to record this activity.
The only client of preprocessing records is CIndex, which keeps track
of macro definitions and instantations so that they can be exposed via
cursors. At present, only token annotation uses these facilities, and
only for macro instantiations; both will change in the near
future. However, with this change, token annotation properly annotates
macro instantiations that do not produce any tokens and instantiations
of macros that are later undef'd, improving our consistency.
Preprocessing directives that are not macro definitions are still
handled by clang_annotateTokens() via re-lexing, so that we don't have
to track every preprocessing directive in the preprocessing record.
Performance impact of preprocessing records is still TBD, although it
is limited to CIndex and therefore out of the path of the main compiler.
llvm-svn: 98836
2010-03-19 01:52:52 +08:00
|
|
|
MacroInstantiation *getCursorMacroInstantiation(CXCursor C);
|
2010-03-18 23:23:44 +08:00
|
|
|
|
2010-10-21 06:00:55 +08:00
|
|
|
/// \brief Create an inclusion directive cursor.
|
|
|
|
CXCursor MakeInclusionDirectiveCursor(InclusionDirective *, ASTUnit *TU);
|
|
|
|
|
|
|
|
/// \brief Unpack a given inclusion directive cursor to retrieve its
|
|
|
|
/// source range.
|
|
|
|
InclusionDirective *getCursorInclusionDirective(CXCursor C);
|
|
|
|
|
2010-09-10 08:22:18 +08:00
|
|
|
/// \brief Create a label reference at the given location.
|
|
|
|
CXCursor MakeCursorLabelRef(LabelStmt *Label, SourceLocation Loc, ASTUnit *TU);
|
|
|
|
|
|
|
|
/// \brief Unpack a label reference into the label statement it refers to and
|
|
|
|
/// the location of the reference.
|
|
|
|
std::pair<LabelStmt *, SourceLocation> getCursorLabelRef(CXCursor C);
|
2010-09-14 06:52:57 +08:00
|
|
|
|
|
|
|
/// \brief Create a overloaded declaration reference cursor for an expression.
|
|
|
|
CXCursor MakeCursorOverloadedDeclRef(OverloadExpr *E, ASTUnit *TU);
|
|
|
|
|
|
|
|
/// \brief Create a overloaded declaration reference cursor for a declaration.
|
|
|
|
CXCursor MakeCursorOverloadedDeclRef(Decl *D, SourceLocation Location,
|
|
|
|
ASTUnit *TU);
|
|
|
|
|
|
|
|
/// \brief Create a overloaded declaration reference cursor for a template name.
|
|
|
|
CXCursor MakeCursorOverloadedDeclRef(TemplateName Template,
|
|
|
|
SourceLocation Location, ASTUnit *TU);
|
|
|
|
|
|
|
|
/// \brief Internal storage for an overloaded declaration reference cursor;
|
|
|
|
typedef llvm::PointerUnion3<OverloadExpr *, Decl *,
|
|
|
|
OverloadedTemplateStorage *>
|
|
|
|
OverloadedDeclRefStorage;
|
|
|
|
|
|
|
|
/// \brief Unpack an overloaded declaration reference into an expression,
|
|
|
|
/// declaration, or template name along with the source location.
|
|
|
|
std::pair<OverloadedDeclRefStorage, SourceLocation>
|
|
|
|
getCursorOverloadedDeclRef(CXCursor C);
|
2010-09-10 08:22:18 +08:00
|
|
|
|
2010-01-16 05:56:13 +08:00
|
|
|
Decl *getCursorDecl(CXCursor Cursor);
|
|
|
|
Expr *getCursorExpr(CXCursor Cursor);
|
|
|
|
Stmt *getCursorStmt(CXCursor Cursor);
|
2010-08-26 09:42:22 +08:00
|
|
|
Attr *getCursorAttr(CXCursor Cursor);
|
|
|
|
|
2010-01-19 07:41:10 +08:00
|
|
|
ASTContext &getCursorContext(CXCursor Cursor);
|
2010-01-21 07:57:43 +08:00
|
|
|
ASTUnit *getCursorASTUnit(CXCursor Cursor);
|
2010-01-16 05:56:13 +08:00
|
|
|
|
|
|
|
bool operator==(CXCursor X, CXCursor Y);
|
|
|
|
|
|
|
|
inline bool operator!=(CXCursor X, CXCursor Y) {
|
|
|
|
return !(X == Y);
|
|
|
|
}
|
|
|
|
|
2010-01-16 04:35:54 +08:00
|
|
|
}} // end namespace: clang::cxcursor
|
|
|
|
|
|
|
|
#endif
|