================ @@ -0,0 +1,355 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "StaticInitializationCycleCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/AST/DynamicRecursiveASTVisitor.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Analysis/CallGraph.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SCCIterator.h" + +using namespace clang; +using namespace clang::ast_matchers; + +// Compute (for the purpose of this check) if the value of a DeclRefExpr is used +// (at runtime). +// The value is not used if it appears at LHS of an assignment or it appears +// inside a compile-time constant expression (like 'sizeof'). +static bool isUnusedValue(const DeclRefExpr *DRE, ASTContext &ACtx) { + ParentMapContext &PMC = ACtx.getParentMapContext(); + DynTypedNodeList Parents = PMC.getParents(*DRE); + const BinaryOperator *ParentBO = nullptr; + while (!Parents.empty()) { + if (const Expr *E = Parents[0].get<Expr>()) { + if (E->isIntegerConstantExpr(ACtx)) + return true; + if ((ParentBO = dyn_cast<BinaryOperator>(E))) + break; + } + Parents = PMC.getParents(Parents[0]); + } ---------------- balazske wrote:
Normally this should stop when a specific parent is reached, otherwise it will reach the `llvm_ureachable` assertion. https://github.com/llvm/llvm-project/pull/175342 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
