Skip to content

Conversation

@zhaojunmeng
Copy link
Contributor

Modify ClangParser::ParseHeader() to stop parsing and return immediately if any file has a non-success ParseResult.

@tritao
Copy link
Collaborator

tritao commented Dec 2, 2025

Maybe the failure is due to the fact that this PR returns early in case of failure, and doesn't end up parsing all header files.

We should probably still keep attempting to parse all files, but we need to keep track in case there is a failure in any of the parsed files, and not return early.

@zhaojunmeng
Copy link
Contributor Author

The CI pipeline failed while executing the tests/emscripten/test.sh script. After debugging this issue, I found the path containing the cstddef header file has not been added to the include paths.

For other test projects (e.g., CSharp.Gen), the include path for cstddef (such as C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include on Windows) is added within the Parser::Setup() function:

void Parser::Setup(bool Compile)
{
    ...
    if (Target.getOS() == llvm::Triple::Linux)
        TC = new driver::toolchains::Linux(D, Target, Args);
    else if (Target.getEnvironment() == llvm::Triple::EnvironmentType::MSVC)
        TC = new driver::toolchains::MSVCToolChain(D, Target, Args);

    if (TC && !opts->noStandardIncludes)
    {
        llvm::opt::ArgStringList Includes;
        // calling AddClangSystemIncludeArgs() will add C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include into Includes variable.
        TC->AddClangSystemIncludeArgs(Args, Includes);
        TC->AddClangCXXStdlibIncludeArgs(Args, Includes);
        for (auto& Arg : Includes)
        {
            if (strlen(Arg) > 0 && Arg[0] != '-')
                HSOpts.AddPath(Arg, frontend::System, /*IsFramework=*/false,
                               /*IgnoreSysRoot=*/false);
        }
    }
    ...
}

However, when running tests/emscripten/test.sh, Target.getOS() returns Emscripten, resulting in a null TC variable, and the include path for cstddef is not added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants