Fix gn suggest adding self-dependency loops. Change-Id: I9663c1fd8533418f9d3a91d3baab01816a6a6964 Reviewed-on: https://gn-review.googlesource.com/c/gn/+/25580 Reviewed-by: Takuto Ikuta <tikuta@google.com> Commit-Queue: Matt Stark <msta@google.com>
diff --git a/src/gn/command_suggest.cc b/src/gn/command_suggest.cc index 1f9a1e0..e88dffa 100644 --- a/src/gn/command_suggest.cc +++ b/src/gn/command_suggest.cc
@@ -677,6 +677,14 @@ OutputEditCommand(edit, included); } + // If a public header attempts to include a private header, we output "suggest + // making private header public". We also suggest depending on the target that + // declares the private header. If it's all within the same target though, we + // should stop here and not suggest adding the dependency. + if (includer == included) { + return result; + } + // TODO: There are a bunch of optimizations we can perform here to make better // suggestions. They may be considered in the future. Some initial thoughts // include: