From: River Riddle Date: Mon, 26 Aug 2019 20:53:22 +0000 (-0700) Subject: NFC: Remove unnecessary context parameters from several Location getters. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=23251f9f3a3dd518bd7cc9c3289d3a04e58c07bc;p=platform%2Fupstream%2Fllvm.git 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 --- diff --git a/mlir/include/mlir/IR/Location.h b/mlir/include/mlir/IR/Location.h index 32fe0f4..d7ad5f7 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 83b579c..7be9280 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 4d432bf..2e61616 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,