[PATCH] [Request, 142 lines] D25074: [clang-tidy] Improve rename_check.py

2016-09-30 Thread Kirill Bobyrev via cfe-commits
omtcyfz created this revision.
omtcyfz added reviewers: ClockMan, ioeric, aaron.ballman.
omtcyfz added a subscriber: cfe-commits.

Start using `argparse` instead of mimicking CLI parsing.

PEPify the code.


https://reviews.llvm.org/D25074

Files:
  clang-tidy/rename_check.py

Index: clang-tidy/rename_check.py
===
--- clang-tidy/rename_check.py
+++ clang-tidy/rename_check.py
@@ -13,81 +13,99 @@
 import re
 import sys
 import glob
+import argparse
+
 
 def replaceInFile(fileName, sFrom, sTo):
-  if sFrom == sTo:
-return
-  txt = None
-  with open(fileName, "r") as f:
-txt = f.read()
+if sFrom == sTo:
+return
+txt = None
+with open(fileName, "r") as f:
+txt = f.read()
+
+if sFrom not in txt:
+return
 
-  if sFrom not in txt:
-return
+txt = txt.replace(sFrom, sTo)
+print("Replace '%s' -> '%s' in '%s'" % (sFrom, sTo, fileName))
+with open(fileName, "w") as f:
+f.write(txt)
 
-  txt = txt.replace(sFrom, sTo)
-  print("Replace '%s' -> '%s' in '%s'" % (sFrom, sTo, fileName))
-  with open(fileName, "w") as f:
-f.write(txt)
 
 def generateCommentLineHeader(filename):
-  return ''.join(['//===--- ',
-  os.path.basename(filename),
-  ' - clang-tidy ',
-  '-' * max(0, 42 - len(os.path.basename(filename))),
-  '*- C++ -*-===//'])
+return ''.join(['//===--- ',
+os.path.basename(filename),
+' - clang-tidy ',
+'-' * max(0, 42 - len(os.path.basename(filename))),
+'*- C++ -*-===//'])
+
 
 def generateCommentLineSource(filename):
-  return ''.join(['//===--- ',
-  os.path.basename(filename),
-  ' - clang-tidy',
-  '-' * max(0, 52 - len(os.path.basename(filename))),
-  '-===//'])
+return ''.join(['//===--- ',
+os.path.basename(filename),
+' - clang-tidy',
+'-' * max(0, 52 - len(os.path.basename(filename))),
+'-===//'])
+
 
 def fileRename(fileName, sFrom, sTo):
-  if sFrom not in fileName:
-return fileName
-  newFileName = fileName.replace(sFrom, sTo)
-  print("Rename '%s' -> '%s'" % (fileName, newFileName))
-  os.rename(fileName, newFileName)
-  return newFileName
+if sFrom not in fileName:
+return fileName
+newFileName = fileName.replace(sFrom, sTo)
+print("Rename '%s' -> '%s'" % (fileName, newFileName))
+os.rename(fileName, newFileName)
+return newFileName
+
 
 def getListOfFiles(clang_tidy_path):
-  files =  glob.glob(os.path.join(clang_tidy_path,'*'))
-  for dirname in files:
-if os.path.isdir(dirname):
-  files += glob.glob(os.path.join(dirname,'*'))
-  files += glob.glob(os.path.join(clang_tidy_path,'..', 'test', 'clang-tidy', '*'))
-  files += glob.glob(os.path.join(clang_tidy_path,'..', 'docs', 'clang-tidy', 'checks', '*'))
-  return [filename for filename in files if os.path.isfile(filename)]
+files = glob.glob(os.path.join(clang_tidy_path, '*'))
+for dirname in files:
+if os.path.isdir(dirname):
+files += glob.glob(os.path.join(dirname, '*'))
+files += glob.glob(os.path.join(clang_tidy_path, '..', 'test',
+'clang-tidy', '*'))
+files += glob.glob(os.path.join(clang_tidy_path, '..', 'docs',
+'clang-tidy', 'checks', '*'))
+return [filename for filename in files if os.path.isfile(filename)]
+
 
 def main():
-  if len(sys.argv) != 4:
-print('Usage: rename_check.py   \n')
-print('   example: rename_check.py misc awesome-functions new-awesome-function')
-return
-
-  module = sys.argv[1].lower()
-  check_name = sys.argv[2]
-  check_name_camel = ''.join(map(lambda elem: elem.capitalize(),
- check_name.split('-'))) + 'Check'
-  check_name_new = sys.argv[3]
-  check_name_new_camel = ''.join(map(lambda elem: elem.capitalize(),
- check_name_new.split('-'))) + 'Check'
-
-  clang_tidy_path = os.path.dirname(sys.argv[0])
-
-  header_guard_old = module.upper() + '_' + check_name.upper().replace('-', '_')
-  header_guard_new = module.upper() + '_' + check_name_new.upper().replace('-', '_')
-
-  for filename in getListOfFiles(clang_tidy_path):
-originalName = filename
-filename = fileRename(filename, check_name, check_name_new)
-filename = fileRename(filename, check_name_camel, check_name_new_camel)
-replaceInFile(filename, generateCommentLineHeader(originalName), generateCommentLineHeader(filename))
-replaceInFile(filename, generateCommentLineSource(originalName), generateCommentLineSource(filename))
-replaceInFile(filename, header_guard_old, header_guard_new)
-replaceInFile(filename, check_name, check_name_new)
-replaceInFile(filename, check_nam

[PATCH] [Changed Subscribers] D25074: [clang-tidy] Improve rename_check.py

2016-09-30 Thread Alexander Shaposhnikov via cfe-commits
alexshap added inline comments.


> rename_check.py:81
> +args = parser.parse_args()
> +print(args)
> +

the script always prints the args, is it intentional ?

https://reviews.llvm.org/D25074



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


[PATCH] [Updated, 82 lines] D25068: [coroutines] Switch to using std::experimental namespace per P0057R5

2016-09-30 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 73000.
EricWF added a comment.

Run patch through clang-format.


https://reviews.llvm.org/D25068

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -1,18 +1,18 @@
 // RUN: %clang_cc1 -std=c++14 -fcoroutines -verify %s
 
 void no_coroutine_traits_bad_arg_await() {
-  co_await a; // expected-error {{include }}
+  co_await a; // expected-error {{include }}
   // expected-error@-1 {{use of undeclared identifier 'a'}}
 }
 
 void no_coroutine_traits_bad_arg_yield() {
-  co_yield a; // expected-error {{include }}
+  co_yield a; // expected-error {{include }}
   // expected-error@-1 {{use of undeclared identifier 'a'}}
 }
 
 
 void no_coroutine_traits_bad_arg_return() {
-  co_return a; // expected-error {{include }}
+  co_return a; // expected-error {{include }}
   // expected-error@-1 {{use of undeclared identifier 'a'}}
 }
 
@@ -36,45 +36,59 @@
 };
 
 void no_coroutine_traits() {
-  co_await a; // expected-error {{need to include }}
+  co_await a; // expected-error {{need to include }}
 }
 
 namespace std {
-  template struct coroutine_traits; // expected-note {{declared here}}
-};
+namespace experimental {
+template 
+struct coroutine_traits; // expected-note {{declared here}}
+}
+}
 
 template struct coro {};
-template
-struct std::coroutine_traits, Ps...> {
+template 
+struct std::experimental::coroutine_traits, Ps...> {
   using promise_type = Promise;
 };
 
 void no_specialization() {
-  co_await a; // expected-error {{implicit instantiation of undefined template 'std::coroutine_traits'}}
+  co_await a; // expected-error {{implicit instantiation of undefined template 'std::experimental::coroutine_traits'}}
 }
 
-template struct std::coroutine_traits {};
+template 
+struct std::experimental::coroutine_traits {};
 
 int no_promise_type() {
-  co_await a; // expected-error {{this function cannot be a coroutine: 'std::coroutine_traits' has no member named 'promise_type'}}
+  co_await a; // expected-error {{this function cannot be a coroutine: 'std::experimental::coroutine_traits' has no member named 'promise_type'}}
 }
 
-template<> struct std::coroutine_traits { typedef int promise_type; };
+template <>
+struct std::experimental::coroutine_traits { typedef int promise_type; };
 double bad_promise_type(double) {
-  co_await a; // expected-error {{this function cannot be a coroutine: 'std::coroutine_traits::promise_type' (aka 'int') is not a class}}
+  co_await a; // expected-error {{this function cannot be a coroutine: 'experimental::coroutine_traits::promise_type' (aka 'int') is not a class}}
 }
 
-template<> struct std::coroutine_traits {
+template <>
+struct std::experimental::coroutine_traits {
   struct promise_type {};
 };
 double bad_promise_type_2(int) {
-  co_yield 0; // expected-error {{no member named 'yield_value' in 'std::coroutine_traits::promise_type'}}
+  co_yield 0; // expected-error {{no member named 'yield_value' in 'std::experimental::coroutine_traits::promise_type'}}
 }
 
 struct promise; // expected-note 2{{forward declaration}}
-template struct std::coroutine_traits { using promise_type = promise; };
+template 
+struct std::experimental::coroutine_traits { using promise_type = promise; };
+
+namespace std {
+namespace experimental {
+template 
+struct coroutine_handle;
+}
+}
 
-  // FIXME: This diagnostic is terrible.
+// FIXME: This diagnostic is terrible.
 void undefined_promise() { // expected-error {{variable has incomplete type 'promise_type'}}
   // FIXME: This diagnostic doesn't make any sense.
   // expected-error@-2 {{incomplete definition of type 'promise'}}
@@ -200,7 +214,8 @@
 }
 
 struct yield_fn_tag {};
-template<> struct std::coroutine_traits {
+template <>
+struct std::experimental::coroutine_traits {
   struct promise_type {
 // FIXME: add an await_transform overload for functions
 awaitable yield_value(int());
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -8111,6 +8111,7 @@
   bool IsInline = InlineLoc.isValid();
   bool IsInvalid = false;
   bool IsStd = false;
+  bool IsStdExperimental = false;
   bool AddToKnown = false;
   Scope *DeclRegionScope = NamespcScope->getParent();
 
@@ -8152,6 +8153,11 @@
   PrevNS = getStdNamespace();
   IsStd = true;
   AddToKnown = !IsInline;
+} else if (II->isStr("experimental") &&
+   CurContext->getRedeclContext()->isStdNamespace()) {
+  PrevNS = getStdExperimentalNamespace();
+  IsStdExperimental = true;
+  AddToKnown = !IsInline;
 } else {
   // We've seen this namespace for the first time.
   AddToKnown = !IsInline;
@@ -8186,6 +8192,8 @@
 
 

[PATCH] [Commented On] D25068: [coroutines] Switch to using std::experimental namespace per P0057R5

2016-09-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Hijacked to address review comments. @GorNishanov feel free to commandeer this 
revision back.


https://reviews.llvm.org/D25068



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


[PATCH] [Updated, 383 lines] D24916: [analyzer] Extend bug reports with extra notes - CloneChecker

2016-09-30 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 72991.
NoQ added a comment.

- Update the commit messages.
- Move a run-away test file to its correct directory.
- Fix a copy-paste error in initialization of the variable field of a clone 
pair.


https://reviews.llvm.org/D24916

Files:
  include/clang/Analysis/CloneDetection.h
  lib/Analysis/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  test/Analysis/copypaste/blocks.cpp
  test/Analysis/copypaste/function-try-block.cpp
  test/Analysis/copypaste/functions.cpp
  test/Analysis/copypaste/macro-complexity.cpp
  test/Analysis/copypaste/macros.cpp
  test/Analysis/copypaste/objc-methods.m
  test/Analysis/copypaste/plist-diagnostics-notes-as-events.cpp
  test/Analysis/copypaste/plist-diagnostics.cpp
  test/Analysis/copypaste/sub-sequences.cpp
  test/Analysis/copypaste/suspicious-clones.cpp
  test/Analysis/copypaste/text-diagnostics.cpp

Index: test/Analysis/copypaste/text-diagnostics.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/text-diagnostics.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -analyze -analyzer-output=text -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+void log();
+
+int max(int a, int b) { // expected-warning{{Duplicate code detected}} // expected-note{{Duplicate code detected}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) { // expected-note{{Similar code here}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
Index: test/Analysis/copypaste/suspicious-clones.cpp
===
--- test/Analysis/copypaste/suspicious-clones.cpp
+++ test/Analysis/copypaste/suspicious-clones.cpp
@@ -8,14 +8,14 @@
   log();
   if (a > b)
 return a;
-  return b; // expected-note{{suggestion is based on the usage of this variable in a similar piece of code}}
+  return b; // expected-note{{Similar code using 'b' here}}
 }
 
 int maxClone(int x, int y, int z) {
   log();
   if (x > y)
 return x;
-  return z; // expected-warning{{suspicious code clone detected; did you mean to use 'y'?}}
+  return z; // expected-warning{{Potential copy-paste error; did you really mean to use 'z' here?}}
 }
 
 // Tests finding a suspicious clone that references global variables.
@@ -33,7 +33,7 @@
   while (true) {
 if (m1.try_lock()) {
   ++i;
-  m1.unlock(); // expected-note{{suggestion is based on the usage of this variable in a similar piece of code}}
+  m1.unlock(); // expected-note{{Similar code using 'm1' here}}
   if (i > 1000) {
 return;
   }
@@ -45,7 +45,7 @@
   while (true) {
 if (m1.try_lock()) {
   ++i;
-  m2.unlock();  // expected-warning{{suspicious code clone detected; did you mean to use 'm1'?}}
+  m2.unlock();  // expected-warning{{Potential copy-paste error; did you really mean to use 'm2' here?}}
   if (i > 1000) {
 return;
   }
@@ -58,14 +58,14 @@
 int foo(int a, int b, int c) {
   a += b + c;
   b /= a + b;
-  c -= b * a; // expected-warning{{suspicious code clone detected; did you mean to use 'a'?}}
+  c -= b * a; // expected-warning{{Potential copy-paste error; did you really mean to use 'b' here?}}
   return c;
 }
 
 int fooClone(int a, int b, int c) {
   a += b + c;
   b /= a + b;
-  c -= a * a; // expected-note{{suggestion is based on the usage of this variable in a similar piece of code; did you mean to use 'b'?}}
+  c -= a * a; // expected-note{{Similar code using 'a' here}}
   return c;
 }
 
@@ -77,21 +77,21 @@
 long bar1(long a, long b, long c, long d) {
   c = a - b;
   c = c / d * a;
-  d = b * b - c; // expected-warning{{suspicious code clone detected; did you mean to use 'c'?}}
+  d = b * b - c; // expected-warning{{Potential copy-paste error; did you really mean to use 'b' here?}}
   return d;
 }
 
 long bar2(long a, long b, long c, long d) {
   c = a - b;
   c = c / d * a;
-  d = c * b - c; // expected-note{{suggestion is based on the usage of this variable in a similar piece of code; did you mean to use 'b'?}} \
- // expected-warning{{suspicious code clone detected; did you mean to use 'a'?}}
+  d = c * b - c; // expected-note{{Similar code using 'c' here}} \
+ // expected-warning{{Potential copy-paste error; did you really mean to use 'c' here?}}
   return d;
 }
 
 long bar3(long a, long b, long c, long d) {
   c = a - b;
   c = c / d * a;
-  d = a * b - c; // expected-note{{suggestion is based on the usage of this variable in a similar piece of code; did you mean to use 'c'?}}
+  d = a * b - c; // expected-note{{Similar code using 'a' here}}
   return d;
 }
Index: test/Analysis/copypaste/sub-sequences.cpp
===
--- test/Analysis/copypaste/sub-sequences.cpp
+++ test/Analysis/copypaste/sub-sequences.cpp
@@ -7,14 +7,14 @@
 
 int max(int a, int b) {
   log2(a);
-  log(); // expected-warning{{Detected code clon

[PATCH] [Accepted] D25060: [Coroutines] Fix assertion about uncorrected typos in co_await/co_yield/co_return expressions.

2016-09-30 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a reviewer: EricWF.
EricWF added a comment.
This revision is now accepted and ready to land.

Committed in r282792.


https://reviews.llvm.org/D25060



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


[PATCH] [Request, 15 lines] D25078: [Coroutines] Diagnose when 'main' is declared as a coroutine.

2016-09-30 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: rsmith, GorNishanov.
EricWF added a subscriber: cfe-commits.
Herald added a subscriber: mehdi_amini.

The title says it all.


https://reviews.llvm.org/D25078

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCoroutine.cpp
  test/SemaCXX/coroutines.cpp


Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -283,3 +283,11 @@
 coro bad_final_suspend() { // expected-error {{no member named 
'await_ready' in 'not_awaitable'}}
   co_await a;
 }
+
+
+template<> struct std::coroutine_traits
+{ using promise_type = promise; };
+
+int main(int, const char**) { // expected-error {{'main' cannot be a 
coroutine}}
+  co_await a; // expected-note {{function is a coroutine due to use of 
'co_await' here}}
+}
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -127,6 +127,11 @@
 S.Diag(Loc, diag::err_coroutine_constexpr) << Keyword;
   } else if (FD->isVariadic()) {
 S.Diag(Loc, diag::err_coroutine_varargs) << Keyword;
+  } else if (FD->isMain()) {
+S.Diag(FD->getLocStart(), diag::err_coroutine_main);
+S.Diag(Loc, diag::note_declared_coroutine_here)
+  << (Keyword == "co_await" ? 0 :
+  Keyword == "co_yield" ? 1 : 2);
   } else {
 auto *ScopeInfo = S.getCurFunction();
 assert(ScopeInfo && "missing function scope for function");
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8562,6 +8562,8 @@
   "'%1' cannot be used in a %select{constructor|destructor}0">;
 def err_coroutine_constexpr : Error<
   "'%0' cannot be used in a constexpr function">;
+def err_coroutine_main : Error<
+  "'main' cannot be a coroutine">;
 def err_coroutine_varargs : Error<
   "'%0' cannot be used in a varargs function">;
 def ext_coroutine_without_co_await_co_yield : ExtWarn<


Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -283,3 +283,11 @@
 coro bad_final_suspend() { // expected-error {{no member named 'await_ready' in 'not_awaitable'}}
   co_await a;
 }
+
+
+template<> struct std::coroutine_traits
+{ using promise_type = promise; };
+
+int main(int, const char**) { // expected-error {{'main' cannot be a coroutine}}
+  co_await a; // expected-note {{function is a coroutine due to use of 'co_await' here}}
+}
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -127,6 +127,11 @@
 S.Diag(Loc, diag::err_coroutine_constexpr) << Keyword;
   } else if (FD->isVariadic()) {
 S.Diag(Loc, diag::err_coroutine_varargs) << Keyword;
+  } else if (FD->isMain()) {
+S.Diag(FD->getLocStart(), diag::err_coroutine_main);
+S.Diag(Loc, diag::note_declared_coroutine_here)
+  << (Keyword == "co_await" ? 0 :
+  Keyword == "co_yield" ? 1 : 2);
   } else {
 auto *ScopeInfo = S.getCurFunction();
 assert(ScopeInfo && "missing function scope for function");
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8562,6 +8562,8 @@
   "'%1' cannot be used in a %select{constructor|destructor}0">;
 def err_coroutine_constexpr : Error<
   "'%0' cannot be used in a constexpr function">;
+def err_coroutine_main : Error<
+  "'main' cannot be a coroutine">;
 def err_coroutine_varargs : Error<
   "'%0' cannot be used in a varargs function">;
 def ext_coroutine_without_co_await_co_yield : ExtWarn<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] [Accepted] D24922: [clang-move] Make it support both relative and absolute file path arguments.

2016-09-30 Thread Eric Liu via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lg with nits.



> ClangMove.cpp:36
> +  llvm::sys::fs::make_absolute(InitialDirectory, AbsolutePath))
> +llvm::errs() << "warning: could not make absolute file: '" <<  
> EC.message()
> + << '\n';

s/warning/Warning/

> ClangMove.cpp:51
> +   
> SM.getFileManager().getVirtualFileSystem()->makeAbsolute(AbsolutePath))
> +llvm::errs() << "warning: could not make absolute file: '" <<  
> EC.message()
> + << '\n';

s/warning/Warning

> database_template.json:3
> +{
> +  "directory": "test_dir/build",
> +  "command": "clang++ -o test.o test_dir/test.cpp",

Maybe decorate "test_dir" as "$test_dir" or "%test_dir" or similar so that 
others would know it is gonna replaced.

https://reviews.llvm.org/D24922



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


[PATCH] [Commented On] D24380: [migrate-tool] Framework for a codebase-dependent migration tool.

2016-09-30 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


> MigrateTool.cpp:52
> +  // Get all files that are affected by the migration, i.e. users of the 
> symbol.
> +  auto Files = 
> Env.getAffectedFilesFinder().getAffectedFiles(Spec.getOldName());
> +  if (!Files)

I'm wondering whether we really want to evolve this to a callback / executor 
based design. That is, have AffectedFilesFinder give an interface like 
RunOnAffectedFiles(...)

https://reviews.llvm.org/D24380



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


[PATCH] [Updated, 225 lines] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-30 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 73007.
rmaprath added a comment.

Updated with the following changes:

- Address review comments from @EricWF and @compnerd regarding using 
`_POSIX_THREADS` for detecting pthread availability. Now the patch is checking 
for `defined(_POSIX_THREADS) && _POSIX_THREADS >= 0` instead of enumerating the 
platforms.
- Fix a missed pthread dependency in `cxa_guard.cpp`. The call to 
`pthread_mach_thread_np` is now replaced with 
`__libcxxabi_thread_get_current_id()`.
- Fix a couple of missing pthread dependencies in `test_exception_storage.cpp` 
(see patch below).

@EricWF: Hope the new changes look OK? I'm going to test this on a Mac before 
committing.

I will also ping https://reviews.llvm.org/D21803 and 
https://reviews.llvm.org/D17815, as they'll be affected by this patch (those 
patches add more pthread calls).


https://reviews.llvm.org/D24864

Files:
  CMakeLists.txt
  src/config.h
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/fallback_malloc.ipp
  src/threading_support.h
  test/test_exception_storage.pass.cpp
  test/test_fallback_malloc.pass.cpp

Index: test/test_fallback_malloc.pass.cpp
===
--- test/test_fallback_malloc.pass.cpp
+++ test/test_fallback_malloc.pass.cpp
@@ -10,7 +10,7 @@
 #include 
 #include 
 
-#include 
+#include "../src/threading_support.h"
 
 typedef std::deque container;
 
Index: test/test_exception_storage.pass.cpp
===
--- test/test_exception_storage.pass.cpp
+++ test/test_exception_storage.pass.cpp
@@ -12,9 +12,7 @@
 #include 
 #include 
 #include 
-#ifndef _LIBCXXABI_HAS_NO_THREADS
-#  include 
-#endif
+#include "../src/threading_support.h"
 #include 
 
 #include "../src/cxa_exception.hpp"
@@ -40,19 +38,19 @@
 
 #ifndef _LIBCXXABI_HAS_NO_THREADS
 #define NUMTHREADS  10
-size_t  thread_globals [ NUMTHREADS ] = { 0 };
-pthread_t   threads[ NUMTHREADS ];
+size_t thread_globals [ NUMTHREADS ] = { 0 };
+__libcxxabi_thread_t   threads[ NUMTHREADS ];
 #endif
 
 int main ( int argc, char *argv [] ) {
 int retVal = 0;
 
 #ifndef _LIBCXXABI_HAS_NO_THREADS
 //  Make the threads, let them run, and wait for them to finish
 for ( int i = 0; i < NUMTHREADS; ++i )
-pthread_create( threads + i, NULL, thread_code, (void *) (thread_globals + i));
+__libcxxabi_thread_create ( threads + i, thread_code, (void *) (thread_globals + i));
 for ( int i = 0; i < NUMTHREADS; ++i )
-pthread_join ( threads [ i ], NULL );
+__libcxxabi_thread_join ( &threads [ i ] );
 
 for ( int i = 0; i < NUMTHREADS; ++i )
 if ( 0 == thread_globals [ i ] ) {
Index: src/threading_support.h
===
--- /dev/null
+++ src/threading_support.h
@@ -0,0 +1,109 @@
+//=== threading_support.h -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCXXABI_THREADING_SUPPORT_H
+#define _LIBCXXABI_THREADING_SUPPORT_H
+
+#include "__cxxabi_config.h"
+#include "config.h"
+
+#ifndef _LIBCXXABI_HAS_NO_THREADS
+
+#if defined(_LIBCXXABI_USE_THREAD_API_PTHREAD)
+#include 
+
+#define _LIBCXXABI_THREAD_ABI_VISIBILITY inline _LIBCXXABI_INLINE_VISIBILITY
+
+// Mutex
+typedef pthread_mutex_t __libcxxabi_mutex_t;
+#define _LIBCXXABI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_lock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_lock(mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_unlock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_unlock(mutex);
+}
+
+// Condition variable
+typedef pthread_cond_t __libcxxabi_condvar_t;
+#define _LIBCXXABI_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_wait(__libcxxabi_condvar_t *cv,
+ __libcxxabi_mutex_t *mutex) {
+  return pthread_cond_wait(cv, mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_broadcast(__libcxxabi_condvar_t *cv) {
+  return pthread_cond_broadcast(cv);
+}
+
+// Execute once
+typedef pthread_once_t __libcxxabi_exec_once_flag;
+#define _LIBCXXABI_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_execute_once(__libcxxabi_exec_once_flag *flag,
+ void (*init_routine)(void)) {
+  return pthread_once(flag, init_routine);
+}
+
+// Thread
+typedef pthread_t __libcxxabi_thread_id;
+typedef pthread_t __libcxxabi_thread_t;
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+__libcxxabi_thread_id __libcxxabi_thread_get_cur

[PATCH] [Updated] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-09-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

@tavianator: I'm about to commit https://reviews.llvm.org/D24864, which will 
affect this patch (indirectly). https://reviews.llvm.org/D24864 basically 
refactors all pthread dependencies behind a separate API. It would be pretty 
straightforward for you to update this patch though, just replacing pthread 
calls with ones in `thread_support.h` (perhaps adding anything missing).

Hope you don't mind me going first? If you are going to commit this soon, I can 
hold off https://reviews.llvm.org/D24864. Let me know.

Cheers,

/ Asiri


https://reviews.llvm.org/D21803



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


[PATCH] [Updated] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

2016-09-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

@ikudrin: Looks like you've reverted this soon after. I'm just about to commit 
https://reviews.llvm.org/D24864, which will affect this slightly. 
https://reviews.llvm.org/D24864 basically refactors all pthread dependencies 
behind a separate API. It would be pretty straightforward for you to update 
this patch though, just replacing pthread calls with ones in thread_support.h 
(perhaps adding anything missing).

Hope you don't mind me going first? If you are going to commit this soon, I can 
hold off https://reviews.llvm.org/D24864. Let me know.

Cheers,

/ Asiri


Repository:
  rL LLVM

https://reviews.llvm.org/D17815



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


[PATCH] [Commented On] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-09-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

@rmaprath I'll merge this if needed. Feel free to commit your patch first.

@tavianator Do you need somebody to merge this for you?


https://reviews.llvm.org/D21803



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


[PATCH] [Accepted] D25049: Add missing std::move in Replacements::add

2016-09-30 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


Repository:
  rL LLVM

https://reviews.llvm.org/D25049



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


[PATCH] [Commented On] D24380: [migrate-tool] Framework for a codebase-dependent migration tool.

2016-09-30 Thread Eric Liu via cfe-commits
ioeric added inline comments.


> klimek wrote in MigrateTool.cpp:52
> I'm wondering whether we really want to evolve this to a callback / executor 
> based design. That is, have AffectedFilesFinder give an interface like 
> RunOnAffectedFiles(...)

That sounds like a good design, but I'm not sure if we need this at this point 
since actions on affected files would simply be renaming and include fixing now 
and in the foreseeable future.

https://reviews.llvm.org/D24380



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


[PATCH] [Commented On] D24380: [migrate-tool] Framework for a codebase-dependent migration tool.

2016-09-30 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


> ioeric wrote in MigrateTool.cpp:52
> That sounds like a good design, but I'm not sure if we need this at this 
> point since actions on affected files would simply be renaming and include 
> fixing now and in the foreseeable future.

Well, my main concern is how we hook this up to full codebase wide analyses. 
Currently, we basically hard-code the execution strategy, right?

https://reviews.llvm.org/D24380



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


[PATCH] [Updated, 96 lines] D24965: [clang-tidy] Fix cppcoreguidelines-pro-type-member-init false negatives

2016-09-30 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 73019.
malcolm.parsons added a comment.

Rebase


https://reviews.llvm.org/D24965

Files:
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
  clang-tidy/utils/TypeTraits.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -377,3 +377,25 @@
 {
   NegativeInClassInitializedDefaulted s;
 }
+
+struct PositiveVirtualMethod {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructor does not initialize these fields: F
+  int F;
+  // CHECK-FIXES: int F{};
+  virtual int f() = 0;
+};
+
+struct PositiveVirtualDestructor {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructor does not initialize these fields: F
+  PositiveVirtualDestructor() = default;
+  int F;
+  // CHECK-FIXES: int F{};
+  virtual ~PositiveVirtualDestructor() {}
+};
+
+struct PositiveVirtualBase : public virtual NegativeAggregateType {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructor does not initialize these bases: NegativeAggregateType
+  // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: constructor does not initialize these fields: F
+  int F;
+  // CHECK-FIXES: int F{};
+};
Index: clang-tidy/utils/TypeTraits.cpp
===
--- clang-tidy/utils/TypeTraits.cpp
+++ clang-tidy/utils/TypeTraits.cpp
@@ -58,6 +58,9 @@
   // constructible.
   if (ClassDecl->hasUserProvidedDefaultConstructor())
 return false;
+  // A polymorphic class is not trivially constructible
+  if (ClassDecl->isPolymorphic())
+return false;
   // A class is trivially constructible if it has a trivial default constructor.
   if (ClassDecl->hasTrivialDefaultConstructor())
 return true;
@@ -73,6 +76,8 @@
   for (const CXXBaseSpecifier &Base : ClassDecl->bases()) {
 if (!isTriviallyDefaultConstructible(Base.getType(), Context))
   return false;
+if (Base.isVirtual())
+  return false;
   }
 
   return true;
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
@@ -46,11 +46,13 @@
   // To fix: Write a data member initializer, or mention it in the member
   // initializer list.
   void checkMissingMemberInitializer(ASTContext &Context,
+ const CXXRecordDecl *ClassDecl,
  const CXXConstructorDecl *Ctor);
 
   // A subtle side effect of Type.6 part 2:
   // Make sure to initialize trivially constructible base classes.
   void checkMissingBaseClassInitializer(const ASTContext &Context,
+const CXXRecordDecl *ClassDecl,
 const CXXConstructorDecl *Ctor);
 
   // Checks Type.6 part 2:
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -269,6 +269,19 @@
IsNonTrivialDefaultConstructor))
   .bind("ctor"),
   this);
