[cfe-commits] [PATCH] Disallow __has_include and __has_include_next outside of preprocessor directives

Dmitri Gribenko gribozavr at gmail.com
Tue Jan 15 15:35:53 PST 2013


On Wed, Jan 16, 2013 at 1:12 AM, Aaron Ballman <aaron at aaronballman.com> wrote:
> Yes, I prefer the way that looks -- new patch attached.  Note that it
> does change another test in the test cases, but I think the change is
> beneficial.

+  // We only want to get the file name if we're currently within a
+  // preprocessor directive.
+  if (PP.getCurrentLexer() &&
+      !PP.getCurrentLexer()->isParsingPreprocessorDirective()) {

1. Trailing whitespace.

2. The comment should say something like "These macros are only
allowed in a PP directive."

3. What about the case when PP.getCurrentLexer() == 0?

4. You can move the check before LParenLoc is declared.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-commits mailing list