From: Ted Kremenek Date: Tue, 30 Mar 2010 20:30:52 +0000 (+0000) Subject: Use 'const Optional&' to avoid an extra copy. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2cf073b7686a05bc0f637862bdc06f71232db954;p=clang Use 'const Optional&' to avoid an extra copy. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99921 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Checker/RegionStore.cpp b/lib/Checker/RegionStore.cpp index 19cf6d51e0..26d33f6588 100644 --- a/lib/Checker/RegionStore.cpp +++ b/lib/Checker/RegionStore.cpp @@ -963,7 +963,7 @@ Optional RegionStoreManager::getDefaultBinding(RegionBindings B, Optional RegionStoreManager::getBinding(RegionBindings B, const MemRegion *R) { - if (Optional V = getDirectBinding(B, R)) + if (const Optional &V = getDirectBinding(B, R)) return V; return getDefaultBinding(B, R); @@ -1144,7 +1144,7 @@ SVal RegionStoreManager::RetrieveElement(Store store, const ElementRegion* R) { // Check if the region has a binding. RegionBindings B = GetRegionBindings(store); - if (Optional V = getDirectBinding(B, R)) + if (const Optional &V = getDirectBinding(B, R)) return *V; const MemRegion* superR = R->getSuperRegion(); @@ -1175,7 +1175,7 @@ SVal RegionStoreManager::RetrieveElement(Store store, } // Check if the immediate super region has a direct binding. - if (Optional V = getDirectBinding(B, superR)) { + if (const Optional &V = getDirectBinding(B, superR)) { if (SymbolRef parentSym = V->getAsSymbol()) return ValMgr.getDerivedRegionValueSymbolVal(parentSym, R); @@ -1203,7 +1203,7 @@ SVal RegionStoreManager::RetrieveField(Store store, // Check if the region has a binding. RegionBindings B = GetRegionBindings(store); - if (Optional V = getDirectBinding(B, R)) + if (const Optional &V = getDirectBinding(B, R)) return *V; QualType Ty = R->getValueType(getContext()); @@ -1278,13 +1278,13 @@ SVal RegionStoreManager::RetrieveObjCIvar(Store store, const ObjCIvarRegion* R){ // Check if the region has a binding. RegionBindings B = GetRegionBindings(store); - if (Optional V = getDirectBinding(B, R)) + if (const Optional &V = getDirectBinding(B, R)) return *V; const MemRegion *superR = R->getSuperRegion(); // Check if the super region has a default binding. - if (Optional V = getDefaultBinding(B, superR)) { + if (const Optional &V = getDefaultBinding(B, superR)) { if (SymbolRef parentSym = V->getAsSymbol()) return ValMgr.getDerivedRegionValueSymbolVal(parentSym, R); @@ -1300,7 +1300,7 @@ SVal RegionStoreManager::RetrieveVar(Store store, const VarRegion *R) { // Check if the region has a binding. RegionBindings B = GetRegionBindings(store); - if (Optional V = getDirectBinding(B, R)) + if (const Optional &V = getDirectBinding(B, R)) return *V; // Lazily derive a value for the VarRegion. @@ -1788,7 +1788,7 @@ void RemoveDeadBindingsWorker::VisitRegion(const MemRegion *R) { } // Get the data binding for R (if any). - if (Optional V = RM.getBinding(B, R)) + if (const Optional &V = RM.getBinding(B, R)) VisitBinding(*V); }