diff --git a/llvm-coding-standards.md b/llvm-coding-standards.md
index b4c72a1..11d1fe8 100644
--- a/llvm-coding-standards.md
+++ b/llvm-coding-standards.md
@@ -29,7 +29,7 @@
- [不要使用静态构造函数](#不要使用静态构造函数)
- [使用class和struct关键字](#使用class和struct关键字)
- [不要使用花括号初始化列表调用构造函数](#不要使用花括号初始化列表调用构造函数)
- - [ 使用auto类型推导提高代码可读性](#-使用auto类型推导提高代码可读性)
+ - [使用auto类型推导提高代码可读性](#使用auto类型推导提高代码可读性)
- [小心auto带来的不必要拷贝](#小心auto带来的不必要拷贝)
- [小心对指针排序带来的不确定性](#小心对指针排序带来的不确定性)
- [小心相同元素不确定的排序顺序](#小心相同元素不确定的排序顺序)
@@ -91,7 +91,7 @@ Most source code in LLVM and other LLVM projects using these coding standards is
大部分在 *LLVM* 和其它 *LLVM* 项目中使用该代码规范的源码为C++代码。由于一些环境、历史限制或者引入至源码树中的第三方源码导致在某些地方存在C代码。通常而言,我们倾向于符合标准,现代和可移植的C++代码作为选择实现的语言。
-## C++ 标准版本
+## C++ 标准版本
Unless otherwise documented, LLVM subprojects are written using standard C++14 code and avoid unnecessary vendor-specific extensions.
@@ -111,7 +111,7 @@ Each toolchain provides a good reference for what it accepts:
- GCC:
- MSVC:
-## C++ 标准库
+## C++ 标准库
Instead of implementing custom data structures, we encourage the use of C++ standard library facilities or LLVM support libraries whenever they are available for a particular task. LLVM and related projects emphasize and rely on the standard library facilities and the LLVM support libraries as much as possible.
@@ -131,7 +131,7 @@ LLVM支持的库(例如ADT)实现了标准库缺少的特有数据结构或
更多关于LLVM数据结构和做出权衡的信息,请参考 [that section of the programmer’s manual](https://llvm.org/docs/ProgrammersManual.html#picking-the-right-data-structure-for-a-task)。
-## Go 代码准则
+## Go 代码准则
Any code written in the Go programming language is not subject to the formatting rules below. Instead, we adopt the formatting rules enforced by the gofmt tool.
@@ -366,7 +366,7 @@ When using report_fatal_error, follow the same standards for the message as regu
当使用 `report_fatal_error`,遵循相同的规范保持错误消息的规律。断言消息和`llvm_unreachable`调用则没有必要遵循这种自动格式化的格式,因此这些参考不一定合适。
-### include 风格
+### include 风格
Immediately after the header file comment (and include guards if working on a header file), the minimal list of #includes required by the file should be listed. We prefer these #includes to be listed in this order:
@@ -511,7 +511,7 @@ In almost all cases, it is possible to write completely portable code. When you
在绝大数的情况下,尽可能的编写完全可移植的代码。当你需要依赖于不可移植的代码时,将其放入良好声明和良好的文档接口中。
-#### 不要使用 RTTI 或 Exceptions
+#### 不要使用 RTTI 或 Exceptions
In an effort to reduce code and executable size, LLVM does not use exceptions or RTTI (runtime type information, for example, dynamic_cast<>).
@@ -607,7 +607,7 @@ If you use a braced initializer list when initializing a variable, use an equals
int data[] = {0, 1, 2, 3};
```
-#### 使用auto类型推导提高代码可读性
+#### 使用auto类型推导提高代码可读性
Some are advocating a policy of “almost always auto” in C++11, however LLVM uses a more moderate stance. Use auto if and only if it makes the code more readable or easier to maintain. Don’t “almost always” use auto, but do use auto with initializers like cast(...) or other places where the type is already obvious from the context. Another time when auto works well for these purposes is when the type would have been abstracted away anyways, often behind a container’s typedef such as std::vector::iterator.
@@ -692,7 +692,7 @@ This doesn’t fully enforce all inter-library dependencies, and importantly doe
这样不会完全强制的执行所有的相互库依赖,且重要的是不会执行由内联函数带来的头文件循环依赖。回答是否正确分层的一个好方法是判断 Unix 链接器是否可以正确链接使用非内联函数代替内联函数的程序。(对于所有依赖的有效顺序 - 由于链接的方案是线性的,因此可能潜伏一些隐式的依赖:A 依赖于B和C,所以有效的顺序为“CBA” 或者“BCA”,两种显示的依赖都在使用之前出现。但对于第一种情况,B如果隐式的依赖于C仍然可以链接成功,或者在第二种情况,相反的依赖也可以链接成功)
-#### 尽可能的减少 #include
+#### 尽可能的减少 #include
`#include` hurts compile time performance. Don’t do it unless you have to, especially in header files.
@@ -720,7 +720,7 @@ If you really need to do something like this, put a private header file in the s
> 允许将扩展实现的方法放入到一个公共类自身中,但是需要让它们设为私有(保护),一切就正常。
-#### 使用 namespace 限定符莱实现前置声明的函数
+#### 使用 namespace 限定符莱实现前置声明的函数
When providing an out of line implementation of a function in a source file, do not open namespace blocks in the source file. Instead, use namespace qualifiers to help ensure that your definition matches an existing declaration. Do this:
@@ -761,7 +761,7 @@ Class method implementations must already name the class and new overloads canno
类方法实现必须类已经被命名并且新的重载不能够引入到外部,所以这个建议对它们不起作用。
-#### 提前退出或 continue 以简化代码
+#### 提前退出或 continue 以简化代码
When reading code, keep in mind how much state and how many previous decisions have to be remembered by the reader to understand a block of code. Aim to reduce indentation where possible when it doesn’t make it more difficult to understand the code. One great way to do this is by making use of early exits and the continue keyword in long loops. Consider this code that does not use an early exit:
@@ -842,7 +842,7 @@ This has all the benefits of using early exits for functions: it reduces nesting
在函数中使用尽快退出的好处是:减少循环的缩进,更易于描述为何条件为真,而没有 `else` 出现则在读者的脑袋中变得更加明显。如果一个循环非常的庞大,这些做法具有巨大的理解优势。
-#### return 之后不要使用 else
+#### return 之后不要使用 else
For similar reasons as above (reduction of indentation and easier reading), please do not use 'else' or 'else if' after something that interrupts control flow — like return, break, continue, goto, etc. For example:
@@ -1091,7 +1091,7 @@ bool NewToSet = Myset.insert(Value); (void)NewToSet;
assert(NewToSet && "The value shouldn't be in the set yet");
```
-#### 不要使用 using namesapce std
+#### 不要使用 using namesapce std
In LLVM, we prefer to explicitly prefix all identifiers from the standard namespace with an “std::” prefix, rather than rely on “using namespace std;”.
@@ -1115,7 +1115,7 @@ If a class is defined in a header file and has a vtable (either it has virtual m
如果一个定义在头文件内的类存在虚表(含有虚表或者从有虚表继承),在类中必须总是至少含有一个非内联的虚方法。否则,编译器将复制 vtable 和 RTTI 信息到每一个包含该头文件中的 `.o` 文件中,导致 `.o` 文件大小膨胀并且增加链接耗时。
-#### 不要在全覆盖枚举的switch 中使用 default
+#### 不要在全覆盖枚举的switch 中使用 default
-Wswitch warns if a switch, without a default label, over an enumeration does not cover every enumeration value. If you write a default label on a fully covered switch over an enumeration then the -Wswitch warning won’t fire when new elements are added to that enumeration. To help avoid adding these kinds of defaults, Clang has the warning -Wcovered-switch-default which is off by default but turned on when building LLVM with a version of Clang that supports the warning.
@@ -1137,7 +1137,7 @@ for (Instruction &I : *BB)
... use I ...
```
-#### 不要每次通过循环计算 end()
+#### 不要每次通过循环计算 end()
In cases where range-based for loops can’t be used and it is necessary to write an explicit iterator-based loop, pay close attention to whether end() is re-evaluated on each loop iteration. One common mistake is to write a loop in this style:
@@ -1175,7 +1175,7 @@ While the second form of the loop is a few extra keystrokes, we do strongly pref
即使第二种循环的形式有一些额外的按键,我们依然强烈推荐。
-#### 禁止包含 iostream
+#### 禁止包含 iostream
The use of #include `` in library files is hereby forbidden, because many common implementations transparently inject a static constructor into every translation unit that includes it.
@@ -1187,7 +1187,7 @@ Note that using the other stream headers (`` for example) is not proble
> 新代码应该总是使用 raw_ostream 来写文件,或者 llvm::MemoryBuffer 来读文件。
-#### 使用 raw_stream
+#### 使用 raw_stream
LLVM includes a lightweight, simple, and efficient stream implementation in llvm/Support/raw_ostream.h, which provides all of the common features of std::ostream. All new code should use raw_ostream instead of ostream.
@@ -1197,7 +1197,7 @@ LLVM 包含一个轻量的,简单和高效的流实现,位于 `llvm/Support/
和 `std::ostream` 不同,`raw_ostream` 不是模板并且作为 `class raw_ostream` 可以被前向声明。公共头文件应该不包含该 raw_ostream 头文件,而是应该使用前向声明和常量`raw_ostream`实例。
-#### 避免 std::endl
+#### 避免 std::endl
The `std::endl` modifier, when used with `iostreams` outputs a newline to the output stream specified. In addition to doing this, however, it also flushes the output stream. In other words, these are equivalent:
@@ -1212,7 +1212,7 @@ Most of the time, you probably have no reason to flush the output stream, so it
大多数情况下,你可能没有理由去 flush 输出流,所以更好的做法使用字面量 `'\n'`.
-#### 不要在class中声明的函数中使用 inline
+#### 不要在class中声明的函数中使用 inline
A member function defined in a class definition is implicitly inline, so don’t put the inline keyword in this case.
@@ -1277,7 +1277,7 @@ The semantics of postincrement include making a copy of the value being incremen
后置自增的语义上包含拷贝被递增的值,返回它,再前递增这个 “工作值”。对于基本类型,这样做没什么大不了的。但是对于迭代器,这样做是一个很大的问题(举个例子,一些迭代器中包含 stack 和 set 对象,拷贝这些迭代器同样可能会调用这些对象的拷贝构造函数)。通常而言,养成总是使用前置自增的习惯,就不会有问题。
-#### namespace 缩进
+#### namespace 缩进
In general, we strive to reduce indentation wherever possible. This is useful because we want code to fit into 80 columns without excessive wrapping, but also because it makes it easier to understand the code. To facilitate this and avoid some insanely deep nesting on occasion, don’t indent namespaces. If it helps readability, feel free to add a comment indicating what namespace is being closed by a }. For example:
@@ -1307,7 +1307,7 @@ Feel free to skip the closing comment when the namespace being closed is obvious
当由于任何原因而关闭的命名空间很明显时,请随时跳过结束注释。例如,头文件中最外面的名称空间很少引起混乱。但是匿名命名空间和源文件中半途被关闭的命名空间可能需要说明。
-#### 匿名 namespace
+#### 匿名 namespace
After talking about namespaces in general, you may be wondering about anonymous namespaces in particular. Anonymous namespaces are a great language feature that tells the C++ compiler that the contents of the namespace are only visible within the current translation unit, allowing more aggressive optimization and eliminating the possibility of symbol name collisions. Anonymous namespaces are to C++ as “static” is to C functions and global variables. While “static” is available in C++, anonymous namespaces are more general: they can make entire classes private to a file.