diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 7cf661994a29c..37d7a6755d390 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -554,14 +554,16 @@ void CGDebugInfo::CreateCompileUnit() { // 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. + // linemarker if the input is a preprocessed source. In this case we don't + // know the content to compute a checksum. if (MainFile->getName() == MainFileName && FrontendOptions::getInputKindForExtension( MainFile->getName().rsplit('.').second) - .isPreprocessed()) + .isPreprocessed()) { MainFileName = CGM.getModule().getName().str(); - - CSKind = computeChecksum(SM.getMainFileID(), Checksum); + } else { + CSKind = computeChecksum(SM.getMainFileID(), Checksum); + } } llvm::dwarf::SourceLanguage LangTag; diff --git a/clang/test/CodeGen/debug-info-preprocessed-file.i b/clang/test/CodeGen/debug-info-preprocessed-file.i index 23fd26525e3bf..c8a2307d46c31 100644 --- a/clang/test/CodeGen/debug-info-preprocessed-file.i +++ b/clang/test/CodeGen/debug-info-preprocessed-file.i @@ -6,6 +6,10 @@ # 1 "" 2 # 1 "preprocessed-input.c" 2 +/// The main file is preprocessed. We change it to preprocessed-input.c. Since +/// the content is not available, we don't compute a checksum. // RUN: %clang -g -c -S -emit-llvm -o - %s | FileCheck %s // CHECK: !DICompileUnit(language: DW_LANG_C{{.*}}, file: ![[FILE:[0-9]+]] // CHECK: ![[FILE]] = !DIFile(filename: "/foo/bar/preprocessed-input.c" +// CHECK-NOT: checksumkind: +// CHECK-NOT: !DIFile(