Skip to content

Commit

Permalink
[clang-format][NFC] Skip ObjCHeaderStyleGuesser for empty code (#82957)
Browse files Browse the repository at this point in the history
  • Loading branch information
owenca committed Feb 27, 2024
1 parent f410f74 commit b2a4f64
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/Format/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3923,7 +3923,7 @@ FormatStyle::LanguageKind guessLanguage(StringRef FileName, StringRef Code) {
auto Extension = llvm::sys::path::extension(FileName);
// If there's no file extension (or it's .h), we need to check the contents
// of the code to see if it contains Objective-C.
if (Extension.empty() || Extension == ".h") {
if (!Code.empty() && (Extension.empty() || Extension == ".h")) {
auto NonEmptyFileName = FileName.empty() ? "guess.h" : FileName;
Environment Env(Code, NonEmptyFileName, /*Ranges=*/{});
ObjCHeaderStyleGuesser Guesser(Env, getLLVMStyle());
Expand Down

0 comments on commit b2a4f64

Please sign in to comment.