[PATCH] D53354: [WIP][NOT FOR COMMIT][PROTOTYPE] clang-scan-deps: dependency scanning tool rough prototype
whisperity added a comment. With regards to https://reviews.llvm.org/D53352: you can change the diff related to a patch whilst keeping discuccion and metadata of the diff. Please add a generic description to the diff for an easy skimming on what you are accomplishing. If I get this right, your tool will spit out a CPP file that is only include directives and perhaps the related conditional logic, or the final output of your tool is a file list? This is different than the `-M` flags in a way that it keeps conditions sane, rather than spitting out what includes were used if the input, with regards to the compiler options, was to be compiled? Have you checked the tool //Include What You Use//? I'm curious in what way the mishappenings of that tool present themselves in yours. There were some challenges not overcome in a good way in IWYU, their readme goes into a bit more detail on this. Repository: rC Clang https://reviews.llvm.org/D53354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344668 - NFC: Remove trailing space from CodeGenModule.cpp
Author: tikuta Date: Tue Oct 16 21:29:56 2018 New Revision: 344668 URL: http://llvm.org/viewvc/llvm-project?rev=344668=rev Log: NFC: Remove trailing space from CodeGenModule.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=344668=344667=344668=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Oct 16 21:29:56 2018 @@ -4106,17 +4106,17 @@ CodeGenModule::GetAddrOfConstantCFString llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty); llvm::Constant *Zeros[] = { Zero, Zero }; - + // If we don't already have it, get __CFConstantStringClassReference. if (!CFConstantStringClassRef) { llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy); Ty = llvm::ArrayType::get(Ty, 0); llvm::Constant *C = CreateRuntimeVariable(Ty, "__CFConstantStringClassReference"); - + if (getTriple().isOSBinFormatELF() || getTriple().isOSBinFormatCOFF()) { llvm::GlobalValue *GV = nullptr; - + if ((GV = dyn_cast(C))) { IdentifierInfo = getContext().Idents.get(GV->getName()); TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl(); @@ -4126,7 +4126,7 @@ CodeGenModule::GetAddrOfConstantCFString for (const auto : DC->lookup()) if ((VD = dyn_cast(Result))) break; - + if (getTriple().isOSBinFormatELF()) { if (!VD) GV->setLinkage(llvm::GlobalValue::ExternalLinkage); @@ -4140,11 +4140,11 @@ CodeGenModule::GetAddrOfConstantCFString GV->setLinkage(llvm::GlobalValue::ExternalLinkage); } } - + setDSOLocal(GV); } } - + // Decay array -> ptr CFConstantStringClassRef = llvm::ConstantExpr::getGetElementPtr(Ty, C, Zeros); @@ -4197,7 +4197,7 @@ CodeGenModule::GetAddrOfConstantCFString // the static linker to adjust permissions to read-only later on. else if (getTriple().isOSBinFormatELF()) GV->setSection(".rodata"); - + // String. llvm::Constant *Str = llvm::ConstantExpr::getGetElementPtr(GV->getValueType(), GV, Zeros); @@ -4876,7 +4876,7 @@ void CodeGenModule::EmitTopLevelDecl(Dec case Decl::OMPDeclareReduction: EmitOMPDeclareReduction(cast(D)); break; - + case Decl::OMPRequires: EmitOMPRequiresDecl(cast(D)); break; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53339: [clang-tidy] Add the abseil-duration-factory-float check
hwright added inline comments. Comment at: clang-tidy/abseil/DurationFactoryFloatCheck.cpp:27 + double value = FloatLiteral.getValueAsApproximateDouble(); + if (std::fmod(value, 1) == 0) { +bool is_negative = false; alexfh wrote: > Probably doesn't matter much, but would `std::modf` be more appropriate in > this context? I'm not actually sure. Since we're checking the remainder against `0`, we don't need to also separately get the integral part, since if the conditional passes, we know the original value //is// the integral part. It would seem that `std::modf` just adds more complexity. https://reviews.llvm.org/D53339 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53339: [clang-tidy] Add the abseil-duration-factory-float check
hwright updated this revision to Diff 169946. hwright marked 8 inline comments as done. hwright added a comment. Addressed review comments https://reviews.llvm.org/D53339 Files: clang-tidy/abseil/AbseilTidyModule.cpp clang-tidy/abseil/CMakeLists.txt clang-tidy/abseil/DurationFactoryFloatCheck.cpp clang-tidy/abseil/DurationFactoryFloatCheck.h docs/ReleaseNotes.rst docs/clang-tidy/checks/abseil-duration-factory-float.rst docs/clang-tidy/checks/list.rst test/clang-tidy/abseil-duration-factory-float.cpp Index: test/clang-tidy/abseil-duration-factory-float.cpp === --- /dev/null +++ test/clang-tidy/abseil-duration-factory-float.cpp @@ -0,0 +1,104 @@ +// RUN: %check_clang_tidy %s abseil-duration-factory-float %t + +// Mimic the implementation of absl::Duration +namespace absl { + +class Duration {}; + +Duration Nanoseconds(long long); +Duration Microseconds(long long); +Duration Milliseconds(long long); +Duration Seconds(long long); +Duration Minutes(long long); +Duration Hours(long long); + +#define GENERATE_DURATION_FACTORY_OVERLOADS(NAME) \ + Duration NAME(float n); \ + Duration NAME(double n);\ + template\ + Duration NAME(T n); + +GENERATE_DURATION_FACTORY_OVERLOADS(Nanoseconds); +GENERATE_DURATION_FACTORY_OVERLOADS(Microseconds); +GENERATE_DURATION_FACTORY_OVERLOADS(Milliseconds); +GENERATE_DURATION_FACTORY_OVERLOADS(Seconds); +GENERATE_DURATION_FACTORY_OVERLOADS(Minutes); +GENERATE_DURATION_FACTORY_OVERLOADS(Hours); +#undef GENERATE_DURATION_FACTORY_OVERLOADS + +} // namespace absl + +void ConvertFloatTest() { + absl::Duration d; + + d = absl::Seconds(60.0); + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Seconds [abseil-duration-factory-float] + // CHECK-FIXES: absl::Seconds(60); + d = absl::Minutes(300.0); + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Minutes [abseil-duration-factory-float] + // CHECK-FIXES: absl::Minutes(300); + + d = absl::Milliseconds(1e2); + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Milliseconds [abseil-duration-factory-float] + // CHECK-FIXES: absl::Milliseconds(100); + d = absl::Seconds(3.0f); + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Seconds [abseil-duration-factory-float] + // CHECK-FIXES: absl::Seconds(3); + d = absl::Seconds(3.); + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Seconds [abseil-duration-factory-float] + // CHECK-FIXES: absl::Seconds(3); + + // Ignored expressions + d = absl::Seconds(.001); + d = absl::Seconds(.100); + d = ::absl::Seconds(1); + d = ::absl::Minutes(1); + d = ::absl::Hours(1); + + // This is bigger than we can safely fit in a positive int32, so we ignore it. + d = absl::Seconds(1e12); + + int x; + d = absl::Seconds(x); + float y; + d = absl::Minutes(y); + +#define SECONDS(x) absl::Seconds(x) + SECONDS(60); +#undef SECONDS +#define THIRTY 30.0 + d = absl::Seconds(THIRTY); +#undef THIRTY +} + +template +void InTemplate() { + absl::Duration d; + + d = absl::Seconds(N); // 1 + // ^ No replacement here. + + d = absl::Minutes(1.0); // 2 + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Minutes [abseil-duration-factory-float] + // CHECK-FIXES: absl::Minutes(1); // 2 +} + +void Instantiate() { + InTemplate<60>(); + InTemplate<1>(); +} + +void ConvertStaticCastTest() { + absl::Duration d; + + d = absl::Seconds(static_cast(5)); + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Seconds [abseil-duration-factory-float] + // CHECK-FIXES: absl::Seconds(5); + + d = absl::Minutes(static_cast(5)); + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Minutes [abseil-duration-factory-float] + // CHECK-FIXES: absl::Minutes(5); + + // This should not be flagged + d = absl::Seconds(static_cast(5.0)); +} Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -5,12 +5,13 @@ .. toctree:: abseil-duration-division + abseil-duration-factory-float abseil-faster-strsplit-delimiter abseil-no-internal-dependencies abseil-no-namespace abseil-redundant-strcat-calls - abseil-string-find-startswith abseil-str-cat-append + abseil-string-find-startswith android-cloexec-accept android-cloexec-accept4 android-cloexec-creat Index: docs/clang-tidy/checks/abseil-duration-factory-float.rst === --- /dev/null +++ docs/clang-tidy/checks/abseil-duration-factory-float.rst @@ -0,0 +1,29 @@ +.. title:: clang-tidy - abseil-duration-factory-float + +abseil-duration-factory-float += + +Finds cases where callers of
[PATCH] D53326: [python] [tests] Disable on known-broken arches
mgorny added a comment. Thanks for the review. I'm going to be away most of the day today, so if it breaks something (worse), feel free to revert. Repository: rL LLVM https://reviews.llvm.org/D53326 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53326: [python] [tests] Disable on known-broken arches
This revision was automatically updated to reflect the committed changes. Closed by commit rL344666: [python] [tests] Disable on known-broken arches (authored by mgorny, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D53326?vs=169832=169944#toc Repository: rL LLVM https://reviews.llvm.org/D53326 Files: cfe/trunk/bindings/python/tests/CMakeLists.txt Index: cfe/trunk/bindings/python/tests/CMakeLists.txt === --- cfe/trunk/bindings/python/tests/CMakeLists.txt +++ cfe/trunk/bindings/python/tests/CMakeLists.txt @@ -7,24 +7,34 @@ DEPENDS libclang WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) -# Check if we are building with ASan -list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) -if (LLVM_USE_ASAN_INDEX EQUAL -1) - set(LLVM_USE_ASAN FALSE) -else() - set(LLVM_USE_ASAN TRUE) -endif() +set(RUN_PYTHON_TESTS TRUE) -# Tests fail on Windows, and need someone knowledgeable to fix. -# It's not clear whether it's a test or a valid binding problem. -# # Do not try to run if libclang was built with ASan because # the sanitizer library will likely be loaded too late to perform # interception and will then fail. # We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't # portable so its easier just to not run the tests when building # with ASan. -if((NOT WIN32) AND (NOT LLVM_USE_ASAN)) +list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) +if(NOT LLVM_USE_ASAN_INDEX EQUAL -1) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# Tests fail on Windows, and need someone knowledgeable to fix. +# It's not clear whether it's a test or a valid binding problem. +if(WIN32) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# AArch64 and Hexagon have known test failures that need to be +# addressed. +# SystemZ has broken Python/FFI interface: +# https://reviews.llvm.org/D52840#1265716 +if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$") + set(RUN_PYTHON_TESTS FALSE) +endif() + +if(RUN_PYTHON_TESTS) set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) endif() Index: cfe/trunk/bindings/python/tests/CMakeLists.txt === --- cfe/trunk/bindings/python/tests/CMakeLists.txt +++ cfe/trunk/bindings/python/tests/CMakeLists.txt @@ -7,24 +7,34 @@ DEPENDS libclang WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) -# Check if we are building with ASan -list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) -if (LLVM_USE_ASAN_INDEX EQUAL -1) - set(LLVM_USE_ASAN FALSE) -else() - set(LLVM_USE_ASAN TRUE) -endif() +set(RUN_PYTHON_TESTS TRUE) -# Tests fail on Windows, and need someone knowledgeable to fix. -# It's not clear whether it's a test or a valid binding problem. -# # Do not try to run if libclang was built with ASan because # the sanitizer library will likely be loaded too late to perform # interception and will then fail. # We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't # portable so its easier just to not run the tests when building # with ASan. -if((NOT WIN32) AND (NOT LLVM_USE_ASAN)) +list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) +if(NOT LLVM_USE_ASAN_INDEX EQUAL -1) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# Tests fail on Windows, and need someone knowledgeable to fix. +# It's not clear whether it's a test or a valid binding problem. +if(WIN32) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# AArch64 and Hexagon have known test failures that need to be +# addressed. +# SystemZ has broken Python/FFI interface: +# https://reviews.llvm.org/D52840#1265716 +if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$") + set(RUN_PYTHON_TESTS FALSE) +endif() + +if(RUN_PYTHON_TESTS) set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53326: [python] [tests] Disable on known-broken arches
This revision was automatically updated to reflect the committed changes. Closed by commit rC344666: [python] [tests] Disable on known-broken arches (authored by mgorny, committed by ). Repository: rC Clang https://reviews.llvm.org/D53326 Files: bindings/python/tests/CMakeLists.txt Index: bindings/python/tests/CMakeLists.txt === --- bindings/python/tests/CMakeLists.txt +++ bindings/python/tests/CMakeLists.txt @@ -7,24 +7,34 @@ DEPENDS libclang WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) -# Check if we are building with ASan -list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) -if (LLVM_USE_ASAN_INDEX EQUAL -1) - set(LLVM_USE_ASAN FALSE) -else() - set(LLVM_USE_ASAN TRUE) -endif() +set(RUN_PYTHON_TESTS TRUE) -# Tests fail on Windows, and need someone knowledgeable to fix. -# It's not clear whether it's a test or a valid binding problem. -# # Do not try to run if libclang was built with ASan because # the sanitizer library will likely be loaded too late to perform # interception and will then fail. # We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't # portable so its easier just to not run the tests when building # with ASan. -if((NOT WIN32) AND (NOT LLVM_USE_ASAN)) +list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) +if(NOT LLVM_USE_ASAN_INDEX EQUAL -1) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# Tests fail on Windows, and need someone knowledgeable to fix. +# It's not clear whether it's a test or a valid binding problem. +if(WIN32) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# AArch64 and Hexagon have known test failures that need to be +# addressed. +# SystemZ has broken Python/FFI interface: +# https://reviews.llvm.org/D52840#1265716 +if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$") + set(RUN_PYTHON_TESTS FALSE) +endif() + +if(RUN_PYTHON_TESTS) set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) endif() Index: bindings/python/tests/CMakeLists.txt === --- bindings/python/tests/CMakeLists.txt +++ bindings/python/tests/CMakeLists.txt @@ -7,24 +7,34 @@ DEPENDS libclang WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) -# Check if we are building with ASan -list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) -if (LLVM_USE_ASAN_INDEX EQUAL -1) - set(LLVM_USE_ASAN FALSE) -else() - set(LLVM_USE_ASAN TRUE) -endif() +set(RUN_PYTHON_TESTS TRUE) -# Tests fail on Windows, and need someone knowledgeable to fix. -# It's not clear whether it's a test or a valid binding problem. -# # Do not try to run if libclang was built with ASan because # the sanitizer library will likely be loaded too late to perform # interception and will then fail. # We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't # portable so its easier just to not run the tests when building # with ASan. -if((NOT WIN32) AND (NOT LLVM_USE_ASAN)) +list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) +if(NOT LLVM_USE_ASAN_INDEX EQUAL -1) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# Tests fail on Windows, and need someone knowledgeable to fix. +# It's not clear whether it's a test or a valid binding problem. +if(WIN32) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# AArch64 and Hexagon have known test failures that need to be +# addressed. +# SystemZ has broken Python/FFI interface: +# https://reviews.llvm.org/D52840#1265716 +if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$") + set(RUN_PYTHON_TESTS FALSE) +endif() + +if(RUN_PYTHON_TESTS) set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344666 - [python] [tests] Disable on known-broken arches
Author: mgorny Date: Tue Oct 16 20:05:39 2018 New Revision: 344666 URL: http://llvm.org/viewvc/llvm-project?rev=344666=rev Log: [python] [tests] Disable on known-broken arches Disable the Python binding tests on AArch64, Hexagon and SystemZ following reports on test failures. The first two yield different results, possibly indicating test case problems. The last one seems to have broken FFI in Python. While at it, refactor the code to make adding future test restrictions easier. Differential Revision: https://reviews.llvm.org/D53326 Modified: cfe/trunk/bindings/python/tests/CMakeLists.txt Modified: cfe/trunk/bindings/python/tests/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/CMakeLists.txt?rev=344666=344665=344666=diff == --- cfe/trunk/bindings/python/tests/CMakeLists.txt (original) +++ cfe/trunk/bindings/python/tests/CMakeLists.txt Tue Oct 16 20:05:39 2018 @@ -7,24 +7,34 @@ add_custom_target(check-clang-python DEPENDS libclang WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) -# Check if we are building with ASan -list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) -if (LLVM_USE_ASAN_INDEX EQUAL -1) - set(LLVM_USE_ASAN FALSE) -else() - set(LLVM_USE_ASAN TRUE) -endif() +set(RUN_PYTHON_TESTS TRUE) -# Tests fail on Windows, and need someone knowledgeable to fix. -# It's not clear whether it's a test or a valid binding problem. -# # Do not try to run if libclang was built with ASan because # the sanitizer library will likely be loaded too late to perform # interception and will then fail. # We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't # portable so its easier just to not run the tests when building # with ASan. -if((NOT WIN32) AND (NOT LLVM_USE_ASAN)) +list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) +if(NOT LLVM_USE_ASAN_INDEX EQUAL -1) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# Tests fail on Windows, and need someone knowledgeable to fix. +# It's not clear whether it's a test or a valid binding problem. +if(WIN32) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# AArch64 and Hexagon have known test failures that need to be +# addressed. +# SystemZ has broken Python/FFI interface: +# https://reviews.llvm.org/D52840#1265716 +if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$") + set(RUN_PYTHON_TESTS FALSE) +endif() + +if(RUN_PYTHON_TESTS) set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344665 - AMDGPU: add __builtin_amdgcn_update_dpp
Author: yaxunl Date: Tue Oct 16 19:32:26 2018 New Revision: 344665 URL: http://llvm.org/viewvc/llvm-project?rev=344665=rev Log: AMDGPU: add __builtin_amdgcn_update_dpp Emit llvm.amdgcn.update.dpp for both __builtin_amdgcn_mov_dpp and __builtin_amdgcn_update_dpp. The first argument to llvm.amdgcn.update.dpp will be undef for __builtin_amdgcn_mov_dpp. Differential Revision: https://reviews.llvm.org/D52320 Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=344665=344664=344665=diff == --- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Tue Oct 16 19:32:26 2018 @@ -122,6 +122,7 @@ TARGET_BUILTIN(__builtin_amdgcn_fracth, TARGET_BUILTIN(__builtin_amdgcn_classh, "bhi", "nc", "16-bit-insts") TARGET_BUILTIN(__builtin_amdgcn_s_memrealtime, "LUi", "n", "s-memrealtime") TARGET_BUILTIN(__builtin_amdgcn_mov_dpp, "iiIiIiIiIb", "nc", "dpp") +TARGET_BUILTIN(__builtin_amdgcn_update_dpp, "iiiIiIiIiIb", "nc", "dpp") TARGET_BUILTIN(__builtin_amdgcn_s_dcache_wb, "v", "n", "vi-insts") //===--===// Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=344665=344664=344665=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Oct 16 19:32:26 2018 @@ -11347,12 +11347,16 @@ Value *CodeGenFunction::EmitAMDGPUBuilti case AMDGPU::BI__builtin_amdgcn_ds_swizzle: return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_ds_swizzle); - case AMDGPU::BI__builtin_amdgcn_mov_dpp: { -llvm::SmallVector Args; -for (unsigned I = 0; I != 5; ++I) + case AMDGPU::BI__builtin_amdgcn_mov_dpp: + case AMDGPU::BI__builtin_amdgcn_update_dpp: { +llvm::SmallVector Args; +for (unsigned I = 0; I != E->getNumArgs(); ++I) Args.push_back(EmitScalarExpr(E->getArg(I))); -Value *F = CGM.getIntrinsic(Intrinsic::amdgcn_mov_dpp, -Args[0]->getType()); +assert(Args.size() == 5 || Args.size() == 6); +if (Args.size() == 5) + Args.insert(Args.begin(), llvm::UndefValue::get(Args[0]->getType())); +Value *F = +CGM.getIntrinsic(Intrinsic::amdgcn_update_dpp, Args[0]->getType()); return Builder.CreateCall(F, Args); } case AMDGPU::BI__builtin_amdgcn_div_fixup: Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl?rev=344665=344664=344665=diff == --- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl Tue Oct 16 19:32:26 2018 @@ -90,12 +90,19 @@ void test_s_dcache_wb() } // CHECK-LABEL: @test_mov_dpp -// CHECK: call i32 @llvm.amdgcn.mov.dpp.i32(i32 %src, i32 0, i32 0, i32 0, i1 false) +// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 undef, i32 %src, i32 0, i32 0, i32 0, i1 false) void test_mov_dpp(global int* out, int src) { *out = __builtin_amdgcn_mov_dpp(src, 0, 0, 0, false); } +// CHECK-LABEL: @test_update_dpp +// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 %arg1, i32 %arg2, i32 0, i32 0, i32 0, i1 false) +void test_update_dpp(global int* out, int arg1, int arg2) +{ + *out = __builtin_amdgcn_update_dpp(arg1, arg2, 0, 0, 0, false); +} + // CHECK-LABEL: @test_ds_fadd // CHECK: call float @llvm.amdgcn.ds.fadd(float addrspace(3)* %out, float %src, i32 0, i32 0, i1 false) void test_ds_faddf(local float *out, float src) { Modified: cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl?rev=344665=344664=344665=diff == --- cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl (original) +++ cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl Tue Oct 16 19:32:26 2018 @@ -102,6 +102,15 @@ void test_mov_dpp2(global int* out, int *out = __builtin_amdgcn_mov_dpp(a, 0, 0, 0, e); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}} } +void test_update_dpp2(global int* out, int a, int b, int c, int d, int e, bool f) +{ + *out = __builtin_amdgcn_update_dpp(a, b, 0, 0, 0, false); + *out = __builtin_amdgcn_update_dpp(a, 0, c, 0, 0, false); // expected-error {{argument to '__builtin_amdgcn_update_dpp'
[PATCH] D52320: AMDGPU: add __builtin_amdgcn_update_dpp
This revision was automatically updated to reflect the committed changes. Closed by commit rC344665: AMDGPU: add __builtin_amdgcn_update_dpp (authored by yaxunl, committed by ). Changed prior to commit: https://reviews.llvm.org/D52320?vs=169882=169942#toc Repository: rC Clang https://reviews.llvm.org/D52320 Files: include/clang/Basic/BuiltinsAMDGPU.def lib/CodeGen/CGBuiltin.cpp test/CodeGenOpenCL/builtins-amdgcn-vi.cl test/SemaOpenCL/builtins-amdgcn-error.cl Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -11347,12 +11347,16 @@ case AMDGPU::BI__builtin_amdgcn_ds_swizzle: return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_ds_swizzle); - case AMDGPU::BI__builtin_amdgcn_mov_dpp: { -llvm::SmallVector Args; -for (unsigned I = 0; I != 5; ++I) + case AMDGPU::BI__builtin_amdgcn_mov_dpp: + case AMDGPU::BI__builtin_amdgcn_update_dpp: { +llvm::SmallVector Args; +for (unsigned I = 0; I != E->getNumArgs(); ++I) Args.push_back(EmitScalarExpr(E->getArg(I))); -Value *F = CGM.getIntrinsic(Intrinsic::amdgcn_mov_dpp, -Args[0]->getType()); +assert(Args.size() == 5 || Args.size() == 6); +if (Args.size() == 5) + Args.insert(Args.begin(), llvm::UndefValue::get(Args[0]->getType())); +Value *F = +CGM.getIntrinsic(Intrinsic::amdgcn_update_dpp, Args[0]->getType()); return Builder.CreateCall(F, Args); } case AMDGPU::BI__builtin_amdgcn_div_fixup: Index: include/clang/Basic/BuiltinsAMDGPU.def === --- include/clang/Basic/BuiltinsAMDGPU.def +++ include/clang/Basic/BuiltinsAMDGPU.def @@ -122,6 +122,7 @@ TARGET_BUILTIN(__builtin_amdgcn_classh, "bhi", "nc", "16-bit-insts") TARGET_BUILTIN(__builtin_amdgcn_s_memrealtime, "LUi", "n", "s-memrealtime") TARGET_BUILTIN(__builtin_amdgcn_mov_dpp, "iiIiIiIiIb", "nc", "dpp") +TARGET_BUILTIN(__builtin_amdgcn_update_dpp, "iiiIiIiIiIb", "nc", "dpp") TARGET_BUILTIN(__builtin_amdgcn_s_dcache_wb, "v", "n", "vi-insts") //===--===// Index: test/SemaOpenCL/builtins-amdgcn-error.cl === --- test/SemaOpenCL/builtins-amdgcn-error.cl +++ test/SemaOpenCL/builtins-amdgcn-error.cl @@ -102,6 +102,15 @@ *out = __builtin_amdgcn_mov_dpp(a, 0, 0, 0, e); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}} } +void test_update_dpp2(global int* out, int a, int b, int c, int d, int e, bool f) +{ + *out = __builtin_amdgcn_update_dpp(a, b, 0, 0, 0, false); + *out = __builtin_amdgcn_update_dpp(a, 0, c, 0, 0, false); // expected-error {{argument to '__builtin_amdgcn_update_dpp' must be a constant integer}} + *out = __builtin_amdgcn_update_dpp(a, 0, 0, d, 0, false); // expected-error {{argument to '__builtin_amdgcn_update_dpp' must be a constant integer}} + *out = __builtin_amdgcn_update_dpp(a, 0, 0, 0, e, false); // expected-error {{argument to '__builtin_amdgcn_update_dpp' must be a constant integer}} + *out = __builtin_amdgcn_update_dpp(a, 0, 0, 0, 0, f); // expected-error {{argument to '__builtin_amdgcn_update_dpp' must be a constant integer}} +} + void test_ds_faddf(local float *out, float src, int a) { *out = __builtin_amdgcn_ds_faddf(out, src, a, 0, false); // expected-error {{argument to '__builtin_amdgcn_ds_faddf' must be a constant integer}} *out = __builtin_amdgcn_ds_faddf(out, src, 0, a, false); // expected-error {{argument to '__builtin_amdgcn_ds_faddf' must be a constant integer}} Index: test/CodeGenOpenCL/builtins-amdgcn-vi.cl === --- test/CodeGenOpenCL/builtins-amdgcn-vi.cl +++ test/CodeGenOpenCL/builtins-amdgcn-vi.cl @@ -90,12 +90,19 @@ } // CHECK-LABEL: @test_mov_dpp -// CHECK: call i32 @llvm.amdgcn.mov.dpp.i32(i32 %src, i32 0, i32 0, i32 0, i1 false) +// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 undef, i32 %src, i32 0, i32 0, i32 0, i1 false) void test_mov_dpp(global int* out, int src) { *out = __builtin_amdgcn_mov_dpp(src, 0, 0, 0, false); } +// CHECK-LABEL: @test_update_dpp +// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 %arg1, i32 %arg2, i32 0, i32 0, i32 0, i1 false) +void test_update_dpp(global int* out, int arg1, int arg2) +{ + *out = __builtin_amdgcn_update_dpp(arg1, arg2, 0, 0, 0, false); +} + // CHECK-LABEL: @test_ds_fadd // CHECK: call float @llvm.amdgcn.ds.fadd(float addrspace(3)* %out, float %src, i32 0, i32 0, i1 false) void test_ds_faddf(local float *out, float src) { Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -11347,12 +11347,16 @@ case AMDGPU::BI__builtin_amdgcn_ds_swizzle:
[PATCH] D53348: [AArch64] Define __ELF__ for aarch64-none-elf and other similar triples.
t.p.northover accepted this revision. t.p.northover added a comment. This revision is now accepted and ready to land. Looks reasonable. Repository: rC Clang https://reviews.llvm.org/D53348 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53025: [clang-tidy] implement new check for const return types.
ymandel added inline comments. Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:93 +Diagnostics << FixItHint::CreateRemoval( +CharSourceRange::getTokenRange(*PrevLoc, *PrevLoc)); + } else { JonasToth wrote: > ymandel wrote: > > JonasToth wrote: > > > Twice `*PrevLoc`? > > Is there a better alternative? I thought that, since token ranges closed on > > both ends, this constructs a SourceRange that spans the single token at > > PrevLoc. Instead, I could rework `getConstTokLocations` to return the > > actual tokens instead, and then create CharSourceRanges from > > Tok.getLocation(), Tok.getLastLocation(). > The Fixits work with sourcelocations, you dont need to get the tokenrange and > CharSourceRange things. This looks more complicated then necessary to me. > Your `findConstToRemove` can return a `Optional` that encloses > the `const` token. This range can then be used for the FixIts. I think this > would make the code a bit clearer as well. After reworking to pipe the Token all the way through to the use, I ended up sticking with CharSourceRange::getCharRange(), because otherwise the fixithint will convert a plain SourceRange into a token range, which is not what we want (since we already have the lower-level char range from the lexed token). Comment at: clang-tidy/utils/LexerUtils.cpp:41 + const char *TokenBegin = File.data() + LocInfo.second; + Lexer RawLexer(SM.getLocForStartOfFile(LocInfo.first), Context.getLangOpts(), + File.begin(), TokenBegin, File.end()); JonasToth wrote: > I think this function can be simplified as the manual lexing stuff seems > unnecessary. > Take a look at https://reviews.llvm.org/D51949#change-B_4XlTym3KPw that uses > `clang::Lexer` functionality quite a bit to do manual lexing. > > You can use the public static methods from `clang::Lexer` to simplify this > function. (FWIW, this code was taken (almost directly) from clang-tidy/readability/AvoidConstParamsInDecls.cpp.) I agree that would potentially simplify the code here, but I'm not sure its the right thing to do. Basically all of the relevant functions create a clang::Lexer internally and do a bunch more work. So, it seems like this case, where we are incrementally proceeding through a source, token by token, we really should be using a (stateful) clang::Lexer directly, rather than repeatedly calling into the static methods and creating/destroying a Lexer with each such call. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53025 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53025: [clang-tidy] implement new check for const return types.
ymandel updated this revision to Diff 169941. ymandel added a comment. Changed check result into struct (was pair). Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53025 Files: clang-tidy/readability/CMakeLists.txt clang-tidy/readability/ConstValueReturnCheck.cpp clang-tidy/readability/ConstValueReturnCheck.h clang-tidy/readability/ReadabilityTidyModule.cpp clang-tidy/utils/LexerUtils.cpp clang-tidy/utils/LexerUtils.h docs/ReleaseNotes.rst docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/readability-const-value-return.rst test/clang-tidy/readability-const-value-return.cpp Index: test/clang-tidy/readability-const-value-return.cpp === --- /dev/null +++ test/clang-tidy/readability-const-value-return.cpp @@ -0,0 +1,174 @@ +// RUN: %check_clang_tidy %s readability-const-value-return %t + +// p# = positive test +// n# = negative test + +const int p1() { +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qualified hindering compiler optimizations +// CHECK-FIXES: int p1() { + return 1; +} + +const int p15(); +// CHECK-FIXES: int p15(); + +template class Klazz {}; +class Clazz { + public: + Clazz *const p2() { +// CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'Clazz *const' is 'co +// CHECK-FIXES: Clazz *p2() { +return this; + } + + Clazz *const p3(); + // CHECK-FIXES: Clazz *p3(); + + const int p4() const { +// CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 'const +// CHECK-FIXES: int p4() const { +return 4; + } + + const Klazz* const p5() const; + // CHECK-FIXES: const Klazz* p5() const; + + const Clazz operator++(int x) { // p12 + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const Clazz' is 'const + // CHECK-FIXES: Clazz operator++(int x) { + } + + struct Strukt { +int i; + }; + + const Strukt p6() {} + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const Clazz::Strukt' i + // CHECK-FIXES: Strukt p6() {} + + // No warning is emitted here, because this is only the declaration. The + // warning will be associated with the definition, below. + const Strukt* const p7(); + // CHECK-FIXES: const Strukt* p7(); + + static const int p8() {} + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 'const'- + // CHECK-FIXES: static int p8() {} + + static const Strukt p9() {} + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const Clazz::Strukt' i + // CHECK-FIXES: static Strukt p9() {} + + int n0() const { return 0; } + const Klazz& n11(const Klazz) const; +}; + +Clazz *const Clazz::p3() { + // CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'Clazz *const' is 'cons + // CHECK-FIXES: Clazz *Clazz::p3() { + return this; +} + +const Klazz* const Clazz::p5() const {} +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz * +// CHECK-FIXES: const Klazz* Clazz::p5() const {} + +const Clazz::Strukt* const Clazz::p7() {} +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Clazz::Strukt *con +// CHECK-FIXES: const Clazz::Strukt* Clazz::p7() {} + +Clazz *const p10(); +// CHECK-FIXES: Clazz *p10(); + +Clazz *const p10() { + // CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'Clazz *const' is 'cons + // CHECK-FIXES: Clazz *p10() { + return new Clazz(); +} + +const Clazz bar; +const Clazz *const p11() { + // CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Clazz *const' is + // CHECK-FIXES: const Clazz *p11() { + return +} + +const Klazz p12() {} +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz' +// CHECK-FIXES: Klazz p12() {} + +const Klazz* const p13() {} +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz * +// CHECK-FIXES: const Klazz* p13() {} + +// re-declaration of p15. +const int p15(); +// CHECK-FIXES: int p15(); + +const int p15() { +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: +// CHECK-FIXES: int p15() { + return 0; +} + +// Exercise the lexer. + +const /* comment */ /* another comment*/ int p16() { return 0; } +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: +// CHECK-FIXES: /* comment */ /* another comment*/ int p16() { return 0; } + +/* comment */ const +// CHECK-MESSAGES: [[@LINE-1]]:15: warning: +// CHECK-FIXES: /* comment */ +// more +/* another comment*/ int p17() { return 0; } + +// Test cases where the `const` token lexically is hidden behind some form of +// indirection. + +#define CONSTINT const int +CONSTINT p18() {} +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu + +#define CONST const +CONST int p19() {} +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu + +using ty = const int; +ty p21() {} +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'ty' (aka 'const int') is + +typedef const int ty2; +ty2 p22() {} +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'ty2' (aka 'const int') i +
[PATCH] D52973: Add type_info predefined decl
mwasplund added inline comments. Comment at: lib/Sema/SemaDecl.cpp:1467-1470 + // FIXME: The Modules TS does not specify how to handle inplicit types + // For now we will simply ignore the implicit global types + if (Old->isImplicit()) +return false; rsmith wrote: > Rather than doing this, please change `ASTContext::buildImplicitRecord` to > `setModuleOwnershipKind(Decl::ModuleOwnershipKind::Unowned)` on the created > declaration. That doesn't seem to work. The check still fails since the owning module is now null. I can fix that by ignoring decls that have no owner on the old version, but I am also running into issues where the cached linkage no longer matches up. Repository: rC Clang https://reviews.llvm.org/D52973 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53069: [analyzer][www] Update avaible_checks.html
george.karpenkov added a comment. Herald added a subscriber: dkrupp. @Szelethus Also you have without a doubt noticed that a "Download" section on the index page could be improved :P https://reviews.llvm.org/D53069 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53025: [clang-tidy] implement new check for const return types.
ymandel updated this revision to Diff 169938. ymandel marked 5 inline comments as done. ymandel added a comment. Refactors generation of clang-tidy fixits and notes. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53025 Files: clang-tidy/readability/CMakeLists.txt clang-tidy/readability/ConstValueReturnCheck.cpp clang-tidy/readability/ConstValueReturnCheck.h clang-tidy/readability/ReadabilityTidyModule.cpp clang-tidy/utils/LexerUtils.cpp clang-tidy/utils/LexerUtils.h docs/ReleaseNotes.rst docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/readability-const-value-return.rst test/clang-tidy/readability-const-value-return.cpp Index: test/clang-tidy/readability-const-value-return.cpp === --- /dev/null +++ test/clang-tidy/readability-const-value-return.cpp @@ -0,0 +1,174 @@ +// RUN: %check_clang_tidy %s readability-const-value-return %t + +// p# = positive test +// n# = negative test + +const int p1() { +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qualified hindering compiler optimizations +// CHECK-FIXES: int p1() { + return 1; +} + +const int p15(); +// CHECK-FIXES: int p15(); + +template class Klazz {}; +class Clazz { + public: + Clazz *const p2() { +// CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'Clazz *const' is 'co +// CHECK-FIXES: Clazz *p2() { +return this; + } + + Clazz *const p3(); + // CHECK-FIXES: Clazz *p3(); + + const int p4() const { +// CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 'const +// CHECK-FIXES: int p4() const { +return 4; + } + + const Klazz* const p5() const; + // CHECK-FIXES: const Klazz* p5() const; + + const Clazz operator++(int x) { // p12 + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const Clazz' is 'const + // CHECK-FIXES: Clazz operator++(int x) { + } + + struct Strukt { +int i; + }; + + const Strukt p6() {} + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const Clazz::Strukt' i + // CHECK-FIXES: Strukt p6() {} + + // No warning is emitted here, because this is only the declaration. The + // warning will be associated with the definition, below. + const Strukt* const p7(); + // CHECK-FIXES: const Strukt* p7(); + + static const int p8() {} + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 'const'- + // CHECK-FIXES: static int p8() {} + + static const Strukt p9() {} + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const Clazz::Strukt' i + // CHECK-FIXES: static Strukt p9() {} + + int n0() const { return 0; } + const Klazz& n11(const Klazz) const; +}; + +Clazz *const Clazz::p3() { + // CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'Clazz *const' is 'cons + // CHECK-FIXES: Clazz *Clazz::p3() { + return this; +} + +const Klazz* const Clazz::p5() const {} +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz * +// CHECK-FIXES: const Klazz* Clazz::p5() const {} + +const Clazz::Strukt* const Clazz::p7() {} +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Clazz::Strukt *con +// CHECK-FIXES: const Clazz::Strukt* Clazz::p7() {} + +Clazz *const p10(); +// CHECK-FIXES: Clazz *p10(); + +Clazz *const p10() { + // CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'Clazz *const' is 'cons + // CHECK-FIXES: Clazz *p10() { + return new Clazz(); +} + +const Clazz bar; +const Clazz *const p11() { + // CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Clazz *const' is + // CHECK-FIXES: const Clazz *p11() { + return +} + +const Klazz p12() {} +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz' +// CHECK-FIXES: Klazz p12() {} + +const Klazz* const p13() {} +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz * +// CHECK-FIXES: const Klazz* p13() {} + +// re-declaration of p15. +const int p15(); +// CHECK-FIXES: int p15(); + +const int p15() { +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: +// CHECK-FIXES: int p15() { + return 0; +} + +// Exercise the lexer. + +const /* comment */ /* another comment*/ int p16() { return 0; } +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: +// CHECK-FIXES: /* comment */ /* another comment*/ int p16() { return 0; } + +/* comment */ const +// CHECK-MESSAGES: [[@LINE-1]]:15: warning: +// CHECK-FIXES: /* comment */ +// more +/* another comment*/ int p17() { return 0; } + +// Test cases where the `const` token lexically is hidden behind some form of +// indirection. + +#define CONSTINT const int +CONSTINT p18() {} +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu + +#define CONST const +CONST int p19() {} +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu + +using ty = const int; +ty p21() {} +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'ty' (aka 'const int') is + +typedef const int ty2; +ty2 p22() {} +// CHECK-MESSAGES: [[@LINE-1]]:1:
r344664 - [analyzer] [www] Minor improvements to the text in open_projects
Author: george.karpenkov Date: Tue Oct 16 18:15:53 2018 New Revision: 344664 URL: http://llvm.org/viewvc/llvm-project?rev=344664=rev Log: [analyzer] [www] Minor improvements to the text in open_projects Modified: cfe/trunk/www/analyzer/open_projects.html Modified: cfe/trunk/www/analyzer/open_projects.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/open_projects.html?rev=344664=344663=344664=diff == --- cfe/trunk/www/analyzer/open_projects.html (original) +++ cfe/trunk/www/analyzer/open_projects.html Tue Oct 16 18:15:53 2018 @@ -27,17 +27,14 @@ mailing list to notify other members New checkers which were contributed to the analyzer, but have not passed a rigorous evaluation process, are committed as "alpha checkers" (from "alpha version"), -and are not enabled by default. +and are not enabled by default. -Ideally, only the checkers which are actively being worked on should be in +Ideally, only the checkers which are actively being worked on should be in "alpha", but over the years the development of many of those has stalled. -Such checkers need a cleanup: -checkers which have been there for a long time should either -be improved up to a point where they can be enabled by default, -or removed, if such an improvement is not possible. -Most notably, these checkers could be "graduated" out of alpha -if a consistent effort is applied: +Such checkers should either be improved +up to a point where they can be enabled by default, +or removed from the analyzer entirely. alpha.security.ArrayBound and @@ -48,7 +45,7 @@ mailing list to notify other members https://en.wikipedia.org/wiki/Widening_(computer_science)">loop widening support. Additionally, it might be more promising to perform index checking based on https://en.wikipedia.org/wiki/Taint_checking;>tainted index values. - (Difficulty: Medium) + (Difficulty: Medium) alpha.cplusplus.MisusedMovedObject @@ -58,7 +55,7 @@ mailing list to notify other members which have a well-defined semantics for use-after-move. This property does not hold for STL objects, but is often the case for custom containers. - (Difficulty: Medium) + (Difficulty: Medium) alpha.unix.StreamChecker @@ -79,7 +76,7 @@ mailing list to notify other members - Improved C++ support + Improve C++ support Handle aggregate construction. https://en.cppreference.com/w/cpp/language/aggregate_initialization;>Aggregates @@ -99,7 +96,7 @@ mailing list to notify other members CXXConstructExpr::CK_NonVirtualBase branch of ExprEngine::VisitCXXConstructExpr() with proper support for the feature. - (Difficulty: Medium) + (Difficulty: Medium) Handle constructors within new[] @@ -139,14 +136,14 @@ mailing list to notify other members large gains can be achieved by supporting only a few cases: e.g. calling .length() on an empty std::string always yields zero. -(Difficulty: Medium) +(Difficulty: Medium) Enhance CFG to model exception-handling. Currently exceptions are treated as "black holes", and exception-handling control structures are poorly modeled in order to be conservative. This could be improved for both C++ and Objective-C exceptions. - (Difficulty: Medium) + (Difficulty: Hard) @@ -159,7 +156,7 @@ mailing list to notify other members This problem was previously http://lists.llvm.org/pipermail/cfe-dev/2017-March/052864.html;>discussed on the mailing list, but no solution was implemented. - (Difficulty: Medium) + (Difficulty: Medium) Floating-point support. @@ -169,7 +166,7 @@ mailing list to notify other members and auditing existing code to make sure it doesn't make incorrect assumptions (most notably, that X == X is always true, since it does not hold for NaN). - (Difficulty: Medium) + (Difficulty: Medium) Improved loop execution modeling. @@ -183,7 +180,7 @@ mailing list to notify other members but the https://en.wikipedia.org/wiki/Widening_(computer_science)">widening problem still remains open. - (Difficulty: Hard) + (Difficulty: Hard) Basic function summarization support @@ -195,7 +192,7 @@ mailing list to notify other members enough to be a large improvement over conservative evaluation. Such summaries could be obtained either syntactically, or using a dataflow framework. - (Difficulty: Hard) + (Difficulty: Hard) Implement a dataflow flamework. @@ -213,7 +210,7 @@ mailing list to notify other members a few dataflow analyses (most notably, liveness),
[PATCH] D53024: [analyzer][www] Add more open projects
This revision was automatically updated to reflect the committed changes. Closed by commit rC344663: [analyzer] [www] Updated a list of open projects (authored by george.karpenkov, committed by ). Changed prior to commit: https://reviews.llvm.org/D53024?vs=169920=169933#toc Repository: rC Clang https://reviews.llvm.org/D53024 Files: www/analyzer/open_projects.html Index: www/analyzer/open_projects.html === --- www/analyzer/open_projects.html +++ www/analyzer/open_projects.html @@ -22,162 +22,219 @@ to the http://lists.llvm.org/mailman/listinfo/cfe-dev>cfe-dev mailing list to notify other members of the community. - - Core Analyzer Infrastructure - -Explicitly model standard library functions with BodyFarm. -http://clang.llvm.org/doxygen/classclang_1_1BodyFarm.html;>BodyFarm -allows the analyzer to explicitly model functions whose definitions are -not available during analysis. Modeling more of the widely used functions -(such as the members of std::string) will improve precision of the -analysis. -(Difficulty: Easy, ongoing) - - -Handle floating-point values. -Currently, the analyzer treats all floating-point values as unknown. -However, we already have most of the infrastructure we need to handle -floats: RangeConstraintManager. This would involve adding a new SVal kind -for constant floats, generalizing the constraint manager to handle floats -and integers equally, and auditing existing code to make sure it doesn't -make untoward assumptions. - (Difficulty: Medium) - - -Implement generalized loop execution modeling. -Currently, the analyzer simply unrolls each loop N times. This -means that it will not execute any code after the loop if the loop is -guaranteed to execute more than N times. This results in lost -basic block coverage. We could continue exploring the path if we could -model a generic i-th iteration of a loop. - (Difficulty: Hard) - - -Enhance CFG to model C++ temporaries properly. -There is an existing implementation of this, but it's not complete and -is disabled in the analyzer. -(Difficulty: Medium; current contact: Alex McCarthy) - -Enhance CFG to model exception-handling properly. -Currently exceptions are treated as "black holes", and exception-handling -control structures are poorly modeled (to be conservative). This could be -much improved for both C++ and Objective-C exceptions. -(Difficulty: Medium) - -Enhance CFG to model C++ new more precisely. -The current representation of new does not provide an easy -way for the analyzer to model the call to a memory allocation function -(operator new), then initialize the result with a constructor -call. The problem is discussed at length in -http://llvm.org/bugs/show_bug.cgi?id=12014;>PR12014. -(Difficulty: Easy; current contact: Karthik Bhat) - -Enhance CFG to model C++ delete more precisely. -Similarly, the representation of delete does not include -the call to the destructor, followed by the call to the deallocation -function (operator delete). One particular issue -(noreturn destructors) is discussed in -http://llvm.org/bugs/show_bug.cgi?id=15599;>PR15599 -(Difficulty: Easy; current contact: Karthik Bhat) - -Implement a BitwiseConstraintManager to handle http://llvm.org/bugs/show_bug.cgi?id=3098;>PR3098. -Constraints on the bits of an integer are not easily representable as -ranges. A bitwise constraint manager would model constraints such as "bit 32 -is known to be 1". This would help code that made use of bitmasks. -(Difficulty: Medium) - - -Track type info through casts more precisely. -The DynamicTypePropagation checker is in charge of inferring a region's -dynamic type based on what operations the code is performing. Casts are a -rich source of type information that the analyzer currently ignores. They -are tricky to get right, but might have very useful consequences. -(Difficulty: Medium) - -Design and implement alpha-renaming. -Implement unifying two symbolic values along a path after they are -determined to be equal via comparison. This would allow us to reduce the -number of false positives and would be a building step to more advanced -analyses, such as summary-based interprocedural and cross-translation-unit -analysis. -(Difficulty: Hard) - - + + Release checkers from "alpha" +New checkers which were contributed to the analyzer, +but have not passed a rigorous evaluation process, +are committed as "alpha checkers" (from "alpha version"), +and are not enabled by default. + +Ideally, only the checkers which are actively being worked on should be in +"alpha", +but over the years the development of many of
r344663 - [analyzer] [www] Updated a list of open projects
Author: george.karpenkov Date: Tue Oct 16 18:06:20 2018 New Revision: 344663 URL: http://llvm.org/viewvc/llvm-project?rev=344663=rev Log: [analyzer] [www] Updated a list of open projects Differential Revision: https://reviews.llvm.org/D53024 Modified: cfe/trunk/www/analyzer/open_projects.html Modified: cfe/trunk/www/analyzer/open_projects.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/open_projects.html?rev=344663=344662=344663=diff == --- cfe/trunk/www/analyzer/open_projects.html (original) +++ cfe/trunk/www/analyzer/open_projects.html Tue Oct 16 18:06:20 2018 @@ -22,162 +22,219 @@ list. If you are interested in tackl to the http://lists.llvm.org/mailman/listinfo/cfe-dev>cfe-dev mailing list to notify other members of the community. - - Core Analyzer Infrastructure - -Explicitly model standard library functions with BodyFarm. -http://clang.llvm.org/doxygen/classclang_1_1BodyFarm.html;>BodyFarm -allows the analyzer to explicitly model functions whose definitions are -not available during analysis. Modeling more of the widely used functions -(such as the members of std::string) will improve precision of the -analysis. -(Difficulty: Easy, ongoing) - - -Handle floating-point values. -Currently, the analyzer treats all floating-point values as unknown. -However, we already have most of the infrastructure we need to handle -floats: RangeConstraintManager. This would involve adding a new SVal kind -for constant floats, generalizing the constraint manager to handle floats -and integers equally, and auditing existing code to make sure it doesn't -make untoward assumptions. - (Difficulty: Medium) - - -Implement generalized loop execution modeling. -Currently, the analyzer simply unrolls each loop N times. This -means that it will not execute any code after the loop if the loop is -guaranteed to execute more than N times. This results in lost -basic block coverage. We could continue exploring the path if we could -model a generic i-th iteration of a loop. - (Difficulty: Hard) - - -Enhance CFG to model C++ temporaries properly. -There is an existing implementation of this, but it's not complete and -is disabled in the analyzer. -(Difficulty: Medium; current contact: Alex McCarthy) - -Enhance CFG to model exception-handling properly. -Currently exceptions are treated as "black holes", and exception-handling -control structures are poorly modeled (to be conservative). This could be -much improved for both C++ and Objective-C exceptions. -(Difficulty: Medium) - -Enhance CFG to model C++ new more precisely. -The current representation of new does not provide an easy -way for the analyzer to model the call to a memory allocation function -(operator new), then initialize the result with a constructor -call. The problem is discussed at length in -http://llvm.org/bugs/show_bug.cgi?id=12014;>PR12014. -(Difficulty: Easy; current contact: Karthik Bhat) - -Enhance CFG to model C++ delete more precisely. -Similarly, the representation of delete does not include -the call to the destructor, followed by the call to the deallocation -function (operator delete). One particular issue -(noreturn destructors) is discussed in -http://llvm.org/bugs/show_bug.cgi?id=15599;>PR15599 -(Difficulty: Easy; current contact: Karthik Bhat) - -Implement a BitwiseConstraintManager to handle http://llvm.org/bugs/show_bug.cgi?id=3098;>PR3098. -Constraints on the bits of an integer are not easily representable as -ranges. A bitwise constraint manager would model constraints such as "bit 32 -is known to be 1". This would help code that made use of bitmasks. -(Difficulty: Medium) - - -Track type info through casts more precisely. -The DynamicTypePropagation checker is in charge of inferring a region's -dynamic type based on what operations the code is performing. Casts are a -rich source of type information that the analyzer currently ignores. They -are tricky to get right, but might have very useful consequences. -(Difficulty: Medium) - -Design and implement alpha-renaming. -Implement unifying two symbolic values along a path after they are -determined to be equal via comparison. This would allow us to reduce the -number of false positives and would be a building step to more advanced -analyses, such as summary-based interprocedural and cross-translation-unit -analysis. -(Difficulty: Hard) - - + + Release checkers from "alpha" +New checkers which were contributed to the analyzer, +but have not passed a rigorous evaluation process, +are committed as "alpha checkers" (from "alpha version"), +and are not enabled by
[PATCH] D53339: [clang-tidy] Add the abseil-duration-factory-float check
Eugene.Zelenko added a comment. By the word, why this check could not be generalized to any function/method which have floating-point and integer variants? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53339 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53296: [analyzer] New flag to print all -analyzer-config options
Szelethus updated this revision to Diff 169927. Szelethus edited the summary of this revision. Szelethus added a comment. Added a test. https://reviews.llvm.org/D53296 Files: include/clang/Driver/CC1Options.td include/clang/StaticAnalyzer/Core/AnalyzerOptions.h include/clang/StaticAnalyzer/Frontend/FrontendActions.h lib/Frontend/CompilerInvocation.cpp lib/FrontendTool/ExecuteCompilerInvocation.cpp lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp test/Analysis/analyzer-list-configs.c Index: test/Analysis/analyzer-list-configs.c === --- /dev/null +++ test/Analysis/analyzer-list-configs.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -analyzer-list-configs 2>&1 | FileCheck %s +// CHECK: OVERVIEW: Clang Static Analyzer -analyzer-config Option List +// +// CHECK: USAGE: clang [CLANG_OPTIONS] -analyzer-config +// +// CHECK:clang [CLANG_OPTIONS] -analyzer-config OPTION1=VALUE, -analyzer-config OPTION2=VALUE, ... +// +// CHECK: OPTIONS: Index: lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp === --- lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp +++ lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp @@ -22,6 +22,7 @@ #include "clang/StaticAnalyzer/Frontend/FrontendActions.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/DynamicLibrary.h" +#include "llvm/Support/FormattedStream.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include @@ -157,3 +158,54 @@ SmallVector checkerOpts = getCheckerOptList(opts); ClangCheckerRegistry(plugins).printList(out, checkerOpts); } + +void ento::printAnalyzerConfigList(raw_ostream ) { + out << "OVERVIEW: Clang Static Analyzer -analyzer-config Option List\n\n"; + out << "USAGE: clang [CLANG_OPTIONS] -analyzer-config " + "\n\n"; + out << " clang [CLANG_OPTIONS] -analyzer-config OPTION1=VALUE, " + "-analyzer-config OPTION2=VALUE, ...\n\n"; + out << "OPTIONS:\n\n"; + + using OptionAndDescriptionTy = std::pair; + OptionAndDescriptionTy PrintableOptions[] = { +#define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC) \ +{ CMDFLAG, DESC }, +#include "clang/StaticAnalyzer/Core/AnalyzerOptions.def" +#undef BOOL_ANALYZER_OPTION + }; + + llvm::sort(PrintableOptions, [](const OptionAndDescriptionTy , + const OptionAndDescriptionTy ) { +return LHS.first < RHS.first; + }); + + constexpr size_t MinLineWidth = 70; + constexpr size_t PadForOpt = 2; + constexpr size_t OptionWidth = 30; + constexpr size_t PadForDesc = PadForOpt + OptionWidth; + static_assert(MinLineWidth > PadForDesc, "MinLineWidth must be greater!"); + + llvm::formatted_raw_ostream FOut(out); + + for (const auto : PrintableOptions) { +FOut.PadToColumn(PadForOpt) << Pair.first; + +// If the buffer's length is greater then PadForDesc, print a newline. +if (FOut.getColumn() > PadForDesc) { + FOut << '\n'; +} + +FOut.PadToColumn(PadForDesc); + +for (char C : Pair.second) { + if (FOut.getColumn() > MinLineWidth && C == ' ') { +FOut << '\n'; +FOut.PadToColumn(PadForDesc); +continue; + } + FOut << C; +} +FOut << "\n\n"; + } +} Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp === --- lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -241,11 +241,19 @@ ento::printCheckerHelp(llvm::outs(), Clang->getFrontendOpts().Plugins); return true; } + + // Honor -analyzer-list-enabled-checkers. if (Clang->getAnalyzerOpts()->ShowEnabledCheckerList) { ento::printEnabledCheckerList(llvm::outs(), Clang->getFrontendOpts().Plugins, *Clang->getAnalyzerOpts()); } + + // Honor -analyzer-list-configs. + if (Clang->getAnalyzerOpts()->ShowConfigOptionsList) { +ento::printAnalyzerConfigList(llvm::outs()); +return true; + } #endif // If there were errors in processing arguments, don't do anything else. Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -279,6 +279,7 @@ } Opts.ShowCheckerHelp = Args.hasArg(OPT_analyzer_checker_help); + Opts.ShowConfigOptionsList = Args.hasArg(OPT_analyzer_list_configs); Opts.ShowEnabledCheckerList = Args.hasArg(OPT_analyzer_list_enabled_checkers); Opts.DisableAllChecks = Args.hasArg(OPT_analyzer_disable_all_checks); Index: include/clang/StaticAnalyzer/Frontend/FrontendActions.h === --- include/clang/StaticAnalyzer/Frontend/FrontendActions.h +++ include/clang/StaticAnalyzer/Frontend/FrontendActions.h @@ -55,6 +55,7 @@ void
[PATCH] D53339: Add the abseil-duration-factory-float clang-tidy check
Eugene.Zelenko added inline comments. Comment at: clang-tidy/abseil/DurationFactoryFloatCheck.cpp:24 +// Returns an integer if the fractional part of a `FloatingLiteral` is 0. +llvm::Optional +TruncateIfIntegral(const FloatingLiteral ) { Please use static keyword instead of anonymous namespace. Comment at: clang-tidy/abseil/DurationFactoryFloatCheck.cpp:70 + const Expr *Arg = MatchedCall->getArg(0)->IgnoreImpCasts(); + // We don't mess with macros. + if (Arg->getBeginLoc().isMacroID()) May be //Macros are ignored// will sound better? Comment at: docs/ReleaseNotes.rst:70 +- New :doc:`abseil-duration-factory-float + ` check. Please sort new check lists alphabetically. Comment at: docs/clang-tidy/checks/abseil-duration-factory-float.rst:8 +``absl::Seconds`` or ``absl::Hours``) are providing a floating point value +when an integer could be used instead. The integer factory function overload +is more efficient and readable. Please fix double space. https://reviews.llvm.org/D53339 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53296: [analyzer] New flag to print all -analyzer-config options
Szelethus updated this revision to Diff 169925. Szelethus edited the summary of this revision. Szelethus added a comment. Herald added a subscriber: nhaehnle. Using `llvm::formatted_raw_ostream` to drastically simplify the previous solution. The actual output changed a little bit too, now I'm printing a newline at the first space after the width of the line exceeds 70. Updated the summary accordingly. https://reviews.llvm.org/D53296 Files: include/clang/Driver/CC1Options.td include/clang/StaticAnalyzer/Core/AnalyzerOptions.h include/clang/StaticAnalyzer/Frontend/FrontendActions.h lib/Frontend/CompilerInvocation.cpp lib/FrontendTool/ExecuteCompilerInvocation.cpp lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp Index: lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp === --- lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp +++ lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp @@ -22,6 +22,7 @@ #include "clang/StaticAnalyzer/Frontend/FrontendActions.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/DynamicLibrary.h" +#include "llvm/Support/FormattedStream.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include @@ -157,3 +158,54 @@ SmallVector checkerOpts = getCheckerOptList(opts); ClangCheckerRegistry(plugins).printList(out, checkerOpts); } + +void ento::printAnalyzerConfigList(raw_ostream ) { + out << "OVERVIEW: Clang Static Analyzer -analyzer-config Option List\n\n"; + out << "USAGE: clang [CLANG_OPTIONS] -analyzer-config " + "\n\n"; + out << " clang [CLANG_OPTIONS] -analyzer-config OPTION1=VALUE, " + "-analyzer-config OPTION2=VALUE, ...\n\n"; + out << "OPTIONS:\n\n"; + + using OptionAndDescriptionTy = std::pair; + OptionAndDescriptionTy PrintableOptions[] = { +#define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC) \ +{ CMDFLAG, DESC }, +#include "clang/StaticAnalyzer/Core/AnalyzerOptions.def" +#undef BOOL_ANALYZER_OPTION + }; + + llvm::sort(PrintableOptions, [](const OptionAndDescriptionTy , + const OptionAndDescriptionTy ) { +return LHS.first < RHS.first; + }); + + constexpr size_t MinLineWidth = 70; + constexpr size_t PadForOpt = 2; + constexpr size_t OptionWidth = 30; + constexpr size_t PadForDesc = PadForOpt + OptionWidth; + static_assert(MinLineWidth > PadForDesc, "MinLineWidth must be greater!"); + + llvm::formatted_raw_ostream FOut(out); + + for (const auto : PrintableOptions) { +FOut.PadToColumn(PadForOpt) << Pair.first; + +// If the buffer's length is greater then PadForDesc, print a newline. +if (FOut.getColumn() > PadForDesc) { + FOut << '\n'; +} + +FOut.PadToColumn(PadForDesc); + +for (char C : Pair.second) { + if (FOut.getColumn() > MinLineWidth && C == ' ') { +FOut << '\n'; +FOut.PadToColumn(PadForDesc); +continue; + } + FOut << C; +} +FOut << "\n\n"; + } +} Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp === --- lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -241,11 +241,19 @@ ento::printCheckerHelp(llvm::outs(), Clang->getFrontendOpts().Plugins); return true; } + + // Honor -analyzer-list-enabled-checkers. if (Clang->getAnalyzerOpts()->ShowEnabledCheckerList) { ento::printEnabledCheckerList(llvm::outs(), Clang->getFrontendOpts().Plugins, *Clang->getAnalyzerOpts()); } + + // Honor -analyzer-list-enabled-checkers. + if (Clang->getAnalyzerOpts()->ShowConfigOptionsList) { +ento::printAnalyzerConfigList(llvm::outs()); +return true; + } #endif // If there were errors in processing arguments, don't do anything else. Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -279,6 +279,7 @@ } Opts.ShowCheckerHelp = Args.hasArg(OPT_analyzer_checker_help); + Opts.ShowConfigOptionsList = Args.hasArg(OPT_analyzer_list_configs); Opts.ShowEnabledCheckerList = Args.hasArg(OPT_analyzer_list_enabled_checkers); Opts.DisableAllChecks = Args.hasArg(OPT_analyzer_disable_all_checks); Index: include/clang/StaticAnalyzer/Frontend/FrontendActions.h === --- include/clang/StaticAnalyzer/Frontend/FrontendActions.h +++ include/clang/StaticAnalyzer/Frontend/FrontendActions.h @@ -55,6 +55,7 @@ void printCheckerHelp(raw_ostream , ArrayRef plugins); void printEnabledCheckerList(raw_ostream , ArrayRef plugins, const AnalyzerOptions ); +void printAnalyzerConfigList(raw_ostream ); } // end GR namespace Index:
[PATCH] D53339: Add the abseil-duration-factory-float clang-tidy check
alexfh added a comment. LG In general, but see a few comments inline. Comment at: clang-tidy/abseil/DurationFactoryFloatCheck.cpp:25 +llvm::Optional +TruncateIfIntegral(const FloatingLiteral ) { + double value = FloatLiteral.getValueAsApproximateDouble(); Please use the LLVM style (`functionName`). See http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly Comment at: clang-tidy/abseil/DurationFactoryFloatCheck.cpp:27 + double value = FloatLiteral.getValueAsApproximateDouble(); + if (std::fmod(value, 1) == 0) { +bool is_negative = false; Probably doesn't matter much, but would `std::modf` be more appropriate in this context? Comment at: clang-tidy/abseil/DurationFactoryFloatCheck.cpp:65-66 + // Don't try and replace things inside of macro definitions. + if (MatchedCall->getBeginLoc().isMacroID() || + MatchedCall->getEndLoc().isMacroID()) +return; Lexer::makeFileCharRange may be a better (and less strict) way to test whether we can safely replace a range. Comment at: clang-tidy/abseil/DurationFactoryFloatCheck.cpp:87 + // Check for floats without fractional components + if (const FloatingLiteral *LitFloat = + Result.Nodes.getNodeAs("float_literal")) { `const auto *` will be as readable and less verbose. Comment at: docs/ReleaseNotes.rst:73 + + FIXME: add release notes. + Please remove the FIXME https://reviews.llvm.org/D53339 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53347: [clangd] Simplify auto hover
kadircet accepted this revision. kadircet added a comment. This revision is now accepted and ready to land. LGTM, it bugs me that some part in the documentation says it doesn't go through decltype(`This looks through declarators like pointer types, but not through decltype or typedefs`) but since tests containing decltype didn't break it looks OK to me. I would still wait for @hokein to have another look as well. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53347 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53192: [clangd] Do not query index for new name completions.
ilya-biryukov added a comment. A drive-by NIT ;-) Comment at: clangd/CodeComplete.cpp:643 case CodeCompletionContext::CCC_Recovery: + // TODO: Provide identifier based completions for the following two contexts: + case CodeCompletionContext::CCC_Name: sammccall wrote: > consider Recovery, NaturalLanguage there too? and maybe Other? NIT: use FIXME to be consistent with the rest of clangd Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53192 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53024: [analyzer][www] Add more open projects
NoQ accepted this revision. NoQ added a comment. Ok, let's see if this actually works :) https://reviews.llvm.org/D53024 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52301: [clang] Set TypeSourceInfo for vardecl's in addition to type when we can deduce.
kadircet added a comment. In https://reviews.llvm.org/D52301#1263275, @aaron.ballman wrote: > Can you give a bit more background on what problem you're trying to solve > with this patch? Sorry for the lack of context, it was about an offline discussion on `Sema::DeduceVariableDeclarationType` just setting the type and not setting the typesourceinfo, which was resulting in having `DeducedType` in type but not in typesourceinfo. We wanted to fix that behavior because it was resulting in getting "auto"s when we look at typesourceinfo(which happens in astprinter). But then it turned out to be there are other parts of clang(including extra tools) that depend on typesourceinfo not having the deduced type, for example include-fixer and refactoring/rename, relied on that information being missing when they were looking for (usage counts/locations) of symbols they were looking for. So in the middle of the patch we were just trying to figure out whether we are going to break a big assumption that lots of different components relied on but just didn't had any tests for. Maybe @rsmith would have more context about the behavior? Comment at: lib/Sema/SemaChecking.cpp:852 - if (RT->getPointeeType().getAddressSpace() != LangAS::opencl_generic) { -S.Diag(Call->getArg(0)->getBeginLoc(), aaron.ballman wrote: > I'm not certain I understand why this code has been removed? It shouldn't have been, tried rebasing but it didn't go away. I think it was deleted at some point by a different change and somehow ended up showing in here as well. (Tried to revert, got an error stating warn_opencl_generic_address_space_arg doesn't exist) Comment at: lib/Sema/SemaDecl.cpp:10766 -QualType Sema::deduceVarTypeFromInitializer(VarDecl *VDecl, +std::pair Sema::deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, aaron.ballman wrote: > Why does this need to return a pair? It seems like the returned > `TypeSourceInfo*` carries all the information needed by the caller, or is > there ever a case where the `QualType` will be different than what is > returned by `TypeSourceInfo::getType()`? Yes, unfortunately there are cases these two differ. That's exactly the case we are trying to fix with that patch. Repository: rC Clang https://reviews.llvm.org/D52301 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53024: [analyzer][www] Add more open projects
george.karpenkov updated this revision to Diff 169920. https://reviews.llvm.org/D53024 Files: clang/www/analyzer/open_projects.html Index: clang/www/analyzer/open_projects.html === --- clang/www/analyzer/open_projects.html +++ clang/www/analyzer/open_projects.html @@ -22,162 +22,219 @@ to the http://lists.llvm.org/mailman/listinfo/cfe-dev>cfe-dev mailing list to notify other members of the community. - - Core Analyzer Infrastructure + + Release checkers from "alpha" +New checkers which were contributed to the analyzer, +but have not passed a rigorous evaluation process, +are committed as "alpha checkers" (from "alpha version"), +and are not enabled by default. + +Ideally, only the checkers which are actively being worked on should be in +"alpha", +but over the years the development of many of those has stalled. +Such checkers need a cleanup: +checkers which have been there for a long time should either +be improved up to a point where they can be enabled by default, +or removed, if such an improvement is not possible. +Most notably, these checkers could be "graduated" out of alpha +if a consistent effort is applied: + + + alpha.security.ArrayBound and + alpha.security.ArrayBoundV2 + Array bounds checking is a desired feature, + but having an acceptable rate of false positives might not be possible + without a proper + https://en.wikipedia.org/wiki/Widening_(computer_science)">loop widening support. + Additionally, it might be more promising to perform index checking based on + https://en.wikipedia.org/wiki/Taint_checking;>tainted index values. + (Difficulty: Medium) + + + alpha.cplusplus.MisusedMovedObject +The checker emits a warning on objects which were used after +https://en.cppreference.com/w/cpp/utility/move;>move. +Currently it has an overly high false positive rate due to classes +which have a well-defined semantics for use-after-move. +This property does not hold for STL objects, but is often the case +for custom containers. + (Difficulty: Medium) + + + alpha.unix.StreamChecker +A SimpleStreamChecker has been presented in the Building a Checker in 24 +Hours talk +(http://llvm.org/devmtg/2012-11/Zaks-Rose-Checker24Hours.pdf;>slides +https://youtu.be/kdxlsP5QVPw;>video). + +This alpha checker is an attempt to write a production grade stream checker. +However, it was found to have an unacceptably high false positive rate. +One of the found problems was that eagerly splitting the state +based on whether the system call may fail leads to too many reports. +A delayed split where the implication is stored in the state +(similarly to nullability implications in TrustNonnullChecker) +may produce much better results. +(Difficulty: Medium) + + + + + Improved C++ support -Explicitly model standard library functions with BodyFarm. -http://clang.llvm.org/doxygen/classclang_1_1BodyFarm.html;>BodyFarm -allows the analyzer to explicitly model functions whose definitions are -not available during analysis. Modeling more of the widely used functions -(such as the members of std::string) will improve precision of the -analysis. -(Difficulty: Easy, ongoing) +Handle aggregate construction. + https://en.cppreference.com/w/cpp/language/aggregate_initialization;>Aggregates + are objects that can be brace-initialized without calling a + constructor (that is, https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html;> + CXXConstructExpr does not occur in the AST), + but potentially calling + constructors for their fields and base classes + These + constructors of sub-objects need to know what object they are constructing. + Moreover, if the aggregate contains + references, lifetime extension needs to be properly modeled. + + One can start untangling this problem by trying to replace the + current ad-hoc https://clang.llvm.org/doxygen/classclang_1_1ParentMap.html;> + ParentMap lookup in https://clang.llvm.org/doxygen/ExprEngineCXX_8cpp_source.html#l00430;> + CXXConstructExpr::CK_NonVirtualBase branch of + ExprEngine::VisitCXXConstructExpr() + with proper support for the feature. + (Difficulty: Medium) -Handle floating-point values. -Currently, the analyzer treats all floating-point values as unknown. -However, we already have most of the infrastructure we need to handle -floats: RangeConstraintManager. This would involve adding a new SVal kind -for constant floats, generalizing the constraint manager to handle floats -and integers equally, and auditing existing code to make sure it doesn't -make
[PATCH] D53348: [AArch64] Define __ELF__ for aarch64-none-elf and other similar triples.
efriedma created this revision. efriedma added reviewers: olista01, SjoerdMeijer. Herald added a reviewer: javed.absar. Herald added a subscriber: kristof.beyls. "aarch64-none-elf" is commonly used for AArch64 baremetal toolchains. Repository: rC Clang https://reviews.llvm.org/D53348 Files: lib/Basic/Targets/AArch64.cpp test/Preprocessor/init.c Index: test/Preprocessor/init.c === --- test/Preprocessor/init.c +++ test/Preprocessor/init.c @@ -2590,6 +2590,7 @@ // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-eabihf < /dev/null | FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-none-eabi < /dev/null | FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-none-eabihf < /dev/null | FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-none-elf < /dev/null | FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s // ARM-NONE-EABI: #define __ELF__ 1 // No MachO targets use the full EABI, even if AAPCS is used. Index: lib/Basic/Targets/AArch64.cpp === --- lib/Basic/Targets/AArch64.cpp +++ lib/Basic/Targets/AArch64.cpp @@ -122,10 +122,9 @@ MacroBuilder ) const { // Target identification. Builder.defineMacro("__aarch64__"); - // For bare-metal none-eabi. + // For bare-metal. if (getTriple().getOS() == llvm::Triple::UnknownOS && - (getTriple().getEnvironment() == llvm::Triple::EABI || - getTriple().getEnvironment() == llvm::Triple::EABIHF)) + getTriple().isOSBinFormatELF()) Builder.defineMacro("__ELF__"); // Target properties. Index: test/Preprocessor/init.c === --- test/Preprocessor/init.c +++ test/Preprocessor/init.c @@ -2590,6 +2590,7 @@ // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-eabihf < /dev/null | FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-none-eabi < /dev/null | FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-none-eabihf < /dev/null | FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-none-elf < /dev/null | FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s // ARM-NONE-EABI: #define __ELF__ 1 // No MachO targets use the full EABI, even if AAPCS is used. Index: lib/Basic/Targets/AArch64.cpp === --- lib/Basic/Targets/AArch64.cpp +++ lib/Basic/Targets/AArch64.cpp @@ -122,10 +122,9 @@ MacroBuilder ) const { // Target identification. Builder.defineMacro("__aarch64__"); - // For bare-metal none-eabi. + // For bare-metal. if (getTriple().getOS() == llvm::Triple::UnknownOS && - (getTriple().getEnvironment() == llvm::Triple::EABI || - getTriple().getEnvironment() == llvm::Triple::EABIHF)) + getTriple().isOSBinFormatELF()) Builder.defineMacro("__ELF__"); // Target properties. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53347: [clangd] Simplify auto hover
ilya-biryukov created this revision. ilya-biryukov added reviewers: kadircet, hokein. Herald added subscribers: arphaman, jkorous, MaskRay, ioeric. Use helper from clang. Also fixes some weird corner cases, e.g. auto (*foo)() = bar; Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53347 Files: clangd/XRefs.cpp unittests/clangd/XRefsTests.cpp Index: unittests/clangd/XRefsTests.cpp === --- unittests/clangd/XRefsTests.cpp +++ unittests/clangd/XRefsTests.cpp @@ -999,6 +999,13 @@ )cpp", "", }, + { + R"cpp(// More compilcated structured types. +int bar(); +^auto (*foo)() = bar; + )cpp", + "int", + }, }; for (const OneTest : Tests) { Index: clangd/XRefs.cpp === --- clangd/XRefs.cpp +++ clangd/XRefs.cpp @@ -579,17 +579,6 @@ llvm::Optional getDeducedType() { return DeducedType; } - // Remove the surrounding Reference or Pointer type of the given type T. - QualType UnwrapReferenceOrPointer(QualType T) { -// "auto &" is represented as a ReferenceType containing an AutoType -if (const ReferenceType *RT = dyn_cast(T.getTypePtr())) - return RT->getPointeeType(); -// "auto *" is represented as a PointerType containing an AutoType -if (const PointerType *PT = dyn_cast(T.getTypePtr())) - return PT->getPointeeType(); -return T; - } - // Handle auto initializers: //- auto i = 1; //- decltype(auto) i = 1; @@ -600,18 +589,9 @@ D->getTypeSourceInfo()->getTypeLoc().getBeginLoc() != SearchedLocation) return true; -auto DeclT = UnwrapReferenceOrPointer(D->getType()); -const AutoType *AT = dyn_cast(DeclT.getTypePtr()); -if (AT && !AT->getDeducedType().isNull()) { - // For auto, use the underlying type because the const& would be - // represented twice: written in the code and in the hover. - // Example: "const auto I = 1", we only want "int" when hovering on auto, - // not "const int". - // - // For decltype(auto), take the type as is because it cannot be written - // with qualifiers or references but its decuded type can be const-ref. - DeducedType = AT->isDecltypeAuto() ? DeclT : DeclT.getUnqualifiedType(); -} +auto AT = D->getType()->getContainedAutoType(); +if (AT && !AT->getDeducedType().isNull()) + DeducedType = AT->getDeducedType(); return true; } @@ -634,12 +614,11 @@ if (CurLoc != SearchedLocation) return true; -auto T = UnwrapReferenceOrPointer(D->getReturnType()); -const AutoType *AT = dyn_cast(T.getTypePtr()); +const AutoType *AT = D->getReturnType()->getContainedAutoType(); if (AT && !AT->getDeducedType().isNull()) { - DeducedType = T.getUnqualifiedType(); + DeducedType = AT->getDeducedType(); } else { // auto in a trailing return type just points to a DecltypeType. - const DecltypeType *DT = dyn_cast(T.getTypePtr()); + const DecltypeType *DT = dyn_cast(D->getReturnType()); if (!DT->getUnderlyingType().isNull()) DeducedType = DT->getUnderlyingType(); } Index: unittests/clangd/XRefsTests.cpp === --- unittests/clangd/XRefsTests.cpp +++ unittests/clangd/XRefsTests.cpp @@ -999,6 +999,13 @@ )cpp", "", }, + { + R"cpp(// More compilcated structured types. +int bar(); +^auto (*foo)() = bar; + )cpp", + "int", + }, }; for (const OneTest : Tests) { Index: clangd/XRefs.cpp === --- clangd/XRefs.cpp +++ clangd/XRefs.cpp @@ -579,17 +579,6 @@ llvm::Optional getDeducedType() { return DeducedType; } - // Remove the surrounding Reference or Pointer type of the given type T. - QualType UnwrapReferenceOrPointer(QualType T) { -// "auto &" is represented as a ReferenceType containing an AutoType -if (const ReferenceType *RT = dyn_cast(T.getTypePtr())) - return RT->getPointeeType(); -// "auto *" is represented as a PointerType containing an AutoType -if (const PointerType *PT = dyn_cast(T.getTypePtr())) - return PT->getPointeeType(); -return T; - } - // Handle auto initializers: //- auto i = 1; //- decltype(auto) i = 1; @@ -600,18 +589,9 @@ D->getTypeSourceInfo()->getTypeLoc().getBeginLoc() != SearchedLocation) return true; -auto DeclT = UnwrapReferenceOrPointer(D->getType()); -const AutoType *AT = dyn_cast(DeclT.getTypePtr()); -if (AT && !AT->getDeducedType().isNull()) { - // For auto, use the underlying type because the const& would be - // represented twice: written in the code and in the hover. - // Example: "const auto I = 1", we only want "int" when
[PATCH] D52794: [analyzer][PlistMacroExpansion] Part 2.: Retrieving the macro name and primitive expansion
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:727 + +static std::string getExpandedMacroImpl(TokenPrinter , +SourceLocation MacroLoc, Whoa, that's so easy! Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:787-791 + // Acquire the macro's name. + Token TheTok; + RawLexer.LexFromRawLexer(TheTok); + + std::string MacroName = PP.getSpelling(TheTok); Not sure, random thought: Could this work in fact be done with the //static// `Lexer::getImmediateMacroName()` helper? Comment at: test/Analysis/plist-macros-with-expansion.cpp:31 +// CHECK: nameSET_PTR_VAR_TO_NULL +// CHECK: expansionptr = 0 Hmm, i think we can use `CHECK-NEXT:` here, in order to make sure these lines go sequentially. Otherwise this second line may accidentally match someone else's expansion(?). Comment at: test/Analysis/plist-macros-with-expansion.cpp:84 + +// TODO: Expand argumnts. +// CHECK: nameTO_NULL Typo: `arguments`. https://reviews.llvm.org/D52794 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53085: [clang-doc] Add unit tests for Markdown
This revision was automatically updated to reflect the committed changes. Closed by commit rCTE344654: [clang-doc] Add unit tests for Markdown generation (authored by juliehockett, committed by ). Changed prior to commit: https://reviews.llvm.org/D53085?vs=169752=169911#toc Repository: rL LLVM https://reviews.llvm.org/D53085 Files: unittests/clang-doc/CMakeLists.txt unittests/clang-doc/MDGeneratorTest.cpp Index: unittests/clang-doc/CMakeLists.txt === --- unittests/clang-doc/CMakeLists.txt +++ unittests/clang-doc/CMakeLists.txt @@ -13,6 +13,7 @@ add_extra_unittest(ClangDocTests BitcodeTest.cpp ClangDocTest.cpp + MDGeneratorTest.cpp MergeTest.cpp SerializeTest.cpp YAMLGeneratorTest.cpp Index: unittests/clang-doc/MDGeneratorTest.cpp === --- unittests/clang-doc/MDGeneratorTest.cpp +++ unittests/clang-doc/MDGeneratorTest.cpp @@ -0,0 +1,361 @@ +//===-- clang-doc/MDGeneratorTest.cpp -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "ClangDocTest.h" +#include "Generators.h" +#include "Representation.h" +#include "gtest/gtest.h" + +namespace clang { +namespace doc { + +std::unique_ptr getMDGenerator() { + auto G = doc::findGeneratorByName("md"); + if (!G) +return nullptr; + return std::move(G.get()); +} + +TEST(MDGeneratorTest, emitNamespaceMD) { + NamespaceInfo I; + I.Name = "Namespace"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.ChildNamespaces.emplace_back(EmptySID, "ChildNamespace", + InfoType::IT_namespace); + I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record); + I.ChildFunctions.emplace_back(); + I.ChildFunctions.back().Name = "OneFunction"; + I.ChildEnums.emplace_back(); + I.ChildEnums.back().Name = "OneEnum"; + + auto G = getMDGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(, Actual); + assert(!Err); + std::string Expected = R"raw(# namespace Namespace + + + +## Namespaces + +ChildNamespace + + + +## Records + +ChildStruct + + + +## Functions + +### OneFunction + +* OneFunction()* + + + +## Enums + +| enum OneEnum | + +-- + + + + + +)raw"; + EXPECT_EQ(Expected, Actual.str()); +} + +TEST(MDGeneratorTest, emitRecordMD) { + RecordInfo I; + I.Name = "r"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); + I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); + + I.Members.emplace_back("int", "X", AccessSpecifier::AS_private); + I.TagType = TagTypeKind::TTK_Class; + I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record); + I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); + + I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record); + I.ChildFunctions.emplace_back(); + I.ChildFunctions.back().Name = "OneFunction"; + I.ChildEnums.emplace_back(); + I.ChildEnums.back().Name = "OneEnum"; + + auto G = getMDGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(, Actual); + assert(!Err); + std::string Expected = R"raw(# class r + +*Defined at line 10 of test.cpp* + +Inherits from F, G + + + +## Members + +private int X + + + +## Records + +ChildStruct + + + +## Functions + +### OneFunction + +* OneFunction()* + + + +## Enums + +| enum OneEnum | + +-- + + + + + +)raw"; + EXPECT_EQ(Expected, Actual.str()); +} + +TEST(MDGeneratorTest, emitFunctionMD) { + FunctionInfo I; + I.Name = "f"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); + I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); + + I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); + I.Params.emplace_back("int", "P"); + I.IsMethod = true; + I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record); + + auto G = getMDGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(, Actual); + assert(!Err); + std::string Expected = R"raw(### f + +*void f(int P)* + +*Defined at line 10 of test.cpp* + +)raw"; + + EXPECT_EQ(Expected, Actual.str()); +} + +TEST(MDGeneratorTest, emitEnumMD) { + EnumInfo I; + I.Name = "e"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); + I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); + + I.Members.emplace_back("X"); + I.Scoped = true;
[PATCH] D53084: [clang-doc] Add unit tests for YAML
This revision was automatically updated to reflect the committed changes. Closed by commit rCTE344653: [clang-doc] Add unit tests for YAML generation (authored by juliehockett, committed by ). Changed prior to commit: https://reviews.llvm.org/D53084?vs=169751=169910#toc Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53084 Files: unittests/clang-doc/CMakeLists.txt unittests/clang-doc/YAMLGeneratorTest.cpp Index: unittests/clang-doc/CMakeLists.txt === --- unittests/clang-doc/CMakeLists.txt +++ unittests/clang-doc/CMakeLists.txt @@ -15,6 +15,7 @@ ClangDocTest.cpp MergeTest.cpp SerializeTest.cpp + YAMLGeneratorTest.cpp ) target_link_libraries(ClangDocTests Index: unittests/clang-doc/YAMLGeneratorTest.cpp === --- unittests/clang-doc/YAMLGeneratorTest.cpp +++ unittests/clang-doc/YAMLGeneratorTest.cpp @@ -0,0 +1,427 @@ +//===-- clang-doc/YAMLGeneratorTest.cpp +//===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "ClangDocTest.h" +#include "Generators.h" +#include "Representation.h" +#include "gtest/gtest.h" + +namespace clang { +namespace doc { + +std::unique_ptr getYAMLGenerator() { + auto G = doc::findGeneratorByName("yaml"); + if (!G) +return nullptr; + return std::move(G.get()); +} + +TEST(YAMLGeneratorTest, emitNamespaceYAML) { + NamespaceInfo I; + I.Name = "Namespace"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.ChildNamespaces.emplace_back(EmptySID, "ChildNamespace", + InfoType::IT_namespace); + I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record); + I.ChildFunctions.emplace_back(); + I.ChildFunctions.back().Name = "OneFunction"; + I.ChildEnums.emplace_back(); + I.ChildEnums.back().Name = "OneEnum"; + + auto G = getYAMLGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(, Actual); + assert(!Err); + std::string Expected = + R"raw(--- +USR: '' +Name:'Namespace' +Namespace: + - Type:Namespace +Name:'A' +ChildNamespaces: + - Type:Namespace +Name:'ChildNamespace' +ChildRecords: + - Type:Record +Name:'ChildStruct' +ChildFunctions: + - USR: '' +Name:'OneFunction' +ReturnType: +ChildEnums: + - USR: '' +Name:'OneEnum' +... +)raw"; + EXPECT_EQ(Expected, Actual.str()); +} + +TEST(YAMLGeneratorTest, emitRecordYAML) { + RecordInfo I; + I.Name = "r"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); + I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); + + I.Members.emplace_back("int", "X", AccessSpecifier::AS_private); + I.TagType = TagTypeKind::TTK_Class; + I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record); + I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); + + I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record); + I.ChildFunctions.emplace_back(); + I.ChildFunctions.back().Name = "OneFunction"; + I.ChildEnums.emplace_back(); + I.ChildEnums.back().Name = "OneEnum"; + + auto G = getYAMLGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(, Actual); + assert(!Err); + std::string Expected = + R"raw(--- +USR: '' +Name:'r' +Namespace: + - Type:Namespace +Name:'A' +DefLocation: + LineNumber: 10 + Filename:'test.cpp' +Location: + - LineNumber: 12 +Filename:'test.cpp' +TagType: Class +Members: + - Type: + Name:'int' +Name:'X' +Access: Private +Parents: + - Type:Record +Name:'F' +VirtualParents: + - Type:Record +Name:'G' +ChildRecords: + - Type:Record +Name:'ChildStruct' +ChildFunctions: + - USR: '' +Name:'OneFunction' +ReturnType: +ChildEnums: + - USR: '' +Name:'OneEnum' +... +)raw"; +
[PATCH] D53085: [clang-doc] Add unit tests for Markdown
This revision was automatically updated to reflect the committed changes. Closed by commit rL344654: [clang-doc] Add unit tests for Markdown generation (authored by juliehockett, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D53085?vs=169752=169912#toc Repository: rL LLVM https://reviews.llvm.org/D53085 Files: clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt clang-tools-extra/trunk/unittests/clang-doc/MDGeneratorTest.cpp Index: clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt === --- clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt +++ clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt @@ -13,6 +13,7 @@ add_extra_unittest(ClangDocTests BitcodeTest.cpp ClangDocTest.cpp + MDGeneratorTest.cpp MergeTest.cpp SerializeTest.cpp YAMLGeneratorTest.cpp Index: clang-tools-extra/trunk/unittests/clang-doc/MDGeneratorTest.cpp === --- clang-tools-extra/trunk/unittests/clang-doc/MDGeneratorTest.cpp +++ clang-tools-extra/trunk/unittests/clang-doc/MDGeneratorTest.cpp @@ -0,0 +1,361 @@ +//===-- clang-doc/MDGeneratorTest.cpp -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "ClangDocTest.h" +#include "Generators.h" +#include "Representation.h" +#include "gtest/gtest.h" + +namespace clang { +namespace doc { + +std::unique_ptr getMDGenerator() { + auto G = doc::findGeneratorByName("md"); + if (!G) +return nullptr; + return std::move(G.get()); +} + +TEST(MDGeneratorTest, emitNamespaceMD) { + NamespaceInfo I; + I.Name = "Namespace"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.ChildNamespaces.emplace_back(EmptySID, "ChildNamespace", + InfoType::IT_namespace); + I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record); + I.ChildFunctions.emplace_back(); + I.ChildFunctions.back().Name = "OneFunction"; + I.ChildEnums.emplace_back(); + I.ChildEnums.back().Name = "OneEnum"; + + auto G = getMDGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(, Actual); + assert(!Err); + std::string Expected = R"raw(# namespace Namespace + + + +## Namespaces + +ChildNamespace + + + +## Records + +ChildStruct + + + +## Functions + +### OneFunction + +* OneFunction()* + + + +## Enums + +| enum OneEnum | + +-- + + + + + +)raw"; + EXPECT_EQ(Expected, Actual.str()); +} + +TEST(MDGeneratorTest, emitRecordMD) { + RecordInfo I; + I.Name = "r"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); + I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); + + I.Members.emplace_back("int", "X", AccessSpecifier::AS_private); + I.TagType = TagTypeKind::TTK_Class; + I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record); + I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); + + I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record); + I.ChildFunctions.emplace_back(); + I.ChildFunctions.back().Name = "OneFunction"; + I.ChildEnums.emplace_back(); + I.ChildEnums.back().Name = "OneEnum"; + + auto G = getMDGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(, Actual); + assert(!Err); + std::string Expected = R"raw(# class r + +*Defined at line 10 of test.cpp* + +Inherits from F, G + + + +## Members + +private int X + + + +## Records + +ChildStruct + + + +## Functions + +### OneFunction + +* OneFunction()* + + + +## Enums + +| enum OneEnum | + +-- + + + + + +)raw"; + EXPECT_EQ(Expected, Actual.str()); +} + +TEST(MDGeneratorTest, emitFunctionMD) { + FunctionInfo I; + I.Name = "f"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); + I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); + + I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); + I.Params.emplace_back("int", "P"); + I.IsMethod = true; + I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record); + + auto G = getMDGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(, Actual); + assert(!Err); + std::string Expected = R"raw(### f + +*void f(int P)* + +*Defined at line 10 of test.cpp* + +)raw"; + + EXPECT_EQ(Expected, Actual.str()); +} + +TEST(MDGeneratorTest, emitEnumMD) { + EnumInfo I; + I.Name = "e"; +
[PATCH] D53083: [clang-doc] Add unit tests for merging
This revision was automatically updated to reflect the committed changes. Closed by commit rL344652: [clang-doc] Add unit tests for merging (authored by juliehockett, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D53083?vs=169014=169909#toc Repository: rL LLVM https://reviews.llvm.org/D53083 Files: clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt clang-tools-extra/trunk/unittests/clang-doc/MergeTest.cpp Index: clang-tools-extra/trunk/unittests/clang-doc/MergeTest.cpp === --- clang-tools-extra/trunk/unittests/clang-doc/MergeTest.cpp +++ clang-tools-extra/trunk/unittests/clang-doc/MergeTest.cpp @@ -0,0 +1,236 @@ +//===-- clang-doc/MergeTest.cpp ---===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "ClangDocTest.h" +#include "Representation.h" +#include "gtest/gtest.h" + +namespace clang { +namespace doc { + +TEST(MergeTest, mergeNamespaceInfos) { + NamespaceInfo One; + One.Name = "Namespace"; + One.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + One.ChildNamespaces.emplace_back(NonEmptySID, "ChildNamespace", + InfoType::IT_namespace); + One.ChildRecords.emplace_back(NonEmptySID, "ChildStruct", +InfoType::IT_record); + One.ChildFunctions.emplace_back(); + One.ChildFunctions.back().Name = "OneFunction"; + One.ChildFunctions.back().USR = NonEmptySID; + One.ChildEnums.emplace_back(); + One.ChildEnums.back().Name = "OneEnum"; + One.ChildEnums.back().USR = NonEmptySID; + + NamespaceInfo Two; + Two.Name = "Namespace"; + Two.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + Two.ChildNamespaces.emplace_back(EmptySID, "OtherChildNamespace", + InfoType::IT_namespace); + Two.ChildRecords.emplace_back(EmptySID, "OtherChildStruct", +InfoType::IT_record); + Two.ChildFunctions.emplace_back(); + Two.ChildFunctions.back().Name = "TwoFunction"; + Two.ChildEnums.emplace_back(); + Two.ChildEnums.back().Name = "TwoEnum"; + + std::vector> Infos; + Infos.emplace_back(llvm::make_unique(std::move(One))); + Infos.emplace_back(llvm::make_unique(std::move(Two))); + + auto Expected = llvm::make_unique(); + Expected->Name = "Namespace"; + Expected->Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + Expected->ChildNamespaces.emplace_back(NonEmptySID, "ChildNamespace", + InfoType::IT_namespace); + Expected->ChildRecords.emplace_back(NonEmptySID, "ChildStruct", + InfoType::IT_record); + Expected->ChildNamespaces.emplace_back(EmptySID, "OtherChildNamespace", + InfoType::IT_namespace); + Expected->ChildRecords.emplace_back(EmptySID, "OtherChildStruct", + InfoType::IT_record); + Expected->ChildFunctions.emplace_back(); + Expected->ChildFunctions.back().Name = "OneFunction"; + Expected->ChildFunctions.back().USR = NonEmptySID; + Expected->ChildFunctions.emplace_back(); + Expected->ChildFunctions.back().Name = "TwoFunction"; + Expected->ChildEnums.emplace_back(); + Expected->ChildEnums.back().Name = "OneEnum"; + Expected->ChildEnums.back().USR = NonEmptySID; + Expected->ChildEnums.emplace_back(); + Expected->ChildEnums.back().Name = "TwoEnum"; + + auto Actual = mergeInfos(Infos); + assert(Actual); + CheckNamespaceInfo(InfoAsNamespace(Expected.get()), + InfoAsNamespace(Actual.get().get())); +} + +TEST(MergeTest, mergeRecordInfos) { + RecordInfo One; + One.Name = "r"; + One.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + One.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); + + One.Members.emplace_back("int", "X", AccessSpecifier::AS_private); + One.TagType = TagTypeKind::TTK_Class; + One.Parents.emplace_back(EmptySID, "F", InfoType::IT_record); + One.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); + + One.ChildRecords.emplace_back(NonEmptySID, "ChildStruct", +InfoType::IT_record); + One.ChildFunctions.emplace_back(); + One.ChildFunctions.back().Name = "OneFunction"; + One.ChildFunctions.back().USR = NonEmptySID; + One.ChildEnums.emplace_back(); + One.ChildEnums.back().Name = "OneEnum"; + One.ChildEnums.back().USR = NonEmptySID; + + RecordInfo Two; + Two.Name = "r"; + Two.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + Two.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); + + Two.TagType = TagTypeKind::TTK_Class; + +
[PATCH] D52784: [ARM][AArch64] Pass through endianness flags to the GNU assembler and linker
nickdesaulniers added a comment. Thanks again for this patch! Repository: rC Clang https://reviews.llvm.org/D52784 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r344653 - [clang-doc] Add unit tests for YAML generation
Author: juliehockett Date: Tue Oct 16 16:07:16 2018 New Revision: 344653 URL: http://llvm.org/viewvc/llvm-project?rev=344653=rev Log: [clang-doc] Add unit tests for YAML generation Adds unit tests for the YAML generator library. This is part of a move to convert clang-doc's tests to a more maintainable unit test framework, with a smaller number of integration tests to maintain and more granular failure feedback. Differential Revision: https://reviews.llvm.org/D53084 Added: clang-tools-extra/trunk/unittests/clang-doc/YAMLGeneratorTest.cpp Modified: clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt Modified: clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt?rev=344653=344652=344653=diff == --- clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt (original) +++ clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt Tue Oct 16 16:07:16 2018 @@ -15,6 +15,7 @@ add_extra_unittest(ClangDocTests ClangDocTest.cpp MergeTest.cpp SerializeTest.cpp + YAMLGeneratorTest.cpp ) target_link_libraries(ClangDocTests Added: clang-tools-extra/trunk/unittests/clang-doc/YAMLGeneratorTest.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-doc/YAMLGeneratorTest.cpp?rev=344653=auto == --- clang-tools-extra/trunk/unittests/clang-doc/YAMLGeneratorTest.cpp (added) +++ clang-tools-extra/trunk/unittests/clang-doc/YAMLGeneratorTest.cpp Tue Oct 16 16:07:16 2018 @@ -0,0 +1,427 @@ +//===-- clang-doc/YAMLGeneratorTest.cpp +//===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "ClangDocTest.h" +#include "Generators.h" +#include "Representation.h" +#include "gtest/gtest.h" + +namespace clang { +namespace doc { + +std::unique_ptr getYAMLGenerator() { + auto G = doc::findGeneratorByName("yaml"); + if (!G) +return nullptr; + return std::move(G.get()); +} + +TEST(YAMLGeneratorTest, emitNamespaceYAML) { + NamespaceInfo I; + I.Name = "Namespace"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.ChildNamespaces.emplace_back(EmptySID, "ChildNamespace", + InfoType::IT_namespace); + I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record); + I.ChildFunctions.emplace_back(); + I.ChildFunctions.back().Name = "OneFunction"; + I.ChildEnums.emplace_back(); + I.ChildEnums.back().Name = "OneEnum"; + + auto G = getYAMLGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(, Actual); + assert(!Err); + std::string Expected = + R"raw(--- +USR: '' +Name:'Namespace' +Namespace: + - Type:Namespace +Name:'A' +ChildNamespaces: + - Type:Namespace +Name:'ChildNamespace' +ChildRecords: + - Type:Record +Name:'ChildStruct' +ChildFunctions: + - USR: '' +Name:'OneFunction' +ReturnType: +ChildEnums: + - USR: '' +Name:'OneEnum' +... +)raw"; + EXPECT_EQ(Expected, Actual.str()); +} + +TEST(YAMLGeneratorTest, emitRecordYAML) { + RecordInfo I; + I.Name = "r"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); + I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); + + I.Members.emplace_back("int", "X", AccessSpecifier::AS_private); + I.TagType = TagTypeKind::TTK_Class; + I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record); + I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); + + I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record); + I.ChildFunctions.emplace_back(); + I.ChildFunctions.back().Name = "OneFunction"; + I.ChildEnums.emplace_back(); + I.ChildEnums.back().Name = "OneEnum"; + + auto G = getYAMLGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(, Actual); + assert(!Err); + std::string Expected = + R"raw(--- +USR: '' +Name:'r' +Namespace: + - Type:Namespace +Name:'A' +DefLocation: + LineNumber: 10 + Filename:'test.cpp' +Location: + -
[clang-tools-extra] r344654 - [clang-doc] Add unit tests for Markdown generation
Author: juliehockett Date: Tue Oct 16 16:07:26 2018 New Revision: 344654 URL: http://llvm.org/viewvc/llvm-project?rev=344654=rev Log: [clang-doc] Add unit tests for Markdown generation Add unit tests for Markdown generation. This is part of a move to convert clang-doc's tests to a more maintainable unit test framework, with a smaller number of integration tests to maintain and more granular failure feedback. Differential Revision: https://reviews.llvm.org/D53085 Added: clang-tools-extra/trunk/unittests/clang-doc/MDGeneratorTest.cpp Modified: clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt Modified: clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt?rev=344654=344653=344654=diff == --- clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt (original) +++ clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt Tue Oct 16 16:07:26 2018 @@ -13,6 +13,7 @@ include_directories( add_extra_unittest(ClangDocTests BitcodeTest.cpp ClangDocTest.cpp + MDGeneratorTest.cpp MergeTest.cpp SerializeTest.cpp YAMLGeneratorTest.cpp Added: clang-tools-extra/trunk/unittests/clang-doc/MDGeneratorTest.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-doc/MDGeneratorTest.cpp?rev=344654=auto == --- clang-tools-extra/trunk/unittests/clang-doc/MDGeneratorTest.cpp (added) +++ clang-tools-extra/trunk/unittests/clang-doc/MDGeneratorTest.cpp Tue Oct 16 16:07:26 2018 @@ -0,0 +1,361 @@ +//===-- clang-doc/MDGeneratorTest.cpp -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "ClangDocTest.h" +#include "Generators.h" +#include "Representation.h" +#include "gtest/gtest.h" + +namespace clang { +namespace doc { + +std::unique_ptr getMDGenerator() { + auto G = doc::findGeneratorByName("md"); + if (!G) +return nullptr; + return std::move(G.get()); +} + +TEST(MDGeneratorTest, emitNamespaceMD) { + NamespaceInfo I; + I.Name = "Namespace"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.ChildNamespaces.emplace_back(EmptySID, "ChildNamespace", + InfoType::IT_namespace); + I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record); + I.ChildFunctions.emplace_back(); + I.ChildFunctions.back().Name = "OneFunction"; + I.ChildEnums.emplace_back(); + I.ChildEnums.back().Name = "OneEnum"; + + auto G = getMDGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(, Actual); + assert(!Err); + std::string Expected = R"raw(# namespace Namespace + + + +## Namespaces + +ChildNamespace + + + +## Records + +ChildStruct + + + +## Functions + +### OneFunction + +* OneFunction()* + + + +## Enums + +| enum OneEnum | + +-- + + + + + +)raw"; + EXPECT_EQ(Expected, Actual.str()); +} + +TEST(MDGeneratorTest, emitRecordMD) { + RecordInfo I; + I.Name = "r"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); + I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); + + I.Members.emplace_back("int", "X", AccessSpecifier::AS_private); + I.TagType = TagTypeKind::TTK_Class; + I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record); + I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); + + I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record); + I.ChildFunctions.emplace_back(); + I.ChildFunctions.back().Name = "OneFunction"; + I.ChildEnums.emplace_back(); + I.ChildEnums.back().Name = "OneEnum"; + + auto G = getMDGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(, Actual); + assert(!Err); + std::string Expected = R"raw(# class r + +*Defined at line 10 of test.cpp* + +Inherits from F, G + + + +## Members + +private int X + + + +## Records + +ChildStruct + + + +## Functions + +### OneFunction + +* OneFunction()* + + + +## Enums + +| enum OneEnum | + +-- + + + + + +)raw"; + EXPECT_EQ(Expected, Actual.str()); +} + +TEST(MDGeneratorTest, emitFunctionMD) { + FunctionInfo I; + I.Name = "f"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"}); + I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"}); + + I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); + I.Params.emplace_back("int", "P"); + I.IsMethod =
[PATCH] D53081: [clang-doc] Add unit tests for serialization
This revision was automatically updated to reflect the committed changes. Closed by commit rCTE344650: [clang-doc] Add unit tests for serialization (authored by juliehockett, committed by ). Changed prior to commit: https://reviews.llvm.org/D53081?vs=169754=169907#toc Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53081 Files: unittests/CMakeLists.txt unittests/clang-doc/CMakeLists.txt unittests/clang-doc/ClangDocTest.cpp unittests/clang-doc/ClangDocTest.h unittests/clang-doc/SerializeTest.cpp Index: unittests/clang-doc/ClangDocTest.cpp === --- unittests/clang-doc/ClangDocTest.cpp +++ unittests/clang-doc/ClangDocTest.cpp @@ -0,0 +1,182 @@ +//===-- clang-doc/ClangDocTest.cpp ===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "Representation.h" +#include "clang/AST/RecursiveASTVisitor.h" +#include "gtest/gtest.h" + +namespace clang { +namespace doc { + +NamespaceInfo *InfoAsNamespace(Info *I) { + assert(I->IT == InfoType::IT_namespace); + return static_cast(I); +} + +RecordInfo *InfoAsRecord(Info *I) { + assert(I->IT == InfoType::IT_record); + return static_cast(I); +} + +FunctionInfo *InfoAsFunction(Info *I) { + assert(I->IT == InfoType::IT_function); + return static_cast(I); +} + +EnumInfo *InfoAsEnum(Info *I) { + assert(I->IT == InfoType::IT_enum); + return static_cast(I); +} + +void CheckCommentInfo(CommentInfo , CommentInfo ) { + EXPECT_EQ(Expected.Kind, Actual.Kind); + EXPECT_EQ(Expected.Text, Actual.Text); + EXPECT_EQ(Expected.Name, Actual.Name); + EXPECT_EQ(Expected.Direction, Actual.Direction); + EXPECT_EQ(Expected.ParamName, Actual.ParamName); + EXPECT_EQ(Expected.CloseName, Actual.CloseName); + EXPECT_EQ(Expected.SelfClosing, Actual.SelfClosing); + EXPECT_EQ(Expected.Explicit, Actual.Explicit); + + ASSERT_EQ(Expected.AttrKeys.size(), Actual.AttrKeys.size()); + for (size_t Idx = 0; Idx < Actual.AttrKeys.size(); ++Idx) +EXPECT_EQ(Expected.AttrKeys[Idx], Actual.AttrKeys[Idx]); + + ASSERT_EQ(Expected.AttrValues.size(), Actual.AttrValues.size()); + for (size_t Idx = 0; Idx < Actual.AttrValues.size(); ++Idx) +EXPECT_EQ(Expected.AttrValues[Idx], Actual.AttrValues[Idx]); + + ASSERT_EQ(Expected.Args.size(), Actual.Args.size()); + for (size_t Idx = 0; Idx < Actual.Args.size(); ++Idx) +EXPECT_EQ(Expected.Args[Idx], Actual.Args[Idx]); + + ASSERT_EQ(Expected.Children.size(), Actual.Children.size()); + for (size_t Idx = 0; Idx < Actual.Children.size(); ++Idx) +CheckCommentInfo(*Expected.Children[Idx], *Actual.Children[Idx]); +} + +void CheckReference(Reference , Reference ) { + EXPECT_EQ(Expected.Name, Actual.Name); + EXPECT_EQ(Expected.RefType, Actual.RefType); +} + +void CheckTypeInfo(TypeInfo *Expected, TypeInfo *Actual) { + CheckReference(Expected->Type, Actual->Type); +} + +void CheckFieldTypeInfo(FieldTypeInfo *Expected, FieldTypeInfo *Actual) { + CheckTypeInfo(Expected, Actual); + EXPECT_EQ(Expected->Name, Actual->Name); +} + +void CheckMemberTypeInfo(MemberTypeInfo *Expected, MemberTypeInfo *Actual) { + CheckFieldTypeInfo(Expected, Actual); + EXPECT_EQ(Expected->Access, Actual->Access); +} + +void CheckBaseInfo(Info *Expected, Info *Actual) { + EXPECT_EQ(size_t(20), Actual->USR.size()); + EXPECT_EQ(Expected->Name, Actual->Name); + ASSERT_EQ(Expected->Namespace.size(), Actual->Namespace.size()); + for (size_t Idx = 0; Idx < Actual->Namespace.size(); ++Idx) +CheckReference(Expected->Namespace[Idx], Actual->Namespace[Idx]); + ASSERT_EQ(Expected->Description.size(), Actual->Description.size()); + for (size_t Idx = 0; Idx < Actual->Description.size(); ++Idx) +CheckCommentInfo(Expected->Description[Idx], Actual->Description[Idx]); +} + +void CheckSymbolInfo(SymbolInfo *Expected, SymbolInfo *Actual) { + CheckBaseInfo(Expected, Actual); + EXPECT_EQ(Expected->DefLoc.hasValue(), Actual->DefLoc.hasValue()); + if (Expected->DefLoc.hasValue() && Actual->DefLoc.hasValue()) { +EXPECT_EQ(Expected->DefLoc->LineNumber, Actual->DefLoc->LineNumber); +EXPECT_EQ(Expected->DefLoc->Filename, Actual->DefLoc->Filename); + } + ASSERT_EQ(Expected->Loc.size(), Actual->Loc.size()); + for (size_t Idx = 0; Idx < Actual->Loc.size(); ++Idx) +EXPECT_EQ(Expected->Loc[Idx], Actual->Loc[Idx]); +} + +void CheckFunctionInfo(FunctionInfo *Expected, FunctionInfo *Actual) { + CheckSymbolInfo(Expected, Actual); + + EXPECT_EQ(Expected->IsMethod, Actual->IsMethod); + CheckReference(Expected->Parent, Actual->Parent); + CheckTypeInfo(>ReturnType, >ReturnType); + + ASSERT_EQ(Expected->Params.size(), Actual->Params.size()); + for (size_t Idx = 0; Idx < Actual->Params.size(); ++Idx) +
[clang-tools-extra] r344652 - [clang-doc] Add unit tests for merging
Author: juliehockett Date: Tue Oct 16 16:07:04 2018 New Revision: 344652 URL: http://llvm.org/viewvc/llvm-project?rev=344652=rev Log: [clang-doc] Add unit tests for merging Adds unit tests for the merging logic in Respresentation.cpp. This is part of a move to convert clang-doc's tests to a more maintainable unit test framework, with a smaller number of integration tests to maintain and more granular failure feedback. Differential Revision: https://reviews.llvm.org/D53083 Added: clang-tools-extra/trunk/unittests/clang-doc/MergeTest.cpp Modified: clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt Modified: clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt?rev=344652=344651=344652=diff == --- clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt (original) +++ clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt Tue Oct 16 16:07:04 2018 @@ -13,6 +13,7 @@ include_directories( add_extra_unittest(ClangDocTests BitcodeTest.cpp ClangDocTest.cpp + MergeTest.cpp SerializeTest.cpp ) Added: clang-tools-extra/trunk/unittests/clang-doc/MergeTest.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-doc/MergeTest.cpp?rev=344652=auto == --- clang-tools-extra/trunk/unittests/clang-doc/MergeTest.cpp (added) +++ clang-tools-extra/trunk/unittests/clang-doc/MergeTest.cpp Tue Oct 16 16:07:04 2018 @@ -0,0 +1,236 @@ +//===-- clang-doc/MergeTest.cpp ---===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "ClangDocTest.h" +#include "Representation.h" +#include "gtest/gtest.h" + +namespace clang { +namespace doc { + +TEST(MergeTest, mergeNamespaceInfos) { + NamespaceInfo One; + One.Name = "Namespace"; + One.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + One.ChildNamespaces.emplace_back(NonEmptySID, "ChildNamespace", + InfoType::IT_namespace); + One.ChildRecords.emplace_back(NonEmptySID, "ChildStruct", +InfoType::IT_record); + One.ChildFunctions.emplace_back(); + One.ChildFunctions.back().Name = "OneFunction"; + One.ChildFunctions.back().USR = NonEmptySID; + One.ChildEnums.emplace_back(); + One.ChildEnums.back().Name = "OneEnum"; + One.ChildEnums.back().USR = NonEmptySID; + + NamespaceInfo Two; + Two.Name = "Namespace"; + Two.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + Two.ChildNamespaces.emplace_back(EmptySID, "OtherChildNamespace", + InfoType::IT_namespace); + Two.ChildRecords.emplace_back(EmptySID, "OtherChildStruct", +InfoType::IT_record); + Two.ChildFunctions.emplace_back(); + Two.ChildFunctions.back().Name = "TwoFunction"; + Two.ChildEnums.emplace_back(); + Two.ChildEnums.back().Name = "TwoEnum"; + + std::vector> Infos; + Infos.emplace_back(llvm::make_unique(std::move(One))); + Infos.emplace_back(llvm::make_unique(std::move(Two))); + + auto Expected = llvm::make_unique(); + Expected->Name = "Namespace"; + Expected->Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + Expected->ChildNamespaces.emplace_back(NonEmptySID, "ChildNamespace", + InfoType::IT_namespace); + Expected->ChildRecords.emplace_back(NonEmptySID, "ChildStruct", + InfoType::IT_record); + Expected->ChildNamespaces.emplace_back(EmptySID, "OtherChildNamespace", + InfoType::IT_namespace); + Expected->ChildRecords.emplace_back(EmptySID, "OtherChildStruct", + InfoType::IT_record); + Expected->ChildFunctions.emplace_back(); + Expected->ChildFunctions.back().Name = "OneFunction"; + Expected->ChildFunctions.back().USR = NonEmptySID; + Expected->ChildFunctions.emplace_back(); + Expected->ChildFunctions.back().Name = "TwoFunction"; + Expected->ChildEnums.emplace_back(); + Expected->ChildEnums.back().Name = "OneEnum"; + Expected->ChildEnums.back().USR = NonEmptySID; + Expected->ChildEnums.emplace_back(); + Expected->ChildEnums.back().Name = "TwoEnum"; + + auto Actual = mergeInfos(Infos); + assert(Actual); + CheckNamespaceInfo(InfoAsNamespace(Expected.get()), + InfoAsNamespace(Actual.get().get())); +} + +TEST(MergeTest, mergeRecordInfos) { + RecordInfo One; + One.Name = "r"; + One.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + One.DefLoc =
[clang-tools-extra] r344650 - [clang-doc] Add unit tests for serialization
Author: juliehockett Date: Tue Oct 16 16:06:42 2018 New Revision: 344650 URL: http://llvm.org/viewvc/llvm-project?rev=344650=rev Log: [clang-doc] Add unit tests for serialization Adds unit tests for the Serialize library. This is part of a move to convert clang-doc's tests to a more maintainable unit test framework, with a smaller number of integration tests to maintain and more granular failure feedback. Differential Revision: https://reviews.llvm.org/D53081 Added: clang-tools-extra/trunk/unittests/clang-doc/ clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt clang-tools-extra/trunk/unittests/clang-doc/ClangDocTest.cpp clang-tools-extra/trunk/unittests/clang-doc/ClangDocTest.h clang-tools-extra/trunk/unittests/clang-doc/SerializeTest.cpp Modified: clang-tools-extra/trunk/unittests/CMakeLists.txt Modified: clang-tools-extra/trunk/unittests/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/CMakeLists.txt?rev=344650=344649=344650=diff == --- clang-tools-extra/trunk/unittests/CMakeLists.txt (original) +++ clang-tools-extra/trunk/unittests/CMakeLists.txt Tue Oct 16 16:06:42 2018 @@ -16,6 +16,7 @@ endif() add_subdirectory(change-namespace) add_subdirectory(clang-apply-replacements) +add_subdirectory(clang-doc) add_subdirectory(clang-move) add_subdirectory(clang-query) add_subdirectory(clang-tidy) Added: clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt?rev=344650=auto == --- clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt (added) +++ clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt Tue Oct 16 16:06:42 2018 @@ -0,0 +1,29 @@ +set(LLVM_LINK_COMPONENTS + support + BitReader + BitWriter + ) + +get_filename_component(CLANG_DOC_SOURCE_DIR + ${CMAKE_CURRENT_SOURCE_DIR}/../../clang-doc REALPATH) +include_directories( + ${CLANG_DOC_SOURCE_DIR} + ) + +add_extra_unittest(ClangDocTests + ClangDocTest.cpp + SerializeTest.cpp + ) + +target_link_libraries(ClangDocTests + PRIVATE + clangAST + clangASTMatchers + clangBasic + clangDoc + clangFormat + clangFrontend + clangRewrite + clangTooling + clangToolingCore + ) Added: clang-tools-extra/trunk/unittests/clang-doc/ClangDocTest.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-doc/ClangDocTest.cpp?rev=344650=auto == --- clang-tools-extra/trunk/unittests/clang-doc/ClangDocTest.cpp (added) +++ clang-tools-extra/trunk/unittests/clang-doc/ClangDocTest.cpp Tue Oct 16 16:06:42 2018 @@ -0,0 +1,182 @@ +//===-- clang-doc/ClangDocTest.cpp ===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "Representation.h" +#include "clang/AST/RecursiveASTVisitor.h" +#include "gtest/gtest.h" + +namespace clang { +namespace doc { + +NamespaceInfo *InfoAsNamespace(Info *I) { + assert(I->IT == InfoType::IT_namespace); + return static_cast(I); +} + +RecordInfo *InfoAsRecord(Info *I) { + assert(I->IT == InfoType::IT_record); + return static_cast(I); +} + +FunctionInfo *InfoAsFunction(Info *I) { + assert(I->IT == InfoType::IT_function); + return static_cast(I); +} + +EnumInfo *InfoAsEnum(Info *I) { + assert(I->IT == InfoType::IT_enum); + return static_cast(I); +} + +void CheckCommentInfo(CommentInfo , CommentInfo ) { + EXPECT_EQ(Expected.Kind, Actual.Kind); + EXPECT_EQ(Expected.Text, Actual.Text); + EXPECT_EQ(Expected.Name, Actual.Name); + EXPECT_EQ(Expected.Direction, Actual.Direction); + EXPECT_EQ(Expected.ParamName, Actual.ParamName); + EXPECT_EQ(Expected.CloseName, Actual.CloseName); + EXPECT_EQ(Expected.SelfClosing, Actual.SelfClosing); + EXPECT_EQ(Expected.Explicit, Actual.Explicit); + + ASSERT_EQ(Expected.AttrKeys.size(), Actual.AttrKeys.size()); + for (size_t Idx = 0; Idx < Actual.AttrKeys.size(); ++Idx) +EXPECT_EQ(Expected.AttrKeys[Idx], Actual.AttrKeys[Idx]); + + ASSERT_EQ(Expected.AttrValues.size(), Actual.AttrValues.size()); + for (size_t Idx = 0; Idx < Actual.AttrValues.size(); ++Idx) +EXPECT_EQ(Expected.AttrValues[Idx], Actual.AttrValues[Idx]); + + ASSERT_EQ(Expected.Args.size(), Actual.Args.size()); + for (size_t Idx = 0; Idx < Actual.Args.size(); ++Idx) +EXPECT_EQ(Expected.Args[Idx], Actual.Args[Idx]); + + ASSERT_EQ(Expected.Children.size(), Actual.Children.size()); + for (size_t Idx = 0; Idx < Actual.Children.size(); ++Idx) +CheckCommentInfo(*Expected.Children[Idx],
[PATCH] D53344: [Driver] Use --warn-shared-textrel for Android.
danalbert created this revision. danalbert added a reviewer: srhines. Android does not allow shared text relocations. Enable the linker warning to detect them by default. Repository: rC Clang https://reviews.llvm.org/D53344 Files: lib/Driver/ToolChains/Gnu.cpp test/Driver/linux-ld.c Index: test/Driver/linux-ld.c === --- test/Driver/linux-ld.c +++ test/Driver/linux-ld.c @@ -989,7 +989,13 @@ // RUN: | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-M %s // CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}" // CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu" -// + +// RUN: %clang %s -### -o %t.o 2>&1 \ +// RUN: --target=armv7-linux-android21 \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-WARN-SHARED-TEXTREL %s +// CHECK-ANDROID-WARN-SHARED-TEXTREL: "{{.*}}ld{{(.exe)?}}" +// CHECK-ANDROID-WARN-SHARED-TEXTREL: "--warn-shared-textrel" + // RUN: %clang %s -### -o %t.o 2>&1 --target=mips64-linux-gnuabin32 \ // RUN: | FileCheck --check-prefix=CHECK-MIPS64EL-GNUABIN32 %s // CHECK-MIPS64EL-GNUABIN32: "{{.*}}ld{{(.exe)?}}" Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -375,6 +375,11 @@ CmdArgs.push_back("--fix-cortex-a53-843419"); } + // Android does not allow shared text relocations. Emit a warning if the + // user's code contains any. + if (isAndroid) + CmdArgs.push_back("--warn-shared-textrel"); + for (const auto : ToolChain.ExtraOpts) CmdArgs.push_back(Opt.c_str()); Index: test/Driver/linux-ld.c === --- test/Driver/linux-ld.c +++ test/Driver/linux-ld.c @@ -989,7 +989,13 @@ // RUN: | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-M %s // CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}" // CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu" -// + +// RUN: %clang %s -### -o %t.o 2>&1 \ +// RUN: --target=armv7-linux-android21 \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-WARN-SHARED-TEXTREL %s +// CHECK-ANDROID-WARN-SHARED-TEXTREL: "{{.*}}ld{{(.exe)?}}" +// CHECK-ANDROID-WARN-SHARED-TEXTREL: "--warn-shared-textrel" + // RUN: %clang %s -### -o %t.o 2>&1 --target=mips64-linux-gnuabin32 \ // RUN: | FileCheck --check-prefix=CHECK-MIPS64EL-GNUABIN32 %s // CHECK-MIPS64EL-GNUABIN32: "{{.*}}ld{{(.exe)?}}" Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -375,6 +375,11 @@ CmdArgs.push_back("--fix-cortex-a53-843419"); } + // Android does not allow shared text relocations. Emit a warning if the + // user's code contains any. + if (isAndroid) + CmdArgs.push_back("--warn-shared-textrel"); + for (const auto : ToolChain.ExtraOpts) CmdArgs.push_back(Opt.c_str()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52742: [analyzer][PlistMacroExpansion] Part 1.: New expand-macros flag
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp:469 +DisplayMacroExpansions = +getBooleanOption("expand-macros", /*Default=*/false); + return DisplayMacroExpansions.getValue(); Should we say something about plists in the option name? Comment at: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist:44-54 + + kindmacro_expansion + location + + line26 + col3 + file0 Because we're adding an element of an `` rather than a key of a ``, I'm not entirely sure this is backwards compatible. Clients may crash if they iterate over the `path` array and encounter an unexpected element kind. Is it going to be bad for your use case if we put expansions into a separate array alongside the `path` array? https://reviews.llvm.org/D52742 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52750: [Diagnostics] Check for integer overflow in array size expressions
xbolva00 added a comment. Reping :) https://reviews.llvm.org/D52750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53343: [Driver] Default Android toolchains to noexecstack.
danalbert created this revision. danalbert added a reviewer: srhines. Android does not support executable stacks. Repository: rC Clang https://reviews.llvm.org/D53343 Files: include/clang/Driver/ToolChain.h lib/Driver/ToolChain.cpp lib/Driver/ToolChains/Clang.cpp lib/Driver/ToolChains/Gnu.cpp lib/Driver/ToolChains/Linux.cpp lib/Driver/ToolChains/Linux.h test/Driver/integrated-as.c test/Driver/linux-as.c test/Driver/linux-ld.c Index: test/Driver/linux-ld.c === --- test/Driver/linux-ld.c +++ test/Driver/linux-ld.c @@ -989,6 +989,15 @@ // RUN: | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-M %s // CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}" // CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu" + +// RUN: %clang %s -### -o %t.o 2>&1 \ +// RUN: --target=armv7-linux-android21 \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-NOEXECSTACK %s +// CHECK-ANDROID-NOEXECSTACK: "{{.*}}ld{{(.exe)?}}" +// CHECK-ANDROID-NOEXECSTACK: "-z" "noexecstack" +// CHECK-ANDROID-NOEXECSTACK-NOT: "-z" "execstack" +// CHECK-ANDROID-NOEXECSTACK-NOT: "-z,execstack" +// CHECK-ANDROID-NOEXECSTACK-NOT: "-zexecstack" // // RUN: %clang %s -### -o %t.o 2>&1 --target=mips64-linux-gnuabin32 \ // RUN: | FileCheck --check-prefix=CHECK-MIPS64EL-GNUABIN32 %s Index: test/Driver/linux-as.c === --- test/Driver/linux-as.c +++ test/Driver/linux-as.c @@ -108,12 +108,12 @@ // RUN: %clang -target arm-linux-androideabi -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-ARM-ANDROID %s -// CHECK-ARM-ANDROID: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" +// CHECK-ARM-ANDROID: as{{(.exe)?}}" "--noexecstack" "-EL" "-mfloat-abi=soft" // // RUN: %clang -target arm-linux-androideabi -march=armv7-a -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-ARM-ANDROID-SOFTFP %s -// CHECK-ARM-ANDROID-SOFTFP: as{{(.exe)?}}" "-EL" "-mfloat-abi=softfp" "-march=armv7-a" +// CHECK-ARM-ANDROID-SOFTFP: as{{(.exe)?}}" "--noexecstack" "-EL" "-mfloat-abi=softfp" "-march=armv7-a" // // RUN: %clang -target arm-linux-eabi -mhard-float -### \ // RUN: -no-integrated-as -c %s 2>&1 \ Index: test/Driver/integrated-as.c === --- test/Driver/integrated-as.c +++ test/Driver/integrated-as.c @@ -13,3 +13,8 @@ // NOFIAS-NOT: cc1as // NOFIAS: -cc1 // NOFIAS: -no-integrated-as + +// RUN: %clang -target arm-linux-androideabi -### \ +// RUN: -integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-ARM-ANDROID %s +// CHECK-ARM-ANDROID: "-mnoexecstack" Index: lib/Driver/ToolChains/Linux.h === --- lib/Driver/ToolChains/Linux.h +++ lib/Driver/ToolChains/Linux.h @@ -38,6 +38,7 @@ void AddIAMCUIncludeArgs(const llvm::opt::ArgList , llvm::opt::ArgStringList ) const override; bool isPIEDefault() const override; + bool isNoExecStackDefault() const override; bool IsMathErrnoDefault() const override; SanitizerMask getSupportedSanitizers() const override; void addProfileRTLibs(const llvm::opt::ArgList , Index: lib/Driver/ToolChains/Linux.cpp === --- lib/Driver/ToolChains/Linux.cpp +++ lib/Driver/ToolChains/Linux.cpp @@ -955,6 +955,10 @@ getTriple().isMusl() || getSanitizerArgs().requiresPIE(); } +bool Linux::isNoExecStackDefault() const { +return getTriple().isAndroid(); +} + bool Linux::IsMathErrnoDefault() const { if (getTriple().isAndroid()) return false; Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -353,6 +353,11 @@ if (IsPIE) CmdArgs.push_back("-pie"); + if (ToolChain.isNoExecStackDefault()) { +CmdArgs.push_back("-z"); +CmdArgs.push_back("noexecstack"); + } + if (Args.hasArg(options::OPT_rdynamic)) CmdArgs.push_back("-export-dynamic"); @@ -599,6 +604,10 @@ } } + if (getToolChain().isNoExecStackDefault()) { + CmdArgs.push_back("--noexecstack"); + } + switch (getToolChain().getArch()) { default: break; Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -1933,6 +1933,7 @@ bool TakeNextArg = false; bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations(); + bool UseNoExecStack = C.getDefaultToolChain().isNoExecStackDefault(); const char *MipsTargetFeature = nullptr; for (const Arg *A : Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) { @@ -2014,7 +2015,7 @@ } else if (Value == "--fatal-warnings") {
[PATCH] D53200: [OpenCL] Fix serialization of OpenCLExtensionDecls
JDevlieghere added a comment. The patch looks fine but since I don't know much about opencl I'll leave the LGTM to someone that actually knows this code. Comment at: test/Headers/opencl-pragma-extension-begin.h:1 + +#pragma OPENCL EXTENSION cl_my_ext : begin Is this newline intentional? https://reviews.llvm.org/D53200 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52320: AMDGPU: add __builtin_amdgcn_update_dpp
yaxunl added a comment. Brian checked the extra argument for dpp mov should be the first one. so mov_dpp(x,...) --> update_dpp(undef, x, ...). I will fix that when committing. https://reviews.llvm.org/D52320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52320: AMDGPU: add __builtin_amdgcn_update_dpp
arsenm accepted this revision. arsenm added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D52320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52000: Feedback/direction Review for cpu-dispatch emit stage into GlobalDecl
erichkeane abandoned this revision. erichkeane added a comment. Herald added a subscriber: nhaehnle. Superseding with a version that seems to work Repository: rC Clang https://reviews.llvm.org/D52000 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53341: Add MV-index to GlobalDecl, spread GlobalDecl through CodeGen (CPU-Dispatch cleanup)
erichkeane created this revision. erichkeane added reviewers: rsmith, aaron.ballman, echristo. Herald added subscribers: nhaehnle, arphaman. As brought up by Richard Smith on https://reviews.llvm.org/D51650: Sorry, I don't think it's acceptable from a design perspective to have mutable state in an Attr object, even if you can ensure that only one client of the Attr will be using the state at a time. CodeGen is going to need to track its own index into the attribute's list of clones. The proposed fix was to put it into GlobalDecl, which this patch does. However, doing this also requires making GlobalDecl be passed around more often instead of FunctionDecl, so this does that as well. https://reviews.llvm.org/D53341 Files: include/clang/AST/GlobalDecl.h include/clang/Basic/Attr.td lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGBuiltin.cpp lib/CodeGen/CGCXX.cpp lib/CodeGen/CGCall.cpp lib/CodeGen/CGCall.h lib/CodeGen/CGClass.cpp lib/CodeGen/CGException.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CGExprCXX.cpp lib/CodeGen/CGNonTrivialStruct.cpp lib/CodeGen/CGVTables.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/CodeGenFunction.h lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h lib/CodeGen/ItaniumCXXABI.cpp lib/CodeGen/MicrosoftCXXABI.cpp Index: lib/CodeGen/MicrosoftCXXABI.cpp === --- lib/CodeGen/MicrosoftCXXABI.cpp +++ lib/CodeGen/MicrosoftCXXABI.cpp @@ -1552,9 +1552,9 @@ if (Type == Dtor_Complete && DD->getParent()->getNumVBases() == 0) Type = Dtor_Base; - CGCallee Callee = CGCallee::forDirect( - CGM.getAddrOfCXXStructor(DD, getFromDtorType(Type)), -DD); + CGCallee Callee = + CGCallee::forDirect(CGM.getAddrOfCXXStructor(DD, getFromDtorType(Type)), + GlobalDecl(DD, Type)); if (DD->isVirtual()) { assert(Type != CXXDtorType::Dtor_Deleting && @@ -1872,7 +1872,7 @@ VFunc = Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign()); } - CGCallee Callee(MethodDecl->getCanonicalDecl(), VFunc); + CGCallee Callee(GD, VFunc); return Callee; } @@ -3956,7 +3956,8 @@ // Call the destructor with our arguments. llvm::Constant *CalleePtr = CGM.getAddrOfCXXStructor(CD, StructorType::Complete); - CGCallee Callee = CGCallee::forDirect(CalleePtr, CD); + CGCallee Callee = + CGCallee::forDirect(CalleePtr, GlobalDecl(CD, Ctor_Complete)); const CGFunctionInfo = CGM.getTypes().arrangeCXXConstructorCall( Args, CD, Ctor_Complete, ExtraArgs.Prefix, ExtraArgs.Suffix); CGF.EmitCall(CalleeInfo, Callee, ReturnValueSlot(), Args); Index: lib/CodeGen/ItaniumCXXABI.cpp === --- lib/CodeGen/ItaniumCXXABI.cpp +++ lib/CodeGen/ItaniumCXXABI.cpp @@ -1562,9 +1562,8 @@ Type != Dtor_Base && DD->isVirtual()) Callee = CGF.BuildAppleKextVirtualDestructorCall(DD, Type, DD->getParent()); else -Callee = - CGCallee::forDirect(CGM.getAddrOfCXXStructor(DD, getFromDtorType(Type)), - DD); +Callee = CGCallee::forDirect( +CGM.getAddrOfCXXStructor(DD, getFromDtorType(Type)), GD); CGF.EmitCXXMemberOrOperatorCall(DD, Callee, ReturnValueSlot(), This.getPointer(), VTT, VTTTy, @@ -1750,7 +1749,7 @@ VFunc = VFuncLoad; } - CGCallee Callee(MethodDecl->getCanonicalDecl(), VFunc); + CGCallee Callee(GD, VFunc); return Callee; } @@ -2418,7 +2417,7 @@ llvm::Function::Create(FnTy, getThreadLocalWrapperLinkage(VD, CGM), WrapperName.str(), ()); - CGM.SetLLVMFunctionAttributes(nullptr, FI, Wrapper); + CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, Wrapper); if (VD->hasDefinition()) CGM.SetLLVMFunctionAttributesForDefinition(nullptr, Wrapper); @@ -2525,7 +2524,8 @@ llvm::GlobalVariable::ExternalWeakLinkage, InitFnName.str(), ()); const CGFunctionInfo = CGM.getTypes().arrangeNullaryFunction(); - CGM.SetLLVMFunctionAttributes(nullptr, FI, cast(Init)); + CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, +cast(Init)); } if (Init) { Index: lib/CodeGen/CodeGenModule.h === --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -1043,8 +1043,7 @@ const CGFunctionInfo ); /// Set the LLVM function attributes (sext, zext, etc). - void SetLLVMFunctionAttributes(const Decl *D, - const CGFunctionInfo , + void SetLLVMFunctionAttributes(GlobalDecl GD, const CGFunctionInfo , llvm::Function *F); /// Set the LLVM function attributes which only apply to a function @@ -1104,8
[PATCH] D53024: [analyzer][www] Add more open projects
NoQ added inline comments. Comment at: clang/www/analyzer/open_projects.html:27-32 +New checkers which were contributed to the analyzer, +but have not passed a rigorous evaluation process, +are committed as "alpha checkers" (from "alpha version"), +and are not enabled by default. + +The development of many such checkers has stalled over the years. george.karpenkov wrote: > NoQ wrote: > > This is extremely important to get right. Alpha doesn't mean "i did an > > experiment, let me dump my code so that it wasn't lost, maybe others will > > pick it up and turn it into a useful checker if they figure out how". Alpha > > doesn't mean "a checker that power-users can use at their own risk when > > they want to find more bugs". Alpha doesn't mean "i think this checker is > > great but maintainers think it's bad so they keep me in alpha but i'm happy > > because i can write in my resume that i'm an llvm contributor". All of > > these are super popular misconceptions. > > > > Alpha means "i'm working on it". That's it. > > > > Let's re-phrase to something like: "When a new checker is being developed > > incrementally, it is committed into clang and is put into the hidden > > "alpha" package (from "alpha version"). Ideally, once all desired > > functionality of the checker is implemented, checker should be moved out of > > the alpha package and become enabled by default or recommended to opt-in > > into, but development of many alpha checkers has stalled over the years." > Let's ignore (3) as a red herring, but I'm not sure I see the difference > between (1), (2) and (4). When someone works actively on a checker, but then > stops, it immediately transfers from state (4) to state (2) and optionally (1) This is kinda mostly about the attitude with which people should put stuff into the `alpha` package. Yeah, if someone stops for inevitable reasons, then we're inevitably left with unmaintained experimental code in the repo, i guess that's why this section exists. But contributors shouldn't plan for this from the start. A lot of contributors literally believe that alpha is by design a stockpile of incomplete work and weird experiments and it'll make everybody happy if they add more incomplete work and weird experiments into it, i myself misunderstood this for a long time and i want to address this misconception. https://reviews.llvm.org/D53024 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53339: Add the abseil-duration-factory-float clang-tidy check
hwright created this revision. hwright added reviewers: alexfh, alexfh_. Herald added a subscriber: mgorny. This check finds cases where calls to an absl::Duration factory could use the more efficient integer overload. For example: // Original - Providing a floating-point literal. absl::Duration d = absl::Seconds(10.0); // Suggested - Use an integer instead. absl::Duration d = absl::Seconds(10); https://reviews.llvm.org/D53339 Files: clang-tidy/abseil/AbseilTidyModule.cpp clang-tidy/abseil/CMakeLists.txt clang-tidy/abseil/DurationFactoryFloatCheck.cpp clang-tidy/abseil/DurationFactoryFloatCheck.h docs/ReleaseNotes.rst docs/clang-tidy/checks/abseil-duration-factory-float.rst docs/clang-tidy/checks/list.rst test/clang-tidy/abseil-duration-factory-float.cpp Index: test/clang-tidy/abseil-duration-factory-float.cpp === --- /dev/null +++ test/clang-tidy/abseil-duration-factory-float.cpp @@ -0,0 +1,104 @@ +// RUN: %check_clang_tidy %s abseil-duration-factory-float %t + +// Mimic the implementation of absl::Duration +namespace absl { + +class Duration {}; + +Duration Nanoseconds(long long); +Duration Microseconds(long long); +Duration Milliseconds(long long); +Duration Seconds(long long); +Duration Minutes(long long); +Duration Hours(long long); + +#define GENERATE_DURATION_FACTORY_OVERLOADS(NAME) \ + Duration NAME(float n); \ + Duration NAME(double n);\ + template\ + Duration NAME(T n); + +GENERATE_DURATION_FACTORY_OVERLOADS(Nanoseconds); +GENERATE_DURATION_FACTORY_OVERLOADS(Microseconds); +GENERATE_DURATION_FACTORY_OVERLOADS(Milliseconds); +GENERATE_DURATION_FACTORY_OVERLOADS(Seconds); +GENERATE_DURATION_FACTORY_OVERLOADS(Minutes); +GENERATE_DURATION_FACTORY_OVERLOADS(Hours); +#undef GENERATE_DURATION_FACTORY_OVERLOADS + +} // namespace absl + +void ConvertFloatTest() { + absl::Duration d; + + d = absl::Seconds(60.0); + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Seconds [abseil-duration-factory-float] + // CHECK-FIXES: absl::Seconds(60); + d = absl::Minutes(300.0); + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Minutes [abseil-duration-factory-float] + // CHECK-FIXES: absl::Minutes(300); + + d = absl::Milliseconds(1e2); + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Milliseconds [abseil-duration-factory-float] + // CHECK-FIXES: absl::Milliseconds(100); + d = absl::Seconds(3.0f); + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Seconds [abseil-duration-factory-float] + // CHECK-FIXES: absl::Seconds(3); + d = absl::Seconds(3.); + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Seconds [abseil-duration-factory-float] + // CHECK-FIXES: absl::Seconds(3); + + // Ignored expressions + d = absl::Seconds(.001); + d = absl::Seconds(.100); + d = ::absl::Seconds(1); + d = ::absl::Minutes(1); + d = ::absl::Hours(1); + + // This is bigger than we can safely fit in a positive int32, so we ignore it. + d = absl::Seconds(1e12); + + int x; + d = absl::Seconds(x); + float y; + d = absl::Minutes(y); + +#define SECONDS(x) absl::Seconds(x) + SECONDS(60); +#undef SECONDS +#define THIRTY 30.0 + d = absl::Seconds(THIRTY); +#undef THIRTY +} + +template +void InTemplate() { + absl::Duration d; + + d = absl::Seconds(N); // 1 + // ^ No replacement here. + + d = absl::Minutes(1.0); // 2 + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Minutes [abseil-duration-factory-float] + // CHECK-FIXES: absl::Minutes(1); // 2 +} + +void Instantiate() { + InTemplate<60>(); + InTemplate<1>(); +} + +void ConvertStaticCastTest() { + absl::Duration d; + + d = absl::Seconds(static_cast(5)); + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Seconds [abseil-duration-factory-float] + // CHECK-FIXES: absl::Seconds(5); + + d = absl::Minutes(static_cast(5)); + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Use integer version of absl::Minutes [abseil-duration-factory-float] + // CHECK-FIXES: absl::Minutes(5); + + // This should not be flagged + d = absl::Seconds(static_cast(5.0)); +} Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -5,12 +5,13 @@ .. toctree:: abseil-duration-division + abseil-duration-factory-float abseil-faster-strsplit-delimiter abseil-no-internal-dependencies abseil-no-namespace abseil-redundant-strcat-calls - abseil-string-find-startswith abseil-str-cat-append + abseil-string-find-startswith android-cloexec-accept android-cloexec-accept4 android-cloexec-creat Index: docs/clang-tidy/checks/abseil-duration-factory-float.rst
[PATCH] D52301: [clang] Set TypeSourceInfo for vardecl's in addition to type when we can deduce.
kadircet updated this revision to Diff 169885. kadircet added a comment. Herald added a subscriber: nhaehnle. rebase Repository: rC Clang https://reviews.llvm.org/D52301 Files: include/clang/AST/PrettyPrinter.h include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/Sema.h lib/AST/TypePrinter.cpp lib/Frontend/ASTConsumers.cpp lib/Sema/SemaChecking.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaLambda.cpp lib/Sema/SemaStmt.cpp lib/Sema/SemaTemplate.cpp lib/Sema/SemaTemplateDeduction.cpp lib/Tooling/Refactoring/Rename/USRLocFinder.cpp test/Analysis/scopes-cfg-output.cpp test/SemaOpenCL/to_addr_builtin.cl Index: test/SemaOpenCL/to_addr_builtin.cl === --- test/SemaOpenCL/to_addr_builtin.cl +++ test/SemaOpenCL/to_addr_builtin.cl @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -verify -fsyntax-only %s -// RUN: %clang_cc1 -Wconversion -verify -fsyntax-only -cl-std=CL2.0 %s +// RUN: %clang_cc1 -verify -fsyntax-only -cl-std=CL2.0 %s void test(void) { global int *glob; @@ -45,7 +45,6 @@ // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}} #else // expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}} - // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}} #endif loc = to_private(glob); @@ -119,7 +118,6 @@ // expected-warning@-2{{incompatible integer to pointer conversion initializing '__global char *' with an expression of type 'int'}} #else // expected-warning@-4{{incompatible pointer types initializing '__global char *' with an expression of type '__global int *'}} - // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}} #endif glob_wrong_ty = to_global(glob); Index: test/Analysis/scopes-cfg-output.cpp === --- test/Analysis/scopes-cfg-output.cpp +++ test/Analysis/scopes-cfg-output.cpp @@ -834,7 +834,7 @@ // CHECK-NEXT: 2: __begin1 // CHECK-NEXT: 3: [B4.2] (ImplicitCastExpr, LValueToRValue, class A *) // CHECK-NEXT: 4: *[B4.3] -// CHECK-NEXT: 5: auto = *__begin1; +// CHECK-NEXT: 5: A = *__begin1; // CHECK-NEXT: 6: operator= // CHECK-NEXT: 7: [B4.6] (ImplicitCastExpr, FunctionToPointerDecay, class A &(*)(const class A &) // CHECK-NEXT: 8: i @@ -849,16 +849,16 @@ // CHECK-NEXT: 2: (CXXConstructExpr, [B5.3], class A [10]) // CHECK-NEXT: 3: A a[10]; // CHECK-NEXT: 4: a -// CHECK-NEXT: 5: auto &&__range1 = a; +// CHECK-NEXT: 5: A (&__range1)[10] = a; // CHECK-NEXT: 6: CFGScopeBegin(__end1) // CHECK-NEXT: 7: __range1 // CHECK-NEXT: 8: [B5.7] (ImplicitCastExpr, ArrayToPointerDecay, class A *) // CHECK-NEXT: 9: 10 // CHECK-NEXT: 10: [B5.8] + [B5.9] -// CHECK-NEXT: 11: auto __end1 = __range1 + 10 +// CHECK-NEXT: 11: A *__end1 = __range1 + 10 // CHECK-NEXT: 12: __range1 // CHECK-NEXT: 13: [B5.12] (ImplicitCastExpr, ArrayToPointerDecay, class A *) -// CHECK-NEXT: 14: auto __begin1 = __range1; +// CHECK-NEXT: 14: A *__begin1 = __range1; // CHECK-NEXT: Preds (1): B6 // CHECK-NEXT: Succs (1): B2 // CHECK: [B0 (EXIT)] Index: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp === --- lib/Tooling/Refactoring/Rename/USRLocFinder.cpp +++ lib/Tooling/Refactoring/Rename/USRLocFinder.cpp @@ -351,6 +351,8 @@ } bool VisitTypeLoc(TypeLoc Loc) { +if(Loc.getTypeLocClass() == TypeLoc::Auto) + return true; auto Parents = Context.getParents(Loc); TypeLoc ParentTypeLoc; if (!Parents.empty()) { Index: lib/Sema/SemaTemplateDeduction.cpp === --- lib/Sema/SemaTemplateDeduction.cpp +++ lib/Sema/SemaTemplateDeduction.cpp @@ -4340,19 +4340,20 @@ return E; } -QualType Apply(TypeLoc TL) { +TypeSourceInfo* Apply(TypeLoc TL) { // Create some scratch storage for the transformed type locations. // FIXME: We're just going to throw this information away. Don't build it. TypeLocBuilder TLB; TLB.reserve(TL.getFullDataSize()); - return TransformType(TLB, TL); + QualType Result = TransformType(TLB, TL); + return TLB.getTypeSourceInfo(getSema().Context, Result); } }; } // namespace Sema::DeduceAutoResult -Sema::DeduceAutoType(TypeSourceInfo *Type, Expr *, QualType , +Sema::DeduceAutoType(TypeSourceInfo *Type, Expr *, TypeSourceInfo *, Optional DependentDeductionDepth) { return DeduceAutoType(Type->getTypeLoc(), Init, Result, DependentDeductionDepth); @@ -4398,7 +4399,7 @@ ///'auto' template parameters. The value specified is the template ///
[PATCH] D52320: AMDGPU: add __builtin_amdgcn_update_dpp
yaxunl updated this revision to Diff 169882. yaxunl edited the summary of this revision. yaxunl added a comment. emit llvm.amdgcn.update.dpp for __builtin_amdgcn_mov_dpp. https://reviews.llvm.org/D52320 Files: include/clang/Basic/BuiltinsAMDGPU.def lib/CodeGen/CGBuiltin.cpp test/CodeGenOpenCL/builtins-amdgcn-vi.cl test/SemaOpenCL/builtins-amdgcn-error.cl Index: test/SemaOpenCL/builtins-amdgcn-error.cl === --- test/SemaOpenCL/builtins-amdgcn-error.cl +++ test/SemaOpenCL/builtins-amdgcn-error.cl @@ -102,6 +102,15 @@ *out = __builtin_amdgcn_mov_dpp(a, 0, 0, 0, e); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}} } +void test_update_dpp2(global int* out, int a, int b, int c, int d, int e, bool f) +{ + *out = __builtin_amdgcn_update_dpp(a, b, 0, 0, 0, false); + *out = __builtin_amdgcn_update_dpp(a, 0, c, 0, 0, false); // expected-error {{argument to '__builtin_amdgcn_update_dpp' must be a constant integer}} + *out = __builtin_amdgcn_update_dpp(a, 0, 0, d, 0, false); // expected-error {{argument to '__builtin_amdgcn_update_dpp' must be a constant integer}} + *out = __builtin_amdgcn_update_dpp(a, 0, 0, 0, e, false); // expected-error {{argument to '__builtin_amdgcn_update_dpp' must be a constant integer}} + *out = __builtin_amdgcn_update_dpp(a, 0, 0, 0, 0, f); // expected-error {{argument to '__builtin_amdgcn_update_dpp' must be a constant integer}} +} + void test_ds_faddf(local float *out, float src, int a) { *out = __builtin_amdgcn_ds_faddf(out, src, a, 0, false); // expected-error {{argument to '__builtin_amdgcn_ds_faddf' must be a constant integer}} *out = __builtin_amdgcn_ds_faddf(out, src, 0, a, false); // expected-error {{argument to '__builtin_amdgcn_ds_faddf' must be a constant integer}} Index: test/CodeGenOpenCL/builtins-amdgcn-vi.cl === --- test/CodeGenOpenCL/builtins-amdgcn-vi.cl +++ test/CodeGenOpenCL/builtins-amdgcn-vi.cl @@ -90,12 +90,19 @@ } // CHECK-LABEL: @test_mov_dpp -// CHECK: call i32 @llvm.amdgcn.mov.dpp.i32(i32 %src, i32 0, i32 0, i32 0, i1 false) +// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 %src, i32 0, i32 0, i32 0, i32 undef, i1 false) void test_mov_dpp(global int* out, int src) { *out = __builtin_amdgcn_mov_dpp(src, 0, 0, 0, false); } +// CHECK-LABEL: @test_update_dpp +// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 %arg1, i32 %arg2, i32 0, i32 0, i32 0, i1 false) +void test_update_dpp(global int* out, int arg1, int arg2) +{ + *out = __builtin_amdgcn_update_dpp(arg1, arg2, 0, 0, 0, false); +} + // CHECK-LABEL: @test_ds_fadd // CHECK: call float @llvm.amdgcn.ds.fadd(float addrspace(3)* %out, float %src, i32 0, i32 0, i1 false) void test_ds_faddf(local float *out, float src) { Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -11347,12 +11347,16 @@ case AMDGPU::BI__builtin_amdgcn_ds_swizzle: return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_ds_swizzle); - case AMDGPU::BI__builtin_amdgcn_mov_dpp: { -llvm::SmallVector Args; -for (unsigned I = 0; I != 5; ++I) + case AMDGPU::BI__builtin_amdgcn_mov_dpp: + case AMDGPU::BI__builtin_amdgcn_update_dpp: { +llvm::SmallVector Args; +for (unsigned I = 0; I != E->getNumArgs(); ++I) Args.push_back(EmitScalarExpr(E->getArg(I))); -Value *F = CGM.getIntrinsic(Intrinsic::amdgcn_mov_dpp, -Args[0]->getType()); +assert(Args.size() == 5 || Args.size() == 6); +if (Args.size() == 5) + Args.insert(Args.begin() + 4, llvm::UndefValue::get(Args[0]->getType())); +Value *F = +CGM.getIntrinsic(Intrinsic::amdgcn_update_dpp, Args[0]->getType()); return Builder.CreateCall(F, Args); } case AMDGPU::BI__builtin_amdgcn_div_fixup: Index: include/clang/Basic/BuiltinsAMDGPU.def === --- include/clang/Basic/BuiltinsAMDGPU.def +++ include/clang/Basic/BuiltinsAMDGPU.def @@ -122,6 +122,7 @@ TARGET_BUILTIN(__builtin_amdgcn_classh, "bhi", "nc", "16-bit-insts") TARGET_BUILTIN(__builtin_amdgcn_s_memrealtime, "LUi", "n", "s-memrealtime") TARGET_BUILTIN(__builtin_amdgcn_mov_dpp, "iiIiIiIiIb", "nc", "dpp") +TARGET_BUILTIN(__builtin_amdgcn_update_dpp, "iiiIiIiIiIb", "nc", "dpp") TARGET_BUILTIN(__builtin_amdgcn_s_dcache_wb, "v", "n", "vi-insts") //===--===// Index: test/SemaOpenCL/builtins-amdgcn-error.cl === --- test/SemaOpenCL/builtins-amdgcn-error.cl +++ test/SemaOpenCL/builtins-amdgcn-error.cl @@ -102,6 +102,15 @@ *out = __builtin_amdgcn_mov_dpp(a, 0, 0, 0, e); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must
[PATCH] D53024: [analyzer][www] Add more open projects
george.karpenkov added inline comments. Herald added a subscriber: dkrupp. Comment at: clang/www/analyzer/open_projects.html:27-32 +New checkers which were contributed to the analyzer, +but have not passed a rigorous evaluation process, +are committed as "alpha checkers" (from "alpha version"), +and are not enabled by default. + +The development of many such checkers has stalled over the years. NoQ wrote: > This is extremely important to get right. Alpha doesn't mean "i did an > experiment, let me dump my code so that it wasn't lost, maybe others will > pick it up and turn it into a useful checker if they figure out how". Alpha > doesn't mean "a checker that power-users can use at their own risk when they > want to find more bugs". Alpha doesn't mean "i think this checker is great > but maintainers think it's bad so they keep me in alpha but i'm happy because > i can write in my resume that i'm an llvm contributor". All of these are > super popular misconceptions. > > Alpha means "i'm working on it". That's it. > > Let's re-phrase to something like: "When a new checker is being developed > incrementally, it is committed into clang and is put into the hidden "alpha" > package (from "alpha version"). Ideally, once all desired functionality of > the checker is implemented, checker should be moved out of the alpha package > and become enabled by default or recommended to opt-in into, but development > of many alpha checkers has stalled over the years." Let's ignore (3) as a red herring, but I'm not sure I see the difference between (1), (2) and (4). When someone works actively on a checker, but then stops, it immediately transfers from state (4) to state (2) and optionally (1) Comment at: clang/www/analyzer/open_projects.html:80 -Handle floating-point values. -Currently, the analyzer treats all floating-point values as unknown. -However, we already have most of the infrastructure we need to handle -floats: RangeConstraintManager. This would involve adding a new SVal kind -for constant floats, generalizing the constraint manager to handle floats -and integers equally, and auditing existing code to make sure it doesn't -make untoward assumptions. - (Difficulty: Medium) - - -Implement generalized loop execution modeling. -Currently, the analyzer simply unrolls each loop N times. This -means that it will not execute any code after the loop if the loop is -guaranteed to execute more than N times. This results in lost -basic block coverage. We could continue exploring the path if we could -model a generic i-th iteration of a loop. - (Difficulty: Hard) + Improved C++ support + NoQ wrote: > I guess let's add the rest of the constructors from my message above. What message above? The original email? https://reviews.llvm.org/D53024 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions
xbolva00 updated this revision to Diff 169881. xbolva00 added a comment. - Added missing test file https://reviews.llvm.org/D52835 Files: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaChecking.cpp test/Sema/ext_vector_casts.c test/Sema/impcast-integer-float.c Index: test/Sema/impcast-integer-float.c === --- test/Sema/impcast-integer-float.c +++ test/Sema/impcast-integer-float.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -verify -Wconversion -fsyntax-only + +#define shift_plus_one(x) ((1ULL << x) + 1) + +void test(void) { +float a1 = (1ULL << 31) + 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'float' changes value from 2147483649 to 2.1474836E+9}} +float a2 = 1ULL << 31; +float a3 = shift_plus_one(31); // expected-warning {{implicit conversion from 'unsigned long long' to 'float' changes value from 2147483649 to 2.1474836E+9}} +float a4 = (1ULL << 31) - 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'float' changes value from 2147483647 to 2.1474836E+9}} + +double b1 = (1ULL << 63) + 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'double' changes value from 9223372036854775809 to 9.223372036854775E+18}} +double b2 = 1ULL << 63; +double b3 = shift_plus_one(63); // expected-warning {{implicit conversion from 'unsigned long long' to 'double' changes value from 9223372036854775809 to 9.223372036854775E+18}} +double b4 = (1ULL << 63) - 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'double' changes value from 9223372036854775807 to 9.223372036854775E+18}} + +long double c1 = ((__int128)1 << 127) + 1; // expected-warning {{implicit conversion from '__int128' to 'long double' changes value from -170141183460469231731687303715884105727 to -1.7014118346046923173E+38}} +long double c2 = (__int128)1 << 127; + +_Float16 d1 = (1ULL << 15) + 1; // expected-warning {{implicit conversion from 'unsigned long long' to '_Float16' changes value from 32769 to 3.277E+4}} +_Float16 d2 = 1ULL << 15; +_Float16 d3 = shift_plus_one(15); // expected-warning {{implicit conversion from 'unsigned long long' to '_Float16' changes value from 32769 to 3.277E+4}} +_Float16 d4 = (1ULL << 15) - 1; // expected-warning {{implicit conversion from 'unsigned long long' to '_Float16' changes value from 32767 to 3.277E+4}} + +float e = (__uint128_t)-1; // expected-warning {{implicit conversion from '__uint128_t' (aka 'unsigned __int128') to 'float' changes value from 340282366920938463463374607431768211455 to +Inf}} +} Index: test/Sema/ext_vector_casts.c === --- test/Sema/ext_vector_casts.c +++ test/Sema/ext_vector_casts.c @@ -118,7 +118,7 @@ vf = l + vf; vf = 2.0 + vf; vf = d + vf; // expected-warning {{implicit conversion loses floating-point precision}} - vf = vf + 0x; + vf = vf + 0x; // expected-warning {{implicit conversion from 'unsigned int' to 'float2' (vector of 2 'float' values) changes value from 4294967295 to 4.2949673E+9}} vf = vf + 2.1; // expected-warning {{implicit conversion loses floating-point precision}} vd = l + vd; Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -105,6 +105,19 @@ Context.getTargetInfo()); } +// FIXME: Force the precision of the source value down so we don't print +// digits which are usually useless (we don't really care here if we +// truncate a digit by accident in edge cases). Ideally, APFloat::toString +// would automatically print the shortest representation, but it's a bit +// tricky to implement. +static void PrettyPrintFloat(const llvm::APFloat , + const llvm::fltSemantics , + SmallVectorImpl ) { + unsigned precision = llvm::APFloat::semanticsPrecision(floatSem); + precision = llvm::divideCeil(precision * 59, 196); + floatValue.toString(prettyFloatValue, precision); +} + /// Checks that a call expression's argument count is the desired number. /// This is useful when doing custom type-checking. Returns true on error. static bool checkArgCount(Sema , CallExpr *call, unsigned desiredArgCount) { @@ -10414,15 +10427,8 @@ DiagID = diag::warn_impcast_float_to_integer; } - // FIXME: Force the precision of the source value down so we don't print - // digits which are usually useless (we don't really care here if we - // truncate a digit by accident in edge cases). Ideally, APFloat::toString - // would automatically print the shortest representation, but it's a bit - // tricky to implement. SmallString<16> PrettySourceValue; - unsigned precision =
[PATCH] D52973: Add type_info predefined decl
mwasplund added a comment. Can you see the full change? I am only seeing that latest commit after running: "git show HEAD -U99 > mypatch.patch". It was working fine with I ran "git diff master..mybranch > mybranch.diff" however that does not give the full context. Repository: rC Clang https://reviews.llvm.org/D52973 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52973: Add type_info predefined decl
mwasplund added inline comments. Comment at: lib/Sema/SemaDecl.cpp:1464 if (NewM == OldM) return false; rsmith wrote: > Somewhere up here we're calling `getOwningModule()` but should be calling > `getOwningModuleForLinkage()`. (Please upload patches with full context as > described at https://llvm.org/docs/Phabricator.html) I am using the git mirror to work out of so I can commit incremental changes. However when I used the commands provided they were only showing my latest change, not the full diff from origin master. I will give it another try... Repository: rC Clang https://reviews.llvm.org/D52973 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52973: Add type_info predefined decl
mwasplund updated this revision to Diff 169879. mwasplund marked 2 inline comments as done. Repository: rC Clang https://reviews.llvm.org/D52973 Files: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp lib/Sema/SemaDecl.cpp test/Modules/msvc-compat-implitic-types.cpp Index: test/Modules/msvc-compat-implitic-types.cpp === --- /dev/null +++ test/Modules/msvc-compat-implitic-types.cpp @@ -0,0 +1,14 @@ +// Verify there is not collision between the +// RUN: %clang -fms-compatibility -fmodules-ts -x c++-module --precompile -DEXPORT -o %t.pcm %s +// RUN: %clang -fms-compatibility -fmodules-ts -fmodule-file=%t.pcm -c -DMAIN %s + +// expected-no-diagnostics + +#if EXPORT +export module MyModule; +export class MyClass {}; +#elif MAIN +#include +#else +#error MISSING DEFINE +#endif \ No newline at end of file Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -1464,11 +1464,6 @@ if (NewM == OldM) return false; - // FIXME: The Modules TS does not specify how to handle inplicit types - // For now we will simply ignore the implicit global types - if (Old->isImplicit()) -return false; - // FIXME: Check proclaimed-ownership-declarations here too. bool NewIsModuleInterface = NewM && NewM->Kind == Module::ModuleInterfaceUnit; bool OldIsModuleInterface = OldM && OldM->Kind == Module::ModuleInterfaceUnit; Index: lib/AST/ASTContext.cpp === --- lib/AST/ASTContext.cpp +++ lib/AST/ASTContext.cpp @@ -1081,8 +1081,10 @@ } RecordDecl *ASTContext::getTypeInfoClassDecl() const { - if (!TypeInfoClassDecl) + if (!TypeInfoClassDecl) { TypeInfoClassDecl = buildImplicitRecord("type_info", TTK_Class); + TypeInfoClassDecl->setModuleOwnershipKind(Decl::ModuleOwnershipKind::Unowned); + } return TypeInfoClassDecl; } Index: include/clang/AST/ASTContext.h === --- include/clang/AST/ASTContext.h +++ include/clang/AST/ASTContext.h @@ -1126,7 +1126,7 @@ /// Retrieve the declaration for the 128-bit unsigned integer type. TypedefDecl *getUInt128Decl() const; - /// Retrieve the declaration for the type_info class type. + /// Retrieve the declaration for the MSVC ::type_info class type. RecordDecl *getTypeInfoClassDecl() const; //======// Index: test/Modules/msvc-compat-implitic-types.cpp === --- /dev/null +++ test/Modules/msvc-compat-implitic-types.cpp @@ -0,0 +1,14 @@ +// Verify there is not collision between the +// RUN: %clang -fms-compatibility -fmodules-ts -x c++-module --precompile -DEXPORT -o %t.pcm %s +// RUN: %clang -fms-compatibility -fmodules-ts -fmodule-file=%t.pcm -c -DMAIN %s + +// expected-no-diagnostics + +#if EXPORT +export module MyModule; +export class MyClass {}; +#elif MAIN +#include +#else +#error MISSING DEFINE +#endif \ No newline at end of file Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -1464,11 +1464,6 @@ if (NewM == OldM) return false; - // FIXME: The Modules TS does not specify how to handle inplicit types - // For now we will simply ignore the implicit global types - if (Old->isImplicit()) -return false; - // FIXME: Check proclaimed-ownership-declarations here too. bool NewIsModuleInterface = NewM && NewM->Kind == Module::ModuleInterfaceUnit; bool OldIsModuleInterface = OldM && OldM->Kind == Module::ModuleInterfaceUnit; Index: lib/AST/ASTContext.cpp === --- lib/AST/ASTContext.cpp +++ lib/AST/ASTContext.cpp @@ -1081,8 +1081,10 @@ } RecordDecl *ASTContext::getTypeInfoClassDecl() const { - if (!TypeInfoClassDecl) + if (!TypeInfoClassDecl) { TypeInfoClassDecl = buildImplicitRecord("type_info", TTK_Class); +TypeInfoClassDecl->setModuleOwnershipKind(Decl::ModuleOwnershipKind::Unowned); + } return TypeInfoClassDecl; } Index: include/clang/AST/ASTContext.h === --- include/clang/AST/ASTContext.h +++ include/clang/AST/ASTContext.h @@ -1126,7 +1126,7 @@ /// Retrieve the declaration for the 128-bit unsigned integer type. TypedefDecl *getUInt128Decl() const; - /// Retrieve the declaration for the type_info class type. + /// Retrieve the declaration for the MSVC ::type_info class type. RecordDecl *getTypeInfoClassDecl() const; //======// ___ cfe-commits mailing list cfe-commits@lists.llvm.org
[PATCH] D52390: [analyzer] Add StackSizeChecker to StaticAnalyzer
mate1214 abandoned this revision. mate1214 marked 24 inline comments as done. mate1214 added a comment. Herald added subscribers: dkrupp, nhaehnle, donat.nagy. Hi! Sorry for the delay. After considering the amount of requested tests and investigating the possibly reviewer friendly ways to split this up, I came to the conclusion that I can not go through with all this work for now. Thanks to everyone who took the time to comment. I'm abandoning this revision. Repository: rC Clang https://reviews.llvm.org/D52390 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47687: [Sema] Missing -Wlogical-op-parentheses warnings in macros (PR18971)
vsapsai added a comment. Sorry about the delay. The change seems to be correct but `ninja check-clang` reveals the test "Misc/caret-diags-macros.c" is failing. Can you please look into that? Appreciate your contribution, Xing, and thanks for verifying your change with tests. Comment at: lib/Sema/SemaExpr.cpp:7107-7108 + SourceManager = Self.getSourceManager(); + SourceLocation spellLoc = SM.getSpellingLoc(ParenRange.getEnd()); + unsigned tokLen = Lexer::MeasureTokenLength(spellLoc, SM, Self.getLangOpts()); + SourceLocation EndLoc = spellLoc.getLocWithOffset(tokLen); Can you please start variables with an upper case letter? Like `SpellLoc`, `TokLen`. https://reviews.llvm.org/D47687 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions
efriedma added a comment. Herald added a subscriber: nhaehnle. Looks like the latest update is missing a test file? https://reviews.llvm.org/D52835 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53266: [clangd] Simplify client capabilities parsing.
kadircet accepted this revision. kadircet added a comment. This revision is now accepted and ready to land. LGTM, thanks for the change! Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53266 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52795: [analyzer][PlistMacroExpansion] Part 3.: Macro arguments are expanded
Szelethus added inline comments. Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:677 +/// need to expanded further when it is nested inside another macro. +class MacroArgMap : public std::map { +public: Szelethus wrote: > george.karpenkov wrote: > > Please don't do this, inheritance from standard containers is a bad thing > > (tm) > Actually, I disagree with you on this one. For ease of use, these constructs > are used all over the place in the LLVM codebase, and since I never do > anything inheritance related, this shouldn't hurt much. > > https://clang.llvm.org/doxygen/classclang_1_1ento_1_1PathPieces.html > http://llvm.org/doxygen/classllvm_1_1PredicateBitsetImpl.html > http://llvm.org/doxygen/classllvm_1_1HexagonBlockRanges_1_1RangeList.html > > These are just a few. > > Do you insist? I mean, polymorphism, not inheritance. https://reviews.llvm.org/D52795 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r344637 - Revert "[clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction."
Author: krasimir Date: Tue Oct 16 11:44:41 2018 New Revision: 344637 URL: http://llvm.org/viewvc/llvm-project?rev=344637=rev Log: Revert "[clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction." This reverts commit r344620. Breaks upstream bots. Removed: clang-tools-extra/trunk/clangd/JSONTransport.cpp clang-tools-extra/trunk/clangd/Transport.h clang-tools-extra/trunk/unittests/clangd/JSONTransportTests.cpp Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdLSPServer.h clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h clang-tools-extra/trunk/clangd/Protocol.cpp clang-tools-extra/trunk/clangd/Protocol.h clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test clang-tools-extra/trunk/test/clangd/completion-snippets.test clang-tools-extra/trunk/test/clangd/completion.test clang-tools-extra/trunk/test/clangd/crash-non-added-files.test clang-tools-extra/trunk/test/clangd/execute-command.test clang-tools-extra/trunk/test/clangd/input-mirror.test clang-tools-extra/trunk/test/clangd/signature-help.test clang-tools-extra/trunk/test/clangd/textdocument-didchange-fail.test clang-tools-extra/trunk/test/clangd/trace.test clang-tools-extra/trunk/test/clangd/xrefs.test clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=344637=344636=344637=diff == --- clang-tools-extra/trunk/clangd/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clangd/CMakeLists.txt Tue Oct 16 11:44:41 2018 @@ -26,7 +26,6 @@ add_clang_library(clangDaemon GlobalCompilationDatabase.cpp Headers.cpp JSONRPCDispatcher.cpp - JSONTransport.cpp Logger.cpp Protocol.cpp ProtocolHandlers.cpp Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=344637=344636=344637=diff == --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Oct 16 11:44:41 2018 @@ -162,10 +162,7 @@ void ClangdLSPServer::onShutdown(Shutdow reply(nullptr); } -void ClangdLSPServer::onExit(ExitParams ) { - // No work to do. - // JSONRPCDispatcher shuts down the transport after this notification. -} +void ClangdLSPServer::onExit(ExitParams ) { IsDone = true; } void ClangdLSPServer::onDocumentDidOpen(DidOpenTextDocumentParams ) { PathRef File = Params.textDocument.uri.file(); @@ -500,41 +497,39 @@ void ClangdLSPServer::onReference(Refere }); } -ClangdLSPServer::ClangdLSPServer(class Transport , +ClangdLSPServer::ClangdLSPServer(JSONOutput , const clangd::CodeCompleteOptions , llvm::Optional CompileCommandsDir, bool ShouldUseInMemoryCDB, const ClangdServer::Options ) -: Transport(Transport), - CDB(ShouldUseInMemoryCDB ? CompilationDB::makeInMemory() - : CompilationDB::makeDirectoryBased( - std::move(CompileCommandsDir))), +: Out(Out), CDB(ShouldUseInMemoryCDB ? CompilationDB::makeInMemory() + : CompilationDB::makeDirectoryBased( + std::move(CompileCommandsDir))), CCOpts(CCOpts), SupportedSymbolKinds(defaultSymbolKinds()), SupportedCompletionItemKinds(defaultCompletionItemKinds()), Server(new ClangdServer(CDB.getCDB(), FSProvider, /*DiagConsumer=*/*this, Opts)) {} -bool ClangdLSPServer::run() { +bool ClangdLSPServer::run(std::FILE *In, JSONStreamStyle InputStyle) { + assert(!IsDone && "Run was called before"); assert(Server); // Set up JSONRPCDispatcher. JSONRPCDispatcher Dispatcher([](const json::Value ) { replyError(ErrorCode::MethodNotFound, "method not found"); -return true; }); registerCallbackHandlers(Dispatcher, /*Callbacks=*/*this); // Run the Language Server loop. - bool CleanExit = true; - if (auto Err = Dispatcher.runLanguageServerLoop(Transport)) { -elog("Transport error: {0}", std::move(Err)); -CleanExit = false; - } + runLanguageServerLoop(In, Out, InputStyle, Dispatcher, IsDone); + // Make sure IsDone is set to true after this method exits to ensure assertion + // at the
[PATCH] D52795: [analyzer][PlistMacroExpansion] Part 3.: Macro arguments are expanded
Szelethus added inline comments. Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:677 +/// need to expanded further when it is nested inside another macro. +class MacroArgMap : public std::map { +public: george.karpenkov wrote: > Please don't do this, inheritance from standard containers is a bad thing (tm) Actually, I disagree with you on this one. For ease of use, these constructs are used all over the place in the LLVM codebase, and since I never do anything inheritance related, this shouldn't hurt much. https://clang.llvm.org/doxygen/classclang_1_1ento_1_1PathPieces.html http://llvm.org/doxygen/classllvm_1_1PredicateBitsetImpl.html http://llvm.org/doxygen/classllvm_1_1HexagonBlockRanges_1_1RangeList.html These are just a few. Do you insist? https://reviews.llvm.org/D52795 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52790: [analyzer][PlistMacroExpansion] New flag to convert macro expansions to events
Szelethus added inline comments. Comment at: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist:6 clang_version -clang version 8.0.0 (http://mainstream.inf.elte.hu/Szelethus/clang 80e1678b9f598ca78bb3b71cf546a63414a37b11) (https://github.com/llvm-mirror/llvm 1ffbf26a1a0a190d69327af875a3337b74a2ce82) +clang version 8.0.0 (http://mainstream.inf.elte.hu/Szelethus/clang ec097c9a35733c2c703e8ff03ea9b6ae345bf3f3) (https://github.com/llvm-mirror/llvm 1ffbf26a1a0a190d69327af875a3337b74a2ce82) diagnostics george.karpenkov wrote: > Could we figure out how not to have hardcoded contributor-based strings > there? Maybe have a python script generating those / doing a cleanup? I'm just about to remove it, as I did for all the other [PlistMacroExpancion] patches. But yea, a tool wouldn't hurt. https://reviews.llvm.org/D52790 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52988: [analyzer][PlistMacroExpansion] Part 5.: Support for # and ##
Szelethus updated this revision to Diff 169871. Szelethus added a comment. Herald added a subscriber: dkrupp. This patch didn't really work, sometimes it printed extra spaces, sometimes printed the hash tokens, and so on, so I refactored the whole project to deal with this issue almost out of the box. https://reviews.llvm.org/D52988 Files: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist test/Analysis/plist-macros-with-expansion.cpp Index: test/Analysis/plist-macros-with-expansion.cpp === --- test/Analysis/plist-macros-with-expansion.cpp +++ test/Analysis/plist-macros-with-expansion.cpp @@ -278,9 +278,17 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// TODO: Should expand correctly. // CHECK: nameDECLARE_FUNC_AND_SET_TO_NULL -// CHECK: expansionvoid generated_##whatever(); ptr = nullptr; +// CHECK: expansionvoid generated_whatever(); ptr = nullptr; + +void macroArgContainsHashHashInStringTest() { + int *a; + TO_NULL_AND_PRINT(a, "Will this ## cause a crash?"); + *a = 5; // expected-warning{{Dereference of null pointer}} +} + +// CHECK: nameTO_NULL_AND_PRINT +// CHECK: expansiona = 0; print( Will this ## cause a crash?) #define PRINT_STR(str, ptr) \ print(#str); \ @@ -292,6 +300,14 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// TODO: Should expand correctly. // CHECK: namePRINT_STR -// CHECK: expansionprint(#Hello); ptr = nullptr +// CHECK: expansionprint(Hello); ptr = nullptr + +void macroArgContainsHashInStringTest() { + int *a; + TO_NULL_AND_PRINT(a, "Will this # cause a crash?"); + *a = 5; // expected-warning{{Dereference of null pointer}} +} + +// CHECK: nameTO_NULL_AND_PRINT +// CHECK: expansiona = 0; print( Will this # cause a crash?) Index: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist === --- test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist +++ test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist @@ -3755,7 +3755,7 @@ file0 nameDECLARE_FUNC_AND_SET_TO_NULL - expansionvoid generated_##whatever(); ptr = nullptr; + expansionvoid generated_whatever(); ptr = nullptr; kindevent @@ -3887,25 +3887,192 @@ start - line290 + line285 col3 file0 - line290 + line285 col5 file0 end - line291 + line286 col3 file0 - line291 + line286 + col19 + file0 + + + + + + + kindmacro_expansion + location + + line286 + col3 + file0 + + nameTO_NULL_AND_PRINT + expansiona = 0; print( Will this ## cause a crash?) + + + kindevent + location + + line286 + col3 + file0 + + ranges + + + + line286 + col3 + file0 + + + line286 + col53 + file0 + + + + depth0 + extended_message + Null pointer value stored to a + message + Null pointer value stored to a + + + kindcontrol + edges + + +start + + + line287 + col3 + file0 + + + line287 + col3 + file0 + + +end + + + line287 + col6 + file0 + + + line287 + col6 + file0 + + + + + + + kindevent + location + + line287 + col6 + file0 + + ranges + + + + line287 + col4 + file0 + + + line287 + col4 + file0 + + + + depth0 + extended_message + Dereference of null pointer (loaded from variable a) + message + Dereference of null pointer (loaded from variable a) + + + descriptionDereference of null pointer (loaded from variable a) + categoryLogic error + typeDereference of null pointer + check_namecore.NullDereference + + issue_hash_content_of_line_in_context6817572ced27cb7d28fc87b2aba75fb4 + issue_context_kindfunction + issue_contextmacroArgContainsHashHashInStringTest + issue_hash_function_offset3 + location + + line287 + col6 + file0 + + ExecutedLines + + 0 + +284 +285 +286 +287 + + + + + path + + + kindcontrol +
[PATCH] D52790: [analyzer][PlistMacroExpansion] New flag to convert macro expansions to events
george.karpenkov added inline comments. Comment at: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist:6 clang_version -clang version 8.0.0 (http://mainstream.inf.elte.hu/Szelethus/clang 80e1678b9f598ca78bb3b71cf546a63414a37b11) (https://github.com/llvm-mirror/llvm 1ffbf26a1a0a190d69327af875a3337b74a2ce82) +clang version 8.0.0 (http://mainstream.inf.elte.hu/Szelethus/clang ec097c9a35733c2c703e8ff03ea9b6ae345bf3f3) (https://github.com/llvm-mirror/llvm 1ffbf26a1a0a190d69327af875a3337b74a2ce82) diagnostics Could we figure out how not to have hardcoded contributor-based strings there? Maybe have a python script generating those / doing a cleanup? https://reviews.llvm.org/D52790 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52795: [analyzer][PlistMacroExpansion] Part 3.: Macro arguments are expanded
george.karpenkov requested changes to this revision. george.karpenkov added inline comments. This revision now requires changes to proceed. Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:677 +/// need to expanded further when it is nested inside another macro. +class MacroArgMap : public std::map { +public: Please don't do this, inheritance from standard containers is a bad thing (tm) https://reviews.llvm.org/D52795 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52986: [analyzer][PlistMacroExpansion] Part 4.: Support for __VA_ARGS__
Szelethus updated this revision to Diff 169869. Szelethus added a comment. Herald added a subscriber: dkrupp. Rebased to part 3. https://reviews.llvm.org/D52986 Files: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist test/Analysis/plist-macros-with-expansion.cpp Index: test/Analysis/plist-macros-with-expansion.cpp === --- test/Analysis/plist-macros-with-expansion.cpp +++ test/Analysis/plist-macros-with-expansion.cpp @@ -261,9 +261,8 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// TODO: Should correctly display the rest of the parameters. // CHECK: nameVARIADIC_SET_TO_NULL -// CHECK: expansionptr = nullptr; variadicFunc( 1) +// CHECK: expansionptr = nullptr; variadicFunc( 1, 5, haha!) //===--===// // Tests for # and ##. Index: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist === --- test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist +++ test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist @@ -3588,7 +3588,7 @@ file0 nameVARIADIC_SET_TO_NULL - expansionptr = nullptr; variadicFunc( 1) + expansionptr = nullptr; variadicFunc( 1, 5, haha!) kindevent @@ -3720,25 +3720,25 @@ start - line277 + line276 col3 file0 - line277 + line276 col5 file0 end - line278 + line277 col3 file0 - line278 + line277 col30 file0 @@ -3750,7 +3750,7 @@ kindmacro_expansion location - line278 + line277 col3 file0 @@ -3761,20 +3761,20 @@ kindevent location - line278 + line277 col3 file0 ranges - line278 + line277 col3 file0 - line278 + line277 col45 file0 @@ -3794,25 +3794,25 @@ start - line279 + line278 col3 file0 - line279 + line278 col3 file0 end - line279 + line278 col8 file0 - line279 + line278 col8 file0 @@ -3824,20 +3824,20 @@ kindevent location - line279 + line278 col8 file0 ranges - line279 + line278 col4 file0 - line279 + line278 col6 file0 @@ -3861,18 +3861,18 @@ issue_hash_function_offset3 location - line279 + line278 col8 file0 ExecutedLines 0 +275 276 277 278 -279 @@ -3887,25 +3887,25 @@ start - line291 + line290 col3 file0 - line291 + line290 col5 file0 end - line292 + line291 col3 file0 - line292 + line291 col11 file0 @@ -3917,7 +3917,7 @@ kindmacro_expansion location - line292 + line291 col3 file0 @@ -3928,20 +3928,20 @@ kindevent location - line292 + line291 col3 file0 ranges - line292 + line291 col3 file0 - line292 + line291 col23 file0 @@ -3961,25 +3961,25 @@ start - line293 + line292 col3 file0 - line293 + line292 col3 file0 end - line293 + line292 col8 file0 - line293 + line292 col8 file0 @@ -3991,20 +3991,20 @@ kindevent location - line293 + line292 col8 file0
[PATCH] D52790: [analyzer][PlistMacroExpansion] New flag to convert macro expansions to events
whisperity accepted this revision. whisperity added a comment. This revision is now accepted and ready to land. Herald added a subscriber: donat.nagy. Remove the custom file paths and URLs but other than that this is pretty trivial. https://reviews.llvm.org/D52790 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53295: Mark store and load of block invoke function as invariant.group
yaxunl updated this revision to Diff 169864. yaxunl retitled this revision from "[OpenCL] Mark load of block invoke function as invariant" to "Mark store and load of block invoke function as invariant.group". yaxunl edited the summary of this revision. yaxunl added a comment. Herald added a subscriber: Prazek. mark store and load of block invoke function as invariant.group. https://reviews.llvm.org/D53295 Files: lib/CodeGen/CGBlocks.cpp test/CodeGenOpenCL/blocks-indirect-call.cl Index: test/CodeGenOpenCL/blocks-indirect-call.cl === --- /dev/null +++ test/CodeGenOpenCL/blocks-indirect-call.cl @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes=COMMON,NOOPT %s +// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes=COMMON,OPT %s + +// Check invariant.group MD are emitted at -O0 and indirect function calls +// are eliminated at default optimization level. + +// COMMON-LABEL: define {{.*}} @blockInLoopCondition +// NOOPT: store {{.*}}@__blockInLoopCondition_block_invoke{{.*}} !invariant.group +// NOOPT: %[[INV:.*]] = getelementptr {{.*}}%block.literal, i32 0, i32 2 +// NOOPT: load {{.*}}%[[INV]]{{.*}}, !invariant.group +// ToDo: Fix LLVM optimizations to lower indirect function call +// OPT: %[[INV:.*]] = phi {{.*}}[ @__blockInLoopCondition_block_invoke, %entry ] +// OPT: call i32 %[[INV]] + +// OPT-NOT: load {{.*}}!invariant.group +void blockInLoopCondition(int* res, int tid, int multiplier) { + int (^kernelBlock)(int) = ^(int num) { +return num * multiplier; + }; + res[tid] = 39; + for(int i=0; i Address { return Builder.CreateStructGEP(blockAddr, index, offset, name); }; - auto storeField = -[&](llvm::Value *value, unsigned index, CharUnits offset, -const Twine ) { - Builder.CreateStore(value, projectField(index, offset, name)); -}; + auto storeField = [&](llvm::Value *value, unsigned index, CharUnits offset, +const Twine , bool IsInvariant) { +auto *ST = Builder.CreateStore(value, projectField(index, offset, name)); +if (IsInvariant) + ST->setMetadata(CGM.getModule().getMDKindID("invariant.group"), + llvm::MDNode::get(getLLVMContext(), None)); + }; // Initialize the block header. { // We assume all the header fields are densely packed. unsigned index = 0; CharUnits offset; -auto addHeaderField = - [&](llvm::Value *value, CharUnits size, const Twine ) { -storeField(value, index, offset, name); -offset += size; -index++; - }; +auto addHeaderField = [&](llvm::Value *value, CharUnits size, + const Twine , bool IsInvariant = false) { + storeField(value, index, offset, name, IsInvariant); + offset += size; + index++; +}; if (!IsOpenCL) { addHeaderField(isa, getPointerSize(), "block.isa"); @@ -1008,7 +1010,8 @@ llvm::ConstantInt::get(IntTy, blockInfo.BlockAlign.getQuantity()), getIntSize(), "block.align"); } -addHeaderField(blockFn, GenVoidPtrSize, "block.invoke"); +addHeaderField(blockFn, GenVoidPtrSize, "block.invoke", + /*IsInvariant=*/true); if (!IsOpenCL) addHeaderField(descriptor, getPointerSize(), "block.descriptor"); else if (auto *Helper = @@ -1302,6 +1305,9 @@ // Load the function. llvm::Value *Func = Builder.CreateAlignedLoad(FuncPtr, getPointerAlign()); + cast(Func)->setMetadata( + CGM.getModule().getMDKindID("invariant.group"), + llvm::MDNode::get(getLLVMContext(), None)); const FunctionType *FuncTy = FnType->castAs(); const CGFunctionInfo = ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53308: [Fixed Point Arithmetic] Fixed Point to Boolean Cast
leonardchan added inline comments. Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1032 + // them. + return Builder.CreateIsNotNull(Src); +} ebevhan wrote: > Is this comment true? I don't think EmitFixedPointConversion does this. > > Maybe I'm misinterpreting what it means. Ah sorry, this was my bad. I briefly forgot that we intended for overflow into the bit to be undefined behavior. In that case, this comment doesn't make sense and should be removed, but we still shouldn't have to clear/check the padding bit in this case because we should assume it's zero'd. So this refers to handling when the padding bit needs to be cleared since if we ever have an operation that reads the whole int of an underlying unsigned type. I accidentally wrote this comment thinking that it would be cleared/zero'd at some point when we decided before that overflow into this padding was just undefined behavior. Updated the comment to reflect this. Repository: rC Clang https://reviews.llvm.org/D53308 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53308: [Fixed Point Arithmetic] Fixed Point to Boolean Cast
leonardchan updated this revision to Diff 169863. leonardchan marked 3 inline comments as done. Repository: rC Clang https://reviews.llvm.org/D53308 Files: clang/include/clang/AST/OperationKinds.def clang/lib/AST/Expr.cpp clang/lib/AST/ExprConstant.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGExprAgg.cpp clang/lib/CodeGen/CGExprComplex.cpp clang/lib/CodeGen/CGExprConstant.cpp clang/lib/CodeGen/CGExprScalar.cpp clang/lib/Edit/RewriteObjCFoundationAPI.cpp clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp clang/test/Frontend/fixed_point_to_bool.c clang/test/Frontend/fixed_point_unknown_conversions.c Index: clang/test/Frontend/fixed_point_unknown_conversions.c === --- clang/test/Frontend/fixed_point_unknown_conversions.c +++ clang/test/Frontend/fixed_point_unknown_conversions.c @@ -35,7 +35,6 @@ accum_ptr = ptr; // expected-warning{{incompatible pointer types assigning to '_Accum *' from 'int *'}} accum = i2; // expected-error{{conversion between fixed point and 'int_t' (aka 'int') is not yet supported}} - b = accum; // expected-error{{conversion between fixed point and '_Bool' is not yet supported}} c = accum; // expected-error{{conversion between fixed point and 'char' is not yet supported}} i = accum; // expected-error{{conversion between fixed point and 'int' is not yet supported}} f = accum; // expected-error{{conversion between fixed point and 'float' is not yet supported}} Index: clang/test/Frontend/fixed_point_to_bool.c === --- /dev/null +++ clang/test/Frontend/fixed_point_to_bool.c @@ -0,0 +1,53 @@ +// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - -fpadding-on-unsigned-fixed-point | FileCheck %s + +_Bool global_b = 1.0k; // @global_b = {{*.}}global i8 1, align 1 +_Bool global_b2 = 0.0k; // @global_b2 = {{*.}}global i8 0, align 1 + +void func() { + _Accum a = 0.5k; + unsigned _Accum ua = 0.5uk; + _Bool b; + + // CHECK: store i8 1, i8* %b, align 1 + // CHECK-NEXT: store i8 0, i8* %b, align 1 + // CHECK: store i8 1, i8* %b, align 1 + // CHECK-NEXT: store i8 0, i8* %b, align 1 + b = 0.5k; + b = 0.0k; + b = 0.5uk; + b = 0.0uk; + + // CHECK-NEXT: store i8 1, i8* %b, align 1 + // CHECK-NEXT: store i8 0, i8* %b, align 1 + // CHECK-NEXT: store i8 1, i8* %b, align 1 + // CHECK-NEXT: store i8 0, i8* %b, align 1 + b = (_Bool)0.5r; + b = (_Bool)0.0r; + b = (_Bool)0.5ur; + b = (_Bool)0.0ur; + + // CHECK-NEXT: [[ACCUM:%[0-9]+]] = load i32, i32* %a, align 4 + // CHECK-NEXT: [[NOTZERO:%[0-9]+]] = icmp ne i32 [[ACCUM]], 0 + // CHECK-NEXT: %frombool = zext i1 [[NOTZERO]] to i8 + // CHECK-NEXT: store i8 %frombool, i8* %b, align 1 + b = a; + + // CHECK-NEXT: [[ACCUM:%[0-9]+]] = load i32, i32* %ua, align 4 + // CHECK-NEXT: [[NOTZERO:%[0-9]+]] = icmp ne i32 [[ACCUM]], 0 + // CHECK-NEXT: %frombool1 = zext i1 [[NOTZERO]] to i8 + // CHECK-NEXT: store i8 %frombool1, i8* %b, align 1 + b = ua; + + // CHECK-NEXT: [[ACCUM:%[0-9]+]] = load i32, i32* %a, align 4 + // CHECK-NEXT: [[NOTZERO:%[0-9]+]] = icmp ne i32 [[ACCUM]], 0 + // CHECK-NEXT: br i1 [[NOTZERO]], label %if.then, label %if.end + if (a) { + } + + // CHECK: [[ACCUM:%[0-9]+]] = load i32, i32* %ua, align 4 + // CHECK-NEXT: [[NOTZERO:%[0-9]+]] = icmp ne i32 [[ACCUM]], 0 + // CHECK-NEXT: br i1 [[NOTZERO]], label %if.then{{[0-9]+}}, label %if.end{{[0-9]+}} + if (ua) { + } +} Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp === --- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -416,7 +416,8 @@ case CK_ZeroToOCLQueue: case CK_IntToOCLSampler: case CK_LValueBitCast: - case CK_FixedPointCast: { + case CK_FixedPointCast: + case CK_FixedPointToBoolean: { state = handleLValueBitCast(state, Ex, LCtx, T, ExTy, CastE, Bldr, Pred); continue; Index: clang/lib/Sema/SemaExpr.cpp === --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -5894,10 +5894,7 @@ case Type::STK_FixedPoint: return CK_FixedPointCast; case Type::STK_Bool: - Diag(Src.get()->getExprLoc(), - diag::err_unimplemented_conversion_with_fixed_point_type) - << DestTy; - return CK_IntegralToBoolean; + return CK_FixedPointToBoolean; case Type::STK_Integral: case Type::STK_Floating: case Type::STK_IntegralComplex: @@ -12793,12 +12790,6 @@ if (Context.getLangOpts().CPlusPlus) { // C++03 [expr.unary.op]p8, C++0x [expr.unary.op]p9: // operand contextually converted to bool. -if
[PATCH] D53334: [Frontend] Show diagnostics on prebuilt module configuration mismatch too
whisperity created this revision. whisperity added reviewers: rsmith, doug.gregor. whisperity added a project: clang. Herald added subscribers: Szelethus, dkrupp, rnkovacs. The current version only emits the below error for a module (attempted to be loaded) from the `prebuilt-module-path`: error: module file blabla.pcm cannot be loaded due to a configuration mismatch with the current compilation [-Wmodule-file-config-mismatch] With this change, if the prebuilt module is used, we allow the proper diagnostic behind the configuration mismatch to be shown. error: POSIX thread support was disabled in PCH file but is currently enabled error: module file blabla.pcm cannot be loaded due to a configuration mismatch with the current compilation [-Wmodule-file-config-mismatch] (A few lines later an error is emitted anyways, so there is no reason not to complain for configuration mismatches if a config mismatch is found and kills the build.) Repository: rC Clang https://reviews.llvm.org/D53334 Files: lib/Frontend/CompilerInstance.cpp Index: lib/Frontend/CompilerInstance.cpp === --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -1724,7 +1724,9 @@ // module cache, we don't know how to rebuild modules. unsigned ARRFlags = Source == ModuleCache ? ASTReader::ARR_OutOfDate | ASTReader::ARR_Missing : -ASTReader::ARR_ConfigurationMismatch; +Source == PrebuiltModulePath ? +0 : +ASTReader::ARR_ConfigurationMismatch; switch (ModuleManager->ReadAST(ModuleFileName, Source == PrebuiltModulePath ? serialization::MK_PrebuiltModule Index: lib/Frontend/CompilerInstance.cpp === --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -1724,7 +1724,9 @@ // module cache, we don't know how to rebuild modules. unsigned ARRFlags = Source == ModuleCache ? ASTReader::ARR_OutOfDate | ASTReader::ARR_Missing : -ASTReader::ARR_ConfigurationMismatch; +Source == PrebuiltModulePath ? +0 : +ASTReader::ARR_ConfigurationMismatch; switch (ModuleManager->ReadAST(ModuleFileName, Source == PrebuiltModulePath ? serialization::MK_PrebuiltModule ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52794: [analyzer][PlistMacroExpansion] Part 2.: Retrieving the macro name and primitive expansion
Szelethus updated this revision to Diff 169862. Szelethus added a comment. Herald added a subscriber: donat.nagy. - Removed the version entry from the plist file, - Now using `TokenConcatenation` to print spaces only when needed (this needed for https://reviews.llvm.org/D52988), - A bit more doc, - Reorganized ("refactored" would be too strong of a word) `getExpandedMacroImpl` to make it easier to read. https://reviews.llvm.org/D52794 Files: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist test/Analysis/plist-macros-with-expansion.cpp Index: test/Analysis/plist-macros-with-expansion.cpp === --- test/Analysis/plist-macros-with-expansion.cpp +++ test/Analysis/plist-macros-with-expansion.cpp @@ -27,8 +27,8 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: name -// CHECK: expansion +// CHECK: nameSET_PTR_VAR_TO_NULL +// CHECK: expansionptr = 0 #define NULL 0 #define SET_PTR_VAR_TO_NULL_WITH_NESTED_MACRO \ @@ -40,5 +40,51 @@ *ptr = 5; // expected-warning{{Dereference of null pointer}} } -// CHECK: name -// CHECK: expansion +// CHECK: nameSET_PTR_VAR_TO_NULL_WITH_NESTED_MACRO +// CHECK: expansionptr =0 + +//===--===// +// Tests for function-like macro expansions. +//===--===// + +void setToNull(int **vptr) { + *vptr = nullptr; +} + +#define TO_NULL(x) \ + setToNull(x) + +void functionLikeMacroTest() { + int *ptr; + TO_NULL(); + *ptr = 5; // expected-warning{{Dereference of null pointer}} +} + +// TODO: Expand argumnts. +// CHECK: nameTO_NULL +// CHECK: expansionsetToNull(x) + +#define DOES_NOTHING(x) \ + { \ +int b; \ +b = 5; \ + } \ + print(x) + +#define DEREF(x) \ + DOES_NOTHING(x); \ + *x + +void functionLikeNestedMacroTest() { + int *a; + TO_NULL(); + DEREF(a) = 5; // expected-warning{{Dereference of null pointer}} +} + +// TODO: Expand argumnts. +// CHECK: nameTO_NULL +// CHECK: expansionsetToNull(x) + +// TODO: Expand argumnts. +// CHECK: nameDEREF +// CHECK: expansion{ int b; b = 5; } print(x); *x Index: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist === --- test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist +++ test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist @@ -49,8 +49,8 @@ col3 file0 - name - expansion + nameSET_PTR_VAR_TO_NULL + expansion ptr = 0 kindevent @@ -216,8 +216,8 @@ col3 file0 - name - expansion + nameSET_PTR_VAR_TO_NULL_WITH_NESTED_MACRO + expansion ptr =0 kindevent @@ -338,6 +338,533 @@ + + path + + + kindcontrol + edges + + +start + + + line58 + col3 + file0 + + + line58 + col5 + file0 + + +end + + + line59 + col3 + file0 + + + line59 + col9 + file0 + + + + + + + kindmacro_expansion + location + + line59 + col3 + file0 + + nameTO_NULL + expansion setToNull(x) + + + kindevent + location + + line59 + col3 + file0 + + ranges + + + + line59 + col3 + file0 + + + line59 + col15 + file0 + + + + depth0 + extended_message + Calling setToNull + message + Calling setToNull + + + kindevent + location + + line50 + col1 + file0 + + depth1 + extended_message + Entered call from functionLikeMacroTest + message + Entered call from functionLikeMacroTest + + + kindcontrol + edges + + +start + + + line50 + col1 + file0 + + + line50 + col4 + file0 + + +end + + + line51 + col3 + file0 + + + line51 + col3 + file0 + + + + + + + kindevent + location + + line51 + col3 + file0 + + ranges + + + + line51 + col3 + file0 + + + line51 + col17 + file0 + +
[PATCH] D52742: [analyzer][PlistMacroExpansion] Part 1.: New expand-macros flag
Szelethus updated this revision to Diff 169858. Szelethus added a comment. Removed the version entry from the plist file. https://reviews.llvm.org/D52742 Files: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h lib/StaticAnalyzer/Core/AnalyzerOptions.cpp lib/StaticAnalyzer/Core/BugReporter.cpp lib/StaticAnalyzer/Core/PlistDiagnostics.cpp test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist test/Analysis/plist-macros-with-expansion.cpp Index: test/Analysis/plist-macros-with-expansion.cpp === --- /dev/null +++ test/Analysis/plist-macros-with-expansion.cpp @@ -0,0 +1,44 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s +// +// RUN: %clang_analyze_cc1 -analyzer-checker=core %s \ +// RUN: -analyzer-output=plist -o %t.plist \ +// RUN: -analyzer-config expand-macros=true +// +// Check the actual plist output. +// RUN: cat %t.plist | %diff_plist \ +// RUN: %S/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist +// +// Check the macro expansions from the plist output here, to make the test more +// understandable. +// RUN: FileCheck --input-file=%t.plist %s + +void print(const void*); + +//===--===// +// Tests for non-function-like macro expansions. +//===--===// + +#define SET_PTR_VAR_TO_NULL \ + ptr = 0 + +void nonFunctionLikeMacroTest() { + int *ptr; + SET_PTR_VAR_TO_NULL; + *ptr = 5; // expected-warning{{Dereference of null pointer}} +} + +// CHECK: name +// CHECK: expansion + +#define NULL 0 +#define SET_PTR_VAR_TO_NULL_WITH_NESTED_MACRO \ + ptr = NULL + +void nonFunctionLikeNestedMacroTest() { + int *ptr; + SET_PTR_VAR_TO_NULL_WITH_NESTED_MACRO; + *ptr = 5; // expected-warning{{Dereference of null pointer}} +} + +// CHECK: name +// CHECK: expansion Index: test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist === --- /dev/null +++ test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist @@ -0,0 +1,347 @@ + +http://www.apple.com/DTDs/PropertyList-1.0.dtd;> + + + diagnostics + + + path + + + kindcontrol + edges + + +start + + + line25 + col3 + file0 + + + line25 + col5 + file0 + + +end + + + line26 + col3 + file0 + + + line26 + col21 + file0 + + + + + + + kindmacro_expansion + location + + line26 + col3 + file0 + + name + expansion + + + kindevent + location + + line26 + col3 + file0 + + ranges + + + + line26 + col3 + file0 + + + line26 + col21 + file0 + + + + depth0 + extended_message + Null pointer value stored to ptr + message + Null pointer value stored to ptr + + + kindcontrol + edges + + +start + + + line27 + col3 + file0 + + + line27 + col3 + file0 + + +end + + + line27 + col8 + file0 + + + line27 + col8 + file0 + + + + + + + kindevent + location + + line27 + col8 + file0 + + ranges + + + + line27 + col4 + file0 + + + line27 + col6 + file0 + + + + depth0 + extended_message + Dereference of null pointer (loaded from variable ptr) + message + Dereference of null pointer (loaded from variable ptr) + + + descriptionDereference of null pointer (loaded from variable ptr) + categoryLogic error + typeDereference of null pointer + check_namecore.NullDereference + + issue_hash_content_of_line_in_contextf8fbc46cc5afbb056d92bd3d3d702781 + issue_context_kindfunction + issue_contextnonFunctionLikeMacroTest + issue_hash_function_offset3 + location + + line27 + col8 + file0 + + ExecutedLines + + 0 + +24 +25 +26 +27 + + + + + path + + + kindcontrol + edges + + +start + + + line38 + col3 + file0 + + + line38 + col5 + file0 + + +end + +
[PATCH] D50539: [VFS] Add property 'fallthrough' that controls fallback to real file system.
vsapsai marked 3 inline comments as done. vsapsai added a comment. In https://reviews.llvm.org/D50539#1241034, @bruno wrote: > > - Current way of working with modules in VFS "root" is clunky and > > error-prone. > > Why? Mostly because when you approach it in a straightforward way, you cannot read written modules because they aren't in VFS and "rootness" correctly prevents you from reading random files. You can add `-fdisable-module-hash` as I've done in the test but it has its own downsides when used not in a test but in a real project. >> Also I don't like that VFSFromYamlDirIterImpl is similar to overlay iterator >> but doesn't share code. At the moment I think it's not worth it to rework >> those abstractions to make more code reusable. If you've noticed problems >> with those iterators before, maybe it makes sense to try to find a better >> approach. > > Maybe add FIXMEs for it? Good idea, added. https://reviews.llvm.org/D50539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50539: [VFS] Add property 'fallthrough' that controls fallback to real file system.
vsapsai marked 5 inline comments as done. vsapsai added inline comments. Comment at: clang/lib/Basic/VirtualFileSystem.cpp:934 RedirectingFileSystem RedirectingDirectoryEntry::iterator Current, End; + bool IsExternalFSCurrent; bruno wrote: > Can you add comments to these new members? Specifically, what's the purpose > of `IsExternalFSCurrent` and how it connects to `ExternalFS` Added comments. Comment at: clang/lib/Basic/VirtualFileSystem.cpp:940 - std::error_code incrementImpl(); + std::error_code incrementExternal(); + std::error_code incrementContent(bool IsFirstTime); bruno wrote: > Same for these methods Added comments. Not entirely happy with them, would like to hear opinion of others. Comment at: clang/lib/Basic/VirtualFileSystem.cpp:1738 +ErrorOr RedirectingFileSystem::status(const Twine , + bool ShouldCheckExternalFS) { ErrorOr Result = lookupPath(Path); bruno wrote: > Is passing `ShouldCheckExternalFS ` really necessary? Why checking the status > of the member isn't enough? Not required anymore, simplified the code. https://reviews.llvm.org/D50539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52814: [PassManager/Sanitizer] Enable usage of ported AddressSanitizer passes with -fsanitize=address
leonardchan added a comment. @philip.pfaffe @fedor.sergeev Do you have any more comments on this patch? Repository: rC Clang https://reviews.llvm.org/D52814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53325: Disable code object version 3 for HIP toolchain
This revision was automatically updated to reflect the committed changes. Closed by commit rL344630: Disable code object version 3 for HIP toolchain (authored by yaxunl, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D53325?vs=169831=169855#toc Repository: rL LLVM https://reviews.llvm.org/D53325 Files: cfe/trunk/lib/Driver/ToolChains/HIP.cpp cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip cfe/trunk/test/Driver/hip-toolchain-rdc.hip Index: cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip === --- cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip +++ cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip @@ -32,7 +32,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_A_803:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_803]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_A_803:.*out]]" [[OBJ_DEV_A_803]] @@ -57,7 +59,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_A_900:".*-gfx900-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_900]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx900" "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_A_900:.*out]]" [[OBJ_DEV_A_900]] @@ -97,7 +101,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_B_803:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_B_803]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV_B_803:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV_B_803:".*-gfx803-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_B_803:.*out]]" [[OBJ_DEV_B_803]] @@ -122,7 +128,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_B_900:".*-gfx900-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_B_900]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx900" "-o" [[OBJ_DEV_B_900:".*-gfx900-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV_B_900:".*-gfx900-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_B_900:.*out]]" [[OBJ_DEV_B_900]] Index: cfe/trunk/test/Driver/hip-toolchain-rdc.hip === --- cfe/trunk/test/Driver/hip-toolchain-rdc.hip +++ cfe/trunk/test/Driver/hip-toolchain-rdc.hip @@ -35,7 +35,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV1:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV1]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV1:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV1:".*-gfx803-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV1:.*out]]" [[OBJ_DEV1]] @@ -61,7 +63,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV2:".*-gfx900-optimized.*bc"]] // CHECK: [[LLC]] [[OPT_BC_DEV2]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx900" "-o" [[OBJ_DEV2:".*-gfx900-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV2:".*-gfx900-.*o"]] // CHECK: [[LLD]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV2:.*out]]" [[OBJ_DEV2]] Index: cfe/trunk/lib/Driver/ToolChains/HIP.cpp === --- cfe/trunk/lib/Driver/ToolChains/HIP.cpp +++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp @@ -154,7 +154,7 @@ llvm::StringRef OutputFilePrefix, const char *InputFileName) const { // Construct llc command. ArgStringList LlcArgs{InputFileName, "-mtriple=amdgcn-amd-amdhsa", -"-filetype=obj", +"-filetype=obj", "-mattr=-code-object-v3", Args.MakeArgString("-mcpu=" + SubArchName), "-o"}; std::string LlcOutputFileName = C.getDriver().GetTemporaryPath(OutputFilePrefix, "o"); Index: cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip === --- cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip +++ cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip @@ -32,7 +32,9
r344630 - Disable code object version 3 for HIP toolchain
Author: yaxunl Date: Tue Oct 16 10:36:23 2018 New Revision: 344630 URL: http://llvm.org/viewvc/llvm-project?rev=344630=rev Log: Disable code object version 3 for HIP toolchain AMDGPU backend will switch to code object version 3 by default. Since HIP runtime is not ready, disable it until the runtime is ready. Differential Revision: https://reviews.llvm.org/D53325 Modified: cfe/trunk/lib/Driver/ToolChains/HIP.cpp cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip cfe/trunk/test/Driver/hip-toolchain-rdc.hip Modified: cfe/trunk/lib/Driver/ToolChains/HIP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/HIP.cpp?rev=344630=344629=344630=diff == --- cfe/trunk/lib/Driver/ToolChains/HIP.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp Tue Oct 16 10:36:23 2018 @@ -154,7 +154,7 @@ const char *AMDGCN::Linker::constructLlc llvm::StringRef OutputFilePrefix, const char *InputFileName) const { // Construct llc command. ArgStringList LlcArgs{InputFileName, "-mtriple=amdgcn-amd-amdhsa", -"-filetype=obj", +"-filetype=obj", "-mattr=-code-object-v3", Args.MakeArgString("-mcpu=" + SubArchName), "-o"}; std::string LlcOutputFileName = C.getDriver().GetTemporaryPath(OutputFilePrefix, "o"); Modified: cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip?rev=344630=344629=344630=diff == --- cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip (original) +++ cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip Tue Oct 16 10:36:23 2018 @@ -32,7 +32,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_A_803:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_803]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_A_803:.*out]]" [[OBJ_DEV_A_803]] @@ -57,7 +59,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_A_900:".*-gfx900-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_900]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx900" "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_A_900:.*out]]" [[OBJ_DEV_A_900]] @@ -97,7 +101,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_B_803:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_B_803]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV_B_803:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV_B_803:".*-gfx803-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_B_803:.*out]]" [[OBJ_DEV_B_803]] @@ -122,7 +128,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV_B_900:".*-gfx900-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_B_900]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx900" "-o" [[OBJ_DEV_B_900:".*-gfx900-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV_B_900:".*-gfx900-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV_B_900:.*out]]" [[OBJ_DEV_B_900]] Modified: cfe/trunk/test/Driver/hip-toolchain-rdc.hip URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-toolchain-rdc.hip?rev=344630=344629=344630=diff == --- cfe/trunk/test/Driver/hip-toolchain-rdc.hip (original) +++ cfe/trunk/test/Driver/hip-toolchain-rdc.hip Tue Oct 16 10:36:23 2018 @@ -35,7 +35,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV1:".*-gfx803-optimized.*bc"]] // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV1]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME: "-filetype=obj" "-mcpu=gfx803" "-o" [[OBJ_DEV1:".*-gfx803-.*o"]] +// CHECK-SAME: "-filetype=obj" +// CHECK-SAME: "-mattr=-code-object-v3" +// CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV1:".*-gfx803-.*o"]] // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared" // CHECK-SAME: "-o" "[[IMG_DEV1:.*out]]" [[OBJ_DEV1]] @@ -61,7 +63,9 @@ // CHECK-SAME: "-o" [[OPT_BC_DEV2:".*-gfx900-optimized.*bc"]] // CHECK: [[LLC]] [[OPT_BC_DEV2]] "-mtriple=amdgcn-amd-amdhsa" -// CHECK-SAME:
[PATCH] D53200: [OpenCL] Fix serialization of OpenCLExtensionDecls
AlexeySachkov updated this revision to Diff 169851. AlexeySachkov added a comment. Added test https://reviews.llvm.org/D53200 Files: lib/Serialization/ASTWriter.cpp test/Headers/opencl-pragma-extension-begin.cl test/Headers/opencl-pragma-extension-begin.h Index: test/Headers/opencl-pragma-extension-begin.h === --- /dev/null +++ test/Headers/opencl-pragma-extension-begin.h @@ -0,0 +1,4 @@ + +#pragma OPENCL EXTENSION cl_my_ext : begin +void cl_my_ext_foo(); +#pragma OPENCL EXTENSION cl_my_ext : end Index: test/Headers/opencl-pragma-extension-begin.cl === --- /dev/null +++ test/Headers/opencl-pragma-extension-begin.cl @@ -0,0 +1,13 @@ +// RUN: rm -rf %t.ocl.pragma.ext.begin +// RUN: mkdir -p %t.ocl.pragma.ext.begin +// +// RUN: %clang_cc1 -cl-std=CL1.2 -include %S/opencl-pragma-extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.ocl.pragma.ext.begin %s 2>&1 +// +// RUN: rm -rf %t.ocl.pragma.ext.begin +// RUN: mkdir -p %t.ocl.pragma.ext.begin +// +// RUN: %clang_cc1 -cl-std=CL2.0 -include %S/opencl-pragma-extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.ocl.pragma.ext.begin %s 2>&1 + +void __kernel test(__global int *data) { + *data = 10; +} Index: lib/Serialization/ASTWriter.cpp === --- lib/Serialization/ASTWriter.cpp +++ lib/Serialization/ASTWriter.cpp @@ -5014,13 +5014,16 @@ WriteFPPragmaOptions(SemaRef.getFPOptions()); WriteOpenCLExtensions(SemaRef); WriteOpenCLExtensionTypes(SemaRef); - WriteOpenCLExtensionDecls(SemaRef); WriteCUDAPragmas(SemaRef); // If we're emitting a module, write out the submodule information. if (WritingModule) WriteSubmodules(WritingModule); + // We need to have information about submodules to correctly deserialize + // decls from OpenCLExtensionDecls block + WriteOpenCLExtensionDecls(SemaRef); + Stream.EmitRecord(SPECIAL_TYPES, SpecialTypes); // Write the record containing external, unnamed definitions. Index: test/Headers/opencl-pragma-extension-begin.h === --- /dev/null +++ test/Headers/opencl-pragma-extension-begin.h @@ -0,0 +1,4 @@ + +#pragma OPENCL EXTENSION cl_my_ext : begin +void cl_my_ext_foo(); +#pragma OPENCL EXTENSION cl_my_ext : end Index: test/Headers/opencl-pragma-extension-begin.cl === --- /dev/null +++ test/Headers/opencl-pragma-extension-begin.cl @@ -0,0 +1,13 @@ +// RUN: rm -rf %t.ocl.pragma.ext.begin +// RUN: mkdir -p %t.ocl.pragma.ext.begin +// +// RUN: %clang_cc1 -cl-std=CL1.2 -include %S/opencl-pragma-extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.ocl.pragma.ext.begin %s 2>&1 +// +// RUN: rm -rf %t.ocl.pragma.ext.begin +// RUN: mkdir -p %t.ocl.pragma.ext.begin +// +// RUN: %clang_cc1 -cl-std=CL2.0 -include %S/opencl-pragma-extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.ocl.pragma.ext.begin %s 2>&1 + +void __kernel test(__global int *data) { + *data = 10; +} Index: lib/Serialization/ASTWriter.cpp === --- lib/Serialization/ASTWriter.cpp +++ lib/Serialization/ASTWriter.cpp @@ -5014,13 +5014,16 @@ WriteFPPragmaOptions(SemaRef.getFPOptions()); WriteOpenCLExtensions(SemaRef); WriteOpenCLExtensionTypes(SemaRef); - WriteOpenCLExtensionDecls(SemaRef); WriteCUDAPragmas(SemaRef); // If we're emitting a module, write out the submodule information. if (WritingModule) WriteSubmodules(WritingModule); + // We need to have information about submodules to correctly deserialize + // decls from OpenCLExtensionDecls block + WriteOpenCLExtensionDecls(SemaRef); + Stream.EmitRecord(SPECIAL_TYPES, SpecialTypes); // Write the record containing external, unnamed definitions. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53329: Generate DIFile with main program if source is not available
yonghong-song added a comment. In the above `/virtual/main.c` is a memory mapped file. The `invocation0.getPreprocessorOpts().addRemappedFile(...)` adds the mapping for the compilation. Repository: rC Clang https://reviews.llvm.org/D53329 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50539: [VFS] Add property 'fallthrough' that controls fallback to real file system.
vsapsai updated this revision to Diff 169849. vsapsai added a comment. Herald added a subscriber: hiraditya. - Rebase on top of the latest changes in trunk. - Address review comments. I expect diff between diffs to be noisy due to rebase. https://reviews.llvm.org/D50539 Files: clang/lib/Frontend/CompilerInvocation.cpp clang/test/VFS/Inputs/Broken.framework/Headers/Error.h clang/test/VFS/Inputs/Broken.framework/Modules/module.modulemap clang/test/VFS/Inputs/Broken.framework/VFSHeaders/A.h clang/test/VFS/Inputs/vfsroot.yaml clang/test/VFS/vfsroot-include.c clang/test/VFS/vfsroot-module.m clang/test/VFS/vfsroot-with-overlay.c llvm/lib/Support/VirtualFileSystem.cpp llvm/unittests/Support/VirtualFileSystemTest.cpp Index: llvm/unittests/Support/VirtualFileSystemTest.cpp === --- llvm/unittests/Support/VirtualFileSystemTest.cpp +++ llvm/unittests/Support/VirtualFileSystemTest.cpp @@ -1599,3 +1599,89 @@ EXPECT_EQ(3, NumDiagnostics); } + +TEST_F(VFSFromYAMLTest, NonFallthroughDirectoryIteration) { + IntrusiveRefCntPtr Lower(new DummyFileSystem()); + Lower->addDirectory("//root/"); + Lower->addRegularFile("//root/a"); + Lower->addRegularFile("//root/b"); + IntrusiveRefCntPtr FS = getFromYAMLString( + "{ 'use-external-names': false,\n" + " 'fallthrough': false,\n" + " 'roots': [\n" + "{\n" + " 'type': 'directory',\n" + " 'name': '//root/',\n" + " 'contents': [ {\n" + " 'type': 'file',\n" + " 'name': 'c',\n" + " 'external-contents': '//root/a'\n" + "}\n" + " ]\n" + "}\n" + "]\n" + "}", + Lower); + ASSERT_TRUE(FS.get() != nullptr); + + std::error_code EC; + checkContents(FS->dir_begin("//root/", EC), +{"//root/c"}); +} + +TEST_F(VFSFromYAMLTest, DirectoryIterationWithDuplicates) { + IntrusiveRefCntPtr Lower(new DummyFileSystem()); + Lower->addDirectory("//root/"); + Lower->addRegularFile("//root/a"); + Lower->addRegularFile("//root/b"); + IntrusiveRefCntPtr FS = getFromYAMLString( + "{ 'use-external-names': false,\n" + " 'roots': [\n" + "{\n" + " 'type': 'directory',\n" + " 'name': '//root/',\n" + " 'contents': [ {\n" + " 'type': 'file',\n" + " 'name': 'a',\n" + " 'external-contents': '//root/a'\n" + "}\n" + " ]\n" + "}\n" + "]\n" + "}", + Lower); + ASSERT_TRUE(FS.get() != nullptr); + + std::error_code EC; + checkContents(FS->dir_begin("//root/", EC), +{"//root/a", "//root/b"}); +} + +TEST_F(VFSFromYAMLTest, DirectoryIterationErrorInVFSLayer) { + IntrusiveRefCntPtr Lower(new DummyFileSystem()); + Lower->addDirectory("//root/"); + Lower->addDirectory("//root/foo"); + Lower->addRegularFile("//root/foo/a"); + Lower->addRegularFile("//root/foo/b"); + IntrusiveRefCntPtr FS = getFromYAMLString( + "{ 'use-external-names': false,\n" + " 'roots': [\n" + "{\n" + " 'type': 'directory',\n" + " 'name': '//root/',\n" + " 'contents': [ {\n" + " 'type': 'file',\n" + " 'name': 'bar/a',\n" + " 'external-contents': '//root/foo/a'\n" + "}\n" + " ]\n" + "}\n" + "]\n" + "}", + Lower); + ASSERT_TRUE(FS.get() != nullptr); + + std::error_code EC; + checkContents(FS->dir_begin("//root/foo", EC), +{"//root/foo/a", "//root/foo/b"}); +} Index: llvm/lib/Support/VirtualFileSystem.cpp === --- llvm/lib/Support/VirtualFileSystem.cpp +++ llvm/lib/Support/VirtualFileSystem.cpp @@ -993,16 +993,40 @@ static bool classof(const Entry *E) { return E->getKind() == EK_File; } }; +// FIXME: reuse implementation common with OverlayFSDirIterImpl as these +// iterators are conceptually similar. class VFSFromYamlDirIterImpl : public llvm::vfs::detail::DirIterImpl { std::string Dir; RedirectingDirectoryEntry::iterator Current, End; - std::error_code incrementImpl(); + // To handle 'fallthrough' mode we need to iterate at first through + // RedirectingDirectoryEntry and then through ExternalFS. These operations are + // done sequentially, we just need to keep a track of what kind of iteration + // we are currently performing. + + // Flag telling if we should iterate through ExternalFS or stop at the last + // RedirectingDirectoryEntry::iterator. + bool IterateExternalFS; + // Flag telling if we have switched to iterating through ExternalFS. + bool IsExternalFSCurrent = false; + FileSystem + directory_iterator ExternalDirIter; + llvm::StringSet<> SeenNames; + + // To combine multiple iterations, different methods are responsible for... +
[PATCH] D53329: Generate DIFile with main program if source is not available
yonghong-song added a comment. We already have `-main-file-name` in cc1. `clang -cc1 -triple x86_64-unknown-linux-gnu ... -main-file-name main.c ... -o main.bc -x c /virtual/main.c -faddrsig` Is this expected? BTW, we just pass the normal C flags to the driver like vector flags_cstr({"-O0", "-O2", "-emit-llvm", "-I", dstack.cwd(), "-D", "__BPF_TRACING__", "-Wno-deprecated-declarations", "-Wno-gnu-variable-sized-type-not-at-end", "-Wno-pragma-once-outside-header", "-Wno-address-of-packed-member", "-Wno-unknown-warning-option", "-fno-color-diagnostics", "-fno-unwind-tables", "-fno-asynchronous-unwind-tables", "-x", "c", "-c", abs_file.c_str()}); flags_cstr.push_back("-g"); flags_cstr.push_back("-gdwarf-5"); flags_cstr.push_back("-gembed-source"); // A few other flags We call drv.BuildCompilation to get the cc1 flags. Repository: rC Clang https://reviews.llvm.org/D53329 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52320: AMDGPU: add __builtin_amdgcn_update_dpp
b-sumner added a comment. Ping. There's quite a bit of interest in getting this exposed by clang. https://reviews.llvm.org/D52320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53329: Generate DIFile with main program if source is not available
aprantl added a comment. Couldn't you just pass `-main-file-name` to cc1 instead? Repository: rC Clang https://reviews.llvm.org/D53329 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53329: Generate DIFile with main program if source is not available
yonghong-song added a comment. Hi, @vsk @HsiangKai @ABataev I found a bug in clang when trying to use "-g -gdwarf-5 -gembed-source" for bcc MCJIT based clang/llvm compilation. This patch fixed the issue but I am not sure whether this is the correct fix or not. Please help take a look and advise if the fix is not correct and there is a better one. Thanks! Repository: rC Clang https://reviews.llvm.org/D53329 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53329: Generate DIFile with main program if source is not available
yonghong-song created this revision. yonghong-song added reviewers: vsk, HsiangKai, ABataev. yonghong-song added a project: debug-info. Herald added subscribers: cfe-commits, JDevlieghere, aprantl. A llvm segfault happens when I tried to add "-g -gdwarf-5 -gembed-source" in bcc in order to get soruce code into IR and dwarf. A little bit background, bcc (https://github.com/iovisor/bcc) utilizes llvm MCJIT to generate BPF insns and load them to the kernel for execution. Several files passed to clang are memory mapped including the main program /virtual/main.c. I did some analysis on why segfault happens and whether we did get all file sources. And I found that we did not get source for one instance: !32 = !DIFile(filename: "/virtual/main.c", directory: "/usr/src/kernels/4.11.3-70_fbk18_4116_g1cf3f1a0ca4f") After some debugging, I found this patch can fix the problem. Basically, when the source is not available to generate DIFile use the main program. You can get more details of the bug, IR, cc1 flags, segfault stack and how to reproduce at this commit: https://github.com/yonghong-song/bcc/commit/7ac342e05468e60138d61e0e41691ed2f98bd929 Signed-off-by: Yonghong Song Repository: rC Clang https://reviews.llvm.org/D53329 Files: lib/CodeGen/CGDebugInfo.cpp Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -411,6 +411,10 @@ // If the location is not valid then use main input file. return getOrCreateMainFile(); + if (!getSource(SM, SM.getFileID(Loc))) +// If the source file is not valid then use main input file +return getOrCreateMainFile(); + // Cache the results. const char *fname = PLoc.getFilename(); auto It = DIFileCache.find(fname); Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -411,6 +411,10 @@ // If the location is not valid then use main input file. return getOrCreateMainFile(); + if (!getSource(SM, SM.getFileID(Loc))) +// If the source file is not valid then use main input file +return getOrCreateMainFile(); + // Cache the results. const char *fname = PLoc.getFilename(); auto It = DIFileCache.find(fname); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53286: [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction.
This revision was automatically updated to reflect the committed changes. sammccall marked 5 inline comments as done. Closed by commit rL344620: [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction. (authored by sammccall, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D53286?vs=169835=169841#toc Repository: rL LLVM https://reviews.llvm.org/D53286 Files: clang-tools-extra/trunk/clangd/CMakeLists.txt clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdLSPServer.h clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h clang-tools-extra/trunk/clangd/JSONTransport.cpp clang-tools-extra/trunk/clangd/Protocol.cpp clang-tools-extra/trunk/clangd/Protocol.h clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp clang-tools-extra/trunk/clangd/Transport.h clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test clang-tools-extra/trunk/test/clangd/completion-snippets.test clang-tools-extra/trunk/test/clangd/completion.test clang-tools-extra/trunk/test/clangd/crash-non-added-files.test clang-tools-extra/trunk/test/clangd/execute-command.test clang-tools-extra/trunk/test/clangd/input-mirror.test clang-tools-extra/trunk/test/clangd/signature-help.test clang-tools-extra/trunk/test/clangd/textdocument-didchange-fail.test clang-tools-extra/trunk/test/clangd/trace.test clang-tools-extra/trunk/test/clangd/xrefs.test clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt clang-tools-extra/trunk/unittests/clangd/JSONTransportTests.cpp Index: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h === --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h @@ -14,6 +14,7 @@ #include "Logger.h" #include "Protocol.h" #include "Trace.h" +#include "Transport.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" @@ -24,37 +25,19 @@ namespace clang { namespace clangd { -/// Encapsulates output and logs streams and provides thread-safe access to -/// them. +// Logs to an output stream, such as stderr. +// FIXME: Rename to StreamLogger or such, and move to Logger.h. class JSONOutput : public Logger { - // FIXME(ibiryukov): figure out if we can shrink the public interface of - // JSONOutput now that we pass Context everywhere. public: - JSONOutput(llvm::raw_ostream , llvm::raw_ostream , - Logger::Level MinLevel, llvm::raw_ostream *InputMirror = nullptr, - bool Pretty = false) - : Pretty(Pretty), MinLevel(MinLevel), Outs(Outs), Logs(Logs), -InputMirror(InputMirror) {} - - /// Emit a JSONRPC message. - void writeMessage(const llvm::json::Value ); + JSONOutput(llvm::raw_ostream , Logger::Level MinLevel) + : MinLevel(MinLevel), Logs(Logs) {} /// Write a line to the logging stream. void log(Level, const llvm::formatv_object_base ) override; - /// Mirror \p Message into InputMirror stream. Does nothing if InputMirror is - /// null. - /// Unlike other methods of JSONOutput, mirrorInput is not thread-safe. - void mirrorInput(const Twine ); - - // Whether output should be pretty-printed. - const bool Pretty; - private: Logger::Level MinLevel; - llvm::raw_ostream llvm::raw_ostream - llvm::raw_ostream *InputMirror; std::mutex StreamMutex; }; @@ -81,26 +64,39 @@ /// /// The `$/cancelRequest` notification is handled by the dispatcher itself. /// It marks the matching request as cancelled, if it's still running. -class JSONRPCDispatcher { +class JSONRPCDispatcher : private Transport::MessageHandler { public: /// A handler responds to requests for a particular method name. + /// It returns false if the server should now shut down. /// /// JSONRPCDispatcher will mark the handler's context as cancelled if a /// matching cancellation request is received. Handlers are encouraged to /// check for cancellation and fail quickly in this case. - using Handler = std::function; + using Handler = std::function; /// Create a new JSONRPCDispatcher. UnknownHandler is called when an unknown /// method is received. JSONRPCDispatcher(Handler UnknownHandler); /// Registers a Handler for the specified Method. void registerHandler(StringRef Method, Handler H); - /// Parses a JSONRPC message and calls the Handler for it. - bool call(const llvm::json::Value , JSONOutput ); + /// Parses input queries from LSP client (coming from \p In) and runs call + /// method for each query. + /// + /// Input stream(\p In) must be opened in binary mode to avoid + /// preliminary replacements of \r\n with \n. We use C-style FILE* for reading + /// as std::istream has unclear interaction with signals, which
[clang-tools-extra] r344620 - [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction.
Author: sammccall Date: Tue Oct 16 09:48:06 2018 New Revision: 344620 URL: http://llvm.org/viewvc/llvm-project?rev=344620=rev Log: [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction. Summary: This paves the way for alternative transports (mac XPC, maybe messagepack?), and also generally improves layering: testing ClangdLSPServer becomes less of a pipe dream, we split up the JSONOutput monolith, etc. This isn't a final state, much of what remains in JSONRPCDispatcher can go away, handlers can call reply() on the transport directly, JSONOutput can be renamed to StreamLogger and removed, etc. But this patch is sprawling already. The main observable change (see tests) is that hitting EOF on input is now an error: the client should send the 'exit' notification. This is defensible: the protocol doesn't spell this case out. Reproducing the current behavior for all combinations of shutdown/exit/EOF clutters interfaces. We can iterate on this if desired. Reviewers: jkorous, ioeric, hokein Subscribers: mgorny, ilya-biryukov, MaskRay, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53286 Added: clang-tools-extra/trunk/clangd/JSONTransport.cpp clang-tools-extra/trunk/clangd/Transport.h clang-tools-extra/trunk/unittests/clangd/JSONTransportTests.cpp Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdLSPServer.h clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h clang-tools-extra/trunk/clangd/Protocol.cpp clang-tools-extra/trunk/clangd/Protocol.h clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp clang-tools-extra/trunk/test/clangd/compile-commands-path-in-initialize.test clang-tools-extra/trunk/test/clangd/completion-snippets.test clang-tools-extra/trunk/test/clangd/completion.test clang-tools-extra/trunk/test/clangd/crash-non-added-files.test clang-tools-extra/trunk/test/clangd/execute-command.test clang-tools-extra/trunk/test/clangd/input-mirror.test clang-tools-extra/trunk/test/clangd/signature-help.test clang-tools-extra/trunk/test/clangd/textdocument-didchange-fail.test clang-tools-extra/trunk/test/clangd/trace.test clang-tools-extra/trunk/test/clangd/xrefs.test clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=344620=344619=344620=diff == --- clang-tools-extra/trunk/clangd/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clangd/CMakeLists.txt Tue Oct 16 09:48:06 2018 @@ -26,6 +26,7 @@ add_clang_library(clangDaemon GlobalCompilationDatabase.cpp Headers.cpp JSONRPCDispatcher.cpp + JSONTransport.cpp Logger.cpp Protocol.cpp ProtocolHandlers.cpp Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=344620=344619=344620=diff == --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Oct 16 09:48:06 2018 @@ -162,7 +162,10 @@ void ClangdLSPServer::onShutdown(Shutdow reply(nullptr); } -void ClangdLSPServer::onExit(ExitParams ) { IsDone = true; } +void ClangdLSPServer::onExit(ExitParams ) { + // No work to do. + // JSONRPCDispatcher shuts down the transport after this notification. +} void ClangdLSPServer::onDocumentDidOpen(DidOpenTextDocumentParams ) { PathRef File = Params.textDocument.uri.file(); @@ -497,39 +500,41 @@ void ClangdLSPServer::onReference(Refere }); } -ClangdLSPServer::ClangdLSPServer(JSONOutput , +ClangdLSPServer::ClangdLSPServer(class Transport , const clangd::CodeCompleteOptions , llvm::Optional CompileCommandsDir, bool ShouldUseInMemoryCDB, const ClangdServer::Options ) -: Out(Out), CDB(ShouldUseInMemoryCDB ? CompilationDB::makeInMemory() - : CompilationDB::makeDirectoryBased( - std::move(CompileCommandsDir))), +: Transport(Transport), + CDB(ShouldUseInMemoryCDB ? CompilationDB::makeInMemory() + : CompilationDB::makeDirectoryBased( + std::move(CompileCommandsDir))), CCOpts(CCOpts), SupportedSymbolKinds(defaultSymbolKinds()), SupportedCompletionItemKinds(defaultCompletionItemKinds()), Server(new
[PATCH] D53266: [clangd] Simplify client capabilities parsing.
sammccall updated this revision to Diff 169839. sammccall added a comment. Rebase to include CodeAction literal support Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53266 Files: clangd/ClangdLSPServer.cpp clangd/Protocol.cpp clangd/Protocol.h Index: clangd/Protocol.h === --- clangd/Protocol.h +++ clangd/Protocol.h @@ -221,18 +221,6 @@ Incremental = 2, }; -struct CompletionItemClientCapabilities { - /// Client supports snippets as insert text. - bool snippetSupport = false; - /// Client supports commit characters on a completion item. - bool commitCharacterSupport = false; - // Client supports the follow content formats for the documentation property. - // The order describes the preferred format of the client. - // NOTE: not used by clangd at the moment. - // std::vector documentationFormat; -}; -bool fromJSON(const llvm::json::Value &, CompletionItemClientCapabilities &); - /// The kind of a completion entry. enum class CompletionItemKind { Missing = 0, @@ -263,58 +251,16 @@ TypeParameter = 25, }; bool fromJSON(const llvm::json::Value &, CompletionItemKind &); - -struct CompletionItemKindCapabilities { - /// The CompletionItemKinds that the client supports. If not set, the client - /// only supports <= CompletionItemKind::Reference and will not fall back to a - /// valid default value. - llvm::Optional> valueSet; -}; -// Discards unknown CompletionItemKinds. -bool fromJSON(const llvm::json::Value &, std::vector &); -bool fromJSON(const llvm::json::Value &, CompletionItemKindCapabilities &); - constexpr auto CompletionItemKindMin = static_cast(CompletionItemKind::Text); constexpr auto CompletionItemKindMax = static_cast(CompletionItemKind::TypeParameter); using CompletionItemKindBitset = std::bitset; +bool fromJSON(const llvm::json::Value &, CompletionItemKindBitset &); CompletionItemKind adjustKindToCapability(CompletionItemKind Kind, CompletionItemKindBitset ); -struct CompletionClientCapabilities { - /// Whether completion supports dynamic registration. - bool dynamicRegistration = false; - /// The client supports the following `CompletionItem` specific capabilities. - CompletionItemClientCapabilities completionItem; - /// The CompletionItemKinds that the client supports. If not set, the client - /// only supports <= CompletionItemKind::Reference and will not fall back to a - /// valid default value. - llvm::Optional completionItemKind; - - /// The client supports to send additional context information for a - /// `textDocument/completion` request. - bool contextSupport = false; -}; -bool fromJSON(const llvm::json::Value &, CompletionClientCapabilities &); - -struct PublishDiagnosticsClientCapabilities { - // Whether the client accepts diagnostics with related information. - // NOTE: not used by clangd at the moment. - // bool relatedInformation; - - /// Whether the client accepts diagnostics with fixes attached using the - /// "clangd_fixes" extension. - bool clangdFixSupport = false; - - /// Whether the client accepts diagnostics with category attached to it - /// using the "category" extension. - bool categorySupport = false; -}; -bool fromJSON(const llvm::json::Value &, - PublishDiagnosticsClientCapabilities &); - /// A symbol kind. enum class SymbolKind { File = 1, @@ -344,62 +290,44 @@ Operator = 25, TypeParameter = 26 }; - +bool fromJSON(const llvm::json::Value &, SymbolKind &); constexpr auto SymbolKindMin = static_cast(SymbolKind::File); constexpr auto SymbolKindMax = static_cast(SymbolKind::TypeParameter); using SymbolKindBitset = std::bitset; - -bool fromJSON(const llvm::json::Value &, SymbolKind &); - -struct SymbolKindCapabilities { - /// The SymbolKinds that the client supports. If not set, the client only - /// supports <= SymbolKind::Array and will not fall back to a valid default - /// value. - llvm::Optional> valueSet; -}; -// Discards unknown SymbolKinds. -bool fromJSON(const llvm::json::Value &, std::vector &); -bool fromJSON(const llvm::json::Value &, SymbolKindCapabilities &); +bool fromJSON(const llvm::json::Value &, SymbolKindBitset &); SymbolKind adjustKindToCapability(SymbolKind Kind, SymbolKindBitset ); -struct WorkspaceSymbolCapabilities { - /// Capabilities SymbolKind. - llvm::Optional symbolKind; -}; -bool fromJSON(const llvm::json::Value &, WorkspaceSymbolCapabilities &); - -// FIXME: most of the capabilities are missing from this struct. Only the ones -// used by clangd are currently there. -struct WorkspaceClientCapabilities { - /// Capabilities specific to `workspace/symbol`. - llvm::Optional symbol; -}; -bool fromJSON(const llvm::json::Value &, WorkspaceClientCapabilities &); +// This struct doesn't mirror LSP! +// The protocol defines deeply nested structures for client capabilities. +// Instead of mapping them
[PATCH] D53325: Disable code object version 3 for HIP toolchain
kzhuravl accepted this revision. kzhuravl added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D53325 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53286: [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction.
ioeric accepted this revision. ioeric added inline comments. This revision is now accepted and ready to land. Comment at: clangd/JSONRPCDispatcher.h:70 /// A handler responds to requests for a particular method name. + /// It returns true if the server should now shut down. /// s/true/false/ Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53286 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53213: [clangd] Send CodeAction responses to textDocument/codeAction (LSP 3.8)
This revision was automatically updated to reflect the committed changes. Closed by commit rL344617: [clangd] Send CodeAction responses to textDocument/codeAction (LSP 3.8) (authored by sammccall, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D53213?vs=169837=169838#toc Repository: rL LLVM https://reviews.llvm.org/D53213 Files: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdLSPServer.h clang-tools-extra/trunk/clangd/Protocol.cpp clang-tools-extra/trunk/clangd/Protocol.h clang-tools-extra/trunk/test/clangd/fixits-codeaction.test clang-tools-extra/trunk/test/clangd/fixits-command.test clang-tools-extra/trunk/test/clangd/fixits.test Index: clang-tools-extra/trunk/test/clangd/fixits-command.test === --- clang-tools-extra/trunk/test/clangd/fixits-command.test +++ clang-tools-extra/trunk/test/clangd/fixits-command.test @@ -0,0 +1,210 @@ +# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} +--- +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"int main(int i, char **a) { if (i = 2) {}}"}}} +# CHECK:"method": "textDocument/publishDiagnostics", +# CHECK-NEXT: "params": { +# CHECK-NEXT:"diagnostics": [ +# CHECK-NEXT: { +# CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses", +# CHECK-NEXT:"range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT:"character": 37, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT:"character": 32, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: } +# CHECK-NEXT:}, +# CHECK-NEXT:"severity": 2 +# CHECK-NEXT: } +# CHECK-NEXT:], +# CHECK-NEXT:"uri": "file://{{.*}}/foo.c" +# CHECK-NEXT: } +--- +{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses"}]}}} +# CHECK: "id": 2, +# CHECK-NEXT: "jsonrpc": "2.0", +# CHECK-NEXT: "result": [ +# CHECK-NEXT:{ +# CHECK-NEXT: "arguments": [ +# CHECK-NEXT:{ +# CHECK-NEXT: "changes": { +# CHECK-NEXT:"file://{{.*}}/foo.c": [ +# CHECK-NEXT: { +# CHECK-NEXT:"newText": "(", +# CHECK-NEXT:"range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT:"character": 32, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT:"character": 32, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: } +# CHECK-NEXT:} +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT:"newText": ")", +# CHECK-NEXT:"range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT:"character": 37, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT:"character": 37, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: } +# CHECK-NEXT:} +# CHECK-NEXT: } +# CHECK-NEXT:] +# CHECK-NEXT: } +# CHECK-NEXT:} +# CHECK-NEXT: ], +# CHECK-NEXT: "command": "clangd.applyFix", +# CHECK-NEXT: "title": "Apply fix: place parentheses around the assignment to silence this warning" +# CHECK-NEXT:}, +# CHECK-NEXT:{ +# CHECK-NEXT: "arguments": [ +# CHECK-NEXT:{ +# CHECK-NEXT: "changes": { +# CHECK-NEXT:"file://{{.*}}/foo.c": [ +# CHECK-NEXT: { +# CHECK-NEXT:"newText": "==", +# CHECK-NEXT:"range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT:"character": 35, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT:"character": 34, +# CHECK-NEXT:"line": 0 +# CHECK-NEXT: } +# CHECK-NEXT:} +# CHECK-NEXT: } +# CHECK-NEXT:] +# CHECK-NEXT: } +# CHECK-NEXT:} +# CHECK-NEXT: ], +# CHECK-NEXT: "command": "clangd.applyFix", +# CHECK-NEXT: "title":
[PATCH] D53213: [clangd] Send CodeAction responses to textDocument/codeAction (LSP 3.8)
sammccall updated this revision to Diff 169837. sammccall added a comment. rebase only Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53213 Files: clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/Protocol.cpp clangd/Protocol.h test/clangd/fixits-codeaction.test test/clangd/fixits-command.test test/clangd/fixits.test Index: test/clangd/fixits.test === --- /dev/null +++ test/clangd/fixits.test @@ -1,210 +0,0 @@ -# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s -{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} -{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"int main(int i, char **a) { if (i = 2) {}}"}}} -# CHECK:"method": "textDocument/publishDiagnostics", -# CHECK-NEXT: "params": { -# CHECK-NEXT:"diagnostics": [ -# CHECK-NEXT: { -# CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses", -# CHECK-NEXT:"range": { -# CHECK-NEXT: "end": { -# CHECK-NEXT:"character": 37, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: }, -# CHECK-NEXT: "start": { -# CHECK-NEXT:"character": 32, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: } -# CHECK-NEXT:}, -# CHECK-NEXT:"severity": 2 -# CHECK-NEXT: } -# CHECK-NEXT:], -# CHECK-NEXT:"uri": "file://{{.*}}/foo.c" -# CHECK-NEXT: } -{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses"}]}}} -# CHECK: "id": 2, -# CHECK-NEXT: "jsonrpc": "2.0", -# CHECK-NEXT: "result": [ -# CHECK-NEXT:{ -# CHECK-NEXT: "arguments": [ -# CHECK-NEXT:{ -# CHECK-NEXT: "changes": { -# CHECK-NEXT:"file://{{.*}}/foo.c": [ -# CHECK-NEXT: { -# CHECK-NEXT:"newText": "(", -# CHECK-NEXT:"range": { -# CHECK-NEXT: "end": { -# CHECK-NEXT:"character": 32, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: }, -# CHECK-NEXT: "start": { -# CHECK-NEXT:"character": 32, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: } -# CHECK-NEXT:} -# CHECK-NEXT: }, -# CHECK-NEXT: { -# CHECK-NEXT:"newText": ")", -# CHECK-NEXT:"range": { -# CHECK-NEXT: "end": { -# CHECK-NEXT:"character": 37, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: }, -# CHECK-NEXT: "start": { -# CHECK-NEXT:"character": 37, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: } -# CHECK-NEXT:} -# CHECK-NEXT: } -# CHECK-NEXT:] -# CHECK-NEXT: } -# CHECK-NEXT:} -# CHECK-NEXT: ], -# CHECK-NEXT: "command": "clangd.applyFix", -# CHECK-NEXT: "title": "Apply fix: place parentheses around the assignment to silence this warning" -# CHECK-NEXT:}, -# CHECK-NEXT:{ -# CHECK-NEXT: "arguments": [ -# CHECK-NEXT:{ -# CHECK-NEXT: "changes": { -# CHECK-NEXT:"file://{{.*}}/foo.c": [ -# CHECK-NEXT: { -# CHECK-NEXT:"newText": "==", -# CHECK-NEXT:"range": { -# CHECK-NEXT: "end": { -# CHECK-NEXT:"character": 35, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: }, -# CHECK-NEXT: "start": { -# CHECK-NEXT:"character": 34, -# CHECK-NEXT:"line": 0 -# CHECK-NEXT: } -# CHECK-NEXT:} -# CHECK-NEXT: } -# CHECK-NEXT:] -# CHECK-NEXT: } -# CHECK-NEXT:} -# CHECK-NEXT: ], -# CHECK-NEXT: "command": "clangd.applyFix", -# CHECK-NEXT: "title": "Apply fix: use '==' to turn this assignment into an equality comparison" -# CHECK-NEXT:} -# CHECK-NEXT: ] -{"jsonrpc":"2.0","id":3,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":104,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without
[clang-tools-extra] r344617 - [clangd] Send CodeAction responses to textDocument/codeAction (LSP 3.8)
Author: sammccall Date: Tue Oct 16 09:29:41 2018 New Revision: 344617 URL: http://llvm.org/viewvc/llvm-project?rev=344617=rev Log: [clangd] Send CodeAction responses to textDocument/codeAction (LSP 3.8) Summary: I don't bother mirroring the full capabilities struct, just parse the bits we care about. I'll send a new patch to use this approach elsewhere too. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53213 Added: clang-tools-extra/trunk/test/clangd/fixits-codeaction.test clang-tools-extra/trunk/test/clangd/fixits-command.test - copied, changed from r344614, clang-tools-extra/trunk/test/clangd/fixits.test Removed: clang-tools-extra/trunk/test/clangd/fixits.test Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdLSPServer.h clang-tools-extra/trunk/clangd/Protocol.cpp clang-tools-extra/trunk/clangd/Protocol.h Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=344617=344616=344617=diff == --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Oct 16 09:29:41 2018 @@ -103,6 +103,8 @@ void ClangdLSPServer::onInitialize(Initi Params.capabilities.textDocument.publishDiagnostics.clangdFixSupport; DiagOpts.SendDiagnosticCategory = Params.capabilities.textDocument.publishDiagnostics.categorySupport; + SupportsCodeAction = + Params.capabilities.textDocument.codeActionLiteralSupport; if (Params.capabilities.workspace && Params.capabilities.workspace->symbol && Params.capabilities.workspace->symbol->symbolKind && @@ -339,29 +341,53 @@ void ClangdLSPServer::onDocumentSymbol(D }); } +static Optional asCommand(const CodeAction ) { + Command Cmd; + if (Action.command && Action.edit) +return llvm::None; // Not representable. (We never emit these anyway). + if (Action.command) { +Cmd = *Action.command; + } else if (Action.edit) { +Cmd.command = Command::CLANGD_APPLY_FIX_COMMAND; +Cmd.workspaceEdit = *Action.edit; + } else { +return llvm::None; + } + Cmd.title = Action.title; + if (Action.kind && *Action.kind == CodeAction::QUICKFIX_KIND) +Cmd.title = "Apply fix: " + Cmd.title; + return Cmd; +} + void ClangdLSPServer::onCodeAction(CodeActionParams ) { - // We provide a code action for each diagnostic at the requested location - // which has FixIts available. - auto Code = DraftMgr.getDraft(Params.textDocument.uri.file()); - if (!Code) + // We provide a code action for Fixes on the specified diagnostics. + if (!DraftMgr.getDraft(Params.textDocument.uri.file())) return replyError(ErrorCode::InvalidParams, "onCodeAction called for non-added file"); - std::vector Commands; + std::vector Actions; for (Diagnostic : Params.context.diagnostics) { for (auto : getFixes(Params.textDocument.uri.file(), D)) { - WorkspaceEdit WE; - std::vector Edits(F.Edits.begin(), F.Edits.end()); - Commands.emplace_back(); - Commands.back().title = llvm::formatv("Apply fix: {0}", F.Message); - Commands.back().command = ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND; - Commands.back().workspaceEdit.emplace(); - Commands.back().workspaceEdit->changes = { - {Params.textDocument.uri.uri(), std::move(Edits)}, - }; + Actions.emplace_back(); + Actions.back().title = F.Message; + Actions.back().kind = CodeAction::QUICKFIX_KIND; + Actions.back().diagnostics = {D}; + Actions.back().edit.emplace(); + Actions.back().edit->changes.emplace(); + (*Actions.back().edit->changes)[Params.textDocument.uri.uri()] = { + F.Edits.begin(), F.Edits.end()}; } } - reply(json::Array(Commands)); + + if (SupportsCodeAction) +reply(json::Array(Actions)); + else { +std::vector Commands; +for (const auto : Actions) + if (auto Command = asCommand(Action)) +Commands.push_back(std::move(*Command)); +reply(json::Array(Commands)); + } } void ClangdLSPServer::onCompletion(TextDocumentPositionParams ) { Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=344617=344616=344617=diff == --- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Tue Oct 16 09:29:41 2018 @@ -166,6 +166,8 @@ private: SymbolKindBitset SupportedSymbolKinds; /// The supported completion item kinds of the client. CompletionItemKindBitset SupportedCompletionItemKinds; + // Whether the