diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2014-10-18 06:23:50 +0000 |
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2014-10-18 06:23:50 +0000 |
| commit | ee301f941c4e4b02eff76cb1b8f2f10b88327619 (patch) | |
| tree | e6e2b11a66c0fc8673ce78416e387975bc0311d4 | |
| parent | e62d682a27ce9addf40223430fe8228a793e889f (diff) | |
| download | bcm5719-llvm-ee301f941c4e4b02eff76cb1b8f2f10b88327619.tar.gz bcm5719-llvm-ee301f941c4e4b02eff76cb1b8f2f10b88327619.zip | |
[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.
llvm-svn: 220136
| -rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 9 | ||||
| -rw-r--r-- | clang/test/Index/complete-at-EOF.c | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index c15a6ab956a..5da54aea30f 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -384,6 +384,15 @@ bool Preprocessor::SetCodeCompletionPoint(const FileEntry *File, } 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()) Position = Buffer->getBufferEnd(); diff --git a/clang/test/Index/complete-at-EOF.c b/clang/test/Index/complete-at-EOF.c index ff39233f0a6..d039aaa1af1 100644 --- a/clang/test/Index/complete-at-EOF.c +++ b/clang/test/Index/complete-at-EOF.c @@ -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 // CHECK-EOF: macro definition:{TypedText CAKE} // 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} |

