[LLVMbugs] [Bug 18669] New: Behavior change of clang_getCanonicalType when cursor is on C++11 auto-declaration

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 30 00:43:41 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18669

            Bug ID: 18669
           Summary: Behavior change of clang_getCanonicalType when cursor
                    is on C++11 auto-declaration
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: libclang
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kfunk at kde.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11977
  --> http://llvm.org/bugs/attachment.cgi?id=11977&action=edit
Standalone parser based on libclang, dumping AST

We're having some problems getting the deduced type for C++11 auto-declarations
out of libclang using clang_getCanonicalType.

Example:

echo "auto i = 1;" > test.cpp

Using just clang to print the type gives us:
$ clang -cc1 -std=c++11 -ast-dump test.cpp
(...)
`-VarDecl 0x1c2e5b0 <test.cpp:1:1, col:10> i 'int':'int'
  `-IntegerLiteral 0x1c2e608 <col:10> 'int' 5
=> 'auto' is deduced to 'int' => Okay

Now, with just depending on libclang, this gets confusing.
In LLVM-3.2 apparently clang_getCanonicalType on the cursor pointing to 'i'
actually returned CXType_Int, whereas in any future version this returns
CXType_Unexposed => No way to get the deduced type any more.

I've attached some sample code that you can try out in order to reproduce the
bug.

Compile & run with:
$ clang parser.c -I/usr/include/clang-c -l clang -o parser
$ ./parser -std=c++11 test.cpp

For LLVM-3.2, I get:
test.cpp:1:6 (5, 0-10) kind: VarDecl type: int display name: i usr: (...)
   test.cpp:1:10 (9, 9-10) kind: IntegerLiteral type: int
=> Type is resolved as 'int' => Okay

For any other version >LLVM-3.3:
test.cpp:1:6 (5, 0-10) kind: VarDecl type: auto display name: i usr: (...)
  test.cpp:1:10 (9, 9-10) kind: IntegerLiteral type: int 
=> Type is resolved as 'auto'

Maybe this behavior changed due to the following commit:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130211/074246.html

Can someone clarify if the change was intended, or if this is a bug and should
be fixed?

-- 
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/20140130/24f014bf/attachment.html>


More information about the llvm-bugs mailing list