diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h index 9695884c00c98..3a149b5ff397f 100644 --- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h @@ -111,8 +111,7 @@ class DataflowAnalysisContext { /// Returns the storage location assigned to `D` or null if `D` has no /// assigned storage location. StorageLocation *getStorageLocation(const ValueDecl &D) const { - auto It = DeclToLoc.find(&D); - return It == DeclToLoc.end() ? nullptr : It->second; + return DeclToLoc.lookup(&D); } /// Assigns `Loc` as the storage location of `E`. @@ -129,8 +128,7 @@ class DataflowAnalysisContext { /// Returns the storage location assigned to `E` or null if `E` has no /// assigned storage location. StorageLocation *getStorageLocation(const Expr &E) const { - auto It = ExprToLoc.find(&ignoreCFGOmittedNodes(E)); - return It == ExprToLoc.end() ? nullptr : It->second; + return ExprToLoc.lookup(&ignoreCFGOmittedNodes(E)); } /// Returns a pointer value that represents a null pointer. Calls with diff --git a/clang/include/clang/Analysis/FlowSensitive/Value.h b/clang/include/clang/Analysis/FlowSensitive/Value.h index 861a9963e6689..fd8d6ee2f1e0d 100644 --- a/clang/include/clang/Analysis/FlowSensitive/Value.h +++ b/clang/include/clang/Analysis/FlowSensitive/Value.h @@ -63,8 +63,7 @@ class Value { /// Returns the value of the synthetic property with the given `Name` or null /// if the property isn't assigned a value. Value *getProperty(llvm::StringRef Name) const { - auto It = Properties.find(Name); - return It == Properties.end() ? nullptr : It->second; + return Properties.lookup(Name); } /// Assigns `Val` as the value of the synthetic property with the given @@ -302,12 +301,7 @@ class StructValue final : public Value { /// Returns the child value that is assigned for `D` or null if the child is /// not initialized. - Value *getChild(const ValueDecl &D) const { - auto It = Children.find(&D); - if (It == Children.end()) - return nullptr; - return It->second; - } + Value *getChild(const ValueDecl &D) const { return Children.lookup(&D); } /// Assigns `Val` as the child value for `D`. void setChild(const ValueDecl &D, Value &Val) { Children[&D] = &Val; } diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp index ee1a78472586d..4f5a877f71d03 100644 --- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp @@ -761,8 +761,7 @@ void Environment::setValueStrict(const Expr &E, Value &Val) { } Value *Environment::getValue(const StorageLocation &Loc) const { - auto It = LocToVal.find(&Loc); - return It == LocToVal.end() ? nullptr : It->second; + return LocToVal.lookup(&Loc); } Value *Environment::getValue(const ValueDecl &D) const {