Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
3513ea8
verify: Assume an invariant's definedness at its loop's head, where a…
SwayamInSync Oct 24, 2026
962251b
test: Check loops that initialize local storage and invariants whose …
SwayamInSync Oct 24, 2026
cf024f0
verify: Assume at a loop's head only the definedness checks whose con…
SwayamInSync Oct 24, 2026
d0a17ce
docs: Describe an invariant's definedness at the head and initializat…
SwayamInSync Oct 24, 2026
fcd1d6c
docs: Note loops that initialize local storage in the release notes.
SwayamInSync Oct 24, 2026
b2e73ca
docs: State that an invariant holds with its definedness at the head …
SwayamInSync Oct 24, 2026
57b9e8e
docs: Describe definedness and initialization at a loop's head in the…
SwayamInSync Oct 24, 2026
d879449
verify: Frame a loop that writes local or dynamic storage by the cell…
SwayamInSync Oct 24, 2026
92f0ab7
test: Check that a loop writing local storage keeps every other object.
SwayamInSync Oct 24, 2026
a0698a7
docs: Describe the local and dynamic objects a loop writes, with a ch…
SwayamInSync Oct 24, 2026
6f9a7ca
docs: Note loops that write local storage in the release notes.
SwayamInSync Oct 24, 2026
7d5c123
docs: Count local and dynamic objects in a loop's write set in the de…
SwayamInSync Oct 24, 2026
991d0ef
docs: Describe loop frames of local and dynamic storage in the archit…
SwayamInSync Oct 24, 2026
ab5515b
verify: Mark a function that constructs its object.
SwayamInSync Oct 24, 2026
0c470f1
verify: Clone the constructor mark.
SwayamInSync Oct 24, 2026
3094064
verify: Keep a function's constructor mark through loop unrolling.
SwayamInSync Oct 24, 2026
8e0ebbf
verify: Declare the construction of an object and its member initiali…
SwayamInSync Oct 24, 2026
5cb75c1
verify: Verify constructors on their caller's storage and run them wh…
SwayamInSync Oct 24, 2026
3d812d8
verify: Check every member of a constructor's object at its end and m…
SwayamInSync Oct 24, 2026
909c00e
test: Check constructors, their callers, and implicit constructors.
SwayamInSync Oct 24, 2026
7f68f9a
test: Expect the constructor of a class with a destructor to be rejec…
SwayamInSync Oct 24, 2026
62ecdd3
docs: Describe constructors, with a checked example.
SwayamInSync Oct 24, 2026
ddd1330
docs: List constructors as supported in the limitations.
SwayamInSync Oct 24, 2026
f9ba04b
docs: Note constructors in the release notes.
SwayamInSync Oct 24, 2026
284bfbe
docs: Describe constructors in the design.
SwayamInSync Oct 24, 2026
c0d0135
docs: Describe constructors in the architecture.
SwayamInSync Oct 24, 2026
94d85b1
verify: Declare reading a record value kept in memory field by field.
SwayamInSync Oct 24, 2026
5568b3a
verify: Pass, return, and copy a record kept in memory by value, read…
SwayamInSync Oct 24, 2026
4de0f8e
test: Check records kept in memory passed, returned, and copied by va…
SwayamInSync Oct 24, 2026
df6b301
test: Expect a record read through a reference and passed by value to…
SwayamInSync Oct 24, 2026
59959a3
docs: Describe records read and passed by value from memory, with a c…
SwayamInSync Oct 24, 2026
1e454f5
docs: Narrow the unsupported whole-record reads in the limitations.
SwayamInSync Oct 24, 2026
ff29f57
docs: Note records in memory by value in the release notes.
SwayamInSync Oct 24, 2026
c447b9b
docs: Describe records in memory by value in the design.
SwayamInSync Oct 24, 2026
1f809ef
docs: Describe reading records in memory by value in the architecture.
SwayamInSync Oct 24, 2026
25328ce
docs: Link constructed objects by value to the section that describes…
SwayamInSync Oct 24, 2026
c860ed3
verify: Declare the class invariants of a member function's entry and…
SwayamInSync Oct 24, 2026
1969e1a
verify: Hold a class's invariant at its public member functions and c…
SwayamInSync Oct 24, 2026
7f4c1a9
verify: Frame a call's write of a record parameter's object as the ce…
SwayamInSync Oct 24, 2026
1f6e4cb
test: Check class invariants at member functions, constructors, and c…
SwayamInSync Oct 24, 2026
86274fc
docs: Describe class invariants, with a checked example.
SwayamInSync Oct 24, 2026
97222ba
docs: Note class invariants and calls that write a record in the rele…
SwayamInSync Oct 24, 2026
1ecf271
docs: Describe class invariants in the design.
SwayamInSync Oct 24, 2026
6b74d76
docs: Describe class invariants and call frames of records in the arc…
SwayamInSync Oct 24, 2026
b58968c
verify: Declare the object a class invariant is instantiated for.
SwayamInSync Oct 24, 2026
23288e0
verify: Call a member operator on its first operand, return a member'…
SwayamInSync Oct 24, 2026
c0c0688
verify: Let a callee lent a local object have local objects of its own.
SwayamInSync Oct 24, 2026
8fc95d0
test: Check member operators and the invariants of objects passed by …
SwayamInSync Oct 24, 2026
3b5d6a1
test: Check a null pointer argument and an extent through a reference…
SwayamInSync Oct 24, 2026
dcb9c9f
test: Expect a record's invariant to hold through a reference.
SwayamInSync Oct 24, 2026
2e04499
verify: Declare the check that rejects using the reference a member r…
SwayamInSync Oct 24, 2026
19d1182
verify: Reject a copy or assignment from the reference a member retur…
SwayamInSync Oct 24, 2026
1ff05af
test: Check copying and assigning the reference a member operator ret…
SwayamInSync Oct 24, 2026
1b7dd64
docs: Describe member operators and the class invariants of objects p…
SwayamInSync Oct 24, 2026
010fc0c
docs: Note member operators and class invariants at reference and poi…
SwayamInSync Oct 24, 2026
4380589
docs: Design member operators, own-object returns, and type invariant…
SwayamInSync Oct 24, 2026
1aefeef
docs: Describe how member operators and the invariants of parameters …
SwayamInSync Oct 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
610 changes: 551 additions & 59 deletions clang/lib/Verify/Frontend/ASTConverter.cpp

