Skip to content

Commit bba3849

Browse files
authored
[clang][docs] Add documentation for APValue constructors (llvm#109994)
I always get confused when looking at these.
1 parent 5030dea commit bba3849

File tree

1 file changed

+56
-12
lines changed

1 file changed

+56
-12
lines changed

clang/include/clang/AST/APValue.h

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -314,51 +314,95 @@ class APValue {
314314
DataType Data;
315315

316316
public:
317+
/// Creates an empty APValue of type None.
317318
APValue() : Kind(None) {}
319+
/// Creates an integer APValue holding the given value.
318320
explicit APValue(APSInt I) : Kind(None) {
319321
MakeInt(); setInt(std::move(I));
320322
}
323+
/// Creates a float APValue holding the given value.
321324
explicit APValue(APFloat F) : Kind(None) {
322325
MakeFloat(); setFloat(std::move(F));
323326
}
327+
/// Creates a fixed-point APValue holding the given value.
324328
explicit APValue(APFixedPoint FX) : Kind(None) {
325329
MakeFixedPoint(std::move(FX));
326330
}
331+
/// Creates a vector APValue with \p N elements. The elements
332+
/// are read from \p E.
327333
explicit APValue(const APValue *E, unsigned N) : Kind(None) {
328334
MakeVector(); setVector(E, N);
329335
}
336+
/// Creates an integer complex APValue with the given real and imaginary
337+
/// values.
330338
APValue(APSInt R, APSInt I) : Kind(None) {
331339
MakeComplexInt(); setComplexInt(std::move(R), std::move(I));
332340
}
341+
/// Creates a float complex APValue with the given real and imaginary values.
333342
APValue(APFloat R, APFloat I) : Kind(None) {
334343
MakeComplexFloat(); setComplexFloat(std::move(R), std::move(I));
335344
}
336345
APValue(const APValue &RHS);
337346
APValue(APValue &&RHS);
338-
APValue(LValueBase B, const CharUnits &O, NoLValuePath N,
347+
/// Creates an lvalue APValue without an lvalue path.
348+
/// \param Base The base of the lvalue.
349+
/// \param Offset The offset of the lvalue.
350+
/// \param IsNullPtr Whether this lvalue is a null pointer.
351+
APValue(LValueBase Base, const CharUnits &Offset, NoLValuePath,
339352
bool IsNullPtr = false)
340353
: Kind(None) {
341-
MakeLValue(); setLValue(B, O, N, IsNullPtr);
342-
}
343-
APValue(LValueBase B, const CharUnits &O, ArrayRef<LValuePathEntry> Path,
344-
bool OnePastTheEnd, bool IsNullPtr = false)
354+
MakeLValue();
355+
setLValue(Base, Offset, NoLValuePath{}, IsNullPtr);
356+
}
357+
/// Creates an lvalue APValue with an lvalue path.
358+
/// \param Base The base of the lvalue.
359+
/// \param Offset The offset of the lvalue.
360+
/// \param Path The lvalue path.
361+
/// \param OnePastTheEnd Whether this lvalue is one-past-the-end of the
362+
/// subobject it points to.
363+
/// \param IsNullPtr Whether this lvalue is a null pointer.
364+
APValue(LValueBase Base, const CharUnits &Offset,
365+
ArrayRef<LValuePathEntry> Path, bool OnePastTheEnd,
366+
bool IsNullPtr = false)
345367
: Kind(None) {
346-
MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, IsNullPtr);
347-
}
368+
MakeLValue();
369+
setLValue(Base, Offset, Path, OnePastTheEnd, IsNullPtr);
370+
}
371+
/// Creates a new array APValue.
372+
/// \param UninitArray Marker. Pass an empty UninitArray.
373+
/// \param InitElts Number of elements you're going to initialize in the
374+
/// array.
375+
/// \param Size Full size of the array.
348376
APValue(UninitArray, unsigned InitElts, unsigned Size) : Kind(None) {
349377
MakeArray(InitElts, Size);
350378
}
351-
APValue(UninitStruct, unsigned B, unsigned M) : Kind(None) {
352-
MakeStruct(B, M);
353-
}
354-
explicit APValue(const FieldDecl *D, const APValue &V = APValue())
379+
/// Creates a new struct APValue.
380+
/// \param UninitStruct Marker. Pass an empty UninitStruct.
381+
/// \param NumBases Number of bases.
382+
/// \param NumMembers Number of members.
383+
APValue(UninitStruct, unsigned NumBases, unsigned NumMembers) : Kind(None) {
384+
MakeStruct(NumBases, NumMembers);
385+
}
386+
/// Creates a new union APValue.
387+
/// \param ActiveDecl The FieldDecl of the active union member.
388+
/// \param ActiveValue The value of the active union member.
389+
explicit APValue(const FieldDecl *ActiveDecl,
390+
const APValue &ActiveValue = APValue())
355391
: Kind(None) {
356-
MakeUnion(); setUnion(D, V);
392+
MakeUnion();
393+
setUnion(ActiveDecl, ActiveValue);
357394
}
395+
/// Creates a new member pointer APValue.
396+
/// \param Member Declaration of the member
397+
/// \param IsDerivedMember Whether member is a derived one.
398+
/// \param Path The path of the member.
358399
APValue(const ValueDecl *Member, bool IsDerivedMember,
359400
ArrayRef<const CXXRecordDecl*> Path) : Kind(None) {
360401
MakeMemberPointer(Member, IsDerivedMember, Path);
361402
}
403+
/// Creates a new address label diff APValue.
404+
/// \param LHSExpr The left-hand side of the difference.
405+
/// \param RHSExpr The right-hand side of the difference.
362406
APValue(const AddrLabelExpr* LHSExpr, const AddrLabelExpr* RHSExpr)
363407
: Kind(None) {
364408
MakeAddrLabelDiff(); setAddrLabelDiff(LHSExpr, RHSExpr);

0 commit comments

Comments
 (0)