[libunwind] r295944 - Drop the dependency on dl_unwind_find_exidx().
Author: ed Date: Thu Feb 23 02:05:58 2017 New Revision: 295944 URL: http://llvm.org/viewvc/llvm-project?rev=295944&view=rev Log: Drop the dependency on dl_unwind_find_exidx(). While porting libunwind over to CloudABI for ARMv6, I observed that this source file doesn't build, as it depends on dl_unwind_find_exidx(), which CloudABI's C library was lacking. After I added that function, I still needed to patch up libunwind to define _Unwind_Ptr. Taking a step back, I wonder why we need to make use of this function anyway. The unwinder already has some nice code to use dl_iterate_phdr() to scan for a PT_GNU_EH_FRAME header. The dl_unwind_find_exidx() does the same thing, except matching PT_ARM_EXIDX instead. We could also do that ourselves. This change gets rid of the dl_unwind_find_exidx() call and extends the dl_iterate_phdr() loop. In addition to making the code a bit shorter, it has the advantage of getting rid of some of those OS-specific #ifdefs. This now means that if an operating system only provides dl_iterate_phdr(), it gets support for unwinding on all architectures. There is no need to add more stuff, just to get ARMv6 support. Differential Revision: https://reviews.llvm.org/D28082 Modified: libunwind/trunk/src/AddressSpace.hpp Modified: libunwind/trunk/src/AddressSpace.hpp URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=295944&r1=295943&r2=295944&view=diff == --- libunwind/trunk/src/AddressSpace.hpp (original) +++ libunwind/trunk/src/AddressSpace.hpp Thu Feb 23 02:05:58 2017 @@ -35,29 +35,17 @@ namespace libunwind { #include "Registers.hpp" #if _LIBUNWIND_ARM_EHABI -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) - -typedef void *_Unwind_Ptr; - -#elif defined(__linux__) - -typedef long unsigned int *_Unwind_Ptr; -extern "C" _Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr addr, int *len); - -// Emulate the BSD dl_unwind_find_exidx API when on a GNU libdl system. -#define dl_unwind_find_exidx __gnu_Unwind_Find_exidx - -#elif !defined(_LIBUNWIND_IS_BAREMETAL) -#include -#else // !defined(_LIBUNWIND_IS_BAREMETAL) -// When statically linked on bare-metal, the symbols for the EH table are looked -// up without going through the dynamic loader. struct EHTEntry { uint32_t functionOffset; uint32_t unwindOpcodes; }; +#if defined(_LIBUNWIND_IS_BAREMETAL) +// When statically linked on bare-metal, the symbols for the EH table are looked +// up without going through the dynamic loader. extern EHTEntry __exidx_start; extern EHTEntry __exidx_end; +#else +#include #endif // !defined(_LIBUNWIND_IS_BAREMETAL) #endif // _LIBUNWIND_ARM_EHABI @@ -368,23 +356,15 @@ inline bool LocalAddressSpace::findUnwin info.compact_unwind_section_length = dyldInfo.compact_unwind_section_length; return true; } -#elif _LIBUNWIND_ARM_EHABI - #ifdef _LIBUNWIND_IS_BAREMETAL +#elif _LIBUNWIND_ARM_EHABI && defined(_LIBUNWIND_IS_BAREMETAL) // Bare metal is statically linked, so no need to ask the dynamic loader info.arm_section =(uintptr_t)(&__exidx_start); info.arm_section_length = (uintptr_t)(&__exidx_end - &__exidx_start); - #else - int length = 0; - info.arm_section = (uintptr_t) dl_unwind_find_exidx( - (_Unwind_Ptr) targetAddr, &length); - info.arm_section_length = (uintptr_t)length; - #endif _LIBUNWIND_TRACE_UNWINDING("findUnwindSections: section %X length %x", info.arm_section, info.arm_section_length); if (info.arm_section && info.arm_section_length) return true; -#elif _LIBUNWIND_SUPPORT_DWARF_UNWIND -#if _LIBUNWIND_SUPPORT_DWARF_INDEX +#elif _LIBUNWIND_ARM_EHABI || _LIBUNWIND_SUPPORT_DWARF_UNWIND struct dl_iterate_cb_data { LocalAddressSpace *addressSpace; UnwindInfoSections *sects; @@ -395,9 +375,6 @@ inline bool LocalAddressSpace::findUnwin int found = dl_iterate_phdr( [](struct dl_phdr_info *pinfo, size_t, void *data) -> int { auto cbdata = static_cast(data); -size_t object_length; -bool found_obj = false; -bool found_hdr = false; assert(cbdata); assert(cbdata->sects); @@ -413,6 +390,14 @@ inline bool LocalAddressSpace::findUnwin typedef ElfW(Phdr) Elf_Phdr; #endif + #if _LIBUNWIND_SUPPORT_DWARF_UNWIND + #if !_LIBUNWIND_SUPPORT_DWARF_INDEX + #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform." + #endif +size_t object_length; +bool found_obj = false; +bool found_hdr = false; + for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) { const Elf_Phdr *phdr = &pinfo->dlpi_phdr[i]; if (phdr->p_type == PT_LOAD) { @@ -442,12 +427,22 @@ inline bool LocalAddressSpace::findUnwin } else { return false; } + #else // _LIBUNWIND_ARM_EHABI +for (Elf_Half i = 0; i < pinfo->dlpi_ph
[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.
hokein added inline comments. Comment at: include-fixer/InMemorySymbolIndex.h:27 - std::vector + std::vector search(llvm::StringRef Identifier) override; There are many places using `std::vector`. Maybe we can use a type alias for it, so that we can type less. Comment at: include-fixer/SymbolIndexManager.cpp:104 +for (const auto &SymAndSig : Symbols) { + const SymbolInfo Symbol = SymAndSig.Symbol; // Match the identifier name without qualifier. I think you miss `&` here. Comment at: include-fixer/find-all-symbols/FindAllMacros.cpp:37 const MacroDirective *MD) { - SourceLocation Loc = SM->getExpansionLoc(MacroNameTok.getLocation()); - std::string FilePath = getIncludePath(*SM, Loc, Collector); - if (FilePath.empty()) return; + if (auto Symbol = CreateMacroSymbol(MacroNameTok, MD->getMacroInfo())) { +FileSymbols[*Symbol].Seen++; Nit: No `{}` for single statement in `if`. The same below. Comment at: include-fixer/find-all-symbols/FindAllMacros.h:39 + + void Ifdef(SourceLocation Loc, const Token &MacroNameTok, + const MacroDefinition &MD) override; We are missing tests for these macro usages. Comment at: include-fixer/find-all-symbols/FindAllSymbols.h:52 + std::string Filename; + // Findings for the current source file, flushed on EndSourceFileAction. + SymbolInfo::SignalMap FileSymbols; s/`on EndSourceFileAction`/`onEndOfTranslationUnit`. Comment at: include-fixer/find-all-symbols/SymbolInfo.h:50 + // used. These are used to rank results. + struct Signals { +Signals() {} I think we can make a standalone class instead of making it a nested class of `SymbolInfo` because I don't see strong relationship between them. Maybe name it `FindingSignals` or `FindingInfo`. Comment at: include-fixer/find-all-symbols/SymbolInfo.h:72 int LineNumber, const std::vector &Contexts, - unsigned NumOccurrences = 0); + unsigned NumOccurrences = 0, unsigned NumUses = 0); We don't need this method since we have `SymbolAndSignals`? Comment at: include-fixer/find-all-symbols/SymbolInfo.h:101 private: - friend struct llvm::yaml::MappingTraits; + friend struct llvm::yaml::MappingTraits; I'd put this statement inside `SymbolAndSignals`. Comment at: include-fixer/find-all-symbols/SymbolInfo.h:129 - /// \brief The number of times this symbol was found during an indexing - /// run. Populated by the reducer and used to rank results. - unsigned NumOccurrences; +struct SymbolAndSignals { + SymbolInfo Symbol; Not much better idea on names, how about `SymbolFinding`? ``` struct SymbolFinding { SymbolInfo Symbol; FindingInfo Finding; }; ``` https://reviews.llvm.org/D30210 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] r295948 - Revert r295944.
Author: ed Date: Thu Feb 23 03:13:22 2017 New Revision: 295948 URL: http://llvm.org/viewvc/llvm-project?rev=295948&view=rev Log: Revert r295944. Even though the change works perfectly fine on CloudABI, it fails to work on the libcxx-libcxxabi-libunwind-arm-linux-noexceptions build bot. Looking at the code, this may be attributed to the fact that the code doesn't take the PT_LOAD addresses into consideration. I will rework this change to fix that and send out an updated version for review in the nearby future. Modified: libunwind/trunk/src/AddressSpace.hpp Modified: libunwind/trunk/src/AddressSpace.hpp URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=295948&r1=295947&r2=295948&view=diff == --- libunwind/trunk/src/AddressSpace.hpp (original) +++ libunwind/trunk/src/AddressSpace.hpp Thu Feb 23 03:13:22 2017 @@ -35,17 +35,29 @@ namespace libunwind { #include "Registers.hpp" #if _LIBUNWIND_ARM_EHABI +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) + +typedef void *_Unwind_Ptr; + +#elif defined(__linux__) + +typedef long unsigned int *_Unwind_Ptr; +extern "C" _Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr addr, int *len); + +// Emulate the BSD dl_unwind_find_exidx API when on a GNU libdl system. +#define dl_unwind_find_exidx __gnu_Unwind_Find_exidx + +#elif !defined(_LIBUNWIND_IS_BAREMETAL) +#include +#else // !defined(_LIBUNWIND_IS_BAREMETAL) +// When statically linked on bare-metal, the symbols for the EH table are looked +// up without going through the dynamic loader. struct EHTEntry { uint32_t functionOffset; uint32_t unwindOpcodes; }; -#if defined(_LIBUNWIND_IS_BAREMETAL) -// When statically linked on bare-metal, the symbols for the EH table are looked -// up without going through the dynamic loader. extern EHTEntry __exidx_start; extern EHTEntry __exidx_end; -#else -#include #endif // !defined(_LIBUNWIND_IS_BAREMETAL) #endif // _LIBUNWIND_ARM_EHABI @@ -356,15 +368,23 @@ inline bool LocalAddressSpace::findUnwin info.compact_unwind_section_length = dyldInfo.compact_unwind_section_length; return true; } -#elif _LIBUNWIND_ARM_EHABI && defined(_LIBUNWIND_IS_BAREMETAL) +#elif _LIBUNWIND_ARM_EHABI + #ifdef _LIBUNWIND_IS_BAREMETAL // Bare metal is statically linked, so no need to ask the dynamic loader info.arm_section =(uintptr_t)(&__exidx_start); info.arm_section_length = (uintptr_t)(&__exidx_end - &__exidx_start); + #else + int length = 0; + info.arm_section = (uintptr_t) dl_unwind_find_exidx( + (_Unwind_Ptr) targetAddr, &length); + info.arm_section_length = (uintptr_t)length; + #endif _LIBUNWIND_TRACE_UNWINDING("findUnwindSections: section %X length %x", info.arm_section, info.arm_section_length); if (info.arm_section && info.arm_section_length) return true; -#elif _LIBUNWIND_ARM_EHABI || _LIBUNWIND_SUPPORT_DWARF_UNWIND +#elif _LIBUNWIND_SUPPORT_DWARF_UNWIND +#if _LIBUNWIND_SUPPORT_DWARF_INDEX struct dl_iterate_cb_data { LocalAddressSpace *addressSpace; UnwindInfoSections *sects; @@ -375,6 +395,9 @@ inline bool LocalAddressSpace::findUnwin int found = dl_iterate_phdr( [](struct dl_phdr_info *pinfo, size_t, void *data) -> int { auto cbdata = static_cast(data); +size_t object_length; +bool found_obj = false; +bool found_hdr = false; assert(cbdata); assert(cbdata->sects); @@ -390,14 +413,6 @@ inline bool LocalAddressSpace::findUnwin typedef ElfW(Phdr) Elf_Phdr; #endif - #if _LIBUNWIND_SUPPORT_DWARF_UNWIND - #if !_LIBUNWIND_SUPPORT_DWARF_INDEX - #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform." - #endif -size_t object_length; -bool found_obj = false; -bool found_hdr = false; - for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) { const Elf_Phdr *phdr = &pinfo->dlpi_phdr[i]; if (phdr->p_type == PT_LOAD) { @@ -427,22 +442,12 @@ inline bool LocalAddressSpace::findUnwin } else { return false; } - #else // _LIBUNWIND_ARM_EHABI -for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) { - const Elf_Phdr *phdr = &pinfo->dlpi_phdr[i]; - if (phdr->p_type == PT_ARM_EXIDX) { -uintptr_t exidx_start = pinfo->dlpi_addr + phdr->p_vaddr; -cbdata->sects->arm_section = exidx_start; -cbdata->sects->arm_section_length = phdr->p_memsz / -sizeof(EHTEntry); -return true; - } -} -return false; - #endif }, &cb_data); return static_cast(found); +#else +#error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform." +#endif #endif return false; ___
[PATCH] D30289: [Analyzer] Add bug visitor for taint checker
vlad.tsyrklevich created this revision. Add a bug visitor to the taint checker to make it easy to distinguish where the tainted value originated. This is especially useful when the original taint source is obscured by complex data flow. https://reviews.llvm.org/D30289 Files: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp === --- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp +++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp @@ -101,6 +101,22 @@ bool generateReportIfTainted(const Expr *E, const char Msg[], CheckerContext &C) const; + /// The bug visitor prints a diagnostic message at the location where a given + /// variable was tainted. + class TaintBugVisitor + : public BugReporterVisitorImpl { + private: +const SVal S; + + public: +TaintBugVisitor(const SVal S) : S(S) {} +void Profile(llvm::FoldingSetNodeID &ID) const override { ID.Add(S); } + +std::shared_ptr VisitNode(const ExplodedNode *N, + const ExplodedNode *PrevN, + BugReporterContext &BRC, + BugReport &BR) override; + }; typedef SmallVector ArgVector; @@ -194,6 +210,28 @@ /// points to data, which should be tainted on return. REGISTER_SET_WITH_PROGRAMSTATE(TaintArgsOnPostVisit, unsigned) +std::shared_ptr +GenericTaintChecker::TaintBugVisitor::VisitNode(const ExplodedNode *N, +const ExplodedNode *PrevN, BugReporterContext &BRC, BugReport &BR) { + + // Find the ExplodedNode where the taint was first introduced + if (!N->getState()->isTainted(S) || PrevN->getState()->isTainted(S)) +return nullptr; + + const Stmt *S = PathDiagnosticLocation::getStmt(N); + if (!S) +return nullptr; + + const LocationContext *NCtx = N->getLocationContext(); + PathDiagnosticLocation L = + PathDiagnosticLocation::createBegin(S, BRC.getSourceManager(), NCtx); + if (!L.isValid() || !L.asLocation().isValid()) +return nullptr; + + return std::make_shared( + L, "Taint originated here"); +} + GenericTaintChecker::TaintPropagationRule GenericTaintChecker::TaintPropagationRule::getTaintPropagationRule( const FunctionDecl *FDecl, @@ -635,15 +673,21 @@ // Check for taint. ProgramStateRef State = C.getState(); - if (!State->isTainted(getPointedToSymbol(C, E)) && - !State->isTainted(E, C.getLocationContext())) + const SymbolRef PointedToSym = getPointedToSymbol(C, E); + SVal TaintedSVal; + if (State->isTainted(PointedToSym)) +TaintedSVal = nonloc::SymbolVal(PointedToSym); + else if (State->isTainted(E, C.getLocationContext())) +TaintedSVal = State->getSVal(E, C.getLocationContext()); + else return false; // Generate diagnostic. if (ExplodedNode *N = C.generateNonFatalErrorNode()) { initBugType(); auto report = llvm::make_unique(*BT, Msg, N); report->addRange(E->getSourceRange()); +report->addVisitor(llvm::make_unique(TaintedSVal)); C.emitReport(std::move(report)); return true; } Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp === --- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp +++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp @@ -101,6 +101,22 @@ bool generateReportIfTainted(const Expr *E, const char Msg[], CheckerContext &C) const; + /// The bug visitor prints a diagnostic message at the location where a given + /// variable was tainted. + class TaintBugVisitor + : public BugReporterVisitorImpl { + private: +const SVal S; + + public: +TaintBugVisitor(const SVal S) : S(S) {} +void Profile(llvm::FoldingSetNodeID &ID) const override { ID.Add(S); } + +std::shared_ptr VisitNode(const ExplodedNode *N, + const ExplodedNode *PrevN, + BugReporterContext &BRC, + BugReport &BR) override; + }; typedef SmallVector ArgVector; @@ -194,6 +210,28 @@ /// points to data, which should be tainted on return. REGISTER_SET_WITH_PROGRAMSTATE(TaintArgsOnPostVisit, unsigned) +std::shared_ptr +GenericTaintChecker::TaintBugVisitor::VisitNode(const ExplodedNode *N, +const ExplodedNode *PrevN, BugReporterContext &BRC, BugReport &BR) { + + // Find the ExplodedNode where the taint was first introduced + if (!N->getState()->isTainted(S) || PrevN->getState()->isTainted(S)) +return nullptr; + + const Stmt *S = PathDiagnosticLocation::getStmt(N); + if (!S) +return nullptr; + + const LocationContext *NCtx = N->getLocationContext(); + PathDiagnosticLocation L = +
Re: [libunwind] r295948 - Revert r295944.
Hi Ed, I have a feeling that the no-exceptions builders are missing a few configuration bits. "No-exceptions" libraries should not require libunwind... Looking at the cmake configs: http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux-noexceptions/builds/430/steps/cmake/logs/stdio I see that it's missing the -DLIBCXXABI_ENALBE_EXCEPTIONS=OFF flag and the -DLIBCXX_USE_LLVM_UNWINDER=ON should also be dropped I think. I'll upload a patch to fix this soon, and ask Galina to restart the build-master. You will be able to continue with your work afterward. Sorry about the trouble. / Asiri On Thu, Feb 23, 2017 at 9:13 AM, Ed Schouten via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: ed > Date: Thu Feb 23 03:13:22 2017 > New Revision: 295948 > > URL: http://llvm.org/viewvc/llvm-project?rev=295948&view=rev > Log: > Revert r295944. > > Even though the change works perfectly fine on CloudABI, it fails to > work on the libcxx-libcxxabi-libunwind-arm-linux-noexceptions build bot. > Looking at the code, this may be attributed to the fact that the code > doesn't take the PT_LOAD addresses into consideration. > > I will rework this change to fix that and send out an updated version > for review in the nearby future. > > Modified: > libunwind/trunk/src/AddressSpace.hpp > > Modified: libunwind/trunk/src/AddressSpace.hpp > URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/ > AddressSpace.hpp?rev=295948&r1=295947&r2=295948&view=diff > > == > --- libunwind/trunk/src/AddressSpace.hpp (original) > +++ libunwind/trunk/src/AddressSpace.hpp Thu Feb 23 03:13:22 2017 > @@ -35,17 +35,29 @@ namespace libunwind { > #include "Registers.hpp" > > #if _LIBUNWIND_ARM_EHABI > +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) > + > +typedef void *_Unwind_Ptr; > + > +#elif defined(__linux__) > + > +typedef long unsigned int *_Unwind_Ptr; > +extern "C" _Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr addr, int > *len); > + > +// Emulate the BSD dl_unwind_find_exidx API when on a GNU libdl system. > +#define dl_unwind_find_exidx __gnu_Unwind_Find_exidx > + > +#elif !defined(_LIBUNWIND_IS_BAREMETAL) > +#include > +#else // !defined(_LIBUNWIND_IS_BAREMETAL) > +// When statically linked on bare-metal, the symbols for the EH table are > looked > +// up without going through the dynamic loader. > struct EHTEntry { >uint32_t functionOffset; >uint32_t unwindOpcodes; > }; > -#if defined(_LIBUNWIND_IS_BAREMETAL) > -// When statically linked on bare-metal, the symbols for the EH table are > looked > -// up without going through the dynamic loader. > extern EHTEntry __exidx_start; > extern EHTEntry __exidx_end; > -#else > -#include > #endif // !defined(_LIBUNWIND_IS_BAREMETAL) > #endif // _LIBUNWIND_ARM_EHABI > > @@ -356,15 +368,23 @@ inline bool LocalAddressSpace::findUnwin > info.compact_unwind_section_length = dyldInfo.compact_unwind_ > section_length; > return true; >} > -#elif _LIBUNWIND_ARM_EHABI && defined(_LIBUNWIND_IS_BAREMETAL) > +#elif _LIBUNWIND_ARM_EHABI > + #ifdef _LIBUNWIND_IS_BAREMETAL >// Bare metal is statically linked, so no need to ask the dynamic loader >info.arm_section =(uintptr_t)(&__exidx_start); >info.arm_section_length = (uintptr_t)(&__exidx_end - &__exidx_start); > + #else > + int length = 0; > + info.arm_section = (uintptr_t) dl_unwind_find_exidx( > + (_Unwind_Ptr) targetAddr, &length); > + info.arm_section_length = (uintptr_t)length; > + #endif >_LIBUNWIND_TRACE_UNWINDING("findUnwindSections: section %X length %x", > info.arm_section, info.arm_section_length); >if (info.arm_section && info.arm_section_length) > return true; > -#elif _LIBUNWIND_ARM_EHABI || _LIBUNWIND_SUPPORT_DWARF_UNWIND > +#elif _LIBUNWIND_SUPPORT_DWARF_UNWIND > +#if _LIBUNWIND_SUPPORT_DWARF_INDEX >struct dl_iterate_cb_data { > LocalAddressSpace *addressSpace; > UnwindInfoSections *sects; > @@ -375,6 +395,9 @@ inline bool LocalAddressSpace::findUnwin >int found = dl_iterate_phdr( >[](struct dl_phdr_info *pinfo, size_t, void *data) -> int { > auto cbdata = static_cast(data); > +size_t object_length; > +bool found_obj = false; > +bool found_hdr = false; > > assert(cbdata); > assert(cbdata->sects); > @@ -390,14 +413,6 @@ inline bool LocalAddressSpace::findUnwin > typedef ElfW(Phdr) Elf_Phdr; > #endif > > - #if _LIBUNWIND_SUPPORT_DWARF_UNWIND > - #if !_LIBUNWIND_SUPPORT_DWARF_INDEX > - #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires > _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform." > - #endif > -size_t object_length; > -bool found_obj = false; > -bool found_hdr = false; > - > for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) { >const Elf_Phdr *phdr = &pinfo->dlpi_phdr[i]; >
[PATCH] D30289: [Analyzer] Add bug visitor for taint checker
NoQ added a comment. Yay, this is awesome! It's actually possible to test visitors with the `-analyzer-output=text` option. This option converts path notes to `note:` diagnostics, which you can catch with `expected-note{{}}`, see `test/Analysis/inlining/path-notes.c` for an example (well, it's also possible to test this with other `-analyzer-output` variants, but that'd be an overkill). Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:109 + private: +const SVal S; + Could you call this `V`? Because `S` is often a statement pointer (so often that you actually shadow this member with a local statement later). Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:681 + else if (State->isTainted(E, C.getLocationContext())) +TaintedSVal = State->getSVal(E, C.getLocationContext()); + else `C.getSVal(E)` Promoting the new fancy helper function^^ https://reviews.llvm.org/D30289 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libunwind] r295948 - Revert r295944.
Hi there, 2017-02-23 10:37 GMT+01:00 Asiri Rathnayake : > I have a feeling that the no-exceptions builders are missing a few > configuration bits. > > "No-exceptions" libraries should not require libunwind... > > Looking at the cmake configs: > http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux-noexceptions/builds/430/steps/cmake/logs/stdio > > I see that it's missing the -DLIBCXXABI_ENALBE_EXCEPTIONS=OFF flag and the > -DLIBCXX_USE_LLVM_UNWINDER=ON should also be dropped I think. > > I'll upload a patch to fix this soon, and ask Galina to restart the > build-master. You will be able to continue with your work afterward. > > Sorry about the trouble. No problem whatsoever! It looks like the change I made doesn't just break the *-noexceptions builders; it breaks ARM in general: http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux/builds/396 Still good that we uncovered a potential misconfiguration in the builders as a result. Best regards, -- Ed Schouten Nuxi, 's-Hertogenbosch, the Netherlands KvK-nr.: 62051717 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30290: [libcxx][zorg] Fix no-exceptions builder configurations
rmaprath created this revision. Herald added a reviewer: EricWF. The no-exceptions builders are missing the -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF flag (without this, only the libc++ libraries will be built without exceptions support, libc++abi will still be built with exceptions support - this is not a meaningful configuration). Also we should not need to link in libunwind for these configurations. No-exceptions libraries by definition should not require an unwinder. https://reviews.llvm.org/D30290 Files: buildbot/osuosl/master/config/builders.py Index: buildbot/osuosl/master/config/builders.py === --- buildbot/osuosl/master/config/builders.py +++ buildbot/osuosl/master/config/builders.py @@ -1044,7 +1044,8 @@ 'builddir': 'libcxx-libcxxabi-x86_64-linux-debian-noexceptions', 'factory': LibcxxAndAbiBuilder.getLibcxxAndAbiBuilder( env={'CC': 'clang', 'CXX': 'clang++'}, - cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF'}, + cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF'}, lit_extra_args=['--shuffle']), 'category': 'libcxx'}, @@ -1183,17 +1184,17 @@ 'CMAKE_CXX_FLAGS': '-mcpu=cortex-a15 -marm', 'LLVM_PARALLEL_LINK_JOBS': '2'})}, -{'name': 'libcxx-libcxxabi-libunwind-arm-linux-noexceptions', +{'name': 'libcxx-libcxxabi-arm-linux-noexceptions', 'slavenames': ['linaro-tk1-01'], - 'builddir': 'libcxx-libcxxabi-libunwind-arm-linux-noexceptions', + 'builddir': 'libcxx-libcxxabi-arm-linux-noexceptions', 'category': 'libcxx', 'factory': LibcxxAndAbiBuilder.getLibcxxAndAbiBuilder( env={'CC': 'clang', 'CXX': 'clang++', 'PATH': '/usr/lib/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/llvm/bin'}, # FIXME: there should be a way to merge autodetected with user-defined linker flags # See: libcxxabi/test/lit.cfg -lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -lunwind -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-armhf"'}, -cmake_extra_opts={'LIBCXXABI_USE_LLVM_UNWINDER': 'ON', - 'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', +lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-armhf"'}, +cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF', 'CMAKE_C_FLAGS': '-mcpu=cortex-a15 -mthumb', 'CMAKE_CXX_FLAGS': '-mcpu=cortex-a15 -mthumb', 'LLVM_PARALLEL_LINK_JOBS': '2'})}, @@ -1212,18 +1213,18 @@ cmake_extra_opts={'LIBCXXABI_USE_LLVM_UNWINDER': 'ON', 'LLVM_PARALLEL_LINK_JOBS': '4'})}, -{'name': 'libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions', +{'name': 'libcxx-libcxxabi-aarch64-linux-noexceptions', 'slavenames': ['linaro-apm-03'], - 'builddir': 'libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions', + 'builddir': 'libcxx-libcxxabi-aarch64-linux-noexceptions', 'category': 'libcxx', 'factory': LibcxxAndAbiBuilder.getLibcxxAndAbiBuilder( # FIXME: CFLAGS / CXXFLAGS are here because cmake_extra_opts doesn't quote correctly env={'CC': 'clang', 'CXX': 'clang++', 'CFLAGS': '-mcpu=cortex-a57', 'CXXFLAGS': '-mcpu=cortex-a57'}, # FIXME: there should be a way to merge autodetected with user-defined linker flags # See: libcxxabi/test/lit.cfg -lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -lunwind -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-aarch64"'}, -cmake_extra_opts={'LIBCXXABI_USE_LLVM_UNWINDER': 'ON', - 'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', +lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-aarch64"'}, +cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF', 'LLVM_PARALLEL_LINK_JOBS': '4'})}, ] Index: buildbot/osuosl/master/config/builders.py === --- buildbot/osuosl/master/config/builders.py +++ buildbot/osuosl/master/config/builders.py @@ -1044,7 +1044,8 @@ 'builddir': 'libcxx-libcxxabi-x86_64-linux-debian-noexceptions', 'factory': LibcxxAndAbiBuilder.getLibcxxAndAbiBuilder( env={'CC': 'clang', 'CXX': 'clang++'}, - cmake_extra_opts={'LIBCXX_E
RE: r295843 - [OpenCL] r600 needs OpenCL kernel calling convention
Sure! No objections here! Thanks, Anastasia -Original Message- From: hwennb...@google.com [mailto:hwennb...@google.com] On Behalf Of Hans Wennborg Sent: 22 February 2017 18:10 To: Jan Vesely Cc: cfe-commits; Matt Arsenault; Anastasia Stulova Subject: Re: r295843 - [OpenCL] r600 needs OpenCL kernel calling convention I'm OK with it if either Matt or Anastasia agrees. Thanks, Hans On Wed, Feb 22, 2017 at 7:20 AM, Jan Vesely wrote: > Hi Hans, > > I'd like this commit to make it to 4.0. I'm not sure if it falls under > OpenCL or AMDGPU so I've added both Matt and Anastasia to cc. > > thank you, > Jan > > On Wed, 2017-02-22 at 15:01 +, Jan Vesely via cfe-commits wrote: >> Author: jvesely >> Date: Wed Feb 22 09:01:42 2017 >> New Revision: 295843 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=295843&view=rev >> Log: >> [OpenCL] r600 needs OpenCL kernel calling convention >> >> Differential Revision: https://reviews.llvm.org/D30236 >> >> Modified: >> cfe/trunk/lib/Sema/SemaType.cpp >> cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl >> >> Modified: cfe/trunk/lib/Sema/SemaType.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?r >> ev=295843&r1=295842&r2=295843&view=diff >> = >> = >> --- cfe/trunk/lib/Sema/SemaType.cpp (original) >> +++ cfe/trunk/lib/Sema/SemaType.cpp Wed Feb 22 09:01:42 2017 >> @@ -3175,7 +3175,7 @@ getCCForDeclaratorChunk(Sema &S, Declara >>if (Attr->getKind() == AttributeList::AT_OpenCLKernel) { >> llvm::Triple::ArchType arch = >> S.Context.getTargetInfo().getTriple().getArch(); >> if (arch == llvm::Triple::spir || arch == llvm::Triple::spir64 || >> -arch == llvm::Triple::amdgcn) { >> +arch == llvm::Triple::amdgcn || arch == >> + llvm::Triple::r600) { >>CC = CC_OpenCLKernel; >> } >> break; >> >> Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdg >> pu-abi-struct-coerce.cl?rev=295843&r1=295842&r2=295843&view=diff >> = >> = >> --- cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl >> (original) >> +++ cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl Wed Feb >> +++ 22 09:01:42 2017 >> @@ -1,5 +1,6 @@ >> // REQUIRES: amdgpu-registered-target // RUN: %clang_cc1 -triple >> amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s >> +// RUN: %clang_cc1 -triple r600-unknown-unknown -S -emit-llvm -o - >> +%s | FileCheck %s >> >> // CHECK-NOT: %struct.single_element_struct_arg = type { i32 } >> typedef struct single_element_struct_arg >> >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.
sammccall updated this revision to Diff 89484. sammccall marked 4 inline comments as done. sammccall added a comment. Address review comments. https://reviews.llvm.org/D30210 Files: include-fixer/InMemorySymbolIndex.cpp include-fixer/InMemorySymbolIndex.h include-fixer/IncludeFixer.cpp include-fixer/SymbolIndex.h include-fixer/SymbolIndexManager.cpp include-fixer/YamlSymbolIndex.cpp include-fixer/YamlSymbolIndex.h include-fixer/find-all-symbols/FindAllMacros.cpp include-fixer/find-all-symbols/FindAllMacros.h include-fixer/find-all-symbols/FindAllSymbols.cpp include-fixer/find-all-symbols/FindAllSymbols.h include-fixer/find-all-symbols/SymbolInfo.cpp include-fixer/find-all-symbols/SymbolInfo.h include-fixer/find-all-symbols/SymbolReporter.h include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp include-fixer/tool/ClangIncludeFixer.cpp test/include-fixer/Inputs/fake_yaml_db.yaml test/include-fixer/Inputs/merge/a.yaml test/include-fixer/Inputs/merge/b.yaml test/include-fixer/merge.test unittests/include-fixer/IncludeFixerTest.cpp unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp === --- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp +++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp @@ -19,6 +19,7 @@ #include "clang/Frontend/PCHContainerOperations.h" #include "clang/Tooling/Tooling.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/MemoryBuffer.h" #include "gtest/gtest.h" @@ -35,30 +36,35 @@ public: ~TestSymbolReporter() override {} - void reportSymbol(llvm::StringRef FileName, -const SymbolInfo &Symbol) override { -Symbols.push_back(Symbol); + void reportSymbols(llvm::StringRef FileName, + SymbolInfo::SignalMap NewSymbols) override { +for (const auto &Entry : NewSymbols) + Symbols[Entry.first] += Entry.second; } bool hasSymbol(const SymbolInfo &Symbol) const { -for (const auto &S : Symbols) { - if (S == Symbol) -return true; -} -return false; +auto it = Symbols.find(Symbol); +return it != Symbols.end() && it->second.Seen > 0; + } + + bool hasUse(const SymbolInfo &Symbol) const { +auto it = Symbols.find(Symbol); +return it != Symbols.end() && it->second.Used > 0; } private: - std::vector Symbols; + SymbolInfo::SignalMap Symbols; }; class FindAllSymbolsTest : public ::testing::Test { public: bool hasSymbol(const SymbolInfo &Symbol) { return Reporter.hasSymbol(Symbol); } - bool runFindAllSymbols(StringRef Code) { + bool hasUse(const SymbolInfo &Symbol) { return Reporter.hasUse(Symbol); } + + bool runFindAllSymbols(StringRef HeaderCode, StringRef MainCode) { llvm::IntrusiveRefCntPtr InMemoryFileSystem( new vfs::InMemoryFileSystem); llvm::IntrusiveRefCntPtr Files( @@ -98,7 +104,7 @@ std::make_shared()); InMemoryFileSystem->addFile(HeaderName, 0, -llvm::MemoryBuffer::getMemBuffer(Code)); +llvm::MemoryBuffer::getMemBuffer(HeaderCode)); std::string Content = "#include\"" + std::string(HeaderName) + "\"\n" @@ -118,6 +124,7 @@ SymbolInfo DirtySymbol("ExtraInternal", SymbolInfo::SymbolKind::Class, CleanHeader, 2, {}); #endif // _MSC_VER && __MINGW32__ +Content += "\n" + MainCode.str(); InMemoryFileSystem->addFile(FileName, 0, llvm::MemoryBuffer::getMemBuffer(Content)); Invocation.run(); @@ -135,49 +142,64 @@ }; TEST_F(FindAllSymbolsTest, VariableSymbols) { - static const char Code[] = R"( + static const char Header[] = R"( extern int xargc; namespace na { static bool = false; namespace nb { const long long *; } })"; - runFindAllSymbols(Code); + static const char Main[] = R"( + auto y = &na::nb::; + int main() { if (na::) return xargc; } + )"; + runFindAllSymbols(Header, Main); SymbolInfo Symbol = SymbolInfo("xargc", SymbolInfo::SymbolKind::Variable, HeaderName, 2, {}); EXPECT_TRUE(hasSymbol(Symbol)); + EXPECT_TRUE(hasUse(Symbol)); Symbol = SymbolInfo("", SymbolInfo::SymbolKind::Variable, HeaderName, 4, {{SymbolInfo::ContextType::Namespace, "na"}}); EXPECT_TRUE(hasSymbol(Symbol)); + EXPECT_TRUE(hasUse(Symbol)); Symbol = SymbolInfo("", SymbolInfo::SymbolKind::Variable, HeaderName, 5, {{SymbolInfo::ContextType::Namespace, "nb"}, {SymbolInfo::ContextType::Namespace, "na"}}); EXPECT_TRUE(hasSymbol(Symbol)); + EXPECT_TRUE(hasUse(Symbol)); } TEST_F(FindAllSymbolsTest, Exte
[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.
sammccall added inline comments. Comment at: include-fixer/InMemorySymbolIndex.h:27 - std::vector + std::vector search(llvm::StringRef Identifier) override; hokein wrote: > There are many places using > `std::vector`. Maybe we can use a > type alias for it, so that we can type less. I guess? It's the namespaces that are the problem (vector is fine) and most of the namespace noise wouldn't go away here. is `clang::find_all_symbols::SymbolsSignalsList` better enough to obscure what the actual type is? It's 45 chars vs 54. IMO it's not worth it here, though `clang::find_all_symbols::SymbolInfo::SignalMap` vs `std::map` is. Comment at: include-fixer/find-all-symbols/FindAllMacros.h:39 + + void Ifdef(SourceLocation Loc, const Token &MacroNameTok, + const MacroDefinition &MD) override; hokein wrote: > We are missing tests for these macro usages. These are covered by FindAllSymbolsTests, which (despite the name) tests the whole FindAllSymbolsAction. Specifically, MacroTest and MacroTestWithIWYU cover these. Comment at: include-fixer/find-all-symbols/SymbolInfo.h:50 + // used. These are used to rank results. + struct Signals { +Signals() {} hokein wrote: > I think we can make a standalone class instead of making it a nested class of > `SymbolInfo` because I don't see strong relationship between them. Maybe name > it `FindingSignals` or `FindingInfo`. The relationship between them is a strong scoping one: signals only make sense in the context of a particular SymbolInfo. If it was a parallel top-level class, it needs a name that communicates this relationship, most likely SymbolSignals. I don't think that's significantly better than SymbolInfo::Signals. (If I had my druthers, these would probably be Symbol and Symbol::Signals - the "info" is the main reason that SymbolInfo::Signals is noisy. But not worth the churn I think) Comment at: include-fixer/find-all-symbols/SymbolInfo.h:101 private: - friend struct llvm::yaml::MappingTraits; + friend struct llvm::yaml::MappingTraits; hokein wrote: > I'd put this statement inside `SymbolAndSignals`. That won't compile: it's the members of SymbolInfo that are private, not the members of SymbolAndSignals. Comment at: include-fixer/find-all-symbols/SymbolInfo.h:129 - /// \brief The number of times this symbol was found during an indexing - /// run. Populated by the reducer and used to rank results. - unsigned NumOccurrences; +struct SymbolAndSignals { + SymbolInfo Symbol; hokein wrote: > Not much better idea on names, how about `SymbolFinding`? > > ``` > struct SymbolFinding { >SymbolInfo Symbol; >FindingInfo Finding; > }; > ``` I don't think SymbolFinding is better: - it can be misinterpreted as finding *for* a signal, not findings *and* a signal. I think the And is important - "finding" is vague while "signal" is more specific. I changed this from finding -> signal already based on a discussion with Ben, if you do want to change this we should sync up offline :) https://reviews.llvm.org/D30210 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30290: [libcxx][zorg] Fix no-exceptions builder configurations
rengolin added inline comments. Comment at: buildbot/osuosl/master/config/builders.py:1196 +lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-armhf"'}, +cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF', Why remove the unwinder? https://reviews.llvm.org/D30290 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30290: [libcxx][zorg] Fix no-exceptions builder configurations
rmaprath added inline comments. Comment at: buildbot/osuosl/master/config/builders.py:1196 +lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-armhf"'}, +cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF', rengolin wrote: > Why remove the unwinder? The unwinder should not be required for the no-exceptions library testing, as these libraries do not throw/catch any exceptions. / Asiri https://reviews.llvm.org/D30290 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30290: [libcxx][zorg] Fix no-exceptions builder configurations
rengolin added inline comments. Comment at: buildbot/osuosl/master/config/builders.py:1196 +lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-armhf"'}, +cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF', rmaprath wrote: > rengolin wrote: > > Why remove the unwinder? > The unwinder should not be required for the no-exceptions library testing, as > these libraries do not throw/catch any exceptions. > > / Asiri But the requirement is not only to test it, but to make them work. We had trouble making the bot pass without the unwinder, due to dependencies. Regardless, this is a *different* change and should be made later, with proper research. For now, just add the new flag, please. https://reviews.llvm.org/D30290 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28278: [StaticAnalyzer] dont show wrong 'garbage value' warning when there is array index out of bounds
danielmarjamaki added a comment. In https://reviews.llvm.org/D28278#677905, @zaks.anna wrote: > Does the code you added detects array out of bounds cases without false > positives? Is it an option to just have this checkers produce a more precise > error message in the specific case. > > A lot of work will probably need to be done to implement a proper array out > of bounds checking and no-one is working on that. I don't know.. maybe I can avoid some false positive. Maybe if the left operand seems to be out-of-bounds and the right operand is uninitialized maybe it would be better to complain about the right operand. It is definitely an option for me to have this checker produce more precise error messages. I believe that will solve my problems. Repository: rL LLVM https://reviews.llvm.org/D28278 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30290: [libcxx][zorg] Fix no-exceptions builder configurations
rmaprath updated this revision to Diff 89485. rmaprath added a comment. Updated to address comments from @rengolin. In theory, it should not be necessary to link-in or enable the unwinder for these tests. However, it is best to leave this for a separate patch (after some local testing), just to make sure that none of those other libraries attempt to reference symbols from the unwinder (they should not, but who knows...). https://reviews.llvm.org/D30290 Files: buildbot/osuosl/master/config/builders.py Index: buildbot/osuosl/master/config/builders.py === --- buildbot/osuosl/master/config/builders.py +++ buildbot/osuosl/master/config/builders.py @@ -1044,7 +1044,8 @@ 'builddir': 'libcxx-libcxxabi-x86_64-linux-debian-noexceptions', 'factory': LibcxxAndAbiBuilder.getLibcxxAndAbiBuilder( env={'CC': 'clang', 'CXX': 'clang++'}, - cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF'}, + cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF'}, lit_extra_args=['--shuffle']), 'category': 'libcxx'}, @@ -1194,6 +1195,7 @@ lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -lunwind -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-armhf"'}, cmake_extra_opts={'LIBCXXABI_USE_LLVM_UNWINDER': 'ON', 'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF', 'CMAKE_C_FLAGS': '-mcpu=cortex-a15 -mthumb', 'CMAKE_CXX_FLAGS': '-mcpu=cortex-a15 -mthumb', 'LLVM_PARALLEL_LINK_JOBS': '2'})}, @@ -1224,6 +1226,7 @@ lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -lunwind -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-aarch64"'}, cmake_extra_opts={'LIBCXXABI_USE_LLVM_UNWINDER': 'ON', 'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF', 'LLVM_PARALLEL_LINK_JOBS': '4'})}, ] Index: buildbot/osuosl/master/config/builders.py === --- buildbot/osuosl/master/config/builders.py +++ buildbot/osuosl/master/config/builders.py @@ -1044,7 +1044,8 @@ 'builddir': 'libcxx-libcxxabi-x86_64-linux-debian-noexceptions', 'factory': LibcxxAndAbiBuilder.getLibcxxAndAbiBuilder( env={'CC': 'clang', 'CXX': 'clang++'}, - cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF'}, + cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF'}, lit_extra_args=['--shuffle']), 'category': 'libcxx'}, @@ -1194,6 +1195,7 @@ lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -lunwind -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-armhf"'}, cmake_extra_opts={'LIBCXXABI_USE_LLVM_UNWINDER': 'ON', 'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF', 'CMAKE_C_FLAGS': '-mcpu=cortex-a15 -mthumb', 'CMAKE_CXX_FLAGS': '-mcpu=cortex-a15 -mthumb', 'LLVM_PARALLEL_LINK_JOBS': '2'})}, @@ -1224,6 +1226,7 @@ lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -lunwind -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-aarch64"'}, cmake_extra_opts={'LIBCXXABI_USE_LLVM_UNWINDER': 'ON', 'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF', 'LLVM_PARALLEL_LINK_JOBS': '4'})}, ] ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30290: [libcxx][zorg] Fix no-exceptions builder configurations
rmaprath marked an inline comment as done. rmaprath added inline comments. Comment at: buildbot/osuosl/master/config/builders.py:1196 +lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-armhf"'}, +cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF', rengolin wrote: > rmaprath wrote: > > rengolin wrote: > > > Why remove the unwinder? > > The unwinder should not be required for the no-exceptions library testing, > > as these libraries do not throw/catch any exceptions. > > > > / Asiri > But the requirement is not only to test it, but to make them work. We had > trouble making the bot pass without the unwinder, due to dependencies. > > Regardless, this is a *different* change and should be made later, with > proper research. For now, just add the new flag, please. If you have a time (heh!), please do try out without the unwinder and see if it still works fine. I'll be quite interested if it doesn't. Downstream we have even more stricter tests to make sure there are no exception tables in the final binaries, but this require special linker options. It would be good to make sure that we can at least do without the unwinder upstream :) https://reviews.llvm.org/D30290 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30290: [libcxx][zorg] Fix no-exceptions builder configurations
rengolin accepted this revision. rengolin added a comment. This revision is now accepted and ready to land. LGTM, thanks! I'll add a local task to look into that, but with Connect coming, I'm not sure how long that will take. :) https://reviews.llvm.org/D30290 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30285: [ubsan] Don't check alignment if the alignment is 1
filcab accepted this revision. filcab added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D30285 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30290: [libcxx][zorg] Fix no-exceptions builder configurations
This revision was automatically updated to reflect the committed changes. Closed by commit rL295963: [zorg] Fix no-exceptions libcxx configurations (authored by asiri). Changed prior to commit: https://reviews.llvm.org/D30290?vs=89485&id=89496#toc Repository: rL LLVM https://reviews.llvm.org/D30290 Files: zorg/trunk/buildbot/osuosl/master/config/builders.py Index: zorg/trunk/buildbot/osuosl/master/config/builders.py === --- zorg/trunk/buildbot/osuosl/master/config/builders.py +++ zorg/trunk/buildbot/osuosl/master/config/builders.py @@ -1044,7 +1044,8 @@ 'builddir': 'libcxx-libcxxabi-x86_64-linux-debian-noexceptions', 'factory': LibcxxAndAbiBuilder.getLibcxxAndAbiBuilder( env={'CC': 'clang', 'CXX': 'clang++'}, - cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF'}, + cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF'}, lit_extra_args=['--shuffle']), 'category': 'libcxx'}, @@ -1194,6 +1195,7 @@ lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -lunwind -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-armhf"'}, cmake_extra_opts={'LIBCXXABI_USE_LLVM_UNWINDER': 'ON', 'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF', 'CMAKE_C_FLAGS': '-mcpu=cortex-a15 -mthumb', 'CMAKE_CXX_FLAGS': '-mcpu=cortex-a15 -mthumb', 'LLVM_PARALLEL_LINK_JOBS': '2'})}, @@ -1224,6 +1226,7 @@ lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -lunwind -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-aarch64"'}, cmake_extra_opts={'LIBCXXABI_USE_LLVM_UNWINDER': 'ON', 'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF', 'LLVM_PARALLEL_LINK_JOBS': '4'})}, ] Index: zorg/trunk/buildbot/osuosl/master/config/builders.py === --- zorg/trunk/buildbot/osuosl/master/config/builders.py +++ zorg/trunk/buildbot/osuosl/master/config/builders.py @@ -1044,7 +1044,8 @@ 'builddir': 'libcxx-libcxxabi-x86_64-linux-debian-noexceptions', 'factory': LibcxxAndAbiBuilder.getLibcxxAndAbiBuilder( env={'CC': 'clang', 'CXX': 'clang++'}, - cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF'}, + cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF'}, lit_extra_args=['--shuffle']), 'category': 'libcxx'}, @@ -1194,6 +1195,7 @@ lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -lunwind -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-armhf"'}, cmake_extra_opts={'LIBCXXABI_USE_LLVM_UNWINDER': 'ON', 'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF', 'CMAKE_C_FLAGS': '-mcpu=cortex-a15 -mthumb', 'CMAKE_CXX_FLAGS': '-mcpu=cortex-a15 -mthumb', 'LLVM_PARALLEL_LINK_JOBS': '2'})}, @@ -1224,6 +1226,7 @@ lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread -lunwind -ldl -L/opt/llvm/lib/clang/3.9.0/lib/linux -lclang_rt.builtins-aarch64"'}, cmake_extra_opts={'LIBCXXABI_USE_LLVM_UNWINDER': 'ON', 'LIBCXX_ENABLE_EXCEPTIONS': 'OFF', + 'LIBCXXABI_ENABLE_EXCEPTIONS': 'OFF', 'LLVM_PARALLEL_LINK_JOBS': '4'})}, ] ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30289: [Analyzer] Add bug visitor for taint checker
vlad.tsyrklevich updated this revision to Diff 89497. vlad.tsyrklevich marked 2 inline comments as done. vlad.tsyrklevich added a comment. Fixes and a test for Artem's suggestions. https://reviews.llvm.org/D30289 Files: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp test/Analysis/taint-diagnostic-visitor.c Index: test/Analysis/taint-diagnostic-visitor.c === --- /dev/null +++ test/Analysis/taint-diagnostic-visitor.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.security.taint,core -analyzer-output=text -verify %s + +// This file is for testing enhanced diagnostics produced by the GenericTaintChecker + +int scanf(const char *restrict format, ...); +int system(const char *command); + +void taintDiagnostic() +{ + char buf[128]; + scanf("%s", buf); // expected-note {{Taint originated here}} + system(buf); // expected-warning {{Untrusted data is passed to a system call}} // expected-note {{Untrusted data is passed to a system call (CERT/STR02-C. Sanitize data passed to complex subsystems)}} +} Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp === --- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp +++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp @@ -101,6 +101,22 @@ bool generateReportIfTainted(const Expr *E, const char Msg[], CheckerContext &C) const; + /// The bug visitor prints a diagnostic message at the location where a given + /// variable was tainted. + class TaintBugVisitor + : public BugReporterVisitorImpl { + private: +const SVal V; + + public: +TaintBugVisitor(const SVal V) : V(V) {} +void Profile(llvm::FoldingSetNodeID &ID) const override { ID.Add(V); } + +std::shared_ptr VisitNode(const ExplodedNode *N, + const ExplodedNode *PrevN, + BugReporterContext &BRC, + BugReport &BR) override; + }; typedef SmallVector ArgVector; @@ -194,6 +210,28 @@ /// points to data, which should be tainted on return. REGISTER_SET_WITH_PROGRAMSTATE(TaintArgsOnPostVisit, unsigned) +std::shared_ptr +GenericTaintChecker::TaintBugVisitor::VisitNode(const ExplodedNode *N, +const ExplodedNode *PrevN, BugReporterContext &BRC, BugReport &BR) { + + // Find the ExplodedNode where the taint was first introduced + if (!N->getState()->isTainted(V) || PrevN->getState()->isTainted(V)) +return nullptr; + + const Stmt *S = PathDiagnosticLocation::getStmt(N); + if (!S) +return nullptr; + + const LocationContext *NCtx = N->getLocationContext(); + PathDiagnosticLocation L = + PathDiagnosticLocation::createBegin(S, BRC.getSourceManager(), NCtx); + if (!L.isValid() || !L.asLocation().isValid()) +return nullptr; + + return std::make_shared( + L, "Taint originated here"); +} + GenericTaintChecker::TaintPropagationRule GenericTaintChecker::TaintPropagationRule::getTaintPropagationRule( const FunctionDecl *FDecl, @@ -635,15 +673,21 @@ // Check for taint. ProgramStateRef State = C.getState(); - if (!State->isTainted(getPointedToSymbol(C, E)) && - !State->isTainted(E, C.getLocationContext())) + const SymbolRef PointedToSym = getPointedToSymbol(C, E); + SVal TaintedSVal; + if (State->isTainted(PointedToSym)) +TaintedSVal = nonloc::SymbolVal(PointedToSym); + else if (State->isTainted(E, C.getLocationContext())) +TaintedSVal = C.getSVal(E); + else return false; // Generate diagnostic. if (ExplodedNode *N = C.generateNonFatalErrorNode()) { initBugType(); auto report = llvm::make_unique(*BT, Msg, N); report->addRange(E->getSourceRange()); +report->addVisitor(llvm::make_unique(TaintedSVal)); C.emitReport(std::move(report)); return true; } Index: test/Analysis/taint-diagnostic-visitor.c === --- /dev/null +++ test/Analysis/taint-diagnostic-visitor.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.security.taint,core -analyzer-output=text -verify %s + +// This file is for testing enhanced diagnostics produced by the GenericTaintChecker + +int scanf(const char *restrict format, ...); +int system(const char *command); + +void taintDiagnostic() +{ + char buf[128]; + scanf("%s", buf); // expected-note {{Taint originated here}} + system(buf); // expected-warning {{Untrusted data is passed to a system call}} // expected-note {{Untrusted data is passed to a system call (CERT/STR02-C. Sanitize data passed to complex subsystems)}} +} Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp === --- lib/StaticAnalyzer/Checkers/GenericTaintChecker
[PATCH] D30290: [libcxx][zorg] Fix no-exceptions builder configurations
rmaprath marked an inline comment as done. rmaprath added a comment. Thanks! Committed as r295963. @gkistanova: Could you please let me know when the next restart is due? I would like to keep an eye on the builders. Cheers, / Asiri Repository: rL LLVM https://reviews.llvm.org/D30290 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30295: [analyzer] clarify undef shift result when shift count is negative or exceeds the bit width
danielmarjamaki created this revision. The error messages are confusing when shift result is undefined because the shift count is negative or exceeds the bit width. I have seen that users often draw the conclusion that Clang thinks some operand is uninitialized and determine that Clang shows a false positive. I also know that some users use negative shift count by intention and don't think that would cause problems. This patch clarify the error message and refactors the code a little. Repository: rL LLVM https://reviews.llvm.org/D30295 Files: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h lib/StaticAnalyzer/Checkers/ConversionChecker.cpp lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp lib/StaticAnalyzer/Core/CheckerHelpers.cpp test/Analysis/bitwise-ops.c Index: test/Analysis/bitwise-ops.c === --- test/Analysis/bitwise-ops.c +++ test/Analysis/bitwise-ops.c @@ -29,4 +29,18 @@ default: return 0; } -} \ No newline at end of file +} + +int testOverflowShift(int a) { + if (a == 323) { +return 1 << a; // expected-warning{{The result of the '<<' expression is undefined due to shift count >= width of type}} + } + return 0; +} + +int testNegativeShift(int a) { + if (a == -5) { +return 1 << a; // expected-warning{{The result of the '<<' expression is undefined due to negative value on the right side of operand}} + } + return 0; +} Index: lib/StaticAnalyzer/Core/CheckerHelpers.cpp === --- lib/StaticAnalyzer/Core/CheckerHelpers.cpp +++ lib/StaticAnalyzer/Core/CheckerHelpers.cpp @@ -94,3 +94,37 @@ return std::make_pair(VD, RHS); } + +bool clang::ento::isExprResultConformsComparisonRule(CheckerContext &C, + BinaryOperatorKind BOK, + const Expr *LExpr, + const SVal RVal) { + ProgramStateRef State = C.getState(); + + SVal LVal = C.getSVal(LExpr); + if (LVal.isUnknownOrUndef() || !LVal.getAs()) +return false; + + SValBuilder &Bldr = C.getSValBuilder(); + SVal Eval = Bldr.evalBinOp(State, BOK, LVal, RVal, Bldr.getConditionType()); + if (Eval.isUnknownOrUndef()) +return false; + + ConstraintManager &CM = C.getConstraintManager(); + ProgramStateRef StTrue, StFalse; + std::tie(StTrue, StFalse) = CM.assumeDual(State, Eval.castAs()); + return StTrue && !StFalse; +} + +// Is E value greater or equal than Val? +bool clang::ento::isGreaterEqual(CheckerContext &C, const Expr *E, + unsigned long long Val) { + DefinedSVal V = C.getSValBuilder().makeIntVal(Val, C.getASTContext().LongLongTy); + return isExprResultConformsComparisonRule(C, BO_GE, E, V); +} + +// Is E value negative? +bool clang::ento::isNegative(CheckerContext &C, const Expr *E) { + DefinedSVal V = C.getSValBuilder().makeIntVal(0, false); + return isExprResultConformsComparisonRule(C, BO_LT, E, V); +} Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp === --- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp +++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp @@ -17,6 +17,7 @@ #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/raw_ostream.h" @@ -35,6 +36,11 @@ }; } // end anonymous namespace +bool isShiftOverflow(CheckerContext &C, const BinaryOperator *B) { + return isGreaterEqual(C, B->getRHS(), +C.getASTContext().getIntWidth(B->getLHS()->getType())); +} + void UndefResultChecker::checkPostStmt(const BinaryOperator *B, CheckerContext &C) const { ProgramStateRef state = C.getState(); @@ -80,9 +86,24 @@ } else { // Neither operand was undefined, but the result is undefined. - OS << "The result of the '" - << BinaryOperator::getOpcodeStr(B->getOpcode()) - << "' expression is undefined"; + if ((B->getOpcode() == BinaryOperatorKind::BO_Shl || + B->getOpcode() == BinaryOperatorKind::BO_Shr) && + isNegative(C, B->getRHS())) { +OS << "The result of the '" + << BinaryOperator::getOpcodeStr(B->getOpcode()) + << "' expression is undefined due to negative value on the right " + "side of operand"; + } else if ((B->getOpcode() == BinaryOperatorKind::BO_Shl || + B->getOpcode() == BinaryOperatorKind::BO_Shr) && + isShiftOverflow(C, B)) { +OS << "The result of the '" + <<
r295975 - Added regression tests
Author: sepavloff Date: Thu Feb 23 08:34:04 2017 New Revision: 295975 URL: http://llvm.org/viewvc/llvm-project?rev=295975&view=rev Log: Added regression tests Added: cfe/trunk/test/SemaCXX/friend3.cpp Added: cfe/trunk/test/SemaCXX/friend3.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/friend3.cpp?rev=295975&view=auto == --- cfe/trunk/test/SemaCXX/friend3.cpp (added) +++ cfe/trunk/test/SemaCXX/friend3.cpp Thu Feb 23 08:34:04 2017 @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -S -triple i686-pc-linux-gnu -std=c++11 %s -o - | FileCheck %s + +namespace pr8852 { +void foo(); +struct S { + friend void foo() {} +}; + +void main() { + foo(); +} +// CHECK: _ZN6pr88523fooEv: +} + +namespace pr9518 { +template +struct provide { + friend T f() { return T(); } +}; + +void g() { + void f(); + provide p; + f(); +} +// CHECK: _ZN6pr95181fEv: +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r295982 - Reverted r295975
Author: sepavloff Date: Thu Feb 23 09:10:45 2017 New Revision: 295982 URL: http://llvm.org/viewvc/llvm-project?rev=295982&view=rev Log: Reverted r295975 Removed: cfe/trunk/test/SemaCXX/friend3.cpp Removed: cfe/trunk/test/SemaCXX/friend3.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/friend3.cpp?rev=295981&view=auto == --- cfe/trunk/test/SemaCXX/friend3.cpp (original) +++ cfe/trunk/test/SemaCXX/friend3.cpp (removed) @@ -1,27 +0,0 @@ -// RUN: %clang_cc1 -S -triple i686-pc-linux-gnu -std=c++11 %s -o - | FileCheck %s - -namespace pr8852 { -void foo(); -struct S { - friend void foo() {} -}; - -void main() { - foo(); -} -// CHECK: _ZN6pr88523fooEv: -} - -namespace pr9518 { -template -struct provide { - friend T f() { return T(); } -}; - -void g() { - void f(); - provide p; - f(); -} -// CHECK: _ZN6pr95181fEv: -} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.
hokein added inline comments. Comment at: include-fixer/InMemorySymbolIndex.h:27 - std::vector + std::vector search(llvm::StringRef Identifier) override; sammccall wrote: > hokein wrote: > > There are many places using > > `std::vector`. Maybe we can use > > a type alias for it, so that we can type less. > I guess? It's the namespaces that are the problem (vector > is fine) and most of the namespace noise wouldn't go away here. > > is `clang::find_all_symbols::SymbolsSignalsList` better enough to obscure > what the actual type is? It's 45 chars vs 54. > > IMO it's not worth it here, though > `clang::find_all_symbols::SymbolInfo::SignalMap` vs > `std::map clang::find_all_symbols::SymbolInfo::Signals>` is. If we put the type alias under `clang::include_fixer` namespace, it will shorten the name more. Agree it is not worth the effect as the full name only happens in headers. We could save a few characters by getting rid of `clang` because we are always in `clang` namespace. So `std::vector` should work, this looks slightly better. :) Comment at: include-fixer/find-all-symbols/FindAllMacros.cpp:38 + if (auto Symbol = CreateMacroSymbol(MacroNameTok, MD->getMacroInfo())) +FileSymbols[*Symbol].Seen++; +} code style: use prefix `++`. The same below. Comment at: include-fixer/find-all-symbols/FindAllMacros.h:39 + + void Ifdef(SourceLocation Loc, const Token &MacroNameTok, + const MacroDefinition &MD) override; sammccall wrote: > hokein wrote: > > We are missing tests for these macro usages. > These are covered by FindAllSymbolsTests, which (despite the name) tests the > whole FindAllSymbolsAction. > > Specifically, MacroTest and MacroTestWithIWYU cover these. Acked. You combined them in current tests (I originally thought there should be some separate tests for these). Comment at: include-fixer/find-all-symbols/SymbolInfo.cpp:79 const std::vector &Contexts, - unsigned NumOccurrences) + unsigned NumOccurrences, unsigned NumUses) : Name(Name), Type(Type), FilePath(FilePath), Contexts(Contexts), You forgot to update this? Comment at: include-fixer/find-all-symbols/SymbolInfo.h:50 + // used. These are used to rank results. + struct Signals { +Signals() {} sammccall wrote: > hokein wrote: > > I think we can make a standalone class instead of making it a nested class > > of `SymbolInfo` because I don't see strong relationship between them. Maybe > > name it `FindingSignals` or `FindingInfo`. > The relationship between them is a strong scoping one: signals only make > sense in the context of a particular SymbolInfo. > > If it was a parallel top-level class, it needs a name that communicates this > relationship, most likely SymbolSignals. I don't think that's significantly > better than SymbolInfo::Signals. > > (If I had my druthers, these would probably be Symbol and Symbol::Signals - > the "info" is the main reason that SymbolInfo::Signals is noisy. But not > worth the churn I think) > You convinced me. Please keep the comment of `Signals` updated. > If I had my druthers, these would probably be Symbol and Symbol::Signals - > the "info" is the main reason that SymbolInfo::Signals is noisy. But not > worth the churn I think) In the initial design, `SymbolInfo` merely represents a cpp symbol. But as more features developed, `SymbolInfo` might be not a good name at the moment. `Symbol` seems not a better name as LLVM already has many classes named `Symbol`. We can leave it here. Comment at: include-fixer/find-all-symbols/SymbolInfo.h:101 private: - friend struct llvm::yaml::MappingTraits; + friend struct llvm::yaml::MappingTraits; sammccall wrote: > hokein wrote: > > I'd put this statement inside `SymbolAndSignals`. > That won't compile: it's the members of SymbolInfo that are private, not the > members of SymbolAndSignals. Acked. Thanks for explanations. Sorry for misleading. Comment at: include-fixer/find-all-symbols/SymbolInfo.h:129 - /// \brief The number of times this symbol was found during an indexing - /// run. Populated by the reducer and used to rank results. - unsigned NumOccurrences; +struct SymbolAndSignals { + SymbolInfo Symbol; sammccall wrote: > hokein wrote: > > Not much better idea on names, how about `SymbolFinding`? > > > > ``` > > struct SymbolFinding { > >SymbolInfo Symbol; > >FindingInfo Finding; > > }; > > ``` > I don't think SymbolFinding is better: > - it can be misinterpreted as finding *for* a signal, not findings *and* a > signal. I think the And is important > - "finding" is vague while "signal" is more specific. I changed this from > finding -> signal already based on a discussion
Re: Patch for Bug 30413, including test case
Hi Akira, Pardon my slow reply here- I was traveling and just got back to work email. I will check into this as soon as I can, and get back to you. Thank you, David > On Feb 20, 2017, at 12:04 AM, Akira Hatanaka wrote: > > This patch changes the encoding of an id conforming to a protocol, which I > think was not intended: For example: > > @encode(id) > > Would passing IVD to the call to getObjCEncodingForType in > CGObjCGNU::GenerateClass solve the problem? > >> On Feb 15, 2017, at 1:59 PM, Lobron, David via cfe-commits >> wrote: >> >> Hi All, >> >> I am re-submitting my patch for Bug 30413, this time with a test case >> included as well (ivar-type-encoding.m). The test case file should be added >> to clang/test/CodeGenObjC. The test verifies that correct metadata is >> emitted by clang for an object-valued instance variable. I've verified that >> the test passes when the patch has been applied to ASTContext.cpp, and fails >> otherwise. >> >> Please let me know if this looks OK, or if any additional information is >> needed. >> >> Thanks, >> >> David >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.
sammccall updated this revision to Diff 89506. sammccall marked 3 inline comments as done. sammccall added a comment. Address review comments; remove redundant namespace qualifiers; format. https://reviews.llvm.org/D30210 Files: include-fixer/InMemorySymbolIndex.cpp include-fixer/InMemorySymbolIndex.h include-fixer/IncludeFixer.cpp include-fixer/SymbolIndex.h include-fixer/SymbolIndexManager.cpp include-fixer/YamlSymbolIndex.cpp include-fixer/YamlSymbolIndex.h include-fixer/find-all-symbols/FindAllMacros.cpp include-fixer/find-all-symbols/FindAllMacros.h include-fixer/find-all-symbols/FindAllSymbols.cpp include-fixer/find-all-symbols/FindAllSymbols.h include-fixer/find-all-symbols/FindAllSymbolsAction.cpp include-fixer/find-all-symbols/SymbolInfo.cpp include-fixer/find-all-symbols/SymbolInfo.h include-fixer/find-all-symbols/SymbolReporter.h include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp include-fixer/tool/ClangIncludeFixer.cpp test/include-fixer/Inputs/fake_yaml_db.yaml test/include-fixer/Inputs/merge/a.yaml test/include-fixer/Inputs/merge/b.yaml test/include-fixer/merge.test unittests/include-fixer/IncludeFixerTest.cpp unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp === --- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp +++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp @@ -19,6 +19,7 @@ #include "clang/Frontend/PCHContainerOperations.h" #include "clang/Tooling/Tooling.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/MemoryBuffer.h" #include "gtest/gtest.h" @@ -31,34 +32,39 @@ static const char HeaderName[] = "symbols.h"; -class TestSymbolReporter : public clang::find_all_symbols::SymbolReporter { +class TestSymbolReporter : public SymbolReporter { public: ~TestSymbolReporter() override {} - void reportSymbol(llvm::StringRef FileName, -const SymbolInfo &Symbol) override { -Symbols.push_back(Symbol); + void reportSymbols(llvm::StringRef FileName, + SymbolInfo::SignalMap NewSymbols) override { +for (const auto &Entry : NewSymbols) + Symbols[Entry.first] += Entry.second; } bool hasSymbol(const SymbolInfo &Symbol) const { -for (const auto &S : Symbols) { - if (S == Symbol) -return true; -} -return false; +auto it = Symbols.find(Symbol); +return it != Symbols.end() && it->second.Seen > 0; + } + + bool hasUse(const SymbolInfo &Symbol) const { +auto it = Symbols.find(Symbol); +return it != Symbols.end() && it->second.Used > 0; } private: - std::vector Symbols; + SymbolInfo::SignalMap Symbols; }; class FindAllSymbolsTest : public ::testing::Test { public: bool hasSymbol(const SymbolInfo &Symbol) { return Reporter.hasSymbol(Symbol); } - bool runFindAllSymbols(StringRef Code) { + bool hasUse(const SymbolInfo &Symbol) { return Reporter.hasUse(Symbol); } + + bool runFindAllSymbols(StringRef HeaderCode, StringRef MainCode) { llvm::IntrusiveRefCntPtr InMemoryFileSystem( new vfs::InMemoryFileSystem); llvm::IntrusiveRefCntPtr Files( @@ -88,7 +94,7 @@ InMemoryFileSystem->addFile(InternalHeader, 0, llvm::MemoryBuffer::getMemBuffer(InternalCode)); -std::unique_ptr Factory( +std::unique_ptr Factory( new FindAllSymbolsActionFactory(&Reporter, &RegexMap)); tooling::ToolInvocation Invocation( @@ -98,7 +104,7 @@ std::make_shared()); InMemoryFileSystem->addFile(HeaderName, 0, -llvm::MemoryBuffer::getMemBuffer(Code)); +llvm::MemoryBuffer::getMemBuffer(HeaderCode)); std::string Content = "#include\"" + std::string(HeaderName) + "\"\n" @@ -118,6 +124,7 @@ SymbolInfo DirtySymbol("ExtraInternal", SymbolInfo::SymbolKind::Class, CleanHeader, 2, {}); #endif // _MSC_VER && __MINGW32__ +Content += "\n" + MainCode.str(); InMemoryFileSystem->addFile(FileName, 0, llvm::MemoryBuffer::getMemBuffer(Content)); Invocation.run(); @@ -135,49 +142,64 @@ }; TEST_F(FindAllSymbolsTest, VariableSymbols) { - static const char Code[] = R"( + static const char Header[] = R"( extern int xargc; namespace na { static bool = false; namespace nb { const long long *; } })"; - runFindAllSymbols(Code); + static const char Main[] = R"( + auto y = &na::nb::; + int main() { if (na::) return xargc; } + )"; + runFindAllSymbols(Header, Main); SymbolInfo Symbol = SymbolInfo("xargc", SymbolInfo::SymbolKind::Variable, HeaderName, 2, {});
[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.
sammccall added a comment. Thanks for bearing with me here :) Comment at: include-fixer/InMemorySymbolIndex.h:27 - std::vector + std::vector search(llvm::StringRef Identifier) override; hokein wrote: > sammccall wrote: > > hokein wrote: > > > There are many places using > > > `std::vector`. Maybe we can > > > use a type alias for it, so that we can type less. > > I guess? It's the namespaces that are the problem (vector > > is fine) and most of the namespace noise wouldn't go away here. > > > > is `clang::find_all_symbols::SymbolsSignalsList` better enough to obscure > > what the actual type is? It's 45 chars vs 54. > > > > IMO it's not worth it here, though > > `clang::find_all_symbols::SymbolInfo::SignalMap` vs > > `std::map > clang::find_all_symbols::SymbolInfo::Signals>` is. > If we put the type alias under `clang::include_fixer` namespace, it will > shorten the name more. Agree it is not worth the effect as the full name only > happens in headers. > > We could save a few characters by getting rid of `clang` because we are > always in `clang` namespace. So > `std::vector` should work, this looks > slightly better. :) Done, also cleaned up other redundant namespaces in touched files. https://reviews.llvm.org/D30210 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28297: [StaticAnalyzer] Fix crash in CastToStructChecker
danielmarjamaki updated this revision to Diff 89507. danielmarjamaki added a comment. It was reported in the bugzilla report that my first fix did not fix all crashes. A new example code was provided that triggered a new crash. I have updated the patch so both crashes are fixed. https://reviews.llvm.org/D28297 Files: lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp test/Analysis/cast-to-struct.cpp Index: test/Analysis/cast-to-struct.cpp === --- test/Analysis/cast-to-struct.cpp +++ test/Analysis/cast-to-struct.cpp @@ -65,3 +65,17 @@ void *VP = P; Abc = (struct ABC *)VP; } + +// https://llvm.org/bugs/show_bug.cgi?id=31173 +void dontCrash1(struct AB X) { + struct UndefS *S = (struct UndefS *)&X; +} + +struct S; +struct T { + struct S *P; +}; +extern struct S Var1, Var2; +void dontCrash2() { + ((struct T *) &Var1)->P = &Var2; +} Index: lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp === --- lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp +++ lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp @@ -84,6 +84,10 @@ if (!VD || VD->getType()->isReferenceType()) return true; +if (ToPointeeTy->isIncompleteType() || +OrigPointeeTy->isIncompleteType()) + return true; + // Warn when there is widening cast. unsigned ToWidth = Ctx.getTypeInfo(ToPointeeTy).Width; unsigned OrigWidth = Ctx.getTypeInfo(OrigPointeeTy).Width; Index: test/Analysis/cast-to-struct.cpp === --- test/Analysis/cast-to-struct.cpp +++ test/Analysis/cast-to-struct.cpp @@ -65,3 +65,17 @@ void *VP = P; Abc = (struct ABC *)VP; } + +// https://llvm.org/bugs/show_bug.cgi?id=31173 +void dontCrash1(struct AB X) { + struct UndefS *S = (struct UndefS *)&X; +} + +struct S; +struct T { + struct S *P; +}; +extern struct S Var1, Var2; +void dontCrash2() { + ((struct T *) &Var1)->P = &Var2; +} Index: lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp === --- lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp +++ lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp @@ -84,6 +84,10 @@ if (!VD || VD->getType()->isReferenceType()) return true; +if (ToPointeeTy->isIncompleteType() || +OrigPointeeTy->isIncompleteType()) + return true; + // Warn when there is widening cast. unsigned ToWidth = Ctx.getTypeInfo(ToPointeeTy).Width; unsigned OrigWidth = Ctx.getTypeInfo(OrigPointeeTy).Width; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28297: [StaticAnalyzer] Fix crash in CastToStructChecker
danielmarjamaki requested review of this revision. danielmarjamaki added a comment. I have updated the patch and want a new review. https://reviews.llvm.org/D28297 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.
hokein accepted this revision. hokein added a comment. This revision is now accepted and ready to land. Thanks! Looks good from my side. I'd wait to see whether @bkramer has more comments before commit it. Comment at: include-fixer/find-all-symbols/SymbolInfo.h:50 + // used. These are used to rank results. + struct Signals { +Signals() {} hokein wrote: > sammccall wrote: > > hokein wrote: > > > I think we can make a standalone class instead of making it a nested > > > class of `SymbolInfo` because I don't see strong relationship between > > > them. Maybe name it `FindingSignals` or `FindingInfo`. > > The relationship between them is a strong scoping one: signals only make > > sense in the context of a particular SymbolInfo. > > > > If it was a parallel top-level class, it needs a name that communicates > > this relationship, most likely SymbolSignals. I don't think that's > > significantly better than SymbolInfo::Signals. > > > > (If I had my druthers, these would probably be Symbol and Symbol::Signals - > > the "info" is the main reason that SymbolInfo::Signals is noisy. But not > > worth the churn I think) > > > You convinced me. Please keep the comment of `Signals` updated. > > > If I had my druthers, these would probably be Symbol and Symbol::Signals - > > the "info" is the main reason that SymbolInfo::Signals is noisy. But not > > worth the churn I think) > > In the initial design, `SymbolInfo` merely represents a cpp symbol. But as > more features developed, `SymbolInfo` might be not a good name at the moment. > `Symbol` seems not a better name as LLVM already has many classes named > `Symbol`. We can leave it here. > > > keep the comment of Signals updated. You are missing this. https://reviews.llvm.org/D30210 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.
sammccall updated this revision to Diff 89510. sammccall added a comment. Update comment - oops! https://reviews.llvm.org/D30210 Files: include-fixer/InMemorySymbolIndex.cpp include-fixer/InMemorySymbolIndex.h include-fixer/IncludeFixer.cpp include-fixer/SymbolIndex.h include-fixer/SymbolIndexManager.cpp include-fixer/YamlSymbolIndex.cpp include-fixer/YamlSymbolIndex.h include-fixer/find-all-symbols/FindAllMacros.cpp include-fixer/find-all-symbols/FindAllMacros.h include-fixer/find-all-symbols/FindAllSymbols.cpp include-fixer/find-all-symbols/FindAllSymbols.h include-fixer/find-all-symbols/FindAllSymbolsAction.cpp include-fixer/find-all-symbols/SymbolInfo.cpp include-fixer/find-all-symbols/SymbolInfo.h include-fixer/find-all-symbols/SymbolReporter.h include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp include-fixer/tool/ClangIncludeFixer.cpp test/include-fixer/Inputs/fake_yaml_db.yaml test/include-fixer/Inputs/merge/a.yaml test/include-fixer/Inputs/merge/b.yaml test/include-fixer/merge.test unittests/include-fixer/IncludeFixerTest.cpp unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp === --- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp +++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp @@ -19,6 +19,7 @@ #include "clang/Frontend/PCHContainerOperations.h" #include "clang/Tooling/Tooling.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/MemoryBuffer.h" #include "gtest/gtest.h" @@ -31,34 +32,39 @@ static const char HeaderName[] = "symbols.h"; -class TestSymbolReporter : public clang::find_all_symbols::SymbolReporter { +class TestSymbolReporter : public SymbolReporter { public: ~TestSymbolReporter() override {} - void reportSymbol(llvm::StringRef FileName, -const SymbolInfo &Symbol) override { -Symbols.push_back(Symbol); + void reportSymbols(llvm::StringRef FileName, + SymbolInfo::SignalMap NewSymbols) override { +for (const auto &Entry : NewSymbols) + Symbols[Entry.first] += Entry.second; } bool hasSymbol(const SymbolInfo &Symbol) const { -for (const auto &S : Symbols) { - if (S == Symbol) -return true; -} -return false; +auto it = Symbols.find(Symbol); +return it != Symbols.end() && it->second.Seen > 0; + } + + bool hasUse(const SymbolInfo &Symbol) const { +auto it = Symbols.find(Symbol); +return it != Symbols.end() && it->second.Used > 0; } private: - std::vector Symbols; + SymbolInfo::SignalMap Symbols; }; class FindAllSymbolsTest : public ::testing::Test { public: bool hasSymbol(const SymbolInfo &Symbol) { return Reporter.hasSymbol(Symbol); } - bool runFindAllSymbols(StringRef Code) { + bool hasUse(const SymbolInfo &Symbol) { return Reporter.hasUse(Symbol); } + + bool runFindAllSymbols(StringRef HeaderCode, StringRef MainCode) { llvm::IntrusiveRefCntPtr InMemoryFileSystem( new vfs::InMemoryFileSystem); llvm::IntrusiveRefCntPtr Files( @@ -88,7 +94,7 @@ InMemoryFileSystem->addFile(InternalHeader, 0, llvm::MemoryBuffer::getMemBuffer(InternalCode)); -std::unique_ptr Factory( +std::unique_ptr Factory( new FindAllSymbolsActionFactory(&Reporter, &RegexMap)); tooling::ToolInvocation Invocation( @@ -98,7 +104,7 @@ std::make_shared()); InMemoryFileSystem->addFile(HeaderName, 0, -llvm::MemoryBuffer::getMemBuffer(Code)); +llvm::MemoryBuffer::getMemBuffer(HeaderCode)); std::string Content = "#include\"" + std::string(HeaderName) + "\"\n" @@ -118,6 +124,7 @@ SymbolInfo DirtySymbol("ExtraInternal", SymbolInfo::SymbolKind::Class, CleanHeader, 2, {}); #endif // _MSC_VER && __MINGW32__ +Content += "\n" + MainCode.str(); InMemoryFileSystem->addFile(FileName, 0, llvm::MemoryBuffer::getMemBuffer(Content)); Invocation.run(); @@ -135,49 +142,64 @@ }; TEST_F(FindAllSymbolsTest, VariableSymbols) { - static const char Code[] = R"( + static const char Header[] = R"( extern int xargc; namespace na { static bool = false; namespace nb { const long long *; } })"; - runFindAllSymbols(Code); + static const char Main[] = R"( + auto y = &na::nb::; + int main() { if (na::) return xargc; } + )"; + runFindAllSymbols(Header, Main); SymbolInfo Symbol = SymbolInfo("xargc", SymbolInfo::SymbolKind::Variable, HeaderName, 2, {}); EXPECT_TRUE(hasSymbol(Symbol)); + EXPECT_TRUE(hasUse(Symbol)); Symbol = SymbolInfo("SSS
[clang-tools-extra] r295988 - Make clang-include-fixer--insert-line work when the difference is on an empty line
Author: klimek Date: Thu Feb 23 10:02:53 2017 New Revision: 295988 URL: http://llvm.org/viewvc/llvm-project?rev=295988&view=rev Log: Make clang-include-fixer--insert-line work when the difference is on an empty line `clang-include-fixer--insert-line` has an off-by-one error because it uses `(goto-char (point-min)) (forward-char chars)`, which is (goto-char (1+ chars))`. Because of this, when the first difference was on an empty line (i.e. an include was appended to the block of includes), the pointer in the `to` buffer would be on the next line. Also wrapped calls inside another process sentinel inside `with-local-quit`. Patch by Torsten Marek. Differential Revision: https://reviews.llvm.org/D30292 Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el?rev=295988&r1=295987&r2=295988&view=diff == --- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el (original) +++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el Thu Feb 23 10:02:53 2017 @@ -23,6 +23,18 @@ (should (equal (buffer-string) "aa\nab\nac\nad\n") (should (equal (buffer-string) "aa\nab\nac\nad\n" +(ert-deftest clang-include-fixer--insert-line-diff-on-empty-line () + "Unit test for `clang-include-fixer--insert-line'." + (with-temp-buffer +(insert "aa\nab\n\nac\nad\n") +(let ((from (current-buffer))) + (with-temp-buffer +(insert "aa\n\nac\nad\n") +(let ((to (current-buffer))) + (should (clang-include-fixer--insert-line from to)) + (should (equal (buffer-string) "aa\nab\n\nac\nad\n") +(should (equal (buffer-string) "aa\nab\n\nac\nad\n" + (ert-deftest clang-include-fixer--symbol-at-point () "Unit test for `clang-include-fixer--symbol-at-point'." (with-temp-buffer 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=295988&r1=295987&r2=295988&view=diff == --- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el (original) +++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el Thu Feb 23 10:02:53 2017 @@ -213,16 +213,14 @@ return nil. Buffer restrictions are ign (if (zerop chars) ;; Buffer contents are equal, nothing to do. t - (goto-char (point-min)) - (forward-char chars) + (goto-char chars) ;; We might have ended up in the middle of a line if the ;; current line partially matches. In this case we would ;; have to insert more than a line. Move to the beginning of ;; the line to avoid this situation. (beginning-of-line) (with-current-buffer from -(goto-char (point-min)) -(forward-char chars) +(goto-char chars) (beginning-of-line) (let ((from-begin (point)) (from-end (progn (forward-line) (point))) @@ -268,9 +266,10 @@ clang-include-fixer to insert the select (clang-include-fixer--replace-buffer stdout) (let-alist context (let-alist (car .HeaderInfos) - (run-hook-with-args 'clang-include-fixer-add-include-hook - (substring .Header 1 -1) - (string= (substring .Header 0 1) "<")) + (with-local-quit + (run-hook-with-args 'clang-include-fixer-add-include-hook + (substring .Header 1 -1) + (string= (substring .Header 0 1) "<"))) (format "-insert-header=%s" (clang-include-fixer--encode-json context nil) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28771: [Analyzer] Various fixes for the IteratorPastEnd checker
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:530 + auto value = RVal; + if (auto loc = value.getAs()) { +value = State->getRawSVal(*loc); baloghadamsoftware wrote: > NoQ wrote: > > baloghadamsoftware wrote: > > > NoQ wrote: > > > > baloghadamsoftware wrote: > > > > > NoQ wrote: > > > > > > Is there a test case for this hack? > > > > > > > > > > > > I'd also consider inspecting the AST (probably before passing the > > > > > > values to `handleRandomIncrOrDecr()`) and making the decision based > > > > > > on that. Because even though this pattern ("if a value is a loc and > > > > > > we expect a nonloc, do an extra dereference") is present in many > > > > > > places in the analyzer, in most of these places it doesn't work > > > > > > correctly (what if we try to discriminate between `int*` and > > > > > > `int*&`?). > > > > > I just want to get the sign of the integer value (if it is > > > > > available). It turned out that I cannot do comparison between loc and > > > > > nonloc. (Strange, because I can do anything else). After I created > > > > > this hack, the Analyzer did not crash anymore on the llvm/clang code. > > > > > > > > > > I do not fully understand what I should fix here and how? In this > > > > > particular place we expect some integer, thus no int* or int*&. > > > > Loc value, essentially, *is* a pointer or reference value. If you're > > > > getting a Loc, then your expectations of an integer are not met in the > > > > actual code. In this case you *want* to know why they are not met, > > > > otherwise you may avoid the crash, but do incorrect things and run into > > > > false positives. So i'd rather have this investigated carefully. > > > > > > > > You say that you are crashing otherwise - and then it should be trivial > > > > for you to attach a debugger and `dump()` the expression for which you > > > > expect to take the integer value, and see why it suddenly has a pointer > > > > type in a particular case. From that you'd easily see what to do. > > > > > > > > Also, crashes are often easy to auto-reduce using tools like `creduce`. > > > > Unlike false positives, which may turn into true positives during > > > > reduction. > > > > > > > > If you still don't see the reason why your workaround is necessary and > > > > what exactly it does, could you attach a preprocessed file and an > > > > analyzer runline for the crash, so that we could have a look together? > > > Just to be clear: I know why it crashes without the hack: I simply cannot > > > compare loc and nonloc. Since concrete 0 is nonloc I need another nonloc. > > > I suppose this happens if an integer reference is passed to the operator > > > +, +=, - or -=. So I thought that dereferencing it by getting the raw > > > SVal is the correct thing to do. > > Yep, in this case the correct thing to do would be to check AST types > > rather than SVal types. Eg., > > ``` > > if (Arg->getType()->isReferenceType()) > > value = State->getRawSVal(*loc); > > ``` > > > > (you might need to do it in the caller function, which still has access to > > the expressions) > > > > It is better this way because expectations are explicitly stated, and the > > assertion would still catch the situation when expectations are not met. > > > > Also, please still add a test case to cover this branch :) > I tried it and failed in std::vector::back(). It seems that the problem is > not the reference, but loc::ConcreteInt. I added a test case, but in our > mocked vector the integer 1 in *(end()-1) is nonloc::ConcreteInt, but in the > real one it is loc::ConcreteInt. I do not see why is there a difference, > neither do I know how could something be a location and a concrete integer at > once. What is loc::ConcreteInt and what to do with it? > What is loc::ConcreteInt and what to do with it? It is a concrete memory address. The null pointer, for example, or maybe a fixed magic pointer in some embedded driver code. Could you post an AST dump for the real `(end()-1)`on which you are failing? It might be that we end up looking at the other `operator-()` as in `(end() - begin())`, while iterators are implemented as pointers; no idea how that could be, but i'm suspecting something like that. https://reviews.llvm.org/D28771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28771: [Analyzer] Various fixes for the IteratorPastEnd checker
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:530 + auto value = RVal; + if (auto loc = value.getAs()) { +value = State->getRawSVal(*loc); NoQ wrote: > baloghadamsoftware wrote: > > NoQ wrote: > > > baloghadamsoftware wrote: > > > > NoQ wrote: > > > > > baloghadamsoftware wrote: > > > > > > NoQ wrote: > > > > > > > Is there a test case for this hack? > > > > > > > > > > > > > > I'd also consider inspecting the AST (probably before passing the > > > > > > > values to `handleRandomIncrOrDecr()`) and making the decision > > > > > > > based on that. Because even though this pattern ("if a value is a > > > > > > > loc and we expect a nonloc, do an extra dereference") is present > > > > > > > in many places in the analyzer, in most of these places it > > > > > > > doesn't work correctly (what if we try to discriminate between > > > > > > > `int*` and `int*&`?). > > > > > > I just want to get the sign of the integer value (if it is > > > > > > available). It turned out that I cannot do comparison between loc > > > > > > and nonloc. (Strange, because I can do anything else). After I > > > > > > created this hack, the Analyzer did not crash anymore on the > > > > > > llvm/clang code. > > > > > > > > > > > > I do not fully understand what I should fix here and how? In this > > > > > > particular place we expect some integer, thus no int* or int*&. > > > > > Loc value, essentially, *is* a pointer or reference value. If you're > > > > > getting a Loc, then your expectations of an integer are not met in > > > > > the actual code. In this case you *want* to know why they are not > > > > > met, otherwise you may avoid the crash, but do incorrect things and > > > > > run into false positives. So i'd rather have this investigated > > > > > carefully. > > > > > > > > > > You say that you are crashing otherwise - and then it should be > > > > > trivial for you to attach a debugger and `dump()` the expression for > > > > > which you expect to take the integer value, and see why it suddenly > > > > > has a pointer type in a particular case. From that you'd easily see > > > > > what to do. > > > > > > > > > > Also, crashes are often easy to auto-reduce using tools like > > > > > `creduce`. Unlike false positives, which may turn into true positives > > > > > during reduction. > > > > > > > > > > If you still don't see the reason why your workaround is necessary > > > > > and what exactly it does, could you attach a preprocessed file and an > > > > > analyzer runline for the crash, so that we could have a look together? > > > > Just to be clear: I know why it crashes without the hack: I simply > > > > cannot compare loc and nonloc. Since concrete 0 is nonloc I need > > > > another nonloc. I suppose this happens if an integer reference is > > > > passed to the operator +, +=, - or -=. So I thought that dereferencing > > > > it by getting the raw SVal is the correct thing to do. > > > Yep, in this case the correct thing to do would be to check AST types > > > rather than SVal types. Eg., > > > ``` > > > if (Arg->getType()->isReferenceType()) > > > value = State->getRawSVal(*loc); > > > ``` > > > > > > (you might need to do it in the caller function, which still has access > > > to the expressions) > > > > > > It is better this way because expectations are explicitly stated, and the > > > assertion would still catch the situation when expectations are not met. > > > > > > Also, please still add a test case to cover this branch :) > > I tried it and failed in std::vector::back(). It seems that the problem is > > not the reference, but loc::ConcreteInt. I added a test case, but in our > > mocked vector the integer 1 in *(end()-1) is nonloc::ConcreteInt, but in > > the real one it is loc::ConcreteInt. I do not see why is there a > > difference, neither do I know how could something be a location and a > > concrete integer at once. What is loc::ConcreteInt and what to do with it? > > What is loc::ConcreteInt and what to do with it? > > It is a concrete memory address. The null pointer, for example, or maybe a > fixed magic pointer in some embedded driver code. > > Could you post an AST dump for the real `(end()-1)`on which you are failing? > It might be that we end up looking at the other `operator-()` as in `(end() - > begin())`, while iterators are implemented as pointers; no idea how that > could be, but i'm suspecting something like that. Also, dereferencing a `loc::ConcreteInt` loc (through `getSVal`/`getRawSVal`) would always yield `UndefinedVal` value. https://reviews.llvm.org/D28771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29986: Fix crash when an incorrect redeclaration only differs in __unaligned type-qualifier
rogfer01 added a comment. Ping? https://reviews.llvm.org/D29986 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29986: Fix crash when an incorrect redeclaration only differs in __unaligned type-qualifier
rjmccall added a comment. In https://reviews.llvm.org/D29986#684811, @rogfer01 wrote: > Ping? Are you expecting something even more conclusive than "looks good to me"? Because I sent you that feedback a week ago. :) https://reviews.llvm.org/D29986 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r295473 - [OpenMP] Remove barriers at cancel and cancellation point
Thanks! r296000. On Wed, Feb 22, 2017 at 8:15 PM, Alexey Bataev wrote: > Yes, approved > > Best regards, > Alexey Bataev > >> 23 февр. 2017 г., в 1:00, Hans Wennborg написал(а): >> >> Alexey: ping? >> >>> On Tue, Feb 21, 2017 at 11:07 AM, Hans Wennborg wrote: >>> I'm Ok with it if Alexey approves. >>> >>> On Fri, Feb 17, 2017 at 10:52 AM, Hahnfeld, Jonas >>> wrote: Hi Hans, Alexey, can we merge this commit and r295474 for the 4.0 release or is it already too late for that? I will totally understand that and can apply these commits locally prior to installing. However, I think that these changes are quite focussed and bear minimal possibility of introducing regressions. Thanks, Jonas Am Freitag, den 17.02.2017, 18:32 + schrieb Jonas Hahnfeld via cfe-commits: Author: hahnfeld Date: Fri Feb 17 12:32:51 2017 New Revision: 295473 URL: http://llvm.org/viewvc/llvm-project?rev=295473&view=rev Log: [OpenMP] Remove barriers at cancel and cancellation point This resolves a deadlock with the cancel directive when there is no explicit cancellation point. In that case, the implicit barrier acts as cancellation point. After removing the barrier after cancel, the now unmatched barrier for the explicit cancellation point has to go as well. This has probably worked before rL255992: With the calls for the explicit barrier, it was sure that all threads passed a barrier before exiting. Reported by Simon Convent and Joachim Protze! Differential Revision: https://reviews.llvm.org/D30088 Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/test/OpenMP/cancel_codegen.cpp cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r295843 - [OpenCL] r600 needs OpenCL kernel calling convention
Thanks! r296001. On Thu, Feb 23, 2017 at 2:01 AM, Anastasia Stulova wrote: > Sure! No objections here! > > Thanks, > Anastasia > > -Original Message- > From: hwennb...@google.com [mailto:hwennb...@google.com] On Behalf Of Hans > Wennborg > Sent: 22 February 2017 18:10 > To: Jan Vesely > Cc: cfe-commits; Matt Arsenault; Anastasia Stulova > Subject: Re: r295843 - [OpenCL] r600 needs OpenCL kernel calling convention > > I'm OK with it if either Matt or Anastasia agrees. > > Thanks, > Hans > > On Wed, Feb 22, 2017 at 7:20 AM, Jan Vesely wrote: >> Hi Hans, >> >> I'd like this commit to make it to 4.0. I'm not sure if it falls under >> OpenCL or AMDGPU so I've added both Matt and Anastasia to cc. >> >> thank you, >> Jan >> >> On Wed, 2017-02-22 at 15:01 +, Jan Vesely via cfe-commits wrote: >>> Author: jvesely >>> Date: Wed Feb 22 09:01:42 2017 >>> New Revision: 295843 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=295843&view=rev >>> Log: >>> [OpenCL] r600 needs OpenCL kernel calling convention >>> >>> Differential Revision: https://reviews.llvm.org/D30236 >>> >>> Modified: >>> cfe/trunk/lib/Sema/SemaType.cpp >>> cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl >>> >>> Modified: cfe/trunk/lib/Sema/SemaType.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?r >>> ev=295843&r1=295842&r2=295843&view=diff >>> = >>> = >>> --- cfe/trunk/lib/Sema/SemaType.cpp (original) >>> +++ cfe/trunk/lib/Sema/SemaType.cpp Wed Feb 22 09:01:42 2017 >>> @@ -3175,7 +3175,7 @@ getCCForDeclaratorChunk(Sema &S, Declara >>>if (Attr->getKind() == AttributeList::AT_OpenCLKernel) { >>> llvm::Triple::ArchType arch = >>> S.Context.getTargetInfo().getTriple().getArch(); >>> if (arch == llvm::Triple::spir || arch == llvm::Triple::spir64 || >>> -arch == llvm::Triple::amdgcn) { >>> +arch == llvm::Triple::amdgcn || arch == >>> + llvm::Triple::r600) { >>>CC = CC_OpenCLKernel; >>> } >>> break; >>> >>> Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdg >>> pu-abi-struct-coerce.cl?rev=295843&r1=295842&r2=295843&view=diff >>> = >>> = >>> --- cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl >>> (original) >>> +++ cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl Wed Feb >>> +++ 22 09:01:42 2017 >>> @@ -1,5 +1,6 @@ >>> // REQUIRES: amdgpu-registered-target // RUN: %clang_cc1 -triple >>> amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s >>> +// RUN: %clang_cc1 -triple r600-unknown-unknown -S -emit-llvm -o - >>> +%s | FileCheck %s >>> >>> // CHECK-NOT: %struct.single_element_struct_arg = type { i32 } >>> typedef struct single_element_struct_arg >>> >>> >>> ___ >>> cfe-commits mailing list >>> cfe-commits@lists.llvm.org >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24861: [Sema] extend Wshift-op-parentheses so it warns for multiplicative operators
danielmarjamaki abandoned this revision. danielmarjamaki added a comment. I will not work on this in the near future Repository: rL LLVM https://reviews.llvm.org/D24861 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28278: [StaticAnalyzer] dont show wrong 'garbage value' warning when there is array index out of bounds
danielmarjamaki updated this revision to Diff 89540. danielmarjamaki added a comment. Making the error message more precise. https://reviews.llvm.org/D28278 Files: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp test/Analysis/uninit-vals-ps.c Index: test/Analysis/uninit-vals-ps.c === --- test/Analysis/uninit-vals-ps.c +++ test/Analysis/uninit-vals-ps.c @@ -57,6 +57,12 @@ return s.x; // no-warning } +void f6(int x) { + int a[20]; + if (x == 25) {} + if (a[x] == 123) {} // expected-warning{{The left operand of '==' is a garbage value due to array index out of bounds}} +} + int ret_uninit() { int i; int *p = &i; Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp === --- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp +++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp @@ -73,10 +73,31 @@ } if (Ex) { + bool ArrayIndexOutOfBounds = false; + if (isa(Ex)) { +SVal Loc = state->getSVal(Ex,LCtx); +if (Loc.isValid()) { + const MemRegion *MR = Loc.castAs().getRegion(); + if (const ElementRegion *ER = dyn_cast(MR)) { +DefinedOrUnknownSVal Idx = ER->getIndex().castAs(); +DefinedOrUnknownSVal NumElements + = C.getStoreManager().getSizeInElements(state, ER->getSuperRegion(), +ER->getValueType()); +ProgramStateRef StInBound = state->assumeInBound(Idx, NumElements, true); +ProgramStateRef StOutBound = state->assumeInBound(Idx, NumElements, false); +if (StOutBound && !StInBound) { + ArrayIndexOutOfBounds = true; +} + } +} + } + OS << "The " << (isLeft ? "left" : "right") << " operand of '" << BinaryOperator::getOpcodeStr(B->getOpcode()) << "' is a garbage value"; + if (ArrayIndexOutOfBounds) +OS << " due to array index out of bounds"; } else { // Neither operand was undefined, but the result is undefined. Index: test/Analysis/uninit-vals-ps.c === --- test/Analysis/uninit-vals-ps.c +++ test/Analysis/uninit-vals-ps.c @@ -57,6 +57,12 @@ return s.x; // no-warning } +void f6(int x) { + int a[20]; + if (x == 25) {} + if (a[x] == 123) {} // expected-warning{{The left operand of '==' is a garbage value due to array index out of bounds}} +} + int ret_uninit() { int i; int *p = &i; Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp === --- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp +++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp @@ -73,10 +73,31 @@ } if (Ex) { + bool ArrayIndexOutOfBounds = false; + if (isa(Ex)) { +SVal Loc = state->getSVal(Ex,LCtx); +if (Loc.isValid()) { + const MemRegion *MR = Loc.castAs().getRegion(); + if (const ElementRegion *ER = dyn_cast(MR)) { +DefinedOrUnknownSVal Idx = ER->getIndex().castAs(); +DefinedOrUnknownSVal NumElements + = C.getStoreManager().getSizeInElements(state, ER->getSuperRegion(), +ER->getValueType()); +ProgramStateRef StInBound = state->assumeInBound(Idx, NumElements, true); +ProgramStateRef StOutBound = state->assumeInBound(Idx, NumElements, false); +if (StOutBound && !StInBound) { + ArrayIndexOutOfBounds = true; +} + } +} + } + OS << "The " << (isLeft ? "left" : "right") << " operand of '" << BinaryOperator::getOpcodeStr(B->getOpcode()) << "' is a garbage value"; + if (ArrayIndexOutOfBounds) +OS << " due to array index out of bounds"; } else { // Neither operand was undefined, but the result is undefined. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.
hokein added inline comments. Comment at: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp:40 + void reportSymbols(llvm::StringRef FileName, + SymbolInfo::SignalMap NewSymbols) override { +for (const auto &Entry : NewSymbols) A new catch: `NewSymbols` should be passed by reference, otherwise a copy will be generated. https://reviews.llvm.org/D30210 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r295417 - Work around Clang assertion when testing C++17 deduction guides with '-g'.
Hi Eric Looks like the issue is fixed in r295794? Now green dragon is failing due to XPASS. http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/3018/testReport/ Can we remove that XFAILs in these two files? std/strings/basic_string/string_cons.implicit_deduction_guides.pass.cpp std/strings/string_view/string_view_cons.implicit_deduction_guides.pass.cpp Thanks Steven > On Feb 16, 2017, at 9:04 PM, Eric Fiselier via cfe-commits > wrote: > > Author: ericwf > Date: Thu Feb 16 23:04:09 2017 > New Revision: 295417 > > URL: http://llvm.org/viewvc/llvm-project?rev=295417&view=rev > Log: > Work around Clang assertion when testing C++17 deduction guides with '-g'. > > Modified: > > libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp > > Modified: > libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp > URL: > http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp?rev=295417&r1=295416&r2=295417&view=diff > == > --- > libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp > (original) > +++ > libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp > Thu Feb 16 23:04:09 2017 > @@ -10,6 +10,10 @@ > // UNSUPPORTED: c++98, c++03, c++11, c++14 > // UNSUPPORTED: libcpp-no-deduction-guides > > +// FIXME(EricWF): As of 16/Feb/2017 Clang hits an assertion when compiling > this > +// test with '-g' (as the sanitizers do). > +// XFAIL: ubsan, asan, msan, tsan > + > // > > // Test that the constructors offered by std::basic_string are formulated > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30158: [clang-tidy] modernize: Find usage of random_shuffle and replace it with shuffle.
madsravn updated this revision to Diff 89543. madsravn added a comment. Updated the code based on comments received. https://reviews.llvm.org/D30158 Files: clang-tidy/modernize/CMakeLists.txt clang-tidy/modernize/ModernizeTidyModule.cpp clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp clang-tidy/modernize/ReplaceRandomShuffleCheck.h docs/ReleaseNotes.rst docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/modernize-replace-random-shuffle.rst test/clang-tidy/modernize-replace-random-shuffle.cpp Index: test/clang-tidy/modernize-replace-random-shuffle.cpp === --- test/clang-tidy/modernize-replace-random-shuffle.cpp +++ test/clang-tidy/modernize-replace-random-shuffle.cpp @@ -0,0 +1,58 @@ +// RUN: %check_clang_tidy %s modernize-replace-random-shuffle %t -- -- -std=c++11 + +//CHECK-FIXES: #include + +namespace std { +template struct vec_iterator { + T *ptr; + vec_iterator operator++(int); +}; + +template struct vector { + typedef vec_iterator iterator; + + iterator begin(); + iterator end(); +}; + +template +void random_shuffle(FwIt begin, FwIt end); + +template +void random_shuffle(FwIt begin, FwIt end, randomFunc& randomfunc); + +template +void shuffle(FwIt begin, FwIt end); +} // namespace std + +// Random Func +int myrandom (int i) { return i;} + +using namespace std; + +int main() { + std::vector vec; + + std::random_shuffle(vec.begin(), vec.end()); + // CHECK-MESSAGE: [[@LINE-1]]:3: warning: do not use 'random_shuffle'. It is deprecated and replaced by 'shuffle' + // CHECK-FIXES: std::shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()())); + + + std::shuffle(vec.begin(), vec.end()); + + random_shuffle(vec.begin(), vec.end()); + // CHECK-MESSAGE: [[@LINE-1]]:3: warning: do not use 'random_shuffle'. It is deprecated and replaced by 'shuffle' + // CHECK-FIXES: shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()())); + + std::random_shuffle(vec.begin(), vec.end(), myrandom); + // CHECK-MESSAGE: [[@LINE-1]]:3: warning: do not use 'random_shuffle'. It is deprecated and replaced by 'shuffle'. The old user defined 'RandomFunction' is not usable for shuffle. You need to make additional changes if you want a specific random function + // CHECK-FIXES: std::shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()())); + + random_shuffle(vec.begin(), vec.end(), myrandom); + // CHECK-MESSAGE: [[@LINE-1]]:3: warning: do not use 'random_shuffle'. It is deprecated and replaced by 'shuffle'. The old user defined 'RandomFunction' is not usable for shuffle. You need to make additional changes if you want a specific random function + // CHECK-FIXES: shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()())); + + shuffle(vec.begin(), vec.end()); + + return 0; +} Index: docs/clang-tidy/checks/modernize-replace-random-shuffle.rst === --- docs/clang-tidy/checks/modernize-replace-random-shuffle.rst +++ docs/clang-tidy/checks/modernize-replace-random-shuffle.rst @@ -0,0 +1,28 @@ +.. title:: clang-tidy - modernize-replace-random-shuffle + +modernize-replace-random-shuffle + + +This check will find occurences of ``std::random_shuffle`` and replace it with ``std::shuffle``. In C++17 ``std::random_shuffle`` will no longer be available and thus we need to replace it. + +Below is two examples of what kind of occurences will be found and two examples of what it will be replaced with. + +.. code-block:: c++ + + std::vector v; + + // First example + std::random_shuffle(vec.begin(), vec.end()); + + // Second example + std::random_shuffle(vec.begin(), vec.end(), randomFun); + +Both these examples will be replaced with + +.. code-block:: c++ + + std::shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()())); + +The second example will also receive a warning that ``randomFunc`` is no longer supported in the same way as before so if the user wants the same functionality, the user will need to change the implementation of the ``randomFunc``. + +One thing to be aware of here is that ``std::random_device`` is quite expensive to initialize. So if you are using the code in a performance critical place, you probably want to initialize it elsewhere. Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -110,6 +110,7 @@ modernize-raw-string-literal modernize-redundant-void-arg modernize-replace-auto-ptr + modernize-replace-random-shuffle modernize-return-braced-init-list modernize-shrink-to-fit modernize-use-auto Index: docs/ReleaseNotes.rst === --- docs/ReleaseNotes.rst +++ docs/ReleaseNotes.rst @@ -72,6 +72,11 @@ Finds uses of inline assembler. +- New `
[PATCH] D30158: [clang-tidy] modernize: Find usage of random_shuffle and replace it with shuffle.
madsravn marked 18 inline comments as done. madsravn added inline comments. Comment at: test/clang-tidy/modernize-replace-random-shuffle.cpp:50 + // CHECK-MESSAGE: [[@LINE-1]]:3: warning: do not use 'random_shuffle'. It is deprecated and replaced by 'shuffle'. The old user defined 'RandomFunction' is not usable for shuffle. You need to make additional changes if you want a specific random function + // CHECK-FIXES: shuffle(vec.begin(), vec.begin(), std::mt19937(std::random_device()())); + xazax.hun wrote: > This check-fix might match the previous fix instead of this one. You might > want to make the fixes unique, e.g.: with a comment after a line. Note that > it is also worth to test that line ending comments are preserved. > > Also, are you sure you want to do the fixit when a custom random function is > passed to random_shuffle? I re-arranged them. This way the check-fixes does not say the same twice in a row. I am not sure what you mean by 'line ending comments are preserved'. Why shouldn't they be? The fixit should also be done when a custom random function is passed. random_shuffle will be removed and the signature of the custom random function will be changed. It's hard to do much differently than just issuing a warning. https://reviews.llvm.org/D30158 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27827: [ObjC] CodeGen support for @available on macOS
arphaman added a comment. Thanks for the explanation, now I get it! LGTM, with one request for change in the tests Comment at: test/CodeGenObjC/availability-check.m:22 + // CHECK: br i1 true + if (__builtin_available(macos 10.11, *)) +; Please add a line that verifies that `@available()` uses the builtin as well. https://reviews.llvm.org/D27827 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r296015 - [ObjC][CodeGen] CodeGen support for @available.
Author: epilk Date: Thu Feb 23 15:08:08 2017 New Revision: 296015 URL: http://llvm.org/viewvc/llvm-project?rev=296015&view=rev Log: [ObjC][CodeGen] CodeGen support for @available. CodeGens uses of @available into calls to the compiler-rt function __isOSVersionAtLeast. This commit is part of a feature that I proposed here: http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html Differential revision: https://reviews.llvm.org/D27827 Added: cfe/trunk/test/CodeGenObjC/availability-check.m Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.h Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=296015&r1=296014&r2=296015&view=diff == --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Feb 23 15:08:08 2017 @@ -300,6 +300,24 @@ public: return V; } + Value *VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) { +VersionTuple Version = E->getVersion(); + +// If we're checking for a platform older than our minimum deployment +// target, we can fold the check away. +if (Version <= CGF.CGM.getTarget().getPlatformMinVersion()) + return llvm::ConstantInt::get(Builder.getInt1Ty(), 1); + +Optional Min = Version.getMinor(), SMin = Version.getSubminor(); +llvm::Value *Args[] = { +llvm::ConstantInt::get(CGF.CGM.Int32Ty, Version.getMajor()), +llvm::ConstantInt::get(CGF.CGM.Int32Ty, Min ? *Min : 0), +llvm::ConstantInt::get(CGF.CGM.Int32Ty, SMin ? *SMin : 0), +}; + +return CGF.EmitBuiltinAvailable(Args); + } + Value *VisitArraySubscriptExpr(ArraySubscriptExpr *E); Value *VisitShuffleVectorExpr(ShuffleVectorExpr *E); Value *VisitConvertVectorExpr(ConvertVectorExpr *E); Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=296015&r1=296014&r2=296015&view=diff == --- cfe/trunk/lib/CodeGen/CGObjC.cpp (original) +++ cfe/trunk/lib/CodeGen/CGObjC.cpp Thu Feb 23 15:08:08 2017 @@ -3399,5 +3399,21 @@ CodeGenFunction::EmitBlockCopyAndAutorel return Val; } +llvm::Value * +CodeGenFunction::EmitBuiltinAvailable(ArrayRef Args) { + assert(Args.size() == 3 && "Expected 3 argument here!"); + + if (!CGM.IsOSVersionAtLeastFn) { +llvm::FunctionType *FTy = +llvm::FunctionType::get(Int32Ty, {Int32Ty, Int32Ty, Int32Ty}, false); +CGM.IsOSVersionAtLeastFn = +CGM.CreateRuntimeFunction(FTy, "__isOSVersionAtLeast"); + } + + llvm::Value *CallRes = + EmitNounwindRuntimeCall(CGM.IsOSVersionAtLeastFn, Args); + + return Builder.CreateICmpNE(CallRes, llvm::Constant::getNullValue(Int32Ty)); +} CGObjCRuntime::~CGObjCRuntime() {} Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=296015&r1=296014&r2=296015&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Thu Feb 23 15:08:08 2017 @@ -3169,6 +3169,8 @@ private: public: llvm::Value *EmitMSVCBuiltinExpr(MSVCIntrin BuiltinID, const CallExpr *E); + llvm::Value *EmitBuiltinAvailable(ArrayRef Args); + llvm::Value *EmitObjCProtocolExpr(const ObjCProtocolExpr *E); llvm::Value *EmitObjCStringLiteral(const ObjCStringLiteral *E); llvm::Value *EmitObjCBoxedExpr(const ObjCBoxedExpr *E); Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=296015&r1=296014&r2=296015&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.h Thu Feb 23 15:08:08 2017 @@ -546,6 +546,10 @@ public: return *ObjCData; } + // Version checking function, used to implement ObjC's @available: + // i32 @__isOSVersionAtLeast(i32, i32, i32) + llvm::Constant *IsOSVersionAtLeastFn = nullptr; + InstrProfStats &getPGOStats() { return PGOStats; } llvm::IndexedInstrProfReader *getPGOReader() const { return PGOReader.get(); } Added: cfe/trunk/test/CodeGenObjC/availability-check.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/availability-check.m?rev=296015&view=auto == --- cfe/trunk/test/CodeGenObjC/availability-check.m (added) +++ cfe/trunk/test/CodeGenObjC/availability-check.m Thu Feb 23 15:08:08 2017 @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - %s | FileChec
[PATCH] D27827: [ObjC] CodeGen support for @available on macOS
This revision was automatically updated to reflect the committed changes. Closed by commit rL296015: [ObjC][CodeGen] CodeGen support for @available. (authored by epilk). Changed prior to commit: https://reviews.llvm.org/D27827?vs=89305&id=89556#toc Repository: rL LLVM https://reviews.llvm.org/D27827 Files: cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/test/CodeGenObjC/availability-check.m Index: cfe/trunk/test/CodeGenObjC/availability-check.m === --- cfe/trunk/test/CodeGenObjC/availability-check.m +++ cfe/trunk/test/CodeGenObjC/availability-check.m @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - %s | FileCheck %s + +void use_at_available() { + // CHECK: call i32 @__isOSVersionAtLeast(i32 10, i32 12, i32 0) + // CHECK-NEXT: icmp ne + if (__builtin_available(macos 10.12, *)) +; + + // CHECK: call i32 @__isOSVersionAtLeast(i32 10, i32 12, i32 0) + // CHECK-NEXT: icmp ne + if (@available(macos 10.12, *)) +; + + // CHECK: call i32 @__isOSVersionAtLeast(i32 10, i32 12, i32 42) + // CHECK-NEXT: icmp ne + if (__builtin_available(ios 10, macos 10.12.42, *)) +; + + // CHECK-NOT: call i32 @__isOSVersionAtLeast + // CHECK: br i1 true + if (__builtin_available(ios 10, *)) +; + + // This check should be folded: our deployment target is 10.11. + // CHECK-NOT: call i32 @__isOSVersionAtLeast + // CHECK: br i1 true + if (__builtin_available(macos 10.11, *)) +; +} + +// CHECK: declare i32 @__isOSVersionAtLeast(i32, i32, i32) Index: cfe/trunk/lib/CodeGen/CGObjC.cpp === --- cfe/trunk/lib/CodeGen/CGObjC.cpp +++ cfe/trunk/lib/CodeGen/CGObjC.cpp @@ -3399,5 +3399,21 @@ return Val; } +llvm::Value * +CodeGenFunction::EmitBuiltinAvailable(ArrayRef Args) { + assert(Args.size() == 3 && "Expected 3 argument here!"); + + if (!CGM.IsOSVersionAtLeastFn) { +llvm::FunctionType *FTy = +llvm::FunctionType::get(Int32Ty, {Int32Ty, Int32Ty, Int32Ty}, false); +CGM.IsOSVersionAtLeastFn = +CGM.CreateRuntimeFunction(FTy, "__isOSVersionAtLeast"); + } + + llvm::Value *CallRes = + EmitNounwindRuntimeCall(CGM.IsOSVersionAtLeastFn, Args); + + return Builder.CreateICmpNE(CallRes, llvm::Constant::getNullValue(Int32Ty)); +} CGObjCRuntime::~CGObjCRuntime() {} Index: cfe/trunk/lib/CodeGen/CodeGenFunction.h === --- cfe/trunk/lib/CodeGen/CodeGenFunction.h +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h @@ -3169,6 +3169,8 @@ public: llvm::Value *EmitMSVCBuiltinExpr(MSVCIntrin BuiltinID, const CallExpr *E); + llvm::Value *EmitBuiltinAvailable(ArrayRef Args); + llvm::Value *EmitObjCProtocolExpr(const ObjCProtocolExpr *E); llvm::Value *EmitObjCStringLiteral(const ObjCStringLiteral *E); llvm::Value *EmitObjCBoxedExpr(const ObjCBoxedExpr *E); Index: cfe/trunk/lib/CodeGen/CodeGenModule.h === --- cfe/trunk/lib/CodeGen/CodeGenModule.h +++ cfe/trunk/lib/CodeGen/CodeGenModule.h @@ -546,6 +546,10 @@ return *ObjCData; } + // Version checking function, used to implement ObjC's @available: + // i32 @__isOSVersionAtLeast(i32, i32, i32) + llvm::Constant *IsOSVersionAtLeastFn = nullptr; + InstrProfStats &getPGOStats() { return PGOStats; } llvm::IndexedInstrProfReader *getPGOReader() const { return PGOReader.get(); } Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp === --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp @@ -300,6 +300,24 @@ return V; } + Value *VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) { +VersionTuple Version = E->getVersion(); + +// If we're checking for a platform older than our minimum deployment +// target, we can fold the check away. +if (Version <= CGF.CGM.getTarget().getPlatformMinVersion()) + return llvm::ConstantInt::get(Builder.getInt1Ty(), 1); + +Optional Min = Version.getMinor(), SMin = Version.getSubminor(); +llvm::Value *Args[] = { +llvm::ConstantInt::get(CGF.CGM.Int32Ty, Version.getMajor()), +llvm::ConstantInt::get(CGF.CGM.Int32Ty, Min ? *Min : 0), +llvm::ConstantInt::get(CGF.CGM.Int32Ty, SMin ? *SMin : 0), +}; + +return CGF.EmitBuiltinAvailable(Args); + } + Value *VisitArraySubscriptExpr(ArraySubscriptExpr *E); Value *VisitShuffleVectorExpr(ShuffleVectorExpr *E); Value *VisitConvertVectorExpr(ConvertVectorExpr *E); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28772: [Preprocessor] Fix incorrect token caching that occurs when lexing _Pragma in macro argument pre-expansion mode when skipping a function body
arphaman added a comment. Ping. Repository: rL LLVM https://reviews.llvm.org/D28772 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.
On Feb 23, 2017 8:48 PM, "Haojian Wu via Phabricator" < revi...@reviews.llvm.org> wrote: hokein added inline comments. Comment at: unittests/include-fixer/find-all-symbols/ FindAllSymbolsTests.cpp:40 + void reportSymbols(llvm::StringRef FileName, + SymbolInfo::SignalMap NewSymbols) override { +for (const auto &Entry : NewSymbols) A new catch: `NewSymbols` should be passed by reference, otherwise a copy will be generated. I did actually intend by-value here, FindAllSymbols no longer needs the map once it's reported, so it is moved rather than copied (see the end of FindAllSymbols.cpp) If this is too surprising, I can change it. https://reviews.llvm.org/D30210 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28278: [StaticAnalyzer] dont show wrong 'garbage value' warning when there is array index out of bounds
zaks.anna added inline comments. Comment at: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp:76 if (Ex) { + bool ArrayIndexOutOfBounds = false; + if (isa(Ex)) { Please, pull this out into a sub-rutine. Thanks! https://reviews.llvm.org/D28278 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r296020 - Add context note to diagnostics that occur while declaring an implicit special member function.
Author: rsmith Date: Thu Feb 23 15:43:43 2017 New Revision: 296020 URL: http://llvm.org/viewvc/llvm-project?rev=296020&view=rev Log: Add context note to diagnostics that occur while declaring an implicit special member function. Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp cfe/trunk/test/CXX/class.derived/class.abstract/p16.cpp cfe/trunk/test/SemaCXX/implicit-member-functions.cpp cfe/trunk/test/SemaCXX/virtual-base-used.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=296020&r1=296019&r2=296020&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Feb 23 15:43:43 2017 @@ -1624,7 +1624,14 @@ def err_covariant_return_type_class_type "return type of virtual function %0 is not covariant with the return type of " "the function it overrides (class type %1 is more qualified than class " "type %2">; - + +// C++ implicit special member functions +def note_in_declaration_of_implicit_special_member : Note< + "while declaring the implicit " + "%select{default constructor|copy constructor|move constructor|" + "copy assignment operator|move assignment operator|destructor}1" + " for %0">; + // C++ constructors def err_constructor_cannot_be : Error<"constructor cannot be declared '%0'">; def err_invalid_qualified_constructor : Error< Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=296020&r1=296019&r2=296020&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Thu Feb 23 15:43:43 2017 @@ -6881,28 +6881,42 @@ public: /// We are instantiating the exception specification for a function /// template which was deferred until it was needed. - ExceptionSpecInstantiation + ExceptionSpecInstantiation, + + /// We are declaring an implicit special member function. + DeclaringSpecialMember, } Kind; -/// \brief The point of instantiation within the source code. +/// \brief Was the enclosing context a non-instantiation SFINAE context? +bool SavedInNonInstantiationSFINAEContext; + +/// \brief The point of instantiation or synthesis within the source code. SourceLocation PointOfInstantiation; +/// \brief The entity that is being synthesized. +Decl *Entity; + /// \brief The template (or partial specialization) in which we are /// performing the instantiation, for substitutions of prior template /// arguments. NamedDecl *Template; -/// \brief The entity that is being instantiated. -Decl *Entity; - /// \brief The list of template arguments we are substituting, if they /// are not part of the entity. const TemplateArgument *TemplateArgs; -/// \brief The number of template arguments in TemplateArgs. -unsigned NumTemplateArgs; +// FIXME: Wrap this union around more members, or perhaps store the +// kind-specific members in the RAII object owning the context. +union { + /// \brief The number of template arguments in TemplateArgs. + unsigned NumTemplateArgs; + + /// \brief The special member being declared or defined. + CXXSpecialMember SpecialMember; +}; ArrayRef template_arguments() const { + assert(Kind != DeclaringSpecialMember); return {TemplateArgs, NumTemplateArgs}; } @@ -6916,7 +6930,7 @@ public: SourceRange InstantiationRange; CodeSynthesisContext() - : Kind(TemplateInstantiation), Template(nullptr), Entity(nullptr), + : Kind(TemplateInstantiation), Entity(nullptr), Template(nullptr), TemplateArgs(nullptr), NumTemplateArgs(0), DeductionInfo(nullptr) {} /// \brief Determines whether this template is an actual instantiation @@ -7134,7 +7148,6 @@ public: Sema &SemaRef; bool Invalid; bool AlreadyInstantiating; -bool SavedInNonInstantiationSFINAEContext; bool CheckInstantiationDepth(SourceLocation PointOfInstantiation, SourceRange InstantiationRange); @@ -7151,6 +7164,9 @@ public: operator=(const InstantiatingTemplate&) = delete; }; + void pushCodeSynthesisContext(CodeSynthesisContext Ctx); + void popCodeSynthesisContext(); + /// Determine whether we are currently performing template instantiation. bool inTemplateInstantiation() const { return CodeSynthesisContexts.size() > NonInstantiationEntries; Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp URL: http://llvm.org/viewvc/
r296024 - [CodeGen] Fix ExtParameterInfo bugs in C++ CodeGen code.
Author: gbiv Date: Thu Feb 23 16:07:35 2017 New Revision: 296024 URL: http://llvm.org/viewvc/llvm-project?rev=296024&view=rev Log: [CodeGen] Fix ExtParameterInfo bugs in C++ CodeGen code. This patch makes use of the prefix/suffix ABI argument distinction that was introduced in r295870, so that we now emit ExtParameterInfo at the correct offset for member calls that have added ABI arguments. I don't see a good way to test the generated param info, since we don't actually seem to use it in CGFunctionInfo outside of Swift. Any suggestions/thoughts for how to better test this are welcome. :) This patch also fixes a small bug with inheriting constructors: if we decide not to pass args into an base class ctor, we would still generate ExtParameterInfo as though we did. The added test-case is for that behavior. Modified: cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/lib/CodeGen/CGExprCXX.cpp cfe/trunk/lib/CodeGen/CGVTables.cpp cfe/trunk/lib/CodeGen/CodeGenTypes.h cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp cfe/trunk/test/CodeGenObjCXX/arc-attrs-abi.mm Modified: cfe/trunk/lib/CodeGen/CGCall.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=296024&r1=296023&r2=296024&view=diff == --- cfe/trunk/lib/CodeGen/CGCall.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Feb 23 16:07:35 2017 @@ -362,18 +362,31 @@ getExtParameterInfosForCall(const Functi } /// Arrange a call to a C++ method, passing the given arguments. +/// +/// ExtraPrefixArgs is the number of ABI-specific args passed after the `this` +/// parameter. +/// ExtraSuffixArgs is the number of ABI-specific args passed at the end of +/// args. +/// PassProtoArgs indicates whether `args` has args for the parameters in the +/// given CXXConstructorDecl. const CGFunctionInfo & CodeGenTypes::arrangeCXXConstructorCall(const CallArgList &args, const CXXConstructorDecl *D, CXXCtorType CtorKind, -unsigned ExtraArgs) { +unsigned ExtraPrefixArgs, +unsigned ExtraSuffixArgs, +bool PassProtoArgs) { // FIXME: Kill copy. SmallVector ArgTypes; for (const auto &Arg : args) ArgTypes.push_back(Context.getCanonicalParamType(Arg.Ty)); + // +1 for implicit this, which should always be args[0]. + unsigned TotalPrefixArgs = 1 + ExtraPrefixArgs; + CanQual FPT = GetFormalType(D); - RequiredArgs Required = RequiredArgs::forPrototypePlus(FPT, 1 + ExtraArgs, D); + RequiredArgs Required = + RequiredArgs::forPrototypePlus(FPT, TotalPrefixArgs + ExtraSuffixArgs, D); GlobalDecl GD(D, CtorKind); CanQualType ResultType = TheCXXABI.HasThisReturn(GD) ? ArgTypes.front() @@ -382,8 +395,14 @@ CodeGenTypes::arrangeCXXConstructorCall( : Context.VoidTy; FunctionType::ExtInfo Info = FPT->getExtInfo(); - auto ParamInfos = getExtParameterInfosForCall(FPT.getTypePtr(), 1 + ExtraArgs, -ArgTypes.size()); + llvm::SmallVector ParamInfos; + // If the prototype args are elided, we should only have ABI-specific args, + // which never have param info. + if (PassProtoArgs && FPT->hasExtParameterInfos()) { +// ABI-specific suffix arguments are treated the same as variadic arguments. +addExtParameterInfosForCall(ParamInfos, FPT.getTypePtr(), TotalPrefixArgs, +ArgTypes.size()); + } return arrangeLLVMFunctionInfo(ResultType, /*instanceMethod=*/true, /*chainCall=*/false, ArgTypes, Info, ParamInfos, Required); @@ -627,15 +646,20 @@ CodeGenTypes::arrangeBuiltinFunctionDecl } /// Arrange a call to a C++ method, passing the given arguments. +/// +/// numPrefixArgs is the number of ABI-specific prefix arguments we have. It +/// does not count `this`. const CGFunctionInfo & CodeGenTypes::arrangeCXXMethodCall(const CallArgList &args, const FunctionProtoType *proto, - RequiredArgs required) { - unsigned numRequiredArgs = -(proto->isVariadic() ? required.getNumRequiredArgs() : args.size()); - unsigned numPrefixArgs = numRequiredArgs - proto->getNumParams(); + RequiredArgs required, + unsigned numPrefixArgs) { + assert(numPrefixArgs + 1 <= args.size() && + "Emitting a call with less args than the required prefix?"); + // Add one to account for `this`. It's a bit awkward here, but we don't count + // `this` in similar places elsewhere. auto paramInfos = -getExtParameterInfosForCall
r296027 - Tighten up a regex in a test
Author: gbiv Date: Thu Feb 23 16:14:55 2017 New Revision: 296027 URL: http://llvm.org/viewvc/llvm-project?rev=296027&view=rev Log: Tighten up a regex in a test ...If we're trying to match "this function has only two arguments", `.*` probably isn't the best thing to use. :) Modified: cfe/trunk/test/CodeGenObjCXX/arc-attrs-abi.mm Modified: cfe/trunk/test/CodeGenObjCXX/arc-attrs-abi.mm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/arc-attrs-abi.mm?rev=296027&r1=296026&r2=296027&view=diff == --- cfe/trunk/test/CodeGenObjCXX/arc-attrs-abi.mm (original) +++ cfe/trunk/test/CodeGenObjCXX/arc-attrs-abi.mm Thu Feb 23 16:14:55 2017 @@ -25,7 +25,7 @@ struct VirtualBase2 { // emit the construction code inline. struct WithVirtualBaseMid : virtual VirtualBase2 { // Ensure we only pass in `this` and a vtable. Otherwise this test is useless. - // ITANIUM: define {{.*}} void @_ZN18WithVirtualBaseMidCI212VirtualBase2EP11objc_objectPv({{.*}}, {{.*}}) + // ITANIUM: define {{.*}} void @_ZN18WithVirtualBaseMidCI212VirtualBase2EP11objc_objectPv({{[^,]*}}, {{[^,]*}}) using VirtualBase2::VirtualBase2; }; struct WithVirtualBaseLast : WithVirtualBaseMid { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30312: Fix unix.Malloc analysis crasher when allocating dynamic arrays w/unbound statements (fix PR32050)
kmarshall created this revision. The extent calculation function had a bug which caused it to ignore if the size value was defined prior to casting it. As a result, size expressions with free variables would trigger assertion failures during the cast operation. This patch adds that missing check, and replaces the redundant call to castAs<>() with the SVar that is returned by the checked cast. Added a regression test "Malloc+NewDynamicArray" that exercises the fix. https://reviews.llvm.org/D30312 Files: lib/StaticAnalyzer/Checkers/MallocChecker.cpp test/Analysis/Malloc+NewDynamicArray.cpp Index: test/Analysis/Malloc+NewDynamicArray.cpp === --- test/Analysis/Malloc+NewDynamicArray.cpp +++ test/Analysis/Malloc+NewDynamicArray.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=unix.Malloc -verify %s + +//--- +// Check that arrays sized using expressions with free variables +// do not cause the unix.Malloc checker to crash. +// +// The function should not actually be called from anywhere, otherwise +// the compiler will optimize the length expression and replace it with +// with precomputed literals. +//--- + +void AllocateExpr(int lhs, int rhs) { + new int[lhs + rhs]; +} + +// expected-no-diagnostics + Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp === --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -1026,12 +1026,11 @@ ASTContext &AstContext = C.getASTContext(); CharUnits TypeSize = AstContext.getTypeSizeInChars(ElementType); - if (Optional DefinedSize = - ElementCount.getAs()) { + if (Optional DefinedSize = ElementCount.getAs()) { DefinedOrUnknownSVal Extent = Region->getExtent(svalBuilder); // size in Bytes = ElementCount*TypeSize SVal SizeInBytes = svalBuilder.evalBinOpNN( -State, BO_Mul, ElementCount.castAs(), +State, BO_Mul, *DefinedSize, svalBuilder.makeArrayIndex(TypeSize.getQuantity()), svalBuilder.getArrayIndexType()); DefinedOrUnknownSVal extentMatchesSize = svalBuilder.evalEQ( Index: test/Analysis/Malloc+NewDynamicArray.cpp === --- test/Analysis/Malloc+NewDynamicArray.cpp +++ test/Analysis/Malloc+NewDynamicArray.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=unix.Malloc -verify %s + +//--- +// Check that arrays sized using expressions with free variables +// do not cause the unix.Malloc checker to crash. +// +// The function should not actually be called from anywhere, otherwise +// the compiler will optimize the length expression and replace it with +// with precomputed literals. +//--- + +void AllocateExpr(int lhs, int rhs) { + new int[lhs + rhs]; +} + +// expected-no-diagnostics + Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp === --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -1026,12 +1026,11 @@ ASTContext &AstContext = C.getASTContext(); CharUnits TypeSize = AstContext.getTypeSizeInChars(ElementType); - if (Optional DefinedSize = - ElementCount.getAs()) { + if (Optional DefinedSize = ElementCount.getAs()) { DefinedOrUnknownSVal Extent = Region->getExtent(svalBuilder); // size in Bytes = ElementCount*TypeSize SVal SizeInBytes = svalBuilder.evalBinOpNN( -State, BO_Mul, ElementCount.castAs(), +State, BO_Mul, *DefinedSize, svalBuilder.makeArrayIndex(TypeSize.getQuantity()), svalBuilder.getArrayIndexType()); DefinedOrUnknownSVal extentMatchesSize = svalBuilder.evalEQ( ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r296033 - PR32044: Fix some cases where we would confuse a transparent init-list expression with an aggregate init.
Author: rsmith Date: Thu Feb 23 16:41:47 2017 New Revision: 296033 URL: http://llvm.org/viewvc/llvm-project?rev=296033&view=rev Log: PR32044: Fix some cases where we would confuse a transparent init-list expression with an aggregate init. Modified: cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/test/CodeGenCXX/cxx11-initializer-aggregate.cpp cfe/trunk/test/CodeGenCXX/reference-init.cpp Modified: cfe/trunk/lib/AST/Expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=296033&r1=296032&r2=296033&view=diff == --- cfe/trunk/lib/AST/Expr.cpp (original) +++ cfe/trunk/lib/AST/Expr.cpp Thu Feb 23 16:41:47 2017 @@ -1882,6 +1882,11 @@ bool InitListExpr::isTransparent() const if (getNumInits() != 1 || !getInit(0)) return false; + // Don't confuse aggregate initialization of a struct X { X &x; }; with a + // transparent struct copy. + if (!getInit(0)->isRValue() && getType()->isRecordType()) +return false; + return getType().getCanonicalType() == getInit(0)->getType().getCanonicalType(); } Modified: cfe/trunk/lib/Sema/SemaInit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=296033&r1=296032&r2=296033&view=diff == --- cfe/trunk/lib/Sema/SemaInit.cpp (original) +++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Feb 23 16:41:47 2017 @@ -623,6 +623,11 @@ InitListChecker::FillInEmptyInitializati assert((ILE->getType() != SemaRef.Context.VoidTy) && "Should not have void type"); + // A transparent ILE is not performing aggregate initialization and should + // not be filled in. + if (ILE->isTransparent()) +return; + if (const RecordType *RType = ILE->getType()->getAs()) { const RecordDecl *RDecl = RType->getDecl(); if (RDecl->isUnion() && ILE->getInitializedFieldInUnion()) Modified: cfe/trunk/test/CodeGenCXX/cxx11-initializer-aggregate.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-initializer-aggregate.cpp?rev=296033&r1=296032&r2=296033&view=diff == --- cfe/trunk/test/CodeGenCXX/cxx11-initializer-aggregate.cpp (original) +++ cfe/trunk/test/CodeGenCXX/cxx11-initializer-aggregate.cpp Thu Feb 23 16:41:47 2017 @@ -2,7 +2,16 @@ struct A { int a, b; int f(); }; -// CHECK: define {{.*}}@_Z3fn1i( +namespace NonAggregateCopyInAggregateInit { // PR32044 + struct A { constexpr A(int n) : x(n), y() {} int x, y; } extern a; + // CHECK-DAG: @_ZN31NonAggregateCopyInAggregateInit1bE = global %{{.*}} { %[[A:.*]]* @_ZN31NonAggregateCopyInAggregateInit1aE } + struct B { A &p; } b{{a}}; + // CHECK-DAG: @_ZGRN31NonAggregateCopyInAggregateInit1cE_ = internal global %[[A]] { i32 1, i32 0 } + // CHECK-DAG: @_ZN31NonAggregateCopyInAggregateInit1cE = global %{{.*}} { %{{.*}}* @_ZGRN31NonAggregateCopyInAggregateInit1cE_ } + struct C { A &&p; } c{{1}}; +} + +// CHECK-LABEL: define {{.*}}@_Z3fn1i( int fn1(int x) { // CHECK: %[[INITLIST:.*]] = alloca %struct.A // CHECK: %[[A:.*]] = getelementptr inbounds %struct.A, %struct.A* %[[INITLIST]], i32 0, i32 0 @@ -15,7 +24,7 @@ int fn1(int x) { struct B { int &r; int &f() { return r; } }; -// CHECK: define {{.*}}@_Z3fn2Ri( +// CHECK-LABEL: define {{.*}}@_Z3fn2Ri( int &fn2(int &v) { // CHECK: %[[INITLIST2:.*]] = alloca %struct.B, align 8 // CHECK: %[[R:.*]] = getelementptr inbounds %struct.B, %struct.B* %[[INITLIST2:.*]], i32 0, i32 0 @@ -24,7 +33,7 @@ int &fn2(int &v) { return B{v}.f(); } -// CHECK: define {{.*}}@__cxx_global_var_init( +// CHECK-LABEL: define {{.*}}@__cxx_global_var_init( // // CHECK: call {{.*}}@_ZN14NonTrivialInit1AC1Ev( // CHECK: getelementptr inbounds {{.*}}, i64 1 Modified: cfe/trunk/test/CodeGenCXX/reference-init.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/reference-init.cpp?rev=296033&r1=296032&r2=296033&view=diff == --- cfe/trunk/test/CodeGenCXX/reference-init.cpp (original) +++ cfe/trunk/test/CodeGenCXX/reference-init.cpp Thu Feb 23 16:41:47 2017 @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple -verify %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -verify %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - -std=c++98 | FileCheck %s --check-prefix=CHECK-CXX98 +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - -std=c++11 | FileCheck %s --check-prefix=CHECK-CXX11 // expected-no-diagnostics struct XPTParamDescriptor {}; @@ -23,3 +25,12 @@ Foo& ignoreSetMutex = *(new Foo); // Binding to a bit-field that requires a temporary. struct { int bitfield : 3; } s = { 3 }; const int &s2 = s.bitfield; + +// In C++98, this forms a reference to itself. In C++11 onwa
r296034 - [CodeGen] Silence unused variable warning in Release builds.
Author: d0k Date: Thu Feb 23 16:47:56 2017 New Revision: 296034 URL: http://llvm.org/viewvc/llvm-project?rev=296034&view=rev Log: [CodeGen] Silence unused variable warning in Release builds. Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=296034&r1=296033&r2=296034&view=diff == --- cfe/trunk/lib/CodeGen/CGVTables.cpp (original) +++ cfe/trunk/lib/CodeGen/CGVTables.cpp Thu Feb 23 16:47:56 2017 @@ -284,7 +284,9 @@ void CodeGenFunction::EmitCallAndReturnF if (isa(MD)) CGM.getCXXABI().adjustCallArgsForDestructorThunk(*this, CurGD, CallArgs); +#ifndef NDEBUG unsigned PrefixArgs = CallArgs.size() - 1; +#endif // Add the rest of the arguments. for (const ParmVarDecl *PD : MD->parameters()) EmitDelegateCallArg(CallArgs, PD, SourceLocation()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30239: enable -flto=thin in clang-cl
inglorion updated this revision to Diff 89577. inglorion retitled this revision from "enable -flto=thin, -flto-jobs=, and -fthinlto-index= in clang-cl" to "enable -flto=thin in clang-cl". inglorion added a comment. Implemented @hans's suggestion of moving the tests into cl-options.c. Also restricted the implementation to only implement -flto=. -flto-index= doesn't seem useful without further changes (it just complains that it requires -x ir, which is not supported by clang-cl). -flto-jobs would require a fair bit of extra work compared to what is here now, and I'm not sure it's worth it. The number of jobs lld-link uses can be controlled with /link:/opt:lldltojobs=N, anyway. We can implement support for this later if we want it - for now I really just want -flto=thin. https://reviews.llvm.org/D30239 Files: include/clang/Driver/Options.td test/Driver/cl-options.c Index: test/Driver/cl-options.c === --- test/Driver/cl-options.c +++ test/Driver/cl-options.c @@ -522,6 +522,12 @@ // RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c +// RUN: %clang_cl -### /c -flto %s 2>&1 | FileCheck -check-prefix=LTO %s +// LTO: -flto + +// RUN: %clang_cl -### /c -flto=thin %s 2>&1 | FileCheck -check-prefix=LTO-THIN %s +// LTO-THIN: -flto=thin + // Accept "core" clang options. // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options) // RUN: %clang_cl \ Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -957,7 +957,7 @@ def flat__namespace : Flag<["-"], "flat_namespace">; def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group; def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group; -def flto_EQ : Joined<["-"], "flto=">, Flags<[CC1Option]>, Group, +def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Set LTO mode to either 'full' or 'thin'">; def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Enable LTO in 'full' mode">; Index: test/Driver/cl-options.c === --- test/Driver/cl-options.c +++ test/Driver/cl-options.c @@ -522,6 +522,12 @@ // RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c +// RUN: %clang_cl -### /c -flto %s 2>&1 | FileCheck -check-prefix=LTO %s +// LTO: -flto + +// RUN: %clang_cl -### /c -flto=thin %s 2>&1 | FileCheck -check-prefix=LTO-THIN %s +// LTO-THIN: -flto=thin + // Accept "core" clang options. // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options) // RUN: %clang_cl \ Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -957,7 +957,7 @@ def flat__namespace : Flag<["-"], "flat_namespace">; def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group; def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group; -def flto_EQ : Joined<["-"], "flto=">, Flags<[CC1Option]>, Group, +def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Set LTO mode to either 'full' or 'thin'">; def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Enable LTO in 'full' mode">; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D30312: Fix unix.Malloc analysis crasher when allocating dynamic arrays w/unbound statements (fix PR32050)
This looks pretty similar to https://reviews.llvm.org/D27849 – are you synced to trunk? On Thu, Feb 23, 2017 at 5:42 PM, Kevin Marshall via Phabricator via cfe-commits wrote: > kmarshall created this revision. > > The extent calculation function had a bug which caused it to ignore if the > size value was defined prior to casting it. As a result, size expressions > with free variables would trigger assertion failures during the cast > operation. > > This patch adds that missing check, and replaces the redundant call to > castAs<>() with the SVar that is returned by the checked cast. > > Added a regression test "Malloc+NewDynamicArray" that exercises the fix. > > > https://reviews.llvm.org/D30312 > > Files: > lib/StaticAnalyzer/Checkers/MallocChecker.cpp > test/Analysis/Malloc+NewDynamicArray.cpp > > > Index: test/Analysis/Malloc+NewDynamicArray.cpp > === > --- test/Analysis/Malloc+NewDynamicArray.cpp > +++ test/Analysis/Malloc+NewDynamicArray.cpp > @@ -0,0 +1,17 @@ > +// RUN: %clang_cc1 -analyze -analyzer-checker=unix.Malloc -verify %s > + > +//--- > +// Check that arrays sized using expressions with free variables > +// do not cause the unix.Malloc checker to crash. > +// > +// The function should not actually be called from anywhere, otherwise > +// the compiler will optimize the length expression and replace it with > +// with precomputed literals. > +//--- > + > +void AllocateExpr(int lhs, int rhs) { > + new int[lhs + rhs]; > +} > + > +// expected-no-diagnostics > + > Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp > === > --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp > +++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp > @@ -1026,12 +1026,11 @@ >ASTContext &AstContext = C.getASTContext(); >CharUnits TypeSize = AstContext.getTypeSizeInChars(ElementType); > > - if (Optional DefinedSize = > - ElementCount.getAs()) { > + if (Optional DefinedSize = ElementCount.getAs()) { > DefinedOrUnknownSVal Extent = Region->getExtent(svalBuilder); > // size in Bytes = ElementCount*TypeSize > SVal SizeInBytes = svalBuilder.evalBinOpNN( > -State, BO_Mul, ElementCount.castAs(), > +State, BO_Mul, *DefinedSize, > svalBuilder.makeArrayIndex(TypeSize.getQuantity()), > svalBuilder.getArrayIndexType()); > DefinedOrUnknownSVal extentMatchesSize = svalBuilder.evalEQ( > > > > ___ > 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
r296040 - NFC, Add a test that ensure that we don't emit helper code in copy/dispose
Author: arphaman Date: Thu Feb 23 17:41:50 2017 New Revision: 296040 URL: http://llvm.org/viewvc/llvm-project?rev=296040&view=rev Log: NFC, Add a test that ensure that we don't emit helper code in copy/dispose routines for variables that are const-captured This is a preparation commit that improves code-coverage in code that emits block copy/dispose routines. Modified: cfe/trunk/test/CodeGen/blocks.c Modified: cfe/trunk/test/CodeGen/blocks.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/blocks.c?rev=296040&r1=296039&r2=296040&view=diff == --- cfe/trunk/test/CodeGen/blocks.c (original) +++ cfe/trunk/test/CodeGen/blocks.c Thu Feb 23 17:41:50 2017 @@ -78,3 +78,37 @@ int main() { // CHECK: [[ONE:%.*]] = bitcast void (...)* [[ZERO]] to void ()* // CHECK-NEXT: br label [[CE:%.*]] +// Ensure that we don't emit helper code in copy/dispose routines for variables +// that are const-captured. +void testConstCaptureInCopyAndDestroyHelpers() { + const int x = 0; + __block int i; + (^ { i = x; })(); +} +// CHECK-LABEL: testConstCaptureInCopyAndDestroyHelpers_block_invoke + +// CHECK: @__copy_helper_block +// CHECK: alloca +// CHECK-NEXT: alloca +// CHECK-NEXT: store +// CHECK-NEXT: store +// CHECK-NEXT: load +// CHECK-NEXT: bitcast +// CHECK-NEXT: load +// CHECK-NEXT: bitcast +// CHECK-NEXT: getelementptr +// CHECK-NEXT: getelementptr +// CHECK-NEXT: load +// CHECK-NEXT: bitcast +// CHECK-NEXT: call void @_Block_object_assign +// CHECK-NEXT: ret + +// CHECK: @__destroy_helper_block +// CHECK: alloca +// CHECK-NEXT: store +// CHECK-NEXT: load +// CHECK-NEXT: bitcast +// CHECK-NEXT: getelementptr +// CHECK-NEXT: load +// CHECK-NEXT: call void @_Block_object_dispose +// CHECK-NEXT: ret ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30239: enable -flto=thin in clang-cl
hans accepted this revision. hans added a comment. This revision is now accepted and ready to land. lgtm with a comment Comment at: test/Driver/cl-options.c:525 +// RUN: %clang_cl -### /c -flto %s 2>&1 | FileCheck -check-prefix=LTO %s +// LTO: -flto This needs `--` before `%s`, otherwise if `%s` expands to e.g. `/Users/foo` it will be interpreted as the `/U` option :-) Same thing below. https://reviews.llvm.org/D30239 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30239: enable -flto=thin in clang-cl
inglorion added inline comments. Comment at: test/Driver/cl-options.c:525 +// RUN: %clang_cl -### /c -flto %s 2>&1 | FileCheck -check-prefix=LTO %s +// LTO: -flto hans wrote: > This needs `--` before `%s`, otherwise if `%s` expands to e.g. `/Users/foo` > it will be interpreted as the `/U` option :-) > > Same thing below. Good catch. That's what I get for not copy-pasting it. ;-) https://reviews.llvm.org/D30239 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30239: enable -flto=thin in clang-cl
inglorion updated this revision to Diff 89583. inglorion added a comment. added missing -- https://reviews.llvm.org/D30239 Files: include/clang/Driver/Options.td test/Driver/cl-options.c Index: test/Driver/cl-options.c === --- test/Driver/cl-options.c +++ test/Driver/cl-options.c @@ -522,6 +522,12 @@ // RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c +// RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s +// LTO: -flto + +// RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck -check-prefix=LTO-THIN %s +// LTO-THIN: -flto=thin + // Accept "core" clang options. // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options) // RUN: %clang_cl \ Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -957,7 +957,7 @@ def flat__namespace : Flag<["-"], "flat_namespace">; def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group; def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group; -def flto_EQ : Joined<["-"], "flto=">, Flags<[CC1Option]>, Group, +def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Set LTO mode to either 'full' or 'thin'">; def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Enable LTO in 'full' mode">; Index: test/Driver/cl-options.c === --- test/Driver/cl-options.c +++ test/Driver/cl-options.c @@ -522,6 +522,12 @@ // RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c +// RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s +// LTO: -flto + +// RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck -check-prefix=LTO-THIN %s +// LTO-THIN: -flto=thin + // Accept "core" clang options. // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options) // RUN: %clang_cl \ Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -957,7 +957,7 @@ def flat__namespace : Flag<["-"], "flat_namespace">; def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group; def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group; -def flto_EQ : Joined<["-"], "flto=">, Flags<[CC1Option]>, Group, +def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Set LTO mode to either 'full' or 'thin'">; def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Enable LTO in 'full' mode">; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r296048 - NFC, Add a test that ensures that we don't emit helper code in copy/dispose
Author: arphaman Date: Thu Feb 23 18:09:30 2017 New Revision: 296048 URL: http://llvm.org/viewvc/llvm-project?rev=296048&view=rev Log: NFC, Add a test that ensures that we don't emit helper code in copy/dispose routines for objects that are captured with the __unsafe_unretained ownership qualifier This is a preparation commit that improves code-coverage in code that emits block copy/dispose routines. Modified: cfe/trunk/test/CodeGenObjC/arc-blocks.m Modified: cfe/trunk/test/CodeGenObjC/arc-blocks.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-blocks.m?rev=296048&r1=296047&r2=296048&view=diff == --- cfe/trunk/test/CodeGenObjC/arc-blocks.m (original) +++ cfe/trunk/test/CodeGenObjC/arc-blocks.m Thu Feb 23 18:09:30 2017 @@ -667,6 +667,41 @@ void test18(id x) { // CHECK-UNOPT-NEXT: ret void } +// Ensure that we don't emit helper code in copy/dispose routines for variables +// that are const-captured. +void testUnsafeUnretainedLifetimeInCopyAndDestroyHelpers(id x, id y) { + id __unsafe_unretained unsafeObject = x; + (^ { testUnsafeUnretainedLifetimeInCopyAndDestroyHelpers(x, unsafeObject); })(); +} + +// CHECK-LABEL: testUnsafeUnretainedLifetimeInCopyAndDestroyHelpers_block_invoke +// CHECK-UNOPT-LABEL: testUnsafeUnretainedLifetimeInCopyAndDestroyHelpers_block_invoke + +// CHECK-UNOPT: @__copy_helper_block +// CHECK-UNOPT: alloca +// CHECK-UNOPT-NEXT: alloca +// CHECK-UNOPT-NEXT: store +// CHECK-UNOPT-NEXT: store +// CHECK-UNOPT-NEXT: load +// CHECK-UNOPT-NEXT: bitcast +// CHECK-UNOPT-NEXT: load +// CHECK-UNOPT-NEXT: bitcast +// CHECK-UNOPT-NEXT: getelementptr +// CHECK-UNOPT-NEXT: getelementptr +// CHECK-UNOPT-NEXT: load +// CHECK-UNOPT-NEXT: store +// CHECK-UNOPT-NEXT: call void @objc_storeStrong +// CHECK-UNOPT-NEXT: ret + +// CHECK-UNOPT: @__destroy_helper_block +// CHECK-UNOPT: alloca +// CHECK-UNOPT-NEXT: store +// CHECK-UNOPT-NEXT: load +// CHECK-UNOPT-NEXT: bitcast +// CHECK-UNOPT-NEXT: getelementptr +// CHECK-UNOPT-NEXT: call void @objc_storeStrong +// CHECK-UNOPT-NEXT: ret + // rdar://13588325 void test19_sink(void (^)(int)); void test19(void (^b)(void)) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30315: [Driver] Move architecture-specific free helper functions to their own files.
rsmith accepted this revision. rsmith added a comment. This revision is now accepted and ready to land. It might make sense to move the *Arch.cpp files to a subdirectory of lib/Driver, but otherwise this looks good. https://reviews.llvm.org/D30315 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r296054 - NFC, Remove commented out block of code from CGBlocks.cpp
Author: arphaman Date: Thu Feb 23 18:21:20 2017 New Revision: 296054 URL: http://llvm.org/viewvc/llvm-project?rev=296054&view=rev Log: NFC, Remove commented out block of code from CGBlocks.cpp This is a preparation clean-up commit around the code that emits block copy/dispose routines. Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=296054&r1=296053&r2=296054&view=diff == --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Feb 23 18:21:20 2017 @@ -1373,24 +1373,6 @@ CodeGenFunction::GenerateBlockFunction(G return fn; } -/* -notes.push_back(HelperInfo()); -HelperInfo ¬e = notes.back(); -note.index = capture.getIndex(); -note.RequiresCopying = (ci->hasCopyExpr() || BlockRequiresCopying(type)); -note.cxxbar_import = ci->getCopyExpr(); - -if (ci->isByRef()) { - note.flag = BLOCK_FIELD_IS_BYREF; - if (type.isObjCGCWeak()) -note.flag |= BLOCK_FIELD_IS_WEAK; -} else if (type->isBlockPointerType()) { - note.flag = BLOCK_FIELD_IS_BLOCK; -} else { - note.flag = BLOCK_FIELD_IS_OBJECT; -} - */ - /// Generate the copy-helper function for a block closure object: /// static void block_copy_helper(block_t *dst, block_t *src); /// The runtime will have previously initialized 'dst' by doing a ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29812: Update template-id-expr.cpp test to work when compiler defaults to non-C++03 standard
dyung added a comment. ping https://reviews.llvm.org/D29812 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29812: Update template-id-expr.cpp test to work when compiler defaults to non-C++03 standard
rsmith accepted this revision. rsmith added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D29812 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r296034 - [CodeGen] Silence unused variable warning in Release builds.
Thanks for catching this! :) On Thu, Feb 23, 2017 at 2:47 PM, Benjamin Kramer via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: d0k > Date: Thu Feb 23 16:47:56 2017 > New Revision: 296034 > > URL: http://llvm.org/viewvc/llvm-project?rev=296034&view=rev > Log: > [CodeGen] Silence unused variable warning in Release builds. > > Modified: > cfe/trunk/lib/CodeGen/CGVTables.cpp > > Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CG > VTables.cpp?rev=296034&r1=296033&r2=296034&view=diff > > == > --- cfe/trunk/lib/CodeGen/CGVTables.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGVTables.cpp Thu Feb 23 16:47:56 2017 > @@ -284,7 +284,9 @@ void CodeGenFunction::EmitCallAndReturnF >if (isa(MD)) > CGM.getCXXABI().adjustCallArgsForDestructorThunk(*this, CurGD, > CallArgs); > > +#ifndef NDEBUG >unsigned PrefixArgs = CallArgs.size() - 1; > +#endif >// Add the rest of the arguments. >for (const ParmVarDecl *PD : MD->parameters()) > EmitDelegateCallArg(CallArgs, PD, SourceLocation()); > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30239: enable -flto=thin in clang-cl
inglorion updated this revision to Diff 89590. inglorion added a comment. fail early with a friendlier message when using -flto without -fuse-ld=lld https://reviews.llvm.org/D30239 Files: include/clang/Driver/Options.td lib/Driver/Driver.cpp test/Driver/cl-options.c Index: test/Driver/cl-options.c === --- test/Driver/cl-options.c +++ test/Driver/cl-options.c @@ -522,6 +522,15 @@ // RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c +// RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s +// LTO: -flto + +// RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck -check-prefix=LTO-THIN %s +// LTO-THIN: -flto=thin + +// RUN: %clang_cl -### -Fe%t.exe -entry:main -flto -- %s 2>&1 | FileCheck -check-prefix=LTO-WITHOUT-LLD %s +// LTO-WITHOUT-LLD: invalid argument '-flto' only allowed with '-fuse-ld=lld' + // Accept "core" clang options. // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options) // RUN: %clang_cl \ Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -2352,8 +2352,13 @@ Arg *FinalPhaseArg; phases::ID FinalPhase = getFinalPhase(Args, &FinalPhaseArg); - if (FinalPhase == phases::Link && Args.hasArg(options::OPT_emit_llvm)) { -Diag(clang::diag::err_drv_emit_llvm_link); + if (FinalPhase == phases::Link) { +if (Args.hasArg(options::OPT_emit_llvm)) + Diag(clang::diag::err_drv_emit_llvm_link); +if (IsCLMode() && LTOMode != LTOK_None && +!Args.getLastArgValue(options::OPT_fuse_ld_EQ).equals_lower("lld")) + Diag(clang::diag::err_drv_argument_only_allowed_with) +<< "-flto" << "-fuse-ld=lld"; } // Reject -Z* at the top level, these options should never have been exposed Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -957,7 +957,7 @@ def flat__namespace : Flag<["-"], "flat_namespace">; def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group; def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group; -def flto_EQ : Joined<["-"], "flto=">, Flags<[CC1Option]>, Group, +def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Set LTO mode to either 'full' or 'thin'">; def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Enable LTO in 'full' mode">; Index: test/Driver/cl-options.c === --- test/Driver/cl-options.c +++ test/Driver/cl-options.c @@ -522,6 +522,15 @@ // RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c +// RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s +// LTO: -flto + +// RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck -check-prefix=LTO-THIN %s +// LTO-THIN: -flto=thin + +// RUN: %clang_cl -### -Fe%t.exe -entry:main -flto -- %s 2>&1 | FileCheck -check-prefix=LTO-WITHOUT-LLD %s +// LTO-WITHOUT-LLD: invalid argument '-flto' only allowed with '-fuse-ld=lld' + // Accept "core" clang options. // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options) // RUN: %clang_cl \ Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -2352,8 +2352,13 @@ Arg *FinalPhaseArg; phases::ID FinalPhase = getFinalPhase(Args, &FinalPhaseArg); - if (FinalPhase == phases::Link && Args.hasArg(options::OPT_emit_llvm)) { -Diag(clang::diag::err_drv_emit_llvm_link); + if (FinalPhase == phases::Link) { +if (Args.hasArg(options::OPT_emit_llvm)) + Diag(clang::diag::err_drv_emit_llvm_link); +if (IsCLMode() && LTOMode != LTOK_None && +!Args.getLastArgValue(options::OPT_fuse_ld_EQ).equals_lower("lld")) + Diag(clang::diag::err_drv_argument_only_allowed_with) +<< "-flto" << "-fuse-ld=lld"; } // Reject -Z* at the top level, these options should never have been exposed Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -957,7 +957,7 @@ def flat__namespace : Flag<["-"], "flat_namespace">; def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group; def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group; -def flto_EQ : Joined<["-"], "flto=">, Flags<[CC1Option]>, Group, +def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Set LTO mode to either 'full' or 'thin'">; def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Enable LTO in 'full' mode">; ___ cfe-commits mai
[PATCH] D30239: enable -flto=thin in clang-cl
hans added inline comments. Comment at: test/Driver/cl-options.c:532 +// RUN: %clang_cl -### -Fe%t.exe -entry:main -flto -- %s 2>&1 | FileCheck -check-prefix=LTO-WITHOUT-LLD %s +// LTO-WITHOUT-LLD: invalid argument '-flto' only allowed with '-fuse-ld=lld' + This is nit-picky, but "invalid argument" doesn't sound great to me here; -flto isn't invalid, it's the lack of -fuse-ld=lld that's the problem. Maybe just adding a new "err_drv_flto_without_lld" that says somethihng like "'-flto' without '-fuse-ld=lld' is not supported" would be better? https://reviews.llvm.org/D30239 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30316: AMDGPU: Make 0 the private nullptr value
arsenm created this revision. Herald added subscribers: tpr, dstuttard, tony-tye, nhaehnle, wdng, kzhuravl. https://reviews.llvm.org/D30316 Files: lib/Basic/Targets.cpp test/CodeGenOpenCL/amdgpu-nullptr.cl Index: test/CodeGenOpenCL/amdgpu-nullptr.cl === --- test/CodeGenOpenCL/amdgpu-nullptr.cl +++ test/CodeGenOpenCL/amdgpu-nullptr.cl @@ -20,7 +20,7 @@ // Test 0 as initializer. -// CHECK: @private_p = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4 +// CHECK: @private_p = local_unnamed_addr addrspace(1) global i8* null, align 4 private char *private_p = 0; // CHECK: @local_p = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4 @@ -37,7 +37,7 @@ // Test NULL as initializer. -// CHECK: @private_p_NULL = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4 +// CHECK: @private_p_NULL = local_unnamed_addr addrspace(1) global i8* null, align 4 private char *private_p_NULL = NULL; // CHECK: @local_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4 @@ -58,38 +58,55 @@ // CHECK: @fold_generic = local_unnamed_addr addrspace(1) global i32 addrspace(4)* null, align 4 generic int *fold_generic = (global int*)(generic float*)(private char*)0; -// CHECK: @fold_priv = local_unnamed_addr addrspace(1) global i16* addrspacecast (i16 addrspace(4)* null to i16*), align 4 +// CHECK: @fold_priv = local_unnamed_addr addrspace(1) global i16* null, align 4 private short *fold_priv = (private short*)(generic int*)(global void*)0; -// CHECK: @fold_priv_arith = local_unnamed_addr addrspace(1) global i8* inttoptr (i32 9 to i8*), align 4 +// CHECK: @fold_priv_arith = local_unnamed_addr addrspace(1) global i8* inttoptr (i32 10 to i8*), align 4 private char *fold_priv_arith = (private char*)0 + 10; -// CHECK: @fold_int = local_unnamed_addr addrspace(1) global i32 13, align 4 +// CHECK: @fold_int = local_unnamed_addr addrspace(1) global i32 14, align 4 int fold_int = (int)(private void*)(generic char*)(global int*)0 + 14; -// CHECK: @fold_int2 = local_unnamed_addr addrspace(1) global i32 12, align 4 +// CHECK: @fold_int2 = local_unnamed_addr addrspace(1) global i32 13, align 4 int fold_int2 = (int) ((private void*)0 + 13); -// CHECK: @fold_int3 = local_unnamed_addr addrspace(1) global i32 -1, align 4 +// CHECK: @fold_int3 = local_unnamed_addr addrspace(1) global i32 0, align 4 int fold_int3 = (int) ((private int*)0); -// CHECK: @fold_int4 = local_unnamed_addr addrspace(1) global i32 7, align 4 +// CHECK: @fold_int4 = local_unnamed_addr addrspace(1) global i32 8, align 4 int fold_int4 = (int) &((private int*)0)[2]; -// CHECK: @fold_int5 = local_unnamed_addr addrspace(1) global i32 3, align 4 +// CHECK: @fold_int5 = local_unnamed_addr addrspace(1) global i32 4, align 4 int fold_int5 = (int) &((private StructTy1*)0)->p2; + +// CHECK: @fold_int_local = local_unnamed_addr addrspace(1) global i32 13, align 4 +int fold_int_local = (int)(local void*)(generic char*)(global int*)0 + 14; + +// CHECK: @fold_int2_local = local_unnamed_addr addrspace(1) global i32 12, align 4 +int fold_int2_local = (int) ((local void*)0 + 13); + +// CHECK: @fold_int3_local = local_unnamed_addr addrspace(1) global i32 -1, align 4 +int fold_int3_local = (int) ((local int*)0); + +// CHECK: @fold_int4_local = local_unnamed_addr addrspace(1) global i32 7, align 4 +int fold_int4_local = (int) &((local int*)0)[2]; + +// CHECK: @fold_int5_local = local_unnamed_addr addrspace(1) global i32 3, align 4 +int fold_int5_local = (int) &((local StructTy1*)0)->p2; + + // Test static variable initialization. -// NOOPT: @test_static_var.sp1 = internal addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4 -// NOOPT: @test_static_var.sp2 = internal addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4 -// NOOPT: @test_static_var.sp3 = internal addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4 -// NOOPT: @test_static_var.sp4 = internal addrspace(1) global i8* null, align 4 -// NOOPT: @test_static_var.sp5 = internal addrspace(1) global i8* null, align 4 -// NOOPT: @test_static_var.SS1 = internal addrspace(1) global %struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }, align 4 -// NOOPT: @test_static_var.SS2 = internal addrspace(1) global %struct.StructTy2 zeroinitializer, align 4 +// NOOPT: @test_static_var_private.sp1 = internal addrspace(1) global i8* null, align 4 +// NOOPT: @test_static_var_private.sp2 = internal addrspace(1) global i8* null, align 4 +// NOOPT: @test_static_var_private.sp3 = interna
[PATCH] D28772: [Preprocessor] Fix incorrect token caching that occurs when lexing _Pragma in macro argument pre-expansion mode when skipping a function body
akyrtzi accepted this revision. akyrtzi added a comment. This revision is now accepted and ready to land. LGTM! Repository: rL LLVM https://reviews.llvm.org/D28772 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used
hans added a reviewer: jyknight. hans added a comment. +jyknight, who had a similar patch in http://reviews.llvm.org/D17933 (see also r291477 and PR31864) Comment at: test/CodeGen/atomic-ops.c:1 -// RUN: %clang_cc1 %s -emit-llvm -o - -ffreestanding -ffake-address-space-map -triple=i686-apple-darwin9 | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -o - -ffreestanding -ffake-address-space-map -triple=i686-apple-darwin9 -target-cpu i686 | FileCheck %s // REQUIRES: x86-registered-target Naive question: why is the i686- part of the triple not sufficient here; why is -target-cpu needed? https://reviews.llvm.org/D29542 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30131: [profiling] PR31992: Don't skip interesting non-base constructors
vsk added a comment. In https://reviews.llvm.org/D30131#684310, @arphaman wrote: > LGTM. > > One point to note, when we are displaying coverage for constructors that have > both the base and complete versions instrumented, e.g.: > > class Foo { > public: > Foo() { } > }; > > class Bar : virtual public Foo { > public: > Bar() { }; // llvm-cov will show 2 instantiations for Bar() > }; > > class BarBar: public Bar { > public: > BarBar() { } > }; > > int main (int argc, char* argv[]) > { > BarBar b; > Bar bb; > } > > > llvm-cov will treat each constructor as an instantiation (like a template > instantiation). Should they be treated as instantiations though? No, ideally we'd combine the coverage reporting for Bar's constructors, since it's unlikely that users care about the distinction between them: /tmp/x.cc: 1| |class Foo { 2| |public: 3| 2|Foo() { } 4| |}; 5| | 6| |class Bar : virtual public Foo { 7| |public: 8| 2| Bar() { }; // llvm-cov will show 2 instantiations for Bar() -- | _ZN3BarC2Ev://< It doesn't help that these symbols demangle to the same name.. |8| 1| Bar() { }; // llvm-cov will show 2 instantiations for Bar() -- | _ZN3BarC1Ev: |8| 1| Bar() { }; // llvm-cov will show 2 instantiations for Bar() -- 9| |}; 10| | 11| |class BarBar: public Bar { 12| |public: 13| 1| BarBar() { } 14| |}; 15| | 16| |int main (int argc, char* argv[]) 17| 1|{ 18| 1|BarBar b; // calls _ZN6BarBarC1Ev -> {_ZN3FooC2Ev, _ZN3BarC2Ev} (leaves) 19| 1|Bar bb; // calls _ZN3BarC1Ev -> _ZN3FooC2Ev (leaf) 20| 1|} I don't think this report is 'terrible' though. It's certainly better than saying "BarBar"/"Bar" are executed 0/1 times, which is the status quo. https://reviews.llvm.org/D30131 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r296062 - [profiling] PR31992: Don't skip interesting non-base constructors
Author: vedantk Date: Thu Feb 23 19:15:19 2017 New Revision: 296062 URL: http://llvm.org/viewvc/llvm-project?rev=296062&view=rev Log: [profiling] PR31992: Don't skip interesting non-base constructors Fix the fact that we don't assign profile counters to constructors in classes with virtual bases, or constructors with variadic parameters. Differential Revision: https://reviews.llvm.org/D30131 Modified: cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenPGO.cpp cfe/trunk/test/Profile/Inputs/cxx-class.proftext cfe/trunk/test/Profile/cxx-class.cpp cfe/trunk/test/Profile/cxx-structors.cpp Modified: cfe/trunk/lib/CodeGen/CGClass.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=296062&r1=296061&r2=296062&view=diff == --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) +++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Feb 23 19:15:19 2017 @@ -689,7 +689,8 @@ void CodeGenFunction::EmitInitializerFor /// complete-to-base constructor delegation optimization, i.e. /// emitting the complete constructor as a simple call to the base /// constructor. -static bool IsConstructorDelegationValid(const CXXConstructorDecl *Ctor) { +bool CodeGenFunction::IsConstructorDelegationValid( +const CXXConstructorDecl *Ctor) { // Currently we disable the optimization for classes with virtual // bases because (1) the addresses of parameter variables need to be Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=296062&r1=296061&r2=296062&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Thu Feb 23 19:15:19 2017 @@ -1564,6 +1564,8 @@ public: SourceLocation Loc = SourceLocation(), SourceLocation StartLoc = SourceLocation()); + static bool IsConstructorDelegationValid(const CXXConstructorDecl *Ctor); + void EmitConstructorBody(FunctionArgList &Args); void EmitDestructorBody(FunctionArgList &Args); void emitImplicitAssignmentOperatorBody(FunctionArgList &Args); Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=296062&r1=296061&r2=296062&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Thu Feb 23 19:15:19 2017 @@ -626,10 +626,14 @@ void CodeGenPGO::assignRegionCounters(Gl // Constructors and destructors may be represented by several functions in IR. // If so, instrument only base variant, others are implemented by delegation // to the base one, it would be counted twice otherwise. - if (CGM.getTarget().getCXXABI().hasConstructorVariants() && - ((isa(D) && GD.getCtorType() != Ctor_Base) || - (isa(D) && GD.getDtorType() != Dtor_Base))) { -return; + if (CGM.getTarget().getCXXABI().hasConstructorVariants()) { +if (isa(D) && GD.getDtorType() != Dtor_Base) + return; + +if (const auto *CCD = dyn_cast(D)) + if (GD.getCtorType() != Ctor_Base && + CodeGenFunction::IsConstructorDelegationValid(CCD)) +return; } CGM.ClearUnusedCoverageMapping(D); setFuncName(Fn); Modified: cfe/trunk/test/Profile/Inputs/cxx-class.proftext URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/Inputs/cxx-class.proftext?rev=296062&r1=296061&r2=296062&view=diff == --- cfe/trunk/test/Profile/Inputs/cxx-class.proftext (original) +++ cfe/trunk/test/Profile/Inputs/cxx-class.proftext Thu Feb 23 19:15:19 2017 @@ -39,3 +39,14 @@ _ZN6SimpleC2Ei 100 99 +_ZN7DerivedC1Ev +10 +2 +100 +99 + +_ZN7DerivedD2Ev +10 +2 +100 +99 Modified: cfe/trunk/test/Profile/cxx-class.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-class.cpp?rev=296062&r1=296061&r2=296062&view=diff == --- cfe/trunk/test/Profile/cxx-class.cpp (original) +++ cfe/trunk/test/Profile/cxx-class.cpp Thu Feb 23 19:15:19 2017 @@ -5,6 +5,8 @@ // RUN: FileCheck --input-file=%tgen -check-prefix=DTRGEN %s // RUN: FileCheck --input-file=%tgen -check-prefix=MTHGEN %s // RUN: FileCheck --input-file=%tgen -check-prefix=WRPGEN %s +// RUN: FileCheck --input-file=%tgen -check-prefix=VCTRGEN %s +// RUN: FileCheck --input-file=%tgen -check-prefix=VDTRGEN %s // RUN: llvm-profdata merge %S/Inputs/cxx-class.proftext -o %t.profdata // RUN: %clang_cc1 %s -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata -triple %itanium_abi_triple > %tuse @@ -12,10 +14,12 @@ // RUN: FileCheck --input-file=%tuse -check
[PATCH] D30131: [profiling] PR31992: Don't skip interesting non-base constructors
This revision was automatically updated to reflect the committed changes. Closed by commit rL296062: [profiling] PR31992: Don't skip interesting non-base constructors (authored by vedantk). Changed prior to commit: https://reviews.llvm.org/D30131?vs=89151&id=89595#toc Repository: rL LLVM https://reviews.llvm.org/D30131 Files: cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenPGO.cpp cfe/trunk/test/Profile/Inputs/cxx-class.proftext cfe/trunk/test/Profile/cxx-class.cpp cfe/trunk/test/Profile/cxx-structors.cpp Index: cfe/trunk/test/Profile/cxx-structors.cpp === --- cfe/trunk/test/Profile/cxx-structors.cpp +++ cfe/trunk/test/Profile/cxx-structors.cpp @@ -16,12 +16,28 @@ ~Bar(); }; +struct Baz : virtual public Foo { + Baz() {} + Baz(int x) : Foo(x) {} + ~Baz(); +}; + +struct Quux : public Foo { + Quux(const char *y, ...) : Foo(0) {} +}; + Foo foo; Foo foo2(1); Bar bar; +Baz baz; +Baz baz2(1); +Quux qux("fi", "fo", "fum"); // Profile data for complete constructors and destructors must absent. +// INSTR: @__profc__ZN3BazC1Ev = +// INSTR: @__profc__ZN3BazC1Ei = +// INSTR: @__profc__ZN4QuuxC1EPKcz = // INSTR: @__profc_main = // INSTR: @__profc__ZN3FooC2Ev = // INSTR: @__profc__ZN3FooD2Ev = Index: cfe/trunk/test/Profile/Inputs/cxx-class.proftext === --- cfe/trunk/test/Profile/Inputs/cxx-class.proftext +++ cfe/trunk/test/Profile/Inputs/cxx-class.proftext @@ -39,3 +39,14 @@ 100 99 +_ZN7DerivedC1Ev +10 +2 +100 +99 + +_ZN7DerivedD2Ev +10 +2 +100 +99 Index: cfe/trunk/test/Profile/cxx-class.cpp === --- cfe/trunk/test/Profile/cxx-class.cpp +++ cfe/trunk/test/Profile/cxx-class.cpp @@ -5,17 +5,21 @@ // RUN: FileCheck --input-file=%tgen -check-prefix=DTRGEN %s // RUN: FileCheck --input-file=%tgen -check-prefix=MTHGEN %s // RUN: FileCheck --input-file=%tgen -check-prefix=WRPGEN %s +// RUN: FileCheck --input-file=%tgen -check-prefix=VCTRGEN %s +// RUN: FileCheck --input-file=%tgen -check-prefix=VDTRGEN %s // RUN: llvm-profdata merge %S/Inputs/cxx-class.proftext -o %t.profdata // RUN: %clang_cc1 %s -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata -triple %itanium_abi_triple > %tuse // RUN: FileCheck --input-file=%tuse -check-prefix=CTRUSE %s // RUN: FileCheck --input-file=%tuse -check-prefix=DTRUSE %s // RUN: FileCheck --input-file=%tuse -check-prefix=MTHUSE %s // RUN: FileCheck --input-file=%tuse -check-prefix=WRPUSE %s +// RUN: FileCheck --input-file=%tuse -check-prefix=VCTRUSE %s +// RUN: FileCheck --input-file=%tuse -check-prefix=VDTRUSE %s class Simple { - int Member; public: + int Member; // CTRGEN-LABEL: define {{.*}} @_ZN6SimpleC2Ei( // CTRUSE-LABEL: define {{.*}} @_ZN6SimpleC2Ei( // CTRGEN: store {{.*}} @[[SCC:__profc__ZN6SimpleC2Ei]], i64 0, i64 0 @@ -56,13 +60,43 @@ // MTHUSE: ![[SM1]] = !{!"branch_weights", i32 100, i32 2} }; +class Derived : virtual public Simple { +public: + // VCTRGEN-LABEL: define {{.*}} @_ZN7DerivedC1Ev( + // VCTRUSE-LABEL: define {{.*}} @_ZN7DerivedC1Ev( + // VCTRGEN: store {{.*}} @[[SCC:__profc__ZN7DerivedC1Ev]], i64 0, i64 0 + Derived() : Simple(0) { +// VCTRGEN: store {{.*}} @[[SCC]], i64 0, i64 1 +// VCTRUSE: br {{.*}} !prof ![[SC1:[0-9]+]] +if (Member) {} +// VCTRGEN-NOT: store {{.*}} @[[SCC]], +// VCTRUSE-NOT: br {{.*}} !prof ![0-9]+ +// VCTRUSE: ret + } + // VCTRUSE: ![[SC1]] = !{!"branch_weights", i32 100, i32 2} + + // VDTRGEN-LABEL: define {{.*}} @_ZN7DerivedD2Ev( + // VDTRUSE-LABEL: define {{.*}} @_ZN7DerivedD2Ev( + // VDTRGEN: store {{.*}} @[[SDC:__profc__ZN7DerivedD2Ev]], i64 0, i64 0 + ~Derived() { +// VDTRGEN: store {{.*}} @[[SDC]], i64 0, i64 1 +// VDTRUSE: br {{.*}} !prof ![[SD1:[0-9]+]] +if (Member) {} +// VDTRGEN-NOT: store {{.*}} @[[SDC]], +// VDTRUSE-NOT: br {{.*}} !prof ![0-9]+ +// VDTRUSE: ret + } + // VDTRUSE: ![[SD1]] = !{!"branch_weights", i32 100, i32 2} +}; + // WRPGEN-LABEL: define {{.*}} @_Z14simple_wrapperv( // WRPUSE-LABEL: define {{.*}} @_Z14simple_wrapperv( // WRPGEN: store {{.*}} @[[SWC:__profc__Z14simple_wrapperv]], i64 0, i64 0 void simple_wrapper() { // WRPGEN: store {{.*}} @[[SWC]], i64 0, i64 1 // WRPUSE: br {{.*}} !prof ![[SW1:[0-9]+]] for (int I = 0; I < 100; ++I) { +Derived d; Simple S(I); S.method(); } Index: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp === --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp @@ -626,10 +626,14 @@ // Constructors and destructors may be represented by several functions in IR. // If so, instrument only base variant, others are implemented by delegation // to the base one, it would be counted twice otherwise. - i
r296063 - Revert r291477 "[Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin"
Author: hans Date: Thu Feb 23 19:16:34 2017 New Revision: 296063 URL: http://llvm.org/viewvc/llvm-project?rev=296063&view=rev Log: Revert r291477 "[Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin" It caused PR31864. There is a patch in progress to fix that, but let's revert in the meantime. Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp cfe/trunk/test/Sema/atomic-ops.c Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=296063&r1=296062&r2=296063&view=diff == --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original) +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Thu Feb 23 19:16:34 2017 @@ -286,12 +286,12 @@ static void DefineFastIntType(unsigned T /// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with /// the specified properties. -static const char *getLockFreeValue(unsigned TypeWidth, unsigned InlineWidth) { +static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign, +unsigned InlineWidth) { // Fully-aligned, power-of-2 sizes no larger than the inline // width will be inlined as lock-free operations. - // Note: we do not need to check alignment since _Atomic(T) is always - // appropriately-aligned in clang. - if ((TypeWidth & (TypeWidth - 1)) == 0 && TypeWidth <= InlineWidth) + if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 && + TypeWidth <= InlineWidth) return "2"; // "always lock free" // We cannot be certain what operations the lib calls might be // able to implement as lock-free on future processors. @@ -886,6 +886,7 @@ static void InitializePredefinedMacros(c #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \ Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \ getLockFreeValue(TI.get##Type##Width(), \ + TI.get##Type##Align(), \ InlineWidthBits)); DEFINE_LOCK_FREE_MACRO(BOOL, Bool); DEFINE_LOCK_FREE_MACRO(CHAR, Char); @@ -898,6 +899,7 @@ static void InitializePredefinedMacros(c DEFINE_LOCK_FREE_MACRO(LLONG, LongLong); Builder.defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE", getLockFreeValue(TI.getPointerWidth(0), + TI.getPointerAlign(0), InlineWidthBits)); #undef DEFINE_LOCK_FREE_MACRO } Modified: cfe/trunk/test/Sema/atomic-ops.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/atomic-ops.c?rev=296063&r1=296062&r2=296063&view=diff == --- cfe/trunk/test/Sema/atomic-ops.c (original) +++ cfe/trunk/test/Sema/atomic-ops.c Thu Feb 23 19:16:34 2017 @@ -14,7 +14,11 @@ _Static_assert(__GCC_ATOMIC_WCHAR_T_LOCK _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, ""); _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, ""); _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, ""); +#ifdef __i386__ +_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, ""); +#else _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, ""); +#endif _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, ""); _Static_assert(__c11_atomic_is_lock_free(1), ""); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r291477 - [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin
This was reverted in r296063 due to PR31864. On Mon, Jan 9, 2017 at 12:54 PM, Michal Gorny via cfe-commits wrote: > Author: mgorny > Date: Mon Jan 9 14:54:20 2017 > New Revision: 291477 > > URL: http://llvm.org/viewvc/llvm-project?rev=291477&view=rev > Log: > [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin > > Correct the logic used to set ATOMIC_*_LOCK_FREE preprocessor macros not > to rely on the ABI alignment of types. Instead, just assume all those > types are aligned correctly by default since clang uses safe alignment > for _Atomic types even if the underlying types are aligned to a lower > boundary by default. > > For example, the 'long long' and 'double' types on x86 are aligned to > 32-bit boundary by default. However, '_Atomic long long' and '_Atomic > double' are aligned to 64-bit boundary, therefore satisfying > the requirements of lock-free atomic operations. > > This fixes PR #19355 by correcting the value of > __GCC_ATOMIC_LLONG_LOCK_FREE on x86, and therefore also fixing > the assumption made in libc++ tests. This also fixes PR #30581 by > applying a consistent logic between the functions used to implement > both interfaces. > > Differential Revision: https://reviews.llvm.org/D28213 > > Modified: > cfe/trunk/lib/Frontend/InitPreprocessor.cpp > cfe/trunk/test/Sema/atomic-ops.c > > Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=291477&r1=291476&r2=291477&view=diff > == > --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original) > +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Jan 9 14:54:20 2017 > @@ -286,12 +286,12 @@ static void DefineFastIntType(unsigned T > > /// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with > /// the specified properties. > -static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign, > -unsigned InlineWidth) { > +static const char *getLockFreeValue(unsigned TypeWidth, unsigned > InlineWidth) { >// Fully-aligned, power-of-2 sizes no larger than the inline >// width will be inlined as lock-free operations. > - if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 && > - TypeWidth <= InlineWidth) > + // Note: we do not need to check alignment since _Atomic(T) is always > + // appropriately-aligned in clang. > + if ((TypeWidth & (TypeWidth - 1)) == 0 && TypeWidth <= InlineWidth) > return "2"; // "always lock free" >// We cannot be certain what operations the lib calls might be >// able to implement as lock-free on future processors. > @@ -881,7 +881,6 @@ static void InitializePredefinedMacros(c > #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \ > Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \ > getLockFreeValue(TI.get##Type##Width(), \ > - TI.get##Type##Align(), \ > InlineWidthBits)); > DEFINE_LOCK_FREE_MACRO(BOOL, Bool); > DEFINE_LOCK_FREE_MACRO(CHAR, Char); > @@ -894,7 +893,6 @@ static void InitializePredefinedMacros(c > DEFINE_LOCK_FREE_MACRO(LLONG, LongLong); > Builder.defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE", > getLockFreeValue(TI.getPointerWidth(0), > - TI.getPointerAlign(0), > InlineWidthBits)); > #undef DEFINE_LOCK_FREE_MACRO >} > > Modified: cfe/trunk/test/Sema/atomic-ops.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/atomic-ops.c?rev=291477&r1=291476&r2=291477&view=diff > == > --- cfe/trunk/test/Sema/atomic-ops.c (original) > +++ cfe/trunk/test/Sema/atomic-ops.c Mon Jan 9 14:54:20 2017 > @@ -14,11 +14,7 @@ _Static_assert(__GCC_ATOMIC_WCHAR_T_LOCK > _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, ""); > _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, ""); > _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, ""); > -#ifdef __i386__ > -_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, ""); > -#else > _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, ""); > -#endif > _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, ""); > > _Static_assert(__c11_atomic_is_lock_free(1), ""); > > > ___ > 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
r296066 - Recently a change was made to this test in r294639 which fails when the
Author: dyung Date: Thu Feb 23 19:25:02 2017 New Revision: 296066 URL: http://llvm.org/viewvc/llvm-project?rev=296066&view=rev Log: Recently a change was made to this test in r294639 which fails when the compiler is run in a mode where the default C++ standard is newer than C++03. The reason is because one of the warnings checked is only produced when the compiler is using C++03 or lower. This change fixes this problem as well as adds explicit run lines to run the test in C++03 and C++11 modes. Modified: cfe/trunk/test/SemaTemplate/template-id-expr.cpp Modified: cfe/trunk/test/SemaTemplate/template-id-expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/template-id-expr.cpp?rev=296066&r1=296065&r2=296066&view=diff == --- cfe/trunk/test/SemaTemplate/template-id-expr.cpp (original) +++ cfe/trunk/test/SemaTemplate/template-id-expr.cpp Thu Feb 23 19:25:02 2017 @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++03 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // PR5336 template struct isa_impl_cl { @@ -104,5 +106,8 @@ class E { template<> class D; // expected-error {{cannot specialize a template template parameter}} friend class D; // expected-error {{type alias template 'D' cannot be referenced with a class specifier}} }; -template using D = int; // expected-note {{declared here}} expected-warning {{extension}} +#if __cplusplus <= 199711L +// expected-warning@+2 {{extension}} +#endif +template using D = int; // expected-note {{declared here}} E ed; // expected-note {{instantiation of}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r296067 - Refactor computation of exception specification for special members to remove
Author: rsmith Date: Thu Feb 23 19:29:42 2017 New Revision: 296067 URL: http://llvm.org/viewvc/llvm-project?rev=296067&view=rev Log: Refactor computation of exception specification for special members to remove some of the repetition. Modified: cfe/trunk/include/clang/AST/DeclCXX.h cfe/trunk/lib/Sema/SemaDeclCXX.cpp Modified: cfe/trunk/include/clang/AST/DeclCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=296067&r1=296066&r2=296067&view=diff == --- cfe/trunk/include/clang/AST/DeclCXX.h (original) +++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Feb 23 19:29:42 2017 @@ -203,6 +203,11 @@ public: SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); } SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); } + /// \brief Get the location at which the base class type was written. + SourceLocation getBaseTypeLoc() const LLVM_READONLY { +return BaseTypeInfo->getTypeLoc().getLocStart(); + } + /// \brief Determines whether the base class is a virtual base class (or not). bool isVirtual() const { return Virtual; } Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=296067&r1=296066&r2=296067&view=diff == --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Feb 23 19:29:42 2017 @@ -6091,27 +6091,34 @@ static bool defaultedSpecialMemberIsCons } static Sema::ImplicitExceptionSpecification +ComputeDefaultedSpecialMemberExceptionSpec( +Sema &S, SourceLocation Loc, CXXMethodDecl *MD, Sema::CXXSpecialMember CSM, +Sema::InheritedConstructorInfo *ICI); + +static Sema::ImplicitExceptionSpecification computeImplicitExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD) { - switch (S.getSpecialMember(MD)) { + switch (auto CSM = S.getSpecialMember(MD)) { case Sema::CXXDefaultConstructor: -return S.ComputeDefaultedDefaultCtorExceptionSpec(Loc, MD); +return ComputeDefaultedSpecialMemberExceptionSpec( +S, Loc, MD, Sema::CXXDefaultConstructor, nullptr); case Sema::CXXCopyConstructor: -return S.ComputeDefaultedCopyCtorExceptionSpec(MD); case Sema::CXXCopyAssignment: -return S.ComputeDefaultedCopyAssignmentExceptionSpec(MD); case Sema::CXXMoveConstructor: -return S.ComputeDefaultedMoveCtorExceptionSpec(MD); case Sema::CXXMoveAssignment: -return S.ComputeDefaultedMoveAssignmentExceptionSpec(MD); case Sema::CXXDestructor: -return S.ComputeDefaultedDtorExceptionSpec(MD); +return ComputeDefaultedSpecialMemberExceptionSpec( +S, MD->getLocation(), MD, CSM, nullptr); case Sema::CXXInvalid: break; } - assert(cast(MD)->getInheritedConstructor() && + + auto *CD = cast(MD); + assert(CD->getInheritedConstructor() && "only special members have implicit exception specs"); - return S.ComputeInheritingCtorExceptionSpec(Loc, - cast(MD)); + Sema::InheritedConstructorInfo ICI( + S, Loc, CD->getInheritedConstructor().getShadowDecl()); + return ComputeDefaultedSpecialMemberExceptionSpec( + S, Loc, CD, Sema::CXXDefaultConstructor, &ICI); } static FunctionProtoType::ExtProtoInfo getImplicitMethodEPI(Sema &S, @@ -10036,123 +10043,143 @@ Decl *Sema::ActOnNamespaceAliasDef(Scope return AliasDecl; } -Sema::ImplicitExceptionSpecification -Sema::ComputeDefaultedDefaultCtorExceptionSpec(SourceLocation Loc, - CXXMethodDecl *MD) { - CXXRecordDecl *ClassDecl = MD->getParent(); +namespace { +struct SpecialMemberExceptionSpecInfo { + Sema &S; + CXXMethodDecl *MD; + Sema::CXXSpecialMember CSM; + Sema::InheritedConstructorInfo *ICI; - // C++ [except.spec]p14: - // An implicitly declared special member function (Clause 12) shall have an - // exception-specification. [...] - ImplicitExceptionSpecification ExceptSpec(*this); - if (ClassDecl->isInvalidDecl()) -return ExceptSpec; + SourceLocation Loc; + Sema::ImplicitExceptionSpecification ExceptSpec; - // Direct base-class constructors. - for (const auto &B : ClassDecl->bases()) { -if (B.isVirtual()) // Handled below. - continue; - -if (const RecordType *BaseType = B.getType()->getAs()) { - CXXRecordDecl *BaseClassDecl = cast(BaseType->getDecl()); - CXXConstructorDecl *Constructor = LookupDefaultConstructor(BaseClassDecl); - // If this is a deleted function, add it anyway. This might be conformant - // with the standard. This might not. I'm not sure. It might not matter. - if (Constructor) -ExceptSpec.CalledDecl(B.getLocStart(), Constructor); -} - } + bool ConstArg = false; - // Virtual base-class constructors. - for (const auto &B : ClassDecl-
r296068 - Simplify and pass a more useful source location when computing an exception
Author: rsmith Date: Thu Feb 23 19:36:58 2017 New Revision: 296068 URL: http://llvm.org/viewvc/llvm-project?rev=296068&view=rev Log: Simplify and pass a more useful source location when computing an exception specification for an implicit special member. Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=296068&r1=296067&r2=296068&view=diff == --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Feb 23 19:36:58 2017 @@ -6097,20 +6097,9 @@ ComputeDefaultedSpecialMemberExceptionSp static Sema::ImplicitExceptionSpecification computeImplicitExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD) { - switch (auto CSM = S.getSpecialMember(MD)) { - case Sema::CXXDefaultConstructor: -return ComputeDefaultedSpecialMemberExceptionSpec( -S, Loc, MD, Sema::CXXDefaultConstructor, nullptr); - case Sema::CXXCopyConstructor: - case Sema::CXXCopyAssignment: - case Sema::CXXMoveConstructor: - case Sema::CXXMoveAssignment: - case Sema::CXXDestructor: -return ComputeDefaultedSpecialMemberExceptionSpec( -S, MD->getLocation(), MD, CSM, nullptr); - case Sema::CXXInvalid: -break; - } + auto CSM = S.getSpecialMember(MD); + if (CSM != Sema::CXXInvalid) +return ComputeDefaultedSpecialMemberExceptionSpec(S, Loc, MD, CSM, nullptr); auto *CD = cast(MD); assert(CD->getInheritedConstructor() && ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30239: enable -flto=thin in clang-cl
inglorion updated this revision to Diff 89598. inglorion added a comment. changed error message https://reviews.llvm.org/D30239 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Driver/Options.td lib/Driver/Driver.cpp test/Driver/cl-options.c Index: test/Driver/cl-options.c === --- test/Driver/cl-options.c +++ test/Driver/cl-options.c @@ -522,6 +522,15 @@ // RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c +// RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s +// LTO: -flto + +// RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck -check-prefix=LTO-THIN %s +// LTO-THIN: -flto=thin + +// RUN: %clang_cl -### -Fe%t.exe -entry:main -flto -- %s 2>&1 | FileCheck -check-prefix=LTO-WITHOUT-LLD %s +// LTO-WITHOUT-LLD: LTO requires -fuse-ld=lld + // Accept "core" clang options. // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options) // RUN: %clang_cl \ Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -2352,8 +2352,12 @@ Arg *FinalPhaseArg; phases::ID FinalPhase = getFinalPhase(Args, &FinalPhaseArg); - if (FinalPhase == phases::Link && Args.hasArg(options::OPT_emit_llvm)) { -Diag(clang::diag::err_drv_emit_llvm_link); + if (FinalPhase == phases::Link) { +if (Args.hasArg(options::OPT_emit_llvm)) + Diag(clang::diag::err_drv_emit_llvm_link); +if (IsCLMode() && LTOMode != LTOK_None && +!Args.getLastArgValue(options::OPT_fuse_ld_EQ).equals_lower("lld")) + Diag(clang::diag::err_drv_lto_without_lld); } // Reject -Z* at the top level, these options should never have been exposed Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -957,7 +957,7 @@ def flat__namespace : Flag<["-"], "flat_namespace">; def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group; def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group; -def flto_EQ : Joined<["-"], "flto=">, Flags<[CC1Option]>, Group, +def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Set LTO mode to either 'full' or 'thin'">; def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Enable LTO in 'full' mode">; Index: include/clang/Basic/DiagnosticDriverKinds.td === --- include/clang/Basic/DiagnosticDriverKinds.td +++ include/clang/Basic/DiagnosticDriverKinds.td @@ -133,6 +133,7 @@ "invalid output type '%0' for use with gcc tool">; def err_drv_cc_print_options_failure : Error< "unable to open CC_PRINT_OPTIONS file: %0">; +def err_drv_lto_without_lld : Error<"LTO requires -fuse-ld=lld">; def err_drv_preamble_format : Error< "incorrect format for -preamble-bytes=N,END">; def err_drv_conflicting_deployment_targets : Error< Index: test/Driver/cl-options.c === --- test/Driver/cl-options.c +++ test/Driver/cl-options.c @@ -522,6 +522,15 @@ // RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c +// RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s +// LTO: -flto + +// RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck -check-prefix=LTO-THIN %s +// LTO-THIN: -flto=thin + +// RUN: %clang_cl -### -Fe%t.exe -entry:main -flto -- %s 2>&1 | FileCheck -check-prefix=LTO-WITHOUT-LLD %s +// LTO-WITHOUT-LLD: LTO requires -fuse-ld=lld + // Accept "core" clang options. // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options) // RUN: %clang_cl \ Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -2352,8 +2352,12 @@ Arg *FinalPhaseArg; phases::ID FinalPhase = getFinalPhase(Args, &FinalPhaseArg); - if (FinalPhase == phases::Link && Args.hasArg(options::OPT_emit_llvm)) { -Diag(clang::diag::err_drv_emit_llvm_link); + if (FinalPhase == phases::Link) { +if (Args.hasArg(options::OPT_emit_llvm)) + Diag(clang::diag::err_drv_emit_llvm_link); +if (IsCLMode() && LTOMode != LTOK_None && +!Args.getLastArgValue(options::OPT_fuse_ld_EQ).equals_lower("lld")) + Diag(clang::diag::err_drv_lto_without_lld); } // Reject -Z* at the top level, these options should never have been exposed Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -957,7 +957,7 @@ def flat__namespace : Flag<["-"], "flat_namespace">; def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group; def flimited_prec
[PATCH] D30239: enable -flto=thin in clang-cl
hans added a comment. lgtm2 https://reviews.llvm.org/D30239 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D30312: Fix unix.Malloc analysis crasher when allocating dynamic arrays w/unbound statements (fix PR32050)
Apparently not - I'm at 289944 locally. Sigh. Oh well, it was an interesting investigation. On Thu, Feb 23, 2017 at 3:48 PM, Nico Weber wrote: > This looks pretty similar to https://reviews.llvm.org/D27849 – are you > synced to trunk? > > On Thu, Feb 23, 2017 at 5:42 PM, Kevin Marshall via Phabricator via > cfe-commits wrote: > >> kmarshall created this revision. >> >> The extent calculation function had a bug which caused it to ignore if >> the size value was defined prior to casting it. As a result, size >> expressions with free variables would trigger assertion failures during the >> cast operation. >> >> This patch adds that missing check, and replaces the redundant call to >> castAs<>() with the SVar that is returned by the checked cast. >> >> Added a regression test "Malloc+NewDynamicArray" that exercises the fix. >> >> >> https://reviews.llvm.org/D30312 >> >> Files: >> lib/StaticAnalyzer/Checkers/MallocChecker.cpp >> test/Analysis/Malloc+NewDynamicArray.cpp >> >> >> Index: test/Analysis/Malloc+NewDynamicArray.cpp >> === >> --- test/Analysis/Malloc+NewDynamicArray.cpp >> +++ test/Analysis/Malloc+NewDynamicArray.cpp >> @@ -0,0 +1,17 @@ >> +// RUN: %clang_cc1 -analyze -analyzer-checker=unix.Malloc -verify %s >> + >> +//- >> -- >> +// Check that arrays sized using expressions with free variables >> +// do not cause the unix.Malloc checker to crash. >> +// >> +// The function should not actually be called from anywhere, otherwise >> +// the compiler will optimize the length expression and replace it with >> +// with precomputed literals. >> +//- >> -- >> + >> +void AllocateExpr(int lhs, int rhs) { >> + new int[lhs + rhs]; >> +} >> + >> +// expected-no-diagnostics >> + >> Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp >> === >> --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp >> +++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp >> @@ -1026,12 +1026,11 @@ >>ASTContext &AstContext = C.getASTContext(); >>CharUnits TypeSize = AstContext.getTypeSizeInChars(ElementType); >> >> - if (Optional DefinedSize = >> - ElementCount.getAs()) { >> + if (Optional DefinedSize = ElementCount.getAs()) { >> DefinedOrUnknownSVal Extent = Region->getExtent(svalBuilder); >> // size in Bytes = ElementCount*TypeSize >> SVal SizeInBytes = svalBuilder.evalBinOpNN( >> -State, BO_Mul, ElementCount.castAs(), >> +State, BO_Mul, *DefinedSize, >> svalBuilder.makeArrayIndex(TypeSize.getQuantity()), >> svalBuilder.getArrayIndexType()); >> DefinedOrUnknownSVal extentMatchesSize = svalBuilder.evalEQ( >> >> >> >> ___ >> 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
r296073 - Factor out some common code between SpecialMemberExceptionSpecInfo and SpecialMemberDeletionInfo.
Author: rsmith Date: Thu Feb 23 20:07:20 2017 New Revision: 296073 URL: http://llvm.org/viewvc/llvm-project?rev=296073&view=rev Log: Factor out some common code between SpecialMemberExceptionSpecInfo and SpecialMemberDeletionInfo. To simplify this, convert SpecialMemberOverloadResult to a value type. Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaCUDA.cpp cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaLookup.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=296073&r1=296072&r2=296073&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Thu Feb 23 20:07:20 2017 @@ -931,7 +931,7 @@ public: /// /// This is basically a wrapper around PointerIntPair. The lowest bits of the /// integer are used to determine whether overload resolution succeeded. - class SpecialMemberOverloadResult : public llvm::FastFoldingSetNode { + class SpecialMemberOverloadResult { public: enum Kind { NoMemberOrDeleted, @@ -943,9 +943,9 @@ public: llvm::PointerIntPair Pair; public: -SpecialMemberOverloadResult(const llvm::FoldingSetNodeID &ID) - : FastFoldingSetNode(ID) -{} +SpecialMemberOverloadResult() : Pair() {} +SpecialMemberOverloadResult(CXXMethodDecl *MD) +: Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {} CXXMethodDecl *getMethod() const { return Pair.getPointer(); } void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); } @@ -954,9 +954,18 @@ public: void setKind(Kind K) { Pair.setInt(K); } }; + class SpecialMemberOverloadResultEntry + : public llvm::FastFoldingSetNode, +public SpecialMemberOverloadResult { + public: +SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID) + : FastFoldingSetNode(ID) +{} + }; + /// \brief A cache of special member function overload resolution results /// for C++ records. - llvm::FoldingSet SpecialMemberCache; + llvm::FoldingSet SpecialMemberCache; /// \brief A cache of the flags available in enumerations with the flag_bits /// attribute. @@ -2891,13 +2900,13 @@ public: LOLR_StringTemplate }; - SpecialMemberOverloadResult *LookupSpecialMember(CXXRecordDecl *D, - CXXSpecialMember SM, - bool ConstArg, - bool VolatileArg, - bool RValueThis, - bool ConstThis, - bool VolatileThis); + SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, + CXXSpecialMember SM, + bool ConstArg, + bool VolatileArg, + bool RValueThis, + bool ConstThis, + bool VolatileThis); typedef std::function TypoDiagnosticGenerator; typedef std::function Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=296073&r1=296072&r2=296073&view=diff == --- cfe/trunk/lib/Sema/SemaCUDA.cpp (original) +++ cfe/trunk/lib/Sema/SemaCUDA.cpp Thu Feb 23 20:07:20 2017 @@ -295,7 +295,7 @@ bool Sema::inferCUDATargetForImplicitSpe } CXXRecordDecl *BaseClassDecl = cast(BaseType->getDecl()); -Sema::SpecialMemberOverloadResult *SMOR = +Sema::SpecialMemberOverloadResult SMOR = LookupSpecialMember(BaseClassDecl, CSM, /* ConstArg */ ConstRHS, /* VolatileArg */ false, @@ -303,11 +303,10 @@ bool Sema::inferCUDATargetForImplicitSpe /* ConstThis */ false, /* VolatileThis */ false); -if (!SMOR || !SMOR->getMethod()) { +if (!SMOR.getMethod()) continue; -} -CUDAFunctionTarget BaseMethodTarget = IdentifyCUDATarget(SMOR->getMethod()); +CUDAFunctionTarget BaseMethodTarget = IdentifyCUDATarget(SMOR.getMethod()); if (!InferredTarget.hasValue()) { InferredTarget = BaseMethodTarget; } else { @@ -339,7 +338,7 @@ bool Sema::inferCUDATargetForImplicitSpe } CXXRecordDecl *FieldRecDecl = cast(FieldType->getDecl()); -Sema::SpecialMemberOverloadResult *SMOR = +Sema::SpecialMemberOverloadResult SMOR = LookupSpecialMember(FieldRecDecl, CSM, /* ConstArg */ ConstRHS && !F->is
r296076 - Represent pass_object_size attrs in ExtParameterInfo
Author: gbiv Date: Thu Feb 23 20:49:47 2017 New Revision: 296076 URL: http://llvm.org/viewvc/llvm-project?rev=296076&view=rev Log: Represent pass_object_size attrs in ExtParameterInfo The goal of this is to fix a bug in modules where we'd merge FunctionDecls that differed in their pass_object_size attributes. Since we can overload on the presence of pass_object_size attributes, this behavior is incorrect. We don't represent `N` in `pass_object_size(N)` as part of ExtParameterInfo, since it's an error to overload solely on the value of N. This means that we have a bug if we have two modules that declare functions that differ only in their pass_object_size attrs, like so: // In module A, from a.h void foo(char *__attribute__((pass_object_size(0; // In module B, from b.h void foo(char *__attribute__((pass_object_size(1; // In module C, in main.c #include "a.h" #include "b.h" At the moment, we'll merge the foo decls, when we should instead emit a diagnostic about an invalid overload. We seem to have similar (silent) behavior if we overload only on the return type of `foo` instead; I'll try to find a good place to put a FIXME (or I'll just file a bug) soon. This patch also fixes a bug where we'd not output the proper extended parameter info for declarations with pass_object_size attrs. Modified: cfe/trunk/include/clang/AST/Type.h cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/test/CodeGenObjCXX/arc-attrs-abi.mm cfe/trunk/test/Modules/Inputs/overloadable-attrs/a.h cfe/trunk/test/Modules/overloadable-attrs.cpp Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=296076&r1=296075&r2=296076&view=diff == --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Thu Feb 23 20:49:47 2017 @@ -3116,9 +3116,11 @@ public: class ExtParameterInfo { enum { ABIMask = 0x0F, - IsConsumed = 0x10 + IsConsumed = 0x10, + HasPassObjSize = 0x20, }; unsigned char Data; + public: ExtParameterInfo() : Data(0) {} @@ -3147,6 +3149,15 @@ public: return copy; } +bool hasPassObjectSize() const { + return Data & HasPassObjSize; +} +ExtParameterInfo withHasPassObjectSize() const { + ExtParameterInfo Copy = *this; + Copy.Data |= HasPassObjSize; + return Copy; +} + unsigned char getOpaqueValue() const { return Data; } static ExtParameterInfo getFromOpaqueValue(unsigned char data) { ExtParameterInfo result; Modified: cfe/trunk/lib/CodeGen/CGCall.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=296076&r1=296075&r2=296076&view=diff == --- cfe/trunk/lib/CodeGen/CGCall.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Feb 23 20:49:47 2017 @@ -101,39 +101,64 @@ CodeGenTypes::arrangeFreeFunctionType(Ca FTNP->getExtInfo(), {}, RequiredArgs(0)); } -/// Adds the formal parameters in FPT to the given prefix. If any parameter in +static void addExtParameterInfosForCall( + llvm::SmallVectorImpl ¶mInfos, +const FunctionProtoType *proto, +unsigned prefixArgs, +unsigned totalArgs) { + assert(proto->hasExtParameterInfos()); + assert(paramInfos.size() <= prefixArgs); + assert(proto->getNumParams() + prefixArgs <= totalArgs); + + paramInfos.reserve(totalArgs); + + // Add default infos for any prefix args that don't already have infos. + paramInfos.resize(prefixArgs); + + // Add infos for the prototype. + for (const auto &ParamInfo : proto->getExtParameterInfos()) { +paramInfos.push_back(ParamInfo); +// pass_object_size params have no parameter info. +if (ParamInfo.hasPassObjectSize()) + paramInfos.emplace_back(); + } + + assert(paramInfos.size() <= totalArgs && + "Did we forget to insert pass_object_size args?"); + // Add default infos for the variadic and/or suffix arguments. + paramInfos.resize(totalArgs); +} + +/// Adds the formal paramaters in FPT to the given prefix. If any parameter in /// FPT has pass_object_size attrs, then we'll add parameters for those, too. static void appendParameterTypes(const CodeGenTypes &CGT, SmallVectorImpl &prefix, SmallVectorImpl ¶mInfos, - CanQual FPT, - const FunctionDecl *FD) { - // Fill out paramInfos. - if (FPT->hasExtParameterInfos() || !paramInfos.empty()) { -assert(paramInfos.size() <= prefix.size()); -auto protoParamInfos = FPT->getExtParameterInfos(); -
Re: r295252 - [Modules] Consider enable_if attrs in isSameEntity.
WFM; added them to ExtParameterInfo in r296076. Thanks for the idea! On Wed, Feb 15, 2017 at 5:44 PM, Richard Smith wrote: > On 15 February 2017 at 17:32, George Burgess IV < > george.burgess...@gmail.com> wrote: > >> I remember that we wanted to pretend that pass_object_size isn't a part >> of the FunctionType during the review that added it, though. >> > > I remember we wanted to not add extra fake "parameters" to the > FunctionType to model pass_object_size. I don't remember whether or why we > wanted it to not be part of the function type at all -- on reflection, it > seems as much a part of the type as, say, a calling convention (which it > is, in some sense). > > >> Do you think that would be better than serializing parameters before we >> serialize template info? AFAICT, we only do merging after we start reading >> the template info, so I can't immediately see why that wouldn't work. >> > > I would be concerned about the possibility of that introducing dependency > cycles into the deserialization process. For instance, merging default > arguments for function parameters may require us to have already merged the > function itself into its redeclaration chain (we don't currently model that > quite correctly, so we probably won't hit it today). > > >> On Wed, Feb 15, 2017 at 4:55 PM, Richard Smith >> wrote: >> >>> On 15 February 2017 at 14:43, George Burgess IV via cfe-commits < >>> cfe-commits@lists.llvm.org> wrote: >>> Author: gbiv Date: Wed Feb 15 16:43:27 2017 New Revision: 295252 URL: http://llvm.org/viewvc/llvm-project?rev=295252&view=rev Log: [Modules] Consider enable_if attrs in isSameEntity. Two functions that differ only in their enable_if attributes are considered overloads, so we should check for those when we're trying to figure out if two functions are mergeable. We need to do the same thing for pass_object_size, as well. Looks like that'll be a bit less trivial, since we sometimes do these merging checks before we have pass_object_size attributes available (see the merge checks in ASTDeclReader::VisitFunctionDecl that happen before we read parameters, and merge checks in calls to ReadDeclAs<>()). >>> >>> Perhaps the best way to tackle this would be to track the presence of >>> pass_object_size as part of the function type (in the ExtParameterInfo data >>> on the function type). >>> >>> Added: cfe/trunk/test/Modules/Inputs/overloadable-attrs/ cfe/trunk/test/Modules/Inputs/overloadable-attrs/a.h cfe/trunk/test/Modules/Inputs/overloadable-attrs/module.modulemap cfe/trunk/test/Modules/overloadable-attrs.cpp Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serializat ion/ASTReaderDecl.cpp?rev=295252&r1=295251&r2=295252&view=diff == --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Feb 15 16:43:27 2017 @@ -2656,6 +2656,44 @@ static bool isSameTemplateParameterList( return true; } +/// Determine whether the attributes we can overload on are identical for A and +/// B. Expects A and B to (otherwise) have the same type. +static bool hasSameOverloadableAttrs(const FunctionDecl *A, + const FunctionDecl *B) { + SmallVector AEnableIfs; + // Since this is an equality check, we can ignore that enable_if attrs show up + // in reverse order. + for (const auto *EIA : A->specific_attrs()) +AEnableIfs.push_back(EIA); + + SmallVector BEnableIfs; + for (const auto *EIA : B->specific_attrs()) +BEnableIfs.push_back(EIA); + + // Two very common cases: either we have 0 enable_if attrs, or we have an + // unequal number of enable_if attrs. + if (AEnableIfs.empty() && BEnableIfs.empty()) +return true; + + if (AEnableIfs.size() != BEnableIfs.size()) +return false; + + llvm::FoldingSetNodeID Cand1ID, Cand2ID; + for (unsigned I = 0, E = AEnableIfs.size(); I != E; ++I) { +Cand1ID.clear(); +Cand2ID.clear(); + +AEnableIfs[I]->getCond()->Profile(Cand1ID, A->getASTContext(), true); +BEnableIfs[I]->getCond()->Profile(Cand2ID, B->getASTContext(), true); +if (Cand1ID != Cand2ID) + return false; + } + + // FIXME: This doesn't currently consider pass_object_size attributes, since + // we aren't guaranteed that A and B have valid parameter lists yet. + return true; +} + /// \brief Determine whether the two declarations refer to the same entity. >>
r296078 - [ODRHash] Add handling of TypedefType and DeclarationName
Author: rtrieu Date: Thu Feb 23 20:59:12 2017 New Revision: 296078 URL: http://llvm.org/viewvc/llvm-project?rev=296078&view=rev Log: [ODRHash] Add handling of TypedefType and DeclarationName Differential Revision: https://reviews.llvm.org/D21675 Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td cfe/trunk/lib/AST/ODRHash.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/test/Modules/odr_hash.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=296078&r1=296077&r2=296078&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Thu Feb 23 20:59:12 2017 @@ -133,14 +133,14 @@ def err_module_odr_violation_mismatch_de "static assert with condition|" "static assert with message|" "static assert with %select{|no }4message|" - "field %4}3">; + "field %4|field %4 with type %5}3">; def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found " "%select{" "static assert with different condition|" "static assert with different message|" "static assert with %select{|no }2message|" - "field %2}1">; + "field %2|field %2 with type %3}1">; def warn_module_uses_date_time : Warning< "%select{precompiled header|module}0 uses __DATE__ or __TIME__">, Modified: cfe/trunk/lib/AST/ODRHash.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=296078&r1=296077&r2=296078&view=diff == --- cfe/trunk/lib/AST/ODRHash.cpp (original) +++ cfe/trunk/lib/AST/ODRHash.cpp Thu Feb 23 20:59:12 2017 @@ -32,9 +32,57 @@ void ODRHash::AddIdentifierInfo(const Id ID.AddString(II->getName()); } +void ODRHash::AddDeclarationName(DeclarationName Name) { + AddBoolean(Name.isEmpty()); + if (Name.isEmpty()) +return; + + auto Kind = Name.getNameKind(); + ID.AddInteger(Kind); + switch (Kind) { + case DeclarationName::Identifier: +AddIdentifierInfo(Name.getAsIdentifierInfo()); +break; + case DeclarationName::ObjCZeroArgSelector: + case DeclarationName::ObjCOneArgSelector: + case DeclarationName::ObjCMultiArgSelector: { +Selector S = Name.getObjCSelector(); +AddBoolean(S.isNull()); +AddBoolean(S.isKeywordSelector()); +AddBoolean(S.isUnarySelector()); +unsigned NumArgs = S.getNumArgs(); +for (unsigned i = 0; i < NumArgs; ++i) { + AddIdentifierInfo(S.getIdentifierInfoForSlot(i)); +} +break; + } + case DeclarationName::CXXConstructorName: + case DeclarationName::CXXDestructorName: +AddQualType(Name.getCXXNameType()); +break; + case DeclarationName::CXXOperatorName: +ID.AddInteger(Name.getCXXOverloadedOperator()); +break; + case DeclarationName::CXXLiteralOperatorName: +AddIdentifierInfo(Name.getCXXLiteralIdentifier()); +break; + case DeclarationName::CXXConversionFunctionName: +AddQualType(Name.getCXXNameType()); +break; + case DeclarationName::CXXUsingDirective: +break; + case DeclarationName::CXXDeductionGuideName: { +auto *Template = Name.getCXXDeductionGuideTemplate(); +AddBoolean(Template); +if (Template) { + AddDecl(Template); +} + } + } +} + void ODRHash::AddNestedNameSpecifier(const NestedNameSpecifier *NNS) {} void ODRHash::AddTemplateName(TemplateName Name) {} -void ODRHash::AddDeclarationName(DeclarationName Name) {} void ODRHash::AddTemplateArgument(TemplateArgument TA) {} void ODRHash::AddTemplateParameterList(const TemplateParameterList *TPL) {} @@ -192,6 +240,10 @@ void ODRHash::AddDecl(const Decl *D) { } ID.AddInteger(D->getKind()); + + if (const NamedDecl *ND = dyn_cast(D)) { +AddDeclarationName(ND->getDeclName()); + } } // Process a Type pointer. Add* methods call back into ODRHash while Visit* @@ -212,6 +264,13 @@ public: } } + void AddDecl(Decl *D) { +Hash.AddBoolean(D); +if (D) { + Hash.AddDecl(D); +} + } + void Visit(const Type *T) { ID.AddInteger(T->getTypeClass()); Inherited::Visit(T); @@ -223,6 +282,11 @@ public: ID.AddInteger(T->getKind()); VisitType(T); } + + void VisitTypedefType(const TypedefType *T) { +AddDecl(T->getDecl()); +VisitType(T); + } }; void ODRHash::AddType(const Type *T) { Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=296078&r1=296077&r2=296078&view=diff == --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Feb 23 20:59:12 2017 @@ -9062,6 +9062,7 @@ void ASTReader::diagnoseOdrViolations
r296082 - [Driver] Enable SafeStack for Fuchsia targets
Author: phosek Date: Thu Feb 23 21:17:41 2017 New Revision: 296082 URL: http://llvm.org/viewvc/llvm-project?rev=296082&view=rev Log: [Driver] Enable SafeStack for Fuchsia targets The runtime support is provided directly by the Fuchsia system C library. Patch by Roland McGrath Differential Revision: https://reviews.llvm.org/D30238 Modified: cfe/trunk/lib/Driver/ToolChains.cpp cfe/trunk/lib/Driver/ToolChains.h cfe/trunk/test/Driver/fuchsia.c Modified: cfe/trunk/lib/Driver/ToolChains.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=296082&r1=296081&r2=296082&view=diff == --- cfe/trunk/lib/Driver/ToolChains.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Feb 23 21:17:41 2017 @@ -4860,6 +4860,12 @@ void Fuchsia::AddCXXStdlibLibArgs(const CmdArgs.push_back("-lunwind"); } +SanitizerMask Fuchsia::getSupportedSanitizers() const { + SanitizerMask Res = ToolChain::getSupportedSanitizers(); + Res |= SanitizerKind::SafeStack; + return Res; +} + /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly. DragonFly::DragonFly(const Driver &D, const llvm::Triple &Triple, Modified: cfe/trunk/lib/Driver/ToolChains.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=296082&r1=296081&r2=296082&view=diff == --- cfe/trunk/lib/Driver/ToolChains.h (original) +++ cfe/trunk/lib/Driver/ToolChains.h Thu Feb 23 21:17:41 2017 @@ -1095,6 +1095,8 @@ public: return llvm::DebuggerKind::GDB; } + SanitizerMask getSupportedSanitizers() const override; + RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override; CXXStdlibType Modified: cfe/trunk/test/Driver/fuchsia.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.c?rev=296082&r1=296081&r2=296082&view=diff == --- cfe/trunk/test/Driver/fuchsia.c (original) +++ cfe/trunk/test/Driver/fuchsia.c Thu Feb 23 21:17:41 2017 @@ -38,3 +38,8 @@ // CHECK-RELOCATABLE-NOT: "-pie" // CHECK-RELOCATABLE-NOT: "--build-id" // CHECK-RELOCATABLE: "-r" + +// RUN: %clang %s -### --target=x86_64-unknown-fuchsia \ +// RUN: -fsanitize=safe-stack 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK +// CHECK-SAFESTACK: "-fsanitize=safe-stack" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30238: [Driver] Enable SafeStack for Fuchsia targets
This revision was automatically updated to reflect the committed changes. Closed by commit rL296082: [Driver] Enable SafeStack for Fuchsia targets (authored by phosek). Changed prior to commit: https://reviews.llvm.org/D30238?vs=89393&id=89607#toc Repository: rL LLVM https://reviews.llvm.org/D30238 Files: cfe/trunk/lib/Driver/ToolChains.cpp cfe/trunk/lib/Driver/ToolChains.h cfe/trunk/test/Driver/fuchsia.c Index: cfe/trunk/test/Driver/fuchsia.c === --- cfe/trunk/test/Driver/fuchsia.c +++ cfe/trunk/test/Driver/fuchsia.c @@ -38,3 +38,8 @@ // CHECK-RELOCATABLE-NOT: "-pie" // CHECK-RELOCATABLE-NOT: "--build-id" // CHECK-RELOCATABLE: "-r" + +// RUN: %clang %s -### --target=x86_64-unknown-fuchsia \ +// RUN: -fsanitize=safe-stack 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK +// CHECK-SAFESTACK: "-fsanitize=safe-stack" Index: cfe/trunk/lib/Driver/ToolChains.h === --- cfe/trunk/lib/Driver/ToolChains.h +++ cfe/trunk/lib/Driver/ToolChains.h @@ -1095,6 +1095,8 @@ return llvm::DebuggerKind::GDB; } + SanitizerMask getSupportedSanitizers() const override; + RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override; CXXStdlibType Index: cfe/trunk/lib/Driver/ToolChains.cpp === --- cfe/trunk/lib/Driver/ToolChains.cpp +++ cfe/trunk/lib/Driver/ToolChains.cpp @@ -4860,6 +4860,12 @@ CmdArgs.push_back("-lunwind"); } +SanitizerMask Fuchsia::getSupportedSanitizers() const { + SanitizerMask Res = ToolChain::getSupportedSanitizers(); + Res |= SanitizerKind::SafeStack; + return Res; +} + /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly. DragonFly::DragonFly(const Driver &D, const llvm::Triple &Triple, Index: cfe/trunk/test/Driver/fuchsia.c === --- cfe/trunk/test/Driver/fuchsia.c +++ cfe/trunk/test/Driver/fuchsia.c @@ -38,3 +38,8 @@ // CHECK-RELOCATABLE-NOT: "-pie" // CHECK-RELOCATABLE-NOT: "--build-id" // CHECK-RELOCATABLE: "-r" + +// RUN: %clang %s -### --target=x86_64-unknown-fuchsia \ +// RUN: -fsanitize=safe-stack 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK +// CHECK-SAFESTACK: "-fsanitize=safe-stack" Index: cfe/trunk/lib/Driver/ToolChains.h === --- cfe/trunk/lib/Driver/ToolChains.h +++ cfe/trunk/lib/Driver/ToolChains.h @@ -1095,6 +1095,8 @@ return llvm::DebuggerKind::GDB; } + SanitizerMask getSupportedSanitizers() const override; + RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override; CXXStdlibType Index: cfe/trunk/lib/Driver/ToolChains.cpp === --- cfe/trunk/lib/Driver/ToolChains.cpp +++ cfe/trunk/lib/Driver/ToolChains.cpp @@ -4860,6 +4860,12 @@ CmdArgs.push_back("-lunwind"); } +SanitizerMask Fuchsia::getSupportedSanitizers() const { + SanitizerMask Res = ToolChain::getSupportedSanitizers(); + Res |= SanitizerKind::SafeStack; + return Res; +} + /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly. DragonFly::DragonFly(const Driver &D, const llvm::Triple &Triple, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used
mgorny added inline comments. Comment at: test/CodeGen/atomic-ops.c:1 -// RUN: %clang_cc1 %s -emit-llvm -o - -ffreestanding -ffake-address-space-map -triple=i686-apple-darwin9 | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -o - -ffreestanding -ffake-address-space-map -triple=i686-apple-darwin9 -target-cpu i686 | FileCheck %s // REQUIRES: x86-registered-target hans wrote: > Naive question: why is the i686- part of the triple not sufficient here; why > is -target-cpu needed? It's because triple is not really meaningful on most of the systems (e.g. many Linux distros use i386, *BSD use i486), and the default CPU logic is applied in the Driver, while cc1 is called directly here. https://reviews.llvm.org/D29542 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
RE: r295473 - [OpenMP] Remove barriers at cancel and cancellation point
Hi Hans, Did r295474 fall off your radar? Sorry that I asked for both commits in one email, should I reply to the other original commit? Thanks, Jonas > -Original Message- > From: hwennb...@google.com [mailto:hwennb...@google.com] On Behalf > Of Hans Wennborg > Sent: Thursday, February 23, 2017 7:46 PM > To: Alexey Bataev > Cc: Hahnfeld, Jonas; cfe-commits@lists.llvm.org > Subject: Re: r295473 - [OpenMP] Remove barriers at cancel and cancellation > point > > Thanks! r296000. > > On Wed, Feb 22, 2017 at 8:15 PM, Alexey Bataev > wrote: > > Yes, approved > > > > Best regards, > > Alexey Bataev > > > >> 23 февр. 2017 г., в 1:00, Hans Wennborg > написал(а): > >> > >> Alexey: ping? > >> > >>> On Tue, Feb 21, 2017 at 11:07 AM, Hans Wennborg > wrote: > >>> I'm Ok with it if Alexey approves. > >>> > >>> On Fri, Feb 17, 2017 at 10:52 AM, Hahnfeld, Jonas > >>> wrote: > Hi Hans, Alexey, > > can we merge this commit and r295474 for the 4.0 release or is it > already too late for that? I will totally understand that and can > apply these commits locally prior to installing. > However, I think that these changes are quite focussed and bear > minimal possibility of introducing regressions. > > Thanks, > Jonas > > Am Freitag, den 17.02.2017, 18:32 + schrieb Jonas Hahnfeld via > cfe-commits: > > Author: hahnfeld > Date: Fri Feb 17 12:32:51 2017 > New Revision: 295473 > > URL: http://llvm.org/viewvc/llvm-project?rev=295473&view=rev > Log: > [OpenMP] Remove barriers at cancel and cancellation point > > This resolves a deadlock with the cancel directive when there is no > explicit cancellation point. In that case, the implicit barrier > acts as cancellation point. After removing the barrier after > cancel, the now unmatched barrier for the explicit cancellation > point has to go as well. > > This has probably worked before rL255992: With the calls for the > explicit barrier, it was sure that all threads passed a barrier before > exiting. > > Reported by Simon Convent and Joachim Protze! > > Differential Revision: https://reviews.llvm.org/D30088 > > Modified: > cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp > cfe/trunk/test/OpenMP/cancel_codegen.cpp > cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp smime.p7s Description: S/MIME cryptographic signature ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29812: Update template-id-expr.cpp test to work when compiler defaults to non-C++03 standard
dyung closed this revision. dyung added a comment. I forgot to add a reference to this in the commit message, so I'm closing this manually. This change was submitted with commit r296066. https://reviews.llvm.org/D29812 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits