[clang] [Format] Fix detection of languages when reading from stdin (PR #79051)
Ben Hamilton via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 22 12:44:57 PST 2024
================
@@ -547,18 +547,20 @@ static void PrintVersion(raw_ostream &OS) {
// Dump the configuration.
static int dumpConfig(bool IsSTDIN) {
std::unique_ptr<llvm::MemoryBuffer> Code;
- // 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]);
- if (std::error_code EC = CodeOrErr.getError()) {
- llvm::errs() << EC.message() << "\n";
- return 1;
- }
- Code = std::move(CodeOrErr.get());
+
+ // FileNames should have at least "-" in it even if no file was specified.
----------------
bhamiltoncx wrote:
OK, changed to "must".
https://github.com/llvm/llvm-project/pull/79051
More information about the cfe-commits
mailing list