summaryrefslogtreecommitdiffstats
path: root/include/clang/Analysis
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Analysis')
-rw-r--r--include/clang/Analysis/Analyses/Consumed.h38
-rw-r--r--include/clang/Analysis/Analyses/ThreadSafetyCommon.h4
-rw-r--r--include/clang/Analysis/Analyses/ThreadSafetyTIL.h8
-rw-r--r--include/clang/Analysis/CFG.h8
-rw-r--r--include/clang/Analysis/ProgramPoint.h49
-rw-r--r--include/clang/Analysis/Support/BumpVector.h7
6 files changed, 62 insertions, 52 deletions
diff --git a/include/clang/Analysis/Analyses/Consumed.h b/include/clang/Analysis/Analyses/Consumed.h
index a710923..1f5aa12 100644
--- a/include/clang/Analysis/Analyses/Consumed.h
+++ b/include/clang/Analysis/Analyses/Consumed.h
@@ -71,7 +71,7 @@ namespace consumed {
virtual void warnParamReturnTypestateMismatch(SourceLocation Loc,
StringRef VariableName,
StringRef ExpectedState,
- StringRef ObservedState) {};
+ StringRef ObservedState) {}
// FIXME: Add documentation.
virtual void warnParamTypestateMismatch(SourceLocation LOC,
@@ -162,8 +162,8 @@ namespace consumed {
ConsumedState getState(const CXXBindTemporaryExpr *Tmp) const;
/// \brief Merge this state map with another map.
- void intersect(const ConsumedStateMap *Other);
-
+ void intersect(const ConsumedStateMap &Other);
+
void intersectAtLoopHead(const CFGBlock *LoopHead, const CFGBlock *LoopBack,
const ConsumedStateMap *LoopBackStates,
ConsumedWarningsHandlerBase &WarningsHandler);
@@ -196,15 +196,19 @@ namespace consumed {
};
class ConsumedBlockInfo {
- std::vector<ConsumedStateMap*> StateMapsArray;
+ std::vector<std::unique_ptr<ConsumedStateMap>> StateMapsArray;
std::vector<unsigned int> VisitOrder;
public:
- ConsumedBlockInfo() { }
- ~ConsumedBlockInfo() { llvm::DeleteContainerPointers(StateMapsArray); }
+ ConsumedBlockInfo() = default;
+ ConsumedBlockInfo &operator=(ConsumedBlockInfo &&Other) {
+ StateMapsArray = std::move(Other.StateMapsArray);
+ VisitOrder = std::move(Other.VisitOrder);
+ return *this;
+ }
ConsumedBlockInfo(unsigned int NumBlocks, PostOrderCFGView *SortedGraph)
- : StateMapsArray(NumBlocks, nullptr), VisitOrder(NumBlocks, 0) {
+ : StateMapsArray(NumBlocks), VisitOrder(NumBlocks, 0) {
unsigned int VisitOrderCounter = 0;
for (PostOrderCFGView::iterator BI = SortedGraph->begin(),
BE = SortedGraph->end(); BI != BE; ++BI) {
@@ -214,17 +218,18 @@ namespace consumed {
bool allBackEdgesVisited(const CFGBlock *CurrBlock,
const CFGBlock *TargetBlock);
-
+
void addInfo(const CFGBlock *Block, ConsumedStateMap *StateMap,
- bool &AlreadyOwned);
- void addInfo(const CFGBlock *Block, ConsumedStateMap *StateMap);
-
+ std::unique_ptr<ConsumedStateMap> &OwnedStateMap);
+ void addInfo(const CFGBlock *Block,
+ std::unique_ptr<ConsumedStateMap> StateMap);
+
ConsumedStateMap* borrowInfo(const CFGBlock *Block);
void discardInfo(const CFGBlock *Block);
-
- ConsumedStateMap* getInfo(const CFGBlock *Block);
-
+
+ std::unique_ptr<ConsumedStateMap> getInfo(const CFGBlock *Block);
+
bool isBackEdge(const CFGBlock *From, const CFGBlock *To);
bool isBackEdgeTarget(const CFGBlock *Block);
};
@@ -233,13 +238,12 @@ namespace consumed {
class ConsumedAnalyzer {
ConsumedBlockInfo BlockInfo;
- ConsumedStateMap *CurrStates;
-
+ std::unique_ptr<ConsumedStateMap> CurrStates;
+
ConsumedState ExpectedReturnState;
void determineExpectedReturnState(AnalysisDeclContext &AC,
const FunctionDecl *D);
- bool hasConsumableAttributes(const CXXRecordDecl *RD);
bool splitState(const CFGBlock *CurrBlock,
const ConsumedStmtVisitor &Visitor);
diff --git a/include/clang/Analysis/Analyses/ThreadSafetyCommon.h b/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
index 9b7725a..e357013 100644
--- a/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
+++ b/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
@@ -287,10 +287,12 @@ public:
}
const ValueDecl* valueDecl() const {
- if (Negated)
+ if (Negated || CapExpr == nullptr)
return nullptr;
if (auto *P = dyn_cast<til::Project>(CapExpr))
return P->clangDecl();
+ if (auto *P = dyn_cast<til::LiteralPtr>(CapExpr))
+ return P->clangDecl();
return nullptr;
}
diff --git a/include/clang/Analysis/Analyses/ThreadSafetyTIL.h b/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
index 4b59466..be8a710 100644
--- a/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
+++ b/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
@@ -1395,7 +1395,7 @@ public:
/// Return the list of basic blocks that this terminator can branch to.
ArrayRef<BasicBlock*> successors() {
- return ArrayRef<BasicBlock*>(&TargetBlock, 1);
+ return TargetBlock;
}
template <class V>
@@ -1445,7 +1445,7 @@ public:
/// Return the list of basic blocks that this terminator can branch to.
ArrayRef<BasicBlock*> successors() {
- return ArrayRef<BasicBlock*>(Branches, 2);
+ return llvm::makeArrayRef(Branches);
}
template <class V>
@@ -1479,7 +1479,7 @@ public:
/// Return an empty list.
ArrayRef<BasicBlock*> successors() {
- return ArrayRef<BasicBlock*>();
+ return None;
}
SExpr *returnValue() { return Retval; }
@@ -1507,7 +1507,7 @@ inline ArrayRef<BasicBlock*> Terminator::successors() {
case COP_Branch: return cast<Branch>(this)->successors();
case COP_Return: return cast<Return>(this)->successors();
default:
- return ArrayRef<BasicBlock*>();
+ return None;
}
}
diff --git a/include/clang/Analysis/CFG.h b/include/clang/Analysis/CFG.h
index 5430c3b..293990c 100644
--- a/include/clang/Analysis/CFG.h
+++ b/include/clang/Analysis/CFG.h
@@ -229,7 +229,6 @@ public:
return static_cast<CXXDeleteExpr *>(Data2.getPointer());
}
-
private:
friend class CFGElement;
CFGDeleteDtor() {}
@@ -693,7 +692,7 @@ public:
iterator beginAutomaticObjDtorsInsert(iterator I, size_t Cnt,
BumpVectorContext &C) {
return iterator(Elements.insert(I.base(), Cnt,
- CFGAutomaticObjDtor(nullptr, 0), C));
+ CFGAutomaticObjDtor(nullptr, nullptr), C));
}
iterator insertAutomaticObjDtor(iterator I, VarDecl *VD, Stmt *S) {
*I = CFGAutomaticObjDtor(VD, S);
@@ -767,7 +766,7 @@ public:
/// (not a pointer to CFGBlock).
class graph_iterator {
public:
- typedef const CFGBlock value_type;
+ typedef CFGBlock value_type;
typedef value_type& reference;
typedef value_type* pointer;
typedef BumpVector<CFGBlock*>::iterator ImplTy;
@@ -1110,4 +1109,5 @@ template <> struct GraphTraits<Inverse<const ::clang::CFG*> >
}
};
} // end llvm namespace
-#endif
+
+#endif // LLVM_CLANG_ANALYSIS_CFG_H
diff --git a/include/clang/Analysis/ProgramPoint.h b/include/clang/Analysis/ProgramPoint.h
index f872715..6d816fd 100644
--- a/include/clang/Analysis/ProgramPoint.h
+++ b/include/clang/Analysis/ProgramPoint.h
@@ -33,8 +33,31 @@ namespace clang {
class AnalysisDeclContext;
class FunctionDecl;
class LocationContext;
-class ProgramPointTag;
+/// ProgramPoints can be "tagged" as representing points specific to a given
+/// analysis entity. Tags are abstract annotations, with an associated
+/// description and potentially other information.
+class ProgramPointTag {
+public:
+ ProgramPointTag(void *tagKind = nullptr) : TagKind(tagKind) {}
+ virtual ~ProgramPointTag();
+ virtual StringRef getTagDescription() const = 0;
+
+protected:
+ /// Used to implement 'isKind' in subclasses.
+ const void *getTagKind() { return TagKind; }
+
+private:
+ const void *TagKind;
+};
+
+class SimpleProgramPointTag : public ProgramPointTag {
+ std::string Desc;
+public:
+ SimpleProgramPointTag(StringRef MsgProvider, StringRef Msg);
+ StringRef getTagDescription() const override;
+};
+
class ProgramPoint {
public:
enum Kind { BlockEdgeKind,
@@ -643,30 +666,6 @@ private:
}
};
-/// ProgramPoints can be "tagged" as representing points specific to a given
-/// analysis entity. Tags are abstract annotations, with an associated
-/// description and potentially other information.
-class ProgramPointTag {
-public:
- ProgramPointTag(void *tagKind = nullptr) : TagKind(tagKind) {}
- virtual ~ProgramPointTag();
- virtual StringRef getTagDescription() const = 0;
-
-protected:
- /// Used to implement 'isKind' in subclasses.
- const void *getTagKind() { return TagKind; }
-
-private:
- const void *TagKind;
-};
-
-class SimpleProgramPointTag : public ProgramPointTag {
- std::string Desc;
-public:
- SimpleProgramPointTag(StringRef MsgProvider, StringRef Msg);
- StringRef getTagDescription() const override;
-};
-
} // end namespace clang
diff --git a/include/clang/Analysis/Support/BumpVector.h b/include/clang/Analysis/Support/BumpVector.h
index 3abe32d..591d17b 100644
--- a/include/clang/Analysis/Support/BumpVector.h
+++ b/include/clang/Analysis/Support/BumpVector.h
@@ -35,7 +35,12 @@ public:
/// Construct a new BumpVectorContext that creates a new BumpPtrAllocator
/// and destroys it when the BumpVectorContext object is destroyed.
BumpVectorContext() : Alloc(new llvm::BumpPtrAllocator(), 1) {}
-
+
+ BumpVectorContext(BumpVectorContext &&Other) : Alloc(Other.Alloc) {
+ Other.Alloc.setInt(false);
+ Other.Alloc.setPointer(nullptr);
+ }
+
/// Construct a new BumpVectorContext that reuses an existing
/// BumpPtrAllocator. This BumpPtrAllocator is not destroyed when the
/// BumpVectorContext object is destroyed.
OpenPOWER on IntegriCloud