On Jan 16, 2013, at 9:52 AM, Aaron Ballman <[email protected]> wrote:
> On Wed, Jan 16, 2013 at 10:33 AM, Dmitri Gribenko <[email protected]> wrote: >> On Wed, Jan 16, 2013 at 3:15 PM, Aaron Ballman <[email protected]> >> wrote: >>> This patch moves the logic around slightly to handle macros better; >>> instead of relying on the PP Lexer, we track the information in the PP >>> itself so that is is always available. I've expanded the test cases >>> to cover macros more fully. >> >> void Preprocessor::HandleIfDirective(Token &IfToken, >> bool ReadAnyTokensBeforeDirective) { >> + ParsingPreprocessorDirective = true; >> ++NumIf; >> >> // Parse and evaluate the conditional expression. >> @@ -2101,6 +2102,7 @@ >> SkipExcludedConditionalBlock(IfToken.getLocation(), >> /*Foundnonskip*/false, >> /*FoundElse*/false); >> } >> + ParsingPreprocessorDirective = false; >> } >> >> We have llvm/Support/SaveAndRestore.h to simplify this. > > That's neat, I didn't notice we had that. However, using that would > mean I couldn't use a bit-field for the property either (due to > requiring a reference). So the question I have is: which is "better"? > Given that we already have several other boolean bitfields, I am on > the fence. This is not specific to this patch but needing to make a choice between RAII or bitfield seems unfortunate, could we add a helper macro or something when bitfields are involved ? > >> + /// \brief Returns true if currently parsing a preprocessor directive >> + bool isParsingPreprocessorDirective() const { >> + return ParsingPreprocessorDirective; >> + } >> >> + /// \brief True if we are currently preprocessing a #if or #elif directive >> + bool ParsingPreprocessorDirective : 1; >> >> Please synchronize these two comments, and maybe rename to >> ParsingIfOrElifDirective. > > Can do. > > Thanks! > > ~Aaron > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