Large diffs are not rendered by default.

37 changes: 35 additions & 2 deletions clang/lib/Verify/Frontend/ASTConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ class ASTConverter {
/// address parameter, by the synthetic parameter of the field's entry value
/// (VFunction::FieldParams).
std::map<const Expr *, std::string> FieldExtentParameters;
/// Converting a clause where an extent marker states nothing (a class
/// invariant at exit): each marker is true.
bool DropExtentMarkers = false;
/// The object `this` stands for while a class invariant is instantiated
/// for a parameter: the pointer or reference that addresses it.
const VExpr *ThisSubstitute = nullptr;
std::set<const VarDecl *> GhostLocals;
unsigned DynamicProvenanceId = 0;
unsigned DynamicPointerAssignmentId = 0;
Expand Down Expand Up @@ -231,6 +237,18 @@ class ASTConverter {
const VExpr *Base, uint64_t Offset,
SourceLocation Loc,
std::vector<std::unique_ptr<VStmt>> &Out);
/// The member initializers of a constructor, in the order they run, on
/// the object at Base + Offset.
bool appendMemberInitializers(const CXXConstructorDecl *Ctor,
const VExpr *Base, uint64_t Offset,
SourceLocation Loc,
std::vector<std::unique_ptr<VStmt>> &Out);
/// Runs a constructor on the object at Base + Offset: a call of one the
/// class provides, else its members' initializers.
bool appendConstruction(const CXXConstructExpr *Construct, QualType Ty,
const VExpr *Base, uint64_t Offset,
SourceLocation Loc,
std::vector<std::unique_ptr<VStmt>> &Out);
bool appendObjectZeroInitialization(QualType Ty, const VExpr *Base,
uint64_t Offset, SourceLocation Loc,
std::vector<std::unique_ptr<VStmt>> &Out);
Expand Down Expand Up @@ -286,6 +304,13 @@ class ASTConverter {
std::string Provenance = "");
bool appendRecordCallArgument(const Expr *E, const ParmVarDecl *Formal,
std::vector<std::unique_ptr<VExpr>> &Args);
/// The fields of a record value that is kept in memory, a local object or
/// one a pointer or reference addresses, each read where it is: nothing
/// when E is no such record, false after an error.
std::optional<bool> recordFieldsInMemory(
const Expr *E, SourceLocation Loc,
std::vector<std::pair<const FieldDecl *, std::unique_ptr<VExpr>>>
&Fields);
std::unique_ptr<VExpr>
convertAssignmentValue(const BinaryOperator *Assignment);
void appendAssignment(const Expr *LHS, std::unique_ptr<VExpr> Value,
Expand All @@ -299,6 +324,9 @@ class ASTConverter {
bool appendRecordCopy(const Expr *Source, const VarDecl *Target,
SourceLocation Loc,
std::vector<std::unique_ptr<VStmt>> &Out);
/// Reports a use of the reference a member function returns to its own
/// object, which is no value.
bool rejectOwnObjectUse(const Expr *E);
bool appendRecordInitializer(const InitListExpr *Init, const VarDecl *Target,
SourceLocation Loc,
std::vector<std::unique_ptr<VStmt>> &Out);
Expand Down Expand Up @@ -351,8 +379,13 @@ class ASTConverter {
/// of FCI's preconditions names a synthetic parameter for its entry value
/// (VFunction::FieldParams), and returns them for the default
/// separation.
std::vector<AddressEntry> collectFieldExtents(const FunctionContractInfo &FCI,
VFunction &Fn);
std::vector<AddressEntry>
collectFieldExtents(const FunctionContractInfo &FCI,
llvm::ArrayRef<const Expr *> Invariants, VFunction &Fn);
std::vector<const Expr *> entryClassInvariants(const CXXMethodDecl *Method,
bool Constructor) const;
std::vector<const Expr *> exitClassInvariants(const CXXMethodDecl *Method,
bool Constructor) const;
void registerLayoutType(QualType QT, VFunction &Fn);
void buildRecordLayout(QualType QT, VFunction &Fn);
void buildArrayLayout(QualType QT, const ConstantArrayType *CAT,
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Verify/IR/VStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ VFunction verify::cloneVFunction(const VFunction &Fn) {
Out.SourceVariables = Fn.SourceVariables;
Out.ScalarReferenceParams = Fn.ScalarReferenceParams;
Out.RecordParams = Fn.RecordParams;
Out.IsConstructor = Fn.IsConstructor;
for (const auto &[Name, Field] : Fn.FieldParams)
Out.FieldParams.emplace_back(Name, cloneVExpr(Field.get()));
Out.ConstAddressParams = Fn.ConstAddressParams;
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Verify/IR/VStmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ struct VFunction {
/// [[cppverify::trusted]]: its contract is assumed and its body, if any,
/// is not verified.
bool IsTrusted = false;
/// A constructor: its object's lifetime begins at `this`, uninitialized,
/// and the body initializes every leaf of it.
bool IsConstructor = false;
/// The declaration, for diagnostics about the function itself.
SourceLocation DeclLoc;
bool NeedsDecreasesCheck = false;
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Verify/Transform/LoopUnroll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ VFunction LoopUnroller::unroll(const VFunction &Fn, unsigned K) {
Out.SourceVariables = Fn.SourceVariables;
Out.ScalarReferenceParams = Fn.ScalarReferenceParams;
Out.RecordParams = Fn.RecordParams;
Out.IsConstructor = Fn.IsConstructor;
for (const auto &[Name, Field] : Fn.FieldParams)
Out.FieldParams.emplace_back(Name, cloneVExpr(Field.get()));
Out.ConstAddressParams = Fn.ConstAddressParams;
Expand Down
Loading
Loading