+
+  // Match classes with a default constructor that is defaulted or is not in the
+  // AST.
+  Finder->addMatcher(
+  cxxRecordDecl(
+  isDefinition(),
+  anyOf(has(cxxConstructorDecl(isDefaultConstructor(), isDefaulted(),
+   unless(isImplicit(,
+unless(has(cxxConstructorDecl(,
+  unless(isTriviallyDefaultConstructible()))
+  .bind("record"),
+  this);
+
   auto HasDefaultConstructor = hasInitializer(
   cxxConstructExpr(unless(requiresZeroInitialization()),
hasDeclaration(cxxConstructorDecl(
@@ -287,8 +300,13 @@
 // Skip declarations delayed by late template parsing without a body.
 if (!Ctor->getBody())
   return;
-checkMissingMemberInitializer(*Result.Context, Ctor);
-checkMissingBaseClassInitializer(*Result.Context, Ctor);
+checkMissingMemberInitializer(*Result.Context, Ctor->getParent(), Ctor);
+checkMissingBaseClassInitializer(*Result.Context, Ctor->getParent(), Ctor);
+  } else if (const auto *Record =
+ Result.Nodes.getNodeAs("record")) {
+assert(Record->hasDefaultConstructor());
+checkMissingMemberInitializer(*Result.Context, Record, nullptr);
+checkMissingBaseClassInitializer(*Result.Context, Record, nullptr);
   } else if (const auto *Var = Result.Nodes.getNodeAs("var")) {
 checkUninitializedTrivialType(*Result.Context, Var);
   }

[PATCH] [Updated, 141 lines] D25074: [clang-tidy] Improve rename_check.py

2016-09-30 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 73018.
omtcyfz marked an inline comment as done.
omtcyfz added a comment.

Remove leftover from debugging.


https://reviews.llvm.org/D25074

Files:
  clang-tidy/rename_check.py

Index: clang-tidy/rename_check.py
===
--- clang-tidy/rename_check.py
+++ clang-tidy/rename_check.py
@@ -13,81 +13,98 @@
 import re
 import sys
 import glob
+import argparse
+
 
 def replaceInFile(fileName, sFrom, sTo):
-  if sFrom == sTo:
-return
-  txt = None
-  with open(fileName, "r") as f:
-txt = f.read()
+if sFrom == sTo:
+return
+txt = None
+with open(fileName, "r") as f:
+txt = f.read()
+
+if sFrom not in txt:
+return
 
-  if sFrom not in txt:
-return
+txt = txt.replace(sFrom, sTo)
+print("Replace '%s' -> '%s' in '%s'" % (sFrom, sTo, fileName))
+with open(fileName, "w") as f:
+f.write(txt)
 
-  txt = txt.replace(sFrom, sTo)
-  print("Replace '%s' -> '%s' in '%s'" % (sFrom, sTo, fileName))
-  with open(fileName, "w") as f:
-f.write(txt)
 
 def generateCommentLineHeader(filename):
-  return ''.join(['//===--- ',
-  os.path.basename(filename),
-  ' - clang-tidy ',
-  '-' * max(0, 42 - len(os.path.basename(filename))),
-  '*- C++ -*-===//'])
+return ''.join(['//===--- ',
+os.path.basename(filename),
+' - clang-tidy ',
+'-' * max(0, 42 - len(os.path.basename(filename))),
+'*- C++ -*-===//'])
+
 
 def generateCommentLineSource(filename):
-  return ''.join(['//===--- ',
-  os.path.basename(filename),
-  ' - clang-tidy',
-  '-' * max(0, 52 - len(os.path.basename(filename))),
-  '-===//'])
+return ''.join(['//===--- ',
+os.path.basename(filename),
+' - clang-tidy',
+'-' * max(0, 52 - len(os.path.basename(filename))),
+'-===//'])
+
 
 def fileRename(fileName, sFrom, sTo):
-  if sFrom not in fileName:
-return fileName
-  newFileName = fileName.replace(sFrom, sTo)
-  print("Rename '%s' -> '%s'" % (fileName, newFileName))
-  os.rename(fileName, newFileName)
-  return newFileName
+if sFrom not in fileName:
+return fileName
+newFileName = fileName.replace(sFrom, sTo)
+print("Rename '%s' -> '%s'" % (fileName, newFileName))
+os.rename(fileName, newFileName)
+return newFileName
+
 
 def getListOfFiles(clang_tidy_path):
-  files =  glob.glob(os.path.join(clang_tidy_path,'*'))
-  for dirname in files:
-if os.path.isdir(dirname):
-  files += glob.glob(os.path.join(dirname,'*'))
-  files += glob.glob(os.path.join(clang_tidy_path,'..', 'test', 'clang-tidy', '*'))
-  files += glob.glob(os.path.join(clang_tidy_path,'..', 'docs', 'clang-tidy', 'checks', '*'))
-  return [filename for filename in files if os.path.isfile(filename)]
+files = glob.glob(os.path.join(clang_tidy_path, '*'))
+for dirname in files:
+if os.path.isdir(dirname):
+files += glob.glob(os.path.join(dirname, '*'))
+files += glob.glob(os.path.join(clang_tidy_path, '..', 'test',
+'clang-tidy', '*'))
+files += glob.glob(os.path.join(clang_tidy_path, '..', 'docs',
+'clang-tidy', 'checks', '*'))
+return [filename for filename in files if os.path.isfile(filename)]
+
 
 def main():
-  if len(sys.argv) != 4:
-print('Usage: rename_check.py   \n')
-print('   example: rename_check.py misc awesome-functions new-awesome-function')
-return
-
-  module = sys.argv[1].lower()
-  check_name = sys.argv[2]
-  check_name_camel = ''.join(map(lambda elem: elem.capitalize(),
- check_name.split('-'))) + 'Check'
-  check_name_new = sys.argv[3]
-  check_name_new_camel = ''.join(map(lambda elem: elem.capitalize(),
- check_name_new.split('-'))) + 'Check'
-
-  clang_tidy_path = os.path.dirname(sys.argv[0])
-
-  header_guard_old = module.upper() + '_' + check_name.upper().replace('-', '_')
-  header_guard_new = module.upper() + '_' + check_name_new.upper().replace('-', '_')
-
-  for filename in getListOfFiles(clang_tidy_path):
-originalName = filename
-filename = fileRename(filename, check_name, check_name_new)
-filename = fileRename(filename, check_name_camel, check_name_new_camel)
-replaceInFile(filename, generateCommentLineHeader(originalName), generateCommentLineHeader(filename))
-replaceInFile(filename, generateCommentLineSource(originalName), generateCommentLineSource(filename))
-replaceInFile(filename, header_guard_old, header_guard_new)
-replaceInFile(filename, check_name, check_name_new)
-replaceInFile(filename, check_name_camel, check_name_new_camel)
+parser = argparse.Argumen

[PATCH] [Commented On] D24380: [migrate-tool] Framework for a codebase-dependent migration tool.

2016-09-30 Thread Eric Liu via cfe-commits
ioeric added inline comments.


> klimek wrote in MigrateTool.cpp:52
> Well, my main concern is how we hook this up to full codebase wide analyses. 
> Currently, we basically hard-code the execution strategy, right?

I see. That makes sense then. Thanks!

https://reviews.llvm.org/D24380



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


[PATCH] [Updated, 134 lines] D25024: [clang-tidy] Add check for detecting declarations with multiple names

2016-09-30 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 73025.
omtcyfz marked an inline comment as done.
omtcyfz added a comment.

Minor improvements.


https://reviews.llvm.org/D25024

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.cpp
  clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-one-name-per-declaration.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-one-name-per-declaration.cpp

Index: test/clang-tidy/cppcoreguidelines-one-name-per-declaration.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-one-name-per-declaration.cpp
@@ -0,0 +1,16 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-one-name-per-declaration %t
+
+int main() {
+  {
+int x = 42;
+  }
+  {
+int x = 42, y = 43;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Do not declare multiple names per declaration [cppcoreguidelines-one-name-per-declaration]
+  }
+  {
+int x = 42, y = 43, z = 44;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Do not declare multiple names per declaration
+  }
+  return 0;
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -19,6 +19,7 @@
cert-flp30-c
cert-oop11-cpp (redirects to misc-move-constructor-init) 
cppcoreguidelines-interfaces-global-init
+   cppcoreguidelines-one-name-per-declaration
cppcoreguidelines-pro-bounds-array-to-pointer-decay
cppcoreguidelines-pro-bounds-constant-array-index
cppcoreguidelines-pro-bounds-pointer-arithmetic
Index: docs/clang-tidy/checks/cppcoreguidelines-one-name-per-declaration.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-one-name-per-declaration.rst
@@ -0,0 +1,29 @@
+.. title:: clang-tidy - cppcoreguidelines-one-name-per-declaration
+
+cppcoreguidelines-one-name-per-declaration
+==
+
+Checks for declarations with multiple names. C++ Core Guidelines suggests to
+split such declarations into multiple declarations each containing one name.
+
+This would improve readability and prevents potential bugs caused by inattention
+and C/C++ syntax specifics.
+
+Example, bad.
+
+.. code-block:: c++
+
+  std::vector velocities(10, 0), numbers(other_numbers),
+   inputs(input.begin(), input.end());
+
+Example, good.
+
+.. code-block:: c++
+
+  std::vector velocities(10, 0);
+  std::vector numbers(other_numbers);
+  std::vector inputs(input.begin(), input.end());
+
+This rule is part of the "Expressions and statements" profile of the C++ Core
+Guidelines, see
+http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#a-nameres-name-oneaes10-declare-one-name-only-per-declaration
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,12 @@
 Improvements to clang-tidy
 --
 
+- New `cppcoreguidelines-one-name-per-declaration
+  `_ check
+
+  Warns when multiple variables are declared within a single declaration
+  statement, e.g. `int a, b, c`.
+
 - New `cppcoreguidelines-slicing
   `_ check
 
Index: clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.h
===
--- /dev/null
+++ clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.h
@@ -0,0 +1,35 @@
+//===--- OneNamePerDeclarationCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_ONE_NAME_PER_DECLARATION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_ONE_NAME_PER_DECLARATION_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace cppcoreguidelines {
+
+/// This check warns about multiple names in one declaration.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-one-name-per-declaration.html
+class OneNamePerDeclarationCheck : public ClangTidyCheck {
+public:
+  OneNamePerDeclarationCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;

[PATCH] [Commented On] D25024: [clang-tidy] Add check for detecting declarations with multiple names

2016-09-30 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.


> omtcyfz wrote in OneNamePerDeclarationCheck.cpp:30
> Sure it can. I just thought `declCountIsGreaterThan` might be useful at some 
> point.

Actually, for the sake of simplicity I'll use `unless(declCountIs(1))`, when 
some other part of code would need similar stuff we'd add it. For now it's only 
one use case, so I should be fine.

Thank you very much for the suggestion!

> Eugene.Zelenko wrote in ReleaseNotes.rst:62
> Please add one sentence description. Probably //Checks for declarations with 
> multiple names.// should be enough.

Aw, yes, totally forgot about that. Thank you very much!

https://reviews.llvm.org/D25024



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


[PATCH] [Commented On] D25074: [clang-tidy] Improve rename_check.py

2016-09-30 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.


> alexshap wrote in rename_check.py:81
> the script always prints the args, is it intentional ?

Aw, a leftover from debugging.

Good catch! Thanks for the note!

https://reviews.llvm.org/D25074



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


[PATCH] [Commented On] D25019: [clang-tidy] Make add_new_check.py Python 3 compatible

2016-09-30 Thread Benjamin Kramer via cfe-commits
bkramer added inline comments.


> add_new_check.py:16
>  
> +from six.moves import filter
> +

Can we rely on six being available? It's not part of the default python 
installation afaik.

https://reviews.llvm.org/D25019



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


[PATCH] [Commented On] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D24864#556845, @rmaprath wrote:

> I'm going to test this on a Mac before committing.


Good call that was, wouldn't have compiled there. Attaching updated patch soon.


https://reviews.llvm.org/D24864



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


[PATCH] [Updated, 223 lines] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-30 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 73033.
rmaprath added a comment.

`pthread_mach_thread_np` is Mac specific. I've introduced a Mac-only 
`__libcxxabi_thread_get_port()` API call to sort this out (didn't think it 
would be nice to leave a pthread call even if it is Mac specific).

I can revisit this if there is a better approach. Will commit now.


https://reviews.llvm.org/D24864

Files:
  CMakeLists.txt
  src/config.h
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/fallback_malloc.ipp
  src/threading_support.h
  test/test_exception_storage.pass.cpp
  test/test_fallback_malloc.pass.cpp

Index: test/test_fallback_malloc.pass.cpp
===
--- test/test_fallback_malloc.pass.cpp
+++ test/test_fallback_malloc.pass.cpp
@@ -10,7 +10,7 @@
 #include 
 #include 
 
-#include 
+#include "../src/threading_support.h"
 
 typedef std::deque container;
 
Index: test/test_exception_storage.pass.cpp
===
--- test/test_exception_storage.pass.cpp
+++ test/test_exception_storage.pass.cpp
@@ -12,9 +12,7 @@
 #include 
 #include 
 #include 
-#ifndef _LIBCXXABI_HAS_NO_THREADS
-#  include 
-#endif
+#include "../src/threading_support.h"
 #include 
 
 #include "../src/cxa_exception.hpp"
@@ -40,19 +38,19 @@
 
 #ifndef _LIBCXXABI_HAS_NO_THREADS
 #define NUMTHREADS  10
-size_t  thread_globals [ NUMTHREADS ] = { 0 };
-pthread_t   threads[ NUMTHREADS ];
+size_t thread_globals [ NUMTHREADS ] = { 0 };
+__libcxxabi_thread_t   threads[ NUMTHREADS ];
 #endif
 
 int main ( int argc, char *argv [] ) {
 int retVal = 0;
 
 #ifndef _LIBCXXABI_HAS_NO_THREADS
 //  Make the threads, let them run, and wait for them to finish
 for ( int i = 0; i < NUMTHREADS; ++i )
-pthread_create( threads + i, NULL, thread_code, (void *) (thread_globals + i));
+__libcxxabi_thread_create ( threads + i, thread_code, (void *) (thread_globals + i));
 for ( int i = 0; i < NUMTHREADS; ++i )
-pthread_join ( threads [ i ], NULL );
+__libcxxabi_thread_join ( &threads [ i ] );
 
 for ( int i = 0; i < NUMTHREADS; ++i )
 if ( 0 == thread_globals [ i ] ) {
Index: src/threading_support.h
===
--- /dev/null
+++ src/threading_support.h
@@ -0,0 +1,107 @@
+//=== threading_support.h -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCXXABI_THREADING_SUPPORT_H
+#define _LIBCXXABI_THREADING_SUPPORT_H
+
+#include "__cxxabi_config.h"
+#include "config.h"
+
+#ifndef _LIBCXXABI_HAS_NO_THREADS
+
+#if defined(_LIBCXXABI_USE_THREAD_API_PTHREAD)
+#include 
+
+#define _LIBCXXABI_THREAD_ABI_VISIBILITY inline _LIBCXXABI_INLINE_VISIBILITY
+
+// Mutex
+typedef pthread_mutex_t __libcxxabi_mutex_t;
+#define _LIBCXXABI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_lock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_lock(mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_unlock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_unlock(mutex);
+}
+
+// Condition variable
+typedef pthread_cond_t __libcxxabi_condvar_t;
+#define _LIBCXXABI_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_wait(__libcxxabi_condvar_t *cv,
+ __libcxxabi_mutex_t *mutex) {
+  return pthread_cond_wait(cv, mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_broadcast(__libcxxabi_condvar_t *cv) {
+  return pthread_cond_broadcast(cv);
+}
+
+// Execute once
+typedef pthread_once_t __libcxxabi_exec_once_flag;
+#define _LIBCXXABI_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_execute_once(__libcxxabi_exec_once_flag *flag,
+ void (*init_routine)(void)) {
+  return pthread_once(flag, init_routine);
+}
+
+// Thread id
+#if defined(__APPLE__) && !defined(__arm__)
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+mach_port_t __libcxxabi_thread_get_port()
+{
+return pthread_mach_thread_np(pthread_self());
+}
+#endif
+
+// Thread
+typedef pthread_t __libcxxabi_thread_t;
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_thread_create(__libcxxabi_thread_t* __t,
+   void* (*__func)(void*), void* __arg)
+{
+return pthread_create(__t, 0, __func, __arg);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_thread_join(__libcxxabi_thread_t* __t)
+{
+return pthread_join(*__t, 0);
+}
+
+// TLS
+typedef pthread_key_t __libcxxabi_tls_key;
+
+_LIBCXXABI_THREAD_ABI_VIS

[PATCH] [Reopened] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

2016-09-30 Thread Igor Kudrin via cfe-commits
ikudrin reopened this revision.
ikudrin added a comment.
This revision is now accepted and ready to land.

@rmaprath: There are some issues in the test which upset build bots and I need 
some time to fix them. You don't need to wait for me, I'll put my patch on the 
top of yours when my fix is ready.


Repository:
  rL LLVM

https://reviews.llvm.org/D17815



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


[PATCH] [Commented On] D21698: [OpenCL] Allow disabling types and declarations associated with extensions

2016-09-30 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Sam, I ran a few more tests and understood that the overhead mainly comes from 
extra initialization (in Sema::Initialize()). Therefore, it's more noticeable 
on a very small kernels.  However, I agree we can probably neglect the overhead 
as it account for only a couple % of overall time max in Release mode. Sorry, 
for taking this long time.



> yaxunl wrote in DiagnosticSemaKinds.td:7998
> these two error msgs have different format.
> 
>   def err_type_requires_extension : Error<
>"use of type %0 requires %1 extension to be enabled">;
> 
> err_type_requires_extension has an extra type name argument.

I guess we could multiplex with select and pass an empty string as a first 
parameter to the diagnostic? Apart from that, the core part seems to be the 
same.

> yaxunl wrote in ParsePragma.cpp:461
> Using PointerIntPair with 2 bits requires IdentifierInfo to be aligned at 4 
> bytes, however this is not true. IdentifierInfo has no explicit alignment 
> specifier, therefore it can only hold 1 bit in PointerIntPair.

Based on its structure with having a pointer member I think it's reasonable to 
assume at least 4 bytes alignment... Although this doesn't seem to affect the 
performance anyways.

> ParsePragma.cpp:1429
>PP.Lex(Tok);
> -  if (Tok.isNot(tok::identifier)) {
> -PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_enable_disable);
> +  if (Tok.isNot(tok::identifier) && Tok.isNot(tok::kw_register)) {
> +PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_predicate) << 0;

Not clear why register keyword is here too?

> Sema.cpp:226
>   Context.getAtomicType(Context.UnsignedIntTy));
> -  addImplicitTypedef("atomic_long", 
> Context.getAtomicType(Context.LongTy));
> -  addImplicitTypedef("atomic_ulong",
> - Context.getAtomicType(Context.UnsignedLongTy));
> +  auto AtomicLongT = Context.getAtomicType(Context.LongTy);
> +  addImplicitTypedef("atomic_long", AtomicLongT);

Any reason for changing this too?

> yaxunl wrote in Sema.cpp:1558
> This function can be called grammatically to set extensions for a group of 
> image types, e.g., the extensions associated with image types. It is more 
> convenient to allow empty string here. If empty string is not allowed, it can 
> be diagnosed before calling this function.

Could we then check for an empty string ExtStr as a first function statement 
instead?

> opencl-atomics-cl20.cl:51
>  // expected-error@-28 {{use of type 'atomic_double' (aka '_Atomic(double)') 
> requires cl_khr_int64_extended_atomics extension to be enabled}}
> -// expected-error-re@-27 {{use of type 'atomic_intptr_t' (aka 
> '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be 
> enabled}}
> -// expected-error-re@-28 {{use of type 'atomic_intptr_t' (aka 
> '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be 
> enabled}}
> -// expected-error-re@-28 {{use of type 'atomic_uintptr_t' (aka 
> '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be 
> enabled}}
> -// expected-error-re@-29 {{use of type 'atomic_uintptr_t' (aka 
> '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be 
> enabled}}
> -// expected-error-re@-29 {{use of type 'atomic_size_t' (aka 
> '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be 
> enabled}}
> -// expected-error-re@-30 {{use of type 'atomic_size_t' (aka 
> '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be 
> enabled}}
> -// expected-error-re@-30 {{use of type 'atomic_ptrdiff_t' (aka 
> '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be 
> enabled}}
> -// expected-error-re@-31 {{use of type 'atomic_ptrdiff_t' (aka 
> '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be 
> enabled}}
> +#if __LP64__
> +// expected-error-re@-28 {{use of type 'atomic_intptr_t' (aka 
> '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be 
> enabled}}

Why this change?

> extension-begin.cl:27
> +}
> +
> +#pragma OPENCL EXTENSION my_ext : disable 

Could you please add case with typedef of a type from an extensions and also 
using it with qualifiers for the better coverage.

https://reviews.llvm.org/D21698



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


[PATCH] [Commented On] D25019: [clang-tidy] Make add_new_check.py Python 3 compatible

2016-09-30 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.


> bkramer wrote in add_new_check.py:16
> Can we rely on six being available? It's not part of the default python 
> installation afaik.

Yes, I am pretty sure about that. Absolute majority of Python projects relies 
on having six available and Python installation without six seems really weird 
to me.

This is THE standard library for Python 2.7.X/3.X compatibility issues.

https://reviews.llvm.org/D25019



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


[PATCH] [Accepted] D25019: [clang-tidy] Make add_new_check.py Python 3 compatible

2016-09-30 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

Okay. If six is installed by default on Ubuntu and macOS we should be fine. The 
script isn't in the critical path for anyone.


https://reviews.llvm.org/D25019



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


[PATCH] [Commented On] D25024: [clang-tidy] Add check for detecting declarations with multiple names

2016-09-30 Thread Eric Liu via cfe-commits
ioeric added a comment.

The code looks about right, but I am not the right person to decide whether 
checks go into clang-tidy.


https://reviews.llvm.org/D25024



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


[PATCH] [Commented On] D25019: [clang-tidy] Make add_new_check.py Python 3 compatible

2016-09-30 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

UPD: This patch is eventually causing some problems in Python 3. Working on 
that.


https://reviews.llvm.org/D25019



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


[PATCH] [Commented On] D25024: [clang-tidy] Add check for detecting declarations with multiple names

2016-09-30 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

In https://reviews.llvm.org/D25024#557033, @ioeric wrote:

> The code looks about right, but I am not the right person to decide whether 
> checks go into clang-tidy.


Okay, thank you!


https://reviews.llvm.org/D25024



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


Re: [llvm-dev] Upgrading phabricator

2016-09-30 Thread Aaron Ballman via cfe-commits
On Fri, Sep 30, 2016 at 2:04 AM, Eric Liu via cfe-commits
 wrote:
> I've switched the default email format to be plain text only now. This
> option should be per-user configurable, but somehow it is not shown in the
> "Settings"; I'll try if I can make the option personalized.

Thank you for working on this upgrade!

Is there a way that we can remove the [Request, X lines] tag from the
email headers on phab patches? While it's neat to understand how large
a patch is, you can get a rough feel for that information by looking
at the patch contents. Unfortunately, the extra text means we lose
information from the subject line when viewing emails from a smaller
screen (like a mobile device), so I'm not certain that the utility
warrants the cost (at least, to me).

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


Re: [llvm-dev] Upgrading phabricator

2016-09-30 Thread Eric Liu via cfe-commits
Thanks for the feedback Aaron! :)

I've disabled it. I think the annoying part really is the status (e.g.
Request, Closed etc) in the tag, and I am wondering if a tag with just line
numbers like "(N Loc)" would be better. But I'm not really sure about the
trade-off here.

- Eric

On Fri, Sep 30, 2016 at 3:05 PM Aaron Ballman 
wrote:

> On Fri, Sep 30, 2016 at 2:04 AM, Eric Liu via cfe-commits
>  wrote:
> > I've switched the default email format to be plain text only now. This
> > option should be per-user configurable, but somehow it is not shown in
> the
> > "Settings"; I'll try if I can make the option personalized.
>
> Thank you for working on this upgrade!
>
> Is there a way that we can remove the [Request, X lines] tag from the
> email headers on phab patches? While it's neat to understand how large
> a patch is, you can get a rough feel for that information by looking
> at the patch contents. Unfortunately, the extra text means we lose
> information from the subject line when viewing emails from a smaller
> screen (like a mobile device), so I'm not certain that the utility
> warrants the cost (at least, to me).
>
> ~Aaron
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [llvm-dev] Upgrading phabricator

2016-09-30 Thread Aaron Ballman via cfe-commits
On Fri, Sep 30, 2016 at 9:21 AM, Eric Liu  wrote:
> Thanks for the feedback Aaron! :)
>
> I've disabled it. I think the annoying part really is the status (e.g.
> Request, Closed etc) in the tag, and I am wondering if a tag with just line
> numbers like "(N Loc)" would be better. But I'm not really sure about the
> trade-off here.

