Bug 1501903 - Properly handle paths in inThirdPartyPath. r=andi a=RyanVM
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 25 Oct 2018 11:05:27 +0000
changeset 500882 a186639fc5c55c43708a6f897902c714f0dab791
parent 500881 3bb5d6b720eb9c27fc1990fb942b3f2da13403c5
child 500883 2058a60f13a7172dec390d9608fe35e2e7761e55
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersandi, RyanVM
bugs1501903
milestone64.0
Bug 1501903 - Properly handle paths in inThirdPartyPath. r=andi a=RyanVM SourceLocation that are passed to inThirdPartyPath might be macro expansion locations, for which SourceManager.getFilename returns the path of the directory containing the source, rather than of the expansion location. Furthermore, the paths getFileName returns are not canonical, and can contain e.g. `..`. Differential Revision: https://phabricator.services.mozilla.com/D9758
build/clang-plugin/Utils.h
--- a/build/clang-plugin/Utils.h
+++ b/build/clang-plugin/Utils.h
@@ -341,18 +341,22 @@ inline bool isPlacementNew(const CXXNewE
   const FunctionDecl *Declaration = Expression->getOperatorNew();
   if (Declaration && hasCustomAttribute<moz_heap_allocator>(Declaration)) {
     return false;
   }
   return true;
 }
 
 inline bool inThirdPartyPath(SourceLocation Loc, const SourceManager &SM) {
-  SmallString<1024> FileName = SM.getFilename(Loc);
-  llvm::sys::fs::make_absolute(FileName);
+  Loc = SM.getFileLoc(Loc);
+
+  SmallString<1024> RawFileName = SM.getFilename(Loc);
+  llvm::sys::fs::make_absolute(RawFileName);
+  SmallString<1024> FileName;
+  llvm::sys::fs::real_path(RawFileName, FileName);
 
   for (uint32_t i = 0; i < MOZ_THIRD_PARTY_PATHS_COUNT; ++i) {
     auto PathB = sys::path::begin(FileName);
     auto PathE = sys::path::end(FileName);
 
     auto ThirdPartyB = sys::path::begin(MOZ_THIRD_PARTY_PATHS[i]);
     auto ThirdPartyE = sys::path::end(MOZ_THIRD_PARTY_PATHS[i]);