From 23251f9f3a3dd518bd7cc9c3289d3a04e58c07bc Mon Sep 17 00:00:00 2001 From: River Riddle Date: Mon, 26 Aug 2019 13:53:22 -0700 Subject: [PATCH] NFC: Remove unnecessary context parameters from several Location getters. The context can be recovered by other means in these methods and doesn't need to be passed explicitly. PiperOrigin-RevId: 265532956 --- mlir/include/mlir/IR/Location.h | 7 +++---- mlir/lib/IR/Location.cpp | 23 +++++++++++------------ mlir/lib/Parser/Parser.cpp | 6 ++---- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/mlir/include/mlir/IR/Location.h b/mlir/include/mlir/IR/Location.h index 32fe0f4cca1c..d7ad5f7f031b 100644 --- a/mlir/include/mlir/IR/Location.h +++ b/mlir/include/mlir/IR/Location.h @@ -109,13 +109,12 @@ public: using Base::Base; /// Return a uniqued call location object. - static Location get(Location callee, Location caller, MLIRContext *context); + static Location get(Location callee, Location caller); /// Return a call site location which represents a name reference in one line /// or a stack of frames. The input frames are ordered from innermost to /// outermost. - static Location get(Location name, ArrayRef frames, - MLIRContext *context); + static Location get(Location name, ArrayRef frames); /// The concrete location information this object presents. Location getCallee() const; @@ -191,7 +190,7 @@ public: /// Return a uniqued name location object. The child location must not be /// another NameLoc. - static Location get(Identifier name, Location child, MLIRContext *context); + static Location get(Identifier name, Location child); /// Return a uniqued name location object with an unknown child. static Location get(Identifier name, MLIRContext *context); diff --git a/mlir/lib/IR/Location.cpp b/mlir/lib/IR/Location.cpp index 83b579c4d905..7be9280a28d5 100644 --- a/mlir/lib/IR/Location.cpp +++ b/mlir/lib/IR/Location.cpp @@ -26,19 +26,17 @@ using namespace mlir::detail; // CallSiteLoc //===----------------------------------------------------------------------===// -Location CallSiteLoc::get(Location callee, Location caller, - MLIRContext *context) { - return Base::get(context, StandardAttributes::CallSiteLocation, callee, - caller); +Location CallSiteLoc::get(Location callee, Location caller) { + return Base::get(callee->getContext(), StandardAttributes::CallSiteLocation, + callee, caller); } -Location CallSiteLoc::get(Location name, ArrayRef frames, - MLIRContext *context) { - assert(!frames.empty() && "required at least 1 frames"); +Location CallSiteLoc::get(Location name, ArrayRef frames) { + assert(!frames.empty() && "required at least 1 call frame"); Location caller = frames.back(); for (auto frame : llvm::reverse(frames.drop_back())) - caller = CallSiteLoc::get(frame, caller, context); - return CallSiteLoc::get(name, caller, context); + caller = CallSiteLoc::get(frame, caller); + return CallSiteLoc::get(name, caller); } Location CallSiteLoc::getCallee() const { return getImpl()->callee; } @@ -109,14 +107,15 @@ Attribute FusedLoc::getMetadata() const { return getImpl()->metadata; } // NameLoc //===----------------------------------------------------------------------===// -Location NameLoc::get(Identifier name, Location child, MLIRContext *context) { +Location NameLoc::get(Identifier name, Location child) { assert(!child.isa() && "a NameLoc cannot be used as a child of another NameLoc"); - return Base::get(context, StandardAttributes::NameLocation, name, child); + return Base::get(child->getContext(), StandardAttributes::NameLocation, name, + child); } Location NameLoc::get(Identifier name, MLIRContext *context) { - return get(name, UnknownLoc::get(context), context); + return get(name, UnknownLoc::get(context)); } /// Return the name identifier. diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index 4d432bf5512b..2e6161689c1f 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -1692,8 +1692,6 @@ ParseResult Parser::parseLocation(LocationAttr &loc) { /// unknown-location ::= 'unknown' /// ParseResult Parser::parseCallSiteLocation(LocationAttr &loc) { - auto *ctx = getContext(); - consumeToken(Token::bare_identifier); // Parse the '('. @@ -1721,7 +1719,7 @@ ParseResult Parser::parseCallSiteLocation(LocationAttr &loc) { return failure(); // Return the callsite location. - loc = CallSiteLoc::get(calleeLoc, callerLoc, ctx); + loc = CallSiteLoc::get(calleeLoc, callerLoc); return success(); } @@ -1805,7 +1803,7 @@ ParseResult Parser::parseNameOrFileLineColLocation(LocationAttr &loc) { if (childLoc.isa()) return emitError(childSourceLoc, "child of NameLoc cannot be another NameLoc"); - loc = NameLoc::get(Identifier::get(str, ctx), childLoc, ctx); + loc = NameLoc::get(Identifier::get(str, ctx), childLoc); // Parse the closing ')'. if (parseToken(Token::r_paren,