diff options
| author | Ted Kremenek <kremenek@apple.com> | 2010-11-16 08:15:36 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2010-11-16 08:15:36 +0000 |
| commit | 915542850b7bd6d8b9e3ff6535f38ce8f73bb8dd (patch) | |
| tree | 03513c05a6d5259c6a82e075fa49e916553e039b /clang/tools/libclang/CXCursor.h | |
| parent | 9813d3221d7d533032c44c2019e8614075d1a6c0 (diff) | |
| download | bcm5719-llvm-915542850b7bd6d8b9e3ff6535f38ce8f73bb8dd.tar.gz bcm5719-llvm-915542850b7bd6d8b9e3ff6535f38ce8f73bb8dd.zip | |
Change CXTranslationUnit to not directly cast to an ASTUnit*,
but to wrap both an ASTUnit and a "string pool"
that will be used for fast USR generation.
This requires a bunch of mechanical changes, as
there was a ton of code that assumed that CXTranslationUnit
and ASTUnit* were the same.
Along with this change, introduce CXStringBuf,
which provides an llvm::SmallVector<char> backing
for repeatedly generating CXStrings without a huge
amount of malloc() traffic. This requires making
some changes to the representation of CXString
by renaming a few fields (but keeping the size
of the object the same).
llvm-svn: 119337
Diffstat (limited to 'clang/tools/libclang/CXCursor.h')
| -rw-r--r-- | clang/tools/libclang/CXCursor.h | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/clang/tools/libclang/CXCursor.h b/clang/tools/libclang/CXCursor.h index 7e518edef96..11f2500fb14 100644 --- a/clang/tools/libclang/CXCursor.h +++ b/clang/tools/libclang/CXCursor.h @@ -44,16 +44,18 @@ class TypeDecl; namespace cxcursor { -CXCursor MakeCXCursor(const clang::Attr *A, clang::Decl *Parent, ASTUnit *TU); -CXCursor MakeCXCursor(clang::Decl *D, ASTUnit *TU, +CXCursor MakeCXCursor(const clang::Attr *A, clang::Decl *Parent, + CXTranslationUnit TU); +CXCursor MakeCXCursor(clang::Decl *D, CXTranslationUnit TU, bool FirstInDeclGroup = true); -CXCursor MakeCXCursor(clang::Stmt *S, clang::Decl *Parent, ASTUnit *TU); +CXCursor MakeCXCursor(clang::Stmt *S, clang::Decl *Parent, + CXTranslationUnit TU); CXCursor MakeCXCursorInvalid(CXCursorKind K); /// \brief Create an Objective-C superclass reference at the given location. CXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super, SourceLocation Loc, - ASTUnit *TU); + CXTranslationUnit TU); /// \brief Unpack an ObjCSuperClassRef cursor into the interface it references /// and optionally the location where the reference occurred. @@ -62,7 +64,7 @@ std::pair<ObjCInterfaceDecl *, SourceLocation> /// \brief Create an Objective-C protocol reference at the given location. CXCursor MakeCursorObjCProtocolRef(ObjCProtocolDecl *Proto, SourceLocation Loc, - ASTUnit *TU); + CXTranslationUnit TU); /// \brief Unpack an ObjCProtocolRef cursor into the protocol it references /// and optionally the location where the reference occurred. @@ -71,7 +73,7 @@ std::pair<ObjCProtocolDecl *, SourceLocation> /// \brief Create an Objective-C class reference at the given location. CXCursor MakeCursorObjCClassRef(ObjCInterfaceDecl *Class, SourceLocation Loc, - ASTUnit *TU); + CXTranslationUnit TU); /// \brief Unpack an ObjCClassRef cursor into the class it references /// and optionally the location where the reference occurred. @@ -79,7 +81,8 @@ std::pair<ObjCInterfaceDecl *, SourceLocation> getCursorObjCClassRef(CXCursor C); /// \brief Create a type reference at the given location. -CXCursor MakeCursorTypeRef(TypeDecl *Type, SourceLocation Loc, ASTUnit *TU); +CXCursor MakeCursorTypeRef(TypeDecl *Type, SourceLocation Loc, + CXTranslationUnit TU); /// \brief Unpack a TypeRef cursor into the class it references /// and optionally the location where the reference occurred. @@ -87,7 +90,7 @@ std::pair<TypeDecl *, SourceLocation> getCursorTypeRef(CXCursor C); /// \brief Create a reference to a template at the given location. CXCursor MakeCursorTemplateRef(TemplateDecl *Template, SourceLocation Loc, - ASTUnit *TU); + CXTranslationUnit TU); /// \brief Unpack a TemplateRef cursor into the template it references and /// the location where the reference occurred. @@ -95,7 +98,8 @@ std::pair<TemplateDecl *, SourceLocation> getCursorTemplateRef(CXCursor C); /// \brief Create a reference to a namespace or namespace alias at the given /// location. -CXCursor MakeCursorNamespaceRef(NamedDecl *NS, SourceLocation Loc, ASTUnit *TU); +CXCursor MakeCursorNamespaceRef(NamedDecl *NS, SourceLocation Loc, + CXTranslationUnit TU); /// \brief Unpack a NamespaceRef cursor into the namespace or namespace alias /// it references and the location where the reference occurred. @@ -103,62 +107,68 @@ std::pair<NamedDecl *, SourceLocation> getCursorNamespaceRef(CXCursor C); /// \brief Create a reference to a field at the given location. CXCursor MakeCursorMemberRef(FieldDecl *Field, SourceLocation Loc, - ASTUnit *TU); + CXTranslationUnit 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); /// \brief Create a CXX base specifier cursor. -CXCursor MakeCursorCXXBaseSpecifier(CXXBaseSpecifier *B, ASTUnit *TU); +CXCursor MakeCursorCXXBaseSpecifier(CXXBaseSpecifier *B, + CXTranslationUnit TU); /// \brief Unpack a CXXBaseSpecifier cursor into a CXXBaseSpecifier. CXXBaseSpecifier *getCursorCXXBaseSpecifier(CXCursor C); /// \brief Create a preprocessing directive cursor. -CXCursor MakePreprocessingDirectiveCursor(SourceRange Range, ASTUnit *TU); +CXCursor MakePreprocessingDirectiveCursor(SourceRange Range, + CXTranslationUnit TU); /// \brief Unpack a given preprocessing directive to retrieve its source range. SourceRange getCursorPreprocessingDirective(CXCursor C); /// \brief Create a macro definition cursor. -CXCursor MakeMacroDefinitionCursor(MacroDefinition *, ASTUnit *TU); +CXCursor MakeMacroDefinitionCursor(MacroDefinition *, CXTranslationUnit TU); /// \brief Unpack a given macro definition cursor to retrieve its /// source range. MacroDefinition *getCursorMacroDefinition(CXCursor C); /// \brief Create a macro instantiation cursor. -CXCursor MakeMacroInstantiationCursor(MacroInstantiation *, ASTUnit *TU); +CXCursor MakeMacroInstantiationCursor(MacroInstantiation *, + CXTranslationUnit TU); /// \brief Unpack a given macro instantiation cursor to retrieve its /// source range. MacroInstantiation *getCursorMacroInstantiation(CXCursor C); /// \brief Create an inclusion directive cursor. -CXCursor MakeInclusionDirectiveCursor(InclusionDirective *, ASTUnit *TU); +CXCursor MakeInclusionDirectiveCursor(InclusionDirective *, + CXTranslationUnit TU); /// \brief Unpack a given inclusion directive cursor to retrieve its /// source range. InclusionDirective *getCursorInclusionDirective(CXCursor C); /// \brief Create a label reference at the given location. -CXCursor MakeCursorLabelRef(LabelStmt *Label, SourceLocation Loc, ASTUnit *TU); +CXCursor MakeCursorLabelRef(LabelStmt *Label, SourceLocation Loc, + CXTranslationUnit 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); /// \brief Create a overloaded declaration reference cursor for an expression. -CXCursor MakeCursorOverloadedDeclRef(OverloadExpr *E, ASTUnit *TU); +CXCursor MakeCursorOverloadedDeclRef(OverloadExpr *E, CXTranslationUnit TU); /// \brief Create a overloaded declaration reference cursor for a declaration. CXCursor MakeCursorOverloadedDeclRef(Decl *D, SourceLocation Location, - ASTUnit *TU); + CXTranslationUnit TU); /// \brief Create a overloaded declaration reference cursor for a template name. CXCursor MakeCursorOverloadedDeclRef(TemplateName Template, - SourceLocation Location, ASTUnit *TU); + SourceLocation Location, + CXTranslationUnit TU); /// \brief Internal storage for an overloaded declaration reference cursor; typedef llvm::PointerUnion3<OverloadExpr *, Decl *, @@ -177,6 +187,7 @@ Attr *getCursorAttr(CXCursor Cursor); ASTContext &getCursorContext(CXCursor Cursor); ASTUnit *getCursorASTUnit(CXCursor Cursor); +CXTranslationUnit getCursorTU(CXCursor Cursor); bool operator==(CXCursor X, CXCursor Y); |

