[llvm-branch-commits] [clang] [llvm] [Clang][Lex] Fix __has_include_next to return false when no valid next dir (PR #173717)

Zachary Fogg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Dec 27 04:46:30 PST 2025


zfogg wrote:

I need to verify this more carefully. Looking at the code, `EvaluateHasIncludeNext` is identical between `release/21.x` and `main`. 

My original observation may have been incorrect - the bug might exist in both versions. I'll verify whether this fix is also needed for `main` and create a separate PR if so.

The issue occurs when:
1. A file is included via absolute path (not through a search directory)
2. That file contains `__has_include_next()`
3. `getIncludeNextStart()` returns `{nullptr, LookupFromFile}` because there's no search directory
4. `EvaluateHasIncludeCommon` should return `false` in this case, but instead tries to look up the file

If the bug exists in main, I'll create a PR targeting main first, then cherry-pick to 21.x.

https://github.com/llvm/llvm-project/pull/173717


More information about the llvm-branch-commits mailing list