This is an archive of the discontinued LLVM Phabricator instance.

[clang][modules][deps] System module maps might not be affecting
ClosedPublic

Authored by jansvoboda11 on Oct 14 2022, 5:36 PM.

Details

Summary

The dependency scanner relies on the module map filtering logic in ASTWriter. The algorithm currently considers all system module maps affecting, which is not only sub-optimal, but can also cause failures when building a module explicitly (see attached test case).

This patch applies the same filtering logic to system module maps.

Diff Detail

Event Timeline

jansvoboda11 created this revision.Oct 14 2022, 5:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2022, 5:36 PM
Herald added a subscriber: ributzka. · View Herald Transcript
jansvoboda11 requested review of this revision.Oct 14 2022, 5:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2022, 5:36 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jansvoboda11 added inline comments.Oct 17 2022, 9:09 PM
clang/test/ClangScanDeps/modules-redefinition.m
38

Before this patch, this would fail with duplicate definition of module 'X'. It would be reached from the explicitly-provided -fmodule-map-file=%t/zeroth/module.modulemap and the implicitly discovered %t/second/module.modulemap.

Bigcheese accepted this revision.Oct 26 2022, 1:45 PM

lgtm once D136624 lands.

This revision is now accepted and ready to land.Oct 26 2022, 1:45 PM

FYI @fmayer

Probably this patch
https://lab.llvm.org/buildbot/#/builders/237/builds/350/steps/13/logs/stdio

-- Testing: 66920 tests, 48 workers --
Testing:  0.. 10.. 20
FAIL: Clang :: SemaCXX/sugar-common-types.cpp (14838 of 66920)
******************** TEST 'Clang :: SemaCXX/sugar-common-types.cpp' FAILED ********************
Script:
--
: 'RUN: at line 1';   /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang -cc1 -internal-isystem /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/lib/clang/16.0.0/include -nostdsysteminc -fsyntax-only -verify /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/test/SemaCXX/sugar-common-types.cpp -std=c++20 -fenable-matrix -triple i686-pc-win32
--
Exit Code: 1
Command Output (stderr):
--
==3367002==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0xaaaad3ed5664 in clang::TemplateArgument::Profile(llvm::FoldingSetNodeID&, clang::ASTContext const&) const /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/AST/TemplateBase.cpp:310:3
    #1 0xaaaad3f77740 in clang::AutoType::Profile(llvm::FoldingSetNodeID&, clang::ASTContext const&, clang::QualType, clang::AutoTypeKeyword, bool, clang::ConceptDecl*, llvm::ArrayRef<clang::TemplateArgument>) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/AST/Type.cpp:4532:9
    #2 0xaaaad34ac920 in Profile /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/include/llvm/ADT/FoldingSet.h:268:7
    #3 0xaaaad34ac920 in Equals /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/include/llvm/ADT/FoldingSet.h:420:3
    #4 0xaaaad34ac920 in llvm::ContextualFoldingSet<clang::AutoType, clang::ASTContext&>::NodeEquals(llvm::FoldingSetBase const*, llvm::FoldingSetBase::Node*, llvm::FoldingSetNodeID const&, unsigned int, llvm::FoldingSetNodeID&) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/include/llvm/ADT/FoldingSet.h:600:12
    #5 0xaaaacd221610 in llvm::FoldingSetBase::FindNodeOrInsertPos(llvm::FoldingSetNodeID const&, void*&, llvm::FoldingSetBase::FoldingSetInfo const&) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/FoldingSet.cpp:288:9
    #6 0xaaaad3450850 in FindNodeOrInsertPos /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/include/llvm/ADT/FoldingSet.h:490:45
    #7 0xaaaad3450850 in clang::ASTContext::getAutoTypeInternal(clang::QualType, clang::AutoTypeKeyword, bool, bool, clang::ConceptDecl*, llvm::ArrayRef<clang::TemplateArgument>, bool) const /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/AST/ASTContext.cpp:5804:32
    #8 0xaaaad3450e34 in clang::ASTContext::getAutoType(clang::QualType, clang::AutoTypeKeyword, bool, bool, clang::ConceptDecl*, llvm::ArrayRef<clang::TemplateArgument>) const /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/AST/ASTContext.cpp:5846:10
    #9 0xaaaad2e44934 in (anonymous namespace)::SubstituteDeducedTypeTransform::TransformAutoType(clang::TypeLocBuilder&, clang::AutoTypeLoc) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4618:41
    #10 0xaaaad2e407e4 in clang::TreeTransform<(anonymous namespace)::SubstituteDeducedTypeTransform>::TransformType(clang::TypeLocBuilder&, clang::TypeLoc) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/include/clang/AST/TypeNodes.inc:37:1
    #11 0xaaaad2e22d94 in (anonymous namespace)::SubstituteDeducedTypeTransform::Apply(clang::TypeLoc) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4650:14
    #12 0xaaaad2e225cc in clang::Sema::DeduceAutoType(clang::TypeLoc, clang::Expr*, clang::QualType&, clang::sema::TemplateDeductionInfo&, bool, bool) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4867:63
    #13 0xaaaad1fd7c14 in clang::Sema::deduceVarTypeFromInitializer(clang::VarDecl*, clang::DeclarationName, clang::QualType, clang::TypeSourceInfo*, clang::SourceRange, bool, clang::Expr*) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:12481:7
    #14 0xaaaad1fd85d8 in clang::Sema::DeduceVariableDeclarationType(clang::VarDecl*, bool, clang::Expr*) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:12517:26
    #15 0xaaaad1fd99f8 in clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:12868:9
    #16 0xaaaad1a605a8 in clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:2491:17
    #17 0xaaaad1a5a844 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:2198:21
    #18 0xaaaad19a37f8 in clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/Parser.cpp:1189:10
    #19 0xaaaad19a25e8 in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/Parser.cpp:1203:12
    #20 0xaaaad19a0238 in clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsingDeclSpec*) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/Parser.cpp:1029:12
    #21 0xaaaad199af10 in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/Parser.cpp:737:12
    #22 0xaaaad198c85c in clang::ParseAST(clang::Sema&, bool, bool) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseAST.cpp:162:20
    #23 0xaaaaced9fcb8 in clang::FrontendAction::Execute() /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1055:8
    #24 0xaaaacec7811c in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1044:33
    #25 0xaaaacef9542c in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:266:25
    #26 0xaaaac803d0f8 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/tools/driver/cc1_main.cpp:250:15
    #27 0xaaaac80346a4 in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/tools/driver/driver.cpp:319:12
    #28 0xaaaac80334dc in clang_main(int, char**) /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/tools/driver/driver.cpp:395:12
    #29 0xffffb1e473f8  (/lib/aarch64-linux-gnu/libc.so.6+0x273f8) (BuildId: f37f3aa07c797e333fd106472898d361f71798f5)
    #30 0xffffb1e474c8 in __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x274c8) (BuildId: f37f3aa07c797e333fd106472898d361f71798f5)
    #31 0xaaaac7faa6ac in _start (/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-16+0x4e5a6ac)
SUMMARY: MemorySanitizer: use-of-uninitialized-value /b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/AST/TemplateBase.cpp:310:3 in clang::TemplateArgument::Profile(llvm::FoldingSetNodeID&, clang::ASTContext const&) const
Exiting

I'm not sure about that. The failing test isn't using modules and it has failed with the same error before: https://lab.llvm.org/buildbot/#/builders/237/builds/345