Thank you for disabling it! Also, I agree, the Request, Closed, etc
stuff is also rather superfluous in some regards. But that at least
helps to determine whether the email is one I can archive immediately
or not (such as something that's been closed or abandoned), so perhaps
there is some utility with it? I do agree that it distracts from the
subject line, unfortunately.

~Aaron

>
> - Eric
>
> On Fri, Sep 30, 2016 at 3:05 PM Aaron Ballman 
> wrote:
>>
>> On Fri, Sep 30, 2016 at 2:04 AM, Eric Liu via cfe-commits
>>  wrote:
>> > I've switched the default email format to be plain text only now. This
>> > option should be per-user configurable, but somehow it is not shown in
>> > the
>> > "Settings"; I'll try if I can make the option personalized.
>>
>> Thank you for working on this upgrade!
>>
>> Is there a way that we can remove the [Request, X lines] tag from the
>> email headers on phab patches? While it's neat to understand how large
>> a patch is, you can get a rough feel for that information by looking
>> at the patch contents. Unfortunately, the extra text means we lose
>> information from the subject line when viewing emails from a smaller
>> screen (like a mobile device), so I'm not certain that the utility
>> warrants the cost (at least, to me).
>>
>> ~Aaron
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25092: [analyzer] Add "Assuming..." diagnostic pieces for short-circuit logical operators.

2016-09-30 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added reviewers: zaks.anna, dcoughlin, xazax.hun, a.sidorin.
NoQ added a subscriber: cfe-commits.

Fix clang path event diagnostics around operators `&&` and `||`. Now there's a 
separate event for both sides of the operator.

Control flow pieces are unaffected - they're still broken, a bit more broken 
for operator `||`.

This fix should go on top of https://reviews.llvm.org/D23300.

A few html examples:

F2456635: before-1.html  F2456636: 
before-2.html  F2456637: before-3.html 

F2456632: after-1.html  F2456633: 
after-2.html  F2456634: after-3.html 



https://reviews.llvm.org/D25092

Files:
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  test/Analysis/conditional-path-notes.c
  test/Analysis/edges-new.mm

Index: test/Analysis/edges-new.mm
===
--- test/Analysis/edges-new.mm
+++ test/Analysis/edges-new.mm
@@ -7655,53 +7655,19 @@
 // CHECK-NEXT:   
 // CHECK-NEXT: 
 // CHECK-NEXT: 
-// CHECK-NEXT:  kindcontrol
-// CHECK-NEXT:  edges
-// CHECK-NEXT:   
-// CHECK-NEXT:
-// CHECK-NEXT: start
-// CHECK-NEXT:  
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col19
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col22
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:  
-// CHECK-NEXT: end
-// CHECK-NEXT:  
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col7
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col7
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:  
-// CHECK-NEXT:
-// CHECK-NEXT:   
-// CHECK-NEXT: 
-// CHECK-NEXT: 
 // CHECK-NEXT:  kindevent
 // CHECK-NEXT:  location
 // CHECK-NEXT:  
 // CHECK-NEXT:   line263
-// CHECK-NEXT:   col7
+// CHECK-NEXT:   col19
 // CHECK-NEXT:   file0
 // CHECK-NEXT:  
 // CHECK-NEXT:  ranges
 // CHECK-NEXT:  
 // CHECK-NEXT:
 // CHECK-NEXT: 
 // CHECK-NEXT:  line263
-// CHECK-NEXT:  col7
+// CHECK-NEXT:  col19
 // CHECK-NEXT:  file0
 // CHECK-NEXT: 
 // CHECK-NEXT: 
@@ -7713,9 +7679,9 @@
 // CHECK-NEXT:  
 // CHECK-NEXT:  depth0
 // CHECK-NEXT:  extended_message
-// CHECK-NEXT:  Assuming the condition is true
+// CHECK-NEXT:  Assuming 'coin' is not equal to 0
 // CHECK-NEXT:  message
-// CHECK-NEXT:  Assuming the condition is true
+// CHECK-NEXT:  Assuming 'coin' is not equal to 0
 // CHECK-NEXT: 
 // CHECK-NEXT: 
 // CHECK-NEXT:  kindcontrol
@@ -7726,12 +7692,12 @@
 // CHECK-NEXT:  
 // CHECK-NEXT:   
 // CHECK-NEXT:line263
-// CHECK-NEXT:col7
+// CHECK-NEXT:col19
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
 // CHECK-NEXT:   
 // CHECK-NEXT:line263
-// CHECK-NEXT:col7
+// CHECK-NEXT:col22
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
 // CHECK-NEXT:  
@@ -8000,53 +7966,19 @@
 // CHECK-NEXT:   
 // CHECK-NEXT: 
 // CHECK-NEXT: 
-// CHECK-NEXT:  kindcontrol
-// CHECK-NEXT:  edges
-// CHECK-NEXT:   
-// CHECK-NEXT:
-// CHECK-NEXT: start
-// CHECK-NEXT:  
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col19
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col22
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:  
-// CHECK-NEXT: end
-// CHECK-NEXT:  
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col7
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col7
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:  
-// CHECK-NEXT:
-// CHECK-NEXT:   
-// CHECK-NEXT: 
-// CHECK-NEXT: 
 // CHECK-NEXT:  kindevent
 // CHECK-NEXT:  location
 // CHECK-NEXT:  
 // CHECK-NEXT:   line263
-// CHECK-NEXT:   col7
+// CHECK-NEXT:   col19
 // CHECK-NEXT:   file0
 // CHECK-NEXT:  
 // CHECK-NEXT:  ranges
 // CHECK-NEXT:  
 // CHECK-NEXT:
 // CHECK-NEXT: 
 // CHECK-NEXT:  line263
-// CHECK-NEXT: 

[PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2016-09-30 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

This patch doesn't detect more complex conflicts (like the following code), but 
I think it's OK for now.

  asm ("foo" : "=Q" (x) : : "%rax", "%rbx", "%rcx", "%rdx"); // Q: Any register 
accessible as rh: a, b, c, and d. 



> TargetInfo.h:593
>///
>/// For example, on x86 it will return "ax" when "eax" is passed in.
> +  StringRef getNormalizedGCCRegisterName(StringRef Name,

It looks like this comment was wrong: it didn't return "ax" when "eax" was 
passed in Name.

> TargetInfo.cpp:406
>  StringRef
> -TargetInfo::getNormalizedGCCRegisterName(StringRef Name) const {
> +TargetInfo::getNormalizedGCCRegisterName(StringRef Name,
> +bool ReturnCannonical) const {

I think it's spelled "Canonical" rather than "Cannonical".

The comment added here doesn't seem correct to me. ReturnCanonical is used to 
make this function return the "canonical" register instead of the register 
passed in Name (e.g., when ReturnCanonical=true and Name="rax", it returns 
"ax").

> Targets.cpp:2718
> +  switch (Constraint[i]) {
> +// Ignore these
> +  case '*':

Can we skip the checks for all these non-alphabet characters and handle them in 
"default"? Would doing so be incorrect?

> asm.c:34
> +  int a,b,c;
> +  asm ("nop" : "=r" (no_clobber_conflict) : "r" (clobber_conflict) : 
> "%rcx"); // expected-error {{asm-specifier for input or output variable 
> conflicts with asm clobber list}}
> +  asm ("nop" : "=r" (clobber_conflict) : "r" (no_clobber_conflict) : 
> "%rcx"); // expected-error {{asm-specifier for input or output variable 
> conflicts with asm clobber list}}

Do you think you can improve the error message using '^' so that it's clear 
which constraint has a conflict with the clobbers? I was thinking about 
something like this:

error: inline-asm constraint "=r" conflicts with clobber list

asm ("nop" : "=r" (no_clobber_conflict) : "r" (clobber_conflict) : "%rcx");

  ^

https://reviews.llvm.org/D15075



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


[PATCH] D25093: [libcxx] [cmake] Allow testing against installed LLVM with no sources

2016-09-30 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: EricWF, beanz.
mgorny added a subscriber: cfe-commits.

Adjust the stand-alone build files to accept either CMake files from 
LLVM_CMAKE_PATH or from LLVM_MAIN_SRC_DIR instead of requiring both.  This 
makes it possible to run libcxx  tests on top of installed LLVM and lit, 
without having to unpack a copy of LLVM sources. Furthermore, it avoids adding 
duplicate paths.


https://reviews.llvm.org/D25093

Files:
  cmake/Modules/HandleOutOfTreeLLVM.cmake


Index: cmake/Modules/HandleOutOfTreeLLVM.cmake
===
--- cmake/Modules/HandleOutOfTreeLLVM.cmake
+++ cmake/Modules/HandleOutOfTreeLLVM.cmake
@@ -43,21 +43,16 @@
 return()
   endif()
 
-  if (NOT EXISTS ${LLVM_MAIN_SRC_DIR})
-set(LLVM_FOUND OFF)
-message(WARNING "Not found: ${LLVM_MAIN_SRC_DIR}")
-return()
-  endif()
-
-  if(NOT EXISTS ${LLVM_CMAKE_PATH})
+  if (EXISTS "${LLVM_CMAKE_PATH}")
+list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
+  elseif (EXISTS "${LLVM_MAIN_SRC_DIR}/cmake/modules")
+list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
+  else()
 set(LLVM_FOUND OFF)
-message(WARNING "Not found: ${LLVM_CMAKE_PATH}")
+message(WARNING "Neither ${LLVM_CMAKE_PATH} nor 
${LLVM_MAIN_SRC_DIR}/cmake/modules found")
 return()
   endif()
 
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
-
   set(LLVM_FOUND ON)
 endmacro(find_llvm_parts)
 


Index: cmake/Modules/HandleOutOfTreeLLVM.cmake
===
--- cmake/Modules/HandleOutOfTreeLLVM.cmake
+++ cmake/Modules/HandleOutOfTreeLLVM.cmake
@@ -43,21 +43,16 @@
 return()
   endif()
 
-  if (NOT EXISTS ${LLVM_MAIN_SRC_DIR})
-set(LLVM_FOUND OFF)
-message(WARNING "Not found: ${LLVM_MAIN_SRC_DIR}")
-return()
-  endif()
-
-  if(NOT EXISTS ${LLVM_CMAKE_PATH})
+  if (EXISTS "${LLVM_CMAKE_PATH}")
+list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
+  elseif (EXISTS "${LLVM_MAIN_SRC_DIR}/cmake/modules")
+list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
+  else()
 set(LLVM_FOUND OFF)
-message(WARNING "Not found: ${LLVM_CMAKE_PATH}")
+message(WARNING "Neither ${LLVM_CMAKE_PATH} nor ${LLVM_MAIN_SRC_DIR}/cmake/modules found")
 return()
   endif()
 
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
-
   set(LLVM_FOUND ON)
 endmacro(find_llvm_parts)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r282857 - Fix int <= bool comparison warning on MSVC

2016-09-30 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Fri Sep 30 09:18:06 2016
New Revision: 282857

URL: http://llvm.org/viewvc/llvm-project?rev=282857&view=rev
Log:
Fix int <= bool comparison warning on MSVC

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

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=282857&r1=282856&r2=282857&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Sep 30 09:18:06 2016
@@ -2366,11 +2366,14 @@ void Sema::DeclareGlobalNewDelete() {
 bool HasSizedVariant = getLangOpts().SizedDeallocation &&
(Kind == OO_Delete || Kind == OO_Array_Delete);
 bool HasAlignedVariant = getLangOpts().CPlusPlus1z;
-for (int Sized = 0; Sized <= HasSizedVariant; ++Sized) {
+
+int NumSizeVariants = (HasSizedVariant ? 2 : 1);
+int NumAlignVariants = (HasAlignedVariant ? 2 : 1);
+for (int Sized = 0; Sized < NumSizeVariants; ++Sized) {
   if (Sized)
 Params.push_back(SizeT);
 
-  for (int Aligned = 0; Aligned <= HasAlignedVariant; ++Aligned) {
+  for (int Aligned = 0; Aligned < NumAlignVariants; ++Aligned) {
 if (Aligned)
   Params.push_back(Context.getTypeDeclType(getStdAlignValT()));
 


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


r282858 - Strip trailing whitespace (NFCI)

2016-09-30 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Fri Sep 30 09:25:09 2016
New Revision: 282858

URL: http://llvm.org/viewvc/llvm-project?rev=282858&view=rev
Log:
Strip trailing whitespace (NFCI)

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

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=282858&r1=282857&r2=282858&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Sep 30 09:25:09 2016
@@ -292,7 +292,7 @@ ParsedType Sema::getDestructorName(Sourc
   if (isDependent) {
 // We didn't find our type, but that's okay: it's dependent
 // anyway.
-
+
 // FIXME: What if we have no nested-name-specifier?
 QualType T = CheckTypenameType(ETK_None, SourceLocation(),
SS.getWithLocInContext(Context),
@@ -326,14 +326,14 @@ ParsedType Sema::getDestructorName(Sourc
 ParsedType Sema::getDestructorType(const DeclSpec& DS, ParsedType ObjectType) {
 if (DS.getTypeSpecType() == DeclSpec::TST_error || !ObjectType)
   return nullptr;
-assert(DS.getTypeSpecType() == DeclSpec::TST_decltype 
+assert(DS.getTypeSpecType() == DeclSpec::TST_decltype
&& "only get destructor types from declspecs");
 QualType T = BuildDecltypeType(DS.getRepAsExpr(), DS.getTypeSpecTypeLoc());
 QualType SearchType = GetTypeFromParser(ObjectType);
 if (SearchType->isDependentType() || 
Context.hasSameUnqualifiedType(SearchType, T)) {
   return ParsedType::make(T);
 }
-  
+
 Diag(DS.getTypeSpecTypeLoc(), diag::err_destructor_expr_type_mismatch)
   << T << SearchType;
 return nullptr;
@@ -662,7 +662,7 @@ Sema::ActOnCXXThrow(Scope *S, SourceLoca
   IsThrownVarInScope = true;
   break;
 }
-
+
 if (S->getFlags() &
 (Scope::FnScope | Scope::ClassScope | Scope::BlockScope |
  Scope::FunctionPrototypeScope | Scope::ObjCMethodScope |
@@ -672,11 +672,11 @@ Sema::ActOnCXXThrow(Scope *S, SourceLoca
 }
   }
   }
-  
+
   return BuildCXXThrow(OpLoc, Ex, IsThrownVarInScope);
 }
 
-ExprResult Sema::BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, 
+ExprResult Sema::BuildCXXThrow(SourceLocation OpLoc, Expr *Ex,
bool IsThrownVarInScope) {
   // Don't report an error if 'throw' is used in system headers.
   if (!getLangOpts().CXXExceptions &&
@@ -907,10 +907,10 @@ static QualType adjustCVQualifiersForCXX
I-- && isa(FunctionScopes[I]);
CurDC = getLambdaAwareParentOfDeclContext(CurDC)) {
 CurLSI = cast(FunctionScopes[I]);
-
-if (!CurLSI->isCXXThisCaptured()) 
+
+if (!CurLSI->isCXXThisCaptured())
 continue;
-  
+
 auto C = CurLSI->getCXXThisCapture();
 
 if (C.isCopyCapture()) {
@@ -926,7 +926,7 @@ static QualType adjustCVQualifiersForCXX
 assert(CurLSI);
 assert(isGenericLambdaCallOperatorSpecialization(CurLSI->CallOperator));
 assert(CurDC == getLambdaAwareParentOfDeclContext(CurLSI->CallOperator));
-
+
 auto IsThisCaptured =
 [](CXXRecordDecl *Closure, bool &IsByCopy, bool &IsConst) {
   IsConst = false;
@@ -996,10 +996,10 @@ QualType Sema::getCurrentThisType() {
   return ThisTy;
 }
 
-Sema::CXXThisScopeRAII::CXXThisScopeRAII(Sema &S, 
+Sema::CXXThisScopeRAII::CXXThisScopeRAII(Sema &S,
  Decl *ContextDecl,
  unsigned CXXThisTypeQuals,
- bool Enabled) 
+ bool Enabled)
   : S(S), OldCXXThisTypeOverride(S.CXXThisTypeOverride), Enabled(false)
 {
   if (!Enabled || !ContextDecl)
@@ -1010,13 +1010,13 @@ Sema::CXXThisScopeRAII::CXXThisScopeRAII
 Record = Template->getTemplatedDecl();
   else
 Record = cast(ContextDecl);
-
+
   // We care only for CVR qualifiers here, so cut everything else.
   CXXThisTypeQuals &= Qualifiers::FastMask;
   S.CXXThisTypeOverride
 = S.Context.getPointerType(
 S.Context.getRecordType(Record).withCVRQualifiers(CXXThisTypeQuals));
-  
+
   this->Enabled = true;
 }
 
@@ -1030,7 +1030,7 @@ Sema::CXXThisScopeRAII::~CXXThisScopeRAI
 static Expr *captureThis(Sema &S, ASTContext &Context, RecordDecl *RD,
  QualType ThisTy, SourceLocation Loc,
  const bool ByCopy) {
- 
+
   QualType AdjustedThisTy = ThisTy;
   // The type of the corresponding data member (not a 'this' pointer if 'by
   // copy').
@@ -1043,7 +1043,7 @@ static Expr *captureThis(Sema &S, ASTCon
 CaptureThisFieldTy.removeLocalCVRQualifiers(Qualifiers::CVRMask);
 AdjustedThisTy = Context.getPointerType(CaptureThisFieldTy);
   }
-  
+
   FieldDecl *Field = FieldDecl::Create(
   Context, RD, Loc, Loc, nullptr, CaptureThisFieldTy,
   Context.getTrivi

[PATCH] D24815: [clang] make reciprocal estimate codegen a function attribute

2016-09-30 Thread Sanjay Patel via cfe-commits
spatel added a comment.

Ping.


https://reviews.llvm.org/D24815



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


Re: [llvm-dev] Upgrading phabricator

2016-09-30 Thread Alex Bradbury via cfe-commits
On 30 September 2016 at 14:21, Eric Liu via llvm-commits
 wrote:
> Thanks for the feedback Aaron! :)
>
> I've disabled it. I think the annoying part really is the status (e.g.
> Request, Closed etc) in the tag, and I am wondering if a tag with just line
> numbers like "(N Loc)" would be better. But I'm not really sure about the
> trade-off here.

I'd suggest that [PATCH] is a waste of screen real estate too - the
`Dn:` prefix makes it obvious. I do appreciate there's an argument
for having it for consistency with people who post patches directly to
llvm-commits.

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


[PATCH] D9127: PR23175 (fix) - Infinite loop iterating Objective-C method declarations in categories when the AST was deserialized from an .ast file

2016-09-30 Thread Tom Honermann via cfe-commits
tahonermann added a comment.

For what it's worth, Coverity has been running with this patch in place for at 
least a year and a half now.  I believe the only reason it wasn't committed was 
due to concerns with the test case in https://reviews.llvm.org/D9126.  I 
haven't had time to address those concerns (and don't expect to anytime soon).


Repository:
  rL LLVM

https://reviews.llvm.org/D9127



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


Re: [llvm-dev] Upgrading phabricator

2016-09-30 Thread Zachary Turner via cfe-commits
Is there any way to disable emails when a revision is closed? I always find
those annoying, especially when it's a mass closing to clean out your
dashboard
On Fri, Sep 30, 2016 at 7:45 AM Alex Bradbury via llvm-dev <
llvm-...@lists.llvm.org> wrote:

> On 30 September 2016 at 14:21, Eric Liu via llvm-commits
>  wrote:
> > Thanks for the feedback Aaron! :)
> >
> > I've disabled it. I think the annoying part really is the status (e.g.
> > Request, Closed etc) in the tag, and I am wondering if a tag with just
> line
> > numbers like "(N Loc)" would be better. But I'm not really sure about the
> > trade-off here.
>
> I'd suggest that [PATCH] is a waste of screen real estate too - the
> `Dn:` prefix makes it obvious. I do appreciate there's an argument
> for having it for consistency with people who post patches directly to
> llvm-commits.
>
> Alex
> ___
> LLVM Developers mailing list
> llvm-...@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [llvm-dev] Upgrading phabricator

2016-09-30 Thread Eric Liu via cfe-commits
@Alex I tried glancing through emails in llvm-commits, and I found
"[PATCH]" makes it easier to tell revisions from patches, and I guess
people are also used to "[PATCH]" after all these years :)

@Zachary Yes! This option can be configured in "Email Preferences" in your
personal setting, but I'm not sure if this should be disabled globally. For
me personally, I'd like to be notified when a patch I am following is
closed.

Although I am happy to make these changes if people want :)

Thanks,
Eric

On Fri, Sep 30, 2016 at 4:52 PM Zachary Turner  wrote:

Is there any way to disable emails when a revision is closed? I always find
those annoying, especially when it's a mass closing to clean out your
dashboard
On Fri, Sep 30, 2016 at 7:45 AM Alex Bradbury via llvm-dev <
llvm-...@lists.llvm.org> wrote:

On 30 September 2016 at 14:21, Eric Liu via llvm-commits
 wrote:
> Thanks for the feedback Aaron! :)
>
> I've disabled it. I think the annoying part really is the status (e.g.
> Request, Closed etc) in the tag, and I am wondering if a tag with just
line
> numbers like "(N Loc)" would be better. But I'm not really sure about the
> trade-off here.

I'd suggest that [PATCH] is a waste of screen real estate too - the
`Dn:` prefix makes it obvious. I do appreciate there's an argument
for having it for consistency with people who post patches directly to
llvm-commits.

Alex

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


[PATCH] D25011: [x86][inline-asm] Introducing (AVX512) k0-k7 registers for inline-asm usage

2016-09-30 Thread Reid Kleckner via cfe-commits
rnk added a comment.

I'm pretty sure GCCRegNames is used to parse constraint lists, not to parse 
inline asm text. Your test should try using kN as a constraint.


Repository:
  rL LLVM

https://reviews.llvm.org/D25011



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


[PATCH] D25012: [x86][inline-asm] Add support for curly brackets escape using "%" in extended inline asm.

2016-09-30 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


> x86_inlineasm_curly_bracket_escape.c:1
> +// RUN: %clang_cc1 %s -target-cpu skylake-avx512 -O0  -S -o - -Wall -Werror 
> | FileCheck %s
> +// This test checks validity of inline assembly using curly brackets syntax

Please check the LLVM IR, not the assembly

Repository:
  rL LLVM

https://reviews.llvm.org/D25012



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


[PATCH] D25078: [Coroutines] Diagnose when 'main' is declared as a coroutine.

2016-09-30 Thread Gor Nishanov via cfe-commits
GorNishanov added inline comments.


> DiagnosticSemaKinds.td:8569
>"'%0' cannot be used in a varargs function">;
>  def ext_coroutine_without_co_await_co_yield : ExtWarn<
>"'co_return' used in a function "

I am wondering, if we can handle all four cases when function can be a 
coroutine.

co_await
co_yield
co_return
for co_await

future f() { co_return 42; } // is a valid coroutine per P0057R5

https://reviews.llvm.org/D25078



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


r282865 - [CUDA][OpenMP] Add a generic offload action builder

2016-09-30 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Fri Sep 30 10:34:19 2016
New Revision: 282865

URL: http://llvm.org/viewvc/llvm-project?rev=282865&view=rev
Log:
[CUDA][OpenMP] Add a generic offload action builder

Summary:
This patch proposes a new class to generate and record action dependences 
related with offloading. The builder provides three main functionalities:
- Add device dependences to host actions.
- Add host dependence to device actions.
- Register device top-level actions.

The constructor of the builder detect the programming models that should be 
supported, and generates a specialized builder for each. If a new programming 
model is to be added in the future, only a new specialized builder has to be 
implemented. 

When the specialized builder is generated, it produces 
programming-model-specific diagnostics.

A CUDA specialized builder is proposed in the patch that mostly consists of the 
partition of the current  `buildCudaAction` by the three different 
functionalities.

Reviewers: tra, echristo, ABataev, jlebar, hfinkel

Subscribers: Hahnfeld, whchung, guansong, jlebar, mehdi_amini, andreybokhanko, 
tcramer, mkuron, cfe-commits, arpith-jacob, carlo.bertolli, caomhin

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

Modified:
cfe/trunk/include/clang/Driver/Compilation.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Types.cpp
cfe/trunk/test/Driver/cuda-bindings.cu
cfe/trunk/test/Driver/cuda-phases.cu

Modified: cfe/trunk/include/clang/Driver/Compilation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Compilation.h?rev=282865&r1=282864&r2=282865&view=diff
==
--- cfe/trunk/include/clang/Driver/Compilation.h (original)
+++ cfe/trunk/include/clang/Driver/Compilation.h Fri Sep 30 10:34:19 2016
@@ -115,6 +115,12 @@ public:
 return OrderedOffloadingToolchains.equal_range(Kind);
   }
 
+  /// Return true if an offloading tool chain of a given kind exists.
+  template  bool hasOffloadToolChain() const {
+return OrderedOffloadingToolchains.find(Kind) !=
+   OrderedOffloadingToolchains.end();
+  }
+
   /// Return an offload toolchain of the provided kind. Only one is expected to
   /// exist.
   template 

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=282865&r1=282864&r2=282865&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Sep 30 10:34:19 2016
@@ -1400,139 +1400,536 @@ void Driver::BuildInputs(const ToolChain
   }
 }
 
-// For each unique --cuda-gpu-arch= argument creates a TY_CUDA_DEVICE
-// input action and then wraps each in CudaDeviceAction paired with
-// appropriate GPU arch name. In case of partial (i.e preprocessing
-// only) or device-only compilation, each device action is added to /p
-// Actions and /p Current is released. Otherwise the function creates
-// and returns a new CudaHostAction which wraps /p Current and device
-// side actions.
-static Action *buildCudaActions(Compilation &C, DerivedArgList &Args,
-const Arg *InputArg, Action *HostAction,
-ActionList &Actions) {
-  Arg *PartialCompilationArg = Args.getLastArg(
-  options::OPT_cuda_host_only, options::OPT_cuda_device_only,
-  options::OPT_cuda_compile_host_device);
-  bool CompileHostOnly =
-  PartialCompilationArg &&
-  PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only);
-  bool CompileDeviceOnly =
-  PartialCompilationArg &&
-  
PartialCompilationArg->getOption().matches(options::OPT_cuda_device_only);
-  const ToolChain *HostTC = C.getSingleOffloadToolChain();
-  assert(HostTC && "No toolchain for host compilation.");
-  if (HostTC->getTriple().isNVPTX()) {
-// We do not support targeting NVPTX for host compilation. Throw
-// an error and abort pipeline construction early so we don't trip
-// asserts that assume device-side compilation.
-C.getDriver().Diag(diag::err_drv_cuda_nvptx_host);
-return nullptr;
-  }
-
-  if (CompileHostOnly) {
-OffloadAction::HostDependence HDep(*HostAction, *HostTC,
-   /*BoundArch=*/nullptr, 
Action::OFK_Cuda);
-return C.MakeAction(HDep);
-  }
-
-  // Collect all cuda_gpu_arch parameters, removing duplicates.
-  SmallVector GpuArchList;
-  llvm::SmallSet GpuArchs;
-  for (Arg *A : Args) {
-if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ))
-  continue;
-A->claim();
+namespace {
+/// Provides a convenient interface for different programming models to 
generate
+/// the required device actions.
+class OffloadingActionBuilder final {
+  /// Flag used to trace errors in the builder.
+  bool IsValid = false;
+
+  /// The compilation that is using this builder.
+  Compilation &C;
+
+  

[PATCH] D18172: [CUDA][OpenMP] Add a generic offload action builder

2016-09-30 Thread Samuel Antao via cfe-commits
This revision was automatically updated to reflect the committed changes.
sfantao marked an inline comment as done.
Closed by commit rL282865: [CUDA][OpenMP] Add a generic offload action builder 
(authored by sfantao).

Changed prior to commit:
  https://reviews.llvm.org/D18172?vs=72117&id=73060#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D18172

Files:
  cfe/trunk/include/clang/Driver/Compilation.h
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/Types.cpp
  cfe/trunk/test/Driver/cuda-bindings.cu
  cfe/trunk/test/Driver/cuda-phases.cu

Index: cfe/trunk/include/clang/Driver/Compilation.h
===
--- cfe/trunk/include/clang/Driver/Compilation.h
+++ cfe/trunk/include/clang/Driver/Compilation.h
@@ -115,6 +115,12 @@
 return OrderedOffloadingToolchains.equal_range(Kind);
   }
 
+  /// Return true if an offloading tool chain of a given kind exists.
+  template  bool hasOffloadToolChain() const {
+return OrderedOffloadingToolchains.find(Kind) !=
+   OrderedOffloadingToolchains.end();
+  }
+
   /// Return an offload toolchain of the provided kind. Only one is expected to
   /// exist.
   template 
Index: cfe/trunk/test/Driver/cuda-bindings.cu
===
--- cfe/trunk/test/Driver/cuda-bindings.cu
+++ cfe/trunk/test/Driver/cuda-bindings.cu
@@ -34,8 +34,8 @@
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 %s -S 2>&1 \
 // RUN: | FileCheck -check-prefix=ASM %s
-// ASM: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_30.s"
-// ASM: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s"
+// ASM-DAG: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_30.s"
+// ASM-DAG: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s"
 
 //
 // Test two gpu architectures with complete compilation.
@@ -62,9 +62,9 @@
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
 // RUN:--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s -S 2>&1 \
 // RUN: | FileCheck -check-prefix=ASM2 %s
-// ASM2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_30.s"
-// ASM2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_35.s"
-// ASM2: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s"
+// ASM2-DAG: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_30.s"
+// ASM2-DAG: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_35.s"
+// ASM2-DAG: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s"
 
 //
 // Test one or more gpu architecture with complete compilation in host-only
Index: cfe/trunk/test/Driver/cuda-phases.cu
===
--- cfe/trunk/test/Driver/cuda-phases.cu
+++ cfe/trunk/test/Driver/cuda-phases.cu
@@ -13,194 +13,189 @@
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s 2>&1 \
 // RUN: | FileCheck -check-prefix=BIN %s
-// BIN: 0: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
-// BIN: 1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
-// BIN: 2: compiler, {1}, ir, (host-cuda)
-// BIN: 3: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
-// BIN: 4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_30)
-// BIN: 5: compiler, {4}, ir, (device-cuda, sm_30)
-// BIN: 6: backend, {5}, assembler, (device-cuda, sm_30)
-// BIN: 7: assembler, {6}, object, (device-cuda, sm_30)
-// BIN: 8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {7}, object
-// BIN: 9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {6}, assembler
-// BIN: 10: linker, {8, 9}, cuda-fatbin, (device-cuda)
-// BIN: 11: offload, "host-cuda (powerpc64le-ibm-linux-gnu)" {2}, "device-cuda (nvptx64-nvidia-cuda)" {10}, ir
-// BIN: 12: backend, {11}, assembler, (host-cuda)
-// BIN: 13: assembler, {12}, object, (host-cuda)
-// BIN: 14: linker, {13}, image, (host-cuda)
+// BIN-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
+// BIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (host-cuda)
+// BIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (host-cuda)
+// BIN-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
+// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, cuda-cpp-output, (device-cuda, sm_30)
+// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-cuda, sm_30)
+// BIN-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-cuda, sm_30)
+// BIN-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-cuda, sm_30)
+// BIN-DAG: [[P8:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P7]]}, object
+// BIN-DAG: [[

Re: [llvm-dev] Upgrading phabricator

2016-09-30 Thread Mehdi Amini via cfe-commits

> On Sep 29, 2016, at 11:04 PM, Eric Liu  wrote:
> 
> I've switched the default email format to be plain text only now. This option 
> should be per-user configurable, but somehow it is not shown in the 
> "Settings"; I'll try if I can make the option personalized.
> 
> Regarding new features and bug fixes in this upgrade, I don't really have a 
> list since the Phabricator we are running is the open-source repo + some 
> local modification. The last merge was more than one year ago, so I guess 
> there should be a long list of new features and bug fixes.
> 
> Some new features that I am aware of:
> - Syntax highlighting.
> - Patch size in email headers
> - HTML email (disabled)
> - More compatible with modern arc (the reason for this upgrade)
> - and more to be discovered! :)
> 
> @Mehdi Deleting unposted inline comments works for me. At which patch did 
> this issue occur?

I picked randomly in the “All revisions” list.
(For example: https://reviews.llvm.org/D25094 )

It seems I can delete comment unless I edited it first. Strange…

— 
Mehdi


> 
> - Eric
> 
> On Fri, Sep 30, 2016 at 7:39 AM Mehdi Amini  > wrote:
> One of the new “feature” is that emails are HTML only right now. Not quite 
> nice for the archive (or for interacting by email). 
> See for instance: 
> http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160926/172081.html 
> 
> 
> (Also the funky "[Changed Subscribers] “ in the title)
> 
> Another issue is that we can’t delete unposted inline comment anymore.
> 
> — 
> Mehdi
> 
>> On Sep 29, 2016, at 9:35 PM, Zachary Turner via llvm-dev 
>> mailto:llvm-...@lists.llvm.org>> wrote:
>> 
>> You mentioned this was for an upgrade. Are there any major new features or 
>> bugfixes to be aware of?
>> On Thu, Sep 29, 2016 at 9:26 PM Eric Liu via llvm-commits 
>> mailto:llvm-comm...@lists.llvm.org>> wrote:
>> Hi all,
>> 
>> Phabricator is (finally) back online! Let me know if you have any feedback 
>> or problem :)
>> 
>> Thanks,
>> Eric
>> 
>> On Thu, Sep 29, 2016 at 10:23 PM Eric Liu > > wrote:
>> According to top and iotop, mysqld is still working, and the progress bar 
>> did move by a little bit, so I think it's just really slow. Apologies if 
>> this is blocking you.
>> 
>> On Thu, Sep 29, 2016 at 10:17 PM Zachary Turner via llvm-dev 
>> mailto:llvm-...@lists.llvm.org>> wrote:
>> Still no word on when it will be back up?  It's not hung is it?  :D
>> 
>> On Thu, Sep 29, 2016 at 9:03 AM mats petersson via llvm-dev 
>> mailto:llvm-...@lists.llvm.org>> wrote:
>> On 29 September 2016 at 16:11, Mehdi Amini via llvm-dev 
>> mailto:llvm-...@lists.llvm.org>> wrote:
>> 
>>> On Sep 29, 2016, at 7:21 AM, Eric Liu via llvm-dev >> > wrote:
>>> 
>>> Sorry for blocking everyone for so long.
>> 
>> No pb, thanks very much for taking care of it :)
>> 
>>> It has been more than a year since the last upgrade, and mysql is adjusting 
>>> schema for a table with ~150G data on a single VM instance.
>> 
>> 150GB? I’m very surprised there is so much data in our phab! That seems 
>> huge...
>> 
>> My guess is that this includes all the diffs for every revision of every 
>> review (as well as all the comments, etc), and it probably isn't as clever 
>> with diffs as for example git. Which quite soon adds up to huge numbers when 
>> you have tens of thousands of reviews.
>> 
>> Purse speculation of course, I have never looked inside phabricator (or for 
>> that matter, any other code-review tool).
>> 
>> --
>> Mats
>> 
>> — 
>> Mehdi
>> 
>>> Sadly, the progress bar isn't giving useful information (plus I am not a 
>>> good system admin),  so I couldn't tell the ETA...
>>> 
>>> FYI: According to previous maintainer, it takes a couple of hours for the 
>>> last upgrade, so this should be done within a few hours (hopefully!).
>>> 
>>> On Thu, Sep 29, 2016 at 4:04 PM Krzysztof Parzyszek via llvm-dev 
>>> mailto:llvm-...@lists.llvm.org>> wrote:
>>> Is there any ETA?
>>> 
>>> -Krzysztof
>>> 
>>> On 9/29/2016 5:34 AM, Eric Liu via llvm-dev wrote:
>>> > That was a bad estimation. Database upgrade is taking time.
>>> >
>>> > On Thu, Sep 29, 2016 at 11:03 AM Eric Liu >> > 
>>> > >> wrote:
>>> >
>>> > Hi all,
>>> >
>>> > Phabricator(reviews.llvm.org  
>>> > >) will be down
>>> > for ~30 mins for an upgrade. Sorry for the short notice.
>>> >
>>> > Regards,
>>> > Eric
>>> >
>>> >
>>> >
>>> > ___
>>> > LLVM Developers mailing list
>>> > llvm-...@lists.llvm.org 
>>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev 
>>> > 
>>> >
>>> 
>>> --
>>> Qualcomm Innov

Re: [cfe-dev] [llvm-dev] Upgrading phabricator

2016-09-30 Thread Adam Nemet via cfe-commits
Hi Eric,

Thanks for your work.

> On Sep 29, 2016, at 11:04 PM, Eric Liu via cfe-dev  
> wrote:
> 
> I've switched the default email format to be plain text only now. This option 
> should be per-user configurable, but somehow it is not shown in the 
> "Settings"; I'll try if I can make the option personalized.
> 
> Regarding new features and bug fixes in this upgrade, I don't really have a 
> list since the Phabricator we are running is the open-source repo + some 
> local modification. The last merge was more than one year ago, so I guess 
> there should be a long list of new features and bug fixes.
> 
> Some new features that I am aware of:
> - Syntax highlighting.
> - Patch size in email headers
> - HTML email (disabled)
> - More compatible with modern arc (the reason for this upgrade)

Can you please elaborate?  Is this meant for bug-fixing only, or can we use 
some new features from arc?

Adam

> - and more to be discovered! :)
> 
> @Mehdi Deleting unposted inline comments works for me. At which patch did 
> this issue occur?
> 
> - Eric
> 
> On Fri, Sep 30, 2016 at 7:39 AM Mehdi Amini  > wrote:
> One of the new “feature” is that emails are HTML only right now. Not quite 
> nice for the archive (or for interacting by email). 
> See for instance: 
> http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160926/172081.html 
> 
> 
> (Also the funky "[Changed Subscribers] “ in the title)
> 
> Another issue is that we can’t delete unposted inline comment anymore.
> 
> — 
> Mehdi
> 
>> On Sep 29, 2016, at 9:35 PM, Zachary Turner via llvm-dev 
>> mailto:llvm-...@lists.llvm.org>> wrote:
>> 
>> You mentioned this was for an upgrade. Are there any major new features or 
>> bugfixes to be aware of?
>> On Thu, Sep 29, 2016 at 9:26 PM Eric Liu via llvm-commits 
>> mailto:llvm-comm...@lists.llvm.org>> wrote:
>> Hi all,
>> 
>> Phabricator is (finally) back online! Let me know if you have any feedback 
>> or problem :)
>> 
>> Thanks,
>> Eric
>> 
>> On Thu, Sep 29, 2016 at 10:23 PM Eric Liu > > wrote:
>> According to top and iotop, mysqld is still working, and the progress bar 
>> did move by a little bit, so I think it's just really slow. Apologies if 
>> this is blocking you.
>> 
>> On Thu, Sep 29, 2016 at 10:17 PM Zachary Turner via llvm-dev 
>> mailto:llvm-...@lists.llvm.org>> wrote:
>> Still no word on when it will be back up?  It's not hung is it?  :D
>> 
>> On Thu, Sep 29, 2016 at 9:03 AM mats petersson via llvm-dev 
>> mailto:llvm-...@lists.llvm.org>> wrote:
>> On 29 September 2016 at 16:11, Mehdi Amini via llvm-dev 
>> mailto:llvm-...@lists.llvm.org>> wrote:
>> 
>>> On Sep 29, 2016, at 7:21 AM, Eric Liu via llvm-dev >> > wrote:
>>> 
>>> Sorry for blocking everyone for so long.
>> 
>> No pb, thanks very much for taking care of it :)
>> 
>>> It has been more than a year since the last upgrade, and mysql is adjusting 
>>> schema for a table with ~150G data on a single VM instance.
>> 
>> 150GB? I’m very surprised there is so much data in our phab! That seems 
>> huge...
>> 
>> My guess is that this includes all the diffs for every revision of every 
>> review (as well as all the comments, etc), and it probably isn't as clever 
>> with diffs as for example git. Which quite soon adds up to huge numbers when 
>> you have tens of thousands of reviews.
>> 
>> Purse speculation of course, I have never looked inside phabricator (or for 
>> that matter, any other code-review tool).
>> 
>> --
>> Mats
>> 
>> — 
>> Mehdi
>> 
>>> Sadly, the progress bar isn't giving useful information (plus I am not a 
>>> good system admin),  so I couldn't tell the ETA...
>>> 
>>> FYI: According to previous maintainer, it takes a couple of hours for the 
>>> last upgrade, so this should be done within a few hours (hopefully!).
>>> 
>>> On Thu, Sep 29, 2016 at 4:04 PM Krzysztof Parzyszek via llvm-dev 
>>> mailto:llvm-...@lists.llvm.org>> wrote:
>>> Is there any ETA?
>>> 
>>> -Krzysztof
>>> 
>>> On 9/29/2016 5:34 AM, Eric Liu via llvm-dev wrote:
>>> > That was a bad estimation. Database upgrade is taking time.
>>> >
>>> > On Thu, Sep 29, 2016 at 11:03 AM Eric Liu >> > 
>>> > >> wrote:
>>> >
>>> > Hi all,
>>> >
>>> > Phabricator(reviews.llvm.org  
>>> > >) will be down
>>> > for ~30 mins for an upgrade. Sorry for the short notice.
>>> >
>>> > Regards,
>>> > Eric
>>> >
>>> >
>>> >
>>> > ___
>>> > LLVM Developers mailing list
>>> > llvm-...@lists.llvm.org 
>>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev 
>>> > 
>>> >
>>> 
>>> --
>>> Qualcomm Innovation Center, 

[PATCH] D24916: [analyzer] Extend bug reports with extra notes - CloneChecker

2016-09-30 Thread Anna Zaks via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D24916



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


[PATCH] D24682: [PR30341] Alias must point to a definition

2016-09-30 Thread Aditya Kumar via cfe-commits
hiraditya added a comment.

I had to revert the patch because this test case was failing. The problem was 
that the destructors have different return type for different targets. So I'll 
modify the testcase and put the patch back in.


Repository:
  rL LLVM

https://reviews.llvm.org/D24682



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


[PATCH] D25092: [analyzer] Add "Assuming..." diagnostic pieces for short-circuit logical operators.

2016-09-30 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Looks good overall. Very minor nits.



> BugReporterVisitors.cpp:1274
>  
> +  // In the code below, Term is a CFG terminator, and Cond is a branch
> +  // condition expression upon which the decision is made on this terminator.

nit: no comma before "and".

> BugReporterVisitors.cpp:1288
>switch (Term->getStmtClass()) {
> +  // FIXME: Come up with something for switch statements?
>default:

It is not clear what the FIXME is for.

> BugReporterVisitors.cpp:1302
> +const auto *BO = cast(Term);
> +if (!BO->isLogicalOp())
> +  return nullptr;

Is this expected to ever trigger?

https://reviews.llvm.org/D25092



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


[PATCH] D25103: [CUDA] Handle attributes on CUDA lambdas appearing between [...] and (...).

2016-09-30 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rnk.
jlebar added subscribers: tra, cfe-commits.

This is ugh, but it makes us compatible with NVCC.  Fixes bug 26341.


https://reviews.llvm.org/D25103

Files:
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/Parser/lambda-attr.cu

Index: clang/test/Parser/lambda-attr.cu
===
--- /dev/null
+++ clang/test/Parser/lambda-attr.cu
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcuda-is-device -verify %s
+
+// expected-no-diagnostics
+
+__attribute__((device)) void device_attr() {
+  ([]() __attribute__((device)){})();
+  ([] __attribute__((device)) () {})();
+  ([] __attribute__((device)) {})();
+
+  ([&]() __attribute__((device)){})();
+  ([&] __attribute__((device)) () {})();
+  ([&] __attribute__((device)) {})();
+
+  ([&](int) __attribute__((device)){})(0);
+  ([&] __attribute__((device)) (int) {})(0);
+}
+
+__attribute__((host)) __attribute__((device)) void host_device_attrs() {
+  ([]() __attribute__((host)) __attribute__((device)){})();
+  ([] __attribute__((host)) __attribute__((device)) () {})();
+  ([] __attribute__((host)) __attribute__((device)) {})();
+
+  ([&]() __attribute__((host)) __attribute__((device)){})();
+  ([&] __attribute__((host)) __attribute__((device)) () {})();
+  ([&] __attribute__((host)) __attribute__((device)) {})();
+
+  ([&](int) __attribute__((host)) __attribute__((device)){})(0);
+  ([&] __attribute__((host)) __attribute__((device)) (int) {})(0);
+}
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -1124,22 +1124,29 @@
   DeclSpec DS(AttrFactory);
   Declarator D(DS, Declarator::LambdaExprContext);
   TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
-  Actions.PushLambdaScope();
+  Actions.PushLambdaScope();
+
+  ParsedAttributes Attr(AttrFactory);
+  SourceLocation DeclLoc = Tok.getLocation();
+  SourceLocation DeclEndLoc = DeclLoc;
+  if (getLangOpts().CUDA) {
+// In CUDA code, GNU attributes are allowed to appear immediately after the
+// "[...]", even if there is no "(...)" before the lambda body.
+MaybeParseGNUAttributes(Attr, &DeclEndLoc);
+  }
 
   TypeResult TrailingReturnType;
   if (Tok.is(tok::l_paren)) {
 ParseScope PrototypeScope(this,
   Scope::FunctionPrototypeScope |
   Scope::FunctionDeclarationScope |
   Scope::DeclScope);
 
-SourceLocation DeclEndLoc;
 BalancedDelimiterTracker T(*this, tok::l_paren);
 T.consumeOpen();
 SourceLocation LParenLoc = T.getOpenLocation();
 
 // Parse parameter-declaration-clause.
-ParsedAttributes Attr(AttrFactory);
 SmallVector ParamInfo;
 SourceLocation EllipsisLoc;
 
@@ -1245,12 +1252,10 @@
 Diag(Tok, diag::err_lambda_missing_parens)
   << TokKind
   << FixItHint::CreateInsertion(Tok.getLocation(), "() ");
-SourceLocation DeclLoc = Tok.getLocation();
-SourceLocation DeclEndLoc = DeclLoc;
+DeclEndLoc = DeclLoc;
 
 // GNU-style attributes must be parsed before the mutable specifier to be
 // compatible with GCC.
-ParsedAttributes Attr(AttrFactory);
 MaybeParseGNUAttributes(Attr, &DeclEndLoc);
 
 // Parse 'mutable', if it's there.
@@ -1296,8 +1301,35 @@
DeclLoc, DeclEndLoc, D,
TrailingReturnType),
   Attr, DeclEndLoc);
+  } else if (getLangOpts().CUDA) {
+// CUDA code may have attributes, which we need to add if they weren't added
+// in one of the if statements above.
+SourceLocation NoLoc;
+D.AddTypeInfo(DeclaratorChunk::getFunction(/*hasProto=*/true,
+   /*isAmbiguous=*/false,
+   /*LParenLoc=*/NoLoc,
+   /*Params=*/nullptr,
+   /*NumParams=*/0,
+   /*EllipsisLoc=*/NoLoc,
+   /*RParenLoc=*/NoLoc,
+   /*TypeQuals=*/0,
+   /*RefQualifierIsLValueRef=*/true,
+   /*RefQualifierLoc=*/NoLoc,
+   /*ConstQualifierLoc=*/NoLoc,
+   /*VolatileQualifierLoc=*/NoLoc,
+   /*RestrictQualifierLoc=*/NoLoc,
+   /*MutableLoc=*/NoLoc,
+   EST_None,
+   

[PATCH] D25105: [CUDA] Make lambdas inherit __host__ and __device__ attributes from the scope in which they're created.

2016-09-30 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: rnk, cfe-commits.

NVCC compat.  Fixes bug 30567.


https://reviews.llvm.org/D25105

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/test/SemaCUDA/implicit-device-lambda-hd.cu
  clang/test/SemaCUDA/implicit-device-lambda.cu

Index: clang/test/SemaCUDA/implicit-device-lambda.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/implicit-device-lambda.cu
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -verify -fsyntax-only -verify-ignore-unexpected=note %s
+// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -verify-ignore-unexpected=note %s
+
+#include "Inputs/cuda.h"
+
+__device__ void device_fn() {
+  auto f1 = [&] {};
+  f1(); // implicitly __device__
+
+  auto f2 = [&] __device__ {};
+  f2();
+
+  auto f3 = [&] __host__ {};
+  f3();  // expected-error {{no matching function}}
+
+  auto f4 = [&] __host__ __device__ {};
+  f4();
+
+  // Now do it all again with '()'s in the lambda declarations: This is a
+  // different parse path.
+  auto g1 = [&]() {};
+  g1(); // implicitly __device__
+
+  auto g2 = [&]() __device__ {};
+  g2();
+
+  auto g3 = [&]() __host__ {};
+  g3();  // expected-error {{no matching function}}
+
+  auto g4 = [&]() __host__ __device__ {};
+  g4();
+
+  // Once more, with the '()'s in a different place.
+  auto h1 = [&]() {};
+  h1(); // implicitly __device__
+
+  auto h2 = [&] __device__ () {};
+  h2();
+
+  auto h3 = [&] __host__ () {};
+  h3();  // expected-error {{no matching function}}
+
+  auto h4 = [&] __host__ __device__ () {};
+  h4();
+}
+
+// Behaves identically to device_fn.
+__global__ void kernel_fn() {
+  auto f1 = [&] {};
+  f1(); // implicitly __device__
+
+  auto f2 = [&] __device__ {};
+  f2();
+
+  auto f3 = [&] __host__ {};
+  f3();  // expected-error {{no matching function}}
+
+  auto f4 = [&] __host__ __device__ {};
+  f4();
+
+  // No need to re-test all the parser contortions we test in the device
+  // function.
+}
+
+__host__ void host_fn() {
+  auto f1 = [&] {};
+  f1(); // implicitly __host__ (i.e., no magic)
+
+  auto f2 = [&] __device__ {};
+  f2();  // expected-error {{no matching function}}
+
+  auto f3 = [&] __host__ {};
+  f3();
+
+  auto f4 = [&] __host__ __device__ {};
+  f4();
+}
+
+// The special treatment above only applies to lambdas.
+__device__ void foo() {
+  struct X {
+void foo() {}
+  };
+  X x;
+  x.foo(); // expected-error {{reference to __host__ function 'foo' in __device__ function}}
+}
Index: clang/test/SemaCUDA/implicit-device-lambda-hd.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/implicit-device-lambda-hd.cu
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -verify -verify-ignore-unexpected=note \
+// RUN:   -S -o /dev/null %s
+// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -verify-ignore-unexpected=note \
+// RUN:   -DHOST -S -o /dev/null %s
+#include "Inputs/cuda.h"
+
+__host__ __device__ void hd_fn() {
+  auto f1 = [&] {};
+  f1(); // implicitly __host__ __device__
+
+  auto f2 = [&] __device__ {};
+  f2();
+#ifdef HOST
+  // expected-error@-2 {{reference to __device__ function}}
+#endif
+
+  auto f3 = [&] __host__ {};
+  f3();
+#ifndef HOST
+  // expected-error@-2 {{reference to __host__ function}}
+#endif
+
+  auto f4 = [&] __host__ __device__ {};
+  f4();
+}
+
+
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -886,7 +886,12 @@
   
   // Attributes on the lambda apply to the method.  
   ProcessDeclAttributes(CurScope, Method, ParamInfo);
-  
+
+  // CUDA lambdas get implicit attributes based on the scope in which they're
+  // declared.
+  if (getLangOpts().CUDA)
+CUDASetLambdaAttrs(Method);
+
   // Introduce the function call operator as the current declaration context.
   PushDeclContext(CurScope, Method);
 
Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -559,3 +559,22 @@
   }
   return true;
 }
+
+void Sema::CUDASetLambdaAttrs(CXXMethodDecl *Method) {
+  if (Method->hasAttr() || Method->hasAttr())
+return;
+  FunctionDecl *CurFn = dyn_cast(CurContext);
+  if (!CurFn)
+return;
+  CUDAFunctionTarget Target = IdentifyCUDATarget(CurFn);
+  if (Target == CFT_Global || Target == CFT_Device) {
+Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+  } else if (Target == CFT_HostDevice) {
+Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+Method->addAttr(CUDAHostAttr::CreateImplicit(Context));
+  }
+
+  // TODO: nvcc doesn't allow you to specify __host__ or __device__ attributes
+  // on lambdas in all contexts -- we should emit a compatib

[PATCH] D24598: Separate builtins for x84-64 and i386; implement __mulh and __umulh

2016-09-30 Thread Albert Gutowski via cfe-commits
agutowski added inline comments.


> BuiltinsX86_32.def:1
> +//===--- BuiltinsX86_32.def - X86-32 Builtin function database --*- C++ 
> -*-===//
> +//

Will we ever need that file? It seems to nicely complement the 64-bit one, but 
if it's going to be empty forever maybe it's better to remove it.

https://reviews.llvm.org/D24598



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


[PATCH] D25106: Packed member warning: Use the typedef name for anonymous structures when it is available

2016-09-30 Thread Alex Lorenz via cfe-commits
arphaman created this revision.
arphaman added reviewers: aaron.ballman, rogfer01.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch improves the packed member warning by showing the name of the 
anonymous structure/union when it was defined with a typedef, e.g. the code 
below:

  typedef struct {
char c;
int x;
  } __attribute__((packed)) Foo;
  int *foo(Foo *f) { return &f->x; }

Would now produce the following warning:

  taking address of packed member 'x' of class or structure 'Foo' may result in 
an unaligned pointer value


Repository:
  rL LLVM

https://reviews.llvm.org/D25106

Files:
  Sema/SemaChecking.cpp
  Sema/address-packed.c


Index: Sema/address-packed.c
===
--- Sema/address-packed.c
+++ Sema/address-packed.c
@@ -161,3 +161,27 @@
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+typedef struct {
+  char c;
+  int x;
+} __attribute__((packed)) TypedefStructArguable;
+
+typedef union {
+  char c;
+  int x;
+} __attribute((packed)) TypedefUnionArguable;
+
+typedef TypedefStructArguable TypedefStructArguableTheSecond;
+
+int *typedef1(TypedefStructArguable *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or 
structure 'TypedefStructArguable'}}
+}
+
+int *typedef2(TypedefStructArguableTheSecond *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or 
structure 'TypedefStructArguable'}}
+}
+
+int *typedef3(TypedefUnionArguable *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or 
structure 'TypedefUnionArguable'}}
+}
Index: Sema/SemaChecking.cpp
===
--- Sema/SemaChecking.cpp
+++ Sema/SemaChecking.cpp
@@ -11279,8 +11279,13 @@
 
 void Sema::DiagnoseMisalignedMembers() {
   for (MisalignedMember &m : MisalignedMembers) {
+const NamedDecl *ND = m.RD;
+if (ND->getName().empty()) {
+  if (const auto *TypedefDecl = m.RD->getTypedefNameForAnonDecl())
+ND = TypedefDecl;
+}
 Diag(m.E->getLocStart(), diag::warn_taking_address_of_packed_member)
-<< m.MD << m.RD << m.E->getSourceRange();
+<< m.MD << ND << m.E->getSourceRange();
   }
   MisalignedMembers.clear();
 }


