-frewrite-includes: Fix support for __has_include_next
__has_include_next handling inside -frewrite-includes had two
issues. First the Lookup parameter passed to HandleHasInclude was
unused and second, the Lookup paramenter pass was always nullptr and
thus never incremented as intended for __has_include_next
functionality to work.
-frewrite-includes works in two stages. The first stage runs the
preprocessor on the entire file and through callbacks records included
files. The second stage steps through the file again using the raw
lexer and replaces include directives with the recorded includes from
stage one. However in the second stage, the current directory lookup
is not maintained inside PP and PP.GetCurDirLookup() would always
return nullptr.
Instead of relying on PP.GetCurDirLookup(), use HeaderSearch to find
the lookup for the current file and move past it. Update the testsuite
to depend on the new behaviour instead of the old.
Fixes PR26828.