[llvm-bugs] [Bug 26254] New: clang_codeCompleteGetContexts suggests CXCompletionContext_DotMemberAccess for "Foo::"

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jan 22 04:40:23 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26254

            Bug ID: 26254
           Summary: clang_codeCompleteGetContexts suggests
                    CXCompletionContext_DotMemberAccess for "Foo::"
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: libclang
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nikolai.kosjar at theqtcompany.com
                CC: klimek at google.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Ubuntu clang version 3.8.0-svn257311-1~exp1 (trunk) (based on LLVM 3.8.0)

For a *.cpp file with the contents

  1 void f()
  2 {
  3     Foo::
  4 }

...and a completion right after the second colon (line 3, column 10), libclang
will suggest CXCompletionContext_DotMemberAccess. Foo is unknown, but still
this shouldn't suggest CXCompletionContext_DotMemberAccess?

Tested with the following code:

  #include <clang-c/Index.h>

  #undef NDEBUG
  #include <cassert>

  #include <cstdlib>
  #include <cstdio>

  int main(int argc, char *argv[])
  {
      if (argc != 4) {
          fprintf(stderr, "Usage: $0 <file> <line> <column>\n");
          return 0;
      }

      const char *filePath = argv[1];
      const unsigned line = unsigned(atoi(argv[2]));
      const unsigned column = unsigned(atoi(argv[3]));

      // Parse
      CXIndex index = clang_createIndex(0, /*displayDiagnostics*/ 1); // ...to
compare
      CXTranslationUnit tu = clang_parseTranslationUnit(index, argv[1], 0, 0,
NULL, 0, 0);

      // Complete
      CXCodeCompleteResults *completeResults = clang_codeCompleteAt(tu,
filePath, line, column, NULL, 0, 0);

      // Test
      const unsigned long long contexts =
clang_codeCompleteGetContexts(completeResults);
      const bool wasDotMemberCompletion = contexts &
CXCompletionContext_DotMemberAccess;
      assert(!wasDotMemberCompletion);

      return 0;
  }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160122/5bc68c16/attachment-0001.html>


More information about the llvm-bugs mailing list