[PATCH] D45603: Fix evaluation of `__has_include_next` during -frewrite-includes.

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 12 16:44:12 PDT 2018


vsapsai created this revision.
vsapsai added a reviewer: bkramer.
Herald added a subscriber: jkorous-apple.

`__has_include_next` requires correct DirectoryLookup for being
evaluated correctly. We were using Preprocessor::GetCurDirLookup() but
we were calling it after the preprocessor finished its work. And in this
case CurDirLookup is always nullptr which makes `__has_include_next`
behave as `__has_include`.

Fix by storing and using CurDirLookup when preprocessor enters a file,
not when we rewrite the includes.

rdar://problem/36305026


https://reviews.llvm.org/D45603

Files:
  clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
  clang/test/Frontend/Inputs/NextIncludes/rewrite-includes9.h
  clang/test/Frontend/Inputs/rewrite-includes9.h
  clang/test/Frontend/rewrite-includes.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45603.142299.patch
Type: text/x-patch
Size: 9181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180412/dca4d592/attachment.bin>


More information about the cfe-commits mailing list