r303582 - Give files from #line the characteristics of the current file

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Mon May 22 15:22:33 PDT 2017


On Mon, May 22, 2017 at 3:17 PM, Richard Smith <richard at metafoo.co.uk>
wrote:

>    // If the StrTok is "eod", then it wasn't present.  Otherwise, it must
>> be a
>>    // string followed by eod.
>> -  if (StrTok.is(tok::eod))
>> -    ; // ok
>> -  else if (StrTok.isNot(tok::string_literal)) {
>> +  if (StrTok.is(tok::eod)) {
>> +    // Treat this like "#line NN", which doesn't change file
>> characteristics.
>> +    FileKind = SourceMgr.getFileCharacteristic(DigitTok.getLocation());
>>
>
> This change for "# <number>" handling makes sense (and I've checked and it
> matches GCC), but it looks like we don't have test coverage for either the
> old or new behavior. Can I interest you in adding some? :)
>

We do have coverage for it, see test/Preprocessor/line-directive.c:
"""
# 192 "glomp.h" 3 // System header.
typedef int y;  // ok
typedef int y;  // ok

typedef int q;  // q is in system header.

#line 42 "blonk.h"  // doesn't change system headerness.

typedef int z;  // ok
typedef int z;  // ok

# 97     // doesn't change system headerness.

typedef int z1;  // ok
typedef int z1;  // ok
"""

We were just getting similar behavior because of the code I removed that
sends us to the #line directive handling when the filename isn't present.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170522/fc32d02d/attachment.html>


More information about the cfe-commits mailing list