diff options
| author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2017-08-18 23:51:26 +0000 |
|---|---|---|
| committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2017-08-18 23:51:26 +0000 |
| commit | be709f2c19bc59df5dbbd877f782bf7cc47fc663 (patch) | |
| tree | 2eb83e9edad89b79f3d6aa314380cbf985090d5b /llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp | |
| parent | deb2a2adc87fa69da694d15fe1dfd45b99218529 (diff) | |
[Analysis] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 311212
Diffstat (limited to 'llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp')
| -rw-r--r-- | llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp index 86c528de267a..3a3a7ad39554 100644 --- a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp +++ b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp @@ -123,10 +123,20 @@ #include "llvm/Analysis/TypeBasedAliasAnalysis.h" #include "llvm/ADT/SetVector.h" +#include "llvm/Analysis/AliasAnalysis.h" +#include "llvm/Analysis/MemoryLocation.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/DerivedTypes.h" +#include "llvm/IR/Instruction.h" #include "llvm/IR/LLVMContext.h" -#include "llvm/IR/Module.h" +#include "llvm/IR/Metadata.h" +#include "llvm/Pass.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ErrorHandling.h" +#include <cassert> +#include <cstdint> + using namespace llvm; // A handy option for disabling TBAA functionality. The same effect can also be @@ -135,15 +145,16 @@ using namespace llvm; static cl::opt<bool> EnableTBAA("enable-tbaa", cl::init(true)); namespace { + /// This is a simple wrapper around an MDNode which provides a higher-level /// interface by hiding the details of how alias analysis information is encoded /// in its operands. template<typename MDNodeTy> class TBAANodeImpl { - MDNodeTy *Node; + MDNodeTy *Node = nullptr; public: - TBAANodeImpl() : Node(nullptr) {} + TBAANodeImpl() = default; explicit TBAANodeImpl(MDNodeTy *N) : Node(N) {} /// getNode - Get the MDNode for this TBAANode. @@ -176,8 +187,8 @@ public: /// \name Specializations of \c TBAANodeImpl for const and non const qualified /// \c MDNode. /// @{ -typedef TBAANodeImpl<const MDNode> TBAANode; -typedef TBAANodeImpl<MDNode> MutableTBAANode; +using TBAANode = TBAANodeImpl<const MDNode>; +using MutableTBAANode = TBAANodeImpl<MDNode>; /// @} /// This is a simple wrapper around an MDNode which provides a @@ -197,12 +208,15 @@ public: MDNodeTy *getBaseType() const { return dyn_cast_or_null<MDNode>(Node->getOperand(0)); } + MDNodeTy *getAccessType() const { return dyn_cast_or_null<MDNode>(Node->getOperand(1)); } + uint64_t getOffset() const { return mdconst::extract<ConstantInt>(Node->getOperand(2))->getZExtValue(); } + /// Test if this TBAAStructTagNode represents a type for objects /// which are not modified (by any means) in the context where this /// AliasAnalysis is relevant. @@ -219,8 +233,8 @@ public: /// \name Specializations of \c TBAAStructTagNodeImpl for const and non const /// qualified \c MDNods. /// @{ -typedef TBAAStructTagNodeImpl<const MDNode> TBAAStructTagNode; -typedef TBAAStructTagNodeImpl<MDNode> MutableTBAAStructTagNode; +using TBAAStructTagNode = TBAAStructTagNodeImpl<const MDNode>; +using MutableTBAAStructTagNode = TBAAStructTagNodeImpl<MDNode>; /// @} /// This is a simple wrapper around an MDNode which provides a @@ -228,10 +242,10 @@ typedef TBAAStructTagNodeImpl<MDNode> MutableTBAAStructTagNode; /// information is encoded in its operands. class TBAAStructTypeNode { /// This node should be created with createTBAAStructTypeNode. - const MDNode *Node; + const MDNode *Node = nullptr; public: - TBAAStructTypeNode() : Node(nullptr) {} + TBAAStructTypeNode() = default; explicit TBAAStructTypeNode(const MDNode *N) : Node(N) {} /// Get the MDNode for this TBAAStructTypeNode. @@ -283,7 +297,8 @@ public: return TBAAStructTypeNode(P); } }; -} + +} // end anonymous namespace /// Check the first operand of the tbaa tag node, if it is a MDNode, we treat /// it as struct-path aware TBAA format, otherwise, we treat it as scalar TBAA |
