clang 20.0.0git
EvaluatedExprVisitor.h
Go to the documentation of this file.
1//===--- EvaluatedExprVisitor.h - Evaluated expression visitor --*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the EvaluatedExprVisitor class template, which visits
10// the potentially-evaluated subexpressions of a potentially-evaluated
11// expression.
12//
13//===----------------------------------------------------------------------===//
14#ifndef LLVM_CLANG_AST_EVALUATEDEXPRVISITOR_H
15#define LLVM_CLANG_AST_EVALUATEDEXPRVISITOR_H
16
17#include "clang/AST/DeclCXX.h"
18#include "clang/AST/Expr.h"
19#include "clang/AST/ExprCXX.h"
21#include "llvm/ADT/STLExtras.h"
22
23namespace clang {
24
25class ASTContext;
26
27/// Given a potentially-evaluated expression, this visitor visits all
28/// of its potentially-evaluated subexpressions, recursively.
29template<template <typename> class Ptr, typename ImplClass>
30class EvaluatedExprVisitorBase : public StmtVisitorBase<Ptr, ImplClass, void> {
31protected:
33
34public:
35 // Return whether this visitor should recurse into discarded statements for a
36 // 'constexpr-if'.
37 bool shouldVisitDiscardedStmt() const { return true; }
38#define PTR(CLASS) typename Ptr<CLASS>::type
39
41
42 // Expressions that have no potentially-evaluated subexpressions (but may have
43 // other sub-expressions).
51
53 // Only the base matters.
54 return this->Visit(E->getBase());
55 }
56
57 void