[all-commits] [llvm/llvm-project] 9e0474: Perform access checking to private members in simp...
Utkarsh Saxena via All-commits
all-commits at lists.llvm.org
Wed Jan 11 03:14:24 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 9e0474fbb9c56725a1dfd1658837f07db73f4d8d
https://github.com/llvm/llvm-project/commit/9e0474fbb9c56725a1dfd1658837f07db73f4d8d
Author: Utkarsh Saxena <usx at google.com>
Date: 2023-01-11 (Wed, 11 Jan 2023)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/AST/ExprConcepts.h
M clang/lib/Parse/ParseExprCXX.cpp
M clang/lib/Sema/SemaAccess.cpp
M clang/lib/Sema/SemaConcept.cpp
M clang/lib/Sema/SemaTemplateInstantiate.cpp
M clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp
A clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
Log Message:
-----------
Perform access checking to private members in simple requirement.
> Dependent access checks.
Fixes: https://github.com/llvm/llvm-project/issues/53364
We previously ignored dependent access checks to private members.
These are visible only to the `RequiresExprBodyExpr` (through `PerformDependentDiagnositcs`) and not to the individual requirements.
---
> Non-dependent access checks.
Fixes: https://github.com/llvm/llvm-project/issues/53334
Access to members in a non-dependent context would always yield an
invalid expression. When it appears in a requires-expression, then this
is a hard error as this would always result in a substitution failure.
https://eel.is/c++draft/expr.prim.req#general-note-1
> Note 1: If a requires-expression contains invalid types or expressions in its requirements, and it does not appear within the declaration of a templated entity, then the program is ill-formed. — end note]
> If the substitution of template arguments into a requirement would always result in a substitution failure, the program is ill-formed; no diagnostic required.
The main issue here is the delaying of the diagnostics.
Use a `ParsingDeclRAIIObject` creates a separate diagnostic pool for diagnositcs associated to the `RequiresExprBodyDecl`.
This is important because dependent diagnostics should not be leaked/delayed to higher scopes (Eg. inside a template function or in a trailing requires). These dependent diagnostics must be attached to the `DeclContext` of the parameters of `RequiresExpr` (which is the `RequiresExprBodyDecl` in this case).
Non dependent diagnostics, on the other hand, should not delayed and surfaced as hard errors.
Differential Revision: https://reviews.llvm.org/D140547
More information about the All-commits
mailing list