Skip to content

Commit 305c865

Browse files
committed
[cling] Completely remove setting CodeCompletionOffset
This is not needed anymore as cling follows the same autocomplete logic as `clang-repl`
1 parent 98abbee commit 305c865

3 files changed

Lines changed: 20 additions & 60 deletions

File tree

interpreter/cling/include/cling/Interpreter/CompilationOptions.h

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ namespace cling {
7070
///\brief Optimization level.
7171
unsigned OptLevel : 2;
7272

73-
///\brief Offset into the input line to enable the setting of the
74-
/// code completion point.
75-
/// -1 diasables code completion.
76-
///
77-
int CodeCompletionOffset = -1;
78-
7973
CompilationOptions() {
8074
DeclarationExtraction = 0;
8175
EnableShadowing = 0;
@@ -91,35 +85,29 @@ namespace cling {
9185
}
9286

9387
bool operator==(CompilationOptions Other) const {
94-
return
95-
DeclarationExtraction == Other.DeclarationExtraction &&
96-
EnableShadowing == Other.EnableShadowing &&
97-
ValuePrinting == Other.ValuePrinting &&
98-
ResultEvaluation == Other.ResultEvaluation &&
99-
DynamicScoping == Other.DynamicScoping &&
100-
Debug == Other.Debug &&
101-
CodeGeneration == Other.CodeGeneration &&
102-
CodeGenerationForModule == Other.CodeGenerationForModule &&
103-
IgnorePromptDiags == Other.IgnorePromptDiags &&
104-
CheckPointerValidity == Other.CheckPointerValidity &&
105-
OptLevel == Other.OptLevel &&
106-
CodeCompletionOffset == Other.CodeCompletionOffset;
88+
return DeclarationExtraction == Other.DeclarationExtraction &&
89+
EnableShadowing == Other.EnableShadowing &&
90+
ValuePrinting == Other.ValuePrinting &&
91+
ResultEvaluation == Other.ResultEvaluation &&
92+
DynamicScoping == Other.DynamicScoping && Debug == Other.Debug &&
93+
CodeGeneration == Other.CodeGeneration &&
94+
CodeGenerationForModule == Other.CodeGenerationForModule &&
95+
IgnorePromptDiags == Other.IgnorePromptDiags &&
96+
CheckPointerValidity == Other.CheckPointerValidity &&
97+
OptLevel == Other.OptLevel;
10798
}
10899

109100
bool operator!=(CompilationOptions Other) const {
110-
return
111-
DeclarationExtraction != Other.DeclarationExtraction ||
112-
EnableShadowing != Other.EnableShadowing ||
113-
ValuePrinting != Other.ValuePrinting ||
114-
ResultEvaluation != Other.ResultEvaluation ||
115-
DynamicScoping != Other.DynamicScoping ||
116-
Debug != Other.Debug ||
117-
CodeGeneration != Other.CodeGeneration ||
118-
CodeGenerationForModule != Other.CodeGenerationForModule ||
119-
IgnorePromptDiags != Other.IgnorePromptDiags ||
120-
CheckPointerValidity != Other.CheckPointerValidity ||
121-
OptLevel != Other.OptLevel ||
122-
CodeCompletionOffset != Other.CodeCompletionOffset;
101+
return DeclarationExtraction != Other.DeclarationExtraction ||
102+
EnableShadowing != Other.EnableShadowing ||
103+
ValuePrinting != Other.ValuePrinting ||
104+
ResultEvaluation != Other.ResultEvaluation ||
105+
DynamicScoping != Other.DynamicScoping || Debug != Other.Debug ||
106+
CodeGeneration != Other.CodeGeneration ||
107+
CodeGenerationForModule != Other.CodeGenerationForModule ||
108+
IgnorePromptDiags != Other.IgnorePromptDiags ||
109+
CheckPointerValidity != Other.CheckPointerValidity ||
110+
OptLevel != Other.OptLevel;
123111
}
124112
};
125113
} // end namespace cling

interpreter/cling/lib/Interpreter/IncrementalParser.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -860,9 +860,6 @@ namespace cling {
860860

861861
Sema& S = getCI()->getSema();
862862

863-
const CompilationOptions& CO
864-
= m_Consumer->getTransaction()->getCompilationOpts();
865-
866863
// Recover resources if we crash before exiting this method.
867864
llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleanupSema(&S);
868865

@@ -902,12 +899,6 @@ namespace cling {
902899
0 /* mod time*/);
903900
SM.overrideFileContents(FE, std::move(MB));
904901
FID = SM.createFileID(FE, NewLoc, SrcMgr::C_User);
905-
if (CO.CodeCompletionOffset != -1) {
906-
// The completion point is set one a 1-based line/column numbering.
907-
// It relies on the implementation to account for the wrapper extra line.
908-
PP.SetCodeCompletionPoint(FE, 1/* start point 1-based line*/,
909-
CO.CodeCompletionOffset+1/* 1-based column*/);
910-
}
911902

912903
// NewLoc only used for diags.
913904
PP.EnterSourceFile(FID, /*DirLookup*/nullptr, NewLoc);
@@ -984,23 +975,6 @@ namespace cling {
984975
std::error_code());
985976
}
986977

987-
if (CO.CodeCompletionOffset != -1) {
988-
#ifndef NDEBUG
989-
Preprocessor& PP = m_CI->getPreprocessor();
990-
SourceManager& SM = getCI()->getSourceManager();
991-
assert((int)SM.getFileOffset(PP.getCodeCompletionLoc())
992-
== CO.CodeCompletionOffset
993-
&& "Completion point wrongly set!");
994-
assert(PP.isCodeCompletionReached()
995-
&& "Code completion set but not reached!");
996-
#endif
997-
998-
// Let's ignore this transaction:
999-
m_Consumer->getTransaction()->setIssuedDiags(Transaction::kErrors);
1000-
1001-
return llvm::Error::success();
1002-
}
1003-
1004978
// Process any TopLevelDecls generated by #pragma weak.
1005979
for (Decl* D : S.WeakTopLevelDecls()) {
1006980
DeclGroupRef DGR(D);

interpreter/cling/lib/Interpreter/Interpreter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,6 @@ namespace cling {
984984
size_t wrapPos = utils::getWrapPoint(wrapped, getCI()->getLangOpts());
985985
const std::string& Src = WrapInput(wrapped, wrapped, wrapPos);
986986

987-
CO.CodeCompletionOffset = offset + wrapPos;
988-
989987
StateDebuggerRAII stateDebugger(this);
990988

991989
// This triggers the FileEntry to be created and the completion

0 commit comments

Comments
 (0)