dyung created this revision.
dyung added a reviewer: aprantl.
dyung added a subscriber: cfe-commits.

In our internal testing, we found a crash in the compiler which was reduced to 
the attached test case. The issue was "fixed" a while back with Adrian's change 
in r248069 as the code causing the crash was changed and consequently no longer 
crashes. The crash occurred in the function CGDebugInfo::EmitImportDecl() in 
CGDebugInfo.cpp. We did not determine the underlying cause of the crash since 
it no longer occurs, but wanted to contribute the test case along with some 
info about it in case anyone might wish to investigate further in case the 
issue might still exist somewhere.

The function EmitImportDecl contained the following code:

```
void CGDebugInfo::EmitImportDecl(const ImportDecl &ID) {
    auto *Reader = CGM.getContext().getExternalSource();
    auto Info = Reader->getSourceDescriptor(*ID.getImportedModule());
```

The crash was because getExternalSource() was returning a null pointer which 
was assigned into Reader, and when the next line tried to use that pointer, it 
caused a crash.

http://reviews.llvm.org/D19048

Files:
  test/Modules/Inputs/getSourceDescriptor-crash/h1.h
  test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
  test/Modules/getSourceDescriptor-crash.cpp

Index: test/Modules/getSourceDescriptor-crash.cpp
===================================================================
--- test/Modules/getSourceDescriptor-crash.cpp
+++ test/Modules/getSourceDescriptor-crash.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang -I %S/Inputs/getSourceDescriptor-crash -c -g 
-fimplicit-module-maps %s
+
+#include "h1.h"
+#include "h1.h"
Index: test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
===================================================================
--- test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
+++ test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
@@ -0,0 +1,3 @@
+module foo {
+       header "h1.h"
+}
\ No newline at end of file
Index: test/Modules/Inputs/getSourceDescriptor-crash/h1.h
===================================================================
--- test/Modules/Inputs/getSourceDescriptor-crash/h1.h
+++ test/Modules/Inputs/getSourceDescriptor-crash/h1.h
@@ -0,0 +1 @@
+#pragma once


Index: test/Modules/getSourceDescriptor-crash.cpp
===================================================================
--- test/Modules/getSourceDescriptor-crash.cpp
+++ test/Modules/getSourceDescriptor-crash.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang -I %S/Inputs/getSourceDescriptor-crash -c -g -fimplicit-module-maps %s
+
+#include "h1.h"
+#include "h1.h"
Index: test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
===================================================================
--- test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
+++ test/Modules/Inputs/getSourceDescriptor-crash/module.modulemap
@@ -0,0 +1,3 @@
+module foo {
+       header "h1.h"
+}
\ No newline at end of file
Index: test/Modules/Inputs/getSourceDescriptor-crash/h1.h
===================================================================
--- test/Modules/Inputs/getSourceDescriptor-crash/h1.h
+++ test/Modules/Inputs/getSourceDescriptor-crash/h1.h
@@ -0,0 +1 @@
+#pragma once
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to