This is an archive of the discontinued LLVM Phabricator instance.

Fix for expanding __pragmas in macro arguments
ClosedPublic

Authored by akhuang on Sep 26 2019, 5:43 PM.

Details

Summary

Avoid executing __pragma when macro arguments are pre-expanded.
This is what clang currently does when parsing _Pragmas.

Fixes https://bugs.llvm.org/show_bug.cgi?id=41128, where clang crashes
when trying to get the length of annot_pragma tokens.

Diff Detail

Repository
rL LLVM

Event Timeline

akhuang created this revision.Sep 26 2019, 5:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 26 2019, 5:43 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
akhuang updated this revision to Diff 222464.Sep 30 2019, 11:19 AM

comments/whitespace/test

akhuang edited the summary of this revision. (Show Details)Sep 30 2019, 11:27 AM
akhuang added reviewers: rsmith, rnk.
rnk accepted this revision.Oct 3 2019, 4:17 PM

Nice, the solution was right in front of us the whole time. :)

lgtm, but please share the TokenCollector class.

clang/lib/Lex/Pragma.cpp
169 ↗(On Diff #222464)

Let's pull this class out to file scope (and put it in an anonymous namespace) so we can reuse it instead of copying it.

This revision is now accepted and ready to land.Oct 3 2019, 4:17 PM
akhuang updated this revision to Diff 223255.Oct 4 2019, 11:22 AM
  • move TokenCollector out of function
rnk added a subscriber: Bigcheese.Oct 4 2019, 11:33 AM

+ @Bigcheese, for amusement. We discussed some interesting behavior of _Pragma and C++ raw string literals last night.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptOct 7 2019, 10:18 PM