File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
lib/Tooling/DependencyScanning Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -425,6 +425,13 @@ Error IncludeTreeActionController::finalizeModuleBuild(
425
425
ModuleScanInstance.getInvocation ().getLangOpts (),
426
426
ModuleScanInstance.getInvocation ().getCodeGenOpts ());
427
427
auto Builder = BuilderStack.pop_back_val ();
428
+
429
+ // If there was an error, bail out early. The state of `Builder` may be
430
+ // inconsistent since there is no guarantee that exitedInclude or
431
+ // finalizeModuleBuild have been called for all imports.
432
+ if (ModuleScanInstance.getDiagnostics ().hasUnrecoverableErrorOccurred ())
433
+ return Error::success (); // Already reported.
434
+
428
435
auto Tree = Builder->finishIncludeTree (ModuleScanInstance,
429
436
ModuleScanInstance.getInvocation ());
430
437
if (!Tree)
Original file line number Diff line number Diff line change
1
+ // Tests that a missing header in a module that is itself imported by another
2
+ // module does not crash/assert in the IncludeTreeBuilder.
3
+
4
+ // RUN: rm -rf %t
5
+ // RUN: split-file %s %t
6
+
7
+ // RUN: not clang-scan-deps -format experimental-include-tree-full -cas-path %t/cas -- %clang -fmodules -fmodules-cache-path=%t/cache -c %t/tu0.m -I%t
8
+ // RUN: not clang-scan-deps -format experimental-include-tree-full -cas-path %t/cas -- %clang -fmodules -fmodules-cache-path=%t/cache -c %t/tu1.m -I%t
9
+
10
+ //--- module.modulemap
11
+ module MissingH {
12
+ header "missing.h"
13
+ }
14
+
15
+ module Importer {
16
+ header "importer.h"
17
+ }
18
+
19
+ //--- not-missing.h
20
+
21
+ //--- importer.h
22
+ @import MissingH ;
23
+
24
+ //--- tu0.m
25
+ @import MissingH ;
26
+
27
+ //--- tu1.m
28
+ @import Importer ;
You can’t perform that action at this time.
0 commit comments