[PATCH] D36953: [libclang] Keep track of TranslationUnit instance when annotating tokens

2017-09-21 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added a comment.

Do you need someone to commit this change for you?

I'm happy to do so if you don't have commit access.


https://reviews.llvm.org/D36953



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


[PATCH] D34512: Add preliminary Cross Translation Unit support library

2017-09-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D34512#877032, @dcoughlin wrote:

> I'm OK with this going into the repo a is (although it is light on tests!), 
> as long as we have an agreement that you'll be OK with iteration on both the 
> interface and the implementation to handle real-world projects.


I agree that it could have more tests, but while the main features are already 
tested, more tests are also coming with the first usage of the library (the 
Static Analyzer). We are also willing to add new tests as the interface/library 
evolves.

> More specifically, for this to work well on large/complicated projects we'll 
> need to:
> 
> - Move conflict resolution from index generation where it is now to query 
> time so that clients can pick the best implementation of a function when 
> multiple are found. This is important for projects that have multiple 
> functions with the same name or that build the same file in multiple ways.

I agree. Right now the way we use this internally, the collisions are handled 
after index generation by an external tool (CodeChecker).

> - Change function lookup from needing to traverse over the entire AST.
> - Move away from a linear, flat-file index to something that can handle 
> larger projects more efficiently.
> 
>   For this last point, I suspect it will be good to adopt whatever Clangd 
> ends up using to support indexing. (There has been some discussion of this 
> relatively recently on the cfe-dev list.)

The index right now is a minimal implementation to make this functionality 
work. This part was never the bottleneck according to our measurements so far.  
It would be great to reuse the index format from ClangD in case it supports to 
generate lightweight indexes that only contain the data we need for analysis. 
(We only need an index of function definitions for the analyzer and nothing 
else. I suspect other clients also would not need other information.)

I think it would be a waste of effort to change the lookup strategy or move the 
collision handling mechanisms to index generation until we do not know how the 
index will work. But I also think it wouldn't be good to block this until ClanD 
indexing reaching a mature state.

All in all, we are willing to reuse as much of ClangD indexing as we can in the 
future, but I think it is also more aligned with the LLVM Developer Policy to 
have something working committed and do the development in the repo rather than 
working separately on a fork.


https://reviews.llvm.org/D34512



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


r313866 - [analyzer] Fix an assertion fail in VirtualCallChecker

2017-09-21 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Thu Sep 21 01:18:59 2017
New Revision: 313866

