Skip to content

Commit

Permalink
Add const information about AST nodes used to construct CFG elements.
Browse files Browse the repository at this point in the history
Most constructors and destructors in CFG.h already specify const arguments, but some are missing this.

Reviewed By: gribozavr2, krasimir

Differential Revision: https://reviews.llvm.org/D137584
  • Loading branch information
merrymeerkat authored and gribozavr committed Nov 8, 2022
1 parent e7bb54d commit 3c50f0d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions clang/include/clang/Analysis/CFG.h
Expand Up @@ -131,7 +131,7 @@ class CFGElement {

class CFGStmt : public CFGElement {
public:
explicit CFGStmt(Stmt *S, Kind K = Statement) : CFGElement(K, S) {
explicit CFGStmt(const Stmt *S, Kind K = Statement) : CFGElement(K, S) {
assert(isKind(*this));
}

Expand All @@ -155,7 +155,8 @@ class CFGStmt : public CFGElement {
/// this is only used by the analyzer's CFG.
class CFGConstructor : public CFGStmt {
public:
explicit CFGConstructor(CXXConstructExpr *CE, const ConstructionContext *C)
explicit CFGConstructor(const CXXConstructExpr *CE,
const ConstructionContext *C)
: CFGStmt(CE, Constructor) {
assert(C);
Data2.setPointer(const_cast<ConstructionContext *>(C));
Expand Down Expand Up @@ -185,7 +186,7 @@ class CFGCXXRecordTypedCall : public CFGStmt {
public:
/// Returns true when call expression \p CE needs to be represented
/// by CFGCXXRecordTypedCall, as opposed to a regular CFGStmt.
static bool isCXXRecordTypedCall(Expr *E) {
static bool isCXXRecordTypedCall(const Expr *E) {
assert(isa<CallExpr>(E) || isa<ObjCMessageExpr>(E));
// There is no such thing as reference-type expression. If the function
// returns a reference, it'll return the respective lvalue or xvalue
Expand All @@ -194,7 +195,7 @@ class CFGCXXRecordTypedCall : public CFGStmt {
E->getType().getCanonicalType()->getAsCXXRecordDecl();
}

explicit CFGCXXRecordTypedCall(Expr *E, const ConstructionContext *C)
explicit CFGCXXRecordTypedCall(const Expr *E, const ConstructionContext *C)
: CFGStmt(E, CXXRecordTypedCall) {
assert(isCXXRecordTypedCall(E));
assert(C && (isa<TemporaryObjectConstructionContext>(C) ||
Expand Down Expand Up @@ -225,7 +226,7 @@ class CFGCXXRecordTypedCall : public CFGStmt {
/// list.
class CFGInitializer : public CFGElement {
public:
explicit CFGInitializer(CXXCtorInitializer *initializer)
explicit CFGInitializer(const CXXCtorInitializer *initializer)
: CFGElement(Initializer, initializer) {}

CXXCtorInitializer* getInitializer() const {
Expand Down Expand Up @@ -482,7 +483,7 @@ class CFGMemberDtor : public CFGImplicitDtor {
/// expression for temporary object.
class CFGTemporaryDtor : public CFGImplicitDtor {
public:
CFGTemporaryDtor(CXXBindTemporaryExpr *expr)
CFGTemporaryDtor(const CXXBindTemporaryExpr *expr)
: CFGImplicitDtor(TemporaryDtor, expr, nullptr) {}

const CXXBindTemporaryExpr *getBindTemporaryExpr() const {
Expand Down

0 comments on commit 3c50f0d

Please sign in to comment.