]> granicus.if.org Git - clang/commitdiff
Module Debugging: Canonicalize the file names used as PCH module names
authorAdrian Prantl <aprantl@apple.com>
Fri, 22 Jan 2016 23:30:56 +0000 (23:30 +0000)
committerAdrian Prantl <aprantl@apple.com>
Fri, 22 Jan 2016 23:30:56 +0000 (23:30 +0000)
by stripping the path. Follow-up to r258555.

This is safe because only one PCH per CU is currently supported for
module debugging.

rdar://problem/24301262

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258582 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/ObjectFilePCHContainerOperations.cpp
lib/Serialization/ASTReader.cpp
test/Modules/ExtDebugInfo.m
test/Modules/ModuleDebugInfo.m

index 406b433c95c5069555176f405278a5cfe4f3d89e..e3030a8e81212c8be3b3c36061cc2720ee71e773 100644 (file)
@@ -19,8 +19,8 @@
 #include "clang/CodeGen/BackendUtil.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "clang/Frontend/CompilerInstance.h"
-#include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/HeaderSearch.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Serialization/ASTWriter.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Bitcode/BitstreamReader.h"
@@ -31,6 +31,7 @@
 #include "llvm/IR/Module.h"
 #include "llvm/Object/COFF.h"
 #include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/TargetRegistry.h"
 #include <memory>
 
@@ -164,9 +165,12 @@ public:
     M->setDataLayout(Ctx->getTargetInfo().getDataLayoutString());
     Builder.reset(new CodeGen::CodeGenModule(
         *Ctx, HeaderSearchOpts, PreprocessorOpts, CodeGenOpts, *M, Diags));
-    Builder->getModuleDebugInfo()->setModuleMap(MMap);
-    Builder->getModuleDebugInfo()->setPCHDescriptor(
-        {MainFileName, "", OutputFileName, ~1ULL});
+
+    // Prepare CGDebugInfo to emit debug info for a clang module.
+    auto *DI = Builder->getModuleDebugInfo();
+    StringRef ModuleName = llvm::sys::path::filename(MainFileName);
+    DI->setPCHDescriptor({ModuleName, "", OutputFileName, ~1ULL});
+    DI->setModuleMap(MMap);
   }
 
   bool HandleTopLevelDecl(DeclGroupRef D) override {
index 833ff57e4d0b8fb92beea486e0c1cc7459768f08..97fbb45e121be0901c111529900ff835610474ca 100644 (file)
@@ -7581,8 +7581,9 @@ ASTReader::getSourceDescriptor(unsigned ID) {
   // Chained PCH are not suported.
   if (ModuleMgr.size() == 1) {
     ModuleFile &MF = ModuleMgr.getPrimaryModule();
-    return ASTReader::ASTSourceDescriptor(
-        MF.OriginalSourceFileName, MF.OriginalDir, MF.FileName, MF.Signature);
+    StringRef ModuleName = llvm::sys::path::filename(MF.OriginalSourceFileName);
+    return ASTReader::ASTSourceDescriptor(ModuleName, MF.OriginalDir,
+                                          MF.FileName, MF.Signature);
   }
   return None;
 }
index 416f2813cecfdd7cc0a47a1675c6dde6012fc50e..5c3c7112b8ca210b085262fe691fc96a62646503 100644 (file)
@@ -34,7 +34,7 @@ int foo(ObjCClass *c) {
 // CHECK-SAME:             scope: ![[MOD:[0-9]+]],
 // CHECK-SAME:             flags: DIFlagFwdDecl)
 // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type,
-// CHECK: ![[MOD]] = !DIModule(scope: null, name: {{.*}}DebugObjC
+// CHECK: ![[MOD]] = !DIModule(scope: null, name: "DebugObjC
 
 // CHECK: !DIGlobalVariable(name: "GlobalUnion",
 // CHECK-SAME:              type: ![[GLOBAL_UNION:[0-9]+]]
index 3d6c6657c916e800b1522272d65c8fdffa2e2b17..6bca67656aedcb6bf30bd1cfbc788051ff61dee5 100644 (file)
@@ -28,7 +28,7 @@
 
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
 // CHECK-SAME:             scope: ![[MODULE:[0-9]+]],
-// CHECK: ![[MODULE]] = !DIModule(scope: null, name:{{.*}}DebugObjC
+// CHECK: ![[MODULE]] = !DIModule(scope: null, name: "DebugObjC
 
 // CHECK: ![[TD_ENUM:.*]] = !DICompositeType(tag: DW_TAG_enumeration_type,
 // CHECK-SAME-NOT:         name: