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 | |
parent | 800ec3da7af7b73cd3c61d5da53d9d7c8343ad83 (diff) |
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
-rw-r--r-- | include/llvm/MC/MCParser/MCAsmParser.h | 4 | ||||
-rw-r--r-- | lib/MC/MCParser/AsmParser.cpp | 11 |
2 files changed, 11 insertions, 4 deletions
diff --git a/include/llvm/MC/MCParser/MCAsmParser.h b/include/llvm/MC/MCParser/MCAsmParser.h index 8c4c06bf4d..a0433f9855 100644 --- a/include/llvm/MC/MCParser/MCAsmParser.h +++ b/include/llvm/MC/MCParser/MCAsmParser.h @@ -136,6 +136,10 @@ public: /// recovery. virtual void EatToEndOfStatement() = 0; + /// Control a flag in the parser that enables or disables macros. + virtual bool MacrosEnabled() = 0; + virtual void SetMacrosEnabled(bool flag) = 0; + /// ParseExpression - Parse an arbitrary expression. /// /// @param Res - The value of the expression. The result is undefined diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 50579a64a2..3621982259 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; } |