r280786 - Fix whitespace issues
Author: arsenm Date: Wed Sep 7 02:07:59 2016 New Revision: 280786 URL: http://llvm.org/viewvc/llvm-project?rev=280786&view=rev Log: Fix whitespace issues ^M and extra space 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=280786&r1=280785&r2=280786&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Sep 7 02:07:59 2016 @@ -6969,7 +6969,6 @@ void AMDGPUTargetCodeGenInfo::setTargetA appendOpenCLVersionMD(M); } - unsigned AMDGPUTargetCodeGenInfo::getOpenCLKernelCallingConv() const { return llvm::CallingConv::AMDGPU_KERNEL; @@ -7644,7 +7643,7 @@ void SPIRTargetCodeGenInfo::emitTargetMD appendOpenCLVersionMD(CGM); } -static void appendOpenCLVersionMD (CodeGen::CodeGenModule &CGM) { +static void appendOpenCLVersionMD(CodeGen::CodeGenModule &CGM) { llvm::LLVMContext &Ctx = CGM.getModule().getContext(); llvm::Type *Int32Ty = llvm::Type::getInt32Ty(Ctx); llvm::Module &M = CGM.getModule(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r280787 - OpenCL: Defining __ENDIAN_LITTLE__ and fix target endianness
Author: arsenm Date: Wed Sep 7 02:08:02 2016 New Revision: 280787 URL: http://llvm.org/viewvc/llvm-project?rev=280787&view=rev Log: OpenCL: Defining __ENDIAN_LITTLE__ and fix target endianness OpenCL requires __ENDIAN_LITTLE__ be set for little endian targets. The default for targets was also apparently big endian, so AMDGPU was incorrectly reported as big endian. Set this from the triple so targets don't have another place to set the endianness. Modified: cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/lib/Basic/TargetInfo.cpp cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/Frontend/InitPreprocessor.cpp cfe/trunk/test/Preprocessor/init.c Modified: cfe/trunk/include/clang/Basic/TargetInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=280787&r1=280786&r2=280787&view=diff == --- cfe/trunk/include/clang/Basic/TargetInfo.h (original) +++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Sep 7 02:08:02 2016 @@ -939,6 +939,7 @@ public: VersionTuple getPlatformMinVersion() const { return PlatformMinVersion; } bool isBigEndian() const { return BigEndian; } + bool isLittleEndian() const { return !BigEndian; } enum CallingConvMethodType { CCMT_Unknown, Modified: cfe/trunk/lib/Basic/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=280787&r1=280786&r2=280787&view=diff == --- cfe/trunk/lib/Basic/TargetInfo.cpp (original) +++ cfe/trunk/lib/Basic/TargetInfo.cpp Wed Sep 7 02:08:02 2016 @@ -27,7 +27,7 @@ static const LangAS::Map DefaultAddrSpac TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) { // Set defaults. Defaults are set for a 32-bit RISC platform, like PPC or // SPARC. These should be overridden by concrete targets as needed. - BigEndian = true; + BigEndian = !T.isLittleEndian(); TLSSupported = true; NoAsmVariants = false; HasFloat128 = false; Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=280787&r1=280786&r2=280787&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Wed Sep 7 02:08:02 2016 @@ -879,7 +879,6 @@ public: : TargetInfo(Triple), HasVSX(false), HasP8Vector(false), HasP8Crypto(false), HasDirectMove(false), HasQPX(false), HasHTM(false), HasBPERMD(false), HasExtDiv(false) { -BigEndian = (Triple.getArch() != llvm::Triple::ppc64le); SimdDefaultAlign = 128; LongDoubleWidth = LongDoubleAlign = 128; LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble; @@ -1712,7 +1711,6 @@ class NVPTXTargetInfo : public TargetInf public: NVPTXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : TargetInfo(Triple) { -BigEndian = false; TLSSupported = false; LongWidth = LongAlign = 64; AddrSpaceMap = &NVPTXAddrSpaceMap; @@ -2663,7 +2661,6 @@ class X86TargetInfo : public TargetInfo public: X86TargetInfo(const llvm::Triple &Triple, const TargetOptions &) : TargetInfo(Triple) { -BigEndian = false; LongDoubleFormat = &llvm::APFloat::x87DoubleExtended; } unsigned getFloatEvalMethod() const override { @@ -4878,11 +4875,9 @@ class ARMTargetInfo : public TargetInfo } public: - ARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts, -bool IsBigEndian) + ARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : TargetInfo(Triple), FPMath(FP_Default), IsAAPCS(true), LDREX(0), HW_FP(0) { -BigEndian = IsBigEndian; switch (getTriple().getOS()) { case llvm::Triple::NetBSD: @@ -5522,7 +5517,7 @@ const Builtin::Info ARMTargetInfo::Built class ARMleTargetInfo : public ARMTargetInfo { public: ARMleTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) - : ARMTargetInfo(Triple, Opts, /*BigEndian=*/false) {} + : ARMTargetInfo(Triple, Opts) {} void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override { Builder.defineMacro("__ARMEL__"); @@ -5533,7 +5528,7 @@ public: class ARMbeTargetInfo : public ARMTargetInfo { public: ARMbeTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) - : ARMTargetInfo(Triple, Opts, /*BigEndian=*/true) {} + : ARMTargetInfo(Triple, Opts) {} void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override { Builder.defineMacro("__ARMEB__"); @@ -6044,7 +6039,6 @@ class AArch64leTargetInfo : public AArch public: AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : AArch64TargetInfo(Triple, Opts) { -BigEndian = false; }
Re: [PATCH] D23953: OpenCL: Defining __ENDIAN_LITTLE__ and fix target endianness
arsenm closed this revision. arsenm added a comment. r280787 https://reviews.llvm.org/D23953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23284: Add -fdiagnostics-show-hotness
rsmith added inline comments. Comment at: lib/Frontend/CompilerInvocation.cpp:844 @@ +843,3 @@ + Args.hasFlag(options::OPT_fdiagnostics_show_hotness, + options::OPT_fno_diagnostics_show_hotness, + /*default*/ false); You should just use hasArg here, there is no -fno-diagnostics-show-hotness flag for -cc1. https://reviews.llvm.org/D23284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r280575 - Add plumbing for new attribute type "Microsoft".
Hi Nico, One of our thumb bots [1] is having issues building lately and it looks like it might be related to one of the commits in this series. Could you please have a look? Thanks, Diana [1] http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/15286/steps/build%20stage%201/logs/stdio On 3 September 2016 at 05:55, Nico Weber via cfe-commits wrote: > Author: nico > Date: Fri Sep 2 21:55:10 2016 > New Revision: 280575 > > URL: http://llvm.org/viewvc/llvm-project?rev=280575&view=rev > Log: > Add plumbing for new attribute type "Microsoft". > > This is for attributes in []-delimited lists preceding a class, like e.g. > `[uuid("...")] class Foo {};` Not used by anything yet, so no behavior > change. > Part of https://reviews.llvm.org/D23895 > > Modified: > cfe/trunk/include/clang/Basic/Attributes.h > cfe/trunk/include/clang/Sema/AttributeList.h > cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp > > Modified: cfe/trunk/include/clang/Basic/Attributes.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attributes.h?rev=280575&r1=280574&r2=280575&view=diff > == > --- cfe/trunk/include/clang/Basic/Attributes.h (original) > +++ cfe/trunk/include/clang/Basic/Attributes.h Fri Sep 2 21:55:10 2016 > @@ -22,6 +22,8 @@ enum class AttrSyntax { >GNU, >/// Is the identifier known as a __declspec-style attribute? >Declspec, > + /// Is the identifier known as a [] Microsoft-style attribute? > + Microsoft, >// Is the identifier known as a C++-style attribute? >CXX, >// Is the identifier known as a pragma attribute? > > Modified: cfe/trunk/include/clang/Sema/AttributeList.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=280575&r1=280574&r2=280575&view=diff > == > --- cfe/trunk/include/clang/Sema/AttributeList.h (original) > +++ cfe/trunk/include/clang/Sema/AttributeList.h Fri Sep 2 21:55:10 2016 > @@ -101,12 +101,14 @@ public: > AS_CXX11, > /// __declspec(...) > AS_Declspec, > +/// [uuid("...")] class Foo > +AS_Microsoft, > /// __ptr16, alignas(...), etc. > AS_Keyword, > /// Context-sensitive version of a keyword attribute. > AS_ContextSensitiveKeyword, > /// #pragma ... > -AS_Pragma > +AS_Pragma, >}; > > private: > @@ -369,6 +371,7 @@ public: >} > >bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; } > + bool isMicrosoftAttribute() const { return SyntaxUsed == AS_Microsoft; } >bool isCXX11Attribute() const { > return SyntaxUsed == AS_CXX11 || isAlignasAttribute(); >} > > Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=280575&r1=280574&r2=280575&view=diff > == > --- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original) > +++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Fri Sep 2 21:55:10 2016 > @@ -1312,6 +1312,9 @@ writePrettyPrintFunction(Record &R, > } else if (Variety == "Declspec") { >Prefix = " __declspec("; >Suffix = ")"; > +} else if (Variety == "Microsoft") { > + Prefix = "["; > + Suffix = "]"; > } else if (Variety == "Keyword") { >Prefix = " "; >Suffix = ""; > @@ -2295,7 +2298,7 @@ void EmitClangAttrHasAttrImpl(RecordKeep >// Separate all of the attributes out into four group: generic, C++11, GNU, >// and declspecs. Then generate a big switch statement for each of them. >std::vector Attrs = Records.getAllDerivedDefinitions("Attr"); > - std::vector Declspec, GNU, Pragma; > + std::vector Declspec, Microsoft, GNU, Pragma; >std::map> CXX; > >// Walk over the list of all attributes, and split them out based on the > @@ -2308,6 +2311,8 @@ void EmitClangAttrHasAttrImpl(RecordKeep > GNU.push_back(R); >else if (Variety == "Declspec") > Declspec.push_back(R); > + else if (Variety == "Microsoft") > +Microsoft.push_back(R); >else if (Variety == "CXX11") > CXX[SI.nameSpace()].push_back(R); >else if (Variety == "Pragma") > @@ -2323,6 +2328,9 @@ void EmitClangAttrHasAttrImpl(RecordKeep >OS << "case AttrSyntax::Declspec:\n"; >OS << " return llvm::StringSwitch(Name)\n"; >GenerateHasAttrSpellingStringSwitch(Declspec, OS, "Declspec"); > + OS << "case AttrSyntax::Microsoft:\n"; > + OS << " return llvm::StringSwitch(Name)\n"; > + GenerateHasAttrSpellingStringSwitch(Microsoft, OS, "Microsoft"); >OS << "case AttrSyntax::Pragma:\n"; >OS << " return llvm::StringSwitch(Name)\n"; >GenerateHasAttrSpellingStringSwitch(Pragma, OS, "Pragma"); > @@ -2361,8 +2369,9 @@ void EmitClangAttrSpellingListIndex(Reco >
Re: [PATCH] D21279: Fix some issues in clang-format's AlignConsecutive modes
bmharper added a comment. PING! My previous commit hopefully addressed the issue with the sprawl of IndentLevel + ScopeLevel https://reviews.llvm.org/D21279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24192: [clang-refactor] introducing clang-refactor
curdeius added a subscriber: curdeius. curdeius added a comment. For the moment, just a few nitty-gritty comments inline. What I miss here is (as already pointed by someone) an example on how to write a new module, register it etc. Comment at: clang-refactor/driver/Driver.cpp:41 @@ +40,3 @@ +Command = argv[1]; +std::string Invocation = std::string(argv[0]) + " " + argv[1]; +argv[1] = Invocation.c_str(); Simpler: ``` std::string Invocation = argv[0] + (" " + Command); ``` Comment at: clang-refactor/driver/ModuleManager.cpp:22-24 @@ +21,5 @@ +int ModuleManager::Dispatch(StringRef Command, int argc, const char **argv) { + if (CommandToModuleID.find(Command) != CommandToModuleID.end()) { +return RegisteredModules[CommandToModuleID[Command]]->run(argc, argv); + } + return 1; Using `find` and then `operator[]` makes the search twice. IMO, it would be better to avoid that by: ``` auto it = CommandToModuleID.find(Command); if (it != CommandToModuleID.end()) { return RegisteredModules[*it]->run(argc, argv); } ``` Comment at: clang-refactor/driver/ModuleManager.h:13-19 @@ +12,9 @@ + +#include "llvm/ADT/StringRef.h" + +#include +#include +#include + +#include "core/RefactoringModule.h" + clang-format includes (and make it a single block)? Comment at: clang-refactor/driver/ModuleManager.h:21 @@ +20,3 @@ + +using namespace llvm; + `using namespace` in header?! Comment at: clang-refactor/modules/core/RefactoringModule.h:36 @@ +35,3 @@ + // + // 1. Extract infromation needed for the refactoring upon tool invocation. + // s/infromation/information Comment at: clang-refactor/modules/core/RefactoringModule.h:56 @@ +55,3 @@ + // 2. Check whether renaming will introduce any name conflicts. If it won't + // find each occurance of the symbol in translation unit using USR and store + // replacements. s/occurance/occurrence Comment at: clang-refactor/modules/core/RefactoringModule.h:72 @@ +71,3 @@ + // code will no longer compile. If it won't find function calls, add needed + // temprorary variables and replace the call with function body. + // s/temprorary/temporary Comment at: clang-refactor/modules/core/RefactoringModule.h:112 @@ +111,3 @@ + + // Routine for regiestering common modules options. + void registerCommonOptions(llvm::cl::OptionCategory &Category) { s/regiestering/registering https://reviews.llvm.org/D24192 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r280575 - Add plumbing for new attribute type "Microsoft".
Scratch that, apparently it fixed itself after I removed the build directory and restarted the bot. Sorry about the noise. Diana On 7 September 2016 at 11:10, Diana Picus wrote: > Hi Nico, > > One of our thumb bots [1] is having issues building lately and it > looks like it might be related to one of the commits in this series. > Could you please have a look? > > Thanks, > Diana > > [1] > http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/15286/steps/build%20stage%201/logs/stdio > > On 3 September 2016 at 05:55, Nico Weber via cfe-commits > wrote: >> Author: nico >> Date: Fri Sep 2 21:55:10 2016 >> New Revision: 280575 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=280575&view=rev >> Log: >> Add plumbing for new attribute type "Microsoft". >> >> This is for attributes in []-delimited lists preceding a class, like e.g. >> `[uuid("...")] class Foo {};` Not used by anything yet, so no behavior >> change. >> Part of https://reviews.llvm.org/D23895 >> >> Modified: >> cfe/trunk/include/clang/Basic/Attributes.h >> cfe/trunk/include/clang/Sema/AttributeList.h >> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp >> >> Modified: cfe/trunk/include/clang/Basic/Attributes.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attributes.h?rev=280575&r1=280574&r2=280575&view=diff >> == >> --- cfe/trunk/include/clang/Basic/Attributes.h (original) >> +++ cfe/trunk/include/clang/Basic/Attributes.h Fri Sep 2 21:55:10 2016 >> @@ -22,6 +22,8 @@ enum class AttrSyntax { >>GNU, >>/// Is the identifier known as a __declspec-style attribute? >>Declspec, >> + /// Is the identifier known as a [] Microsoft-style attribute? >> + Microsoft, >>// Is the identifier known as a C++-style attribute? >>CXX, >>// Is the identifier known as a pragma attribute? >> >> Modified: cfe/trunk/include/clang/Sema/AttributeList.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=280575&r1=280574&r2=280575&view=diff >> == >> --- cfe/trunk/include/clang/Sema/AttributeList.h (original) >> +++ cfe/trunk/include/clang/Sema/AttributeList.h Fri Sep 2 21:55:10 2016 >> @@ -101,12 +101,14 @@ public: >> AS_CXX11, >> /// __declspec(...) >> AS_Declspec, >> +/// [uuid("...")] class Foo >> +AS_Microsoft, >> /// __ptr16, alignas(...), etc. >> AS_Keyword, >> /// Context-sensitive version of a keyword attribute. >> AS_ContextSensitiveKeyword, >> /// #pragma ... >> -AS_Pragma >> +AS_Pragma, >>}; >> >> private: >> @@ -369,6 +371,7 @@ public: >>} >> >>bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; } >> + bool isMicrosoftAttribute() const { return SyntaxUsed == AS_Microsoft; } >>bool isCXX11Attribute() const { >> return SyntaxUsed == AS_CXX11 || isAlignasAttribute(); >>} >> >> Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=280575&r1=280574&r2=280575&view=diff >> == >> --- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original) >> +++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Fri Sep 2 21:55:10 2016 >> @@ -1312,6 +1312,9 @@ writePrettyPrintFunction(Record &R, >> } else if (Variety == "Declspec") { >>Prefix = " __declspec("; >>Suffix = ")"; >> +} else if (Variety == "Microsoft") { >> + Prefix = "["; >> + Suffix = "]"; >> } else if (Variety == "Keyword") { >>Prefix = " "; >>Suffix = ""; >> @@ -2295,7 +2298,7 @@ void EmitClangAttrHasAttrImpl(RecordKeep >>// Separate all of the attributes out into four group: generic, C++11, >> GNU, >>// and declspecs. Then generate a big switch statement for each of them. >>std::vector Attrs = Records.getAllDerivedDefinitions("Attr"); >> - std::vector Declspec, GNU, Pragma; >> + std::vector Declspec, Microsoft, GNU, Pragma; >>std::map> CXX; >> >>// Walk over the list of all attributes, and split them out based on the >> @@ -2308,6 +2311,8 @@ void EmitClangAttrHasAttrImpl(RecordKeep >> GNU.push_back(R); >>else if (Variety == "Declspec") >> Declspec.push_back(R); >> + else if (Variety == "Microsoft") >> +Microsoft.push_back(R); >>else if (Variety == "CXX11") >> CXX[SI.nameSpace()].push_back(R); >>else if (Variety == "Pragma") >> @@ -2323,6 +2328,9 @@ void EmitClangAttrHasAttrImpl(RecordKeep >>OS << "case AttrSyntax::Declspec:\n"; >>OS << " return llvm::StringSwitch(Name)\n"; >>GenerateHasAttrSpellingStringSwitch(Declspec, OS, "Declspec"); >> + OS << "case AttrSyntax::Microsoft:\n"; >> + OS << " return llvm::StringSwitch(Na
r280800 - [OpenCL] Fix pipe built-in functions return type.
Author: bader Date: Wed Sep 7 05:32:03 2016 New Revision: 280800 URL: http://llvm.org/viewvc/llvm-project?rev=280800&view=rev Log: [OpenCL] Fix pipe built-in functions return type. By default return type of call expressions calling built-in functions is set to bool. Fixes https://llvm.org/bugs/show_bug.cgi?id=30219. Reviewers: Anastasia Subscribers: dmitry, cfe-commits, yaxunl Differential Revision: https://reviews.llvm.org/D24136 Modified: cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl Modified: cfe/trunk/lib/Sema/SemaChecking.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=280800&r1=280799&r2=280800&view=diff == --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) +++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Sep 7 05:32:03 2016 @@ -1020,6 +1020,7 @@ Sema::CheckBuiltinFunctionCall(FunctionD // check for the argument. if (SemaBuiltinRWPipe(*this, TheCall)) return ExprError(); +TheCall->setType(Context.IntTy); break; case Builtin::BIreserve_read_pipe: case Builtin::BIreserve_write_pipe: @@ -1047,6 +1048,7 @@ Sema::CheckBuiltinFunctionCall(FunctionD case Builtin::BIget_pipe_max_packets: if (SemaBuiltinPipePackets(*this, TheCall)) return ExprError(); +TheCall->setType(Context.UnsignedIntTy); break; case Builtin::BIto_global: case Builtin::BIto_local: Modified: cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl?rev=280800&r1=280799&r2=280800&view=diff == --- cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl Wed Sep 7 05:32:03 2016 @@ -59,3 +59,19 @@ void test7(write_only pipe int p, global // CHECK: call i32 @__get_pipe_max_packets(%opencl.pipe_t* %{{.*}}) *ptr = get_pipe_max_packets(p); } + +void test8(read_only pipe int r, write_only pipe int w, global int *ptr) { + // verify that return type is correctly casted to i1 value + // CHECK: %[[R:[0-9]+]] = call i32 @__read_pipe_2 + // CHECK: icmp ne i32 %[[R]], 0 + if (read_pipe(r, ptr)) *ptr = -1; + // CHECK: %[[W:[0-9]+]] = call i32 @__write_pipe_2 + // CHECK: icmp ne i32 %[[W]], 0 + if (write_pipe(w, ptr)) *ptr = -1; + // CHECK: %[[N:[0-9]+]] = call i32 @__get_pipe_num_packets + // CHECK: icmp ne i32 %[[N]], 0 + if (get_pipe_num_packets(r)) *ptr = -1; + // CHECK: %[[M:[0-9]+]] = call i32 @__get_pipe_max_packets + // CHECK: icmp ne i32 %[[M]], 0 + if (get_pipe_max_packets(w)) *ptr = -1; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24136: [OpenCL] Fix pipe built-in functions return type.
This revision was automatically updated to reflect the committed changes. Closed by commit rL280800: [OpenCL] Fix pipe built-in functions return type. (authored by bader). Changed prior to commit: https://reviews.llvm.org/D24136?vs=70368&id=70516#toc Repository: rL LLVM https://reviews.llvm.org/D24136 Files: cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl Index: cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl === --- cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl +++ cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl @@ -59,3 +59,19 @@ // CHECK: call i32 @__get_pipe_max_packets(%opencl.pipe_t* %{{.*}}) *ptr = get_pipe_max_packets(p); } + +void test8(read_only pipe int r, write_only pipe int w, global int *ptr) { + // verify that return type is correctly casted to i1 value + // CHECK: %[[R:[0-9]+]] = call i32 @__read_pipe_2 + // CHECK: icmp ne i32 %[[R]], 0 + if (read_pipe(r, ptr)) *ptr = -1; + // CHECK: %[[W:[0-9]+]] = call i32 @__write_pipe_2 + // CHECK: icmp ne i32 %[[W]], 0 + if (write_pipe(w, ptr)) *ptr = -1; + // CHECK: %[[N:[0-9]+]] = call i32 @__get_pipe_num_packets + // CHECK: icmp ne i32 %[[N]], 0 + if (get_pipe_num_packets(r)) *ptr = -1; + // CHECK: %[[M:[0-9]+]] = call i32 @__get_pipe_max_packets + // CHECK: icmp ne i32 %[[M]], 0 + if (get_pipe_max_packets(w)) *ptr = -1; +} Index: cfe/trunk/lib/Sema/SemaChecking.cpp === --- cfe/trunk/lib/Sema/SemaChecking.cpp +++ cfe/trunk/lib/Sema/SemaChecking.cpp @@ -1020,6 +1020,7 @@ // check for the argument. if (SemaBuiltinRWPipe(*this, TheCall)) return ExprError(); +TheCall->setType(Context.IntTy); break; case Builtin::BIreserve_read_pipe: case Builtin::BIreserve_write_pipe: @@ -1047,6 +1048,7 @@ case Builtin::BIget_pipe_max_packets: if (SemaBuiltinPipePackets(*this, TheCall)) return ExprError(); +TheCall->setType(Context.UnsignedIntTy); break; case Builtin::BIto_global: case Builtin::BIto_local: Index: cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl === --- cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl +++ cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl @@ -59,3 +59,19 @@ // CHECK: call i32 @__get_pipe_max_packets(%opencl.pipe_t* %{{.*}}) *ptr = get_pipe_max_packets(p); } + +void test8(read_only pipe int r, write_only pipe int w, global int *ptr) { + // verify that return type is correctly casted to i1 value + // CHECK: %[[R:[0-9]+]] = call i32 @__read_pipe_2 + // CHECK: icmp ne i32 %[[R]], 0 + if (read_pipe(r, ptr)) *ptr = -1; + // CHECK: %[[W:[0-9]+]] = call i32 @__write_pipe_2 + // CHECK: icmp ne i32 %[[W]], 0 + if (write_pipe(w, ptr)) *ptr = -1; + // CHECK: %[[N:[0-9]+]] = call i32 @__get_pipe_num_packets + // CHECK: icmp ne i32 %[[N]], 0 + if (get_pipe_num_packets(r)) *ptr = -1; + // CHECK: %[[M:[0-9]+]] = call i32 @__get_pipe_max_packets + // CHECK: icmp ne i32 %[[M]], 0 + if (get_pipe_max_packets(w)) *ptr = -1; +} Index: cfe/trunk/lib/Sema/SemaChecking.cpp === --- cfe/trunk/lib/Sema/SemaChecking.cpp +++ cfe/trunk/lib/Sema/SemaChecking.cpp @@ -1020,6 +1020,7 @@ // check for the argument. if (SemaBuiltinRWPipe(*this, TheCall)) return ExprError(); +TheCall->setType(Context.IntTy); break; case Builtin::BIreserve_read_pipe: case Builtin::BIreserve_write_pipe: @@ -1047,6 +1048,7 @@ case Builtin::BIget_pipe_max_packets: if (SemaBuiltinPipePackets(*this, TheCall)) return ExprError(); +TheCall->setType(Context.UnsignedIntTy); break; case Builtin::BIto_global: case Builtin::BIto_local: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r280597 - [AVX-512] Remove masked integer mullo builtins and replace with native IR.
On 6 September 2016 at 01:21, Nico Weber wrote: > Renato, I remember you saying you worked around the bot problem by making > the build dir a symlink. Maybe stuff gets confused by that setup? Symlink > build dirs tend to cause trouble. Hi Nico, The symlink was from base source to base source, shouldn't make a difference. But now the change was reverted and it's green again. Thanks! --reanto ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24192: [clang-refactor] introducing clang-refactor
alexfh added a comment. Kirill, first, thank you for working on this! As discussed offline, the RefactoringModule interface should explicitly define: - separation of execution stages for each check: 1. preparation or execution planning - should figure out the set of affected translation units and what should be done for each of them 2. processing of affected translation units - ideally, this should be done in parallel, separate process per TU, and the interface should not prevent this 3. application of replacements or error reporting, if stage 2 detected that execution of refactoring is not possible - looks like this is not refactoring-specific and can be done by the clang-refactor framework - state transferred between stages (since they should allow for independent execution, potentially in multiple processes, so data should be in a serializable form) - data and facilities available to each stage (e.g. cross-reference index, AST of a certain translation unit, ability to register PPCallbacks, interface to pass data to the next stage, report results or errors) - basic interfaces for the facilities mentioned above. A failure to define these aspects would complicate introduction of multi-TU support and require significant changes to refactoring tools to follow a stricter interface. https://reviews.llvm.org/D24192 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23992: [OpenCL] Augment pipe built-ins with pipe packet size and alignment.
bader added a comment. Valery, do you have any additional comments/questions regarding this patch? https://reviews.llvm.org/D23992 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24192: [clang-refactor] introducing clang-refactor
alexfh requested changes to this revision. This revision now requires changes to proceed. Comment at: clang-refactor/driver/Driver.cpp:41 @@ +40,3 @@ +Command = argv[1]; +std::string Invocation = std::string(argv[0]) + " " + argv[1]; +argv[1] = Invocation.c_str(); curdeius wrote: > Simpler: > > ``` > std::string Invocation = argv[0] + (" " + Command); > ``` (llvm::Twine(argv[0]) + " " + ...).str() Comment at: clang-refactor/driver/ModuleManager.h:21 @@ +20,3 @@ + +using namespace llvm; + curdeius wrote: > `using namespace` in header?! If you need StringRef, ArrayRef etc. in clang namespace, just include "clang/Basic/LLVM.h". Comment at: clang-refactor/modules/core/RefactoringModule.h:91 @@ +90,3 @@ + // + int run(int argc, const char **argv) { +// Register options. I believe, `run` should be external to the module. Its implementation might be different depending on whether we're just running all stages sequentially or trying to parallelize processing of different translation units. Comment at: clang-refactor/modules/core/RefactoringModule.h:148 @@ +147,3 @@ + // Panic: if there are conflicting replacements. + virtual int applyReplacementsOrOutputDiagnostics() = 0; + This should be possible to implement in a refactoring-independent way in clang-refactor itself. Or do you see any issues with this? https://reviews.llvm.org/D24192 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24224: [clang-rename] Merge rename-{ at | all } and optimise USRFindingAction.
alexfh requested changes to this revision. This revision now requires changes to proceed. Comment at: clang-rename/USRFindingAction.cpp:158 @@ +157,3 @@ + +FoundDecl = QualifiedName.empty() ? getNamedDeclAt(Context, Point) + : getNamedDeclFor(Context, QualifiedName); Merge this to the variable declaration. Comment at: clang-rename/USRFindingAction.cpp:169 @@ -160,2 +168,3 @@ << SymbolOffset << ").\n"; +exit(1); } else { I'd better not use `exit()` in library code and try to find a way to signal the error to the caller (e.g. make the function return a bool so that HandleTranslationUnit doesn't do useless work, and use ASTContext::getDiagnostics() to report errors; or add a separate callback, if this doesn't work for some reason). https://reviews.llvm.org/D24224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23848: Add a clang-tidy Visual Studio extension
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. A few late comments. Looks good overall. Comment at: clang-tidy-vs/ClangTidy/CategoryVerb.cs:52 @@ +51,3 @@ +{ +if (value.GetType() == typeof(CategoryVerb) && destinationType == typeof(string)) +{ Should this be `value is CategoryVerb`? Comment at: clang-tidy-vs/ClangTidy/ClangTidyConfigurationPage.cs:11 @@ +10,3 @@ +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; Is this addressed? Comment at: clang-tidy-vs/ClangTidy/ClangTidyPropertyGrid.cs:176 @@ +175,3 @@ + +private void ClangTidyPropertyGrid_Load(object sender, EventArgs e) +{ I guess, this handler is not needed, since it's empty. Comment at: clang-tidy-vs/ClangTidy/Guids.cs:13 @@ +12,1 @@ +} \ No newline at end of file Could you fix the No newline at end of file? Comment at: clang-tidy-vs/ClangTidy/PkgCmdID.cs:8 @@ +7,1 @@ +} \ No newline at end of file Could you fix the `No newline at end of file`? Comment at: clang-tidy-vs/ClangTidy/Resources/ClangTidyChecks.yaml:1 @@ +1,2 @@ +--- +Checks: Does YAML support comments? If yes, I'd add a not that this file should be updated when new checks are added and a TODO to add a generator from .rst. https://reviews.llvm.org/D23848 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23848: Add a clang-tidy Visual Studio extension
alexfh added inline comments. Comment at: clang-tidy-vs/ClangTidy/ClangTidyPackage.cs:53 @@ +52,3 @@ +private void MenuItemCallback(object sender, EventArgs args) +{ +} Add a FIXME to actually implement this. https://reviews.llvm.org/D23848 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21134: clang-tidy: new check readability-misplaced-array-index
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. Looks good. Please ensure it works reasonably on LLVM code before submitting. Sorry for the delay. Feel free to ping earlier. https://reviews.llvm.org/D21134 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22507: Clang-tidy - Enum misuse check
alexfh requested changes to this revision. alexfh added a comment. This revision now requires changes to proceed. Close, but still a bunch of comments in the docs and a suggestion to fix a class of false positives. Comment at: clang-tidy/misc/EnumMisuseCheck.cpp:210 @@ +209,3 @@ + DiagnosticIDs::Note); +} else if (!LhsConstant->getInitVal().isPowerOf2()) + diag(LhsExpr->getExprLoc(), "left hand side value is not power-of-2 " # llvm/lib/MC/ELFObjectWriter.cpp:903 - the warning looks reasonable. # llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h:66 - the warning looks reasonable (ATTR_max doesn't seem to be useful for the bitmask enum). # llvm/tools/clang/lib/Basic/IdentifierTable.cpp:95 - two issues here: 1. the "possibly contains misspelled number(s) " message could be more useful, if it specified which member corresponds to the possibly misspelled number 2. I suppose, the check considers `KEYALL = (0x1f & ~KEYNOMS18 & ~KEYNOOPENCL)` to be incorrect. I think, it should exclude enum members initialized with a bit arithmetic expressions, since it's rather common to define aliases for a certain combination of flags. # llvm/tools/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp:5083 and friends - the warning looks reasonable, since it's hard to understand the motivation for the `BLOCK_FIELD_IS_OBJECT = 3`. If it's a combination of flags, it should be written as such, and the check should ignore enum members initialized with a bit arithmetic expression. Comment at: docs/clang-tidy/checks/misc-enum-misuse.rst:9 @@ +8,3 @@ +1. When "ADD" or "bitwise OR" is used between two enum which come from different + types and these types value ranges are not disjoint. + Too much indentation here. Comment at: docs/clang-tidy/checks/misc-enum-misuse.rst:38 @@ +37,3 @@ + // Case 1 (strict and weak mode): + Enum {A, B, C}; + Enum {D, E, F = 5}; 1. `Enum` should not start with a capital letter, since it's a keyword. 2. Please indent the code block contents by 2 spaces (currently, it's indented by 1). 3. Please clang-format all code samples. Comment at: docs/clang-tidy/checks/misc-enum-misuse.rst:47 @@ +46,3 @@ + // Case 2 (only in strict mode): + Enum bitmask { A = 0; +B = 1; Commas should be used instead of semicolons. Comment at: docs/clang-tidy/checks/misc-enum-misuse.rst:54 @@ +53,3 @@ +G = 31; // OK, real bitmask. + } + Missing semicolon. In general, please make sure code snippets are valid code. Otherwise, it creates unneeded obstacles in reading the code. https://reviews.llvm.org/D22507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23353: [clang-tidy] Add check 'misc-use-after-move'
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. LG Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:30 @@ +29,3 @@ +/// a `CFGBlock`. +/// +/// While a `CFGBlock` does contain individual `CFGElement`s for some Yep, you're right. I was thinking about .rst, probably. https://reviews.llvm.org/D23353 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r280806 - [EfficiencySanitizer] [MIPS64] Enables esan clang driver options for MIPS64
Author: slthakur Date: Wed Sep 7 07:23:15 2016 New Revision: 280806 URL: http://llvm.org/viewvc/llvm-project?rev=280806&view=rev Log: [EfficiencySanitizer] [MIPS64] Enables esan clang driver options for MIPS64 Reviewed by bruening Differential: D23800 Modified: cfe/trunk/lib/Driver/ToolChains.cpp cfe/trunk/test/Driver/esan.c Modified: cfe/trunk/lib/Driver/ToolChains.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=280806&r1=280805&r2=280806&view=diff == --- cfe/trunk/lib/Driver/ToolChains.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Sep 7 07:23:15 2016 @@ -4736,7 +4736,7 @@ SanitizerMask Linux::getSupportedSanitiz Res |= SanitizerKind::Thread; if (IsX86_64 || IsMIPS64 || IsPowerPC64 || IsAArch64) Res |= SanitizerKind::Memory; - if (IsX86_64) + if (IsX86_64 || IsMIPS64) Res |= SanitizerKind::Efficiency; if (IsX86 || IsX86_64) { Res |= SanitizerKind::Function; Modified: cfe/trunk/test/Driver/esan.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/esan.c?rev=280806&r1=280805&r2=280806&view=diff == --- cfe/trunk/test/Driver/esan.c (original) +++ cfe/trunk/test/Driver/esan.c Wed Sep 7 07:23:15 2016 @@ -6,6 +6,10 @@ // RUN: %clang -O1 -target x86_64-unknown-linux -fsanitize=efficiency-working-set %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -O2 -target x86_64-unknown-linux -fsanitize=efficiency-working-set %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -O3 -target x86_64-unknown-linux -fsanitize=efficiency-working-set %s -S -emit-llvm -o - | FileCheck %s +// RUN: %clang -target mips64-unknown-linux -fsanitize=efficiency-cache-frag %s -S -emit-llvm -o - | FileCheck %s +// RUN: %clang -target mips64-unknown-linux -fsanitize=efficiency-working-set %s -S -emit-llvm -o - | FileCheck %s +// RUN: %clang -target mips64el-unknown-linux -fsanitize=efficiency-cache-frag %s -S -emit-llvm -o - | FileCheck %s +// RUN: %clang -target mips64el-unknown-linux -fsanitize=efficiency-working-set %s -S -emit-llvm -o - | FileCheck %s // Verify that -fsanitize=efficiency-* invokes esan instrumentation. int foo(int *a) { return *a; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23657: Remove some false positives when taking the address of packed members
rogfer01 added a comment. Ping? :) Thank you very much. https://reviews.llvm.org/D23657 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24235: [OpenCL] Improve double literal handling
neil.hickey updated this revision to Diff 70527. neil.hickey added a comment. Added a CodeGen test as well as fixed an issue with vararg type promotion https://reviews.llvm.org/D24235 Files: lib/Sema/SemaExpr.cpp lib/Sema/SemaType.cpp test/CodeGenOpenCL/fpmath.cl test/SemaOpenCL/extensions.cl Index: test/SemaOpenCL/extensions.cl === --- test/SemaOpenCL/extensions.cl +++ test/SemaOpenCL/extensions.cl @@ -1,13 +1,16 @@ // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1 +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2 -DFP64 // Test with a target not supporting fp64. // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 +#if __OPENCL_C_VERSION__ < 120 void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}} double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}} (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}} } +#endif #pragma OPENCL EXTENSION cl_khr_fp64 : enable #ifdef NOFP64 @@ -21,16 +24,22 @@ #endif (void) 1.0; +#ifdef FP64 +// expected-no-diagnostics +#endif + #ifdef NOFP64 -// expected-warning@-2{{double precision constant requires cl_khr_fp64, casting to single precision}} +// expected-warning@-6{{double precision constant requires cl_khr_fp64, casting to single precision}} #endif } #pragma OPENCL EXTENSION cl_khr_fp64 : disable #ifdef NOFP64 // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}} #endif +#if __OPENCL_C_VERSION__ < 120 void f3(void) { double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}} } +#endif Index: test/CodeGenOpenCL/fpmath.cl === --- test/CodeGenOpenCL/fpmath.cl +++ test/CodeGenOpenCL/fpmath.cl @@ -1,5 +1,6 @@ // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck --check-prefix=CHECK --check-prefix=NODIVOPT %s // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -cl-fp32-correctly-rounded-divide-sqrt | FileCheck --check-prefix=CHECK --check-prefix=DIVOPT %s +// RUN: %clang_cc1 %s -emit-llvm -o - -DNOFP64 -cl-std=CL1.1 -triple r600-unknown-unknown -target-cpu r600 -pedantic | FileCheck --check-prefix=CHECK-DBL %s typedef __attribute__(( ext_vector_type(4) )) float float4; @@ -21,14 +22,22 @@ return a / b; } -#pragma OPENCL EXTENSION cl_khr_fp64 : enable +void printf(constant char* fmt, ...); + +void testdbllit(long *val) { + // CHECK-DBL: float 2.00e+01 + printf("%f", 20.0); +} +#ifndef NOFP64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable double dpscalardiv(double a, double b) { // CHECK: @dpscalardiv // CHECK: #[[ATTR]] // CHECK-NOT: !fpmath return a / b; } +#endif // CHECK: attributes #[[ATTR]] = { // NODIVOPT: "correctly-rounded-divide-sqrt-fp-math"="false" Index: lib/Sema/SemaType.cpp === --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -1413,7 +1413,8 @@ Result = Context.DoubleTy; if (S.getLangOpts().OpenCL && -!((S.getLangOpts().OpenCLVersion >= 120) || +!((S.getLangOpts().OpenCLVersion >= 120 + && S.Context.getTargetInfo().getSupportedOpenCLOpts().cl_khr_fp64) || S.getOpenCLOptions().cl_khr_fp64)) { S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension) << Result << "cl_khr_fp64"; Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -829,7 +829,20 @@ const BuiltinType *BTy = Ty->getAs(); if (BTy && (BTy->getKind() == BuiltinType::Half || BTy->getKind() == BuiltinType::Float)) -E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get(); + { +if (getLangOpts().OpenCL && +!((getLangOpts().OpenCLVersion >= 120 && + Context.getTargetInfo() + .getSupportedOpenCLOpts() + .cl_khr_fp64) || + getOpenCLOptions().cl_khr_fp64)) { +E = ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast).get(); +} +else +{ + E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get(); +} + } // C++ performs lvalue-to-rvalue conversion as a default argument // promotion, even on class types, but note: @@ -3406,8 +3419,14 @@ if (getLangOpts().SinglePrecisionConstants) { Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get(); } else if (getLangOpts().OpenCL && - !((getLangOpts().OpenCLVersion >= 120) || + !((getLangOpts().OpenCLVersion >=
Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation
tavianator added inline comments. Comment at: src/cxa_thread_atexit.cpp:70 @@ +69,3 @@ +while (auto head = dtors) { + dtors = head->next; + head->dtor(head->obj); EricWF wrote: > There is a bug here. If `head->next == nullptr` and if > `head->dtor(head->obj))` creates a TL variable in the destructor then that > destructor will not be invoked. > > Here's an updated test case which catches the bug: > https://gist.github.com/EricWF/3bb50d4f28b91aa28d2adefea0e94a0e I can't reproduce that failure here, your exact test case passes (even with `#undef HAVE___CXA_THREAD_ATEXIT_IMPL` and the weak symbol test commented out). Tracing the implementation logic, it seems correct. If `head->next == nullptr` then this line does `dtors = nullptr`. Then if `head->dtor(head->obj)` registers a new `thread_local`, `__cxa_thread_atexit()` does `head = malloc(...); ... dtors = head;`. Then the next iteration of the loop `while (auto head = dtors) {` picks up that new node. Have I missed something? https://reviews.llvm.org/D21803 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24113: Allow implicit conversions between incompatible pointer types in overload resolution in C.
yaxunl added a subscriber: yaxunl. yaxunl added a comment. This seems to cause regression for the following test: __kernel void test_atomic_fn(volatile __global uint *destMemory, __global uint *oldValues) { int tid = get_global_id(0); oldValues[tid] = atom_add( &destMemory[0], tid + 3 ); atom_add( &destMemory[0], tid + 3 ); atom_add( &destMemory[0], tid + 3 ); atom_add( &destMemory[0], tid + 3 ); } /tmp/AMD_17652_49/t_17652_51.cl:6:19: error: call to 'atom_add' is ambiguous oldValues[tid] = atom_add( &destMemory[0], tid + 3 ); ^~~~ /srv/opencl_rocm/drivers/opencl/library/amdgcn/headers/build/lnx64a/B_dbg/:14336:12: note: candidate function int __ovld atom_add(volatile __global int *p, int val); ^ /srv/opencl_rocm/drivers/opencl/library/amdgcn/headers/build/lnx64a/B_dbg/:14337:21: note: candidate function unsigned int __ovld atom_add(volatile __global unsigned int *p, unsigned int val); ^ /srv/opencl_rocm/drivers/opencl/library/amdgcn/headers/build/lnx64a/B_dbg/:14345:13: note: candidate function long __ovld atom_add(volatile __global long *p, long val); ^ /srv/opencl_rocm/drivers/opencl/library/amdgcn/headers/build/lnx64a/B_dbg/:14346:22: note: candidate function unsigned long __ovld atom_add(volatile __global unsigned long *p, unsigned long val); ^ /srv/opencl_rocm/drivers/opencl/library/amdgcn/headers/build/lnx64a/B_dbg/:14347:13: note: candidate function long __ovld atom_add(volatile __local long *p, long val); ^ /srv/opencl_rocm/drivers/opencl/library/amdgcn/headers/build/lnx64a/B_dbg/:14348:22: note: candidate function unsigned long __ovld atom_add(volatile __local unsigned long *p, unsigned long val); ^ /tmp/AMD_17652_49/t_17652_51.cl:7:2: error: call to 'atom_add' is ambiguous atom_add( &destMemory[0], tid + 3 ); ^~~~ Is this intended? Thanks. Repository: rL LLVM https://reviews.llvm.org/D24113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24075: [include-fixer] Support finding headers for the symbol under cursor.
bkramer accepted this revision. bkramer added a comment. This revision is now accepted and ready to land. I can't really comment on the emacs integration with my limited knowledge of elisp. The rest looks good to me. https://reviews.llvm.org/D24075 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24075: [include-fixer] Support finding headers for the symbol under cursor.
hokein added a comment. + Jens for reviewing emacs integration part. https://reviews.llvm.org/D24075 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24286: Add MS __nop intrinsic to intrin.h
thakis accepted this revision. thakis added a comment. This revision is now accepted and ready to land. Looks great, thanks! https://reviews.llvm.org/D24286 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r280815 - [MS] Fix 'this' type when calling virtual methods with inalloca
Author: rnk Date: Wed Sep 7 10:15:51 2016 New Revision: 280815 URL: http://llvm.org/viewvc/llvm-project?rev=280815&view=rev Log: [MS] Fix 'this' type when calling virtual methods with inalloca If the virtual method comes from a secondary vtable, then the type of the 'this' parameter should be i8*, and not a pointer to the complete class. In the MS ABI, the 'this' parameter on entry points to the vptr containing the virtual method that was called, so we use i8* instead of the normal type. We had a mismatch where the CGFunctionInfo of the call didn't match the CGFunctionInfo of the declaration, and this resulted in some assertions, but now both sides agree the type of 'this' is i8*. Fixes one issue raised in PR30293 Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=280815&r1=280814&r2=280815&view=diff == --- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Wed Sep 7 10:15:51 2016 @@ -33,6 +33,7 @@ commonEmitCXXMemberOrOperatorCall(CodeGe isa(CE)); assert(MD->isInstance() && "Trying to emit a member or operator call expr on a static method!"); + ASTContext &C = CGF.getContext(); // C++11 [class.mfct.non-static]p2: // If a non-static member function of a class X is called for an object that @@ -40,13 +41,16 @@ commonEmitCXXMemberOrOperatorCall(CodeGe SourceLocation CallLoc; if (CE) CallLoc = CE->getExprLoc(); - CGF.EmitTypeCheck( - isa(MD) ? CodeGenFunction::TCK_ConstructorCall - : CodeGenFunction::TCK_MemberCall, - CallLoc, This, CGF.getContext().getRecordType(MD->getParent())); + CGF.EmitTypeCheck(isa(MD) +? CodeGenFunction::TCK_ConstructorCall +: CodeGenFunction::TCK_MemberCall, +CallLoc, This, C.getRecordType(MD->getParent())); // Push the this ptr. - Args.add(RValue::get(This), MD->getThisType(CGF.getContext())); + const CXXRecordDecl *RD = + CGF.CGM.getCXXABI().getThisArgumentTypeForMethod(MD); + Args.add(RValue::get(This), + RD ? C.getPointerType(C.getTypeDeclType(RD)) : C.VoidPtrTy); // If there is an implicit parameter (e.g. VTT), emit it. if (ImplicitParam) { Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp?rev=280815&r1=280814&r2=280815&view=diff == --- cfe/trunk/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp (original) +++ cfe/trunk/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp Wed Sep 7 10:15:51 2016 @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-linux | FileCheck -check-prefix LINUX %s -// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fno-rtti | FileCheck -check-prefix WIN32 %s -// RUN: %clang_cc1 -emit-llvm %s -o - -triple=thumb-pc-win32 -mconstructor-aliases -fno-rtti | FileCheck -check-prefix WOA %s -// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-win32 -mconstructor-aliases -fno-rtti | FileCheck -check-prefix WIN64 %s +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=i386-pc-linux | FileCheck -check-prefix LINUX %s +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fno-rtti | FileCheck -check-prefix WIN32 %s +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=thumb-pc-win32 -mconstructor-aliases -fno-rtti | FileCheck -check-prefix WOA %s +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-pc-win32 -mconstructor-aliases -fno-rtti | FileCheck -check-prefix WIN64 %s struct Empty {}; @@ -401,3 +401,30 @@ void fn2(FnPtr1 a, SmallWithDtor b) { fn // WIN32: %[[addr:[^ ]*]] = bitcast {}** %[[gep2]] to void [[dst_ty]]* // WIN32: store void [[dst_ty]] %[[a2]], void [[dst_ty]]* %[[addr]], align 4 // WIN32: call void @"\01?fn1@@YAXP6AXUForwardDeclare1@@@ZUSmallWithDtor@@@Z"([[argmem_ty]]* inalloca %[[argmem]]) + +namespace pr30293 { +// Virtual methods living in a secondary vtable take i8* as their 'this' +// parameter because the 'this' parameter on entry points to the secondary +// vptr. We used to have a bug where we didn't apply this rule consistently, +// and it would cause assertion failures when used with inalloca. +struct A { + virtual void f(); +}; +struct B { + virtual void __cdecl h(SmallWithDtor); +}; +struct C final : A, B { + void g(); + void __cdecl h(SmallWithDtor); + void f(); +}; +void C::g() { return h(SmallWithDtor()); } + +// WIN32-LABEL: define x86_thiscallcc void @"\01?g@C@pr30293@@QAEXXZ"(%"struct.pr30293::C"* %this) +// WI
Re: [PATCH] D24243: [clang-move] A prototype tool for moving class definition to new file.
hokein added inline comments. Comment at: clang-move/ClangMove.cpp:38 @@ +37,3 @@ + const clang::Module * /*Imported*/) override { +if (const auto *FileEntry = SM.getFileEntryForID(SM.getFileID(HashLoc))) { + if (IsAngled) { ioeric wrote: > Might want to comment on how #include "old_header" is handled here? Currently the old_header is also copied to new file. Comment at: clang-move/ClangMove.cpp:103 @@ +102,3 @@ + const clang::SourceManager *SM) { + // Gets the ending ";". + auto EndLoc = clang::Lexer::getLocForEndOfToken(D->getLocEnd(), 0, *SM, ioeric wrote: > Consider the code below to also include trailing comment. > clang::SourceLocation after_semi = clang::Lexer::findLocationAfterToken( > D->getLocEnd, clang::tok::semi, *SM, > result.Context->getLangOpts(), > /*SkipTrailingWhitespaceAndNewLine=*/true); > But this code could not handle cases where the declaration definition has no semi at the end, such as "void f() {}" Comment at: clang-move/ClangMove.cpp:125 @@ +124,3 @@ + + // Add moved class definition and its related declarations. All declarations + // in same namespace are grouped together. ioeric wrote: > If two declarations in the same namespace are not consecutive in the vector > (i.e. there is a decl in a different ns between them), will they be put into > two canonical namespace blocks? Yes, only declarations which are consecutive in the vector and in the same namespace are put in one namespace block. Comment at: clang-move/ClangMove.cpp:129 @@ +128,3 @@ + for (const auto &MovedDecl : Decls) { +std::vector DeclNamespaces = GetNamespaces(MovedDecl.Decl); +auto CurrentIt = CurrentNamespaces.begin(); ioeric wrote: > Is it possible to restrict all `MovedDecl.Decl` to NamedDecl so that we can > use `getQualifiedNameAsString` instead of having a second implementation of > retrieving namespaces. > > Also how is anonymous namespace handled here? > > Yeah, `getQualifiedNameAsString` looks like a simpler way, but it doesn't suitable for our usage here. The `getQualifiedNameAsString` includes the name of the class. For instance, a class method decl like `void A::f() {}` defined in global namespace, it retruns `A::f` which is not intended. It handles anonymous namespace by wrapping like `namespace { ... } // namespace`, see the test. Comment at: clang-move/ClangMove.cpp:199 @@ +198,3 @@ + + // Match functions defined in anonymous namespace. + Finder->addMatcher( ioeric wrote: > What about static functions? Good catch, I missed it. Added. Comment at: clang-move/ClangMove.cpp:210 @@ +209,3 @@ + this); +} + ioeric wrote: > FIXME: support out-of-line member variable initializations etc? Or is it > already covered? Add support now. Comment at: clang-move/ClangMove.cpp:240 @@ +239,3 @@ +llvm::StringRef FileName) { + if (!Spec.OldHeader.empty() && FileName.endswith(Spec.OldHeader)) { +HeaderIncludes.push_back(IncludeLine.str()); ioeric wrote: > No braces. > > Also, I am worrying if `endswith` is a safe way to compare files. For > example, what if `FileName` is relative path? The `FileName` is from the `PPCallbacks::InclusionDirective` APIs. From my experience, it seems always to be an absolute file path either I pass a relative file path or a absolute path to clang-move, but this is no guarantee in the document. Using `endswith` is the most reliable way so far. Comment at: clang-move/ClangMove.h:39 @@ +38,3 @@ + struct MoveDefinitionSpec { +std::string Name; +std::string OldHeader; ioeric wrote: > Should the `Name` be fully qualified? It's not required. The name can be fully/partially qualified, e.g., `::a::b::X`, `a::b::X`, `b::X`, `X`, which has the same behavior with `hasName` ast matcher. It the given name is partially qualified, it will match all the class whose name ends with the given name. Comment at: clang-move/ClangMove.h:65 @@ +64,3 @@ + + const MoveDefinitionSpec &Spec; + // The Key is file path, value is the replacements being applied to the file. ioeric wrote: > Is there any reason why you made this a reference? To avoid the cost of making a copy of the structure. Comment at: clang-move/ClangMove.h:83 @@ +82,3 @@ +public: + explicit ClangMoveAction( + const ClangMoveTool::MoveDefinitionSpec &spec, Eugene.Zelenko wrote: > Is explicit necessary? The `explicit` keyword can prevent the copy-list-initialization like `ClangMoveAction a = {spec, file_to_replacement}`. I'm fine to remove it since it is trival. Comment at: clang-move/tool/Cl
Re: [PATCH] D21678: Fix For pr28288 - Error message in shift of vector values
Thanks, I’ll take a look at your patch today. vec1.patch Description: Binary data > On Sep 7, 2016, at 12:53 AM, Vladimir Yakovlev wrote: > > I did another fix (attached). It fixes the error and chang-check has not any > new errors. Please take a look. > > Where can I see your fix? > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24243: [clang-move] A prototype tool for moving class definition to new file.
hokein updated this revision to Diff 70538. hokein marked 19 inline comments as done. hokein added a comment. Herald added a subscriber: beanz. - Address review comments. https://reviews.llvm.org/D24243 Files: CMakeLists.txt clang-move/CMakeLists.txt clang-move/ClangMove.cpp clang-move/ClangMove.h clang-move/tool/CMakeLists.txt clang-move/tool/ClangMoveMain.cpp unittests/CMakeLists.txt unittests/clang-move/CMakeLists.txt unittests/clang-move/ClangMoveTests.cpp Index: unittests/clang-move/ClangMoveTests.cpp === --- /dev/null +++ unittests/clang-move/ClangMoveTests.cpp @@ -0,0 +1,226 @@ +//===-- ClangMoveTest.cpp - clang-move unit tests -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "ClangMove.h" +#include "unittests/Tooling/RewriterTestContext.h" +#include "clang/Format/Format.h" +#include "clang/Frontend/FrontendActions.h" +#include "clang/Frontend/TextDiagnosticPrinter.h" +#include "clang/Rewrite/Core/Rewriter.h" +#include "clang/Tooling/Refactoring.h" +#include "clang/Tooling/Tooling.h" +#include "llvm/ADT/StringRef.h" +#include "gtest/gtest.h" +#include +#include + +namespace clang { +namespace move { +namespace { + +const char TestHeaderName[] = "foo.h"; + +const char TestCCName[] = "foo.cc"; + +const char TestHeader[] = "namespace a {\n" + "class C1;\n" + "namespace b {\n" + "class Foo {\n" + "public:\n" + " void f();\n" + "\n" + "private:\n" + " C1 *c1;\n" + " static int b;\n" + "};\n" + "\n" + "class Foo2 {\n" + "public:\n" + " int f();\n" + "};\n" + "} // namespace b\n" + "} // namespace a\n"; + +const char TestCC[] = "#include \"foo.h\"\n" + "namespace a {\n" + "namespace b {\n" + "namespace {\n" + "void f1() {}\n" + "int kConstInt1 = 0;\n" + "} // namespace\n" + "\n" + "static int kConstInt2 = 1;\n" + "\n" + "static int help() {\n" + " int a = 0;\n" + " return a;\n" + "}\n" + "\n" + "void Foo::f() { f1(); }\n" + "\n" + "int Foo::b = 2;\n" + "int Foo2::f() {\n" + " f1();\n" + " return 1;\n" + "}\n" + "} // namespace b\n" + "} // namespace a\n"; + +const char ExpectedTestHeader[] = "namespace a {\n" + "class C1;\n" + "namespace b {\n" + "\n" + "class Foo2 {\n" + "public:\n" + " int f();\n" + "};\n" + "} // namespace b\n" + "} // namespace a\n"; + +const char ExpectedTestCC[] = "#include \"foo.h\"\n" + "namespace a {\n" + "namespace b {\n" + "namespace {\n" + "void f1() {}\n" + "int kConstInt1 = 0;\n" + "} // namespace\n" + "\n" + "static int kConstInt2 = 1;\n" + "\n" + "static int help() {\n" + " int a = 0;\n" + " return a;\n" + "}\n" + "\n" + "int Foo2::f() {\n" + " f1();\n" + " return 1;\n" + "}\n" + "} // namespace b\n" + "} // namespace a\n"; + +const char ExpectedNewHeader[] = "namespace a {\n" + "class C1;\n" + "namespace b {\n" + "class Foo {\n" + "public:\n
Re: [PATCH] D24075: [include-fixer] Support finding headers for the symbol under cursor.
massberg added a comment. Added two comments. It took some time for me to recall Emacs Lisps ;) Comment at: include-fixer/tool/clang-include-fixer.el:48 @@ +47,3 @@ + :group 'clang-include-fixer + :type 'bool + :risky t) Please use 'boolean here Comment at: include-fixer/tool/clang-include-fixer.el:204 @@ -197,3 +203,3 @@ (message (concat "Calling the include fixer. " "This might take some seconds. Please wait.")) Is this message still accurate when using the new query mode? https://reviews.llvm.org/D24075 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22227: [ubsan] Disable bounds-check for flexible array ivars
vsk added a comment. Ping? https://reviews.llvm.org/D7 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24075: [include-fixer] Support finding headers for the symbol under cursor.
hokein updated this revision to Diff 70545. hokein marked an inline comment as done. hokein updated the summary for this revision. hokein added a comment. bool => boolean https://reviews.llvm.org/D24075 Files: include-fixer/find-all-symbols/SymbolInfo.h include-fixer/tool/ClangIncludeFixer.cpp include-fixer/tool/clang-include-fixer.el include-fixer/tool/clang-include-fixer.py test/include-fixer/query_symbol.cpp Index: test/include-fixer/query_symbol.cpp === --- /dev/null +++ test/include-fixer/query_symbol.cpp @@ -0,0 +1,13 @@ +// RUN: clang-include-fixer -db=fixed -input='foo= "foo.h","bar.h"' -query-symbol="foo" test.cpp -- | FileCheck %s + +// CHECK: "FilePath": "test.cpp", +// CHECK-NEXT:"QuerySymbolInfos": [ +// CHECK-NEXT: {"RawIdentifier": "foo", +// CHECK-NEXT:"Range":{"Offset":0,"Length":0}} +// CHECK-NEXT:], +// CHECK-NEXT:"HeaderInfos": [ +// CHECK-NEXT: {"Header": "\"foo.h\"", +// CHECK-NEXT: "QualifiedName": "foo"}, +// CHECK-NEXT: {"Header": "\"bar.h\"", +// CHECK-NEXT: "QualifiedName": "foo"} +// CHECK-NEXT:] Index: include-fixer/tool/clang-include-fixer.py === --- include-fixer/tool/clang-include-fixer.py +++ include-fixer/tool/clang-include-fixer.py @@ -17,9 +17,10 @@ import argparse import difflib +import json +import re import subprocess import vim -import json # set g:clang_include_fixer_path to the path to clang-include-fixer if it is not # on the path. @@ -44,6 +45,10 @@ if vim.eval('exists("g:clang_include_fixer_jump_to_include")') == "1": jump_to_include = vim.eval('g:clang_include_fixer_jump_to_include') != "0" +query_mode = True +if vim.eval('exists("g:clang_include_fixer_query_mode")') == "1": + query_mode = vim.eval('g:clang_include_fixer_query_mode') != "0" + def GetUserSelection(message, headers, maximum_suggested_headers): eval_message = message + '\n' @@ -105,6 +110,25 @@ vim.current.window.cursor = (line_num, 0) +# The vim internal implementation (expand("cword"/"cWORD")) doesn't support +# our use case very well, we re-implement our own one. +def get_symbol_under_cursor(): + line = vim.eval("line(\".\")") + # column number in vim is 1-based. + col = int(vim.eval("col(\".\")")) - 1 + line_text = vim.eval("getline({0})".format(line)) + if len(line_text) == 0: return "" + symbol_pos_begin = col + p = re.compile('[a-zA-Z0-9:_]') + while symbol_pos_begin >= 0 and p.match(line_text[symbol_pos_begin]): +symbol_pos_begin -= 1 + + symbol_pos_end = col + while symbol_pos_end < len(line_text) and p.match(line_text[symbol_pos_end]): +symbol_pos_end += 1 + return line_text[symbol_pos_begin+1:symbol_pos_end] + + def main(): parser = argparse.ArgumentParser( description='Vim integration for clang-include-fixer') @@ -118,9 +142,18 @@ buf = vim.current.buffer text = '\n'.join(buf) - # Run command to get all headers. - command = [binary, "-stdin", "-output-headers", "-db=" + args.db, - "-input=" + args.input, vim.current.buffer.name] + if query_mode: +symbol = get_symbol_under_cursor() +if len(symbol) == 0: + print "Skip querying empty symbol." + return +command = [binary, "-stdin", "-query-symbol="+get_symbol_under_cursor(), + "-db=" + args.db, "-input=" + args.input, + vim.current.buffer.name] + else: +# Run command to get all headers. +command = [binary, "-stdin", "-output-headers", "-db=" + args.db, + "-input=" + args.input, vim.current.buffer.name] stdout, stderr = execute(command, text) if stderr: print >> sys.stderr, "Error while running clang-include-fixer: " + stderr Index: include-fixer/tool/clang-include-fixer.el === --- include-fixer/tool/clang-include-fixer.el +++ include-fixer/tool/clang-include-fixer.el @@ -36,11 +36,17 @@ (defcustom clang-include-fixer-init-string "" - "clang-include-fixer input format." + "clang-include-fixer init string." :group 'clang-include-fixer :type 'string :risky t) +(defcustom clang-include-fixer-query-mode + nil + "clang-include-fixer query mode." + :group 'clang-include-fixer + :type 'boolean + :risky t) (defun clang-include-fixer-call-executable (callee include-fixer-parameter-a @@ -197,11 +203,28 @@ (message (concat "Calling the include fixer. " "This might take some seconds. Please wait.")) - (clang-include-fixer-call-executable - 'clang-include-fixer-add-header - (concat "-db=" clang-include-fixer-input-format) - (concat "-input=" clang-include-fixer-init-string) - "-output-headers")) + (if clang-include-fixer-query-mode + (let (p1 p2) + (save-excursion +(skip-chars-backward "-a-zA-Z0-9_:") +(setq p1 (point)) +(skip-chars-for
Re: [PATCH] D24075: [include-fixer] Support finding headers for the symbol under cursor.
hokein marked an inline comment as done. Comment at: include-fixer/tool/clang-include-fixer.el:204 @@ -197,3 +203,3 @@ (message (concat "Calling the include fixer. " "This might take some seconds. Please wait.")) massberg wrote: > Is this message still accurate when using the new query mode? I think it is fine to keep it here. https://reviews.llvm.org/D24075 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24075: [include-fixer] Support finding headers for the symbol under cursor.
massberg added a comment. The Emacs part looks good for me now. Comment at: include-fixer/tool/clang-include-fixer.el:204 @@ -197,3 +203,3 @@ (message (concat "Calling the include fixer. " "This might take some seconds. Please wait.")) Then it fine for me, too. https://reviews.llvm.org/D24075 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23284: Add -fdiagnostics-show-hotness
anemet marked an inline comment as done. anemet added a comment. https://reviews.llvm.org/D23284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23284: Add -fdiagnostics-show-hotness
anemet updated this revision to Diff 70547. anemet updated the summary for this revision. anemet added a comment. Address Richard's comment https://reviews.llvm.org/D23284 Files: docs/UsersManual.rst include/clang/Basic/DiagnosticDriverKinds.td include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/CodeGenAction.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp test/Frontend/Inputs/optimization-remark-with-hotness.proftext test/Frontend/optimization-remark-with-hotness.c Index: test/Frontend/optimization-remark-with-hotness.c === --- /dev/null +++ test/Frontend/optimization-remark-with-hotness.c @@ -0,0 +1,45 @@ +// RUN: llvm-profdata merge \ +// RUN: %S/Inputs/optimization-remark-with-hotness.proftext \ +// RUN: -o %t.profdata +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ +// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ +// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \ +// RUN: -Rpass-analysis=inline -fdiagnostics-show-hotness -verify +// The clang version of the previous test. +// RUN: %clang -target x86_64-apple-macosx10.9 %s -o /dev/null \ +// RUN: -fprofile-instr-use=%t.profdata -Rpass=inline \ +// RUN: -Rpass-analysis=inline -fdiagnostics-show-hotness -Xclang -verify +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ +// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ +// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \ +// RUN: -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ +// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ +// RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \ +// RUN: -Rpass-analysis=inline -Rno-pass-with-hotness 2>&1 | FileCheck \ +// RUN: -check-prefix=HOTNESS_OFF %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ +// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ +// RUN: -Rpass=inline -Rpass-analysis=inline -fdiagnostics-show-hotness 2>&1 \ +// RUN: | FileCheck -check-prefix=NO_PGO %s + +int foo(int x, int y) __attribute__((always_inline)); +int foo(int x, int y) { return x + y; } + +int sum = 0; + +void bar(int x) { + // HOTNESS_OFF: foo inlined into bar + // HOTNESS_OFF-NOT: hotness: + // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information + // expected-remark@+2 {{foo should always be inlined (cost=always) (hotness: 30)}} + // expected-remark@+1 {{foo inlined into bar (hotness: 30)}} + sum += foo(x, x - 2); +} + +int main(int argc, const char *argv[]) { + for (int i = 0; i < 30; i++) +// expected-remark@+1 {{bar should never be inlined}} +bar(argc); + return sum; +} Index: test/Frontend/Inputs/optimization-remark-with-hotness.proftext === --- /dev/null +++ test/Frontend/Inputs/optimization-remark-with-hotness.proftext @@ -0,0 +1,25 @@ +foo +# Func Hash: +0 +# Num Counters: +1 +# Counter Values: +30 + +bar +# Func Hash: +0 +# Num Counters: +1 +# Counter Values: +30 + +main +# Func Hash: +4 +# Num Counters: +2 +# Counter Values: +1 +30 + Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -839,6 +839,12 @@ NeedLocTracking = true; } + Opts.DiagnosticsWithHotness = + Args.hasArg(options::OPT_fdiagnostics_show_hotness); + if (Opts.DiagnosticsWithHotness && + Opts.getProfileUse() == CodeGenOptions::ProfileNone) +Diags.Report(diag::warn_drv_fdiagnostics_show_hotness_requires_pgo); + // If the user requested to use a sample profile for PGO, then the // backend will need to track source location information so the profile // can be incorporated into the IR. Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4896,6 +4896,7 @@ claimNoWarnArgs(Args); Args.AddAllArgs(CmdArgs, options::OPT_R_Group); + Args.AddAllArgs(CmdArgs, options::OPT_W_Group); if (Args.hasFlag(options::OPT_pedantic, options::OPT_no_pedantic, false)) CmdArgs.push_back("-pedantic"); @@ -5898,6 +5899,10 @@ CmdArgs.push_back(A->getValue()); } + if (Args.hasFlag(options::OPT_fdiagnostics_show_hotness, + options::OPT_fno_diagnostics_show_hotness, false)) +CmdArgs.push_back("-fdiagnostics-show-hotness"); + if (const Arg *A = Args.getLastArg(options::OPT_fdiagnostics_format_EQ)) { CmdArgs.push_back("-fdiagnostics-format"); CmdArgs.push_back(A->getValue()); Index: lib/CodeGen/CodeGenAction.cpp
[clang-tools-extra] r280824 - [include-fixer] Support finding headers for the symbol under cursor.
Author: hokein Date: Wed Sep 7 11:34:35 2016 New Revision: 280824 URL: http://llvm.org/viewvc/llvm-project?rev=280824&view=rev Log: [include-fixer] Support finding headers for the symbol under cursor. Summary: * Add a `query-symbol` option to query symbol without parsing the source file. * Update Vim & Emacs integration scripts. Reviewers: bkramer, massberg Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24075 Added: clang-tools-extra/trunk/test/include-fixer/query_symbol.cpp Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h?rev=280824&r1=280823&r2=280824&view=diff == --- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h (original) +++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h Wed Sep 7 11:34:35 2016 @@ -54,6 +54,8 @@ public: int LineNumber, const std::vector &Contexts, unsigned NumOccurrences = 0); + void SetFilePath(llvm::StringRef Path) { FilePath = Path; } + /// \brief Get symbol name. llvm::StringRef getName() const { return Name; } Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=280824&r1=280823&r2=280824&view=diff == --- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original) +++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Wed Sep 7 11:34:35 2016 @@ -98,6 +98,12 @@ cl::opt Input("input", cl::desc("String to initialize the database"), cl::cat(IncludeFixerCategory)); +cl::opt +QuerySymbol("query-symbol", + cl::desc("Query a given symbol (e.g. \"a::b::foo\") in\n" + "database directly without parsing the file."), + cl::cat(IncludeFixerCategory)); + cl::opt MinimizeIncludePaths("minimize-paths", cl::desc("Whether to minimize added include paths"), @@ -236,6 +242,7 @@ int includeFixerMain(int argc, const cha tooling::ClangTool tool(options.getCompilations(), options.getSourcePathList()); + llvm::StringRef SourceFilePath = options.getSourcePathList().front(); // In STDINMode, we override the file content with the input. // Since `tool.mapVirtualFile` takes `StringRef`, we define `Code` outside of // the if-block so that `Code` is not released after the if-block. @@ -253,7 +260,7 @@ int includeFixerMain(int argc, const cha if (Code->getBufferSize() == 0) return 0; // Skip empty files. -tool.mapVirtualFile(options.getSourcePathList().front(), Code->getBuffer()); +tool.mapVirtualFile(SourceFilePath, Code->getBuffer()); } if (!InsertHeader.empty()) { @@ -314,10 +321,31 @@ int includeFixerMain(int argc, const cha // Set up data source. std::unique_ptr SymbolIndexMgr = - createSymbolIndexManager(options.getSourcePathList().front()); + createSymbolIndexManager(SourceFilePath); if (!SymbolIndexMgr) return 1; + // Query symbol mode. + if (!QuerySymbol.empty()) { +auto MatchedSymbols = SymbolIndexMgr->search(QuerySymbol); +for (auto &Symbol : MatchedSymbols) { + std::string HeaderPath = Symbol.getFilePath().str(); + Symbol.SetFilePath(((HeaderPath[0] == '"' || HeaderPath[0] == '<') + ? HeaderPath + : "\"" + HeaderPath + "\"")); +} + +// We leave an empty symbol range as we don't know the range of the symbol +// being queried in this mode. include-fixer won't add namespace qualifiers +// if the symbol range is empty, which also fits this case. +IncludeFixerContext::QuerySymbolInfo Symbol; +Symbol.RawIdentifier = QuerySymbol; +auto Context = +IncludeFixerContext(SourceFilePath, {Symbol}, MatchedSymbols); +writeToJson(llvm::outs(), Context); +return 0; + } + // Now run our tool. std::vector Contexts; include_fixer::IncludeFixerActionFactory Factory(*SymbolIndexMgr, Contexts, Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el?rev=280824&r1=280823&r2=280824&view=diff ==
Re: [PATCH] D24075: [include-fixer] Support finding headers for the symbol under cursor.
This revision was automatically updated to reflect the committed changes. hokein marked an inline comment as done. Closed by commit rL280824: [include-fixer] Support finding headers for the symbol under cursor. (authored by hokein). Changed prior to commit: https://reviews.llvm.org/D24075?vs=70545&id=70549#toc Repository: rL LLVM https://reviews.llvm.org/D24075 Files: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py clang-tools-extra/trunk/test/include-fixer/query_symbol.cpp Index: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el === --- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el +++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el @@ -36,11 +36,17 @@ (defcustom clang-include-fixer-init-string "" - "clang-include-fixer input format." + "clang-include-fixer init string." :group 'clang-include-fixer :type 'string :risky t) +(defcustom clang-include-fixer-query-mode + nil + "clang-include-fixer query mode." + :group 'clang-include-fixer + :type 'boolean + :risky t) (defun clang-include-fixer-call-executable (callee include-fixer-parameter-a @@ -197,11 +203,28 @@ (message (concat "Calling the include fixer. " "This might take some seconds. Please wait.")) - (clang-include-fixer-call-executable - 'clang-include-fixer-add-header - (concat "-db=" clang-include-fixer-input-format) - (concat "-input=" clang-include-fixer-init-string) - "-output-headers")) + (if clang-include-fixer-query-mode + (let (p1 p2) + (save-excursion +(skip-chars-backward "-a-zA-Z0-9_:") +(setq p1 (point)) +(skip-chars-forward "-a-zA-Z0-9_:") +(setq p2 (point)) +(setq query-symbol (buffer-substring-no-properties p1 p2)) +(if (string= "" query-symbol) +(message "Skip querying empty symbol.") + (clang-include-fixer-call-executable +'clang-include-fixer-add-header +(concat "-db=" clang-include-fixer-input-format) +(concat "-input=" clang-include-fixer-init-string) +(concat "-query-symbol=" (thing-at-point 'symbol)) + +(clang-include-fixer-call-executable + 'clang-include-fixer-add-header + (concat "-db=" clang-include-fixer-input-format) + (concat "-input=" clang-include-fixer-init-string) + "-output-headers")) + ) (provide 'clang-include-fixer) ;;; clang-include-fixer.el ends here Index: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py === --- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py +++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py @@ -17,9 +17,10 @@ import argparse import difflib +import json +import re import subprocess import vim -import json # set g:clang_include_fixer_path to the path to clang-include-fixer if it is not # on the path. @@ -44,6 +45,10 @@ if vim.eval('exists("g:clang_include_fixer_jump_to_include")') == "1": jump_to_include = vim.eval('g:clang_include_fixer_jump_to_include') != "0" +query_mode = True +if vim.eval('exists("g:clang_include_fixer_query_mode")') == "1": + query_mode = vim.eval('g:clang_include_fixer_query_mode') != "0" + def GetUserSelection(message, headers, maximum_suggested_headers): eval_message = message + '\n' @@ -105,6 +110,25 @@ vim.current.window.cursor = (line_num, 0) +# The vim internal implementation (expand("cword"/"cWORD")) doesn't support +# our use case very well, we re-implement our own one. +def get_symbol_under_cursor(): + line = vim.eval("line(\".\")") + # column number in vim is 1-based. + col = int(vim.eval("col(\".\")")) - 1 + line_text = vim.eval("getline({0})".format(line)) + if len(line_text) == 0: return "" + symbol_pos_begin = col + p = re.compile('[a-zA-Z0-9:_]') + while symbol_pos_begin >= 0 and p.match(line_text[symbol_pos_begin]): +symbol_pos_begin -= 1 + + symbol_pos_end = col + while symbol_pos_end < len(line_text) and p.match(line_text[symbol_pos_end]): +symbol_pos_end += 1 + return line_text[symbol_pos_begin+1:symbol_pos_end] + + def main(): parser = argparse.ArgumentParser( description='Vim integration for clang-include-fixer') @@ -118,9 +142,18 @@ buf = vim.current.buffer text = '\n'.join(buf) - # Run command to get all headers. - command = [binary, "-stdin", "-output-headers", "-db=" + args.db, - "-input=" + args.input, vim.current.buffer.name] + if query_mode: +symbol = get_symbol_under_cursor() +if len(symbol) == 0: + print "Skip quer
r280825 - Parsing MS pragma intrinsic
Author: rnk Date: Wed Sep 7 11:38:32 2016 New Revision: 280825 URL: http://llvm.org/viewvc/llvm-project?rev=280825&view=rev Log: Parsing MS pragma intrinsic Parse pragma intrinsic, display warning if the function isn't a builtin function in clang and suggest including intrin.h. Patch by Albert Gutowski! Reviewers: aaron.ballman, rnk Subscribers: aaron.ballman, cfe-commits Differential Revision: https://reviews.llvm.org/D23944 Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td cfe/trunk/include/clang/Basic/IdentifierTable.h cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/lib/Parse/ParsePragma.cpp cfe/trunk/test/Preprocessor/pragma_microsoft.c Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=280825&r1=280824&r2=280825&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Wed Sep 7 11:38:32 2016 @@ -911,6 +911,10 @@ def warn_pragma_invalid_action : Warning def warn_pragma_pack_malformed : Warning< "expected integer or identifier in '#pragma pack' - ignored">, InGroup; +// - #pragma intrinsic +def warn_pragma_intrinsic_builtin : Warning< + "%0 is not a recognized builtin%select{|; consider including to access non-builtin intrinsics}1">, + InGroup; // - #pragma unused def warn_pragma_unused_expected_var : Warning< "expected '#pragma unused' argument to be a variable name">, Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=280825&r1=280824&r2=280825&view=diff == --- cfe/trunk/include/clang/Basic/IdentifierTable.h (original) +++ cfe/trunk/include/clang/Basic/IdentifierTable.h Wed Sep 7 11:38:32 2016 @@ -205,8 +205,7 @@ public: /// \brief Return a value indicating whether this is a builtin function. /// - /// 0 is not-built-in. 1 is builtin-for-some-nonprimary-target. - /// 2+ are specific builtin functions. + /// 0 is not-built-in. 1+ are specific builtin functions. unsigned getBuiltinID() const { if (ObjCOrBuiltinID >= tok::NUM_OBJC_KEYWORDS) return ObjCOrBuiltinID - tok::NUM_OBJC_KEYWORDS; Modified: cfe/trunk/include/clang/Parse/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=280825&r1=280824&r2=280825&view=diff == --- cfe/trunk/include/clang/Parse/Parser.h (original) +++ cfe/trunk/include/clang/Parse/Parser.h Wed Sep 7 11:38:32 2016 @@ -172,6 +172,7 @@ class Parser : public CodeCompletionHand std::unique_ptr MSCodeSeg; std::unique_ptr MSSection; std::unique_ptr MSRuntimeChecks; + std::unique_ptr MSIntrinsic; std::unique_ptr OptimizeHandler; std::unique_ptr LoopHintHandler; std::unique_ptr UnrollHintHandler; Modified: cfe/trunk/lib/Parse/ParsePragma.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.cpp?rev=280825&r1=280824&r2=280825&view=diff == --- cfe/trunk/lib/Parse/ParsePragma.cpp (original) +++ cfe/trunk/lib/Parse/ParsePragma.cpp Wed Sep 7 11:38:32 2016 @@ -161,6 +161,12 @@ struct PragmaMSRuntimeChecksHandler : pu PragmaMSRuntimeChecksHandler() : EmptyPragmaHandler("runtime_checks") {} }; +struct PragmaMSIntrinsicHandler : public PragmaHandler { + PragmaMSIntrinsicHandler() : PragmaHandler("intrinsic") {} + void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, +Token &FirstToken) override; +}; + } // end namespace void Parser::initializePragmaHandlers() { @@ -229,6 +235,8 @@ void Parser::initializePragmaHandlers() PP.AddPragmaHandler(MSSection.get()); MSRuntimeChecks.reset(new PragmaMSRuntimeChecksHandler()); PP.AddPragmaHandler(MSRuntimeChecks.get()); +MSIntrinsic.reset(new PragmaMSIntrinsicHandler()); +PP.AddPragmaHandler(MSIntrinsic.get()); } OptimizeHandler.reset(new PragmaOptimizeHandler(Actions)); @@ -297,6 +305,8 @@ void Parser::resetPragmaHandlers() { MSSection.reset(); PP.RemovePragmaHandler(MSRuntimeChecks.get()); MSRuntimeChecks.reset(); +PP.RemovePragmaHandler(MSIntrinsic.get()); +MSIntrinsic.reset(); } PP.RemovePragmaHandler("STDC", FPContractHandler.get()); @@ -2127,3 +2137,53 @@ void PragmaUnrollHintHandler::HandlePrag PP.EnterTokenStream(std::move(TokenArray), 1, /*DisableMacroExpansion=*/false); } + +/// \brief Handle the Microsoft \#pragma intrinsic extension. +/// +/// The syntax is: +/// \code +/// #pragma intrinsic(memset) +/// #pragma intrinsic(strlen, memcpy) +/// \en
Re: [PATCH] D23944: Parsing MS pragma intrinsic
This revision was automatically updated to reflect the committed changes. Closed by commit rL280825: Parsing MS pragma intrinsic (authored by rnk). Changed prior to commit: https://reviews.llvm.org/D23944?vs=69768&id=70551#toc Repository: rL LLVM https://reviews.llvm.org/D23944 Files: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td cfe/trunk/include/clang/Basic/IdentifierTable.h cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/lib/Parse/ParsePragma.cpp cfe/trunk/test/Preprocessor/pragma_microsoft.c Index: cfe/trunk/include/clang/Basic/IdentifierTable.h === --- cfe/trunk/include/clang/Basic/IdentifierTable.h +++ cfe/trunk/include/clang/Basic/IdentifierTable.h @@ -205,8 +205,7 @@ /// \brief Return a value indicating whether this is a builtin function. /// - /// 0 is not-built-in. 1 is builtin-for-some-nonprimary-target. - /// 2+ are specific builtin functions. + /// 0 is not-built-in. 1+ are specific builtin functions. unsigned getBuiltinID() const { if (ObjCOrBuiltinID >= tok::NUM_OBJC_KEYWORDS) return ObjCOrBuiltinID - tok::NUM_OBJC_KEYWORDS; Index: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td @@ -911,6 +911,10 @@ def warn_pragma_pack_malformed : Warning< "expected integer or identifier in '#pragma pack' - ignored">, InGroup; +// - #pragma intrinsic +def warn_pragma_intrinsic_builtin : Warning< + "%0 is not a recognized builtin%select{|; consider including to access non-builtin intrinsics}1">, + InGroup; // - #pragma unused def warn_pragma_unused_expected_var : Warning< "expected '#pragma unused' argument to be a variable name">, Index: cfe/trunk/include/clang/Parse/Parser.h === --- cfe/trunk/include/clang/Parse/Parser.h +++ cfe/trunk/include/clang/Parse/Parser.h @@ -172,6 +172,7 @@ std::unique_ptr MSCodeSeg; std::unique_ptr MSSection; std::unique_ptr MSRuntimeChecks; + std::unique_ptr MSIntrinsic; std::unique_ptr OptimizeHandler; std::unique_ptr LoopHintHandler; std::unique_ptr UnrollHintHandler; Index: cfe/trunk/test/Preprocessor/pragma_microsoft.c === --- cfe/trunk/test/Preprocessor/pragma_microsoft.c +++ cfe/trunk/test/Preprocessor/pragma_microsoft.c @@ -162,3 +162,19 @@ // Test that runtime_checks is parsed but ignored. #pragma runtime_checks("sc", restore) // no-warning + +// Test pragma intrinsic +#pragma intrinsic(memset) // no-warning +#pragma intrinsic(memcpy, strlen, strlen) // no-warning +#pragma intrinsic() // no-warning +#pragma intrinsic(asdf) // expected-warning {{'asdf' is not a recognized builtin; consider including }} +#pragma intrinsic(main) // expected-warning {{'main' is not a recognized builtin; consider including }} +#pragma intrinsic( // expected-warning {{missing ')' after}} +#pragma intrinsic(int) // expected-warning {{missing ')' after}} +#pragma intrinsic(strcmp) asdf // expected-warning {{extra tokens at end}} + +#define __INTRIN_H // there should be no notes after defining __INTRIN_H +#pragma intrinsic(asdf) // expected-warning-re {{'asdf' is not a recognized builtin{{$ +#pragma intrinsic(memset) // no-warning +#undef __INTRIN_H +#pragma intrinsic(asdf) // expected-warning {{'asdf' is not a recognized builtin; consider including }} Index: cfe/trunk/lib/Parse/ParsePragma.cpp === --- cfe/trunk/lib/Parse/ParsePragma.cpp +++ cfe/trunk/lib/Parse/ParsePragma.cpp @@ -161,6 +161,12 @@ PragmaMSRuntimeChecksHandler() : EmptyPragmaHandler("runtime_checks") {} }; +struct PragmaMSIntrinsicHandler : public PragmaHandler { + PragmaMSIntrinsicHandler() : PragmaHandler("intrinsic") {} + void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, +Token &FirstToken) override; +}; + } // end namespace void Parser::initializePragmaHandlers() { @@ -229,6 +235,8 @@ PP.AddPragmaHandler(MSSection.get()); MSRuntimeChecks.reset(new PragmaMSRuntimeChecksHandler()); PP.AddPragmaHandler(MSRuntimeChecks.get()); +MSIntrinsic.reset(new PragmaMSIntrinsicHandler()); +PP.AddPragmaHandler(MSIntrinsic.get()); } OptimizeHandler.reset(new PragmaOptimizeHandler(Actions)); @@ -297,6 +305,8 @@ MSSection.reset(); PP.RemovePragmaHandler(MSRuntimeChecks.get()); MSRuntimeChecks.reset(); +PP.RemovePragmaHandler(MSIntrinsic.get()); +MSIntrinsic.reset(); } PP.RemovePragmaHandler("STDC", FPContractHandler.get()); @@ -2127,3 +2137,53 @@ PP.EnterTokenStream(std::move(TokenArray), 1, /*DisableMacroExpansion=*/false); } + +/// \brief Handle the Microsoft \#pragma int
Re: [PATCH] D24153: Add bunch of _Interlocked builtins
rnk added a comment. Looks good to me. David, do you remember any subtleties here? I seem to recall there were some bugs in our intrin.h implementations, or inconsistencies between us and MSVC. Comment at: test/CodeGen/ms-intrinsics.c:297 @@ +296,3 @@ +// CHECK: define{{.*}}i16 @test_InterlockedIncrement16(i16*{{[a-z_ ]*}}%Addend){{.*}}{ +// CHECK: [[TMP:%[0-9]+]] = atomicrmw volatile add i16* %Addend, i16 1 seq_cst +// CHECK: [[RESULT:%[0-9]+]] = add i16 [[TMP]], 1 I think we should make these increments and decrements non-volatile. I'd like us to be able to optimize this kind of code to return 2: int f() { int x = 0; _InterlockedIncrement(&x); _InterlockedIncrement(&x); return x; // always 2 } https://reviews.llvm.org/D24153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r280826 - Add MS __nop intrinsic to intrin.h
Author: rnk Date: Wed Sep 7 11:55:12 2016 New Revision: 280826 URL: http://llvm.org/viewvc/llvm-project?rev=280826&view=rev Log: Add MS __nop intrinsic to intrin.h Summary: There was no definition for __nop function - added inline assembly. Patch by Albert Gutowski! Reviewers: rnk, thakis Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24286 Modified: cfe/trunk/lib/Headers/intrin.h cfe/trunk/test/Headers/ms-intrin.cpp Modified: cfe/trunk/lib/Headers/intrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=280826&r1=280825&r2=280826&view=diff == --- cfe/trunk/lib/Headers/intrin.h (original) +++ cfe/trunk/lib/Headers/intrin.h Wed Sep 7 11:55:12 2016 @@ -97,6 +97,7 @@ static __inline__ void __movsd(unsigned long *, unsigned long const *, size_t); static __inline__ void __movsw(unsigned short *, unsigned short const *, size_t); +static __inline__ void __nop(void); void __nvreg_restore_fence(void); void __nvreg_save_fence(void); @@ -918,6 +919,10 @@ static __inline__ void __DEFAULT_FN_ATTR __halt(void) { __asm__ volatile ("hlt"); } +static __inline__ void __DEFAULT_FN_ATTRS +__nop(void) { + __asm__ volatile ("nop"); +} #endif /**\ Modified: cfe/trunk/test/Headers/ms-intrin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/ms-intrin.cpp?rev=280826&r1=280825&r2=280826&view=diff == --- cfe/trunk/test/Headers/ms-intrin.cpp (original) +++ cfe/trunk/test/Headers/ms-intrin.cpp Wed Sep 7 11:55:12 2016 @@ -52,6 +52,7 @@ void f() { __cpuidex(info, 0, 0); _xgetbv(0); __halt(); + __nop(); __readmsr(0); // FIXME: Call these in 64-bit too once the intrinsics have been fixed to ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24286: Add MS __nop intrinsic to intrin.h
This revision was automatically updated to reflect the committed changes. Closed by commit rL280826: Add MS __nop intrinsic to intrin.h (authored by rnk). Changed prior to commit: https://reviews.llvm.org/D24286?vs=70495&id=70555#toc Repository: rL LLVM https://reviews.llvm.org/D24286 Files: cfe/trunk/lib/Headers/intrin.h cfe/trunk/test/Headers/ms-intrin.cpp Index: cfe/trunk/test/Headers/ms-intrin.cpp === --- cfe/trunk/test/Headers/ms-intrin.cpp +++ cfe/trunk/test/Headers/ms-intrin.cpp @@ -52,6 +52,7 @@ __cpuidex(info, 0, 0); _xgetbv(0); __halt(); + __nop(); __readmsr(0); // FIXME: Call these in 64-bit too once the intrinsics have been fixed to Index: cfe/trunk/lib/Headers/intrin.h === --- cfe/trunk/lib/Headers/intrin.h +++ cfe/trunk/lib/Headers/intrin.h @@ -97,6 +97,7 @@ void __movsd(unsigned long *, unsigned long const *, size_t); static __inline__ void __movsw(unsigned short *, unsigned short const *, size_t); +static __inline__ void __nop(void); void __nvreg_restore_fence(void); void __nvreg_save_fence(void); @@ -918,6 +919,10 @@ __halt(void) { __asm__ volatile ("hlt"); } +static __inline__ void __DEFAULT_FN_ATTRS +__nop(void) { + __asm__ volatile ("nop"); +} #endif /**\ Index: cfe/trunk/test/Headers/ms-intrin.cpp === --- cfe/trunk/test/Headers/ms-intrin.cpp +++ cfe/trunk/test/Headers/ms-intrin.cpp @@ -52,6 +52,7 @@ __cpuidex(info, 0, 0); _xgetbv(0); __halt(); + __nop(); __readmsr(0); // FIXME: Call these in 64-bit too once the intrinsics have been fixed to Index: cfe/trunk/lib/Headers/intrin.h === --- cfe/trunk/lib/Headers/intrin.h +++ cfe/trunk/lib/Headers/intrin.h @@ -97,6 +97,7 @@ void __movsd(unsigned long *, unsigned long const *, size_t); static __inline__ void __movsw(unsigned short *, unsigned short const *, size_t); +static __inline__ void __nop(void); void __nvreg_restore_fence(void); void __nvreg_save_fence(void); @@ -918,6 +919,10 @@ __halt(void) { __asm__ volatile ("hlt"); } +static __inline__ void __DEFAULT_FN_ATTRS +__nop(void) { + __asm__ volatile ("nop"); +} #endif /**\ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24235: [OpenCL] Improve double literal handling
Anastasia added inline comments. Comment at: lib/Sema/SemaExpr.cpp:832 @@ -831,2 +831,3 @@ BTy->getKind() == BuiltinType::Float)) -E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get(); + { +if (getLangOpts().OpenCL && This should go on the previous line. Comment at: lib/Sema/SemaExpr.cpp:837 @@ +836,3 @@ + .getSupportedOpenCLOpts() + .cl_khr_fp64) || + getOpenCLOptions().cl_khr_fp64)) { Could we merge this and two lines above into one? Comment at: lib/Sema/SemaExpr.cpp:840 @@ +839,3 @@ +E = ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast).get(); +} +else I think the formatting is not right here. Could you change to: } else { Comment at: test/CodeGenOpenCL/fpmath.cl:28 @@ +27,3 @@ +void testdbllit(long *val) { + // CHECK-DBL: float 2.00e+01 + printf("%f", 20.0); Could you please add a check that double is generated in either CL2.0 or fp64 mode. https://reviews.llvm.org/D24235 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24158: Try contextually converting condition of constexpr if to Boolean value
ismailp updated this revision to Diff 70561. ismailp added a comment. - Added more tests https://reviews.llvm.org/D24158 Files: lib/Sema/SemaOverload.cpp test/CodeGenCXX/cxx1z-constexpr-if.cpp Index: test/CodeGenCXX/cxx1z-constexpr-if.cpp === --- test/CodeGenCXX/cxx1z-constexpr-if.cpp +++ test/CodeGenCXX/cxx1z-constexpr-if.cpp @@ -1,8 +1,17 @@ // RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - | FileCheck %s --implicit-check-not=should_not_be_used +// RUN: %clang_cc1 -std=c++1z %s -DCHECK_CONVERSION -verify %s void should_be_used_1(); void should_be_used_2(); +void should_be_used_3(); void should_not_be_used(); + +struct A { + constexpr explicit operator bool() const { +return true; + } +}; + void f() { if constexpr (false) should_not_be_used(); @@ -15,7 +24,17 @@ goto foo; foo: should_not_be_used(); } + if constexpr (A()) +should_be_used_3(); + else +should_not_be_used(); +#ifdef CHECK_CONVERSION + if constexpr (4.3) ; // expected-error{{conversion from 'double' to 'bool' is not allowed in a converted constant expression}} + constexpr void *p = nullptr; + if constexpr (p) ; // expected-error{{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}} +#endif } // CHECK: should_be_used_1 // CHECK: should_be_used_2 +// CHECK: should_be_used_3 Index: lib/Sema/SemaOverload.cpp === --- lib/Sema/SemaOverload.cpp +++ lib/Sema/SemaOverload.cpp @@ -5140,12 +5140,18 @@ // implicitly converted to type T, where the converted // expression is a constant expression and the implicit conversion // sequence contains only [... list of conversions ...]. + // C++1z [stmt.if]p2: + // If the if statement is of the form if constexpr, the value of the + // condition shall be a contextually converted constant expression of type + // bool. ImplicitConversionSequence ICS = -TryCopyInitialization(S, From, T, - /*SuppressUserConversions=*/false, - /*InOverloadResolution=*/false, - /*AllowObjcWritebackConversion=*/false, - /*AllowExplicit=*/false); + CCE == Sema::CCEK_ConstexprIf + ? TryContextuallyConvertToBool(S, From) + : TryCopyInitialization(S, From, T, + /*SuppressUserConversions=*/false, + /*InOverloadResolution=*/false, + /*AllowObjcWritebackConversion=*/false, + /*AllowExplicit=*/false); StandardConversionSequence *SCS = nullptr; switch (ICS.getKind()) { case ImplicitConversionSequence::StandardConversion: Index: test/CodeGenCXX/cxx1z-constexpr-if.cpp === --- test/CodeGenCXX/cxx1z-constexpr-if.cpp +++ test/CodeGenCXX/cxx1z-constexpr-if.cpp @@ -1,8 +1,17 @@ // RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - | FileCheck %s --implicit-check-not=should_not_be_used +// RUN: %clang_cc1 -std=c++1z %s -DCHECK_CONVERSION -verify %s void should_be_used_1(); void should_be_used_2(); +void should_be_used_3(); void should_not_be_used(); + +struct A { + constexpr explicit operator bool() const { +return true; + } +}; + void f() { if constexpr (false) should_not_be_used(); @@ -15,7 +24,17 @@ goto foo; foo: should_not_be_used(); } + if constexpr (A()) +should_be_used_3(); + else +should_not_be_used(); +#ifdef CHECK_CONVERSION + if constexpr (4.3) ; // expected-error{{conversion from 'double' to 'bool' is not allowed in a converted constant expression}} + constexpr void *p = nullptr; + if constexpr (p) ; // expected-error{{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}} +#endif } // CHECK: should_be_used_1 // CHECK: should_be_used_2 +// CHECK: should_be_used_3 Index: lib/Sema/SemaOverload.cpp === --- lib/Sema/SemaOverload.cpp +++ lib/Sema/SemaOverload.cpp @@ -5140,12 +5140,18 @@ // implicitly converted to type T, where the converted // expression is a constant expression and the implicit conversion // sequence contains only [... list of conversions ...]. + // C++1z [stmt.if]p2: + // If the if statement is of the form if constexpr, the value of the + // condition shall be a contextually converted constant expression of type + // bool. ImplicitConversionSequence ICS = -TryCopyInitialization(S, From, T, - /*SuppressUserConversions=*/false, - /*InOverloadResolution=*/false, - /*AllowObjcWritebackConversion=*/false, - /*AllowExplicit=*/false); + CCE == Sema::CCEK_ConstexprIf + ? TryContextuallyC
r280827 - Add missing include. White space.
Author: vvassilev Date: Wed Sep 7 12:30:50 2016 New Revision: 280827 URL: http://llvm.org/viewvc/llvm-project?rev=280827&view=rev Log: Add missing include. White space. Modified: cfe/trunk/include/clang/Lex/ModuleMap.h Modified: cfe/trunk/include/clang/Lex/ModuleMap.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=280827&r1=280826&r2=280827&view=diff == --- cfe/trunk/include/clang/Lex/ModuleMap.h (original) +++ cfe/trunk/include/clang/Lex/ModuleMap.h Wed Sep 7 12:30:50 2016 @@ -18,6 +18,7 @@ #include "clang/Basic/LangOptions.h" #include "clang/Basic/Module.h" +#include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" @@ -27,7 +28,7 @@ #include namespace clang { - + class DirectoryEntry; class FileEntry; class FileManager; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24158: Try contextually converting condition of constexpr if to Boolean value
ismailp added a comment. Thank you for reviewing. Sure, I'll try to look into those conversions as well. Comment at: test/CodeGenCXX/cxx1z-constexpr-if.cpp:2 @@ -1,2 +1,3 @@ // RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - | FileCheck %s --implicit-check-not=should_not_be_used +// RUN: %clang_cc1 -std=c++1z %s -DCHECK_CONVERSION -verify %s Is there a more elegant way to do this? The previous check didn't seem to work with diagnostics. https://reviews.llvm.org/D24158 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24165: [clang-offload-bundler] Fix some Clang-tidy modernize-use-override and Include What You Use warnings; other minor fixes
This revision was automatically updated to reflect the committed changes. Closed by commit rL280828: [clang-offload-bundler] Fix some Clang-tidy modernize-use-override and… (authored by eugenezelenko). Changed prior to commit: https://reviews.llvm.org/D24165?vs=70084&id=70564#toc Repository: rL LLVM https://reviews.llvm.org/D24165 Files: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Index: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp === --- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp +++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp @@ -1,4 +1,4 @@ -//===-- clang-offload-bundler/ClangOffloadBundler.cpp - Clang format tool -===// +//===-- clang-offload-bundler/ClangOffloadBundler.cpp -===// // // The LLVM Compiler Infrastructure // @@ -15,22 +15,39 @@ /// //===--===// -#include "clang/Basic/FileManager.h" #include "clang/Basic/Version.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/ADT/Triple.h" #include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/IR/Constant.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/GlobalVariable.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/Object/Binary.h" -#include "llvm/Object/ELFObjectFile.h" #include "llvm/Object/ObjectFile.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/Program.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Support/Signals.h" +#include +#include +#include +#include +#include +#include +#include +#include using namespace llvm; using namespace llvm::object; @@ -116,33 +133,41 @@ /// Generic file handler interface. class FileHandler { public: + FileHandler() {} + + virtual ~FileHandler() {} + /// Update the file handler with information from the header of the bundled /// file virtual void ReadHeader(MemoryBuffer &Input) = 0; + /// Read the marker of the next bundled to be read in the file. The triple of /// the target associated with that bundle is returned. An empty string is /// returned if there are no more bundles to be read. virtual StringRef ReadBundleStart(MemoryBuffer &Input) = 0; + /// Read the marker that closes the current bundle. virtual void ReadBundleEnd(MemoryBuffer &Input) = 0; + /// Read the current bundle and write the result into the stream \a OS. virtual void ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0; /// Write the header of the bundled file to \a OS based on the information /// gathered from \a Inputs. virtual void WriteHeader(raw_fd_ostream &OS, ArrayRef> Inputs) = 0; + /// Write the marker that initiates a bundle for the triple \a TargetTriple to /// \a OS. virtual void WriteBundleStart(raw_fd_ostream &OS, StringRef TargetTriple) = 0; + /// Write the marker that closes a bundle for the triple \a TargetTriple to \a /// OS. Return true if any error was found. + virtual bool WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) = 0; + /// Write the bundle from \a Input into \a OS. virtual void WriteBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0; - - FileHandler() {} - virtual ~FileHandler() {} }; /// Handler for binary files. The bundled file will have the following format @@ -183,7 +208,6 @@ /// Write 8-byte integers to a buffer in little-endian format. static void Write8byteIntegerToBuffer(raw_fd_ostream &OS, uint64_t Val) { - for (unsigned i = 0; i < 8; ++i) { char Char = (char)(Val & 0xffu); OS.write(&Char, 1); @@ -198,17 +222,23 @@ uint64_t Size = 0u; /// Offset at which the bundle starts in the bundled file. uint64_t Offset = 0u; + BundleInfo() {} BundleInfo(uint64_t Size, uint64_t Offset) : Size(Size), Offset(Offset) {} }; + /// Map between a triple and the corresponding bundle information. StringMap BundlesInfo; /// Iterator for the bundle information that is being read. StringMap::iterator CurBundleInfo; public: - void ReadHeader(MemoryBuffer &Input) { + BinaryFileHandler() : FileHandler() {} + + ~BinaryFileHandler() final {} + + void ReadHeader(MemoryBuffer &Input) final { StringRef FC = Input.getBuffer(); // Initialize the current bundle with the end of the container. @@ -273,25 +303,28 @@ // Set the iterator to where we will start to read. CurBundleInfo = BundlesInfo.begin(); } - StringRef ReadBundleStart(MemoryBuffer &Input)
r280828 - [clang-offload-bundler] Fix some Clang-tidy modernize-use-override and Include What You Use warnings; other minor fixes.
Author: eugenezelenko Date: Wed Sep 7 12:37:28 2016 New Revision: 280828 URL: http://llvm.org/viewvc/llvm-project?rev=280828&view=rev Log: [clang-offload-bundler] Fix some Clang-tidy modernize-use-override and Include What You Use warnings; other minor fixes. Differential revision: https://reviews.llvm.org/D24165 Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp?rev=280828&r1=280827&r2=280828&view=diff == --- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp (original) +++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Wed Sep 7 12:37:28 2016 @@ -1,4 +1,4 @@ -//===-- clang-offload-bundler/ClangOffloadBundler.cpp - Clang format tool -===// +//===-- clang-offload-bundler/ClangOffloadBundler.cpp -===// // // The LLVM Compiler Infrastructure // @@ -15,22 +15,39 @@ /// //===--===// -#include "clang/Basic/FileManager.h" #include "clang/Basic/Version.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/ADT/Triple.h" #include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/IR/Constant.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/GlobalVariable.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/Object/Binary.h" -#include "llvm/Object/ELFObjectFile.h" #include "llvm/Object/ObjectFile.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/Program.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Support/Signals.h" +#include +#include +#include +#include +#include +#include +#include +#include using namespace llvm; using namespace llvm::object; @@ -116,15 +133,22 @@ static bool hasHostKind(StringRef Target /// Generic file handler interface. class FileHandler { public: + FileHandler() {} + + virtual ~FileHandler() {} + /// Update the file handler with information from the header of the bundled /// file virtual void ReadHeader(MemoryBuffer &Input) = 0; + /// Read the marker of the next bundled to be read in the file. The triple of /// the target associated with that bundle is returned. An empty string is /// returned if there are no more bundles to be read. virtual StringRef ReadBundleStart(MemoryBuffer &Input) = 0; + /// Read the marker that closes the current bundle. virtual void ReadBundleEnd(MemoryBuffer &Input) = 0; + /// Read the current bundle and write the result into the stream \a OS. virtual void ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0; @@ -132,17 +156,18 @@ public: /// gathered from \a Inputs. virtual void WriteHeader(raw_fd_ostream &OS, ArrayRef> Inputs) = 0; + /// Write the marker that initiates a bundle for the triple \a TargetTriple to /// \a OS. virtual void WriteBundleStart(raw_fd_ostream &OS, StringRef TargetTriple) = 0; + /// Write the marker that closes a bundle for the triple \a TargetTriple to \a /// OS. Return true if any error was found. + virtual bool WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) = 0; + /// Write the bundle from \a Input into \a OS. virtual void WriteBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0; - - FileHandler() {} - virtual ~FileHandler() {} }; /// Handler for binary files. The bundled file will have the following format @@ -183,7 +208,6 @@ static uint64_t Read8byteIntegerFromBuff /// Write 8-byte integers to a buffer in little-endian format. static void Write8byteIntegerToBuffer(raw_fd_ostream &OS, uint64_t Val) { - for (unsigned i = 0; i < 8; ++i) { char Char = (char)(Val & 0xffu); OS.write(&Char, 1); @@ -198,9 +222,11 @@ class BinaryFileHandler final : public F uint64_t Size = 0u; /// Offset at which the bundle starts in the bundled file. uint64_t Offset = 0u; + BundleInfo() {} BundleInfo(uint64_t Size, uint64_t Offset) : Size(Size), Offset(Offset) {} }; + /// Map between a triple and the corresponding bundle information. StringMap BundlesInfo; @@ -208,7 +234,11 @@ class BinaryFileHandler final : public F StringMap::iterator CurBundleInfo; public: - void ReadHeader(MemoryBuffer &Input) { + BinaryFileHandler() : FileHandler() {} + + ~BinaryFileHandler() final {} + + void ReadHeader(MemoryBuffer &Input) final { StringRef FC = Input.
Re: [PATCH] D24158: Try contextually converting condition of constexpr if to Boolean value
rsmith added inline comments. Comment at: test/CodeGenCXX/cxx1z-constexpr-if.cpp:2 @@ -1,2 +1,3 @@ // RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - | FileCheck %s --implicit-check-not=should_not_be_used +// RUN: %clang_cc1 -std=c++1z %s -DCHECK_CONVERSION -verify %s ismailp wrote: > Is there a more elegant way to do this? The previous check didn't seem to > work with diagnostics. Tests for semantic issues should go into test/SemaCXX (organized by category) or test/CXX (organized by section of the standard). In this case, test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp is probably the most appropriate place (somewhere in its `namespace ccce`, perhaps). https://reviews.llvm.org/D24158 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24307: calculate extent size for memory regions allocated by C++ new expression
dkrupp created this revision. dkrupp added reviewers: xazax.hun, NoQ, dcoughlin, zaks.anna. dkrupp added a subscriber: cfe-commits. ArrayBoundChecker did not detect out of bounds memory access errors in case an array was allocated by the new expression. 1. MallocChecker.cpp was updated to calculate the extent size in Bytes similarly how it was done for memory regions allocated by malloc. The size constraint is added for arrays and non-arrays allocated by new. 2. ArrayBoundCheckerV2.cpp was updated to better handle accessing locations preceding a symbolic memory region (such as buf[-1] in test2(..) in out-of-bounds.cpp). So computeExtentBegin(..) was updated to assume that the extent of a symbolic region starts at 0 if we know the size of the extent (as is the case in case of malloc or new). 3. out-of-bounds.cpp contains the relevant test cases for C++. https://reviews.llvm.org/D24307 Files: lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp lib/StaticAnalyzer/Checkers/MallocChecker.cpp test/Analysis/out-of-bounds.cpp Index: test/Analysis/out-of-bounds.cpp === --- /dev/null +++ test/Analysis/out-of-bounds.cpp @@ -0,0 +1,147 @@ +// RUN: %clang_cc1 -std=c++11 -Wno-array-bounds -analyze -analyzer-checker=unix,core,alpha.security.ArrayBoundV2 -verify %s + +// Tests doing an out-of-bounds access after the end of an array using: +// - constant integer index +// - constant integer size for buffer +void test1(int x) { + int *buf = new int[100]; + buf[100] = 1; // expected-warning{{Out of bound memory access}} +} + +void test1_ok(int x) { + int *buf = new int[100]; + buf[99] = 1; // no-warning +} + +// Tests doing an out-of-bounds access after the end of an array using: +// - indirect pointer to buffer +// - constant integer index +// - constant integer size for buffer +void test1_ptr(int x) { + int *buf = new int[100]; + int *p = buf; + p[101] = 1; // expected-warning{{Out of bound memory access}} +} + +void test1_ptr_ok(int x) { + int *buf = new int[100]; + int *p = buf; + p[99] = 1; // no-warning +} + +// Tests doing an out-of-bounds access before the start of an array using: +// - indirect pointer to buffer, manipulated using simple pointer arithmetic +// - constant integer index +// - constant integer size for buffer +void test1_ptr_arith(int x) { + int *buf = new int[100]; + int *p = buf; + p = p + 100; + p[0] = 1; // expected-warning{{Out of bound memory access}} +} + +void test1_ptr_arith_ok(int x) { + int *buf = new int[100]; + int *p = buf; + p = p + 99; + p[0] = 1; // no-warning +} + +void test1_ptr_arith_bad(int x) { + int *buf = new int[100]; + int *p = buf; + p = p + 99; + p[1] = 1; // expected-warning{{Out of bound memory access}} +} + +void test1_ptr_arith_ok2(int x) { + int *buf = new int[100]; + int *p = buf; + p = p + 99; + p[-1] = 1; // no-warning +} + +// Tests doing an out-of-bounds access before the start of an array using: +// - constant integer index +// - constant integer size for buffer +void test2(int x) { + int *buf = new int[100]; + buf[-1] = 1; // expected-warning{{Out of bound memory access}} +} + +// Tests doing an out-of-bounds access before the start of an array using: +// - indirect pointer to buffer +// - constant integer index +// - constant integer size for buffer +void test2_ptr(int x) { + int *buf = new int[100]; + int *p = buf; + p[-1] = 1; // expected-warning{{Out of bound memory access}} +} + +// Tests doing an out-of-bounds access before the start of an array using: +// - indirect pointer to buffer, manipulated using simple pointer arithmetic +// - constant integer index +// - constant integer size for buffer +void test2_ptr_arith(int x) { + int *buf = new int[100]; + int *p = buf; + --p; + p[0] = 1; // expected-warning {{Out of bound memory access (accessed memory precedes memory block)}} +} + +// Tests doing an out-of-bounds access before the start of a multi-dimensional +// array using: +// - constant integer indices +// - constant integer sizes for the array +void test2_multi(int x) { + auto buf = new int[100][100]; + buf[0][-1] = 1; // expected-warning{{Out of bound memory access}} +} + +// Tests doing an out-of-bounds access before the start of a multi-dimensional +// array using: +// - constant integer indices +// - constant integer sizes for the array +void test2_multi_b(int x) { + auto buf = new int[100][100]; + buf[-1][0] = 1; // expected-warning{{Out of bound memory access}} +} + +// Tests doing an out-of-bounds access before the start of a multi-dimensional +// array using: +// - constant integer indices +// - constant integer sizes for the array +void test2_multi_c(int x) { + auto buf = new int[100][100]; + buf[100][0] = 1; // expected-warning{{Out of bound memory access}} +} + +// Tests doing an out-of-bounds access before the start of a multi-dimensional +// array using: +// - constant integer indices +// - constant integer sizes f
Re: [PATCH] D24113: Allow implicit conversions between incompatible pointer types in overload resolution in C.
On Tue, Sep 6, 2016 at 10:55 PM, George Burgess IV < george.burgess...@gmail.com> wrote: > george.burgess.iv added a comment. > > > Although I think that users will expect atomic_add(unsigned int *, 5) to > work.without error > > > Totally agree; I was just making sure that I understood the problem. :) > > I think, with a small tweak in semantics, we can make everything work > without needing to patch existing code. Let me play around a little. It seems to me that we could handle this by ranking viable-but-ill-formed conversion sequences before non-viable ones in clang::isBetterOverloadCandidate. This problem is actually more general than __attribute__((overloadable)) in C -- there is one form of ill-formed implicit conversion sequence that we accept in C++ that leads to the same problem: void f(char*, int); void f(const char*, unsigned); void g() { f("foo", 0); } Clang reports an ambiguity on line 3, but in C++11 onwards this code is valid because there is no implicit conversion sequence from a string literal to char*. (We provide one as an extension, and it's ranked worse than any other conversion.) > Repository: > rL LLVM > > https://reviews.llvm.org/D24113 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24054: Do not validate pch when -fno-validate-pch is set
yaxunl updated the summary for this revision. yaxunl updated this revision to Diff 70569. yaxunl added a comment. Herald added a subscriber: wdng. Implemented a simple AST reader listener to replace PCHValidator. Added a test. https://reviews.llvm.org/D24054 Files: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp test/PCH/no-validate-pch.cl Index: test/PCH/no-validate-pch.cl === --- /dev/null +++ test/PCH/no-validate-pch.cl @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -emit-pch -D TWO=2 -D X=4 -o %t %s -triple spir-unknown-unknown +// RUN: %clang_cc1 -include-pch %t -D THREE=3 -D X=5 -O0 -U__OPTIMIZE__ -fno-validate-pch %s -triple spir-unknown-unknown 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -include-pch %t -D THREE=3 -D X=5 -D VALIDATE -O0 -fsyntax-only %s -triple spir-unknown-unknown 2>&1 | FileCheck --check-prefix=CHECK-VAL %s + +#ifndef HEADER +#define HEADER +// Header. + +#define ONE 1 + +#else +// Using the header. + +// CHECK: warning: 'X' macro redefined +// CHECK: #define X 5 +// CHECK: note: previous definition is here +// CHECK: #define X 4 + +// CHECK-VAL: error: __OPTIMIZE__ predefined macro was enabled in PCH file but is currently disabled +// CHECK-VAL: error: definition of macro 'X' differs between the precompiled header ('4') and the command line ('5') + +void test(void) { + int a = ONE; + int b = TWO; + int c = THREE; + +#ifndef VALIDATE +#if X != 5 +#error Definition of X is not overridden! +#endif + +#ifdef __OPTIMIZE__ +#error Optimization is not off! +#endif +#endif + +} + +#endif Index: lib/Serialization/ASTReader.cpp === --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -496,12 +496,16 @@ /// against the preprocessor options in an existing preprocessor. /// /// \param Diags If non-null, produce diagnostics for any mismatches incurred. +/// \param Validate If true, validate preprocessor options. If false, allow +///macros defined by \p ExistingPPOpts to override those defined by +///\p PPOpts in SuggestedPredefines. static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts, const PreprocessorOptions &ExistingPPOpts, DiagnosticsEngine *Diags, FileManager &FileMgr, std::string &SuggestedPredefines, - const LangOptions &LangOpts) { + const LangOptions &LangOpts, + bool Validate = true) { // Check macro definitions. MacroDefinitionsMap ASTFileMacros; collectMacroDefinitions(PPOpts, ASTFileMacros); @@ -517,7 +521,7 @@ // Check whether we know anything about this macro name or not. llvm::StringMap >::iterator Known = ASTFileMacros.find(MacroName); -if (Known == ASTFileMacros.end()) { +if (!Validate || Known == ASTFileMacros.end()) { // FIXME: Check whether this identifier was referenced anywhere in the // AST file. If so, we should reject the AST file. Unfortunately, this // information isn't in the control block. What shall we do about it? @@ -560,16 +564,16 @@ } // Check whether we're using predefines. - if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines) { + if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines && Validate) { if (Diags) { Diags->Report(diag::err_pch_undef) << ExistingPPOpts.UsePredefines; } return true; } // Detailed record is important since it is used for the module cache hash. if (LangOpts.Modules && - PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord) { + PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord && Validate) { if (Diags) { Diags->Report(diag::err_pch_pp_detailed_record) << PPOpts.DetailedRecord; } @@ -618,6 +622,19 @@ PP.getLangOpts()); } +bool SimpleASTReaderListener::ReadPreprocessorOptions( + const PreprocessorOptions &PPOpts, + bool Complain, + std::string &SuggestedPredefines) { + return checkPreprocessorOptions(PPOpts, + PP.getPreprocessorOpts(), + nullptr, + PP.getFileManager(), + SuggestedPredefines, + PP.getLangOpts(), + false); +} + /// Check the header search options deserialized from the control block /// against the header search options in an existing preprocessor. /// @@ -8710,7 +8727,10 @@ bool AllowConfigurationMismatch, bool ValidateSystemInputs, bool UseGlobalIndex, std::unique_ptr Read
Re: [PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.
ioeric added inline comments. Comment at: change-namespace/ChangeNamespace.cpp:21 @@ +20,3 @@ +inline std::string formatNamespace(llvm::StringRef NS) { + (void)NS.ltrim(':'); + return NS.str(); hokein wrote: > this statement doesn't do the intended thing (It won't change `NS`). The > result returned by `ltrim` is what you want here, I think. Aha, no wonder! Thanks! Comment at: change-namespace/ChangeNamespace.cpp:480 @@ +479,3 @@ +Replaces = Replaces.merge(NewReplacements); +format::FormatStyle Style = format::getStyle("file", FilePath, "google"); +// Clean up old namespaces if there is nothing in it after moving. hokein wrote: > omtcyfz wrote: > > omtcyfz wrote: > > > By the way, shouldn't this one be "LLVM"? > > Alternatively, it might be nice to provide an option to specify desired > > formatting style. > +1 on adding a `CodeStyle` command-line option. Will do. Comment at: unittests/change-namespace/ChangeNamespaceTests.cpp:49 @@ +48,3 @@ +formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite); +return format(Context.getRewrittenText(ID)); + } hokein wrote: > Looks like `formatAndApplyAllReplacements` has already formatted the code, > why do we need to format it again? `formatAndApplyAllReplacements ` only formats around replacements. I added `format` to format the whole file so that I don't need to get every white space right in `Code` and `Expected`. https://reviews.llvm.org/D24183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24153: Add bunch of _Interlocked builtins
agutowski updated this revision to Diff 70572. agutowski added a comment. Mark _InterlockedIncrement and _InterlockedDecrement as non-volatile https://reviews.llvm.org/D24153 Files: include/clang/Basic/Builtins.def lib/CodeGen/CGBuiltin.cpp lib/Headers/intrin.h test/CodeGen/ms-intrinsics.c test/CodeGen/pr27892.c Index: lib/Headers/intrin.h === --- lib/Headers/intrin.h +++ lib/Headers/intrin.h @@ -602,177 +602,6 @@ } #endif /**\ -|* Interlocked Exchange Add -\**/ -static __inline__ char __DEFAULT_FN_ATTRS -_InterlockedExchangeAdd8(char volatile *_Addend, char _Value) { - return __atomic_fetch_add(_Addend, _Value, __ATOMIC_SEQ_CST); -} -static __inline__ short __DEFAULT_FN_ATTRS -_InterlockedExchangeAdd16(short volatile *_Addend, short _Value) { - return __atomic_fetch_add(_Addend, _Value, __ATOMIC_SEQ_CST); -} -#ifdef __x86_64__ -static __inline__ __int64 __DEFAULT_FN_ATTRS -_InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value) { - return __atomic_fetch_add(_Addend, _Value, __ATOMIC_SEQ_CST); -} -#endif -/**\ -|* Interlocked Exchange Sub -\**/ -static __inline__ char __DEFAULT_FN_ATTRS -_InterlockedExchangeSub8(char volatile *_Subend, char _Value) { - return __atomic_fetch_sub(_Subend, _Value, __ATOMIC_SEQ_CST); -} -static __inline__ short __DEFAULT_FN_ATTRS -_InterlockedExchangeSub16(short volatile *_Subend, short _Value) { - return __atomic_fetch_sub(_Subend, _Value, __ATOMIC_SEQ_CST); -} -static __inline__ long __DEFAULT_FN_ATTRS -_InterlockedExchangeSub(long volatile *_Subend, long _Value) { - return __atomic_fetch_sub(_Subend, _Value, __ATOMIC_SEQ_CST); -} -#ifdef __x86_64__ -static __inline__ __int64 __DEFAULT_FN_ATTRS -_InterlockedExchangeSub64(__int64 volatile *_Subend, __int64 _Value) { - return __atomic_fetch_sub(_Subend, _Value, __ATOMIC_SEQ_CST); -} -#endif -/**\ -|* Interlocked Increment -\**/ -static __inline__ short __DEFAULT_FN_ATTRS -_InterlockedIncrement16(short volatile *_Value) { - return __atomic_add_fetch(_Value, 1, __ATOMIC_SEQ_CST); -} -#ifdef __x86_64__ -static __inline__ __int64 __DEFAULT_FN_ATTRS -_InterlockedIncrement64(__int64 volatile *_Value) { - return __atomic_add_fetch(_Value, 1, __ATOMIC_SEQ_CST); -} -#endif -/**\ -|* Interlocked Decrement -\**/ -static __inline__ short __DEFAULT_FN_ATTRS -_InterlockedDecrement16(short volatile *_Value) { - return __atomic_sub_fetch(_Value, 1, __ATOMIC_SEQ_CST); -} -#ifdef __x86_64__ -static __inline__ __int64 __DEFAULT_FN_ATTRS -_InterlockedDecrement64(__int64 volatile *_Value) { - return __atomic_sub_fetch(_Value, 1, __ATOMIC_SEQ_CST); -} -#endif -/**\ -|* Interlocked And -\**/ -static __inline__ char __DEFAULT_FN_ATTRS -_InterlockedAnd8(char volatile *_Value, char _Mask) { - return __atomic_fetch_and(_Value, _Mask, __ATOMIC_SEQ_CST); -} -static __inline__ short __DEFAULT_FN_ATTRS -_InterlockedAnd16(short volatile *_Value, short _Mask) { - return __atomic_fetch_and(_Value, _Mask, __ATOMIC_SEQ_CST); -} -static __inline__ long __DEFAULT_FN_ATTRS -_InterlockedAnd(long volatile *_Value, long _Mask) { - return __atomic_fetch_and(_Value, _Mask, __ATOMIC_SEQ_CST); -} -#ifdef __x86_64__ -static __inline__ __int64 __DEFAULT_FN_ATTRS -_InterlockedAnd64(__int64 volatile *_Value, __int64 _Mask) { - return __atomic_fetch_and(_Value, _Mask, __ATOMIC_SEQ_CST); -} -#endif -/**\ -|* Interlocked Or -\**/ -static __inline__ char __DEFAULT_FN_ATTRS -_InterlockedOr8(char volatile *_Value, char _Mask) { - return __atomic_fetch_or(_Value, _Mask, __ATOMIC_SEQ_CST); -} -static __inline__ short __DEFAULT_FN_ATTRS -_InterlockedOr16(short volatile *_Value, short _Mask) { - return __atomic_fetch_or(_Value, _Mask, __ATOMIC_SEQ_CST); -} -static __inline__ long __DEFAULT_FN_ATTRS -_InterlockedOr(long volatile *_Value, long _Mask) { - return __atomic_fetch_or(_Value, _Mask, __ATOMIC_SEQ_CST); -} -#ifdef __x86_64__ -static __inline__ __int64 __DEFAULT_FN_ATTRS -_InterlockedOr64(__int64 volatile *_Value, __int64 _Mask) { - return __atomic_fetch_or(_Value, _Mask, _
Re: [PATCH] D24153: Add bunch of _Interlocked builtins
agutowski marked an inline comment as done. agutowski added a comment. https://reviews.llvm.org/D24153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r280836 - [MS] Fix prologue this adjustment when 'this' is passed indirectly
Author: rnk Date: Wed Sep 7 13:21:30 2016 New Revision: 280836 URL: http://llvm.org/viewvc/llvm-project?rev=280836&view=rev Log: [MS] Fix prologue this adjustment when 'this' is passed indirectly Move the logic for doing this from the ABI argument lowering into EmitParmDecl, which runs for all parameters. Our codegen is slightly suboptimal in this case, as we may leave behind a dead store after optimization, but it's 32-bit inalloca, and this fixes the bug in a robust way. Fixes PR30293 Modified: cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/lib/CodeGen/CGDecl.cpp cfe/trunk/test/CodeGenCXX/constructor-destructor-return-this.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-this-adjustment.cpp Modified: cfe/trunk/lib/CodeGen/CGCall.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=280836&r1=280835&r2=280836&view=diff == --- cfe/trunk/lib/CodeGen/CGCall.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Sep 7 13:21:30 2016 @@ -2309,13 +2309,6 @@ void CodeGenFunction::EmitFunctionProlog if (isPromoted) V = emitArgumentDemotion(*this, Arg, V); -if (const CXXMethodDecl *MD = -dyn_cast_or_null(CurCodeDecl)) { - if (MD->isVirtual() && Arg == CXXABIThisDecl) -V = CGM.getCXXABI(). -adjustThisParameterInVirtualFunctionPrologue(*this, CurGD, V); -} - // Because of merging of function types from multiple decls it is // possible for the type of an argument to not match the corresponding // type in the function type. Since we are codegening the callee Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=280836&r1=280835&r2=280836&view=diff == --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Sep 7 13:21:30 2016 @@ -13,6 +13,7 @@ #include "CodeGenFunction.h" #include "CGBlocks.h" +#include "CGCXXABI.h" #include "CGCleanup.h" #include "CGDebugInfo.h" #include "CGOpenCLRuntime.h" @@ -1769,6 +1770,24 @@ void CodeGenFunction::EmitParmDecl(const setBlockContextParameter(IPD, ArgNo, Arg.getDirectValue()); return; } + +// Apply any prologue 'this' adjustments required by the ABI. Be careful to +// handle the case where 'this' is passed indirectly as part of an inalloca +// struct. +if (const CXXMethodDecl *MD = +dyn_cast_or_null(CurCodeDecl)) { + if (MD->isVirtual() && IPD == CXXABIThisDecl) { +llvm::Value *This = Arg.isIndirect() +? Builder.CreateLoad(Arg.getIndirectAddress()) +: Arg.getDirectValue(); +This = CGM.getCXXABI().adjustThisParameterInVirtualFunctionPrologue( +*this, CurGD, This); +if (Arg.isIndirect()) + Builder.CreateStore(This, Arg.getIndirectAddress()); +else + Arg = ParamValue::forDirect(This); + } +} } Address DeclPtr = Address::invalid(); Modified: cfe/trunk/test/CodeGenCXX/constructor-destructor-return-this.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/constructor-destructor-return-this.cpp?rev=280836&r1=280835&r2=280836&view=diff == --- cfe/trunk/test/CodeGenCXX/constructor-destructor-return-this.cpp (original) +++ cfe/trunk/test/CodeGenCXX/constructor-destructor-return-this.cpp Wed Sep 7 13:21:30 2016 @@ -111,7 +111,7 @@ D::~D() { } // CHECKIOS5-LABEL: define %class.D* @_ZN1DD1Ev(%class.D* %this) // CHECKMS-LABEL: define x86_thiscallcc %class.D* @"\01??0D@@QAE@XZ"(%class.D* returned %this, i32 %is_most_derived) -// CHECKMS-LABEL: define x86_thiscallcc void @"\01??1D@@UAE@XZ"(%class.D*) +// CHECKMS-LABEL: define x86_thiscallcc void @"\01??1D@@UAE@XZ"(%class.D* %this) class E { public: Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp?rev=280836&r1=280835&r2=280836&view=diff == --- cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp (original) +++ cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp Wed Sep 7 13:21:30 2016 @@ -196,7 +196,7 @@ struct E : virtual C { int e; }; struct F : D, E { ~F(); int f; }; F::~F() { -// CHECK-LABEL: define x86_thiscallcc void @"\01??1F@test2@@UAE@XZ"(%"struct.test2::F"*) +// CHECK-LABEL: define x86_thiscallcc void @"\01??1F@test2@@UAE@XZ"(%"struct.test2::F"*{{[^,]*}}) // Do an a
r280838 - Try contextually converting condition of constexpr if to Boolean value
Author: ismailp Date: Wed Sep 7 13:24:54 2016 New Revision: 280838 URL: http://llvm.org/viewvc/llvm-project?rev=280838&view=rev Log: Try contextually converting condition of constexpr if to Boolean value Summary: C++1z 6.4.1/p2: If the if statement is of the form if constexpr, the value of the condition shall be a contextually converted constant expression of type bool [...] C++1z 5.20/p4: [...] A contextually converted constant expression of type bool is an expression, contextually converted to bool (Clause4), where the converted expression is a constant expression and the conversion sequence contains only the conversions above. [...] Contextually converting result of an expression `e` to a Boolean value requires `bool t(e)` to be well-formed. An explicit conversion function is only considered as a user-defined conversion for direct-initialization, which is essentially what //contextually converted to bool// requires. Also, fixes PR28470. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24158 Modified: cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp cfe/trunk/test/CodeGenCXX/cxx1z-constexpr-if.cpp Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=280838&r1=280837&r2=280838&view=diff == --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Sep 7 13:24:54 2016 @@ -5164,12 +5164,18 @@ static ExprResult CheckConvertedConstant // implicitly converted to type T, where the converted // expression is a constant expression and the implicit conversion // sequence contains only [... list of conversions ...]. + // C++1z [stmt.if]p2: + // If the if statement is of the form if constexpr, the value of the + // condition shall be a contextually converted constant expression of type + // bool. ImplicitConversionSequence ICS = -TryCopyInitialization(S, From, T, - /*SuppressUserConversions=*/false, - /*InOverloadResolution=*/false, - /*AllowObjcWritebackConversion=*/false, - /*AllowExplicit=*/false); + CCE == Sema::CCEK_ConstexprIf + ? TryContextuallyConvertToBool(S, From) + : TryCopyInitialization(S, From, T, + /*SuppressUserConversions=*/false, + /*InOverloadResolution=*/false, + /*AllowObjcWritebackConversion=*/false, + /*AllowExplicit=*/false); StandardConversionSequence *SCS = nullptr; switch (ICS.getKind()) { case ImplicitConversionSequence::StandardConversion: Modified: cfe/trunk/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp?rev=280838&r1=280837&r2=280838&view=diff == --- cfe/trunk/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp (original) +++ cfe/trunk/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp Wed Sep 7 13:24:54 2016 @@ -46,6 +46,11 @@ namespace ccce { if constexpr (N) {} // expected-error {{cannot be narrowed}} } template void g<5>(); // expected-note {{instantiation of}} + void h() { +if constexpr (4.3) {} // expected-error{{conversion from 'double' to 'bool' is not allowed in a converted constant expression}} +constexpr void *p = nullptr; +if constexpr (p) {} // expected-error{{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}} + } } namespace generic_lambda { Modified: cfe/trunk/test/CodeGenCXX/cxx1z-constexpr-if.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx1z-constexpr-if.cpp?rev=280838&r1=280837&r2=280838&view=diff == --- cfe/trunk/test/CodeGenCXX/cxx1z-constexpr-if.cpp (original) +++ cfe/trunk/test/CodeGenCXX/cxx1z-constexpr-if.cpp Wed Sep 7 13:24:54 2016 @@ -2,7 +2,15 @@ void should_be_used_1(); void should_be_used_2(); +void should_be_used_3(); void should_not_be_used(); + +struct A { + constexpr explicit operator bool() const { +return true; + } +}; + void f() { if constexpr (false) should_not_be_used(); @@ -15,7 +23,12 @@ void f() { goto foo; foo: should_not_be_used(); } + if constexpr (A()) +should_be_used_3(); + else +should_not_be_used(); } // CHECK: should_be_used_1 // CHECK: should_be_used_2 +// CHECK: should_be_used_3 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24158: Try contextually converting condition of constexpr if to Boolean value
This revision was automatically updated to reflect the committed changes. Closed by commit rL280838: Try contextually converting condition of constexpr if to Boolean value (authored by ismailp). Changed prior to commit: https://reviews.llvm.org/D24158?vs=70561&id=70577#toc Repository: rL LLVM https://reviews.llvm.org/D24158 Files: cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp cfe/trunk/test/CodeGenCXX/cxx1z-constexpr-if.cpp Index: cfe/trunk/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp === --- cfe/trunk/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp +++ cfe/trunk/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp @@ -46,6 +46,11 @@ if constexpr (N) {} // expected-error {{cannot be narrowed}} } template void g<5>(); // expected-note {{instantiation of}} + void h() { +if constexpr (4.3) {} // expected-error{{conversion from 'double' to 'bool' is not allowed in a converted constant expression}} +constexpr void *p = nullptr; +if constexpr (p) {} // expected-error{{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}} + } } namespace generic_lambda { Index: cfe/trunk/test/CodeGenCXX/cxx1z-constexpr-if.cpp === --- cfe/trunk/test/CodeGenCXX/cxx1z-constexpr-if.cpp +++ cfe/trunk/test/CodeGenCXX/cxx1z-constexpr-if.cpp @@ -2,7 +2,15 @@ void should_be_used_1(); void should_be_used_2(); +void should_be_used_3(); void should_not_be_used(); + +struct A { + constexpr explicit operator bool() const { +return true; + } +}; + void f() { if constexpr (false) should_not_be_used(); @@ -15,7 +23,12 @@ goto foo; foo: should_not_be_used(); } + if constexpr (A()) +should_be_used_3(); + else +should_not_be_used(); } // CHECK: should_be_used_1 // CHECK: should_be_used_2 +// CHECK: should_be_used_3 Index: cfe/trunk/lib/Sema/SemaOverload.cpp === --- cfe/trunk/lib/Sema/SemaOverload.cpp +++ cfe/trunk/lib/Sema/SemaOverload.cpp @@ -5164,12 +5164,18 @@ // implicitly converted to type T, where the converted // expression is a constant expression and the implicit conversion // sequence contains only [... list of conversions ...]. + // C++1z [stmt.if]p2: + // If the if statement is of the form if constexpr, the value of the + // condition shall be a contextually converted constant expression of type + // bool. ImplicitConversionSequence ICS = -TryCopyInitialization(S, From, T, - /*SuppressUserConversions=*/false, - /*InOverloadResolution=*/false, - /*AllowObjcWritebackConversion=*/false, - /*AllowExplicit=*/false); + CCE == Sema::CCEK_ConstexprIf + ? TryContextuallyConvertToBool(S, From) + : TryCopyInitialization(S, From, T, + /*SuppressUserConversions=*/false, + /*InOverloadResolution=*/false, + /*AllowObjcWritebackConversion=*/false, + /*AllowExplicit=*/false); StandardConversionSequence *SCS = nullptr; switch (ICS.getKind()) { case ImplicitConversionSequence::StandardConversion: Index: cfe/trunk/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp === --- cfe/trunk/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp +++ cfe/trunk/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp @@ -46,6 +46,11 @@ if constexpr (N) {} // expected-error {{cannot be narrowed}} } template void g<5>(); // expected-note {{instantiation of}} + void h() { +if constexpr (4.3) {} // expected-error{{conversion from 'double' to 'bool' is not allowed in a converted constant expression}} +constexpr void *p = nullptr; +if constexpr (p) {} // expected-error{{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}} + } } namespace generic_lambda { Index: cfe/trunk/test/CodeGenCXX/cxx1z-constexpr-if.cpp === --- cfe/trunk/test/CodeGenCXX/cxx1z-constexpr-if.cpp +++ cfe/trunk/test/CodeGenCXX/cxx1z-constexpr-if.cpp @@ -2,7 +2,15 @@ void should_be_used_1(); void should_be_used_2(); +void should_be_used_3(); void should_not_be_used(); + +struct A { + constexpr explicit operator bool() const { +return true; + } +}; + void f() { if constexpr (false) should_not_be_used(); @@ -15,7 +23,12 @@ goto foo; foo: should_not_be_used(); } + if constexpr (A()) +should_be_used_3(); + else +should_not_be_used(); } // CHECK: should_be_used_1 // CHECK: should_be_used_2 +// CHECK: should_be_used_3 Index: cfe/trunk/lib/Sema/SemaOverload.cpp
Re: [PATCH] D23848: Add a clang-tidy Visual Studio extension
The unnecessary usings are added by Visual Studio, so I would rather leave them. For example, they often provide extension methods to containers so that containers can be used with functional paradigms, and you expect to see those methods in the Intellisense window when you type "Foo.", but without the using statement they would not appear. In general they don't affect performance or compilation the same way that #includes do in C++, so for the ones that are added automatically by Visual Studio I would rather leave them alone. I've cleaned up all the unnecessary ones that were not automatically added though. On Wed, Sep 7, 2016 at 4:27 AM Alexander Kornienko wrote: > alexfh added inline comments. > > > Comment at: clang-tidy-vs/ClangTidy/ClangTidyPackage.cs:53 > @@ +52,3 @@ > +private void MenuItemCallback(object sender, EventArgs args) > +{ > +} > > Add a FIXME to actually implement this. > > > https://reviews.llvm.org/D23848 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24158: Try contextually converting condition of constexpr if to Boolean value
ismailp added inline comments. Comment at: test/CodeGenCXX/cxx1z-constexpr-if.cpp:2 @@ -1,2 +1,3 @@ // RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - | FileCheck %s --implicit-check-not=should_not_be_used +// RUN: %clang_cc1 -std=c++1z %s -DCHECK_CONVERSION -verify %s rsmith wrote: > ismailp wrote: > > Is there a more elegant way to do this? The previous check didn't seem to > > work with diagnostics. > Tests for semantic issues should go into test/SemaCXX (organized by category) > or test/CXX (organized by section of the standard). In this case, > test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp is probably the most > appropriate place (somewhere in its `namespace ccce`, perhaps). Thanks! I've done that, and pushed. Repository: rL LLVM https://reviews.llvm.org/D24158 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r280839 - Resubmit "Add a test for clang-tidy using the clang-cl driver."
Author: zturner Date: Wed Sep 7 13:28:42 2016 New Revision: 280839 URL: http://llvm.org/viewvc/llvm-project?rev=280839&view=rev Log: Resubmit "Add a test for clang-tidy using the clang-cl driver." This was originally reverted because the patch on the clang tooling side was reverted. That patch is being resubmitted, so this patch is resubmitted as well. Added: clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp Added: clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp?rev=280839&view=auto == --- clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp (added) +++ clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp Wed Sep 7 13:28:42 2016 @@ -0,0 +1,17 @@ +// RUN: clang-tidy -checks=-*,modernize-use-nullptr %s -- --driver-mode=cl /DTEST1 /DFOO=foo /DBAR=bar | FileCheck -implicit-check-not="{{warning|error}}:" %s +int *a = 0; +// CHECK: :[[@LINE-1]]:10: warning: use nullptr +#ifdef TEST1 +int *b = 0; +// CHECK: :[[@LINE-1]]:10: warning: use nullptr +#endif +#define foo 1 +#define bar 1 +#if FOO +int *c = 0; +// CHECK: :[[@LINE-1]]:10: warning: use nullptr +#endif +#if BAR +int *d = 0; +// CHECK: :[[@LINE-1]]:10: warning: use nullptr +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.
alexshap added a subscriber: alexshap. Comment at: change-namespace/ChangeNamespace.cpp:125 @@ +124,3 @@ +// applying all existing Replaces first if there is conflict. +void addOrMergeReplacement(const tooling::Replacement &R, + tooling::Replacements *Replaces) { khm, this seems to be a recurring pattern (if i'm not mistaken), looks like the interface of tooling::Replacements can be changed/improved (although i don't know). Another (separate) observation is about duplicates. For example for replacements in headers we can get into if(Err) branch pretty frequently because the same replacement can be generated multiple times (if that header is included into several *.cpp files). https://reviews.llvm.org/D24183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24054: Do not validate pch when -fno-validate-pch is set
rsmith accepted this revision. rsmith added a comment. It's pretty gross that we're computing `SuggestedPredefines` in the `ASTReaderListener`, but sure, this seems OK for now. https://reviews.llvm.org/D24054 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24054: Do not validate pch when -fno-validate-pch is set
Anastasia accepted this revision. Anastasia added a comment. This revision is now accepted and ready to land. LGTM! https://reviews.llvm.org/D24054 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r280842 - Do not validate pch when -fno-validate-pch is set
Author: yaxunl Date: Wed Sep 7 13:40:20 2016 New Revision: 280842 URL: http://llvm.org/viewvc/llvm-project?rev=280842&view=rev Log: Do not validate pch when -fno-validate-pch is set There is a bug causing pch to be validated even though -fno-validate-pch is set. This patch fixes it. ASTReader relies on ASTReaderListener to initialize SuggestedPredefines, which is required for compilations using PCH. Before this change, PCHValidator is the default ASTReaderListener. After this change, when -fno-validate-pch is set, PCHValidator is disabled, but we need a replacement ASTReaderListener to initialize SuggestedPredefines. Class SimpleASTReaderListener is implemented for this purpose. This change only affects -fno-validate-pch. There is no functional change if -fno-validate-pch is not set. If -fno-validate-pch is not set, conflicts in predefined macros between pch and current compiler instance causes error. If -fno-validate-pch is set, predefine macros in current compiler override those in pch so that compilation can continue. Differential Revision: https://reviews.llvm.org/D24054 Added: cfe/trunk/test/PCH/no-validate-pch.cl Modified: cfe/trunk/include/clang/Serialization/ASTReader.h cfe/trunk/lib/Serialization/ASTReader.cpp Modified: cfe/trunk/include/clang/Serialization/ASTReader.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=280842&r1=280841&r2=280842&view=diff == --- cfe/trunk/include/clang/Serialization/ASTReader.h (original) +++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Sep 7 13:40:20 2016 @@ -284,6 +284,21 @@ private: void Error(const char *Msg); }; +/// \brief ASTReaderListenter implementation to set SuggestedPredefines of +/// ASTReader which is required to use a pch file. This is the replacement +/// of PCHValidator or SimplePCHValidator when using a pch file without +/// validating it. +class SimpleASTReaderListener : public ASTReaderListener { + Preprocessor &PP; + +public: + SimpleASTReaderListener(Preprocessor &PP) +: PP(PP) {} + + bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, + std::string &SuggestedPredefines) override; +}; + namespace serialization { class ReadMethodPoolVisitor; Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=280842&r1=280841&r2=280842&view=diff == --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Sep 7 13:40:20 2016 @@ -496,12 +496,16 @@ collectMacroDefinitions(const Preprocess /// against the preprocessor options in an existing preprocessor. /// /// \param Diags If non-null, produce diagnostics for any mismatches incurred. +/// \param Validate If true, validate preprocessor options. If false, allow +///macros defined by \p ExistingPPOpts to override those defined by +///\p PPOpts in SuggestedPredefines. static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts, const PreprocessorOptions &ExistingPPOpts, DiagnosticsEngine *Diags, FileManager &FileMgr, std::string &SuggestedPredefines, - const LangOptions &LangOpts) { + const LangOptions &LangOpts, + bool Validate = true) { // Check macro definitions. MacroDefinitionsMap ASTFileMacros; collectMacroDefinitions(PPOpts, ASTFileMacros); @@ -517,7 +521,7 @@ static bool checkPreprocessorOptions(con // Check whether we know anything about this macro name or not. llvm::StringMap >::iterator Known = ASTFileMacros.find(MacroName); -if (Known == ASTFileMacros.end()) { +if (!Validate || Known == ASTFileMacros.end()) { // FIXME: Check whether this identifier was referenced anywhere in the // AST file. If so, we should reject the AST file. Unfortunately, this // information isn't in the control block. What shall we do about it? @@ -560,7 +564,7 @@ static bool checkPreprocessorOptions(con } // Check whether we're using predefines. - if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines) { + if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines && Validate) { if (Diags) { Diags->Report(diag::err_pch_undef) << ExistingPPOpts.UsePredefines; } @@ -569,7 +573,7 @@ static bool checkPreprocessorOptions(con // Detailed record is important since it is used for the module cache hash. if (LangOpts.Modules && - PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord) { + PPOpts.DetailedRecord !=
Re: [PATCH] D24054: Do not validate pch when -fno-validate-pch is set
This revision was automatically updated to reflect the committed changes. Closed by commit rL280842: Do not validate pch when -fno-validate-pch is set (authored by yaxunl). Changed prior to commit: https://reviews.llvm.org/D24054?vs=70569&id=70580#toc Repository: rL LLVM https://reviews.llvm.org/D24054 Files: cfe/trunk/include/clang/Serialization/ASTReader.h cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/test/PCH/no-validate-pch.cl Index: cfe/trunk/lib/Serialization/ASTReader.cpp === --- cfe/trunk/lib/Serialization/ASTReader.cpp +++ cfe/trunk/lib/Serialization/ASTReader.cpp @@ -496,12 +496,16 @@ /// against the preprocessor options in an existing preprocessor. /// /// \param Diags If non-null, produce diagnostics for any mismatches incurred. +/// \param Validate If true, validate preprocessor options. If false, allow +///macros defined by \p ExistingPPOpts to override those defined by +///\p PPOpts in SuggestedPredefines. static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts, const PreprocessorOptions &ExistingPPOpts, DiagnosticsEngine *Diags, FileManager &FileMgr, std::string &SuggestedPredefines, - const LangOptions &LangOpts) { + const LangOptions &LangOpts, + bool Validate = true) { // Check macro definitions. MacroDefinitionsMap ASTFileMacros; collectMacroDefinitions(PPOpts, ASTFileMacros); @@ -517,7 +521,7 @@ // Check whether we know anything about this macro name or not. llvm::StringMap >::iterator Known = ASTFileMacros.find(MacroName); -if (Known == ASTFileMacros.end()) { +if (!Validate || Known == ASTFileMacros.end()) { // FIXME: Check whether this identifier was referenced anywhere in the // AST file. If so, we should reject the AST file. Unfortunately, this // information isn't in the control block. What shall we do about it? @@ -560,16 +564,16 @@ } // Check whether we're using predefines. - if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines) { + if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines && Validate) { if (Diags) { Diags->Report(diag::err_pch_undef) << ExistingPPOpts.UsePredefines; } return true; } // Detailed record is important since it is used for the module cache hash. if (LangOpts.Modules && - PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord) { + PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord && Validate) { if (Diags) { Diags->Report(diag::err_pch_pp_detailed_record) << PPOpts.DetailedRecord; } @@ -618,6 +622,19 @@ PP.getLangOpts()); } +bool SimpleASTReaderListener::ReadPreprocessorOptions( + const PreprocessorOptions &PPOpts, + bool Complain, + std::string &SuggestedPredefines) { + return checkPreprocessorOptions(PPOpts, + PP.getPreprocessorOpts(), + nullptr, + PP.getFileManager(), + SuggestedPredefines, + PP.getLangOpts(), + false); +} + /// Check the header search options deserialized from the control block /// against the header search options in an existing preprocessor. /// @@ -8710,7 +8727,10 @@ bool AllowConfigurationMismatch, bool ValidateSystemInputs, bool UseGlobalIndex, std::unique_ptr ReadTimer) -: Listener(new PCHValidator(PP, *this)), DeserializationListener(nullptr), +: Listener(DisableValidation ? +cast(new SimpleASTReaderListener(PP)) : +cast(new PCHValidator(PP, *this))), + DeserializationListener(nullptr), OwnsDeserializationListener(false), SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()), PCHContainerRdr(PCHContainerRdr), Diags(PP.getDiagnostics()), SemaObj(nullptr), PP(PP), Context(Context), Index: cfe/trunk/include/clang/Serialization/ASTReader.h === --- cfe/trunk/include/clang/Serialization/ASTReader.h +++ cfe/trunk/include/clang/Serialization/ASTReader.h @@ -284,6 +284,21 @@ void Error(const char *Msg); }; +/// \brief ASTReaderListenter implementation to set SuggestedPredefines of +/// ASTReader which is required to use a pch file. This is the replacement +/// of PCHValidator or SimplePCHValidator when using a pch file without +/// validating it. +class SimpleASTReaderListener : public ASTReaderListener { + Preprocessor &PP; + +public: + SimpleASTReaderListen
Re: [PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.
alexshap added inline comments. Comment at: change-namespace/tool/ClangChangeNamespace.cpp:48 @@ +47,3 @@ + +cl::opt OldNamespace("old_namespace", cl::desc("Old namespace."), + cl::cat(ChangeNamespaceCategory)); probably you need to add cl::Required cl::opt OldNamespace("old_namespace", cl::Required, cl::desc("Old namespace."), cl::cat(ChangeNamespaceCategory)); and the same for NewNamespace. https://reviews.llvm.org/D24183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24153: Add bunch of _Interlocked builtins
majnemer added a comment. In https://reviews.llvm.org/D24153#535992, @rnk wrote: > Looks good to me. David, do you remember any subtleties here? I seem to > recall there were some bugs in our intrin.h implementations, or > inconsistencies between us and MSVC. I can't seem to recall anything major. Our `_ReadBarrier` and `_WriteBarrier` simply map to `_ReadWriteBarrier`. Our `__faststorefence` is just a normal fence instead of an interlocked operation. https://reviews.llvm.org/D24153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23932: [XRay] ARM 32-bit no-Thumb support in Clang
rSerge added a comment. I don't have commit access rights. Could someone commit? https://reviews.llvm.org/D23932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24268: Traversing template paramter lists of DeclaratorDecls and/or TagDecls.
lukasza added a comment. In https://reviews.llvm.org/D24268#535463, @rsmith wrote: > This patch looks great, thank you! Do you have an SVN account or do you need > someone to commit this for you? I don't have an SVN account. Could you please commit the patch for me? https://reviews.llvm.org/D24268 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Modules: Suggestion on how to fix a regression caused by r259901
Hi Richard, We noticed a regression for this simple testing case: rm -rf tmp3 clang -cc1 -fimplicit-module-maps -x objective-c -fmodules -fmodules-cache-path=tmp3 -emit-obj standalone.c -I Inputs/ —> standalone.c:4:6: error: variable has incomplete type 'void' void foo __P(()); ^ standalone.c:4:9: error: expected ';' after top level declarator void foo __P(()); ^ ; 2 errors generated. clang -cc1 -fimplicit-module-maps -x objective-c -fmodules -fmodules-cache-path=tmp3 -emit-obj standalone.c -I Inputs/ —> This runs fine. cat standalone.c #import "C.h" #import "A.h" void foo __P(()); cat Inputs/module.map module X { header "A.h" export * } // Y imports X, it also uses “__P” as a parameter name module Y { header "B.h" export * } // Z imports X and Y module Z { header "C.h” } cat Inputs/A.h #define __P(protos) () cat Inputs/B.h #import "A.h" #import "B2.h” cat Inputs/B2.h void test(int __P) { } cat Inputs/C.h #import "A.h" #import “B.h” r259901 causes the compiler to write out identifier “__P” without the macro information for module Y, which seems to be incorrect. Any suggestion on how to fix this? Why the 2nd run works is related to global index. Global Index only considers interesting identifiers, so it skips module Y when calling ModuleManager::visit. Cheers, Manman ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r280728 - Modules: Fix an assertion in DeclContext::buildLookup.
On Tue, Sep 6, 2016 at 6:54 PM, Richard Smith wrote: > On Tue, Sep 6, 2016 at 11:16 AM, Manman Ren via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: mren >> Date: Tue Sep 6 13:16:54 2016 >> New Revision: 280728 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=280728&view=rev >> Log: >> Modules: Fix an assertion in DeclContext::buildLookup. >> >> When calling getMostRecentDecl, we can pull in more definitions from >> a module. We call getPrimaryContext afterwards to make sure that >> we buildLookup on a primary context. >> >> rdar://27926200 >> >> Added: >> cfe/trunk/test/Modules/Inputs/lookup-assert/ >> cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h >> cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h >> cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h >> cfe/trunk/test/Modules/Inputs/lookup-assert/module.map >> cfe/trunk/test/Modules/lookup-assert.m >> Modified: >> cfe/trunk/lib/AST/DeclBase.cpp >> >> Modified: cfe/trunk/lib/AST/DeclBase.cpp >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBa >> se.cpp?rev=280728&r1=280727&r2=280728&view=diff >> >> == >> --- cfe/trunk/lib/AST/DeclBase.cpp (original) >> +++ cfe/trunk/lib/AST/DeclBase.cpp Tue Sep 6 13:16:54 2016 >> @@ -1411,10 +1411,6 @@ DeclContext::lookup(DeclarationName Name >>assert(DeclKind != Decl::LinkageSpec && >> "Should not perform lookups into linkage specs!"); >> >> - const DeclContext *PrimaryContext = getPrimaryContext(); >> - if (PrimaryContext != this) >> -return PrimaryContext->lookup(Name); >> - >>// If we have an external source, ensure that any later redeclarations >> of this >>// context have been loaded, since they may add names to the result of >> this >>// lookup (or add external visible storage). >> @@ -1422,6 +1418,12 @@ DeclContext::lookup(DeclarationName Name >>if (Source) >> (void)cast(this)->getMostRecentDecl(); >> >> + // getMostRecentDecl can change the result of getPrimaryContext. Call >> + // getPrimaryContext afterwards. >> + const DeclContext *PrimaryContext = getPrimaryContext(); >> + if (PrimaryContext != this) >> +return PrimaryContext->lookup(Name); >> > > This seems like a bug in getPrimaryContext() -- if there is a > not-yet-loaded definition of the DeclContext, getPrimaryContext() should > return that instead of returning a non-defining declaration. Why is > ObjCInterfaceDecl::hasDefinition (indirectly called by getPrimaryContext) > not loading the definition in this case? > In the testing case, we have a definition of the ObjC interface from textually including a header file, but the definition is also in a module. getPrimaryContext for ObjCInterface currently does not pull from the external source. Since getPrimaryContext does not guarantee to pull from the external source, I thought that is why we call getMostRecentDecl in DeclContext::lookup. Are you suggesting to pull from external source in getPrimaryContext? Cheers, Manman > >> + >>if (hasExternalVisibleStorage()) { >> assert(Source && "external visible storage but no external source?"); >> >> >> Added: cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/I >> nputs/lookup-assert/Base.h?rev=280728&view=auto >> >> == >> --- cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h (added) >> +++ cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h Tue Sep 6 >> 13:16:54 2016 >> @@ -0,0 +1,4 @@ >> +@interface BaseInterface >> +- (void) test; >> +@end >> + >> >> Added: cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/I >> nputs/lookup-assert/Derive.h?rev=280728&view=auto >> >> == >> --- cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h (added) >> +++ cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h Tue Sep 6 >> 13:16:54 2016 >> @@ -0,0 +1,3 @@ >> +#include "Base.h" >> +@interface DerivedInterface : BaseInterface >> +@end >> >> Added: cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/I >> nputs/lookup-assert/H3.h?rev=280728&view=auto >> >> == >> --- cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h (added) >> +++ cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h Tue Sep 6 13:16:54 >> 2016 >> @@ -0,0 +1 @@ >> +#include "Base.h" >> >> Added: cfe/trunk/test/Modules/Inputs/lookup-assert/module.map >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/I >> nputs/lookup-assert/module.map?rev=280728&view=auto >> >> == >> --- cfe/trunk/test/Mod
[clang-tools-extra] r280844 - Fix a few oversights in the clang-tidy VS plugin.
Author: zturner Date: Wed Sep 7 14:41:19 2016 New Revision: 280844 URL: http://llvm.org/viewvc/llvm-project?rev=280844&view=rev Log: Fix a few oversights in the clang-tidy VS plugin. Over-zealous cleanup of using statements removed some that were actually needed. Also cleaned up a few warnings. Modified: clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/CheckDatabase.cs clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/CheckTree.cs clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/ClangTidyProperties.cs clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/ClangTidyPropertyGrid.cs Modified: clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/CheckDatabase.cs URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/CheckDatabase.cs?rev=280844&r1=280843&r2=280844&view=diff == --- clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/CheckDatabase.cs (original) +++ clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/CheckDatabase.cs Wed Sep 7 14:41:19 2016 @@ -50,7 +50,7 @@ namespace LLVM.ClangTidy foreach (var Check in Checks_) { if (Names.Contains(Check.Name)) -throw new ArgumentException(String.Format("Check {0} exists more than once!", Check.Name)); +continue; Names.Add(Check.Name); } } Modified: clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/CheckTree.cs URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/CheckTree.cs?rev=280844&r1=280843&r2=280844&view=diff == --- clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/CheckTree.cs (original) +++ clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/CheckTree.cs Wed Sep 7 14:41:19 2016 @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Linq; using System.Text; namespace LLVM.ClangTidy Modified: clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/ClangTidyProperties.cs URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/ClangTidyProperties.cs?rev=280844&r1=280843&r2=280844&view=diff == --- clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/ClangTidyProperties.cs (original) +++ clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/ClangTidyProperties.cs Wed Sep 7 14:41:19 2016 @@ -40,7 +40,6 @@ namespace LLVM.ClangTidy static ClangTidyProperties() { RootProperties_ = new ClangTidyProperties(null); -PropertyDescriptor D; } public static ClangTidyProperties RootProperties Modified: clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/ClangTidyPropertyGrid.cs URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/ClangTidyPropertyGrid.cs?rev=280844&r1=280843&r2=280844&view=diff == --- clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/ClangTidyPropertyGrid.cs (original) +++ clang-tools-extra/trunk/clang-tidy-vs/ClangTidy/ClangTidyPropertyGrid.cs Wed Sep 7 14:41:19 2016 @@ -42,13 +42,6 @@ namespace LLVM.ClangTidy /// List> PropertyChain_ = null; -/// -/// A tree representing all the checks that the extension knows about, used -/// when serializing a file to intelligently determine when to use wildcard -/// include / exclude rules. -/// -CheckTree Checks_; - public ClangTidyPropertyGrid() { InitializeComponent(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r280845 - Add a few more test for []-style uuid attributes.
Author: nico Date: Wed Sep 7 14:41:35 2016 New Revision: 280845 URL: http://llvm.org/viewvc/llvm-project?rev=280845&view=rev Log: Add a few more test for []-style uuid attributes. - Should diag on a function (clang-cl warns; it's an error in cl) - Test the attribute on nested classes (clang-cl is more permissive and more self-consistent than cl here) Modified: cfe/trunk/test/Parser/ms-square-bracket-attributes.mm Modified: cfe/trunk/test/Parser/ms-square-bracket-attributes.mm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/ms-square-bracket-attributes.mm?rev=280845&r1=280844&r2=280845&view=diff == --- cfe/trunk/test/Parser/ms-square-bracket-attributes.mm (original) +++ cfe/trunk/test/Parser/ms-square-bracket-attributes.mm Wed Sep 7 14:41:35 2016 @@ -94,6 +94,23 @@ struct struct_with_uuid2_trigraph; // expected-error@+1 {{uuid attribute contains a malformed GUID}} [uuid(0ZA0---C000-0049)] struct struct_with_uuid2; +struct OuterClass { + // [] uuids and inner classes are weird in cl.exe: It warns that uuid on + // nested types has undefined behavior, and errors out __uuidof() claiming + // that the inner type has no assigned uuid. Things work fine if __declspec() + // is used instead. clang-cl handles this fine. + [uuid(1000----)] class InnerClass1; + [uuid(1000----)] class InnerClass2 {} ic; + [uuid(1000----)] static class InnerClass3 {} sic; + // Putting `static` in front of [...] causes parse errors in both cl and clang + + // This is the only syntax to declare an inner class with []-style attributes + // that works in cl: Declare the inner class without an attribute, and then + // have the []-style attribute on the definition. + class InnerClass; +}; +[uuid(1000----)] class OuterClass::InnerClass {}; + void use_it() { (void)__uuidof(struct_with_uuid); (void)__uuidof(struct_with_uuid_brace); @@ -107,7 +124,17 @@ void use_it() { (void)__uuidof(struct_with_uuid2_macro); (void)__uuidof(struct_with_uuid2_macro_part); (void)__uuidof(struct_with_uuid2_trigraph); + + (void)__uuidof(OuterClass::InnerClass); + (void)__uuidof(OuterClass::InnerClass1); + (void)__uuidof(OuterClass::InnerClass2); + (void)__uuidof(OuterClass::InnerClass3); + (void)__uuidof(OuterClass().ic); + (void)__uuidof(OuterClass::sic); } + +// expected-warning@+1 {{'uuid' attribute only applies to classes}} +[uuid("00A0---C000-0049")] void f(); } // clang supports these on toplevel decls, but not on local decls since this ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24311: Implement MS _rot intrinsics
agutowski created this revision. agutowski added reviewers: rnk, thakis, Prazek, compnerd. agutowski added a subscriber: cfe-commits. https://reviews.llvm.org/D24311 Files: include/clang/Basic/Builtins.def lib/CodeGen/CGBuiltin.cpp lib/Headers/intrin.h test/CodeGen/ms-intrinsics-rotations.c Index: lib/Headers/intrin.h === --- lib/Headers/intrin.h +++ lib/Headers/intrin.h @@ -447,61 +447,6 @@ return (unsigned __int64)__in1 * (unsigned __int64)__in2; } /**\ -|* Bit Twiddling -\**/ -static __inline__ unsigned char __DEFAULT_FN_ATTRS -_rotl8(unsigned char _Value, unsigned char _Shift) { - _Shift &= 0x7; - return _Shift ? (_Value << _Shift) | (_Value >> (8 - _Shift)) : _Value; -} -static __inline__ unsigned char __DEFAULT_FN_ATTRS -_rotr8(unsigned char _Value, unsigned char _Shift) { - _Shift &= 0x7; - return _Shift ? (_Value >> _Shift) | (_Value << (8 - _Shift)) : _Value; -} -static __inline__ unsigned short __DEFAULT_FN_ATTRS -_rotl16(unsigned short _Value, unsigned char _Shift) { - _Shift &= 0xf; - return _Shift ? (_Value << _Shift) | (_Value >> (16 - _Shift)) : _Value; -} -static __inline__ unsigned short __DEFAULT_FN_ATTRS -_rotr16(unsigned short _Value, unsigned char _Shift) { - _Shift &= 0xf; - return _Shift ? (_Value >> _Shift) | (_Value << (16 - _Shift)) : _Value; -} -static __inline__ unsigned int __DEFAULT_FN_ATTRS -_rotl(unsigned int _Value, int _Shift) { - _Shift &= 0x1f; - return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value; -} -static __inline__ unsigned int __DEFAULT_FN_ATTRS -_rotr(unsigned int _Value, int _Shift) { - _Shift &= 0x1f; - return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value; -} -static __inline__ unsigned long __DEFAULT_FN_ATTRS -_lrotl(unsigned long _Value, int _Shift) { - _Shift &= 0x1f; - return _Shift ? (_Value << _Shift) | (_Value >> (32 - _Shift)) : _Value; -} -static __inline__ unsigned long __DEFAULT_FN_ATTRS -_lrotr(unsigned long _Value, int _Shift) { - _Shift &= 0x1f; - return _Shift ? (_Value >> _Shift) | (_Value << (32 - _Shift)) : _Value; -} -static -__inline__ unsigned __int64 __DEFAULT_FN_ATTRS -_rotl64(unsigned __int64 _Value, int _Shift) { - _Shift &= 0x3f; - return _Shift ? (_Value << _Shift) | (_Value >> (64 - _Shift)) : _Value; -} -static -__inline__ unsigned __int64 __DEFAULT_FN_ATTRS -_rotr64(unsigned __int64 _Value, int _Shift) { - _Shift &= 0x3f; - return _Shift ? (_Value >> _Shift) | (_Value << (64 - _Shift)) : _Value; -} -/**\ |* Bit Counting and Testing \**/ static __inline__ unsigned char __DEFAULT_FN_ATTRS Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -696,6 +696,52 @@ "cast"); return RValue::get(Result); } + case Builtin::BI_rotr8: + case Builtin::BI_rotr16: + case Builtin::BI_rotr: + case Builtin::BI_lrotr: + case Builtin::BI_rotr64: { +Value *Val = EmitScalarExpr(E->getArg(0)); +Value *Shift = EmitScalarExpr(E->getArg(1)); + +llvm::Type *ArgType = Val->getType(); +Shift = Builder.CreateIntCast(Shift, ArgType, false); +unsigned ArgWidth = cast(ArgType)->getBitWidth(); +Value *ArgTypeSize = llvm::ConstantInt::get(ArgType, ArgWidth); + +Value *Mask = llvm::ConstantInt::get(ArgType, ArgWidth - 1); +Shift = Builder.CreateAnd(Shift, Mask); +Value *LeftShift = Builder.CreateSub(ArgTypeSize, Shift); + +Value *RightShifted = Builder.CreateLShr(Val, Shift); +Value *LeftShifted = Builder.CreateShl(Val, LeftShift); +Value *Shifted = Builder.CreateOr(LeftShifted, RightShifted); + +return RValue::get(Shifted); + } + case Builtin::BI_rotl8: + case Builtin::BI_rotl16: + case Builtin::BI_rotl: + case Builtin::BI_lrotl: + case Builtin::BI_rotl64: { +Value *Val = EmitScalarExpr(E->getArg(0)); +Value *Shift = EmitScalarExpr(E->getArg(1)); + +llvm::Type *ArgType = Val->getType(); +Shift = Builder.CreateIntCast(Shift, ArgType, false); +unsigned ArgWidth = cast(ArgType)->getBitWidth(); +Value *ArgTypeSize = llvm::ConstantInt::get(ArgType, ArgWidth); + +Value *Mask = llvm::ConstantInt::get(ArgType, ArgWidth - 1); +Shift = Builder.CreateAnd(Shift, Mask); +Value *RightShift = Builder.CreateSub(ArgTypeSize, Shift); + +Value *LeftShifted = Builder.CreateShl(Val, Shift); +Value *RightShifted = Builder.CreateLShr(Val, RightShift); +Value *Shifted = Builder.CreateOr(LeftShifted, RightShifted); + +return RValue::get(Shifted); + } case Builtin::BI__builtin_unpredicta
Re: [PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.
ioeric updated this revision to Diff 70588. ioeric marked 9 inline comments as done. ioeric added a comment. Herald added a subscriber: beanz. - Addressed reviewer comments. https://reviews.llvm.org/D24183 Files: CMakeLists.txt change-namespace/CMakeLists.txt change-namespace/ChangeNamespace.cpp change-namespace/ChangeNamespace.h change-namespace/tool/CMakeLists.txt change-namespace/tool/ClangChangeNamespace.cpp test/CMakeLists.txt test/change-namespace/simple-move.cpp unittests/CMakeLists.txt unittests/change-namespace/CMakeLists.txt unittests/change-namespace/ChangeNamespaceTests.cpp Index: unittests/change-namespace/ChangeNamespaceTests.cpp === --- /dev/null +++ unittests/change-namespace/ChangeNamespaceTests.cpp @@ -0,0 +1,234 @@ +//===-- ChangeNamespaceTests.cpp - Change namespace unit tests ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "ChangeNamespace.h" +#include "unittests/Tooling/RewriterTestContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Basic/FileManager.h" +#include "clang/Basic/FileSystemOptions.h" +#include "clang/Basic/VirtualFileSystem.h" +#include "clang/Format/Format.h" +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Frontend/PCHContainerOperations.h" +#include "clang/Tooling/Refactoring.h" +#include "clang/Tooling/Tooling.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/MemoryBuffer.h" +#include "gtest/gtest.h" +#include +#include +#include + +namespace clang { +namespace change_namespace { +namespace { + +class ChangeNamespaceTest : public ::testing::Test { +public: + std::string runChangeNamespaceOnCode(llvm::StringRef Code) { +clang::RewriterTestContext Context; +clang::FileID ID = Context.createInMemoryFile(FileName, Code); + +std::map FileToReplacements; +change_namespace::ChangeNamespaceTool NamespaceTool( +OldNamespace, NewNamespace, FilePattern, &FileToReplacements); +ast_matchers::MatchFinder Finder; +NamespaceTool.registerMatchers(&Finder); +std::unique_ptr Factory = +tooling::newFrontendActionFactory(&Finder); +tooling::runToolOnCodeWithArgs(Factory->create(), Code, {"-std=c++11"}, + FileName); +formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite); +return format(Context.getRewrittenText(ID)); + } + + std::string format(llvm::StringRef Code) { +tooling::Replacements Replaces = format::reformat( +format::getLLVMStyle(), Code, {tooling::Range(0, Code.size())}); +auto ChangedCode = tooling::applyAllReplacements(Code, Replaces); +EXPECT_TRUE(static_cast(ChangedCode)); +if (!ChangedCode) { + llvm::errs() << llvm::toString(ChangedCode.takeError()); + return ""; +} +return *ChangedCode; + } + +protected: + std::string FileName = "input.cc"; + std::string OldNamespace = "na::nb"; + std::string NewNamespace = "x::y"; + std::string FilePattern = "input.cc"; +}; + +TEST_F(ChangeNamespaceTest, NoMatchingNamespace) { + std::string Code = "namespace na {\n" + "namespace nx {\n" + "class A {};\n" + "} // namespace nx\n" + "} // namespace na\n"; + std::string Expected = "namespace na {\n" + "namespace nx {\n" + "class A {};\n" + "} // namespace nx\n" + "} // namespace na\n"; + EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); +} + +TEST_F(ChangeNamespaceTest, SimpleMoveWithoutTypeRefs) { + std::string Code = "namespace na {\n" + "namespace nb {\n" + "class A {};\n" + "} // namespace nb\n" + "} // namespace na\n"; + std::string Expected = "\n\n" + "namespace x {\n" + "namespace y {\n" + "class A {};\n" + "} // namespace y\n" + "} // namespace x\n"; + EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); +} + +TEST_F(ChangeNamespaceTest, SimpleMoveIntoAnotherNestedNamespace) { + NewNamespace = "na::nc"; + std::string Code = "namespace na {\n" + "namespace nb {\n" + "class A {};\n" + "} // namespace nb\n" + "} // namespace na\n"; + std::string Expected = "namespace na {\n" + "\n" + "namespace nc {\n" + "class A {};\n" + "} // namespace nc\n" +
Re: [PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.
ioeric added inline comments. Comment at: change-namespace/ChangeNamespace.cpp:125 @@ +124,3 @@ +// applying all existing Replaces first if there is conflict. +void addOrMergeReplacement(const tooling::Replacement &R, + tooling::Replacements *Replaces) { alexshap wrote: > khm, this seems to be a recurring pattern (if i'm not mistaken), > looks like the interface of tooling::Replacements can be changed/improved > (although i don't know). > Another (separate) observation is about duplicates. For example for > replacements in headers we can get into if(Err) branch pretty frequently > because the same replacement can be generated multiple times (if that header > is included into several *.cpp files). SGTM. An `addOrMerge()` interface for tooling::Replacements should be helpful. Comment at: change-namespace/ChangeNamespace.cpp:481 @@ +480,3 @@ + continue; +} +FileToReplacements[FilePath] = *CleanReplacements; Added a `FallbackStyle`. Comment at: change-namespace/tool/ClangChangeNamespace.cpp:105 @@ +104,3 @@ +outs() << "== " << File << " ==\n"; +Rewrite.getEditBuffer(ID).write(llvm::outs()); +outs() << "\n\n"; I'd like to keep this for now for better readability. Will change the format in the future if necessary. https://reviews.llvm.org/D24183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r280847 - [Sema] Compare bad conversions in overload resolution.
Author: gbiv Date: Wed Sep 7 15:03:19 2016 New Revision: 280847 URL: http://llvm.org/viewvc/llvm-project?rev=280847&view=rev Log: [Sema] Compare bad conversions in overload resolution. r280553 introduced an issue where we'd emit ambiguity errors for code like: ``` void foo(int *, int); void foo(unsigned int *, unsigned int); void callFoo() { unsigned int i; foo(&i, 0); // ambiguous: int->unsigned int is worse than int->int, // but unsigned int*->unsigned int* is better than // int*->int*. } ``` This patch fixes this issue by changing how we handle ill-formed (but valid) implicit conversions. Candidates with said conversions now always rank worse than candidates without them, and two candidates are considered to be equally bad if they both have these conversions for the same argument. Additionally, this fixes a case in C++11 where we'd complain about an ambiguity in a case like: ``` void f(char *, int); void f(const char *, unsigned); void g() { f("abc", 0); } ``` ...Since conversion to char* from a string literal is considered ill-formed in C++11 (and deprecated in C++03), but we accept it as an extension. Modified: cfe/trunk/include/clang/Basic/AttrDocs.td cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/CodeGen/overloadable.c cfe/trunk/test/SemaCXX/overload-call.cpp Modified: cfe/trunk/include/clang/Basic/AttrDocs.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=280847&r1=280846&r2=280847&view=diff == --- cfe/trunk/include/clang/Basic/AttrDocs.td (original) +++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Sep 7 15:03:19 2016 @@ -470,10 +470,11 @@ semantics: * A conversion from type ``T`` to a value of type ``U`` is permitted if ``T`` and ``U`` are compatible types. This conversion is given "conversion" rank. -* A conversion from a pointer of type ``T*`` to a pointer of type ``U*``, where - ``T`` and ``U`` are incompatible, is allowed, but is ranked below all other - types of conversions. Please note: ``U`` lacking qualifiers that are present - on ``T`` is sufficient for ``T`` and ``U`` to be incompatible. +* If no viable candidates are otherwise available, we allow a conversion from a + pointer of type ``T*`` to a pointer of type ``U*``, where ``T`` and ``U`` are + incompatible. This conversion is ranked below all other types of conversions. + Please note: ``U`` lacking qualifiers that are present on ``T`` is sufficient + for ``T`` and ``U`` to be incompatible. The declaration of ``overloadable`` functions is restricted to function declarations and definitions. Most importantly, if any function with a given Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=280847&r1=280846&r2=280847&view=diff == --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Sep 7 15:03:19 2016 @@ -8600,13 +8600,40 @@ bool clang::isBetterOverloadCandidate(Se if (Cand1.IgnoreObjectArgument || Cand2.IgnoreObjectArgument) StartArg = 1; + auto IsIllFormedConversion = [&](const ImplicitConversionSequence &ICS) { +// We don't allow incompatible pointer conversions in C++. +if (!S.getLangOpts().CPlusPlus) + return ICS.isStandard() && + ICS.Standard.Second == ICK_Incompatible_Pointer_Conversion; + +// The only ill-formed conversion we allow in C++ is the string literal to +// char* conversion, which is only considered ill-formed after C++11. +return S.getLangOpts().CPlusPlus11 && !S.getLangOpts().WritableStrings && + hasDeprecatedStringLiteralToCharPtrConversion(ICS); + }; + + // Define functions that don't require ill-formed conversions for a given + // argument to be better candidates than functions that do. + unsigned NumArgs = Cand1.NumConversions; + assert(Cand2.NumConversions == NumArgs && "Overload candidate mismatch"); + bool HasBetterConversion = false; + for (unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) { +bool Cand1Bad = IsIllFormedConversion(Cand1.Conversions[ArgIdx]); +bool Cand2Bad = IsIllFormedConversion(Cand2.Conversions[ArgIdx]); +if (Cand1Bad != Cand2Bad) { + if (Cand1Bad) +return false; + HasBetterConversion = true; +} + } + + if (HasBetterConversion) +return true; + // C++ [over.match.best]p1: // A viable function F1 is defined to be a better function than another // viable function F2 if for all arguments i, ICSi(F1) is not a worse // conversion sequence than ICSi(F2), and then... - unsigned NumArgs = Cand1.NumConversions; - assert(Cand2.NumConversions == NumArgs && "Overload candidate mismatch"); - bool HasBetterConversion = false; for (unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx
[PATCH] D24312: [CodeGen] Fix an assert in EmitNullConstant
ahatanak created this revision. ahatanak added a reviewer: rjmccall. ahatanak added a subscriber: cfe-commits. r235815 changed CGRecordLowering::accumulateBases to ignore non-virtual bases of size 0, which prevented adding those non-virtual bases to CGRecordLayout's NonVirtualBases. EmitNullConstant calls CGRecordLayout::getNonVirtualBaseLLVMFieldNo to get the field number of the base, which causes an assert. This patch fixes the bug. https://reviews.llvm.org/D24312 Files: lib/CodeGen/CGExprConstant.cpp test/CodeGenCXX/empty-classes.cpp Index: test/CodeGenCXX/empty-classes.cpp === --- test/CodeGenCXX/empty-classes.cpp +++ test/CodeGenCXX/empty-classes.cpp @@ -96,3 +96,24 @@ // Type checked at the top of the file. B b; }; + +// This test used to crash when CGRecordLayout::getNonVirtualBaseLLVMFieldNo was called. +namespace record_layout { +struct X0 { + int x[0]; +}; + +template +struct X2 : X0 { +}; + +template +struct X3 : X2 { + X3() : X2() {} +}; + + +void test0() { + X3(); +} +} Index: lib/CodeGen/CGExprConstant.cpp === --- lib/CodeGen/CGExprConstant.cpp +++ lib/CodeGen/CGExprConstant.cpp @@ -1532,7 +1532,8 @@ cast(I.getType()->castAs()->getDecl()); // Ignore empty bases. -if (base->isEmpty()) +if (base->isEmpty() || +CGM.getContext().getASTRecordLayout(base).getNonVirtualSize().isZero()) continue; unsigned fieldIndex = layout.getNonVirtualBaseLLVMFieldNo(base); Index: test/CodeGenCXX/empty-classes.cpp === --- test/CodeGenCXX/empty-classes.cpp +++ test/CodeGenCXX/empty-classes.cpp @@ -96,3 +96,24 @@ // Type checked at the top of the file. B b; }; + +// This test used to crash when CGRecordLayout::getNonVirtualBaseLLVMFieldNo was called. +namespace record_layout { +struct X0 { + int x[0]; +}; + +template +struct X2 : X0 { +}; + +template +struct X3 : X2 { + X3() : X2() {} +}; + + +void test0() { + X3(); +} +} Index: lib/CodeGen/CGExprConstant.cpp === --- lib/CodeGen/CGExprConstant.cpp +++ lib/CodeGen/CGExprConstant.cpp @@ -1532,7 +1532,8 @@ cast(I.getType()->castAs()->getDecl()); // Ignore empty bases. -if (base->isEmpty()) +if (base->isEmpty() || +CGM.getContext().getASTRecordLayout(base).getNonVirtualSize().isZero()) continue; unsigned fieldIndex = layout.getNonVirtualBaseLLVMFieldNo(base); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24113: Allow implicit conversions between incompatible pointer types in overload resolution in C.
Fix committed as r280847 -- thanks for the reports! > It seems to me that we could handle this by ranking viable-but-ill-formed conversion sequences before non-viable ones in clang::isBetterOverloadCandidate That's what I was thinking, too. :) > Clang reports an ambiguity on line 3 TIL. Woohoo for extensions! r280847 should fix this, as well. On Wed, Sep 7, 2016 at 11:08 AM, Richard Smith wrote: > On Tue, Sep 6, 2016 at 10:55 PM, George Burgess IV < > george.burgess...@gmail.com> wrote: > >> george.burgess.iv added a comment. >> >> > Although I think that users will expect atomic_add(unsigned int *, 5) >> to work.without error >> >> >> Totally agree; I was just making sure that I understood the problem. :) >> >> I think, with a small tweak in semantics, we can make everything work >> without needing to patch existing code. Let me play around a little. > > > It seems to me that we could handle this by ranking viable-but-ill-formed > conversion sequences before non-viable ones in > clang::isBetterOverloadCandidate. This problem is actually more general > than __attribute__((overloadable)) in C -- there is one form of ill-formed > implicit conversion sequence that we accept in C++ that leads to the same > problem: > > void f(char*, int); > void f(const char*, unsigned); > void g() { f("foo", 0); } > > Clang reports an ambiguity on line 3, but in C++11 onwards this code is > valid because there is no implicit conversion sequence from a string > literal to char*. (We provide one as an extension, and it's ranked worse > than any other conversion.) > > >> Repository: >> rL LLVM >> >> https://reviews.llvm.org/D24113 >> >> >> >> > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r280852 - Move CHECK right before the function it describes.
Author: gbiv Date: Wed Sep 7 15:15:03 2016 New Revision: 280852 URL: http://llvm.org/viewvc/llvm-project?rev=280852&view=rev Log: Move CHECK right before the function it describes. Modified: cfe/trunk/test/CodeGen/overloadable.c Modified: cfe/trunk/test/CodeGen/overloadable.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/overloadable.c?rev=280852&r1=280851&r2=280852&view=diff == --- cfe/trunk/test/CodeGen/overloadable.c (original) +++ cfe/trunk/test/CodeGen/overloadable.c Wed Sep 7 15:15:03 2016 @@ -75,11 +75,11 @@ void bar() { ovl_bar(ucharbuf); } -// CHECK-LABEL: define void @baz void ovl_baz(int *, int) __attribute__((overloadable)); void ovl_baz(unsigned int *, unsigned int) __attribute__((overloadable)); void ovl_baz2(int, int *) __attribute__((overloadable)); void ovl_baz2(unsigned int, unsigned int *) __attribute__((overloadable)); +// CHECK-LABEL: define void @baz void baz() { unsigned int j; // Initial rules for incompatible pointer conversions made this overload ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24243: [clang-move] A prototype tool for moving class definition to new file.
ioeric added inline comments. Comment at: clang-move/ClangMove.cpp:103 @@ +102,3 @@ + const clang::SourceManager *SM) { + // Gets the ending ";". + auto EndLoc = clang::Lexer::getLocForEndOfToken(D->getLocEnd(), 0, *SM, hokein wrote: > ioeric wrote: > > Consider the code below to also include trailing comment. > > clang::SourceLocation after_semi = clang::Lexer::findLocationAfterToken( > > D->getLocEnd, clang::tok::semi, *SM, > > result.Context->getLangOpts(), > > /*SkipTrailingWhitespaceAndNewLine=*/true); > > > But this code could not handle cases where the declaration definition has no > semi at the end, such as "void f() {}" Please see the comment for `findLocationAfterToken`. > If the token is not found or the location is inside a macro, the returned > source location will be invalid. Comment at: clang-move/ClangMove.cpp:129 @@ +128,3 @@ + for (const auto &MovedDecl : Decls) { +std::vector DeclNamespaces = GetNamespaces(MovedDecl.Decl); +auto CurrentIt = CurrentNamespaces.begin(); hokein wrote: > ioeric wrote: > > Is it possible to restrict all `MovedDecl.Decl` to NamedDecl so that we can > > use `getQualifiedNameAsString` instead of having a second implementation of > > retrieving namespaces. > > > > Also how is anonymous namespace handled here? > > > > > Yeah, `getQualifiedNameAsString` looks like a simpler way, but it doesn't > suitable for our usage here. > > The `getQualifiedNameAsString` includes the name of the class. For instance, > a class method decl like `void A::f() {}` defined in global namespace, it > retruns `A::f` which is not intended. > > It handles anonymous namespace by wrapping like `namespace { ... } // > namespace`, see the test. > I think it should be relatively easy to split the qualified name returned by `getQualifiedNameAsString `. > It handles anonymous namespace by wrapping like namespace { ... } // > namespace, see the test. I mean...wouldn't `getNamespaces` return something like "a::(anonymous)" for anonymous namespace? How do you handle this? Comment at: clang-move/ClangMove.h:39 @@ +38,3 @@ + struct MoveDefinitionSpec { +std::string Name; +std::string OldHeader; hokein wrote: > ioeric wrote: > > Should the `Name` be fully qualified? > It's not required. The name can be fully/partially qualified, e.g., > `::a::b::X`, `a::b::X`, `b::X`, `X`, which has the same behavior with > `hasName` ast matcher. > > It the given name is partially qualified, it will match all the class whose > name ends with the given name. > It the given name is partially qualified, it will match all the class whose > name ends with the given name. In this case, all matched classes will be moved right? Might want to mention this in the comment. Comment at: clang-move/ClangMove.h:65 @@ +64,3 @@ + + const MoveDefinitionSpec &Spec; + // The Key is file path, value is the replacements being applied to the file. hokein wrote: > ioeric wrote: > > Is there any reason why you made this a reference? > To avoid the cost of making a copy of the structure. If the copy is not that expensive, I'd just make a copy so that I don't need to worry about the life-cycle of `Spec`. https://reviews.llvm.org/D24243 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24307: calculate extent size for memory regions allocated by C++ new expression
zaks.anna added inline comments. Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1003 @@ +1002,3 @@ +// +ProgramStateRef MallocChecker::addExtentSize(CheckerContext &C, + const CXXNewExpr *NE, I am not sure this code belongs to the malloc checker since it only supports the array bounds checker. Is there a reason it's not part of that checker? https://reviews.llvm.org/D24307 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24311: Implement MS _rot intrinsics
rnk added inline comments. Comment at: lib/CodeGen/CGBuiltin.cpp:740 @@ +739,3 @@ +Value *LeftShifted = Builder.CreateShl(Val, Shift); +Value *RightShifted = Builder.CreateLShr(Val, RightShift); +Value *Shifted = Builder.CreateOr(LeftShifted, RightShifted); I don't think this is correct when rotating by zero. That will cause us to shift right by ArgTypeSize, which will result in an undefined value: http://llvm.org/docs/LangRef.html#lshr-instruction I think we need to generate a select or conditional branch as in the original code. Comment at: test/CodeGen/ms-intrinsics-rotations.c:138 @@ +137,3 @@ + +// CHECK-64BIT-LONG: i64 @test_lrotr +// CHECK-64BIT-LONG: [[SHIFT:%[0-9]+]] = and i64 %shift, 63 Nice, testing both LP64 and LLP64. :) https://reviews.llvm.org/D24311 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24311: Implement MS _rot intrinsics
rnk added a comment. You should locally verify that this generates the correct assembly when optimizations are enabled, and if it doesn't, try to make the input look more like llvm/test/CodeGen/X86/rotate.ll Comment at: test/CodeGen/ms-intrinsics-rotations.c:2 @@ +1,3 @@ +// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \ +// RUN: -triple i686--windows -Oz -emit-llvm %s -o - \ +// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG Can we run without -Oz? The test should still pass. https://reviews.llvm.org/D24311 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation
EricWF added inline comments. Comment at: src/cxa_thread_atexit.cpp:70 @@ +69,3 @@ +while (auto head = dtors) { + dtors = head->next; + head->dtor(head->obj); tavianator wrote: > EricWF wrote: > > There is a bug here. If `head->next == nullptr` and if > > `head->dtor(head->obj))` creates a TL variable in the destructor then that > > destructor will not be invoked. > > > > Here's an updated test case which catches the bug: > > https://gist.github.com/EricWF/3bb50d4f28b91aa28d2adefea0e94a0e > I can't reproduce that failure here, your exact test case passes (even with > `#undef HAVE___CXA_THREAD_ATEXIT_IMPL` and the weak symbol test commented > out). > > Tracing the implementation logic, it seems correct. If `head->next == > nullptr` then this line does `dtors = nullptr`. Then if > `head->dtor(head->obj)` registers a new `thread_local`, > `__cxa_thread_atexit()` does `head = malloc(...); ... dtors = head;`. Then > the next iteration of the loop `while (auto head = dtors) {` picks up that > new node. > > Have I missed something? I can't reproduce this morning either, I must have been doing something funny. I'll look at this with a fresh head tomorrow. If I can't find anything this will be good to go. Thanks for working on this. https://reviews.llvm.org/D21803 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24307: calculate extent size for memory regions allocated by C++ new expression
xazax.hun added inline comments. Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1003 @@ +1002,3 @@ +// +ProgramStateRef MallocChecker::addExtentSize(CheckerContext &C, + const CXXNewExpr *NE, zaks.anna wrote: > I am not sure this code belongs to the malloc checker since it only supports > the array bounds checker. Is there a reason it's not part of that checker? I think it is part of the malloc checker because it already does something very very similar to malloc, see the MallocMemAux function. So in fact, for the array bounds checker to work properly, the malloc checker should be turned on. https://reviews.llvm.org/D24307 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24314: [libc++] Clean up MSVC support
smeenai created this revision. smeenai added reviewers: compnerd, EricWF, mclow.lists. smeenai added a subscriber: cfe-commits. Visual Studio 2013 (CRT version 12) added support for many C99 long long and long double functions. Visual Studio 2015 (CRT version 14) increased C99 and C11 compliance further. Since we don't support Visual Studio versions older than 2013, we can considerably clean up the support header. https://reviews.llvm.org/D24314 Files: include/support/win32/support.h Index: include/support/win32/support.h === --- include/support/win32/support.h +++ include/support/win32/support.h @@ -22,7 +22,7 @@ #include #endif #if defined(_LIBCPP_MSVCRT) -#include +#include #endif #define swprintf _snwprintf #define vswprintf _vsnwprintf @@ -45,27 +45,11 @@ #endif // __MINGW32__ #if defined(_LIBCPP_MSVCRT) +#if _VC_CRT_MAJOR_VERSION < 14 #define snprintf _snprintf -#define atoll _atoi64 -#define strtoll _strtoi64 -#define strtoull _strtoui64 -#define wcstoll _wcstoi64 -#define wcstoull _wcstoui64 -_LIBCPP_ALWAYS_INLINE float strtof(const char *nptr, char **endptr) -{ - return _Stof(nptr, endptr, 0); -} -_LIBCPP_ALWAYS_INLINE double strtod(const char *nptr, char **endptr) -{ - return _Stod(nptr, endptr, 0); -} -_LIBCPP_ALWAYS_INLINE long double strtold(const char *nptr, char **endptr) -{ - return _Stold(nptr, endptr, 0); -} - #define _Exit _exit #endif +#endif #if defined(_LIBCPP_MSVC) Index: include/support/win32/support.h === --- include/support/win32/support.h +++ include/support/win32/support.h @@ -22,7 +22,7 @@ #include #endif #if defined(_LIBCPP_MSVCRT) -#include +#include #endif #define swprintf _snwprintf #define vswprintf _vsnwprintf @@ -45,27 +45,11 @@ #endif // __MINGW32__ #if defined(_LIBCPP_MSVCRT) +#if _VC_CRT_MAJOR_VERSION < 14 #define snprintf _snprintf -#define atoll _atoi64 -#define strtoll _strtoi64 -#define strtoull _strtoui64 -#define wcstoll _wcstoi64 -#define wcstoull _wcstoui64 -_LIBCPP_ALWAYS_INLINE float strtof(const char *nptr, char **endptr) -{ - return _Stof(nptr, endptr, 0); -} -_LIBCPP_ALWAYS_INLINE double strtod(const char *nptr, char **endptr) -{ - return _Stod(nptr, endptr, 0); -} -_LIBCPP_ALWAYS_INLINE long double strtold(const char *nptr, char **endptr) -{ - return _Stold(nptr, endptr, 0); -} - #define _Exit _exit #endif +#endif #if defined(_LIBCPP_MSVC) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24314: [libc++] Clean up MSVC support
EricWF added a comment. This LGTM but I'll let @compnerd give it the final OK, since I've never built libc++ on windows. Comment at: include/support/win32/support.h:48 @@ -47,2 +47,3 @@ #if defined(_LIBCPP_MSVCRT) +#if _VC_CRT_MAJOR_VERSION < 14 #define snprintf _snprintf Maybe fold these to `#if`'s into `#if defined(_VC_CRT_MAJOR_VERSION) && _VC_CRT_MAJOR_VERSION < 14`. https://reviews.llvm.org/D24314 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24314: [libc++] Clean up MSVC support
smeenai added inline comments. Comment at: include/support/win32/support.h:48 @@ -47,2 +47,3 @@ #if defined(_LIBCPP_MSVCRT) +#if _VC_CRT_MAJOR_VERSION < 14 #define snprintf _snprintf EricWF wrote: > Maybe fold these to `#if`'s into `#if defined(_VC_CRT_MAJOR_VERSION) && > _VC_CRT_MAJOR_VERSION < 14`. Good idea. https://reviews.llvm.org/D24314 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24314: [libc++] Clean up MSVC support
smeenai updated this revision to Diff 70598. smeenai added a comment. Simpliying conditional per EricWF's suggestion https://reviews.llvm.org/D24314 Files: include/support/win32/support.h Index: include/support/win32/support.h === --- include/support/win32/support.h +++ include/support/win32/support.h @@ -22,7 +22,7 @@ #include #endif #if defined(_LIBCPP_MSVCRT) -#include +#include #endif #define swprintf _snwprintf #define vswprintf _vsnwprintf @@ -44,26 +44,8 @@ } #endif // __MINGW32__ -#if defined(_LIBCPP_MSVCRT) +#if defined(_VC_CRT_MAJOR_VERSION) && _VC_CRT_MAJOR_VERSION < 14 #define snprintf _snprintf -#define atoll _atoi64 -#define strtoll _strtoi64 -#define strtoull _strtoui64 -#define wcstoll _wcstoi64 -#define wcstoull _wcstoui64 -_LIBCPP_ALWAYS_INLINE float strtof(const char *nptr, char **endptr) -{ - return _Stof(nptr, endptr, 0); -} -_LIBCPP_ALWAYS_INLINE double strtod(const char *nptr, char **endptr) -{ - return _Stod(nptr, endptr, 0); -} -_LIBCPP_ALWAYS_INLINE long double strtold(const char *nptr, char **endptr) -{ - return _Stold(nptr, endptr, 0); -} - #define _Exit _exit #endif Index: include/support/win32/support.h === --- include/support/win32/support.h +++ include/support/win32/support.h @@ -22,7 +22,7 @@ #include #endif #if defined(_LIBCPP_MSVCRT) -#include +#include #endif #define swprintf _snwprintf #define vswprintf _vsnwprintf @@ -44,26 +44,8 @@ } #endif // __MINGW32__ -#if defined(_LIBCPP_MSVCRT) +#if defined(_VC_CRT_MAJOR_VERSION) && _VC_CRT_MAJOR_VERSION < 14 #define snprintf _snprintf -#define atoll _atoi64 -#define strtoll _strtoi64 -#define strtoull _strtoui64 -#define wcstoll _wcstoi64 -#define wcstoull _wcstoui64 -_LIBCPP_ALWAYS_INLINE float strtof(const char *nptr, char **endptr) -{ - return _Stof(nptr, endptr, 0); -} -_LIBCPP_ALWAYS_INLINE double strtod(const char *nptr, char **endptr) -{ - return _Stod(nptr, endptr, 0); -} -_LIBCPP_ALWAYS_INLINE long double strtold(const char *nptr, char **endptr) -{ - return _Stold(nptr, endptr, 0); -} - #define _Exit _exit #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24314: [libc++] Clean up MSVC support
smeenai marked 2 inline comments as done. smeenai added a comment. https://reviews.llvm.org/D24314 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r280870 - Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes.
Author: eugenezelenko Date: Wed Sep 7 16:53:17 2016 New Revision: 280870 URL: http://llvm.org/viewvc/llvm-project?rev=280870&view=rev Log: Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes. Differential revision: https://reviews.llvm.org/D24115 Modified: cfe/trunk/lib/Lex/Lexer.cpp cfe/trunk/lib/Lex/LiteralSupport.cpp cfe/trunk/lib/Lex/PPDirectives.cpp cfe/trunk/lib/Lex/PPExpressions.cpp cfe/trunk/lib/Lex/PPMacroExpansion.cpp cfe/trunk/lib/Lex/Pragma.cpp cfe/trunk/lib/Lex/Preprocessor.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp Modified: cfe/trunk/lib/Lex/Lexer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=280870&r1=280869&r2=280870&view=diff == --- cfe/trunk/lib/Lex/Lexer.cpp (original) +++ cfe/trunk/lib/Lex/Lexer.cpp Wed Sep 7 16:53:17 2016 @@ -14,18 +14,27 @@ #include "clang/Lex/Lexer.h" #include "UnicodeCharSets.h" #include "clang/Basic/CharInfo.h" +#include "clang/Basic/IdentifierTable.h" #include "clang/Basic/SourceManager.h" -#include "clang/Lex/CodeCompletionHandler.h" #include "clang/Lex/LexDiagnostic.h" #include "clang/Lex/LiteralSupport.h" #include "clang/Lex/Preprocessor.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ConvertUTF.h" +#include "llvm/Support/MathExtras.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/UnicodeCharRanges.h" +#include +#include +#include +#include #include +#include +#include +#include + using namespace clang; //===--===// @@ -45,7 +54,6 @@ tok::ObjCKeywordKind Token::getObjCKeywo return specId ? specId->getObjCKeywordID() : tok::objc_not_keyword; } - //===--===// // Lexer Class Implementation //===--===// @@ -196,7 +204,6 @@ Lexer *Lexer::Create_PragmaLexer(SourceL return L; } - /// Stringify - Convert the specified string into a C string, with surrounding /// ""'s, and with escaped \ and " characters. std::string Lexer::Stringify(StringRef Str, bool Charify) { @@ -398,7 +405,6 @@ unsigned Lexer::getSpelling(const Token return getSpellingSlow(Tok, TokStart, LangOpts, const_cast(Buffer)); } - /// MeasureTokenLength - Relex the token at the specified location and return /// its length in bytes in the input file. If the token needs cleaning (e.g. /// includes a trigraph or an escaped newline) then this count includes bytes @@ -526,13 +532,15 @@ SourceLocation Lexer::GetBeginningOfToke } namespace { + enum PreambleDirectiveKind { PDK_Skipped, PDK_StartIf, PDK_EndIf, PDK_Unknown }; -} + +} // end anonymous namespace std::pair Lexer::ComputePreamble(StringRef Buffer, const LangOptions &LangOpts, @@ -694,7 +702,6 @@ std::pair Lexer::Compute : TheTok.isAtStartOfLine()); } - /// AdvanceToTokenCharacter - Given a location that specifies the start of a /// token, return a new location that specifies a character within the token. SourceLocation Lexer::AdvanceToTokenCharacter(SourceLocation TokStart, @@ -961,7 +968,7 @@ StringRef Lexer::getImmediateMacroName(S assert(Loc.isMacroID() && "Only reasonble to call this on macros"); // Find the location of the immediate macro expansion. - while (1) { + while (true) { FileID FID = SM.getFileID(Loc); const SrcMgr::SLocEntry *E = &SM.getSLocEntry(FID); const SrcMgr::ExpansionInfo &Expansion = E->getExpansion(); @@ -1031,7 +1038,6 @@ bool Lexer::isIdentifierBodyChar(char c, return isIdentifierBody(c, LangOpts.DollarIdents); } - //===--===// // Diagnostics forwarding code. //===--===// @@ -1157,7 +1163,7 @@ unsigned Lexer::getEscapedNewLineSize(co /// them), skip over them and return the first non-escaped-newline found, /// otherwise return P. const char *Lexer::SkipEscapedNewLines(const char *P) { - while (1) { + while (true) { const char *AfterEscape; if (*P == '\\') { AfterEscape = P+1; @@ -1310,7 +1316,6 @@ Slash: return *Ptr; } - /// getCharAndSizeSlowNoWarn - Handle the slow/uncommon case of the /// getCharAndSizeNoWarn method. Here we know that we can accumulate into Size, /// and that we have already incremented Ptr by Size bytes. @@ -1548,7 +1553,7 @@ FinishIdentifier: // Otherwise, $,\,? in identifier found. Enter slower path. C = getCharAndSize(CurPtr, Size); - while (1) { + while
Re: [PATCH] D24115: [Clang] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes
This revision was automatically updated to reflect the committed changes. Closed by commit rL280870: Fix some Clang-tidy modernize-use-using and Include What You Use warnings… (authored by eugenezelenko). Changed prior to commit: https://reviews.llvm.org/D24115?vs=69937&id=70606#toc Repository: rL LLVM https://reviews.llvm.org/D24115 Files: cfe/trunk/lib/Lex/Lexer.cpp cfe/trunk/lib/Lex/LiteralSupport.cpp cfe/trunk/lib/Lex/PPDirectives.cpp cfe/trunk/lib/Lex/PPExpressions.cpp cfe/trunk/lib/Lex/PPMacroExpansion.cpp cfe/trunk/lib/Lex/Pragma.cpp cfe/trunk/lib/Lex/Preprocessor.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp Index: cfe/trunk/lib/Lex/LiteralSupport.cpp === --- cfe/trunk/lib/Lex/LiteralSupport.cpp +++ cfe/trunk/lib/Lex/LiteralSupport.cpp @@ -14,13 +14,25 @@ #include "clang/Lex/LiteralSupport.h" #include "clang/Basic/CharInfo.h" +#include "clang/Basic/LangOptions.h" +#include "clang/Basic/SourceLocation.h" #include "clang/Basic/TargetInfo.h" #include "clang/Lex/LexDiagnostic.h" +#include "clang/Lex/Lexer.h" #include "clang/Lex/Preprocessor.h" +#include "clang/Lex/Token.h" +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/ErrorHandling.h" +#include +#include +#include +#include +#include +#include using namespace clang; @@ -135,7 +147,7 @@ if (Diags) Diag(Diags, Features, Loc, ThisTokBegin, EscapeBegin, ThisTokBuf, diag::err_hex_escape_no_digits) << "x"; - HadError = 1; + HadError = true; break; } @@ -453,7 +465,6 @@ ResultBuf += bytesToWrite; } - /// integer-constant: [C99 6.4.4.1] /// decimal-constant integer-suffix /// octal-constant integer-suffix @@ -986,7 +997,6 @@ return Result.convertFromString(Str, APFloat::rmNearestTiesToEven); } - /// \verbatim /// user-defined-character-literal: [C++11 lex.ext] /// character-literal ud-suffix Index: cfe/trunk/lib/Lex/Preprocessor.cpp === --- cfe/trunk/lib/Lex/Preprocessor.cpp +++ cfe/trunk/lib/Lex/Preprocessor.cpp @@ -43,15 +43,24 @@ #include "clang/Lex/PreprocessingRecord.h" #include "clang/Lex/PreprocessorOptions.h" #include "clang/Lex/ScratchBuffer.h" -#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallString.h" -#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/Capacity.h" -#include "llvm/Support/ConvertUTF.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include +#include #include +#include + using namespace clang; LLVM_INSTANTIATE_REGISTRY(PragmaHandlerRegistry) @@ -74,11 +83,12 @@ IncrementalProcessing(false), TUKind(TUKind), CodeComplete(nullptr), CodeCompletionFile(nullptr), CodeCompletionOffset(0), LastTokenWasAt(false), ModuleImportExpectsIdentifier(false), - CodeCompletionReached(0), CodeCompletionII(0), MainFileDir(nullptr), - SkipMainFilePreamble(0, true), CurPPLexer(nullptr), CurDirLookup(nullptr), - CurLexerKind(CLK_Lexer), CurSubmodule(nullptr), Callbacks(nullptr), - CurSubmoduleState(&NullSubmoduleState), MacroArgCache(nullptr), - Record(nullptr), MIChainHead(nullptr), DeserialMIChainHead(nullptr) { + CodeCompletionReached(false), CodeCompletionII(nullptr), + MainFileDir(nullptr), SkipMainFilePreamble(0, true), CurPPLexer(nullptr), + CurDirLookup(nullptr), CurLexerKind(CLK_Lexer), CurSubmodule(nullptr), + Callbacks(nullptr), CurSubmoduleState(&NullSubmoduleState), + MacroArgCache(nullptr), Record(nullptr), MIChainHead(nullptr), + DeserialMIChainHead(nullptr) { OwnsHeaderSearch = OwnsHeaders; CounterValue = 0; // __COUNTER__ starts at 0. @@ -490,7 +500,6 @@ // Preprocessor Initialization Methods //===--===// - /// EnterMainSourceFile - Enter the specified FileID as the main source file, /// which implicitly adds the builtin defines etc. void Preprocessor::EnterMainSourceFile() { @@ -758,7 +767,6 @@ LastTokenWasAt = Result.is(tok::at); } - /// \brief Lex a token following the 'import' contextual keyword. /// void Preprocessor::LexAfterModuleImport(Token &Result) { Index: cfe/trunk/lib/Lex/PPMacroExpansion.cpp === --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp @@ -13,23 +13,48 @@ //===
[PATCH] D24319: clang-format: Add a flag to limit git-clang-format's diff to a single commit
lhchavez created this revision. lhchavez added a reviewer: djasper. lhchavez added subscribers: srhines, cfe-commits. lhchavez set the repository for this revision to rL LLVM. lhchavez added a project: clang-c. When building pre-upload hooks using git-clang-format, it is useful to limit the scope to a single commit (instead of from a commit against the working tree) to allow for less false positives in dependent commits. This change adds a flag (--single-commit) to git-clang-format, which uses a different strategy to diff (using git-diff-tree instead of git-diff-index) and create the temporary working tree (using the git hashes of the objects present in the specified commit instead of the ones found in the current working directory). Repository: rL LLVM https://reviews.llvm.org/D24319 Files: cfe/trunk/tools/clang-format/git-clang-format Index: cfe/trunk/tools/clang-format/git-clang-format === --- cfe/trunk/tools/clang-format/git-clang-format +++ cfe/trunk/tools/clang-format/git-clang-format @@ -35,9 +35,9 @@ usage = 'git clang-format [OPTIONS] [] [--] [...]' desc = ''' -Run clang-format on all lines that differ between the working directory -and , which defaults to HEAD. Changes are only applied to the working -directory. +Run clang-format on all lines that differ between the working directory and + (which defaults to HEAD), or all lines that changed in a specific +commit. Changes are only applied to the working directory. The following git-config settings set the default of the corresponding option: clangFormat.binary @@ -90,6 +90,9 @@ p.add_argument('--commit', default=config.get('clangformat.commit', 'HEAD'), help='default commit to use if none is specified'), + p.add_argument('--single-commit', action='store_true', + help=('run clang-format on a single commit instead of against ' + 'the working tree')), p.add_argument('--diff', action='store_true', help='print a diff instead of applying the changes') p.add_argument('--extensions', @@ -121,7 +124,8 @@ del opts.quiet commit, files = interpret_args(opts.args, dash_dash, opts.commit) - changed_lines = compute_diff_and_extract_lines(commit, files) + changed_lines = compute_diff_and_extract_lines(commit, files, + opts.single_commit) if opts.verbose >= 1: ignored_files = set(changed_lines) filter_by_extension(changed_lines, opts.extensions.lower().split(',')) @@ -141,7 +145,10 @@ # The computed diff outputs absolute paths, so we must cd before accessing # those files. cd_to_toplevel() - old_tree = create_tree_from_workdir(changed_lines) + if opts.single_commit: +old_tree = create_tree_from_commit(opts.commit, changed_lines) + else: +old_tree = create_tree_from_workdir(changed_lines) new_tree = run_clang_format_and_save_to_tree(changed_lines, binary=opts.binary, style=opts.style) @@ -242,9 +249,9 @@ return stdout.strip() -def compute_diff_and_extract_lines(commit, files): +def compute_diff_and_extract_lines(commit, files, single_commit): """Calls compute_diff() followed by extract_lines().""" - diff_process = compute_diff(commit, files) + diff_process = compute_diff(commit, files, single_commit) changed_lines = extract_lines(diff_process.stdout) diff_process.stdout.close() diff_process.wait() @@ -254,13 +261,16 @@ return changed_lines -def compute_diff(commit, files): +def compute_diff(commit, files, single_commit): """Return a subprocess object producing the diff from `commit`. The return value's `stdin` file object will produce a patch with the differences between the working directory and `commit`, filtered on `files` (if non-empty). Zero context lines are used in the patch.""" - cmd = ['git', 'diff-index', '-p', '-U0', commit, '--'] + git_tool = 'diff-index' + if single_commit: +git_tool = 'diff-tree' + cmd = ['git', git_tool, '-p', '-U0', commit, '--'] cmd.extend(files) p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) p.stdin.close() @@ -310,6 +320,29 @@ os.chdir(toplevel) +def create_tree_from_commit(commit, filenames): + """Create a new git tree with the given files from `commit`. + + Returns the object ID (SHA-1) of the created tree.""" + def index_info_generator(lines, filenames): +for line in lines: + match = re.match(r'^(\d+) blob ([0-9a-f]+)\t(.*)', line) + if not match: +continue + mode, blob_id, filename = match.groups() + if filename not in filenames: +continue + yield '%s %s\t%s' % (mode, blob_id, filename) + cmd = ['git', 'ls-tree', '-r', commit] + p = subprocess.Popen(cmd, stdout=subprocess.PIPE) + stdout = p.communicate()[0] +
[libclc] r280871 - Avoid ambiguity in calling atom_add functions.
Author: jvesely Date: Wed Sep 7 17:11:02 2016 New Revision: 280871 URL: http://llvm.org/viewvc/llvm-project?rev=280871&view=rev Log: Avoid ambiguity in calling atom_add functions. clang (since r280553) allows pointer casts in function overloads, so we need to disambiguate the second argument. clang might be smarter about overloads in the future see https://reviews.llvm.org/D24113, but let's be safe in libclc anyway. Modified: libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl Modified: libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl?rev=280871&r1=280870&r2=280871&view=diff == --- libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl (original) +++ libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_dec.cl Wed Sep 7 17:11:02 2016 @@ -2,7 +2,7 @@ #define IMPL(TYPE) \ _CLC_OVERLOAD _CLC_DEF TYPE atom_dec(global TYPE *p) { \ - return atom_sub(p, 1); \ + return atom_sub(p, (TYPE)1); \ } IMPL(int) Modified: libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl?rev=280871&r1=280870&r2=280871&view=diff == --- libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl (original) +++ libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_inc.cl Wed Sep 7 17:11:02 2016 @@ -2,7 +2,7 @@ #define IMPL(TYPE) \ _CLC_OVERLOAD _CLC_DEF TYPE atom_inc(global TYPE *p) { \ - return atom_add(p, 1); \ + return atom_add(p, (TYPE)1); \ } IMPL(int) Modified: libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl?rev=280871&r1=280870&r2=280871&view=diff == --- libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl (original) +++ libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_dec.cl Wed Sep 7 17:11:02 2016 @@ -2,7 +2,7 @@ #define IMPL(TYPE) \ _CLC_OVERLOAD _CLC_DEF TYPE atom_dec(local TYPE *p) { \ - return atom_sub(p, 1); \ + return atom_sub(p, (TYPE)1); \ } IMPL(int) Modified: libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl?rev=280871&r1=280870&r2=280871&view=diff == --- libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl (original) +++ libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_inc.cl Wed Sep 7 17:11:02 2016 @@ -2,7 +2,7 @@ #define IMPL(TYPE) \ _CLC_OVERLOAD _CLC_DEF TYPE atom_inc(local TYPE *p) { \ - return atom_add(p, 1); \ + return atom_add(p, (TYPE)1); \ } IMPL(int) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits