[PATCH] D48440: [NEON] Support vldNq intrinsics in AArch32 (Clang part)

2018-06-26 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev added a comment.

Ping.


https://reviews.llvm.org/D48440



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


[PATCH] D45719: [clang-Format] Fix indentation of member call after block

2018-06-26 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: unittests/Format/FormatTest.cpp:4449-4450
+   "  })\n"
+   "  
.foo(\"aaa\"\n"
+   "   \"bb\");\n"
+   "}");

One more nit: I'd use a Style with a smaller column limit for these tests, 
makes them a lot more readable :)



Comment at: unittests/Format/FormatTest.cpp:4452
+   "}");
+
+  verifyFormat("test() {\n"

Are the ones below here testing anything that's not tested above?


Repository:
  rC Clang

https://reviews.llvm.org/D45719



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


[PATCH] D46944: [analyzer] Use sufficiently large types for index/size calculation.

2018-06-26 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.
Herald added a subscriber: mikhail.ramalho.

Ping.


https://reviews.llvm.org/D46944



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


[PATCH] D48456: [Fixed Point Arithmetic] Casting between fixed point types and other arithmetic types

2018-06-26 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: lib/AST/ExprConstant.cpp:9501
+  return false;
+return Success(Result.getInt() >> Scale, E);
+  }

ebevhan wrote:
> The shift here will not produce the correct rounding behavior for fixed-point 
> to integer conversion. E-C says `Conversions from a fixed-point to an integer 
> type round toward zero.` However, simply shifting will always round towards 
> -inf.
> 
> If the fixed-point number is negative, you need to add `lowBits(Scale)` 
> before performing the shift.
> 
> This operation here is also not the same as the FixedPointToBool emission in 
> CodeGen.
Oops, this has nothing at all to do with FixedPointToBool. Forget about that.


Repository:
  rC Clang

https://reviews.llvm.org/D48456



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


[PATCH] D48363: [clang-format] Enable text proto formatting in common functions

2018-06-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


Repository:
  rC Clang

https://reviews.llvm.org/D48363



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


[PATCH] D48589: [WIP] [CodeGen] Allow specifying Extend to CoerceAndExpand

2018-06-26 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added inline comments.



Comment at: include/clang/CodeGen/CGFunctionInfo.h:475
 
+static_assert(std::is_trivially_copyable::value,
+"ABIArgInfo must be trivially copyable as it is embedded as trailing "

I think this is the right trait here. I spent too much time debugging this :)


https://reviews.llvm.org/D48589



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


[PATCH] D48589: [WIP] [CodeGen] Allow specifying Extend to CoerceAndExpand

2018-06-26 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 created this revision.
rogfer01 added a reviewer: rjmccall.

This is WIP and it is motivated by the suggestions in 
http://lists.llvm.org/pipermail/cfe-dev/2018-June/058263.html

First attempt, piggybacking the extend information in a structure where the 
bit-width of the integer represents the exact extension intended. There is a 
bit of overlapping with the original Extend but I'm not convinced we win 
anything from rewriting it into the new representation.

I plan to test this using unit tests but I can link a diff with the current 
usage in case it helps.


https://reviews.llvm.org/D48589

Files:
  include/clang/CodeGen/CGFunctionInfo.h
  lib/CodeGen/CGCall.cpp

Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1951,7 +1951,6 @@
 
   case ABIArgInfo::CoerceAndExpand:
 break;
-
   case ABIArgInfo::Expand:
 llvm_unreachable("Invalid ABI kind for return argument");
   }
@@ -1987,6 +1986,8 @@
 llvm::AttributeSet::get(getLLVMContext(), Attrs);
   }
 
+  SmallVector CoerceAndExpandAttrs(IRFunctionArgs.totalIRArgs());
+  bool CoerceAndExpandHasAttributes = false;
   unsigned ArgNo = 0;
   for (CGFunctionInfo::const_arg_iterator I = FI.arg_begin(),
   E = FI.arg_end();
@@ -2055,9 +2056,39 @@
 }
 case ABIArgInfo::Ignore:
 case ABIArgInfo::Expand:
-case ABIArgInfo::CoerceAndExpand:
   break;
+case ABIArgInfo::CoerceAndExpand:
+  if (AI.getExtendSeq()) {
+// Handle extends in expanded items
+unsigned FirstIRArg, NumIRArgs;
+std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
+llvm::StructType *CoercionType = AI.getCoerceAndExpandType();
+for (unsigned I = 0, Ext = 0; I < NumIRArgs; I++) {
+  llvm::Type *EltType = CoercionType->getElementType(I);
+  if (ABIArgInfo::isPaddingForCoerceAndExpand(EltType))
+continue;
 
+  llvm::Type *ExtendKind = AI.getExtendSeq()->getElementType(Ext++);
+  switch (ABIArgInfo::getExtendKind(ExtendKind)) {
+  case ABIArgInfo::ExtendKind::None:
+break;
+  case ABIArgInfo::ExtendKind::SignExt: {
+CoerceAndExpandHasAttributes = true;
+CoerceAndExpandAttrs[FirstIRArg + I].addAttribute(
+llvm::Attribute::SExt);
+break;
+  }
+  case ABIArgInfo::ExtendKind::ZeroExt: {
+CoerceAndExpandHasAttributes = true;
+CoerceAndExpandAttrs[FirstIRArg + I].addAttribute(
+llvm::Attribute::ZExt);
+break;
+  }
+  }
+}
+  }
+
+  break;
 case ABIArgInfo::InAlloca:
   // inalloca disables readnone and readonly.
   FuncAttrs.removeAttribute(llvm::Attribute::ReadOnly)
@@ -2112,12 +2143,16 @@
 if (FI.getExtParameterInfo(ArgNo).isNoEscape())
   Attrs.addAttribute(llvm::Attribute::NoCapture);
 
-if (Attrs.hasAttributes()) {
+if (Attrs.hasAttributes() || CoerceAndExpandHasAttributes) {
   unsigned FirstIRArg, NumIRArgs;
   std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
   for (unsigned i = 0; i < NumIRArgs; i++)
+  {
+llvm::AttrBuilder CoerceAndExpandMergedAttrs(Attrs);
+CoerceAndExpandMergedAttrs.merge(CoerceAndExpandAttrs[FirstIRArg + i]);
 ArgAttrs[FirstIRArg + i] =
-llvm::AttributeSet::get(getLLVMContext(), Attrs);
+llvm::AttributeSet::get(getLLVMContext(), CoerceAndExpandMergedAttrs);
+  }
 }
   }
   assert(ArgNo == FI.arg_size());
Index: include/clang/CodeGen/CGFunctionInfo.h
===
--- include/clang/CodeGen/CGFunctionInfo.h
+++ include/clang/CodeGen/CGFunctionInfo.h
@@ -25,6 +25,7 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/Support/TrailingObjects.h"
 #include 
+#include 
 
 namespace clang {
 namespace CodeGen {
@@ -76,16 +77,20 @@
 KindLast = InAlloca
   };
 
+  enum class ExtendKind : unsigned { None = 1, SignExt = 2, ZeroExt = 3 };
+
 private:
+
   llvm::Type *TypeData; // canHaveCoerceToType()
   union {
 llvm::Type *PaddingType; // canHavePaddingType()
 llvm::Type *UnpaddedCoerceAndExpandType; // isCoerceAndExpand()
   };
   union {
-unsigned DirectOffset; // isDirect() || isExtend()
-unsigned IndirectAlign;// isIndirect()
-unsigned AllocaFieldIndex; // isInAlloca()
+llvm::StructType *ExtendSeq; // isCoerceAndExpand()
+unsigned DirectOffset;   // isDirect() || isExtend()
+unsigned IndirectAlign;  // isIndirect()
+unsigned AllocaFieldIndex;   // isInAlloca()
   };
   Kind TheKind;
   bool PaddingInReg : 1;
@@ -110,13 +115,16 @@
 UnpaddedCoerceAndExpandType = T;
   }
 
-  ABIArgInfo(Kind K)
-  : TheKind(K), PaddingInReg(false), InReg(false) {
+  void setExtendSet(llvm::StructType *ES) {
+ 

[PATCH] D47632: [ASTImporter] Refactor Decl creation

2018-06-26 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hi Gabor!

I like the change but there are also some questions.




Comment at: lib/AST/ASTImporter.cpp:1659
+  AccessSpecDecl *ToD;
+  std::tie(ToD, AlreadyImported) = CreateDecl(
+  D, Importer.getToContext(), D->getAccess(), DC, Loc, ColonLoc);

As I see, all usage samples require having a variable AlreadyImported used only 
once. How about changing the signature a bit:
```bool getOrCreateDecl(ToDeclTy *&ToD, FromDeclT *FromD, Args &&... args)```
with optional `LLVM_NODISCARD`? (Naming is a subject for discussion).
This signature also allows us to omit template arguments because we pass an 
argument of a templated type. So, the call will look like this:
```AccessSpecDecl *ToD;
if (getOrCreateDecl(ToD, D, Importer.getToContext(), D->getAccess(), DC, Loc, 
ColonLoc))
  return ToD;```



Comment at: lib/AST/ASTImporter.cpp:1922
   if (auto *FoundAlias = dyn_cast(FoundDecl))
-  return Importer.Imported(D, FoundAlias);
+  return Importer.MapImported(D, FoundAlias);
   ConflictingDecls.push_back(FoundDecl);

Could you also fix indentation here?


Repository:
  rC Clang

https://reviews.llvm.org/D47632



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


[PATCH] D47459: [ASTImporter] Eliminated some unittest warnings.

2018-06-26 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.
This revision is now accepted and ready to land.

Thank you!

When committing, please change the commit message (the current review 
description is out-of-date) and mention the reformatting done.


Repository:
  rC Clang

https://reviews.llvm.org/D47459



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


[PATCH] D47450: [ASTImporter] Use InjectedClassNameType at import of templated record.

2018-06-26 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rC Clang

https://reviews.llvm.org/D47450



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


[PATCH] D48098: clang-format-diff: Switch to python3 by default, support python 2.7

2018-06-26 Thread Marco Falke via Phabricator via cfe-commits
MarcoFalke updated this revision to Diff 152867.
MarcoFalke added a comment.

Keep python2 by default for now


https://reviews.llvm.org/D48098

Files:
  tools/clang-format/clang-format-diff.py


Index: tools/clang-format/clang-format-diff.py
===
--- tools/clang-format/clang-format-diff.py
+++ tools/clang-format/clang-format-diff.py
@@ -25,10 +25,12 @@
 import argparse
 import difflib
 import re
-import string
 import subprocess
-import StringIO
 import sys
+try:
+  from StringIO import StringIO
+except ImportError:
+   from io import StringIO
 
 
 def main():
@@ -84,36 +86,39 @@
 line_count = int(match.group(3))
   if line_count == 0:
 continue
-  end_line = start_line + line_count - 1;
+  end_line = start_line + line_count - 1
   lines_by_file.setdefault(filename, []).extend(
   ['-lines', str(start_line) + ':' + str(end_line)])
 
   # Reformat files containing changes in place.
-  for filename, lines in lines_by_file.iteritems():
+  for filename, lines in lines_by_file.items():
 if args.i and args.verbose:
-  print 'Formatting', filename
+  print('Formatting {}'.format(filename))
 command = [args.binary, filename]
 if args.i:
   command.append('-i')
 if args.sort_includes:
   command.append('-sort-includes')
 command.extend(lines)
 if args.style:
   command.extend(['-style', args.style])
-p = subprocess.Popen(command, stdout=subprocess.PIPE,
- stderr=None, stdin=subprocess.PIPE)
+p = subprocess.Popen(command,
+ stdout=subprocess.PIPE,
+ stderr=None,
+ stdin=subprocess.PIPE,
+ universal_newlines=True)
 stdout, stderr = p.communicate()
 if p.returncode != 0:
-  sys.exit(p.returncode);
+  sys.exit(p.returncode)
 
 if not args.i:
   with open(filename) as f:
 code = f.readlines()
-  formatted_code = StringIO.StringIO(stdout).readlines()
+  formatted_code = StringIO(stdout).readlines()
   diff = difflib.unified_diff(code, formatted_code,
   filename, filename,
   '(before formatting)', '(after formatting)')
-  diff_string = string.join(diff, '')
+  diff_string = ''.join(diff)
   if len(diff_string) > 0:
 sys.stdout.write(diff_string)
 


Index: tools/clang-format/clang-format-diff.py
===
--- tools/clang-format/clang-format-diff.py
+++ tools/clang-format/clang-format-diff.py
@@ -25,10 +25,12 @@
 import argparse
 import difflib
 import re
-import string
 import subprocess
-import StringIO
 import sys
+try:
+  from StringIO import StringIO
+except ImportError:
+   from io import StringIO
 
 
 def main():
@@ -84,36 +86,39 @@
 line_count = int(match.group(3))
   if line_count == 0:
 continue
-  end_line = start_line + line_count - 1;
+  end_line = start_line + line_count - 1
   lines_by_file.setdefault(filename, []).extend(
   ['-lines', str(start_line) + ':' + str(end_line)])
 
   # Reformat files containing changes in place.
-  for filename, lines in lines_by_file.iteritems():
+  for filename, lines in lines_by_file.items():
 if args.i and args.verbose:
-  print 'Formatting', filename
+  print('Formatting {}'.format(filename))
 command = [args.binary, filename]
 if args.i:
   command.append('-i')
 if args.sort_includes:
   command.append('-sort-includes')
 command.extend(lines)
 if args.style:
   command.extend(['-style', args.style])
-p = subprocess.Popen(command, stdout=subprocess.PIPE,
- stderr=None, stdin=subprocess.PIPE)
+p = subprocess.Popen(command,
+ stdout=subprocess.PIPE,
+ stderr=None,
+ stdin=subprocess.PIPE,
+ universal_newlines=True)
 stdout, stderr = p.communicate()
 if p.returncode != 0:
-  sys.exit(p.returncode);
+  sys.exit(p.returncode)
 
 if not args.i:
   with open(filename) as f:
 code = f.readlines()
-  formatted_code = StringIO.StringIO(stdout).readlines()
+  formatted_code = StringIO(stdout).readlines()
   diff = difflib.unified_diff(code, formatted_code,
   filename, filename,
   '(before formatting)', '(after formatting)')
-  diff_string = string.join(diff, '')
+  diff_string = ''.join(diff)
   if len(diff_string) > 0:
 sys.stdout.write(diff_string)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45719: [clang-Format] Fix indentation of member call after block

2018-06-26 Thread Anders Karlsson via Phabricator via cfe-commits
ank added inline comments.



Comment at: unittests/Format/FormatTest.cpp:4449-4450
+   "  })\n"
+   "  
.foo(\"aaa\"\n"
+   "   \"bb\");\n"
+   "}");

klimek wrote:
> One more nit: I'd use a Style with a smaller column limit for these tests, 
> makes them a lot more readable :)
makes sense, I'll do that.



Comment at: unittests/Format/FormatTest.cpp:4452
+   "}");
+
+  verifyFormat("test() {\n"

klimek wrote:
> Are the ones below here testing anything that's not tested above?
nope I'll remove them!


Repository:
  rC Clang

https://reviews.llvm.org/D45719



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


[PATCH] D48507: [mips] Explicitly specify the linker emulation for MIPS on FreeBSD.

2018-06-26 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added inline comments.



Comment at: lib/Driver/ToolChains/FreeBSD.cpp:197
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf64ltsmip_fbsd");
+break;

Does it make a sense to handle N32 ABI case here?


Repository:
  rC Clang

https://reviews.llvm.org/D48507



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


[PATCH] D45719: [clang-Format] Fix indentation of member call after block

2018-06-26 Thread Anders Karlsson via Phabricator via cfe-commits
ank updated this revision to Diff 152870.

Repository:
  rC Clang

https://reviews.llvm.org/D45719

Files:
  lib/Format/ContinuationIndenter.cpp
  lib/Format/FormatToken.h
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -4416,6 +4416,40 @@
   verifyFormat(".(\n"
"aa)\n"
".aa();");
+
+  // Dont break if only closing statements before member call
+  verifyFormat("test() {\n"
+   "  ([]() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  }).foo();\n"
+   "}");
+  verifyFormat("test() {\n"
+   "  (\n"
+   "  []() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  },\n"
+   "  foo, bar)\n"
+   "  .foo();\n"
+   "}");
+  verifyFormat("test() {\n"
+   "  ([]() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  })\n"
+   "  .foo()\n"
+   "  .bar();\n"
+   "}");
+  verifyFormat("test() {\n"
+   "  ([]() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  })\n"
+   "  .foo(\"a\"\n"
+   "   \"\");\n"
+   "}",
+   getLLVMStyleWithColumns(30));
 }
 
 TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -319,6 +319,14 @@
   }
   template  bool isNot(T Kind) const { return !is(Kind); }
 
+  bool closesScopeAfterBlock() const {
+if(BlockKind == BK_Block)
+  return true;
+if(closesScope())
+  return Previous->closesScopeAfterBlock();
+return false;
+  }
+
   /// \c true if this token starts a sequence with the given tokens in order,
   /// following the ``Next`` pointers, ignoring comments.
   template 
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -399,7 +399,9 @@
   //   }.bind(...));
   // FIXME: We should find a more generic solution to this problem.
   !(State.Column <= NewLineColumn &&
-Style.Language == FormatStyle::LK_JavaScript))
+Style.Language == FormatStyle::LK_JavaScript) &&
+  !(Previous.closesScopeAfterBlock() &&
+State.Column <= NewLineColumn))
 return true;
 
   // If the template declaration spans multiple lines, force wrap before the


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -4416,6 +4416,40 @@
   verifyFormat(".(\n"
"aa)\n"
".aa();");
+
+  // Dont break if only closing statements before member call
+  verifyFormat("test() {\n"
+   "  ([]() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  }).foo();\n"
+   "}");
+  verifyFormat("test() {\n"
+   "  (\n"
+   "  []() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  },\n"
+   "  foo, bar)\n"
+   "  .foo();\n"
+   "}");
+  verifyFormat("test() {\n"
+   "  ([]() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  })\n"
+   "  .foo()\n"
+   "  .bar();\n"
+   "}");
+  verifyFormat("test() {\n"
+   "  ([]() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  })\n"
+   "  .foo(\"a\"\n"
+   "   \"\");\n"
+   "}",
+   getLLVMStyleWithColumns(30));
 }
 
 TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -319,6 +319,14 @@
   }
   template  bool isNot(T Kind) const { return !is(Kind); }
 
+  bool closesScopeAfterBlock() const {
+if(BlockKind == BK_Block)
+  return true;
+if(closesScope())
+  return Previous->closesScopeAfterBlock();

[PATCH] D48515: [mips][ias] Enable IAS by default for OpenBSD / FreeBSD mips64/mips64el.

2018-06-26 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added a comment.

LGTM, but before commit please add a test case into the freebsd.c.


Repository:
  rC Clang

https://reviews.llvm.org/D48515



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


[PATCH] D46944: [analyzer] Use sufficiently large types for index/size calculation.

2018-06-26 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.
This revision is now accepted and ready to land.

Hi Bevin,

The patch looks good to me. But let's wait for maintainers to approve it. @NoQ 
, could you take a look?


https://reviews.llvm.org/D46944



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


[PATCH] D45719: [clang-Format] Fix indentation of member call after block

2018-06-26 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG.


Repository:
  rC Clang

https://reviews.llvm.org/D45719



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


r335595 - [clang-format] Enable text proto formatting in common functions

2018-06-26 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Tue Jun 26 05:00:14 2018
New Revision: 335595

URL: http://llvm.org/viewvc/llvm-project?rev=335595&view=rev
Log:
[clang-format] Enable text proto formatting in common functions

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Format/Format.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=335595&r1=335594&r2=335595&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Jun 26 05:00:14 2018
@@ -774,7 +774,10 @@ FormatStyle getGoogleStyle(FormatStyle::
   "PROTO",
   },
   /*EnclosingFunctionNames=*/
-  {},
+  {
+  "PARSE_TEXT_PROTO",
+  "EqualsProto",
+  },
   /*CanonicalDelimiter=*/"",
   /*BasedOnStyle=*/"google",
   },


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


[PATCH] D48363: [clang-format] Enable text proto formatting in common functions

2018-06-26 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335595: [clang-format] Enable text proto formatting in 
common functions (authored by krasimir, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D48363

Files:
  cfe/trunk/lib/Format/Format.cpp


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -774,7 +774,10 @@
   "PROTO",
   },
   /*EnclosingFunctionNames=*/
-  {},
+  {
+  "PARSE_TEXT_PROTO",
+  "EqualsProto",
+  },
   /*CanonicalDelimiter=*/"",
   /*BasedOnStyle=*/"google",
   },


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -774,7 +774,10 @@
   "PROTO",
   },
   /*EnclosingFunctionNames=*/
-  {},
+  {
+  "PARSE_TEXT_PROTO",
+  "EqualsProto",
+  },
   /*CanonicalDelimiter=*/"",
   /*BasedOnStyle=*/"google",
   },
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48367: [modules] Fix 37878; Autoload subdirectory modulemaps with specific LangOpts

2018-06-26 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 152875.
yamaguchi added a comment.

Add #import test and add branch AllowExtraModuleMapSearch when ModuleName was 
from @import


https://reviews.llvm.org/D48367

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/Modules/Inputs/autoload-subdirectory/a.h
  clang/test/Modules/Inputs/autoload-subdirectory/b.h
  clang/test/Modules/Inputs/autoload-subdirectory/c.h
  clang/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap
  clang/test/Modules/Inputs/autoload-subdirectory/module.modulemap
  clang/test/Modules/a.out
  clang/test/Modules/autoload-subdirectory.cpp

Index: clang/test/Modules/autoload-subdirectory.cpp
===
--- /dev/null
+++ clang/test/Modules/autoload-subdirectory.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fmodules -fmodule-name=Foo -I %S/Inputs/autoload-subdirectory/ %s -verify
+// expected-no-diagnostics
+
+#include "a.h"
+#import "c.h"
+
+int main() {
+  foo neko;
+  return 0;
+}
Index: clang/test/Modules/Inputs/autoload-subdirectory/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/module.modulemap
@@ -0,0 +1,3 @@
+module a { header "a.h" }
+module b { header "b.h" }
+module c { header "c.h" }
Index: clang/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap
@@ -0,0 +1,3 @@
+module a { header "a.h" }
+module b { header "b.h" }
+module c { header "c.h" }
Index: clang/test/Modules/Inputs/autoload-subdirectory/c.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/c.h
@@ -0,0 +1,7 @@
+class nyan {
+  bool x, y;
+
+public:
+  nyan(){};
+  ~nyan(){};
+};
Index: clang/test/Modules/Inputs/autoload-subdirectory/b.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/b.h
@@ -0,0 +1 @@
+class bar {};
Index: clang/test/Modules/Inputs/autoload-subdirectory/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/a.h
@@ -0,0 +1,9 @@
+#include "b.h"
+
+class foo {
+  int x, y;
+
+public:
+  foo(){};
+  ~foo(){};
+};
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -2613,7 +2613,9 @@
  "MODULE_DIRECTORY found before MODULE_NAME");
   // If we've already loaded a module map file covering this module, we may
   // have a better path for it (relative to the current build).
-  Module *M = PP.getHeaderSearchInfo().lookupModule(F.ModuleName);
+  Module *M = PP.getHeaderSearchInfo().lookupModule(
+  F.ModuleName, /*AllowSearch*/ true,
+  /*AllowExtraModuleMapSearch*/ true);
   if (M && M->Directory) {
 // If we're implicitly loading a module, the base directory can't
 // change between the build and use.
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -198,14 +198,15 @@
   return Result.str().str();
 }
 
