We're struggling with delayed template parsing in our IWYU tool, so this
caught my eye.
This fragment:
#include "tests/cxx/direct.h"
template <typename T> void foo() {
IndirectClass ic;
}
(from https://code.google.com/p/include-what-you-use/issues/detail?id=129)
will have IWYU suggest removal of the #include in MSVC-compatible mode only
(because of -fdelayed-template-parsing). In 'normal' mode, the template
gets an AST built for it, and the IndirectClass use is properly detected.
We've considered always running IWYU with -fno-delayed-template-parsing,
but that would probably make parsing of Microsoft system headers fail
entirely.
Are we stuck here? Or is there a workaround for visiting template bodies
even under -fdelayed-template-parsing?
Clang-modernize seems to have run into the same problem, so this might
become more of a problem as tools start supporting Windows:
http://clang.llvm.org/extra/PassByValueTransform.html#note-about-delayed-template-parsing
So your approach sounds interesting, to treat delayed template parsing as
an error path. It would fix the vast majority of these RAV problems in
portable codebases, and code that relies on delayed parsing would still
compile, even if it would be silently missed in RAV.
- Kim