Chizi123 created this revision. Chizi123 added reviewers: llvm-commits, cfe-commits, djasper, rsmith, klimek. Herald added a project: clang. Chizi123 requested review of this revision.
Currently, -style is capable of accepting configuration options in its argument, while -fallback-style must be a predefined style. This allows -fallback-style to take an argument formatted like a style argument. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D90133 Files: clang/lib/Format/Format.cpp Index: clang/lib/Format/Format.cpp =================================================================== --- clang/lib/Format/Format.cpp +++ clang/lib/Format/Format.cpp @@ -2844,8 +2844,15 @@ FormatStyle Style = getLLVMStyle(guessLanguage(FileName, Code)); FormatStyle FallbackStyle = getNoStyle(); - if (!getPredefinedStyle(FallbackStyleName, Style.Language, &FallbackStyle)) + if (FallbackStyleName.startswith("{")) { + if (std::error_code ec = parseConfiguration( + FallbackStyleName, &FallbackStyle, AllowUnknownOptions)) + return make_string_error("Error parsing -fallback-style: " + + ec.message()); + } else if (!getPredefinedStyle(FallbackStyleName, Style.Language, + &FallbackStyle)) { return make_string_error("Invalid fallback style \"" + FallbackStyleName); + } if (StyleName.startswith("{")) { // Parse YAML/JSON style from the command line.
Index: clang/lib/Format/Format.cpp =================================================================== --- clang/lib/Format/Format.cpp +++ clang/lib/Format/Format.cpp @@ -2844,8 +2844,15 @@ FormatStyle Style = getLLVMStyle(guessLanguage(FileName, Code)); FormatStyle FallbackStyle = getNoStyle(); - if (!getPredefinedStyle(FallbackStyleName, Style.Language, &FallbackStyle)) + if (FallbackStyleName.startswith("{")) { + if (std::error_code ec = parseConfiguration( + FallbackStyleName, &FallbackStyle, AllowUnknownOptions)) + return make_string_error("Error parsing -fallback-style: " + + ec.message()); + } else if (!getPredefinedStyle(FallbackStyleName, Style.Language, + &FallbackStyle)) { return make_string_error("Invalid fallback style \"" + FallbackStyleName); + } if (StyleName.startswith("{")) { // Parse YAML/JSON style from the command line.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits