Properly handle temporaries that are created in a AsmStmt.
[clang.git] / tools / libclang / CXCursor.h
blob7e518edef9699d201e738ee00f91ab1226c52159
1 //===- CXCursor.h - Routines for manipulating CXCursors -------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines routines for manipulating CXCursors.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_CXCURSOR_H
15 #define LLVM_CLANG_CXCURSOR_H
17 #include "clang-c/Index.h"
18 #include "clang/Basic/SourceLocation.h"
19 #include "llvm/ADT/PointerUnion.h"
20 #include <utility>
22 namespace clang {
24 class ASTContext;
25 class ASTUnit;
26 class Attr;
27 class CXXBaseSpecifier;
28 class Decl;
29 class Expr;
30 class FieldDecl;
31 class InclusionDirective;
32 class LabelStmt;
33 class MacroDefinition;
34 class MacroInstantiation;
35 class NamedDecl;
36 class ObjCInterfaceDecl;
37 class ObjCProtocolDecl;
38 class OverloadedTemplateStorage;
39 class OverloadExpr;
40 class Stmt;
41 class TemplateDecl;
42 class TemplateName;
43 class TypeDecl;
45 namespace cxcursor {
47 CXCursor MakeCXCursor(const clang::Attr *A, clang::Decl *Parent, ASTUnit *TU);
48 CXCursor MakeCXCursor(clang::Decl *D, ASTUnit *TU,
49 bool FirstInDeclGroup = true);
50 CXCursor MakeCXCursor(clang::Stmt *S, clang::Decl *Parent, ASTUnit *TU);
51 CXCursor MakeCXCursorInvalid(CXCursorKind K);
53 /// \brief Create an Objective-C superclass reference at the given location.
54 CXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super,
55 SourceLocation Loc,
56 ASTUnit *TU);
58 /// \brief Unpack an ObjCSuperClassRef cursor into the interface it references
59 /// and optionally the location where the reference occurred.
60 std::pair<ObjCInterfaceDecl *, SourceLocation>
61 getCursorObjCSuperClassRef(CXCursor C);
63 /// \brief Create an Objective-C protocol reference at the given location.
64 CXCursor MakeCursorObjCProtocolRef(ObjCProtocolDecl *Proto, SourceLocation Loc,
65 ASTUnit *TU);
67 /// \brief Unpack an ObjCProtocolRef cursor into the protocol it references
68 /// and optionally the location where the reference occurred.
69 std::pair<ObjCProtocolDecl *, SourceLocation>
70 getCursorObjCProtocolRef(CXCursor C);
72 /// \brief Create an Objective-C class reference at the given location.
73 CXCursor MakeCursorObjCClassRef(ObjCInterfaceDecl *Class, SourceLocation Loc,
74 ASTUnit *TU);
76 /// \brief Unpack an ObjCClassRef cursor into the class it references
77 /// and optionally the location where the reference occurred.
78 std::pair<ObjCInterfaceDecl *, SourceLocation>
79 getCursorObjCClassRef(CXCursor C);
81 /// \brief Create a type reference at the given location.
82 CXCursor MakeCursorTypeRef(TypeDecl *Type, SourceLocation Loc, ASTUnit *TU);
84 /// \brief Unpack a TypeRef cursor into the class it references
85 /// and optionally the location where the reference occurred.
86 std::pair<TypeDecl *, SourceLocation> getCursorTypeRef(CXCursor C);
88 /// \brief Create a reference to a template at the given location.
89 CXCursor MakeCursorTemplateRef(TemplateDecl *Template, SourceLocation Loc,
90 ASTUnit *TU);
92 /// \brief Unpack a TemplateRef cursor into the template it references and
93 /// the location where the reference occurred.
94 std::pair<TemplateDecl *, SourceLocation> getCursorTemplateRef(CXCursor C);
96 /// \brief Create a reference to a namespace or namespace alias at the given
97 /// location.
98 CXCursor MakeCursorNamespaceRef(NamedDecl *NS, SourceLocation Loc, ASTUnit *TU);
100 /// \brief Unpack a NamespaceRef cursor into the namespace or namespace alias
101 /// it references and the location where the reference occurred.
102 std::pair<NamedDecl *, SourceLocation> getCursorNamespaceRef(CXCursor C);
104 /// \brief Create a reference to a field at the given location.
105 CXCursor MakeCursorMemberRef(FieldDecl *Field, SourceLocation Loc,
106 ASTUnit *TU);
108 /// \brief Unpack a MemberRef cursor into the field it references and the
109 /// location where the reference occurred.
110 std::pair<FieldDecl *, SourceLocation> getCursorMemberRef(CXCursor C);
112 /// \brief Create a CXX base specifier cursor.
113 CXCursor MakeCursorCXXBaseSpecifier(CXXBaseSpecifier *B, ASTUnit *TU);
115 /// \brief Unpack a CXXBaseSpecifier cursor into a CXXBaseSpecifier.
116 CXXBaseSpecifier *getCursorCXXBaseSpecifier(CXCursor C);
118 /// \brief Create a preprocessing directive cursor.
119 CXCursor MakePreprocessingDirectiveCursor(SourceRange Range, ASTUnit *TU);
121 /// \brief Unpack a given preprocessing directive to retrieve its source range.
122 SourceRange getCursorPreprocessingDirective(CXCursor C);
124 /// \brief Create a macro definition cursor.
125 CXCursor MakeMacroDefinitionCursor(MacroDefinition *, ASTUnit *TU);
127 /// \brief Unpack a given macro definition cursor to retrieve its
128 /// source range.
129 MacroDefinition *getCursorMacroDefinition(CXCursor C);
131 /// \brief Create a macro instantiation cursor.
132 CXCursor MakeMacroInstantiationCursor(MacroInstantiation *, ASTUnit *TU);
134 /// \brief Unpack a given macro instantiation cursor to retrieve its
135 /// source range.
136 MacroInstantiation *getCursorMacroInstantiation(CXCursor C);
138 /// \brief Create an inclusion directive cursor.
139 CXCursor MakeInclusionDirectiveCursor(InclusionDirective *, ASTUnit *TU);
141 /// \brief Unpack a given inclusion directive cursor to retrieve its
142 /// source range.
143 InclusionDirective *getCursorInclusionDirective(CXCursor C);
145 /// \brief Create a label reference at the given location.
146 CXCursor MakeCursorLabelRef(LabelStmt *Label, SourceLocation Loc, ASTUnit *TU);
148 /// \brief Unpack a label reference into the label statement it refers to and
149 /// the location of the reference.
150 std::pair<LabelStmt *, SourceLocation> getCursorLabelRef(CXCursor C);
152 /// \brief Create a overloaded declaration reference cursor for an expression.
153 CXCursor MakeCursorOverloadedDeclRef(OverloadExpr *E, ASTUnit *TU);
155 /// \brief Create a overloaded declaration reference cursor for a declaration.
156 CXCursor MakeCursorOverloadedDeclRef(Decl *D, SourceLocation Location,
157 ASTUnit *TU);
159 /// \brief Create a overloaded declaration reference cursor for a template name.
160 CXCursor MakeCursorOverloadedDeclRef(TemplateName Template,
161 SourceLocation Location, ASTUnit *TU);
163 /// \brief Internal storage for an overloaded declaration reference cursor;
164 typedef llvm::PointerUnion3<OverloadExpr *, Decl *,
165 OverloadedTemplateStorage *>
166 OverloadedDeclRefStorage;
168 /// \brief Unpack an overloaded declaration reference into an expression,
169 /// declaration, or template name along with the source location.
170 std::pair<OverloadedDeclRefStorage, SourceLocation>
171 getCursorOverloadedDeclRef(CXCursor C);
173 Decl *getCursorDecl(CXCursor Cursor);
174 Expr *getCursorExpr(CXCursor Cursor);
175 Stmt *getCursorStmt(CXCursor Cursor);
176 Attr *getCursorAttr(CXCursor Cursor);
178 ASTContext &getCursorContext(CXCursor Cursor);
179 ASTUnit *getCursorASTUnit(CXCursor Cursor);
181 bool operator==(CXCursor X, CXCursor Y);
183 inline bool operator!=(CXCursor X, CXCursor Y) {
184 return !(X == Y);
187 /// \brief Return true if the cursor represents a declaration that is the
188 /// first in a declaration group.
189 bool isFirstInDeclGroup(CXCursor C);
191 }} // end namespace: clang::cxcursor
193 #endif