[PATCH] D34158: For Linux/gnu compatibility, preinclude <stdc-predef.h> if the file is available

Melanie Blower via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 7 12:54:08 PDT 2017


mibintc updated this revision to Diff 110055.
mibintc added a comment.

In the last review, it was deemed less controversial if I move these updates back into the gnu/Linux tool chain. This revision is responding to that feedback.  I also simplified the test case. I tested on Linux with check-all and check-clang and found no unexpected failures.

The other test case modifications are to fix tests which are broken with this change due to unexpected changes to the preprocessing. I changed all these to pass -ffreestanding which inhibits the new behavior.

In fact I did have trouble writing the new test case to pass with the gnu/Linux toolchain. In the file lib/Driver/ToolChains/Linux.cpp function AddGnuIncludeArgs checks if GCCInstallation.isValid(). I don't know how to set up a Driver/Inputs sysroot tree so that the isValid check passes. (Does anyone know?) I experimented with various existing trees and had success with basic_cross_linux_tree, so I used that one in the test case. However basic_cross_linux_tree doesn't contain stdc-predef.h.  Would it be OK to add an include file to that tree? (I don't know if it's acceptable to add a new sysroot tree: it is a lot of new files and directories. On the other hand, I don't know if it's OK to co-opt a tree which was added by a different test case)  Perhaps you want me to another test case which verifies that fsystem-include-if-exists works generally. Currently I've added an affirmative test to see that -fsystem-include-if-exists is on the command line, and a test that -ffreestanding inhibits, and a negative test that when given a sysroot without the file, that the preprocessed output shows no indication of stdc-predef.h.


https://reviews.llvm.org/D34158

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Lex/PreprocessorOptions.h
  lib/Driver/ToolChains/Linux.cpp
  lib/Driver/ToolChains/Linux.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/clang_cpp.c
  test/Driver/crash-report-header.h
  test/Driver/crash-report-spaces.c
  test/Driver/crash-report.c
  test/Driver/rewrite-legacy-objc.m
  test/Driver/rewrite-map-in-diagnostics.c
  test/Driver/rewrite-objc.m
  test/Driver/stdc-predef.c
  test/Index/IBOutletCollection.m
  test/Index/annotate-macro-args.m
  test/Index/annotate-tokens-pp.c
  test/Index/annotate-tokens.c
  test/Index/c-index-getCursor-test.m
  test/Index/get-cursor-macro-args.m
  test/Index/get-cursor.cpp
  test/Preprocessor/ignore-pragmas.c
  unittests/Tooling/TestVisitor.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34158.110055.patch
Type: text/x-patch
Size: 33249 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170807/953ae847/attachment-0001.bin>


More information about the cfe-commits mailing list