[PATCH] D25610: [clang-move] Add header guard for the new header.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 14 06:03:51 PDT 2016


hokein added inline comments.


================
Comment at: clang-move/ClangMove.cpp:264
+    HeaderGuard += "#define " + GuardName + "\n";
+    clang::tooling::Replacement HeaderGuardInclude(FileName, 0, 0,
+                                                   HeaderGuard);
----------------
ioeric wrote:
> Might not quite related to this patch:
> 
> Considering how `tooling::Replacements::add(...)` is implemented now, it's quite inefficient to use `addOrMergeReplacement` in you case since almost all replacements will conflict, which would require expensive conflict-resolving merge. I think it would be cleaner and easier if you just concatenate all `Decl`s and create a single insertion replacement instead of keeping merging replacements at offset 0.
Good point. Yeah, the function only inserts new code to the new file. Make sense to only construct a single Replacement of the concatenated string. Will do in a follow-up.


https://reviews.llvm.org/D25610





More information about the cfe-commits mailing list