[Format] Do not use a global static value for EOF within ScopedMacroState.
authorDavid L. Jones <dlj@google.com>
Fri, 15 Jun 2018 06:08:54 +0000 (06:08 +0000)
committerDavid L. Jones <dlj@google.com>
Fri, 15 Jun 2018 06:08:54 +0000 (06:08 +0000)
commit5de2272174587bc8ce10a59fc20570890d0f9721
treea4473b3da86f019287070525a4e169b64c638fd5
parent3c4cc0122626af9f11317a3ebeebaad0796d0655
[Format] Do not use a global static value for EOF within ScopedMacroState.

ScopedMacroState injects its own EOF token under certain conditions, and the
returned token may be modified in several different locations. If multiple
reformat operations are started in different threads, then they will both see
the same fake EOF token, and may both try to modify it. This is a data race.

This bug was caught with tsan.

Reviewers: klimek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D47759

llvm-svn: 334801
clang/lib/Format/UnwrappedLineParser.cpp