[clang-tools-extra] r321762 - [clang-tidy] Update fuchsia-overloaded-operator to check for valid loc

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 4 02:20:50 PST 2018


Yes, would be nice to include this into 6.0.

On Wed, Jan 3, 2018 at 11:16 PM, Aaron Ballman <aaron at aaronballman.com>
wrote:

> Hans, I'd like to nominate this patch for the 6.0 branch. It fixes a
> failing assertion with new functionality; without this fix, anyone
> enabling this check and including a STL header that transitively
> includes <new> (which is most of them) will hit the assertion.
>
> Thanks!
>
> ~Aaron
>
> On Wed, Jan 3, 2018 at 5:10 PM, Julie Hockett via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
> > Author: juliehockett
> > Date: Wed Jan  3 14:10:11 2018
> > New Revision: 321762
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=321762&view=rev
> > Log:
> > [clang-tidy] Update fuchsia-overloaded-operator to check for valid loc
> >
> > Updating fuchsia-overloaded-operator check to not issue warnings for
> > invalid locations.
> >
> > Fixes PR35803.
> >
> > Differential Revision: https://reviews.llvm.org/D41708
> >
> > Modified:
> >     clang-tools-extra/trunk/clang-tidy/fuchsia/
> OverloadedOperatorCheck.cpp
> >     clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-
> operator.cpp
> >
> > Modified: clang-tools-extra/trunk/clang-tidy/fuchsia/
> OverloadedOperatorCheck.cpp
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp?
> rev=321762&r1=321761&r2=321762&view=diff
> > ============================================================
> ==================
> > --- clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
> (original)
> > +++ clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
> Wed Jan  3 14:10:11 2018
> > @@ -30,8 +30,12 @@ void OverloadedOperatorCheck::registerMa
> >  }
> >
> >  void OverloadedOperatorCheck::check(const MatchFinder::MatchResult
> &Result) {
> > -  if (const auto *D = Result.Nodes.getNodeAs<FunctionDecl>("decl"))
> > -    diag(D->getLocStart(), "cannot overload %0") << D;
> > +  const auto *D = Result.Nodes.getNodeAs<FunctionDecl>("decl");
> > +  assert(D && "No FunctionDecl captured!");
> > +
> > +  SourceLocation Loc = D->getLocStart();
> > +  if (Loc.isValid())
> > +    diag(Loc, "cannot overload %0") << D;
> >  }
> >
> >  } // namespace fuchsia
> >
> > Modified: clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-
> operator.cpp
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp?rev=
> 321762&r1=321761&r2=321762&view=diff
> > ============================================================
> ==================
> > --- clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp
> (original)
> > +++ clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp
> Wed Jan  3 14:10:11 2018
> > @@ -16,3 +16,6 @@ public:
> >
> >  A operator-(const A &A1, const A &A2);
> >  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator-'
> [fuchsia-overloaded-operator]
> > +
> > +void operator delete(void*, void*) throw();
> > +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator
> delete' [fuchsia-overloaded-operator]
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180104/84e84b81/attachment.html>


More information about the cfe-commits mailing list