[PATCH] D42995: [ThinLTO] Ignore object files with empty ThinLTO index

2018-02-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In https://reviews.llvm.org/D42995#125, @tejohnson wrote:

> > Empty ThinLTOIndexFile signals that we don't need this module during
> >  linking.
>
> Not the only case actually. We now also pass an empty index file when we want 
> to compile the bitcode down to object without applying any LTO optimization 
> (there are a few cases where we decide we want to turn off LTO optimizations 
> for some links), and this is currently relying on being able to pass 
> /dev/null for the index file that would be broken by this change.


I'd expect this should be done by indexing and content is already in the merged 
object file.
Not sure how to reproduce this. I've build some large targets and I never seen 
this.

> 
> 
>> So we should not run ThinLTO backend even if it contains the
>>  ThinLTO module. Backend may fail because of lack of necessary
>>  information which should be provided by ThinLTOIndex.
> 
> This shouldn't happen - are you seeing cases where we fail? After 
> loadModule() is called, EmitBackendOutput() is called which passes 
> /*IgnoreEmptyThinLTOIndexFile*/true to  getModuleSummaryIndexForFile, which 
> would cause it to return nullptr if the index file is empty.  Back in 
> EmitBackendOutput(), if the combined index is null we will skip ThinLTO 
> compilation and fall back to normal compilation.

I don't see for regular compilation, but I see for  for CFI. Backend will not 
be able to process llvm.type.test without TypeIdMap from index and it will 
crash in "Instruction Select"


https://reviews.llvm.org/D42995



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


[PATCH] D41537: Optionally add code completion results for arrow instead of dot

2018-02-07 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

ping...


https://reviews.llvm.org/D41537



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


[PATCH] D42978: Make march/target-cpu print a note with the list of valid values

2018-02-07 Thread Sam Parker via Phabricator via cfe-commits
samparker added a comment.

No tests?


Repository:
  rC Clang

https://reviews.llvm.org/D42978



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


[PATCH] D42645: New simple Checker for mmap calls

2018-02-07 Thread David CARLIER via Phabricator via cfe-commits
devnexen updated this revision to Diff 133164.

Repository:
  rC Clang

https://reviews.llvm.org/D42645

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
  test/Analysis/mmap-writeexec.c

Index: test/Analysis/mmap-writeexec.c
===
--- test/Analysis/mmap-writeexec.c
+++ test/Analysis/mmap-writeexec.c
@@ -0,0 +1,35 @@
+// RUN: %clang_analyze_cc1 -triple i686-unknown-linux -analyzer-checker=security.MmapWriteExec -analyzer-config security.MmapWriteExec:MmapProtExec=1 -DPROT_EXEC=1 -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-apple-darwin10 -analyzer-checker=security.MmapWriteExec -verify %s
+
+#define PROT_WRITE  0x02
+#ifndef PROT_EXEC
+#define PROT_EXEC   0x04
+#define PROT_READ   0x01
+#else
+#define PROT_READ   0x04
+#endif
+#define MAP_PRIVATE 0x0002
+#define MAP_ANON0x1000
+#define MAP_FIXED   0x0010
+#define NULL((void *)0)
+
+typedef __typeof(sizeof(int)) size_t;
+void *mmap(void *, size_t, int, int, int, long);
+
+void f1()
+{
+  void *a = mmap(NULL, 16, PROT_READ | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); // no-warning
+  void *b = mmap(a, 16, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED | MAP_ANON, -1, 0); // no-warning
+  void *c = mmap(NULL, 32, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); // expected-warning{{Both PROT_WRITE and PROT_EXEC flags are set. This can lead to exploitable memory regions, which could be overwritten with malicious code}}
+  (void)a;
+  (void)b;
+  (void)c;
+}
+
+void f2()
+{
+  void *(*callm)(void *, size_t, int, int, int, long);
+  callm = mmap;
+  int prot = PROT_WRITE | PROT_EXEC;
+  (void)callm(NULL, 1024, prot, MAP_PRIVATE | MAP_ANON, -1, 0); // expected-warning{{Both PROT_WRITE and PROT_EXEC flags are set. This can lead to exploitable memory regions, which could be overwritten with malicious code}}
+}
Index: lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
@@ -0,0 +1,76 @@
+// MmapWriteExecChecker.cpp - Check for the prot argument -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This checker tests the 3rd argument of mmap's calls to check if
+// it is writable and executable in the same time. It's somehow
+// an optional checker since for example in JIT libraries it is pretty common.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+using llvm::APSInt;
+
+namespace {
+class MmapWriteExecChecker : public Checker {
+  CallDescription MmapFn;
+  static int ProtWrite;
+  static int ProtExec;
+  mutable std::unique_ptr BT;
+public:
+  MmapWriteExecChecker() : MmapFn("mmap", 6) {}
+  void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
+  int ProtExecOv;
+};
+}
+
+int MmapWriteExecChecker::ProtWrite = 0x02;
+int MmapWriteExecChecker::ProtExec  = 0x04;
+
+void MmapWriteExecChecker::checkPreCall(const CallEvent &Call,
+ CheckerContext &C) const {
+  if (Call.isCalled(MmapFn)) {
+SVal ProtVal = Call.getArgSVal(2); 
+Optional ProtLoc = ProtVal.getAs();
+int64_t Prot = ProtLoc->getValue().getSExtValue();
+if (ProtExecOv != ProtExec)
+  ProtExec = ProtExecOv;
+
+if ((Prot & (ProtWrite | ProtExec)) == (ProtWrite | ProtExec)) {
+  if (!BT)
+BT.reset(new BugType(this, "W^X check fails, Write Exec prot flags set", "Security"));
+
+  ExplodedNode *N = C.generateNonFatalErrorNode();
+  if (!N)
+return;
+
+  auto Report = llvm::make_unique(
+  *BT, "Both PROT_WRITE and PROT_EXEC flags are set. This can "
+   "lead to exploitable memory regions, which could be overwritten "
+   "with malicious code", N);
+  Report->addRange(Call.getArgSourceRange(2));
+  C.emitReport(std::move(Report));
+}
+  }
+}
+
+void ento::registerMmapWriteExecChecker(CheckerManager &mgr) {
+  MmapWriteExecChecker *Mwec =
+  mgr.registerChecker();
+  Mwec->ProtExecOv =
+mgr.getAnalyzerOptions().getOptionAsInteger("MmapProtExec", 0x04, Mwec);
+}
Index: lib/StaticAnalyzer/Checkers/CMakeLists.txt

Re: r324439 - AST: support SwiftCC on MS ABI

2018-02-07 Thread Hans Wennborg via cfe-commits
On Wed, Feb 7, 2018 at 8:01 AM, Saleem Abdulrasool via cfe-commits
 wrote:
> On Tue, Feb 6, 2018 at 5:55 PM, Saleem Abdulrasool via cfe-commits
>  wrote:
>>
>> Author: compnerd
>> Date: Tue Feb  6 17:55:08 2018
>> New Revision: 324439
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=324439&view=rev
>> Log:
>> AST: support SwiftCC on MS ABI
>>
>> Microsoft has reserved the identifier 'S' as the swift calling
>> convention.  Decorate the symbols appropriately.  This enables swift on
>> Windows.
>
>
> Hans, thoughts on getting this into 6.0?  This is needed to enable swift on
> Windows.

Sure, why not. r324460.

>
>>
>> Added:
>> cfe/trunk/test/CodeGenCXX/msabi-swiftcall-cc.cpp
>> Modified:
>> cfe/trunk/lib/AST/MicrosoftMangle.cpp
>>
>> Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=324439&r1=324438&r2=324439&view=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
>> +++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Feb  6 17:55:08 2018
>> @@ -950,11 +950,10 @@ void MicrosoftCXXNameMangler::mangleUnqu
>>}
>>  }
>>
>> +//  ::=  []
>> +//   ::=  []
>>  void MicrosoftCXXNameMangler::mangleNestedName(const NamedDecl *ND) {
>> -  //  ::=  []
>> -  //   ::=  []
>>const DeclContext *DC = getEffectiveDeclContext(ND);
>> -
>>while (!DC->isTranslationUnit()) {
>>  if (isa(ND) || isa(ND)) {
>>unsigned Disc;
>> @@ -2136,6 +2135,7 @@ void MicrosoftCXXNameMangler::mangleCall
>>  case CC_X86StdCall: Out << 'G'; break;
>>  case CC_X86FastCall: Out << 'I'; break;
>>  case CC_X86VectorCall: Out << 'Q'; break;
>> +case CC_Swift: Out << 'S'; break;
>>  case CC_X86RegCall: Out << 'w'; break;
>>}
>>  }
>>
>> Added: cfe/trunk/test/CodeGenCXX/msabi-swiftcall-cc.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/msabi-swiftcall-cc.cpp?rev=324439&view=auto
>>
>> ==
>> --- cfe/trunk/test/CodeGenCXX/msabi-swiftcall-cc.cpp (added)
>> +++ cfe/trunk/test/CodeGenCXX/msabi-swiftcall-cc.cpp Tue Feb  6 17:55:08
>> 2018
>> @@ -0,0 +1,28 @@
>> +// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fdeclspec
>> -emit-llvm %s -o - | FileCheck %s
>> +
>> +void __attribute__((__swiftcall__)) f() {}
>> +// CHECK-DAG: @"\01?f@@YSXXZ"
>> +
>> +void (__attribute__((__swiftcall__)) *p)();
>> +// CHECK-DAG: @"\01?p@@3P6SXXZA"
>> +
>> +namespace {
>> +void __attribute__((__swiftcall__)) __attribute__((__used__)) f() { }
>> +// CHECK-DAG: "\01?f@?A@@YSXXZ"
>> +}
>> +
>> +namespace n {
>> +void __attribute__((__swiftcall__)) f() {}
>> +// CHECK-DAG: "\01?f@n@@YSXXZ"
>> +}
>> +
>> +struct __declspec(dllexport) S {
>> +  S(const S &) = delete;
>> +  S & operator=(const S &) = delete;
>> +  void __attribute__((__swiftcall__)) m() { }
>> +  // CHECK-DAG: "\01?m@S@@QASXXZ"
>> +};
>> +
>> +void f(void (__attribute__((__swiftcall__))())) {}
>> +// CHECK-DAG: "\01?f@@YAXP6SXXZ@Z"
>> +
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
>
> --
> Saleem Abdulrasool
> compnerd (at) compnerd (dot) org
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42645: New simple Checker for mmap calls

2018-02-07 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

None of the possible solutions are ideal, but I think I chose the least complex 
(e.g. via analyzer-config), less edgy one, and 4 is the most common value I ve 
found so far for PROT_EXEC.


Repository:
  rC Clang

https://reviews.llvm.org/D42645



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


[PATCH] D42995: [ThinLTO] Ignore object files with empty ThinLTO index

2018-02-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In https://reviews.llvm.org/D42995#1000155, @vitalybuka wrote:

> In https://reviews.llvm.org/D42995#125, @tejohnson wrote:
>
> > > Empty ThinLTOIndexFile signals that we don't need this module during
> > >  linking.
> >
> > Not the only case actually. We now also pass an empty index file when we 
> > want to compile the bitcode down to object without applying any LTO 
> > optimization (there are a few cases where we decide we want to turn off LTO 
> > optimizations for some links), and this is currently relying on being able 
> > to pass /dev/null for the index file that would be broken by this change.
>
>
> I'd expect this should be done by indexing and content is already in the 
> merged object file.
>  Not sure how to reproduce this. I've build some large targets and I never 
> seen this.


At least with gold I don't see how this possible. I see that thinlto.bc can be 
empty only
if getSymbolsAndView returns nullptr or if LTOInfo for input object was false.
Former means that we don't need this object and so I created this patch.
For latter we already going to do the same anyway: 
https://reviews.llvm.org/D42680


https://reviews.llvm.org/D42995



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


[PATCH] D42942: [clangd] Collect definitions when indexing.

2018-02-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp:67
+  // XXX this is just to make running the tool fast during dev!
+  bool BeginInvocation(CompilerInstance &CI) override {
+const auto &Inputs = CI.getInvocation().getFrontendOpts().Inputs;

ioeric wrote:
> sammccall wrote:
> > hokein wrote:
> > > It is fine for debugging, but I think we don't want this behavior by 
> > > default.
> > > 
> > > global-symbol-builder also supports running a single TU 
> > > (`global-symbol-builder /path/to/file`), which is sufficient for 
> > > debugging, I think?
> > > 
> > Yeah, I'm not going to check this in, thus the XXX comment :-)
> > 
> > Single TU isn't enough - it doesn't test the reducer. On the other hand the 
> > full compilation database is too big. So this option would actually be 
> > useful! But it doesn't belong here.
> Drive-by: you could also run the tool in the default standalone mode and 
> provide a list of files. 
However the default standalone mode is not multiple thread :(.



Comment at: clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp:159
+  // Output phase: emit YAML for result symbols.
   for (const auto &Sym : UniqueSymbols)
+llvm::outs() << SymbolToYAML(Sym);

nit: we could get rid of the loop by using `SymbolsToYAML(UniqueSymbols)` .



Comment at: clangd/index/SymbolCollector.cpp:137
+// FIXME: EndOffset is inclusive (closed range), and should be exclusive.
+// FIXME: Because the underlying ranges are token ranges, this code chops the
+//last token in half if it contains multiple characters.

That's bad, thanks for finding it.



Comment at: clangd/index/SymbolCollector.cpp:210
+  BasicSymbol = addDeclaration(*ND, std::move(ID));
+if (Roles & static_cast(index::SymbolRole::Definition))
+  addDefinition(*cast(ASTNode.OrigD), *BasicSymbol);

ioeric wrote:
> It seems that we store definition even if it's the same as declaration, which 
> might be true for most classes? This is probably fine, but it would be worth 
> documenting. Or maybe consider not storing the same location twice?
I think it is fine to store the same location twice. We can't tell whether the 
CanonicalLoc is a definition or not.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42942



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


[PATCH] D43009: [clangd] Do not precent-encode numbers in URI.

2018-02-07 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, jkorous-apple, klimek.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43009

Files:
  clangd/URI.cpp
  unittests/clangd/URITests.cpp


Index: unittests/clangd/URITests.cpp
===
--- unittests/clangd/URITests.cpp
+++ unittests/clangd/URITests.cpp
@@ -72,6 +72,7 @@
 TEST(PercentEncodingTest, Encode) {
   EXPECT_EQ(URI("x", /*Authority=*/"", "a/b/c").toString(), "x:a/b/c");
   EXPECT_EQ(URI("x", /*Authority=*/"", "a!b;c~").toString(), "x:a%21b%3bc~");
+  EXPECT_EQ(URI("x", /*Authority=*/"", "a123b").toString(), "x:a123b");
 }
 
 TEST(PercentEncodingTest, Decode) {
Index: clangd/URI.cpp
===
--- clangd/URI.cpp
+++ clangd/URI.cpp
@@ -79,7 +79,8 @@
 
 bool shouldEscape(unsigned char C) {
   // Unreserved characters.
-  if ((C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z'))
+  if ((C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') ||
+  (C >= '0' && C <= '9'))
 return false;
   switch (C) {
   case '-':


Index: unittests/clangd/URITests.cpp
===
--- unittests/clangd/URITests.cpp
+++ unittests/clangd/URITests.cpp
@@ -72,6 +72,7 @@
 TEST(PercentEncodingTest, Encode) {
   EXPECT_EQ(URI("x", /*Authority=*/"", "a/b/c").toString(), "x:a/b/c");
   EXPECT_EQ(URI("x", /*Authority=*/"", "a!b;c~").toString(), "x:a%21b%3bc~");
+  EXPECT_EQ(URI("x", /*Authority=*/"", "a123b").toString(), "x:a123b");
 }
 
 TEST(PercentEncodingTest, Decode) {
Index: clangd/URI.cpp
===
--- clangd/URI.cpp
+++ clangd/URI.cpp
@@ -79,7 +79,8 @@
 
 bool shouldEscape(unsigned char C) {
   // Unreserved characters.
-  if ((C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z'))
+  if ((C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') ||
+  (C >= '0' && C <= '9'))
 return false;
   switch (C) {
   case '-':
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42493: [clang-format] Fix ObjC message arguments formatting.

2018-02-07 Thread Jacek Olesiak via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324469: [clang-format] Fix ObjC message arguments 
formatting. (authored by jolesiak, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D42493

Files:
  cfe/trunk/lib/Format/ContinuationIndenter.cpp
  cfe/trunk/lib/Format/FormatToken.h
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTestObjC.cpp

Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -411,6 +411,8 @@
 if (Contexts.back().FirstObjCSelectorName) {
   Contexts.back().FirstObjCSelectorName->LongestObjCSelectorName =
   Contexts.back().LongestObjCSelectorName;
+  Contexts.back().FirstObjCSelectorName->ObjCSelectorNameParts =
+  Left->ParameterCount;
   if (Left->BlockParameterCount > 1)
 Contexts.back().FirstObjCSelectorName->LongestObjCSelectorName = 0;
 }
@@ -424,6 +426,11 @@
   TT_DesignatedInitializerLSquare)) {
   Left->Type = TT_ObjCMethodExpr;
   StartsObjCMethodExpr = true;
+  // ParameterCount might have been set to 1 before expression was
+  // recognized as ObjCMethodExpr (as '1 + number of commas' formula is
+  // used for other expression types). Parameter counter has to be,
+  // therefore, reset to 0.
+  Left->ParameterCount = 0;
   Contexts.back().ColonIsObjCMethodExpr = true;
   if (Parent && Parent->is(tok::r_paren))
 Parent->Type = TT_CastRParen;
@@ -498,7 +505,10 @@
   void updateParameterCount(FormatToken *Left, FormatToken *Current) {
 if (Current->is(tok::l_brace) && Current->BlockKind == BK_Block)
   ++Left->BlockParameterCount;
-if (Current->is(tok::comma)) {
+if (Left->Type == TT_ObjCMethodExpr) {
+  if (Current->is(tok::colon))
+++Left->ParameterCount;
+} else if (Current->is(tok::comma)) {
   ++Left->ParameterCount;
   if (!Left->Role)
 Left->Role.reset(new CommaSeparatedList(Style));
Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -266,6 +266,11 @@
 return true;
   if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection)
 return true;
+  if (Style.Language == FormatStyle::LK_ObjC &&
+  Current.ObjCSelectorNameParts > 1 &&
+  Current.startsSequence(TT_SelectorName, tok::colon, tok::caret)) {
+return true;
+  }
   if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) ||
(Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) &&
 Style.isCpp() &&
Index: cfe/trunk/lib/Format/FormatToken.h
===
--- cfe/trunk/lib/Format/FormatToken.h
+++ cfe/trunk/lib/Format/FormatToken.h
@@ -240,6 +240,10 @@
   /// e.g. because several of them are block-type.
   unsigned LongestObjCSelectorName = 0;
 
+  /// \brief How many parts ObjC selector have (i.e. how many parameters method
+  /// has).
+  unsigned ObjCSelectorNameParts = 0;
+
   /// \brief Stores the number of required fake parentheses and the
   /// corresponding operator precedence.
   ///
Index: cfe/trunk/unittests/Format/FormatTestObjC.cpp
===
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp
@@ -693,6 +693,39 @@
"ofSize:aa:bbb\n"
"  atOrigin:cc:dd];");
 
+  // Inline block as a first argument.
+  verifyFormat("[object justBlock:^{\n"
+   "  a = 42;\n"
+   "}];");
+  verifyFormat("[object\n"
+   "justBlock:^{\n"
+   "  a = 42;\n"
+   "}\n"
+   " notBlock:42\n"
+   "a:42];");
+  verifyFormat("[object\n"
+   "firstBlock:^{\n"
+   "  a = 42;\n"
+   "}\n"
+   "blockWithLongerName:^{\n"
+   "  a = 42;\n"
+   "}];");
+  verifyFormat("[object\n"
+   "blockWithLongerName:^{\n"
+   "  a = 42;\n"
+   "}\n"
+   "secondBlock:^{\n"
+   "  a = 42;\n"
+   "}];");
+  verifyFormat("[object\n"
+   "firstBlock:^{\n"
+   "  a = 42;\n"
+   "}\n"
+   "notBlock:42\n"
+   "secondBlock:^{\n"
+   "  a = 42;\n"
+   "}];");
+
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() 

[PATCH] D42895: [libclang] Add `CXSymbolRole role` to CXIdxEntityRefInfo

2018-02-07 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added reviewers: ilya-biryukov, bkramer, arphaman.
yvvan added a comment.

Looks ok-ish, I haven't built it though.
Also I don't have much exp with indexing part of libclang. Adding more 
reviewers.


Repository:
  rC Clang

https://reviews.llvm.org/D42895



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


[PATCH] D43012: [ASTImporter] Fix lexical DC for templated decls; support VarTemplatePartialSpecDecl

2018-02-07 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin created this revision.
a.sidorin added reviewers: xazax.hun, szepet, jingham.
Herald added a subscriber: rnkovacs.

Also minor refactoring in related functions was done.


Repository:
  rC Clang

https://reviews.llvm.org/D43012

Files:
  lib/AST/ASTImporter.cpp
  test/ASTMerge/var-cpp/Inputs/var1.cpp
  test/ASTMerge/var-cpp/test.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -542,20 +542,32 @@
 
 TEST(ImportType, ImportTypeAliasTemplate) {
   MatchVerifier Verifier;
-  testImport("template "
- "struct dummy { static const int i = K; };"
- "template  using dummy2 = dummy;"
- "int declToImport() { return dummy2<3>::i; }",
- Lang_CXX11, "", Lang_CXX11, Verifier,
- functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- returnStmt(
-   has(
- implicitCastExpr(
-   has(
- declRefExpr());
+  testImport(
+  "template "
+  "struct dummy { static const int i = K; };"
+  "template  using dummy2 = dummy;"
+  "int declToImport() { return dummy2<3>::i; }",
+  Lang_CXX11, "", Lang_CXX11, Verifier,
+  functionDecl(
+  hasBody(compoundStmt(
+  has(returnStmt(has(implicitCastExpr(has(declRefExpr(,
+  unless(hasAncestor(translationUnitDecl(has(typeAliasDecl()));
+}
+
+const internal::VariadicDynCastAllOfMatcher
+varTemplateSpecializationDecl;
+
+TEST(ImportDecl, ImportVarTemplate) {
+  MatchVerifier Verifier;
+  testImport(
+  "template "
+  "T pi = T(3.1415926535897932385L);"
+  "void declToImport() { pi; }",
+  Lang_CXX11, "", Lang_CXX11, Verifier,
+  functionDecl(
+  hasBody(has(declRefExpr(to(varTemplateSpecializationDecl(),
+  unless(hasAncestor(translationUnitDecl(has(varDecl(
+  hasName("pi"), unless(varTemplateSpecializationDecl();
 }
 
 TEST(ImportType, ImportPackExpansion) {
Index: test/ASTMerge/var-cpp/test.cpp
===
--- /dev/null
+++ test/ASTMerge/var-cpp/test.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -std=c++17 -o %t.1.ast %S/Inputs/var1.cpp
+// RUN: %clang_cc1 -std=c++17 -ast-merge %t.1.ast -fsyntax-only %s 2>&1
+
+static_assert(my_pi == (double)3.1415926535897932385L);
+static_assert(my_pi == '3');
+
+static_assert(Wrapper::my_const == 1.f);
+static_assert(Wrapper::my_const == nullptr);
+static_assert(Wrapper::my_const == a);
Index: test/ASTMerge/var-cpp/Inputs/var1.cpp
===
--- /dev/null
+++ test/ASTMerge/var-cpp/Inputs/var1.cpp
@@ -0,0 +1,17 @@
+
+template 
+constexpr T my_pi = T(3.1415926535897932385L);  // variable template
+
+template <> constexpr char my_pi = '3';   // variable template specialization
+
+template 
+struct Wrapper {
+  template  static constexpr U my_const = U(1);
+   // Variable template partial specialization with member variable.
+  template  static constexpr U *my_const = (U *)(0);
+};
+
+constexpr char a[] = "hello";
+
+template <> template <>
+constexpr const char *Wrapper::my_const = a;
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -23,7 +23,6 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/Support/MemoryBuffer.h"
-#include 
 
 namespace clang {
   class ASTNodeImporter : public TypeVisitor,
@@ -1335,6 +1334,21 @@
   return false;
 }
 
+template <>
+bool ASTNodeImporter::ImportTemplateArgumentListInfo(
+const TemplateArgumentListInfo &From, TemplateArgumentListInfo &Result) {
+  return ImportTemplateArgumentListInfo(
+  From.getLAngleLoc(), From.getRAngleLoc(), From.arguments(), Result);
+}
+
+template <>
+bool ASTNodeImporter::ImportTemplateArgumentListInfo<
+ASTTemplateArgumentListInfo>(const ASTTemplateArgumentListInfo &From,
+ TemplateArgumentListInfo &Result) {
+  return ImportTemplateArgumentListInfo(From.LAngleLoc, From.RAngleLoc,
+From.arguments(), Result);
+}
+
 bool ASTNodeImporter::IsStructuralMatch(RecordDecl *FromRecord, 
 RecordDecl *ToRecord, bool Complain) {
   // Eliminate a potential failure point where we attempt to re-import
@@ -1655,10 +1669,8 @@
   SourceLocation StartL = Importer.Import(D->getLocStart());
   TypedefNameDecl *ToTypedef;
   if (IsAlias)
-ToTypedef = TypeAliasDecl::Create(Importer.getToContext(), DC,
-  StartL, Loc,
-  Name.

[PATCH] D5767: Template Instantiation Observer + a few other templight-related changes

2018-02-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D5767#999143, @sabel83 wrote:

> 2. What do you mean by regression tests? We have run the clang-test target 
> successfully on the patched code (which has the hook). Note that the hook 
> this pull request provides is implemented as a ProgramAction. It is not 
> intended to be used together with other program actions, I don't see how we 
> could turn it on for other tests (if that is what you referred to).


I would bet the sema tests are full of tricky edge cases. So running templight 
on those tests would be a helpful exercise. I am only interested in assertion 
fails, so we do not need to check the output.  One option to do so would be to 
add the -templight-dump option to the %clang_cc1 variable when running the 
tests. Note that the tests are likely to fail because the output will change, 
but if there are no crashes, it is fine.


https://reviews.llvm.org/D5767



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


[PATCH] D43013: ASan+operator new[]: Fix operator new[] cookie poisoning

2018-02-07 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab created this revision.
filcab added reviewers: rjmccall, kcc, rsmith.

The C++ Itanium ABI says:
No cookie is required if the new operator being used is ::operator 
new[](size_t, void*).

This commit adds a flag to tell clang to poison all operator new[]
cookies.

A previous review was poisoning unconditionally, but there is an edge
case which would stop working under ASan (a custom operator new[] saves
whatever pointer it returned, and then accesses it).

This newer revision adds a command line argument to toggle this feature.

Original revision: https://reviews.llvm.org/D41301
Compiler-rt test revision with an explanation of the edge case: 
https://reviews.llvm.org/D41664


Repository:
  rC Clang

https://reviews.llvm.org/D43013

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/address-sanitizer-and-array-cookie.cpp


Index: test/CodeGen/address-sanitizer-and-array-cookie.cpp
===
--- test/CodeGen/address-sanitizer-and-array-cookie.cpp
+++ test/CodeGen/address-sanitizer-and-array-cookie.cpp
@@ -1,13 +1,15 @@
 // RUN: %clang_cc1 -triple x86_64-gnu-linux -emit-llvm -o - %s | FileCheck %s 
-check-prefix=PLAIN
 // RUN: %clang_cc1 -triple x86_64-gnu-linux -emit-llvm -o - -fsanitize=address 
%s | FileCheck %s -check-prefix=ASAN
+// RUN: %clang_cc1 -triple x86_64-gnu-linux -emit-llvm -o - -fsanitize=address 
-fsanitize-address-poison-class-member-array-new-cookie %s | FileCheck %s 
-check-prefix=ASAN-POISON-ALL-NEW-ARRAY
 
 typedef __typeof__(sizeof(0)) size_t;
 namespace std {
   struct nothrow_t {};
   std::nothrow_t nothrow;
 }
 void *operator new[](size_t, const std::nothrow_t &) throw();
 void *operator new[](size_t, char *);
+void *operator new[](size_t, int, int);
 
 struct C {
   int x;
@@ -53,3 +55,10 @@
 }
 // ASAN-LABEL: CallPlacementNew
 // ASAN-NOT: __asan_poison_cxx_array_cookie
+
+C *CallNewWithArgs() {
+// ASAN-LABEL: CallNewWithArgs
+// ASAN-NOT: call void @__asan_poison_cxx_array_cookie
+// ASAN-POISON-ALL-NEW-ARRAY: call void @__asan_poison_cxx_array_cookie
+  return new (123, 456) C[20];
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -890,6 +890,13 @@
   Opts.SanitizeCfiICallGeneralizePointers =
   Args.hasArg(OPT_fsanitize_cfi_icall_generalize_pointers);
   Opts.SanitizeStats = Args.hasArg(OPT_fsanitize_stats);
+  if (Arg *A = Args.getLastArg(
+  OPT_fsanitize_address_poison_class_member_array_new_cookie,
+  OPT_fno_sanitize_address_poison_class_member_array_new_cookie)) {
+Opts.SanitizeAddressPoisonClassMemberArrayNewCookie =
+A->getOption().getID() ==
+OPT_fsanitize_address_poison_class_member_array_new_cookie;
+  }
   if (Arg *A = Args.getLastArg(OPT_fsanitize_address_use_after_scope,
OPT_fno_sanitize_address_use_after_scope)) {
 Opts.SanitizeAddressUseAfterScope =
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -1848,7 +1848,8 @@
 
   // Handle the array cookie specially in ASan.
   if (CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) && AS == 0 &&
-  expr->getOperatorNew()->isReplaceableGlobalAllocationFunction()) {
+  (expr->getOperatorNew()->isReplaceableGlobalAllocationFunction() ||
+   CGM.getCodeGenOpts().SanitizeAddressPoisonClassMemberArrayNewCookie)) {
 // The store to the CookiePtr does not need to be instrumented.
 CGM.getSanitizerMetadata()->disableSanitizerForInstruction(SI);
 llvm::FunctionType *FTy =
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -159,6 +159,9 @@
 CODEGENOPT(SaveTempLabels, 1, 0) ///< Save temporary labels.
 CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0) ///< Enable use-after-scope 
detection
 ///< in AddressSanitizer
+CODEGENOPT(SanitizeAddressPoisonClassMemberArrayNewCookie, 1,
+   0) ///< Enable poisoning operator new[] which is not a replaceable
+  ///< global allocation function in AddressSanitizer
 CODEGENOPT(SanitizeAddressGlobalsDeadStripping, 1, 0) ///< Enable linker dead 
stripping
   ///< of globals in 
AddressSanitizer
 CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0) ///< Enable tracking origins in
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -889,6 +889,14 @@
   

[PATCH] D40481: [libclang] Fix cursors for arguments of Subscript and Call operators

2018-02-07 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

Ping...


https://reviews.llvm.org/D40481



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


[PATCH] D41629: [libcxx] Improve accuracy of complex asinh and acosh

2018-02-07 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

ping^3


https://reviews.llvm.org/D41629



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


[clang-tools-extra] r324475 - [clangd] Do not precent-encode numbers in URI.

2018-02-07 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Feb  7 04:12:06 2018
New Revision: 324475

URL: http://llvm.org/viewvc/llvm-project?rev=324475&view=rev
Log:
[clangd] Do not precent-encode numbers in URI.

Reviewers: ilya-biryukov

Subscribers: klimek, jkorous-apple, cfe-commits, sammccall

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

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

Modified: clang-tools-extra/trunk/clangd/URI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/URI.cpp?rev=324475&r1=324474&r2=324475&view=diff
==
--- clang-tools-extra/trunk/clangd/URI.cpp (original)
+++ clang-tools-extra/trunk/clangd/URI.cpp Wed Feb  7 04:12:06 2018
@@ -79,7 +79,8 @@ findSchemeByName(llvm::StringRef Scheme)
 
 bool shouldEscape(unsigned char C) {
   // Unreserved characters.
-  if ((C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z'))
+  if ((C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') ||
+  (C >= '0' && C <= '9'))
 return false;
   switch (C) {
   case '-':

Modified: clang-tools-extra/trunk/unittests/clangd/URITests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/URITests.cpp?rev=324475&r1=324474&r2=324475&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/URITests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/URITests.cpp Wed Feb  7 04:12:06 
2018
@@ -72,6 +72,7 @@ URI parseOrDie(llvm::StringRef Uri) {
 TEST(PercentEncodingTest, Encode) {
   EXPECT_EQ(URI("x", /*Authority=*/"", "a/b/c").toString(), "x:a/b/c");
   EXPECT_EQ(URI("x", /*Authority=*/"", "a!b;c~").toString(), "x:a%21b%3bc~");
+  EXPECT_EQ(URI("x", /*Authority=*/"", "a123b").toString(), "x:a123b");
 }
 
 TEST(PercentEncodingTest, Decode) {


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


[PATCH] D43009: [clangd] Do not precent-encode numbers in URI.

2018-02-07 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324475: [clangd] Do not precent-encode numbers in URI. 
(authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D43009

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


Index: clang-tools-extra/trunk/unittests/clangd/URITests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/URITests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/URITests.cpp
@@ -72,6 +72,7 @@
 TEST(PercentEncodingTest, Encode) {
   EXPECT_EQ(URI("x", /*Authority=*/"", "a/b/c").toString(), "x:a/b/c");
   EXPECT_EQ(URI("x", /*Authority=*/"", "a!b;c~").toString(), "x:a%21b%3bc~");
+  EXPECT_EQ(URI("x", /*Authority=*/"", "a123b").toString(), "x:a123b");
 }
 
 TEST(PercentEncodingTest, Decode) {
Index: clang-tools-extra/trunk/clangd/URI.cpp
===
--- clang-tools-extra/trunk/clangd/URI.cpp
+++ clang-tools-extra/trunk/clangd/URI.cpp
@@ -79,7 +79,8 @@
 
 bool shouldEscape(unsigned char C) {
   // Unreserved characters.
-  if ((C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z'))
+  if ((C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') ||
+  (C >= '0' && C <= '9'))
 return false;
   switch (C) {
   case '-':


Index: clang-tools-extra/trunk/unittests/clangd/URITests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/URITests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/URITests.cpp
@@ -72,6 +72,7 @@
 TEST(PercentEncodingTest, Encode) {
   EXPECT_EQ(URI("x", /*Authority=*/"", "a/b/c").toString(), "x:a/b/c");
   EXPECT_EQ(URI("x", /*Authority=*/"", "a!b;c~").toString(), "x:a%21b%3bc~");
+  EXPECT_EQ(URI("x", /*Authority=*/"", "a123b").toString(), "x:a123b");
 }
 
 TEST(PercentEncodingTest, Decode) {
Index: clang-tools-extra/trunk/clangd/URI.cpp
===
--- clang-tools-extra/trunk/clangd/URI.cpp
+++ clang-tools-extra/trunk/clangd/URI.cpp
@@ -79,7 +79,8 @@
 
 bool shouldEscape(unsigned char C) {
   // Unreserved characters.
-  if ((C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z'))
+  if ((C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') ||
+  (C >= '0' && C <= '9'))
 return false;
   switch (C) {
   case '-':
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:26
+
+  static const llvm::StringMap Mapping{
+// [simd.alg]

You probably want to move `Mapping` out of the function.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:34
+{"sub", "operator- on std::experimental::simd objects"},
+{"mul", "operator* on std::experimental::simd objects"},
+  };

To point the obvious, this is not exhaustive list, at least `div` is missing.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:55
+  // [simd.binary]
+  if (Name.startswith("add_"))
+return "operator+ on std::experimental::simd objects";

This function was not updated to use the `Mapping` map.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:75
+  // libcxx implementation of std::experimental::simd requires at least C++11.
+  if (!Result.Context->getLangOpts().CPlusPlus11)
+return;

Is it reasonable to suggest to use ``?
I would guess it should be `CPlusPlus2a`



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:84
+  // SIMD intrinsic call.
+  const FunctionDecl *Callee = Call->getDirectCallee();
+  if (!Callee)

I would refactor this as astmatcher, at least a local one, e.g. something like
```
AST_MATCHER(CallExpr, hasDirectCallee) {
  return Node.getDirectCallee();
}
```
+
```
void SIMDIntrinsicsCheck::registerMatchers(MatchFinder *Finder) {
  Finder->addMatcher(
  callExpr(callee(
+allOf(
 functionDecl(matchesName("^::(_mm_|_mm256_|_mm512_|vec_)")
+  , hasDirectCallee()
+)
   )),
   unless(isExpansionInSystemHeader()))
  .bind("call"),
  this);
}
```
Unless of course there is already a narrower that does that



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:87
+return;
+  bool IsVector = Callee->getReturnType()->isVectorType();
+  for (const ParmVarDecl *Parm : Callee->parameters()) {

Same here, i *think* something like this would be better?
```
AST_MATCHER(FunctionDecl, isVectorFunction) {
 bool IsVector = Node.getReturnType()->isVectorType();
  for (const ParmVarDecl *Parm : Node.parameters()) {
QualType Type = Parm->getType();
if (Type->isPointerType())
  Type = Type->getPointeeType();
if (Type->isVectorType())
  IsVector = true;

  return IsVector;
}
```
+
```
void SIMDIntrinsicsCheck::registerMatchers(MatchFinder *Finder) {
  Finder->addMatcher(
  callExpr(callee(
allOf(
 functionDecl(
+   allOf(
 matchesName("^::(_mm_|_mm256_|_mm512_|vec_)")
+ , isVectorFunction()
+   )
  , hasDirectCallee()
)
   )),
   unless(isExpansionInSystemHeader()))
  .bind("call"),
  this);
}
```



Comment at: docs/clang-tidy/checks/readability-simd-intrinsics.rst:1
+.. title:: clang-tidy - simd-readability-intrinsics
+

This should be 
```
.. title:: clang-tidy - readability-simd-intrinsics
```



Comment at: docs/clang-tidy/checks/readability-simd-intrinsics.rst:3
+
+simd-readability-intrinsics
+===

Here too


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983



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


[PATCH] D43015: clang-format: Introduce BreakInheritanceList option

2018-02-07 Thread Francois Ferrand via Phabricator via cfe-commits
Typz created this revision.
Typz added reviewers: djasper, krasimir, klimek.

This option replaces the BreakBeforeInheritanceComma option with an
enum, thus introducing a mode where the colon stays on the same line as
constructor declaration:

  // When it fits on line:
  class A : public B, public C {
...
  };
  
  // When it does not fit:
  class A :
  public B,
  public C {
...
  };

This matches the behavior of the `BreakConstructorInitializers` option,
introduced in https://reviews.llvm.org/D32479.


Repository:
  rC Clang

https://reviews.llvm.org/D43015

Files:
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1286,15 +1286,40 @@
   verifyFormat("class ::A::B {};");
 }
 
-TEST_F(FormatTest, BreakBeforeInheritanceComma) {
-  FormatStyle StyleWithInheritanceBreak = getLLVMStyle();
-  StyleWithInheritanceBreak.BreakBeforeInheritanceComma = true;
-
-  verifyFormat("class MyClass : public X {};", StyleWithInheritanceBreak);
+TEST_F(FormatTest, BreakInheritanceStyle) {
+  FormatStyle StyleWithInheritanceBreakBeforeComma = getLLVMStyle();
+  StyleWithInheritanceBreakBeforeComma.BreakInheritanceList =
+  FormatStyle::BILS_BeforeComma;
+  verifyFormat("class MyClass : public X {};",
+   StyleWithInheritanceBreakBeforeComma);
   verifyFormat("class MyClass\n"
": public X\n"
", public Y {};",
-   StyleWithInheritanceBreak);
+   StyleWithInheritanceBreakBeforeComma);
+  verifyFormat("class AA\n"
+   ": public BB\n"
+   ", public CC {};",
+   StyleWithInheritanceBreakBeforeComma);
+  verifyFormat("struct a\n"
+   ": public aaa< // break\n"
+   "  > {};",
+   StyleWithInheritanceBreakBeforeComma);
+
+  FormatStyle StyleWithInheritanceBreakAfterColon = getLLVMStyle();
+  StyleWithInheritanceBreakAfterColon.BreakInheritanceList =
+  FormatStyle::BILS_AfterColon;
+  verifyFormat("class MyClass : public X {};",
+   StyleWithInheritanceBreakAfterColon);
+  verifyFormat("class MyClass : public X, public Y {};",
+   StyleWithInheritanceBreakAfterColon);
+  verifyFormat("class AA :\n"
+   "public BB,\n"
+   "public CC {};",
+   StyleWithInheritanceBreakAfterColon);
+  verifyFormat("struct a :\n"
+   "public aaa< // break\n"
+   "> {};",
+   StyleWithInheritanceBreakAfterColon);
 }
 
 TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) {
@@ -10172,7 +10197,6 @@
   CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
   CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
   CHECK_PARSE_BOOL(BreakStringLiterals);
-  CHECK_PARSE_BOOL(BreakBeforeInheritanceComma)
   CHECK_PARSE_BOOL(CompactNamespaces);
   CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine);
   CHECK_PARSE_BOOL(DerivePointerAlignment);
@@ -10284,6 +10308,17 @@
   CHECK_PARSE("BreakConstructorInitializersBeforeComma: true",
   BreakConstructorInitializers, FormatStyle::BCIS_BeforeComma);
 
+  Style.BreakInheritanceList = FormatStyle::BILS_BeforeColon;
+  CHECK_PARSE("BreakInheritanceList: BeforeComma",
+  BreakInheritanceList, FormatStyle::BILS_BeforeComma);
+  CHECK_PARSE("BreakInheritanceList: AfterColon",
+  BreakInheritanceList, FormatStyle::BILS_AfterColon);
+  CHECK_PARSE("BreakInheritanceList: BeforeColon",
+  BreakInheritanceList, FormatStyle::BILS_BeforeColon);
+  // For backward compatibility:
+  CHECK_PARSE("BreakBeforeInheritanceComma: true",
+  BreakInheritanceList, FormatStyle::BILS_BeforeComma);
+
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
   CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket,
   FormatStyle::BAS_Align);
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2652,7 +2652,8 @@
   !Style.ConstructorInitializerAllOnOneLineOrOnePerLine)
 return true;
   // Break only if we have multiple inheritance.
-  if (Style.BreakBeforeInheritanceComma && Right.is(TT_InheritanceComma))
+  if (Style.BreakInheritanceList == FormatStyle::BILS_BeforeComma &&
+  Right.is(TT_InheritanceComma))
 return true;
   if (Right.is(tok::string_literal) && Right.TokenTe

[PATCH] D43016: Fix for #31362 - ms_abi is implemented incorrectly for larger values (>=16 bytes).

2018-02-07 Thread Mateusz Belicki via Phabricator via cfe-commits
belickim created this revision.
Herald added a subscriber: cfe-commits.

This patch is a fix for following issue: 
https://bugs.llvm.org/show_bug.cgi?id=31362
The problem was caused by front end lowering C calling conventions without 
taking into account calling conventions enforced by __attribute__. In this case 
win64cc was no correctly lowered on targets other than Windows.


Repository:
  rC Clang

https://reviews.llvm.org/D43016

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/ms_abi.c


Index: test/CodeGen/ms_abi.c
===
--- test/CodeGen/ms_abi.c
+++ test/CodeGen/ms_abi.c
@@ -146,3 +146,16 @@
   // WIN64: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
   // WIN64-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
 }
+
+// This test checks if structs are passed according to Win64 calling convention
+// when it's enforced by __attribute((ms_abi)).
+struct i128 {
+  unsigned long long a;
+  unsigned long long b;
+};
+
+__attribute__((ms_abi)) struct i128 f7(struct i128 a) {
+  // WIN64: define void @f7(%struct.i128* noalias sret %agg.result, 
%struct.i128* %a)
+  // FREEBSD: define win64cc void @f7(%struct.i128* noalias sret %agg.result, 
%struct.i128* %a)
+  return a;
+}
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -3536,7 +3536,17 @@
 
 void X86_64ABIInfo::computeInfo(CGFunctionInfo &FI) const {
 
-  bool IsRegCall = FI.getCallingConvention() == llvm::CallingConv::X86_RegCall;
+  const unsigned CallingConv = FI.getCallingConvention();
+  // It is possible to force Win64 calling convention on any x86_64 target by
+  // using __attribute__((ms_abi)). In such case to correctly emit Win64
+  // compatible code delegate this call to WinX86_64ABIInfo::computeInfo.
+  if (CallingConv == llvm::CallingConv::Win64) {
+WinX86_64ABIInfo Win64ABIInfo(CGT);
+Win64ABIInfo.computeInfo(FI);
+return;
+  }
+
+  bool IsRegCall = CallingConv == llvm::CallingConv::X86_RegCall;
 
   // Keep track of the number of assigned registers.
   unsigned FreeIntRegs = IsRegCall ? 11 : 6;


Index: test/CodeGen/ms_abi.c
===
--- test/CodeGen/ms_abi.c
+++ test/CodeGen/ms_abi.c
@@ -146,3 +146,16 @@
   // WIN64: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
   // WIN64-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
 }
+
+// This test checks if structs are passed according to Win64 calling convention
+// when it's enforced by __attribute((ms_abi)).
+struct i128 {
+  unsigned long long a;
+  unsigned long long b;
+};
+
+__attribute__((ms_abi)) struct i128 f7(struct i128 a) {
+  // WIN64: define void @f7(%struct.i128* noalias sret %agg.result, %struct.i128* %a)
+  // FREEBSD: define win64cc void @f7(%struct.i128* noalias sret %agg.result, %struct.i128* %a)
+  return a;
+}
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -3536,7 +3536,17 @@
 
 void X86_64ABIInfo::computeInfo(CGFunctionInfo &FI) const {
 
-  bool IsRegCall = FI.getCallingConvention() == llvm::CallingConv::X86_RegCall;
+  const unsigned CallingConv = FI.getCallingConvention();
+  // It is possible to force Win64 calling convention on any x86_64 target by
+  // using __attribute__((ms_abi)). In such case to correctly emit Win64
+  // compatible code delegate this call to WinX86_64ABIInfo::computeInfo.
+  if (CallingConv == llvm::CallingConv::Win64) {
+WinX86_64ABIInfo Win64ABIInfo(CGT);
+Win64ABIInfo.computeInfo(FI);
+return;
+  }
+
+  bool IsRegCall = CallingConv == llvm::CallingConv::X86_RegCall;
 
   // Keep track of the number of assigned registers.
   unsigned FreeIntRegs = IsRegCall ? 11 : 6;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43017: Clean up use of C allocation functions

2018-02-07 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: akyrtzi, rnk.

This change cleans up uses of malloc/calloc/realloc. In the case where
the return value is not checked agains null pointer, the call to
'std::malloc' is replaced by 'llvm::malloc', which reports fatal error
on allocation failure. In plain C files, assertion statements are added
to ensure that memory is successfully allocated.

The aim of this change is to get better diagnostics of OOM on Windows.


Repository:
  rC Clang

https://reviews.llvm.org/D43017

Files:
  include/clang/Sema/ParsedTemplate.h
  lib/AST/NestedNameSpecifier.cpp
  lib/Frontend/CacheTokens.cpp
  lib/Frontend/Rewrite/HTMLPrint.cpp
  lib/Lex/MacroArgs.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/BuildSystem.cpp
  tools/libclang/CIndex.cpp
  tools/libclang/CXString.cpp

Index: tools/libclang/CXString.cpp
===
--- tools/libclang/CXString.cpp
+++ tools/libclang/CXString.cpp
@@ -96,7 +96,7 @@
 
 CXString createDup(StringRef String) {
   CXString Result;
-  char *Spelling = static_cast(malloc(String.size() + 1));
+  char *Spelling = static_cast(llvm::malloc(String.size() + 1));
   memmove(Spelling, String.data(), String.size());
   Spelling[String.size()] = 0;
   Result.data = Spelling;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -,7 +,8 @@
   if (CXTokens.empty())
 return;
 
-  *Tokens = (CXToken *)malloc(sizeof(CXToken) * CXTokens.size());
+  *Tokens = static_cast(
+  llvm::malloc(sizeof(CXToken) * CXTokens.size()));
   memmove(*Tokens, CXTokens.data(), sizeof(CXToken) * CXTokens.size());
   *NumTokens = CXTokens.size();
 }
Index: tools/libclang/BuildSystem.cpp
===
--- tools/libclang/BuildSystem.cpp
+++ tools/libclang/BuildSystem.cpp
@@ -17,6 +17,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/CBindingWrapping.h"
 #include "llvm/Support/Chrono.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -78,7 +79,7 @@
   unwrap(VFO)->write(OS);
 
   StringRef Data = OS.str();
-  *out_buffer_ptr = (char*)malloc(Data.size());
+  *out_buffer_ptr = static_cast(llvm::malloc(Data.size()));
   *out_buffer_size = Data.size();
   memcpy(*out_buffer_ptr, Data.data(), Data.size());
   return CXError_Success;
@@ -140,7 +141,7 @@
   OS << "}\n";
 
   StringRef Data = OS.str();
-  *out_buffer_ptr = (char*)malloc(Data.size());
+  *out_buffer_ptr = static_cast(llvm::malloc(Data.size()));
   *out_buffer_size = Data.size();
   memcpy(*out_buffer_ptr, Data.data(), Data.size());
   return CXError_Success;
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -232,6 +232,7 @@
   *unsaved_files
 = (struct CXUnsavedFile *)malloc(sizeof(struct CXUnsavedFile) *
  *num_unsaved_files);
+  assert(unsaved_files);
   for (i = 0; i != *num_unsaved_files; ++i) {
 struct CXUnsavedFile *unsaved = *unsaved_files + i;
 const char *arg_string = argv[arg_indices[i]] + prefix_len;
@@ -267,6 +268,7 @@
 
 /* Read the contents of the file we're remapping to. */
 contents = (char *)malloc(unsaved->Length + 1);
+assert(contents);
 if (fread(contents, 1, unsaved->Length, to_file) != unsaved->Length) {
   fprintf(stderr, "error: unexpected %s reading 'to' file %s\n",
   (feof(to_file) ? "EOF" : "error"), sep + 1);
@@ -286,6 +288,7 @@
 /* Copy the file name that we're remapping from. */
 filename_len = sep - arg_string;
 filename = (char *)malloc(filename_len + 1);
+assert(filename);
 memcpy(filename, arg_string, filename_len);
 filename[filename_len] = 0;
 unsaved->Filename = filename;
@@ -340,6 +343,7 @@
 = (struct CXUnsavedFile *)realloc(unsaved_files_no_try_idx,
   sizeof(struct CXUnsavedFile) *
 *num_unsaved_files);
+  assert(unsaved_files);
   memcpy(*unsaved_files + num_unsaved_files_no_try_idx,
  unsaved_files_try_idx, sizeof(struct CXUnsavedFile) *
 num_unsaved_files_try_idx);
@@ -2169,6 +2173,7 @@
 
   /* Copy the file name. */
   *filename = (char*)malloc(last_colon - input + 1);
+  assert(*filename);
   memcpy(*filename, input, last_colon - input);
   (*filename)[last_colon - input] = 0;
   return 0;
@@ -2578,6 +2583,7 @@
   assert(NumLocations > 0 && "Unable to count locations?");
   Locations = (CursorSourceLocation *)malloc(
   NumLocations * sizeof(CursorSourceLocation));
+  assert(Locations);
   for (Loc = 0; Loc < NumLocations; ++Loc) {
 const char *input = argv[Loc + 1] + strlen(loc

[PATCH] D42640: [clangd] Prototype: collect symbol #include & insert #include in global code completion.

2018-02-07 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 133202.
ioeric added a comment.

- Added tests for IncludeURI and CanonicalIncludes and minor cleanup.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42640

Files:
  clangd/CMakeLists.txt
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/CodeComplete.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/clients/clangd-vscode/package.json
  clangd/global-symbol-builder/CMakeLists.txt
  clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
  clangd/index/CanonicalIncludes.cpp
  clangd/index/CanonicalIncludes.h
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/Merge.cpp
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  clangd/index/SymbolYAML.cpp
  clangd/tool/ClangdMain.cpp
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test
  unittests/clangd/IndexTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -46,7 +46,13 @@
   return arg.CompletionSnippetInsertText == S;
 }
 MATCHER_P(QName, Name, "") { return (arg.Scope + arg.Name).str() == Name; }
-MATCHER_P(CPath, P, "") { return arg.CanonicalDeclaration.FilePath == P; }
+MATCHER_P(DeclURI, P, "") { return arg.CanonicalDeclaration.FileURI == P; }
+MATCHER_P(IncludeURI, P, "") {
+  return arg.Detail && arg.Detail->IncludeURI == P;
+}
+MATCHER(HasIncludeURI, "") {
+  return arg.Detail && !arg.Detail->IncludeURI.empty();
+}
 MATCHER_P(LocationOffsets, Offsets, "") {
   // Offset range in SymbolLocation is [start, end] while in Clangd is [start,
   // end).
@@ -58,38 +64,64 @@
 namespace clangd {
 
 namespace {
-const char TestHeaderName[] = "symbols.h";
-const char TestFileName[] = "symbol.cc";
 class SymbolIndexActionFactory : public tooling::FrontendActionFactory {
 public:
-  SymbolIndexActionFactory(SymbolCollector::Options COpts)
-  : COpts(std::move(COpts)) {}
+  SymbolIndexActionFactory(SymbolCollector::Options COpts,
+   CommentHandler *PragmaHandler)
+  : COpts(std::move(COpts)), PragmaHandler(PragmaHandler) {}
 
   clang::FrontendAction *create() override {
+class WrappedIndexAction : public WrapperFrontendAction {
+public:
+  WrappedIndexAction(std::shared_ptr C,
+ const index::IndexingOptions &Opts,
+ CommentHandler *PragmaHandler)
+  : WrapperFrontendAction(
+index::createIndexingAction(C, Opts, nullptr)),
+PragmaHandler(PragmaHandler) {}
+
+  std::unique_ptr
+  CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override {
+if (PragmaHandler)
+  CI.getPreprocessor().addCommentHandler(PragmaHandler);
+return WrapperFrontendAction::CreateASTConsumer(CI, InFile);
+  }
+
+private:
+  index::IndexingOptions IndexOpts;
+  CommentHandler *PragmaHandler;
+};
 index::IndexingOptions IndexOpts;
 IndexOpts.SystemSymbolFilter =
 index::IndexingOptions::SystemSymbolFilterKind::All;
 IndexOpts.IndexFunctionLocals = false;
 Collector = std::make_shared(COpts);
-FrontendAction *Action =
-index::createIndexingAction(Collector, IndexOpts, nullptr).release();
-return Action;
+return new WrappedIndexAction(Collector, std::move(IndexOpts),
+  PragmaHandler);
   }
 
   std::shared_ptr Collector;
   SymbolCollector::Options COpts;
+  CommentHandler *PragmaHandler;
 };
 
 class SymbolCollectorTest : public ::testing::Test {
 public:
+  SymbolCollectorTest()
+  : InMemoryFileSystem(new vfs::InMemoryFileSystem),
+TestHeaderName(getVirtualTestFilePath("symbol.h").str()),
+TestFileName(getVirtualTestFilePath("symbol.cc").str()) {
+TestHeaderURI = URI::createFile(TestHeaderName).toString();
+TestFileURI = URI::createFile(TestFileName).toString();
+  }
+
   bool runSymbolCollector(StringRef HeaderCode, StringRef MainCode,
   const std::vector &ExtraArgs = {}) {
-llvm::IntrusiveRefCntPtr InMemoryFileSystem(
-new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
 new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
-auto Factory = llvm::make_unique(CollectorOpts);
+auto Factory = llvm::make_unique(
+CollectorOpts, PragmaHandler.get());
 
 std::vector Args = {"symbol_collector", "-fsyntax-only",
  "-std=c++11", TestFileName};
@@ -104,17 +136,25 @@
 
 std::string Content = MainCode;
 if (!HeaderCode.empty())
-  Content = "#include\"" + std::string(TestHeaderName) + "\"\n" + Content;
+  Content = (llvm::Twine("#include\"") +
+ llvm::sys::path::filename(TestHeaderName) + "\"\n" + Conte

[PATCH] D42640: [clangd] Prototype: collect symbol #include & insert #include in global code completion.

2018-02-07 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 133203.
ioeric added a comment.

- Merge with origin/master


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42640

Files:
  clangd/CMakeLists.txt
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/CodeComplete.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/clients/clangd-vscode/package.json
  clangd/global-symbol-builder/CMakeLists.txt
  clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
  clangd/index/CanonicalIncludes.cpp
  clangd/index/CanonicalIncludes.h
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/Merge.cpp
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  clangd/index/SymbolYAML.cpp
  clangd/tool/ClangdMain.cpp
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -47,6 +47,12 @@
 }
 MATCHER_P(QName, Name, "") { return (arg.Scope + arg.Name).str() == Name; }
 MATCHER_P(DeclURI, P, "") { return arg.CanonicalDeclaration.FileURI == P; }
+MATCHER_P(IncludeURI, P, "") {
+  return arg.Detail && arg.Detail->IncludeURI == P;
+}
+MATCHER(HasIncludeURI, "") {
+  return arg.Detail && !arg.Detail->IncludeURI.empty();
+}
 MATCHER_P(LocationOffsets, Offsets, "") {
   // Offset range in SymbolLocation is [start, end] while in Clangd is [start,
   // end).
@@ -60,41 +66,62 @@
 namespace {
 class SymbolIndexActionFactory : public tooling::FrontendActionFactory {
 public:
-  SymbolIndexActionFactory(SymbolCollector::Options COpts)
-  : COpts(std::move(COpts)) {}
+  SymbolIndexActionFactory(SymbolCollector::Options COpts,
+   CommentHandler *PragmaHandler)
+  : COpts(std::move(COpts)), PragmaHandler(PragmaHandler) {}
 
   clang::FrontendAction *create() override {
+class WrappedIndexAction : public WrapperFrontendAction {
+public:
+  WrappedIndexAction(std::shared_ptr C,
+ const index::IndexingOptions &Opts,
+ CommentHandler *PragmaHandler)
+  : WrapperFrontendAction(
+index::createIndexingAction(C, Opts, nullptr)),
+PragmaHandler(PragmaHandler) {}
+
+  std::unique_ptr
+  CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override {
+if (PragmaHandler)
+  CI.getPreprocessor().addCommentHandler(PragmaHandler);
+return WrapperFrontendAction::CreateASTConsumer(CI, InFile);
+  }
+
+private:
+  index::IndexingOptions IndexOpts;
+  CommentHandler *PragmaHandler;
+};
 index::IndexingOptions IndexOpts;
 IndexOpts.SystemSymbolFilter =
 index::IndexingOptions::SystemSymbolFilterKind::All;
 IndexOpts.IndexFunctionLocals = false;
 Collector = std::make_shared(COpts);
-FrontendAction *Action =
-index::createIndexingAction(Collector, IndexOpts, nullptr).release();
-return Action;
+return new WrappedIndexAction(Collector, std::move(IndexOpts),
+  PragmaHandler);
   }
 
   std::shared_ptr Collector;
   SymbolCollector::Options COpts;
+  CommentHandler *PragmaHandler;
 };
 
 class SymbolCollectorTest : public ::testing::Test {
 public:
   SymbolCollectorTest()
-  : TestHeaderName(getVirtualTestFilePath("symbol.h").str()),
+  : InMemoryFileSystem(new vfs::InMemoryFileSystem),
+TestHeaderName(getVirtualTestFilePath("symbol.h").str()),
 TestFileName(getVirtualTestFilePath("symbol.cc").str()) {
 TestHeaderURI = URI::createFile(TestHeaderName).toString();
 TestFileURI = URI::createFile(TestFileName).toString();
   }
 
   bool runSymbolCollector(StringRef HeaderCode, StringRef MainCode,
   const std::vector &ExtraArgs = {}) {
-llvm::IntrusiveRefCntPtr InMemoryFileSystem(
-new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
 new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
-auto Factory = llvm::make_unique(CollectorOpts);
+auto Factory = llvm::make_unique(
+CollectorOpts, PragmaHandler.get());
 
 std::vector Args = {"symbol_collector", "-fsyntax-only",
  "-std=c++11", TestFileName};
@@ -120,12 +147,14 @@
   }
 
 protected:
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem;
   std::string TestHeaderName;
   std::string TestHeaderURI;
   std::string TestFileName;
   std::string TestFileURI;
   SymbolSlab Symbols;
   SymbolCollector::Options CollectorOpts;
+  std::unique_ptr PragmaHandler;
 };
 
 TEST_F(SymbolCollectorTest, CollectSymbols) {
@@ -521,6 +550,64 @@
QName("clang::Foo2")));
 }
 
+TEST_F(SymbolCollectorTest, NoIncludeURIIfSameAsFileURI) {
+  CollectorOpts.CollectInclu

[PATCH] D43015: clang-format: Introduce BreakInheritanceList option

2018-02-07 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 133204.
Typz added a comment.

Fix indentation of inheritance list, which is actually based on 
`ConstructorInitializerIndentWidth`.

Maybe a new option (`InheritanceListIndentWidth`) should be used instead?


Repository:
  rC Clang

https://reviews.llvm.org/D43015

Files:
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1286,15 +1286,40 @@
   verifyFormat("class ::A::B {};");
 }
 
-TEST_F(FormatTest, BreakBeforeInheritanceComma) {
-  FormatStyle StyleWithInheritanceBreak = getLLVMStyle();
-  StyleWithInheritanceBreak.BreakBeforeInheritanceComma = true;
-
-  verifyFormat("class MyClass : public X {};", StyleWithInheritanceBreak);
+TEST_F(FormatTest, BreakInheritanceStyle) {
+  FormatStyle StyleWithInheritanceBreakBeforeComma = getLLVMStyle();
+  StyleWithInheritanceBreakBeforeComma.BreakInheritanceList =
+  FormatStyle::BILS_BeforeComma;
+  verifyFormat("class MyClass : public X {};",
+   StyleWithInheritanceBreakBeforeComma);
   verifyFormat("class MyClass\n"
": public X\n"
", public Y {};",
-   StyleWithInheritanceBreak);
+   StyleWithInheritanceBreakBeforeComma);
+  verifyFormat("class AA\n"
+   ": public BB\n"
+   ", public CC {};",
+   StyleWithInheritanceBreakBeforeComma);
+  verifyFormat("struct a\n"
+   ": public aaa< // break\n"
+   "  > {};",
+   StyleWithInheritanceBreakBeforeComma);
+
+  FormatStyle StyleWithInheritanceBreakAfterColon = getLLVMStyle();
+  StyleWithInheritanceBreakAfterColon.BreakInheritanceList =
+  FormatStyle::BILS_AfterColon;
+  verifyFormat("class MyClass : public X {};",
+   StyleWithInheritanceBreakAfterColon);
+  verifyFormat("class MyClass : public X, public Y {};",
+   StyleWithInheritanceBreakAfterColon);
+  verifyFormat("class AA :\n"
+   "public BB,\n"
+   "public CC {};",
+   StyleWithInheritanceBreakAfterColon);
+  verifyFormat("struct a :\n"
+   "public aaa< // break\n"
+   "> {};",
+   StyleWithInheritanceBreakAfterColon);
 }
 
 TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) {
@@ -3618,6 +3643,23 @@
"  aa,\n"
"  bb {}",
Style);
+
+  // `ConstructorInitializerIndentWidth` actually applies to InheritanceList as well
+  Style.BreakInheritanceList = FormatStyle::BILS_BeforeColon;
+  verifyFormat("class SomeClass\n"
+   "  : public aa,\n"
+   "public bb {};",
+   Style);
+  Style.BreakInheritanceList = FormatStyle::BILS_BeforeComma;
+  verifyFormat("class SomeClass\n"
+   "  : public aa\n"
+   "  , public bb {};",
+   Style);
+  Style.BreakInheritanceList = FormatStyle::BILS_AfterColon;
+  verifyFormat("class SomeClass :\n"
+   "  public aa,\n"
+   "  public bb {};",
+   Style);
 }
 
 #ifndef EXPENSIVE_CHECKS
@@ -10172,7 +10214,6 @@
   CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
   CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
   CHECK_PARSE_BOOL(BreakStringLiterals);
-  CHECK_PARSE_BOOL(BreakBeforeInheritanceComma)
   CHECK_PARSE_BOOL(CompactNamespaces);
   CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine);
   CHECK_PARSE_BOOL(DerivePointerAlignment);
@@ -10284,6 +10325,17 @@
   CHECK_PARSE("BreakConstructorInitializersBeforeComma: true",
   BreakConstructorInitializers, FormatStyle::BCIS_BeforeComma);
 
+  Style.BreakInheritanceList = FormatStyle::BILS_BeforeColon;
+  CHECK_PARSE("BreakInheritanceList: BeforeComma",
+  BreakInheritanceList, FormatStyle::BILS_BeforeComma);
+  CHECK_PARSE("BreakInheritanceList: AfterColon",
+  BreakInheritanceList, FormatStyle::BILS_AfterColon);
+  CHECK_PARSE("BreakInheritanceList: BeforeColon",
+  BreakInheritanceList, FormatStyle::BI

[PATCH] D42978: Make march/target-cpu print a note with the list of valid values

2018-02-07 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a reviewer: rengolin.
fhahn added a comment.

I like the idea. However for all backends, except Arm and AArch64, we would 
have to maintain another list of CPU names. At least for the targets which 
implement `isValidCPUName`, we could add an array with valid names and use 
that.  That's still not ideal, but I do not think we should hold back this 
patch until all targets use the same infrastructure to handle CPUs. As for 
tests, we should test the note for all backends I think.




Comment at: test/Misc/target-parser.c:3
 // CHECK: error: unknown target CPU 'not-a-cpu'
+// //CHECK: note: valid target CPU values are:

drop one set of //


Repository:
  rC Clang

https://reviews.llvm.org/D42978



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


[clang-tools-extra] r324407 - Support special acronyms inside property names and allow plural forms

2018-02-07 Thread Yan Zhang via cfe-commits
Author: wizard
Date: Tue Feb  6 13:40:38 2018
New Revision: 324407

URL: http://llvm.org/viewvc/llvm-project?rev=324407&view=rev
Log:
Support special acronyms inside property names and allow plural forms

Reviewers: benhamilton, hokein

Reviewed By: benhamilton, hokein

Subscribers: klimek, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m

Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp?rev=324407&r1=324406&r2=324407&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Tue 
Feb  6 13:40:38 2018
@@ -12,8 +12,8 @@
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "llvm/ADT/STLExtras.h"
 #include "clang/Basic/CharInfo.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Regex.h"
 
@@ -118,6 +118,12 @@ FixItHint generateFixItHint(const ObjCPr
   return FixItHint();
 }
 
+std::string AcronymsGroupRegex(llvm::ArrayRef EscapedAcronyms) {
+  return "(" +
+ llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "s?|") +
+ "s?)";
+}
+
 std::string validPropertyNameRegex(llvm::ArrayRef EscapedAcronyms,
bool UsedInMatcher) {
   // Allow any of these names:
@@ -129,12 +135,9 @@ std::string validPropertyNameRegex(llvm:
   // URLString
   // bundleID
   std::string StartMatcher = UsedInMatcher ? "::" : "^";
-
-  return StartMatcher + "((" +
- llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") +
- ")[A-Z]?)?[a-z]+[a-z0-9]*([A-Z][a-z0-9]+)*" + "(" +
- llvm::join(EscapedAcronyms.begin(), EscapedAcronyms.end(), "|") +
- ")?$";
+  std::string AcronymsMatcher = AcronymsGroupRegex(EscapedAcronyms);
+  return StartMatcher + "(" + AcronymsMatcher + "[A-Z]?)?[a-z]+[a-z0-9]*(" +
+ AcronymsMatcher + "|([A-Z][a-z0-9]+))*$";
 }
 
 bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {

Modified: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m?rev=324407&r1=324406&r2=324407&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m Tue Feb 
 6 13:40:38 2018
@@ -14,6 +14,9 @@
 @property(strong, nonatomic) UIViewController *notificationsVC;
 @property(strong, nonatomic) NSString *URL_string;
 // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' not 
using lowerCamelCase style or not prefixed in a category, according to the 
Apple Coding Guidelines [objc-property-declaration]
+@property(strong, nonatomic) NSString *supportURLsCamelCase;
+@property(strong, nonatomic) NSString *supportURLCamelCase;
+@property(strong, nonatomic) NSString *VCsPluralToAdd;
 @end
 
 @interface Foo (Bar)


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


[PATCH] D42978: Make march/target-cpu print a note with the list of valid values

2018-02-07 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

Also with tests for each backend, this diff will get quite big. As this is 
opt-in, it might make sense to enable backends separately.


Repository:
  rC Clang

https://reviews.llvm.org/D42978



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


r324469 - [clang-format] Fix ObjC message arguments formatting.

2018-02-07 Thread Jacek Olesiak via cfe-commits
Author: jolesiak
Date: Wed Feb  7 02:35:08 2018
New Revision: 324469

URL: http://llvm.org/viewvc/llvm-project?rev=324469&view=rev
Log:
[clang-format] Fix ObjC message arguments formatting.

Summary:
Fixes formatting of ObjC message arguments when inline block is a first
argument.

Having inline block as a first argument when method has multiple parameters is
discouraged by Apple:
"It’s best practice to use only one block argument to a method. If the
method also needs other non-block arguments, the block should come last"
(https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html#//apple_ref/doc/uid/TP40011210-CH8-SW7),
it should be correctly formatted nevertheless.

Current formatting:
```
[object blockArgument:^{
  a = 42;
}
anotherArg:42];
```

Fixed (colon alignment):
```
[object
  blockArgument:^{
a = 42;
  }
 anotherArg:42];
```

Test Plan: make -j12 FormatTests && tools/clang/unittests/Format/FormatTests

Reviewers: krasimir, benhamilton

Reviewed By: krasimir, benhamilton

Subscribers: benhamilton, klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestObjC.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=324469&r1=324468&r2=324469&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Wed Feb  7 02:35:08 2018
@@ -266,6 +266,11 @@ bool ContinuationIndenter::mustBreak(con
 return true;
   if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection)
 return true;
+  if (Style.Language == FormatStyle::LK_ObjC &&
+  Current.ObjCSelectorNameParts > 1 &&
+  Current.startsSequence(TT_SelectorName, tok::colon, tok::caret)) {
+return true;
+  }
   if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) ||
(Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) &&
 Style.isCpp() &&

Modified: cfe/trunk/lib/Format/FormatToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=324469&r1=324468&r2=324469&view=diff
==
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Wed Feb  7 02:35:08 2018
@@ -240,6 +240,10 @@ struct FormatToken {
   /// e.g. because several of them are block-type.
   unsigned LongestObjCSelectorName = 0;
 
+  /// \brief How many parts ObjC selector have (i.e. how many parameters method
+  /// has).
+  unsigned ObjCSelectorNameParts = 0;
+
   /// \brief Stores the number of required fake parentheses and the
   /// corresponding operator precedence.
   ///

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=324469&r1=324468&r2=324469&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Feb  7 02:35:08 2018
@@ -411,6 +411,8 @@ private:
 if (Contexts.back().FirstObjCSelectorName) {
   Contexts.back().FirstObjCSelectorName->LongestObjCSelectorName =
   Contexts.back().LongestObjCSelectorName;
+  Contexts.back().FirstObjCSelectorName->ObjCSelectorNameParts =
+  Left->ParameterCount;
   if (Left->BlockParameterCount > 1)
 Contexts.back().FirstObjCSelectorName->LongestObjCSelectorName = 0;
 }
@@ -424,6 +426,11 @@ private:
   TT_DesignatedInitializerLSquare)) {
   Left->Type = TT_ObjCMethodExpr;
   StartsObjCMethodExpr = true;
+  // ParameterCount might have been set to 1 before expression was
+  // recognized as ObjCMethodExpr (as '1 + number of commas' formula is
+  // used for other expression types). Parameter counter has to be,
+  // therefore, reset to 0.
+  Left->ParameterCount = 0;
   Contexts.back().ColonIsObjCMethodExpr = true;
   if (Parent && Parent->is(tok::r_paren))
 Parent->Type = TT_CastRParen;
@@ -498,7 +505,10 @@ private:
   void updateParameterCount(FormatToken *Left, FormatToken *Current) {
 if (Current->is(tok::l_brace) && Current->BlockKind == BK_Block)
   ++Left->BlockParameterCount;
-if (Current->is(tok::comma)) {
+if (Left->Type == TT_ObjCMethodExpr) {
+  if (Current->is(tok::colon))
+++Left->ParameterCount;
+} else if (Current->is(tok::comma)) {
   ++Left->ParameterCount;
   if (!Left->Ro

[PATCH] D36191: [CodeGen] Don't make availability attributes imply default visibility on macos

2018-02-07 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.
Herald added a subscriber: llvm-commits.

What's the status here?


Repository:
  rL LLVM

https://reviews.llvm.org/D36191



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


[PATCH] D36191: [CodeGen] Don't make availability attributes imply default visibility on macos

2018-02-07 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Err sorry, landed in https://reviews.llvm.org/rL310382.


Repository:
  rL LLVM

https://reviews.llvm.org/D36191



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


[PATCH] D42995: [ThinLTO] Ignore object files with empty ThinLTO index

2018-02-07 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D42995#1000155, @vitalybuka wrote:

> In https://reviews.llvm.org/D42995#125, @tejohnson wrote:
>
> > > Empty ThinLTOIndexFile signals that we don't need this module during
> > >  linking.
> >
> > Not the only case actually. We now also pass an empty index file when we 
> > want to compile the bitcode down to object without applying any LTO 
> > optimization (there are a few cases where we decide we want to turn off LTO 
> > optimizations for some links), and this is currently relying on being able 
> > to pass /dev/null for the index file that would be broken by this change.
>
>
> I'd expect this should be done by indexing and content is already in the 
> merged object file.
>  Not sure how to reproduce this. I've build some large targets and I never 
> seen this.


This is done in bazel, not in gold.  See below.

> 
> 
>> 
>> 
>>> So we should not run ThinLTO backend even if it contains the
>>>  ThinLTO module. Backend may fail because of lack of necessary
>>>  information which should be provided by ThinLTOIndex.
>> 
>> This shouldn't happen - are you seeing cases where we fail? After 
>> loadModule() is called, EmitBackendOutput() is called which passes 
>> /*IgnoreEmptyThinLTOIndexFile*/true to  getModuleSummaryIndexForFile, which 
>> would cause it to return nullptr if the index file is empty.  Back in 
>> EmitBackendOutput(), if the combined index is null we will skip ThinLTO 
>> compilation and fall back to normal compilation.
> 
> I don't see for regular compilation, but I see for  for CFI. Backend will not 
> be able to process llvm.type.test without TypeIdMap from index and it will 
> crash in "Instruction Select"

@pcc and I already discussed this a little bit in the context of bazel. I will 
point you to that discussion separately.


https://reviews.llvm.org/D42995



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


[PATCH] D43026: [OpenMP] Support for implicit "declare target" functions - CodeGen patch

2018-02-07 Thread George Rokos via Phabricator via cfe-commits
grokos created this revision.
grokos added a reviewer: ABataev.
grokos added projects: clang, OpenMP.
Herald added a subscriber: guansong.

This patch implements CodeGen support for the "declare target" directive.

Code is generated for variables, functions and ctors/dtors.

I understand that the patch as a whole is somewhat large; if this is the case 
and it cannot land in one go then let's discuss how it can be split. Due to 
this uncertainty I haven't included any regression tests, I'll upload them once 
the scope of each patch has been determined.


Repository:
  rC Clang

https://reviews.llvm.org/D43026

Files:
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Parse/ParseOpenMP.cpp

Index: lib/Parse/ParseOpenMP.cpp
===
--- lib/Parse/ParseOpenMP.cpp
+++ lib/Parse/ParseOpenMP.cpp
@@ -758,6 +758,7 @@
 if (!Actions.ActOnStartOpenMPDeclareTargetDirective(DTLoc))
   return DeclGroupPtrTy();
 
+SmallVector Decls;
 DKind = ParseOpenMPDirectiveKind(*this);
 while (DKind != OMPD_end_declare_target && DKind != OMPD_declare_target &&
Tok.isNot(tok::eof) && Tok.isNot(tok::r_brace)) {
@@ -781,6 +782,12 @@
 else
   TPA.Commit();
   }
+
+  // Save the declarations so that we can create the declare target group
+  // later on.
+  if (Ptr)
+for (auto *V : Ptr.get())
+  Decls.push_back(V);
 }
 
 if (DKind == OMPD_end_declare_target) {
@@ -795,8 +802,17 @@
 } else {
   Diag(Tok, diag::err_expected_end_declare_target);
   Diag(DTLoc, diag::note_matching) << "'#pragma omp declare target'";
+  // We have an error, so we don't have to attempt to generate code for the
+  // declarations.
+  Decls.clear();
 }
 Actions.ActOnFinishOpenMPDeclareTargetDirective();
+
+// If we have decls generate the group so that code can be generated for it
+// later on.
+if (!Decls.empty())
+  return Actions.BuildDeclaratorGroup(Decls);
+
 return DeclGroupPtrTy();
   }
   case OMPD_unknown:
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -387,8 +387,8 @@
   QualType LValType) override;
 
   void EmitGuardedInit(CodeGenFunction &CGF, const VarDecl &D,
-   llvm::GlobalVariable *DeclPtr,
-   bool PerformInit) override;
+   llvm::GlobalVariable *DeclPtr, bool PerformInit,
+   bool EmitInitOnly, bool EmitDtorOnly) override;
   void registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D,
   llvm::Constant *Dtor, llvm::Constant *Addr) override;
 
@@ -2387,15 +2387,17 @@
 
 void MicrosoftCXXABI::EmitGuardedInit(CodeGenFunction &CGF, const VarDecl &D,
   llvm::GlobalVariable *GV,
-  bool PerformInit) {
+  bool PerformInit, bool EmitInitOnly,
+  bool EmitDtorOnly) {
   // MSVC only uses guards for static locals.
   if (!D.isStaticLocal()) {
 assert(GV->hasWeakLinkage() || GV->hasLinkOnceLinkage());
 // GlobalOpt is allowed to discard the initializer, so use linkonce_odr.
 llvm::Function *F = CGF.CurFn;
 F->setLinkage(llvm::GlobalValue::LinkOnceODRLinkage);
 F->setComdat(CGM.getModule().getOrInsertComdat(F->getName()));
-CGF.EmitCXXGlobalVarDeclInit(D, GV, PerformInit);
+CGF.EmitCXXGlobalVarDeclInit(D, GV, PerformInit, EmitInitOnly,
+ EmitDtorOnly);
 return;
   }
 
@@ -2496,7 +2498,8 @@
 CGF.EmitBlock(InitBlock);
 Builder.CreateStore(Builder.CreateOr(LI, Bit), GuardAddr);
 CGF.EHStack.pushCleanup(EHCleanup, GuardAddr, GuardNum);
-CGF.EmitCXXGlobalVarDeclInit(D, GV, PerformInit);
+CGF.EmitCXXGlobalVarDeclInit(D, GV, PerformInit, EmitInitOnly,
+ EmitDtorOnly);
 CGF.PopCleanupBlock();
 Builder.CreateBr(EndBlock);
 
@@ -2542,7 +2545,8 @@
 // Ok, we ended up getting selected as the initializing thread.
 CGF.EmitBlock(InitBlock);
 CGF.EHStack.pushCleanup(EHCleanup, GuardAddr);
-CGF.EmitCXXGlobalVarDeclInit(D, GV, PerformInit);
+CGF.EmitCXXGlobalVarDeclInit(D, GV, PerformInit, EmitInitOnly,
+ EmitDtorOnly);
 CGF.PopCleanupBlock();
 CGF.EmitNounwindRuntimeCall(getInitThreadFooterFn(CGM),
 GuardAddr.getPointer());
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/Itaniu

r324490 - [DebugInfo] Improvements to representation of enumeration types (PR36168)

2018-02-07 Thread Momchil Velikov via cfe-commits
Author: chill
Date: Wed Feb  7 08:52:02 2018
New Revision: 324490

URL: http://llvm.org/viewvc/llvm-project?rev=324490&view=rev
Log:
[DebugInfo] Improvements to representation of enumeration types (PR36168)

This patch:

* fixes an incorrect sign-extension of unsigned values, when emitting
  debug info metadata for enumerators
* the enumerators metadata is created with a flag, which determines
  interpretation of the value bits (signed or unsigned)
* the enumerations metadata contains the underlying integer type and a
  flag, indicating whether this is a C++ "fixed enum"

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

Added:
cfe/trunk/test/CodeGen/debug-info-enum.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGenCXX/debug-info-enum-class.cpp
cfe/trunk/test/CodeGenCXX/debug-info-enum.cpp
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=324490&r1=324489&r2=324490&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Feb  7 08:52:02 2018
@@ -2492,9 +2492,12 @@ llvm::DIType *CGDebugInfo::CreateTypeDef
   // Create elements for each enumerator.
   SmallVector Enumerators;
   ED = ED->getDefinition();
+  bool IsSigned = ED->getIntegerType()->isSignedIntegerType();
   for (const auto *Enum : ED->enumerators()) {
-Enumerators.push_back(DBuilder.createEnumerator(
-Enum->getName(), Enum->getInitVal().getSExtValue()));
+const auto &InitVal = Enum->getInitVal();
+auto Value = IsSigned ? InitVal.getSExtValue() : InitVal.getZExtValue();
+Enumerators.push_back(
+DBuilder.createEnumerator(Enum->getName(), Value, !IsSigned));
   }
 
   // Return a CompositeType for the enum itself.
@@ -2503,11 +2506,10 @@ llvm::DIType *CGDebugInfo::CreateTypeDef
   llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
   unsigned Line = getLineNumber(ED->getLocation());
   llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
-  llvm::DIType *ClassTy =
-  ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : nullptr;
+  llvm::DIType *ClassTy = getOrCreateType(ED->getIntegerType(), DefUnit);
   return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
 Line, Size, Align, EltArray, ClassTy,
-FullName);
+FullName, ED->isFixed());
 }
 
 llvm::DIMacro *CGDebugInfo::CreateMacro(llvm::DIMacroFile *Parent,

Added: cfe/trunk/test/CodeGen/debug-info-enum.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-enum.cpp?rev=324490&view=auto
==
--- cfe/trunk/test/CodeGen/debug-info-enum.cpp (added)
+++ cfe/trunk/test/CodeGen/debug-info-enum.cpp Wed Feb  7 08:52:02 2018
@@ -0,0 +1,100 @@
+// Test enumeration representation in debuig info metadata:
+// * test value representation for each possible underlying integer type
+// * test the integer type is as expected
+// * test the DW_AT_enum_class attribute is present (resp. absent) as expected.
+
+// RUN: %clang -target x86_64-linux -g -S -emit-llvm -o - %s | FileCheck %s
+
+
+enum class E0 : signed char {
+  A0 = -128,
+  B0 = 127,
+} x0;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E0"
+// CHECK-SAME: baseType: ![[SCHAR:[0-9]+]]
+// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: elements: ![[ELTS0:[0-9]+]]
+// CHECK: ![[SCHAR]] = !DIBasicType(name: "signed char", size: 8, encoding: 
DW_ATE_signed_char)
+// CHECK: ![[ELTS0]] = !{![[A0:[0-9]+]], ![[B0:[0-9]+]]}
+// CHECK: ![[A0]] = !DIEnumerator(name: "A0", value: -128)
+// CHECK: ![[B0]] = !DIEnumerator(name: "B0", value: 127)
+
+enum class E1 : unsigned char { A1 = 255 } x1;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E1"
+// CHECK-SAME: baseType: ![[UCHAR:[0-9]+]]
+// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: elements: ![[ELTS1:[0-9]+]]
+// CHECK: ![[UCHAR]] = !DIBasicType(name: "unsigned char", size: 8, encoding: 
DW_ATE_unsigned_char)
+// CHECK: ![[ELTS1]] = !{![[A1:[0-9]+]]}
+// CHECK: ![[A1]] = !DIEnumerator(name: "A1", value: 255, isUnsigned: true)
+
+enum class E2 : signed short {
+  A2 = -32768,
+  B2 = 32767,
+} x2;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E2"
+// CHECK-SAME: baseType: ![[SHORT:[0-9]+]]
+// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: elements: ![[ELTS2:[0-9]+]]
+// CHECK: ![[SHORT]] = !DIBasicType(name: "short", size: 16, encoding: 
DW_ATE_signed)
+// CHECK: ![[ELTS2]] = !{![[A2:[0-9]+]], ![[B2:[0-9]+]]}
+// CHECK: ![[A2]] = !DIEnumerator(name: "A2", value: -32768)
+// CHECK: ![[B2]] = !DIEnumerator(name: "B2", value: 32767)
+
+enum class E3 : unsigned short { A3 = 655

[PATCH] D42736: [DebugInfo] Improvements to representation of enumeration types (PR36168)

2018-02-07 Thread Momchil Velikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324490: [DebugInfo] Improvements to representation of 
enumeration types (PR36168) (authored by chill, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42736?vs=132822&id=133228#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42736

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/test/CodeGen/debug-info-enum.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-enum-class.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-enum.cpp
  cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Index: cfe/trunk/test/CodeGenCXX/debug-info-enum.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-enum.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-enum.cpp
@@ -11,7 +11,7 @@
 // CHECK-SAME:  identifier: "_ZTSN5test11eE"
 // CHECK: [[TEST1]] = !DINamespace(name: "test1"
 // CHECK: [[TEST1_ENUMS]] = !{[[TEST1_E:![0-9]*]]}
-// CHECK: [[TEST1_E]] = !DIEnumerator(name: "E", value: 0)
+// CHECK: [[TEST1_E]] = !DIEnumerator(name: "E", value: 0, isUnsigned: true)
 enum e { E };
 void foo() {
   int v = E;
Index: cfe/trunk/test/CodeGenCXX/debug-info-enum-class.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-enum-class.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-enum-class.cpp
@@ -15,20 +15,20 @@
 // CHECK-SAME: baseType: ![[INT:[0-9]+]]
 // CHECK-SAME: size: 32
 // CHECK-NOT:  offset:
-// CHECK-NOT:  flags:
+// CHECK-SAME: flags: DIFlagFixedEnum
 // CHECK-SAME: ){{$}}
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "B"
 // CHECK-SAME: line: 4
 // CHECK-SAME: baseType: ![[ULONG:[0-9]+]]
 // CHECK-SAME: size: 64
 // CHECK-NOT:  offset:
-// CHECK-NOT:  flags:
+// CHECK-SAME: flags: DIFlagFixedEnum
 // CHECK-SAME: ){{$}}
 // CHECK: ![[ULONG]] = !DIBasicType(name: "long unsigned int"
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "C"
 // CHECK-SAME: line: 5
-// CHECK-NOT:  baseType:
+// CHECK-SAME: baseType: ![[ULONG:[0-9]+]]
 // CHECK-SAME: size: 32
 // CHECK-NOT:  offset:
 // CHECK-NOT:  flags:
Index: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
===
--- cfe/trunk/test/Modules/ModuleDebugInfo.cpp
+++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp
@@ -48,7 +48,7 @@
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
 // CHECK-NOT:  name:
 // CHECK-SAME: )
-// CHECK: !DIEnumerator(name: "e5", value: 5)
+// CHECK: !DIEnumerator(name: "e5", value: 5, isUnsigned: true)
 
 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
 // no mangled name here yet.
Index: cfe/trunk/test/CodeGen/debug-info-enum.cpp
===
--- cfe/trunk/test/CodeGen/debug-info-enum.cpp
+++ cfe/trunk/test/CodeGen/debug-info-enum.cpp
@@ -0,0 +1,100 @@
+// Test enumeration representation in debuig info metadata:
+// * test value representation for each possible underlying integer type
+// * test the integer type is as expected
+// * test the DW_AT_enum_class attribute is present (resp. absent) as expected.
+
+// RUN: %clang -target x86_64-linux -g -S -emit-llvm -o - %s | FileCheck %s
+
+
+enum class E0 : signed char {
+  A0 = -128,
+  B0 = 127,
+} x0;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E0"
+// CHECK-SAME: baseType: ![[SCHAR:[0-9]+]]
+// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: elements: ![[ELTS0:[0-9]+]]
+// CHECK: ![[SCHAR]] = !DIBasicType(name: "signed char", size: 8, encoding: DW_ATE_signed_char)
+// CHECK: ![[ELTS0]] = !{![[A0:[0-9]+]], ![[B0:[0-9]+]]}
+// CHECK: ![[A0]] = !DIEnumerator(name: "A0", value: -128)
+// CHECK: ![[B0]] = !DIEnumerator(name: "B0", value: 127)
+
+enum class E1 : unsigned char { A1 = 255 } x1;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E1"
+// CHECK-SAME: baseType: ![[UCHAR:[0-9]+]]
+// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: elements: ![[ELTS1:[0-9]+]]
+// CHECK: ![[UCHAR]] = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)
+// CHECK: ![[ELTS1]] = !{![[A1:[0-9]+]]}
+// CHECK: ![[A1]] = !DIEnumerator(name: "A1", value: 255, isUnsigned: true)
+
+enum class E2 : signed short {
+  A2 = -32768,
+  B2 = 32767,
+} x2;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E2"
+// CHECK-SAME: baseType: ![[SHORT:[0-9]+]]
+// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: elements: ![[ELTS2:[0-9]+]]
+// CHECK: ![[SHORT]] = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
+// CHECK: ![[ELTS2]] = !{![[A2:[0-9]+]

[PATCH] D42736: [DebugInfo] Improvements to representation of enumeration types (PR36168)

2018-02-07 Thread Momchil Velikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC324490: [DebugInfo] Improvements to representation of 
enumeration types (PR36168) (authored by chill, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D42736

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGen/debug-info-enum.cpp
  test/CodeGenCXX/debug-info-enum-class.cpp
  test/CodeGenCXX/debug-info-enum.cpp
  test/Modules/ModuleDebugInfo.cpp

Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2492,22 +2492,24 @@
   // Create elements for each enumerator.
   SmallVector Enumerators;
   ED = ED->getDefinition();
+  bool IsSigned = ED->getIntegerType()->isSignedIntegerType();
   for (const auto *Enum : ED->enumerators()) {
-Enumerators.push_back(DBuilder.createEnumerator(
-Enum->getName(), Enum->getInitVal().getSExtValue()));
+const auto &InitVal = Enum->getInitVal();
+auto Value = IsSigned ? InitVal.getSExtValue() : InitVal.getZExtValue();
+Enumerators.push_back(
+DBuilder.createEnumerator(Enum->getName(), Value, !IsSigned));
   }
 
   // Return a CompositeType for the enum itself.
   llvm::DINodeArray EltArray = DBuilder.getOrCreateArray(Enumerators);
 
   llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
   unsigned Line = getLineNumber(ED->getLocation());
   llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
-  llvm::DIType *ClassTy =
-  ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : nullptr;
+  llvm::DIType *ClassTy = getOrCreateType(ED->getIntegerType(), DefUnit);
   return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
 Line, Size, Align, EltArray, ClassTy,
-FullName);
+FullName, ED->isFixed());
 }
 
 llvm::DIMacro *CGDebugInfo::CreateMacro(llvm::DIMacroFile *Parent,
Index: test/Modules/ModuleDebugInfo.cpp
===
--- test/Modules/ModuleDebugInfo.cpp
+++ test/Modules/ModuleDebugInfo.cpp
@@ -48,7 +48,7 @@
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
 // CHECK-NOT:  name:
 // CHECK-SAME: )
-// CHECK: !DIEnumerator(name: "e5", value: 5)
+// CHECK: !DIEnumerator(name: "e5", value: 5, isUnsigned: true)
 
 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
 // no mangled name here yet.
Index: test/CodeGen/debug-info-enum.cpp
===
--- test/CodeGen/debug-info-enum.cpp
+++ test/CodeGen/debug-info-enum.cpp
@@ -0,0 +1,100 @@
+// Test enumeration representation in debuig info metadata:
+// * test value representation for each possible underlying integer type
+// * test the integer type is as expected
+// * test the DW_AT_enum_class attribute is present (resp. absent) as expected.
+
+// RUN: %clang -target x86_64-linux -g -S -emit-llvm -o - %s | FileCheck %s
+
+
+enum class E0 : signed char {
+  A0 = -128,
+  B0 = 127,
+} x0;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E0"
+// CHECK-SAME: baseType: ![[SCHAR:[0-9]+]]
+// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: elements: ![[ELTS0:[0-9]+]]
+// CHECK: ![[SCHAR]] = !DIBasicType(name: "signed char", size: 8, encoding: DW_ATE_signed_char)
+// CHECK: ![[ELTS0]] = !{![[A0:[0-9]+]], ![[B0:[0-9]+]]}
+// CHECK: ![[A0]] = !DIEnumerator(name: "A0", value: -128)
+// CHECK: ![[B0]] = !DIEnumerator(name: "B0", value: 127)
+
+enum class E1 : unsigned char { A1 = 255 } x1;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E1"
+// CHECK-SAME: baseType: ![[UCHAR:[0-9]+]]
+// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: elements: ![[ELTS1:[0-9]+]]
+// CHECK: ![[UCHAR]] = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)
+// CHECK: ![[ELTS1]] = !{![[A1:[0-9]+]]}
+// CHECK: ![[A1]] = !DIEnumerator(name: "A1", value: 255, isUnsigned: true)
+
+enum class E2 : signed short {
+  A2 = -32768,
+  B2 = 32767,
+} x2;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E2"
+// CHECK-SAME: baseType: ![[SHORT:[0-9]+]]
+// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: elements: ![[ELTS2:[0-9]+]]
+// CHECK: ![[SHORT]] = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
+// CHECK: ![[ELTS2]] = !{![[A2:[0-9]+]], ![[B2:[0-9]+]]}
+// CHECK: ![[A2]] = !DIEnumerator(name: "A2", value: -32768)
+// CHECK: ![[B2]] = !DIEnumerator(name: "B2", value: 32767)
+
+enum class E3 : unsigned short { A3 = 65535 } x3;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E3"
+// CHECK-SAME: baseType: ![[USHORT:[0-9]+]]
+// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: elements: ![[ELTS3:[0-9]+]]
+// CHECK: ![[USHORT]] = !DIBasicType(name: "unsigned short", size: 16, encoding: DW_ATE_unsigned)
+// CHECK: ![[ELTS3]] = !{![[A

[PATCH] D42787: clang-format: do not add extra indent when wrapping last parameter

2018-02-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

We could adapt the single-argument version instead, turning:

  foo(bb +
  c);

into:

  foo(bb +
  c);


Repository:
  rC Clang

https://reviews.llvm.org/D42787



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


[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 133233.
MaskRay marked 2 inline comments as done.
MaskRay added a comment.

Fix word order of readability-simd-intrinsics


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-simd-intrinsics.rst
  test/clang-tidy/readability-simd-intrinsics.cpp

Index: test/clang-tidy/readability-simd-intrinsics.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-simd-intrinsics.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s readability-simd-intrinsics %t
+
+/ X86
+typedef long long __m128i __attribute__((vector_size(16)));
+typedef double __m256 __attribute__((vector_size(32)));
+
+__m128i _mm_add_epi32(__m128i, __m128i);
+__m256 _mm256_load_pd(double const *);
+void _mm256_store_pd(double *, __m256);
+
+int _mm_add_fake(int, int);
+
+void X86() {
+  __m128i i0, i1;
+  __m256 d0;
+
+  _mm_add_epi32(i0, i1);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::experimental::simd objects [readability-simd-intrinsics]
+  d0 = _mm256_load_pd(0);
+  _mm256_store_pd(0, d0);
+
+  _mm_add_fake(0, 1);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:
+}
+
+/ PPC
+// vector/__vector requires -maltivec, but this typedef is similar.
+typedef int vector_int __attribute__((vector_size(16)));
+
+vector_int vec_add(vector_int, vector_int);
+
+void PPC() {
+}
Index: docs/clang-tidy/checks/readability-simd-intrinsics.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-simd-intrinsics.rst
@@ -0,0 +1,32 @@
+.. title:: clang-tidy - readability-simd-intrinsics
+
+readability-simd-intrinsics
+===
+
+Finds SIMD intrinsics calls and suggests ``std::experimental::simd`` (`P0214`_) alternatives.
+
+For
+
+.. code-block:: c++
+
+  _mm_add_epi32(a, b);
+
+the check suggests an alternative:
+
+.. code-block:: c++
+
+  simd::experimental::simd::operator+
+
+Many architectures provide SIMD operations (e.g. x86 SSE/AVX, Power AltiVec/VSX,
+ARM NEON). It is common that SIMD code implementing the same algorithm, is
+written in multiple target-dispatching pieces to optimize for different
+architectures or micro-architectures.
+
+The C++ standard proposal `P0214`_ and its extensions cover many common SIMD
+operations. By migrating from target-dependent intrinsics to `P0214` operations,
+the SIMD code can be simplified and pieces for different targets can be unified.
+
+Refer to `P0214`_ for introduction and motivation for the data-parallel standard
+library.
+
+.. _P0214: http://wg21.link/p0214
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -216,6 +216,7 @@
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
+   readability-simd-intrinsics
readability-simplify-boolean-expr
readability-static-accessed-through-instance
readability-static-definition-in-anonymous-namespace
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -88,6 +88,12 @@
   Functions that have trailing returns are disallowed, except for those 
   using decltype specifiers and lambda with otherwise unutterable 
   return types.
+
+- New `readability-simd-intrinsics
+  `_ check
+
+  Warns if SIMD intrinsics are used which can be replaced by
+  ``std::experimental::simd`` operations.
 
 - New alias `hicpp-avoid-goto
   `_ to 
Index: clang-tidy/readability/SIMDIntrinsicsCheck.h
===
--- /dev/null
+++ clang-tidy/readability/SIMDIntrinsicsCheck.h
@@ -0,0 +1,35 @@
+//===--- SIMDIntrinsicsCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SIMD_INTRINSICS_CHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SIMD_INTRINSICS_CHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// Find SIMD intrinsics calls and suggest std::experimental::simd alternatives.
+///
+/// For the user-faci

[PATCH] D43026: [OpenMP] Support for implicit "declare target" functions - CodeGen patch

2018-02-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

It is impossible to understand what is going on here. We need to discuss this 
before even reviewing of this patch.




Comment at: lib/CodeGen/CGCXXABI.h:543
+   llvm::GlobalVariable *DeclPtr, bool PerformInit,
+   bool EmitInitOnly, bool EmitDtorOnly) = 0;
 

Why do you need these additional parameters?



Comment at: lib/CodeGen/CGDeclCXX.cpp:153-154
+   bool PerformInit,
+   bool EmitInitOnly,
+   bool EmitDtorOnly) {
 

Why do you need these parameters?



Comment at: lib/CodeGen/CGDeclCXX.cpp:588-590
+  if (CGM.getLangOpts().OpenMP)
+CGM.getOpenMPRuntime().registerDeviceCtorDtorLaunching(*this, *D, Addr,
+   PerformInit);

1. Check that this is the device codegen.
2. Enclose in braces



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3484-3486
+  if (Entry->second.isRegistered())
+return false;
+  return true;

Just `return !Entry->second.isRegistered();`



Comment at: lib/CodeGen/CGOpenMPRuntime.h:388
 
-/// \brief Number of entries registered so far.
-unsigned OffloadingEntriesNum;
+/// \brief Number of ordered entries registered so far.
+unsigned OffloadingOrderedEntriesNum = 0u;

Remove `brief`s



Comment at: lib/CodeGen/CGOpenMPRuntime.h:508-509
+  OffloadEntryInfoDeviceGlobalVar()
+  : OffloadEntryInfo(OFFLOAD_ENTRY_INFO_DEVICE_GLOBAL_VAR, ~0u,
+ /*Flags=*/0u),
+Addr(nullptr) {}

Use enumeric values rather than the magical numbers.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:559-563
+  : OffloadEntryInfo(OFFLOAD_ENTRY_INFO_DEVICE_FUNCTION, ~0u,
+ /*Flags=*/0u) {}
+  explicit OffloadEntryInfoDeviceFunction(bool IsRegistered)
+  : OffloadEntryInfo(OFFLOAD_ENTRY_INFO_DEVICE_FUNCTION, ~0u,
+ /*Flags=*/0u),

Use enum constants rather than the magical numbers


Repository:
  rC Clang

https://reviews.llvm.org/D43026



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


[PATCH] D42895: [libclang] Add `CXSymbolRole role` to CXIdxEntityRefInfo

2018-02-07 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: include/clang-c/Index.h:6159
+   */
+  CXSymbolRole role;
 } CXIdxEntityRefInfo;

Why do we need to store both `CXIdxEntityRefKind` and `CXSymbolRole`? Can we 
store just `CXSymbolRole`?
Is this for compatibility with existing clients?

If so, maybe we could:
- remove `Implicit` and `Direct` from the `CXSymbolRole`
- keep it only in `CXIdxEntityRefKind`
- not deprecate the `CXIdxEntityRefKind`



Comment at: tools/libclang/CXIndexDataConsumer.cpp:154
+  // CXSymbolRole is synchronized with clang::index::SymbolRole.
+  return CXSymbolRole(static_cast(Role));
+}

`SymbolRoleSet` seems to have more roles not covered by `CXSymbolRole`.
Should they be accepted by this function? 
If yes, maybe zero those bits?
If no, maybe add an assert?


The extra roles are:
```
  RelationChildOf = 1 << 9,
  RelationBaseOf  = 1 << 10,
  RelationOverrideOf  = 1 << 11,
  RelationReceivedBy  = 1 << 12,
  RelationCalledBy= 1 << 13,
  RelationExtendedBy  = 1 << 14,
  RelationAccessorOf  = 1 << 15,
  RelationContainedBy = 1 << 16,
  RelationIBTypeOf= 1 << 17,
  RelationSpecializationOf = 1 << 18,
```


Repository:
  rC Clang

https://reviews.llvm.org/D42895



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


[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 133237.
MaskRay added a comment.

Add check-specific option `Experimental`

  StringRef Std;
  if (Result.Context->getLangOpts().CPlusPlus2a) {
Std = "std";
  } else if (Result.Context->getLangOpts().CPlusPlus11 && Experimental) {
// libcxx implementation backports it to C++11 std::experimental::simd.
Std = "std::experimental";
  } else
return;


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-simd-intrinsics.rst
  test/clang-tidy/readability-simd-intrinsics.cpp

Index: test/clang-tidy/readability-simd-intrinsics.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-simd-intrinsics.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s readability-simd-intrinsics %t
+
+/ X86
+typedef long long __m128i __attribute__((vector_size(16)));
+typedef double __m256 __attribute__((vector_size(32)));
+
+__m128i _mm_add_epi32(__m128i, __m128i);
+__m256 _mm256_load_pd(double const *);
+void _mm256_store_pd(double *, __m256);
+
+int _mm_add_fake(int, int);
+
+void X86() {
+  __m128i i0, i1;
+  __m256 d0;
+
+  _mm_add_epi32(i0, i1);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::experimental::simd objects [readability-simd-intrinsics]
+  d0 = _mm256_load_pd(0);
+  _mm256_store_pd(0, d0);
+
+  _mm_add_fake(0, 1);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:
+}
+
+/ PPC
+// vector/__vector requires -maltivec, but this typedef is similar.
+typedef int vector_int __attribute__((vector_size(16)));
+
+vector_int vec_add(vector_int, vector_int);
+
+void PPC() {
+}
Index: docs/clang-tidy/checks/readability-simd-intrinsics.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-simd-intrinsics.rst
@@ -0,0 +1,32 @@
+.. title:: clang-tidy - readability-simd-intrinsics
+
+readability-simd-intrinsics
+===
+
+Finds SIMD intrinsics calls and suggests ``std::experimental::simd`` (`P0214`_) alternatives.
+
+For
+
+.. code-block:: c++
+
+  _mm_add_epi32(a, b);
+
+the check suggests an alternative:
+
+.. code-block:: c++
+
+  simd::experimental::simd::operator+
+
+Many architectures provide SIMD operations (e.g. x86 SSE/AVX, Power AltiVec/VSX,
+ARM NEON). It is common that SIMD code implementing the same algorithm, is
+written in multiple target-dispatching pieces to optimize for different
+architectures or micro-architectures.
+
+The C++ standard proposal `P0214`_ and its extensions cover many common SIMD
+operations. By migrating from target-dependent intrinsics to `P0214` operations,
+the SIMD code can be simplified and pieces for different targets can be unified.
+
+Refer to `P0214`_ for introduction and motivation for the data-parallel standard
+library.
+
+.. _P0214: http://wg21.link/p0214
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -216,6 +216,7 @@
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
+   readability-simd-intrinsics
readability-simplify-boolean-expr
readability-static-accessed-through-instance
readability-static-definition-in-anonymous-namespace
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -88,6 +88,12 @@
   Functions that have trailing returns are disallowed, except for those 
   using decltype specifiers and lambda with otherwise unutterable 
   return types.
+
+- New `readability-simd-intrinsics
+  `_ check
+
+  Warns if SIMD intrinsics are used which can be replaced by
+  ``std::experimental::simd`` operations.
 
 - New alias `hicpp-avoid-goto
   `_ to 
Index: clang-tidy/readability/SIMDIntrinsicsCheck.h
===
--- /dev/null
+++ clang-tidy/readability/SIMDIntrinsicsCheck.h
@@ -0,0 +1,41 @@
+//===--- SIMDIntrinsicsCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SIMD_INTRINSICS_CHECK_H
+#define LLVM_CLANG_TOOLS_EXTR

[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 133239.
MaskRay added a comment.

Use unnamed namespace to enclose AST_MATCHER and TrySuggest*


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-simd-intrinsics.rst
  test/clang-tidy/readability-simd-intrinsics.cpp

Index: test/clang-tidy/readability-simd-intrinsics.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-simd-intrinsics.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s readability-simd-intrinsics %t
+
+/ X86
+typedef long long __m128i __attribute__((vector_size(16)));
+typedef double __m256 __attribute__((vector_size(32)));
+
+__m128i _mm_add_epi32(__m128i, __m128i);
+__m256 _mm256_load_pd(double const *);
+void _mm256_store_pd(double *, __m256);
+
+int _mm_add_fake(int, int);
+
+void X86() {
+  __m128i i0, i1;
+  __m256 d0;
+
+  _mm_add_epi32(i0, i1);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::experimental::simd objects [readability-simd-intrinsics]
+  d0 = _mm256_load_pd(0);
+  _mm256_store_pd(0, d0);
+
+  _mm_add_fake(0, 1);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:
+}
+
+/ PPC
+// vector/__vector requires -maltivec, but this typedef is similar.
+typedef int vector_int __attribute__((vector_size(16)));
+
+vector_int vec_add(vector_int, vector_int);
+
+void PPC() {
+}
Index: docs/clang-tidy/checks/readability-simd-intrinsics.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-simd-intrinsics.rst
@@ -0,0 +1,32 @@
+.. title:: clang-tidy - readability-simd-intrinsics
+
+readability-simd-intrinsics
+===
+
+Finds SIMD intrinsics calls and suggests ``std::experimental::simd`` (`P0214`_) alternatives.
+
+For
+
+.. code-block:: c++
+
+  _mm_add_epi32(a, b);
+
+the check suggests an alternative:
+
+.. code-block:: c++
+
+  simd::experimental::simd::operator+
+
+Many architectures provide SIMD operations (e.g. x86 SSE/AVX, Power AltiVec/VSX,
+ARM NEON). It is common that SIMD code implementing the same algorithm, is
+written in multiple target-dispatching pieces to optimize for different
+architectures or micro-architectures.
+
+The C++ standard proposal `P0214`_ and its extensions cover many common SIMD
+operations. By migrating from target-dependent intrinsics to `P0214` operations,
+the SIMD code can be simplified and pieces for different targets can be unified.
+
+Refer to `P0214`_ for introduction and motivation for the data-parallel standard
+library.
+
+.. _P0214: http://wg21.link/p0214
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -216,6 +216,7 @@
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
+   readability-simd-intrinsics
readability-simplify-boolean-expr
readability-static-accessed-through-instance
readability-static-definition-in-anonymous-namespace
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -88,6 +88,12 @@
   Functions that have trailing returns are disallowed, except for those 
   using decltype specifiers and lambda with otherwise unutterable 
   return types.
+
+- New `readability-simd-intrinsics
+  `_ check
+
+  Warns if SIMD intrinsics are used which can be replaced by
+  ``std::experimental::simd`` operations.
 
 - New alias `hicpp-avoid-goto
   `_ to 
Index: clang-tidy/readability/SIMDIntrinsicsCheck.h
===
--- /dev/null
+++ clang-tidy/readability/SIMDIntrinsicsCheck.h
@@ -0,0 +1,41 @@
+//===--- SIMDIntrinsicsCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SIMD_INTRINSICS_CHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SIMD_INTRINSICS_CHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// Find SIMD intrinsics calls and suggest std::experimental::simd alternatives.
+///
+/// For the user-facing documentation see:
+/// 

[PATCH] D41629: [libcxx] Improve accuracy of complex asinh and acosh

2018-02-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

This all looks good to me.
I think that one more test should be added - and that's one that tests `__sqr` 
directly.
Since that's not a public routine, the test should go in 
"test/libcxx/numerics/complex.number"


https://reviews.llvm.org/D41629



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


[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 2 inline comments as done.
MaskRay added inline comments.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:75
+  // libcxx implementation of std::experimental::simd requires at least C++11.
+  if (!Result.Context->getLangOpts().CPlusPlus11)
+return;

lebedev.ri wrote:
> Is it reasonable to suggest to use ``?
> I would guess it should be `CPlusPlus2a`
Added a check-specific option `readability-simd-intrinsics.Experiment`.





Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:84
+  // SIMD intrinsic call.
+  const FunctionDecl *Callee = Call->getDirectCallee();
+  if (!Callee)

lebedev.ri wrote:
> I would refactor this as astmatcher, at least a local one, e.g. something like
> ```
> AST_MATCHER(CallExpr, hasDirectCallee) {
>   return Node.getDirectCallee();
> }
> ```
> +
> ```
> void SIMDIntrinsicsCheck::registerMatchers(MatchFinder *Finder) {
>   Finder->addMatcher(
>   callExpr(callee(
> +allOf(
>  
> functionDecl(matchesName("^::(_mm_|_mm256_|_mm512_|vec_)")
> +  , hasDirectCallee()
> +)
>)),
>unless(isExpansionInSystemHeader()))
>   .bind("call"),
>   this);
> }
> ```
> Unless of course there is already a narrower that does that
```
AST_MATCHER(CallExpr, hasDirectCallee) {
  return Node.getDirectCallee();
}
```

looks too overkill and I still have to call `Call->getDirectCallee()` in 
`SIMDIntrinsicsCheck::check` and then `Callee->getName()`. I decide to keep it 
as is.


That said, I should also study why `AST_MATCHER(CallExpr, hasDirectCallee)` 
does not compile:
```
../tools/clang/tools/extra/clang-tidy/readability/SIMDIntrinsicsCheck.cpp:95:16:
 error: call to 'callee' is ambiguous
  callExpr(callee(allOf(functionDecl(allOf(
   ^~
../tools/clang/include/clang/ASTMatchers/ASTMatchers.h:2811:25: note: candidate 
function
AST_MATCHER_P(CallExpr, callee, internal::Matcher,
^
../tools/clang/include/clang/ASTMatchers/ASTMatchers.h:2827:34: note: candidate 
function
AST_MATCHER_P_OVERLOAD(CallExpr, callee, internal::Matcher, InnerMatcher,
```



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:87
+return;
+  bool IsVector = Callee->getReturnType()->isVectorType();
+  for (const ParmVarDecl *Parm : Callee->parameters()) {

lebedev.ri wrote:
> Same here, i *think* something like this would be better?
> ```
> AST_MATCHER(FunctionDecl, isVectorFunction) {
>  bool IsVector = Node.getReturnType()->isVectorType();
>   for (const ParmVarDecl *Parm : Node.parameters()) {
> QualType Type = Parm->getType();
> if (Type->isPointerType())
>   Type = Type->getPointeeType();
> if (Type->isVectorType())
>   IsVector = true;
> 
>   return IsVector;
> }
> ```
> +
> ```
> void SIMDIntrinsicsCheck::registerMatchers(MatchFinder *Finder) {
>   Finder->addMatcher(
>   callExpr(callee(
> allOf(
>  functionDecl(
> +   allOf(
>  matchesName("^::(_mm_|_mm256_|_mm512_|vec_)")
> + , isVectorFunction()
> +   )
>   , hasDirectCallee()
> )
>)),
>unless(isExpansionInSystemHeader()))
>   .bind("call"),
>   this);
> }
> ```
Thanks! Added isVectorFunction. I guess I may should use unnamed namespace for 
AST_MATCHER, but do I also need the unnamed namespace to enclose TrySuggestPPC 
and TrySuggestX86?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983



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


[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 3 inline comments as done.
MaskRay added inline comments.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:26
+
+  static const llvm::StringMap Mapping{
+// [simd.alg]

lebedev.ri wrote:
> You probably want to move `Mapping` out of the function.
Does keeping `  static const llvm::StringMap Mapping{ ... }` 
inside the function avoid a global constructor? The blacklist will surely be 
modified to cover more operations after the revision 



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:34
+{"sub", "operator- on std::experimental::simd objects"},
+{"mul", "operator* on std::experimental::simd objects"},
+  };

lebedev.ri wrote:
> To point the obvious, this is not exhaustive list, at least `div` is missing.
Yes, the blacklist will be modified to cover more instructions.

Another fun fact is that though `_mm_div_epi*` are listed in Intel's intrinsics 
guide, no there are no mapping hardware instructions and the functions only 
exist in ICC/ICPC (I guess) not in clang/lib/Headers/*.h



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:55
+  // [simd.binary]
+  if (Name.startswith("add_"))
+return "operator+ on std::experimental::simd objects";

lebedev.ri wrote:
> This function was not updated to use the `Mapping` map.
This is because on Power, these functions are overloaded `vec_add` `vec_sub` ...
But on x86, there are suffixes, e.g. `_mm_add_epi32`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983



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


[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:77
+void SIMDIntrinsicsCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  
callExpr(callee(functionDecl(matchesName("^::(_mm_|_mm256_|_mm512_|vec_)"))),

Eugene.Zelenko wrote:
> MaskRay wrote:
> > Eugene.Zelenko wrote:
> > > You should enable this check only when compiling in appropriate C++ 
> > > version. See getLangOpts() usage in other checks.
> > Thx, I didn't know getLangOpts() before.
> > 
> > I think even in `-x c` mode, `::` is still the prefix of an identifier.
> > 
> >   matchesName("^(_mm_|_mm256_|_mm512_|vec_)")
> > 
> > doesn't match anything but 
> > 
> >   matchesName("^::(_mm_|_mm256_|_mm512_|vec_)")
> > 
> > matches.
> > 
> > verified via `clang-tidy -checks='-*,readability-simd-intrinsics' a.c -- 
> > -xc`
> > 
> Check should be enabled only for C++ version which has 
> std::experimental::simd implementation, so this is why you need to use 
> getLangOpts().
I think this is still not done, 
```
Experimental(Options.getLocalOrGlobal("Experimental", 1) != 0)
```
means it will still be on by default for C++11



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:106
+  } else
+return;
+

This logic should be in the beginning of `registerMatchers()`, so this wouldn't 
even be registered/called if it won't do anything.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.h:27
+  : ClangTidyCheck(Name, Context),
+Experimental(Options.getLocalOrGlobal("Experimental", 1) != 0) {}
+

I //think// usually this is in `.cpp` file


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983



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


[PATCH] D41992: [libcxx] Avoid spurious construction of valarray elements

2018-02-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

This LGTM.




Comment at: include/valarray:3728
+{
+__clear();
 if (__n)

I thought that you had lost an exception guarantee here, but it turns out that 
there wasn't one before.  If the allocation fails, you are left with an empty 
array instead of the old contents.




https://reviews.llvm.org/D41992



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


[PATCH] D42924: Don't pass ForDefinition_t in places it is redundant.

2018-02-07 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola added a comment.

Ping.


https://reviews.llvm.org/D42924



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


[PATCH] D42895: [libclang] Add `CXSymbolRole role` to CXIdxEntityRefInfo

2018-02-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 2 inline comments as done.
MaskRay added inline comments.



Comment at: include/clang-c/Index.h:6159
+   */
+  CXSymbolRole role;
 } CXIdxEntityRefInfo;

ilya-biryukov wrote:
> Why do we need to store both `CXIdxEntityRefKind` and `CXSymbolRole`? Can we 
> store just `CXSymbolRole`?
> Is this for compatibility with existing clients?
> 
> If so, maybe we could:
> - remove `Implicit` and `Direct` from the `CXSymbolRole`
> - keep it only in `CXIdxEntityRefKind`
> - not deprecate the `CXIdxEntityRefKind`
I think `CXIdxEntityRefKind` should be deprecated but for compatibility we do 
not remove the field for this minor version upgrade. But they can be removed 
after a major version upgrade.

For what I have observed, `Implicit` is only used by Objective-C



Comment at: tools/libclang/CXIndexDataConsumer.cpp:154
+  // CXSymbolRole is synchronized with clang::index::SymbolRole.
+  return CXSymbolRole(static_cast(Role));
+}

ilya-biryukov wrote:
> `SymbolRoleSet` seems to have more roles not covered by `CXSymbolRole`.
> Should they be accepted by this function? 
> If yes, maybe zero those bits?
> If no, maybe add an assert?
> 
> 
> The extra roles are:
> ```
>   RelationChildOf = 1 << 9,
>   RelationBaseOf  = 1 << 10,
>   RelationOverrideOf  = 1 << 11,
>   RelationReceivedBy  = 1 << 12,
>   RelationCalledBy= 1 << 13,
>   RelationExtendedBy  = 1 << 14,
>   RelationAccessorOf  = 1 << 15,
>   RelationContainedBy = 1 << 16,
>   RelationIBTypeOf= 1 << 17,
>   RelationSpecializationOf = 1 << 18,
> ```
Yes, it has more relations, but most are only used by Objective-C. In all 
test/Index tests, I have only seen `RelationContainedBy` used for .cpp files. 
Many have not occurred in .m files. So I do not want to expose them, at least 
for now.




Repository:
  rC Clang

https://reviews.llvm.org/D42895



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


[PATCH] D42887: [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF marked 5 inline comments as done.
EricWF added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:3269-3274
+  const bool IsAssertBuild =
 #ifdef NDEBUG
-  CmdArgs.push_back("-disable-llvm-verifier");
-  // Discard LLVM value names in -asserts builds.
-  CmdArgs.push_back("-discard-value-names");
+  false;
+#else
+  true;
 #endif

bogner wrote:
> It might be a few more characters, but I feel like this is more readable if 
> you put entire statements in the branches of the #if, ie:
> 
> #ifdef NDEBUG
>   const bool IsAssertBuild = false;
> #else
>   const bool IsAssertBuild = true;
> #endif
Ack. Done.



Comment at: test/Driver/clang_f_opts.c:522
+// RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck 
-check-prefix=CHECK-DISCARD-NAMES %s
+// RUN: %clang -### -S -fno-discard-value-names %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-DISCARD-NAMES %s
+// CHECK-DISCARD-NAMES: "-discard-value-names"

lebedev.ri wrote:
> I wonder if it is also possible to check that if neither of 
> `-f[no-]discard-value-names` is specified, what happens.
> The caveat is of course the asserts-vs-no-asserts build type.
I don't think so, at least not easily and without changes to the `lit` 
configuration.

It's gone untested this long, I would love to get this patch in without being 
responsible for adding those tests.



https://reviews.llvm.org/D42887



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


[PATCH] D42887: [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 133251.
EricWF marked an inline comment as done.
EricWF added a comment.

- Fix documentation as requested.
- Put entire statement inside of `#ifdef` blocks.


https://reviews.llvm.org/D42887

Files:
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/clang_f_opts.c


Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -517,3 +517,8 @@
 // RUN: %clang -### -S %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-CF-PROTECTION-BRANCH %s
 // CHECK-CF-PROTECTION-BRANCH: -fcf-protection=branch
 // CHECK-NO-CF-PROTECTION-BRANCH-NOT: -fcf-protection=branch
+
+// RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck 
-check-prefix=CHECK-DISCARD-NAMES %s
+// RUN: %clang -### -S -fno-discard-value-names %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-DISCARD-NAMES %s
+// CHECK-DISCARD-NAMES: "-discard-value-names"
+// CHECK-NO-DISCARD-NAMES-NOT: "-discard-value-names"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3266,13 +3266,24 @@
   if (!C.isForDiagnostics())
 CmdArgs.push_back("-disable-free");
 
-// Disable the verification pass in -asserts builds.
 #ifdef NDEBUG
-  CmdArgs.push_back("-disable-llvm-verifier");
-  // Discard LLVM value names in -asserts builds.
-  CmdArgs.push_back("-discard-value-names");
+  const bool IsAssertBuild = false;
+#else
+  const bool IsAssertBuild = true;
 #endif
 
+  // Disable the verification pass in -asserts builds.
+  if (!IsAssertBuild)
+CmdArgs.push_back("disable-llvm-verifier");
+
+  // Discard value names in assert builds unless otherwise specified.
+  if (const Arg *A = Args.getLastArg(options::OPT_fdiscard_value_names,
+ options::OPT_fno_discard_value_names)) {
+if (A->getOption().matches(options::OPT_fdiscard_value_names))
+  CmdArgs.push_back("-discard-value-names");
+  } else if (!IsAssertBuild)
+CmdArgs.push_back("-discard-value-names");
+
   // Set the main file name, so that debug info works even with
   // -save-temps.
   CmdArgs.push_back("-main-file-name");
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -790,6 +790,10 @@
 HelpText<"Print a template comparison tree for differing templates">;
 def fdeclspec : Flag<["-"], "fdeclspec">, Group,
   HelpText<"Allow __declspec as a keyword">, Flags<[CC1Option]>;
+def fdiscard_value_names : Flag<["-"], "fdiscard-value-names">, 
Group,
+  HelpText<"Discard value names in LLVM IR">, Flags<[DriverOption]>;
+def fno_discard_value_names : Flag<["-"], "fno-discard-value-names">, 
Group,
+  HelpText<"Do not discard value names in LLVM IR">, Flags<[DriverOption]>;
 def fdollars_in_identifiers : Flag<["-"], "fdollars-in-identifiers">, 
Group,
   HelpText<"Allow '$' in identifiers">, Flags<[CC1Option]>;
 def fdwarf2_cfi_asm : Flag<["-"], "fdwarf2-cfi-asm">, 
Group;
Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1855,6 +1855,27 @@
   must come first.)
 
 
+Controlling LLVM IR Output
+--
+
+Controlling Value Names in LLVM IR
+^^
+
+Emitting value names in LLVM IR increases the size and verbosity of the IR.
+By default, value names are only emitted in assertion-enabled builds of Clang.
+However, when reading IR it can be useful to re-enable the emission of value
+names to improve readability.
+
+.. option:: -fdiscard-value-names
+
+  Discard value names when generating LLVM IR.
+
+.. option:: -fno-discard-value-names
+
+  Do not discard value names when generating LLVM IR. This option can be used
+  to re-enable names for release builds of Clang.
+
+
 Comment Parsing Options
 ---
 


Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -517,3 +517,8 @@
 // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CF-PROTECTION-BRANCH %s
 // CHECK-CF-PROTECTION-BRANCH: -fcf-protection=branch
 // CHECK-NO-CF-PROTECTION-BRANCH-NOT: -fcf-protection=branch
+
+// RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-DISCARD-NAMES %s
+// RUN: %clang -### -S -fno-discard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-NO-DISCARD-NAMES %s
+// CHECK-DISCARD-NAMES: "-discard-value-names"
+// CHECK-NO-DISCARD-NAMES-NOT: "-discard-value-names"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/Too

[PATCH] D42924: Don't pass ForDefinition_t in places it is redundant.

2018-02-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

I'm guessing things were structured this way so that a function definition 
could have its visibility set before giving it a body, i.e. it would look like 
a declaration, but the visibility should be "for a definition". If everything 
works I suppose we don't do that anymore.


https://reviews.llvm.org/D42924



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


[PATCH] D42887: [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D42887



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


r324498 - [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Feb  7 10:36:51 2018
New Revision: 324498

URL: http://llvm.org/viewvc/llvm-project?rev=324498&view=rev
Log:
[Driver] Add option to manually control discarding value names in LLVM IR.

Summary:
Currently, assertion-disabled Clang builds emit value names when generating 
LLVM IR. This is controlled by the `NDEBUG` macro, and is not easily 
overridable. In order to get IR output containing names from a release build of 
Clang, the user must manually construct the CC1 invocation w/o the 
`-discard-value-names` option. This is less than ideal.

For example, Godbolt uses a release build of Clang, and so when asked to emit 
LLVM IR the result lacks names, making it harder to read. Manually invoking CC1 
on Compiler Explorer is not feasible.

This patch adds the driver options `-fdiscard-value-names` and 
`-fno-discard-value-names` which allow the user to override the default 
behavior. If neither is specified, the old behavior remains.

Reviewers: erichkeane, aaron.ballman, lebedev.ri

Reviewed By: aaron.ballman

Subscribers: bogner, cfe-commits

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

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=324498&r1=324497&r2=324498&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Wed Feb  7 10:36:51 2018
@@ -1855,6 +1855,27 @@ features. You can "tune" the debug info
   must come first.)
 
 
+Controlling LLVM IR Output
+--
+
+Controlling Value Names in LLVM IR
+^^
+
+Emitting value names in LLVM IR increases the size and verbosity of the IR.
+By default, value names are only emitted in assertion-enabled builds of Clang.
+However, when reading IR it can be useful to re-enable the emission of value
+names to improve readability.
+
+.. option:: -fdiscard-value-names
+
+  Discard value names when generating LLVM IR.
+
+.. option:: -fno-discard-value-names
+
+  Do not discard value names when generating LLVM IR. This option can be used
+  to re-enable names for release builds of Clang.
+
+
 Comment Parsing Options
 ---
 

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=324498&r1=324497&r2=324498&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Feb  7 10:36:51 2018
@@ -790,6 +790,10 @@ def fdiagnostics_show_template_tree : Fl
 HelpText<"Print a template comparison tree for differing templates">;
 def fdeclspec : Flag<["-"], "fdeclspec">, Group,
   HelpText<"Allow __declspec as a keyword">, Flags<[CC1Option]>;
+def fdiscard_value_names : Flag<["-"], "fdiscard-value-names">, 
Group,
+  HelpText<"Discard value names in LLVM IR">, Flags<[DriverOption]>;
+def fno_discard_value_names : Flag<["-"], "fno-discard-value-names">, 
Group,
+  HelpText<"Do not discard value names in LLVM IR">, Flags<[DriverOption]>;
 def fdollars_in_identifiers : Flag<["-"], "fdollars-in-identifiers">, 
Group,
   HelpText<"Allow '$' in identifiers">, Flags<[CC1Option]>;
 def fdwarf2_cfi_asm : Flag<["-"], "fdwarf2-cfi-asm">, 
Group;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=324498&r1=324497&r2=324498&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Feb  7 10:36:51 2018
@@ -3266,13 +3266,24 @@ void Clang::ConstructJob(Compilation &C,
   if (!C.isForDiagnostics())
 CmdArgs.push_back("-disable-free");
 
-// Disable the verification pass in -asserts builds.
 #ifdef NDEBUG
-  CmdArgs.push_back("-disable-llvm-verifier");
-  // Discard LLVM value names in -asserts builds.
-  CmdArgs.push_back("-discard-value-names");
+  const bool IsAssertBuild = false;
+#else
+  const bool IsAssertBuild = true;
 #endif
 
+  // Disable the verification pass in -asserts builds.
+  if (!IsAssertBuild)
+CmdArgs.push_back("disable-llvm-verifier");
+
+  // Discard value names in assert builds unless otherwise specified.
+  if (const Arg *A = Args.getLastArg(options::OPT_fdiscard_value_names,
+ options::OPT_fno_discard_value_names)) {
+if (A->getOption().matches(options::OPT_fdiscard_value_names))
+  CmdArgs.push_back("-discard-value-names");
+  } else if (!IsAssertBuild)
+CmdArgs.push_back("-discard-value-names");
+
   // Set the main file

[PATCH] D42887: [Driver] Add option to manually control discarding value names in LLVM IR.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC324498: [Driver] Add option to manually control discarding 
value names in LLVM IR. (authored by EricWF, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D42887

Files:
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/clang_f_opts.c


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1855,6 +1855,27 @@
   must come first.)
 
 
+Controlling LLVM IR Output
+--
+
+Controlling Value Names in LLVM IR
+^^
+
+Emitting value names in LLVM IR increases the size and verbosity of the IR.
+By default, value names are only emitted in assertion-enabled builds of Clang.
+However, when reading IR it can be useful to re-enable the emission of value
+names to improve readability.
+
+.. option:: -fdiscard-value-names
+
+  Discard value names when generating LLVM IR.
+
+.. option:: -fno-discard-value-names
+
+  Do not discard value names when generating LLVM IR. This option can be used
+  to re-enable names for release builds of Clang.
+
+
 Comment Parsing Options
 ---
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -790,6 +790,10 @@
 HelpText<"Print a template comparison tree for differing templates">;
 def fdeclspec : Flag<["-"], "fdeclspec">, Group,
   HelpText<"Allow __declspec as a keyword">, Flags<[CC1Option]>;
+def fdiscard_value_names : Flag<["-"], "fdiscard-value-names">, 
Group,
+  HelpText<"Discard value names in LLVM IR">, Flags<[DriverOption]>;
+def fno_discard_value_names : Flag<["-"], "fno-discard-value-names">, 
Group,
+  HelpText<"Do not discard value names in LLVM IR">, Flags<[DriverOption]>;
 def fdollars_in_identifiers : Flag<["-"], "fdollars-in-identifiers">, 
Group,
   HelpText<"Allow '$' in identifiers">, Flags<[CC1Option]>;
 def fdwarf2_cfi_asm : Flag<["-"], "fdwarf2-cfi-asm">, 
Group;
Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -517,3 +517,8 @@
 // RUN: %clang -### -S %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-CF-PROTECTION-BRANCH %s
 // CHECK-CF-PROTECTION-BRANCH: -fcf-protection=branch
 // CHECK-NO-CF-PROTECTION-BRANCH-NOT: -fcf-protection=branch
+
+// RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck 
-check-prefix=CHECK-DISCARD-NAMES %s
+// RUN: %clang -### -S -fno-discard-value-names %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-DISCARD-NAMES %s
+// CHECK-DISCARD-NAMES: "-discard-value-names"
+// CHECK-NO-DISCARD-NAMES-NOT: "-discard-value-names"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3266,13 +3266,24 @@
   if (!C.isForDiagnostics())
 CmdArgs.push_back("-disable-free");
 
-// Disable the verification pass in -asserts builds.
 #ifdef NDEBUG
-  CmdArgs.push_back("-disable-llvm-verifier");
-  // Discard LLVM value names in -asserts builds.
-  CmdArgs.push_back("-discard-value-names");
+  const bool IsAssertBuild = false;
+#else
+  const bool IsAssertBuild = true;
 #endif
 
+  // Disable the verification pass in -asserts builds.
+  if (!IsAssertBuild)
+CmdArgs.push_back("disable-llvm-verifier");
+
+  // Discard value names in assert builds unless otherwise specified.
+  if (const Arg *A = Args.getLastArg(options::OPT_fdiscard_value_names,
+ options::OPT_fno_discard_value_names)) {
+if (A->getOption().matches(options::OPT_fdiscard_value_names))
+  CmdArgs.push_back("-discard-value-names");
+  } else if (!IsAssertBuild)
+CmdArgs.push_back("-discard-value-names");
+
   // Set the main file name, so that debug info works even with
   // -save-temps.
   CmdArgs.push_back("-main-file-name");


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1855,6 +1855,27 @@
   must come first.)
 
 
+Controlling LLVM IR Output
+--
+
+Controlling Value Names in LLVM IR
+^^
+
+Emitting value names in LLVM IR increases the size and verbosity of the IR.
+By default, value names are only emitted in assertion-enabled builds of Clang.
+However, when reading IR it can be useful to re-enable the emission of value
+names to improve readability.
+
+.. option:: -fdiscard-value-names
+
+  Discard value names when generating LLVM IR.
+
+.. option:: -fno-discard-value-names
+
+  Do not discard value names when generating LLVM IR. This option can be used
+  to re-enable names for re

[PATCH] D43017: Clean up use of C allocation functions

2018-02-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

https://reviews.llvm.org/D43017



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


[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 133255.
MaskRay marked an inline comment as done.
MaskRay added a comment.

readability-simd-intrinsics.rst


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.cpp
  clang-tidy/readability/SIMDIntrinsicsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-simd-intrinsics.rst
  test/clang-tidy/readability-simd-intrinsics.cpp

Index: test/clang-tidy/readability-simd-intrinsics.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-simd-intrinsics.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s readability-simd-intrinsics %t
+
+/ X86
+typedef long long __m128i __attribute__((vector_size(16)));
+typedef double __m256 __attribute__((vector_size(32)));
+
+__m128i _mm_add_epi32(__m128i, __m128i);
+__m256 _mm256_load_pd(double const *);
+void _mm256_store_pd(double *, __m256);
+
+int _mm_add_fake(int, int);
+
+void X86() {
+  __m128i i0, i1;
+  __m256 d0;
+
+  _mm_add_epi32(i0, i1);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::experimental::simd objects [readability-simd-intrinsics]
+  d0 = _mm256_load_pd(0);
+  _mm256_store_pd(0, d0);
+
+  _mm_add_fake(0, 1);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:
+}
+
+/ PPC
+// vector/__vector requires -maltivec, but this typedef is similar.
+typedef int vector_int __attribute__((vector_size(16)));
+
+vector_int vec_add(vector_int, vector_int);
+
+void PPC() {
+}
Index: docs/clang-tidy/checks/readability-simd-intrinsics.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-simd-intrinsics.rst
@@ -0,0 +1,42 @@
+.. title:: clang-tidy - readability-simd-intrinsics
+
+readability-simd-intrinsics
+===
+
+Finds SIMD intrinsics calls and suggests ``std::experimental::simd`` (`P0214`_) alternatives.
+
+For
+
+.. code-block:: c++
+
+  _mm_add_epi32(a, b);
+
+the check suggests an alternative:
+
+.. code-block:: c++
+
+  simd::experimental::simd::operator+
+
+Many architectures provide SIMD operations (e.g. x86 SSE/AVX, Power AltiVec/VSX,
+ARM NEON). It is common that SIMD code implementing the same algorithm, is
+written in multiple target-dispatching pieces to optimize for different
+architectures or micro-architectures.
+
+The C++ standard proposal `P0214`_ and its extensions cover many common SIMD
+operations. By migrating from target-dependent intrinsics to `P0214` operations,
+the SIMD code can be simplified and pieces for different targets can be unified.
+
+Refer to `P0214`_ for introduction and motivation for the data-parallel standard
+library.
+
+Options
+---
+
+.. option:: Experimental
+
+   If set to zero, the check will be enabled for ``-std=c++2a``. If non-zero,
+   the check will be enabled for ``-std=c++11`` or above (libc++
+   ``std::experimental::simd`` implementation backports `P0214`_ to C++11).
+   Default is ``1``.
+
+.. _P0214: http://wg21.link/p0214
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -216,6 +216,7 @@
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
+   readability-simd-intrinsics
readability-simplify-boolean-expr
readability-static-accessed-through-instance
readability-static-definition-in-anonymous-namespace
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -88,6 +88,12 @@
   Functions that have trailing returns are disallowed, except for those 
   using decltype specifiers and lambda with otherwise unutterable 
   return types.
+
+- New `readability-simd-intrinsics
+  `_ check
+
+  Warns if SIMD intrinsics are used which can be replaced by
+  ``std::experimental::simd`` operations.
 
 - New alias `hicpp-avoid-goto
   `_ to 
Index: clang-tidy/readability/SIMDIntrinsicsCheck.h
===
--- /dev/null
+++ clang-tidy/readability/SIMDIntrinsicsCheck.h
@@ -0,0 +1,41 @@
+//===--- SIMDIntrinsicsCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_SIMD_INTRINSICS

[PATCH] D43016: Fix for #31362 - ms_abi is implemented incorrectly for larger values (>=16 bytes).

2018-02-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

These ABIInfo classes don't have any state, so just building one on the stack 
as needed is the way to go. Thanks for the fix!


Repository:
  rC Clang

https://reviews.llvm.org/D43016



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


r324499 - Don't pass ForDefinition_t in places it is redundant.

2018-02-07 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb  7 11:04:41 2018
New Revision: 324499

URL: http://llvm.org/viewvc/llvm-project?rev=324499&view=rev
Log:
Don't pass ForDefinition_t in places it is redundant.

I found this while looking at the ppc failures caused by the dso_local
change.

The issue was that the patch would produce the wrong answer for
available_externally. Having ForDefinition_t available in places where
the code can just check the linkage is a bit of a foot gun.

This patch removes the ForDefiniton_t argument in places where the
linkage is already know.

Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGVTT.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/CodeGen/TargetInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=324499&r1=324498&r2=324499&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Feb  7 11:04:41 2018
@@ -240,7 +240,7 @@ llvm::Constant *CodeGenModule::getOrCrea
   getModule(), LTy, Ty.isConstant(getContext()), Linkage, Init, Name,
   nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
   GV->setAlignment(getContext().getDeclAlign(&D).getQuantity());
-  setGlobalVisibility(GV, &D, ForDefinition);
+  setGlobalVisibility(GV, &D);
 
   if (supportsCOMDAT() && GV->isWeakForLinker())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));

Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=324499&r1=324498&r2=324499&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Wed Feb  7 11:04:41 2018
@@ -100,7 +100,7 @@ CodeGenVTables::EmitVTTDefinition(llvm::
 VTT->setComdat(CGM.getModule().getOrInsertComdat(VTT->getName()));
 
   // Set the right visibility.
-  CGM.setGlobalVisibility(VTT, RD, ForDefinition);
+  CGM.setGlobalVisibility(VTT, RD);
 }
 
 llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=324499&r1=324498&r2=324499&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Feb  7 11:04:41 2018
@@ -51,7 +51,7 @@ llvm::Constant *CodeGenModule::GetAddrOf
 
 static void setThunkVisibility(CodeGenModule &CGM, const CXXMethodDecl *MD,
const ThunkInfo &Thunk, llvm::Function *Fn) {
-  CGM.setGlobalVisibility(Fn, MD, ForDefinition);
+  CGM.setGlobalVisibility(Fn, MD);
 }
 
 static void setThunkProperties(CodeGenModule &CGM, const ThunkInfo &Thunk,
@@ -730,7 +730,7 @@ CodeGenVTables::GenerateConstructionVTab
   // Create the variable that will hold the construction vtable.
   llvm::GlobalVariable *VTable =
 CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage);
-  CGM.setGlobalVisibility(VTable, RD, ForDefinition);
+  CGM.setGlobalVisibility(VTable, RD);
 
   // V-tables are always unnamed_addr.
   VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=324499&r1=324498&r2=324499&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Feb  7 11:04:41 2018
@@ -700,8 +700,7 @@ llvm::ConstantInt *CodeGenModule::getSiz
 }
 
 void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
-const NamedDecl *D,
-ForDefinition_t IsForDefinition) const 
{
+const NamedDecl *D) const {
   if (GV->hasDLLImportStorageClass())
 return;
   // Internal definitions always have default visibility.
@@ -712,8 +711,7 @@ void CodeGenModule::setGlobalVisibility(
 
   // Set visibility for definitions.
   LinkageInfo LV = D->getLinkageAndVisibility();
-  if (LV.isVisibilityExplicit() ||
-  (IsForDefinition && !GV->hasAvailableExternallyLinkage()))
+  if (LV.isVisibilityExplicit() || !GV->isDeclarationForLinker())
 GV->setVisibility(GetLLVMVisibility(LV.getVisibility()));
 }
 
@@ -1174,7 +1172,7 @@ void CodeGenModule::SetLLVMFunctionAttri
 void CodeGenModule::SetCommonAttributes(const Decl *D,
 llvm::GlobalValue *GV) {
   if (const auto *ND = dyn_cas

[PATCH] D42924: Don't pass ForDefinition_t in places it is redundant.

2018-02-07 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola closed this revision.
espindola added a comment.

r324499


https://reviews.llvm.org/D42924



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


[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Tim Shen via Phabricator via cfe-commits
timshen added inline comments.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:75
+  // libcxx implementation of std::experimental::simd requires at least C++11.
+  if (!Result.Context->getLangOpts().CPlusPlus11)
+return;

MaskRay wrote:
> lebedev.ri wrote:
> > Is it reasonable to suggest to use ``?
> > I would guess it should be `CPlusPlus2a`
> Added a check-specific option `readability-simd-intrinsics.Experiment`.
> 
> 
> Is it reasonable to suggest to use ?

I think there are two approaches to proceed:
1) We just warn the users, but don't suggest  fixes.
2) We warn and suggest  fixes, but only when a flag is 
turned on (off by default). The flag documentation should clearly include 
"suggest  API".

I'm not sure which one fits better.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983



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


r324500 - Recommit r324107.

2018-02-07 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb  7 11:16:49 2018
New Revision: 324500

URL: http://llvm.org/viewvc/llvm-project?rev=324500&view=rev
Log:
Recommit r324107.

It now includes a fix to not mark available_externally definitions as
dso_local.

Original message:

Start setting dso_local in clang.

This starts adding dso_local to clang.

The hope is to eventually have TargetMachine::shouldAssumeDsoLocal go
away. My objective for now is to move enough of it to clang to remove
the need for the TargetMachine one to handle PIE copy relocations and
-fno-plt. With that it should then be easy to implement a
-fno-copy-reloc in clang.

This patch just adds the cases where we assume a symbol to be local
based on the file being compiled for an executable or a shared
library.

Added:
cfe/trunk/test/CodeGen/dso-local-executable.c
cfe/trunk/test/CodeGenCXX/dso-local-executable.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGVTT.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGen/mbackchain-2.c
cfe/trunk/test/CodeGen/mbackchain-3.c
cfe/trunk/test/CodeGen/mips-vector-return.c
cfe/trunk/test/CodeGen/split-stacks.c
cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template.cpp
cfe/trunk/test/CodeGenCXX/float16-declarations.cpp
cfe/trunk/test/CodeGenCXX/split-stacks.cpp
cfe/trunk/test/Driver/lanai-unknown-unknown.cpp
cfe/trunk/test/Driver/le32-unknown-nacl.cpp
cfe/trunk/test/Driver/le64-unknown-unknown.cpp
cfe/trunk/test/Driver/riscv32-toolchain.c
cfe/trunk/test/Driver/riscv64-toolchain.c
cfe/trunk/test/Frontend/ast-codegen.c

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=324500&r1=324499&r2=324500&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Feb  7 11:16:49 2018
@@ -240,7 +240,7 @@ llvm::Constant *CodeGenModule::getOrCrea
   getModule(), LTy, Ty.isConstant(getContext()), Linkage, Init, Name,
   nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
   GV->setAlignment(getContext().getDeclAlign(&D).getQuantity());
-  setGlobalVisibility(GV, &D);
+  setGVProperties(GV, &D);
 
   if (supportsCOMDAT() && GV->isWeakForLinker())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
@@ -344,6 +344,7 @@ CodeGenFunction::AddInitializerToStaticV
   OldGV->getThreadLocalMode(),

CGM.getContext().getTargetAddressSpace(D.getType()));
 GV->setVisibility(OldGV->getVisibility());
+GV->setDSOLocal(OldGV->isDSOLocal());
 GV->setComdat(OldGV->getComdat());
 
 // Steal the name of the old global

Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=324500&r1=324499&r2=324500&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Wed Feb  7 11:16:49 2018
@@ -100,7 +100,7 @@ CodeGenVTables::EmitVTTDefinition(llvm::
 VTT->setComdat(CGM.getModule().getOrInsertComdat(VTT->getName()));
 
   // Set the right visibility.
-  CGM.setGlobalVisibility(VTT, RD);
+  CGM.setGVProperties(VTT, RD);
 }
 
 llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=324500&r1=324499&r2=324500&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Feb  7 11:16:49 2018
@@ -51,7 +51,7 @@ llvm::Constant *CodeGenModule::GetAddrOf
 
 static void setThunkVisibility(CodeGenModule &CGM, const CXXMethodDecl *MD,
const ThunkInfo &Thunk, llvm::Function *Fn) {
-  CGM.setGlobalVisibility(Fn, MD);
+  CGM.setGVProperties(Fn, MD);
 }
 
 static void setThunkProperties(CodeGenModule &CGM, const ThunkInfo &Thunk,
@@ -730,7 +730,7 @@ CodeGenVTables::GenerateConstructionVTab
   // Create the variable that will hold the construction vtable.
   llvm::GlobalVariable *VTable =
 CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage);
-  CGM.setGlobalVisibility(VTable, RD);
+  CGM.setGVProperties(VTable, RD);
 
   // V-tables are always unnamed_addr.
   VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=324500&r1=324499&r2=324500&view=diff
==

r324501 - Fix r324498: the commit removed the '-' before the disable-llvm-verifier flag

2018-02-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Feb  7 11:17:03 2018
New Revision: 324501

URL: http://llvm.org/viewvc/llvm-project?rev=324501&view=rev
Log:
Fix r324498: the commit removed the '-' before the disable-llvm-verifier flag

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

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=324501&r1=324500&r2=324501&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Feb  7 11:17:03 2018
@@ -3274,7 +3274,7 @@ void Clang::ConstructJob(Compilation &C,
 
   // Disable the verification pass in -asserts builds.
   if (!IsAssertBuild)
-CmdArgs.push_back("disable-llvm-verifier");
+CmdArgs.push_back("-disable-llvm-verifier");
 
   // Discard value names in assert builds unless otherwise specified.
   if (const Arg *A = Args.getLastArg(options::OPT_fdiscard_value_names,


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


[PATCH] D43033: [WinEH] Put funclet bundles on inline asm calls

2018-02-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: smeenai, majnemer.
Herald added a subscriber: eraman.

Fixes PR36247, which is where WinEHPrepare replaces inline asm in
funclets with unreachable.

Make getBundlesForFunclet return by value to simplify some call sites.


https://reviews.llvm.org/D43033

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCXX/microsoft-abi-eh-inlineasm.cpp

Index: clang/test/CodeGenCXX/microsoft-abi-eh-inlineasm.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/microsoft-abi-eh-inlineasm.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-pc-windows-msvc \
+// RUN: -fexceptions -fcxx-exceptions | FileCheck %s
+
+// Make sure calls to inline asm have funclet bundles.
+
+extern "C" void might_throw();
+extern "C" void foo() {
+  try {
+might_throw();
+  } catch (int) {
+__asm__("nop");
+  }
+}
+
+// CHECK-LABEL: define void @foo()
+// CHECK: invoke void @might_throw()
+// CHECK: %[[CATCHPAD:[^ ]*]] = catchpad within
+// CHECK: call void asm sideeffect "nop", {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -3367,6 +3367,9 @@
   ArrayRef args,
   const Twine &name = "");
 
+  SmallVector
+  getBundlesForFunclet(llvm::Value *Callee);
+
   llvm::CallSite EmitCallOrInvoke(llvm::Value *Callee,
   ArrayRef Args,
   const Twine &Name = "");
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2133,7 +2133,8 @@
   llvm::InlineAsm *IA =
 llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect,
  /* IsAlignStack */ false, AsmDialect);
-  llvm::CallInst *Result = Builder.CreateCall(IA, Args);
+  llvm::CallInst *Result =
+  Builder.CreateCall(IA, Args, getBundlesForFunclet(IA));
   Result->addAttribute(llvm::AttributeList::FunctionIndex,
llvm::Attribute::NoUnwind);
 
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3608,40 +3608,39 @@
 
 // Calls which may throw must have operand bundles indicating which funclet
 // they are nested within.
-static void
-getBundlesForFunclet(llvm::Value *Callee, llvm::Instruction *CurrentFuncletPad,
- SmallVectorImpl &BundleList) {
+SmallVector
+CodeGenFunction::getBundlesForFunclet(llvm::Value *Callee) {
+  SmallVector BundleList;
   // There is no need for a funclet operand bundle if we aren't inside a
   // funclet.
   if (!CurrentFuncletPad)
-return;
+return BundleList;
 
   // Skip intrinsics which cannot throw.
   auto *CalleeFn = dyn_cast(Callee->stripPointerCasts());
   if (CalleeFn && CalleeFn->isIntrinsic() && CalleeFn->doesNotThrow())
-return;
+return BundleList;
 
   BundleList.emplace_back("funclet", CurrentFuncletPad);
+  return BundleList;
 }
 
 /// Emits a simple call (never an invoke) to the given runtime function.
 llvm::CallInst *
 CodeGenFunction::EmitRuntimeCall(llvm::Value *callee,
  ArrayRef args,
  const llvm::Twine &name) {
-  SmallVector BundleList;
-  getBundlesForFunclet(callee, CurrentFuncletPad, BundleList);
-
-  llvm::CallInst *call = Builder.CreateCall(callee, args, BundleList, name);
+  llvm::CallInst *call =
+  Builder.CreateCall(callee, args, getBundlesForFunclet(callee), name);
   call->setCallingConv(getRuntimeCC());
   return call;
 }
 
 /// Emits a call or invoke to the given noreturn runtime function.
 void CodeGenFunction::EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee,
ArrayRef args) {
-  SmallVector BundleList;
-  getBundlesForFunclet(callee, CurrentFuncletPad, BundleList);
+  SmallVector BundleList =
+  getBundlesForFunclet(callee);
 
   if (getInvokeDest()) {
 llvm::InvokeInst *invoke = 
@@ -3684,8 +3683,8 @@
   ArrayRef Args,
   const Twine &Name) {
   llvm::BasicBlock *InvokeDest = getInvokeDest();
-  SmallVector BundleList;
-  getBundlesForFunclet(Callee, CurrentFuncletPad, BundleList);
+  SmallVector BundleList =
+  getBundlesForFunclet(Callee);
 
   llvm::Instruction *Inst;
   if (!InvokeDest)
@@ -4196,8 +4195,8 @@
   }
   llvm::BasicBlock *InvokeDest = CannotThrow ? nullptr : getInvokeDest();
 
-  SmallVector BundleList;
-  getBundlesForFunclet(CalleePtr, CurrentFuncletP

[PATCH] D42983: [clang-tidy] Add readability-simd-intrinsics check.

2018-02-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:75
+  // libcxx implementation of std::experimental::simd requires at least C++11.
+  if (!Result.Context->getLangOpts().CPlusPlus11)
+return;

timshen wrote:
> MaskRay wrote:
> > lebedev.ri wrote:
> > > Is it reasonable to suggest to use ``?
> > > I would guess it should be `CPlusPlus2a`
> > Added a check-specific option `readability-simd-intrinsics.Experiment`.
> > 
> > 
> > Is it reasonable to suggest to use ?
> 
> I think there are two approaches to proceed:
> 1) We just warn the users, but don't suggest  fixes.
> 2) We warn and suggest  fixes, but only when a flag is 
> turned on (off by default). The flag documentation should clearly include 
> "suggest  API".
> 
> I'm not sure which one fits better.
Ok, i should have commented in more words :)

I wasn't questioning the use of ``
I was questioning the whole approach of **defaulting** to issuing the warning 
as long as that header can be used with **specified** C++ standard.
E.g. there is ``, but there isn't any check to 
complain on `fopen()`/`fclose()` and friends.
(I do agree that this argument is chicken-or-the-egg problem)



Comment at: clang-tidy/readability/SIMDIntrinsicsCheck.cpp:87
+return;
+  bool IsVector = Callee->getReturnType()->isVectorType();
+  for (const ParmVarDecl *Parm : Callee->parameters()) {

MaskRay wrote:
> lebedev.ri wrote:
> > Same here, i *think* something like this would be better?
> > ```
> > AST_MATCHER(FunctionDecl, isVectorFunction) {
> >  bool IsVector = Node.getReturnType()->isVectorType();
> >   for (const ParmVarDecl *Parm : Node.parameters()) {
> > QualType Type = Parm->getType();
> > if (Type->isPointerType())
> >   Type = Type->getPointeeType();
> > if (Type->isVectorType())
> >   IsVector = true;
> > 
> >   return IsVector;
> > }
> > ```
> > +
> > ```
> > void SIMDIntrinsicsCheck::registerMatchers(MatchFinder *Finder) {
> >   Finder->addMatcher(
> >   callExpr(callee(
> > allOf(
> >  functionDecl(
> > +   allOf(
> >  matchesName("^::(_mm_|_mm256_|_mm512_|vec_)")
> > + , isVectorFunction()
> > +   )
> >   , hasDirectCallee()
> > )
> >)),
> >unless(isExpansionInSystemHeader()))
> >   .bind("call"),
> >   this);
> > }
> > ```
> Thanks! Added isVectorFunction. I guess I may should use unnamed namespace 
> for AST_MATCHER, but do I also need the unnamed namespace to enclose 
> TrySuggestPPC and TrySuggestX86?
> I may should use unnamed namespace for AST_MATCHER

I //think// so.

> do I also need the unnamed namespace to enclose TrySuggestPPC and 
> TrySuggestX86?

No, but do make those `static`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42983



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


[libcxx] r324503 - Comment on 'Review' issues

2018-02-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Feb  7 11:24:37 2018
New Revision: 324503

URL: http://llvm.org/viewvc/llvm-project?rev=324503&view=rev
Log:
Comment on 'Review' issues

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=324503&r1=324502&r2=324503&view=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Wed Feb  7 11:24:37 2018
@@ -32,7 +32,7 @@
 
 
   
-  libc++ Upcoming Metting Status
+  libc++ Upcoming Meeting Status
   
 
   This is a temporary page; please check the c++1z status here
@@ -97,7 +97,7 @@
 Issues to "Review"
 
 Issue #Issue NameMeetingStatus
-https://wg21.link/LWG2412";>2412promise::set_value() 
and promise::get_future() should not 
raceJacksonville
+https://wg21.link/LWG2412";>2412promise::set_value() 
and promise::get_future() should not 
raceJacksonvilleComplete
 https://wg21.link/LWG2682";>2682filesystem::copy()
 won't create a symlink to a directoryJacksonville
 https://wg21.link/LWG2697";>2697[concurr.ts] 
Behavior of future/shared_future unwrapping constructor when given an 
invalid futureJacksonville
 https://wg21.link/LWG2708";>2708recursive_directory_iterator::recursion_pending()
 is incorrectly specifiedJacksonville
@@ -143,14 +143,14 @@
 
 Comments about the "Review" issues
 
- 2412 - 
- 2682 - 
- 2697 - 
- 2708 - 
- 2936 - 
+ 2412 - I think we do this already
+ 2682 - Eric - don't we do this already? 
+ 2697 - No concurrency TS implementation yet
+ 2708 - Eric? 
+ 2936 - Eric - don't we do this already?
 
 
-Last Updated: 5-Feb-2018
+Last Updated: 7-Feb-2018
 
 
 


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


[PATCH] D43035: Use 'wasm' over 'wasm32' as default arch name

2018-02-07 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: cfe-commits, sunfish, aheejin, jgravelle-google, 
dschuff, jfb.

Repository:
  rC Clang

https://reviews.llvm.org/D43035

Files:
  include/clang/Basic/TargetCXXABI.h
  lib/Basic/Targets.cpp
  lib/Basic/Targets/WebAssembly.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9382,11 +9382,9 @@
 // WEBASSEMBLY32-NOT:#define __unix
 // WEBASSEMBLY32-NOT:#define __unix__
 // WEBASSEMBLY32-NEXT:#define __wasm 1
-// WEBASSEMBLY32-NEXT:#define __wasm32 1
-// WEBASSEMBLY32-NEXT:#define __wasm32__ 1
+// WEBASSEMBLY32-NEXT:#define __wasm__ 1
 // WEBASSEMBLY32-NOT:#define __wasm64
 // WEBASSEMBLY32-NOT:#define __wasm64__
-// WEBASSEMBLY32-NEXT:#define __wasm__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=wasm64-unknown-unknown \
 // RUN:   < /dev/null \
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -347,7 +347,7 @@
   case llvm::Triple::amdgcn:
 return getR600TargetGPU(Args);
 
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 return getWebAssemblyTargetCPU(Args);
   }
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -346,7 +346,7 @@
   case llvm::Triple::hexagon:
 hexagon::getHexagonTargetFeatures(D, Args, Features);
 break;
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 getWebAssemblyTargetFeatures(Args, Features);
 break;
@@ -524,7 +524,7 @@
   const llvm::Triple &Triple) {
   switch (Triple.getArch()) {
   case llvm::Triple::xcore:
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 // XCore never wants frame pointers, regardless of OS.
 // WebAssembly never wants frame pointers.
@@ -1309,7 +1309,7 @@
 return false;
 
   case llvm::Triple::xcore:
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 return true;
   }
@@ -1434,7 +1434,7 @@
 AddHexagonTargetArgs(Args, CmdArgs);
 break;
 
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 AddWebAssemblyTargetArgs(Args, CmdArgs);
 break;
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -480,7 +480,7 @@
Triple.getArch() == llvm::Triple::armeb ||
Triple.getArch() == llvm::Triple::thumb ||
Triple.getArch() == llvm::Triple::thumbeb ||
-   Triple.getArch() == llvm::Triple::wasm32 ||
+   Triple.getArch() == llvm::Triple::wasm ||
Triple.getArch() == llvm::Triple::wasm64;
   } else if (Model == "posix")
 return true;
@@ -793,7 +793,7 @@
   getTriple().getArch() == llvm::Triple::x86_64 ||
   getTriple().getArch() == llvm::Triple::arm ||
   getTriple().getArch() == llvm::Triple::aarch64 ||
-  getTriple().getArch() == llvm::Triple::wasm32 ||
+  getTriple().getArch() == llvm::Triple::wasm ||
   getTriple().getArch() == llvm::Triple::wasm64)
 Res |= CFIICall;
   return Res;
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -4193,7 +4193,7 @@
   case llvm::Triple::xcore:
 TC = llvm::make_unique(*this, Target, Args);
 break;
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 TC = llvm::make_unique(*this, Target, Args);
 break;
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -9000,7 +9000,7 @@
 return SetCGInfo(new AArch64TargetCodeGenInfo(Types, Kind));
   }
 
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 return SetCGInfo(new WebAssemblyTargetCodeGenInfo(Types));
 
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -3416,7 +3416,7 @@
   case llvm::Triple::nvptx:
   case llvm::Triple::nvptx64:
 return CGF->EmitNVPTXBuiltinExpr(BuiltinID, E);
-  case llvm::Triple::wasm32:
+  case llvm::Triple::wasm:
   case llvm::Triple::wasm64:
 return CGF->EmitWebAssemblyBuiltinE

r324505 - Revert "Recommit r324107."

2018-02-07 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb  7 11:44:15 2018
New Revision: 324505

URL: http://llvm.org/viewvc/llvm-project?rev=324505&view=rev
Log:
Revert "Recommit r324107."

This reverts commit r324500.

The bots found two failures:

ThreadSanitizer-x86_64 :: Linux/pie_no_aslr.cc
ThreadSanitizer-x86_64 :: pie_test.cc

when using gold. The issue is a limitation in gold when building pie
binaries. I will investigate how to work around it.

Removed:
cfe/trunk/test/CodeGen/dso-local-executable.c
cfe/trunk/test/CodeGenCXX/dso-local-executable.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGVTT.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGen/mbackchain-2.c
cfe/trunk/test/CodeGen/mbackchain-3.c
cfe/trunk/test/CodeGen/mips-vector-return.c
cfe/trunk/test/CodeGen/split-stacks.c
cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template.cpp
cfe/trunk/test/CodeGenCXX/float16-declarations.cpp
cfe/trunk/test/CodeGenCXX/split-stacks.cpp
cfe/trunk/test/Driver/lanai-unknown-unknown.cpp
cfe/trunk/test/Driver/le32-unknown-nacl.cpp
cfe/trunk/test/Driver/le64-unknown-unknown.cpp
cfe/trunk/test/Driver/riscv32-toolchain.c
cfe/trunk/test/Driver/riscv64-toolchain.c
cfe/trunk/test/Frontend/ast-codegen.c

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=324505&r1=324504&r2=324505&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Feb  7 11:44:15 2018
@@ -240,7 +240,7 @@ llvm::Constant *CodeGenModule::getOrCrea
   getModule(), LTy, Ty.isConstant(getContext()), Linkage, Init, Name,
   nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
   GV->setAlignment(getContext().getDeclAlign(&D).getQuantity());
-  setGVProperties(GV, &D);
+  setGlobalVisibility(GV, &D);
 
   if (supportsCOMDAT() && GV->isWeakForLinker())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
@@ -344,7 +344,6 @@ CodeGenFunction::AddInitializerToStaticV
   OldGV->getThreadLocalMode(),

CGM.getContext().getTargetAddressSpace(D.getType()));
 GV->setVisibility(OldGV->getVisibility());
-GV->setDSOLocal(OldGV->isDSOLocal());
 GV->setComdat(OldGV->getComdat());
 
 // Steal the name of the old global

Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=324505&r1=324504&r2=324505&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Wed Feb  7 11:44:15 2018
@@ -100,7 +100,7 @@ CodeGenVTables::EmitVTTDefinition(llvm::
 VTT->setComdat(CGM.getModule().getOrInsertComdat(VTT->getName()));
 
   // Set the right visibility.
-  CGM.setGVProperties(VTT, RD);
+  CGM.setGlobalVisibility(VTT, RD);
 }
 
 llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=324505&r1=324504&r2=324505&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Feb  7 11:44:15 2018
@@ -51,7 +51,7 @@ llvm::Constant *CodeGenModule::GetAddrOf
 
 static void setThunkVisibility(CodeGenModule &CGM, const CXXMethodDecl *MD,
const ThunkInfo &Thunk, llvm::Function *Fn) {
-  CGM.setGVProperties(Fn, MD);
+  CGM.setGlobalVisibility(Fn, MD);
 }
 
 static void setThunkProperties(CodeGenModule &CGM, const ThunkInfo &Thunk,
@@ -730,7 +730,7 @@ CodeGenVTables::GenerateConstructionVTab
   // Create the variable that will hold the construction vtable.
   llvm::GlobalVariable *VTable =
 CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage);
-  CGM.setGVProperties(VTable, RD);
+  CGM.setGlobalVisibility(VTable, RD);
 
   // V-tables are always unnamed_addr.
   VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=324505&r1=324504&r2=324505&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Feb  7 11:44:15 2018
@@ -715,62 +715,6 @@ void CodeGenModule::setGlobalVisibility(
 GV->setVisibility(GetLLVMVisibility(LV.getVisibility()));
 }
 
-static bool shouldAssumeDSOLocal(

r324507 - [analyzer] [NFC] Factor out generating path diagnostics for a statement into a function

2018-02-07 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Feb  7 11:56:52 2018
New Revision: 324507

URL: http://llvm.org/viewvc/llvm-project?rev=324507&view=rev
Log:
[analyzer] [NFC] Factor out generating path diagnostics for a statement into a 
function

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

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

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=324507&r1=324506&r2=324507&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Wed Feb  7 11:56:52 2018
@@ -556,330 +556,330 @@ static void updateStackPiecesWithMessage
 
 static void CompactPathDiagnostic(PathPieces &path, const SourceManager& SM);
 
-static bool GenerateMinimalPathDiagnostic(
-PathDiagnostic &PD, PathDiagnosticBuilder &PDB, const ExplodedNode *N,
-LocationContextMap &LCM,
-ArrayRef> visitors) {
 
+/// Add path diagnostic for statement associated with node \p N
+/// to diagnostics \p PD.
+/// Precondition: location associated with \p N is a \c BlockEdge.
+static void generateMinimalDiagnosticsForBlockEdge(const ExplodedNode *N,
+   PathDiagnosticBuilder &PDB,
+   PathDiagnostic &PD) {
+
+  const LocationContext *LC = N->getLocationContext();
   SourceManager& SMgr = PDB.getSourceManager();
-  const LocationContext *LC = PDB.LC;
-  const ExplodedNode *NextNode = N->pred_empty()
-? nullptr : *(N->pred_begin());
+  BlockEdge BE = N->getLocation().castAs();
+  const CFGBlock *Src = BE.getSrc();
+  const CFGBlock *Dst = BE.getDst();
+  const Stmt *T = Src->getTerminator();
+  if (!T)
+return;
 
-  StackDiagVector CallStack;
+  auto Start = PathDiagnosticLocation::createBegin(T, SMgr, LC);
+  switch (T->getStmtClass()) {
+  default:
+break;
+
+  case Stmt::GotoStmtClass:
+  case Stmt::IndirectGotoStmtClass: {
+const Stmt *S = PathDiagnosticLocation::getNextStmt(N);
 
-  while (NextNode) {
-N = NextNode;
-PDB.LC = N->getLocationContext();
-NextNode = N->getFirstPred();
+if (!S)
+  break;
 
-ProgramPoint P = N->getLocation();
+std::string sbuf;
+llvm::raw_string_ostream os(sbuf);
+const PathDiagnosticLocation &End = PDB.getEnclosingStmtLocation(S);
+
+os << "Control jumps to line " << 
End.asLocation().getExpansionLineNumber();
+PD.getActivePath().push_front(
+std::make_shared(Start, End, 
os.str()));
+break;
+  }
+
+  case Stmt::SwitchStmtClass: {
+// Figure out what case arm we took.
+std::string sbuf;
+llvm::raw_string_ostream os(sbuf);
 
-do {
-  if (Optional CE = P.getAs()) {
-auto C = PathDiagnosticCallPiece::construct(N, *CE, SMgr);
-// Record the mapping from call piece to LocationContext.
-LCM[&C->path] = CE->getCalleeContext();
-auto *P = C.get();
-PD.getActivePath().push_front(std::move(C));
-PD.pushActivePath(&P->path);
-CallStack.push_back(StackDiagPair(P, N));
+if (const Stmt *S = Dst->getLabel()) {
+  PathDiagnosticLocation End(S, SMgr, LC);
+
+  switch (S->getStmtClass()) {
+  default:
+os << "No cases match in the switch statement. "
+  "Control jumps to line "
+   << End.asLocation().getExpansionLineNumber();
+break;
+  case Stmt::DefaultStmtClass:
+os << "Control jumps to the 'default' case at line "
+   << End.asLocation().getExpansionLineNumber();
 break;
-  }
 
-  if (Optional CE = P.getAs()) {
-// Flush all locations, and pop the active path.
-bool VisitedEntireCall = PD.isWithinCall();
-PD.popActivePath();
-
-// Either we just added a bunch of stuff to the top-level path, or
-// we have a previous CallExitEnd.  If the former, it means that the
-// path terminated within a function call.  We must then take the
-// current contents of the active path and place it within
-// a new PathDiagnosticCallPiece.
-PathDiagnosticCallPiece *C;
-if (VisitedEntireCall) {
-  C = cast(PD.getActivePath().front().get());
-} else {
-  const Decl *Caller = CE->getLocationContext()->getDecl();
-  C = PathDiagnosticCallPiece::construct(PD.getActivePath(), Caller);
-  // Record the mapping from call piece to LocationContext.
-  LCM[&C->path] = CE->getCalleeContext();
+  case Stmt::CaseStmtClass: {
+os << "Control jumps to 'case ";
+const CaseStmt *Case = cast(S);
+const Expr *LHS = Case->getLHS()->IgnoreParenCasts();
+
+// Determine if it is an enum.
+bool GetRawInt = true;
+
+if (const DeclRefExpr *DR = dyn_cast(LHS

r324508 - Revert [DebugInfo] Improvements to representation of enumeration types (PR36168)"

2018-02-07 Thread Momchil Velikov via cfe-commits
Author: chill
Date: Wed Feb  7 11:57:04 2018
New Revision: 324508

URL: http://llvm.org/viewvc/llvm-project?rev=324508&view=rev
Log:
Revert [DebugInfo] Improvements to representation of enumeration types 
(PR36168)"

Revert due to breaking buildbots (LLDB tests)

Removed:
cfe/trunk/test/CodeGen/debug-info-enum.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGenCXX/debug-info-enum-class.cpp
cfe/trunk/test/CodeGenCXX/debug-info-enum.cpp
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=324508&r1=324507&r2=324508&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Feb  7 11:57:04 2018
@@ -2492,12 +2492,9 @@ llvm::DIType *CGDebugInfo::CreateTypeDef
   // Create elements for each enumerator.
   SmallVector Enumerators;
   ED = ED->getDefinition();
-  bool IsSigned = ED->getIntegerType()->isSignedIntegerType();
   for (const auto *Enum : ED->enumerators()) {
-const auto &InitVal = Enum->getInitVal();
-auto Value = IsSigned ? InitVal.getSExtValue() : InitVal.getZExtValue();
-Enumerators.push_back(
-DBuilder.createEnumerator(Enum->getName(), Value, !IsSigned));
+Enumerators.push_back(DBuilder.createEnumerator(
+Enum->getName(), Enum->getInitVal().getSExtValue()));
   }
 
   // Return a CompositeType for the enum itself.
@@ -2506,10 +2503,11 @@ llvm::DIType *CGDebugInfo::CreateTypeDef
   llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
   unsigned Line = getLineNumber(ED->getLocation());
   llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
-  llvm::DIType *ClassTy = getOrCreateType(ED->getIntegerType(), DefUnit);
+  llvm::DIType *ClassTy =
+  ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : nullptr;
   return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
 Line, Size, Align, EltArray, ClassTy,
-FullName, ED->isFixed());
+FullName);
 }
 
 llvm::DIMacro *CGDebugInfo::CreateMacro(llvm::DIMacroFile *Parent,

Removed: cfe/trunk/test/CodeGen/debug-info-enum.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-enum.cpp?rev=324507&view=auto
==
--- cfe/trunk/test/CodeGen/debug-info-enum.cpp (original)
+++ cfe/trunk/test/CodeGen/debug-info-enum.cpp (removed)
@@ -1,100 +0,0 @@
-// Test enumeration representation in debuig info metadata:
-// * test value representation for each possible underlying integer type
-// * test the integer type is as expected
-// * test the DW_AT_enum_class attribute is present (resp. absent) as expected.
-
-// RUN: %clang -target x86_64-linux -g -S -emit-llvm -o - %s | FileCheck %s
-
-
-enum class E0 : signed char {
-  A0 = -128,
-  B0 = 127,
-} x0;
-// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E0"
-// CHECK-SAME: baseType: ![[SCHAR:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
-// CHECK-SAME: elements: ![[ELTS0:[0-9]+]]
-// CHECK: ![[SCHAR]] = !DIBasicType(name: "signed char", size: 8, encoding: 
DW_ATE_signed_char)
-// CHECK: ![[ELTS0]] = !{![[A0:[0-9]+]], ![[B0:[0-9]+]]}
-// CHECK: ![[A0]] = !DIEnumerator(name: "A0", value: -128)
-// CHECK: ![[B0]] = !DIEnumerator(name: "B0", value: 127)
-
-enum class E1 : unsigned char { A1 = 255 } x1;
-// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E1"
-// CHECK-SAME: baseType: ![[UCHAR:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
-// CHECK-SAME: elements: ![[ELTS1:[0-9]+]]
-// CHECK: ![[UCHAR]] = !DIBasicType(name: "unsigned char", size: 8, encoding: 
DW_ATE_unsigned_char)
-// CHECK: ![[ELTS1]] = !{![[A1:[0-9]+]]}
-// CHECK: ![[A1]] = !DIEnumerator(name: "A1", value: 255, isUnsigned: true)
-
-enum class E2 : signed short {
-  A2 = -32768,
-  B2 = 32767,
-} x2;
-// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E2"
-// CHECK-SAME: baseType: ![[SHORT:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
-// CHECK-SAME: elements: ![[ELTS2:[0-9]+]]
-// CHECK: ![[SHORT]] = !DIBasicType(name: "short", size: 16, encoding: 
DW_ATE_signed)
-// CHECK: ![[ELTS2]] = !{![[A2:[0-9]+]], ![[B2:[0-9]+]]}
-// CHECK: ![[A2]] = !DIEnumerator(name: "A2", value: -32768)
-// CHECK: ![[B2]] = !DIEnumerator(name: "B2", value: 32767)
-
-enum class E3 : unsigned short { A3 = 65535 } x3;
-// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E3"
-// CHECK-SAME: baseType: ![[USHORT:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
-// CHECK-SAME: elements: ![[ELTS3:[0-9]+]]
-// CHECK: ![[USHORT]] = !DIBasicType(name: "unsigned short", size: 16, 
encoding: DW_ATE_unsigned)
-// CHECK: ![[ELTS3]] = !{![[A3:[0-9]+]]}
-// CHECK: ![[A3]] = !DIEnumerator(nam

[PATCH] D43013: ASan+operator new[]: Fix operator new[] cookie poisoning

2018-02-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I don't understand why your description of this patch mentions the void* 
placement new[] operator.  There's no cookie to poison for that operator.


Repository:
  rC Clang

https://reviews.llvm.org/D43013



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


r324514 - [PR36008] Avoid -Wsign-compare warning for enum constants in

2018-02-07 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Feb  7 12:45:39 2018
New Revision: 324514

URL: http://llvm.org/viewvc/llvm-project?rev=324514&view=rev
Log:
[PR36008] Avoid -Wsign-compare warning for enum constants in
typeof expressions

This commit looks through typeof type at the original expression when diagnosing
-Wsign-compare to avoid an unfriendly diagnostic.

rdar://36588828

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/compare.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=324514&r1=324513&r2=324514&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Feb  7 12:45:39 2018
@@ -8955,6 +8955,16 @@ static void AnalyzeComparison(Sema &S, B
   LHS = LHS->IgnoreParenImpCasts();
   RHS = RHS->IgnoreParenImpCasts();
 
+  if (!S.getLangOpts().CPlusPlus) {
+// Avoid warning about comparison of integers with different signs when
+// RHS/LHS has a `typeof(E)` type whose sign is different from the sign of
+// the type of `E`.
+if (const auto *TET = dyn_cast(LHS->getType()))
+  LHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+if (const auto *TET = dyn_cast(RHS->getType()))
+  RHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+  }
+
   // Check to see if one of the (unmodified) operands is of different
   // signedness.
   Expr *signedOperand, *unsignedOperand;

Modified: cfe/trunk/test/Sema/compare.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/compare.c?rev=324514&r1=324513&r2=324514&view=diff
==
--- cfe/trunk/test/Sema/compare.c (original)
+++ cfe/trunk/test/Sema/compare.c Wed Feb  7 12:45:39 2018
@@ -391,3 +391,16 @@ typedef char two_chars[2];
 void test12(unsigned a) {
   if (0 && -1 > a) { }
 }
+
+// PR36008
+
+enum PR36008EnumTest {
+  kPR36008Value = 0,
+};
+
+void pr36008(enum PR36008EnumTest lhs) {
+  __typeof__(lhs) x = lhs;
+  __typeof__(kPR36008Value) y = (kPR36008Value);
+  if (x == y) x = y; // no warning
+  if (y == x) y = x; // no warning
+}


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


[libcxxabi] r324519 - Creating release candidate rc2 from release_600 branch

2018-02-07 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Feb  7 12:46:26 2018
New Revision: 324519

URL: http://llvm.org/viewvc/llvm-project?rev=324519&view=rev
Log:
Creating release candidate rc2 from release_600 branch

Added:
libcxxabi/tags/RELEASE_600/rc2/
  - copied from r324518, libcxxabi/branches/release_60/

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


[libcxx] r324518 - Creating release candidate rc2 from release_600 branch

2018-02-07 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Feb  7 12:46:19 2018
New Revision: 324518

URL: http://llvm.org/viewvc/llvm-project?rev=324518&view=rev
Log:
Creating release candidate rc2 from release_600 branch

Added:
libcxx/tags/RELEASE_600/rc2/   (props changed)
  - copied from r324517, libcxx/branches/release_60/

Propchange: libcxx/tags/RELEASE_600/rc2/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Feb  7 12:46:19 2018
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:321963,324153


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


[PATCH] D42993: [AArch64] Fixes for ARMv8.2-A FP16 scalar intrinsic

2018-02-07 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Thanks for fixing this. Looks very reasonable to me.

Question about the failures: I am now wondering if this means we were and still 
are missing tests?

Nit: for future reviews, I think it is better to split patches up if they are 
commits to 
different repos.


https://reviews.llvm.org/D42993



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


[libunwind] r324525 - Creating release candidate rc2 from release_600 branch

2018-02-07 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Feb  7 12:47:12 2018
New Revision: 324525

URL: http://llvm.org/viewvc/llvm-project?rev=324525&view=rev
Log:
Creating release candidate rc2 from release_600 branch

Added:
libunwind/tags/RELEASE_600/rc2/
  - copied from r324524, libunwind/branches/release_60/

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


[PATCH] D42561: [PR36008] Avoid -Wsign-compare warning for enum constants in typeof expressions

2018-02-07 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324514: [PR36008] Avoid -Wsign-compare warning for enum 
constants in (authored by arphaman, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42561?vs=132901&id=133281#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42561

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/compare.c


Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -8955,6 +8955,16 @@
   LHS = LHS->IgnoreParenImpCasts();
   RHS = RHS->IgnoreParenImpCasts();
 
+  if (!S.getLangOpts().CPlusPlus) {
+// Avoid warning about comparison of integers with different signs when
+// RHS/LHS has a `typeof(E)` type whose sign is different from the sign of
+// the type of `E`.
+if (const auto *TET = dyn_cast(LHS->getType()))
+  LHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+if (const auto *TET = dyn_cast(RHS->getType()))
+  RHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+  }
+
   // Check to see if one of the (unmodified) operands is of different
   // signedness.
   Expr *signedOperand, *unsignedOperand;
Index: cfe/trunk/test/Sema/compare.c
===
--- cfe/trunk/test/Sema/compare.c
+++ cfe/trunk/test/Sema/compare.c
@@ -391,3 +391,16 @@
 void test12(unsigned a) {
   if (0 && -1 > a) { }
 }
+
+// PR36008
+
+enum PR36008EnumTest {
+  kPR36008Value = 0,
+};
+
+void pr36008(enum PR36008EnumTest lhs) {
+  __typeof__(lhs) x = lhs;
+  __typeof__(kPR36008Value) y = (kPR36008Value);
+  if (x == y) x = y; // no warning
+  if (y == x) y = x; // no warning
+}


Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -8955,6 +8955,16 @@
   LHS = LHS->IgnoreParenImpCasts();
   RHS = RHS->IgnoreParenImpCasts();
 
+  if (!S.getLangOpts().CPlusPlus) {
+// Avoid warning about comparison of integers with different signs when
+// RHS/LHS has a `typeof(E)` type whose sign is different from the sign of
+// the type of `E`.
+if (const auto *TET = dyn_cast(LHS->getType()))
+  LHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+if (const auto *TET = dyn_cast(RHS->getType()))
+  RHS = TET->getUnderlyingExpr()->IgnoreParenImpCasts();
+  }
+
   // Check to see if one of the (unmodified) operands is of different
   // signedness.
   Expr *signedOperand, *unsignedOperand;
Index: cfe/trunk/test/Sema/compare.c
===
--- cfe/trunk/test/Sema/compare.c
+++ cfe/trunk/test/Sema/compare.c
@@ -391,3 +391,16 @@
 void test12(unsigned a) {
   if (0 && -1 > a) { }
 }
+
+// PR36008
+
+enum PR36008EnumTest {
+  kPR36008Value = 0,
+};
+
+void pr36008(enum PR36008EnumTest lhs) {
+  __typeof__(lhs) x = lhs;
+  __typeof__(kPR36008Value) y = (kPR36008Value);
+  if (x == y) x = y; // no warning
+  if (y == x) y = x; // no warning
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40988: Clang-format: add finer-grained options for putting all arguments on one line

2018-02-07 Thread Russell McClellan via Phabricator via cfe-commits
russellmcc updated this revision to Diff 133280.
russellmcc added a comment.

Responded to review feedback:

- Fix bug where `AllowAllArgumentsOnNextLine` overrode 
`AllowAllParametersOfDeclarationOnNextLine`
- Add tests demonstrating independence of `AllowAllArgumentsOnNextLine` and 
`AllowAllParametersOfDeclarationOnNextLine`
- Add test showing `AllowAllConstructorInitializersOnNextLine` doesn't affect 
single-line constructors
- Removed unnecessary re-setting of llvm styles
- Removed bonus line from test


https://reviews.llvm.org/D40988

Files:
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -3433,6 +3433,56 @@
"() {}"));
 }
 
+TEST_F(FormatTest, AllowAllConstructorInitializersOnNextLine) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+  Style.ColumnLimit = 60;
+  Style.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
+  Style.AllowAllConstructorInitializersOnNextLine = true;
+  verifyFormat("Constructor()\n"
+   ": (a), b(b) {}",
+   Style);
+  verifyFormat("Constructor() : a(a), b(b) {}", Style);
+
+  Style.AllowAllConstructorInitializersOnNextLine = false;
+  verifyFormat("Constructor()\n"
+   ": (a)\n"
+   ", b(b) {}",
+   Style);
+  verifyFormat("Constructor() : a(a), b(b) {}", Style);
+}
+
+TEST_F(FormatTest, AllowAllArgumentsOnNextLine) {
+  FormatStyle Style = getLLVMStyle();
+  Style.ColumnLimit = 60;
+  Style.BinPackArguments = false;
+  Style.AllowAllArgumentsOnNextLine = true;
+  verifyFormat("void foo() {\n"
+   "  FunctionCallWithReallyLongName(\n"
+   "  aaa, );\n"
+   "}",
+   Style);
+  Style.AllowAllArgumentsOnNextLine = false;
+  verifyFormat("void foo() {\n"
+   "  FunctionCallWithReallyLongName(\n"
+   "  aaa,\n"
+   "  );\n"
+   "}",
+   Style);
+
+  // This parameter should not affect declarations.
+  Style.BinPackParameters = false;
+  Style.AllowAllParametersOfDeclarationOnNextLine = true;
+  verifyFormat("void FunctionCallWithReallyLongName(\n"
+   "int aaa, int );",
+   Style);
+  Style.AllowAllParametersOfDeclarationOnNextLine = false;
+  verifyFormat("void FunctionCallWithReallyLongName(\n"
+   "int aaa,\n"
+   "int );",
+   Style);
+}
+
 TEST_F(FormatTest, BreakConstructorInitializersAfterColon) {
   FormatStyle Style = getLLVMStyle();
   Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
@@ -10020,6 +10070,8 @@
   CHECK_PARSE_BOOL(AlignTrailingComments);
   CHECK_PARSE_BOOL(AlignConsecutiveAssignments);
   CHECK_PARSE_BOOL(AlignConsecutiveDeclarations);
+  CHECK_PARSE_BOOL(AllowAllArgumentsOnNextLine);
+  CHECK_PARSE_BOOL(AllowAllConstructorInitializersOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowShortBlocksOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -287,6 +287,10 @@
 IO.mapOptional("AlignEscapedNewlines", Style.AlignEscapedNewlines);
 IO.mapOptional("AlignOperands", Style.AlignOperands);
 IO.mapOptional("AlignTrailingComments", Style.AlignTrailingComments);
+IO.mapOptional("AllowAllArgumentsOnNextLine",
+   Style.AllowAllArgumentsOnNextLine);
+IO.mapOptional("AllowAllConstructorInitializersOnNextLine",
+   Style.AllowAllConstructorInitializersOnNextLine);
 IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
 IO.mapOptional("AllowShortBlocksOnASingleLine",
@@ -303,6 +307,7 @@
Style.AlwaysBreakAfterDefinitionReturnType);
 IO.mapOptional("AlwaysBreakAfterReturnType",
Style.AlwaysBreakAfterReturnType);
+
 // If AlwaysBreakAfterDefinitionReturnType was specified but
 // AlwaysBreakAfterReturnType was not, initialize the latter from the
 // former for backwards compatibility.
@@ -575,6 +580,8 @@
   LLVMStyle.AlignTrailingComments = true;
   LLVMStyle.AlignConsecutiveAssignments = false;
   LLVMStyle.AlignConsecutiveDeclarations = false;
+  LLVMStyle.AllowAllArgumentsOnNextLine = true;
+  LLVMStyle.AllowAllCo

[PATCH] D40988: Clang-format: add finer-grained options for putting all arguments on one line

2018-02-07 Thread Russell McClellan via Phabricator via cfe-commits
russellmcc added a comment.

Thanks for the feedback!  I'm very motivated to get some support for these 
features since they are required for my style guide.  Let me know if my recent 
changes made sense to you.




Comment at: lib/Format/ContinuationIndenter.cpp:756
  State.Line->MustBeDeclaration) ||
-Previous.is(TT_DictLiteral))
+Previous.is(TT_DictLiteral) || !Style.AllowAllArgumentsOnNextLine)
   State.Stack.back().BreakBeforeParameter = true;

djasper wrote:
> Hm, this looks suspicious. Doesn't this mean that AllowAllArgumentsOnNextLine 
> implies/overwrites AllowAllParametersOfDeclarationOnNextLine?
> 
> Now, there are two ways out of this:
> - Fix it
> - Provide different options
> 
> The question is whether someone would ever want AllowAllArgumentsOnNextLine 
> to be false while AllowAllParametersOfDeclarationOnNextLine is true. That 
> would seem weird to me. If not, it might be better to turn the existing 
> option into an enum with three values (None, Declarations, All) or something.
Oops!  Thanks for finding this.  I think since other options are exposed 
separately for parameters and arguments (e.g., bin packing), it's more 
consistent to break these out separately.



Comment at: lib/Format/ContinuationIndenter.cpp:962
 State.Stack.back().NestedBlockIndent = State.Stack.back().Indent;
-if (Style.ConstructorInitializerAllOnOneLineOrOnePerLine)
+if (Style.ConstructorInitializerAllOnOneLineOrOnePerLine) {
   State.Stack.back().AvoidBinPacking = true;

djasper wrote:
> I am not 100%, but I think this is doing too much. In accordance with the 
> other options, this should still allow:
> 
>   Constructor() : a(a), b(b) {}
> 
> so long as everything fits on one line (and I think it might not). Either 
> way, add a test.
I think the case you're talking about actually works; I've added a test.



Comment at: lib/Format/Format.cpp:748
   } else {
+ChromiumStyle.AllowAllArgumentsOnNextLine = true;
+ChromiumStyle.AllowAllConstructorInitializersOnNextLine = true;

djasper wrote:
> I think there is no need to set these here and below. Everything derives from 
> LLVM style.
Removed!



Comment at: unittests/Format/FormatTest.cpp:3440
+  Style.ColumnLimit = 60;
+  Style.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
+  Style.AllowAllConstructorInitializersOnNextLine = true;

djasper wrote:
> If we go forward with this, the name of this option gets really confusing and 
> we need to think about renaming it. Or maybe we can also turn it into an enum 
> with three values?
> 
> Here also, the combination of
>   ConstructorInitializerAllOnOneLineOrOnePerLine=false and 
>   AllowAllConstructorInitializersOnNextLine=true
> seems really weird. I wouldn't even know what the desired behavior is in that 
> case.
I agree this combination is weird, however the situation already existed with 
declaration parameters (i.e., `AllowAllParametersOfDeclarationOnNextLine` has 
no effect when `BinPackParameters` was true).  I think exposing these new 
parameters in this way is the most consistent with the existing approach.

I've edited the doc comment for `AllowAllConstructorInitializersOnNextLine ` to 
note that it has no effect when 
`ConstructorInitializerAllOnOneLineOrOnePerLine` is false.



https://reviews.llvm.org/D40988



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


[PATCH] D41223: [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 133285.
EricWF added a comment.

- Update with new, hopefully working, version.


https://reviews.llvm.org/D41223

Files:
  include/__config
  include/array
  test/libcxx/containers/sequences/array/array.zero/db_back.pass.cpp
  test/libcxx/containers/sequences/array/array.zero/db_front.pass.cpp
  test/libcxx/containers/sequences/array/array.zero/db_indexing.pass.cpp
  test/std/containers/sequences/array/array.cons/default.pass.cpp
  test/std/containers/sequences/array/array.cons/implicit_copy.pass.cpp
  test/std/containers/sequences/array/array.data/data.pass.cpp
  test/std/containers/sequences/array/array.data/data_const.pass.cpp
  test/std/containers/sequences/array/array.fill/fill.fail.cpp
  test/std/containers/sequences/array/array.swap/swap.fail.cpp
  test/std/containers/sequences/array/at.pass.cpp
  test/std/containers/sequences/array/begin.pass.cpp
  test/std/containers/sequences/array/compare.fail.cpp
  test/std/containers/sequences/array/compare.pass.cpp
  test/std/containers/sequences/array/empty.fail.cpp
  test/std/containers/sequences/array/front_back.pass.cpp
  test/std/containers/sequences/array/indexing.pass.cpp
  test/std/containers/sequences/array/size_and_alignment.pass.cpp

Index: test/std/containers/sequences/array/size_and_alignment.pass.cpp
===
--- /dev/null
+++ test/std/containers/sequences/array/size_and_alignment.pass.cpp
@@ -0,0 +1,55 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template 
+// struct array
+
+// Test the size and alignment matches that of an array of a given type.
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+template 
+void test() {
+  typedef T CArrayT[Size == 0 ? 1 : Size];
+  typedef std::array ArrayT;
+  static_assert(sizeof(CArrayT) == sizeof(ArrayT), "");
+  static_assert(TEST_ALIGNOF(CArrayT) == TEST_ALIGNOF(ArrayT), "");
+}
+
+template 
+void test_type() {
+  test();
+  test();
+  test();
+}
+
+struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t) * 2) TestType1 {
+
+};
+
+struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t) * 2) TestType2 {
+  char data[1000];
+};
+
+int main() {
+  test_type();
+  test_type();
+  test_type();
+  test_type();
+  test_type();
+  test_type();
+  test_type();
+}
Index: test/std/containers/sequences/array/indexing.pass.cpp
===
--- test/std/containers/sequences/array/indexing.pass.cpp
+++ test/std/containers/sequences/array/indexing.pass.cpp
@@ -56,7 +56,34 @@
 C::const_reference r2 = c[2];
 assert(r2 == 3.5);
 }
-
+{ // Test operator[] "works" on zero sized arrays
+typedef double T;
+typedef std::array C;
+C c = {};
+C const& cc = c;
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+if (c.size() > (0)) { // always false
+  C::reference r1 = c[0];
+  C::const_reference r2 = cc[0];
+  ((void)r1);
+  ((void)r2);
+}
+}
+{ // Test operator[] "works" on zero sized arrays
+typedef double T;
+typedef std::array C;
+C c = {{}};
+C const& cc = c;
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+if (c.size() > (0)) { // always false
+  C::reference r1 = c[0];
+  C::const_reference r2 = cc[0];
+  ((void)r1);
+  ((void)r2);
+}
+}
 #if TEST_STD_VER > 11
 {
 typedef double T;
Index: test/std/containers/sequences/array/front_back.pass.cpp
===
--- test/std/containers/sequences/array/front_back.pass.cpp
+++ test/std/containers/sequences/array/front_back.pass.cpp
@@ -64,7 +64,38 @@
 C::const_reference r2 = c.back();
 assert(r2 == 3.5);
 }
-
+{
+  typedef double T;
+  typedef std::array C;
+  C c = {};
+  C const& cc = c;
+  static_assert((std::is_same::value), "");
+  static_assert((std::is_same::value), "");
+  static_assert((std::is_same::value), "");
+  static_assert((std::is_same::value), "");
+  if (c.size() > (0)) { // always false
+TEST_IGNORE_NODISCARD c.front();
+TEST_IGNORE_NODISCARD c.back();
+TEST_IGNORE_NODISCARD cc.front();
+TEST_IGNORE_NODISCARD cc.back();
+  }
+}
+{
+  typedef double T;
+  typedef std::array C;
+  C c = {{}};
+  C const& cc = c;
+  static_assert((std::is_same::value), "");
+  static_assert((std::is_

[PATCH] D41223: [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF reopened this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

This was reverted as it caused build failures. Re-opening with new version.


Repository:
  rCXX libc++

https://reviews.llvm.org/D41223



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


[libcxx] r324526 - [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

2018-02-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Feb  7 13:06:13 2018
New Revision: 324526

URL: http://llvm.org/viewvc/llvm-project?rev=324526&view=rev
Log:
[libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default 
constructible types.

Summary:
This patch fixes llvm.org/PR35491 and LWG2157  
(https://cplusplus.github.io/LWG/issue2157)

The fix attempts to maintain ABI compatibility by replacing the array with a 
instance of `aligned_storage`.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: lichray, cfe-commits

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

Added:
libcxx/trunk/test/libcxx/containers/sequences/array/array.zero/

libcxx/trunk/test/libcxx/containers/sequences/array/array.zero/db_back.pass.cpp

libcxx/trunk/test/libcxx/containers/sequences/array/array.zero/db_front.pass.cpp

libcxx/trunk/test/libcxx/containers/sequences/array/array.zero/db_indexing.pass.cpp

libcxx/trunk/test/std/containers/sequences/array/array.cons/implicit_copy.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.fail.cpp
libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.fail.cpp
libcxx/trunk/test/std/containers/sequences/array/compare.fail.cpp
libcxx/trunk/test/std/containers/sequences/array/compare.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/size_and_alignment.pass.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/array
libcxx/trunk/test/std/containers/sequences/array/array.cons/default.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.data/data.pass.cpp

libcxx/trunk/test/std/containers/sequences/array/array.data/data_const.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/at.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/begin.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/empty.fail.cpp
libcxx/trunk/test/std/containers/sequences/array/front_back.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/indexing.pass.cpp

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=324526&r1=324525&r2=324526&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Feb  7 13:06:13 2018
@@ -793,8 +793,13 @@ namespace std {
 # if !defined(_LIBCPP_DEBUG)
 #   error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is 
defined
 # endif
-# define _NOEXCEPT_DEBUG noexcept(false)
-# define _NOEXCEPT_DEBUG_(x) noexcept(false)
+# ifdef _LIBCPP_HAS_NO_NOEXCEPT
+#   define _NOEXCEPT_DEBUG
+#   define _NOEXCEPT_DEBUG_(x)
+# else
+#   define _NOEXCEPT_DEBUG noexcept(false)
+#   define _NOEXCEPT_DEBUG_(x) noexcept(false)
+#endif
 #else
 # define _NOEXCEPT_DEBUG _NOEXCEPT
 # define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x)

Modified: libcxx/trunk/include/array
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/array?rev=324526&r1=324525&r2=324526&view=diff
==
--- libcxx/trunk/include/array (original)
+++ libcxx/trunk/include/array Wed Feb  7 13:06:13 2018
@@ -108,6 +108,8 @@ template  c
 #include 
 #include 
 #include 
+#include  // for _LIBCPP_UNREACHABLE
+#include <__debug>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -117,6 +119,7 @@ template  c
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+
 template 
 struct _LIBCPP_TEMPLATE_VIS array
 {
@@ -134,31 +137,27 @@ struct _LIBCPP_TEMPLATE_VIS array
 typedef std::reverse_iterator   reverse_iterator;
 typedef std::reverse_iterator const_reverse_iterator;
 
-value_type __elems_[_Size > 0 ? _Size : 1];
+_Tp __elems_[_Size];
 
 // No explicit construct/copy/destroy for aggregate type
-_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
-{_VSTD::fill_n(__elems_, _Size, __u);}
-_LIBCPP_INLINE_VISIBILITY
-void swap(array& __a) _NOEXCEPT_(_Size == 0 || 
__is_nothrow_swappable<_Tp>::value)
-{ __swap_dispatch((std::integral_constant()), __a); }
+_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u) {
+  _VSTD::fill_n(__elems_, _Size, __u);
+}
 
 _LIBCPP_INLINE_VISIBILITY
-void __swap_dispatch(std::true_type, array&) {}
-
-_LIBCPP_INLINE_VISIBILITY
-void __swap_dispatch(std::false_type, array& __a)
-{ _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
+void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
+  std::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);
+}
 
 // iterators:
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-iterator begin() _NOEXCEPT {return iterator(__elems_);}
+iterator begin() _NOEXCEPT {return iterator(data());}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-const_iterator begin() const _NOEXC

[PATCH] D41223: [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.

Accepting new version.


https://reviews.llvm.org/D41223



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


[PATCH] D41223: [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX324526: [libc++] Fix PR35491 - std::array of zero-size 
doesn't work with non-default… (authored by EricWF, committed by ).

Repository:
  rCXX libc++

https://reviews.llvm.org/D41223

Files:
  include/__config
  include/array
  test/libcxx/containers/sequences/array/array.zero/db_back.pass.cpp
  test/libcxx/containers/sequences/array/array.zero/db_front.pass.cpp
  test/libcxx/containers/sequences/array/array.zero/db_indexing.pass.cpp
  test/std/containers/sequences/array/array.cons/default.pass.cpp
  test/std/containers/sequences/array/array.cons/implicit_copy.pass.cpp
  test/std/containers/sequences/array/array.data/data.pass.cpp
  test/std/containers/sequences/array/array.data/data_const.pass.cpp
  test/std/containers/sequences/array/array.fill/fill.fail.cpp
  test/std/containers/sequences/array/array.swap/swap.fail.cpp
  test/std/containers/sequences/array/at.pass.cpp
  test/std/containers/sequences/array/begin.pass.cpp
  test/std/containers/sequences/array/compare.fail.cpp
  test/std/containers/sequences/array/compare.pass.cpp
  test/std/containers/sequences/array/empty.fail.cpp
  test/std/containers/sequences/array/front_back.pass.cpp
  test/std/containers/sequences/array/indexing.pass.cpp
  test/std/containers/sequences/array/size_and_alignment.pass.cpp

Index: include/array
===
--- include/array
+++ include/array
@@ -108,6 +108,8 @@
 #include 
 #include 
 #include 
+#include  // for _LIBCPP_UNREACHABLE
+#include <__debug>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -117,6 +119,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+
 template 
 struct _LIBCPP_TEMPLATE_VIS array
 {
@@ -134,31 +137,27 @@
 typedef std::reverse_iterator   reverse_iterator;
 typedef std::reverse_iterator const_reverse_iterator;
 
-value_type __elems_[_Size > 0 ? _Size : 1];
+_Tp __elems_[_Size];
 
 // No explicit construct/copy/destroy for aggregate type
-_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
-{_VSTD::fill_n(__elems_, _Size, __u);}
-_LIBCPP_INLINE_VISIBILITY
-void swap(array& __a) _NOEXCEPT_(_Size == 0 || __is_nothrow_swappable<_Tp>::value)
-{ __swap_dispatch((std::integral_constant()), __a); }
+_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u) {
+  _VSTD::fill_n(__elems_, _Size, __u);
+}
 
 _LIBCPP_INLINE_VISIBILITY
-void __swap_dispatch(std::true_type, array&) {}
-
-_LIBCPP_INLINE_VISIBILITY
-void __swap_dispatch(std::false_type, array& __a)
-{ _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
+void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
+  std::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);
+}
 
 // iterators:
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-iterator begin() _NOEXCEPT {return iterator(__elems_);}
+iterator begin() _NOEXCEPT {return iterator(data());}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);}
+const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);}
+iterator end() _NOEXCEPT {return iterator(data() + _Size);}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);}
+const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}
 
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
@@ -184,7 +183,7 @@
 _LIBCPP_INLINE_VISIBILITY
 _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
+_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return false; }
 
 // element access:
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
@@ -197,15 +196,16 @@
 
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() {return __elems_[0];}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];}
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back()  {return __elems_[_Size > 0 ? _Size-1 : 0];}
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const  {return __elems_[_Size > 0 ? _Size-1 : 0];}
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back()  {return __elems_[_Size - 1];}
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_referenc

[PATCH] D41223: [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324526: [libc++] Fix PR35491 - std::array of zero-size 
doesn't work with non-default… (authored by EricWF, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D41223?vs=133285&id=133288#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41223

Files:
  libcxx/trunk/include/__config
  libcxx/trunk/include/array
  
libcxx/trunk/test/libcxx/containers/sequences/array/array.zero/db_back.pass.cpp
  
libcxx/trunk/test/libcxx/containers/sequences/array/array.zero/db_front.pass.cpp
  
libcxx/trunk/test/libcxx/containers/sequences/array/array.zero/db_indexing.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/array.cons/default.pass.cpp
  
libcxx/trunk/test/std/containers/sequences/array/array.cons/implicit_copy.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/array.data/data.pass.cpp
  
libcxx/trunk/test/std/containers/sequences/array/array.data/data_const.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.fail.cpp
  libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.fail.cpp
  libcxx/trunk/test/std/containers/sequences/array/at.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/begin.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/compare.fail.cpp
  libcxx/trunk/test/std/containers/sequences/array/compare.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/empty.fail.cpp
  libcxx/trunk/test/std/containers/sequences/array/front_back.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/indexing.pass.cpp
  libcxx/trunk/test/std/containers/sequences/array/size_and_alignment.pass.cpp

Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -793,8 +793,13 @@
 # if !defined(_LIBCPP_DEBUG)
 #   error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is defined
 # endif
-# define _NOEXCEPT_DEBUG noexcept(false)
-# define _NOEXCEPT_DEBUG_(x) noexcept(false)
+# ifdef _LIBCPP_HAS_NO_NOEXCEPT
+#   define _NOEXCEPT_DEBUG
+#   define _NOEXCEPT_DEBUG_(x)
+# else
+#   define _NOEXCEPT_DEBUG noexcept(false)
+#   define _NOEXCEPT_DEBUG_(x) noexcept(false)
+#endif
 #else
 # define _NOEXCEPT_DEBUG _NOEXCEPT
 # define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x)
Index: libcxx/trunk/include/array
===
--- libcxx/trunk/include/array
+++ libcxx/trunk/include/array
@@ -108,6 +108,8 @@
 #include 
 #include 
 #include 
+#include  // for _LIBCPP_UNREACHABLE
+#include <__debug>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -117,6 +119,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+
 template 
 struct _LIBCPP_TEMPLATE_VIS array
 {
@@ -134,31 +137,27 @@
 typedef std::reverse_iterator   reverse_iterator;
 typedef std::reverse_iterator const_reverse_iterator;
 
-value_type __elems_[_Size > 0 ? _Size : 1];
+_Tp __elems_[_Size];
 
 // No explicit construct/copy/destroy for aggregate type
-_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
-{_VSTD::fill_n(__elems_, _Size, __u);}
-_LIBCPP_INLINE_VISIBILITY
-void swap(array& __a) _NOEXCEPT_(_Size == 0 || __is_nothrow_swappable<_Tp>::value)
-{ __swap_dispatch((std::integral_constant()), __a); }
+_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u) {
+  _VSTD::fill_n(__elems_, _Size, __u);
+}
 
 _LIBCPP_INLINE_VISIBILITY
-void __swap_dispatch(std::true_type, array&) {}
-
-_LIBCPP_INLINE_VISIBILITY
-void __swap_dispatch(std::false_type, array& __a)
-{ _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
+void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
+  std::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);
+}
 
 // iterators:
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-iterator begin() _NOEXCEPT {return iterator(__elems_);}
+iterator begin() _NOEXCEPT {return iterator(data());}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);}
+const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);}
+iterator end() _NOEXCEPT {return iterator(data() + _Size);}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);}
+const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}
 
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
@@ -184,7 +183,7 @@
 _LIBCP

[PATCH] D40218: [Clang] Add __builtin_launder

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Ping.


https://reviews.llvm.org/D40218



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


r324527 - [clang-import-test] Run clang-format, NFC

2018-02-07 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Feb  7 13:17:22 2018
New Revision: 324527

URL: http://llvm.org/viewvc/llvm-project?rev=324527&view=rev
Log:
[clang-import-test] Run clang-format, NFC

I ran across clang-import-test while looking into testing for lldb.
There shouldn't be any harm in running clang-format over it.

Modified:
cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/clang-import-test.cpp?rev=324527&r1=324526&r2=324527&view=diff
==
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp (original)
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp Wed Feb  7 13:17:22 
2018
@@ -50,9 +50,10 @@ static llvm::cl::opt
 Direct("direct", llvm::cl::Optional,
llvm::cl::desc("Use the parsed declarations without indirection"));
 
-static llvm::cl::opt
-UseOrigins("use-origins", llvm::cl::Optional,
-   llvm::cl::desc("Use DeclContext origin information for more 
accurate lookups"));  
+static llvm::cl::opt UseOrigins(
+"use-origins", llvm::cl::Optional,
+llvm::cl::desc(
+"Use DeclContext origin information for more accurate lookups"));
 
 static llvm::cl::list
 ClangArgs("Xcc", llvm::cl::ZeroOrMore,
@@ -225,7 +226,7 @@ std::unique_ptr BuildCode
   CI.getDiagnostics(), ModuleName, CI.getHeaderSearchOpts(),
   CI.getPreprocessorOpts(), CI.getCodeGenOpts(), LLVMCtx));
 }
-} // end namespace
+} // namespace init_convenience
 
 namespace {
 
@@ -261,8 +262,8 @@ void AddExternalSource(CIAndOrigins &CI,
   {CI.getASTContext(), CI.getFileManager()});
   llvm::SmallVector Sources;
   for (CIAndOrigins &Import : Imports)
-Sources.push_back(
-{Import.getASTContext(), Import.getFileManager(), 
Import.getOriginMap()});
+Sources.push_back({Import.getASTContext(), Import.getFileManager(),
+   Import.getOriginMap()});
   auto ES = llvm::make_unique(Target, Sources);
   CI.getASTContext().setExternalSource(ES.release());
   CI.getASTContext().getTranslationUnitDecl()->setHasExternalVisibleStorage();
@@ -334,8 +335,8 @@ llvm::Expected Parse(const
 void Forget(CIAndOrigins &CI, llvm::MutableArrayRef Imports) {
   llvm::SmallVector Sources;
   for (CIAndOrigins &Import : Imports)
-Sources.push_back(
-{Import.getASTContext(), Import.getFileManager(), 
Import.getOriginMap()});
+Sources.push_back({Import.getASTContext(), Import.getFileManager(),
+   Import.getOriginMap()});
   ExternalASTSource *Source = CI.CI->getASTContext().getExternalSource();
   auto *Merger = static_cast(Source);
   Merger->RemoveSources(Sources);


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


[PATCH] D43041: Add X86 Support to ValidCPUList (enabling march notes)

2018-02-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: samparker, fhahn, rengolin, echristo, craig.topper.

A followup to: https://reviews.llvm.org/D42978
This patch adds X86 and X86_64 support for 
enabling the march notes.


Repository:
  rC Clang

https://reviews.llvm.org/D43041

Files:
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  test/Misc/target-invalid-cpu-note.c


Index: test/Misc/target-invalid-cpu-note.c
===
--- test/Misc/target-invalid-cpu-note.c
+++ test/Misc/target-invalid-cpu-note.c
@@ -6,3 +6,11 @@
 // AARCH64: error: unknown target CPU 'not-a-cpu'
 // AARCH64: note: valid target CPU values are: cortex-a35, cortex-a53, 
cortex-a55, cortex-a57, cortex-a72, cortex-a73, cortex-a75, cyclone, exynos-m1, 
exynos-m2, exynos-m3, falkor, saphira, kryo, thunderx2t99, thunderx, 
thunderxt88, thunderxt81, thunderxt83
 
+// RUN: not %clang_cc1 -triple i386--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix X86
+// X86: error: unknown target CPU 'not-a-cpu'
+// X86: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, 
c3, i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3, 
pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott, nocona, 
core2, penryn, bonnell, atom, silvermont, slm, goldmont, nehalem, corei7, 
westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, 
broadwell, skylake, skylake-avx512, skx, cannonlake, icelake, knl, knm, 
lakemont, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, 
k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, 
amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, 
x86-64, geode
+
+
+// RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only 
%s 2>&1 | FileCheck %s --check-prefix X86_64
+// X86_64: error: unknown target CPU 'not-a-cpu'
+// X86_64: note: valid target CPU values are: nocona, core2, penryn, bonnell, 
atom, silvermont, slm, goldmont, nehalem, corei7, westmere, sandybridge, 
corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, 
skylake-avx512, skx, cannonlake, icelake, knl, knm, k8, athlon64, athlon-fx, 
opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, 
btver2, bdver1, bdver2, bdver3, bdver4, znver1, x86-64
Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -264,6 +264,8 @@
 return checkCPUKind(getCPUKind(Name));
   }
 
+  void fillValidCPUList(SmallVectorImpl &Values) const override;
+
   bool setCPU(const std::string &Name) override {
 return checkCPUKind(CPU = getCPUKind(Name));
   }
Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -15,6 +15,7 @@
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/TargetBuiltins.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/TargetParser.h"
@@ -1648,8 +1649,6 @@
 bool X86TargetInfo::checkCPUKind(CPUKind Kind) const {
   // Perform any per-CPU checks necessary to determine if this CPU is
   // acceptable.
-  // FIXME: This results in terrible diagnostics. Clang just says the CPU is
-  // invalid without explaining *why*.
   switch (Kind) {
   case CK_Generic:
 // No processor selected!
@@ -1662,6 +1661,18 @@
   llvm_unreachable("Unhandled CPU kind");
 }
 
+void X86TargetInfo::fillValidCPUList(SmallVectorImpl &Values) const 
{
+#define PROC(ENUM, STRING, IS64BIT)
\
+  if (IS64BIT || getTriple().getArch() == llvm::Triple::x86)   
\
+Values.emplace_back(STRING);
+  // Go through CPUKind checking to ensure that the alias is de-aliased and 
+  // 64 bit-ness is checked.
+#define PROC_ALIAS(ENUM, ALIAS)
\
+  if (checkCPUKind(getCPUKind(ALIAS))) 
\
+Values.emplace_back(ALIAS);
+#include "clang/Basic/X86Target.def"
+}
+
 X86TargetInfo::CPUKind X86TargetInfo::getCPUKind(StringRef CPU) const {
   return llvm::StringSwitch(CPU)
 #define PROC(ENUM, STRING, IS64BIT) .Case(STRING, CK_##ENUM)


Index: test/Misc/target-invalid-cpu-note.c
===
--- test/Misc/target-invalid-cpu-note.c
+++ test/Misc/target-invalid-cpu-note.c
@@ -6,3 +6,11 @@
 // AARCH64: error: unknown target CPU 'not-a-cpu'
 // AARCH64: note: valid target CPU values are: cortex-a35, cortex-a53, cortex-a55, cortex-a57, cortex-a72, cortex-a73, cortex-a75, cyclone, exynos-m1, exynos-m2, exynos-m3, falkor, saphira, kryo, thunderx2t99, thunderx, thunderxt88, thunderxt81, thunderxt83
 
+// RUN: not %clang_cc1 -t

[PATCH] D40218: [Clang] Add __builtin_launder

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 133290.
EricWF added a comment.

- Rebase off master.


https://reviews.llvm.org/D40218

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGen/builtins.c
  test/CodeGenCXX/builtin-launder.cpp
  test/Preprocessor/feature_tests.c
  test/Sema/builtins.c
  test/SemaCXX/builtins.cpp

Index: test/SemaCXX/builtins.cpp
===
--- test/SemaCXX/builtins.cpp
+++ test/SemaCXX/builtins.cpp
@@ -53,3 +53,71 @@
 void synchronize_args() {
   __sync_synchronize(0); // expected-error {{too many arguments}}
 }
+
+namespace test_launder {
+
+struct Dummy {};
+
+using FnType = int(char);
+using MemFnType = int (Dummy::*)(char);
+using ConstMemFnType = int (Dummy::*)() const;
+
+void foo() {}
+
+void test_builtin_launder_diags(void *vp, const void *cvp, FnType *fnp,
+MemFnType mfp, ConstMemFnType cmfp) {
+  __builtin_launder(vp);   // expected-error {{void pointer argument to '__builtin_launder' is not allowed}}
+  __builtin_launder(cvp);  // expected-error {{void pointer argument to '__builtin_launder' is not allowed}}
+  __builtin_launder(fnp);  // expected-error {{function pointer argument to '__builtin_launder' is not allowed}}
+  __builtin_launder(mfp);  // expected-error {{non-pointer argument to '__builtin_launder' is not allowed}}
+  __builtin_launder(cmfp); // expected-error {{non-pointer argument to '__builtin_launder' is not allowed}}
+  (void)__builtin_launder(&fnp);
+  __builtin_launder(42);  // expected-error {{non-pointer argument to '__builtin_launder' is not allowed}}
+  __builtin_launder(nullptr); // expected-error {{non-pointer argument to '__builtin_launder' is not allowed}}
+  __builtin_launder(foo)  // expected-error {{non-pointer argument to '__builtin_launder' is not allowed}}
+}
+
+void test_builtin_launder(char *p, const volatile int *ip, const float *&fp,
+  double *__restrict dp) {
+  int x;
+  __builtin_launder(x); // expected-error {{non-pointer argument to '__builtin_launder' is not allowed}}
+#define TEST_TYPE(Ptr, Type) \
+  static_assert(__is_same(decltype(__builtin_launder(Ptr)), Type), "expected same type")
+  TEST_TYPE(p, char*);
+  TEST_TYPE(ip, const volatile int*);
+  TEST_TYPE(fp, const float*);
+  TEST_TYPE(dp, double *__restrict);
+#undef TEST_TYPE
+  char *d = __builtin_launder(p);
+  const volatile int *id = __builtin_launder(ip);
+  int *id2 = __builtin_launder(ip); // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const volatile int *'}}
+  const float* fd = __builtin_launder(fp);
+}
+
+template 
+constexpr Tp *test_constexpr_launder(Tp *tp) {
+  return __builtin_launder(tp);
+}
+constexpr int const_int = 42;
+constexpr int const_int2 = 101;
+constexpr const int *const_ptr = test_constexpr_launder(&const_int);
+static_assert(&const_int == const_ptr, "");
+static_assert(const_ptr != test_constexpr_launder(&const_int2), "");
+
+void test_non_constexpr() {
+  constexpr int i = 42;// expected-note {{declared here}}
+  constexpr const int *ip = __builtin_launder(&i); // expected-error {{constexpr variable 'ip' must be initialized by a constant expression}}
+  // expected-note@-1 {{pointer to 'i' is not a constant expression}}
+}
+
+constexpr bool test_in_constexpr(const int &i) {
+  return (__builtin_launder(&i) == &i);
+}
+static_assert(test_in_constexpr(const_int), "");
+void f() {
+  constexpr int i = 42;
+  // FIXME: Should this work? Since `&i` doesn't.
+  static_assert(test_in_constexpr(i), "");
+}
+
+} // end namespace test_launder
Index: test/Sema/builtins.c
===
--- test/Sema/builtins.c
+++ test/Sema/builtins.c
@@ -248,3 +248,21 @@
 
 return buf;
 }
+
+typedef void (fn_t)(int);
+
+void test_builtin_launder(char *p, void *vp, const void *cvp,
+  const volatile int *ip, float *restrict fp,
+  fn_t *fn) {
+  __builtin_launder(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+  __builtin_launder(p, p); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  int x;
+  __builtin_launder(x); // expected-error {{non-pointer argument to '__builtin_launder' is not allowed}}
+  char *d = __builtin_launder(p);
+  __builtin_launder(vp);  // expected-error {{void pointer argument to '__builtin_launder' is not allowed}}
+  __builtin_launder(cvp); // expected-error {{void pointer argument to '__builtin_launder' is not allowed}}
+  const volatile int *id = __builtin_launder(ip);
+  int *id2 = __builtin_launder(ip); // expected-warning {{discards qualifiers}}
+  float *fd = __builtin_launder(fp);
+  __builtin_launder(fn); // expected-error {{function pointer argument to '__bu

[libcxx] r324529 - Fix -verify static assert messages for older Clang versions

2018-02-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Feb  7 13:25:25 2018
New Revision: 324529

URL: http://llvm.org/viewvc/llvm-project?rev=324529&view=rev
Log:
Fix -verify static assert messages for older Clang versions

Modified:
libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.fail.cpp
libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.fail.cpp

Modified: 
libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.fail.cpp?rev=324529&r1=324528&r2=324529&view=diff
==
--- libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.fail.cpp 
(original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.fill/fill.fail.cpp 
Wed Feb  7 13:25:25 2018
@@ -23,7 +23,7 @@ int main() {
 typedef double T;
 typedef std::array C;
 C c = {};
-// expected-error-re@array:* {{static_assert failed {{.*}} "cannot fill 
zero-sized array of type 'const T'"}}
+// expected-error-re@array:* {{static_assert failed {{.*}}"cannot fill 
zero-sized array of type 'const T'"}}
 c.fill(5.5); // expected-note {{requested here}}
   }
 }

Modified: 
libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.fail.cpp?rev=324529&r1=324528&r2=324529&view=diff
==
--- libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.fail.cpp 
(original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.fail.cpp 
Wed Feb  7 13:25:25 2018
@@ -24,7 +24,7 @@ int main() {
 typedef std::array C;
 C c = {};
 C c2 = {};
-// expected-error-re@array:* {{static_assert failed {{.*}} "cannot swap 
zero-sized array of type 'const T'"}}
+// expected-error-re@array:* {{static_assert failed {{.*}}"cannot swap 
zero-sized array of type 'const T'"}}
 c.swap(c2); // expected-note {{requested here}}
   }
 }


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


[PATCH] D42680: [ThinLTO] Ignore object files with no ThinLTO modules if -fthinlto-index= is set

2018-02-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

ping


https://reviews.llvm.org/D42680



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


[PATCH] D37035: Implement __builtin_LINE() et. al. to support source location capture.

2018-02-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 133294.
EricWF added reviewers: aaron.ballman, bogner, majnemer.
EricWF added a comment.

Ping.

- Rebase off trunk.


https://reviews.llvm.org/D37035

Files:
  docs/LanguageExtensions.rst
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/SourceLocExprScope.h
  include/clang/AST/Stmt.h
  include/clang/Basic/StmtNodes.td
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTImporter.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/CodeGenCXX/builtin_FUNCTION.cpp
  test/CodeGenCXX/builtin_LINE.cpp
  test/CodeGenCXX/debug-info-line.cpp
  test/Parser/builtin_source_location.c
  test/Sema/source_location.c
  test/SemaCXX/Inputs/source-location-file.h
  test/SemaCXX/source_location.cpp

Index: test/SemaCXX/source_location.cpp
===
--- /dev/null
+++ test/SemaCXX/source_location.cpp
@@ -0,0 +1,475 @@
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify %s
+// expected-no-diagnostics
+
+#define assert(...) ((__VA_ARGS__) ? ((void)0) : throw 42)
+#define CURRENT_FROM_MACRO() SL::current()
+#define FORWARD(...) __VA_ARGS__
+
+namespace std {
+namespace experimental {
+struct source_location {
+private:
+  unsigned int __m_line = 0;
+  unsigned int __m_col = 0;
+  const char *__m_file = nullptr;
+  const char *__m_func = nullptr;
+public:
+  static constexpr source_location current(
+  const char *__file = __builtin_FILE(),
+  const char *__func = __builtin_FUNCTION(),
+  unsigned int __line = __builtin_LINE(),
+  unsigned int __col = __builtin_COLUMN()) noexcept {
+source_location __loc;
+__loc.__m_line = __line;
+__loc.__m_col = __col;
+__loc.__m_file = __file;
+__loc.__m_func = __func;
+return __loc;
+  }
+  constexpr source_location() = default;
+  constexpr source_location(source_location const &) = default;
+  constexpr unsigned int line() const noexcept { return __m_line; }
+  constexpr unsigned int column() const noexcept { return __m_col; }
+  constexpr const char *file() const noexcept { return __m_file; }
+  constexpr const char *function() const noexcept { return __m_func; }
+};
+} // namespace experimental
+} // namespace std
+
+using SL = std::experimental::source_location;
+
+#include "Inputs/source-location-file.h"
+namespace SLF = source_location_file;
+
+constexpr bool is_equal(const char *LHS, const char *RHS) {
+  while (*LHS != 0 && *RHS != 0) {
+if (*LHS != *RHS)
+  return false;
+++LHS;
+++RHS;
+  }
+  return *LHS == 0 && *RHS == 0;
+}
+
+template 
+constexpr T identity(T t) {
+  return t;
+}
+
+template 
+struct Pair {
+  T first;
+  U second;
+};
+
+template 
+constexpr bool is_same = false;
+template 
+constexpr bool is_same = true;
+
+// test types
+static_assert(is_same);
+static_assert(is_same);
+static_assert(is_same);
+static_assert(is_same);
+
+// test noexcept
+static_assert(noexcept(__builtin_LINE()));
+static_assert(noexcept(__builtin_COLUMN()));
+static_assert(noexcept(__builtin_FILE()));
+static_assert(noexcept(__builtin_FUNCTION()));
+
+//===--===//
+//__builtin_LINE()
+//===--===//
+
+namespace test_line {
+
+static_assert(SL::current().line() == __LINE__);
+static_assert(SL::current().line() == CURRENT_FROM_MACRO().line());
+
+static constexpr SL GlobalS = SL::current();
+
+static_assert(GlobalS.line() == __LINE__ - 2);
+
+// clang-format off
+constexpr bool test_line_fn() {
+  constexpr SL S = SL::current();
+  static_assert(S.line() == (__LINE__ - 1), "");
+  // The start of the call expression to `current()` begins at the token `SL`
+  constexpr int ExpectLine = __LINE__ + 3;
+  constexpr SL S2
+  =
+  SL // Call expression starts here
+  ::
+  current
+  (
+
+  )
+  ;
+  static_assert(S2.line() == ExpectLine, "");
+
+  static_assert(
+  FORWARD(
+ __builtin_LINE
+(
+)
+  )
+== __LINE__ - 1, "");
+  static_assert(\
+\
+  __builtin_LINE()\
+\
+  == __LINE__ - 2, "");
+  static_assert(\
+  _\
+_builtin_LINE()
+  == __LINE__ - 2, "");
+
+  return true;
+}
+// clang-format on
+static_assert(test_line_fn());
+
+

[libcxx] r324531 - Fix PR#31454 - 'basic_string::push_back() crashes if sizeof(T)>sizeof(long long)'. We were mishandling the small-string optimization calculations for very large 'characters'. Thi

2018-02-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Feb  7 13:30:17 2018
New Revision: 324531

URL: http://llvm.org/viewvc/llvm-project?rev=324531&view=rev
Log:
Fix PR#31454 - 'basic_string::push_back() crashes if sizeof(T)>sizeof(long 
long)'. We were mishandling the small-string optimization calculations for very 
large 'characters'. This may be an ABI change (change the size of) strings of 
very large 'characters', but since they never worked, I'm not too concerned.

Modified:
libcxx/trunk/include/string

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=324531&r1=324530&r2=324531&view=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Wed Feb  7 13:30:17 2018
@@ -1363,9 +1363,13 @@ private:
 enum {__alignment = 16};
 static _LIBCPP_INLINE_VISIBILITY
 size_type __recommend(size_type __s) _NOEXCEPT
-{return (__s < __min_cap ? static_cast(__min_cap) :
- __align_it (__s+1)) - 1;}
+{
+if (__s < __min_cap) return static_cast(__min_cap) - 1;
+size_type __guess = __align_it (__s+1) - 1;
+if (__guess == __min_cap) ++__guess;
+return __guess;
+}
 
 inline
 void __init(const value_type* __s, size_type __sz, size_type __reserve);

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp?rev=324531&r1=324530&r2=324531&view=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
 Wed Feb  7 13:30:17 2018
@@ -48,7 +48,7 @@ int main()
 test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
 }
 #endif
-#if 0
+
 {
 // https://bugs.llvm.org/show_bug.cgi?id=31454
 std::basic_string s;
@@ -57,5 +57,4 @@ int main()
 s.push_back(vl);
 s.push_back(vl);
 }
-#endif
 }


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


[PATCH] D43044: [DebugInfo] Update Checksum handling in CGDebugInfo

2018-02-07 Thread Scott Linder via Phabricator via cfe-commits
scott.linder created this revision.
scott.linder added reviewers: aprantl, JDevlieghere.
Herald added a subscriber: cfe-commits.
scott.linder added a dependency: D43043: [DebugInfo] Unify ChecksumKind and 
Checksum value in DIFile.

Update to match new DIFile API.


Repository:
  rC Clang

https://reviews.llvm.org/D43044

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

Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -499,8 +499,8 @@
   std::string remapDIPath(StringRef) const;
 
   /// Compute the file checksum debug info for input file ID.
-  llvm::DIFile::ChecksumKind computeChecksum(FileID FID,
- SmallString<32> &Checksum) const;
+  Optional
+  computeChecksum(FileID FID, SmallString<32> &Checksum) const;
 
   /// Get the file debug info descriptor for the input location.
   llvm::DIFile *getOrCreateFile(SourceLocation Loc);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -361,19 +361,19 @@
   return StringRef();
 }
 
-llvm::DIFile::ChecksumKind
+Optional
 CGDebugInfo::computeChecksum(FileID FID, SmallString<32> &Checksum) const {
   Checksum.clear();
 
   if (!CGM.getCodeGenOpts().EmitCodeView &&
   CGM.getCodeGenOpts().DwarfVersion < 5)
-return llvm::DIFile::CSK_None;
+return None;
 
   SourceManager &SM = CGM.getContext().getSourceManager();
   bool Invalid;
   llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID, &Invalid);
   if (Invalid)
-return llvm::DIFile::CSK_None;
+return None;
 
   llvm::MD5 Hash;
   llvm::MD5::MD5Result Result;
@@ -390,7 +390,6 @@
 // If Location is not valid then use main input file.
 return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
remapDIPath(TheCU->getDirectory()),
-   TheCU->getFile()->getChecksumKind(),
TheCU->getFile()->getChecksum());
 
   SourceManager &SM = CGM.getContext().getSourceManager();
@@ -400,7 +399,6 @@
 // If the location is not valid then use main input file.
 return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
remapDIPath(TheCU->getDirectory()),
-   TheCU->getFile()->getChecksumKind(),
TheCU->getFile()->getChecksum());
 
   // Cache the results.
@@ -414,21 +412,23 @@
   }
 
   SmallString<32> Checksum;
-  llvm::DIFile::ChecksumKind CSKind =
+  Optional CSKind =
   computeChecksum(SM.getFileID(Loc), Checksum);
+  Optional> CSInfo;
+  if (CSKind)
+CSInfo.emplace(*CSKind, Checksum);
 
   llvm::DIFile *F = DBuilder.createFile(remapDIPath(PLoc.getFilename()),
 remapDIPath(getCurrentDirname()),
-CSKind, Checksum);
+CSInfo);
 
   DIFileCache[fname].reset(F);
   return F;
 }
 
 llvm::DIFile *CGDebugInfo::getOrCreateMainFile() {
   return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
  remapDIPath(TheCU->getDirectory()),
- TheCU->getFile()->getChecksumKind(),
  TheCU->getFile()->getChecksum());
 }
 
@@ -473,7 +473,8 @@
 
 void CGDebugInfo::CreateCompileUnit() {
   SmallString<32> Checksum;
-  llvm::DIFile::ChecksumKind CSKind = llvm::DIFile::CSK_None;
+  Optional CSKind;
+  Optional> CSInfo;
 
   // Should we be asking the SourceManager for the main file name, instead of
   // accepting it as an argument? This just causes the main file name to
@@ -552,13 +553,16 @@
 break;
   }
 
+  if (CSKind)
+CSInfo.emplace(*CSKind, Checksum);
+
   // Create new compile unit.
   // FIXME - Eliminate TheCU.
   auto &CGOpts = CGM.getCodeGenOpts();
   TheCU = DBuilder.createCompileUnit(
   LangTag,
   DBuilder.createFile(remapDIPath(MainFileName),
-  remapDIPath(getCurrentDirname()), CSKind, Checksum),
+  remapDIPath(getCurrentDirname()), CSInfo),
   Producer, LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex,
   CGOpts.DwarfDebugFlags, RuntimeVers,
   CGOpts.EnableSplitDwarf ? "" : CGOpts.SplitDwarfFile, EmissionKind,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42991: [analyzer] Use EvalCallOptions for destructors as well.

2018-02-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 133299.
NoQ added a comment.

Remove the check in `shouldInlineCall()` as well. It's quite covered by the 
`IsConstructorWithImproperlyModeledTargetRegion` check.


https://reviews.llvm.org/D42991

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  test/Analysis/new.cpp

Index: test/Analysis/new.cpp
===
--- test/Analysis/new.cpp
+++ test/Analysis/new.cpp
@@ -311,7 +311,8 @@
 void testArrayDestr() {
   NoReturnDtor *p = new NoReturnDtor[2];
   delete[] p; // Calls the base destructor which aborts, checked below
-  clang_analyzer_eval(true); // no-warning
+   //TODO: clang_analyzer_eval should not be called
+  clang_analyzer_eval(true); // expected-warning{{TRUE}}
 }
 
 // Invalidate Region even in case of default destructor
Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -650,7 +650,7 @@
 // initializers for array fields in default move/copy constructors.
 // We still allow construction into ElementRegion targets when they don't
 // represent array elements.
-if (CallOpts.IsArrayConstructorOrDestructor)
+if (CallOpts.IsArrayCtorOrDtor)
   return CIP_DisallowedOnce;
 
 // Inlining constructors requires including initializers in the CFG.
@@ -670,14 +670,14 @@
 if (CtorExpr->getConstructionKind() == CXXConstructExpr::CK_Complete) {
   // If we don't handle temporary destructors, we shouldn't inline
   // their constructors.
-  if (CallOpts.IsConstructorIntoTemporary &&
+  if (CallOpts.IsTemporaryCtorOrDtor &&
   !Opts.includeTemporaryDtorsInCFG())
 return CIP_DisallowedOnce;
 
-  // If we did not construct the correct this-region, it would be pointless
+  // If we did not find the correct this-region, it would be pointless
   // to inline the constructor. Instead we will simply invalidate
   // the fake temporary target.
-  if (CallOpts.IsConstructorWithImproperlyModeledTargetRegion)
+  if (CallOpts.IsCtorOrDtorWithImproperlyModeledTargetRegion)
 return CIP_DisallowedOnce;
 }
 
@@ -693,9 +693,14 @@
 (void)ADC;
 
 // FIXME: We don't handle constructors or destructors for arrays properly.
-if (CallOpts.IsArrayConstructorOrDestructor)
+if (CallOpts.IsArrayCtorOrDtor)
   return CIP_DisallowedOnce;
 
+// If we did not find the correct this-region, it would be pointless
+// to inline the destructor. Instead we will simply invalidate
+// the fake temporary target.
+if (CallOpts.IsCtorOrDtorWithImproperlyModeledTargetRegion)
+  return CIP_DisallowedOnce;
 break;
   }
   case CE_CXXAllocator:
@@ -844,14 +849,6 @@
   AnalysisDeclContextManager &ADCMgr = AMgr.getAnalysisDeclContextManager();
   AnalysisDeclContext *CalleeADC = ADCMgr.getContext(D);
 
-  // Temporary object destructor processing is currently broken, so we never
-  // inline them.
-  // FIXME: Remove this once temp destructors are working.
-  if (isa(Call)) {
-if ((*currBldrCtx->getBlock())[currStmtIdx].getAs())
-  return false;
-  }
-
   // The auto-synthesized bodies are essential to inline as they are
   // usually small and commonly used. Note: we should do this check early on to
   // ensure we always inline these calls.
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -84,16 +84,8 @@
 }
 
 
-/// Returns a region representing the first element of a (possibly
-/// multi-dimensional) array, for the purposes of element construction or
-/// destruction.
-///
-/// On return, \p Ty will be set to the base type of the array.
-///
-/// If the type is not an array type at all, the original value is returned.
-/// Otherwise the "IsArray" flag is set.
-static SVal makeZeroElementRegion(ProgramStateRef State, SVal LValue,
-  QualType &Ty, bool &IsArray) {
+SVal ExprEngine::makeZeroElementRegion(ProgramStateRef State, SVal LValue,
+   QualType &Ty, bool &IsArray) {
   SValBuilder &SVB = State->getStateManager().getSValBuilder();
   ASTContext &Ctx = SVB.getContext();
 
@@ -128,7 +120,7 @@
 if (CNE->isArray()) {
   // TODO: In fact, we need to call the constructor for every
   // allocated element, not just the first one!
-  CallOpts.IsArrayConstructorOrDestructor = true;
+  CallOpts.IsArrayCtorOrDtor = true;
   return getStoreManager().GetElementZeroRegion(
 

[libcxx] r324534 - Stop using __strtonum_fallback on Android.

2018-02-07 Thread Dan Albert via cfe-commits
Author: danalbert
Date: Wed Feb  7 13:58:48 2018
New Revision: 324534

URL: http://llvm.org/viewvc/llvm-project?rev=324534&view=rev
Log:
Stop using __strtonum_fallback on Android.

Fallback implementations are now provided by bionic when necessary,
which these may conflict with.

Modified:
libcxx/trunk/include/support/android/locale_bionic.h

Modified: libcxx/trunk/include/support/android/locale_bionic.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/android/locale_bionic.h?rev=324534&r1=324533&r2=324534&view=diff
==
--- libcxx/trunk/include/support/android/locale_bionic.h (original)
+++ libcxx/trunk/include/support/android/locale_bionic.h Wed Feb  7 13:58:48 
2018
@@ -25,7 +25,6 @@ extern "C" {
 #endif
 
 #include 
-#include 
 
 #endif // defined(__BIONIC__)
 #endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H


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


[PATCH] D43045: Add NVPTX Support to ValidCPUList (enabling march notes)

2018-02-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: samparker, fhahn, rengolin, echristo, Hahnfeld.
Herald added a subscriber: jholewinski.

A followup to: https://reviews.llvm.org/D42978
This patch adds NVPTX support for
enabling the march notes.


Repository:
  rC Clang

https://reviews.llvm.org/D43045

Files:
  include/clang/Basic/Cuda.h
  lib/Basic/Cuda.cpp
  lib/Basic/Targets/NVPTX.cpp
  lib/Basic/Targets/NVPTX.h
  test/Misc/target-invalid-cpu-note.c


Index: test/Misc/target-invalid-cpu-note.c
===
--- test/Misc/target-invalid-cpu-note.c
+++ test/Misc/target-invalid-cpu-note.c
@@ -14,3 +14,7 @@
 // RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only 
%s 2>&1 | FileCheck %s --check-prefix X86_64
 // X86_64: error: unknown target CPU 'not-a-cpu'
 // X86_64: note: valid target CPU values are: nocona, core2, penryn, bonnell, 
atom, silvermont, slm, goldmont, nehalem, corei7, westmere, sandybridge, 
corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, 
skylake-avx512, skx, cannonlake, icelake, knl, knm, k8, athlon64, athlon-fx, 
opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, 
btver2, bdver1, bdver2, bdver3, bdver4, znver1, x86-64
+
+// RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix NVPTX
+// NVPTX: error: unknown target CPU 'not-a-cpu'
+// NVPTX: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, 
sm_35, sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72
Index: lib/Basic/Targets/NVPTX.h
===
--- lib/Basic/Targets/NVPTX.h
+++ lib/Basic/Targets/NVPTX.h
@@ -98,6 +98,12 @@
 return StringToCudaArch(Name) != CudaArch::UNKNOWN;
   }
 
+  void fillValidCPUList(SmallVectorImpl &Values) const override {
+for (int i = static_cast(CudaArch::SM_20);
+ i < static_cast(CudaArch::LAST); ++i)
+  Values.emplace_back(CudaArchToString(static_cast(i)));
+  }
+
   bool setCPU(const std::string &Name) override {
 GPU = StringToCudaArch(Name);
 return GPU != CudaArch::UNKNOWN;
Index: lib/Basic/Targets/NVPTX.cpp
===
--- lib/Basic/Targets/NVPTX.cpp
+++ lib/Basic/Targets/NVPTX.cpp
@@ -157,6 +157,8 @@
 // Set __CUDA_ARCH__ for the GPU specified.
 std::string CUDAArchCode = [this] {
   switch (GPU) {
+  case CudaArch::LAST:
+break;
   case CudaArch::UNKNOWN:
 assert(false && "No GPU arch when compiling CUDA device code.");
 return "";
Index: lib/Basic/Cuda.cpp
===
--- lib/Basic/Cuda.cpp
+++ lib/Basic/Cuda.cpp
@@ -26,6 +26,8 @@
 
 const char *CudaArchToString(CudaArch A) {
   switch (A) {
+  case CudaArch::LAST:
+break;
   case CudaArch::UNKNOWN:
 return "unknown";
   case CudaArch::SM_20:
@@ -133,6 +135,8 @@
 
 CudaVirtualArch VirtualArchForCudaArch(CudaArch A) {
   switch (A) {
+  case CudaArch::LAST:
+break;
   case CudaArch::UNKNOWN:
 return CudaVirtualArch::UNKNOWN;
   case CudaArch::SM_20:
@@ -168,6 +172,8 @@
 
 CudaVersion MinVersionForCudaArch(CudaArch A) {
   switch (A) {
+  case CudaArch::LAST:
+break;
   case CudaArch::UNKNOWN:
 return CudaVersion::UNKNOWN;
   case CudaArch::SM_20:
Index: include/clang/Basic/Cuda.h
===
--- include/clang/Basic/Cuda.h
+++ include/clang/Basic/Cuda.h
@@ -46,6 +46,7 @@
   SM_62,
   SM_70,
   SM_72,
+  LAST,
 };
 const char *CudaArchToString(CudaArch A);
 


Index: test/Misc/target-invalid-cpu-note.c
===
--- test/Misc/target-invalid-cpu-note.c
+++ test/Misc/target-invalid-cpu-note.c
@@ -14,3 +14,7 @@
 // RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86_64
 // X86_64: error: unknown target CPU 'not-a-cpu'
 // X86_64: note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cannonlake, icelake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, x86-64
+
+// RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX
+// NVPTX: error: unknown target CPU 'not-a-cpu'
+// NVPTX: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, sm_35, sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72
Index: lib/Basic/Targets/NVPTX.h
===
--- lib/Basic/Targets/NVPTX.h
+++ lib/Basic/Targets/NVPT

[PATCH] D36802: AMDGPU: Cleanup most of the macros

2018-02-07 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

Need to only define canonical names.


https://reviews.llvm.org/D36802



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


[PATCH] D42933: [Sema] Avoid -Wformat warning for NSInteger/NSUInteger 'int' values with %zu/%zi long specifiers

2018-02-07 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman abandoned this revision.
arphaman added subscribers: dcoughlin, dexonsmith.
arphaman added a comment.

Thanks for your input. You're right, this warning is quite correct (even though 
it seems like too much).

I discussed this with @dexonsmith  and @dcoughlin and we decided to keep the 
warning as is and to avoid establishing new guidelines. I'm closing this one.


Repository:
  rC Clang

https://reviews.llvm.org/D42933



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


r324535 - Recommit r324107 again.

2018-02-07 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb  7 14:15:33 2018
New Revision: 324535

URL: http://llvm.org/viewvc/llvm-project?rev=324535&view=rev
Log:
Recommit r324107 again.

The difference from the previous try is that we no longer directly
access function declarations from position independent executables. It
should work, but currently doesn't with some linkers.

It now includes a fix to not mark available_externally definitions as
dso_local.

Original message:

Start setting dso_local in clang.

This starts adding dso_local to clang.

The hope is to eventually have TargetMachine::shouldAssumeDsoLocal go
away. My objective for now is to move enough of it to clang to remove
the need for the TargetMachine one to handle PIE copy relocations and
-fno-plt. With that it should then be easy to implement a
-fno-copy-reloc in clang.

This patch just adds the cases where we assume a symbol to be local
based on the file being compiled for an executable or a shared
library.

Added:
cfe/trunk/test/CodeGen/dso-local-executable.c
cfe/trunk/test/CodeGenCXX/dso-local-executable.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGVTT.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGen/mbackchain-2.c
cfe/trunk/test/CodeGen/mbackchain-3.c
cfe/trunk/test/CodeGen/mips-vector-return.c
cfe/trunk/test/CodeGen/split-stacks.c
cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template.cpp
cfe/trunk/test/CodeGenCXX/float16-declarations.cpp
cfe/trunk/test/CodeGenCXX/split-stacks.cpp
cfe/trunk/test/Driver/lanai-unknown-unknown.cpp
cfe/trunk/test/Driver/le32-unknown-nacl.cpp
cfe/trunk/test/Driver/le64-unknown-unknown.cpp
cfe/trunk/test/Driver/riscv32-toolchain.c
cfe/trunk/test/Driver/riscv64-toolchain.c
cfe/trunk/test/Frontend/ast-codegen.c

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=324535&r1=324534&r2=324535&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Feb  7 14:15:33 2018
@@ -240,7 +240,7 @@ llvm::Constant *CodeGenModule::getOrCrea
   getModule(), LTy, Ty.isConstant(getContext()), Linkage, Init, Name,
   nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
   GV->setAlignment(getContext().getDeclAlign(&D).getQuantity());
-  setGlobalVisibility(GV, &D);
+  setGVProperties(GV, &D);
 
   if (supportsCOMDAT() && GV->isWeakForLinker())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
@@ -344,6 +344,7 @@ CodeGenFunction::AddInitializerToStaticV
   OldGV->getThreadLocalMode(),

CGM.getContext().getTargetAddressSpace(D.getType()));
 GV->setVisibility(OldGV->getVisibility());
+GV->setDSOLocal(OldGV->isDSOLocal());
 GV->setComdat(OldGV->getComdat());
 
 // Steal the name of the old global

Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=324535&r1=324534&r2=324535&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Wed Feb  7 14:15:33 2018
@@ -100,7 +100,7 @@ CodeGenVTables::EmitVTTDefinition(llvm::
 VTT->setComdat(CGM.getModule().getOrInsertComdat(VTT->getName()));
 
   // Set the right visibility.
-  CGM.setGlobalVisibility(VTT, RD);
+  CGM.setGVProperties(VTT, RD);
 }
 
 llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=324535&r1=324534&r2=324535&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Feb  7 14:15:33 2018
@@ -51,7 +51,7 @@ llvm::Constant *CodeGenModule::GetAddrOf
 
 static void setThunkVisibility(CodeGenModule &CGM, const CXXMethodDecl *MD,
const ThunkInfo &Thunk, llvm::Function *Fn) {
-  CGM.setGlobalVisibility(Fn, MD);
+  CGM.setGVProperties(Fn, MD);
 }
 
 static void setThunkProperties(CodeGenModule &CGM, const ThunkInfo &Thunk,
@@ -730,7 +730,7 @@ CodeGenVTables::GenerateConstructionVTab
   // Create the variable that will hold the construction vtable.
   llvm::GlobalVariable *VTable =
 CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage);
-  CGM.setGlobalVisibility(VTable, RD);
+  CGM.setGVProperties(VTable, RD);
 
   // V-tables are always unnamed_addr.
   VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);

Modified: cfe/tr

  1   2   >