[PATCH] D32111: [modules] Attempt to fix PR31905 - #include "stddef.h" breaks module map search paths; causes redefinitions.

2017-06-02 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 101307.
EricWF edited the summary of this revision.
EricWF added reviewers: rtrieu, dexonsmith, dblaikie, aprantl, v.g.vassilev.
EricWF added a comment.

- Only allow the top  level header search directories to be search for 
`module.modulemap` files when loading modules in `ReadAST.cpp`.

Perhaps it would be better to figure out what top-level search directory the 
module was originally built under, and then remove the prefix of the top-level 
directory. Then we could allow the search to look under matching subdirectories 
of other top-level search paths. However this seems like it could be incorrect 
as well.

@zygoloid: Any thoughts?


https://reviews.llvm.org/D32111

Files:
  include/clang/Lex/HeaderSearch.h
  lib/Lex/HeaderSearch.cpp
  lib/Serialization/ASTReader.cpp
  test/Modules/Inputs/PR31905/my-project/module.modulemap
  test/Modules/Inputs/PR31905/my-project/my-header.h
  test/Modules/pr31905.cpp

Index: test/Modules/pr31905.cpp
===
--- /dev/null
+++ test/Modules/pr31905.cpp
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cp -R %S/Inputs/PR31905 %t/other-include
+// RUN: %clang_cc1 -std=c++11 -I%S/Inputs/PR31905/ -I%t/other-include -fmodules -fmodules-local-submodule-visibility \
+// RUN:-fimplicit-module-maps -fmodules-cache-path=%t -verify %s
+
+#include "my-project/my-header.h"
+
+int main() {} // expected-no-diagnostics
Index: test/Modules/Inputs/PR31905/my-project/my-header.h
===
--- /dev/null
+++ test/Modules/Inputs/PR31905/my-project/my-header.h
@@ -0,0 +1,4 @@
+#ifndef MY_HEADER_H
+#define MY_HEADER_H
+#include 
+#endif
Index: test/Modules/Inputs/PR31905/my-project/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/PR31905/my-project/module.modulemap
@@ -0,0 +1,3 @@
+module my_project {
+  header "my-header.h"
+}
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -2551,7 +2551,9 @@
  "MODULE_DIRECTORY found before MODULE_NAME");
   // If we've already loaded a module map file covering this module, we may
   // have a better path for it (relative to the current build).
-  Module *M = PP.getHeaderSearchInfo().lookupModule(F.ModuleName);
+  Module *M = PP.getHeaderSearchInfo().lookupModule(
+  F.ModuleName,
+  /*AllowSearch*/ true, /*SearchTopLevelOnly*/ true);
   if (M && M->Directory) {
 // If we're implicitly loading a module, the base directory can't
 // change between the build and use.
Index: lib/Lex/HeaderSearch.cpp
===
--- lib/Lex/HeaderSearch.cpp
+++ lib/Lex/HeaderSearch.cpp
@@ -191,14 +191,15 @@
   return Result.str().str();
 }
 
-Module *HeaderSearch::lookupModule(StringRef ModuleName, bool AllowSearch) {
+Module *HeaderSearch::lookupModule(StringRef ModuleName, bool AllowSearch,
+   bool SearchTopLevelOnly) {
   // Look in the module map to determine if there is a module by this name.
   Module *Module = ModMap.findModule(ModuleName);
   if (Module || !AllowSearch || !HSOpts->ImplicitModuleMaps)
 return Module;
 
   StringRef SearchName = ModuleName;
-  Module = lookupModule(ModuleName, SearchName);
+  Module = lookupModule(ModuleName, SearchName, SearchTopLevelOnly);
 
   // The facility for "private modules" -- adjacent, optional module maps named
   // module.private.modulemap that are supposed to define private submodules --
@@ -208,11 +209,12 @@
   // Foo.framework, when we previously looked and failed to find a
   // FooPrivate.framework.
   if (!Module && SearchName.consume_back("Private"))
-Module = lookupModule(ModuleName, SearchName);
+Module = lookupModule(ModuleName, SearchName, SearchTopLevelOnly);
   return Module;
 }
 
-Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName) {
+Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
+   bool SearchTopLevelOnly) {
   Module *Module = nullptr;
 
   // Look through the various header search paths to load any available module
@@ -267,7 +269,7 @@
 
 // If we've already performed the exhaustive search for module maps in this
 // search directory, don't do it again.
-if (SearchDirs[Idx].haveSearchedAllModuleMaps())
+if (SearchTopLevelOnly || SearchDirs[Idx].haveSearchedAllModuleMaps())
   continue;
 
 // Load all module maps in the immediate subdirectories of this search
Index: include/clang/Lex/HeaderSearch.h
===
--- include/clang/Lex/HeaderSearch.h
+++ include/clang/Lex/HeaderSearch.h
@@ -503,8 +503,12 @@
   

[PATCH] D30963: Fix crash when an 'import a module' TypoCorrection has its CorrectionDecls replaced by visible decls.

2017-06-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Sema/SemaLookup.cpp:3792-3793
 static void checkCorrectionVisibility(Sema , TypoCorrection ) {
   if (TC.begin() == TC.end())
 return;
 

jgorbe wrote:
> rsmith wrote:
> > Do we need to clear the flag on this path too? (This might happen if the 
> > old correction required an import and after clearing we set this up as a 
> > keyword correction.)
> If this might happen, then yes. I have updated the patch to clear the flag 
> here as well but, on second thought, is this path necessary at all? It seems 
> to me that 'no declarations' is a special case of 'all declarations are 
> visible', which we check right after this.
I agree, this check is redundant. Just go ahead and remove it :)


https://reviews.llvm.org/D30963



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r304631 - [sanitizer-coverage] one more flavor of coverage: -fsanitize-coverage=inline-8bit-counters. Experimental so far, not documenting yet. (clang part)

2017-06-02 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Fri Jun  2 20:36:23 2017
New Revision: 304631

URL: http://llvm.org/viewvc/llvm-project?rev=304631=rev
Log:
[sanitizer-coverage] one more flavor of coverage: 
-fsanitize-coverage=inline-8bit-counters. Experimental so far, not documenting 
yet. (clang part)

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/fsanitize-coverage.c

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=304631=304630=304631=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Jun  2 20:36:23 2017
@@ -293,6 +293,9 @@ def fsanitize_coverage_trace_gep
 def fsanitize_coverage_8bit_counters
 : Flag<["-"], "fsanitize-coverage-8bit-counters">,
   HelpText<"Enable frequency counters in sanitizer coverage">;
+def fsanitize_coverage_inline_8bit_counters
+: Flag<["-"], "fsanitize-coverage-inline-8bit-counters">,
+  HelpText<"Enable inline 8-bit counters in sanitizer coverage">;
 def fsanitize_coverage_trace_pc
 : Flag<["-"], "fsanitize-coverage-trace-pc">,
   HelpText<"Enable PC tracing in sanitizer coverage">;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=304631=304630=304631=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Fri Jun  2 20:36:23 2017
@@ -163,6 +163,7 @@ CODEGENOPT(SanitizeCoverageTracePC, 1, 0
   ///< in sanitizer coverage.
 CODEGENOPT(SanitizeCoverageTracePCGuard, 1, 0) ///< Enable PC tracing with 
guard
///< in sanitizer coverage.
+CODEGENOPT(SanitizeCoverageInline8bitCounters, 1, 0) ///< Use inline 8bit 
counters.
 CODEGENOPT(SanitizeCoverageNoPrune, 1, 0) ///< Disable coverage pruning.
 CODEGENOPT(SanitizeStats , 1, 0) ///< Collect statistics for sanitizers.
 CODEGENOPT(SimplifyLibCalls  , 1, 1) ///< Set when -fbuiltin is enabled.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=304631=304630=304631=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Jun  2 20:36:23 2017
@@ -187,6 +187,7 @@ static void addSanitizerCoveragePass(con
   Opts.TracePC = CGOpts.SanitizeCoverageTracePC;
   Opts.TracePCGuard = CGOpts.SanitizeCoverageTracePCGuard;
   Opts.NoPrune = CGOpts.SanitizeCoverageNoPrune;
+  Opts.Inline8bitCounters = CGOpts.SanitizeCoverageInline8bitCounters;
   PM.add(createSanitizerCoverageModulePass(Opts));
 }
 

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=304631=304630=304631=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Fri Jun  2 20:36:23 2017
@@ -48,13 +48,14 @@ enum CoverageFeature {
   CoverageBB = 1 << 1,
   CoverageEdge = 1 << 2,
   CoverageIndirCall = 1 << 3,
-  CoverageTraceBB = 1 << 4,
+  CoverageTraceBB = 1 << 4,  // Deprecated.
   CoverageTraceCmp = 1 << 5,
   CoverageTraceDiv = 1 << 6,
   CoverageTraceGep = 1 << 7,
-  Coverage8bitCounters = 1 << 8,
+  Coverage8bitCounters = 1 << 8,  // Deprecated.
   CoverageTracePC = 1 << 9,
   CoverageTracePCGuard = 1 << 10,
+  CoverageInline8bitCounters = 1 << 12,
   CoverageNoPrune = 1 << 11,
 };
 
@@ -530,7 +531,8 @@ SanitizerArgs::SanitizerArgs(const ToolC
   }
 
   // trace-pc w/o func/bb/edge implies edge.
-  if ((CoverageFeatures & (CoverageTracePC | CoverageTracePCGuard)) &&
+  if ((CoverageFeatures &
+   (CoverageTracePC | CoverageTracePCGuard | CoverageInline8bitCounters)) 
&&
   !(CoverageFeatures & InsertionPointTypes))
 CoverageFeatures |= CoverageEdge;
 
@@ -637,6 +639,7 @@ void SanitizerArgs::addArgs(const ToolCh
 std::make_pair(Coverage8bitCounters, "-fsanitize-coverage-8bit-counters"),
 std::make_pair(CoverageTracePC, "-fsanitize-coverage-trace-pc"),
 std::make_pair(CoverageTracePCGuard, "-fsanitize-coverage-trace-pc-guard"),
+std::make_pair(CoverageInline8bitCounters, 
"-fsanitize-coverage-inline-8bit-counters"),
 std::make_pair(CoverageNoPrune, "-fsanitize-coverage-no-prune")};
   for (auto F : CoverageFlags) {
 if 

[libcxx] r304629 - Fix the recently introduced test to work on C++03

2017-06-02 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Fri Jun  2 20:21:29 2017
New Revision: 304629

URL: http://llvm.org/viewvc/llvm-project?rev=304629=rev
Log:
Fix the recently introduced test to work on C++03

Modified:
libcxx/trunk/test/libcxx/containers/unord/next_pow2.pass.cpp

Modified: libcxx/trunk/test/libcxx/containers/unord/next_pow2.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/unord/next_pow2.pass.cpp?rev=304629=304628=304629=diff
==
--- libcxx/trunk/test/libcxx/containers/unord/next_pow2.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/containers/unord/next_pow2.pass.cpp Fri Jun  2 
20:21:29 2017
@@ -8,6 +8,7 @@
 
//===--===//
 //
 // REQUIRES: long_tests
+// UNSUPPORTED: c++98, c++03
 
 // Not a portable test
 
@@ -30,6 +31,12 @@ is_power_of_two(unsigned long n)
 return __builtin_popcount(n) == 1;
 }
 
+void test_next_pow2_val(size_t n)
+{
+std::size_t npow2 = std::__next_hash_pow2(n);
+assert(is_power_of_two(npow2) && npow2 > n);
+}
+
 void
 test_next_pow2()
 {
@@ -47,11 +54,12 @@ test_next_pow2()
 assert(std::__next_hash_pow2(pow2) == pow2);
 }
 
-for (std::size_t n : {3, 7, 9, 15, 127, 129})
-{
-std::size_t npow2 = std::__next_hash_pow2(n);
-assert(is_power_of_two(npow2) && npow2 > n);
-}
+   test_next_pow2_val(3);
+   test_next_pow2_val(7);
+   test_next_pow2_val(9);
+   test_next_pow2_val(15);
+   test_next_pow2_val(127);
+   test_next_pow2_val(129);
 }
 
 // Note: this is only really useful when run with -fsanitize=undefined.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30963: Fix crash when an 'import a module' TypoCorrection has its CorrectionDecls replaced by visible decls.

2017-06-02 Thread Jorge Gorbe via Phabricator via cfe-commits
jgorbe added inline comments.



Comment at: lib/Sema/SemaLookup.cpp:3792-3793
 static void checkCorrectionVisibility(Sema , TypoCorrection ) {
   if (TC.begin() == TC.end())
 return;
 

rsmith wrote:
> Do we need to clear the flag on this path too? (This might happen if the old 
> correction required an import and after clearing we set this up as a keyword 
> correction.)
If this might happen, then yes. I have updated the patch to clear the flag here 
as well but, on second thought, is this path necessary at all? It seems to me 
that 'no declarations' is a special case of 'all declarations are visible', 
which we check right after this.


https://reviews.llvm.org/D30963



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30963: Fix crash when an 'import a module' TypoCorrection has its CorrectionDecls replaced by visible decls.

2017-06-02 Thread Jorge Gorbe via Phabricator via cfe-commits
jgorbe updated this revision to Diff 101302.
jgorbe added a comment.

Also clear the 'requires import' flag when the TypoCorrection has no decls at 
all.


https://reviews.llvm.org/D30963

Files:
  lib/Sema/SemaLookup.cpp
  test/Modules/Inputs/crash-typo-correction-visibility/module.h
  test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
  test/Modules/crash-typo-correction-visibility.cpp


Index: test/Modules/crash-typo-correction-visibility.cpp
===
--- /dev/null
+++ test/Modules/crash-typo-correction-visibility.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=module -o 
%T/module.pcm -emit-module 
%S/Inputs/crash-typo-correction-visibility/module.modulemap
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-file=%T/module.pcm %s 
-verify
+
+struct S {
+  int member; // expected-note {{declared here}}
+};
+
+int f(...);
+
+int b = sizeof(f(member)); // expected-error {{undeclared identifier 'member'}}
Index: test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
@@ -0,0 +1,3 @@
+module "module" {
+  header "module.h"
+}
Index: test/Modules/Inputs/crash-typo-correction-visibility/module.h
===
--- /dev/null
+++ test/Modules/Inputs/crash-typo-correction-visibility/module.h
@@ -0,0 +1 @@
+struct member;
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3746,20 +3746,24 @@
   bool FindHidden);
 
 /// \brief Check whether the declarations found for a typo correction are
-/// visible, and if none of them are, convert the correction to an 'import
-/// a module' correction.
+/// visible. Set the correction's RequiresImport flag to true if none of the
+/// declarations are visible, false otherwise.
 static void checkCorrectionVisibility(Sema , TypoCorrection ) {
-  if (TC.begin() == TC.end())
+  if (TC.begin() == TC.end()) {
+TC.setRequiresImport(false);
 return;
+  }
 
   TypoCorrection::decl_iterator DI = TC.begin(), DE = TC.end();
 
   for (/**/; DI != DE; ++DI)
 if (!LookupResult::isVisible(SemaRef, *DI))
   break;
-  // Nothing to do if all decls are visible.
-  if (DI == DE)
+  // No filtering needed if all decls are visible.
+  if (DI == DE) {
+TC.setRequiresImport(false);
 return;
+  }
 
   llvm::SmallVector NewDecls(TC.begin(), DI);
   bool AnyVisibleDecls = !NewDecls.empty();


Index: test/Modules/crash-typo-correction-visibility.cpp
===
--- /dev/null
+++ test/Modules/crash-typo-correction-visibility.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=module -o %T/module.pcm -emit-module %S/Inputs/crash-typo-correction-visibility/module.modulemap
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-file=%T/module.pcm %s -verify
+
+struct S {
+  int member; // expected-note {{declared here}}
+};
+
+int f(...);
+
+int b = sizeof(f(member)); // expected-error {{undeclared identifier 'member'}}
Index: test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
@@ -0,0 +1,3 @@
+module "module" {
+  header "module.h"
+}
Index: test/Modules/Inputs/crash-typo-correction-visibility/module.h
===
--- /dev/null
+++ test/Modules/Inputs/crash-typo-correction-visibility/module.h
@@ -0,0 +1 @@
+struct member;
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3746,20 +3746,24 @@
   bool FindHidden);
 
 /// \brief Check whether the declarations found for a typo correction are
-/// visible, and if none of them are, convert the correction to an 'import
-/// a module' correction.
+/// visible. Set the correction's RequiresImport flag to true if none of the
+/// declarations are visible, false otherwise.
 static void checkCorrectionVisibility(Sema , TypoCorrection ) {
-  if (TC.begin() == TC.end())
+  if (TC.begin() == TC.end()) {
+TC.setRequiresImport(false);
 return;
+  }
 
   TypoCorrection::decl_iterator DI = TC.begin(), DE = TC.end();
 
   for (/**/; DI != DE; ++DI)
 if (!LookupResult::isVisible(SemaRef, *DI))
   break;
-  // Nothing to do if all decls are visible.
-  if (DI == DE)
+  // No filtering needed if all decls are visible.
+  if (DI == DE) {
+TC.setRequiresImport(false);
 return;
+  }
 
   

[PATCH] D30963: Fix crash when an 'import a module' TypoCorrection has its CorrectionDecls replaced by visible decls.

2017-06-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaLookup.cpp:3792-3793
 static void checkCorrectionVisibility(Sema , TypoCorrection ) {
   if (TC.begin() == TC.end())
 return;
 

Do we need to clear the flag on this path too? (This might happen if the old 
correction required an import and after clearing we set this up as a keyword 
correction.)


https://reviews.llvm.org/D30963



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Buildbot numbers for the last week of 05/21/2017 - 05/27/2017

2017-06-02 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 05/21/2017 -
05/27/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername |  was_red
+--
 clang-x64-ninja-win7   | 110:30:16
 clang-with-thin-lto-ubuntu | 74:49:07
 sanitizer-x86_64-linux-bootstrap   | 67:49:22
 sanitizer-ppc64be-linux| 53:25:55
 sanitizer-x86_64-linux-fast| 27:40:22
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only  | 27:32:12
 clang-cmake-armv7-a15-full | 26:03:36
 clang-x86-windows-msvc2015 | 25:24:33
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 22:55:33
 clang-ppc64be-linux-multistage | 20:12:56
 perf-x86_64-penryn-O3-polly| 19:20:44
 perf-x86_64-penryn-O3  | 19:11:40
 llvm-clang-x86_64-expensive-checks-win | 15:07:27
 clang-cmake-thumbv7-a15-full-sh| 13:29:45
 lldb-windows7-android  | 12:34:59
 sanitizer-x86_64-linux-fuzzer  | 12:15:42
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan  | 11:19:28
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14 | 11:07:14
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-cxx1z | 11:03:24
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan  | 10:51:20
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11 | 10:51:00
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan  | 10:38:35
 perf-x86_64-penryn-O3-polly-fast   | 10:36:41
 clang-ppc64be-linux| 10:33:35
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx1z | 10:32:33
 clang-ppc64be-linux-lnt| 10:25:24
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu | 10:15:34
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 09:50:32
 clang-cmake-armv7-a15-selfhost-neon| 09:32:30
 clang-lld-x86_64-2stage| 08:58:30
 clang-bpf-build| 08:45:51
 polly-amd64-linux  | 08:21:25
 perf-x86_64-penryn-O3-polly-parallel-fast  | 07:58:51
 lldb-x86_64-ubuntu-14.04-buildserver   | 07:57:02
 clang-cmake-armv7-a15-selfhost | 07:46:54
 clang-x86_64-linux-selfhost-modules-2  | 07:42:43
 clang-cmake-aarch64-lld| 07:41:19
 clang-cmake-aarch64-full   | 07:40:31
 clang-cmake-aarch64-39vma  | 07:33:58
 sanitizer-x86_64-linux | 07:19:23
 clang-with-lto-ubuntu  | 07:17:30
 perf-x86_64-penryn-O3-polly-unprofitable   | 07:13:52
 clang-cuda-build   | 07:09:47
 lldb-x86-windows-msvc2015  | 07:02:31
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan | 06:56:43
 clang-ppc64le-linux| 06:53:03
 clang-cmake-aarch64-quick  | 06:40:01
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 06:39:07
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 06:37:45
 clang-x86_64-linux-selfhost-modules| 06:35:35
 clang-atom-d525-fedora-rel | 06:29:32
 clang-ppc64le-linux-multistage | 06:29:04
 clang-cmake-aarch64-42vma  | 06:23:52
 clang-s390x-linux  | 06:15:34
 lld-x86_64-darwin13| 06:00:42
 clang-native-arm-lnt   | 06:00:03
 sanitizer-windows  | 05:58:04
 clang-hexagon-elf  | 05:56:35
 polly-arm-linux| 05:52:54
 

Buildbot numbers for the week of 05/14/2017 - 05/20/2017

2017-06-02 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 05/14/2017 - 05/20/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername | was_red
+-
 sanitizer-x86_64-linux-fast| 38:43:28
 perf-x86_64-penryn-O3  | 31:17:12
 clang-cmake-thumbv7-a15-full-sh| 30:13:25
 clang-cmake-armv7-a15-selfhost-neon| 28:50:30
 perf-x86_64-penryn-O3-polly-fast   | 28:12:18
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 28:10:31
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only  | 28:02:26
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 26:54:10
 perf-x86_64-penryn-O3-polly-unprofitable   | 26:52:46
 clang-cmake-armv7-a15-selfhost | 26:34:34
 perf-x86_64-penryn-O3-polly-parallel-fast  | 26:27:47
 perf-x86_64-penryn-O3-polly| 24:09:14
 sanitizer-windows  | 15:47:24
 polly-amd64-linux  | 13:51:37
 polly-arm-linux| 13:16:56
 clang-lld-x86_64-2stage| 10:49:44
 sanitizer-ppc64be-linux| 09:46:02
 clang-with-lto-ubuntu  | 08:34:03
 sanitizer-x86_64-linux-autoconf| 08:26:15
 clang-ppc64be-linux| 07:44:26
 clang-x86_64-linux-selfhost-modules| 07:43:55
 lld-x86_64-darwin13| 07:42:32
 clang-with-thin-lto-ubuntu | 07:35:02
 clang-x86_64-linux-selfhost-modules-2  | 07:32:45
 clang-hexagon-elf  | 07:28:51
 clang-s390x-linux  | 07:28:26
 clang-cmake-aarch64-lld| 07:27:06
 clang-cuda-build   | 07:26:07
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 07:21:09
 llvm-hexagon-elf   | 07:08:50
 clang-ppc64le-linux| 07:06:38
 clang-cmake-aarch64-42vma  | 07:06:00
 clang-ppc64le-linux-multistage | 07:02:45
 clang-ppc64be-linux-lnt| 06:57:39
 clang-cmake-aarch64-quick  | 06:54:58
 clang-cmake-aarch64-39vma  | 06:40:23
 sanitizer-ppc64le-linux| 06:17:22
 clang-cmake-thumbv7-a15| 06:11:39
 clang-cmake-armv7-a15  | 06:08:35
 clang-cmake-armv7-a15-full | 05:58:15
 clang-x86_64-debian-fast   | 05:57:36
 clang-cmake-aarch64-full   | 05:55:10
 clang-ppc64be-linux-multistage | 05:51:00
 sanitizer-x86_64-linux | 05:48:32
 clang-x86-windows-msvc2015 | 05:18:47
 clang-bpf-build| 04:23:45
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 03:50:59
 llvm-clang-x86_64-expensive-checks-win | 03:50:58
 clang-x64-ninja-win7   | 03:50:36
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan  | 02:58:40
 lldb-windows7-android  | 02:54:14
 lldb-x86_64-ubuntu-14.04-cmake | 01:40:35
 sanitizer-x86_64-linux-fuzzer  | 01:23:01
 lldb-x86_64-darwin-13.4| 01:19:45
 lldb-x86_64-ubuntu-14.04-buildserver   | 01:19:12
 lld-x86_64-freebsd | 01:05:16
 lldb-amd64-ninja-netbsd8   | 01:01:32
 clang-native-arm-lnt   | 00:50:23
 clang-tools-sphinx-docs| 00:46:14
 

r304620 - [coroutines] Fix rebuilding of dependent coroutine parameters

2017-06-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jun  2 19:22:18 2017
New Revision: 304620

URL: http://llvm.org/viewvc/llvm-project?rev=304620=rev
Log:
[coroutines] Fix rebuilding of dependent coroutine parameters

Summary:
We were not handling correctly rebuilding of parameter and were not creating 
copies for them.
Now we will always rebuild parameter moves in TreeTransform's 
TransformCoroutineBodyStmt.

Reviewers: rsmith, GorNishanov

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D33797

Modified:
cfe/trunk/lib/Sema/CoroutineStmtBuilder.h
cfe/trunk/lib/Sema/SemaCoroutine.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/CodeGenCoroutines/coro-params.cpp
cfe/trunk/test/SemaCXX/coroutines.cpp

Modified: cfe/trunk/lib/Sema/CoroutineStmtBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CoroutineStmtBuilder.h?rev=304620=304619=304620=diff
==
--- cfe/trunk/lib/Sema/CoroutineStmtBuilder.h (original)
+++ cfe/trunk/lib/Sema/CoroutineStmtBuilder.h Fri Jun  2 19:22:18 2017
@@ -51,6 +51,9 @@ public:
   /// name lookup.
   bool buildDependentStatements();
 
+  /// \brief Build just parameter moves. To use for rebuilding in 
TreeTransform.
+  bool buildParameterMoves();
+
   bool isInvalid() const { return !this->IsValid; }
 
 private:

Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=304620=304619=304620=diff
==
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Fri Jun  2 19:22:18 2017
@@ -832,6 +832,12 @@ bool CoroutineStmtBuilder::buildDependen
   return this->IsValid;
 }
 
+bool CoroutineStmtBuilder::buildParameterMoves() {
+  assert(this->IsValid && "coroutine already invalid");
+  assert(this->ParamMoves.empty() && "param moves already built");
+  return this->IsValid = makeParamMoves();
+}
+
 bool CoroutineStmtBuilder::makePromiseStmt() {
   // Form a declaration statement for the promise declaration, so that AST
   // visitors can more easily find it.
@@ -1244,14 +1250,13 @@ static Expr *castForMoving(Sema , Expr
   .get();
 }
 
+
 /// \brief Build a variable declaration for move parameter.
 static VarDecl *buildVarDecl(Sema , SourceLocation Loc, QualType Type,
- StringRef Name) {
-  DeclContext *DC = S.CurContext;
-  IdentifierInfo *II = ().get(Name);
+ IdentifierInfo *II) {
   TypeSourceInfo *TInfo = S.Context.getTrivialTypeSourceInfo(Type, Loc);
   VarDecl *Decl =
-  VarDecl::Create(S.Context, DC, Loc, Loc, II, Type, TInfo, SC_None);
+  VarDecl::Create(S.Context, S.CurContext, Loc, Loc, II, Type, TInfo, 
SC_None);
   Decl->setImplicit();
   return Decl;
 }
@@ -1264,9 +1269,6 @@ bool CoroutineStmtBuilder::makeParamMove
 
 // No need to copy scalars, llvm will take care of them.
 if (Ty->getAsCXXRecordDecl()) {
-  if (!paramDecl->getIdentifier())
-continue;
-
   ExprResult ParamRef =
   S.BuildDeclRefExpr(paramDecl, paramDecl->getType(),
  ExprValueKind::VK_LValue, Loc); // FIXME: scope?
@@ -1275,8 +1277,7 @@ bool CoroutineStmtBuilder::makeParamMove
 
   Expr *RCast = castForMoving(S, ParamRef.get());
 
-  auto D = buildVarDecl(S, Loc, Ty, paramDecl->getIdentifier()->getName());
-
+  auto D = buildVarDecl(S, Loc, Ty, paramDecl->getIdentifier());
   S.AddInitializerToDecl(D, RCast, /*DirectInit=*/true);
 
   // Convert decl to a statement.

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=304620=304619=304620=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Fri Jun  2 19:22:18 2017
@@ -6959,6 +6959,8 @@ TreeTransform::TransformCorouti
   Builder.ReturnStmt = Res.get();
 }
   }
+  if (!Builder.buildParameterMoves())
+return StmtError();
 
   return getDerived().RebuildCoroutineBodyStmt(Builder);
 }

Modified: cfe/trunk/test/CodeGenCoroutines/coro-params.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCoroutines/coro-params.cpp?rev=304620=304619=304620=diff
==
--- cfe/trunk/test/CodeGenCoroutines/coro-params.cpp (original)
+++ cfe/trunk/test/CodeGenCoroutines/coro-params.cpp Fri Jun  2 19:22:18 2017
@@ -93,3 +93,37 @@ void f(int val, MoveOnly moParam, MoveAn
   // CHECK-NEXT: call void @_ZN8MoveOnlyD1Ev(%struct.MoveOnly* %[[MoCopy]]
   // CHECK-NEXT: call i8* @llvm.coro.free(
 }
+
+// CHECK-LABEL: void @_Z16dependent_paramsI1A1BEvT_T0_S3_(%struct.A* %x, 
%struct.B*, %struct.B* %y)
+template 
+void dependent_params(T x, 

[PATCH] D33797: [coroutines] Fix rebuilding of dependent coroutine parameters

2017-06-02 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: lib/Sema/SemaCoroutine.cpp:1285
+  // We needed to check it, but we don't need to generate code for it.
+  if (!paramDecl->getIdentifier())
+continue;

rsmith wrote:
> EricWF wrote:
> > @rsmith Is there a better way to check if the move would be valid for 
> > unnamed parameters without building up these expressions?
> We could wire through a flag to tell `AddInitializerToDecl` to build the 
> `InitializationSequence` but not `Perform` it, but I don't think it's worth 
> the effort. In fact, I'd prefer that we store the copy statement in the AST 
> regardless, and make the choice to elide the copy from within `CodeGen`. 
> (Sema shouldn't be dropping parts of the AST just because CodeGen doesn't 
> need them; for example, a tool that wants to identify all potential callers 
> of the move constructor should be able to find this call.)
> 
> I think we should also disable elision of parameter copies under 
> `-fno-elide-constructors`.
Makes sense that we shouldn't drop this from the AST. I'll fix that.



https://reviews.llvm.org/D33797



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r304618 - Revert r304592

2017-06-02 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Jun  2 19:11:23 2017
New Revision: 304618

URL: http://llvm.org/viewvc/llvm-project?rev=304618=rev
Log:
Revert r304592

r304592 - [ODRHash] Add support for TemplateArgument types.
Possibly causing one of the errors in modules build bot.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=304618=304617=304618=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Jun  2 19:11:23 2017
@@ -128,25 +128,7 @@ void ODRHash::AddTemplateName(TemplateNa
   }
 }
 
-void ODRHash::AddTemplateArgument(TemplateArgument TA) {
-  auto Kind = TA.getKind();
-  ID.AddInteger(Kind);
-
-  switch (Kind) {
-  case TemplateArgument::Null:
-  case TemplateArgument::Declaration:
-  case TemplateArgument::NullPtr:
-  case TemplateArgument::Integral:
-  case TemplateArgument::Template:
-  case TemplateArgument::TemplateExpansion:
-  case TemplateArgument::Expression:
-  case TemplateArgument::Pack:
-break;
-  case TemplateArgument::Type:
-AddQualType(TA.getAsType());
-break;
-  }
-}
+void ODRHash::AddTemplateArgument(TemplateArgument TA) {}
 void ODRHash::AddTemplateParameterList(const TemplateParameterList *TPL) {}
 
 void ODRHash::clear() {

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=304618=304617=304618=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Jun  2 19:11:23 2017
@@ -900,24 +900,6 @@ S2 s2;
 #endif
 }
 
-namespace TemplateArgument {
-#if defined(FIRST)
-template struct U1 {};
-struct S1 {
-  U1 u;
-};
-#elif defined(SECOND)
-template struct U1 {};
-struct S1 {
-  U1 u;
-};
-#else
-S1 s1;
-// expected-error@first.h:* {{'TemplateArgument::S1::u' from module 
'FirstModule' is not present in definition of 'TemplateArgument::S1' in module 
'SecondModule'}}
-// expected-note@second.h:* {{declaration of 'u' does not match}}
-#endif
-}
-
 // Interesting cases that should not cause errors.  struct S should not error
 // while struct T should error at the access specifier mismatch at the end.
 namespace AllDecls {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33588: Fix two sources of UB in __next_hash_pow2 (from __hash_table)

2017-06-02 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added inline comments.
This revision is now accepted and ready to land.



Comment at: include/__hash_table:140
+return (__n > 1) ? (size_t(1) << (std::numeric_limits::digits - 
__clz(__n-1))) : __n;
 }
 

I turned the condition around, and commtted this as r304617:

 return __n < 2 ? __n : (size_t(1) << (std::numeric_limits::digits 
- __clz(__n-1)));



https://reviews.llvm.org/D33588



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r304617 - Fix some undefined behavior in __hash_table. Thanks to vsk for the report and the patch. Reviewed as https://reviews.llvm.org/D33588.

2017-06-02 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Fri Jun  2 19:08:32 2017
New Revision: 304617

URL: http://llvm.org/viewvc/llvm-project?rev=304617=rev
Log:
Fix some undefined behavior in __hash_table. Thanks to vsk for the report and 
the patch. Reviewed as https://reviews.llvm.org/D33588.

Added:
libcxx/trunk/test/libcxx/containers/unord/next_pow2.pass.cpp
Modified:
libcxx/trunk/include/__hash_table

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=304617=304616=304617=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Fri Jun  2 19:08:32 2017
@@ -137,7 +137,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 size_t
 __next_hash_pow2(size_t __n)
 {
-return size_t(1) << (std::numeric_limits::digits - __clz(__n-1));
+return __n < 2 ? __n : (size_t(1) << (std::numeric_limits::digits 
- __clz(__n-1)));
 }
 
 

Added: libcxx/trunk/test/libcxx/containers/unord/next_pow2.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/unord/next_pow2.pass.cpp?rev=304617=auto
==
--- libcxx/trunk/test/libcxx/containers/unord/next_pow2.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/containers/unord/next_pow2.pass.cpp Fri Jun  2 
19:08:32 2017
@@ -0,0 +1,80 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// REQUIRES: long_tests
+
+// Not a portable test
+
+// <__hash_table>
+
+// size_t __next_hash_pow2(size_t n);
+
+// If n <= 1, return n. If n is a power of 2, return n.
+// Otherwise, return the next power of 2.
+
+#include <__hash_table>
+#include 
+#include 
+
+#include 
+
+bool
+is_power_of_two(unsigned long n)
+{
+return __builtin_popcount(n) == 1;
+}
+
+void
+test_next_pow2()
+{
+assert(!is_power_of_two(0));
+assert(is_power_of_two(1));
+assert(is_power_of_two(2));
+assert(!is_power_of_two(3));
+
+assert(std::__next_hash_pow2(0) == 0);
+assert(std::__next_hash_pow2(1) == 1);
+
+for (std::size_t n = 2; n < (sizeof(std::size_t) * 8 - 1); ++n)
+{
+std::size_t pow2 = 1ULL << n;
+assert(std::__next_hash_pow2(pow2) == pow2);
+}
+
+for (std::size_t n : {3, 7, 9, 15, 127, 129})
+{
+std::size_t npow2 = std::__next_hash_pow2(n);
+assert(is_power_of_two(npow2) && npow2 > n);
+}
+}
+
+// Note: this is only really useful when run with -fsanitize=undefined.
+void
+fuzz_unordered_map_reserve(unsigned num_inserts,
+   unsigned num_reserve1,
+   unsigned num_reserve2)
+{
+std::unordered_map m;
+m.reserve(num_reserve1);
+for (unsigned I = 0; I < num_inserts; ++I) m[I] = 0;
+m.reserve(num_reserve2);
+assert(m.bucket_count() >= num_reserve2);
+}
+
+int main()
+{
+test_next_pow2();
+
+for (unsigned num_inserts = 0; num_inserts <= 64; ++num_inserts)
+for (unsigned num_reserve1 = 1; num_reserve1 <= 64; ++num_reserve1)
+for (unsigned num_reserve2 = 1; num_reserve2 <= 64; ++num_reserve2)
+fuzz_unordered_map_reserve(num_inserts, num_reserve1, 
num_reserve2);
+
+return 0;
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30963: Fix crash when an 'import a module' TypoCorrection has its CorrectionDecls replaced by visible decls.

2017-06-02 Thread Jorge Gorbe via Phabricator via cfe-commits
jgorbe added a comment.

Ping?


https://reviews.llvm.org/D30963



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33797: [coroutines] Fix rebuilding of dependent coroutine parameters

2017-06-02 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 101293.
EricWF added a comment.

- No longer unnamed parameters from the AST.


https://reviews.llvm.org/D33797

Files:
  lib/Sema/CoroutineStmtBuilder.h
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/TreeTransform.h
  test/CodeGenCoroutines/coro-params.cpp
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -892,3 +892,16 @@
 co_await d; // OK
   }
 }
+
+template 
+struct NoCopy {
+  NoCopy(NoCopy const&) = delete; // expected-note 2 {{deleted here}}
+};
+template 
+void test_dependent_param(T t, U) {
+  // expected-error@-1 {{call to deleted constructor of 'NoCopy<0>'}}
+  // expected-error@-2 {{call to deleted constructor of 'NoCopy<1>'}}
+  ((void)t);
+  co_return 42;
+}
+template void test_dependent_param(NoCopy<0>, NoCopy<1>); // expected-note {{requested here}}
Index: test/CodeGenCoroutines/coro-params.cpp
===
--- test/CodeGenCoroutines/coro-params.cpp
+++ test/CodeGenCoroutines/coro-params.cpp
@@ -93,3 +93,37 @@
   // CHECK-NEXT: call void @_ZN8MoveOnlyD1Ev(%struct.MoveOnly* %[[MoCopy]]
   // CHECK-NEXT: call i8* @llvm.coro.free(
 }
+
+// CHECK-LABEL: void @_Z16dependent_paramsI1A1BEvT_T0_S3_(%struct.A* %x, %struct.B*, %struct.B* %y)
+template 
+void dependent_params(T x, U, U y) {
+  // CHECK: %[[x_copy:.+]] = alloca %struct.A
+  // CHECK-NEXT: %[[unnamed_copy:.+]] = alloca %struct.B
+  // CHECK-NEXT: %[[y_copy:.+]] = alloca %struct.B
+
+  // CHECK: call i8* @llvm.coro.begin
+  // CHECK-NEXT: call void @_ZN1AC1EOS_(%struct.A* %[[x_copy]], %struct.A* dereferenceable(512) %x)
+  // CHECK-NEXT: call void @_ZN1BC1EOS_(%struct.B* %[[unnamed_copy]], %struct.B* dereferenceable(512) %0)
+  // CHECK-NEXT: call void @_ZN1BC1EOS_(%struct.B* %[[y_copy]], %struct.B* dereferenceable(512) %y)
+  // CHECK-NEXT: invoke void @_ZNSt12experimental16coroutine_traitsIJv1A1BS2_EE12promise_typeC1Ev(
+
+  co_return;
+}
+
+struct A {
+  int WontFitIntoRegisterForSure[128];
+  A();
+  A(A&&) noexcept;
+  ~A();
+};
+
+struct B {
+  int WontFitIntoRegisterForSure[128];
+  B();
+  B(B&&) noexcept;
+  ~B();
+};
+
+void call_dependent_params() {
+  dependent_params(A{}, B{}, B{});
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6959,6 +6959,8 @@
   Builder.ReturnStmt = Res.get();
 }
   }
+  if (!Builder.buildParameterMoves())
+return StmtError();
 
   return getDerived().RebuildCoroutineBodyStmt(Builder);
 }
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -832,6 +832,12 @@
   return this->IsValid;
 }
 
+bool CoroutineStmtBuilder::buildParameterMoves() {
+  assert(this->IsValid && "coroutine already invalid");
+  assert(this->ParamMoves.empty() && "param moves already built");
+  return this->IsValid = makeParamMoves();
+}
+
 bool CoroutineStmtBuilder::makePromiseStmt() {
   // Form a declaration statement for the promise declaration, so that AST
   // visitors can more easily find it.
@@ -1244,14 +1250,13 @@
   .get();
 }
 
+
 /// \brief Build a variable declaration for move parameter.
 static VarDecl *buildVarDecl(Sema , SourceLocation Loc, QualType Type,
- StringRef Name) {
-  DeclContext *DC = S.CurContext;
-  IdentifierInfo *II = ().get(Name);
+ IdentifierInfo *II) {
   TypeSourceInfo *TInfo = S.Context.getTrivialTypeSourceInfo(Type, Loc);
   VarDecl *Decl =
-  VarDecl::Create(S.Context, DC, Loc, Loc, II, Type, TInfo, SC_None);
+  VarDecl::Create(S.Context, S.CurContext, Loc, Loc, II, Type, TInfo, SC_None);
   Decl->setImplicit();
   return Decl;
 }
@@ -1264,19 +1269,15 @@
 
 // No need to copy scalars, llvm will take care of them.
 if (Ty->getAsCXXRecordDecl()) {
-  if (!paramDecl->getIdentifier())
-continue;
-
   ExprResult ParamRef =
   S.BuildDeclRefExpr(paramDecl, paramDecl->getType(),
  ExprValueKind::VK_LValue, Loc); // FIXME: scope?
   if (ParamRef.isInvalid())
 return false;
 
   Expr *RCast = castForMoving(S, ParamRef.get());
 
-  auto D = buildVarDecl(S, Loc, Ty, paramDecl->getIdentifier()->getName());
-
+  auto D = buildVarDecl(S, Loc, Ty, paramDecl->getIdentifier());
   S.AddInitializerToDecl(D, RCast, /*DirectInit=*/true);
 
   // Convert decl to a statement.
Index: lib/Sema/CoroutineStmtBuilder.h
===
--- lib/Sema/CoroutineStmtBuilder.h
+++ lib/Sema/CoroutineStmtBuilder.h
@@ -51,6 +51,9 @@
   /// name lookup.
   bool buildDependentStatements();
 
+  /// \brief Build just parameter moves. To use for 

[PATCH] D33797: [coroutines] Fix rebuilding of dependent coroutine parameters

2017-06-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaCoroutine.cpp:1285
+  // We needed to check it, but we don't need to generate code for it.
+  if (!paramDecl->getIdentifier())
+continue;

EricWF wrote:
> @rsmith Is there a better way to check if the move would be valid for unnamed 
> parameters without building up these expressions?
We could wire through a flag to tell `AddInitializerToDecl` to build the 
`InitializationSequence` but not `Perform` it, but I don't think it's worth the 
effort. In fact, I'd prefer that we store the copy statement in the AST 
regardless, and make the choice to elide the copy from within `CodeGen`. (Sema 
shouldn't be dropping parts of the AST just because CodeGen doesn't need them; 
for example, a tool that wants to identify all potential callers of the move 
constructor should be able to find this call.)

I think we should also disable elision of parameter copies under 
`-fno-elide-constructors`.


https://reviews.llvm.org/D33797



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-06-02 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

OK, I will try to make it work on linux and windows only


https://reviews.llvm.org/D33852



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33841: [clang-tidy] redundant keyword check

2017-06-02 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

extern on function definition is also redundant, right?

Also, what about:
inline extern void foo();
(you check if it startswith extern)


Repository:
  rL LLVM

https://reviews.llvm.org/D33841



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33797: [coroutines] Fix rebuilding of dependent coroutine parameters

2017-06-02 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: lib/Sema/SemaCoroutine.cpp:1285
+  // We needed to check it, but we don't need to generate code for it.
+  if (!paramDecl->getIdentifier())
+continue;

@rsmith Is there a better way to check if the move would be valid for unnamed 
parameters without building up these expressions?


https://reviews.llvm.org/D33797



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33797: [coroutines] Fix rebuilding of dependent coroutine parameters

2017-06-02 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 101291.
EricWF added a comment.

- Diagnose non-moveable but otherwise unnamed parameters.
- Have TreeTransform.h check if building the move params is successful.


https://reviews.llvm.org/D33797

Files:
  lib/Sema/CoroutineStmtBuilder.h
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/TreeTransform.h
  test/CodeGenCoroutines/coro-params.cpp
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -892,3 +892,16 @@
 co_await d; // OK
   }
 }
+
+template 
+struct NoCopy {
+  NoCopy(NoCopy const&) = delete; // expected-note 2 {{deleted here}}
+};
+template 
+void test_dependent_param(T t, U) {
+  // expected-error@-1 {{call to deleted constructor of 'NoCopy<0>'}}
+  // expected-error@-2 {{call to deleted constructor of 'NoCopy<1>'}}
+  ((void)t);
+  co_return 42;
+}
+template void test_dependent_param(NoCopy<0>, NoCopy<1>); // expected-note {{requested here}}
Index: test/CodeGenCoroutines/coro-params.cpp
===
--- test/CodeGenCoroutines/coro-params.cpp
+++ test/CodeGenCoroutines/coro-params.cpp
@@ -93,3 +93,34 @@
   // CHECK-NEXT: call void @_ZN8MoveOnlyD1Ev(%struct.MoveOnly* %[[MoCopy]]
   // CHECK-NEXT: call i8* @llvm.coro.free(
 }
+
+// CHECK-LABEL: void @_Z16dependent_paramsI1A1BEvT_T0_(%struct.A* %x, %struct.B*)
+template 
+void dependent_params(T x, U) {
+  // CHECK: %[[x_copy:.+]] = alloca %struct.A
+  // CHECK-NOT: alloca %struct.B
+
+  // CHECK: call i8* @llvm.coro.begin
+  // CHECK-NEXT: call void @_ZN1AC1EOS_(%struct.A* %[[x_copy]], %struct.A* dereferenceable(512) %x)
+  // CHECK-NEXT: invoke void @_ZNSt12experimental16coroutine_traitsIJv1A1BEE12promise_typeC1Ev
+
+  co_return;
+}
+
+struct A {
+  int WontFitIntoRegisterForSure[128];
+  A();
+  A(A&&) noexcept;
+  ~A();
+};
+
+struct B {
+  int WontFitIntoRegisterForSure[128];
+  B();
+  B(B&&) noexcept;
+  ~B();
+};
+
+void call_dependent_params() {
+  dependent_params(A{}, B{});
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6959,6 +6959,8 @@
   Builder.ReturnStmt = Res.get();
 }
   }
+  if (!Builder.buildParameterMoves())
+return StmtError();
 
   return getDerived().RebuildCoroutineBodyStmt(Builder);
 }
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -832,6 +832,12 @@
   return this->IsValid;
 }
 
+bool CoroutineStmtBuilder::buildParameterMoves() {
+  assert(this->IsValid && "coroutine already invalid");
+  assert(this->ParamMoves.empty() && "param moves already built");
+  return this->IsValid = makeParamMoves();
+}
+
 bool CoroutineStmtBuilder::makePromiseStmt() {
   // Form a declaration statement for the promise declaration, so that AST
   // visitors can more easily find it.
@@ -1244,14 +1250,13 @@
   .get();
 }
 
+
 /// \brief Build a variable declaration for move parameter.
 static VarDecl *buildVarDecl(Sema , SourceLocation Loc, QualType Type,
- StringRef Name) {
-  DeclContext *DC = S.CurContext;
-  IdentifierInfo *II = ().get(Name);
+ IdentifierInfo *II) {
   TypeSourceInfo *TInfo = S.Context.getTrivialTypeSourceInfo(Type, Loc);
   VarDecl *Decl =
-  VarDecl::Create(S.Context, DC, Loc, Loc, II, Type, TInfo, SC_None);
+  VarDecl::Create(S.Context, S.CurContext, Loc, Loc, II, Type, TInfo, SC_None);
   Decl->setImplicit();
   return Decl;
 }
@@ -1264,21 +1269,22 @@
 
 // No need to copy scalars, llvm will take care of them.
 if (Ty->getAsCXXRecordDecl()) {
-  if (!paramDecl->getIdentifier())
-continue;
-
   ExprResult ParamRef =
   S.BuildDeclRefExpr(paramDecl, paramDecl->getType(),
  ExprValueKind::VK_LValue, Loc); // FIXME: scope?
   if (ParamRef.isInvalid())
 return false;
 
   Expr *RCast = castForMoving(S, ParamRef.get());
 
-  auto D = buildVarDecl(S, Loc, Ty, paramDecl->getIdentifier()->getName());
-
+  auto D = buildVarDecl(S, Loc, Ty, paramDecl->getIdentifier());
   S.AddInitializerToDecl(D, RCast, /*DirectInit=*/true);
 
+  // Throw away the build declaration if the parameter is unnamed.
+  // We needed to check it, but we don't need to generate code for it.
+  if (!paramDecl->getIdentifier())
+continue;
+
   // Convert decl to a statement.
   StmtResult Stmt = S.ActOnDeclStmt(S.ConvertDeclToDeclGroup(D), Loc, Loc);
   if (Stmt.isInvalid())
Index: lib/Sema/CoroutineStmtBuilder.h
===
--- lib/Sema/CoroutineStmtBuilder.h
+++ lib/Sema/CoroutineStmtBuilder.h
@@ -51,6 +51,9 @@
   /// name lookup.
   bool 

[PATCH] D33841: [clang-tidy] redundant keyword check

2017-06-02 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

In https://reviews.llvm.org/D33841#771944, @Prazek wrote:

> Feature request: removing "void" from int main(void)


This will duplicate modernize-redundant-void-arg.


Repository:
  rL LLVM

https://reviews.llvm.org/D33841



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33841: [clang-tidy] redundant keyword check

2017-06-02 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

Feature request: removing "void" from int main(void)


Repository:
  rL LLVM

https://reviews.llvm.org/D33841



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33841: [clang-tidy] redundant keyword check

2017-06-02 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please mention this check in docs/ReleaseNotes.rst (in alphabetical order).




Comment at: docs/clang-tidy/checks/readability-redundant-keyword.rst:6
+
+This checker removes the redundant `extern` and `inline` keywords from code.
+

checker -> check. Please use `` to highlight language constructs here and below.



Comment at: docs/clang-tidy/checks/readability-redundant-keyword.rst:13
+  extern void h();
+
+

Unnecessary empty line.



Comment at: docs/clang-tidy/checks/readability-redundant-keyword.rst:20
+  class X {
+inline int f() {  }
+  };

May be three dots will be better as common punctuation?



Comment at: docs/clang-tidy/checks/readability-redundant-keyword.rst:22
+  };
\ No newline at end of file


Please add newline.


Repository:
  rL LLVM

https://reviews.llvm.org/D33841



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33833: Fix PR 33189: Clang assertion on template destructor declaration

2017-06-02 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: lib/AST/DeclCXX.cpp:1420
   DeclContext::lookup_result R = lookup(Name);
-  if (R.empty())
+  if (R.empty() || !isa(R.front()))
 return nullptr;

As it is,
```
return R.empty() ? nullptr : dyn_cast(R.front());
```
would probably be much more succinct.



https://reviews.llvm.org/D33833



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r304604 - Fix assertion failure if we can't deduce a template argument for a variable

2017-06-02 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jun  2 17:53:06 2017
New Revision: 304604

URL: http://llvm.org/viewvc/llvm-project?rev=304604=rev
Log:
Fix assertion failure if we can't deduce a template argument for a variable
template partial specialization.

In passing, fix the deduction-crash.cpp test to actually run all the tests. Due
to a typo, the last third of the file was being skipped by the parser and some
of the tests were not actually testing anything as a result. Switch from
FileCheck to -verify to make the problem more obvious and prevent this
happening again.

Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaTemplate/deduction-crash.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=304604=304603=304604=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Fri Jun  2 17:53:06 2017
@@ -2383,7 +2383,8 @@ static Sema::TemplateDeductionResult Con
 bool HasDefaultArg = false;
 TemplateDecl *TD = dyn_cast(Template);
 if (!TD) {
-  assert(isa(Template));
+  assert(isa(Template) ||
+ isa(Template));
   return Sema::TDK_Incomplete;
 }
 

Modified: cfe/trunk/test/SemaTemplate/deduction-crash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/deduction-crash.cpp?rev=304604=304603=304604=diff
==
--- cfe/trunk/test/SemaTemplate/deduction-crash.cpp (original)
+++ cfe/trunk/test/SemaTemplate/deduction-crash.cpp Fri Jun  2 17:53:06 2017
@@ -1,14 +1,10 @@
-// RUN: not %clang_cc1 -fsyntax-only %s -std=c++11 2>&1| FileCheck %s
-
-// Note that the error count below doesn't matter. We just want to
-// make sure that the parser doesn't crash.
-// CHECK: 17 errors
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++1z -verify
 
 // PR7511
-template
+template // expected-error +{{}}
 struct int_;
 
-template
+template // expected-error +{{}}
 template
 struct ac
 {
@@ -17,7 +13,7 @@ struct ac
 
 templatestruct aaa
 {
-  typedef ac<1,int,int>::ae ae
+  typedef ac<1,int,int>::ae ae // expected-error +{{}}
 };
 
 template
@@ -36,19 +32,19 @@ struct state_machine
 struct In;
 
 template
-struct In;
+struct In; // expected-error +{{}}
 
 template
 int process(Event)
 {
-  In > a;
+  In > a; // expected-error +{{}}
 }
-  }
+  } // expected-error +{{}}
   template
   int ant(Event)
   {
 region_processing_helper* helper;
-helper->process(0)
+helper->process(0) // expected-error +{{}}
   }
 };
 
@@ -81,21 +77,21 @@ void endl( ) ;
 
 extern basic_ostream cout;
 
-int operator<<( basic_ostream , pair ) ;
+int operator<<( basic_ostream , pair ) ; // expected-note +{{}}
 
 void register_object_imp ( )
 {
-cout << endl<1>;
+cout << endl<1>; // expected-error +{{}}
 }
 
 // PR12933
