From: John McCall Date: Wed, 25 Aug 2010 06:19:51 +0000 (+0000) Subject: Teach Sema to live without CodeCompleteConsumer.h. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0a2c5e256abb4dc031c21fe4dc92c4f3afe9947c;p=clang Teach Sema to live without CodeCompleteConsumer.h. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112028 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index 614807b61e..e3fd4b37ed 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -17,6 +17,7 @@ #include "clang/Index/ASTLocation.h" #include "clang/Serialization/ASTBitCodes.h" #include "clang/Sema/Sema.h" +#include "clang/Sema/CodeCompleteConsumer.h" #include "clang/Lex/PreprocessingRecord.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/FileManager.h" diff --git a/include/clang/Sema/CodeCompleteConsumer.h b/include/clang/Sema/CodeCompleteConsumer.h index b4a0301dbf..3bb9df34bc 100644 --- a/include/clang/Sema/CodeCompleteConsumer.h +++ b/include/clang/Sema/CodeCompleteConsumer.h @@ -22,7 +22,7 @@ #include namespace llvm { -class raw_ostream; + class raw_ostream; } namespace clang { @@ -109,7 +109,7 @@ QualType getDeclUsageType(ASTContext &C, NamedDecl *ND); /// of this macro is a pointer type. unsigned getMacroUsagePriority(llvm::StringRef MacroName, bool PreferredTypeIsPointer = false); - + class FunctionDecl; class FunctionType; class FunctionTemplateDecl; @@ -428,173 +428,175 @@ public: /// \returns true if successful, false otherwise. bool Deserialize(const char *&Str, const char *StrEnd); }; - -llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, - const CodeCompletionString &CCS); - -/// \brief Abstract interface for a consumer of code-completion -/// information. -class CodeCompleteConsumer { -protected: - /// \brief Whether to include macros in the code-completion results. - bool IncludeMacros; - /// \brief Whether to include code patterns (such as for loops) within - /// the completion results. - bool IncludeCodePatterns; - - /// \brief Whether to include global (top-level) declarations and names in - /// the completion results. - bool IncludeGlobals; - - /// \brief Whether the output format for the code-completion consumer is - /// binary. - bool OutputIsBinary; - +/// \brief Captures a result of code completion. +class CodeCompletionResult { public: - /// \brief Captures a result of code completion. - struct Result { - /// \brief Describes the kind of result generated. - enum ResultKind { - RK_Declaration = 0, //< Refers to a declaration - RK_Keyword, //< Refers to a keyword or symbol. - RK_Macro, //< Refers to a macro - RK_Pattern //< Refers to a precomputed pattern. - }; + /// \brief Describes the kind of result generated. + enum ResultKind { + RK_Declaration = 0, //< Refers to a declaration + RK_Keyword, //< Refers to a keyword or symbol. + RK_Macro, //< Refers to a macro + RK_Pattern //< Refers to a precomputed pattern. + }; - /// \brief The kind of result stored here. - ResultKind Kind; + /// \brief The kind of result stored here. + ResultKind Kind; - union { - /// \brief When Kind == RK_Declaration, the declaration we are referring - /// to. - NamedDecl *Declaration; + union { + /// \brief When Kind == RK_Declaration, the declaration we are referring + /// to. + NamedDecl *Declaration; - /// \brief When Kind == RK_Keyword, the string representing the keyword - /// or symbol's spelling. - const char *Keyword; + /// \brief When Kind == RK_Keyword, the string representing the keyword + /// or symbol's spelling. + const char *Keyword; - /// \brief When Kind == RK_Pattern, the code-completion string that - /// describes the completion text to insert. - CodeCompletionString *Pattern; + /// \brief When Kind == RK_Pattern, the code-completion string that + /// describes the completion text to insert. + CodeCompletionString *Pattern; - /// \brief When Kind == RK_Macro, the identifier that refers to a macro. - IdentifierInfo *Macro; - }; + /// \brief When Kind == RK_Macro, the identifier that refers to a macro. + IdentifierInfo *Macro; + }; - /// \brief The priority of this particular code-completion result. - unsigned Priority; + /// \brief The priority of this particular code-completion result. + unsigned Priority; - /// \brief The cursor kind that describes this result. - CXCursorKind CursorKind; + /// \brief The cursor kind that describes this result. + CXCursorKind CursorKind; - /// \brief The availability of this result. - CXAvailabilityKind Availability; + /// \brief The availability of this result. + CXAvailabilityKind Availability; - /// \brief Specifies which parameter (of a function, Objective-C method, - /// macro, etc.) we should start with when formatting the result. - unsigned StartParameter; + /// \brief Specifies which parameter (of a function, Objective-C method, + /// macro, etc.) we should start with when formatting the result. + unsigned StartParameter; - /// \brief Whether this result is hidden by another name. - bool Hidden : 1; + /// \brief Whether this result is hidden by another name. + bool Hidden : 1; - /// \brief Whether this result was found via lookup into a base class. - bool QualifierIsInformative : 1; + /// \brief Whether this result was found via lookup into a base class. + bool QualifierIsInformative : 1; - /// \brief Whether this declaration is the beginning of a - /// nested-name-specifier and, therefore, should be followed by '::'. - bool StartsNestedNameSpecifier : 1; + /// \brief Whether this declaration is the beginning of a + /// nested-name-specifier and, therefore, should be followed by '::'. + bool StartsNestedNameSpecifier : 1; - /// \brief Whether all parameters (of a function, Objective-C - /// method, etc.) should be considered "informative". - bool AllParametersAreInformative : 1; + /// \brief Whether all parameters (of a function, Objective-C + /// method, etc.) should be considered "informative". + bool AllParametersAreInformative : 1; - /// \brief Whether we're completing a declaration of the given entity, - /// rather than a use of that entity. - bool DeclaringEntity : 1; + /// \brief Whether we're completing a declaration of the given entity, + /// rather than a use of that entity. + bool DeclaringEntity : 1; - /// \brief If the result should have a nested-name-specifier, this is it. - /// When \c QualifierIsInformative, the nested-name-specifier is - /// informative rather than required. - NestedNameSpecifier *Qualifier; + /// \brief If the result should have a nested-name-specifier, this is it. + /// When \c QualifierIsInformative, the nested-name-specifier is + /// informative rather than required. + NestedNameSpecifier *Qualifier; - /// \brief Build a result that refers to a declaration. - Result(NamedDecl *Declaration, - NestedNameSpecifier *Qualifier = 0, - bool QualifierIsInformative = false) - : Kind(RK_Declaration), Declaration(Declaration), - Priority(getPriorityFromDecl(Declaration)), - Availability(CXAvailability_Available), StartParameter(0), - Hidden(false), QualifierIsInformative(QualifierIsInformative), - StartsNestedNameSpecifier(false), AllParametersAreInformative(false), - DeclaringEntity(false), Qualifier(Qualifier) { - computeCursorKindAndAvailability(); - } + /// \brief Build a result that refers to a declaration. + CodeCompletionResult(NamedDecl *Declaration, + NestedNameSpecifier *Qualifier = 0, + bool QualifierIsInformative = false) + : Kind(RK_Declaration), Declaration(Declaration), + Priority(getPriorityFromDecl(Declaration)), + Availability(CXAvailability_Available), StartParameter(0), + Hidden(false), QualifierIsInformative(QualifierIsInformative), + StartsNestedNameSpecifier(false), AllParametersAreInformative(false), + DeclaringEntity(false), Qualifier(Qualifier) { + computeCursorKindAndAvailability(); + } - /// \brief Build a result that refers to a keyword or symbol. - Result(const char *Keyword, unsigned Priority = CCP_Keyword) - : Kind(RK_Keyword), Keyword(Keyword), Priority(Priority), - Availability(CXAvailability_Available), - StartParameter(0), Hidden(false), QualifierIsInformative(0), - StartsNestedNameSpecifier(false), AllParametersAreInformative(false), - DeclaringEntity(false), Qualifier(0) { - computeCursorKindAndAvailability(); - } + /// \brief Build a result that refers to a keyword or symbol. + CodeCompletionResult(const char *Keyword, unsigned Priority = CCP_Keyword) + : Kind(RK_Keyword), Keyword(Keyword), Priority(Priority), + Availability(CXAvailability_Available), + StartParameter(0), Hidden(false), QualifierIsInformative(0), + StartsNestedNameSpecifier(false), AllParametersAreInformative(false), + DeclaringEntity(false), Qualifier(0) { + computeCursorKindAndAvailability(); + } - /// \brief Build a result that refers to a macro. - Result(IdentifierInfo *Macro, unsigned Priority = CCP_Macro) - : Kind(RK_Macro), Macro(Macro), Priority(Priority), - Availability(CXAvailability_Available), StartParameter(0), - Hidden(false), QualifierIsInformative(0), - StartsNestedNameSpecifier(false), AllParametersAreInformative(false), - DeclaringEntity(false), Qualifier(0) { - computeCursorKindAndAvailability(); - } + /// \brief Build a result that refers to a macro. + CodeCompletionResult(IdentifierInfo *Macro, unsigned Priority = CCP_Macro) + : Kind(RK_Macro), Macro(Macro), Priority(Priority), + Availability(CXAvailability_Available), StartParameter(0), + Hidden(false), QualifierIsInformative(0), + StartsNestedNameSpecifier(false), AllParametersAreInformative(false), + DeclaringEntity(false), Qualifier(0) { + computeCursorKindAndAvailability(); + } - /// \brief Build a result that refers to a pattern. - Result(CodeCompletionString *Pattern, unsigned Priority = CCP_CodePattern, - CXCursorKind CursorKind = CXCursor_NotImplemented, - CXAvailabilityKind Availability = CXAvailability_Available) - : Kind(RK_Pattern), Pattern(Pattern), Priority(Priority), - CursorKind(CursorKind), Availability(Availability), StartParameter(0), - Hidden(false), QualifierIsInformative(0), - StartsNestedNameSpecifier(false), AllParametersAreInformative(false), - DeclaringEntity(false), Qualifier(0) - { - } - - /// \brief Retrieve the declaration stored in this result. - NamedDecl *getDeclaration() const { - assert(Kind == RK_Declaration && "Not a declaration result"); - return Declaration; - } + /// \brief Build a result that refers to a pattern. + CodeCompletionResult(CodeCompletionString *Pattern, + unsigned Priority = CCP_CodePattern, + CXCursorKind CursorKind = CXCursor_NotImplemented, + CXAvailabilityKind Availability = CXAvailability_Available) + : Kind(RK_Pattern), Pattern(Pattern), Priority(Priority), + CursorKind(CursorKind), Availability(Availability), StartParameter(0), + Hidden(false), QualifierIsInformative(0), + StartsNestedNameSpecifier(false), AllParametersAreInformative(false), + DeclaringEntity(false), Qualifier(0) + { + } - /// \brief Retrieve the keyword stored in this result. - const char *getKeyword() const { - assert(Kind == RK_Keyword && "Not a keyword result"); - return Keyword; - } + /// \brief Retrieve the declaration stored in this result. + NamedDecl *getDeclaration() const { + assert(Kind == RK_Declaration && "Not a declaration result"); + return Declaration; + } - /// \brief Create a new code-completion string that describes how to insert - /// this result into a program. - /// - /// \param S The semantic analysis that created the result. - /// - /// \param Result If non-NULL, the already-allocated, empty - /// code-completion string that will be populated with the - /// appropriate code completion string for this result. - CodeCompletionString *CreateCodeCompletionString(Sema &S, - CodeCompletionString *Result = 0); + /// \brief Retrieve the keyword stored in this result. + const char *getKeyword() const { + assert(Kind == RK_Keyword && "Not a keyword result"); + return Keyword; + } - void Destroy(); + /// \brief Create a new code-completion string that describes how to insert + /// this result into a program. + /// + /// \param S The semantic analysis that created the result. + /// + /// \param Result If non-NULL, the already-allocated, empty + /// code-completion string that will be populated with the + /// appropriate code completion string for this result. + CodeCompletionString *CreateCodeCompletionString(Sema &S, + CodeCompletionString *Result = 0); - /// brief Determine a base priority for the given declaration. - static unsigned getPriorityFromDecl(NamedDecl *ND); + void Destroy(); - private: - void computeCursorKindAndAvailability(); - }; + /// brief Determine a base priority for the given declaration. + static unsigned getPriorityFromDecl(NamedDecl *ND); +private: + void computeCursorKindAndAvailability(); +}; + +llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, + const CodeCompletionString &CCS); + +/// \brief Abstract interface for a consumer of code-completion +/// information. +class CodeCompleteConsumer { +protected: + /// \brief Whether to include macros in the code-completion results. + bool IncludeMacros; + + /// \brief Whether to include code patterns (such as for loops) within + /// the completion results. + bool IncludeCodePatterns; + + /// \brief Whether to include global (top-level) declarations and names in + /// the completion results. + bool IncludeGlobals; + + /// \brief Whether the output format for the code-completion consumer is + /// binary. + bool OutputIsBinary; + +public: class OverloadCandidate { public: /// \brief Describes the type of overload candidate. @@ -687,7 +689,7 @@ public: /// \brief Process the finalized code-completion results. virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, - Result *Results, + CodeCompletionResult *Results, unsigned NumResults) { } /// \param S the semantic-analyzer object for which code-completion is being @@ -703,7 +705,7 @@ public: unsigned NumCandidates) { } //@} }; - + /// \brief A simple code-completion consumer that prints the results it /// receives in a simple format. class PrintingCodeCompleteConsumer : public CodeCompleteConsumer { @@ -722,7 +724,7 @@ public: /// \brief Prints the finalized code-completion results. virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, - Result *Results, + CodeCompletionResult *Results, unsigned NumResults); virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, @@ -748,14 +750,14 @@ public: /// \brief Prints the finalized code-completion results. virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, - Result *Results, + CodeCompletionResult *Results, unsigned NumResults); virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates); }; - + } // end namespace clang #endif // LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 6c3abc4a51..73806a6266 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -17,7 +17,6 @@ #include "clang/Sema/Action.h" #include "clang/Sema/AnalysisBasedWarnings.h" -#include "clang/Sema/CodeCompleteConsumer.h" #include "clang/Sema/IdentifierResolver.h" #include "clang/Sema/ObjCMethodList.h" #include "clang/Sema/SemaDiagnostic.h" @@ -54,6 +53,8 @@ namespace clang { class ClassTemplateDecl; class ClassTemplatePartialSpecializationDecl; class ClassTemplateSpecializationDecl; + class CodeCompleteConsumer; + class CodeCompletionResult; class Decl; class DeclAccessPair; class DeclContext; @@ -4497,7 +4498,7 @@ public: MacroInfo *MacroInfo, unsigned Argument); void GatherGlobalCodeCompletions( - llvm::SmallVectorImpl &Results); + llvm::SmallVectorImpl &Results); //@} //===--------------------------------------------------------------------===// diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 117d3775c0..a22761d649 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -176,7 +176,7 @@ void ASTUnit::CacheCodeCompletionResults() { ClearCachedCompletionResults(); // Gather the set of global code completions. - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; llvm::SmallVector Results; TheSema->GatherGlobalCodeCompletions(Results); @@ -1506,7 +1506,7 @@ namespace { virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, - Result *Results, + CodeCompletionResult *Results, unsigned NumResults); virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, @@ -1520,7 +1520,7 @@ namespace { /// \brief Helper function that computes which global names are hidden by the /// local code-completion results. void CalculateHiddenNames(const CodeCompletionContext &Context, - CodeCompleteConsumer::Result *Results, + CodeCompletionResult *Results, unsigned NumResults, ASTContext &Ctx, llvm::StringSet<> &HiddenNames) { @@ -1556,7 +1556,7 @@ void CalculateHiddenNames(const CodeCompletionContext &Context, return; } - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; for (unsigned I = 0; I != NumResults; ++I) { if (Results[I].Kind != Result::RK_Declaration) continue; @@ -1590,7 +1590,7 @@ void CalculateHiddenNames(const CodeCompletionContext &Context, void AugmentedCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, - Result *Results, + CodeCompletionResult *Results, unsigned NumResults) { // Merge the results we were given with the results we cached. bool AddedResult = false; @@ -1601,7 +1601,7 @@ void AugmentedCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &S, // Contains the set of names that are hidden by "local" completion results. llvm::StringSet<> HiddenNames; llvm::SmallVector StringsToDestroy; - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; llvm::SmallVector AllResults; for (ASTUnit::cached_completion_iterator C = AST.cached_completion_begin(), diff --git a/lib/Sema/CodeCompleteConsumer.cpp b/lib/Sema/CodeCompleteConsumer.cpp index e25980c0d1..303647bbc1 100644 --- a/lib/Sema/CodeCompleteConsumer.cpp +++ b/lib/Sema/CodeCompleteConsumer.cpp @@ -376,14 +376,14 @@ bool CodeCompletionString::Deserialize(const char *&Str, const char *StrEnd) { return true; } -void CodeCompleteConsumer::Result::Destroy() { +void CodeCompletionResult::Destroy() { if (Kind == RK_Pattern) { delete Pattern; Pattern = 0; } } -unsigned CodeCompleteConsumer::Result::getPriorityFromDecl(NamedDecl *ND) { +unsigned CodeCompletionResult::getPriorityFromDecl(NamedDecl *ND) { if (!ND) return CCP_Unlikely; @@ -441,13 +441,13 @@ CodeCompleteConsumer::~CodeCompleteConsumer() { } void PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef, CodeCompletionContext Context, - Result *Results, + CodeCompletionResult *Results, unsigned NumResults) { // Print the results. for (unsigned I = 0; I != NumResults; ++I) { OS << "COMPLETION: "; switch (Results[I].Kind) { - case Result::RK_Declaration: + case CodeCompletionResult::RK_Declaration: OS << Results[I].Declaration; if (Results[I].Hidden) OS << " (Hidden)"; @@ -460,11 +460,11 @@ PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef, OS << '\n'; break; - case Result::RK_Keyword: + case CodeCompletionResult::RK_Keyword: OS << Results[I].Keyword << '\n'; break; - case Result::RK_Macro: { + case CodeCompletionResult::RK_Macro: { OS << Results[I].Macro->getName(); if (CodeCompletionString *CCS = Results[I].CreateCodeCompletionString(SemaRef)) { @@ -475,7 +475,7 @@ PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef, break; } - case Result::RK_Pattern: { + case CodeCompletionResult::RK_Pattern: { OS << "Pattern : " << Results[I].Pattern->getAsString() << '\n'; break; @@ -498,7 +498,7 @@ PrintingCodeCompleteConsumer::ProcessOverloadCandidates(Sema &SemaRef, } } -void CodeCompleteConsumer::Result::computeCursorKindAndAvailability() { +void CodeCompletionResult::computeCursorKindAndAvailability() { switch (Kind) { case RK_Declaration: // Set the availability based on attributes. @@ -599,17 +599,17 @@ void CodeCompleteConsumer::Result::computeCursorKindAndAvailability() { } break; - case Result::RK_Macro: + case RK_Macro: Availability = CXAvailability_Available; CursorKind = CXCursor_MacroDefinition; break; - case Result::RK_Keyword: + case RK_Keyword: Availability = CXAvailability_Available; CursorKind = CXCursor_NotImplemented; break; - case Result::RK_Pattern: + case RK_Pattern: // Do nothing: Patterns can come with cursor kinds! break; } @@ -618,7 +618,7 @@ void CodeCompleteConsumer::Result::computeCursorKindAndAvailability() { void CIndexCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef, CodeCompletionContext Context, - Result *Results, + CodeCompletionResult *Results, unsigned NumResults) { // Print the results. for (unsigned I = 0; I != NumResults; ++I) { diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index b3948dba1e..4228bed9ee 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -40,7 +40,7 @@ namespace { /// filtered out (returns false). typedef bool (ResultBuilder::*LookupFilter)(NamedDecl *) const; - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; private: /// \brief The actual results we have found. @@ -1001,7 +1001,7 @@ namespace { /// \brief Add type specifiers for the current language as keyword results. static void AddTypeSpecifierResults(const LangOptions &LangOpts, ResultBuilder &Results) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; Results.AddResult(Result("short", CCP_Type)); Results.AddResult(Result("long", CCP_Type)); Results.AddResult(Result("signed", CCP_Type)); @@ -1079,7 +1079,7 @@ static void AddTypeSpecifierResults(const LangOptions &LangOpts, static void AddStorageSpecifiers(Action::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; // Note: we don't suggest either "auto" or "register", because both // are pointless as storage specifiers. Elsewhere, we suggest "auto" // in C++0x as a type specifier. @@ -1090,7 +1090,7 @@ static void AddStorageSpecifiers(Action::ParserCompletionContext CCC, static void AddFunctionSpecifiers(Action::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; switch (CCC) { case Action::PCC_Class: case Action::PCC_MemberTemplate: @@ -1141,7 +1141,7 @@ static void AddTypedefResult(ResultBuilder &Results) { Pattern->AddPlaceholderChunk("type"); Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace); Pattern->AddPlaceholderChunk("name"); - Results.AddResult(CodeCompleteConsumer::Result(Pattern)); + Results.AddResult(CodeCompletionResult(Pattern)); } static bool WantTypesInContext(Action::ParserCompletionContext CCC, @@ -1178,7 +1178,7 @@ static void AddOrdinaryNameResults(Action::ParserCompletionContext CCC, Scope *S, Sema &SemaRef, ResultBuilder &Results) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; switch (CCC) { case Action::PCC_Namespace: if (SemaRef.getLangOptions().CPlusPlus) { @@ -1942,7 +1942,7 @@ static void AddFunctionTypeQualsToCompletionString(CodeCompletionString *Result, /// how to use this result, or NULL to indicate that the string or name of the /// result is all that is needed. CodeCompletionString * -CodeCompleteConsumer::Result::CreateCodeCompletionString(Sema &S, +CodeCompletionResult::CreateCodeCompletionString(Sema &S, CodeCompletionString *Result) { typedef CodeCompletionString::Chunk Chunk; @@ -2231,7 +2231,7 @@ CodeCompleteConsumer::OverloadCandidate::CreateSignatureString( namespace { struct SortCodeCompleteResult { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; /// \brief Retrieve the name that should be used to order a result. /// @@ -2306,7 +2306,7 @@ unsigned clang::getMacroUsagePriority(llvm::StringRef MacroName, static void AddMacroResults(Preprocessor &PP, ResultBuilder &Results, bool TargetTypeIsPointer = false) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; Results.EnterNewScope(); for (Preprocessor::macro_iterator M = PP.macro_begin(), @@ -2321,7 +2321,7 @@ static void AddMacroResults(Preprocessor &PP, ResultBuilder &Results, static void AddPrettyFunctionResults(const LangOptions &LangOpts, ResultBuilder &Results) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; Results.EnterNewScope(); Results.AddResult(Result("__PRETTY_FUNCTION__", CCP_Constant)); @@ -2334,7 +2334,7 @@ static void AddPrettyFunctionResults(const LangOptions &LangOpts, static void HandleCodeCompleteResults(Sema *S, CodeCompleteConsumer *CodeCompleter, CodeCompletionContext Context, - CodeCompleteConsumer::Result *Results, + CodeCompletionResult *Results, unsigned NumResults) { std::stable_sort(Results, Results + NumResults, SortCodeCompleteResult()); @@ -2385,7 +2385,7 @@ static enum CodeCompletionContext::Kind mapCodeCompletionContext(Sema &S, void Sema::CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; ResultBuilder Results(*this); // Determine how to filter results, e.g., so that the names of @@ -2464,7 +2464,7 @@ void Sema::CodeCompleteOrdinaryName(Scope *S, void Sema::CodeCompleteDeclarator(Scope *S, bool AllowNonIdentifiers, bool AllowNestedNameSpecifiers) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; ResultBuilder Results(*this); Results.EnterNewScope(); @@ -2517,7 +2517,7 @@ struct Sema::CodeCompleteExpressionData { /// expressions. void Sema::CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; ResultBuilder Results(*this); if (Data.ObjCCollection) @@ -2568,7 +2568,7 @@ static void AddObjCProperties(ObjCContainerDecl *Container, bool AllowCategories, DeclContext *CurContext, ResultBuilder &Results) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; // Add properties in this container. for (ObjCContainerDecl::prop_iterator P = Container->prop_begin(), @@ -2617,7 +2617,7 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, ExprTy *BaseE, if (!BaseE || !CodeCompleter) return; - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; Expr *Base = static_cast(BaseE); QualType BaseType = Base->getType(); @@ -2706,7 +2706,7 @@ void Sema::CodeCompleteTag(Scope *S, unsigned TagSpec) { if (!CodeCompleter) return; - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; ResultBuilder::LookupFilter Filter = 0; enum CodeCompletionContext::Kind ContextKind = CodeCompletionContext::CCC_Other; @@ -2824,7 +2824,7 @@ void Sema::CodeCompleteCase(Scope *S) { if (EnumeratorsSeen.count(*E)) continue; - Results.AddResult(CodeCompleteConsumer::Result(*E, Qualifier), + Results.AddResult(CodeCompletionResult(*E, Qualifier), CurContext, 0, false); } Results.ExitScope(); @@ -3043,7 +3043,7 @@ void Sema::CodeCompleteUsing(Scope *S) { // If we aren't in class scope, we could see the "namespace" keyword. if (!S->isClassScope()) - Results.AddResult(CodeCompleteConsumer::Result("namespace")); + Results.AddResult(CodeCompletionResult("namespace")); // After "using", we can see anything that would start a // nested-name-specifier. @@ -3100,7 +3100,7 @@ void Sema::CodeCompleteNamespaceDecl(Scope *S) { for (std::map::iterator NS = OrigToLatest.begin(), NSEnd = OrigToLatest.end(); NS != NSEnd; ++NS) - Results.AddResult(CodeCompleteConsumer::Result(NS->second, 0), + Results.AddResult(CodeCompletionResult(NS->second, 0), CurContext, 0, false); Results.ExitScope(); } @@ -3128,7 +3128,7 @@ void Sema::CodeCompleteOperatorName(Scope *S) { if (!CodeCompleter) return; - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; ResultBuilder Results(*this, &ResultBuilder::IsType); Results.EnterNewScope(); @@ -3159,7 +3159,7 @@ void Sema::CodeCompleteOperatorName(Scope *S) { static void AddObjCImplementationResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; // Since we have an implementation, we can end it. Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,end))); @@ -3184,7 +3184,7 @@ static void AddObjCImplementationResults(const LangOptions &LangOpts, static void AddObjCInterfaceResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; // Since we have an interface or protocol, we can end it. Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,end))); @@ -3202,7 +3202,7 @@ static void AddObjCInterfaceResults(const LangOptions &LangOpts, } static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; CodeCompletionString *Pattern = 0; // @class name ; @@ -3249,7 +3249,7 @@ static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt) { void Sema::CodeCompleteObjCAtDirective(Scope *S, Decl *ObjCImpDecl, bool InInterface) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; ResultBuilder Results(*this); Results.EnterNewScope(); if (ObjCImpDecl) @@ -3265,7 +3265,7 @@ void Sema::CodeCompleteObjCAtDirective(Scope *S, Decl *ObjCImpDecl, } static void AddObjCExpressionResults(ResultBuilder &Results, bool NeedAt) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; CodeCompletionString *Pattern = 0; // @encode ( type-name ) @@ -3294,7 +3294,7 @@ static void AddObjCExpressionResults(ResultBuilder &Results, bool NeedAt) { } static void AddObjCStatementResults(ResultBuilder &Results, bool NeedAt) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; CodeCompletionString *Pattern = 0; if (Results.includeCodePatterns()) { @@ -3344,7 +3344,7 @@ static void AddObjCStatementResults(ResultBuilder &Results, bool NeedAt) { static void AddObjCVisibilityResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,private))); Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,protected))); Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,public))); @@ -3419,34 +3419,34 @@ void Sema::CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS) { unsigned Attributes = ODS.getPropertyAttributes(); - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; ResultBuilder Results(*this); Results.EnterNewScope(); if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_readonly)) - Results.AddResult(CodeCompleteConsumer::Result("readonly")); + Results.AddResult(CodeCompletionResult("readonly")); if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_assign)) - Results.AddResult(CodeCompleteConsumer::Result("assign")); + Results.AddResult(CodeCompletionResult("assign")); if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_readwrite)) - Results.AddResult(CodeCompleteConsumer::Result("readwrite")); + Results.AddResult(CodeCompletionResult("readwrite")); if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_retain)) - Results.AddResult(CodeCompleteConsumer::Result("retain")); + Results.AddResult(CodeCompletionResult("retain")); if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_copy)) - Results.AddResult(CodeCompleteConsumer::Result("copy")); + Results.AddResult(CodeCompletionResult("copy")); if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_nonatomic)) - Results.AddResult(CodeCompleteConsumer::Result("nonatomic")); + Results.AddResult(CodeCompletionResult("nonatomic")); if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_setter)) { CodeCompletionString *Setter = new CodeCompletionString; Setter->AddTypedTextChunk("setter"); Setter->AddTextChunk(" = "); Setter->AddPlaceholderChunk("method"); - Results.AddResult(CodeCompleteConsumer::Result(Setter)); + Results.AddResult(CodeCompletionResult(Setter)); } if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_getter)) { CodeCompletionString *Getter = new CodeCompletionString; Getter->AddTypedTextChunk("getter"); Getter->AddTextChunk(" = "); Getter->AddPlaceholderChunk("method"); - Results.AddResult(CodeCompleteConsumer::Result(Getter)); + Results.AddResult(CodeCompletionResult(Getter)); } Results.ExitScope(); HandleCodeCompleteResults(this, CodeCompleter, @@ -3508,7 +3508,7 @@ static void AddObjCMethods(ObjCContainerDecl *Container, DeclContext *CurContext, ResultBuilder &Results, bool InOriginalClass = true) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; for (ObjCContainerDecl::method_iterator M = Container->meth_begin(), MEnd = Container->meth_end(); M != MEnd; ++M) { @@ -3575,7 +3575,7 @@ static void AddObjCMethods(ObjCContainerDecl *Container, void Sema::CodeCompleteObjCPropertyGetter(Scope *S, Decl *ClassDecl, Decl **Methods, unsigned NumMethods) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; // Try to find the interface where getters might live. ObjCInterfaceDecl *Class = dyn_cast_or_null(ClassDecl); @@ -3615,7 +3615,7 @@ void Sema::CodeCompleteObjCPropertyGetter(Scope *S, Decl *ClassDecl, void Sema::CodeCompleteObjCPropertySetter(Scope *S, Decl *ObjCImplDecl, Decl **Methods, unsigned NumMethods) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; // Try to find the interface where setters might live. ObjCInterfaceDecl *Class @@ -3655,7 +3655,7 @@ void Sema::CodeCompleteObjCPropertySetter(Scope *S, Decl *ObjCImplDecl, } void Sema::CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; ResultBuilder Results(*this); Results.EnterNewScope(); @@ -3770,7 +3770,7 @@ static ObjCInterfaceDecl *GetAssumedMessageSendExprType(Expr *E) { } void Sema::CodeCompleteObjCMessageReceiver(Scope *S) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; ResultBuilder Results(*this); // Find anything that looks like it could be a message receiver. @@ -3863,7 +3863,7 @@ void Sema::CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, void Sema::CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, IdentifierInfo **SelIdents, unsigned NumSelIdents) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; ObjCInterfaceDecl *CDecl = 0; // If the given name refers to an interface type, retrieve the @@ -3926,7 +3926,7 @@ void Sema::CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, void Sema::CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver, IdentifierInfo **SelIdents, unsigned NumSelIdents) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; Expr *RecExpr = static_cast(Receiver); @@ -4045,7 +4045,7 @@ void Sema::CodeCompleteObjCForCollection(Scope *S, static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext, bool OnlyForwardDeclarations, ResultBuilder &Results) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; for (DeclContext::decl_iterator D = Ctx->decls_begin(), DEnd = Ctx->decls_end(); @@ -4110,7 +4110,7 @@ static void AddInterfaceResults(DeclContext *Ctx, DeclContext *CurContext, bool OnlyForwardDeclarations, bool OnlyUnimplemented, ResultBuilder &Results) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; for (DeclContext::decl_iterator D = Ctx->decls_begin(), DEnd = Ctx->decls_end(); @@ -4185,7 +4185,7 @@ void Sema::CodeCompleteObjCImplementationDecl(Scope *S) { void Sema::CodeCompleteObjCInterfaceCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; ResultBuilder Results(*this); @@ -4218,7 +4218,7 @@ void Sema::CodeCompleteObjCInterfaceCategory(Scope *S, void Sema::CodeCompleteObjCImplementationCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; // Find the corresponding interface. If we couldn't find the interface, the // program itself is ill-formed. However, we'll try to be helpful still by @@ -4255,7 +4255,7 @@ void Sema::CodeCompleteObjCImplementationCategory(Scope *S, } void Sema::CodeCompleteObjCPropertyDefinition(Scope *S, Decl *ObjCImpDecl) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; ResultBuilder Results(*this); // Figure out where this @synthesize lives. @@ -4292,7 +4292,7 @@ void Sema::CodeCompleteObjCPropertyDefinition(Scope *S, Decl *ObjCImpDecl) { void Sema::CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName, Decl *ObjCImpDecl) { - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; ResultBuilder Results(*this); // Figure out where this @synthesize lives. @@ -4473,7 +4473,7 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S, } // Add declarations or definitions for each of the known methods. - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; ResultBuilder Results(*this); Results.EnterNewScope(); PrintingPolicy Policy(Context.PrintingPolicy); @@ -4586,7 +4586,7 @@ void Sema::CodeCompleteObjCMethodDeclSelector(Scope *S, } // Build the set of methods we can see. - typedef CodeCompleteConsumer::Result Result; + typedef CodeCompletionResult Result; ResultBuilder Results(*this); if (ReturnTy) @@ -4872,7 +4872,7 @@ void Sema::CodeCompletePreprocessorMacroArgument(Scope *S, } void Sema::GatherGlobalCodeCompletions( - llvm::SmallVectorImpl &Results) { + llvm::SmallVectorImpl &Results) { ResultBuilder Builder(*this); if (!CodeCompleter || CodeCompleter->includeGlobals()) { diff --git a/tools/libclang/CIndexCodeCompletion.cpp b/tools/libclang/CIndexCodeCompletion.cpp index e99927b5b9..026d0be4ba 100644 --- a/tools/libclang/CIndexCodeCompletion.cpp +++ b/tools/libclang/CIndexCodeCompletion.cpp @@ -569,7 +569,7 @@ namespace { virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, - Result *Results, + CodeCompletionResult *Results, unsigned NumResults) { AllocatedResults.Results = new CXCompletionResult [NumResults]; AllocatedResults.NumResults = NumResults;