[PATCH] clang-apply-replacements: Add code-formatting post processing step

Edwin Vane edwin.vane at intel.com
Mon Sep 30 07:02:42 PDT 2013

Comment at: clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp:79
@@ +78,3 @@
+/// \param[in] Replacements Replacements to apply
+/// \param[in] Rewrites Rewriter to use to apply replacements.
Daniel Jasper wrote:
> Is there a reason for this precondition. Why not just have the first statement:
>   if (Replacements.empty()) return;
> ?
> Like this all the callsites need to worry about that ..
No reason than for preference. This function had (accidentally) unwritten post-condition that `Result` would have file contents in it upon return. But since at least one Replacement is required to get the file name, this function would be unable to even put unmodified data in `Result`. Whether the function is left as is or just returns an empty string in the case of no replacements, some caller still needs to worry about there being no replacements.




More information about the cfe-commits mailing list