title: How to delete a line with clang-tidy?
body: <p>I'm creating a clang-tidy checker to replace a function with another function. The replaced function is relying on a <code>using namespace ..;</code> declaration. As part of my clang-tidy checker I also want to remove that declaration.</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;filesystem&gt;
  
  namespace fs = std::filesystem;
  using namespace ns1::ns2; // declaration I want to remove
  using namespace std;
  
  </code></pre>
  <p>If have it currently working to remove the SourceRange of <code>using namespace ns1::ns2</code> and trailing <code>;</code>. But this leaves a empty line behind as this diff shows:</p>
  <pre class="lang-diff prettyprint-override"><code> #include &lt;filesystem&gt;
  
   namespace fs = std::filesystem;
  -using namespace ns1::ns2;
  +
   using namespace std;
  </code></pre>
  <p>I achieved it with clang-tidy <code>check()</code>:</p>
  <pre class="lang-cpp prettyprint-override"><code>void RenameFunctionCheck::check(const MatchFinder::MatchResult &amp;Result)
  {
    // rename function
  
    if (const auto *MatchNS = Result.Nodes.getNodeAs&lt;UsingDirectiveDecl&gt;(&quot;replaceNS&quot;)) {
      ASTContext *Context = Result.Context;
      SourceLocation Semicolon = Lexer::getLocForEndOfToken(
        MatchedNS-&gt;getIdentLocation(), 0, Context-&gt;getSourceManager(),
        Context-&gt;getLangOpts());
      
      diag(MatchedNS-&gt;getUsingLoc(), &quot;obsolete nested namespace ns1::ns2&quot;)
          &lt;&lt; FixItHint::CreateRemoval(MatchedNS-&gt;getSourceRange())
          &lt;&lt; FixItHint::CreateRemoval(Semicolon);
    }
  }
  </code></pre>
  <p>How do I delete the whole line?</p>