Bug 1483953 - Add a FixIt hint for the ExplicitImplicitChecker analysis. r=Ehsan
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Fri, 24 Aug 2018 14:11:26 +0000
changeset 481658 c51e568a0a51e8d7b460b9704ef2cda9f4a0ed7e
parent 481657 11e6aa3a116b7d116e307a8c1df090049f3df3ee
child 481659 69faa23050d945c1e1a4f0e5ec0e822f2c3b7ae3
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersEhsan
bugs1483953
milestone63.0a1
Bug 1483953 - Add a FixIt hint for the ExplicitImplicitChecker analysis. r=Ehsan Differential Revision: https://phabricator.services.mozilla.com/D4191
build/clang-plugin/ExplicitImplicitChecker.cpp
--- a/build/clang-plugin/ExplicitImplicitChecker.cpp
+++ b/build/clang-plugin/ExplicitImplicitChecker.cpp
@@ -19,15 +19,18 @@ void ExplicitImplicitChecker::check(cons
   // We've already checked everything in the matcher, so we just have to report
   // the error.
 
   const CXXConstructorDecl *Ctor =
       Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor");
   const CXXRecordDecl *Declaration =
       Result.Nodes.getNodeAs<CXXRecordDecl>("class");
 
+  FixItHint FixItHint =
+      FixItHint::CreateInsertion(Ctor->getLocation(), "explicit ");
   diag(Ctor->getLocation(), "bad implicit conversion constructor for %0",
        DiagnosticIDs::Error)
       << Declaration->getDeclName();
   diag(Ctor->getLocation(),
        "consider adding the explicit keyword to the constructor",
-       DiagnosticIDs::Note);
+       DiagnosticIDs::Note)
+      << FixItHint;
 }