[clang] [clang][dataflow] Add a lattice to help cache const accessor methods (PR #111006)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 3 08:31:00 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff ee4dd147baff8f971f3ec5aad5a216ca9837a732 f82e63e470f704f29f4c161579fd592c27301868 --extensions h,cpp -- clang/include/clang/Analysis/FlowSensitive/CachedConstAccessorsLattice.h clang/unittests/Analysis/FlowSensitive/CachedConstAccessorsLatticeTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/Analysis/FlowSensitive/CachedConstAccessorsLattice.h b/clang/include/clang/Analysis/FlowSensitive/CachedConstAccessorsLattice.h
index b8517fabd1..52114173e2 100644
--- a/clang/include/clang/Analysis/FlowSensitive/CachedConstAccessorsLattice.h
+++ b/clang/include/clang/Analysis/FlowSensitive/CachedConstAccessorsLattice.h
@@ -45,10 +45,9 @@ namespace dataflow {
/// use(s.getFoo().value()); // unsafe (invalidate cache for s)
/// }
/// }
-template <typename Base>
-class CachedConstAccessorsLattice : public Base {
+template <typename Base> class CachedConstAccessorsLattice : public Base {
public:
- using Base::Base; // inherit all constructors
+ using Base::Base; // inherit all constructors
/// Creates or returns a previously created `Value` associated with a const
/// method call `obj.getFoo()` where `RecordLoc` is the
@@ -74,8 +73,7 @@ public:
/// - `CE` should return a location (GLValue or a record type).
StorageLocation *getOrCreateConstMethodReturnStorageLocation(
const RecordStorageLocation &RecordLoc, const CallExpr *CE,
- Environment &Env,
- llvm::function_ref<void(StorageLocation &)> Initialize);
+ Environment &Env, llvm::function_ref<void(StorageLocation &)> Initialize);
void clearConstMethodReturnValues(const RecordStorageLocation &RecordLoc) {
ConstMethodReturnValues.erase(&RecordLoc);
@@ -95,9 +93,9 @@ public:
private:
// Maps a record storage location and const method to the value to return
// from that const method.
- using ConstMethodReturnValuesType = llvm::SmallDenseMap<
- const RecordStorageLocation *,
- llvm::SmallDenseMap<const FunctionDecl *, Value *>>;
+ using ConstMethodReturnValuesType =
+ llvm::SmallDenseMap<const RecordStorageLocation *,
+ llvm::SmallDenseMap<const FunctionDecl *, Value *>>;
ConstMethodReturnValuesType ConstMethodReturnValues;
// Maps a record storage location and const method to the record storage
@@ -194,8 +192,7 @@ template <typename Base>
StorageLocation *
CachedConstAccessorsLattice<Base>::getOrCreateConstMethodReturnStorageLocation(
const RecordStorageLocation &RecordLoc, const CallExpr *CE,
- Environment &Env,
- llvm::function_ref<void(StorageLocation &)> Initialize) {
+ Environment &Env, llvm::function_ref<void(StorageLocation &)> Initialize) {
QualType Type = CE->getType();
assert(!Type.isNull());
assert(CE->isGLValue() || Type->isRecordType());
@@ -218,4 +215,4 @@ CachedConstAccessorsLattice<Base>::getOrCreateConstMethodReturnStorageLocation(
} // namespace dataflow
} // namespace clang
-#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_CACHED_CONST_ACCESSORS_LATTICE_H
+#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_CACHED_CONST_ACCESSORS_LATTICE_H
diff --git a/clang/unittests/Analysis/FlowSensitive/CachedConstAccessorsLatticeTest.cpp b/clang/unittests/Analysis/FlowSensitive/CachedConstAccessorsLatticeTest.cpp
index eb6f081fd2..de0c9278fa 100644
--- a/clang/unittests/Analysis/FlowSensitive/CachedConstAccessorsLatticeTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/CachedConstAccessorsLatticeTest.cpp
@@ -91,7 +91,7 @@ struct CommonTestInputs {
.bind("call"),
AST.context()));
assert(CallRef != nullptr);
-}
+ }
TestAST AST;
QualType SType;
``````````
</details>
https://github.com/llvm/llvm-project/pull/111006
More information about the cfe-commits
mailing list