-namespacae PR12933 {
-  template
+namespace PR12933 {
+  template // expected-error +{{}}
 template
 void function(S a, T b) {}
 
   int main() {
-function(0, 1);
+function(0, 1); // expected-error +{{}}
 return 0;
   }
 }
@@ -142,3 +138,9 @@ namespace PR14281_part3 {
   template  struct B {};
   A, _decl>::type x;
 }
+
+namespace var_template_partial_spec_incomplete {
+  template int n;
+  template int n; // expected-error +{{}} 
expected-note {{}}
+  int k = n;
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-06-02 Thread Davide Italiano via Phabricator via cfe-commits
davide added a comment.

If you take my example, and you pass `-target x86_64-pc-win32-macho`:

On clang-3.8, `TinkyWinky` is lowered to a GV with `weak_odr` linkage:

  $ clang++ 1.cpp -o - -emit-llvm -S -fms-extensions -target 
x86_64-pc-win32-macho
  ; ModuleID = '1.cpp'
  target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
  target triple = "x86_64-pc-windows-macho"
  
  @TinkyWinky = weak_odr global i32 0, align 4
  
  !llvm.module.flags = !{!0}
  !llvm.ident = !{!1}
  
  !0 = !{i32 1, !"PIC Level", i32 2}
  !1 = !{!"clang version 3.8.0 (tags/RELEASE_380/final)"}

On clang-5.0 (trunk, release+assert), the compiler just crashes :(

  $ ../clang++ 1.cpp -o - -emit-llvm -S -fms-extensions -target 
x86_64-pc-win32-macho
  clang-5.0: ../tools/clang/lib/CodeGen/CodeGenModule.cpp:479: void 
clang::CodeGen::CodeGenModule::Release(): Assertion `(LangOpts.ShortWChar || 
llvm::TargetLibraryInfoImpl::getTarget
  WCharSize(Target.getTriple()) == Target.getWCharWidth() / 8) && "LLVM wchar_t 
size out of sync"' failed.
  #0 0x0206f67a llvm::sys::PrintStackTrace(llvm::raw_ostream&) 
(/home/davide/work/llvm/build-release/bin/clang-5.0+0x206f67a)
  #1 0x0206d46e llvm::sys::RunSignalHandlers() 
(/home/davide/work/llvm/build-release/bin/clang-5.0+0x206d46e)
  #2 0x0206d5bc SignalHandler(int) 
(/home/davide/work/llvm/build-release/bin/clang-5.0+0x206d5bc)
  #3 0x7f72dc473c30 __restore_rt (/lib64/libpthread.so.0+0x10c30)
  #4 0x7f72dafdf765 __GI_raise (/lib64/libc.so.6+0x34765)
  #5 0x7f72dafe136a __GI_abort (/lib64/libc.so.6+0x3636a)
  #6 0x7f72dafd7f97 __assert_fail_base (/lib64/libc.so.6+0x2cf97)
  #7 0x7f72dafd8042 (/lib64/libc.so.6+0x2d042)
  #8 0x022cab88 clang::CodeGen::CodeGenModule::Release() 
(/home/davide/work/llvm/build-release/bin/clang-5.0+0x22cab88)
  #9 0x028fbc77 (anonymous 
namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) 
(/home/davide/work/llvm/build-release/bin/clang-5.0+0x28fbc77)
  #10 0x028fa965 
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) 
(/home/davide/work/llvm/build-release/bin/clang-5.0+0x28fa965)
  #11 0x02ccdf38 clang::ParseAST(clang::Sema&, bool, bool) 
(/home/davide/work/llvm/build-release/bin/clang-5.0+0x2ccdf38)
  #12 0x028f9bbc clang::CodeGenAction::ExecuteAction() 
(/home/davide/work/llvm/build-release/bin/clang-5.0+0x28f9bbc)
  #13 0x025bae0e clang::FrontendAction::Execute() 
(/home/davide/work/llvm/build-release/bin/clang-5.0+0x25bae0e)
  #14 0x0258c746 
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) 
(/home/davide/work/llvm/build-release/bin/clang-5.0+0x258c746)
  #15 0x0264ac7b 
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) 
(/home/davide/work/llvm/build-release/bin/clang-5.0+0x264ac7b)
  #16 0x00aff078 cc1_main(llvm::ArrayRef, char const*, 
void*) (/home/davide/work/llvm/build-release/bin/clang-5.0+0xaff078)
  #17 0x00a92775 main 
(/home/davide/work/llvm/build-release/bin/clang-5.0+0xa92775)
  #18 0x7f72dafcb731 __libc_start_main (/lib64/libc.so.6+0x20731)
  #19 0x00afb7e9 _start 
(/home/davide/work/llvm/build-release/bin/clang-5.0+0xafb7e9)
  Stack dump:
  0.  Program arguments: /home/davide/work/llvm/build-release/bin/clang-5.0 
-cc1 -triple x86_64-pc-windows-macho -emit-llvm -disable-free -main-file-name 
1.cpp -mrelocation-model
  pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fmath-errno 
-masm-verbose -mconstructor-aliases -target-cpu x86-64 -dwarf-column-info 
-debugger-tuning=gdb -coverage-notes-f
  ile /home/davide/work/llvm/build-release/bin/decl/-.gcno -resource-dir 
/home/davide/work/llvm/build-release/lib/clang/5.0.0 -internal-isystem 
/home/davide/work/llvm/build-release/li
  b/clang/5.0.0/include -fdeprecated-macro -fdebug-compilation-dir 
/home/davide/work/llvm/build-release/bin/decl -ferror-limit 19 -fmessage-length 
181 -fms-extensions -fms-compatibili
  ty -fms-compatibility-version=18 -std=c++11 -fno-threadsafe-statics 
-fdelayed-template-parsing -fobjc-runtime=gcc -fcxx-exceptions -fexceptions 
-fdiagnostics-show-option -fcolor-dia
  gnostics -o - -x c++ 1.cpp
  1.   parser at end of file
  2.  Per-file LLVM IR generation
  clang-5.0: error: unable to execute command: Aborted (core dumped)
  clang-5.0: error: clang frontend command failed due to signal (use -v to see 
invocation)
  clang version 5.0.0 (trunk 304592) (llvm/trunk 304594)
  Target: x86_64-pc-windows-macho


https://reviews.llvm.org/D33852



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-06-02 Thread Davide Italiano via Phabricator via cfe-commits
davide added a comment.

I think lowering `__declspec(selectany)` to a `comdat` for GVs on ELF platform 
is actually reasonable.
I don't know what happens on Mach-O (as far as I can tell they don't have a 
real notion of COMDAT, they use coalesced symbols, but I'm not an expert of the 
format so you might want to ask somebody who's familiar with it). I think Reid 
should sign-off this change anyway.


https://reviews.llvm.org/D33852



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r304376 - PR33232: implement support for MSVC's __is_trivially_destructible trait.

2017-06-02 Thread Richard Smith via cfe-commits
I think it comes down to a question of whether we want to guarantee that
these traits are treated as not being identifiers. In some sense, it's an
implementation detail that we model them as keywords -- and as it happens,
there are some circumstances in which we *don't* model them as keywords.
For example:

// Starts off as a keyword
const bool a = __is_trivial(int);
#if __is_identifier(__is_trivial)
#error not an identifier
#endif

// Downgraded to a simple identifier
template struct __is_trivial {};
#if !__is_identifier(__is_trivial)
#error is an identifier
#endif

// Can still be used as a trait, though
const bool b = __is_trivial(int);

The implementation of the above would be simpler if we *never* treated
these traits as keywords, but that would break libc++ if it relies on
__is_identifier to check this.

Ultimately, though if people are already relying on using __is_identifier
for this, then maybe we should just say that's the supported way to check
for these things (and keep it working that way if we ever do change the
internal representation to something else).

On 2 June 2017 at 13:44, Eric Fiselier  wrote:

> I've been using !__is_identifier to test for things like that. It seems to
> be the most consistent way.
> Is there some problem with this?
>
> /Eric
>
> On Thu, Jun 1, 2017 at 6:46 PM, Richard Smith 
> wrote:
>
>> On 31 May 2017 at 17:41, Eric Fiselier  wrote:
>>
>>> I'm assuming libc++ should move to this trait instead?
>>>
>>
>> Yes, that'd be a good idea. Though now that you mention it, I'm not sure
>> we have a good feature detection story for these builtins. Looks like a
>> bunch of the existing ones are (oddly) covered by __has_feature, and they
>> can all be discovered through !__is_identifier, but __has_extension or
>> __has_builtin seem like the right detection mechanism and neither of them
>> works here. ;-(
>>
>> Thoughts?
>>
>>
>>> /Eric
>>>
>>> On Wed, May 31, 2017 at 6:28 PM, Richard Smith via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: rsmith
 Date: Wed May 31 19:28:16 2017
 New Revision: 304376

 URL: http://llvm.org/viewvc/llvm-project?rev=304376=rev
 Log:
 PR33232: implement support for MSVC's __is_trivially_destructible trait.

 Unlike the GCC-compatible __has_trivial_destructor trait, this one
 computes the
 right answer rather than performing the quirky set of checks described
 in GCC's
 documentation (https://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html).

 MSVC also has a __has_trivial_destructor trait which is the same as its
 (and
 now Clang's) __is_trivially_destructible trait; we might want to
 consider
 changing the behavior of __has_trivial_destructor if we're targeting an
 MSVC
 platform, but I'm not doing so for now.

 While implementing this I found that we were incorrectly rejecting
 __is_destructible queries on arrays of unknown bound of incomplete
 types; that
 too is fixed, and I've added similar tests for other traits for good
 measure.

 Modified:
 cfe/trunk/include/clang/Basic/TokenKinds.def
 cfe/trunk/include/clang/Basic/TypeTraits.h
 cfe/trunk/lib/Sema/SemaExprCXX.cpp
 cfe/trunk/test/SemaCXX/type-traits.cpp

 Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
 Basic/TokenKinds.def?rev=304376=304375=304376=diff
 
 ==
 --- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
 +++ cfe/trunk/include/clang/Basic/TokenKinds.def Wed May 31 19:28:16
 2017
 @@ -411,6 +411,7 @@ TYPE_TRAIT_1(__is_sealed, IsSealed, KEYM

  // MSVC12.0 / VS2013 Type Traits
  TYPE_TRAIT_1(__is_destructible, IsDestructible, KEYMS)
 +TYPE_TRAIT_1(__is_trivially_destructible, IsTriviallyDestructible,
 KEYCXX)
  TYPE_TRAIT_1(__is_nothrow_destructible, IsNothrowDestructible, KEYMS)
  TYPE_TRAIT_2(__is_nothrow_assignable, IsNothrowAssignable, KEYCXX)
  TYPE_TRAIT_N(__is_constructible, IsConstructible, KEYCXX)
 @@ -439,7 +440,6 @@ TYPE_TRAIT_2(__is_convertible_to, IsConv
  TYPE_TRAIT_1(__is_empty, IsEmpty, KEYCXX)
  TYPE_TRAIT_1(__is_enum, IsEnum, KEYCXX)
  TYPE_TRAIT_1(__is_final, IsFinal, KEYCXX)
 -// Tentative name - there's no implementation of std::is_literal_type
 yet.
  TYPE_TRAIT_1(__is_literal, IsLiteral, KEYCXX)
  // Name for GCC 4.6 compatibility - people have already written
 libraries using
  // this name unfortunately.

 Modified: cfe/trunk/include/clang/Basic/TypeTraits.h
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
 Basic/TypeTraits.h?rev=304376=304375=304376=diff
 
 ==
 --- 

[PATCH] D33797: [coroutines] Fix rebuilding of dependent coroutine parameters

2017-06-02 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov updated this revision to Diff 101282.
GorNishanov added a comment.

test updated to use %[[copy_x]] instead of %x1


https://reviews.llvm.org/D33797

Files:
  lib/Sema/CoroutineStmtBuilder.h
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/TreeTransform.h
  test/CodeGenCoroutines/coro-params.cpp


Index: test/CodeGenCoroutines/coro-params.cpp
===
--- test/CodeGenCoroutines/coro-params.cpp
+++ test/CodeGenCoroutines/coro-params.cpp
@@ -93,3 +93,26 @@
   // CHECK-NEXT: call void @_ZN8MoveOnlyD1Ev(%struct.MoveOnly* %[[MoCopy]]
   // CHECK-NEXT: call i8* @llvm.coro.free(
 }
+
+// CHECK-LABEL: void @_Z16dependent_paramsI1AEvT_(%struct.A* %x
+template 
+void dependent_params(T x) {
+  // CHECK: %[[x_copy:.+]] = alloca %struct.A
+
+  // CHECK: call i8* @llvm.coro.begin
+  // CHECK-NEXT: call void @_ZN1AC1EOS_(%struct.A* %[[x_copy]], %struct.A* 
dereferenceable(512) %x)
+  // CHECK-NEXT: invoke void 
@_ZNSt12experimental16coroutine_traitsIJv1AEE12promise_typeC1Ev
+
+  co_return;
+}
+
+struct A {
+  int WontFitIntoRegisterForSure[128];
+  A() noexcept;
+  A(A&&) noexcept;
+  ~A();
+};
+
+void call_dependent_params() {
+  dependent_params(A{});
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6959,6 +6959,7 @@
   Builder.ReturnStmt = Res.get();
 }
   }
+  Builder.buildParameterMoves();
 
   return getDerived().RebuildCoroutineBodyStmt(Builder);
 }
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -822,6 +822,12 @@
   return this->IsValid;
 }
 
+bool CoroutineStmtBuilder::buildParameterMoves() {
+  assert(this->IsValid && "coroutine already invalid");
+  assert(this->ParamMoves.empty() && "param moves already built");
+  return this->IsValid = makeParamMoves();
+}
+
 bool CoroutineStmtBuilder::buildDependentStatements() {
   assert(this->IsValid && "coroutine already invalid");
   assert(!this->IsPromiseDependentType &&
Index: lib/Sema/CoroutineStmtBuilder.h
===
--- lib/Sema/CoroutineStmtBuilder.h
+++ lib/Sema/CoroutineStmtBuilder.h
@@ -51,6 +51,9 @@
   /// name lookup.
   bool buildDependentStatements();
 
+  /// \brief Build just parameter moves. To use for rebuilding in 
TreeTransform.
+  bool buildParameterMoves();
+
   bool isInvalid() const { return !this->IsValid; }
 
 private:


Index: test/CodeGenCoroutines/coro-params.cpp
===
--- test/CodeGenCoroutines/coro-params.cpp
+++ test/CodeGenCoroutines/coro-params.cpp
@@ -93,3 +93,26 @@
   // CHECK-NEXT: call void @_ZN8MoveOnlyD1Ev(%struct.MoveOnly* %[[MoCopy]]
   // CHECK-NEXT: call i8* @llvm.coro.free(
 }
+
+// CHECK-LABEL: void @_Z16dependent_paramsI1AEvT_(%struct.A* %x
+template 
+void dependent_params(T x) {
+  // CHECK: %[[x_copy:.+]] = alloca %struct.A
+
+  // CHECK: call i8* @llvm.coro.begin
+  // CHECK-NEXT: call void @_ZN1AC1EOS_(%struct.A* %[[x_copy]], %struct.A* dereferenceable(512) %x)
+  // CHECK-NEXT: invoke void @_ZNSt12experimental16coroutine_traitsIJv1AEE12promise_typeC1Ev
+
+  co_return;
+}
+
+struct A {
+  int WontFitIntoRegisterForSure[128];
+  A() noexcept;
+  A(A&&) noexcept;
+  ~A();
+};
+
+void call_dependent_params() {
+  dependent_params(A{});
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6959,6 +6959,7 @@
   Builder.ReturnStmt = Res.get();
 }
   }
+  Builder.buildParameterMoves();
 
   return getDerived().RebuildCoroutineBodyStmt(Builder);
 }
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -822,6 +822,12 @@
   return this->IsValid;
 }
 
+bool CoroutineStmtBuilder::buildParameterMoves() {
+  assert(this->IsValid && "coroutine already invalid");
+  assert(this->ParamMoves.empty() && "param moves already built");
+  return this->IsValid = makeParamMoves();
+}
+
 bool CoroutineStmtBuilder::buildDependentStatements() {
   assert(this->IsValid && "coroutine already invalid");
   assert(!this->IsPromiseDependentType &&
Index: lib/Sema/CoroutineStmtBuilder.h
===
--- lib/Sema/CoroutineStmtBuilder.h
+++ lib/Sema/CoroutineStmtBuilder.h
@@ -51,6 +51,9 @@
   /// name lookup.
   bool buildDependentStatements();
 
+  /// \brief Build just parameter moves. To use for rebuilding in TreeTransform.
+  bool buildParameterMoves();
+
   bool isInvalid() const { return !this->IsValid; }
 
 private:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D33852: Enable __declspec(selectany) on linux)

2017-06-02 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek created this revision.

This feature was disabled probably by mistake in 
https://reviews.llvm.org/rL300562
This fixes bug https://bugs.llvm.org/show_bug.cgi?id=33285


https://reviews.llvm.org/D33852

Files:
  include/clang/Basic/Attr.td
  test/Sema/attr-selectany.c
  test/SemaCXX/attr-selectany.cpp


Index: test/SemaCXX/attr-selectany.cpp
===
--- test/SemaCXX/attr-selectany.cpp
+++ test/SemaCXX/attr-selectany.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-win32 -fms-compatibility -fms-extensions 
-fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fms-compatibility 
-fms-extensions -fsyntax-only -verify -std=c++11 %s
+
 // MSVC produces similar diagnostics.
 
 __declspec(selectany) void foo() { } // expected-error{{'selectany' can only 
be applied to data items with external linkage}}
Index: test/Sema/attr-selectany.c
===
--- test/Sema/attr-selectany.c
+++ test/Sema/attr-selectany.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-win32 -fdeclspec -verify %s
 // RUN: %clang_cc1 -triple x86_64-mingw32 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -verify -fms-extensions %s
 
 extern __declspec(selectany) const int x1 = 1; // no warning, const means we 
need extern in C++
 
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2413,7 +2413,7 @@
   let Documentation = [DLLImportDocs];
 }
 
-def SelectAny : InheritableAttr, TargetSpecificAttr {
+def SelectAny : InheritableAttr {
   let Spellings = [Declspec<"selectany">, GCC<"selectany">];
   let Documentation = [Undocumented];
 }


Index: test/SemaCXX/attr-selectany.cpp
===
--- test/SemaCXX/attr-selectany.cpp
+++ test/SemaCXX/attr-selectany.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-win32 -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s
+
 // MSVC produces similar diagnostics.
 
 __declspec(selectany) void foo() { } // expected-error{{'selectany' can only be applied to data items with external linkage}}
Index: test/Sema/attr-selectany.c
===
--- test/Sema/attr-selectany.c
+++ test/Sema/attr-selectany.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-win32 -fdeclspec -verify %s
 // RUN: %clang_cc1 -triple x86_64-mingw32 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -verify -fms-extensions %s
 
 extern __declspec(selectany) const int x1 = 1; // no warning, const means we need extern in C++
 
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2413,7 +2413,7 @@
   let Documentation = [DLLImportDocs];
 }
 
-def SelectAny : InheritableAttr, TargetSpecificAttr {
+def SelectAny : InheritableAttr {
   let Spellings = [Declspec<"selectany">, GCC<"selectany">];
   let Documentation = [Undocumented];
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33797: [coroutines] Fix rebuilding of dependent coroutine parameters

2017-06-02 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

@GorNishanov I think we should be transforming the move parameters, instead of 
re-building them entirely. I'll put together a different set of changes.


https://reviews.llvm.org/D33797



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33304: [clang-tidy][Part1] Add a new module Android and three new checks.

2017-06-02 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 101279.
yawanng added a comment.

Format changes.


https://reviews.llvm.org/D33304

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/FileOpenFlagCheck.cpp
  clang-tidy/android/FileOpenFlagCheck.h
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-file-open-flag.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/android-file-open-flag.cpp
  unittests/clang-tidy/CMakeLists.txt

Index: unittests/clang-tidy/CMakeLists.txt
===
--- unittests/clang-tidy/CMakeLists.txt
+++ unittests/clang-tidy/CMakeLists.txt
@@ -25,6 +25,7 @@
   clangFrontend
   clangLex
   clangTidy
+  clangTidyAndroidModule
   clangTidyGoogleModule
   clangTidyLLVMModule
   clangTidyMiscModule
Index: test/clang-tidy/android-file-open-flag.cpp
===
--- /dev/null
+++ test/clang-tidy/android-file-open-flag.cpp
@@ -0,0 +1,104 @@
+// RUN: %check_clang_tidy %s android-file-open-flag %t
+
+#define O_RDWR 1
+#define O_EXCL 2
+#define __O_CLOEXEC 3
+#define O_CLOEXEC __O_CLOEXEC
+
+extern "C" int open(const char *fn, int flags, ...);
+extern "C" int open64(const char *fn, int flags, ...);
+extern "C" int openat(int dirfd, const char *pathname, int flags, ...);
+
+void a() {
+  open("filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: open should use O_CLOEXEC where possible. [android-file-open-flag]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  open("filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: open should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void b() {
+  open64("filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: open64 should use O_CLOEXEC where possible. [android-file-open-flag]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  open64("filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: open64 should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void c() {
+  openat(0, "filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: openat should use O_CLOEXEC where possible. [android-file-open-flag]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  openat(0, "filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: openat should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void f() {
+  open("filename", 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: open should use O_CLOEXEC where possible. [android-file-open-flag]
+  // CHECK-FIXES: 3 | O_CLOEXEC
+  open64("filename", 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: open64 should use O_CLOEXEC where possible. [android-file-open-flag]
+  // CHECK-FIXES: 3 | O_CLOEXEC
+  openat(0, "filename", 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: openat should use O_CLOEXEC where possible. [android-file-open-flag]
+  // CHECK-FIXES: 3 | O_CLOEXEC
+
+  int flag = 3;
+  open("filename", flag);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", flag);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", flag);
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+namespace i {
+int open(const char *pathname, int flags, ...);
+int open64(const char *pathname, int flags, ...);
+int openat(int dirfd, const char *pathname, int flags, ...);
+
+void d() {
+  open("filename", O_RDWR);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_RDWR);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_RDWR);
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+} // namespace i
+
+void e() {
+  open("filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open("filename", O_RDWR | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_RDWR | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_RDWR | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+class G {
+public:
+  int open(const char *pathname, int flags, ...);
+  int open64(const char *pathname, int flags, ...);
+  int openat(int dirfd, const char *pathname, int flags, ...);
+
+  void h() {
+open("filename", O_RDWR);
+// CHECK-MESSAGES-NOT: warning:
+open64("filename", O_RDWR);
+// CHECK-MESSAGES-NOT: warning:
+openat(0, "filename", O_RDWR);
+// CHECK-MESSAGES-NOT: warning:
+  }
+};
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -55,6 +55,7 @@
 == =
 Name prefixDescription
 

[PATCH] D33797: [coroutines] Fix rebuilding of dependent coroutine parameters

2017-06-02 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov added inline comments.



Comment at: test/CodeGenCoroutines/coro-params.cpp:103
+  // CHECK: call i8* @llvm.coro.begin
+  // CHECK-NEXT: call void @_ZN1AC1EOS_(%struct.A* %x1, %struct.A* 
dereferenceable(512) %x)
+  // CHECK-NEXT: call void 
@_ZNSt12experimental16coroutine_traitsIJv1AEE12promise_typeC1Ev

use %[[x_copy]] instead of %x1 here


https://reviews.llvm.org/D33797



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30170: Function definition may have uninstantiated body

2017-06-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/AST/Decl.h:1868-1871
   bool isThisDeclarationADefinition() const {
-return IsDeleted || Body || IsLateTemplateParsed;
+return IsDeleted || IsDefaulted || Body || IsLateTemplateParsed ||
+  hasDefiningAttr();
   }

Can you check in this change and the corresponding changes to 
`test/SemaCXX/cxx0x-cursory-default-delete.cpp` separately?



Comment at: lib/AST/Decl.cpp:2557
+  // have a body until it is used, nevertheless it is a definition. The
+  // following code must produce redeclaration error:
+  //

redeclaration -> redefinition



Comment at: lib/Sema/SemaDecl.cpp:11882
+
+  if (FD == Definition)
+return;

sepavloff wrote:
> rsmith wrote:
> > This looks wrong to me: `CheckForFunctionRedefinition` is intended to be 
> > called *before* marking the function in question as a definition. If you 
> > call it afterwards, then the `isOdrDefined` call won't work properly 
> > because it will always check to see whether `FD` is a definition before 
> > checking any other declaration. So any case that reaches here with `FD` 
> > being a definition seems like a bug. I expect we're only getting here in 
> > that case due to the missing check for friend in 
> > `isThisDeclarationAnOdrDefinition`.
> `CheckForFunctionRedefinition` is called after the declaration is put to 
> redeclaration chain. At this point the declaration does not have a body, so 
> problem may arise only if the provided declaration is an instantiation. It 
> happens when the method is called from `PerformPendingInstantiations` -> 
> `InstantiateFunctionDefinition` -> `ActOnStartOfFunctionDef` -> 
> `CheckForFunctionRedefinition`. In this case function body is generated for 
> declaration that is already in redeclaration chain. If the chain is in valid 
> state, it does not have duplicate definitions and call to 
> `CheckForFunctionRedefinition` is redundant and this check makes shortcut 
> return.
Ultimately, I'd like to be able to remove the special-case handling for friend 
function redefinitions from `TemplateDeclInstantiator::VisitFunctionDecl` and 
simply call `CheckForFunctionRedefinition` from there (we just need to keep the 
part that checks for a prior declaration marked as 'used' and instantiates the 
definition if so). For that to work, this function has to be able to cope with 
the case where `FD` is an instantiated friend and there is another instantiated 
friend in the redeclaration chain. In that case, `FD->isOdrDefined()` is going 
to determine that `FD` itself is the definition and not find the other 
definition (because `D->redecls()` yields `D` first).

I think the best way to make that work would be to skip `FD` when looping over 
redeclarations and checking for an existing definition. At that point, 
`isOdrDefined` is really not a general-purpose mechanism for checking for a 
definition, and should probably simply be inlined into here.



https://reviews.llvm.org/D30170



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r304591 - Mark two coroutine tests as unsupported under ubsan, again

2017-06-02 Thread Gor Nishanov via cfe-commits
Cool. Thanks for checking.

On Fri, Jun 2, 2017 at 1:12 PM, Vedant Kumar  wrote:

> Hm, sorry, the compiler on the bot could not have picked up r304518, so I
> jumped the gun here. I'll try again later and report back in PR33271.
>
> vedant
>
> > On Jun 2, 2017, at 1:09 PM, Vedant Kumar via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> > Hi Gor,
> >
> > This is just a heads-up that I tried re-enabling ubsan for the two tests
> affected by PR33271, but saw some similar failures. The commit message
> below has more details about what was tested and what went wrong.
> >
> > best,
> > vedant
> >
> >
> >> On Jun 2, 2017, at 1:06 PM, Vedant Kumar via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>
> >> Author: vedantk
> >> Date: Fri Jun  2 15:06:49 2017
> >> New Revision: 304591
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=304591=rev
> >> Log:
> >> Mark two coroutine tests as unsupported under ubsan, again
> >>
> >> This reverts commit r304580, making bool_await_suspend.pass.cpp and
> >> generator.pass.cpp unsupported on ubsan again. The host compiler is
> >> based on r304329, which has the change from PR33271 (r304277). However,
> >> this was not enough to address the issue.
> >>
> >> Bot Failure:
> >> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_
> 64-linux-ubuntu-ubsan/builds/628
> >>
> >> Unknown type!
> >> UNREACHABLE executed at /home/eric/full-llvm/llvm/lib/
> IR/ValueTypes.cpp:287!
> >> llvm::EVT::getEVT(llvm::Type*, bool) (/usr/local/bin/clang-5.0+
> 0x17e7a07)
> >> llvm::TargetLoweringBase::getValueType(llvm::DataLayout const&,
> llvm::Type*, bool) const (/usr/local/bin/clang-5.0+0x852c4a)
> >> llvm::ComputeValueVTs(llvm::TargetLowering const&, llvm::DataLayout
> const&, llvm::Type*, llvm::SmallVectorImpl&,
> llvm::SmallVectorImpl*, unsigned long)
> (/usr/local/bin/clang-5.0+0x141b6e9)
> >> llvm::SelectionDAGBuilder::visitTargetIntrinsic(llvm::CallInst const&,
> unsigned int) (/usr/local/bin/clang-5.0+0x237b1ca)
> >>
> >> clang-5.0: 
> >> /home/eric/full-llvm/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1236:
> virtual void llvm::DwarfDebug::endFunctionImpl(const
> llvm::MachineFunction *): Assertion `LScopes.getAbstractScopesList().size()
> == NumAbstractScopes && "ensureAbstractVariableIsCreated inserted
> abstract scopes"' failed.
> >> __assert_fail_base /build/glibc-9tT8Do/glibc-2.23/assert/assert.c:92:0
> >> (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
> >> llvm::DwarfDebug::endFunctionImpl(llvm::MachineFunction const*)
> (/usr/local/bin/clang-5.0+0x223f86b)
> >> llvm::DebugHandlerBase::endFunction(llvm::MachineFunction const*)
> (/usr/local/bin/clang-5.0+0x227a5a1)
> >> llvm::AsmPrinter::EmitFunctionBody() (/usr/local/bin/clang-5.0+
> 0x222522f)
> >>
> >> Modified:
> >>   libcxx/trunk/test/std/experimental/language.support/
> support.coroutines/end.to.end/bool_await_suspend.pass.cpp
> >>   libcxx/trunk/test/std/experimental/language.support/
> support.coroutines/end.to.end/generator.pass.cpp
> >>
> >> Modified: libcxx/trunk/test/std/experimental/language.support/
> support.coroutines/end.to.end/bool_await_suspend.pass.cpp
> >> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/
> experimental/language.support/support.coroutines/end.to.end/
> bool_await_suspend.pass.cpp?rev=304591=304590=304591=diff
> >> 
> ==
> >> --- libcxx/trunk/test/std/experimental/language.support/
> support.coroutines/end.to.end/bool_await_suspend.pass.cpp (original)
> >> +++ libcxx/trunk/test/std/experimental/language.support/
> support.coroutines/end.to.end/bool_await_suspend.pass.cpp Fri Jun  2
> 15:06:49 2017
> >> @@ -10,6 +10,9 @@
> >>
> >> // UNSUPPORTED: c++98, c++03, c++11
> >>
> >> +// See https://bugs.llvm.org/show_bug.cgi?id=33271
> >> +// UNSUPPORTED: ubsan
> >> +
> >> #include 
> >> #include 
> >>
> >>
> >> Modified: libcxx/trunk/test/std/experimental/language.support/
> support.coroutines/end.to.end/generator.pass.cpp
> >> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/
> experimental/language.support/support.coroutines/end.to.end/
> generator.pass.cpp?rev=304591=304590=304591=diff
> >> 
> ==
> >> --- libcxx/trunk/test/std/experimental/language.support/
> support.coroutines/end.to.end/generator.pass.cpp (original)
> >> +++ libcxx/trunk/test/std/experimental/language.support/
> support.coroutines/end.to.end/generator.pass.cpp Fri Jun  2 15:06:49 2017
> >> @@ -10,6 +10,9 @@
> >>
> >> // UNSUPPORTED: c++98, c++03, c++11
> >>
> >> +// See https://bugs.llvm.org/show_bug.cgi?id=33271
> >> +// UNSUPPORTED: ubsan
> >> +
> >> #include 
> >> #include 
> >> #include 
> >>
> >>
> >> ___
> >> cfe-commits mailing list
> >> cfe-commits@lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
> > 

Re: r304376 - PR33232: implement support for MSVC's __is_trivially_destructible trait.

2017-06-02 Thread Eric Fiselier via cfe-commits
I've been using !__is_identifier to test for things like that. It seems to
be the most consistent way.
Is there some problem with this?

/Eric

On Thu, Jun 1, 2017 at 6:46 PM, Richard Smith  wrote:

> On 31 May 2017 at 17:41, Eric Fiselier  wrote:
>
>> I'm assuming libc++ should move to this trait instead?
>>
>
> Yes, that'd be a good idea. Though now that you mention it, I'm not sure
> we have a good feature detection story for these builtins. Looks like a
> bunch of the existing ones are (oddly) covered by __has_feature, and they
> can all be discovered through !__is_identifier, but __has_extension or
> __has_builtin seem like the right detection mechanism and neither of them
> works here. ;-(
>
> Thoughts?
>
>
>> /Eric
>>
>> On Wed, May 31, 2017 at 6:28 PM, Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: rsmith
>>> Date: Wed May 31 19:28:16 2017
>>> New Revision: 304376
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=304376=rev
>>> Log:
>>> PR33232: implement support for MSVC's __is_trivially_destructible trait.
>>>
>>> Unlike the GCC-compatible __has_trivial_destructor trait, this one
>>> computes the
>>> right answer rather than performing the quirky set of checks described
>>> in GCC's
>>> documentation (https://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html).
>>>
>>> MSVC also has a __has_trivial_destructor trait which is the same as its
>>> (and
>>> now Clang's) __is_trivially_destructible trait; we might want to consider
>>> changing the behavior of __has_trivial_destructor if we're targeting an
>>> MSVC
>>> platform, but I'm not doing so for now.
>>>
>>> While implementing this I found that we were incorrectly rejecting
>>> __is_destructible queries on arrays of unknown bound of incomplete
>>> types; that
>>> too is fixed, and I've added similar tests for other traits for good
>>> measure.
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Basic/TokenKinds.def
>>> cfe/trunk/include/clang/Basic/TypeTraits.h
>>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>> cfe/trunk/test/SemaCXX/type-traits.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> Basic/TokenKinds.def?rev=304376=304375=304376=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
>>> +++ cfe/trunk/include/clang/Basic/TokenKinds.def Wed May 31 19:28:16
>>> 2017
>>> @@ -411,6 +411,7 @@ TYPE_TRAIT_1(__is_sealed, IsSealed, KEYM
>>>
>>>  // MSVC12.0 / VS2013 Type Traits
>>>  TYPE_TRAIT_1(__is_destructible, IsDestructible, KEYMS)
>>> +TYPE_TRAIT_1(__is_trivially_destructible, IsTriviallyDestructible,
>>> KEYCXX)
>>>  TYPE_TRAIT_1(__is_nothrow_destructible, IsNothrowDestructible, KEYMS)
>>>  TYPE_TRAIT_2(__is_nothrow_assignable, IsNothrowAssignable, KEYCXX)
>>>  TYPE_TRAIT_N(__is_constructible, IsConstructible, KEYCXX)
>>> @@ -439,7 +440,6 @@ TYPE_TRAIT_2(__is_convertible_to, IsConv
>>>  TYPE_TRAIT_1(__is_empty, IsEmpty, KEYCXX)
>>>  TYPE_TRAIT_1(__is_enum, IsEnum, KEYCXX)
>>>  TYPE_TRAIT_1(__is_final, IsFinal, KEYCXX)
>>> -// Tentative name - there's no implementation of std::is_literal_type
>>> yet.
>>>  TYPE_TRAIT_1(__is_literal, IsLiteral, KEYCXX)
>>>  // Name for GCC 4.6 compatibility - people have already written
>>> libraries using
>>>  // this name unfortunately.
>>>
>>> Modified: cfe/trunk/include/clang/Basic/TypeTraits.h
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> Basic/TypeTraits.h?rev=304376=304375=304376=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Basic/TypeTraits.h (original)
>>> +++ cfe/trunk/include/clang/Basic/TypeTraits.h Wed May 31 19:28:16 2017
>>> @@ -65,6 +65,7 @@ namespace clang {
>>>  UTT_IsStandardLayout,
>>>  UTT_IsTrivial,
>>>  UTT_IsTriviallyCopyable,
>>> +UTT_IsTriviallyDestructible,
>>>  UTT_IsUnion,
>>>  UTT_IsUnsigned,
>>>  UTT_IsVoid,
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaE
>>> xprCXX.cpp?rev=304376=304375=304376=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed May 31 19:28:16 2017
>>> @@ -4080,24 +4080,23 @@ static bool CheckUnaryTypeTraitTypeCompl
>>>Loc, ArgTy, diag::err_incomplete_type_used
>>> _in_type_trait_expr);
>>>  return true;
>>>
>>> -  // C++0x [meta.unary.prop] Table 49 requires the following traits to
>>> be
>>> -  // applied to a complete type.
>>> +  // C++1z [meta.unary.prop]:
>>> +  //   remove_all_extents_t shall be a complete type or cv void.
>>>case UTT_IsAggregate:
>>>case UTT_IsTrivial:
>>>case UTT_IsTriviallyCopyable:
>>>case 

[PATCH] D33304: [clang-tidy][Part1] Add a new module Android and three new checks.

2017-06-02 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 101267.

https://reviews.llvm.org/D33304

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/FileOpenFlagCheck.cpp
  clang-tidy/android/FileOpenFlagCheck.h
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-file-open-flag.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/android-file-open-flag.cpp
  unittests/clang-tidy/CMakeLists.txt

Index: unittests/clang-tidy/CMakeLists.txt
===
--- unittests/clang-tidy/CMakeLists.txt
+++ unittests/clang-tidy/CMakeLists.txt
@@ -25,6 +25,7 @@
   clangFrontend
   clangLex
   clangTidy
+  clangTidyAndroidModule
   clangTidyGoogleModule
   clangTidyLLVMModule
   clangTidyMiscModule
Index: test/clang-tidy/android-file-open-flag.cpp
===
--- /dev/null
+++ test/clang-tidy/android-file-open-flag.cpp
@@ -0,0 +1,104 @@
+// RUN: %check_clang_tidy %s android-file-open-flag %t
+
+#define O_RDWR 1
+#define O_EXCL 2
+#define __O_CLOEXEC 3
+#define O_CLOEXEC __O_CLOEXEC
+
+extern "C" int open(const char *fn, int flags, ...);
+extern "C" int open64(const char *fn, int flags, ...);
+extern "C" int openat(int dirfd, const char *pathname, int flags, ...);
+
+void a() {
+  open("filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: open should use O_CLOEXEC where possible. [android-file-open-flag]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  open("filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: open should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void b() {
+  open64("filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: open64 should use O_CLOEXEC where possible. [android-file-open-flag]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  open64("filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: open64 should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void c() {
+  openat(0, "filename", O_RDWR);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: openat should use O_CLOEXEC where possible. [android-file-open-flag]
+  // CHECK-FIXES: O_RDWR | O_CLOEXEC
+  openat(0, "filename", O_RDWR | O_EXCL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: openat should use O_CLOEXEC where
+  // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC
+}
+
+void f() {
+  open("filename", 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: open should use O_CLOEXEC where possible. [android-file-open-flag]
+  // CHECK-FIXES: 3 | O_CLOEXEC
+  open64("filename", 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: open64 should use O_CLOEXEC where possible. [android-file-open-flag]
+  // CHECK-FIXES: 3 | O_CLOEXEC
+  openat(0, "filename", 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: openat should use O_CLOEXEC where possible. [android-file-open-flag]
+  // CHECK-FIXES: 3 | O_CLOEXEC
+
+  int flag = 3;
+  open("filename", flag);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", flag);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", flag);
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+namespace i {
+int open(const char *pathname, int flags, ...);
+int open64(const char *pathname, int flags, ...);
+int openat(int dirfd, const char *pathname, int flags, ...);
+
+void d() {
+  open("filename", O_RDWR);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_RDWR);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_RDWR);
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+} // namespace i
+
+void e() {
+  open("filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open("filename", O_RDWR | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  open64("filename", O_RDWR | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+  openat(0, "filename", O_RDWR | O_CLOEXEC);
+  // CHECK-MESSAGES-NOT: warning:
+}
+
+class G {
+public:
+  int open(const char *pathname, int flags, ...);
+  int open64(const char *pathname, int flags, ...);
+  int openat(int dirfd, const char *pathname, int flags, ...);
+
+  void h() {
+open("filename", O_RDWR);
+// CHECK-MESSAGES-NOT: warning:
+open64("filename", O_RDWR);
+// CHECK-MESSAGES-NOT: warning:
+openat(0, "filename", O_RDWR);
+// CHECK-MESSAGES-NOT: warning:
+  }
+};
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -55,6 +55,7 @@
 == =
 Name prefixDescription
 == 

r304592 - [ODRHash] Add support for TemplateArgument types.

2017-06-02 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Jun  2 15:35:29 2017
New Revision: 304592

URL: http://llvm.org/viewvc/llvm-project?rev=304592=rev
Log:
[ODRHash] Add support for TemplateArgument types.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=304592=304591=304592=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Jun  2 15:35:29 2017
@@ -128,7 +128,25 @@ void ODRHash::AddTemplateName(TemplateNa
   }
 }
 
-void ODRHash::AddTemplateArgument(TemplateArgument TA) {}
+void ODRHash::AddTemplateArgument(TemplateArgument TA) {
+  auto Kind = TA.getKind();
+  ID.AddInteger(Kind);
+
+  switch (Kind) {
+  case TemplateArgument::Null:
+  case TemplateArgument::Declaration:
+  case TemplateArgument::NullPtr:
+  case TemplateArgument::Integral:
+  case TemplateArgument::Template:
+  case TemplateArgument::TemplateExpansion:
+  case TemplateArgument::Expression:
+  case TemplateArgument::Pack:
+break;
+  case TemplateArgument::Type:
+AddQualType(TA.getAsType());
+break;
+  }
+}
 void ODRHash::AddTemplateParameterList(const TemplateParameterList *TPL) {}
 
 void ODRHash::clear() {

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=304592=304591=304592=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Jun  2 15:35:29 2017
@@ -900,6 +900,24 @@ S2 s2;
 #endif
 }
 
+namespace TemplateArgument {
+#if defined(FIRST)
+template struct U1 {};
+struct S1 {
+  U1 u;
+};
+#elif defined(SECOND)
+template struct U1 {};
+struct S1 {
+  U1 u;
+};
+#else
+S1 s1;
+// expected-error@first.h:* {{'TemplateArgument::S1::u' from module 
'FirstModule' is not present in definition of 'TemplateArgument::S1' in module 
'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'u' does not match}}
+#endif
+}
+
 // Interesting cases that should not cause errors.  struct S should not error
 // while struct T should error at the access specifier mismatch at the end.
 namespace AllDecls {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33732: Catch invalid bitwise operation on vector of floats

2017-06-02 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hi,




Comment at: test/Sema/types.c:92
+
+typedef float __attribute__((ext_vector_type(4)))  float4;
+float4 test3(float4 x) {

Can you also add a test for the `vector_type` variant? It might be more 
appropriate to put this at test/Sema/ext_vector* and test/Sema/vector*


https://reviews.llvm.org/D33732



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D33788: Return a canonical path from getClangResourcePath()

2017-06-02 Thread Richard Smith via cfe-commits
On 2 June 2017 at 12:26, Aaron Ballman  wrote:

> On Fri, Jun 2, 2017 at 3:22 PM, Richard Smith 
> wrote:
> > On 2 June 2017 at 12:04, Richard Smith  wrote:
> >>
> >> On 2 June 2017 at 11:39, Aaron Ballman via Phabricator via cfe-commits
> >>  wrote:
> >>>
> >>> aaron.ballman added a comment.
> >>>
> >>> In https://reviews.llvm.org/D33788#771671, @bruno wrote:
> >>>
> >>> > > I'm unaware of any other API that canonicalizes the path, which is
> >>> > > what users of this API are going to expect.
> >>> >
> >>> > You can also call `sys::path::remove_dots(Path,
> >>> > /*remove_dot_dot=*/true);`
> >>>
> >>>
> >>> Yes, but that does not canonicalize the path. For instance, it won't
> >>> handle doubled-up slashes or symlinks.
> >>
> >>
> >> That's at least partly a feature, not a bug. Resolving symlinks and
> >> removing x/.. are both potentially breaking changes when applied to the
> path
> >> -- if you canonicalize, you break installations where the file is
> actually a
> >> symlink to a file that does *not* also have a resource directory
> relative to
> >> it.
> >>
> >> The path with the bin/../lib in it is presumably the path from the clang
> >> binary, not the path from libclang,
> >
> >
> > I'm not sure about this any more. Looks like clang::Driver::Driver
> applies
> > parent_path to the .../bin directory instead of adding a .. component. So
> > maybe the bin/../lib path comes from how the dynamic loader finds the
> > libclang.so file relative to c-index-test?
>
> What we're finding is that the path we get back from dladdr() in
> getClangResourcesPath() is what contains the "..", so I think you're
> correct.
>
> > In any case, adding canonicalization in just one of the places where we
> > compute the resource path will break this test for anyone who has
> symlinks
> > elsewhere in the path (then the paths will differ because the symlinks
> are
> > resolved in the libclang path but not in the clang binary path). And
> > canonicalization everywhere will break existing clang installations that
> > rely on the symlinks *not* being resolved. I think we need to find
> another
> > option.
>
> I can probably switch to just removing the dots to get the test case
> to stop failing, but as you point out below, this is a bit of a mess.
> :-D


Alternative suggestion: right now, whenever we write a path into an AST
file, we currently check if the path starts with the "base directory" of
the build -- which is the home directory of the module for a module build
and the sysroot for a PCH, and if so we strip off that prefix so that the
AST file can be relocated with the files it describes. Prior to that check,
we could check whether the path starts with the compiler resource directory
path, and if so, strip *that* path off instead (storing a marker with the
path so we know how to reconstruct it). That way, it shouldn't matter what
path we pick to the resource directory (or where the compiler is
installed); we'll get the same AST file regardless.

~Aaron
>
> >
> >> so it's not clear to me that this patch would even help -- the clang
> >> driver also does not canonicalize the path (see SetInstallDir in
> >> tools/driver/driver.cpp).
> >
> >
> > ... but if you run -cc1 directly rather than from the clang driver, we
> > instead make a call that does use getMainExecutable(). What a mess.
> >
> >>> Ultimately, the value returned from this API gets passed to POSIX
> >>> functions which expect a canonical path. I don't think `remove_dots()`
> is
> >>> sufficient. It should do the same thing as `getMainExecutable()`, I
> believe.
> >>
> >>
> >> Note that we don't actually use getMainExecutable for the main clang
> >> driver, just for tooling purposes, and it *also* does not canonicalize.
> >
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] git-clang-format: Add --cached option to format index

2017-06-02 Thread Kevin Locke via cfe-commits
Add --cached option to git-clang-format which behaves analogously to
--cached for other git subcommands, by causing the operation to work
against the index state rather than the working directory state.

This can be particularly useful for hook scripts which need to check or
change the formatting of the index state before commit.

Patch by Kevin Locke.
---
 tools/clang-format/git-clang-format | 70 +
 1 file changed, 48 insertions(+), 22 deletions(-)

diff --git a/tools/clang-format/git-clang-format 
b/tools/clang-format/git-clang-format
index 71b9124149..3f01006dca 100755
--- a/tools/clang-format/git-clang-format
+++ b/tools/clang-format/git-clang-format
@@ -92,6 +92,8 @@ def main():
   p.add_argument('--binary',
  default=config.get('clangformat.binary', 'clang-format'),
  help='path to clang-format'),
+  p.add_argument('--cached', action='store_true',
+ help='format index instead of working directory'),
   p.add_argument('--commit',
  default=config.get('clangformat.commit', 'HEAD'),
  help='default commit to use if none is specified'),
@@ -129,10 +131,12 @@ def main():
   if len(commits) > 1:
 if not opts.diff:
   die('--diff is required when two commits are given')
+if opts.cached:
+  die('--cached is not applicable when two commits are given')
   else:
 if len(commits) > 2:
   die('at most two commits allowed; %d given' % len(commits))
-  changed_lines = compute_diff_and_extract_lines(commits, files)
+  changed_lines = compute_diff_and_extract_lines(commits, files, opts.cached)
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)
   filter_by_extension(changed_lines, opts.extensions.lower().split(','))
@@ -154,15 +158,17 @@ def main():
   cd_to_toplevel()
   if len(commits) > 1:
 old_tree = commits[1]
-new_tree = run_clang_format_and_save_to_tree(changed_lines,
- revision=commits[1],
- binary=opts.binary,
- style=opts.style)
+fmt_tree = commits[1]
+  elif opts.cached:
+old_tree = run('git', 'write-tree')
+fmt_tree = old_tree
   else:
 old_tree = create_tree_from_workdir(changed_lines)
-new_tree = run_clang_format_and_save_to_tree(changed_lines,
- binary=opts.binary,
- style=opts.style)
+fmt_tree = None
+  new_tree = run_clang_format_and_save_to_tree(changed_lines,
+   revision=fmt_tree,
+   binary=opts.binary,
+   style=opts.style)
   if opts.verbose >= 1:
 print('old tree: %s' % old_tree)
 print('new tree: %s' % new_tree)
@@ -173,7 +179,7 @@ def main():
 print_diff(old_tree, new_tree)
   else:
 changed_files = apply_changes(old_tree, new_tree, force=opts.force,
-  patch_mode=opts.patch)
+  patch_mode=opts.patch, cached=opts.cached)
 if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
   print('changed files:')
   for filename in changed_files:
@@ -261,9 +267,9 @@ def get_object_type(value):
   return convert_string(stdout.strip())
 
 
-def compute_diff_and_extract_lines(commits, files):
+def compute_diff_and_extract_lines(commits, files, cached=False):
   """Calls compute_diff() followed by extract_lines()."""
-  diff_process = compute_diff(commits, files)
+  diff_process = compute_diff(commits, files, cached)
   changed_lines = extract_lines(diff_process.stdout)
   diff_process.stdout.close()
   diff_process.wait()
@@ -273,7 +279,7 @@ def compute_diff_and_extract_lines(commits, files):
   return changed_lines
 
 
-def compute_diff(commits, files):
+def compute_diff(commits, files, cached=False):
   """Return a subprocess object producing the diff from `commits`.
 
   The return value's `stdin` file object will produce a patch with the
@@ -283,7 +289,11 @@ def compute_diff(commits, files):
   git_tool = 'diff-index'
   if len(commits) > 1:
 git_tool = 'diff-tree'
-  cmd = ['git', git_tool, '-p', '-U0'] + commits + ['--']
+  cmd = ['git', git_tool, '-p', '-U0']
+  if cached:
+cmd.append('--cached')
+  cmd.extend(commits)
+  cmd.append('--')
   cmd.extend(files)
   p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
   p.stdin.close()
@@ -487,23 +497,39 @@ def print_diff(old_tree, new_tree):
  '--'])
 
 
-def apply_changes(old_tree, new_tree, force=False, patch_mode=False):
-  """Apply the changes in `new_tree` to the working directory.
+def apply_changes(old_tree, new_tree, force=False, patch_mode=False,
+  cached=False):
+  """Apply the changes in `new_tree` to the working directory 

Re: [libcxx] r304591 - Mark two coroutine tests as unsupported under ubsan, again

2017-06-02 Thread Vedant Kumar via cfe-commits
Hm, sorry, the compiler on the bot could not have picked up r304518, so I 
jumped the gun here. I'll try again later and report back in PR33271.

vedant

> On Jun 2, 2017, at 1:09 PM, Vedant Kumar via cfe-commits 
>  wrote:
> 
> Hi Gor,
> 
> This is just a heads-up that I tried re-enabling ubsan for the two tests 
> affected by PR33271, but saw some similar failures. The commit message below 
> has more details about what was tested and what went wrong.
> 
> best,
> vedant
> 
> 
>> On Jun 2, 2017, at 1:06 PM, Vedant Kumar via cfe-commits 
>>  wrote:
>> 
>> Author: vedantk
>> Date: Fri Jun  2 15:06:49 2017
>> New Revision: 304591
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=304591=rev
>> Log:
>> Mark two coroutine tests as unsupported under ubsan, again
>> 
>> This reverts commit r304580, making bool_await_suspend.pass.cpp and
>> generator.pass.cpp unsupported on ubsan again. The host compiler is
>> based on r304329, which has the change from PR33271 (r304277). However,
>> this was not enough to address the issue.
>> 
>> Bot Failure:
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan/builds/628
>> 
>> Unknown type!
>> UNREACHABLE executed at /home/eric/full-llvm/llvm/lib/IR/ValueTypes.cpp:287!
>> llvm::EVT::getEVT(llvm::Type*, bool) (/usr/local/bin/clang-5.0+0x17e7a07)
>> llvm::TargetLoweringBase::getValueType(llvm::DataLayout const&, llvm::Type*, 
>> bool) const (/usr/local/bin/clang-5.0+0x852c4a)
>> llvm::ComputeValueVTs(llvm::TargetLowering const&, llvm::DataLayout const&, 
>> llvm::Type*, llvm::SmallVectorImpl&, 
>> llvm::SmallVectorImpl*, unsigned long) 
>> (/usr/local/bin/clang-5.0+0x141b6e9)
>> llvm::SelectionDAGBuilder::visitTargetIntrinsic(llvm::CallInst const&, 
>> unsigned int) (/usr/local/bin/clang-5.0+0x237b1ca)
>> 
>> clang-5.0: 
>> /home/eric/full-llvm/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1236: 
>> virtual void llvm::DwarfDebug::endFunctionImpl(const llvm::MachineFunction 
>> *): Assertion `LScopes.getAbstractScopesList().size() == NumAbstractScopes 
>> && "ensureAbstractVariableIsCreated inserted abstract scopes"' failed.
>> __assert_fail_base /build/glibc-9tT8Do/glibc-2.23/assert/assert.c:92:0
>> (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
>> llvm::DwarfDebug::endFunctionImpl(llvm::MachineFunction const*) 
>> (/usr/local/bin/clang-5.0+0x223f86b)
>> llvm::DebugHandlerBase::endFunction(llvm::MachineFunction const*) 
>> (/usr/local/bin/clang-5.0+0x227a5a1)
>> llvm::AsmPrinter::EmitFunctionBody() (/usr/local/bin/clang-5.0+0x222522f)
>> 
>> Modified:
>>   
>> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
>>   
>> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
>> 
>> Modified: 
>> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp?rev=304591=304590=304591=diff
>> ==
>> --- 
>> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
>>  (original)
>> +++ 
>> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
>>  Fri Jun  2 15:06:49 2017
>> @@ -10,6 +10,9 @@
>> 
>> // UNSUPPORTED: c++98, c++03, c++11
>> 
>> +// See https://bugs.llvm.org/show_bug.cgi?id=33271
>> +// UNSUPPORTED: ubsan
>> +
>> #include 
>> #include 
>> 
>> 
>> Modified: 
>> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp?rev=304591=304590=304591=diff
>> ==
>> --- 
>> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
>>  (original)
>> +++ 
>> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
>>  Fri Jun  2 15:06:49 2017
>> @@ -10,6 +10,9 @@
>> 
>> // UNSUPPORTED: c++98, c++03, c++11
>> 
>> +// See https://bugs.llvm.org/show_bug.cgi?id=33271
>> +// UNSUPPORTED: ubsan
>> +
>> #include 
>> #include 
>> #include 
>> 
>> 
>> ___
>> 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

___
cfe-commits mailing list
cfe-commits@lists.llvm.org

Re: [libcxx] r304591 - Mark two coroutine tests as unsupported under ubsan, again

2017-06-02 Thread Vedant Kumar via cfe-commits
Hi Gor,

This is just a heads-up that I tried re-enabling ubsan for the two tests 
affected by PR33271, but saw some similar failures. The commit message below 
has more details about what was tested and what went wrong.

best,
vedant


> On Jun 2, 2017, at 1:06 PM, Vedant Kumar via cfe-commits 
>  wrote:
> 
> Author: vedantk
> Date: Fri Jun  2 15:06:49 2017
> New Revision: 304591
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=304591=rev
> Log:
> Mark two coroutine tests as unsupported under ubsan, again
> 
> This reverts commit r304580, making bool_await_suspend.pass.cpp and
> generator.pass.cpp unsupported on ubsan again. The host compiler is
> based on r304329, which has the change from PR33271 (r304277). However,
> this was not enough to address the issue.
> 
> Bot Failure:
> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan/builds/628
> 
> Unknown type!
> UNREACHABLE executed at /home/eric/full-llvm/llvm/lib/IR/ValueTypes.cpp:287!
> llvm::EVT::getEVT(llvm::Type*, bool) (/usr/local/bin/clang-5.0+0x17e7a07)
> llvm::TargetLoweringBase::getValueType(llvm::DataLayout const&, llvm::Type*, 
> bool) const (/usr/local/bin/clang-5.0+0x852c4a)
> llvm::ComputeValueVTs(llvm::TargetLowering const&, llvm::DataLayout const&, 
> llvm::Type*, llvm::SmallVectorImpl&, 
> llvm::SmallVectorImpl*, unsigned long) 
> (/usr/local/bin/clang-5.0+0x141b6e9)
> llvm::SelectionDAGBuilder::visitTargetIntrinsic(llvm::CallInst const&, 
> unsigned int) (/usr/local/bin/clang-5.0+0x237b1ca)
> 
> clang-5.0: 
> /home/eric/full-llvm/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1236: virtual 
> void llvm::DwarfDebug::endFunctionImpl(const llvm::MachineFunction *): 
> Assertion `LScopes.getAbstractScopesList().size() == NumAbstractScopes && 
> "ensureAbstractVariableIsCreated inserted abstract scopes"' failed.
> __assert_fail_base /build/glibc-9tT8Do/glibc-2.23/assert/assert.c:92:0
> (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
> llvm::DwarfDebug::endFunctionImpl(llvm::MachineFunction const*) 
> (/usr/local/bin/clang-5.0+0x223f86b)
> llvm::DebugHandlerBase::endFunction(llvm::MachineFunction const*) 
> (/usr/local/bin/clang-5.0+0x227a5a1)
> llvm::AsmPrinter::EmitFunctionBody() (/usr/local/bin/clang-5.0+0x222522f)
> 
> Modified:
>
> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
>
> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
> 
> Modified: 
> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp?rev=304591=304590=304591=diff
> ==
> --- 
> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
>  (original)
> +++ 
> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
>  Fri Jun  2 15:06:49 2017
> @@ -10,6 +10,9 @@
> 
> // UNSUPPORTED: c++98, c++03, c++11
> 
> +// See https://bugs.llvm.org/show_bug.cgi?id=33271
> +// UNSUPPORTED: ubsan
> +
> #include 
> #include 
> 
> 
> Modified: 
> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp?rev=304591=304590=304591=diff
> ==
> --- 
> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
>  (original)
> +++ 
> libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
>  Fri Jun  2 15:06:49 2017
> @@ -10,6 +10,9 @@
> 
> // UNSUPPORTED: c++98, c++03, c++11
> 
> +// See https://bugs.llvm.org/show_bug.cgi?id=33271
> +// UNSUPPORTED: ubsan
> +
> #include 
> #include 
> #include 
> 
> 
> ___
> 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


[libcxx] r304591 - Mark two coroutine tests as unsupported under ubsan, again

2017-06-02 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Jun  2 15:06:49 2017
New Revision: 304591

URL: http://llvm.org/viewvc/llvm-project?rev=304591=rev
Log:
Mark two coroutine tests as unsupported under ubsan, again

This reverts commit r304580, making bool_await_suspend.pass.cpp and
generator.pass.cpp unsupported on ubsan again. The host compiler is
based on r304329, which has the change from PR33271 (r304277). However,
this was not enough to address the issue.

Bot Failure:
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan/builds/628

Unknown type!
UNREACHABLE executed at /home/eric/full-llvm/llvm/lib/IR/ValueTypes.cpp:287!
llvm::EVT::getEVT(llvm::Type*, bool) (/usr/local/bin/clang-5.0+0x17e7a07)
llvm::TargetLoweringBase::getValueType(llvm::DataLayout const&, llvm::Type*, 
bool) const (/usr/local/bin/clang-5.0+0x852c4a)
llvm::ComputeValueVTs(llvm::TargetLowering const&, llvm::DataLayout const&, 
llvm::Type*, llvm::SmallVectorImpl&, llvm::SmallVectorImpl*, unsigned long) (/usr/local/bin/clang-5.0+0x141b6e9)
 llvm::SelectionDAGBuilder::visitTargetIntrinsic(llvm::CallInst const&, 
unsigned int) (/usr/local/bin/clang-5.0+0x237b1ca)

clang-5.0: 
/home/eric/full-llvm/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1236: virtual 
void llvm::DwarfDebug::endFunctionImpl(const llvm::MachineFunction *): 
Assertion `LScopes.getAbstractScopesList().size() == NumAbstractScopes && 
"ensureAbstractVariableIsCreated inserted abstract scopes"' failed.
__assert_fail_base /build/glibc-9tT8Do/glibc-2.23/assert/assert.c:92:0
(/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
llvm::DwarfDebug::endFunctionImpl(llvm::MachineFunction const*) 
(/usr/local/bin/clang-5.0+0x223f86b)
llvm::DebugHandlerBase::endFunction(llvm::MachineFunction const*) 
(/usr/local/bin/clang-5.0+0x227a5a1)
llvm::AsmPrinter::EmitFunctionBody() (/usr/local/bin/clang-5.0+0x222522f)

Modified:

libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp

libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp?rev=304591=304590=304591=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
 Fri Jun  2 15:06:49 2017
@@ -10,6 +10,9 @@
 
 // UNSUPPORTED: c++98, c++03, c++11
 
+// See https://bugs.llvm.org/show_bug.cgi?id=33271
+// UNSUPPORTED: ubsan
+
 #include 
 #include 
 

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp?rev=304591=304590=304591=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
 Fri Jun  2 15:06:49 2017
@@ -10,6 +10,9 @@
 
 // UNSUPPORTED: c++98, c++03, c++11
 
+// See https://bugs.llvm.org/show_bug.cgi?id=33271
+// UNSUPPORTED: ubsan
+
 #include 
 #include 
 #include 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33827: [clang-tidy] misc-static-assert shouldn't flag assert(!"msg")

2017-06-02 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thank you!


Repository:
  rL LLVM

https://reviews.llvm.org/D33827



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 101262.
ABataev added a comment.
Herald added a subscriber: jholewinski.

Added different kinds of ImplicitParamDecl.


https://reviews.llvm.org/D33735

Files:
  include/clang/AST/Decl.h
  lib/AST/ASTImporter.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclObjC.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGCXXABI.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/captured-statements.c
  test/CodeGenCXX/captured-statements.cpp

Index: test/CodeGenCXX/captured-statements.cpp
===
--- test/CodeGenCXX/captured-statements.cpp
+++ test/CodeGenCXX/captured-statements.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t
+// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3
@@ -194,3 +194,18 @@
 void call_test_captured_linkage() {
   test_captured_linkage();
 }
+
+// CHECK-1-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-1-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-2-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-2-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-3-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-3-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-4-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-4-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-5-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-5-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-6-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-6-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-7-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-7-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
Index: test/CodeGen/captured-statements.c
===
--- test/CodeGen/captured-statements.c
+++ test/CodeGen/captured-statements.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
@@ -98,3 +98,8 @@
 // CHECK-GLOBALS:   load i32, i32* @global
 // CHECK-GLOBALS:   load i32, i32* @
 // CHECK-GLOBALS:   load i32, i32* @e
+
+// CHECK-GLOBALS-NOT: DIFlagObjectPointer
+// CHECK-1-NOT: DIFlagObjectPointer
+// CHECK-2-NOT: DIFlagObjectPointer
+// CHECK-3-NOT: DIFlagObjectPointer
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -967,6 +967,7 @@
 
 void ASTDeclWriter::VisitImplicitParamDecl(ImplicitParamDecl *D) {
   VisitVarDecl(D);
+  Record.push_back(D->getParameterKind());
   Code = serialization::DECL_IMPLICIT_PARAM;
 }
 
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1278,6 +1278,8 @@
 
 void ASTDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) {
   VisitVarDecl(PD);
+  PD->ParamKind =
+  static_cast(Record.readInt());
 }
 
 void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) {
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -3956,8 +3956,9 @@
   DeclContext *DC = CapturedDecl::castToDeclContext(CD);
   IdentifierInfo *ParamName = ("__context");
   QualType ParamType = Context.getPointerType(Context.getTagDeclType(RD));
-  ImplicitParamDecl *Param
-= ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType);
+  ImplicitParamDecl 

Re: [PATCH] D33788: Return a canonical path from getClangResourcePath()

2017-06-02 Thread Aaron Ballman via cfe-commits
On Fri, Jun 2, 2017 at 3:22 PM, Richard Smith  wrote:
> On 2 June 2017 at 12:04, Richard Smith  wrote:
>>
>> On 2 June 2017 at 11:39, Aaron Ballman via Phabricator via cfe-commits
>>  wrote:
>>>
>>> aaron.ballman added a comment.
>>>
>>> In https://reviews.llvm.org/D33788#771671, @bruno wrote:
>>>
>>> > > I'm unaware of any other API that canonicalizes the path, which is
>>> > > what users of this API are going to expect.
>>> >
>>> > You can also call `sys::path::remove_dots(Path,
>>> > /*remove_dot_dot=*/true);`
>>>
>>>
>>> Yes, but that does not canonicalize the path. For instance, it won't
>>> handle doubled-up slashes or symlinks.
>>
>>
>> That's at least partly a feature, not a bug. Resolving symlinks and
>> removing x/.. are both potentially breaking changes when applied to the path
>> -- if you canonicalize, you break installations where the file is actually a
>> symlink to a file that does *not* also have a resource directory relative to
>> it.
>>
>> The path with the bin/../lib in it is presumably the path from the clang
>> binary, not the path from libclang,
>
>
> I'm not sure about this any more. Looks like clang::Driver::Driver applies
> parent_path to the .../bin directory instead of adding a .. component. So
> maybe the bin/../lib path comes from how the dynamic loader finds the
> libclang.so file relative to c-index-test?

What we're finding is that the path we get back from dladdr() in
getClangResourcesPath() is what contains the "..", so I think you're
correct.

> In any case, adding canonicalization in just one of the places where we
> compute the resource path will break this test for anyone who has symlinks
> elsewhere in the path (then the paths will differ because the symlinks are
> resolved in the libclang path but not in the clang binary path). And
> canonicalization everywhere will break existing clang installations that
> rely on the symlinks *not* being resolved. I think we need to find another
> option.

I can probably switch to just removing the dots to get the test case
to stop failing, but as you point out below, this is a bit of a mess.
:-D

~Aaron

>
>> so it's not clear to me that this patch would even help -- the clang
>> driver also does not canonicalize the path (see SetInstallDir in
>> tools/driver/driver.cpp).
>
>
> ... but if you run -cc1 directly rather than from the clang driver, we
> instead make a call that does use getMainExecutable(). What a mess.
>
>>> Ultimately, the value returned from this API gets passed to POSIX
>>> functions which expect a canonical path. I don't think `remove_dots()` is
>>> sufficient. It should do the same thing as `getMainExecutable()`, I believe.
>>
>>
>> Note that we don't actually use getMainExecutable for the main clang
>> driver, just for tooling purposes, and it *also* does not canonicalize.
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D33788: Return a canonical path from getClangResourcePath()

2017-06-02 Thread Aaron Ballman via cfe-commits
On Fri, Jun 2, 2017 at 3:04 PM, Richard Smith  wrote:
> On 2 June 2017 at 11:39, Aaron Ballman via Phabricator via cfe-commits
>  wrote:
>>
>> aaron.ballman added a comment.
>>
>> In https://reviews.llvm.org/D33788#771671, @bruno wrote:
>>
>> > > I'm unaware of any other API that canonicalizes the path, which is
>> > > what users of this API are going to expect.
>> >
>> > You can also call `sys::path::remove_dots(Path,
>> > /*remove_dot_dot=*/true);`
>>
>>
>> Yes, but that does not canonicalize the path. For instance, it won't
>> handle doubled-up slashes or symlinks.
>
>
> That's at least partly a feature, not a bug. Resolving symlinks and removing
> x/.. are both potentially breaking changes when applied to the path -- if
> you canonicalize, you break installations where the file is actually a
> symlink to a file that does *not* also have a resource directory relative to
> it.

Breaking changes would be bad, but I'm not particularly sympathetic to
that use case compared to expecting callers to canonicalize the
results before passing off to POSIX APIs (as we do). Effectively, by
pushing this off to callers, we create a more fragile system that's
harder to reason about. You could argue that while this does break
such an installation, the installation is rather defective for
expecting the symlink to not resolve.

> The path with the bin/../lib in it is presumably the path from the clang
> binary, not the path from libclang, so it's not clear to me that this patch
> would even help -- the clang driver also does not canonicalize the path (see
> SetInstallDir in tools/driver/driver.cpp).

To be clear: this change fixed the test case breakage we were seeing.
So I do believe it helps. ;-)

>> Ultimately, the value returned from this API gets passed to POSIX
>> functions which expect a canonical path. I don't think `remove_dots()` is
>> sufficient. It should do the same thing as `getMainExecutable()`, I believe.
>
>
> Note that we don't actually use getMainExecutable for the main clang driver,
> just for tooling purposes, and it *also* does not canonicalize.

Maybe I'm confused, but in main() (ToolChain.cpp), I see a call to
GetExecutablePath(), and it canonicalizes prefixes unless passing
-no-canonical-prefixes. When canonicalizing, it calls
getMainExecutable(), which calls real_path() in at least two cases
(one of which is for __APPLE__ targets).

~Aaron
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30170: Function definition may have uninstantiated body

2017-06-02 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 101260.
sepavloff added a comment.

Do not call getCanonicalDecl for deleted functions


https://reviews.llvm.org/D30170

Files:
  include/clang/AST/Decl.h
  lib/AST/Decl.cpp
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/cxx0x-cursory-default-delete.cpp
  test/SemaCXX/friend2.cpp

Index: test/SemaCXX/friend2.cpp
===
--- test/SemaCXX/friend2.cpp
+++ test/SemaCXX/friend2.cpp
@@ -101,6 +101,34 @@
   friend void func_12(int x = 0);  // expected-error{{friend declaration specifying a default argument must be the only declaration}}
 };
 
+// Friend function with uninstantiated body is still a definition.
+
+template struct C20 {
+  friend void func_20() {} // expected-note{{previous definition is here}}
+};
+C20 c20i;
+void func_20() {} // expected-error{{redefinition of 'func_20'}}
+
+template struct C21a {
+  friend void func_21() {} // expected-note{{previous definition is here}}
+};
+template struct C21b {
+  friend void func_21() {} // expected-error{{redefinition of 'func_21'}}
+};
+C21a c21ai;
+C21b c21bi; // expected-note{{in instantiation of template class 'C21b' requested here}}
+
+template struct C22a {
+  friend void func_22() {} // expected-note{{previous definition is here}}
+};
+template struct C22b {
+  friend void func_22();
+};
+C22a c22ai;
+C22b c22bi;
+void func_22() {} // expected-error{{redefinition of 'func_22'}}
+
+
 
 namespace pr22307 {
 
Index: test/SemaCXX/cxx0x-cursory-default-delete.cpp
===
--- test/SemaCXX/cxx0x-cursory-default-delete.cpp
+++ test/SemaCXX/cxx0x-cursory-default-delete.cpp
@@ -136,13 +136,13 @@
 };
 
 struct DefaultDelete {
-  DefaultDelete() = default; // expected-note {{previous declaration is here}}
+  DefaultDelete() = default; // expected-note {{previous definition is here}}
   DefaultDelete() = delete; // expected-error {{constructor cannot be redeclared}}
 
-  ~DefaultDelete() = default; // expected-note {{previous declaration is here}}
+  ~DefaultDelete() = default; // expected-note {{previous definition is here}}
   ~DefaultDelete() = delete; // expected-error {{destructor cannot be redeclared}}
 
-  DefaultDelete =(const DefaultDelete &) = default; // expected-note {{previous declaration is here}}
+  DefaultDelete =(const DefaultDelete &) = default; // expected-note {{previous definition is here}}
   DefaultDelete =(const DefaultDelete &) = delete; // expected-error {{class member cannot be redeclared}}
 };
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -11875,8 +11875,12 @@
SkipBodyInfo *SkipBody) {
   const FunctionDecl *Definition = EffectiveDefinition;
   if (!Definition)
-if (!FD->isDefined(Definition))
+if (!FD->isOdrDefined(Definition))
   return;
+  assert(Definition);
+
+  if (FD == Definition)
+return;
 
   if (canRedefineFunction(Definition, getLangOpts()))
 return;
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -2534,16 +2534,45 @@
 
 bool FunctionDecl::isDefined(const FunctionDecl *) const {
   for (auto I : redecls()) {
-if (I->IsDeleted || I->IsDefaulted || I->Body || I->IsLateTemplateParsed ||
-I->hasDefiningAttr()) {
-  Definition = I->IsDeleted ? I->getCanonicalDecl() : I;
+if (I->isThisDeclarationADefinition()) {
+  Definition = I;
   return true;
 }
   }
 
   return false;
 }
 
+bool FunctionDecl::isOdrDefined(const FunctionDecl *) const {
+  // First try to find a declaration that has existing definition.
+  if (isDefined(Definition))
+return true;
+
+  // If no existing definition exist, look for a definition which can be
+  // instantiated.
+  for (auto I : redecls()) {
+if (I->getFriendObjectKind() != Decl::FOK_None) {
+  // If this is a friend function defined in a class template, it does not
+  // have a body until it is used, nevertheless it is a definition. The
+  // following code must produce redeclaration error:
+  //
+  // template struct C20 { friend void func_20() {} };
+  // C20 c20i;
+  // void func_20() {}
+  //
+  if (FunctionDecl *Original = I->getInstantiatedFromMemberFunction()) {
+const FunctionDecl *D;
+if (Original->isOdrDefined(D)) {
+  Definition = I;
+  return true;
+}
+  }
+}
+  }
+
+  return false;
+}
+
 Stmt *FunctionDecl::getBody(const FunctionDecl *) const {
   if (!hasBody(Definition))
 return nullptr;
Index: include/clang/AST/Decl.h
===
--- include/clang/AST/Decl.h
+++ include/clang/AST/Decl.h
@@ -1778,11 +1778,26 @@
 
   SourceRange getSourceRange() const override LLVM_READONLY;
 
-  /// \brief 

Re: [PATCH] D33788: Return a canonical path from getClangResourcePath()

2017-06-02 Thread Richard Smith via cfe-commits
On 2 June 2017 at 12:04, Richard Smith  wrote:

> On 2 June 2017 at 11:39, Aaron Ballman via Phabricator via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> aaron.ballman added a comment.
>>
>> In https://reviews.llvm.org/D33788#771671, @bruno wrote:
>>
>> > > I'm unaware of any other API that canonicalizes the path, which is
>> what users of this API are going to expect.
>> >
>> > You can also call `sys::path::remove_dots(Path,
>> /*remove_dot_dot=*/true);`
>>
>>
>> Yes, but that does not canonicalize the path. For instance, it won't
>> handle doubled-up slashes or symlinks.
>>
>
> That's at least partly a feature, not a bug. Resolving symlinks and
> removing x/.. are both potentially breaking changes when applied to the
> path -- if you canonicalize, you break installations where the file is
> actually a symlink to a file that does *not* also have a resource directory
> relative to it.
>
> The path with the bin/../lib in it is presumably the path from the clang
> binary, not the path from libclang,
>

I'm not sure about this any more. Looks like clang::Driver::Driver applies
parent_path to the .../bin directory instead of adding a .. component. So
maybe the bin/../lib path comes from how the dynamic loader finds the
libclang.so file relative to c-index-test?

In any case, adding canonicalization in just one of the places where we
compute the resource path will break this test for anyone who has symlinks
elsewhere in the path (then the paths will differ because the symlinks are
resolved in the libclang path but not in the clang binary path). And
canonicalization everywhere will break existing clang installations that
rely on the symlinks *not* being resolved. I think we need to find another
option.

so it's not clear to me that this patch would even help -- the clang driver
> also does not canonicalize the path (see SetInstallDir in
> tools/driver/driver.cpp).
>

... but if you run -cc1 directly rather than from the clang driver, we
instead make a call that does use getMainExecutable(). What a mess.

Ultimately, the value returned from this API gets passed to POSIX functions
>> which expect a canonical path. I don't think `remove_dots()` is sufficient.
>> It should do the same thing as `getMainExecutable()`, I believe.
>
>
> Note that we don't actually use getMainExecutable for the main clang
> driver, just for tooling purposes, and it *also* does not canonicalize.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D33788: Return a canonical path from getClangResourcePath()

2017-06-02 Thread Richard Smith via cfe-commits
On 2 June 2017 at 11:39, Aaron Ballman via Phabricator via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> aaron.ballman added a comment.
>
> In https://reviews.llvm.org/D33788#771671, @bruno wrote:
>
> > > I'm unaware of any other API that canonicalizes the path, which is
> what users of this API are going to expect.
> >
> > You can also call `sys::path::remove_dots(Path,
> /*remove_dot_dot=*/true);`
>
>
> Yes, but that does not canonicalize the path. For instance, it won't
> handle doubled-up slashes or symlinks.
>

That's at least partly a feature, not a bug. Resolving symlinks and
removing x/.. are both potentially breaking changes when applied to the
path -- if you canonicalize, you break installations where the file is
actually a symlink to a file that does *not* also have a resource directory
relative to it.

The path with the bin/../lib in it is presumably the path from the clang
binary, not the path from libclang, so it's not clear to me that this patch
would even help -- the clang driver also does not canonicalize the path
(see SetInstallDir in tools/driver/driver.cpp).

Ultimately, the value returned from this API gets passed to POSIX functions
> which expect a canonical path. I don't think `remove_dots()` is sufficient.
> It should do the same thing as `getMainExecutable()`, I believe.


Note that we don't actually use getMainExecutable for the main clang
driver, just for tooling purposes, and it *also* does not canonicalize.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33788: Return a canonical path from getClangResourcePath()

2017-06-02 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.



> Yes, but that does not canonicalize the path. For instance, it won't handle 
> doubled-up slashes or symlinks.

Right.

> Ultimately, the value returned from this API gets passed to POSIX functions 
> which expect a canonical path. I don't think `remove_dots()` is sufficient. 
> It should do the same thing as `getMainExecutable()`, I believe.

I see, LGTM then


https://reviews.llvm.org/D33788



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r304583 - [clang-tidy] Add `const` to operator() to fix a warning.

2017-06-02 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Jun  2 13:47:50 2017
New Revision: 304583

URL: http://llvm.org/viewvc/llvm-project?rev=304583=rev
Log:
[clang-tidy] Add `const` to operator() to fix a warning.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h

Modified: clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h?rev=304583=304582=304583=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h Fri Jun  
2 13:47:50 2017
@@ -25,7 +25,7 @@ namespace misc {
 class LambdaFunctionNameCheck : public ClangTidyCheck {
 public:
   struct SourceRangeLessThan {
-bool operator()(const SourceRange , const SourceRange ) {
+bool operator()(const SourceRange , const SourceRange ) const {
   if (L.getBegin() == R.getBegin()) {
 return L.getEnd() < R.getEnd();
   }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r304581 - Fix formatting in docs.

2017-06-02 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Jun  2 13:44:32 2017
New Revision: 304581

URL: http://llvm.org/viewvc/llvm-project?rev=304581=rev
Log:
Fix formatting in docs.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=304581=304580=304581=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Fri Jun  2 13:44:32 2017
@@ -71,16 +71,15 @@ Improvements to clang-tidy
   
`_
 check
 
   Allow custom memory management functions to be considered as well.
-  
+
 - New `misc-forwarding-reference-overload
   
`_
 check
 
   Finds perfect forwarding constructors that can unintentionally hide copy or 
move constructors.
 
-- New `misc-lambda-function-name
-   
`_
 check
+- New `misc-lambda-function-name 
`_
 check
 
-   Finds uses of ``__func__`` or ``__FUNCTION__`` inside lambdas.
+  Finds uses of ``__func__`` or ``__FUNCTION__`` inside lambdas.
 
 - New `modernize-replace-random-shuffle
   
`_
 check
@@ -92,7 +91,7 @@ Improvements to clang-tidy
 
   Finds and replaces explicit calls to the constructor in a return statement by
   a braced initializer list so that the return type is not needlessly repeated.
-  
+
 - Improved `modernize-use-emplace
   `_ 
check
 
@@ -106,7 +105,7 @@ Improvements to clang-tidy
 
   Finds possible inefficient vector operations in for loops that may cause
   unnecessary memory reallocations.
-  
+
 - Added `ParameterThreshold` to `readability-function-size
   
`_
 check
 
@@ -116,10 +115,10 @@ Improvements to clang-tidy
   
`_
 check
 
   Finds misleading indentation where braces should be introduced or the code 
should be reformatted.
-  
+
 - Support clang-formatting of the code around applied fixes (``-format-style``
   command-line option).
-  
+
 - New `hicpp` module
 
   Adds checks that implement the `High Integrity C++ Coding Standard 
`_ and other safety


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33788: Return a canonical path from getClangResourcePath()

2017-06-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D33788#771671, @bruno wrote:

> > I'm unaware of any other API that canonicalizes the path, which is what 
> > users of this API are going to expect.
>
> You can also call `sys::path::remove_dots(Path, /*remove_dot_dot=*/true);`


Yes, but that does not canonicalize the path. For instance, it won't handle 
doubled-up slashes or symlinks.

Ultimately, the value returned from this API gets passed to POSIX functions 
which expect a canonical path. I don't think `remove_dots()` is sufficient. It 
should do the same thing as `getMainExecutable()`, I believe.

> 
> 
>> There's already a test case that covers this: Index/pch-from-libclang.c -- 
>> it was failing on OS X 10.6 for us. If you have a better test case in mind, 
>> I can certainly add it.
> 
> Works for me.




https://reviews.llvm.org/D33788



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r304580 - Revert "Mark two coroutine tests as unsupported under ubsan"

2017-06-02 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Jun  2 13:30:16 2017
New Revision: 304580

URL: http://llvm.org/viewvc/llvm-project?rev=304580=rev
Log:
Revert "Mark two coroutine tests as unsupported under ubsan"

This reverts commit r304462, thereby re-enabling two tests under ubsan.
We expect these tests to pass now that PR33271 is fixed.

Modified:

libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp

libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp?rev=304580=304579=304580=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
 Fri Jun  2 13:30:16 2017
@@ -10,9 +10,6 @@
 
 // UNSUPPORTED: c++98, c++03, c++11
 
-// See https://bugs.llvm.org/show_bug.cgi?id=33271
-// UNSUPPORTED: ubsan
-
 #include 
 #include 
 

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp?rev=304580=304579=304580=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
 Fri Jun  2 13:30:16 2017
@@ -10,9 +10,6 @@
 
 // UNSUPPORTED: c++98, c++03, c++11
 
-// See https://bugs.llvm.org/show_bug.cgi?id=33271
-// UNSUPPORTED: ubsan
-
 #include 
 #include 
 #include 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33788: Return a canonical path from getClangResourcePath()

2017-06-02 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.



> I'm unaware of any other API that canonicalizes the path, which is what users 
> of this API are going to expect.

You can also call `sys::path::remove_dots(Path, /*remove_dot_dot=*/true);`

> There's already a test case that covers this: Index/pch-from-libclang.c -- it 
> was failing on OS X 10.6 for us. If you have a better test case in mind, I 
> can certainly add it.

Works for me.


https://reviews.llvm.org/D33788



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33842: [AMDGPU] Fix address space of global variable

2017-06-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGExpr.cpp:360
+  CGF.getContext().getTargetAddressSpace(LangAS::opencl_constant);
+}
 auto *GV = new llvm::GlobalVariable(

This is not an appropriate place to stick target-specific code.  You should add 
a target hook that returns the address space into which to allocate constant 
temporaries, with the requirement that the target must not return an address 
space which cannot be lifted into LangAS::Default.  For some configurations 
this may not be possible (e.g. OpenCL C++?), so the hook should return an 
Optional so that a None return will disable the optimization.

And you should go ahead and lift the pointer here if necessary.

You may have to make createReferenceTemporary return whether it 
constant-emitted the temporary initializer.


https://reviews.llvm.org/D33842



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33827: [clang-tidy] misc-static-assert shouldn't flag assert(!"msg")

2017-06-02 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

While not directly related to this Differential, i wonder if it would make 
sense to also not warn on calls to (especially non-member) functions marked 
with `__attribute__((const))`, maybe `__attribute__((pure))` too.
At least i'm not sure what side-effects such calls may have..


Repository:
  rL LLVM

https://reviews.llvm.org/D33827



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33821: [OpenCL] Harden function pointer diagnostics.

2017-06-02 Thread Alexey Bader via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304575: [OpenCL] Harden function pointer diagnostics. 
(authored by bader).

Changed prior to commit:
  https://reviews.llvm.org/D33821?vs=101181=101242#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33821

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/SemaOpenCL/func.cl


Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -1881,6 +1881,11 @@
 return QualType();
   }
 
+  if (T->isFunctionType() && getLangOpts().OpenCL) {
+Diag(Loc, diag::err_opencl_function_pointer);
+return QualType();
+  }
+
   if (checkQualifiedFunction(*this, T, Loc, QFK_Pointer))
 return QualType();
 
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -6160,7 +6160,7 @@
 QualType NR = R;
 while (NR->isPointerType()) {
   if (NR->isFunctionPointerType()) {
-Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer_variable);
+Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer);
 D.setInvalidType();
 break;
   }
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7268,7 +7268,7 @@
   "invalid conversion between vector type %0 and integer type %1 "
   "of different size">;
 
-def err_opencl_function_pointer_variable : Error<
+def err_opencl_function_pointer : Error<
   "pointers to functions are not allowed">;
 
 def err_opencl_taking_function_address : Error<
Index: cfe/trunk/test/SemaOpenCL/func.cl
===
--- cfe/trunk/test/SemaOpenCL/func.cl
+++ cfe/trunk/test/SemaOpenCL/func.cl
@@ -4,8 +4,15 @@
 void vararg_f(int, ...);// expected-error {{invalid 
prototype, variadic arguments are not allowed in OpenCL}}
 void __vararg_f(int, ...);
 typedef void (*vararg_fptr_t)(int, ...);// expected-error {{invalid 
prototype, variadic arguments are not allowed in OpenCL}}
+// expected-error@-1{{pointers to 
functions are not allowed}}
 int printf(__constant const char *st, ...); // expected-error {{invalid 
prototype, variadic arguments are not allowed in OpenCL}}
 
+// Struct type with function pointer field
+typedef struct s
+{
+   void (*f)(struct s *self, int *i);   // expected-error{{pointers to 
functions are not allowed}}
+} s_t;
+
 //Function pointer
 void foo(void*);
 


Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -1881,6 +1881,11 @@
 return QualType();
   }
 
+  if (T->isFunctionType() && getLangOpts().OpenCL) {
+Diag(Loc, diag::err_opencl_function_pointer);
+return QualType();
+  }
+
   if (checkQualifiedFunction(*this, T, Loc, QFK_Pointer))
 return QualType();
 
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -6160,7 +6160,7 @@
 QualType NR = R;
 while (NR->isPointerType()) {
   if (NR->isFunctionPointerType()) {
-Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer_variable);
+Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer);
 D.setInvalidType();
 break;
   }
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7268,7 +7268,7 @@
   "invalid conversion between vector type %0 and integer type %1 "
   "of different size">;
 
-def err_opencl_function_pointer_variable : Error<
+def err_opencl_function_pointer : Error<
   "pointers to functions are not allowed">;
 
 def err_opencl_taking_function_address : Error<
Index: cfe/trunk/test/SemaOpenCL/func.cl
===
--- cfe/trunk/test/SemaOpenCL/func.cl
+++ cfe/trunk/test/SemaOpenCL/func.cl
@@ -4,8 +4,15 @@
 void vararg_f(int, ...);// expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}}
 void __vararg_f(int, ...);
 typedef void (*vararg_fptr_t)(int, ...);// expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}}
+// 

r304575 - [OpenCL] Harden function pointer diagnostics.

2017-06-02 Thread Alexey Bader via cfe-commits
Author: bader
Date: Fri Jun  2 13:08:58 2017
New Revision: 304575

URL: http://llvm.org/viewvc/llvm-project?rev=304575=rev
Log:
[OpenCL] Harden function pointer diagnostics.

Summary: Improve OpenCL type checking by rejecting function pointer types.

Reviewers: Anastasia, yaxunl

Reviewed By: Anastasia

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D33821


Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaOpenCL/func.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=304575=304574=304575=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jun  2 13:08:58 
2017
@@ -7268,7 +7268,7 @@ def err_invalid_conversion_between_vecto
   "invalid conversion between vector type %0 and integer type %1 "
   "of different size">;
 
-def err_opencl_function_pointer_variable : Error<
+def err_opencl_function_pointer : Error<
   "pointers to functions are not allowed">;
 
 def err_opencl_taking_function_address : Error<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=304575=304574=304575=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Jun  2 13:08:58 2017
@@ -6160,7 +6160,7 @@ NamedDecl *Sema::ActOnVariableDeclarator
 QualType NR = R;
 while (NR->isPointerType()) {
   if (NR->isFunctionPointerType()) {
-Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer_variable);
+Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer);
 D.setInvalidType();
 break;
   }

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=304575=304574=304575=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Jun  2 13:08:58 2017
@@ -1881,6 +1881,11 @@ QualType Sema::BuildPointerType(QualType
 return QualType();
   }
 
+  if (T->isFunctionType() && getLangOpts().OpenCL) {
+Diag(Loc, diag::err_opencl_function_pointer);
+return QualType();
+  }
+
   if (checkQualifiedFunction(*this, T, Loc, QFK_Pointer))
 return QualType();
 

Modified: cfe/trunk/test/SemaOpenCL/func.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/func.cl?rev=304575=304574=304575=diff
==
--- cfe/trunk/test/SemaOpenCL/func.cl (original)
+++ cfe/trunk/test/SemaOpenCL/func.cl Fri Jun  2 13:08:58 2017
@@ -4,8 +4,15 @@
 void vararg_f(int, ...);// expected-error {{invalid 
prototype, variadic arguments are not allowed in OpenCL}}
 void __vararg_f(int, ...);
 typedef void (*vararg_fptr_t)(int, ...);// expected-error {{invalid 
prototype, variadic arguments are not allowed in OpenCL}}
+// expected-error@-1{{pointers to 
functions are not allowed}}
 int printf(__constant const char *st, ...); // expected-error {{invalid 
prototype, variadic arguments are not allowed in OpenCL}}
 
+// Struct type with function pointer field
+typedef struct s
+{
+   void (*f)(struct s *self, int *i);   // expected-error{{pointers to 
functions are not allowed}}
+} s_t;
+
 //Function pointer
 void foo(void*);
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33597: [OpenCL] Fix pipe size in TypeInfo.

2017-06-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


https://reviews.llvm.org/D33597



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33821: [OpenCL] Harden function pointer diagnostics.

2017-06-02 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D33821



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33497: [clang-tidy] check for __func__/__FUNCTION__ in lambdas

2017-06-02 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304570: [clang-tidy] check for __func__/__FUNCTION__ in 
lambdas (authored by alexfh).

Changed prior to commit:
  https://reviews.llvm.org/D33497?vs=101224=101237#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33497

Files:
  clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h
  clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-lambda-function-name.rst
  clang-tools-extra/trunk/test/clang-tidy/misc-lambda-function-name.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/misc-lambda-function-name.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-lambda-function-name.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-lambda-function-name.cpp
@@ -0,0 +1,41 @@
+// RUN: %check_clang_tidy %s misc-lambda-function-name %t
+
+void Foo(const char* a, const char* b, int c) {}
+
+#define FUNC_MACRO Foo(__func__, "", 0)
+#define FUNCTION_MACRO Foo(__FUNCTION__, "", 0)
+#define EMBED_IN_ANOTHER_MACRO1 FUNC_MACRO
+
+void Positives() {
+  [] { __func__; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { __FUNCTION__; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { FUNC_MACRO; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { FUNCTION_MACRO; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { EMBED_IN_ANOTHER_MACRO1; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+}
+
+#define FUNC_MACRO_WITH_FILE_AND_LINE Foo(__func__, __FILE__, __LINE__)
+#define FUNCTION_MACRO_WITH_FILE_AND_LINE Foo(__FUNCTION__, __FILE__, __LINE__)
+#define EMBED_IN_ANOTHER_MACRO2 FUNC_MACRO_WITH_FILE_AND_LINE
+
+void Negatives() {
+  __func__;
+  __FUNCTION__;
+
+  // __PRETTY_FUNCTION__ should not trigger a warning because its value is
+  // actually potentially useful.
+  __PRETTY_FUNCTION__;
+  [] { __PRETTY_FUNCTION__; }();
+
+  // Don't warn if __func__/__FUNCTION is used inside a macro that also uses
+  // __FILE__ and __LINE__, on the assumption that __FILE__ and __LINE__ will
+  // be useful even if __func__/__FUNCTION__ is not.
+  [] { FUNC_MACRO_WITH_FILE_AND_LINE; }();
+  [] { FUNCTION_MACRO_WITH_FILE_AND_LINE; }();
+  [] { EMBED_IN_ANOTHER_MACRO2; }();
+}
Index: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
@@ -4,6 +4,7 @@
   ArgumentCommentCheck.cpp
   AssertSideEffectCheck.cpp
   ForwardingReferenceOverloadCheck.cpp
+  LambdaFunctionNameCheck.cpp
   MisplacedConstCheck.cpp
   UnconventionalAssignOperatorCheck.cpp
   BoolPointerImplicitConversionCheck.cpp
Index: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
@@ -21,6 +21,7 @@
 #include "InaccurateEraseCheck.h"
 #include "IncorrectRoundings.h"
 #include "InefficientAlgorithmCheck.h"
+#include "LambdaFunctionNameCheck.h"
 #include "MacroParenthesesCheck.h"
 #include "MacroRepeatedSideEffectsCheck.h"
 #include "MisplacedConstCheck.h"
@@ -68,6 +69,8 @@
 "misc-assert-side-effect");
 CheckFactories.registerCheck(
 "misc-forwarding-reference-overload");
+CheckFactories.registerCheck(
+"misc-lambda-function-name");
 CheckFactories.registerCheck("misc-misplaced-const");
 CheckFactories.registerCheck(
 "misc-unconventional-assign-operator");
Index: clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.cpp
===
--- 

[clang-tools-extra] r304570 - [clang-tidy] check for __func__/__FUNCTION__ in lambdas

2017-06-02 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Jun  2 12:36:32 2017
New Revision: 304570

URL: http://llvm.org/viewvc/llvm-project?rev=304570=rev
Log:
[clang-tidy] check for __func__/__FUNCTION__ in lambdas

Add a clang-tidy check for using func__/FUNCTION__ inside lambdas. This
evaluates to the string operator(), which is almost never useful and almost
certainly not what the author intended.

Patch by Bryce Liu!

Differential Revision: https://reviews.llvm.org/D33497

Added:
clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-lambda-function-name.rst
clang-tools-extra/trunk/test/clang-tidy/misc-lambda-function-name.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=304570=304569=304570=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Fri Jun  2 12:36:32 
2017
@@ -4,6 +4,7 @@ add_clang_library(clangTidyMiscModule
   ArgumentCommentCheck.cpp
   AssertSideEffectCheck.cpp
   ForwardingReferenceOverloadCheck.cpp
+  LambdaFunctionNameCheck.cpp
   MisplacedConstCheck.cpp
   UnconventionalAssignOperatorCheck.cpp
   BoolPointerImplicitConversionCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.cpp?rev=304570=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.cpp Fri Jun 
 2 12:36:32 2017
@@ -0,0 +1,99 @@
+//===--- LambdaFunctionNameCheck.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "LambdaFunctionNameCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/MacroInfo.h"
+#include "clang/Lex/Preprocessor.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+namespace {
+
+// Keep track of macro expansions that contain both __FILE__ and __LINE__. If
+// such a macro also uses __func__ or __FUNCTION__, we don't want to issue a
+// warning because __FILE__ and __LINE__ may be useful even if __func__ or
+// __FUNCTION__ is not, especially if the macro could be used in the context of
+// either a function body or a lambda body.
+class MacroExpansionsWithFileAndLine : public PPCallbacks {
+public:
+  explicit MacroExpansionsWithFileAndLine(
+  LambdaFunctionNameCheck::SourceRangeSet *SME)
+  : SuppressMacroExpansions(SME) {}
+
+  void MacroExpands(const Token ,
+const MacroDefinition , SourceRange Range,
+const MacroArgs *Args) override {
+bool has_file = false;
+bool has_line = false;
+for (const auto& T : MD.getMacroInfo()->tokens()) {
+  if (T.is(tok::identifier)) {
+StringRef IdentName = T.getIdentifierInfo()->getName();
+if (IdentName == "__FILE__") {
+  has_file = true;
+} else if (IdentName == "__LINE__") {
+  has_line = true;
+}
+  }
+}
+if (has_file && has_line) {
+  SuppressMacroExpansions->insert(Range);
+}
+  }
+
+private:
+  LambdaFunctionNameCheck::SourceRangeSet* SuppressMacroExpansions;
+};
+
+} // namespace
+
+void LambdaFunctionNameCheck::registerMatchers(MatchFinder *Finder) {
+  // Match on PredefinedExprs inside a lambda.
+  Finder->addMatcher(predefinedExpr(hasAncestor(lambdaExpr())).bind("E"),
+ this);
+}
+
+void LambdaFunctionNameCheck::registerPPCallbacks(CompilerInstance ) {
+  Compiler.getPreprocessor().addPPCallbacks(
+  llvm::make_unique(
+  ));
+}
+
+void LambdaFunctionNameCheck::check(const MatchFinder::MatchResult ) {
+  const auto *E = Result.Nodes.getNodeAs("E");
+  if (E->getIdentType() != PredefinedExpr::Func &&
+  E->getIdentType() != PredefinedExpr::Function) {
+// We don't care about other PredefinedExprs.
+return;
+  }
+  if (E->getLocation().isMacroID()) {
+auto ER =
+

[PATCH] D33842: [AMDGPU] Fix address space of global variable

2017-06-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
Herald added subscribers: t-tye, tpr, dstuttard, wdng, kzhuravl.

amdgcn target requires global variable to stay in global or constant address 
space.
In C or C++ global variables are emitted in the default (generic) address space
which the amdgcn backend cannot handle.

This patch emits global variables in global or constant address space and cast
them to generic address space, in a similar approach as CUDA.

It also fixes pointer size and metadata issue so that standard initializer list 
is
supported.

This patch was originally part of https://reviews.llvm.org/D33706.


https://reviews.llvm.org/D33842

Files:
  lib/Basic/Targets.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/address-space.c
  test/CodeGen/default-address-space.c
  test/CodeGenCXX/amdgcn-automatic-variable.cpp
  test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp

Index: test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
===
--- test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
+++ test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-none-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN1: %clang_cc1 -std=c++11 -triple x86_64-none-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefixes=X86,CHECK %s
+// RUN: %clang_cc1 -std=c++11 -triple amdgcn-amd-amdhsa-amdgiz -DNO_TLS -emit-llvm -o - %s | FileCheck -check-prefixes=AMD,CHECK %s
 
 namespace std {
   typedef decltype(sizeof(int)) size_t;
@@ -46,62 +47,82 @@
   wantslist1(std::initializer_list);
   ~wantslist1();
 };
-
-// CHECK: @_ZGR15globalInitList1_ = internal constant [3 x i32] [i32 1, i32 2, i32 3]
-// CHECK: @globalInitList1 = global %{{[^ ]+}} { i32* getelementptr inbounds ([3 x i32], [3 x i32]* @_ZGR15globalInitList1_, i32 0, i32 0), i{{32|64}} 3 }
+// X86: @_ZGR15globalInitList1_ = internal constant [3 x i32] [i32 1, i32 2, i32 3]
+// X86: @globalInitList1 = global %{{[^ ]+}} { i32* getelementptr inbounds ([3 x i32], [3 x i32]* @_ZGR15globalInitList1_, i32 0, i32 0), i{{32|64}} 3 }
+// AMD: @_ZGR15globalInitList1_ = internal addrspace(1) constant [3 x i32] [i32 1, i32 2, i32 3]
+// AMD: @globalInitList1 = addrspace(1) global %{{[^ ]+}} { i32* addrspacecast (i32 addrspace(1)* getelementptr inbounds ([3 x i32], [3 x i32] addrspace(1)* @_ZGR15globalInitList1_, i32 0, i32 0) to i32*), i{{32|64}} 3 }
 std::initializer_list globalInitList1 = {1, 2, 3};
 
+#ifndef NO_TLS
 namespace thread_local_global_array {
   // FIXME: We should be able to constant-evaluate this even though the
   // initializer is not a constant expression (pointers to thread_local
   // objects aren't really a problem).
   //
-  // CHECK: @_ZN25thread_local_global_array1xE = thread_local global
-  // CHECK: @_ZGRN25thread_local_global_array1xE_ = internal thread_local constant [4 x i32] [i32 1, i32 2, i32 3, i32 4]
+  // X86: @_ZN25thread_local_global_array1xE = thread_local global
+  // X86: @_ZGRN25thread_local_global_array1xE_ = internal thread_local constant [4 x i32] [i32 1, i32 2, i32 3, i32 4]
   std::initializer_list thread_local x = { 1, 2, 3, 4 };
 }
-
-// CHECK: @globalInitList2 = global %{{[^ ]+}} zeroinitializer
-// CHECK: @_ZGR15globalInitList2_ = internal global [2 x %[[WITHARG:[^ ]*]]] zeroinitializer
-
-// CHECK: @_ZN15partly_constant1kE = global i32 0, align 4
-// CHECK: @_ZN15partly_constant2ilE = global {{.*}} null, align 8
-// CHECK: @[[PARTLY_CONSTANT_OUTER:_ZGRN15partly_constant2ilE.*]] = internal global {{.*}} zeroinitializer, align 8
-// CHECK: @[[PARTLY_CONSTANT_INNER:_ZGRN15partly_constant2ilE.*]] = internal global [3 x {{.*}}] zeroinitializer, align 8
-// CHECK: @[[PARTLY_CONSTANT_FIRST:_ZGRN15partly_constant2ilE.*]] = internal constant [3 x i32] [i32 1, i32 2, i32 3], align 4
-// CHECK: @[[PARTLY_CONSTANT_SECOND:_ZGRN15partly_constant2ilE.*]] = internal global [2 x i32] zeroinitializer, align 4
-// CHECK: @[[PARTLY_CONSTANT_THIRD:_ZGRN15partly_constant2ilE.*]] = internal constant [4 x i32] [i32 5, i32 6, i32 7, i32 8], align 4
-
-// CHECK: @[[REFTMP1:.*]] = private constant [2 x i32] [i32 42, i32 43], align 4
-// CHECK: @[[REFTMP2:.*]] = private constant [3 x %{{.*}}] [%{{.*}} { i32 1 }, %{{.*}} { i32 2 }, %{{.*}} { i32 3 }], align 4
+#endif
+
+// X86: @globalInitList2 = global %{{[^ ]+}} zeroinitializer
+// X86: @_ZGR15globalInitList2_ = internal global [2 x %[[WITHARG:[^ ]*]]] zeroinitializer
+// AMD: @globalInitList2 = addrspace(1) global %{{[^ ]+}} zeroinitializer
+// AMD: @_ZGR15globalInitList2_ = internal addrspace(1) global [2 x %[[WITHARG:[^ ]*]]] zeroinitializer
+
+// X86: @_ZN15partly_constant1kE = global i32 0, align 4
+// X86: @_ZN15partly_constant2ilE = global {{.*}} null, align 8
+// X86: @[[PARTLY_CONSTANT_OUTER:_ZGRN15partly_constant2ilE.*]] = internal global {{.*}} zeroinitializer, align 8
+// X86: 

[PATCH] D33597: [OpenCL] Fix pipe size in TypeInfo.

2017-06-02 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 101236.
Anastasia added a comment.

Added RUN line for AMD


https://reviews.llvm.org/D33597

Files:
  lib/AST/ASTContext.cpp
  test/Index/pipe-size.cl


Index: test/Index/pipe-size.cl
===
--- /dev/null
+++ test/Index/pipe-size.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
spir-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
spir64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR64
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
amdgcn-amd-amdhsa-amdgizcl %s -o - | FileCheck %s --check-prefix=AMD
+__kernel void testPipe( pipe int test )
+{
+int s = sizeof(test);
+// X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8
+// X86: store i32 8, i32* %s, align 4
+// SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t 
addrspace(1)** %test.addr, align 4
+// SPIR: store i32 4, i32* %s, align 4
+// SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t 
addrspace(1)** %test.addr, align 8
+// SPIR64: store i32 8, i32* %s, align 4
+// AMD: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t 
addrspace(1)* addrspace(5)* %test.addr, align 4
+// AMD: store i32 8, i32 addrspace(5)* %s, align 4
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1939,9 +1939,8 @@
   break;
 
   case Type::Pipe: {
-TypeInfo Info = getTypeInfo(cast(T)->getElementType());
-Width = Info.Width;
-Align = Info.Align;
+Width = 
Target->getPointerWidth(getTargetAddressSpace(LangAS::opencl_global));
+Align = 
Target->getPointerAlign(getTargetAddressSpace(LangAS::opencl_global));
   }
 
   }


Index: test/Index/pipe-size.cl
===
--- /dev/null
+++ test/Index/pipe-size.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR64
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple amdgcn-amd-amdhsa-amdgizcl %s -o - | FileCheck %s --check-prefix=AMD
+__kernel void testPipe( pipe int test )
+{
+int s = sizeof(test);
+// X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8
+// X86: store i32 8, i32* %s, align 4
+// SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 4
+// SPIR: store i32 4, i32* %s, align 4
+// SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 8
+// SPIR64: store i32 8, i32* %s, align 4
+// AMD: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)* addrspace(5)* %test.addr, align 4
+// AMD: store i32 8, i32 addrspace(5)* %s, align 4
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1939,9 +1939,8 @@
   break;
 
   case Type::Pipe: {
-TypeInfo Info = getTypeInfo(cast(T)->getElementType());
-Width = Info.Width;
-Align = Info.Align;
+Width = Target->getPointerWidth(getTargetAddressSpace(LangAS::opencl_global));
+Align = Target->getPointerAlign(getTargetAddressSpace(LangAS::opencl_global));
   }
 
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r304515 - Support lazy stat'ing of files referenced by module maps.

2017-06-02 Thread Benjamin Kramer via cfe-commits
I committed a workaround in r304568.

On Fri, Jun 2, 2017 at 6:59 PM, Alexander Kornienko via cfe-commits
 wrote:
> I've not yet figured out exactly, but I have a suspicion that this commit
> causes crashes when run under asan. Specifically, when running
> test/Modules/preprocess-module.cpp
>
> The stack trace is:
> #0 0x1d644c6 in (anonymous
> namespace)::HeaderFileInfoTrait::EmitData(llvm::raw_ostream&, (anonymous
> namespace)::HeaderFileInfoTrait::key_type const&, (anonymous
> namespace)::HeaderFileInfoTrait::data_type const&, unsigned int)
> llvm/tools/clang/lib/Serialization/ASTWriter.cpp:1926:39
> #1 0x1d322f3 in llvm::OnDiskChainedHashTableGenerator<(anonymous
> namespace)::HeaderFileInfoTrait>::Emit(llvm::raw_ostream&, (anonymous
> namespace)::HeaderFileInfoTrait&)
> llvm/include/llvm/Support/OnDiskHashTable.h:198:17
> #2 0x1d3168d in clang::ASTWriter::WriteHeaderSearch(clang::HeaderSearch
> const&) llvm/tools/clang/lib/Serialization/ASTWriter.cpp:2092:30
> #3 0x1d52f4c in clang::ASTWriter::WriteASTCore(clang::Sema&,
> llvm::StringRef, std::string const&, clang::Module*)
> llvm/tools/clang/lib/Serialization/ASTWriter.cpp:4857:3
> #4 0x1d4f7db in clang::ASTWriter::WriteAST(clang::Sema&, std::string
> const&, clang::Module*, llvm::StringRef, bool)
> llvm/tools/clang/lib/Serialization/ASTWriter.cpp:4475:7
> #5 0x1cd0333 in
> clang::PCHGenerator::HandleTranslationUnit(clang::ASTContext&)
> llvm/tools/clang/lib/Serialization/GeneratePCH.cpp:62:14
> #6 0x1f56cc7 in
> clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&)
> llvm/tools/clang/lib/Frontend/MultiplexConsumer.cpp:305:15
> #7 0x24ebc9c in clang::ParseAST(clang::Sema&, bool, bool)
> llvm/tools/clang/lib/Parse/ParseAST.cpp:159:13
> #8 0x1f4b283 in clang::FrontendAction::Execute()
> llvm/tools/clang/lib/Frontend/FrontendAction.cpp:856:8
> #9 0x1caf916 in
> clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
> llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:970:11
> #10 0x5ed12c in
> clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
> llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:249:25
>
> Could you take a look?
>
>
> On Fri, Jun 2, 2017 at 3:55 AM, Richard Smith via cfe-commits
>  wrote:
>>
>> Author: rsmith
>> Date: Thu Jun  1 20:55:39 2017
>> New Revision: 304515
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=304515=rev
>> Log:
>> Support lazy stat'ing of files referenced by module maps.
>>
>> This patch adds support for a `header` declaration in a module map to
>> specify
>> certain `stat` information (currently, size and mtime) about that header
>> file.
>> This has two purposes:
>>
>> - It removes the need to eagerly `stat` every file referenced by a module
>> map.
>>   Instead, we track a list of unresolved header files with each size /
>> mtime
>>   (actually, for simplicity, we track submodules with such headers), and
>> when
>>   attempting to look up a header file based on a `FileEntry`, we check if
>> there
>>   are any unresolved header directives with that `FileEntry`'s size /
>> mtime and
>>   perform deferred `stat`s if so.
>>
>> - It permits a preprocessed module to be compiled without the original
>> files
>>   being present on disk. The only reason we used to need those files was
>> to get
>>   the `stat` information in order to do header -> module lookups when
>> using the
>>   module. If we're provided with the `stat` information in the
>> preprocessed
>>   module, we can avoid requiring the files to exist.
>>
>> Unlike most `header` directives, if a `header` directive with `stat`
>> information has no corresponding on-disk file the enclosing module is
>> *not*
>> marked unavailable (so that behavior is consistent regardless of whether
>> we've
>> resolved a header directive, and so that preprocessed modules don't get
>> marked
>> unavailable). We could actually do this for all `header` directives: the
>> only
>> reason we mark the module unavailable if headers are missing is to give a
>> diagnostic slightly earlier (rather than waiting until we actually try to
>> build
>> the module / load and validate its .pcm file).
>>
>> Differential Revision: https://reviews.llvm.org/D33703
>>
>> Added:
>> cfe/trunk/test/Modules/Inputs/header-attribs/
>> cfe/trunk/test/Modules/Inputs/header-attribs/bar.h
>> cfe/trunk/test/Modules/Inputs/header-attribs/baz.h
>> cfe/trunk/test/Modules/Inputs/header-attribs/foo.h
>> cfe/trunk/test/Modules/Inputs/header-attribs/modular.modulemap
>> cfe/trunk/test/Modules/Inputs/header-attribs/textual.modulemap
>> cfe/trunk/test/Modules/header-attribs.cpp
>> cfe/trunk/test/Modules/preprocess-missing.modulemap
>> Modified:
>> cfe/trunk/docs/Modules.rst
>> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
>> 

r304568 - [Modules] Fix use after scope.

2017-06-02 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Jun  2 12:30:24 2017
New Revision: 304568

URL: http://llvm.org/viewvc/llvm-project?rev=304568=rev
Log:
[Modules] Fix use after scope.

Found by asan.

Modified:
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=304568=304567=304568=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri Jun  2 12:30:24 2017
@@ -1989,6 +1989,7 @@ void ASTWriter::WriteHeaderSearch(const
   // have resolved them before we get here, but not necessarily: we might be
   // compiling a preprocessed module, where there is no requirement for the
   // original files to exist any more.
+  const HeaderFileInfo Empty; // So we can take a reference.
   if (WritingModule) {
 llvm::SmallVector Worklist(1, WritingModule);
 while (!Worklist.empty()) {
@@ -2027,7 +2028,7 @@ void ASTWriter::WriteHeaderSearch(const
   FilenameDup, *U.Size, IncludeTimestamps ? *U.ModTime : 0
 };
 HeaderFileInfoTrait::data_type Data = {
-  {}, {}, {M, ModuleMap::headerKindToRole(U.Kind)}
+  Empty, {}, {M, ModuleMap::headerKindToRole(U.Kind)}
 };
 // FIXME: Deal with cases where there are multiple unresolved header
 // directives in different submodules for the same header.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33825: [clang-tidy] signal handler must be plain old function check

2017-06-02 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/cert/CERTTidyModule.cpp:64
+"cert-msc54-cpp");
 // C checkers
 // DCL

checker -> check.



Comment at: docs/ReleaseNotes.rst:73
+
+  Checks if a signal handler is not a plain old function.
+

Probably C++ should be mentioned for clarity.



Comment at: docs/clang-tidy/checks/cert-msc54-cpp.rst:7
+This check will give a warning if a signal handler is not defined
+as an 'extern C' function or if the declaration of the function
+contains C++ representation.

'extern C' -> ``extern "C"``.



Comment at: docs/clang-tidy/checks/cert-msc54-cpp.rst:21
+}
+
+

Unnecessary empty line.



Comment at: docs/clang-tidy/checks/cert-msc54-cpp.rst:32
+}
+
+

Unnecessary empty line.



Comment at: docs/clang-tidy/checks/cert-msc54-cpp.rst:34
+
+This check corresponds to the CERT CPP Coding Standard rule
+`MSC54-CPP. A signal handler must be a plain old function

Please replace CPP with C++ as in similar checks documentation.


Repository:
  rL LLVM

https://reviews.llvm.org/D33825



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33788: Return a canonical path from getClangResourcePath()

2017-06-02 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a comment.

I retract my comment, I see that `getMainExecutable` on OSX calls realpath as 
well, so it's good to use realpath in this code to make sure they are in-sync 
with how the compiler will determine the path.


https://reviews.llvm.org/D33788



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33497: [clang-tidy] check for __func__/__FUNCTION__ in lambdas

2017-06-02 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good!


https://reviews.llvm.org/D33497



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33102: [clang] Implement -Wcast-qual for C++

2017-06-02 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D33102#767291, @dblaikie wrote:

> Still seems like an awful lot more testing than I'd  expect for this warning. 
> (eg: testing all the many variations of C++ const_cast - when they all 
> provide basically the same coverage I think, that all const_casts don't warn)


Ok, i removed a bit more of const_cast checks, but unless you insist, i'd think 
all the rest of the test are needed :)
I do understand that it is ideal to keep the checks as small as possible for 
speed reasons.


Repository:
  rL LLVM

https://reviews.llvm.org/D33102



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33102: [clang] Implement -Wcast-qual for C++

2017-06-02 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 101232.
lebedev.ri marked an inline comment as done.
lebedev.ri added a subscriber: cfe-commits.
lebedev.ri added a comment.

Address review notes.


Repository:
  rL LLVM

https://reviews.llvm.org/D33102

Files:
  docs/ReleaseNotes.rst
  lib/Sema/SemaCast.cpp
  test/Sema/warn-cast-qual.c
  test/SemaCXX/warn-cast-qual.cpp

Index: test/SemaCXX/warn-cast-qual.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-cast-qual.cpp
@@ -0,0 +1,134 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -Wcast-qual -verify %s
+
+#include 
+
+// do *NOT* warn on const_cast<>()
+// use clang-tidy's cppcoreguidelines-pro-type-const-cast for that.
+void foo_ptr() {
+  const char *const ptr = 0;
+  char *t0 = const_cast(ptr); // no warning
+
+  volatile char *ptr2 = 0;
+  char *t1 = const_cast(ptr2); // no warning
+
+  const volatile char *ptr3 = 0;
+  char *t2 = const_cast(ptr3); // no warning
+}
+
+void foo_0() {
+  const int a = 0;
+
+  const int  = a;  // no warning
+  const int  = (const int &)a; // no warning
+
+  int  = (int &)a;  // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}}
+  const int  = (int &)a;// expected-warning {{cast from 'const int' to 'int &' drops const qualifier}}
+  int  = (int &)((const int &)a);   // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}}
+  int  = (int &)((int &)a); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}}
+  const int  = (int &)((int &)a);   // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}}
+  const int  = (int &)((const int &)a); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}}
+  const int  = (const int &)((int &)a); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}}
+}
+
+void foo_1() {
+  volatile int a = 0;
+
+  volatile int  = a; // no warning
+  volatile int  = (volatile int &)a; // no warning
+
+  int  = (int &)a;// expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}}
+  volatile int  = (int &)a;   // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}}
+  int  = (int &)((volatile int &)a);  // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}}
+  int  = (int &)((int &)a);   // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}}
+  volatile int  = (int &)((int &)a);  // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}}
+  volatile int  = (int &)((volatile int &)a); // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}}
+  volatile int  = (volatile int &)((int &)a); // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}}
+}
+
+void foo_2() {
+  const volatile int a = 0;
+
+  const volatile int  = a;   // no warning
+  const volatile int  = (const volatile int &)a; // no warning
+
+  int  = (int &)a;// expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}}
+  const volatile int  = (int &)a; // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}}
+  int  = (int &)((const volatile int &)a);// expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}}
+  int  = (int &)((int &)a);   // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}}
+  const volatile int  = (int &)((int &)a);// expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}}
+  const volatile int  = (int &)((const volatile int &)a); // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}}
+  const volatile int  = (const volatile int &)((int &)a); // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}}
+}
+
+void bar_0() {
+  const int *_a = 0;
+  const int **a = &_a;
+
+  int **a0 = (int **)((const int **)a); // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}}
+  int **a1 = (int **)((int **)a);   // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}}
+
+  // const int **a2 = (int **)((int **)a);
+  // const int **a3 = (int **)((const int **)a);
+
+  const int **a4 = (const int **)((int **)a);// expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} expected-warning {{cast from 'int **' to 'const int **' must have all intermediate 

[PATCH] D33788: Return a canonical path from getClangResourcePath()

2017-06-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D33788#771504, @akyrtzi wrote:

> Getting the real path is notoriously slow (at least it's horrible in OSX, not 
> sure about linux). Since this is about dropping the '/../' part, could we do 
> some simple canonicalization of removing the dots ? Not sure if there is an 
> existing function that does that.


Given the fact that this path is cached, so you only need to do the slow path 
one time, are you sure that's a practical concern? I'm unaware of any other API 
that canonicalizes the path, which is what users of this API are going to 
expect.


https://reviews.llvm.org/D33788



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible

2017-06-02 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler added inline comments.



Comment at: tools/libclang/CIndex.cpp:7322
+
+  for (int I = 0, E = AvailabilityAttrs.size(); I < E && I < availability_size;
+   ++I) {

arphaman wrote:
> You can use a ranged for loop here if you use `take_front`, e.g.
> 
> ```
> for (const auto *Avail : AvailabilityAttrs.take_front(availability_size))
> ```
I would need to covert this to an `ArrayRef`, I believe. Also, I would need to 
check `availability_size` is in bounds. Would something like the following be 
preferred:
```
int N = 0;
for (const auto *Avail : AvailabilityAttrs) {
  if (N < availability_size) {
// populate availability
N++;
  }
}
```


https://reviews.llvm.org/D33478



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33788: Return a canonical path from getClangResourcePath()

2017-06-02 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a comment.

Getting the real path is notoriously slow (at least it's horrible in OSX, not 
sure about linux). Since this is about dropping the '/../' part, could we do 
some simple canonicalization of removing the dots ? Not sure if there is an 
existing function that does that.


https://reviews.llvm.org/D33788



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33706: CodeGen: Cast temporary variable to proper address space

2017-06-02 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks!


https://reviews.llvm.org/D33706



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/AST/Decl.h:1388
SourceLocation IdLoc, IdentifierInfo *Id,
-   QualType T);
+   QualType T, bool IsThisOrSelf = false);
 

Is there a good reason not to have a little enum here and require the caller to 
pass it down?  There's only 20 different call sites, it shouldn't be hard to 
quickly classify them.

I think we should at least have:
  ObjCSelf
  ObjCCmd
  CXXThis
  CXXVTT
and then if you want to categorize everything else as Other, that's fine.



Comment at: lib/CodeGen/CGDebugInfo.cpp:3466
+  // If this is the first argument, it is implicit and has ThisOrSelf attribute
+  // then give it an object pointer flag.
+  if (ArgNo && *ArgNo == 1)

I don't think you need the ArgNo conditions anymore.


https://reviews.llvm.org/D33735



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33304: [clang-tidy][Part1] Add a new module Android and three new checks.

2017-06-02 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D33304#771215, @hokein wrote:

> Thanks for the contributions.
>
> All your three checks are not android specific -- because they are checking 
> POSIX APIs (`open`, `creat`, `fopen`), which are more likely related to 
> POSIX. So personally, I'm +1 on a "posix" module, instead of "android", but 
> wait to see other reviewers' opinions before renaming it.


IIUC, these checks enforce a certain - Android-specific - way of using POSIX 
APIs. I'm not sure if the recommendations are universally useful. Or am I 
mistaken?


https://reviews.llvm.org/D33304



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33706: CodeGen: Cast temporary variable to proper address space

2017-06-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 101227.
yaxunl added a comment.

Fix a comment.


https://reviews.llvm.org/D33706

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/address-space.c
  test/CodeGen/default-address-space.c
  test/CodeGenCXX/amdgcn-automatic-variable.cpp

Index: test/CodeGenCXX/amdgcn-automatic-variable.cpp
===
--- test/CodeGenCXX/amdgcn-automatic-variable.cpp
+++ test/CodeGenCXX/amdgcn-automatic-variable.cpp
@@ -3,9 +3,10 @@
 // CHECK-LABEL: define void @_Z5func1Pi(i32* %x)
 void func1(int *x) {
   // CHECK: %[[x_addr:.*]] = alloca i32*{{.*}}addrspace(5)
-  // CHECK: store i32* %x, i32* addrspace(5)* %[[x_addr]]
-  // CHECK: %[[r0:.*]] = load i32*, i32* addrspace(5)* %[[x_addr]]
-  // CHECK: store i32 1, i32* %[[r0]]
+  // CHECK: %[[r0:.*]] = addrspacecast i32* addrspace(5)* %[[x_addr]] to i32**
+  // CHECK: store i32* %x, i32** %[[r0]]
+  // CHECK: %[[r1:.*]] = load i32*, i32** %[[r0]]
+  // CHECK: store i32 1, i32* %[[r1]]
   *x = 1;
 }
 
@@ -70,3 +71,12 @@
   // CHECK: call void @_ZN1AD1Ev(%class.A* %[[r0]])
   A a;
 }
+
+// CHECK-LABEL: define void @_Z5func4i
+void func4(int x) {
+  // CHECK: %[[x_addr:.*]] = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %[[x_addr]] to i32*
+  // CHECK: store i32 %x, i32* %[[r0]], align 4
+  // CHECK: call void @_Z5func1Pi(i32* %[[r0]])
+  func1();
+}
Index: test/CodeGen/default-address-space.c
===
--- test/CodeGen/default-address-space.c
+++ test/CodeGen/default-address-space.c
@@ -22,9 +22,10 @@
 int test1() { return foo; }
 
 // COM-LABEL: define i32 @test2(i32 %i)
-// PIZ: load i32, i32 addrspace(4)*
+// COM: %[[addr:.*]] = getelementptr
+// PIZ: load i32, i32 addrspace(4)* %[[addr]]
 // PIZ-NEXT: ret i32
-// CHECK: load i32, i32*
+// CHECK: load i32, i32* %[[addr]]
 // CHECK-NEXT: ret i32
 int test2(int i) { return ban[i]; }
 
@@ -42,15 +43,17 @@
 }
 
 // PIZ-LABEL: define void @test4(i32 addrspace(4)* %a)
-// PIZ: %[[a_addr:.*]] = alloca i32 addrspace(4)*
-// PIZ: store i32 addrspace(4)* %a, i32 addrspace(4)** %[[a_addr]]
-// PIZ: %[[r0:.*]] = load i32 addrspace(4)*, i32 addrspace(4)** %[[a_addr]]
+// PIZ: %[[alloca:.*]] = alloca i32 addrspace(4)*
+// PIZ: %[[a_addr:.*]] = addrspacecast{{.*}} %[[alloca]] to i32 addrspace(4)* addrspace(4)*
+// PIZ: store i32 addrspace(4)* %a, i32 addrspace(4)* addrspace(4)* %[[a_addr]]
+// PIZ: %[[r0:.*]] = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* %[[a_addr]]
 // PIZ: %[[arrayidx:.*]] = getelementptr inbounds i32, i32 addrspace(4)* %[[r0]]
 // PIZ: store i32 0, i32 addrspace(4)* %[[arrayidx]]
 // CHECK-LABEL: define void @test4(i32* %a)
-// CHECK: %[[a_addr:.*]] = alloca i32*, align 4, addrspace(5)
-// CHECK: store i32* %a, i32* addrspace(5)* %[[a_addr]]
-// CHECK: %[[r0:.*]] = load i32*, i32* addrspace(5)* %[[a_addr]]
+// CHECK: %[[alloca:.*]] = alloca i32*, align 4, addrspace(5)
+// CHECK: %[[a_addr:.*]] = addrspacecast{{.*}} %[[alloca]] to i32**
+// CHECK: store i32* %a, i32** %[[a_addr]]
+// CHECK: %[[r0:.*]] = load i32*, i32** %[[a_addr]]
 // CHECK: %[[arrayidx:.*]] = getelementptr inbounds i32, i32* %[[r0]]
 // CHECK: store i32 0, i32* %[[arrayidx]]
 void test4(int *a) {
Index: test/CodeGen/address-space.c
===
--- test/CodeGen/address-space.c
+++ test/CodeGen/address-space.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck -check-prefixes=CHECK,GIZ %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck -check-prefixes=CHECK,X86,GIZ %s
 // RUN: %clang_cc1 -triple amdgcn -emit-llvm < %s | FileCheck -check-prefixes=CHECK,PIZ %s
-// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK,GIZ %s
+// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK,AMDGIZ,GIZ %s
 
 // CHECK: @foo = common addrspace(1) global
 int foo __attribute__((address_space(1)));
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1915,13 +1915,36 @@
 LValueBaseInfo *BaseInfo = nullptr);
   LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy);
 
-  /// CreateTempAlloca - This creates a alloca and inserts it into the entry
-  /// block. The caller is responsible for setting an appropriate alignment on
+  /// CreateTempAlloca - This creates an alloca and inserts it into the entry
+  /// block if \p ArraySize is nullptr, otherwise inserts it at the current
+  /// insertion point of the builder. The caller is responsible for setting an
+  /// appropriate alignment on
   /// the alloca.
-  llvm::AllocaInst 

[PATCH] D33706: CodeGen: Cast temporary variable to proper address space

2017-06-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Thanks.  One tweak and then LGTM.




Comment at: lib/CodeGen/CodeGenFunction.h:1937
+  /// to the stack.
+
+  /// Because the address of a temporary is often exposed to the program in

This line should have ///.


https://reviews.llvm.org/D33706



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33497: [clang-tidy] check for __func__/__FUNCTION__ in lambdas

2017-06-02 Thread Bryce Liu via Phabricator via cfe-commits
brycel updated this revision to Diff 101224.
brycel added a comment.

Move namespace-level types to class-level to avoid potential future name 
conflicts.


https://reviews.llvm.org/D33497

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/LambdaFunctionNameCheck.cpp
  clang-tidy/misc/LambdaFunctionNameCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-lambda-function-name.rst
  test/clang-tidy/misc-lambda-function-name.cpp

Index: test/clang-tidy/misc-lambda-function-name.cpp
===
--- test/clang-tidy/misc-lambda-function-name.cpp
+++ test/clang-tidy/misc-lambda-function-name.cpp
@@ -0,0 +1,41 @@
+// RUN: %check_clang_tidy %s misc-lambda-function-name %t
+
+void Foo(const char* a, const char* b, int c) {}
+
+#define FUNC_MACRO Foo(__func__, "", 0)
+#define FUNCTION_MACRO Foo(__FUNCTION__, "", 0)
+#define EMBED_IN_ANOTHER_MACRO1 FUNC_MACRO
+
+void Positives() {
+  [] { __func__; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { __FUNCTION__; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { FUNC_MACRO; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { FUNCTION_MACRO; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { EMBED_IN_ANOTHER_MACRO1; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+}
+
+#define FUNC_MACRO_WITH_FILE_AND_LINE Foo(__func__, __FILE__, __LINE__)
+#define FUNCTION_MACRO_WITH_FILE_AND_LINE Foo(__FUNCTION__, __FILE__, __LINE__)
+#define EMBED_IN_ANOTHER_MACRO2 FUNC_MACRO_WITH_FILE_AND_LINE
+
+void Negatives() {
+  __func__;
+  __FUNCTION__;
+
+  // __PRETTY_FUNCTION__ should not trigger a warning because its value is
+  // actually potentially useful.
+  __PRETTY_FUNCTION__;
+  [] { __PRETTY_FUNCTION__; }();
+
+  // Don't warn if __func__/__FUNCTION is used inside a macro that also uses
+  // __FILE__ and __LINE__, on the assumption that __FILE__ and __LINE__ will
+  // be useful even if __func__/__FUNCTION__ is not.
+  [] { FUNC_MACRO_WITH_FILE_AND_LINE; }();
+  [] { FUNCTION_MACRO_WITH_FILE_AND_LINE; }();
+  [] { EMBED_IN_ANOTHER_MACRO2; }();
+}
Index: docs/clang-tidy/checks/misc-lambda-function-name.rst
===
--- docs/clang-tidy/checks/misc-lambda-function-name.rst
+++ docs/clang-tidy/checks/misc-lambda-function-name.rst
@@ -0,0 +1,27 @@
+.. title:: clang-tidy - misc-lambda-function-name
+
+misc-lambda-function-name
+=
+
+Checks for attempts to get the name of a function from within a lambda
+expression. The name of a lambda is always something like ``operator()``, which
+is almost never what was intended.
+
+Example:
+
+.. code-block:: c++
+
+  void FancyFunction() {
+[] { printf("Called from %s\n", __func__); }();
+[] { printf("Now called from %s\n", __FUNCTION__); }();
+  }
+
+Output::
+
+  Called from operator()
+  Now called from operator()
+
+Likely intended output::
+
+  Called from FancyFunction
+  Now called from FancyFunction
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -82,6 +82,7 @@
misc-inaccurate-erase
misc-incorrect-roundings
misc-inefficient-algorithm
+   misc-lambda-function-name
misc-macro-parentheses
misc-macro-repeated-side-effects
misc-misplaced-const
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -77,6 +77,11 @@
 
   Finds perfect forwarding constructors that can unintentionally hide copy or move constructors.
 
+- New `misc-lambda-function-name
+	`_ check
+
+	Finds uses of ``__func__`` or ``__FUNCTION__`` inside lambdas.
+
 - New `modernize-replace-random-shuffle
   `_ check
 
Index: 

[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 marked 2 inline comments as done.
jyu2 added inline comments.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:334
+  continue;
+else
+  HasThrowOutFunc = true;

jyu2 wrote:
> aaron.ballman wrote:
> > You can drop the `else` here and just set `HasThrowOutFunc` to true.
> Can not do that, don't if block has throw expression yet. 
Yes, Eric just point out, you are right, I can remove the line of "else"


https://reviews.llvm.org/D3



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libclc] r304556 - generic: add missing get_work_dim include

2017-06-02 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Jun  2 10:58:35 2017
New Revision: 304556

URL: http://llvm.org/viewvc/llvm-project?rev=304556=rev
Log:
generic: add missing get_work_dim include

Fixes few piglits since clang r304193

Signed-off-by: Jan Vesely 
Reviewed-by: Aaron Watry 

Modified:
libclc/trunk/generic/include/clc/clc.h

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=304556=304555=304556=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Fri Jun  2 10:58:35 2017
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* 6.11.2 Math Functions */
 #include 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33497: [clang-tidy] check for __func__/__FUNCTION__ in lambdas

2017-06-02 Thread Bryce Liu via Phabricator via cfe-commits
brycel updated this revision to Diff 101223.
brycel marked 4 inline comments as done.
brycel added a comment.

Addressed comments from alexfh. In particular, changed to using a set from a 
vector.


https://reviews.llvm.org/D33497

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/LambdaFunctionNameCheck.cpp
  clang-tidy/misc/LambdaFunctionNameCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-lambda-function-name.rst
  test/clang-tidy/misc-lambda-function-name.cpp

Index: test/clang-tidy/misc-lambda-function-name.cpp
===
--- test/clang-tidy/misc-lambda-function-name.cpp
+++ test/clang-tidy/misc-lambda-function-name.cpp
@@ -0,0 +1,41 @@
+// RUN: %check_clang_tidy %s misc-lambda-function-name %t
+
+void Foo(const char* a, const char* b, int c) {}
+
+#define FUNC_MACRO Foo(__func__, "", 0)
+#define FUNCTION_MACRO Foo(__FUNCTION__, "", 0)
+#define EMBED_IN_ANOTHER_MACRO1 FUNC_MACRO
+
+void Positives() {
+  [] { __func__; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { __FUNCTION__; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { FUNC_MACRO; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { FUNCTION_MACRO; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { EMBED_IN_ANOTHER_MACRO1; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+}
+
+#define FUNC_MACRO_WITH_FILE_AND_LINE Foo(__func__, __FILE__, __LINE__)
+#define FUNCTION_MACRO_WITH_FILE_AND_LINE Foo(__FUNCTION__, __FILE__, __LINE__)
+#define EMBED_IN_ANOTHER_MACRO2 FUNC_MACRO_WITH_FILE_AND_LINE
+
+void Negatives() {
+  __func__;
+  __FUNCTION__;
+
+  // __PRETTY_FUNCTION__ should not trigger a warning because its value is
+  // actually potentially useful.
+  __PRETTY_FUNCTION__;
+  [] { __PRETTY_FUNCTION__; }();
+
+  // Don't warn if __func__/__FUNCTION is used inside a macro that also uses
+  // __FILE__ and __LINE__, on the assumption that __FILE__ and __LINE__ will
+  // be useful even if __func__/__FUNCTION__ is not.
+  [] { FUNC_MACRO_WITH_FILE_AND_LINE; }();
+  [] { FUNCTION_MACRO_WITH_FILE_AND_LINE; }();
+  [] { EMBED_IN_ANOTHER_MACRO2; }();
+}
Index: docs/clang-tidy/checks/misc-lambda-function-name.rst
===
--- docs/clang-tidy/checks/misc-lambda-function-name.rst
+++ docs/clang-tidy/checks/misc-lambda-function-name.rst
@@ -0,0 +1,27 @@
+.. title:: clang-tidy - misc-lambda-function-name
+
+misc-lambda-function-name
+=
+
+Checks for attempts to get the name of a function from within a lambda
+expression. The name of a lambda is always something like ``operator()``, which
+is almost never what was intended.
+
+Example:
+
+.. code-block:: c++
+
+  void FancyFunction() {
+[] { printf("Called from %s\n", __func__); }();
+[] { printf("Now called from %s\n", __FUNCTION__); }();
+  }
+
+Output::
+
+  Called from operator()
+  Now called from operator()
+
+Likely intended output::
+
+  Called from FancyFunction
+  Now called from FancyFunction
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -82,6 +82,7 @@
misc-inaccurate-erase
misc-incorrect-roundings
misc-inefficient-algorithm
+   misc-lambda-function-name
misc-macro-parentheses
misc-macro-repeated-side-effects
misc-misplaced-const
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -77,6 +77,11 @@
 
   Finds perfect forwarding constructors that can unintentionally hide copy or move constructors.
 
+- New `misc-lambda-function-name
+	`_ check
+
+	Finds uses of ``__func__`` or ``__FUNCTION__`` inside lambdas.
+
 - New `modernize-replace-random-shuffle
   

[PATCH] D33706: CodeGen: Cast temporary variable to proper address space

2017-06-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 101221.
yaxunl marked 7 inline comments as done.
yaxunl added a comment.

Revised by John's comments.


https://reviews.llvm.org/D33706

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/address-space.c
  test/CodeGen/default-address-space.c
  test/CodeGenCXX/amdgcn-automatic-variable.cpp

Index: test/CodeGenCXX/amdgcn-automatic-variable.cpp
===
--- test/CodeGenCXX/amdgcn-automatic-variable.cpp
+++ test/CodeGenCXX/amdgcn-automatic-variable.cpp
@@ -3,9 +3,10 @@
 // CHECK-LABEL: define void @_Z5func1Pi(i32* %x)
 void func1(int *x) {
   // CHECK: %[[x_addr:.*]] = alloca i32*{{.*}}addrspace(5)
-  // CHECK: store i32* %x, i32* addrspace(5)* %[[x_addr]]
-  // CHECK: %[[r0:.*]] = load i32*, i32* addrspace(5)* %[[x_addr]]
-  // CHECK: store i32 1, i32* %[[r0]]
+  // CHECK: %[[r0:.*]] = addrspacecast i32* addrspace(5)* %[[x_addr]] to i32**
+  // CHECK: store i32* %x, i32** %[[r0]]
+  // CHECK: %[[r1:.*]] = load i32*, i32** %[[r0]]
+  // CHECK: store i32 1, i32* %[[r1]]
   *x = 1;
 }
 
@@ -70,3 +71,12 @@
   // CHECK: call void @_ZN1AD1Ev(%class.A* %[[r0]])
   A a;
 }
+
+// CHECK-LABEL: define void @_Z5func4i
+void func4(int x) {
+  // CHECK: %[[x_addr:.*]] = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %[[x_addr]] to i32*
+  // CHECK: store i32 %x, i32* %[[r0]], align 4
+  // CHECK: call void @_Z5func1Pi(i32* %[[r0]])
+  func1();
+}
Index: test/CodeGen/default-address-space.c
===
--- test/CodeGen/default-address-space.c
+++ test/CodeGen/default-address-space.c
@@ -22,9 +22,10 @@
 int test1() { return foo; }
 
 // COM-LABEL: define i32 @test2(i32 %i)
-// PIZ: load i32, i32 addrspace(4)*
+// COM: %[[addr:.*]] = getelementptr
+// PIZ: load i32, i32 addrspace(4)* %[[addr]]
 // PIZ-NEXT: ret i32
-// CHECK: load i32, i32*
+// CHECK: load i32, i32* %[[addr]]
 // CHECK-NEXT: ret i32
 int test2(int i) { return ban[i]; }
 
@@ -42,15 +43,17 @@
 }
 
 // PIZ-LABEL: define void @test4(i32 addrspace(4)* %a)
-// PIZ: %[[a_addr:.*]] = alloca i32 addrspace(4)*
-// PIZ: store i32 addrspace(4)* %a, i32 addrspace(4)** %[[a_addr]]
-// PIZ: %[[r0:.*]] = load i32 addrspace(4)*, i32 addrspace(4)** %[[a_addr]]
+// PIZ: %[[alloca:.*]] = alloca i32 addrspace(4)*
+// PIZ: %[[a_addr:.*]] = addrspacecast{{.*}} %[[alloca]] to i32 addrspace(4)* addrspace(4)*
+// PIZ: store i32 addrspace(4)* %a, i32 addrspace(4)* addrspace(4)* %[[a_addr]]
+// PIZ: %[[r0:.*]] = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* %[[a_addr]]
 // PIZ: %[[arrayidx:.*]] = getelementptr inbounds i32, i32 addrspace(4)* %[[r0]]
 // PIZ: store i32 0, i32 addrspace(4)* %[[arrayidx]]
 // CHECK-LABEL: define void @test4(i32* %a)
-// CHECK: %[[a_addr:.*]] = alloca i32*, align 4, addrspace(5)
-// CHECK: store i32* %a, i32* addrspace(5)* %[[a_addr]]
-// CHECK: %[[r0:.*]] = load i32*, i32* addrspace(5)* %[[a_addr]]
+// CHECK: %[[alloca:.*]] = alloca i32*, align 4, addrspace(5)
+// CHECK: %[[a_addr:.*]] = addrspacecast{{.*}} %[[alloca]] to i32**
+// CHECK: store i32* %a, i32** %[[a_addr]]
+// CHECK: %[[r0:.*]] = load i32*, i32** %[[a_addr]]
 // CHECK: %[[arrayidx:.*]] = getelementptr inbounds i32, i32* %[[r0]]
 // CHECK: store i32 0, i32* %[[arrayidx]]
 void test4(int *a) {
Index: test/CodeGen/address-space.c
===
--- test/CodeGen/address-space.c
+++ test/CodeGen/address-space.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck -check-prefixes=CHECK,GIZ %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck -check-prefixes=CHECK,X86,GIZ %s
 // RUN: %clang_cc1 -triple amdgcn -emit-llvm < %s | FileCheck -check-prefixes=CHECK,PIZ %s
-// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK,GIZ %s
+// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK,AMDGIZ,GIZ %s
 
 // CHECK: @foo = common addrspace(1) global
 int foo __attribute__((address_space(1)));
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1915,13 +1915,36 @@
 LValueBaseInfo *BaseInfo = nullptr);
   LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy);
 
-  /// CreateTempAlloca - This creates a alloca and inserts it into the entry
-  /// block. The caller is responsible for setting an appropriate alignment on
+  /// CreateTempAlloca - This creates an alloca and inserts it into the entry
+  /// block if \p ArraySize is nullptr, otherwise inserts it at the current
+  /// insertion point of the builder. The caller is responsible for setting an
+  /// appropriate 

[PATCH] D33821: [OpenCL] Harden function pointer diagnostics.

2017-06-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

LGTM. Thanks.


https://reviews.llvm.org/D33821



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r304553 - ASTPrinter: Objective-C method declarations don't need a space after

2017-06-02 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jun  2 10:02:59 2017
New Revision: 304553

URL: http://llvm.org/viewvc/llvm-project?rev=304553=rev
Log:
ASTPrinter: Objective-C method declarations don't need a space after
the return type

rdar://32332039

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Misc/ast-print-objectivec.m
cfe/trunk/test/Modules/lookup.m
cfe/trunk/unittests/AST/DeclPrinterTest.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=304553=304552=304553=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Fri Jun  2 10:02:59 2017
@@ -1189,7 +1189,9 @@ void DeclPrinter::VisitObjCMethodDecl(Ob
   for (const auto *PI : OMD->parameters()) {
 // FIXME: selector is missing here!
 pos = name.find_first_of(':', lastPos);
-Out << " " << name.substr(lastPos, pos - lastPos) << ':';
+if (lastPos != 0)
+  Out << " ";
+Out << name.substr(lastPos, pos - lastPos) << ':';
 PrintObjCMethodType(OMD->getASTContext(), 
 PI->getObjCDeclQualifier(),
 PI->getType());
@@ -1198,7 +1200,7 @@ void DeclPrinter::VisitObjCMethodDecl(Ob
   }
 
   if (OMD->param_begin() == OMD->param_end())
-Out << " " << name;
+Out << name;
 
   if (OMD->isVariadic())
   Out << ", ...";

Modified: cfe/trunk/test/Misc/ast-print-objectivec.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-objectivec.m?rev=304553=304552=304553=diff
==
--- cfe/trunk/test/Misc/ast-print-objectivec.m (original)
+++ cfe/trunk/test/Misc/ast-print-objectivec.m Fri Jun  2 10:02:59 2017
@@ -17,25 +17,30 @@
 @implementation I
 - (void)MethP 
__attribute__((availability(macosx,introduced=10.1.0,deprecated=10.2))) {}
 - (void)MethI 
__attribute__((availability(macosx,introduced=10.1.0,deprecated=10.2))) {}
+
+- (void)methodWithArg:(int)x andAnotherOne:(int)y { }
 @end
 
 // CHECK: @protocol P
-// CHECK: - (void) MethP __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2)));
+// CHECK: - (void)MethP __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2)));
 // CHECK: @end
 
 // CHECK: @interface I : NSObject 
-// CHECK: - (void) MethI __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2)));
+// CHECK: - (void)MethI __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2)));
 // CHECK: @end
 
 // CHECK: @interface I(CAT)
-// CHECK: - (void) MethCAT __attribute__((availability(macos, 
introduced=10_1_0, deprecated=10_2)));
+// CHECK: - (void)MethCAT __attribute__((availability(macos, 
introduced=10_1_0, deprecated=10_2)));
 // CHECK: @end
 
 // CHECK: @implementation I
-// CHECK: - (void) MethP __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2))) {
+// CHECK: - (void)MethP __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2))) {
+// CHECK: }
+
+// CHECK: - (void)MethI __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2))) {
 // CHECK: }
 
-// CHECK: - (void) MethI __attribute__((availability(macos, introduced=10.1.0, 
deprecated=10.2))) {
+// CHECK: - (void)methodWithArg:(int)x andAnotherOne:(int)y {
 // CHECK: }
 
 // CHECK: @end

Modified: cfe/trunk/test/Modules/lookup.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/lookup.m?rev=304553=304552=304553=diff
==
--- cfe/trunk/test/Modules/lookup.m (original)
+++ cfe/trunk/test/Modules/lookup.m Fri Jun  2 10:02:59 2017
@@ -14,7 +14,7 @@ void test(id x) {
 // expected-note@Inputs/lookup_right.h:3{{also found}}
 }
 
-// CHECK-PRINT: - (int) method;
-// CHECK-PRINT: - (double) method
+// CHECK-PRINT: - (int)method;
+// CHECK-PRINT: - (double)method
 // CHECK-PRINT: void test(id x)
 

Modified: cfe/trunk/unittests/AST/DeclPrinterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/DeclPrinterTest.cpp?rev=304553=304552=304553=diff
==
--- cfe/trunk/unittests/AST/DeclPrinterTest.cpp (original)
+++ cfe/trunk/unittests/AST/DeclPrinterTest.cpp Fri Jun  2 10:02:59 2017
@@ -1228,7 +1228,7 @@ TEST(DeclPrinter, TestObjCMethod1) {
 "@end\n",
 namedDecl(hasName("A:inRange:"),
   hasDescendant(namedDecl(hasName("printThis".bind("id"),
-"- (int) A:(id)anObject inRange:(long)range"));
+"- (int)A:(id)anObject inRange:(long)range"));
 }
 
 TEST(DeclPrinter, TestObjCProtocol1) {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33833: Fix Clang assertion on template destructor declaration

2017-06-02 Thread Kuang He via Phabricator via cfe-commits
kuang_he created this revision.

This patch aim to fix bug reported at 
https://bugs.llvm.org/show_bug.cgi?id=33189. Clang hit assertion on template 
destructor declaration


https://reviews.llvm.org/D33833

Files:
  lib/AST/DeclCXX.cpp
  test/SemaCXX/PR33189.cpp


Index: test/SemaCXX/PR33189.cpp
===
--- /dev/null
+++ test/SemaCXX/PR33189.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+class U
+{
+  template 
+  ~U() { } // expected-error{{destructor cannot be declared as a template}}
+};
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1417,7 +1417,7 @@
   Context.getCanonicalType(ClassType));
 
   DeclContext::lookup_result R = lookup(Name);
-  if (R.empty())
+  if (R.empty() || !isa(R.front()))
 return nullptr;
 
   CXXDestructorDecl *Dtor = cast(R.front());


Index: test/SemaCXX/PR33189.cpp
===
--- /dev/null
+++ test/SemaCXX/PR33189.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+class U
+{
+  template 
+  ~U() { } // expected-error{{destructor cannot be declared as a template}}
+};
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1417,7 +1417,7 @@
   Context.getCanonicalType(ClassType));
 
   DeclContext::lookup_result R = lookup(Name);
-  if (R.empty())
+  if (R.empty() || !isa(R.front()))
 return nullptr;
 
   CXXDestructorDecl *Dtor = cast(R.front());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible

2017-06-02 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: tools/libclang/CIndex.cpp:7287
+
   if (!HadAvailAttr)
 if (const EnumConstantDecl *EnumConst = dyn_cast(D))

I think that you can move this `if` before the new `if`, and convert the new 
`if` to be an `if (AvailabilityAttrs.empty())` that returns early. Then you can 
do the merging outside of the `if` at the end of the function.



Comment at: tools/libclang/CIndex.cpp:7322
+
+  for (int I = 0, E = AvailabilityAttrs.size(); I < E && I < availability_size;
+   ++I) {

You can use a ranged for loop here if you use `take_front`, e.g.

```
for (const auto *Avail : AvailabilityAttrs.take_front(availability_size))
```


https://reviews.llvm.org/D33478



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33826: [clang-tidy] avoid pointer cast to more strict alignment check

2017-06-02 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: 
test/clang-tidy/cert-avoid-pointer-cast-to-more-strict-alignment.c:17
+ 
+  tmp = (struct foo_header *)(data + offset);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not cast pointers into more 
strictly aligned pointer types [cert-exp36-c] 

Shouldn't there be at least one test for C++-style cast?


Repository:
  rL LLVM

https://reviews.llvm.org/D33826



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 101199.
ABataev added a comment.

Updates after review


https://reviews.llvm.org/D33735

Files:
  include/clang/AST/Decl.h
  lib/AST/Decl.cpp
  lib/AST/DeclObjC.cpp
  lib/CodeGen/CGCXXABI.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/captured-statements.c
  test/CodeGenCXX/captured-statements.cpp

Index: test/CodeGenCXX/captured-statements.cpp
===
--- test/CodeGenCXX/captured-statements.cpp
+++ test/CodeGenCXX/captured-statements.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t
+// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3
@@ -194,3 +194,18 @@
 void call_test_captured_linkage() {
   test_captured_linkage();
 }
+
+// CHECK-1-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-1-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-2-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-2-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-3-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-3-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-4-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-4-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-5-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-5-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-6-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-6-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-7-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-7-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
Index: test/CodeGen/captured-statements.c
===
--- test/CodeGen/captured-statements.c
+++ test/CodeGen/captured-statements.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
@@ -98,3 +98,8 @@
 // CHECK-GLOBALS:   load i32, i32* @global
 // CHECK-GLOBALS:   load i32, i32* @
 // CHECK-GLOBALS:   load i32, i32* @e
+
+// CHECK-GLOBALS-NOT: DIFlagObjectPointer
+// CHECK-1-NOT: DIFlagObjectPointer
+// CHECK-2-NOT: DIFlagObjectPointer
+// CHECK-3-NOT: DIFlagObjectPointer
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -967,6 +967,7 @@
 
 void ASTDeclWriter::VisitImplicitParamDecl(ImplicitParamDecl *D) {
   VisitVarDecl(D);
+  Record.push_back(D->isThisOrSelfParam());
   Code = serialization::DECL_IMPLICIT_PARAM;
 }
 
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1278,6 +1278,7 @@
 
 void ASTDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) {
   VisitVarDecl(PD);
+  PD->IsThisOrSelf = Record.readInt();
 }
 
 void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) {
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3462,13 +3462,12 @@
   unsigned AddressSpace = CGM.getContext().getTargetAddressSpace(VD->getType());
   AppendAddressSpaceXDeref(AddressSpace, Expr);
 
-  // If this is the first argument and it is implicit then
-  // give it an object pointer flag.
-  // FIXME: There has to be a better way to do this, but for static
-  // functions there won't be an implicit param at arg1 and
-  // otherwise it is 'self' or 'this'.
-  if (isa(VD) && ArgNo && *ArgNo == 1)
-  Flags |= llvm::DINode::FlagObjectPointer;
+  // If this is the first argument, it is implicit and has ThisOrSelf attribute
+  // then give it an object pointer flag.
+  if (ArgNo && *ArgNo == 1)
+if (auto *IPD = dyn_cast(VD))
+  if (IPD->isThisOrSelfParam())
+Flags |= 

[PATCH] D33828: [analyzer] Don't crash when the code tries to construct an Objective-C object in AllocaRegion.

2017-06-02 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
Herald added a subscriber: xazax.hun.

The analyzer crashes when the user tries to allocate stack memory through 
`alloca()` and then construct an Objective-C object in it. The `alloca()` 
function is handled in the analyzer by its own concrete untyped memory region, 
`AllocaRegion`, which doesn't contain any clues on what type it might carry 
(because there are none). `getDynamicTypeInfo()` therefore ignores it unless a 
specific type info is already available.

To think: maybe we could pickup some dynamic type info from the implicit cast. 
We don't always have an implicit cast though.


https://reviews.llvm.org/D33828

Files:
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/DynamicTypePropagation.m


Index: test/Analysis/DynamicTypePropagation.m
===
--- test/Analysis/DynamicTypePropagation.m
+++ test/Analysis/DynamicTypePropagation.m
@@ -4,6 +4,9 @@
 #  error Compiler does not support Objective-C generics?
 #endif
 
+typedef __typeof(sizeof(int)) size_t;
+void *memset(void *, int, size_t);
+
 #define nil 0
 typedef unsigned long NSUInteger;
 typedef int BOOL;
@@ -21,6 +24,7 @@
 @end
 
 @interface NSArray : NSObject
+- (void) init;
 - (BOOL)contains:(ObjectType)obj;
 - (ObjectType)getObjAtIndex:(NSUInteger)idx;
 - (ObjectType)objectAtIndexedSubscript:(NSUInteger)idx;
@@ -55,3 +59,11 @@
   // MyType!
   [element myFunction:0 myParam:0 ];
 }
+
+// Do not try this at home! The analyzer shouldn't crash though when it
+// tries to figure out the dynamic type behind the alloca's return value.
+void testAlloca(size_t NSArrayClassSizeWeKnowSomehow) {
+  NSArray *arr = __builtin_alloca(NSArrayClassSizeWeKnowSomehow);
+  memset(arr, 0, NSArrayClassSizeWeKnowSomehow);
+  [arr init]; // no-crash
+}
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -957,6 +957,9 @@
 return RuntimeDefinition();
 
   DynamicTypeInfo DTI = getDynamicTypeInfo(getState(), Receiver);
+  if (!DTI.isValid()) // Might be AllocaRegion.
+return RuntimeDefinition();
+
   QualType DynType = DTI.getType();
   CanBeSubClassed = DTI.canBeASubClass();
   ReceiverT = dyn_cast(DynType.getCanonicalType());


Index: test/Analysis/DynamicTypePropagation.m
===
--- test/Analysis/DynamicTypePropagation.m
+++ test/Analysis/DynamicTypePropagation.m
@@ -4,6 +4,9 @@
 #  error Compiler does not support Objective-C generics?
 #endif
 
+typedef __typeof(sizeof(int)) size_t;
+void *memset(void *, int, size_t);
+
 #define nil 0
 typedef unsigned long NSUInteger;
 typedef int BOOL;
@@ -21,6 +24,7 @@
 @end
 
 @interface NSArray : NSObject
+- (void) init;
 - (BOOL)contains:(ObjectType)obj;
 - (ObjectType)getObjAtIndex:(NSUInteger)idx;
 - (ObjectType)objectAtIndexedSubscript:(NSUInteger)idx;
@@ -55,3 +59,11 @@
   // MyType!
   [element myFunction:0 myParam:0 ];
 }
+
+// Do not try this at home! The analyzer shouldn't crash though when it
+// tries to figure out the dynamic type behind the alloca's return value.
+void testAlloca(size_t NSArrayClassSizeWeKnowSomehow) {
+  NSArray *arr = __builtin_alloca(NSArrayClassSizeWeKnowSomehow);
+  memset(arr, 0, NSArrayClassSizeWeKnowSomehow);
+  [arr init]; // no-crash
+}
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -957,6 +957,9 @@
 return RuntimeDefinition();
 
   DynamicTypeInfo DTI = getDynamicTypeInfo(getState(), Receiver);
+  if (!DTI.isValid()) // Might be AllocaRegion.
+return RuntimeDefinition();
+
   QualType DynType = DTI.getType();
   CanBeSubClassed = DTI.canBeASubClass();
   ReceiverT = dyn_cast(DynType.getCanonicalType());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33827: [clang-tidy] misc-static-assert shouldn't flag assert(!"msg")

2017-06-02 Thread Florian Gross via Phabricator via cfe-commits
fgross created this revision.
Herald added a subscriber: xazax.hun.

Added negated string literals to the set of IsAlwaysFalse expressions to avoid 
flagging of

  assert(!"msg")


https://reviews.llvm.org/D33827

Files:
  clang-tidy/misc/StaticAssertCheck.cpp
  test/clang-tidy/misc-static-assert.cpp


Index: test/clang-tidy/misc-static-assert.cpp
===
--- test/clang-tidy/misc-static-assert.cpp
+++ test/clang-tidy/misc-static-assert.cpp
@@ -76,6 +76,9 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
   // CHECK-FIXES: {{^  }}static_assert(ZERO_MACRO, "");
 
+  assert(!"Don't report me!");
+  // CHECK-FIXES: {{^  }}assert(!"Don't report me!");
+
   assert(0 && "Don't report me!");
   // CHECK-FIXES: {{^  }}assert(0 && "Don't report me!");
 
Index: clang-tidy/misc/StaticAssertCheck.cpp
===
--- clang-tidy/misc/StaticAssertCheck.cpp
+++ clang-tidy/misc/StaticAssertCheck.cpp
@@ -33,9 +33,11 @@
   if (!(getLangOpts().CPlusPlus11 || getLangOpts().C11))
 return;
 
+  auto NegatedString = unaryOperator(
+  hasOperatorName("!"), 
hasUnaryOperand(ignoringImpCasts(stringLiteral(;
   auto IsAlwaysFalse =
   expr(anyOf(cxxBoolLiteral(equals(false)), integerLiteral(equals(0)),
- cxxNullPtrLiteralExpr(), gnuNullExpr()))
+ cxxNullPtrLiteralExpr(), gnuNullExpr(), NegatedString))
   .bind("isAlwaysFalse");
   auto IsAlwaysFalseWithCast = ignoringParenImpCasts(anyOf(
   IsAlwaysFalse, cStyleCastExpr(has(ignoringParenImpCasts(IsAlwaysFalse)))


Index: test/clang-tidy/misc-static-assert.cpp
===
--- test/clang-tidy/misc-static-assert.cpp
+++ test/clang-tidy/misc-static-assert.cpp
@@ -76,6 +76,9 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
   // CHECK-FIXES: {{^  }}static_assert(ZERO_MACRO, "");
 
+  assert(!"Don't report me!");
+  // CHECK-FIXES: {{^  }}assert(!"Don't report me!");
+
   assert(0 && "Don't report me!");
   // CHECK-FIXES: {{^  }}assert(0 && "Don't report me!");
 
Index: clang-tidy/misc/StaticAssertCheck.cpp
===
--- clang-tidy/misc/StaticAssertCheck.cpp
+++ clang-tidy/misc/StaticAssertCheck.cpp
@@ -33,9 +33,11 @@
   if (!(getLangOpts().CPlusPlus11 || getLangOpts().C11))
 return;
 
+  auto NegatedString = unaryOperator(
+  hasOperatorName("!"), hasUnaryOperand(ignoringImpCasts(stringLiteral(;
   auto IsAlwaysFalse =
   expr(anyOf(cxxBoolLiteral(equals(false)), integerLiteral(equals(0)),
- cxxNullPtrLiteralExpr(), gnuNullExpr()))
+ cxxNullPtrLiteralExpr(), gnuNullExpr(), NegatedString))
   .bind("isAlwaysFalse");
   auto IsAlwaysFalseWithCast = ignoringParenImpCasts(anyOf(
   IsAlwaysFalse, cStyleCastExpr(has(ignoringParenImpCasts(IsAlwaysFalse)))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33826: [clang-tidy] avoid pointer cast to more strict alignment check

2017-06-02 Thread Eniko Donatella Toth via Phabricator via cfe-commits
NorenaLeonetti created this revision.
NorenaLeonetti added a project: clang-tools-extra.
Herald added subscribers: xazax.hun, mgorny.

Based on CERT-EXP36-C


Repository:
  rL LLVM

https://reviews.llvm.org/D33826

Files:
  clang-tidy/cert/AvoidPointerCastToMoreStrictAlignmentCheck.cpp
  clang-tidy/cert/AvoidPointerCastToMoreStrictAlignmentCheck.h
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cert-exp36-c.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-avoid-pointer-cast-to-more-strict-alignment.c

Index: test/clang-tidy/cert-avoid-pointer-cast-to-more-strict-alignment.c
===
--- /dev/null
+++ test/clang-tidy/cert-avoid-pointer-cast-to-more-strict-alignment.c
@@ -0,0 +1,45 @@
+// RUN: %check_clang_tidy %s cert-exp36-c %t -- -- -std=c11
+
+void function(void) {
+  char c = 'x';
+  int *ip = (int *)
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not cast pointers into more strictly aligned pointer types [cert-exp36-c] 
+}
+
+struct foo_header {
+  int len;
+};
+ 
+void function2(char *data, unsigned offset) {
+  struct foo_header *tmp;
+  struct foo_header header;
+ 
+  tmp = (struct foo_header *)(data + offset);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not cast pointers into more strictly aligned pointer types [cert-exp36-c] 
+}
+
+
+// Something that does not trigger the check:
+
+struct w;
+
+void function3(struct w *v) {
+  int *ip = (int *)v;
+  struct w *u = (struct w *)ip;
+}
+
+struct x {
+   _Alignas(int) char c;
+};
+
+void function4(void) {
+  struct x c = {'x'};
+  int *ip = (int *)
+}
+
+// FIXME: we do not want a warning for this
+void function5(void) {
+  _Alignas(int) char c = 'x';
+  int *ip = (int *)
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not cast pointers into more strictly aligned pointer types [cert-exp36-c]
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -5,6 +5,7 @@
 
 .. toctree::
boost-use-to-string
+   cert-exp36-c
cert-dcl03-c (redirects to misc-static-assert) 
cert-dcl21-cpp
cert-dcl50-cpp
Index: docs/clang-tidy/checks/cert-exp36-c.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cert-exp36-c.rst
@@ -0,0 +1,43 @@
+.. title:: clang-tidy - cert-exp36-c
+
+cert-exp36-c
+
+
+This check will give a warning if a pointer value is converted to
+a pointer type that is more strictly aligned than the referenced type.
+ 
+ Here's an example:
+ 
+ .. code-block:: c
+ 
+char c = 'x';
+int *ip = (int *)
+// warning: do not cast pointers into more strictly aligned pointer types
+ 
+ This check does not completely include warnings for types with explicitly
+ specified alignment, this remains a possible future extension.
+
+ See the example:
+
+  .. code-block:: c
+
+// Works fine:
+struct x {
+  _Alignas(int) char c;
+};
+
+void function3(void) {
+  struct x c = {'x'};
+  int *ip = (int *)
+}
+
+// Won't work:
+void function4(void) {
+  _Alignas(int) char c = 'x';
+  int *ip = (int *)
+  // the check will give a warning for this
+}
+
+ This check corresponds to the CERT C Coding Standard rule
+ `EXP36-C. Do not cast pointers into more strictly aligned pointer types
+`_.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `cert-exp36-c
+  `_ check
+
+  Checks if a pointer value is casted to a more stricter alignment.
+
 - New `cert-dcl21-cpp
   `_ check
 
Index: clang-tidy/cert/CMakeLists.txt
===
--- clang-tidy/cert/CMakeLists.txt
+++ clang-tidy/cert/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyCERTModule
+  AvoidPointerCastToMoreStrictAlignmentCheck.cpp
   CERTTidyModule.cpp
   CommandProcessorCheck.cpp
   DontModifyStdNamespaceCheck.cpp
Index: clang-tidy/cert/CERTTidyModule.cpp
===
--- clang-tidy/cert/CERTTidyModule.cpp
+++ clang-tidy/cert/CERTTidyModule.cpp
@@ -16,6 +16,7 @@
 #include "../misc/NonCopyableObjects.h"
 #include "../misc/StaticAssertCheck.h"
 #include "../misc/ThrowByValueCatchByReferenceCheck.h"
+#include "AvoidPointerCastToMoreStrictAlignmentCheck.h"
 #include "CommandProcessorCheck.h"
 #include 

[PATCH] D33537: [clang-tidy] Exception Escape Checker

2017-06-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D33537#771159, @baloghadamsoftware wrote:

> In https://reviews.llvm.org/D33537#770264, @aaron.ballman wrote:
>
> > I think we should try to get as much of this functionality in 
> > https://reviews.llvm.org/D3 as possible; there is a considerable amount 
> > of overlap between that functionality and this functionality. This check 
> > can then cover only the parts that are not reasonably handled by the 
> > frontend check instead of duplicating diagnostics the user already receives.
>
>
> I suppose that the frontend check will not travarse the call-graph just check 
> direct throws. Should we only check indirect throws then?


The check in https://reviews.llvm.org/D3 is using a CFG, not just checking 
direct throws.


https://reviews.llvm.org/D33537



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33788: Return a canonical path from getClangResourcePath()

2017-06-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D33788#771070, @bruno wrote:

> Hi Aaron,
>
> Nice catch! Any chance you can add a testcase to this?


There's already a test case that covers this: Index/pch-from-libclang.c -- it 
was failing on OS X 10.6 for us. If you have a better test case in mind, I can 
certainly add it.


https://reviews.llvm.org/D33788



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33825: [clang-tidy] signal handler must be plain old function check

2017-06-02 Thread Eniko Donatella Toth via Phabricator via cfe-commits
NorenaLeonetti created this revision.
NorenaLeonetti added a project: clang-tools-extra.
Herald added subscribers: xazax.hun, mgorny.

Based on CERT-MSC54-CPP


Repository:
  rL LLVM

https://reviews.llvm.org/D33825

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/SignalHandlerMustBePlainOldFunctionCheck.cpp
  clang-tidy/cert/SignalHandlerMustBePlainOldFunctionCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cert-msc54-cpp.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-signal-handler-must-be-plain-old-function.cpp

Index: test/clang-tidy/cert-signal-handler-must-be-plain-old-function.cpp
===
--- /dev/null
+++ test/clang-tidy/cert-signal-handler-must-be-plain-old-function.cpp
@@ -0,0 +1,134 @@
+// RUN: %check_clang_tidy %s cert-msc54-cpp %t -- -- -std=c++11
+
+namespace std {
+extern "C" using signalhandler = void(int);
+int signal(int sig, signalhandler *func);
+}
+
+#define SIG_ERR -1
+#define SIGTERM 15
+
+static void sig_handler(int sig) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use 'external C' prefix for signal handlers [cert-msc54-cpp]
+// CHECK-MESSAGES: :[[@LINE+3]]:39: note: given as a signal parameter here
+
+void install_signal_handler() {
+  if (SIG_ERR == std::signal(SIGTERM, sig_handler))
+return;
+}
+
+extern "C" void cpp_signal_handler(int sig) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: do not use C++ representations in signal handlers [cert-msc54-cpp]
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: note: C++ representation used here
+  throw "error message";
+}
+
+void install_cpp_signal_handler() {
+  if (SIG_ERR == std::signal(SIGTERM, cpp_signal_handler))
+return;
+}
+
+void indirect_recursion();
+
+void cpp_like(){
+  try {
+cpp_signal_handler(SIG_ERR);
+  } catch(...) {
+// handle error
+  }
+}
+
+void no_body();
+
+void recursive_function() {
+  indirect_recursion();
+  cpp_like();
+  no_body();
+  recursive_function();
+}
+
+void indirect_recursion() {
+  recursive_function();
+}
+
+extern "C" void signal_handler_with_cpp_function_call(int sig) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: do not call functions with C++ representations in signal handlers [cert-msc54-cpp]
+  // CHECK-MESSAGES: :[[@LINE-11]]:3: note: function called here
+  // CHECK-MESSAGES: :[[@LINE-23]]:3: note: C++ representation used here
+  recursive_function();
+}
+
+void install_signal_handler_with_cpp_function_call() {
+  if (SIG_ERR == std::signal(SIGTERM, signal_handler_with_cpp_function_call))
+return;
+}
+
+class TestClass {
+public:
+  static void static_function() {}
+};
+
+extern "C" void signal_handler_with_cpp_static_method_call(int sig) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: do not call functions with C++ representations in signal handlers [cert-msc54-cpp]
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: note: function called here
+  TestClass::static_function();
+}
+
+void install_signal_handler_with_cpp_static_method_call() {
+  if (SIG_ERR == std::signal(SIGTERM, signal_handler_with_cpp_static_method_call))
+return;
+}
+
+
+// Something that does not trigger the check:
+
+extern "C" void c_sig_handler(int sig) {
+#define cbrt(X) _Generic((X), long double \
+ : cbrtl, default \
+ : cbrt)(X)
+  auto char c = '1';
+  extern _Thread_local double _Complex d;
+  static const unsigned long int i = sizeof(float);
+  register short s;
+  void f();
+  volatile struct c_struct {
+enum e {};
+union u;
+  };
+  typedef bool boolean;
+label:
+  switch (c) {
+  case ('1'):
+break;
+  default:
+d = 1.2;
+  }
+  goto label;
+  for (; i < 42;) {
+if (d == 1.2)
+  continue;
+else
+  return;
+  }
+  do {
+_Atomic int v = _Alignof(char);
+_Static_assert(42 == 42, "True");
+  } while (c == 42);
+}
+
+void install_c_sig_handler() {
+  if (SIG_ERR == std::signal(SIGTERM, c_sig_handler)) {
+// Handle error
+  }
+}
+
+extern "C" void signal_handler_with_function_pointer(int sig) {
+  void (*funp) (void);
+  funp = _like;
+  funp();
+}
+
+void install_signal_handler_with_function_pointer() {
+  if (SIG_ERR == std::signal(SIGTERM, signal_handler_with_function_pointer))
+return;
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -22,6 +22,7 @@
cert-flp30-c
cert-msc30-c (redirects to cert-msc50-cpp) 
cert-msc50-cpp
+   cert-msc54-cpp
cert-oop11-cpp (redirects to misc-move-constructor-init) 
cppcoreguidelines-interfaces-global-init
cppcoreguidelines-no-malloc
Index: docs/clang-tidy/checks/cert-msc54-cpp.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cert-msc54-cpp.rst
@@ -0,0 +1,36 @@
+.. title:: clang-tidy - cert-msc54-cpp
+
+cert-msc54-cpp

  1   2   >