- 
                Notifications
    You must be signed in to change notification settings 
- Fork 10.6k
[AST] Eliminate IfConfigStmt #9413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AST] Eliminate IfConfigStmt #9413
Conversation
| @slavapestov @jrose-apple | 
| @swift-ci Please smoke test | 
| @swift-ci Please test source compatibility | 
        
          
                include/swift/AST/Decl.h
              
                Outdated
          
        
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These new methods looks overkill since they only have one client.
        
          
                include/swift/AST/Stmt.h
              
                Outdated
          
        
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidental addition.
        
          
                lib/AST/ASTDumper.cpp
              
                Outdated
          
        
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add : after #else.
10c93c4    to
    1266ada      
    Compare
  
    | @swift-ci Please smoke test | 
| @swift-ci Please test source compatibility | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test that shows that we still reject statements within #if within types, and at the top level in -parse-as-library code?
        
          
                lib/AST/ASTPrinter.cpp
              
                Outdated
          
        
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you print something here, even a comment, so that people will know it's not a bug? Or, well, that it's a known bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is just a unimplemented feature.
For now, added a commit for printing /* condition */ here.
| @swift-ci Please smoke test | 
| Compatibility test result | 
| @rintaro Is there anything blocking you from merging this now? | 
| I didn't see any problems but I wasn't looking too closely. Slava may also still have opinions. | 
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
Now that, all TopLevelCodeDecl is real. Just don't need this.
* Removed extra newlines. * Print '/* condition */' for condition part.
26629d8    to
    2ad22a8      
    Compare
  
    | @swift-ci Please smoke test | 
Now that, IfConfigDecl holds ASTNode regardless statements position or declarations postion. We can construct it in single method.
552dea0    to
    c8d717e      
    Compare
  
    | @swift-ci Please smoke test | 
| @slavapestov Could you review this? | 
| Just to get the validation tests in @swift-ci please test | 
| @slavapestov Ping | 
| Thanks! | 
NOTE: This conflicts with #7955 , I will rebase this PR when it's merged.landedResolves: SR-4426
#ifin statements position doesn't have to beStmt.Modeling it as
IfConfigDeclsimplify the code and AST.IfConfigDeclbe able to holdASTNodeelements#ifasIfConfigDecl#ifintoTopLevelCodeDecl.New methods onIfConfigDeclfor retrieving active elements asDecls. This replacesIfConfigDecl::getActiveMembers().IfConfigStmtis now dumped as: