r250687 - Use saner variable names. NFC.
Author: mkuper Date: Mon Oct 19 02:52:25 2015 New Revision: 250687 URL: http://llvm.org/viewvc/llvm-project?rev=250687&view=rev Log: Use saner variable names. NFC. Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=250687&r1=250686&r2=250687&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Oct 19 02:52:25 2015 @@ -796,7 +796,7 @@ class X86_32ABIInfo : public ABIInfo { static const unsigned MinABIStackAlignInBytes = 4; bool IsDarwinVectorABI; - bool IsSmallStructInRegABI; + bool IsRetSmallStructInRegABI; bool IsWin32StructABI; unsigned DefaultNumRegisterParameters; @@ -845,17 +845,23 @@ public: Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty) const override; - X86_32ABIInfo(CodeGen::CodeGenTypes &CGT, bool d, bool p, bool w, -unsigned r) -: ABIInfo(CGT), IsDarwinVectorABI(d), IsSmallStructInRegABI(p), - IsWin32StructABI(w), DefaultNumRegisterParameters(r) {} + X86_32ABIInfo(CodeGen::CodeGenTypes &CGT, bool DarwinVectorABI, +bool RetSmallStructInRegABI, bool Win32StructABI, +unsigned NumRegisterParameters) +: ABIInfo(CGT), IsDarwinVectorABI(DarwinVectorABI), + IsRetSmallStructInRegABI(RetSmallStructInRegABI), + IsWin32StructABI(Win32StructABI), + DefaultNumRegisterParameters(NumRegisterParameters) {} }; class X86_32TargetCodeGenInfo : public TargetCodeGenInfo { public: - X86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, - bool d, bool p, bool w, unsigned r) -:TargetCodeGenInfo(new X86_32ABIInfo(CGT, d, p, w, r)) {} + X86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, bool DarwinVectorABI, + bool RetSmallStructInRegABI, bool Win32StructABI, + unsigned NumRegisterParameters) + : TargetCodeGenInfo( +new X86_32ABIInfo(CGT, DarwinVectorABI, RetSmallStructInRegABI, + Win32StructABI, NumRegisterParameters)) {} static bool isStructReturnInRegABI( const llvm::Triple &Triple, const CodeGenOptions &Opts); @@ -978,7 +984,7 @@ void X86_32TargetCodeGenInfo::addReturnR } /// shouldReturnTypeInRegister - Determine if the given type should be -/// passed in a register (for the Darwin ABI). +/// returned in a register (for the Darwin ABI). bool X86_32ABIInfo::shouldReturnTypeInRegister(QualType Ty, ASTContext &Context) const { uint64_t Size = Context.getTypeSize(Ty); @@ -1083,7 +1089,7 @@ ABIArgInfo X86_32ABIInfo::classifyReturn } // If specified, structs and unions are always indirect. -if (!IsSmallStructInRegABI && !RetTy->isAnyComplexType()) +if (!IsRetSmallStructInRegABI && !RetTy->isAnyComplexType()) return getIndirectReturnResult(RetTy, State); // Small structures which are register sized are generally returned @@ -1876,8 +1882,10 @@ static std::string qualifyWindowsLibrary class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo { public: WinX86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, -bool d, bool p, bool w, unsigned RegParms) -: X86_32TargetCodeGenInfo(CGT, d, p, w, RegParms) {} +bool DarwinVectorABI, bool RetSmallStructInRegABI, bool Win32StructABI, +unsigned NumRegisterParameters) +: X86_32TargetCodeGenInfo(CGT, DarwinVectorABI, RetSmallStructInRegABI, +Win32StructABI, NumRegisterParameters) {} void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const override; @@ -7378,17 +7386,17 @@ const TargetCodeGenInfo &CodeGenModule:: case llvm::Triple::x86: { bool IsDarwinVectorABI = Triple.isOSDarwin(); -bool IsSmallStructInRegABI = +bool RetSmallStructInRegABI = X86_32TargetCodeGenInfo::isStructReturnInRegABI(Triple, CodeGenOpts); bool IsWin32FloatStructABI = Triple.isOSWindows() && !Triple.isOSCygMing(); if (Triple.getOS() == llvm::Triple::Win32) { return *(TheTargetCodeGenInfo = new WinX86_32TargetCodeGenInfo( - Types, IsDarwinVectorABI, IsSmallStructInRegABI, + Types, IsDarwinVectorABI, RetSmallStructInRegABI, IsWin32FloatStructABI, CodeGenOpts.NumRegisterParameters)); } else { return *(TheTargetCodeGenInfo = new X86_32TargetCodeGenInfo( - Types, IsDarwinVectorABI, IsSmallStructInRegABI, + Types, IsDarwinVectorABI, RetSmallStructInRegABI, IsWin32FloatStructABI, CodeGenOpts.NumRegisterParameters)); } } ___ cfe-commits mailing list cfe-commits@lis
r250689 - [X86] Enable soft float ABI for x86
Author: mkuper Date: Mon Oct 19 03:09:43 2015 New Revision: 250689 URL: http://llvm.org/viewvc/llvm-project?rev=250689&view=rev Log: [X86] Enable soft float ABI for x86 The Intel MCU psABI requires floating-point values to be passed in-reg. This makes the x86-32 ABI code respect "-mfloat-abi soft" and generate float inreg arguments. Differential Revision: http://reviews.llvm.org/D13554 Added: cfe/trunk/test/CodeGen/x86-soft-float.c Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=250689&r1=250688&r2=250689&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Oct 19 03:09:43 2015 @@ -798,6 +798,7 @@ class X86_32ABIInfo : public ABIInfo { bool IsDarwinVectorABI; bool IsRetSmallStructInRegABI; bool IsWin32StructABI; + bool IsSoftFloatABI; unsigned DefaultNumRegisterParameters; static bool isRegisterSize(unsigned Size) { @@ -847,21 +848,22 @@ public: X86_32ABIInfo(CodeGen::CodeGenTypes &CGT, bool DarwinVectorABI, bool RetSmallStructInRegABI, bool Win32StructABI, -unsigned NumRegisterParameters) +unsigned NumRegisterParameters, bool SoftFloatABI) : ABIInfo(CGT), IsDarwinVectorABI(DarwinVectorABI), IsRetSmallStructInRegABI(RetSmallStructInRegABI), IsWin32StructABI(Win32StructABI), - DefaultNumRegisterParameters(NumRegisterParameters) {} + DefaultNumRegisterParameters(NumRegisterParameters), + IsSoftFloatABI(SoftFloatABI) {} }; class X86_32TargetCodeGenInfo : public TargetCodeGenInfo { public: X86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, bool DarwinVectorABI, bool RetSmallStructInRegABI, bool Win32StructABI, - unsigned NumRegisterParameters) - : TargetCodeGenInfo( -new X86_32ABIInfo(CGT, DarwinVectorABI, RetSmallStructInRegABI, - Win32StructABI, NumRegisterParameters)) {} + unsigned NumRegisterParameters, bool SoftFloatABI) + : TargetCodeGenInfo(new X86_32ABIInfo( +CGT, DarwinVectorABI, RetSmallStructInRegABI, Win32StructABI, +NumRegisterParameters, SoftFloatABI)) {} static bool isStructReturnInRegABI( const llvm::Triple &Triple, const CodeGenOptions &Opts); @@ -1212,9 +1214,11 @@ X86_32ABIInfo::Class X86_32ABIInfo::clas bool X86_32ABIInfo::shouldUseInReg(QualType Ty, CCState &State, bool &NeedsPadding) const { NeedsPadding = false; - Class C = classify(Ty); - if (C == Float) -return false; + if (!IsSoftFloatABI) { +Class C = classify(Ty); +if (C == Float) + return false; + } unsigned Size = getContext().getTypeSize(Ty); unsigned SizeInRegs = (Size + 31) / 32; @@ -1885,7 +1889,7 @@ public: bool DarwinVectorABI, bool RetSmallStructInRegABI, bool Win32StructABI, unsigned NumRegisterParameters) : X86_32TargetCodeGenInfo(CGT, DarwinVectorABI, RetSmallStructInRegABI, -Win32StructABI, NumRegisterParameters) {} +Win32StructABI, NumRegisterParameters, false) {} void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const override; @@ -7397,7 +7401,8 @@ const TargetCodeGenInfo &CodeGenModule:: } else { return *(TheTargetCodeGenInfo = new X86_32TargetCodeGenInfo( Types, IsDarwinVectorABI, RetSmallStructInRegABI, - IsWin32FloatStructABI, CodeGenOpts.NumRegisterParameters)); + IsWin32FloatStructABI, CodeGenOpts.NumRegisterParameters, + CodeGenOpts.FloatABI == "soft")); } } Added: cfe/trunk/test/CodeGen/x86-soft-float.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86-soft-float.c?rev=250689&view=auto == --- cfe/trunk/test/CodeGen/x86-soft-float.c (added) +++ cfe/trunk/test/CodeGen/x86-soft-float.c Mon Oct 19 03:09:43 2015 @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 3 -emit-llvm %s -o - | FileCheck %s -check-prefix=HARD +// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 3 -mfloat-abi soft -emit-llvm %s -o - | FileCheck %s -check-prefix=SOFT + +// HARD: define void @f1(float %a) +// SOFT: define void @f1(float inreg %a) +void f1(float a) {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13554: [X86] Enable soft float ABI for x86
This revision was automatically updated to reflect the committed changes. Closed by commit rL250689: [X86] Enable soft float ABI for x86 (authored by mkuper). Changed prior to commit: http://reviews.llvm.org/D13554?vs=36853&id=37723#toc Repository: rL LLVM http://reviews.llvm.org/D13554 Files: cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/test/CodeGen/x86-soft-float.c Index: cfe/trunk/test/CodeGen/x86-soft-float.c === --- cfe/trunk/test/CodeGen/x86-soft-float.c +++ cfe/trunk/test/CodeGen/x86-soft-float.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 3 -emit-llvm %s -o - | FileCheck %s -check-prefix=HARD +// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 3 -mfloat-abi soft -emit-llvm %s -o - | FileCheck %s -check-prefix=SOFT + +// HARD: define void @f1(float %a) +// SOFT: define void @f1(float inreg %a) +void f1(float a) {} Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp === --- cfe/trunk/lib/CodeGen/TargetInfo.cpp +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp @@ -798,6 +798,7 @@ bool IsDarwinVectorABI; bool IsRetSmallStructInRegABI; bool IsWin32StructABI; + bool IsSoftFloatABI; unsigned DefaultNumRegisterParameters; static bool isRegisterSize(unsigned Size) { @@ -847,21 +848,22 @@ X86_32ABIInfo(CodeGen::CodeGenTypes &CGT, bool DarwinVectorABI, bool RetSmallStructInRegABI, bool Win32StructABI, -unsigned NumRegisterParameters) +unsigned NumRegisterParameters, bool SoftFloatABI) : ABIInfo(CGT), IsDarwinVectorABI(DarwinVectorABI), IsRetSmallStructInRegABI(RetSmallStructInRegABI), IsWin32StructABI(Win32StructABI), - DefaultNumRegisterParameters(NumRegisterParameters) {} + DefaultNumRegisterParameters(NumRegisterParameters), + IsSoftFloatABI(SoftFloatABI) {} }; class X86_32TargetCodeGenInfo : public TargetCodeGenInfo { public: X86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, bool DarwinVectorABI, bool RetSmallStructInRegABI, bool Win32StructABI, - unsigned NumRegisterParameters) - : TargetCodeGenInfo( -new X86_32ABIInfo(CGT, DarwinVectorABI, RetSmallStructInRegABI, - Win32StructABI, NumRegisterParameters)) {} + unsigned NumRegisterParameters, bool SoftFloatABI) + : TargetCodeGenInfo(new X86_32ABIInfo( +CGT, DarwinVectorABI, RetSmallStructInRegABI, Win32StructABI, +NumRegisterParameters, SoftFloatABI)) {} static bool isStructReturnInRegABI( const llvm::Triple &Triple, const CodeGenOptions &Opts); @@ -1212,9 +1214,11 @@ bool X86_32ABIInfo::shouldUseInReg(QualType Ty, CCState &State, bool &NeedsPadding) const { NeedsPadding = false; - Class C = classify(Ty); - if (C == Float) -return false; + if (!IsSoftFloatABI) { +Class C = classify(Ty); +if (C == Float) + return false; + } unsigned Size = getContext().getTypeSize(Ty); unsigned SizeInRegs = (Size + 31) / 32; @@ -1885,7 +1889,7 @@ bool DarwinVectorABI, bool RetSmallStructInRegABI, bool Win32StructABI, unsigned NumRegisterParameters) : X86_32TargetCodeGenInfo(CGT, DarwinVectorABI, RetSmallStructInRegABI, -Win32StructABI, NumRegisterParameters) {} +Win32StructABI, NumRegisterParameters, false) {} void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const override; @@ -7397,7 +7401,8 @@ } else { return *(TheTargetCodeGenInfo = new X86_32TargetCodeGenInfo( Types, IsDarwinVectorABI, RetSmallStructInRegABI, - IsWin32FloatStructABI, CodeGenOpts.NumRegisterParameters)); + IsWin32FloatStructABI, CodeGenOpts.NumRegisterParameters, + CodeGenOpts.FloatABI == "soft")); } } Index: cfe/trunk/test/CodeGen/x86-soft-float.c === --- cfe/trunk/test/CodeGen/x86-soft-float.c +++ cfe/trunk/test/CodeGen/x86-soft-float.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 3 -emit-llvm %s -o - | FileCheck %s -check-prefix=HARD +// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 3 -mfloat-abi soft -emit-llvm %s -o - | FileCheck %s -check-prefix=SOFT + +// HARD: define void @f1(float %a) +// SOFT: define void @f1(float inreg %a) +void f1(float a) {} Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp === --- cfe/trunk/lib/CodeGen/TargetInfo.cpp +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp @@ -798,6 +798,7 @@ bool IsDarwinVectorABI; bool IsRetSmallStructInRegABI; bool IsWin32StructABI; + bool IsSoftFloatABI; unsigned
r250690 - Make test not rely on %T ending on /Output.
Author: klimek Date: Mon Oct 19 03:27:51 2015 New Revision: 250690 URL: http://llvm.org/viewvc/llvm-project?rev=250690&view=rev Log: Make test not rely on %T ending on /Output. Modified: cfe/trunk/test/Driver/ps4-linker-non-win.c Modified: cfe/trunk/test/Driver/ps4-linker-non-win.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-linker-non-win.c?rev=250690&r1=250689&r2=250690&view=diff == --- cfe/trunk/test/Driver/ps4-linker-non-win.c (original) +++ cfe/trunk/test/Driver/ps4-linker-non-win.c Mon Oct 19 03:27:51 2015 @@ -1,21 +1,21 @@ // UNSUPPORTED: system-windows // REQUIRES: x86-registered-target -// RUN: rm -f %T/ps4-ld -// RUN: touch %T/ps4-ld -// RUN: chmod +x %T/ps4-ld +// RUN: mkdir -p %T/Output +// RUN: rm -f %T/Output/ps4-ld +// RUN: touch %T/Output/ps4-ld +// RUN: chmod +x %T/Output/ps4-ld -// RUN: env "PATH=%T:%PATH%" %clang -### -target x86_64-scei-ps4 %s -fuse-ld=gold 2>&1 \ +// RUN: env "PATH=%T/Output:%PATH%" %clang -### -target x86_64-scei-ps4 %s -fuse-ld=gold 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-PS4-LINKER %s -// RUN: env "PATH=%T:%PATH%" %clang -### -target x86_64-scei-ps4 %s -shared 2>&1 \ +// RUN: env "PATH=%T/Output:%PATH%" %clang -### -target x86_64-scei-ps4 %s -shared 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-PS4-LINKER %s -// RUN: env "PATH=%T:%PATH%" %clang -### -target x86_64-scei-ps4 %s 2>&1 \ +// RUN: env "PATH=%T/Output:%PATH%" %clang -### -target x86_64-scei-ps4 %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-PS4-LINKER %s -// RUN: env "PATH=%T:%PATH%" %clang -### -target x86_64-scei-ps4 %s -fuse-ld=ps4 2>&1 \ +// RUN: env "PATH=%T/Output:%PATH%" %clang -### -target x86_64-scei-ps4 %s -fuse-ld=ps4 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-PS4-LINKER %s -// RUN: env "PATH=%T:%PATH%" %clang -### -target x86_64-scei-ps4 %s -shared \ +// RUN: env "PATH=%T/Output:%PATH%" %clang -### -target x86_64-scei-ps4 %s -shared \ // RUN: -fuse-ld=ps4 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s -// FIXME: This depends that %T ends with "Output". // CHECK-PS4-LINKER: Output/ps4-ld ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r250691 - Fix 'will be initialized after' warning.
Author: klimek Date: Mon Oct 19 03:43:46 2015 New Revision: 250691 URL: http://llvm.org/viewvc/llvm-project?rev=250691&view=rev Log: Fix 'will be initialized after' warning. Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=250691&r1=250690&r2=250691&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Oct 19 03:43:46 2015 @@ -852,8 +852,8 @@ public: : ABIInfo(CGT), IsDarwinVectorABI(DarwinVectorABI), IsRetSmallStructInRegABI(RetSmallStructInRegABI), IsWin32StructABI(Win32StructABI), - DefaultNumRegisterParameters(NumRegisterParameters), - IsSoftFloatABI(SoftFloatABI) {} + IsSoftFloatABI(SoftFloatABI), + DefaultNumRegisterParameters(NumRegisterParameters) {} }; class X86_32TargetCodeGenInfo : public TargetCodeGenInfo { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r250514 - PS4: Make sure to add the sanitizer runtime before any linker input
I don't see this. Do you have a log for them? Thank you, Filipe On Fri, Oct 16, 2015 at 11:52 PM, Artem Belevich via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Filipe, > > FYI, this change appears to introduce a somewhat subtle problem. clang > compiled with itself starts producing (false positive?) warnings about > uninitialized variables. I didn't get a chance to dig deeper yet. > > --Artem > > On Fri, Oct 16, 2015 at 8:07 AM, Filipe Cabecinhas via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: filcab >> Date: Fri Oct 16 10:07:48 2015 >> New Revision: 250514 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=250514&view=rev >> Log: >> PS4: Make sure to add the sanitizer runtime before any linker input >> >> Modified: >> cfe/trunk/lib/Driver/Tools.cpp >> >> Modified: cfe/trunk/lib/Driver/Tools.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=250514&r1=250513&r2=250514&view=diff >> >> == >> --- cfe/trunk/lib/Driver/Tools.cpp (original) >> +++ cfe/trunk/lib/Driver/Tools.cpp Fri Oct 16 10:07:48 2015 >> @@ -10017,6 +10017,8 @@ static void ConstructPS4LinkJob(const To >> assert(Output.isNothing() && "Invalid output."); >>} >> >> + AddPS4SanitizerArgs(ToolChain, CmdArgs); >> + >>Args.AddAllArgs(CmdArgs, options::OPT_L); >>Args.AddAllArgs(CmdArgs, options::OPT_T_Group); >>Args.AddAllArgs(CmdArgs, options::OPT_e); >> @@ -10034,7 +10036,6 @@ static void ConstructPS4LinkJob(const To >>} >> >>AddPS4ProfileRT(ToolChain, Args, CmdArgs); >> - AddPS4SanitizerArgs(ToolChain, CmdArgs); >> >>const char *Exec = >> Args.MakeArgString(ToolChain.GetProgramPath("ps4-ld")); >> >> @@ -10087,6 +10088,8 @@ static void ConstructGoldLinkJob(const T >> assert(Output.isNothing() && "Invalid output."); >>} >> >> + AddPS4SanitizerArgs(ToolChain, CmdArgs); >> + >>if (!Args.hasArg(options::OPT_nostdlib) && >>!Args.hasArg(options::OPT_nostartfiles)) { >> const char *crt1 = NULL; >> @@ -10214,7 +10217,6 @@ static void ConstructGoldLinkJob(const T >>} >> >>AddPS4ProfileRT(ToolChain, Args, CmdArgs); >> - AddPS4SanitizerArgs(ToolChain, CmdArgs); >> >>const char *Exec = >> #ifdef LLVM_ON_WIN32 >> >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> > > > > -- > --Artem Belevich > > ___ > 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
Re: r250577 - [modules] Allow the error when explicitly loading an incompatible module file
On Sat, Oct 17, 2015 at 3:41 AM Richard Smith via cfe-commits < cfe-commits@lists.llvm.org> wrote: > On Fri, Oct 16, 2015 at 6:30 PM, Sean Silva wrote: > >> On Fri, Oct 16, 2015 at 6:26 PM, Richard Smith >> wrote: >> >>> On Fri, Oct 16, 2015 at 6:25 PM, Sean Silva >>> wrote: >>> On Fri, Oct 16, 2015 at 6:12 PM, Richard Smith wrote: > On Fri, Oct 16, 2015 at 4:43 PM, Sean Silva > wrote: > >> On Fri, Oct 16, 2015 at 4:20 PM, Richard Smith via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Author: rsmith >>> Date: Fri Oct 16 18:20:19 2015 >>> New Revision: 250577 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=250577&view=rev >>> Log: >>> [modules] Allow the error when explicitly loading an incompatible >>> module file >>> via -fmodule-file= to be turned off; in that case, just include the >>> relevant >>> files textually. This allows module files to be unconditionally >>> passed to all >>> compile actions via CXXFLAGS, and to be ignored for rules that >>> specify custom >>> incompatible flags. >>> >> >> What direction are you trying to go with this? Are you thinking >> something like having CMake build a bunch of modules up front? >> > > That's certainly one thing you can do with this. Another is that you > can make cmake automatically and explicitly build a module for each > library, and then provide that for all the dependencies of that library, > How does CMake know which headers are part of which library? Strategically named top-level modules in the module map? >>> >>> The idea would be for CMake to generate the module map itself based on >>> the build rules. >>> >> >> How would it know which headers to include? Do our ADDITIONAL_HEADER_DIRS >> things in our CMakeLists.txt have enough information for this? >> > > Some additional information may need to be added to the CMakeLists to > enable this. Some build systems already model the headers for a library, > and so already have the requisite information. > CMake supports specifying headers for libraries (mainly used for MS VS). If we need this for modules, we'll probably need to update our build rules (which will probably make sense anyway, for a better experience for VS users ;) > > >> -- Sean Silva >> >> >>> >>> -- Sean Silva > with an (error-by-default) warning in the case where the downstream > library specifies incompatible compilation flags. You can use this warning > flag to turn off the error so you can make progress before you get around > to fixing all the incompatible flags. > > >> If that's the case, it would be nice to explain what caused the >> mismatch, so that the user can look into rectifying it. Otherwise this >> warning is not directly actionable. The existing diagnostics seemed >> alright. Demoting them to "error: {{.*}} configuration mismatch" seems >> like >> a regression. >> > > I agree, it is a regression, and fixing it is high on my list of > priorities (sorry for not mentioning that in the commit message). > > -- Sean Silva >> >> >>> >>> Modified: >>> cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td >>> cfe/trunk/lib/Frontend/CompilerInstance.cpp >>> cfe/trunk/test/Modules/merge-target-features.cpp >>> >>> Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=250577&r1=250576&r2=250577&view=diff >>> >>> == >>> --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td >>> (original) >>> +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Fri Oct >>> 16 18:20:19 2015 >>> @@ -172,6 +172,9 @@ def warn_incompatible_analyzer_plugin_ap >>> def note_incompatible_analyzer_plugin_api : Note< >>> "current API version is '%0', but plugin was compiled with >>> version '%1'">; >>> >>> +def warn_module_config_mismatch : Warning< >>> + "module file %0 cannot be loaded due to a configuration mismatch >>> with the current " >>> + "compilation">, >>> InGroup>, DefaultError; >>> def err_module_map_not_found : Error<"module map file '%0' not >>> found">, >>>DefaultFatal; >>> def err_missing_module_name : Error< >>> >>> Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=250577&r1=250576&r2=250577&view=diff >>> >>> == >>> --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original) >>> +++ cfe/trunk/lib/Frontend/Compiler
Re: [clang-tools-extra] r250509 - Fix overlapping replacements in clang-tidy.
Using these as the default comparison operators might not make much sense, as they don't take into account all the fields (they only look at ClangTidyError::Message). But here I just wanted to mimic existing behavior, so honestly I don't know. I implemented equality with !<&&!< to improve maintainability. If someone ever wants to modify LessClangTidyError, EqualClangTidyError will still be consistent with the new definition without any additional work. Moreover, LessClangTidyError is used to sort, while EqualClangTidyError is used by std::unique (a linear amount of times), so the extra work shouldn't be too bad for the performance. On Fri, Oct 16, 2015 at 10:50 PM, David Blaikie wrote: > > > On Fri, Oct 16, 2015 at 4:43 AM, Angel Garcia Gomez via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: angelgarcia >> Date: Fri Oct 16 06:43:49 2015 >> New Revision: 250509 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=250509&view=rev >> Log: >> Fix overlapping replacements in clang-tidy. >> >> Summary: Prevent clang-tidy from applying fixes to errors that overlap >> with other errors' fixes, with one exception: if one fix is completely >> contained inside another one, then we can apply the big one. >> >> Reviewers: bkramer, klimek >> >> Subscribers: djasper, cfe-commits, alexfh >> >> Differential Revision: http://reviews.llvm.org/D13516 >> >> Modified: >> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp >> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h >> >> clang-tools-extra/trunk/unittests/clang-tidy/OverlappingReplacementsTest.cpp >> >> Modified: >> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=250509&r1=250508&r2=250509&view=diff >> >> == >> --- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp >> (original) >> +++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp >> Fri Oct 16 06:43:49 2015 >> @@ -22,8 +22,8 @@ >> #include "clang/Basic/DiagnosticOptions.h" >> #include "clang/Frontend/DiagnosticRenderer.h" >> #include "llvm/ADT/SmallString.h" >> -#include >> #include >> +#include >> using namespace clang; >> using namespace tidy; >> >> @@ -146,8 +146,7 @@ static llvm::Regex ConsumeGlob(StringRef >> } >> >> GlobList::GlobList(StringRef Globs) >> -: Positive(!ConsumeNegativeIndicator(Globs)), >> - Regex(ConsumeGlob(Globs)), >> +: Positive(!ConsumeNegativeIndicator(Globs)), >> Regex(ConsumeGlob(Globs)), >>NextGlob(Globs.empty() ? nullptr : new GlobList(Globs)) {} >> >> bool GlobList::contains(StringRef S, bool Contains) { >> @@ -222,9 +221,7 @@ const ClangTidyOptions &ClangTidyContext >>return CurrentOptions; >> } >> >> -void ClangTidyContext::setCheckProfileData(ProfileData *P) { >> - Profile = P; >> -} >> +void ClangTidyContext::setCheckProfileData(ProfileData *P) { Profile = >> P; } >> >> GlobList &ClangTidyContext::getChecksFilter() { >>assert(CheckFilter != nullptr); >> @@ -296,16 +293,16 @@ void ClangTidyDiagnosticConsumer::Handle >>// This is a compiler diagnostic without a warning option. Assign >> check >>// name based on its level. >>switch (DiagLevel) { >> -case DiagnosticsEngine::Error: >> -case DiagnosticsEngine::Fatal: >> - CheckName = "clang-diagnostic-error"; >> - break; >> -case DiagnosticsEngine::Warning: >> - CheckName = "clang-diagnostic-warning"; >> - break; >> -default: >> - CheckName = "clang-diagnostic-unknown"; >> - break; >> + case DiagnosticsEngine::Error: >> + case DiagnosticsEngine::Fatal: >> +CheckName = "clang-diagnostic-error"; >> +break; >> + case DiagnosticsEngine::Warning: >> +CheckName = "clang-diagnostic-warning"; >> +break; >> + default: >> +CheckName = "clang-diagnostic-unknown"; >> +break; >>} >> } >> >> @@ -340,7 +337,7 @@ bool ClangTidyDiagnosticConsumer::passes >> unsigned LineNumber) >> const { >>if (Context.getGlobalOptions().LineFilter.empty()) >> return true; >> - for (const FileFilter& Filter : Context.getGlobalOptions().LineFilter) >> { >> + for (const FileFilter &Filter : Context.getGlobalOptions().LineFilter) >> { >> if (FileName.endswith(Filter.Name)) { >>if (Filter.LineRanges.empty()) >> return true; >> @@ -398,26 +395,147 @@ llvm::Regex *ClangTidyDiagnosticConsumer >>return HeaderFilter.get(); >> } >> >> +void ClangTidyDiagnosticConsumer::removeIncompatibleErrors( >> +SmallVectorImpl &Errors) const { >> + // Each error is modelled as the set of intervals in which it applies >> + // replacements. To detect overlapping replaceme
Re: [PATCH] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const
danielmarjamaki updated this revision to Diff 37728. danielmarjamaki marked an inline comment as done. danielmarjamaki added a comment. Fix FN for code: const char *ret(char *p) { return p ? p : ""; } http://reviews.llvm.org/D12359 Files: include/clang/AST/Decl.h include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/Sema.h lib/AST/Decl.cpp lib/Parse/ParseDecl.cpp lib/Parse/ParseExpr.cpp lib/Parse/ParseStmt.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaLambda.cpp lib/Sema/SemaOpenMP.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp lib/Serialization/ASTReaderDecl.cpp test/Analysis/NoReturn.m test/Analysis/bstring.c test/Analysis/casts.c test/Analysis/coverage.c test/Analysis/inlining/false-positive-suppression.c test/Analysis/inlining/inline-defensive-checks.c test/Analysis/inlining/path-notes.m test/Analysis/logical-ops.c test/Analysis/malloc.c test/Analysis/misc-ps-region-store.m test/Analysis/misc-ps.c test/Analysis/misc-ps.m test/Analysis/null-deref-ps.c test/Analysis/objc-boxing.m test/Analysis/pr22954.c test/Analysis/ptr-arith.c test/Analysis/retain-release-inline.m test/Analysis/retain-release.m test/Analysis/simple-stream-checks.c test/Analysis/stack-addr-ps.c test/Analysis/string.c test/Analysis/svalbuilder-logic.c test/Analysis/unix-fns.c test/CodeGen/builtins-arm-exclusive.c test/CodeGen/builtins-systemz.c test/FixIt/dereference-addressof.c test/Parser/MicrosoftExtensionsInlineAsm.c test/Parser/attributes.c test/Parser/declarators.c test/Parser/pointer-arithmetic.c test/Sema/annotate.c test/Sema/arm-neon-types.c test/Sema/atomic-ops.c test/Sema/builtin-assume-aligned.c test/Sema/builtin-assume.c test/Sema/builtins-arm-exclusive.c test/Sema/builtins-arm64-exclusive.c test/Sema/builtins.c test/Sema/builtins.cl test/Sema/c89.c test/Sema/compare.c test/Sema/crash-invalid-array.c test/Sema/empty1.c test/Sema/exprs.c test/Sema/function.c test/Sema/merge-decls.c test/Sema/ms-inline-asm.c test/Sema/pointer-subtract-compat.c test/Sema/transparent-union.c test/Sema/typecheck-binop.c test/Sema/typo-correction.c test/Sema/uninit-variables.c test/Sema/unused-expr.c test/Sema/varargs-x86-64.c test/Sema/warn-logical-not-compare.c test/Sema/warn-nonconst-parameter.c test/Sema/warn-sizeof-arrayarg.c test/Sema/warn-strncat-size.c test/Sema/warn-thread-safety-analysis.c test/Sema/warn-type-safety-mpi-hdf5.c test/SemaObjC/nullability.m test/SemaObjC/uninit-variables.m test/SemaOpenCL/address-spaces.cl test/SemaOpenCL/cond.cl test/SemaOpenCL/event_t_overload.cl Index: test/SemaOpenCL/event_t_overload.cl === --- test/SemaOpenCL/event_t_overload.cl +++ test/SemaOpenCL/event_t_overload.cl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 %s -verify -pedantic -Wno-nonconst-parameter -fsyntax-only void __attribute__((overloadable)) foo(event_t, __local char *); // expected-note {{candidate function not viable: no known conversion from '__global int *' to '__local char *' for 2nd argument}} void __attribute__((overloadable)) foo(event_t, __local float *); // expected-note {{candidate function not viable: no known conversion from '__global int *' to '__local float *' for 2nd argument}} Index: test/SemaOpenCL/cond.cl === --- test/SemaOpenCL/cond.cl +++ test/SemaOpenCL/cond.cl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 %s -verify -pedantic -Wno-nonconst-parameter -fsyntax-only typedef unsigned char uchar; typedef unsigned char uchar2 __attribute__((ext_vector_type(2))); Index: test/SemaOpenCL/address-spaces.cl === --- test/SemaOpenCL/address-spaces.cl +++ test/SemaOpenCL/address-spaces.cl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 %s -verify -pedantic -Wno-nonconst-parameter -fsyntax-only __constant int ci = 1; Index: test/SemaObjC/uninit-variables.m === --- test/SemaObjC/uninit-variables.m +++ test/SemaObjC/uninit-variables.m @@ -36,7 +36,7 @@ } } -int test_abort_on_exceptions(int y, NSException *e, NSString *s, int *z, ...) { +int test_abort_on_exceptions(int y, NSException *e, NSString *s, const int *z, ...) { int x; // expected-note {{initialize the variable 'x' to silence this warning}} if (y == 1) { va_list alist; Index: test/SemaObjC/nullability.m === --- test/SemaObjC/nullability.m +++ test/SemaObjC/nullability.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -fblocks -Woverriding-method-mismatch -Wno-nullability-de
Re: [PATCH] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const
danielmarjamaki added a comment. In http://reviews.llvm.org/D12359#233152, @sberg wrote: > causes false positive for > > char * f(char *); > char * g(char * p) { return f(p); } > Sorry for replying this late. This should work in latest patch. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:201 @@ -200,1 +200,3 @@ +def warn_nonconst_parameter : Warning<"parameter %0 can be const">, + InGroup, DefaultIgnore; def warn_unused_variable : Warning<"unused variable %0">, aaron.ballman wrote: > > I disagree about this. Normal usage is to enable as much warnings as you > > can. > > > > Is it possible for you to show a document, discussion or something that > > backs your claim? > > Searching through the Clang email archives yields: > > http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20150504/128373.html > http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140922/115379.html > > and others as well. This has been the de facto bar for as long as I've been > contributing. ok thanks for looking it up. I will try to fix all the test cases. Comment at: lib/Parse/ParseExpr.cpp:176 @@ +175,3 @@ + if (auto *B = dyn_cast(ER.get())) { +if (B->isAssignmentOp() || B->isAdditiveOp()) { + MarkNonConstUse(B->getLHS()); aaron.ballman wrote: > > basic idea is that p can't be const here: > ``` > void f(int *p) { > int *q = p + 1; > // ... > } > ``` > But it could be const here: > ``` > void f(int *p) { > const *q = p + 1; > } > ``` > I am not certain that addition, by itself, is sufficient to say the use is > non-const. At the least, this could have some comments explaining the > rationale with a FIXME. that is not by intention. There is no nonconst use if lhs is a const pointer. I will investigate. Comment at: lib/Parse/ParseExpr.cpp:176 @@ +175,3 @@ + Expr *E = ER.get()->IgnoreParenCasts(); + if (auto *B = dyn_cast(E)) { +if (B->isAssignmentOp()) { it's handled better now. Comment at: lib/Parse/ParseExpr.cpp:181 @@ +180,3 @@ + isa(E) || + isa(E) || + isa(E)) { yes. dontwarn9 was just a test.. if a nonconst pointer is returned then the parameter can't be const. I have corrected the test, see return6 . I will add a new test in the next iteration when a const pointer is returned. Comment at: lib/Parse/ParseStmt.cpp:376 @@ +375,3 @@ +// Mark symbols in r-value expression as written. +void Parser::MarkNonConstUse(Expr *E) { + E = E->IgnoreParenCasts(); aaron.ballman wrote: > > This is called from the Parser only. > > So will this still properly diagnose the same cases from a serialized AST? I don't know what this "serialized AST" is that you are talking about. All I know is the -ast-dump and that flag is only intended as a debugging aid as far as I know. If I just run "clang -cc1 -Wnonconst-parameter somefile.c" then it does not serialize does it? So what flags do I use to serialize etc? I would appreciate if you can show me a command that will cause FP. So I can look at it. I believe that we can't put this in the Sema only. The parser knows better how the result is used and can set "nonconstuse" properly for expressions. For instance I don't want to mark all pointer additions as "nonconstuse" just because some of them are "nonconstuse". http://reviews.llvm.org/D12359 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r250694 - Added new options to ClangFormat VSIX package.
Author: mkurdej Date: Mon Oct 19 05:08:35 2015 New Revision: 250694 URL: http://llvm.org/viewvc/llvm-project?rev=250694&view=rev Log: Added new options to ClangFormat VSIX package. Summary: Added new options to ClangFormat VSIX package: * fallback-style * assume-filename * sort-includes. Changed version to 1.1 (otherwise one couldn't update). Fixed clang-format escaping of XML reserved characters. Reviewers: hans, aaron.ballman, klimek, rnk, zturner Subscribers: djasper, cfe-commits Differential Revision: http://reviews.llvm.org/D13549 Modified: cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs cfe/trunk/tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs Modified: cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs?rev=250694&r1=250693&r2=250694&view=diff == --- cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs (original) +++ cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs Mon Oct 19 05:08:35 2015 @@ -19,10 +19,10 @@ using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.TextManager.Interop; using System; +using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.IO; -using System.Reflection; using System.Runtime.InteropServices; using System.Xml.Linq; @@ -32,13 +32,53 @@ namespace LLVM.ClangFormat [CLSCompliant(false), ComVisible(true)] public class OptionPageGrid : DialogPage { -private string style = "File"; +private string assumeFilename = ""; +private string fallbackStyle = "LLVM"; +private bool sortIncludes = false; +private string style = "file"; + +public class StyleConverter : TypeConverter +{ +protected ArrayList values; +public StyleConverter() +{ +// Initializes the standard values list with defaults. +values = new ArrayList(new string[] { "file", "Chromium", "Google", "LLVM", "Mozilla", "WebKit" }); +} + +public override bool GetStandardValuesSupported(ITypeDescriptorContext context) +{ +return true; +} + +public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) +{ +return new StandardValuesCollection(values); +} + +public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) +{ +if (sourceType == typeof(string)) +return true; + +return base.CanConvertFrom(context, sourceType); +} + +public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) +{ +string s = value as string; +if (s == null) +return base.ConvertFrom(context, culture, value); + +return value; +} +} [Category("LLVM/Clang")] [DisplayName("Style")] [Description("Coding style, currently supports:\n" + - " - Predefined styles ('LLVM', 'Google', 'Chromium', 'Mozilla').\n" + - " - 'File' to search for a YAML .clang-format or _clang-format\n" + + " - Predefined styles ('LLVM', 'Google', 'Chromium', 'Mozilla', 'WebKit').\n" + + " - 'file' to search for a YAML .clang-format or _clang-format\n" + "configuration file.\n" + " - A YAML configuration snippet.\n\n" + "'File':\n" + @@ -48,11 +88,81 @@ namespace LLVM.ClangFormat " The content of a .clang-format configuration file, as string.\n" + " Example: '{BasedOnStyle: \"LLVM\", IndentWidth: 8}'\n\n" + "See also: http://clang.llvm.org/docs/ClangFormatStyleOptions.html.";)] +[TypeConverter(typeof(StyleConverter))] public string Style { get { return style; } set { style = value; } } + +public sealed class FilenameConverter : TypeConverter +{ +public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) +{ +if (sourceType == typeof(string)) +return true; + +return base.CanConvertFrom(context, sourceType); +} + +public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) +{ +string s = value as string; +
Re: [PATCH] D13852: clang-format: Use pipes instead of temporary files for most lit tests.
klimek accepted this revision. klimek added a reviewer: klimek. klimek added a comment. This revision is now accepted and ready to land. I'd slightly prefer if the commands were still on their own line (via escaped newlines if that's possible), but lg. http://reviews.llvm.org/D13852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r248782 - clang-format: Extend #include sorting functionality
Hm, seems to me that this is broken either way. If config.h remains first, that is good, but the main #include is unlikely to remain second. I think we should give the main #include a non-zero #include category and then properly configure config.h to be before that. I'll try to get to that this week. On Sun, Oct 18, 2015 at 6:40 PM, Nico Weber wrote: > On Tue, Sep 29, 2015 at 12:53 AM, Daniel Jasper via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: djasper >> Date: Tue Sep 29 02:53:08 2015 >> New Revision: 248782 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=248782&view=rev >> Log: >> clang-format: Extend #include sorting functionality >> >> Recognize the main module header as well as different #include categories. >> This should now mimic the behavior of llvm/utils/sort_includes.py as >> well as clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp very >> closely. >> >> Modified: >> cfe/trunk/include/clang/Format/Format.h >> cfe/trunk/lib/Format/Format.cpp >> cfe/trunk/tools/clang-format/ClangFormat.cpp >> cfe/trunk/unittests/Format/SortIncludesTest.cpp >> >> Modified: cfe/trunk/include/clang/Format/Format.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=248782&r1=248781&r2=248782&view=diff >> >> == >> --- cfe/trunk/include/clang/Format/Format.h (original) >> +++ cfe/trunk/include/clang/Format/Format.h Tue Sep 29 02:53:08 2015 >> @@ -259,6 +259,21 @@ struct FormatStyle { >>/// For example: BOOST_FOREACH. >>std::vector ForEachMacros; >> >> + /// \brief Regular expressions denoting the different #include >> categories used >> + /// for ordering #includes. >> + /// >> + /// These regular expressions are matched against the filename of an >> include >> + /// (including the <> or "") in order. The value belonging to the first >> + /// matching regular expression is assigned and #includes are sorted >> first >> + /// according to increasing category number and then alphabetically >> within >> + /// each category. >> + /// >> + /// If none of the regular expressions match, UINT_MAX is assigned as >> + /// category. The main header for a source file automatically gets >> category 0, >> + /// so that it is kept at the beginning of the #includes >> + /// (http://llvm.org/docs/CodingStandards.html#include-style). >> + std::vector> IncludeCategories; >> + >>/// \brief Indent case labels one level from the switch statement. >>/// >>/// When \c false, use the same indentation level as for the switch >> statement. >> >> Modified: cfe/trunk/lib/Format/Format.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=248782&r1=248781&r2=248782&view=diff >> >> == >> --- cfe/trunk/lib/Format/Format.cpp (original) >> +++ cfe/trunk/lib/Format/Format.cpp Tue Sep 29 02:53:08 2015 >> @@ -13,6 +13,7 @@ >> /// >> >> >> //===--===// >> >> +#include "clang/Format/Format.h" >> #include "ContinuationIndenter.h" >> #include "TokenAnnotator.h" >> #include "UnwrappedLineFormatter.h" >> @@ -21,7 +22,6 @@ >> #include "clang/Basic/Diagnostic.h" >> #include "clang/Basic/DiagnosticOptions.h" >> #include "clang/Basic/SourceManager.h" >> -#include "clang/Format/Format.h" >> #include "clang/Lex/Lexer.h" >> #include "llvm/ADT/STLExtras.h" >> #include "llvm/Support/Allocator.h" >> @@ -375,6 +375,9 @@ FormatStyle getLLVMStyle() { >>LLVMStyle.ForEachMacros.push_back("foreach"); >>LLVMStyle.ForEachMacros.push_back("Q_FOREACH"); >>LLVMStyle.ForEachMacros.push_back("BOOST_FOREACH"); >> + LLVMStyle.IncludeCategories = {{"^\"(llvm|llvm-c|clang|clang-c)/", 2}, >> + {"^(<|\"(gtest|isl|json)/)", 3}, >> + {".*", 1}}; >>LLVMStyle.IndentCaseLabels = false; >>LLVMStyle.IndentWrappedFunctionNames = false; >>LLVMStyle.IndentWidth = 2; >> @@ -423,6 +426,7 @@ FormatStyle getGoogleStyle(FormatStyle:: >>GoogleStyle.AlwaysBreakTemplateDeclarations = true; >>GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true; >>GoogleStyle.DerivePointerAlignment = true; >> + GoogleStyle.IncludeCategories = {{"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", >> 3}}; >>GoogleStyle.IndentCaseLabels = true; >>GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false; >>GoogleStyle.ObjCSpaceAfterProperty = false; >> @@ -1575,7 +1579,7 @@ struct IncludeDirective { >>StringRef Filename; >>StringRef Text; >>unsigned Offset; >> - bool IsAngled; >> + unsigned Category; >> }; >> >> } // end anonymous namespace >> @@ -1605,7 +1609,8 @@ static void sortIncludes(const FormatSty >>for (unsigned i = 0, e = Includes.size(); i != e; ++i) >> Indices.push_back(i); >>std::sort(Indices.begin(),
Re: [PATCH] D13000: [libclang] Expose AutoType
klimek accepted this revision. klimek added a comment. This revision is now accepted and ready to land. Thx Milinan; this also looks fine from a binary compatibility perspective ... http://reviews.llvm.org/D13000 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13001: [libclang] Handle AutoType in clang_getTypeDeclaration
klimek added a comment. +1 to "not tested before" not implying "doesn't need tests" :) http://reviews.llvm.org/D13001 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D13861: [x86] fix wrong maskload/store intrinsic definitions in avxintrin.h (follow up of D13776).
andreadb created this revision. andreadb added reviewers: bruno, mkuper, delena, qcolombet. andreadb added a subscriber: cfe-commits. Hi, This patch is a follow up of D13776. According to the Intel documentation, the mask operand of a maskload and maskstore intrinsics is always a vector of packed integer/long integer values. This patch introduces the following two changes: 1) It fixes the avx maskload/store intrinsic definitions in avxintrin.h; 2) It changes BuiltinsX86.def to match the correct gcc definitions for avx maskload/store (see D13776 for more details). Please let me know if okay to submit. Thanks, Andrea http://reviews.llvm.org/D13861 Files: include/clang/Basic/BuiltinsX86.def lib/Headers/avxintrin.h test/CodeGen/builtins-x86.c Index: test/CodeGen/builtins-x86.c === --- test/CodeGen/builtins-x86.c +++ test/CodeGen/builtins-x86.c @@ -465,14 +465,14 @@ __builtin_ia32_movntdq256(tmp_V4LLip, tmp_V4LLi); __builtin_ia32_movntpd256(tmp_dp, tmp_V4d); __builtin_ia32_movntps256(tmp_fp, tmp_V8f); - tmp_V2d = __builtin_ia32_maskloadpd(tmp_V2dCp, tmp_V2d); - tmp_V4f = __builtin_ia32_maskloadps(tmp_V4fCp, tmp_V4f); - tmp_V4d = __builtin_ia32_maskloadpd256(tmp_V4dCp, tmp_V4d); - tmp_V8f = __builtin_ia32_maskloadps256(tmp_V8fCp, tmp_V8f); - __builtin_ia32_maskstorepd(tmp_V2dp, tmp_V2d, tmp_V2d); - __builtin_ia32_maskstoreps(tmp_V4fp, tmp_V4f, tmp_V4f); - __builtin_ia32_maskstorepd256(tmp_V4dp, tmp_V4d, tmp_V4d); - __builtin_ia32_maskstoreps256(tmp_V8fp, tmp_V8f, tmp_V8f); + tmp_V2d = __builtin_ia32_maskloadpd(tmp_V2dCp, tmp_V2LLi); + tmp_V4f = __builtin_ia32_maskloadps(tmp_V4fCp, tmp_V4i); + tmp_V4d = __builtin_ia32_maskloadpd256(tmp_V4dCp, tmp_V4LLi); + tmp_V8f = __builtin_ia32_maskloadps256(tmp_V8fCp, tmp_V8i); + __builtin_ia32_maskstorepd(tmp_V2dp, tmp_V2LLi, tmp_V2d); + __builtin_ia32_maskstoreps(tmp_V4fp, tmp_V4i, tmp_V4f); + __builtin_ia32_maskstorepd256(tmp_V4dp, tmp_V4LLi, tmp_V4d); + __builtin_ia32_maskstoreps256(tmp_V8fp, tmp_V8i, tmp_V8f); #ifdef USE_3DNOW tmp_V8c = __builtin_ia32_pavgusb(tmp_V8c, tmp_V8c); Index: lib/Headers/avxintrin.h === --- lib/Headers/avxintrin.h +++ lib/Headers/avxintrin.h @@ -835,53 +835,53 @@ /* Conditional load ops */ static __inline __m128d __DEFAULT_FN_ATTRS -_mm_maskload_pd(double const *__p, __m128d __m) +_mm_maskload_pd(double const *__p, __m128i __m) { - return (__m128d)__builtin_ia32_maskloadpd((const __v2df *)__p, (__v2df)__m); + return (__m128d)__builtin_ia32_maskloadpd((const __v2df *)__p, (__v2di)__m); } static __inline __m256d __DEFAULT_FN_ATTRS -_mm256_maskload_pd(double const *__p, __m256d __m) +_mm256_maskload_pd(double const *__p, __m256i __m) { return (__m256d)__builtin_ia32_maskloadpd256((const __v4df *)__p, - (__v4df)__m); + (__v4di)__m); } static __inline __m128 __DEFAULT_FN_ATTRS -_mm_maskload_ps(float const *__p, __m128 __m) +_mm_maskload_ps(float const *__p, __m128i __m) { - return (__m128)__builtin_ia32_maskloadps((const __v4sf *)__p, (__v4sf)__m); + return (__m128)__builtin_ia32_maskloadps((const __v4sf *)__p, (__v4si)__m); } static __inline __m256 __DEFAULT_FN_ATTRS -_mm256_maskload_ps(float const *__p, __m256 __m) +_mm256_maskload_ps(float const *__p, __m256i __m) { - return (__m256)__builtin_ia32_maskloadps256((const __v8sf *)__p, (__v8sf)__m); + return (__m256)__builtin_ia32_maskloadps256((const __v8sf *)__p, (__v8si)__m); } /* Conditional store ops */ static __inline void __DEFAULT_FN_ATTRS -_mm256_maskstore_ps(float *__p, __m256 __m, __m256 __a) +_mm256_maskstore_ps(float *__p, __m256i __m, __m256 __a) { - __builtin_ia32_maskstoreps256((__v8sf *)__p, (__v8sf)__m, (__v8sf)__a); + __builtin_ia32_maskstoreps256((__v8sf *)__p, (__v8si)__m, (__v8sf)__a); } static __inline void __DEFAULT_FN_ATTRS -_mm_maskstore_pd(double *__p, __m128d __m, __m128d __a) +_mm_maskstore_pd(double *__p, __m128i __m, __m128d __a) { - __builtin_ia32_maskstorepd((__v2df *)__p, (__v2df)__m, (__v2df)__a); + __builtin_ia32_maskstorepd((__v2df *)__p, (__v2di)__m, (__v2df)__a); } static __inline void __DEFAULT_FN_ATTRS -_mm256_maskstore_pd(double *__p, __m256d __m, __m256d __a) +_mm256_maskstore_pd(double *__p, __m256i __m, __m256d __a) { - __builtin_ia32_maskstorepd256((__v4df *)__p, (__v4df)__m, (__v4df)__a); + __builtin_ia32_maskstorepd256((__v4df *)__p, (__v4di)__m, (__v4df)__a); } static __inline void __DEFAULT_FN_ATTRS -_mm_maskstore_ps(float *__p, __m128 __m, __m128 __a) +_mm_maskstore_ps(float *__p, __m128i __m, __m128 __a) { - __builtin_ia32_maskstoreps((__v4sf *)__p, (__v4sf)__m, (__v4sf)__a); + __builtin_ia32_maskstoreps((__v4sf *)__p, (__v4si)__m, (__v4sf)__a); } /* Cacheability support ops */ Index: include/clang/Basic/BuiltinsX86.def ==
Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision
danielmarjamaki added a comment. > It might be more useful if you could print the paths on which the errors > occurred (this could be done for text output with -analyzer-output=text) Sounds good. Is it possible to use it with scan-build? Comment at: lib/StaticAnalyzer/Checkers/CMakeLists.txt:29 @@ -28,2 +28,3 @@ ChrootChecker.cpp + ConversionChecker.cpp ClangCheckers.cpp hmm.. I will move this down 1 line http://reviews.llvm.org/D13126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [Diffusion] rL248379: Refactor library decision for -fopenmp support from Darwin into a
emaste added a subscriber: emaste. Users: joerg (Author, Auditor) 3.7-release (Auditor) cfe-commits (Auditor) tstellarAMD (Auditor) http://reviews.llvm.org/rL248379 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision
danielmarjamaki added a comment. In http://reviews.llvm.org/D13126#270193, @danielmarjamaki wrote: > > It might be more useful if you could print the paths on which the errors > > occurred (this could be done for text output with -analyzer-output=text) > > > Sounds good. Is it possible to use it with scan-build? Sorry. I saw that this has been discussed recently on cfe-dev. http://lists.llvm.org/pipermail/cfe-dev/2015-October/045292.html http://reviews.llvm.org/D13126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D13871: Add modernize-use-default check to clang-tidy.
angelgarcia created this revision. angelgarcia added a reviewer: klimek. angelgarcia added subscribers: cfe-commits, alexfh. Add a check that replaces empty bodies of special member functions with '= default;'. For now, it is only implemented for the default constructor and the destructor, which are the easier cases. The copy-constructor and the copy-assignment operator cases will be implemented later. I applied this check to the llvm code base and found 627 warnings (385 in llvm, 9 in compiler-rt, 220 in clang and 13 in clang-tools-extra). Applying the fixes didn't break any build or test, it only caused a -Wpedantic warning in lib/Target/Mips/MipsOptionRecord.h:33 becaused it replaced virtual ~MipsOptionRecord(){}; to virtual ~MipsOptionRecord()= default;; http://reviews.llvm.org/D13871 Files: clang-tidy/modernize/CMakeLists.txt clang-tidy/modernize/ModernizeTidyModule.cpp clang-tidy/modernize/UseDefaultCheck.cpp clang-tidy/modernize/UseDefaultCheck.h docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/modernize-use-default.rst test/clang-tidy/modernize-use-default.cpp Index: test/clang-tidy/modernize-use-default.cpp === --- /dev/null +++ test/clang-tidy/modernize-use-default.cpp @@ -0,0 +1,137 @@ +// RUN: %python %S/check_clang_tidy.py %s modernize-use-default %t + +class A { +public: + A(); + ~A(); +}; + +A::A() {} +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a default constructor/destructor [modernize-use-default] +// CHECK-FIXES: A::A() = default; +A::~A() {} +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' +// CHECK-FIXES: A::~A() = default; + +// Inline definitions. +class B { +public: + B() {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' + // CHECK-FIXES: B() = default; + ~B() {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' + // CHECK-FIXES: ~B() = default; +}; + +void f(); + +class C { +public: + // Non-empty constructor body. + C() { f(); } + // Non-empty destructor body. + ~C() { f(); } +}; + +class D { +public: + // Constructor with initializer. + D() : Field(5) {} + // Constructor with arguments. + D(int Arg1, int Arg2) {} + int Field; +}; + +// Private constructor/destructor. +class E { + E() {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' + // CHECK-FIXES: E() = default; + ~E() {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' + // CHECK-FIXES: ~E() = default; +}; + +// struct. +struct F { + F() {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' + // CHECK-FIXES: F() = default; + ~F() {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' + // CHECK-FIXES: F() = default; +}; + +// Deleted constructor/destructor. +class G { +public: + G() = delete; + ~G() = delete; +}; + +// Do not remove other keywords. +class H { +public: + explicit H() {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' + // CHECK-FIXES: explicit H() = default; + virtual ~H() {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' + // CHECK-FIXES: virtual ~H() = default; +}; + +// Nested class. +struct I { + struct II { +II() {} +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' +// CHECK-FIXES: II() = default; +~II() {} +// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' +// CHECK-FIXES: ~II() = default; + }; + int Int; +}; + +// Class template. +template +class J { +public: + J() {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' + // CHECK-FIXES: J() = default; + ~J() {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' + // CHECK-FIXES: ~J() = default; +}; + +// Non user-provided constructor/destructor. +struct K { + int Int; +}; +void g() { + K *PtrK = new K(); + PtrK->~K(); + delete PtrK; +} + +// Already using default. +struct L { + L() = default; + ~L() = default; +}; +struct M { + M(); + ~M(); +}; +M::M() = default; +M::~M() = default; + +// Delegating constructor and overriden destructor. +struct N : H { + N() : H() {} + ~N() override {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' + // CHECK-FIXES: ~N() override = default; +}; Index: docs/clang-tidy/checks/modernize-use-default.rst === --- /dev/null +++ docs/clang-tidy/checks/modernize-use-default.rst @@ -0,0 +1,27 @@ +modernize-use-default += + +This check replaces default bodies of special member functions with ``= +default;``. The explicitly defaulted function declarations enable more +opportunities in optimization, because the compiler might treat explicitly +defaulted functions as trivial. + +.. code-block:: c++ + + struct A { +A() {} +~A(); + }; + A::~A() {} + + // becomes + + struct A { +A() = default; +~A(); + }; + A::~A() = default; + +.. note:: + Copy-constructor,
r250705 - Sample Profiles - Fix location of binary encoding documentation. NFC.
Author: dnovillo Date: Mon Oct 19 10:53:17 2015 New Revision: 250705 URL: http://llvm.org/viewvc/llvm-project?rev=250705&view=rev Log: Sample Profiles - Fix location of binary encoding documentation. NFC. Modified: cfe/trunk/docs/UsersManual.rst Modified: cfe/trunk/docs/UsersManual.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=250705&r1=250704&r2=250705&view=diff == --- cfe/trunk/docs/UsersManual.rst (original) +++ cfe/trunk/docs/UsersManual.rst Mon Oct 19 10:53:17 2015 @@ -1380,7 +1380,7 @@ Sample Profile Text Format This section describes the ASCII text format for sampling profiles. It is, arguably, the easiest one to generate. If you are interested in generating any of the other two, consult the ``ProfileData`` library in in LLVM's source tree -(specifically, ``llvm/lib/ProfileData/SampleProfWriter.cpp``). +(specifically, ``include/llvm/ProfileData/SampleProfReader.h``). .. code-block:: console ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13852: clang-format: Use pipes instead of temporary files for most lit tests.
thakis closed this revision. thakis added a comment. Landed in r250706 (with rewrapped lines). Thanks! http://reviews.llvm.org/D13852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r250706 - clang-format: Use pipes instead of temporary files for most lit tests.
Author: nico Date: Mon Oct 19 11:21:29 2015 New Revision: 250706 URL: http://llvm.org/viewvc/llvm-project?rev=250706&view=rev Log: clang-format: Use pipes instead of temporary files for most lit tests. This makes the format tests look more like most other FileCheck tests in clang. The multiple-inputs tests still use temp files, to make sure that the file input code in clang-format stays tested. Stop stripping out the comment lines in style-on-command-line.cpp as they don't get in the way and it makes the test simpler. Also remove 2>&1s on the tests in that file that don't need it. http://reviews.llvm.org/D13852 Modified: cfe/trunk/test/Format/basic.cpp cfe/trunk/test/Format/cursor.cpp cfe/trunk/test/Format/disable-format.cpp cfe/trunk/test/Format/incomplete.cpp cfe/trunk/test/Format/language-detection.cpp cfe/trunk/test/Format/line-ranges.cpp cfe/trunk/test/Format/ranges.cpp cfe/trunk/test/Format/style-on-command-line.cpp cfe/trunk/test/Format/xmloutput.cpp Modified: cfe/trunk/test/Format/basic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/basic.cpp?rev=250706&r1=250705&r2=250706&view=diff == --- cfe/trunk/test/Format/basic.cpp (original) +++ cfe/trunk/test/Format/basic.cpp Mon Oct 19 11:21:29 2015 @@ -1,6 +1,5 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: clang-format -style=LLVM -i %t.cpp -// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style=LLVM \ +// RUN: | FileCheck -strict-whitespace %s // CHECK: {{^int\ \*i;}} int * i ; Modified: cfe/trunk/test/Format/cursor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/cursor.cpp?rev=250706&r1=250705&r2=250706&view=diff == --- cfe/trunk/test/Format/cursor.cpp (original) +++ cfe/trunk/test/Format/cursor.cpp Mon Oct 19 11:21:29 2015 @@ -1,6 +1,5 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t2.cpp -// RUN: clang-format -style=LLVM %t2.cpp -cursor=6 > %t.cpp -// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style=LLVM -cursor=6 \ +// RUN: | FileCheck -strict-whitespace %s // CHECK: {{^\{ "Cursor": 4, }} // CHECK: {{^int\ \i;$}} inti; Modified: cfe/trunk/test/Format/disable-format.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/disable-format.cpp?rev=250706&r1=250705&r2=250706&view=diff == --- cfe/trunk/test/Format/disable-format.cpp (original) +++ cfe/trunk/test/Format/disable-format.cpp Mon Oct 19 11:21:29 2015 @@ -1,6 +1,5 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: clang-format -style=none -i %t.cpp -// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style=none \ +// RUN: | FileCheck -strict-whitespace %s // CHECK: int i; int i; Modified: cfe/trunk/test/Format/incomplete.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/incomplete.cpp?rev=250706&r1=250705&r2=250706&view=diff == --- cfe/trunk/test/Format/incomplete.cpp (original) +++ cfe/trunk/test/Format/incomplete.cpp Mon Oct 19 11:21:29 2015 @@ -1,6 +1,5 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t2.cpp -// RUN: clang-format -style=LLVM %t2.cpp -cursor=0 > %t.cpp -// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style=LLVM -cursor=0 \ +// RUN: | FileCheck -strict-whitespace %s // CHECK: {{"IncompleteFormat": true}} // CHECK: {{^int\ \i;$}} inti; Modified: cfe/trunk/test/Format/language-detection.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/language-detection.cpp?rev=250706&r1=250705&r2=250706&view=diff == --- cfe/trunk/test/Format/language-detection.cpp (original) +++ cfe/trunk/test/Format/language-detection.cpp Mon Oct 19 11:21:29 2015 @@ -1,7 +1,9 @@ -// RUN: grep -Ev "// *[A-Z0-9_]+:" %s > %t.js -// RUN: grep -Ev "// *[A-Z0-9_]+:" %s > %t.cpp -// RUN: clang-format -style=llvm %t.js | FileCheck -strict-whitespace -check-prefix=CHECK1 %s -// RUN: clang-format -style=llvm %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK2 %s +// RUN: grep -Ev "// *[A-Z0-9_]+:" %s \ +// RUN: | clang-format -style=llvm -assume-filename=foo.js \ +// RUN: | FileCheck -strict-whitespace -check-prefix=CHECK1 %s +// RUN: grep -Ev "// *[A-Z0-9_]+:" %s \ +// RUN: | clang-format -style=llvm -assume-filename=foo.cpp \ +// RUN: | FileCheck -strict-whitespace -check-prefix=CHECK2 %s // CHECK1: {{^a >>>= b;$}} // CHECK2: {{^a >> >= b;$}} a >>>= b; Modified: cfe/trunk/test/Format/line-ranges.cpp URL
Re: r248782 - clang-format: Extend #include sorting functionality
On Mon, Oct 19, 2015 at 4:24 AM, Daniel Jasper wrote: > Hm, seems to me that this is broken either way. If config.h remains first, > that is good, but the main #include is unlikely to remain second. > In practice, the first two lines are a block with two includes: config.h first and the main header seconds. Since clang-format doesn't move the first line around and since it does include-block-internal sorting only, it currently never reorders this first two-includes block. > I think we should give the main #include a non-zero #include category and > then properly configure config.h to be before that. I'll try to get to that > this week. > Sounds great, thanks! > > On Sun, Oct 18, 2015 at 6:40 PM, Nico Weber wrote: > >> On Tue, Sep 29, 2015 at 12:53 AM, Daniel Jasper via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Author: djasper >>> Date: Tue Sep 29 02:53:08 2015 >>> New Revision: 248782 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=248782&view=rev >>> Log: >>> clang-format: Extend #include sorting functionality >>> >>> Recognize the main module header as well as different #include >>> categories. >>> This should now mimic the behavior of llvm/utils/sort_includes.py as >>> well as clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp very >>> closely. >>> >>> Modified: >>> cfe/trunk/include/clang/Format/Format.h >>> cfe/trunk/lib/Format/Format.cpp >>> cfe/trunk/tools/clang-format/ClangFormat.cpp >>> cfe/trunk/unittests/Format/SortIncludesTest.cpp >>> >>> Modified: cfe/trunk/include/clang/Format/Format.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=248782&r1=248781&r2=248782&view=diff >>> >>> == >>> --- cfe/trunk/include/clang/Format/Format.h (original) >>> +++ cfe/trunk/include/clang/Format/Format.h Tue Sep 29 02:53:08 2015 >>> @@ -259,6 +259,21 @@ struct FormatStyle { >>>/// For example: BOOST_FOREACH. >>>std::vector ForEachMacros; >>> >>> + /// \brief Regular expressions denoting the different #include >>> categories used >>> + /// for ordering #includes. >>> + /// >>> + /// These regular expressions are matched against the filename of an >>> include >>> + /// (including the <> or "") in order. The value belonging to the >>> first >>> + /// matching regular expression is assigned and #includes are sorted >>> first >>> + /// according to increasing category number and then alphabetically >>> within >>> + /// each category. >>> + /// >>> + /// If none of the regular expressions match, UINT_MAX is assigned as >>> + /// category. The main header for a source file automatically gets >>> category 0, >>> + /// so that it is kept at the beginning of the #includes >>> + /// (http://llvm.org/docs/CodingStandards.html#include-style). >>> + std::vector> IncludeCategories; >>> + >>>/// \brief Indent case labels one level from the switch statement. >>>/// >>>/// When \c false, use the same indentation level as for the switch >>> statement. >>> >>> Modified: cfe/trunk/lib/Format/Format.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=248782&r1=248781&r2=248782&view=diff >>> >>> == >>> --- cfe/trunk/lib/Format/Format.cpp (original) >>> +++ cfe/trunk/lib/Format/Format.cpp Tue Sep 29 02:53:08 2015 >>> @@ -13,6 +13,7 @@ >>> /// >>> >>> >>> //===--===// >>> >>> +#include "clang/Format/Format.h" >>> #include "ContinuationIndenter.h" >>> #include "TokenAnnotator.h" >>> #include "UnwrappedLineFormatter.h" >>> @@ -21,7 +22,6 @@ >>> #include "clang/Basic/Diagnostic.h" >>> #include "clang/Basic/DiagnosticOptions.h" >>> #include "clang/Basic/SourceManager.h" >>> -#include "clang/Format/Format.h" >>> #include "clang/Lex/Lexer.h" >>> #include "llvm/ADT/STLExtras.h" >>> #include "llvm/Support/Allocator.h" >>> @@ -375,6 +375,9 @@ FormatStyle getLLVMStyle() { >>>LLVMStyle.ForEachMacros.push_back("foreach"); >>>LLVMStyle.ForEachMacros.push_back("Q_FOREACH"); >>>LLVMStyle.ForEachMacros.push_back("BOOST_FOREACH"); >>> + LLVMStyle.IncludeCategories = {{"^\"(llvm|llvm-c|clang|clang-c)/", 2}, >>> + {"^(<|\"(gtest|isl|json)/)", 3}, >>> + {".*", 1}}; >>>LLVMStyle.IndentCaseLabels = false; >>>LLVMStyle.IndentWrappedFunctionNames = false; >>>LLVMStyle.IndentWidth = 2; >>> @@ -423,6 +426,7 @@ FormatStyle getGoogleStyle(FormatStyle:: >>>GoogleStyle.AlwaysBreakTemplateDeclarations = true; >>>GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true; >>>GoogleStyle.DerivePointerAlignment = true; >>> + GoogleStyle.IncludeCategories = {{"^<.*\\.h>", 1}, {"^<.*", 2}, >>> {".*", 3}}; >>>GoogleStyle.IndentCaseLabels = true; >>>GoogleStyle.KeepE
Re: [PATCH] D13731: [RFC][Analyzer] Supporting function attributes in .model files.
pgousseau updated this revision to Diff 37765. pgousseau added a comment. Following Gabor's review: Remove changes to UncheckedReturn checker. Add a test using the NonNullParamChecker checker. Abstract the origin of the attributes. An analyzer option "faux-attributes" is added. This is 'false' by default and meant to prevent unnecessary parsing of model files. http://reviews.llvm.org/D13731 Files: include/clang/Analysis/AnalysisContext.h include/clang/Analysis/CodeInjector.h include/clang/StaticAnalyzer/Core/AnalyzerOptions.h include/clang/StaticAnalyzer/Frontend/FrontendActions.h include/clang/StaticAnalyzer/Frontend/ModelConsumer.h lib/Analysis/AnalysisDeclContext.cpp lib/Analysis/BodyFarm.cpp lib/Analysis/BodyFarm.h lib/StaticAnalyzer/Core/AnalysisManager.cpp lib/StaticAnalyzer/Core/AnalyzerOptions.cpp lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp lib/StaticAnalyzer/Frontend/FrontendActions.cpp lib/StaticAnalyzer/Frontend/ModelConsumer.cpp lib/StaticAnalyzer/Frontend/ModelInjector.cpp lib/StaticAnalyzer/Frontend/ModelInjector.h test/Analysis/Inputs/Models/modelFileHasAttributes.model test/Analysis/analyzer-config.c test/Analysis/analyzer-config.cpp test/Analysis/model-attributes.cpp Index: test/Analysis/model-attributes.cpp === --- /dev/null +++ test/Analysis/model-attributes.cpp @@ -0,0 +1,23 @@ +// This is testing the 'faux-attributes' analyzer option. +// The declaration of 'modelFileHasAttributes' found in modelFileHasAttributes.model has 'nonnull' attributes on the 2nd and 3rd parameter. +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -analyze -analyzer-checker=core -analyzer-config faux-attributes=true,model-path=%S/Inputs/Models %s -verify + +int modelFileHasAttributes(int * p0, int * p1, int * p2); + +int f0(int * x, int * y) { + int * p = 0; + modelFileHasAttributes(p, x, y); // no-warning + return 0; +} + +int f1(int * x, int * y) { + int * p = 0; + modelFileHasAttributes(x, p, y); // expected-warning{{Null pointer passed as an argument to a 'nonnull' parameter}} + return 0; +} + +int f2(int * x, int * y) { + int * p = 0; + modelFileHasAttributes(x, y, p); // expected-warning{{Null pointer passed as an argument to a 'nonnull' parameter}} + return 0; +} Index: test/Analysis/analyzer-config.cpp === --- test/Analysis/analyzer-config.cpp +++ test/Analysis/analyzer-config.cpp @@ -24,6 +24,7 @@ // CHECK-NEXT: c++-template-inlining = true // CHECK-NEXT: cfg-conditional-static-initializers = true // CHECK-NEXT: cfg-temporary-dtors = false +// CHECK-NEXT: faux-attributes = false // CHECK-NEXT: faux-bodies = true // CHECK-NEXT: graph-trim-interval = 1000 // CHECK-NEXT: inline-lambdas = true @@ -37,4 +38,4 @@ // CHECK-NEXT: mode = deep // CHECK-NEXT: region-store-small-struct-limit = 2 // CHECK-NEXT: [stats] -// CHECK-NEXT: num-entries = 19 +// CHECK-NEXT: num-entries = 20 Index: test/Analysis/analyzer-config.c === --- test/Analysis/analyzer-config.c +++ test/Analysis/analyzer-config.c @@ -13,6 +13,7 @@ // CHECK: [config] // CHECK-NEXT: cfg-conditional-static-initializers = true // CHECK-NEXT: cfg-temporary-dtors = false +// CHECK-NEXT: faux-attributes = false // CHECK-NEXT: faux-bodies = true // CHECK-NEXT: graph-trim-interval = 1000 // CHECK-NEXT: inline-lambdas = true @@ -26,5 +27,5 @@ // CHECK-NEXT: mode = deep // CHECK-NEXT: region-store-small-struct-limit = 2 // CHECK-NEXT: [stats] -// CHECK-NEXT: num-entries = 14 +// CHECK-NEXT: num-entries = 15 Index: test/Analysis/Inputs/Models/modelFileHasAttributes.model === --- /dev/null +++ test/Analysis/Inputs/Models/modelFileHasAttributes.model @@ -0,0 +1 @@ +int modelFileHasAttributes(int * p0, int * p1, int * p2 __attribute__((nonnull))) __attribute__((nonnull(2))); \ No newline at end of file Index: lib/StaticAnalyzer/Frontend/ModelInjector.h === --- lib/StaticAnalyzer/Frontend/ModelInjector.h +++ lib/StaticAnalyzer/Frontend/ModelInjector.h @@ -45,6 +45,7 @@ ModelInjector(CompilerInstance &CI); Stmt *getBody(const FunctionDecl *D) override; Stmt *getBody(const ObjCMethodDecl *D) override; + FunctionDecl *getModelDecl(const FunctionDecl *D) override; private: /// \brief Synthesize a body for a declaration @@ -67,6 +68,9 @@ // FIXME: double memoization is redundant, with memoization both here and in // BodyFarm. llvm::StringMap Bodies; + + // Store the model's function declaration if provided. + llvm::StringMap Decls; }; } } Index: lib/StaticAnalyzer/Frontend/ModelInjector.cpp === --- lib/StaticAnalyzer/Frontend/ModelInjector.cpp +++ lib/StaticAnalyzer/Frontend/ModelInj
Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.
hans added a comment. This is now part of the latest snapshot at http://llvm.org/builds/ Seems to work :-) I had to dig around a bit to figure out where these settings are actually exposed. Should we mention that in the documentation somewhere? Actually, do we even have any documentation for this plugin? http://reviews.llvm.org/D13549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13582: [DEBUG INFO] Emit debug info for type used in explicit cast only.
rjmccall added a comment. That looks great, thank you. http://reviews.llvm.org/D13582 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.
On Mon, Oct 19, 2015 at 7:45 PM, Hans Wennborg via cfe-commits < cfe-commits@lists.llvm.org> wrote: > hans added a comment. > > This is now part of the latest snapshot at http://llvm.org/builds/ > Seems to work :-) > > I had to dig around a bit to figure out where these settings are actually > exposed. Should we mention that in the documentation somewhere? Actually, > do we even have any documentation for this plugin? > > Options are exposed in Tools->Options->LLVM/Clang->ClangFormat it seems (which is very nice btw!) ismail ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13787: [clang-tidy] add check cppcoreguidelines-pro-type-vararg-use
sbenza added inline comments. Comment at: clang-tidy/cppcoreguidelines/ProTypeVarargUseCheck.cpp:20 @@ +19,3 @@ +void ProTypeVarargUseCheck::registerMatchers(MatchFinder *Finder) { + Finder->addMatcher(callExpr(callee(functionDecl(isVariadic(.bind("expr"), this); +} mgehre wrote: > sbenza wrote: > > The guideline says that we should also issue a diagnostics for uses of > > va_list/va_start/va_arg. > This is handled by http://reviews.llvm.org/D13785 I see. They are split between vararg "def" and "use". Comment at: test/clang-tidy/cppcoreguidelines-pro-type-vararg-use.cpp:14 @@ +13,3 @@ + +void check() { + f_vararg(1, 7, 9); mgehre wrote: > sbenza wrote: > > how does this handle SFINAE style ... uses? > > The guideline mentions this case as "useful" so we should try to avoid > > warning on it. > I saw the note in the guidelines, but frankly I don't quite get the use case. > Do you have an example or reference for me? ... has the lowest rank for overload resolution. You can use it as a default case. Example: template void CallFooIfAvailableImpl(T& t, decltype(t.foo())*) { t->foo(); } template void CallFooIfAvailableImpl(T& t, ...) { // nothing } template void CallFooIfAvailable(T& t) { CallFooIfAvailableImpl(t, 0); } It is also useful when making traits. Eg: https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Member_Detector#Solution_and_Sample_Code http://reviews.llvm.org/D13787 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13001: [libclang] Handle AutoType in clang_getTypeDeclaration
milianw added a comment. Adding tests wouldn't hurt though, quite the contrary. Especially if it wasn't tested before. Otherwise, this looks good to me. http://reviews.llvm.org/D13001 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13000: [libclang] Expose AutoType
milianw added a comment. Looks good to me! http://reviews.llvm.org/D13000 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13643: [Sema] Warn on ternary comparison
mgrabovsky updated this revision to Diff 37720. mgrabovsky added a comment. Change message wording http://reviews.llvm.org/D13643 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaChecking.cpp test/Sema/bool-compare.c Index: test/Sema/bool-compare.c === --- test/Sema/bool-compare.c +++ test/Sema/bool-compare.c @@ -85,7 +85,9 @@ if ((ayy b < c' do not have their mathematical meaning}} \ + // expected-note {{to achieve the expected behavior, turn this expression into a conjunction of two comparisons}} \ + // expected-note {{place parentheses around either of the comparisons to silence this warning}} if ((a z) {} // no warning if((a(zy) {}// no warning - if (z > (a(ay) {} // expected-warning {{comparisons such as 'a < b > c' do not have their mathematical meaning}} \ + // expected-note {{to achieve the expected behavior, turn this expression into a conjunction of two comparisons}} \ + // expected-note {{place parentheses around either of the comparisons to silence this warning}} + if (z > (a(agetLHS()->getSourceRange() << E->getRHS()->getSourceRange()); } +/// Diagnose attempts at ternary comparison, e.g., 1 < x < 2 +static void DiagnoseTernaryComparison(Sema &S, BinaryOperator *E) { + BinaryOperator *LHS = dyn_cast(E->getLHS()); + if (!LHS || !LHS->isComparisonOp()) +return; + + SourceLocation Loc = E->getSourceRange().getBegin(); + + S.Diag(Loc, diag::warn_ternary_comparison) +<< LHS->getOpcodeStr() +<< E->getOpcodeStr() +<< E->getSourceRange(); + S.Diag(Loc, diag::note_ternary_comparison_to_conjunction); + S.Diag(Loc, diag::note_ternary_comparison_silence) +<< FixItHint::CreateInsertion(LHS->getSourceRange().getBegin(), "(") +<< FixItHint::CreateInsertion(LHS->getSourceRange().getEnd(), ")"); +} + /// Analyze the operands of the given comparison. Implements the /// fallback case from AnalyzeComparison. static void AnalyzeImpConvsInComparison(Sema &S, BinaryOperator *E) { @@ -6716,11 +6734,13 @@ if (E->isValueDependent()) return AnalyzeImpConvsInComparison(S, E); + DiagnoseTernaryComparison(S, E); + Expr *LHS = E->getLHS()->IgnoreParenImpCasts(); Expr *RHS = E->getRHS()->IgnoreParenImpCasts(); - + bool IsComparisonConstant = false; - + // Check whether an integer constant comparison results in a value // of 'true' or 'false'. if (T->isIntegralType(S.Context)) { Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -5866,6 +5866,14 @@ def note_condition_assign_silence : Note< "place parentheses around the assignment to silence this warning">; +def warn_ternary_comparison : Warning<"comparisons such as 'a %0 b %1 c' do not " + "have their mathematical meaning">, + InGroup; +def note_ternary_comparison_to_conjunction : Note<"to achieve the expected behavior, " + "turn this expression into a conjunction of two comparisons">; +def note_ternary_comparison_silence : Note<"place parentheses around either " + "of the comparisons to silence this warning">; + def warn_equality_with_extra_parens : Warning<"equality comparison with " "extraneous parentheses">, InGroup; def note_equality_comparison_to_assign : Note< ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r250514 - PS4: Make sure to add the sanitizer runtime before any linker input
False alarm. My bisect script was not robust enough and git bisect ended up pointing to the wrong change. Sorry for the noise. --Artem On Mon, Oct 19, 2015 at 2:05 AM, Filipe Cabecinhas wrote: > I don't see this. Do you have a log for them? > > Thank you, > > Filipe > > On Fri, Oct 16, 2015 at 11:52 PM, Artem Belevich via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Filipe, >> >> FYI, this change appears to introduce a somewhat subtle problem. clang >> compiled with itself starts producing (false positive?) warnings about >> uninitialized variables. I didn't get a chance to dig deeper yet. >> >> --Artem >> >> On Fri, Oct 16, 2015 at 8:07 AM, Filipe Cabecinhas via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Author: filcab >>> Date: Fri Oct 16 10:07:48 2015 >>> New Revision: 250514 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=250514&view=rev >>> Log: >>> PS4: Make sure to add the sanitizer runtime before any linker input >>> >>> Modified: >>> cfe/trunk/lib/Driver/Tools.cpp >>> >>> Modified: cfe/trunk/lib/Driver/Tools.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=250514&r1=250513&r2=250514&view=diff >>> >>> == >>> --- cfe/trunk/lib/Driver/Tools.cpp (original) >>> +++ cfe/trunk/lib/Driver/Tools.cpp Fri Oct 16 10:07:48 2015 >>> @@ -10017,6 +10017,8 @@ static void ConstructPS4LinkJob(const To >>> assert(Output.isNothing() && "Invalid output."); >>>} >>> >>> + AddPS4SanitizerArgs(ToolChain, CmdArgs); >>> + >>>Args.AddAllArgs(CmdArgs, options::OPT_L); >>>Args.AddAllArgs(CmdArgs, options::OPT_T_Group); >>>Args.AddAllArgs(CmdArgs, options::OPT_e); >>> @@ -10034,7 +10036,6 @@ static void ConstructPS4LinkJob(const To >>>} >>> >>>AddPS4ProfileRT(ToolChain, Args, CmdArgs); >>> - AddPS4SanitizerArgs(ToolChain, CmdArgs); >>> >>>const char *Exec = >>> Args.MakeArgString(ToolChain.GetProgramPath("ps4-ld")); >>> >>> @@ -10087,6 +10088,8 @@ static void ConstructGoldLinkJob(const T >>> assert(Output.isNothing() && "Invalid output."); >>>} >>> >>> + AddPS4SanitizerArgs(ToolChain, CmdArgs); >>> + >>>if (!Args.hasArg(options::OPT_nostdlib) && >>>!Args.hasArg(options::OPT_nostartfiles)) { >>> const char *crt1 = NULL; >>> @@ -10214,7 +10217,6 @@ static void ConstructGoldLinkJob(const T >>>} >>> >>>AddPS4ProfileRT(ToolChain, Args, CmdArgs); >>> - AddPS4SanitizerArgs(ToolChain, CmdArgs); >>> >>>const char *Exec = >>> #ifdef LLVM_ON_WIN32 >>> >>> >>> ___ >>> cfe-commits mailing list >>> cfe-commits@lists.llvm.org >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >>> >> >> >> >> -- >> --Artem Belevich >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> >> > -- --Artem Belevich ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r249738 - Split out of .
> On Oct 16, 2015, at 5:47 PM, Richard Smith wrote: > > Great, looks like progress. Next you need a correct module map for libc++ > that actually covers all of its headers :) Try the attached one. > Sorry for the delay. With the updated module map I get /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/module.modulemap:64:14: error: header 'locale.h' not found header "locale.h" ^ /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/cassert:20:10: note: submodule of top-level module 'std' implicitly imported here #include <__config> ^ and after commenting out the locale module I get the rather puzzling (shouldn’t this have been avoided by the clang changes?): While building module 'std' imported from /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/cassert:20: In file included from :2: In file included from /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/complex.h:29: In file included from /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/ccomplex:21: In file included from /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/complex:244: /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/type_traits:219:1: error: templates must have C++ linkage template ^~~~ /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/type_traits:222:1: error: templates must have C++ linkage template ^~~~ /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/type_traits:225:1: error: templates must have C++ linkage template ^~ —adrian___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r249738 - Split out of .
On Mon, Oct 19, 2015 at 1:28 PM, Adrian Prantl via cfe-commits < cfe-commits@lists.llvm.org> wrote: > > On Oct 16, 2015, at 5:47 PM, Richard Smith wrote: > > Great, looks like progress. Next you need a correct module map for libc++ > that actually covers all of its headers :) Try the attached one. > > Sorry for the delay. > With the updated module map I get > > */Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/module.modulemap:64:14: > **error: * > * header 'locale.h' not found* > header "locale.h" > * ^* > */Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/cassert:20:10: > note: * > submodule of top-level module 'std' implicitly imported here > #include <__config> > * ^* > and after commenting out the locale module I get the rather puzzling > (shouldn’t this have been avoided by the clang changes?): > Ah right, complex.h should not really be treated as an [extern_c] module. It doesn't make any sense in that context (... or in general ...). Try the attached libc++ module map instead (sorry, untested on my end). > While building module 'std' imported from > /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/cassert:20: > In file included from :2: > In file included from > /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/complex.h:29: > In file included from > /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/ccomplex:21: > In file included from > /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/complex:244: > */Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/type_traits:219:1: > **error: * > * templates must have C++ linkage* > template > *^~~~* > */Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/type_traits:222:1: > **error: * > * templates must have C++ linkage* > template > *^~~~* > */Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/type_traits:225:1: > **error: * > * templates must have C++ linkage* > template > *^~* > > —adrian > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > > module.modulemap Description: Binary data ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13787: [clang-tidy] add check cppcoreguidelines-pro-type-vararg-use
mgehre updated this revision to Diff 37790. mgehre added a comment. Revert "[clang-tidy] add cert's VariadicFunctionDefCheck as cppcoreguidelines-pro-type-vararg-def"; warn about va_* in this check (to allow SFINAE) http://reviews.llvm.org/D13787 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp clang-tidy/cppcoreguidelines/ProTypeVarargCheck.h docs/clang-tidy/checks/cppcoreguidelines-pro-type-vararg.rst docs/clang-tidy/checks/list.rst test/clang-tidy/cppcoreguidelines-pro-type-vararg.cpp Index: test/clang-tidy/cppcoreguidelines-pro-type-vararg.cpp === --- /dev/null +++ test/clang-tidy/cppcoreguidelines-pro-type-vararg.cpp @@ -0,0 +1,43 @@ +// RUN: %python %S/check_clang_tidy.py %s cppcoreguidelines-pro-type-vararg %t + +void f(int i); +void f_vararg(int i, ...); + +struct C { + void g_vararg(...); + void g(const char*); +} c; + +template +void cpp_vararg(P... p); + +void check() { + f_vararg(1, 7, 9); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call c-style vararg functions [cppcoreguidelines-pro-type-vararg] + c.g_vararg("foo"); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call c-style vararg functions + + f(3); // OK + c.g("foo"); // OK + cpp_vararg(1, 7, 9); // OK +} + +// ... as a parameter is allowed (e.g. for SFINAE) +template +void CallFooIfAvailableImpl(T& t, ...) { +} + +#include +void my_printf(const char* format, ...) { + va_list ap; + va_start(ap, format); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use va_start/va_arg to define c-style vararg functions; use variadic templates instead [cppcoreguidelines-pro-type-vararg] + va_list n; + va_copy(n, ap); // Don't warn, va_copy is anyway useless without va_start + int i = va_arg(ap, int); + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use va_start/va_arg to define c-style vararg functions; use variadic templates instead + va_end(ap); // Don't warn, va_end is anyway useless without va_start +} + +int my_vprintf(const char* format, va_list arg ); +// CHECK-MESSAGES: :[[@LINE-1]]:36: warning: do not declare variables of type va_list; use variadic templates instead [cppcoreguidelines-pro-type-vararg] Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -8,6 +8,7 @@ cppcoreguidelines-pro-type-const-cast cppcoreguidelines-pro-type-reinterpret-cast cppcoreguidelines-pro-type-static-cast-downcast + cppcoreguidelines-pro-type-vararg google-build-explicit-make-pair google-build-namespaces google-build-using-namespace Index: docs/clang-tidy/checks/cppcoreguidelines-pro-type-vararg.rst === --- /dev/null +++ docs/clang-tidy/checks/cppcoreguidelines-pro-type-vararg.rst @@ -0,0 +1,10 @@ +cppcoreguidelines-pro-type-vararg += + +This check flags all calls to c-style vararg functions and all use +of va_list, va_start and va_arg. + +Passing to varargs assumes the correct type will be read. This is fragile because it cannot generally be enforced to be safe in the language and so relies on programmer discipline to get it right. + +This rule is part of the "Type safety" profile of the C++ Core Guidelines, see +https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type8-avoid-reading-from-varargs-or-passing-vararg-arguments-prefer-variadic-template-parameters-instead Index: clang-tidy/cppcoreguidelines/ProTypeVarargCheck.h === --- /dev/null +++ clang-tidy/cppcoreguidelines/ProTypeVarargCheck.h @@ -0,0 +1,34 @@ +//===--- ProTypeVarargCheck.h - clang-tidy*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_TYPE_VARARG_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_TYPE_VARARG_H + +#include "../ClangTidy.h" + +namespace clang { +namespace tidy { + +/// This check flags all calls to c-style variadic functions and all use +/// of va_list, va_start and va_arg. +/// +/// For the user-facing documentation see: +/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-type-vararg.html +class ProTypeVarargCheck : public ClangTidyCheck { +public: + ProTypeVarargCheck(StringRef Name, ClangTidyContext *Context) + : ClangTidyCheck(Name, Context) {} + void registerMatchers(ast_matchers::MatchFinder *Finder) override; + void check(const ast_matchers::
[PATCH] D13874: Atomics: support __c11_* calls on _Atomic struct types
t.p.northover created this revision. t.p.northover added a subscriber: cfe-commits. t.p.northover set the repository for this revision to rL LLVM. When a struct's size is not a power of 2, the corresponding _Atomic() type is promoted to the nearest. We already correctly handled normal C++ expressions of this form, but direct calls to the __c11_atomic_whatever builtins ended up performing dodgy operations on the smaller non-atomic types (e.g. memcpy too much). Later optimisations removed this as undefined behaviour. This patch converts EmitAtomicExpr to allocate its temporaries at the full atomic width, sidestepping the issue. It also tidies up that function a little: previously there was a confusing dual-return situation, where sometimes the result was returned as an RValue, other times stored into a user-provided destination. I don't think this is necessary (it dates back from the very beginning of CGAtomic.cpp). Repository: rL LLVM http://reviews.llvm.org/D13874 Files: lib/CodeGen/CGAtomic.cpp lib/CodeGen/CGExprAgg.cpp lib/CodeGen/CodeGenFunction.h test/CodeGen/atomic-arm64.c test/CodeGen/atomic-ops.c test/CodeGen/c11atomics-ios.c test/CodeGen/c11atomics.c Index: test/CodeGen/c11atomics.c === --- test/CodeGen/c11atomics.c +++ test/CodeGen/c11atomics.c @@ -367,14 +367,111 @@ // CHECK-NEXT: ret void } -// CHECK: define arm_aapcscc void @testPromotedStructOps([[APS:.*]]* - -// FIXME: none of these look right, but we can leave the "test" here -// to make sure they at least don't crash. -void testPromotedStructOps(_Atomic(PS) *p) { - PS a = __c11_atomic_load(p, 5); - __c11_atomic_store(p, a, 5); - PS b = __c11_atomic_exchange(p, a, 5); - _Bool v = __c11_atomic_compare_exchange_strong(p, &b, a, 5, 5); - v = __c11_atomic_compare_exchange_weak(p, &b, a, 5, 5); +PS test_promoted_load(_Atomic(PS) *addr) { + // CHECK-LABEL: @test_promoted_load(%struct.PS* noalias sret %agg.result, { %struct.PS, [2 x i8] }* %addr) + // CHECK: [[ADDR_ARG:%.*]] = alloca { %struct.PS, [2 x i8] }*, align 4 + // CHECK: [[ATOMIC_RES:%.*]] = alloca { %struct.PS, [2 x i8] }, align 8 + // CHECK: store { %struct.PS, [2 x i8] }* %addr, { %struct.PS, [2 x i8] }** [[ADDR_ARG]], align 4 + // CHECK: [[ADDR:%.*]] = load { %struct.PS, [2 x i8] }*, { %struct.PS, [2 x i8] }** [[ADDR_ARG]], align 4 + // CHECK: [[ADDR64:%.*]] = bitcast { %struct.PS, [2 x i8] }* [[ADDR]] to i64* + // CHECK: [[ATOMIC_RES64:%.*]] = bitcast { %struct.PS, [2 x i8] }* [[ATOMIC_RES]] to i64* + // CHECK: [[ADDR8:%.*]] = bitcast i64* [[ADDR64]] to i8* + // CHECK: [[RES:%.*]] = call arm_aapcscc i64 @__atomic_load_8(i8* [[ADDR8]], i32 5) + // CHECK: store i64 [[RES]], i64* [[ATOMIC_RES64]], align 8 + // CHECK: [[ATOMIC_RES_STRUCT:%.*]] = bitcast i64* [[ATOMIC_RES64]] to %struct.PS* + // CHECK: [[AGG_RESULT8:%.*]] = bitcast %struct.PS* %agg.result to i8* + // CHECK: [[ATOMIC_RES8:%.*]] = bitcast %struct.PS* [[ATOMIC_RES_STRUCT]] to i8* + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* [[AGG_RESULT8]], i8* [[ATOMIC_RES8]], i32 6, i32 2, i1 false) + + return __c11_atomic_load(addr, 5); +} + +void test_promoted_store(_Atomic(PS) *addr, PS *val) { + // CHECK-LABEL: @test_promoted_store({ %struct.PS, [2 x i8] }* %addr, %struct.PS* %val) + // CHECK: [[ADDR_ARG:%.*]] = alloca { %struct.PS, [2 x i8] }*, align 4 + // CHECK: [[VAL_ARG:%.*]] = alloca %struct.PS*, align 4 + // CHECK: [[NONATOMIC_TMP:%.*]] = alloca %struct.PS, align 2 + // CHECK: [[ATOMIC_VAL:%.*]] = alloca { %struct.PS, [2 x i8] }, align 8 + // CHECK: store { %struct.PS, [2 x i8] }* %addr, { %struct.PS, [2 x i8] }** [[ADDR_ARG]], align 4 + // CHECK: store %struct.PS* %val, %struct.PS** [[VAL_ARG]], align 4 + // CHECK: [[ADDR:%.*]] = load { %struct.PS, [2 x i8] }*, { %struct.PS, [2 x i8] }** [[ADDR_ARG]], align 4 + // CHECK: [[VAL:%.*]] = load %struct.PS*, %struct.PS** [[VAL_ARG]], align 4 + // CHECK: [[NONATOMIC_TMP8:%.*]] = bitcast %struct.PS* [[NONATOMIC_TMP]] to i8* + // CHECK: [[VAL8:%.*]] = bitcast %struct.PS* [[VAL]] to i8* + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* [[NONATOMIC_TMP8]], i8* [[VAL8]], i32 6, i32 2, i1 false) + // CHECK: [[ADDR64:%.*]] = bitcast { %struct.PS, [2 x i8] }* [[ADDR]] to i64* + // CHECK: [[ATOMIC_VAL8:%.*]] = bitcast { %struct.PS, [2 x i8] }* [[ATOMIC_VAL]] to i8* + // CHECK: [[NONATOMIC_TMP8:%.*]] = bitcast %struct.PS* [[NONATOMIC_TMP]] to i8* + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[ATOMIC_VAL8]], i8* [[NONATOMIC_TMP8]], i64 6, i32 2, i1 false) + // CHECK: [[ATOMIC_VAL64:%.*]] = bitcast { %struct.PS, [2 x i8] }* [[ATOMIC_VAL]] to i64* + // CHECK: [[ADDR8:%.*]] = bitcast i64* [[ADDR64]] to i8* + // CHECK: [[VAL64:%.*]] = load i64, i64* [[ATOMIC_VAL64]], align 2 + // CHECK: call arm_aapcscc void @__atomic_store_8(i8* [[ADDR8]], i64 [[VAL64]], i32 5) + __c11_atomic_stor
Re: [PATCH] D10677: Allow deque to handle incomplete types
eugenis updated this revision to Diff 37795. eugenis marked 3 inline comments as done. Repository: rL LLVM http://reviews.llvm.org/D10677 Files: include/__config include/deque test/libcxx/containers/sequences/deque/incomplete.pass.cpp Index: test/libcxx/containers/sequences/deque/incomplete.pass.cpp === --- /dev/null +++ test/libcxx/containers/sequences/deque/incomplete.pass.cpp @@ -0,0 +1,31 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// + +// deque() +// deque::iterator() + +#define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE +#include +#include + +struct A { + std::deque d; + std::deque::iterator it; + std::deque::reverse_iterator it2; +}; + +int main() +{ + A a; + assert(a.d.size() == 0); + a.it = a.d.begin(); + a.it2 = a.d.rend(); +} Index: include/deque === --- include/deque +++ include/deque @@ -261,8 +261,21 @@ __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r); +template +struct __deque_block_size { + static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16; +}; + template + class _DiffType, _DiffType _BS = +#ifdef _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE +// Keep template parameter to avoid changing all template declarations thoughout +// this file. + 0 +#else + __deque_block_size<_ValueType, _DiffType>::value +#endif + > class _LIBCPP_TYPE_VIS_ONLY __deque_iterator { typedef _MapPointer __map_iterator; @@ -273,7 +286,7 @@ __map_iterator __m_iter_; pointer__ptr_; -static const difference_type __block_size = _BlockSize; +static const difference_type __block_size; public: typedef _ValueType value_type; typedef random_access_iterator_tag iterator_category; @@ -287,7 +300,7 @@ template _LIBCPP_INLINE_VISIBILITY -__deque_iterator(const __deque_iterator& __it, +__deque_iterator(const __deque_iterator& __it, typename enable_if::value>::type* = 0) _NOEXCEPT : __m_iter_(__it.__m_iter_), __ptr_(__it.__ptr_) {} @@ -520,6 +533,12 @@ __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r); }; +template +const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, + _DiffType, _BlockSize>::__block_size = +__deque_block_size<_ValueType, _DiffType>::value; + // copy template ::difference_type difference_type; typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer; +const difference_type __block_size = __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::__block_size; while (__f != __l) { pointer __rb = __r.__ptr_; -pointer __re = *__r.__m_iter_ + _B2; +pointer __re = *__r.__m_iter_ + __block_size; difference_type __bs = __re - __rb; difference_type __n = __l - __f; _RAIter __m = __l; @@ -560,11 +580,12 @@ { typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; +const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size; difference_type __n = __l - __f; while (__n > 0) { pointer __fb = __f.__ptr_; -pointer __fe = *__f.__m_iter_ + _B1; +pointer __fe = *__f.__m_iter_ + __block_size; difference_type __bs = __fe - __fb; if (__bs > __n) { @@ -587,11 +608,12 @@ { typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; +const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size; difference_type __n = __l - __f; while (__n > 0) { pointer __fb = __f.__ptr_; -pointer __fe = *__f.__m_iter_ + _B1; +pointer __fe = *__f.__m_iter_ + __block_size; difference_type __bs = __fe - __fb; if (__bs > __n) { @@ -705,10 +727,11 @@ { typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type; typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer; +const difference_type __block_size = __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::__block_size;
Re: [PATCH] D10677: Allow deque to handle incomplete types
eugenis added a comment. In http://reviews.llvm.org/D10677#266595, @EricWF wrote: > For the most part this looks good. I'm a touch concerned though about the > changes to the static initialization. The initializer is moved from within > the function body to outside it. Could you have somebody confirm this won't > affect the existing ABI? I'm pretty sure it only affects template evaluation order, and does not change the mangling of any name. Repository: rL LLVM http://reviews.llvm.org/D10677 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r249738 - Split out of .
While building module 'std' imported from /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/cassert:20: While building module 'Darwin' imported from /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/ctype.h:39: In file included from :95: In file included from /Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/util.h:64: /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/stdio.h:102:10: fatal error: '__config' file not found #include <__config> ^ While building module 'std' imported from /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/cassert:20: In file included from :2: /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/ctype.h:39:15: fatal error: could not build module 'Darwin' #include_next ~^ In file included from test.cpp:2: /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/cassert:20:10: fatal error: could not build module 'std' #include <__config> ^ 3 errors generated.___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13787: [clang-tidy] add check cppcoreguidelines-pro-type-vararg-use
sbenza added inline comments. Comment at: clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp:26 @@ +25,3 @@ + Finder->addMatcher( + varDecl(hasType(pointsTo(cxxRecordDecl(hasName("__va_list_tag") + .bind("va_list"), Is there a way to look for the standard type (and not the implementation defined __xxx type name)? Comment at: test/clang-tidy/cppcoreguidelines-pro-type-vararg.cpp:38 @@ +37,3 @@ + int i = va_arg(ap, int); + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use va_start/va_arg to define c-style vararg functions; use variadic templates instead + va_end(ap); // Don't warn, va_end is anyway useless without va_start isn't va_arg as useless as va_copy (without va_start)? Actually, given that va_arg is the only one we can look for without using the private __va_xxx name, maybe we should only warn on that one. http://reviews.llvm.org/D13787 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13787: [clang-tidy] add check cppcoreguidelines-pro-type-vararg-use
sbenza added inline comments. Comment at: test/clang-tidy/cppcoreguidelines-pro-type-vararg.cpp:27 @@ +26,3 @@ +template +void CallFooIfAvailableImpl(T& t, ...) { +} You would still warn on the callers of this. Maybe we should ignore any call if the variadic part is a single argument with value 0, which is what is commonly used for SFINAE checks. http://reviews.llvm.org/D13787 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r250742 - Added check uniqueptr-delete-release to replace "delete x.release()" with "x = nullptr"
Author: sbenza Date: Mon Oct 19 16:49:51 2015 New Revision: 250742 URL: http://llvm.org/viewvc/llvm-project?rev=250742&view=rev Log: Added check uniqueptr-delete-release to replace "delete x.release()" with "x = nullptr" Reviewers: alexfh Differential Revision: http://reviews.llvm.org/D13179 Added: clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst clang-tools-extra/trunk/test/clang-tidy/readability-uniqueptr-delete-release.cpp Modified: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Modified: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt?rev=250742&r1=250741&r2=250742&view=diff == --- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt Mon Oct 19 16:49:51 2015 @@ -13,6 +13,7 @@ add_clang_library(clangTidyReadabilityMo RedundantStringCStrCheck.cpp RedundantSmartptrGetCheck.cpp SimplifyBooleanExprCheck.cpp + UniqueptrDeleteReleaseCheck.cpp LINK_LIBS clangAST Modified: clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp?rev=250742&r1=250741&r2=250742&view=diff == --- clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp Mon Oct 19 16:49:51 2015 @@ -20,6 +20,7 @@ #include "RedundantSmartptrGetCheck.h" #include "RedundantStringCStrCheck.h" #include "SimplifyBooleanExprCheck.h" +#include "UniqueptrDeleteReleaseCheck.h" namespace clang { namespace tidy { @@ -40,6 +41,8 @@ public: "readability-identifier-naming"); CheckFactories.registerCheck( "readability-inconsistent-declaration-parameter-name"); +CheckFactories.registerCheck( +"readability-uniqueptr-delete-release"); CheckFactories.registerCheck( "readability-named-parameter"); CheckFactories.registerCheck( Added: clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp?rev=250742&view=auto == --- clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp (added) +++ clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp Mon Oct 19 16:49:51 2015 @@ -0,0 +1,69 @@ +//===--- UniqueptrDeleteReleaseCheck.cpp - clang-tidy--===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "UniqueptrDeleteReleaseCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace clang { +namespace tidy { + +void UniqueptrDeleteReleaseCheck::registerMatchers(MatchFinder *Finder) { + auto IsSusbstituted = qualType(anyOf( + substTemplateTypeParmType(), hasDescendant(substTemplateTypeParmType(; + + auto UniquePtrWithDefaultDelete = classTemplateSpecializationDecl( + hasName("std::unique_ptr"), + hasTemplateArgument(1, refersToType(qualType(hasDeclaration(cxxRecordDecl( + hasName("std::default_delete"))); + + Finder->addMatcher( + cxxDeleteExpr( + has(cxxMemberCallExpr(on(expr(hasType(UniquePtrWithDefaultDelete), +unless(hasType(IsSusbstituted))) + .bind("uptr")), +callee(cxxMethodDecl(hasName("release")) + .bind("delete"), + this); +} + +void UniqueptrDeleteReleaseCheck::check( +const MatchFinder::MatchResult &Result) { + const auto *PtrExpr = Result.Nodes.getNodeAs("uptr"); + const auto *DeleteExpr = Result.Nodes.getNodeAs("delete"); + + if (PtrExpr->getLocStart().isMacroID()) +return; + + // Ignore dependent types. + // It can give us false positives, so we go with false negatives instead to + // be safe. + if (Ptr
Re: [clang-tools-extra] r250742 - Added check uniqueptr-delete-release to replace "delete x.release()" with "x = nullptr"
On Mon, Oct 19, 2015 at 2:49 PM, Samuel Benzaquen via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: sbenza > Date: Mon Oct 19 16:49:51 2015 > New Revision: 250742 > > URL: http://llvm.org/viewvc/llvm-project?rev=250742&view=rev > Log: > Added check uniqueptr-delete-release to replace "delete x.release()" with > "x = nullptr" > Any stats on this? Have we seen many instances of "delete x.release()" Also, an interesting question: should the fixit be "x = nullptr" or "x.reset()" ? I remember having this discussion with at least Lang Hames & he preferred the latter, which I can see, though my initial reaction is to use the former. > > Reviewers: alexfh > > Differential Revision: http://reviews.llvm.org/D13179 > > Added: > > clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp > > clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h > > clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst > > clang-tools-extra/trunk/test/clang-tidy/readability-uniqueptr-delete-release.cpp > Modified: > clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt > > clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp > clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst > > Modified: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt?rev=250742&r1=250741&r2=250742&view=diff > > == > --- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt > (original) > +++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt Mon Oct > 19 16:49:51 2015 > @@ -13,6 +13,7 @@ add_clang_library(clangTidyReadabilityMo >RedundantStringCStrCheck.cpp >RedundantSmartptrGetCheck.cpp >SimplifyBooleanExprCheck.cpp > + UniqueptrDeleteReleaseCheck.cpp > >LINK_LIBS >clangAST > > Modified: > clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp?rev=250742&r1=250741&r2=250742&view=diff > > == > --- > clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp > (original) > +++ > clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp > Mon Oct 19 16:49:51 2015 > @@ -20,6 +20,7 @@ > #include "RedundantSmartptrGetCheck.h" > #include "RedundantStringCStrCheck.h" > #include "SimplifyBooleanExprCheck.h" > +#include "UniqueptrDeleteReleaseCheck.h" > > namespace clang { > namespace tidy { > @@ -40,6 +41,8 @@ public: > "readability-identifier-naming"); > > CheckFactories.registerCheck( > "readability-inconsistent-declaration-parameter-name"); > +CheckFactories.registerCheck( > +"readability-uniqueptr-delete-release"); > CheckFactories.registerCheck( > "readability-named-parameter"); > CheckFactories.registerCheck( > > Added: > clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp?rev=250742&view=auto > > == > --- > clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp > (added) > +++ > clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp > Mon Oct 19 16:49:51 2015 > @@ -0,0 +1,69 @@ > +//===--- UniqueptrDeleteReleaseCheck.cpp - > clang-tidy--===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > > +//===--===// > + > +#include "UniqueptrDeleteReleaseCheck.h" > +#include "clang/AST/ASTContext.h" > +#include "clang/ASTMatchers/ASTMatchFinder.h" > +#include "clang/Lex/Lexer.h" > + > +using namespace clang::ast_matchers; > + > +namespace clang { > +namespace tidy { > + > +void UniqueptrDeleteReleaseCheck::registerMatchers(MatchFinder *Finder) { > + auto IsSusbstituted = qualType(anyOf( > + substTemplateTypeParmType(), > hasDescendant(substTemplateTypeParmType(; > + > + auto UniquePtrWithDefaultDelete = classTemplateSpecializationDecl( > + hasName("std::unique_ptr"), > + hasTemplateArgument(1, > refersToType(qualType(hasDeclaration(cxxRecordDecl( > + hasName("std::default_delete"))); > + > + Finder->addMatcher( > + cxxDeleteExpr( > + > has(cxxMemberCallExpr(on(expr(hasType(UniquePtrWithDefaultDelete), > +unless(has
Re: [PATCH] D12614: [OpenMP] Offloading descriptor registration and device codegen.
sfantao updated this revision to Diff 37802. sfantao added a comment. Use `GlobalDecl` to forward information about the name of OpenMP region's enclosing function to the OpenMP outlined functions. This replaces the initial implementation that was using a stack to keep this information. Add regression test that checks that the target region name mangling is correct if enclosed in a lambda function. I had to add extra logic in the scanning of the target regions because lambda function are emitted as global definitions. Other minor changes to address Alexey's comments. http://reviews.llvm.org/D12614 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Basic/LangOptions.def include/clang/Basic/LangOptions.h include/clang/Driver/CC1Options.td include/clang/Driver/Options.td lib/CodeGen/CGOpenMPRuntime.cpp lib/CodeGen/CGOpenMPRuntime.h lib/CodeGen/CGStmtOpenMP.cpp lib/CodeGen/CodeGenFunction.h lib/CodeGen/CodeGenModule.cpp lib/Frontend/CompilerInvocation.cpp lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp test/OpenMP/target_codegen.cpp test/OpenMP/target_codegen_global_capture.cpp test/OpenMP/target_codegen_registration.cpp test/OpenMP/target_codegen_registration_naming.cpp test/OpenMP/target_messages.cpp Index: test/OpenMP/target_messages.cpp === --- test/OpenMP/target_messages.cpp +++ test/OpenMP/target_messages.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -verify -fopenmp -std=c++11 -o - %s +// RUN: not %clang_cc1 -fopenmp -std=c++11 -omptargets=aaa-bbb-ccc-ddd -o - %s 2>&1 | FileCheck %s +// CHECK: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd' void foo() { } Index: test/OpenMP/target_codegen_registration_naming.cpp === --- /dev/null +++ test/OpenMP/target_codegen_registration_naming.cpp @@ -0,0 +1,65 @@ +// Test host codegen. +// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s + +// Test target codegen - host bc file has to be created first. +// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc +// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s -check-prefix=TCHECK +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o %t %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=TCHECK +// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc +// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s -check-prefix=TCHECK +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o %t %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=TCHECK + +// expected-no-diagnostics +#ifndef HEADER +#define HEADER + +// CHECK: [[CA:%.+]] = type { i32* } + +// CHECK: define {{.*}}i32 @[[NNAME:.+]](i32 {{.*}}%{{.+}}) +int nested(int a){ + // CHECK: call void @.omp_offloading.[[FILEID:[0-9a-f]+\.[0-9a-f]+]].[[NNAME]].l[[T1L:[0-9]+]].c[[T1C:[0-9]+]]( + #pragma omp target +++a; + + // CHECK: call void @"[[LNAME:.+]]"([[CA]]* +
Re: [PATCH] D12614: [OpenMP] Offloading descriptor registration and device codegen.
sfantao added inline comments. Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:1962 @@ +1961,3 @@ +[LineNum][ColNum]; +assert(Entry.Order != -1u && "Entry not initialized!"); +assert(!Entry.Addr && !Entry.ID && "Entry registered already!"); ABataev wrote: > ~0u Done. Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2349 @@ +2348,3 @@ +TgtBinaryDescriptorTy = llvm::StructType::create( +"tgt_bin_desc", CGM.Int32Ty, getTgtDeviceImageTy()->getPointerTo(), +getTgtOffloadEntryTy()->getPointerTo(), ABataev wrote: > I think there should be 4-bytes padding between NumDevices and DeviceImages > fields in 64-bit mode, right? It is better to create this structure as clang > AST RecordDecl/CXXRecordDecl and then use CGM.getTypes().ConvertTypeForMem(). Done! Comment at: lib/CodeGen/CGOpenMPRuntime.h:325-328 @@ +324,6 @@ + public: +CodeGenModule &CGM; + +/// \brief Number of entries registered so far. +unsigned OffloadingEntriesNum; + ABataev wrote: > I think these members must be private. Done! Also added some setters and getters for the privatized fields. Comment at: lib/CodeGen/CGOpenMPRuntime.h:339 @@ +338,3 @@ +// Invalid entry info. +OFFLOAD_ENTRY_INFO_INVALID = -1u + }; ABataev wrote: > Better ~0 Done! Comment at: lib/CodeGen/CGOpenMPRuntime.h:343 @@ +342,3 @@ + // \brief Order this entry was emitted. + unsigned Order; + ABataev wrote: > Make it private/protected also Done! Comment at: lib/CodeGen/CGOpenMPRuntime.h:345 @@ +344,3 @@ + + OffloadEntryInfo() : Order(-1u), Kind(OFFLOAD_ENTRY_INFO_INVALID) {} + OffloadEntryInfo(OffloadingEntryInfoKinds Kind, unsigned Order) ABataev wrote: > explicit, ~0u Done Comment at: lib/CodeGen/CGOpenMPRuntime.h:367-370 @@ +366,6 @@ +public: + // \brief Address of the entity that has to be mapped for offloading. + llvm::Constant *Addr; + // \brief Address that can be used as the ID of the entry. + llvm::Constant *ID; + ABataev wrote: > Private/protected Done Comment at: lib/CodeGen/CGOpenMPRuntime.h:372 @@ +371,3 @@ + + OffloadEntryInfoTargetRegion() + : OffloadEntryInfo(OFFLOAD_ENTRY_INFO_TARGET_REGION, -1u), ABataev wrote: > explicit Done Comment at: lib/CodeGen/CGOpenMPRuntime.h:373 @@ +372,3 @@ + OffloadEntryInfoTargetRegion() + : OffloadEntryInfo(OFFLOAD_ENTRY_INFO_TARGET_REGION, -1u), +Addr(nullptr), ID(nullptr) {} ABataev wrote: > ~0u Done Comment at: lib/CodeGen/CGOpenMPRuntime.h:957-967 @@ -759,1 +956,13 @@ + + /// \brief Notify the runtime implementation that a user function definition + /// is about to be emmited. + /// \param GD Declaration of the function definition that will be emitted. + void pushCurrentUserFunction(GlobalDecl GD); + + /// \brief Notify the runtime implementation that the emission of the current + /// user function is finished. + void popCurrentUserFunction(); + + /// \brief Get the declaration of the current user function being emitted. + StringRef getCurrentUserFunction(); }; ABataev wrote: > Do we really need this stuff? CodeGenFunction has member CurFuncDecl, which, > it seems, could give you required info without these functions. I can't rely on CurFuncDecl because the parent function can be in some cases an implicit outlined function, and what I need is the enclosing user function. In the new diff, I implemented this in a slightly different way: I forward the user function `GlobalDecl` to the implicit functions (see `GenerateOpenMPCapturedStmtFunction`). In order for this to work I had to add special login in the scanning of the target regions to deal with lambda functions given that they are also emitted as global definitions. Hope you like this approach better. http://reviews.llvm.org/D12614 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r249738 - Split out of .
Ugh, looks like I missed a submodule for stdio.h :( On Oct 19, 2015 11:34 AM, "Adrian Prantl" wrote: > While building module 'std' imported from > /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/cassert:20: > While building module 'Darwin' imported from > /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/ctype.h:39: > In file included from :95: > In file included from > /Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/util.h:64: > */Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/stdio.h:102:10: > **fatal error: * > * '__config' file not found* > #include <__config> > * ^* > While building module 'std' imported from > /Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/cassert:20: > In file included from :2: > */Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/ctype.h:39:15: > **fatal error: * > * could not build module 'Darwin'* > #include_next > * ~^* > In file included from test.cpp:2: > */Volumes/Data/llvm/_build.ninja.release/bin/../include/c++/v1/cassert:20:10: > **fatal error: * > * could not build module 'std'* > #include <__config> > * ^* > 3 errors generated. > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13787: [clang-tidy] add check cppcoreguidelines-pro-type-vararg-use
mgehre updated this revision to Diff 37814. mgehre added a comment. Only flag va_arg and variadic call. Suppress warning if the only vararg argument is literal 0. http://reviews.llvm.org/D13787 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp clang-tidy/cppcoreguidelines/ProTypeVarargCheck.h docs/clang-tidy/checks/cppcoreguidelines-pro-type-vararg.rst docs/clang-tidy/checks/list.rst test/clang-tidy/cppcoreguidelines-pro-type-vararg.cpp Index: test/clang-tidy/cppcoreguidelines-pro-type-vararg.cpp === --- /dev/null +++ test/clang-tidy/cppcoreguidelines-pro-type-vararg.cpp @@ -0,0 +1,50 @@ +// RUN: %python %S/check_clang_tidy.py %s cppcoreguidelines-pro-type-vararg %t + +void f(int i); +void f_vararg(int i, ...); + +struct C { + void g_vararg(...); + void g(const char*); +} c; + +template +void cpp_vararg(P... p); + +void check() { + f_vararg(1, 7, 9); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call c-style vararg functions [cppcoreguidelines-pro-type-vararg] + c.g_vararg("foo"); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call c-style vararg functions + + f(3); // OK + c.g("foo"); // OK + cpp_vararg(1, 7, 9); // OK +} + +// ... as a parameter is allowed (e.g. for SFINAE) +template +void CallFooIfAvailableImpl(T& t, ...) { + // nothing +} +template +void CallFooIfAvailableImpl(T& t, decltype(t.foo())*) { + t->foo(); +} +template +void CallFooIfAvailable(T& t) { + CallFooIfAvailableImpl(t, 0); // OK to call variadic function when the argument is a literal 0 +} + +#include +void my_printf(const char* format, ...) { + va_list ap; + va_start(ap, format); + va_list n; + va_copy(n, ap); // Don't warn, va_copy is anyway useless without va_start + int i = va_arg(ap, int); + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use va_start/va_arg to define c-style vararg functions; use variadic templates instead + va_end(ap); // Don't warn, va_end is anyway useless without va_start +} + +int my_vprintf(const char* format, va_list arg ); // OK to declare function taking va_list Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -8,6 +8,7 @@ cppcoreguidelines-pro-type-const-cast cppcoreguidelines-pro-type-reinterpret-cast cppcoreguidelines-pro-type-static-cast-downcast + cppcoreguidelines-pro-type-vararg google-build-explicit-make-pair google-build-namespaces google-build-using-namespace Index: docs/clang-tidy/checks/cppcoreguidelines-pro-type-vararg.rst === --- /dev/null +++ docs/clang-tidy/checks/cppcoreguidelines-pro-type-vararg.rst @@ -0,0 +1,12 @@ +cppcoreguidelines-pro-type-vararg += + +This check flags all calls to c-style vararg functions and all use +of va_arg. +To allow for SFINAE use of vararg functions, a call is not flagged if +a literal 0 is passed as the only vararg argument. + +Passing to varargs assumes the correct type will be read. This is fragile because it cannot generally be enforced to be safe in the language and so relies on programmer discipline to get it right. + +This rule is part of the "Type safety" profile of the C++ Core Guidelines, see +https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type8-avoid-reading-from-varargs-or-passing-vararg-arguments-prefer-variadic-template-parameters-instead Index: clang-tidy/cppcoreguidelines/ProTypeVarargCheck.h === --- /dev/null +++ clang-tidy/cppcoreguidelines/ProTypeVarargCheck.h @@ -0,0 +1,34 @@ +//===--- ProTypeVarargCheck.h - clang-tidy*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_TYPE_VARARG_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_TYPE_VARARG_H + +#include "../ClangTidy.h" + +namespace clang { +namespace tidy { + +/// This check flags all calls to c-style variadic functions and all use +/// of va_arg. +/// +/// For the user-facing documentation see: +/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-type-vararg.html +class ProTypeVarargCheck : public ClangTidyCheck { +public: + ProTypeVarargCheck(StringRef Name, ClangTidyContext *Context) + : ClangTidyCheck(Name, Context) {} + void registerMatchers(ast_matchers::MatchFinder *Finder) override; + void check(const ast_matchers::MatchFinder::MatchResul
r250757 - [MS ABI] Give linkonce_odr, instead of external_linkage, to certain kinds of static data members
Author: majnemer Date: Mon Oct 19 18:22:49 2015 New Revision: 250757 URL: http://llvm.org/viewvc/llvm-project?rev=250757&view=rev Log: [MS ABI] Give linkonce_odr, instead of external_linkage, to certain kinds of static data members Out-of-line definitions of static data members which have an inline initializer must get GVA_DiscardableODR linkage instead of GVA_StrongExternal linkage. MSVC 2013's behavior is different with respect to this and would cause link errors if one TU provided a definition while another did not. MSVC 2015 fixed this bug, making this OK. Note that the 2015 behavior is always compatible with 2013: it never produces a strong definition. This essentially reverts r237787. Modified: cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/test/CodeGenCXX/dllexport-members.cpp cfe/trunk/test/CodeGenCXX/ms-integer-static-data-members.cpp Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=250757&r1=250756&r2=250757&view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Mon Oct 19 18:22:49 2015 @@ -5035,8 +5035,8 @@ CharUnits ASTContext::getObjCEncodingTyp bool ASTContext::isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const { return getTargetInfo().getCXXABI().isMicrosoft() && VD->isStaticDataMember() && - VD->getType()->isIntegralOrEnumerationType() && VD->isFirstDecl() && - !VD->isOutOfLine() && VD->hasInit(); + VD->getType()->isIntegralOrEnumerationType() && + !VD->getFirstDecl()->isOutOfLine() && VD->getFirstDecl()->hasInit(); } static inline Modified: cfe/trunk/test/CodeGenCXX/dllexport-members.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport-members.cpp?rev=250757&r1=250756&r2=250757&view=diff == --- cfe/trunk/test/CodeGenCXX/dllexport-members.cpp (original) +++ cfe/trunk/test/CodeGenCXX/dllexport-members.cpp Mon Oct 19 18:22:49 2015 @@ -110,10 +110,10 @@ public: // MSC-DAG: @"\01?StaticField@ExportMembers@@2HA" = dllexport global i32 1, align 4 // MSC-DAG: @"\01?StaticConstField@ExportMembers@@2HB" = dllexport constant i32 1, align 4 - // MSC-DAG: @"\01?StaticConstFieldEqualInit@ExportMembers@@2HB" = dllexport constant i32 1, comdat, align 4 - // MSC-DAG: @"\01?StaticConstFieldBraceInit@ExportMembers@@2HB" = dllexport constant i32 1, comdat, align 4 + // MSC-DAG: @"\01?StaticConstFieldEqualInit@ExportMembers@@2HB" = weak_odr dllexport constant i32 1, comdat, align 4 + // MSC-DAG: @"\01?StaticConstFieldBraceInit@ExportMembers@@2HB" = weak_odr dllexport constant i32 1, comdat, align 4 // MSC-DAG: @"\01?StaticConstFieldRefNotDef@ExportMembers@@2HB" = weak_odr dllexport constant i32 1, comdat, align 4 - // MSC-DAG: @"\01?ConstexprField@ExportMembers@@2HB"= dllexport constant i32 1, comdat, align 4 + // MSC-DAG: @"\01?ConstexprField@ExportMembers@@2HB"= weak_odr dllexport constant i32 1, comdat, align 4 // GNU-DAG: @_ZN13ExportMembers11StaticFieldE = dllexport global i32 1, align 4 // GNU-DAG: @_ZN13ExportMembers16StaticConstFieldE = dllexport constant i32 1, align 4 // GNU-DAG: @_ZN13ExportMembers25StaticConstFieldEqualInitE = dllexport constant i32 1, align 4 @@ -236,10 +236,10 @@ public: // MSC-DAG: @"\01?StaticField@Nested@ExportMembers@@2HA" = dllexport global i32 1, align 4 // MSC-DAG: @"\01?StaticConstField@Nested@ExportMembers@@2HB" = dllexport constant i32 1, align 4 - // MSC-DAG: @"\01?StaticConstFieldEqualInit@Nested@ExportMembers@@2HB" = dllexport constant i32 1, comdat, align 4 - // MSC-DAG: @"\01?StaticConstFieldBraceInit@Nested@ExportMembers@@2HB" = dllexport constant i32 1, comdat, align 4 + // MSC-DAG: @"\01?StaticConstFieldEqualInit@Nested@ExportMembers@@2HB" = weak_odr dllexport constant i32 1, comdat, align 4 + // MSC-DAG: @"\01?StaticConstFieldBraceInit@Nested@ExportMembers@@2HB" = weak_odr dllexport constant i32 1, comdat, align 4 // MSC-DAG: @"\01?StaticConstFieldRefNotDef@Nested@ExportMembers@@2HB" = weak_odr dllexport constant i32 1, comdat, align 4 - // MSC-DAG: @"\01?ConstexprField@Nested@ExportMembers@@2HB"= dllexport constant i32 1, comdat, align 4 + // MSC-DAG: @"\01?ConstexprField@Nested@ExportMembers@@2HB"= weak_odr dllexport constant i32 1, comdat, align 4 // GNU-DAG: @_ZN13ExportMembers6Nested11StaticFieldE = dllexport global i32 1, align 4 // GNU-DAG: @_ZN13ExportMembers6Nested16StaticConstFieldE = dllexport constant i32 1, align 4 // GNU-DAG: @_ZN13ExportMembers6Nested25StaticConstFieldEqualInitE = dllexport constant i32 1, align 4 Modified: cfe/trunk/test/C
Re: r250418 - [CodeGen] Remove dead code. NFC.
> On Oct 15, 2015, at 8:29 AM, Benjamin Kramer via cfe-commits > wrote: > > Author: d0k > Date: Thu Oct 15 10:29:40 2015 > New Revision: 250418 > > URL: http://llvm.org/viewvc/llvm-project?rev=250418&view=rev > Log: > [CodeGen] Remove dead code. NFC. > > Modified: >cfe/trunk/lib/CodeGen/CGBuiltin.cpp >cfe/trunk/lib/CodeGen/CGCall.cpp >cfe/trunk/lib/CodeGen/CGCleanup.cpp >cfe/trunk/lib/CodeGen/CGDebugInfo.cpp >cfe/trunk/lib/CodeGen/CGDebugInfo.h >cfe/trunk/lib/CodeGen/CGObjC.cpp >cfe/trunk/lib/CodeGen/CGObjCMac.cpp >cfe/trunk/lib/CodeGen/CGVTables.h >cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp >cfe/trunk/lib/CodeGen/CodeGenFunction.h >cfe/trunk/lib/CodeGen/CodeGenModule.cpp >cfe/trunk/lib/CodeGen/CodeGenModule.h >cfe/trunk/lib/CodeGen/CodeGenPGO.h >cfe/trunk/lib/CodeGen/EHScopeStack.h >cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp > > Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=250418&r1=250417&r2=250418&view=diff > == > --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Oct 15 10:29:40 2015 > @@ -4106,15 +4106,6 @@ Value *CodeGenFunction::vectorWrapScalar > return Op; > } > > -Value *CodeGenFunction::vectorWrapScalar8(Value *Op) { > - llvm::Type *VTy = llvm::VectorType::get(Int8Ty, 8); > - Op = Builder.CreateBitCast(Op, Int8Ty); > - Value *V = UndefValue::get(VTy); > - llvm::Constant *CI = ConstantInt::get(SizeTy, 0); > - Op = Builder.CreateInsertElement(V, Op, CI); > - return Op; > -} > - > Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, >const CallExpr *E) { > unsigned HintID = static_cast(-1); > > Modified: cfe/trunk/lib/CodeGen/CGCall.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=250418&r1=250417&r2=250418&view=diff > == > --- cfe/trunk/lib/CodeGen/CGCall.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Oct 15 10:29:40 2015 > @@ -3038,12 +3038,6 @@ CodeGenFunction::EmitRuntimeCallOrInvoke > return callSite; > } > > -llvm::CallSite > -CodeGenFunction::EmitCallOrInvoke(llvm::Value *Callee, > - const Twine &Name) { > - return EmitCallOrInvoke(Callee, None, Name); > -} > - > /// Emits a call or invoke instruction to the given function, depending > /// on the current state of the EH stack. > llvm::CallSite > > Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=250418&r1=250417&r2=250418&view=diff > == > --- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Thu Oct 15 10:29:40 2015 > @@ -167,23 +167,6 @@ EHScopeStack::getInnermostActiveNormalCl > return stable_end(); > } > > -EHScopeStack::stable_iterator EHScopeStack::getInnermostActiveEHScope() > const { > - for (stable_iterator si = getInnermostEHScope(), se = stable_end(); > - si != se; ) { > -// Skip over inactive cleanups. > -EHCleanupScope *cleanup = dyn_cast(&*find(si)); > -if (cleanup && !cleanup->isActive()) { > - si = cleanup->getEnclosingEHScope(); > - continue; > -} > - > -// All other scopes are always active. > -return si; > - } > - > - return stable_end(); > -} > - > > void *EHScopeStack::pushCleanup(CleanupKind Kind, size_t Size) { > char *Buffer = allocate(EHCleanupScope::getSizeForCleanupSize(Size)); > > Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=250418&r1=250417&r2=250418&view=diff > == > --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Oct 15 10:29:40 2015 > @@ -2159,30 +2159,6 @@ llvm::DIType *CGDebugInfo::getOrCreateTy > return Res; > } > > -unsigned CGDebugInfo::Checksum(const ObjCInterfaceDecl *ID) { > - // The assumption is that the number of ivars can only increase > - // monotonically, so it is safe to just use their current number as > - // a checksum. > - unsigned Sum = 0; > - for (const ObjCIvarDecl *Ivar = ID->all_declared_ivar_begin(); > - Ivar != nullptr; Ivar = Ivar->getNextIvar()) > -++Sum; > - > - return Sum; > -} > - > -ObjCInterfaceDecl *CGDebugInfo::getObjCInterfaceDecl(QualType Ty) { > - switch (Ty->getTypeClass()) { > - case Type::ObjCObjectPointer: > -return getObjCInterfaceDecl( > -cast(Ty)->getPointeeType()); > - case Type::ObjCInterface: > -return cast(Ty)->getDecl(); > - default: > -return nullptr; > - }
r250764 - [X86] Remove a few 'else' after 'return'
Author: ctopper Date: Mon Oct 19 19:00:17 2015 New Revision: 250764 URL: http://llvm.org/viewvc/llvm-project?rev=250764&view=rev Log: [X86] Remove a few 'else' after 'return' Modified: cfe/trunk/lib/Basic/Targets.cpp Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=250764&r1=250763&r2=250764&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Mon Oct 19 19:00:17 2015 @@ -2386,9 +2386,9 @@ public: StringRef getABI() const override { if (getTriple().getArch() == llvm::Triple::x86_64 && SSELevel >= AVX512F) return "avx512"; -else if (getTriple().getArch() == llvm::Triple::x86_64 && SSELevel >= AVX) +if (getTriple().getArch() == llvm::Triple::x86_64 && SSELevel >= AVX) return "avx"; -else if (getTriple().getArch() == llvm::Triple::x86 && +if (getTriple().getArch() == llvm::Triple::x86 && MMX3DNowLevel == NoMMX3DNow) return "no-mmx"; return ""; @@ -3025,11 +3025,10 @@ bool X86TargetInfo::handleTargetFeatures // LLVM doesn't have a separate switch for fpmath, so only accept it if it // matches the selected sse level. - if (FPMath == FP_SSE && SSELevel < SSE1) { -Diags.Report(diag::err_target_unsupported_fpmath) << "sse"; -return false; - } else if (FPMath == FP_387 && SSELevel >= SSE1) { -Diags.Report(diag::err_target_unsupported_fpmath) << "387"; + if ((FPMath == FP_SSE && SSELevel < SSE1) || + (FPMath == FP_387 && SSELevel >= SSE1)) { +Diags.Report(diag::err_target_unsupported_fpmath) << + (FPMath == FP_SSE ? "sse" : "387"); return false; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13336: [MSVC] 'property' with an empty array in array subscript expression.
rnk added a subscriber: rnk. rnk added a comment. I spent some time reading through the pseudo-object implementation in clang, but I still don't understand it. We should ask John if he can review this. My gut feeling is that we shouldn't have a global DenseMap in Sema just for this. Should we have some other node, like an ObjCSubscriptRefExpr that describes this instead? We need *some* AST for the as-written syntactic form. Can you send a dump of the AST for the test? Comment at: lib/Sema/SemaExpr.cpp:3986-3987 @@ -3971,1 +3985,4 @@ + if (MSProp && MSProp->getPropertyDecl()->getType()->isArrayType()) +return base; + Will this affect the syntactic form of the expression? Comment at: test/CodeGenCXX/ms-property.cpp:32 @@ +31,3 @@ + // CHECK-NEXT: call void @"\01?PutX@?$St@M@@QEAAXMMM@Z"(%class.St* %{{.+}}, float 2.30e+01, float 1.00e+00, float [[J1]]) + p2->x[23][1] = j1; + return 0; Can you add a ++ test? http://reviews.llvm.org/D13336 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r250774 - Revert "Diagnose UnresolvedLookupExprs that resolve to instance members in static methods"
Author: rnk Date: Mon Oct 19 19:31:42 2015 New Revision: 250774 URL: http://llvm.org/viewvc/llvm-project?rev=250774&view=rev Log: Revert "Diagnose UnresolvedLookupExprs that resolve to instance members in static methods" This reverts commit r250592. It has issues around unevaluated contexts, like this: template struct A { T i; }; template struct B : A { using A::i; typedef decltype(i) U; }; template struct B; Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaExprMember.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/test/SemaCXX/using-decl-1.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=250774&r1=250773&r2=250774&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Mon Oct 19 19:31:42 2015 @@ -3692,9 +3692,6 @@ public: Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation()); - void DiagnoseInstanceReference(const CXXScopeSpec &SS, NamedDecl *Rep, - const DeclarationNameInfo &nameInfo); - ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=250774&r1=250773&r2=250774&view=diff == --- cfe/trunk/lib/Sema/SemaExprMember.cpp (original) +++ cfe/trunk/lib/Sema/SemaExprMember.cpp Mon Oct 19 19:31:42 2015 @@ -192,8 +192,10 @@ static IMAKind ClassifyImplicitMemberAcc } /// Diagnose a reference to a field with no object available. -void Sema::DiagnoseInstanceReference(const CXXScopeSpec &SS, NamedDecl *Rep, - const DeclarationNameInfo &nameInfo) { +static void diagnoseInstanceReference(Sema &SemaRef, + const CXXScopeSpec &SS, + NamedDecl *Rep, + const DeclarationNameInfo &nameInfo) { SourceLocation Loc = nameInfo.getLoc(); SourceRange Range(Loc); if (SS.isSet()) Range.setBegin(SS.getRange().getBegin()); @@ -201,7 +203,7 @@ void Sema::DiagnoseInstanceReference(con // Look through using shadow decls and aliases. Rep = Rep->getUnderlyingDecl(); - DeclContext *FunctionLevelDC = getFunctionLevelDeclContext(); + DeclContext *FunctionLevelDC = SemaRef.getFunctionLevelDeclContext(); CXXMethodDecl *Method = dyn_cast(FunctionLevelDC); CXXRecordDecl *ContextClass = Method ? Method->getParent() : nullptr; CXXRecordDecl *RepClass = dyn_cast(Rep->getDeclContext()); @@ -211,19 +213,20 @@ void Sema::DiagnoseInstanceReference(con if (IsField && InStaticMethod) // "invalid use of member 'x' in static member function" -Diag(Loc, diag::err_invalid_member_use_in_static_method) +SemaRef.Diag(Loc, diag::err_invalid_member_use_in_static_method) << Range << nameInfo.getName(); else if (ContextClass && RepClass && SS.isEmpty() && !InStaticMethod && !RepClass->Equals(ContextClass) && RepClass->Encloses(ContextClass)) // Unqualified lookup in a non-static member function found a member of an // enclosing class. -Diag(Loc, diag::err_nested_non_static_member_use) -<< IsField << RepClass << nameInfo.getName() << ContextClass << Range; +SemaRef.Diag(Loc, diag::err_nested_non_static_member_use) + << IsField << RepClass << nameInfo.getName() << ContextClass << Range; else if (IsField) -Diag(Loc, diag::err_invalid_non_static_member_use) << nameInfo.getName() - << Range; +SemaRef.Diag(Loc, diag::err_invalid_non_static_member_use) + << nameInfo.getName() << Range; else -Diag(Loc, diag::err_member_call_without_object) << Range; +SemaRef.Diag(Loc, diag::err_member_call_without_object) + << Range; } /// Builds an expression which might be an implicit member expression. @@ -257,7 +260,7 @@ Sema::BuildPossibleImplicitMemberExpr(co case IMA_Error_StaticContext: case IMA_Error_Unrelated: -DiagnoseInstanceReference(SS, R.getRepresentativeDecl(), +diagnoseInstanceReference(*this, SS, R.getRepresentativeDecl(), R.getLookupNameInfo()); return ExprError(); } @@ -471,7 +474,7 @@ static void DiagnoseQualifiedMemberRefer // If this is an implicit member access, use a different set of // diagnostics. if (!BaseExpr) -return SemaRef.DiagnoseInstanceReference(SS, rep, nameInfo); +return diagnoseInstanceReference(SemaRef, SS, rep, nameInfo); SemaRef.Diag(nameInfo.getLoc
Re: [PATCH] D12922: Add support for function attribute "notail"
ahatanak updated this revision to Diff 37816. ahatanak added a comment. Address review comments: 1. Renamed the attribute to "not_tail_called". I chose "not_tail_called" over "notailcall" or "notail" to better distinguish it from the attribute that is proposed in http://reviews.llvm.org/D12547 (which is tentatively named "disable_tail_calls"). 2. Made changes to error-out if a virtual function or an objective-c method is marked "not_tail_called". I made this change because this attribute isn't useful when the compiler cannot resolve the function call statically at compile time and it isn't important for the use case I have. 3. Added code examples to AttrDocs.td. http://reviews.llvm.org/D12922 Files: include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticSemaKinds.td lib/CodeGen/CGCall.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclAttr.cpp test/CodeGen/attr-no-tail.c test/CodeGenCXX/attr-notail.cpp test/Sema/attr-notail.c test/SemaCXX/attr-notail.cpp Index: test/SemaCXX/attr-notail.cpp === --- /dev/null +++ test/SemaCXX/attr-notail.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +class Base { +public: + [[clang::not_tail_called]] virtual int foo1(); // expected-error {{'not_tail_called' attribute cannot be applied to virtual function}} + virtual int foo2(); + [[clang::not_tail_called]] int foo3(); + virtual ~Base() {} +}; + +class Derived1 : public Base { +public: + int foo1() override; + [[clang::not_tail_called]] int foo2() override; // expected-error {{'not_tail_called' attribute cannot be applied to virtual function}} + [[clang::not_tail_called]] int foo4(); +}; Index: test/Sema/attr-notail.c === --- /dev/null +++ test/Sema/attr-notail.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +int callee0() __attribute__((not_tail_called,always_inline)); // expected-error{{'not_tail_called' and 'always_inline' attributes are not compatible}} +int callee1() __attribute__((always_inline,not_tail_called)); // expected-error{{'always_inline' and 'not_tail_called' attributes are not compatible}} + +int foo(int a) { + return a ? callee0() : callee1(); +} Index: test/CodeGenCXX/attr-notail.cpp === --- /dev/null +++ test/CodeGenCXX/attr-notail.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -triple=x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s + +class Class1 { +public: + [[clang::not_tail_called]] int m1(); + int m2(); +}; + +int foo1(int a, Class1 *c1) { + if (a) +return c1->m1(); + return c1->m2(); +} + +// CHECK-LABEL: define i32 @_Z4foo1iP6Class1( +// CHECK: %{{[a-z0-9]+}} = notail call i32 @_ZN6Class12m1Ev(%class.Class1* +// CHECK: %{{[a-z0-9]+}} = call i32 @_ZN6Class12m2Ev(%class.Class1* Index: test/CodeGen/attr-no-tail.c === --- /dev/null +++ test/CodeGen/attr-no-tail.c @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -o - | FileCheck %s + +// CHECK: %{{[a-z0-9]+}} = notail call i32 @callee0(i32 % +// CHECK: %{{[a-z0-9]+}} = notail call i32 @callee1(i32 % + +// Check that indirect calls do not have the notail marker. +// CHECK: store i32 (i32)* @callee1, i32 (i32)** [[ALLOCA1:%[A-Za-z0-9]+]], align 8 +// CHECK: [[INDIRFUNC:%[0-9]+]] = load i32 (i32)*, i32 (i32)** [[ALLOCA1]], align 8 +// CHECK: %{{[a-z0-9]+}} = call i32 [[INDIRFUNC]](i32 %6) + +// CHECK: %{{[a-z0-9]+}} = call i32 @callee2(i32 % + +int callee0(int a) __attribute__((not_tail_called)) { + return a + 1; +} + +int callee1(int) __attribute__((not_tail_called)); + +int callee2(int); + +typedef int (*FuncTy)(int); + +int foo0(int a) { + if (a > 1) +return callee0(a); + if (a == 1) +return callee1(a); + if (a < 0) { +FuncTy F = callee1; +return (*F)(a); + } + return callee2(a); +} Index: lib/Sema/SemaDeclAttr.cpp === --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -1701,6 +1701,15 @@ Attr.getAttributeSpellingListIndex())); } +static void handleNotTailCalledAttr(Sema &S, Decl *D, +const AttributeList &Attr) { + if (checkAttrMutualExclusion(S, D, Attr)) +return; + + D->addAttr(::new (S.Context) NotTailCalledAttr( + Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex())); +} + static void handleUsedAttr(Sema &S, Decl *D, const AttributeList &Attr) { if (const VarDecl *VD = dyn_cast(D)) { if (VD->hasLocalStorage()) { @@ -3335,6 +3344,9 @@ static void handleAlwaysInlineAttr(Sema &S, Decl *D, const AttributeList &Attr) { + if (checkAttrMutualExclusion(S, D, Attr)) +return; + if (Always
Re: [PATCH] D13871: Add modernize-use-default check to clang-tidy.
Eugene.Zelenko added a subscriber: Eugene.Zelenko. Eugene.Zelenko added a comment. Will be good idea to add handling of cases where default constructor is empty and only call base class(es) default constructor/members default constructors (see http://en.cppreference.com/w/cpp/language/default_constructor). In test check should suggest to use default for N() : H() {}. Of course, if it will be easy to implement. Otherwise, such cases may be left for future development. http://reviews.llvm.org/D13871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13871: Add modernize-use-default check to clang-tidy.
george.burgess.iv added a subscriber: george.burgess.iv. george.burgess.iv added a comment. This looks like a good check -- thanks for adding it! Just one small nit for you. Comment at: clang-tidy/modernize/UseDefaultCheck.cpp:19 @@ +18,3 @@ + +const char CtorDtor[] = "CtorDtorDecl"; + I don't see where this is used outside of UseDefaultCheck.cpp. Can we make it static? http://reviews.llvm.org/D13871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r250577 - [modules] Allow the error when explicitly loading an incompatible module file
On Fri, Oct 16, 2015 at 6:41 PM, Richard Smith wrote: > On Fri, Oct 16, 2015 at 6:30 PM, Sean Silva wrote: > >> On Fri, Oct 16, 2015 at 6:26 PM, Richard Smith >> wrote: >> >>> On Fri, Oct 16, 2015 at 6:25 PM, Sean Silva >>> wrote: >>> On Fri, Oct 16, 2015 at 6:12 PM, Richard Smith wrote: > On Fri, Oct 16, 2015 at 4:43 PM, Sean Silva > wrote: > >> On Fri, Oct 16, 2015 at 4:20 PM, Richard Smith via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Author: rsmith >>> Date: Fri Oct 16 18:20:19 2015 >>> New Revision: 250577 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=250577&view=rev >>> Log: >>> [modules] Allow the error when explicitly loading an incompatible >>> module file >>> via -fmodule-file= to be turned off; in that case, just include the >>> relevant >>> files textually. This allows module files to be unconditionally >>> passed to all >>> compile actions via CXXFLAGS, and to be ignored for rules that >>> specify custom >>> incompatible flags. >>> >> >> What direction are you trying to go with this? Are you thinking >> something like having CMake build a bunch of modules up front? >> > > That's certainly one thing you can do with this. Another is that you > can make cmake automatically and explicitly build a module for each > library, and then provide that for all the dependencies of that library, > How does CMake know which headers are part of which library? Strategically named top-level modules in the module map? >>> >>> The idea would be for CMake to generate the module map itself based on >>> the build rules. >>> >> >> How would it know which headers to include? Do our ADDITIONAL_HEADER_DIRS >> things in our CMakeLists.txt have enough information for this? >> > > Some additional information may need to be added to the CMakeLists to > enable this. Some build systems already model the headers for a library, > and so already have the requisite information. > Yeah, I was wondering whether you were diving into doing that :) Any way you could import this info from the bazel rules you guys already have? -- Sean Silva > > >> -- Sean Silva >> >> >>> >>> -- Sean Silva > with an (error-by-default) warning in the case where the downstream > library specifies incompatible compilation flags. You can use this warning > flag to turn off the error so you can make progress before you get around > to fixing all the incompatible flags. > > >> If that's the case, it would be nice to explain what caused the >> mismatch, so that the user can look into rectifying it. Otherwise this >> warning is not directly actionable. The existing diagnostics seemed >> alright. Demoting them to "error: {{.*}} configuration mismatch" seems >> like >> a regression. >> > > I agree, it is a regression, and fixing it is high on my list of > priorities (sorry for not mentioning that in the commit message). > > -- Sean Silva >> >> >>> >>> Modified: >>> cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td >>> cfe/trunk/lib/Frontend/CompilerInstance.cpp >>> cfe/trunk/test/Modules/merge-target-features.cpp >>> >>> Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=250577&r1=250576&r2=250577&view=diff >>> >>> == >>> --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td >>> (original) >>> +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Fri Oct >>> 16 18:20:19 2015 >>> @@ -172,6 +172,9 @@ def warn_incompatible_analyzer_plugin_ap >>> def note_incompatible_analyzer_plugin_api : Note< >>> "current API version is '%0', but plugin was compiled with >>> version '%1'">; >>> >>> +def warn_module_config_mismatch : Warning< >>> + "module file %0 cannot be loaded due to a configuration mismatch >>> with the current " >>> + "compilation">, >>> InGroup>, DefaultError; >>> def err_module_map_not_found : Error<"module map file '%0' not >>> found">, >>>DefaultFatal; >>> def err_missing_module_name : Error< >>> >>> Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=250577&r1=250576&r2=250577&view=diff >>> >>> == >>> --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original) >>> +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Oct 16 18:20:19 >>> 2015 >>> @@ -1335,15 +1335,24 @@ bool CompilerInstance::loadModuleFi
Re: r250577 - [modules] Allow the error when explicitly loading an incompatible module file
On Mon, Oct 19, 2015 at 2:10 AM, Manuel Klimek wrote: > On Sat, Oct 17, 2015 at 3:41 AM Richard Smith via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> On Fri, Oct 16, 2015 at 6:30 PM, Sean Silva >> wrote: >> >>> On Fri, Oct 16, 2015 at 6:26 PM, Richard Smith >>> wrote: >>> On Fri, Oct 16, 2015 at 6:25 PM, Sean Silva wrote: > On Fri, Oct 16, 2015 at 6:12 PM, Richard Smith > wrote: > >> On Fri, Oct 16, 2015 at 4:43 PM, Sean Silva >> wrote: >> >>> On Fri, Oct 16, 2015 at 4:20 PM, Richard Smith via cfe-commits < >>> cfe-commits@lists.llvm.org> wrote: >>> Author: rsmith Date: Fri Oct 16 18:20:19 2015 New Revision: 250577 URL: http://llvm.org/viewvc/llvm-project?rev=250577&view=rev Log: [modules] Allow the error when explicitly loading an incompatible module file via -fmodule-file= to be turned off; in that case, just include the relevant files textually. This allows module files to be unconditionally passed to all compile actions via CXXFLAGS, and to be ignored for rules that specify custom incompatible flags. >>> >>> What direction are you trying to go with this? Are you thinking >>> something like having CMake build a bunch of modules up front? >>> >> >> That's certainly one thing you can do with this. Another is that you >> can make cmake automatically and explicitly build a module for each >> library, and then provide that for all the dependencies of that library, >> > > How does CMake know which headers are part of which library? > Strategically named top-level modules in the module map? > The idea would be for CMake to generate the module map itself based on the build rules. >>> >>> How would it know which headers to include? Do >>> our ADDITIONAL_HEADER_DIRS things in our CMakeLists.txt have enough >>> information for this? >>> >> >> Some additional information may need to be added to the CMakeLists to >> enable this. Some build systems already model the headers for a library, >> and so already have the requisite information. >> > > CMake supports specifying headers for libraries (mainly used for MS VS). > If we need this for modules, we'll probably need to update our build rules > (which will probably make sense anyway, for a better experience for VS > users ;) > Nice. Brad, do you have any idea how hard it would be to get cmake to generate clang module map files and add explicit module build steps? Basically, the requirements (off the top of my head) are: - for each library, generate a module map which is essentially just a list of the headers in that library (it's not just a flat list, but that's the gist of it). - for each module map, add a build step that invokes clang on it to say "build the module corresponding to this module map" (it's basically `clang++ path/to/foo.modulemap -o foo.pcm` with a little bit of fluff around it). There is also a dependency from foo.pcm on each of the libraries that library "foo" depends on. - for each library $Dep that library $Lib depends on, add $Dep's .pcm file as a dependency of the .o build steps for $Lib. $Dep's .pcm file also needs to be passed on the command line of the .o build steps for $Lib. It seems like similar requirements are going to be common in the standardized modules feature (except for the module map I think? Richard?). Basically, in order to avoid redundantly parsing textual headers, you need to run a build step on headers that turns them into some form that can be processed more efficiently than just parsing it. E.g. the build step on slide 36 of this cppcon presentation about the Microsoft experimental modules implementation https://www.youtube.com/watch?v=RwdQA0pGWa4 (slides: https://goo.gl/t4Eg89 ). Let me know if there is anything I can do to help (up to and including patches, but I'll need pointers and possibly some hand-holding as I'm unfamiliar with the CMake language and CMake codebase). There's also some issues of detecting if the host clang is new enough that we want to use its modules feature and also the issue of detecting modularized system headers if available, but we can hammer those things out as we run into them. Manuel, I heard through the grape vine that you were the one that implemented the explicit modules stuff for bazel? Did I miss anything in my list above? Richard, are there any blockers to exposing a driver flag for explicit modules? -- Sean Silva > > >> >> >>> -- Sean Silva >>> >>> > -- Sean Silva > > >> with an (error-by-default) warning in the case where the downstream >> library specifies incompatible compilation flags. You can use this >> warning >> flag to turn off the error so you can make progress before you get around >> to fixing all the incompatible flags. >> >> >>
LLVM buildmaster will be restarted in few minutes
Hello everyone, LLVM buildmaster will restarted in few minutes. Thank you for understanding. Thanks Galina ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r250795 - [DEBUG INFO] Emit debug info for type used in explicit cast only.
Author: abataev Date: Mon Oct 19 23:24:12 2015 New Revision: 250795 URL: http://llvm.org/viewvc/llvm-project?rev=250795&view=rev Log: [DEBUG INFO] Emit debug info for type used in explicit cast only. Currently debug info for types used in explicit cast only is not emitted. It happened after a patch for better alignment handling. This patch fixes this bug. Differential Revision: http://reviews.llvm.org/D13582 Added: cfe/trunk/test/CodeGenCXX/debug-info-explicit-cast.cpp (with props) Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGExprAgg.cpp cfe/trunk/lib/CodeGen/CGExprCXX.cpp cfe/trunk/lib/CodeGen/CGExprComplex.cpp cfe/trunk/lib/CodeGen/CGExprConstant.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=250795&r1=250794&r2=250795&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Oct 19 23:24:12 2015 @@ -780,6 +780,16 @@ EmitComplexPrePostIncDec(const UnaryOper return isPre ? IncVal : InVal; } +void CodeGenModule::EmitExplicitCastExprType(const ExplicitCastExpr *E, + CodeGenFunction *CGF) { + // Bind VLAs in the cast type. + if (CGF && E->getType()->isVariablyModifiedType()) +CGF->EmitVariablyModifiedType(E->getType()); + + if (CGDebugInfo *DI = getModuleDebugInfo()) +DI->EmitExplicitCastType(E->getType()); +} + //===--===// // LValue Expression Emission //===--===// @@ -795,9 +805,8 @@ Address CodeGenFunction::EmitPointerWith // Casts: if (const CastExpr *CE = dyn_cast(E)) { -// Bind VLAs in the cast type. -if (E->getType()->isVariablyModifiedType()) - EmitVariablyModifiedType(E->getType()); +if (const auto *ECE = dyn_cast(CE)) + CGM.EmitExplicitCastExprType(ECE, this); switch (CE->getCastKind()) { // Non-converting casts (but not C's implicit conversion from void*). @@ -3427,6 +3436,7 @@ LValue CodeGenFunction::EmitCastLValue(c // This must be a reinterpret_cast (or c-style equivalent). const auto *CE = cast(E); +CGM.EmitExplicitCastExprType(CE, this); LValue LV = EmitLValue(E->getSubExpr()); Address V = Builder.CreateBitCast(LV.getAddress(), ConvertType(CE->getTypeAsWritten())); Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=250795&r1=250794&r2=250795&view=diff == --- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Mon Oct 19 23:24:12 2015 @@ -571,6 +571,8 @@ static Expr *findPeephole(Expr *op, Cast } void AggExprEmitter::VisitCastExpr(CastExpr *E) { + if (const auto *ECE = dyn_cast(E)) +CGF.CGM.EmitExplicitCastExprType(ECE, &CGF); switch (E->getCastKind()) { case CK_Dynamic: { // FIXME: Can this actually happen? We have no test coverage for it. Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=250795&r1=250794&r2=250795&view=diff == --- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Mon Oct 19 23:24:12 2015 @@ -1806,6 +1806,7 @@ static llvm::Value *EmitDynamicCastToNul llvm::Value *CodeGenFunction::EmitDynamicCast(Address ThisAddr, const CXXDynamicCastExpr *DCE) { + CGM.EmitExplicitCastExprType(DCE, this); QualType DestTy = DCE->getTypeAsWritten(); if (DCE->isAlwaysNull()) Modified: cfe/trunk/lib/CodeGen/CGExprComplex.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=250795&r1=250794&r2=250795&view=diff == --- cfe/trunk/lib/CodeGen/CGExprComplex.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp Mon Oct 19 23:24:12 2015 @@ -154,6 +154,8 @@ public: return EmitCast(E->getCastKind(), E->getSubExpr(), E->getType()); } ComplexPairTy VisitCastExpr(CastExpr *E) { +if (const auto *ECE = dyn_cast(E)) + CGF.CGM.EmitExplicitCastExprType(ECE, &CGF); return EmitCast(E->getCastKind(), E->getSubExpr(), E->getType()); } ComplexPairTy VisitCallExpr(const CallExpr *E); Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=250795&r1=250794&r2=250795&view=diff =
Re: [PATCH] D13582: [DEBUG INFO] Emit debug info for type used in explicit cast only.
This revision was automatically updated to reflect the committed changes. Closed by commit rL250795: [DEBUG INFO] Emit debug info for type used in explicit cast only. (authored by ABataev). Changed prior to commit: http://reviews.llvm.org/D13582?vs=37476&id=37825#toc Repository: rL LLVM http://reviews.llvm.org/D13582 Files: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGExprAgg.cpp cfe/trunk/lib/CodeGen/CGExprCXX.cpp cfe/trunk/lib/CodeGen/CGExprComplex.cpp cfe/trunk/lib/CodeGen/CGExprConstant.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/test/CodeGenCXX/debug-info-explicit-cast.cpp Index: cfe/trunk/test/CodeGenCXX/debug-info-explicit-cast.cpp === --- cfe/trunk/test/CodeGenCXX/debug-info-explicit-cast.cpp +++ cfe/trunk/test/CodeGenCXX/debug-info-explicit-cast.cpp @@ -0,0 +1,46 @@ +// RUN: %clangxx -c -target %itanium_abi_triple -g %s -emit-llvm -S -o - | FileCheck %s +// RUN: %clangxx -c -target %ms_abi_triple -g %s -emit-llvm -S -o - | FileCheck %s + +struct Foo { + int A; + Foo() : A(1){}; +}; + +struct Bar { + int B; + Bar() : B(2){}; +}; + +struct Baz { + int C; + Baz() : C(3){}; +}; + +struct Qux { + int d() { return 4; } + Qux() {}; +}; + +struct Quux { + int E; + Quux() : E(5){}; +}; + +typedef int(Qux::*TD)(); +typedef int(Qux::*TD1)(); +int Val = reinterpret_cast(0)->C; +int main() { + Bar *PB = new Bar; + TD d = &Qux::d; + (void)reinterpret_cast(d); + + return reinterpret_cast(PB)->A + reinterpret_cast(0)->E; +} + +// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", +// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "Bar", +// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "Baz", +// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "Qux", +// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "Quux", +// CHECK-DAG: !DIDerivedType(tag: DW_TAG_typedef, name: "TD", +// CHECK-DAG: !DIDerivedType(tag: DW_TAG_typedef, name: "TD1", Index: cfe/trunk/lib/CodeGen/CGExprComplex.cpp === --- cfe/trunk/lib/CodeGen/CGExprComplex.cpp +++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp @@ -154,6 +154,8 @@ return EmitCast(E->getCastKind(), E->getSubExpr(), E->getType()); } ComplexPairTy VisitCastExpr(CastExpr *E) { +if (const auto *ECE = dyn_cast(E)) + CGF.CGM.EmitExplicitCastExprType(ECE, &CGF); return EmitCast(E->getCastKind(), E->getSubExpr(), E->getType()); } ComplexPairTy VisitCallExpr(const CallExpr *E); Index: cfe/trunk/lib/CodeGen/CGExpr.cpp === --- cfe/trunk/lib/CodeGen/CGExpr.cpp +++ cfe/trunk/lib/CodeGen/CGExpr.cpp @@ -780,6 +780,16 @@ return isPre ? IncVal : InVal; } +void CodeGenModule::EmitExplicitCastExprType(const ExplicitCastExpr *E, + CodeGenFunction *CGF) { + // Bind VLAs in the cast type. + if (CGF && E->getType()->isVariablyModifiedType()) +CGF->EmitVariablyModifiedType(E->getType()); + + if (CGDebugInfo *DI = getModuleDebugInfo()) +DI->EmitExplicitCastType(E->getType()); +} + //===--===// // LValue Expression Emission //===--===// @@ -795,9 +805,8 @@ // Casts: if (const CastExpr *CE = dyn_cast(E)) { -// Bind VLAs in the cast type. -if (E->getType()->isVariablyModifiedType()) - EmitVariablyModifiedType(E->getType()); +if (const auto *ECE = dyn_cast(CE)) + CGM.EmitExplicitCastExprType(ECE, this); switch (CE->getCastKind()) { // Non-converting casts (but not C's implicit conversion from void*). @@ -3427,6 +3436,7 @@ // This must be a reinterpret_cast (or c-style equivalent). const auto *CE = cast(E); +CGM.EmitExplicitCastExprType(CE, this); LValue LV = EmitLValue(E->getSubExpr()); Address V = Builder.CreateBitCast(LV.getAddress(), ConvertType(CE->getTypeAsWritten())); Index: cfe/trunk/lib/CodeGen/CodeGenModule.h === --- cfe/trunk/lib/CodeGen/CodeGenModule.h +++ cfe/trunk/lib/CodeGen/CodeGenModule.h @@ -921,6 +921,11 @@ QualType DestType, CodeGenFunction *CGF = nullptr); + /// \brief Emit type info if type of an expression is a variably modified + /// type. Also emit proper debug info for cast types. + void EmitExplicitCastExprType(const ExplicitCastExpr *E, +CodeGenFunction *CGF = nullptr); + /// Return the result of value-initializing the given type, i.e. a null /// expression of the given type. Th
Re: [PATCH] D13336: [MSVC] 'property' with an empty array in array subscript expression.
rjmccall added a comment. I agree with Reid that you should not be adding a DenseMap to Sema for this. Just build a SubscriptExpr for the syntactic form and have it yield an expression of pseudo-object type; or you can make your own AST node for it if that makes things easier. http://reviews.llvm.org/D13336 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13861: [x86] fix wrong maskload/store intrinsic definitions in avxintrin.h (follow up of D13776).
delena added a comment. LGTM http://reviews.llvm.org/D13861 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13643: [Sema] Warn on ternary comparison
danielmarjamaki added a subscriber: danielmarjamaki. danielmarjamaki added a comment. Interesting checker. I'll test it on some debian projects. If you're interested.. it does not currently warn about "1.0 < 2.0 < 3.0" as far as I see. http://reviews.llvm.org/D13643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits