]> granicus.if.org Git - clang/commit
Preprocessor: Suppress -Wnonportable-include-path for header maps
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 27 Apr 2017 21:41:51 +0000 (21:41 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 27 Apr 2017 21:41:51 +0000 (21:41 +0000)
commitfc4c78381af3a65eb64567c94bac097b6b0246e4
tree676bfacc9bd028284df37322477d17edc9950a1f
parentdff815aaab302b85a0543851f716a948333cb870
Preprocessor: Suppress -Wnonportable-include-path for header maps

If a file search involves a header map, suppress
-Wnonportable-include-path.  It's firing lots of false positives for
framework authors internally, and it's not trivial to fix.

Consider a framework called "Foo" with a main (installed) framework header
"Foo/Foo.h".  It's atypical for "Foo.h" to actually live inside a
directory called "Foo" in the source repository.  Instead, the
build system generates a header map while building the framework.
If Foo.h lives at the top-level of the source repository (common), and
the git repo is called ssh://some.url/foo.git, then the header map will
have something like:

    Foo/Foo.h -> /Users/myname/code/foo/Foo.h

where "/Users/myname/code/foo" is the clone of ssh://some.url/foo.git.

After #import <Foo/Foo.h>, the current implementation of
-Wnonportable-include-path will falsely assume that Foo.h was found in a
nonportable way, because of the name of the git clone (.../foo/Foo.h).
However, that directory name was not involved in the header search at
all.

This commit adds an extra parameter to Preprocessor::LookupFile and
HeaderSearch::LookupFile to track if the search used a header map,
making it easy to suppress the warning.  Longer term, once we find a way
to avoid the false positive, we should turn the warning back on.

rdar://problem/28863903

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301592 91177308-0d34-0410-b5e6-96231b3b80d8
12 files changed:
include/clang/Lex/HeaderSearch.h
include/clang/Lex/Preprocessor.h
lib/Frontend/CompilerInstance.cpp
lib/Frontend/Rewrite/InclusionRewriter.cpp
lib/Frontend/VerifyDiagnosticConsumer.cpp
lib/Lex/HeaderSearch.cpp
lib/Lex/PPDirectives.cpp
lib/Lex/PPMacroExpansion.cpp
lib/Lex/Pragma.cpp
test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap [new file with mode: 0644]
test/Preprocessor/Inputs/nonportable-hmaps/headers/foo/Foo.h [new file with mode: 0644]
test/Preprocessor/nonportable-include-with-hmap.c [new file with mode: 0644]