Add const. NFC.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 11 Nov 2014 05:11:47 +0000 (05:11 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 11 Nov 2014 05:11:47 +0000 (05:11 +0000)
This adds const to a few methods that already return const references or
creates a const version when they reterun non-const references.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221666 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCParser/MCAsmLexer.h
include/llvm/MC/MCParser/MCAsmParser.h
include/llvm/MC/MCParser/MCAsmParserExtension.h
lib/MC/MCParser/MCAsmParser.cpp

index f7e73f9c1d93f412025dee827a81d9825faad7dc..b05891c13250b85c68e22114fcacdcb8fa8a06a8 100644 (file)
@@ -157,7 +157,7 @@ public:
   SMLoc getLoc() const;
 
   /// Get the current (last) lexed token.
-  const AsmToken &getTok() {
+  const AsmToken &getTok() const {
     return CurTok;
   }
 
index d3be208eb82df49467cff85d0f9678b480ba416f..34188e66e62dabaeb746aa0244b26e010f0a52d0 100644 (file)
@@ -87,6 +87,9 @@ public:
   virtual SourceMgr &getSourceManager() = 0;
 
   virtual MCAsmLexer &getLexer() = 0;
+  const MCAsmLexer &getLexer() const {
+    return const_cast<MCAsmParser*>(this)->getLexer();
+  }
 
   virtual MCContext &getContext() = 0;
 
@@ -138,7 +141,7 @@ public:
   virtual const AsmToken &Lex() = 0;
 
   /// Get the current AsmToken from the stream.
-  const AsmToken &getTok();
+  const AsmToken &getTok() const;
 
   /// \brief Report an error at the current lexer location.
   bool TokError(const Twine &Msg, ArrayRef<SMRange> Ranges = None);
index 2eda3a9a214368ae8000d752ee2d74228b00d9cd..bfc0afa132b7f656a5373716dba03036589ce21d 100644 (file)
@@ -52,8 +52,17 @@ public:
   /// @{
 
   MCContext &getContext() { return getParser().getContext(); }
+
   MCAsmLexer &getLexer() { return getParser().getLexer(); }
+  const MCAsmLexer &getLexer() const {
+    return const_cast<MCAsmParserExtension *>(this)->getLexer();
+  }
+
   MCAsmParser &getParser() { return *Parser; }
+  const MCAsmParser &getParser() const {
+    return const_cast<MCAsmParserExtension*>(this)->getParser();
+  }
+
   SourceMgr &getSourceManager() { return getParser().getSourceManager(); }
   MCStreamer &getStreamer() { return getParser().getStreamer(); }
   bool Warning(SMLoc L, const Twine &Msg) {
index e417aa97716b2efa68b6691eee91e1da01a9be18..290dcb297742827a2d930f4350ce0cdb09d7dc27 100644 (file)
@@ -29,7 +29,7 @@ void MCAsmParser::setTargetParser(MCTargetAsmParser &P) {
   TargetParser->Initialize(*this);
 }
 
-const AsmToken &MCAsmParser::getTok() {
+const AsmToken &MCAsmParser::getTok() const {
   return getLexer().getTok();
 }