aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
diff options
context:
space:
mode:
authorYitzhak Mandelbaum <yitzhakm@google.com>2023-01-06 01:07:28 +0000
committerYitzhak Mandelbaum <yitzhakm@google.com>2023-01-06 01:07:28 +0000
commit2b1a517a92bfdfa3b692a660e19a2bb22513a567 (patch)
treea066a6e6789fd3caee45c93cc56a0f1a52e174f0 /clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
parent3b2537be767c97d0b557aee53b3c989b339dd6bc (diff)
downloadllvm-2b1a517a92bfdfa3b692a660e19a2bb22513a567.zip
llvm-2b1a517a92bfdfa3b692a660e19a2bb22513a567.tar.gz
llvm-2b1a517a92bfdfa3b692a660e19a2bb22513a567.tar.bz2
Revert "[clang][dataflow] Only model struct fields that are used in the function being analyzed."
This reverts commit 5e8f597c2fedc740b71f07dfdb1ef3c2d348b193. It caused msan and ubsan breakages.
Diffstat (limited to 'clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp')
-rw-r--r--clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp27
1 files changed, 3 insertions, 24 deletions
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
index 6b7b2dc..af2f1fcb 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -16,7 +16,6 @@
#include "clang/AST/ExprCXX.h"
#include "clang/Analysis/FlowSensitive/DebugSupport.h"
#include "clang/Analysis/FlowSensitive/Value.h"
-#include "llvm/ADT/SetOperations.h"
#include "llvm/Support/Debug.h"
#include <cassert>
#include <memory>
@@ -25,33 +24,13 @@
namespace clang {
namespace dataflow {
-void DataflowAnalysisContext::addFieldsReferencedInScope(
- llvm::DenseSet<const FieldDecl *> Fields) {
- llvm::set_union(FieldsReferencedInScope, Fields);
-}
-
-llvm::DenseSet<const FieldDecl *>
-DataflowAnalysisContext::getReferencedFields(QualType Type) {
- llvm::DenseSet<const FieldDecl *> Fields = getObjectFields(Type);
- llvm::set_intersect(Fields, FieldsReferencedInScope);
- return Fields;
-}
-
StorageLocation &DataflowAnalysisContext::createStorageLocation(QualType Type) {
if (!Type.isNull() &&
(Type->isStructureOrClassType() || Type->isUnionType())) {
+ // FIXME: Explore options to avoid eager initialization of fields as some of
+ // them might not be needed for a particular analysis.
llvm::DenseMap<const ValueDecl *, StorageLocation *> FieldLocs;
- // During context-sensitive analysis, a struct may be allocated in one
- // function, but its field accessed in a function lower in the stack than
- // the allocation. Since we only collect fields used in the function where
- // the allocation occurs, we can't apply that filter when performing
- // context-sensitive analysis. But, this only applies to storage locations,
- // since fields access it not allowed to fail. In contrast, field *values*
- // don't need this allowance, since the API allows for uninitialized fields.
- auto Fields = Options.EnableContextSensitiveAnalysis
- ? getObjectFields(Type)
- : getReferencedFields(Type);
- for (const FieldDecl *Field : Fields)
+ for (const FieldDecl *Field : getObjectFields(Type))
FieldLocs.insert({Field, &createStorageLocation(Field->getType())});
return takeOwnership(
std::make_unique<AggregateStorageLocation>(Type, std::move(FieldLocs)));