diff options
author | Eli Bendersky <eliben@google.com> | 2013-01-14 18:08:41 +0000 |
---|---|---|
committer | Eli Bendersky <eliben@google.com> | 2013-01-14 18:08:41 +0000 |
commit | 733c336327621d41617d3d49c7b86199a361a367 (patch) | |
tree | 89a0773eb1877dae46bdb2198759ba2646c1580e /lib/MC | |
parent | 800ec3da7af7b73cd3c61d5da53d9d7c8343ad83 (diff) | |
download | external_llvm-733c336327621d41617d3d49c7b86199a361a367.zip external_llvm-733c336327621d41617d3d49c7b86199a361a367.tar.gz external_llvm-733c336327621d41617d3d49c7b86199a361a367.tar.bz2 |
Encapsulate the MacroEnabled flag in AsmParser behind accessor methods.
The methods are also exposed via the MCAsmParser interface, which allows more
than one client to control them. Previously, GenericAsmParser was playing with
a member var in AsmParser directly (by virtue of being its friend).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172440 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/MCParser/AsmParser.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 50579a6..3621982 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -151,7 +151,7 @@ private: std::vector<MacroInstantiation*> ActiveMacros; /// Boolean tracking whether macro substitution is enabled. - unsigned MacrosEnabled : 1; + unsigned MacrosEnabledFlag : 1; /// Flag tracking whether any errors have been encountered. unsigned HadError : 1; @@ -231,6 +231,9 @@ public: virtual bool ParseIdentifier(StringRef &Res); virtual void EatToEndOfStatement(); + virtual bool MacrosEnabled() {return MacrosEnabledFlag;} + virtual void SetMacrosEnabled(bool flag) {MacrosEnabledFlag = flag;} + /// } private: @@ -503,7 +506,7 @@ AsmParser::AsmParser(SourceMgr &_SM, MCContext &_Ctx, MCStreamer &_Out, const MCAsmInfo &_MAI) : Lexer(_MAI), Ctx(_Ctx), Out(_Out), MAI(_MAI), SrcMgr(_SM), GenericParser(new GenericAsmParser), PlatformParser(0), - CurBuffer(0), MacrosEnabled(true), CppHashLineNumber(0), + CurBuffer(0), MacrosEnabledFlag(true), CppHashLineNumber(0), AssemblerDialect(~0U), IsDarwin(false), ParsingInlineAsm(false) { // Save the old handler. SavedDiagHandler = SrcMgr.getDiagHandler(); @@ -1278,7 +1281,7 @@ bool AsmParser::ParseStatement(ParseStatementInfo &Info) { } // If macros are enabled, check to see if this is a macro instantiation. - if (MacrosEnabled) + if (MacrosEnabled()) if (const Macro *M = MacroMap.lookup(IDVal)) return HandleMacroEntry(IDVal, IDLoc, M); @@ -3489,7 +3492,7 @@ bool GenericAsmParser::ParseDirectiveMacrosOnOff(StringRef Directive, return Error(getLexer().getLoc(), "unexpected token in '" + Directive + "' directive"); - getParser().MacrosEnabled = Directive == ".macros_on"; + getParser().SetMacrosEnabled(Directive == ".macros_on"); return false; } |