[PATCH] D36150: [clangd] LSP extension to switch between source/header file
ilya-biryukov added a comment. The function in `ClangdServer` seems to be getting more complicated and more complicated, mostly because of mixing up `std::string`, `StringRef`, `SmallString`. Here's a slightly revamped implementation of your function, hope you'll find it (or parts of it) useful to simplify your implementation and address remaining comments. // Note that the returned value is now llvm::Optional to clearly indicate no matching file was found. llvm::Optional ClangdServer::switchSourceHeader(PathRef Path) { const StringRef SourceExtensions[] = {/*...*/; // only lower-case extensions const StringRef HeaderExtensions[] = {/*...*/}; // ... StringRef PathExt = llvm::sys::path::extension(Path); // Lookup in a list of known extensions. auto SourceIter = std::find(SourceExtensions, /*end iterator*/, PathExt, [](StringRef LHS, StringRef RHS) { return LHS.equals_lower(RHS); }); bool IsSource = SourceIter != /*end iterator*/; // ... bool IsHeader = ...; // We can only switch between extensions known extensions. if (!IsSource && !IsHeader) return llvm::None; // Array to lookup extensions for the switch. An opposite of where original extension was found. ArrayRef NewExts = IsSource ? HeaderExtensions : SourceExtensions; // Storage for the new path. SmallString<128> NewPath; Path.toVector(NewPath); // Instance of vfs::FileSystem, used for file existence checks. auto FS = FSProvider.getTaggedFileSystem(Path).Value; // Loop through switched extension candidates. for (StringRef NewExt : NewExts) { llvm::sys::path::replace_extension(NewPath, NewExt) if (FS->exists(NewPath)) return NewPath.str().str(); // First str() to convert from SmallString to StringRef, second to convert from StringRef to std::string // Also check NewExt in upper-case, just in case. llvm::sys::path::replace_extension(NewPath, NewExt.upper()) if (FS->exists(NewPath)) return NewPath.str().str(); } return llvm::None; } Comment at: clangd/ClangdServer.cpp:404 +std::string returnValue = "file://" + std::string(test.str()); +returnValue = URI::unparse(URI::fromUri(returnValue)); +return Path(returnValue); No need to create a `URI` here, this should be handled outside `ClangdServer`, just return a path with replaced extension. https://reviews.llvm.org/D36150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34512: Add preliminary Cross Translation Unit support library
dkrupp added a subscriber: zaks.anna. dkrupp added a comment. The creation of this library (libCrossTU) is approved for importing function definitions. @zaks.anna, @NoQ , @klimek could you please help us reviewing the code itself? Then, when this is approved, we could progress with the review of the dependent "Support for naive cross translational unit analysis" (https://reviews.llvm.org/D30691) feature. The two patch is now in sync. Thanks a lot in advance. https://reviews.llvm.org/D34512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311319 - [ARM][AArch64] Cortex-A75 and Cortex-A55 tests
Author: sam_parker Date: Mon Aug 21 01:52:45 2017 New Revision: 311319 URL: http://llvm.org/viewvc/llvm-project?rev=311319&view=rev Log: [ARM][AArch64] Cortex-A75 and Cortex-A55 tests Add frontend tests for Cortex-A75 and Cortex-A55, Arm's latest big.LITTLE A-class cores. They implement the ARMv8.2-A architecture, including the cryptography and RAS extensions, plus the optional dot product extension. They also implement the RCpc AArch64 extension from ARMv8.3-A. Cortex-A75: https://developer.arm.com/products/processors/cortex-a/cortex-a75 Cortex-A55: https://developer.arm.com/products/processors/cortex-a/cortex-a55 Differential Revision: https://reviews.llvm.org/D36731 Added: cfe/trunk/test/Driver/aarch64-dotprod.c cfe/trunk/test/Driver/aarch64-rcpc.s cfe/trunk/test/Driver/arm-dotprod.c Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp cfe/trunk/test/Driver/aarch64-cpus.c cfe/trunk/test/Driver/aarch64-ras.c cfe/trunk/test/Driver/arm-cortex-cpus.c cfe/trunk/test/Driver/arm-ras.c Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=311319&r1=311318&r2=311319&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Mon Aug 21 01:52:45 2017 @@ -87,6 +87,15 @@ static bool DecodeARMFeatures(const Driv return true; } +static void DecodeARMFeaturesFromCPU(const Driver &D, StringRef CPU, + std::vector &Features) { + if (CPU != "generic") { +llvm::ARM::ArchKind ArchKind = llvm::ARM::parseCPUArch(CPU); +unsigned Extension = llvm::ARM::getDefaultExtensions(CPU, ArchKind); +llvm::ARM::getExtensionFeatures(Extension, Features); + } +} + // Check if -march is valid by checking if it can be canonicalised and parsed. // getARMArch is used here instead of just checking the -march value in order // to handle -march=native correctly. @@ -331,6 +340,8 @@ void arm::getARMTargetFeatures(const Too for (auto &F : HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); + } else if (!CPUName.empty()) { +DecodeARMFeaturesFromCPU(D, CPUName, Features); } // Honor -mfpu=. ClangAs gives preference to -Wa,-mfpu=. Modified: cfe/trunk/test/Driver/aarch64-cpus.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-cpus.c?rev=311319&r1=311318&r2=311319&view=diff == --- cfe/trunk/test/Driver/aarch64-cpus.c (original) +++ cfe/trunk/test/Driver/aarch64-cpus.c Mon Aug 21 01:52:45 2017 @@ -46,6 +46,19 @@ // RUN: %clang -target arm64 -mlittle-endian -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53 %s // ARM64-CA53: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "cortex-a53" +// RUN: %clang -target aarch64 -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CA55 %s +// RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CA55 %s +// RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CA55 %s +// RUN: %clang -target aarch64 -mtune=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CA55 %s +// RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CA55 %s +// CA55: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a55" + +// RUN: %clang -target arm64 -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA55 %s +// RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA55 %s +// RUN: %clang -target arm64 -mtune=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA55 %s +// RUN: %clang -target arm64 -mlittle-endian -mtune=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA55 %s +// ARM64-CA55: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "cortex-a55" + // RUN: %clang -target aarch64 -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57 %s // RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57 %s // RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57 %s @@ -88,6 +101,20 @@ // RUN: %clang -target arm64 -mlittle-endian -mtune=cortex-a73 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CORTEX-A73 %s // ARM64-CORTEX-A73: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "cortex-a73" +// RUN: %clang -target aarch64 -mcpu=cortex-a75 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-A75 %s +// RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a75 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-A75 %s +// RUN: %clang
[PATCH] D36731: [ARM][AArch64] Cortex-A75 and Cortex-A55 tests
This revision was automatically updated to reflect the committed changes. Closed by commit rL311319: [ARM][AArch64] Cortex-A75 and Cortex-A55 tests (authored by sam_parker). Changed prior to commit: https://reviews.llvm.org/D36731?vs=111664&id=111940#toc Repository: rL LLVM https://reviews.llvm.org/D36731 Files: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp cfe/trunk/test/Driver/aarch64-cpus.c cfe/trunk/test/Driver/aarch64-dotprod.c cfe/trunk/test/Driver/aarch64-ras.c cfe/trunk/test/Driver/aarch64-rcpc.s cfe/trunk/test/Driver/arm-cortex-cpus.c cfe/trunk/test/Driver/arm-dotprod.c cfe/trunk/test/Driver/arm-ras.c Index: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp === --- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp +++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp @@ -87,6 +87,15 @@ return true; } +static void DecodeARMFeaturesFromCPU(const Driver &D, StringRef CPU, + std::vector &Features) { + if (CPU != "generic") { +llvm::ARM::ArchKind ArchKind = llvm::ARM::parseCPUArch(CPU); +unsigned Extension = llvm::ARM::getDefaultExtensions(CPU, ArchKind); +llvm::ARM::getExtensionFeatures(Extension, Features); + } +} + // Check if -march is valid by checking if it can be canonicalised and parsed. // getARMArch is used here instead of just checking the -march value in order // to handle -march=native correctly. @@ -331,6 +340,8 @@ for (auto &F : HostFeatures) Features.push_back( Args.MakeArgString((F.second ? "+" : "-") + F.first())); + } else if (!CPUName.empty()) { +DecodeARMFeaturesFromCPU(D, CPUName, Features); } // Honor -mfpu=. ClangAs gives preference to -Wa,-mfpu=. Index: cfe/trunk/test/Driver/aarch64-rcpc.s === --- cfe/trunk/test/Driver/aarch64-rcpc.s +++ cfe/trunk/test/Driver/aarch64-rcpc.s @@ -0,0 +1,14 @@ +// RUN: %clang -### -target aarch64 %s 2>&1 | FileCheck --check-prefix=CHECK-NONE %s +// RUN: %clang -### -target aarch64 -march=armv8.1a %s 2>&1 | FileCheck --check-prefix=CHECK-NONE %s +// RUN: %clang -### -target aarch64 -march=armv8.2a %s 2>&1 | FileCheck --check-prefix=CHECK-NONE %s +// CHECK-NONE-NOT: "-target-feature" "+rcpc" + +// RUN: %clang -### -target aarch64 -march=armv8.2a+rcpc %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64 -march=armv8.3a+rcpc %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64 -mcpu=cortex-a75 %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64 -mcpu=cortex-a55 %s 2>&1 | FileCheck %s +// CHECK: "-target-feature" "+rcpc" + +// RUN: %clang -### -target aarch64 -mcpu=cortex-a75+norcpc %s 2>&1 | FileCheck --check-prefix=CHECK-NO-RCPC %s +// RUN: %clang -### -target aarch64 -mcpu=cortex-a55+norcpc %s 2>&1 | FileCheck --check-prefix=CHECK-NO-RCPC %s +// CHECK-NO-RCPC: "-rcpc" Index: cfe/trunk/test/Driver/arm-ras.c === --- cfe/trunk/test/Driver/arm-ras.c +++ cfe/trunk/test/Driver/arm-ras.c @@ -1,5 +1,7 @@ // RUN: %clang -target arm-none-none-eabi -march=armv8a+ras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s // RUN: %clang -target arm-none-none-eabi -mcpu=generic+ras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s +// RUN: %clang -target arm-none-none-eabi -mcpu=cortex-a75 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s +// RUN: %clang -target arm-none-none-eabi -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s // CHECK-RAS: "-target-feature" "+ras" // RUN: %clang -target arm-none-none-eabi -march=armv8a+noras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NORAS %s Index: cfe/trunk/test/Driver/aarch64-dotprod.c === --- cfe/trunk/test/Driver/aarch64-dotprod.c +++ cfe/trunk/test/Driver/aarch64-dotprod.c @@ -0,0 +1,11 @@ +// RUN: %clang -### -target aarch64 %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONE +// RUN: %clang -### -target aarch64 -march=armv8.1a %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONE +// RUN: %clang -### -target aarch64 -march=armv8.2a %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONE +// RUN: %clang -### -target aarch64 -march=armv8.3a %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONE +// CHECK-NONE-NOT: "-target-feature" "+dotprod" + +// RUN: %clang -### -target aarch64 -march=armv8.2a+dotprod %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64 -march=armv8.3a+dotprod %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64 -mcpu=cortex-a75 %s 2>&1 | FileCheck %s +// RUN: %clang -### -target aarch64 -mcpu=cortex-a55 %s 2>&1 | FileCheck %s +// CHECK: "+dotprod" Index: cfe/trunk/test/Driver/arm-dotprod.c === --- cfe/trunk/test/Driver/arm-dotprod.c +++ cfe/trunk/test/Driver/arm-dotprod.c @@ -0,0 +1,11 @@ +// RUN: %clang -### -targ
[PATCH] D36614: [clang-format] Refine trailing comment detection
krasimir added a comment. ping https://reviews.llvm.org/D36614 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36666: [ObjC] Use consistent comment style in inline asm
olista01 added reviewers: rnk, niravd, SjoerdMeijer. olista01 added a comment. Ping. Repository: rL LLVM https://reviews.llvm.org/D3 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36666: [ObjC] Use consistent comment style in inline asm
SjoerdMeijer accepted this revision. SjoerdMeijer added a comment. This revision is now accepted and ready to land. Looks reasonable to me. Repository: rL LLVM https://reviews.llvm.org/D3 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311325 - [ObjC] Use consistent comment style in inline asm
Author: olista01 Date: Mon Aug 21 02:54:46 2017 New Revision: 311325 URL: http://llvm.org/viewvc/llvm-project?rev=311325&view=rev Log: [ObjC] Use consistent comment style in inline asm The comment markers accepted by the assembler vary between different targets, but '//' is always accepted, so we should use that for consistency. Differential revision: https://reviews.llvm.org/D3 Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/test/CodeGenObjC/arc-arm.m Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=311325&r1=311324&r2=311325&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Aug 21 02:54:46 2017 @@ -1085,7 +1085,7 @@ public: StringRef getARCRetainAutoreleasedReturnValueMarker() const override { return "movl\t%ebp, %ebp" - "\t\t## marker for objc_retainAutoreleaseReturnValue"; + "\t\t// marker for objc_retainAutoreleaseReturnValue"; } }; @@ -4880,7 +4880,7 @@ public: : TargetCodeGenInfo(new AArch64ABIInfo(CGT, Kind)) {} StringRef getARCRetainAutoreleasedReturnValueMarker() const override { -return "mov\tfp, fp\t\t# marker for objc_retainAutoreleaseReturnValue"; +return "mov\tfp, fp\t\t// marker for objc_retainAutoreleaseReturnValue"; } int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override { @@ -5486,7 +5486,7 @@ public: } StringRef getARCRetainAutoreleasedReturnValueMarker() const override { -return "mov\tr7, r7\t\t@ marker for objc_retainAutoreleaseReturnValue"; +return "mov\tr7, r7\t\t// marker for objc_retainAutoreleaseReturnValue"; } bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF, Modified: cfe/trunk/test/CodeGenObjC/arc-arm.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-arm.m?rev=311325&r1=311324&r2=311325&view=diff == --- cfe/trunk/test/CodeGenObjC/arc-arm.m (original) +++ cfe/trunk/test/CodeGenObjC/arc-arm.m Mon Aug 21 02:54:46 2017 @@ -13,7 +13,7 @@ id test0(void) { void test1(void) { extern id test1_helper(void); // CHECK: [[T0:%.*]] = call [[CC]]i8* @test1_helper() - // CHECK-NEXT: call void asm sideeffect "mov + // CHECK-NEXT: call void asm sideeffect "mov\09{{fp, fp|r7, r7}}\09\09// marker for objc_retainAutoreleaseReturnValue" // CHECK-NEXT: [[T1:%.*]] = call [[CC]]i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]]) // CHECK-NEXT: store i8* [[T1]], // CHECK-NEXT: call [[CC]]void @objc_storeStrong( ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36666: [ObjC] Use consistent comment style in inline asm
This revision was automatically updated to reflect the committed changes. Closed by commit rL311325: [ObjC] Use consistent comment style in inline asm (authored by olista01). Changed prior to commit: https://reviews.llvm.org/D3?vs=110927&id=111942#toc Repository: rL LLVM https://reviews.llvm.org/D3 Files: cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/test/CodeGenObjC/arc-arm.m Index: cfe/trunk/test/CodeGenObjC/arc-arm.m === --- cfe/trunk/test/CodeGenObjC/arc-arm.m +++ cfe/trunk/test/CodeGenObjC/arc-arm.m @@ -13,7 +13,7 @@ void test1(void) { extern id test1_helper(void); // CHECK: [[T0:%.*]] = call [[CC]]i8* @test1_helper() - // CHECK-NEXT: call void asm sideeffect "mov + // CHECK-NEXT: call void asm sideeffect "mov\09{{fp, fp|r7, r7}}\09\09// marker for objc_retainAutoreleaseReturnValue" // CHECK-NEXT: [[T1:%.*]] = call [[CC]]i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]]) // CHECK-NEXT: store i8* [[T1]], // CHECK-NEXT: call [[CC]]void @objc_storeStrong( Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp === --- cfe/trunk/lib/CodeGen/TargetInfo.cpp +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp @@ -1085,7 +1085,7 @@ StringRef getARCRetainAutoreleasedReturnValueMarker() const override { return "movl\t%ebp, %ebp" - "\t\t## marker for objc_retainAutoreleaseReturnValue"; + "\t\t// marker for objc_retainAutoreleaseReturnValue"; } }; @@ -4880,7 +4880,7 @@ : TargetCodeGenInfo(new AArch64ABIInfo(CGT, Kind)) {} StringRef getARCRetainAutoreleasedReturnValueMarker() const override { -return "mov\tfp, fp\t\t# marker for objc_retainAutoreleaseReturnValue"; +return "mov\tfp, fp\t\t// marker for objc_retainAutoreleaseReturnValue"; } int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override { @@ -5486,7 +5486,7 @@ } StringRef getARCRetainAutoreleasedReturnValueMarker() const override { -return "mov\tr7, r7\t\t@ marker for objc_retainAutoreleaseReturnValue"; +return "mov\tr7, r7\t\t// marker for objc_retainAutoreleaseReturnValue"; } bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF, Index: cfe/trunk/test/CodeGenObjC/arc-arm.m === --- cfe/trunk/test/CodeGenObjC/arc-arm.m +++ cfe/trunk/test/CodeGenObjC/arc-arm.m @@ -13,7 +13,7 @@ void test1(void) { extern id test1_helper(void); // CHECK: [[T0:%.*]] = call [[CC]]i8* @test1_helper() - // CHECK-NEXT: call void asm sideeffect "mov + // CHECK-NEXT: call void asm sideeffect "mov\09{{fp, fp|r7, r7}}\09\09// marker for objc_retainAutoreleaseReturnValue" // CHECK-NEXT: [[T1:%.*]] = call [[CC]]i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]]) // CHECK-NEXT: store i8* [[T1]], // CHECK-NEXT: call [[CC]]void @objc_storeStrong( Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp === --- cfe/trunk/lib/CodeGen/TargetInfo.cpp +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp @@ -1085,7 +1085,7 @@ StringRef getARCRetainAutoreleasedReturnValueMarker() const override { return "movl\t%ebp, %ebp" - "\t\t## marker for objc_retainAutoreleaseReturnValue"; + "\t\t// marker for objc_retainAutoreleaseReturnValue"; } }; @@ -4880,7 +4880,7 @@ : TargetCodeGenInfo(new AArch64ABIInfo(CGT, Kind)) {} StringRef getARCRetainAutoreleasedReturnValueMarker() const override { -return "mov\tfp, fp\t\t# marker for objc_retainAutoreleaseReturnValue"; +return "mov\tfp, fp\t\t// marker for objc_retainAutoreleaseReturnValue"; } int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override { @@ -5486,7 +5486,7 @@ } StringRef getARCRetainAutoreleasedReturnValueMarker() const override { -return "mov\tr7, r7\t\t@ marker for objc_retainAutoreleaseReturnValue"; +return "mov\tr7, r7\t\t// marker for objc_retainAutoreleaseReturnValue"; } bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36872: Fixed a crash on replaying Preamble's PP conditional stack.
bkramer accepted this revision. bkramer added a comment. This revision is now accepted and ready to land. This looks good to me. https://reviews.llvm.org/D36872 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36821: [libclang]: Honor LIBCLANG_NOTHREADS for clang_parseTranslationUnit*
bkramer accepted this revision. bkramer added a comment. This revision is now accepted and ready to land. lg https://reviews.llvm.org/D36821 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36853: [Parser] Correct initalizer typos before lambda capture type is deduced.
arphaman accepted this revision. arphaman added a comment. This revision is now accepted and ready to land. LGTM, Thanks. You should obtain commit access if you haven't already done so (https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access). I can commit this on your behalf as well if you want. https://reviews.llvm.org/D36853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30946: [ScopePrinting] Added support to print full scopes of types and declarations.
schroedersi added a comment. Ping :) https://reviews.llvm.org/D30946 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas
faisalv added a comment. In regards to representing this in the AST - I think (based on precedence) that the number of explicit template parameters should be stored in LambdaDefinitionData - and the interface exposed through LambdaExpr (where the source information of the template parameter list should be stored too i think - Richard you agree?). Also can you add examples of such generic lambdas that are nested within either other generic lambdas or templates - and make sure that they instantiate/substitute correctly - and that we really don't have to touch the template instantiation machinery? Thanks! Comment at: include/clang/Sema/ScopeInfo.h:955 + } + // When passed the index, returns the VarDecl and Expr associated This function doesn't seem to be called anywhere? Comment at: lib/Parse/ParseExprCXX.cpp:1116 + if (HasExplicitTemplateParams) { +SmallVector TemplateParams; +SourceLocation LAngleLoc, RAngleLoc; Why not Just use/pass LSI->TemplateParams? Comment at: lib/Sema/SemaLambda.cpp:501 + LAngleLoc, TParams, RAngleLoc, + /*RequiresClause=*/nullptr); + I'm not sure i see the point in creating the template parameter list here and returning it, when it's not used anywhere? The TPL is created and cached in GLTemplateParameterList when needed it seems. Comment at: lib/Sema/SemaLambda.cpp:858 +KnownDependent = CurScope->getTemplateParamParent() != nullptr; + } Hmm - now that you drew my attention to this ;) - I'm pretty sure this is broken - but (embarrassingly) it broke back when i implemented generic lambdas (and interestingly is less broken w generic lambdas w explicit TPLs) - could I ask you to add a FIXME here that states something along the lines of: When parsing default arguments that contain lambdas, it seems necessary to know whether the containing parameter-declaration clause is that of a template to mark the closure type created in the default-argument as dependent. Using template params to detect dependence is not enough for all generic lambdas since you can have generic lambdas without explicit template parameters, and whose default arguments contain lambdas that should be dependent - and you can not rely on the existence of a template parameter scope to detect those cases. Consider: auto L = [](int I = [] { return 5; }(), auto a) { }; The above nested closure type (of the default argument) occurs within a dependent context and is therefore dependent - but we won't know that until we parse the second parameter. p.s. I'll try and get around to fixing this if no one else does. https://reviews.llvm.org/D36527 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36951: [OpenCL][5.0.0 Release] Release notes for OpenCL in Clang
Anastasia created this revision. Added release notes describing committed functionality for OpenCL in release 5.0. https://reviews.llvm.org/D36951 Files: docs/ReleaseNotes.rst Index: docs/ReleaseNotes.rst === --- docs/ReleaseNotes.rst +++ docs/ReleaseNotes.rst @@ -122,7 +122,30 @@ OpenCL C Language Changes in Clang -- -... +Various bug fixes and improvements: +- Extended OpenCL-related Clang tests. +- Improved diagnostics across several areas: scoped address space + qualified variables, function pointers, atomics, type rank for overloading, + block captures, ``reserve_id_t``. +- Several address space related fixes for constant AS function scope variables, + IR generation, mangling of ``generic`` and alloca (post-fix from general Clang + refactoring of address spaces). +- Several improvements in extensions: fixed OpenCL version for ``cl_khr_mipmap_image``, + added missing ``cl_khr_3d_image_writes``. +- Improvements in ``enqueue_kernel``, especially the implementation of ``ndrange_t`` and blocks. +- OpenCL type related fixes: global samplers, the ``pipe_t`` size, internal type redefinition, + and type compatibility checking in ternary and other operations. +- The OpenCL header has been extended with missing extension guards, and direct mapping of ``as_type`` + to ``__builtin_astype``. +- Fixed ``kernel_arg_type_qual`` and OpenCL/SPIR version in metadata. +- Added proper use of the kernel calling convention to various targets. + +The following new functionalities have been added: +- Added documentation on OpenCL to Clang user manual. +- Extended Clang builtins with required ``cl_khr_subgroups`` support. +- Now interpreting empty argument function as void argument list in OpenCL code. +- Add ``intel_reqd_sub_group_size`` attribute support. +- Added OpenCL types to ``CIndex``. OpenMP Support in Clang -- Index: docs/ReleaseNotes.rst === --- docs/ReleaseNotes.rst +++ docs/ReleaseNotes.rst @@ -122,7 +122,30 @@ OpenCL C Language Changes in Clang -- -... +Various bug fixes and improvements: +- Extended OpenCL-related Clang tests. +- Improved diagnostics across several areas: scoped address space + qualified variables, function pointers, atomics, type rank for overloading, + block captures, ``reserve_id_t``. +- Several address space related fixes for constant AS function scope variables, + IR generation, mangling of ``generic`` and alloca (post-fix from general Clang + refactoring of address spaces). +- Several improvements in extensions: fixed OpenCL version for ``cl_khr_mipmap_image``, + added missing ``cl_khr_3d_image_writes``. +- Improvements in ``enqueue_kernel``, especially the implementation of ``ndrange_t`` and blocks. +- OpenCL type related fixes: global samplers, the ``pipe_t`` size, internal type redefinition, + and type compatibility checking in ternary and other operations. +- The OpenCL header has been extended with missing extension guards, and direct mapping of ``as_type`` + to ``__builtin_astype``. +- Fixed ``kernel_arg_type_qual`` and OpenCL/SPIR version in metadata. +- Added proper use of the kernel calling convention to various targets. + +The following new functionalities have been added: +- Added documentation on OpenCL to Clang user manual. +- Extended Clang builtins with required ``cl_khr_subgroups`` support. +- Now interpreting empty argument function as void argument list in OpenCL code. +- Add ``intel_reqd_sub_group_size`` attribute support. +- Added OpenCL types to ``CIndex``. OpenMP Support in Clang -- ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas
hamzasood marked 5 inline comments as done. hamzasood added a comment. So to clarify: NumExplicitTemplateParams should be stored in LambdaDefinitionData (with an accessor in LambdaExpr) and ExplicitTemplateParamRange (SourceRange) should be stored in LambdaExpr? That makes sense, but doesn't seem consistent with how things are currently stored. E.g. NumCaptures is stored in both LambdaDefinitionData and LambdaExpr. Comment at: lib/Parse/ParseExprCXX.cpp:1116 + if (HasExplicitTemplateParams) { +SmallVector TemplateParams; +SourceLocation LAngleLoc, RAngleLoc; faisalv wrote: > Why not Just use/pass LSI->TemplateParams? I thought that Parser and Sema stay separate, and communicate through various ActOn functions? Directly accessing LSI would violate that. https://reviews.llvm.org/D36527 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36951: [OpenCL][5.0.0 Release] Release notes for OpenCL in Clang
bader accepted this revision. bader added a comment. This revision is now accepted and ready to land. LGTM, except one nit. Comment at: docs/ReleaseNotes.rst:146 +- Extended Clang builtins with required ``cl_khr_subgroups`` support. +- Now interpreting empty argument function as void argument list in OpenCL code. +- Add ``intel_reqd_sub_group_size`` attribute support. As far as I remember, this change was reverted as it had caused some regressions. I haven't fix them yet, so I users still have to explicitly specify void for empty parameter list. https://reviews.llvm.org/D36951 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311330 - Fixed a crash on replaying Preamble's PP conditional stack.
Author: ibiryukov Date: Mon Aug 21 05:03:08 2017 New Revision: 311330 URL: http://llvm.org/viewvc/llvm-project?rev=311330&view=rev Log: Fixed a crash on replaying Preamble's PP conditional stack. Summary: The crash occurs when the first token after a preamble is a macro expansion. Fixed by moving replayPreambleConditionalStack from Parser into Preprocessor. It is now called right after the predefines file is processed. Reviewers: erikjv, bkramer, klimek, yvvan Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36872 Added: cfe/trunk/test/Index/preamble-conditionals-crash.cpp cfe/trunk/test/Index/preamble-conditionals.cpp Modified: cfe/trunk/include/clang/Lex/Preprocessor.h cfe/trunk/lib/Lex/PPLexerChange.cpp cfe/trunk/lib/Lex/Preprocessor.cpp cfe/trunk/lib/Parse/Parser.cpp Modified: cfe/trunk/include/clang/Lex/Preprocessor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=311330&r1=311329&r2=311330&view=diff == --- cfe/trunk/include/clang/Lex/Preprocessor.h (original) +++ cfe/trunk/include/clang/Lex/Preprocessor.h Mon Aug 21 05:03:08 2017 @@ -1049,10 +1049,6 @@ public: /// which implicitly adds the builtin defines etc. void EnterMainSourceFile(); - /// \brief After parser warm-up, initialize the conditional stack from - /// the preamble. - void replayPreambleConditionalStack(); - /// \brief Inform the preprocessor callbacks that processing is complete. void EndSourceFile(); @@ -2026,6 +2022,10 @@ public: } private: + /// \brief After processing predefined file, initialize the conditional stack from + /// the preamble. + void replayPreambleConditionalStack(); + // Macro handling. void HandleDefineDirective(Token &Tok, bool ImmediatelyAfterTopLevelIfndef); void HandleUndefDirective(); Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=311330&r1=311329&r2=311330&view=diff == --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original) +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Mon Aug 21 05:03:08 2017 @@ -458,10 +458,16 @@ bool Preprocessor::HandleEndOfFile(Token SourceMgr.setNumCreatedFIDsForFileID(CurPPLexer->getFileID(), NumFIDs); } +bool ExitedFromPredefinesFile = false; FileID ExitedFID; -if (Callbacks && !isEndOfMacro && CurPPLexer) +if (!isEndOfMacro && CurPPLexer) { ExitedFID = CurPPLexer->getFileID(); + assert(PredefinesFileID.isValid() && + "HandleEndOfFile is called before PredefinesFileId is set"); + ExitedFromPredefinesFile = (PredefinesFileID == ExitedFID); +} + if (LeavingSubmodule) { // We're done with this submodule. Module *M = LeaveSubmodule(/*ForPragma*/false); @@ -489,6 +495,11 @@ bool Preprocessor::HandleEndOfFile(Token PPCallbacks::ExitFile, FileType, ExitedFID); } +// Restore conditional stack from the preamble right after exiting from the +// predefines file. +if (ExitedFromPredefinesFile) + replayPreambleConditionalStack(); + // Client should lex another token unless we generated an EOM. return LeavingSubmodule; } Modified: cfe/trunk/lib/Lex/Preprocessor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=311330&r1=311329&r2=311330&view=diff == --- cfe/trunk/lib/Lex/Preprocessor.cpp (original) +++ cfe/trunk/lib/Lex/Preprocessor.cpp Mon Aug 21 05:03:08 2017 @@ -540,6 +540,8 @@ void Preprocessor::EnterMainSourceFile() void Preprocessor::replayPreambleConditionalStack() { // Restore the conditional stack from the preamble, if there is one. if (PreambleConditionalStack.isReplaying()) { +assert(CurPPLexer && + "CurPPLexer is null when calling replayPreambleConditionalStack."); CurPPLexer->setConditionalLevels(PreambleConditionalStack.getStack()); PreambleConditionalStack.doneReplaying(); } Modified: cfe/trunk/lib/Parse/Parser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=311330&r1=311329&r2=311330&view=diff == --- cfe/trunk/lib/Parse/Parser.cpp (original) +++ cfe/trunk/lib/Parse/Parser.cpp Mon Aug 21 05:03:08 2017 @@ -516,8 +516,6 @@ void Parser::Initialize() { // Prime the lexer look-ahead. ConsumeToken(); - - PP.replayPreambleConditionalStack(); } void Parser::LateTemplateParserCleanupCallback(void *P) { Added: cfe/trunk/test/Index/preamble-conditionals-crash.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/preamble-conditionals-crash.cpp?rev=311330&view=auto ===
[PATCH] D36872: Fixed a crash on replaying Preamble's PP conditional stack.
This revision was automatically updated to reflect the committed changes. Closed by commit rL311330: Fixed a crash on replaying Preamble's PP conditional stack. (authored by ibiryukov). Repository: rL LLVM https://reviews.llvm.org/D36872 Files: cfe/trunk/include/clang/Lex/Preprocessor.h cfe/trunk/lib/Lex/PPLexerChange.cpp cfe/trunk/lib/Lex/Preprocessor.cpp cfe/trunk/lib/Parse/Parser.cpp cfe/trunk/test/Index/preamble-conditionals-crash.cpp cfe/trunk/test/Index/preamble-conditionals.cpp Index: cfe/trunk/test/Index/preamble-conditionals-crash.cpp === --- cfe/trunk/test/Index/preamble-conditionals-crash.cpp +++ cfe/trunk/test/Index/preamble-conditionals-crash.cpp @@ -0,0 +1,12 @@ +#ifndef HEADER_GUARD + +#define FOO int aba; +FOO + +#endif +// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \ +// RUN: local -std=c++14 %s 2>&1 \ +// RUN: | FileCheck %s --implicit-check-not "libclang: crash detected" \ +// RUN:--implicit-check-not "error:" +// CHECK: macro expansion=FOO:3:9 Extent=[4:1 - 4:4] +// CHECK: VarDecl=aba:4:1 (Definition) Extent=[4:1 - 4:4] Index: cfe/trunk/test/Index/preamble-conditionals.cpp === --- cfe/trunk/test/Index/preamble-conditionals.cpp +++ cfe/trunk/test/Index/preamble-conditionals.cpp @@ -0,0 +1,8 @@ +// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source local %s 2>&1 \ +// RUN: | FileCheck %s --implicit-check-not "error:" +#ifndef FOO_H +#define FOO_H + +void foo(); + +#endif Index: cfe/trunk/lib/Parse/Parser.cpp === --- cfe/trunk/lib/Parse/Parser.cpp +++ cfe/trunk/lib/Parse/Parser.cpp @@ -516,8 +516,6 @@ // Prime the lexer look-ahead. ConsumeToken(); - - PP.replayPreambleConditionalStack(); } void Parser::LateTemplateParserCleanupCallback(void *P) { Index: cfe/trunk/lib/Lex/Preprocessor.cpp === --- cfe/trunk/lib/Lex/Preprocessor.cpp +++ cfe/trunk/lib/Lex/Preprocessor.cpp @@ -540,6 +540,8 @@ void Preprocessor::replayPreambleConditionalStack() { // Restore the conditional stack from the preamble, if there is one. if (PreambleConditionalStack.isReplaying()) { +assert(CurPPLexer && + "CurPPLexer is null when calling replayPreambleConditionalStack."); CurPPLexer->setConditionalLevels(PreambleConditionalStack.getStack()); PreambleConditionalStack.doneReplaying(); } Index: cfe/trunk/lib/Lex/PPLexerChange.cpp === --- cfe/trunk/lib/Lex/PPLexerChange.cpp +++ cfe/trunk/lib/Lex/PPLexerChange.cpp @@ -458,10 +458,16 @@ SourceMgr.setNumCreatedFIDsForFileID(CurPPLexer->getFileID(), NumFIDs); } +bool ExitedFromPredefinesFile = false; FileID ExitedFID; -if (Callbacks && !isEndOfMacro && CurPPLexer) +if (!isEndOfMacro && CurPPLexer) { ExitedFID = CurPPLexer->getFileID(); + assert(PredefinesFileID.isValid() && + "HandleEndOfFile is called before PredefinesFileId is set"); + ExitedFromPredefinesFile = (PredefinesFileID == ExitedFID); +} + if (LeavingSubmodule) { // We're done with this submodule. Module *M = LeaveSubmodule(/*ForPragma*/false); @@ -489,6 +495,11 @@ PPCallbacks::ExitFile, FileType, ExitedFID); } +// Restore conditional stack from the preamble right after exiting from the +// predefines file. +if (ExitedFromPredefinesFile) + replayPreambleConditionalStack(); + // Client should lex another token unless we generated an EOM. return LeavingSubmodule; } Index: cfe/trunk/include/clang/Lex/Preprocessor.h === --- cfe/trunk/include/clang/Lex/Preprocessor.h +++ cfe/trunk/include/clang/Lex/Preprocessor.h @@ -1049,10 +1049,6 @@ /// which implicitly adds the builtin defines etc. void EnterMainSourceFile(); - /// \brief After parser warm-up, initialize the conditional stack from - /// the preamble. - void replayPreambleConditionalStack(); - /// \brief Inform the preprocessor callbacks that processing is complete. void EndSourceFile(); @@ -2026,6 +2022,10 @@ } private: + /// \brief After processing predefined file, initialize the conditional stack from + /// the preamble. + void replayPreambleConditionalStack(); + // Macro handling. void HandleDefineDirective(Token &Tok, bool ImmediatelyAfterTopLevelIfndef); void HandleUndefDirective(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35271: Fix printing policy for AST context loaded from file
jklaehn added a comment. In https://reviews.llvm.org/D35271#809159, @vsk wrote: > I wonder if it's possible to do away with the calls to 'updated()'... it > seems strange that we initialize the same preprocessor repeatedly. Is there > any way to finalize an ASTInfoCollector after ReadAST happens (or > ASTReaderListeners in general)? I can look into this but would prefer to do so in a different patch, as this would require refactoring beyond this simple bug fix. Would it be okay to land this patch as-is? https://reviews.llvm.org/D35271 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36876: [IRGen] Evaluate constant static variables referenced through member expressions
arphaman added inline comments. Comment at: lib/CodeGen/CGExprComplex.cpp:156 +auto Constant = tryEmitDeclRefOrMemberExprAsConstant( +ME, ME->getMemberDecl(), /*AllowSideEffects=*/true); +if (Constant) { rsmith wrote: > If we can (correctly) allow side-effects in the initializer here, why can we > not also do so when emitting a `DeclRefExpr`? I think that DREs can't have side-effects in any case, so I think I can remove that argument. Repository: rL LLVM https://reviews.llvm.org/D36876 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36876: [IRGen] Evaluate constant static variables referenced through member expressions
arphaman updated this revision to Diff 111956. arphaman marked an inline comment as done. arphaman added a comment. - Get rid of the `AllowSideEffects` argument. - Get rid of the old integer field evaluation code. Repository: rL LLVM https://reviews.llvm.org/D36876 Files: lib/CodeGen/CGExpr.cpp lib/CodeGen/CGExprAgg.cpp lib/CodeGen/CGExprComplex.cpp lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/CodeGenFunction.h test/CodeGenCXX/member-expr-references-variable.cpp test/CodeGenCXX/temporaries.cpp Index: test/CodeGenCXX/temporaries.cpp === --- test/CodeGenCXX/temporaries.cpp +++ test/CodeGenCXX/temporaries.cpp @@ -673,18 +673,20 @@ vi4b w; }; // CHECK: alloca - // CHECK: extractelement - // CHECK: store i32 {{.*}}, i32* @_ZGRN6Vector1rE_ + // CHECK: store i32 0, i32* @_ZGRN6Vector1rE_ // CHECK: store i32* @_ZGRN6Vector1rE_, i32** @_ZN6Vector1rE, int &&r = S().v[1]; // CHECK: alloca - // CHECK: extractelement - // CHECK: store i32 {{.*}}, i32* @_ZGRN6Vector1sE_ + // CHECK: store i32 0, i32* @_ZGRN6Vector1sE_ // CHECK: store i32* @_ZGRN6Vector1sE_, i32** @_ZN6Vector1sE, int &&s = S().w[1]; - // FIXME PR16204: The following code leads to an assertion in Sema. - //int &&s = S().w.y; + + // CHECK: alloca + // CHECK: extractelement + // CHECK: store i32 {{.*}}, i32* @_ZGRN6Vector2s2E_ + // CHECK: store i32* @_ZGRN6Vector2s2E_, i32** @_ZN6Vector2s2E, + int &&s2 = S().w.y; } namespace ImplicitTemporaryCleanup { Index: test/CodeGenCXX/member-expr-references-variable.cpp === --- /dev/null +++ test/CodeGenCXX/member-expr-references-variable.cpp @@ -0,0 +1,82 @@ +// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s + +struct Struct { + constexpr static const char *name = "foo"; + + constexpr static __complex float complexValue = 42.0; + + Struct(); + Struct(int x); +}; + +void use(int n, const char *c); + +Struct *getPtr(); + +// CHECK: @[[STR:.*]] = private unnamed_addr constant [4 x i8] c"foo\00", align 1 + +void scalarStaticVariableInMemberExpr(Struct *ptr, Struct &ref) { + use(1, Struct::name); +// CHECK: call void @_Z3useiPKc(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0)) + Struct s; + use(2, s.name); +// CHECK: call void @_Z3useiPKc(i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0)) + use(3, ptr->name); +// CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8 +// CHECK: call void @_Z3useiPKc(i32 3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0)) + use(4, ref.name); +// CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8 +// CHECK: call void @_Z3useiPKc(i32 4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0)) + use(5, Struct(2).name); +// CHECK: call void @_ZN6StructC1Ei(%struct.Struct* %{{.*}}, i32 2) +// CHECK: call void @_Z3useiPKc(i32 5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0)) + use(6, getPtr()->name); +// CHECK: call %struct.Struct* @_Z6getPtrv() +// CHECK: call void @_Z3useiPKc(i32 6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0)) +} + +void use(int n, __complex float v); + +void complexStaticVariableInMemberExpr(Struct *ptr, Struct &ref) { + use(1, Struct::complexValue); +// CHECK: store float 4.20e+01, float* %[[coerce0:.*]].{{.*}}, align 4 +// CHECK: store float 0.00e+00, float* %[[coerce0]].{{.*}}, align 4 +// CHECK: %[[cast0:.*]] = bitcast { float, float }* %[[coerce0]] to <2 x float>* +// CHECK: %[[vector0:.*]] = load <2 x float>, <2 x float>* %[[cast0]], align 4 +// CHECK: call void @_Z3useiCf(i32 1, <2 x float> %[[vector0]]) + Struct s; + use(2, s.complexValue); +// CHECK: store float 4.20e+01, float* %[[coerce1:.*]].{{.*}}, align 4 +// CHECK: store float 0.00e+00, float* %[[coerce1]].{{.*}}, align 4 +// CHECK: %[[cast1:.*]] = bitcast { float, float }* %[[coerce1]] to <2 x float>* +// CHECK: %[[vector1:.*]] = load <2 x float>, <2 x float>* %[[cast1]], align 4 +// CHECK: call void @_Z3useiCf(i32 2, <2 x float> %[[vector1]]) + use(3, ptr->complexValue); +// CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8 +// CHECK: store float 4.20e+01, float* %[[coerce2:.*]].{{.*}}, align 4 +// CHECK: store float 0.00e+00, float* %[[coerce2]].{{.*}}, align 4 +// CHECK: %[[cast2:.*]] = bitcast { float, float }* %[[coerce2]] to <2 x float>* +// CHECK: %[[vector2:.*]] = load <2 x float>, <2 x float>* %[[cast2]], align 4 +// CHECK: call void @_Z3useiCf(i32 3, <2 x float> %[[vector2]]) + use(4, ref.complexValue); +// CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8 +// CHECK: store float 4.20e+01, float* %[[coerce3:.*]].{{.*}}, align 4 +// CHECK: store float 0.00e+00, float* %[[coerce3]].{{.*}}, ali
[PATCH] D36952: [libclang] Add support for checking abstractness of records
jklaehn created this revision. jklaehn added a project: clang. This patch allows checking whether a C++ record declaration is abstract through libclang and clang.cindex (Python). https://reviews.llvm.org/D36952 Files: bindings/python/clang/cindex.py bindings/python/tests/cindex/test_cursor.py include/clang-c/Index.h test/Index/load-classes.cpp tools/c-index-test/c-index-test.c tools/libclang/CIndex.cpp tools/libclang/libclang.exports Index: tools/libclang/libclang.exports === --- tools/libclang/libclang.exports +++ tools/libclang/libclang.exports @@ -12,6 +12,7 @@ clang_CXXMethod_isPureVirtual clang_CXXMethod_isStatic clang_CXXMethod_isVirtual +clang_CXXRecord_isAbstract clang_EnumDecl_isScoped clang_Cursor_getArgument clang_Cursor_getNumTemplateArguments Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -7846,6 +7846,17 @@ return (Method && Method->isVirtual()) ? 1 : 0; } +unsigned clang_CXXRecord_isAbstract(CXCursor C) { + if (!clang_isDeclaration(C.kind)) +return 0; + + const auto *D = cxcursor::getCursorDecl(C); + const auto *RD = dyn_cast_or_null(D); + if (RD) +RD = RD->getDefinition(); + return (RD && RD->isAbstract()) ? 1 : 0; +} + unsigned clang_EnumDecl_isScoped(CXCursor C) { if (!clang_isDeclaration(C.kind)) return 0; Index: tools/c-index-test/c-index-test.c === --- tools/c-index-test/c-index-test.c +++ tools/c-index-test/c-index-test.c @@ -804,6 +804,8 @@ printf(" (const)"); if (clang_CXXMethod_isPureVirtual(Cursor)) printf(" (pure)"); +if (clang_CXXRecord_isAbstract(Cursor)) + printf(" (abstract)"); if (clang_EnumDecl_isScoped(Cursor)) printf(" (scoped)"); if (clang_Cursor_isVariadic(Cursor)) Index: test/Index/load-classes.cpp === --- test/Index/load-classes.cpp +++ test/Index/load-classes.cpp @@ -29,7 +29,7 @@ } // RUN: c-index-test -test-load-source all %s | FileCheck %s -// CHECK: load-classes.cpp:3:8: StructDecl=X:3:8 (Definition) Extent=[3:1 - 26:2] +// CHECK: load-classes.cpp:3:8: StructDecl=X:3:8 (Definition) (abstract) Extent=[3:1 - 26:2] // CHECK: load-classes.cpp:4:3: CXXConstructor=X:4:3 (converting constructor) Extent=[4:3 - 4:15] [access=public] // FIXME: missing TypeRef in the constructor name // CHECK: load-classes.cpp:4:9: ParmDecl=value:4:9 (Definition) Extent=[4:5 - 4:14] Index: include/clang-c/Index.h === --- include/clang-c/Index.h +++ include/clang-c/Index.h @@ -4418,6 +4418,12 @@ */ CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C); +/** + * \brief Determine if a C++ record is abstract, i.e. whether a class or struct + * has a pure virtual member function. + */ +CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C); + /** * \brief Determine if an enum declaration refers to a scoped enum. */ Index: bindings/python/tests/cindex/test_cursor.py === --- bindings/python/tests/cindex/test_cursor.py +++ bindings/python/tests/cindex/test_cursor.py @@ -255,6 +255,17 @@ assert foo.is_virtual_method() assert not bar.is_virtual_method() +def test_is_abstract_record(): +"""Ensure Cursor.is_abstract_record works.""" +source = 'struct X { virtual void x() = 0; }; struct Y : X { void x(); };' +tu = get_tu(source, lang='cpp') + +cls = get_cursor(tu, 'X') +assert cls.is_abstract_record() + +cls = get_cursor(tu, 'Y') +assert not cls.is_abstract_record() + def test_is_scoped_enum(): """Ensure Cursor.is_scoped_enum works.""" source = 'class X {}; enum RegularEnum {}; enum class ScopedEnum {};' Index: bindings/python/clang/cindex.py === --- bindings/python/clang/cindex.py +++ bindings/python/clang/cindex.py @@ -1478,6 +1478,12 @@ """ return conf.lib.clang_CXXMethod_isVirtual(self) +def is_abstract_record(self): +"""Returns True if the cursor refers to a C++ record declaration +that has pure virtual member functions. +""" +return conf.lib.clang_CXXRecord_isAbstract(self) + def is_scoped_enum(self): """Returns True if the cursor refers to a scoped enum declaration. """ @@ -3319,6 +3325,10 @@ [Cursor], bool), + ("clang_CXXRecord_isAbstract", + [Cursor], + bool), + ("clang_EnumDecl_isScoped", [Cursor], bool), ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36953: [libclang] Keep track of TranslationUnit instance when annotating tokens
jklaehn created this revision. jklaehn added a project: clang. Previously the `_tu` was not propagated to the returned cursor, leading to errors when calling any method on that cursor (e.g. `cursor.referenced`). https://reviews.llvm.org/D36953 Files: bindings/python/clang/cindex.py bindings/python/tests/cindex/test_cursor.py Index: bindings/python/tests/cindex/test_cursor.py === --- bindings/python/tests/cindex/test_cursor.py +++ bindings/python/tests/cindex/test_cursor.py @@ -395,6 +395,28 @@ assert tokens[0].spelling == 'int' assert tokens[1].spelling == 'foo' +def test_get_token_cursor(): +"""Ensure we can map tokens to cursors.""" +tu = get_tu('class A {}; int foo(A var = A());', lang='cpp') +foo = get_cursor(tu, 'foo') + +for cursor in foo.walk_preorder(): +if cursor.kind.is_expression() and not cursor.kind.is_statement(): +break +else: +assert False, "Could not find default value expression" + +tokens = list(cursor.get_tokens()) +assert len(tokens) == 4, [t.spelling for t in tokens] +assert tokens[0].spelling == '=' +assert tokens[1].spelling == 'A' +assert tokens[2].spelling == '(' +assert tokens[3].spelling == ')' +t_cursor = tokens[1].cursor +assert t_cursor.kind == CursorKind.TYPE_REF +r_cursor = t_cursor.referenced # should not raise an exception +assert r_cursor.kind == CursorKind.CLASS_DECL + def test_get_arguments(): tu = get_tu('void foo(int i, int j);') foo = get_cursor(tu, 'foo') Index: bindings/python/clang/cindex.py === --- bindings/python/clang/cindex.py +++ bindings/python/clang/cindex.py @@ -3193,6 +3193,7 @@ def cursor(self): """The Cursor this Token corresponds to.""" cursor = Cursor() +cursor._tu = self._tu conf.lib.clang_annotateTokens(self._tu, byref(self), 1, byref(cursor)) Index: bindings/python/tests/cindex/test_cursor.py === --- bindings/python/tests/cindex/test_cursor.py +++ bindings/python/tests/cindex/test_cursor.py @@ -395,6 +395,28 @@ assert tokens[0].spelling == 'int' assert tokens[1].spelling == 'foo' +def test_get_token_cursor(): +"""Ensure we can map tokens to cursors.""" +tu = get_tu('class A {}; int foo(A var = A());', lang='cpp') +foo = get_cursor(tu, 'foo') + +for cursor in foo.walk_preorder(): +if cursor.kind.is_expression() and not cursor.kind.is_statement(): +break +else: +assert False, "Could not find default value expression" + +tokens = list(cursor.get_tokens()) +assert len(tokens) == 4, [t.spelling for t in tokens] +assert tokens[0].spelling == '=' +assert tokens[1].spelling == 'A' +assert tokens[2].spelling == '(' +assert tokens[3].spelling == ')' +t_cursor = tokens[1].cursor +assert t_cursor.kind == CursorKind.TYPE_REF +r_cursor = t_cursor.referenced # should not raise an exception +assert r_cursor.kind == CursorKind.CLASS_DECL + def test_get_arguments(): tu = get_tu('void foo(int i, int j);') foo = get_cursor(tu, 'foo') Index: bindings/python/clang/cindex.py === --- bindings/python/clang/cindex.py +++ bindings/python/clang/cindex.py @@ -3193,6 +3193,7 @@ def cursor(self): """The Cursor this Token corresponds to.""" cursor = Cursor() +cursor._tu = self._tu conf.lib.clang_annotateTokens(self._tu, byref(self), 1, byref(cursor)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas
faisalv added inline comments. Comment at: lib/Parse/ParseExprCXX.cpp:1116 + if (HasExplicitTemplateParams) { +SmallVector TemplateParams; +SourceLocation LAngleLoc, RAngleLoc; hamzasood wrote: > faisalv wrote: > > Why not Just use/pass LSI->TemplateParams? > I thought that Parser and Sema stay separate, and communicate through various > ActOn functions? Directly accessing LSI would violate that. Aah yes - you're right. Still it does seem a little wasteful to create two of those (and then append). What are your thoughts about passing the argument by (moved from) value, and then swapping their guts within ActOn (i..e value-semantics) ? (I suppose the only concern would be the small array case - but i think that would be quite easy for any optimizer to inline). https://reviews.llvm.org/D36527 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36951: [OpenCL][5.0.0 Release] Release notes for OpenCL in Clang
yaxunl accepted this revision. yaxunl added a comment. LGTM. Thanks. https://reviews.llvm.org/D36951 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Clang-format bug patch
To Whom It May Concern, I am writing in reference to a patch I created in response to the bug I have decided to work on. Bug comes from the official site: https://bugs.llvm.org/show_bug.cgi?id=34001 Short overview: Clang-format bug resulting in a strange behavior of control statements short blocks. Different flags combinations do not guarantee expected result. Turned on option AllowShortBlocksOnASingleLine does not work as intended. Description of the problem: Cpp source file UnwrappedLineFormatter does not handle AllowShortBlocksOnASingleLine flag as it should. Putting a single-line control statement without any braces, clang-format works as expected (depending on AllowShortIfStatementOnASingleLine or AllowShortLoopsOnASingleLine value). Putting a single-line control statement in braces, we can observe strange and incorrect behavior. Our short block is intercepted by tryFitMultipleLinesInOne function. The function returns a number of lines to be merged. Unfortunately, our control statement block is not covered properly. There are several if-return statements, but none of them handles our block. A block is identified by the line first token and by left and right braces. A function block works as expected, there is such an if-return statement doing proper job. A control statement block, from the other hand, falls into strange conditional construct, which depends on BraceWrapping.AfterFunction flag (with condition that the line's last token is left brace, what is possible in our case) or goes even further. That should definitely not happen. Description of the patch: By adding three different if statements, we guarantee that our short control statement block, however it looks like (different brace wrapping flags may be turned on), is handled properly and does not fall into wrong conditional construct. Depending on appropriate options we return either 0 (when something disturbs our merging attempt) or let another function (tryMergeSimpleBlock) take the responsibility of returned result (number of merged lines). Nevertheless, one more correction is required in mentioned tryMergeSimpleBlock function. The function, previously, returned either 0 or 2. The problem was that this did not handle the case when our block had the left brace in a separate line, not the header one. After change, after adding condition, we return the result compatible with block's structure. In case of left brace in the header's line we do everything as before the patch. In case of left brace in a separate line we do the job similar to the one we do in case of a "non-header left brace" function short block. To be precise, we try to merge the block ignoring the header line. Then, if success, we increment our returned result. Please find the attached diff files. There are two. One created by simple svn diff command and one with postscript "NoWhitespaces" which ignores every whitespace while creating patch file. Has been done for more readable format. I would be very grateful if that could go under review. Thank you. Best regards, Pawel Maciocha UnwrappedLineFormatter.patch Description: UnwrappedLineFormatter.patch UnwrappedLineFormatterNoWhitespaces.patch Description: UnwrappedLineFormatterNoWhitespaces.patch ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36954: [Sema] Update release notes with details of implicit scalar to vector conversions
sdardis created this revision. Add notes on this to the C language section, along with the C++ section. https://reviews.llvm.org/D36954 Files: docs/ReleaseNotes.rst Index: docs/ReleaseNotes.rst === --- docs/ReleaseNotes.rst +++ docs/ReleaseNotes.rst @@ -95,7 +95,41 @@ C Language Changes in Clang --- -- ... +- Added near complete support for implicit scalar to vector conversion, a GNU + C/C++ language extension. With this extension, the following code is + considered valid: + +.. code-block:: c + +typedef unsigned v4i32 __attribute__((vector_size(16))); + +v4i32 foo(v4i32 a) { + // Here 5 is implicitly casted to an unsigned value and replicated into a + // vector with as many elements as 'a'. + return a + 5; +} + +The implicit conversion of a scalar value to a vector value--in the context of +a vector expression--occurs when: + +- The type of the vector is that of a ``__attribute__((vector_size(size)))`` + vector, not an OpenCL ``__attribute__((ext_vector_type(size)))`` vector type. + +- The scalar value can be casted to that of the vector element's type without + the loss of precision based on the type of the scalar and the type of the + vector's elements. + +- For compile time constant values, the above rule is weakened to consider the + value of the scalar constant rather than the constant's type. + +- Floating point constants with precise integral representations are not + implicitly converted to integer values, this is for compatability with GCC. + + +Currently the basic integer and floating point types with the following +operators are supported: ``+``, ``/``, ``-``, ``*``, ``%``, ``>``, ``<``, +``>=``, ``<=``, ``==``, ``!=``, ``&``, ``|``, ``^`` and the corresponding +assignment operators where applicable. ... @@ -107,6 +141,10 @@ C++ Language Changes in Clang - +- As mentioned in `C Language Changes in Clang`_, Clang's support for + implicit scalar to vector conversions also applies to C++. Additionally + the following operators are also supported: ``&&`` and ``||``. + ... C++1z Feature Support Index: docs/ReleaseNotes.rst === --- docs/ReleaseNotes.rst +++ docs/ReleaseNotes.rst @@ -95,7 +95,41 @@ C Language Changes in Clang --- -- ... +- Added near complete support for implicit scalar to vector conversion, a GNU + C/C++ language extension. With this extension, the following code is + considered valid: + +.. code-block:: c + +typedef unsigned v4i32 __attribute__((vector_size(16))); + +v4i32 foo(v4i32 a) { + // Here 5 is implicitly casted to an unsigned value and replicated into a + // vector with as many elements as 'a'. + return a + 5; +} + +The implicit conversion of a scalar value to a vector value--in the context of +a vector expression--occurs when: + +- The type of the vector is that of a ``__attribute__((vector_size(size)))`` + vector, not an OpenCL ``__attribute__((ext_vector_type(size)))`` vector type. + +- The scalar value can be casted to that of the vector element's type without + the loss of precision based on the type of the scalar and the type of the + vector's elements. + +- For compile time constant values, the above rule is weakened to consider the + value of the scalar constant rather than the constant's type. + +- Floating point constants with precise integral representations are not + implicitly converted to integer values, this is for compatability with GCC. + + +Currently the basic integer and floating point types with the following +operators are supported: ``+``, ``/``, ``-``, ``*``, ``%``, ``>``, ``<``, +``>=``, ``<=``, ``==``, ``!=``, ``&``, ``|``, ``^`` and the corresponding +assignment operators where applicable. ... @@ -107,6 +141,10 @@ C++ Language Changes in Clang - +- As mentioned in `C Language Changes in Clang`_, Clang's support for + implicit scalar to vector conversions also applies to C++. Additionally + the following operators are also supported: ``&&`` and ``||``. + ... C++1z Feature Support ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36955: [libclang] Visit attributes for function and class templates
jklaehn created this revision. jklaehn added a project: clang. Previously, `VisitAttributes` was not called for function and class templates and thus their attributes were not accessible using libclang. https://reviews.llvm.org/D36955 Files: bindings/python/tests/cindex/test_cursor.py tools/libclang/CIndex.cpp Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -907,16 +907,18 @@ if (VisitTemplateParameters(D->getTemplateParameters())) return true; - return VisitFunctionDecl(D->getTemplatedDecl()); + auto* FD = D->getTemplatedDecl(); + return VisitAttributes(FD) || VisitFunctionDecl(FD); } bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) { // FIXME: Visit the "outer" template parameter lists on the TagDecl // before visiting these template parameters. if (VisitTemplateParameters(D->getTemplateParameters())) return true; - return VisitCXXRecordDecl(D->getTemplatedDecl()); + auto* CD = D->getTemplatedDecl(); + return VisitAttributes(CD) || VisitCXXRecordDecl(CD); } bool CursorVisitor::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { Index: bindings/python/tests/cindex/test_cursor.py === --- bindings/python/tests/cindex/test_cursor.py +++ bindings/python/tests/cindex/test_cursor.py @@ -377,6 +377,26 @@ else: assert False, "Couldn't find annotation" +def test_annotation_template(): +annotation = '__attribute__ ((annotate("annotation")))' +for source, kind in [ +('int foo (T value) %s;', CursorKind.FUNCTION_TEMPLATE), +('class %s foo {};', CursorKind.CLASS_TEMPLATE), +]: +source = 'template ' + (source % annotation) +tu = get_tu(source, lang="cpp") + +foo = get_cursor(tu, 'foo') +assert foo is not None +assert foo.kind == kind + +for c in foo.get_children(): +if c.kind == CursorKind.ANNOTATE_ATTR: +assert c.displayname == "annotation" +break +else: +assert False, "Couldn't find annotation for {}".format(kind) + def test_result_type(): tu = get_tu('int foo();') foo = get_cursor(tu, 'foo') Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -907,16 +907,18 @@ if (VisitTemplateParameters(D->getTemplateParameters())) return true; - return VisitFunctionDecl(D->getTemplatedDecl()); + auto* FD = D->getTemplatedDecl(); + return VisitAttributes(FD) || VisitFunctionDecl(FD); } bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) { // FIXME: Visit the "outer" template parameter lists on the TagDecl // before visiting these template parameters. if (VisitTemplateParameters(D->getTemplateParameters())) return true; - return VisitCXXRecordDecl(D->getTemplatedDecl()); + auto* CD = D->getTemplatedDecl(); + return VisitAttributes(CD) || VisitCXXRecordDecl(CD); } bool CursorVisitor::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { Index: bindings/python/tests/cindex/test_cursor.py === --- bindings/python/tests/cindex/test_cursor.py +++ bindings/python/tests/cindex/test_cursor.py @@ -377,6 +377,26 @@ else: assert False, "Couldn't find annotation" +def test_annotation_template(): +annotation = '__attribute__ ((annotate("annotation")))' +for source, kind in [ +('int foo (T value) %s;', CursorKind.FUNCTION_TEMPLATE), +('class %s foo {};', CursorKind.CLASS_TEMPLATE), +]: +source = 'template ' + (source % annotation) +tu = get_tu(source, lang="cpp") + +foo = get_cursor(tu, 'foo') +assert foo is not None +assert foo.kind == kind + +for c in foo.get_children(): +if c.kind == CursorKind.ANNOTATE_ATTR: +assert c.displayname == "annotation" +break +else: +assert False, "Couldn't find annotation for {}".format(kind) + def test_result_type(): tu = get_tu('int foo();') foo = get_cursor(tu, 'foo') ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36956: [clang-format] Emit absolute splits before lines for comments
krasimir created this revision. Herald added a subscriber: klimek. This patch makes the splits emitted for the beginning of comment lines during reformatting absolute. Previously, they were relative to the start of the non-whitespace content of the line, which messes up further TailOffset calculations in breakProtrudingToken. This fixes an assertion failure reported in bug 34236: https://bugs.llvm.org/show_bug.cgi?id=34236. https://reviews.llvm.org/D36956 Files: lib/Format/BreakableToken.cpp unittests/Format/FormatTestComments.cpp Index: unittests/Format/FormatTestComments.cpp === --- unittests/Format/FormatTestComments.cpp +++ unittests/Format/FormatTestComments.cpp @@ -2780,6 +2780,23 @@ "* long */", getLLVMStyleWithColumns(20))); } + +TEST_F(FormatTestComments, NoCrush_Bug34236) { + // This is a test case from a crusher reported in bug 34236: + // https://bugs.llvm.org/show_bug.cgi?id=34236 + EXPECT_EQ( + R"( +/**/ /* + * a + * b c + * d*/)", + format( + R"( +/**/ /* + * a b + * c d*/)", + getLLVMStyleWithColumns(80))); +} } // end namespace } // end namespace format } // end namespace clang Index: lib/Format/BreakableToken.cpp === --- lib/Format/BreakableToken.cpp +++ lib/Format/BreakableToken.cpp @@ -545,15 +545,18 @@ } BreakableToken::Split BreakableBlockComment::getSplitBefore( -unsigned LineIndex, -unsigned PreviousEndColumn, -unsigned ColumnLimit, +unsigned LineIndex, unsigned PreviousEndColumn, unsigned ColumnLimit, llvm::Regex &CommentPragmasRegex) const { if (!mayReflow(LineIndex, CommentPragmasRegex)) return Split(StringRef::npos, 0); StringRef TrimmedContent = Content[LineIndex].ltrim(Blanks); - return getReflowSplit(TrimmedContent, ReflowPrefix, PreviousEndColumn, -ColumnLimit); + Split TrimmedSplit = getReflowSplit(TrimmedContent, ReflowPrefix, + PreviousEndColumn, ColumnLimit); + if (TrimmedSplit.first == StringRef::npos) +return TrimmedSplit; + return Split(TrimmedSplit.first + Content[LineIndex].size() - + TrimmedContent.size(), + TrimmedSplit.second); } unsigned BreakableBlockComment::getReflownColumn( @@ -633,17 +636,12 @@ /*CurrentPrefix=*/ReflowPrefix, InPPDirective, /*Newlines=*/0, /*Spaces=*/0); // Check if we need to also insert a break at the whitespace range. -// For this we first adapt the reflow split relative to the beginning of the -// content. // Note that we don't need a penalty for this break, since it doesn't change // the total number of lines. -Split BreakSplit = SplitBefore; -BreakSplit.first += TrimmedContent.data() - Content[LineIndex].data(); unsigned ReflownColumn = getReflownColumn(TrimmedContent, LineIndex, PreviousEndColumn); -if (ReflownColumn > ColumnLimit) { - insertBreak(LineIndex, 0, BreakSplit, Whitespaces); -} +if (ReflownColumn > ColumnLimit) + insertBreak(LineIndex, 0, SplitBefore, Whitespaces); return; } Index: unittests/Format/FormatTestComments.cpp === --- unittests/Format/FormatTestComments.cpp +++ unittests/Format/FormatTestComments.cpp @@ -2780,6 +2780,23 @@ "* long */", getLLVMStyleWithColumns(20))); } + +TEST_F(FormatTestComments, NoCrush_Bug34236) { + // This is a test case from a crusher reported in bug 34236: + // https://bugs.llvm.org/show_bug.cgi?id=34236 + EXPECT_EQ( + R"( +/**/ /* + * a + * b c + * d*/)", + format( + R"( +/**/ /* + * a b + * c d*/)", + getLLVMStyleWithColumns(80))); +} } // end namespace } // end namespace format } // end namespace clang Index: lib/Format/BreakableToken.cpp === --- lib/Format/BreakableToken.cpp +++ lib/Format/BreakableToken.cpp @@ -545,15 +545,18 @@ } BreakableToken::Split BreakableBlockComment::getSplitBefore( -unsigned LineIndex, -unsigned Previou
[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas
hamzasood added inline comments. Comment at: lib/Parse/ParseExprCXX.cpp:1116 + if (HasExplicitTemplateParams) { +SmallVector TemplateParams; +SourceLocation LAngleLoc, RAngleLoc; faisalv wrote: > hamzasood wrote: > > faisalv wrote: > > > Why not Just use/pass LSI->TemplateParams? > > I thought that Parser and Sema stay separate, and communicate through > > various ActOn functions? Directly accessing LSI would violate that. > Aah yes - you're right. Still it does seem a little wasteful to create two > of those (and then append). What are your thoughts about passing the > argument by (moved from) value, and then swapping their guts within ActOn > (i..e value-semantics) ? (I suppose the only concern would be the small > array case - but i think that would be quite easy for any optimizer to > inline). > I don't think a SmallVectorImpl can be passed by value. So to make that work, the function would either needed to be templated (SmallVector) or only accept a SmallVector. And I don't think either of those options are worthwhile. Comment at: lib/Sema/SemaLambda.cpp:858 +KnownDependent = CurScope->getTemplateParamParent() != nullptr; + } faisalv wrote: > Hmm - now that you drew my attention to this ;) - I'm pretty sure this is > broken - but (embarrassingly) it broke back when i implemented generic > lambdas (and interestingly is less broken w generic lambdas w explicit TPLs) > - could I ask you to add a FIXME here that states something along the lines > of: > > When parsing default arguments that contain lambdas, it seems necessary to > know whether the containing parameter-declaration clause is that of a > template to mark the closure type created in the default-argument as > dependent. Using template params to detect dependence is not enough for all > generic lambdas since you can have generic lambdas without explicit template > parameters, and whose default arguments contain lambdas that should be > dependent - and you can not rely on the existence of a template parameter > scope to detect those cases. Consider: >auto L = [](int I = [] { return 5; }(), auto a) { }; > The above nested closure type (of the default argument) occurs within a > dependent context and is therefore dependent - but we won't know that until > we parse the second parameter. > > p.s. I'll try and get around to fixing this if no one else does. > Good point. Now you mention it, isn't it even more broken than than? E.g: ``` auto L = [](auto A, int I = [] { return 5; }()); ``` L is known to be generic before we parse the nested lambda, but template param scopes aren't established for auto parameters (I think), so the nested lambda won't get marked as dependent https://reviews.llvm.org/D36527 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34275: [analyzer] Re-implemente current virtual calls checker in a path-sensitive way
NoQ added a comment. Tests are still not working - they pass now, but they don't actually test anything. Please make sure that tests actually work. Which means that 1. Tests pass when you run `make -j4 check-clang-analysis`; 2. Tests start failing when you change your code or expected-warning directives. Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:110 + auto ThiSVal = + State->getSVal(SVB.getCXXThis(MD, LCtx->getCurrentStackFrame())); + const MemRegion *Reg = ThiSVal.getAsRegion(); wangxindsb wrote: > NoQ wrote: > > I don't think this is working. CXXThisRegion is never a region of a C++ > > object; it's the segment of the stack where the pointer is passed, you need > > to dereference its value to get the actual object region. > > > > Probably tests for the visitor might make things more clear. > ``` > class Y { > public: > virtual void foobar(); > void fooY() { > F f1; > foobar(); > } > Y() { > fooY(); > } > }; > > ``` > I thought this test is for this situation. If the visitor is correct, it will > issued "Called from this constructor 'Y'", else it will issued "Called from > this constructor 'F'". > Right, i didn't notice `getSVal()`; seems correct. This test doesn't verify anything though, because it has no expected-warnings. Even if it had, it wouldn't verify where the visitor diagnostic appears, because without a more specific `-analyzer-output` option (eg. `=text`), the analyzer wouldn't emit visitor notes, so the `-verify` option would not be able to verify them. So by visitor tests i mean adding `-analyzer-output=text` to the run-line and then adding `expected-note` directives wherever notes are expected. Comment at: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp:124-127 + if (CD) +InfoText = "Called from this constrctor '" + CD->getNameAsString() + "'"; + else +InfoText = "Called from this destrctor '" + DD->getNameAsString() + "'"; Typo: "constr//**u**//ctor", "destr//**u**//ctor". Also i guess we need to think about this warning message more carefully anyway. Like, we already have an "entering function..." event diagnostic piece. Because the warning always happens inside the function in question, this event would never be pruned, so it'd always be there. So what do we expect the visitor's diagnostic piece to say? I suggest "This [constructor|destructor] of an object of type 'Foo' has not returned when the virtual method was called". With a probable future improvement of specifying the name of the object (when eg. it's a variable). It might even be that later we'd decide that the visitor is not necessary for this checker. I'm not sure, i guess i'd have to see how it works in practice. Also, right now the visitor's piece is above the "entering function..." event. Not sure if having it below, or even inside the constructor, would be better. Comment at: test/Analysis/virtualcall.cpp:1-6 +// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall +// -analyzer-store region -verify -std=c++11 %s + +// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall +// -analyzer-store region -analyzer-config +// optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s Tests are still not working because your auto-format tool has inserted weird line breaks. https://reviews.llvm.org/D34275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36872: Fixed a crash on replaying Preamble's PP conditional stack.
nik added a reviewer: hans. nik added a comment. I see this in trunk/master submitted, but not in the release_50 branch. Could this be cherry-picked to 5.0? Repository: rL LLVM https://reviews.llvm.org/D36872 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36821: [libclang]: Honor LIBCLANG_NOTHREADS for clang_parseTranslationUnit*
nik added a reviewer: erikjv. nik added a comment. Please submit as I do not have the necessary permissions. https://reviews.llvm.org/D36821 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34275: [analyzer] Re-implemente current virtual calls checker in a path-sensitive way
NoQ added a comment. Most importantly, do you think we can enable the checker by default now? Was this checker evaluated on any large codebase, and if so, how many true/false positives did it find, probably compared to the old checker? https://reviews.llvm.org/D34275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311334 - [mips] Remove checking of the redundant condition. NFC
Author: atanasyan Date: Mon Aug 21 07:08:29 2017 New Revision: 311334 URL: http://llvm.org/viewvc/llvm-project?rev=311334&view=rev Log: [mips] Remove checking of the redundant condition. NFC Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=311334&r1=311333&r2=311334&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Mon Aug 21 07:08:29 2017 @@ -232,8 +232,7 @@ void mips::getMIPSTargetFeatures(const D Arg *ABICallsArg = Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls); UseAbiCalls = - !ABICallsArg || - (ABICallsArg && ABICallsArg->getOption().matches(options::OPT_mabicalls)); + !ABICallsArg || ABICallsArg->getOption().matches(options::OPT_mabicalls); if (UseAbiCalls && IsN64 && NonPIC) { D.Diag(diag::warn_drv_unsupported_abicalls); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas
faisalv added inline comments. Comment at: lib/Sema/SemaLambda.cpp:858 +KnownDependent = CurScope->getTemplateParamParent() != nullptr; + } hamzasood wrote: > faisalv wrote: > > Hmm - now that you drew my attention to this ;) - I'm pretty sure this is > > broken - but (embarrassingly) it broke back when i implemented generic > > lambdas (and interestingly is less broken w generic lambdas w explicit > > TPLs) - could I ask you to add a FIXME here that states something along the > > lines of: > > > > When parsing default arguments that contain lambdas, it seems necessary to > > know whether the containing parameter-declaration clause is that of a > > template to mark the closure type created in the default-argument as > > dependent. Using template params to detect dependence is not enough for > > all generic lambdas since you can have generic lambdas without explicit > > template parameters, and whose default arguments contain lambdas that > > should be dependent - and you can not rely on the existence of a template > > parameter scope to detect those cases. Consider: > >auto L = [](int I = [] { return 5; }(), auto a) { }; > > The above nested closure type (of the default argument) occurs within a > > dependent context and is therefore dependent - but we won't know that until > > we parse the second parameter. > > > > p.s. I'll try and get around to fixing this if no one else does. > > > Good point. Now you mention it, isn't it even more broken than than? > E.g: > > ``` > auto L = [](auto A, int I = [] { return 5; }()); > ``` > > L is known to be generic before we parse the nested lambda, but template > param scopes aren't established for auto parameters (I think), so the nested > lambda won't get marked as dependent I was aware of that - but I think that's the easier case to fix (where you see the auto first - hence i reversed it in my example). https://reviews.llvm.org/D36527 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas
faisalv added inline comments. Comment at: lib/Parse/ParseExprCXX.cpp:1116 + if (HasExplicitTemplateParams) { +SmallVector TemplateParams; +SourceLocation LAngleLoc, RAngleLoc; hamzasood wrote: > faisalv wrote: > > hamzasood wrote: > > > faisalv wrote: > > > > Why not Just use/pass LSI->TemplateParams? > > > I thought that Parser and Sema stay separate, and communicate through > > > various ActOn functions? Directly accessing LSI would violate that. > > Aah yes - you're right. Still it does seem a little wasteful to create two > > of those (and then append). What are your thoughts about passing the > > argument by (moved from) value, and then swapping their guts within ActOn > > (i..e value-semantics) ? (I suppose the only concern would be the small > > array case - but i think that would be quite easy for any optimizer to > > inline). > > > I don't think a SmallVectorImpl can be passed by value. > > So to make that work, the function would either needed to be templated > (SmallVector) or only accept a SmallVector. And I don't > think either of those options are worthwhile. OK - add a FIXME that alerts folks that we currently make two copies of this and ideally we shouldn't need to. https://reviews.llvm.org/D36527 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36949: [clang] Fix tests for Emitting Single Inline Remark
anemet accepted this revision. anemet added a comment. This revision is now accepted and ready to land. LGTM. https://reviews.llvm.org/D36949 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36969: [Basic] Add a DiagnosticOr type
arphaman created this revision. Clang's `DiagnosticOr` type mimics the `Expected` type from LLVM. It either stores a partial diagnostic and its location or a value. I'll be using in https://reviews.llvm.org/D36075. Repository: rL LLVM https://reviews.llvm.org/D36969 Files: include/clang/Basic/DiagnosticOr.h unittests/Basic/DiagnosticTest.cpp Index: unittests/Basic/DiagnosticTest.cpp === --- unittests/Basic/DiagnosticTest.cpp +++ unittests/Basic/DiagnosticTest.cpp @@ -9,6 +9,7 @@ #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticIDs.h" +#include "clang/Basic/DiagnosticOr.h" #include "gtest/gtest.h" using namespace llvm; @@ -72,4 +73,21 @@ } } +TEST(DiagnosticTest, diagnosticOr) { + DiagnosticsEngine Diags(new DiagnosticIDs(), new DiagnosticOptions, + new IgnoringDiagConsumer()); + PartialDiagnostic::StorageAllocator Alloc; + DiagnosticOr> Value = PartialDiagnosticAt( + SourceLocation(), PartialDiagnostic(diag::err_cannot_open_file, Alloc) +<< "file" +<< "error"); + EXPECT_TRUE(!Value); + EXPECT_EQ(Value.getDiagnostic().first, SourceLocation()); + EXPECT_EQ(Value.getDiagnostic().second.getDiagID(), +diag::err_cannot_open_file); + Value = std::make_pair(20, 1); + EXPECT_FALSE(!Value); + EXPECT_EQ(*Value, std::make_pair(20, 1)); + EXPECT_EQ(Value->first, 20); +} } Index: include/clang/Basic/DiagnosticOr.h === --- /dev/null +++ include/clang/Basic/DiagnosticOr.h @@ -0,0 +1,131 @@ +//===--- DiagnosticOr.h - A partial diagnostic or a value ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +/// +/// \file +/// \brief Implements a DiagnosticOr variant that stores either a value or a +/// partial diagnostic and its location. +/// +//===--===// + +#ifndef LLVM_CLANG_BASIC_DIAGNOSTIC_OR_H +#define LLVM_CLANG_BASIC_DIAGNOSTIC_OR_H + +#include "clang/Basic/PartialDiagnostic.h" +#include "llvm/Support/AlignOf.h" + +namespace clang { + +/// Tagged union holding either a T or a PartialDiagnosticAt. +/// +/// This class parallels llvm::Expected, but replaces Error with +/// PartialDiagnosticAt. +template class LLVM_NODISCARD DiagnosticOr { +private: + using storage_type = T; + using reference = T &; + using const_reference = const T &; + using pointer = T *; + using const_pointer = const T *; + +public: + /// Create an DiagnosticOr diagnostic value from the given partial + /// diagnostic. + DiagnosticOr(PartialDiagnosticAt Diagnostic) : HasDiagnostic(true) { +new (getDiagnosticStorage()) PartialDiagnosticAt(std::move(Diagnostic)); + } + + /// Create an DiagnosticOr success value from the given OtherT value, which + /// must be convertible to T. + template + DiagnosticOr( + OtherT &&Val, + typename std::enable_if::value>::type * = + nullptr) + : HasDiagnostic(false) { +new (getStorage()) storage_type(std::forward(Val)); + } + + DiagnosticOr(DiagnosticOr &&Other) { moveConstruct(std::move(Other)); } + + DiagnosticOr &operator=(DiagnosticOr &&Other) { +moveAssign(std::move(Other)); +return *this; + } + + ~DiagnosticOr() { +if (!HasDiagnostic) + getStorage()->~storage_type(); +else + getDiagnosticStorage()->~PartialDiagnosticAt(); + } + + /// Returns false if there is a diagnostic. + explicit operator bool() { return !HasDiagnostic; } + + PartialDiagnosticAt &getDiagnostic() { return *getDiagnosticStorage(); } + + const PartialDiagnosticAt &getDiagnostic() const { +return *getDiagnosticStorage(); + } + + pointer operator->() { return getStorage(); } + + const_pointer operator->() const { return getStorage(); } + + reference operator*() { return *getStorage(); } + + const_reference operator*() const { return *getStorage(); } + +private: + void moveConstruct(DiagnosticOr &&Other) { +HasDiagnostic = Other.HasDiagnostic; + +if (!HasDiagnostic) + new (getStorage()) storage_type(std::move(*Other.getStorage())); +else + new (getDiagnosticStorage()) + PartialDiagnosticAt(std::move(*Other.getDiagnosticStorage())); + } + + void moveAssign(DiagnosticOr &&Other) { +this->~DiagnosticOr(); +new (this) DiagnosticOr(std::move(Other)); + } + + storage_type *getStorage() { +assert(!HasDiagnostic && "Cannot get value when a diagnostic exists!"); +return reinterpret_cast(TStorage.buffer); + } + + const storage_type *getStorage() const { +assert(!HasDiagnostic && "Cannot get value when a diagnostic exists!"); +return
[PATCH] D36075: [refactor] Initial support for refactoring action rules
arphaman added a comment. Extracted `DiagnosticOr` to a separate patch at https://reviews.llvm.org/D36969. I will update this patch tomorrow. Repository: rL LLVM https://reviews.llvm.org/D36075 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36187: [clang-diff] Use the relative name for NamedDecls
arphaman accepted this revision. arphaman added a comment. This revision is now accepted and ready to land. LG Comment at: lib/Tooling/ASTDiff/ASTDiff.cpp:371 + std::string ContextPrefix; + if (auto *Namespace = dyn_cast(Context)) +ContextPrefix = Namespace->getQualifiedNameAsString(); johannes wrote: > arphaman wrote: > > You don't need to check both `NamespaceDecl` and `TagDecl`, since you can > > just do one if with a `NamedDecl`. > FunctionDecl should not be used for example Oh yeah, makes sense. https://reviews.llvm.org/D36187 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36951: [OpenCL][5.0.0 Release] Release notes for OpenCL in Clang
Anastasia added inline comments. Comment at: docs/ReleaseNotes.rst:146 +- Extended Clang builtins with required ``cl_khr_subgroups`` support. +- Now interpreting empty argument function as void argument list in OpenCL code. +- Add ``intel_reqd_sub_group_size`` attribute support. bader wrote: > As far as I remember, this change was reverted as it had caused some > regressions. I haven't fix them yet, so I users still have to explicitly > specify void for empty parameter list. Good spot. Thanks! I will remove this. https://reviews.llvm.org/D36951 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r311182 - [analyzer] Fix modeling of constructors
Hello, Do we have time to merge this change into release 5.0.0? It's an assertion failure fix, which shows up on C++ code involving double-inheritance with empty base classes. Artem. On 8/18/17 9:20 PM, Alexander Shaposhnikov via cfe-commits wrote: Author: alexshap Date: Fri Aug 18 11:20:43 2017 New Revision: 311182 URL:http://llvm.org/viewvc/llvm-project?rev=311182&view=rev Log: [analyzer] Fix modeling of constructors This diff fixes analyzer's crash (triggered assert) on the newly added test case. The assert being discussed is assert(!B.lookup(R, BindingKey::Direct)) in lib/StaticAnalyzer/Core/RegionStore.cpp, however the root cause is different. For classes with empty bases the offsets might be tricky. For example, let's assume we have struct S: NonEmptyBase, EmptyBase { ... }; In this case Clang applies empty base class optimization and the offset of EmptyBase will be 0, it can be verified via clang -cc1 -x c++ -v -fdump-record-layouts main.cpp -emit-llvm -o /dev/null. When the analyzer tries to perform zero initialization of EmptyBase it will hit the assert because that region has already been "written" by the constructor of NonEmptyBase. Test plan: make check-all Differential revision:https://reviews.llvm.org/D36851 Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp cfe/trunk/test/Analysis/ctor.mm Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=311182&r1=311181&r2=311182&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Fri Aug 18 11:20:43 2017 @@ -409,6 +409,19 @@ public: // Part of public interface to c // BindDefault is only used to initialize a region with a default value. StoreRef BindDefault(Store store, const MemRegion *R, SVal V) override { +// FIXME: The offsets of empty bases can be tricky because of +// of the so called "empty base class optimization". +// If a base class has been optimized out +// we should not try to create a binding, otherwise we should. +// Unfortunately, at the moment ASTRecordLayout doesn't expose +// the actual sizes of the empty bases +// and trying to infer them from offsets/alignments +// seems to be error-prone and non-trivial because of the trailing padding. +// As a temporary mitigation we don't create bindings for empty bases. +if (R->getKind() == MemRegion::CXXBaseObjectRegionKind && +cast(R)->getDecl()->isEmpty()) + return StoreRef(store, *this); + RegionBindingsRef B = getRegionBindings(store); assert(!B.lookup(R, BindingKey::Direct)); Modified: cfe/trunk/test/Analysis/ctor.mm URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ctor.mm?rev=311182&r1=311181&r2=311182&view=diff == --- cfe/trunk/test/Analysis/ctor.mm (original) +++ cfe/trunk/test/Analysis/ctor.mm Fri Aug 18 11:20:43 2017 @@ -704,3 +704,20 @@ namespace PR19579 { }; } } + +namespace NoCrashOnEmptyBaseOptimization { + struct NonEmptyBase { +int X; +explicit NonEmptyBase(int X) : X(X) {} + }; + + struct EmptyBase {}; + + struct S : NonEmptyBase, EmptyBase { +S() : NonEmptyBase(0), EmptyBase() {} + }; + + void testSCtorNoCrash() { +S s; + } +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311344 - [StaticAnalyzer] Handle LoopExit CFGElement in the analyzer
Author: szepet Date: Mon Aug 21 09:10:19 2017 New Revision: 311344 URL: http://llvm.org/viewvc/llvm-project?rev=311344&view=rev Log: [StaticAnalyzer] Handle LoopExit CFGElement in the analyzer This patch adds handling of the LoopExit CFGElements to the StaticAnalyzer. This is reached by introducing a new ProgramPoint. Tests will be added in a following commit. Differential Revision: https://reviews.llvm.org/D35670 Modified: cfe/trunk/include/clang/Analysis/ProgramPoint.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Modified: cfe/trunk/include/clang/Analysis/ProgramPoint.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ProgramPoint.h?rev=311344&r1=311343&r2=311344&view=diff == --- cfe/trunk/include/clang/Analysis/ProgramPoint.h (original) +++ cfe/trunk/include/clang/Analysis/ProgramPoint.h Mon Aug 21 09:10:19 2017 @@ -83,6 +83,7 @@ public: PostImplicitCallKind, MinImplicitCallKind = PreImplicitCallKind, MaxImplicitCallKind = PostImplicitCallKind, + LoopExitKind, EpsilonKind}; private: @@ -654,6 +655,29 @@ private: } }; +/// Represents a point when we exit a loop. +/// When this ProgramPoint is encountered we can be sure that the symbolic +/// execution of the corresponding LoopStmt is finished on the given path. +/// Note: It is possible to encounter a LoopExit element when we haven't even +/// encountered the loop itself. At the current state not all loop exits will +/// result in a LoopExit program point. +class LoopExit : public ProgramPoint { +public: +LoopExit(const Stmt *LoopStmt, const LocationContext *LC) +: ProgramPoint(LoopStmt, nullptr, LoopExitKind, LC) {} + +const Stmt *getLoopStmt() const { + return static_cast(getData1()); +} + +private: +friend class ProgramPoint; +LoopExit() {} +static bool isKind(const ProgramPoint &Location) { + return Location.getKind() == LoopExitKind; +} +}; + /// This is a meta program point, which should be skipped by all the diagnostic /// reasoning etc. class EpsilonPoint : public ProgramPoint { Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=311344&r1=311343&r2=311344&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Mon Aug 21 09:10:19 2017 @@ -196,6 +196,8 @@ public: void ProcessStmt(const CFGStmt S, ExplodedNode *Pred); + void ProcessLoopExit(const Stmt* S, ExplodedNode *Pred); + void ProcessInitializer(const CFGInitializer I, ExplodedNode *Pred); void ProcessImplicitDtor(const CFGImplicitDtor D, ExplodedNode *Pred); Modified: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=311344&r1=311343&r2=311344&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp Mon Aug 21 09:10:19 2017 @@ -274,7 +274,8 @@ void CoreEngine::dispatchWorkItem(Explod assert(Loc.getAs() || Loc.getAs() || Loc.getAs() || - Loc.getAs()); + Loc.getAs() || + Loc.getAs()); HandlePostStmt(WU.getBlock(), WU.getIndex(), Pred); break; } @@ -566,7 +567,8 @@ void CoreEngine::enqueueStmtNode(Explode // Do not create extra nodes. Move to the next CFG element. if (N->getLocation().getAs() || - N->getLocation().getAs()) { + N->getLocation().getAs()|| + N->getLocation().getAs()) { WList->enqueue(N, Block, Idx+1); return; } Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=311344&r1=311343&r2=311344&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Mon Aug 21 09:10:19 2017 @@ -364,8 +364,10 @@ void ExprEngine::processCFGElement(const case CFGElement::TemporaryDtor: ProcessImplicitDtor(E.castAs(), Pred); return; -case CFGElement::LifetimeEnds: case CFGElement::LoopExit: + ProcessLoopExit(E.castAs().getLoopStmt(), Pred); + return; +case CFGElement::LifetimeEnds: return; } } @@ -510,6 +512,21 @@ void
[PATCH] D35670: [StaticAnalyzer] Handle LoopExit CFGElement in the analyzer
This revision was automatically updated to reflect the committed changes. Closed by commit rL311344: [StaticAnalyzer] Handle LoopExit CFGElement in the analyzer (authored by szepet). Changed prior to commit: https://reviews.llvm.org/D35670?vs=110981&id=111993#toc Repository: rL LLVM https://reviews.llvm.org/D35670 Files: cfe/trunk/include/clang/Analysis/ProgramPoint.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Index: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp @@ -274,7 +274,8 @@ assert(Loc.getAs() || Loc.getAs() || Loc.getAs() || - Loc.getAs()); + Loc.getAs() || + Loc.getAs()); HandlePostStmt(WU.getBlock(), WU.getIndex(), Pred); break; } @@ -566,7 +567,8 @@ // Do not create extra nodes. Move to the next CFG element. if (N->getLocation().getAs() || - N->getLocation().getAs()) { + N->getLocation().getAs()|| + N->getLocation().getAs()) { WList->enqueue(N, Block, Idx+1); return; } Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp === --- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -364,8 +364,10 @@ case CFGElement::TemporaryDtor: ProcessImplicitDtor(E.castAs(), Pred); return; -case CFGElement::LifetimeEnds: case CFGElement::LoopExit: + ProcessLoopExit(E.castAs().getLoopStmt(), Pred); + return; +case CFGElement::LifetimeEnds: return; } } @@ -510,6 +512,21 @@ Engine.enqueue(Dst, currBldrCtx->getBlock(), currStmtIdx); } +void ExprEngine::ProcessLoopExit(const Stmt* S, ExplodedNode *Pred) { + PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(), +S->getLocStart(), +"Error evaluating end of the loop"); + ExplodedNodeSet Dst; + Dst.Add(Pred); + NodeBuilder Bldr(Pred, Dst, *currBldrCtx); + + LoopExit PP(S, Pred->getLocationContext()); + Bldr.generateNode(PP, Pred->getState(), Pred); + + // Enqueue the new nodes onto the work list. + Engine.enqueue(Dst, currBldrCtx->getBlock(), currStmtIdx); +} + void ExprEngine::ProcessInitializer(const CFGInitializer Init, ExplodedNode *Pred) { const CXXCtorInitializer *BMI = Init.getInitializer(); @@ -2689,6 +2706,12 @@ Out << "Epsilon Point"; break; + case ProgramPoint::LoopExitKind: { +LoopExit LE = Loc.castAs(); +Out << "LoopExit: " << LE.getLoopStmt()->getStmtClassName(); +break; + } + case ProgramPoint::PreImplicitCallKind: { ImplicitCallPoint PC = Loc.castAs(); Out << "PreCall: "; Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h === --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h @@ -196,6 +196,8 @@ void ProcessStmt(const CFGStmt S, ExplodedNode *Pred); + void ProcessLoopExit(const Stmt* S, ExplodedNode *Pred); + void ProcessInitializer(const CFGInitializer I, ExplodedNode *Pred); void ProcessImplicitDtor(const CFGImplicitDtor D, ExplodedNode *Pred); Index: cfe/trunk/include/clang/Analysis/ProgramPoint.h === --- cfe/trunk/include/clang/Analysis/ProgramPoint.h +++ cfe/trunk/include/clang/Analysis/ProgramPoint.h @@ -83,6 +83,7 @@ PostImplicitCallKind, MinImplicitCallKind = PreImplicitCallKind, MaxImplicitCallKind = PostImplicitCallKind, + LoopExitKind, EpsilonKind}; private: @@ -654,6 +655,29 @@ } }; +/// Represents a point when we exit a loop. +/// When this ProgramPoint is encountered we can be sure that the symbolic +/// execution of the corresponding LoopStmt is finished on the given path. +/// Note: It is possible to encounter a LoopExit element when we haven't even +/// encountered the loop itself. At the current state not all loop exits will +/// result in a LoopExit program point. +class LoopExit : public ProgramPoint { +public: +LoopExit(const Stmt *LoopStmt, const LocationContext *LC) +: ProgramPoint(LoopStmt, nullptr, LoopExitKind, LC) {} + +const Stmt *getLoopStmt() const { + return static_cast(getData1()); +} + +private: +friend class ProgramPoint; +LoopExit() {} +static bool isKind(const ProgramPoint &Location) { + return Location.getKind() == Lo
r311345 - [clang-proto-fuzzer] Update README.
Author: morehouse Date: Mon Aug 21 09:18:43 2017 New Revision: 311345 URL: http://llvm.org/viewvc/llvm-project?rev=311345&view=rev Log: [clang-proto-fuzzer] Update README. Add instructions on how to modify the compiler invocation. Modified: cfe/trunk/tools/clang-fuzzer/README.txt Modified: cfe/trunk/tools/clang-fuzzer/README.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/README.txt?rev=311345&r1=311344&r2=311345&view=diff == --- cfe/trunk/tools/clang-fuzzer/README.txt (original) +++ cfe/trunk/tools/clang-fuzzer/README.txt Mon Aug 21 09:18:43 2017 @@ -29,6 +29,11 @@ Example: -DLLVM_USE_SANITIZE_COVERAGE=YES -DLLVM_USE_SANITIZER=Address ninja clang-fuzzer +== + Running clang-fuzzer +== + bin/clang-fuzzer CORPUS_DIR + === Building clang-proto-fuzzer (Linux-only instructions) @@ -62,14 +67,16 @@ Example: This directory also contains a Dockerfile which sets up all required dependencies and builds the fuzzers. -= - Running the fuzzers -= -clang-fuzzer: - bin/clang-fuzzer CORPUS_DIR - -clang-proto-fuzzer: + + Running clang-proto-fuzzer + bin/clang-proto-fuzzer CORPUS_DIR -Translating a clang-proto-fuzzer corpus output to C++: +Arguments can be specified after -ignore_remaining_args=1 to modify the compiler +invocation. For example, the following command line will fuzz LLVM with a +custom optimization level and target triple: + bin/clang-proto-fuzzer CORPUS_DIR -ignore_remaining_args=1 -O3 -triple \ + arm64apple-ios9 + +To translate a clang-proto-fuzzer corpus output to C++: bin/clang-proto-to-cxx CORPUS_OUTPUT_FILE ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36423: [libc++] Introsort based sorting function
DIVYA updated this revision to Diff 111998. DIVYA added a comment. - added test qsort_worst_uint32 in algorithm.bench.cpp https://reviews.llvm.org/D36423 Files: benchmarks/GenerateInput.hpp benchmarks/algorithms.bench.cpp include/algorithm Index: include/algorithm === --- include/algorithm +++ include/algorithm @@ -642,6 +642,7 @@ #include // needed to provide swap_ranges. #include #include +#include #include #if defined(__IBMCPP__) @@ -3994,7 +3995,14 @@ template void -__sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, +_Compare); + +// Using introsort algorithm for sorting +template +void +__intro_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, + typename iterator_traits<_RandomAccessIterator>::difference_type __depth_limit) { // _Compare is known to be a reference type typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; @@ -4029,6 +4037,12 @@ _VSTD::__insertion_sort_3<_Compare>(__first, __last, __comp); return; } +if (__depth_limit == 0) +{ +__partial_sort<_Compare>(__first,__last,__last,__comp); +return; +} + // __len > 5 _RandomAccessIterator __m = __first; _RandomAccessIterator __lm1 = __last; @@ -4172,19 +4186,33 @@ // sort smaller range with recursive call and larger with tail recursion elimination if (__i - __first < __last - __i) { -_VSTD::__sort<_Compare>(__first, __i, __comp); -// _VSTD::__sort<_Compare>(__i+1, __last, __comp); +_VSTD::__intro_sort<_Compare>(__first, __i, __comp, __depth_limit); +// _VSTD::__intro_sort<_Compare>(__i+1, __last, __comp, __depth_limit); __first = ++__i; } else { -_VSTD::__sort<_Compare>(__i+1, __last, __comp); -// _VSTD::__sort<_Compare>(__first, __i, __comp); +_VSTD::__intro_sort<_Compare>(__i+1, __last, __comp, __depth_limit); +// _VSTD::__intro_sort<_Compare>(__first, __i, __comp, __depth_limit); __last = __i; } +--__depth_limit; } } +template +void +__sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +{ + + // Threshold(or depth limit) for introsort is taken to be 2*log2(size) + typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; + const difference_type __dp = __last - __first; + difference_type __depth_limit = __last == __first ? 0 : _VSTD::log2(__dp); + __depth_limit *= 2; + __intro_sort<_Compare>(__first, __last, __comp, __depth_limit); +} + // This forwarder keeps the top call and the recursive calls using the same instantiation, forcing a reference _Compare template inline _LIBCPP_INLINE_VISIBILITY Index: benchmarks/algorithms.bench.cpp === --- benchmarks/algorithms.bench.cpp +++ benchmarks/algorithms.bench.cpp @@ -5,7 +5,7 @@ #include "benchmark/benchmark_api.h" #include "GenerateInput.hpp" -constexpr std::size_t TestNumInputs = 1024; +constexpr std::size_t TestNumInputs = 1024*64; template void BM_Sort(benchmark::State& st, GenInputs gen) { @@ -58,5 +58,8 @@ BENCHMARK_CAPTURE(BM_Sort, single_element_strings, getDuplicateStringInputs)->Arg(TestNumInputs); +BENCHMARK_CAPTURE(BM_Sort, qsort_worst_uint32, +getQSortKiller)->Arg(TestNumInputs); + BENCHMARK_MAIN() Index: benchmarks/GenerateInput.hpp === --- benchmarks/GenerateInput.hpp +++ benchmarks/GenerateInput.hpp @@ -138,5 +138,40 @@ return cinputs; } +template +inline std::vector make_killer(size_t N) { +std::vector inputs; +uint32_t candidate = 0; +uint32_t num_solid = 0; +uint32_t gas = N - 1; + +std::vector tmp(N); +inputs.resize(N); + +for (T i = 0; i < N; ++i) { +tmp[i] = i; +inputs[i] = gas; +} + +std::sort(tmp.begin(), tmp.end(), [&](T x, T y) { +if (inputs[x] == gas && inputs[y] == gas) { +if (x == candidate) inputs[x] = num_solid++; +else inputs[y] = num_solid++; +} + +if (inputs[x] == gas) candidate = x; +else if (inputs[y] == gas) candidate = y; + +return inputs[x] < inputs[y]; +}); +return inputs; +} + + +template +inline std::vector getQSortKiller(size_t N){ +std::vector inputs = make_killer(N); +return inputs; +} #endif // BENCHMARK_GENERATE_INPUT_HPP ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-c
[PATCH] D36931: Update LLVM 5.0 release notes for ms_abi and __builtin_ms_va_list for aarch64
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm https://reviews.llvm.org/D36931 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311346 - [StaticAnalyzer] LoopUnrolling: Track a LoopStack in order to completely unroll specific loops
Author: szepet Date: Mon Aug 21 09:32:57 2017 New Revision: 311346 URL: http://llvm.org/viewvc/llvm-project?rev=311346&view=rev Log: [StaticAnalyzer] LoopUnrolling: Track a LoopStack in order to completely unroll specific loops The LoopExit CFG information provides the opportunity to not mark the loops but having a stack which tracks if a loop is unrolled or not. So in case of simulating a loop we just add it and the information if it meets the requirements to be unrolled to the top of the stack. Differential Revision: https://reviews.llvm.org/D35684 Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp cfe/trunk/lib/StaticAnalyzer/Core/LoopUnrolling.cpp cfe/trunk/test/Analysis/loop-unrolling.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h?rev=311346&r1=311345&r2=311346&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h Mon Aug 21 09:32:57 2017 @@ -8,7 +8,17 @@ //===--===// /// /// This header contains the declarations of functions which are used to decide -/// which loops should be completely unrolled and mark them. +/// which loops should be completely unrolled and mark their corresponding +/// CFGBlocks. It is done by tracking a stack of loops in the ProgramState. This +/// way specific loops can be marked as completely unrolled. For considering a +/// loop to be completely unrolled it has to fulfill the following requirements: +/// - Currently only forStmts can be considered. +/// - The bound has to be known. +/// - The counter variable has not escaped before/in the body of the loop and +/// changed only in the increment statement corresponding to the loop. It also +/// has to be initialized by a literal in the corresponding initStmt. +/// - Does not contain goto, switch and returnStmt. +/// /// //===--===// @@ -18,17 +28,21 @@ #include "clang/Analysis/CFG.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h" - namespace clang { namespace ento { class AnalysisManager; -ProgramStateRef markLoopAsUnrolled(const Stmt *Term, ProgramStateRef State, - const FunctionDecl *FD); -bool isUnrolledLoopBlock(const CFGBlock *Block, ExplodedNode *Pred, - AnalysisManager &AMgr); -bool shouldCompletelyUnroll(const Stmt *LoopStmt, ASTContext &ASTCtx, -ExplodedNode *Pred); +/// Returns if the given State indicates that is inside a completely unrolled +/// loop. +bool isUnrolledState(ProgramStateRef State); + +/// Updates the stack of loops contained by the ProgramState. +ProgramStateRef updateLoopStack(const Stmt *LoopStmt, ASTContext &ASTCtx, +ExplodedNode* Pred); + +/// Updates the given ProgramState. In current implementation it removes the top +/// element of the stack of loops. +ProgramStateRef processLoopEnd(const Stmt *LoopStmt, ProgramStateRef State); } // end namespace ento } // end namespace clang Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=311346&r1=311345&r2=311346&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Mon Aug 21 09:32:57 2017 @@ -519,10 +519,13 @@ void ExprEngine::ProcessLoopExit(const S ExplodedNodeSet Dst; Dst.Add(Pred); NodeBuilder Bldr(Pred, Dst, *currBldrCtx); + ProgramStateRef NewState = Pred->getState(); - LoopExit PP(S, Pred->getLocationContext()); - Bldr.generateNode(PP, Pred->getState(), Pred); + if(AMgr.options.shouldUnrollLoops()) +NewState = processLoopEnd(S, NewState); + LoopExit PP(S, Pred->getLocationContext()); + Bldr.generateNode(PP, NewState, Pred); // Enqueue the new nodes onto the work list. Engine.enqueue(Dst, currBldrCtx->getBlock(), currStmtIdx); } @@ -1519,22 +1522,17 @@ void ExprEngine::processCFGBlockEntrance PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext()); // If we reach a loop which has a known bound (and meets // other constraints) then consider completely unrolling it. - if (AMgr.options.shouldUnrollLoops()) { -const CFGBlock *ActualBlock = nodeBuilder.getContext().getBlock(); -const Stmt *Term = ActualBlock->getTerminato
[PATCH] D36914: Implement CFG construction for __try / __except / __leave.
rnk added a comment. > Don't add any EH edges to the CFG for SEH. In practice, BuildOpts.AddEHEdges > is always false in practice from what I can tell, and with SEH every single > stmt would have to get an EH edge. Since we can't mix C++ EH and SEH, do you think it would be better to reuse the TryTerminatedBlock chain so that we get edges from every call to the __except? That's the approximation of SEH that we actually support in LLVM anyway. Comment at: lib/Analysis/CFG.cpp:2570 + // All __leaves should go to the code following the __try + // (FIXME: or if the __try // has a __finally, to the __finally.) + SaveAndRestore save_break(SEHLeaveJumpTarget); Looks like a `//` got re-wrapped in the comment Comment at: test/Sema/warn-unreachable-ms.c:23 + } __except(1) { // Filter expression should not be marked as unreachable. +// Emtpy __except body. + } typo empty https://reviews.llvm.org/D36914 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311347 - [clang] Fix tests for Emitting Single Inline Remark
Author: lenary Date: Mon Aug 21 09:40:35 2017 New Revision: 311347 URL: http://llvm.org/viewvc/llvm-project?rev=311347&view=rev Log: [clang] Fix tests for Emitting Single Inline Remark Summary: This change depends on https://reviews.llvm.org/D36054 and should be landed at the same time. Reviewers: anemet Reviewed By: anemet Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36949 Modified: cfe/trunk/test/Frontend/optimization-remark-with-hotness.c cfe/trunk/test/Frontend/optimization-remark.c Modified: cfe/trunk/test/Frontend/optimization-remark-with-hotness.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-with-hotness.c?rev=311347&r1=311346&r2=311347&view=diff == --- cfe/trunk/test/Frontend/optimization-remark-with-hotness.c (original) +++ cfe/trunk/test/Frontend/optimization-remark-with-hotness.c Mon Aug 21 09:40:35 2017 @@ -56,8 +56,7 @@ void bar(int x) { // THRESHOLD-NOT: hotness // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided optimization information - // expected-remark@+2 {{foo should always be inlined (cost=always) (hotness: 30)}} - // expected-remark@+1 {{foo inlined into bar (hotness: 30)}} + // expected-remark@+1 {{foo inlined into bar with cost=always}} sum += foo(x, x - 2); } Modified: cfe/trunk/test/Frontend/optimization-remark.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark.c?rev=311347&r1=311346&r2=311347&view=diff == --- cfe/trunk/test/Frontend/optimization-remark.c (original) +++ cfe/trunk/test/Frontend/optimization-remark.c Mon Aug 21 09:40:35 2017 @@ -42,9 +42,8 @@ float foz(int x, int y) { return x * y; // twice. // int bar(int j) { -// expected-remark@+4 {{foz not inlined into bar because it should never be inlined (cost=never)}} // expected-remark@+3 {{foz not inlined into bar because it should never be inlined (cost=never)}} -// expected-remark@+2 {{foo should always be inlined}} +// expected-remark@+2 {{foz not inlined into bar because it should never be inlined (cost=never)}} // expected-remark@+1 {{foo inlined into bar}} return foo(j, j - 2) * foz(j - 2, j); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36949: [clang] Fix tests for Emitting Single Inline Remark
This revision was automatically updated to reflect the committed changes. Closed by commit rL311347: [clang] Fix tests for Emitting Single Inline Remark (authored by lenary). Repository: rL LLVM https://reviews.llvm.org/D36949 Files: cfe/trunk/test/Frontend/optimization-remark-with-hotness.c cfe/trunk/test/Frontend/optimization-remark.c Index: cfe/trunk/test/Frontend/optimization-remark.c === --- cfe/trunk/test/Frontend/optimization-remark.c +++ cfe/trunk/test/Frontend/optimization-remark.c @@ -42,9 +42,8 @@ // twice. // int bar(int j) { -// expected-remark@+4 {{foz not inlined into bar because it should never be inlined (cost=never)}} // expected-remark@+3 {{foz not inlined into bar because it should never be inlined (cost=never)}} -// expected-remark@+2 {{foo should always be inlined}} +// expected-remark@+2 {{foz not inlined into bar because it should never be inlined (cost=never)}} // expected-remark@+1 {{foo inlined into bar}} return foo(j, j - 2) * foz(j - 2, j); } Index: cfe/trunk/test/Frontend/optimization-remark-with-hotness.c === --- cfe/trunk/test/Frontend/optimization-remark-with-hotness.c +++ cfe/trunk/test/Frontend/optimization-remark-with-hotness.c @@ -56,8 +56,7 @@ // THRESHOLD-NOT: hotness // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided optimization information - // expected-remark@+2 {{foo should always be inlined (cost=always) (hotness: 30)}} - // expected-remark@+1 {{foo inlined into bar (hotness: 30)}} + // expected-remark@+1 {{foo inlined into bar with cost=always}} sum += foo(x, x - 2); } Index: cfe/trunk/test/Frontend/optimization-remark.c === --- cfe/trunk/test/Frontend/optimization-remark.c +++ cfe/trunk/test/Frontend/optimization-remark.c @@ -42,9 +42,8 @@ // twice. // int bar(int j) { -// expected-remark@+4 {{foz not inlined into bar because it should never be inlined (cost=never)}} // expected-remark@+3 {{foz not inlined into bar because it should never be inlined (cost=never)}} -// expected-remark@+2 {{foo should always be inlined}} +// expected-remark@+2 {{foz not inlined into bar because it should never be inlined (cost=never)}} // expected-remark@+1 {{foo inlined into bar}} return foo(j, j - 2) * foz(j - 2, j); } Index: cfe/trunk/test/Frontend/optimization-remark-with-hotness.c === --- cfe/trunk/test/Frontend/optimization-remark-with-hotness.c +++ cfe/trunk/test/Frontend/optimization-remark-with-hotness.c @@ -56,8 +56,7 @@ // THRESHOLD-NOT: hotness // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided optimization information - // expected-remark@+2 {{foo should always be inlined (cost=always) (hotness: 30)}} - // expected-remark@+1 {{foo inlined into bar (hotness: 30)}} + // expected-remark@+1 {{foo inlined into bar with cost=always}} sum += foo(x, x - 2); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D36914: Implement CFG construction for __try / __except / __leave.
On Mon, Aug 21, 2017 at 12:41 PM, Reid Kleckner via Phabricator via cfe-commits wrote: > rnk added a comment. > > > Don't add any EH edges to the CFG for SEH. In practice, > BuildOpts.AddEHEdges is always false in practice from what I can tell, and > with SEH every single stmt would have to get an EH edge. > > Since we can't mix C++ EH and SEH, do you think it would be better to > reuse the TryTerminatedBlock chain so that we get edges from every call to > the __except? That's the approximation of SEH that we actually support in > LLVM anyway. > Oh, that's a good idea. It'd mean that a CXXThrow would lead to a __try block, but I suppose that's a feature, not a bug? > > Comment at: lib/Analysis/CFG.cpp:2570 > + // All __leaves should go to the code following the __try > + // (FIXME: or if the __try // has a __finally, to the __finally.) > + SaveAndRestore save_break(SEHLeaveJumpTarget); > > Looks like a `//` got re-wrapped in the comment > > > > Comment at: test/Sema/warn-unreachable-ms.c:23 > + } __except(1) { // Filter expression should not be marked as > unreachable. > +// Emtpy __except body. > + } > > typo empty > > > https://reviews.llvm.org/D36914 > > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35533: [Basic] Update CMakeLists.txt to handle Repo
hintonda added a comment. I've submitted a patch, https://reviews.llvm.org/D36971, that moves find_first_existing_file and find_first_existing_vc_file to ADDLLVM so they can be reused here. If that patch is accepted and lands, you can then remove these versions and check to see if that solves your problem. Note that you must remove these versions in order for cmake to use the moved ones, which would be hidden by the new ones, but can still be accessed by adding a '_' prefix. Comment at: lib/Basic/CMakeLists.txt:17 macro(find_first_existing_vc_file out_var path) set(git_path "${path}/.git") minseong.kim wrote: > hintonda wrote: > > LLVM already has a version of find_first_existing_vc_file in > > llvm/include/llvm/Support/CMakelists.txt. > > > > Would it make sense move it to an llvm module and reuse it in clang? > Thanks for the suggestion. > My understanding is that "llvm/include/llvm/Support/CMakeLists.txt" is used > to generate VCSRevision.h which is used by llvm-specific modules such as opt, > not clang. Furthermore find_first_existing_vc_file function in > llvm/include/llvm/Support/CMakeLists.txt does not handle the version info > either. I believe the version of `find_first_vc_file` in llvm/Support/CMakeLists.txt handles this case correctly. So, instead of fixing/maintaining this version, which is slightly different, perhaps the version in llvm/Support/CMakeList.txt could be moved to ADDLLVM.cmake where it could be used by both. https://reviews.llvm.org/D35533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36914: Implement CFG construction for __try / __except / __leave.
thakis added inline comments. Comment at: lib/Analysis/CFG.cpp:448 +BuildOpts(buildOpts), switchExclusivelyCovered(false), +switchCond(nullptr), cachedEntry(nullptr), lastLookup(nullptr) {} (this is now a no-op and only a clang-formatting of the existing ctor code. I can omit this if you want.) https://reviews.llvm.org/D36914 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36914: Implement CFG construction for __try / __except / __leave.
thakis updated this revision to Diff 112015. thakis edited the summary of this revision. thakis added a comment. Just use TryTerminatedBlock https://reviews.llvm.org/D36914 Files: lib/Analysis/CFG.cpp test/Sema/warn-unreachable-ms.c Index: test/Sema/warn-unreachable-ms.c === --- test/Sema/warn-unreachable-ms.c +++ test/Sema/warn-unreachable-ms.c @@ -0,0 +1,42 @@ +// RUN: %clang_cc1 %s -triple=i686-pc-win32 -fsyntax-only -verify -fms-extensions -Wunreachable-code + +void f(); + +void g1() { + __try { +f(); +__leave; +f(); // expected-warning{{will never be executed}} + } __except(1) { +f(); + } + + // Completely empty. + __try { + } __except(1) { + } + + __try { +f(); +return; + } __except(1) { // Filter expression should not be marked as unreachable. +// Empty __except body. + } +} + +void g2() { + __try { +// Nested __try. +__try { + f(); + __leave; + f(); // expected-warning{{will never be executed}} +} __except(2) { +} +f(); +__leave; +f(); // expected-warning{{will never be executed}} + } __except(1) { +f(); + } +} Index: lib/Analysis/CFG.cpp === --- lib/Analysis/CFG.cpp +++ lib/Analysis/CFG.cpp @@ -395,12 +395,16 @@ ASTContext *Context; std::unique_ptr cfg; - CFGBlock *Block; - CFGBlock *Succ; + CFGBlock *Block; // Current block. + CFGBlock *Succ; // Block after the current block. JumpTarget ContinueJumpTarget; JumpTarget BreakJumpTarget; + JumpTarget SEHLeaveJumpTarget; CFGBlock *SwitchTerminatedBlock; CFGBlock *DefaultCaseBlock; + + // This can point either to a try or a __try block. The frontend forbids + // mixing both kinds in one function, so having one for both is enough. CFGBlock *TryTerminatedBlock; // Current position in local scope. @@ -436,13 +440,12 @@ public: explicit CFGBuilder(ASTContext *astContext, - const CFG::BuildOptions &buildOpts) -: Context(astContext), cfg(new CFG()), // crew a new CFG - Block(nullptr), Succ(nullptr), - SwitchTerminatedBlock(nullptr), DefaultCaseBlock(nullptr), - TryTerminatedBlock(nullptr), badCFG(false), BuildOpts(buildOpts), - switchExclusivelyCovered(false), switchCond(nullptr), - cachedEntry(nullptr), lastLookup(nullptr) {} + const CFG::BuildOptions &buildOpts) + : Context(astContext), cfg(new CFG()), // crew a new CFG +Block(nullptr), Succ(nullptr), SwitchTerminatedBlock(nullptr), +DefaultCaseBlock(nullptr), TryTerminatedBlock(nullptr), badCFG(false), +BuildOpts(buildOpts), switchExclusivelyCovered(false), +switchCond(nullptr), cachedEntry(nullptr), lastLookup(nullptr) {} // buildCFG - Used by external clients to construct the CFG. std::unique_ptr buildCFG(const Decl *D, Stmt *Statement); @@ -501,6 +504,10 @@ CFGBlock *VisitObjCForCollectionStmt(ObjCForCollectionStmt *S); CFGBlock *VisitPseudoObjectExpr(PseudoObjectExpr *E); CFGBlock *VisitReturnStmt(ReturnStmt *R); + CFGBlock *VisitSEHExceptStmt(SEHExceptStmt *S); + CFGBlock *VisitSEHFinallyStmt(SEHFinallyStmt *S); + CFGBlock *VisitSEHLeaveStmt(SEHLeaveStmt *S); + CFGBlock *VisitSEHTryStmt(SEHTryStmt *S); CFGBlock *VisitStmtExpr(StmtExpr *S, AddStmtChoice asc); CFGBlock *VisitSwitchStmt(SwitchStmt *S); CFGBlock *VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E, @@ -1716,6 +1723,18 @@ case Stmt::ReturnStmtClass: return VisitReturnStmt(cast(S)); +case Stmt::SEHExceptStmtClass: + return VisitSEHExceptStmt(cast(S)); + +case Stmt::SEHFinallyStmtClass: + return VisitSEHFinallyStmt(cast(S)); + +case Stmt::SEHLeaveStmtClass: + return VisitSEHLeaveStmt(cast(S)); + +case Stmt::SEHTryStmtClass: + return VisitSEHTryStmt(cast(S)); + case Stmt::UnaryExprOrTypeTraitExprClass: return VisitUnaryExprOrTypeTraitExpr(cast(S), asc); @@ -2447,6 +2466,117 @@ return VisitStmt(R, AddStmtChoice::AlwaysAdd); } +CFGBlock *CFGBuilder::VisitSEHExceptStmt(SEHExceptStmt *ES) { + // SEHExceptStmt are treated like labels, so they are the first statement in a + // block. + + // Save local scope position because in case of exception variable ScopePos + // won't be restored when traversing AST. + SaveAndRestore save_scope_pos(ScopePos); + + addStmt(ES->getBlock()); + CFGBlock *SEHExceptBlock = Block; + if (!SEHExceptBlock) +SEHExceptBlock = createBlock(); + + appendStmt(SEHExceptBlock, ES); + + // Also add the SEHExceptBlock as a label, like with regular labels. + SEHExceptBlock->setLabel(ES); + + // Bail out if the CFG is bad. + if (badCFG) +return nullptr; + + // We set Block to NULL to allow lazy creation of a new block (if necessary). + Block = nullptr; + + return SEHExceptBlock; +} + +CFGBlo
[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas
hamzasood updated this revision to Diff 112018. hamzasood added a comment. - Info about a lambda's explicit template parameters is now exposed in the AST (see changes to LambdaExpr). It turns out that no extra storage was actually needed to achieve this. - Removed remnants of a previous implementation (unused getExplicitTemplateParams function, creation of a TemplateParameterList in ActOnLambdaTemplateParameterList). - Renamed ActOnLambdaTemplateParameterList -> ActOnLambdaExplicitTemplateParameterList (which is a bit more clear). - Changed LambdaScopeInfo::TemplateParams from a vector of Decl* to a vector of NamedDecl*. https://reviews.llvm.org/D36527 Files: include/clang/AST/ExprCXX.h include/clang/Basic/DiagnosticParseKinds.td include/clang/Sema/ScopeInfo.h include/clang/Sema/Sema.h lib/AST/ExprCXX.cpp lib/Parse/ParseExprCXX.cpp lib/Sema/Sema.cpp lib/Sema/SemaLambda.cpp lib/Sema/SemaType.cpp test/CXX/temp/temp.decls/temp.variadic/p4.cpp test/Parser/cxx2a-template-lambdas.cpp test/SemaCXX/cxx2a-template-lambdas.cpp www/cxx_status.html Index: www/cxx_status.html === --- www/cxx_status.html +++ www/cxx_status.html @@ -822,7 +822,7 @@ template-parameter-list for generic lambdas http://wg21.link/p0428r2";>P0428R2 - No + SVN Initializer list constructors in class template argument deduction Index: test/SemaCXX/cxx2a-template-lambdas.cpp === --- test/SemaCXX/cxx2a-template-lambdas.cpp +++ test/SemaCXX/cxx2a-template-lambdas.cpp @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -std=c++2a -verify %s + +template +constexpr bool is_same = false; + +template +constexpr bool is_same = true; + +template +struct DummyTemplate { }; + +void func() { + auto L0 = [](T arg) { +static_assert(is_same); + }; + L0(0); + + auto L1 = [] { +static_assert(I == 5); + }; + L1.operator()<5>(); + + auto L2 = [] class T, class U>(T &&arg) { +static_assert(is_same, DummyTemplate>); + }; + L2(DummyTemplate()); +} + +template // expected-note {{declared here}} +struct ShadowMe { + void member_func() { +auto L = [] { }; // expected-error {{'T' shadows template parameter}} + } +}; Index: test/Parser/cxx2a-template-lambdas.cpp === --- test/Parser/cxx2a-template-lambdas.cpp +++ test/Parser/cxx2a-template-lambdas.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -std=c++2a %s -verify + +auto L0 = []<> { }; //expected-error {{cannot be empty}} + +auto L1 = [] { }; +auto L2 = [](T1 arg1, T2 arg2) -> T1 { }; +auto L3 = [](auto arg) { T t; }; +auto L4 = []() { }; Index: test/CXX/temp/temp.decls/temp.variadic/p4.cpp === --- test/CXX/temp/temp.decls/temp.variadic/p4.cpp +++ test/CXX/temp/temp.decls/temp.variadic/p4.cpp @@ -213,8 +213,10 @@ }; #endif +#if __cplusplus >= 201707L //- in a template parameter pack that is a pack expansion - // FIXME: We do not support any way to reach this case yet. + swallow([] typename ...W>(W ...wv) { }); +#endif //- in an initializer-list int arr[] = {T().x...}; @@ -279,11 +281,6 @@ struct T { int x; using U = int; }; void g() { f(1, 2, 3); } - template void pack_in_lambda(U ...u) { // expected-note {{here}} -// FIXME: Move this test into 'f' above once we support this syntax. -[] typename ...U>(U ...uv) {}; // expected-error {{expected body of lambda}} expected-error {{does not refer to a value}} - } - template void pack_expand_attr() { // FIXME: Move this test into 'f' above once we support this. [[gnu::aligned(alignof(T))...]] int x; // expected-error {{cannot be used as an attribute pack}} expected-error {{unexpanded}} Index: lib/Sema/SemaType.cpp === --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -2790,7 +2790,7 @@ sema::LambdaScopeInfo *LSI = SemaRef.getCurLambda(); assert(LSI && "No LambdaScopeInfo on the stack!"); const unsigned TemplateParameterDepth = LSI->AutoTemplateParameterDepth; -const unsigned AutoParameterPosition = LSI->AutoTemplateParams.size(); +const unsigned AutoParameterPosition = LSI->TemplateParams.size(); const bool IsParameterPack = D.hasEllipsis(); // Create the TemplateTypeParmDecl here to retrieve the corresponding @@ -2802,7 +2802,8 @@ /*KeyLoc*/SourceLocation(), /*NameLoc*/D.getLocStart(), TemplateParameterDepth, AutoParameterPosition, /*Identifier*/nullptr, false, IsParameterPack); -LSI->AutoTemplateParams.push_back(CorrespondingTemplateParam); +CorrespondingTemplateParam->setImplicit(); +LSI->TemplateParams.push_back(CorrespondingTemplateParam); //
Re: r292458 - Add -fdebug-info-for-profiling to emit more debug info for sample pgo profile collection
On Fri, Aug 18, 2017 at 5:22 PM, Dehao Chen wrote: > On Fri, Aug 18, 2017 at 2:46 PM, Hans Wennborg wrote: >> >> Should we mention this in the release notes? >> >> >> Is the flag documented somewhere? > > > It's documented in the Options.td file, do you think there are other > documents that need to be added/updated? Maybe https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization if we think this is something users should be using. And if it improves things, perhaps its worth mentioning in the release notes? Thanks, Hans >> On Wed, Jan 18, 2017 at 4:44 PM, Dehao Chen via cfe-commits >> wrote: >> > Author: dehao >> > Date: Wed Jan 18 18:44:21 2017 >> > New Revision: 292458 >> > >> > URL: http://llvm.org/viewvc/llvm-project?rev=292458&view=rev >> > Log: >> > Add -fdebug-info-for-profiling to emit more debug info for sample pgo >> > profile collection >> > >> > Summary: >> > SamplePGO uses profile with debug info to collect profile. Unlike the >> > traditional debugging purpose, sample pgo needs more accurate debug info to >> > represent the profile. We add -femit-accurate-debug-info for this purpose. >> > It can be combined with all debugging modes (-g, -gmlt, etc). It makes sure >> > that the following pieces of info is always emitted: >> > >> > * start line of all subprograms >> > * linkage name of all subprograms >> > * standalone subprograms (functions that has neither inlined nor been >> > inlined) >> > >> > The impact on speccpu2006 binary size (size increase comparing with -g0 >> > binary, also includes data for -g binary, which does not change with this >> > patch): >> > >> >-gmlt(orig) -gmlt(patched) -g >> > 433.milc 4.68% 5.40% 19.73% >> > 444.namd 8.45% 8.93% 45.99% >> > 447.dealII 97.43% 115.21%374.89% >> > 450.soplex 27.75% 31.88% 126.04% >> > 453.povray 21.81% 26.16% 92.03% >> > 470.lbm0.60% 0.67% 1.96% >> > 482.sphinx35.77% 6.47% 26.17% >> > 400.perlbench 17.81% 19.43% 73.08% >> > 401.bzip2 3.73% 3.92% 12.18% >> > 403.gcc31.75% 34.48% 122.75% >> > 429.mcf0.78% 0.88% 3.89% >> > 445.gobmk 6.08% 7.92% 42.27% >> > 456.hmmer 10.36% 11.25% 35.23% >> > 458.sjeng 5.08% 5.42% 14.36% >> > 462.libquantum 1.71% 1.96% 6.36% >> > 464.h264ref15.61% 16.56% 43.92% >> > 471.omnetpp11.93% 15.84% 60.09% >> > 473.astar 3.11% 3.69% 14.18% >> > 483.xalancbmk 56.29% 81.63% 353.22% >> > geomean15.60% 18.30% 57.81% >> > >> > Debug info size change for -gmlt binary with this patch: >> > >> > 433.milc 13.46% >> > 444.namd 5.35% >> > 447.dealII 18.21% >> > 450.soplex 14.68% >> > 453.povray 19.65% >> > 470.lbm6.03% >> > 482.sphinx311.21% >> > 400.perlbench 8.91% >> > 401.bzip2 4.41% >> > 403.gcc8.56% >> > 429.mcf8.24% >> > 445.gobmk 29.47% >> > 456.hmmer 8.19% >> > 458.sjeng 6.05% >> > 462.libquantum 11.23% >> > 464.h264ref5.93% >> > 471.omnetpp31.89% >> > 473.astar 16.20% >> > 483.xalancbmk 44.62% >> > geomean16.83% >> > >> > Reviewers: davidxl, andreadb, rob.lougher, dblaikie, echristo >> > >> > Reviewed By: dblaikie, echristo >> > >> > Subscribers: hfinkel, rob.lougher, andreadb, gbedwell, cfe-commits, >> > probinson, llvm-commits, mehdi_amini >> > >> > Differential Revision: https://reviews.llvm.org/D25435 >> > >> > Modified: >> > cfe/trunk/include/clang/Driver/Options.td >> > cfe/trunk/include/clang/Frontend/CodeGenOptions.def >> > cfe/trunk/lib/CodeGen/BackendUtil.cpp >> > cfe/trunk/lib/CodeGen/CGDebugInfo.cpp >> > cfe/trunk/lib/Driver/Tools.cpp >> > cfe/trunk/lib/Frontend/CompilerInvocation.cpp >> > cfe/trunk/test/Driver/clang_f_opts.c >> > >> > Modified: cfe/trunk/include/clang/Driver/Options.td >> > URL: >> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=292458&r1=292457&r2=292458&view=diff >> > >> > == >> > --- cfe/trunk/include/clang/Driver/Options.td (original) >> > +++ cfe/trunk/include/clang/Driver/Options.td Wed Jan 18 18:44:21 2017 >> > @@ -516,6 +516,12 @@ def fprofile_sample_use_EQ : Joined<["-" >> > HelpText<"Enable sample-based profile guided optimizations">; >> > def fauto_profile_EQ : Joined<["-"], "fauto-profile=">, >> > Alias; >> > +def fdebug_info_for_profiling : Flag<["-"], >> > "fdebug-info-for-profiling">, Group, >> > +Flags<[CC1Option]>, >> > +HelpText<"Emit extra debug info to make sample profile more >> > accurate.">; >> > +def fno_debug_info_for_profiling : Flag<["-"], >> > "fno-debug-info-for-profiling">, Group, >> > +Flags<[Driver
[PATCH] D36969: [Basic] Add a DiagnosticOr type
vsk added a comment. Would it be more convenient to extend ErrorInfo instead of creating a new diagnostic wrapper? E.g one benefit of passing around Expected's is that there's some assurance the diagnostics will be reported. Repository: rL LLVM https://reviews.llvm.org/D36969 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36973: [libclang] Add support for querying cursor availability
jklaehn created this revision. jklaehn added a project: clang. This patch allows checking the availability of cursors through libclang and clang.cindex (Python). This e.g. allows to check whether a C++ member function has been marked as deleted. https://reviews.llvm.org/D36973 Files: bindings/python/clang/cindex.py bindings/python/tests/cindex/test_cursor.py Index: bindings/python/tests/cindex/test_cursor.py === --- bindings/python/tests/cindex/test_cursor.py +++ bindings/python/tests/cindex/test_cursor.py @@ -1,6 +1,7 @@ import ctypes import gc +from clang.cindex import AvailabilityKind from clang.cindex import CursorKind from clang.cindex import TemplateArgumentKind from clang.cindex import TranslationUnit @@ -385,6 +386,18 @@ t = foo.result_type assert t.kind == TypeKind.INT +def test_availability(): +tu = get_tu('class A { A(A const&) = delete; };', lang='cpp') +cursors = get_cursors(tu, "A") +for c in cursors: +if c.kind == CursorKind.CLASS_DECL: +assert c.availability == AvailabilityKind.AVAILABLE +if c.kind == CursorKind.CONSTRUCTOR: +assert c.availability == AvailabilityKind.NOT_AVAILABLE +break +else: +assert False, "Could not find cursor for deleted constructor" + def test_get_tokens(): """Ensure we can map cursors back to tokens.""" tu = get_tu('int foo(int i);') Index: bindings/python/clang/cindex.py === --- bindings/python/clang/cindex.py +++ bindings/python/clang/cindex.py @@ -1572,6 +1572,16 @@ return StorageClass.from_id(self._storage_class) +@property +def availability(self): +""" +Retrieves the availability of the entity pointed at by the cursor. +""" +if not hasattr(self, '_availability'): +self._availability = conf.lib.clang_getCursorAvailability(self) + +return AvailabilityKind.from_id(self._availability) + @property def access_specifier(self): """ @@ -1909,6 +1919,25 @@ StorageClass.AUTO = StorageClass(6) StorageClass.REGISTER = StorageClass(7) +### Availability Kinds ### + +class AvailabilityKind(BaseEnumeration): +""" +Describes the availability of an entity. +""" + +# The unique kind objects, indexed by id. +_kinds = [] +_name_map = None + +def __repr__(self): +return 'AvailabilityKind.%s' % (self.name,) + +AvailabilityKind.AVAILABLE = AvailabilityKind(0) +AvailabilityKind.DEPRECATED = AvailabilityKind(1) +AvailabilityKind.NOT_AVAILABLE = AvailabilityKind(2) +AvailabilityKind.NOT_ACCESSIBLE = AvailabilityKind(3) + ### C++ access specifiers ### @@ -3440,6 +3469,10 @@ [TranslationUnit, SourceLocation], Cursor), + ("clang_getCursorAvailability", + [Cursor], + c_int), + ("clang_getCursorDefinition", [Cursor], Cursor, Index: bindings/python/tests/cindex/test_cursor.py === --- bindings/python/tests/cindex/test_cursor.py +++ bindings/python/tests/cindex/test_cursor.py @@ -1,6 +1,7 @@ import ctypes import gc +from clang.cindex import AvailabilityKind from clang.cindex import CursorKind from clang.cindex import TemplateArgumentKind from clang.cindex import TranslationUnit @@ -385,6 +386,18 @@ t = foo.result_type assert t.kind == TypeKind.INT +def test_availability(): +tu = get_tu('class A { A(A const&) = delete; };', lang='cpp') +cursors = get_cursors(tu, "A") +for c in cursors: +if c.kind == CursorKind.CLASS_DECL: +assert c.availability == AvailabilityKind.AVAILABLE +if c.kind == CursorKind.CONSTRUCTOR: +assert c.availability == AvailabilityKind.NOT_AVAILABLE +break +else: +assert False, "Could not find cursor for deleted constructor" + def test_get_tokens(): """Ensure we can map cursors back to tokens.""" tu = get_tu('int foo(int i);') Index: bindings/python/clang/cindex.py === --- bindings/python/clang/cindex.py +++ bindings/python/clang/cindex.py @@ -1572,6 +1572,16 @@ return StorageClass.from_id(self._storage_class) +@property +def availability(self): +""" +Retrieves the availability of the entity pointed at by the cursor. +""" +if not hasattr(self, '_availability'): +self._availability = conf.lib.clang_getCursorAvailability(self) + +return AvailabilityKind.from_id(self._availability) + @property def access_specifier(self): """ @@ -1909,6 +1919,25 @@ StorageClass.AUTO = StorageClass(6) StorageClass.REGISTER = StorageClass(7) +### Availability Kinds ### + +class AvailabilityKind(BaseEnumeration): +""" +Describes the availability of an entity. +"""
[PATCH] D36931: Update LLVM 5.0 release notes for ms_abi and __builtin_ms_va_list for aarch64
This revision was automatically updated to reflect the committed changes. Closed by commit rL311359: Update Clang 5.0 release notes for ms_abi and __builtin_ms_va_list for aarch64 (authored by mstorsjo). Changed prior to commit: https://reviews.llvm.org/D36931?vs=111857&id=112022#toc Repository: rL LLVM https://reviews.llvm.org/D36931 Files: cfe/branches/release_50/docs/ReleaseNotes.rst Index: cfe/branches/release_50/docs/ReleaseNotes.rst === --- cfe/branches/release_50/docs/ReleaseNotes.rst +++ cfe/branches/release_50/docs/ReleaseNotes.rst @@ -104,6 +104,8 @@ - The ``overloadable`` attribute now allows at most one function with a given name to lack the ``overloadable`` attribute. This unmarked function will not have its name mangled. +- The ```ms_abi`` attribute and the ``__builtin_ms_va_list`` types and builtins + are now supported on AArch64. Windows Support --- Index: cfe/branches/release_50/docs/ReleaseNotes.rst === --- cfe/branches/release_50/docs/ReleaseNotes.rst +++ cfe/branches/release_50/docs/ReleaseNotes.rst @@ -104,6 +104,8 @@ - The ``overloadable`` attribute now allows at most one function with a given name to lack the ``overloadable`` attribute. This unmarked function will not have its name mangled. +- The ```ms_abi`` attribute and the ``__builtin_ms_va_list`` types and builtins + are now supported on AArch64. Windows Support --- ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35271: Fix printing policy for AST context loaded from file
vsk added a comment. In https://reviews.llvm.org/D35271#847306, @jklaehn wrote: > In https://reviews.llvm.org/D35271#809159, @vsk wrote: > > > I wonder if it's possible to do away with the calls to 'updated()'... it > > seems strange that we initialize the same preprocessor repeatedly. Is there > > any way to finalize an ASTInfoCollector after ReadAST happens (or > > ASTReaderListeners in general)? > > > I can look into this but would prefer to do so in a different patch, as this > would require refactoring beyond this simple bug fix. Would it be okay to > land this patch as-is? Not having worked on this code I'm afraid I can't say. Usually it's a good idea to include a regression test. https://reviews.llvm.org/D35271 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311365 - Enable libfuzzer on NetBSD/amd64
Author: kamil Date: Mon Aug 21 12:12:14 2017 New Revision: 311365 URL: http://llvm.org/viewvc/llvm-project?rev=311365&view=rev Log: Enable libfuzzer on NetBSD/amd64 Summary: Enable SanitizerKind::Fuzzer and SanitizerKind::FuzzerNoLink on x86_64. Sponsored by Reviewers: joerg, kcc, vitalybuka, george.karpenkov Reviewed By: vitalybuka Subscribers: cfe-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36935 Modified: cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp Modified: cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp?rev=311365&r1=311364&r2=311365&view=diff == --- cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp Mon Aug 21 12:12:14 2017 @@ -428,6 +428,8 @@ SanitizerMask NetBSD::getSupportedSaniti Res |= SanitizerKind::Vptr; } if (IsX86_64) { +Res |= SanitizerKind::Fuzzer; +Res |= SanitizerKind::FuzzerNoLink; Res |= SanitizerKind::Thread; } return Res; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36954: [Sema] Update release notes with details of implicit scalar to vector conversions
hans accepted this revision. hans added a comment. This revision is now accepted and ready to land. lgtm, please commit to the 5.0 branch https://reviews.llvm.org/D36954 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r311330 - Fixed a crash on replaying Preamble's PP conditional stack.
Nikolai suggested this should be merged to 5.0. Richard, what do you think? On Mon, Aug 21, 2017 at 5:03 AM, Ilya Biryukov via cfe-commits wrote: > Author: ibiryukov > Date: Mon Aug 21 05:03:08 2017 > New Revision: 311330 > > URL: http://llvm.org/viewvc/llvm-project?rev=311330&view=rev > Log: > Fixed a crash on replaying Preamble's PP conditional stack. > > Summary: > The crash occurs when the first token after a preamble is a macro > expansion. > Fixed by moving replayPreambleConditionalStack from Parser into > Preprocessor. It is now called right after the predefines file is > processed. > > Reviewers: erikjv, bkramer, klimek, yvvan > > Reviewed By: bkramer > > Subscribers: cfe-commits > > Differential Revision: https://reviews.llvm.org/D36872 > > Added: > cfe/trunk/test/Index/preamble-conditionals-crash.cpp > cfe/trunk/test/Index/preamble-conditionals.cpp > Modified: > cfe/trunk/include/clang/Lex/Preprocessor.h > cfe/trunk/lib/Lex/PPLexerChange.cpp > cfe/trunk/lib/Lex/Preprocessor.cpp > cfe/trunk/lib/Parse/Parser.cpp > > Modified: cfe/trunk/include/clang/Lex/Preprocessor.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=311330&r1=311329&r2=311330&view=diff > == > --- cfe/trunk/include/clang/Lex/Preprocessor.h (original) > +++ cfe/trunk/include/clang/Lex/Preprocessor.h Mon Aug 21 05:03:08 2017 > @@ -1049,10 +1049,6 @@ public: >/// which implicitly adds the builtin defines etc. >void EnterMainSourceFile(); > > - /// \brief After parser warm-up, initialize the conditional stack from > - /// the preamble. > - void replayPreambleConditionalStack(); > - >/// \brief Inform the preprocessor callbacks that processing is complete. >void EndSourceFile(); > > @@ -2026,6 +2022,10 @@ public: >} > > private: > + /// \brief After processing predefined file, initialize the conditional > stack from > + /// the preamble. > + void replayPreambleConditionalStack(); > + >// Macro handling. >void HandleDefineDirective(Token &Tok, bool > ImmediatelyAfterTopLevelIfndef); >void HandleUndefDirective(); > > Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=311330&r1=311329&r2=311330&view=diff > == > --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original) > +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Mon Aug 21 05:03:08 2017 > @@ -458,10 +458,16 @@ bool Preprocessor::HandleEndOfFile(Token >SourceMgr.setNumCreatedFIDsForFileID(CurPPLexer->getFileID(), NumFIDs); > } > > +bool ExitedFromPredefinesFile = false; > FileID ExitedFID; > -if (Callbacks && !isEndOfMacro && CurPPLexer) > +if (!isEndOfMacro && CurPPLexer) { >ExitedFID = CurPPLexer->getFileID(); > > + assert(PredefinesFileID.isValid() && > + "HandleEndOfFile is called before PredefinesFileId is set"); > + ExitedFromPredefinesFile = (PredefinesFileID == ExitedFID); > +} > + > if (LeavingSubmodule) { >// We're done with this submodule. >Module *M = LeaveSubmodule(/*ForPragma*/false); > @@ -489,6 +495,11 @@ bool Preprocessor::HandleEndOfFile(Token > PPCallbacks::ExitFile, FileType, ExitedFID); > } > > +// Restore conditional stack from the preamble right after exiting from > the > +// predefines file. > +if (ExitedFromPredefinesFile) > + replayPreambleConditionalStack(); > + > // Client should lex another token unless we generated an EOM. > return LeavingSubmodule; >} > > Modified: cfe/trunk/lib/Lex/Preprocessor.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=311330&r1=311329&r2=311330&view=diff > == > --- cfe/trunk/lib/Lex/Preprocessor.cpp (original) > +++ cfe/trunk/lib/Lex/Preprocessor.cpp Mon Aug 21 05:03:08 2017 > @@ -540,6 +540,8 @@ void Preprocessor::EnterMainSourceFile() > void Preprocessor::replayPreambleConditionalStack() { >// Restore the conditional stack from the preamble, if there is one. >if (PreambleConditionalStack.isReplaying()) { > +assert(CurPPLexer && > + "CurPPLexer is null when calling > replayPreambleConditionalStack."); > CurPPLexer->setConditionalLevels(PreambleConditionalStack.getStack()); > PreambleConditionalStack.doneReplaying(); >} > > Modified: cfe/trunk/lib/Parse/Parser.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=311330&r1=311329&r2=311330&view=diff > == > --- cfe/trunk/lib/Parse/Parser.cpp (original) > +++ cfe/trunk/lib/Parse/Parser.cpp Mon Aug 21 05:03:08 2017 > @@ -516,8 +516,6 @@ void Parser::Initia
[PATCH] D36872: Fixed a crash on replaying Preamble's PP conditional stack.
hans added a comment. In https://reviews.llvm.org/D36872#847416, @nik wrote: > I see this in trunk/master submitted, but not in the release_50 branch. Could > this be cherry-picked to 5.0? I've replied on the commit message thread. Thanks! Repository: rL LLVM https://reviews.llvm.org/D36872 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r311182 - [analyzer] Fix modeling of constructors
I'm ok with it if Anna approves. On Mon, Aug 21, 2017 at 9:06 AM, Artem Dergachev wrote: > Hello, > > Do we have time to merge this change into release 5.0.0? It's an assertion > failure fix, which shows up on C++ code involving double-inheritance with > empty base classes. > > Artem. > > > On 8/18/17 9:20 PM, Alexander Shaposhnikov via cfe-commits wrote: >> >> Author: alexshap >> Date: Fri Aug 18 11:20:43 2017 >> New Revision: 311182 >> >> URL:http://llvm.org/viewvc/llvm-project?rev=311182&view=rev >> Log: >> [analyzer] Fix modeling of constructors >> >> This diff fixes analyzer's crash (triggered assert) on the newly added >> test case. >> The assert being discussed is assert(!B.lookup(R, BindingKey::Direct)) >> in lib/StaticAnalyzer/Core/RegionStore.cpp, however the root cause is >> different. >> For classes with empty bases the offsets might be tricky. >> For example, let's assume we have >> struct S: NonEmptyBase, EmptyBase { >> ... >> }; >> In this case Clang applies empty base class optimization and >> the offset of EmptyBase will be 0, it can be verified via >> clang -cc1 -x c++ -v -fdump-record-layouts main.cpp -emit-llvm -o >> /dev/null. >> When the analyzer tries to perform zero initialization of EmptyBase >> it will hit the assert because that region >> has already been "written" by the constructor of NonEmptyBase. >> >> Test plan: >> make check-all >> >> Differential revision:https://reviews.llvm.org/D36851 >> >> Modified: >> cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp >> cfe/trunk/test/Analysis/ctor.mm >> >> Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp >> >> URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=311182&r1=311181&r2=311182&view=diff >> >> == >> --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original) >> +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Fri Aug 18 11:20:43 >> 2017 >> @@ -409,6 +409,19 @@ public: // Part of public interface to c >> // BindDefault is only used to initialize a region with a default >> value. >> StoreRef BindDefault(Store store, const MemRegion *R, SVal V) override >> { >> +// FIXME: The offsets of empty bases can be tricky because of >> +// of the so called "empty base class optimization". >> +// If a base class has been optimized out >> +// we should not try to create a binding, otherwise we should. >> +// Unfortunately, at the moment ASTRecordLayout doesn't expose >> +// the actual sizes of the empty bases >> +// and trying to infer them from offsets/alignments >> +// seems to be error-prone and non-trivial because of the trailing >> padding. >> +// As a temporary mitigation we don't create bindings for empty >> bases. >> +if (R->getKind() == MemRegion::CXXBaseObjectRegionKind && >> +cast(R)->getDecl()->isEmpty()) >> + return StoreRef(store, *this); >> + >> RegionBindingsRef B = getRegionBindings(store); >> assert(!B.lookup(R, BindingKey::Direct)); >> >> Modified: cfe/trunk/test/Analysis/ctor.mm >> >> URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ctor.mm?rev=311182&r1=311181&r2=311182&view=diff >> >> == >> --- cfe/trunk/test/Analysis/ctor.mm (original) >> +++ cfe/trunk/test/Analysis/ctor.mm Fri Aug 18 11:20:43 2017 >> @@ -704,3 +704,20 @@ namespace PR19579 { >> }; >> } >> } >> + >> +namespace NoCrashOnEmptyBaseOptimization { >> + struct NonEmptyBase { >> +int X; >> +explicit NonEmptyBase(int X) : X(X) {} >> + }; >> + >> + struct EmptyBase {}; >> + >> + struct S : NonEmptyBase, EmptyBase { >> +S() : NonEmptyBase(0), EmptyBase() {} >> + }; >> + >> + void testSCtorNoCrash() { >> +S s; >> + } >> +} >> >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36347: Add new script to launch lldb and set breakpoints for diagnostics all diagnostics seen.
hintonda added a comment. ping... https://reviews.llvm.org/D36347 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r311182 - [analyzer] Fix modeling of constructors
I approve.Thanks Hans! Anna > On Aug 21, 2017, at 1:05 PM, Hans Wennborg wrote: > > I'm ok with it if Anna approves. > > On Mon, Aug 21, 2017 at 9:06 AM, Artem Dergachev wrote: >> Hello, >> >> Do we have time to merge this change into release 5.0.0? It's an assertion >> failure fix, which shows up on C++ code involving double-inheritance with >> empty base classes. >> >> Artem. >> >> >> On 8/18/17 9:20 PM, Alexander Shaposhnikov via cfe-commits wrote: >>> >>> Author: alexshap >>> Date: Fri Aug 18 11:20:43 2017 >>> New Revision: 311182 >>> >>> URL:http://llvm.org/viewvc/llvm-project?rev=311182&view=rev >>> Log: >>> [analyzer] Fix modeling of constructors >>> >>> This diff fixes analyzer's crash (triggered assert) on the newly added >>> test case. >>> The assert being discussed is assert(!B.lookup(R, BindingKey::Direct)) >>> in lib/StaticAnalyzer/Core/RegionStore.cpp, however the root cause is >>> different. >>> For classes with empty bases the offsets might be tricky. >>> For example, let's assume we have >>> struct S: NonEmptyBase, EmptyBase { >>> ... >>> }; >>> In this case Clang applies empty base class optimization and >>> the offset of EmptyBase will be 0, it can be verified via >>> clang -cc1 -x c++ -v -fdump-record-layouts main.cpp -emit-llvm -o >>> /dev/null. >>> When the analyzer tries to perform zero initialization of EmptyBase >>> it will hit the assert because that region >>> has already been "written" by the constructor of NonEmptyBase. >>> >>> Test plan: >>> make check-all >>> >>> Differential revision:https://reviews.llvm.org/D36851 >>> >>> Modified: >>> cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp >>> cfe/trunk/test/Analysis/ctor.mm >>> >>> Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp >>> >>> URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=311182&r1=311181&r2=311182&view=diff >>> >>> == >>> --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original) >>> +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Fri Aug 18 11:20:43 >>> 2017 >>> @@ -409,6 +409,19 @@ public: // Part of public interface to c >>> // BindDefault is only used to initialize a region with a default >>> value. >>>StoreRef BindDefault(Store store, const MemRegion *R, SVal V) override >>> { >>> +// FIXME: The offsets of empty bases can be tricky because of >>> +// of the so called "empty base class optimization". >>> +// If a base class has been optimized out >>> +// we should not try to create a binding, otherwise we should. >>> +// Unfortunately, at the moment ASTRecordLayout doesn't expose >>> +// the actual sizes of the empty bases >>> +// and trying to infer them from offsets/alignments >>> +// seems to be error-prone and non-trivial because of the trailing >>> padding. >>> +// As a temporary mitigation we don't create bindings for empty >>> bases. >>> +if (R->getKind() == MemRegion::CXXBaseObjectRegionKind && >>> +cast(R)->getDecl()->isEmpty()) >>> + return StoreRef(store, *this); >>> + >>> RegionBindingsRef B = getRegionBindings(store); >>> assert(!B.lookup(R, BindingKey::Direct)); >>> >>> Modified: cfe/trunk/test/Analysis/ctor.mm >>> >>> URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ctor.mm?rev=311182&r1=311181&r2=311182&view=diff >>> >>> == >>> --- cfe/trunk/test/Analysis/ctor.mm (original) >>> +++ cfe/trunk/test/Analysis/ctor.mm Fri Aug 18 11:20:43 2017 >>> @@ -704,3 +704,20 @@ namespace PR19579 { >>> }; >>>} >>> } >>> + >>> +namespace NoCrashOnEmptyBaseOptimization { >>> + struct NonEmptyBase { >>> +int X; >>> +explicit NonEmptyBase(int X) : X(X) {} >>> + }; >>> + >>> + struct EmptyBase {}; >>> + >>> + struct S : NonEmptyBase, EmptyBase { >>> +S() : NonEmptyBase(0), EmptyBase() {} >>> + }; >>> + >>> + void testSCtorNoCrash() { >>> +S s; >>> + } >>> +} >>> >>> >>> ___ >>> cfe-commits mailing list >>> cfe-commits@lists.llvm.org >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> >> ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36806: Switch to cantFail(), since it does the same assertion.
srhines added a comment. Ping. https://reviews.llvm.org/D36806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r311182 - [analyzer] Fix modeling of constructors
Merged in r311378. Thanks, Hans On Mon, Aug 21, 2017 at 1:12 PM, Anna Zaks wrote: > I approve.Thanks Hans! > Anna >> On Aug 21, 2017, at 1:05 PM, Hans Wennborg wrote: >> >> I'm ok with it if Anna approves. >> >> On Mon, Aug 21, 2017 at 9:06 AM, Artem Dergachev wrote: >>> Hello, >>> >>> Do we have time to merge this change into release 5.0.0? It's an assertion >>> failure fix, which shows up on C++ code involving double-inheritance with >>> empty base classes. >>> >>> Artem. >>> >>> >>> On 8/18/17 9:20 PM, Alexander Shaposhnikov via cfe-commits wrote: Author: alexshap Date: Fri Aug 18 11:20:43 2017 New Revision: 311182 URL:http://llvm.org/viewvc/llvm-project?rev=311182&view=rev Log: [analyzer] Fix modeling of constructors This diff fixes analyzer's crash (triggered assert) on the newly added test case. The assert being discussed is assert(!B.lookup(R, BindingKey::Direct)) in lib/StaticAnalyzer/Core/RegionStore.cpp, however the root cause is different. For classes with empty bases the offsets might be tricky. For example, let's assume we have struct S: NonEmptyBase, EmptyBase { ... }; In this case Clang applies empty base class optimization and the offset of EmptyBase will be 0, it can be verified via clang -cc1 -x c++ -v -fdump-record-layouts main.cpp -emit-llvm -o /dev/null. When the analyzer tries to perform zero initialization of EmptyBase it will hit the assert because that region has already been "written" by the constructor of NonEmptyBase. Test plan: make check-all Differential revision:https://reviews.llvm.org/D36851 Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp cfe/trunk/test/Analysis/ctor.mm Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=311182&r1=311181&r2=311182&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Fri Aug 18 11:20:43 2017 @@ -409,6 +409,19 @@ public: // Part of public interface to c // BindDefault is only used to initialize a region with a default value. StoreRef BindDefault(Store store, const MemRegion *R, SVal V) override { +// FIXME: The offsets of empty bases can be tricky because of +// of the so called "empty base class optimization". +// If a base class has been optimized out +// we should not try to create a binding, otherwise we should. +// Unfortunately, at the moment ASTRecordLayout doesn't expose +// the actual sizes of the empty bases +// and trying to infer them from offsets/alignments +// seems to be error-prone and non-trivial because of the trailing padding. +// As a temporary mitigation we don't create bindings for empty bases. +if (R->getKind() == MemRegion::CXXBaseObjectRegionKind && +cast(R)->getDecl()->isEmpty()) + return StoreRef(store, *this); + RegionBindingsRef B = getRegionBindings(store); assert(!B.lookup(R, BindingKey::Direct)); Modified: cfe/trunk/test/Analysis/ctor.mm URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ctor.mm?rev=311182&r1=311181&r2=311182&view=diff == --- cfe/trunk/test/Analysis/ctor.mm (original) +++ cfe/trunk/test/Analysis/ctor.mm Fri Aug 18 11:20:43 2017 @@ -704,3 +704,20 @@ namespace PR19579 { }; } } + +namespace NoCrashOnEmptyBaseOptimization { + struct NonEmptyBase { +int X; +explicit NonEmptyBase(int X) : X(X) {} + }; + + struct EmptyBase {}; + + struct S : NonEmptyBase, EmptyBase { +S() : NonEmptyBase(0), EmptyBase() {} + }; + + void testSCtorNoCrash() { +S s; + } +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >>> >>> > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36806: Switch to cantFail(), since it does the same assertion.
hintonda added inline comments. Comment at: lib/Tooling/Core/Replacement.cpp:505 -assert(!Err && - "Replacements must not conflict since ranges have been merged."); -llvm::consumeError(std::move(Err)); While obviously correct, are you concerned that by removing the explanatory text, this change will obscure the reason for the assert? https://reviews.llvm.org/D36806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36806: Switch to cantFail(), since it does the same assertion.
srhines marked an inline comment as done. srhines added inline comments. Comment at: lib/Tooling/Core/Replacement.cpp:505 -assert(!Err && - "Replacements must not conflict since ranges have been merged."); -llvm::consumeError(std::move(Err)); hintonda wrote: > While obviously correct, are you concerned that by removing the explanatory > text, this change will obscure the reason for the assert? The text is now in a comment above the call. https://reviews.llvm.org/D36806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r311182 - [analyzer] Fix modeling of constructors
Thanks! On Mon, Aug 21, 2017 at 1:28 PM, Hans Wennborg via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Merged in r311378. > > Thanks, > Hans > > On Mon, Aug 21, 2017 at 1:12 PM, Anna Zaks wrote: > > I approve.Thanks Hans! > > Anna > >> On Aug 21, 2017, at 1:05 PM, Hans Wennborg wrote: > >> > >> I'm ok with it if Anna approves. > >> > >> On Mon, Aug 21, 2017 at 9:06 AM, Artem Dergachev > wrote: > >>> Hello, > >>> > >>> Do we have time to merge this change into release 5.0.0? It's an > assertion > >>> failure fix, which shows up on C++ code involving double-inheritance > with > >>> empty base classes. > >>> > >>> Artem. > >>> > >>> > >>> On 8/18/17 9:20 PM, Alexander Shaposhnikov via cfe-commits wrote: > > Author: alexshap > Date: Fri Aug 18 11:20:43 2017 > New Revision: 311182 > > URL:http://llvm.org/viewvc/llvm-project?rev=311182&view=rev > Log: > [analyzer] Fix modeling of constructors > > This diff fixes analyzer's crash (triggered assert) on the newly added > test case. > The assert being discussed is assert(!B.lookup(R, BindingKey::Direct)) > in lib/StaticAnalyzer/Core/RegionStore.cpp, however the root cause is > different. > For classes with empty bases the offsets might be tricky. > For example, let's assume we have > struct S: NonEmptyBase, EmptyBase { > ... > }; > In this case Clang applies empty base class optimization and > the offset of EmptyBase will be 0, it can be verified via > clang -cc1 -x c++ -v -fdump-record-layouts main.cpp -emit-llvm -o > /dev/null. > When the analyzer tries to perform zero initialization of EmptyBase > it will hit the assert because that region > has already been "written" by the constructor of NonEmptyBase. > > Test plan: > make check-all > > Differential revision:https://reviews.llvm.org/D36851 > > Modified: > cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp > cfe/trunk/test/Analysis/ctor.mm > > Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp > > URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ > StaticAnalyzer/Core/RegionStore.cpp?rev=311182&r1= > 311181&r2=311182&view=diff > > > == > --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original) > +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Fri Aug 18 > 11:20:43 > 2017 > @@ -409,6 +409,19 @@ public: // Part of public interface to c > // BindDefault is only used to initialize a region with a default > value. > StoreRef BindDefault(Store store, const MemRegion *R, SVal V) > override > { > +// FIXME: The offsets of empty bases can be tricky because of > +// of the so called "empty base class optimization". > +// If a base class has been optimized out > +// we should not try to create a binding, otherwise we should. > +// Unfortunately, at the moment ASTRecordLayout doesn't expose > +// the actual sizes of the empty bases > +// and trying to infer them from offsets/alignments > +// seems to be error-prone and non-trivial because of the > trailing > padding. > +// As a temporary mitigation we don't create bindings for empty > bases. > +if (R->getKind() == MemRegion::CXXBaseObjectRegionKind && > +cast(R)->getDecl()->isEmpty()) > + return StoreRef(store, *this); > + > RegionBindingsRef B = getRegionBindings(store); > assert(!B.lookup(R, BindingKey::Direct)); > > Modified: cfe/trunk/test/Analysis/ctor.mm > > URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ > Analysis/ctor.mm?rev=311182&r1=311181&r2=311182&view=diff > > > == > --- cfe/trunk/test/Analysis/ctor.mm (original) > +++ cfe/trunk/test/Analysis/ctor.mm Fri Aug 18 11:20:43 2017 > @@ -704,3 +704,20 @@ namespace PR19579 { > }; > } > } > + > +namespace NoCrashOnEmptyBaseOptimization { > + struct NonEmptyBase { > +int X; > +explicit NonEmptyBase(int X) : X(X) {} > + }; > + > + struct EmptyBase {}; > + > + struct S : NonEmptyBase, EmptyBase { > +S() : NonEmptyBase(0), EmptyBase() {} > + }; > + > + void testSCtorNoCrash() { > +S s; > + } > +} > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > >>> > >>> > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin
[PATCH] D36806: Switch to cantFail(), since it does the same assertion.
hintonda added inline comments. Comment at: lib/Tooling/Core/Replacement.cpp:505 -assert(!Err && - "Replacements must not conflict since ranges have been merged."); -llvm::consumeError(std::move(Err)); srhines wrote: > hintonda wrote: > > While obviously correct, are you concerned that by removing the explanatory > > text, this change will obscure the reason for the assert? > The text is now in a comment above the call. Well, that's what I mean. The reason is no longer in the backtrace. https://reviews.llvm.org/D36806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311391 - [Driver] Recognize DevDiv internal builds of MSVC, with a different directory structure.
Author: stl_msft Date: Mon Aug 21 15:19:33 2017 New Revision: 311391 URL: http://llvm.org/viewvc/llvm-project?rev=311391&view=rev Log: [Driver] Recognize DevDiv internal builds of MSVC, with a different directory structure. This is a reasonably non-intrusive change, which I've verified works for both x86 and x64 DevDiv-internal builds. The idea is to change `bool IsVS2017OrNewer` into a 3-state `ToolsetLayout VSLayout`. Either a build is DevDiv-internal, released VS 2017 or newer, or released VS 2015 or older. When looking at the directory structure, if instead of `"VC"` we see `"x86ret"`, `"x86chk"`, `"amd64ret"`, or `"amd64chk"`, we recognize this as a DevDiv-internal build. After we get past the directory structure validation, we use this knowledge to regenerate paths appropriately. `llvmArchToDevDivInternalArch()` knows how we use `"i386"` subdirectories, and `MSVCToolChain::getSubDirectoryPath()` uses that. It also knows that DevDiv-internal builds have an `"inc"` subdirectory instead of `"include"`. This may still not be the "right" fix in any sense, but I believe that it's non-intrusive in the sense that if the special directory names aren't found, no codepaths are affected. (`ToolsetLayout::OlderVS` and `ToolsetLayout::VS2017OrNewer` correspond to `IsVS2017OrNewer` being `false` or `true`, respectively.) I searched for all references to `IsVS2017OrNewer`, which are places where Clang cares about VS's directory structure, and the only one that isn't being patched is some logic to deal with cross-compilation. I'm fine with that not working for DevDiv-internal builds for the moment (we typically test the native compilers), so I added a comment. Fixes D36860. Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp cfe/trunk/lib/Driver/ToolChains/MSVC.h Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=311391&r1=311390&r2=311391&view=diff == --- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Mon Aug 21 15:19:33 2017 @@ -76,7 +76,7 @@ static bool getSystemRegistryString(cons // Check various environment variables to try and find a toolchain. static bool findVCToolChainViaEnvironment(std::string &Path, - bool &IsVS2017OrNewer) { + MSVCToolChain::ToolsetLayout &VSLayout) { // These variables are typically set by vcvarsall.bat // when launching a developer command prompt. if (llvm::Optional VCToolsInstallDir = @@ -84,7 +84,7 @@ static bool findVCToolChainViaEnvironmen // This is only set by newer Visual Studios, and it leads straight to // the toolchain directory. Path = std::move(*VCToolsInstallDir); -IsVS2017OrNewer = true; +VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer; return true; } if (llvm::Optional VCInstallDir = @@ -94,7 +94,7 @@ static bool findVCToolChainViaEnvironmen // so this check has to appear second. // In older Visual Studios, the VC directory is the toolchain. Path = std::move(*VCInstallDir); -IsVS2017OrNewer = false; +VSLayout = MSVCToolChain::ToolsetLayout::OlderVS; return true; } @@ -134,9 +134,16 @@ static bool findVCToolChainViaEnvironmen } if (IsBin) { llvm::StringRef ParentPath = llvm::sys::path::parent_path(TestPath); -if (llvm::sys::path::filename(ParentPath) == "VC") { +llvm::StringRef ParentFilename = llvm::sys::path::filename(ParentPath); +if (ParentFilename == "VC") { Path = ParentPath; - IsVS2017OrNewer = false; + VSLayout = MSVCToolChain::ToolsetLayout::OlderVS; + return true; +} +if (ParentFilename == "x86ret" || ParentFilename == "x86chk" + || ParentFilename == "amd64ret" || ParentFilename == "amd64chk") { + Path = ParentPath; + VSLayout = MSVCToolChain::ToolsetLayout::DevDivInternal; return true; } @@ -165,7 +172,7 @@ static bool findVCToolChainViaEnvironmen ToolChainPath = llvm::sys::path::parent_path(ToolChainPath); Path = ToolChainPath; -IsVS2017OrNewer = true; +VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer; return true; } @@ -181,7 +188,7 @@ static bool findVCToolChainViaEnvironmen // This is the preferred way to discover new Visual Studios, as they're no // longer listed in the registry. static bool findVCToolChainViaSetupConfig(std::string &Path, - bool &IsVS2017OrNewer) { + MSVCToolChain::ToolsetLayout &VSLayout) { #if !defined(USE_MSVC_SETUP_API) return false; #else @@ -263,7 +270,7 @@ static bool findVCToolChainViaSetupConfi return false; Path = ToolchainPath.st
[PATCH] D36853: [Parser] Correct initalizer typos before lambda capture type is deduced.
vsapsai added a comment. Thanks for review, Alex. I've requested commit access and plan to commit the change myself to make sure everything works as expected. https://reviews.llvm.org/D36853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311397 - [Driver][Darwin] Do not pass -munwind-table if -fno-excpetions is
Author: ahatanak Date: Mon Aug 21 15:46:46 2017 New Revision: 311397 URL: http://llvm.org/viewvc/llvm-project?rev=311397&view=rev Log: [Driver][Darwin] Do not pass -munwind-table if -fno-excpetions is supplied. With this change, -fno-exceptions disables unwind tables unless -funwind-tables is supplied too or the target is x86-64 (x86-64 requires emitting unwind tables). rdar://problem/33934446 Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp cfe/trunk/test/Driver/clang-translation.c Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=311397&r1=311396&r2=311397&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Mon Aug 21 15:46:46 2017 @@ -1845,7 +1845,12 @@ Darwin::TranslateArgs(const DerivedArgLi } bool MachO::IsUnwindTablesDefault(const ArgList &Args) const { - return !UseSjLjExceptions(Args); + // Unwind tables are not emitted if -fno-exceptions is supplied (except when + // targeting x86_64). + return getArch() == llvm::Triple::x86_64 || + (!UseSjLjExceptions(Args) && + Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, + true)); } bool MachO::UseDwarfDebugFlags() const { Modified: cfe/trunk/test/Driver/clang-translation.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-translation.c?rev=311397&r1=311396&r2=311397&view=diff == --- cfe/trunk/test/Driver/clang-translation.c (original) +++ cfe/trunk/test/Driver/clang-translation.c Mon Aug 21 15:46:46 2017 @@ -73,6 +73,10 @@ // RUN: FileCheck -check-prefix=ARM64-APPLE %s // ARM64-APPLE: -munwind-table +// RUN: %clang -target arm64-apple-ios10 -fno-exceptions -### -S %s -arch arm64 2>&1 | \ +// RUN: FileCheck -check-prefix=ARM64-APPLE-EXCEP %s +// ARM64-APPLE-EXCEP-NOT: -munwind-table + // RUN: %clang -target armv7k-apple-watchos4.0 -### -S %s -arch armv7k 2>&1 | \ // RUN: FileCheck -check-prefix=ARMV7K-APPLE %s // ARMV7K-APPLE: -munwind-table ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36989: [clang-diff] Refactor stop-after command-line flag
jgravelle-google created this revision. Herald added subscribers: aheejin, klimek. Rename stop-after to stop-after-topdown. When building LLVM with -DLLVM_BUILD_LLVM_DYLIB=ON, stop-after collides with the stop-after already present in LLVM. This also refactors the flag to a boolean, to reflect that it can only be in two states. https://reviews.llvm.org/D36989 Files: lib/Tooling/ASTDiff/ASTDiff.cpp test/Tooling/clang-diff-topdown.cpp tools/clang-diff/ClangDiff.cpp Index: tools/clang-diff/ClangDiff.cpp === --- tools/clang-diff/ClangDiff.cpp +++ tools/clang-diff/ClangDiff.cpp @@ -21,7 +21,7 @@ using namespace clang; using namespace clang::tooling; -static cl::OptionCategory ClangDiffCategory("clang-diff options"); +cl::OptionCategory ClangDiffCategory("clang-diff options"); static cl::opt ASTDump("ast-dump", @@ -50,11 +50,6 @@ cl::Optional, cl::cat(ClangDiffCategory)); -static cl::opt StopAfter("stop-after", - cl::desc(""), - cl::Optional, cl::init(""), - cl::cat(ClangDiffCategory)); - static cl::opt MaxSize("s", cl::desc(""), cl::Optional, cl::init(-1), cl::cat(ClangDiffCategory)); @@ -442,14 +437,6 @@ diff::ComparisonOptions Options; if (MaxSize != -1) Options.MaxSize = MaxSize; - if (!StopAfter.empty()) { -if (StopAfter == "topdown") - Options.StopAfterTopDown = true; -else if (StopAfter != "bottomup") { - llvm::errs() << "Error: Invalid argument for -stop-after\n"; - return 1; -} - } diff::SyntaxTree SrcTree(Src->getASTContext()); diff::SyntaxTree DstTree(Dst->getASTContext()); diff::ASTDiff Diff(SrcTree, DstTree, Options); Index: test/Tooling/clang-diff-topdown.cpp === --- test/Tooling/clang-diff-topdown.cpp +++ test/Tooling/clang-diff-topdown.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -E %s > %t.src.cpp // RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST -// RUN: clang-diff -dump-matches -stop-after=topdown %t.src.cpp %t.dst.cpp -- -std=c++11 | FileCheck %s +// RUN: clang-diff -dump-matches -stop-after-topdown %t.src.cpp %t.dst.cpp -- -std=c++11 | FileCheck %s // // Test the top-down matching of identical subtrees only. Index: lib/Tooling/ASTDiff/ASTDiff.cpp === --- lib/Tooling/ASTDiff/ASTDiff.cpp +++ lib/Tooling/ASTDiff/ASTDiff.cpp @@ -16,14 +16,21 @@ #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Lex/Lexer.h" #include "llvm/ADT/PriorityQueue.h" +#include "llvm/Support/CommandLine.h" #include #include #include using namespace llvm; using namespace clang; +extern cl::OptionCategory ClangDiffCategory; +static cl::opt StopAfterTopDown("stop-after-topdown", + cl::desc("Stops after top-down matching"), + cl::Optional, cl::init(false), + cl::cat(ClangDiffCategory)); + namespace clang { namespace diff { @@ -891,7 +898,7 @@ void ASTDiff::Impl::computeMapping() { TheMapping = matchTopDown(); - if (Options.StopAfterTopDown) + if (StopAfterTopDown) return; matchBottomUp(TheMapping); } Index: tools/clang-diff/ClangDiff.cpp === --- tools/clang-diff/ClangDiff.cpp +++ tools/clang-diff/ClangDiff.cpp @@ -21,7 +21,7 @@ using namespace clang; using namespace clang::tooling; -static cl::OptionCategory ClangDiffCategory("clang-diff options"); +cl::OptionCategory ClangDiffCategory("clang-diff options"); static cl::opt ASTDump("ast-dump", @@ -50,11 +50,6 @@ cl::Optional, cl::cat(ClangDiffCategory)); -static cl::opt StopAfter("stop-after", - cl::desc(""), - cl::Optional, cl::init(""), - cl::cat(ClangDiffCategory)); - static cl::opt MaxSize("s", cl::desc(""), cl::Optional, cl::init(-1), cl::cat(ClangDiffCategory)); @@ -442,14 +437,6 @@ diff::ComparisonOptions Options; if (MaxSize != -1) Options.MaxSize = MaxSize; - if (!StopAfter.empty()) { -if (StopAfter == "topdown") - Options.StopAfterTopDown = true; -else if (StopAfter != "bottomup") { - llvm::errs() << "Error: Invalid argument for -stop-after\n"; - return 1; -} - } diff::SyntaxTree SrcTree(Src->getASTContext()); diff::SyntaxTree DstTree(Dst->getASTContext()); diff::ASTDiff Diff(SrcTree, DstTree, Options); Index: test/Tooling/clang-diff-topdown.cpp ==
Re: r310983 - PR19668, PR23034: Fix handling of move constructors and deleted copy
PR19668 was marked as a release blocker. Is this suitable for merging? On Tue, Aug 15, 2017 at 6:49 PM, Richard Smith via cfe-commits wrote: > Author: rsmith > Date: Tue Aug 15 18:49:53 2017 > New Revision: 310983 > > URL: http://llvm.org/viewvc/llvm-project?rev=310983&view=rev > Log: > PR19668, PR23034: Fix handling of move constructors and deleted copy > constructors when deciding whether classes should be passed indirectly. > > This fixes ABI differences between Clang and GCC: > > * Previously, Clang ignored the move constructor when making this >determination. It now takes the move constructor into account, per >https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may >seem recent, but the ABI change was agreed on the Itanium C++ ABI >list a long time ago). > > * Previously, Clang's behavior when the copy constructor was deleted >was unstable -- depending on whether the lazy declaration of the >copy constructor had been triggered, you might get different behavior. >We now eagerly declare the copy constructor whenever its deletedness >is unclear, and ignore deleted copy/move constructors when looking for >a trivial such constructor. > > This also fixes an ABI difference between Clang and MSVC: > > * If the copy constructor would be implicitly deleted (but has not been >lazily declared yet), for instance because the class has an rvalue >reference member, we would pass it directly. We now pass such a class >indirectly, matching MSVC. > > Based on a patch by Vassil Vassilev, which was based on a patch by Bernd > Schmidt, which was based on a patch by Reid Kleckner! > > This is a re-commit of r310401, which was reverted in r310464 due to ARM > failures (which should now be fixed). > > Modified: > cfe/trunk/include/clang/AST/DeclCXX.h > cfe/trunk/lib/AST/ASTImporter.cpp > cfe/trunk/lib/AST/DeclCXX.cpp > cfe/trunk/lib/CodeGen/CGCXXABI.cpp > cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp > cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp > cfe/trunk/lib/Sema/SemaDeclCXX.cpp > cfe/trunk/lib/Serialization/ASTReaderDecl.cpp > cfe/trunk/lib/Serialization/ASTWriter.cpp > cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp > cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp > > Modified: cfe/trunk/include/clang/AST/DeclCXX.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310983&r1=310982&r2=310983&view=diff > == > --- cfe/trunk/include/clang/AST/DeclCXX.h (original) > +++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug 15 18:49:53 2017 > @@ -374,6 +374,7 @@ class CXXRecordDecl : public RecordDecl > /// \brief These flags are \c true if a defaulted corresponding special > /// member can't be fully analyzed without performing overload > resolution. > /// @{ > +unsigned NeedOverloadResolutionForCopyConstructor : 1; > unsigned NeedOverloadResolutionForMoveConstructor : 1; > unsigned NeedOverloadResolutionForMoveAssignment : 1; > unsigned NeedOverloadResolutionForDestructor : 1; > @@ -382,6 +383,7 @@ class CXXRecordDecl : public RecordDecl > /// \brief These flags are \c true if an implicit defaulted corresponding > /// special member would be defined as deleted. > /// @{ > +unsigned DefaultedCopyConstructorIsDeleted : 1; > unsigned DefaultedMoveConstructorIsDeleted : 1; > unsigned DefaultedMoveAssignmentIsDeleted : 1; > unsigned DefaultedDestructorIsDeleted : 1; > @@ -414,6 +416,12 @@ class CXXRecordDecl : public RecordDecl > /// constructor. > unsigned HasDefaultedDefaultConstructor : 1; > > +/// \brief True if this class can be passed in a non-address-preserving > +/// fashion (such as in registers) according to the C++ language rules. > +/// This does not imply anything about how the ABI in use will actually > +/// pass an object of this class. > +unsigned CanPassInRegisters : 1; > + > /// \brief True if a defaulted default constructor for this class would > /// be constexpr. > unsigned DefaultedDefaultConstructorIsConstexpr : 1; > @@ -810,18 +818,50 @@ public: > return data().FirstFriend.isValid(); >} > > + /// \brief \c true if a defaulted copy constructor for this class would be > + /// deleted. > + bool defaultedCopyConstructorIsDeleted() const { > +assert((!needsOverloadResolutionForCopyConstructor() || > +(data().DeclaredSpecialMembers & SMF_CopyConstructor)) && > + "this property has not yet been computed by Sema"); > +return data().DefaultedCopyConstructorIsDeleted; > + } > + > + /// \brief \c true if a defaulted move constructor for this class would be > + /// deleted. > + bool defaultedMoveConstructorIsDeleted() const { > +assert((!needsOverloadResolutionForMoveConstructor() || > +(data().DeclaredSpecialMembers & SMF_MoveCon
Re: r310983 - PR19668, PR23034: Fix handling of move constructors and deleted copy
Yes, I'd very much like to get this into the upcoming release. On 21 August 2017 at 16:16, Hans Wennborg wrote: > PR19668 was marked as a release blocker. Is this suitable for merging? > > On Tue, Aug 15, 2017 at 6:49 PM, Richard Smith via cfe-commits > wrote: > > Author: rsmith > > Date: Tue Aug 15 18:49:53 2017 > > New Revision: 310983 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=310983&view=rev > > Log: > > PR19668, PR23034: Fix handling of move constructors and deleted copy > > constructors when deciding whether classes should be passed indirectly. > > > > This fixes ABI differences between Clang and GCC: > > > > * Previously, Clang ignored the move constructor when making this > >determination. It now takes the move constructor into account, per > >https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may > >seem recent, but the ABI change was agreed on the Itanium C++ ABI > >list a long time ago). > > > > * Previously, Clang's behavior when the copy constructor was deleted > >was unstable -- depending on whether the lazy declaration of the > >copy constructor had been triggered, you might get different behavior. > >We now eagerly declare the copy constructor whenever its deletedness > >is unclear, and ignore deleted copy/move constructors when looking for > >a trivial such constructor. > > > > This also fixes an ABI difference between Clang and MSVC: > > > > * If the copy constructor would be implicitly deleted (but has not been > >lazily declared yet), for instance because the class has an rvalue > >reference member, we would pass it directly. We now pass such a class > >indirectly, matching MSVC. > > > > Based on a patch by Vassil Vassilev, which was based on a patch by Bernd > > Schmidt, which was based on a patch by Reid Kleckner! > > > > This is a re-commit of r310401, which was reverted in r310464 due to ARM > > failures (which should now be fixed). > > > > Modified: > > cfe/trunk/include/clang/AST/DeclCXX.h > > cfe/trunk/lib/AST/ASTImporter.cpp > > cfe/trunk/lib/AST/DeclCXX.cpp > > cfe/trunk/lib/CodeGen/CGCXXABI.cpp > > cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp > > cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp > > cfe/trunk/lib/Sema/SemaDeclCXX.cpp > > cfe/trunk/lib/Serialization/ASTReaderDecl.cpp > > cfe/trunk/lib/Serialization/ASTWriter.cpp > > cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp > > cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp > > > > Modified: cfe/trunk/include/clang/AST/DeclCXX.h > > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/ > clang/AST/DeclCXX.h?rev=310983&r1=310982&r2=310983&view=diff > > > == > > --- cfe/trunk/include/clang/AST/DeclCXX.h (original) > > +++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug 15 18:49:53 2017 > > @@ -374,6 +374,7 @@ class CXXRecordDecl : public RecordDecl > > /// \brief These flags are \c true if a defaulted corresponding > special > > /// member can't be fully analyzed without performing overload > resolution. > > /// @{ > > +unsigned NeedOverloadResolutionForCopyConstructor : 1; > > unsigned NeedOverloadResolutionForMoveConstructor : 1; > > unsigned NeedOverloadResolutionForMoveAssignment : 1; > > unsigned NeedOverloadResolutionForDestructor : 1; > > @@ -382,6 +383,7 @@ class CXXRecordDecl : public RecordDecl > > /// \brief These flags are \c true if an implicit defaulted > corresponding > > /// special member would be defined as deleted. > > /// @{ > > +unsigned DefaultedCopyConstructorIsDeleted : 1; > > unsigned DefaultedMoveConstructorIsDeleted : 1; > > unsigned DefaultedMoveAssignmentIsDeleted : 1; > > unsigned DefaultedDestructorIsDeleted : 1; > > @@ -414,6 +416,12 @@ class CXXRecordDecl : public RecordDecl > > /// constructor. > > unsigned HasDefaultedDefaultConstructor : 1; > > > > +/// \brief True if this class can be passed in a > non-address-preserving > > +/// fashion (such as in registers) according to the C++ language > rules. > > +/// This does not imply anything about how the ABI in use will > actually > > +/// pass an object of this class. > > +unsigned CanPassInRegisters : 1; > > + > > /// \brief True if a defaulted default constructor for this class > would > > /// be constexpr. > > unsigned DefaultedDefaultConstructorIsConstexpr : 1; > > @@ -810,18 +818,50 @@ public: > > return data().FirstFriend.isValid(); > >} > > > > + /// \brief \c true if a defaulted copy constructor for this class > would be > > + /// deleted. > > + bool defaultedCopyConstructorIsDeleted() const { > > +assert((!needsOverloadResolutionForCopyConstructor() || > > +(data().DeclaredSpecialMembers & SMF_CopyConstructor)) && > > + "this property has not yet been computed by Sema"); > > +return
r311406 - Moving libFuzzer to compiler-rt: required updates to the Clang driver.
Author: george.karpenkov Date: Mon Aug 21 16:25:19 2017 New Revision: 311406 URL: http://llvm.org/viewvc/llvm-project?rev=311406&view=rev Log: Moving libFuzzer to compiler-rt: required updates to the Clang driver. Differential Revision: https://reviews.llvm.org/D36909 Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp cfe/trunk/lib/Driver/ToolChains/Darwin.cpp cfe/trunk/lib/Driver/ToolChains/Darwin.h cfe/trunk/test/Driver/fuzzer.c Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=311406&r1=311405&r2=311406&view=diff == --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Mon Aug 21 16:25:19 2017 @@ -597,19 +597,6 @@ collectSanitizerRuntimes(const ToolChain StaticRuntimes.push_back("esan"); } -static void addLibFuzzerRuntime(const ToolChain &TC, -const ArgList &Args, -ArgStringList &CmdArgs) { - StringRef ParentDir = - llvm::sys::path::parent_path(TC.getDriver().InstalledDir); - SmallString<128> P(ParentDir); - llvm::sys::path::append(P, "lib", "libLLVMFuzzer.a"); - CmdArgs.push_back(Args.MakeArgString(P)); - if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx)) -TC.AddCXXStdlibLibArgs(Args, CmdArgs); -} - - // Should be called before we add system libraries (C++ ABI, libstdc++/libc++, // C runtime, etc). Returns true if sanitizer system deps need to be linked in. bool tools::addSanitizerRuntimes(const ToolChain &TC, const ArgList &Args, @@ -619,10 +606,14 @@ bool tools::addSanitizerRuntimes(const T collectSanitizerRuntimes(TC, Args, SharedRuntimes, StaticRuntimes, NonWholeStaticRuntimes, HelperStaticRuntimes, RequiredSymbols); + // Inject libfuzzer dependencies. if (TC.getSanitizerArgs().needsFuzzer() && !Args.hasArg(options::OPT_shared)) { -addLibFuzzerRuntime(TC, Args, CmdArgs); + +addSanitizerRuntime(TC, Args, CmdArgs, "fuzzer", false, true); +if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx)) + TC.AddCXXStdlibLibArgs(Args, CmdArgs); } for (auto RT : SharedRuntimes) Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=311406&r1=311405&r2=311406&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Mon Aug 21 16:25:19 2017 @@ -930,18 +930,6 @@ void MachO::AddLinkRuntimeLib(const ArgL } } -void MachO::AddFuzzerLinkArgs(const ArgList &Args, ArgStringList &CmdArgs) const { - - // Go up one directory from Clang to find the libfuzzer archive file. - StringRef ParentDir = llvm::sys::path::parent_path(getDriver().InstalledDir); - SmallString<128> P(ParentDir); - llvm::sys::path::append(P, "lib", "libLLVMFuzzer.a"); - CmdArgs.push_back(Args.MakeArgString(P)); - - // Libfuzzer is written in C++ and requires libcxx. - AddCXXStdlibLibArgs(Args, CmdArgs); -} - StringRef Darwin::getPlatformFamily() const { switch (TargetPlatform) { case DarwinPlatformKind::MacOS: @@ -1003,11 +991,12 @@ void Darwin::addProfileRTLibs(const ArgL void DarwinClang::AddLinkSanitizerLibArgs(const ArgList &Args, ArgStringList &CmdArgs, - StringRef Sanitizer) const { + StringRef Sanitizer, + bool Shared) const { AddLinkRuntimeLib( Args, CmdArgs, (Twine("libclang_rt.") + Sanitizer + "_" + - getOSLibraryNameSuffix() + "_dynamic.dylib").str(), + getOSLibraryNameSuffix() + (Shared ? "_dynamic.dylib" : ".a")).str(), /*AlwaysLink*/ true, /*IsEmbedded*/ false, /*AddRPath*/ true); } @@ -1053,8 +1042,12 @@ void DarwinClang::AddLinkRuntimeLibArgs( AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan"); if (Sanitize.needsTsanRt()) AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan"); - if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib)) -AddFuzzerLinkArgs(Args, CmdArgs); + if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib)) { +AddLinkSanitizerLibArgs(Args, CmdArgs, "fuzzer", /*shared=*/false); + +// Libfuzzer is written in C++ and requires libcxx. +AddCXXStdlibLibArgs(Args, CmdArgs); + } if (Sanitize.needsStatsRt()) { StringRef OS = isTargetMacOS() ? "osx" : "iossim"; AddLinkRuntimeLib(Args, CmdArgs, Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.h?rev=311406&r1=311405&r2=311406&view=diff
[PATCH] D36806: Switch to cantFail(), since it does the same assertion.
srhines marked an inline comment as done. srhines added inline comments. Comment at: lib/Tooling/Core/Replacement.cpp:505 -assert(!Err && - "Replacements must not conflict since ranges have been merged."); -llvm::consumeError(std::move(Err)); hintonda wrote: > srhines wrote: > > hintonda wrote: > > > While obviously correct, are you concerned that by removing the > > > explanatory text, this change will obscure the reason for the assert? > > The text is now in a comment above the call. > Well, that's what I mean. The reason is no longer in the backtrace. The backtrace will point to this exact line, so I assume anyone debugging it will eventually read the comment. It might be better to have an optional message to cantFail(), but that isn't within the scope of this change. https://reviews.llvm.org/D36806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r310983 - PR19668, PR23034: Fix handling of move constructors and deleted copy
Clean merge in r311410. Thanks. On Mon, Aug 21, 2017 at 4:21 PM, Richard Smith wrote: > Yes, I'd very much like to get this into the upcoming release. > > On 21 August 2017 at 16:16, Hans Wennborg wrote: >> >> PR19668 was marked as a release blocker. Is this suitable for merging? >> >> On Tue, Aug 15, 2017 at 6:49 PM, Richard Smith via cfe-commits >> wrote: >> > Author: rsmith >> > Date: Tue Aug 15 18:49:53 2017 >> > New Revision: 310983 >> > >> > URL: http://llvm.org/viewvc/llvm-project?rev=310983&view=rev >> > Log: >> > PR19668, PR23034: Fix handling of move constructors and deleted copy >> > constructors when deciding whether classes should be passed indirectly. >> > >> > This fixes ABI differences between Clang and GCC: >> > >> > * Previously, Clang ignored the move constructor when making this >> >determination. It now takes the move constructor into account, per >> >https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may >> >seem recent, but the ABI change was agreed on the Itanium C++ ABI >> >list a long time ago). >> > >> > * Previously, Clang's behavior when the copy constructor was deleted >> >was unstable -- depending on whether the lazy declaration of the >> >copy constructor had been triggered, you might get different >> > behavior. >> >We now eagerly declare the copy constructor whenever its deletedness >> >is unclear, and ignore deleted copy/move constructors when looking >> > for >> >a trivial such constructor. >> > >> > This also fixes an ABI difference between Clang and MSVC: >> > >> > * If the copy constructor would be implicitly deleted (but has not been >> >lazily declared yet), for instance because the class has an rvalue >> >reference member, we would pass it directly. We now pass such a class >> >indirectly, matching MSVC. >> > >> > Based on a patch by Vassil Vassilev, which was based on a patch by Bernd >> > Schmidt, which was based on a patch by Reid Kleckner! >> > >> > This is a re-commit of r310401, which was reverted in r310464 due to ARM >> > failures (which should now be fixed). >> > >> > Modified: >> > cfe/trunk/include/clang/AST/DeclCXX.h >> > cfe/trunk/lib/AST/ASTImporter.cpp >> > cfe/trunk/lib/AST/DeclCXX.cpp >> > cfe/trunk/lib/CodeGen/CGCXXABI.cpp >> > cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp >> > cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp >> > cfe/trunk/lib/Sema/SemaDeclCXX.cpp >> > cfe/trunk/lib/Serialization/ASTReaderDecl.cpp >> > cfe/trunk/lib/Serialization/ASTWriter.cpp >> > cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp >> > cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp >> > >> > Modified: cfe/trunk/include/clang/AST/DeclCXX.h >> > URL: >> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310983&r1=310982&r2=310983&view=diff >> > >> > == >> > --- cfe/trunk/include/clang/AST/DeclCXX.h (original) >> > +++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug 15 18:49:53 2017 >> > @@ -374,6 +374,7 @@ class CXXRecordDecl : public RecordDecl >> > /// \brief These flags are \c true if a defaulted corresponding >> > special >> > /// member can't be fully analyzed without performing overload >> > resolution. >> > /// @{ >> > +unsigned NeedOverloadResolutionForCopyConstructor : 1; >> > unsigned NeedOverloadResolutionForMoveConstructor : 1; >> > unsigned NeedOverloadResolutionForMoveAssignment : 1; >> > unsigned NeedOverloadResolutionForDestructor : 1; >> > @@ -382,6 +383,7 @@ class CXXRecordDecl : public RecordDecl >> > /// \brief These flags are \c true if an implicit defaulted >> > corresponding >> > /// special member would be defined as deleted. >> > /// @{ >> > +unsigned DefaultedCopyConstructorIsDeleted : 1; >> > unsigned DefaultedMoveConstructorIsDeleted : 1; >> > unsigned DefaultedMoveAssignmentIsDeleted : 1; >> > unsigned DefaultedDestructorIsDeleted : 1; >> > @@ -414,6 +416,12 @@ class CXXRecordDecl : public RecordDecl >> > /// constructor. >> > unsigned HasDefaultedDefaultConstructor : 1; >> > >> > +/// \brief True if this class can be passed in a >> > non-address-preserving >> > +/// fashion (such as in registers) according to the C++ language >> > rules. >> > +/// This does not imply anything about how the ABI in use will >> > actually >> > +/// pass an object of this class. >> > +unsigned CanPassInRegisters : 1; >> > + >> > /// \brief True if a defaulted default constructor for this class >> > would >> > /// be constexpr. >> > unsigned DefaultedDefaultConstructorIsConstexpr : 1; >> > @@ -810,18 +818,50 @@ public: >> > return data().FirstFriend.isValid(); >> >} >> > >> > + /// \brief \c true if a defaulted copy constructor for this class >> > would be >> > + /// deleted. >> > + bool defaultedCopyConstructorIsDeleted() con
[PATCH] D36806: Switch to cantFail(), since it does the same assertion.
hintonda added inline comments. Comment at: lib/Tooling/Core/Replacement.cpp:505 -assert(!Err && - "Replacements must not conflict since ranges have been merged."); -llvm::consumeError(std::move(Err)); srhines wrote: > hintonda wrote: > > srhines wrote: > > > hintonda wrote: > > > > While obviously correct, are you concerned that by removing the > > > > explanatory text, this change will obscure the reason for the assert? > > > The text is now in a comment above the call. > > Well, that's what I mean. The reason is no longer in the backtrace. > The backtrace will point to this exact line, so I assume anyone debugging it > will eventually read the comment. It might be better to have an optional > message to cantFail(), but that isn't within the scope of this change. Sorry, I meant the output of llvm::sys::PrintStackTrace(), which include the assert. https://reviews.llvm.org/D36806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r309226 - Headers: improve ARM EHABI coverage of unwind.h
Is there something we need for 5.0.0 here? On Sat, Aug 12, 2017 at 9:58 PM, Saleem Abdulrasool wrote: > Yeah, we should adjust that. Technically, it is `_Unwind_Control_Block on > ARM EHABI. However, _Unwind_Exception is aliased to that, which is why we > can use that in the personality routine. We should adjust the sources for > the personality routine. > > On Fri, Aug 11, 2017 at 1:12 PM, Evgenii Stepanov > wrote: >> >> Hi, >> >> I've noticed that the code in >> compiler-rt/lib/builtins/gcc_personality_v0.c refers to >> _Unwind_Exception as "struct _Unwind_Exception". With this change, it >> is not a struct anymore on ARM. Should that code be fixed, or is it a >> problem in this change? >> >> compiler-rt/lib/builtins/gcc_personality_v0.c:153:23: error: >> declaration of 'struct _Unwind_Exception' will not be visible outside >> of this function [-Werror,-Wvisibility] >> continueUnwind(struct _Unwind_Exception *exceptionObject, >> >> On Thu, Jul 27, 2017 at 9:46 AM, Hans Wennborg via cfe-commits >> wrote: >> > Merged to 5.0 in r309290. >> > >> > On Wed, Jul 26, 2017 at 3:55 PM, Saleem Abdulrasool via cfe-commits >> > wrote: >> >> Author: compnerd >> >> Date: Wed Jul 26 15:55:23 2017 >> >> New Revision: 309226 >> >> >> >> URL: http://llvm.org/viewvc/llvm-project?rev=309226&view=rev >> >> Log: >> >> Headers: improve ARM EHABI coverage of unwind.h >> >> >> >> Ensure that we define the `_Unwind_Control_Block` structure used on ARM >> >> EHABI targets. This is needed for building libc++abi with the unwind.h >> >> from the resource dir. A minor fallout of this is that we needed to >> >> create a typedef for _Unwind_Exception to work across ARM EHABI and >> >> non-EHABI targets. The structure definitions here are based originally >> >> on the documentation from ARM under the "Exception Handling ABI for the >> >> ARM® Architecture" Section 7.2. They are then adjusted to more closely >> >> reflect the definition in libunwind from LLVM. Those changes are >> >> compatible in layout but permit easier use in libc++abi and help >> >> maintain compatibility between libunwind and the compiler provided >> >> definition. >> >> >> >> Modified: >> >> cfe/trunk/lib/Headers/unwind.h >> >> >> >> Modified: cfe/trunk/lib/Headers/unwind.h >> >> URL: >> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/unwind.h?rev=309226&r1=309225&r2=309226&view=diff >> >> >> >> == >> >> --- cfe/trunk/lib/Headers/unwind.h (original) >> >> +++ cfe/trunk/lib/Headers/unwind.h Wed Jul 26 15:55:23 2017 >> >> @@ -76,7 +76,13 @@ typedef intptr_t _sleb128_t; >> >> typedef uintptr_t _uleb128_t; >> >> >> >> struct _Unwind_Context; >> >> +#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) || >> >> defined(__ARM_DWARF_EH___)) >> >> +struct _Unwind_Control_Block; >> >> +typedef struct _Unwind_Control_Block _Unwind_Exception; /* Alias */ >> >> +#else >> >> struct _Unwind_Exception; >> >> +typedef struct _Unwind_Exception _Unwind_Exception; >> >> +#endif >> >> typedef enum { >> >>_URC_NO_REASON = 0, >> >> #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \ >> >> @@ -109,8 +115,42 @@ typedef enum { >> >> } _Unwind_Action; >> >> >> >> typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code, >> >> - struct _Unwind_Exception >> >> *); >> >> + _Unwind_Exception *); >> >> >> >> +#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) || >> >> defined(__ARM_DWARF_EH___)) >> >> +typedef struct _Unwind_Control_Block _Unwind_Control_Block; >> >> +typedef uint32_t _Unwind_EHT_Header; >> >> + >> >> +struct _Unwind_Control_Block { >> >> + uint64_t exception_class; >> >> + void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block >> >> *); >> >> + /* unwinder cache (private fields for the unwinder's use) */ >> >> + struct { >> >> +uint32_t reserved1; /* forced unwind stop function, 0 if not >> >> forced */ >> >> +uint32_t reserved2; /* personality routine */ >> >> +uint32_t reserved3; /* callsite */ >> >> +uint32_t reserved4; /* forced unwind stop argument */ >> >> +uint32_t reserved5; >> >> + } unwinder_cache; >> >> + /* propagation barrier cache (valid after phase 1) */ >> >> + struct { >> >> +uint32_t sp; >> >> +uint32_t bitpattern[5]; >> >> + } barrier_cache; >> >> + /* cleanup cache (preserved over cleanup) */ >> >> + struct { >> >> +uint32_t bitpattern[4]; >> >> + } cleanup_cache; >> >> + /* personality cache (for personality's benefit) */ >> >> + struct { >> >> +uint32_t fnstart; /* function start address */ >> >> +_Unwind_EHT_Header *ehtp; /* pointer to EHT entry header word */ >> >> +uint32_t additional; /* additional data */ >> >> +uint32_t reserved1; >> >> + } pr_cache; >> >> + long long int : 0; /* force alignment of next item to 8-byte >> >> b
r311412 - Fixed driver tests for -fsanitize=fuzzer.
Author: george.karpenkov Date: Mon Aug 21 17:04:05 2017 New Revision: 311412 URL: http://llvm.org/viewvc/llvm-project?rev=311412&view=rev Log: Fixed driver tests for -fsanitize=fuzzer. Modified: cfe/trunk/test/Driver/fuzzer.c Modified: cfe/trunk/test/Driver/fuzzer.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuzzer.c?rev=311412&r1=311411&r2=311412&view=diff == --- cfe/trunk/test/Driver/fuzzer.c (original) +++ cfe/trunk/test/Driver/fuzzer.c Mon Aug 21 17:04:05 2017 @@ -2,7 +2,7 @@ // RUN: %clang -fsanitize=fuzzer %s -target x86_64-apple-darwin14 -### 2>&1 | FileCheck --check-prefixes=CHECK-FUZZER-LIB,CHECK-COVERAGE-FLAGS %s // -// CHECK-FUZZER-LIB: libclang_rt.libfuzzer +// CHECK-FUZZER-LIB: libclang_rt.fuzzer // CHECK-COVERAGE: -fsanitize-coverage-trace-pc-guard // CHECK-COVERAGE-SAME: -fsanitize-coverage-indirect-calls // CHECK-COVERAGE-SAME: -fsanitize-coverage-trace-cmp ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36423: [libc++] Introsort based sorting function
bcraig added a comment. LGTM. You should probably get one other person to approve though. I'm hoping that @EricWF or @mclow.lists will take a look https://reviews.llvm.org/D36423 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36806: Switch to cantFail(), since it does the same assertion.
hintonda added a comment. It's just too bad llvm::cantFail() doesn't take an optional string. But the code is cleaner, so I won't comment further. https://reviews.llvm.org/D36806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311422 - Test fix: only add shared libraries to rpath.
Author: george.karpenkov Date: Mon Aug 21 19:10:53 2017 New Revision: 311422 URL: http://llvm.org/viewvc/llvm-project?rev=311422&view=rev Log: Test fix: only add shared libraries to rpath. Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=311422&r1=311421&r2=311422&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Mon Aug 21 19:10:53 2017 @@ -998,7 +998,7 @@ void DarwinClang::AddLinkSanitizerLibArg (Twine("libclang_rt.") + Sanitizer + "_" + getOSLibraryNameSuffix() + (Shared ? "_dynamic.dylib" : ".a")).str(), /*AlwaysLink*/ true, /*IsEmbedded*/ false, - /*AddRPath*/ true); + /*AddRPath*/ Shared); } ToolChain::RuntimeLibType DarwinClang::GetRuntimeLibType( ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas
Rakete updated this revision to Diff 112103. Rakete added a comment. Rebased and friendly ping. https://reviews.llvm.org/D36357 Files: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseExprCXX.cpp test/Parser/cxx0x-lambda-expressions.cpp test/SemaCXX/new-delete-0x.cpp Index: test/SemaCXX/new-delete-0x.cpp === --- test/SemaCXX/new-delete-0x.cpp +++ test/SemaCXX/new-delete-0x.cpp @@ -34,6 +34,5 @@ void bad_deletes() { // 'delete []' is always array delete, per [expr.delete]p1. - // FIXME: Give a better diagnostic. - delete []{ return (int*)0; }(); // expected-error {{expected expression}} + delete []{ return (int*)0; }(); // expected-error{{missing parentheses around lambda expression}} } Index: test/Parser/cxx0x-lambda-expressions.cpp === --- test/Parser/cxx0x-lambda-expressions.cpp +++ test/Parser/cxx0x-lambda-expressions.cpp @@ -53,7 +53,7 @@ void delete_lambda(int *p) { delete [] p; delete [] (int*) { new int }; // ok, compound-literal, not lambda -delete [] { return new int; } (); // expected-error{{expected expression}} +delete [] { return new int; } (); // expected-error{{missing parentheses around lambda expression}} delete [&] { return new int; } (); // ok, lambda } Index: lib/Parse/ParseExprCXX.cpp === --- lib/Parse/ParseExprCXX.cpp +++ lib/Parse/ParseExprCXX.cpp @@ -2885,15 +2885,39 @@ // [Footnote: A lambda expression with a lambda-introducer that consists // of empty square brackets can follow the delete keyword if // the lambda expression is enclosed in parentheses.] -// FIXME: Produce a better diagnostic if the '[]' is unambiguously a -//lambda-introducer. -ArrayDelete = true; -BalancedDelimiterTracker T(*this, tok::l_square); +TentativeParsingAction TPA(*this); -T.consumeOpen(); -T.consumeClose(); -if (T.getCloseLocation().isInvalid()) - return ExprError(); +// Basic lookahead to check if we have a lambda expression. If we +// encounter two braces with a semicolon, we can be pretty sure +// that this is a lambda, not say a compound literal. +if (!SkipUntil(tok::l_brace, SkipUntilFlags::StopAtSemi) || +(NextToken().isNot(tok::r_brace) && !SkipUntil(tok::semi)) || +!SkipUntil(tok::r_brace, SkipUntilFlags::StopAtSemi)) { + TPA.Revert(); + ArrayDelete = true; + BalancedDelimiterTracker T(*this, tok::l_square); + + T.consumeOpen(); + T.consumeClose(); + if (T.getCloseLocation().isInvalid()) +return ExprError(); +} else { + TPA.Revert(); + + // Warn if the non-capturing lambda isn't surrounded by parenthesis + // to disambiguate it from 'delete[]'. + ExprResult Lambda = TryParseLambdaExpression(); + if (!Lambda.isInvalid()) { +SourceLocation StartLoc = Lambda.get()->getLocStart(); +Diag(StartLoc, diag::err_lambda_after_array_delete) + << SourceRange(StartLoc, Lambda.get()->getLocEnd()); + +// Evaluate any postfix expressions used on the lambda. +Lambda = ParsePostfixExpressionSuffix(Lambda); +return Actions.ActOnCXXDelete(Start, UseGlobal, /*ArrayForm=*/false, + Lambda.get()); + } +} } ExprResult Operand(ParseCastExpression(false)); Index: include/clang/Basic/DiagnosticParseKinds.td === --- include/clang/Basic/DiagnosticParseKinds.td +++ include/clang/Basic/DiagnosticParseKinds.td @@ -99,6 +99,8 @@ InGroup, DefaultIgnore; def ext_alignof_expr : ExtWarn< "%0 applied to an expression is a GNU extension">, InGroup; +def err_lambda_after_array_delete : Error< + "missing parentheses around lambda expression">; def warn_microsoft_dependent_exists : Warning< "dependent %select{__if_not_exists|__if_exists}0 declarations are ignored">, Index: test/SemaCXX/new-delete-0x.cpp === --- test/SemaCXX/new-delete-0x.cpp +++ test/SemaCXX/new-delete-0x.cpp @@ -34,6 +34,5 @@ void bad_deletes() { // 'delete []' is always array delete, per [expr.delete]p1. - // FIXME: Give a better diagnostic. - delete []{ return (int*)0; }(); // expected-error {{expected expression}} + delete []{ return (int*)0; }(); // expected-error{{missing parentheses around lambda expression}} } Index: test/Parser/cxx0x-lambda-expressions.cpp === --- test/Parser/cxx0x-lambda-expressions.cpp +++ test/Parser/cxx0x-lambda-expressions.cpp @@ -53,7 +53,7 @@ void delete_lambda(int *p) { delete [] p; delete [] (int*) { new int }; // ok, compound-literal, not lambda -delete []
[PATCH] D34275: [analyzer] Re-implemente current virtual calls checker in a path-sensitive way
wangxindsb updated this revision to Diff 112110. wangxindsb added a comment. - Fix the errors of the tests; - Add `-analyzer-output=text` to the run-line; - Change the message of the visitor's diagnostic piece. https://reviews.llvm.org/D34275 Files: lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp test/Analysis/virtualcall.cpp Index: test/Analysis/virtualcall.cpp === --- test/Analysis/virtualcall.cpp +++ test/Analysis/virtualcall.cpp @@ -1,98 +1,86 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s -// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:Interprocedural=true -DINTERPROCEDURAL=1 -verify -std=c++11 %s -// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s - -/* When INTERPROCEDURAL is set, we expect diagnostics in all functions reachable - from a constructor or destructor. If it is not set, we expect diagnostics - only in the constructor or destructor. - - When PUREONLY is set, we expect diagnostics only for calls to pure virtual - functions not to non-pure virtual functions. -*/ +// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-output=text -verify -std=c++11 %s + +// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -analyzer-output=text -verify -std=c++11 %s class A { public: A(); - A(int i); - ~A() {}; - - virtual int foo() = 0; // from Sema: expected-note {{'foo' declared here}} + ~A(){}; + + virtual int foo() = 0; virtual void bar() = 0; void f() { foo(); -#if INTERPROCEDURAL -// expected-warning-re@-2 ^}}Call Path : foo <-- fCall to pure virtual function during construction has undefined behavior}} +#if PUREONLY + // expected-warning-re@-2 ^}}Call to pure virtual function during construction}} + // expected-note-re@-3 ^}}Call to pure virtual function during construction}} +#else + // expected-warning-re@-5 ^}}Call to virtual function during construction}} + // expected-note-re@-6 ^}}Call to virtual function during construction}} #endif } }; class B : public A { public: - B() { -foo(); + B() { // expected-note {{Calling default constructor for 'A'}} +foo(); #if !PUREONLY -#if INTERPROCEDURAL -// expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}} -#else -// expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}} + // expected-warning-re@-2 ^}}Call to virtual function during construction}} + // expected-note-re@-3 ^}}This constructor of an object of type 'B' has not returned when the virtual method was called}} + // expected-note-re@-4 ^}}Call to virtual function during construction}} #endif -#endif - } ~B(); - + virtual int foo(); - virtual void bar() { foo(); } -#if INTERPROCEDURAL - // expected-warning-re@-2 ^}}Call Path : foo <-- barCall to virtual function during destruction will not dispatch to derived class}} + virtual void bar() { +foo(); +#if !PUREONLY + // expected-warning-re@-2 ^}}Call to virtual function during destruction}} + // expected-note-re@-3 ^}}Call to virtual function during destruction}} #endif + } }; -A::A() { - f(); -} - -A::A(int i) { - foo(); // From Sema: expected-warning {{call to pure virtual member function 'foo' has undefined behavior}} -#if INTERPROCEDURAL - // expected-warning-re@-2 ^}}Call Path : fooCall to pure virtual function during construction has undefined behavior}} -#else - // expected-warning-re@-4 ^}}Call to pure virtual function during construction has undefined behavior}} -#endif +A::A() { + f(); +// expected-note-re@-1 ^}}This constructor of an object of type 'A' has not returned when the virtual method was called}} +// expected-note-re@-2 ^}}Calling 'A::f'}} } B::~B() { this->B::foo(); // no-warning this->B::bar(); - this->foo(); #if !PUREONLY -#if INTERPROCEDURAL - // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during destruction will not dispatch to derived class}} -#else - // expected-warning-re@-5 ^}}Call to virtual function during destruction will not dispatch to derived class}} + // expected-note-re@-2 ^}}This destructor of an object of type '~B' has not returned when the virtual method was called}} + // expected-note-re@-3 ^}}Calling 'B::bar'}} #endif + this->foo(); +#if !PUREONLY + // expected-warning-re@-2 ^}}Cal
[PATCH] D34275: [analyzer] Re-implemente current virtual calls checker in a path-sensitive way
wangxindsb added a comment. @NoQ In https://reviews.llvm.org/D34275#847434, @NoQ wrote: > Most importantly, do you think we can enable the checker by default now? Was > this checker evaluated on any large codebase, and if so, how many true/false > positives did it find, probably compared to the old checker? I am now runing the checker to check the build of firefox, llvm and libreoffice. There are no alarms on the building of firefox and llvm. When use scan-build to check the building of libreoffice, the scan-build failed (this may because the scan-build. Enable or not enable the virtualcallchecker, the build failed all the same, but when I just build the libreoffice and not run the scan-build, the build worked well) and there are 105 alarms about the virtual function in ctors/dtors, I am evaluating these alarms now. https://reviews.llvm.org/D34275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311428 - Update libprotobuf-mutator revision
Author: vitalybuka Date: Mon Aug 21 22:18:28 2017 New Revision: 311428 URL: http://llvm.org/viewvc/llvm-project?rev=311428&view=rev Log: Update libprotobuf-mutator revision Modified: cfe/trunk/cmake/modules/ProtobufMutator.cmake Modified: cfe/trunk/cmake/modules/ProtobufMutator.cmake URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/ProtobufMutator.cmake?rev=311428&r1=311427&r2=311428&view=diff == --- cfe/trunk/cmake/modules/ProtobufMutator.cmake (original) +++ cfe/trunk/cmake/modules/ProtobufMutator.cmake Mon Aug 21 22:18:28 2017 @@ -6,7 +6,7 @@ set(PBM_FUZZ_LIB_PATH ${PBM_PATH}/src/li ExternalProject_Add(${PBM_PREFIX} PREFIX ${PBM_PREFIX} GIT_REPOSITORY https://github.com/google/libprotobuf-mutator.git - GIT_TAG 34287f8 + GIT_TAG 17789d1 CONFIGURE_COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36876: [IRGen] Evaluate constant static variables referenced through member expressions
rjmccall added inline comments. Comment at: lib/CodeGen/CGExpr.cpp:1323 + if (result.HasSideEffects && !AllowSideEffects) { +assert(!isa(E) && "declrefs should not have side effects"); return ConstantEmission(); The side effects here are those associated with the initializer of the referenced declaration, not the DRE itself. Some expressions can be constant-evaluated despite having side-effects because the side-effects occur in an ignored operand, like the LHS of a comma or the base of a MemberExpr that refers to a static member. We can't allow side effects here because (1) we're not actually collecting the side-effectful expressions to emit and (2) we'd need some permission from the context to decide that we're allowed to do so anyway (with a lambda capture, those side-effects have actually already been emitted, but I'm not convinced that's always true). On the other hand, I think we need to be able to emit MemberExprs to static members as constants despite the presence of side-effects in their base expressions, and I can't think of any reasonable way to do that except actually making a temporary DeclRefExpr to try to constant-emit instead. Repository: rL LLVM https://reviews.llvm.org/D36876 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36956: [clang-format] Emit absolute splits before lines for comments
djasper added inline comments. Comment at: lib/Format/BreakableToken.cpp:553 StringRef TrimmedContent = Content[LineIndex].ltrim(Blanks); - return getReflowSplit(TrimmedContent, ReflowPrefix, PreviousEndColumn, -ColumnLimit); + Split TrimmedSplit = getReflowSplit(TrimmedContent, ReflowPrefix, + PreviousEndColumn, ColumnLimit); I think a split cannot be "Trimmed". Maybe "Result" or "NewSplit"? Comment at: lib/Format/BreakableToken.cpp:557 +return TrimmedSplit; + return Split(TrimmedSplit.first + Content[LineIndex].size() - + TrimmedContent.size(), Why do you create a new split instead of: TrimmedSplit += Content[LineIndex].size() - TrimmedContent.size(); ? Comment at: unittests/Format/FormatTestComments.cpp:2785 +TEST_F(FormatTestComments, NoCrush_Bug34236) { + // This is a test case from a crusher reported in bug 34236: + // https://bugs.llvm.org/show_bug.cgi?id=34236 s/crusher/crasher/ :-D Also, I'd just remove " bug 34236", seems redundant. https://reviews.llvm.org/D36956 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36614: [clang-format] Refine trailing comment detection
djasper added inline comments. Comment at: lib/Format/FormatToken.h:397 + (!Previous || + Previous->isOneOf(tok::comma, tok::equal, tok::l_brace) || + Next->is(tok::r_brace; Is this list coming from existing tests? Comment at: unittests/Format/FormatTestComments.cpp:461 + + verifyFormat("const /** comment comment comment comment */\n" + "A = B;", I wonder whether instead we should just break the comment here, even if it is not a trailing one. Violating the column limit also seems bad. What happens if we do that (i.e. break non-trailing comments)? https://reviews.llvm.org/D36614 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits