r342834 - [analyzer][UninitializedObjectChecker] Using the new const methods of ImmutableList
Kristof Umann via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 23 02:16:28 PDT 2018
Author: szelethus
Date: Sun Sep 23 02:16:27 2018
New Revision: 342834
URL: http://llvm.org/viewvc/llvm-project?rev=342834&view=rev
Log:
[analyzer][UninitializedObjectChecker] Using the new const methods of ImmutableList
Differential Revision: https://reviews.llvm.org/D51886
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h?rev=342834&r1=342833&r2=342834&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h Sun Sep 23 02:16:27 2018
@@ -152,7 +152,6 @@ std::string getVariableName(const FieldD
/// functions such as add() and replaceHead().
class FieldChainInfo {
public:
- using FieldChainImpl = llvm::ImmutableListImpl<const FieldNode &>;
using FieldChain = llvm::ImmutableList<const FieldNode &>;
private:
@@ -179,8 +178,8 @@ public:
bool contains(const FieldRegion *FR) const;
bool isEmpty() const { return Chain.isEmpty(); }
- const FieldRegion *getUninitRegion() const;
- const FieldNode &getHead() { return Chain.getHead(); }
+ const FieldNode &getHead() const { return Chain.getHead(); }
+ const FieldRegion *getUninitRegion() const { return getHead().getRegion(); }
void printNoteMsg(llvm::raw_ostream &Out) const;
};
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp?rev=342834&r1=342833&r2=342834&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp Sun Sep 23 02:16:27 2018
@@ -339,14 +339,6 @@ bool FindUninitializedFields::isPrimitiv
// Methods for FieldChainInfo.
//===----------------------------------------------------------------------===//
-const FieldRegion *FieldChainInfo::getUninitRegion() const {
- assert(!Chain.isEmpty() && "Empty fieldchain!");
-
- // ImmutableList::getHead() isn't a const method, hence the not too nice
- // implementation.
- return (*Chain.begin()).getRegion();
-}
-
bool FieldChainInfo::contains(const FieldRegion *FR) const {
for (const FieldNode &Node : Chain) {
if (Node.isSameRegion(FR))
@@ -360,7 +352,7 @@ bool FieldChainInfo::contains(const Fiel
/// recursive function to print the fieldchain correctly. The last element in
/// the chain is to be printed by `FieldChainInfo::print`.
static void printTail(llvm::raw_ostream &Out,
- const FieldChainInfo::FieldChainImpl *L);
+ const FieldChainInfo::FieldChain L);
// FIXME: This function constructs an incorrect string in the following case:
//
@@ -379,8 +371,7 @@ void FieldChainInfo::printNoteMsg(llvm::
if (Chain.isEmpty())
return;
- const FieldChainImpl *L = Chain.getInternalPointer();
- const FieldNode &LastField = L->getHead();
+ const FieldNode &LastField = getHead();
LastField.printNoteMsg(Out);
Out << '\'';
@@ -389,20 +380,20 @@ void FieldChainInfo::printNoteMsg(llvm::
Node.printPrefix(Out);
Out << "this->";
- printTail(Out, L->getTail());
+ printTail(Out, Chain.getTail());
LastField.printNode(Out);
Out << '\'';
}
static void printTail(llvm::raw_ostream &Out,
- const FieldChainInfo::FieldChainImpl *L) {
- if (!L)
+ const FieldChainInfo::FieldChain L) {
+ if (L.isEmpty())
return;
- printTail(Out, L->getTail());
+ printTail(Out, L.getTail());
- L->getHead().printNode(Out);
- L->getHead().printSeparator(Out);
+ L.getHead().printNode(Out);
+ L.getHead().printSeparator(Out);
}
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list