Index: Sema/address-packed.c
===
--- Sema/address-packed.c
+++ Sema/address-packed.c
@@ -161,3 +161,27 @@
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+typedef struct {
+  char c;
+  int x;
+} __attribute__((packed)) TypedefStructArguable;
+
+typedef union {
+  char c;
+  int x;
+} __attribute((packed)) TypedefUnionArguable;
+
+typedef TypedefStructArguable TypedefStructArguableTheSecond;
+
+int *typedef1(TypedefStructArguable *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or structure 'TypedefStructArguable'}}
+}
+
+int *typedef2(TypedefStructArguableTheSecond *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or structure 'TypedefStructArguable'}}
+}
+
+int *typedef3(TypedefUnionArguable *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or structure 'TypedefUnionArguable'}}
+}
Index: Sema/SemaChecking.cpp
===
--- Sema/SemaChecking.cpp
+++ Sema/SemaChecking.cpp
@@ -11279,8 +11279,13 @@
 
 void Sema::DiagnoseMisalignedMembers() {
   for (MisalignedMember &m : MisalignedMembers) {
+const NamedDecl *ND = m.RD;
+if (ND->getName().empty()) {
+  if (const auto *TypedefDecl = m.RD->getTypedefNameForAnonDecl())
+ND = TypedefDecl;
+}
 Diag(m.E->getLocStart(), diag::warn_taking_address_of_packed_member)
-<< m.MD << m.RD << m.E->getSourceRange();
+<< m.MD << ND << m.E->getSourceRange();
   }
   MisalignedMembers.clear();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Sigh. I've bumped into some downstream problems. Will commit as soon as I've 
verified these problems are not related to the patch.


https://reviews.llvm.org/D24864



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


[PATCH] D25103: [CUDA] Handle attributes on CUDA lambdas appearing between [...] and (...).

2016-09-30 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


> ParseExprCXX.cpp:1135
> +// "[...]", even if there is no "(...)" before the lambda body.
> +MaybeParseGNUAttributes(Attr, &DeclEndLoc);
> +  }

Does nvcc support __declspec style attributes? Maybe we should check for those 
too?

> ParseExprCXX.cpp:1280
>  SourceLocation NoLoc;
>  D.AddTypeInfo(DeclaratorChunk::getFunction(/*hasProto=*/true,
> /*isAmbiguous=*/false,

Let's not duplicate this amazingly long type info thingy. I think you can avoid 
it if you hoist MutableLoc and add a bool like `NeedFuncDeclaratorChunk`. Also, 
maybe we shouldn't be hallucinating a function declarator chunk in CUDA when 
there are no attributes?

https://reviews.llvm.org/D25103



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


[PATCH] D25106: Packed member warning: Use the typedef name for anonymous structures when it is available

2016-09-30 Thread Alex Lorenz via cfe-commits
arphaman removed rL LLVM as the repository for this revision.
arphaman updated this revision to Diff 73076.
arphaman added a comment.

I had to reuploaded the diff as Phabricator seemed to have removed the 'lib' 
and 'test' paths prefixes from the filenames in the original diff.


https://reviews.llvm.org/D25106

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/address-packed.c


Index: test/Sema/address-packed.c
===
--- test/Sema/address-packed.c
+++ test/Sema/address-packed.c
@@ -161,3 +161,27 @@
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+typedef struct {
+  char c;
+  int x;
+} __attribute__((packed)) TypedefStructArguable;
+
+typedef union {
+  char c;
+  int x;
+} __attribute((packed)) TypedefUnionArguable;
+
+typedef TypedefStructArguable TypedefStructArguableTheSecond;
+
+int *typedef1(TypedefStructArguable *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or 
structure 'TypedefStructArguable'}}
+}
+
+int *typedef2(TypedefStructArguableTheSecond *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or 
structure 'TypedefStructArguable'}}
+}
+
+int *typedef3(TypedefUnionArguable *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or 
structure 'TypedefUnionArguable'}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -11279,8 +11279,13 @@
 
 void Sema::DiagnoseMisalignedMembers() {
   for (MisalignedMember &m : MisalignedMembers) {
+const NamedDecl *ND = m.RD;
+if (ND->getName().empty()) {
+  if (const auto *TypedefDecl = m.RD->getTypedefNameForAnonDecl())
+ND = TypedefDecl;
+}
 Diag(m.E->getLocStart(), diag::warn_taking_address_of_packed_member)
-<< m.MD << m.RD << m.E->getSourceRange();
+<< m.MD << ND << m.E->getSourceRange();
   }
   MisalignedMembers.clear();
 }


