|
27 | 27 |
|
28 | 28 | using namespace llvm;
|
29 | 29 |
|
30 |
| -// Default style to use when no style specified or specified style not found. |
31 |
| -static const char *DefaultStyle = "LLVM"; |
| 30 | +// Fallback style when no style specified or found in a .clang-format file. |
| 31 | +static const char FallbackStyle[] = "LLVM"; |
32 | 32 |
|
33 | 33 | static cl::opt<bool> Help("h", cl::desc("Alias for -help"), cl::Hidden);
|
34 | 34 |
|
@@ -72,7 +72,7 @@ static cl::opt<std::string>
|
72 | 72 | "Use -style=\"{key: value, ...}\" to set specific\n"
|
73 | 73 | "parameters, e.g.:\n"
|
74 | 74 | " -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\""),
|
75 |
| - cl::init(DefaultStyle), cl::cat(ClangFormatCategory)); |
| 75 | + cl::init("file"), cl::cat(ClangFormatCategory)); |
76 | 76 | static cl::opt<bool> Inplace("i",
|
77 | 77 | cl::desc("Inplace edit <file>s, if specified."),
|
78 | 78 | cl::cat(ClangFormatCategory));
|
@@ -108,20 +108,20 @@ static FileID createInMemoryFile(StringRef FileName, const MemoryBuffer *Source,
|
108 | 108 |
|
109 | 109 | FormatStyle getStyle(StringRef StyleName, StringRef FileName) {
|
110 | 110 | FormatStyle Style;
|
111 |
| - getPredefinedStyle(DefaultStyle, &Style); |
| 111 | + getPredefinedStyle(FallbackStyle, &Style); |
112 | 112 |
|
113 | 113 | if (StyleName.startswith("{")) {
|
114 | 114 | // Parse YAML/JSON style from the command line.
|
115 | 115 | if (error_code ec = parseConfiguration(StyleName, &Style)) {
|
116 | 116 | llvm::errs() << "Error parsing -style: " << ec.message()
|
117 |
| - << ", using " << DefaultStyle << " style\n"; |
| 117 | + << ", using " << FallbackStyle << " style\n"; |
118 | 118 | }
|
119 | 119 | return Style;
|
120 | 120 | }
|
121 | 121 |
|
122 | 122 | if (!StyleName.equals_lower("file")) {
|
123 | 123 | if (!getPredefinedStyle(StyleName, &Style))
|
124 |
| - llvm::errs() << "Invalid value for -style, using " << DefaultStyle |
| 124 | + llvm::errs() << "Invalid value for -style, using " << FallbackStyle |
125 | 125 | << " style\n";
|
126 | 126 | return Style;
|
127 | 127 | }
|
@@ -153,7 +153,7 @@ FormatStyle getStyle(StringRef StyleName, StringRef FileName) {
|
153 | 153 | return Style;
|
154 | 154 | }
|
155 | 155 | }
|
156 |
| - llvm::errs() << "Can't find usable .clang-format, using " << DefaultStyle |
| 156 | + llvm::errs() << "Can't find usable .clang-format, using " << FallbackStyle |
157 | 157 | << " style\n";
|
158 | 158 | return Style;
|
159 | 159 | }
|
|
0 commit comments