Re: [PATCH] D20561: Warn when taking address of packed member

2016-07-15 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 reopened this revision.
rogfer01 added a comment.
This revision is now accepted and ready to land.

I suggest that we handle the reference binding diagnostic in another change and 
leave this one only for the address taking diagnostic.


Repository:
  rL LLVM

https://reviews.llvm.org/D20561



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-07-15 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

In https://reviews.llvm.org/D20561#484421, @jyknight wrote:

> This seems to trigger even for the implicitly generated copier of a packed 
> struct. E.g.
>
>   #include 
>  
>   void copyit(epoll_event&out, const epoll_event &in) {
> out = in;
>   }
>  
>
>
> Is that as intended?


No, it wasn't. It seems to happen as well for the implicit copy constructor as 
well.

  #include 
  
  void copyit2(epoll_event foo);
  void copyit(epoll_event &out) { copyit2(out); }

  clang++ -c test.cc
  In file included from test.cc:1:
  /usr/include/x86_64-linux-gnu/sys/epoll.h:87:8: error: binding reference to 
packed member 'data' of class or structure 'epoll_event'
  struct epoll_event
 ^~~
  test.cc:4:41: note: implicit copy constructor for 'epoll_event' first 
required here
  void copyit(epoll_event &out) { copyit2(out); }
  ^
  1 error generated.


Repository:
  rL LLVM

https://reviews.llvm.org/D20561



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


Re: [PATCH] D22351: [include-fixer] Move cursor to #include line in vim after inserting a missing header.

2016-07-15 Thread Daniel Jasper via cfe-commits
djasper added a comment.

FWIW, I think I'd like this behavior as it shows me what is actually being 
done. I can undo/redo to double-check or C-O to get back to where I was. Of 
course making it configurable seems like the right thing to do.



Comment at: include-fixer/tool/clang-include-fixer.py:102
@@ +101,3 @@
+  # Set cursor to the #include line.
+  include_header = "#include " + header["HeaderInfos"][0]["Header"]
+  line_num = lines.index(include_header) + 1

Seems seems very hacky. Can't you extract it out of the diff sequence above?


https://reviews.llvm.org/D22351



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


Re: [PATCH] D22367: [include-fixer] Always add as few as possible qualifiers to the unidentified symbol.

2016-07-15 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 64104.
hokein marked an inline comment as done.
hokein added a comment.

Add comment.


https://reviews.llvm.org/D22367

Files:
  include-fixer/IncludeFixerContext.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -245,6 +245,14 @@
   EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar b;\n}\n",
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
+  // Test common qualifers reduction.
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace a {\nnamespace d {\nb::bar b;\n}\n}\n",
+  runIncludeFixer("namespace a {\nnamespace d {\nbar b;\n}\n}\n"));
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace d {\nnamespace a {\na::b::bar b;\n}\n}\n",
+  runIncludeFixer("namespace d {\nnamespace a {\nbar b;\n}\n}\n"));
+
   // Test nested classes.
   EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
 runIncludeFixer("namespace d {\nbar::t b;\n}\n"));
Index: include-fixer/IncludeFixerContext.cpp
===
--- include-fixer/IncludeFixerContext.cpp
+++ include-fixer/IncludeFixerContext.cpp
@@ -15,9 +15,17 @@
 
 namespace {
 
+// Splits a multiply qualified names (e.g. a::b::c).
+llvm::SmallVector
+SplitQualifiers(llvm::StringRef StringQualifiers) {
+  llvm::SmallVector Qualifiers;
+  StringQualifiers.split(Qualifiers, "::");
+  return Qualifiers;
+}
+
 std::string createQualifiedNameForReplacement(
 llvm::StringRef RawSymbolName,
-llvm::StringRef SymbolScopedQualifiers,
+llvm::StringRef SymbolScopedQualifiersName,
 const find_all_symbols::SymbolInfo &MatchedSymbol) {
   // No need to add missing qualifiers if SymbolIndentifer has a global scope
   // operator "::".
@@ -32,8 +40,7 @@
   // missing stripped qualifiers here.
   //
   // Get stripped qualifiers.
-  llvm::SmallVector SymbolQualifiers;
-  RawSymbolName.split(SymbolQualifiers, "::");
+  auto SymbolQualifiers = SplitQualifiers(RawSymbolName);
   std::string StrippedQualifiers;
   while (!SymbolQualifiers.empty() &&
  !llvm::StringRef(QualifiedName).endswith(SymbolQualifiers.back())) {
@@ -43,11 +50,26 @@
   // Append the missing stripped qualifiers.
   std::string FullyQualifiedName = QualifiedName + StrippedQualifiers;
 
-  // Skips symbol scoped qualifiers prefix.
-  if (llvm::StringRef(FullyQualifiedName).startswith(SymbolScopedQualifiers))
-return FullyQualifiedName.substr(SymbolScopedQualifiers.size());
-
-  return FullyQualifiedName;
+  // Try to find and skip the common prefix qualifiers.
+  auto FullySymbolQualifiers = SplitQualifiers(FullyQualifiedName);
+  auto ScopedQualifiers = SplitQualifiers(SymbolScopedQualifiersName);
+  auto FullySymbolQualifiersIter = FullySymbolQualifiers.begin();
+  auto SymbolScopedQualifiersIter = ScopedQualifiers.begin();
+  while (FullySymbolQualifiersIter != FullySymbolQualifiers.end() &&
+ SymbolScopedQualifiersIter != ScopedQualifiers.end()) {
+if (*FullySymbolQualifiersIter != *SymbolScopedQualifiersIter)
+  break;
+++FullySymbolQualifiersIter;
+++SymbolScopedQualifiersIter;
+  }
+  std::string Result;
+  for (; FullySymbolQualifiersIter != FullySymbolQualifiers.end();
+   ++FullySymbolQualifiersIter) {
+if (!Result.empty())
+  Result += "::";
+Result += *FullySymbolQualifiersIter;
+  }
+  return Result;
 }
 
 } // anonymous namespace


Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -245,6 +245,14 @@
   EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar b;\n}\n",
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
+  // Test common qualifers reduction.
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace a {\nnamespace d {\nb::bar b;\n}\n}\n",
+  runIncludeFixer("namespace a {\nnamespace d {\nbar b;\n}\n}\n"));
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace d {\nnamespace a {\na::b::bar b;\n}\n}\n",
+  runIncludeFixer("namespace d {\nnamespace a {\nbar b;\n}\n}\n"));
+
   // Test nested classes.
   EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
 runIncludeFixer("namespace d {\nbar::t b;\n}\n"));
Index: include-fixer/IncludeFixerContext.cpp
===
--- include-fixer/IncludeFixerContext.cpp
+++ include-fixer/IncludeFixerContext.cpp
@@ -15,9 +15,17 @@
 
 namespace {
 
+// Splits a multiply qualified names (e.g. a::b::c).
+llvm::SmallVector
+SplitQualifiers(llvm::StringRef StringQualifiers) {
+  llvm::SmallVector Qualifiers;
+  StringQualifiers.split(Qualifiers, "::");
+  return Qualifiers;
+}
+
 std::

[clang-tools-extra] r275542 - [include-fixer] Always add as few as possible qualifiers to the unidentified symbol.

2016-07-15 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Jul 15 03:12:48 2016
New Revision: 275542

URL: http://llvm.org/viewvc/llvm-project?rev=275542&view=rev
Log:
[include-fixer] Always add as few as possible qualifiers to the unidentified 
symbol.

Reviewers: bkramer

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp?rev=275542&r1=275541&r2=275542&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp Fri Jul 15 
03:12:48 2016
@@ -15,9 +15,17 @@ namespace include_fixer {
 
 namespace {
 
+// Splits a multiply qualified names (e.g. a::b::c).
+llvm::SmallVector
+SplitQualifiers(llvm::StringRef StringQualifiers) {
+  llvm::SmallVector Qualifiers;
+  StringQualifiers.split(Qualifiers, "::");
+  return Qualifiers;
+}
+
 std::string createQualifiedNameForReplacement(
 llvm::StringRef RawSymbolName,
-llvm::StringRef SymbolScopedQualifiers,
+llvm::StringRef SymbolScopedQualifiersName,
 const find_all_symbols::SymbolInfo &MatchedSymbol) {
   // No need to add missing qualifiers if SymbolIndentifer has a global scope
   // operator "::".
@@ -32,8 +40,7 @@ std::string createQualifiedNameForReplac
   // missing stripped qualifiers here.
   //
   // Get stripped qualifiers.
-  llvm::SmallVector SymbolQualifiers;
-  RawSymbolName.split(SymbolQualifiers, "::");
+  auto SymbolQualifiers = SplitQualifiers(RawSymbolName);
   std::string StrippedQualifiers;
   while (!SymbolQualifiers.empty() &&
  !llvm::StringRef(QualifiedName).endswith(SymbolQualifiers.back())) {
@@ -43,11 +50,26 @@ std::string createQualifiedNameForReplac
   // Append the missing stripped qualifiers.
   std::string FullyQualifiedName = QualifiedName + StrippedQualifiers;
 
-  // Skips symbol scoped qualifiers prefix.
-  if (llvm::StringRef(FullyQualifiedName).startswith(SymbolScopedQualifiers))
-return FullyQualifiedName.substr(SymbolScopedQualifiers.size());
-
-  return FullyQualifiedName;
+  // Try to find and skip the common prefix qualifiers.
+  auto FullySymbolQualifiers = SplitQualifiers(FullyQualifiedName);
+  auto ScopedQualifiers = SplitQualifiers(SymbolScopedQualifiersName);
+  auto FullySymbolQualifiersIter = FullySymbolQualifiers.begin();
+  auto SymbolScopedQualifiersIter = ScopedQualifiers.begin();
+  while (FullySymbolQualifiersIter != FullySymbolQualifiers.end() &&
+ SymbolScopedQualifiersIter != ScopedQualifiers.end()) {
+if (*FullySymbolQualifiersIter != *SymbolScopedQualifiersIter)
+  break;
+++FullySymbolQualifiersIter;
+++SymbolScopedQualifiersIter;
+  }
+  std::string Result;
+  for (; FullySymbolQualifiersIter != FullySymbolQualifiers.end();
+   ++FullySymbolQualifiersIter) {
+if (!Result.empty())
+  Result += "::";
+Result += *FullySymbolQualifiersIter;
+  }
+  return Result;
 }
 
 } // anonymous namespace

Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp?rev=275542&r1=275541&r2=275542&view=diff
==
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Fri 
Jul 15 03:12:48 2016
@@ -245,6 +245,14 @@ TEST(IncludeFixer, FixNamespaceQualifier
   EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar b;\n}\n",
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
+  // Test common qualifers reduction.
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace a {\nnamespace d {\nb::bar b;\n}\n}\n",
+  runIncludeFixer("namespace a {\nnamespace d {\nbar b;\n}\n}\n"));
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace d {\nnamespace a {\na::b::bar b;\n}\n}\n",
+  runIncludeFixer("namespace d {\nnamespace a {\nbar b;\n}\n}\n"));
+
   // Test nested classes.
   EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
 runIncludeFixer("namespace d {\nbar::t b;\n}\n"));


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


Re: [PATCH] D22367: [include-fixer] Always add as few as possible qualifiers to the unidentified symbol.

2016-07-15 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275542: [include-fixer] Always add as few as possible 
qualifiers to the unidentified… (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D22367?vs=64104&id=64107#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22367

Files:
  clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
  clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

Index: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
===
--- clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
+++ clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
@@ -15,9 +15,17 @@
 
 namespace {
 
+// Splits a multiply qualified names (e.g. a::b::c).
+llvm::SmallVector
+SplitQualifiers(llvm::StringRef StringQualifiers) {
+  llvm::SmallVector Qualifiers;
+  StringQualifiers.split(Qualifiers, "::");
+  return Qualifiers;
+}
+
 std::string createQualifiedNameForReplacement(
 llvm::StringRef RawSymbolName,
-llvm::StringRef SymbolScopedQualifiers,
+llvm::StringRef SymbolScopedQualifiersName,
 const find_all_symbols::SymbolInfo &MatchedSymbol) {
   // No need to add missing qualifiers if SymbolIndentifer has a global scope
   // operator "::".
@@ -32,8 +40,7 @@
   // missing stripped qualifiers here.
   //
   // Get stripped qualifiers.
-  llvm::SmallVector SymbolQualifiers;
-  RawSymbolName.split(SymbolQualifiers, "::");
+  auto SymbolQualifiers = SplitQualifiers(RawSymbolName);
   std::string StrippedQualifiers;
   while (!SymbolQualifiers.empty() &&
  !llvm::StringRef(QualifiedName).endswith(SymbolQualifiers.back())) {
@@ -43,11 +50,26 @@
   // Append the missing stripped qualifiers.
   std::string FullyQualifiedName = QualifiedName + StrippedQualifiers;
 
-  // Skips symbol scoped qualifiers prefix.
-  if (llvm::StringRef(FullyQualifiedName).startswith(SymbolScopedQualifiers))
-return FullyQualifiedName.substr(SymbolScopedQualifiers.size());
-
-  return FullyQualifiedName;
+  // Try to find and skip the common prefix qualifiers.
+  auto FullySymbolQualifiers = SplitQualifiers(FullyQualifiedName);
+  auto ScopedQualifiers = SplitQualifiers(SymbolScopedQualifiersName);
+  auto FullySymbolQualifiersIter = FullySymbolQualifiers.begin();
+  auto SymbolScopedQualifiersIter = ScopedQualifiers.begin();
+  while (FullySymbolQualifiersIter != FullySymbolQualifiers.end() &&
+ SymbolScopedQualifiersIter != ScopedQualifiers.end()) {
+if (*FullySymbolQualifiersIter != *SymbolScopedQualifiersIter)
+  break;
+++FullySymbolQualifiersIter;
+++SymbolScopedQualifiersIter;
+  }
+  std::string Result;
+  for (; FullySymbolQualifiersIter != FullySymbolQualifiers.end();
+   ++FullySymbolQualifiersIter) {
+if (!Result.empty())
+  Result += "::";
+Result += *FullySymbolQualifiersIter;
+  }
+  return Result;
 }
 
 } // anonymous namespace
Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
@@ -245,6 +245,14 @@
   EXPECT_EQ("#include \"bar2.h\"\nnamespace c {\na::c::bar b;\n}\n",
 runIncludeFixer("namespace c {\nbar b;\n}\n"));
 
+  // Test common qualifers reduction.
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace a {\nnamespace d {\nb::bar b;\n}\n}\n",
+  runIncludeFixer("namespace a {\nnamespace d {\nbar b;\n}\n}\n"));
+  EXPECT_EQ(
+  "#include \"bar.h\"\nnamespace d {\nnamespace a {\na::b::bar b;\n}\n}\n",
+  runIncludeFixer("namespace d {\nnamespace a {\nbar b;\n}\n}\n"));
+
   // Test nested classes.
   EXPECT_EQ("#include \"bar.h\"\nnamespace d {\na::b::bar::t b;\n}\n",
 runIncludeFixer("namespace d {\nbar::t b;\n}\n"));


Index: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
===
--- clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
+++ clang-tools-extra/trunk/include-fixer/IncludeFixerContext.cpp
@@ -15,9 +15,17 @@
 
 namespace {
 
+// Splits a multiply qualified names (e.g. a::b::c).
+llvm::SmallVector
+SplitQualifiers(llvm::StringRef StringQualifiers) {
+  llvm::SmallVector Qualifiers;
+  StringQualifiers.split(Qualifiers, "::");
+  return Qualifiers;
+}
+
 std::string createQualifiedNameForReplacement(
 llvm::StringRef RawSymbolName,
-llvm::StringRef SymbolScopedQualifiers,
+llvm::StringRef SymbolScopedQualifiersName,
 const find_all_symbols::SymbolInfo &MatchedSymbol) {
   // No need to add missing qualifiers if SymbolIndentifer has a global scope
   // operator "::".
@@ -32,8 +40,7 @@
   // missing stripped qualifiers here.
   //
   // Get stripped qualifiers.
-  llvm::SmallVector SymbolQualifiers

Re: [PATCH] D22351: [include-fixer] Move cursor to #include line in vim after inserting a missing header.

2016-07-15 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 64110.
hokein added a comment.

Avoid a hacky way to get #include line number.


https://reviews.llvm.org/D22351

Files:
  include-fixer/tool/clang-include-fixer.py

Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -40,6 +40,10 @@
   1,
   vim.eval('g:clang_include_fixer_increment_num'))
 
+jump_to_include = False
+if vim.eval('exists("g:clang_include_fixer_jump_to_include")') == "1":
+  jump_to_include = vim.eval('g:clang_include_fixer_jump_to_include') != "0"
+
 
 def GetUserSelection(message, headers, maximum_suggested_headers):
   eval_message = message + '\n'
@@ -84,12 +88,21 @@
   command = [binary, "-stdin", "-insert-header=" + json.dumps(header),
  vim.current.buffer.name]
   stdout, stderr = execute(command, text)
+  if stderr:
+raise Exception(stderr)
   if stdout:
 lines = stdout.splitlines()
 sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
+line_num = None
 for op in reversed(sequence.get_opcodes()):
-  if op[0] is not 'equal':
+  if op[0] != 'equal':
 vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
+  if op[0] == 'insert':
+# line_num in vim is 1-based.
+line_num = op[1] + 1
+
+if jump_to_include and line_num:
+  vim.current.window.cursor = (line_num, 0)
 
 
 def main():
@@ -128,22 +141,22 @@
   unique_headers.append(header)
 
   if not symbol:
-print "The file is fine, no need to add a header.\n"
+print "The file is fine, no need to add a header."
 return
 
   if not unique_headers:
-print "Couldn't find a header for {0}.\n".format(symbol)
-return
-
-  # If there is only one suggested header, insert it directly.
-  if len(unique_headers) == 1 or maximum_suggested_headers == 1:
-InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
- "Range": include_fixer_context["Range"],
- "HeaderInfos": header_infos}, text)
-print "Added #include {0} for {1}.\n".format(unique_headers[0], symbol)
+print "Couldn't find a header for {0}.".format(symbol)
 return
 
   try:
+# If there is only one suggested header, insert it directly.
+if len(unique_headers) == 1 or maximum_suggested_headers == 1:
+  InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+   "Range": include_fixer_context["Range"],
+   "HeaderInfos": header_infos}, text)
+  print "Added #include {0} for {1}.".format(unique_headers[0], symbol)
+  return
+
 selected = GetUserSelection("choose a header file for {0}.".format(symbol),
 unique_headers, maximum_suggested_headers)
 selected_header_infos = [
@@ -153,7 +166,7 @@
 InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
  "Range": include_fixer_context["Range"],
  "HeaderInfos": selected_header_infos}, text)
-print "Added #include {0} for {1}.\n".format(selected, symbol)
+print "Added #include {0} for {1}.".format(selected, symbol)
   except Exception as error:
 print >> sys.stderr, error.message
   return


Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -40,6 +40,10 @@
   1,
   vim.eval('g:clang_include_fixer_increment_num'))
 
+jump_to_include = False
+if vim.eval('exists("g:clang_include_fixer_jump_to_include")') == "1":
+  jump_to_include = vim.eval('g:clang_include_fixer_jump_to_include') != "0"
+
 
 def GetUserSelection(message, headers, maximum_suggested_headers):
   eval_message = message + '\n'
@@ -84,12 +88,21 @@
   command = [binary, "-stdin", "-insert-header=" + json.dumps(header),
  vim.current.buffer.name]
   stdout, stderr = execute(command, text)
+  if stderr:
+raise Exception(stderr)
   if stdout:
 lines = stdout.splitlines()
 sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
+line_num = None
 for op in reversed(sequence.get_opcodes()):
-  if op[0] is not 'equal':
+  if op[0] != 'equal':
 vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
+  if op[0] == 'insert':
+# line_num in vim is 1-based.
+line_num = op[1] + 1
+
+if jump_to_include and line_num:
+  vim.current.window.cursor = (line_num, 0)
 
 
 def main():
@@ -128,22 +141,22 @@
   unique_headers.append(header)
 
   if not symbol:
-print "The file is fine, no need to add a header.\n"
+print "The file is fine, no need to add a header."
 return
 
   if not unique_headers:
-print "Couldn't find a header for {0}.\n".format(symbol)
-return
-
-  # If there is onl

Re: [PATCH] D22351: [include-fixer] Move cursor to #include line in vim after inserting a missing header.

2016-07-15 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.
hokein added a comment.

https://reviews.llvm.org/D22351



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-07-15 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

I've opened https://llvm.org/bugs/show_bug.cgi?id=28571 to track the reference 
binding issue.


Repository:
  rL LLVM

https://reviews.llvm.org/D20561



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


Re: [PATCH] D20561: Warn when taking address of packed member

2016-07-15 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated the summary for this revision.
rogfer01 removed rL LLVM as the repository for this revision.
rogfer01 updated this revision to Diff 64114.
rogfer01 added a comment.

Remove the diagnostic for the binding of references.


https://reviews.llvm.org/D20561

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  test/Sema/address-packed-member-memops.c
  test/Sema/address-packed.c
  test/SemaCXX/address-packed-member-memops.cpp
  test/SemaCXX/address-packed.cpp

Index: test/SemaCXX/address-packed.cpp
===
--- /dev/null
+++ test/SemaCXX/address-packed.cpp
@@ -0,0 +1,114 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+extern void f1(int *);
+extern void f2(char *);
+
+struct __attribute__((packed)) Arguable {
+  int x;
+  char c;
+  static void foo();
+};
+
+extern void f3(void());
+
+namespace Foo {
+struct __attribute__((packed)) Arguable {
+  char c;
+  int x;
+  static void foo();
+};
+}
+
+struct Arguable *get_arguable();
+
+void f4(int &);
+
+void to_void(void *);
+
+template 
+void sink(T...);
+
+void g0() {
+  {
+Foo::Arguable arguable;
+f1(&arguable.x);   // expected-warning {{packed member 'x' of class or structure 'Foo::Arguable'}}
+f2(&arguable.c);   // no-warning
+f3(&arguable.foo); // no-warning
+
+to_void(&arguable.x); // no-warning
+void *p1 = &arguable.x;   // no-warning
+void *p2 = static_cast(&arguable.x);  // no-warning
+void *p3 = reinterpret_cast(&arguable.x); // no-warning
+void *p4 = (void *)&arguable.x;   // no-warning
+sink(p1, p2, p3, p4);
+  }
+  {
+Arguable arguable1;
+Arguable &arguable(arguable1);
+f1(&arguable.x);   // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
+f2(&arguable.c);   // no-warning
+f3(&arguable.foo); // no-warning
+  }
+  {
+Arguable *arguable1;
+Arguable *&arguable(arguable1);
+f1(&arguable->x);   // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
+f2(&arguable->c);   // no-warning
+f3(&arguable->foo); // no-warning
+  }
+}
+
+struct __attribute__((packed)) A {
+  int x;
+  char c;
+
+  int *f0() {
+return &this->x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+  }
+
+  int *g0() {
+return &x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+  }
+
+  char *h0() {
+return &c; // no-warning
+  }
+};
+
+struct B : A {
+  int *f1() {
+return &this->x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+  }
+
+  int *g1() {
+return &x; // expected-warning {{packed member 'x' of class or structure 'A'}}
+  }
+
+  char *h1() {
+return &c; // no-warning
+  }
+};
+
+template 
+class __attribute__((packed)) S {
+  Ty X;
+
+public:
+  const Ty *get() const {
+return &X; // expected-warning {{packed member 'X' of class or structure 'S'}}
+   // expected-warning@-1 {{packed member 'X' of class or structure 'S'}}
+  }
+};
+
+template 
+void h(Ty *);
+
+void g1() {
+  S s1;
+  s1.get(); // expected-note {{in instantiation of member function 'S::get'}}
+
+  S s2;
+  s2.get();
+
+  S s3;
+  s3.get(); // expected-note {{in instantiation of member function 'S::get'}}
+}
Index: test/SemaCXX/address-packed-member-memops.cpp
===
--- /dev/null
+++ test/SemaCXX/address-packed-member-memops.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+struct B {
+  int x, y, z, w;
+} b;
+
+struct __attribute__((packed)) A {
+  struct B b;
+} a;
+
+typedef __typeof__(sizeof(int)) size_t;
+
+extern "C" {
+void *memcpy(void *dest, const void *src, size_t n);
+int memcmp(const void *s1, const void *s2, size_t n);
+void *memmove(void *dest, const void *src, size_t n);
+void *memset(void *s, int c, size_t n);
+}
+
+int x;
+
+void foo() {
+  memcpy(&a.b, &b, sizeof(b));
+  memmove(&a.b, &b, sizeof(b));
+  memset(&a.b, 0, sizeof(b));
+  x = memcmp(&a.b, &b, sizeof(b));
+}
Index: test/Sema/address-packed.c
===
--- /dev/null
+++ test/Sema/address-packed.c
@@ -0,0 +1,160 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+extern void f1(int *);
+extern void f2(char *);
+
+struct Ok {
+  char c;
+  int x;
+};
+
+struct __attribute__((packed)) Arguable {
+  char c0;
+  int x;
+  char c1;
+};
+
+union __attribute__((packed)) UnionArguable {
+  char c;
+  int x;
+};
+
+typedef struct Arguable ArguableT;
+
+struct Arguable *get_arguable();
+
+void to_void(void *);
+
+void g0(void) {
+  {
+struct Ok ok;
+f1(&ok.x); // no-warning
+f2(&ok.c); // no-warning
+  }
+  {
+struct Arguable arguable;
+f2(&arguable.c0); // no-wa

Re: [PATCH] D21748: Implement tooling::Replacements as a class.

2016-07-15 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: lib/Tooling/Core/Replacement.cpp:300
@@ +299,3 @@
+Replacements Replacements::merge(const Replacement &R) const {
+  Replacements Rs;
+  llvm::consumeError(Rs.add(R));

klimek wrote:
> I'd probably add a single-replacement constructor for convenience.
Right...added single-replacement constructor and removed merge(R).


Comment at: lib/Tooling/Core/Replacement.cpp:306
@@ +305,3 @@
+// Merge and sort overlapping ranges in \p Ranges.
+static std::vector mergeAndSortRanges(std::vector Ranges) {
+  std::sort(Ranges.begin(), Ranges.end(),

klimek wrote:
> So, this doesn't do the same as Replacements::merge, right? I think we're 
> getting into a bit confusing terminology - perhaps we can find a better name 
> for this?
Changed to `combineAndSortRanges`...not sure if this is better though


https://reviews.llvm.org/D21748



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


Re: [PATCH] D22374: [analyzer] Copy and move constructors - ExprEngine extended for "almost trivial" copy and move constructors

2016-07-15 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

Note that, once a constructor is not available, we will conservatively treat it 
as nontrivial. This is not the case however for most of the templated code. 
Since the STL use templates heavily I think this patch is a great step forward 
in improving the modeling of C++ code.



Comment at: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:37
@@ -36,1 +36,3 @@
 
+bool isCopyOrMoveLike(const CXXConstructorDecl *Constr) {
+  if (Constr->isCopyOrMoveConstructor())

These two functions only used in this translation unit right? Maybe it would be 
better to make them static.


Comment at: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:57
@@ +56,3 @@
+
+  if(ParamRecDecl!=ThisRecDecl)
+return false;

nit: need spaced around the operator.


Comment at: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:63
@@ +62,3 @@
+
+bool isAlmostTrivial(const CXXMethodDecl *Met) {
+  if (Met->isTrivial())

Isn't this only applicable to ctors? Maybe you should reflect this in the name 
or change the type of the parameter accordingly.


Comment at: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:67
@@ +66,3 @@
+
+  if(!Met->hasTrivialBody())
+return false;

Please document that, in case we do not see the body of a ctor, we treat it 
conservatively as non trivial. (hasTrivialBody returns false when the body is 
not available)


Comment at: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:88
@@ +87,3 @@
+  if(Initzer->isBaseInitializer() &&
+ Initzer->getBaseClass() == &*Base.getType()) {
+if(const auto *CtrCall = 
dyn_cast(Initzer->getInit()->IgnoreParenImpCasts())) {

Maybe you could reduce the indentation if you use "early continue" here.


Comment at: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:109
@@ +108,3 @@
+if(!Field->getType()->isScalarType() &&
+   !Field->getType()->isRecordType())
+  return false;

What types do we want to exclude and why? It might be a good idea to document 
them.


Comment at: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:112
@@ +111,3 @@
+bool found = false;
+for(const auto *Initzer: Constr->inits()) {
+  if(Initzer->isMemberInitializer() && Initzer->getMember() == Field) {

Instead of the O(n^2) algorithm, it might be better to just iterate through the 
initializers, and put each field into a llvm small pointer set, or something 
like that. Afterwards you can iterate through the fields of the struct and 
check whether each field is inside the set. This might be both more efficient 
and cleaner.


https://reviews.llvm.org/D22374



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


Re: [PATCH] D22292: [libunwind] Fix unw_getcontext for ARMv6-m

2016-07-15 Thread Asiri Rathnayake via cfe-commits
rmaprath added a subscriber: olista01.
rmaprath added a comment.

Update: We've hit a minor issue with the patch, we're confident it can be 
sorted by next week. I will ask @olista01 to put the final patch for review 
next week, as I'm on holidays. Hope this is OK.

Cheers,

/ Asiri


https://reviews.llvm.org/D22292



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


[clang-tools-extra] r275545 - [clang-rename] add few tests

2016-07-15 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Fri Jul 15 05:21:33 2016
New Revision: 275545

URL: http://llvm.org/viewvc/llvm-project?rev=275545&view=rev
Log:
[clang-rename] add few tests

Thiis patch introduces few additional tests including one case the tool does 
not handle yet, which should be fixed in the future.

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


Added:
clang-tools-extra/trunk/test/clang-rename/FunctionMacro.cpp
clang-tools-extra/trunk/test/clang-rename/Namespace.cpp
clang-tools-extra/trunk/test/clang-rename/TemplateTypename.cpp
clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp
clang-tools-extra/trunk/test/clang-rename/VariableMacro.cpp

Added: clang-tools-extra/trunk/test/clang-rename/FunctionMacro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/FunctionMacro.cpp?rev=275545&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/FunctionMacro.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/FunctionMacro.cpp Fri Jul 15 
05:21:33 2016
@@ -0,0 +1,21 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=199 -new-name=macro_function %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+#define moo foo // CHECK: #define moo macro_function
+
+int foo() { // CHECK: int macro_function() {
+  return 42;
+}
+
+void boo(int value) {}
+
+void qoo() {
+  foo();// CHECK: macro_function();
+  boo(foo());   // CHECK: boo(macro_function());
+  moo();
+  boo(moo());
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.

Added: clang-tools-extra/trunk/test/clang-rename/Namespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/Namespace.cpp?rev=275545&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/Namespace.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/Namespace.cpp Fri Jul 15 05:21:33 
2016
@@ -0,0 +1,14 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=143 -new-name=llvm %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+namespace foo { // CHECK: namespace llvm {
+  int x;
+}
+
+void boo() {
+  foo::x = 42;  // CHECK: llvm::x = 42;
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.

Added: clang-tools-extra/trunk/test/clang-rename/TemplateTypename.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/TemplateTypename.cpp?rev=275545&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/TemplateTypename.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/TemplateTypename.cpp Fri Jul 15 
05:21:33 2016
@@ -0,0 +1,11 @@
+// Currently unsupported test.
+// FIXME: clang-rename should be able to rename template parameters correctly.
+
+template 
+T foo(T arg, T& ref, T* ptr) {
+  T value;
+  int number = 42;
+  value = (T)number;
+  value = static_cast(number);
+  return value;
+}

Added: clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp?rev=275545&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp Fri Jul 
15 05:21:33 2016
@@ -0,0 +1,12 @@
+// Currently unsupported test.
+// FIXME: clang-rename should handle conversions from a class type to another
+// type.
+
+class Foo {}; // CHECK: class Bar {};
+
+class Baz {   // CHECK: class Bar {
+  operator Foo() const {  // CHECK: operator Bar() const {
+Foo foo;  // CHECK: Bar foo;
+return foo;
+  }
+};

Added: clang-tools-extra/trunk/test/clang-rename/VariableMacro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/VariableMacro.cpp?rev=275545&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/VariableMacro.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/VariableMacro.cpp Fri Jul 15 
05:21:33 2016
@@ -0,0 +1,18 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=208 -new-name=Z %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+#define Y X // CHECK: #define Y Z
+
+void foo(int value) {}
+
+void macro() {
+  int X;// CHECK: int Z;
+  X = 42;   // CHECK: Z = 42;
+  Y -= 0;
+  foo(X);   // CHECK: foo(Z);
+  foo(Y);
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.


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

Re: [PATCH] D22102: [clang-rename] extend testset

2016-07-15 Thread Kirill Bobyrev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275545: [clang-rename] add few tests (authored by omtcyfz).

Changed prior to commit:
  https://reviews.llvm.org/D22102?vs=63939&id=64119#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22102

Files:
  clang-tools-extra/trunk/test/clang-rename/FunctionMacro.cpp
  clang-tools-extra/trunk/test/clang-rename/Namespace.cpp
  clang-tools-extra/trunk/test/clang-rename/TemplateTypename.cpp
  clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp
  clang-tools-extra/trunk/test/clang-rename/VariableMacro.cpp

Index: clang-tools-extra/trunk/test/clang-rename/TemplateTypename.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/TemplateTypename.cpp
+++ clang-tools-extra/trunk/test/clang-rename/TemplateTypename.cpp
@@ -0,0 +1,11 @@
+// Currently unsupported test.
+// FIXME: clang-rename should be able to rename template parameters correctly.
+
+template 
+T foo(T arg, T& ref, T* ptr) {
+  T value;
+  int number = 42;
+  value = (T)number;
+  value = static_cast(number);
+  return value;
+}
Index: clang-tools-extra/trunk/test/clang-rename/FunctionMacro.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/FunctionMacro.cpp
+++ clang-tools-extra/trunk/test/clang-rename/FunctionMacro.cpp
@@ -0,0 +1,21 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=199 -new-name=macro_function %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+#define moo foo // CHECK: #define moo macro_function
+
+int foo() { // CHECK: int macro_function() {
+  return 42;
+}
+
+void boo(int value) {}
+
+void qoo() {
+  foo();// CHECK: macro_function();
+  boo(foo());   // CHECK: boo(macro_function());
+  moo();
+  boo(moo());
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.
Index: clang-tools-extra/trunk/test/clang-rename/VariableMacro.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/VariableMacro.cpp
+++ clang-tools-extra/trunk/test/clang-rename/VariableMacro.cpp
@@ -0,0 +1,18 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=208 -new-name=Z %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+#define Y X // CHECK: #define Y Z
+
+void foo(int value) {}
+
+void macro() {
+  int X;// CHECK: int Z;
+  X = 42;   // CHECK: Z = 42;
+  Y -= 0;
+  foo(X);   // CHECK: foo(Z);
+  foo(Y);
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.
Index: clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp
+++ clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp
@@ -0,0 +1,12 @@
+// Currently unsupported test.
+// FIXME: clang-rename should handle conversions from a class type to another
+// type.
+
+class Foo {}; // CHECK: class Bar {};
+
+class Baz {   // CHECK: class Bar {
+  operator Foo() const {  // CHECK: operator Bar() const {
+Foo foo;  // CHECK: Bar foo;
+return foo;
+  }
+};
Index: clang-tools-extra/trunk/test/clang-rename/Namespace.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/Namespace.cpp
+++ clang-tools-extra/trunk/test/clang-rename/Namespace.cpp
@@ -0,0 +1,14 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=143 -new-name=llvm %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+namespace foo { // CHECK: namespace llvm {
+  int x;
+}
+
+void boo() {
+  foo::x = 42;  // CHECK: llvm::x = 42;
+}
+
+// Use grep -FUbo 'foo;'  to get the correct offset of foo when changing
+// this file.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r275550 - [clang-rename] apply stylistic fixes

2016-07-15 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Fri Jul 15 06:29:16 2016
New Revision: 275550

URL: http://llvm.org/viewvc/llvm-project?rev=275550&view=rev
Log:
[clang-rename] apply stylistic fixes

Modified:
clang-tools-extra/trunk/clang-rename/USRFinder.cpp
clang-tools-extra/trunk/clang-rename/USRFindingAction.h
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFinder.cpp?rev=275550&r1=275549&r2=275550&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp Fri Jul 15 06:29:16 2016
@@ -139,7 +139,7 @@ private:
   const SourceLocation Point; // The location to find the NamedDecl.
   const std::string Name;
 };
-}
+} // namespace
 
 const NamedDecl *getNamedDeclAt(const ASTContext &Context,
 const SourceLocation Point) {
@@ -191,5 +191,5 @@ std::string getUSRForDecl(const Decl *De
   return std::string(Buff.data(), Buff.size());
 }
 
-} // namespace clang
 } // namespace rename
+} // namespace clang

Modified: clang-tools-extra/trunk/clang-rename/USRFindingAction.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFindingAction.h?rev=275550&r1=275549&r2=275550&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.h (original)
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.h Fri Jul 15 06:29:16 
2016
@@ -8,7 +8,7 @@
 
//===--===//
 ///
 /// \file
-/// \brief Provides an action to find all relevent USRs at a point.
+/// \brief Provides an action to find all relevant USRs at a point.
 ///
 
//===--===//
 
@@ -25,18 +25,14 @@ class NamedDecl;
 namespace rename {
 
 struct USRFindingAction {
-  USRFindingAction(unsigned Offset, const std::string &Name) : 
SymbolOffset(Offset), OldName(Name) {
-  }
+  USRFindingAction(unsigned Offset, const std::string &Name)
+  : SymbolOffset(Offset), OldName(Name) {}
   std::unique_ptr newASTConsumer();
 
   // \brief get the spelling of the USR(s) as it would appear in source files.
-  const std::string &getUSRSpelling() {
-return SpellingName;
-  }
-
-  const std::vector &getUSRs() {
-return USRs;
-  }
+  const std::string &getUSRSpelling() { return SpellingName; }
+
+  const std::vector &getUSRs() { return USRs; }
 
 private:
   unsigned SymbolOffset;
@@ -45,7 +41,7 @@ private:
   std::vector USRs;
 };
 
-}
-}
+} // namespace rename
+} // namespace clang
 
 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_RENAME_USR_FINDING_ACTION_H_

Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=275550&r1=275549&r2=275550&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Fri Jul 15 06:29:16 
2016
@@ -210,10 +210,10 @@ private:
 
 std::vector getLocationsOfUSR(StringRef USR, StringRef 
PrevName,
   Decl *Decl) {
-  USRLocFindingASTVisitor visitor(USR, PrevName);
+  USRLocFindingASTVisitor Visitor(USR, PrevName);
 
-  visitor.TraverseDecl(Decl);
-  return visitor.getLocationsFound();
+  Visitor.TraverseDecl(Decl);
+  return Visitor.getLocationsFound();
 }
 
 } // namespace rename

Modified: clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp?rev=275550&r1=275549&r2=275550&view=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp Fri Jul 15 
06:29:16 2016
@@ -126,12 +126,12 @@ int main(int argc, const char **argv) {
   rename::RenamingAction RenameAction(NewName, PrevName, USRs,
   Tool.getReplacements(), PrintLocations);
   auto Factory = tooling::newFrontendActionFactory(&RenameAction);
-  int res;
+  int ExitCode;
 
   if (Inplace) {
-res = Tool.runAndSave(Factory.get());
+ExitCode = Tool.runAndSave(Factory.get());
   } else {
-res = Tool.run(Factory.get());
+ExitCode = Tool.run(Factory.get());
 
 if (!ExportFixes.empty()) {
   std::error_code EC;
@@ -175,5 +175,5 @@ int main(int argc, const char **argv) {
 }
   }
 
-  exit(res);
+  exit(ExitCode);
 }


__

[clang-tools-extra] r275556 - [clang-rename] fix testset

2016-07-15 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Fri Jul 15 07:22:38 2016
New Revision: 275556

URL: http://llvm.org/viewvc/llvm-project?rev=275556&view=rev
Log:
[clang-rename] fix testset

Make yet unsupported tests marked with FIXME pass so that buildbot doesn't fail.

Added:
clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp
clang-tools-extra/trunk/test/clang-rename/ClassReplacements.cpp
clang-tools-extra/trunk/test/clang-rename/ClassSimpleRenaming.cpp
clang-tools-extra/trunk/test/clang-rename/ComplicatedClassTest.cpp
clang-tools-extra/trunk/test/clang-rename/CtorFindByDeclaration.cpp
clang-tools-extra/trunk/test/clang-rename/CtorFindByDefinition.cpp
clang-tools-extra/trunk/test/clang-rename/CtorInitializer.cpp
clang-tools-extra/trunk/test/clang-rename/DtorDeclaration.cpp
clang-tools-extra/trunk/test/clang-rename/DtorDefinition.cpp
clang-tools-extra/trunk/test/clang-rename/Field.cpp

clang-tools-extra/trunk/test/clang-rename/UserDefinedConversionFindByTypeDeclaration.cpp
clang-tools-extra/trunk/test/clang-rename/Variable.cpp
Modified:
clang-tools-extra/trunk/test/clang-rename/ConstCastExpr.cpp
clang-tools-extra/trunk/test/clang-rename/ConstructExpr.cpp
clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp
clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp
clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp
clang-tools-extra/trunk/test/clang-rename/TemplateTypename.cpp
clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp

Added: clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp?rev=275556&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp Fri Jul 15 
07:22:38 2016
@@ -0,0 +1,11 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -old-name=Foo -new-name=Bar %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class Foo { // CHECK: class Bar
+};
+
+int main() {
+  Foo *Pointer = 0; // CHECK: Bar *Pointer = 0;
+  return 0;
+}

Added: 
clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp?rev=275556&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp 
(added)
+++ clang-tools-extra/trunk/test/clang-rename/ClassNameInFunctionDefenition.cpp 
Fri Jul 15 07:22:38 2016
@@ -0,0 +1,17 @@
+// Currently unsupported test.
+// RUN: cat %s > %t.cpp
+// FIXME: clang-rename doesn't recognize symbol in class function definition.
+
+class Foo {
+public:
+  void foo(int x);
+};
+
+void Foo::foo(int x) {}
+//   ^ this one
+
+int main() {
+  Foo obj;
+  obj.foo(0);
+  return 0;
+}

Added: clang-tools-extra/trunk/test/clang-rename/ClassReplacements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassReplacements.cpp?rev=275556&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/ClassReplacements.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/ClassReplacements.cpp Fri Jul 15 
07:22:38 2016
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/fixes
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=254 -new-name=Bar 
-export-fixes=%t/fixes/clang-rename.yaml %t.cpp --
+// RUN: clang-apply-replacements %t
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class Foo {}; // CHECK: class Bar {};
+
+// Use grep -FUbo 'Foo'  to get the correct offset of Cla when changing
+// this file.

Added: clang-tools-extra/trunk/test/clang-rename/ClassSimpleRenaming.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassSimpleRenaming.cpp?rev=275556&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/ClassSimpleRenaming.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/ClassSimpleRenaming.cpp Fri Jul 
15 07:22:38 2016
@@ -0,0 +1,13 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=136 -new-name=Bar %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class Foo {};   // CHECK: class Bar
+
+int main() {
+  Foo *Pointer = 0; // CHECK: Bar *Pointer = 0;
+  return 0;
+}
+
+// Use grep -FUbo 'Foo'  to get the correct offset of Cla when changing
+// this file.

Added: clang-tools-extra/trunk/test/clang-rename/ComplicatedClassTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ComplicatedClassTest.cpp?rev=

[PATCH] D22408: [clang-rename] add support for overridden functions

2016-07-15 Thread Kirill Bobyrev via cfe-commits
omtcyfz created this revision.
omtcyfz added reviewers: bkramer, alexfh, klimek.
omtcyfz added a subscriber: cfe-commits.

add implementation and tests for virtual function renaming

https://reviews.llvm.org/D22408

Files:
  clang-rename/USRFindingAction.cpp
  test/clang-rename/VirtualFunctionFindInBaseClass.cpp
  test/clang-rename/VirtualFunctionFindInDerivedClass.cpp

Index: test/clang-rename/VirtualFunctionFindInDerivedClass.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunctionFindInDerivedClass.cpp
@@ -0,0 +1,33 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=165 -new-name=bar %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class Foo {
+public:
+  virtual void foo() {}   // CHECK: virtual void bar() {}
+};
+
+class Bar : public Foo {
+public:
+  void foo() override {}  // CHECK: void bar() override {}
+};
+
+class Baz : public Bar {
+ public:
+  void foo() override {}  // CHECK: void bar() override {}
+};
+
+int main() {
+  Foo f;
+  f.foo();// CHECK: f.bar();
+
+  Bar b;
+  b.foo();// CHECK: b.bar();
+
+  Baz obj;
+  obj.foo();  // CHECK: obj.bar();
+
+  return 0;
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
Index: test/clang-rename/VirtualFunctionFindInBaseClass.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunctionFindInBaseClass.cpp
@@ -0,0 +1,33 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=165 -new-name=bar %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class Foo {
+public:
+  virtual void foo() {}   // CHECK: virtual void bar() {}
+};
+
+class Bar : public Foo {
+public:
+  void foo() override {}  // CHECK: void bar() override {}
+};
+
+class Baz : public Bar {
+ public:
+  void foo() override {}  // CHECK: void bar() override {}
+};
+
+int main() {
+  Foo f;
+  f.foo();// CHECK: f.bar();
+
+  Bar b;
+  b.foo();// CHECK: b.bar();
+
+  Baz obj;
+  obj.foo();  // CHECK: obj.bar();
+
+  return 0;
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
Index: clang-rename/USRFindingAction.cpp
===
--- clang-rename/USRFindingAction.cpp
+++ clang-rename/USRFindingAction.cpp
@@ -8,64 +8,111 @@
 //===--===//
 ///
 /// \file
-/// \brief Provides an action to rename every symbol at a point.
+/// \brief Provides an action to find USR for the symbol at  and all
+/// relevant USRs aswell.
 ///
 //===--===//
 
 #include "USRFindingAction.h"
 #include "USRFinder.h"
 #include "clang/AST/AST.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/Tooling.h"
+#include 
 #include 
 #include 
 
 using namespace llvm;
 
 namespace clang {
 namespace rename {
 
-// Get the USRs for the constructors of the class.
-static std::vector getAllConstructorUSRs(
-const CXXRecordDecl *Decl) {
-  std::vector USRs;
+namespace {
+// \brief NamedDeclFindingConsumer should delegate finding USRs relevant to
+// given Decl to RelevantUSRFinder.
+//
+// FIXME: It's better to match ctors/dtors via typeLoc's instead of adding
+// their USRs to the storage, because we can also match CXXConversionDecl's by
+// typeLoc and we won't have to "manually" handle them here.
+class RelevantUSRFinder : public clang::RecursiveASTVisitor {
+public:
+  explicit RelevantUSRFinder(const Decl *FoundDecl, TranslationUnitDecl *TUDecl,
+ std::vector *USRs)
+  : FoundDecl(FoundDecl), USRs(USRs) {
+USRs->push_back(getUSRForDecl(FoundDecl));
+addRelevantUSRs();
+TraverseDecl(TUDecl);
+  }
 
-  // We need to get the definition of the record (as opposed to any forward
-  // declarations) in order to find the constructor and destructor.
-  const auto *RecordDecl = Decl->getDefinition();
+  // CXXMethodDecl which overrides one of the methods stored for renaming
+  // should be added to the storage, too.
+  bool VisitCXXMethodDecl(CXXMethodDecl *D) {
+if (D->isVirtual()) {
+  bool Found = false;
+  for (auto &OverriddenMethod : D->overridden_methods()) {
+if (std::find(USRs->begin(), USRs->end(),
+  getUSRForDecl(OverriddenMethod)) != USRs->end()) {
+  Found = true;
+}
+  }
+  if (Found) {
+USRs->push_back(getUSRForDecl(D));
+  

r275558 - Removing a few more :option: tags that we do not have corresponding .. option directives for; these are causing the sphinx bot to fail (http://lab.llvm.org:8011/builders/clang-sphinx-docs/bu

2016-07-15 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Jul 15 07:55:47 2016
New Revision: 275558

URL: http://llvm.org/viewvc/llvm-project?rev=275558&view=rev
Log:
Removing a few more :option: tags that we do not have corresponding .. option 
directives for; these are causing the sphinx bot to fail 
(http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/15213/steps/docs-clang-html/logs/stdio).

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=275558&r1=275557&r2=275558&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Fri Jul 15 07:55:47 2016
@@ -543,15 +543,15 @@ vectorize a loop body.
 Clang offers a family of flags which the optimizers can use to emit
 a diagnostic in three cases:
 
-1. When the pass makes a transformation (:option:`-Rpass`).
+1. When the pass makes a transformation (`-Rpass`).
 
-2. When the pass fails to make a transformation (:option:`-Rpass-missed`).
+2. When the pass fails to make a transformation (`-Rpass-missed`).
 
 3. When the pass determines whether or not to make a transformation
-   (:option:`-Rpass-analysis`).
+   (`-Rpass-analysis`).
 
-NOTE: Although the discussion below focuses on :option:`-Rpass`, the exact
-same options apply to :option:`-Rpass-missed` and :option:`-Rpass-analysis`.
+NOTE: Although the discussion below focuses on `-Rpass`, the exact
+same options apply to `-Rpass-missed` and `-Rpass-analysis`.
 
 Since there are dozens of passes inside the compiler, each of these flags
 take a regular expression that identifies the name of the pass which should
@@ -567,7 +567,7 @@ compile the code with:
 
 Note that remarks from the inliner are identified with `[-Rpass=inline]`.
 To request a report from every optimization pass, you should use
-:option:`-Rpass=.*` (in fact, you can use any valid POSIX regular
+`-Rpass=.*` (in fact, you can use any valid POSIX regular
 expression). However, do not expect a report from every transformation
 made by the compiler. Optimization remarks do not really make sense
 outside of the major transformations (e.g., inlining, vectorization,
@@ -585,7 +585,7 @@ Current limitations
 2. Some source locations are not displayed correctly. The front end has
a more detailed source location tracking than the locations included
in the debug info (e.g., the front end can locate code inside macro
-   expansions). However, the locations used by :option:`-Rpass` are
+   expansions). However, the locations used by `-Rpass` are
translated from debug annotations. That translation can be lossy,
which results in some remarks having no location information.
 


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


Re: [PATCH] D19311: [analyzer] Self Assignment Checker

2016-07-15 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware updated this revision to Diff 64135.
baloghadamsoftware added a comment.

Test updated.


https://reviews.llvm.org/D19311

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
  lib/StaticAnalyzer/Core/BugReporter.cpp
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/self-assign.cpp

Index: test/Analysis/self-assign.cpp
===
--- /dev/null
+++ test/Analysis/self-assign.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,cplusplus,unix.Malloc,debug.ExprInspection %s -verify -analyzer-output=text
+
+extern "C" char *strdup(const char* s);
+extern "C" void free(void* ptr);
+
+namespace std {
+template struct remove_reference  { typedef T type; };
+template struct remove_reference  { typedef T type; };
+template struct remove_reference { typedef T type; };
+template typename remove_reference::type&& move(T&& t);
+}
+
+void clang_analyzer_eval(int);
+
+class StringUsed {
+public:
+  StringUsed(const char *s = "") : str(strdup(s)) {}
+  StringUsed(const StringUsed &rhs) : str(strdup(rhs.str)) {}
+  ~StringUsed();
+  StringUsed& operator=(const StringUsed &rhs);
+  StringUsed& operator=(StringUsed &&rhs);
+  operator const char*() const;
+private:
+  char *str;
+};
+
+StringUsed::~StringUsed() {
+  free(str);
+}
+
+StringUsed& StringUsed::operator=(const StringUsed &rhs) { // expected-note{{Assuming rhs == *this}} expected-note{{Assuming rhs == *this}} expected-note{{Assuming rhs != *this}}
+  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}} expected-note{{TRUE}} expected-note{{UNKNOWN}}
+  free(str); // expected-note{{Memory is released}}
+  str = strdup(rhs.str); // expected-warning{{Use of memory after it is freed}}  expected-note{{Use of memory after it is freed}}
+  return *this;
+}
+
+StringUsed& StringUsed::operator=(StringUsed &&rhs) { // expected-note{{Assuming rhs == *this}} expected-note{{Assuming rhs != *this}}
+  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}} expected-note{{TRUE}} expected-note{{UNKNOWN}}
+  str = rhs.str;
+  rhs.str = nullptr; // FIXME: An improved leak checker should warn here
+  return *this;
+}
+
+StringUsed::operator const char*() const {
+  return str;
+}
+
+class StringUnused {
+public:
+  StringUnused(const char *s = "") : str(strdup(s)) {}
+  StringUnused(const StringUnused &rhs) : str(strdup(rhs.str)) {}
+  ~StringUnused();
+  StringUnused& operator=(const StringUnused &rhs);
+  StringUnused& operator=(StringUnused &&rhs);
+  operator const char*() const;
+private:
+  char *str;
+};
+
+StringUnused::~StringUnused() {
+  free(str);
+}
+
+StringUnused& StringUnused::operator=(const StringUnused &rhs) { // expected-note{{Assuming rhs == *this}} expected-note{{Assuming rhs == *this}} expected-note{{Assuming rhs != *this}}
+  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}} expected-note{{TRUE}} expected-note{{UNKNOWN}}
+  free(str); // expected-note{{Memory is released}}
+  str = strdup(rhs.str); // expected-warning{{Use of memory after it is freed}}  expected-note{{Use of memory after it is freed}}
+  return *this;
+}
+
+StringUnused& StringUnused::operator=(StringUnused &&rhs) { // expected-note{{Assuming rhs == *this}} expected-note{{Assuming rhs != *this}}
+  clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}} expected-note{{TRUE}} expected-note{{UNKNOWN}}
+  str = rhs.str;
+  rhs.str = nullptr; // FIXME: An improved leak checker should warn here
+  return *this;
+}
+
+StringUnused::operator const char*() const {
+  return str;
+}
+
+
+int main() {
+  StringUsed s1 ("test"), s2;
+  s2 = s1;
+  s2 = std::move(s1);
+  return 0;
+}
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -431,6 +431,13 @@
   //   Count naming convention errors more aggressively.
   if (isa(D))
 return false;
+  // We also want to reanalyze all C++ copy and move assignment operators to
+  // separately check the two cases where 'this' aliases with the parameter and
+  // where it may not. (cplusplus.SelfAssignmentChecker)
+  if (const auto *MD = dyn_cast(D)) {
+if (MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())
+  return false;
+  }
 
   // Otherwise, if we visited the function before, do not reanalyze it.
   return Visited.count(D);
@@ -442,9 +449,7 @@
   // We want to reanalyze all ObjC methods as top level to report Retain
   // Count naming convention errors more aggr

Re: [PATCH] D19311: [analyzer] Self Assignment Checker

2016-07-15 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added a comment.

https://reviews.llvm.org/D19311



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


r275560 - Removing a few more :option: tags that we do not have corresponding .. option directives for; these are causing the sphinx bot to fail (http://lab.llvm.org:8011/builders/clang-sphinx-docs/bu

2016-07-15 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Jul 15 08:13:45 2016
New Revision: 275560

URL: http://llvm.org/viewvc/llvm-project?rev=275560&view=rev
Log:
Removing a few more :option: tags that we do not have corresponding .. option 
directives for; these are causing the sphinx bot to fail 
(http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/15214/steps/docs-clang-html/logs/stdio).

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=275560&r1=275559&r2=275560&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Fri Jul 15 08:13:45 2016
@@ -783,7 +783,7 @@ the pragma onwards within the same file.
   #if foo
   #endif foo // no warning
 
-The :option:`--system-header-prefix=` and :option:`--no-system-header-prefix=`
+The `--system-header-prefix=` and `--no-system-header-prefix=`
 command-line arguments can be used to override whether subsets of an include
 path are treated as system headers. When the name in a ``#include`` directive
 is found within a header search path and starts with a system prefix, the
@@ -852,7 +852,7 @@ Generating a PCH File
 ^
 
 To generate a PCH file using Clang, one invokes Clang with the
-:option:`-x -header` option. This mirrors the interface in GCC
+`-x -header` option. This mirrors the interface in GCC
 for generating PCH files:
 
 .. code-block:: console
@@ -915,7 +915,7 @@ location.
 Building a relocatable precompiled header requires two additional
 arguments. First, pass the ``--relocatable-pch`` flag to indicate that
 the resulting PCH file should be relocatable. Second, pass
-:option:`-isysroot /path/to/build`, which makes all includes for your library
+`-isysroot /path/to/build`, which makes all includes for your library
 relative to the build directory. For example:
 
 .. code-block:: console
@@ -925,9 +925,9 @@ relative to the build directory. For exa
 When loading the relocatable PCH file, the various headers used in the
 PCH file are found from the system header root. For example, ``mylib.h``
 can be found in ``/usr/include/mylib.h``. If the headers are installed
-in some other system root, the :option:`-isysroot` option can be used provide
+in some other system root, the `-isysroot` option can be used provide
 a different system root from which the headers will be based. For
-example, :option:`-isysroot /Developer/SDKs/MacOSX10.4u.sdk` will look for
+example, `-isysroot /Developer/SDKs/MacOSX10.4u.sdk` will look for
 ``mylib.h`` in ``/Developer/SDKs/MacOSX10.4u.sdk/usr/include/mylib.h``.
 
 Relocatable precompiled headers are intended to be used in a limited
@@ -1872,8 +1872,8 @@ directives, ``depend`` clause for ``#pra
 array sections), ``#pragma omp cancel`` and ``#pragma omp cancellation point``
 directives, and ``#pragma omp taskgroup`` directive.
 
-Use :option:`-fopenmp` to enable OpenMP. Support for OpenMP can be disabled 
with
-:option:`-fno-openmp`.
+Use `-fopenmp` to enable OpenMP. Support for OpenMP can be disabled with
+`-fno-openmp`.
 
 Controlling implementation limits
 -
@@ -1882,7 +1882,7 @@ Controlling implementation limits
 
  Controls code generation for OpenMP threadprivate variables. In presence of
  this option all threadprivate variables are generated the same way as thread
- local variables, using TLS support. If :option:`-fno-openmp-use-tls`
+ local variables, using TLS support. If `-fno-openmp-use-tls`
  is provided or target does not support TLS, code generation for threadprivate
  variables relies on OpenMP runtime library.
 
@@ -1906,7 +1906,7 @@ On ``x86_64-mingw32``, passing i128(by v
 Microsoft x64 calling convention. You might need to tweak
 ``WinX86_64ABIInfo::classify()`` in lib/CodeGen/TargetInfo.cpp.
 
-For the X86 target, clang supports the :option:`-m16` command line
+For the X86 target, clang supports the `-m16` command line
 argument which enables 16-bit code output. This is broadly similar to
 using ``asm(".code16gcc")`` with the GNU toolchain. The generated code
 and the ABI remains 32-bit but the assembler emits instructions


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


Re: [PATCH] D21814: clang-rename: support multiple renames with one invocation

2016-07-15 Thread Manuel Klimek via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D21814#478879, @vmiklos wrote:

> As far as I see `tooling::CommonOptionsParser` (in its current form) does not 
> handle cl::SubCommand instances. Should I fix that or would it be OK to 
> switch to using `cl::ParseCommandLineOptions` directly in clang-rename?


Well, if you switch, you'll lose a lot of what CommonOptionsParser gives you... 
So I think it's useful to keep it working with CommonOptionsParser.


https://reviews.llvm.org/D21814



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


Re: [PATCH] D21814: clang-rename: support multiple renames with one invocation

2016-07-15 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

The alternative is to change the `CommonOptionsParser` ctor to take a vector of 
`OptionCategory&`, and in that case we can add the -extra-arg-before and other 
options to all subcommands, but that means he'll have to adapt all client code, 
i.e. all tools in clang-tools-extra that uses CommonOptionsParser. Is that an 
acceptable cost? Or did I miss some easier way?


https://reviews.llvm.org/D21814



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


Re: [PATCH] D21814: clang-rename: support multiple renames with one invocation

2016-07-15 Thread Manuel Klimek via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D21814#485410, @vmiklos wrote:

> The alternative is to change the `CommonOptionsParser` ctor to take a vector 
> of `OptionCategory&`, and in that case we can add the -extra-arg-before and 
> other options to all subcommands, but that means he'll have to adapt all 
> client code, i.e. all tools in clang-tools-extra that uses 
> CommonOptionsParser. Is that an acceptable cost? Or did I miss some easier 
> way?


So Subcommand doesn't support having a set of common options?


https://reviews.llvm.org/D21814



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


Re: [PATCH] D19771: Rework FixedSizeTemplateParameterListStorage

2016-07-15 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast abandoned this revision.
hubert.reinterpretcast added a comment.

This is superseded by https://reviews.llvm.org/D19322.


https://reviews.llvm.org/D19771



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


Re: [PATCH] D18639: Use __builtin_isnan/isinf/isfinite in complex

2016-07-15 Thread Steve Canon via cfe-commits
scanon added a comment.

I am not the right person to review the C++ template details, but everything 
else seems OK to me.


https://reviews.llvm.org/D18639



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


Re: [PATCH] D22096: [OpenMP] Sema and parsing for 'target parallel for simd' pragma

2016-07-15 Thread Kelvin Li via cfe-commits
I will take a look and put up a patch for it.

Kelvin

On Fri, Jul 15, 2016 at 2:46 AM, Alexey Bataev  wrote:

> Kelvin,
> Please look at these messages and fix the tests. Or tell me and I will
> fix them
>
> Best regards,
> Alexey Bataev
> =
> Software Engineer
> Intel Compiler Team
>
> 15.07.2016 9:23, Robinson, Paul пишет:
> >
> >> -Original Message-
> >> From: Alexey Bataev [mailto:a.bat...@hotmail.com]
> >> Sent: Thursday, July 14, 2016 7:51 PM
> >> To: reviews+d22096+public+4c00789034d62...@reviews.llvm.org
> >> Cc: cfe-commits@lists.llvm.org; kkw...@gmail.com; cber...@us.ibm.com;
> >> sfan...@us.ibm.com; hfin...@anl.gov; acja...@us.ibm.com; Robinson, Paul
> >> Subject: Re: [PATCH] D22096: [OpenMP] Sema and parsing for 'target
> >> parallel for simd' pragma
> >>
> >> Hi Paul,
> >> Could you provide a little bit more info about diagnostic you see? Maybe
> >> the tests just need to be fixed
> > That would be fine too.  Log of the two failing tests attached.
> > Thanks,
> > --paulr
> >
> >> Best regards,
> >> Alexey Bataev
> >> =
> >> Software Engineer
> >> Intel Compiler Team
> >>
> >> 15.07.2016 2:09, Paul Robinson пишет:
> >>> probinson added a subscriber: probinson.
> >>> probinson added a comment.
> >>>
> >>> I'm seeing a different set of diagnostics in two of these tests,
> because
> >> we default to C+11, which makes them fail for us.  Ideally you'd
> >> conditionalize the tests on the value of `__cplusplus` (like Charles Li
> >> has been doing for a whole lot of the Clang tests).  If that's
> >> inconvenient for you right now, would you mind if I added `-std=c++03`
> to
> >> the following tests?  It's just these two that need it:
> >>> target_parallel_for_simd_collapse_messages.cpp
> >>> target_parallel_for_simd_ordered_messages.cpp
> >>>
> >>>
> >>> Repository:
> >>> rL LLVM
> >>>
> >>> https://reviews.llvm.org/D22096
> >>>
> >>>
> >>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22171: [ObjC Availability] Implement parser support for Objective-C's @available

2016-07-15 Thread Erik Pilkington via cfe-commits
erik.pilkington added a comment.

Ping!


https://reviews.llvm.org/D22171



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


Re: [PATCH] D21814: clang-rename: support multiple renames with one invocation

2016-07-15 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

I'm a bit confused.

On one hand, I want to use tooling::CommonOptionsParser to parse the options, 
which needs a cl::OptionCategory as a parameter.

On the other hand, I want to parse the options, based on that I'll know what 
subcommand was requested, and then I can choose the right option category. 
Based on the above example, I want to use an option category that recognizes 
-oldname when "rename-all" is used, and I want an other option category that 
recognizes -offset" when "rename-at" is used.

I sense a chicken-and-egg problem, the argument of CommonOptionsParser needs 
the category, but I'll only know the correct category after I called 
CommonOptionsParser. Or is there a way out of this? ;-)


https://reviews.llvm.org/D21814



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


r275570 - XRay: Remove duplicate checks for xray instrumentation flags

2016-07-15 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Fri Jul 15 10:46:39 2016
New Revision: 275570

URL: http://llvm.org/viewvc/llvm-project?rev=275570&view=rev
Log:
XRay: Remove duplicate checks for xray instrumentation flags

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=275570&r1=275569&r2=275570&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jul 15 10:46:39 2016
@@ -4612,16 +4612,6 @@ void Clang::ConstructJob(Compilation &C,
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
 CmdArgs.push_back("-fxray-instrument");
-if (Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_,
- options::OPT_fxray_instruction_threshold_EQ)) 
{
-  CmdArgs.push_back("-fxray-instruction-threshold");
-  CmdArgs.push_back(A->getValue());
-}
-  }
-
-  if (Args.hasFlag(options::OPT_fxray_instrument,
-   options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {


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


Re: [PATCH] D22374: [analyzer] Copy and move constructors - ExprEngine extended for "almost trivial" copy and move constructors

2016-07-15 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware updated this revision to Diff 64149.
baloghadamsoftware added a comment.

Revised version based on comments.


https://reviews.llvm.org/D22374

Files:
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  test/Analysis/ctor.mm

Index: test/Analysis/ctor.mm
===
--- test/Analysis/ctor.mm
+++ test/Analysis/ctor.mm
@@ -144,11 +144,11 @@
 
 NonPOD() {}
 NonPOD(const NonPOD &Other)
-  : x(Other.x), y(Other.y) // expected-warning {{undefined}}
+  : x(Other.x), y(Other.y) // no-warning
 {
 }
 NonPOD(NonPOD &&Other)
-: x(Other.x), y(Other.y) // expected-warning {{undefined}}
+: x(Other.x), y(Other.y) // no-warning
 {
 }
 
@@ -174,11 +174,11 @@
 
   Inner() {}
   Inner(const Inner &Other)
-: x(Other.x), y(Other.y) // expected-warning {{undefined}}
+: x(Other.x), y(Other.y) // no-warning
   {
   }
   Inner(Inner &&Other)
-  : x(Other.x), y(Other.y) // expected-warning {{undefined}}
+  : x(Other.x), y(Other.y) // no-warning
   {
   }
 
@@ -224,25 +224,29 @@
   void testNonPOD() {
 NonPOD p;
 p.x = 1;
-NonPOD p2 = p;
+NonPOD p2 = p; // no-warning
+clang_analyzer_eval(p2.x == 1); // expected-warning{{TRUE}}
   }
 
   void testNonPODMove() {
 NonPOD p;
 p.x = 1;
-NonPOD p2 = move(p);
+NonPOD p2 = move(p); // no-warning
+clang_analyzer_eval(p2.x == 1); // expected-warning{{TRUE}}
   }
 
   void testNonPODWrapper() {
 NonPODWrapper w;
 w.p.y = 1;
-NonPODWrapper w2 = w;
+NonPODWrapper w2 = w; // no-warning
+clang_analyzer_eval(w2.p.y == 1); // expected-warning{{TRUE}}
   }
 
   void testNonPODWrapperMove() {
 NonPODWrapper w;
 w.p.y = 1;
-NonPODWrapper w2 = move(w);
+NonPODWrapper w2 = move(w); // no-warning
+clang_analyzer_eval(w2.p.y == 1); // expected-warning{{TRUE}}
   }
 
   // Not strictly about constructors, but trivial assignment operators should
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -19,6 +19,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 
+#include "llvm/ADT/SmallPtrSet.h"
+
 using namespace clang;
 using namespace ento;
 
@@ -34,19 +36,136 @@
   Bldr.generateNode(ME, Pred, state);
 }
 
+static bool isCopyOrMoveLike(const CXXConstructorDecl *Constr) {
+  if (Constr->isCopyOrMoveConstructor())
+return true;
+
+  if (Constr->getNumParams() != 1)
+return false;
+
+  const auto ParamType =
+  Constr->getParamDecl(0)->getType()->getUnqualifiedDesugaredType();
+  if (!ParamType->isReferenceType())
+return false;
+
+  const auto ParamPointeeType =
+  ParamType->getAs()->getPointeeType();
+  if (!ParamPointeeType->isRecordType())
+return false;
+
+  const auto *ParamRecDecl = ParamPointeeType->getAs()->getDecl();
+  const auto *ThisRecDecl = Constr->getParent();
+
+  if (ParamRecDecl != ThisRecDecl)
+return false;
+
+  return true;
+}
+
+static bool isAlmostTrivialConstructor(const CXXMethodDecl *Met) {
+  if (Met->isTrivial())
+return true;
+
+  if (!Met->hasTrivialBody()) // Returns false if body is not available
+return false;
+
+  if (Met->getNumParams() != 1)
+return false;
+
+  const auto *Param = Met->getParamDecl(0);
+  const auto *ThisRecDecl = Met->getParent();
+
+  const auto *Constr = dyn_cast(Met);
+  if (!Constr)
+return false;
+
+  if (ThisRecDecl->getNumVBases() > 0)
+return false;
+
+  llvm::SmallPtrSet InitBaseSet;
+  llvm::SmallPtrSet InitFieldSet;
+
+  for (const auto *Initzer : Constr->inits()) {
+if (Initzer->isBaseInitializer()) {
+  const auto *Base = Initzer->getBaseClass();
+  if (const auto *CtrCall = dyn_cast(
+  Initzer->getInit()->IgnoreParenImpCasts())) {
+if (!isCopyOrMoveLike(CtrCall->getConstructor()) ||
+!isAlmostTrivialConstructor(CtrCall->getConstructor()))
+  return false;
+if (const auto *Init = dyn_cast(
+CtrCall->getArg(0)->IgnoreParenImpCasts())) {
+  if (Init->getDecl() != Param)
+return false;
+} else {
+  return false;
+}
+  } else {
+return false;
+  }
+  InitBaseSet.insert(Base);
+} else if (Initzer->isMemberInitializer()) {
+  const auto *Field = Initzer->getMember();
+  const MemberExpr *InitMem;
+  if (Field->getType()->isScalarType()) {
+InitMem =
+dyn_cast(Initzer->getInit()->IgnoreParenImpCasts());
+  } else {
+if (const auto *CtrCall = dyn_cast(
+Initzer->getInit()->IgnoreParenImpCasts())) {
+  if (!isCopyOrMoveLike(CtrCall->getConstructor()) ||
+  !isAlmostTrivialConstructor(CtrCall->getConstr

Re: [PATCH] D22374: [analyzer] Copy and move constructors - ExprEngine extended for "almost trivial" copy and move constructors

2016-07-15 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware marked 6 inline comments as done.
baloghadamsoftware added a comment.

https://reviews.llvm.org/D22374



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


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-15 Thread Yaxun Liu via cfe-commits
yaxunl marked 11 inline comments as done.


Comment at: test/CodeGenOpenCL/sampler.cl:2
@@ +1,3 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - -O0 | 
FileCheck %s
+
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2

Fixed and moved to sema test.


Comment at: test/CodeGenOpenCL/sampler.cl:18
@@ +17,3 @@
+  sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | 
CLK_FILTER_NEAREST;
+  // CHECK-LABEL: define spir_kernel void @foo()
+  // CHECK: [[smp_ptr:%[A-Za-z0-9_\.]+]] = alloca %__opencl_sampler_t 
addrspace(2)*

Moved to sema tests.


https://reviews.llvm.org/D21567



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


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-15 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 64154.
yaxunl added a comment.

Turn on -Wspir-compat for spir target by default. Diagnose invalid sampler 
value at Sema instead of Codegen.


https://reviews.llvm.org/D21567

Files:
  include/clang/AST/OperationKinds.def
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/CodeGenOpenCL/sampler.cl
  test/SemaOpenCL/sampler_t.cl

Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -1,6 +1,25 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -triple spir-unknown-unknown
 
-constant sampler_t glb_smp = 5;
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+constant sampler_t glb_smp2; // expected-error{{variable in constant address space must be initialized}}
+global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
+
+constant sampler_t glb_smp4 = 0;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Filter Mode bits}}
+#endif
+
+constant sampler_t glb_smp5 = 0x1f;
+#ifdef CHECK_SAMPLER_VALUE
+// expected-warning@-2{{sampler initializer has invalid Addressing Mode bits}}
+#endif
 
 void foo(sampler_t);
 
@@ -10,22 +29,27 @@
 
 void kernel ker(sampler_t argsmp) {
   local sampler_t smp; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
-  const sampler_t const_smp = 7;
+  const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  const sampler_t const_smp2;
   foo(glb_smp);
+  foo(glb_smp2);
+  foo(glb_smp3);
   foo(const_smp);
+  foo(const_smp2);
+  foo(argsmp);
   foo(5); // expected-error{{sampler_t variable required - got 'int'}}
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
 }
 
 void bad(sampler_t*); // expected-error{{pointer to type 'sampler_t' is invalid in OpenCL}}
 
 void bar() {
-  sampler_t smp1 = 7;
-  sampler_t smp2 = 2;
+  sampler_t smp1 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+  sampler_t smp2 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST;
   smp1=smp2; //expected-error{{invalid operands to binary expression ('sampler_t' and 'sampler_t')}}
   smp1+1; //expected-error{{invalid operands to binary expression ('sampler_t' and 'int')}}
   &smp1; //expected-error{{invalid argument type 'sampler_t' to unary expression}}
   *smp2; //expected-error{{invalid argument type 'sampler_t' to unary expression}}
 }
 
-sampler_t bad(); //expected-error{{declaring function return value of type 'sampler_t' is not allowed}}
+sampler_t bad(void); //expected-error{{declaring function return value of type 'sampler_t' is not allowed}}
Index: test/CodeGenOpenCL/sampler.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/sampler.cl
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - -O0 | FileCheck %s
+
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+// CHECK: %__opencl_sampler_t = type opaque
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+// CHECK-NOT: glb_smp
+
+void fnc4smp(sampler_t s) {}
+// CHECK: define spir_func void @fnc4smp(%__opencl_sampler_t addrspace(2)* %
+
+kernel void foo() {
+  sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST;
+  // CHECK-LABEL: define spir_kernel void @foo()
+  // CHECK: [[smp_ptr:%[A-Za-z0-9_\.]+]] = alloca %__opencl_sampler_t 

Re: [PATCH] D22183: [SemObjC] Fix TypoExpr handling in TransformObjCDictionaryLiteral

2016-07-15 Thread Bruno Cardoso Lopes via cfe-commits
bruno updated this revision to Diff 64162.
bruno added a comment.

Thanks for the review Manman, I found a much better approach. Updated the patch 
to reflect that!


https://reviews.llvm.org/D22183

Files:
  lib/Parse/ParseObjc.cpp
  test/SemaObjC/objc-array-literal.m
  test/SemaObjC/objc-dictionary-literal.m

Index: test/SemaObjC/objc-dictionary-literal.m
===
--- test/SemaObjC/objc-dictionary-literal.m
+++ test/SemaObjC/objc-dictionary-literal.m
@@ -63,3 +63,10 @@
 	return 0;
 }
 
+enum XXXYYYZZZType { XXXYYYZZZTypeAny }; // expected-note {{'XXXYYYZZZTypeAny' declared here}}
+void foo() {
+  NSDictionary *d = @{
+@"A" : @(XXXYYYZZZTypeA), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeA'; did you mean 'XXXYYYZZZTypeAny'}}
+@"F" : @(XXXYYYZZZTypeSomethingSomething), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeSomethingSomething'}}
+  };
+}
Index: test/SemaObjC/objc-array-literal.m
===
--- test/SemaObjC/objc-array-literal.m
+++ test/SemaObjC/objc-array-literal.m
@@ -67,3 +67,11 @@
   x = @[ @"stuff", @"hello" "world"]; // expected-warning {{concatenated NSString literal for an NSArray expression}}
   return x;
 }
+
+enum XXXYYYZZZType { XXXYYYZZZTypeAny };
+void foo() {
+  NSArray *array = @[
+@(XXXYYYZZZTypeA), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeA'; did you mean 'XXXYYYZZZTypeAny'}}
+@(XXXYYYZZZTypeSomethingSomething) // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeSomethingSomething'}}
+  ];
+}
Index: lib/Parse/ParseObjc.cpp
===
--- lib/Parse/ParseObjc.cpp
+++ lib/Parse/ParseObjc.cpp
@@ -3414,6 +3414,7 @@
   ExprVector ElementExprs;   // array elements.
   ConsumeBracket(); // consume the l_square.
 
+  bool HasInvalidEltExpr = false;
   while (Tok.isNot(tok::r_square)) {
 // Parse list of array element expressions (all must be id types).
 ExprResult Res(ParseAssignmentExpression());
@@ -3425,11 +3426,15 @@
   return Res;
 }
 
+Res = Actions.CorrectDelayedTyposInExpr(Res.get());
+if (Res.isInvalid())
+  HasInvalidEltExpr = true;
+
 // Parse the ellipsis that indicates a pack expansion.
 if (Tok.is(tok::ellipsis))
   Res = Actions.ActOnPackExpansion(Res.get(), ConsumeToken());
 if (Res.isInvalid())
-  return true;
+  HasInvalidEltExpr = true;
 
 ElementExprs.push_back(Res.get());
 
@@ -3440,13 +3445,18 @@
 << tok::comma);
   }
   SourceLocation EndLoc = ConsumeBracket(); // location of ']'
+
+  if (HasInvalidEltExpr)
+return ExprError();
+
   MultiExprArg Args(ElementExprs);
   return Actions.BuildObjCArrayLiteral(SourceRange(AtLoc, EndLoc), Args);
 }
 
 ExprResult Parser::ParseObjCDictionaryLiteral(SourceLocation AtLoc) {
   SmallVector Elements; // dictionary elements.
   ConsumeBrace(); // consume the l_square.
+  bool HasInvalidEltExpr = false;
   while (Tok.isNot(tok::r_brace)) {
 // Parse the comma separated key : value expressions.
 ExprResult KeyExpr;
@@ -3476,8 +3486,15 @@
   return ValueExpr;
 }
 
-// Parse the ellipsis that designates this as a pack expansion.
-SourceLocation EllipsisLoc;
+// Check the key and value for possible typos
+KeyExpr = Actions.CorrectDelayedTyposInExpr(KeyExpr.get());
+ValueExpr = Actions.CorrectDelayedTyposInExpr(ValueExpr.get());
+if (KeyExpr.isInvalid() || ValueExpr.isInvalid())
+  HasInvalidEltExpr = true;
+
+// Parse the ellipsis that designates this as a pack expansion. Do not
+// ActOnPackExpansion here, leave it to template instantiation time where
+// we can get better diagnostics.
 if (getLangOpts().CPlusPlus)
   TryConsumeToken(tok::ellipsis, EllipsisLoc);
 
@@ -3493,6 +3510,9 @@
 << tok::comma);
   }
   SourceLocation EndLoc = ConsumeBrace();
+
+  if (HasInvalidEltExpr)
+return ExprError();
   
   // Create the ObjCDictionaryLiteral.
   return Actions.BuildObjCDictionaryLiteral(SourceRange(AtLoc, EndLoc),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r275577 - AMDGPU: Add Clang Builtin for v_lerp_u8

2016-07-15 Thread Wei Ding via cfe-commits
Author: wdng
Date: Fri Jul 15 11:43:03 2016
New Revision: 275577

URL: http://llvm.org/viewvc/llvm-project?rev=275577&view=rev
Log:
AMDGPU: Add Clang Builtin for v_lerp_u8

Differential Revision: http://reviews.llvm.org/D22380

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=275577&r1=275576&r2=275577&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Fri Jul 15 11:43:03 2016
@@ -61,6 +61,7 @@ BUILTIN(__builtin_amdgcn_frexp_exp, "id"
 BUILTIN(__builtin_amdgcn_frexp_expf, "if", "nc")
 BUILTIN(__builtin_amdgcn_fract, "dd", "nc")
 BUILTIN(__builtin_amdgcn_fractf, "ff", "nc")
+BUILTIN(__builtin_amdgcn_lerp, "UiUiUiUi", "nc")
 BUILTIN(__builtin_amdgcn_class, "bdi", "nc")
 BUILTIN(__builtin_amdgcn_classf, "bfi", "nc")
 BUILTIN(__builtin_amdgcn_cubeid, "", "nc")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=275577&r1=275576&r2=275577&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Jul 15 11:43:03 2016
@@ -7659,6 +7659,8 @@ Value *CodeGenFunction::EmitAMDGPUBuilti
   case AMDGPU::BI__builtin_amdgcn_fract:
   case AMDGPU::BI__builtin_amdgcn_fractf:
 return emitUnaryBuiltin(*this, E, Intrinsic::amdgcn_fract);
+  case AMDGPU::BI__builtin_amdgcn_lerp:
+return emitTernaryBuiltin(*this, E, Intrinsic::amdgcn_lerp);
   case AMDGPU::BI__builtin_amdgcn_class:
   case AMDGPU::BI__builtin_amdgcn_classf:
 return emitFPIntBuiltin(*this, E, Intrinsic::amdgcn_class);

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=275577&r1=275576&r2=275577&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Fri Jul 15 11:43:03 2016
@@ -192,6 +192,13 @@ void test_fract_f64(global int* out, dou
   *out = __builtin_amdgcn_fract(a);
 }
 
+// CHECK-LABEL: @test_lerp
+// CHECK: call i32 @llvm.amdgcn.lerp
+void test_lerp(global int* out, int a, int b, int c)
+{
+  *out = __builtin_amdgcn_lerp(a, b, c);
+}
+
 // CHECK-LABEL: @test_class_f32
 // CHECK: call i1 @llvm.amdgcn.class.f32
 void test_class_f32(global float* out, float a, int b)


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


Re: [PATCH] D22096: [OpenMP] Sema and parsing for 'target parallel for simd' pragma

2016-07-15 Thread Kelvin Li via cfe-commits
kkwli0 added a comment.

I update the test cases in https://reviews.llvm.org/D22417.


Repository:
  rL LLVM

https://reviews.llvm.org/D22096



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


Re: [PATCH] D19544: Pass for translating math intrinsics to math library calls.

2016-07-15 Thread Matt via cfe-commits
mmasten added a comment.

Thanks for reviewing. One concern I have going forward is the number of entries 
that will appear in the switch statement inside 
addVectorizableFunctionsFromVecLib(). I assume that the right thing to do is to 
replace this with something that is TableGen'd? Also, I just wanted to point 
out that some of these entries will result in svml calls that are not legal. 
E.g., __svml_sinf32 does not actually exist in the library, but can be 
legalized in case one explicitly sets a vector length of 32. Although these 
types of cases are probably not common, I wanted to bring this to your 
attention since the legalization piece of this work will be reviewed and 
committed separately. If needed, I can remove those entries until the 
legalization is in place.


https://reviews.llvm.org/D19544



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


r275589 - [objcmt] Don't add an #import of Foundation unnecessarily, if the NS_ENUM macro is already defined.

2016-07-15 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Jul 15 13:11:27 2016
New Revision: 275589

URL: http://llvm.org/viewvc/llvm-project?rev=275589&view=rev
Log:
[objcmt] Don't add an #import of Foundation unnecessarily, if the NS_ENUM macro 
is already defined.

Modified:
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result

Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=275589&r1=275588&r2=275589&view=diff
==
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Fri Jul 15 13:11:27 2016
@@ -1737,6 +1737,11 @@ bool ObjCMigrateASTConsumer::InsertFound
 return true;
   if (Loc.isInvalid())
 return false;
+  auto *nsEnumId = &Ctx.Idents.get("NS_ENUM");
+  if (PP.getMacroDefinitionAtLoc(nsEnumId, Loc)) {
+FoundationIncluded = true;
+return true;
+  }
   edit::Commit commit(*Editor);
   if (Ctx.getLangOpts().Modules)
 commit.insert(Loc, "#ifndef NS_ENUM\n@import Foundation;\n#endif\n");

Modified: cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result?rev=275589&r1=275588&r2=275589&view=diff
==
--- cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result Fri Jul 15 13:11:27 2016
@@ -19,9 +19,6 @@ typedef unsigned long long uint64_t;
 #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
 #define DEPRECATED  __attribute__((deprecated))
 
-#ifndef NS_ENUM
-#import 
-#endif
 typedef NS_ENUM(NSInteger, wibble) {
   blah,
   blarg


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


r275590 - [AST] Keep track of the left brace source location of a tag decl.

2016-07-15 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Jul 15 13:11:33 2016
New Revision: 275590

URL: http://llvm.org/viewvc/llvm-project?rev=275590&view=rev
Log:
[AST] Keep track of the left brace source location of a tag decl.

This is useful for source modification tools. There will be a follow-up commit 
using it.

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=275590&r1=275589&r2=275590&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Jul 15 13:11:33 2016
@@ -2781,7 +2781,7 @@ protected:
   /// the TU.
   unsigned IsCompleteDefinitionRequired : 1;
 private:
-  SourceLocation RBraceLoc;
+  SourceRange BraceRange;
 
   // A struct representing syntactic qualifier info,
   // to be used for the (uncommon) case of out-of-line declarations.
@@ -2843,8 +2843,8 @@ public:
   using redeclarable_base::getMostRecentDecl;
   using redeclarable_base::isFirstDecl;
 
-  SourceLocation getRBraceLoc() const { return RBraceLoc; }
-  void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
+  SourceRange getBraceRange() const { return BraceRange; }
+  void setBraceRange(SourceRange R) { BraceRange = R; }
 
   /// getInnerLocStart - Return SourceLocation representing start of source
   /// range ignoring outer template declarations.

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=275590&r1=275589&r2=275590&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Jul 15 13:11:33 2016
@@ -2039,7 +2039,7 @@ public:
   /// ActOnTagFinishDefinition - Invoked once we have finished parsing
   /// the definition of a tag (enumeration, class, struct, or union).
   void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl,
-SourceLocation RBraceLoc);
+SourceRange BraceRange);
 
   void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context);
 
@@ -2076,8 +2076,8 @@ public:
   SourceLocation IdLoc, IdentifierInfo *Id,
   AttributeList *Attrs,
   SourceLocation EqualLoc, Expr *Val);
-  void ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
- SourceLocation RBraceLoc, Decl *EnumDecl,
+  void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
+ Decl *EnumDecl,
  ArrayRef Elements,
  Scope *S, AttributeList *Attr);
 

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=275590&r1=275589&r2=275590&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Fri Jul 15 13:11:33 2016
@@ -3525,6 +3525,7 @@ SourceLocation TagDecl::getOuterLocStart
 }
 
 SourceRange TagDecl::getSourceRange() const {
+  SourceLocation RBraceLoc = BraceRange.getEnd();
   SourceLocation E = RBraceLoc.isValid() ? RBraceLoc : getLocation();
   return SourceRange(getOuterLocStart(), E);
 }

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=275590&r1=275589&r2=275590&view=diff
==
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Fri Jul 15 13:11:33 2016
@@ -778,7 +778,7 @@ ClassTemplateSpecializationDecl::getSour
  getSpecializationKind() == TSK_ExplicitInstantiationDefinition);
   if (getExternLoc().isValid())
 Begin = getExternLoc();
-  SourceLocation End = getRBraceLoc();
+  SourceLocation End = getBraceRange().getEnd();
   if (End.isInvalid())
 End = getTypeAsWritten()->getTypeLoc().getEndLoc();
   return SourceRange(Begin, End);

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=275590&r1=275589&r2=275590&view=diff
==
--- cfe/trunk/lib/Par

Re: [PATCH] D22171: [ObjC Availability] Implement parser support for Objective-C's @available

2016-07-15 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Manman


https://reviews.llvm.org/D22171



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


Re: [PATCH] D22334: Fix for Bug 28172 : clang crashes on invalid code (with too few arguments to __builtin_signbit) without any proper diagnostics.

2016-07-15 Thread George Burgess IV via cfe-commits
george.burgess.iv accepted this revision.
george.burgess.iv added a comment.
This revision is now accepted and ready to land.

LGTM; thanks for the patch!


https://reviews.llvm.org/D22334



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


Re: [PATCH] D22334: Fix for Bug 28172 : clang crashes on invalid code (with too few arguments to __builtin_signbit) without any proper diagnostics.

2016-07-15 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.
majnemer requested changes to this revision.
majnemer added a reviewer: majnemer.
majnemer added a comment.
This revision now requires changes to proceed.

I feel like this needs further validation.  For example, we crash on:

  int x = __builtin_signbit("1");


https://reviews.llvm.org/D22334



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


r275600 - [objcmt] Fix a buffer overflow crash than can occur while modernizing enums.

2016-07-15 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Jul 15 14:22:34 2016
New Revision: 275600

URL: http://llvm.org/viewvc/llvm-project?rev=275600&view=rev
Log:
[objcmt] Fix a buffer overflow crash than can occur while modernizing enums.

Note that due to the nature of the crash it requires libgmalloc or asan for it 
to crash consistently.

rdar://19932927

Added:
cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m
cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m.result
Modified:
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result

Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=275600&r1=275599&r2=275600&view=diff
==
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Fri Jul 15 14:22:34 2016
@@ -771,23 +771,11 @@ static void rewriteToNSMacroDecl(ASTCont
   ClassString += ", ";
   
   ClassString += TypedefDcl->getIdentifier()->getName();
-  ClassString += ')';
-  SourceLocation EndLoc;
-  if (EnumDcl->getIntegerTypeSourceInfo()) {
-TypeSourceInfo *TSourceInfo = EnumDcl->getIntegerTypeSourceInfo();
-TypeLoc TLoc = TSourceInfo->getTypeLoc();
-EndLoc = TLoc.getLocEnd();
-const char *lbrace = Ctx.getSourceManager().getCharacterData(EndLoc);
-unsigned count = 0;
-if (lbrace)
-  while (lbrace[count] != '{')
-++count;
-if (count > 0)
-  EndLoc = EndLoc.getLocWithOffset(count-1);
-  }
-  else
-EndLoc = EnumDcl->getLocStart();
-  SourceRange R(EnumDcl->getLocStart(), EndLoc);
+  ClassString += ") ";
+  SourceLocation EndLoc = EnumDcl->getBraceRange().getBegin();
+  if (EndLoc.isInvalid())
+return;
+  CharSourceRange R = CharSourceRange::getCharRange(EnumDcl->getLocStart(), 
EndLoc);
   commit.replace(R, ClassString);
   // This is to remove spaces between '}' and typedef name.
   SourceLocation StartTypedefLoc = EnumDcl->getLocEnd();
@@ -1900,18 +1888,20 @@ void ObjCMigrateASTConsumer::HandleTrans
 if (++N == DEnd)
   continue;
 if (const EnumDecl *ED = dyn_cast(*N)) {
-  if (++N != DEnd)
-if (const TypedefDecl *TDF = dyn_cast(*N)) {
-  // prefer typedef-follows-enum to enum-follows-typedef pattern.
-  if (migrateNSEnumDecl(Ctx, ED, TDF)) {
-++D; ++D;
-CacheObjCNSIntegerTypedefed(TD);
-continue;
+  if (canModify(ED)) {
+if (++N != DEnd)
+  if (const TypedefDecl *TDF = dyn_cast(*N)) {
+// prefer typedef-follows-enum to enum-follows-typedef pattern.
+if (migrateNSEnumDecl(Ctx, ED, TDF)) {
+  ++D; ++D;
+  CacheObjCNSIntegerTypedefed(TD);
+  continue;
+}
   }
+if (migrateNSEnumDecl(Ctx, ED, TD)) {
+  ++D;
+  continue;
 }
-  if (migrateNSEnumDecl(Ctx, ED, TD)) {
-++D;
-continue;
   }
 }
 CacheObjCNSIntegerTypedefed(TD);

Added: cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m?rev=275600&view=auto
==
--- cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m (added)
+++ cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m Fri Jul 15 14:22:34 2016
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x 
objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test 
-verify-transformed-files %s.result
+
+#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
+typedef long NSInteger;
+
+typedef enum : NSInteger {five} ApplicableEnum;
+
+typedef unsigned long mytd;
+
+#define MY_ENUM(name, type, ...) typedef enum : type { __VA_ARGS__ } name##_t
+MY_ENUM(MyEnum, unsigned int, One);

Added: cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m.result
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m.result?rev=275600&view=auto
==
--- cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m.result (added)
+++ cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m.result Fri Jul 15 14:22:34 2016
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x 
objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test 
-verify-transformed-files %s.result
+
+#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#define NS_OPTIONS(_type, _n

Re: r275600 - [objcmt] Fix a buffer overflow crash than can occur while modernizing enums.

2016-07-15 Thread Ben Langmuir via cfe-commits

> On Jul 15, 2016, at 12:22 PM, Argyrios Kyrtzidis via cfe-commits 
>  wrote:
> 
> Author: akirtzidis
> Date: Fri Jul 15 14:22:34 2016
> New Revision: 275600
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=275600&view=rev
> Log:
> [objcmt] Fix a buffer overflow crash than can occur while modernizing enums.
> 
> Note that due to the nature of the crash it requires libgmalloc or asan for 
> it to crash consistently.
> 
> rdar://19932927
> 
> Added:
>cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m
>cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m.result
> Modified:
>cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
>cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result
> 
> Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=275600&r1=275599&r2=275600&view=diff
> ==
> --- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
> +++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Fri Jul 15 14:22:34 2016
> @@ -771,23 +771,11 @@ static void rewriteToNSMacroDecl(ASTCont
>   ClassString += ", ";
> 
>   ClassString += TypedefDcl->getIdentifier()->getName();
> -  ClassString += ')';
> -  SourceLocation EndLoc;
> -  if (EnumDcl->getIntegerTypeSourceInfo()) {
> -TypeSourceInfo *TSourceInfo = EnumDcl->getIntegerTypeSourceInfo();
> -TypeLoc TLoc = TSourceInfo->getTypeLoc();
> -EndLoc = TLoc.getLocEnd();
> -const char *lbrace = Ctx.getSourceManager().getCharacterData(EndLoc);
> -unsigned count = 0;
> -if (lbrace)
> -  while (lbrace[count] != '{')
> -++count;
> -if (count > 0)
> -  EndLoc = EndLoc.getLocWithOffset(count-1);
> -  }
> -  else
> -EndLoc = EnumDcl->getLocStart();
> -  SourceRange R(EnumDcl->getLocStart(), EndLoc);
> +  ClassString += ") ";
> +  SourceLocation EndLoc = EnumDcl->getBraceRange().getBegin();
> +  if (EndLoc.isInvalid())
> +return;
> +  CharSourceRange R = CharSourceRange::getCharRange(EnumDcl->getLocStart(), 
> EndLoc);
>   commit.replace(R, ClassString);
>   // This is to remove spaces between '}' and typedef name.
>   SourceLocation StartTypedefLoc = EnumDcl->getLocEnd();
> @@ -1900,18 +1888,20 @@ void ObjCMigrateASTConsumer::HandleTrans
> if (++N == DEnd)
>   continue;
> if (const EnumDecl *ED = dyn_cast(*N)) {
> -  if (++N != DEnd)
> -if (const TypedefDecl *TDF = dyn_cast(*N)) {
> -  // prefer typedef-follows-enum to enum-follows-typedef pattern.
> -  if (migrateNSEnumDecl(Ctx, ED, TDF)) {
> -++D; ++D;
> -CacheObjCNSIntegerTypedefed(TD);
> -continue;
> +  if (canModify(ED)) {

Is this change tested anywhere?  It looks orthogonal to the source range 
changes.

> +if (++N != DEnd)
> +  if (const TypedefDecl *TDF = dyn_cast(*N)) {
> +// prefer typedef-follows-enum to enum-follows-typedef 
> pattern.
> +if (migrateNSEnumDecl(Ctx, ED, TDF)) {
> +  ++D; ++D;
> +  CacheObjCNSIntegerTypedefed(TD);
> +  continue;
> +}
>   }
> +if (migrateNSEnumDecl(Ctx, ED, TD)) {
> +  ++D;
> +  continue;
> }
> -  if (migrateNSEnumDecl(Ctx, ED, TD)) {
> -++D;
> -continue;
>   }
> }
> CacheObjCNSIntegerTypedefed(TD);
> 
> Added: cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m?rev=275600&view=auto
> ==
> --- cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m (added)
> +++ cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m Fri Jul 15 14:22:34 2016
> @@ -0,0 +1,14 @@
> +// RUN: rm -rf %t
> +// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x 
> objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
> +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test 
> -verify-transformed-files %s.result
> +
> +#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
> +#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
> +typedef long NSInteger;
> +
> +typedef enum : NSInteger {five} ApplicableEnum;
> +
> +typedef unsigned long mytd;
> +
> +#define MY_ENUM(name, type, ...) typedef enum : type { __VA_ARGS__ } name##_t
> +MY_ENUM(MyEnum, unsigned int, One);
> 
> Added: cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m.result
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m.result?rev=275600&view=auto
> ==
> --- cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m.result (added)
> +++ cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m.result Fri Jul 15 14:22:34 
> 2016
> @@ -

Re: r275600 - [objcmt] Fix a buffer overflow crash than can occur while modernizing enums.

2016-07-15 Thread Argyrios Kyrtzidis via cfe-commits

> On Jul 15, 2016, at 12:58 PM, Ben Langmuir  wrote:
> 
>> 
>> On Jul 15, 2016, at 12:22 PM, Argyrios Kyrtzidis via cfe-commits 
>>  wrote:
>> 
>> Author: akirtzidis
>> Date: Fri Jul 15 14:22:34 2016
>> New Revision: 275600
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=275600&view=rev
>> Log:
>> [objcmt] Fix a buffer overflow crash than can occur while modernizing enums.
>> 
>> Note that due to the nature of the crash it requires libgmalloc or asan for 
>> it to crash consistently.
>> 
>> rdar://19932927
>> 
>> Added:
>>   cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m
>>   cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m.result
>> Modified:
>>   cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
>>   cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result
>> 
>> Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=275600&r1=275599&r2=275600&view=diff
>> ==
>> --- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
>> +++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Fri Jul 15 14:22:34 2016
>> @@ -771,23 +771,11 @@ static void rewriteToNSMacroDecl(ASTCont
>>  ClassString += ", ";
>> 
>>  ClassString += TypedefDcl->getIdentifier()->getName();
>> -  ClassString += ')';
>> -  SourceLocation EndLoc;
>> -  if (EnumDcl->getIntegerTypeSourceInfo()) {
>> -TypeSourceInfo *TSourceInfo = EnumDcl->getIntegerTypeSourceInfo();
>> -TypeLoc TLoc = TSourceInfo->getTypeLoc();
>> -EndLoc = TLoc.getLocEnd();
>> -const char *lbrace = Ctx.getSourceManager().getCharacterData(EndLoc);
>> -unsigned count = 0;
>> -if (lbrace)
>> -  while (lbrace[count] != '{')
>> -++count;
>> -if (count > 0)
>> -  EndLoc = EndLoc.getLocWithOffset(count-1);
>> -  }
>> -  else
>> -EndLoc = EnumDcl->getLocStart();
>> -  SourceRange R(EnumDcl->getLocStart(), EndLoc);
>> +  ClassString += ") ";
>> +  SourceLocation EndLoc = EnumDcl->getBraceRange().getBegin();
>> +  if (EndLoc.isInvalid())
>> +return;
>> +  CharSourceRange R = CharSourceRange::getCharRange(EnumDcl->getLocStart(), 
>> EndLoc);
>>  commit.replace(R, ClassString);
>>  // This is to remove spaces between '}' and typedef name.
>>  SourceLocation StartTypedefLoc = EnumDcl->getLocEnd();
>> @@ -1900,18 +1888,20 @@ void ObjCMigrateASTConsumer::HandleTrans
>>if (++N == DEnd)
>>  continue;
>>if (const EnumDecl *ED = dyn_cast(*N)) {
>> -  if (++N != DEnd)
>> -if (const TypedefDecl *TDF = dyn_cast(*N)) {
>> -  // prefer typedef-follows-enum to enum-follows-typedef 
>> pattern.
>> -  if (migrateNSEnumDecl(Ctx, ED, TDF)) {
>> -++D; ++D;
>> -CacheObjCNSIntegerTypedefed(TD);
>> -continue;
>> +  if (canModify(ED)) {
> 
> Is this change tested anywhere?  It looks orthogonal to the source range 
> changes.

You are right that it is orthogonal. It avoids unnecessary work, it’s not 
changing behavior.

> 
>> +if (++N != DEnd)
>> +  if (const TypedefDecl *TDF = dyn_cast(*N)) {
>> +// prefer typedef-follows-enum to enum-follows-typedef 
>> pattern.
>> +if (migrateNSEnumDecl(Ctx, ED, TDF)) {
>> +  ++D; ++D;
>> +  CacheObjCNSIntegerTypedefed(TD);
>> +  continue;
>> +}
>>  }
>> +if (migrateNSEnumDecl(Ctx, ED, TD)) {
>> +  ++D;
>> +  continue;
>>}
>> -  if (migrateNSEnumDecl(Ctx, ED, TD)) {
>> -++D;
>> -continue;
>>  }
>>}
>>CacheObjCNSIntegerTypedefed(TD);
>> 
>> Added: cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m?rev=275600&view=auto
>> ==
>> --- cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m (added)
>> +++ cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m Fri Jul 15 14:22:34 2016
>> @@ -0,0 +1,14 @@
>> +// RUN: rm -rf %t
>> +// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x 
>> objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
>> +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test 
>> -verify-transformed-files %s.result
>> +
>> +#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
>> +#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : 
>> _type
>> +typedef long NSInteger;
>> +
>> +typedef enum : NSInteger {five} ApplicableEnum;
>> +
>> +typedef unsigned long mytd;
>> +
>> +#define MY_ENUM(name, type, ...) typedef enum : type { __VA_ARGS__ } 
>> name##_t
>> +MY_ENUM(MyEnum, unsigned int, One);
>> 
>> Added: cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m.result
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-ns-

Re: [PATCH] D15914: [OpenCL] Pipe builtin functions

2016-07-15 Thread Valery Pykhtin via cfe-commits
vpykhtin added a subscriber: vpykhtin.
vpykhtin added a comment.

Hi,

is there an intention to make this SPIR 2.0 (provisional) conformant? This 
would require changing resulting builtin names, changing pipe argument to 
"struct opencl.pipe*" and adding two trailing "size, alignment" parameters. If 
there is an interest for this a can try to submit a patch for review next week.


https://reviews.llvm.org/D15914



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


Re: [PATCH] D22273: Treat enumerator_too_large as an extension in MS ABI mode

2016-07-15 Thread Dave Bartolomeo via cfe-commits
DaveBartolomeo abandoned this revision.
DaveBartolomeo added a comment.

I'll attempt to fix the underlying issue 
https://llvm.org/bugs/show_bug.cgi?id=27098 instead.


https://reviews.llvm.org/D22273



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


r275609 - [test/objcmt] Add a follow-up test case for r275600.

2016-07-15 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Jul 15 15:40:24 2016
New Revision: 275609

URL: http://llvm.org/viewvc/llvm-project?rev=275609&view=rev
Log:
[test/objcmt] Add a follow-up test case for r275600.

Modified:
cfe/trunk/test/ARCMT/whitelisted/header1.h
cfe/trunk/test/ARCMT/whitelisted/header1.h.result
cfe/trunk/test/ARCMT/whitelisted/header2.h
cfe/trunk/test/ARCMT/whitelisted/header2.h.result
cfe/trunk/test/ARCMT/whitelisted/objcmt-with-whitelist.m

Modified: cfe/trunk/test/ARCMT/whitelisted/header1.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/whitelisted/header1.h?rev=275609&r1=275608&r2=275609&view=diff
==
--- cfe/trunk/test/ARCMT/whitelisted/header1.h (original)
+++ cfe/trunk/test/ARCMT/whitelisted/header1.h Fri Jul 15 15:40:24 2016
@@ -4,3 +4,5 @@
 -(void)setProp:(int)p;
 +(id)i1;
 @end
+
+typedef long NSInteger;

Modified: cfe/trunk/test/ARCMT/whitelisted/header1.h.result
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/whitelisted/header1.h.result?rev=275609&r1=275608&r2=275609&view=diff
==
--- cfe/trunk/test/ARCMT/whitelisted/header1.h.result (original)
+++ cfe/trunk/test/ARCMT/whitelisted/header1.h.result Fri Jul 15 15:40:24 2016
@@ -3,3 +3,5 @@
 @property (nonatomic) int prop;
 +(instancetype)i1;
 @end
+
+typedef long NSInteger;

Modified: cfe/trunk/test/ARCMT/whitelisted/header2.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/whitelisted/header2.h?rev=275609&r1=275608&r2=275609&view=diff
==
--- cfe/trunk/test/ARCMT/whitelisted/header2.h (original)
+++ cfe/trunk/test/ARCMT/whitelisted/header2.h Fri Jul 15 15:40:24 2016
@@ -1,4 +1,7 @@
 
+#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+typedef enum : NSInteger {five} ApplicableEnum;
+
 @interface I2 : NSObject
 -(int)prop;
 -(void)setProp:(int)p;

Modified: cfe/trunk/test/ARCMT/whitelisted/header2.h.result
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/whitelisted/header2.h.result?rev=275609&r1=275608&r2=275609&view=diff
==
--- cfe/trunk/test/ARCMT/whitelisted/header2.h.result (original)
+++ cfe/trunk/test/ARCMT/whitelisted/header2.h.result Fri Jul 15 15:40:24 2016
@@ -1,4 +1,7 @@
 
+#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+typedef NS_ENUM(NSInteger, ApplicableEnum) {five};
+
 @interface I2 : NSObject
 @property (nonatomic) int prop;
 @end

Modified: cfe/trunk/test/ARCMT/whitelisted/objcmt-with-whitelist.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/whitelisted/objcmt-with-whitelist.m?rev=275609&r1=275608&r2=275609&view=diff
==
--- cfe/trunk/test/ARCMT/whitelisted/objcmt-with-whitelist.m (original)
+++ cfe/trunk/test/ARCMT/whitelisted/objcmt-with-whitelist.m Fri Jul 15 
15:40:24 2016
@@ -1,7 +1,7 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-readwrite-property 
-objcmt-migrate-instancetype %s -triple x86_64-apple-darwin11 -migrate -o 
%t.remap
+// RUN: %clang_cc1 -objcmt-migrate-readwrite-property 
-objcmt-migrate-instancetype -objcmt-migrate-ns-macros %s -triple 
x86_64-apple-darwin11 -migrate -o %t.remap
 // RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files 
%S/header1.h.result %S/header2.h.result
-// RUN: %clang_cc1 -objcmt-migrate-readwrite-property 
-objcmt-migrate-instancetype -objcmt-white-list-dir-path=%S/Inputs %s -triple 
x86_64-apple-darwin11 -migrate -o %t.remap
+// RUN: %clang_cc1 -objcmt-migrate-readwrite-property 
-objcmt-migrate-instancetype -objcmt-migrate-ns-macros 
-objcmt-white-list-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate 
-o %t.remap
 // RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files 
%S/header1.h.result
 
 @interface NSObject


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


Re: r275600 - [objcmt] Fix a buffer overflow crash than can occur while modernizing enums.

2016-07-15 Thread Argyrios Kyrtzidis via cfe-commits

> On Jul 15, 2016, at 1:03 PM, Argyrios Kyrtzidis  wrote:
> 
>> 
>> On Jul 15, 2016, at 12:58 PM, Ben Langmuir > > wrote:
>> 
>>> 
>>> On Jul 15, 2016, at 12:22 PM, Argyrios Kyrtzidis via cfe-commits 
>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>> 
>>> Author: akirtzidis
>>> Date: Fri Jul 15 14:22:34 2016
>>> New Revision: 275600
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=275600&view=rev 
>>> 
>>> Log:
>>> [objcmt] Fix a buffer overflow crash than can occur while modernizing enums.
>>> 
>>> Note that due to the nature of the crash it requires libgmalloc or asan for 
>>> it to crash consistently.
>>> 
>>> rdar://19932927 
>>> 
>>> Added:
>>>   cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m
>>>   cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m.result
>>> Modified:
>>>   cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
>>>   cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result
>>> 
>>> Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=275600&r1=275599&r2=275600&view=diff
>>> ==
>>> --- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
>>> +++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Fri Jul 15 14:22:34 2016
>>> @@ -771,23 +771,11 @@ static void rewriteToNSMacroDecl(ASTCont
>>>  ClassString += ", ";
>>> 
>>>  ClassString += TypedefDcl->getIdentifier()->getName();
>>> -  ClassString += ')';
>>> -  SourceLocation EndLoc;
>>> -  if (EnumDcl->getIntegerTypeSourceInfo()) {
>>> -TypeSourceInfo *TSourceInfo = EnumDcl->getIntegerTypeSourceInfo();
>>> -TypeLoc TLoc = TSourceInfo->getTypeLoc();
>>> -EndLoc = TLoc.getLocEnd();
>>> -const char *lbrace = Ctx.getSourceManager().getCharacterData(EndLoc);
>>> -unsigned count = 0;
>>> -if (lbrace)
>>> -  while (lbrace[count] != '{')
>>> -++count;
>>> -if (count > 0)
>>> -  EndLoc = EndLoc.getLocWithOffset(count-1);
>>> -  }
>>> -  else
>>> -EndLoc = EnumDcl->getLocStart();
>>> -  SourceRange R(EnumDcl->getLocStart(), EndLoc);
>>> +  ClassString += ") ";
>>> +  SourceLocation EndLoc = EnumDcl->getBraceRange().getBegin();
>>> +  if (EndLoc.isInvalid())
>>> +return;
>>> +  CharSourceRange R = 
>>> CharSourceRange::getCharRange(EnumDcl->getLocStart(), EndLoc);
>>>  commit.replace(R, ClassString);
>>>  // This is to remove spaces between '}' and typedef name.
>>>  SourceLocation StartTypedefLoc = EnumDcl->getLocEnd();
>>> @@ -1900,18 +1888,20 @@ void ObjCMigrateASTConsumer::HandleTrans
>>>if (++N == DEnd)
>>>  continue;
>>>if (const EnumDecl *ED = dyn_cast(*N)) {
>>> -  if (++N != DEnd)
>>> -if (const TypedefDecl *TDF = dyn_cast(*N)) {
>>> -  // prefer typedef-follows-enum to enum-follows-typedef 
>>> pattern.
>>> -  if (migrateNSEnumDecl(Ctx, ED, TDF)) {
>>> -++D; ++D;
>>> -CacheObjCNSIntegerTypedefed(TD);
>>> -continue;
>>> +  if (canModify(ED)) {
>> 
>> Is this change tested anywhere?  It looks orthogonal to the source range 
>> changes.
> 
> You are right that it is orthogonal. It avoids unnecessary work, it’s not 
> changing behavior.

On second look, test case in r275609 shows behavior improvement.
Without this change, 'ARCMT/whitelisted/objcmt-with-whitelist.m’ will fail.

> 
>> 
>>> +if (++N != DEnd)
>>> +  if (const TypedefDecl *TDF = dyn_cast(*N)) {
>>> +// prefer typedef-follows-enum to enum-follows-typedef 
>>> pattern.
>>> +if (migrateNSEnumDecl(Ctx, ED, TDF)) {
>>> +  ++D; ++D;
>>> +  CacheObjCNSIntegerTypedefed(TD);
>>> +  continue;
>>> +}
>>>  }
>>> +if (migrateNSEnumDecl(Ctx, ED, TD)) {
>>> +  ++D;
>>> +  continue;
>>>}
>>> -  if (migrateNSEnumDecl(Ctx, ED, TD)) {
>>> -++D;
>>> -continue;
>>>  }
>>>}
>>>CacheObjCNSIntegerTypedefed(TD);
>>> 
>>> Added: cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m?rev=275600&view=auto
>>>  
>>> 
>>> ==
>>> --- cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m (added)
>>> +++ cfe/trunk/test/ARCMT/objcmt-ns-enum-crash.m Fri Jul 15 14:22:34 2016
>>> @@ -0,0 +1,14 @@
>>> +// RUN: rm -rf %t
>>> +// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s 
>>> -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple 
>>> x86_64-apple-darwin11
>>> +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test 
>>> -verify-transformed-files %

r275610 - Sema: support __declspec(dll*) on ObjC interfaces

2016-07-15 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Jul 15 15:41:10 2016
New Revision: 275610

URL: http://llvm.org/viewvc/llvm-project?rev=275610&view=rev
Log:
Sema: support __declspec(dll*) on ObjC interfaces

Extend the __declspec(dll*) attribute to cover ObjC interfaces.  This was
requested by Microsoft for their ObjC support.  Cover both import and export.
This only adds the semantic analysis portion of the support, code-generation
still remains outstanding.  Add some basic initial documentation on the
attributes that were previously empty.  Tweak the previous tests to use the
relative expected-warnings to make the tests easier to read.

Added:
cfe/trunk/test/SemaObjC/dllexport.m
cfe/trunk/test/SemaObjC/dllimport.m
cfe/trunk/test/SemaObjCXX/dllexport.mm
cfe/trunk/test/SemaObjCXX/dllimport.mm
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/test/Sema/dllexport.c
cfe/trunk/test/Sema/dllimport.c
cfe/trunk/test/SemaCXX/dllexport.cpp
cfe/trunk/test/SemaCXX/dllimport.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=275610&r1=275609&r2=275610&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Jul 15 15:41:10 2016
@@ -2087,14 +2087,14 @@ def MSStruct : InheritableAttr {
 
 def DLLExport : InheritableAttr, TargetSpecificAttr {
   let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
-  let Subjects = SubjectList<[Function, Var, CXXRecord]>;
-  let Documentation = [Undocumented];
+  let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
+  let Documentation = [DLLExportDocs];
 }
 
 def DLLImport : InheritableAttr, TargetSpecificAttr {
   let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
-  let Subjects = SubjectList<[Function, Var, CXXRecord]>;
-  let Documentation = [Undocumented];
+  let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>;
+  let Documentation = [DLLImportDocs];
 }
 
 def SelectAny : InheritableAttr {

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=275610&r1=275609&r2=275610&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri Jul 15 15:41:10 2016
@@ -67,6 +67,34 @@ TLS models are mutually exclusive.
   }];
 }
 
+def DLLExportDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+The ``__declspec(dllexport)`` attribute declares a variable, function, or
+Objective-C interface to be exported from the module.  It is available under 
the
+``-fdeclspec`` flag for compatibility with various compilers.  The primary use
+is for COFF object files which explicitly specify what interfaces are available
+for external use.  See the dllexport_ documentation on MSDN for more
+information.
+
+.. _dllexport: https://msdn.microsoft.com/en-us/library/3y1sfaz2.aspx
+  }];
+}
+
+def DLLImportDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+The ``__declspec(dllimport)`` attribute declares a variable, function, or
+Objective-C interface to be imported from an external module.  It is available
+under the ``-fdeclspec`` flag for compatibility with various compilers.  The
+primary use is for COFF object files which explicitly specify what interfaces
+are imported from external modules.  See the dllimport_ documentation on MSDN
+for more information.
+
+.. _dllimport: https://msdn.microsoft.com/en-us/library/3y1sfaz2.aspx
+  }];
+}
+
 def ThreadDocs : Documentation {
   let Category = DocCatVariable;
   let Content = [{

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=275610&r1=275609&r2=275610&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jul 15 15:41:10 
2016
@@ -2503,7 +2503,9 @@ def err_ifunc_resolver_params : Error<
   "ifunc resolver function must have no parameters">;
 def warn_attribute_wrong_decl_type : Warning<
   "%0 attribute only applies to %select{functions|unions|"
-  "variables and functions|functions and methods|parameters|"
+  "variables and functions|"
+  "functions, variables, and Objective-C interfaces|"
+  "functions and methods|parameters|"
   "functions, methods and blocks|functions, methods, and classes|"
   "functions, methods, and parameters|classe

r275612 - Push alias-declarations and alias-template declarations into scope even if

2016-07-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jul 15 15:53:25 2016
New Revision: 275612

URL: http://llvm.org/viewvc/llvm-project?rev=275612&view=rev
Log:
Push alias-declarations and alias-template declarations into scope even if
they're redeclarations. This is necessary in order for name lookup to correctly
find the most recent declaration of the name (which affects default template
argument lookup and cross-module merging, among other things).

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
cfe/trunk/test/CXX/drs/dr6xx.cpp
cfe/trunk/test/CXX/temp/temp.param/p15-cxx0x.cpp
cfe/trunk/test/Modules/submodules-merge-defs.cpp
cfe/trunk/test/SemaCXX/alias-template.cpp
cfe/trunk/test/SemaTemplate/alias-templates.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=275612&r1=275611&r2=275612&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Jul 15 15:53:25 2016
@@ -8885,9 +8885,7 @@ Decl *Sema::ActOnAliasDeclaration(Scope
 NewND = NewTD;
   }
 
-  if (!Redeclaration)
-PushOnScopeChains(NewND, S);
-
+  PushOnScopeChains(NewND, S);
   ActOnDocumentableDecl(NewND);
   return NewND;
 }

Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp?rev=275612&r1=275611&r2=275612&view=diff
==
--- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp Fri Jul 15 
15:53:25 2016
@@ -38,8 +38,8 @@ namespace VariableLengthArrays {
   using T = int[n]; // expected-error {{variable length array declaration not 
allowed at file scope}}
 
   const int m = 42;
-  using U = int[m]; // expected-note {{previous definition}}
-  using U = int[42]; // ok
+  using U = int[m];
+  using U = int[42]; // expected-note {{previous definition}}
   using U = int; // expected-error {{type alias redefinition with different 
types ('int' vs 'int [42]')}}
 
   void f() {

Modified: cfe/trunk/test/CXX/drs/dr6xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr6xx.cpp?rev=275612&r1=275611&r2=275612&view=diff
==
--- cfe/trunk/test/CXX/drs/dr6xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr6xx.cpp Fri Jul 15 15:53:25 2016
@@ -146,9 +146,9 @@ namespace dr616 { // dr616: no
 #if __cplusplus >= 201103L
   struct S { int n; } s;
   // FIXME: These should all be 'int &&'
-  using T = decltype(S().n); // expected-note 2{{previous}}
+  using T = decltype(S().n);
   using T = decltype(static_cast(s).n);
-  using T = decltype(S().*&S::n);
+  using T = decltype(S().*&S::n); // expected-note 2{{previous}}
   using T = decltype(static_cast(s).*&S::n); // expected-error 
{{different type}}
   using T = int&&; // expected-error {{different type}}
 #endif

Modified: cfe/trunk/test/CXX/temp/temp.param/p15-cxx0x.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.param/p15-cxx0x.cpp?rev=275612&r1=275611&r2=275612&view=diff
==
--- cfe/trunk/test/CXX/temp/temp.param/p15-cxx0x.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.param/p15-cxx0x.cpp Fri Jul 15 15:53:25 2016
@@ -102,10 +102,10 @@ using D1 = drop<3, int, char, double, lo
 using D1 = types;
 
 using T2 = take<4, int, char, double, long>::type; // expected-note 
{{previous}}
-using T2 = types;
 // FIXME: Desguar the types on the RHS in this diagnostic.
 // desired-error {{'types' vs 'types'}}
 using T2 = types; // expected-error {{'types' vs 'types::type, typename inner<_>::type, 
typename inner<_>::type, typename inner<_>::type>'}}
+using T2 = types;
 using D2 = drop<4, int, char, double, long>::type;
 using D2 = types<>;
 

Modified: cfe/trunk/test/Modules/submodules-merge-defs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/submodules-merge-defs.cpp?rev=275612&r1=275611&r2=275612&view=diff
==
--- cfe/trunk/test/Modules/submodules-merge-defs.cpp (original)
+++ cfe/trunk/test/Modules/submodules-merge-defs.cpp Fri Jul 15 15:53:25 2016
@@ -58,6 +58,11 @@ G::A pre_ga // expected-error +{{must be
 decltype(G::h) pre_gh = G::h; // expected-error +{{must be imported}}
 // expected-note@defs.h:51 +{{here}}
 
+int pre_h = H(); // expected-error +{{must be imported}}
+// expected-note@defs.h:56 +{{here}}
+using pre_i = I<>; // expected-error +{{must be imported}}
+// expected-note@defs.h:57 +{{here}}
+
 J<> pre_j; // expected-error {{declaration of 'J' must be imported}}
 #ifdef IMPORT_USE_2
 // expected-er

Re: [PATCH] D22392: [Sema] Fix an invalid nullability warning for binary conditional operators

2016-07-15 Thread Akira Hatanaka via cfe-commits
ahatanak added inline comments.


Comment at: lib/Sema/SemaExpr.cpp:7007
@@ +7006,3 @@
+/// expression.
+static QualType modifyNullability(QualType ResTy, Expr *RHSExpr,
+  ASTContext &Ctx) {

doug.gregor wrote:
> This name could be improved. You're not really 'modifying' nullability here; 
> in the general case, you're computing the appropriate nullability given the 
> LHS, RHS, and applying that to the result type.
I'm thinking about renaming it to computeConditionalNullability or something, 
but I'm open to suggestions.


Comment at: lib/Sema/SemaExpr.cpp:7024
@@ +7023,3 @@
+
+  NullabilityKind NewKind = GetNullability(RHSExpr->getType());
+

doug.gregor wrote:
> I'm fairly certain that more extensive testing will show that you need to 
> have the LHSExpr as well, to look at the nullability of both.
This patch only tries to correct the case where you have a binary (shorthand 
version) conditional operator "p0 ?: p1" where p1 is nonnulll and p0 is 
nullable, in which case the result type should be nonnull. I think this 
function behaves correctly in this particular case, but it's possible that I 
have overlooked some corner cases.

In any case, I think the focus of this patch was too narrow. I think I should 
fix the nullability of any conditional operators, not just the shorthand 
versions, in my next patch.


Comment at: lib/Sema/SemaExpr.cpp:7030
@@ +7029,3 @@
+  // Create a new AttributedType with the new nullability kind.
+  QualType NewTy = ResTy.getDesugaredType(Ctx);
+  auto NewAttr = AttributedType::getNullabilityAttrKind(NewKind);

doug.gregor wrote:
>  It would be better to only unwrap sugar until we hit the 
> nullability-attributed type, then replace it.
I think we need to unwrap sugar more than once until there are no more 
nullability-attributed types in some cases. For example, it's possible to have 
multiple levels of typedefs having nullability markers:

```
typedef int * IntP;
typedef IntP _Nullable NullableIntP0;
typedef NullableIntP0 _Nullable NullableIntP1;
```


Comment at: test/Sema/nullability.c:137
@@ +136,3 @@
+
+  int * _Nonnull p2 = p0 ?: p1; // no warnings here.
+}

doug.gregor wrote:
> You really need much more testing coverage here, e.g., for ternary operators 
> where the types on the second and third arguments are different types (say, 
> superclass/subclass pointer), the nullability is on either argument, etc. The 
> ternary operator, especially in C++, has a ton of different cases that you 
> need to look at.
Yes, I'll have more test cases in my next patch.


https://reviews.llvm.org/D22392



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


r275622 - AMDGPU: Update for rsq intrinsic changes

2016-07-15 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Fri Jul 15 16:33:02 2016
New Revision: 275622

URL: http://llvm.org/viewvc/llvm-project?rev=275622&view=rev
Log:
AMDGPU: Update for rsq intrinsic changes

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=275622&r1=275621&r2=275622&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Fri Jul 15 16:33:02 2016
@@ -96,12 +96,13 @@ BUILTIN(__builtin_r600_read_tidig_x, "Ui
 BUILTIN(__builtin_r600_read_tidig_y, "Ui", "nc")
 BUILTIN(__builtin_r600_read_tidig_z, "Ui", "nc")
 
+BUILTIN(__builtin_r600_recipsqrt_ieee, "dd", "nc")
+BUILTIN(__builtin_r600_recipsqrt_ieeef, "ff", "nc")
+
 
//===--===//
 // Legacy names with amdgpu prefix
 
//===--===//
 
-BUILTIN(__builtin_amdgpu_rsq, "dd", "nc")
-BUILTIN(__builtin_amdgpu_rsqf, "ff", "nc")
 BUILTIN(__builtin_amdgpu_ldexp, "ddi", "nc")
 BUILTIN(__builtin_amdgpu_ldexpf, "ffi", "nc")
 

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=275622&r1=275621&r2=275622&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Jul 15 16:33:02 2016
@@ -7671,19 +7671,6 @@ Value *CodeGenFunction::EmitAMDGPUBuilti
 CI->setConvergent();
 return CI;
   }
-  // Legacy amdgpu prefix
-  case AMDGPU::BI__builtin_amdgpu_rsq:
-  case AMDGPU::BI__builtin_amdgpu_rsqf: {
-if (getTarget().getTriple().getArch() == Triple::amdgcn)
-  return emitUnaryBuiltin(*this, E, Intrinsic::amdgcn_rsq);
-return emitUnaryBuiltin(*this, E, Intrinsic::r600_rsq);
-  }
-  case AMDGPU::BI__builtin_amdgpu_ldexp:
-  case AMDGPU::BI__builtin_amdgpu_ldexpf: {
-if (getTarget().getTriple().getArch() == Triple::amdgcn)
-  return emitFPIntBuiltin(*this, E, Intrinsic::amdgcn_ldexp);
-return emitFPIntBuiltin(*this, E, Intrinsic::AMDGPU_ldexp);
-  }
 
   // amdgcn workitem
   case AMDGPU::BI__builtin_amdgcn_workitem_id_x:
@@ -7693,13 +7680,24 @@ Value *CodeGenFunction::EmitAMDGPUBuilti
   case AMDGPU::BI__builtin_amdgcn_workitem_id_z:
 return emitRangedBuiltin(*this, Intrinsic::amdgcn_workitem_id_z, 0, 1024);
 
-  // r600 workitem
+  // r600 intrinsics
+  case AMDGPU::BI__builtin_r600_recipsqrt_ieee:
+  case AMDGPU::BI__builtin_r600_recipsqrt_ieeef:
+return emitUnaryBuiltin(*this, E, Intrinsic::r600_recipsqrt_ieee);
   case AMDGPU::BI__builtin_r600_read_tidig_x:
 return emitRangedBuiltin(*this, Intrinsic::r600_read_tidig_x, 0, 1024);
   case AMDGPU::BI__builtin_r600_read_tidig_y:
 return emitRangedBuiltin(*this, Intrinsic::r600_read_tidig_y, 0, 1024);
   case AMDGPU::BI__builtin_r600_read_tidig_z:
 return emitRangedBuiltin(*this, Intrinsic::r600_read_tidig_z, 0, 1024);
+
+   // Legacy amdgpu prefix
+  case AMDGPU::BI__builtin_amdgpu_ldexp:
+  case AMDGPU::BI__builtin_amdgpu_ldexpf: {
+if (getTarget().getTriple().getArch() == Triple::amdgcn)
+  return emitFPIntBuiltin(*this, E, Intrinsic::amdgcn_ldexp);
+return emitFPIntBuiltin(*this, E, Intrinsic::AMDGPU_ldexp);
+  }
   default:
 return nullptr;
   }

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=275622&r1=275621&r2=275622&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Fri Jul 15 16:33:02 2016
@@ -270,20 +270,6 @@ void test_read_exec(global ulong* out) {
 
 // Legacy intrinsics with AMDGPU prefix
 
-// CHECK-LABEL: @test_legacy_rsq_f32
-// CHECK: call float @llvm.amdgcn.rsq.f32
-void test_legacy_rsq_f32(global float* out, float a)
-{
-  *out = __builtin_amdgpu_rsqf(a);
-}
-
-// CHECK-LABEL: @test_legacy_rsq_f64
-// CHECK: call double @llvm.amdgcn.rsq.f64
-void test_legacy_rsq_f64(global double* out, double a)
-{
-  *out = __builtin_amdgpu_rsq(a);
-}
-
 // CHECK-LABEL: @test_legacy_ldexp_f32
 // CHECK: call float @llvm.amdgcn.ldexp.f32
 void test_legacy_ldexp_f32(global float* out, float a, int b)

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl?rev=275622&r1=275621&r2=275622&view=diff

r275623 - AMDGPU: Remove legacy ldexp builtin

2016-07-15 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Fri Jul 15 16:33:06 2016
New Revision: 275623

URL: http://llvm.org/viewvc/llvm-project?rev=275623&view=rev
Log:
AMDGPU: Remove legacy ldexp builtin

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=275623&r1=275622&r2=275623&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Fri Jul 15 16:33:06 2016
@@ -99,12 +99,5 @@ BUILTIN(__builtin_r600_read_tidig_z, "Ui
 BUILTIN(__builtin_r600_recipsqrt_ieee, "dd", "nc")
 BUILTIN(__builtin_r600_recipsqrt_ieeef, "ff", "nc")
 
-//===--===//
-// Legacy names with amdgpu prefix
-//===--===//
-
-BUILTIN(__builtin_amdgpu_ldexp, "ddi", "nc")
-BUILTIN(__builtin_amdgpu_ldexpf, "ffi", "nc")
-
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=275623&r1=275622&r2=275623&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Jul 15 16:33:06 2016
@@ -7690,14 +7690,6 @@ Value *CodeGenFunction::EmitAMDGPUBuilti
 return emitRangedBuiltin(*this, Intrinsic::r600_read_tidig_y, 0, 1024);
   case AMDGPU::BI__builtin_r600_read_tidig_z:
 return emitRangedBuiltin(*this, Intrinsic::r600_read_tidig_z, 0, 1024);
-
-   // Legacy amdgpu prefix
-  case AMDGPU::BI__builtin_amdgpu_ldexp:
-  case AMDGPU::BI__builtin_amdgpu_ldexpf: {
-if (getTarget().getTriple().getArch() == Triple::amdgcn)
-  return emitFPIntBuiltin(*this, E, Intrinsic::amdgcn_ldexp);
-return emitFPIntBuiltin(*this, E, Intrinsic::AMDGPU_ldexp);
-  }
   default:
 return nullptr;
   }

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=275623&r1=275622&r2=275623&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Fri Jul 15 16:33:06 2016
@@ -268,22 +268,6 @@ void test_read_exec(global ulong* out) {
 
 // CHECK: declare i64 @llvm.read_register.i64(metadata) 
#[[NOUNWIND_READONLY:[0-9]+]]
 
-// Legacy intrinsics with AMDGPU prefix
-
-// CHECK-LABEL: @test_legacy_ldexp_f32
-// CHECK: call float @llvm.amdgcn.ldexp.f32
-void test_legacy_ldexp_f32(global float* out, float a, int b)
-{
-  *out = __builtin_amdgpu_ldexpf(a, b);
-}
-
-// CHECK-LABEL: @test_legacy_ldexp_f64
-// CHECK: call double @llvm.amdgcn.ldexp.f64
-void test_legacy_ldexp_f64(global double* out, double a, int b)
-{
-  *out = __builtin_amdgpu_ldexp(a, b);
-}
-
 // CHECK-LABEL: @test_kernarg_segment_ptr
 // CHECK: call i8 addrspace(2)* @llvm.amdgcn.kernarg.segment.ptr()
 void test_kernarg_segment_ptr(__attribute__((address_space(2))) unsigned char 
** out)

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl?rev=275623&r1=275622&r2=275623&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl Fri Jul 15 16:33:06 2016
@@ -17,22 +17,6 @@ void test_recipsqrt_ieee_f64(global doub
 }
 #endif
 
-// CHECK-LABEL: @test_legacy_ldexp_f32
-// CHECK: call float @llvm.AMDGPU.ldexp.f32
-void test_legacy_ldexp_f32(global float* out, float a, int b)
-{
-  *out = __builtin_amdgpu_ldexpf(a, b);
-}
-
-#if cl_khr_fp64
-// XCHECK-LABEL: @test_legacy_ldexp_f64
-// XCHECK: call double @llvm.AMDGPU.ldexp.f64
-void test_legacy_ldexp_f64(global double* out, double a, int b)
-{
-  *out = __builtin_amdgpu_ldexp(a, b);
-}
-#endif
-
 // CHECK-LABEL: @test_implicitarg_ptr
 // CHECK: call i8 addrspace(7)* @llvm.r600.implicitarg.ptr()
 void test_implicitarg_ptr(__attribute__((address_space(7))) unsigned char ** 
out)


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


r275624 - Revert r275481, r275490. This broke modules bootstrap.

2016-07-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jul 15 16:33:46 2016
New Revision: 275624

URL: http://llvm.org/viewvc/llvm-project?rev=275624&view=rev
Log:
Revert r275481, r275490. This broke modules bootstrap.

Removed:
cfe/trunk/test/Modules/Inputs/unused-global-init/
cfe/trunk/test/Modules/unused-global-init.cpp
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=275624&r1=275623&r2=275624&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Fri Jul 15 16:33:46 2016
@@ -613,7 +613,7 @@ private:
   /// \brief A mapping from each of the hidden submodules to the deserialized
   /// declarations in that submodule that could be made visible.
   HiddenNamesMapType HiddenNamesMap;
-
+  
   
   /// \brief A module import, export, or conflict that hasn't yet been 
resolved.
   struct UnresolvedModuleRef {
@@ -947,24 +947,6 @@ private:
   /// Objective-C protocols.
   std::deque InterestingDecls;
 
-  /// \brief Contains imported interesting declarations from modules that have
-  /// not yet themselves been imported, even indirectly.
-  typedef llvm::SmallVector ModuleInterestingDecls;
-
-  /// Map from top-level modules to their list of interesting declarations.
-  /// Each map entry may be in one of three states: no entry means we've never
-  /// seen this module and never transitively imported it. A null pointer means
-  /// we're not tracking interesting decls: they should be handed straight to
-  /// the consumer because we've transitively imported this module already.
-  /// Otherwise, a list of pending interesting decls.
-  ///
-  /// As an added twist, declarations that are re-exported are listed against
-  /// the owning module and the re-exporting one, but the owning module's list
-  /// is definitive: the decl is there if and only if it has not been handed to
-  /// the consumer already.
-  llvm::DenseMap
-  UnimportedModuleInterestingDecls;
-
   /// \brief The list of redeclaration chains that still need to be 
   /// reconstructed, and the local offset to the corresponding list
   /// of redeclarations.
@@ -1267,9 +1249,6 @@ private:
   llvm::iterator_range
   getModuleFileLevelDecls(ModuleFile &Mod);
 
-  void addInterestingDecl(Decl *D,
-  llvm::Optional OwnerOverride = llvm::None);
-
   void PassInterestingDeclsToConsumer();
   void PassInterestingDeclToConsumer(Decl *D);
 
@@ -1407,11 +1386,6 @@ public:
   /// \brief Make the names within this set of hidden names visible.
   void makeNamesVisible(const HiddenNames &Names, Module *Owner);
 
-  /// \brief Mark a module as "used". This implies that any global initializers
-  /// of declarations contained transitively within it should be run as part of
-  /// the current compilation.
-  void markModuleUsed(Module *M);
-
   /// \brief Take the AST callbacks listener.
   std::unique_ptr takeListener() {
 return std::move(Listener);

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=275624&r1=275623&r2=275624&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Jul 15 16:33:46 2016
@@ -2691,8 +2691,6 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
 case EAGERLY_DESERIALIZED_DECLS:
   // FIXME: Skip reading this record if our ASTConsumer doesn't care
   // about "interesting" decls (for instance, if we're building a module).
-  // FIXME: Store this somewhere per-module and defer until
-  // markModuleReferenced is called.
   for (unsigned I = 0, N = Record.size(); I != N; ++I)
 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
   break;
@@ -3363,9 +3361,6 @@ void ASTReader::makeNamesVisible(const H
 void ASTReader::makeModuleVisible(Module *Mod,
   Module::NameVisibilityKind NameVisibility,
   SourceLocation ImportLoc) {
-  // If we import anything from the module in any way, then it is used.
-  markModuleUsed(Mod);
-
   llvm::SmallPtrSet Visited;
   SmallVector Stack;
   Stack.push_back(Mod);
@@ -6732,95 +6727,10 @@ void ASTReader::PassInterestingDeclsToCo
 Decl *D = InterestingDecls.front();
 InterestingDecls.pop_front();
 
-// If we have found an interesting ImportDecl, then its imported module
-// is considered used.
-if (auto *ID = dyn_cast(D))
-  markModuleUsed(ID->getImportedModule());
-
 PassInteresti

[PATCH] D22426: Fix automatic detection of ARM MSVC toolset in clang.exe

2016-07-15 Thread Dave Bartolomeo via cfe-commits
DaveBartolomeo created this revision.
DaveBartolomeo added reviewers: rnk, majnemer, cfe-commits.
Herald added subscribers: rengolin, aemerson.

Clang was failing to find the ARM version of the MSVC link.exe, even though it 
could correctly find link.exe for x86 and x64. Clang looks in the 
%VCINSTALLDIR%\VC\bin directory for link.exe when targeting x86 (finding the 
x86-hosted, x86-targeting tools), the VC\bin\amd64 directory when targeting x64 
(finding the x64-hosted, x64-targeting tools), and the non-existent VC\bin\arm 
directory when targeting ARM (which is where the ARM-hosted tools would be if 
they existed). I just switched it to always look for the x86-hosted tools for 
all targets, in VC\bin\x86, VC\bin\x86_amd64, or VC\bin\x86_arm.


https://reviews.llvm.org/D22426

Files:
  lib/Driver/MSVCToolChain.cpp

Index: lib/Driver/MSVCToolChain.cpp
===
--- lib/Driver/MSVCToolChain.cpp
+++ lib/Driver/MSVCToolChain.cpp
@@ -457,10 +457,10 @@
   case llvm::Triple::x86:
 break;
   case llvm::Triple::x86_64:
-llvm::sys::path::append(BinDir, "amd64");
+llvm::sys::path::append(BinDir, "x86_amd64");
 break;
   case llvm::Triple::arm:
-llvm::sys::path::append(BinDir, "arm");
+llvm::sys::path::append(BinDir, "x86_arm");
 break;
   default:
 // Whatever this is, Visual Studio doesn't have a toolchain for it.


Index: lib/Driver/MSVCToolChain.cpp
===
--- lib/Driver/MSVCToolChain.cpp
+++ lib/Driver/MSVCToolChain.cpp
@@ -457,10 +457,10 @@
   case llvm::Triple::x86:
 break;
   case llvm::Triple::x86_64:
-llvm::sys::path::append(BinDir, "amd64");
+llvm::sys::path::append(BinDir, "x86_amd64");
 break;
   case llvm::Triple::arm:
-llvm::sys::path::append(BinDir, "arm");
+llvm::sys::path::append(BinDir, "x86_arm");
 break;
   default:
 // Whatever this is, Visual Studio doesn't have a toolchain for it.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22392: [Sema] Fix an invalid nullability warning for binary conditional operators

2016-07-15 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

I'm thinking about taking the following steps to compute the nullability of 
ternary operators.

The first step is to compute the "merged" nullability of the LHS and RHS.

For normal ternary operators (not the shorthand version):

- If both LHS and RHS have the same nullability (one of nonnull, nullable, 
null_unspecified, or none), pick that as the merged nullability.
- Otherwise, if either side is nullable, the merged nullability is nullable too.
- Otherwise, if either side is nonnull, pick the nullability of the other side. 
For example, if (LHS,RHS) == (nonnull, none), the merged nullability is none 
because we can't guarantee that the result is nonnull.
- Otherwise, the nullability is either null_unspecified or none. I think we can 
pick either one in this case.

For binary conditional operators like "p0 ?: p1":

- If the LHS (p0) is nonnull, the merged nullability is nonnull.
- Otherwise, the merged nullability is the nullability of the RHS (p1).

Once we have the merged nullability, the next step is to compare it with the 
result's nullability. If the nullability kinds differ, a new type that has the 
merged nullability is created.

Note that it looks like we might be able to simplify the steps described above 
if we take advantage of the fact that clang only warns when a nullable pointer 
is assigned/passed to a nonnull pointer (I don't think clang issues any 
warnings, for example, when a null_unspecified pointer is assigned to a nonnull 
pointer).


https://reviews.llvm.org/D22392



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


Re: [PATCH] D21104: [CodeGen][ObjC] Block captures should inherit the type of the captured field in the enclosing lambda or block

2016-07-15 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 64199.
ahatanak added a comment.

Rebase.


https://reviews.llvm.org/D21104

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBlocks.h
  test/CodeGenObjCXX/lambda-expressions.mm

Index: test/CodeGenObjCXX/lambda-expressions.mm
===
--- test/CodeGenObjCXX/lambda-expressions.mm
+++ test/CodeGenObjCXX/lambda-expressions.mm
@@ -4,6 +4,8 @@
 typedef int (^fp)();
 fp f() { auto x = []{ return 3; }; return x; }
 
+// ARC: %[[LAMBDACLASS:.*]] = type { i32 }
+
 // MRC: @OBJC_METH_VAR_NAME{{.*}} = private global [5 x i8] c"copy\00"
 // MRC: @OBJC_METH_VAR_NAME{{.*}} = private global [12 x i8] c"autorelease\00"
 // MRC-LABEL: define i32 ()* @_Z1fv(
@@ -60,6 +62,40 @@
 }
 @end
 
+// ARC: define void @_ZN13LambdaCapture4foo1ERi(i32* dereferenceable(4) %{{.*}})
+// ARC:   %[[CAPTURE0:.*]] = getelementptr inbounds %[[LAMBDACLASS]], %[[LAMBDACLASS]]* %{{.*}}, i32 0, i32 0
+// ARC:   store i32 %{{.*}}, i32* %[[CAPTURE0]]
+
+// ARC: define internal void @"_ZZN13LambdaCapture4foo1ERiENK3$_3clEv"(%[[LAMBDACLASS]]* %{{.*}})
+// ARC:   %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>
+// ARC:   %[[CAPTURE1:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>* %[[BLOCK]], i32 0, i32 5
+// ARC:   store i32 %{{.*}}, i32* %[[CAPTURE1]]
+
+// ARC: define internal void @"___ZZN13LambdaCapture4foo1ERiENK3$_3clEv_block_invoke"
+// ARC:   %[[CAPTURE2:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>* %{{.*}}, i32 0, i32 5
+// ARC:   store i32 %{{.*}}, i32* %[[CAPTURE2]]
+
+// ARC: define internal void @"___ZZN13LambdaCapture4foo1ERiENK3$_3clEv_block_invoke_2"(i8* %{{.*}})
+// ARC:   %[[CAPTURE3:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32 }>* %{{.*}}, i32 0, i32 5
+// ARC:   %[[V1:.*]] = load i32, i32* %[[CAPTURE3]]
+// ARC:   store i32 %[[V1]], i32* @_ZN13LambdaCapture1iE
+
+namespace LambdaCapture {
+  int i;
+  void foo1(int &a) {
+auto lambda = [a]{
+  auto block1 = ^{
+auto block2 = ^{
+  i = a;
+};
+block2();
+  };
+  block1();
+};
+lambda();
+  }
+}
+
 // ARC-LABEL: define linkonce_odr i32 ()* @_ZZNK13StaticMembersIfE1fMUlvE_clEvENKUlvE_cvU13block_pointerFivEEv
 
 // Check lines for BlockInLambda test below
Index: lib/CodeGen/CGBlocks.h
===
--- lib/CodeGen/CGBlocks.h
+++ lib/CodeGen/CGBlocks.h
@@ -163,6 +163,11 @@
 EHScopeStack::stable_iterator Cleanup;
 CharUnits::QuantityType Offset;
 
+/// Type of the capture field. Normally, this is identical to the type of
+/// the capture's VarDecl, but can be different if there is an enclosing
+/// lambda.
+QualType FieldType;
+
   public:
 bool isIndex() const { return (Data & 1) != 0; }
 bool isConstant() const { return !isIndex(); }
@@ -189,10 +194,16 @@
   return reinterpret_cast(Data);
 }
 
-static Capture makeIndex(unsigned index, CharUnits offset) {
+QualType fieldType() const {
+  return FieldType;
+}
+
+static Capture makeIndex(unsigned index, CharUnits offset,
+ QualType FieldType) {
   Capture v;
   v.Data = (index << 1) | 1;
   v.Offset = offset.getQuantity();
+  v.FieldType = FieldType;
   return v;
 }
 
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -194,13 +194,14 @@
 Qualifiers::ObjCLifetime Lifetime;
 const BlockDecl::Capture *Capture; // null for 'this'
 llvm::Type *Type;
+QualType FieldType;
 
 BlockLayoutChunk(CharUnits align, CharUnits size,
  Qualifiers::ObjCLifetime lifetime,
  const BlockDecl::Capture *capture,
- llvm::Type *type)
+ llvm::Type *type, QualType fieldType)
   : Alignment(align), Size(size), Lifetime(lifetime),
-Capture(capture), Type(type) {}
+Capture(capture), Type(type), FieldType(fieldType) {}
 
 /// Tell the block info that this chunk has the given field index.
 void setIndex(CGBlockInfo &info, unsigned index, CharUnits offset) {
@@ -208,8 +209,8 @@
 info.CXXThisIndex = index;
 info.CXXThisOffset = offset;
   } else {
-info.Captures.insert({Capture->getVariable(),
-  CGBlockInfo::Capture::makeIndex(index, offset)});
+auto C = CGBlockInfo::Capture::makeIndex(index, offset, FieldType);
+info.Captures.insert({Capture->getVariable(), C});
   }
 }
   };
@@ -358,7 +359,7 @@
 
 layout

r275630 - [index] Create different USR if a property is a class property.

2016-07-15 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Jul 15 17:18:19 2016
New Revision: 275630

URL: http://llvm.org/viewvc/llvm-project?rev=275630&view=rev
Log:
[index] Create different USR if a property is a class property.

Avoids USR conflicts between class & instance properties of the same name.

Modified:
cfe/trunk/include/clang/Index/USRGeneration.h
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/test/Index/index-decls.m
cfe/trunk/tools/libclang/CIndexUSRs.cpp

Modified: cfe/trunk/include/clang/Index/USRGeneration.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/USRGeneration.h?rev=275630&r1=275629&r2=275630&view=diff
==
--- cfe/trunk/include/clang/Index/USRGeneration.h (original)
+++ cfe/trunk/include/clang/Index/USRGeneration.h Fri Jul 15 17:18:19 2016
@@ -44,7 +44,7 @@ void generateUSRForObjCMethod(StringRef
   raw_ostream &OS);
 
 /// \brief Generate a USR fragment for an Objective-C property.
-void generateUSRForObjCProperty(StringRef Prop, raw_ostream &OS);
+void generateUSRForObjCProperty(StringRef Prop, bool isClassProp, raw_ostream 
&OS);
 
 /// \brief Generate a USR fragment for an Objective-C protocol.
 void generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS);

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=275630&r1=275629&r2=275630&view=diff
==
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Fri Jul 15 17:18:19 2016
@@ -138,8 +138,8 @@ public:
   }
 
   /// Generate a USR fragment for an Objective-C property.
-  void GenObjCProperty(StringRef prop) {
-generateUSRForObjCProperty(prop, Out);
+  void GenObjCProperty(StringRef prop, bool isClassProp) {
+generateUSRForObjCProperty(prop, isClassProp, Out);
   }
 
   /// Generate a USR for an Objective-C protocol.
@@ -411,7 +411,7 @@ void USRGenerator::VisitObjCPropertyDecl
 Visit(ID);
   else
 Visit(cast(D->getDeclContext()));
-  GenObjCProperty(D->getName());
+  GenObjCProperty(D->getName(), D->isClassProperty());
 }
 
 void USRGenerator::VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D) {
@@ -864,8 +864,9 @@ void clang::index::generateUSRForObjCMet
   OS << (IsInstanceMethod ? "(im)" : "(cm)") << Sel;
 }
 
-void clang::index::generateUSRForObjCProperty(StringRef Prop, raw_ostream &OS) 
{
-  OS << "(py)" << Prop;
+void clang::index::generateUSRForObjCProperty(StringRef Prop, bool isClassProp,
+  raw_ostream &OS) {
+  OS << (isClassProp ? "(cpy)" : "(py)") << Prop;
 }
 
 void clang::index::generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS) 
{

Modified: cfe/trunk/test/Index/index-decls.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-decls.m?rev=275630&r1=275629&r2=275630&view=diff
==
--- cfe/trunk/test/Index/index-decls.m (original)
+++ cfe/trunk/test/Index/index-decls.m Fri Jul 15 17:18:19 2016
@@ -52,6 +52,7 @@ int test1() {
 @class I5;
 @interface I5
 -(void)meth;
+@property (class) int c;
 @end
 
 // RUN: c-index-test -index-file %s -target x86_64-apple-macosx10.7 > %t
@@ -82,3 +83,4 @@ int test1() {
 // CHECK-NOT: [indexDeclaration]: kind: objc-instance-method {{.*}} loc: 43:
 
 // CHECK: [indexDeclaration]: kind: objc-instance-method | name: meth | {{.*}} 
loc: 54:1 | {{.*}} | isRedecl: 0 | isDef: 0 |
+// CHECK: [indexDeclaration]: kind: objc-property | name: c | USR: 
c:objc(cs)I5(cpy)c | lang: ObjC | cursor: ObjCPropertyDecl=c:55:23 [class,] | 
loc: 55:23

Modified: cfe/trunk/tools/libclang/CIndexUSRs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexUSRs.cpp?rev=275630&r1=275629&r2=275630&view=diff
==
--- cfe/trunk/tools/libclang/CIndexUSRs.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexUSRs.cpp Fri Jul 15 17:18:19 2016
@@ -137,7 +137,7 @@ CXString clang_constructUSR_ObjCProperty
   SmallString<128> Buf(getUSRSpacePrefix());
   llvm::raw_svector_ostream OS(Buf);
   OS << extractUSRSuffix(clang_getCString(classUSR));
-  generateUSRForObjCProperty(property, OS);
+  generateUSRForObjCProperty(property, /*isClassProp=*/false, OS);
   return cxstring::createDup(OS.str());
 }
 


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


Re: [PATCH] D21814: clang-rename: support multiple renames with one invocation

2016-07-15 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 64204.

https://reviews.llvm.org/D21814

Files:
  clang-rename/tool/ClangRename.cpp
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassReplacements.cpp
  test/clang-rename/ClassSimpleRenaming.cpp
  test/clang-rename/ClassTest.cpp
  test/clang-rename/ClassTestByName.cpp
  test/clang-rename/ClassTestReplacements.cpp
  test/clang-rename/ConstCastExpr.cpp
  test/clang-rename/ConstructExpr.cpp
  test/clang-rename/CtorDefTest.cpp
  test/clang-rename/CtorFindByDeclaration.cpp
  test/clang-rename/CtorFindByDefinition.cpp
  test/clang-rename/CtorInitializer.cpp
  test/clang-rename/CtorInitializerTest.cpp
  test/clang-rename/DeclRefExpr.cpp
  test/clang-rename/DtorDeclaration.cpp
  test/clang-rename/DtorDefTest.cpp
  test/clang-rename/DtorDefinition.cpp
  test/clang-rename/DynamicCastExpr.cpp
  test/clang-rename/Field.cpp
  test/clang-rename/FieldTest.cpp
  test/clang-rename/FunctionMacro.cpp
  test/clang-rename/MemberExprMacro.cpp
  test/clang-rename/Namespace.cpp
  test/clang-rename/NoNewName.cpp
  test/clang-rename/ReinterpretCastExpr.cpp
  test/clang-rename/StaticCastExpr.cpp
  test/clang-rename/VarTest.cpp
  test/clang-rename/Variable.cpp
  test/clang-rename/VariableMacro.cpp

Index: test/clang-rename/VariableMacro.cpp
===
--- test/clang-rename/VariableMacro.cpp
+++ test/clang-rename/VariableMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=208 -new-name=Z %t.cpp -i --
+// RUN: clang-rename rename-at -offset=218 -new-name=Z %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 #define Y X // CHECK: #define Y Z
Index: test/clang-rename/Variable.cpp
===
--- test/clang-rename/Variable.cpp
+++ test/clang-rename/Variable.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=148 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=158 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 namespace A {
Index: test/clang-rename/VarTest.cpp
===
--- test/clang-rename/VarTest.cpp
+++ test/clang-rename/VarTest.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=150 -new-name=hector %t.cpp -i --
+// RUN: clang-rename rename-at -offset=160 -new-name=hector %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 namespace A { int foo;  // CHECK: int hector;
 }
Index: test/clang-rename/StaticCastExpr.cpp
===
--- test/clang-rename/StaticCastExpr.cpp
+++ test/clang-rename/StaticCastExpr.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=150 -new-name=X %t.cpp -i --
+// RUN: clang-rename rename-at -offset=160 -new-name=X %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Base {
 };
Index: test/clang-rename/ReinterpretCastExpr.cpp
===
--- test/clang-rename/ReinterpretCastExpr.cpp
+++ test/clang-rename/ReinterpretCastExpr.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=133 -new-name=X %t.cpp -i --
+// RUN: clang-rename rename-at -offset=143 -new-name=X %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla {
 public:
Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
-// RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
+// RUN: not clang-rename rename-at -offset=133 %s 2>&1 | FileCheck %s
 // CHECK: clang-rename: no new name provided.
Index: test/clang-rename/Namespace.cpp
===
--- test/clang-rename/Namespace.cpp
+++ test/clang-rename/Namespace.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=143 -new-name=llvm %t.cpp -i --
+// RUN: clang-rename rename-at -offset=153 -new-name=llvm %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 namespace foo { // CHECK: namespace llvm {
Index: test/clang-rename/MemberExprMacro.cpp
===
--- test/clang-rename/MemberExprMacro.cpp
+++ test/clang-rename/MemberExprMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=156 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=166 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Baz {
Index: test/clang-rename/FunctionMacro.cpp
===
--- test/clang-rename/FunctionMacro.cpp
+++ test/clang-rename/FunctionMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN:

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-15 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

I've implemented the requested split of options, now there are two new 
rename-at and rename-all subcommands. The only common options is -i and 
-new-name, nothing else is shared, apart from the common options added by 
`tooling::CommonOptionsParser`. The code is modeled after `llvm-cov`, that way 
I could break the chicken-and-egg problem I outlined in my previous comment.

I've also updated all tests to use either of the two subcommands.

For now I did not touch documentation, though that'll be obviously the next 
step, I just didn't want to make this patch larger than necessary. :-)


https://reviews.llvm.org/D21814



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


r275645 - [CUDA][OpenMP] Create generic offload action

2016-07-15 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Fri Jul 15 18:13:27 2016
New Revision: 275645

URL: http://llvm.org/viewvc/llvm-project?rev=275645&view=rev
Log:
[CUDA][OpenMP] Create generic offload action

Summary:
This patch replaces the CUDA specific action by a generic offload action. The 
offload action may have multiple dependences classier in “host” and “device”. 
The way this generic offloading action is used is very similar to what is done 
today by the CUDA implementation: it is used to set a specific toolchain and 
architecture to its dependences during the generation of jobs.

This patch also proposes propagating the offloading information through the 
action graph so that that information can be easily retrieved at any time 
during the generation of commands. This allows e.g. the "clang tool” to 
evaluate whether CUDA should be supported for the device or host and ptas to 
easily retrieve the target architecture.

This is an example of how the action graphs would look like (compilation of a 
single CUDA file with two GPU architectures)
```
0: input, "cudatests.cu", cuda, (host-cuda)
1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
2: compiler, {1}, ir, (host-cuda)
3: input, "cudatests.cu", cuda, (device-cuda, sm_35)
4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_35)
5: compiler, {4}, ir, (device-cuda, sm_35)
6: backend, {5}, assembler, (device-cuda, sm_35)
7: assembler, {6}, object, (device-cuda, sm_35)
8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_35)" {7}, object
9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_35)" {6}, assembler
10: input, "cudatests.cu", cuda, (device-cuda, sm_37)
11: preprocessor, {10}, cuda-cpp-output, (device-cuda, sm_37)
12: compiler, {11}, ir, (device-cuda, sm_37)
13: backend, {12}, assembler, (device-cuda, sm_37)
14: assembler, {13}, object, (device-cuda, sm_37)
15: offload, "device-cuda (nvptx64-nvidia-cuda:sm_37)" {14}, object
16: offload, "device-cuda (nvptx64-nvidia-cuda:sm_37)" {13}, assembler
17: linker, {8, 9, 15, 16}, cuda-fatbin, (device-cuda)
18: offload, "host-cuda (powerpc64le-unknown-linux-gnu)" {2}, "device-cuda 
(nvptx64-nvidia-cuda)" {17}, ir
19: backend, {18}, assembler
20: assembler, {19}, object
21: input, "cuda", object
22: input, "cudart", object
23: linker, {20, 21, 22}, image
```
The changes in this patch pass the existent regression tests (keeps the 
existent functionality) and resulting binaries execute correctly in a 
Power8+K40 machine.

Reviewers: echristo, hfinkel, jlebar, ABataev, tra

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

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

Added:
cfe/trunk/test/Driver/cuda_phases.cu
Modified:
cfe/trunk/include/clang/Driver/Action.h
cfe/trunk/include/clang/Driver/Compilation.h
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Action.cpp
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp

Modified: cfe/trunk/include/clang/Driver/Action.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=275645&r1=275644&r2=275645&view=diff
==
--- cfe/trunk/include/clang/Driver/Action.h (original)
+++ cfe/trunk/include/clang/Driver/Action.h Fri Jul 15 18:13:27 2016
@@ -13,6 +13,7 @@
 #include "clang/Basic/Cuda.h"
 #include "clang/Driver/Types.h"
 #include "clang/Driver/Util.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 
 namespace llvm {
@@ -27,6 +28,8 @@ namespace opt {
 namespace clang {
 namespace driver {
 
+class ToolChain;
+
 /// Action - Represent an abstract compilation step to perform.
 ///
 /// An action represents an edge in the compilation graph; typically
@@ -50,8 +53,7 @@ public:
   enum ActionClass {
 InputClass = 0,
 BindArchClass,
-CudaDeviceClass,
-CudaHostClass,
+OffloadClass,
 PreprocessJobClass,
 PrecompileJobClass,
 AnalyzeJobClass,
@@ -65,17 +67,13 @@ public:
 VerifyDebugInfoJobClass,
 VerifyPCHJobClass,
 
-JobClassFirst=PreprocessJobClass,
-JobClassLast=VerifyPCHJobClass
+JobClassFirst = PreprocessJobClass,
+JobClassLast = VerifyPCHJobClass
   };
 
   // The offloading kind determines if this action is binded to a particular
   // programming model. Each entry reserves one bit. We also have a special 
kind
   // to designate the host offloading tool chain.
-  //
-  // FIXME: This is currently used to indicate that tool chains are used in a
-  // given programming, but will be used here as well once a generic offloading
-  // action is implemented.
   enum OffloadKind {
 OFK_None = 0x00,
 // The host offloading tool chain.
@@ -95,6 +93,19 @@ private:
   ActionList Inputs;
 
 protected:
+  ///
+  /// Offload information.
+  ///
+
+  /// The host offloading k

Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-15 Thread Sean Silva via cfe-commits
silvas accepted this revision.
silvas added a comment.
This revision is now accepted and ready to land.

Once all of David's comments are addressed this LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D21823



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


Re: [PATCH] D19544: Pass for translating math intrinsics to math library calls.

2016-07-15 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D19544#485677, @mmasten wrote:

> Thanks for reviewing. One concern I have going forward is the number of 
> entries that will appear in the switch statement inside 
> addVectorizableFunctionsFromVecLib(). I assume that the right thing to do is 
> to replace this with something that is TableGen'd?


I completely agree; this seems like a good candidate to be TableGen'd.

> Also, I just wanted to point out that some of these entries will result in 
> svml calls that are not legal. E.g., __svml_sinf32 does not actually exist in 
> the library, but can be legalized in case one explicitly sets a vector length 
> of 32. Although these types of cases are probably not common, I wanted to 
> bring this to your attention since the legalization piece of this work will 
> be reviewed and committed separately. If needed, I can remove those entries 
> until the legalization is in place.


Yes, let's start only with the directly-legal calls.


https://reviews.llvm.org/D19544



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


Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-15 Thread David Li via cfe-commits
davidxl accepted this revision.
davidxl added a comment.

lgtm


Repository:
  rL LLVM

https://reviews.llvm.org/D21823



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


Re: r275645 - [CUDA][OpenMP] Create generic offload action

2016-07-15 Thread Samuel F Antao via cfe-commits
I'm looking into it. Thanks for letting me know.
 
Samuel
 
- Original message -From: Kostya Serebryany To: Samuel F Antao/Watson/IBM@IBMUSCc: cfe-commits Subject: Re: r275645 - [CUDA][OpenMP] Create generic offload actionDate: Fri, Jul 15, 2016 7:37 PM 
Our windows bot is unhappy: 
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/25679/steps/run%20tests/logs/stdio
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Driver\Action.cpp(107) : error C2065: 'StringRef' : undeclared identifierC:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Driver\Action.cpp(107) : error C2146: syntax error : missing ')' before identifier 'NormalizedTriple'C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Driver\Action.cpp(107) : error C2761: 'std::string clang::driver::Action::getOffloadingFileNamePrefix(llvm::StringRef) const' : member function redeclaration not allowedC:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Driver\Action.cpp(107) : error C2059: syntax error : ')'C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Driver\Action.cpp(107) : error C2143: syntax error : missing ';' before '{'C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Driver\Action.cpp(107) : error C2447: '{' : missing function header (old-style formal list?)
 
On Fri, Jul 15, 2016 at 4:13 PM, Samuel Antao via cfe-commits  wrote:

Author: sfantaoDate: Fri Jul 15 18:13:27 2016New Revision: 275645URL: http://llvm.org/viewvc/llvm-project?rev=275645&view=revLog:[CUDA][OpenMP] Create generic offload actionSummary:This patch replaces the CUDA specific action by a generic offload action. The offload action may have multiple dependences classier in “host” and “device”. The way this generic offloading action is used is very similar to what is done today by the CUDA implementation: it is used to set a specific toolchain and architecture to its dependences during the generation of jobs.This patch also proposes propagating the offloading information through the action graph so that that information can be easily retrieved at any time during the generation of commands. This allows e.g. the "clang tool” to evaluate whether CUDA should be supported for the device or host and ptas to easily retrieve the target architecture.This is an example of how the action graphs would look like (compilation of a single CUDA file with two GPU architectures)```0: input, "cudatests.cu", cuda, (host-cuda)1: preprocessor, {0}, cuda-cpp-output, (host-cuda)2: compiler, {1}, ir, (host-cuda)3: input, "cudatests.cu", cuda, (device-cuda, sm_35)4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_35)5: compiler, {4}, ir, (device-cuda, sm_35)6: backend, {5}, assembler, (device-cuda, sm_35)7: assembler, {6}, object, (device-cuda, sm_35)8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_35)" {7}, object9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_35)" {6}, assembler10: input, "cudatests.cu", cuda, (device-cuda, sm_37)11: preprocessor, {10}, cuda-cpp-output, (device-cuda, sm_37)12: compiler, {11}, ir, (device-cuda, sm_37)13: backend, {12}, assembler, (device-cuda, sm_37)14: assembler, {13}, object, (device-cuda, sm_37)15: offload, "device-cuda (nvptx64-nvidia-cuda:sm_37)" {14}, object16: offload, "device-cuda (nvptx64-nvidia-cuda:sm_37)" {13}, assembler17: linker, {8, 9, 15, 16}, cuda-fatbin, (device-cuda)18: offload, "host-cuda (powerpc64le-unknown-linux-gnu)" {2}, "device-cuda (nvptx64-nvidia-cuda)" {17}, ir19: backend, {18}, assembler20: assembler, {19}, object21: input, "cuda", object22: input, "cudart", object23: linker, {20, 21, 22}, image```The changes in this patch pass the existent regression tests (keeps the existent functionality) and resulting binaries execute correctly in a Power8+K40 machine.Reviewers: echristo, hfinkel, jlebar, ABataev, traSubscribers: guansong, andreybokhanko, tcramer, mkuron, cfe-commits, arpith-jacob, carlo.bertolli, caomhinDifferential Revision: https://reviews.llvm.org/D18171Added:    cfe/trunk/test/Driver/cuda_phases.cuModified:    cfe/trunk/include/clang/Driver/Action.h    cfe/trunk/include/clang/Driver/Compilation.h    cfe/trunk/include/clang/Driver/Driver.h    cfe/trunk/lib/Driver/Action.cpp    cfe/trunk/lib/Driver/Driver.cpp    cfe/trunk/lib/Driver/ToolChain.cpp    cfe/trunk/lib/Driver/Tools.cpp    cfe/trunk/lib/Driver/Tools.h    cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cppModified: cfe/trunk/include/clang/Driver/Action.hURL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=275645&r1=275644&r2=275645&view=diff==--- cfe/trunk/include/clang/Driver/Action.h (original)+++ cfe/trunk/include/clang/Driver/Action.h Fri Jul 15 18:13:27 2016@@ -13,6 +13,7 @@ #include "clang/Basic/Cuda.h" #include "clang/Driver/Types.h" #include "clang/Driver/Util.h"+#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" namespace llvm {@@ -27,6 +28,8 @@ namespace opt { namespace clang { namespace dri

r275650 - Attempt to fix breakage caused by r275645 for Windows bots.

2016-07-15 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Fri Jul 15 18:51:21 2016
New Revision: 275650

URL: http://llvm.org/viewvc/llvm-project?rev=275650&view=rev
Log:
Attempt to fix breakage caused by r275645 for Windows bots.

Modified:
cfe/trunk/include/clang/Driver/Action.h
cfe/trunk/lib/Driver/Action.cpp

Modified: cfe/trunk/include/clang/Driver/Action.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=275650&r1=275649&r2=275650&view=diff
==
--- cfe/trunk/include/clang/Driver/Action.h (original)
+++ cfe/trunk/include/clang/Driver/Action.h Fri Jul 15 18:51:21 2016
@@ -140,7 +140,8 @@ public:
   std::string getOffloadingKindPrefix() const;
   /// Return a string that can be used as prefix in order to generate unique
   /// files for each offloading kind.
-  std::string getOffloadingFileNamePrefix(StringRef NormalizedTriple) const;
+  std::string
+  getOffloadingFileNamePrefix(llvm::StringRef NormalizedTriple) const;
 
   /// Set the device offload info of this action and propagate it to its
   /// dependences.

Modified: cfe/trunk/lib/Driver/Action.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Action.cpp?rev=275650&r1=275649&r2=275650&view=diff
==
--- cfe/trunk/lib/Driver/Action.cpp (original)
+++ cfe/trunk/lib/Driver/Action.cpp Fri Jul 15 18:51:21 2016
@@ -104,7 +104,7 @@ std::string Action::getOffloadingKindPre
 }
 
 std::string
-Action::getOffloadingFileNamePrefix(StringRef NormalizedTriple) const {
+Action::getOffloadingFileNamePrefix(llvm::StringRef NormalizedTriple) const {
   // A file prefix is only generated for device actions and consists of the
   // offload kind and triple.
   if (!OffloadingDeviceKind)


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


Re: r275115 - Prevent the creation of empty (forwarding) blocks resulting from nested ifs.

2016-07-15 Thread Doug Gilmore via cfe-commits
This change broke several MIPS builders:

https://dmz-portal.mips.com/bb/builders/LLVM%20with%20integrated%20assembler%20and%20fPIC%20and%20-O0

and 

https://dmz-portal.mips.com/bb/builders/LLVM%20with%20integrated%20assembler%20and%20fPIC%20and%20-O0%20and%20fast%20isel%20and%20mips%20fast%20isel

More information to follow.

Sorry for the delay in tracking this down,

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


Re: [PATCH] D22426: Fix automatic detection of ARM MSVC toolset in clang.exe

2016-07-15 Thread Saleem Abdulrasool via cfe-commits
compnerd added a subscriber: compnerd.
compnerd accepted this revision.
compnerd added a reviewer: compnerd.
compnerd added a comment.
This revision is now accepted and ready to land.

I imagine that at this point, most usage is still based around the x86 
toolchain rather than x64 (I didnt even notice the x64 tools until recently).  
That is, any reason that we shouldnt be using x64 for x64, x64_x86 for x86, and 
x64_arm for ARM?


https://reviews.llvm.org/D22426



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


r275651 - Use std::string instead of StringRef when generating the auxiliar triple in the frontend tool.

2016-07-15 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Fri Jul 15 19:15:56 2016
New Revision: 275651

URL: http://llvm.org/viewvc/llvm-project?rev=275651&view=rev
Log:
Use std::string instead of StringRef when generating the auxiliar triple in the 
frontend tool. 

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=275651&r1=275650&r2=275651&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jul 15 19:15:56 2016
@@ -3847,7 +3847,7 @@ void Clang::ConstructJob(Compilation &C,
   if (IsCuda) {
 // We have to pass the triple of the host if compiling for a CUDA device 
and
 // vice-versa.
-StringRef NormalizedTriple;
+std::string NormalizedTriple;
 if (JA.isDeviceOffloading(Action::OFK_Cuda))
   NormalizedTriple = C.getSingleOffloadToolChain()
  ->getTriple()


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


[PATCH] D22431: clang-format: [JS] nested and tagged template strings.

2016-07-15 Thread Martin Probst via cfe-commits
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

https://reviews.llvm.org/D22431

Files:
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1122,7 +1122,7 @@
 TEST_F(FormatTestJS, TemplateStrings) {
   // Keeps any whitespace/indentation within the template string.
   verifyFormat("var x = `hello\n"
-" ${  name}\n"
+" ${name}\n"
 "  !`;",
 "var x=`hello\n"
" ${  name}\n"
@@ -1206,6 +1206,12 @@
"var y;",
"var x = ` \\` a`;\n"
"var y;");
+  verifyFormat(
+  "var x = `${xs.map(x => `${x}`).join('\\n')}`;");
+}
+
+TEST_F(FormatTestJS, TaggedTemplateStrings) {
+  verifyFormat("var x = html``;");
 }
 
 TEST_F(FormatTestJS, CastSyntax) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -858,7 +858,7 @@
 if (!CurrentToken->isOneOf(TT_LambdaLSquare, TT_ForEachMacro,
TT_FunctionLBrace, TT_ImplicitStringLiteral,
TT_InlineASMBrace, TT_JsFatArrow, TT_LambdaArrow,
-   TT_RegexLiteral))
+   TT_RegexLiteral, TT_TemplateString))
   CurrentToken->Type = TT_Unknown;
 CurrentToken->Role.reset();
 CurrentToken->MatchingParen = nullptr;
@@ -1816,6 +1816,9 @@
   return 100;
 if (Left.is(TT_JsTypeColon))
   return 35;
+if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
+(Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
+  return 100;
   }
 
   if (Left.is(tok::comma) || (Right.is(tok::identifier) && Right.Next &&
@@ -2113,6 +2116,11 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
+if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
+(Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
+  return false;
+if (Left.is(tok::identifier) && Right.is(TT_TemplateString))
+  return false;
 if (Right.is(tok::star) &&
 Left.isOneOf(Keywords.kw_function, Keywords.kw_yield))
   return false;
Index: lib/Format/FormatTokenLexer.h
===
--- lib/Format/FormatTokenLexer.h
+++ lib/Format/FormatTokenLexer.h
@@ -66,6 +66,7 @@
   FormatToken *FormatTok;
   bool IsFirstToken;
   bool GreaterStashed, LessStashed;
+  unsigned TemplateStringDepth;
   unsigned Column;
   unsigned TrailingWhitespace;
   std::unique_ptr Lex;
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -27,8 +27,8 @@
const FormatStyle &Style,
encoding::Encoding Encoding)
 : FormatTok(nullptr), IsFirstToken(true), GreaterStashed(false),
-  LessStashed(false), Column(0), TrailingWhitespace(0),
-  SourceMgr(SourceMgr), ID(ID), Style(Style),
+  LessStashed(false), TemplateStringDepth(0), Column(0),
+  TrailingWhitespace(0), SourceMgr(SourceMgr), ID(ID), Style(Style),
   IdentTable(getFormattingLangOpts(Style)), Keywords(IdentTable),
   Encoding(Encoding), FirstInLineIndex(0), FormattingDisabled(false),
   MacroBlockBeginRegex(Style.MacroBlockBegin),
@@ -230,15 +230,25 @@
 
 void FormatTokenLexer::tryParseTemplateString() {
   FormatToken *BacktickToken = Tokens.back();
-  if (!BacktickToken->is(tok::unknown) || BacktickToken->TokenText != "`")
+  if (TemplateStringDepth > 0 && BacktickToken->TokenText == "}")
+TemplateStringDepth--;
+  else if (!BacktickToken->is(tok::unknown) ||
+ BacktickToken->TokenText != "`")
 return;
 
   // 'Manually' lex ahead in the current file buffer.
   const char *Offset = Lex->getBufferLocation();
   const char *TmplBegin = Offset - BacktickToken->TokenText.size(); // at "`"
   for (; Offset != Lex->getBuffer().end() && *Offset != '`'; ++Offset) {
 if (*Offset == '\\')
   ++Offset; // Skip the escaped character.
+if (Offset + 1 < Lex->getBuffer().end() && *Offset == '$' &&
+*(Offset + 1) == '{') {
+  // '${' introduces an expression interpolation in the template string.
+  TemplateStringDepth++;
+  ++Offset;
+  break;
+}
   }
 
   StringRef LiteralText(TmplBegin, Offset - TmplBegin + 1);
___
cfe-commits ma

r275653 - Reimplement ExternalSemaSource delegation in terms of

2016-07-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jul 15 19:35:14 2016
New Revision: 275653

URL: http://llvm.org/viewvc/llvm-project?rev=275653&view=rev
Log:
Reimplement ExternalSemaSource delegation in terms of
MultiplexExternalSemaSource to remove one of the places that needs updating
every time the ExternalSemaSource interface changes.

Modified:
cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp

Modified: cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp?rev=275653&r1=275652&r2=275653&view=diff
==
--- cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp (original)
+++ cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp Fri Jul 15 19:35:14 2016
@@ -18,6 +18,7 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Parse/ParseAST.h"
+#include "clang/Sema/MultiplexExternalSemaSource.h"
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/ASTWriter.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -25,51 +26,48 @@
 using namespace clang;
 
 namespace {
-class ChainedIncludesSource : public ExternalSemaSource {
+class ChainedIncludesSourceImpl : public ExternalSemaSource {
 public:
-  ~ChainedIncludesSource() override;
-
-  ExternalSemaSource &getFinalReader() const { return *FinalReader; }
-
-  std::vector CIs;
-  IntrusiveRefCntPtr FinalReader;
+  ChainedIncludesSourceImpl(std::vector> CIs)
+  : CIs(std::move(CIs)) {}
 
 protected:
   
//===--===//
   // ExternalASTSource interface.
   
//===--===//
 
-  Decl *GetExternalDecl(uint32_t ID) override;
-  Selector GetExternalSelector(uint32_t ID) override;
-  uint32_t GetNumExternalSelectors() override;
-  Stmt *GetExternalDeclStmt(uint64_t Offset) override;
-  CXXCtorInitializer **GetExternalCXXCtorInitializers(uint64_t Offset) 
override;
-  CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset) override;
-  bool FindExternalVisibleDeclsByName(const DeclContext *DC,
-  DeclarationName Name) override;
-  void
-  FindExternalLexicalDecls(const DeclContext *DC,
-   llvm::function_ref IsKindWeWant,
-   SmallVectorImpl &Result) override;
-  void CompleteType(TagDecl *Tag) override;
-  void CompleteType(ObjCInterfaceDecl *Class) override;
-  void StartedDeserializing() override;
-  void FinishedDeserializing() override;
-  void StartTranslationUnit(ASTConsumer *Consumer) override;
-  void PrintStats() override;
-
   /// Return the amount of memory used by memory buffers, breaking down
   /// by heap-backed versus mmap'ed memory.
-  void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override;
+  void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override {
+for (unsigned i = 0, e = CIs.size(); i != e; ++i) {
+  if (const ExternalASTSource *eSrc =
+  CIs[i]->getASTContext().getExternalSource()) {
+eSrc->getMemoryBufferSizes(sizes);
+  }
+}
+  }
 
-  
//===--===//
-  // ExternalSemaSource interface.
-  
//===--===//
+private:
+  std::vector> CIs;
+};
 
-  void InitializeSema(Sema &S) override;
-  void ForgetSema() override;
-  void ReadMethodPool(Selector Sel) override;
-  bool LookupUnqualified(LookupResult &R, Scope *S) override;
+/// Members of ChainedIncludesSource, factored out so we can initialize
+/// them before we initialize the ExternalSemaSource base class.
+struct ChainedIncludesSourceMembers {
+  ChainedIncludesSourceImpl Impl;
+  IntrusiveRefCntPtr FinalReader;
+};
+
+/// Use MultiplexExternalSemaSource to dispatch all ExternalSemaSource
+/// calls to the final reader.
+class ChainedIncludesSource
+: private ChainedIncludesSourceMembers,
+  public MultiplexExternalSemaSource {
+public:
+  ChainedIncludesSource(std::vector> CIs,
+IntrusiveRefCntPtr FinalReader)
+  : ChainedIncludesSourceMembers{{std::move(CIs)}, std::move(FinalReader)},
+MultiplexExternalSemaSource(Impl, *this->FinalReader) {}
 };
 }
 
@@ -107,18 +105,13 @@ createASTReader(CompilerInstance &CI, St
   return nullptr;
 }
 
-ChainedIncludesSource::~ChainedIncludesSource() {
-  for (unsigned i = 0, e = CIs.size(); i != e; ++i)
-delete CIs[i];
-}
-
 IntrusiveRefCntPtr clang::createChainedIncludesSource(
 CompilerInstance &CI, IntrusiveRefCntPtr &Reader) {
 
   std::vector &includes = 
CI.getPreprocessorOpts().ChainedIncludes;
   assert(!includes.empty() && "No '-chain-include' in options!");
 
-  IntrusiveRefCntPtr source(new 
ChainedIncludesSource());
+  std::vector> CIs;
   InputKind IK = CI.getFrontendOpts().Inputs[0].getKind()

r275654 - [ObjC] Implement @available in the Parser and AST

2016-07-15 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Fri Jul 15 19:35:23 2016
New Revision: 275654

URL: http://llvm.org/viewvc/llvm-project?rev=275654&view=rev
Log:
[ObjC] Implement @available in the Parser and AST

This patch adds a new AST node: ObjCAvailabilityCheckExpr, and teaches the
Parser and Sema to generate it. This node represents an availability check of
the form:

  @available(macos 10.10, *);

Which will eventually compile to a runtime check of the host's OS version. This
is the first patch of the feature I proposed here:
http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html

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

Added:
cfe/trunk/include/clang/AST/Availability.h
cfe/trunk/test/Parser/objc-available.m
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/AST/ExprObjC.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/StmtNodes.td
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprClassification.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=275654&r1=275653&r2=275654&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Fri Jul 15 19:35:23 2016
@@ -2014,7 +2014,11 @@ enum CXCursorKind {
*/
   CXCursor_OMPArraySectionExpr   = 147,
 
-  CXCursor_LastExpr  = CXCursor_OMPArraySectionExpr,
+  /** \brief Represents an @available(...) check.
+   */
+  CXCursor_ObjCAvailabilityCheckExpr = 148,
+
+  CXCursor_LastExpr  = CXCursor_ObjCAvailabilityCheckExpr,
 
   /* Statements */
   CXCursor_FirstStmt = 200,

Added: cfe/trunk/include/clang/AST/Availability.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Availability.h?rev=275654&view=auto
==
--- cfe/trunk/include/clang/AST/Availability.h (added)
+++ cfe/trunk/include/clang/AST/Availability.h Fri Jul 15 19:35:23 2016
@@ -0,0 +1,63 @@
+//===--- Availability.h - Classes for availability --*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This files defines some classes that implement availability checking.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_AVAILABILITY_H
+#define LLVM_CLANG_AST_AVAILABILITY_H
+
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/VersionTuple.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace clang {
+
+/// \brief One specifier in an @available expression.
+///
+/// \code
+///   @available(macos 10.10, *)
+/// \endcode
+///
+/// Here, 'macos 10.10' and '*' both map to an instance of this type.
+///
+class AvailabilitySpec {
+  /// Represents the version that this specifier requires. If the host OS
+  /// version is greater than or equal to Version, the @available will evaluate
+  /// to true.
+  VersionTuple Version;
+
+  /// Name of the platform that Version corresponds to.
+  StringRef Platform;
+
+  SourceLocation BeginLoc, EndLoc;
+
+public:
+  AvailabilitySpec(VersionTuple Version, StringRef Platform,
+   SourceLocation BeginLoc, SourceLocation EndLoc)
+  : Version(Version), Platform(Platform), BeginLoc(BeginLoc),
+EndLoc(EndLoc) {}
+
+  /// This constructor is used when representing the '*' case.
+  AvailabilitySpec(SourceLocation StarLoc)
+  : BeginLoc(StarLoc), EndLoc(StarLoc) {}
+
+  VersionTuple getVersion() const { return Version; }
+  StringRef getPlatform() const { return Platform; }
+  SourceLocation getBeginLoc() const { return BeginLoc; }
+  SourceLocation g

Re: [PATCH] D22171: [ObjC Availability] Implement parser support for Objective-C's @available

2016-07-15 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275654: [ObjC] Implement @available in the Parser and AST 
(authored by epilk).

Changed prior to commit:
  https://reviews.llvm.org/D22171?vs=63603&id=64215#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22171

Files:
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/include/clang/AST/Availability.h
  cfe/trunk/include/clang/AST/ExprObjC.h
  cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Basic/StmtNodes.td
  cfe/trunk/include/clang/Basic/TokenKinds.def
  cfe/trunk/include/clang/Parse/Parser.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/include/clang/Serialization/ASTBitCodes.h
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/AST/ExprClassification.cpp
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/lib/AST/StmtPrinter.cpp
  cfe/trunk/lib/AST/StmtProfile.cpp
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/lib/Parse/ParseObjc.cpp
  cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
  cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/test/Parser/objc-available.m
  cfe/trunk/tools/libclang/CIndex.cpp
  cfe/trunk/tools/libclang/CXCursor.cpp

Index: cfe/trunk/include/clang-c/Index.h
===
--- cfe/trunk/include/clang-c/Index.h
+++ cfe/trunk/include/clang-c/Index.h
@@ -2014,7 +2014,11 @@
*/
   CXCursor_OMPArraySectionExpr   = 147,
 
-  CXCursor_LastExpr  = CXCursor_OMPArraySectionExpr,
+  /** \brief Represents an @available(...) check.
+   */
+  CXCursor_ObjCAvailabilityCheckExpr = 148,
+
+  CXCursor_LastExpr  = CXCursor_ObjCAvailabilityCheckExpr,
 
   /* Statements */
   CXCursor_FirstStmt = 200,
Index: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
===
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
@@ -2352,6 +2352,7 @@
 DEF_TRAVERSE_STMT(ObjCBridgedCastExpr, {
   TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
 })
+DEF_TRAVERSE_STMT(ObjCAvailabilityCheckExpr, {})
 DEF_TRAVERSE_STMT(ParenExpr, {})
 DEF_TRAVERSE_STMT(ParenListExpr, {})
 DEF_TRAVERSE_STMT(PredefinedExpr, {})
Index: cfe/trunk/include/clang/AST/ExprObjC.h
===
--- cfe/trunk/include/clang/AST/ExprObjC.h
+++ cfe/trunk/include/clang/AST/ExprObjC.h
@@ -1562,7 +1562,52 @@
 return T->getStmtClass() == ObjCBridgedCastExprClass;
   }
 };
-  
+
+/// \brief A runtime availability query.
+///
+/// There are 2 ways to spell this node:
+/// \code
+///   @available(macos 10.10, ios 8, *); // Objective-C
+///   __builtin_available(macos 10.10, ios 8, *); // C, C++, and Objective-C
+/// \endcode
+///
+/// Note that we only need to keep track of one \c VersionTuple here, which is
+/// the one that corresponds to the current deployment target. This is meant to
+/// be used in the condition of an \c if, but it is also usable as top level
+/// expressions.
+///
+class ObjCAvailabilityCheckExpr : public Expr {
+  VersionTuple VersionToCheck;
+  SourceLocation AtLoc, RParen;
+
+  friend class ASTStmtReader;
+public:
+  ObjCAvailabilityCheckExpr(VersionTuple VersionToCheck, SourceLocation AtLoc,
+SourceLocation RParen, QualType Ty)
+  : Expr(ObjCAvailabilityCheckExprClass, Ty, VK_RValue, OK_Ordinary, false,
+ false, false, false),
+VersionToCheck(VersionToCheck), AtLoc(AtLoc), RParen(RParen) {}
+
+  explicit ObjCAvailabilityCheckExpr(EmptyShell Shell)
+  : Expr(ObjCAvailabilityCheckExprClass, Shell) {}
+
+  SourceLocation getLocStart() const { return AtLoc; }
+  SourceLocation getLocEnd() const { return RParen; }
+  SourceRange getSourceRange() const { return {AtLoc, RParen}; }
+
+  /// \brief This may be '*', in which case this should fold to true.
+  bool hasVersion() const { return !VersionToCheck.empty(); }
+  VersionTuple getVersion() { return VersionToCheck; }
+
+  child_range children() {
+return child_range(child_iterator(), child_iterator());
+  }
+
+  static bool classof(const Stmt *T) {
+return T->getStmtClass() == ObjCAvailabilityCheckExprClass;
+  }
+};
+
 }  // end namespace clang
 
 #endif
Index: cfe/trunk/include/clang/AST/Availability.h
===
--- cfe/trunk/include/clang/AST/Availability.h
+++ cfe/trunk/include/clang/AST/Availability.h
@@ -0,0 +1,63 @@
+//===--- 

Re: [PATCH] D22431: clang-format: [JS] nested and tagged template strings.

2016-07-15 Thread Martin Probst via cfe-commits
mprobst added inline comments.


Comment at: lib/Format/TokenAnnotator.cpp:1821
@@ -1819,1 +1820,3 @@
+(Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
+  return 100;
   }

I've chosen 100 by fair dice roll. Please advise on how to pick a reasonable 
penalty :-)


https://reviews.llvm.org/D22431



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


r275655 - Remove extra semi-colon. Fixes warning and Werror bots.

2016-07-15 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Fri Jul 15 19:58:34 2016
New Revision: 275655

URL: http://llvm.org/viewvc/llvm-project?rev=275655&view=rev
Log:
Remove extra semi-colon. Fixes warning and Werror bots.

Modified:
cfe/trunk/lib/Driver/Action.cpp

Modified: cfe/trunk/lib/Driver/Action.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Action.cpp?rev=275655&r1=275654&r2=275655&view=diff
==
--- cfe/trunk/lib/Driver/Action.cpp (original)
+++ cfe/trunk/lib/Driver/Action.cpp Fri Jul 15 19:58:34 2016
@@ -136,7 +136,7 @@ OffloadAction::OffloadAction(const HostD
   ActiveOffloadKindMask = HDep.getOffloadKinds();
   HDep.getAction()->propagateHostOffloadInfo(HDep.getOffloadKinds(),
  HDep.getBoundArch());
-};
+}
 
 OffloadAction::OffloadAction(const DeviceDependences &DDeps, types::ID Ty)
 : Action(OffloadClass, DDeps.getActions(), Ty),


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


Re: [PATCH] D22426: Fix automatic detection of ARM MSVC toolset in clang.exe

2016-07-15 Thread Dave Bartolomeo via cfe-commits
DaveBartolomeo added a comment.

In https://reviews.llvm.org/D22426#486100, @compnerd wrote:

> I imagine that at this point, most usage is still based around the x86 
> toolchain rather than x64 (I didnt even notice the x64 tools until recently). 
>  That is, any reason that we shouldnt be using x64 for x64, x64_x86 for x86, 
> and x64_arm for ARM?


Most usage is indeed x86-hosted. While the x64-hosted x64-targeting compiler 
has been available from the beginning of MSVC's x64 support, the x64-hosted 
x86-targeting toolset is relatively recent (VS 2102 or VS 2013, I think). In 
general, the x86-hosted compilers are marginally faster than the equivalent 
x64-hosted compiler, and since x86-hosted has always been the default, most 
developers don't switch to the x64-hosted toolset unless they run into code 
that won't compile or link without running out of memory space on the 
x86-hosted toolset. Also, the x64-hosted toolset won't run on machines running 
a 32-bit OS, which are more rare these days, but still exist. The existing 
Clang behavior would have failed on a 32-bit OS when targeting x64, though, so 
if we've gotten away with it this long, we're probably OK.

One reasonable solution would be to choose the toolset that is hosted on the 
same architecture as the host of clang.exe (e.g. x64-hosted Clang looks for 
x64-hosted MSVC). If this sounds good, I can make that change in a follow-up 
commit.


https://reviews.llvm.org/D22426



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


Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-15 Thread Jake VanAdrighem via cfe-commits
jakev added a comment.

Fantastic. Sean or David, could one of you commit this for me? It would be much 
appreciated.


Repository:
  rL LLVM

https://reviews.llvm.org/D21823



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


r275668 - [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-15 Thread Sean Silva via cfe-commits
Author: silvas
Date: Fri Jul 15 21:54:58 2016
New Revision: 275668

URL: http://llvm.org/viewvc/llvm-project?rev=275668&view=rev
Log:
[Driver] Add flags for enabling both types of PGO Instrumentation

The flags:
Enable IR-level instrumentation -fprofile-generate or -fprofile-generate=
When applying profile data: -fprofile-use=/path/to/profdata

Patch by Jake VanAdrighem!

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

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/clang_f_opts.c
cfe/trunk/test/Profile/gcc-flag-compatibility.c

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=275668&r1=275667&r2=275668&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Fri Jul 15 21:54:58 2016
@@ -1502,19 +1502,21 @@ instrumentation:
profile. As you make changes to your code, clang may no longer be able to
use the profile data. It will warn you when this happens.
 
-Profile generation and use can also be controlled by the GCC-compatible flags
-``-fprofile-generate`` and ``-fprofile-use``. Although these flags are
-semantically equivalent to their GCC counterparts, they *do not* handle
-GCC-compatible profiles. They are only meant to implement GCC's semantics
-with respect to profile creation and use.
+Profile generation using an alternative instrumentation method can be
+controlled by the GCC-compatible flags ``-fprofile-generate`` and
+``-fprofile-use``. Although these flags are semantically equivalent to
+their GCC counterparts, they *do not* handle GCC-compatible profiles.
+They are only meant to implement GCC's semantics with respect to
+profile creation and use.
 
 .. option:: -fprofile-generate[=]
 
-  Without any other arguments, ``-fprofile-generate`` behaves identically to
-  ``-fprofile-instr-generate``. When given a directory name, it generates the
-  profile file ``default.profraw`` in the directory named ``dirname``. If
-  ``dirname`` does not exist, it will be created at runtime. The environment
-  variable ``LLVM_PROFILE_FILE`` can be used to override the directory and
+  The ``-fprofile-generate`` and ``-fprofile-generate=`` flags will use
+  an alterantive instrumentation method for profile generation. When
+  given a directory name, it generates the profile file
+  ``default.profraw`` in the directory named ``dirname``. If ``dirname``
+  does not exist, it will be created at runtime. The environment variable
+  ``LLVM_PROFILE_FILE`` can be used to override the directory and
   filename for the profile file at runtime. For example,
 
   .. code-block:: console

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=275668&r1=275667&r2=275668&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Jul 15 21:54:58 2016
@@ -516,7 +516,8 @@ def fno_coverage_mapping : Flag<["-"], "
 Group, Flags<[DriverOption]>,
 HelpText<"Disable code coverage analysis">;
 def fprofile_generate : Flag<["-"], "fprofile-generate">,
-Alias;
+Group, Flags<[DriverOption]>,
+HelpText<"Generate instrumented code to collect execution counts into 
default.profraw (overridden by LLVM_PROFILE_FILE env var)">;
 def fprofile_generate_EQ : Joined<["-"], "fprofile-generate=">,
 Group, Flags<[DriverOption]>, MetaVarName<"">,
 HelpText<"Generate instrumented code to collect execution counts into 
/default.profraw (overridden by LLVM_PROFILE_FILE env var)">;
@@ -529,7 +530,8 @@ def fno_profile_instr_generate : Flag<["
 Group, Flags<[DriverOption]>,
 HelpText<"Disable generation of profile instrumentation.">;
 def fno_profile_generate : Flag<["-"], "fno-profile-generate">,
-Alias;
+Group, Flags<[DriverOption]>,
+HelpText<"Disable generation of profile instrumentation.">;
 def fno_profile_instr_use : Flag<["-"], "fno-profile-instr-use">,
 Group, Flags<[DriverOption]>,
 HelpText<"Disable using instrumentation data for profile-guided 
optimization">;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=275668&r1=275667&r2=275668&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jul 15 21:54:58 2016
@@ -3529,16 +3529,27 @@ VersionTuple visualstudio::getMSVCVersio
 static void addPGOAndCoverageFlags(Compilation &C, const Driver &D,
const InputInfo &Output, const ArgList 
&Args,
ArgStringList &CmdArgs) {
+
+  au

Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-15 Thread Sean Silva via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL275668: [Driver] Add flags for enabling both types of PGO 
Instrumentation (authored by silvas).

Changed prior to commit:
  https://reviews.llvm.org/D21823?vs=64056&id=64222#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21823

Files:
  cfe/trunk/docs/UsersManual.rst
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/clang_f_opts.c
  cfe/trunk/test/Profile/gcc-flag-compatibility.c

Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -1502,19 +1502,21 @@
profile. As you make changes to your code, clang may no longer be able to
use the profile data. It will warn you when this happens.
 
-Profile generation and use can also be controlled by the GCC-compatible flags
-``-fprofile-generate`` and ``-fprofile-use``. Although these flags are
-semantically equivalent to their GCC counterparts, they *do not* handle
-GCC-compatible profiles. They are only meant to implement GCC's semantics
-with respect to profile creation and use.
+Profile generation using an alternative instrumentation method can be
+controlled by the GCC-compatible flags ``-fprofile-generate`` and
+``-fprofile-use``. Although these flags are semantically equivalent to
+their GCC counterparts, they *do not* handle GCC-compatible profiles.
+They are only meant to implement GCC's semantics with respect to
+profile creation and use.
 
 .. option:: -fprofile-generate[=]
 
-  Without any other arguments, ``-fprofile-generate`` behaves identically to
-  ``-fprofile-instr-generate``. When given a directory name, it generates the
-  profile file ``default.profraw`` in the directory named ``dirname``. If
-  ``dirname`` does not exist, it will be created at runtime. The environment
-  variable ``LLVM_PROFILE_FILE`` can be used to override the directory and
+  The ``-fprofile-generate`` and ``-fprofile-generate=`` flags will use
+  an alterantive instrumentation method for profile generation. When
+  given a directory name, it generates the profile file
+  ``default.profraw`` in the directory named ``dirname``. If ``dirname``
+  does not exist, it will be created at runtime. The environment variable
+  ``LLVM_PROFILE_FILE`` can be used to override the directory and
   filename for the profile file at runtime. For example,
 
   .. code-block:: console
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -516,7 +516,8 @@
 Group, Flags<[DriverOption]>,
 HelpText<"Disable code coverage analysis">;
 def fprofile_generate : Flag<["-"], "fprofile-generate">,
-Alias;
+Group, Flags<[DriverOption]>,
+HelpText<"Generate instrumented code to collect execution counts into default.profraw (overridden by LLVM_PROFILE_FILE env var)">;
 def fprofile_generate_EQ : Joined<["-"], "fprofile-generate=">,
 Group, Flags<[DriverOption]>, MetaVarName<"">,
 HelpText<"Generate instrumented code to collect execution counts into /default.profraw (overridden by LLVM_PROFILE_FILE env var)">;
@@ -529,7 +530,8 @@
 Group, Flags<[DriverOption]>,
 HelpText<"Disable generation of profile instrumentation.">;
 def fno_profile_generate : Flag<["-"], "fno-profile-generate">,
-Alias;
+Group, Flags<[DriverOption]>,
+HelpText<"Disable generation of profile instrumentation.">;
 def fno_profile_instr_use : Flag<["-"], "fno-profile-instr-use">,
 Group, Flags<[DriverOption]>,
 HelpText<"Disable using instrumentation data for profile-guided optimization">;
Index: cfe/trunk/test/Profile/gcc-flag-compatibility.c
===
--- cfe/trunk/test/Profile/gcc-flag-compatibility.c
+++ cfe/trunk/test/Profile/gcc-flag-compatibility.c
@@ -7,10 +7,11 @@
 // -fprofile-use=Uses the profile file /default.profdata
 // -fprofile-use=/file   Uses the profile file /file
 
-// Check that -fprofile-generate uses the runtime default profile file.
+// FIXME: IRPGO shouldn't use the override API when no profraw name is given.
+// Check that -fprofile-generate overrides the default profraw.
 // RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate | FileCheck -check-prefix=PROFILE-GEN %s
-// PROFILE-GEN-NOT: call void @__llvm_profile_override_default_filename
-// PROFILE-GEN-NOT: declare void @__llvm_profile_override_default_filename(i8*)
+// PROFILE-GEN: call void @__llvm_profile_override_default_filename
+// PROFILE-GEN: declare void @__llvm_profile_override_default_filename(i8*)
 
 // Check that -fprofile-generate=/path/to generates /path/to/default.profraw
 // RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to | FileCheck -check-prefix=PROFILE-GEN-EQ %s
Index:

Re: [PATCH] D22237: clang-rename: fix renaming member functions

2016-07-15 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

Hi!

Sorry for a late response.

The issue is that you only deal with the consequences of this "bug". Overridden 
functions simply have different USRs, so the solution is just to add relevant 
USRs. Trying to deal with it in `USRLocFinder.cpp` doesn't seem right; the 
chances of dealing with such issue correctly on that side are very small. I.e. 
it still doesn't pass the more complicated test I have in my patch (see below).

There's a patch I've been working on lately, it does exactly that. 
https://reviews.llvm.org/D22408 (it's from the other account I'll have to use 
from now, nvm)


https://reviews.llvm.org/D22237



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