[PATCH] D50447: [clang-tidy] Add a whitelistClasses option in performance-for-range-copy check.

2018-08-08 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment.

In https://reviews.llvm.org/D50447#1192393, @JonasToth wrote:

> ... just check if the variable is dereferenced in the scope of the loop (any
>  declRefExpr exists).


+1
And I would imagine it's very rare (as in categories not raw number of 
occurrences) for a loop variable to be not used in the loop body so it's 
probably a safe change. Though I'm interested to learn whether there's any real 
false negative by doing this.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50447



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


[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

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



Comment at: lib/CodeGen/CGBlocks.cpp:1682
+  if (IsCopyHelper && Ctx.getBlockVarCopyInits(Var).CanThrow)
+Name += "c";
+}

ahatanak wrote:
> rjmccall wrote:
> > I don't think you need to add `d` to the name of a copy helper.  It's a bit 
> > weird, but while copying a `__block` variable can cause its copy helper to 
> > run, destroying it immediately afterwards can never cause its destroy 
> > helper to run.  That's because a newly-copied `__block` variable always has 
> > a reference count of 2: the new reference in the copy and the forwarding 
> > reference from the original.
> > 
> > I think that means you can just add a single letter which specifies whether 
> > the corresponding `__block` variable operation is known to be able to throw.
> I added 'd' to the name of the copy helper functions only because IRGen 
> generates different code depending on whether the destructor can throw or not.
> 
> For example, if I compile the following code with -DTHROWS, IRGen uses 
> 'invoke' (which jumps to the terminate block) for the calls to 
> `_Block_object_dispose` on the EH path whereas it uses 'call' if the 
> destructor doesn't throw.
> 
> ```
> struct S {
>   S();
> #ifdef THROWS
>   ~S() noexcept(false);
> #else
>   ~S() noexcept(true);
> #endif
>   S(const S &);
>   int a;
> };
> 
> void test() {
>   __block S s0, s1, s2;
>   ^{ (void)s0, (void)s1; (void)s2; };
> }
> ```
> 
> It seems like IRGen doesn't have to use 'invoke' when emitting a call to  
> `_Block_object_dispose` even when the class has a destructor that can throw, 
> if I understood your explanation correctly?
Right.  It's specifically only true when unwinding after a copy, which is very 
atypical for C++ code, but nonetheless it's true.  We should make the call 
`nounwind` in these situations and leave a comment explaining why.  Did my 
explanation make any sense?



Comment at: lib/CodeGen/CGBlocks.cpp:1688
+if (F == BLOCK_FIELD_IS_BLOCK)
+  Name += "b";
+  }

ahatanak wrote:
> rjmccall wrote:
> > Why `rb` for a captured block instead of some single-letter thing?  You 
> > don't need to emulate the structure of the flags here.
> I can use a single letter here, but I'm already using 'b' for byref captures. 
> Perhaps I can use 'o' for non-arc objects, instead of 'r', and use 'r' for 
> byref?
That seems reasonable.


Repository:
  rC Clang

https://reviews.llvm.org/D50152



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


[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

2018-08-08 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: include/clang/AST/ASTContext.h:158
+Expr *CopyExpr;
+bool CanThrow;
+  };

rjmccall wrote:
> Using a PointerIntPair in the implementation of this is still a reasonable 
> choice.  Just make it a proper abstraction, with a constructor with the two 
> arguments and getters for the two fields.
I also needed a function that sets the pointer and flag.



Comment at: lib/CodeGen/CGBlocks.cpp:1682
+  if (IsCopyHelper && Ctx.getBlockVarCopyInits(Var).CanThrow)
+Name += "c";
+}

rjmccall wrote:
> I don't think you need to add `d` to the name of a copy helper.  It's a bit 
> weird, but while copying a `__block` variable can cause its copy helper to 
> run, destroying it immediately afterwards can never cause its destroy helper 
> to run.  That's because a newly-copied `__block` variable always has a 
> reference count of 2: the new reference in the copy and the forwarding 
> reference from the original.
> 
> I think that means you can just add a single letter which specifies whether 
> the corresponding `__block` variable operation is known to be able to throw.
I added 'd' to the name of the copy helper functions only because IRGen 
generates different code depending on whether the destructor can throw or not.

For example, if I compile the following code with -DTHROWS, IRGen uses 'invoke' 
(which jumps to the terminate block) for the calls to `_Block_object_dispose` 
on the EH path whereas it uses 'call' if the destructor doesn't throw.

```
struct S {
  S();
#ifdef THROWS
  ~S() noexcept(false);
#else
  ~S() noexcept(true);
#endif
  S(const S &);
  int a;
};

void test() {
  __block S s0, s1, s2;
  ^{ (void)s0, (void)s1; (void)s2; };
}
```

It seems like IRGen doesn't have to use 'invoke' when emitting a call to  
`_Block_object_dispose` even when the class has a destructor that can throw, if 
I understood your explanation correctly?



Comment at: lib/CodeGen/CGBlocks.cpp:1688
+if (F == BLOCK_FIELD_IS_BLOCK)
+  Name += "b";
+  }

rjmccall wrote:
> Why `rb` for a captured block instead of some single-letter thing?  You don't 
> need to emulate the structure of the flags here.
I can use a single letter here, but I'm already using 'b' for byref captures. 
Perhaps I can use 'o' for non-arc objects, instead of 'r', and use 'r' for 
byref?



Comment at: lib/CodeGen/CGBlocks.cpp:1705
+  IsVolatile, Ctx);
+  Name += llvm::to_string(Str.size()) + "_" + Str;
+  break;

rjmccall wrote:
> The underscore is necessary here because non-trivial destructor strings can 
> start with a number?  Worth a comment.
Yes, that's correct.


Repository:
  rC Clang

https://reviews.llvm.org/D50152



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


[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

2018-08-08 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 159850.
ahatanak marked 5 inline comments as done.
ahatanak added a comment.

Address review comments.


Repository:
  rC Clang

https://reviews.llvm.org/D50152

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBlocks.h
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGNonTrivialStruct.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaDecl.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/blocks-1.c
  test/CodeGen/blocks.c
  test/CodeGen/sanitize-thread-no-checking-at-run-time.m
  test/CodeGenCXX/block-byref-cxx-objc.cpp
  test/CodeGenCXX/blocks.cpp
  test/CodeGenCXX/cxx-block-objects.cpp
  test/CodeGenObjC/arc-blocks.m
  test/CodeGenObjC/debug-info-block-helper.m
  test/CodeGenObjC/debug-info-blocks.m
  test/CodeGenObjC/mrc-weak.m
  test/CodeGenObjC/strong-in-c-struct.m
  test/CodeGenObjCXX/arc-blocks.mm
  test/CodeGenObjCXX/lambda-to-block.mm
  test/CodeGenObjCXX/mrc-weak.mm
  test/PCH/block-helpers.cpp
  test/PCH/block-helpers.h

Index: test/PCH/block-helpers.h
===
--- /dev/null
+++ test/PCH/block-helpers.h
@@ -0,0 +1,12 @@
+struct S0 {
+  S0();
+  S0(const S0 &) noexcept(false);
+  int a;
+};
+
+struct S {
+  void m() {
+__block S0 x, y;
+^{ (void)x; (void)y; };
+  }
+};
Index: test/PCH/block-helpers.cpp
===
--- /dev/null
+++ test/PCH/block-helpers.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -x c++-header -triple x86_64-apple-darwin11 -emit-pch -fblocks -fexceptions -o %t %S/block-helpers.h
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -include-pch %t -emit-llvm -fblocks -fexceptions -o - %s | FileCheck %s
+
+// The second call to block_object_assign should be an invoke.
+
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_e8_32bc40bc(
+// CHECK: call void @_Block_object_assign(
+// CHECK: invoke void @_Block_object_assign(
+// CHECK: call void @_Block_object_dispose(
+
+// CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block_e8_32b40b(
+void test() {
+  S s;
+  s.m();
+}
Index: test/CodeGenObjCXX/mrc-weak.mm
===
--- test/CodeGenObjCXX/mrc-weak.mm
+++ test/CodeGenObjCXX/mrc-weak.mm
@@ -119,10 +119,10 @@
 // CHECK:   call void @use_block
 // CHECK:   call void @objc_destroyWeak
 
-// CHECK-LABEL: define internal void @__copy_helper_block
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block
 // CHECK:   @objc_copyWeak
 
-// CHECK-LABEL: define internal void @__destroy_helper_block
+// CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block
 // CHECK:   @objc_destroyWeak
 
 void test8(void) {
@@ -142,8 +142,8 @@
 // CHECK:   call void @objc_destroyWeak
 
 // CHECK-LABEL: define void @_Z14test9_baselinev()
-// CHECK:   define internal void @__copy_helper
-// CHECK:   define internal void @__destroy_helper
+// CHECK:   define linkonce_odr hidden void @__copy_helper
+// CHECK:   define linkonce_odr hidden void @__destroy_helper
 void test9_baseline(void) {
   Foo *p = get_object();
   use_block(^{ [p run]; });
Index: test/CodeGenObjCXX/lambda-to-block.mm
===
--- test/CodeGenObjCXX/lambda-to-block.mm
+++ test/CodeGenObjCXX/lambda-to-block.mm
@@ -12,7 +12,7 @@
 void hasLambda(Copyable x) {
   takesBlock([x] () { });
 }
-// CHECK-LABEL: define internal void @__copy_helper_block_
+// CHECK-LABEL: define internal void @"__copy_helper_block_
 // CHECK: call void @"_ZZ9hasLambda8CopyableEN3$_0C1ERKS0_"
 // CHECK-LABEL: define internal void @"_ZZ9hasLambda8CopyableEN3$_0C2ERKS0_"
 // CHECK: call void @_ZN8CopyableC1ERKS_
Index: test/CodeGenObjCXX/arc-blocks.mm
===
--- test/CodeGenObjCXX/arc-blocks.mm
+++ test/CodeGenObjCXX/arc-blocks.mm
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -o - %s | FileCheck -check-prefix CHECK %s
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -O1 -o - %s | FileCheck -check-prefix CHECK-O1 %s
+// RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck -check-prefix CHECK-NOEXCP %s
 
 // CHECK: [[A:.*]] = type { i64, [10 x i8*] }
 // CHECK: %[[STRUCT_TEST1_S0:.*]] = type { i32 }
+// CHECK: %[[STRUCT_TRIVIAL_INTERNAL:.*]] = type { i32 }
 // CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 }
 
 // CHECK: [[LAYOUT0:@.*]] = private unnamed_addr constant [3 x i8] c" 9\00"
@@ -55,34 +57,34 @@
 
 // 

[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like keys

2018-08-08 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang created this revision.
mgrang added reviewers: NoQ, george.karpenkov, whisperity.
Herald added subscribers: mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
xazax.hun, mgorny.

Repository:
  rC Clang

https://reviews.llvm.org/D50488

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp
  test/Analysis/ptr-sort.cpp

Index: test/Analysis/ptr-sort.cpp
===
--- /dev/null
+++ test/Analysis/ptr-sort.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.nondeterminism.PointerSorting %s -analyzer-output=text -verify
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+namespace std {
+  template
+  void sort(RandomAccessIterator first, RandomAccessIterator last);
+}
+
+void PointerSorting() {
+  int a = 1, b = 2;
+
+  std::vector V1 = {a, b};
+  std::sort(V1.begin(), V1.end()); // no-warning
+
+  std::vector V2 = {, };
+  std::sort(V2.begin(), V2.end()); // expected-warning {{Non-deterministic sorting of pointer-like keys}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Non-deterministic sorting of pointer-like keys}} [alpha.nondeterminism.PointerSorting]
+}
Index: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp
@@ -0,0 +1,123 @@
+//=== PointerSortingChecker.cpp - Pointer Sorting Checker ---*- C++ -*---=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file defines PointerSortingChecker, a builtin checker that checks for
+// non-determinism caused by sorting of pointer-like keys.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/AST/StmtVisitor.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
+
+#define DEBUG_TYPE "check-pointer-sort"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+// PointerSortingVisitor class.
+class PointerSortingVisitor : public StmtVisitor {
+  BugReporter 
+  const CheckerBase *Checker;
+  AnalysisDeclContext* AC;
+
+private:
+  void reportPointerSortingDiagnostic(CallExpr *CE);
+
+public:
+  PointerSortingVisitor(BugReporter ,
+const CheckerBase *checker,
+AnalysisDeclContext *ac)
+  : BR(br), Checker(checker), AC(ac) {}
+  void VisitStmt(Stmt *S) { VisitChildren(S); }
+  void VisitChildren(Stmt *S);
+  void VisitCallExpr(CallExpr *CE);
+};
+}
+
+void PointerSortingVisitor::VisitChildren(Stmt *S) {
+  for (Stmt *Child : S->children())
+if (Child)
+  Visit(Child);
+}
+
+void PointerSortingVisitor::reportPointerSortingDiagnostic(CallExpr *CE) {
+  SmallString<64> buf;
+  llvm::raw_svector_ostream os(buf);
+  os << "Non-deterministic sorting of pointer-like keys";
+  const char *BugType = "Pointer Sorting";
+
+  SmallVector ranges;
+  ranges.push_back(CE->getSourceRange());
+
+  PathDiagnosticLocation CELoc =
+PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), AC);
+  BR.EmitBasicReport(AC->getDecl(), Checker, BugType,
+ "Non-determinism", os.str(), CELoc, ranges);
+}
+
+// VisitCallExpr - This looks for calls to std::sort for containers with
+// pointer-like keys.
+void PointerSortingVisitor::VisitCallExpr(CallExpr *CE) {
+  // FIXME: Currently we only report std::sort which uses the default comparator
+  // to sort a container with pointer-like keys.
+  if (CE->getNumArgs() != 2)
+return;
+
+  const FunctionDecl *FD = CE->getDirectCallee();
+  if (!FD)
+return;
+
+  if (!AnalysisDeclContext::isInStdNamespace(FD))
+return;
+
+  IdentifierInfo *II = FD->getIdentifier();
+  if (!II)
+return;
+
+  if (!II->getName().equals("sort"))
+return;
+
+  const QualType IterTy = CE->getArg(0)->getType();
+  const RecordDecl *RD =
+IterTy->getUnqualifiedDesugaredType()->getAsCXXRecordDecl();
+
+  if (RD->field_empty())
+return;
+
+  const FieldDecl *I = *RD->field_begin();
+  if (!I->getType()->getPointeeType()->isPointerType())
+return;
+
+  reportPointerSortingDiagnostic(CE);
+}
+
+//===--===//
+// PointerSortingChecker
+//===--===//
+
+namespace {
+class PointerSortingChecker : public Checker {
+public:
+  void checkASTCodeBody(const Decl *D,
+AnalysisManager& mgr,
+BugReporter ) const 

r339307 - [CMake] Use normalized Windows target triples

2018-08-08 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Aug  8 19:16:18 2018
New Revision: 339307

URL: http://llvm.org/viewvc/llvm-project?rev=339307=rev
Log:
[CMake] Use normalized Windows target triples

Changes the default Windows target triple returned by
GetHostTriple.cmake from the old environment names (which we wanted to
move away from) to newer, normalized ones. This also requires updating
all tests to use the new systems names in constraints.

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

Modified:
cfe/trunk/test/CodeGen/2007-06-18-SextAttrAggregate.c
cfe/trunk/test/CodeGenCXX/vtable-debug-info.cpp
cfe/trunk/test/Driver/coverage_no_integrated_as.c
cfe/trunk/test/Driver/crash-report-null.test
cfe/trunk/test/Driver/inhibit-downstream-commands.c
cfe/trunk/test/Driver/linker-opts.c
cfe/trunk/test/Driver/no-integrated-as.s
cfe/trunk/test/Lexer/cross-windows-on-linux.cpp
cfe/trunk/test/Modules/crash-vfs-path-emptydir-entries.m
cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m
cfe/trunk/test/Modules/crash-vfs-path-symlink-topheader.m
cfe/trunk/test/Modules/crash-vfs-path-traversal.m
cfe/trunk/test/Modules/crash-vfs-relative-overlay.m
cfe/trunk/test/Modules/crash-vfs-umbrella-frameworks.m
cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp
cfe/trunk/test/VFS/umbrella-framework-import-skipnonexist.m
cfe/trunk/test/lit.cfg.py

Modified: cfe/trunk/test/CodeGen/2007-06-18-SextAttrAggregate.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/2007-06-18-SextAttrAggregate.c?rev=339307=339306=339307=diff
==
--- cfe/trunk/test/CodeGen/2007-06-18-SextAttrAggregate.c (original)
+++ cfe/trunk/test/CodeGen/2007-06-18-SextAttrAggregate.c Wed Aug  8 19:16:18 
2018
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -o - -emit-llvm | FileCheck %s
-// XFAIL: aarch64, arm64, x86_64-pc-win32, x86_64-w64-mingw32, 
x86_64-pc-windows-gnu
+// XFAIL: aarch64, arm64, x86_64-pc-windows-msvc, x86_64-w64-windows-gnu, 
x86_64-pc-windows-gnu
 
 // PR1513
 

Modified: cfe/trunk/test/CodeGenCXX/vtable-debug-info.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtable-debug-info.cpp?rev=339307=339306=339307=diff
==
--- cfe/trunk/test/CodeGenCXX/vtable-debug-info.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/vtable-debug-info.cpp Wed Aug  8 19:16:18 2018
@@ -1,6 +1,6 @@
 // RUN: %clang -emit-llvm -S -g %s -o /dev/null
 // Radar 8730409
-// XFAIL: win32
+// XFAIL: windows-msvc
 
 // FIXME: This test crashes on *-pc-win32
 // for lack of debugging support on -integrated-as (MCCOFF).

Modified: cfe/trunk/test/Driver/coverage_no_integrated_as.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/coverage_no_integrated_as.c?rev=339307=339306=339307=diff
==
--- cfe/trunk/test/Driver/coverage_no_integrated_as.c (original)
+++ cfe/trunk/test/Driver/coverage_no_integrated_as.c Wed Aug  8 19:16:18 2018
@@ -1,5 +1,5 @@
 // REQUIRES: clang-driver
-// XFAIL: win32,win64
+// XFAIL: windows-msvc
 
 // RUN: %clang -### -S -fprofile-arcs %s 2>&1 | FileCheck 
-check-prefix=CHECK-GCNO-DEFAULT-LOCATION %s
 // RUN: %clang -### -S -fprofile-arcs -no-integrated-as %s 2>&1 | FileCheck 
-check-prefix=CHECK-GCNO-DEFAULT-LOCATION %s

Modified: cfe/trunk/test/Driver/crash-report-null.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-report-null.test?rev=339307=339306=339307=diff
==
--- cfe/trunk/test/Driver/crash-report-null.test (original)
+++ cfe/trunk/test/Driver/crash-report-null.test Wed Aug  8 19:16:18 2018
@@ -1,7 +1,7 @@
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH=1 %clang -fsyntax-only -x c 
/dev/null -lstdc++ 2>&1 | FileCheck %s
 
 // FIXME: Investigating. "fatal error: file 'nul' modified since it was first 
processed"
-// XFAIL: mingw32
+// XFAIL: windows-gnu
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
 // CHECK-NEXT: note: diagnostic msg: {{.*}}null-{{.*}}.c

Modified: cfe/trunk/test/Driver/inhibit-downstream-commands.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/inhibit-downstream-commands.c?rev=339307=339306=339307=diff
==
--- cfe/trunk/test/Driver/inhibit-downstream-commands.c (original)
+++ cfe/trunk/test/Driver/inhibit-downstream-commands.c Wed Aug  8 19:16:18 2018
@@ -2,5 +2,5 @@
 // CHECK: error: unknown type name 'invalid'
 // CHECK-NOT: clang: error: assembler command failed 
 // CHECK-NOT: clang: error: linker command failed
-// XFAIL: win32
+// XFAIL: windows-msvc
 invalid C code!

Modified: cfe/trunk/test/Driver/linker-opts.c
URL: 

[clang-tools-extra] r339307 - [CMake] Use normalized Windows target triples

2018-08-08 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Aug  8 19:16:18 2018
New Revision: 339307

URL: http://llvm.org/viewvc/llvm-project?rev=339307=rev
Log:
[CMake] Use normalized Windows target triples

Changes the default Windows target triple returned by
GetHostTriple.cmake from the old environment names (which we wanted to
move away from) to newer, normalized ones. This also requires updating
all tests to use the new systems names in constraints.

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

Modified:
clang-tools-extra/trunk/test/clangd/did-change-configuration-params.test
clang-tools-extra/trunk/test/clangd/test-uri-posix.test
clang-tools-extra/trunk/test/clangd/test-uri-windows.test

Modified: 
clang-tools-extra/trunk/test/clangd/did-change-configuration-params.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/did-change-configuration-params.test?rev=339307=339306=339307=diff
==
--- clang-tools-extra/trunk/test/clangd/did-change-configuration-params.test 
(original)
+++ clang-tools-extra/trunk/test/clangd/did-change-configuration-params.test 
Wed Aug  8 19:16:18 2018
@@ -1,6 +1,6 @@
 # RUN: clangd -compile_args_from=lsp -lit-test < %s 2> %t | FileCheck 
-strict-whitespace %s
 # RUN: cat %t | FileCheck --check-prefix=ERR %s
-# UNSUPPORTED: mingw32,win32
+# UNSUPPORTED: windows-gnu,windows-msvc
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
 
{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"/clangd-test/foo.c":
 {"workingDirectory":"/clangd-test", "compilationCommand": ["clang", "-c", 
"foo.c"]}

Modified: clang-tools-extra/trunk/test/clangd/test-uri-posix.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/test-uri-posix.test?rev=339307=339306=339307=diff
==
--- clang-tools-extra/trunk/test/clangd/test-uri-posix.test (original)
+++ clang-tools-extra/trunk/test/clangd/test-uri-posix.test Wed Aug  8 19:16:18 
2018
@@ -1,5 +1,5 @@
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
-# UNSUPPORTED: mingw32,win32
+# UNSUPPORTED: windows-gnu,windows-msvc
 # Test authority-less URI
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---

Modified: clang-tools-extra/trunk/test/clangd/test-uri-windows.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/test-uri-windows.test?rev=339307=339306=339307=diff
==
--- clang-tools-extra/trunk/test/clangd/test-uri-windows.test (original)
+++ clang-tools-extra/trunk/test/clangd/test-uri-windows.test Wed Aug  8 
19:16:18 2018
@@ -1,5 +1,5 @@
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
-# REQUIRES: mingw32 || win32
+# REQUIRES: windows-gnu || windows-msvc
 # Test authority-less URI
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---


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


[PATCH] D50487: [CFG] [analyzer] Find argument constructors in CXXTemporaryObjectExprs.

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

`CXXTemporaryObjectExpr` is a sub-class of `CXXConstructExpr` that represents a 
construct-expression written as `T(Arg1, ..., ArgN)`, where `N` is not equal to 
1. If `N` is equal to 1, such expression is parsed as a construction conversion 
from type of `Arg1` to type `T` instead. Not every temporary object is 
represented by `CXXTemporaryObjectExpr` (for instance, implicit temporary 
copies aren't), and `CXXTemporaryObjectExpr` doesn't necessarily represent a 
temporary object (constructor written as a `CXXTemporaryObjectExpr` may 
construct a pretty much arbitrary object if copy elision kicks in).

If any of `Arg1`, ..., `ArgN` requires construction, give it a construction 
context of an argument. For now it only works for `CXXConstructExpr`s that 
aren't `CXXTemporaryObjectExpr`s. I forgot to add it when i was adding stubs 
for `CXXConstructExpr` argument constructors in 
https://reviews.llvm.org/D48249. I thought i had a test for it 
(`passArgumentIntoAnotherConstructor()`), but in fact in this test `N` was 
equal to 1, so it wasn't really testing a `CXXTemporaryObjectExpr`.


Repository:
  rC Clang

https://reviews.llvm.org/D50487

Files:
  lib/Analysis/CFG.cpp
  test/Analysis/cfg-rich-constructors.cpp


Index: test/Analysis/cfg-rich-constructors.cpp
===
--- test/Analysis/cfg-rich-constructors.cpp
+++ test/Analysis/cfg-rich-constructors.cpp
@@ -820,6 +820,7 @@
 class E {
 public:
   E(D d);
+  E(D d1, D d2);
 };
 
 void useC(C c);
@@ -939,6 +940,38 @@
 void passArgumentIntoAnotherConstructor() {
   E e = E(D());
 }
+
+
+// CHECK: void passTwoArgumentsIntoAnotherConstructor()
+// CXX11-ELIDE:  1: argument_constructors::D() (CXXConstructExpr, 
[B1.2], [B1.4], [B1.5], class argument_constructors::D)
+// CXX11-NOELIDE:  1: argument_constructors::D() (CXXConstructExpr, 
[B1.2], [B1.4], class argument_constructors::D)
+// CXX11-NEXT: 2: [B1.1] (BindTemporary)
+// CXX11-NEXT: 3: [B1.2] (ImplicitCastExpr, NoOp, const class 
argument_constructors::D)
+// CXX11-NEXT: 4: [B1.3]
+// CXX11-NEXT: 5: [B1.4] (CXXConstructExpr, [B1.6], [B1.13]+0, class 
argument_constructors::D)
+// CXX11-NEXT: 6: [B1.5] (BindTemporary)
+// CXX11-ELIDE-NEXT: 7: argument_constructors::D() (CXXConstructExpr, 
[B1.8], [B1.10], [B1.11], class argument_constructors::D)
+// CXX11-NOELIDE-NEXT: 7: argument_constructors::D() (CXXConstructExpr, 
[B1.8], [B1.10], class argument_constructors::D)
+// CXX11-NEXT: 8: [B1.7] (BindTemporary)
+// CXX11-NEXT: 9: [B1.8] (ImplicitCastExpr, NoOp, const class 
argument_constructors::D)
+// CXX11-NEXT:10: [B1.9]
+// CXX11-NEXT:11: [B1.10] (CXXConstructExpr, [B1.12], [B1.13]+1, class 
argument_constructors::D)
+// CXX11-NEXT:12: [B1.11] (BindTemporary)
+// CXX11-NEXT:13: argument_constructors::E([B1.6], [B1.12]) 
(CXXConstructExpr, class argument_constructors::E)
+// CXX11-NEXT:14: ~argument_constructors::D() (Temporary object destructor)
+// CXX11-NEXT:15: ~argument_constructors::D() (Temporary object destructor)
+// CXX11-NEXT:16: ~argument_constructors::D() (Temporary object destructor)
+// CXX11-NEXT:17: ~argument_constructors::D() (Temporary object destructor)
+// CXX17:  1: argument_constructors::D() (CXXConstructExpr, [B1.2], 
[B1.5]+0, class argument_constructors::D)
+// CXX17-NEXT: 2: [B1.1] (BindTemporary)
+// CXX17-NEXT: 3: argument_constructors::D() (CXXConstructExpr, [B1.4], 
[B1.5]+1, class argument_constructors::D)
+// CXX17-NEXT: 4: [B1.3] (BindTemporary)
+// CXX17-NEXT: 5: argument_constructors::E([B1.2], [B1.4]) 
(CXXConstructExpr, class argument_constructors::E)
+// CXX17-NEXT: 6: ~argument_constructors::D() (Temporary object destructor)
+// CXX17-NEXT: 7: ~argument_constructors::D() (Temporary object destructor)
+void passTwoArgumentsIntoAnotherConstructor() {
+  E(D(), D());
+}
 } // end namespace argument_constructors
 
 namespace copy_elision_with_extra_arguments {
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -4352,6 +4352,11 @@
 
 CFGBlock *CFGBuilder::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *C,
   AddStmtChoice asc) {
+  // If the constructor takes objects as arguments by value, we need to 
properly
+  // construct these objects. Construction contexts we find here aren't for the
+  // constructor C, they're for its arguments only.
+  findConstructionContextsForArguments(C);
+
   autoCreateBlock();
   appendConstructor(Block, C);
   return VisitChildren(C);


Index: test/Analysis/cfg-rich-constructors.cpp

r339306 - Refactor attribute printing to be a bit more obviously-correct.

2018-08-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Aug  8 18:21:06 2018
New Revision: 339306

URL: http://llvm.org/viewvc/llvm-project?rev=339306=rev
Log:
Refactor attribute printing to be a bit more obviously-correct.

No functionality change intended.

Added:
cfe/trunk/test/Misc/ast-print-attr.c
Modified:
cfe/trunk/lib/AST/TypePrinter.cpp

Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=339306=339305=339306=diff
==
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Wed Aug  8 18:21:06 2018
@@ -1398,25 +1398,21 @@ void TypePrinter::printAttributedAfter(c
   T->getAttrKind() == AttributedType::attr_objc_ownership)
 return printAfter(T->getEquivalentType(), OS);
 
-  if (T->getAttrKind() == AttributedType::attr_objc_kindof)
-return;
-
-  // TODO: not all attributes are GCC-style attributes.
-  if (T->isMSTypeSpec())
-return;
-
-  // Nothing to print after.
-  if (T->getAttrKind() == AttributedType::attr_nonnull ||
-  T->getAttrKind() == AttributedType::attr_nullable ||
-  T->getAttrKind() == AttributedType::attr_null_unspecified)
-return printAfter(T->getModifiedType(), OS);
-
   // If this is a calling convention attribute, don't print the implicit CC 
from
   // the modified type.
   SaveAndRestore MaybeSuppressCC(InsideCCAttribute, T->isCallingConv());
 
   printAfter(T->getModifiedType(), OS);
 
+  // Some attributes are printed as qualifiers before the type, so we have
+  // nothing left to do.
+  if (T->getAttrKind() == AttributedType::attr_objc_kindof ||
+  T->isMSTypeSpec() ||
+  T->getAttrKind() == AttributedType::attr_nonnull ||
+  T->getAttrKind() == AttributedType::attr_nullable ||
+  T->getAttrKind() == AttributedType::attr_null_unspecified)
+return;
+
   // Don't print the inert __unsafe_unretained attribute at all.
   if (T->getAttrKind() == AttributedType::attr_objc_inert_unsafe_unretained)
 return;

Added: cfe/trunk/test/Misc/ast-print-attr.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-attr.c?rev=339306=auto
==
--- cfe/trunk/test/Misc/ast-print-attr.c (added)
+++ cfe/trunk/test/Misc/ast-print-attr.c Wed Aug  8 18:21:06 2018
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -ast-print -x objective-c++ -fms-extensions %s -o - | 
FileCheck %s
+
+// CHECK: using A = __kindof id (*)[1];
+using A = __kindof id (*)[1];
+
+// CHECK: using B = int ** __ptr32 *[3];
+using B = int ** __ptr32 *[3];
+
+// FIXME: This is the wrong spelling for the attribute.
+// FIXME: Too many parens here!
+// CHECK: using C = int ((*))() __attribute__((cdecl));
+using C = int (*)() [[gnu::cdecl]];


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


[PATCH] D50482: Added another optimization pass to make vectorizing possible

2018-08-08 Thread Emmett Neyman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339305: Added another optimization pass to make vectorizing 
possible (authored by emmettneyman, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50482?vs=159838=159839#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50482

Files:
  cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp


Index: cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
===
--- cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -100,17 +100,29 @@
   if (!M || verifyModule(*M, ()))
 ErrorAndExit("Could not parse IR");
 
+  Triple ModuleTriple(M->getTargetTriple());
+  const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+  std::string E;
+  const Target *TheTarget = TargetRegistry::lookupTarget(MArch, ModuleTriple, 
E);
+  TargetMachine *Machine =
+  TheTarget->createTargetMachine(M->getTargetTriple(), getCPUStr(),
+ getFeaturesStr(), Options, 
getRelocModel(),
+ getCodeModel(), OLvl);
+  std::unique_ptr TM(Machine);
   setFunctionAttributes(getCPUStr(), getFeaturesStr(), *M);
-  
+
   legacy::PassManager Passes;
-  Triple ModuleTriple(M->getTargetTriple());
   
   Passes.add(new TargetLibraryInfoWrapperPass(ModuleTriple));
-  Passes.add(createTargetTransformInfoWrapperPass(TargetIRAnalysis()));
+  Passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
+
+  LLVMTargetMachine  = static_cast(*TM);
+  Passes.add(LTM.createPassConfig(Passes));
+
   Passes.add(createVerifierPass());
 
   AddOptimizationPasses(Passes, OLvl, 0);
-  
+
   // Add a pass that writes the optimized IR to an output stream
   std::string outString;
   raw_string_ostream OS(outString);


Index: cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
===
--- cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -100,17 +100,29 @@
   if (!M || verifyModule(*M, ()))
 ErrorAndExit("Could not parse IR");
 
+  Triple ModuleTriple(M->getTargetTriple());
+  const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+  std::string E;
+  const Target *TheTarget = TargetRegistry::lookupTarget(MArch, ModuleTriple, E);
+  TargetMachine *Machine =
+  TheTarget->createTargetMachine(M->getTargetTriple(), getCPUStr(),
+ getFeaturesStr(), Options, getRelocModel(),
+ getCodeModel(), OLvl);
+  std::unique_ptr TM(Machine);
   setFunctionAttributes(getCPUStr(), getFeaturesStr(), *M);
-  
+
   legacy::PassManager Passes;
-  Triple ModuleTriple(M->getTargetTriple());
   
   Passes.add(new TargetLibraryInfoWrapperPass(ModuleTriple));
-  Passes.add(createTargetTransformInfoWrapperPass(TargetIRAnalysis()));
+  Passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
+
+  LLVMTargetMachine  = static_cast(*TM);
+  Passes.add(LTM.createPassConfig(Passes));
+
   Passes.add(createVerifierPass());
 
   AddOptimizationPasses(Passes, OLvl, 0);
-  
+
   // Add a pass that writes the optimized IR to an output stream
   std::string outString;
   raw_string_ostream OS(outString);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r339305 - Added another optimization pass to make vectorizing possible

2018-08-08 Thread Emmett Neyman via cfe-commits
Author: emmettneyman
Date: Wed Aug  8 17:58:23 2018
New Revision: 339305

URL: http://llvm.org/viewvc/llvm-project?rev=339305=rev
Log:
Added another optimization pass to make vectorizing possible

Summary: I noticed that my code wasn't going deep into the loop vectorizer code 
so added another pass that makes it go further.

Reviewers: morehouse, kcc

Reviewed By: morehouse

Subscribers: cfe-commits, llvm-commits

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

Modified:
cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp

Modified: cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp?rev=339305=339304=339305=diff
==
--- cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp (original)
+++ cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp Wed Aug  8 
17:58:23 2018
@@ -100,17 +100,29 @@ static std::string OptLLVM(const std::st
   if (!M || verifyModule(*M, ()))
 ErrorAndExit("Could not parse IR");
 
+  Triple ModuleTriple(M->getTargetTriple());
+  const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+  std::string E;
+  const Target *TheTarget = TargetRegistry::lookupTarget(MArch, ModuleTriple, 
E);
+  TargetMachine *Machine =
+  TheTarget->createTargetMachine(M->getTargetTriple(), getCPUStr(),
+ getFeaturesStr(), Options, 
getRelocModel(),
+ getCodeModel(), OLvl);
+  std::unique_ptr TM(Machine);
   setFunctionAttributes(getCPUStr(), getFeaturesStr(), *M);
-  
+
   legacy::PassManager Passes;
-  Triple ModuleTriple(M->getTargetTriple());
   
   Passes.add(new TargetLibraryInfoWrapperPass(ModuleTriple));
-  Passes.add(createTargetTransformInfoWrapperPass(TargetIRAnalysis()));
+  Passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
+
+  LLVMTargetMachine  = static_cast(*TM);
+  Passes.add(LTM.createPassConfig(Passes));
+
   Passes.add(createVerifierPass());
 
   AddOptimizationPasses(Passes, OLvl, 0);
-  
+
   // Add a pass that writes the optimized IR to an output stream
   std::string outString;
   raw_string_ostream OS(outString);


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


[PATCH] D50482: Added another optimization pass to make vectorizing possible

2018-08-08 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 159838.
emmettneyman added a comment.

  Rebase


Repository:
  rC Clang

https://reviews.llvm.org/D50482

Files:
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp


Index: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
===
--- clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -100,17 +100,29 @@
   if (!M || verifyModule(*M, ()))
 ErrorAndExit("Could not parse IR");
 
+  Triple ModuleTriple(M->getTargetTriple());
+  const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+  std::string E;
+  const Target *TheTarget = TargetRegistry::lookupTarget(MArch, ModuleTriple, 
E);
+  TargetMachine *Machine =
+  TheTarget->createTargetMachine(M->getTargetTriple(), getCPUStr(),
+ getFeaturesStr(), Options, 
getRelocModel(),
+ getCodeModel(), OLvl);
+  std::unique_ptr TM(Machine);
   setFunctionAttributes(getCPUStr(), getFeaturesStr(), *M);
-  
+
   legacy::PassManager Passes;
-  Triple ModuleTriple(M->getTargetTriple());
   
   Passes.add(new TargetLibraryInfoWrapperPass(ModuleTriple));
-  Passes.add(createTargetTransformInfoWrapperPass(TargetIRAnalysis()));
+  Passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
+
+  LLVMTargetMachine  = static_cast(*TM);
+  Passes.add(LTM.createPassConfig(Passes));
+
   Passes.add(createVerifierPass());
 
   AddOptimizationPasses(Passes, OLvl, 0);
-  
+
   // Add a pass that writes the optimized IR to an output stream
   std::string outString;
   raw_string_ostream OS(outString);


Index: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
===
--- clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -100,17 +100,29 @@
   if (!M || verifyModule(*M, ()))
 ErrorAndExit("Could not parse IR");
 
+  Triple ModuleTriple(M->getTargetTriple());
+  const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+  std::string E;
+  const Target *TheTarget = TargetRegistry::lookupTarget(MArch, ModuleTriple, E);
+  TargetMachine *Machine =
+  TheTarget->createTargetMachine(M->getTargetTriple(), getCPUStr(),
+ getFeaturesStr(), Options, getRelocModel(),
+ getCodeModel(), OLvl);
+  std::unique_ptr TM(Machine);
   setFunctionAttributes(getCPUStr(), getFeaturesStr(), *M);
-  
+
   legacy::PassManager Passes;
-  Triple ModuleTriple(M->getTargetTriple());
   
   Passes.add(new TargetLibraryInfoWrapperPass(ModuleTriple));
-  Passes.add(createTargetTransformInfoWrapperPass(TargetIRAnalysis()));
+  Passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
+
+  LLVMTargetMachine  = static_cast(*TM);
+  Passes.add(LTM.createPassConfig(Passes));
+
   Passes.add(createVerifierPass());
 
   AddOptimizationPasses(Passes, OLvl, 0);
-  
+
   // Add a pass that writes the optimized IR to an output stream
   std::string outString;
   raw_string_ostream OS(outString);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r339304 - Delete some unreachable AST printing code.

2018-08-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Aug  8 17:44:49 2018
New Revision: 339304

URL: http://llvm.org/viewvc/llvm-project?rev=339304=rev
Log:
Delete some unreachable AST printing code.

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

Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=339304=339303=339304=diff
==
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Wed Aug  8 17:44:49 2018
@@ -1427,22 +1427,6 @@ void TypePrinter::printAttributedAfter(c
  ->getExtInfo().getProducesResult())
 return;
 
-  // Print nullability type specifiers that occur after
-  if (T->getAttrKind() == AttributedType::attr_nonnull ||
-  T->getAttrKind() == AttributedType::attr_nullable ||
-  T->getAttrKind() == AttributedType::attr_null_unspecified) {
-if (T->getAttrKind() == AttributedType::attr_nonnull)
-  OS << " _Nonnull";
-else if (T->getAttrKind() == AttributedType::attr_nullable)
-  OS << " _Nullable";
-else if (T->getAttrKind() == AttributedType::attr_null_unspecified)
-  OS << " _Null_unspecified";
-else
-  llvm_unreachable("unhandled nullability");
-
-return;
-  }
-
   if (T->getAttrKind() == AttributedType::attr_lifetimebound) {
 OS << " [[clang::lifetimebound]]";
 return;


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


[PATCH] D50482: Added another optimization pass to make vectorizing possible

2018-08-08 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman added inline comments.



Comment at: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp:103
 
+  Triple ModuleTriple(M->getTargetTriple());
+  const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();

morehouse wrote:
> I think you can avoid creating a Triple and instead just call 
> `M->getTargetTriple()` in `lookupTarget` below.
`M->getTargetTriple()` returns a `std::string` and both `lookupTarget()` and 
`TargetLibraryInfoWrapperPass()` take a `Triple` object.


Repository:
  rC Clang

https://reviews.llvm.org/D50482



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


[PATCH] D50482: Added another optimization pass to make vectorizing possible

2018-08-08 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp:103
 
+  Triple ModuleTriple(M->getTargetTriple());
+  const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();

I think you can avoid creating a Triple and instead just call 
`M->getTargetTriple()` in `lookupTarget` below.


Repository:
  rC Clang

https://reviews.llvm.org/D50482



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


[PATCH] D50482: Added another optimization pass to make vectorizing possible

2018-08-08 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 159834.
emmettneyman added a comment.

- Inlined function


Repository:
  rC Clang

https://reviews.llvm.org/D50482

Files:
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp


Index: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
===
--- clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -100,17 +100,29 @@
   if (!M || verifyModule(*M, ()))
 ErrorAndExit("Could not parse IR");
 
+  Triple ModuleTriple(M->getTargetTriple());
+  const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+  std::string E;
+  const Target *TheTarget = TargetRegistry::lookupTarget(MArch, ModuleTriple, 
E);
+  TargetMachine *Machine =
+  TheTarget->createTargetMachine(M->getTargetTriple(), getCPUStr(),
+ getFeaturesStr(), Options, 
getRelocModel(),
+ getCodeModel(), OLvl);
+  std::unique_ptr TM(Machine);
   setFunctionAttributes(getCPUStr(), getFeaturesStr(), *M);
-  
+
   legacy::PassManager Passes;
-  Triple ModuleTriple(M->getTargetTriple());
   
   Passes.add(new TargetLibraryInfoWrapperPass(ModuleTriple));
-  Passes.add(createTargetTransformInfoWrapperPass(TargetIRAnalysis()));
+  Passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
+
+  LLVMTargetMachine  = static_cast(*TM);
+  Passes.add(LTM.createPassConfig(Passes));
+
   Passes.add(createVerifierPass());
 
   AddOptimizationPasses(Passes, OLvl, 0);
-  
+
   // Add a pass that writes the optimized IR to an output stream
   std::string outString;
   raw_string_ostream OS(outString);


Index: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
===
--- clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -100,17 +100,29 @@
   if (!M || verifyModule(*M, ()))
 ErrorAndExit("Could not parse IR");
 
+  Triple ModuleTriple(M->getTargetTriple());
+  const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+  std::string E;
+  const Target *TheTarget = TargetRegistry::lookupTarget(MArch, ModuleTriple, E);
+  TargetMachine *Machine =
+  TheTarget->createTargetMachine(M->getTargetTriple(), getCPUStr(),
+ getFeaturesStr(), Options, getRelocModel(),
+ getCodeModel(), OLvl);
+  std::unique_ptr TM(Machine);
   setFunctionAttributes(getCPUStr(), getFeaturesStr(), *M);
-  
+
   legacy::PassManager Passes;
-  Triple ModuleTriple(M->getTargetTriple());
   
   Passes.add(new TargetLibraryInfoWrapperPass(ModuleTriple));
-  Passes.add(createTargetTransformInfoWrapperPass(TargetIRAnalysis()));
+  Passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
+
+  LLVMTargetMachine  = static_cast(*TM);
+  Passes.add(LTM.createPassConfig(Passes));
+
   Passes.add(createVerifierPass());
 
   AddOptimizationPasses(Passes, OLvl, 0);
-  
+
   // Add a pass that writes the optimized IR to an output stream
   std::string outString;
   raw_string_ostream OS(outString);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50482: Added another optimization pass to make vectorizing possible

2018-08-08 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman added inline comments.



Comment at: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp:126
+
+  auto  = static_cast(*TM);
+  Passes.add(LTM.createPassConfig(Passes));

morehouse wrote:
> Is TM guaranteed to be an LLVMTargetMachine?
Yes, since the target triple will always be X86.


Repository:
  rC Clang

https://reviews.llvm.org/D50482



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


[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

2018-08-08 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 159832.
Rakete added a comment.

Rebase + friendly ping :)


Repository:
  rC Clang

https://reviews.llvm.org/D36357

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  lib/Parse/ParseExprCXX.cpp
  test/FixIt/fixit-cxx0x.cpp
  test/Parser/cxx0x-lambda-expressions.cpp
  test/SemaCXX/new-delete-0x.cpp

Index: test/SemaCXX/new-delete-0x.cpp
===
--- test/SemaCXX/new-delete-0x.cpp
+++ test/SemaCXX/new-delete-0x.cpp
@@ -34,6 +34,6 @@
 void bad_deletes()
 {
   // 'delete []' is always array delete, per [expr.delete]p1.
-  // FIXME: Give a better diagnostic.
-  delete []{ return (int*)0; }(); // expected-error {{expected expression}}
+  delete []{ return (int*)0; }(); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
 }
+
Index: test/Parser/cxx0x-lambda-expressions.cpp
===
--- test/Parser/cxx0x-lambda-expressions.cpp
+++ test/Parser/cxx0x-lambda-expressions.cpp
@@ -53,8 +53,11 @@
   void delete_lambda(int *p) {
 delete [] p;
 delete [] (int*) { new int }; // ok, compound-literal, not lambda
-delete [] { return new int; } (); // expected-error{{expected expression}}
+delete [] { return new int; } (); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
 delete [&] { return new int; } (); // ok, lambda
+
+delete []() { return new int; }(); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
+delete [](E Enum) { return new int((int)Enum); }(e); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
   }
 
   // We support init-captures in C++11 as an extension.
Index: test/FixIt/fixit-cxx0x.cpp
===
--- test/FixIt/fixit-cxx0x.cpp
+++ test/FixIt/fixit-cxx0x.cpp
@@ -58,6 +58,9 @@
   (void)[&, i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
   (void)[] mutable { }; // expected-error{{lambda requires '()' before 'mutable'}}
   (void)[] -> int { }; // expected-error{{lambda requires '()' before return type}}
+
+  delete []() { return new int; }(); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
+  delete [] { return new int; }(); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
 }
 
 #define bar "bar"
Index: lib/Parse/ParseExprCXX.cpp
===
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -2946,8 +2946,38 @@
 //   [Footnote: A lambda expression with a lambda-introducer that consists
 //  of empty square brackets can follow the delete keyword if
 //  the lambda expression is enclosed in parentheses.]
-// FIXME: Produce a better diagnostic if the '[]' is unambiguously a
-//lambda-introducer.
+
+const Token Next = GetLookAheadToken(2);
+
+// Basic lookahead to check if we have a lambda expression.
+if (Next.isOneOf(tok::l_brace, tok::less) ||
+(Next.is(tok::l_paren) &&
+ (GetLookAheadToken(3).is(tok::r_paren) ||
+  (GetLookAheadToken(3).is(tok::identifier) &&
+   GetLookAheadToken(4).is(tok::identifier) {
+  SourceLocation RightBracketLock = NextToken().getLocation();
+  // Warn if the non-capturing lambda isn't surrounded by parenthesis
+  // to disambiguate it from 'delete[]'.
+  ExprResult Lambda = ParseLambdaExpression();
+  if (Lambda.isInvalid())
+return ExprError();
+
+  SourceLocation StartLoc = Lambda.get()->getLocStart();
+  Diag(Start, diag::err_lambda_after_delete)
+  << SourceRange(Start, RightBracketLock)
+  << FixItHint::CreateInsertion(StartLoc, "(")
+  << FixItHint::CreateInsertion(
+ Lexer::getLocForEndOfToken(Lambda.get()->getLocEnd(), 0,
+Actions.getSourceManager(),
+getLangOpts()),
+ ")");
+
+  // Evaluate any postfix expressions used on the lambda.
+  Lambda = ParsePostfixExpressionSuffix(Lambda);
+  return Actions.ActOnCXXDelete(Start, UseGlobal, /*ArrayForm=*/false,
+Lambda.get());
+}
+
 ArrayDelete = true;
 BalancedDelimiterTracker T(*this, tok::l_square);
 
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -99,6 +99,8 @@
   InGroup, DefaultIgnore;
 def ext_alignof_expr : ExtWarn<
   "%0 applied to an expression is a GNU extension">, InGroup;
+def err_lambda_after_delete : Error<
+  "'[]' after delete interpreted as 'delete[]'">;
 
 def warn_microsoft_dependent_exists : Warning<
   "dependent %select{__if_not_exists|__if_exists}0 declarations are 

[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

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



Comment at: include/clang/AST/ASTContext.h:248
+  /// Mapping from __block VarDecls to their copy initialization expr. The
+  /// boolean flag indicates whether the expression can throw.
+  typedef llvm::DenseMap Maybe you should just make a type for this pairing.  You can put this 
> documentation there, and the access functions can take and return it.
I don't think the `typedef` is needed here.



Comment at: include/clang/AST/ASTContext.h:158
+Expr *CopyExpr;
+bool CanThrow;
+  };

Using a PointerIntPair in the implementation of this is still a reasonable 
choice.  Just make it a proper abstraction, with a constructor with the two 
arguments and getters for the two fields.



Comment at: include/clang/AST/ASTContext.h:2680
+  /// indicates whether the copy expression can throw or not.
+  void setBlockVarCopyInits(const VarDecl* VD, Expr *CopyExpr, bool CanThrow);
 

I know this is longstanding, but since you're changing all the call sites 
anyway, please remove the trailing `s` from these two method names.



Comment at: lib/AST/ASTContext.cpp:2511
  "getBlockVarCopyInits - not __block var");
-  llvm::DenseMap::iterator
-I = BlockVarCopyInits.find(VD);
-  return (I != BlockVarCopyInits.end()) ? I->second : nullptr;
+  BlockVarCopyInitMap::const_iterator I = BlockVarCopyInits.find(VD);
+  if (I != BlockVarCopyInits.end())

I think `auto` is okay for things like this.



Comment at: lib/CodeGen/CGBlocks.cpp:1682
+  if (IsCopyHelper && Ctx.getBlockVarCopyInits(Var).CanThrow)
+Name += "c";
+}

I don't think you need to add `d` to the name of a copy helper.  It's a bit 
weird, but while copying a `__block` variable can cause its copy helper to run, 
destroying it immediately afterwards can never cause its destroy helper to run. 
 That's because a newly-copied `__block` variable always has a reference count 
of 2: the new reference in the copy and the forwarding reference from the 
original.

I think that means you can just add a single letter which specifies whether the 
corresponding `__block` variable operation is known to be able to throw.



Comment at: lib/CodeGen/CGBlocks.cpp:1688
+if (F == BLOCK_FIELD_IS_BLOCK)
+  Name += "b";
+  }

Why `rb` for a captured block instead of some single-letter thing?  You don't 
need to emulate the structure of the flags here.



Comment at: lib/CodeGen/CGBlocks.cpp:1705
+  IsVolatile, Ctx);
+  Name += llvm::to_string(Str.size()) + "_" + Str;
+  break;

The underscore is necessary here because non-trivial destructor strings can 
start with a number?  Worth a comment.


Repository:
  rC Clang

https://reviews.llvm.org/D50152



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


[PATCH] D50482: Added another optimization pass to make vectorizing possible

2018-08-08 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp:90
+getCodeModel(), OLvl);
+}
+

If you have to pass that many parameters to a 3 line function, just inline 
instead.



Comment at: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp:126
+
+  auto  = static_cast(*TM);
+  Passes.add(LTM.createPassConfig(Passes));

Is TM guaranteed to be an LLVMTargetMachine?


Repository:
  rC Clang

https://reviews.llvm.org/D50482



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


[PATCH] D50482: Added another optimization pass to make vectorizing possible

2018-08-08 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 159831.
emmettneyman added a comment.

- minor style fix


Repository:
  rC Clang

https://reviews.llvm.org/D50482

Files:
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp


Index: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
===
--- clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -77,6 +77,18 @@
   std::exit(1);
 }
 
+// Helper function that returns a *TargetMachine, used by OptLLVM
+static TargetMachine* GetTargetMachine(Triple TheTriple, StringRef CPUStr,
+   StringRef FeaturesStr,
+   const TargetOptions ,
+   CodeGenOpt::Level OLvl) {
+  std::string E;
+  const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple, E);
+  return TheTarget->createTargetMachine(TheTriple.getTriple(), CPUStr,
+FeaturesStr, Options, getRelocModel(),
+getCodeModel(), OLvl);
+}
+
 // Helper function to add optimization passes to the TargetMachine at the 
 // specified optimization level, OptLevel
 static void AddOptimizationPasses(legacy::PassManagerBase ,
@@ -100,17 +112,24 @@
   if (!M || verifyModule(*M, ()))
 ErrorAndExit("Could not parse IR");
 
+  Triple ModuleTriple(M->getTargetTriple());
+  const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+  std::unique_ptr TM(GetTargetMachine(ModuleTriple, getCPUStr(),
+getFeaturesStr(), Options, OLvl));
   setFunctionAttributes(getCPUStr(), getFeaturesStr(), *M);
-  
+
   legacy::PassManager Passes;
-  Triple ModuleTriple(M->getTargetTriple());
   
   Passes.add(new TargetLibraryInfoWrapperPass(ModuleTriple));
-  Passes.add(createTargetTransformInfoWrapperPass(TargetIRAnalysis()));
+  Passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
+
+  LLVMTargetMachine  = static_cast(*TM);
+  Passes.add(LTM.createPassConfig(Passes));
+
   Passes.add(createVerifierPass());
 
   AddOptimizationPasses(Passes, OLvl, 0);
-  
+
   // Add a pass that writes the optimized IR to an output stream
   std::string outString;
   raw_string_ostream OS(outString);


Index: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
===
--- clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -77,6 +77,18 @@
   std::exit(1);
 }
 
+// Helper function that returns a *TargetMachine, used by OptLLVM
+static TargetMachine* GetTargetMachine(Triple TheTriple, StringRef CPUStr,
+   StringRef FeaturesStr,
+   const TargetOptions ,
+   CodeGenOpt::Level OLvl) {
+  std::string E;
+  const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple, E);
+  return TheTarget->createTargetMachine(TheTriple.getTriple(), CPUStr,
+FeaturesStr, Options, getRelocModel(),
+getCodeModel(), OLvl);
+}
+
 // Helper function to add optimization passes to the TargetMachine at the 
 // specified optimization level, OptLevel
 static void AddOptimizationPasses(legacy::PassManagerBase ,
@@ -100,17 +112,24 @@
   if (!M || verifyModule(*M, ()))
 ErrorAndExit("Could not parse IR");
 
+  Triple ModuleTriple(M->getTargetTriple());
+  const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+  std::unique_ptr TM(GetTargetMachine(ModuleTriple, getCPUStr(),
+getFeaturesStr(), Options, OLvl));
   setFunctionAttributes(getCPUStr(), getFeaturesStr(), *M);
-  
+
   legacy::PassManager Passes;
-  Triple ModuleTriple(M->getTargetTriple());
   
   Passes.add(new TargetLibraryInfoWrapperPass(ModuleTriple));
-  Passes.add(createTargetTransformInfoWrapperPass(TargetIRAnalysis()));
+  Passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
+
+  LLVMTargetMachine  = static_cast(*TM);
+  Passes.add(LTM.createPassConfig(Passes));
+
   Passes.add(createVerifierPass());
 
   AddOptimizationPasses(Passes, OLvl, 0);
-  
+
   // Add a pass that writes the optimized IR to an output stream
   std::string outString;
   raw_string_ostream OS(outString);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50482: Added another optimization pass to make vectorizing possible

2018-08-08 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman created this revision.
emmettneyman added reviewers: morehouse, kcc.
Herald added a subscriber: cfe-commits.

I noticed that my code wasn't going deep into the loop vectorizer code so added 
another pass that makes it go further.


Repository:
  rC Clang

https://reviews.llvm.org/D50482

Files:
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp


Index: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
===
--- clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -77,6 +77,18 @@
   std::exit(1);
 }
 
+// Helper function that returns a *TargetMachine, used by OptLLVM
+static TargetMachine* GetTargetMachine(Triple TheTriple, StringRef CPUStr,
+   StringRef FeaturesStr,
+   const TargetOptions ,
+   CodeGenOpt::Level OLvl) {
+  std::string E;
+  const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple, E);
+  return TheTarget->createTargetMachine(TheTriple.getTriple(), CPUStr,
+FeaturesStr, Options, getRelocModel(),
+getCodeModel(), OLvl);
+}
+
 // Helper function to add optimization passes to the TargetMachine at the 
 // specified optimization level, OptLevel
 static void AddOptimizationPasses(legacy::PassManagerBase ,
@@ -100,17 +112,24 @@
   if (!M || verifyModule(*M, ()))
 ErrorAndExit("Could not parse IR");
 
+  Triple ModuleTriple(M->getTargetTriple());
+  const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+  std::unique_ptr TM(GetTargetMachine(ModuleTriple, getCPUStr(),
+getFeaturesStr(), Options, OLvl));
   setFunctionAttributes(getCPUStr(), getFeaturesStr(), *M);
-  
+
   legacy::PassManager Passes;
-  Triple ModuleTriple(M->getTargetTriple());
   
   Passes.add(new TargetLibraryInfoWrapperPass(ModuleTriple));
-  Passes.add(createTargetTransformInfoWrapperPass(TargetIRAnalysis()));
+  Passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
+
+  auto  = static_cast(*TM);
+  Passes.add(LTM.createPassConfig(Passes));
+
   Passes.add(createVerifierPass());
 
   AddOptimizationPasses(Passes, OLvl, 0);
-  
+
   // Add a pass that writes the optimized IR to an output stream
   std::string outString;
   raw_string_ostream OS(outString);


Index: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
===
--- clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -77,6 +77,18 @@
   std::exit(1);
 }
 
+// Helper function that returns a *TargetMachine, used by OptLLVM
+static TargetMachine* GetTargetMachine(Triple TheTriple, StringRef CPUStr,
+   StringRef FeaturesStr,
+   const TargetOptions ,
+   CodeGenOpt::Level OLvl) {
+  std::string E;
+  const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple, E);
+  return TheTarget->createTargetMachine(TheTriple.getTriple(), CPUStr,
+FeaturesStr, Options, getRelocModel(),
+getCodeModel(), OLvl);
+}
+
 // Helper function to add optimization passes to the TargetMachine at the 
 // specified optimization level, OptLevel
 static void AddOptimizationPasses(legacy::PassManagerBase ,
@@ -100,17 +112,24 @@
   if (!M || verifyModule(*M, ()))
 ErrorAndExit("Could not parse IR");
 
+  Triple ModuleTriple(M->getTargetTriple());
+  const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+  std::unique_ptr TM(GetTargetMachine(ModuleTriple, getCPUStr(),
+getFeaturesStr(), Options, OLvl));
   setFunctionAttributes(getCPUStr(), getFeaturesStr(), *M);
-  
+
   legacy::PassManager Passes;
-  Triple ModuleTriple(M->getTargetTriple());
   
   Passes.add(new TargetLibraryInfoWrapperPass(ModuleTriple));
-  Passes.add(createTargetTransformInfoWrapperPass(TargetIRAnalysis()));
+  Passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
+
+  auto  = static_cast(*TM);
+  Passes.add(LTM.createPassConfig(Passes));
+
   Passes.add(createVerifierPass());
 
   AddOptimizationPasses(Passes, OLvl, 0);
-  
+
   // Add a pass that writes the optimized IR to an output stream
   std::string outString;
   raw_string_ostream OS(outString);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50462: Try building complete AST after a fatal error was emitted if further diagnostics are expected

2018-08-08 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

On a second look I think that there is value separating the concepts of 
'producing diagnostics' after hitting the fatal error (which is 
SuppressAfterFatalError currently does), and trying to build a more complete 
AST.
For example,

- An editor client might not want to show the diagnostics after the fatal error 
has been reached to match the diagnostics observed during build, but it would 
benefit from a more complete AST for other editing features.
- Index-while-building: the compiler shouldn't show the diagnostics after a 
fatal error has been reached, but the indexer would be able to produce better 
indexing data from a more complete AST.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50462



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


[PATCH] D50462: Try building complete AST after a fatal error was emitted if further diagnostics are expected

2018-08-08 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

This seems sensible to me.




Comment at: include/clang/Basic/Diagnostic.h:764
+  /// off extra processing that might be wasteful in this case.
+bool areDiagnosticsSuppressedAfterFatalError() const {
+return FatalErrorOccurred && SuppressAfterFatalError;

Looks like this line wasn't formatted with clang-format.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50462



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


[PATCH] D50467: [SEMA] add more -Wfloat-conversion to compound assigment analysis

2018-08-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 159820.
nickdesaulniers added a comment.

- clean up conditional and add comment


Repository:
  rC Clang

https://reviews.llvm.org/D50467

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

Index: test/SemaCXX/warn-float-conversion.cpp
===
--- test/SemaCXX/warn-float-conversion.cpp
+++ test/SemaCXX/warn-float-conversion.cpp
@@ -41,6 +41,22 @@
   l = ld;  //expected-warning{{conversion}}
 }
 
+void CompoundAssignment() {
+  int x = 3;
+
+  x += 1.234;  //expected-warning{{conversion}}
+  x -= -0.0;  //expected-warning{{conversion}}
+  x *= 1.1f;  //expected-warning{{conversion}}
+  x /= -2.2f;  //expected-warning{{conversion}}
+
+  int y = x += 1.4f;  //expected-warning{{conversion}}
+
+  float z = 1.1f;
+  double w = -2.2;
+
+  y += z + w;  //expected-warning{{conversion}}
+}
+
 void Test() {
   int a1 = 10.0/2.0;  //expected-warning{{conversion}}
   int a2 = 1.0/2.0;  //expected-warning{{conversion}}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -10292,33 +10292,6 @@
   DiagnoseImpCast(S, E, E->getType(), T, CContext, diag, pruneControlFlow);
 }
 
-/// Analyze the given compound assignment for the possible losing of
-/// floating-point precision.
-static void AnalyzeCompoundAssignment(Sema , BinaryOperator *E) {
-  assert(isa(E) &&
- "Must be compound assignment operation");
-  // Recurse on the LHS and RHS in here
-  AnalyzeImplicitConversions(S, E->getLHS(), E->getOperatorLoc());
-  AnalyzeImplicitConversions(S, E->getRHS(), E->getOperatorLoc());
-
-  // Now check the outermost expression
-  const auto *ResultBT = E->getLHS()->getType()->getAs();
-  const auto *RBT = cast(E)
-->getComputationResultType()
-->getAs();
-
-  // If both source and target are floating points.
-  if (ResultBT && ResultBT->isFloatingPoint() && RBT && RBT->isFloatingPoint())
-// Builtin FP kinds are ordered by increasing FP rank.
-if (ResultBT->getKind() < RBT->getKind())
-  // We don't want to warn for system macro.
-  if (!S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
-// warn about dropping FP rank.
-DiagnoseImpCast(S, E->getRHS(), E->getLHS()->getType(),
-E->getOperatorLoc(),
-diag::warn_impcast_float_result_precision);
-}
-
 /// Diagnose an implicit cast from a floating point value to an integer value.
 static void DiagnoseFloatingImpCast(Sema , Expr *E, QualType T,
 SourceLocation CContext) {
@@ -10421,6 +10394,39 @@
   }
 }
 
+/// Analyze the given compound assignment for the possible losing of
+/// floating-point precision.
+static void AnalyzeCompoundAssignment(Sema , BinaryOperator *E) {
+  assert(isa(E) &&
+ "Must be compound assignment operation");
+  // Recurse on the LHS and RHS in here
+  AnalyzeImplicitConversions(S, E->getLHS(), E->getOperatorLoc());
+  AnalyzeImplicitConversions(S, E->getRHS(), E->getOperatorLoc());
+
+  // Now check the outermost expression
+  const auto *ResultBT = E->getLHS()->getType()->getAs();
+  const auto *RBT = cast(E)
+->getComputationResultType()
+->getAs();
+
+  // The below checks assume source is floating point.
+  if (!ResultBT || !RBT || !RBT->isFloatingPoint()) return;
+
+  // If source is floating point but target is not.
+  if (!ResultBT->isFloatingPoint())
+return DiagnoseFloatingImpCast(S, E, E->getRHS()->getType(),
+   E->getExprLoc());
+
+  // If both source and target are floating points.
+  // Builtin FP kinds are ordered by increasing FP rank.
+  if (ResultBT->getKind() < RBT->getKind() &&
+  // We don't want to warn for system macro.
+  S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
+// warn about dropping FP rank.
+DiagnoseImpCast(S, E->getRHS(), E->getLHS()->getType(), E->getOperatorLoc(),
+diag::warn_impcast_float_result_precision);
+}
+
 static std::string PrettyPrintInRange(const llvm::APSInt ,
   IntRange Range) {
   if (!Range.Width) return "0";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50467: [SEMA] add more -Wfloat-conversion to compound assigment analysis

2018-08-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:10411
+->getAs();
+  if (!ResultBT || !(RBT && RBT->isFloatingPoint())) return;
+

nickdesaulniers wrote:
> pirama wrote:
> > Add a comment explaining this conditional as well?  
> > 
> > > Return if source and target types are unavailable or if source is not a 
> > > floating point.
> > 
> > With the comment, it might be cleaner to read if you expand the negation: 
> > `!ResultBT || !RBT || !RBT->isFloatingPoint()`
> `ResultBT` and `RBT` are pointers that may be null and need to be checked.  
> The previous code did this before accessing them, I've just moved the checks 
> to be sooner.
> 
> If `!RBT` (if it's `nullptr`), then `!RBT->isFloatingPoint()` would be a null 
> deref, so unfortunately I can not expand it as recommended.
oops, nevermind


Repository:
  rC Clang

https://reviews.llvm.org/D50467



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


[PATCH] D50467: [SEMA] add more -Wfloat-conversion to compound assigment analysis

2018-08-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:10411
+->getAs();
+  if (!ResultBT || !(RBT && RBT->isFloatingPoint())) return;
+

pirama wrote:
> Add a comment explaining this conditional as well?  
> 
> > Return if source and target types are unavailable or if source is not a 
> > floating point.
> 
> With the comment, it might be cleaner to read if you expand the negation: 
> `!ResultBT || !RBT || !RBT->isFloatingPoint()`
`ResultBT` and `RBT` are pointers that may be null and need to be checked.  The 
previous code did this before accessing them, I've just moved the checks to be 
sooner.

If `!RBT` (if it's `nullptr`), then `!RBT->isFloatingPoint()` would be a null 
deref, so unfortunately I can not expand it as recommended.


Repository:
  rC Clang

https://reviews.llvm.org/D50467



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


[PATCH] D50444: [ASTImporter] Fix structural inequivalency of forward EnumDecl

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

Yes, this seems to be correct. Thanks!




Comment at: lib/AST/ASTStructuralEquivalence.cpp:1182
+
+  // Compare the definitions of these two eunums. If either or both are
+  // incomplete (i.e. forward declared), we assume that they are equivalent.

enums


Repository:
  rC Clang

https://reviews.llvm.org/D50444



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


r339295 - [Builtins] Add __builtin_clrsb support to IntExprEvaluator::VisitBuiltinCallExpr

2018-08-08 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Aug  8 15:31:12 2018
New Revision: 339295

URL: http://llvm.org/viewvc/llvm-project?rev=339295=rev
Log:
[Builtins] Add __builtin_clrsb support to IntExprEvaluator::VisitBuiltinCallExpr

This addresses a FIXME that has existed since before clang supported the 
builtin.

This time with only reviewed changes.

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

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/Sema/constant-builtins-2.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=339295=339294=339295=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Aug  8 15:31:12 2018
@@ -8117,9 +8117,15 @@ bool IntExprEvaluator::VisitBuiltinCallE
   case Builtin::BI__builtin_classify_type:
 return Success((int)EvaluateBuiltinClassifyType(E, Info.getLangOpts()), E);
 
-  // FIXME: BI__builtin_clrsb
-  // FIXME: BI__builtin_clrsbl
-  // FIXME: BI__builtin_clrsbll
+  case Builtin::BI__builtin_clrsb:
+  case Builtin::BI__builtin_clrsbl:
+  case Builtin::BI__builtin_clrsbll: {
+APSInt Val;
+if (!EvaluateInteger(E->getArg(0), Val, Info))
+  return false;
+
+return Success(Val.getBitWidth() - Val.getMinSignedBits(), E);
+  }
 
   case Builtin::BI__builtin_clz:
   case Builtin::BI__builtin_clzl:

Modified: cfe/trunk/test/Sema/constant-builtins-2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/constant-builtins-2.c?rev=339295=339294=339295=diff
==
--- cfe/trunk/test/Sema/constant-builtins-2.c (original)
+++ cfe/trunk/test/Sema/constant-builtins-2.c Wed Aug  8 15:31:12 2018
@@ -176,6 +176,19 @@ char ffs4[__builtin_ffs(0xfbe70) == 5 ?
 char ffs5[__builtin_ffs(1U << (BITSIZE(int) - 1)) == BITSIZE(int) ? 1 : -1];
 char ffs6[__builtin_ffsl(0x10L) == 5 ? 1 : -1];
 char ffs7[__builtin_ffsll(0x100LL) == 9 ? 1 : -1];
+
+char clrsb1[__builtin_clrsb(0) == BITSIZE(int) - 1 ? 1 : -1];
+char clrsb2[__builtin_clrsbl(0L) == BITSIZE(long) - 1 ? 1 : -1];
+char clrsb3[__builtin_clrsbll(0LL) == BITSIZE(long long) - 1 ? 1 : -1];
+char clrsb4[__builtin_clrsb(~0) == BITSIZE(int) - 1 ? 1 : -1];
+char clrsb5[__builtin_clrsbl(~0L) == BITSIZE(long) - 1 ? 1 : -1];
+char clrsb6[__builtin_clrsbll(~0LL) == BITSIZE(long long) - 1 ? 1 : -1];
+char clrsb7[__builtin_clrsb(1) == BITSIZE(int) - 2 ? 1 : -1];
+char clrsb8[__builtin_clrsb(~1) == BITSIZE(int) - 2 ? 1 : -1];
+char clrsb9[__builtin_clrsb(1 << (BITSIZE(int) - 1)) == 0 ? 1 : -1];
+char clrsb10[__builtin_clrsb(~(1 << (BITSIZE(int) - 1))) == 0 ? 1 : -1];
+char clrsb11[__builtin_clrsb(0xf) == BITSIZE(int) - 5 ? 1 : -1];
+char clrsb12[__builtin_clrsb(~0x1f) == BITSIZE(int) - 6 ? 1 : -1];
 #undef BITSIZE
 
 // GCC misc stuff


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


r339296 - [VFS] Remove superfluous semicolon from unittest.

2018-08-08 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Aug  8 15:31:14 2018
New Revision: 339296

URL: http://llvm.org/viewvc/llvm-project?rev=339296=rev
Log:
[VFS] Remove superfluous semicolon from unittest.

Modified:
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=339296=339295=339296=diff
==
--- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original)
+++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Wed Aug  8 15:31:14 2018
@@ -158,7 +158,7 @@ std::string getPosixPath(std::string S)
   SmallString<128> Result;
   llvm::sys::path::native(S, Result, llvm::sys::path::Style::posix);
   return Result.str();
-};
+}
 } // end anonymous namespace
 
 TEST(VirtualFileSystemTest, StatusQueries) {


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


[PATCH] D50467: [SEMA] add more -Wfloat-conversion to compound assigment analysis

2018-08-08 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:10411
+->getAs();
+  if (!ResultBT || !(RBT && RBT->isFloatingPoint())) return;
+

Add a comment explaining this conditional as well?  

> Return if source and target types are unavailable or if source is not a 
> floating point.

With the comment, it might be cleaner to read if you expand the negation: 
`!ResultBT || !RBT || !RBT->isFloatingPoint()`


Repository:
  rC Clang

https://reviews.llvm.org/D50467



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


[PATCH] D45639: [Driver] Support default libc++ library location on Darwin

2018-08-08 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

I must say I therefore don't understand the purpose of this patch.


Repository:
  rC Clang

https://reviews.llvm.org/D45639



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


[PATCH] D45639: [Driver] Support default libc++ library location on Darwin

2018-08-08 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

@phosek I don't understand how you can expect code compiled with new headers to 
link against an old dylib, unless you're setting the target platform, in which 
case anything that would fail to link will instead be a compiler error. I mean, 
we're adding stuff to the dylib from one version to the next, so _of course_ it 
won't always work.

Regarding the specific error you're encountering (`Undefined symbols for 
architecture x86_64: "operator delete(void*, std::align_val_t)", referenced 
from: [...]`), we're aware of it and this will in fact be fixed by 
https://reviews.llvm.org/D50344.


Repository:
  rC Clang

https://reviews.llvm.org/D45639



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


[PATCH] D50428: [ASTImporter] Add support for importing imaginary literals

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

LGTM! Just a stylish nit.




Comment at: lib/AST/ASTImporter.cpp:5617
+
+  return new (Importer.getToContext())
+  ImaginaryLiteral(SubE, T);

The line split is not needed here.


Repository:
  rC Clang

https://reviews.llvm.org/D50428



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


[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

2018-08-08 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 159800.
ahatanak marked 2 inline comments as done.
ahatanak added a comment.

Modify getBlockVarCopyInits and setBlockVarCopyInits to get and set both the 
copy expression and the boolean flag that indicates whether the expression can 
throw or not.


Repository:
  rC Clang

https://reviews.llvm.org/D50152

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBlocks.h
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGNonTrivialStruct.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaDecl.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/blocks-1.c
  test/CodeGen/blocks.c
  test/CodeGen/sanitize-thread-no-checking-at-run-time.m
  test/CodeGenCXX/block-byref-cxx-objc.cpp
  test/CodeGenCXX/blocks.cpp
  test/CodeGenCXX/cxx-block-objects.cpp
  test/CodeGenObjC/arc-blocks.m
  test/CodeGenObjC/debug-info-block-helper.m
  test/CodeGenObjC/debug-info-blocks.m
  test/CodeGenObjC/mrc-weak.m
  test/CodeGenObjC/strong-in-c-struct.m
  test/CodeGenObjCXX/arc-blocks.mm
  test/CodeGenObjCXX/lambda-to-block.mm
  test/CodeGenObjCXX/mrc-weak.mm
  test/PCH/block-helpers.cpp
  test/PCH/block-helpers.h

Index: test/PCH/block-helpers.h
===
--- /dev/null
+++ test/PCH/block-helpers.h
@@ -0,0 +1,12 @@
+struct S0 {
+  S0();
+  S0(const S0 &) noexcept(false);
+  int a;
+};
+
+struct S {
+  void m() {
+__block S0 x, y;
+^{ (void)x; (void)y; };
+  }
+};
Index: test/PCH/block-helpers.cpp
===
--- /dev/null
+++ test/PCH/block-helpers.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -x c++-header -triple x86_64-apple-darwin11 -emit-pch -fblocks -fexceptions -o %t %S/block-helpers.h
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -include-pch %t -emit-llvm -fblocks -fexceptions -o - %s | FileCheck %s
+
+// The second call to block_object_assign should be an invoke.
+
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_e8_32bc40bc(
+// CHECK: call void @_Block_object_assign(
+// CHECK: invoke void @_Block_object_assign(
+// CHECK: call void @_Block_object_dispose(
+
+// CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block_e8_32b40b(
+void test() {
+  S s;
+  s.m();
+}
Index: test/CodeGenObjCXX/mrc-weak.mm
===
--- test/CodeGenObjCXX/mrc-weak.mm
+++ test/CodeGenObjCXX/mrc-weak.mm
@@ -119,10 +119,10 @@
 // CHECK:   call void @use_block
 // CHECK:   call void @objc_destroyWeak
 
-// CHECK-LABEL: define internal void @__copy_helper_block
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block
 // CHECK:   @objc_copyWeak
 
-// CHECK-LABEL: define internal void @__destroy_helper_block
+// CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block
 // CHECK:   @objc_destroyWeak
 
 void test8(void) {
@@ -142,8 +142,8 @@
 // CHECK:   call void @objc_destroyWeak
 
 // CHECK-LABEL: define void @_Z14test9_baselinev()
-// CHECK:   define internal void @__copy_helper
-// CHECK:   define internal void @__destroy_helper
+// CHECK:   define linkonce_odr hidden void @__copy_helper
+// CHECK:   define linkonce_odr hidden void @__destroy_helper
 void test9_baseline(void) {
   Foo *p = get_object();
   use_block(^{ [p run]; });
Index: test/CodeGenObjCXX/lambda-to-block.mm
===
--- test/CodeGenObjCXX/lambda-to-block.mm
+++ test/CodeGenObjCXX/lambda-to-block.mm
@@ -12,7 +12,7 @@
 void hasLambda(Copyable x) {
   takesBlock([x] () { });
 }
-// CHECK-LABEL: define internal void @__copy_helper_block_
+// CHECK-LABEL: define internal void @"__copy_helper_block_
 // CHECK: call void @"_ZZ9hasLambda8CopyableEN3$_0C1ERKS0_"
 // CHECK-LABEL: define internal void @"_ZZ9hasLambda8CopyableEN3$_0C2ERKS0_"
 // CHECK: call void @_ZN8CopyableC1ERKS_
Index: test/CodeGenObjCXX/arc-blocks.mm
===
--- test/CodeGenObjCXX/arc-blocks.mm
+++ test/CodeGenObjCXX/arc-blocks.mm
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -o - %s | FileCheck -check-prefix CHECK %s
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -O1 -o - %s | FileCheck -check-prefix CHECK-O1 %s
+// RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck -check-prefix CHECK-NOEXCP %s
 
 // CHECK: [[A:.*]] = type { i64, [10 x i8*] }
 // CHECK: %[[STRUCT_TEST1_S0:.*]] = type { i32 }
+// CHECK: %[[STRUCT_TRIVIAL_INTERNAL:.*]] = type { i32 }
 // CHECK: 

r339289 - Revert r339287 "[Builtins] Add __builtin_clrsb support to IntExprEvaluator::VisitBuiltinCallExpr"

2018-08-08 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Aug  8 14:21:21 2018
New Revision: 339289

URL: http://llvm.org/viewvc/llvm-project?rev=339289=rev
Log:
Revert r339287 "[Builtins] Add __builtin_clrsb support to 
IntExprEvaluator::VisitBuiltinCallExpr"

This add an additional unintended change in it.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/Sema/constant-builtins-2.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=339289=339288=339289=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Aug  8 14:21:21 2018
@@ -8117,15 +8117,9 @@ bool IntExprEvaluator::VisitBuiltinCallE
   case Builtin::BI__builtin_classify_type:
 return Success((int)EvaluateBuiltinClassifyType(E, Info.getLangOpts()), E);
 
-  case Builtin::BI__builtin_clrsb:
-  case Builtin::BI__builtin_clrsbl:
-  case Builtin::BI__builtin_clrsbll: {
-APSInt Val;
-if (!EvaluateInteger(E->getArg(0), Val, Info))
-  return false;
-
-return Success(Val.getBitWidth() - Val.getMinSignedBits(), E);
-  }
+  // FIXME: BI__builtin_clrsb
+  // FIXME: BI__builtin_clrsbl
+  // FIXME: BI__builtin_clrsbll
 
   case Builtin::BI__builtin_clz:
   case Builtin::BI__builtin_clzl:

Modified: cfe/trunk/test/Sema/constant-builtins-2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/constant-builtins-2.c?rev=339289=339288=339289=diff
==
--- cfe/trunk/test/Sema/constant-builtins-2.c (original)
+++ cfe/trunk/test/Sema/constant-builtins-2.c Wed Aug  8 14:21:21 2018
@@ -132,7 +132,7 @@ char isnormal_snan   [!__builtin_isnorma
 char clz1[__builtin_clz(1) == BITSIZE(int) - 1 ? 1 : -1];
 char clz2[__builtin_clz(7) == BITSIZE(int) - 3 ? 1 : -1];
 char clz3[__builtin_clz(1 << (BITSIZE(int) - 1)) == 0 ? 1 : -1];
-//int clz4 = __builtin_clz(0); // expected-error {{not a compile-time 
constant}}
+int clz4 = __builtin_clz(0); // expected-error {{not a compile-time constant}}
 char clz5[__builtin_clzl(0xFL) == BITSIZE(long) - 4 ? 1 : -1];
 char clz6[__builtin_clzll(0xFFLL) == BITSIZE(long long) - 8 ? 1 : -1];
 char clz7[__builtin_clzs(0x1) == BITSIZE(short) - 1 ? 1 : -1];
@@ -142,7 +142,7 @@ char clz9[__builtin_clzs(0xfff) == BITSI
 char ctz1[__builtin_ctz(1) == 0 ? 1 : -1];
 char ctz2[__builtin_ctz(8) == 3 ? 1 : -1];
 char ctz3[__builtin_ctz(1 << (BITSIZE(int) - 1)) == BITSIZE(int) - 1 ? 1 : -1];
-//int ctz4 = __builtin_ctz(0); // expected-error {{not a compile-time 
constant}}
+int ctz4 = __builtin_ctz(0); // expected-error {{not a compile-time constant}}
 char ctz5[__builtin_ctzl(0x10L) == 4 ? 1 : -1];
 char ctz6[__builtin_ctzll(0x100LL) == 8 ? 1 : -1];
 char ctz7[__builtin_ctzs(1 << (BITSIZE(short) - 1)) == BITSIZE(short) - 1 ? 1 
: -1];
@@ -176,19 +176,6 @@ char ffs4[__builtin_ffs(0xfbe70) == 5 ?
 char ffs5[__builtin_ffs(1U << (BITSIZE(int) - 1)) == BITSIZE(int) ? 1 : -1];
 char ffs6[__builtin_ffsl(0x10L) == 5 ? 1 : -1];
 char ffs7[__builtin_ffsll(0x100LL) == 9 ? 1 : -1];
-
-char clrsb1[__builtin_clrsb(0) == BITSIZE(int) - 1 ? 1 : -1];
-char clrsb2[__builtin_clrsbl(0L) == BITSIZE(long) - 1 ? 1 : -1];
-char clrsb3[__builtin_clrsbll(0LL) == BITSIZE(long long) - 1 ? 1 : -1];
-char clrsb4[__builtin_clrsb(~0) == BITSIZE(int) - 1 ? 1 : -1];
-char clrsb5[__builtin_clrsbl(~0L) == BITSIZE(long) - 1 ? 1 : -1];
-char clrsb6[__builtin_clrsbll(~0LL) == BITSIZE(long long) - 1 ? 1 : -1];
-char clrsb7[__builtin_clrsb(1) == BITSIZE(int) - 2 ? 1 : -1];
-char clrsb8[__builtin_clrsb(~1) == BITSIZE(int) - 2 ? 1 : -1];
-char clrsb9[__builtin_clrsb(1 << (BITSIZE(int) - 1)) == 0 ? 1 : -1];
-char clrsb10[__builtin_clrsb(~(1 << (BITSIZE(int) - 1))) == 0 ? 1 : -1];
-char clrsb11[__builtin_clrsb(0xf) == BITSIZE(int) - 5 ? 1 : -1];
-char clrsb11[__builtin_clrsb(~0x1f) == BITSIZE(int) - 6 ? 1 : -1];
 #undef BITSIZE
 
 // GCC misc stuff


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


[PATCH] D50477: WIP: Ensure that the type of size_t is represended as one of the fixed width types

2018-08-08 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 159794.
sbc100 added a comment.

remove debugging


Repository:
  rC Clang

https://reviews.llvm.org/D50477

Files:
  lib/Frontend/InitPreprocessor.cpp


Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -870,16 +870,18 @@
   if (!TargetInfo::isTypeSigned(TI.getWIntType()))
 Builder.defineMacro("__WINT_UNSIGNED__");
 
+  unsigned SizeTypeWidth = TI.getTypeWidth(TI.getSizeType());
+
   // Define exact-width integer types for stdint.h
   DefineExactWidthIntType(TargetInfo::SignedChar, TI, Builder);
 
   if (TI.getShortWidth() > TI.getCharWidth())
 DefineExactWidthIntType(TargetInfo::SignedShort, TI, Builder);
 
-  if (TI.getIntWidth() > TI.getShortWidth())
+  if (TI.getIntWidth() > TI.getShortWidth() && !(TI.getIntWidth() == 
SizeTypeWidth && TI.getSignedSizeType() != TargetInfo::SignedInt))
 DefineExactWidthIntType(TargetInfo::SignedInt, TI, Builder);
 
-  if (TI.getLongWidth() > TI.getIntWidth())
+  if (TI.getLongWidth() > TI.getIntWidth() || TI.getSignedSizeType() == 
TargetInfo::SignedLong)
 DefineExactWidthIntType(TargetInfo::SignedLong, TI, Builder);
 
   if (TI.getLongLongWidth() > TI.getLongWidth())
@@ -895,13 +897,13 @@
 DefineExactWidthIntTypeSize(TargetInfo::SignedShort, TI, Builder);
   }
 
-  if (TI.getIntWidth() > TI.getShortWidth()) {
+  if (TI.getIntWidth() > TI.getShortWidth() && !(TI.getIntWidth() == 
SizeTypeWidth && TI.getSizeType() != TargetInfo::UnsignedInt)) {
 DefineExactWidthIntType(TargetInfo::UnsignedInt, TI, Builder);
 DefineExactWidthIntTypeSize(TargetInfo::UnsignedInt, TI, Builder);
 DefineExactWidthIntTypeSize(TargetInfo::SignedInt, TI, Builder);
   }
 
-  if (TI.getLongWidth() > TI.getIntWidth()) {
+  if (TI.getLongWidth() > TI.getIntWidth() || TI.getSizeType() == 
TargetInfo::UnsignedLong) {
 DefineExactWidthIntType(TargetInfo::UnsignedLong, TI, Builder);
 DefineExactWidthIntTypeSize(TargetInfo::UnsignedLong, TI, Builder);
 DefineExactWidthIntTypeSize(TargetInfo::SignedLong, TI, Builder);


Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -870,16 +870,18 @@
   if (!TargetInfo::isTypeSigned(TI.getWIntType()))
 Builder.defineMacro("__WINT_UNSIGNED__");
 
+  unsigned SizeTypeWidth = TI.getTypeWidth(TI.getSizeType());
+
   // Define exact-width integer types for stdint.h
   DefineExactWidthIntType(TargetInfo::SignedChar, TI, Builder);
 
   if (TI.getShortWidth() > TI.getCharWidth())
 DefineExactWidthIntType(TargetInfo::SignedShort, TI, Builder);
 
-  if (TI.getIntWidth() > TI.getShortWidth())
+  if (TI.getIntWidth() > TI.getShortWidth() && !(TI.getIntWidth() == SizeTypeWidth && TI.getSignedSizeType() != TargetInfo::SignedInt))
 DefineExactWidthIntType(TargetInfo::SignedInt, TI, Builder);
 
-  if (TI.getLongWidth() > TI.getIntWidth())
+  if (TI.getLongWidth() > TI.getIntWidth() || TI.getSignedSizeType() == TargetInfo::SignedLong)
 DefineExactWidthIntType(TargetInfo::SignedLong, TI, Builder);
 
   if (TI.getLongLongWidth() > TI.getLongWidth())
@@ -895,13 +897,13 @@
 DefineExactWidthIntTypeSize(TargetInfo::SignedShort, TI, Builder);
   }
 
-  if (TI.getIntWidth() > TI.getShortWidth()) {
+  if (TI.getIntWidth() > TI.getShortWidth() && !(TI.getIntWidth() == SizeTypeWidth && TI.getSizeType() != TargetInfo::UnsignedInt)) {
 DefineExactWidthIntType(TargetInfo::UnsignedInt, TI, Builder);
 DefineExactWidthIntTypeSize(TargetInfo::UnsignedInt, TI, Builder);
 DefineExactWidthIntTypeSize(TargetInfo::SignedInt, TI, Builder);
   }
 
-  if (TI.getLongWidth() > TI.getIntWidth()) {
+  if (TI.getLongWidth() > TI.getIntWidth() || TI.getSizeType() == TargetInfo::UnsignedLong) {
 DefineExactWidthIntType(TargetInfo::UnsignedLong, TI, Builder);
 DefineExactWidthIntTypeSize(TargetInfo::UnsignedLong, TI, Builder);
 DefineExactWidthIntTypeSize(TargetInfo::SignedLong, TI, Builder);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50477: WIP: Ensure that the type of size_t is represended as one of the fixed width types

2018-08-08 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: cfe-commits, sunfish, aheejin.

We recently changes `size_t` on wasm from `int` to `long` which
had the effect of making the type of size_t (long) not match either
int32_t or int64_t.

This solution is not very elegant but fixes the build issues that
resulted from this change.


Repository:
  rC Clang

https://reviews.llvm.org/D50477

Files:
  lib/Frontend/InitPreprocessor.cpp


Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -209,6 +209,8 @@
 
 static void DefineType(const Twine , TargetInfo::IntType Ty,
MacroBuilder ) {
+  printf("macro = %s\n", MacroName.str().c_str());
+  printf("name = %s\n", TargetInfo::getTypeName(Ty));
   Builder.defineMacro(MacroName, TargetInfo::getTypeName(Ty));
 }
 
@@ -228,6 +230,7 @@
 MacroBuilder ) {
   int TypeWidth = TI.getTypeWidth(Ty);
   bool IsSigned = TI.isTypeSigned(Ty);
+  printf("DefineExactWidthIntType\n");
 
   // Use the target specified int64 type, when appropriate, so that [u]int64_t
   // ends up being defined in terms of the correct type.
@@ -870,16 +873,18 @@
   if (!TargetInfo::isTypeSigned(TI.getWIntType()))
 Builder.defineMacro("__WINT_UNSIGNED__");
 
+  unsigned SizeTypeWidth = TI.getTypeWidth(TI.getSizeType());
+
   // Define exact-width integer types for stdint.h
   DefineExactWidthIntType(TargetInfo::SignedChar, TI, Builder);
 
   if (TI.getShortWidth() > TI.getCharWidth())
 DefineExactWidthIntType(TargetInfo::SignedShort, TI, Builder);
 
-  if (TI.getIntWidth() > TI.getShortWidth())
+  if (TI.getIntWidth() > TI.getShortWidth() && !(TI.getIntWidth() == 
SizeTypeWidth && TI.getSignedSizeType() != TargetInfo::SignedInt))
 DefineExactWidthIntType(TargetInfo::SignedInt, TI, Builder);
 
-  if (TI.getLongWidth() > TI.getIntWidth())
+  if (TI.getLongWidth() > TI.getIntWidth() || TI.getSignedSizeType() == 
TargetInfo::SignedLong)
 DefineExactWidthIntType(TargetInfo::SignedLong, TI, Builder);
 
   if (TI.getLongLongWidth() > TI.getLongWidth())
@@ -895,13 +900,13 @@
 DefineExactWidthIntTypeSize(TargetInfo::SignedShort, TI, Builder);
   }
 
-  if (TI.getIntWidth() > TI.getShortWidth()) {
+  if (TI.getIntWidth() > TI.getShortWidth() && !(TI.getIntWidth() == 
SizeTypeWidth && TI.getSizeType() != TargetInfo::UnsignedInt)) {
 DefineExactWidthIntType(TargetInfo::UnsignedInt, TI, Builder);
 DefineExactWidthIntTypeSize(TargetInfo::UnsignedInt, TI, Builder);
 DefineExactWidthIntTypeSize(TargetInfo::SignedInt, TI, Builder);
   }
 
-  if (TI.getLongWidth() > TI.getIntWidth()) {
+  if (TI.getLongWidth() > TI.getIntWidth() || TI.getSizeType() == 
TargetInfo::UnsignedLong) {
 DefineExactWidthIntType(TargetInfo::UnsignedLong, TI, Builder);
 DefineExactWidthIntTypeSize(TargetInfo::UnsignedLong, TI, Builder);
 DefineExactWidthIntTypeSize(TargetInfo::SignedLong, TI, Builder);


Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -209,6 +209,8 @@
 
 static void DefineType(const Twine , TargetInfo::IntType Ty,
MacroBuilder ) {
+  printf("macro = %s\n", MacroName.str().c_str());
+  printf("name = %s\n", TargetInfo::getTypeName(Ty));
   Builder.defineMacro(MacroName, TargetInfo::getTypeName(Ty));
 }
 
@@ -228,6 +230,7 @@
 MacroBuilder ) {
   int TypeWidth = TI.getTypeWidth(Ty);
   bool IsSigned = TI.isTypeSigned(Ty);
+  printf("DefineExactWidthIntType\n");
 
   // Use the target specified int64 type, when appropriate, so that [u]int64_t
   // ends up being defined in terms of the correct type.
@@ -870,16 +873,18 @@
   if (!TargetInfo::isTypeSigned(TI.getWIntType()))
 Builder.defineMacro("__WINT_UNSIGNED__");
 
+  unsigned SizeTypeWidth = TI.getTypeWidth(TI.getSizeType());
+
   // Define exact-width integer types for stdint.h
   DefineExactWidthIntType(TargetInfo::SignedChar, TI, Builder);
 
   if (TI.getShortWidth() > TI.getCharWidth())
 DefineExactWidthIntType(TargetInfo::SignedShort, TI, Builder);
 
-  if (TI.getIntWidth() > TI.getShortWidth())
+  if (TI.getIntWidth() > TI.getShortWidth() && !(TI.getIntWidth() == SizeTypeWidth && TI.getSignedSizeType() != TargetInfo::SignedInt))
 DefineExactWidthIntType(TargetInfo::SignedInt, TI, Builder);
 
-  if (TI.getLongWidth() > TI.getIntWidth())
+  if (TI.getLongWidth() > TI.getIntWidth() || TI.getSignedSizeType() == TargetInfo::SignedLong)
 DefineExactWidthIntType(TargetInfo::SignedLong, TI, Builder);
 
   if (TI.getLongLongWidth() > TI.getLongWidth())
@@ -895,13 +900,13 @@
 DefineExactWidthIntTypeSize(TargetInfo::SignedShort, TI, Builder);
   }
 
-  if (TI.getIntWidth() > TI.getShortWidth()) {
+  if (TI.getIntWidth() > 

[PATCH] D50471: [Builtins] Add __bulitin_clrsb support to IntExprEvaluator::VisitBuiltinCallExpr

2018-08-08 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339287: [Builtins] Add __builtin_clrsb support to 
IntExprEvaluator::VisitBuiltinCallExpr (authored by ctopper, committed by ).
Herald added a subscriber: kristina.

Changed prior to commit:
  https://reviews.llvm.org/D50471?vs=159777=159786#toc

Repository:
  rC Clang

https://reviews.llvm.org/D50471

Files:
  lib/AST/ExprConstant.cpp
  test/Sema/constant-builtins-2.c


Index: test/Sema/constant-builtins-2.c
===
--- test/Sema/constant-builtins-2.c
+++ test/Sema/constant-builtins-2.c
@@ -132,7 +132,7 @@
 char clz1[__builtin_clz(1) == BITSIZE(int) - 1 ? 1 : -1];
 char clz2[__builtin_clz(7) == BITSIZE(int) - 3 ? 1 : -1];
 char clz3[__builtin_clz(1 << (BITSIZE(int) - 1)) == 0 ? 1 : -1];
-int clz4 = __builtin_clz(0); // expected-error {{not a compile-time constant}}
+//int clz4 = __builtin_clz(0); // expected-error {{not a compile-time 
constant}}
 char clz5[__builtin_clzl(0xFL) == BITSIZE(long) - 4 ? 1 : -1];
 char clz6[__builtin_clzll(0xFFLL) == BITSIZE(long long) - 8 ? 1 : -1];
 char clz7[__builtin_clzs(0x1) == BITSIZE(short) - 1 ? 1 : -1];
@@ -142,7 +142,7 @@
 char ctz1[__builtin_ctz(1) == 0 ? 1 : -1];
 char ctz2[__builtin_ctz(8) == 3 ? 1 : -1];
 char ctz3[__builtin_ctz(1 << (BITSIZE(int) - 1)) == BITSIZE(int) - 1 ? 1 : -1];
-int ctz4 = __builtin_ctz(0); // expected-error {{not a compile-time constant}}
+//int ctz4 = __builtin_ctz(0); // expected-error {{not a compile-time 
constant}}
 char ctz5[__builtin_ctzl(0x10L) == 4 ? 1 : -1];
 char ctz6[__builtin_ctzll(0x100LL) == 8 ? 1 : -1];
 char ctz7[__builtin_ctzs(1 << (BITSIZE(short) - 1)) == BITSIZE(short) - 1 ? 1 
: -1];
@@ -176,6 +176,19 @@
 char ffs5[__builtin_ffs(1U << (BITSIZE(int) - 1)) == BITSIZE(int) ? 1 : -1];
 char ffs6[__builtin_ffsl(0x10L) == 5 ? 1 : -1];
 char ffs7[__builtin_ffsll(0x100LL) == 9 ? 1 : -1];
+
+char clrsb1[__builtin_clrsb(0) == BITSIZE(int) - 1 ? 1 : -1];
+char clrsb2[__builtin_clrsbl(0L) == BITSIZE(long) - 1 ? 1 : -1];
+char clrsb3[__builtin_clrsbll(0LL) == BITSIZE(long long) - 1 ? 1 : -1];
+char clrsb4[__builtin_clrsb(~0) == BITSIZE(int) - 1 ? 1 : -1];
+char clrsb5[__builtin_clrsbl(~0L) == BITSIZE(long) - 1 ? 1 : -1];
+char clrsb6[__builtin_clrsbll(~0LL) == BITSIZE(long long) - 1 ? 1 : -1];
+char clrsb7[__builtin_clrsb(1) == BITSIZE(int) - 2 ? 1 : -1];
+char clrsb8[__builtin_clrsb(~1) == BITSIZE(int) - 2 ? 1 : -1];
+char clrsb9[__builtin_clrsb(1 << (BITSIZE(int) - 1)) == 0 ? 1 : -1];
+char clrsb10[__builtin_clrsb(~(1 << (BITSIZE(int) - 1))) == 0 ? 1 : -1];
+char clrsb11[__builtin_clrsb(0xf) == BITSIZE(int) - 5 ? 1 : -1];
+char clrsb11[__builtin_clrsb(~0x1f) == BITSIZE(int) - 6 ? 1 : -1];
 #undef BITSIZE
 
 // GCC misc stuff
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -8117,9 +8117,15 @@
   case Builtin::BI__builtin_classify_type:
 return Success((int)EvaluateBuiltinClassifyType(E, Info.getLangOpts()), E);
 
-  // FIXME: BI__builtin_clrsb
-  // FIXME: BI__builtin_clrsbl
-  // FIXME: BI__builtin_clrsbll
+  case Builtin::BI__builtin_clrsb:
+  case Builtin::BI__builtin_clrsbl:
+  case Builtin::BI__builtin_clrsbll: {
+APSInt Val;
+if (!EvaluateInteger(E->getArg(0), Val, Info))
+  return false;
+
+return Success(Val.getBitWidth() - Val.getMinSignedBits(), E);
+  }
 
   case Builtin::BI__builtin_clz:
   case Builtin::BI__builtin_clzl:


Index: test/Sema/constant-builtins-2.c
===
--- test/Sema/constant-builtins-2.c
+++ test/Sema/constant-builtins-2.c
@@ -132,7 +132,7 @@
 char clz1[__builtin_clz(1) == BITSIZE(int) - 1 ? 1 : -1];
 char clz2[__builtin_clz(7) == BITSIZE(int) - 3 ? 1 : -1];
 char clz3[__builtin_clz(1 << (BITSIZE(int) - 1)) == 0 ? 1 : -1];
-int clz4 = __builtin_clz(0); // expected-error {{not a compile-time constant}}
+//int clz4 = __builtin_clz(0); // expected-error {{not a compile-time constant}}
 char clz5[__builtin_clzl(0xFL) == BITSIZE(long) - 4 ? 1 : -1];
 char clz6[__builtin_clzll(0xFFLL) == BITSIZE(long long) - 8 ? 1 : -1];
 char clz7[__builtin_clzs(0x1) == BITSIZE(short) - 1 ? 1 : -1];
@@ -142,7 +142,7 @@
 char ctz1[__builtin_ctz(1) == 0 ? 1 : -1];
 char ctz2[__builtin_ctz(8) == 3 ? 1 : -1];
 char ctz3[__builtin_ctz(1 << (BITSIZE(int) - 1)) == BITSIZE(int) - 1 ? 1 : -1];
-int ctz4 = __builtin_ctz(0); // expected-error {{not a compile-time constant}}
+//int ctz4 = __builtin_ctz(0); // expected-error {{not a compile-time constant}}
 char ctz5[__builtin_ctzl(0x10L) == 4 ? 1 : -1];
 char ctz6[__builtin_ctzll(0x100LL) == 8 ? 1 : -1];
 char ctz7[__builtin_ctzs(1 << (BITSIZE(short) - 1)) == BITSIZE(short) - 1 ? 1 : -1];
@@ -176,6 +176,19 @@
 char ffs5[__builtin_ffs(1U << (BITSIZE(int) - 1)) == BITSIZE(int) ? 1 : -1];
 char ffs6[__builtin_ffsl(0x10L) == 5 ? 1 : -1];
 char 

r339287 - [Builtins] Add __builtin_clrsb support to IntExprEvaluator::VisitBuiltinCallExpr

2018-08-08 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Aug  8 13:59:40 2018
New Revision: 339287

URL: http://llvm.org/viewvc/llvm-project?rev=339287=rev
Log:
[Builtins] Add __builtin_clrsb support to IntExprEvaluator::VisitBuiltinCallExpr

This addresses a FIXME that has existed since before clang supported the 
builtin.

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

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/Sema/constant-builtins-2.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=339287=339286=339287=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Aug  8 13:59:40 2018
@@ -8117,9 +8117,15 @@ bool IntExprEvaluator::VisitBuiltinCallE
   case Builtin::BI__builtin_classify_type:
 return Success((int)EvaluateBuiltinClassifyType(E, Info.getLangOpts()), E);
 
-  // FIXME: BI__builtin_clrsb
-  // FIXME: BI__builtin_clrsbl
-  // FIXME: BI__builtin_clrsbll
+  case Builtin::BI__builtin_clrsb:
+  case Builtin::BI__builtin_clrsbl:
+  case Builtin::BI__builtin_clrsbll: {
+APSInt Val;
+if (!EvaluateInteger(E->getArg(0), Val, Info))
+  return false;
+
+return Success(Val.getBitWidth() - Val.getMinSignedBits(), E);
+  }
 
   case Builtin::BI__builtin_clz:
   case Builtin::BI__builtin_clzl:

Modified: cfe/trunk/test/Sema/constant-builtins-2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/constant-builtins-2.c?rev=339287=339286=339287=diff
==
--- cfe/trunk/test/Sema/constant-builtins-2.c (original)
+++ cfe/trunk/test/Sema/constant-builtins-2.c Wed Aug  8 13:59:40 2018
@@ -132,7 +132,7 @@ char isnormal_snan   [!__builtin_isnorma
 char clz1[__builtin_clz(1) == BITSIZE(int) - 1 ? 1 : -1];
 char clz2[__builtin_clz(7) == BITSIZE(int) - 3 ? 1 : -1];
 char clz3[__builtin_clz(1 << (BITSIZE(int) - 1)) == 0 ? 1 : -1];
-int clz4 = __builtin_clz(0); // expected-error {{not a compile-time constant}}
+//int clz4 = __builtin_clz(0); // expected-error {{not a compile-time 
constant}}
 char clz5[__builtin_clzl(0xFL) == BITSIZE(long) - 4 ? 1 : -1];
 char clz6[__builtin_clzll(0xFFLL) == BITSIZE(long long) - 8 ? 1 : -1];
 char clz7[__builtin_clzs(0x1) == BITSIZE(short) - 1 ? 1 : -1];
@@ -142,7 +142,7 @@ char clz9[__builtin_clzs(0xfff) == BITSI
 char ctz1[__builtin_ctz(1) == 0 ? 1 : -1];
 char ctz2[__builtin_ctz(8) == 3 ? 1 : -1];
 char ctz3[__builtin_ctz(1 << (BITSIZE(int) - 1)) == BITSIZE(int) - 1 ? 1 : -1];
-int ctz4 = __builtin_ctz(0); // expected-error {{not a compile-time constant}}
+//int ctz4 = __builtin_ctz(0); // expected-error {{not a compile-time 
constant}}
 char ctz5[__builtin_ctzl(0x10L) == 4 ? 1 : -1];
 char ctz6[__builtin_ctzll(0x100LL) == 8 ? 1 : -1];
 char ctz7[__builtin_ctzs(1 << (BITSIZE(short) - 1)) == BITSIZE(short) - 1 ? 1 
: -1];
@@ -176,6 +176,19 @@ char ffs4[__builtin_ffs(0xfbe70) == 5 ?
 char ffs5[__builtin_ffs(1U << (BITSIZE(int) - 1)) == BITSIZE(int) ? 1 : -1];
 char ffs6[__builtin_ffsl(0x10L) == 5 ? 1 : -1];
 char ffs7[__builtin_ffsll(0x100LL) == 9 ? 1 : -1];
+
+char clrsb1[__builtin_clrsb(0) == BITSIZE(int) - 1 ? 1 : -1];
+char clrsb2[__builtin_clrsbl(0L) == BITSIZE(long) - 1 ? 1 : -1];
+char clrsb3[__builtin_clrsbll(0LL) == BITSIZE(long long) - 1 ? 1 : -1];
+char clrsb4[__builtin_clrsb(~0) == BITSIZE(int) - 1 ? 1 : -1];
+char clrsb5[__builtin_clrsbl(~0L) == BITSIZE(long) - 1 ? 1 : -1];
+char clrsb6[__builtin_clrsbll(~0LL) == BITSIZE(long long) - 1 ? 1 : -1];
+char clrsb7[__builtin_clrsb(1) == BITSIZE(int) - 2 ? 1 : -1];
+char clrsb8[__builtin_clrsb(~1) == BITSIZE(int) - 2 ? 1 : -1];
+char clrsb9[__builtin_clrsb(1 << (BITSIZE(int) - 1)) == 0 ? 1 : -1];
+char clrsb10[__builtin_clrsb(~(1 << (BITSIZE(int) - 1))) == 0 ? 1 : -1];
+char clrsb11[__builtin_clrsb(0xf) == BITSIZE(int) - 5 ? 1 : -1];
+char clrsb11[__builtin_clrsb(~0x1f) == BITSIZE(int) - 6 ? 1 : -1];
 #undef BITSIZE
 
 // GCC misc stuff


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


[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2018-08-08 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339284: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL 
(authored by pirama, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D37302?vs=159330=159778#toc

Repository:
  rC Clang

https://reviews.llvm.org/D37302

Files:
  lib/Headers/float.h
  test/Headers/float.c


Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > 
LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 


Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r339284 - [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2018-08-08 Thread Pirama Arumuga Nainar via cfe-commits
Author: pirama
Date: Wed Aug  8 13:38:38 2018
New Revision: 339284

URL: http://llvm.org/viewvc/llvm-project?rev=339284=rev
Log:
[Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

Summary:
These macros are defined in the C11 standard and can be defined based on
the __*_HAS_DENORM__ default macros.

Reviewers: bruno, rsmith, doug.gregor

Subscribers: llvm-commits, enh, srhines

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

Modified:
cfe/trunk/lib/Headers/float.h
cfe/trunk/test/Headers/float.c

Modified: cfe/trunk/lib/Headers/float.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/float.h?rev=339284=339283=339284=diff
==
--- cfe/trunk/lib/Headers/float.h (original)
+++ cfe/trunk/lib/Headers/float.h Wed Aug  8 13:38:38 2018
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__

Modified: cfe/trunk/test/Headers/float.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/float.c?rev=339284=339283=339284=diff
==
--- cfe/trunk/test/Headers/float.c (original)
+++ cfe/trunk/test/Headers/float.c Wed Aug  8 13:38:38 2018
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > 
LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 


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


[PATCH] D50471: [Builtins] Add __bulitin_clrsb support to IntExprEvaluator::VisitBuiltinCallExpr

2018-08-08 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 159777.
craig.topper added a comment.

Fix duplicate variable name in the test. Not sure why that didn't complain


https://reviews.llvm.org/D50471

Files:
  lib/AST/ExprConstant.cpp
  test/Sema/constant-builtins-2.c


Index: test/Sema/constant-builtins-2.c
===
--- test/Sema/constant-builtins-2.c
+++ test/Sema/constant-builtins-2.c
@@ -176,6 +176,19 @@
 char ffs5[__builtin_ffs(1U << (BITSIZE(int) - 1)) == BITSIZE(int) ? 1 : -1];
 char ffs6[__builtin_ffsl(0x10L) == 5 ? 1 : -1];
 char ffs7[__builtin_ffsll(0x100LL) == 9 ? 1 : -1];
+
+char clrsb1[__builtin_clrsb(0) == BITSIZE(int) - 1 ? 1 : -1];
+char clrsb2[__builtin_clrsbl(0L) == BITSIZE(long) - 1 ? 1 : -1];
+char clrsb3[__builtin_clrsbll(0LL) == BITSIZE(long long) - 1 ? 1 : -1];
+char clrsb4[__builtin_clrsb(~0) == BITSIZE(int) - 1 ? 1 : -1];
+char clrsb5[__builtin_clrsbl(~0L) == BITSIZE(long) - 1 ? 1 : -1];
+char clrsb6[__builtin_clrsbll(~0LL) == BITSIZE(long long) - 1 ? 1 : -1];
+char clrsb7[__builtin_clrsb(1) == BITSIZE(int) - 2 ? 1 : -1];
+char clrsb8[__builtin_clrsb(~1) == BITSIZE(int) - 2 ? 1 : -1];
+char clrsb9[__builtin_clrsb(1 << (BITSIZE(int) - 1)) == 0 ? 1 : -1];
+char clrsb10[__builtin_clrsb(~(1 << (BITSIZE(int) - 1))) == 0 ? 1 : -1];
+char clrsb11[__builtin_clrsb(0xf) == BITSIZE(int) - 5 ? 1 : -1];
+char clrsb12[__builtin_clrsb(~0x1f) == BITSIZE(int) - 6 ? 1 : -1];
 #undef BITSIZE
 
 // GCC misc stuff
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -8117,9 +8117,15 @@
   case Builtin::BI__builtin_classify_type:
 return Success((int)EvaluateBuiltinClassifyType(E, Info.getLangOpts()), E);
 
-  // FIXME: BI__builtin_clrsb
-  // FIXME: BI__builtin_clrsbl
-  // FIXME: BI__builtin_clrsbll
+  case Builtin::BI__builtin_clrsb:
+  case Builtin::BI__builtin_clrsbl:
+  case Builtin::BI__builtin_clrsbll: {
+APSInt Val;
+if (!EvaluateInteger(E->getArg(0), Val, Info))
+  return false;
+
+return Success(Val.getBitWidth() - Val.getMinSignedBits(), E);
+  }
 
   case Builtin::BI__builtin_clz:
   case Builtin::BI__builtin_clzl:


Index: test/Sema/constant-builtins-2.c
===
--- test/Sema/constant-builtins-2.c
+++ test/Sema/constant-builtins-2.c
@@ -176,6 +176,19 @@
 char ffs5[__builtin_ffs(1U << (BITSIZE(int) - 1)) == BITSIZE(int) ? 1 : -1];
 char ffs6[__builtin_ffsl(0x10L) == 5 ? 1 : -1];
 char ffs7[__builtin_ffsll(0x100LL) == 9 ? 1 : -1];
+
+char clrsb1[__builtin_clrsb(0) == BITSIZE(int) - 1 ? 1 : -1];
+char clrsb2[__builtin_clrsbl(0L) == BITSIZE(long) - 1 ? 1 : -1];
+char clrsb3[__builtin_clrsbll(0LL) == BITSIZE(long long) - 1 ? 1 : -1];
+char clrsb4[__builtin_clrsb(~0) == BITSIZE(int) - 1 ? 1 : -1];
+char clrsb5[__builtin_clrsbl(~0L) == BITSIZE(long) - 1 ? 1 : -1];
+char clrsb6[__builtin_clrsbll(~0LL) == BITSIZE(long long) - 1 ? 1 : -1];
+char clrsb7[__builtin_clrsb(1) == BITSIZE(int) - 2 ? 1 : -1];
+char clrsb8[__builtin_clrsb(~1) == BITSIZE(int) - 2 ? 1 : -1];
+char clrsb9[__builtin_clrsb(1 << (BITSIZE(int) - 1)) == 0 ? 1 : -1];
+char clrsb10[__builtin_clrsb(~(1 << (BITSIZE(int) - 1))) == 0 ? 1 : -1];
+char clrsb11[__builtin_clrsb(0xf) == BITSIZE(int) - 5 ? 1 : -1];
+char clrsb12[__builtin_clrsb(~0x1f) == BITSIZE(int) - 6 ? 1 : -1];
 #undef BITSIZE
 
 // GCC misc stuff
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -8117,9 +8117,15 @@
   case Builtin::BI__builtin_classify_type:
 return Success((int)EvaluateBuiltinClassifyType(E, Info.getLangOpts()), E);
 
-  // FIXME: BI__builtin_clrsb
-  // FIXME: BI__builtin_clrsbl
-  // FIXME: BI__builtin_clrsbll
+  case Builtin::BI__builtin_clrsb:
+  case Builtin::BI__builtin_clrsbl:
+  case Builtin::BI__builtin_clrsbll: {
+APSInt Val;
+if (!EvaluateInteger(E->getArg(0), Val, Info))
+  return false;
+
+return Success(Val.getBitWidth() - Val.getMinSignedBits(), E);
+  }
 
   case Builtin::BI__builtin_clz:
   case Builtin::BI__builtin_clzl:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50471: [Builtins] Add __bulitin_clrsb support to IntExprEvaluator::VisitBuiltinCallExpr

2018-08-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

Looks easy enough, just note the test issue.




Comment at: test/Sema/constant-builtins-2.c:191
+char clrsb11[__builtin_clrsb(0xf) == BITSIZE(int) - 5 ? 1 : -1];
+char clrsb11[__builtin_clrsb(~0x1f) == BITSIZE(int) - 6 ? 1 : -1];
 #undef BITSIZE

Same name as line 190.


https://reviews.llvm.org/D50471



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


[PATCH] D45444: [clang-tidy] implement new check for const-correctness

2018-08-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 159775.
JonasToth added a comment.

- fix bug with AnalyzeValues==false skipping whole check, adjust test code to 
'const' instead of const


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp
  clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-const-correctness.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-const-correctness-pointer-as-values.cpp
  test/clang-tidy/cppcoreguidelines-const-correctness-values.cpp

Index: test/clang-tidy/cppcoreguidelines-const-correctness-values.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-const-correctness-values.cpp
@@ -0,0 +1,557 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-const-correctness %t
+
+// --- Provide test samples for primitive builtins -
+// - every 'p_*' variable is a 'potential_const_*' variable
+// - every 'np_*' variable is a 'non_potential_const_*' variable
+
+bool global;
+char np_global = 0; // globals can't be known to be const
+
+namespace foo {
+int scoped;
+float np_scoped = 1; // namespace variables are like globals
+} // namespace foo
+
+void some_function(double, wchar_t);
+
+void some_function(double np_arg0, wchar_t np_arg1) {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local0;
+  const int np_local1 = 42;
+
+  unsigned int np_local2 = 3;
+  np_local2 <<= 4;
+
+  int np_local3 = 4;
+  ++np_local3;
+  int np_local4 = 4;
+  np_local4++;
+
+  int np_local5 = 4;
+  --np_local5;
+  int np_local6 = 4;
+  np_local6--;
+}
+
+void nested_scopes() {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+  int np_local0 = 42;
+
+  {
+int p_local1 = 42;
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: variable 'p_local1' of type 'int' can be declared 'const'
+np_local0 *= 2;
+  }
+}
+
+void some_lambda_environment_capture_all_by_reference(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local2;
+  const int np_local3 = 2;
+
+  // Capturing all variables by reference prohibits making them const.
+  [&]() { ++np_local0; };
+
+  int p_local1 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+}
+
+void some_lambda_environment_capture_all_by_value(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local1;
+  const int np_local2 = 2;
+
+  // Capturing by value has no influence on them.
+  [=]() { (void)p_local0; };
+
+  np_local0 += 10;
+}
+
+void function_inout_pointer(int *inout);
+void function_in_pointer(const int *in);
+
+void some_pointer_taking(int *out) {
+  int np_local0 = 42;
+  const int *const p0_np_local0 = _local0;
+  int *const p1_np_local0 = _local0;
+
+  int np_local1 = 42;
+  const int *const p0_np_local1 = _local1;
+  int *const p1_np_local1 = _local1;
+  *p1_np_local0 = 43;
+
+  int np_local2 = 42;
+  function_inout_pointer(_local2);
+
+  // Prevents const.
+  int np_local3 = 42;
+  out = _local3; // This returns and invalid address, its just about the AST
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+  const int *const p0_p_local1 = _local1;
+
+  int p_local2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local2' of type 'int' can be declared 'const'
+  function_in_pointer(_local2);
+}
+
+void function_inout_ref(int );
+void function_in_ref(const int );
+
+void some_reference_taking() {
+  int np_local0 = 42;
+  const int _np_local0 = np_local0;
+  int _np_local0 = np_local0;
+  r1_np_local0 = 43;
+  const int _np_local0 = r1_np_local0;
+
+  int np_local1 = 42;
+  function_inout_ref(np_local1);
+
+  int p_local0 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+  const int _p_local0 = p_local0;
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+  function_in_ref(p_local1);
+}
+
+double *non_const_pointer_return() {
+  double p_local0 = 0.0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared 'const'
+  double np_local0 = 24.4;
+
+  return _local0;
+}
+
+const double *const_pointer_return() {
+  double p_local0 = 0.0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 

[PATCH] D50471: [Builtins] Add __bulitin_clrsb support to IntExprEvaluator::VisitBuiltinCallExpr

2018-08-08 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: bkramer, erichkeane.

Now that __builtin_clrsb is supported by clang, this patch adds constant 
evaluation of it to address the FIXME.


https://reviews.llvm.org/D50471

Files:
  lib/AST/ExprConstant.cpp
  test/Sema/constant-builtins-2.c


Index: test/Sema/constant-builtins-2.c
===
--- test/Sema/constant-builtins-2.c
+++ test/Sema/constant-builtins-2.c
@@ -176,6 +176,19 @@
 char ffs5[__builtin_ffs(1U << (BITSIZE(int) - 1)) == BITSIZE(int) ? 1 : -1];
 char ffs6[__builtin_ffsl(0x10L) == 5 ? 1 : -1];
 char ffs7[__builtin_ffsll(0x100LL) == 9 ? 1 : -1];
+
+char clrsb1[__builtin_clrsb(0) == BITSIZE(int) - 1 ? 1 : -1];
+char clrsb2[__builtin_clrsbl(0L) == BITSIZE(long) - 1 ? 1 : -1];
+char clrsb3[__builtin_clrsbll(0LL) == BITSIZE(long long) - 1 ? 1 : -1];
+char clrsb4[__builtin_clrsb(~0) == BITSIZE(int) - 1 ? 1 : -1];
+char clrsb5[__builtin_clrsbl(~0L) == BITSIZE(long) - 1 ? 1 : -1];
+char clrsb6[__builtin_clrsbll(~0LL) == BITSIZE(long long) - 1 ? 1 : -1];
+char clrsb7[__builtin_clrsb(1) == BITSIZE(int) - 2 ? 1 : -1];
+char clrsb8[__builtin_clrsb(~1) == BITSIZE(int) - 2 ? 1 : -1];
+char clrsb9[__builtin_clrsb(1 << (BITSIZE(int) - 1)) == 0 ? 1 : -1];
+char clrsb10[__builtin_clrsb(~(1 << (BITSIZE(int) - 1))) == 0 ? 1 : -1];
+char clrsb11[__builtin_clrsb(0xf) == BITSIZE(int) - 5 ? 1 : -1];
+char clrsb11[__builtin_clrsb(~0x1f) == BITSIZE(int) - 6 ? 1 : -1];
 #undef BITSIZE
 
 // GCC misc stuff
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -8117,9 +8117,15 @@
   case Builtin::BI__builtin_classify_type:
 return Success((int)EvaluateBuiltinClassifyType(E, Info.getLangOpts()), E);
 
-  // FIXME: BI__builtin_clrsb
-  // FIXME: BI__builtin_clrsbl
-  // FIXME: BI__builtin_clrsbll
+  case Builtin::BI__builtin_clrsb:
+  case Builtin::BI__builtin_clrsbl:
+  case Builtin::BI__builtin_clrsbll: {
+APSInt Val;
+if (!EvaluateInteger(E->getArg(0), Val, Info))
+  return false;
+
+return Success(Val.getBitWidth() - Val.getMinSignedBits(), E);
+  }
 
   case Builtin::BI__builtin_clz:
   case Builtin::BI__builtin_clzl:


Index: test/Sema/constant-builtins-2.c
===
--- test/Sema/constant-builtins-2.c
+++ test/Sema/constant-builtins-2.c
@@ -176,6 +176,19 @@
 char ffs5[__builtin_ffs(1U << (BITSIZE(int) - 1)) == BITSIZE(int) ? 1 : -1];
 char ffs6[__builtin_ffsl(0x10L) == 5 ? 1 : -1];
 char ffs7[__builtin_ffsll(0x100LL) == 9 ? 1 : -1];
+
+char clrsb1[__builtin_clrsb(0) == BITSIZE(int) - 1 ? 1 : -1];
+char clrsb2[__builtin_clrsbl(0L) == BITSIZE(long) - 1 ? 1 : -1];
+char clrsb3[__builtin_clrsbll(0LL) == BITSIZE(long long) - 1 ? 1 : -1];
+char clrsb4[__builtin_clrsb(~0) == BITSIZE(int) - 1 ? 1 : -1];
+char clrsb5[__builtin_clrsbl(~0L) == BITSIZE(long) - 1 ? 1 : -1];
+char clrsb6[__builtin_clrsbll(~0LL) == BITSIZE(long long) - 1 ? 1 : -1];
+char clrsb7[__builtin_clrsb(1) == BITSIZE(int) - 2 ? 1 : -1];
+char clrsb8[__builtin_clrsb(~1) == BITSIZE(int) - 2 ? 1 : -1];
+char clrsb9[__builtin_clrsb(1 << (BITSIZE(int) - 1)) == 0 ? 1 : -1];
+char clrsb10[__builtin_clrsb(~(1 << (BITSIZE(int) - 1))) == 0 ? 1 : -1];
+char clrsb11[__builtin_clrsb(0xf) == BITSIZE(int) - 5 ? 1 : -1];
+char clrsb11[__builtin_clrsb(~0x1f) == BITSIZE(int) - 6 ? 1 : -1];
 #undef BITSIZE
 
 // GCC misc stuff
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -8117,9 +8117,15 @@
   case Builtin::BI__builtin_classify_type:
 return Success((int)EvaluateBuiltinClassifyType(E, Info.getLangOpts()), E);
 
-  // FIXME: BI__builtin_clrsb
-  // FIXME: BI__builtin_clrsbl
-  // FIXME: BI__builtin_clrsbll
+  case Builtin::BI__builtin_clrsb:
+  case Builtin::BI__builtin_clrsbl:
+  case Builtin::BI__builtin_clrsbll: {
+APSInt Val;
+if (!EvaluateInteger(E->getArg(0), Val, Info))
+  return false;
+
+return Success(Val.getBitWidth() - Val.getMinSignedBits(), E);
+  }
 
   case Builtin::BI__builtin_clz:
   case Builtin::BI__builtin_clzl:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44671: [libcxx] Enable static libcxxabi linking on Darwin

2018-08-08 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Were the concerns expressed in https://reviews.llvm.org/D8017 addressed?


Repository:
  rCXX libc++

https://reviews.llvm.org/D44671



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


[PATCH] D45639: [Driver] Support default libc++ library location on Darwin

2018-08-08 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In https://reviews.llvm.org/D45639#1192849, @beanz wrote:

> Adding @jfb since this is his domain now too.


@ldionne is the libc++ expert :-)


Repository:
  rC Clang

https://reviews.llvm.org/D45639



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


[PATCH] D45639: [Driver] Support default libc++ library location on Darwin

2018-08-08 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a subscriber: jfb.
beanz added a comment.

Adding @jfb since this is his domain now too.


Repository:
  rC Clang

https://reviews.llvm.org/D45639



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


[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

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



Comment at: include/clang/AST/ASTContext.h:248
+  /// Mapping from __block VarDecls to their copy initialization expr. The
+  /// boolean flag indicates whether the expression can throw.
+  typedef llvm::DenseMaphttps://reviews.llvm.org/D50152



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


[PATCH] D50168: [Builtins] Implement __builtin_clrsb to be compatible with gcc

2018-08-08 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339282: [Builtins] Implement __builtin_clrsb to be 
compatible with gcc (authored by ctopper, committed by ).
Herald added a subscriber: kristina.

Repository:
  rC Clang

https://reviews.llvm.org/D50168

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtin_clrsb.c


Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -413,6 +413,9 @@
 BUILTIN(__builtin_popcount  , "iUi"  , "nc")
 BUILTIN(__builtin_popcountl , "iULi" , "nc")
 BUILTIN(__builtin_popcountll, "iULLi", "nc")
+BUILTIN(__builtin_clrsb  , "ii"  , "nc")
+BUILTIN(__builtin_clrsbl , "iLi" , "nc")
+BUILTIN(__builtin_clrsbll, "iLLi", "nc")
 
 // FIXME: These type signatures are not correct for targets with int != 32-bits
 // or with ULL != 64-bits.
Index: test/CodeGen/builtin_clrsb.c
===
--- test/CodeGen/builtin_clrsb.c
+++ test/CodeGen/builtin_clrsb.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+int test__builtin_clrsb(int x) {
+// CHECK-LABEL: test__builtin_clrsb
+// CHECK: [[C:%.*]] = icmp slt i32 [[X:%.*]], 0
+// CHECK-NEXT: [[INV:%.*]] = xor i32 [[X]], -1
+// CHECK-NEXT: [[SEL:%.*]] = select i1 [[C]], i32 [[INV]], i32 [[X]]
+// CHECK-NEXT: [[CTLZ:%.*]] = call i32 @llvm.ctlz.i32(i32 [[SEL]], i1 false)
+// CHECK-NEXT: [[SUB:%.*]] = sub i32 [[CTLZ]], 1
+  return __builtin_clrsb(x);
+}
+
+int test__builtin_clrsbll(long long x) {
+// CHECK-LABEL: test__builtin_clrsbll
+// CHECK: [[C:%.*]] = icmp slt i64 [[X:%.*]], 0
+// CHECK-NEXT: [[INV:%.*]] = xor i64 [[X]], -1
+// CHECK-NEXT: [[SEL:%.*]] = select i1 [[C]], i64 [[INV]], i64 [[X]]
+// CHECK-NEXT: [[CTLZ:%.*]] = call i64 @llvm.ctlz.i64(i64 [[SEL]], i1 false)
+// CHECK-NEXT: [[SUB:%.*]] = sub i64 [[CTLZ]], 1
+// CHECK-NEXT: trunc i64 [[SUB]] to i32
+  return __builtin_clrsbll(x);
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -1537,6 +1537,26 @@
 return RValue::get(ComplexVal.second);
   }
 
+  case Builtin::BI__builtin_clrsb:
+  case Builtin::BI__builtin_clrsbl:
+  case Builtin::BI__builtin_clrsbll: {
+// clrsb(x) -> clz(x < 0 ? ~x : x) - 1 or
+Value *ArgValue = EmitScalarExpr(E->getArg(0));
+
+llvm::Type *ArgType = ArgValue->getType();
+Value *F = CGM.getIntrinsic(Intrinsic::ctlz, ArgType);
+
+llvm::Type *ResultType = ConvertType(E->getType());
+Value *Zero = llvm::Constant::getNullValue(ArgType);
+Value *IsNeg = Builder.CreateICmpSLT(ArgValue, Zero, "isneg");
+Value *Inverse = Builder.CreateNot(ArgValue, "not");
+Value *Tmp = Builder.CreateSelect(IsNeg, Inverse, ArgValue);
+Value *Ctlz = Builder.CreateCall(F, {Tmp, Builder.getFalse()});
+Value *Result = Builder.CreateSub(Ctlz, llvm::ConstantInt::get(ArgType, 
1));
+Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true,
+   "cast");
+return RValue::get(Result);
+  }
   case Builtin::BI__builtin_ctzs:
   case Builtin::BI__builtin_ctz:
   case Builtin::BI__builtin_ctzl:


Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -413,6 +413,9 @@
 BUILTIN(__builtin_popcount  , "iUi"  , "nc")
 BUILTIN(__builtin_popcountl , "iULi" , "nc")
 BUILTIN(__builtin_popcountll, "iULLi", "nc")
+BUILTIN(__builtin_clrsb  , "ii"  , "nc")
+BUILTIN(__builtin_clrsbl , "iLi" , "nc")
+BUILTIN(__builtin_clrsbll, "iLLi", "nc")
 
 // FIXME: These type signatures are not correct for targets with int != 32-bits
 // or with ULL != 64-bits.
Index: test/CodeGen/builtin_clrsb.c
===
--- test/CodeGen/builtin_clrsb.c
+++ test/CodeGen/builtin_clrsb.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+int test__builtin_clrsb(int x) {
+// CHECK-LABEL: test__builtin_clrsb
+// CHECK: [[C:%.*]] = icmp slt i32 [[X:%.*]], 0
+// CHECK-NEXT: [[INV:%.*]] = xor i32 [[X]], -1
+// CHECK-NEXT: [[SEL:%.*]] = select i1 [[C]], i32 [[INV]], i32 [[X]]
+// CHECK-NEXT: [[CTLZ:%.*]] = call i32 @llvm.ctlz.i32(i32 [[SEL]], i1 false)
+// CHECK-NEXT: [[SUB:%.*]] = sub i32 [[CTLZ]], 1
+  return __builtin_clrsb(x);
+}
+
+int test__builtin_clrsbll(long long x) {
+// CHECK-LABEL: test__builtin_clrsbll
+// CHECK: [[C:%.*]] = icmp slt i64 [[X:%.*]], 0
+// CHECK-NEXT: [[INV:%.*]] = xor i64 [[X]], -1
+// CHECK-NEXT: [[SEL:%.*]] = select i1 [[C]], i64 [[INV]], i64 [[X]]
+// CHECK-NEXT: [[CTLZ:%.*]] = call i64 @llvm.ctlz.i64(i64 [[SEL]], i1 false)
+// CHECK-NEXT: [[SUB:%.*]] = sub i64 [[CTLZ]], 1
+// CHECK-NEXT: trunc i64 [[SUB]] to i32
+  

r339282 - [Builtins] Implement __builtin_clrsb to be compatible with gcc

2018-08-08 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Aug  8 12:55:52 2018
New Revision: 339282

URL: http://llvm.org/viewvc/llvm-project?rev=339282=rev
Log:
[Builtins] Implement __builtin_clrsb to be compatible with gcc

gcc defines an intrinsic called __builtin_clrsb which counts the number of 
extra sign bits on a number. This is equivalent to counting the number of 
leading zeros on a positive number or the number of leading ones on a negative 
number and subtracting one from the result. Since we can't count leading ones 
we need to invert negative numbers to count zeros.

This patch will cause the builtin to be expanded inline while gcc uses a call 
to a function like clrsbdi2 that is implemented in libgcc. But this is similar 
to what we already do for popcnt. And I don't think compiler-rt supports 
clrsbdi2.

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

Added:
cfe/trunk/test/CodeGen/builtin_clrsb.c   (with props)
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=339282=339281=339282=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Wed Aug  8 12:55:52 2018
@@ -413,6 +413,9 @@ BUILTIN(__builtin_parityll, "iULLi", "nc
 BUILTIN(__builtin_popcount  , "iUi"  , "nc")
 BUILTIN(__builtin_popcountl , "iULi" , "nc")
 BUILTIN(__builtin_popcountll, "iULLi", "nc")
+BUILTIN(__builtin_clrsb  , "ii"  , "nc")
+BUILTIN(__builtin_clrsbl , "iLi" , "nc")
+BUILTIN(__builtin_clrsbll, "iLLi", "nc")
 
 // FIXME: These type signatures are not correct for targets with int != 32-bits
 // or with ULL != 64-bits.

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=339282=339281=339282=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Aug  8 12:55:52 2018
@@ -1537,6 +1537,26 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 return RValue::get(ComplexVal.second);
   }
 
+  case Builtin::BI__builtin_clrsb:
+  case Builtin::BI__builtin_clrsbl:
+  case Builtin::BI__builtin_clrsbll: {
+// clrsb(x) -> clz(x < 0 ? ~x : x) - 1 or
+Value *ArgValue = EmitScalarExpr(E->getArg(0));
+
+llvm::Type *ArgType = ArgValue->getType();
+Value *F = CGM.getIntrinsic(Intrinsic::ctlz, ArgType);
+
+llvm::Type *ResultType = ConvertType(E->getType());
+Value *Zero = llvm::Constant::getNullValue(ArgType);
+Value *IsNeg = Builder.CreateICmpSLT(ArgValue, Zero, "isneg");
+Value *Inverse = Builder.CreateNot(ArgValue, "not");
+Value *Tmp = Builder.CreateSelect(IsNeg, Inverse, ArgValue);
+Value *Ctlz = Builder.CreateCall(F, {Tmp, Builder.getFalse()});
+Value *Result = Builder.CreateSub(Ctlz, llvm::ConstantInt::get(ArgType, 
1));
+Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true,
+   "cast");
+return RValue::get(Result);
+  }
   case Builtin::BI__builtin_ctzs:
   case Builtin::BI__builtin_ctz:
   case Builtin::BI__builtin_ctzl:

Added: cfe/trunk/test/CodeGen/builtin_clrsb.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin_clrsb.c?rev=339282=auto
==
--- cfe/trunk/test/CodeGen/builtin_clrsb.c (added)
+++ cfe/trunk/test/CodeGen/builtin_clrsb.c Wed Aug  8 12:55:52 2018
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+int test__builtin_clrsb(int x) {
+// CHECK-LABEL: test__builtin_clrsb
+// CHECK: [[C:%.*]] = icmp slt i32 [[X:%.*]], 0
+// CHECK-NEXT: [[INV:%.*]] = xor i32 [[X]], -1
+// CHECK-NEXT: [[SEL:%.*]] = select i1 [[C]], i32 [[INV]], i32 [[X]]
+// CHECK-NEXT: [[CTLZ:%.*]] = call i32 @llvm.ctlz.i32(i32 [[SEL]], i1 false)
+// CHECK-NEXT: [[SUB:%.*]] = sub i32 [[CTLZ]], 1
+  return __builtin_clrsb(x);
+}
+
+int test__builtin_clrsbll(long long x) {
+// CHECK-LABEL: test__builtin_clrsbll
+// CHECK: [[C:%.*]] = icmp slt i64 [[X:%.*]], 0
+// CHECK-NEXT: [[INV:%.*]] = xor i64 [[X]], -1
+// CHECK-NEXT: [[SEL:%.*]] = select i1 [[C]], i64 [[INV]], i64 [[X]]
+// CHECK-NEXT: [[CTLZ:%.*]] = call i64 @llvm.ctlz.i64(i64 [[SEL]], i1 false)
+// CHECK-NEXT: [[SUB:%.*]] = sub i64 [[CTLZ]], 1
+// CHECK-NEXT: trunc i64 [[SUB]] to i32
+  return __builtin_clrsbll(x);
+}

Propchange: cfe/trunk/test/CodeGen/builtin_clrsb.c
--
svn:eol-style = native

Propchange: cfe/trunk/test/CodeGen/builtin_clrsb.c
--
svn:keywords = "Author Date Id Rev URL"

Propchange: cfe/trunk/test/CodeGen/builtin_clrsb.c

[PATCH] D50122: Complex Variable defined in InitCapture Crash fix

2018-08-08 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: lib/Sema/SemaTemplateInstantiate.cpp:2916-2918
+  if (const VarDecl *VD = dyn_cast(D))
+if (VD->isInitCapture())
+  return nullptr;

Why are we failing to find the instantiation of the VarDecl in this case? It 
seems to me like we should of picked it up in the `for` loop above. Is it not 
getting added to the LocalInstantiationScope? Or are we looking in the wrong 
LocalInstantiationScope?


Repository:
  rC Clang

https://reviews.llvm.org/D50122



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


[PATCH] D50144: Add Windows support for the GNUstep Objective-C ABI V2.

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



Comment at: lib/CodeGen/CGObjCGNU.cpp:3542
+  allSelectors.push_back(entry.first);
+std::sort(allSelectors.begin(), allSelectors.end());
 

mgrang wrote:
> Please use llvm::sort instead of std::sort. See 
> https://llvm.org/docs/CodingStandards.html#beware-of-non-deterministic-sorting-order-of-equal-elements.
Also, why is the sort necessary?  Should this change be separately committed 
and tested?



Comment at: lib/CodeGen/CGObjCGNU.cpp:915
+return name;
+  }
   /// The GCC ABI superclass message lookup function.  Takes a pointer to a

theraven wrote:
> rjmccall wrote:
> > Can this section-names cleanup also just be in a separate patch?
> This is difficult to extract, because it's mostly needed for the COFF part 
> where we need to modify the section names.  For ELF, it was fine to keep them 
> as separate `const char*`s
I don't mind if the extracted patch seems unmotivated on its own, but I do 
think it should be a separate patch.



Comment at: lib/CodeGen/CGObjCGNU.cpp:2262
 llvm::Constant *CGObjCGNUstep::GetEHType(QualType T) {
+  if (CGM.getContext().getTargetInfo().getTriple().isWindowsMSVCEnvironment())
+return CGM.getCXXABI().getAddrOfRTTIDescriptor(T);

theraven wrote:
> rjmccall wrote:
> > I think this is the third different way that you test for Windows in this 
> > patch. :) Is there a reason why this is just testing for MSVC and the 
> > others are testing for PE/COFF or for Windows generally?
> For the EH logic, we are using DWARF exceptions if we are targeting a Windows 
> environment that uses DWARF EH and SEH-based exceptions if we are targeting a 
> Windows environment that uses MSVC-compatible SEH.
> 
> The section code is specific to PE/COFF, where we don't get to use some of 
> the ELF tricks.
> 
> The blocks code is specific to Windows, because it relates to Windows 
> run-time linking.  Hypothetically, a PE/COFF platform could provide dynamic 
> relocations that would eliminate the need for that check.
> 
> It's possible that some of the PE/COFF vs Windows distinctions are wrong.  
> For example, UEFI images are PE/COFF binaries and if anyone wanted to use 
> blocks in a UEFI firmware image then they may find that they need the Windows 
> code path (but I do not have a good way of testing this, so restricted it to 
> Windows initially).  Similarly, some of the section initialisation code in 
> CGObjCGNU may actually be Windows-only, but it's probably a good starting 
> point for anyone who actually wants to use Objective-C in UEFI firmware 
> (though the final destination for such people is likely to involve padded 
> cells). 
Okay, the exception logic makes sense.  Please make this a common predicate 
instead of repeating it in different places.

My understanding is that the restriction on the use of `dllimport`-ed symbols 
is a general PE restriction: the format itself only supports binds in the 
import address table, and everything else has just to be a rebase.  I mean, of 
course you can imagine a loader that extends PE to support arbitrary binds, but 
you can also imagine a loader that extends PE to support just embedding an ELF 
image.  Firmware probably never uses imported symbols.



Comment at: lib/CodeGen/CGObjCGNU.cpp:3817
+  if (isRethrow && CGF.CGM.getTarget().getTriple().isWindowsMSVCEnvironment()) 
{
+CGF.EmitRuntimeCallOrInvoke(ExceptionReThrowFn).setDoesNotReturn();
+  }

theraven wrote:
> rjmccall wrote:
> > You're sure here that the static information aligns with the dynamic?
> I'm not sure I understand this question.
Your new code path no longer uses `ExceptionAsObject`, which is our static 
notion of the current exception value.  Instead, you call a runtime function 
which presumably relies on a dynamically-stored current exception value.  I'm 
just asking if, in this lexical position, you're definitely rethrowing the 
right exception.



Comment at: lib/CodeGen/CGObjCRuntime.cpp:125
 llvm::Constant *TypeInfo;
+unsigned Flags;
   };

theraven wrote:
> rjmccall wrote:
> > Please add some sort of comment about the meaning and source of these flags.
> These are not well documented anywhere, including in the Clang Microsoft C++ 
> ABI code that I read to see why exceptions weren't working, but I've added a 
> small comment that explains why they exist.  I have no idea where the values 
> come from though.
Just mentioning that they're the same catch flags used in the Microsoft C++ ABI 
is all I'm asking for.  Although maybe there could be an abstraction for that 
instead of passing them around separately?


Repository:
  rC Clang

https://reviews.llvm.org/D50144



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


[PATCH] D50436: Correctly initialise global blocks on Windows.

2018-08-08 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Alright, LGTM, at least until we have that backend support you mentioned.


Repository:
  rC Clang

https://reviews.llvm.org/D50436



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


[PATCH] D50122: Complex Variable defined in InitCapture Crash fix

2018-08-08 Thread Balaji Iyer via Phabricator via cfe-commits
bviyer added a comment.

Ping!


Repository:
  rC Clang

https://reviews.llvm.org/D50122



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


[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-08-08 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Assignment restored in r339281. I'll file a bug to merge to 7.0


Repository:
  rL LLVM

https://reviews.llvm.org/D45619



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


r339281 - [CodeGen][Timers] Enable llvm::TimePassesIsEnabled when -ftime-report is specified

2018-08-08 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Aug  8 12:14:23 2018
New Revision: 339281

URL: http://llvm.org/viewvc/llvm-project?rev=339281=rev
Log:
[CodeGen][Timers] Enable llvm::TimePassesIsEnabled when -ftime-report is 
specified

r330571 added a new FrontendTimesIsEnabled variable and replaced many usages of 
llvm::TimePassesIsEnabled. Including the place that set 
llvm::TimePassesIsEnabled for -ftime-report. The effect of this is that 
-ftime-report now only contains the timers specifically referenced in 
CodeGenAction.cpp and none of the timers in the backend.

This commit adds back the assignment, but otherwise leaves everything else 
unchanged.

Modified:
cfe/trunk/lib/CodeGen/CodeGenAction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=339281=339280=339281=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Wed Aug  8 12:14:23 2018
@@ -127,6 +127,7 @@ namespace clang {
 CodeGenOpts, C, CoverageInfo)),
   LinkModules(std::move(LinkModules)) {
   FrontendTimesIsEnabled = TimePasses;
+  llvm::TimePassesIsEnabled = TimePasses;
 }
 llvm::Module *getModule() const { return Gen->GetModule(); }
 std::unique_ptr takeModule() {


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


[PATCH] D48687: [clangd] Avoid duplicates in findDefinitions response

2018-08-08 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 159768.
simark added a comment.

Formatting.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48687

Files:
  clangd/FindSymbols.cpp
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/XRefs.cpp
  unittests/clangd/TestFS.cpp
  unittests/clangd/TestFS.h
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -312,27 +312,65 @@
 }
 
 TEST(GoToDefinition, RelPathsInCompileCommand) {
+  // The source is in "/clangd-test/src".
+  // We build in "/clangd-test/build".
+
   Annotations SourceAnnotations(R"cpp(
+#include "header_in_preamble.h"
 int [[foo]];
-int baz = f^oo;
+#include "header_not_in_preamble.h"
+int baz = f$p1^oo + bar_pre$p2^amble + bar_not_pre$p3^amble;
+)cpp");
+
+  Annotations HeaderInPreambleAnnotations(R"cpp(
+int [[bar_preamble]];
+)cpp");
+
+  Annotations HeaderNotInPreambleAnnotations(R"cpp(
+int [[bar_not_preamble]];
 )cpp");
 
+  // Make the compilation paths appear as ../src/foo.cpp in the compile
+  // commands.
+  SmallString<32> RelPathPrefix("..");
+  llvm::sys::path::append(RelPathPrefix, "src");
+  std::string BuildDir = testPath("build");
+  MockCompilationDatabase CDB(BuildDir, RelPathPrefix);
+
   IgnoreDiagnostics DiagConsumer;
-  MockCompilationDatabase CDB(/*UseRelPaths=*/true);
   MockFSProvider FS;
   ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
 
-  auto FooCpp = testPath("foo.cpp");
+  // Fill the filesystem.
+  auto FooCpp = testPath("src/foo.cpp");
   FS.Files[FooCpp] = "";
+  auto HeaderInPreambleH = testPath("src/header_in_preamble.h");
+  FS.Files[HeaderInPreambleH] = HeaderInPreambleAnnotations.code();
+  auto HeaderNotInPreambleH = testPath("src/header_not_in_preamble.h");
+  FS.Files[HeaderNotInPreambleH] = HeaderNotInPreambleAnnotations.code();
 
-  Server.addDocument(FooCpp, SourceAnnotations.code());
   runAddDocument(Server, FooCpp, SourceAnnotations.code());
+
+  // Go to a definition in main source file.
   auto Locations =
-  runFindDefinitions(Server, FooCpp, SourceAnnotations.point());
+  runFindDefinitions(Server, FooCpp, SourceAnnotations.point("p1"));
   EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
-
   EXPECT_THAT(*Locations, ElementsAre(Location{URIForFile{FooCpp},
SourceAnnotations.range()}));
+
+  // Go to a definition in header_in_preamble.h.
+  Locations = runFindDefinitions(Server, FooCpp, SourceAnnotations.point("p2"));
+  EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+  EXPECT_THAT(*Locations,
+  ElementsAre(Location{URIForFile{HeaderInPreambleH},
+   HeaderInPreambleAnnotations.range()}));
+
+  // Go to a definition in header_not_in_preamble.h.
+  Locations = runFindDefinitions(Server, FooCpp, SourceAnnotations.point("p3"));
+  EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+  EXPECT_THAT(*Locations,
+  ElementsAre(Location{URIForFile{HeaderNotInPreambleH},
+   HeaderNotInPreambleAnnotations.range()}));
 }
 
 TEST(Hover, All) {
Index: unittests/clangd/TestFS.h
===
--- unittests/clangd/TestFS.h
+++ unittests/clangd/TestFS.h
@@ -40,15 +40,22 @@
 // A Compilation database that returns a fixed set of compile flags.
 class MockCompilationDatabase : public GlobalCompilationDatabase {
 public:
-  /// When \p UseRelPaths is true, uses relative paths in compile commands.
-  /// When \p UseRelPaths is false, uses absoulte paths.
-  MockCompilationDatabase(bool UseRelPaths = false);
+  /// If \p Directory is not null, use that as the Directory field of the
+  /// CompileCommand.
+  ///
+  /// If \p RelPathPrefix is not null, use that as a prefix in front of the
+  /// source file name, instead of using an absolute path.
+  MockCompilationDatabase(StringRef Directory = StringRef(),
+  StringRef RelPathPrefix = StringRef());
 
   llvm::Optional
   getCompileCommand(PathRef File) const override;
 
   std::vector ExtraClangFlags;
-  const bool UseRelPaths;
+
+private:
+  StringRef Directory;
+  StringRef RelPathPrefix;
 };
 
 // Returns an absolute (fake) test directory for this OS.
Index: unittests/clangd/TestFS.cpp
===
--- unittests/clangd/TestFS.cpp
+++ unittests/clangd/TestFS.cpp
@@ -32,22 +32,36 @@
   return MemFS;
 }
 
-MockCompilationDatabase::MockCompilationDatabase(bool UseRelPaths)
-: ExtraClangFlags({"-ffreestanding"}), UseRelPaths(UseRelPaths) {
+MockCompilationDatabase::MockCompilationDatabase(StringRef Directory,
+ StringRef RelPathPrefix)
+: ExtraClangFlags({"-ffreestanding"}), 

[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-08-08 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Ok I'll add that back.

I'm unclear why the we would want to assign clang's FrontendTimesIsEnabled from 
inside CodeGenAction. If I'm understanding the intentions here, the goal was to 
add more timing infrastructure to clang. But if the enabling is tied to 
CodeGenAction, then doesn't that mean any new clang timers wouldn't work under 
-fsyntax-only?


Repository:
  rL LLVM

https://reviews.llvm.org/D45619



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


[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-08-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Oh, oops, I should have spotted that.  No, the point of this was to separate 
the timing infrastructure, not to change the behavior of -ftime-report.

Should be a one-line change to add "llvm::TimePassesIsEnabled = TimePasses" 
back to BackendConsumer::BackendConsumer.  (Maybe we can add flags to control 
them separately as a followup.)


Repository:
  rL LLVM

https://reviews.llvm.org/D45619



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


[PATCH] D49986: [ADT] ImmutableList::add parameters are switched

2018-08-08 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a subscriber: dblaikie.
Szelethus added a comment.

In https://reviews.llvm.org/D49985#1181568, @NoQ wrote:

> In https://reviews.llvm.org/D49985#1181564, @dblaikie wrote:
>
> > It looks like concat orders the arguments in the same way that the output 
> > would be (so concat(X, list) produces [X, list]) - so preserving that 
> > argument order seems like it improves/retains readability compared to 
> > switching them around so 'concat(list, X)' produces '[X, list]'.
>
>
> Yeah, i guess that might have been the motivation behind such inconsistency. 
> I'll be fine with fixing the order for other data structures.


@NoQ Have your views changed about this patch? Shall I abandon it?


Repository:
  rC Clang

https://reviews.llvm.org/D49986



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


[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-08-08 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Correct me if I'm wrong, but after this change llvm no longer enables the 
timing of individual passes when -ftime-report is passed? Was that intentional?


Repository:
  rL LLVM

https://reviews.llvm.org/D45619



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


[PATCH] D50415: [clangd] extend the publishDiagnostics response to send back fixits to the client directly as well (if requested)

2018-08-08 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 159760.
arphaman added a comment.

- Client now can request the fixes using a 
'clientCapabilities/textDocument/publishDiagnostics' extension.
- Use 'Fixes' instead of 'Fixits' in code.


https://reviews.llvm.org/D50415

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/Diagnostics.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/fuzzer/ClangdFuzzer.cpp
  clangd/tool/ClangdMain.cpp
  test/clangd/fixits-embed-in-diagnostic.test

Index: test/clangd/fixits-embed-in-diagnostic.test
===
--- /dev/null
+++ test/clangd/fixits-embed-in-diagnostic.test
@@ -0,0 +1,66 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument":{"publishDiagnostics":{"clangdFixSupport":true}}},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"struct Point {}; union Point p;"}}}
+#  CHECK:"method": "textDocument/publishDiagnostics",
+# CHECK-NEXT:"params": {
+# CHECK-NEXT: "diagnostics": [
+# CHECK-NEXT:  {
+# CHECK-NEXT:"clangd.fixes": [
+# CHECK-NEXT:  {
+# CHECK-NEXT:"edit": {
+# CHECK-NEXT:  "changes": {
+# CHECK-NEXT:"file://{{.*}}/foo.c": [
+# CHECK-NEXT:  {
+# CHECK-NEXT:"newText": "struct",
+# CHECK-NEXT:"range": {
+# CHECK-NEXT:  "end": {
+# CHECK-NEXT:"character": 22,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "start": {
+# CHECK-NEXT:"character": 17,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  }
+# CHECK-NEXT:}
+# CHECK-NEXT:  }
+# CHECK-NEXT:]
+# CHECK-NEXT:  }
+# CHECK-NEXT:},
+# CHECK-NEXT:"title": "change 'union' to 'struct'"
+# CHECK-NEXT:  }
+# CHECK-NEXT:],
+# CHECK-NEXT:"message": "Use of 'Point' with tag type that does not match previous declaration\n\nfoo.c:1:8: note: previous use is here",
+# CHECK-NEXT:"range": {
+# CHECK-NEXT:  "end": {
+# CHECK-NEXT:"character": 22,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "start": {
+# CHECK-NEXT:"character": 17,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  }
+# CHECK-NEXT:},
+# CHECK-NEXT:"severity": 1
+# CHECK-NEXT:  },
+# CHECK-NEXT:  {
+# CHECK-NEXT:"message": "Previous use is here\n\nfoo.c:1:18: error: use of 'Point' with tag type that does not match previous declaration",
+# CHECK-NEXT:"range": {
+# CHECK-NEXT:  "end": {
+# CHECK-NEXT:"character": 12,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "start": {
+# CHECK-NEXT:"character": 7,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  }
+# CHECK-NEXT:},
+# CHECK-NEXT:"severity": 3
+# CHECK-NEXT:  }
+# CHECK-NEXT:],
+# CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
+# CHECK-NEXT:  }
+---
+{"jsonrpc":"2.0","id":4,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -300,9 +300,11 @@
 CCOpts.IncludeIndicator.NoInsert.clear();
   }
 
+  ClangdDiagnosticOptions DiagOpts;
+
   // Initialize and run ClangdLSPServer.
   ClangdLSPServer LSPServer(
-  Out, CCOpts, CompileCommandsDirPath,
+  Out, CCOpts, DiagOpts, CompileCommandsDirPath,
   /*ShouldUseInMemoryCDB=*/CompileArgsFrom == LSPCompileArgs, Opts);
   constexpr int NoShutdownRequestErrorCode = 1;
   llvm::set_thread_name("clangd.main");
Index: clangd/fuzzer/ClangdFuzzer.cpp
===
--- clangd/fuzzer/ClangdFuzzer.cpp
+++ clangd/fuzzer/ClangdFuzzer.cpp
@@ -27,11 +27,12 @@
 clang::clangd::Logger::Error, nullptr);
   clang::clangd::CodeCompleteOptions CCOpts;
   CCOpts.EnableSnippets = false;
+  ClangdDiagnosticOptions DiagOpts;
   clang::clangd::ClangdServer::Options Opts;
 
   // Initialize and run ClangdLSPServer.
-  clang::clangd::ClangdLSPServer LSPServer(Out, CCOpts, llvm::None, false,
-   Opts);
+  clang::clangd::ClangdLSPServer LSPServer(Out, CCOpts, DiagOpts, llvm::None,
+   false, Opts);
   // fmemopen isn't portable, but I think we only run the fuzzer on Linux.
   

[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

2018-08-08 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 159762.
ahatanak added a comment.

Change the value type of BlockVarCopyInits to PointerIntPair. 
The boolean flag indicates whether the copy expression can throw. 
Serialize/deserialize the copy expression and the boolean flag and add a 
regression test to test/PCH.


Repository:
  rC Clang

https://reviews.llvm.org/D50152

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBlocks.h
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGNonTrivialStruct.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaDecl.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/blocks-1.c
  test/CodeGen/blocks.c
  test/CodeGen/sanitize-thread-no-checking-at-run-time.m
  test/CodeGenCXX/block-byref-cxx-objc.cpp
  test/CodeGenCXX/blocks.cpp
  test/CodeGenCXX/cxx-block-objects.cpp
  test/CodeGenObjC/arc-blocks.m
  test/CodeGenObjC/debug-info-block-helper.m
  test/CodeGenObjC/debug-info-blocks.m
  test/CodeGenObjC/mrc-weak.m
  test/CodeGenObjC/strong-in-c-struct.m
  test/CodeGenObjCXX/arc-blocks.mm
  test/CodeGenObjCXX/lambda-to-block.mm
  test/CodeGenObjCXX/mrc-weak.mm
  test/PCH/block-helpers.cpp
  test/PCH/block-helpers.h

Index: test/PCH/block-helpers.h
===
--- /dev/null
+++ test/PCH/block-helpers.h
@@ -0,0 +1,12 @@
+struct S0 {
+  S0();
+  S0(const S0 &) noexcept(false);
+  int a;
+};
+
+struct S {
+  void m() {
+__block S0 x, y;
+^{ (void)x; (void)y; };
+  }
+};
Index: test/PCH/block-helpers.cpp
===
--- /dev/null
+++ test/PCH/block-helpers.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -x c++-header -triple x86_64-apple-darwin11 -emit-pch -fblocks -fexceptions -o %t %S/block-helpers.h
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -include-pch %t -emit-llvm -fblocks -fexceptions -o - %s | FileCheck %s
+
+// The second call to block_object_assign should be an invoke.
+
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_e8_32bc40bc(
+// CHECK: call void @_Block_object_assign(
+// CHECK: invoke void @_Block_object_assign(
+// CHECK: call void @_Block_object_dispose(
+
+// CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block_e8_32b40b(
+void test() {
+  S s;
+  s.m();
+}
Index: test/CodeGenObjCXX/mrc-weak.mm
===
--- test/CodeGenObjCXX/mrc-weak.mm
+++ test/CodeGenObjCXX/mrc-weak.mm
@@ -119,10 +119,10 @@
 // CHECK:   call void @use_block
 // CHECK:   call void @objc_destroyWeak
 
-// CHECK-LABEL: define internal void @__copy_helper_block
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block
 // CHECK:   @objc_copyWeak
 
-// CHECK-LABEL: define internal void @__destroy_helper_block
+// CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block
 // CHECK:   @objc_destroyWeak
 
 void test8(void) {
@@ -142,8 +142,8 @@
 // CHECK:   call void @objc_destroyWeak
 
 // CHECK-LABEL: define void @_Z14test9_baselinev()
-// CHECK:   define internal void @__copy_helper
-// CHECK:   define internal void @__destroy_helper
+// CHECK:   define linkonce_odr hidden void @__copy_helper
+// CHECK:   define linkonce_odr hidden void @__destroy_helper
 void test9_baseline(void) {
   Foo *p = get_object();
   use_block(^{ [p run]; });
Index: test/CodeGenObjCXX/lambda-to-block.mm
===
--- test/CodeGenObjCXX/lambda-to-block.mm
+++ test/CodeGenObjCXX/lambda-to-block.mm
@@ -12,7 +12,7 @@
 void hasLambda(Copyable x) {
   takesBlock([x] () { });
 }
-// CHECK-LABEL: define internal void @__copy_helper_block_
+// CHECK-LABEL: define internal void @"__copy_helper_block_
 // CHECK: call void @"_ZZ9hasLambda8CopyableEN3$_0C1ERKS0_"
 // CHECK-LABEL: define internal void @"_ZZ9hasLambda8CopyableEN3$_0C2ERKS0_"
 // CHECK: call void @_ZN8CopyableC1ERKS_
Index: test/CodeGenObjCXX/arc-blocks.mm
===
--- test/CodeGenObjCXX/arc-blocks.mm
+++ test/CodeGenObjCXX/arc-blocks.mm
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -o - %s | FileCheck -check-prefix CHECK %s
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -O1 -o - %s | FileCheck -check-prefix CHECK-O1 %s
+// RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck -check-prefix CHECK-NOEXCP %s
 
 // CHECK: [[A:.*]] = type { i64, [10 x i8*] }
 // CHECK: %[[STRUCT_TEST1_S0:.*]] = type { i32 }
+// CHECK: %[[STRUCT_TRIVIAL_INTERNAL:.*]] = type { i32 }
 

[PATCH] D50467: [SEMA] add more -Wfloat-conversion to compound assigment analysis

2018-08-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:10413-10416
+  // If source is floating point but target is not.
+  if (!ResultBT->isFloatingPoint())
+return DiagnoseFloatingImpCast(S, E, E->getRHS()->getType(),
+   E->getExprLoc());

This is essentially the only new code.  AnalyzeCompoundAssignment was moved in 
order to be able to call DiagnoseFloatingImpCast (it's defined above). The rest 
is a small refactoring of the conditionals.


Repository:
  rC Clang

https://reviews.llvm.org/D50467



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


[PATCH] D48687: [clangd] Avoid duplicates in findDefinitions response

2018-08-08 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 159764.
simark added a comment.
Herald added a subscriber: arphaman.

New version.  I tried to share the code between this and SymbolCollector, but
didn't find a good clean way.  Do you have concrete suggestions on how to do
this?  Otherwise, would it be acceptable to merge it as-is?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48687

Files:
  clangd/FindSymbols.cpp
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/XRefs.cpp
  unittests/clangd/TestFS.cpp
  unittests/clangd/TestFS.h
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -312,27 +312,65 @@
 }
 
 TEST(GoToDefinition, RelPathsInCompileCommand) {
+  // The source is in "/clangd-test/src".
+  // We build in "/clangd-test/build".
+
   Annotations SourceAnnotations(R"cpp(
+#include "header_in_preamble.h"
 int [[foo]];
-int baz = f^oo;
+#include "header_not_in_preamble.h"
+int baz = f$p1^oo + bar_pre$p2^amble + bar_not_pre$p3^amble;
+)cpp");
+
+  Annotations HeaderInPreambleAnnotations(R"cpp(
+int [[bar_preamble]];
+)cpp");
+
+  Annotations HeaderNotInPreambleAnnotations(R"cpp(
+int [[bar_not_preamble]];
 )cpp");
 
+  // Make the compilation paths appear as ../src/foo.cpp in the compile
+  // commands.
+  SmallString<32> RelPathPrefix("..");
+  llvm::sys::path::append(RelPathPrefix, "src");
+  std::string BuildDir = testPath("build");
+  MockCompilationDatabase CDB(BuildDir, RelPathPrefix);
+
   IgnoreDiagnostics DiagConsumer;
-  MockCompilationDatabase CDB(/*UseRelPaths=*/true);
   MockFSProvider FS;
   ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
 
-  auto FooCpp = testPath("foo.cpp");
+  // Fill the filesystem.
+  auto FooCpp = testPath("src/foo.cpp");
   FS.Files[FooCpp] = "";
+  auto HeaderInPreambleH = testPath("src/header_in_preamble.h");
+  FS.Files[HeaderInPreambleH] = HeaderInPreambleAnnotations.code();
+  auto HeaderNotInPreambleH = testPath("src/header_not_in_preamble.h");
+  FS.Files[HeaderNotInPreambleH] = HeaderNotInPreambleAnnotations.code();
 
-  Server.addDocument(FooCpp, SourceAnnotations.code());
   runAddDocument(Server, FooCpp, SourceAnnotations.code());
+
+  // Go to a definition in main source file.
   auto Locations =
-  runFindDefinitions(Server, FooCpp, SourceAnnotations.point());
+  runFindDefinitions(Server, FooCpp, SourceAnnotations.point("p1"));
   EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
-
   EXPECT_THAT(*Locations, ElementsAre(Location{URIForFile{FooCpp},
SourceAnnotations.range()}));
+
+  // Go to a definition in header_in_preamble.h.
+  Locations = runFindDefinitions(Server, FooCpp, SourceAnnotations.point("p2"));
+  EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+  EXPECT_THAT(*Locations,
+  ElementsAre(Location{URIForFile{HeaderInPreambleH},
+   HeaderInPreambleAnnotations.range()}));
+
+  // Go to a definition in header_not_in_preamble.h.
+  Locations = runFindDefinitions(Server, FooCpp, SourceAnnotations.point("p3"));
+  EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+  EXPECT_THAT(*Locations,
+  ElementsAre(Location{URIForFile{HeaderNotInPreambleH},
+   HeaderNotInPreambleAnnotations.range()}));
 }
 
 TEST(Hover, All) {
Index: unittests/clangd/TestFS.h
===
--- unittests/clangd/TestFS.h
+++ unittests/clangd/TestFS.h
@@ -40,15 +40,22 @@
 // A Compilation database that returns a fixed set of compile flags.
 class MockCompilationDatabase : public GlobalCompilationDatabase {
 public:
-  /// When \p UseRelPaths is true, uses relative paths in compile commands.
-  /// When \p UseRelPaths is false, uses absoulte paths.
-  MockCompilationDatabase(bool UseRelPaths = false);
+  /// If \p Directory is not null, use that as the Directory field of the
+  /// CompileCommand.
+  ///
+  /// If \p RelPathPrefix is not null, use that as a prefix in front of the
+  /// source file name, instead of using an absolute path.
+  MockCompilationDatabase(StringRef Directory = StringRef(),
+  StringRef RelPathPrefix = StringRef());
 
   llvm::Optional
   getCompileCommand(PathRef File) const override;
 
   std::vector ExtraClangFlags;
-  const bool UseRelPaths;
+
+private:
+  StringRef Directory;
+  StringRef RelPathPrefix;
 };
 
 // Returns an absolute (fake) test directory for this OS.
Index: unittests/clangd/TestFS.cpp
===
--- unittests/clangd/TestFS.cpp
+++ unittests/clangd/TestFS.cpp
@@ -32,22 +32,36 @@
   return MemFS;
 }
 
-MockCompilationDatabase::MockCompilationDatabase(bool UseRelPaths)
-: 

[PATCH] D50467: [SEMA] add more -Wfloat-conversion to compound assigment analysis

2018-08-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 159763.
nickdesaulniers added a comment.

- rework ordering of conditionals to reduce indentation


Repository:
  rC Clang

https://reviews.llvm.org/D50467

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

Index: test/SemaCXX/warn-float-conversion.cpp
===
--- test/SemaCXX/warn-float-conversion.cpp
+++ test/SemaCXX/warn-float-conversion.cpp
@@ -41,6 +41,22 @@
   l = ld;  //expected-warning{{conversion}}
 }
 
+void CompoundAssignment() {
+  int x = 3;
+
+  x += 1.234;  //expected-warning{{conversion}}
+  x -= -0.0;  //expected-warning{{conversion}}
+  x *= 1.1f;  //expected-warning{{conversion}}
+  x /= -2.2f;  //expected-warning{{conversion}}
+
+  int y = x += 1.4f;  //expected-warning{{conversion}}
+
+  float z = 1.1f;
+  double w = -2.2;
+
+  y += z + w;  //expected-warning{{conversion}}
+}
+
 void Test() {
   int a1 = 10.0/2.0;  //expected-warning{{conversion}}
   int a2 = 1.0/2.0;  //expected-warning{{conversion}}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -10292,33 +10292,6 @@
   DiagnoseImpCast(S, E, E->getType(), T, CContext, diag, pruneControlFlow);
 }
 
-/// Analyze the given compound assignment for the possible losing of
-/// floating-point precision.
-static void AnalyzeCompoundAssignment(Sema , BinaryOperator *E) {
-  assert(isa(E) &&
- "Must be compound assignment operation");
-  // Recurse on the LHS and RHS in here
-  AnalyzeImplicitConversions(S, E->getLHS(), E->getOperatorLoc());
-  AnalyzeImplicitConversions(S, E->getRHS(), E->getOperatorLoc());
-
-  // Now check the outermost expression
-  const auto *ResultBT = E->getLHS()->getType()->getAs();
-  const auto *RBT = cast(E)
-->getComputationResultType()
-->getAs();
-
-  // If both source and target are floating points.
-  if (ResultBT && ResultBT->isFloatingPoint() && RBT && RBT->isFloatingPoint())
-// Builtin FP kinds are ordered by increasing FP rank.
-if (ResultBT->getKind() < RBT->getKind())
-  // We don't want to warn for system macro.
-  if (!S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
-// warn about dropping FP rank.
-DiagnoseImpCast(S, E->getRHS(), E->getLHS()->getType(),
-E->getOperatorLoc(),
-diag::warn_impcast_float_result_precision);
-}
-
 /// Diagnose an implicit cast from a floating point value to an integer value.
 static void DiagnoseFloatingImpCast(Sema , Expr *E, QualType T,
 SourceLocation CContext) {
@@ -10421,6 +10394,37 @@
   }
 }
 
+/// Analyze the given compound assignment for the possible losing of
+/// floating-point precision.
+static void AnalyzeCompoundAssignment(Sema , BinaryOperator *E) {
+  assert(isa(E) &&
+ "Must be compound assignment operation");
+  // Recurse on the LHS and RHS in here
+  AnalyzeImplicitConversions(S, E->getLHS(), E->getOperatorLoc());
+  AnalyzeImplicitConversions(S, E->getRHS(), E->getOperatorLoc());
+
+  // Now check the outermost expression
+  const auto *ResultBT = E->getLHS()->getType()->getAs();
+  const auto *RBT = cast(E)
+->getComputationResultType()
+->getAs();
+  if (!ResultBT || !(RBT && RBT->isFloatingPoint())) return;
+
+  // If source is floating point but target is not.
+  if (!ResultBT->isFloatingPoint())
+return DiagnoseFloatingImpCast(S, E, E->getRHS()->getType(),
+   E->getExprLoc());
+
+  // If both source and target are floating points.
+  // Builtin FP kinds are ordered by increasing FP rank.
+  if (ResultBT->getKind() < RBT->getKind() &&
+  // We don't want to warn for system macro.
+  S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
+// warn about dropping FP rank.
+DiagnoseImpCast(S, E->getRHS(), E->getLHS()->getType(), E->getOperatorLoc(),
+diag::warn_impcast_float_result_precision);
+}
+
 static std::string PrettyPrintInRange(const llvm::APSInt ,
   IntRange Range) {
   if (!Range.Width) return "0";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50168: [Builtins] Implement __builtin_clrsb to be compatible with gcc

2018-08-08 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D50168



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


[PATCH] D41910: [Concepts] Constrained partial specializations and function overloads.

2018-08-08 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 159759.
saar.raz added a comment.

- Moved constraint checks to the end of FinishTemplateArgumentDeduction


Repository:
  rC Clang

https://reviews.llvm.org/D41910

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ASTContext.cpp
  lib/AST/DeclTemplate.cpp
  lib/Sema/SemaConcept.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/func-template-decl.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.normal/p1.cpp
  
test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/function-templates.cpp
  
test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp

Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+template requires sizeof(T) >= 4
+bool a = false; // expected-note{{template is declared here}}
+
+template requires sizeof(T) >= 4 && sizeof(T) <= 10
+bool a = true; // expected-error{{variable template partial specialization is not more specialized than the primary template}}
+
+template
+concept C1 = sizeof(T) >= 4;
+
+template requires C1
+bool b = false;
+
+template requires C1 && sizeof(T) <= 10
+bool b = true;
+
+template
+concept C2 = sizeof(T) > 1 && sizeof(T) <= 8;
+
+template
+bool c = false;
+
+template requires C1
+bool c = true;
+
+template
+bool d = false;
+
+template
+bool d = true; // expected-error{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}}
+
+template requires C1
+bool e = false;
+
+template
+bool e = true; // expected-error{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}}
+
+template
+constexpr int f = 1;
+
+template requires C1 && C2
+constexpr int f = 2;
+
+template requires C1 || C2
+constexpr int f = 3;
+
+static_assert(f == 2);
+static_assert(f == 3);
+static_assert(f == 1);
+
+
+
Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/function-templates.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/function-templates.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+template requires sizeof(T) >= 4
+bool a() { return false; } // expected-note {{candidate function [with T = unsigned int]}}
+
+template requires sizeof(T) >= 4 && sizeof(T) <= 10
+bool a() { return true; } // expected-note {{candidate function [with T = unsigned int]}}
+
+bool av = a(); // expected-error {{call to 'a' is ambiguous}}
+
+template
+concept C1 = sizeof(T) >= 4;
+
+template requires C1
+constexpr bool b() { return false; }
+
+template requires C1 && sizeof(T) <= 10
+constexpr bool b() { return true; }
+
+static_assert(b());
+static_assert(!b());
+
+template
+concept C2 = sizeof(T) > 1 && sizeof(T) <= 8;
+
+template
+bool c() { return false; }
+
+template requires C1
+bool c() { return true; }
+
+template requires C1
+constexpr bool d() { return false; }
+
+template
+constexpr bool d() { return true; }
+
+static_assert(!d());
+
+template
+constexpr int e() { return 1; }
+
+template requires C1 && C2
+constexpr int e() { return 2; }
+
+template requires C1 || C2
+constexpr int e() { return 3; }
+
+static_assert(e() == 2);
+static_assert(e() == 3);
+static_assert(e() == 1);
+
+
+
Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+template requires sizeof(T) >= 4
+class A{}; // expected-note{{template is declared here}}
+
+template requires sizeof(T) >= 4 && sizeof(T) <= 10
+class A{}; // expected-error{{class template partial specialization is not more specialized than the primary template}}
+
+template
+concept C1 = sizeof(T) >= 4;
+
+template requires C1
+class B{};
+
+template requires C1 && sizeof(T) <= 10
+class B{};
+
+template
+concept C2 = sizeof(T) > 1 && sizeof(T) <= 8;
+
+template
+class C{};
+
+template requires C1
+class C{};
+
+template
+class D{}; // 

[PATCH] D40526: [WebAssembly] Change size_t to `unsigned long`

2018-08-08 Thread Alon Zakai via Phabricator via cfe-commits
azakai added subscribers: sunfish, jgravelle-google.
azakai added a comment.

This has also shown up in a game engine middleware codebase, so it may be a
broader issue - people seem to assume size_t is one of the int*_t types.


Repository:
  rC Clang

https://reviews.llvm.org/D40526



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


[PATCH] D50467: [SEMA] add more -Wfloat-conversion to compound assigment analysis

2018-08-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
Herald added a subscriber: cfe-commits.

Fixes Bug: https://bugs.llvm.org/show_bug.cgi?id=27061


Repository:
  rC Clang

https://reviews.llvm.org/D50467

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

Index: test/SemaCXX/warn-float-conversion.cpp
===
--- test/SemaCXX/warn-float-conversion.cpp
+++ test/SemaCXX/warn-float-conversion.cpp
@@ -41,6 +41,22 @@
   l = ld;  //expected-warning{{conversion}}
 }
 
+void CompoundAssignment() {
+  int x = 3;
+
+  x += 1.234;  //expected-warning{{conversion}}
+  x -= -0.0;  //expected-warning{{conversion}}
+  x *= 1.1f;  //expected-warning{{conversion}}
+  x /= -2.2f;  //expected-warning{{conversion}}
+
+  int y = x += 1.4f;  //expected-warning{{conversion}}
+
+  float z = 1.1f;
+  double w = -2.2;
+
+  y += z + w;  //expected-warning{{conversion}}
+}
+
 void Test() {
   int a1 = 10.0/2.0;  //expected-warning{{conversion}}
   int a2 = 1.0/2.0;  //expected-warning{{conversion}}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -10292,33 +10292,6 @@
   DiagnoseImpCast(S, E, E->getType(), T, CContext, diag, pruneControlFlow);
 }
 
-/// Analyze the given compound assignment for the possible losing of
-/// floating-point precision.
-static void AnalyzeCompoundAssignment(Sema , BinaryOperator *E) {
-  assert(isa(E) &&
- "Must be compound assignment operation");
-  // Recurse on the LHS and RHS in here
-  AnalyzeImplicitConversions(S, E->getLHS(), E->getOperatorLoc());
-  AnalyzeImplicitConversions(S, E->getRHS(), E->getOperatorLoc());
-
-  // Now check the outermost expression
-  const auto *ResultBT = E->getLHS()->getType()->getAs();
-  const auto *RBT = cast(E)
-->getComputationResultType()
-->getAs();
-
-  // If both source and target are floating points.
-  if (ResultBT && ResultBT->isFloatingPoint() && RBT && RBT->isFloatingPoint())
-// Builtin FP kinds are ordered by increasing FP rank.
-if (ResultBT->getKind() < RBT->getKind())
-  // We don't want to warn for system macro.
-  if (!S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
-// warn about dropping FP rank.
-DiagnoseImpCast(S, E->getRHS(), E->getLHS()->getType(),
-E->getOperatorLoc(),
-diag::warn_impcast_float_result_precision);
-}
-
 /// Diagnose an implicit cast from a floating point value to an integer value.
 static void DiagnoseFloatingImpCast(Sema , Expr *E, QualType T,
 SourceLocation CContext) {
@@ -10421,6 +10394,38 @@
   }
 }
 
+/// Analyze the given compound assignment for the possible losing of
+/// floating-point precision.
+static void AnalyzeCompoundAssignment(Sema , BinaryOperator *E) {
+  assert(isa(E) &&
+ "Must be compound assignment operation");
+  // Recurse on the LHS and RHS in here
+  AnalyzeImplicitConversions(S, E->getLHS(), E->getOperatorLoc());
+  AnalyzeImplicitConversions(S, E->getRHS(), E->getOperatorLoc());
+
+  // Now check the outermost expression
+  const auto *ResultBT = E->getLHS()->getType()->getAs();
+  const auto *RBT = cast(E)
+->getComputationResultType()
+->getAs();
+  if (!ResultBT || !(RBT && RBT->isFloatingPoint())) return;
+
+  // If both source and target are floating points.
+  if (ResultBT->isFloatingPoint()) {
+// Builtin FP kinds are ordered by increasing FP rank.
+if(ResultBT->getKind() < RBT->getKind() &&
+   // We don't want to warn for system macro.
+   S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
+  // warn about dropping FP rank.
+  DiagnoseImpCast(S, E->getRHS(), E->getLHS()->getType(),
+  E->getOperatorLoc(),
+  diag::warn_impcast_float_result_precision);
+
+  } else
+// If source is floating point but target is not.
+DiagnoseFloatingImpCast(S, E, E->getRHS()->getType(), E->getExprLoc());
+}
+
 static std::string PrettyPrintInRange(const llvm::APSInt ,
   IntRange Range) {
   if (!Range.Width) return "0";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40526: [WebAssembly] Change size_t to `unsigned long`

2018-08-08 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

In https://reviews.llvm.org/D40526#1192688, @sunfish wrote:

> Is this related to the issue reported in the thread here 
> ?


Ah yes, I'll follow up there.


Repository:
  rC Clang

https://reviews.llvm.org/D40526



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


[PATCH] D50376: AMDGPU: Fix enabling denormals by default on pre-VI targets

2018-08-08 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r339278


https://reviews.llvm.org/D50376



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


r339278 - AMDGPU: Fix enabling denormals by default on pre-VI targets

2018-08-08 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Wed Aug  8 10:48:37 2018
New Revision: 339278

URL: http://llvm.org/viewvc/llvm-project?rev=339278=rev
Log:
AMDGPU: Fix enabling denormals by default on pre-VI targets

Fast FMAF is not a sufficient condition to enable denormals.
Before VI, enabling denormals caused F32 instructions to
run at F64 speeds.

Modified:
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/lib/Basic/Targets/AMDGPU.h
cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl
cfe/trunk/test/CodeGenOpenCL/denorms-are-zero.cl

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=339278=339277=339278=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Wed Aug  8 10:48:37 2018
@@ -210,7 +210,8 @@ void AMDGPUTargetInfo::adjustTargetOptio
   }
   if (!hasFP32Denormals)
 TargetOpts.Features.push_back(
-(Twine(CGOptsGPU.HasFastFMAF && !CGOpts.FlushDenorm
+(Twine(CGOptsGPU.HasFastFMAF && CGOptsGPU.HasFullRateF32Denorms &&
+   !CGOpts.FlushDenorm
? '+'
: '-') +
  Twine("fp32-denormals"))

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.h?rev=339278=339277=339278=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.h (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.h Wed Aug  8 10:48:37 2018
@@ -94,77 +94,78 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTarg
 bool HasLDEXPF;
 bool HasFP64;
 bool HasFastFMA;
+bool HasFullRateF32Denorms;
   };
 
   static constexpr GPUInfo InvalidGPU =
-{{""}, {""}, GK_NONE, false, false, false, false, false};
+{{""}, {""}, GK_NONE, false, false, false, false, false, false};
   static constexpr GPUInfo R600GPUs[26] = {
-  // Name CanonicalKindHasHasHasHasHas
-  //  Name FMAF   Fast   LDEXPF FP64   Fast
-  //  FMAF FMA
-{{"r600"},{"r600"},GK_R600,false, false, false, false, false},
-{{"rv630"},   {"r600"},GK_R600,false, false, false, false, false},
-{{"rv635"},   {"r600"},GK_R600,false, false, false, false, false},
-{{"r630"},{"r630"},GK_R630,false, false, false, false, false},
-{{"rs780"},   {"rs880"},   GK_RS880,   false, false, false, false, false},
-{{"rs880"},   {"rs880"},   GK_RS880,   false, false, false, false, false},
-{{"rv610"},   {"rs880"},   GK_RS880,   false, false, false, false, false},
-{{"rv620"},   {"rs880"},   GK_RS880,   false, false, false, false, false},
-{{"rv670"},   {"rv670"},   GK_RV670,   false, false, false, false, false},
-{{"rv710"},   {"rv710"},   GK_RV710,   false, false, false, false, false},
-{{"rv730"},   {"rv730"},   GK_RV730,   false, false, false, false, false},
-{{"rv740"},   {"rv770"},   GK_RV770,   false, false, false, false, false},
-{{"rv770"},   {"rv770"},   GK_RV770,   false, false, false, false, false},
-{{"cedar"},   {"cedar"},   GK_CEDAR,   false, false, false, false, false},
-{{"palm"},{"cedar"},   GK_CEDAR,   false, false, false, false, false},
-{{"cypress"}, {"cypress"}, GK_CYPRESS, true,  false, false, false, false},
-{{"hemlock"}, {"cypress"}, GK_CYPRESS, true,  false, false, false, false},
-{{"juniper"}, {"juniper"}, GK_JUNIPER, false, false, false, false, false},
-{{"redwood"}, {"redwood"}, GK_REDWOOD, false, false, false, false, false},
-{{"sumo"},{"sumo"},GK_SUMO,false, false, false, false, false},
-{{"sumo2"},   {"sumo"},GK_SUMO,false, false, false, false, false},
-{{"barts"},   {"barts"},   GK_BARTS,   false, false, false, false, false},
-{{"caicos"},  {"caicos"},  GK_BARTS,   false, false, false, false, false},
-{{"aruba"},   {"cayman"},  GK_CAYMAN,  true,  false, false, false, false},
-{{"cayman"},  {"cayman"},  GK_CAYMAN,  true,  false, false, false, false},
-{{"turks"},   {"turks"},   GK_TURKS,   false, false, false, false, false},
+  // Name CanonicalKindHasHasHasHasHas
Has
+  //  Name FMAF   Fast   LDEXPF FP64   Fast   
Fast
+  //  FMAF FMA
Denorm
+{{"r600"},{"r600"},GK_R600,false, false, false, false, false, 
false},
+{{"rv630"},   {"r600"},GK_R600,false, false, false, false, false, 
false},
+{{"rv635"},   {"r600"},GK_R600,false, false, false, false, false, 
false},
+{{"r630"},{"r630"},GK_R630,false, false, false, false, false, 
false},
+{{"rs780"},   {"rs880"},   GK_RS880,   false, false, false, 

[PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

2018-08-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I got some actual data. The way we package clang today, the extracted 
installation is 134.83M, and lib/clang/7.0.0/lib/darwin/* is 13M, so it's a 10% 
increase. It would be worth it to us to replace these with empty files if this 
change does land, but again, I'd rather not go this direction, which would 
require special logic just for the darwin parts of compiler-rt.


Repository:
  rL LLVM

https://reviews.llvm.org/D15225



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


[PATCH] D50168: [Builtins] Implement __builtin_clrsb to be compatible with gcc

2018-08-08 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 159753.
craig.topper added a comment.

Use ctlz(zero_undef=false) and sub


https://reviews.llvm.org/D50168

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtin_clrsb.c


Index: test/CodeGen/builtin_clrsb.c
===
--- /dev/null
+++ test/CodeGen/builtin_clrsb.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+int test__builtin_clrsb(int x) {
+// CHECK-LABEL: test__builtin_clrsb
+// CHECK: [[C:%.*]] = icmp slt i32 [[X:%.*]], 0
+// CHECK-NEXT: [[INV:%.*]] = xor i32 [[X]], -1
+// CHECK-NEXT: [[SEL:%.*]] = select i1 [[C]], i32 [[INV]], i32 [[X]]
+// CHECK-NEXT: [[CTLZ:%.*]] = call i32 @llvm.ctlz.i32(i32 [[SEL]], i1 false)
+// CHECK-NEXT: [[SUB:%.*]] = sub i32 [[CTLZ]], 1
+  return __builtin_clrsb(x);
+}
+
+int test__builtin_clrsbll(long long x) {
+// CHECK-LABEL: test__builtin_clrsbll
+// CHECK: [[C:%.*]] = icmp slt i64 [[X:%.*]], 0
+// CHECK-NEXT: [[INV:%.*]] = xor i64 [[X]], -1
+// CHECK-NEXT: [[SEL:%.*]] = select i1 [[C]], i64 [[INV]], i64 [[X]]
+// CHECK-NEXT: [[CTLZ:%.*]] = call i64 @llvm.ctlz.i64(i64 [[SEL]], i1 false)
+// CHECK-NEXT: [[SUB:%.*]] = sub i64 [[CTLZ]], 1
+// CHECK-NEXT: trunc i64 [[SUB]] to i32
+  return __builtin_clrsbll(x);
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -1537,6 +1537,26 @@
 return RValue::get(ComplexVal.second);
   }
 
+  case Builtin::BI__builtin_clrsb:
+  case Builtin::BI__builtin_clrsbl:
+  case Builtin::BI__builtin_clrsbll: {
+// clrsb(x) -> clz(x < 0 ? ~x : x) - 1 or
+Value *ArgValue = EmitScalarExpr(E->getArg(0));
+
+llvm::Type *ArgType = ArgValue->getType();
+Value *F = CGM.getIntrinsic(Intrinsic::ctlz, ArgType);
+
+llvm::Type *ResultType = ConvertType(E->getType());
+Value *Zero = llvm::Constant::getNullValue(ArgType);
+Value *IsNeg = Builder.CreateICmpSLT(ArgValue, Zero, "isneg");
+Value *Inverse = Builder.CreateNot(ArgValue, "not");
+Value *Tmp = Builder.CreateSelect(IsNeg, Inverse, ArgValue);
+Value *Ctlz = Builder.CreateCall(F, {Tmp, Builder.getFalse()});
+Value *Result = Builder.CreateSub(Ctlz, llvm::ConstantInt::get(ArgType, 
1));
+Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true,
+   "cast");
+return RValue::get(Result);
+  }
   case Builtin::BI__builtin_ctzs:
   case Builtin::BI__builtin_ctz:
   case Builtin::BI__builtin_ctzl:
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -413,6 +413,9 @@
 BUILTIN(__builtin_popcount  , "iUi"  , "nc")
 BUILTIN(__builtin_popcountl , "iULi" , "nc")
 BUILTIN(__builtin_popcountll, "iULLi", "nc")
+BUILTIN(__builtin_clrsb  , "ii"  , "nc")
+BUILTIN(__builtin_clrsbl , "iLi" , "nc")
+BUILTIN(__builtin_clrsbll, "iLLi", "nc")
 
 // FIXME: These type signatures are not correct for targets with int != 32-bits
 // or with ULL != 64-bits.


Index: test/CodeGen/builtin_clrsb.c
===
--- /dev/null
+++ test/CodeGen/builtin_clrsb.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+int test__builtin_clrsb(int x) {
+// CHECK-LABEL: test__builtin_clrsb
+// CHECK: [[C:%.*]] = icmp slt i32 [[X:%.*]], 0
+// CHECK-NEXT: [[INV:%.*]] = xor i32 [[X]], -1
+// CHECK-NEXT: [[SEL:%.*]] = select i1 [[C]], i32 [[INV]], i32 [[X]]
+// CHECK-NEXT: [[CTLZ:%.*]] = call i32 @llvm.ctlz.i32(i32 [[SEL]], i1 false)
+// CHECK-NEXT: [[SUB:%.*]] = sub i32 [[CTLZ]], 1
+  return __builtin_clrsb(x);
+}
+
+int test__builtin_clrsbll(long long x) {
+// CHECK-LABEL: test__builtin_clrsbll
+// CHECK: [[C:%.*]] = icmp slt i64 [[X:%.*]], 0
+// CHECK-NEXT: [[INV:%.*]] = xor i64 [[X]], -1
+// CHECK-NEXT: [[SEL:%.*]] = select i1 [[C]], i64 [[INV]], i64 [[X]]
+// CHECK-NEXT: [[CTLZ:%.*]] = call i64 @llvm.ctlz.i64(i64 [[SEL]], i1 false)
+// CHECK-NEXT: [[SUB:%.*]] = sub i64 [[CTLZ]], 1
+// CHECK-NEXT: trunc i64 [[SUB]] to i32
+  return __builtin_clrsbll(x);
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -1537,6 +1537,26 @@
 return RValue::get(ComplexVal.second);
   }
 
+  case Builtin::BI__builtin_clrsb:
+  case Builtin::BI__builtin_clrsbl:
+  case Builtin::BI__builtin_clrsbll: {
+// clrsb(x) -> clz(x < 0 ? ~x : x) - 1 or
+Value *ArgValue = EmitScalarExpr(E->getArg(0));
+
+llvm::Type *ArgType = ArgValue->getType();
+Value *F = CGM.getIntrinsic(Intrinsic::ctlz, ArgType);
+
+llvm::Type *ResultType = ConvertType(E->getType());
+Value *Zero = llvm::Constant::getNullValue(ArgType);
+Value *IsNeg = Builder.CreateICmpSLT(ArgValue, 

[PATCH] D40526: [WebAssembly] Change size_t to `unsigned long`

2018-08-08 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added a comment.

Is this related to the issue reported in the thread here 
?


Repository:
  rC Clang

https://reviews.llvm.org/D40526



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


[PATCH] D50144: Add Windows support for the GNUstep Objective-C ABI V2.

2018-08-08 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added inline comments.



Comment at: lib/CodeGen/CGObjCGNU.cpp:3542
+  allSelectors.push_back(entry.first);
+std::sort(allSelectors.begin(), allSelectors.end());
 

Please use llvm::sort instead of std::sort. See 
https://llvm.org/docs/CodingStandards.html#beware-of-non-deterministic-sorting-order-of-equal-elements.


Repository:
  rC Clang

https://reviews.llvm.org/D50144



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


[PATCH] D50455: Continue emitting diagnostics after a fatal error

2018-08-08 Thread Dmitry via Phabricator via cfe-commits
Dmitry.Kozhevnikov added a comment.

See also https://reviews.llvm.org/D50462


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50455



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


[PATCH] D50462: Try building complete AST after a fatal error was emitted if further diagnostics are expected

2018-08-08 Thread Dmitry via Phabricator via cfe-commits
Dmitry.Kozhevnikov created this revision.
Dmitry.Kozhevnikov added reviewers: ilya-biryukov, sammccall, milianw.
Herald added subscribers: cfe-commits, ioeric.

Related to https://reviews.llvm.org/D50455

There is some code here and there that assume that no sane output is required 
if a fatal error has occurred. When using clangd/libclang, it's no longer true: 
diagnostics might still be requested, and AST might still be required for other 
IDE/tooling features, so it has to be as complete as possible.

Here I try to separate the following use cases:

1. Some clients check `hasFatalErrorOccurred()` because they are known to work 
unstable in presence of compile errors and want to mitigate it - they'll work 
as before
2. However, we don't want to take shortcuts in PP and Sema and still want to 
process include directives and instantiate templates

Note: I've found out that initially the flag in `DiagnosticsEngine` (which is 
now called `SuppressAfterFatalError`) had different meaning and was just 
demoting all fatal errors to non-fatal (https://reviews.llvm.org/rL262318). 
This would also fix this issue, however, it was partly reverted in 
https://reviews.llvm.org/rL301992 to the current state. Maybe we should go with 
the old approach instead (I assume the issue was that this flag was not 
serialized/restored, but probably should?)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50462

Files:
  include/clang/Basic/Diagnostic.h
  lib/Lex/PPDirectives.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  unittests/Frontend/PCHPreambleTest.cpp

Index: unittests/Frontend/PCHPreambleTest.cpp
===
--- unittests/Frontend/PCHPreambleTest.cpp
+++ unittests/Frontend/PCHPreambleTest.cpp
@@ -77,7 +77,8 @@
 RemappedFiles[Filename] = Contents;
   }
 
-  std::unique_ptr ParseAST(const std::string ) {
+  std::unique_ptr ParseAST(const std::string ,
+bool SuppressAfterFatalError = true) {
 PCHContainerOpts = std::make_shared();
 std::shared_ptr CI(new CompilerInvocation);
 CI->getFrontendOpts().Inputs.push_back(
@@ -88,11 +89,15 @@
 
 CI->getPreprocessorOpts().RemappedFileBuffers = GetRemappedFiles();
 
+CI->getLangOpts()->CPlusPlus = true;
+CI->getLangOpts()->CPlusPlus11 = true;
+
 PreprocessorOptions  = CI->getPreprocessorOpts();
 PPOpts.RemappedFilesKeepOriginalName = true;
 
 IntrusiveRefCntPtr
   Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions, new DiagnosticConsumer));
+Diags->setSuppressAfterFatalError(SuppressAfterFatalError);
 
 FileManager *FileMgr = new FileManager(FSOpts, VFS);
 
@@ -197,4 +202,33 @@
   ASSERT_LE(HeaderReadCount, GetFileReadCount(Header));
 }
 
+TEST_F(PCHPreambleTest, MissingHeader) {
+  std::string Header1 = "//./header1.h";
+  AddFile(Header1,
+"template  class C;\n"
+"template  class C{};\n");
+
+  std::string Header2 = "//./header2.h";
+  AddFile(Header2, "using Alias = C;\n");
+
+  std::string Main = "//./main.cpp";
+  AddFile(Main,
+"#include \"nonexistent1\"\n"
+"#include \"//./header1.h\"\n"
+"#include \"nonexistent2\"\n"
+"#include \"//./header2.h\"\n"
+"Alias Var;");
+
+  std::unique_ptr AST(ParseAST(Main, /*SuppressAfterFatalError=*/false));
+  ASSERT_TRUE(AST.get());
+
+  // only "file not found" errors should be emitted,
+  // "Alias" should be visible for lookup.
+  auto ExpectedErrorsCount = 2u;
+
+  ASSERT_EQ(AST->getDiagnostics().getClient()->getNumErrors(), ExpectedErrorsCount);
+  ASSERT_TRUE(ReparseAST(AST));
+  ASSERT_EQ(AST->getDiagnostics().getClient()->getNumErrors(), ExpectedErrorsCount);
+}
+
 } // anonymous namespace
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -218,7 +218,7 @@
   // Don't allow further instantiation if a fatal error and an uncompilable
   // error have occurred. Any diagnostics we might have raised will not be
   // visible, and we do not need to construct a correct AST.
-  if (SemaRef.Diags.hasFatalErrorOccurred() &&
+  if (SemaRef.Diags.areDiagnosticsSuppressedAfterFatalError() &&
   SemaRef.Diags.hasUncompilableErrorOccurred()) {
 Invalid = true;
 return;
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -1899,7 +1899,7 @@
   // Any diagnostics after the fatal error will not be visible. As the
   // compilation failed already and errors in subsequently included files won't
   // be visible, avoid preprocessing those files.
-  if (ShouldEnter && Diags->hasFatalErrorOccurred())
+  if (ShouldEnter && Diags->areDiagnosticsSuppressedAfterFatalError())
 ShouldEnter = false;
 
   // Determine whether we should try to import the module for this #include, if
Index: 

r339273 - CDDecl More automatic variable tail padding test

2018-08-08 Thread JF Bastien via cfe-commits
Author: jfb
Date: Wed Aug  8 10:05:17 2018
New Revision: 339273

URL: http://llvm.org/viewvc/llvm-project?rev=339273=rev
Log:
CDDecl More automatic variable tail padding test

Test tail padded automatic variable at different width, because they encounter 
different codegen.

Modified:
cfe/trunk/test/CodeGenCXX/auto-var-init.cpp

Modified: cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/auto-var-init.cpp?rev=339273=339272=339273=diff
==
--- cfe/trunk/test/CodeGenCXX/auto-var-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/auto-var-init.cpp Wed Aug  8 10:05:17 2018
@@ -612,13 +612,32 @@ TEST_BRACES(tailpad4, tailpad[4]);
 // CHECK-NEXT:  call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 
0, i64 16, i1 false)
 // CHECK-NEXT:  call void @{{.*}}used{{.*}}%braces)
 
-TEST_CUSTOM(tailpad4, tailpad[4], { {17, 1}, {17, 1}, {17, 1}, {17, 1} });
+TEST_CUSTOM(tailpad4, tailpad[4], { {257, 1}, {257, 1}, {257, 1}, {257, 1} });
 // CHECK-LABEL: @test_tailpad4_custom()
 // CHECK:   %custom = alloca [4 x %struct.tailpad], align
 // CHECK-NEXT:  bitcast
 // CHECK-NEXT:  call void @llvm.memcpy
 // CHECK-NEXT:  call void @{{.*}}used{{.*}}%custom)
 
+TEST_UNINIT(tailpad9, tailpad[9]);
+// CHECK-LABEL: @test_tailpad9_uninit()
+// CHECK:   %uninit = alloca [9 x %struct.tailpad], align
+// CHECK-NEXT:  call void @{{.*}}used{{.*}}%uninit)
+
+TEST_BRACES(tailpad9, tailpad[9]);
+// CHECK-LABEL: @test_tailpad9_braces()
+// CHECK:   %braces = alloca [9 x %struct.tailpad], align [[ALIGN:[0-9]*]]
+// CHECK-NEXT:  bitcast
+// CHECK-NEXT:  call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 
0, i64 36, i1 false)
+// CHECK-NEXT:  call void @{{.*}}used{{.*}}%braces)
+
+TEST_CUSTOM(tailpad9, tailpad[9], { {257, 1}, {257, 1}, {257, 1}, {257, 1}, 
{257, 1}, {257, 1}, {257, 1}, {257, 1}, {257, 1} });
+// CHECK-LABEL: @test_tailpad9_custom()
+// CHECK:   %custom = alloca [9 x %struct.tailpad], align [[ALIGN:[0-9]*]]
+// CHECK-NEXT:  bitcast
+// CHECK-NEXT:  call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 
1, i64 36, i1 false)
+// CHECK-NEXT:  call void @{{.*}}used{{.*}}%custom)
+
 
 TEST_UNINIT(atomicbool, _Atomic(bool));
 // CHECK-LABEL: @test_atomicbool_uninit()


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


[PATCH] D50446: [clangd] Record the currently active file in context for codeCompletion and findDefinitions.

2018-08-08 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Ok, I am convinced :) Putting the context key into TUScheduler.cpp and exposing 
a static method to access it sound like a better idea afterall. Thanks for the 
suggestions!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50446



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


[PATCH] D50446: [clangd] Record the currently active file in context for codeCompletion and findDefinitions.

2018-08-08 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 159746.
ioeric marked 3 inline comments as done.
ioeric added a comment.
Herald added a subscriber: javed.absar.

- Addressed review comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50446

Files:
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -197,20 +197,22 @@
 {
   WithContextValue WithNonce(NonceKey, ++Nonce);
   S.update(File, Inputs, WantDiagnostics::Auto,
-   [Nonce, ,
+   [File, Nonce, ,
 ](llvm::Optional> Diags) {
  EXPECT_THAT(Context::current().get(NonceKey),
  Pointee(Nonce));
 
  std::lock_guard Lock(Mut);
  ++TotalUpdates;
+ EXPECT_EQ(File,
+   *TUScheduler::getFileBeingProcessedInContext());
});
 }
 
 {
   WithContextValue WithNonce(NonceKey, ++Nonce);
   S.runWithAST("CheckAST", File,
-   [Inputs, Nonce, ,
+   [File, Inputs, Nonce, ,
 ](llvm::Expected AST) {
  EXPECT_THAT(Context::current().get(NonceKey),
  Pointee(Nonce));
@@ -221,23 +223,27 @@
 
  std::lock_guard Lock(Mut);
  ++TotalASTReads;
+ EXPECT_EQ(
+ File,
+ *TUScheduler::getFileBeingProcessedInContext());
});
 }
 
 {
   WithContextValue WithNonce(NonceKey, ++Nonce);
-  S.runWithPreamble("CheckPreamble", File,
-[Inputs, Nonce, , ](
-llvm::Expected Preamble) {
-  EXPECT_THAT(Context::current().get(NonceKey),
-  Pointee(Nonce));
-
-  ASSERT_TRUE((bool)Preamble);
-  EXPECT_EQ(Preamble->Contents, Inputs.Contents);
-
-  std::lock_guard Lock(Mut);
-  ++TotalPreambleReads;
-});
+  S.runWithPreamble(
+  "CheckPreamble", File,
+  [File, Inputs, Nonce, , ](
+  llvm::Expected Preamble) {
+EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce));
+
+ASSERT_TRUE((bool)Preamble);
+EXPECT_EQ(Preamble->Contents, Inputs.Contents);
+
+std::lock_guard Lock(Mut);
+++TotalPreambleReads;
+EXPECT_EQ(File, *TUScheduler::getFileBeingProcessedInContext());
+  });
 }
   }
 }
Index: clangd/TUScheduler.h
===
--- clangd/TUScheduler.h
+++ clangd/TUScheduler.h
@@ -122,6 +122,13 @@
   /// an LRU cache.
   class ASTCache;
 
+  // The file being built/processed in the current thread. This is a hack in
+  // order to get the file name into the index implementations. Do not depend on
+  // this inside clangd.
+  // FIXME: remove this when there is proper index support via build system
+  // integration.
+  static llvm::Optional getFileBeingProcessedInContext();
+
 private:
   const bool StorePreamblesInMemory;
   const std::shared_ptr PCHOps;
@@ -135,6 +142,7 @@
   llvm::Optional WorkerThreads;
   std::chrono::steady_clock::duration UpdateDebounce;
 };
+
 } // namespace clangd
 } // namespace clang
 
Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -63,6 +63,14 @@
 class ASTWorker;
 }
 
+static const clang::clangd::Key kFileBeingProcessed;
+
+llvm::Optional TUScheduler::getFileBeingProcessedInContext() {
+  if (auto *File = Context::current().get(kFileBeingProcessed))
+return StringRef(*File);
+  return llvm::None;
+}
+
 /// An LRU cache of idle ASTs.
 /// Because we want to limit the overall number of these we retain, the cache
 /// owns ASTs (and may evict them) while their workers are idle.
@@ -491,8 +499,9 @@
   {
 std::lock_guard Lock(Mutex);
 assert(!Done && "running a task after stop()");
-Requests.push_back({std::move(Task), Name, steady_clock::now(),
-Context::current().clone(), UpdateType});
+Requests.push_back(
+{std::move(Task), Name, steady_clock::now(),
+ Context::current().derive(kFileBeingProcessed, FileName), UpdateType});
   }
   RequestsCV.notify_all();
 }
@@ -734,10 +743,12 @@
 Action(InputsAndPreamble{Contents, 

[PATCH] D40526: [WebAssembly] Change size_t to `unsigned long`

2018-08-08 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

Should we change int32_t as well?   Or does the above code just need fixing?  
I'm a little concerned because this code is very portable which implies that 
WebAssembly might be doing something unusual here.


Repository:
  rC Clang

https://reviews.llvm.org/D40526



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


[PATCH] D40526: [WebAssembly] Change size_t to `unsigned long`

2018-08-08 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

I'm running into an issue with an internal codebase that assumes that size_t is 
equivalent to either int32_t or int64_t which this change invalidates.

After this change we have:  
size_t -> long
int32_t -> int
int64_t -> ling long int.

e.g.:

  #include 
  #include 
  
  int func(int32_t* f) {
return 1;
  }
  
  int func(int64_t* f) {
return 2;
  }
  
  int main() {
size_t a = 0 ;
return func();
  }

This generates the following error after this change:

  ./bin/clang --target=wasm32 -c ./test.cpp 
  ./test.cpp:14:10: error: no matching function for call to 'func'
return func();
   ^~~~
  ./test.cpp:4:5: note: candidate function not viable: no known conversion from 
'size_t *' (aka 'unsigned long *') to 'int32_t *'
(aka 'int *') for 1st argument
  int func(int32_t* f) {
  ^
  ./test.cpp:8:5: note: candidate function not viable: no known conversion from 
'size_t *' (aka 'unsigned long *') to 'int64_t *'
(aka 'long long *') for 1st argument
  int func(int64_t* f) {
  ^
  1 error generated.


Repository:
  rC Clang

https://reviews.llvm.org/D40526



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


[PATCH] D50413: [libunwind][include] Add some missing definitions to .

2018-08-08 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a subscriber: joerg.
krytarowski added a comment.

In https://reviews.llvm.org/D50413#1192475, @cdavis5x wrote:

> In https://reviews.llvm.org/D50413#1191726, @krytarowski wrote:
>
> > NetBSD uses `typedef void *_Unwind_Ptr;` unconditionally in its 
> > ``... if that has to be matched.
>
>
> Done.
>
> > Additionally: `typedef long _Unwind_Word;`.
>
> Done.


I recommend to get a review of this by @joerg


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50413



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


[PATCH] D50455: Continue emitting diagnostics after a fatal error

2018-08-08 Thread Dmitry via Phabricator via cfe-commits
Dmitry.Kozhevnikov created this revision.
Dmitry.Kozhevnikov added reviewers: ilya-biryukov, sammccall.
Herald added subscribers: cfe-commits, arphaman, jkorous.

By default, diagnostics are suppressed after a fatal error. Some fatal errors 
(notably, "file not found" for include directive) are common for incomplete 
code and we probably want to have further diagnostics anyway.

Currently, this flag is optionally set by libclang (see 
CXTranslationUnit_KeepGoing option).

There are also a bunch of related problems when AST is not fully built in 
presence of fatal errors (templates are not instantiated and include directives 
are not processed), I'll address these in separate patches.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50455

Files:
  clangd/ClangdUnit.cpp
  clangd/Compiler.cpp
  test/clangd/missing-includes.test


Index: test/clangd/missing-includes.test
===
--- test/clangd/missing-includes.test
+++ test/clangd/missing-includes.test
@@ -0,0 +1,13 @@
+# RUN: clangd -lit-test < %s | FileCheck %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"#include
 \n#include \nint x;\n#include \n#include \n"}}}
+# CHECK:  "method": "textDocument/publishDiagnostics",
+# CHECK:  "message": "'a' file not found",
+# CHECK:  "message": "'b' file not found",
+# CHECK:  "message": "'c' file not found",
+# CHECK:  "message": "'d' file not found",
+---
+{"jsonrpc":"2.0","id":5,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clangd/Compiler.cpp
===
--- clangd/Compiler.cpp
+++ clangd/Compiler.cpp
@@ -63,6 +63,7 @@
   auto Clang = llvm::make_unique(PCHs);
   Clang->setInvocation(std::move(CI));
   Clang->createDiagnostics(, false);
+  Clang->getDiagnostics().setSuppressAfterFatalError(false);
 
   if (auto VFSWithRemapping = createVFSFromCompilerInvocation(
   Clang->getInvocation(), Clang->getDiagnostics(), VFS))
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -328,6 +328,8 @@
   // to read back. We rely on dynamic index for the comments instead.
   CI.getPreprocessorOpts().WriteCommentListToPCH = false;
 
+  PreambleDiagsEngine->setSuppressAfterFatalError(false);
+
   CppFilePreambleCallbacks SerializedDeclsCollector(FileName, 
PreambleCallback);
   if (Inputs.FS->setCurrentWorkingDirectory(Inputs.CompileCommand.Directory)) {
 log("Couldn't set working directory when building the preamble.");


Index: test/clangd/missing-includes.test
===
--- test/clangd/missing-includes.test
+++ test/clangd/missing-includes.test
@@ -0,0 +1,13 @@
+# RUN: clangd -lit-test < %s | FileCheck %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"#include \n#include \nint x;\n#include \n#include \n"}}}
+# CHECK:  "method": "textDocument/publishDiagnostics",
+# CHECK:  "message": "'a' file not found",
+# CHECK:  "message": "'b' file not found",
+# CHECK:  "message": "'c' file not found",
+# CHECK:  "message": "'d' file not found",
+---
+{"jsonrpc":"2.0","id":5,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clangd/Compiler.cpp
===
--- clangd/Compiler.cpp
+++ clangd/Compiler.cpp
@@ -63,6 +63,7 @@
   auto Clang = llvm::make_unique(PCHs);
   Clang->setInvocation(std::move(CI));
   Clang->createDiagnostics(, false);
+  Clang->getDiagnostics().setSuppressAfterFatalError(false);
 
   if (auto VFSWithRemapping = createVFSFromCompilerInvocation(
   Clang->getInvocation(), Clang->getDiagnostics(), VFS))
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -328,6 +328,8 @@
   // to read back. We rely on dynamic index for the comments instead.
   CI.getPreprocessorOpts().WriteCommentListToPCH = false;
 
+  PreambleDiagsEngine->setSuppressAfterFatalError(false);
+
   CppFilePreambleCallbacks SerializedDeclsCollector(FileName, PreambleCallback);
   if (Inputs.FS->setCurrentWorkingDirectory(Inputs.CompileCommand.Directory)) {
 log("Couldn't set working directory when building the preamble.");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2018-08-08 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

In https://reviews.llvm.org/D47849#1192493, @gtbercea wrote:

> @Hahnfeld do you get the same error if you compile with clang++ instead of 
> clang?


Yes, with both trunk and this patch applied. It's the same header after all...


Repository:
  rC Clang

https://reviews.llvm.org/D47849



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


[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2018-08-08 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

@Hahnfeld do you get the same error if you compile with clang++ instead of 
clang?


Repository:
  rC Clang

https://reviews.llvm.org/D47849



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


r339265 - [DebugInfo][OpenCL] Address post-commit review for r338299

2018-08-08 Thread Scott Linder via cfe-commits
Author: scott.linder
Date: Wed Aug  8 08:56:12 2018
New Revision: 339265

URL: http://llvm.org/viewvc/llvm-project?rev=339265=rev
Log:
[DebugInfo][OpenCL] Address post-commit review for r338299

NFC refactor of code to generate debug info for OpenCL 2.X blocks.

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

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGenOpenCL/blocks.cl

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=339265=339264=339265=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Aug  8 08:56:12 2018
@@ -942,12 +942,47 @@ llvm::DIType *CGDebugInfo::getOrCreateSt
   return Cache;
 }
 
+uint64_t CGDebugInfo::collectDefaultElementTypesForBlockPointer(
+const BlockPointerType *Ty, llvm::DIFile *Unit, llvm::DIDerivedType 
*DescTy,
+unsigned LineNo, SmallVectorImpl ) {
+  QualType FType;
+
+  // Advanced by calls to CreateMemberType in increments of FType, then
+  // returned as the overall size of the default elements.
+  uint64_t FieldOffset = 0;
+
+  // Blocks in OpenCL have unique constraints which make the standard fields
+  // redundant while requiring size and align fields for enqueue_kernel. See
+  // initializeForBlockHeader in CGBlocks.cpp
+  if (CGM.getLangOpts().OpenCL) {
+FType = CGM.getContext().IntTy;
+EltTys.push_back(CreateMemberType(Unit, FType, "__size", ));
+EltTys.push_back(CreateMemberType(Unit, FType, "__align", ));
+  } else {
+FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
+EltTys.push_back(CreateMemberType(Unit, FType, "__isa", ));
+FType = CGM.getContext().IntTy;
+EltTys.push_back(CreateMemberType(Unit, FType, "__flags", ));
+EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", 
));
+FType = CGM.getContext().getPointerType(Ty->getPointeeType());
+EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", ));
+FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
+uint64_t FieldSize = CGM.getContext().getTypeSize(Ty);
+uint32_t FieldAlign = CGM.getContext().getTypeAlign(Ty);
+EltTys.push_back(DBuilder.createMemberType(
+Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign,
+FieldOffset, llvm::DINode::FlagZero, DescTy));
+FieldOffset += FieldSize;
+  }
+
+  return FieldOffset;
+}
+
 llvm::DIType *CGDebugInfo::CreateType(const BlockPointerType *Ty,
   llvm::DIFile *Unit) {
   SmallVector EltTys;
   QualType FType;
-  uint64_t FieldSize, FieldOffset;
-  uint32_t FieldAlign;
+  uint64_t FieldOffset;
   llvm::DINodeArray Elements;
 
   FieldOffset = 0;
@@ -959,10 +994,9 @@ llvm::DIType *CGDebugInfo::CreateType(co
   EltTys.clear();
 
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagAppleBlock;
-  unsigned LineNo = 0;
 
   auto *EltTy =
-  DBuilder.createStructType(Unit, "__block_descriptor", nullptr, LineNo,
+  DBuilder.createStructType(Unit, "__block_descriptor", nullptr, 0,
 FieldOffset, 0, Flags, nullptr, Elements);
 
   // Bit size, align and offset of the type.
@@ -970,27 +1004,8 @@ llvm::DIType *CGDebugInfo::CreateType(co
 
   auto *DescTy = DBuilder.createPointerType(EltTy, Size);
 
-  FieldOffset = 0;
-  if (CGM.getLangOpts().OpenCL) {
-FType = CGM.getContext().IntTy;
-EltTys.push_back(CreateMemberType(Unit, FType, "__size", ));
-EltTys.push_back(CreateMemberType(Unit, FType, "__align", ));
-  } else {
-FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
-EltTys.push_back(CreateMemberType(Unit, FType, "__isa", ));
-FType = CGM.getContext().IntTy;
-EltTys.push_back(CreateMemberType(Unit, FType, "__flags", ));
-EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", 
));
-FType = CGM.getContext().getPointerType(Ty->getPointeeType());
-EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", ));
-FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
-FieldSize = CGM.getContext().getTypeSize(Ty);
-FieldAlign = CGM.getContext().getTypeAlign(Ty);
-EltTys.push_back(DBuilder.createMemberType(
-Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign, 
FieldOffset,
-llvm::DINode::FlagZero, DescTy));
-FieldOffset += FieldSize;
-  }
+  FieldOffset = collectDefaultElementTypesForBlockPointer(Ty, Unit, DescTy,
+  0, EltTys);
 
   Elements = DBuilder.getOrCreateArray(EltTys);
 
@@ -998,7 +1013,7 @@ llvm::DIType *CGDebugInfo::CreateType(co
   // DW_AT_APPLE_BLOCK attribute and are an implementation detail only
   // the debugger needs to know about. To allow type uniquing, emit
   // them without a name or a location.
-  

[PATCH] D50099: [DebugInfo][OpenCL] Address post-commit review of D49930

2018-08-08 Thread Scott Linder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339265: [DebugInfo][OpenCL] Address post-commit review for 
r338299 (authored by scott.linder, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50099?vs=159512=159734#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50099

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h
  cfe/trunk/test/CodeGenOpenCL/blocks.cl

Index: cfe/trunk/lib/CodeGen/CGDebugInfo.h
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h
@@ -311,6 +311,22 @@
   void AppendAddressSpaceXDeref(unsigned AddressSpace,
 SmallVectorImpl ) const;
 
+  /// A helper function to collect debug info for the default elements of a
+  /// block.
+  ///
+  /// \returns The next available field offset after the default elements.
+  uint64_t collectDefaultElementTypesForBlockPointer(
+  const BlockPointerType *Ty, llvm::DIFile *Unit,
+  llvm::DIDerivedType *DescTy, unsigned LineNo,
+  SmallVectorImpl );
+
+  /// A helper function to collect debug info for the default fields of a
+  /// block.
+  void collectDefaultFieldsForBlockLiteralDeclare(
+  const CGBlockInfo , const ASTContext , SourceLocation Loc,
+  const llvm::StructLayout , llvm::DIFile *Unit,
+  SmallVectorImpl );
+
 public:
   CGDebugInfo(CodeGenModule );
   ~CGDebugInfo();
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -942,12 +942,47 @@
   return Cache;
 }
 
+uint64_t CGDebugInfo::collectDefaultElementTypesForBlockPointer(
+const BlockPointerType *Ty, llvm::DIFile *Unit, llvm::DIDerivedType *DescTy,
+unsigned LineNo, SmallVectorImpl ) {
+  QualType FType;
+
+  // Advanced by calls to CreateMemberType in increments of FType, then
+  // returned as the overall size of the default elements.
+  uint64_t FieldOffset = 0;
+
+  // Blocks in OpenCL have unique constraints which make the standard fields
+  // redundant while requiring size and align fields for enqueue_kernel. See
+  // initializeForBlockHeader in CGBlocks.cpp
+  if (CGM.getLangOpts().OpenCL) {
+FType = CGM.getContext().IntTy;
+EltTys.push_back(CreateMemberType(Unit, FType, "__size", ));
+EltTys.push_back(CreateMemberType(Unit, FType, "__align", ));
+  } else {
+FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
+EltTys.push_back(CreateMemberType(Unit, FType, "__isa", ));
+FType = CGM.getContext().IntTy;
+EltTys.push_back(CreateMemberType(Unit, FType, "__flags", ));
+EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", ));
+FType = CGM.getContext().getPointerType(Ty->getPointeeType());
+EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", ));
+FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
+uint64_t FieldSize = CGM.getContext().getTypeSize(Ty);
+uint32_t FieldAlign = CGM.getContext().getTypeAlign(Ty);
+EltTys.push_back(DBuilder.createMemberType(
+Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign,
+FieldOffset, llvm::DINode::FlagZero, DescTy));
+FieldOffset += FieldSize;
+  }
+
+  return FieldOffset;
+}
+
 llvm::DIType *CGDebugInfo::CreateType(const BlockPointerType *Ty,
   llvm::DIFile *Unit) {
   SmallVector EltTys;
   QualType FType;
-  uint64_t FieldSize, FieldOffset;
-  uint32_t FieldAlign;
+  uint64_t FieldOffset;
   llvm::DINodeArray Elements;
 
   FieldOffset = 0;
@@ -959,46 +994,26 @@
   EltTys.clear();
 
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagAppleBlock;
-  unsigned LineNo = 0;
 
   auto *EltTy =
-  DBuilder.createStructType(Unit, "__block_descriptor", nullptr, LineNo,
+  DBuilder.createStructType(Unit, "__block_descriptor", nullptr, 0,
 FieldOffset, 0, Flags, nullptr, Elements);
 
   // Bit size, align and offset of the type.
   uint64_t Size = CGM.getContext().getTypeSize(Ty);
 
   auto *DescTy = DBuilder.createPointerType(EltTy, Size);
 
-  FieldOffset = 0;
-  if (CGM.getLangOpts().OpenCL) {
-FType = CGM.getContext().IntTy;
-EltTys.push_back(CreateMemberType(Unit, FType, "__size", ));
-EltTys.push_back(CreateMemberType(Unit, FType, "__align", ));
-  } else {
-FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
-EltTys.push_back(CreateMemberType(Unit, FType, "__isa", ));
-FType = CGM.getContext().IntTy;
-EltTys.push_back(CreateMemberType(Unit, FType, "__flags", ));
-EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", ));
-FType = CGM.getContext().getPointerType(Ty->getPointeeType());
-EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", 

Re: [PATCH] D50154: [clangd] capitalize diagnostic messages

2018-08-08 Thread David Blaikie via cfe-commits
On Wed, Aug 8, 2018 at 5:00 AM Ilya Biryukov via Phabricator <
revi...@reviews.llvm.org> wrote:

> ilya-biryukov added a comment.
>
> In https://reviews.llvm.org/D50154#1191002, @dblaikie wrote:
>
> > What's the motivation for clangd to differ from clang here?
>
>
> The presentation of diagnostics to the users is different between clang
> and clangd:
>
> - clang diagnostics are always prefixed with the file, location and
> severity of the diagnostic, e.g. `main.cpp:1:2: error: expected '}'`
>

*nod* That's a fairly natural one - and I assume the information is
provided semantically - source, line, column, and text. A client can stitch
them together as clang does or it can render the information some other way
(by placing the text as a mouseover/popup at the source location). I don't
see that as a divergence - but providing the full fidelity of the
information (rather than prematurely stringifying it all together) &
leaving it up to the client to decide how to render it to the user.


> - In LSP clients (VSCode in particular), the diagnostic message is the
> first thing the user sees and it looks a little nicer (subjectively) if the
> first letter is capitalized.
>

It looks nicer in VSCode because that's the UI convention for mouseover
text (in Windows, at least) - first letter capitalized. But it seems hard
to me to generalize from there to all or most LSP clients. (& I also worry
that such a mechanical transformation might be erroneous in some messages)

(well, there's at least one case where reversing this would fail - there's
a diagnostic in Clang that starts with "ISO" - so uppercasing does nothing,
but lowercasing it to try to get back to the original would result in "iSO"
- several others like "Objective-C", "Neon", "GCC", etc)

(also, there's one that this will mangle: "ms_struct may not produce
Microsoft-compatible layouts" - I assume capitalizing "ms_struct" would be
incorrect (though arguably/mostly identifiers like that are quoted in error
messages - and that may be reasonable/correct/better to do that here).
Similar use of 'sizeof' at the start of a diagnostic, 'os_log()', -
those'll be an issue no matter where the implementation is (in clangd or
its client(s)) though - short of having a more customized thing in the
diagnostics table itself to record which things can be capitalized/how they
should be capitalized - but, yeah, arguably quoting might be the right
thing in many, maybe all, of those cases)




>
> See the screenshots from VSCode on how diagnostics are presented:
> F6901986: image.png  F6901990:
> image.png 
>
>
> Repository:
>   rCTE Clang Tools Extra
>
> https://reviews.llvm.org/D50154
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50448: [CGObjCGNU] Rename GetSelector helper method to fix -Woverloaded-virtual warning (PR38210)

2018-08-08 Thread Simon Pilgrim via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339264: [CGObjCGNU] Rename GetSelector helper method to fix 
-Woverloaded-virtual… (authored by RKSimon, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50448?vs=159709=159732#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50448

Files:
  cfe/trunk/lib/CodeGen/CGObjCGNU.cpp


Index: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
@@ -510,8 +510,8 @@
 
   /// Returns a selector with the specified type encoding.  An empty string is
   /// used to return an untyped selector (with the types field set to NULL).
-  virtual llvm::Value *GetSelector(CodeGenFunction , Selector Sel,
-   const std::string );
+  virtual llvm::Value *GetTypedSelector(CodeGenFunction , Selector Sel,
+const std::string );
 
   /// Returns the name of ivar offset variables.  In the GNUstep v1 ABI, this
   /// contains the class and ivar names, in the v2 ABI this contains the type
@@ -1342,8 +1342,8 @@
   return Val;
 return llvm::ConstantExpr::getBitCast(Val, Ty);
   }
-  llvm::Value *GetSelector(CodeGenFunction , Selector Sel,
-const std::string ) override {
+  llvm::Value *GetTypedSelector(CodeGenFunction , Selector Sel,
+const std::string ) override {
 return GetConstantSelector(Sel, TypeEncoding);
   }
   llvm::Constant  *GetTypeString(llvm::StringRef TypeEncoding) {
@@ -2121,8 +2121,8 @@
   return Value;
 }
 
-llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction , Selector Sel,
-const std::string ) {
+llvm::Value *CGObjCGNU::GetTypedSelector(CodeGenFunction , Selector Sel,
+ const std::string ) {
   SmallVectorImpl  = SelectorTable[Sel];
   llvm::GlobalAlias *SelValue = nullptr;
 
@@ -2155,13 +2155,13 @@
 }
 
 llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction , Selector Sel) {
-  return GetSelector(CGF, Sel, std::string());
+  return GetTypedSelector(CGF, Sel, std::string());
 }
 
 llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction ,
 const ObjCMethodDecl *Method) {
   std::string SelTypes = CGM.getContext().getObjCEncodingForMethodDecl(Method);
-  return GetSelector(CGF, Method->getSelector(), SelTypes);
+  return GetTypedSelector(CGF, Method->getSelector(), SelTypes);
 }
 
 llvm::Constant *CGObjCGNU::GetEHType(QualType T) {


Index: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
@@ -510,8 +510,8 @@
 
   /// Returns a selector with the specified type encoding.  An empty string is
   /// used to return an untyped selector (with the types field set to NULL).
-  virtual llvm::Value *GetSelector(CodeGenFunction , Selector Sel,
-   const std::string );
+  virtual llvm::Value *GetTypedSelector(CodeGenFunction , Selector Sel,
+const std::string );
 
   /// Returns the name of ivar offset variables.  In the GNUstep v1 ABI, this
   /// contains the class and ivar names, in the v2 ABI this contains the type
@@ -1342,8 +1342,8 @@
   return Val;
 return llvm::ConstantExpr::getBitCast(Val, Ty);
   }
-  llvm::Value *GetSelector(CodeGenFunction , Selector Sel,
-const std::string ) override {
+  llvm::Value *GetTypedSelector(CodeGenFunction , Selector Sel,
+const std::string ) override {
 return GetConstantSelector(Sel, TypeEncoding);
   }
   llvm::Constant  *GetTypeString(llvm::StringRef TypeEncoding) {
@@ -2121,8 +2121,8 @@
   return Value;
 }
 
-llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction , Selector Sel,
-const std::string ) {
+llvm::Value *CGObjCGNU::GetTypedSelector(CodeGenFunction , Selector Sel,
+ const std::string ) {
   SmallVectorImpl  = SelectorTable[Sel];
   llvm::GlobalAlias *SelValue = nullptr;
 
@@ -2155,13 +2155,13 @@
 }
 
 llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction , Selector Sel) {
-  return GetSelector(CGF, Sel, std::string());
+  return GetTypedSelector(CGF, Sel, std::string());
 }
 
 llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction ,
 const ObjCMethodDecl *Method) {
   std::string SelTypes = CGM.getContext().getObjCEncodingForMethodDecl(Method);
-  return GetSelector(CGF, Method->getSelector(), SelTypes);
+  return GetTypedSelector(CGF, Method->getSelector(), SelTypes);
 }
 
 llvm::Constant *CGObjCGNU::GetEHType(QualType T) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r339264 - [CGObjCGNU] Rename GetSelector helper method to fix -Woverloaded-virtual warning (PR38210)

2018-08-08 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Wed Aug  8 08:53:14 2018
New Revision: 339264

URL: http://llvm.org/viewvc/llvm-project?rev=339264=rev
Log:
[CGObjCGNU] Rename GetSelector helper method to fix -Woverloaded-virtual 
warning (PR38210)

As suggested by @theraven on PR38210, this patch fixes the gcc 
-Woverloaded-virtual warnings by renaming the extra CGObjCGNU::GetSelector 
method to CGObjCGNU::GetTypedSelector

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

Modified:
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=339264=339263=339264=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Wed Aug  8 08:53:14 2018
@@ -510,8 +510,8 @@ protected:
 
   /// Returns a selector with the specified type encoding.  An empty string is
   /// used to return an untyped selector (with the types field set to NULL).
-  virtual llvm::Value *GetSelector(CodeGenFunction , Selector Sel,
-   const std::string );
+  virtual llvm::Value *GetTypedSelector(CodeGenFunction , Selector Sel,
+const std::string );
 
   /// Returns the name of ivar offset variables.  In the GNUstep v1 ABI, this
   /// contains the class and ivar names, in the v2 ABI this contains the type
@@ -1342,8 +1342,8 @@ class CGObjCGNUstep2 : public CGObjCGNUs
   return Val;
 return llvm::ConstantExpr::getBitCast(Val, Ty);
   }
-  llvm::Value *GetSelector(CodeGenFunction , Selector Sel,
-const std::string ) override {
+  llvm::Value *GetTypedSelector(CodeGenFunction , Selector Sel,
+const std::string ) override {
 return GetConstantSelector(Sel, TypeEncoding);
   }
   llvm::Constant  *GetTypeString(llvm::StringRef TypeEncoding) {
@@ -2121,8 +2121,8 @@ llvm::Value *CGObjCGNU::EmitNSAutoreleas
   return Value;
 }
 
-llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction , Selector Sel,
-const std::string ) {
+llvm::Value *CGObjCGNU::GetTypedSelector(CodeGenFunction , Selector Sel,
+ const std::string ) {
   SmallVectorImpl  = SelectorTable[Sel];
   llvm::GlobalAlias *SelValue = nullptr;
 
@@ -2155,13 +2155,13 @@ Address CGObjCGNU::GetAddrOfSelector(Cod
 }
 
 llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction , Selector Sel) {
-  return GetSelector(CGF, Sel, std::string());
+  return GetTypedSelector(CGF, Sel, std::string());
 }
 
 llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction ,
 const ObjCMethodDecl *Method) {
   std::string SelTypes = CGM.getContext().getObjCEncodingForMethodDecl(Method);
-  return GetSelector(CGF, Method->getSelector(), SelTypes);
+  return GetTypedSelector(CGF, Method->getSelector(), SelTypes);
 }
 
 llvm::Constant *CGObjCGNU::GetEHType(QualType T) {


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


[PATCH] D50413: [libunwind][include] Add some missing definitions to .

2018-08-08 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x updated this revision to Diff 159731.
cdavis5x added a comment.

- Add NetBSD-specific definitions.
- Pull out common declaration of `__personality_routine`.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50413

Files:
  include/unwind.h


Index: include/unwind.h
===
--- include/unwind.h
+++ include/unwind.h
@@ -29,6 +29,32 @@
 #define LIBUNWIND_UNAVAIL
 #endif
 
+#if defined(__NetBSD__)
+typedef long _Unwind_Word;
+#else
+typedef uintptr_t _Unwind_Word;
+#endif
+typedef intptr_t _Unwind_Sword;
+typedef uintptr_t _Unwind_Internal_Ptr;
+typedef uint64_t _Unwind_Exception_Class;
+
+typedef intptr_t _sleb128_t;
+typedef uintptr_t _uleb128_t;
+
+#if _LIBUNWIND_ARM_EHABI
+#if defined(__FreeBSD__)
+typedef void *_Unwind_Ptr;
+#elif defined(__linux__)
+typedef unsigned long *_Unwind_Ptr;
+#else
+typedef uintptr_t _Unwind_Ptr;
+#endif
+#elif defined(__NetBSD__)
+typedef void *_Unwind_Ptr;
+#else
+typedef uintptr_t _Unwind_Ptr;
+#endif
+
 typedef enum {
   _URC_NO_REASON = 0,
   _URC_OK = 0,
@@ -111,7 +137,7 @@
_Unwind_Exception* exceptionObject,
struct _Unwind_Context* context);
 
-typedef _Unwind_Reason_Code (*__personality_routine)
+typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)
   (_Unwind_State state,
_Unwind_Exception* exceptionObject,
struct _Unwind_Context* context);
@@ -150,13 +176,14 @@
  struct _Unwind_Context* context,
  void* stop_parameter );
 
-typedef _Unwind_Reason_Code (*__personality_routine)
+typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)
   (int version,
_Unwind_Action actions,
uint64_t exceptionClass,
_Unwind_Exception* exceptionObject,
struct _Unwind_Context* context);
 #endif
+typedef _Unwind_Personality_Fn __personality_routine;
 
 #ifdef __cplusplus
 extern "C" {


Index: include/unwind.h
===
--- include/unwind.h
+++ include/unwind.h
@@ -29,6 +29,32 @@
 #define LIBUNWIND_UNAVAIL
 #endif
 
+#if defined(__NetBSD__)
+typedef long _Unwind_Word;
+#else
+typedef uintptr_t _Unwind_Word;
+#endif
+typedef intptr_t _Unwind_Sword;
+typedef uintptr_t _Unwind_Internal_Ptr;
+typedef uint64_t _Unwind_Exception_Class;
+
+typedef intptr_t _sleb128_t;
+typedef uintptr_t _uleb128_t;
+
+#if _LIBUNWIND_ARM_EHABI
+#if defined(__FreeBSD__)
+typedef void *_Unwind_Ptr;
+#elif defined(__linux__)
+typedef unsigned long *_Unwind_Ptr;
+#else
+typedef uintptr_t _Unwind_Ptr;
+#endif
+#elif defined(__NetBSD__)
+typedef void *_Unwind_Ptr;
+#else
+typedef uintptr_t _Unwind_Ptr;
+#endif
+
 typedef enum {
   _URC_NO_REASON = 0,
   _URC_OK = 0,
@@ -111,7 +137,7 @@
_Unwind_Exception* exceptionObject,
struct _Unwind_Context* context);
 
-typedef _Unwind_Reason_Code (*__personality_routine)
+typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)
   (_Unwind_State state,
_Unwind_Exception* exceptionObject,
struct _Unwind_Context* context);
@@ -150,13 +176,14 @@
  struct _Unwind_Context* context,
  void* stop_parameter );
 
-typedef _Unwind_Reason_Code (*__personality_routine)
+typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)
   (int version,
_Unwind_Action actions,
uint64_t exceptionClass,
_Unwind_Exception* exceptionObject,
struct _Unwind_Context* context);
 #endif
+typedef _Unwind_Personality_Fn __personality_routine;
 
 #ifdef __cplusplus
 extern "C" {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50413: [libunwind][include] Add some missing definitions to .

2018-08-08 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x marked an inline comment as done.
cdavis5x added a comment.

In https://reviews.llvm.org/D50413#1191726, @krytarowski wrote:

> NetBSD uses `typedef void *_Unwind_Ptr;` unconditionally in its 
> ``... if that has to be matched.


Done.

> Additionally: `typedef long _Unwind_Word;`.

Done.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50413



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


[PATCH] D50448: [CGObjCGNU] Rename GetSelector helper method to fix -Woverloaded-virtual warning (PR38210)

2018-08-08 Thread David Chisnall via Phabricator via cfe-commits
theraven accepted this revision.
theraven added a comment.
This revision is now accepted and ready to land.

Looks good to me.  This method should probably take a StringRef rather than a 
`const std::string&`, but I can make that change separately.


Repository:
  rC Clang

https://reviews.llvm.org/D50448



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


[PATCH] D50413: [libunwind][include] Add some missing definitions to .

2018-08-08 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x added inline comments.



Comment at: include/unwind.h:46
+typedef uintptr_t _Unwind_Ptr;
+#endif
+

mstorsjo wrote:
> What other reference is this list of typedefs for `_Unwind_Ptr` based on? I 
> don't see any of these cases in clang's unwind.h at least.
Where //did// I get those from...? These seem to be for ARM EHABI, but I can't 
find them anymore in the GCC source. They aren't in Clang's header, either. I 
wrote this a while ago... did something change in the meantime?

I could probably get away with removing those special cases if we don't really 
need them.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50413



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


r339261 - Fix -Wdocumentation warnings. NFCI.

2018-08-08 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Wed Aug  8 08:34:00 2018
New Revision: 339261

URL: http://llvm.org/viewvc/llvm-project?rev=339261=rev
Log:
Fix -Wdocumentation warnings. NFCI.

Modified:
cfe/trunk/include/clang/Basic/IdentifierTable.h

Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=339261=339260=339261=diff
==
--- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Wed Aug  8 08:34:00 2018
@@ -50,60 +50,60 @@ using IdentifierLocPair = std::pair *Entry = nullptr;


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


  1   2   >