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.

llvm-svn: 221666
This commit is contained in:
Rafael Espindola 2014-11-11 05:11:47 +00:00
parent 2d5cbc9569
commit 804f43c655
4 changed files with 15 additions and 3 deletions

View File

@ -157,7 +157,7 @@ public:
SMLoc getLoc() const;
/// Get the current (last) lexed token.
const AsmToken &getTok() {
const AsmToken &getTok() const {
return CurTok;
}

View 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);

View 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) {

View 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();
}