[llvm] r221666 - Add const. NFC.

Rafael Espindola rafael.espindola at gmail.com
Mon Nov 10 21:11:48 PST 2014


Author: rafael
Date: Mon Nov 10 23:11:47 2014
New Revision: 221666

URL: http://llvm.org/viewvc/llvm-project?rev=221666&view=rev
Log:
Add const. NFC.

This adds const to a few methods that already return const references or
creates a const version when they reterun non-const references.

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

Modified: llvm/trunk/include/llvm/MC/MCParser/MCAsmLexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParser/MCAsmLexer.h?rev=221666&r1=221665&r2=221666&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCParser/MCAsmLexer.h (original)
+++ llvm/trunk/include/llvm/MC/MCParser/MCAsmLexer.h Mon Nov 10 23:11:47 2014
@@ -157,7 +157,7 @@ public:
   SMLoc getLoc() const;
 
   /// Get the current (last) lexed token.
-  const AsmToken &getTok() {
+  const AsmToken &getTok() const {
     return CurTok;
   }
 

Modified: llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h?rev=221666&r1=221665&r2=221666&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h (original)
+++ llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h Mon Nov 10 23:11:47 2014
@@ -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);

Modified: llvm/trunk/include/llvm/MC/MCParser/MCAsmParserExtension.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParser/MCAsmParserExtension.h?rev=221666&r1=221665&r2=221666&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCParser/MCAsmParserExtension.h (original)
+++ llvm/trunk/include/llvm/MC/MCParser/MCAsmParserExtension.h Mon Nov 10 23:11:47 2014
@@ -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) {

Modified: llvm/trunk/lib/MC/MCParser/MCAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/MCAsmParser.cpp?rev=221666&r1=221665&r2=221666&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/MCAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/MCAsmParser.cpp Mon Nov 10 23:11:47 2014
@@ -29,7 +29,7 @@ void MCAsmParser::setTargetParser(MCTarg
   TargetParser->Initialize(*this);
 }
 
-const AsmToken &MCAsmParser::getTok() {
+const AsmToken &MCAsmParser::getTok() const {
   return getLexer().getTok();
 }
 





More information about the llvm-commits mailing list