This is an archive of the discontinued LLVM Phabricator instance.

[ms compatibility] Fix for PR9984.
ClosedPublic

Authored by ABataev on Dec 11 2014, 12:04 AM.

Details

Summary

Fixed incompatibility in lexer with MSVC for a wide string literal from L#macro_arg in a function-like macro

Diff Detail

Repository
rL LLVM

Event Timeline

ABataev updated this revision to Diff 17147.Dec 11 2014, 12:04 AM
ABataev retitled this revision from to [ms compatibility] Fix for PR9984..
ABataev updated this object.
ABataev edited the test plan for this revision. (Show Details)
ABataev added reviewers: rnk, doug.gregor.
ABataev added a subscriber: Unknown Object (MLST).
majnemer added inline comments.
include/clang/Lex/Token.h
69 ↗(On Diff #17147)

Can we make this unsigned short instead?

268 ↗(On Diff #17147)

is formed by macro

lib/Lex/TokenLexer.cpp
441 ↗(On Diff #17147)

processing

442 ↗(On Diff #17147)

References to bug reports shouldn't be in the source code. Instead, I'd have a description of what the special logic is trying to accomplish.

443–445 ↗(On Diff #17147)

This if is getting pretty gnarly, maybe it would be a little cleaner if you broke this logic up a little bit.

David, thanks for the review!

include/clang/Lex/Token.h
69 ↗(On Diff #17147)

Yes, of course, I'll do it

268 ↗(On Diff #17147)

Will be fixed, thanks.

lib/Lex/TokenLexer.cpp
441 ↗(On Diff #17147)

Thanks

442 ↗(On Diff #17147)

Ok, will be fixed

443–445 ↗(On Diff #17147)

Ok, I'll split it

Can we get rid of our kw_L__FUNCTION__ hack with this change?

lib/Lex/TokenLexer.cpp
524 ↗(On Diff #17147)

What's the rationale behind this change?

ABataev updated this revision to Diff 17214.Dec 11 2014, 8:59 PM

Update after review

ABataev added inline comments.Dec 11 2014, 11:58 PM
lib/Lex/TokenLexer.cpp
524 ↗(On Diff #17147)

In construct L#x we don't have ## that should be skipped. So I just check it and skip this ## only if it exists.

Can we get rid of our kw_L__FUNCTION__ hack with this change?

No, I don't think we can. My solution fixes only lexer, but when we building LFUNCTION we're building an expression.

Best regards,

Alexey Bataev

Software Engineer
Intel Compiler Team

12.12.2014 7:39, David Majnemer пишет:

Can we get rid of our kw_L__FUNCTION__ hack with this change?

Comment at: lib/Lex/TokenLexer.cpp:524
@@ -515,2 +523,3 @@

PasteOpLoc = Tokens[CurToken].getLocation();
  • ++CurToken;

+ if (Tokens[CurToken].is(tok::hashhash))

+ ++CurToken;

What's the rationale behind this change?

http://reviews.llvm.org/D6604

EMAIL PREFERENCES

http://reviews.llvm.org/settings/panel/emailpreferences/
rnk accepted this revision.Dec 12 2014, 9:46 AM
rnk edited edge metadata.

lgtm

include/clang/Lex/Token.h
69 ↗(On Diff #17214)

OK, I guess either way there is no overall size increase. We could probably pack Kind and Flags more tightly, but that's separable.

lib/Lex/TokenLexer.cpp
410 ↗(On Diff #17214)

The convention for functions uses a leading lower case.

448–454 ↗(On Diff #17214)

Let's rearrange this to check the Macro bool first so we can short-circuit out with the least amount of work.

This revision is now accepted and ready to land.Dec 12 2014, 9:46 AM

Reid, thanks for the review!

lib/Lex/TokenLexer.cpp
410 ↗(On Diff #17214)

Ok, fixed.

448–454 ↗(On Diff #17214)

Agree, fixed

This revision was automatically updated to reflect the committed changes.