This is an archive of the discontinued LLVM Phabricator instance.

[clang][lex] Fix failures with Microsoft header search rules
ClosedPublic

Authored by jansvoboda11 on Mar 22 2022, 9:19 AM.

Details

Summary

HeaderSearch currently assumes LookupFileCache is eventually populated in LookupFile. However, that's not always the case with -fms-compatibility and its early returns.

This patch adds a defensive check that the iterator pulled out of the cache is actually valid before using it.

(This bug was introduced in D119721. Before that, the cache was initialized to 0 - essentially the search_dir_begin() iterator.)

Diff Detail

Event Timeline

jansvoboda11 created this revision.Mar 22 2022, 9:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2022, 9:19 AM
jansvoboda11 requested review of this revision.Mar 22 2022, 9:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2022, 9:19 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

I think this ends up being the same as what we came up with internally, so I think this LGTM!

erichkeane accepted this revision.Mar 22 2022, 9:32 AM
This revision is now accepted and ready to land.Mar 22 2022, 9:32 AM

Remove slash from test to make it pass on Windows