================
@@ -132,6 +133,41 @@ MacroExpansionContext::getOriginalText(SourceLocation 
MacroExpansionLoc) const {
       LangOpts);
 }
 
+std::optional<StringRef> MacroExpansionContext::getFormattedExpandedText(
+    SourceLocation MacroExpansionLoc, bool ShouldFormatMacrosPlist) const {
+  std::optional<StringRef> ExpandedText = getExpandedText(MacroExpansionLoc);
+  if (!ExpandedText)
+    return std::nullopt;
+
+  if (!ShouldFormatMacrosPlist)
+    return ExpandedText;
+
+  auto CachedIt = FormattedExpandedTokens.find(MacroExpansionLoc);
+  if (CachedIt != FormattedExpandedTokens.end())
+    return StringRef(CachedIt->getSecond());
+
+  clang::format::FormatStyle Style = clang::format::getLLVMStyle();
+
+  std::string MacroCodeBlock = ExpandedText->str();
+
+  std::vector<clang::tooling::Range> Ranges;
+  Ranges.emplace_back(0, MacroCodeBlock.length());
+
+  auto Replacements = clang::format::reformat(Style, MacroCodeBlock, Ranges,
+                                              "<macro-expansion>");
+
+  auto Result =
----------------
ankurkraj wrote:

makes sense, have made the changes

https://github.com/llvm/llvm-project/pull/156046
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to