[Parse] Check the SourceFile for #if evaluation

Remove the `EvaluateConditionals` flags from the
parser, and instead query the source file.

This commit also changes ParserUnit such that it
doesn't evaluate #if conditions by default, as
none of its clients appear to require it. The
only client that wasn't explicitly disabling #if
evaluation and is processing the resulting AST is
swift-indent, so this commit also adds a test to
ensure it continues to work correctly with #if
decls.
This commit is contained in:
Hamish Knight
2020-02-11 15:30:34 -08:00
parent 2724cf6f65
commit f56b061407
15 changed files with 74 additions and 43 deletions

View File

@@ -289,8 +289,6 @@ swiftparse_client_node_t SynParser::parse(const char *source) {
ParserUnit PU(SM, SourceFileKind::Main, bufID, langOpts, tyckOpts,
"syntax_parse_module", std::move(parseActions),
/*SyntaxCache=*/nullptr);
// Evaluating pound conditions may lead to unknown syntax.
PU.getParser().EvaluateConditionals = false;
std::unique_ptr<SynParserDiagConsumer> pConsumer;
if (DiagHandler) {
pConsumer = std::make_unique<SynParserDiagConsumer>(*this, bufID);