-Module *HeaderSearch::lookupModule(StringRef ModuleName, bool AllowSearch) {
+Module *HeaderSearch::lookupModule(StringRef ModuleName, bool AllowSearch,
+   bool AllowExtraModuleMapSearch) {
   // Look in the module map to determine if there is a module by this name.
   Module *Module = ModMap.findModule(ModuleName);
   if (Module || !AllowSearch || !HSOpts->ImplicitModuleMaps)
 return Module;
 
   StringRef SearchName = ModuleName;
-  Module = lookupModule(ModuleName, SearchName);
+  Module = lookupModule(ModuleName, SearchName, AllowExtraModuleMapSearch);
 
   // The facility for "private modules" -- adjacent, optional module maps named
   // module.private.modulemap that are supposed to define private submodules --
@@ -216,13 +217,14 @@
   // could force building unwanted dependencies into the parent module and cause
   // dependency cycles.
   if (!Module && SearchName.consume_back("_Private"))
-Module = lookupModule(ModuleName, SearchName);
+Module = lookupModule(ModuleName, SearchName, AllowExtraModuleMapSearch);
   if (!Module && SearchName.consume_back("Private"))
-Module = lookupModule(ModuleName, SearchName);
+Module = lookupModule(ModuleName, SearchName, AllowExtraModuleMapSearch);
   return Module;
 }
 
-Module *HeaderSearch::lookupModule(StringRef ModuleName, Strin

[PATCH] D48367: [modules] Fix 37878; Autoload subdirectory modulemaps with specific LangOpts

2018-06-26 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi added inline comments.



Comment at: clang/lib/Lex/HeaderSearch.cpp:285
 // directory.
-loadSubdirectoryModuleMaps(SearchDirs[Idx]);
+if (ModMap.getLangOpts().ObjC1 || ModMap.getLangOpts().ObjC2)
+  loadSubdirectoryModuleMaps(SearchDirs[Idx]);

bruno wrote:
> yamaguchi wrote:
> > bruno wrote:
> > > yamaguchi wrote:
> > > > bruno wrote:
> > > > > aprantl wrote:
> > > > > > Are these flags also enabled in Objective-C++ mode?
> > > > > Looks like all this logic was introduced in r177621 to allow the 
> > > > > names of modules to differ from the name of their subdirectory in the 
> > > > > include path.
> > > > > 
> > > > > Instead of having this to be based on the language, it's probably 
> > > > > better if we have it based on @import name lookup, which is the 
> > > > > scenario where we actually currently look more aggressively, did you 
> > > > > try that path?
> > > > > 
> > > > > This is also lacking a testcase, can you create one?
> > > > > Are these flags also enabled in Objective-C++ mode?
> > > > I think so from FrontendOptions.h:190
> > > > `bool isObjectiveC() const { return Lang == ObjC || Lang == ObjCXX; }`
> > > > 
> > > > > it's probably better if we have it based on @import name lookup
> > > > I don't think I understood what you're saying, could you explain a bit 
> > > > more?
> > > > 
> > > > > This is also lacking a testcase, can you create one?
> > > > Sure!
> > > > I don't think I understood what you're saying, could you explain a bit 
> > > > more?
> > > 
> > > This extra call to `loadSubdirectoryModuleMaps` was introduced in r177621 
> > > to allow `@import SomeName` to work even if `SomeName` doesn't match a 
> > > subdirectory name. See the original commit for more details.
> > > 
> > > This means that it was never supposed to be called when the module is 
> > > built via `#include` or `#import`, which is what you are getting. That 
> > > said, I believe it's better if the condition for calling 
> > > `loadSubdirectoryModuleMaps` checks somehow if the lookup is coming from 
> > > of an `@import` instead of checking the language (we too don't want it to 
> > > be called for ObjC when `#include` or `#import` are used).
> > > we too don't want it to be called for ObjC when #include or #import are 
> > > used
> > https://gist.github.com/yamaguchi1024/27caba1897eb813b297a8c4785adc11d
> > This is one thing I could think of, it excludes `#include` but `#import` 
> > and `@import` are still treated in the same way. Do you have any idea how 
> > to do this? Is Clang differenciating the module behavior based on `#import` 
> > or `@import` in ObjC?
> > https://gist.github.com/yamaguchi1024/27caba1897eb813b297a8c4785adc11d
> 
> Something along these lines seems fine. I'd reverse the condition of 
> `IsInclusionDirective` to be true by default (which is the most common case), 
> and you pass false when coming from `@import`s. Maybe also rename it to 
> something more meaningful for the change in question, around the lines of 
> `AllowExtraModuleMapSearch`.
> 
> > This is one thing I could think of, it excludes #include but #import and 
> > @import are still treated in the same way.
> 
> `#import` and `#include` should be treated the same way (extra searches 
> shouldn't happen for both), `@import` is the only one different. 
> 
> > Do you have any idea how to do this? Is Clang differenciating the module 
> > behavior based on #import or @import in ObjC?
> 
> `#import` works very much like `#include`, the difference is that `#import`'s 
> have implicit `#pragma once` like behavior. 
> #import and #include should be treated the same way
I'll add a test for #import as well.


https://reviews.llvm.org/D48367



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


[PATCH] D48367: [modules] Fix 37878; Autoload subdirectory modulemaps with specific LangOpts

2018-06-26 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 152876.
yamaguchi added a comment.

Delete a.out)


https://reviews.llvm.org/D48367

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/Modules/Inputs/autoload-subdirectory/a.h
  clang/test/Modules/Inputs/autoload-subdirectory/b.h
  clang/test/Modules/Inputs/autoload-subdirectory/c.h
  clang/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap
  clang/test/Modules/Inputs/autoload-subdirectory/module.modulemap
  clang/test/Modules/autoload-subdirectory.cpp

Index: clang/test/Modules/autoload-subdirectory.cpp
===
--- /dev/null
+++ clang/test/Modules/autoload-subdirectory.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fmodules -fmodule-name=Foo -I %S/Inputs/autoload-subdirectory/ %s -verify
+// expected-no-diagnostics
+
+#include "a.h"
+#import "c.h"
+
+int main() {
+  foo neko;
+  return 0;
+}
Index: clang/test/Modules/Inputs/autoload-subdirectory/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/module.modulemap
@@ -0,0 +1,3 @@
+module a { header "a.h" }
+module b { header "b.h" }
+module c { header "c.h" }
Index: clang/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap
@@ -0,0 +1,3 @@
+module a { header "a.h" }
+module b { header "b.h" }
+module c { header "c.h" }
Index: clang/test/Modules/Inputs/autoload-subdirectory/c.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/c.h
@@ -0,0 +1,7 @@
+class nyan {
+  bool x, y;
+
+public:
+  nyan(){};
+  ~nyan(){};
+};
Index: clang/test/Modules/Inputs/autoload-subdirectory/b.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/b.h
@@ -0,0 +1 @@
+class bar {};
Index: clang/test/Modules/Inputs/autoload-subdirectory/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/autoload-subdirectory/a.h
@@ -0,0 +1,9 @@
+#include "b.h"
+
+class foo {
+  int x, y;
+
+public:
+  foo(){};
+  ~foo(){};
+};
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -2613,7 +2613,9 @@
  "MODULE_DIRECTORY found before MODULE_NAME");
   // If we've already loaded a module map file covering this module, we may
   // have a better path for it (relative to the current build).
-  Module *M = PP.getHeaderSearchInfo().lookupModule(F.ModuleName);
+  Module *M = PP.getHeaderSearchInfo().lookupModule(
+  F.ModuleName, /*AllowSearch*/ true,
+  /*AllowExtraModuleMapSearch*/ true);
   if (M && M->Directory) {
 // If we're implicitly loading a module, the base directory can't
 // change between the build and use.
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -198,14 +198,15 @@
   return Result.str().str();
 }
 
-Module *HeaderSearch::lookupModule(StringRef ModuleName, bool AllowSearch) {
+Module *HeaderSearch::lookupModule(StringRef ModuleName, bool AllowSearch,
+   bool AllowExtraModuleMapSearch) {
   // Look in the module map to determine if there is a module by this name.
   Module *Module = ModMap.findModule(ModuleName);
   if (Module || !AllowSearch || !HSOpts->ImplicitModuleMaps)
 return Module;
 
   StringRef SearchName = ModuleName;
-  Module = lookupModule(ModuleName, SearchName);
+  Module = lookupModule(ModuleName, SearchName, AllowExtraModuleMapSearch);
 
   // The facility for "private modules" -- adjacent, optional module maps named
   // module.private.modulemap that are supposed to define private submodules --
@@ -216,13 +217,14 @@
   // could force building unwanted dependencies into the parent module and cause
   // dependency cycles.
   if (!Module && SearchName.consume_back("_Private"))
-Module = lookupModule(ModuleName, SearchName);
+Module = lookupModule(ModuleName, SearchName, AllowExtraModuleMapSearch);
   if (!Module && SearchName.consume_back("Private"))
-Module = lookupModule(ModuleName, SearchName);
+Module = lookupModule(ModuleName, SearchName, AllowExtraModuleMapSearch);
   return Module;
 }
 
-Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName) {
+Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
+ 

[clang-tools-extra] r335598 - [clangd] Use default clang-format styles.

2018-06-26 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Jun 26 05:49:09 2018
New Revision: 335598

URL: http://llvm.org/viewvc/llvm-project?rev=335598&view=rev
Log:
[clangd] Use default clang-format styles.

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/CodeComplete.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=335598&r1=335597&r2=335598&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue Jun 26 05:49:09 2018
@@ -375,7 +375,8 @@ ClangdServer::formatCode(llvm::StringRef
  ArrayRef Ranges) {
   // Call clang-format.
   auto FS = FSProvider.getFileSystem();
-  auto Style = format::getStyle("file", File, "LLVM", Code, FS.get());
+  auto Style = format::getStyle(format::DefaultFormatStyle, File,
+format::DefaultFallbackStyle, Code, FS.get());
   if (!Style)
 return Style.takeError();
 

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=335598&r1=335597&r2=335598&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Tue Jun 26 05:49:09 2018
@@ -825,10 +825,11 @@ bool semaCodeComplete(std::unique_ptrhttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r335084 - Append new attributes to the end of an AttributeList.

2018-06-26 Thread Michael Kruse via cfe-commits
Thank you for your reproducer. I debugged it and found the issue.
ngettext is defined as follows.

extern char *ngettext (const char *__msgid1, const char *__msgid2,
 unsigned long int __n)
 throw () __attribute__ ((__format_arg__ (1))) __attribute__
((__format_arg__ (2)));

Indeed, two format attributes (Just not the plain "format" I
expected). The code which is processing it from SemaChecking.cpp:5521

if (const FormatArgAttr *FA = ND->getAttr()) {

That is, the code as written can process at most one FormatAttr and
takes the first one (which is a different one before and after my
patch).

I suggest to change this to:

for (const auto *FA : FDecl->specific_attrs()) {

such that both arguments to ngettext are checked, as defined by the
attributes. That also means that emitting the warning is emitted with
and without my patch.

Michael







2018-06-25 19:29 GMT-05:00 David Jones :
> (Sorry for the late reply...)
>
> On Mon, Jun 25, 2018 at 2:45 PM Michael Kruse via cfe-commits
>  wrote:
>>
>> I just revert if to have further discussions (r335516)
>>
>> Michael
>>
>> 2018-06-25 14:58 GMT-05:00 Eric Christopher :
>> >
>> >
>> > On Mon, Jun 25, 2018 at 12:21 PM Richard Smith via cfe-commits
>> >  wrote:
>> >>
>> >> On 23 June 2018 at 22:34, Michael Kruse via cfe-commits
>> >>  wrote:
>> >>>
>> >>> Hi,
>> >>>
>> >>> multiple comments in the code indicate that the attribute order was
>> >>> surprising and probably has lead to bugs, and will lead to bugs in the
>> >>> future. The order had to be explicitly reversed to avoid those. This
>> >>> alone for me this seems a good reason to have the attributes in the
>> >>> order in which they appear in the source.
>> >>>
>> >>> It would be nice it you could send a reproducer. At a glance, your
>> >>> case does not seem related since the format strings are function
>> >>> arguments, not attributes.
>
>
> Well, there is a nested function call, but the format warning applies to two
> different parameters: a singular phrasing string, and a plural one. A
> reproducer would look like this, which is almost verbatim from the link:
>
> $ cat /tmp/repro.cc
> #include 
> #include 
>
> void foo(){ printf(ngettext("one frobber", "%lu frobbers", 0UL), 0UL); }
> $ /bin/clang -Wall -c -o /dev/null /tmp/repro.cc
> /tmp/repro.cc:4:66: warning: data argument not used by format string
> [-Wformat-extra-args]
> void foo(){ printf(ngettext("one frobber", "%lu frobbers", 0UL), 0UL); }
> ~^
> 1 warning generated.
>
>
> Swapping the string params works, and an older revision yields inverse
> results.
>
>
>>
>> >>> 2018-06-23 17:17 GMT-05:00 David Jones :
>> >>> > Since the semantics of the ordering of multiple format args seems
>> >>> > somewhat
>> >>> > ill-defined, it seems to me like reverting may be the best near-term
>> >>> > choice.
>> >>> > I can imagine other ways to fix the diagnostic, but the only
>> >>> > behaviour
>> >>> > that
>> >>> > I would believe to be expected by existing code is the old one, so a
>> >>> > change
>> >>> > like this one probably needs to be more carefully vetted before
>> >>> > being
>> >>> > (re-)committed.
>> >>>
>> >>> Could you give more details about your concerns?
>
>
>
> Multiple format strings (or repeating or reordering other attributes) seems
> like it lacks clear semantics. I can't find any particularly well-documented
> explanation of Clang's behaviour in these cases, which makes me suspect that
> most people would just "fix it until it works" and move on. GCC's
> documentation doesn't seem to be very decisive, either.
>
> For example, you mentioned that multiple format attributes may be invalid;
> if so, then rejecting such cases should probably be a part of the fix. But
> that would require some vetting, since this (pretty clearly) doesn't mirror
> the current reality.
>
>
>> >> (I'm not sure what the problem is, but as a data point, Sema::checkCall
>> >> iterates over the FormatAttrs in order, so it's possible that changing
>> >> the
>> >> order may have triggered a new warning. That may be due to a
>> >> pre-existing
>> >> order-dependence bug, or it may be that we're losing an attribute
>> >> here.)
>
>
> It's arguably a pre-existing order dependence bug in ngettext, but it would
> be ... well, a fairly prevalent bug, since it could churn any such calls
> through libintl/gettext/etc.
>
>>
>> >>> > Please let me know your plan. (If I don't hear back in a day or so,
>> >>> > I'll go
>> >>> > ahead and revert for you as the safe default course of action.)
>> >>>
>> >>> On a weekend?
>> >>
>> >>
>> >> Yes; our policy is generally to revert to green if a patch causes
>> >> regressions that aren't going to be fixed in a few hours. This is
>> >> generally
>> >> good for the committer, because it lets you figure out what's wrong and
>> >> deal
>> >> with it on your own schedule rather than being pressured to fix it
>> >> urgently
>> >> because you're blocking the work of ot

[PATCH] D46652: [clang-cl, PCH] Implement support for MS-style PCH through headers

2018-06-26 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

This looks reasonable to me as far as I can tell. Thanks!

I think the expert on the driver side for this stuff is Nico, so hopefully he 
can take a look as well.




Comment at: include/clang/Basic/DiagnosticLexKinds.td:412
+  "%select{create|use}1 precompiled header">, DefaultFatal;
+def err_pp_macro_def_mismatch_with_pch : Warning<
+  "definition of macro %0 does not match definition in precompiled header">,

Should probably just have a warn_ prefix.



Comment at: include/clang/Driver/CC1Options.td:604
+  HelpText<"When creating a pch stop at this file.  When using a pch start "
+   "after this file.">;
 def fno_pch_timestamp : Flag<["-"], "fno-pch-timestamp">,

The "through header" terminology was new to me, and I didn't see it when 
browsing the MSDN articles about precompiled headers. The HelpText here 
probably isn't the right place, but it would be good if the term could be 
documented somewhere to make it clearer exactly what the behaviour is. It's not 
really obvious to me what "stop at this file" and "start after this file"  
means. I can guess, but it would be nice if it were more explicit :-)



Comment at: include/clang/Lex/Preprocessor.h:2050
+PCHThroughHeaderFileID = FID;
+  }
+

I would probably define this out-of-line like the other methods you added, but 
no big deal.



Comment at: lib/Driver/ToolChains/Clang.cpp:1091
+  Args.MakeArgString(Twine("-pch-through-header=") + ThroughHeader));
 }
   }

In r335466, I added the -building-pch-with-obj flag. This is probably the right 
place to pass it when there's a /Yc flag.



Comment at: lib/Lex/PPDirectives.cpp:1887
+  SkippingUntilPCHThroughHeader = false;
+return;
+  }

Returning here seemed surprising to me. Isn't just setting the flag and then 
carrying on as usual what we want?



Comment at: lib/Lex/PPLexerChange.cpp:344
   const bool LeavingSubmodule = CurLexer && CurLexerSubmodule;
