Open Quuxplusone opened 10 years ago
Bugzilla Link | PR19759 |
Status | NEW |
Importance | P normal |
Reported by | David Abdurachmanov (david.abdurachmanov@gmail.com) |
Reported on | 2014-05-15 16:01:27 -0700 |
Last modified on | 2014-05-17 00:13:04 -0700 |
Version | 3.4 |
Hardware | Other other |
CC | llvm-bugs@lists.llvm.org |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
Currently looks like the following is failing:
4708 unsigned clang_isCursorDefinition(CXCursor C) {
4709 if (!clang_isDeclaration(C.kind))
4710 return 0;
4711
4712 return clang_getCursorDefinition(C) == C;
4713 }
Line 4712.
Breakpoint 1, clang_isCursorDefinition (C=...)
at /home/david/new-arch/test/BUILD/fc19_aarch64_gcc490/external/llvm/3.4-cms2/llvm-3.4-6800b6d2afc/tools/clang/tools/libclang/CIndex.cpp:4709
4709 if (!clang_isDeclaration(C.kind))
(gdb) p C
$1 = {kind = CXCursor_ClassDecl, xdata = 0, data = {0x7fb39e60e0, 0x0,
0x7fb000cfb0}}
(gdb) p clang_getCString(clang_getCursorDisplayName(C))
$2 = 0x9a5cd0 "RunNumber"
(gdb) p C.
data kind xdata
(gdb) set $foo = clang_getCursorDefinition(C)
(gdb) p $foo
$3 = {kind = CXCursor_ClassDecl, xdata = 0, data = {0x7fb39e60e0, 0x1,
0x7fb000cfb0}}
But printing location of both, prints the same file, line and column.
They are not equal because: C.data[1] != clang_getCursorDefinition(C).data[1]
I moved to trunk for LLVM and Clang. Still the same. Smaller example below.
$ cat my.h
struct timespec
{
int tv_sec;
int tv_nsec;
};
$ cat check.py
import sys
import clang.cindex
def find_all(node):
for child in node.get_children():
print("displayname: {0}, kind: {1}, is_definition: {2}, location:{3}".format(child.displayname, child.kind, child.is_definition(), child.location))
if child.get_definition() is not None:
print(">> get_definition().location: {0}".format(child.get_definition().location))
find_all(child)
index = clang.cindex.Index.create()
tu = index.parse(sys.argv[1])
print 'Translation unit:', tu.spelling
find_all(tu.cursor)
## Fedora 20 / x86_64
$ python check.py my.h
Translation unit: my.h
displayname: __int128_t, kind: CursorKind.TYPEDEF_DECL, is_definition: True,
location:<SourceLocation file None, line 0, column 0>
>> get_definition().location: <SourceLocation file None, line 0, column 0>
displayname: __uint128_t, kind: CursorKind.TYPEDEF_DECL, is_definition: True,
location:<SourceLocation file None, line 0, column 0>
>> get_definition().location: <SourceLocation file None, line 0, column 0>
displayname: __builtin_va_list, kind: CursorKind.TYPEDEF_DECL, is_definition:
True, location:<SourceLocation file None, line 0, column 0>
>> get_definition().location: <SourceLocation file None, line 0, column 0>
displayname: __va_list_tag, kind: CursorKind.TYPE_REF, is_definition: False,
location:<SourceLocation file None, line 0, column 0>
>> get_definition().location: <SourceLocation file None, line 0, column 0>
displayname: timespec, kind: CursorKind.STRUCT_DECL, is_definition: True,
location:<SourceLocation file 'my.h', line 1, column 8>
>> get_definition().location: <SourceLocation file 'my.h', line 1, column 8>
displayname: tv_sec, kind: CursorKind.FIELD_DECL, is_definition: True,
location:<SourceLocation file 'my.h', line 3, column 7>
>> get_definition().location: <SourceLocation file 'my.h', line 3, column 7>
displayname: tv_nsec, kind: CursorKind.FIELD_DECL, is_definition: True,
location:<SourceLocation file 'my.h', line 4, column 7>
>> get_definition().location: <SourceLocation file 'my.h', line 4, column 7>
## Fedora 19 / AArch64
$ python check.py my.h
Translation unit: my.h
displayname: timespec, kind: CursorKind.STRUCT_DECL, is_definition: False,
location:<SourceLocation file 'my.h', line 1, column 8>
>> get_definition().location: <SourceLocation file 'my.h', line 1, column 8>
displayname: tv_sec, kind: CursorKind.FIELD_DECL, is_definition: True,
location:<SourceLocation file 'my.h', line 3, column 7>
>> get_definition().location: <SourceLocation file 'my.h', line 3, column 7>
displayname: tv_nsec, kind: CursorKind.FIELD_DECL, is_definition: True,
location:<SourceLocation file 'my.h', line 4, column 7>
>> get_definition().location: <SourceLocation file 'my.h', line 4, column 7>