
The multiple-include optimization allows Clang to avoid opening a files when they contain #pragma once or a proper include guard. Both GCC and Microsoft Visual Studio allow null directives outside of the #ifndef/#endif pair without disabling this multiple-include optimization. GCC documents this behavior here https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html. > There must be no directives outside the controlling directive pair, > but the null directive (a line containing nothing other than a > single '#' and possibly whitespace) is permitted. However, Clang disables the multiple-include optimization when encountering the null directive. In particular, this slows down preprocessing of most projects that depend on boost as many boost libraries depend on the boost preprocessor library, which contains null directives outside the include guard on every header file. Differential Revision: https://reviews.llvm.org/D147928
8 lines
261 B
C++
8 lines
261 B
C++
// RUN: %clang_cc1 -E -P -H %s 2>&1 | grep "multiple-inclusion-opt.h" | count 1
|
|
|
|
#include "multiple-inclusion-opt.h"
|
|
#include "multiple-inclusion-opt.h"
|
|
#include "multiple-inclusion-opt.h"
|
|
#include "multiple-inclusion-opt.h"
|
|
#include "multiple-inclusion-opt.h"
|