Reland r371785: Add -Wpoison-system-directories warning
authorManoj Gupta <manojgupta@google.com>
Fri, 13 Sep 2019 18:00:51 +0000 (18:00 +0000)
committerManoj Gupta <manojgupta@google.com>
Fri, 13 Sep 2019 18:00:51 +0000 (18:00 +0000)
commit41d9d5092a17e60615077da6ef22b4f5cfae2c2e
tree77c85d972d72bc4b27cba6e4c7ab8000cf01d19a
parent4cb267f9f5ffed2bbc495ff577287e1d970eba7e
Reland r371785: 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.

This is reland of r371785 with a fix to test file.

Patch by: denik (Denis Nikitin)

llvm-svn: 371878
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]