This is an archive of the discontinued LLVM Phabricator instance.

[clang][ASTImporter] Add import of type-related nodes
ClosedPublic

Authored by danix800 on Aug 26 2023, 8:49 PM.

Details

Summary

Add import of type-related nodes:

  • bitIntType
  • constantMatrixType
  • dependentAddressSpaceType
  • dependentBitIntType
  • dependentSizedMatrixType
  • dependentVectorType
  • objcTypeParamDecl
  • objcTypeParamType
  • pipeType
  • vectorType

Diff Detail

Event Timeline

danix800 created this revision.Aug 26 2023, 8:49 PM
Herald added a reviewer: shafik. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: martong. · View Herald Transcript
danix800 requested review of this revision.Aug 26 2023, 8:49 PM
danix800 edited the summary of this revision. (Show Details)Aug 29 2023, 5:20 AM
balazske added inline comments.Aug 29 2023, 8:49 AM
clang/lib/AST/ASTImporter.cpp
1758

At cases like this (many imported values) importChecked can be used, like at VisitDependentSizedArrayType.

clang/unittests/AST/ASTImporterObjCTest.cpp
100

This single assert can be sufficient for this test because the ToTU was empty before import, it is not expected that more than one instance will be created. Better is to check for example if getTypeForDecl is correctly imported.

danix800 updated this revision to Diff 554545.Aug 29 2023, 7:11 PM
  1. Simplify error handling
  2. Remove unnecessary tests
danix800 planned changes to this revision.Aug 29 2023, 7:11 PM

Changes planned for https://reviews.llvm.org/D158872 is still under discussion.

danix800 updated this revision to Diff 554603.EditedAug 30 2023, 12:29 AM

Pull in local matchers for testcases, since https://reviews.llvm.org/D158872 is abandoned.

balazske accepted this revision.Aug 31 2023, 8:20 AM
This revision is now accepted and ready to land.Aug 31 2023, 8:20 AM
This revision was landed with ongoing or failed builds.Aug 31 2023, 5:00 PM
This revision was automatically updated to reflect the committed changes.
haowei added a subscriber: haowei.Sep 8 2023, 4:05 PM

Hi I am working on updating GoogleTest in LLVM to v1.14.0 and during my local testing, I noticed that this patch added 2 new tests ImportMatrixType and ImportOpenCLPipe through TEST_P calls, however, both tests were not instantiated by INSTANTIATE_TEST_SUITE_P so they were not ran during check-clang. This will causes test failures when using GoogleTest v1.14.0 since it now explicitly fail when an INSTANTIATE_TEST_SUITE_P is not paired with an TEST_P I manually added

INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportMatrixType,
                         DefaultTestValuesForRunOptions);

INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportOpenCLPipe,
                         DefaultTestValuesForRunOptions);

to ASTImporterTest.cpp and reran the clang test and it failed with error message:

[ RUN      ] ParameterizedTests/ImportOpenCLPipe.ImportPipeType/0
Not implemented yet!
UNREACHABLE executed at clang/lib/Testing/CommandLineArgs.cpp:47!
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  ASTTests 0x00005565e9e71d18

--
exit: -6
--

Looking at https://github.com/llvm/llvm-project/blob/37a20cc68f545647e614c5ba4ae311dc3fd277e9/clang/lib/Testing/CommandLineArgs.cpp#L47, this is were the unreachable code was hit. Is it the intended behavior?

Shall I enable ImportMatrixType and disable ImportOpenCLPipe tests so we can update the GoogleTest in LLVM?

Looking at https://github.com/llvm/llvm-project/blob/37a20cc68f545647e614c5ba4ae311dc3fd277e9/clang/lib/Testing/CommandLineArgs.cpp#L47, this is were the unreachable code was hit. Is it the intended behavior?

Shall I enable ImportMatrixType and disable ImportOpenCLPipe tests so we can update the GoogleTest in LLVM?

I'm not familiar with GoogleTest so I wasn't expecting this to happen.

To enabling ImportOpenCLPipe we might use "-x", "cl", "-cl-no-stdinc", "-cl-std=CL2.0" here.

See also https://reviews.llvm.org/D158872 for some extra context of both testing with ImportMatrixType and ImportOpenCLPipe.

haowei added a comment.Sep 8 2023, 7:00 PM

Looking at https://github.com/llvm/llvm-project/blob/37a20cc68f545647e614c5ba4ae311dc3fd277e9/clang/lib/Testing/CommandLineArgs.cpp#L47, this is were the unreachable code was hit. Is it the intended behavior?

Shall I enable ImportMatrixType and disable ImportOpenCLPipe tests so we can update the GoogleTest in LLVM?

I'm not familiar with GoogleTest so I wasn't expecting this to happen.

To enabling ImportOpenCLPipe we might use "-x", "cl", "-cl-no-stdinc", "-cl-std=CL2.0" here.

See also https://reviews.llvm.org/D158872 for some extra context of both testing with ImportMatrixType and ImportOpenCLPipe.

In a nutshell, ImportOpenCLPipe wasn't enabled after your patch, that is why the test failure was unnoticed. You have to add

INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportOpenCLPipe,
                         DefaultTestValuesForRunOptions);

in the same namespace like other tests in this file to let it run. I am very unfamiliar with Clang AST codebase so sorry I don't really know what changes you need to make this test pass. At current state, this test will lead to unreachable code error.

https://github.com/llvm/llvm-project/pull/65823 is my attempt to roll GoogleTest 1.14.0 to bring some upstream bug fixes and improvements to LLVM. Patch https://github.com/llvm/llvm-project/pull/65823/commits/ff67955ecbafcf847e11188c44e8dd070899b0b6 attempts to enable ImportMatrixType and explicitly disable ImportOpenCLPipe so the check-clang step can pass under GoogleTest v1.14.0