-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang] Don't create import decls without -fmodules
When modules are disabled, there's no loaded module for these import decls to point at. This results in crashes when there are modulemap files but no -fmodules flag (this configuration is used for layering check violations). This patch makes sure import declarations are introduced only when modules are enabled, which makes this case similar to textual headers (no import decls are created for #include of textual headers from a modulemap). Differential Revision: https://reviews.llvm.org/D152274
- Loading branch information
Showing
8 changed files
with
25 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
3 changes: 3 additions & 0 deletions
3
clang/test/Modules/Inputs/modulemaps-nomodules/module.modulemap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module M { | ||
private header "header.h" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Make sure we treat includes that are part of modulemaps the same as textual | ||
// headers when modules are not enabled (e.g do't generate import decls, but | ||
// still perform layering checks). | ||
// No need to pass -fno-modules explicitly, absence implies negation for cc1. | ||
// RUN: %clang_cc1 -I %S/Inputs/modulemaps-nomodules -fmodule-map-file=%S/Inputs/modulemaps-nomodules/module.modulemap %s -verify -ast-dump | FileCheck %s | ||
|
||
#include "header.h" // expected-error{{use of private header from outside its module: 'header.h'}} | ||
// CHECK-NOT: ImportDecl |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module M { | ||
header "header.h" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Make sure we don't crash when serializing a PCH with an include from a | ||
// modulemap file in nomodules mode. | ||
// No need to pass -fno-modules explicitly, absence implies negation for cc1. | ||
// RUN: %clang_cc1 -I %S/Inputs/modulemaps-nomodules -fmodule-map-file=%S/Inputs/modulemaps-nomodules/module.modulemap %s -emit-pch -o /dev/null | ||
|
||
#include "header.h" |