-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[analyzer][NFC] Trivial refactoring of region invalidation #102456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit removes `invalidateRegionsImpl()`, moving its body to `invalidateRegions(ValueList Values, ...)`, because it was a completely useless layer of indirection. Moreover I'm fixing some strange indentation within this function body and renaming two variables to the proper `UpperCamelCase` format.
@llvm/pr-subscribers-clang Author: Donát Nagy (NagyDonat) ChangesThis commit removes Moreover I'm fixing some strange indentation within this function body and renaming two variables to the proper Full diff: https://github.com/llvm/llvm-project/pull/102456.diff 2 Files Affected:
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
index 51d76dc257ee9..9889d2604a890 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -484,17 +484,6 @@ class ProgramState : public llvm::FoldingSetNode {
friend void ProgramStateRetain(const ProgramState *state);
friend void ProgramStateRelease(const ProgramState *state);
- /// \sa invalidateValues()
- /// \sa invalidateRegions()
- ProgramStateRef
- invalidateRegionsImpl(ArrayRef<SVal> Values,
- const Expr *E, unsigned BlockCount,
- const LocationContext *LCtx,
- bool ResultsInSymbolEscape,
- InvalidatedSymbols *IS,
- RegionAndSymbolInvalidationTraits *HTraits,
- const CallEvent *Call) const;
-
SVal wrapSymbolicRegion(SVal Base) const;
};
diff --git a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp
index f82cd944750a3..e6d3399a21942 100644
--- a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -159,8 +159,8 @@ ProgramState::invalidateRegions(RegionList Regions,
for (const MemRegion *Reg : Regions)
Values.push_back(loc::MemRegionVal(Reg));
- return invalidateRegionsImpl(Values, E, Count, LCtx, CausedByPointerEscape,
- IS, ITraits, Call);
+ return invalidateRegions(Values, E, Count, LCtx, CausedByPointerEscape, IS,
+ Call, ITraits);
}
ProgramStateRef
@@ -172,18 +172,6 @@ ProgramState::invalidateRegions(ValueList Values,
const CallEvent *Call,
RegionAndSymbolInvalidationTraits *ITraits) const {
- return invalidateRegionsImpl(Values, E, Count, LCtx, CausedByPointerEscape,
- IS, ITraits, Call);
-}
-
-ProgramStateRef
-ProgramState::invalidateRegionsImpl(ValueList Values,
- const Expr *E, unsigned Count,
- const LocationContext *LCtx,
- bool CausedByPointerEscape,
- InvalidatedSymbols *IS,
- RegionAndSymbolInvalidationTraits *ITraits,
- const CallEvent *Call) const {
ProgramStateManager &Mgr = getStateManager();
ExprEngine &Eng = Mgr.getOwningEngine();
@@ -197,21 +185,18 @@ ProgramState::invalidateRegionsImpl(ValueList Values,
StoreManager::InvalidatedRegions TopLevelInvalidated;
StoreManager::InvalidatedRegions Invalidated;
- const StoreRef &newStore
- = Mgr.StoreMgr->invalidateRegions(getStore(), Values, E, Count, LCtx, Call,
- *IS, *ITraits, &TopLevelInvalidated,
- &Invalidated);
+ const StoreRef &NewStore = Mgr.StoreMgr->invalidateRegions(
+ getStore(), Values, E, Count, LCtx, Call, *IS, *ITraits,
+ &TopLevelInvalidated, &Invalidated);
- ProgramStateRef newState = makeWithStore(newStore);
+ ProgramStateRef NewState = makeWithStore(NewStore);
if (CausedByPointerEscape) {
- newState = Eng.notifyCheckersOfPointerEscape(newState, IS,
- TopLevelInvalidated,
- Call,
- *ITraits);
+ NewState = Eng.notifyCheckersOfPointerEscape(
+ NewState, IS, TopLevelInvalidated, Call, *ITraits);
}
- return Eng.processRegionChanges(newState, IS, TopLevelInvalidated,
+ return Eng.processRegionChanges(NewState, IS, TopLevelInvalidated,
Invalidated, LCtx, Call);
}
|
@llvm/pr-subscribers-clang-static-analyzer-1 Author: Donát Nagy (NagyDonat) ChangesThis commit removes Moreover I'm fixing some strange indentation within this function body and renaming two variables to the proper Full diff: https://github.com/llvm/llvm-project/pull/102456.diff 2 Files Affected:
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
index 51d76dc257ee94..9889d2604a890e 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -484,17 +484,6 @@ class ProgramState : public llvm::FoldingSetNode {
friend void ProgramStateRetain(const ProgramState *state);
friend void ProgramStateRelease(const ProgramState *state);
- /// \sa invalidateValues()
- /// \sa invalidateRegions()
- ProgramStateRef
- invalidateRegionsImpl(ArrayRef<SVal> Values,
- const Expr *E, unsigned BlockCount,
- const LocationContext *LCtx,
- bool ResultsInSymbolEscape,
- InvalidatedSymbols *IS,
- RegionAndSymbolInvalidationTraits *HTraits,
- const CallEvent *Call) const;
-
SVal wrapSymbolicRegion(SVal Base) const;
};
diff --git a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp
index f82cd944750a3c..e6d3399a219424 100644
--- a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -159,8 +159,8 @@ ProgramState::invalidateRegions(RegionList Regions,
for (const MemRegion *Reg : Regions)
Values.push_back(loc::MemRegionVal(Reg));
- return invalidateRegionsImpl(Values, E, Count, LCtx, CausedByPointerEscape,
- IS, ITraits, Call);
+ return invalidateRegions(Values, E, Count, LCtx, CausedByPointerEscape, IS,
+ Call, ITraits);
}
ProgramStateRef
@@ -172,18 +172,6 @@ ProgramState::invalidateRegions(ValueList Values,
const CallEvent *Call,
RegionAndSymbolInvalidationTraits *ITraits) const {
- return invalidateRegionsImpl(Values, E, Count, LCtx, CausedByPointerEscape,
- IS, ITraits, Call);
-}
-
-ProgramStateRef
-ProgramState::invalidateRegionsImpl(ValueList Values,
- const Expr *E, unsigned Count,
- const LocationContext *LCtx,
- bool CausedByPointerEscape,
- InvalidatedSymbols *IS,
- RegionAndSymbolInvalidationTraits *ITraits,
- const CallEvent *Call) const {
ProgramStateManager &Mgr = getStateManager();
ExprEngine &Eng = Mgr.getOwningEngine();
@@ -197,21 +185,18 @@ ProgramState::invalidateRegionsImpl(ValueList Values,
StoreManager::InvalidatedRegions TopLevelInvalidated;
StoreManager::InvalidatedRegions Invalidated;
- const StoreRef &newStore
- = Mgr.StoreMgr->invalidateRegions(getStore(), Values, E, Count, LCtx, Call,
- *IS, *ITraits, &TopLevelInvalidated,
- &Invalidated);
+ const StoreRef &NewStore = Mgr.StoreMgr->invalidateRegions(
+ getStore(), Values, E, Count, LCtx, Call, *IS, *ITraits,
+ &TopLevelInvalidated, &Invalidated);
- ProgramStateRef newState = makeWithStore(newStore);
+ ProgramStateRef NewState = makeWithStore(NewStore);
if (CausedByPointerEscape) {
- newState = Eng.notifyCheckersOfPointerEscape(newState, IS,
- TopLevelInvalidated,
- Call,
- *ITraits);
+ NewState = Eng.notifyCheckersOfPointerEscape(
+ NewState, IS, TopLevelInvalidated, Call, *ITraits);
}
- return Eng.processRegionChanges(newState, IS, TopLevelInvalidated,
+ return Eng.processRegionChanges(NewState, IS, TopLevelInvalidated,
Invalidated, LCtx, Call);
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This commit removes
invalidateRegionsImpl()
, moving its body toinvalidateRegions(ValueList Values, ...)
, because it was a completely useless layer of indirection.Moreover I'm fixing some strange indentation within this function body and renaming two variables to the proper
UpperCamelCase
format.