swiftlang/swift

[SR-6982] Improve internal compiler consistency

Open

#49,530 创建于 2018年2月12日

在 GitHub 查看
 (4 评论) (0 反应) (0 负责人)Swift (69,989 star) (10,719 fork)batch import
compilergood first issueimprovement

描述

Previous ID SR-6982
Radar None
Original Reporter @lattner
Type Improvement
Votes 1
Component/s Compiler
Labels Improvement, StarterBug
Assignee None
Priority Medium

md5: 22bde6140d0fa9756c0c6301d019c71d

Issue Description:

As is typical for an established codebase that has been worked on by lots of different people, the consistency of naming and approach of things has drifted a bit over the last years. This makes it difficult to work on the compiler, particularly if you don't have full code completion at all times.

I'd suggest making that we make a pass over the compiler to regularize things. Here are some IMHO suggestions for things that I find irritating on a daily basis. That said, it would make sense to propose these on swift-dev before producing any monster patches:

  • Rename things referring to source locations, but spelling out "Location" to use "Loc". E.g. getDebugLocation() -> getDebugLoc()

  • Rename MultipleValueInstruction, SingleValueInstruction to SingleValueInst/MultipleValueInst since most of SIL uses "Inst". SILInstruction was supposed to be the one longhand one.

  • There are lots of different ways to get the current ASTContext, but a getASTContext() member is the most common (and flexible, because sometimes it isn't stored). As such, we should change public "Context" members to a getASTContext() method.

  • Some Expr nodes are created with "new (ctx) Node(...)" and others are made with Node::create(... ctx). We should standardize on the create methods, since they are more flexible.

I'm sure there are lots more places we can improve things as well.

贡献者指南

[SR-6982] Improve internal compiler consistency · swiftlang/swift#49530 | Good First Issue