diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-09-09 23:10:46 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-09-09 23:10:46 +0000 |
| commit | 0d4d88cf385c9fb78f7cf82c10a1fb697ab052a1 (patch) | |
| tree | 5a4729c0dc89457abf57cd1d77c0dbbab2cedcf1 /clang/tools | |
| parent | e89d03f619940dced72468711ea5b3f39a8f4f94 (diff) | |
| download | bcm5719-llvm-0d4d88cf385c9fb78f7cf82c10a1fb697ab052a1.tar.gz bcm5719-llvm-0d4d88cf385c9fb78f7cf82c10a1fb697ab052a1.zip | |
Add libclang visitation for __builtin_offsetof's components (fields
and array references).
llvm-svn: 113556
Diffstat (limited to 'clang/tools')
| -rw-r--r-- | clang/tools/libclang/CIndex.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index cb2f7b53dc4..35e28ad4298 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -1555,11 +1555,34 @@ bool CursorVisitor::VisitBlockExpr(BlockExpr *B) { } bool CursorVisitor::VisitOffsetOfExpr(OffsetOfExpr *E) { - // FIXME: Visit fields as well? + // Visit the type into which we're computing an offset. if (Visit(E->getTypeSourceInfo()->getTypeLoc())) return true; + + // Visit the components of the offsetof expression. + for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) { + typedef OffsetOfExpr::OffsetOfNode OffsetOfNode; + const OffsetOfNode &Node = E->getComponent(I); + switch (Node.getKind()) { + case OffsetOfNode::Array: + if (Visit(MakeCXCursor(E->getIndexExpr(Node.getArrayExprIndex()), + StmtParent, TU))) + return true; + break; + + case OffsetOfNode::Field: + if (Visit(MakeCursorMemberRef(Node.getField(), Node.getRange().getEnd(), + TU))) + return true; + break; + + case OffsetOfNode::Identifier: + case OffsetOfNode::Base: + continue; + } + } - return VisitExpr(E); + return false; } bool CursorVisitor::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) { |