+  bool LeavingPCHThroughHeader = false;
   if ((LeavingSubmodule || IncludeMacroStack.empty()) &&

Maybe move this down to where it's first used?



Comment at: lib/Lex/Preprocessor.cpp:583
+
+/// Return true if the FileEntry is the PCH through header.
+bool Preprocessor::isPCHThroughHeader(const FileEntry *FE) {

I know some functions already do this, but I don't think repeating the comment 
from the .h file here is necessary, it's just another thing to keep in sync. 
Same for the other small methods below.



Comment at: lib/Lex/Preprocessor.cpp:607
+void Preprocessor::SkipTokensUntilPCHThroughHeader()
+{
+  bool ReachedMainFileEOF = false;

nit: curly on the previous line



Comment at: test/PCH/pch-through2.cpp:3
+// RUN: %clang_cc1 -I %S -emit-pch \
+// RUN:   -pch-through-header=Inputs/pch-through2.h -o %t.s2t2 %s
+

What's s2t2 for? From what I see, there's only two pch files used in this test, 
so I would have gone with %t.1 and %t.2


https://reviews.llvm.org/D46652



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


[PATCH] D48499: [mips] Use more conservative default CPUs for MIPS on FreeBSD.

2018-06-26 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D48499



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


r335600 - [ASTImporter] Use InjectedClassNameType at import of templated record.

2018-06-26 Thread Gabor Marton via cfe-commits
Author: martong
Date: Tue Jun 26 06:44:24 2018
New Revision: 335600

URL: http://llvm.org/viewvc/llvm-project?rev=335600&view=rev
Log:
[ASTImporter] Use InjectedClassNameType at import of templated record.

Summary:
At import of a record describing a template set its type to
InjectedClassNameType (instead of RecordType).

Reviewers: a.sidorin, martong, r.stahl

Reviewed By: a.sidorin, martong, r.stahl

Subscribers: a_sidorin, rnkovacs, martong, cfe-commits

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

Patch by Balazs Keri!

Added:
cfe/trunk/test/ASTMerge/injected-class-name-decl/
cfe/trunk/test/ASTMerge/injected-class-name-decl/Inputs/
cfe/trunk/test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp
cfe/trunk/test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp
cfe/trunk/test/ASTMerge/injected-class-name-decl/test.cpp
Modified:
cfe/trunk/lib/AST/ASTImporter.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=335600&r1=335599&r2=335600&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Jun 26 06:44:24 2018
@@ -2135,6 +2135,29 @@ Decl *ASTNodeImporter::VisitRecordDecl(R
 if (!ToDescribed)
   return nullptr;
 D2CXX->setDescribedClassTemplate(ToDescribed);
+if (!DCXX->isInjectedClassName()) {
+  // In a record describing a template the type should be an
+  // InjectedClassNameType (see Sema::CheckClassTemplate). Update the
+  // previously set type to the correct value here (ToDescribed is not
+  // available at record create).
+  // FIXME: The previous type is cleared but not removed from
+  // ASTContext's internal storage.
+  CXXRecordDecl *Injected = nullptr;
+  for (NamedDecl *Found : D2CXX->noload_lookup(Name)) {
+auto *Record = dyn_cast(Found);
+if (Record && Record->isInjectedClassName()) {
+  Injected = Record;
+  break;
+}
+  }
+  D2CXX->setTypeForDecl(nullptr);
+  Importer.getToContext().getInjectedClassNameType(D2CXX,
+  ToDescribed->getInjectedClassNameSpecialization());
+  if (Injected) {
+Injected->setTypeForDecl(nullptr);
+Importer.getToContext().getTypeDeclType(Injected, D2CXX);
+  }
+}
   } else if (MemberSpecializationInfo *MemberInfo =
DCXX->getMemberSpecializationInfo()) {
 TemplateSpecializationKind SK =

Added: cfe/trunk/test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp?rev=335600&view=auto
==
--- cfe/trunk/test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp (added)
+++ cfe/trunk/test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp Tue Jun 
26 06:44:24 2018
@@ -0,0 +1,2 @@
+template 
+class C { static X x; };

Added: cfe/trunk/test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp?rev=335600&view=auto
==
--- cfe/trunk/test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp (added)
+++ cfe/trunk/test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp Tue Jun 
26 06:44:24 2018
@@ -0,0 +1,2 @@
+template 
+X C::x;

Added: cfe/trunk/test/ASTMerge/injected-class-name-decl/test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/injected-class-name-decl/test.cpp?rev=335600&view=auto
==
--- cfe/trunk/test/ASTMerge/injected-class-name-decl/test.cpp (added)
+++ cfe/trunk/test/ASTMerge/injected-class-name-decl/test.cpp Tue Jun 26 
06:44:24 2018
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -std=c++1z -emit-pch -o %t.ast %S/Inputs/inject1.cpp
+// RUN: %clang_cc1 -std=c++1z -emit-obj -o /dev/null -ast-merge %t.ast 
%S/Inputs/inject2.cpp
+// expected-no-diagnostics


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


[PATCH] D47450: [ASTImporter] Use InjectedClassNameType at import of templated record.

2018-06-26 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC335600: [ASTImporter] Use InjectedClassNameType at import of 
templated record. (authored by martong, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47450?vs=152634&id=152880#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47450

Files:
  lib/AST/ASTImporter.cpp
  test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp
  test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp
  test/ASTMerge/injected-class-name-decl/test.cpp


Index: test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp
===
--- test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp
+++ test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp
@@ -0,0 +1,2 @@
+template 
+X C::x;
Index: test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp
===
--- test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp
+++ test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp
@@ -0,0 +1,2 @@
+template 
+class C { static X x; };
Index: test/ASTMerge/injected-class-name-decl/test.cpp
===
--- test/ASTMerge/injected-class-name-decl/test.cpp
+++ test/ASTMerge/injected-class-name-decl/test.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -std=c++1z -emit-pch -o %t.ast %S/Inputs/inject1.cpp
+// RUN: %clang_cc1 -std=c++1z -emit-obj -o /dev/null -ast-merge %t.ast 
%S/Inputs/inject2.cpp
+// expected-no-diagnostics
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2135,6 +2135,29 @@
 if (!ToDescribed)
   return nullptr;
 D2CXX->setDescribedClassTemplate(ToDescribed);
+if (!DCXX->isInjectedClassName()) {
+  // In a record describing a template the type should be an
+  // InjectedClassNameType (see Sema::CheckClassTemplate). Update the
+  // previously set type to the correct value here (ToDescribed is not
+  // available at record create).
+  // FIXME: The previous type is cleared but not removed from
+  // ASTContext's internal storage.
+  CXXRecordDecl *Injected = nullptr;
+  for (NamedDecl *Found : D2CXX->noload_lookup(Name)) {
+auto *Record = dyn_cast(Found);
+if (Record && Record->isInjectedClassName()) {
+  Injected = Record;
+  break;
+}
+  }
+  D2CXX->setTypeForDecl(nullptr);
+  Importer.getToContext().getInjectedClassNameType(D2CXX,
+  ToDescribed->getInjectedClassNameSpecialization());
+  if (Injected) {
+Injected->setTypeForDecl(nullptr);
+Importer.getToContext().getTypeDeclType(Injected, D2CXX);
+  }
+}
   } else if (MemberSpecializationInfo *MemberInfo =
DCXX->getMemberSpecializationInfo()) {
 TemplateSpecializationKind SK =


Index: test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp
===
--- test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp
+++ test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp
@@ -0,0 +1,2 @@
+template 
+X C::x;
Index: test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp
===
--- test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp
+++ test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp
@@ -0,0 +1,2 @@
+template 
+class C { static X x; };
Index: test/ASTMerge/injected-class-name-decl/test.cpp
===
--- test/ASTMerge/injected-class-name-decl/test.cpp
+++ test/ASTMerge/injected-class-name-decl/test.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -std=c++1z -emit-pch -o %t.ast %S/Inputs/inject1.cpp
+// RUN: %clang_cc1 -std=c++1z -emit-obj -o /dev/null -ast-merge %t.ast %S/Inputs/inject2.cpp
+// expected-no-diagnostics
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2135,6 +2135,29 @@
 if (!ToDescribed)
   return nullptr;
 D2CXX->setDescribedClassTemplate(ToDescribed);
+if (!DCXX->isInjectedClassName()) {
+  // In a record describing a template the type should be an
+  // InjectedClassNameType (see Sema::CheckClassTemplate). Update the
+  // previously set type to the correct value here (ToDescribed is not
+  // available at record create).
+  // FIXME: The previous type is cleared but not removed from
+  // ASTContext's internal storage.
+  CXXRecordDecl *Injected = nullptr;
+  for (NamedDecl *Found : D2CXX->noload_lookup(Name)) {

[PATCH] D46940: [ASTImporter] make sure that ACtx::getParents still works

2018-06-26 Thread Rafael Stahl via Phabricator via cfe-commits
r.stahl added a comment.

@rsmith do you have a chance to take a look or assign someone else?


https://reviews.llvm.org/D46940



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


[PATCH] D48241: [DebugInfo] Emit ObjC methods as part of interface.

2018-06-26 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

I tested this patch on the LLDB test suite and all tests passed.

What I did was:

- I removed the DWARF version check in clang so this was always generated.
- I commented out the code that reads the .apple_objc accelerator tables in 
DWARFASTParserClang.cpp (which as far as I can tell is the only consumer). I 
expected to have to add logic to read the methods but the code already takes 
care of that, and just had a special if-clause for Objective-C classes. This is 
actually quite nice, as we don't need a code change to make both things working 
next to each other.


https://reviews.llvm.org/D48241



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


[PATCH] D48241: [DebugInfo] Emit ObjC methods as part of interface.

2018-06-26 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere updated this revision to Diff 152883.
JDevlieghere added a comment.

- Update diff to version I used for testing (modulo the removed DWARF version 
check)


https://reviews.llvm.org/D48241

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -98,6 +98,15 @@
   /// Cache of previously constructed interfaces which may change.
   llvm::SmallVector ObjCInterfaceCache;
 
+  struct ObjCMethodCacheEntry {
+const ObjCMethodDecl *MD;
+llvm::DISubprogram *DIMethodDecl;
+  };
+
+  /// Cache of forward declarations for methods belonging to the interface.
+  llvm::DenseMap>
+  ObjCMethodCache;
+
   /// Cache of references to clang modules and precompiled headers.
   llvm::DenseMap ModuleCache;
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3346,6 +3346,27 @@
   if (HasDecl && isa(D))
 DeclCache[D->getCanonicalDecl()].reset(SP);
 
+  if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
+// Starting with DWARF V5 method declarations are emitted as children of
+// the interface type.
+if (const auto *OMD = dyn_cast_or_null(D)) {
+  const ObjCInterfaceDecl *ID = OMD->getClassInterface();
+  QualType QTy(ID->getTypeForDecl(), 0);
+  auto it = TypeCache.find(QTy.getAsOpaquePtr());
+  if (it != TypeCache.end()) {
+llvm::DICompositeType *InterfaceDecl =
+cast(it->second);
+llvm::DISubprogram *FD = DBuilder.createFunction(
+InterfaceDecl, Name, LinkageName, Unit, LineNo,
+getOrCreateFunctionType(D, FnType, Unit), Fn->hasLocalLinkage(),
+false /*definition*/, ScopeLine, Flags, CGM.getLangOpts().Optimize,
+TParamsArray.get());
+DBuilder.finalizeSubprogram(FD);
+ObjCMethodCache[ID].push_back({OMD, FD});
+  }
+}
+  }
+
   // Push the function onto the lexical block stack.
   LexicalBlockStack.emplace_back(SP);
 
@@ -4213,6 +4234,30 @@
 DBuilder.replaceTemporary(llvm::TempDIType(E.Decl), Ty);
   }
 
+  if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
+// Add methods to interface.
+for (auto p : ObjCMethodCache) {
+  if (p.second.empty())
+continue;
+
+  QualType QTy(p.first->getTypeForDecl(), 0);
+  auto it = TypeCache.find(QTy.getAsOpaquePtr());
+  if (it == TypeCache.end())
+continue;
+
+  llvm::DICompositeType *InterfaceDecl =
+  cast(it->second);
+
+  SmallVector EltTys;
+  auto CurrenetElts = InterfaceDecl->getElements();
+  EltTys.append(CurrenetElts.begin(), CurrenetElts.end());
+  for (auto &M : p.second)
+EltTys.push_back(M.DIMethodDecl);
+  llvm::DINodeArray Elements = DBuilder.getOrCreateArray(EltTys);
+  DBuilder.replaceArrays(InterfaceDecl, Elements);
+}
+  }
+
   for (auto p : ReplaceMap) {
 assert(p.second);
 auto *Ty = cast(p.second);


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -98,6 +98,15 @@
   /// Cache of previously constructed interfaces which may change.
   llvm::SmallVector ObjCInterfaceCache;
 
+  struct ObjCMethodCacheEntry {
+const ObjCMethodDecl *MD;
+llvm::DISubprogram *DIMethodDecl;
+  };
+
+  /// Cache of forward declarations for methods belonging to the interface.
+  llvm::DenseMap>
+  ObjCMethodCache;
+
   /// Cache of references to clang modules and precompiled headers.
   llvm::DenseMap ModuleCache;
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3346,6 +3346,27 @@
   if (HasDecl && isa(D))
 DeclCache[D->getCanonicalDecl()].reset(SP);
 
+  if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
+// Starting with DWARF V5 method declarations are emitted as children of
+// the interface type.
+if (const auto *OMD = dyn_cast_or_null(D)) {
+  const ObjCInterfaceDecl *ID = OMD->getClassInterface();
+  QualType QTy(ID->getTypeForDecl(), 0);
+  auto it = TypeCache.find(QTy.getAsOpaquePtr());
+  if (it != TypeCache.end()) {
+llvm::DICompositeType *InterfaceDecl =
+cast(it->second);
+llvm::DISubprogram *FD = DBuilder.createFunction(
+InterfaceDecl, Name, LinkageName, Unit, LineNo,
+getOrCreateFunctionType(D, FnType, Unit), Fn->hasLocalLinkage(),
+false /*definition*/, ScopeLine, Flags, CGM.getLangOpts().Optimize,
+TParamsArray.get());
+DBuilder.finalizeSubprogram(FD);
+ObjCMethodCache[ID].push_back({OMD, FD});
+  }
+}
+  }
+
   // Push the function onto the lexical block stack.
   LexicalBlock

[PATCH] D48342: [libcxx] Optimize vectors construction of trivial types from an iterator range with const-ness mismatch.

2018-06-26 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Hi Volodymyr, thanks for working on this!




Comment at: libcxx/include/memory:1479
+struct __has_construct_missing
+: false_type
+{

Shouldn't this be true_type?



Comment at: libcxx/include/memory:1673-1677
+(is_same
+ <
+typename _VSTD::remove_const::type,
+typename _VSTD::remove_const<_SourceTp>::type
+ >::value

I'm not sure if this is correct. Previously, we only selected this overload if 
the allocator didn't have a construct() member, or if it was a std::allocator, 
in which case we know construct() just called in-place new. With this patch, we 
would select this overload for a custom allocator that overrode construct() so 
long as the value_types matched. I think the right behaviour for the custom 
allocator case would be to use the construct() member instead of memcpying.


https://reviews.llvm.org/D48342



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


[PATCH] D47906: [ThinLTO] Add testing of summary index parsing to a couple CFI tests

2018-06-26 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

ping (assuming this is ok, but since I sent for review...)


Repository:
  rC Clang

https://reviews.llvm.org/D47906



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


[PATCH] D48562: [clangd] XPC transport layer

2018-06-26 Thread Jan Korous via Phabricator via cfe-commits
jkorous added inline comments.



Comment at: xpc/test-client/ClangdXPCTestClient.cpp:51
+  dlHandle, "clangd_xpc_get_bundle_identifier");
+  xpc_connection_t conn =
+  xpc_connection_create(clangd_xpc_get_bundle_identifier(), NULL);

arphaman wrote:
> We should probably use the main queue here too to ensure that we don't get 
> bit by concurrent handler invocations. 
As far as I understand it this is taken care of by calling dispatch_main().

Per man dispatch_main:
"MAIN QUEUE
[...]
 Programs must call dispatch_main() at the end of main() in order to 
process blocks submitted to the main queue."



Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48562



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


[PATCH] D48562: [clangd] XPC transport layer

2018-06-26 Thread Jan Korous via Phabricator via cfe-commits
jkorous updated this revision to Diff 152888.
jkorous added a comment.

Two changes in test client based on internal review by XPC folks:

- Removed cleanup code at the end of main() as dispatch_main() never returns.
- Removed check for conn as xpc_connection_create() is guaranteed to succeed.


https://reviews.llvm.org/D48562

Files:
  CMakeLists.txt
  Features.inc.in
  ProtocolHandlers.h
  clangd/CMakeLists.txt
  clangd/xpc/initialize.test
  lit.cfg
  lit.site.cfg.in
  tool/CMakeLists.txt
  tool/ClangdMain.cpp
  xpc/CMakeLists.txt
  xpc/README.txt
  xpc/XPCDispatcher.cpp
  xpc/XPCDispatcher.h
  xpc/cmake/Info.plist.in
  xpc/cmake/XPCServiceInfo.plist.in
  xpc/cmake/modules/CreateClangdXPCFramework.cmake
  xpc/framework/CMakeLists.txt
  xpc/framework/ClangdXPC.cpp
  xpc/test-client/CMakeLists.txt
  xpc/test-client/ClangdXPCTestClient.cpp

Index: clangd/CMakeLists.txt
===
--- clangd/CMakeLists.txt
+++ clangd/CMakeLists.txt
@@ -52,3 +52,7 @@
   LLVMSupport
   LLVMTestingSupport
   )
+
+if (CLANGD_BUILD_XPC_SUPPORT)
+  add_subdirectory(xpc)
+endif ()
Index: lit.site.cfg.in
===
--- lit.site.cfg.in
+++ lit.site.cfg.in
@@ -11,6 +11,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
+config.clangd_xpc_support = @CLANGD_BUILD_XPC_SUPPORT@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: lit.cfg
===
--- lit.cfg
+++ lit.cfg
@@ -117,6 +117,10 @@
 if platform.system() not in ['Windows']:
 config.available_features.add('ansi-escape-sequences')
 
+# XPC support for Clangd.
+if config.clangd_xpc_support:
+config.available_features.add('clangd-xpc-support')
+
 if config.clang_staticanalyzer:
 config.available_features.add('static-analyzer')
 check_clang_tidy = os.path.join(
Index: clangd/xpc/initialize.test
===
--- /dev/null
+++ clangd/xpc/initialize.test
@@ -0,0 +1,10 @@
+# RUN: clangd-xpc-test-client < %s | FileCheck %s
+# REQUIRES: clangd-xpc-support
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootUri":"test:///workspace","capabilities":{},"trace":"off"}}
+# CHECK: {"id":0,"jsonrpc":"2.0","result":{"capabilities":{"codeActionProvider":true,"completionProvider":{"resolveProvider":false,"triggerCharacters":[".",">",":"]},"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"}","moreTriggerCharacter":[]},"documentRangeFormattingProvider":true,"executeCommandProvider":{"commands":["clangd.applyFix"]},"hoverProvider":true,"renameProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"textDocumentSync":2,"workspaceSymbolProvider":true}}}
+
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+# CHECK: {"id":3,"jsonrpc":"2.0","result":null}
+
+{"jsonrpc":"2.0","method":"exit"}
Index: xpc/test-client/ClangdXPCTestClient.cpp
===
--- /dev/null
+++ xpc/test-client/ClangdXPCTestClient.cpp
@@ -0,0 +1,96 @@
+#include "xpc/XPCJSONConversions.h"
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+#include 
+#include 
+#include 
+
+typedef const char *(*clangd_xpc_get_bundle_identifier_t)(void);
+
+using namespace llvm;
+using namespace clang;
+
+std::string getLibraryPath() {
+  Dl_info info;
+  if (dladdr((void *)(uintptr_t)getLibraryPath, &info) == 0)
+llvm_unreachable("Call to dladdr() failed");
+  llvm::SmallString<128> LibClangPath;
+  LibClangPath = llvm::sys::path::parent_path(
+  llvm::sys::path::parent_path(info.dli_fname));
+  llvm::sys::path::append(LibClangPath, "lib", "ClangdXPC.framework",
+  "ClangdXPC");
+  return LibClangPath.str();
+}
+
+static void dumpXPCObject(xpc_object_t Object, llvm::raw_ostream &OS) {
+  xpc_type_t Type = xpc_get_type(Object);
+  if (Type == XPC_TYPE_DICTIONARY) {
+clang::clangd::json::Expr Json = clang::clangd::xpcToJson(Object);
+OS << Json;
+  } else {
+OS << "";
+  }
+}
+
+int main(int argc, char *argv[]) {
+  // Open the ClangdXPC dylib in the framework.
+  std::string LibPath = getLibraryPath();
+  void *dlHandle = dlopen(LibPath.c_str(), RTLD_LOCAL | RTLD_FIRST);
+  if (!dlHandle)
+return 1;
+
+  // Lookup the XPC service bundle name, and launch it.
+  clangd_xpc_get_bundle_identifier_t clangd_xpc_get_bundle_identifier =
+  (clangd_xpc_get_bundle_identifier_t)dlsym(
+  dlH

r335614 - Avoid spurious 'comma operator within array index expression' MSVC warning. NFCI.

2018-06-26 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Jun 26 08:20:20 2018
New Revision: 335614

URL: http://llvm.org/viewvc/llvm-project?rev=335614&view=rev
Log:
Avoid spurious 'comma operator within array index expression' MSVC warning. 
NFCI.

Split the braces list initialization from the [] map operator to keep MSVC 
happy.

Modified:
cfe/trunk/lib/AST/ItaniumCXXABI.cpp

Modified: cfe/trunk/lib/AST/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumCXXABI.cpp?rev=335614&r1=335613&r2=335614&view=diff
==
--- cfe/trunk/lib/AST/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumCXXABI.cpp Tue Jun 26 08:20:20 2018
@@ -135,9 +135,10 @@ public:
 
   /// Variable decls are numbered by identifier.
   unsigned getManglingNumber(const VarDecl *VD, unsigned) override {
-if (auto *DD = dyn_cast(VD))
-  return ++DecompsitionDeclManglingNumbers[
-  DecompositionDeclName{DD->bindings()}];
+if (auto *DD = dyn_cast(VD)) {
+  DecompositionDeclName Name{DD->bindings()};
+  return ++DecompsitionDeclManglingNumbers[Name];
+}
 
 const IdentifierInfo *Identifier = VD->getIdentifier();
 if (!Identifier) {


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


[PATCH] D47906: [ThinLTO] Add testing of summary index parsing to a couple CFI tests

2018-06-26 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D47906



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


[PATCH] D48241: [DebugInfo] Emit ObjC methods as part of interface.

2018-06-26 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere updated this revision to Diff 152896.
JDevlieghere added a comment.

- Re-add test case (forgot to stage it for last patch)


https://reviews.llvm.org/D48241

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenObjC/debug-info-category.m

Index: test/CodeGenObjC/debug-info-category.m
===
--- /dev/null
+++ test/CodeGenObjC/debug-info-category.m
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -debug-info-kind=limited -w -triple x86_64-apple-darwin10 %s -o - | FileCheck %s --check-prefix CHECK --check-prefix DWARF5
+// RUN: %clang_cc1 -dwarf-version=4 -emit-llvm -debug-info-kind=limited -w -triple x86_64-apple-darwin10 %s -o - | FileCheck %s --check-prefix CHECK --check-prefix DWARF4
+
+@interface Foo {
+  int integer;
+}
+
+- (int)integer;
+- (id)integer:(int)_integer;
+@end
+
+@implementation Foo
+- (int)integer {
+  return integer;
+}
+
+- (id)integer:(int)_integer {
+  integer = _integer;
+  return self;
+}
+@end
+
+@interface Foo (Bar)
+- (id)add:(Foo *)addend;
+@end
+
+@implementation Foo (Bar)
+- (id)add:(Foo *)addend {
+  return [self integer:[self integer] + [addend integer]];
+}
+@end
+
+// CHECK: ![[STRUCT:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Foo"
+
+// DWARF5: !DISubprogram(name: "-[Foo integer]", scope: ![[STRUCT]], {{.*}}isDefinition: false
+// DWARF5: !DISubprogram(name: "-[Foo integer:]", scope: ![[STRUCT]], {{.*}}isDefinition: false
+// DWARF5: !DISubprogram(name: "-[Foo(Bar) add:]", scope: ![[STRUCT]], {{.*}}isDefinition: false
+
+// DWARF4-NOT: !DISubprogram(name: "-[Foo integer]", scope: ![[STRUCT]], {{.*}}isDefinition: false
+// DWARF4-NOT: !DISubprogram(name: "-[Foo integer:]", scope: ![[STRUCT]], {{.*}}isDefinition: false
+// DWARF4-NOT: !DISubprogram(name: "-[Foo(Bar) add:]", scope: ![[STRUCT]], {{.*}}isDefinition: false
+
+// CHECK: = distinct !DISubprogram(name: "-[Foo integer]"{{.*}}isDefinition: true
+// CHECK: = distinct !DISubprogram(name: "-[Foo integer:]"{{.*}}isDefinition: true
+// CHECK: = distinct !DISubprogram(name: "-[Foo(Bar) add:]"{{.*}}isDefinition: true
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -98,6 +98,15 @@
   /// Cache of previously constructed interfaces which may change.
   llvm::SmallVector ObjCInterfaceCache;
 
+  struct ObjCMethodCacheEntry {
+const ObjCMethodDecl *MD;
+llvm::DISubprogram *DIMethodDecl;
+  };
+
+  /// Cache of forward declarations for methods belonging to the interface.
+  llvm::DenseMap>
+  ObjCMethodCache;
+
   /// Cache of references to clang modules and precompiled headers.
   llvm::DenseMap ModuleCache;
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3346,6 +3346,27 @@
   if (HasDecl && isa(D))
 DeclCache[D->getCanonicalDecl()].reset(SP);
 
+  if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
+// Starting with DWARF V5 method declarations are emitted as children of
+// the interface type.
+if (const auto *OMD = dyn_cast_or_null(D)) {
+  const ObjCInterfaceDecl *ID = OMD->getClassInterface();
+  QualType QTy(ID->getTypeForDecl(), 0);
+  auto it = TypeCache.find(QTy.getAsOpaquePtr());
+  if (it != TypeCache.end()) {
+llvm::DICompositeType *InterfaceDecl =
+cast(it->second);
+llvm::DISubprogram *FD = DBuilder.createFunction(
+InterfaceDecl, Name, LinkageName, Unit, LineNo,
+getOrCreateFunctionType(D, FnType, Unit), Fn->hasLocalLinkage(),
+false /*definition*/, ScopeLine, Flags, CGM.getLangOpts().Optimize,
+TParamsArray.get());
+DBuilder.finalizeSubprogram(FD);
+ObjCMethodCache[ID].push_back({OMD, FD});
+  }
+}
+  }
+
   // Push the function onto the lexical block stack.
   LexicalBlockStack.emplace_back(SP);
 
@@ -4213,6 +4234,30 @@
 DBuilder.replaceTemporary(llvm::TempDIType(E.Decl), Ty);
   }
 
+  if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
+// Add methods to interface.
+for (auto p : ObjCMethodCache) {
+  if (p.second.empty())
+continue;
+
+  QualType QTy(p.first->getTypeForDecl(), 0);
+  auto it = TypeCache.find(QTy.getAsOpaquePtr());
+  if (it == TypeCache.end())
+continue;
+
+  llvm::DICompositeType *InterfaceDecl =
+  cast(it->second);
+
+  SmallVector EltTys;
+  auto CurrenetElts = InterfaceDecl->getElements();
+  EltTys.append(CurrenetElts.begin(), CurrenetElts.end());
+  for (auto &M : p.second)
+EltTys.push_back(M.DIMethodDecl);
+  llvm::DINodeArray Elements = DBuilder.getOrCreateArray(EltTys);
+  DBuilder.replaceArrays(InterfaceDecl, Elements);
+}
+  }
+
   for (auto p : ReplaceMap) {
 assert(p.second);
 auto 

[PATCH] D47906: [ThinLTO] Add testing of summary index parsing to a couple CFI tests

2018-06-26 Thread Teresa Johnson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC335618: [ThinLTO] Add testing of summary index parsing to a 
couple CFI tests (authored by tejohnson, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47906?vs=150402&id=152899#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47906

Files:
  test/CodeGen/thinlto-distributed-cfi-devirt.ll
  test/CodeGen/thinlto-distributed-cfi.ll


Index: test/CodeGen/thinlto-distributed-cfi.ll
===
--- test/CodeGen/thinlto-distributed-cfi.ll
+++ test/CodeGen/thinlto-distributed-cfi.ll
@@ -21,6 +21,8 @@
 ; CHECK-LABEL: Index: test/CodeGen/thinlto-distributed-cfi.ll
===
--- test/CodeGen/thinlto-distributed-cfi.ll
+++ test/CodeGen/thinlto-distributed-cfi.ll
@@ -21,6 +21,8 @@
 ; CHECK-LABEL: ___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r335618 - [ThinLTO] Add testing of summary index parsing to a couple CFI tests

2018-06-26 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Tue Jun 26 08:50:34 2018
New Revision: 335618

URL: http://llvm.org/viewvc/llvm-project?rev=335618&view=rev
Log:
[ThinLTO] Add testing of summary index parsing to a couple CFI tests

Summary:
Changes to some clang side tests to go with the summary parsing patch.

Depends on D47905.

Reviewers: pcc, dexonsmith, mehdi_amini

Subscribers: inglorion, eraman, cfe-commits, steven_wu

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

Modified:
cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll

Modified: cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll?rev=335618&r1=335617&r2=335618&view=diff
==
--- cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll Tue Jun 26 
08:50:34 2018
@@ -30,6 +30,8 @@
 ; CHECK-LABEL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll?rev=335618&r1=335617&r2=335618&view=diff
==
--- cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll Tue Jun 26 08:50:34 2018
@@ -21,6 +21,8 @@
 ; CHECK-LABEL: http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48241: [DebugInfo] Emit ObjC methods as part of interface.

2018-06-26 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:4246
+  if (it == TypeCache.end())
+continue;
+

What does it mean that a type is not being found in the cache here?



Comment at: lib/CodeGen/CGDebugInfo.h:102
+  struct ObjCMethodCacheEntry {
+const ObjCMethodDecl *MD;
+llvm::DISubprogram *DIMethodDecl;

The field naming scheme in this struct is not very consistent :-)



Comment at: test/CodeGenObjC/debug-info-category.m:45
+// CHECK: = distinct !DISubprogram(name: "-[Foo integer:]"{{.*}}isDefinition: 
true
+// CHECK: = distinct !DISubprogram(name: "-[Foo(Bar) add:]"{{.*}}isDefinition: 
true

perhaps also add a class method and a category to the test case?


https://reviews.llvm.org/D48241



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


[PATCH] D48325: [analyzer][UninitializedObjectChecker] Support for MemberPointerTypes

2018-06-26 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Polite ping :)


https://reviews.llvm.org/D48325



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


[PATCH] D48507: [mips] Explicitly specify the linker emulation for MIPS on FreeBSD.

2018-06-26 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb added inline comments.



Comment at: lib/Driver/ToolChains/FreeBSD.cpp:197
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf64ltsmip_fbsd");
+break;

atanasyan wrote:
> Does it make a sense to handle N32 ABI case here?
For whatever reason, FreeBSD only supports N32 on big-endian.  However, 
binutils does ship elf32ltsmipsn32_fbsd linker scripts after all, so I could 
handle little-endian N32 here.


Repository:
  rC Clang

https://reviews.llvm.org/D48507



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


[PATCH] D48507: [mips] Explicitly specify the linker emulation for MIPS on FreeBSD.

2018-06-26 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Driver/ToolChains/FreeBSD.cpp:197
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf64ltsmip_fbsd");
+break;

bsdjhb wrote:
> atanasyan wrote:
> > Does it make a sense to handle N32 ABI case here?
> For whatever reason, FreeBSD only supports N32 on big-endian.  However, 
> binutils does ship elf32ltsmipsn32_fbsd linker scripts after all, so I could 
> handle little-endian N32 here.
LGTM with handling the elf32ltsmipsn32_fbsd case.


Repository:
  rC Clang

https://reviews.llvm.org/D48507



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


[PATCH] D48570: [Driver] Do not add -lpthread & -lrt with -static-libsan on Android

2018-06-26 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad updated this revision to Diff 152900.
cryptoad added a comment.

Rebasing.


Repository:
  rC Clang

https://reviews.llvm.org/D48570

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/sanitizer-ld.c


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -153,7 +153,8 @@
 //
 // CHECK-ASAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-ASAN-ANDROID-STATICLIBASAN: libclang_rt.asan-arm-android.a"
-// CHECK-ASAN-ANDROID-STATICLIBASAN: "-lpthread"
+// CHECK-ASAN-ANDROID-STATICLIBASAN-NOT: "-lpthread"
+// CHECK-ASAN-ANDROID-STATICLIBASAN-NOT: "-lrt"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=undefined \
@@ -175,7 +176,8 @@
 //
 // CHECK-UBSAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-UBSAN-ANDROID-STATICLIBASAN: 
libclang_rt.ubsan_standalone-arm-android.a"
-// CHECK-UBSAN-ANDROID-STATICLIBASAN: "-lpthread"
+// CHECK-UBSAN-ANDROID-STATICLIBASAN-NOT: "-lpthread"
+// CHECK-UBSAN-ANDROID-STATICLIBASAN-NOT: "-lrt"
 
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -735,7 +737,8 @@
 // CHECK-SCUDO-ANDROID-STATIC: "-pie"
 // CHECK-SCUDO-ANDROID-STATIC: "--whole-archive" 
"{{.*}}libclang_rt.scudo-arm-android.a" "--no-whole-archive"
 // CHECK-SCUDO-ANDROID-STATIC-NOT: "-lstdc++"
-// CHECK-SCUDO-ANDROID-STATIC: "-lpthread"
+// CHECK-SCUDO-ANDROID-STATIC-NOT: "-lpthread"
+// CHECK-SCUDO-ANDROID-STATIC-NOT: "-lrt"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -564,8 +564,9 @@
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
   CmdArgs.push_back("--no-as-needed");
-  // There's no libpthread or librt on RTEMS.
-  if (TC.getTriple().getOS() != llvm::Triple::RTEMS) {
+  // There's no libpthread or librt on RTEMS & Android.
+  if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
+  !TC.getTriple().isAndroid()) {
 CmdArgs.push_back("-lpthread");
 if (TC.getTriple().getOS() != llvm::Triple::OpenBSD)
   CmdArgs.push_back("-lrt");


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -153,7 +153,8 @@
 //
 // CHECK-ASAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-ASAN-ANDROID-STATICLIBASAN: libclang_rt.asan-arm-android.a"
-// CHECK-ASAN-ANDROID-STATICLIBASAN: "-lpthread"
+// CHECK-ASAN-ANDROID-STATICLIBASAN-NOT: "-lpthread"
+// CHECK-ASAN-ANDROID-STATICLIBASAN-NOT: "-lrt"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=undefined \
@@ -175,7 +176,8 @@
 //
 // CHECK-UBSAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-UBSAN-ANDROID-STATICLIBASAN: libclang_rt.ubsan_standalone-arm-android.a"
-// CHECK-UBSAN-ANDROID-STATICLIBASAN: "-lpthread"
+// CHECK-UBSAN-ANDROID-STATICLIBASAN-NOT: "-lpthread"
+// CHECK-UBSAN-ANDROID-STATICLIBASAN-NOT: "-lrt"
 
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -735,7 +737,8 @@
 // CHECK-SCUDO-ANDROID-STATIC: "-pie"
 // CHECK-SCUDO-ANDROID-STATIC: "--whole-archive" "{{.*}}libclang_rt.scudo-arm-android.a" "--no-whole-archive"
 // CHECK-SCUDO-ANDROID-STATIC-NOT: "-lstdc++"
-// CHECK-SCUDO-ANDROID-STATIC: "-lpthread"
+// CHECK-SCUDO-ANDROID-STATIC-NOT: "-lpthread"
+// CHECK-SCUDO-ANDROID-STATIC-NOT: "-lrt"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -564,8 +564,9 @@
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
   CmdArgs.push_back("--no-as-needed");
-  // There's no libpthread or librt on RTEMS.
-  if (TC.getTriple().getOS() != llvm::Triple::RTEMS) {
+  // There's no libpthread or librt on RTEMS & Android.
+  if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
+  !TC.getTriple().isAndroid()) {
 CmdArgs.push_back("-lpthread");
 if (TC.getTriple().getOS() != llvm::Triple::OpenBSD)
   CmdArgs.push_back("-lrt");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48570: [Driver] Do not add -lpthread & -lrt with -static-libsan on Android

2018-06-26 Thread Kostya Kortchinsky via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC335620: [Driver] Do not add -lpthread & -lrt with 
-static-libsan on Android (authored by cryptoad, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D48570?vs=152900&id=152901#toc

Repository:
  rC Clang

https://reviews.llvm.org/D48570

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/sanitizer-ld.c


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -153,7 +153,8 @@
 //
 // CHECK-ASAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-ASAN-ANDROID-STATICLIBASAN: libclang_rt.asan-arm-android.a"
-// CHECK-ASAN-ANDROID-STATICLIBASAN: "-lpthread"
+// CHECK-ASAN-ANDROID-STATICLIBASAN-NOT: "-lpthread"
+// CHECK-ASAN-ANDROID-STATICLIBASAN-NOT: "-lrt"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=undefined \
@@ -175,7 +176,8 @@
 //
 // CHECK-UBSAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-UBSAN-ANDROID-STATICLIBASAN: 
libclang_rt.ubsan_standalone-arm-android.a"
-// CHECK-UBSAN-ANDROID-STATICLIBASAN: "-lpthread"
+// CHECK-UBSAN-ANDROID-STATICLIBASAN-NOT: "-lpthread"
+// CHECK-UBSAN-ANDROID-STATICLIBASAN-NOT: "-lrt"
 
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -735,7 +737,8 @@
 // CHECK-SCUDO-ANDROID-STATIC: "-pie"
 // CHECK-SCUDO-ANDROID-STATIC: "--whole-archive" 
"{{.*}}libclang_rt.scudo-arm-android.a" "--no-whole-archive"
 // CHECK-SCUDO-ANDROID-STATIC-NOT: "-lstdc++"
-// CHECK-SCUDO-ANDROID-STATIC: "-lpthread"
+// CHECK-SCUDO-ANDROID-STATIC-NOT: "-lpthread"
+// CHECK-SCUDO-ANDROID-STATIC-NOT: "-lrt"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -564,8 +564,9 @@
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
   CmdArgs.push_back("--no-as-needed");
-  // There's no libpthread or librt on RTEMS.
-  if (TC.getTriple().getOS() != llvm::Triple::RTEMS) {
+  // There's no libpthread or librt on RTEMS & Android.
+  if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
+  !TC.getTriple().isAndroid()) {
 CmdArgs.push_back("-lpthread");
 if (TC.getTriple().getOS() != llvm::Triple::OpenBSD)
   CmdArgs.push_back("-lrt");


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -153,7 +153,8 @@
 //
 // CHECK-ASAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-ASAN-ANDROID-STATICLIBASAN: libclang_rt.asan-arm-android.a"
-// CHECK-ASAN-ANDROID-STATICLIBASAN: "-lpthread"
+// CHECK-ASAN-ANDROID-STATICLIBASAN-NOT: "-lpthread"
+// CHECK-ASAN-ANDROID-STATICLIBASAN-NOT: "-lrt"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=undefined \
@@ -175,7 +176,8 @@
 //
 // CHECK-UBSAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-UBSAN-ANDROID-STATICLIBASAN: libclang_rt.ubsan_standalone-arm-android.a"
-// CHECK-UBSAN-ANDROID-STATICLIBASAN: "-lpthread"
+// CHECK-UBSAN-ANDROID-STATICLIBASAN-NOT: "-lpthread"
+// CHECK-UBSAN-ANDROID-STATICLIBASAN-NOT: "-lrt"
 
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -735,7 +737,8 @@
 // CHECK-SCUDO-ANDROID-STATIC: "-pie"
 // CHECK-SCUDO-ANDROID-STATIC: "--whole-archive" "{{.*}}libclang_rt.scudo-arm-android.a" "--no-whole-archive"
 // CHECK-SCUDO-ANDROID-STATIC-NOT: "-lstdc++"
-// CHECK-SCUDO-ANDROID-STATIC: "-lpthread"
+// CHECK-SCUDO-ANDROID-STATIC-NOT: "-lpthread"
+// CHECK-SCUDO-ANDROID-STATIC-NOT: "-lrt"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -564,8 +564,9 @@
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
   CmdArgs.push_back("--no-as-needed");
-  // There's no libpthread or librt on RTEMS.
-  if (TC.getTriple().getOS() != llvm::Triple::RTEMS) {
+  // There's no libpthread or librt on RTEMS & Android.
+  if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
+  !TC.getTriple().isAndroid()) {
 CmdArgs.push_back("-lpthread");
 if (TC.getTriple().getOS() != llvm::Triple::OpenBSD)
   CmdArgs.push_back("-lrt");
_

r335620 - [Driver] Do not add -lpthread & -lrt with -static-libsan on Android

2018-06-26 Thread Kostya Kortchinsky via cfe-commits
Author: cryptoad
Date: Tue Jun 26 09:14:35 2018
New Revision: 335620

URL: http://llvm.org/viewvc/llvm-project?rev=335620&view=rev
Log:
[Driver] Do not add -lpthread & -lrt with -static-libsan on Android

Summary:
I am not sure anyone has tried to compile an application with sanitizers on
Android with `-static-libsan`, and a recent NDK, but it fails with:
```
.../i686-linux-android/bin/ld.gold: error: cannot find -lpthread
.../i686-linux-android/bin/ld.gold: error: cannot find -lrt
```
My understanding is that both are included in Bionic and as such are not needed,
and actually error out.

So remove the addition of those two in `linkSanitizerRuntimeDeps` when dealing
with Android, and update the tests.

I am unfamiliar with the evolution of the NDK and I am not sure if this has
always been the case or if this is somewhat of a recent evolution. I'll let
Android people chime in.

Reviewers: eugenis, pirama, srhines

Reviewed By: eugenis, srhines

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=335620&r1=335619&r2=335620&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Tue Jun 26 09:14:35 2018
@@ -564,8 +564,9 @@ void tools::linkSanitizerRuntimeDeps(con
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
   CmdArgs.push_back("--no-as-needed");
-  // There's no libpthread or librt on RTEMS.
-  if (TC.getTriple().getOS() != llvm::Triple::RTEMS) {
+  // There's no libpthread or librt on RTEMS & Android.
+  if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
+  !TC.getTriple().isAndroid()) {
 CmdArgs.push_back("-lpthread");
 if (TC.getTriple().getOS() != llvm::Triple::OpenBSD)
   CmdArgs.push_back("-lrt");

Modified: cfe/trunk/test/Driver/sanitizer-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=335620&r1=335619&r2=335620&view=diff
==
--- cfe/trunk/test/Driver/sanitizer-ld.c (original)
+++ cfe/trunk/test/Driver/sanitizer-ld.c Tue Jun 26 09:14:35 2018
@@ -153,7 +153,8 @@
 //
 // CHECK-ASAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-ASAN-ANDROID-STATICLIBASAN: libclang_rt.asan-arm-android.a"
-// CHECK-ASAN-ANDROID-STATICLIBASAN: "-lpthread"
+// CHECK-ASAN-ANDROID-STATICLIBASAN-NOT: "-lpthread"
+// CHECK-ASAN-ANDROID-STATICLIBASAN-NOT: "-lrt"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=undefined \
@@ -175,7 +176,8 @@
 //
 // CHECK-UBSAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-UBSAN-ANDROID-STATICLIBASAN: 
libclang_rt.ubsan_standalone-arm-android.a"
-// CHECK-UBSAN-ANDROID-STATICLIBASAN: "-lpthread"
+// CHECK-UBSAN-ANDROID-STATICLIBASAN-NOT: "-lpthread"
+// CHECK-UBSAN-ANDROID-STATICLIBASAN-NOT: "-lrt"
 
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -735,7 +737,8 @@
 // CHECK-SCUDO-ANDROID-STATIC: "-pie"
 // CHECK-SCUDO-ANDROID-STATIC: "--whole-archive" 
"{{.*}}libclang_rt.scudo-arm-android.a" "--no-whole-archive"
 // CHECK-SCUDO-ANDROID-STATIC-NOT: "-lstdc++"
-// CHECK-SCUDO-ANDROID-STATIC: "-lpthread"
+// CHECK-SCUDO-ANDROID-STATIC-NOT: "-lpthread"
+// CHECK-SCUDO-ANDROID-STATIC-NOT: "-lrt"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \


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


[PATCH] D47632: [ASTImporter] Refactor Decl creation

2018-06-26 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: lib/AST/ASTImporter.cpp:1659
+  AccessSpecDecl *ToD;
+  std::tie(ToD, AlreadyImported) = CreateDecl(
+  D, Importer.getToContext(), D->getAccess(), DC, Loc, ColonLoc);

a.sidorin wrote:
> As I see, all usage samples require having a variable AlreadyImported used 
> only once. How about changing the signature a bit:
> ```bool getOrCreateDecl(ToDeclTy *&ToD, FromDeclT *FromD, Args &&... args)```
> with optional `LLVM_NODISCARD`? (Naming is a subject for discussion).
> This signature also allows us to omit template arguments because we pass an 
> argument of a templated type. So, the call will look like this:
> ```AccessSpecDecl *ToD;
> if (getOrCreateDecl(ToD, D, Importer.getToContext(), D->getAccess(), DC, Loc, 
> ColonLoc))
>   return ToD;```
I like your idea, because indeed we could spare the repetition of the type in 
most cases. However, in one particular case we have to use the original 
version: in `VisitTypedefNameDecl` where we assign either a `TypeAliasDecl *` 
or a `TypedefDecl *` to a pointer to their common base class, `TypedefNameDecl`.
So, I think it is possible to add an overload with the signature `(ToDeclTy 
*&ToD, FromDeclT *FromD, Args &&... args)` and we could use that in the simple 
cases (which is the majority).

About the naming I was thinking about `getAlreadyImportedOrCreateNewDecl`, but 
this appears to be very long. So if you think this is way too long then I am  
OK with the shorter `getOrCreateDecl`.


Repository:
  rC Clang

https://reviews.llvm.org/D47632



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


[PATCH] D48241: [DebugInfo] Emit ObjC methods as part of interface.

2018-06-26 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:3355
+  QualType QTy(ID->getTypeForDecl(), 0);
+  auto it = TypeCache.find(QTy.getAsOpaquePtr());
+  if (it != TypeCache.end()) {

LLVM style rules suggest UpperCamelCase or INITIALISM rather than "it" here:
https://www.llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly





Comment at: lib/CodeGen/CGDebugInfo.cpp:4239
+// Add methods to interface.
+for (auto p : ObjCMethodCache) {
+  if (p.second.empty())

Some comment for "p" here.



Comment at: lib/CodeGen/CGDebugInfo.cpp:4244
+  QualType QTy(p.first->getTypeForDecl(), 0);
+  auto it = TypeCache.find(QTy.getAsOpaquePtr());
+  if (it == TypeCache.end())

And "it" here.


https://reviews.llvm.org/D48241



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


[PATCH] D47847: [clangd] Simplify matches in FindSymbols tests

2018-06-26 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle accepted this revision.
malaperle added a comment.
This revision is now accepted and ready to land.

Self-approving because this is pretty inconsequential.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47847



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


[clang-tools-extra] r335624 - [clangd] Simplify matches in FindSymbols tests

2018-06-26 Thread Marc-Andre Laperle via cfe-commits
Author: malaperle
Date: Tue Jun 26 09:57:44 2018
New Revision: 335624

URL: http://llvm.org/viewvc/llvm-project?rev=335624&view=rev
Log:
[clangd] Simplify matches in FindSymbols tests

Summary:
Instead of checking symbol name and container (scope) separately, check the
qualified name instead. This is much shorter and similar to how it is done
in the SymbolCollector tests.

Signed-off-by: Marc-Andre Laperle 

Reviewers: simark

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, cfe-commits

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

Modified:
clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp?rev=335624&r1=335623&r2=335624&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp Tue Jun 26 
09:57:44 2018
@@ -31,9 +31,10 @@ class IgnoreDiagnostics : public Diagnos
 };
 
 // GMock helpers for matching SymbolInfos items.
-MATCHER_P(Named, Name, "") { return arg.name == Name; }
-MATCHER_P(InContainer, ContainerName, "") {
-  return arg.containerName == ContainerName;
+MATCHER_P(QName, Name, "") {
+  if (arg.containerName.empty())
+return arg.name == Name;
+  return (arg.containerName + "::" + arg.name) == Name;
 }
 MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; }
 
@@ -106,12 +107,10 @@ TEST_F(WorkspaceSymbolsTest, Globals) {
   #include "foo.h"
   )cpp");
   EXPECT_THAT(getSymbols("global"),
-  UnorderedElementsAre(AllOf(Named("GlobalStruct"), 
InContainer(""),
- WithKind(SymbolKind::Struct)),
-   AllOf(Named("global_func"), InContainer(""),
- WithKind(SymbolKind::Function)),
-   AllOf(Named("global_var"), InContainer(""),
- WithKind(SymbolKind::Variable;
+  UnorderedElementsAre(
+  AllOf(QName("GlobalStruct"), WithKind(SymbolKind::Struct)),
+  AllOf(QName("global_func"), WithKind(SymbolKind::Function)),
+  AllOf(QName("global_var"), WithKind(SymbolKind::Variable;
 }
 
 TEST_F(WorkspaceSymbolsTest, Unnamed) {
@@ -123,12 +122,11 @@ TEST_F(WorkspaceSymbolsTest, Unnamed) {
   #include "foo.h"
   )cpp");
   EXPECT_THAT(getSymbols("UnnamedStruct"),
-  ElementsAre(AllOf(Named("UnnamedStruct"),
+  ElementsAre(AllOf(QName("UnnamedStruct"),
 WithKind(SymbolKind::Variable;
-  EXPECT_THAT(
-  getSymbols("InUnnamed"),
-  ElementsAre(AllOf(Named("InUnnamed"), InContainer("(anonymous struct)"),
-WithKind(SymbolKind::Field;
+  EXPECT_THAT(getSymbols("InUnnamed"),
+  ElementsAre(AllOf(QName("(anonymous struct)::InUnnamed"),
+WithKind(SymbolKind::Field;
 }
 
 TEST_F(WorkspaceSymbolsTest, InMainFile) {
@@ -151,28 +149,20 @@ TEST_F(WorkspaceSymbolsTest, Namespaces)
   addFile("foo.cpp", R"cpp(
   #include "foo.h"
   )cpp");
-  EXPECT_THAT(
-  getSymbols("a"),
-  UnorderedElementsAre(AllOf(Named("ans1"), InContainer("")),
-   AllOf(Named("ai1"), InContainer("ans1")),
-   AllOf(Named("ans2"), InContainer("ans1")),
-   AllOf(Named("ai2"), InContainer("ans1::ans2";
-  EXPECT_THAT(getSymbols("::"),
-  ElementsAre(AllOf(Named("ans1"), InContainer("";
-  EXPECT_THAT(getSymbols("::a"),
-  ElementsAre(AllOf(Named("ans1"), InContainer("";
+  EXPECT_THAT(getSymbols("a"),
+  UnorderedElementsAre(QName("ans1"), QName("ans1::ai1"),
+   QName("ans1::ans2"),
+   QName("ans1::ans2::ai2")));
+  EXPECT_THAT(getSymbols("::"), ElementsAre(QName("ans1")));
+  EXPECT_THAT(getSymbols("::a"), ElementsAre(QName("ans1")));
   EXPECT_THAT(getSymbols("ans1::"),
-  UnorderedElementsAre(AllOf(Named("ai1"), InContainer("ans1")),
-   AllOf(Named("ans2"), InContainer("ans1";
-  EXPECT_THAT(getSymbols("::ans1"),
-  ElementsAre(AllOf(Named("ans1"), InContainer("";
+  UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2")));
+  EXPECT_THAT(getSymbols("::ans1"), ElementsAre(QName("ans1")));
   EXPECT_THAT(getSymbols("::ans1::"),
-  UnorderedElementsAre(AllOf(Named("ai1"), InContainer("ans1")),
-   AllOf(Named("ans2"), InContainer("ans1";
-  EXPECT_THAT(getSymbols("::ans1::ans2"),
-  ElementsAre(AllOf(Named("ans2"), InContaine

[PATCH] D47847: [clangd] Simplify matches in FindSymbols tests

2018-06-26 Thread Marc-Andre Laperle via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335624: [clangd] Simplify matches in FindSymbols tests 
(authored by malaperle, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47847

Files:
  clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
@@ -31,9 +31,10 @@
 };
 
 // GMock helpers for matching SymbolInfos items.
-MATCHER_P(Named, Name, "") { return arg.name == Name; }
-MATCHER_P(InContainer, ContainerName, "") {
-  return arg.containerName == ContainerName;
+MATCHER_P(QName, Name, "") {
+  if (arg.containerName.empty())
+return arg.name == Name;
+  return (arg.containerName + "::" + arg.name) == Name;
 }
 MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; }
 
@@ -106,12 +107,10 @@
   #include "foo.h"
   )cpp");
   EXPECT_THAT(getSymbols("global"),
-  UnorderedElementsAre(AllOf(Named("GlobalStruct"), InContainer(""),
- WithKind(SymbolKind::Struct)),
-   AllOf(Named("global_func"), InContainer(""),
- WithKind(SymbolKind::Function)),
-   AllOf(Named("global_var"), InContainer(""),
- WithKind(SymbolKind::Variable;
+  UnorderedElementsAre(
+  AllOf(QName("GlobalStruct"), WithKind(SymbolKind::Struct)),
+  AllOf(QName("global_func"), WithKind(SymbolKind::Function)),
+  AllOf(QName("global_var"), WithKind(SymbolKind::Variable;
 }
 
 TEST_F(WorkspaceSymbolsTest, Unnamed) {
@@ -123,12 +122,11 @@
   #include "foo.h"
   )cpp");
   EXPECT_THAT(getSymbols("UnnamedStruct"),
-  ElementsAre(AllOf(Named("UnnamedStruct"),
+  ElementsAre(AllOf(QName("UnnamedStruct"),
 WithKind(SymbolKind::Variable;
-  EXPECT_THAT(
-  getSymbols("InUnnamed"),
-  ElementsAre(AllOf(Named("InUnnamed"), InContainer("(anonymous struct)"),
-WithKind(SymbolKind::Field;
+  EXPECT_THAT(getSymbols("InUnnamed"),
+  ElementsAre(AllOf(QName("(anonymous struct)::InUnnamed"),
+WithKind(SymbolKind::Field;
 }
 
 TEST_F(WorkspaceSymbolsTest, InMainFile) {
@@ -151,28 +149,20 @@
   addFile("foo.cpp", R"cpp(
   #include "foo.h"
   )cpp");
-  EXPECT_THAT(
-  getSymbols("a"),
-  UnorderedElementsAre(AllOf(Named("ans1"), InContainer("")),
-   AllOf(Named("ai1"), InContainer("ans1")),
-   AllOf(Named("ans2"), InContainer("ans1")),
-   AllOf(Named("ai2"), InContainer("ans1::ans2";
-  EXPECT_THAT(getSymbols("::"),
-  ElementsAre(AllOf(Named("ans1"), InContainer("";
-  EXPECT_THAT(getSymbols("::a"),
-  ElementsAre(AllOf(Named("ans1"), InContainer("";
+  EXPECT_THAT(getSymbols("a"),
+  UnorderedElementsAre(QName("ans1"), QName("ans1::ai1"),
+   QName("ans1::ans2"),
+   QName("ans1::ans2::ai2")));
+  EXPECT_THAT(getSymbols("::"), ElementsAre(QName("ans1")));
+  EXPECT_THAT(getSymbols("::a"), ElementsAre(QName("ans1")));
   EXPECT_THAT(getSymbols("ans1::"),
-  UnorderedElementsAre(AllOf(Named("ai1"), InContainer("ans1")),
-   AllOf(Named("ans2"), InContainer("ans1";
-  EXPECT_THAT(getSymbols("::ans1"),
-  ElementsAre(AllOf(Named("ans1"), InContainer("";
+  UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2")));
+  EXPECT_THAT(getSymbols("::ans1"), ElementsAre(QName("ans1")));
   EXPECT_THAT(getSymbols("::ans1::"),
-  UnorderedElementsAre(AllOf(Named("ai1"), InContainer("ans1")),
-   AllOf(Named("ans2"), InContainer("ans1";
-  EXPECT_THAT(getSymbols("::ans1::ans2"),
-  ElementsAre(AllOf(Named("ans2"), InContainer("ans1";
+  UnorderedElementsAre(QName("ans1::ai1"), QName("ans1::ans2")));
+  EXPECT_THAT(getSymbols("::ans1::ans2"), ElementsAre(QName("ans1::ans2")));
   EXPECT_THAT(getSymbols("::ans1::ans2::"),
-  ElementsAre(AllOf(Named("ai2"), InContainer("ans1::ans2";
+  ElementsAre(QName("ans1::ans2::ai2")));
 }
 
 TEST_F(WorkspaceSymbolsTest, AnonymousNamespace) {
@@ -201,8 +191,7 @@
   #include "foo2.h"
   )cpp");
   EXPECT_THAT(getSymbols("foo"),
-  UnorderedElementsAre(AllOf(Named("foo"), InContainer("")),
-   AllOf(Named("foo2"), I

[PATCH] D48241: [DebugInfo] Emit ObjC methods as part of interface.

2018-06-26 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere updated this revision to Diff 152910.
JDevlieghere marked 6 inline comments as done.
JDevlieghere added a comment.

- Feedback Adrian & Duncan


https://reviews.llvm.org/D48241

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenObjC/debug-info-category.m

Index: test/CodeGenObjC/debug-info-category.m
===
--- /dev/null
+++ test/CodeGenObjC/debug-info-category.m
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -debug-info-kind=limited -w -triple x86_64-apple-darwin10 %s -o - | FileCheck %s --check-prefix CHECK --check-prefix DWARF5
+// RUN: %clang_cc1 -dwarf-version=4 -emit-llvm -debug-info-kind=limited -w -triple x86_64-apple-darwin10 %s -o - | FileCheck %s --check-prefix CHECK --check-prefix DWARF4
+
+@interface Foo {
+  int integer;
+}
+
+- (int)integer;
+- (id)integer:(int)_integer;
+@end
+
+@implementation Foo
+- (int)integer {
+  return integer;
+}
+
+- (id)integer:(int)_integer {
+  integer = _integer;
+  return self;
+}
+@end
+
+@interface Foo (Bar)
++ (id)zero:(Foo *)zeroend;
+- (id)add:(Foo *)addend;
+@end
+
+@implementation Foo (Bar)
++ (id)zero:(Foo *)zeroend {
+  return [self integer:0];
+}
+- (id)add:(Foo *)addend {
+  return [self integer:[self integer] + [addend integer]];
+}
+@end
+
+// CHECK: ![[STRUCT:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Foo"
+
+// DWARF5: !DISubprogram(name: "-[Foo integer]", scope: ![[STRUCT]], {{.*}}isDefinition: false
+// DWARF5: !DISubprogram(name: "-[Foo integer:]", scope: ![[STRUCT]], {{.*}}isDefinition: false
+// DWARF5: !DISubprogram(name: "+[Foo(Bar) zero:]", scope: ![[STRUCT]], {{.*}}isDefinition: false
+// DWARF5: !DISubprogram(name: "-[Foo(Bar) add:]", scope: ![[STRUCT]], {{.*}}isDefinition: false
+
+// DWARF4-NOT: !DISubprogram(name: "-[Foo integer]", scope: ![[STRUCT]], {{.*}}isDefinition: false
+// DWARF4-NOT: !DISubprogram(name: "-[Foo integer:]", scope: ![[STRUCT]], {{.*}}isDefinition: false
+// DWARF4-NOT: !DISubprogram(name: "+[Foo(Bar) zero:]", scope: ![[STRUCT]], {{.*}}isDefinition: false
+// DWARF4-NOT: !DISubprogram(name: "-[Foo(Bar) add:]", scope: ![[STRUCT]], {{.*}}isDefinition: false
+
+// CHECK: = distinct !DISubprogram(name: "-[Foo integer]"{{.*}}isDefinition: true
+// CHECK: = distinct !DISubprogram(name: "-[Foo integer:]"{{.*}}isDefinition: true
+// CHECK: = distinct !DISubprogram(name: "+[Foo(Bar) zero:]"{{.*}}isDefinition: true
+// CHECK: = distinct !DISubprogram(name: "-[Foo(Bar) add:]"{{.*}}isDefinition: true
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -98,6 +98,10 @@
   /// Cache of previously constructed interfaces which may change.
   llvm::SmallVector ObjCInterfaceCache;
 
+  /// Cache of forward declarations for methods belonging to the interface.
+  llvm::DenseMap>
+  ObjCMethodCache;
+
   /// Cache of references to clang modules and precompiled headers.
   llvm::DenseMap ModuleCache;
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3346,6 +3346,27 @@
   if (HasDecl && isa(D))
 DeclCache[D->getCanonicalDecl()].reset(SP);
 
+  if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
+// Starting with DWARF V5 method declarations are emitted as children of
+// the interface type.
+if (const auto *OMD = dyn_cast_or_null(D)) {
+  const ObjCInterfaceDecl *ID = OMD->getClassInterface();
+  QualType QTy(ID->getTypeForDecl(), 0);
+  auto It = TypeCache.find(QTy.getAsOpaquePtr());
+  if (It != TypeCache.end()) {
+llvm::DICompositeType *InterfaceDecl =
+cast(It->second);
+llvm::DISubprogram *FD = DBuilder.createFunction(
+InterfaceDecl, Name, LinkageName, Unit, LineNo,
+getOrCreateFunctionType(D, FnType, Unit), Fn->hasLocalLinkage(),
+false /*definition*/, ScopeLine, Flags, CGM.getLangOpts().Optimize,
+TParamsArray.get());
+DBuilder.finalizeSubprogram(FD);
+ObjCMethodCache[ID].push_back(FD);
+  }
+}
+  }
+
   // Push the function onto the lexical block stack.
   LexicalBlockStack.emplace_back(SP);
 
@@ -4213,6 +4234,29 @@
 DBuilder.replaceTemporary(llvm::TempDIType(E.Decl), Ty);
   }
 
+  if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
+// Add methods to interface.
+for (auto P : ObjCMethodCache) {
+  if (P.second.empty())
+continue;
+
+  QualType QTy(P.first->getTypeForDecl(), 0);
+  auto It = TypeCache.find(QTy.getAsOpaquePtr());
+  assert(It != TypeCache.end());
+
+  llvm::DICompositeType *InterfaceDecl =
+  cast(It->second);
+
+  SmallVector EltTys;
+  auto CurrenetElts = InterfaceDecl->getElements();
+  EltTys.append(CurrenetElts.begin(), CurrenetElts.end());
+  for (auto &

[PATCH] D48241: [DebugInfo] Emit ObjC methods as part of interface.

2018-06-26 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:4239
+// Add methods to interface.
+for (auto p : ObjCMethodCache) {
+  if (p.second.empty())

dexonsmith wrote:
> Some comment for "p" here.
Fixed; I'll update the rest of the file in a follow-up to keep things 
consistent.



Comment at: lib/CodeGen/CGDebugInfo.cpp:4246
+  if (it == TypeCache.end())
+continue;
+

aprantl wrote:
> What does it mean that a type is not being found in the cache here?
Replaced it with an assert. 


https://reviews.llvm.org/D48241



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


[clang-tools-extra] r335626 - Fix -Wdocumentation warning. NFCI.

2018-06-26 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Jun 26 10:00:43 2018
New Revision: 335626

URL: http://llvm.org/viewvc/llvm-project?rev=335626&view=rev
Log:
Fix -Wdocumentation warning. NFCI.

Modified:
clang-tools-extra/trunk/clangd/Headers.h

Modified: clang-tools-extra/trunk/clangd/Headers.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.h?rev=335626&r1=335625&r2=335626&view=diff
==
--- clang-tools-extra/trunk/clangd/Headers.h (original)
+++ clang-tools-extra/trunk/clangd/Headers.h Tue Jun 26 10:00:43 2018
@@ -71,8 +71,7 @@ public:
   /// \param DeclaringHeader is the original header corresponding to \p
   /// InsertedHeader e.g. the header that declares a symbol.
   /// \param InsertedHeader The preferred header to be inserted. This could be
-  /// the same as DeclaringHeader but must be provided. \param Inclusions
-  /// Existing includes in the main file.
+  /// the same as DeclaringHeader but must be provided.
   bool shouldInsertInclude(const HeaderFile &DeclaringHeader,
const HeaderFile &InsertedHeader) const;
 


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


r335628 - Revert "[CMake][Darwin] Match cxx-headers -> cxx_headers libcxx target rename."

2018-06-26 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Tue Jun 26 10:05:01 2018
New Revision: 335628

URL: http://llvm.org/viewvc/llvm-project?rev=335628&view=rev
Log:
Revert "[CMake][Darwin] Match cxx-headers -> cxx_headers libcxx target rename."

This reverts commit r334550. Try to fix the stage2 build failing on
Green Dragon for a while.

http://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/11124/console

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=335628&r1=335627&r2=335628&view=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Tue Jun 26 10:05:01 2018
@@ -61,7 +61,7 @@ set(LLVM_DISTRIBUTION_COMPONENTS
   LTO
   clang-format
   clang-headers
-  cxx_headers
+  cxx-headers
   ${LLVM_TOOLCHAIN_TOOLS}
   CACHE STRING "")
 


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


r335630 - [Test] Initial test commit access

2018-06-26 Thread Aaron Enye Shi via cfe-commits
Author: aaronenyeshi
Date: Tue Jun 26 10:12:29 2018
New Revision: 335630

URL: http://llvm.org/viewvc/llvm-project?rev=335630&view=rev
Log:
[Test] Initial test commit access

Modified:
cfe/trunk/lib/Driver/ToolChains/HIP.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/HIP.cpp?rev=335630&r1=335629&r2=335630&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp Tue Jun 26 10:12:29 2018
@@ -254,7 +254,7 @@ HIPToolChain::TranslateArgs(const llvm::
 
   for (Arg *A : Args) {
 if (A->getOption().matches(options::OPT_Xarch__)) {
-  // Skip this argument unless the architecture matches BoundArch
+  // Skip this argument unless the architecture matches BoundArch.
   if (BoundArch.empty() || A->getValue(0) != BoundArch)
 continue;
 


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


r335632 - [OPENMP, NVPTX] Reduce the number of the globalized variables.

2018-06-26 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jun 26 10:24:03 2018
New Revision: 335632

URL: http://llvm.org/viewvc/llvm-project?rev=335632&view=rev
Log:
[OPENMP, NVPTX] Reduce the number of the globalized variables.

Patch tries to make better analysis of the variables that should be
globalized. From now, instead of all parallel directives it will check
only distribute parallel .. directives and check only for
firstprivte/lastprivate variables if they must be globalized.

Added:
cfe/trunk/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=335632&r1=335631&r2=335632&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue Jun 26 10:24:03 2018
@@ -187,7 +187,7 @@ class CheckVarsEscapingDeclContext final
   RecordDecl *GlobalizedRD = nullptr;
   llvm::SmallDenseMap MappedDeclsFields;
   bool AllEscaped = false;
-  bool IsForParallelRegion = false;
+  bool IsForCombinedParallelRegion = false;
 
   static llvm::Optional
   isDeclareTargetDeclaration(const ValueDecl *VD) {
@@ -210,7 +210,7 @@ class CheckVarsEscapingDeclContext final
   if (const FieldDecl *FD = CSI->lookup(cast(VD))) {
 // Check if need to capture the variable that was already captured by
 // value in the outer region.
-if (!IsForParallelRegion) {
+if (!IsForCombinedParallelRegion) {
   if (!FD->hasAttrs())
 return;
   const auto *Attr = FD->getAttr();
@@ -225,13 +225,13 @@ class CheckVarsEscapingDeclContext final
   assert(!VD->getType()->isVariablyModifiedType() &&
  "Parameter captured by value with variably modified type");
   EscapedParameters.insert(VD);
-} else if (!IsForParallelRegion) {
+} else if (!IsForCombinedParallelRegion) {
   return;
 }
   }
 }
 if ((!CGF.CapturedStmtInfo ||
- (IsForParallelRegion && CGF.CapturedStmtInfo)) &&
+ (IsForCombinedParallelRegion && CGF.CapturedStmtInfo)) &&
 VD->getType()->isReferenceType())
   // Do not globalize variables with reference type.
   return;
@@ -253,18 +253,49 @@ class CheckVarsEscapingDeclContext final
   }
 }
   }
-  void VisitOpenMPCapturedStmt(const CapturedStmt *S, bool IsParallelRegion) {
+  void VisitOpenMPCapturedStmt(const CapturedStmt *S,
+   ArrayRef Clauses,
+   bool IsCombinedParallelRegion) {
 if (!S)
   return;
 for (const CapturedStmt::Capture &C : S->captures()) {
   if (C.capturesVariable() && !C.capturesVariableByCopy()) {
 const ValueDecl *VD = C.getCapturedVar();
-bool SavedIsParallelRegion = IsForParallelRegion;
-IsForParallelRegion = IsParallelRegion;
+bool SavedIsForCombinedParallelRegion = IsForCombinedParallelRegion;
+if (IsCombinedParallelRegion) {
+  // Check if the variable is privatized in the combined construct and
+  // those private copies must be shared in the inner parallel
+  // directive.
+  IsForCombinedParallelRegion = false;
+  for (const OMPClause *C : Clauses) {
+if (!isOpenMPPrivate(C->getClauseKind()) ||
+C->getClauseKind() == OMPC_reduction ||
+C->getClauseKind() == OMPC_linear ||
+C->getClauseKind() == OMPC_private)
+  continue;
+ArrayRef Vars;
+if (const auto *PC = dyn_cast(C))
+  Vars = PC->getVarRefs();
+else if (const auto *PC = dyn_cast(C))
+  Vars = PC->getVarRefs();
+else
+  llvm_unreachable("Unexpected clause.");
+for (const auto *E : Vars) {
+  const Decl *D =
+  cast(E)->getDecl()->getCanonicalDecl();
+  if (D == VD->getCanonicalDecl()) {
+IsForCombinedParallelRegion = true;
+break;
+  }
+}
+if (IsForCombinedParallelRegion)
+  break;
+  }
+}
 markAsEscaped(VD);
 if (isa(VD))
   VisitValueDecl(VD);
-IsForParallelRegion = SavedIsParallelRegion;
+IsForCombinedParallelRegion = SavedIsForCombinedParallelRegion;
   }
 }
   }
@@ -341,7 +372,10 @@ public:
 VisitStmt(S->getCapturedStmt());
 return;
   }
-  VisitOpenMPCapturedStmt(S, CaptureRegions.back() == OMPD_parallel);
+  VisitOpenMPCapturedStmt(
+  S, D->clauses(),
+  CaptureRegions.back() == OMPD_parallel &&
+  isOpenMPDistributeDirective(D->getDirectiveKind()));
 }
   }
   void VisitCapturedStmt(const Ca

[PATCH] D48455: Remove hip.amdgcn.bc hc.amdgcn.bc from HIP Toolchains

2018-06-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335634: [HIP] Remove hip/hc.amdgcn.bc from HIP Toolchains 
(authored by aaronenyeshi, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48455?vs=152378&id=152921#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48455

Files:
  cfe/trunk/lib/Driver/ToolChains/HIP.cpp


Index: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp
@@ -75,12 +75,12 @@
 std::string ISAVerBC =
 "oclc_isa_version_" + SubArchName.drop_front(3).str() + ".amdgcn.bc";
 
-BCLibs.append({"hip.amdgcn.bc", "hc.amdgcn.bc", "opencl.amdgcn.bc",
+BCLibs.append({"opencl.amdgcn.bc",
"ockl.amdgcn.bc", "irif.amdgcn.bc", "ocml.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
"oclc_daz_opt_off.amdgcn.bc",
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
-   "oclc_unsafe_math_off.amdgcn.bc", "hc.amdgcn.bc", 
ISAVerBC});
+   "oclc_unsafe_math_off.amdgcn.bc", ISAVerBC});
   }
   for (auto Lib : BCLibs)
 addBCLib(C, Args, CmdArgs, LibraryPaths, Lib);


Index: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp
@@ -75,12 +75,12 @@
 std::string ISAVerBC =
 "oclc_isa_version_" + SubArchName.drop_front(3).str() + ".amdgcn.bc";
 
-BCLibs.append({"hip.amdgcn.bc", "hc.amdgcn.bc", "opencl.amdgcn.bc",
+BCLibs.append({"opencl.amdgcn.bc",
"ockl.amdgcn.bc", "irif.amdgcn.bc", "ocml.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
"oclc_daz_opt_off.amdgcn.bc",
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
-   "oclc_unsafe_math_off.amdgcn.bc", "hc.amdgcn.bc", ISAVerBC});
+   "oclc_unsafe_math_off.amdgcn.bc", ISAVerBC});
   }
   for (auto Lib : BCLibs)
 addBCLib(C, Args, CmdArgs, LibraryPaths, Lib);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48241: [DebugInfo] Emit ObjC methods as part of interface.

2018-06-26 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:4239
+// Add methods to interface.
+for (auto p : ObjCMethodCache) {
+  if (p.second.empty())

JDevlieghere wrote:
> dexonsmith wrote:
> > Some comment for "p" here.
> Fixed; I'll update the rest of the file in a follow-up to keep things 
> consistent.
Unfortunately CFE doesn't seem to consistently use the LLVM coding style: A lot 
of CFE developers seem to prefer lower-case variable names. I don't know if 
that is a historic artifact or a conscious decision.


https://reviews.llvm.org/D48241



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


r335634 - [HIP] Remove hip/hc.amdgcn.bc from HIP Toolchains

2018-06-26 Thread Aaron Enye Shi via cfe-commits
Author: aaronenyeshi
Date: Tue Jun 26 10:40:36 2018
New Revision: 335634

URL: http://llvm.org/viewvc/llvm-project?rev=335634&view=rev
Log:
[HIP] Remove hip/hc.amdgcn.bc from HIP Toolchains

Summary:
The hc.amdgcn.bc and hip.amdgcn.bc are removed in VDI build and no longer 
needed.

Reviewers: yaxunl

Reviewed By: yaxunl

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/HIP.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/HIP.cpp?rev=335634&r1=335633&r2=335634&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp Tue Jun 26 10:40:36 2018
@@ -75,12 +75,12 @@ const char *AMDGCN::Linker::constructLLV
 std::string ISAVerBC =
 "oclc_isa_version_" + SubArchName.drop_front(3).str() + ".amdgcn.bc";
 
-BCLibs.append({"hip.amdgcn.bc", "hc.amdgcn.bc", "opencl.amdgcn.bc",
+BCLibs.append({"opencl.amdgcn.bc",
"ockl.amdgcn.bc", "irif.amdgcn.bc", "ocml.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
"oclc_daz_opt_off.amdgcn.bc",
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
-   "oclc_unsafe_math_off.amdgcn.bc", "hc.amdgcn.bc", 
ISAVerBC});
+   "oclc_unsafe_math_off.amdgcn.bc", ISAVerBC});
   }
   for (auto Lib : BCLibs)
 addBCLib(C, Args, CmdArgs, LibraryPaths, Lib);


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


r335636 - Compile CodeGenModule.cpp with /bigobj.

2018-06-26 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Tue Jun 26 10:45:26 2018
New Revision: 335636

URL: http://llvm.org/viewvc/llvm-project?rev=335636&view=rev
Log:
Compile CodeGenModule.cpp with /bigobj.

Apparently we're now hitting an object file section limit on this
file with expensive checks enabled.

Modified:
cfe/trunk/lib/CodeGen/CMakeLists.txt

Modified: cfe/trunk/lib/CodeGen/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CMakeLists.txt?rev=335636&r1=335635&r2=335636&view=diff
==
--- cfe/trunk/lib/CodeGen/CMakeLists.txt (original)
+++ cfe/trunk/lib/CodeGen/CMakeLists.txt Tue Jun 26 10:45:26 2018
@@ -32,6 +32,10 @@ if (CLANG_BUILT_STANDALONE)
   set(codegen_deps)
 endif()
 
+if (MSVC)
+  set_source_files_properties(CodeGenModule.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
+endif()
+
 add_clang_library(clangCodeGen
   BackendUtil.cpp
   CGAtomic.cpp


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


r335638 - [Sema] Fix infinite typo correction loop.

2018-06-26 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Tue Jun 26 10:56:48 2018
New Revision: 335638

URL: http://llvm.org/viewvc/llvm-project?rev=335638&view=rev
Log:
[Sema] Fix infinite typo correction loop.

NumTypos guard value ~0U doesn't prevent from creating new delayed typos. When
you create new delayed typos during typo correction, value ~0U wraps around to
0. When NumTypos is 0 we can miss some typos and treat an expression as it can
be typo-corrected. But if the expression is still invalid after correction, we
can get stuck in infinite loop trying to correct it.

Fix by not using value ~0U so that NumTypos correctly reflects the number of
typos.

rdar://problem/38642201

Reviewers: arphaman, majnemer, rsmith

Reviewed By: rsmith

Subscribers: rsmith, nicholas, cfe-commits

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


Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/Sema/typo-correction.c

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=335638&r1=335637&r2=335638&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Jun 26 10:56:48 2018
@@ -7727,12 +7727,8 @@ Sema::CorrectDelayedTyposInExpr(Expr *E,
   if (E && !ExprEvalContexts.empty() && ExprEvalContexts.back().NumTypos &&
   (E->isTypeDependent() || E->isValueDependent() ||
E->isInstantiationDependent())) {
-auto TyposInContext = ExprEvalContexts.back().NumTypos;
-assert(TyposInContext < ~0U && "Recursive call of 
CorrectDelayedTyposInExpr");
-ExprEvalContexts.back().NumTypos = ~0U;
 auto TyposResolved = DelayedTypos.size();
 auto Result = TransformTypos(*this, InitDecl, Filter).Transform(E);
-ExprEvalContexts.back().NumTypos = TyposInContext;
 TyposResolved -= DelayedTypos.size();
 if (Result.isInvalid() || Result.get() != E) {
   ExprEvalContexts.back().NumTypos -= TyposResolved;

Modified: cfe/trunk/test/Sema/typo-correction.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=335638&r1=335637&r2=335638&view=diff
==
--- cfe/trunk/test/Sema/typo-correction.c (original)
+++ cfe/trunk/test/Sema/typo-correction.c Tue Jun 26 10:56:48 2018
@@ -87,3 +87,16 @@ __attribute__((overloadable)) void func_
 void overloadable_callexpr(int arg) {
func_overloadable(ar); //expected-error{{use of undeclared identifier}}
 }
+
+// rdar://problem/38642201
+struct rdar38642201 {
+  int fieldName;
+};
+
+void rdar38642201_callee(int x, int y);
+void rdar38642201_caller() {
+  struct rdar38642201 structVar;
+  rdar38642201_callee(
+  structVar1.fieldName1.member1, //expected-error{{use of undeclared 
identifier 'structVar1'}}
+  structVar2.fieldName2.member2); //expected-error{{use of undeclared 
identifier 'structVar2'}}
+}


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


[PATCH] D47341: [Sema] Fix infinite typo correction loop.

2018-06-26 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC335638: [Sema] Fix infinite typo correction loop. (authored 
by vsapsai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47341?vs=148841&id=152924#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47341

Files:
  lib/Sema/SemaExprCXX.cpp
  test/Sema/typo-correction.c


Index: test/Sema/typo-correction.c
===
--- test/Sema/typo-correction.c
+++ test/Sema/typo-correction.c
@@ -87,3 +87,16 @@
 void overloadable_callexpr(int arg) {
func_overloadable(ar); //expected-error{{use of undeclared identifier}}
 }
+
+// rdar://problem/38642201
+struct rdar38642201 {
+  int fieldName;
+};
+
+void rdar38642201_callee(int x, int y);
+void rdar38642201_caller() {
+  struct rdar38642201 structVar;
+  rdar38642201_callee(
+  structVar1.fieldName1.member1, //expected-error{{use of undeclared 
identifier 'structVar1'}}
+  structVar2.fieldName2.member2); //expected-error{{use of undeclared 
identifier 'structVar2'}}
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -7727,12 +7727,8 @@
   if (E && !ExprEvalContexts.empty() && ExprEvalContexts.back().NumTypos &&
   (E->isTypeDependent() || E->isValueDependent() ||
E->isInstantiationDependent())) {
-auto TyposInContext = ExprEvalContexts.back().NumTypos;
-assert(TyposInContext < ~0U && "Recursive call of 
CorrectDelayedTyposInExpr");
-ExprEvalContexts.back().NumTypos = ~0U;
 auto TyposResolved = DelayedTypos.size();
 auto Result = TransformTypos(*this, InitDecl, Filter).Transform(E);
-ExprEvalContexts.back().NumTypos = TyposInContext;
 TyposResolved -= DelayedTypos.size();
 if (Result.isInvalid() || Result.get() != E) {
   ExprEvalContexts.back().NumTypos -= TyposResolved;


Index: test/Sema/typo-correction.c
===
--- test/Sema/typo-correction.c
+++ test/Sema/typo-correction.c
@@ -87,3 +87,16 @@
 void overloadable_callexpr(int arg) {
 	func_overloadable(ar); //expected-error{{use of undeclared identifier}}
 }
+
+// rdar://problem/38642201
+struct rdar38642201 {
+  int fieldName;
+};
+
+void rdar38642201_callee(int x, int y);
+void rdar38642201_caller() {
+  struct rdar38642201 structVar;
+  rdar38642201_callee(
+  structVar1.fieldName1.member1, //expected-error{{use of undeclared identifier 'structVar1'}}
+  structVar2.fieldName2.member2); //expected-error{{use of undeclared identifier 'structVar2'}}
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -7727,12 +7727,8 @@
   if (E && !ExprEvalContexts.empty() && ExprEvalContexts.back().NumTypos &&
   (E->isTypeDependent() || E->isValueDependent() ||
E->isInstantiationDependent())) {
-auto TyposInContext = ExprEvalContexts.back().NumTypos;
-assert(TyposInContext < ~0U && "Recursive call of CorrectDelayedTyposInExpr");
-ExprEvalContexts.back().NumTypos = ~0U;
 auto TyposResolved = DelayedTypos.size();
 auto Result = TransformTypos(*this, InitDecl, Filter).Transform(E);
-ExprEvalContexts.back().NumTypos = TyposInContext;
 TyposResolved -= DelayedTypos.size();
 if (Result.isInvalid() || Result.get() != E) {
   ExprEvalContexts.back().NumTypos -= TyposResolved;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47341: [Sema] Fix infinite typo correction loop.

2018-06-26 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the review, Richard.


Repository:
  rC Clang

https://reviews.llvm.org/D47341



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


[PATCH] D48474: [analyzer][ctu] fix unsortable diagnostics

2018-06-26 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.
This revision is now accepted and ready to land.

> My fear of using file IDs is that I don't know whether they are stable

IIRC they are currently stable, but that's relying on implementation details.
Still better than not differentiating at all.


Repository:
  rC Clang

https://reviews.llvm.org/D48474



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


[PATCH] D48342: [libcxx] Optimize vectors construction of trivial types from an iterator range with const-ness mismatch.

2018-06-26 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai planned changes to this revision.
vsapsai added inline comments.



Comment at: libcxx/include/memory:1479
+struct __has_construct_missing
+: false_type
+{

erik.pilkington wrote:
> Shouldn't this be true_type?
I see this is confusing and I'm still struggling how to express it. The issue 
is that in C++03 `__has_construct` should be something like unknown, so that 
neither `__has_construct` nor `! __has_construct` evaluate to true because we 
don't really know if allocator has construct. This case is covered by the added 
test, in C++03 the memcpy specialization was enabled when

```
is_same >
  || !false_type
```

So `is_same` check had no effect and we were using memcpy to convert between 
int and float.

I was considering using something like

```lang=c++
typename enable_if
<
(is_same
 <
typename _VSTD::remove_const::type,
typename _VSTD::remove_const<_SourceTp>::type
 >::value
#ifndef _LIBCPP_CXX03_LANG
|| !__has_construct::value
#endif
) &&
 is_trivially_move_constructible<_DestTp>::value,
void
>::type
```

But that doesn't look readable to me, so I've introduced ad-hoc ternary logic 
with `__has_construct_missing`.



Comment at: libcxx/include/memory:1673-1677
+(is_same
+ <
+typename _VSTD::remove_const::type,
+typename _VSTD::remove_const<_SourceTp>::type
+ >::value

erik.pilkington wrote:
> I'm not sure if this is correct. Previously, we only selected this overload 
> if the allocator didn't have a construct() member, or if it was a 
> std::allocator, in which case we know construct() just called in-place new. 
> With this patch, we would select this overload for a custom allocator that 
> overrode construct() so long as the value_types matched. I think the right 
> behaviour for the custom allocator case would be to use the construct() 
> member instead of memcpying.
Thanks for pointing out the case with custom allocator. My expectation is that 
it should use construct() instead of memcpy, I agree with you. Will check 
further and plan to add a test.


https://reviews.llvm.org/D48342



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


[PATCH] D48571: improve diagnostics for missing 'template' keyword

2018-06-26 Thread Brendon Cahoon via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335641: [Hexagon] Add a "generic" cpu (authored by 
bcahoon, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48571?vs=152780&id=152931#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48571

Files:
  llvm/trunk/lib/Target/Hexagon/Hexagon.td
  llvm/trunk/lib/Target/Hexagon/HexagonSubtarget.cpp
  llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
  llvm/trunk/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp
  llvm/trunk/test/CodeGen/Hexagon/generic-cpu.ll


Index: llvm/trunk/test/CodeGen/Hexagon/generic-cpu.ll
===
--- llvm/trunk/test/CodeGen/Hexagon/generic-cpu.ll
+++ llvm/trunk/test/CodeGen/Hexagon/generic-cpu.ll
@@ -0,0 +1,7 @@
+; RUN: llc -mtriple=hexagon-unknown-elf -mcpu=generic < %s | FileCheck %s
+
+; CHECK-NOT: invalid CPU
+
+define i32 @test(i32 %a) {
+  ret i32 0
+}
Index: llvm/trunk/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp
===
--- llvm/trunk/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp
+++ llvm/trunk/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp
@@ -18,6 +18,6 @@
 }
 
 extern "C" void LLVMInitializeHexagonTargetInfo() {
-  RegisterTarget X(
+  RegisterTarget X(
   getTheHexagonTarget(), "hexagon", "Hexagon", "Hexagon");
 }
Index: llvm/trunk/lib/Target/Hexagon/Hexagon.td
===
--- llvm/trunk/lib/Target/Hexagon/Hexagon.td
+++ llvm/trunk/lib/Target/Hexagon/Hexagon.td
@@ -322,6 +322,10 @@
list Features>
  : ProcessorModel;
 
+def : Proc<"generic", HexagonModelV60,
+   [ArchV4, ArchV5, ArchV55, ArchV60,
+FeatureDuplex, FeatureMemops, FeatureNVJ, FeatureNVS,
+FeaturePackets, FeatureSmallData]>;
 def : Proc<"hexagonv4",  HexagonModelV4,
[ArchV4,
 FeatureDuplex, FeatureMemops, FeatureNVJ, FeatureNVS,
Index: llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
===
--- llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
+++ llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
@@ -309,6 +309,7 @@
 {
   std::vector table
   {
+"generic",
 "hexagonv4",
 "hexagonv5",
 "hexagonv55",
Index: llvm/trunk/lib/Target/Hexagon/HexagonSubtarget.cpp
===
--- llvm/trunk/lib/Target/Hexagon/HexagonSubtarget.cpp
+++ llvm/trunk/lib/Target/Hexagon/HexagonSubtarget.cpp
@@ -92,6 +92,7 @@
 HexagonSubtarget &
 HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) 
{
   static std::map CpuTable{
+  {"generic", Hexagon::ArchEnum::V60},
   {"hexagonv4", Hexagon::ArchEnum::V4},
   {"hexagonv5", Hexagon::ArchEnum::V5},
   {"hexagonv55", Hexagon::ArchEnum::V55},


Index: llvm/trunk/test/CodeGen/Hexagon/generic-cpu.ll
===
--- llvm/trunk/test/CodeGen/Hexagon/generic-cpu.ll
+++ llvm/trunk/test/CodeGen/Hexagon/generic-cpu.ll
@@ -0,0 +1,7 @@
+; RUN: llc -mtriple=hexagon-unknown-elf -mcpu=generic < %s | FileCheck %s
+
+; CHECK-NOT: invalid CPU
+
+define i32 @test(i32 %a) {
+  ret i32 0
+}
Index: llvm/trunk/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp
===
--- llvm/trunk/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp
+++ llvm/trunk/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp
@@ -18,6 +18,6 @@
 }
 
 extern "C" void LLVMInitializeHexagonTargetInfo() {
-  RegisterTarget X(
+  RegisterTarget X(
   getTheHexagonTarget(), "hexagon", "Hexagon", "Hexagon");
 }
Index: llvm/trunk/lib/Target/Hexagon/Hexagon.td
===
--- llvm/trunk/lib/Target/Hexagon/Hexagon.td
+++ llvm/trunk/lib/Target/Hexagon/Hexagon.td
@@ -322,6 +322,10 @@
list Features>
  : ProcessorModel;
 
+def : Proc<"generic", HexagonModelV60,
+   [ArchV4, ArchV5, ArchV55, ArchV60,
+FeatureDuplex, FeatureMemops, FeatureNVJ, FeatureNVS,
+FeaturePackets, FeatureSmallData]>;
 def : Proc<"hexagonv4",  HexagonModelV4,
[ArchV4,
 FeatureDuplex, FeatureMemops, FeatureNVJ, FeatureNVS,
Index: llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
===
--- llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
+++ llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
@@ -309,6 +309,7 @@
 {
   std::vector table
   {
+"generic",
 "hexagonv4",
 "hexagonv5",
 "he

[PATCH] D48601: Added -fcrash-diagnostics-dir flag

2018-06-26 Thread Chijioke Kamanu via Phabricator via cfe-commits
j10kay created this revision.
j10kay added reviewers: hans, inglorion, rnk.
Herald added subscribers: llvm-commits, hiraditya.

New flag causes crash reports to be written in the specified directory
rather than the temp directory.


Repository:
  rL LLVM

https://reviews.llvm.org/D48601

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-diagnostics-dir.c
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/Support/Path.cpp


Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -756,13 +756,7 @@
 
 std::error_code createUniqueFile(const Twine &Model, int &ResultFd,
  SmallVectorImpl &ResultPath,
- unsigned Mode) {
-  return createUniqueEntity(Model, ResultFd, ResultPath, false, Mode, FS_File);
-}
-
-static std::error_code createUniqueFile(const Twine &Model, int &ResultFd,
-SmallVectorImpl &ResultPath,
-unsigned Mode, OpenFlags Flags) {
+ unsigned Mode, sys::fs::OpenFlags Flags) {
   return createUniqueEntity(Model, ResultFd, ResultPath, false, Mode, FS_File,
 Flags);
 }
@@ -779,6 +773,12 @@
   return EC;
 }
 
+std::error_code createUniqueFile(const Twine &Prefix, StringRef Suffix,
+ llvm::SmallVectorImpl &ResultPath) {
+  const char *Middle = Suffix.empty() ? "-%%" : "-%%.";
+  return createUniqueFile(Prefix + Middle + Suffix, ResultPath);
+}
+
 static std::error_code
 createTemporaryFile(const Twine &Model, int &ResultFD,
 llvm::SmallVectorImpl &ResultPath, FSEntity Type) {
Index: llvm/include/llvm/Support/FileSystem.h
===
--- llvm/include/llvm/Support/FileSystem.h
+++ llvm/include/llvm/Support/FileSystem.h
@@ -755,6 +755,8 @@
  SmallVectorImpl &ResultPath,
  unsigned Mode = all_read | all_write);
 
+std::error_code createUniqueFile(const Twine &Prefix, StringRef Suffix,
+ SmallVectorImpl &ResultPath);
 /// Represents a temporary file.
 ///
 /// The temporary file must be eventually discarded or given a final name and
Index: clang/test/Driver/crash-diagnostics-dir.c
===
--- /dev/null
+++ clang/test/Driver/crash-diagnostics-dir.c
@@ -0,0 +1,5 @@
+// RUN: mkdir -p %t
+// RUN: not %clang -fcrash-diagnostics-dir=%t -c %s 2>&1 | FileCheck %s
+#pragma clang __debug parser_crash
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK: diagnostic msg: {{.*}}/Output/crash-diagnostics-dir.c.tmp/{{.*}}.c
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4036,8 +4036,22 @@
   CCGenDiagnostics) {
 StringRef Name = llvm::sys::path::filename(BaseInput);
 std::pair Split = Name.split('.');
-std::string TmpName = GetTemporaryPath(
-Split.first, types::getTypeTempSuffix(JA.getType(), IsCLMode()));
+SmallString<128> TmpName;
+auto Suffix = types::getTypeTempSuffix(JA.getType(), IsCLMode());
+Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_dir);
+if (CCGenDiagnostics && A) {
+  SmallString<128> CrashDirectory;
+  CrashDirectory = A->getValue();
+  llvm::sys::path::append(CrashDirectory, Split.first);
+  std::error_code EC =
+  llvm::sys::fs::createUniqueFile(CrashDirectory, Suffix, TmpName);
+  if (EC) {
+Diag(clang::diag::err_unable_to_make_temp) << EC.message();
+return "";
+  }
+} else {
+  TmpName = GetTemporaryPath(Split.first, Suffix);
+}
 return C.addTempFile(C.getArgs().MakeArgString(TmpName));
   }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -798,6 +798,7 @@
 Group;
 def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, 
Group, Flags<[NoArgumentUnused]>,
   HelpText<"Disable auto-generation of preprocessed source files and a script 
for reproduction during a clang crash">;
+def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">, 
Group, Flags<[NoArgumentUnused]>;
 def fcreate_profile : Flag<["-"], "fcreate-profile">, Group;
 def fcxx_exceptions: Flag<["-"], "fcxx-exceptions">, Group,
   HelpText<"Enable C++ exceptions">, Flags<[CC1Option]>;


Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/

[PATCH] D48241: [DebugInfo] Emit ObjC methods as part of interface.

2018-06-26 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:4239
+// Add methods to interface.
+for (auto p : ObjCMethodCache) {
+  if (p.second.empty())

aprantl wrote:
> JDevlieghere wrote:
> > dexonsmith wrote:
> > > Some comment for "p" here.
> > Fixed; I'll update the rest of the file in a follow-up to keep things 
> > consistent.
> Unfortunately CFE doesn't seem to consistently use the LLVM coding style: A 
> lot of CFE developers seem to prefer lower-case variable names. I don't know 
> if that is a historic artifact or a conscious decision.
Probably safe to assume it's historic - I don't think there's any intentional 
diversion from the LLVM style guide, maybe just lazy/accidental "being 
consistent" with the surrounding code & no one's bothered to do bigger cleanups.


https://reviews.llvm.org/D48241



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


[PATCH] D48589: [WIP] [CodeGen] Allow specifying Extend to CoerceAndExpand

2018-06-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/CodeGen/CGFunctionInfo.h:90
   union {
-unsigned DirectOffset; // isDirect() || isExtend()
-unsigned IndirectAlign;// isIndirect()
-unsigned AllocaFieldIndex; // isInAlloca()
+llvm::StructType *ExtendSeq; // isCoerceAndExpand()
+unsigned DirectOffset;   // isDirect() || isExtend()

Hmm.  I understand the need to use something uniqued here, but I think it would 
probably be more natural to at least use a `llvm::ConstantDataArray` (which 
could be null if there are no interesting bits) instead of encoding the 
information into the types of a struct type.  That would also make it easy to 
generalize the elements to an arbitrary flags type.

Also, on 64-bit targets this will increase the size of an `ABIArgInfo` to four 
pointers from three.  That's fine to the extent that we work with independent 
`ABIArgInfo`s, but I'm getting a little annoyed at the storage overhead of the 
array of `ABIArgInfo`s in `CGFunctionInfo` given that, in the overwhelmingly 
common case, an `ABIArgInfo` is no more than a kind and maybe a few of these 
flags.  Maybe there's some reasonable way to optimize the storage of an 
`ABIArgInfo` in a `CGFunctionInfo` so that we only need the extra storage in 
less-common cases?  Like extracting out a base class that's the Kind+Flags and 
making the main array be an array of those + an optional index into a second 
trailing array of full `ABIArgInfo`s.

I might be overthinking this, though.


https://reviews.llvm.org/D48589



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


[PATCH] D44609: [Clang-Format] New option BreakBeforeLambdaBody to manage lambda line break inside function parameter call

2018-06-26 Thread Francois JEAN via Phabricator via cfe-commits
Wawha marked 2 inline comments as done.
Wawha added a comment.

  Hello,

after my last modification (require by previous comment), I do not see any 
feedback or validation for this patch.
Is their something special to do in order to go forward on this patch?

Lambda are more an more used in modern C++, and it's very annoying to not have 
a way to format them in allman style.


Repository:
  rC Clang

https://reviews.llvm.org/D44609



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


[PATCH] D48601: Added -fcrash-diagnostics-dir flag

2018-06-26 Thread Zachary Turner via Phabricator via cfe-commits
zturner added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4043-4044
+if (CCGenDiagnostics && A) {
+  SmallString<128> CrashDirectory;
+  CrashDirectory = A->getValue();
+  llvm::sys::path::append(CrashDirectory, Split.first);

Maybe you can combine these into one line with:

```
SmallString<128> CrashDirectory{ A->getValue() };
```



Comment at: clang/test/Driver/crash-diagnostics-dir.c:5
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK: diagnostic msg: {{.*}}/Output/crash-diagnostics-dir.c.tmp/{{.*}}.c

This will fail on Windows I think where path separators are backslashes.  I 
think you need to do something like:

```
{{.*}}Output{{/|\\}}crash-diagnostics-dir.c.tmp{{(/|\\).*}}.c
```



Comment at: llvm/include/llvm/Support/FileSystem.h:758-759
 
+std::error_code createUniqueFile(const Twine &Prefix, StringRef Suffix,
+ SmallVectorImpl &ResultPath);
 /// Represents a temporary file.

Is there any reason we can't just use the existing overload?  In other words, 
instead of creating this overload and having the user write 
`createUniqueFile("foo", "bar")`, how about just 
`createUniqueFile("foo-%%.bar")` which seems equivalent.


Repository:
  rL LLVM

https://reviews.llvm.org/D48601



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


[PATCH] D48571: improve diagnostics for missing 'template' keyword

2018-06-26 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz reopened this revision.
kparzysz added a comment.

This needs to be restored to the original form.  A mistake in a commit message 
closed this review by accident.


Repository:
  rL LLVM

https://reviews.llvm.org/D48571



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


[PATCH] D47154: Try to make builtin address space declarations not useless

2018-06-26 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:3500
+if (auto *PtrTy = dyn_cast(PTy)) {
+  if (PtrTy->getAddressSpace() !=
+  ArgValue->getType()->getPointerAddressSpace()) {

Anastasia wrote:
> arsenm wrote:
> > Anastasia wrote:
> > > Would this be correct for OpenCL? Should we use  
> > > `isAddressSpaceSupersetOf` helper instead? Would it also sort the issue 
> > > with constant AS (at least for OpenCL)? 
> > The issue I mentioned for the other builtin is that it modifies the memory, 
> > and doesn't have to do with the casting.
> > 
> > At this point the AddrSpaceCast has to be emitted. The checking if the cast 
> > is legal I guess would be in the SemaExpr part. I know at one point I was 
> > trying to use isAddressSpaceSupersetOf in rewriteBuiltinFunctionDecl, but 
> > there was some problem with that. I think it didn't make sense with the 
> > magic where the builtin without an address space is supposed to accept any 
> > address space or something along those lines.
> Yes, I think Sema has to check it before indeed. I am not sure it works right 
> with OpenCL rules though for the Builtin functions.  Would it make sense to 
> add a negative test for this then? 
I'm not sure what this test would look like. Do you mean a test that 
erroneously is accepted now?


https://reviews.llvm.org/D47154



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


r335653 - [mips] Use more conservative default CPUs for MIPS on FreeBSD.

2018-06-26 Thread John Baldwin via cfe-commits
Author: jhb
Date: Tue Jun 26 12:48:05 2018
New Revision: 335653

URL: http://llvm.org/viewvc/llvm-project?rev=335653&view=rev
Log:
[mips] Use more conservative default CPUs for MIPS on FreeBSD.

FreeBSD defaults to mips3 for all MIPS ABIs with GCC as that is the
minimum MIPS architecture FreeBSD supports.  Use mips3 for MIPS64 and
mips2 for MIPS32 to match.

Reviewed By: atanasyan

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/test/Driver/freebsd-mips-as.c
cfe/trunk/test/Driver/freebsd.c

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=335653&r1=335652&r2=335653&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Tue Jun 26 12:48:05 2018
@@ -45,6 +45,13 @@ void mips::getMipsCPUAndABI(const ArgLis
   if (Triple.getOS() == llvm::Triple::OpenBSD)
 DefMips64CPU = "mips3";
 
+  // MIPS2 is the default for mips(el)?-unknown-freebsd.
+  // MIPS3 is the default for mips64(el)?-unknown-freebsd.
+  if (Triple.getOS() == llvm::Triple::FreeBSD) {
+DefMips32CPU = "mips2";
+DefMips64CPU = "mips3";
+  }
+
   if (Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ,
options::OPT_mcpu_EQ))
 CPUName = A->getValue();

Modified: cfe/trunk/test/Driver/freebsd-mips-as.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/freebsd-mips-as.c?rev=335653&r1=335652&r2=335653&view=diff
==
--- cfe/trunk/test/Driver/freebsd-mips-as.c (original)
+++ cfe/trunk/test/Driver/freebsd-mips-as.c Tue Jun 26 12:48:05 2018
@@ -3,62 +3,62 @@
 // RUN: %clang -target mips-unknown-freebsd -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32-EB-AS %s
-// MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+// MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB"
 // MIPS32-EB-AS-NOT: "-KPIC"
 //
 // RUN: %clang -target mips-unknown-freebsd -### \
 // RUN:   -no-integrated-as -fPIC -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32-EB-PIC %s
-// MIPS32-EB-PIC: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+// MIPS32-EB-PIC: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB"
 // MIPS32-EB-PIC: "-KPIC"
 //
 // RUN: %clang -target mips-unknown-freebsd -### \
 // RUN:   -no-integrated-as -fpic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32-EB-PIC-SMALL %s
-// MIPS32-EB-PIC-SMALL: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+// MIPS32-EB-PIC-SMALL: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB"
 // MIPS32-EB-PIC-SMALL: "-KPIC"
 //
 // RUN: %clang -target mips-unknown-freebsd -### \
 // RUN:   -no-integrated-as -fPIE -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32-EB-PIE %s
-// MIPS32-EB-PIE: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+// MIPS32-EB-PIE: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB"
 // MIPS32-EB-PIE: "-KPIC"
 //
 // RUN: %clang -target mips-unknown-freebsd -### \
 // RUN:   -no-integrated-as -fpie -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32-EB-PIE-SMALL %s
-// MIPS32-EB-PIE-SMALL: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+// MIPS32-EB-PIE-SMALL: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB"
 // MIPS32-EB-PIE-SMALL: "-KPIC"
 //
 // RUN: %clang -target mipsel-unknown-freebsd -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32-DEF-EL-AS %s
-// MIPS32-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EL"
+// MIPS32-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EL"
 //
 // RUN: %clang -target mips64-unknown-freebsd -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64-EB-AS %s
-// MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EB"
+// MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips3" "-mabi" "64" "-EB"
 //
 // RUN: %clang -target mips64el-unknown-freebsd -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64-DEF-EL-AS %s
-// MIPS64-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EL"
+// MIPS64-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips3" "-mabi" "64" "-EL"
 //
 // RUN: %clang -target mips64-unknown-freebsd -mabi=n32 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-N32 %s
-// MIPS-N32: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "n32" "-EB"
+// MIPS-N32: as{{(.exe)?}}" "-march" "mips3" "-mabi" "n32" "-EB"
 //
 // RUN: %clang -target mipsel-unknown-freebsd -mabi=32 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32-EL-AS %s
-// MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32r2" 

[PATCH] D48499: [mips] Use more conservative default CPUs for MIPS on FreeBSD.

2018-06-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC335653: [mips] Use more conservative default CPUs for MIPS 
on FreeBSD. (authored by jhb, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D48499?vs=152522&id=152944#toc

Repository:
  rC Clang

https://reviews.llvm.org/D48499

Files:
  lib/Driver/ToolChains/Arch/Mips.cpp
  test/Driver/freebsd-mips-as.c
  test/Driver/freebsd.c

Index: test/Driver/freebsd.c
===
--- test/Driver/freebsd.c
+++ test/Driver/freebsd.c
@@ -148,3 +148,17 @@
 // RUN: %clang -target mips-unknown-freebsd %s -### -G0 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS-G %s
 // CHECK-MIPS-G: ld{{.*}}" "-G0"
+
+// Check CPU type for MIPS
+// RUN: %clang -target mips-unknown-freebsd -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-MIPS-CPU %s
+// RUN: %clang -target mipsel-unknown-freebsd -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-MIPS-CPU %s
+// CHECK-MIPS-CPU: "-target-cpu" "mips2"
+
+// Check CPU type for MIPS64
+// RUN: %clang -target mips64-unknown-freebsd -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-MIPS64-CPU %s
+// RUN: %clang -target mips64el-unknown-freebsd -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-MIPS64-CPU %s
+// CHECK-MIPS64-CPU: "-target-cpu" "mips3"
Index: test/Driver/freebsd-mips-as.c
===
--- test/Driver/freebsd-mips-as.c
+++ test/Driver/freebsd-mips-as.c
@@ -3,62 +3,62 @@
 // RUN: %clang -target mips-unknown-freebsd -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32-EB-AS %s
-// MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+// MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB"
 // MIPS32-EB-AS-NOT: "-KPIC"
 //
 // RUN: %clang -target mips-unknown-freebsd -### \
 // RUN:   -no-integrated-as -fPIC -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32-EB-PIC %s
-// MIPS32-EB-PIC: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+// MIPS32-EB-PIC: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB"
 // MIPS32-EB-PIC: "-KPIC"
 //
 // RUN: %clang -target mips-unknown-freebsd -### \
 // RUN:   -no-integrated-as -fpic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32-EB-PIC-SMALL %s
-// MIPS32-EB-PIC-SMALL: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+// MIPS32-EB-PIC-SMALL: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB"
 // MIPS32-EB-PIC-SMALL: "-KPIC"
 //
 // RUN: %clang -target mips-unknown-freebsd -### \
 // RUN:   -no-integrated-as -fPIE -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32-EB-PIE %s
-// MIPS32-EB-PIE: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+// MIPS32-EB-PIE: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB"
 // MIPS32-EB-PIE: "-KPIC"
 //
 // RUN: %clang -target mips-unknown-freebsd -### \
 // RUN:   -no-integrated-as -fpie -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32-EB-PIE-SMALL %s
-// MIPS32-EB-PIE-SMALL: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+// MIPS32-EB-PIE-SMALL: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB"
 // MIPS32-EB-PIE-SMALL: "-KPIC"
 //
 // RUN: %clang -target mipsel-unknown-freebsd -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32-DEF-EL-AS %s
-// MIPS32-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EL"
+// MIPS32-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EL"
 //
 // RUN: %clang -target mips64-unknown-freebsd -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64-EB-AS %s
-// MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EB"
+// MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips3" "-mabi" "64" "-EB"
 //
 // RUN: %clang -target mips64el-unknown-freebsd -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64-DEF-EL-AS %s
-// MIPS64-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EL"
+// MIPS64-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips3" "-mabi" "64" "-EL"
 //
 // RUN: %clang -target mips64-unknown-freebsd -mabi=n32 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-N32 %s
-// MIPS-N32: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "n32" "-EB"
+// MIPS-N32: as{{(.exe)?}}" "-march" "mips3" "-mabi" "n32" "-EB"
 //
 // RUN: %clang -target mipsel-unknown-freebsd -mabi=32 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32-EL-AS %s
-// MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EL"
+// MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EL"
 //
 // RUN: %clang -target mips64el-unknown-freebsd -mabi=64 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64-EL-AS %s
-// MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64

[PATCH] D48571: improve diagnostics for missing 'template' keyword

2018-06-26 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz updated this revision to Diff 152946.
kparzysz added a comment.

Restored the original patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D48571

Files:
  include/clang/Basic/BitmaskEnum.h
  include/clang/Parse/Parser.h
  include/clang/Parse/RAIIObjectsForParser.h
  include/clang/Sema/Sema.h
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/Parse/ParseCXXInlineMethods.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaTemplate.cpp
  test/SemaTemplate/dependent-template-recover.cpp

Index: test/SemaTemplate/dependent-template-recover.cpp
===
--- test/SemaTemplate/dependent-template-recover.cpp
+++ test/SemaTemplate/dependent-template-recover.cpp
@@ -5,18 +5,59 @@
 t->f0(); // expected-error{{use 'template' keyword to treat 'f0' as a dependent template name}}
 t->f0(); // expected-error{{use 'template' keyword to treat 'f0' as a dependent template name}}
 
-t->operator+(); // expected-error{{use 'template' keyword to treat 'operator +' as a dependent template name}}
-t->f1(); // expected-error{{use 'template' keyword to treat 'f1' as a dependent template name}}
+t->operator+(1); // expected-error{{use 'template' keyword to treat 'operator +' as a dependent template name}}
+t->f1(1); // expected-error{{use 'template' keyword to treat 'f1' as a dependent template name}}
+t->f1<3, int const>(1); // expected-error{{missing 'template' keyword prior to dependent template name 'f1'}}
 
 T::getAs(); // expected-error{{use 'template' keyword to treat 'getAs' as a dependent template name}}
 t->T::getAs(); // expected-error{{use 'template' keyword to treat 'getAs' as a dependent template name}}
 
-// FIXME: We can't recover from these yet
-(*t).f2(); // expected-error{{expected expression}}
-(*t).f2<0>(); // expected-error{{expected expression}}
+(*t).f2(); // expected-error{{missing 'template' keyword prior to dependent template name 'f2'}}
+(*t).f2<0>(); // expected-error{{missing 'template' keyword prior to dependent template name 'f2'}}
+T::f2<0>(); // expected-error{{missing 'template' keyword prior to dependent template name 'f2'}}
+T::f2<0, int>(0); // expected-error{{missing 'template' keyword prior to dependent template name 'f2'}}
+
+T::foo= 4>(); // expected-error{{missing 'template' keyword prior to dependent template name 'foo'}}
+
+// If there are multiple potential template names, pick the one where there
+// is no whitespace between the name and the '<'.
+T::foo(); // expected-error{{missing 'template' keyword prior to dependent template name 'foo'}}
+T::foo < T::bar<1>(); // expected-error{{missing 'template' keyword prior to dependent template name 'bar'}}
+
+// Prefer to diagonse a missing 'template' keyword rather than finding a non-template name.
+xyz < T::foo < 1 > (); // expected-error{{missing 'template' keyword prior to dependent template name 'foo'}}
+T::foo < xyz < 1 > (); // expected-error{{missing 'template' keyword prior to dependent template name 'foo'}}
+
+// ... even if the whitespace suggests the other name is the template name.
+// FIXME: Is this the right heuristic?
+xyz(); // expected-error{{missing 'template' keyword prior to dependent template name 'foo'}}
+T::foo < xyz<1>(); // expected-error{{missing 'template' keyword prior to dependent template name 'foo'}}
   }
+
+  int xyz;
 };
 
+template  void not_missing_template(T t) {
+  (T::n < 0) > (
+ ) // expected-error {{expected expression}}
+;
+
+  int a = T::x < 3;
+  int b = T::y > (); // expected-error {{expected expression}}
+
+  void c(int = T::x < 3);
+  void d(int = T::y > ()); // expected-error {{expected expression}}
+
+  for (int x = t < 3 ? 1 : 2; t > (); ++t) { // expected-error {{expected expression}}
+  }
+
+  // FIXME: We shouldn't treat 'T::t' as a potential template-name here,
+  // because that would leave a '?' with no matching ':'.
+  // We should probably generally treat '?' ... ':' as a bracket-like
+  // construct.
+  bool k = T::t < 3 ? 1 > () : false; // expected-error {{missing 'template' keyword}} expected-error +{{}} expected-note +{{}}
+}
+
 struct MrsBadcrumble {
   friend MrsBadcrumble operator<(void (*)(int), MrsBadcrumble);
   friend void operator>(MrsBadcrumble, int);
@@ -30,6 +71,9 @@
   // Note: no diagnostic here, this is actually valid as a comparison between
   // the decayed pointer to Y::g<> and mb!
   T::g(0);
+
+  // ... but this one must be a template-id.
+  T::g(0); // expected-error {{missing 'template' keyword prior to dependent template name 'g'}}
 }
 
 struct Y {
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -508,20 +508,41 @@
 
   DeclContext *LookupCtx = nullptr;
   NamedDecl *Found = nullptr;
+  bool 

[PATCH] D48571: improve diagnostics for missing 'template' keyword

2018-06-26 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz added a comment.

Please take over, I commandeered to restore the patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D48571



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


[PATCH] D48456: [Fixed Point Arithmetic] Casting between fixed point types and other arithmetic types

2018-06-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/AST/ASTContext.h:1954
+  llvm::APInt getFixedPointMin(QualType Ty) const;
+  llvm::APInt getFixedPointOne(QualType Ty) const;
 

ebevhan wrote:
> rjmccall wrote:
> > Are these opaque bit-patterns?  I think there should be a type which 
> > abstracts over constant fixed-point values, something `APSInt`-like that 
> > also carries the signedness and scale.  For now that type can live in 
> > Clang; if LLVM wants to add intrinsic support for fixed-point, it'll be 
> > easy enough to move it there.
> All of the parameters that determine these values (min, max, one) need to be 
> sourced from the target, though. It's not like APSInt is aware of the 
> dimensions of integers on the targets. I think these should return APSInt and 
> not APInt, though.
> 
> Creating another abstraction on top of APInt is probably still quite useful, 
> especially for certain operations (multiplication, division, saturating 
> conversion, saturating operations). Probably not too useful for this patch 
> since it doesn't deal with constant evaluation.
Well, I think we can add the abstraction — in a separate patch that this can 
depend on — even if it doesn't actually provide operations that would be useful 
for constant-folding yet, and then we can stop introducing assumptions like 
this that constant values are passed around as `APInt`s.



Comment at: lib/CodeGen/CGExprScalar.cpp:768
+if (CGF.getContext().getTargetInfo().unsignedFixedPointTypesHavePadding() 
&&
+Ty->isUnsignedFixedPointType()) {
+  unsigned NumBits = CGF.getContext().getTypeSize(Ty);

ebevhan wrote:
> rjmccall wrote:
> > Can you explain the padding thing?  Why is padding uniformly present or 
> > absent on all unsigned fixed point types on a target, and never on signed 
> > types?  Is this "low bits set" thing endian-specific?
> I'll give an example with a fract type. Let's say fract is 16 bits wide. That 
> means the signed fract will have a scale of 15 (15 fractional bits) and one 
> sign bit, for a value range of [-1.0, 1.0). The LSB is worth 2^-15 and the 
> MSB is worth  -2^0, similar to  signed integers.
> 
> The unsigned fract cannot be negative, but must also have a value range of 
> 1.0. This means that either:
> * The scale remains the same (15), and the MSB is a padding bit. This bit 
> would normally be the 2^0 bit, but since the range of the number cannot 
> exceed 1, this bit will always be 0. In this case, the LSB is worth 2^-15 
> (same as the signed) and the MSB is not worth anything.
> * The scale is that of signed fract + 1 (16). All bits of the number are 
> value bits, and there is no padding. The LSB is worth 2^-16 and the MSB is 
> worth 2^-1. There is no bit with a magnitude of 2^0.
> 
> These rules also apply to accum types, since the number of integral bits in 
> the unsigned accum types may not exceed that of the signed ones. Therefore, 
> we either have to choose between having the same number of fractional bits as 
> the signed ones (leaving the MSB as 0/padding) or having one more fractional 
> bit than the signed ones.
> 
> The lowBits is just there to construct a mask to block out the MSB. There 
> should be no endian consideration.
> I'll give an example with a fract type. Let's say fract is 16 bits wide. That 
> means the signed fract will have a scale of 15 (15 fractional bits) and one 
> sign bit, for a value range of [-1.0, 1.0). The LSB is worth 2^-15 and the 
> MSB is worth -2^0, similar to signed integers.

Ah, I see, and now I've found where this is laid out in the spec, as well as 
where the spec leaves this representation question open for unsigned types.

Is this review debating whether or not to use a padded implementation?  Do we 
not have any requirement to maintain compatibility with other compilers?  Do 
other compilers differ on the representation, perhaps by target, or is there 
general agreement?

In the abstract, I think it would be better to fully use all the bits 
available, even if it means conversions are non-trivial.



Comment at: lib/CodeGen/CGExprScalar.cpp:1801
+  return Builder.CreateLShr(
+  EmitScalarConversion(Val, SrcTy, DestTy, CE->getExprLoc()), scale);
+  }

ebevhan wrote:
> rjmccall wrote:
> > Please abstract functions for doing this kind of arithmetic instead of 
> > inlining them into scalar emission.  Feel free to make a new CGFixedPoint.h 
> > header and corresponding implementation file.
> > 
> > Also, it looks like you're assuming that the output type is the same size 
> > as the input type.  I don't think that's actually a language restriction, 
> > right?
> I think that EmitScalarConversion will do 'the right thing' since it's being 
> passed an input type of width N and converting it to a type of width M, but 
> it's doing so 'stupidly' and isn't really aware of that one of them is a 
> fixed-point type.

r335655 - [AST] Fix typo in LazyOffsetPtr::get docs (NFC)

2018-06-26 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Tue Jun 26 13:05:18 2018
New Revision: 335655

URL: http://llvm.org/viewvc/llvm-project?rev=335655&view=rev
Log:
[AST] Fix typo in LazyOffsetPtr::get docs (NFC)


Modified:
cfe/trunk/include/clang/AST/ExternalASTSource.h

Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=335655&r1=335654&r2=335655&view=diff
==
--- cfe/trunk/include/clang/AST/ExternalASTSource.h (original)
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h Tue Jun 26 13:05:18 2018
@@ -393,7 +393,7 @@ public:
   /// Whether this pointer is currently stored as an offset.
   bool isOffset() const { return Ptr & 0x01; }
 
-  /// Retrieve the pointer to the AST node that this lazy pointer
+  /// Retrieve the pointer to the AST node that this lazy pointer points to.
   ///
   /// \param Source the external AST source.
   ///


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


[PATCH] D47846: [clangd] Implementation of textDocument/documentSymbol

2018-06-26 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle updated this revision to Diff 152953.
malaperle added a comment.

Rebased.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47846

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/FindSymbols.cpp
  clangd/FindSymbols.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/XRefs.cpp
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test
  test/clangd/symbols.test
  unittests/clangd/FindSymbolsTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h

Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -43,6 +43,9 @@
 llvm::Expected>
 runWorkspaceSymbols(ClangdServer &Server, StringRef Query, int Limit);
 
+llvm::Expected>
+runDocumentSymbols(ClangdServer &Server, PathRef File);
+
 } // namespace clangd
 } // namespace clang
 
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -117,5 +117,12 @@
   return std::move(*Result);
 }
 
+llvm::Expected>
+runDocumentSymbols(ClangdServer &Server, PathRef File) {
+  llvm::Optional>> Result;
+  Server.documentSymbols(File, capture(Result));
+  return std::move(*Result);
+}
+
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/FindSymbolsTests.cpp
===
--- unittests/clangd/FindSymbolsTests.cpp
+++ unittests/clangd/FindSymbolsTests.cpp
@@ -22,6 +22,7 @@
 using ::testing::AllOf;
 using ::testing::AnyOf;
 using ::testing::ElementsAre;
+using ::testing::ElementsAreArray;
 using ::testing::IsEmpty;
 using ::testing::UnorderedElementsAre;
 
@@ -37,6 +38,7 @@
   return (arg.containerName + "::" + arg.name) == Name;
 }
 MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; }
+MATCHER_P(SymRange, Range, "") { return arg.location.range == Range; }
 
 ClangdServer::Options optsForTests() {
   auto ServerOpts = ClangdServer::optsForTest();
@@ -287,5 +289,242 @@
   EXPECT_THAT(getSymbols("foo"), ElementsAre(QName("foo")));
 }
 
+namespace {
+class DocumentSymbolsTest : public ::testing::Test {
+public:
+  DocumentSymbolsTest()
+  : Server(CDB, FSProvider, DiagConsumer, optsForTests()) {}
+
+protected:
+  MockFSProvider FSProvider;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server;
+
+  std::vector getSymbols(PathRef File) {
+EXPECT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for preamble";
+auto SymbolInfos = runDocumentSymbols(Server, File);
+EXPECT_TRUE(bool(SymbolInfos)) << "documentSymbols returned an error";
+return *SymbolInfos;
+  }
+
+  void addFile(StringRef FilePath, StringRef Contents) {
+FSProvider.Files[FilePath] = Contents;
+Server.addDocument(FilePath, Contents);
+  }
+};
+} // namespace
+
+TEST_F(DocumentSymbolsTest, BasicSymbols) {
+  std::string FilePath = testPath("foo.cpp");
+  addFile(FilePath, R"(
+class Foo;
+class Foo {
+  Foo() {}
+  Foo(int a) {}
+  void f();
+  friend void f1();
+  friend class Friend;
+  Foo& operator=(const Foo&);
+  ~Foo();
+  class Nested {
+  void f();
+  };
+};
+class Friend {
+};
+
+void f1();
+inline void f2() {}
+static const int KInt = 2;
+const char* kStr = "123";
+
+void f1() {}
+
+namespace foo {
+// Type alias
+typedef int int32;
+using int32_t = int32;
+
+// Variable
+int v1;
+
+// Namespace
+namespace bar {
+int v2;
+}
+// Namespace alias
+namespace baz = bar;
+
+// FIXME: using declaration is not supported as the IndexAction will ignore
+// implicit declarations (the implicit using shadow declaration) by default,
+// and there is no way to customize this behavior at the moment.
+using bar::v2;
+} // namespace foo
+  )");
+  EXPECT_THAT(getSymbols(FilePath),
+  ElementsAreArray(
+  {AllOf(QName("Foo"), WithKind(SymbolKind::Class)),
+   AllOf(QName("Foo"), WithKind(SymbolKind::Class)),
+   AllOf(QName("Foo::Foo"), WithKind(SymbolKind::Method)),
+   AllOf(QName("Foo::Foo"), WithKind(SymbolKind::Method)),
+   AllOf(QName("Foo::f"), WithKind(SymbolKind::Method)),
+   AllOf(QName("f1"), WithKind(SymbolKind::Function)),
+   AllOf(QName("Foo::operator="), WithKind(SymbolKind::Method)),
+   AllOf(QName("Foo::~Foo"), WithKind(SymbolKind::Method)),
+   AllOf(QName("Foo::Nested"), WithKind(SymbolKind::Class)),
+   AllOf(QName("Foo::Nested::f"), WithKind(SymbolKind::Method)),
+
+   AllO

[PATCH] D48507: [mips] Explicitly specify the linker emulation for MIPS on FreeBSD.

2018-06-26 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb updated this revision to Diff 152955.
bsdjhb added a comment.

- Add N32EL.


Repository:
  rC Clang

https://reviews.llvm.org/D48507

Files:
  lib/Driver/ToolChains/FreeBSD.cpp
  test/Driver/freebsd.c


Index: test/Driver/freebsd.c
===
--- test/Driver/freebsd.c
+++ test/Driver/freebsd.c
@@ -42,6 +42,27 @@
 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 
\
 // RUN:   | FileCheck --check-prefix=CHECK-LIB32PATHS %s
 //
+// Check that MIPS passes the correct linker emulation.
+//
+// RUN: %clang -target mips-freebsd %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-LD %s
+// CHECK-MIPS-LD: ld{{.*}}" {{.*}} "-m" "elf32btsmip_fbsd"
+// RUN: %clang -target mipsel-freebsd %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPSEL-LD %s
+// CHECK-MIPSEL-LD: ld{{.*}}" {{.*}} "-m" "elf32ltsmip_fbsd"
+// RUN: %clang -target mips64-freebsd %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS64-LD %s
+// CHECK-MIPS64-LD: ld{{.*}}" {{.*}} "-m" "elf64btsmip_fbsd"
+// RUN: %clang -target mips64el-freebsd %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s
+// CHECK-MIPS64EL-LD: ld{{.*}}" {{.*}} "-m" "elf64ltsmip_fbsd"
+// RUN: %clang -target mips64-freebsd -mabi=n32 %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPSN32-LD %s
+// CHECK-MIPSN32-LD: ld{{.*}}" {{.*}} "-m" "elf32btsmipn32_fbsd"
+// RUN: %clang -target mips64el-freebsd -mabi=n32 %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPSN32EL-LD %s
+// CHECK-MIPSN32EL-LD: ld{{.*}}" {{.*}} "-m" "elf32ltsmipn32_fbsd"
+//
 // Check that the new linker flags are passed to FreeBSD
 // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \
 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
Index: lib/Driver/ToolChains/FreeBSD.cpp
===
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -166,16 +166,39 @@
 CmdArgs.push_back("--enable-new-dtags");
   }
 
-  // When building 32-bit code on FreeBSD/amd64, we have to explicitly
-  // instruct ld in the base system to link 32-bit code.
-  if (Arch == llvm::Triple::x86) {
+  // Explicitly set the linker emulation for platforms that might not
+  // be the default emulation for the linker.
+  switch (Arch) {
+  case llvm::Triple::x86:
 CmdArgs.push_back("-m");
 CmdArgs.push_back("elf_i386_fbsd");
-  }
-
-  if (Arch == llvm::Triple::ppc) {
+break;
+  case llvm::Triple::ppc:
 CmdArgs.push_back("-m");
 CmdArgs.push_back("elf32ppc_fbsd");
+break;
+  case llvm::Triple::mips:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf32btsmip_fbsd");
+break;
+  case llvm::Triple::mipsel:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf32ltsmip_fbsd");
+break;
+  case llvm::Triple::mips64:
+CmdArgs.push_back("-m");
+if (tools::mips::hasMipsAbiArg(Args, "n32"))
+  CmdArgs.push_back("elf32btsmipn32_fbsd");
+else
+  CmdArgs.push_back("elf64btsmip_fbsd");
+break;
+  case llvm::Triple::mips64el:
+CmdArgs.push_back("-m");
+if (tools::mips::hasMipsAbiArg(Args, "n32"))
+  CmdArgs.push_back("elf32ltsmipn32_fbsd");
+else
+  CmdArgs.push_back("elf64ltsmip_fbsd");
+break;
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_G)) {


Index: test/Driver/freebsd.c
===
--- test/Driver/freebsd.c
+++ test/Driver/freebsd.c
@@ -42,6 +42,27 @@
 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LIB32PATHS %s
 //
+// Check that MIPS passes the correct linker emulation.
+//
+// RUN: %clang -target mips-freebsd %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-LD %s
+// CHECK-MIPS-LD: ld{{.*}}" {{.*}} "-m" "elf32btsmip_fbsd"
+// RUN: %clang -target mipsel-freebsd %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPSEL-LD %s
+// CHECK-MIPSEL-LD: ld{{.*}}" {{.*}} "-m" "elf32ltsmip_fbsd"
+// RUN: %clang -target mips64-freebsd %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS64-LD %s
+// CHECK-MIPS64-LD: ld{{.*}}" {{.*}} "-m" "elf64btsmip_fbsd"
+// RUN: %clang -target mips64el-freebsd %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s
+// CHECK-MIPS64EL-LD: ld{{.*}}" {{.*}} "-m" "elf64ltsmip_fbsd"
+// RUN: %clang -target mips64-freebsd -mabi=n32 %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPSN32-LD %s
+// CHECK-MIPSN32-LD: ld{{.*}}" {{.*}} "-m" "elf32btsmipn32_fbsd"
+// RUN: %clang -target mips64el-freebsd -mabi=n32 %s -### %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPSN32EL-LD %s
+// CHECK-MIPSN32EL-LD: ld{{.*}}" {{.*}} "-m" "elf32ltsmipn32_fbsd"
+//
 // Check that the new linker flags are passed to FreeBSD
 // RUN: %clang -

[PATCH] D48589: [WIP] [CodeGen] Allow specifying Extend to CoerceAndExpand

2018-06-26 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added inline comments.



Comment at: include/clang/CodeGen/CGFunctionInfo.h:90
   union {
-unsigned DirectOffset; // isDirect() || isExtend()
-unsigned IndirectAlign;// isIndirect()
-unsigned AllocaFieldIndex; // isInAlloca()
+llvm::StructType *ExtendSeq; // isCoerceAndExpand()
+unsigned DirectOffset;   // isDirect() || isExtend()

rjmccall wrote:
> Hmm.  I understand the need to use something uniqued here, but I think it 
> would probably be more natural to at least use a `llvm::ConstantDataArray` 
> (which could be null if there are no interesting bits) instead of encoding 
> the information into the types of a struct type.  That would also make it 
> easy to generalize the elements to an arbitrary flags type.
> 
> Also, on 64-bit targets this will increase the size of an `ABIArgInfo` to 
> four pointers from three.  That's fine to the extent that we work with 
> independent `ABIArgInfo`s, but I'm getting a little annoyed at the storage 
> overhead of the array of `ABIArgInfo`s in `CGFunctionInfo` given that, in the 
> overwhelmingly common case, an `ABIArgInfo` is no more than a kind and maybe 
> a few of these flags.  Maybe there's some reasonable way to optimize the 
> storage of an `ABIArgInfo` in a `CGFunctionInfo` so that we only need the 
> extra storage in less-common cases?  Like extracting out a base class that's 
> the Kind+Flags and making the main array be an array of those + an optional 
> index into a second trailing array of full `ABIArgInfo`s.
> 
> I might be overthinking this, though.
Oh, of course, using a value rather than a type is more sensible. I will change 
this.

The idea of having a lighter `ABIArgInfo` and an ancillary extra array for it 
seems sensible. I guess it may depend on how early/late we know the precise 
kind of `ABIArgInfo` we need to represent. I haven't looked at this yet, I'll 
investigate.



Comment at: include/clang/CodeGen/CGFunctionInfo.h:475
 
+static_assert(std::is_trivially_copyable::value,
+"ABIArgInfo must be trivially copyable as it is embedded as trailing "

rogfer01 wrote:
> I think this is the right trait here. I spent too much time debugging this :)
But today I realised that GCC 4.9 does not implement this so it will have to go 
away :(


https://reviews.llvm.org/D48589



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


[PATCH] D45454: Make __gcov_flush visible outside a shared library

2018-06-26 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 152957.
chh edited the summary of this revision.

https://reviews.llvm.org/D45454

Files:
  lib/profile/GCDAProfiling.c
  test/profile/Inputs/instrprof-dlopen-dlclose-main.c


Index: test/profile/Inputs/instrprof-dlopen-dlclose-main.c
===
--- test/profile/Inputs/instrprof-dlopen-dlclose-main.c
+++ test/profile/Inputs/instrprof-dlopen-dlclose-main.c
@@ -16,6 +16,31 @@
 return EXIT_FAILURE;
   }
 
+  void (*llvm_flush)() = (void (*)())dlsym(f1_handle, "llvm_gcov_flush");
+  if (llvm_flush != NULL) {
+fprintf(stderr, "llvm_gcov_flush should not be visible in func.shared'\n");
+return EXIT_FAILURE;
+  }
+
+  void (*f1_flush)() = (void (*)())dlsym(f1_handle, "__gcov_flush");
+  if (f1_flush == NULL) {
+fprintf(stderr, "unable to find __gcov_flush in func.shared'\n");
+return EXIT_FAILURE;
+  }
+  f1_flush();
+
+  void (*f2_flush)() = (void (*)())dlsym(f2_handle, "__gcov_flush");
+  if (f2_flush == NULL) {
+fprintf(stderr, "unable to find __gcov_flush in func2.shared'\n");
+return EXIT_FAILURE;
+  }
+  f2_flush();
+
+  if (f1_flush == f2_flush) {
+fprintf(stderr, "Same __gcov_flush found in func.shared and 
func2.shared\n");
+return EXIT_FAILURE;
+  }
+
   if (dlclose(f2_handle) != 0) {
 fprintf(stderr, "unable to close 'func2.shared': %s\n", dlerror());
 return EXIT_FAILURE;
Index: lib/profile/GCDAProfiling.c
===
--- lib/profile/GCDAProfiling.c
+++ lib/profile/GCDAProfiling.c
@@ -527,16 +527,28 @@
   }
 }
 
+// llvm_gcov_flush is like __gcov_flush, but invisible outside a .so file.
+// It should be used inside a .so file to flush its own profile data.
 COMPILER_RT_VISIBILITY
-void __gcov_flush() {
+void llvm_gcov_flush() {
   struct flush_fn_node *curr = flush_fn_head;
 
   while (curr) {
 curr->fn();
 curr = curr->next;
   }
 }
 
+// Keep __gcov_flush visible to be compatible with old gcov users
+// who call dlsym to find and call __gcov_flush in .so files.
+// In that use case, the expected bahavior is to flush profile data
+// for each .so file.
+// When called directly inside a .so file, the unified __gcov_flush
+// would flush the main program profile data.
+void __gcov_flush() {
+  llvm_gcov_flush();
+}
+
 COMPILER_RT_VISIBILITY
 void llvm_delete_flush_function_list(void) {
   while (flush_fn_head) {


Index: test/profile/Inputs/instrprof-dlopen-dlclose-main.c
===
--- test/profile/Inputs/instrprof-dlopen-dlclose-main.c
+++ test/profile/Inputs/instrprof-dlopen-dlclose-main.c
@@ -16,6 +16,31 @@
 return EXIT_FAILURE;
   }
 
+  void (*llvm_flush)() = (void (*)())dlsym(f1_handle, "llvm_gcov_flush");
+  if (llvm_flush != NULL) {
+fprintf(stderr, "llvm_gcov_flush should not be visible in func.shared'\n");
+return EXIT_FAILURE;
+  }
+
+  void (*f1_flush)() = (void (*)())dlsym(f1_handle, "__gcov_flush");
+  if (f1_flush == NULL) {
+fprintf(stderr, "unable to find __gcov_flush in func.shared'\n");
+return EXIT_FAILURE;
+  }
+  f1_flush();
+
+  void (*f2_flush)() = (void (*)())dlsym(f2_handle, "__gcov_flush");
+  if (f2_flush == NULL) {
+fprintf(stderr, "unable to find __gcov_flush in func2.shared'\n");
+return EXIT_FAILURE;
+  }
+  f2_flush();
+
+  if (f1_flush == f2_flush) {
+fprintf(stderr, "Same __gcov_flush found in func.shared and func2.shared\n");
+return EXIT_FAILURE;
+  }
+
   if (dlclose(f2_handle) != 0) {
 fprintf(stderr, "unable to close 'func2.shared': %s\n", dlerror());
 return EXIT_FAILURE;
Index: lib/profile/GCDAProfiling.c
===
--- lib/profile/GCDAProfiling.c
+++ lib/profile/GCDAProfiling.c
@@ -527,16 +527,28 @@
   }
 }
 
+// llvm_gcov_flush is like __gcov_flush, but invisible outside a .so file.
+// It should be used inside a .so file to flush its own profile data.
 COMPILER_RT_VISIBILITY
-void __gcov_flush() {
+void llvm_gcov_flush() {
   struct flush_fn_node *curr = flush_fn_head;
 
   while (curr) {
 curr->fn();
 curr = curr->next;
   }
 }
 
+// Keep __gcov_flush visible to be compatible with old gcov users
+// who call dlsym to find and call __gcov_flush in .so files.
+// In that use case, the expected bahavior is to flush profile data
+// for each .so file.
+// When called directly inside a .so file, the unified __gcov_flush
+// would flush the main program profile data.
+void __gcov_flush() {
+  llvm_gcov_flush();
+}
+
 COMPILER_RT_VISIBILITY
 void llvm_delete_flush_function_list(void) {
   while (flush_fn_head) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48159: [clangd] Implement hover for "auto" and "decltype"

2018-06-26 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle updated this revision to Diff 152958.
malaperle added a comment.

Rebased.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48159

Files:
  clangd/XRefs.cpp
  unittests/clangd/TestTU.cpp
  unittests/clangd/TestTU.h
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -343,6 +343,13 @@
 
   OneTest Tests[] = {
   {
+  R"cpp(// No hover
+^int main() {
+}
+  )cpp",
+  "",
+  },
+  {
   R"cpp(// Local variable
 int main() {
   int bonjour;
@@ -637,16 +644,273 @@
   )cpp",
   "",
   },
+  {
+  R"cpp(// Simple initialization with auto
+void foo() {
+  ^auto i = 1;
+}
+  )cpp",
+  "int",
+  },
+  {
+  R"cpp(// Simple initialization with const auto
+void foo() {
+  const ^auto i = 1;
+}
+  )cpp",
+  "int",
+  },
+  {
+  R"cpp(// Simple initialization with const auto&
+void foo() {
+  const ^auto& i = 1;
+}
+  )cpp",
+  "int",
+  },
+  {
+  R"cpp(// Simple initialization with auto&
+void foo() {
+  ^auto& i = 1;
+}
+  )cpp",
+  "int",
+  },
+  {
+  R"cpp(// Auto with initializer list.
+namespace std
+{
+  template
+  class initializer_list {};
+}
+void foo() {
+  ^auto i = {1,2};
+}
+  )cpp",
+  "class std::initializer_list",
+  },
+  {
+  R"cpp(// User defined conversion to auto
+struct Bar {
+  operator ^auto() const { return 10; }
+};
+  )cpp",
+  "int",
+  },
+  {
+  R"cpp(// Simple initialization with decltype(auto)
+void foo() {
+  ^decltype(auto) i = 1;
+}
+  )cpp",
+  "int",
+  },
+  {
+  R"cpp(// Simple initialization with const decltype(auto)
+void foo() {
+  const int j = 0;
+  ^decltype(auto) i = j;
+}
+  )cpp",
+  "const int",
+  },
+  {
+  R"cpp(// Simple initialization with const& decltype(auto)
+void foo() {
+  int k = 0;
+  const int& j = k;
+  ^decltype(auto) i = j;
+}
+  )cpp",
+  "const int &",
+  },
+  {
+  R"cpp(// Simple initialization with & decltype(auto)
+void foo() {
+  int k = 0;
+  int& j = k;
+  ^decltype(auto) i = j;
+}
+  )cpp",
+  "int &",
+  },
+  {
+  R"cpp(// decltype with initializer list: nothing
+namespace std
+{
+  template
+  class initializer_list {};
+}
+void foo() {
+  ^decltype(auto) i = {1,2};
+}
+  )cpp",
+  "",
+  },
+  {
+  R"cpp(// auto function return with trailing type
+struct Bar {};
+^auto test() -> decltype(Bar()) {
+  return Bar();
+}
+  )cpp",
+  "struct Bar",
+  },
+  {
+  R"cpp(// trailing return type
+struct Bar {};
+auto test() -> ^decltype(Bar()) {
+  return Bar();
+}
+  )cpp",
+  "struct Bar",
+  },
+  {
+  R"cpp(// auto in function return
+struct Bar {};
+^auto test() {
+  return Bar();
+}
+  )cpp",
+  "struct Bar",
+  },
+  {
+  R"cpp(// auto& in function return
+struct Bar {};
+^auto& test() {
+  return Bar();
+}
+  )cpp",
+  "struct Bar",
+  },
+  {
+  R"cpp(// const auto& in function return
+struct Bar {};
+const ^auto& test() {
+  return Bar();
+}
+  )cpp",
+  "struct Bar",
+  },
+  {
+  R"cpp(// decltype(auto) in function return
+struct Bar {};
+^decltype(auto) test() {
+  return Bar();
+}
+  )cpp",
+  "struct Bar",
+  },
+  {
+  R"cpp(// decltype(auto) reference in function return
+struct Bar {};
+^decltype(auto) test() {
+  int a;
+  return (a);
+}
+  )cpp",
+  "int &",
+  },
+  {
+  R"cpp(// decltype lvalue reference
+void foo() {
+  int I 

Re: [PATCH] D45454: Make __gcov_flush visible outside a shared library

2018-06-26 Thread Marco Castelluccio via cfe-commits
Wouldn't it be better to keep compatibility with GCC and make
__gcov_flush have default visibility?

- Marco.


Il 26/06/2018 00:21, Xinliang David Li ha scritto:
> I don't have an objection having another interface which is just a
> simple wrapper to __gcov_flush but with default visibility. Also
> clearly document its usage and behavior.
>
> David
>
> On Mon, Jun 25, 2018 at 10:12 AM, Chih-Hung Hsieh via Phabricator via
> llvm-commits  > wrote:
>
> chh added a comment.
>
> In https://reviews.llvm.org/D45454#1142197
> , @marco-c wrote:
>
> > In https://reviews.llvm.org/D45454#1070884
> , @belleyb wrote:
> >
> > > @chh I had a chance to try out your proposed changes. It's not
> causing us any trouble. In fact, `__gcov_flush()` is not even used
> at all (at least in LLVM 5.0.1).. I can recompile llvm,
> compiler_rt and clang and re-run all the tests with `__gcov_flush`
> commented out! No problem.
> > >
> > > I would suggest adding a bit more documentation to
> `__gcov_flush()`, thus describing what those "special cases" are...
> >
> >
> > __gcov_flush is only used if you actually call it (it's needed
> for example if you want to profile only part of your program).
> >
> > In GCC, __gcov_flush is not hidden, so perhaps we should do the
> same to keep the same behavior? I've also submitted
> https://reviews.llvm.org/D48538 ,
> which is making __gcov_flush flush counters for all shared
> libraries (like GCC does, with the same caveat:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83879
> ).
>
>
> I have no problem keeping these functions compatible with GCC.
> My earlier proposal and David's comment in the mailing list seemed
> to be lost and not showing here.
> So, let me summarize the case here. This change should make
> `__gcov_flush` not hidden as before in GCC,
> but earlier change made it hidden as well as other `llvm_gov_*`
> functions.
> Could we have both `__gov_flush` and `llvm_gov_flush` functions,
> one unhidden and one hidden?
>
>
> https://reviews.llvm.org/D45454 
>
>
>
> ___
> llvm-commits mailing list
> llvm-comm...@lists.llvm.org 
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> 
>
>

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


r335666 - [analyzer] Do not run visitors until the fixpoint, run only once.

2018-06-26 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Jun 26 14:12:08 2018
New Revision: 335666

URL: http://llvm.org/viewvc/llvm-project?rev=335666&view=rev
Log:
[analyzer] Do not run visitors until the fixpoint, run only once.

In the current implementation, we run visitors until the fixed point is
reached.
That is, if a visitor adds another visitor, the currently processed path
is destroyed, all diagnostics is discarded, and it is regenerated again,
until it's no longer modified.
This pattern has a few negative implications:

 - This loop does not even guarantee to terminate.
   E.g. just imagine two visitors bouncing a diagnostics around.
 - Performance-wise, e.g. for sqlite3 all visitors are being re-run at
   least 10 times for some bugs.
   We have already seen a few reports where it leads to timeouts.
 - If we want to add more computationally intense visitors, this will
   become worse.
 - From architectural standpoint, the current layout requires copying
   visitors, which is conceptually wrong, and can be annoying (e.g. no
   unique_ptr on visitors allowed).

The proposed change is a much simpler architecture: the outer loop
processes nodes upwards, and whenever the visitor is added it only
processes current nodes and above, thus guaranteeing termination.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h

cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
cfe/trunk/lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Analysis/null-deref-path-notes.c

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=335666&r1=335665&r2=335666&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Tue 
Jun 26 14:12:08 2018
@@ -23,6 +23,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/FoldingSet.h"
@@ -65,6 +66,11 @@ class SValBuilder;
 // Interface for individual bug reports.
 
//===--===//
 
+/// A mapping from diagnostic consumers to the diagnostics they should
+/// consume.
+using DiagnosticForConsumerMapTy =
+llvm::DenseMap>;
+
 /// This class provides an interface through which checkers can create
 /// individual bug reports.
 class BugReport : public llvm::ilist_node {
@@ -130,10 +136,6 @@ protected:
   /// Used for ensuring the visitors are only added once.
   llvm::FoldingSet CallbacksSet;
 
-  /// Used for clients to tell if the report's configuration has changed
-  /// since the last time they checked.
-  unsigned ConfigurationChangeToken = 0;
-  
   /// When set, this flag disables all callstack pruning from a diagnostic
   /// path.  This is useful for some reports that want maximum fidelty
   /// when reporting an issue.
@@ -229,10 +231,6 @@ public:
   bool isInteresting(SVal V);
   bool isInteresting(const LocationContext *LC);
 
-  unsigned getConfigurationChangeToken() const {
-return ConfigurationChangeToken;
-  }
-
   /// Returns whether or not this report should be considered valid.
   ///
   /// Invalid reports are those that have been classified as likely false
@@ -345,6 +343,9 @@ public:
   /// registerVarDeclsLastStore().
   void addVisitor(std::unique_ptr visitor);
 
+  /// Remove all visitors attached to this bug re

[PATCH] D48608: [CFG] [analyzer] Add construction contexts for C++ objects returned from Objective-C messages.

2018-06-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, george.karpenkov.
Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, rnkovacs, 
szepet, baloghadamsoftware.

This patch extends https://reviews.llvm.org/D44120 to Objective-C messages that 
can also sometimes return C++ objects (in Objective-C++), but aren't inheriting 
from `CallExpr`. We'll now be able to properly destroy temporaries returned 
from such messages and/or materialize them. The analyzer picks up the newly 
added context automatically, as demonstrated by the new test case.

I removed the `getCallReturnType()` check because most of its branches aren't 
useful in our case.


Repository:
  rC Clang

https://reviews.llvm.org/D48608

Files:
  include/clang/Analysis/CFG.h
  lib/Analysis/CFG.cpp
  test/Analysis/cfg-rich-constructors.mm
  test/Analysis/lifetime-extension.mm

Index: test/Analysis/lifetime-extension.mm
===
--- /dev/null
+++ test/Analysis/lifetime-extension.mm
@@ -0,0 +1,64 @@
+// RUN: %clang_analyze_cc1 -Wno-unused -std=c++11 -analyzer-checker=core,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -Wno-unused -std=c++17 -analyzer-checker=core,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -Wno-unused -std=c++11 -analyzer-checker=core,debug.ExprInspection -DMOVES -verify %s
+// RUN: %clang_analyze_cc1 -Wno-unused -std=c++17 -analyzer-checker=core,debug.ExprInspection -DMOVES -verify %s
+
+void clang_analyzer_eval(bool);
+void clang_analyzer_checkInlined(bool);
+
+template  struct AddressVector {
+  T *buf[10];
+  int len;
+
+  AddressVector() : len(0) {}
+
+  void push(T *t) {
+buf[len] = t;
+++len;
+  }
+};
+
+class C {
+  AddressVector &v;
+
+public:
+  C(AddressVector &v) : v(v) { v.push(this); }
+  ~C() { v.push(this); }
+
+#ifdef MOVES
+  C(C &&c) : v(c.v) { v.push(this); }
+#endif
+
+  // Note how return-statements prefer move-constructors when available.
+  C(const C &c) : v(c.v) {
+#ifdef MOVES
+clang_analyzer_checkInlined(false); // no-warning
+#else
+v.push(this);
+#endif
+  } // no-warning
+};
+
+@interface NSObject {}
+@end;
+@interface Foo: NSObject {}
+  -(C) make: (AddressVector &)v;
+@end
+
+@implementation Foo
+-(C) make: (AddressVector &)v {
+  return C(v);
+}
+@end
+
+void testReturnByValueFromMessage(Foo *foo) {
+  AddressVector v;
+  {
+const C &c = [foo make: v];
+  }
+  // 0. Construct the return value of -make (copy/move elided) and
+  //lifetime-extend it directly via reference 'c',
+  // 1. Destroy the temporary lifetime-extended by 'c'.
+  clang_analyzer_eval(v.len == 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval(v.buf[0] == v.buf[1]); // expected-warning{{TRUE}}
+}
Index: test/Analysis/cfg-rich-constructors.mm
===
--- test/Analysis/cfg-rich-constructors.mm
+++ test/Analysis/cfg-rich-constructors.mm
@@ -15,6 +15,7 @@
 
 @interface E {}
 -(void) foo: (D) d;
+-(D) bar;
 @end
 
 // FIXME: Find construction context for the argument.
@@ -39,3 +40,27 @@
 void passArgumentIntoMessage(E *e) {
   [e foo: D()];
 }
+
+// CHECK: void returnObjectFromMessage(E *e)
+// CHECK:[B1]
+// CHECK-NEXT: 1: e
+// CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, LValueToRValue, E *)
+// Double brackets trigger FileCheck variables, escape.
+// CXX11-ELIDE-NEXT: 3: {{\[}}[B1.2] bar] (CXXRecordTypedCall, [B1.4], [B1.6], [B1.7])
+// CXX11-NOELIDE-NEXT: 3: {{\[}}[B1.2] bar] (CXXRecordTypedCall, [B1.4], [B1.6])
+// CXX11-NEXT: 4: [B1.3] (BindTemporary)
+// CXX11-NEXT: 5: [B1.4] (ImplicitCastExpr, NoOp, const class D)
+// CXX11-NEXT: 6: [B1.5]
+// CXX11-NEXT: 7: [B1.6] (CXXConstructExpr, [B1.8], class D)
+// CXX11-NEXT: 8: D d = [e bar];
+// CXX11-NEXT: 9: ~D() (Temporary object destructor)
+// CXX11-NEXT:10: [B1.8].~D() (Implicit destructor)
+// Double brackets trigger FileCheck variables, escape.
+// CXX17-NEXT: 3: {{\[}}[B1.2] bar] (CXXRecordTypedCall, [B1.5], [B1.4])
+// CXX17-NEXT: 4: [B1.3] (BindTemporary)
+// CXX17-NEXT: 5: D d = [e bar];
+// CXX17-NEXT: 6: ~D() (Temporary object destructor)
+// CXX17-NEXT: 7: [B1.5].~D() (Implicit destructor)
+void returnObjectFromMessage(E *e) {
+  D d = [e bar];
+}
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -755,7 +755,7 @@
   cachedEntry->second = B;
 
 if (BuildOpts.AddRichCXXConstructors) {
-  if (CFGCXXRecordTypedCall::isCXXRecordTypedCall(CE, *Context)) {
+  if (CFGCXXRecordTypedCall::isCXXRecordTypedCall(CE)) {
 if (const ConstructionContextLayer *Layer =
 ConstructionContextMap.lookup(CE)) {
   cleanupConstructionContext(CE);
@@ -788,6 +788,28 @@
 B->appendMemberDtor(FD, cfg->getBumpVectorContext());
   }
 
+  void appendObjCMessage(CFGBlock *B, ObjCMessageE

[PATCH] D48589: [WIP] [CodeGen] Allow specifying Extend to CoerceAndExpand

2018-06-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/CodeGen/CGFunctionInfo.h:90
   union {
-unsigned DirectOffset; // isDirect() || isExtend()
-unsigned IndirectAlign;// isIndirect()
-unsigned AllocaFieldIndex; // isInAlloca()
+llvm::StructType *ExtendSeq; // isCoerceAndExpand()
+unsigned DirectOffset;   // isDirect() || isExtend()

rogfer01 wrote:
> rjmccall wrote:
> > Hmm.  I understand the need to use something uniqued here, but I think it 
> > would probably be more natural to at least use a `llvm::ConstantDataArray` 
> > (which could be null if there are no interesting bits) instead of encoding 
> > the information into the types of a struct type.  That would also make it 
> > easy to generalize the elements to an arbitrary flags type.
> > 
> > Also, on 64-bit targets this will increase the size of an `ABIArgInfo` to 
> > four pointers from three.  That's fine to the extent that we work with 
> > independent `ABIArgInfo`s, but I'm getting a little annoyed at the storage 
> > overhead of the array of `ABIArgInfo`s in `CGFunctionInfo` given that, in 
> > the overwhelmingly common case, an `ABIArgInfo` is no more than a kind and 
> > maybe a few of these flags.  Maybe there's some reasonable way to optimize 
> > the storage of an `ABIArgInfo` in a `CGFunctionInfo` so that we only need 
> > the extra storage in less-common cases?  Like extracting out a base class 
> > that's the Kind+Flags and making the main array be an array of those + an 
> > optional index into a second trailing array of full `ABIArgInfo`s.
> > 
> > I might be overthinking this, though.
> Oh, of course, using a value rather than a type is more sensible. I will 
> change this.
> 
> The idea of having a lighter `ABIArgInfo` and an ancillary extra array for it 
> seems sensible. I guess it may depend on how early/late we know the precise 
> kind of `ABIArgInfo` we need to represent. I haven't looked at this yet, I'll 
> investigate.
`CGFunctionInfo` should be totally immutable and just ultimately constructed 
with an array of `ABIArgInfo`, which seems like a reasonable place to inject 
some representation tricks.



Comment at: include/clang/CodeGen/CGFunctionInfo.h:475
 
+static_assert(std::is_trivially_copyable::value,
+"ABIArgInfo must be trivially copyable as it is embedded as trailing "

rogfer01 wrote:
> rogfer01 wrote:
> > I think this is the right trait here. I spent too much time debugging this 
> > :)
> But today I realised that GCC 4.9 does not implement this so it will have to 
> go away :(
You could gate it on the compiler if you want, maybe extracting a 
`HAS_IS_TRIVIALLY_COPYABLE` test macro in `llvm/Support/type_traits.h` out of 
the implementation of `llvm::isPodLike`.


https://reviews.llvm.org/D48589



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


[PATCH] D45454: Make __gcov_flush visible outside a shared library

2018-06-26 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

GCC's behavior is not documented and it also has changed over the years.

Unless there is a bug, changing LLVM's gcov_flush visibility can potentially 
break clients that depend on this behavior.


https://reviews.llvm.org/D45454



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


[PATCH] D45454: Make __gcov_flush visible outside a shared library

2018-06-26 Thread Stephen Hines via Phabricator via cfe-commits
srhines added a comment.

In https://reviews.llvm.org/D45454#1144099, @davidxl wrote:

> GCC's behavior is not documented and it also has changed over the years.
>
> Unless there is a bug, changing LLVM's gcov_flush visibility can potentially 
> break clients that depend on this behavior.


I think that's the issue though. LLVM changed visibility of this function 
recently too. We had Android code depending on this function being visible, and 
that broke.


https://reviews.llvm.org/D45454



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


Re: [PATCH] D45454: Make __gcov_flush visible outside a shared library

2018-06-26 Thread Marco Castelluccio via cfe-commits
Yes, the behavior changed very recently, I would be surprised if
somebody came to depend on it. It's more likely that some clients are
depending on the old behavior.

- Marco.


Il 26/06/2018 22:43, Stephen Hines via Phabricator ha scritto:
> srhines added a comment.
>
> In https://reviews.llvm.org/D45454#1144099, @davidxl wrote:
>
>> GCC's behavior is not documented and it also has changed over the years.
>>
>> Unless there is a bug, changing LLVM's gcov_flush visibility can potentially 
>> break clients that depend on this behavior.
>
> I think that's the issue though. LLVM changed visibility of this function 
> recently too. We had Android code depending on this function being visible, 
> and that broke.
>
>
> https://reviews.llvm.org/D45454
>
>
>

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


[PATCH] D45454: Make __gcov_flush visible outside a shared library

2018-06-26 Thread Marco Castelluccio via Phabricator via cfe-commits
marco-c added a comment.

Yes, the behavior changed very recently, I would be surprised if
somebody came to depend on it. It's more likely that some clients are
depending on the old behavior.

- Marco.

Il 26/06/2018 22:43, Stephen Hines via Phabricator ha scritto:

> srhines added a comment.
> 
> In https://reviews.llvm.org/D45454#1144099, @davidxl wrote:
> 
>> GCC's behavior is not documented and it also has changed over the years.
>> 
>> Unless there is a bug, changing LLVM's gcov_flush visibility can potentially 
>> break clients that depend on this behavior.
> 
> I think that's the issue though. LLVM changed visibility of this function 
> recently too. We had Android code depending on this function being visible, 
> and that broke.
> 
> https://reviews.llvm.org/D45454


https://reviews.llvm.org/D45454



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


[PATCH] D48571: improve diagnostics for missing 'template' keyword

2018-06-26 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks pretty good to me - nice work!


Repository:
  rL LLVM

https://reviews.llvm.org/D48571



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


[PATCH] D48613: [CUDA] Use atexit() to call module destructor.

2018-06-26 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added a reviewer: jlebar.
Herald added subscribers: bixia, sanjoy.

This matches the way NVCC does it. Doing module cleanup at global
destructor phase used to work, but is, apparently, too late for
the CUDA runtime in CUDA-9.2, which ends up crashing with double-free.


https://reviews.llvm.org/D48613

Files:
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -404,10 +404,9 @@
   AddGlobalCtor(ObjCInitFunction);
   if (Context.getLangOpts().CUDA && !Context.getLangOpts().CUDAIsDevice &&
   CUDARuntime) {
-if (llvm::Function *CudaCtorFunction = 
CUDARuntime->makeModuleCtorFunction())
+if (llvm::Function *CudaCtorFunction =
+CUDARuntime->makeModuleCtorFunction())
   AddGlobalCtor(CudaCtorFunction);
-if (llvm::Function *CudaDtorFunction = 
CUDARuntime->makeModuleDtorFunction())
-  AddGlobalDtor(CudaDtorFunction);
   }
   if (OpenMPRuntime) {
 if (llvm::Function *OpenMPRegistrationFunction =
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -472,6 +472,18 @@
 CtorBuilder.CreateCall(RegisterLinkedBinaryFunc, Args);
   }
 
+  // Create destructor and register it with atexit() the way NVCC does it. 
Doing
+  // it during regular destructor phase worked in CUDA before 9.2 but results 
in
+  // double-free in 9.2.
+  llvm::Function *CleanupFn = makeModuleDtorFunction();
+  // extern "C" int atexit(void (*f)(void));
+  llvm::FunctionType *AtExitTy =
+  llvm::FunctionType::get(IntTy, CleanupFn->getType(), false);
+  llvm::Constant *AtExitFunc =
+  CGM.CreateRuntimeFunction(AtExitTy, "atexit", llvm::AttributeList(),
+/*Local=*/true);
+  CtorBuilder.CreateCall(AtExitFunc, CleanupFn);
+
   CtorBuilder.CreateRetVoid();
   return ModuleCtorFunc;
 }


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -404,10 +404,9 @@
   AddGlobalCtor(ObjCInitFunction);
   if (Context.getLangOpts().CUDA && !Context.getLangOpts().CUDAIsDevice &&
   CUDARuntime) {
-if (llvm::Function *CudaCtorFunction = CUDARuntime->makeModuleCtorFunction())
+if (llvm::Function *CudaCtorFunction =
+CUDARuntime->makeModuleCtorFunction())
   AddGlobalCtor(CudaCtorFunction);
-if (llvm::Function *CudaDtorFunction = CUDARuntime->makeModuleDtorFunction())
-  AddGlobalDtor(CudaDtorFunction);
   }
   if (OpenMPRuntime) {
 if (llvm::Function *OpenMPRegistrationFunction =
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -472,6 +472,18 @@
 CtorBuilder.CreateCall(RegisterLinkedBinaryFunc, Args);
   }
 
+  // Create destructor and register it with atexit() the way NVCC does it. Doing
+  // it during regular destructor phase worked in CUDA before 9.2 but results in
+  // double-free in 9.2.
+  llvm::Function *CleanupFn = makeModuleDtorFunction();
+  // extern "C" int atexit(void (*f)(void));
+  llvm::FunctionType *AtExitTy =
+  llvm::FunctionType::get(IntTy, CleanupFn->getType(), false);
+  llvm::Constant *AtExitFunc =
+  CGM.CreateRuntimeFunction(AtExitTy, "atexit", llvm::AttributeList(),
+/*Local=*/true);
+  CtorBuilder.CreateCall(AtExitFunc, CleanupFn);
+
   CtorBuilder.CreateRetVoid();
   return ModuleCtorFunc;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r335672 - [MachineOutliner] Emit a warning when using -moutline on unsupported targets

2018-06-26 Thread Jessica Paquette via cfe-commits
Author: paquette
Date: Tue Jun 26 15:09:48 2018
New Revision: 335672

URL: http://llvm.org/viewvc/llvm-project?rev=335672&view=rev
Log:
[MachineOutliner] Emit a warning when using -moutline on unsupported targets

Instead of just saying "flag unused", we should tell the user that the
outliner isn't (at least officially) supported for some given architecture.

This adds a warning that will state something like

The 'blah' architecture does not support -moutline; flag ignored

when we call -moutline with the 'blah' architecture.

Since the outliner is still mostly an AArch64 thing, any architecture
other than AArch64 will emit this warning.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/aarch64-outliner.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=335672&r1=335671&r2=335672&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Jun 26 15:09:48 
2018
@@ -385,4 +385,8 @@ def warn_drv_experimental_isel_incomplet
 def warn_drv_experimental_isel_incomplete_opt : Warning<
   "-fexperimental-isel support is incomplete for this architecture at the 
current optimization level">,
   InGroup;
+
+def warn_drv_moutline_unsupported_opt : Warning<
+  "The '%0' architecture does not support -moutline; flag ignored">,
+  InGroup;
 }

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=335672&r1=335671&r2=335672&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Jun 26 15:09:48 2018
@@ -1476,19 +1476,6 @@ void Clang::AddAArch64TargetArgs(const A
 else
   CmdArgs.push_back("-aarch64-enable-global-merge=true");
   }
-
-  if (Args.hasFlag(options::OPT_moutline, options::OPT_mno_outline, false)) {
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back("-enable-machine-outliner");
-
-// The outliner shouldn't compete with linkers that dedupe linkonceodr
-// functions in LTO. Enable that behaviour by default when compiling with
-// LTO.
-if (getToolChain().getDriver().isUsingLTO()) {
-  CmdArgs.push_back("-mllvm");
-  CmdArgs.push_back("-enable-linkonceodr-outlining");
-}
-  }
 }
 
 void Clang::AddMIPSTargetArgs(const ArgList &Args,
@@ -4814,6 +4801,26 @@ void Clang::ConstructJob(Compilation &C,
options::OPT_fno_complete_member_pointers, false))
 CmdArgs.push_back("-fcomplete-member-pointers");
 
+  if (Args.hasFlag(options::OPT_moutline, options::OPT_mno_outline, false)) {
+// We only support -moutline in AArch64 right now. If we're not compiling
+// for AArch64, emit a warning and ignore the flag. Otherwise, add the
+// proper mllvm flags.
+if (Triple.getArch() != llvm::Triple::aarch64) {
+  D.Diag(diag::warn_drv_moutline_unsupported_opt) << Triple.getArchName();
+} else {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-enable-machine-outliner");
+
+  // The outliner shouldn't compete with linkers that dedupe linkonceodr
+  // functions in LTO. Enable that behaviour by default when compiling with
+  // LTO.
+  if (getToolChain().getDriver().isUsingLTO()) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-enable-linkonceodr-outlining");
+  }
+}
+  }
+
   // Finally add the compile command to the compilation.
   if (Args.hasArg(options::OPT__SLASH_fallback) &&
   Output.getType() == types::TY_Object &&

Modified: cfe/trunk/test/Driver/aarch64-outliner.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-outliner.c?rev=335672&r1=335671&r2=335672&view=diff
==
--- cfe/trunk/test/Driver/aarch64-outliner.c (original)
+++ cfe/trunk/test/Driver/aarch64-outliner.c Tue Jun 26 15:09:48 2018
@@ -7,3 +7,6 @@
 // FLTO: "-mllvm" "-enable-linkonceodr-outlining"
 // RUN: %clang -target aarch64 -moutline -flto=full -S %s -### 2>&1 | 
FileCheck %s -check-prefix=TLTO
 // TLTO: "-mllvm" "-enable-linkonceodr-outlining"
+// RUN: %clang -target x86_64 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=WARN
+// WARN: warning: The 'x86_64' architecture does not support -moutline; flag 
ignored [-Woption-ignored]
+// WARN-NOT: "-mllvm" "-enable-machine-outliner"


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


[PATCH] D48615: [CUDA] Place all CUDA sections in __NV_CUDA segment on Mac.

2018-06-26 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added a reviewer: Hahnfeld.
Herald added subscribers: bixia, jlebar, sanjoy.

That's where CUDA SDK binaries appear to put them on Mac.


https://reviews.llvm.org/D48615

Files:
  clang/lib/CodeGen/CGCUDANV.cpp


Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -389,17 +389,19 @@
 FatMagic = HIPFatMagic;
   } else {
 if (RelocatableDeviceCode)
-  // TODO: Figure out how this is called on mac OS!
-  FatbinConstantName = "__nv_relfatbin";
+  FatbinConstantName = CGM.getTriple().isMacOSX()
+   ? "__NV_CUDA,__nv_relfatbin"
+   : "__nv_relfatbin";
 else
   FatbinConstantName =
   CGM.getTriple().isMacOSX() ? "__NV_CUDA,__nv_fatbin" : ".nv_fatbin";
 // NVIDIA's cuobjdump looks for fatbins in this section.
 FatbinSectionName =
 CGM.getTriple().isMacOSX() ? "__NV_CUDA,__fatbin" : ".nvFatBinSegment";
 
-// TODO: Figure out how this is called on mac OS!
-ModuleIDSectionName = "__nv_module_id";
+ModuleIDSectionName = CGM.getTriple().isMacOSX()
+  ? "__NV_CUDA,__nv_module_id"
+  : "__nv_module_id";
 ModuleIDPrefix = "__nv_";
 
 // For CUDA, create a string literal containing the fat binary loaded from


Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -389,17 +389,19 @@
 FatMagic = HIPFatMagic;
   } else {
 if (RelocatableDeviceCode)
-  // TODO: Figure out how this is called on mac OS!
-  FatbinConstantName = "__nv_relfatbin";
+  FatbinConstantName = CGM.getTriple().isMacOSX()
+   ? "__NV_CUDA,__nv_relfatbin"
+   : "__nv_relfatbin";
 else
   FatbinConstantName =
   CGM.getTriple().isMacOSX() ? "__NV_CUDA,__nv_fatbin" : ".nv_fatbin";
 // NVIDIA's cuobjdump looks for fatbins in this section.
 FatbinSectionName =
 CGM.getTriple().isMacOSX() ? "__NV_CUDA,__fatbin" : ".nvFatBinSegment";
 
-// TODO: Figure out how this is called on mac OS!
-ModuleIDSectionName = "__nv_module_id";
+ModuleIDSectionName = CGM.getTriple().isMacOSX()
+  ? "__NV_CUDA,__nv_module_id"
+  : "__nv_module_id";
 ModuleIDPrefix = "__nv_";
 
 // For CUDA, create a string literal containing the fat binary loaded from
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48616: Implement LWG 2946, 3075 and 3076

2018-06-26 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added reviewers: EricWF, ldionne, STL_MSFT.

A massive amount of doinking around in .

  https://cplusplus.github.io/LWG/issue2946
  https://cplusplus.github.io/LWG/issue3075
  https://cplusplus.github.io/LWG/issue3076

This is not quite right yet, but I wanted to get it up here for people to look 
at.

I may have stepped on a bug fix for old versions of gcc in C++03 mode - Eric? [ 
was introduced in r292830 ]
Stephan - I updated your deduction guide tests now that we implement all of 
them.


https://reviews.llvm.org/D48616

Files:
  include/memory
  include/string
  test/std/strings/basic.string/string.cons/default_noexcept.pass.cpp
  test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp
  test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
  test/std/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp
  test/std/strings/basic.string/string.cons/move_noexcept.pass.cpp
  test/std/strings/basic.string/string.cons/string_view_deduction.fail.cpp
  test/std/strings/basic.string/string.cons/string_view_deduction.pass.cpp
  
test/std/strings/basic.string/string.cons/string_view_size_size_deduction.fail.cpp
  
test/std/strings/basic.string/string.cons/string_view_size_size_deduction.pass.cpp
  
test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp

Index: test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp
===
--- test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp
+++ test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp
@@ -35,8 +35,8 @@
 
 some_alloc() {}
 some_alloc(const some_alloc&);
+	T *allocate(size_t);
 void deallocate(void*, unsigned) {}
-
 typedef std::true_type propagate_on_container_swap;
 };
 
@@ -47,6 +47,7 @@
 
 some_alloc2() {}
 some_alloc2(const some_alloc2&);
+	T *allocate(size_t);
 void deallocate(void*, unsigned) {}
 
 typedef std::false_type propagate_on_container_swap;
Index: test/std/strings/basic.string/string.cons/string_view_size_size_deduction.pass.cpp
===
--- test/std/strings/basic.string/string.cons/string_view_size_size_deduction.pass.cpp
+++ test/std/strings/basic.string/string.cons/string_view_size_size_deduction.pass.cpp
@@ -0,0 +1,98 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// XFAIL: libcpp-no-deduction-guides
+
+// template
+//   basic_string(InputIterator begin, InputIterator end,
+//   const Allocator& a = Allocator());
+
+// template
+//  >
+// basic_string(basic_string_view,
+//typename see below::size_type,
+//typename see below::size_type,
+//const Allocator& = Allocator())
+//   -> basic_string;
+//
+//	A size_type parameter type in a basic_string deduction guide refers to the size_type 
+//	member type of the type deduced by the deduction guide.
+//
+//  The deduction guide shall not participate in overload resolution if Allocator is
+//  is a type that does not qualify as an allocator.
+
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+#include "test_allocator.h"
+#include "../input_iterator.h"
+#include "min_allocator.h"
+
+int main()
+{
+{
+std::string_view sv = "12345678901234";
+std::basic_string s1{sv, 0, 4};
+using S = decltype(s1); // what type did we get?
+static_assert(std::is_same_v,  "");
+static_assert(std::is_same_v>, "");
+static_assert(std::is_same_v>, "");
+assert(s1.size() == 4);
+assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
+}
+
+{
+std::string_view sv = "12345678901234";
+std::basic_string s1{sv, 0, 4, std::allocator{}};
+using S = decltype(s1); // what type did we get?
+static_assert(std::is_same_v,  "");
+static_assert(std::is_same_v>, "");
+static_assert(std::is_same_v>, "");
+assert(s1.size() == 4);
+assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
+}
+{
+std::wstring_view sv = L"12345678901234";
+std::basic_string s1{sv, 0, 4, test_allocator{}};
+using S = decltype(s1); // what type did we get?
+static_assert(std::is_same_v,  "");
+static_assert(std::is_same_v>, "");
+static_assert(std::is_same_v>, "");
+assert(s1.size() == 4);
+assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
+}
+{
+std::u16string_view sv = u"12345678901234";
+std::basic_string

[PATCH] D48616: Implement LWG 2946, 3075 and 3076

2018-06-26 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

Ok, for some reason, the four tests that I *added* didn't get into the diff.


https://reviews.llvm.org/D48616



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


  1   2   >