From be709f2c19bc59df5dbbd877f782bf7cc47fc663 Mon Sep 17 00:00:00 2001 From: Eugene Zelenko Date: Fri, 18 Aug 2017 23:51:26 +0000 Subject: [Analysis] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). llvm-svn: 311212 --- llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp | 35 ++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp') 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 +#include + 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 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 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 TBAANode; -typedef TBAANodeImpl MutableTBAANode; +using TBAANode = TBAANodeImpl; +using MutableTBAANode = TBAANodeImpl; /// @} /// This is a simple wrapper around an MDNode which provides a @@ -197,12 +208,15 @@ public: MDNodeTy *getBaseType() const { return dyn_cast_or_null(Node->getOperand(0)); } + MDNodeTy *getAccessType() const { return dyn_cast_or_null(Node->getOperand(1)); } + uint64_t getOffset() const { return mdconst::extract(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 TBAAStructTagNode; -typedef TBAAStructTagNodeImpl MutableTBAAStructTagNode; +using TBAAStructTagNode = TBAAStructTagNodeImpl; +using MutableTBAAStructTagNode = TBAAStructTagNodeImpl; /// @} /// This is a simple wrapper around an MDNode which provides a @@ -228,10 +242,10 @@ typedef TBAAStructTagNodeImpl 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 -- cgit v1.2.3