r329685 - [Tooling] fix UB when interpolating compile commands with an empty index

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 10 03:36:47 PDT 2018


Author: sammccall
Date: Tue Apr 10 03:36:46 2018
New Revision: 329685

URL: http://llvm.org/viewvc/llvm-project?rev=329685&view=rev
Log:
[Tooling] fix UB when interpolating compile commands with an empty index

Modified:
    cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp

Modified: cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp?rev=329685&r1=329684&r2=329685&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp Tue Apr 10 03:36:46 2018
@@ -373,8 +373,8 @@ private:
   ArrayRef<SubstringAndIndex>
   indexLookup(StringRef Key, const std::vector<SubstringAndIndex> &Idx) const {
     // Use pointers as iteratiors to ease conversion of result to ArrayRef.
-    auto Range =
-        std::equal_range(&Idx[0], &Idx[Idx.size()], Key, Less<Prefix>());
+    auto Range = std::equal_range(Idx.data(), Idx.data() + Idx.size(), Key,
+                                  Less<Prefix>());
     return {Range.first, Range.second};
   }
 




More information about the cfe-commits mailing list