]> granicus.if.org Git - clang/commitdiff
Fix an assertion when code-completing, rdar://9288730 & http://llvm.org/PR9728.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 23 Apr 2011 01:04:12 +0000 (01:04 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 23 Apr 2011 01:04:12 +0000 (01:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130042 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExprCXX.cpp
test/CodeCompletion/PR9728.cpp [new file with mode: 0644]

index 49d30741190e16b1adeb1031f0f35baf103a39ef..ccc75125ad45503e7682bd7cd18179027ff2642d 100644 (file)
@@ -161,7 +161,12 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
         // Code completion for a nested-name-specifier, where the code
         // code completion token follows the '::'.
         Actions.CodeCompleteQualifiedId(getCurScope(), SS, EnteringContext);
-        ConsumeCodeCompletionToken();
+        SourceLocation ccLoc = ConsumeCodeCompletionToken();
+        // Include code completion token into the range of the scope otherwise
+        // when we try to annotate the scope tokens the dangling code completion
+        // token will cause assertion in
+        // Preprocessor::AnnotatePreviousCachedTokens.
+        SS.setEndLoc(ccLoc);
       }
     }
 
diff --git a/test/CodeCompletion/PR9728.cpp b/test/CodeCompletion/PR9728.cpp
new file mode 100644 (file)
index 0000000..91f49be
--- /dev/null
@@ -0,0 +1,9 @@
+namespace N {
+struct SFoo;
+}
+
+struct brokenfile_t {
+  brokenfile_t (N::
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:6:20 %s -o - | FileCheck %s
+  // CHECK: SFoo
+