Skip to content
Snippets Groups Projects
Commit e02bd00a authored by Argyrios Kyrtzidis's avatar Argyrios Kyrtzidis
Browse files

[libclang] If the code-completion point is inside the preamble, adjust the...

[libclang] If the code-completion point is inside the preamble, adjust the position at the beginning of the file after the preamble.
    
Otherwise we will not hit the code-completion point.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220136 91177308-0d34-0410-b5e6-96231b3b80d8
parent 767b614f
No related branches found
No related tags found
No related merge requests found
...@@ -384,6 +384,15 @@ bool Preprocessor::SetCodeCompletionPoint(const FileEntry *File, ...@@ -384,6 +384,15 @@ bool Preprocessor::SetCodeCompletionPoint(const FileEntry *File,
} }
Position += CompleteColumn - 1; Position += CompleteColumn - 1;
// If pointing inside the preamble, adjust the position at the beginning of
// the file after the preamble.
if (SkipMainFilePreamble.first &&
SourceMgr.getFileEntryForID(SourceMgr.getMainFileID()) == File) {
if (Position - Buffer->getBufferStart() < SkipMainFilePreamble.first)
Position = Buffer->getBufferStart() + SkipMainFilePreamble.first;
}
if (Position > Buffer->getBufferEnd()) if (Position > Buffer->getBufferEnd())
Position = Buffer->getBufferEnd(); Position = Buffer->getBufferEnd();
......
...@@ -3,3 +3,7 @@ ...@@ -3,3 +3,7 @@
// RUN: -code-completion-at=%S/Inputs/complete-at-EOF.c:4:1 %S/Inputs/complete-at-EOF.c | FileCheck -check-prefix=CHECK-EOF %s // RUN: -code-completion-at=%S/Inputs/complete-at-EOF.c:4:1 %S/Inputs/complete-at-EOF.c | FileCheck -check-prefix=CHECK-EOF %s
// CHECK-EOF: macro definition:{TypedText CAKE} // CHECK-EOF: macro definition:{TypedText CAKE}
// CHECK-EOF: TypedefDecl:{TypedText foo} // CHECK-EOF: TypedefDecl:{TypedText foo}
// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test \
// RUN: -code-completion-at=%S/Inputs/complete-at-EOF.c:2:1 %S/Inputs/complete-at-EOF.c | FileCheck -check-prefix=CHECK-AFTER-PREAMBLE %s
// CHECK-AFTER-PREAMBLE: macro definition:{TypedText CAKE}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment