[clang] [clang] Don't issue permission error during header search (PR #194015)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 28 08:24:26 PDT 2026


AaronBallman wrote:

> Error on has_include seems right to me: we can't reliably answer the question if there are permission issues.

I can see an argument either way. `__has_include` can be asking "does this file exist" but I think it more practically is the user asking "can I include this file?" From the "does this file exist" perspective, an error makes more sense because the file may or may not exist, we don't have permission to know. But from the "can I include this file" perspective, I think returning `false` without a diagnostic makes sense -- no, you cannot include that file, and presumably you're only asking because you are prepared for the answer to be no.

What do other compilers do for permission errors? Is there a de facto standard behavior to follow?

That said, I'd want `__has_embed` and `__has_include_next` to behave the same as `__has_include`; I don't think we'd want a different behavior for the same kind of issue.

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


More information about the cfe-commits mailing list