NFC: Remove unnecessary context parameters from several Location getters.
authorRiver Riddle <riverriddle@google.com>
Mon, 26 Aug 2019 20:53:22 +0000 (13:53 -0700)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Mon, 26 Aug 2019 20:54:01 +0000 (13:54 -0700)
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
mlir/lib/IR/Location.cpp
mlir/lib/Parser/Parser.cpp

index 32fe0f4..d7ad5f7 100644 (file)
@@ -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<Location> frames,
-                      MLIRContext *context);
+  static Location get(Location name, ArrayRef<Location> 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);
index 83b579c..7be9280 100644 (file)
@@ -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<Location> frames,
-                          MLIRContext *context) {
-  assert(!frames.empty() && "required at least 1 frames");
+Location CallSiteLoc::get(Location name, ArrayRef<Location> 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<NameLoc>() &&
          "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.
index 4d432bf..2e61616 100644 (file)
@@ -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<NameLoc>())
       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,