Index: test/Sema/address-packed.c
===
--- test/Sema/address-packed.c
+++ test/Sema/address-packed.c
@@ -161,3 +161,27 @@
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+typedef struct {
+  char c;
+  int x;
+} __attribute__((packed)) TypedefStructArguable;
+
+typedef union {
+  char c;
+  int x;
+} __attribute((packed)) TypedefUnionArguable;
+
+typedef TypedefStructArguable TypedefStructArguableTheSecond;
+
+int *typedef1(TypedefStructArguable *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or structure 'TypedefStructArguable'}}
+}
+
+int *typedef2(TypedefStructArguableTheSecond *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or structure 'TypedefStructArguable'}}
+}
+
+int *typedef3(TypedefUnionArguable *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or structure 'TypedefUnionArguable'}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -11279,8 +11279,13 @@
 
 void Sema::DiagnoseMisalignedMembers() {
   for (MisalignedMember &m : MisalignedMembers) {
+const NamedDecl *ND = m.RD;
+if (ND->getName().empty()) {
+  if (const auto *TypedefDecl = m.RD->getTypedefNameForAnonDecl())
+ND = TypedefDecl;
+}
 Diag(m.E->getLocStart(), diag::warn_taking_address_of_packed_member)
-<< m.MD << m.RD << m.E->getSourceRange();
+<< m.MD << ND << m.E->getSourceRange();
   }
   MisalignedMembers.clear();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24472: [Sema] Support lax conversions for compound assignments

2016-09-30 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm



> SemaExpr.cpp:8084
> +// type. Note that this is already done by non-compound assignments in
> +// CheckAssignmentConstraints. If it's a scalar type, only biscast for
> +// <1 x T> -> T. The result is also a vector type.

typo on biscast

> bruno wrote in SemaExpr.cpp:8090
> You're right, the diagnostics are bad here, this patch adds some FIXMEs so we 
> can later work on it. A PR would be nice though (we have an internal track 
> for that as well, see rdar://problem/28067874).
> 
> Given your example:
> 
>   a = a + b; // clang accepts this. 
>   a += b; // currently clang rejects this.
> 
> IMO, clang should reject `a = a + b` too if not in OpenCL mode, which means 
> whenever (a) `a` and `b` have same size but different num elt and (b) `a` and 
> `b` are generic vectors (non ext-vectors). However, It looks like we have 
> tests that rely on this behavior, we should probably find out why first and 
> clean it up.
> 
> I also think we should support splatting when one of the operands is a scalar 
> and the other a non ext-vector (as of now we currently only do it for 
> OpenCL). This is basically what GCC supports 
> https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html.

I agree. I think the way forward is to:

- Allow conversions between `<1 x T>` and scalar `T` without enabling lax 
vector conversions. This seems pretty unobjectionable.
- Disable lax vector conversions by default, and evaluate whether they can be 
completely removed.

https://reviews.llvm.org/D24472



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


[PATCH] D25078: [coroutines] Diagnose when 'main' is declared as a coroutine.

2016-09-30 Thread Richard Smith via cfe-commits
rsmith added a comment.

LGTM, go ahead when Gor is happy.


https://reviews.llvm.org/D25078



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


Re: [PATCH] [coroutines] Rename driver flag -fcoroutines to -fcoroutines-ts

2016-09-30 Thread Gor Nishanov via cfe-commits
I noticed that other TSes has experimental in their SD-6 macro name, hence,
I changed it to match the concepts TS macro __cpp_experimental_concepts.
We are reviewing the wording coming Monday and can tweak the SD-6 macro as
needed.

Also, Richard mentioned in the feedback that:

>> However, we *shouldn't be* defining this until we have a complete
implementation. (Code using this for a feature test wants to test whether
the feature works, not just whether it's enabled on the command line.)

Richard, do you want us to take out __cpp_coroutines completely until all
of the parts are pushed upstream?

On Thu, Sep 29, 2016 at 9:59 PM, Eric Fiselier  wrote:

> On Sep 29, 2016 8:23 PM, "Gor Nishanov"  wrote:
> >
> > You beat me to it, Eric. :) I'll add mine for review, too. Let's see
> which one Richard will respond :) .
> >
> > 1. Remove __has_feature
> > 2. Rename fcoroutines => fcoroutines_TS
> > 3. Rename __cpp_coroutines => __cpp_experimental_coroutines
>
> The TS spec uses __cpp_coroutines. What's the reason for changing it?
>
> >
> > Since phabricator is down, here is a handy diff on a github
> > https://github.com/GorNishanov/clang/commit/
> e129083a73cf82e0bcea0817045ae6baaadccbb7
> >
> >
> >
> >
> > On Thu, Sep 29, 2016 at 6:22 PM, Eric Fiselier  wrote:
> >>
> >> I've attached an updated patch which addresses the comments.
> >>
> >> 1. Remove __has_feature changes.
> >> 2. Rename OPT_fcoroutines -> OPT_fcoroutines_TS.
> >>
> >> /Eric
> >>
> >> On Thu, Sep 29, 2016 at 6:58 PM, Richard Smith 
> wrote:
> >>>
> >>> +def fcoroutines : Flag <["-"], "fcoroutines-ts">, Group, +
> Flags<[DriverOption, CC1Option]>, + HelpText<"Enable support for the C++
> Coroutines TS">; +def fno_coroutines : Flag <["-"], "fno-coroutines-ts">,
> Group,
> >>>
> >>> These should be named fcoroutines_ts, fno_coroutines_ts (see comment
> at the top of the file for the naming scheme).
> >>>
> >>> + .Case("coroutines", LangOpts.Coroutines)
> >>>
> >>> We should use the SD-6 macro name (__cpp_coroutines) rather than
> __has_feature for new features that are covered by SD-6. However, we
> shouldn't be defining this until we have a complete implementation. (Code
> using this for a feature test wants to test whether the feature works, not
> just whether it's enabled on the command line.)
> >>>
> >>> On Thu, Sep 29, 2016 at 5:45 PM, Gor Nishanov 
> wrote:
> 
>  Let's see if renaming the attachment to *.txt helps.
> 
>  On Thu, Sep 29, 2016 at 5:42 PM, Gor Nishanov 
> wrote:
> >
> > Currently the -fcoroutines flag is a CC1 only flag. It really should
> be both a Driver and CC1 flag. This patch fixes the option and adds tests
> for the new options.
> >
> > Also adds a __has_feature for coroutines.
> >
> > Patch is mostly by Eric Fiselier
> > .
> > Meticulous and painstaking extraction from the larger coroutine
> branch by Gor Nishanov
> >
> > P.S.
> >
> > Switching to lowercase [coroutines] tag in the title, as most of the
> coroutine commits in cfe were done with lowercase tag.
> 
> 
> >>>
> >>
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25103: [CUDA] Handle attributes on CUDA lambdas appearing between [...] and (...).

2016-09-30 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 73085.
jlebar marked an inline comment as done.
jlebar added a comment.

Don't hallucinate a function declarator.


https://reviews.llvm.org/D25103

Files:
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/Parser/lambda-attr.cu


Index: clang/test/Parser/lambda-attr.cu
===
--- /dev/null
+++ clang/test/Parser/lambda-attr.cu
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcuda-is-device -verify %s
+
+// expected-no-diagnostics
+
+__attribute__((device)) void device_fn() {}
+__attribute__((device)) void hd_fn() {}
+
+__attribute__((device)) void device_attr() {
+  ([]() __attribute__((device)) { device_fn(); })();
+  ([] __attribute__((device)) () { device_fn(); })();
+  ([] __attribute__((device)) { device_fn(); })();
+
+  ([&]() __attribute__((device)){ device_fn(); })();
+  ([&] __attribute__((device)) () { device_fn(); })();
+  ([&] __attribute__((device)) { device_fn(); })();
+
+  ([&](int) __attribute__((device)){ device_fn(); })(0);
+  ([&] __attribute__((device)) (int) { device_fn(); })(0);
+}
+
+__attribute__((host)) __attribute__((device)) void host_device_attrs() {
+  ([]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
+  ([] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
+  ([] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
+
+  ([&]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
+  ([&] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
+  ([&] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
+
+  ([&](int) __attribute__((host)) __attribute__((device)){ hd_fn(); })(0);
+  ([&] __attribute__((host)) __attribute__((device)) (int) { hd_fn(); })(0);
+}
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -1124,22 +1124,30 @@
   DeclSpec DS(AttrFactory);
   Declarator D(DS, Declarator::LambdaExprContext);
   TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
-  Actions.PushLambdaScope();
+  Actions.PushLambdaScope();
+
+  ParsedAttributes Attr(AttrFactory);
+  SourceLocation DeclLoc = Tok.getLocation();
+  SourceLocation DeclEndLoc = DeclLoc;
+  if (getLangOpts().CUDA) {
+// In CUDA code, GNU attributes are allowed to appear immediately after the
+// "[...]", even if there is no "(...)" before the lambda body.
+MaybeParseGNUAttributes(Attr, &DeclEndLoc);
+D.takeAttributes(Attr, DeclEndLoc);
+  }
 
   TypeResult TrailingReturnType;
   if (Tok.is(tok::l_paren)) {
 ParseScope PrototypeScope(this,
   Scope::FunctionPrototypeScope |
   Scope::FunctionDeclarationScope |
   Scope::DeclScope);
 
-SourceLocation DeclEndLoc;
 BalancedDelimiterTracker T(*this, tok::l_paren);
 T.consumeOpen();
 SourceLocation LParenLoc = T.getOpenLocation();
 
 // Parse parameter-declaration-clause.
-ParsedAttributes Attr(AttrFactory);
 SmallVector ParamInfo;
 SourceLocation EllipsisLoc;
 
@@ -1245,12 +1253,10 @@
 Diag(Tok, diag::err_lambda_missing_parens)
   << TokKind
   << FixItHint::CreateInsertion(Tok.getLocation(), "() ");
-SourceLocation DeclLoc = Tok.getLocation();
-SourceLocation DeclEndLoc = DeclLoc;
+DeclEndLoc = DeclLoc;
 
 // GNU-style attributes must be parsed before the mutable specifier to be
 // compatible with GCC.
-ParsedAttributes Attr(AttrFactory);
 MaybeParseGNUAttributes(Attr, &DeclEndLoc);
 
 // Parse 'mutable', if it's there.
@@ -1297,7 +1303,6 @@
TrailingReturnType),
   Attr, DeclEndLoc);
   }
-  
 
   // FIXME: Rename BlockScope -> ClosureScope if we decide to continue using
   // it.


Index: clang/test/Parser/lambda-attr.cu
===
--- /dev/null
+++ clang/test/Parser/lambda-attr.cu
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcuda-is-device -verify %s
+
+// expected-no-diagnostics
+
+__attribute__((device)) void device_fn() {}
+__attribute__((device)) void hd_fn() {}
+
+__attribute__((device)) void device_attr() {
+  ([]() __attribute__((device)) { device_fn(); })();
+  ([] __attribute__((device)) () { device_fn(); })();
+  ([] __attribute__((device)) { device_fn(); })();
+
+  ([&]() __attribute__((device)){ device_fn(); })();
+  ([&] __attribute__((device)) () { device_fn(); })();
+  ([&] __attribute__((device)) { device_fn(); })();
+
+  ([&](int) __attribute__((device)){ device_fn(); })(0);
+  ([&] __attribute__((device)) (int) { device_fn(); })(0);
+}
+
+__attribute__((host)) __attribute__((device)) vo

[PATCH] D25105: [CUDA] Make lambdas inherit __host__ and __device__ attributes from the scope in which they're created.

2016-09-30 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a reviewer: rnk.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D25105



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


[PATCH] D25103: [CUDA] Handle attributes on CUDA lambdas appearing between [...] and (...).

2016-09-30 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm



> jlebar wrote in ParseExprCXX.cpp:1135
> nvcc doesn't seem to support __declspec attributes.
> 
> I have no strong opinion on whether or not we should add them ourselves, 
> though I guess I have a weak aversion to mucking with the parsing rules more 
> than is necessary.  (I put off this patch for as long as I could while I 
> tried to get nvcc to put the attributes in the right place.)

Nope, let's leave declspec alone then. :)

https://reviews.llvm.org/D25103



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


r282880 - [CUDA] Make lambdas inherit __host__ and __device__ attributes from the scope in which they're created.

2016-09-30 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Fri Sep 30 12:14:53 2016
New Revision: 282880

URL: http://llvm.org/viewvc/llvm-project?rev=282880&view=rev
Log:
[CUDA] Make lambdas inherit __host__ and __device__ attributes from the scope 
in which they're created.

Summary: NVCC compat.  Fixes bug 30567.

Reviewers: tra

Subscribers: cfe-commits, rnk

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

Added:
cfe/trunk/test/SemaCUDA/implicit-device-lambda-hd.cu
cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCUDA.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=282880&r1=282879&r2=282880&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Sep 30 12:14:53 2016
@@ -9264,6 +9264,14 @@ public:
   /// an error otherwise.
   bool CheckCUDAVLA(SourceLocation Loc);
 
+  /// Set __device__ or __host__ __device__ attributes on the given lambda
+  /// operator() method.
+  ///
+  /// CUDA lambdas declared inside __device__ or __global__ functions inherit
+  /// the __device__ attribute.  Similarly, lambdas inside __host__ __device__
+  /// functions become __host__ __device__ themselves.
+  void CUDASetLambdaAttrs(CXXMethodDecl *Method);
+
   /// Finds a function in \p Matches with highest calling priority
   /// from \p Caller context and erases all functions with lower
   /// calling priority.

Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=282880&r1=282879&r2=282880&view=diff
==
--- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp Fri Sep 30 12:14:53 2016
@@ -559,3 +559,22 @@ bool Sema::CheckCUDAVLA(SourceLocation L
   }
   return true;
 }
+
+void Sema::CUDASetLambdaAttrs(CXXMethodDecl *Method) {
+  if (Method->hasAttr() || Method->hasAttr())
+return;
+  FunctionDecl *CurFn = dyn_cast(CurContext);
+  if (!CurFn)
+return;
+  CUDAFunctionTarget Target = IdentifyCUDATarget(CurFn);
+  if (Target == CFT_Global || Target == CFT_Device) {
+Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+  } else if (Target == CFT_HostDevice) {
+Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+Method->addAttr(CUDAHostAttr::CreateImplicit(Context));
+  }
+
+  // TODO: nvcc doesn't allow you to specify __host__ or __device__ attributes
+  // on lambdas in all contexts -- we should emit a compatibility warning where
+  // we're more permissive.
+}

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=282880&r1=282879&r2=282880&view=diff
==
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Fri Sep 30 12:14:53 2016
@@ -886,7 +886,12 @@ void Sema::ActOnStartOfLambdaDefinition(
   
   // Attributes on the lambda apply to the method.  
   ProcessDeclAttributes(CurScope, Method, ParamInfo);
-  
+
+  // CUDA lambdas get implicit attributes based on the scope in which they're
+  // declared.
+  if (getLangOpts().CUDA)
+CUDASetLambdaAttrs(Method);
+
   // Introduce the function call operator as the current declaration context.
   PushDeclContext(CurScope, Method);
 

Added: cfe/trunk/test/SemaCUDA/implicit-device-lambda-hd.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/implicit-device-lambda-hd.cu?rev=282880&view=auto
==
--- cfe/trunk/test/SemaCUDA/implicit-device-lambda-hd.cu (added)
+++ cfe/trunk/test/SemaCUDA/implicit-device-lambda-hd.cu Fri Sep 30 12:14:53 
2016
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -verify 
-verify-ignore-unexpected=note \
+// RUN:   -S -o /dev/null %s
+// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only 
-verify-ignore-unexpected=note \
+// RUN:   -DHOST -S -o /dev/null %s
+#include "Inputs/cuda.h"
+
+__host__ __device__ void hd_fn() {
+  auto f1 = [&] {};
+  f1(); // implicitly __host__ __device__
+
+  auto f2 = [&] __device__ {};
+  f2();
+#ifdef HOST
+  // expected-error@-2 {{reference to __device__ function}}
+#endif
+
+  auto f3 = [&] __host__ {};
+  f3();
+#ifndef HOST
+  // expected-error@-2 {{reference to __host__ function}}
+#endif
+
+  auto f4 = [&] __host__ __device__ {};
+  f4();
+}
+
+

Added: cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu?rev=282880&view=auto
==
--- cfe/trunk/test/SemaCUDA/implicit-device-l

r282879 - [CUDA] Handle attributes on CUDA lambdas appearing between [...] and (...).

2016-09-30 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Fri Sep 30 12:14:48 2016
New Revision: 282879

URL: http://llvm.org/viewvc/llvm-project?rev=282879&view=rev
Log:
[CUDA] Handle attributes on CUDA lambdas appearing between [...] and (...).

Summary: This is ugh, but it makes us compatible with NVCC.  Fixes bug 26341.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

Added:
cfe/trunk/test/Parser/lambda-attr.cu
Modified:
cfe/trunk/lib/Parse/ParseExprCXX.cpp

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=282879&r1=282878&r2=282879&view=diff
==
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Fri Sep 30 12:14:48 2016
@@ -1124,7 +1124,17 @@ ExprResult Parser::ParseLambdaExpression
   DeclSpec DS(AttrFactory);
   Declarator D(DS, Declarator::LambdaExprContext);
   TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
-  Actions.PushLambdaScope();
+  Actions.PushLambdaScope();
+
+  ParsedAttributes Attr(AttrFactory);
+  SourceLocation DeclLoc = Tok.getLocation();
+  SourceLocation DeclEndLoc = DeclLoc;
+  if (getLangOpts().CUDA) {
+// In CUDA code, GNU attributes are allowed to appear immediately after the
+// "[...]", even if there is no "(...)" before the lambda body.
+MaybeParseGNUAttributes(Attr, &DeclEndLoc);
+D.takeAttributes(Attr, DeclEndLoc);
+  }
 
   TypeResult TrailingReturnType;
   if (Tok.is(tok::l_paren)) {
@@ -1133,13 +1143,11 @@ ExprResult Parser::ParseLambdaExpression
   Scope::FunctionDeclarationScope |
   Scope::DeclScope);
 
-SourceLocation DeclEndLoc;
 BalancedDelimiterTracker T(*this, tok::l_paren);
 T.consumeOpen();
 SourceLocation LParenLoc = T.getOpenLocation();
 
 // Parse parameter-declaration-clause.
-ParsedAttributes Attr(AttrFactory);
 SmallVector ParamInfo;
 SourceLocation EllipsisLoc;
 
@@ -1245,12 +1253,10 @@ ExprResult Parser::ParseLambdaExpression
 Diag(Tok, diag::err_lambda_missing_parens)
   << TokKind
   << FixItHint::CreateInsertion(Tok.getLocation(), "() ");
-SourceLocation DeclLoc = Tok.getLocation();
-SourceLocation DeclEndLoc = DeclLoc;
+DeclEndLoc = DeclLoc;
 
 // GNU-style attributes must be parsed before the mutable specifier to be
 // compatible with GCC.
-ParsedAttributes Attr(AttrFactory);
 MaybeParseGNUAttributes(Attr, &DeclEndLoc);
 
 // Parse 'mutable', if it's there.
@@ -1297,7 +1303,6 @@ ExprResult Parser::ParseLambdaExpression
TrailingReturnType),
   Attr, DeclEndLoc);
   }
-  
 
   // FIXME: Rename BlockScope -> ClosureScope if we decide to continue using
   // it.

Added: cfe/trunk/test/Parser/lambda-attr.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/lambda-attr.cu?rev=282879&view=auto
==
--- cfe/trunk/test/Parser/lambda-attr.cu (added)
+++ cfe/trunk/test/Parser/lambda-attr.cu Fri Sep 30 12:14:48 2016
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcuda-is-device -verify %s
+
+// expected-no-diagnostics
+
+__attribute__((device)) void device_fn() {}
+__attribute__((device)) void hd_fn() {}
+
+__attribute__((device)) void device_attr() {
+  ([]() __attribute__((device)) { device_fn(); })();
+  ([] __attribute__((device)) () { device_fn(); })();
+  ([] __attribute__((device)) { device_fn(); })();
+
+  ([&]() __attribute__((device)){ device_fn(); })();
+  ([&] __attribute__((device)) () { device_fn(); })();
+  ([&] __attribute__((device)) { device_fn(); })();
+
+  ([&](int) __attribute__((device)){ device_fn(); })(0);
+  ([&] __attribute__((device)) (int) { device_fn(); })(0);
+}
+
+__attribute__((host)) __attribute__((device)) void host_device_attrs() {
+  ([]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
+  ([] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
+  ([] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
+
+  ([&]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
+  ([&] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
+  ([&] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
+
+  ([&](int) __attribute__((host)) __attribute__((device)){ hd_fn(); })(0);
+  ([&] __attribute__((host)) __attribute__((device)) (int) { hd_fn(); })(0);
+}


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


r282878 - [CUDA] Add missing comment on Sema::CheckCUDAVLA.

2016-09-30 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Fri Sep 30 12:14:44 2016
New Revision: 282878

URL: http://llvm.org/viewvc/llvm-project?rev=282878&view=rev
Log:
[CUDA] Add missing comment on Sema::CheckCUDAVLA.

Modified:
cfe/trunk/include/clang/Sema/Sema.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=282878&r1=282877&r2=282878&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Sep 30 12:14:44 2016
@@ -9259,6 +9259,9 @@ public:
   /// ExprTy should be the string "try" or "throw", as appropriate.
   bool CheckCUDAExceptionExpr(SourceLocation Loc, StringRef ExprTy);
 
+  /// Check whether it's legal for us to create a variable-length array in the
+  /// current context.  Returns true if the VLA is OK; returns false and emits
+  /// an error otherwise.
   bool CheckCUDAVLA(SourceLocation Loc);
 
   /// Finds a function in \p Matches with highest calling priority


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


[PATCH] D25105: [CUDA] Make lambdas inherit __host__ and __device__ attributes from the scope in which they're created.

2016-09-30 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282880: [CUDA] Make lambdas inherit __host__ and __device__ 
attributes from the scope… (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D25105?vs=73073&id=73089#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25105

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaCUDA.cpp
  cfe/trunk/lib/Sema/SemaLambda.cpp
  cfe/trunk/test/SemaCUDA/implicit-device-lambda-hd.cu
  cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -9264,6 +9264,14 @@
   /// an error otherwise.
   bool CheckCUDAVLA(SourceLocation Loc);
 
+  /// Set __device__ or __host__ __device__ attributes on the given lambda
+  /// operator() method.
+  ///
+  /// CUDA lambdas declared inside __device__ or __global__ functions inherit
+  /// the __device__ attribute.  Similarly, lambdas inside __host__ __device__
+  /// functions become __host__ __device__ themselves.
+  void CUDASetLambdaAttrs(CXXMethodDecl *Method);
+
   /// Finds a function in \p Matches with highest calling priority
   /// from \p Caller context and erases all functions with lower
   /// calling priority.
Index: cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu
===
--- cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu
+++ cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -verify -fsyntax-only -verify-ignore-unexpected=note %s
+// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -verify-ignore-unexpected=note %s
+
+#include "Inputs/cuda.h"
+
+__device__ void device_fn() {
+  auto f1 = [&] {};
+  f1(); // implicitly __device__
+
+  auto f2 = [&] __device__ {};
+  f2();
+
+  auto f3 = [&] __host__ {};
+  f3();  // expected-error {{no matching function}}
+
+  auto f4 = [&] __host__ __device__ {};
+  f4();
+
+  // Now do it all again with '()'s in the lambda declarations: This is a
+  // different parse path.
+  auto g1 = [&]() {};
+  g1(); // implicitly __device__
+
+  auto g2 = [&]() __device__ {};
+  g2();
+
+  auto g3 = [&]() __host__ {};
+  g3();  // expected-error {{no matching function}}
+
+  auto g4 = [&]() __host__ __device__ {};
+  g4();
+
+  // Once more, with the '()'s in a different place.
+  auto h1 = [&]() {};
+  h1(); // implicitly __device__
+
+  auto h2 = [&] __device__ () {};
+  h2();
+
+  auto h3 = [&] __host__ () {};
+  h3();  // expected-error {{no matching function}}
+
+  auto h4 = [&] __host__ __device__ () {};
+  h4();
+}
+
+// Behaves identically to device_fn.
+__global__ void kernel_fn() {
+  auto f1 = [&] {};
+  f1(); // implicitly __device__
+
+  auto f2 = [&] __device__ {};
+  f2();
+
+  auto f3 = [&] __host__ {};
+  f3();  // expected-error {{no matching function}}
+
+  auto f4 = [&] __host__ __device__ {};
+  f4();
+
+  // No need to re-test all the parser contortions we test in the device
+  // function.
+}
+
+__host__ void host_fn() {
+  auto f1 = [&] {};
+  f1(); // implicitly __host__ (i.e., no magic)
+
+  auto f2 = [&] __device__ {};
+  f2();  // expected-error {{no matching function}}
+
+  auto f3 = [&] __host__ {};
+  f3();
+
+  auto f4 = [&] __host__ __device__ {};
+  f4();
+}
+
+// The special treatment above only applies to lambdas.
+__device__ void foo() {
+  struct X {
+void foo() {}
+  };
+  X x;
+  x.foo(); // expected-error {{reference to __host__ function 'foo' in __device__ function}}
+}
Index: cfe/trunk/test/SemaCUDA/implicit-device-lambda-hd.cu
===
--- cfe/trunk/test/SemaCUDA/implicit-device-lambda-hd.cu
+++ cfe/trunk/test/SemaCUDA/implicit-device-lambda-hd.cu
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -verify -verify-ignore-unexpected=note \
+// RUN:   -S -o /dev/null %s
+// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -verify-ignore-unexpected=note \
+// RUN:   -DHOST -S -o /dev/null %s
+#include "Inputs/cuda.h"
+
+__host__ __device__ void hd_fn() {
+  auto f1 = [&] {};
+  f1(); // implicitly __host__ __device__
+
+  auto f2 = [&] __device__ {};
+  f2();
+#ifdef HOST
+  // expected-error@-2 {{reference to __device__ function}}
+#endif
+
+  auto f3 = [&] __host__ {};
+  f3();
+#ifndef HOST
+  // expected-error@-2 {{reference to __host__ function}}
+#endif
+
+  auto f4 = [&] __host__ __device__ {};
+  f4();
+}
+
+
Index: cfe/trunk/lib/Sema/SemaLambda.cpp
===
--- cfe/trunk/lib/Sema/SemaLambda.cpp
+++ cfe/trunk/lib/Sema/SemaLambda.cpp
@@ -886,7 +886,12 @@
   
   // Attributes on the lambda apply to the method.  
   ProcessDeclAttributes(CurScope, Method, ParamInfo);
-  
+
+  // CUDA lambdas get implicit attributes based on 

[PATCH] D25103: [CUDA] Handle attributes on CUDA lambdas appearing between [...] and (...).

2016-09-30 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282879: [CUDA] Handle attributes on CUDA lambdas appearing 
between [...] and (...). (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D25103?vs=73085&id=73088#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25103

Files:
  cfe/trunk/lib/Parse/ParseExprCXX.cpp
  cfe/trunk/test/Parser/lambda-attr.cu


Index: cfe/trunk/test/Parser/lambda-attr.cu
===
--- cfe/trunk/test/Parser/lambda-attr.cu
+++ cfe/trunk/test/Parser/lambda-attr.cu
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcuda-is-device -verify %s
+
+// expected-no-diagnostics
+
+__attribute__((device)) void device_fn() {}
+__attribute__((device)) void hd_fn() {}
+
+__attribute__((device)) void device_attr() {
+  ([]() __attribute__((device)) { device_fn(); })();
+  ([] __attribute__((device)) () { device_fn(); })();
+  ([] __attribute__((device)) { device_fn(); })();
+
+  ([&]() __attribute__((device)){ device_fn(); })();
+  ([&] __attribute__((device)) () { device_fn(); })();
+  ([&] __attribute__((device)) { device_fn(); })();
+
+  ([&](int) __attribute__((device)){ device_fn(); })(0);
+  ([&] __attribute__((device)) (int) { device_fn(); })(0);
+}
+
+__attribute__((host)) __attribute__((device)) void host_device_attrs() {
+  ([]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
+  ([] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
+  ([] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
+
+  ([&]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
+  ([&] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
+  ([&] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
+
+  ([&](int) __attribute__((host)) __attribute__((device)){ hd_fn(); })(0);
+  ([&] __attribute__((host)) __attribute__((device)) (int) { hd_fn(); })(0);
+}
Index: cfe/trunk/lib/Parse/ParseExprCXX.cpp
===
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp
@@ -1124,22 +1124,30 @@
   DeclSpec DS(AttrFactory);
   Declarator D(DS, Declarator::LambdaExprContext);
   TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
-  Actions.PushLambdaScope();
+  Actions.PushLambdaScope();
+
+  ParsedAttributes Attr(AttrFactory);
+  SourceLocation DeclLoc = Tok.getLocation();
+  SourceLocation DeclEndLoc = DeclLoc;
+  if (getLangOpts().CUDA) {
+// In CUDA code, GNU attributes are allowed to appear immediately after the
+// "[...]", even if there is no "(...)" before the lambda body.
+MaybeParseGNUAttributes(Attr, &DeclEndLoc);
+D.takeAttributes(Attr, DeclEndLoc);
+  }
 
   TypeResult TrailingReturnType;
   if (Tok.is(tok::l_paren)) {
 ParseScope PrototypeScope(this,
   Scope::FunctionPrototypeScope |
   Scope::FunctionDeclarationScope |
   Scope::DeclScope);
 
-SourceLocation DeclEndLoc;
 BalancedDelimiterTracker T(*this, tok::l_paren);
 T.consumeOpen();
 SourceLocation LParenLoc = T.getOpenLocation();
 
 // Parse parameter-declaration-clause.
-ParsedAttributes Attr(AttrFactory);
 SmallVector ParamInfo;
 SourceLocation EllipsisLoc;
 
@@ -1245,12 +1253,10 @@
 Diag(Tok, diag::err_lambda_missing_parens)
   << TokKind
   << FixItHint::CreateInsertion(Tok.getLocation(), "() ");
-SourceLocation DeclLoc = Tok.getLocation();
-SourceLocation DeclEndLoc = DeclLoc;
+DeclEndLoc = DeclLoc;
 
 // GNU-style attributes must be parsed before the mutable specifier to be
 // compatible with GCC.
-ParsedAttributes Attr(AttrFactory);
 MaybeParseGNUAttributes(Attr, &DeclEndLoc);
 
 // Parse 'mutable', if it's there.
@@ -1297,7 +1303,6 @@
TrailingReturnType),
   Attr, DeclEndLoc);
   }
-  
 
   // FIXME: Rename BlockScope -> ClosureScope if we decide to continue using
   // it.


Index: cfe/trunk/test/Parser/lambda-attr.cu
===
--- cfe/trunk/test/Parser/lambda-attr.cu
+++ cfe/trunk/test/Parser/lambda-attr.cu
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcuda-is-device -verify %s
+
+// expected-no-diagnostics
+
+__attribute__((device)) void device_fn() {}
+__attribute__((device)) void hd_fn() {}
+
+__attribute__((device)) void device_attr() {
+  ([]() __attribute__((device)) { device_fn(); })();
+  ([] __attribute__((device)) () { device_fn(); })();
+  ([] __attribute__((device)) { device_fn(); })();
+
+  ([&]() __attribute__((device)){ device_fn(); })();
+  ([&] __attribute__((device)) () { dev

[PATCH] D25103: [CUDA] Handle attributes on CUDA lambdas appearing between [...] and (...).

2016-09-30 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


> rnk wrote in ParseExprCXX.cpp:1135
> Does nvcc support __declspec style attributes? Maybe we should check for 
> those too?

nvcc doesn't seem to support __declspec attributes.

I have no strong opinion on whether or not we should add them ourselves, though 
I guess I have a weak aversion to mucking with the parsing rules more than is 
necessary.  (I put off this patch for as long as I could while I tried to get 
nvcc to put the attributes in the right place.)

> rnk wrote in ParseExprCXX.cpp:1280
> Let's not duplicate this amazingly long type info thingy. I think you can 
> avoid it if you hoist MutableLoc and add a bool like 
> `NeedFuncDeclaratorChunk`. Also, maybe we shouldn't be hallucinating a 
> function declarator chunk in CUDA when there are no attributes?

Oh, I didn't look closely enough at the API to realize that I could add 
attributes without creating a new function declarator chunk.  New patch is a 
much smaller change.

https://reviews.llvm.org/D25103



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


[PATCH] D25093: [libcxx] [cmake] Allow testing against installed LLVM with no sources

2016-09-30 Thread Michał Górny via cfe-commits
mgorny added a comment.

Combined with https://reviews.llvm.org/D25076 (on llvm), this lets me run 
libcxx test suite on top of installed LLVM+lit, without LLVM sources.


https://reviews.llvm.org/D25093



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


[PATCH] D25078: [coroutines] Diagnose when 'main' is declared as a coroutine.

2016-09-30 Thread Gor Nishanov via cfe-commits
GorNishanov added a comment.

LGTM

I am happy either way. Fixes for co_return can come later.


https://reviews.llvm.org/D25078



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


[PATCH] D24986: [MS] Implement __iso_volatile loads/stores as builtins

2016-09-30 Thread David Majnemer via cfe-commits
majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM



> ms-volatile-arm.c:2
> +// REQUIRES: arm-registered-target
> +// RUN: %clang_cc1 -triple thumbv7-win32 -emit-llvm -fms-extensions 
> -fms-volatile -o - < %s | FileCheck %s
> +

You don't need -fms-volatile.

https://reviews.llvm.org/D24986



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


[PATCH] D24986: [MS] Implement __iso_volatile loads/stores as builtins

2016-09-30 Thread Martin Storsjö via cfe-commits
mstorsjo added inline comments.


> majnemer wrote in ms-volatile-arm.c:2
> You don't need -fms-volatile.

Well, originally, the point was to clarify that these volatile stores end up 
without atomic semantics, regardless of whether -volatile:ms has been 
specified. The original version of this patch (with an inline implementation in 
intrin.h, just using a normal volatile pointer) wouldn't pass this test, but 
would pass if I remove this option. But if you prefer, I can leave it out.

https://reviews.llvm.org/D24986



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


[PATCH] D24759: [RFC][StaticAnalyser] fix unreachable code false positives when block numbers mismatch

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

LGTM. Please commit!


https://reviews.llvm.org/D24759



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


[PATCH] D25113: [Sema] Don't display an invalid redefinition error when dealing with a redefinition of a function whose previous definition was typo-corrected

2016-09-30 Thread Alex Lorenz via cfe-commits
arphaman created this revision.
arphaman added a reviewer: rsmith.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch improves the displayed diagnostics when encountering a redefinition 
of a function whose previous definition was typo-corrected.

For example, given a code sample like this:

  class Foo {
int* create_process(int pid, const char* name);
  };
  
  int *Foo::create_process2(int pid, const char* name) {
return 0;
  }
  
  int *Foo::create_process(int pid, const char* name) {
return 0;
  }

Clang will now show only the error diagnostic for the definition of 
create_process2: "out-of-line definition of 'create_process2' does not match 
any declaration in 'Foo'; did you mean 'create_process'?". However, prior to 
this patch, clang would have also shown a second error diagnostic for the 
definition of create_process: "redefinition of 'create_process'". The second 
diagnostic shouldn't be presented as it's not true, and the automatic renaming 
of create_process2 shouldn't cause such an error.


Repository:
  rL LLVM

https://reviews.llvm.org/D25113

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/typo-correction.cpp


Index: test/SemaCXX/typo-correction.cpp
===
--- test/SemaCXX/typo-correction.cpp
+++ test/SemaCXX/typo-correction.cpp
@@ -679,3 +679,33 @@
   sizeof(c0is0)]; // expected-error {{use of undeclared identifier}}
 };
 }
+
+namespace {
+class Foo {
+  int* create_process(int pid); // expected-note {{'create_process' declared 
here}}
+};
+
+int *Foo::create_process2(int pid) { // expected-error {{out-of-line 
definition of 'create_process2' does not match any declaration in '(anonymous 
namespace)::Foo'; did you mean 'create_process'?}}
+  return 0;
+}
+
+// Expected no redefinition error here.
+int *Foo::create_process(int pid) { // expected-note {{previous definition is 
here}}
+  return 0;
+}
+
+int *Foo::create_process(int pid) { // expected-error {{redefinition of 
'create_process'}}
+  return 0;
+}
+
+namespace test {
+void create_test(); // expected-note {{'create_test' declared here}}
+}
+
+void test::create_test2() { // expected-error {{out-of-line definition of 
'create_test2' does not match any declaration in namespace '(anonymous 
namespace)::test'; did you mean 'create_test'?}}
+}
+
+// Expected no redefinition error here.
+void test::create_test() {
+}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7191,6 +7191,10 @@
 
 } // end anonymous namespace
 
+void Sema::MarkTypoCorrectedFunctionDefinition(const NamedDecl *F) {
+  TypoCorrectedFunctionDefinitions.insert(F);
+}
+
 /// \brief Generate diagnostics for an invalid function redeclaration.
 ///
 /// This routine handles generating the diagnostic messages for an invalid
@@ -7288,6 +7292,8 @@
 if ((*I)->getCanonicalDecl() == Canonical)
   Correction.setCorrectionDecl(*I);
 
+  // Let Sema know about the correction.
+  SemaRef.MarkTypoCorrectedFunctionDefinition(Result);
   SemaRef.diagnoseTypo(
   Correction,
   SemaRef.PDiag(IsLocalFriend
@@ -11315,6 +11321,11 @@
   if (canRedefineFunction(Definition, getLangOpts()))
 return;
 
+  // Don't emit an error when this is redifinition of a typo-corrected
+  // definition.
+  if (TypoCorrectedFunctionDefinitions.count(Definition))
+return;
+
   // If we don't have a visible definition of the function, and it's inline or
   // a template, skip the new definition.
   if (SkipBody && !hasVisibleDefinition(Definition) &&
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -1031,6 +1031,12 @@
   /// currently being copy-initialized. Can be empty.
   llvm::SmallVector CurrentParameterCopyTypes;
 
+  /// The function definitions which were renamed as part of typo-correction
+  /// to match their respective declarations. We want to keep track of them
+  /// to ensure that we don't emit a "redefinition" error if we encounter a
+  /// correctly named definition after the renamed definition.
+  llvm::SmallPtrSet TypoCorrectedFunctionDefinitions;
+
   void ReadMethodPool(Selector Sel);
   void updateOutOfDateSelector(Selector Sel);
 
@@ -3012,6 +3018,8 @@
 const PartialDiagnostic &PrevNote,
 bool ErrorRecovery = true);
 
+  void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F);
+
   void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc,
   ArrayRef Args,
AssociatedNamespaceSet 
&AssociatedNamespaces,


Index: test/SemaCXX/typo-correction.cpp
===
--- test/SemaCXX/

[PATCH] D24905: Fix unreachable code false positive, vardecl in switch

2016-09-30 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

Sorry, missed this patch.

I think it would good to add a test to make sure we do warn when the var decl 
has an initializer, since that will not be executed.

  void varDecl(int X) {
switch (X) {
  int A = 12; // We do want a warning here, since the variable will be 
uninitialized in C (This is not allowed in C++).
case 1:
  ...
  break;
}
  }


Repository:
  rL LLVM

https://reviews.llvm.org/D24905



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


[PATCH] D25114: [CUDA] Fix up MaybeParseGNUAttributes call used for out-of-place attributes on CUDA lambdas.

2016-09-30 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rnk.
jlebar added subscribers: tra, cfe-commits.

There's an overload that we can use to make this a bit cleaner.


https://reviews.llvm.org/D25114

Files:
  clang/lib/Parse/ParseExprCXX.cpp


Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -1128,12 +1128,10 @@
 
   ParsedAttributes Attr(AttrFactory);
   SourceLocation DeclLoc = Tok.getLocation();
-  SourceLocation DeclEndLoc = DeclLoc;
   if (getLangOpts().CUDA) {
 // In CUDA code, GNU attributes are allowed to appear immediately after the
 // "[...]", even if there is no "(...)" before the lambda body.
-MaybeParseGNUAttributes(Attr, &DeclEndLoc);
-D.takeAttributes(Attr, DeclEndLoc);
+MaybeParseGNUAttributes(D);
   }
 
   TypeResult TrailingReturnType;
@@ -1161,7 +1159,7 @@
 }
 T.consumeClose();
 SourceLocation RParenLoc = T.getCloseLocation();
-DeclEndLoc = RParenLoc;
+SourceLocation DeclEndLoc = RParenLoc;
 
 // GNU-style attributes must be parsed before the mutable specifier to be
 // compatible with GCC.
@@ -1253,7 +1251,7 @@
 Diag(Tok, diag::err_lambda_missing_parens)
   << TokKind
   << FixItHint::CreateInsertion(Tok.getLocation(), "() ");
-DeclEndLoc = DeclLoc;
+SourceLocation DeclEndLoc = DeclLoc;
 
 // GNU-style attributes must be parsed before the mutable specifier to be
 // compatible with GCC.


Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -1128,12 +1128,10 @@
 
   ParsedAttributes Attr(AttrFactory);
   SourceLocation DeclLoc = Tok.getLocation();
-  SourceLocation DeclEndLoc = DeclLoc;
   if (getLangOpts().CUDA) {
 // In CUDA code, GNU attributes are allowed to appear immediately after the
 // "[...]", even if there is no "(...)" before the lambda body.
-MaybeParseGNUAttributes(Attr, &DeclEndLoc);
-D.takeAttributes(Attr, DeclEndLoc);
+MaybeParseGNUAttributes(D);
   }
 
   TypeResult TrailingReturnType;
@@ -1161,7 +1159,7 @@
 }
 T.consumeClose();
 SourceLocation RParenLoc = T.getCloseLocation();
-DeclEndLoc = RParenLoc;
+SourceLocation DeclEndLoc = RParenLoc;
 
 // GNU-style attributes must be parsed before the mutable specifier to be
 // compatible with GCC.
@@ -1253,7 +1251,7 @@
 Diag(Tok, diag::err_lambda_missing_parens)
   << TokKind
   << FixItHint::CreateInsertion(Tok.getLocation(), "() ");
-DeclEndLoc = DeclLoc;
+SourceLocation DeclEndLoc = DeclLoc;
 
 // GNU-style attributes must be parsed before the mutable specifier to be
 // compatible with GCC.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25115: [CUDA] Emit a warning if a CUDA host/device/global attribute is placed after '(...)'.

2016-09-30 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rnk.
jlebar added subscribers: tra, cfe-commits.

This is probably the sane place for the attribute to go, but nvcc
specifically rejects it.  Other GNU-style attributes are allowed in this
position (although judging from the warning it emits for
host/device/global, those attributes are applied to the lambda's
anonymous struct, not to the function itself).

It would be nice to have a FixIt message here, but doing so, or even
just getting the correct range for the attribute, including its '((' and
'))'s, is apparently Hard.


https://reviews.llvm.org/D25115

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/Parser/lambda-attr.cu

Index: clang/test/Parser/lambda-attr.cu
===
--- clang/test/Parser/lambda-attr.cu
+++ clang/test/Parser/lambda-attr.cu
@@ -1,33 +1,42 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcuda-is-device -verify %s
 
-// expected-no-diagnostics
-
 __attribute__((device)) void device_fn() {}
 __attribute__((device)) void hd_fn() {}
 
 __attribute__((device)) void device_attr() {
   ([]() __attribute__((device)) { device_fn(); })();
+  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
   ([] __attribute__((device)) () { device_fn(); })();
   ([] __attribute__((device)) { device_fn(); })();
 
   ([&]() __attribute__((device)){ device_fn(); })();
+  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
   ([&] __attribute__((device)) () { device_fn(); })();
   ([&] __attribute__((device)) { device_fn(); })();
 
   ([&](int) __attribute__((device)){ device_fn(); })(0);
+  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
   ([&] __attribute__((device)) (int) { device_fn(); })(0);
 }
 
 __attribute__((host)) __attribute__((device)) void host_device_attrs() {
   ([]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
+  // expected-warning@-1 {{nvcc does not allow '__host__' to appear after '()' in lambdas}}
+  // expected-warning@-2 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
   ([] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
   ([] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
 
   ([&]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
+  // expected-warning@-1 {{nvcc does not allow '__host__' to appear after '()' in lambdas}}
+  // expected-warning@-2 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
   ([&] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
   ([&] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
 
   ([&](int) __attribute__((host)) __attribute__((device)){ hd_fn(); })(0);
+  // expected-warning@-1 {{nvcc does not allow '__host__' to appear after '()' in lambdas}}
+  // expected-warning@-2 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
   ([&] __attribute__((host)) __attribute__((device)) (int) { hd_fn(); })(0);
 }
+
+// TODO: Add tests for __attribute__((global)) once we support global lambdas.
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -1134,6 +1134,18 @@
 MaybeParseGNUAttributes(D);
   }
 
+  // Helper to emit a warning if we see a CUDA host/device/global attribute
+  // after '(...)'. nvcc doesn't accept this.
+  auto WarnIfHasCUDATargetAttr = [&] {
+if (getLangOpts().CUDA)
+  for (auto *A = Attr.getList(); A != nullptr; A = A->getNext())
+if (A->getKind() == AttributeList::AT_CUDADevice ||
+A->getKind() == AttributeList::AT_CUDAHost ||
+A->getKind() == AttributeList::AT_CUDAGlobal)
+  Diag(A->getLoc(), diag::warn_cuda_attr_lambda_position)
+  << A->getName()->getName();
+  };
+
   TypeResult TrailingReturnType;
   if (Tok.is(tok::l_paren)) {
 ParseScope PrototypeScope(this,
@@ -1210,6 +1222,8 @@
 
 PrototypeScope.Exit();
 
+WarnIfHasCUDATargetAttr();
+
 SourceLocation NoLoc;
 D.AddTypeInfo(DeclaratorChunk::getFunction(/*hasProto=*/true,
/*isAmbiguous=*/false,
@@ -1275,6 +1289,8 @@
 DeclEndLoc = Range.getEnd();
 }
 
+WarnIfHasCUDATargetAttr();
+
 SourceLocation NoLoc;
 D.AddTypeInfo(DeclaratorChunk::getFunction(/*hasProto=*/true,
/*isAmbiguous=*/false,
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1022,6 +1022,10 @@
 def warn_pragma_unroll_cuda

[PATCH] D24986: [MS] Implement __iso_volatile loads/stores as builtins

2016-09-30 Thread David Majnemer via cfe-commits
majnemer added inline comments.


> mstorsjo wrote in ms-volatile-arm.c:2
> Well, originally, the point was to clarify that these volatile stores end up 
> without atomic semantics, regardless of whether -volatile:ms has been 
> specified. The original version of this patch (with an inline implementation 
> in intrin.h, just using a normal volatile pointer) wouldn't pass this test, 
> but would pass if I remove this option. But if you prefer, I can leave it out.

Makes sense.

https://reviews.llvm.org/D24986



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


[PATCH] D25115: [CUDA] Emit a warning if a CUDA host/device/global attribute is placed after '(...)'.

2016-09-30 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D25115



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


[PATCH] D24986: [MS] Implement __iso_volatile loads/stores as builtins

2016-09-30 Thread Martin Storsjö via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282900: [MS] Implement __iso_volatile loads/stores as 
builtins (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D24986?vs=72988&id=73113#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24986

Files:
  cfe/trunk/include/clang/Basic/BuiltinsARM.def
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/ms-volatile-arm.c


Index: cfe/trunk/include/clang/Basic/BuiltinsARM.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def
@@ -115,6 +115,14 @@
 LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load8,   "ccCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load16,  "ssCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load32,  "iiCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load64,  "LLiLLiCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store8,  "vcD*c", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store16, "vsD*s", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store32, "viD*i", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store64, "vLLiD*LLi", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__ldrexd, "WiWiCD*", "", ALL_MS_LANGUAGES)
 LANGBUILTIN(_MoveFromCoprocessor, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES)
 LANGBUILTIN(_MoveFromCoprocessor2, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES)
Index: cfe/trunk/test/CodeGen/ms-volatile-arm.c
===
--- cfe/trunk/test/CodeGen/ms-volatile-arm.c
+++ cfe/trunk/test/CodeGen/ms-volatile-arm.c
@@ -0,0 +1,13 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple thumbv7-win32 -emit-llvm -fms-extensions 
-fms-volatile -o - < %s | FileCheck %s
+
+void test1(int volatile *p, int v) {
+  __iso_volatile_store32(p, v);
+  // CHECK-LABEL: @test1
+  // CHECK: store volatile {{.*}}, {{.*}}
+}
+int test2(const int volatile *p) {
+  return __iso_volatile_load32(p);
+  // CHECK-LABEL: @test2
+  // CHECK: load volatile {{.*}}
+}
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -4279,6 +4279,41 @@
 return Builder.CreateCall(F, {StoreVal, StoreAddr}, "strex");
   }
 
+  switch (BuiltinID) {
+  case ARM::BI__iso_volatile_load8:
+  case ARM::BI__iso_volatile_load16:
+  case ARM::BI__iso_volatile_load32:
+  case ARM::BI__iso_volatile_load64: {
+Value *Ptr = EmitScalarExpr(E->getArg(0));
+QualType ElTy = E->getArg(0)->getType()->getPointeeType();
+CharUnits LoadSize = getContext().getTypeSizeInChars(ElTy);
+llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(),
+ LoadSize.getQuantity() * 8);
+Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo());
+llvm::LoadInst *Load =
+  Builder.CreateAlignedLoad(Ptr, LoadSize);
+Load->setVolatile(true);
+return Load;
+  }
+  case ARM::BI__iso_volatile_store8:
+  case ARM::BI__iso_volatile_store16:
+  case ARM::BI__iso_volatile_store32:
+  case ARM::BI__iso_volatile_store64: {
+Value *Ptr = EmitScalarExpr(E->getArg(0));
+Value *Value = EmitScalarExpr(E->getArg(1));
+QualType ElTy = E->getArg(0)->getType()->getPointeeType();
+CharUnits StoreSize = getContext().getTypeSizeInChars(ElTy);
+llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(),
+ StoreSize.getQuantity() * 8);
+Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo());
+llvm::StoreInst *Store =
+  Builder.CreateAlignedStore(Value, Ptr,
+ StoreSize);
+Store->setVolatile(true);
+return Store;
+  }
+  }
+
   if (BuiltinID == ARM::BI__builtin_arm_clrex) {
 Function *F = CGM.getIntrinsic(Intrinsic::arm_clrex);
 return Builder.CreateCall(F);


Index: cfe/trunk/include/clang/Basic/BuiltinsARM.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def
@@ -115,6 +115,14 @@
 LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load8,   "ccCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load16,  "ssCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load32,  "iiCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load64,  "LLiLLiCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store8,  "vcD*c", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store16, "vsD*s", "n", 

r282900 - [MS] Implement __iso_volatile loads/stores as builtins

2016-09-30 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Fri Sep 30 14:13:46 2016
New Revision: 282900

URL: http://llvm.org/viewvc/llvm-project?rev=282900&view=rev
Log:
[MS] Implement __iso_volatile loads/stores as builtins

These are supposed to produce the same as normal volatile
pointer loads/stores. When -volatile:ms is specified,
normal volatile pointers are forced to have atomic semantics
(as is the default on x86 in MSVC mode). In that case,
these builtins should still produce non-atomic volatile
loads/stores without acquire/release semantics, which
the new test verifies.

These are only available on ARM (and on AArch64,
although clang doesn't support AArch64/Windows yet).

This implements what is missing for PR30394, making it possible
to compile C++ for ARM in MSVC mode with MSVC headers.

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

Added:
cfe/trunk/test/CodeGen/ms-volatile-arm.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsARM.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsARM.def?rev=282900&r1=282899&r2=282900&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def Fri Sep 30 14:13:46 2016
@@ -115,6 +115,14 @@ LANGBUILTIN(__sevl, "v", "", ALL_MS_LANG
 LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load8,   "ccCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load16,  "ssCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load32,  "iiCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load64,  "LLiLLiCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store8,  "vcD*c", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store16, "vsD*s", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store32, "viD*i", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store64, "vLLiD*LLi", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__ldrexd, "WiWiCD*", "", ALL_MS_LANGUAGES)
 LANGBUILTIN(_MoveFromCoprocessor, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES)
 LANGBUILTIN(_MoveFromCoprocessor2, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES)

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=282900&r1=282899&r2=282900&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Sep 30 14:13:46 2016
@@ -4279,6 +4279,41 @@ Value *CodeGenFunction::EmitARMBuiltinEx
 return Builder.CreateCall(F, {StoreVal, StoreAddr}, "strex");
   }
 
+  switch (BuiltinID) {
+  case ARM::BI__iso_volatile_load8:
+  case ARM::BI__iso_volatile_load16:
+  case ARM::BI__iso_volatile_load32:
+  case ARM::BI__iso_volatile_load64: {
+Value *Ptr = EmitScalarExpr(E->getArg(0));
+QualType ElTy = E->getArg(0)->getType()->getPointeeType();
+CharUnits LoadSize = getContext().getTypeSizeInChars(ElTy);
+llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(),
+ LoadSize.getQuantity() * 8);
+Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo());
+llvm::LoadInst *Load =
+  Builder.CreateAlignedLoad(Ptr, LoadSize);
+Load->setVolatile(true);
+return Load;
+  }
+  case ARM::BI__iso_volatile_store8:
+  case ARM::BI__iso_volatile_store16:
+  case ARM::BI__iso_volatile_store32:
+  case ARM::BI__iso_volatile_store64: {
+Value *Ptr = EmitScalarExpr(E->getArg(0));
+Value *Value = EmitScalarExpr(E->getArg(1));
+QualType ElTy = E->getArg(0)->getType()->getPointeeType();
+CharUnits StoreSize = getContext().getTypeSizeInChars(ElTy);
+llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(),
+ StoreSize.getQuantity() * 8);
+Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo());
+llvm::StoreInst *Store =
+  Builder.CreateAlignedStore(Value, Ptr,
+ StoreSize);
+Store->setVolatile(true);
+return Store;
+  }
+  }
+
   if (BuiltinID == ARM::BI__builtin_arm_clrex) {
 Function *F = CGM.getIntrinsic(Intrinsic::arm_clrex);
 return Builder.CreateCall(F);

Added: cfe/trunk/test/CodeGen/ms-volatile-arm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-volatile-arm.c?rev=282900&view=auto
==
--- cfe/trunk/test/CodeGen/ms-volatile-arm.c (added)
+++ cfe/trunk/test/CodeGen/ms-volatile-arm.c Fri Sep 30 14:13:46 2016
@@ -0,0 +1,13 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple thumbv7-win32 -emit-llvm -fms-extensions 
-fms-volatile -o - < %s | Fi

[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-09-30 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Ping?


https://reviews.llvm.org/D23657



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


[PATCH] D25065: [change-namespace] Fixed a bug in getShortestQualifiedNameInNamespace.

2016-09-30 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 73116.
ioeric added a comment.

- Remove redundant variable.


https://reviews.llvm.org/D25065

Files:
  change-namespace/ChangeNamespace.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -113,6 +113,24 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, MoveIntoAnotherNestedNamespaceWithRef) {
+  NewNamespace = "na::nc";
+  std::string Code = "namespace na {\n"
+ "class A {};\n"
+ "namespace nb {\n"
+ "class X { A a; };\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "class A {};\n"
+ "\n"
+ "namespace nc {\n"
+ "class X { A a; };\n"
+ "} // namespace nc\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, SimpleMoveNestedNamespace) {
   NewNamespace = "na::x::y";
   std::string Code = "namespace na {\n"
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -172,21 +172,25 @@
 // Returns the shortest qualified name for declaration `DeclName` in the
 // namespace `NsName`. For example, if `DeclName` is "a::b::X" and `NsName`
 // is "a::c::d", then "b::X" will be returned.
+// \param DeclName A fully qualified name, "::a::b::X" or "a::b::X".
+// \param NsName A fully qualified name, "::a::b" or "a::b".
 std::string getShortestQualifiedNameInNamespace(llvm::StringRef DeclName,
 llvm::StringRef NsName) {
-  llvm::SmallVector DeclNameSplitted;
-  DeclName.split(DeclNameSplitted, "::");
-  if (DeclNameSplitted.size() == 1)
-return DeclName;
-  const auto UnqualifiedName = DeclNameSplitted.back();
+  DeclName = DeclName.ltrim(':');
+  NsName = NsName.ltrim(':');
+  // If `DeclName` is a global variable, we prepend "::" to it if it is not in
+  // the global namespace.
+  if (DeclName.find(':') == llvm::StringRef::npos)
+return NsName.empty() ? DeclName.str() : ("::" + DeclName).str();
+
   while (true) {
+if (DeclName.consume_front((NsName + "::").str()))
+  return DeclName.str();
 const auto Pos = NsName.find_last_of(':');
 if (Pos == llvm::StringRef::npos)
   return DeclName;
-const auto Prefix = NsName.substr(0, Pos - 1);
-if (DeclName.startswith(Prefix))
-  return (Prefix + "::" + UnqualifiedName).str();
-NsName = Prefix;
+assert(Pos > 0);
+NsName = NsName.substr(0, Pos - 1);
   }
   return DeclName;
 }


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -113,6 +113,24 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, MoveIntoAnotherNestedNamespaceWithRef) {
+  NewNamespace = "na::nc";
+  std::string Code = "namespace na {\n"
+ "class A {};\n"
+ "namespace nb {\n"
+ "class X { A a; };\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "class A {};\n"
+ "\n"
+ "namespace nc {\n"
+ "class X { A a; };\n"
+ "} // namespace nc\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, SimpleMoveNestedNamespace) {
   NewNamespace = "na::x::y";
   std::string Code = "namespace na {\n"
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -172,21 +172,25 @@
 // Returns the shortest qualified name for declaration `DeclName` in the
 // namespace `NsName`. For example, if `DeclName` is "a::b::X" and `NsName`
 // is "a::c::d", then "b::X" will be returned.
+// \param DeclName A fully qualified name, "::a::b::X" or "a::b::X".
+// \param NsName A fully qualified name, "::a::b" or "a::b".
 std::string getShortestQualifiedNameInNamespace(llvm::StringRef DeclName,
 llvm::StringRef NsName) {
-  llvm::SmallVector DeclN

[PATCH] D25114: [CUDA] Fix up MaybeParseGNUAttributes call used for out-of-place attributes on CUDA lambdas.

2016-09-30 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D25114



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


r282911 - [CUDA] Emit a warning if a CUDA host/device/global attribute is placed after '(...)'.

2016-09-30 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Fri Sep 30 14:55:55 2016
New Revision: 282911

URL: http://llvm.org/viewvc/llvm-project?rev=282911&view=rev
Log:
[CUDA] Emit a warning if a CUDA host/device/global attribute is placed after 
'(...)'.

Summary:
This is probably the sane place for the attribute to go, but nvcc
specifically rejects it.  Other GNU-style attributes are allowed in this
position (although judging from the warning it emits for
host/device/global, those attributes are applied to the lambda's
anonymous struct, not to the function itself).

It would be nice to have a FixIt message here, but doing so, or even
just getting the correct range for the attribute, including its '((' and
'))'s, is apparently Hard.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/test/Parser/lambda-attr.cu

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=282911&r1=282910&r2=282911&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Sep 30 14:55:55 
2016
@@ -1022,6 +1022,10 @@ def err_pragma_invalid_keyword : Error<
 def warn_pragma_unroll_cuda_value_in_parens : Warning<
   "argument to '#pragma unroll' should not be in parentheses in CUDA C/C++">,
   InGroup;
+
+def warn_cuda_attr_lambda_position : Warning<
+  "nvcc does not allow '__%0__' to appear after '()' in lambdas">,
+  InGroup;
 } // end of Parse Issue category.
 
 let CategoryName = "Modules Issue" in {

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=282911&r1=282910&r2=282911&view=diff
==
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Fri Sep 30 14:55:55 2016
@@ -1134,6 +1134,18 @@ ExprResult Parser::ParseLambdaExpression
 MaybeParseGNUAttributes(D);
   }
 
+  // Helper to emit a warning if we see a CUDA host/device/global attribute
+  // after '(...)'. nvcc doesn't accept this.
+  auto WarnIfHasCUDATargetAttr = [&] {
+if (getLangOpts().CUDA)
+  for (auto *A = Attr.getList(); A != nullptr; A = A->getNext())
+if (A->getKind() == AttributeList::AT_CUDADevice ||
+A->getKind() == AttributeList::AT_CUDAHost ||
+A->getKind() == AttributeList::AT_CUDAGlobal)
+  Diag(A->getLoc(), diag::warn_cuda_attr_lambda_position)
+  << A->getName()->getName();
+  };
+
   TypeResult TrailingReturnType;
   if (Tok.is(tok::l_paren)) {
 ParseScope PrototypeScope(this,
@@ -1210,6 +1222,8 @@ ExprResult Parser::ParseLambdaExpression
 
 PrototypeScope.Exit();
 
+WarnIfHasCUDATargetAttr();
+
 SourceLocation NoLoc;
 D.AddTypeInfo(DeclaratorChunk::getFunction(/*hasProto=*/true,
/*isAmbiguous=*/false,
@@ -1275,6 +1289,8 @@ ExprResult Parser::ParseLambdaExpression
 DeclEndLoc = Range.getEnd();
 }
 
+WarnIfHasCUDATargetAttr();
+
 SourceLocation NoLoc;
 D.AddTypeInfo(DeclaratorChunk::getFunction(/*hasProto=*/true,
/*isAmbiguous=*/false,

Modified: cfe/trunk/test/Parser/lambda-attr.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/lambda-attr.cu?rev=282911&r1=282910&r2=282911&view=diff
==
--- cfe/trunk/test/Parser/lambda-attr.cu (original)
+++ cfe/trunk/test/Parser/lambda-attr.cu Fri Sep 30 14:55:55 2016
@@ -1,33 +1,42 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcuda-is-device -verify %s
 
-// expected-no-diagnostics
-
 __attribute__((device)) void device_fn() {}
 __attribute__((device)) void hd_fn() {}
 
 __attribute__((device)) void device_attr() {
   ([]() __attribute__((device)) { device_fn(); })();
+  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after 
'()' in lambdas}}
   ([] __attribute__((device)) () { device_fn(); })();
   ([] __attribute__((device)) { device_fn(); })();
 
   ([&]() __attribute__((device)){ device_fn(); })();
+  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after 
'()' in lambdas}}
   ([&] __attribute__((device)) () { device_fn(); })();
   ([&] __attribute__((device)) { device_fn(); })();
 
   ([&](int) __attribute__((device)){ device_fn(); })(0);
+  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after 
'()' in lambdas}}
   ([&] __attribute__((device)) (int) { device_fn(); })(0);
 }
 
 __attribute__((host)) __attribute__((

r282910 - [CUDA] Fix up MaybeParseGNUAttributes call used for out-of-place attributes on CUDA lambdas.

2016-09-30 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Fri Sep 30 14:55:48 2016
New Revision: 282910

URL: http://llvm.org/viewvc/llvm-project?rev=282910&view=rev
Log:
[CUDA] Fix up MaybeParseGNUAttributes call used for out-of-place attributes on 
CUDA lambdas.

Summary: There's an overload that we can use to make this a bit cleaner.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

Modified:
cfe/trunk/lib/Parse/ParseExprCXX.cpp

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=282910&r1=282909&r2=282910&view=diff
==
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Fri Sep 30 14:55:48 2016
@@ -1128,12 +1128,10 @@ ExprResult Parser::ParseLambdaExpression
 
   ParsedAttributes Attr(AttrFactory);
   SourceLocation DeclLoc = Tok.getLocation();
-  SourceLocation DeclEndLoc = DeclLoc;
   if (getLangOpts().CUDA) {
 // In CUDA code, GNU attributes are allowed to appear immediately after the
 // "[...]", even if there is no "(...)" before the lambda body.
-MaybeParseGNUAttributes(Attr, &DeclEndLoc);
-D.takeAttributes(Attr, DeclEndLoc);
+MaybeParseGNUAttributes(D);
   }
 
   TypeResult TrailingReturnType;
@@ -1161,7 +1159,7 @@ ExprResult Parser::ParseLambdaExpression
 }
 T.consumeClose();
 SourceLocation RParenLoc = T.getCloseLocation();
-DeclEndLoc = RParenLoc;
+SourceLocation DeclEndLoc = RParenLoc;
 
 // GNU-style attributes must be parsed before the mutable specifier to be
 // compatible with GCC.
@@ -1253,7 +1251,7 @@ ExprResult Parser::ParseLambdaExpression
 Diag(Tok, diag::err_lambda_missing_parens)
   << TokKind
   << FixItHint::CreateInsertion(Tok.getLocation(), "() ");
-DeclEndLoc = DeclLoc;
+SourceLocation DeclEndLoc = DeclLoc;
 
 // GNU-style attributes must be parsed before the mutable specifier to be
 // compatible with GCC.


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


r282912 - [CUDA] Remove incorrect comment in CUDASetLambdaAttrs.

2016-09-30 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Fri Sep 30 14:55:59 2016
New Revision: 282912

URL: http://llvm.org/viewvc/llvm-project?rev=282912&view=rev
Log:
[CUDA] Remove incorrect comment in CUDASetLambdaAttrs.

I'd said that nvcc doesn't allow you to add __host__ or __device__
attributes on lambdas in all circumstances, but I believe this was user
error on my part.  I can't reproduce these warnings/errors if I pass
--expt-extended-lambda to nvcc.

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

Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=282912&r1=282911&r2=282912&view=diff
==
--- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp Fri Sep 30 14:55:59 2016
@@ -573,8 +573,4 @@ void Sema::CUDASetLambdaAttrs(CXXMethodD
 Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
 Method->addAttr(CUDAHostAttr::CreateImplicit(Context));
   }
-
-  // TODO: nvcc doesn't allow you to specify __host__ or __device__ attributes
-  // on lambdas in all contexts -- we should emit a compatibility warning where
-  // we're more permissive.
 }


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


[PATCH] D25115: [CUDA] Emit a warning if a CUDA host/device/global attribute is placed after '(...)'.

2016-09-30 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282911: [CUDA] Emit a warning if a CUDA host/device/global 
attribute is placed after '(. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D25115?vs=73105&id=73123#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25115

Files:
  cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
  cfe/trunk/lib/Parse/ParseExprCXX.cpp
  cfe/trunk/test/Parser/lambda-attr.cu

Index: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
@@ -1022,6 +1022,10 @@
 def warn_pragma_unroll_cuda_value_in_parens : Warning<
   "argument to '#pragma unroll' should not be in parentheses in CUDA C/C++">,
   InGroup;
+
+def warn_cuda_attr_lambda_position : Warning<
+  "nvcc does not allow '__%0__' to appear after '()' in lambdas">,
+  InGroup;
 } // end of Parse Issue category.
 
 let CategoryName = "Modules Issue" in {
Index: cfe/trunk/test/Parser/lambda-attr.cu
===
--- cfe/trunk/test/Parser/lambda-attr.cu
+++ cfe/trunk/test/Parser/lambda-attr.cu
@@ -1,33 +1,42 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcuda-is-device -verify %s
 
-// expected-no-diagnostics
-
 __attribute__((device)) void device_fn() {}
 __attribute__((device)) void hd_fn() {}
 
 __attribute__((device)) void device_attr() {
   ([]() __attribute__((device)) { device_fn(); })();
+  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
   ([] __attribute__((device)) () { device_fn(); })();
   ([] __attribute__((device)) { device_fn(); })();
 
   ([&]() __attribute__((device)){ device_fn(); })();
+  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
   ([&] __attribute__((device)) () { device_fn(); })();
   ([&] __attribute__((device)) { device_fn(); })();
 
   ([&](int) __attribute__((device)){ device_fn(); })(0);
+  // expected-warning@-1 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
   ([&] __attribute__((device)) (int) { device_fn(); })(0);
 }
 
 __attribute__((host)) __attribute__((device)) void host_device_attrs() {
   ([]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
+  // expected-warning@-1 {{nvcc does not allow '__host__' to appear after '()' in lambdas}}
+  // expected-warning@-2 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
   ([] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
   ([] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
 
   ([&]() __attribute__((host)) __attribute__((device)){ hd_fn(); })();
+  // expected-warning@-1 {{nvcc does not allow '__host__' to appear after '()' in lambdas}}
+  // expected-warning@-2 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
   ([&] __attribute__((host)) __attribute__((device)) () { hd_fn(); })();
   ([&] __attribute__((host)) __attribute__((device)) { hd_fn(); })();
 
   ([&](int) __attribute__((host)) __attribute__((device)){ hd_fn(); })(0);
+  // expected-warning@-1 {{nvcc does not allow '__host__' to appear after '()' in lambdas}}
+  // expected-warning@-2 {{nvcc does not allow '__device__' to appear after '()' in lambdas}}
   ([&] __attribute__((host)) __attribute__((device)) (int) { hd_fn(); })(0);
 }
+
+// TODO: Add tests for __attribute__((global)) once we support global lambdas.
Index: cfe/trunk/lib/Parse/ParseExprCXX.cpp
===
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp
@@ -1134,6 +1134,18 @@
 MaybeParseGNUAttributes(D);
   }
 
+  // Helper to emit a warning if we see a CUDA host/device/global attribute
+  // after '(...)'. nvcc doesn't accept this.
+  auto WarnIfHasCUDATargetAttr = [&] {
+if (getLangOpts().CUDA)
+  for (auto *A = Attr.getList(); A != nullptr; A = A->getNext())
+if (A->getKind() == AttributeList::AT_CUDADevice ||
+A->getKind() == AttributeList::AT_CUDAHost ||
+A->getKind() == AttributeList::AT_CUDAGlobal)
+  Diag(A->getLoc(), diag::warn_cuda_attr_lambda_position)
+  << A->getName()->getName();
+  };
+
   TypeResult TrailingReturnType;
   if (Tok.is(tok::l_paren)) {
 ParseScope PrototypeScope(this,
@@ -1210,6 +1222,8 @@
 
 PrototypeScope.Exit();
 
+WarnIfHasCUDATargetAttr();
+
 SourceLocation NoLoc;
 D.AddTypeInfo(DeclaratorChunk::getFunction(/*hasProto=*/true,
/*isAmbiguous=*/false,
@@ -1275,6 +1289,8 @@
 DeclEndLoc = Range.getEnd();
 }
 
+WarnIfHasCUDATargetAttr();
+
 SourceLocation NoLoc;
 D.AddTypeInfo(DeclaratorChunk::ge

[PATCH] D25114: [CUDA] Fix up MaybeParseGNUAttributes call used for out-of-place attributes on CUDA lambdas.

2016-09-30 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282910: [CUDA] Fix up MaybeParseGNUAttributes call used for 
out-of-place attributes on… (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D25114?vs=73104&id=73122#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25114

Files:
  cfe/trunk/lib/Parse/ParseExprCXX.cpp


Index: cfe/trunk/lib/Parse/ParseExprCXX.cpp
===
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp
@@ -1128,12 +1128,10 @@
 
   ParsedAttributes Attr(AttrFactory);
   SourceLocation DeclLoc = Tok.getLocation();
-  SourceLocation DeclEndLoc = DeclLoc;
   if (getLangOpts().CUDA) {
 // In CUDA code, GNU attributes are allowed to appear immediately after the
 // "[...]", even if there is no "(...)" before the lambda body.
-MaybeParseGNUAttributes(Attr, &DeclEndLoc);
-D.takeAttributes(Attr, DeclEndLoc);
+MaybeParseGNUAttributes(D);
   }
 
   TypeResult TrailingReturnType;
@@ -1161,7 +1159,7 @@
 }
 T.consumeClose();
 SourceLocation RParenLoc = T.getCloseLocation();
-DeclEndLoc = RParenLoc;
+SourceLocation DeclEndLoc = RParenLoc;
 
 // GNU-style attributes must be parsed before the mutable specifier to be
 // compatible with GCC.
@@ -1253,7 +1251,7 @@
 Diag(Tok, diag::err_lambda_missing_parens)
   << TokKind
   << FixItHint::CreateInsertion(Tok.getLocation(), "() ");
-DeclEndLoc = DeclLoc;
+SourceLocation DeclEndLoc = DeclLoc;
 
 // GNU-style attributes must be parsed before the mutable specifier to be
 // compatible with GCC.


Index: cfe/trunk/lib/Parse/ParseExprCXX.cpp
===
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp
@@ -1128,12 +1128,10 @@
 
   ParsedAttributes Attr(AttrFactory);
   SourceLocation DeclLoc = Tok.getLocation();
-  SourceLocation DeclEndLoc = DeclLoc;
   if (getLangOpts().CUDA) {
 // In CUDA code, GNU attributes are allowed to appear immediately after the
 // "[...]", even if there is no "(...)" before the lambda body.
-MaybeParseGNUAttributes(Attr, &DeclEndLoc);
-D.takeAttributes(Attr, DeclEndLoc);
+MaybeParseGNUAttributes(D);
   }
 
   TypeResult TrailingReturnType;
@@ -1161,7 +1159,7 @@
 }
 T.consumeClose();
 SourceLocation RParenLoc = T.getCloseLocation();
-DeclEndLoc = RParenLoc;
+SourceLocation DeclEndLoc = RParenLoc;
 
 // GNU-style attributes must be parsed before the mutable specifier to be
 // compatible with GCC.
@@ -1253,7 +1251,7 @@
 Diag(Tok, diag::err_lambda_missing_parens)
   << TokKind
   << FixItHint::CreateInsertion(Tok.getLocation(), "() ");
-DeclEndLoc = DeclLoc;
+SourceLocation DeclEndLoc = DeclLoc;
 
 // GNU-style attributes must be parsed before the mutable specifier to be
 // compatible with GCC.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25123: [OpenCL] Fix bug in __builtin_astype causing invalid LLVM cast instructions

2016-09-30 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: Anastasia.
yaxunl added subscribers: cfe-commits, b-sumner, bader.

__builtin_astype is used to cast OpenCL opaque types to other types, as such, 
it needs to be able to handle casting from and to pointer types correctly.

Current it cannot handle 1) casting between pointers of different addr spaces 
2) casting between pointer type and non-pointer types.

This patch fixes that.


https://reviews.llvm.org/D25123

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGenOpenCL/as_type.cl

Index: test/CodeGenOpenCL/as_type.cl
===
--- test/CodeGenOpenCL/as_type.cl
+++ test/CodeGenOpenCL/as_type.cl
@@ -66,3 +66,42 @@
 int3 f8(char16 x) {
   return __builtin_astype(x, int3);
 }
+
+//CHECK: define spir_func i32 addrspace(1)* @addr_cast(i32* readnone %[[x:.*]])
+//CHECK: %[[cast:.*]] = addrspacecast i32* %[[x]] to i32 addrspace(1)*
+//CHECK: ret i32 addrspace(1)* %[[cast]]
+global int* addr_cast(int *x) {
+  return __builtin_astype(x, global int*);
+}
+
+//CHECK: define spir_func i32 addrspace(1)* @int_to_ptr(i32 %[[x:.*]])
+//CHECK: %[[cast:.*]] = inttoptr i32 %[[x]] to i32 addrspace(1)*
+//CHECK: ret i32 addrspace(1)* %[[cast]]
+global int* int_to_ptr(int x) {
+  return __builtin_astype(x, global int*);
+}
+
+//CHECK: define spir_func i32 @ptr_to_int(i32* %[[x:.*]])
+//CHECK: %[[cast:.*]] = ptrtoint i32* %[[x]] to i32
+//CHECK: ret i32 %[[cast]]
+int ptr_to_int(int *x) {
+  return __builtin_astype(x, int);
+}
+
+//CHECK: define spir_func <3 x i8> @ptr_to_char3(i32* %[[x:.*]])
+//CHECK: %[[cast1:.*]] = ptrtoint i32* %[[x]] to i32
+//CHECK: %[[cast2:.*]] = bitcast i32 %[[cast1]] to <4 x i8>
+//CHECK: %[[astype:.*]] = shufflevector <4 x i8> %[[cast2]], <4 x i8> undef, <3 x i32> 
+//CHECK: ret <3 x i8> %[[astype]]
+char3 ptr_to_char3(int *x) {
+  return  __builtin_astype(x, char3);
+}
+
+//CHECK: define spir_func i32* @char3_to_ptr(<3 x i8> %[[x:.*]])
+//CHECK: %[[astype:.*]] = shufflevector <3 x i8> %[[x]], <3 x i8> undef, <4 x i32> 
+//CHECK: %[[cast1:.*]] = bitcast <4 x i8> %[[astype]] to i32
+//CHECK: %[[cast2:.*]] = inttoptr i32 %[[cast1]] to i32*
+//CHECK: ret i32* %[[cast2]]
+int* char3_to_ptr(char3 x) {
+  return __builtin_astype(x, int*);
+}
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -3407,6 +3407,52 @@
   return Builder.CreateShuffleVector(Src, UnV, Mask);
 }
 
+// Create cast instructions for converting LLVM value \p Src to LLVM type \p
+// DstTy. \p Src has the same size as \p DstTy. Both are single value types
+// but could be scalar or vectors of different lengths, and either can be
+// pointer.
+// There are 4 cases:
+// 1. non-pointer -> non-pointer  : needs 1 bitcast
+// 2. pointer -> pointer  : needs 1 bitcast or addrspacecast
+// 3. pointer -> non-pointer
+//   a) pointer -> intptr_t   : needs 1 ptrtoint
+//   b) pointer -> non-intptr_t   : needs 1 ptrtoint then 1 bitcast
+// 4. non-pointer -> pointer
+//   a) intptr_t -> pointer   : needs 1 inttoptr
+//   b) non-intptr_t -> pointer   : needs 1 bitcast then 1 inttoptr
+// Note: for cases 3b and 4b two casts are required since LLVM casts do not
+// allow casting directly between pointer types and non-integer non-pointer
+// types.
+static Value *createCastsForTypeOfSameSize(CGBuilderTy &Builder,
+   const llvm::DataLayout &DL,
+   Value *Src, llvm::Type *DstTy,
+   StringRef Name = "") {
+  auto SrcTy = Src->getType();
+
+  // Case 1.
+  if (!SrcTy->isPointerTy() && !DstTy->isPointerTy())
+return Builder.CreateBitCast(Src, DstTy, Name);
+
+  // Case 2.
+  if (SrcTy->isPointerTy() && DstTy->isPointerTy())
+return Builder.CreatePointerBitCastOrAddrSpaceCast(Src, DstTy, Name);
+
+  // Case 3.
+  if (SrcTy->isPointerTy() && !DstTy->isPointerTy()) {
+// Case 3b.
+if (!DstTy->isIntegerTy())
+  Src = Builder.CreatePtrToInt(Src, DL.getIntPtrType(SrcTy));
+// Cases 3a and 3b.
+return Builder.CreateBitOrPointerCast(Src, DstTy, Name);
+  }
+
+  // Case 4b.
+  if (!SrcTy->isIntegerTy())
+Src = Builder.CreateBitCast(Src, DL.getIntPtrType(DstTy));
+  // Cases 4a and 4b.
+  return Builder.CreateIntToPtr(Src, DstTy, Name);
+}
+
 Value *ScalarExprEmitter::VisitAsTypeExpr(AsTypeExpr *E) {
   Value *Src  = CGF.EmitScalarExpr(E->getSrcExpr());
   llvm::Type *DstTy = ConvertType(E->getType());
@@ -3421,7 +3467,8 @@
   // vector to get a vec4, then a bitcast if the target type is different.
   if (NumElementsSrc == 3 && NumElementsDst != 3) {
 Src = ConvertVec3AndVec4(Builder, CGF, Src, 4);
-Src = Builder.CreateBitCast(Src, DstTy);
+Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
+   DstTy);
 

r282927 - [CUDA] Fix implicit-device-lambda.cu after r282911.

2016-09-30 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Fri Sep 30 15:17:37 2016
New Revision: 282927

URL: http://llvm.org/viewvc/llvm-project?rev=282927&view=rev
Log:
[CUDA] Fix implicit-device-lambda.cu after r282911.

This commit added a warning that we're (correctly) hitting in this test.
Just ignore it.

Modified:
cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu

Modified: cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu?rev=282927&r1=282926&r2=282927&view=diff
==
--- cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu (original)
+++ cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu Fri Sep 30 15:17:37 2016
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -verify -fsyntax-only 
-verify-ignore-unexpected=note %s
-// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only 
-verify-ignore-unexpected=note %s
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -verify -fsyntax-only 
-verify-ignore-unexpected=warning -verify-ignore-unexpected=note %s
+// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only 
-verify-ignore-unexpected=warning -verify-ignore-unexpected=note %s
 
 #include "Inputs/cuda.h"
 


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


[PATCH] D25117: Add driver support for Fuchsia

2016-09-30 Thread Petr Hosek via cfe-commits
phosek created this revision.
phosek added a subscriber: cfe-commits.

Provide toolchain and tool support for Fuchsia operating system. Fuchsia uses 
compiler-rt as the runtime library and libc++, libc++abi and libunwind as the 
C++ standard library. lld is used as a default linker.


https://reviews.llvm.org/D25117

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  test/Driver/fuchsia.c
  test/Driver/fuchsia.cpp

Index: test/Driver/fuchsia.cpp
===
--- /dev/null
+++ test/Driver/fuchsia.cpp
@@ -0,0 +1,33 @@
+// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia \
+// RUN: --sysroot=%S/platform 2>&1 | FileCheck %s
+// CHECK: {{.*}}clang{{.*}}" "-cc1"
+// CHECK: "-fuse-init-array"
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK: "-internal-isystem" "[[SYSROOT]]{{/|}}include{{/|}}c++{{/|}}v1"
+// CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
+// CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "--sysroot=[[SYSROOT]]"
+// CHECK: "-pie"
+// CHECK: "--build-id"
+// CHECK: "-dynamic-linker" "ld.so.1"
+// CHECK: Scrt1.o
+// CHECK-NOT: crti.o
+// CHECK-NOT: crtbegin.o
+// CHECK: "-L[[SYSROOT]]/lib"
+// CHECK: "-lc++" "-lc++abi" "-lunwind" "-lm"
+// CHECK: "{{.*[/\\]}}libclang_rt.builtins-x86_64.a"
+// CHECK: "-Bdynamic" "-lc"
+// CHECK-NOT: crtend.o
+// CHECK-NOT: crtn.o
+
+// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -stdlib=libstdc++ 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-STDLIB
+// CHECK-STDLIB: error: invalid library name in argument '-stdlib=libstdc++'
+
+// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-STATIC
+// CHECK-STATIC: "-Bstatic"
+// CHECK-STATIC: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-STATIC: "-Bdynamic"
+// CHECK-STATIC: "-lm"
+// CHECK-STATIC: "-Bdynamic" "-lc"
Index: test/Driver/fuchsia.c
===
--- /dev/null
+++ test/Driver/fuchsia.c
@@ -0,0 +1,39 @@
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
+// RUN: --sysroot=%S/platform 2>&1 | FileCheck %s
+// CHECK: {{.*}}clang{{.*}}" "-cc1"
+// CHECK: "-fuse-init-array"
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
+// CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "--sysroot=[[SYSROOT]]"
+// CHECK: "-pie"
+// CHECK: "--build-id"
+// CHECK: "-dynamic-linker" "ld.so.1"
+// CHECK: Scrt1.o
+// CHECK-NOT: crti.o
+// CHECK-NOT: crtbegin.o
+// CHECK: "-L[[SYSROOT]]/lib"
+// CHECK: "{{.*[/\\]}}libclang_rt.builtins-x86_64.a"
+// CHECK: "-Bdynamic" "-lc"
+// CHECK-NOT: crtend.o
+// CHECK-NOT: crtn.o
+
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia -rtlib=libgcc 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-RTLIB
+// CHECK-RTLIB: error: invalid runtime library name in argument '-rtlib=libgcc'
+
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia -static 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-STATIC
+// CHECK-STATIC: "-Bstatic"
+// CHECK-STATIC: "-Bdynamic" "-lc"
+
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia -shared 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SHARED
+// CHECK-SHARED-NOT: "-pie"
+// CHECK-SHARED: "-shared"
+
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia -r 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-RELOCATABLE
+// CHECK-RELOCATABLE-NOT: "-pie"
+// CHECK-RELOCATABLE-NOT: "--build-id"
+// CHECK-RELOCATABLE: "-r"
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -596,6 +596,21 @@
 };
 } // end namespace nacltools
 
+namespace fuchsia {
+class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
+public:
+  Linker(const ToolChain &TC) : GnuTool("fuchsia::Linker", "ld.lld", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
+} // end namespace fuchsia
+
 /// minix -- Directly call GNU Binutils assembler and linker
 namespace minix {
 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9476,6 +9476,7 @@
   llvm_unreachable("unsupported OS");
 case llvm::Triple::Win32:
 case llvm::Triple::Linux:
+case llvm::Triple::Fuchsia:
   addClangRT(TC, Args, CmdArgs);
   break;
 }
@@ -9962,6 +9963,124 @@
   C.addCommand(llvm::make_u

[PATCH] D25117: Add driver support for Fuchsia

2016-09-30 Thread Petr Hosek via cfe-commits
phosek added a comment.

The patch with LLVM triple for Fuchsia is here: https://reviews.llvm.org/D25116


https://reviews.llvm.org/D25117



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


[PATCH] D24644: Pass -ffunction-sections/-fdata-sections along to gold-plugin

2016-09-30 Thread Peter Collingbourne via cfe-commits
pcc added a comment.

Perhaps it would be better to enable -ffunction-sections/-fdata-sections 
unconditionally at the linker level if the linker supports it? See also PR22999.


https://reviews.llvm.org/D24644



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


  1   2   >