[PATCH] D39562: [CodeGen][ObjC] Fix an assertion failure caused by copy elision
rjmccall added inline comments. Comment at: include/clang/AST/Expr.h:875 + /// is set to true. + bool IsUnique = false; + Humor me and pack this in the bitfields in Stmt, please. :) Comment at: include/clang/AST/Expr.h:932 + void setIsUnique() { IsUnique = true; } + bool isUnique() const { return IsUnique; } Can we assert that there's a source expression? Comment at: lib/Sema/SemaPseudoObject.cpp:432 + if (capturedRHS->getType()->getAsCXXRecordDecl() && capturedRHS->isRValue()) +capturedRHS->setIsUnique(); + I think you can unconditionally set this here, actually. You just need to teach the other two exhaustive emitters in IRGen (scalar and complex) to look through unique OVEs. Plenty of other things in IRGen could benefit from being able to peephole through unique OVEs. Also, you can set it on the OVE for the base expression if this is a simple assignment or load. https://reviews.llvm.org/D39562 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39562: [CodeGen][ObjC] Fix an assertion failure caused by copy elision
rjmccall added a comment. Oh, and you need to serialize this bit. https://reviews.llvm.org/D39562 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39342: [Bash-autocompletion] Pass all flags in shell command-line to Clang
teemperor accepted this revision. teemperor added a comment. This revision is now accepted and ready to land. As this will land in clang 7, can you add a note to the release notes that this breaks backwards compatibility for this interface (can be another commit)? Also, we should point out that this is the only API change this interface will have in the foreseeable future. https://reviews.llvm.org/D39342 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43741: [Analyzer] More accurate modeling about the increment operator of the operand with type bool.
MTC updated this revision to Diff 136901. MTC added a comment. - If the operand of the ++ operator is of type `_Bool`, also set to true. - Add test file `_Bool-increment-decement.c`. Repository: rC Clang https://reviews.llvm.org/D43741 Files: include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h lib/StaticAnalyzer/Core/ExprEngineC.cpp test/Analysis/_Bool-increment-decrement.c test/Analysis/bool-increment.cpp Index: test/Analysis/bool-increment.cpp === --- /dev/null +++ test/Analysis/bool-increment.cpp @@ -0,0 +1,84 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -analyzer-store=region -verify -std=c++98 -Wno-deprecated %s +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -analyzer-store=region -verify -std=c++11 -Wno-deprecated %s +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -analyzer-store=region -verify -std=c++14 -Wno-deprecated %s + +extern void clang_analyzer_eval(bool); + +void test_bool_value() { + { +bool b = true; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = false; +clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} + } + + { +bool b = -10; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = 10; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = 10; +b++; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = 0; +b++; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } +} + +void test_bool_increment() { + { +bool b = true; +b++; +clang_analyzer_eval(b); // expected-warning{{TRUE}} + } + + { +bool b = false; +b++; +clang_analyzer_eval(b); // expected-warning{{TRUE}} + } + + { +bool b = true; +++b; +clang_analyzer_eval(b); // expected-warning{{TRUE}} + } + + { +bool b = false; +++b; +clang_analyzer_eval(b); // expected-warning{{TRUE}} + } + + { +bool b = 0; +++b; +clang_analyzer_eval(b); // expected-warning{{TRUE}} + } + + { +bool b = 10; +++b; +++b; +clang_analyzer_eval(b); // expected-warning{{TRUE}} + } + + { +bool b = -10; +++b; +clang_analyzer_eval(b); // expected-warning{{TRUE}} + } +} Index: test/Analysis/_Bool-increment-decrement.c === --- /dev/null +++ test/Analysis/_Bool-increment-decrement.c @@ -0,0 +1,140 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -analyzer-store=region -verify -std=c99 -Dbool=_Bool -Dtrue=1 -Dfalse=0 %s +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -analyzer-store=region -verify -std=c11 -Dbool=_Bool -Dtrue=1 -Dfalse=0 %s +extern void clang_analyzer_eval(bool); + +void test__Bool_value() { + { +bool b = true; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = false; +clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} + } + + { +bool b = -10; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = 10; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = 10; +b++; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = 0; +b++; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } +} + +void test__Bool_increment() { + { +bool b = true; +b++; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = false; +b++; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = true; +++b; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = false; +++b; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = 0; +++b; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = 10; +++b; +++b; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = -10; +++b; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = -1; +++b; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } +} + +void test__Bool_decrement() { + { +bool b = true; +b--; +clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} + } + + { +bool b = false; +b--; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = true; +--b; +clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} + } + + { +bool b = false; +--b; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = 0; +--b; +clang_analyzer_eval(b == 1); // expected-warning{{TRUE}} + } + + { +bool b = 10; +--b; +clang_analyzer_eval(b == 0);
[PATCH] D43741: [Analyzer] More accurate modeling about the increment operator of the operand with type bool.
MTC added a comment. Thank you for your review, @NoQ! - `isBooleanType()` is used to check `_Bool` in C99/C11 and `bool` in C++. For `_Bool` , there is the same overflow problem. - In C++98/C++11/C++14, for `++bool` and `bool+`, both sets true directly. - In C++, `--bool` and `bool--` is illeagal. - In C99/C11 standard, there is not much information about `_Bool++` and `_Bool--`. From the implementation of the compiler, `_Bool++` and `_Bool--` are divided into the following situations. - _Bool b = 0; b++; // b -> 1 - _Bool b = 1; b++; // b -> 1 - _Bool b = 0; b--; // b -> 1 - _Bool b = 1; b--; // b -> 0 So it's reasonable to set to true if the operand of the increment operator is of type _Bool, just my opinion. I not familiar with Objective-C++, can you provide a appropriate test about Objective-C++ for me, thank you! And I'm not a native speaker of English, the grammar of the comments may not be correct. If so, please correct me, thanks! Repository: rC Clang https://reviews.llvm.org/D43741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r326645 - Better OpenBSD frontend support
Author: kamil Date: Sat Mar 3 03:47:27 2018 New Revision: 326645 URL: http://llvm.org/viewvc/llvm-project?rev=326645&view=rev Log: Better OpenBSD frontend support Summary: - Like other *BSD, conditioning certain flags to pass - To prepare future OpenBSD sanitisers. Patch by: David CARLIER Reviewers: dlj, krytarowski, vitalybuka Reviewed By: vitalybuka Subscribers: krytarowski, cfe-commits Differential Revision: https://reviews.llvm.org/D43818 Modified: cfe/trunk/lib/Driver/ToolChain.cpp cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Modified: cfe/trunk/lib/Driver/ToolChain.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=326645&r1=326644&r2=326645&view=diff == --- cfe/trunk/lib/Driver/ToolChain.cpp (original) +++ cfe/trunk/lib/Driver/ToolChain.cpp Sat Mar 3 03:47:27 2018 @@ -329,6 +329,8 @@ StringRef ToolChain::getOSLibName() cons return "freebsd"; case llvm::Triple::NetBSD: return "netbsd"; + case llvm::Triple::OpenBSD: +return "openbsd"; case llvm::Triple::Solaris: return "sunos"; default: Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=326645&r1=326644&r2=326645&view=diff == --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Sat Mar 3 03:47:27 2018 @@ -542,12 +542,14 @@ void tools::linkSanitizerRuntimeDeps(con // There's no libpthread or librt on RTEMS. if (TC.getTriple().getOS() != llvm::Triple::RTEMS) { CmdArgs.push_back("-lpthread"); -CmdArgs.push_back("-lrt"); +if (TC.getTriple().getOS() != llvm::Triple::OpenBSD) + CmdArgs.push_back("-lrt"); } CmdArgs.push_back("-lm"); // There's no libdl on all OSes. if (TC.getTriple().getOS() != llvm::Triple::FreeBSD && TC.getTriple().getOS() != llvm::Triple::NetBSD && + TC.getTriple().getOS() != llvm::Triple::OpenBSD && TC.getTriple().getOS() != llvm::Triple::RTEMS) CmdArgs.push_back("-ldl"); // Required for backtrace on some OSes Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=326645&r1=326644&r2=326645&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Sat Mar 3 03:47:27 2018 @@ -242,11 +242,13 @@ static void linkXRayRuntimeDeps(const To ArgStringList &CmdArgs) { CmdArgs.push_back("--no-as-needed"); CmdArgs.push_back("-lpthread"); - CmdArgs.push_back("-lrt"); + if (TC.getTriple().getOS() != llvm::Triple::OpenBSD) +CmdArgs.push_back("-lrt"); CmdArgs.push_back("-lm"); if (TC.getTriple().getOS() != llvm::Triple::FreeBSD && - TC.getTriple().getOS() != llvm::Triple::NetBSD) + TC.getTriple().getOS() != llvm::Triple::NetBSD && + TC.getTriple().getOS() != llvm::Triple::OpenBSD) CmdArgs.push_back("-ldl"); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43818: Better OpenBSD frontend support
This revision was automatically updated to reflect the committed changes. Closed by commit rL326645: Better OpenBSD frontend support (authored by kamil, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D43818?vs=136804&id=136903#toc Repository: rL LLVM https://reviews.llvm.org/D43818 Files: cfe/trunk/lib/Driver/ToolChain.cpp cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp === --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp @@ -542,12 +542,14 @@ // There's no libpthread or librt on RTEMS. if (TC.getTriple().getOS() != llvm::Triple::RTEMS) { CmdArgs.push_back("-lpthread"); -CmdArgs.push_back("-lrt"); +if (TC.getTriple().getOS() != llvm::Triple::OpenBSD) + CmdArgs.push_back("-lrt"); } CmdArgs.push_back("-lm"); // There's no libdl on all OSes. if (TC.getTriple().getOS() != llvm::Triple::FreeBSD && TC.getTriple().getOS() != llvm::Triple::NetBSD && + TC.getTriple().getOS() != llvm::Triple::OpenBSD && TC.getTriple().getOS() != llvm::Triple::RTEMS) CmdArgs.push_back("-ldl"); // Required for backtrace on some OSes Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp === --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp @@ -242,11 +242,13 @@ ArgStringList &CmdArgs) { CmdArgs.push_back("--no-as-needed"); CmdArgs.push_back("-lpthread"); - CmdArgs.push_back("-lrt"); + if (TC.getTriple().getOS() != llvm::Triple::OpenBSD) +CmdArgs.push_back("-lrt"); CmdArgs.push_back("-lm"); if (TC.getTriple().getOS() != llvm::Triple::FreeBSD && - TC.getTriple().getOS() != llvm::Triple::NetBSD) + TC.getTriple().getOS() != llvm::Triple::NetBSD && + TC.getTriple().getOS() != llvm::Triple::OpenBSD) CmdArgs.push_back("-ldl"); } Index: cfe/trunk/lib/Driver/ToolChain.cpp === --- cfe/trunk/lib/Driver/ToolChain.cpp +++ cfe/trunk/lib/Driver/ToolChain.cpp @@ -329,6 +329,8 @@ return "freebsd"; case llvm::Triple::NetBSD: return "netbsd"; + case llvm::Triple::OpenBSD: +return "openbsd"; case llvm::Triple::Solaris: return "sunos"; default: Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp === --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp @@ -542,12 +542,14 @@ // There's no libpthread or librt on RTEMS. if (TC.getTriple().getOS() != llvm::Triple::RTEMS) { CmdArgs.push_back("-lpthread"); -CmdArgs.push_back("-lrt"); +if (TC.getTriple().getOS() != llvm::Triple::OpenBSD) + CmdArgs.push_back("-lrt"); } CmdArgs.push_back("-lm"); // There's no libdl on all OSes. if (TC.getTriple().getOS() != llvm::Triple::FreeBSD && TC.getTriple().getOS() != llvm::Triple::NetBSD && + TC.getTriple().getOS() != llvm::Triple::OpenBSD && TC.getTriple().getOS() != llvm::Triple::RTEMS) CmdArgs.push_back("-ldl"); // Required for backtrace on some OSes Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp === --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp @@ -242,11 +242,13 @@ ArgStringList &CmdArgs) { CmdArgs.push_back("--no-as-needed"); CmdArgs.push_back("-lpthread"); - CmdArgs.push_back("-lrt"); + if (TC.getTriple().getOS() != llvm::Triple::OpenBSD) +CmdArgs.push_back("-lrt"); CmdArgs.push_back("-lm"); if (TC.getTriple().getOS() != llvm::Triple::FreeBSD && - TC.getTriple().getOS() != llvm::Triple::NetBSD) + TC.getTriple().getOS() != llvm::Triple::NetBSD && + TC.getTriple().getOS() != llvm::Triple::OpenBSD) CmdArgs.push_back("-ldl"); } Index: cfe/trunk/lib/Driver/ToolChain.cpp === --- cfe/trunk/lib/Driver/ToolChain.cpp +++ cfe/trunk/lib/Driver/ToolChain.cpp @@ -329,6 +329,8 @@ return "freebsd"; case llvm::Triple::NetBSD: return "netbsd"; + case llvm::Triple::OpenBSD: +return "openbsd"; case llvm::Triple::Solaris: return "sunos"; default: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r326648 - OpenBSD Driver basic sanitiser support
Author: kamil Date: Sat Mar 3 03:52:52 2018 New Revision: 326648 URL: http://llvm.org/viewvc/llvm-project?rev=326648&view=rev Log: OpenBSD Driver basic sanitiser support Summary: Basic support of Sanitiser to follow-up ubsan support in compiler-rt. Needs to use lld instead of base ld to be fully workable. Patch by: David CARLIER Reviewers: krytarowski, vitalybuka, kettenis Reviewed By: vitalybuka Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43961 Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp cfe/trunk/lib/Driver/ToolChains/OpenBSD.h Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp?rev=326648&r1=326647&r2=326648&view=diff == --- cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp Sat Mar 3 03:52:52 2018 @@ -13,6 +13,7 @@ #include "CommonArgs.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/Options.h" +#include "clang/Driver/SanitizerArgs.h" #include "llvm/Option/ArgList.h" using namespace clang::driver; @@ -97,6 +98,8 @@ void openbsd::Linker::ConstructJob(Compi const InputInfoList &Inputs, const ArgList &Args, const char *LinkingOutput) const { + const toolchains::OpenBSD &ToolChain = + static_cast(getToolChain()); const Driver &D = getToolChain().getDriver(); ArgStringList CmdArgs; @@ -170,11 +173,13 @@ void openbsd::Linker::ConstructJob(Compi Triple.replace(0, 6, "amd64"); CmdArgs.push_back( Args.MakeArgString("-L/usr/lib/gcc-lib/" + Triple + "/4.2.1")); + CmdArgs.push_back(Args.MakeArgString("-L/usr/lib")); Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group, options::OPT_e, options::OPT_s, options::OPT_t, options::OPT_Z_Flag, options::OPT_r}); + bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA); if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { @@ -186,7 +191,10 @@ void openbsd::Linker::ConstructJob(Compi else CmdArgs.push_back("-lm"); } - +if (NeedsSanitizerDeps) { + CmdArgs.push_back(ToolChain.getCompilerRTArgString(Args, "builtins", false)); + linkSanitizerRuntimeDeps(ToolChain, CmdArgs); +} // FIXME: For some reason GCC passes -lgcc before adding // the default system libraries. Just mimic this for now. CmdArgs.push_back("-lgcc"); @@ -221,6 +229,19 @@ void openbsd::Linker::ConstructJob(Compi C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs)); } +SanitizerMask OpenBSD::getSupportedSanitizers() const { + const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; + const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64; + + // For future use, only UBsan at the moment + SanitizerMask Res = ToolChain::getSupportedSanitizers(); + + if (IsX86 || IsX86_64) +Res |= SanitizerKind::Vptr; + + return Res; +} + /// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly. OpenBSD::OpenBSD(const Driver &D, const llvm::Triple &Triple, Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/OpenBSD.h?rev=326648&r1=326647&r2=326648&view=diff == --- cfe/trunk/lib/Driver/ToolChains/OpenBSD.h (original) +++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.h Sat Mar 3 03:52:52 2018 @@ -64,6 +64,8 @@ public: } unsigned GetDefaultDwarfVersion() const override { return 2; } + SanitizerMask getSupportedSanitizers() const override; + protected: Tool *buildAssembler() const override; Tool *buildLinker() const override; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43961: OpenBSD Driver basic sanitiser support
This revision was automatically updated to reflect the committed changes. Closed by commit rC326648: OpenBSD Driver basic sanitiser support (authored by kamil, committed by ). Repository: rC Clang https://reviews.llvm.org/D43961 Files: lib/Driver/ToolChains/OpenBSD.cpp lib/Driver/ToolChains/OpenBSD.h Index: lib/Driver/ToolChains/OpenBSD.cpp === --- lib/Driver/ToolChains/OpenBSD.cpp +++ lib/Driver/ToolChains/OpenBSD.cpp @@ -13,6 +13,7 @@ #include "CommonArgs.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/Options.h" +#include "clang/Driver/SanitizerArgs.h" #include "llvm/Option/ArgList.h" using namespace clang::driver; @@ -97,6 +98,8 @@ const InputInfoList &Inputs, const ArgList &Args, const char *LinkingOutput) const { + const toolchains::OpenBSD &ToolChain = + static_cast(getToolChain()); const Driver &D = getToolChain().getDriver(); ArgStringList CmdArgs; @@ -170,11 +173,13 @@ Triple.replace(0, 6, "amd64"); CmdArgs.push_back( Args.MakeArgString("-L/usr/lib/gcc-lib/" + Triple + "/4.2.1")); + CmdArgs.push_back(Args.MakeArgString("-L/usr/lib")); Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group, options::OPT_e, options::OPT_s, options::OPT_t, options::OPT_Z_Flag, options::OPT_r}); + bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA); if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { @@ -186,7 +191,10 @@ else CmdArgs.push_back("-lm"); } - +if (NeedsSanitizerDeps) { + CmdArgs.push_back(ToolChain.getCompilerRTArgString(Args, "builtins", false)); + linkSanitizerRuntimeDeps(ToolChain, CmdArgs); +} // FIXME: For some reason GCC passes -lgcc before adding // the default system libraries. Just mimic this for now. CmdArgs.push_back("-lgcc"); @@ -221,6 +229,19 @@ C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs)); } +SanitizerMask OpenBSD::getSupportedSanitizers() const { + const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; + const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64; + + // For future use, only UBsan at the moment + SanitizerMask Res = ToolChain::getSupportedSanitizers(); + + if (IsX86 || IsX86_64) +Res |= SanitizerKind::Vptr; + + return Res; +} + /// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly. OpenBSD::OpenBSD(const Driver &D, const llvm::Triple &Triple, Index: lib/Driver/ToolChains/OpenBSD.h === --- lib/Driver/ToolChains/OpenBSD.h +++ lib/Driver/ToolChains/OpenBSD.h @@ -64,6 +64,8 @@ } unsigned GetDefaultDwarfVersion() const override { return 2; } + SanitizerMask getSupportedSanitizers() const override; + protected: Tool *buildAssembler() const override; Tool *buildLinker() const override; Index: lib/Driver/ToolChains/OpenBSD.cpp === --- lib/Driver/ToolChains/OpenBSD.cpp +++ lib/Driver/ToolChains/OpenBSD.cpp @@ -13,6 +13,7 @@ #include "CommonArgs.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/Options.h" +#include "clang/Driver/SanitizerArgs.h" #include "llvm/Option/ArgList.h" using namespace clang::driver; @@ -97,6 +98,8 @@ const InputInfoList &Inputs, const ArgList &Args, const char *LinkingOutput) const { + const toolchains::OpenBSD &ToolChain = + static_cast(getToolChain()); const Driver &D = getToolChain().getDriver(); ArgStringList CmdArgs; @@ -170,11 +173,13 @@ Triple.replace(0, 6, "amd64"); CmdArgs.push_back( Args.MakeArgString("-L/usr/lib/gcc-lib/" + Triple + "/4.2.1")); + CmdArgs.push_back(Args.MakeArgString("-L/usr/lib")); Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group, options::OPT_e, options::OPT_s, options::OPT_t, options::OPT_Z_Flag, options::OPT_r}); + bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA); if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { @@ -186,7 +191,10 @@ else CmdArgs.push_back("-lm"); } - +if (NeedsSanitizerDeps) { + CmdArgs.push_back(ToolChain.getCompilerRTArgString(Args, "builtins", false)); + linkSanitizerRuntimeDeps(ToolChain, CmdArgs); +} // FIXME: For some reason GCC passes -lgcc before adding // the default system libraries. Just mimic this for now. CmdArgs.pu
r326652 - Disable tests of -fsanitize on OpenBSD
Author: kamil Date: Sat Mar 3 04:28:54 2018 New Revision: 326652 URL: http://llvm.org/viewvc/llvm-project?rev=326652&view=rev Log: Disable tests of -fsanitize on OpenBSD This causes failures on buildbots: /export/users/atombot/llvm/clang-atom-d525-fedora-rel/llvm/tools/clang/test/Driver/fsanitize.c:18:29: error: expected string not found in input // CHECK-UNDEFINED-OPENBSD: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute),?){18}"}} ^ :1:1: note: scanning from here clang version 7.0.0 (trunk 326648) ^ This will be investigated. Modified: cfe/trunk/test/Driver/fsanitize.c Modified: cfe/trunk/test/Driver/fsanitize.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=326652&r1=326651&r2=326652&view=diff == --- cfe/trunk/test/Driver/fsanitize.c (original) +++ cfe/trunk/test/Driver/fsanitize.c Sat Mar 3 04:28:54 2018 @@ -14,9 +14,6 @@ // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-DARWIN // CHECK-UNDEFINED-DARWIN: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|function|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute),?){19}"}} -// RUN: %clang -target i386-unknown-openbsd -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-OPENBSD -// CHECK-UNDEFINED-OPENBSD: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute),?){18}"}} - // RUN: %clang -target i386-pc-win32 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN32 // RUN: %clang -target i386-pc-win32 -fsanitize=undefined -x c++ %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN32 --check-prefix=CHECK-UNDEFINED-WIN-CXX // RUN: %clang -target x86_64-pc-win32 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN64 @@ -391,9 +388,6 @@ // RUN: %clang -target armv7-apple-ios7 -miphoneos-version-min=7.0 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IOS // CHECK-ASAN-IOS: -fsanitize=address -// RUN: %clang -target i386-pc-openbsd -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-OPENBSD -// CHECK-ASAN-OPENBSD: unsupported option '-fsanitize=address' for target 'i386-pc-openbsd' - // RUN: %clang -target x86_64-apple-darwin -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-X86-64-DARWIN // CHECK-LSAN-X86-64-DARWIN-NOT: unsupported option ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43961: OpenBSD Driver basic sanitiser support
krytarowski added a comment. http://llvm.org/viewvc/llvm-project?revision=326652&view=revision /export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/bin/clang -target x86_64-linux-gnu -fsanitize=hwaddress /export/users/atombot/llvm/clang-atom-d525-fedora-rel/llvm/tools/clang/test/Driver/fsanitize.c -### 2>&1 | /export/users/atombot/llvm/clang-atom-d525-fedora-rel/stage1/bin/FileCheck /export/users/atombot/llvm/clang-atom-d525-fedora-rel/llvm/tools/clang/test/Driver/fsanitize.c --check-prefix=CHECK-SANHA-X86_64 -- Exit Code: 1 Command Output (stderr): -- /export/users/atombot/llvm/clang-atom-d525-fedora-rel/llvm/tools/clang/test/Driver/fsanitize.c:18:29: error: expected string not found in input // CHECK-UNDEFINED-OPENBSD: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute),?){18}"}} ^ :1:1: note: scanning from here clang version 7.0.0 (trunk 326648) ^ -- http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/15071/steps/ninja%20check%201/logs/stdio Please fix this. Repository: rC Clang https://reviews.llvm.org/D43961 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44069: Test Driver sanitise, unsupported on OpenBSD
devnexen created this revision. devnexen added a reviewer: krytarowski. devnexen created this object with visibility "All Users". Herald added a subscriber: cfe-commits. OpenBSD supporting only UBsan unsupported this particular test Repository: rC Clang https://reviews.llvm.org/D44069 Files: test/Driver/fsanitize.c Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -649,3 +649,4 @@ // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANHA-X86_64 // CHECK-SANHA-X86_64: unsupported option '-fsanitize=hwaddress' for target +// UNSUPPORTED: openbsd Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -649,3 +649,4 @@ // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANHA-X86_64 // CHECK-SANHA-X86_64: unsupported option '-fsanitize=hwaddress' for target +// UNSUPPORTED: openbsd ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44069: Test Driver sanitise, unsupported on OpenBSD
krytarowski added a comment. This is not breaking (only?) on OpenBSD, but the triple is breaking all tested platforms. Please support it properly. Repository: rC Clang https://reviews.llvm.org/D44069 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44069: Test Driver sanitise, unsupported on OpenBSD
devnexen added a comment. In https://reviews.llvm.org/D44069#1026551, @krytarowski wrote: > This is not breaking (only?) on OpenBSD, but the triple is breaking all > tested platforms. > Please support it properly. What needs to be done ? I mean I have all OpenBSD compiler-rt code in my side not all is committed. Repository: rC Clang https://reviews.llvm.org/D44069 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44069: Test Driver sanitise, unsupported on OpenBSD
krytarowski added a comment. Revert: http://llvm.org/viewvc/llvm-project?revision=326652&view=revision And fix. Repository: rC Clang https://reviews.llvm.org/D44069 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44069: Test Driver sanitise, unsupported on OpenBSD
devnexen updated this revision to Diff 136919. devnexen added a comment. - Only Asan is not working under OpenBSD - unknown-arg test fails under OpenBSD https://reviews.llvm.org/D44069 Files: test/Driver/fsanitize.c test/Driver/unknown-arg.c Index: test/Driver/unknown-arg.c === --- test/Driver/unknown-arg.c +++ test/Driver/unknown-arg.c @@ -57,3 +57,4 @@ // RUN: %clang -S %s -o %t.s -Wunknown-to-clang-option 2>&1 | FileCheck --check-prefix=IGNORED %s // IGNORED: warning: unknown warning option '-Wunknown-to-clang-option' +// XFAIL: openbsd Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -388,6 +388,9 @@ // RUN: %clang -target armv7-apple-ios7 -miphoneos-version-min=7.0 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IOS // CHECK-ASAN-IOS: -fsanitize=address +// RUN: %clang -target i386-pc-openbsd -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-OPENBSD +// CHECK-ASAN-OPENBSD: unsupported option '-fsanitize=address' for target 'i386-pc-openbsd' + // RUN: %clang -target x86_64-apple-darwin -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-X86-64-DARWIN // CHECK-LSAN-X86-64-DARWIN-NOT: unsupported option Index: test/Driver/unknown-arg.c === --- test/Driver/unknown-arg.c +++ test/Driver/unknown-arg.c @@ -57,3 +57,4 @@ // RUN: %clang -S %s -o %t.s -Wunknown-to-clang-option 2>&1 | FileCheck --check-prefix=IGNORED %s // IGNORED: warning: unknown warning option '-Wunknown-to-clang-option' +// XFAIL: openbsd Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -388,6 +388,9 @@ // RUN: %clang -target armv7-apple-ios7 -miphoneos-version-min=7.0 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IOS // CHECK-ASAN-IOS: -fsanitize=address +// RUN: %clang -target i386-pc-openbsd -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-OPENBSD +// CHECK-ASAN-OPENBSD: unsupported option '-fsanitize=address' for target 'i386-pc-openbsd' + // RUN: %clang -target x86_64-apple-darwin -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-X86-64-DARWIN // CHECK-LSAN-X86-64-DARWIN-NOT: unsupported option ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44069: Test Driver sanitise, unsupported on OpenBSD
devnexen added a comment. In https://reviews.llvm.org/D44069#1026563, @krytarowski wrote: > Revert: http://llvm.org/viewvc/llvm-project?revision=326652&view=revision > > And fix. I launched llvm-lit to the whole directory and this is the fixes. https://reviews.llvm.org/D44069 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44069: Test Driver sanitise, unsupported on OpenBSD
krytarowski added a comment. Please mark ubsan as supported now. https://reviews.llvm.org/D44069 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44069: Test Driver sanitise, unsupported on OpenBSD
devnexen updated this revision to Diff 136924. devnexen added a comment. Enable UBsan test https://reviews.llvm.org/D44069 Files: test/Driver/fsanitize.c test/Driver/unknown-arg.c Index: test/Driver/unknown-arg.c === --- test/Driver/unknown-arg.c +++ test/Driver/unknown-arg.c @@ -57,3 +57,4 @@ // RUN: %clang -S %s -o %t.s -Wunknown-to-clang-option 2>&1 | FileCheck --check-prefix=IGNORED %s // IGNORED: warning: unknown warning option '-Wunknown-to-clang-option' +// XFAIL: openbsd Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -388,6 +388,12 @@ // RUN: %clang -target armv7-apple-ios7 -miphoneos-version-min=7.0 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IOS // CHECK-ASAN-IOS: -fsanitize=address +// RUN %clang -target i386-pc-openbsd -fsanitize=undefined %s -### 2>&1 | FileCheck --check-prefix=CHECK_UBSAN-OPENBSD +// CHECK-UBSAN-OPENBSD: -fsanitize=undefined + +// RUN: %clang -target i386-pc-openbsd -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-OPENBSD +// CHECK-ASAN-OPENBSD: unsupported option '-fsanitize=address' for target 'i386-pc-openbsd' + // RUN: %clang -target x86_64-apple-darwin -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-X86-64-DARWIN // CHECK-LSAN-X86-64-DARWIN-NOT: unsupported option Index: test/Driver/unknown-arg.c === --- test/Driver/unknown-arg.c +++ test/Driver/unknown-arg.c @@ -57,3 +57,4 @@ // RUN: %clang -S %s -o %t.s -Wunknown-to-clang-option 2>&1 | FileCheck --check-prefix=IGNORED %s // IGNORED: warning: unknown warning option '-Wunknown-to-clang-option' +// XFAIL: openbsd Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -388,6 +388,12 @@ // RUN: %clang -target armv7-apple-ios7 -miphoneos-version-min=7.0 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IOS // CHECK-ASAN-IOS: -fsanitize=address +// RUN %clang -target i386-pc-openbsd -fsanitize=undefined %s -### 2>&1 | FileCheck --check-prefix=CHECK_UBSAN-OPENBSD +// CHECK-UBSAN-OPENBSD: -fsanitize=undefined + +// RUN: %clang -target i386-pc-openbsd -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-OPENBSD +// CHECK-ASAN-OPENBSD: unsupported option '-fsanitize=address' for target 'i386-pc-openbsd' + // RUN: %clang -target x86_64-apple-darwin -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LSAN-X86-64-DARWIN // CHECK-LSAN-X86-64-DARWIN-NOT: unsupported option ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43750: Allow writing calling convention attributes on function types
aaron.ballman added a comment. Ping https://reviews.llvm.org/D43750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44069: Test Driver sanitise, unsupported on OpenBSD
davide added a comment. Apologies, but this is not an area I'm particularly familiar with. So, I'm resigning, but @filcab / @vsk can probably comment. https://reviews.llvm.org/D44069 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r326622 - Don't claim that va_start has special semantic checks
The 't' was there because __builtin_va_start and __va_start had them, but those do in fact have custom sema checking so copying that was in fact incorrect. Thanks for fixing my bugs! On Fri, Mar 2, 2018 at 4:41 PM, Reid Kleckner via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: rnk > Date: Fri Mar 2 13:41:08 2018 > New Revision: 326622 > > URL: http://llvm.org/viewvc/llvm-project?rev=326622&view=rev > Log: > Don't claim that va_start has special semantic checks > > We don't have special checks for BI_va_start in > Sema::CheckBuiltinFunctionCall, so setting the 't' flag for va_start in > Builtins.def disables semantic checking for it. That's not desired, and > IRGen crashes when it tries to generate a call to va_start that doesn't > have at least one argument. > > Follow-up to r322573 > > Fixes PR36565 > > Modified: > cfe/trunk/include/clang/Basic/Builtins.def > cfe/trunk/test/Sema/varargs.c > > Modified: cfe/trunk/include/clang/Basic/Builtins.def > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/ > clang/Basic/Builtins.def?rev=326622&r1=326621&r2=326622&view=diff > > == > --- cfe/trunk/include/clang/Basic/Builtins.def (original) > +++ cfe/trunk/include/clang/Basic/Builtins.def Fri Mar 2 13:41:08 2018 > @@ -803,7 +803,7 @@ LIBBUILTIN(_setjmpex, "iJ", "fj", "set > > // C99 library functions > // C99 stdarg.h > -LIBBUILTIN(va_start, "vA.", "fnt", "stdarg.h", ALL_LANGUAGES) > +LIBBUILTIN(va_start, "vA.", "fn","stdarg.h", ALL_LANGUAGES) > LIBBUILTIN(va_end, "vA", "fn","stdarg.h", ALL_LANGUAGES) > LIBBUILTIN(va_copy, "vAA","fn","stdarg.h", ALL_LANGUAGES) > // C99 stdlib.h > > Modified: cfe/trunk/test/Sema/varargs.c > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/ > varargs.c?rev=326622&r1=326621&r2=326622&view=diff > > == > --- cfe/trunk/test/Sema/varargs.c (original) > +++ cfe/trunk/test/Sema/varargs.c Fri Mar 2 13:41:08 2018 > @@ -112,3 +112,12 @@ void f13(enum E1 e, ...) { > #endif >__builtin_va_end(va); > } > + > +void f14(int e, ...) { > + // expected-warning@+3 {{implicitly declaring library function > 'va_start'}} > + // expected-note@+2 {{include the header }} > + // expected-error@+1 {{too few arguments to function call}} > + va_start(); > + __builtin_va_list va; > + va_start(va, e); > +} > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r326665 - Create a subject list for the `used` attribute rather than use custom checking logic.
Author: aaronballman Date: Sat Mar 3 13:02:09 2018 New Revision: 326665 URL: http://llvm.org/viewvc/llvm-project?rev=326665&view=rev Log: Create a subject list for the `used` attribute rather than use custom checking logic. This changes the diagnostic wording somewhat, but otherwise intends no functional change to the attribute. Modified: cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/test/Sema/attr-used.c Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=326665&r1=326664&r2=326665&view=diff == --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Sat Mar 3 13:02:09 2018 @@ -83,6 +83,9 @@ def LocalVar : SubsetSubjectgetKind() != Decl::ParmVar}], "variables">; +def NonLocalVar : SubsetSubjecthasLocalStorage()}], +"variables with non-local storage">; def NonBitField : SubsetSubjectisBitField()}], "non-bit-field non-static data members">; @@ -2007,6 +2010,7 @@ def Unused : InheritableAttr { def Used : InheritableAttr { let Spellings = [GCC<"used">]; + let Subjects = SubjectList<[Function, ObjCMethod, NonLocalVar]>; let Documentation = [Undocumented]; } Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=326665&r1=326664&r2=326665&view=diff == --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sat Mar 3 13:02:09 2018 @@ -2086,23 +2086,6 @@ static void handleDisableTailCallsAttr(S AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); } -static void handleUsedAttr(Sema &S, Decl *D, const AttributeList &AL) { - if (const auto *VD = dyn_cast(D)) { -if (VD->hasLocalStorage()) { - S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL.getName(); - return; -} - } else if (!isFunctionOrMethod(D)) { -S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) - << AL.getName() << ExpectedVariableOrFunction; -return; - } - - D->addAttr(::new (S.Context) - UsedAttr(AL.getRange(), S.Context, - AL.getAttributeSpellingListIndex())); -} - static void handleUnusedAttr(Sema &S, Decl *D, const AttributeList &AL) { bool IsCXX17Attr = AL.isCXX11Attribute() && !AL.getScopeName(); @@ -6248,7 +6231,7 @@ static void ProcessDeclAttribute(Sema &S handleDisableTailCallsAttr(S, D, AL); break; case AttributeList::AT_Used: -handleUsedAttr(S, D, AL); +handleSimpleAttribute(S, D, AL); break; case AttributeList::AT_Visibility: handleVisibilityAttr(S, D, AL, false); Modified: cfe/trunk/test/Sema/attr-used.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-used.c?rev=326665&r1=326664&r2=326665&view=diff == --- cfe/trunk/test/Sema/attr-used.c (original) +++ cfe/trunk/test/Sema/attr-used.c Sat Mar 3 13:02:09 2018 @@ -3,7 +3,7 @@ extern int l0 __attribute__((used)); // expected-warning {{'used' attribute ignored}} __private_extern__ int l1 __attribute__((used)); // expected-warning {{'used' attribute ignored}} -struct __attribute__((used)) s { // expected-warning {{'used' attribute only applies to variables and functions}} +struct __attribute__((used)) s { // expected-warning {{'used' attribute only applies to functions, Objective-C methods, and variables with non-local storage}} int x; }; @@ -14,7 +14,7 @@ static void __attribute__((used)) f0(voi void f1() { static int a __attribute__((used)); - int b __attribute__((used)); // expected-warning {{'used' attribute ignored}} + int b __attribute__((used)); // expected-warning {{'used' attribute only applies to functions, Objective-C methods, and variables with non-local storage}} } static void __attribute__((used)) f0(void); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r326665 - Create a subject list for the `used` attribute rather than use custom checking logic.
Is it easy to mention variables first in the diag? That's probably the most common subject for this attribute. (If it's not easy, nevermind -- definitely a polish thing.) On Sat, Mar 3, 2018, 4:04 PM Aaron Ballman via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: aaronballman > Date: Sat Mar 3 13:02:09 2018 > New Revision: 326665 > > URL: http://llvm.org/viewvc/llvm-project?rev=326665&view=rev > Log: > Create a subject list for the `used` attribute rather than use custom > checking logic. > > This changes the diagnostic wording somewhat, but otherwise intends no > functional change to the attribute. > > Modified: > cfe/trunk/include/clang/Basic/Attr.td > cfe/trunk/lib/Sema/SemaDeclAttr.cpp > cfe/trunk/test/Sema/attr-used.c > > Modified: cfe/trunk/include/clang/Basic/Attr.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=326665&r1=326664&r2=326665&view=diff > > == > --- cfe/trunk/include/clang/Basic/Attr.td (original) > +++ cfe/trunk/include/clang/Basic/Attr.td Sat Mar 3 13:02:09 2018 > @@ -83,6 +83,9 @@ def LocalVar : SubsetSubject def NonParmVar : SubsetSubject [{S->getKind() != Decl::ParmVar}], > "variables">; > +def NonLocalVar : SubsetSubject +[{!S->hasLocalStorage()}], > +"variables with non-local storage">; > def NonBitField : SubsetSubject [{!S->isBitField()}], > "non-bit-field non-static data members">; > @@ -2007,6 +2010,7 @@ def Unused : InheritableAttr { > > def Used : InheritableAttr { >let Spellings = [GCC<"used">]; > + let Subjects = SubjectList<[Function, ObjCMethod, NonLocalVar]>; >let Documentation = [Undocumented]; > } > > > Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=326665&r1=326664&r2=326665&view=diff > > == > --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) > +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sat Mar 3 13:02:09 2018 > @@ -2086,23 +2086,6 @@ static void handleDisableTailCallsAttr(S >AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); > } > > -static void handleUsedAttr(Sema &S, Decl *D, const AttributeList &AL) { > - if (const auto *VD = dyn_cast(D)) { > -if (VD->hasLocalStorage()) { > - S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL.getName(); > - return; > -} > - } else if (!isFunctionOrMethod(D)) { > -S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) > - << AL.getName() << ExpectedVariableOrFunction; > -return; > - } > - > - D->addAttr(::new (S.Context) > - UsedAttr(AL.getRange(), S.Context, > - AL.getAttributeSpellingListIndex())); > -} > - > static void handleUnusedAttr(Sema &S, Decl *D, const AttributeList &AL) { >bool IsCXX17Attr = AL.isCXX11Attribute() && !AL.getScopeName(); > > @@ -6248,7 +6231,7 @@ static void ProcessDeclAttribute(Sema &S > handleDisableTailCallsAttr(S, D, AL); > break; >case AttributeList::AT_Used: > -handleUsedAttr(S, D, AL); > +handleSimpleAttribute(S, D, AL); > break; >case AttributeList::AT_Visibility: > handleVisibilityAttr(S, D, AL, false); > > Modified: cfe/trunk/test/Sema/attr-used.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-used.c?rev=326665&r1=326664&r2=326665&view=diff > > == > --- cfe/trunk/test/Sema/attr-used.c (original) > +++ cfe/trunk/test/Sema/attr-used.c Sat Mar 3 13:02:09 2018 > @@ -3,7 +3,7 @@ > extern int l0 __attribute__((used)); // expected-warning {{'used' > attribute ignored}} > __private_extern__ int l1 __attribute__((used)); // expected-warning > {{'used' attribute ignored}} > > -struct __attribute__((used)) s { // expected-warning {{'used' attribute > only applies to variables and functions}} > +struct __attribute__((used)) s { // expected-warning {{'used' attribute > only applies to functions, Objective-C methods, and variables with > non-local storage}} >int x; > }; > > @@ -14,7 +14,7 @@ static void __attribute__((used)) f0(voi > > void f1() { >static int a __attribute__((used)); > - int b __attribute__((used)); // expected-warning {{'used' attribute > ignored}} > + int b __attribute__((used)); // expected-warning {{'used' attribute > only applies to functions, Objective-C methods, and variables with > non-local storage}} > } > > static void __attribute__((used)) f0(void); > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > _
[PATCH] D39159: [analyzer] Improves the logic of GenericTaintChecker identifying stdin.
MTC updated this revision to Diff 136934. MTC set the repository for this revision to rC Clang. MTC added a comment. Herald added subscribers: cfe-commits, a.sidorin. Herald added a reviewer: george.karpenkov. Update the `taint-generic.c` to test both `stdin` declaration variants. Repository: rC Clang https://reviews.llvm.org/D39159 Files: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp test/Analysis/taint-generic.c Index: test/Analysis/taint-generic.c === --- test/Analysis/taint-generic.c +++ test/Analysis/taint-generic.c @@ -1,10 +1,16 @@ // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.security.taint,core,alpha.security.ArrayBoundV2 -Wno-format-security -verify %s +// RUN: %clang_analyze_cc1 -DFILE_IS_STRUCT -analyzer-checker=alpha.security.taint,core,alpha.security.ArrayBoundV2 -Wno-format-security -verify %s int scanf(const char *restrict format, ...); int getchar(void); typedef struct _FILE FILE; +#ifdef FILE_IS_STRUCT +extern struct _FILE *stdin; +#else extern FILE *stdin; +#endif + int fscanf(FILE *restrict stream, const char *restrict format, ...); int sprintf(char *str, const char *format, ...); void setproctitle(const char *fmt, ...); Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp === --- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp +++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp @@ -646,7 +646,8 @@ if ((D->getName().find("stdin") != StringRef::npos) && D->isExternC()) if (const PointerType * PtrTy = dyn_cast(D->getType().getTypePtr())) - if (PtrTy->getPointeeType() == C.getASTContext().getFILEType()) + if (PtrTy->getPointeeType().getCanonicalType() == + C.getASTContext().getFILEType().getCanonicalType()) return true; } return false; Index: test/Analysis/taint-generic.c === --- test/Analysis/taint-generic.c +++ test/Analysis/taint-generic.c @@ -1,10 +1,16 @@ // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.security.taint,core,alpha.security.ArrayBoundV2 -Wno-format-security -verify %s +// RUN: %clang_analyze_cc1 -DFILE_IS_STRUCT -analyzer-checker=alpha.security.taint,core,alpha.security.ArrayBoundV2 -Wno-format-security -verify %s int scanf(const char *restrict format, ...); int getchar(void); typedef struct _FILE FILE; +#ifdef FILE_IS_STRUCT +extern struct _FILE *stdin; +#else extern FILE *stdin; +#endif + int fscanf(FILE *restrict stream, const char *restrict format, ...); int sprintf(char *str, const char *format, ...); void setproctitle(const char *fmt, ...); Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp === --- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp +++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp @@ -646,7 +646,8 @@ if ((D->getName().find("stdin") != StringRef::npos) && D->isExternC()) if (const PointerType * PtrTy = dyn_cast(D->getType().getTypePtr())) - if (PtrTy->getPointeeType() == C.getASTContext().getFILEType()) + if (PtrTy->getPointeeType().getCanonicalType() == + C.getASTContext().getFILEType().getCanonicalType()) return true; } return false; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39159: [analyzer] Improves the logic of GenericTaintChecker identifying stdin.
MTC added a comment. @NoQ, Very sorry, I've forgotten about this patch, it has now been updated. Repository: rC Clang https://reviews.llvm.org/D39159 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits