[clang-apply-replacements] Always initialize FormatStyle.
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 12 Apr 2018 10:35:24 +0000 (10:35 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 12 Apr 2018 10:35:24 +0000 (10:35 +0000)
The cleanup logic reads from this for cleanups even if reformatting is
not requested.

Found by msan.

llvm-svn: 329894

clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp

index 7f97b8f..24a430f 100644 (file)
@@ -97,16 +97,13 @@ int main(int argc, char **argv) {
       IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs()), DiagOpts.get());
 
   // Determine a formatting style from options.
-  format::FormatStyle FormatStyle;
-  if (DoFormat) {
-    auto FormatStyleOrError =
-        format::getStyle(FormatStyleOpt, FormatStyleConfig, "LLVM");
-    if (!FormatStyleOrError) {
-      llvm::errs() << llvm::toString(FormatStyleOrError.takeError()) << "\n";
-      return 1;
-    }
-    FormatStyle = *FormatStyleOrError;
+  auto FormatStyleOrError =
+      format::getStyle(FormatStyleOpt, FormatStyleConfig, "LLVM");
+  if (!FormatStyleOrError) {
+    llvm::errs() << llvm::toString(FormatStyleOrError.takeError()) << "\n";
+    return 1;
   }
+  format::FormatStyle FormatStyle = std::move(*FormatStyleOrError);
 
   TUReplacements TURs;
   TUReplacementFiles TUFiles;