Closed GoogleCodeExporter closed 9 years ago
Wow, this seems like a really simple case, for iwyu to be getting it wrong.
But I can definitely reproduce it.
It looks like the problem is that iwyu just doesn't intercept
ArraySubscriptExpr -- we need to treat this similarly to MemberExpr or the
like. Would you like to try to add code to handle it? I wrote up a simple
test file (which I'm not committing because I don't have XFAIL support in my
testing suite yet), which you can use to test your change (I put it in
tests/array.cc):
---
//===--- array.cc - test input file for iwyu ------------------------------===/\
/
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===/\
/
// Tests that we handle correctly identify a[i] as a full use of a.
#include "devtools/maintenance/include_what_you_use/tests/direct.h"
class A {
// IWYU: IndirectClass needs a declaration
IndirectClass *getIndirectClass(int i) {
// IWYU: IndirectClass is...*indirect.h
return &(_b[i]);
}
IndirectClass *_b;
};
/**** IWYU_SUMMARY
devtools/maintenance/include_what_you_use/tests/array.cc should add these lines:
#include "devtools/maintenance/include_what_you_use/tests/indirect.h"
devtools/maintenance/include_what_you_use/tests/array.cc should remove these
lines:
- #include "devtools/maintenance/include_what_you_use/tests/direct.h" // lines
XX-XX
The full include-list for
devtools/maintenance/include_what_you_use/tests/array.cc:
#include "devtools/maintenance/include_what_you_use/tests/indirect.h" // for
IndirectClass
***** IWYU_SUMMARY */
Original comment by csilv...@gmail.com
on 2 May 2011 at 2:58
Never mind about a patch, I ended up fixing this myself in r201
Original comment by csilv...@gmail.com
on 4 May 2011 at 6:40
Original issue reported on code.google.com by
saltyho...@gmail.com
on 1 May 2011 at 1:51