[clang] [clang-format][NFC] Clean up the driver and getStyle() in Format.cpp (PR #74794)

Ben Hamilton via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 22 10:26:28 PST 2024


================
@@ -544,28 +544,23 @@ static void PrintVersion(raw_ostream &OS) {
 }
 
 // Dump the configuration.
-static int dumpConfig() {
-  StringRef FileName;
+static int dumpConfig(bool IsSTDIN) {
   std::unique_ptr<llvm::MemoryBuffer> Code;
-  if (FileNames.empty()) {
-    // We can't read the code to detect the language if there's no
-    // file name, so leave Code empty here.
-    FileName = AssumeFileName;
-  } else {
-    // Read in the code in case the filename alone isn't enough to
-    // detect the language.
+  // We can't read the code to detect the language if there's no file name.
+  if (!IsSTDIN) {
+    // Read in the code in case the filename alone isn't enough to detect the
+    // language.
     ErrorOr<std::unique_ptr<MemoryBuffer>> CodeOrErr =
         MemoryBuffer::getFileOrSTDIN(FileNames[0]);
----------------
bhamiltoncx wrote:

Looks like this is the regression that caused #79023.

Previously, this would try to read in the code to detect the language whether or not this was reading from stdin.

Now, this fails to read in the code to detect the language when reading from stdin.


https://github.com/llvm/llvm-project/pull/74794


More information about the cfe-commits mailing list