[cfe-commits] r95972 - in /cfe/trunk: lib/Lex/PPDirectives.cpp test/Preprocessor/mi_opt2.c test/Preprocessor/mi_opt2.h

Neil Booth neil at daikokuya.co.uk
Fri Feb 12 04:50:10 PST 2010


Chris Lattner wrote:-
 
> Fix PR6282: the include guard optimization cannot happen if the
> guard macro is already defined for the first occurrence of the
> header.  If it is, the body will be skipped and not be properly
> analyzed for the include guard optimization.

> +// PR6282
> +// This test should not trigger the include guard optimization since
> +// the guard macro is defined on the first include.
> +
> +#define ITERATING 1
> +#define X 1
> +#include "mi_opt2.h"
> +#undef X
> +#define X 2
> +#include "mi_opt2.h"
> +
> +// CHECK: b: 1
> +// CHECK: b: 2
> +

Chris - forgetting Clang's implementation, I cannot agree with
the comment and rationale here.  The reason that no include guard
optimization is valid is because the header has a non-empty #else.
The status of the macro on initial inclusion is irrelevant.

What am I missing?

Neil.



More information about the cfe-commits mailing list