[clang-tools-extra] r342252 - [modernize-use-transparent-functors] TypeLocs can be implicitly created, don't crash when encountering those.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 14 11:05:30 PDT 2018


Author: d0k
Date: Fri Sep 14 11:05:30 2018
New Revision: 342252

URL: http://llvm.org/viewvc/llvm-project?rev=342252&view=rev
Log:
[modernize-use-transparent-functors] TypeLocs can be implicitly created, don't crash when encountering those.

Modified:
    clang-tools-extra/trunk/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
    clang-tools-extra/trunk/test/clang-tidy/modernize-use-transparent-functors.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp?rev=342252&r1=342251&r2=342252&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp Fri Sep 14 11:05:30 2018
@@ -121,6 +121,8 @@ void UseTransparentFunctorsCheck::check(
     return;
 
   SourceLocation ReportLoc = FunctorLoc.getLocation();
+  if (ReportLoc.isInvalid())
+    return;
   diag(ReportLoc, Message) << (FuncClass->getName() + "<>").str()
                            << FixItHint::CreateRemoval(
                                   FunctorTypeLoc.getArgLoc(0).getSourceRange());

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-transparent-functors.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-transparent-functors.cpp?rev=342252&r1=342251&r2=342252&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-transparent-functors.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-transparent-functors.cpp Fri Sep 14 11:05:30 2018
@@ -104,4 +104,7 @@ int main() {
   std::set2<int> control;
 }
 
-
+struct ImplicitTypeLoc : std::set2<std::less<int>> {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: prefer transparent functors
+  ImplicitTypeLoc() {}
+};




More information about the cfe-commits mailing list