Change SourgeMgr to const reference in Parser/Lexer.
SourceMgr is not be mutated during parsing/lexing.
PiperOrigin-RevId: 212145759
diff --git a/lib/Parser/Lexer.h b/lib/Parser/Lexer.h
index cbd4d0d..220860c 100644
--- a/lib/Parser/Lexer.h
+++ b/lib/Parser/Lexer.h
@@ -30,18 +30,10 @@
/// This class breaks up the current file into a token stream.
class Lexer {
- llvm::SourceMgr &sourceMgr;
- MLIRContext *context;
-
- StringRef curBuffer;
- const char *curPtr;
-
- Lexer(const Lexer&) = delete;
- void operator=(const Lexer&) = delete;
public:
- explicit Lexer(llvm::SourceMgr &sourceMgr, MLIRContext *context);
+ explicit Lexer(const llvm::SourceMgr &sourceMgr, MLIRContext *context);
- llvm::SourceMgr &getSourceMgr() { return sourceMgr; }
+ const llvm::SourceMgr &getSourceMgr() { return sourceMgr; }
Token lexToken();
@@ -69,6 +61,15 @@
Token lexPrefixedIdentifier(const char *tokStart);
Token lexNumber(const char *tokStart);
Token lexString(const char *tokStart);
+
+ const llvm::SourceMgr &sourceMgr;
+ MLIRContext *context;
+
+ StringRef curBuffer;
+ const char *curPtr;
+
+ Lexer(const Lexer &) = delete;
+ void operator=(const Lexer &) = delete;
};
} // end namespace mlir