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 @@ -386,6 +386,13 @@ Error IncludeTreeActionController::finalizeModuleBuild(
386386 ModuleScanInstance.getInvocation ().getLangOpts (),
387387 ModuleScanInstance.getInvocation ().getCodeGenOpts ());
388388 auto Builder = BuilderStack.pop_back_val ();
389+
390+ // If there was an error, bail out early. The state of `Builder` may be
391+ // inconsistent since there is no guarantee that exitedInclude or
392+ // finalizeModuleBuild have been called for all imports.
393+ if (ModuleScanInstance.getDiagnostics ().hasUnrecoverableErrorOccurred ())
394+ return Error::success (); // Already reported.
395+
389396 auto Tree = Builder->finishIncludeTree (ModuleScanInstance,
390397 ModuleScanInstance.getInvocation ());
391398 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