twoh updated this revision to Diff 110230. twoh added a comment. Relocate.
https://reviews.llvm.org/D36474 Files: lib/CodeGen/CGDebugInfo.cpp test/CodeGen/debug-info-preprocessed-file.i Index: test/CodeGen/debug-info-preprocessed-file.i =================================================================== --- /dev/null +++ test/CodeGen/debug-info-preprocessed-file.i @@ -0,0 +1,10 @@ +# 1 "/foo/bar/preprocessed-input.c" +# 1 "<built-in>" 1 +# 1 "<built-in>" 3 +# 318 "<built-in>" 3 +# 1 "<command line>" 1 +# 1 "<built-in>" 2 +# 1 "preprocessed-input.c" 2 + +// RUN: %clang -g -c -S -emit-llvm -o - %s | FileCheck %s +// CHECK: !DIFile(filename: "/foo/bar/preprocessed-input.c" Index: lib/CodeGen/CGDebugInfo.cpp =================================================================== --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -28,6 +28,7 @@ #include "clang/Basic/SourceManager.h" #include "clang/Basic/Version.h" #include "clang/Frontend/CodeGenOptions.h" +#include "clang/Frontend/FrontendOptions.h" #include "clang/Lex/HeaderSearchOptions.h" #include "clang/Lex/ModuleMap.h" #include "clang/Lex/PreprocessorOptions.h" @@ -483,6 +484,16 @@ llvm::sys::path::append(MainFileDirSS, MainFileName); MainFileName = MainFileDirSS.str(); } + // If the main file name provided is identical to the input file name, and + // if the input file is a preprocessed source, use the module name for + // debug info. The module name comes from the name specified in the first + // linemarker if the input is a preprocessed source. + if (MainFile->getName() == MainFileName && + FrontendOptions::getInputKindForExtension( + MainFile->getName().rsplit('.').second) + .isPreprocessed()) + MainFileName = CGM.getModule().getName().str(); + CSKind = computeChecksum(SM.getMainFileID(), Checksum); }
Index: test/CodeGen/debug-info-preprocessed-file.i =================================================================== --- /dev/null +++ test/CodeGen/debug-info-preprocessed-file.i @@ -0,0 +1,10 @@ +# 1 "/foo/bar/preprocessed-input.c" +# 1 "<built-in>" 1 +# 1 "<built-in>" 3 +# 318 "<built-in>" 3 +# 1 "<command line>" 1 +# 1 "<built-in>" 2 +# 1 "preprocessed-input.c" 2 + +// RUN: %clang -g -c -S -emit-llvm -o - %s | FileCheck %s +// CHECK: !DIFile(filename: "/foo/bar/preprocessed-input.c" Index: lib/CodeGen/CGDebugInfo.cpp =================================================================== --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -28,6 +28,7 @@ #include "clang/Basic/SourceManager.h" #include "clang/Basic/Version.h" #include "clang/Frontend/CodeGenOptions.h" +#include "clang/Frontend/FrontendOptions.h" #include "clang/Lex/HeaderSearchOptions.h" #include "clang/Lex/ModuleMap.h" #include "clang/Lex/PreprocessorOptions.h" @@ -483,6 +484,16 @@ llvm::sys::path::append(MainFileDirSS, MainFileName); MainFileName = MainFileDirSS.str(); } + // If the main file name provided is identical to the input file name, and + // if the input file is a preprocessed source, use the module name for + // debug info. The module name comes from the name specified in the first + // linemarker if the input is a preprocessed source. + if (MainFile->getName() == MainFileName && + FrontendOptions::getInputKindForExtension( + MainFile->getName().rsplit('.').second) + .isPreprocessed()) + MainFileName = CGM.getModule().getName().str(); + CSKind = computeChecksum(SM.getMainFileID(), Checksum); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits