Skip to content

Commit f47c121

Browse files
[IncludeTree] Don't callback on visibility only modules
Avoid callback on a visibility only module imports which avoid callback with a nullptr as imported file. Visibility only imports already gets a callback for the included header file and it should not get a callback for module. This also matches the behavior for the implicit module build. rdar://127615714
1 parent 9380081 commit f47c121

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

clang/lib/Lex/PPDirectives.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,16 +2099,16 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
20992099
/*IsIncludeDirective=*/true);
21002100
if (!CheckLoadResult(Imported))
21012101
return;
2102+
// PPCallback for IncludeDirective. Using the AST file as the FileEntry
2103+
// in the callback to indicate this is not a missing header. Note this
2104+
// is not the same behavior as non-include-tree build where the
2105+
// FileEntry is for the header file.
2106+
// FIXME: Need to clarify what `File` means in the callback, and if that
2107+
// can be the module file entry instead of header file entry.
2108+
Module *M = Imported;
2109+
InclusionCallback(M->getASTFile(), Imported);
21022110
}
21032111

2104-
// PPCallback for IncludeDirective. Using the AST file as the FileEntry in
2105-
// the callback to indicate this is not a missing header. Note this is not
2106-
// the same behavior as non-include-tree build where the FileEntry is for
2107-
// the header file.
2108-
// FIXME: Need to clarify what `File` means in the callback, and if that
2109-
// can be the module file entry instead of header file entry.
2110-
Module *M = Imported;
2111-
InclusionCallback(M->getASTFile(), Imported);
21122112
makeModuleVisible(Imported, EndLoc);
21132113
if (IncludeTok.getIdentifierInfo()->getPPKeywordID() !=
21142114
tok::pp___include_macros)

clang/test/ClangScanDeps/modules-include-tree-implementation-private.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
// RUN: cat %t/tu.rsp | sed -E 's|.*"-fcas-include-tree" "(llvmcas://[[:xdigit:]]+)".*|\1|' > %t/tu.casid
1717
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid | FileCheck %s -DPREFIX=%/t
1818
// RUN: %clang @%t/tu.rsp
19+
//
20+
// RUN: FileCheck %s -input-file=%t/tu.d -check-prefix DEPS
21+
22+
// DEPS: dependencies:
23+
// DEPS-DAG: tu.m
24+
// DEPS-DAG: Mod.h
25+
// DEPS-DAG: Priv.h
1926

2027
// CHECK: [[PREFIX]]/tu.m llvmcas://
2128
// CHECK: 1:1 <built-in> llvmcas://
@@ -43,7 +50,7 @@
4350
[{
4451
"file": "DIR/tu.m",
4552
"directory": "DIR",
46-
"command": "clang -fsyntax-only DIR/tu.m -F DIR -fmodule-name=Mod -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache"
53+
"command": "clang -fsyntax-only DIR/tu.m -F DIR -fmodule-name=Mod -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache -MMD -MT dependencies -MF DIR/tu.d"
4754
}]
4855

4956
//--- Mod.framework/Modules/module.modulemap

0 commit comments

Comments
 (0)