Add -Wpoison-system-directories warning
authorManoj Gupta <manojgupta@google.com>
Thu, 12 Sep 2019 22:36:13 +0000 (22:36 +0000)
committerManoj Gupta <manojgupta@google.com>
Thu, 12 Sep 2019 22:36:13 +0000 (22:36 +0000)
commit4fe2732161905a9bd53e09336851482a96b04ce9
tree25acc7992f3ad35217ec73549f5f56f4050a0af3
parentdecff073ee413dbc39a13b45592897b77e87552f
Add -Wpoison-system-directories warning

When using clang as a cross-compiler, we should not use system
headers to do the compilation.
This CL adds support of a new warning flag -Wpoison-system-directories which
emits warnings if --sysroot is set and headers from common host system location
are used.
By default the warning is disabled.

The intention of the warning is to catch bad includes which are usually
generated by third party build system not targeting cross-compilation.
Such cases happen in Chrome OS when someone imports a new package or upgrade
one to a newer version from upstream.

Patch by: denik (Denis Nikitin)

llvm-svn: 371785
clang/include/clang/Basic/DiagnosticCommonKinds.td
clang/lib/Frontend/InitHeaderSearch.cpp
clang/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/.keep [new file with mode: 0644]
clang/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c++/.keep [new file with mode: 0644]
clang/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/.keep [new file with mode: 0644]
clang/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/include/.keep [new file with mode: 0644]
clang/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/lib/.keep [new file with mode: 0644]
clang/test/Frontend/warning-poison-system-directories.c [new file with mode: 0644]