[llvm] 9240e48 - [OpenMP][OMPIRBuilder] Use the source (=directory + filename) for locations

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 07:06:45 PDT 2020


Author: Johannes Doerfert
Date: 2020-08-14T08:59:25-05:00
New Revision: 9240e48a588ccdd766a60a307cf6ea028b3106b6

URL: https://github.com/llvm/llvm-project/commit/9240e48a588ccdd766a60a307cf6ea028b3106b6
DIFF: https://github.com/llvm/llvm-project/commit/9240e48a588ccdd766a60a307cf6ea028b3106b6.diff

LOG: [OpenMP][OMPIRBuilder] Use the source (=directory + filename) for locations

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D85938

Added: 
    

Modified: 
    llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
    llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 924f036a0020..c80a5bbb2401 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -263,8 +263,10 @@ OpenMPIRBuilder::getOrCreateSrcLocStr(const LocationDescription &Loc) {
   DILocation *DIL = Loc.DL.get();
   if (!DIL)
     return getOrCreateDefaultSrcLocStr();
-  StringRef FileName =
-      !DIL->getFilename().empty() ? DIL->getFilename() : M.getName();
+  StringRef FileName = M.getName();
+  if (DIFile *DIF = DIL->getFile())
+    if (Optional<StringRef> Source = DIF->getSource())
+      FileName = *Source;
   StringRef Function = DIL->getScope()->getSubprogram()->getName();
   Function =
       !Function.empty() ? Function : Loc.IP.getBlock()->getParent()->getName();

diff  --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
index edd2c8f5dd88..d671e65f8f49 100644
--- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -34,7 +34,8 @@ class OpenMPIRBuilderTest : public testing::Test {
     BB = BasicBlock::Create(Ctx, "", F);
 
     DIBuilder DIB(*M);
-    auto File = DIB.createFile("test.dbg", "/");
+    auto File = DIB.createFile("test.dbg", "/src", llvm::None,
+                               Optional<StringRef>("/src/test.dbg"));
     auto CU =
         DIB.createCompileUnit(dwarf::DW_LANG_C, File, "llvm-C", true, "", 0);
     auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
@@ -301,7 +302,7 @@ TEST_F(OpenMPIRBuilderTest, DbgLoc) {
       dyn_cast<ConstantDataArray>(SrcStrGlob->getInitializer());
   if (!SrcSrc)
     return;
-  EXPECT_EQ(SrcSrc->getAsCString(), ";test.dbg;foo;3;7;;");
+  EXPECT_EQ(SrcSrc->getAsCString(), ";/src/test.dbg;foo;3;7;;");
 }
 
 TEST_F(OpenMPIRBuilderTest, ParallelSimple) {


        


More information about the llvm-commits mailing list