@@ -198,7 +198,8 @@ Expr *Expr::getSemanticsProvidingExpr() {
198198 return this ;
199199}
200200
201- bool Expr::printConstExprValue (llvm::raw_ostream *OS) const {
201+ bool Expr::printConstExprValue (llvm::raw_ostream *OS,
202+ llvm::function_ref<bool (Expr*)> additionalCheck) const {
202203 auto print = [&](StringRef text) {
203204 if (OS) {
204205 *OS << text;
@@ -242,7 +243,7 @@ bool Expr::printConstExprValue(llvm::raw_ostream *OS) const {
242243 for (unsigned N = CE->getNumElements (), I = 0 ; I != N; I ++) {
243244 auto Ele = CE->getElement (I);
244245 auto needComma = I + 1 != N;
245- if (!Ele->printConstExprValue (OS)) {
246+ if (!Ele->printConstExprValue (OS, additionalCheck )) {
246247 return false ;
247248 }
248249 if (needComma)
@@ -257,7 +258,7 @@ bool Expr::printConstExprValue(llvm::raw_ostream *OS) const {
257258 for (unsigned N = TE->getNumElements (), I = 0 ; I != N; I ++) {
258259 auto Ele = TE->getElement (I);
259260 auto needComma = I + 1 != N;
260- if (!Ele->printConstExprValue (OS)) {
261+ if (!Ele->printConstExprValue (OS, additionalCheck )) {
261262 return false ;
262263 }
263264 if (needComma)
@@ -267,12 +268,13 @@ bool Expr::printConstExprValue(llvm::raw_ostream *OS) const {
267268 return true ;
268269 }
269270 default :
270- return false ;
271+ return additionalCheck && additionalCheck ( const_cast <Expr*>( this )) ;
271272 }
272273}
273274
274- bool Expr::isSemanticallyConstExpr () const {
275- return printConstExprValue (nullptr );
275+ bool Expr::isSemanticallyConstExpr (
276+ llvm::function_ref<bool (Expr*)> additionalCheck) const {
277+ return printConstExprValue (nullptr , additionalCheck);
276278}
277279
278280Expr *Expr::getValueProvidingExpr () {
0 commit comments