URL: http://llvm.org/viewvc/llvm-project?rev=313866&view=rev
Log:
[analyzer] Fix an assertion fail in VirtualCallChecker

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
cfe/trunk/test/Analysis/virtualcall.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp?rev=313866&r1=313865&r2=313866&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp Thu Sep 21 
01:18:59 2017
@@ -146,7 +146,7 @@ static bool isVirtualCall(const CallExpr
 if (CME->getQualifier())
   CallIsNonVirtual = true;
 
-if (const Expr *Base = CME->getBase()->IgnoreImpCasts()) {
+if (const Expr *Base = CME->getBase()) {
   // The most derived class is marked final.
   if (Base->getBestDynamicClassType()->hasAttr())
 CallIsNonVirtual = true;

Modified: cfe/trunk/test/Analysis/virtualcall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/virtualcall.cpp?rev=313866&r1=313865&r2=313866&view=diff
==
--- cfe/trunk/test/Analysis/virtualcall.cpp (original)
+++ cfe/trunk/test/Analysis/virtualcall.cpp Thu Sep 21 01:18:59 2017
@@ -271,3 +271,24 @@ int main() {
 #if !PUREONLY
//expected-note-re@-2 2^}}Calling '~E'}}
 #endif
+
+namespace PR34451 {
+struct a {
+  void b() {
+a c[1];
+c->b();
+  }
+};
+
+class e {
+ public:
+  void b() const;
+};
+
+class c {
+  void m_fn2() const;
+  e d[];
+};
+
+void c::m_fn2() const { d->b(); }
+}


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


[PATCH] D37978: [analyzer] Fix an assertion fail in VirtualCallChecker

2017-09-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313866: [analyzer] Fix an assertion fail in 
VirtualCallChecker (authored by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D37978?vs=115656&id=116145#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37978

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  cfe/trunk/test/Analysis/virtualcall.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
@@ -146,7 +146,7 @@
 if (CME->getQualifier())
   CallIsNonVirtual = true;
 
-if (const Expr *Base = CME->getBase()->IgnoreImpCasts()) {
+if (const Expr *Base = CME->getBase()) {
   // The most derived class is marked final.
   if (Base->getBestDynamicClassType()->hasAttr())
 CallIsNonVirtual = true;
Index: cfe/trunk/test/Analysis/virtualcall.cpp
===
--- cfe/trunk/test/Analysis/virtualcall.cpp
+++ cfe/trunk/test/Analysis/virtualcall.cpp
@@ -271,3 +271,24 @@
 #if !PUREONLY
//expected-note-re@-2 2^}}Calling '~E'}}
 #endif
+
+namespace PR34451 {
+struct a {
+  void b() {
+a c[1];
+c->b();
+  }
+};
+
+class e {
+ public:
+  void b() const;
+};
+
+class c {
+  void m_fn2() const;
+  e d[];
+};
+
+void c::m_fn2() const { d->b(); }
+}


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
@@ -146,7 +146,7 @@
 if (CME->getQualifier())
   CallIsNonVirtual = true;
 
-if (const Expr *Base = CME->getBase()->IgnoreImpCasts()) {
+if (const Expr *Base = CME->getBase()) {
   // The most derived class is marked final.
   if (Base->getBestDynamicClassType()->hasAttr())
 CallIsNonVirtual = true;
Index: cfe/trunk/test/Analysis/virtualcall.cpp
===
--- cfe/trunk/test/Analysis/virtualcall.cpp
+++ cfe/trunk/test/Analysis/virtualcall.cpp
@@ -271,3 +271,24 @@
 #if !PUREONLY
 	//expected-note-re@-2 2^}}Calling '~E'}}
 #endif
+
+namespace PR34451 {
+struct a {
+  void b() {
+a c[1];
+c->b();
+  }
+};
+
+class e {
+ public:
+  void b() const;
+};
+
+class c {
+  void m_fn2() const;
+  e d[];
+};
+
+void c::m_fn2() const { d->b(); }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37437: [analyzer] Fix some checker's output plist not containing the checker name

2017-09-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Ping.


https://reviews.llvm.org/D37437



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


[PATCH] D38123: [driver] [cl] Add/fix c++17/c++latest

2017-09-21 Thread daxpedda via Phabricator via cfe-commits
daxpedda created this revision.

Current "/std:c++latest" adds "-std=c++17", VS has it's own "/std:c++17" for 
that now.

This is my first commit by the way, please tell me if there is anything I can 
do to improve.
Thanks.


https://reviews.llvm.org/D38123

Files:
  lib/Driver/ToolChains/Clang.cpp


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4060,7 +4060,8 @@
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
   LanguageStandard = llvm::StringSwitch(StdArg->getValue())
  .Case("c++14", "-std=c++14")
- .Case("c++latest", "-std=c++1z")
+ .Case("c++17", "-std=c++17")
+ .Case("c++latest", "-std=c++2a")
  .Default("");
   if (LanguageStandard.empty())
 D.Diag(clang::diag::warn_drv_unused_argument)


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4060,7 +4060,8 @@
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
   LanguageStandard = llvm::StringSwitch(StdArg->getValue())
  .Case("c++14", "-std=c++14")
- .Case("c++latest", "-std=c++1z")
+ .Case("c++17", "-std=c++17")
+ .Case("c++latest", "-std=c++2a")
  .Default("");
   if (LanguageStandard.empty())
 D.Diag(clang::diag::warn_drv_unused_argument)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37963: [analyzer] PthreadLock: Don't track dead regions.

2017-09-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

Maybe it worth a comment why we do not want to clean up `LockSet`?  Otherwise 
LGTM!


https://reviews.llvm.org/D37963



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


[PATCH] D37812: [analyzer] PthreadLock: Escape the pointers.

2017-09-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp:594
+// it takes the mutex explicitly as an argument.
+if (IsLibraryFunction &&
+std::find(ExplicitRegions.begin(), ExplicitRegions.end(), R) ==

Wouldn't it be better to branch on `IsLibraryFunction` and in one branch 
iterate on `Regions` and in the other, iterate on `ExplicitRegions`?
That would avoid the possible quadratic explosion when lots of explicit regions 
are invalidated. 


https://reviews.llvm.org/D37812



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


[PATCH] D38124: Hide some symbols to avoid a crash on shutdown when using code coverage

2017-09-21 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru created this revision.
sylvestre.ledru added a project: clang.

gcov / gcda-based profiling crashes when shared libraries are unloaded

Patch by Benoit Belley and tested by Marco Castelluccio for Firefox

See https://bugs.llvm.org/show_bug.cgi?id=27224 & 
https://bugzilla.mozilla.org/show_bug.cgi?id=1401230


https://reviews.llvm.org/D38124

Files:
  lib/profile/GCDAProfiling.c

Index: lib/profile/GCDAProfiling.c
===
--- lib/profile/GCDAProfiling.c
+++ lib/profile/GCDAProfiling.c
@@ -21,6 +21,7 @@
 \*===--===*/
 
 #include "InstrProfilingUtil.h"
+#include "InstrProfilingPort.h" /* for COMPILER_RT_VISIBILITY */
 
 #include 
 #include 
@@ -251,6 +252,7 @@
  * profiling enabled will emit to a different file. Only one file may be
  * started at a time.
  */
+COMPILER_RT_VISIBILITY
 void llvm_gcda_start_file(const char *orig_filename, const char version[4],
   uint32_t checksum) {
   const char *mode = "r+b";
@@ -318,6 +320,7 @@
 /* Given an array of pointers to counters (counters), increment the n-th one,
  * where we're also given a pointer to n (predecessor).
  */
+COMPILER_RT_VISIBILITY
 void llvm_gcda_increment_indirect_counter(uint32_t *predecessor,
   uint64_t **counters) {
   uint64_t *counter;
@@ -340,6 +343,7 @@
 #endif
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_gcda_emit_function(uint32_t ident, const char *function_name,
  uint32_t func_checksum, uint8_t use_extra_checksum,
  uint32_t cfg_checksum) {
@@ -366,6 +370,7 @@
 write_string(function_name);
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_gcda_emit_arcs(uint32_t num_counters, uint64_t *counters) {
   uint32_t i;
   uint64_t *old_ctrs = NULL;
@@ -417,6 +422,7 @@
 #endif
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_gcda_summary_info() {
   const uint32_t obj_summary_len = 9; /* Length for gcov compatibility. */
   uint32_t i;
@@ -470,6 +476,7 @@
 #endif
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_gcda_end_file() {
   /* Write out EOF record. */
   if (output_file) {
@@ -494,6 +501,7 @@
 #endif
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_register_writeout_function(writeout_fn fn) {
   struct writeout_fn_node *new_node = malloc(sizeof(struct writeout_fn_node));
   new_node->fn = fn;
@@ -507,6 +515,7 @@
   }
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_writeout_files() {
   struct writeout_fn_node *curr = writeout_fn_head;
 
@@ -516,6 +525,7 @@
   }
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_delete_writeout_function_list() {
   while (writeout_fn_head) {
 struct writeout_fn_node *node = writeout_fn_head;
@@ -526,6 +536,7 @@
   writeout_fn_head = writeout_fn_tail = NULL;
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_register_flush_function(flush_fn fn) {
   struct flush_fn_node *new_node = malloc(sizeof(struct flush_fn_node));
   new_node->fn = fn;
@@ -539,6 +550,7 @@
   }
 }
 
+COMPILER_RT_VISIBILITY
 void __gcov_flush() {
   struct flush_fn_node *curr = flush_fn_head;
 
@@ -548,6 +560,7 @@
   }
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_delete_flush_function_list() {
   while (flush_fn_head) {
 struct flush_fn_node *node = flush_fn_head;
@@ -558,6 +571,7 @@
   flush_fn_head = flush_fn_tail = NULL;
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_gcov_init(writeout_fn wfn, flush_fn ffn) {
   static int atexit_ran = 0;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38123: [driver] [cl] Add/fix c++17/c++latest

2017-09-21 Thread daxpedda via Phabricator via cfe-commits
daxpedda updated this revision to Diff 116154.
daxpedda added a comment.

Discovered that these flags were tested and added new test.


https://reviews.llvm.org/D38123

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/cl-options.c


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -517,8 +517,11 @@
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++14 -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXX14 %s
 // STDCXX14: -std=c++14
 
+// RUN: %clang_cl -fmsc-version=1900 -TP -std:c++17 -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXX17 %s
+// STDCXX14: -std=c++17
+
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest -### -- %s 2>&1 | 
FileCheck -check-prefix=STDCXXLATEST %s
-// STDCXXLATEST: -std=c++1z
+// STDCXXLATEST: -std=c++2a
 
 // RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck 
-check-prefix=ENV-CL %s
 // ENV-CL: "-ffunction-sections"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4062,7 +4062,8 @@
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
   LanguageStandard = llvm::StringSwitch(StdArg->getValue())
  .Case("c++14", "-std=c++14")
- .Case("c++latest", "-std=c++1z")
+ .Case("c++17", "-std=c++17")
+ .Case("c++latest", "-std=c++2a")
  .Default("");
   if (LanguageStandard.empty())
 D.Diag(clang::diag::warn_drv_unused_argument)


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -517,8 +517,11 @@
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++14 -### -- %s 2>&1 | FileCheck -check-prefix=STDCXX14 %s
 // STDCXX14: -std=c++14
 
+// RUN: %clang_cl -fmsc-version=1900 -TP -std:c++17 -### -- %s 2>&1 | FileCheck -check-prefix=STDCXX17 %s
+// STDCXX14: -std=c++17
+
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest -### -- %s 2>&1 | FileCheck -check-prefix=STDCXXLATEST %s
-// STDCXXLATEST: -std=c++1z
+// STDCXXLATEST: -std=c++2a
 
 // RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=ENV-CL %s
 // ENV-CL: "-ffunction-sections"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4062,7 +4062,8 @@
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
   LanguageStandard = llvm::StringSwitch(StdArg->getValue())
  .Case("c++14", "-std=c++14")
- .Case("c++latest", "-std=c++1z")
+ .Case("c++17", "-std=c++17")
+ .Case("c++latest", "-std=c++2a")
  .Default("");
   if (LanguageStandard.empty())
 D.Diag(clang::diag::warn_drv_unused_argument)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36953: [libclang] Keep track of TranslationUnit instance when annotating tokens

2017-09-21 Thread Johann Klähn via Phabricator via cfe-commits
jklaehn added a comment.

In https://reviews.llvm.org/D36953#877367, @jbcoe wrote:

> Do you need someone to commit this change for you?
>
> I'm happy to do so if you don't have commit access.


Yes that would be great, thanks!


https://reviews.llvm.org/D36953



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


[PATCH] D35743: [clang-format] Adjust space around &/&& of structured bindings

2017-09-21 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

Apart from nits, LGTM, unless Daniel sees issues.




Comment at: lib/Format/TokenAnnotator.cpp:2516
 return Style.SpacesInAngles;
+  // space before TT_StructuredBindingLSquare
+  if (Right.is(TT_StructuredBindingLSquare))

Super-Nit: can you start with a capital letter and end with a '.'?



Comment at: unittests/Format/FormatTest.cpp:11604-11610
+  verifyFormat("auto const &&x1 = y1;", getGoogleStyle());
+  verifyFormat("auto const &&x2 = y1;", getLLVMStyle());
+  verifyFormat("auto const &x1 = y2;", getGoogleStyle());
+  verifyFormat("auto const &x2 = y2;", getLLVMStyle());
+  verifyFormat("auto const &x1 = y2;", getGoogleStyle());
+  verifyFormat("auto const *x1, *x2;", getGoogleStyle());
+  verifyFormat("auto const *x3, *x4;", getLLVMStyle());

I don't think the non-structured-binding tests are necessary here, as they're 
testing something completely different?


https://reviews.llvm.org/D35743



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


[PATCH] D35743: [clang-format] Adjust space around &/&& of structured bindings

2017-09-21 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Could you add just one more test for `PAS_Middle` please? A single line will be 
just enough.
Otherwise, LGTM.


https://reviews.llvm.org/D35743



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


[PATCH] D37554: [libclang] Allow crash recovery with LIBCLANG_NOTHREADS

2017-09-21 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

ping 3


https://reviews.llvm.org/D37554



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


[PATCH] D37554: [libclang] Allow crash recovery with LIBCLANG_NOTHREADS

2017-09-21 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a reviewer: akyrtzi.
klimek added a comment.

Adding Argyrios, who might have insight on how this is used.
I think this had the wrong list of reviewers so far :(


https://reviews.llvm.org/D37554



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


[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI

2017-09-21 Thread Christian Bruel via Phabricator via cfe-commits
chrib added a comment.

Hello,

I didn't find an easy way factorize the change in IsUnwindTableDefault to 
support the multiple ARM toolchains. After a quick check in Triple::arm in 
Driver/Toochains, many seem impacted (excepted NetBSD and Darwin that uses 
DwarfCFI or SJLG).  So here is an attempt to move this into a small arm hook 
and use.

Also, I realized that the cxx tests was not correctly checked because most of 
them are invoked as "clang" instead if "clang++" So another proposal is to 
check the input type in  IsUnwindTablesDefault.

Finally  I've added the clang  tests to check for this.

thanks !


https://reviews.llvm.org/D31140



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


[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI

2017-09-21 Thread Christian Bruel via Phabricator via cfe-commits
chrib updated this revision to Diff 116176.
chrib added a comment.
Herald added a subscriber: javed.absar.

Changes since last revision:

- Check IsUnwindTablesDefault in ARM Toolchains that support 
ExceptionHandling::ARM (not Darwin, NetBSD)
- Check input type with driver mode for C++ mode.
- Add Tests


https://reviews.llvm.org/D31140

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Arch/ARM.cpp
  lib/Driver/ToolChains/Arch/ARM.h
  lib/Driver/ToolChains/BareMetal.cpp
  lib/Driver/ToolChains/BareMetal.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/CrossWindows.cpp
  lib/Driver/ToolChains/CrossWindows.h
  lib/Driver/ToolChains/Darwin.cpp
  lib/Driver/ToolChains/Darwin.h
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Gnu.h
  lib/Driver/ToolChains/MSVC.cpp
  lib/Driver/ToolChains/MSVC.h
  lib/Driver/ToolChains/MinGW.cpp
  lib/Driver/ToolChains/MinGW.h
  lib/Driver/ToolChains/NetBSD.h
  test/Driver/arm-unwind.c
  test/Driver/arm-unwind.cpp

Index: test/Driver/arm-unwind.cpp
===
--- /dev/null
+++ test/Driver/arm-unwind.cpp
@@ -0,0 +1,9 @@
+// Add function attribute "uwtable" for arm ehabi targets in C++.
+
+// RUN: %clang -target arm-none-eabi  -### -S %s -o %t.s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK-EABI %s
+// CHECK-EABI: -munwind-tables
+
+// RUN: %clang -target arm-none-eabi  -### -S %s -o %t.s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK-GNU %s
+// CHECK-GNU: -munwind-tables
Index: test/Driver/arm-unwind.c
===
--- /dev/null
+++ test/Driver/arm-unwind.c
@@ -0,0 +1,9 @@
+// Do not add function attribute "uwtable" for arm ehabi targets for C mode.
+
+// RUN: %clang -target arm-none-eabi  -### -S %s -o %t.s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-EABI %s
+// CHECK-EABI-NOT: -munwind-tables
+
+// RUN: %clang -target arm--linux-gnueabihf -### -S %s -o %t.s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-GNU %s
+// CHECK-GNU-NOT: -munwind-tables
Index: lib/Driver/ToolChains/NetBSD.h
===
--- lib/Driver/ToolChains/NetBSD.h
+++ lib/Driver/ToolChains/NetBSD.h
@@ -65,7 +65,7 @@
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
 
-  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override {
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, bool isCXX) const override {
 return true;
   }
 
Index: lib/Driver/ToolChains/MinGW.h
===
--- lib/Driver/ToolChains/MinGW.h
+++ lib/Driver/ToolChains/MinGW.h
@@ -60,7 +60,7 @@
 const llvm::opt::ArgList &Args);
 
   bool IsIntegratedAssemblerDefault() const override;
-  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, bool isCXX) const override;
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "MinGW.h"
+#include "Arch/ARM.h"
 #include "InputInfo.h"
 #include "CommonArgs.h"
 #include "clang/Driver/Compilation.h"
@@ -358,8 +359,19 @@
   return new tools::MinGW::Linker(*this);
 }
 
-bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args) const {
-  return getArch() == llvm::Triple::x86_64;
+bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args, bool isCXX) const {
+  // Unwind tables are emitted when targeting x86_64 and ARM for C++ or -fexceptions).
+  switch (getArch()) {
+  case llvm::Triple::arm:
+  case llvm::Triple::armeb:
+  case llvm::Triple::thumb:
+  case llvm::Triple::thumbeb:
+return tools::arm::ARMNeedUnwindTable(Args, isCXX);
+  case llvm::Triple::x86_64:
+return true;
+  default:
+return false;
+  }
 }
 
 bool toolchains::MinGW::isPICDefault() const {
Index: lib/Driver/ToolChains/MSVC.h
===
--- lib/Driver/ToolChains/MSVC.h
+++ lib/Driver/ToolChains/MSVC.h
@@ -73,7 +73,7 @@
 Action::OffloadKind DeviceOffloadKind) const override;
 
   bool IsIntegratedAssemblerDefault() const override;
-  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, bool isCXX) const override;
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
Index: lib/Driver/ToolChains/MSVC.cpp
===
-

r313880 - [OPENMP] Use canonical declarations for redeclarations checks.

2017-09-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Sep 21 07:06:59 2017
New Revision: 313880

URL: http://llvm.org/viewvc/llvm-project?rev=313880&view=rev
Log:
[OPENMP] Use canonical declarations for redeclarations checks.

If the captured variable has some redeclarations we may run into the
situation where the redeclaration is used instead of the canonical
declaration and we may consider this variable as one not captured
before.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=313880&r1=313879&r2=313880&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Sep 21 07:06:59 2017
@@ -1130,6 +1130,7 @@ bool Sema::IsOpenMPCapturedByRef(ValueDe
   bool IsByRef = true;
 
   // Find the directive that is associated with the provided scope.
+  D = cast(D->getCanonicalDecl());
   auto Ty = D->getType();
 
   if (DSAStack->hasExplicitDirective(isOpenMPTargetExecutionDirective, Level)) 
{
@@ -1787,6 +1788,7 @@ class DSAAttrChecker : public StmtVisito
   CapturedStmt *CS;
   llvm::SmallVector ImplicitFirstprivate;
   llvm::DenseMap VarsWithInheritedDSA;
+  llvm::DenseSet ImplicitDeclarations;
 
 public:
   void VisitDeclRefExpr(DeclRefExpr *E) {
@@ -1794,13 +1796,14 @@ public:
 E->containsUnexpandedParameterPack() || E->isInstantiationDependent())
   return;
 if (auto *VD = dyn_cast(E->getDecl())) {
+  VD = VD->getCanonicalDecl();
   // Skip internally declared variables.
   if (VD->isLocalVarDecl() && !CS->capturesVariable(VD))
 return;
 
   auto DVar = Stack->getTopDSA(VD, false);
   // Check if the variable has explicit DSA set and stop analysis if it so.
-  if (DVar.RefExpr)
+  if (DVar.RefExpr || !ImplicitDeclarations.insert(VD).second)
 return;
 
   auto ELoc = E->getExprLoc();
@@ -1850,7 +1853,7 @@ public:
 auto DVar = Stack->getTopDSA(FD, false);
 // Check if the variable has explicit DSA set and stop analysis if it
 // so.
-if (DVar.RefExpr)
+if (DVar.RefExpr || !ImplicitDeclarations.insert(FD).second)
   return;
 
 auto ELoc = E->getExprLoc();
@@ -2617,7 +2620,7 @@ StmtResult Sema::ActOnOpenMPExecutableDi
   llvm::DenseMap VarsWithInheritedDSA;
   bool ErrorFound = false;
   ClausesWithImplicit.append(Clauses.begin(), Clauses.end());
-  if (AStmt) {
+  if (AStmt && !CurContext->isDependentContext()) {
 assert(isa(AStmt) && "Captured statement expected");
 
 // Check default data sharing attributes for referenced variables.

Modified: cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp?rev=313880&r1=313879&r2=313880&view=diff
==
--- cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp Thu Sep 21 
07:06:59 2017
@@ -295,9 +295,9 @@ int main(int argc, char **argv) {
 #pragma omp taskloop firstprivate(i) // expected-note {{defined as 
firstprivate}}
   for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in 
the associated loop of 'omp taskloop' directive may not be firstprivate, 
predetermined as private}}
 foo();
-#pragma omp parallel reduction(+ : i) // expected-note 4 {{defined as 
reduction}}
+#pragma omp parallel reduction(+ : i) // expected-note 2 {{defined as 
reduction}}
 #pragma omp taskloop firstprivate(i) //expected-error {{argument of a 
reduction clause of a parallel construct must not appear in a firstprivate 
clause on a task construct}}
-  for (i = 0; i < argc; ++i) // expected-error 3 {{reduction variables may not 
be accessed in an explicit task}}
+  for (i = 0; i < argc; ++i) // expected-error {{reduction variables may not 
be accessed in an explicit task}}
 foo();
 #pragma omp parallel
 #pragma omp taskloop firstprivate(B::x) // expected-error {{threadprivate or 
thread local variable cannot be firstprivate}}

Modified: cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp?rev=313880&r1=313879&r2=313880&view=diff
==
--- cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp Thu Sep 21 
07:06:59 2017
@@ -295,9 +295,9 @@ int main(int argc, char **argv) {
 #pragma omp taskloop simd firstprivate(i) // expected-note {{defined as 
firstprivate}}
   for (i = 0; i < argc; ++i) // expec

[PATCH] D37822: [OpenCL] Clean up and add missing fields for block struct

2017-09-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 4 inline comments as done.
yaxunl added a comment.

In https://reviews.llvm.org/D37822#873876, @Anastasia wrote:

> In https://reviews.llvm.org/D37822#872446, @yaxunl wrote:
>
> > In https://reviews.llvm.org/D37822#872291, @Anastasia wrote:
> >
> > > Could you please explain a bit more why the alignment have to be put 
> > > explicitly in the struct? I am just not very convinced this is general 
> > > enough.
> >
> >
> > The captured variables are fields of the block literal struct. Due to 
> > alignment requirement of these fields, there is alignment requirement of
> >  the block literal struct. The ISA of the block invoke function is 
> > generated with the assumption of these alignments. If the block literal is
> >  allocated at a memory address not satisfying the alignment requirement, 
> > the kernel behavior is undefined.
> >
> > Generally, __enqueue_kernel library function needs to prepare the kernel 
> > argument before launching the kernel. It usually does this by copying
> >  the block literal to some buffer then pass the address of the buffer to 
> > the kernel. Then the address of the buffer has to satisfy the alignment
> >  requirement.
> >
> > If this block literal struct is not general enough, how about add another 
> > field as target reserved size, and leave the remaining space of header for
> >  target specific use. And add a target hook to allow target fill the 
> > reserved space, e.g.
> >
> >   struct __opencl_block_literal {
> > int total_size;
> > int align;
> > __generic void *invoke;
> > int target_reserved_size; /* round up to 4 bytes */
> > int target_reserved[];
> > /* captures */
> >   };
> >
>
>
> I like the idea of the target reserved part actually. But not sure how it 
> could be used without adding any target specific methods?


If we decide to add target reserved fields, I can add target hooks to fill 
these fields. However I would suggest to leave this for future since I don't 
see there is need for other fields for now.

> However, I am still not clear why the alignment of this struct has to be 
> different from any other struct Clang produces. Normally the alignment of 
> objects have to be known during IR generation to put them correctly in the 
> attributes of generated alloca, store and loads. But as a field inside struct 
> I don't know how it can be useful. I would imagine `enqueue_kernel` would 
> just operate on the block as if it would be an arbitrary buffer of data. Also 
> would size of the struct not account for any padding to make sure the 
> alignment can be deduced based on it correctly?

enqueue_kernel needs to pass the block struct to the kernel. Let's assume it 
does this by copying the block struct to a buffer. If enqueue_kernel does not 
know the alignment of the struct, it can only put it at an arbitrary address in 
the buffer. Then the kernel has to copy the struct to an aligned private memory 
and load the fields. However, if the enqueued_kernel knows the alignment of the 
struct, it can put it at an address satisfying the alignment. Then the kernel 
can load the fields directly from the buffer, skips the step of copying to an 
aligned private memory. Therefore, alignment of the block struct is usually a 
useful information for enqueue_kernel. I think that's why in the SPIRV spec 
OpEnqueueKernel requires an alignment operand for the block context.




Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:108
+llvm::PointerType *CGOpenCLRuntime::getGenericVoidPointerType() {
+  return llvm::IntegerType::getInt8PtrTy(
+  CGM.getLLVMContext(),

Anastasia wrote:
> Should we put an assert of LangOpts.OpenCL?
Will do.



Comment at: test/CodeGen/blocks-opencl.cl:1
 // RUN: %clang_cc1 -O0 %s -ffake-address-space-map -emit-llvm -o - -fblocks 
-triple x86_64-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 -O0 %s -emit-llvm -o - -fblocks -triple amdgcn | FileCheck 
%s

Anastasia wrote:
> Btw, do you think we need this test any more? And if yes, could this be moved 
> to CodeGenOpenCL?
I think this one can be removed since what it tests is covered by 
CodeGenOpenCL/blocks.cl.


https://reviews.llvm.org/D37822



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


[PATCH] D38134: [OpenCL] Emit enqueued block as kernel

2017-09-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
Herald added a subscriber: nhaehnle.

In OpenCL the kernel function and non-kernel function has different calling 
conventions.
For certain targets they have different argument ABIs. Also kernels have 
special function
attributes and metadata for runtime to launch them.

The blocks passed to enqueue_kernel is supposed to be executed as kernels. As 
such,
the block invoke function should be emitted as kernel with proper calling 
convention,
argument ABI, function attributes and metadata.

However, currently Clang does not emit enqueued blocks as kernels, which causes 
issues
such as address space of captured variables.

This patch emits enqueued block as kernel. If a block is both called directly 
and passed
to enqueue_kernel, separate functions will be generated.


https://reviews.llvm.org/D38134

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBlocks.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenTypes.h
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
  test/CodeGenOpenCL/blocks.cl
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -6,10 +6,33 @@
 typedef void (^bl_t)(local void *);
 typedef struct {int a;} ndrange_t;
 
-// N.B. The check here only exists to set BL_GLOBAL
-// COMMON: @block_G =  addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL:@__block_literal_global(\.[0-9]+)?]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*)
+// COMMON: %struct.__opencl_block_literal_generic = type { i32, i32, i8 addrspace(4)* }
+
+// For a block global variable, first emit the block literal as a global variable, then emit the block variable itself.
+// COMMON: [[BL_GLOBAL:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*, i8 addrspace(3)*)* [[INV_G:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: @block_G =  addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*)
+
+// For anonymous blocks without captures, emit block literals as global variable.
+// COMMON: [[BLG1:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(1)*, i8 addrspace(3)*)* [[INVG1:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG2:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(1)*, i8 addrspace(3)*)* [[INVG2:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG3:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(1)*, i8 addrspace(3)*)* [[INVG3:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG4:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(1)*, i8 addrspace(3)*)* [[INVG4:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG5:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(1)*, i8 addrspace(3)*)* [[INVG5:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG6:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(1)*, i8 addrspace(3)*, i8 addrspace(3)*, i8 addrspace(3)*)* [[INVG6:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG7:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i32, i32, i8 addrspace(4)* } { i32 {{[0-9]+}}, i32 {{[0-9]+}}, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(1)*, i8 addrspace(3)*)* [[INVG7:@[^ ]+]] to i8*) to i8 addrspace(4)*) }
+// COMMON: [[BLG8:@__block_literal_global[^ ]*]] = internal addrspace(1) constant { i

[PATCH] D37263: [clang-format] Ignore case and stable sort using-declarations

2017-09-21 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, thanks!


https://reviews.llvm.org/D37263



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


[PATCH] D38123: [driver] [cl] Add/fix c++17/c++latest

2017-09-21 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

LGTM

we should probably set c++17 as the default over c++14 as part of this change.
given that everything seems in order for c++17 bar P0522R0 so this looks like 
the change should be good.
adding @rnk to confirm.

@daxpedda do you have commit access?




Comment at: test/Driver/cl-options.c:514
 
 // RUN: %clang_cl -fmsc-version=1900 -TP -### -- %s 2>&1 | FileCheck 
-check-prefix=CXX14 %s
 // CXX14: -std=c++14

We should probably change the default to c++17 as part of this commit.


https://reviews.llvm.org/D38123



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


[PATCH] D38123: [driver] [cl] Add/fix c++17/c++latest

2017-09-21 Thread daxpedda via Phabricator via cfe-commits
daxpedda added a comment.

According to this 

 the default is still c++14.
I do not have commit access, I would prefer if somebody else commits this in my 
stead.




Comment at: test/Driver/cl-options.c:514
 
 // RUN: %clang_cl -fmsc-version=1900 -TP -### -- %s 2>&1 | FileCheck 
-check-prefix=CXX14 %s
 // CXX14: -std=c++14

martell wrote:
> We should probably change the default to c++17 as part of this commit.
According to [[ 
https://docs.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version
 | this ]] the default is still c++14.


https://reviews.llvm.org/D38123



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


[PATCH] D20689: [clang-tidy] Suspicious Call Argument checker

2017-09-21 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D20689#871947, @barancsuk wrote:

> @alexfh, would you mind taking a look at the changes that have been 
> introduced in the new patch?
>
> The main improvements are:
>
>   - The checker has been shifted to the module `readability`.
>   - It is checked, whether implicit type conversion is possible from the 
> argument to the parameter.
>
> I have run the modified checker on some large code bases with the 
> following results: (The errors were categorized subjectively.)
> - **PostgreSQL:** 32 renaming opportunities of 39 warnings
> - **Cpython:** 10 renaming opportunities of 15 warnings
> - **Xerces:** 6 renaming opportunities of 8 warnings
> - **FFmpeg**:  5 renaming opportunities of 9 warnings
> - **OpenSSL:** 3 renaming opportunities of 4 warnings
> - **LLVM:** 20 renaming opportunities of 44 warnings


Is there a list of all the warnings? I'd like to take a closer look.

> This article provides some evidence to support the feasibility of the checker 
> as well. 
>  F5358417: icse2016-names.pdf  
>  The authors have proven that argument names are generally very similar to 
> the corresponding parameters' names. 
>  The presented empirical evidence also shows, that argument and parameter 
> name dissimilarities are strong indicators of incorrect argument usages, or 
> they identify renaming opportunities to improve code readability. 
>  Moreover, the authors have even found 3 existing bugs in open source 
> projects.




https://reviews.llvm.org/D20689



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


[PATCH] D38123: [driver] [cl] Add/fix c++17/c++latest

2017-09-21 Thread Martell Malone via Phabricator via cfe-commits
martell accepted this revision.
martell added a comment.
This revision is now accepted and ready to land.

It seems that msvc enabled some c++17 features when in c++14 mode and they left 
them enabled because projects became dependant on them.
switching to c++17 as the default and removing the c++17 features from c++14 
mode seems like the correct thing to do here even if MS still use c++14 as 
their default.
That should be part of a different patch though because a discussion needs to 
be had on that issue.

LGTM as is.
Thanks for the contribution.


https://reviews.llvm.org/D38123



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


[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-09-21 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

> The metric is implemented as per COGNITIVE COMPLEXITY by SonarSource 
> specification version 1.2 (19 April 2017),

Err, "I did ask them, and received an answer that it is it can be implemented 
in clang-tidy" might not be enough.


Repository:
  rL LLVM

https://reviews.llvm.org/D36836



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


[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-09-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D36836#877636, @alexfh wrote:

> > The metric is implemented as per COGNITIVE COMPLEXITY by SonarSource 
> > specification version 1.2 (19 April 2017),
>
> Err, "I did ask them, and received an answer that it is it can be implemented 
> in clang-tidy" might not be enough.


F5372479: original_msg.txt 

  Hello Roman,
  
  It would not, and I would be happy to be notified once done.
  
  Thanks
  
  Olivier
  
  > On Fri, Jul 28, 2017 at 6:17 PM Roman Lebedev  wrote:
  > Hi.
  > 
  > I would like to know, what is the legal status of
  > https://www.sonarsource.com/docs/CognitiveComplexity.pdf ?
  > 
  > If i (or someone else) is to implement the Specification described in
  > that paper,
  > which will produce the same results as the Cognitive Complexity in 
SonarSource
  > as part of some other static analyzer, for example as a LLVM's clang-tidy 
check,
  > would that be illegal thing to do?
  > 
  > Roman.
  -- 
  Olivier Gaudin | SonarSource
  CEO & Co-Founder
  +41 (0)22 510 2424
  http://sonarsource.com

Might not be enough?


Repository:
  rL LLVM

https://reviews.llvm.org/D36836



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


[PATCH] D34512: Add preliminary Cross Translation Unit support library

2017-09-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 116195.
xazax.hun added a comment.

- Unittests now creates temporary files at the correct location
- Temporary files are also cleaned up when the process is terminated
- Absolute paths are handled correctly by the library


https://reviews.llvm.org/D34512

Files:
  include/clang/Basic/AllDiagnostics.h
  include/clang/Basic/CMakeLists.txt
  include/clang/Basic/Diagnostic.td
  include/clang/Basic/DiagnosticCrossTUKinds.td
  include/clang/Basic/DiagnosticIDs.h
  include/clang/CrossTU/CrossTUDiagnostic.h
  include/clang/CrossTU/CrossTranslationUnit.h
  lib/AST/ASTImporter.cpp
  lib/Basic/DiagnosticIDs.cpp
  lib/CMakeLists.txt
  lib/CrossTU/CMakeLists.txt
  lib/CrossTU/CrossTranslationUnit.cpp
  test/Analysis/func-mapping-test.cpp
  test/CMakeLists.txt
  test/lit.cfg
  tools/CMakeLists.txt
  tools/clang-func-mapping/CMakeLists.txt
  tools/clang-func-mapping/ClangFnMapGen.cpp
  tools/diagtool/DiagnosticNames.cpp
  unittests/CMakeLists.txt
  unittests/CrossTU/CMakeLists.txt
  unittests/CrossTU/CrossTranslationUnitTest.cpp

Index: unittests/CrossTU/CrossTranslationUnitTest.cpp
===
--- /dev/null
+++ unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -0,0 +1,138 @@
+//===- unittest/Tooling/CrossTranslationUnitTest.cpp - Tooling unit tests -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/CrossTU/CrossTranslationUnit.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Config/llvm-config.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/ToolOutputFile.h"
+#include "gtest/gtest.h"
+#include 
+
+namespace clang {
+namespace cross_tu {
+
+namespace {
+
+class CTUASTConsumer : public clang::ASTConsumer {
+public:
+  explicit CTUASTConsumer(clang::CompilerInstance &CI, bool *Success)
+  : CTU(CI), Success(Success) {}
+
+  void HandleTranslationUnit(ASTContext &Ctx) {
+const TranslationUnitDecl *TU = Ctx.getTranslationUnitDecl();
+const FunctionDecl *FD = nullptr;
+for (const Decl *D : TU->decls()) {
+  FD = dyn_cast(D);
+  if (FD && FD->getName() == "f")
+break;
+}
+assert(FD && FD->getName() == "f");
+bool OrigFDHasBody = FD->hasBody();
+
+// Prepare the index file and the AST file.
+int ASTFD;
+llvm::SmallString<256> ASTFileName;
+ASSERT_FALSE(
+llvm::sys::fs::createTemporaryFile("f_ast", "ast", ASTFD, ASTFileName));
+llvm::tool_output_file ASTFile(ASTFileName, ASTFD);
+
+int IndexFD;
+llvm::SmallString<256> IndexFileName;
+ASSERT_FALSE(llvm::sys::fs::createTemporaryFile("index", "txt", IndexFD,
+IndexFileName));
+llvm::tool_output_file IndexFile(IndexFileName, IndexFD);
+IndexFile.os() << "c:@F@f#I# " << ASTFileName << "\n";
+IndexFile.os().flush();
+EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
+
+StringRef SourceText = "int f(int) { return 0; }\n";
+// This file must exist since the saved ASTFile will reference it.
+int SourceFD;
+llvm::SmallString<256> SourceFileName;
+ASSERT_FALSE(llvm::sys::fs::createTemporaryFile("input", "cpp", SourceFD,
+SourceFileName));
+llvm::tool_output_file SourceFile(SourceFileName, SourceFD);
+SourceFile.os() << SourceText;
+SourceFile.os().flush();
+EXPECT_TRUE(llvm::sys::fs::exists(SourceFileName));
+
+std::unique_ptr ASTWithDefinition =
+tooling::buildASTFromCode(SourceText, SourceFileName);
+ASTWithDefinition->Save(ASTFileName.str());
+EXPECT_TRUE(llvm::sys::fs::exists(ASTFileName));
+
+// Load the definition from the AST file.
+llvm::Expected NewFDorError =
+CTU.getCrossTUDefinition(FD, "", IndexFileName);
+EXPECT_TRUE((bool)NewFDorError);
+const FunctionDecl *NewFD = *NewFDorError;
+
+*Success = NewFD && NewFD->hasBody() && !OrigFDHasBody;
+  }
+
+private:
+  CrossTranslationUnitContext CTU;
+  bool *Success;
+};
+
+class CTUAction : public clang::ASTFrontendAction {
+public:
+  CTUAction(bool *Success) : Success(Success) {}
+
+protected:
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &CI, StringRef) override {
+return llvm::make_unique(CI, Success);
+  }
+
+private:
+  bool *Success;
+};
+
+} // end namespace
+
+TEST(CrossTranslationUnit, CanLoadFunctionDefinition) {
+  bool Success = false;
+  EXPECT_TRUE(tooling::runToolOnCode(new CTUAction(&Success), "int f(int);"));
+  EXPECT_TRUE(Success);
+}
+
+TEST(CrossTranslationUnit, IndexFormatCanBeParsed) {
+  llvm::StringMap Index;
+  Index["a"] = "b";
+  Inde

[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path

2017-09-21 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 116198.
Nebiroth added a comment.

More consistent logging in clangdmain.
Restructured argument checking in ClangdMain
Fixed empty compile-commands-dir triggering error messages.
Fixed failing standard tests.


https://reviews.llvm.org/D37150

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/tool/ClangdMain.cpp

Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -11,16 +11,24 @@
 #include "JSONRPCDispatcher.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
-
 #include 
 #include 
 #include 
 #include 
+#include 
 
 using namespace clang;
 using namespace clang::clangd;
 
+static llvm::cl::opt CompileCommandsDir(
+"compile-commands-dir",
+llvm::cl::desc("Specify a path to look for compile_commands.json. If path "
+   "is invalid, clangd will look in the current directory and "
+   "parent paths of each source file."));
+
+
 static llvm::cl::opt
 WorkerThreadsCount("j",
llvm::cl::desc("Number of async workers used by clangd"),
@@ -56,18 +64,44 @@
   if (RunSynchronously)
 WorkerThreadsCount = 0;
 
+  /// Validate command line arguments.
   llvm::raw_ostream &Outs = llvm::outs();
   llvm::raw_ostream &Logs = llvm::errs();
-  JSONOutput Out(Outs, Logs);
+  JSONOutput Out(Outs, Logs);  
 
-  // Change stdin to binary to not lose \r\n on windows.
-  llvm::sys::ChangeStdinToBinary();
+  // If --compile-commands-dir arg was invoked, check value and override default
+  // path.
+  namespace path = llvm::sys::path;
+  llvm::Optional CompileCommandsDirPath;
+
+  if (CompileCommandsDir.empty())
+CompileCommandsDirPath = llvm::None;
+  else
+  {
+if (!llvm::sys::path::is_absolute(CompileCommandsDir)) {
+  llvm::errs() << "Path specified by --compile-commands-dir must be an absolute "
+  "path. The argument will be ignored.\n";
+  CompileCommandsDir = "";
+}
+
+if (!llvm::sys::fs::exists(CompileCommandsDir)) {
+  llvm::errs() << "Path specified by --compile-commands-dir does not exist. The argument will be "
+  "ignored.\n";
+  CompileCommandsDir = "";
+}
+CompileCommandsDirPath = CompileCommandsDir;
+  }  
 
   llvm::Optional ResourceDirRef = None;
   if (!ResourceDir.empty())
 ResourceDirRef = ResourceDir;
 
+  /// Change stdin to binary to not lose \r\n on windows.
+  llvm::sys::ChangeStdinToBinary();  
+
+  /// Initialize and run ClangdLSPServer.
+
   ClangdLSPServer LSPServer(Out, WorkerThreadsCount, EnableSnippets,
-ResourceDirRef);
+ResourceDirRef, CompileCommandsDirPath);
   LSPServer.run(std::cin);
 }
Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -45,14 +45,19 @@
 class DirectoryBasedGlobalCompilationDatabase
 : public GlobalCompilationDatabase {
 public:
+  DirectoryBasedGlobalCompilationDatabase(
+  llvm::Optional NewCompileCommandsDir)
+  : CompileCommandsDir(NewCompileCommandsDir) {}
   std::vector
   getCompileCommands(PathRef File) override;
 
   void setExtraFlagsForFile(PathRef File, std::vector ExtraFlags);
 
 private:
-  tooling::CompilationDatabase *getCompilationDatabase(PathRef File);
+  tooling::CompilationDatabase *getCompilationDatabase(PathRef File);  
+  tooling::CompilationDatabase *tryLoadDatabaseFromPath(PathRef File);
 
+  llvm::Optional CompileCommandsDir;
   std::mutex Mutex;
   /// Caches compilation databases loaded from directories(keys are
   /// directories).
Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -62,43 +62,54 @@
 }
 
 tooling::CompilationDatabase *
-DirectoryBasedGlobalCompilationDatabase::getCompilationDatabase(PathRef File) {
-  std::lock_guard Lock(Mutex);
-
+DirectoryBasedGlobalCompilationDatabase::tryLoadDatabaseFromPath(PathRef File) {
+  
   namespace path = llvm::sys::path;
+  auto CachedIt = CompilationDatabases.find(File);
+  std::string Error = "";
 
   assert((path::is_absolute(File, path::Style::posix) ||
   path::is_absolute(File, path::Style::windows)) &&
  "path must be absolute");
 
-  for (auto Path = path::parent_path(File); !Path.empty();
-   Path = path::parent_path(Path)) {
-
-auto CachedIt = CompilationDatabases.find(Path);
-if (CachedIt != CompilationDatabases.end())
-  return CachedIt->second.get();
-std::string Error;
-auto CDB = tooling::CompilationDatabase::loadFromDir

[PATCH] D35743: [clang-format] Adjust space around &/&& of structured bindings

2017-09-21 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 116201.
chh marked 2 inline comments as done.
chh edited the summary of this revision.

https://reviews.llvm.org/D35743

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11579,24 +11579,59 @@
   EXPECT_EQ("auto const volatile [a, b] = f();",
 format("auto  const   volatile[a, b] = f();"));
   EXPECT_EQ("auto [a, b, c] = f();", format("auto   [  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto & [a, b, c] = f();",
+  EXPECT_EQ("auto &[a, b, c] = f();",
 format("auto   &[  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto && [a, b, c] = f();",
+  EXPECT_EQ("auto &&[a, b, c] = f();",
 format("auto   &&[  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto const & [a, b] = f();", format("auto  const&[a, b] = f();"));
-  EXPECT_EQ("auto const volatile && [a, b] = f();",
+  EXPECT_EQ("auto const &[a, b] = f();", format("auto  const&[a, b] = f();"));
+  EXPECT_EQ("auto const volatile &&[a, b] = f();",
 format("auto  const  volatile  &&[a, b] = f();"));
-  EXPECT_EQ("auto && [a, b] = f();", format("auto  &&[a, b] = f();"));
+  EXPECT_EQ("auto const &&[a, b] = f();", format("auto  const   &&  [a, b] = f();"));
+  EXPECT_EQ("const auto &[a, b] = f();", format("const  auto  &  [a, b] = f();"));
+  EXPECT_EQ("const auto volatile &&[a, b] = f();",
+format("const  auto   volatile  &&[a, b] = f();"));
+  EXPECT_EQ("volatile const auto &&[a, b] = f();",
+format("volatile  const  auto   &&[a, b] = f();"));
+  EXPECT_EQ("const auto &&[a, b] = f();", format("const  auto  &&  [a, b] = f();"));
 
   // Make sure we don't mistake structured bindings for lambdas.
-  verifyFormat("auto [a, b]{A * i};");
-  verifyFormat("auto const [a, b]{A * i};");
-  verifyFormat("auto const && [a, b]{A * i};");
+  FormatStyle PointerMiddle = getLLVMStyle();
+  PointerMiddle.PointerAlignment = FormatStyle::PAS_Middle;
+  verifyFormat("auto [a1, b]{A * i};", getGoogleStyle());
+  verifyFormat("auto [a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto [a3, b]{A * i};", PointerMiddle);
+  verifyFormat("auto const [a1, b]{A * i};", getGoogleStyle());
+  verifyFormat("auto const [a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto const [a3, b]{A * i};", PointerMiddle);
+  verifyFormat("auto const& [a1, b]{A * i};", getGoogleStyle());
+  verifyFormat("auto const &[a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto const & [a3, b]{A * i};", PointerMiddle);
+  verifyFormat("auto const&& [a1, b]{A * i};", getGoogleStyle());
+  verifyFormat("auto const &&[a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto const && [a3, b]{A * i};", PointerMiddle);
+
+  EXPECT_EQ("for (const auto &&[a, b] : some_range) {\n}",
+format("for (const auto   &&   [a, b] : some_range) {\n}"));
+  EXPECT_EQ("for (const auto &[a, b] : some_range) {\n}",
+format("for (const auto   &   [a, b] : some_range) {\n}"));
+  EXPECT_EQ("for (const auto [a, b] : some_range) {\n}",
+format("for (const auto[a, b] : some_range) {\n}"));
+  EXPECT_EQ("auto [x, y](expr);", format("auto[x,y]  (expr);"));
+  EXPECT_EQ("auto &[x, y](expr);", format("auto  &  [x,y]  (expr);"));
+  EXPECT_EQ("auto &&[x, y](expr);", format("auto  &&  [x,y]  (expr);"));
+  EXPECT_EQ("auto const &[x, y](expr);", format("auto  const  &  [x,y]  (expr);"));
+  EXPECT_EQ("auto const &&[x, y](expr);", format("auto  const  &&  [x,y]  (expr);"));
+  EXPECT_EQ("auto [x, y]{expr};", format("auto[x,y] {expr};"));
+  EXPECT_EQ("auto const &[x, y]{expr};", format("auto  const  &  [x,y]  {expr};"));
+  EXPECT_EQ("auto const &&[x, y]{expr};", format("auto  const  &&  [x,y]  {expr};"));
 
   format::FormatStyle Spaces = format::getLLVMStyle();
   Spaces.SpacesInSquareBrackets = true;
   verifyFormat("auto [ a, b ] = f();", Spaces);
-  verifyFormat("auto && [ a, b ] = f();", Spaces);
+  verifyFormat("auto &&[ a, b ] = f();", Spaces);
+  verifyFormat("auto &[ a, b ] = f();", Spaces);
+  verifyFormat("auto const &&[ a, b ] = f();", Spaces);
+  verifyFormat("auto const &[ a, b ] = f();", Spaces);
 }
 
 } // end namespace
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -342,10 +342,10 @@
 bool ColonFound = false;
 
 unsigned BindingIncrease = 1;
-if (Left->is(TT_Unknown)) {
-  if (Left->isCppStructuredBinding(Style)) {
-Left->Type = TT_StructuredBindingLSquare;
-  } else if (StartsObjCMethodExpr) {
+if (Left->isCppStructuredBinding(Style)) {
+  Left->Type = TT_StructuredBindingLSquare;
+} else if (Left->is(TT_Unknown)) {
+  if (StartsObjCMethodExpr) {
 Left->Type = TT_ObjCMethodExpr;
   } else if (Style.Language =

[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-09-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Tried stage2 build, so far only one warning.
But found out that `ubsan_value.h`'s `typedef s128 SIntMax;` crashes this code 
because

  class LLVM_NODISCARD APSInt : public APInt {
  ...
/// \brief Get the correctly-extended \c int64_t value.
int64_t getExtValue() const {
  assert(getMinSignedBits() <= 64 && "Too many bits for int64_t");
  return isSigned() ? getSExtValue() : getZExtValue();
}


Repository:
  rL LLVM

https://reviews.llvm.org/D38101



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


[PATCH] D38075: Fix PR34668 - P0704R1 implementation is too permissive

2017-09-21 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added inline comments.



Comment at: lib/Sema/SemaExprCXX.cpp:5185
   if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
 // C++2a allows functions with ref-qualifier & if they are also 
'const'.
+if (Proto->isConst() && !Proto->isVolatile())

tcanens wrote:
> Rakete wrote:
> > I think you should update the comment to something like "also 'const', but 
> > not if they're 'volatile'."
> "if their cv-qualifier-seq is (exactly) 'const'", maybe?
Sure that works too :)


https://reviews.llvm.org/D38075



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


[PATCH] D36487: Emit section information for extern variables.

2017-09-21 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews updated this revision to Diff 116211.
eandrews added a comment.

I've updated the patch based on review comments. The changes include setting 
section unconditionally for extern variables and emitting a warning if section 
attribute is specified on a redeclaration.


https://reviews.llvm.org/D36487

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDecl.cpp
  test/CodeGenCXX/extern-section-attribute.cpp
  test/Sema/attr-section.c


Index: test/Sema/attr-section.c
===
--- test/Sema/attr-section.c
+++ test/Sema/attr-section.c
@@ -19,3 +19,7 @@
 void __attribute__((section("bar,zed"))) test2(void) {} // expected-warning 
{{section does not match previous declaration}}
 
 enum __attribute__((section("NEAR,x"))) e { one }; // expected-error 
{{'section' attribute only applies to functions, methods, properties, and 
global variables}}
+
+extern int a; // expected-note {{previous declaration is here}}
+int *b = &a;
+extern int a __attribute__((section("foo,zed"))); // expected-warning 
{{section attribute is specified on redeclared variable}}
Index: test/CodeGenCXX/extern-section-attribute.cpp
===
--- /dev/null
+++ test/CodeGenCXX/extern-section-attribute.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu | FileCheck 
%s
+
+extern int aa __attribute__((section(".sdata")));
+// CHECK-DAG: @aa = external global i32, section ".sdata", align 4
+
+extern int bb __attribute__((section(".sdata"))) = 1;
+// CHECK-DAG: @bb = global i32 1, section ".sdata", align 4
+
+int foo() {
+  return aa + bb;
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2607,6 +2607,14 @@
 }
   }
 
+  // This redeclaration adds a section attribute to a declaration that has
+  // already been ODR-used.
+  if (New->hasAttr() && !Old->hasAttr() &&
+  Old->isUsed()) {
+Diag(New->getLocation(), diag::warn_attribute_section_on_redeclaration);
+Diag(Old->getLocation(), diag::note_previous_declaration);
+  }
+
   if (!Old->hasAttrs())
 return;
 
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2431,6 +2431,12 @@
   EmitGlobalVarDefinition(D);
 }
 
+// Emit section information for extern variables.
+if (D->hasExternalStorage()) {
+  if (const SectionAttr *SA = D->getAttr())
+GV->setSection(SA->getName());
+}
+
 // Handle XCore specific ABI requirements.
 if (getTriple().getArch() == llvm::Triple::xcore &&
 D->getLanguageLinkage() == CLanguageLinkage &&
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2611,6 +2611,8 @@
   "argument to 'section' attribute is not valid for this target: %0">;
 def warn_mismatched_section : Warning<
   "section does not match previous declaration">, InGroup;
+def warn_attribute_section_on_redeclaration : Warning<
+  "section attribute is specified on redeclared variable">, InGroup;
 
 def err_anonymous_property: Error<
   "anonymous property is not supported">;


Index: test/Sema/attr-section.c
===
--- test/Sema/attr-section.c
+++ test/Sema/attr-section.c
@@ -19,3 +19,7 @@
 void __attribute__((section("bar,zed"))) test2(void) {} // expected-warning {{section does not match previous declaration}}
 
 enum __attribute__((section("NEAR,x"))) e { one }; // expected-error {{'section' attribute only applies to functions, methods, properties, and global variables}}
+
+extern int a; // expected-note {{previous declaration is here}}
+int *b = &a;
+extern int a __attribute__((section("foo,zed"))); // expected-warning {{section attribute is specified on redeclared variable}}
Index: test/CodeGenCXX/extern-section-attribute.cpp
===
--- /dev/null
+++ test/CodeGenCXX/extern-section-attribute.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu | FileCheck %s
+
+extern int aa __attribute__((section(".sdata")));
+// CHECK-DAG: @aa = external global i32, section ".sdata", align 4
+
+extern int bb __attribute__((section(".sdata"))) = 1;
+// CHECK-DAG: @bb = global i32 1, section ".sdata", align 4
+
+int foo() {
+  return aa + bb;
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2607,6 +2607,14 @@
 }
   }
 
+  // This redeclaration adds a section attribute to a declaration that has
+  // already bee

[PATCH] D36487: Emit section information for extern variables.

2017-09-21 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:2434
+// Emit section information for extern variables.
+if (D->hasExternalStorage() && !D->isThisDeclarationADefinition()) {
+  if (const SectionAttr *SA = D->getAttr())

efriedma wrote:
> eandrews wrote:
> > efriedma wrote:
> > > Why do you specifically check "D->hasExternalStorage() && 
> > > !D->isThisDeclarationADefinition()", instead of just setting the section 
> > > unconditionally?
> > I noticed that you enter GetOrCreateLLVMGlobal( ) whenever the extern 
> > variable is declared as well as when it is defined. The flow of the program 
> > is different in each case. When the variable is defined, it also enters 
> > EmitGlobalVarDefinition( ). There is existing code handling section 
> > information here. I added the check in GetOrCreateLLVMGlobal( ) so the 
> > block gets skipped for variable definition, since its already handled 
> > elsewhere.
> I would rather just call setSection unconditionally here, as opposed to 
> trying to guess whether the global will eventually be defined.
> 
> I'm also sort of concerned the behavior here could be weird if a section 
> attribute is added on a redeclaration (e.g. what happens if you write `extern 
> int x; int y = &x; extern int x __attribute((section("foo")));`)... maybe we 
> should emit a warning?
@efriedma  I modified the patch to emit a warning in the scenario you 
mentioned. A warning is also emitted for the following - 

```extern int x;  int *y=&x; int x __attribute__((section("foo"))); 
```
I thought it made sense to emit the warning for the latter as well. Should I 
restrict the warning to just redeclarations (without definition) instead?


https://reviews.llvm.org/D36487



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


[PATCH] D37925: Allow specifying sanitizers in blacklists

2017-09-21 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich updated this revision to Diff 116213.
vlad.tsyrklevich marked 5 inline comments as done.
vlad.tsyrklevich added a comment.

- sanitizerCompile -> createSanitizerSections
- ASanMask -> AsanMask and fix another bug relating to ANDing with 
LangOpts.Sanitize.Mask


https://reviews.llvm.org/D37925

Files:
  docs/ControlFlowIntegrity.rst
  docs/SanitizerSpecialCaseList.rst
  include/clang/Basic/SanitizerBlacklist.h
  include/clang/Basic/SanitizerSpecialCaseList.h
  lib/AST/Decl.cpp
  lib/Basic/CMakeLists.txt
  lib/Basic/SanitizerBlacklist.cpp
  lib/Basic/SanitizerSpecialCaseList.cpp
  lib/Basic/XRayLists.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGen/Inputs/sanitizer-special-case-list.sanitized.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized1.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized2.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized3.txt
  test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized4.txt
  test/CodeGen/sanitizer-special-case-list.c
  test/CodeGenCXX/cfi-blacklist.cpp

Index: test/CodeGenCXX/cfi-blacklist.cpp
===
--- test/CodeGenCXX/cfi-blacklist.cpp
+++ test/CodeGenCXX/cfi-blacklist.cpp
@@ -1,6 +1,18 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOBL %s
-// RUN: echo "type:std::*" > %t.txt
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+
+// Check that blacklisting cfi and cfi-vcall work correctly
+// RUN: echo "[cfi-vcall]" > %t.vcall.txt
+// RUN: echo "type:std::*" >> %t.vcall.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.vcall.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+//
+// RUN: echo "[cfi]" > %t.cfi.txt
+// RUN: echo "type:std::*" >> %t.cfi.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.cfi.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOSTD %s
+
+// Check that blacklisting non-vcall modes does not affect vcalls
+// RUN: echo "[cfi-icall|cfi-nvcall|cfi-cast-strict|cfi-derived-cast|cfi-unrelated-cast]" > %t.other.txt
+// RUN: echo "type:std::*" >> %t.other.txt
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fvisibility hidden -fms-extensions -fsanitize=cfi-vcall -fsanitize-blacklist=%t.other.txt -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=NOBL %s
 
 struct S1 {
   virtual void f();
Index: test/CodeGen/sanitizer-special-case-list.c
===
--- /dev/null
+++ test/CodeGen/sanitizer-special-case-list.c
@@ -0,0 +1,26 @@
+// Verify that blacklist sections correctly select sanitizers to apply blacklist entries to.
+//
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized1.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized2.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized3.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.unsanitized4.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED
+//
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%S/Inputs/sanitizer-special-case-list.sanitized.txt -emit-llvm %s -o - | FileCheck %s --check-prefix=SANITIZED
+
+unsigned i;
+
+// SANITIZED: @overflow
+// UNSANITIZED: @overflow
+unsigned overflow() {
+  // SANITIZED: call {{.*}}void @__ubsan
+  // UNSANITIZED-NOT: call {{.*}}void @__ubsan
+  return i * 37;
+}
+
+// SANITIZED: @cfi
+// UNSANITIZED: @cfi
+void cfi(void (*fp)()) {
+  // SANITIZED: llvm.type.test
+  // UNSANITIZED-NOT: llvm.type.test
+  fp();
+}
Index: test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized4.txt
===
--- /dev/null
+++ test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized4.txt
@@ -0,0 +1,4 @@
+[c*]
+fun:*cfi*
+[u*]
+fun:*overflow*
Index: test/CodeGen/Inputs/sanitizer-special-case-list.unsanitized3.txt

[PATCH] D37925: Allow specifying sanitizers in blacklists

2017-09-21 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich added inline comments.



Comment at: lib/AST/Decl.cpp:3953
 ReasonToReject = 5;  // is standard layout.
-  else if (Blacklist.isBlacklistedLocation(getLocation(), "field-padding"))
+  else if (Blacklist.isBlacklistedLocation(ASanMask, getLocation(),
+   "field-padding"))

eugenis wrote:
> Looks like this is another case of missing "& LangOpts.Sanitize.Mask" ?
Indeed.



Comment at: lib/Basic/XRayLists.cpp:29
   // whether it's treated as a "never" instrument function.
-  if (AlwaysInstrument->inSection("fun", FunctionName, "arg1"))
+  if (AlwaysInstrument->inSection("xray_always_instrument", "fun", 
FunctionName,
+  "arg1"))

eugenis wrote:
> It feels redundant to have AlwaysInstrument and NeverInstrument lists, and 
> then the same distinction in section names. Maybe sections could be named 
> "xray" in  both cases? Or, better, the lists could be merged into a single 
> list with always and never sections? There is also an issue of backward 
> compatibility. Anyway, that's for xray devs to decide. @dberris 
I chose this approach for backwards compatibility, but I'd defer to what 
@dberris thinks is best.


https://reviews.llvm.org/D37925



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


r313892 - [lit] Rename lld and clang lit configs to end in .py

2017-09-21 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Thu Sep 21 10:38:13 2017
New Revision: 313892

URL: http://llvm.org/viewvc/llvm-project?rev=313892&view=rev
Log:
[lit] Rename lld and clang lit configs to end in .py

This follows in line with a previous patch of renaming LLVM's.

Working on these files is difficult in certain operating systems
and/or environments that don't like handling python code with a
non .py file extension.

Added:
cfe/trunk/test/Unit/lit.cfg.py
cfe/trunk/test/Unit/lit.site.cfg.py.in
cfe/trunk/test/lit.cfg.py
cfe/trunk/test/lit.site.cfg.py.in
Removed:
cfe/trunk/test/Unit/lit.cfg
cfe/trunk/test/Unit/lit.site.cfg.in
cfe/trunk/test/lit.cfg
cfe/trunk/test/lit.site.cfg.in
Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=313892&r1=313891&r2=313892&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Thu Sep 21 10:38:13 2017
@@ -26,13 +26,17 @@ llvm_canonicalize_cmake_booleans(
   HAVE_LIBZ)
 
 configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
+  MAIN_CONFIG
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
   )
 
 configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
+  ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
+  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
+  MAIN_CONFIG
+  ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
   )
 
 option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF)

Removed: cfe/trunk/test/Unit/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Unit/lit.cfg?rev=313891&view=auto
==
--- cfe/trunk/test/Unit/lit.cfg (original)
+++ cfe/trunk/test/Unit/lit.cfg (removed)
@@ -1,51 +0,0 @@
-# -*- Python -*-
-
-# Configuration file for the 'lit' test runner.
-
-import os
-import platform
-import subprocess
-
-import lit.formats
-import lit.util
-
-# name: The name of this test suite.
-config.name = 'Clang-Unit'
-
-# suffixes: A list of file extensions to treat as test files.
-config.suffixes = []
-
-# test_source_root: The root path where tests are located.
-# test_exec_root: The root path where tests should be run.
-config.test_exec_root = os.path.join(config.clang_obj_root, 'unittests')
-config.test_source_root = config.test_exec_root
-
-# testFormat: The test format to use to interpret tests.
-config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, 'Tests')
-
-# Propagate the temp directory. Windows requires this because it uses \Windows\
-# if none of these are present.
-if 'TMP' in os.environ:
-config.environment['TMP'] = os.environ['TMP']
-if 'TEMP' in os.environ:
-config.environment['TEMP'] = os.environ['TEMP']
-
-# Propagate path to symbolizer for ASan/MSan.
-for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
-if symbolizer in os.environ:
-config.environment[symbolizer] = os.environ[symbolizer]
-
-shlibpath_var = ''
-if platform.system() == 'Linux':
-shlibpath_var = 'LD_LIBRARY_PATH'
-elif platform.system() == 'Darwin':
-shlibpath_var = 'DYLD_LIBRARY_PATH'
-elif platform.system() == 'Windows':
-shlibpath_var = 'PATH'
-
-# in stand-alone builds, shlibdir is clang's build tree
-# while llvm_libs_dir is installed LLVM (and possibly older clang)
-shlibpath = os.path.pathsep.join((config.shlibdir, config.llvm_libs_dir,
- config.environment.get(shlibpath_var,'')))
-
-config.environment[shlibpath_var] = shlibpath

Added: cfe/trunk/test/Unit/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Unit/lit.cfg.py?rev=313892&view=auto
==
--- cfe/trunk/test/Unit/lit.cfg.py (added)
+++ cfe/trunk/test/Unit/lit.cfg.py Thu Sep 21 10:38:13 2017
@@ -0,0 +1,51 @@
+# -*- Python -*-
+
+# Configuration file for the 'lit' test runner.
+
+import os
+import platform
+import subprocess
+
+import lit.formats
+import lit.util
+
+# name: The name of this test suite.
+config.name = 'Clang-Unit'
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = []
+
+# test_source_root: The root path where tests are located.
+# test_exec_root: The root path where tests should be run.
+config.test_exec_root = os.path.join(config.clang_obj_root, 'unittests')
+config.test_source_root = config.test_exec_root
+
+# testFormat: The test format to use to interpret tests.
+config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, 'Tests')
+
+# Propagate the temp directory. Windows requires this because it uses \Windows\
+# if none of these are present.

r313894 - [fixup][Sema] Allow in C to define tags inside enumerations.

2017-09-21 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Thu Sep 21 10:41:30 2017
New Revision: 313894

URL: http://llvm.org/viewvc/llvm-project?rev=313894&view=rev
Log:
[fixup][Sema] Allow in C to define tags inside enumerations.

Fix for too aggressive error err_type_defined_in_enum introduced in
r313386. Defining tags inside enumerations is prohibited in C++ but
allowed in C.

Reviewers: aaron.ballman, rnk, doug.gregor

Reviewed By: rnk

Subscribers: alberto_magni, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/enum.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=313894&r1=313893&r2=313894&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Sep 21 10:41:30 2017
@@ -13916,7 +13916,8 @@ CreateNewDecl:
 Invalid = true;
   }
 
-  if (!Invalid && TUK == TUK_Definition && DC->getDeclKind() == Decl::Enum) {
+  if (!Invalid && getLangOpts().CPlusPlus && TUK == TUK_Definition &&
+  DC->getDeclKind() == Decl::Enum) {
 Diag(New->getLocation(), diag::err_type_defined_in_enum)
   << Context.getTagDeclType(New);
 Invalid = true;

Modified: cfe/trunk/test/Sema/enum.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/enum.c?rev=313894&r1=313893&r2=313894&view=diff
==
--- cfe/trunk/test/Sema/enum.c (original)
+++ cfe/trunk/test/Sema/enum.c Thu Sep 21 10:41:30 2017
@@ -125,9 +125,10 @@ enum Color { Red, Green, Blue }; // expe
 typedef struct Color NewColor; // expected-error {{use of 'Color' with tag 
type that does not match previous declaration}}
 
 // PR28903
+// In C it is valid to define tags inside enums.
 struct PR28903 {
   enum {
-PR28903_A = (enum { // expected-error-re {{'enum PR28903::(anonymous at 
{{.*}})' cannot be defined in an enumeration}}
+PR28903_A = (enum {
   PR28903_B,
   PR28903_C = PR28903_B
 })0


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


[PATCH] D38109: [fixup][Sema] Allow in C to define tags inside enumerations.

2017-09-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313894: [fixup][Sema] Allow in C to define tags inside 
enumerations. (authored by vsapsai).

Changed prior to commit:
  https://reviews.llvm.org/D38109?vs=116110&id=116219#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38109

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/Sema/enum.c


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -13916,7 +13916,8 @@
 Invalid = true;
   }
 
-  if (!Invalid && TUK == TUK_Definition && DC->getDeclKind() == Decl::Enum) {
+  if (!Invalid && getLangOpts().CPlusPlus && TUK == TUK_Definition &&
+  DC->getDeclKind() == Decl::Enum) {
 Diag(New->getLocation(), diag::err_type_defined_in_enum)
   << Context.getTagDeclType(New);
 Invalid = true;
Index: cfe/trunk/test/Sema/enum.c
===
--- cfe/trunk/test/Sema/enum.c
+++ cfe/trunk/test/Sema/enum.c
@@ -125,9 +125,10 @@
 typedef struct Color NewColor; // expected-error {{use of 'Color' with tag 
type that does not match previous declaration}}
 
 // PR28903
+// In C it is valid to define tags inside enums.
 struct PR28903 {
   enum {
-PR28903_A = (enum { // expected-error-re {{'enum PR28903::(anonymous at 
{{.*}})' cannot be defined in an enumeration}}
+PR28903_A = (enum {
   PR28903_B,
   PR28903_C = PR28903_B
 })0


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -13916,7 +13916,8 @@
 Invalid = true;
   }
 
-  if (!Invalid && TUK == TUK_Definition && DC->getDeclKind() == Decl::Enum) {
+  if (!Invalid && getLangOpts().CPlusPlus && TUK == TUK_Definition &&
+  DC->getDeclKind() == Decl::Enum) {
 Diag(New->getLocation(), diag::err_type_defined_in_enum)
   << Context.getTagDeclType(New);
 Invalid = true;
Index: cfe/trunk/test/Sema/enum.c
===
--- cfe/trunk/test/Sema/enum.c
+++ cfe/trunk/test/Sema/enum.c
@@ -125,9 +125,10 @@
 typedef struct Color NewColor; // expected-error {{use of 'Color' with tag type that does not match previous declaration}}
 
 // PR28903
+// In C it is valid to define tags inside enums.
 struct PR28903 {
   enum {
-PR28903_A = (enum { // expected-error-re {{'enum PR28903::(anonymous at {{.*}})' cannot be defined in an enumeration}}
+PR28903_A = (enum {
   PR28903_B,
   PR28903_C = PR28903_B
 })0
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38134: [OpenCL] Emit enqueued block as kernel

2017-09-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Now if we have a block which is being called and enqueued at the same time, 
will we generate 2 functions for it? Could we add such test case btw?

I feel it would be much simpler if we could always generate the kernel metadata 
for blocks. A lot of special case code would be removed if we do this. OpenCL 
doesn't prevent kernel functions to be used just as normal functions (6.7.1) so 
it should be a perfectly valid thing to do. Do you seen any issues with that?




Comment at: lib/CodeGen/CGBlocks.cpp:1255
 // Allocate a stack slot to let the debug info survive the RA.
-Address alloc = CreateMemTemp(D->getType(), D->getName() + ".addr");
+Address alloc = CreateMemTemp(
+!PV.isIndirect() ? D->getType()

Is there any test that covers this?



Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:113
+
+llvm::Value *CGOpenCLRuntime::emitOpenCLEnqueuedBlock(CodeGenFunction &CGF,
+  const Expr *E) {

I am not particularly in favour of duplicating CodeGen functionality as it 
typically has so many special cases that are hard to catch. Is this logic 
needed in order to pass to block literal information  that the block is 
enqueued?



Comment at: lib/CodeGen/CodeGenFunction.cpp:535
+if (i == 0 && IsBlock) {
+  ty = CGF.CGM.getTargetCodeGenInfo().getEnqueuedBlockArgumentType(
+  ASTCtx, *CGF.BlockInfo);

I don't quite understand why we need to special case this? As far as I 
undertsnad block argument is a `generic void* ` type but it's being cast to a 
concrete block struct inside the block function. Do we gain anything from 
having it a specific type here?


https://reviews.llvm.org/D38134



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


[PATCH] D38145: Suppress Wsign-conversion for enums with matching underlying type

2017-09-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

As reported here: https://bugs.llvm.org/show_bug.cgi?id=34692

A non-defined enum with a backing type was always defaulting to 
being treated as a signed type.  IN the case where it IS defined,
the signed-ness of the actual items is used.

This patch uses the underlying type's signed-ness in the non-defined
case to test signed-comparision.


https://reviews.llvm.org/D38145

Files:
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/sign-conversion.cpp


Index: test/SemaCXX/sign-conversion.cpp
===
--- /dev/null
+++ test/SemaCXX/sign-conversion.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion -std=c++11 %s
+
+unsigned int test() {
+  short foo;
+  return foo; // expected-warning {{implicit conversion changes signedness}}
+
+}
+
+unsigned int test3() {
+  // For a non-defined enum, use the underlying type.
+  enum u8 : char;
+  u8 foo{static_cast(0)};
+  return foo; // expected-warning {{implicit conversion changes signedness}}
+
+}
+unsigned int test2() {
+  // For a non-defined enum, use the underlying type.
+  enum u8 : unsigned char;
+  u8 foo{static_cast(0)};
+  return foo;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -8172,7 +8172,8 @@
 if (const EnumType *ET = dyn_cast(T)) {
   EnumDecl *Enum = ET->getDecl();
   if (!Enum->isCompleteDefinition())
-return IntRange(C.getIntWidth(QualType(T, 0)), false);
+return IntRange(C.getIntWidth(QualType(T, 0)),
+!ET->isSignedIntegerOrEnumerationType());
 
   unsigned NumPositive = Enum->getNumPositiveBits();
   unsigned NumNegative = Enum->getNumNegativeBits();


Index: test/SemaCXX/sign-conversion.cpp
===
--- /dev/null
+++ test/SemaCXX/sign-conversion.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion -std=c++11 %s
+
+unsigned int test() {
+  short foo;
+  return foo; // expected-warning {{implicit conversion changes signedness}}
+
+}
+
+unsigned int test3() {
+  // For a non-defined enum, use the underlying type.
+  enum u8 : char;
+  u8 foo{static_cast(0)};
+  return foo; // expected-warning {{implicit conversion changes signedness}}
+
+}
+unsigned int test2() {
+  // For a non-defined enum, use the underlying type.
+  enum u8 : unsigned char;
+  u8 foo{static_cast(0)};
+  return foo;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -8172,7 +8172,8 @@
 if (const EnumType *ET = dyn_cast(T)) {
   EnumDecl *Enum = ET->getDecl();
   if (!Enum->isCompleteDefinition())
-return IntRange(C.getIntWidth(QualType(T, 0)), false);
+return IntRange(C.getIntWidth(QualType(T, 0)),
+!ET->isSignedIntegerOrEnumerationType());
 
   unsigned NumPositive = Enum->getNumPositiveBits();
   unsigned NumNegative = Enum->getNumNegativeBits();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r313896 - [Sema] Fix using old initializer during switch statement transformation.

2017-09-21 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Thu Sep 21 10:58:27 2017
New Revision: 313896

URL: http://llvm.org/viewvc/llvm-project?rev=313896&view=rev
Log:
[Sema] Fix using old initializer during switch statement transformation.

It fixes a crash in CodeGen when we are trying to generate code for
initializer expression created before template instantiation, like

CallExpr ''
|-UnresolvedLookupExpr '' lvalue (ADL) = 'parse'
`-DeclRefExpr 'Buffer' lvalue ParmVar 'buffer' 'Buffer'

rdar://problem/33888545

Reviewers: rsmith, ahatanak

Reviewed By: ahatanak

Subscribers: aemerson, kristof.beyls, cfe-commits

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


Added:
cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp
Modified:
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=313896&r1=313895&r2=313896&view=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu Sep 21 10:58:27 2017
@@ -6601,8 +6601,7 @@ TreeTransform::TransformSwitchS
 
   // Rebuild the switch statement.
   StmtResult Switch
-= getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(),
-  S->getInit(), Cond);
+= getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), Init.get(), Cond);
   if (Switch.isInvalid())
 return StmtError();
 

Added: cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp?rev=313896&view=auto
==
--- cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp (added)
+++ cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp Thu Sep 21 
10:58:27 2017
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++1z -verify -emit-llvm-only %s
+// expected-no-diagnostics
+
+// rdar://problem/33888545
+template  class Buffer {};
+
+class A {
+public:
+  int status;
+};
+
+template  A parse(Buffer buffer);
+
+template
+void init_in_if(Buffer buffer) {
+  if (A a = parse(buffer); a.status > 0) {
+  }
+}
+
+template
+void init_in_switch(Buffer buffer) {
+  switch (A a = parse(buffer); a.status) {
+default:
+  break;
+  }
+}
+
+void test() {
+  Buffer<10> buffer;
+  init_in_if(buffer);
+  init_in_switch(buffer);
+}


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


[PATCH] D38009: [Sema] Fix using old initializer during switch statement transformation.

2017-09-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313896: [Sema] Fix using old initializer during switch 
statement transformation. (authored by vsapsai).

Changed prior to commit:
  https://reviews.llvm.org/D38009?vs=115754&id=116226#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38009

Files:
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp


Index: cfe/trunk/lib/Sema/TreeTransform.h
===
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -6601,8 +6601,7 @@
 
   // Rebuild the switch statement.
   StmtResult Switch
-= getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(),
-  S->getInit(), Cond);
+= getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), Init.get(), Cond);
   if (Switch.isInvalid())
 return StmtError();
 
Index: cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp
===
--- cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp
+++ cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++1z -verify -emit-llvm-only %s
+// expected-no-diagnostics
+
+// rdar://problem/33888545
+template  class Buffer {};
+
+class A {
+public:
+  int status;
+};
+
+template  A parse(Buffer buffer);
+
+template
+void init_in_if(Buffer buffer) {
+  if (A a = parse(buffer); a.status > 0) {
+  }
+}
+
+template
+void init_in_switch(Buffer buffer) {
+  switch (A a = parse(buffer); a.status) {
+default:
+  break;
+  }
+}
+
+void test() {
+  Buffer<10> buffer;
+  init_in_if(buffer);
+  init_in_switch(buffer);
+}


Index: cfe/trunk/lib/Sema/TreeTransform.h
===
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -6601,8 +6601,7 @@
 
   // Rebuild the switch statement.
   StmtResult Switch
-= getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(),
-  S->getInit(), Cond);
+= getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), Init.get(), Cond);
   if (Switch.isInvalid())
 return StmtError();
 
Index: cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp
===
--- cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp
+++ cfe/trunk/test/SemaCXX/cxx1z-init-statement-template.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++1z -verify -emit-llvm-only %s
+// expected-no-diagnostics
+
+// rdar://problem/33888545
+template  class Buffer {};
+
+class A {
+public:
+  int status;
+};
+
+template  A parse(Buffer buffer);
+
+template
+void init_in_if(Buffer buffer) {
+  if (A a = parse(buffer); a.status > 0) {
+  }
+}
+
+template
+void init_in_switch(Buffer buffer) {
+  switch (A a = parse(buffer); a.status) {
+default:
+  break;
+  }
+}
+
+void test() {
+  Buffer<10> buffer;
+  init_in_if(buffer);
+  init_in_switch(buffer);
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38113: OpenCL: Assume functions are convergent

2017-09-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

The problem of adding this attribute conservatively for all functions is that 
it prevents some optimizations to happen. I agree to commit this as a temporary 
fix to guarantee correctness of generated code. But if we ask to add the 
`convergent` attribute into the spec we can avoid doing this in the compiler?


https://reviews.llvm.org/D38113



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


[PATCH] D38147: [CUDA] Fixed order of words in the names of shfl builtins.

2017-09-21 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
Herald added a subscriber: sanjoy.

https://reviews.llvm.org/D38147

Files:
  clang/lib/Headers/__clang_cuda_intrinsics.h


Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -148,13 +148,12 @@
  __nvvm_shfl_sync_idx_f32, 0x1f);
 // We use 0 rather than 31 as our mask, because shfl.up applies to lanes >=
 // maxLane.
-__MAKE_SYNC_SHUFFLES(__shfl_sync_up, __nvvm_shfl_sync_up_i32,
+__MAKE_SYNC_SHUFFLES(__shfl_up_sync, __nvvm_shfl_sync_up_i32,
  __nvvm_shfl_sync_up_f32, 0);
-__MAKE_SYNC_SHUFFLES(__shfl_sync_down, __nvvm_shfl_sync_down_i32,
+__MAKE_SYNC_SHUFFLES(__shfl_down_sync, __nvvm_shfl_sync_down_i32,
  __nvvm_shfl_sync_down_f32, 0x1f);
-__MAKE_SYNC_SHUFFLES(__shfl_sync_xor, __nvvm_shfl_sync_bfly_i32,
+__MAKE_SYNC_SHUFFLES(__shfl_xor_sync, __nvvm_shfl_sync_bfly_i32,
  __nvvm_shfl_sync_bfly_f32, 0x1f);
-
 #pragma pop_macro("__MAKE_SYNC_SHUFFLES")
 
 inline __device__ void __syncwarp(unsigned int mask = 0x) {


Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -148,13 +148,12 @@
  __nvvm_shfl_sync_idx_f32, 0x1f);
 // We use 0 rather than 31 as our mask, because shfl.up applies to lanes >=
 // maxLane.
-__MAKE_SYNC_SHUFFLES(__shfl_sync_up, __nvvm_shfl_sync_up_i32,
+__MAKE_SYNC_SHUFFLES(__shfl_up_sync, __nvvm_shfl_sync_up_i32,
  __nvvm_shfl_sync_up_f32, 0);
-__MAKE_SYNC_SHUFFLES(__shfl_sync_down, __nvvm_shfl_sync_down_i32,
+__MAKE_SYNC_SHUFFLES(__shfl_down_sync, __nvvm_shfl_sync_down_i32,
  __nvvm_shfl_sync_down_f32, 0x1f);
-__MAKE_SYNC_SHUFFLES(__shfl_sync_xor, __nvvm_shfl_sync_bfly_i32,
+__MAKE_SYNC_SHUFFLES(__shfl_xor_sync, __nvvm_shfl_sync_bfly_i32,
  __nvvm_shfl_sync_bfly_f32, 0x1f);
-
 #pragma pop_macro("__MAKE_SYNC_SHUFFLES")
 
 inline __device__ void __syncwarp(unsigned int mask = 0x) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38147: [CUDA] Fixed order of words in the names of shfl builtins.

2017-09-21 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

Naturally they're different orders in the PTX and CUDA.  :)


https://reviews.llvm.org/D38147



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


[PATCH] D37822: [OpenCL] Clean up and add missing fields for block struct

2017-09-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D37822#877572, @yaxunl wrote:

> In https://reviews.llvm.org/D37822#873876, @Anastasia wrote:
>
> > In https://reviews.llvm.org/D37822#872446, @yaxunl wrote:
> >
> > > In https://reviews.llvm.org/D37822#872291, @Anastasia wrote:
> > >
> > > > Could you please explain a bit more why the alignment have to be put 
> > > > explicitly in the struct? I am just not very convinced this is general 
> > > > enough.
> > >
> > >
> > > The captured variables are fields of the block literal struct. Due to 
> > > alignment requirement of these fields, there is alignment requirement of
> > >  the block literal struct. The ISA of the block invoke function is 
> > > generated with the assumption of these alignments. If the block literal is
> > >  allocated at a memory address not satisfying the alignment requirement, 
> > > the kernel behavior is undefined.
> > >
> > > Generally, __enqueue_kernel library function needs to prepare the kernel 
> > > argument before launching the kernel. It usually does this by copying
> > >  the block literal to some buffer then pass the address of the buffer to 
> > > the kernel. Then the address of the buffer has to satisfy the alignment
> > >  requirement.
> > >
> > > If this block literal struct is not general enough, how about add another 
> > > field as target reserved size, and leave the remaining space of header for
> > >  target specific use. And add a target hook to allow target fill the 
> > > reserved space, e.g.
> > >
> > >   struct __opencl_block_literal {
> > > int total_size;
> > > int align;
> > > __generic void *invoke;
> > > int target_reserved_size; /* round up to 4 bytes */
> > > int target_reserved[];
> > > /* captures */
> > >   };
> > >
> >
> >
> > I like the idea of the target reserved part actually. But not sure how it 
> > could be used without adding any target specific methods?
>
>
> If we decide to add target reserved fields, I can add target hooks to fill 
> these fields. However I would suggest to leave this for future since I don't 
> see there is need for other fields for now.


I could imagine it can be usefull for some vendor implementations.

>> However, I am still not clear why the alignment of this struct has to be 
>> different from any other struct Clang produces. Normally the alignment of 
>> objects have to be known during IR generation to put them correctly in the 
>> attributes of generated alloca, store and loads. But as a field inside 
>> struct I don't know how it can be useful. I would imagine `enqueue_kernel` 
>> would just operate on the block as if it would be an arbitrary buffer of 
>> data. Also would size of the struct not account for any padding to make sure 
>> the alignment can be deduced based on it correctly?
> 
> enqueue_kernel needs to pass the block struct to the kernel. Let's assume it 
> does this by copying the block struct to a buffer. If enqueue_kernel does not 
> know the alignment of the struct, it can only put it at an arbitrary address 
> in the buffer. Then the kernel has to copy the struct to an aligned private 
> memory and load the fields. However, if the enqueued_kernel knows the 
> alignment of the struct, it can put it at an address satisfying the 
> alignment. Then the kernel can load the fields directly from the buffer, 
> skips the step of copying to an aligned private memory. Therefore, alignment 
> of the block struct is usually a useful information for enqueue_kernel. I 
> think that's why in the SPIRV spec OpEnqueueKernel requires an alignment 
> operand for the block context.

Ok, I just think in C if you use `malloc` to obtain a pointer to some memory 
location it doesn't take any alignment information. Then you can use the 
pointer to copy any data including the struct into the location its pointed to. 
And the pointer can be used later on correctly. I think the alignment is 
deduced in this case from the type or the size of an object. Do you know where 
the alignment information is used for SPIRV call? Also how is the block 
represented in SPIRV?


https://reviews.llvm.org/D37822



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


[PATCH] D38113: OpenCL: Assume functions are convergent

2017-09-21 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

> The problem of adding this attribute conservatively for all functions is that 
> it prevents some optimizations to happen.

function-attrs removes the convergent attribute from anything it can prove does 
not call a convergent function.

I agree this is a nonoptimal solution.  A better way would be to assume that 
any cuda/opencl function is convergent and then figure out what isn't.  This 
would let you generate correct cuda/opencl code in a front-end without worrying 
about this attribute.

One problem with this approach is, suppose you call an external function, whose 
body llvm cannot see.  We need some way to mark this function as 
not-convergent, so that its callers can also be inferred to be not convergent.  
LLVM currently only has a "convergent" attribute.  In the absence of a new 
"not-convergent" attribute, the only way we can tell LLVM that this external 
function is not convergent is to leave off the attribute.  But then this means 
we assume all functions without the convergent attribute are not convergent, 
and thus we have to add the attribute everywhere, as this patch does.

OTOH if we added a not-convergent attribute, we'd have to have rules about what 
happens if both attributes are on a function, and everywhere that checked 
whether a function was convergent would become significantly more complicated.  
I'm not sure that's worthwhile.


https://reviews.llvm.org/D38113



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


[PATCH] D37822: [OpenCL] Clean up and add missing fields for block struct

2017-09-21 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

In https://reviews.llvm.org/D37822#877903, @Anastasia wrote:

> In https://reviews.llvm.org/D37822#877572, @yaxunl wrote:
>
> > In https://reviews.llvm.org/D37822#873876, @Anastasia wrote:
> >
> > > In https://reviews.llvm.org/D37822#872446, @yaxunl wrote:
> > >
> > > > In https://reviews.llvm.org/D37822#872291, @Anastasia wrote:
> > > >
> > > > > Could you please explain a bit more why the alignment have to be put 
> > > > > explicitly in the struct? I am just not very convinced this is 
> > > > > general enough.
> > > >
> > > >
> > > > The captured variables are fields of the block literal struct. Due to 
> > > > alignment requirement of these fields, there is alignment requirement of
> > > >  the block literal struct. The ISA of the block invoke function is 
> > > > generated with the assumption of these alignments. If the block literal 
> > > > is
> > > >  allocated at a memory address not satisfying the alignment 
> > > > requirement, the kernel behavior is undefined.
> > > >
> > > > Generally, __enqueue_kernel library function needs to prepare the 
> > > > kernel argument before launching the kernel. It usually does this by 
> > > > copying
> > > >  the block literal to some buffer then pass the address of the buffer 
> > > > to the kernel. Then the address of the buffer has to satisfy the 
> > > > alignment
> > > >  requirement.
> > > >
> > > > If this block literal struct is not general enough, how about add 
> > > > another field as target reserved size, and leave the remaining space of 
> > > > header for
> > > >  target specific use. And add a target hook to allow target fill the 
> > > > reserved space, e.g.
> > > >
> > > >   struct __opencl_block_literal {
> > > > int total_size;
> > > > int align;
> > > > __generic void *invoke;
> > > > int target_reserved_size; /* round up to 4 bytes */
> > > > int target_reserved[];
> > > > /* captures */
> > > >   };
> > > >
> > >
> > >
> > > I like the idea of the target reserved part actually. But not sure how it 
> > > could be used without adding any target specific methods?
> >
> >
> > If we decide to add target reserved fields, I can add target hooks to fill 
> > these fields. However I would suggest to leave this for future since I 
> > don't see there is need for other fields for now.
>
>
> I could imagine it can be usefull for some vendor implementations.
>
> >> However, I am still not clear why the alignment of this struct has to be 
> >> different from any other struct Clang produces. Normally the alignment of 
> >> objects have to be known during IR generation to put them correctly in the 
> >> attributes of generated alloca, store and loads. But as a field inside 
> >> struct I don't know how it can be useful. I would imagine `enqueue_kernel` 
> >> would just operate on the block as if it would be an arbitrary buffer of 
> >> data. Also would size of the struct not account for any padding to make 
> >> sure the alignment can be deduced based on it correctly?
> > 
> > enqueue_kernel needs to pass the block struct to the kernel. Let's assume 
> > it does this by copying the block struct to a buffer. If enqueue_kernel 
> > does not know the alignment of the struct, it can only put it at an 
> > arbitrary address in the buffer. Then the kernel has to copy the struct to 
> > an aligned private memory and load the fields. However, if the 
> > enqueued_kernel knows the alignment of the struct, it can put it at an 
> > address satisfying the alignment. Then the kernel can load the fields 
> > directly from the buffer, skips the step of copying to an aligned private 
> > memory. Therefore, alignment of the block struct is usually a useful 
> > information for enqueue_kernel. I think that's why in the SPIRV spec 
> > OpEnqueueKernel requires an alignment operand for the block context.
>
> Ok, I just think in C if you use `malloc` to obtain a pointer to some memory 
> location it doesn't take any alignment information. Then you can use the 
> pointer to copy any data including the struct into the location its pointed 
> to. And the pointer can be used later on correctly. I think the alignment is 
> deduced in this case from the type or the size of an object. Do you know 
> where the alignment information is used for SPIRV call? Also how is the block 
> represented in SPIRV?


Actually malloc alignment is not sufficient more many uses such as CPU 
supported vectors, e.g. AVX512 or passed to create buffer with 
use-host-pointer.  In such cases you need posix_memalign or some similar API.  
Having the alignment means it is available if needed.  If an implementation 
doesn't need it, there is no harm is there?


https://reviews.llvm.org/D37822



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


[PATCH] D36562: [Bitfield] Make the bitfield a separate location if it has width of legal integer type and its bit offset is naturally aligned for the type

2017-09-21 Thread Wei Mi via Phabricator via cfe-commits
wmi updated this revision to Diff 116232.
wmi added a comment.

Changes following the discussion:

- Put the bitfield split logic under an option and off by default.
- When sanitizer is enabled, the option for bitfield split will be ignored and 
a warning message will be emitted.

In addition, a test is added.


Repository:
  rL LLVM

https://reviews.llvm.org/D36562

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/bitfield-split.cpp

Index: test/CodeGenCXX/bitfield-split.cpp
===
--- test/CodeGenCXX/bitfield-split.cpp
+++ test/CodeGenCXX/bitfield-split.cpp
@@ -0,0 +1,161 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsplit-bitfields -emit-llvm \
+// RUN:  -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsplit-bitfields -emit-llvm \
+// RUN:  -fsanitize=address -o - %s | FileCheck %s --check-prefix=SANITIZE
+// Check -fsplit-bitfields will be ignored since sanitizer is enabled.
+
+struct S1 {
+  unsigned f1:2;
+  unsigned f2:6;
+  unsigned f3:8;
+  unsigned f4:4;
+  unsigned f5:8;
+};
+
+S1 a1;
+unsigned read8_1() {
+  // CHECK-LABEL: @_Z7read8_1v
+  // CHECK: %bf.load = load i8, i8* getelementptr (i8, i8* bitcast (%struct.S1* @a1 to i8*), i32 1), align 1
+  // CHECK-NEXT: %bf.cast = zext i8 %bf.load to i32
+  // CHECK-NEXT: ret i32 %bf.cast
+  // SANITIZE-LABEL: @_Z7read8_1v
+  // SANITIZE: %bf.load = load i32, i32* getelementptr inbounds {{.*}}, align 4
+  // SANITIZE: %bf.lshr = lshr i32 %bf.load, 8
+  // SANITIZE: %bf.clear = and i32 %bf.lshr, 255
+  // SANITIZE: ret i32 %bf.clear
+  return a1.f3;
+}
+void write8_1() {
+  // CHECK-LABEL: @_Z8write8_1v
+  // CHECK: store i8 3, i8* getelementptr (i8, i8* bitcast (%struct.S1* @a1 to i8*), i32 1), align 1
+  // CHECK-NEXT: ret void
+  // SANITIZE-LABEL: @_Z8write8_1v
+  // SANITIZE: %bf.load = load i32, i32* getelementptr inbounds {{.*}}, align 4
+  // SANITIZE-NEXT: %bf.clear = and i32 %bf.load, -65281
+  // SANITIZE-NEXT: %bf.set = or i32 %bf.clear, 768
+  // SANITIZE-NEXT: store i32 %bf.set, i32* getelementptr inbounds {{.*}}, align 4
+  // SANITIZE-NEXT: ret void
+  a1.f3 = 3;
+}
+
+unsigned read8_2() {
+  // CHECK-LABEL: @_Z7read8_2v
+  // CHECK: %bf.load = load i32, i32* getelementptr inbounds (%struct.S1, %struct.S1* @a1, i32 0, i32 0), align 4
+  // CHECK-NEXT: %bf.lshr = lshr i32 %bf.load, 20
+  // CHECK-NEXT: %bf.clear = and i32 %bf.lshr, 255
+  // CHECK-NEXT: ret i32 %bf.clear
+  // SANITIZE-LABEL: @_Z7read8_2v
+  // SANITIZE: %bf.load = load i32, i32* getelementptr inbounds {{.*}}, align 4
+  // SANITIZE-NEXT: %bf.lshr = lshr i32 %bf.load, 20
+  // SANITIZE-NEXT: %bf.clear = and i32 %bf.lshr, 255
+  // SANITIZE-NEXT: ret i32 %bf.clear
+  return a1.f5;
+}
+void write8_2() {
+  // CHECK-LABEL: @_Z8write8_2v
+  // CHECK: %bf.load = load i32, i32* getelementptr inbounds (%struct.S1, %struct.S1* @a1, i32 0, i32 0), align 4
+  // CHECK-NEXT: %bf.clear = and i32 %bf.load, -267386881
+  // CHECK-NEXT: %bf.set = or i32 %bf.clear, 3145728
+  // CHECK-NEXT: store i32 %bf.set, i32* getelementptr inbounds (%struct.S1, %struct.S1* @a1, i32 0, i32 0), align 4
+  // CHECK-NEXT: ret void
+  // SANITIZE-LABEL: @_Z8write8_2v
+  // SANITIZE: %bf.load = load i32, i32* getelementptr inbounds {{.*}}, align 4
+  // SANITIZE-NEXT: %bf.clear = and i32 %bf.load, -267386881
+  // SANITIZE-NEXT: %bf.set = or i32 %bf.clear, 3145728
+  // SANITIZE-NEXT: store i32 %bf.set, i32* getelementptr inbounds {{.*}}, align 4
+  // SANITIZE-NEXT: ret void
+  a1.f5 = 3;
+}
+
+struct S2 {
+  unsigned long f1:16;
+  unsigned long f2:16;
+  unsigned long f3:6;
+};
+
+S2 a2;
+unsigned read16_1() {
+  // CHECK-LABEL: @_Z8read16_1v
+  // CHECK: %bf.load = load i16, i16* bitcast (%struct.S2* @a2 to i16*), align 2
+  // CHECK-NEXT: %bf.cast = zext i16 %bf.load to i64
+  // CHECK-NEXT: %conv = trunc i64 %bf.cast to i32
+  // CHECK-NEXT: ret i32 %conv
+  // SANITIZE-LABEL: @_Z8read16_1v
+  // SANITIZE: %bf.load = load i64, i64* bitcast {{.*}}, align 8
+  // SANITIZE-NEXT: %bf.clear = and i64 %bf.load, 65535
+  // SANITIZE-NEXT: %conv = trunc i64 %bf.clear to i32
+  // SANITIZE-NEXT: ret i32 %conv
+  return a2.f1;
+}
+unsigned read16_2() {
+  // CHECK-LABEL: @_Z8read16_2v
+  // CHECK: %bf.load = load i16, i16* bitcast (i8* getelementptr (i8, i8* bitcast (%struct.S2* @a2 to i8*), i32 2) to i16*), align 2
+  // CHECK-NEXT: %bf.cast = zext i16 %bf.load to i64
+  // CHECK-NEXT: %conv = trunc i64 %bf.cast to i32
+  // CHECK-NEXT: ret i32 %conv
+  // SANITIZE-LABEL: @_Z8read16_2v
+  // SANITIZE: %bf.load = load i64, i64* bitcast {{.*}}, align 8
+  // SANITIZE-NEXT: %bf.lshr = lshr i64 %bf.load, 16
+  // SANITIZE-NEXT: %bf.clear = and i64 %bf.lshr, 65535
+  // SANITIZE-NEXT: %conv = trunc i64 %bf.clear to i32
+  // SANITIZE-

[PATCH] D38148: [NVPTX] Implemented bar.warp.sync, barrier.sync, and vote{.sync} instructions/intrinsics/builtins.

2017-09-21 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
Herald added subscribers: hiraditya, sanjoy, jholewinski.

https://reviews.llvm.org/D38148

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/Headers/__clang_cuda_intrinsics.h
  clang/test/CodeGen/builtins-nvptx-ptx60.cu
  clang/test/CodeGen/builtins-nvptx.c
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/barrier.ll
  llvm/test/CodeGen/NVPTX/vote.ll

Index: llvm/test/CodeGen/NVPTX/vote.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/vote.ll
@@ -0,0 +1,65 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_30 -mattr=+ptx60 | FileCheck %s
+
+declare i1 @llvm.nvvm.vote.all(i1)
+; CHECK-LABEL: .func{{.*}}vote.all
+define i1 @vote.all(i1 %pred) {
+  ; CHECK: vote.all.pred
+  %val = call i1 @llvm.nvvm.vote.all(i1 %pred)
+  ret i1 %val
+}
+
+declare i1 @llvm.nvvm.vote.any(i1)
+; CHECK-LABEL: .func{{.*}}vote.any
+define i1 @vote.any(i1 %pred) {
+  ; CHECK: vote.any.pred
+  %val = call i1 @llvm.nvvm.vote.any(i1 %pred)
+  ret i1 %val
+}
+
+declare i1 @llvm.nvvm.vote.uni(i1)
+; CHECK-LABEL: .func{{.*}}vote.uni
+define i1 @vote.uni(i1 %pred) {
+  ; CHECK: vote.uni.pred
+  %val = call i1 @llvm.nvvm.vote.uni(i1 %pred)
+  ret i1 %val
+}
+
+declare i32 @llvm.nvvm.vote.ballot(i1)
+; CHECK-LABEL: .func{{.*}}vote.ballot
+define i32 @vote.ballot(i1 %pred) {
+  ; CHECK: vote.ballot.b32
+  %val = call i32 @llvm.nvvm.vote.ballot(i1 %pred)
+  ret i32 %val
+}
+
+declare i1 @llvm.nvvm.vote.all.sync(i32, i1)
+; CHECK-LABEL: .func{{.*}}vote.sync.all
+define i1 @vote.sync.all(i32 %mask, i1 %pred) {
+  ; CHECK: vote.sync.all.pred
+  %val = call i1 @llvm.nvvm.vote.all.sync(i32 %mask, i1 %pred)
+  ret i1 %val
+}
+
+declare i1 @llvm.nvvm.vote.any.sync(i32, i1)
+; CHECK-LABEL: .func{{.*}}vote.sync.any
+define i1 @vote.sync.any(i32 %mask, i1 %pred) {
+  ; CHECK: vote.sync.any.pred
+  %val = call i1 @llvm.nvvm.vote.any.sync(i32 %mask, i1 %pred)
+  ret i1 %val
+}
+
+declare i1 @llvm.nvvm.vote.uni.sync(i32, i1)
+; CHECK-LABEL: .func{{.*}}vote.sync.uni
+define i1 @vote.sync.uni(i32 %mask, i1 %pred) {
+  ; CHECK: vote.sync.uni.pred
+  %val = call i1 @llvm.nvvm.vote.uni.sync(i32 %mask, i1 %pred)
+  ret i1 %val
+}
+
+declare i32 @llvm.nvvm.vote.ballot.sync(i32, i1)
+; CHECK-LABEL: .func{{.*}}vote.sync.ballot
+define i32 @vote.sync.ballot(i32 %mask, i1 %pred) {
+  ; CHECK: vote.sync.ballot.b32
+  %val = call i32 @llvm.nvvm.vote.ballot.sync(i32 %mask, i1 %pred)
+  ret i32 %val
+}
Index: llvm/test/CodeGen/NVPTX/barrier.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/barrier.ll
@@ -0,0 +1,32 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_30 -mattr=+ptx60 | FileCheck %s
+
+declare void @llvm.nvvm.bar.warp.sync(i32)
+declare void @llvm.nvvm.barrier.sync(i32)
+declare void @llvm.nvvm.barrier.sync.cnt(i32, i32)
+
+; CHECK-LABEL: .func{{.*}}barrier.sync
+define void @barrier.sync(i32 %id, i32 %cnt) {
+  ; CHECK: ld.param.u32 	[[ID:%r[0-9]+]], [barrier.sync_param_0];
+  ; CHECK: ld.param.u32 	[[CNT:%r[0-9]+]], [barrier.sync_param_1];
+
+  ; CHECK:  barrier.sync [[ID]], [[CNT]];
+  call void @llvm.nvvm.barrier.sync.cnt(i32 %id, i32 %cnt)
+  ; CHECK:  barrier.sync [[ID]], 2;
+  call void @llvm.nvvm.barrier.sync.cnt(i32 %id, i32 2)
+  ; CHECK:  barrier.sync 3, [[CNT]];
+  call void @llvm.nvvm.barrier.sync.cnt(i32 3, i32 %cnt)
+  ; CHECK:  barrier.sync 4, 5;
+  call void @llvm.nvvm.barrier.sync.cnt(i32 4, i32 5)
+
+  ; CHECK: barrier.sync [[ID]];
+  call void @llvm.nvvm.barrier.sync(i32 %id)
+  ; CHECK: barrier.sync 1;
+  call void @llvm.nvvm.barrier.sync(i32 1)
+
+  ; CHECK: bar.warp.sync [[ID]];
+  call void @llvm.nvvm.bar.warp.sync(i32 %id)
+  ; CHECK: bar.warp.sync 6;
+  call void @llvm.nvvm.bar.warp.sync(i32 6)
+  ret void;
+}
+
Index: llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
===
--- llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -71,6 +71,38 @@
 def INT_BAR_SYNC : NVPTXInst<(outs), (ins i32imm:$i), "bar.sync \t$i;",
  [(int_nvvm_bar_sync imm:$i)]>;
 
+def INT_BAR_WARP_SYNC_I : NVPTXInst<(outs), (ins i32imm:$i), "bar.warp.sync \t$i;",
+ [(int_nvvm_bar_warp_sync imm:$i)]>,
+Requires<[hasPTX60, hasSM30]>;
+def INT_BAR_WARP_SYNC_R : NVPTXInst<(outs), (ins Int32Regs:$i), "bar.warp.sync \t$i;",
+ [(int_nvvm_bar_warp_sync Int32Regs:$i)]>,
+Requires<[hasPTX60, hasSM30]>;
+
+def INT_BARRIER_SYNC_I : NVPTXInst<(outs), (ins i32imm:$i), "barrier.sync \t$i;",
+   [(int_nvvm_barrier_sync imm:$i)]>,
+Requires<[hasPTX60, hasSM30]>;
+def INT_BARRIER_SYNC_R : NVPTXInst<(outs), (ins Int32Regs:$i), "barrier.sync \t$i;",
+   [(int_nvvm_barrier

[PATCH] D38148: [NVPTX] Implemented bar.warp.sync, barrier.sync, and vote{.sync} instructions/intrinsics/builtins.

2017-09-21 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 116236.
tra added a comment.

Fixed a typo in one test.


https://reviews.llvm.org/D38148

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/Headers/__clang_cuda_intrinsics.h
  clang/test/CodeGen/builtins-nvptx-ptx60.cu
  clang/test/CodeGen/builtins-nvptx.c
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/barrier.ll
  llvm/test/CodeGen/NVPTX/vote.ll

Index: llvm/test/CodeGen/NVPTX/vote.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/vote.ll
@@ -0,0 +1,65 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_30 -mattr=+ptx60 | FileCheck %s
+
+declare i1 @llvm.nvvm.vote.all(i1)
+; CHECK-LABEL: .func{{.*}}vote.all
+define i1 @vote.all(i1 %pred) {
+  ; CHECK: vote.all.pred
+  %val = call i1 @llvm.nvvm.vote.all(i1 %pred)
+  ret i1 %val
+}
+
+declare i1 @llvm.nvvm.vote.any(i1)
+; CHECK-LABEL: .func{{.*}}vote.any
+define i1 @vote.any(i1 %pred) {
+  ; CHECK: vote.any.pred
+  %val = call i1 @llvm.nvvm.vote.any(i1 %pred)
+  ret i1 %val
+}
+
+declare i1 @llvm.nvvm.vote.uni(i1)
+; CHECK-LABEL: .func{{.*}}vote.uni
+define i1 @vote.uni(i1 %pred) {
+  ; CHECK: vote.uni.pred
+  %val = call i1 @llvm.nvvm.vote.uni(i1 %pred)
+  ret i1 %val
+}
+
+declare i32 @llvm.nvvm.vote.ballot(i1)
+; CHECK-LABEL: .func{{.*}}vote.ballot
+define i32 @vote.ballot(i1 %pred) {
+  ; CHECK: vote.ballot.b32
+  %val = call i32 @llvm.nvvm.vote.ballot(i1 %pred)
+  ret i32 %val
+}
+
+declare i1 @llvm.nvvm.vote.all.sync(i32, i1)
+; CHECK-LABEL: .func{{.*}}vote.sync.all
+define i1 @vote.sync.all(i32 %mask, i1 %pred) {
+  ; CHECK: vote.sync.all.pred
+  %val = call i1 @llvm.nvvm.vote.all.sync(i32 %mask, i1 %pred)
+  ret i1 %val
+}
+
+declare i1 @llvm.nvvm.vote.any.sync(i32, i1)
+; CHECK-LABEL: .func{{.*}}vote.sync.any
+define i1 @vote.sync.any(i32 %mask, i1 %pred) {
+  ; CHECK: vote.sync.any.pred
+  %val = call i1 @llvm.nvvm.vote.any.sync(i32 %mask, i1 %pred)
+  ret i1 %val
+}
+
+declare i1 @llvm.nvvm.vote.uni.sync(i32, i1)
+; CHECK-LABEL: .func{{.*}}vote.sync.uni
+define i1 @vote.sync.uni(i32 %mask, i1 %pred) {
+  ; CHECK: vote.sync.uni.pred
+  %val = call i1 @llvm.nvvm.vote.uni.sync(i32 %mask, i1 %pred)
+  ret i1 %val
+}
+
+declare i32 @llvm.nvvm.vote.ballot.sync(i32, i1)
+; CHECK-LABEL: .func{{.*}}vote.sync.ballot
+define i32 @vote.sync.ballot(i32 %mask, i1 %pred) {
+  ; CHECK: vote.sync.ballot.b32
+  %val = call i32 @llvm.nvvm.vote.ballot.sync(i32 %mask, i1 %pred)
+  ret i32 %val
+}
Index: llvm/test/CodeGen/NVPTX/barrier.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/barrier.ll
@@ -0,0 +1,32 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_30 -mattr=+ptx60 | FileCheck %s
+
+declare void @llvm.nvvm.bar.warp.sync(i32)
+declare void @llvm.nvvm.barrier.sync(i32)
+declare void @llvm.nvvm.barrier.sync.cnt(i32, i32)
+
+; CHECK-LABEL: .func{{.*}}barrier.sync
+define void @barrier.sync(i32 %id, i32 %cnt) {
+  ; CHECK: ld.param.u32 	[[ID:%r[0-9]+]], [barrier.sync_param_0];
+  ; CHECK: ld.param.u32 	[[CNT:%r[0-9]+]], [barrier.sync_param_1];
+
+  ; CHECK:  barrier.sync [[ID]], [[CNT]];
+  call void @llvm.nvvm.barrier.sync.cnt(i32 %id, i32 %cnt)
+  ; CHECK:  barrier.sync [[ID]], 2;
+  call void @llvm.nvvm.barrier.sync.cnt(i32 %id, i32 2)
+  ; CHECK:  barrier.sync 3, [[CNT]];
+  call void @llvm.nvvm.barrier.sync.cnt(i32 3, i32 %cnt)
+  ; CHECK:  barrier.sync 4, 5;
+  call void @llvm.nvvm.barrier.sync.cnt(i32 4, i32 5)
+
+  ; CHECK: barrier.sync [[ID]];
+  call void @llvm.nvvm.barrier.sync(i32 %id)
+  ; CHECK: barrier.sync 1;
+  call void @llvm.nvvm.barrier.sync(i32 1)
+
+  ; CHECK: bar.warp.sync [[ID]];
+  call void @llvm.nvvm.bar.warp.sync(i32 %id)
+  ; CHECK: bar.warp.sync 6;
+  call void @llvm.nvvm.bar.warp.sync(i32 6)
+  ret void;
+}
+
Index: llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
===
--- llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -71,6 +71,38 @@
 def INT_BAR_SYNC : NVPTXInst<(outs), (ins i32imm:$i), "bar.sync \t$i;",
  [(int_nvvm_bar_sync imm:$i)]>;
 
+def INT_BAR_WARP_SYNC_I : NVPTXInst<(outs), (ins i32imm:$i), "bar.warp.sync \t$i;",
+ [(int_nvvm_bar_warp_sync imm:$i)]>,
+Requires<[hasPTX60, hasSM30]>;
+def INT_BAR_WARP_SYNC_R : NVPTXInst<(outs), (ins Int32Regs:$i), "bar.warp.sync \t$i;",
+ [(int_nvvm_bar_warp_sync Int32Regs:$i)]>,
+Requires<[hasPTX60, hasSM30]>;
+
+def INT_BARRIER_SYNC_I : NVPTXInst<(outs), (ins i32imm:$i), "barrier.sync \t$i;",
+   [(int_nvvm_barrier_sync imm:$i)]>,
+Requires<[hasPTX60, hasSM30]>;
+def INT_BARRIER_SYNC_R : NVPTXInst<(outs), (ins Int32Regs:$i), "barrier.sync \t$i;",
+   [(int_nvvm_b

[PATCH] D38145: Suppress Wsign-conversion for enums with matching underlying type

2017-09-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:8176
+return IntRange(C.getIntWidth(QualType(T, 0)),
+!ET->isSignedIntegerOrEnumerationType());
 

Maybe add a comment noting what can trigger this case?



Comment at: test/SemaCXX/sign-conversion.cpp:21
+  return foo;
+}

There's an existing file test/SemaCXX/warn-sign-conversion.cpp for C++ 
sign-conversion tests.


https://reviews.llvm.org/D38145



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


r313898 - [NVPTX] Implemented bar.warp.sync, barrier.sync, and vote{.sync} instructions/intrinsics/builtins.

2017-09-21 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Sep 21 11:44:49 2017
New Revision: 313898

URL: http://llvm.org/viewvc/llvm-project?rev=313898&view=rev
Log:
[NVPTX] Implemented bar.warp.sync, barrier.sync, and vote{.sync} 
instructions/intrinsics/builtins.

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
cfe/trunk/test/CodeGen/builtins-nvptx-ptx60.cu
cfe/trunk/test/CodeGen/builtins-nvptx.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=313898&r1=313897&r2=313898&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Thu Sep 21 11:44:49 2017
@@ -378,6 +378,9 @@ BUILTIN(__nvvm_bar0_popc, "ii", "")
 BUILTIN(__nvvm_bar0_and, "ii", "")
 BUILTIN(__nvvm_bar0_or, "ii", "")
 BUILTIN(__nvvm_bar_sync, "vi", "n")
+TARGET_BUILTIN(__nvvm_bar_warp_sync, "vUi", "n", "ptx60")
+TARGET_BUILTIN(__nvvm_barrier_sync, "vUi", "n", "ptx60")
+TARGET_BUILTIN(__nvvm_barrier_sync_cnt, "vUiUi", "n", "ptx60")
 
 // Shuffle
 
@@ -399,6 +402,17 @@ TARGET_BUILTIN(__nvvm_shfl_sync_bfly_f32
 TARGET_BUILTIN(__nvvm_shfl_sync_idx_i32, "iU", "", "ptx60")
 TARGET_BUILTIN(__nvvm_shfl_sync_idx_f32, "fUifii", "", "ptx60")
 
+// Vote
+BUILTIN(__nvvm_vote_all, "bb", "")
+BUILTIN(__nvvm_vote_any, "bb", "")
+BUILTIN(__nvvm_vote_uni, "bb", "")
+BUILTIN(__nvvm_vote_ballot, "Uib", "")
+
+TARGET_BUILTIN(__nvvm_vote_all_sync, "bUib", "", "ptx60")
+TARGET_BUILTIN(__nvvm_vote_any_sync, "bUib", "", "ptx60")
+TARGET_BUILTIN(__nvvm_vote_uni_sync, "bUib", "", "ptx60")
+TARGET_BUILTIN(__nvvm_vote_ballot_sync, "UiUib", "", "ptx60")
+
 // Membar
 
 BUILTIN(__nvvm_membar_cta, "v", "")

Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=313898&r1=313897&r2=313898&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Thu Sep 21 11:44:49 2017
@@ -157,6 +157,37 @@ __MAKE_SYNC_SHUFFLES(__shfl_sync_xor, __
 
 #pragma pop_macro("__MAKE_SYNC_SHUFFLES")
 
+inline __device__ void __syncwarp(unsigned int mask = 0x) {
+  return __nvvm_bar_warp_sync(mask);
+}
+
+inline __device__ void __barrier_sync(unsigned int id) {
+  __nvvm_barrier_sync(id);
+}
+
+inline __device__ void __barrier_sync_count(unsigned int id,
+unsigned int count) {
+  __nvvm_barrier_sync_cnt(id, count);
+}
+
+inline __device__ int __all_sync(unsigned int mask, int pred) {
+  return __nvvm_vote_sync_all(mask, pred);
+}
+
+inline __device__ int __any_sync(unsigned int mask, int pred) {
+  return __nvvm_vote_sync_any(mask, pred);
+}
+
+inline __device__ int __uni_sync(unsigned int mask, int pred) {
+  return __nvvm_vote_sync_uni(mask, pred);
+}
+
+inline __device__ unsigned int __ballot_sync(unsigned int mask, int pred) {
+  return __nvvm_vote_sync_ballot(mask, pred);
+}
+
+inline __device__ activemask() { return __nvvm_vote.ballot(1); }
+
 #endif // __CUDA_VERSION >= 9000 && (!defined(__CUDA_ARCH__) ||
// __CUDA_ARCH__ >= 300)
 

Modified: cfe/trunk/test/CodeGen/builtins-nvptx-ptx60.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-nvptx-ptx60.cu?rev=313898&r1=313897&r2=313898&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-nvptx-ptx60.cu (original)
+++ cfe/trunk/test/CodeGen/builtins-nvptx-ptx60.cu Thu Sep 21 11:44:49 2017
@@ -10,8 +10,27 @@
 #define __shared__ __attribute__((shared))
 #define __constant__ __attribute__((constant))
 
-// CHECK-LABEL: nvvm_shfl_sync
-__device__ void nvvm_shfl_sync(unsigned mask, int i, float f, int a, int b) {
+// We have to keep all builtins that depend on particular target feature in the
+// same function, because the codegen will stop after the very first function
+// that encounters an error, so -verify will not be able to find errors in
+// subsequent functions.
+
+// CHECK-LABEL: nvvm_sync
+__device__ void nvvm_sync(unsigned mask, int i, float f, int a, int b,
+  bool pred) {
+  // CHECK: call void @llvm.nvvm.bar.warp.sync(i32
+  // expected-error@+1 {{'__nvvm_bar_warp_sync' needs target feature ptx60}}
+  __nvvm_bar_warp_sync(mask);
+  // CHECK: call void @llvm.nvvm.barrier.sync(i32
+  // expected-error@+1 {{'__nvvm_barrier_sync' needs target feature ptx60}}
+  __nvvm_barrier_sync(mask);
+  // CHECK: call void @llvm.nvvm.barrier.sync.cnt(i32
+  // expected-error@+1 {{'__nvvm_barrier_sync_cnt' needs target feature ptx60}}
+  __nvvm_barrier_sync_cnt(mask, i);
+
+  //
+  // SHFL.SYNC
+  //

[PATCH] D38148: [NVPTX] Implemented bar.warp.sync, barrier.sync, and vote{.sync} instructions/intrinsics/builtins.

2017-09-21 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313898: [NVPTX] Implemented bar.warp.sync, barrier.sync, and 
vote{.sync}… (authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D38148?vs=116236&id=116237#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38148

Files:
  cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
  cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
  cfe/trunk/test/CodeGen/builtins-nvptx-ptx60.cu
  cfe/trunk/test/CodeGen/builtins-nvptx.c
  llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
  llvm/trunk/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/trunk/test/CodeGen/NVPTX/barrier.ll
  llvm/trunk/test/CodeGen/NVPTX/vote.ll

Index: llvm/trunk/lib/Target/NVPTX/NVPTXInstrInfo.td
===
--- llvm/trunk/lib/Target/NVPTX/NVPTXInstrInfo.td
+++ llvm/trunk/lib/Target/NVPTX/NVPTXInstrInfo.td
@@ -155,6 +155,9 @@
 def true : Predicate<"true">;
 
 def hasPTX31 : Predicate<"Subtarget->getPTXVersion() >= 31">;
+def hasPTX60 : Predicate<"Subtarget->getPTXVersion() >= 60">;
+
+def hasSM30 : Predicate<"Subtarget->getSmVersion() >= 30">;
 
 def useFP16Math: Predicate<"Subtarget->allowFP16Math()">;
 
Index: llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td
===
--- llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -71,6 +71,38 @@
 def INT_BAR_SYNC : NVPTXInst<(outs), (ins i32imm:$i), "bar.sync \t$i;",
  [(int_nvvm_bar_sync imm:$i)]>;
 
+def INT_BAR_WARP_SYNC_I : NVPTXInst<(outs), (ins i32imm:$i), "bar.warp.sync \t$i;",
+ [(int_nvvm_bar_warp_sync imm:$i)]>,
+Requires<[hasPTX60, hasSM30]>;
+def INT_BAR_WARP_SYNC_R : NVPTXInst<(outs), (ins Int32Regs:$i), "bar.warp.sync \t$i;",
+ [(int_nvvm_bar_warp_sync Int32Regs:$i)]>,
+Requires<[hasPTX60, hasSM30]>;
+
+def INT_BARRIER_SYNC_I : NVPTXInst<(outs), (ins i32imm:$i), "barrier.sync \t$i;",
+   [(int_nvvm_barrier_sync imm:$i)]>,
+Requires<[hasPTX60, hasSM30]>;
+def INT_BARRIER_SYNC_R : NVPTXInst<(outs), (ins Int32Regs:$i), "barrier.sync \t$i;",
+   [(int_nvvm_barrier_sync Int32Regs:$i)]>,
+Requires<[hasPTX60, hasSM30]>;
+
+def INT_BARRIER_SYNC_CNT_RR : NVPTXInst<(outs), (ins Int32Regs:$id, Int32Regs:$cnt),
+ "barrier.sync \t$id, $cnt;",
+ [(int_nvvm_barrier_sync_cnt Int32Regs:$id, Int32Regs:$cnt)]>,
+Requires<[hasPTX60, hasSM30]>;
+def INT_BARRIER_SYNC_CNT_RI : NVPTXInst<(outs), (ins Int32Regs:$id, i32imm:$cnt),
+ "barrier.sync \t$id, $cnt;",
+ [(int_nvvm_barrier_sync_cnt Int32Regs:$id, imm:$cnt)]>,
+Requires<[hasPTX60, hasSM30]>;
+def INT_BARRIER_SYNC_CNT_IR : NVPTXInst<(outs), (ins i32imm:$id, Int32Regs:$cnt),
+ "barrier.sync \t$id, $cnt;",
+ [(int_nvvm_barrier_sync_cnt imm:$id, Int32Regs:$cnt)]>,
+Requires<[hasPTX60, hasSM30]>;
+def INT_BARRIER_SYNC_CNT_II : NVPTXInst<(outs), (ins i32imm:$id, i32imm:$cnt),
+ "barrier.sync \t$id, $cnt;",
+ [(int_nvvm_barrier_sync_cnt imm:$id, imm:$cnt)]>,
+Requires<[hasPTX60, hasSM30]>;
+
+
 // shfl.{up,down,bfly,idx}.b32
 multiclass SHFL {
   // The last two parameters to shfl can be regs or imms.  ptxas is smart
@@ -184,6 +216,37 @@
 defm INT_SHFL_SYNC_IDX_I32 : SHFL_SYNC;
 defm INT_SHFL_SYNC_IDX_F32 : SHFL_SYNC;
 
+
+// vote.{all,any,uni,ballot}
+multiclass VOTE {
+  def : NVPTXInst<(outs regclass:$dest), (ins Int1Regs:$pred),
+  "vote." # mode # " \t$dest, $pred;",
+  [(set regclass:$dest, (IntOp Int1Regs:$pred))]>,
+Requires<[hasPTX60, hasSM30]>;
+}
+
+defm VOTE_ALL : VOTE;
+defm VOTE_ANY : VOTE;
+defm VOTE_UNI : VOTE;
+defm VOTE_BALLOT : VOTE;
+
+// vote.sync.{all,any,uni,ballot}
+multiclass VOTE_SYNC {
+  def i : NVPTXInst<(outs regclass:$dest), (ins i32imm:$mask, Int1Regs:$pred),
+  "vote.sync." # mode # " \t$dest, $pred, $mask;",
+  [(set regclass:$dest, (IntOp imm:$mask, Int1Regs:$pred))]>,
+  Requires<[hasPTX60, hasSM30]>;
+  def r : NVPTXInst<(outs regclass:$dest), (ins Int32Regs:$mask, Int1Regs:$pred),
+  "vote.sync." # mode #" \t$dest, $pred, $mask;",
+  [(set regclass:$dest, (IntOp Int32Regs:$mask, Int1Regs:$pred))]>,
+  Requires<[hasPTX60, hasSM30]>;
+}
+
+defm VOTE_SYNC_ALL : VOTE_SYNC;
+defm VOTE_SYNC_ANY : VOTE_SYNC;
+defm VOTE_SYNC_UNI : VOTE_SYNC;
+defm VOTE_SYNC_BALLOT : VOTE_SYNC;
+
 } // isConvergent = 1
 
 //---
Index: llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
===
--- llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td

r313899 - [CUDA] Fixed order of words in the names of shfl builtins.

2017-09-21 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Sep 21 11:46:39 2017
New Revision: 313899

URL: http://llvm.org/viewvc/llvm-project?rev=313899&view=rev
Log:
[CUDA] Fixed order of words in the names of shfl builtins.

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=313899&r1=313898&r2=313899&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Thu Sep 21 11:46:39 2017
@@ -148,13 +148,12 @@ __MAKE_SYNC_SHUFFLES(__shfl_sync, __nvvm
  __nvvm_shfl_sync_idx_f32, 0x1f);
 // We use 0 rather than 31 as our mask, because shfl.up applies to lanes >=
 // maxLane.
-__MAKE_SYNC_SHUFFLES(__shfl_sync_up, __nvvm_shfl_sync_up_i32,
+__MAKE_SYNC_SHUFFLES(__shfl_up_sync, __nvvm_shfl_sync_up_i32,
  __nvvm_shfl_sync_up_f32, 0);
-__MAKE_SYNC_SHUFFLES(__shfl_sync_down, __nvvm_shfl_sync_down_i32,
+__MAKE_SYNC_SHUFFLES(__shfl_down_sync, __nvvm_shfl_sync_down_i32,
  __nvvm_shfl_sync_down_f32, 0x1f);
-__MAKE_SYNC_SHUFFLES(__shfl_sync_xor, __nvvm_shfl_sync_bfly_i32,
+__MAKE_SYNC_SHUFFLES(__shfl_xor_sync, __nvvm_shfl_sync_bfly_i32,
  __nvvm_shfl_sync_bfly_f32, 0x1f);
-
 #pragma pop_macro("__MAKE_SYNC_SHUFFLES")
 
 inline __device__ void __syncwarp(unsigned int mask = 0x) {


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


[PATCH] D38147: [CUDA] Fixed order of words in the names of shfl builtins.

2017-09-21 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313899: [CUDA] Fixed order of words in the names of shfl 
builtins. (authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D38147?vs=116228&id=116238#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38147

Files:
  cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h


Index: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
@@ -148,13 +148,12 @@
  __nvvm_shfl_sync_idx_f32, 0x1f);
 // We use 0 rather than 31 as our mask, because shfl.up applies to lanes >=
 // maxLane.
-__MAKE_SYNC_SHUFFLES(__shfl_sync_up, __nvvm_shfl_sync_up_i32,
+__MAKE_SYNC_SHUFFLES(__shfl_up_sync, __nvvm_shfl_sync_up_i32,
  __nvvm_shfl_sync_up_f32, 0);
-__MAKE_SYNC_SHUFFLES(__shfl_sync_down, __nvvm_shfl_sync_down_i32,
+__MAKE_SYNC_SHUFFLES(__shfl_down_sync, __nvvm_shfl_sync_down_i32,
  __nvvm_shfl_sync_down_f32, 0x1f);
-__MAKE_SYNC_SHUFFLES(__shfl_sync_xor, __nvvm_shfl_sync_bfly_i32,
+__MAKE_SYNC_SHUFFLES(__shfl_xor_sync, __nvvm_shfl_sync_bfly_i32,
  __nvvm_shfl_sync_bfly_f32, 0x1f);
-
 #pragma pop_macro("__MAKE_SYNC_SHUFFLES")
 
 inline __device__ void __syncwarp(unsigned int mask = 0x) {


Index: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
@@ -148,13 +148,12 @@
  __nvvm_shfl_sync_idx_f32, 0x1f);
 // We use 0 rather than 31 as our mask, because shfl.up applies to lanes >=
 // maxLane.
-__MAKE_SYNC_SHUFFLES(__shfl_sync_up, __nvvm_shfl_sync_up_i32,
+__MAKE_SYNC_SHUFFLES(__shfl_up_sync, __nvvm_shfl_sync_up_i32,
  __nvvm_shfl_sync_up_f32, 0);
-__MAKE_SYNC_SHUFFLES(__shfl_sync_down, __nvvm_shfl_sync_down_i32,
+__MAKE_SYNC_SHUFFLES(__shfl_down_sync, __nvvm_shfl_sync_down_i32,
  __nvvm_shfl_sync_down_f32, 0x1f);
-__MAKE_SYNC_SHUFFLES(__shfl_sync_xor, __nvvm_shfl_sync_bfly_i32,
+__MAKE_SYNC_SHUFFLES(__shfl_xor_sync, __nvvm_shfl_sync_bfly_i32,
  __nvvm_shfl_sync_bfly_f32, 0x1f);
-
 #pragma pop_macro("__MAKE_SYNC_SHUFFLES")
 
 inline __device__ void __syncwarp(unsigned int mask = 0x) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target

2017-09-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D38046



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


[PATCH] D38145: Suppress Wsign-conversion for enums with matching underlying type

2017-09-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 116244.
erichkeane marked 2 inline comments as done.
erichkeane added a comment.

Updated based on Eli's feedback.


https://reviews.llvm.org/D38145

Files:
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/warn-sign-conversion-cpp11.cpp


Index: test/SemaCXX/warn-sign-conversion-cpp11.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-sign-conversion-cpp11.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion -std=c++11 %s
+
+unsigned int test() {
+  short foo;
+  return foo; // expected-warning {{implicit conversion changes signedness}}
+
+}
+
+unsigned int test3() {
+  // For a non-defined enum, use the underlying type.
+  enum u8 : char;
+  u8 foo{static_cast(0)};
+  return foo; // expected-warning {{implicit conversion changes signedness}}
+
+}
+unsigned int test2() {
+  // For a non-defined enum, use the underlying type.
+  enum u8 : unsigned char;
+  u8 foo{static_cast(0)};
+  return foo;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -8171,8 +8171,12 @@
 // For enum types, use the known bit width of the enumerators.
 if (const EnumType *ET = dyn_cast(T)) {
   EnumDecl *Enum = ET->getDecl();
+  // Enums without definitions should use the signed-ness of the
+  // underlying type, so that when someone specifies the type as
+  // "unsigned" it doesn't cause sign-conversion type warnings.
   if (!Enum->isCompleteDefinition())
-return IntRange(C.getIntWidth(QualType(T, 0)), false);
+return IntRange(C.getIntWidth(QualType(T, 0)),
+!ET->isSignedIntegerOrEnumerationType());
 
   unsigned NumPositive = Enum->getNumPositiveBits();
   unsigned NumNegative = Enum->getNumNegativeBits();


Index: test/SemaCXX/warn-sign-conversion-cpp11.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-sign-conversion-cpp11.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion -std=c++11 %s
+
+unsigned int test() {
+  short foo;
+  return foo; // expected-warning {{implicit conversion changes signedness}}
+
+}
+
+unsigned int test3() {
+  // For a non-defined enum, use the underlying type.
+  enum u8 : char;
+  u8 foo{static_cast(0)};
+  return foo; // expected-warning {{implicit conversion changes signedness}}
+
+}
+unsigned int test2() {
+  // For a non-defined enum, use the underlying type.
+  enum u8 : unsigned char;
+  u8 foo{static_cast(0)};
+  return foo;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -8171,8 +8171,12 @@
 // For enum types, use the known bit width of the enumerators.
 if (const EnumType *ET = dyn_cast(T)) {
   EnumDecl *Enum = ET->getDecl();
+  // Enums without definitions should use the signed-ness of the
+  // underlying type, so that when someone specifies the type as
+  // "unsigned" it doesn't cause sign-conversion type warnings.
   if (!Enum->isCompleteDefinition())
-return IntRange(C.getIntWidth(QualType(T, 0)), false);
+return IntRange(C.getIntWidth(QualType(T, 0)),
+!ET->isSignedIntegerOrEnumerationType());
 
   unsigned NumPositive = Enum->getNumPositiveBits();
   unsigned NumNegative = Enum->getNumNegativeBits();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38145: Suppress Wsign-conversion for enums with matching underlying type

2017-09-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:8176
+  // underlying type, so that when someone specifies the type as
+  // "unsigned" it doesn't cause sign-conversion type warnings.
   if (!Enum->isCompleteDefinition())

Explicitly referencing sign-conversion warnings here isn't really helpful.  
Maybe something more like "Incomplete enums without definitions can have an 
explicitly specified underlying type. Use that type here to compute the range."



Comment at: test/SemaCXX/warn-sign-conversion-cpp11.cpp:11
+  // For a non-defined enum, use the underlying type.
+  enum u8 : char;
+  u8 foo{static_cast(0)};

The signedness of "char" can vary based on the host; probably simplest to write 
out "signed char".


https://reviews.llvm.org/D38145



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


[PATCH] D38145: Suppress Wsign-conversion for enums with matching underlying type

2017-09-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:8176
+  // underlying type, so that when someone specifies the type as
+  // "unsigned" it doesn't cause sign-conversion type warnings.
   if (!Enum->isCompleteDefinition())

efriedma wrote:
> Explicitly referencing sign-conversion warnings here isn't really helpful.  
> Maybe something more like "Incomplete enums without definitions can have an 
> explicitly specified underlying type. Use that type here to compute the 
> range."
Ok, got it.  I DO note that (IIRC) enums with an underlying type are not 
considered 'incomplete', so I modified your text slightly.  Thanks for the help.



Comment at: test/SemaCXX/sign-conversion.cpp:21
+  return foo;
+}

efriedma wrote:
> There's an existing file test/SemaCXX/warn-sign-conversion.cpp for C++ 
> sign-conversion tests.
Thanks for pointing that out! Unfortunately, that file is very dependent on it 
being C++98, and this test requires c++11 or greater.  I DID rename the test 
file to better match that one however.



Comment at: test/SemaCXX/warn-sign-conversion-cpp11.cpp:11
+  // For a non-defined enum, use the underlying type.
+  enum u8 : char;
+  u8 foo{static_cast(0)};

efriedma wrote:
> The signedness of "char" can vary based on the host; probably simplest to 
> write out "signed char".
Right, good catch.


https://reviews.llvm.org/D38145



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


[PATCH] D38145: Suppress Wsign-conversion for enums with matching underlying type

2017-09-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 116245.
erichkeane marked an inline comment as done.

https://reviews.llvm.org/D38145

Files:
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/warn-sign-conversion-cpp11.cpp


Index: test/SemaCXX/warn-sign-conversion-cpp11.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-sign-conversion-cpp11.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion -std=c++11 %s
+
+unsigned int test() {
+  short foo;
+  return foo; // expected-warning {{implicit conversion changes signedness}}
+
+}
+
+unsigned int test3() {
+  // For a non-defined enum, use the underlying type.
+  enum u8 : signed char;
+  u8 foo{static_cast(0)};
+  return foo; // expected-warning {{implicit conversion changes signedness}}
+
+}
+unsigned int test2() {
+  // For a non-defined enum, use the underlying type.
+  enum u8 : unsigned char;
+  u8 foo{static_cast(0)};
+  return foo;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -8171,8 +8171,11 @@
 // For enum types, use the known bit width of the enumerators.
 if (const EnumType *ET = dyn_cast(T)) {
   EnumDecl *Enum = ET->getDecl();
+  // In C++11, enums without definitions can have an explicitly specified
+  // underlying type.  Use this type to compute the range.
   if (!Enum->isCompleteDefinition())
-return IntRange(C.getIntWidth(QualType(T, 0)), false);
+return IntRange(C.getIntWidth(QualType(T, 0)),
+!ET->isSignedIntegerOrEnumerationType());
 
   unsigned NumPositive = Enum->getNumPositiveBits();
   unsigned NumNegative = Enum->getNumNegativeBits();


Index: test/SemaCXX/warn-sign-conversion-cpp11.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-sign-conversion-cpp11.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion -std=c++11 %s
+
+unsigned int test() {
+  short foo;
+  return foo; // expected-warning {{implicit conversion changes signedness}}
+
+}
+
+unsigned int test3() {
+  // For a non-defined enum, use the underlying type.
+  enum u8 : signed char;
+  u8 foo{static_cast(0)};
+  return foo; // expected-warning {{implicit conversion changes signedness}}
+
+}
+unsigned int test2() {
+  // For a non-defined enum, use the underlying type.
+  enum u8 : unsigned char;
+  u8 foo{static_cast(0)};
+  return foo;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -8171,8 +8171,11 @@
 // For enum types, use the known bit width of the enumerators.
 if (const EnumType *ET = dyn_cast(T)) {
   EnumDecl *Enum = ET->getDecl();
+  // In C++11, enums without definitions can have an explicitly specified
+  // underlying type.  Use this type to compute the range.
   if (!Enum->isCompleteDefinition())
-return IntRange(C.getIntWidth(QualType(T, 0)), false);
+return IntRange(C.getIntWidth(QualType(T, 0)),
+!ET->isSignedIntegerOrEnumerationType());
 
   unsigned NumPositive = Enum->getNumPositiveBits();
   unsigned NumNegative = Enum->getNumNegativeBits();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38145: Suppress Wsign-conversion for enums with matching underlying type

2017-09-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D38145



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


r313906 - [Sema] Prevent InstantiateClass from checking unrelated exception specs.

2017-09-21 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Thu Sep 21 12:54:12 2017
New Revision: 313906

URL: http://llvm.org/viewvc/llvm-project?rev=313906&view=rev
Log:
[Sema] Prevent InstantiateClass from checking unrelated exception specs.

Sema::InstantiateClass should check only exception specs added during
class instantiation and ignore already present delayed specs. This fixes
a case where we instantiate a class before parsing member initializers,
check exceptions for a different class and fail to find a member
initializer. Which is required for comparing exception specs for
explicitly-defaulted and implicit default constructor. With the fix we
are still checking exception specs but only after member initializers
are present.

Removing errors in crash-unparsed-exception.cpp is acceptable according
to discussion in PR24000 because other compilers accept code in
crash-unparsed-exception.cpp as valid.

rdar://problem/34167492

Reviewers: davide, rsmith

Reviewed By: rsmith

Subscribers: dim, cfe-commits

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


Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/test/SemaTemplate/crash-unparsed-exception.cpp
cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=313906&r1=313905&r2=313906&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Sep 21 12:54:12 2017
@@ -10503,6 +10503,36 @@ public:
   SmallVector DelayedDllExportClasses;
 
 private:
+  class SavePendingParsedClassStateRAII {
+  public:
+SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
+
+~SavePendingParsedClassStateRAII() {
+  assert(S.DelayedExceptionSpecChecks.empty() &&
+ "there shouldn't be any pending delayed exception spec checks");
+  assert(S.DelayedDefaultedMemberExceptionSpecs.empty() &&
+ "there shouldn't be any pending delayed defaulted member "
+ "exception specs");
+  assert(S.DelayedDllExportClasses.empty() &&
+ "there shouldn't be any pending delayed DLL export classes");
+  swapSavedState();
+}
+
+  private:
+Sema &S;
+decltype(DelayedExceptionSpecChecks) SavedExceptionSpecChecks;
+decltype(DelayedDefaultedMemberExceptionSpecs)
+SavedDefaultedMemberExceptionSpecs;
+decltype(DelayedDllExportClasses) SavedDllExportClasses;
+
+void swapSavedState() {
+  SavedExceptionSpecChecks.swap(S.DelayedExceptionSpecChecks);
+  SavedDefaultedMemberExceptionSpecs.swap(
+  S.DelayedDefaultedMemberExceptionSpecs);
+  SavedDllExportClasses.swap(S.DelayedDllExportClasses);
+}
+  };
+
   /// \brief Helper class that collects misaligned member designations and
   /// their location info for delayed diagnostics.
   struct MisalignedMember {

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=313906&r1=313905&r2=313906&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Thu Sep 21 12:54:12 2017
@@ -2026,12 +2026,11 @@ Sema::InstantiateClass(SourceLocation Po
   bool MergeWithParentScope = 
!Instantiation->isDefinedOutsideFunctionOrMethod();
   LocalInstantiationScope Scope(*this, MergeWithParentScope);
 
-  // All dllexported classes created during instantiation should be fully
-  // emitted after instantiation completes. We may not be ready to emit any
-  // delayed classes already on the stack, so save them away and put them back
-  // later.
-  decltype(DelayedDllExportClasses) ExportedClasses;
-  std::swap(ExportedClasses, DelayedDllExportClasses);
+  // Some class state isn't processed immediately but delayed till class
+  // instantiation completes. We may not be ready to handle any delayed state
+  // already on the stack as it might correspond to a different class, so save
+  // it now and put it back later.
+  SavePendingParsedClassStateRAII SavedPendingParsedClassState(*this);
 
   // Pull attributes from the pattern onto the instantiation.
   InstantiateAttrs(TemplateArgs, Pattern, Instantiation);
@@ -2118,9 +2117,6 @@ Sema::InstantiateClass(SourceLocation Po
   // default arg exprs for default constructors if necessary now.
   ActOnFinishCXXNonNestedClass(Instantiation);
 
-  // Put back the delayed exported classes that we moved out of the way.
-  std::swap(ExportedClasses, DelayedDllExportClasses);
-
   // Instantiate late parsed attributes, and attach them to their decls.
   // See Sema::InstantiateAttrs
   for (LateInstantiatedAttrVec::iterator I = LateAttrs.begin(),

Modified: cfe/trunk/test/SemaTemplate

[PATCH] D37881: [Sema] Prevent InstantiateClass from checking unrelated exception specs.

2017-09-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313906: [Sema] Prevent InstantiateClass from checking 
unrelated exception specs. (authored by vsapsai).

Changed prior to commit:
  https://reviews.llvm.org/D37881?vs=116056&id=116250#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37881

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
  cfe/trunk/test/SemaTemplate/crash-unparsed-exception.cpp
  cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp

Index: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2026,12 +2026,11 @@
   bool MergeWithParentScope = !Instantiation->isDefinedOutsideFunctionOrMethod();
   LocalInstantiationScope Scope(*this, MergeWithParentScope);
 
-  // All dllexported classes created during instantiation should be fully
-  // emitted after instantiation completes. We may not be ready to emit any
-  // delayed classes already on the stack, so save them away and put them back
-  // later.
-  decltype(DelayedDllExportClasses) ExportedClasses;
-  std::swap(ExportedClasses, DelayedDllExportClasses);
+  // Some class state isn't processed immediately but delayed till class
+  // instantiation completes. We may not be ready to handle any delayed state
+  // already on the stack as it might correspond to a different class, so save
+  // it now and put it back later.
+  SavePendingParsedClassStateRAII SavedPendingParsedClassState(*this);
 
   // Pull attributes from the pattern onto the instantiation.
   InstantiateAttrs(TemplateArgs, Pattern, Instantiation);
@@ -2118,9 +2117,6 @@
   // default arg exprs for default constructors if necessary now.
   ActOnFinishCXXNonNestedClass(Instantiation);
 
-  // Put back the delayed exported classes that we moved out of the way.
-  std::swap(ExportedClasses, DelayedDllExportClasses);
-
   // Instantiate late parsed attributes, and attach them to their decls.
   // See Sema::InstantiateAttrs
   for (LateInstantiatedAttrVec::iterator I = LateAttrs.begin(),
Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -10503,6 +10503,36 @@
   SmallVector DelayedDllExportClasses;
 
 private:
+  class SavePendingParsedClassStateRAII {
+  public:
+SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
+
+~SavePendingParsedClassStateRAII() {
+  assert(S.DelayedExceptionSpecChecks.empty() &&
+ "there shouldn't be any pending delayed exception spec checks");
+  assert(S.DelayedDefaultedMemberExceptionSpecs.empty() &&
+ "there shouldn't be any pending delayed defaulted member "
+ "exception specs");
+  assert(S.DelayedDllExportClasses.empty() &&
+ "there shouldn't be any pending delayed DLL export classes");
+  swapSavedState();
+}
+
+  private:
+Sema &S;
+decltype(DelayedExceptionSpecChecks) SavedExceptionSpecChecks;
+decltype(DelayedDefaultedMemberExceptionSpecs)
+SavedDefaultedMemberExceptionSpecs;
+decltype(DelayedDllExportClasses) SavedDllExportClasses;
+
+void swapSavedState() {
+  SavedExceptionSpecChecks.swap(S.DelayedExceptionSpecChecks);
+  SavedDefaultedMemberExceptionSpecs.swap(
+  S.DelayedDefaultedMemberExceptionSpecs);
+  SavedDllExportClasses.swap(S.DelayedDllExportClasses);
+}
+  };
+
   /// \brief Helper class that collects misaligned member designations and
   /// their location info for delayed diagnostics.
   struct MisalignedMember {
Index: cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
===
--- cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
+++ cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -87,3 +87,30 @@
 A<1> m_target;
   };
 }
+
+// rdar://problem/34167492
+// Template B is instantiated during checking if defaulted A copy constructor
+// is constexpr. For this we check if S copy constructor is constexpr. And
+// for this we check S constructor template with default argument that mentions
+// template B. In  turn, template instantiation triggers checking defaulted
+// members exception spec. The problem is that it checks defaulted members not
+// for instantiated class only, but all defaulted members so far. In this case
+// we try to check exception spec for A default constructor which requires
+// initializer for the field _a. But initializers are added after constexpr
+// check so we reject the code because cannot find _a initializer.
+namespace rdar34167492 {
+  template  struct B { using type = bool; };
+
+  template  struct S {
+S() noexcept;
+
+template ::type = true>
+S(const S&) noexcept;

[PATCH] D37861: preserving #pragma clang assume_nonnull in preprocessed output

2017-09-21 Thread Zbigniew Sarbinowski via Phabricator via cfe-commits
zibi added a comment.

ping


https://reviews.llvm.org/D37861



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


r313907 - Suppress Wsign-conversion for enums with matching underlying type

2017-09-21 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Sep 21 12:58:55 2017
New Revision: 313907

URL: http://llvm.org/viewvc/llvm-project?rev=313907&view=rev
Log:
Suppress Wsign-conversion for enums with matching underlying type

As reported here: https://bugs.llvm.org/show_bug.cgi?id=34692

A non-defined enum with a backing type was always defaulting to
being treated as a signed type. IN the case where it IS defined,
the signed-ness of the actual items is used.

This patch uses the underlying type's signed-ness in the non-defined
case to test signed-comparision.

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=313907&r1=313906&r2=313907&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Sep 21 12:58:55 2017
@@ -8171,8 +8171,11 @@ struct IntRange {
 // For enum types, use the known bit width of the enumerators.
 if (const EnumType *ET = dyn_cast(T)) {
   EnumDecl *Enum = ET->getDecl();
+  // In C++11, enums without definitions can have an explicitly specified
+  // underlying type.  Use this type to compute the range.
   if (!Enum->isCompleteDefinition())
-return IntRange(C.getIntWidth(QualType(T, 0)), false);
+return IntRange(C.getIntWidth(QualType(T, 0)),
+!ET->isSignedIntegerOrEnumerationType());
 
   unsigned NumPositive = Enum->getNumPositiveBits();
   unsigned NumNegative = Enum->getNumNegativeBits();


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


[PATCH] D38145: Suppress Wsign-conversion for enums with matching underlying type

2017-09-21 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313907: Suppress Wsign-conversion for enums with matching 
underlying type (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D38145?vs=116245&id=116252#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38145

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp


Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -8171,8 +8171,11 @@
 // For enum types, use the known bit width of the enumerators.
 if (const EnumType *ET = dyn_cast(T)) {
   EnumDecl *Enum = ET->getDecl();
+  // In C++11, enums without definitions can have an explicitly specified
+  // underlying type.  Use this type to compute the range.
   if (!Enum->isCompleteDefinition())
-return IntRange(C.getIntWidth(QualType(T, 0)), false);
+return IntRange(C.getIntWidth(QualType(T, 0)),
+!ET->isSignedIntegerOrEnumerationType());
 
   unsigned NumPositive = Enum->getNumPositiveBits();
   unsigned NumNegative = Enum->getNumNegativeBits();


Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -8171,8 +8171,11 @@
 // For enum types, use the known bit width of the enumerators.
 if (const EnumType *ET = dyn_cast(T)) {
   EnumDecl *Enum = ET->getDecl();
+  // In C++11, enums without definitions can have an explicitly specified
+  // underlying type.  Use this type to compute the range.
   if (!Enum->isCompleteDefinition())
-return IntRange(C.getIntWidth(QualType(T, 0)), false);
+return IntRange(C.getIntWidth(QualType(T, 0)),
+!ET->isSignedIntegerOrEnumerationType());
 
   unsigned NumPositive = Enum->getNumPositiveBits();
   unsigned NumNegative = Enum->getNumNegativeBits();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38151: [clang] Fix isExternC matcher docs

2017-09-21 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.
Herald added a subscriber: klimek.

The wording in the documentation for the matcher isExternC appears to be 
misleading since this
matcher is applicable to functions and variables as well. 
This diff changes the comment regenerates the html file.


Repository:
  rL LLVM

https://reviews.llvm.org/D38151

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h


Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3533,16 +3533,21 @@
   return InnerMatcher.matches(Node.getReturnType(), Finder, Builder);
 }
 
-/// \brief Matches extern "C" function declarations.
+/// \brief Matches extern "C" function or variable declarations.
 ///
 /// Given:
 /// \code
 ///   extern "C" void f() {}
 ///   extern "C" { void g() {} }
 ///   void h() {}
+///   extern "C" int x = 1;
+///   extern "C" int y = 2;
+///   int z = 3;
 /// \endcode
 /// functionDecl(isExternC())
-///   matches the declaration of f and g, but not the declaration h
+///   matches the declaration of f and g, but not the declaration of h.
+/// varDecl(isExternC())
+///   matches the declaration of x and y, but not the declaration of z.
 AST_POLYMORPHIC_MATCHER(isExternC, 
AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
VarDecl)) {
   return Node.isExternC();
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2741,19 +2741,22 @@
 Usable as: MatcherFunctionDecl>,
 MatcherVarDecl>,
 MatcherCXXRecordDecl>
 
 
-
 MatcherFunctionDecl>isExternC
-Matches extern "C" 
function declarations.
+Matches extern "C" 
function or variable declarations.
 
 Given:
   extern "C" void f() {}
   extern "C" { void g() {} }
   void h() {}
+  extern "C" int x = 1;
+  extern "C" int y = 2;
+  int z = 3;
 functionDecl(isExternC())
-  matches the declaration of f and g, but not the declaration h
+  matches the declaration of f and g, but not the declaration of h.
+varDecl(isExternC())
+  matches the declaration of x and y, but not the declaration of z.
 
 
-
 MatcherFunctionDecl>isInline
 Matches function and 
namespace declarations that are marked with
 the inline keyword.
@@ -3680,19 +3683,22 @@
 Usable as: MatcherFunctionDecl>,
 MatcherVarDecl>,
 MatcherCXXRecordDecl>
 
 
-
 MatcherVarDecl>isExternC
-Matches extern "C" 
function declarations.
+Matches extern "C" 
function or variable declarations.
 
 Given:
   extern "C" void f() {}
   extern "C" { void g() {} }
   void h() {}
+  extern "C" int x = 1;
+  extern "C" int y = 2;
+  int z = 3;
 functionDecl(isExternC())
-  matches the declaration of f and g, but not the declaration h
+  matches the declaration of f and g, but not the declaration of h.
+varDecl(isExternC())
+  matches the declaration of x and y, but not the declaration of z.
 
 
-
 MatcherVarDecl>isStaticStorageClass
 Matches 
variablefunction declarations that have "static" storage
 class specifier ("static" keyword) written in the source.


Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3533,16 +3533,21 @@
   return InnerMatcher.matches(Node.getReturnType(), Finder, Builder);
 }
 
-/// \brief Matches extern "C" function declarations.
+/// \brief Matches extern "C" function or variable declarations.
 ///
 /// Given:
 /// \code
 ///   extern "C" void f() {}
 ///   extern "C" { void g() {} }
 ///   void h() {}
+///   extern "C" int x = 1;
+///   extern "C" int y = 2;
+///   int z = 3;
 /// \endcode
 /// functionDecl(isExternC())
-///   matches the declaration of f and g, but not the declaration h
+///   matches the declaration of f and g, but not the declaration of h.
+/// varDecl(isExternC())
+///   matches the declaration of x and y, but not the declaration of z.
 AST_POLYMORPHIC_MATCHER(isExternC, AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
VarDecl)) {
   return Node.isExternC();
Index: docs/LibASTMatchersRe

Re: r313907 - Suppress Wsign-conversion for enums with matching underlying type

2017-09-21 Thread Friedman, Eli via cfe-commits

On 9/21/2017 12:58 PM, Erich Keane via cfe-commits wrote:

Author: erichkeane
Date: Thu Sep 21 12:58:55 2017
New Revision: 313907

URL: http://llvm.org/viewvc/llvm-project?rev=313907&view=rev
Log:
Suppress Wsign-conversion for enums with matching underlying type

As reported here: https://bugs.llvm.org/show_bug.cgi?id=34692

A non-defined enum with a backing type was always defaulting to
being treated as a signed type. IN the case where it IS defined,
the signed-ness of the actual items is used.

This patch uses the underlying type's signed-ness in the non-defined
case to test signed-comparision.

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

Modified:
 cfe/trunk/lib/Sema/SemaChecking.cpp


Missing testcase?

-El

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

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


RE: r313907 - Suppress Wsign-conversion for enums with matching underlying type

2017-09-21 Thread Keane, Erich via cfe-commits
Ugg... good catch, thanks.

-Original Message-
From: Friedman, Eli [mailto:efrie...@codeaurora.org] 
Sent: Thursday, September 21, 2017 1:14 PM
To: Keane, Erich ; cfe-commits@lists.llvm.org
Subject: Re: r313907 - Suppress Wsign-conversion for enums with matching 
underlying type

On 9/21/2017 12:58 PM, Erich Keane via cfe-commits wrote:
> Author: erichkeane
> Date: Thu Sep 21 12:58:55 2017
> New Revision: 313907
>
> URL: http://llvm.org/viewvc/llvm-project?rev=313907&view=rev
> Log:
> Suppress Wsign-conversion for enums with matching underlying type
>
> As reported here: https://bugs.llvm.org/show_bug.cgi?id=34692
>
> A non-defined enum with a backing type was always defaulting to being 
> treated as a signed type. IN the case where it IS defined, the 
> signed-ness of the actual items is used.
>
> This patch uses the underlying type's signed-ness in the non-defined 
> case to test signed-comparision.
>
> Differential Revision: https://reviews.llvm.org/D38145
>
> Modified:
>  cfe/trunk/lib/Sema/SemaChecking.cpp

Missing testcase?

-El

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

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


r313909 - Add testcase I forgot to add in R313907.

2017-09-21 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Sep 21 13:14:08 2017
New Revision: 313909

URL: http://llvm.org/viewvc/llvm-project?rev=313909&view=rev
Log:
Add testcase I forgot to add in R313907.

Added:
cfe/trunk/test/SemaCXX/warn-sign-conversion-cpp11.cpp   (with props)

Added: cfe/trunk/test/SemaCXX/warn-sign-conversion-cpp11.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-sign-conversion-cpp11.cpp?rev=313909&view=auto
==
--- cfe/trunk/test/SemaCXX/warn-sign-conversion-cpp11.cpp (added)
+++ cfe/trunk/test/SemaCXX/warn-sign-conversion-cpp11.cpp Thu Sep 21 13:14:08 
2017
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion -std=c++11 %s
+
+unsigned int test() {
+  short foo;
+  return foo; // expected-warning {{implicit conversion changes signedness}}
+
+}
+
+unsigned int test3() {
+  // For a non-defined enum, use the underlying type.
+  enum u8 : signed char;
+  u8 foo{static_cast(0)};
+  return foo; // expected-warning {{implicit conversion changes signedness}}
+
+}
+unsigned int test2() {
+  // For a non-defined enum, use the underlying type.
+  enum u8 : unsigned char;
+  u8 foo{static_cast(0)};
+  return foo;
+}

Propchange: cfe/trunk/test/SemaCXX/warn-sign-conversion-cpp11.cpp
--
svn:eol-style = native

Propchange: cfe/trunk/test/SemaCXX/warn-sign-conversion-cpp11.cpp
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/SemaCXX/warn-sign-conversion-cpp11.cpp
--
svn:mime-type = text/plain


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


RE: r313907 - Suppress Wsign-conversion for enums with matching underlying type

2017-09-21 Thread Keane, Erich via cfe-commits
Fixed in 313909.

-Original Message-
From: Friedman, Eli [mailto:efrie...@codeaurora.org] 
Sent: Thursday, September 21, 2017 1:14 PM
To: Keane, Erich ; cfe-commits@lists.llvm.org
Subject: Re: r313907 - Suppress Wsign-conversion for enums with matching 
underlying type

On 9/21/2017 12:58 PM, Erich Keane via cfe-commits wrote:
> Author: erichkeane
> Date: Thu Sep 21 12:58:55 2017
> New Revision: 313907
>
> URL: http://llvm.org/viewvc/llvm-project?rev=313907&view=rev
> Log:
> Suppress Wsign-conversion for enums with matching underlying type
>
> As reported here: https://bugs.llvm.org/show_bug.cgi?id=34692
>
> A non-defined enum with a backing type was always defaulting to being 
> treated as a signed type. IN the case where it IS defined, the 
> signed-ness of the actual items is used.
>
> This patch uses the underlying type's signed-ness in the non-defined 
> case to test signed-comparision.
>
> Differential Revision: https://reviews.llvm.org/D38145
>
> Modified:
>  cfe/trunk/lib/Sema/SemaChecking.cpp

Missing testcase?

-El

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

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


r313911 - Remove svn-properties for file added in 313909 (NFC)

2017-09-21 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Sep 21 13:31:01 2017
New Revision: 313911

URL: http://llvm.org/viewvc/llvm-project?rev=313911&view=rev
Log:
Remove svn-properties for file added in 313909 (NFC)

Modified:
cfe/trunk/test/SemaCXX/warn-sign-conversion-cpp11.cpp   (props changed)

Propchange: cfe/trunk/test/SemaCXX/warn-sign-conversion-cpp11.cpp
--
--- svn:eol-style (original)
+++ svn:eol-style (removed)
@@ -1 +0,0 @@
-native

Propchange: cfe/trunk/test/SemaCXX/warn-sign-conversion-cpp11.cpp
--
--- svn:keywords (original)
+++ svn:keywords (removed)
@@ -1 +0,0 @@
-Author Date Id Rev URL

Propchange: cfe/trunk/test/SemaCXX/warn-sign-conversion-cpp11.cpp
--
--- svn:mime-type (original)
+++ svn:mime-type (removed)
@@ -1 +0,0 @@
-text/plain


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


[PATCH] D38040: [OpenMP] Add an additional test for D34888

2017-09-21 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

Hi Doru,

if I remember correctly I submitted https://reviews.llvm.org/D34888 for a crash 
when mapping a scalar value with nested regions.
I've marked another test in this file that the codegen for `tofrom` is correct. 
So I don't know if this test checks some other conditions?

Jonas




Comment at: test/OpenMP/target_map_codegen.cpp:1773
   // CK19: call void [[CALL23:@.+]](i32* {{[^,]+}})
   #pragma omp target map(always, tofrom: a)
   {

`tofrom` is tested here...


Repository:
  rL LLVM

https://reviews.llvm.org/D38040



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


r313913 - [libclang] Keep track of TranslationUnit instance when annotating tokens

2017-09-21 Thread Jonathan Coe via cfe-commits
Author: jbcoe
Date: Thu Sep 21 13:48:43 2017
New Revision: 313913

URL: http://llvm.org/viewvc/llvm-project?rev=313913&view=rev
Log:
[libclang] Keep track of TranslationUnit instance when annotating tokens

Summary:
Previously the `_tu` was not propagated to the returned cursor, leading to 
errors when calling any
method on that cursor (e.g. `cursor.referenced`).

Reviewers: jbcoe, rsmith

Reviewed By: jbcoe

Subscribers: cfe-commits

Tags: #clang

Patch by jklaehn (Johann Klähn)

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/bindings/python/tests/cindex/test_cursor.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=313913&r1=313912&r2=313913&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Thu Sep 21 13:48:43 2017
@@ -3216,6 +3216,7 @@ class Token(Structure):
 def cursor(self):
 """The Cursor this Token corresponds to."""
 cursor = Cursor()
+cursor._tu = self._tu
 
 conf.lib.clang_annotateTokens(self._tu, byref(self), 1, byref(cursor))
 

Modified: cfe/trunk/bindings/python/tests/cindex/test_cursor.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cursor.py?rev=313913&r1=313912&r2=313913&view=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py Thu Sep 21 13:48:43 
2017
@@ -395,6 +395,28 @@ def test_get_tokens():
 assert tokens[0].spelling == 'int'
 assert tokens[1].spelling == 'foo'
 
+def test_get_token_cursor():
+"""Ensure we can map tokens to cursors."""
+tu = get_tu('class A {}; int foo(A var = A());', lang='cpp')
+foo = get_cursor(tu, 'foo')
+
+for cursor in foo.walk_preorder():
+if cursor.kind.is_expression() and not cursor.kind.is_statement():
+break
+else:
+assert False, "Could not find default value expression"
+
+tokens = list(cursor.get_tokens())
+assert len(tokens) == 4, [t.spelling for t in tokens]
+assert tokens[0].spelling == '='
+assert tokens[1].spelling == 'A'
+assert tokens[2].spelling == '('
+assert tokens[3].spelling == ')'
+t_cursor = tokens[1].cursor
+assert t_cursor.kind == CursorKind.TYPE_REF
+r_cursor = t_cursor.referenced # should not raise an exception
+assert r_cursor.kind == CursorKind.CLASS_DECL
+
 def test_get_arguments():
 tu = get_tu('void foo(int i, int j);')
 foo = get_cursor(tu, 'foo')


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


[PATCH] D36953: [libclang] Keep track of TranslationUnit instance when annotating tokens

2017-09-21 Thread Jonathan B Coe via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313913: [libclang] Keep track of TranslationUnit instance 
when annotating tokens (authored by jbcoe).

Changed prior to commit:
  https://reviews.llvm.org/D36953?vs=111959&id=116262#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36953

Files:
  cfe/trunk/bindings/python/clang/cindex.py
  cfe/trunk/bindings/python/tests/cindex/test_cursor.py


Index: cfe/trunk/bindings/python/clang/cindex.py
===
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -3216,6 +3216,7 @@
 def cursor(self):
 """The Cursor this Token corresponds to."""
 cursor = Cursor()
+cursor._tu = self._tu
 
 conf.lib.clang_annotateTokens(self._tu, byref(self), 1, byref(cursor))
 
Index: cfe/trunk/bindings/python/tests/cindex/test_cursor.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py
@@ -395,6 +395,28 @@
 assert tokens[0].spelling == 'int'
 assert tokens[1].spelling == 'foo'
 
+def test_get_token_cursor():
+"""Ensure we can map tokens to cursors."""
+tu = get_tu('class A {}; int foo(A var = A());', lang='cpp')
+foo = get_cursor(tu, 'foo')
+
+for cursor in foo.walk_preorder():
+if cursor.kind.is_expression() and not cursor.kind.is_statement():
+break
+else:
+assert False, "Could not find default value expression"
+
+tokens = list(cursor.get_tokens())
+assert len(tokens) == 4, [t.spelling for t in tokens]
+assert tokens[0].spelling == '='
+assert tokens[1].spelling == 'A'
+assert tokens[2].spelling == '('
+assert tokens[3].spelling == ')'
+t_cursor = tokens[1].cursor
+assert t_cursor.kind == CursorKind.TYPE_REF
+r_cursor = t_cursor.referenced # should not raise an exception
+assert r_cursor.kind == CursorKind.CLASS_DECL
+
 def test_get_arguments():
 tu = get_tu('void foo(int i, int j);')
 foo = get_cursor(tu, 'foo')


Index: cfe/trunk/bindings/python/clang/cindex.py
===
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -3216,6 +3216,7 @@
 def cursor(self):
 """The Cursor this Token corresponds to."""
 cursor = Cursor()
+cursor._tu = self._tu
 
 conf.lib.clang_annotateTokens(self._tu, byref(self), 1, byref(cursor))
 
Index: cfe/trunk/bindings/python/tests/cindex/test_cursor.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py
@@ -395,6 +395,28 @@
 assert tokens[0].spelling == 'int'
 assert tokens[1].spelling == 'foo'
 
+def test_get_token_cursor():
+"""Ensure we can map tokens to cursors."""
+tu = get_tu('class A {}; int foo(A var = A());', lang='cpp')
+foo = get_cursor(tu, 'foo')
+
+for cursor in foo.walk_preorder():
+if cursor.kind.is_expression() and not cursor.kind.is_statement():
+break
+else:
+assert False, "Could not find default value expression"
+
+tokens = list(cursor.get_tokens())
+assert len(tokens) == 4, [t.spelling for t in tokens]
+assert tokens[0].spelling == '='
+assert tokens[1].spelling == 'A'
+assert tokens[2].spelling == '('
+assert tokens[3].spelling == ')'
+t_cursor = tokens[1].cursor
+assert t_cursor.kind == CursorKind.TYPE_REF
+r_cursor = t_cursor.referenced # should not raise an exception
+assert r_cursor.kind == CursorKind.CLASS_DECL
+
 def test_get_arguments():
 tu = get_tu('void foo(int i, int j);')
 foo = get_cursor(tu, 'foo')
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r313919 - [lit] Refactor out some more common lit configuration code.

2017-09-21 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Thu Sep 21 14:27:31 2017
New Revision: 313919

URL: http://llvm.org/viewvc/llvm-project?rev=313919&view=rev
Log:
[lit] Refactor out some more common lit configuration code.

debuginfo-tests has need to reuse a lot of common configuration
from clang and lld, and in general it seems like all of the
projects which are tightly coupled (e.g. lld, clang, llvm, lldb,
etc) can benefit from knowing about one other.  For example,
lldb needs to know various things about how to run clang in its
test suite.  Since there's a lot of common substitutions and
operations that need to be shared among projects, sinking this
up into LLVM makes sense.

In addition, this patch introduces a function add_tool_substitution
which handles all the dirty intricacies of matching tool names
which was previously copied around the various config files.  This
is now a simple straightforward interface which is hard to mess
up.

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

Modified:
cfe/trunk/test/lit.cfg.py

Modified: cfe/trunk/test/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=313919&r1=313918&r2=313919&view=diff
==
--- cfe/trunk/test/lit.cfg.py (original)
+++ cfe/trunk/test/lit.cfg.py Thu Sep 21 14:27:31 2017
@@ -10,6 +10,7 @@ import lit.formats
 import lit.util
 
 from lit.llvm import llvm_config
+from lit.llvm import ToolFilter
 
 # Configuration file for the 'lit' test runner.
 
@@ -112,55 +113,12 @@ config.substitutions.append( ('%PATH%',
 if config.clang_examples:
 config.available_features.add('examples')
 
-# Note that when substituting %clang_cc1 also fill in the include directory of
-# the builtin headers. Those are part of even a freestanding environment, but
-# Clang relies on the driver to locate them.
-def getClangBuiltinIncludeDir(clang):
-# FIXME: Rather than just getting the version, we should have clang print
-# out its resource dir here in an easy to scrape form.
-cmd = subprocess.Popen([clang, '-print-file-name=include'],
-   stdout=subprocess.PIPE,
-   env=config.environment)
-if not cmd.stdout:
-  lit_config.fatal("Couldn't find the include dir for Clang ('%s')" % 
clang)
-dir = cmd.stdout.read().strip()
-if sys.platform in ['win32'] and not llvm_config.use_lit_shell:
-# Don't pass dosish path separator to msys bash.exe.
-dir = dir.replace('\\', '/')
-# Ensure the result is an ascii string, across Python2.5+ - Python3.
-return str(dir.decode('ascii'))
-
-def makeItaniumABITriple(triple):
-m = re.match(r'(\w+)-(\w+)-(\w+)', triple)
-if not m:
-  lit_config.fatal("Could not turn '%s' into Itanium ABI triple" % triple)
-if m.group(3).lower() != 'win32':
-  # All non-win32 triples use the Itanium ABI.
-  return triple
-return m.group(1) + '-' + m.group(2) + '-mingw32'
-
-def makeMSABITriple(triple):
-m = re.match(r'(\w+)-(\w+)-(\w+)', triple)
-if not m:
-  lit_config.fatal("Could not turn '%s' into MS ABI triple" % triple)
-isa = m.group(1).lower()
-vendor = m.group(2).lower()
-os = m.group(3).lower()
-if os == 'win32':
-  # If the OS is win32, we're done.
-  return triple
-if isa.startswith('x86') or isa == 'amd64' or re.match(r'i\d86', isa):
-  # For x86 ISAs, adjust the OS.
-  return isa + '-' + vendor + '-win32'
-# -win32 is not supported for non-x86 targets; use a default.
-return 'i686-pc-win32'
-
+builtin_include_dir = llvm_config.get_clang_builtin_include_dir(config.clang)
 config.substitutions.append( ('%clang_analyze_cc1',
   '%clang_cc1 -analyze %analyze') )
 config.substitutions.append( ('%clang_cc1',
   '%s -cc1 -internal-isystem %s -nostdsysteminc'
-  % (config.clang,
- getClangBuiltinIncludeDir(config.clang))) )
+  % (config.clang, builtin_include_dir)) )
 config.substitutions.append( ('%clang_cpp', ' ' + config.clang +
   ' --driver-mode=cpp '))
 config.substitutions.append( ('%clang_cl', ' ' + config.clang +
@@ -168,16 +126,20 @@ config.substitutions.append( ('%clang_cl
 config.substitutions.append( ('%clangxx', ' ' + config.clang +
   ' --driver-mode=g++ '))
 config.substitutions.append( ('%clang', ' ' + config.clang + ' ') )
-config.substitutions.append( ('%test_debuginfo', ' ' + config.llvm_src_root + 
'/utils/test_debuginfo.pl ') )
-config.substitutions.append( ('%itanium_abi_triple', 
makeItaniumABITriple(config.target_triple)) )
-config.substitutions.append( ('%ms_abi_triple', 
makeMSABITriple(config.target_triple)) )
-config.substitutions.append( ('%resource_dir', 
getClangBuiltinIncludeDir(config.clang)) )
+config.substitutions.append( ('%test_debuginfo',
+  

[libunwind] r313920 - [libunwind] Partially revert r297174 to fix build on at least FreeBSD.

2017-09-21 Thread John Baldwin via cfe-commits
Author: jhb
Date: Thu Sep 21 14:28:48 2017
New Revision: 313920

URL: http://llvm.org/viewvc/llvm-project?rev=313920&view=rev
Log:
[libunwind] Partially revert r297174 to fix build on at least FreeBSD.

The changes in r297174 moved the #include of  on FreeBSD (and
probably other systems) inside of the open 'libunwind' namespace
causing various system-provided types such as pid_t to be declared in
this namespace rather than the global namespace.  Fix this by moving
the relevant declarations before the 'libunwind' namespace is opened,
but still using the cleaned up declarations from r297174.

Reviewed By: ed, compnerd

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

Modified:
libunwind/trunk/src/AddressSpace.hpp

Modified: libunwind/trunk/src/AddressSpace.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=313920&r1=313919&r2=313920&view=diff
==
--- libunwind/trunk/src/AddressSpace.hpp (original)
+++ libunwind/trunk/src/AddressSpace.hpp Thu Sep 21 14:28:48 2017
@@ -35,6 +35,75 @@ namespace libunwind {
 #include "EHHeaderParser.hpp"
 #include "Registers.hpp"
 
+#ifdef __APPLE__
+
+  struct dyld_unwind_sections
+  {
+const struct mach_header*   mh;
+const void* dwarf_section;
+uintptr_t   dwarf_section_length;
+const void* compact_unwind_section;
+uintptr_t   compact_unwind_section_length;
+  };
+  #if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) \
+ && (__MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)) 
\
+  || defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
+// In 10.7.0 or later, libSystem.dylib implements this function.
+extern "C" bool _dyld_find_unwind_sections(void *, dyld_unwind_sections *);
+  #else
+// In 10.6.x and earlier, we need to implement this functionality. Note
+// that this requires a newer version of libmacho (from cctools) than is
+// present in libSystem on 10.6.x (for getsectiondata).
+static inline bool _dyld_find_unwind_sections(void* addr,
+dyld_unwind_sections* 
info) {
+  // Find mach-o image containing address.
+  Dl_info dlinfo;
+  if (!dladdr(addr, &dlinfo))
+return false;
+#if __LP64__
+  const struct mach_header_64 *mh = (const struct mach_header_64 
*)dlinfo.dli_fbase;
+#else
+  const struct mach_header *mh = (const struct mach_header 
*)dlinfo.dli_fbase;
+#endif
+
+  // Initialize the return struct
+  info->mh = (const struct mach_header *)mh;
+  info->dwarf_section = getsectiondata(mh, "__TEXT", "__eh_frame", 
&info->dwarf_section_length);
+  info->compact_unwind_section = getsectiondata(mh, "__TEXT", 
"__unwind_info", &info->compact_unwind_section_length);
+
+  if (!info->dwarf_section) {
+info->dwarf_section_length = 0;
+  }
+
+  if (!info->compact_unwind_section) {
+info->compact_unwind_section_length = 0;
+  }
+
+  return true;
+}
+  #endif
+
+#elif defined(_LIBUNWIND_ARM_EHABI) && defined(_LIBUNWIND_IS_BAREMETAL)
+
+// When statically linked on bare-metal, the symbols for the EH table are 
looked
+// up without going through the dynamic loader.
+extern char __exidx_start;
+extern char __exidx_end;
+
+#elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
+
+// ELF-based systems may use dl_iterate_phdr() to access sections
+// containing unwinding information. The ElfW() macro for pointer-size
+// independent ELF header traversal is not provided by  on some
+// systems (e.g., FreeBSD). On these systems the data structures are
+// just called Elf_XXX. Define ElfW() locally.
+#include 
+#if !defined(ElfW)
+#define ElfW(type) Elf_##type
+#endif
+
+#endif
+
 namespace libunwind {
 
 /// Used by findUnwindSections() to return info about needed sections.
@@ -265,75 +334,6 @@ LocalAddressSpace::getEncodedP(pint_t &a
   return result;
 }
 
-#ifdef __APPLE__
-
-  struct dyld_unwind_sections
-  {
-const struct mach_header*   mh;
-const void* dwarf_section;
-uintptr_t   dwarf_section_length;
-const void* compact_unwind_section;
-uintptr_t   compact_unwind_section_length;
-  };
-  #if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) \
- && (__MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)) 
\
-  || defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
-// In 10.7.0 or later, libSystem.dylib implements this function.
-extern "C" bool _dyld_find_unwind_sections(void *, dyld_unwind_sections *);
-  #else
-// In 10.6.x and earlier, we need to implement this functionality. Note
-// that this requires a newer version of libmacho (from cctools) than is
-// present in libSystem on 10.6.x (for getsectiondata).
-static inline bool _dyld_find_unwind_sections(void* addr,
-

[PATCH] D34512: Add preliminary Cross Translation Unit support library

2017-09-21 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

> But I also think it wouldn't be good to block this until ClanD indexing 
> reaching a mature state.

I agree 100%.

> All in all, we are willing to reuse as much of ClangD indexing as we can in 
> the future, but I think it is also more aligned with the LLVM Developer 
> Policy to have something working committed and do the development in the repo 
> rather than working separately on a fork.

This sounds good to me. I just wanted to make sure that you were onboard with 
changing this index to use the common indexing infrastructure in the future. 
(Assuming it makes sense to do so, of course).


https://reviews.llvm.org/D34512



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


[PATCH] D37861: preserving #pragma clang assume_nonnull in preprocessed output

2017-09-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM.

Do you want me to commit this for you?


https://reviews.llvm.org/D37861



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


[PATCH] D35796: [analyzer] Delete with non-virtual destructor check

2017-09-21 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

This looks good to me! Do you have commit access, or do you need someone to 
commit it for you?


https://reviews.llvm.org/D35796



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


r313922 - Revert "[lit] Refactor out some more common lit configuration code."

2017-09-21 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Thu Sep 21 14:45:45 2017
New Revision: 313922

URL: http://llvm.org/viewvc/llvm-project?rev=313922&view=rev
Log:
Revert "[lit] Refactor out some more common lit configuration code."

This is breaking several bots.  I have enough information to
investigate, so I'm reverting to green until I get it figured
out.

Modified:
cfe/trunk/test/lit.cfg.py

Modified: cfe/trunk/test/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=313922&r1=313921&r2=313922&view=diff
==
--- cfe/trunk/test/lit.cfg.py (original)
+++ cfe/trunk/test/lit.cfg.py Thu Sep 21 14:45:45 2017
@@ -10,7 +10,6 @@ import lit.formats
 import lit.util
 
 from lit.llvm import llvm_config
-from lit.llvm import ToolFilter
 
 # Configuration file for the 'lit' test runner.
 
@@ -113,12 +112,55 @@ config.substitutions.append( ('%PATH%',
 if config.clang_examples:
 config.available_features.add('examples')
 
-builtin_include_dir = llvm_config.get_clang_builtin_include_dir(config.clang)
+# Note that when substituting %clang_cc1 also fill in the include directory of
+# the builtin headers. Those are part of even a freestanding environment, but
+# Clang relies on the driver to locate them.
+def getClangBuiltinIncludeDir(clang):
+# FIXME: Rather than just getting the version, we should have clang print
+# out its resource dir here in an easy to scrape form.
+cmd = subprocess.Popen([clang, '-print-file-name=include'],
+   stdout=subprocess.PIPE,
+   env=config.environment)
+if not cmd.stdout:
+  lit_config.fatal("Couldn't find the include dir for Clang ('%s')" % 
clang)
+dir = cmd.stdout.read().strip()
+if sys.platform in ['win32'] and not llvm_config.use_lit_shell:
+# Don't pass dosish path separator to msys bash.exe.
+dir = dir.replace('\\', '/')
+# Ensure the result is an ascii string, across Python2.5+ - Python3.
+return str(dir.decode('ascii'))
+
+def makeItaniumABITriple(triple):
+m = re.match(r'(\w+)-(\w+)-(\w+)', triple)
+if not m:
+  lit_config.fatal("Could not turn '%s' into Itanium ABI triple" % triple)
+if m.group(3).lower() != 'win32':
+  # All non-win32 triples use the Itanium ABI.
+  return triple
+return m.group(1) + '-' + m.group(2) + '-mingw32'
+
+def makeMSABITriple(triple):
+m = re.match(r'(\w+)-(\w+)-(\w+)', triple)
+if not m:
+  lit_config.fatal("Could not turn '%s' into MS ABI triple" % triple)
+isa = m.group(1).lower()
+vendor = m.group(2).lower()
+os = m.group(3).lower()
+if os == 'win32':
+  # If the OS is win32, we're done.
+  return triple
+if isa.startswith('x86') or isa == 'amd64' or re.match(r'i\d86', isa):
+  # For x86 ISAs, adjust the OS.
+  return isa + '-' + vendor + '-win32'
+# -win32 is not supported for non-x86 targets; use a default.
+return 'i686-pc-win32'
+
 config.substitutions.append( ('%clang_analyze_cc1',
   '%clang_cc1 -analyze %analyze') )
 config.substitutions.append( ('%clang_cc1',
   '%s -cc1 -internal-isystem %s -nostdsysteminc'
-  % (config.clang, builtin_include_dir)) )
+  % (config.clang,
+ getClangBuiltinIncludeDir(config.clang))) )
 config.substitutions.append( ('%clang_cpp', ' ' + config.clang +
   ' --driver-mode=cpp '))
 config.substitutions.append( ('%clang_cl', ' ' + config.clang +
@@ -126,20 +168,16 @@ config.substitutions.append( ('%clang_cl
 config.substitutions.append( ('%clangxx', ' ' + config.clang +
   ' --driver-mode=g++ '))
 config.substitutions.append( ('%clang', ' ' + config.clang + ' ') )
-config.substitutions.append( ('%test_debuginfo',
- ' ' + config.llvm_src_root +  
'/utils/test_debuginfo.pl ') )
-config.substitutions.append( ('%itanium_abi_triple',
- 
llvm_config.make_itanium_abi_triple(config.target_triple)) )
-config.substitutions.append( ('%ms_abi_triple',
- 
llvm_config.make_msabi_triple(config.target_triple)) )
-config.substitutions.append( ('%resource_dir', builtin_include_dir) )
+config.substitutions.append( ('%test_debuginfo', ' ' + config.llvm_src_root + 
'/utils/test_debuginfo.pl ') )
+config.substitutions.append( ('%itanium_abi_triple', 
makeItaniumABITriple(config.target_triple)) )
+config.substitutions.append( ('%ms_abi_triple', 
makeMSABITriple(config.target_triple)) )
+config.substitutions.append( ('%resource_dir', 
getClangBuiltinIncludeDir(config.clang)) )
 config.substitutions.append( ('%python', config.python_executable) )
 
 # The host triple might not be set, at least if we're compiling clang from
 # an already installed llvm.
 if config.host_triple and config.host_trip

r313923 - [Analyzer] Remove dead code from CmpRuns.py.

2017-09-21 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Sep 21 14:47:13 2017
New Revision: 313923

URL: http://llvm.org/viewvc/llvm-project?rev=313923&view=rev
Log:
[Analyzer] Remove dead code from CmpRuns.py.

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

Modified:
cfe/trunk/utils/analyzer/CmpRuns.py

Modified: cfe/trunk/utils/analyzer/CmpRuns.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/CmpRuns.py?rev=313923&r1=313922&r2=313923&view=diff
==
--- cfe/trunk/utils/analyzer/CmpRuns.py (original)
+++ cfe/trunk/utils/analyzer/CmpRuns.py Thu Sep 21 14:47:13 2017
@@ -89,30 +89,6 @@ class AnalysisDiagnostic:
 def getRawData(self):
 return self._data
 
-class multidict:
-def __init__(self, elts=()):
-self.data = {}
-for key,value in elts:
-self[key] = value
-
-def __getitem__(self, item):
-return self.data[item]
-def __setitem__(self, key, value):
-if key in self.data:
-self.data[key].append(value)
-else:
-self.data[key] = [value]
-def items(self):
-return self.data.items()
-def values(self):
-return self.data.values()
-def keys(self):
-return self.data.keys()
-def __len__(self):
-return len(self.data)
-def get(self, key, default=None):
-return self.data.get(key, default)
-
 class CmpOptions:
 def __init__(self, verboseLog=None, rootA="", rootB=""):
 self.rootA = rootA


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


r313924 - [Analyzer] Add simple help to SATestAdd.py

2017-09-21 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Sep 21 14:47:33 2017
New Revision: 313924

URL: http://llvm.org/viewvc/llvm-project?rev=313924&view=rev
Log:
[Analyzer] Add simple help to SATestAdd.py

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

Modified:
cfe/trunk/utils/analyzer/SATestAdd.py

Modified: cfe/trunk/utils/analyzer/SATestAdd.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestAdd.py?rev=313924&r1=313923&r2=313924&view=diff
==
--- cfe/trunk/utils/analyzer/SATestAdd.py (original)
+++ cfe/trunk/utils/analyzer/SATestAdd.py Thu Sep 21 14:47:33 2017
@@ -90,11 +90,12 @@ def addNewProject(ID, BuildMode) :
 # TODO: Add an option not to build.
 # TODO: Set the path to the Repository directory.
 if __name__ == '__main__':
-if len(sys.argv) < 2:
-print >> sys.stderr, 'Usage: ', sys.argv[0],\
- 'project_ID ' \
- 'mode - 0 for single file project; ' \
- '1 for scan_build; ' \
+if len(sys.argv) < 2 or sys.argv[1] in ('-h', '--help'):
+print >> sys.stderr, 'Add a new project for testing to static 
analyzer'\
+ '\nUsage: ', sys.argv[0],\
+ 'project_ID \n' \
+ 'mode: 0 for single file project, ' \
+ '1 for scan_build, ' \
  '2 for single file c++11 project'
 sys.exit(-1)
 


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


[PATCH] D32520: Support __fp16 vectors

2017-09-21 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/CodeGen/CGExprScalar.cpp:1042
+}
+
+assert(SrcElementTy->isFloatingPointTy() &&

bruno wrote:
> What happens if the SrcElementTy is float and DstElementTy isn't? Seems like 
> it will hit the assertion below.
That's not supposed to happen since there are only three cases we have to 
consider here:

1. truncation from an int vector to a short vector
2. promotion from a half vector to a float vector
3. truncation from a float vector to a half vector

I've cleaned up the assertions and moved them up to make the code clearer.



Comment at: lib/Sema/SemaExpr.cpp:7511
+  // If this is a compound assignment, allow converting the RHS to the type
+  // of the LHS.
+  if (IsCompAssign && isVector(LHSType, Context.HalfTy)) {

bruno wrote:
> Since it seems that you're always doing the same conversion (the only 
> variable input here is the number of elements), can you update the comment to 
> mention the exact conversion?
It turns out this code isn't needed at all. I accidentally left the code in 
that I had in my local branch. The conversions between half vectors and float 
vectors take place after the operands are checked, so both the LHS and the RHS 
are still half vectors at this point.

Sorry for causing confusion.



Comment at: lib/Sema/SemaExpr.cpp:11537
+  // Some of the binary operations require promoting operands of half vector
+  // and truncating the result. For now, we do this only when HalfArgsAndReturn
+  // is set (that is, when the target is arm or arm64).

bruno wrote:
> What about `of half vector and truncating the result` to `of half vector to 
> float and truncating the result back to half`
I also changed the comment in CreateBuiltinUnaryOp.



Comment at: lib/Sema/SemaExpr.cpp:11978
+// truncating the result. For now, we do this only when HalfArgsAndReturns
+// is set (that is, when the target is arm or arm64).
+ConvertHalfVec =

bruno wrote:
> This same logic is used elsewhere in the patch, perhaps factor it out into a 
> static function?
I factored it out to function 'needsConversionOfHalfVec'.


https://reviews.llvm.org/D32520



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


[PATCH] D32520: Support __fp16 vectors

2017-09-21 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 116275.
ahatanak marked 8 inline comments as done.
ahatanak added a comment.

Address review comments.


https://reviews.llvm.org/D32520

Files:
  lib/CodeGen/CGExprScalar.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGen/fp16vec-ops.c
  test/Sema/fp16vec-sema.c

Index: test/Sema/fp16vec-sema.c
===
--- /dev/null
+++ test/Sema/fp16vec-sema.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef __fp16 half4 __attribute__ ((vector_size (8)));
+typedef float float4 __attribute__ ((vector_size (16)));
+typedef short short4 __attribute__ ((vector_size (8)));
+typedef int int4 __attribute__ ((vector_size (16)));
+
+half4 hv0, hv1;
+float4 fv0, fv1;
+short4 sv0;
+int4 iv0;
+
+void testFP16Vec(int c) {
+  hv0 = hv0 + hv1;
+  hv0 = hv0 - hv1;
+  hv0 = hv0 * hv1;
+  hv0 = hv0 / hv1;
+  hv0 = c ? hv0 : hv1;
+  hv0 += hv1;
+  hv0 -= hv1;
+  hv0 *= hv1;
+  hv0 /= hv1;
+  sv0 = hv0 == hv1;
+  sv0 = hv0 != hv1;
+  sv0 = hv0 < hv1;
+  sv0 = hv0 > hv1;
+  sv0 = hv0 <= hv1;
+  sv0 = hv0 >= hv1;
+  sv0 = hv0 || hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
+  sv0 = hv0 && hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
+
+  // Implicit conversion between half vectors and float vectors are not allowed.
+  hv0 = fv0; // expected-error{{assigning to}}
+  fv0 = hv0; // expected-error{{assigning to}}
+  hv0 = (half4)fv0; // expected-error{{invalid conversion between}}
+  fv0 = (float4)hv0; // expected-error{{invalid conversion between}}
+  hv0 = fv0 + fv1; // expected-error{{assigning to}}
+  fv0 = hv0 + hv1; // expected-error{{assigning to}}
+  hv0 = hv0 + fv1; // expected-error{{cannot convert between vector}}
+  hv0 = c ? hv0 : fv1; // expected-error{{cannot convert between vector}}
+  sv0 = hv0 == fv1; // expected-error{{cannot convert between vector}}
+  sv0 = hv0 < fv1; // expected-error{{cannot convert between vector}}
+  sv0 = hv0 || fv1; // expected-error{{cannot convert between vector}} expected-error{{invalid operands to binary expression}}
+  iv0 = hv0 == hv1; // expected-error{{assigning to}}
+
+  // FIXME: clang currently disallows using these operators on vectors, which is
+  // allowed by gcc.
+  sv0 = !hv0; // expected-error{{invalid argument type}}
+  hv0++; // expected-error{{cannot increment value of type}}
+  ++hv0; // expected-error{{cannot increment value of type}}
+}
Index: test/CodeGen/fp16vec-ops.c
===
--- /dev/null
+++ test/CodeGen/fp16vec-ops.c
@@ -0,0 +1,162 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple arm64-apple-ios9 -emit-llvm -o - -fallow-half-arguments-and-returns %s | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple armv7-apple-ios9 -emit-llvm -o - -fallow-half-arguments-and-returns %s | FileCheck %s --check-prefix=CHECK
+
+typedef __fp16 half4 __attribute__ ((vector_size (8)));
+typedef short short4 __attribute__ ((vector_size (8)));
+
+half4 hv0, hv1;
+short4 sv0;
+
+// CHECK-LABEL: testFP16Vec0
+// CHECK: %[[V0:.*]] = load <4 x half>, <4 x half>* @hv0, align 8
+// CHECK: %[[CONV:.*]] = fpext <4 x half> %[[V0]] to <4 x float>
+// CHECK: %[[V1:.*]] = load <4 x half>, <4 x half>* @hv1, align 8
+// CHECK: %[[CONV1:.*]] = fpext <4 x half> %[[V1]] to <4 x float>
+// CHECK: %[[ADD:.*]] = fadd <4 x float> %[[CONV]], %[[CONV1]]
+// CHECK: %[[CONV2:.*]] = fptrunc <4 x float> %[[ADD]] to <4 x half>
+// CHECK: store <4 x half> %[[CONV2]], <4 x half>* @hv0, align 8
+// CHECK: %[[V2:.*]] = load <4 x half>, <4 x half>* @hv0, align 8
+// CHECK: %[[CONV3:.*]] = fpext <4 x half> %[[V2]] to <4 x float>
+// CHECK: %[[V3:.*]] = load <4 x half>, <4 x half>* @hv1, align 8
+// CHECK: %[[CONV4:.*]] = fpext <4 x half> %[[V3]] to <4 x float>
+// CHECK: %[[SUB:.*]] = fsub <4 x float> %[[CONV3]], %[[CONV4]]
+// CHECK: %[[CONV5:.*]] = fptrunc <4 x float> %[[SUB]] to <4 x half>
+// CHECK: store <4 x half> %[[CONV5]], <4 x half>* @hv0, align 8
+// CHECK: %[[V4:.*]] = load <4 x half>, <4 x half>* @hv0, align 8
+// CHECK: %[[CONV6:.*]] = fpext <4 x half> %[[V4]] to <4 x float>
+// CHECK: %[[V5:.*]] = load <4 x half>, <4 x half>* @hv1, align 8
+// CHECK: %[[CONV7:.*]] = fpext <4 x half> %[[V5]] to <4 x float>
+// CHECK: %[[MUL:.*]] = fmul <4 x float> %[[CONV6]], %[[CONV7]]
+// CHECK: %[[CONV8:.*]] = fptrunc <4 x float> %[[MUL]] to <4 x half>
+// CHECK: store <4 x half> %[[CONV8]], <4 x half>* @hv0, align 8
+// CHECK: %[[V6:.*]] = load <4 x half>, <4 x half>* @hv0, align 8
+// CHECK: %[[CONV9:.*]] = fpext <4 x half> %[[V6]] to <4 x float>
+// CHECK: %[[V7:.*]] = load <4 x half>, <4 x half>* @hv1, align 8
+// CHECK: %[[CONV10:.*]] = fpext <4 x half> %[[V7]] to <4 x float>
+// CHECK: %[[DIV:.*]] = fdiv <4 x float> %[[CONV9]], %[[CONV10]]
+//

[PATCH] D37822: [OpenCL] Clean up and add missing fields for block struct

2017-09-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 116277.
yaxunl marked 6 inline comments as done.
yaxunl added a comment.

Revise by Anastasia's comments.


https://reviews.llvm.org/D37822

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  test/CodeGen/blocks-opencl.cl
  test/CodeGenOpenCL/blocks.cl
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -7,7 +7,7 @@
 typedef struct {int a;} ndrange_t;
 
 // N.B. The check here only exists to set BL_GLOBAL
-// COMMON: @block_G =  addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor addrspace(2)* } addrspace(1)* [[BL_GLOBAL:@__block_literal_global(\.[0-9]+)?]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*)
+// COMMON: @block_G =  addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL:@__block_literal_global(\.[0-9]+)?]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*)
 const bl_t block_G = (bl_t) ^ (local void *a) {};
 
 kernel void device_side_enqueue(global int *a, global int *b, int i) {
@@ -27,9 +27,10 @@
   // COMMON: [[NDR:%[a-z0-9]+]] = alloca %struct.ndrange_t, align 4
   // COMMON: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t{{.*}}*, %opencl.queue_t{{.*}}** %default_queue
   // COMMON: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
-  // COMMON: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor addrspace(2)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block to void ()*
+  // B32: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block to void ()*
+  // B64: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32 addrspace(1)*, i32 }>* %block to void ()*
   // COMMON: [[BL_I8:%[0-9]+]] = addrspacecast void ()* [[BL]] to i8 addrspace(4)*
-  // COMMON: call i32 @__enqueue_kernel_basic(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* byval [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* [[BL_I8]])
+  // COMMON: call i32 @__enqueue_kernel_basic(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* byval [[NDR]]{{([0-9]+)?}}, i8 addrspace(4)* [[BL_I8]])
   enqueue_kernel(default_queue, flags, ndrange,
  ^(void) {
a[i] = b[i];
@@ -39,7 +40,7 @@
   // COMMON: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
   // COMMON: [[WAIT_EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t{{.*}}** %event_wait_list to %opencl.clk_event_t{{.*}}* addrspace(4)*
   // COMMON: [[EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t{{.*}}** %clk_event to %opencl.clk_event_t{{.*}}* addrspace(4)*
-  // COMMON: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor addrspace(2)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block3 to void ()*
+  // COMMON: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block3 to void ()*
   // COMMON: [[BL_I8:%[0-9]+]] = addrspacecast void ()* [[BL]] to i8 addrspace(4)*
   // COMMON: call i32 @__enqueue_kernel_basic_events(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]],  %struct.ndrange_t* {{.*}}, i32 2, %opencl.clk_event_t{{.*}}* addrspace(4)* [[WAIT_EVNT]], %opencl.clk_event_t{{.*}}* addrspace(4)* [[EVNT]], i8 addrspace(4)* [[BL_I8]])
   enqueue_kernel(default_queue, flags, ndrange, 2, &event_wait_list, &clk_event,
@@ -52,11 +53,11 @@
   // B32: %[[TMP:.*]] = alloca [1 x i32]
   // B32: %[[TMP1:.*]] = getelementptr [1 x i32], [1 x i32]* %[[TMP]], i32 0, i32 0
   // B32: store i32 256, i32* %[[TMP1]], align 4
-  // B32: call i32 @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor addrspace(2)* } addrspace(1)* @__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, i32* %[[TMP1]])
+  // B32: call i32 @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{([0-9]+)?}}, i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* @__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, i32* %[[TMP1]])
   // B64: %[[TMP:.*]] = alloca [1 x i64]
   // B64: %[[TMP1:.*]] = getelementptr [1 x i64], [1 x i64]* %[[TMP]], i32 0, i32 0
   // B64: store i64 256, i64* %[[TMP1]], align 8
-  // B64: call i32 @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %stru

[PATCH] D38158: [Sema] Null check in BuildDeclarationNameExpr

2017-09-21 Thread Yi Kong via Phabricator via cfe-commits
kongyi created this revision.
kongyi added a project: clang.

Qualtype may point to null if we cannot infer its type yet.

Fixes PR33843


Repository:
  rL LLVM

https://reviews.llvm.org/D38158

Files:
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/typo-correction-crash.cpp


Index: test/SemaCXX/typo-correction-crash.cpp
===
--- test/SemaCXX/typo-correction-crash.cpp
+++ test/SemaCXX/typo-correction-crash.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
 auto check1() {
   return 1;
   return s; // expected-error {{use of undeclared identifier 's'}}
@@ -19,3 +19,5 @@
 FooRecord::NestedNamespace::type x; // expected-error {{no member named 
'NestedNamespace' in 'FooRecord'; did you mean 
'BarNamespace::NestedNamespace'?}}
 
 void cast_expr(int g) { +int(n)(g); } // expected-error {{undeclared 
identifier 'n'}}
+
+void bind() { for (const auto& [test,_] : _test_) { }; } // expected-error 
{{undeclared identifier '_test_'}}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -2803,6 +2803,8 @@
 
   {
 QualType type = VD->getType();
+if (type.isNull())
+  return ExprError();
 if (auto *FPT = type->getAs()) {
   // C++ [except.spec]p17:
   //   An exception-specification is considered to be needed when:


Index: test/SemaCXX/typo-correction-crash.cpp
===
--- test/SemaCXX/typo-correction-crash.cpp
+++ test/SemaCXX/typo-correction-crash.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
 auto check1() {
   return 1;
   return s; // expected-error {{use of undeclared identifier 's'}}
@@ -19,3 +19,5 @@
 FooRecord::NestedNamespace::type x; // expected-error {{no member named 'NestedNamespace' in 'FooRecord'; did you mean 'BarNamespace::NestedNamespace'?}}
 
 void cast_expr(int g) { +int(n)(g); } // expected-error {{undeclared identifier 'n'}}
+
+void bind() { for (const auto& [test,_] : _test_) { }; } // expected-error {{undeclared identifier '_test_'}}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -2803,6 +2803,8 @@
 
   {
 QualType type = VD->getType();
+if (type.isNull())
+  return ExprError();
 if (auto *FPT = type->getAs()) {
   // C++ [except.spec]p17:
   //   An exception-specification is considered to be needed when:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r313927 - [Analyzer] Use CC environment variable to select analyzer path in SATestBuild.

2017-09-21 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Sep 21 15:12:49 2017
New Revision: 313927

URL: http://llvm.org/viewvc/llvm-project?rev=313927&view=rev
Log:
[Analyzer] Use CC environment variable to select analyzer path in SATestBuild.

This change is required to easily test the given checkout of the analyzer,
rather than the one bundled with a system compiler.

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

Modified:
cfe/trunk/utils/analyzer/SATestBuild.py

Modified: cfe/trunk/utils/analyzer/SATestBuild.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestBuild.py?rev=313927&r1=313926&r2=313927&view=diff
==
--- cfe/trunk/utils/analyzer/SATestBuild.py (original)
+++ cfe/trunk/utils/analyzer/SATestBuild.py Thu Sep 21 15:12:49 2017
@@ -142,7 +142,10 @@ def getSBOutputDirName(IsReferenceBuild)
 #--
 
 # Find Clang for static analysis.
-Clang = which("clang", os.environ['PATH'])
+if 'CC' in os.environ:
+Clang = os.environ['CC']
+else:
+Clang = which("clang", os.environ['PATH'])
 if not Clang:
 print "Error: cannot find 'clang' in PATH"
 sys.exit(-1)


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


r313928 - Resubmit "[lit] Refactor out some more common lit configuration code."

2017-09-21 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Thu Sep 21 15:16:40 2017
New Revision: 313928

URL: http://llvm.org/viewvc/llvm-project?rev=313928&view=rev
Log:
Resubmit "[lit] Refactor out some more common lit configuration code."

There were two issues, one Python 3 specific related to Unicode,
and another which is that the tool substitution for lld no longer
rejected matches where a / preceded the tool name.

Modified:
cfe/trunk/test/lit.cfg.py

Modified: cfe/trunk/test/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=313928&r1=313927&r2=313928&view=diff
==
--- cfe/trunk/test/lit.cfg.py (original)
+++ cfe/trunk/test/lit.cfg.py Thu Sep 21 15:16:40 2017
@@ -10,6 +10,7 @@ import lit.formats
 import lit.util
 
 from lit.llvm import llvm_config
+from lit.llvm import ToolFilter
 
 # Configuration file for the 'lit' test runner.
 
@@ -112,55 +113,12 @@ config.substitutions.append( ('%PATH%',
 if config.clang_examples:
 config.available_features.add('examples')
 
-# Note that when substituting %clang_cc1 also fill in the include directory of
-# the builtin headers. Those are part of even a freestanding environment, but
-# Clang relies on the driver to locate them.
-def getClangBuiltinIncludeDir(clang):
-# FIXME: Rather than just getting the version, we should have clang print
-# out its resource dir here in an easy to scrape form.
-cmd = subprocess.Popen([clang, '-print-file-name=include'],
-   stdout=subprocess.PIPE,
-   env=config.environment)
-if not cmd.stdout:
-  lit_config.fatal("Couldn't find the include dir for Clang ('%s')" % 
clang)
-dir = cmd.stdout.read().strip()
-if sys.platform in ['win32'] and not llvm_config.use_lit_shell:
-# Don't pass dosish path separator to msys bash.exe.
-dir = dir.replace('\\', '/')
-# Ensure the result is an ascii string, across Python2.5+ - Python3.
-return str(dir.decode('ascii'))
-
-def makeItaniumABITriple(triple):
-m = re.match(r'(\w+)-(\w+)-(\w+)', triple)
-if not m:
-  lit_config.fatal("Could not turn '%s' into Itanium ABI triple" % triple)
-if m.group(3).lower() != 'win32':
-  # All non-win32 triples use the Itanium ABI.
-  return triple
-return m.group(1) + '-' + m.group(2) + '-mingw32'
-
-def makeMSABITriple(triple):
-m = re.match(r'(\w+)-(\w+)-(\w+)', triple)
-if not m:
-  lit_config.fatal("Could not turn '%s' into MS ABI triple" % triple)
-isa = m.group(1).lower()
-vendor = m.group(2).lower()
-os = m.group(3).lower()
-if os == 'win32':
-  # If the OS is win32, we're done.
-  return triple
-if isa.startswith('x86') or isa == 'amd64' or re.match(r'i\d86', isa):
-  # For x86 ISAs, adjust the OS.
-  return isa + '-' + vendor + '-win32'
-# -win32 is not supported for non-x86 targets; use a default.
-return 'i686-pc-win32'
-
+builtin_include_dir = llvm_config.get_clang_builtin_include_dir(config.clang)
 config.substitutions.append( ('%clang_analyze_cc1',
   '%clang_cc1 -analyze %analyze') )
 config.substitutions.append( ('%clang_cc1',
   '%s -cc1 -internal-isystem %s -nostdsysteminc'
-  % (config.clang,
- getClangBuiltinIncludeDir(config.clang))) )
+  % (config.clang, builtin_include_dir)) )
 config.substitutions.append( ('%clang_cpp', ' ' + config.clang +
   ' --driver-mode=cpp '))
 config.substitutions.append( ('%clang_cl', ' ' + config.clang +
@@ -168,16 +126,20 @@ config.substitutions.append( ('%clang_cl
 config.substitutions.append( ('%clangxx', ' ' + config.clang +
   ' --driver-mode=g++ '))
 config.substitutions.append( ('%clang', ' ' + config.clang + ' ') )
-config.substitutions.append( ('%test_debuginfo', ' ' + config.llvm_src_root + 
'/utils/test_debuginfo.pl ') )
-config.substitutions.append( ('%itanium_abi_triple', 
makeItaniumABITriple(config.target_triple)) )
-config.substitutions.append( ('%ms_abi_triple', 
makeMSABITriple(config.target_triple)) )
-config.substitutions.append( ('%resource_dir', 
getClangBuiltinIncludeDir(config.clang)) )
+config.substitutions.append( ('%test_debuginfo',
+ ' ' + config.llvm_src_root +  
'/utils/test_debuginfo.pl ') )
+config.substitutions.append( ('%itanium_abi_triple',
+ 
llvm_config.make_itanium_abi_triple(config.target_triple)) )
+config.substitutions.append( ('%ms_abi_triple',
+ 
llvm_config.make_msabi_triple(config.target_triple)) )
+config.substitutions.append( ('%resource_dir', builtin_include_dir) )
 config.substitutions.append( ('%python', config.python_executable) )
 
 # The host triple might not be set, at least if we're compiling clang from
 # an already ins

Re: r313386 - [Sema] Error out early for tags defined inside an enumeration.

2017-09-21 Thread Richard Smith via cfe-commits
On 15 September 2017 at 12:51, Volodymyr Sapsai via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: vsapsai
> Date: Fri Sep 15 12:51:42 2017
> New Revision: 313386
>
> URL: http://llvm.org/viewvc/llvm-project?rev=313386&view=rev
> Log:
> [Sema] Error out early for tags defined inside an enumeration.
>
> This fixes PR28903 by avoiding access check for inner enum constant. We
> are performing access check because one enum constant references another
> and because enum is defined in CXXRecordDecl. But access check doesn't
> work because FindDeclaringClass doesn't expect more than one EnumDecl
> and because inner enum has access AS_none due to not being an immediate
> child of a record.
>
> The change detects an enum is defined in wrong place and allows to skip
> parsing its body. Access check is skipped together with body parsing.
> There was no crash in C, added test case to cover the new error.
>
> rdar://problem/28530809
>
> Reviewers: rnk, doug.gregor, rsmith
>
> Reviewed By: doug.gregor
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D37089
>
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/test/Sema/enum.c
> cfe/trunk/test/SemaCXX/enum.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=313386&r1=313385&r2=313386&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Sep 15
> 12:51:42 2017
> @@ -1335,6 +1335,8 @@ def err_type_defined_in_alias_template :
>"%0 cannot be defined in a type alias template">;
>  def err_type_defined_in_condition : Error<
>"%0 cannot be defined in a condition">;
> +def err_type_defined_in_enum : Error<
> +  "%0 cannot be defined in an enumeration">;
>
>  def note_pure_virtual_function : Note<
>"unimplemented pure virtual method %0 in %1">;
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaDecl.cpp?rev=313386&r1=313385&r2=313386&view=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Sep 15 12:51:42 2017
> @@ -13928,6 +13928,12 @@ CreateNewDecl:
>  Invalid = true;
>}
>
> +  if (!Invalid && TUK == TUK_Definition && DC->getDeclKind() ==
> Decl::Enum) {
> +Diag(New->getLocation(), diag::err_type_defined_in_enum)
> +  << Context.getTagDeclType(New);
> +Invalid = true;
> +  }
>

This looks like the wrong fix. As noted elsewhere, this is wrong in C. And
in C++, the relevant context is a type-specifier, which should be rejected
due to the check 7 lines above.

It looks like the actual bug is that we don't consider the type within a
C99 compound literal to be a type-specifier. The fact that the context is
an enumeration is irrelevant.


> +
>// Maybe add qualifier info.
>if (SS.isNotEmpty()) {
>  if (SS.isSet()) {
>
> Modified: cfe/trunk/test/Sema/enum.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/
> enum.c?rev=313386&r1=313385&r2=313386&view=diff
> 
> ==
> --- cfe/trunk/test/Sema/enum.c (original)
> +++ cfe/trunk/test/Sema/enum.c Fri Sep 15 12:51:42 2017
> @@ -123,3 +123,14 @@ int NegativeShortTest[NegativeShort == -
>  // PR24610
>  enum Color { Red, Green, Blue }; // expected-note{{previous use is here}}
>  typedef struct Color NewColor; // expected-error {{use of 'Color' with
> tag type that does not match previous declaration}}
> +
> +// PR28903
> +struct PR28903 {
> +  enum {
> +PR28903_A = (enum { // expected-error-re {{'enum PR28903::(anonymous
> at {{.*}})' cannot be defined in an enumeration}}
> +  PR28903_B,
> +  PR28903_C = PR28903_B
> +})0
> +  };
> +  int makeStructNonEmpty;
> +};
>
> Modified: cfe/trunk/test/SemaCXX/enum.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/enum.cpp?rev=313386&r1=313385&r2=313386&view=diff
> 
> ==
> --- cfe/trunk/test/SemaCXX/enum.cpp (original)
> +++ cfe/trunk/test/SemaCXX/enum.cpp Fri Sep 15 12:51:42 2017
> @@ -110,3 +110,13 @@ enum { overflow = 123456 * 234567 };
>  // expected-warning@-2 {{not an integral constant expression}}
>  // expected-note@-3 {{value 28958703552 is outside the range of
> representable values}}
>  #endif
> +
> +// PR28903
> +struct PR28903 {
> +  enum {
> +PR28903_A = (enum { // expected-error-re {{'PR28903::(anonymous enum
> at {{.*}})' cannot be defined in an enumeration}}
> +  PR28903_B,
> +  PR28903_C = PR28903_B
> +})
> +  };
> +};
>
>
> 

[PATCH] D37822: [OpenCL] Clean up and add missing fields for block struct

2017-09-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D37822#877903, @Anastasia wrote:

> In https://reviews.llvm.org/D37822#877572, @yaxunl wrote:
>
> > In https://reviews.llvm.org/D37822#873876, @Anastasia wrote:
> >
> > > In https://reviews.llvm.org/D37822#872446, @yaxunl wrote:
> > >
> > > > In https://reviews.llvm.org/D37822#872291, @Anastasia wrote:
> > > >
> > > > > Could you please explain a bit more why the alignment have to be put 
> > > > > explicitly in the struct? I am just not very convinced this is 
> > > > > general enough.
> > > >
> > > >
> > > > The captured variables are fields of the block literal struct. Due to 
> > > > alignment requirement of these fields, there is alignment requirement of
> > > >  the block literal struct. The ISA of the block invoke function is 
> > > > generated with the assumption of these alignments. If the block literal 
> > > > is
> > > >  allocated at a memory address not satisfying the alignment 
> > > > requirement, the kernel behavior is undefined.
> > > >
> > > > Generally, __enqueue_kernel library function needs to prepare the 
> > > > kernel argument before launching the kernel. It usually does this by 
> > > > copying
> > > >  the block literal to some buffer then pass the address of the buffer 
> > > > to the kernel. Then the address of the buffer has to satisfy the 
> > > > alignment
> > > >  requirement.
> > > >
> > > > If this block literal struct is not general enough, how about add 
> > > > another field as target reserved size, and leave the remaining space of 
> > > > header for
> > > >  target specific use. And add a target hook to allow target fill the 
> > > > reserved space, e.g.
> > > >
> > > >   struct __opencl_block_literal {
> > > > int total_size;
> > > > int align;
> > > > __generic void *invoke;
> > > > int target_reserved_size; /* round up to 4 bytes */
> > > > int target_reserved[];
> > > > /* captures */
> > > >   };
> > > >
> > >
> > >
> > > I like the idea of the target reserved part actually. But not sure how it 
> > > could be used without adding any target specific methods?
> >
> >
> > If we decide to add target reserved fields, I can add target hooks to fill 
> > these fields. However I would suggest to leave this for future since I 
> > don't see there is need for other fields for now.
>
>
> I could imagine it can be usefull for some vendor implementations.




> 
> 
>>> However, I am still not clear why the alignment of this struct has to be 
>>> different from any other struct Clang produces. Normally the alignment of 
>>> objects have to be known during IR generation to put them correctly in the 
>>> attributes of generated alloca, store and loads. But as a field inside 
>>> struct I don't know how it can be useful. I would imagine `enqueue_kernel` 
>>> would just operate on the block as if it would be an arbitrary buffer of 
>>> data. Also would size of the struct not account for any padding to make 
>>> sure the alignment can be deduced based on it correctly?
>> 
>> enqueue_kernel needs to pass the block struct to the kernel. Let's assume it 
>> does this by copying the block struct to a buffer. If enqueue_kernel does 
>> not know the alignment of the struct, it can only put it at an arbitrary 
>> address in the buffer. Then the kernel has to copy the struct to an aligned 
>> private memory and load the fields. However, if the enqueued_kernel knows 
>> the alignment of the struct, it can put it at an address satisfying the 
>> alignment. Then the kernel can load the fields directly from the buffer, 
>> skips the step of copying to an aligned private memory. Therefore, alignment 
>> of the block struct is usually a useful information for enqueue_kernel. I 
>> think that's why in the SPIRV spec OpEnqueueKernel requires an alignment 
>> operand for the block context.
> 
> Ok, I just think in C if you use `malloc` to obtain a pointer to some memory 
> location it doesn't take any alignment information. Then you can use the 
> pointer to copy any data including the struct into the location its pointed 
> to. And the pointer can be used later on correctly. I think the alignment is 
> deduced in this case from the type or the size of an object. Do you know 
> where the alignment information is used for SPIRV call? Also how is the block 
> represented in SPIRV?

If you just use malloc and put your struct in it, there is no guarantee that 
your struct is aligned at the required alignment, then your kernel cannot load 
a field directly from that memory. For example, if your first field is an int 
and the instruction can only load an int from an addr aligned at 4, and your 
malloc'ed addr is aligned at 1, then you cannot load that int directly. 
Instead, you need to copy the 4 bytes to an addr aligned at 4, then use that 
instruction to load it. If you use posix_memalign to get an aligned buffer, 
then your kernel can generate more efficient code.

OpEnqueueKernel instruction in SPIR-V is for representing O

[PATCH] D37656: [cfi] Set function attributes for __cfi_* functions.

2017-09-21 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

ping


https://reviews.llvm.org/D37656



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


[PATCH] D38159: [clang] Fix printf fixit for objc specific types

2017-09-21 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.

Let's take a look at the following example: 
for the triple thumbv7-apple-ios8.0.0 ssize_t is long and size_t is unsigned 
long,
while NSInteger is int and NSUinteger is unsigned int.
Following 
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html
Clang will catch it and insert a cast to long, for example
 printf("%zd", getNSInteger())
will be replaced with 
 printf("%zd", (long)getNSInteger())
but since the underlying type of ssize_t is long the specifier "%zd" is not 
getting replaced.
This diff changes this behavior to enabling replacing the specifier "%zd" with 
the correct one.

Test plan: make check-all


Repository:
  rL LLVM

https://reviews.llvm.org/D38159

Files:
  lib/Sema/SemaChecking.cpp
  test/FixIt/fixit-format-ios.m


Index: test/FixIt/fixit-format-ios.m
===
--- test/FixIt/fixit-format-ios.m
+++ test/FixIt/fixit-format-ios.m
@@ -0,0 +1,27 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -fsyntax-only -fblocks 
-Wformat -fixit %t
+// RUN: grep -v CHECK %t | FileCheck %s
+
+int printf(const char * restrict, ...);
+typedef unsigned int NSUInteger;
+typedef int NSInteger;
+NSUInteger getNSUInteger();
+NSInteger getNSInteger();
+
+void test() {
+  // For thumbv7-apple-ios8.0.0 
+  // the underlying type of size_t is unsigned long 
+  // and for ssize_t it is long.
+
+  printf("test 1: %zu", getNSUInteger()); 
+  // CHECK: printf("test 1: %lu", (unsigned long)getNSUInteger());
+
+  printf("test 2: %zu %zu", getNSUInteger(), getNSUInteger());
+  // CHECK: printf("test 2: %lu %lu", (unsigned long)getNSUInteger(), 
(unsigned long)getNSUInteger());
+
+  printf("test 3: %zd", getNSInteger()); 
+  // CHECK: printf("test 3: %ld", (long)getNSInteger());
+
+  printf("test 4: %zd %zd", getNSInteger(), getNSInteger());
+  // CHECK: printf("test 4: %ld %ld", (long)getNSInteger(), 
(long)getNSInteger());
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -6346,7 +6346,7 @@
   CastFix << ")";
 
   SmallVector Hints;
-  if (!AT.matchesType(S.Context, IntendedTy))
+  if (!AT.matchesType(S.Context, IntendedTy) || ShouldNotPrintDirectly) 
 Hints.push_back(FixItHint::CreateReplacement(SpecRange, os.str()));
 
   if (const CStyleCastExpr *CCast = dyn_cast(E)) {


Index: test/FixIt/fixit-format-ios.m
===
--- test/FixIt/fixit-format-ios.m
+++ test/FixIt/fixit-format-ios.m
@@ -0,0 +1,27 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -triple thumbv7-apple-ios8.0.0 -fsyntax-only -fblocks -Wformat -fixit %t
+// RUN: grep -v CHECK %t | FileCheck %s
+
+int printf(const char * restrict, ...);
+typedef unsigned int NSUInteger;
+typedef int NSInteger;
+NSUInteger getNSUInteger();
+NSInteger getNSInteger();
+
+void test() {
+  // For thumbv7-apple-ios8.0.0 
+  // the underlying type of size_t is unsigned long 
+  // and for ssize_t it is long.
+
+  printf("test 1: %zu", getNSUInteger()); 
+  // CHECK: printf("test 1: %lu", (unsigned long)getNSUInteger());
+
+  printf("test 2: %zu %zu", getNSUInteger(), getNSUInteger());
+  // CHECK: printf("test 2: %lu %lu", (unsigned long)getNSUInteger(), (unsigned long)getNSUInteger());
+
+  printf("test 3: %zd", getNSInteger()); 
+  // CHECK: printf("test 3: %ld", (long)getNSInteger());
+
+  printf("test 4: %zd %zd", getNSInteger(), getNSInteger());
+  // CHECK: printf("test 4: %ld %ld", (long)getNSInteger(), (long)getNSInteger());
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -6346,7 +6346,7 @@
   CastFix << ")";
 
   SmallVector Hints;
-  if (!AT.matchesType(S.Context, IntendedTy))
+  if (!AT.matchesType(S.Context, IntendedTy) || ShouldNotPrintDirectly) 
 Hints.push_back(FixItHint::CreateReplacement(SpecRange, os.str()));
 
   if (const CStyleCastExpr *CCast = dyn_cast(E)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r313943 - Extend -ast-dump for CXXRecordDecl to dump the flags from the DefinitionData.

2017-09-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Sep 21 17:11:15 2017
New Revision: 313943

URL: http://llvm.org/viewvc/llvm-project?rev=313943&view=rev
Log:
Extend -ast-dump for CXXRecordDecl to dump the flags from the DefinitionData.

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/test/Frontend/float16.cpp
cfe/trunk/test/Misc/ast-dump-decl.cpp
cfe/trunk/test/Misc/ast-dump-invalid.cpp
cfe/trunk/test/Misc/pragma-attribute-cxx-subject-match-rules.cpp
cfe/trunk/test/Misc/pragma-attribute-cxx.cpp
cfe/trunk/test/Modules/cxx-templates.cpp
cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=313943&r1=313942&r2=313943&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Thu Sep 21 17:11:15 2017
@@ -1376,6 +1376,128 @@ void ASTDumper::VisitCXXRecordDecl(const
   if (!D->isCompleteDefinition())
 return;
 
+  dumpChild([=] {
+{
+  ColorScope Color(*this, DeclKindNameColor);
+  OS << "DefinitionData";
+}
+#define FLAG(fn, name) if (D->fn()) OS << " " #name;
+FLAG(isParsingBaseSpecifiers, parsing_base_specifiers);
+
+FLAG(isGenericLambda, generic);
+FLAG(isLambda, lambda);
+
+FLAG(canPassInRegisters, pass_in_registers);
+FLAG(isEmpty, empty);
+FLAG(isAggregate, aggregate);
+FLAG(isStandardLayout, standard_layout);
+FLAG(isTriviallyCopyable, trivially_copyable);
+FLAG(isPOD, pod);
+FLAG(isTrivial, trivial);
+FLAG(isPolymorphic, polymorphic);
+FLAG(isAbstract, abstract);
+FLAG(isLiteral, literal);
+
+FLAG(hasUserDeclaredConstructor, has_user_declared_ctor);
+FLAG(hasConstexprNonCopyMoveConstructor, has_constexpr_non_copy_move_ctor);
+FLAG(hasMutableFields, has_mutable_fields);
+FLAG(hasVariantMembers, has_variant_members);
+FLAG(allowConstDefaultInit, can_const_default_init);
+
+dumpChild([=] {
+  {
+ColorScope Color(*this, DeclKindNameColor);
+OS << "DefaultConstructor";
+  }
+  FLAG(hasDefaultConstructor, exists);
+  FLAG(hasTrivialDefaultConstructor, trivial);
+  FLAG(hasNonTrivialDefaultConstructor, non_trivial);
+  FLAG(hasUserProvidedDefaultConstructor, user_provided);
+  FLAG(hasConstexprDefaultConstructor, constexpr);
+  FLAG(needsImplicitDefaultConstructor, needs_implicit);
+  FLAG(defaultedDefaultConstructorIsConstexpr, defaulted_is_constexpr);
+});
+
+dumpChild([=] {
+  {
+ColorScope Color(*this, DeclKindNameColor);
+OS << "CopyConstructor";
+  }
+  FLAG(hasSimpleCopyConstructor, simple);
+  FLAG(hasTrivialCopyConstructor, trivial);
+  FLAG(hasNonTrivialCopyConstructor, non_trivial);
+  FLAG(hasUserDeclaredCopyConstructor, user_declared);
+  FLAG(hasCopyConstructorWithConstParam, has_const_param);
+  FLAG(needsImplicitCopyConstructor, needs_implicit);
+  FLAG(needsOverloadResolutionForCopyConstructor,
+   needs_overload_resolution);
+  if (!D->needsOverloadResolutionForCopyConstructor())
+FLAG(defaultedCopyConstructorIsDeleted, defaulted_is_deleted);
+  FLAG(implicitCopyConstructorHasConstParam, implicit_has_const_param);
+});
+
+dumpChild([=] {
+  {
+ColorScope Color(*this, DeclKindNameColor);
+OS << "MoveConstructor";
+  }
+  FLAG(hasMoveConstructor, exists);
+  FLAG(hasSimpleMoveConstructor, simple);
+  FLAG(hasTrivialMoveConstructor, trivial);
+  FLAG(hasNonTrivialMoveConstructor, non_trivial);
+  FLAG(hasUserDeclaredMoveConstructor, user_declared);
+  FLAG(needsImplicitMoveConstructor, needs_implicit);
+  FLAG(needsOverloadResolutionForMoveConstructor,
+   needs_overload_resolution);
+  if (!D->needsOverloadResolutionForMoveConstructor())
+FLAG(defaultedMoveConstructorIsDeleted, defaulted_is_deleted);
+});
+
+dumpChild([=] {
+  {
+ColorScope Color(*this, DeclKindNameColor);
+OS << "CopyAssignment";
+  }
+  FLAG(hasTrivialCopyAssignment, trivial);
+  FLAG(hasNonTrivialCopyAssignment, non_trivial);
+  FLAG(hasCopyAssignmentWithConstParam, has_const_param);
+  FLAG(hasUserDeclaredCopyAssignment, user_declared);
+  FLAG(needsImplicitCopyAssignment, needs_implicit);
+  FLAG(needsOverloadResolutionForCopyAssignment, 
needs_overload_resolution);
+  FLAG(implicitCopyAssignmentHasConstParam, implicit_has_const_param);
+});
+
+dumpChild([=] {
+  {
+ColorScope Color(*this, DeclKindNameColor);
+OS << "MoveAssignment";
+  }
+  FLAG(hasMoveAssignment, exists);
+  FLAG(hasSimpleMoveAssignment, simple);
+  FLAG(hasTrivialMoveAssignment, trivial);
+  FLAG(hasNonTrivialMoveAssignment, non_trivial);
+  FLAG(hasUserDeclaredMoveAssignment, user_declared);

[PATCH] D38118: [CodeGen][ObjC] Build the global block structure before emitting the body of global block invoke functions

2017-09-21 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.

LGTM with one tweak.




Comment at: lib/CodeGen/CGBlocks.cpp:1124
LocalDeclMap,
-   false);
+   false, true);
   }

Please /*comment*/ the meaning of these bools.


https://reviews.llvm.org/D38118



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


LLVM buildmaster will be updated and restarted tonight

2017-09-21 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 7 PM Pacific time.

Thanks

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


[PATCH] D37656: [cfi] Set function attributes for __cfi_* functions.

2017-09-21 Thread Eric Christopher via Phabricator via cfe-commits
echristo added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:2917
+CodeGenFunction &CGF, llvm::Function *F,
+bool ForceThumb) {
+  StringRef TargetCPU = CGF.getTarget().getTargetOpts().CPU;

I don't think we should be force setting thumb anywhere, it should be handled 
on a function by function basis the way we do all of the target attribute stuff.



Comment at: clang/lib/CodeGen/CGExpr.cpp:2926-2935
+  Features.reserve(DefaultFeatures.size() + ForceThumb);
+  if (ForceThumb && (Triple.isARM() || Triple.isThumb())) {
+for (auto &S : DefaultFeatures)
+  if (S != "-thumb-mode" && S != "+thumb-mode")
+Features.push_back(S);
+Features.push_back("+thumb-mode");
+  } else {

All of this should be handled in lib/Basic/Targets/ARM.cpp 
ARMTargetInfo::initFeatureMap ?



Comment at: clang/lib/CodeGen/CGExpr.cpp:2961-2963
+  // attributes as SetLLVMFunctionAttributes sets. In particular, __cfi_check
+  // must use the default calling convention for the platform. ABI-changing
+  // flags like -mhard-float should not affect __cfi_check.

This is odd. Can you explain this a bit more?


https://reviews.llvm.org/D37656



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


r313944 - [Analyzer] Log when auto-synthesized body is used.

2017-09-21 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Sep 21 17:37:12 2017
New Revision: 313944

URL: http://llvm.org/viewvc/llvm-project?rev=313944&view=rev
Log:
[Analyzer] Log when auto-synthesized body is used.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=313944&r1=313943&r2=313944&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Thu Sep 21 17:37:12 2017
@@ -21,6 +21,9 @@
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Debug.h"
+
+#define DEBUG_TYPE "static-analyzer-call-event"
 
 using namespace clang;
 using namespace ento;
@@ -343,7 +346,6 @@ ArrayRef AnyFunctionCall::
   return D->parameters();
 }
 
-
 RuntimeDefinition AnyFunctionCall::getRuntimeDefinition() const {
   const FunctionDecl *FD = getDecl();
   // Note that the AnalysisDeclContext will have the FunctionDecl with
@@ -352,8 +354,17 @@ RuntimeDefinition AnyFunctionCall::getRu
 AnalysisDeclContext *AD =
   getLocationContext()->getAnalysisDeclContext()->
   getManager()->getContext(FD);
-if (AD->getBody())
-  return RuntimeDefinition(AD->getDecl());
+bool IsAutosynthesized;
+Stmt* Body = AD->getBody(IsAutosynthesized);
+DEBUG({
+if (IsAutosynthesized)
+  llvm::dbgs() << "Using autosynthesized body for " << FD->getName()
+   << "\n";
+});
+if (Body) {
+  const Decl* Decl = AD->getDecl();
+  return RuntimeDefinition(Decl);
+}
   }
 
   return RuntimeDefinition();


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


  1   2   >