This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Add UsedDeclVisitor
ClosedPublic

Authored by yaxunl on Mar 16 2020, 6:00 PM.

Details

Summary

This patch is extracted from https://reviews.llvm.org/D70172

Diff Detail

Event Timeline

yaxunl created this revision.Mar 16 2020, 6:00 PM

Thanks, looks good except for one oversight.

clang/lib/Sema/UsedDeclVisitor.h
44

You need to recurse on the base expression here. (And that's a good test case for your own patch!)

yaxunl updated this revision to Diff 250688.Mar 16 2020, 9:18 PM
yaxunl marked 2 inline comments as done.

visit base expr of member expr.

clang/lib/Sema/UsedDeclVisitor.h
44

fixed

rjmccall accepted this revision.Mar 16 2020, 9:21 PM

Thanks, LGTM.

This revision is now accepted and ready to land.Mar 16 2020, 9:21 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2020, 9:38 AM

This does not appear to be NFC:
git checkout 704cd4d5d0754904361823588f203369c309deca ; ninja check-mlir passes
git checkout 08ab8c9af4dd27cb306b449edc9a9c50ed11194a ; ninja check-mlir fails with:

0.      Program arguments: Compiles/build_clang/bin/clang++ -DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -DMLIR_CUDA_CONVERSIONS_ENABLED=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/mlir/lib/Transforms -Illvm-project/mlir/lib/Transforms -Iinclude -Illvm-project/llvm/include -Illvm-project/mlir/include -Itools/mlir/include -fPIC -fvisibility-inl
ines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT tools/mlir/lib/Transforms/CMakeFiles/MLIRTransforms.dir/AffineDataCopyGeneration.cpp.o -MF tools/mlir/lib/Transforms/CMakeFiles/MLIRTransforms.dir/AffineDataCopyGeneration.cpp.o.d -o tools/mlir/lib/Transforms/CMakeFiles/MLIRTransforms.dir/AffineDataCopyGeneration.cpp.o -c llvm-project/mlir/lib/Transforms/AffineDataCopyGeneration.cpp
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
3.      /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/unique_ptr.h:848:5: Generating code for declaration 'std::make_unique'
build_clang/bin/clang++(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x1a)[0x55796bf8436a]
build_clang/bin/clang++(_ZN4llvm3sys17RunSignalHandlersEv+0x34)[0x55796bf82204]
build_clang/bin/clang++(_ZN4llvm3sys15CleanupOnSignalEm+0xf8)[0x55796bf82708]
build_clang/bin/clang++(+0x1a58a08)[0x55796bf07a08]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13520)[0x7f1b727f7520]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x121)[0x7f1b722bd535]
/lib/x86_64-linux-gnu/libc.so.6(+0x2540f)[0x7f1b722bd40f]
/lib/x86_64-linux-gnu/libc.so.6(+0x32b92)[0x7f1b722cab92]
build_clang/bin/clang++(_ZN5clang7CodeGen15CodeGenFunction17EmitDeclRefLValueEPKNS_11DeclRefExprE+0x358)[0x55796c4cb138]
build_clang/bin/clang++(_ZN5clang7CodeGen15CodeGenFunction10EmitLValueEPKNS_4ExprE+0x2f9)[0x55796c4ca6d9]
build_clang/bin/clang++(_ZN5clang7CodeGen15CodeGenFunction14EmitCastLValueEPKNS_8CastExprE+0x103)[0x55796c4d4033]

This does not appear to be NFC:
git checkout 704cd4d5d0754904361823588f203369c309deca ; ninja check-mlir passes
git checkout 08ab8c9af4dd27cb306b449edc9a9c50ed11194a ; ninja check-mlir fails with:

0.      Program arguments: Compiles/build_clang/bin/clang++ -DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -DMLIR_CUDA_CONVERSIONS_ENABLED=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/mlir/lib/Transforms -Illvm-project/mlir/lib/Transforms -Iinclude -Illvm-project/llvm/include -Illvm-project/mlir/include -Itools/mlir/include -fPIC -fvisibility-inl
ines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT tools/mlir/lib/Transforms/CMakeFiles/MLIRTransforms.dir/AffineDataCopyGeneration.cpp.o -MF tools/mlir/lib/Transforms/CMakeFiles/MLIRTransforms.dir/AffineDataCopyGeneration.cpp.o.d -o tools/mlir/lib/Transforms/CMakeFiles/MLIRTransforms.dir/AffineDataCopyGeneration.cpp.o -c llvm-project/mlir/lib/Transforms/AffineDataCopyGeneration.cpp
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
3.      /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/unique_ptr.h:848:5: Generating code for declaration 'std::make_unique'
build_clang/bin/clang++(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x1a)[0x55796bf8436a]
build_clang/bin/clang++(_ZN4llvm3sys17RunSignalHandlersEv+0x34)[0x55796bf82204]
build_clang/bin/clang++(_ZN4llvm3sys15CleanupOnSignalEm+0xf8)[0x55796bf82708]
build_clang/bin/clang++(+0x1a58a08)[0x55796bf07a08]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13520)[0x7f1b727f7520]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x121)[0x7f1b722bd535]
/lib/x86_64-linux-gnu/libc.so.6(+0x2540f)[0x7f1b722bd40f]
/lib/x86_64-linux-gnu/libc.so.6(+0x32b92)[0x7f1b722cab92]
build_clang/bin/clang++(_ZN5clang7CodeGen15CodeGenFunction17EmitDeclRefLValueEPKNS_11DeclRefExprE+0x358)[0x55796c4cb138]
build_clang/bin/clang++(_ZN5clang7CodeGen15CodeGenFunction10EmitLValueEPKNS_4ExprE+0x2f9)[0x55796c4ca6d9]
build_clang/bin/clang++(_ZN5clang7CodeGen15CodeGenFunction14EmitCastLValueEPKNS_8CastExprE+0x103)[0x55796c4d4033]

Fixed by 62201763c54166a3ee5552975cc3fc06db2d5c6f

thakis added a subscriber: thakis.Mar 18 2020, 7:08 PM

Could you add a clang-side test for the check-mlir fix? Having to run mlir tests to verify clang changes seems suboptimal, so we should try to improve coverage of clang's tests.

Could you add a clang-side test for the check-mlir fix? Having to run mlir tests to verify clang changes seems suboptimal, so we should try to improve coverage of clang's tests.

sure. will do.

Could you add a clang-side test for the check-mlir fix? Having to run mlir tests to verify clang changes seems suboptimal, so we should try to improve coverage of clang's tests.

test added by b58f6bb1207521cdf6a856004525d7bffa5f2153