"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/StaticAnalyzer/Core/SymbolManager.cpp" between
cfe-8.0.1.src.tar.xz and cfe-9.0.0.src.tar.xz

About: Clang is an LLVM front end for the C, C++, and Objective-C languages. Clang aims to provide a better user experience through expressive diagnostics, a high level of conformance to language standards, fast compilation, and low memory use.

SymbolManager.cpp  (cfe-8.0.1.src.tar.xz):SymbolManager.cpp  (cfe-9.0.0.src.tar.xz)
//===- SymbolManager.h - Management of Symbolic Values --------------------===// //===- SymbolManager.h - Management of Symbolic Values --------------------===//
// //
// The LLVM Compiler Infrastructure // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// // See https://llvm.org/LICENSE.txt for license information.
// This file is distributed under the University of Illinois Open Source // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines SymbolManager, a class that manages symbolic values // This file defines SymbolManager, a class that manages symbolic values
// created for use by ExprEngine and related classes. // created for use by ExprEngine and related classes.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
#include "clang/AST/ASTContext.h" #include "clang/AST/ASTContext.h"
skipping to change at line 408 skipping to change at line 407
} }
} }
} }
void SymbolReaper::markLive(SymbolRef sym) { void SymbolReaper::markLive(SymbolRef sym) {
TheLiving[sym] = NotProcessed; TheLiving[sym] = NotProcessed;
markDependentsLive(sym); markDependentsLive(sym);
} }
void SymbolReaper::markLive(const MemRegion *region) { void SymbolReaper::markLive(const MemRegion *region) {
RegionRoots.insert(region); RegionRoots.insert(region->getBaseRegion());
markElementIndicesLive(region); markElementIndicesLive(region);
} }
void SymbolReaper::markElementIndicesLive(const MemRegion *region) { void SymbolReaper::markElementIndicesLive(const MemRegion *region) {
for (auto SR = dyn_cast<SubRegion>(region); SR; for (auto SR = dyn_cast<SubRegion>(region); SR;
SR = dyn_cast<SubRegion>(SR->getSuperRegion())) { SR = dyn_cast<SubRegion>(SR->getSuperRegion())) {
if (const auto ER = dyn_cast<ElementRegion>(SR)) { if (const auto ER = dyn_cast<ElementRegion>(SR)) {
SVal Idx = ER->getIndex(); SVal Idx = ER->getIndex();
for (auto SI = Idx.symbol_begin(), SE = Idx.symbol_end(); SI != SE; ++SI) for (auto SI = Idx.symbol_begin(), SE = Idx.symbol_end(); SI != SE; ++SI)
markLive(*SI); markLive(*SI);
} }
} }
} }
void SymbolReaper::markInUse(SymbolRef sym) { void SymbolReaper::markInUse(SymbolRef sym) {
if (isa<SymbolMetadata>(sym)) if (isa<SymbolMetadata>(sym))
MetadataInUse.insert(sym); MetadataInUse.insert(sym);
} }
bool SymbolReaper::isLiveRegion(const MemRegion *MR) { bool SymbolReaper::isLiveRegion(const MemRegion *MR) {
// TODO: For now, liveness of a memory region is equivalent to liveness of its
// base region. In fact we can do a bit better: say, if a particular FieldDecl
// is not used later in the path, we can diagnose a leak of a value within
// that field earlier than, say, the variable that contains the field dies.
MR = MR->getBaseRegion();
if (RegionRoots.count(MR)) if (RegionRoots.count(MR))
return true; return true;
MR = MR->getBaseRegion();
if (const auto *SR = dyn_cast<SymbolicRegion>(MR)) if (const auto *SR = dyn_cast<SymbolicRegion>(MR))
return isLive(SR->getSymbol()); return isLive(SR->getSymbol());
if (const auto *VR = dyn_cast<VarRegion>(MR)) if (const auto *VR = dyn_cast<VarRegion>(MR))
return isLive(VR, true); return isLive(VR, true);
// FIXME: This is a gross over-approximation. What we really need is a way to // FIXME: This is a gross over-approximation. What we really need is a way to
// tell if anything still refers to this region. Unlike SymbolicRegions, // tell if anything still refers to this region. Unlike SymbolicRegions,
// AllocaRegions don't have associated symbols, though, so we don't actually // AllocaRegions don't have associated symbols, though, so we don't actually
// have a way to track their liveness. // have a way to track their liveness.
 End of changes. 4 change blocks. 
7 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)