[cfe-commits] r116253 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Frontend/CompilerInstance.h include/clang/Frontend/FrontendOptions.h include/clang/Sema/CodeCompleteConsumer.h lib/Frontend/CompilerInstance.cpp lib/Frontend/CompilerInvocation.cpp lib/Sema/CodeCompleteConsumer.cpp
Douglas Gregor
dgregor at apple.com
Mon Oct 11 15:12:16 PDT 2010
Author: dgregor
Date: Mon Oct 11 17:12:15 2010
New Revision: 116253
URL: http://llvm.org/viewvc/llvm-project?rev=116253&view=rev
Log:
Eliminate the (de-)serialization of code completion results, now that
libclang does not support out-of-process code completion.
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=116253&r1=116252&r2=116253&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Oct 11 17:12:15 2010
@@ -267,8 +267,6 @@
HelpText<"Replace the contents of the <from> file with the contents of the <to> file">;
def code_completion_at_EQ : Joined<"-code-completion-at=">,
Alias<code_completion_at>;
-def no_code_completion_debug_printer : Flag<"-no-code-completion-debug-printer">,
- HelpText<"Don't use the \"debug\" code-completion print">;
def code_completion_macros : Flag<"-code-completion-macros">,
HelpText<"Include macros in code-completion results">;
def code_completion_patterns : Flag<"-code-completion-patterns">,
Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=116253&r1=116252&r2=116253&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Mon Oct 11 17:12:15 2010
@@ -548,7 +548,7 @@
static CodeCompleteConsumer *
createCodeCompletionConsumer(Preprocessor &PP, const std::string &Filename,
unsigned Line, unsigned Column,
- bool UseDebugPrinter, bool ShowMacros,
+ bool ShowMacros,
bool ShowCodePatterns, bool ShowGlobals,
llvm::raw_ostream &OS);
Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=116253&r1=116252&r2=116253&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Mon Oct 11 17:12:15 2010
@@ -56,8 +56,6 @@
/// FrontendOptions - Options for controlling the behavior of the frontend.
class FrontendOptions {
public:
- unsigned DebugCodeCompletionPrinter : 1; ///< Use the debug printer for code
- /// completion results.
unsigned DisableFree : 1; ///< Disable memory freeing on exit.
unsigned RelocatablePCH : 1; ///< When generating PCH files,
/// instruct the AST writer to create
@@ -119,7 +117,6 @@
public:
FrontendOptions() {
- DebugCodeCompletionPrinter = 1;
DisableFree = 0;
ProgramAction = frontend::ParseSyntaxOnly;
ActionName = "";
Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=116253&r1=116252&r2=116253&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Mon Oct 11 17:12:15 2010
@@ -465,14 +465,6 @@
/// \param Result If non-NULL, points to an empty code-completion
/// result that will be given a cloned copy of
CodeCompletionString *Clone(CodeCompletionString *Result = 0) const;
-
- /// \brief Serialize this code-completion string to the given stream.
- void Serialize(llvm::raw_ostream &OS) const;
-
- /// \brief Deserialize a code-completion string from the given string.
- ///
- /// \returns true if successful, false otherwise.
- bool Deserialize(const char *&Str, const char *StrEnd);
};
/// \brief Captures a result of code completion.
@@ -797,32 +789,6 @@
unsigned NumCandidates);
};
-/// \brief A code-completion consumer that prints the results it receives
-/// in a format that is parsable by the CIndex library.
-class CIndexCodeCompleteConsumer : public CodeCompleteConsumer {
- /// \brief The raw output stream.
- llvm::raw_ostream &OS;
-
-public:
- /// \brief Create a new CIndex code-completion consumer that prints its
- /// results to the given raw output stream in a format readable to the CIndex
- /// library.
- CIndexCodeCompleteConsumer(bool IncludeMacros, bool IncludeCodePatterns,
- bool IncludeGlobals, llvm::raw_ostream &OS)
- : CodeCompleteConsumer(IncludeMacros, IncludeCodePatterns, IncludeGlobals,
- true), OS(OS) {}
-
- /// \brief Prints the finalized code-completion results.
- virtual void ProcessCodeCompleteResults(Sema &S,
- CodeCompletionContext Context,
- CodeCompletionResult *Results,
- unsigned NumResults);
-
- virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
- OverloadCandidate *Candidates,
- unsigned NumCandidates);
-};
-
} // end namespace clang
#endif // LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=116253&r1=116252&r2=116253&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Oct 11 17:12:15 2010
@@ -289,7 +289,6 @@
CompletionConsumer.reset(
createCodeCompletionConsumer(getPreprocessor(),
Loc.FileName, Loc.Line, Loc.Column,
- getFrontendOpts().DebugCodeCompletionPrinter,
getFrontendOpts().ShowMacrosInCodeCompletion,
getFrontendOpts().ShowCodePatternsInCodeCompletion,
getFrontendOpts().ShowGlobalSymbolsInCodeCompletion,
@@ -318,7 +317,6 @@
const std::string &Filename,
unsigned Line,
unsigned Column,
- bool UseDebugPrinter,
bool ShowMacros,
bool ShowCodePatterns,
bool ShowGlobals,
@@ -327,11 +325,7 @@
return 0;
// Set up the creation routine for code-completion.
- if (UseDebugPrinter)
- return new PrintingCodeCompleteConsumer(ShowMacros, ShowCodePatterns,
- ShowGlobals, OS);
- else
- return new CIndexCodeCompleteConsumer(ShowMacros, ShowCodePatterns,
+ return new PrintingCodeCompleteConsumer(ShowMacros, ShowCodePatterns,
ShowGlobals, OS);
}
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=116253&r1=116252&r2=116253&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Oct 11 17:12:15 2010
@@ -353,8 +353,6 @@
static void FrontendOptsToArgs(const FrontendOptions &Opts,
std::vector<std::string> &Res) {
- if (!Opts.DebugCodeCompletionPrinter)
- Res.push_back("-no-code-completion-debug-printer");
if (Opts.DisableFree)
Res.push_back("-disable-free");
if (Opts.RelocatablePCH)
@@ -1067,8 +1065,6 @@
Diags.Report(diag::err_drv_invalid_value)
<< A->getAsString(Args) << A->getValue(Args);
}
- Opts.DebugCodeCompletionPrinter =
- !Args.hasArg(OPT_no_code_completion_debug_printer);
Opts.DisableFree = Args.hasArg(OPT_disable_free);
Opts.OutputFile = Args.getLastArgValue(OPT_o);
Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=116253&r1=116252&r2=116253&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Mon Oct 11 17:12:15 2010
@@ -297,126 +297,6 @@
return Result;
}
-static void WriteUnsigned(llvm::raw_ostream &OS, unsigned Value) {
- OS.write((const char *)&Value, sizeof(unsigned));
-}
-
-static bool ReadUnsigned(const char *&Memory, const char *MemoryEnd,
- unsigned &Value) {
- if (Memory + sizeof(unsigned) > MemoryEnd)
- return true;
-
- memmove(&Value, Memory, sizeof(unsigned));
- Memory += sizeof(unsigned);
- return false;
-}
-
-void CodeCompletionString::Serialize(llvm::raw_ostream &OS) const {
- // Write the number of chunks.
- WriteUnsigned(OS, size());
-
- for (iterator C = begin(), CEnd = end(); C != CEnd; ++C) {
- WriteUnsigned(OS, C->Kind);
-
- switch (C->Kind) {
- case CK_TypedText:
- case CK_Text:
- case CK_Placeholder:
- case CK_Informative:
- case CK_ResultType:
- case CK_CurrentParameter: {
- const char *Text = C->Text;
- unsigned StrLen = strlen(Text);
- WriteUnsigned(OS, StrLen);
- OS.write(Text, StrLen);
- break;
- }
-
- case CK_Optional:
- C->Optional->Serialize(OS);
- break;
-
- case CK_LeftParen:
- case CK_RightParen:
- case CK_LeftBracket:
- case CK_RightBracket:
- case CK_LeftBrace:
- case CK_RightBrace:
- case CK_LeftAngle:
- case CK_RightAngle:
- case CK_Comma:
- case CK_Colon:
- case CK_SemiColon:
- case CK_Equal:
- case CK_HorizontalSpace:
- case CK_VerticalSpace:
- break;
- }
- }
-}
-
-bool CodeCompletionString::Deserialize(const char *&Str, const char *StrEnd) {
- if (Str == StrEnd || *Str == 0)
- return false;
-
- unsigned NumBlocks;
- if (ReadUnsigned(Str, StrEnd, NumBlocks))
- return false;
-
- for (unsigned I = 0; I != NumBlocks; ++I) {
- if (Str + 1 >= StrEnd)
- break;
-
- // Parse the next kind.
- unsigned KindValue;
- if (ReadUnsigned(Str, StrEnd, KindValue))
- return false;
-
- switch (ChunkKind Kind = (ChunkKind)KindValue) {
- case CK_TypedText:
- case CK_Text:
- case CK_Placeholder:
- case CK_Informative:
- case CK_ResultType:
- case CK_CurrentParameter: {
- unsigned StrLen;
- if (ReadUnsigned(Str, StrEnd, StrLen) || (Str + StrLen > StrEnd))
- return false;
-
- AddChunk(Chunk(Kind, StringRef(Str, StrLen)));
- Str += StrLen;
- break;
- }
-
- case CK_Optional: {
- std::auto_ptr<CodeCompletionString> Optional(new CodeCompletionString());
- if (Optional->Deserialize(Str, StrEnd))
- AddOptionalChunk(Optional);
- break;
- }
-
- case CK_LeftParen:
- case CK_RightParen:
- case CK_LeftBracket:
- case CK_RightBracket:
- case CK_LeftBrace:
- case CK_RightBrace:
- case CK_LeftAngle:
- case CK_RightAngle:
- case CK_Comma:
- case CK_Colon:
- case CK_SemiColon:
- case CK_Equal:
- case CK_HorizontalSpace:
- case CK_VerticalSpace:
- AddChunk(Chunk(Kind));
- break;
- }
- };
-
- return true;
-}
-
void CodeCompletionResult::Destroy() {
if (Kind == RK_Pattern) {
delete Pattern;
@@ -636,37 +516,3 @@
return false;
}
-
-void
-CIndexCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef,
- CodeCompletionContext Context,
- CodeCompletionResult *Results,
- unsigned NumResults) {
- // Print the results.
- for (unsigned I = 0; I != NumResults; ++I) {
- WriteUnsigned(OS, Results[I].CursorKind);
- WriteUnsigned(OS, Results[I].Priority);
- WriteUnsigned(OS, Results[I].Availability);
- CodeCompletionString *CCS = Results[I].CreateCodeCompletionString(SemaRef);
- assert(CCS && "No code-completion string?");
- CCS->Serialize(OS);
- delete CCS;
- }
-}
-
-void
-CIndexCodeCompleteConsumer::ProcessOverloadCandidates(Sema &SemaRef,
- unsigned CurrentArg,
- OverloadCandidate *Candidates,
- unsigned NumCandidates) {
- for (unsigned I = 0; I != NumCandidates; ++I) {
- WriteUnsigned(OS, CXCursor_NotImplemented);
- WriteUnsigned(OS, /*Priority=*/I);
- WriteUnsigned(OS, /*Availability=*/CXAvailability_Available);
- CodeCompletionString *CCS
- = Candidates[I].CreateSignatureString(CurrentArg, SemaRef);
- assert(CCS && "No code-completion string?");
- CCS->Serialize(OS);
- delete CCS;
- }
-}
More information about the cfe-commits
mailing list