Commit Graph

118 Commits

Author SHA1 Message Date
Xi Ge
bfe6a64708 Paser: IfConfigDecl should reflect the underlying source. rdar://34315827 2017-09-12 11:58:49 -07:00
Robert Widmann
75a83da03e Implement SE-0075: CanImport
This implementation required a compromise between parser
performance and AST structuring.  On the one hand, Parse
must be fast in order to keep things in the IDE zippy, on
the other we must hit the disk to properly resolve 'canImport'
conditions and inject members of the active clause into the AST.
Additionally, a Parse-only pass may not provide platform-specific
information to the compiler invocation and so may mistakenly
activate or de-activate branches in the if-configuration decl.

The compromise is to perform condition evaluation only when
continuing on to semantic analysis.  This keeps the parser quick
and avoids the unpacking that parse does for active conditions
while still retaining the ability to see through to an active
condition when we know we're moving on to semantic analysis anyways.
2017-08-28 18:35:06 -04:00
Kosuke Ogawa
2a18723b55 [gardening] Fix typos (#11245)
* [Gardening] Fix typo: getTopLeveDecls -> getTopLevelDecls

* [Gardening] Fix typo: silModue -> silModule

* [Gardening] Fix typo: Evaludate -> Evaluate

* [Gardening] Fix typo: OptioanlPayload -> OptionalPayload

* [Gardening] Fix typo: confromance -> conformance

* [Gardening] Fix typos

* [Gardening] Fix typo: tpye -> type

* [Gardening] Fix typo: resoved -> resolved

* [Gardening] Fix typo: ahve -> have

* Revert "[Gardening] Fix typo: silModue -> silModule"

This reverts commit ed8c4d0b71.
2017-07-28 10:14:21 -07:00
Slava Pestov
732b215b88 Merge pull request #9413 from rintaro/ast-eliminate-ifconfigstmt
[AST] Eliminate IfConfigStmt
2017-06-16 15:39:47 -07:00
Rintaro Ishizaki
4c6ece6fe0 [Parse] Don't invalidate compilation condition with invalid platform condition argument (#10221)
It's just a warning.
2017-06-14 15:09:24 +09:00
Jordan Rose
c0ccdb1626 Change getBaseName to return DeclBaseName instead of Identifier (#9968)
This changes `getBaseName()` on `DeclName` to return a `DeclBaseName`
instead of an `Identifier`. All places that will continue to be
expecting an `Identifier` are changed to call `getBaseIdentifier` which
will later assert that the `DeclName` is actually backed by an
identifier and not a special name.

For transitional purposes, a conversion operator from `DeclBaseName` to
`Identifier` has been added that will be removed again once migration
to DeclBaseName has been completed in other parts of the compiler.

Unify approach to printing declaration names

Printing a declaration's name using `<<` and `getBaseName()` is be
independent of the return type of `getBaseName()` which will change in
the future from `Identifier` to `DeclBaseName`
2017-05-28 17:55:03 -07:00
practicalswift
008cd49091 [gardening] Fix spacing 2017-05-16 23:23:11 +02:00
Rintaro Ishizaki
c8d717e5f4 [Parse] Cleanup #if directive parsing
Now that, IfConfigDecl holds ASTNode regardless statements position or
declarations postion. We can construct it in single method.
2017-05-16 20:52:46 +09:00
Rintaro Ishizaki
6fa84150c5 [AST] Eliminate IfConfigStmt
Resolves: https://bugs.swift.org/browse/SR-4426

* Make IfConfigDecl be able to hold ASTNodes
* Parse #if as IfConfigDecl
* Stop enclosing toplevel #if into TopLevelCodeDecl.
* Eliminate IfConfigStmt
2017-05-16 12:19:54 +09:00
Rintaro Ishizaki
bd3b2c6601 [Parse] Add warning for compound name in compilation condition in swift3 2017-03-29 00:43:28 +09:00
Rintaro Ishizaki
3943b8a77c [Parse] Add warning with fix-it for combination of '||' and '&&' in
compilation condition in Swift3 mode.
2017-03-24 18:28:23 +09:00
Rintaro Ishizaki
cd0b7daf1c [Parse] Renamed 'getNameStr' to 'getDeclRefStr'
and make it to return 'Optional<StringRef>'
2017-03-23 01:25:29 +09:00
Rintaro Ishizaki
b56ab17fa5 [Parse] Separate compilation condition validation and evaluation
Fixes:
https://bugs.swift.org/browse/SR-3455
https://bugs.swift.org/browse/SR-3663
https://bugs.swift.org/browse/SR-4032
https://bugs.swift.org/browse/SR-4031

Now, compilation conditions are validated at first, then evaluated. Also,
in non-Swift3 mode, '&&' now has higher precedence than '||'.
'A || B && C || D' are evaluated as 'A || (B && C) || D'.

Swift3 source breaking changes:

* [SR-3663] This used to be accepted and evaluate to 'true' because of short
  circuit without any validation.

  #if true || true * 12 = try Anything is OK?
  print("foo")
  #endif

  In this change, remaining expressions are properly validated and
  diagnosed if it's invalid.

* [SR-4031] Compound name references are now diagnosed as errors.
  e.g. `#if os(foo:bar:)(macOS)` or `#if FLAG(x:y:)`

Swift3 compatibility:

* [SR-3663] The precedence of '||' and '&&' are still the same and the
  following code evaluates to 'true'.

  #if false || true && false
  print("foo")
  #endif
2017-03-23 01:25:29 +09:00
practicalswift
9f21cae248 [gardening] Fix incorrect file name in header 2017-03-02 16:19:57 +01:00
Rintaro Ishizaki
1f3c66226c [LangOptions] Introduce a new enum class for platform conditions (#7843) 2017-03-02 01:58:20 +09:00
Rintaro Ishizaki
0be1cf1dc4 [Parse] Consolidate parsing IfConfig clauses
decl list position and stmt list poisiton.
2017-02-24 11:07:27 +09:00
Rintaro Ishizaki
136651e191 [AST] Merge IfConfigDeclClause and IfConfigStmtClause
into IfConfigClause<ElemTy>.
2017-02-24 11:07:27 +09:00
Rintaro Ishizaki
58c079e306 [Parse] Split out IfConfig related functions into ParseIfConfig.cpp 2017-02-24 11:07:27 +09:00