[libclc] r312854 - integer: Add popcount implementation using ctpop intrinsic

2017-09-08 Thread Aaron Watry via cfe-commits
Author: awatry
Date: Fri Sep  8 19:23:54 2017
New Revision: 312854

URL: http://llvm.org/viewvc/llvm-project?rev=312854=rev
Log:
integer: Add popcount implementation using ctpop intrinsic

Also copy/modify the unary_intrin.inc from math/ to make the
intrinsic declaration somewhat reusable.

Passes CL CTS integer_ops/test_integer_ops popcount tests for CL 1.2

Tested-by on GCN 1.0 (Pitcairn)

Signed-off-by: Aaron Watry 
Reviewed-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/integer/popcount.h
libclc/trunk/generic/include/clc/integer/unary_intrin.inc
Modified:
libclc/trunk/generic/include/clc/clc.h

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=312854=312853=312854=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Fri Sep  8 19:23:54 2017
@@ -126,6 +126,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/integer/popcount.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/integer/popcount.h?rev=312854=auto
==
--- libclc/trunk/generic/include/clc/integer/popcount.h (added)
+++ libclc/trunk/generic/include/clc/integer/popcount.h Fri Sep  8 19:23:54 2017
@@ -0,0 +1,6 @@
+#undef popcount
+#define popcount __clc_popcount
+
+#define __CLC_FUNCTION __clc_popcount
+#define __CLC_INTRINSIC "llvm.ctpop"
+#include 

Added: libclc/trunk/generic/include/clc/integer/unary_intrin.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/integer/unary_intrin.inc?rev=312854=auto
==
--- libclc/trunk/generic/include/clc/integer/unary_intrin.inc (added)
+++ libclc/trunk/generic/include/clc/integer/unary_intrin.inc Fri Sep  8 
19:23:54 2017
@@ -0,0 +1,20 @@
+#define __CLC_INTRINSIC_DEF(SCALAR_TYPE, BIT_SIZE) \
+_CLC_OVERLOAD SCALAR_TYPE __CLC_FUNCTION(SCALAR_TYPE x) __asm(__CLC_INTRINSIC 
".i" BIT_SIZE); \
+_CLC_OVERLOAD SCALAR_TYPE##2 __CLC_FUNCTION(SCALAR_TYPE##2 x) 
__asm(__CLC_INTRINSIC ".v2i" BIT_SIZE); \
+_CLC_OVERLOAD SCALAR_TYPE##3 __CLC_FUNCTION(SCALAR_TYPE##3 x) 
__asm(__CLC_INTRINSIC ".v3i" BIT_SIZE); \
+_CLC_OVERLOAD SCALAR_TYPE##4 __CLC_FUNCTION(SCALAR_TYPE##4 x) 
__asm(__CLC_INTRINSIC ".v4i" BIT_SIZE); \
+_CLC_OVERLOAD SCALAR_TYPE##8 __CLC_FUNCTION(SCALAR_TYPE##8 x) 
__asm(__CLC_INTRINSIC ".v8i" BIT_SIZE); \
+_CLC_OVERLOAD SCALAR_TYPE##16 __CLC_FUNCTION(SCALAR_TYPE##16 x) 
__asm(__CLC_INTRINSIC ".v16i" BIT_SIZE);
+
+__CLC_INTRINSIC_DEF(char, "8")
+__CLC_INTRINSIC_DEF(uchar, "8")
+__CLC_INTRINSIC_DEF(short, "16")
+__CLC_INTRINSIC_DEF(ushort, "16")
+__CLC_INTRINSIC_DEF(int, "32")
+__CLC_INTRINSIC_DEF(uint, "32")
+__CLC_INTRINSIC_DEF(long, "64")
+__CLC_INTRINSIC_DEF(ulong, "64")
+
+#undef __CLC_FUNCTION
+#undef __CLC_INTRINSIC
+#undef __CLC_INTRINSIC_DEF


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


r312851 - Fix ownership of the MemoryBuffer in a FrontendInputFile.

2017-09-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Sep  8 18:14:04 2017
New Revision: 312851

URL: http://llvm.org/viewvc/llvm-project?rev=312851=rev
Log:
Fix ownership of the MemoryBuffer in a FrontendInputFile.

This fixes a possible crash on certain kinds of corrupted AST file, but
checking in an AST file corrupted in just the right way will be a maintenance
nightmare because the format changes frequently.

Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/lib/Basic/SourceManager.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=312851=312850=312851=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Fri Sep  8 18:14:04 2017
@@ -212,12 +212,6 @@ namespace SrcMgr {
 /// this content cache.  This is used for performance analysis.
 llvm::MemoryBuffer::BufferKind getMemoryBufferKind() const;
 
-void setBuffer(std::unique_ptr B) {
-  assert(!Buffer.getPointer() && "MemoryBuffer already set.");
-  Buffer.setPointer(B.release());
-  Buffer.setInt(0);
-}
-
 /// \brief Get the underlying buffer, returning NULL if the buffer is not
 /// yet available.
 llvm::MemoryBuffer *getRawBuffer() const { return Buffer.getPointer(); }
@@ -816,7 +810,22 @@ public:
   SrcMgr::CharacteristicKind FileCharacter = 
SrcMgr::C_User,
   int LoadedID = 0, unsigned LoadedOffset = 0,
   SourceLocation IncludeLoc = SourceLocation()) {
-return createFileID(createMemBufferContentCache(std::move(Buffer)),
+return createFileID(
+createMemBufferContentCache(Buffer.release(), /*DoNotFree*/ false),
+IncludeLoc, FileCharacter, LoadedID, LoadedOffset);
+  }
+
+  enum UnownedTag { Unowned };
+
+  /// \brief Create a new FileID that represents the specified memory buffer.
+  ///
+  /// This does no caching of the buffer and takes ownership of the
+  /// MemoryBuffer, so only pass a MemoryBuffer to this once.
+  FileID createFileID(UnownedTag, llvm::MemoryBuffer *Buffer,
+  SrcMgr::CharacteristicKind FileCharacter = 
SrcMgr::C_User,
+  int LoadedID = 0, unsigned LoadedOffset = 0,
+  SourceLocation IncludeLoc = SourceLocation()) {
+return createFileID(createMemBufferContentCache(Buffer, /*DoNotFree*/true),
 IncludeLoc, FileCharacter, LoadedID, LoadedOffset);
   }
 
@@ -1699,7 +1708,7 @@ private:
 
   /// \brief Create a new ContentCache for the specified  memory buffer.
   const SrcMgr::ContentCache *
-  createMemBufferContentCache(std::unique_ptr Buf);
+  createMemBufferContentCache(llvm::MemoryBuffer *Buf, bool DoNotFree);
 
   FileID getFileIDSlow(unsigned SLocOffset) const;
   FileID getFileIDLocal(unsigned SLocOffset) const;

Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=312851=312850=312851=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Fri Sep  8 18:14:04 2017
@@ -128,21 +128,24 @@ class FrontendInputFile {
   /// \brief The file name, or "-" to read from standard input.
   std::string File;
 
-  llvm::MemoryBuffer *Buffer;
+  /// The input, if it comes from a buffer rather than a file. This object
+  /// does not own the buffer, and the caller is responsible for ensuring
+  /// that it outlives any users.
+  llvm::MemoryBuffer *Buffer = nullptr;
 
   /// \brief The kind of input, e.g., C source, AST file, LLVM IR.
   InputKind Kind;
 
   /// \brief Whether we're dealing with a 'system' input (vs. a 'user' input).
-  bool IsSystem;
+  bool IsSystem = false;
 
 public:
-  FrontendInputFile() : Buffer(nullptr), Kind(), IsSystem(false) { }
+  FrontendInputFile() { }
   FrontendInputFile(StringRef File, InputKind Kind, bool IsSystem = false)
-: File(File.str()), Buffer(nullptr), Kind(Kind), IsSystem(IsSystem) { }
-  FrontendInputFile(llvm::MemoryBuffer *buffer, InputKind Kind,
+: File(File.str()), Kind(Kind), IsSystem(IsSystem) { }
+  FrontendInputFile(llvm::MemoryBuffer *Buffer, InputKind Kind,
 bool IsSystem = false)
-: Buffer(buffer), Kind(Kind), IsSystem(IsSystem) { }
+: Buffer(Buffer), Kind(Kind), IsSystem(IsSystem) { }
 
   InputKind getKind() const { return Kind; }
   bool isSystem() const { return IsSystem; }

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: 

r312850 - [cxx_status] Change "Clang 5" items from yellow to green now that Clang 5 has been released.

2017-09-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Sep  8 18:11:04 2017
New Revision: 312850

URL: http://llvm.org/viewvc/llvm-project?rev=312850=rev
Log:
[cxx_status] Change "Clang 5" items from yellow to green now that Clang 5 has 
been released.

Modified:
cfe/trunk/www/cxx_dr_status.html
cfe/trunk/www/cxx_status.html
cfe/trunk/www/make_cxx_dr_status

Modified: cfe/trunk/www/cxx_dr_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=312850=312849=312850=diff
==
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Fri Sep  8 18:11:04 2017
@@ -1937,7 +1937,7 @@ of class templates
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#316;>316
 NAD
 Injected-class-name of template used as template template 
parameter
-Superseded by 1004
+Superseded by 1004
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#317;>317
@@ -1949,7 +1949,7 @@ of class templates
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#318;>318
 CD1
 struct A::A should not name the constructor of A
-Superseded by 1310
+Superseded by 1310
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#319;>319
@@ -2279,7 +2279,7 @@ of class templates
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#373;>373
 C++11
 Lookup on namespace qualified name in using-directive
-Clang 5
+Clang 5
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374;>374
@@ -3017,7 +3017,7 @@ of class templates
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#496;>496
 CD3
 Is a volatile-qualified type really a POD?
-Superseded by 2094
+Superseded by 2094
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#497;>497
@@ -5839,7 +5839,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1004;>1004
 C++11
 Injected-class-names as arguments for template template parameters
-Clang 5
+Clang 5
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1005;>1005
@@ -7405,7 +7405,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1265;>1265
 CD3
 Mixed use of the auto specifier
-Clang 5
+Clang 5
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1266;>1266
@@ -7675,7 +7675,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1310;>1310
 CD3
 What is an acceptable lookup result?
-Clang 5
+Clang 5
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1311;>1311
@@ -9481,7 +9481,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1611;>1611
 C++14
 Deleted default constructor for abstract class
-Duplicate of 1658
+Duplicate of 1658
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1612;>1612
@@ -9763,7 +9763,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1658;>1658
 C++14
 Deleted default constructor for abstract class via destructor
-Clang 5
+Clang 5
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1659;>1659
@@ -12379,7 +12379,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094;>2094
 DR
 Trivial copy/move constructor for class with volatile member
-Clang 5
+Clang 5
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2095;>2095

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=312850=312849=312850=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Fri Sep  8 18:11:04 2017
@@ -648,7 +648,7 @@ of the C++ 2017 Draft International Stan
 
   constexpr lambda expressions
   http://wg21.link/p0170r1;>P0170R1
-  Clang 5
+  Clang 5
 
 
   Differing begin and end types in range-based 
for
@@ -684,7 +684,7 @@ of the C++ 2017 Draft International Stan
 
   Template argument deduction for class templates
   http://wg21.link/p0091r3;>P0091R3
-  Clang 5
+  Clang 5
 

 http://wg21.link/p0512r0;>P0512R0
@@ -878,7 +878,7 @@ and library features that are not part o
   
 
 
-  
+  
 Clang 5 (http://wg21.link/p0096r4;>P0096R4)
   
 
@@ -906,7 +906,7 @@ and library features that are not part o
   [DRAFT TS] Coroutines
   https://isocpp.org/files/papers/N4663.pdf;>N4663
   -fcoroutines-ts-stdlib=libc++
-  Clang 5
+  Clang 5
 
 
   [TS] Library Fundamentals, Version 1 (invocation type traits)

Modified: cfe/trunk/www/make_cxx_dr_status

[PATCH] D37656: [cfi] Set function attributes for __cfi_* functions.

2017-09-08 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis created this revision.
Herald added subscribers: hiraditya, kristof.beyls, srhines, aemerson.

Set target_cpu and target_features attributes on __cfi_check_fail and
__cfi_check. Make cfi_check use Thumb encoding on ARM target.


https://reviews.llvm.org/D37656

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/cfi-check-thumb.c
  llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
  llvm/test/Transforms/CrossDSOCFI/thumb.ll

Index: llvm/test/Transforms/CrossDSOCFI/thumb.ll
===
--- llvm/test/Transforms/CrossDSOCFI/thumb.ll
+++ /dev/null
@@ -1,22 +0,0 @@
-; RUN: opt -mtriple=armv7-linux-android -S -cross-dso-cfi < %s | FileCheck --check-prefix=THUMB %s
-; RUN: opt -mtriple=thumbv7-linux-android -S -cross-dso-cfi < %s | FileCheck --check-prefix=THUMB %s
-; RUN: opt -mtriple=i386-linux -S -cross-dso-cfi < %s | FileCheck --check-prefix=NOTHUMB %s
-; RUN: opt -mtriple=x86_64-linux -S -cross-dso-cfi < %s | FileCheck --check-prefix=NOTHUMB %s
-
-target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
-
-define signext i8 @f() !type !0 !type !1 {
-entry:
-  ret i8 1
-}
-
-!llvm.module.flags = !{!2}
-
-!0 = !{i64 0, !"_ZTSFcvE"}
-!1 = !{i64 0, i64 111}
-!2 = !{i32 4, !"Cross-DSO CFI", i32 1}
-
-; THUMB: define void @__cfi_check({{.*}} #[[A:.*]] align 4096
-; THUMB: attributes #[[A]] = { {{.*}}"target-features"="+thumb-mode"
-
-; NOTHUMB: define void @__cfi_check({{.*}} align 4096
Index: llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
===
--- llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
+++ llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
@@ -117,10 +117,6 @@
   F->deleteBody();
   F->setAlignment(4096);
 
-  Triple T(M.getTargetTriple());
-  if (T.isARM() || T.isThumb())
-F->addFnAttr("target-features", "+thumb-mode");
-
   auto args = F->arg_begin();
   Value  = *(args++);
   CallSiteTypeId.setName("CallSiteTypeId");
Index: clang/test/CodeGen/cfi-check-thumb.c
===
--- /dev/null
+++ clang/test/CodeGen/cfi-check-thumb.c
@@ -0,0 +1,18 @@
+// Test that __cfi_check and __cfi_check_fail have common attributes and calling convention.
+// Also __cfi_check is always using Thumb encoding.
+// RUN: %clang_cc1 -triple arm-unknown-linux -O0 -fsanitize-cfi-cross-dso \
+// RUN: -fsanitize=cfi-vcall \
+// RUN: -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,CHECK-ARM %s
+//
+// RUN: %clang_cc1 -triple thumb-unknown-linux -O0 -fsanitize-cfi-cross-dso \
+// RUN: -fsanitize=cfi-vcall \
+// RUN: -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,CHECK-THUMB %s
+//
+// REQUIRES: arm-registered-target
+
+// CHECK-ARM: define weak_odr hidden void @__cfi_check_fail(i8*, i8*) #[[ARM:.*]] {
+// CHECK-THUMB: define weak_odr hidden void @__cfi_check_fail(i8*, i8*) #[[THUMB:.*]] {
+// CHECK: define weak void @__cfi_check(i64, i8*, i8*) #[[THUMB:.*]] {
+
+// CHECK-ARM: attributes #[[ARM]] = {{.*}}"target-features"="{{.*}}-thumb-mode
+// CHECK: attributes #[[THUMB]] = {{.*}}"target-features"="{{.*}}+thumb-mode
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -2912,6 +2912,33 @@
   EmitBlock(Cont);
 }
 
+static void AddTargetAttributes(llvm::AttrBuilder ,
+CodeGenFunction , llvm::Function *F,
+bool ForceThumb) {
+  StringRef TargetCPU = CGF.getTarget().getTargetOpts().CPU;
+  if (TargetCPU != "")
+Builder.addAttribute("target-cpu", TargetCPU);
+
+  std::vector  =
+  CGF.getTarget().getTargetOpts().Features;
+  const auto  = CGF.getTarget().getTriple();
+  SmallVector Features;
+  Features.reserve(DefaultFeatures.size() + ForceThumb);
+  if (ForceThumb && (Triple.isARM() || Triple.isThumb())) {
+for (auto  : DefaultFeatures)
+  if (S != "-thumb-mode" && S != "+thumb-mode")
+Features.push_back(S);
+Features.push_back("+thumb-mode");
+  } else {
+for (auto  : DefaultFeatures)
+  Features.push_back(S);
+  }
+
+  std::sort(Features.begin(), Features.end());
+  Builder.addAttribute("target-features",
+   llvm::join(Features.begin(), Features.end(), ","));
+}
+
 // Emit a stub for __cfi_check function so that the linker knows about this
 // symbol in LTO mode.
 void CodeGenFunction::EmitCfiCheckStub() {
@@ -2928,6 +2955,15 @@
   llvm::CallInst::Create(
   llvm::Intrinsic::getDeclaration(M, llvm::Intrinsic::trap), "", BB);
   llvm::ReturnInst::Create(Ctx, nullptr, BB);
+
+  // Set default target-cpu and target-features, but force thumb encoding if
+  // applicable. Note that we don't want the whole set of default function
+  // attributes as SetLLVMFunctionAttributes sets. In particular, __cfi_check
+  // must use the default calling convention for the platform. ABI-changing
+  // 

r312842 - Catch more cases with -Wenum-compare

2017-09-08 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Sep  8 17:25:05 2017
New Revision: 312842

URL: http://llvm.org/viewvc/llvm-project?rev=312842=rev
Log:
Catch more cases with -Wenum-compare

Treat typedef enum as named enums instead of anonymous enums.  Anonymous enums
are ignored by the warning, so previously, typedef enums were ignored as well.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/SemaCXX/warn-enum-compare.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=312842=312841=312842=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Sep  8 17:25:05 2017
@@ -9151,9 +9151,11 @@ static void checkEnumComparison(Sema ,
 return;
 
   // Ignore anonymous enums.
-  if (!LHSEnumType->getDecl()->getIdentifier())
+  if (!LHSEnumType->getDecl()->getIdentifier() &&
+  !LHSEnumType->getDecl()->getTypedefNameForAnonDecl())
 return;
-  if (!RHSEnumType->getDecl()->getIdentifier())
+  if (!RHSEnumType->getDecl()->getIdentifier() &&
+  !RHSEnumType->getDecl()->getTypedefNameForAnonDecl())
 return;
 
   if (S.Context.hasSameUnqualifiedType(LHSStrippedType, RHSStrippedType))

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=312842=312841=312842=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Fri Sep  8 17:25:05 2017
@@ -754,9 +754,11 @@ static void checkEnumTypesInSwitchStmt(S
 return;
 
   // Ignore anonymous enums.
-  if (!CondEnumType->getDecl()->getIdentifier())
+  if (!CondEnumType->getDecl()->getIdentifier() &&
+  !CondEnumType->getDecl()->getTypedefNameForAnonDecl())
 return;
-  if (!CaseEnumType->getDecl()->getIdentifier())
+  if (!CaseEnumType->getDecl()->getIdentifier() &&
+  !CaseEnumType->getDecl()->getTypedefNameForAnonDecl())
 return;
 
   if (S.Context.hasSameUnqualifiedType(CondType, CaseType))

Modified: cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-enum-compare.cpp?rev=312842=312841=312842=diff
==
--- cfe/trunk/test/SemaCXX/warn-enum-compare.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-enum-compare.cpp Fri Sep  8 17:25:05 2017
@@ -4,6 +4,8 @@ enum Foo { FooA, FooB, FooC };
 enum Bar { BarD, BarE, BarF };
 enum { AnonAA = 42, AnonAB = 43 };
 enum { AnonBA = 44, AnonBB = 45 };
+enum { Anon1, Anon2, Anon3 };
+typedef enum { TD1, TD2 } TD;
 
 namespace name1 {
   enum Foo {F1, F2, F3};
@@ -29,6 +31,7 @@ void test () {
   name1::Foo a;
   oneFoo b;
   twoFoo c;
+  TD td;
 
   while (x == FooA);
   while (y == BarD);
@@ -65,6 +68,9 @@ void test () {
   while ((B1) == (((name1::B2;
   while (B2 == ((name2::B1)));
 
+  while (td == Anon1);
+  while (td == AnonAA);  // expected-warning {{comparison of constant 'AnonAA' 
(42) with expression of type 'TD' is always false}}
+
   while (B1 == B2); // expected-warning  {{comparison of two values with 
different enumeration types ('name1::Baz' and 'name2::Baz')}}
   while (name1::B2 == name2::B3); // expected-warning  {{comparison of two 
values with different enumeration types ('name1::Baz' and 'name2::Baz')}}
   while (z == name2::B2); // expected-warning  {{comparison of two values with 
different enumeration types ('name1::Baz' and 'name2::Baz')}}
@@ -209,6 +215,24 @@ void test () {
   while (getBar() > x); // expected-warning  {{comparison of two values with 
different enumeration types ('Bar' and 'Foo')}}
   while (getBar() < x); // expected-warning  {{comparison of two values with 
different enumeration types ('Bar' and 'Foo')}}
 
+  while (td == FooA); // expected-warning  {{comparison of two values with 
different enumeration types ('TD' and 'Foo')}}
+  while (td == BarD); // expected-warning  {{comparison of two values with 
different enumeration types ('TD' and 'Bar')}}
+  while (name1::F1 == td); // expected-warning  {{comparison of two values 
with different enumeration types ('name1::Foo' and 'TD')}}
+  while (name2::B1 == td); // expected-warning  {{comparison of two values 
with different enumeration types ('name2::Baz' and 'TD')}}
+  while (td == a); // expected-warning  {{comparison of two values with 
different enumeration types ('TD' and 'name1::Foo')}}
+  while (td == b); // expected-warning  {{comparison of two values with 
different enumeration types ('TD' and 'oneFoo' (aka 'name1::Foo'))}}
+  while (td == c); // expected-warning  {{comparison of two values with 
different enumeration types ('TD' and 'twoFoo' (aka 'name1::Foo'))}}
+  while (td == x); // expected-warning  {{comparison of two values with 
different enumeration types 

[PATCH] D37529: [codeview] omit debug locations for nested exprs unless column info enabled

2017-09-08 Thread Bob Haarman via Phabricator via cfe-commits
inglorion updated this revision to Diff 114465.
inglorion added a comment.

Of course, ApplyDebugLocation is also a perfectly legitimate way to add a debug 
location to nodes that are not nested inside nodes that already have a 
location. I updated the diff so that we do end up applying the location in such 
cases.


https://reviews.llvm.org/D37529

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGenCXX/debug-info-nested-exprs.cpp

Index: clang/test/CodeGenCXX/debug-info-nested-exprs.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-nested-exprs.cpp
@@ -0,0 +1,202 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited \
+// RUN:-std=c++11 -gcodeview -emit-llvm -o - %s \
+// RUN:| FileCheck -check-prefix=NONEST %s
+// RUN: %clang_cc1 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited \
+// RUN:-std=c++11 -gcodeview -dwarf-column-info -emit-llvm -o - %s \
+// RUN:| FileCheck -check-prefix=COLUMNS %s
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -debug-info-kind=limited \
+// RUN:-std=c++11 -emit-llvm -o - %s | FileCheck -check-prefix=NESTED %s
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -debug-info-kind=limited \
+// RUN:-std=c++11 -dwarf-column-info -emit-llvm -o - %s \
+// RUN:| FileCheck -check-prefix=COLUMNS %s
+
+class Foo {
+public:
+  static Foo create();
+  void func();
+  int *begin();
+  int *end();
+};
+
+int bar(int x, int y);
+int baz(int x, int y);
+int qux(int x, int y);
+int onearg(int x);
+int noargs();
+int noargs1();
+Foo range(int x);
+
+int foo(int x, int y, int z) {
+  int a = bar(x, y) +
+  baz(x, z) +
+  qux(y, z);
+  // NONEST: call i32 @{{.*}}bar{{.*}}, !dbg ![[LOC:[0-9]+]]
+  // NONEST: call i32 @{{.*}}baz{{.*}}, !dbg ![[LOC]]
+  // NONEST: call i32 @{{.*}}qux{{.*}}, !dbg ![[LOC]]
+  // NONEST: store i32 {{.*}}, i32* %a,{{.*}} !dbg ![[LOC]]
+  // NESTED: call i32 @{{.*}}bar{{.*}}, !dbg ![[BAR:[0-9]+]]
+  // NESTED: call i32 @{{.*}}baz{{.*}}, !dbg ![[BAZ:[0-9]+]]
+  // NESTED: call i32 @{{.*}}qux{{.*}}, !dbg ![[QUX:[0-9]+]]
+  // NESTED: store i32 {{.*}}, i32* %a,{{.*}} !dbg ![[BAR]]
+  // COLUMNS: call i32 @{{.*}}bar{{.*}}, !dbg ![[BAR:[0-9]+]]
+  // COLUMNS: call i32 @{{.*}}baz{{.*}}, !dbg ![[BAZ:[0-9]+]]
+  // COLUMNS: call i32 @{{.*}}qux{{.*}}, !dbg ![[QUX:[0-9]+]]
+  // COLUMNS: store i32 {{.*}}, i32* %a,{{.*}} !dbg ![[DECLA:[0-9]+]]
+
+  int i = 1, b = 0, c = 0;
+  // NONEST: store i32 1, i32* %i,{{.*}} !dbg ![[ILOC:[0-9]+]]
+  // NONEST: store i32 0, i32* %b,{{.*}} !dbg ![[ILOC]]
+  // NONEST: store i32 0, i32* %c,{{.*}} !dbg ![[ILOC]]
+  // NESTED: store i32 1, i32* %i,{{.*}} !dbg ![[ILOC:[0-9]+]]
+  // NESTED: store i32 0, i32* %b,{{.*}} !dbg ![[ILOC]]
+  // NESTED: store i32 0, i32* %c,{{.*}} !dbg ![[ILOC]]
+  // COLUMNS: store i32 1, i32* %i,{{.*}} !dbg ![[ILOC:[0-9]+]]
+  // COLUMNS: store i32 0, i32* %b,{{.*}} !dbg ![[BLOC:[0-9]+]]
+  // COLUMNS: store i32 0, i32* %c,{{.*}} !dbg ![[CLOC:[0-9]+]]
+
+  while (i > 0) {
+b = bar(a, b);
+--i;
+  }
+  // NONEST: call i32 @{{.*}}bar{{.*}}, !dbg ![[WHILE1:[0-9]+]]
+  // NONEST: store i32 %{{[^,]+}}, i32* %i,{{.*}} !dbg ![[WHILE2:[0-9]+]]
+  // NESTED: call i32 @{{.*}}bar{{.*}}, !dbg ![[WHILE1:[0-9]+]]
+  // NESTED: store i32 %{{[^,]+}}, i32* %i,{{.*}} !dbg ![[WHILE2:[0-9]+]]
+  // COLUMNS: call i32 @{{.*}}bar{{.*}}, !dbg ![[WHILE1:[0-9]+]]
+  // COLUMNS: store i32 %{{[^,]+}}, i32* %i,{{.*}} !dbg ![[WHILE2:[0-9]+]]
+
+  for (i = 0; i < 1; i++) {
+b = bar(a, b);
+c = qux(a, c);
+  }
+  // NONEST: call i32 @{{.*}}bar{{.*}}, !dbg ![[FOR1:[0-9]+]]
+  // NONEST: call i32 @{{.*}}qux{{.*}}, !dbg ![[FOR2:[0-9]+]]
+  // NESTED: call i32 @{{.*}}bar{{.*}}, !dbg ![[FOR1:[0-9]+]]
+  // NESTED: call i32 @{{.*}}qux{{.*}}, !dbg ![[FOR2:[0-9]+]]
+  // COLUMNS: call i32 @{{.*}}bar{{.*}}, !dbg ![[FOR1:[0-9]+]]
+  // COLUMNS: call i32 @{{.*}}qux{{.*}}, !dbg ![[FOR2:[0-9]+]]
+
+  if (a < b) {
+int t = a;
+a = b;
+b = t;
+  }
+  // NONEST: store i32 %{{[^,]+}}, i32* %t,{{.*}} !dbg ![[IF1:[0-9]+]]
+  // NONEST: store i32 %{{[^,]+}}, i32* %a,{{.*}} !dbg ![[IF2:[0-9]+]]
+  // NONEST: store i32 %{{[^,]+}}, i32* %b,{{.*}} !dbg ![[IF3:[0-9]+]]
+  // NESTED: store i32 %{{[^,]+}}, i32* %t,{{.*}} !dbg ![[IF1:[0-9]+]]
+  // NESTED: store i32 %{{[^,]+}}, i32* %a,{{.*}} !dbg ![[IF2:[0-9]+]]
+  // NESTED: store i32 %{{[^,]+}}, i32* %b,{{.*}} !dbg ![[IF3:[0-9]+]]
+  // COLUMNS: store i32 %{{[^,]+}}, i32* %t,{{.*}} !dbg ![[IF1:[0-9]+]]
+  // COLUMNS: store i32 %{{[^,]+}}, i32* %a,{{.*}} !dbg ![[IF2:[0-9]+]]
+  // COLUMNS: store i32 %{{[^,]+}}, i32* %b,{{.*}} !dbg ![[IF3:[0-9]+]]
+
+  int d = onearg(
+  noargs());
+  // NONEST: call i32 @{{.*}}noargs{{.*}}, !dbg ![[DECLD:[0-9]+]]
+  // NONEST: call i32 @{{.*}}onearg{{.*}}, !dbg ![[DECLD]]
+  // NONEST: store i32 %{{[^,]+}}, i32* %d,{{.*}} !dbg ![[DECLD]]
+  // NESTED: call i32 

[libclc] r312839 - Implement vload_half{,n} and vload(half)

2017-09-08 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Sep  8 16:59:00 2017
New Revision: 312839

URL: http://llvm.org/viewvc/llvm-project?rev=312839=rev
Log:
Implement vload_half{,n} and vload(half)

v2: add vload(half) as well
make helpers amdgpu specific (NVPTX uses different private AS numbering)
use clang builtin on clang >= 6

Signed-off-by: Jan Vesely 
Reviewed-by: Tom Stellard 

Added:
libclc/trunk/amdgpu/lib/shared/vload_half_helpers.ll
libclc/trunk/generic/lib/shared/vload_half.inc
Modified:
libclc/trunk/amdgpu/lib/SOURCES_4.0
libclc/trunk/amdgpu/lib/SOURCES_5.0
libclc/trunk/generic/include/clc/shared/vload.h
libclc/trunk/generic/lib/shared/vload.cl

Modified: libclc/trunk/amdgpu/lib/SOURCES_4.0
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgpu/lib/SOURCES_4.0?rev=312839=312838=312839=diff
==
--- libclc/trunk/amdgpu/lib/SOURCES_4.0 (original)
+++ libclc/trunk/amdgpu/lib/SOURCES_4.0 Fri Sep  8 16:59:00 2017
@@ -1 +1,2 @@
+shared/vload_half_helpers.ll
 shared/vstore_half_helpers.ll

Modified: libclc/trunk/amdgpu/lib/SOURCES_5.0
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgpu/lib/SOURCES_5.0?rev=312839=312838=312839=diff
==
--- libclc/trunk/amdgpu/lib/SOURCES_5.0 (original)
+++ libclc/trunk/amdgpu/lib/SOURCES_5.0 Fri Sep  8 16:59:00 2017
@@ -1 +1,2 @@
+shared/vload_half_helpers.ll
 shared/vstore_half_helpers.ll

Added: libclc/trunk/amdgpu/lib/shared/vload_half_helpers.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgpu/lib/shared/vload_half_helpers.ll?rev=312839=auto
==
--- libclc/trunk/amdgpu/lib/shared/vload_half_helpers.ll (added)
+++ libclc/trunk/amdgpu/lib/shared/vload_half_helpers.ll Fri Sep  8 16:59:00 
2017
@@ -0,0 +1,23 @@
+define float @__clc_vload_half_float_helper__private(half addrspace(0)* 
nocapture %ptr) nounwind alwaysinline {
+  %data = load half, half addrspace(0)* %ptr
+  %res = fpext half %data to float
+  ret float %res
+}
+
+define float @__clc_vload_half_float_helper__global(half addrspace(1)* 
nocapture %ptr) nounwind alwaysinline {
+  %data = load half, half addrspace(1)* %ptr
+  %res = fpext half %data to float
+  ret float %res
+}
+
+define float @__clc_vload_half_float_helper__local(half addrspace(3)* 
nocapture %ptr) nounwind alwaysinline {
+  %data = load half, half addrspace(3)* %ptr
+  %res = fpext half %data to float
+  ret float %res
+}
+
+define float @__clc_vload_half_float_helper__constant(half addrspace(2)* 
nocapture %ptr) nounwind alwaysinline {
+  %data = load half, half addrspace(2)* %ptr
+  %res = fpext half %data to float
+  ret float %res
+}

Modified: libclc/trunk/generic/include/clc/shared/vload.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/shared/vload.h?rev=312839=312838=312839=diff
==
--- libclc/trunk/generic/include/clc/shared/vload.h (original)
+++ libclc/trunk/generic/include/clc/shared/vload.h Fri Sep  8 16:59:00 2017
@@ -1,18 +1,21 @@
-#define _CLC_VLOAD_DECL(PRIM_TYPE, VEC_TYPE, WIDTH, ADDR_SPACE) \
-  _CLC_OVERLOAD _CLC_DECL VEC_TYPE vload##WIDTH(size_t offset, const 
ADDR_SPACE PRIM_TYPE *x);
+#define _CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, VEC_TYPE, WIDTH, ADDR_SPACE) \
+  _CLC_OVERLOAD _CLC_DECL VEC_TYPE vload##SUFFIX##WIDTH(size_t offset, const 
ADDR_SPACE MEM_TYPE *x);
 
-#define _CLC_VECTOR_VLOAD_DECL(PRIM_TYPE, ADDR_SPACE) \
-  _CLC_VLOAD_DECL(PRIM_TYPE, PRIM_TYPE##2, 2, ADDR_SPACE) \
-  _CLC_VLOAD_DECL(PRIM_TYPE, PRIM_TYPE##3, 3, ADDR_SPACE) \
-  _CLC_VLOAD_DECL(PRIM_TYPE, PRIM_TYPE##4, 4, ADDR_SPACE) \
-  _CLC_VLOAD_DECL(PRIM_TYPE, PRIM_TYPE##8, 8, ADDR_SPACE) \
-  _CLC_VLOAD_DECL(PRIM_TYPE, PRIM_TYPE##16, 16, ADDR_SPACE)
+#define _CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, ADDR_SPACE) \
+  _CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##2, 2, ADDR_SPACE) \
+  _CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##3, 3, ADDR_SPACE) \
+  _CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##4, 4, ADDR_SPACE) \
+  _CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##8, 8, ADDR_SPACE) \
+  _CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##16, 16, ADDR_SPACE)
+
+#define _CLC_VECTOR_VLOAD_PRIM3(SUFFIX, MEM_TYPE, PRIM_TYPE) \
+  _CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __private) \
+  _CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __local) \
+  _CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __constant) \
+  _CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __global) \
 
 #define _CLC_VECTOR_VLOAD_PRIM1(PRIM_TYPE) \
-  _CLC_VECTOR_VLOAD_DECL(PRIM_TYPE, __private) \
-  _CLC_VECTOR_VLOAD_DECL(PRIM_TYPE, __local) \
-  _CLC_VECTOR_VLOAD_DECL(PRIM_TYPE, __constant) \
-  _CLC_VECTOR_VLOAD_DECL(PRIM_TYPE, __global) \
+  

[libclc] r312838 - vstore: Cleanup and add vstore(half)

2017-09-08 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Sep  8 16:58:57 2017
New Revision: 312838

URL: http://llvm.org/viewvc/llvm-project?rev=312838=rev
Log:
vstore: Cleanup and add vstore(half)

Add missing undefs
Make helpers amdgpu specific (NVPTX uses different numbering for private AS)
Use clang builtins on clang >= 6

Signed-off-by: Jan Vesely 
Reviewed-by: Tom Stellard 

Added:
libclc/trunk/amdgpu/lib/SOURCES_4.0
libclc/trunk/amdgpu/lib/SOURCES_5.0
libclc/trunk/amdgpu/lib/shared/
libclc/trunk/amdgpu/lib/shared/vstore_half_helpers.ll
  - copied, changed from r312837, 
libclc/trunk/generic/lib/shared/vstore_half_helpers.ll
Removed:
libclc/trunk/generic/lib/shared/vstore_half_helpers.ll
Modified:
libclc/trunk/generic/include/clc/shared/vstore.h
libclc/trunk/generic/lib/SOURCES
libclc/trunk/generic/lib/shared/vstore.cl

Added: libclc/trunk/amdgpu/lib/SOURCES_4.0
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgpu/lib/SOURCES_4.0?rev=312838=auto
==
--- libclc/trunk/amdgpu/lib/SOURCES_4.0 (added)
+++ libclc/trunk/amdgpu/lib/SOURCES_4.0 Fri Sep  8 16:58:57 2017
@@ -0,0 +1 @@
+shared/vstore_half_helpers.ll

Added: libclc/trunk/amdgpu/lib/SOURCES_5.0
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgpu/lib/SOURCES_5.0?rev=312838=auto
==
--- libclc/trunk/amdgpu/lib/SOURCES_5.0 (added)
+++ libclc/trunk/amdgpu/lib/SOURCES_5.0 Fri Sep  8 16:58:57 2017
@@ -0,0 +1 @@
+shared/vstore_half_helpers.ll

Copied: libclc/trunk/amdgpu/lib/shared/vstore_half_helpers.ll (from r312837, 
libclc/trunk/generic/lib/shared/vstore_half_helpers.ll)
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgpu/lib/shared/vstore_half_helpers.ll?p2=libclc/trunk/amdgpu/lib/shared/vstore_half_helpers.ll=libclc/trunk/generic/lib/shared/vstore_half_helpers.ll=312837=312838=312838=diff
==
(empty)

Modified: libclc/trunk/generic/include/clc/shared/vstore.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/shared/vstore.h?rev=312838=312837=312838=diff
==
--- libclc/trunk/generic/include/clc/shared/vstore.h (original)
+++ libclc/trunk/generic/include/clc/shared/vstore.h Fri Sep  8 16:58:57 2017
@@ -29,7 +29,6 @@
 _CLC_VECTOR_VSTORE_PRIM3(_half, half, float)
 
 #ifdef cl_khr_fp64
-#pragma OPENCL EXTENSION cl_khr_fp64: enable
   _CLC_VECTOR_VSTORE_PRIM1(double)
   _CLC_VECTOR_VSTORE_PRIM3(_half, half, double)
   _CLC_VSTORE_DECL(_half, half, double, , __private)
@@ -37,7 +36,17 @@
   _CLC_VSTORE_DECL(_half, half, double, , __global)
 #endif
 
+#ifdef cl_khr_fp16
+  _CLC_VECTOR_VSTORE_PRIM1(half)
+#endif
+
 _CLC_VECTOR_VSTORE_PRIM()
 _CLC_VSTORE_DECL(_half, half, float, , __private)
 _CLC_VSTORE_DECL(_half, half, float, , __local)
 _CLC_VSTORE_DECL(_half, half, float, , __global)
+
+#undef _CLC_VSTORE_DECL
+#undef _CLC_VECTOR_VSTORE_DECL
+#undef _CLC_VECTOR_VSTORE_PRIM3
+#undef _CLC_VECTOR_VSTORE_PRIM1
+#undef _CLC_VECTOR_VSTORE_PRIM

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=312838=312837=312838=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Fri Sep  8 16:58:57 2017
@@ -147,7 +147,6 @@ shared/max.cl
 shared/min.cl
 shared/vload.cl
 shared/vstore.cl
-shared/vstore_half_helpers.ll
 workitem/get_global_id.cl
 workitem/get_global_size.cl
 image/get_image_dim.cl

Modified: libclc/trunk/generic/lib/shared/vstore.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/shared/vstore.cl?rev=312838=312837=312838=diff
==
--- libclc/trunk/generic/lib/shared/vstore.cl (original)
+++ libclc/trunk/generic/lib/shared/vstore.cl Fri Sep  8 16:58:57 2017
@@ -50,23 +50,34 @@ VSTORE_TYPES()
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 VSTORE_ADDR_SPACES(double)
 #endif
+#ifdef cl_khr_fp16
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+VSTORE_ADDR_SPACES(half)
+#endif
 
 /* vstore_half are legal even without cl_khr_fp16 */
-#define DECLARE_HELPER(STYPE, AS) void 
__clc_vstore_half_##STYPE##_helper##AS(STYPE, AS half *);
+#if __clang_major__ < 6
+#define DECLARE_HELPER(STYPE, AS, builtin) void 
__clc_vstore_half_##STYPE##_helper##AS(STYPE, AS half *);
+#else
+#define DECLARE_HELPER(STYPE, AS, __builtin) \
+inline void __clc_vstore_half_##STYPE##_helper##AS(STYPE s, AS half *d) \
+{ \
+   __builtin(s, d); \
+}
+#endif
 
-DECLARE_HELPER(float, __private);
-DECLARE_HELPER(float, __global);
-DECLARE_HELPER(float, __local);
+DECLARE_HELPER(float, __private, 

[libclc] r312837 - configure.py: Simplify compatibility sources

2017-09-08 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri Sep  8 16:58:53 2017
New Revision: 312837

URL: http://llvm.org/viewvc/llvm-project?rev=312837=rev
Log:
configure.py: Simplify compatibility sources

Just add the SOURCE_X.Y list to the list of sources if X.Y is the current llvm 
version.

Signed-off-by: Jan Vesely 
Reviewed-by: Tom Stellard 

Modified:
libclc/trunk/configure.py

Modified: libclc/trunk/configure.py
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/configure.py?rev=312837=312836=312837=diff
==
--- libclc/trunk/configure.py (original)
+++ libclc/trunk/configure.py Fri Sep  8 16:58:53 2017
@@ -70,7 +70,7 @@ def llvm_config(args):
 
 llvm_version = llvm_config(['--version']).replace('svn', '').split('.')
 llvm_int_version = int(llvm_version[0]) * 100 + int(llvm_version[1]) * 10
-llvm_string_version = 'LLVM' + llvm_version[0] + '.' + llvm_version[1]
+llvm_string_version = llvm_version[0] + '.' + llvm_version[1]
 
 if llvm_int_version < 400:
 print("libclc requires LLVM >= 4.0")
@@ -202,7 +202,7 @@ for target in targets:
 
 objects = []
 sources_seen = set()
-compats_seen = set()
+compats = []
 
 if device['gpu'] == '':
   full_target_name = target
@@ -222,7 +222,7 @@ for target in targets:
   if os.path.exists(compat_list_file):
 for compat in open(compat_list_file).readlines():
   compat = compat.rstrip()
-  compats_seen.add(compat)
+  compats.append(compat)
 
   # Add target overrides
   if os.path.exists(override_list_file):
@@ -230,15 +230,13 @@ for target in targets:
   override = override.rstrip()
   sources_seen.add(override)
 
-  for src in open(subdir_list_file).readlines():
+  for src in open(subdir_list_file).readlines() + compats:
 src = src.rstrip()
 if src not in sources_seen:
   sources_seen.add(src)
   obj = os.path.join(target, 'lib', src + obj_suffix + '.bc')
   objects.append(obj)
   src_path = libdir
-  if src in compats_seen:
-src_path = os.path.join(libdir, llvm_string_version)
   src_file = os.path.join(src_path, src)
   ext = os.path.splitext(src)[1]
   if ext == '.ll':


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


[PATCH] D37564: Update users of llvm::sys::ExecuteAndWait etc.

2017-09-08 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Looks good to me.


https://reviews.llvm.org/D37564



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


Re: [PATCH] D37529: [codeview] omit debug locations for nested exprs unless column info enabled

2017-09-08 Thread Zachary Turner via cfe-commits
Well, if they worked I wasn't going to say we needed to add tests for them,
i just wanted to make sure they work before we move onto something else.
In any case, lgtm

On Fri, Sep 8, 2017 at 4:43 PM Bob Haarman via Phabricator <
revi...@reviews.llvm.org> wrote:

> inglorion updated this revision to Diff 114463.
> inglorion added a comment.
>
> added examples suggested by @zturner, verified step over and step into
> specific behavior matches MSVC, and added tests for them
>
>
> https://reviews.llvm.org/D37529
>
> Files:
>   clang/lib/CodeGen/CGDebugInfo.cpp
>   clang/lib/CodeGen/CodeGenModule.h
>   clang/test/CodeGenCXX/debug-info-nested-exprs.cpp
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37529: [codeview] omit debug locations for nested exprs unless column info enabled

2017-09-08 Thread Bob Haarman via Phabricator via cfe-commits
inglorion updated this revision to Diff 114463.
inglorion added a comment.

added examples suggested by @zturner, verified step over and step into specific 
behavior matches MSVC, and added tests for them


https://reviews.llvm.org/D37529

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGenCXX/debug-info-nested-exprs.cpp

Index: clang/test/CodeGenCXX/debug-info-nested-exprs.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-nested-exprs.cpp
@@ -0,0 +1,202 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited \
+// RUN:-std=c++11 -gcodeview -emit-llvm -o - %s \
+// RUN:| FileCheck -check-prefix=NONEST %s
+// RUN: %clang_cc1 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited \
+// RUN:-std=c++11 -gcodeview -dwarf-column-info -emit-llvm -o - %s \
+// RUN:| FileCheck -check-prefix=COLUMNS %s
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -debug-info-kind=limited \
+// RUN:-std=c++11 -emit-llvm -o - %s | FileCheck -check-prefix=NESTED %s
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -debug-info-kind=limited \
+// RUN:-std=c++11 -dwarf-column-info -emit-llvm -o - %s \
+// RUN:| FileCheck -check-prefix=COLUMNS %s
+
+class Foo {
+public:
+  static Foo create();
+  void func();
+  int *begin();
+  int *end();
+};
+
+int bar(int x, int y);
+int baz(int x, int y);
+int qux(int x, int y);
+int onearg(int x);
+int noargs();
+int noargs1();
+Foo range(int x);
+
+int foo(int x, int y, int z) {
+  int a = bar(x, y) +
+  baz(x, z) +
+  qux(y, z);
+  // NONEST: call i32 @{{.*}}bar{{.*}}, !dbg ![[LOC:[0-9]+]]
+  // NONEST: call i32 @{{.*}}baz{{.*}}, !dbg ![[LOC]]
+  // NONEST: call i32 @{{.*}}qux{{.*}}, !dbg ![[LOC]]
+  // NONEST: store i32 {{.*}}, i32* %a,{{.*}} !dbg ![[LOC]]
+  // NESTED: call i32 @{{.*}}bar{{.*}}, !dbg ![[BAR:[0-9]+]]
+  // NESTED: call i32 @{{.*}}baz{{.*}}, !dbg ![[BAZ:[0-9]+]]
+  // NESTED: call i32 @{{.*}}qux{{.*}}, !dbg ![[QUX:[0-9]+]]
+  // NESTED: store i32 {{.*}}, i32* %a,{{.*}} !dbg ![[BAR]]
+  // COLUMNS: call i32 @{{.*}}bar{{.*}}, !dbg ![[BAR:[0-9]+]]
+  // COLUMNS: call i32 @{{.*}}baz{{.*}}, !dbg ![[BAZ:[0-9]+]]
+  // COLUMNS: call i32 @{{.*}}qux{{.*}}, !dbg ![[QUX:[0-9]+]]
+  // COLUMNS: store i32 {{.*}}, i32* %a,{{.*}} !dbg ![[DECLA:[0-9]+]]
+
+  int i = 1, b = 0, c = 0;
+  // NONEST: store i32 1, i32* %i,{{.*}} !dbg ![[ILOC:[0-9]+]]
+  // NONEST: store i32 0, i32* %b,{{.*}} !dbg ![[ILOC]]
+  // NONEST: store i32 0, i32* %c,{{.*}} !dbg ![[ILOC]]
+  // NESTED: store i32 1, i32* %i,{{.*}} !dbg ![[ILOC:[0-9]+]]
+  // NESTED: store i32 0, i32* %b,{{.*}} !dbg ![[ILOC]]
+  // NESTED: store i32 0, i32* %c,{{.*}} !dbg ![[ILOC]]
+  // COLUMNS: store i32 1, i32* %i,{{.*}} !dbg ![[ILOC:[0-9]+]]
+  // COLUMNS: store i32 0, i32* %b,{{.*}} !dbg ![[BLOC:[0-9]+]]
+  // COLUMNS: store i32 0, i32* %c,{{.*}} !dbg ![[CLOC:[0-9]+]]
+
+  while (i > 0) {
+b = bar(a, b);
+--i;
+  }
+  // NONEST: call i32 @{{.*}}bar{{.*}}, !dbg ![[WHILE1:[0-9]+]]
+  // NONEST: store i32 %{{[^,]+}}, i32* %i,{{.*}} !dbg ![[WHILE2:[0-9]+]]
+  // NESTED: call i32 @{{.*}}bar{{.*}}, !dbg ![[WHILE1:[0-9]+]]
+  // NESTED: store i32 %{{[^,]+}}, i32* %i,{{.*}} !dbg ![[WHILE2:[0-9]+]]
+  // COLUMNS: call i32 @{{.*}}bar{{.*}}, !dbg ![[WHILE1:[0-9]+]]
+  // COLUMNS: store i32 %{{[^,]+}}, i32* %i,{{.*}} !dbg ![[WHILE2:[0-9]+]]
+
+  for (i = 0; i < 1; i++) {
+b = bar(a, b);
+c = qux(a, c);
+  }
+  // NONEST: call i32 @{{.*}}bar{{.*}}, !dbg ![[FOR1:[0-9]+]]
+  // NONEST: call i32 @{{.*}}qux{{.*}}, !dbg ![[FOR2:[0-9]+]]
+  // NESTED: call i32 @{{.*}}bar{{.*}}, !dbg ![[FOR1:[0-9]+]]
+  // NESTED: call i32 @{{.*}}qux{{.*}}, !dbg ![[FOR2:[0-9]+]]
+  // COLUMNS: call i32 @{{.*}}bar{{.*}}, !dbg ![[FOR1:[0-9]+]]
+  // COLUMNS: call i32 @{{.*}}qux{{.*}}, !dbg ![[FOR2:[0-9]+]]
+
+  if (a < b) {
+int t = a;
+a = b;
+b = t;
+  }
+  // NONEST: store i32 %{{[^,]+}}, i32* %t,{{.*}} !dbg ![[IF1:[0-9]+]]
+  // NONEST: store i32 %{{[^,]+}}, i32* %a,{{.*}} !dbg ![[IF2:[0-9]+]]
+  // NONEST: store i32 %{{[^,]+}}, i32* %b,{{.*}} !dbg ![[IF3:[0-9]+]]
+  // NESTED: store i32 %{{[^,]+}}, i32* %t,{{.*}} !dbg ![[IF1:[0-9]+]]
+  // NESTED: store i32 %{{[^,]+}}, i32* %a,{{.*}} !dbg ![[IF2:[0-9]+]]
+  // NESTED: store i32 %{{[^,]+}}, i32* %b,{{.*}} !dbg ![[IF3:[0-9]+]]
+  // COLUMNS: store i32 %{{[^,]+}}, i32* %t,{{.*}} !dbg ![[IF1:[0-9]+]]
+  // COLUMNS: store i32 %{{[^,]+}}, i32* %a,{{.*}} !dbg ![[IF2:[0-9]+]]
+  // COLUMNS: store i32 %{{[^,]+}}, i32* %b,{{.*}} !dbg ![[IF3:[0-9]+]]
+
+  int d = onearg(
+  noargs());
+  // NONEST: call i32 @{{.*}}noargs{{.*}}, !dbg ![[DECLD:[0-9]+]]
+  // NONEST: call i32 @{{.*}}onearg{{.*}}, !dbg ![[DECLD]]
+  // NONEST: store i32 %{{[^,]+}}, i32* %d,{{.*}} !dbg ![[DECLD]]
+  // NESTED: call i32 @{{.*}}noargs{{.*}}, !dbg ![[DNOARGS:[0-9]+]]
+  // NESTED: call i32 @{{.*}}onearg{{.*}}, !dbg ![[DECLD:[0-9]+]]

r312835 - CodeGen: correct arguments for NSFastEnumeration

2017-09-08 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Sep  8 16:41:17 2017
New Revision: 312835

URL: http://llvm.org/viewvc/llvm-project?rev=312835=rev
Log:
CodeGen: correct arguments for NSFastEnumeration

When performing a NSFastEnumeration, the compiler synthesizes a call to
`countByEnumeratingWithState:objects:count:` where the `count` parameter
is of type `NSUInteger` and the return type is a `NSUInteger`.  We would
previously always use a `UnsignedLongTy` for the `NSUInteger` type.  On
32-bit targets, `long` is 32-bits which is the same as `unsigned int`.
Most 64-bit targets are LP64, where `long` is 64-bits.  However, on
LLP64 targets, such as Windows, `long` is 32-bits.  Introduce new
`getNSUIntegerType` and `getNSIntegerType` helpers to allow us to
determine the correct type for the `NSUInteger` type.  Wire those
through into the generation of the message dispatch to the selector.

Added:
cfe/trunk/test/CodeGenObjC/NSFastEnumeration.m
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/CodeGen/CGObjC.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=312835=312834=312835=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Fri Sep  8 16:41:17 2017
@@ -39,6 +39,7 @@
 #include "clang/Basic/SanitizerBlacklist.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
+#include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/XRayLists.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -89,7 +90,6 @@ class DiagnosticsEngine;
 class Expr;
 class MangleNumberingContext;
 class MaterializeTemporaryExpr;
-class TargetInfo;
 // Decls
 class MangleContext;
 class ObjCIvarDecl;
@@ -1582,6 +1582,24 @@ public:
 return NSCopyingName;
   }
 
+  CanQualType getNSUIntegerType() const {
+assert(Target && "Expected target to be initialized");
+const llvm::Triple  = Target->getTriple();
+// Windows is LLP64 rather than LP64
+if (T.isOSWindows() && T.isArch64Bit())
+  return UnsignedLongLongTy;
+return UnsignedLongTy;
+  }
+
+  CanQualType getNSIntegerType() const {
+assert(Target && "Expected target to be initialized");
+const llvm::Triple  = Target->getTriple();
+// Windows is LLP64 rather than LP64
+if (T.isOSWindows() && T.isArch64Bit())
+  return LongLongTy;
+return LongTy;
+  }
+
   /// Retrieve the identifier 'bool'.
   IdentifierInfo *getBoolName() const {
 if (!BoolName)

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=312835=312834=312835=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Fri Sep  8 16:41:17 2017
@@ -1546,16 +1546,15 @@ void CodeGenFunction::EmitObjCForCollect
getContext().getPointerType(ItemsTy));
 
   // The third argument is the capacity of that temporary array.
-  llvm::Type *UnsignedLongLTy = ConvertType(getContext().UnsignedLongTy);
-  llvm::Constant *Count = llvm::ConstantInt::get(UnsignedLongLTy, NumItems);
-  Args.add(RValue::get(Count), getContext().UnsignedLongTy);
+  llvm::Type *NSUIntegerTy = ConvertType(getContext().getNSUIntegerType());
+  llvm::Constant *Count = llvm::ConstantInt::get(NSUIntegerTy, NumItems);
+  Args.add(RValue::get(Count), getContext().getNSUIntegerType());
 
   // Start the enumeration.
   RValue CountRV =
-CGM.getObjCRuntime().GenerateMessageSend(*this, ReturnValueSlot(),
- getContext().UnsignedLongTy,
- FastEnumSel,
- Collection, Args);
+  CGM.getObjCRuntime().GenerateMessageSend(*this, ReturnValueSlot(),
+   
getContext().getNSUIntegerType(),
+   FastEnumSel, Collection, Args);
 
   // The initial number of objects that were returned in the buffer.
   llvm::Value *initialBufferLimit = CountRV.getScalarVal();
@@ -1563,7 +1562,7 @@ void CodeGenFunction::EmitObjCForCollect
   llvm::BasicBlock *EmptyBB = createBasicBlock("forcoll.empty");
   llvm::BasicBlock *LoopInitBB = createBasicBlock("forcoll.loopinit");
 
-  llvm::Value *zero = llvm::Constant::getNullValue(UnsignedLongLTy);
+  llvm::Value *zero = llvm::Constant::getNullValue(NSUIntegerTy);
 
   // If the limit pointer was zero to begin with, the collection is
   // empty; skip all this. Set the branch weight assuming this has the same
@@ -1595,11 +1594,11 @@ void CodeGenFunction::EmitObjCForCollect
   EmitBlock(LoopBodyBB);
 
   // The current index into the buffer.
-  llvm::PHINode *index = Builder.CreatePHI(UnsignedLongLTy, 3, 
"forcoll.index");
+  llvm::PHINode 

[PATCH] D37470: [analyzer] Handle ObjC messages conservatively in CallDescription

2017-09-08 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Can you add a test?


Repository:
  rL LLVM

https://reviews.llvm.org/D37470



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


Buildbot numbers for the week of 08/27/2017 - 09/02/2017

2017-09-08 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 08/27/2017 -
09/02/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

   buildername| was_red
--+-
 clang-cmake-x86_64-avx2-linux-perf   | 29:54:46
 sanitizer-ppc64be-linux  | 21:55:55
 sanitizer-x86_64-linux   | 19:49:02
 sanitizer-ppc64le-linux  | 19:27:52
 perf-x86_64-penryn-O3-polly-fast | 16:26:53
 clang-cmake-thumbv7-a15-full-sh  | 16:13:42
 clang-bpf-build  | 15:07:59
 sanitizer-x86_64-linux-bootstrap | 14:07:01
 sanitizer-x86_64-linux-android   | 13:13:14
 perf-x86_64-penryn-O3-polly  | 13:05:37
 polly-arm-linux  | 11:52:41
 sanitizer-x86_64-linux-fast  | 11:31:12
 lldb-amd64-ninja-netbsd8 | 09:33:25
 clang-atom-d525-fedora-rel   | 08:46:31
 clang-x86_64-linux-selfhost-modules-2| 07:33:59
 llvm-mips-linux  | 07:27:48
 clang-with-lto-ubuntu| 07:26:52
 llvm-clang-x86_64-expensive-checks-win   | 06:52:15
 clang-with-thin-lto-ubuntu   | 06:43:30
 clang-lld-x86_64-2stage  | 06:29:21
 clang-cmake-armv7-a15-selfhost   | 06:25:31
 clang-cmake-x86_64-avx2-linux| 05:53:36
 sanitizer-x86_64-linux-autoconf  | 04:22:14
 clang-ppc64be-linux  | 04:21:16
 clang-x86-windows-msvc2015   | 04:17:13
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 04:11:20
 lld-x86_64-darwin13  | 04:08:09
 clang-cmake-aarch64-lld  | 03:57:09
 clang-cuda-build | 03:52:32
 clang-cmake-aarch64-full | 03:49:03
 clang-x86_64-linux-selfhost-modules  | 03:47:02
 clang-cmake-x86_64-sde-avx512-linux  | 03:43:59
 ubuntu-gcc7.1-werror | 03:37:40
 clang-ppc64le-linux-multistage   | 03:30:57
 clang-ppc64le-linux-lnt  | 03:17:35
 clang-s390x-linux| 03:16:31
 clang-cmake-thumbv7-a15  | 03:16:17
 clang-ppc64be-linux-lnt  | 03:14:21
 clang-ppc64le-linux  | 03:03:39
 clang-cmake-armv7-a15| 03:02:57
 clang-hexagon-elf| 02:55:57
 llvm-hexagon-elf | 02:55:56
 clang-cmake-armv7-a15-full   | 02:49:32
 lldb-windows7-android| 02:44:56
 clang-with-thin-lto-windows  | 02:43:50
 clang-ppc64be-linux-multistage   | 02:40:08
 clang-cmake-aarch64-global-isel  | 02:32:34
 lld-x86_64-win7  | 02:30:28
 sanitizer-windows| 02:25:33
 clang-cmake-aarch64-quick| 02:22:42
 lldb-x86_64-darwin-13.4  | 02:12:27
 clang-x86_64-debian-fast | 02:07:27
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03   | 01:47:49
 clang-x64-ninja-win7 | 01:37:49
 lldb-x86-windows-msvc2015| 01:37:49
 lldb-x86_64-ubuntu-14.04-cmake   | 01:24:21
 sanitizer-x86_64-linux-fuzzer| 01:19:54
 clang-cmake-aarch64-42vma| 01:05:10
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 01:01:31
 clang-x86_64-linux-abi-test  | 00:59:27
 lldb-amd64-ninja-freebsd11   | 00:57:59
 lldb-x86_64-ubuntu-14.04-buildserver | 00:52:46
 clang-native-arm-lnt | 00:50:47
 lld-x86_64-freebsd   | 00:38:17
 clang-cmake-armv7-a15-selfhost-neon  | 00:36:04
 polly-amd64-linux| 00:24:30
 llvm-sphinx-docs | 00:16:56
 clang-tools-sphinx-docs  | 00:05:46
 clang-sphinx-docs| 00:05:46
(69 rows)


"Status 

[PATCH] D37649: [Driver] Support ubsan-minimal on Darwin

2017-09-08 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

Make it possible to use the minimal ubsan runtime on Darwin.


https://reviews.llvm.org/D37649

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


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -254,6 +254,13 @@
 // CHECK-UBSAN-MINIMAL-LINUX: "-whole-archive" 
"{{.*}}libclang_rt.ubsan_minimal-i386.a" "-no-whole-archive"
 // CHECK-UBSAN-MINIMAL-LINUX: "-lpthread"
 
+// RUN: %clang -fsanitize=undefined -fsanitize-minimal-runtime %s -### -o %t.o 
2>&1 \
+// RUN: -target x86_64-apple-darwin -fuse-ld=ld \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-UBSAN-MINIMAL-DARWIN %s
+// CHECK-UBSAN-MINIMAL-DARWIN: "{{.*}}ld{{(.exe)?}}"
+// CHECK-UBSAN-MINIMAL-DARWIN: 
"{{.*}}libclang_rt.ubsan_minimal_osx_dynamic.dylib"
+
 // RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1039,7 +1039,9 @@
   if (Sanitize.needsLsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan");
   if (Sanitize.needsUbsanRt())
-AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
+AddLinkSanitizerLibArgs(Args, CmdArgs,
+Sanitize.requiresMinimalRuntime() ? "ubsan_minimal"
+  : "ubsan");
   if (Sanitize.needsTsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
   if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib)) {


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -254,6 +254,13 @@
 // CHECK-UBSAN-MINIMAL-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan_minimal-i386.a" "-no-whole-archive"
 // CHECK-UBSAN-MINIMAL-LINUX: "-lpthread"
 
+// RUN: %clang -fsanitize=undefined -fsanitize-minimal-runtime %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-apple-darwin -fuse-ld=ld \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-UBSAN-MINIMAL-DARWIN %s
+// CHECK-UBSAN-MINIMAL-DARWIN: "{{.*}}ld{{(.exe)?}}"
+// CHECK-UBSAN-MINIMAL-DARWIN: "{{.*}}libclang_rt.ubsan_minimal_osx_dynamic.dylib"
+
 // RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1039,7 +1039,9 @@
   if (Sanitize.needsLsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan");
   if (Sanitize.needsUbsanRt())
-AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
+AddLinkSanitizerLibArgs(Args, CmdArgs,
+Sanitize.requiresMinimalRuntime() ? "ubsan_minimal"
+  : "ubsan");
   if (Sanitize.needsTsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
   if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Buildbot numbers for the week of 08/20/2017 - 08/26/2017

2017-09-08 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for last the week of 08/20/2017 -
08/26/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

  buildername  |  was_red
---+--
 perf-x86_64-penryn-O3-polly   | 46:50:13
 perf-x86_64-penryn-O3-polly-detect-only   | 42:05:45
 perf-x86_64-penryn-O3-polly-fast  | 40:45:58
 clang-cmake-aarch64-full  | 22:45:50
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions | 21:12:15
 sanitizer-x86_64-linux-bootstrap  | 20:03:48
 clang-bpf-build   | 19:21:43
 clang-lld-x86_64-2stage   | 17:26:37
 sanitizer-ppc64le-linux   | 14:34:41
 ubuntu-gcc7.1-werror  | 13:10:34
 sanitizer-x86_64-linux| 12:09:21
 clang-with-lto-ubuntu | 11:37:41
 clang-with-thin-lto-ubuntu| 11:26:17
 sanitizer-ppc64be-linux   | 11:04:31
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 10:40:24
 clang-x64-ninja-win7  | 08:51:31
 llvm-clang-x86_64-expensive-checks-win| 08:11:23
 llvm-mips-linux   | 06:10:31
 clang-cmake-aarch64-quick | 05:50:13
 clang-cmake-armv7-a15-selfhost| 05:29:37
 clang-ppc64le-linux-multistage| 05:24:08
 clang-cmake-armv7-a15-selfhost-neon   | 04:19:49
 sanitizer-x86_64-linux-fast   | 04:17:41
 clang-cmake-aarch64-lld   | 04:00:21
 clang-s390x-linux-multistage  | 03:51:53
 sanitizer-x86_64-linux-fuzzer | 03:45:05
 clang-cmake-thumbv7-a15-full-sh   | 03:43:38
 clang-s390x-linux | 03:40:21
 clang-x86-windows-msvc2015| 03:33:19
 lldb-windows7-android | 03:15:49
 clang-x86_64-debian-fast  | 03:08:57
 clang-ppc64le-linux   | 03:03:10
 clang-cmake-aarch64-42vma | 02:57:57
 clang-ppc64be-linux   | 02:52:27
 clang-cuda-build  | 02:48:00
 clang-hexagon-elf | 02:47:35
 clang-atom-d525-fedora-rel| 02:45:35
 clang-ppc64be-linux-multistage| 02:45:04
 clang-cmake-armv7-a15 | 02:44:54
 clang-cmake-thumbv7-a15   | 02:44:46
 clang-cmake-armv7-a15-full| 02:38:57
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 02:37:22
 clang-x86_64-linux-selfhost-modules-2 | 02:37:00
 clang-ppc64le-linux-lnt   | 02:36:01
 clang-cmake-x86_64-sde-avx512-linux   | 02:34:18
 sanitizer-x86_64-linux-android| 02:24:01
 clang-cmake-x86_64-avx2-linux | 02:22:10
 clang-cmake-aarch64-global-isel   | 02:21:25
 clang-cmake-x86_64-avx2-linux-perf| 02:20:48
 clang-native-arm-lnt  | 02:12:07
 clang-s390x-linux-lnt | 02:04:20
 clang-with-thin-lto-windows   | 02:00:33
 lldb-x86_64-ubuntu-14.04-cmake| 01:58:18
 clang-ppc64be-linux-lnt   | 01:55:57
 clang-x86_64-linux-selfhost-modules   | 01:55:22
 clang-x86_64-linux-abi-test   | 01:50:57
 lld-x86_64-freebsd| 01:49:24
 sanitizer-x86_64-linux-autoconf   | 01:43:10
 lldb-x86_64-darwin-13.4   | 01:41:39
 sanitizer-windows | 01:21:34
 libcxx-libcxxabi-libunwind-arm-linux  | 01:20:24
 llvm-hexagon-elf  | 01:09:45
 lld-x86_64-win7   | 01:06:18
 lldb-x86_64-ubuntu-14.04-buildserver  | 

Buildbot numbers for the week of 08/13/2017 - 08/19/2017

2017-09-08 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 08/13/2017 - 08/19/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername | was_red
+-
 clang-ppc64le-linux-lnt| 52:15:02
 clang-with-thin-lto-ubuntu | 45:50:37
 clang-with-lto-ubuntu  | 45:47:28
 clang-cuda-build   | 39:35:06
 sanitizer-windows  | 30:09:22
 clang-x86_64-debian-fast   | 27:29:32
 clang-cmake-x86_64-avx2-linux-perf | 25:29:12
 clang-lld-x86_64-2stage| 24:47:55
 clang-cmake-x86_64-avx2-linux  | 24:37:29
 clang-bpf-build| 20:51:26
 perf-x86_64-penryn-O3  | 20:47:21
 perf-x86_64-penryn-O3-polly| 20:41:57
 clang-x64-ninja-win7   | 19:51:04
 perf-x86_64-penryn-O3-polly-detect-only| 19:27:37
 sanitizer-x86_64-linux-autoconf| 18:54:22
 clang-cmake-armv7-a15-selfhost | 09:03:56
 clang-ppc64le-linux-multistage | 08:43:06
 clang-cmake-armv7-a15-selfhost-neon| 08:29:12
 clang-cmake-aarch64-global-isel| 08:16:10
 clang-ppc64be-linux-lnt| 08:13:14
 clang-cmake-aarch64-quick  | 07:56:17
 clang-ppc64be-linux| 07:23:50
 clang-s390x-linux-lnt  | 07:20:14
 llvm-mips-linux| 07:19:34
 sanitizer-ppc64le-linux| 07:11:33
 clang-ppc64le-linux| 07:03:44
 perf-x86_64-penryn-O3-polly-fast   | 06:29:34
 sanitizer-ppc64be-linux| 06:02:25
 polly-arm-linux| 06:02:09
 clang-ppc64be-linux-multistage | 05:54:40
 polly-amd64-linux  | 05:48:33
 clang-cmake-aarch64-lld| 05:34:08
 clang-native-arm-lnt   | 05:20:00
 sanitizer-x86_64-linux-android | 04:09:41
 clang-with-thin-lto-windows| 04:00:05
 sanitizer-x86_64-linux-bootstrap   | 03:52:11
 clang-x86-windows-msvc2015 | 03:39:56
 clang-s390x-linux-multistage   | 03:21:49
 lldb-windows7-android  | 03:13:33
 ubuntu-gcc7.1-werror   | 02:41:47
 clang-x86_64-linux-abi-test| 02:40:25
 clang-s390x-linux  | 02:38:05
 clang-cmake-aarch64-42vma  | 02:29:15
 lld-x86_64-darwin13| 02:25:33
 clang-cmake-armv7-a15-full | 02:14:41
 sanitizer-x86_64-linux | 02:12:30
 lldb-amd64-ninja-netbsd8   | 02:04:24
 lldb-x86-windows-msvc2015  | 02:01:55
 sanitizer-x86_64-linux-fuzzer  | 01:59:30
 clang-atom-d525-fedora-rel | 01:56:30
 llvm-hexagon-elf   | 01:50:01
 clang-x86_64-linux-selfhost-modules-2  | 01:37:31
 lldb-x86_64-darwin-13.4| 01:36:26
 clang-x86_64-linux-selfhost-modules| 01:24:39
 lldb-x86_64-ubuntu-14.04-android   | 01:18:00
 clang-cmake-armv7-a15  | 00:53:59
 clang-cmake-thumbv7-a15| 00:53:15
 clang-hexagon-elf  | 00:51:40
 lldb-x86_64-ubuntu-14.04-buildserver   | 00:51:29
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan  | 00:47:58
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 00:40:49
 lldb-x86_64-ubuntu-14.04-cmake | 00:38:01
 lld-x86_64-freebsd | 00:26:55
 lldb-amd64-ninja-freebsd11 | 00:20:13
 lld-x86_64-win7| 00:14:41
 lld-sphinx-docs| 00:09:34
 clang-tools-sphinx-docs| 00:09:31
 llvm-sphinx-docs   | 00:09:25
 clang-sphinx-docs  | 00:09:18
(69 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):

buildername | builds |
changes | status_change_ratio

++-+
 clang-bpf-build| 72 |
11 |15.3
 

Buildbot numbers for the week of 08/06/2017 - 08/12/2017

2017-09-08 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 08/06/2017 - 08/12/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername | was_red
+-
 sanitizer-x86_64-linux-fast| 75:05:34
 sanitizer-x86_64-linux-bootstrap   | 74:59:09
 clang-ppc64be-linux-lnt| 65:49:04
 clang-ppc64le-linux-multistage | 60:42:09
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 50:15:20
 perf-x86_64-penryn-O3-polly-fast   | 46:18:42
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 41:28:01
 clang-cmake-x86_64-avx2-linux-perf | 34:25:25
 perf-x86_64-penryn-O3-polly| 32:50:55
 llvm-mips-linux| 29:46:14
 perf-x86_64-penryn-O3  | 27:31:40
 clang-x86-windows-msvc2015 | 25:28:47
 clang-lld-x86_64-2stage| 25:00:42
 perf-x86_64-penryn-O3-polly-unprofitable   | 23:52:12
 perf-x86_64-penryn-O3-polly-parallel-fast  | 23:51:36
 clang-cmake-x86_64-avx2-linux  | 22:34:56
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only  | 21:56:36
 lldb-windows7-android  | 20:43:18
 lldb-x86_64-ubuntu-14.04-android   | 19:59:26
 lldb-x86_64-darwin-13.4| 19:56:11
 clang-atom-d525-fedora-rel | 19:52:28
 clang-ppc64be-linux-multistage | 19:33:41
 clang-ppc64le-linux-lnt| 19:29:25
 clang-with-lto-ubuntu  | 19:28:26
 clang-with-thin-lto-ubuntu | 19:18:01
 clang-ppc64le-linux| 19:10:44
 clang-s390x-linux-lnt  | 18:57:30
 clang-cmake-thumbv7-a15-full-sh| 18:52:32
 clang-x86_64-linux-selfhost-modules| 18:44:25
 clang-x86_64-linux-selfhost-modules-2  | 18:36:17
 clang-ppc64be-linux| 18:20:04
 clang-cmake-armv7-a15-selfhost | 17:42:02
 clang-x64-ninja-win7   | 17:31:27
 clang-s390x-linux-multistage   | 17:23:57
 lldb-x86_64-ubuntu-14.04-cmake | 17:08:49
 clang-s390x-linux  | 17:03:46
 clang-bpf-build| 16:58:20
 sanitizer-x86_64-linux-android | 16:32:14
 clang-cmake-armv7-a15-full | 15:48:43
 clang-cmake-armv7-a15-selfhost-neon| 13:51:40
 polly-arm-linux| 06:29:58
 clang-cmake-armv7-a15  | 05:45:31
 clang-cmake-thumbv7-a15| 05:44:12
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions  | 05:16:25
 libcxx-libcxxabi-libunwind-aarch64-linux   | 05:15:48
 libcxx-libcxxabi-libunwind-arm-linux   | 05:15:28
 libcxx-libcxxabi-libunwind-arm-linux-noexceptions  | 05:14:33
 sanitizer-x86_64-linux | 04:48:24
 ubuntu-gcc7.1-werror   | 04:33:01
 clang-with-thin-lto-windows| 04:14:52
 clang-tools-sphinx-docs| 04:05:56
 clang-cmake-aarch64-lld| 03:53:19
 sanitizer-ppc64le-linux| 03:04:56
 sanitizer-ppc64be-linux| 02:49:07
 lld-x86_64-darwin13| 02:00:17
 clang-cmake-aarch64-quick  | 01:59:55
 sanitizer-x86_64-linux-fuzzer  | 01:55:22
 lldb-x86_64-ubuntu-14.04-buildserver   | 01:51:02
 lldb-x86-windows-msvc2015  | 01:23:04
 

Buildbot numbers for the week of 07/30/2017 - 08/05/2017

2017-09-08 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 07/30/2017 - 08/05/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername |  was_red
+--
 clang-x86_64-linux-selfhost-modules-2  | 119:41:05
 clang-x86_64-linux-selfhost-modules| 119:19:49
 clang-ppc64le-linux-multistage | 57:04:10
 aosp-O3-polly-before-vectorizer-unprofitable   | 47:48:00
 sanitizer-x86_64-linux-android | 39:04:10
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 29:22:26
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only  | 29:13:00
 perf-x86_64-penryn-O3-polly| 26:24:24
 sanitizer-ppc64be-linux| 24:39:32
 sanitizer-ppc64le-linux| 24:22:07
 clang-cmake-x86_64-avx2-linux-perf | 21:56:09
 clang-ppc64le-linux-lnt| 19:18:21
 clang-ppc64le-linux| 19:17:15
 clang-ppc64be-linux| 18:59:05
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 17:52:15
 clang-ppc64be-linux-lnt| 17:21:33
 sanitizer-x86_64-linux-bootstrap   | 17:16:22
 sanitizer-windows  | 17:05:04
 clang-ppc64be-linux-multistage | 16:34:47
 sanitizer-x86_64-linux-fast| 15:32:33
 perf-x86_64-penryn-O3  | 14:14:15
 lldb-x86_64-ubuntu-14.04-cmake | 12:18:27
 clang-x86-windows-msvc2015 | 12:10:09
 clang-lld-x86_64-2stage| 11:42:52
 lldb-x86_64-darwin-13.4| 10:54:58
 lldb-x86_64-ubuntu-14.04-android   | 10:02:06
 lldb-windows7-android  | 09:04:01
 clang-with-thin-lto-ubuntu | 08:54:09
 clang-cmake-aarch64-quick  | 08:27:39
 clang-with-lto-ubuntu  | 08:26:53
 ubuntu-gcc7.1-werror   | 08:24:06
 clang-cmake-x86_64-avx2-linux  | 07:57:34
 clang-with-thin-lto-windows| 07:57:08
 clang-cmake-armv7-a15-selfhost | 07:56:05
 clang-x64-ninja-win7   | 07:54:38
 clang-x86_64-debian-fast   | 07:50:48
 clang-cuda-build   | 07:26:25
 clang-bpf-build| 07:26:02
 clang-cmake-aarch64-lld| 07:24:14
 clang-s390x-linux  | 07:19:16
 clang-cmake-armv7-a15-full | 07:11:56
 clang-atom-d525-fedora-rel | 07:10:30
 llvm-hexagon-elf   | 07:10:23
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 07:04:05
 clang-cmake-thumbv7-a15| 07:00:49
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan  | 06:59:04
 clang-s390x-linux-lnt  | 06:54:30
 clang-cmake-armv7-a15  | 06:53:40
 clang-cmake-aarch64-42vma  | 06:53:33
 clang-hexagon-elf  | 06:45:07
 clang-cmake-thumbv7-a15-full-sh| 06:45:01
 clang-cmake-aarch64-global-isel| 06:31:56
 clang-s390x-linux-multistage   | 05:12:28
 lld-x86_64-darwin13| 04:55:50
 polly-amd64-linux  | 04:47:46
 clang-cmake-armv7-a15-selfhost-neon| 04:03:14
 sanitizer-x86_64-linux-fuzzer  | 03:37:29
 polly-arm-linux| 02:42:21
 sanitizer-x86_64-linux | 02:39:19
 clang-native-arm-lnt 

Buildbot numbers for the week of 07/23/2017 - 07/29/2017

2017-09-08 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 07/23/2017 - 07/29/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername |  was_red
+--
 clang-x64-ninja-win7   | 124:58:50
 aosp-O3-polly-before-vectorizer-unprofitable   | 119:55:53
 clang-cuda-build   | 78:44:11
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 77:27:52
 clang-x86-windows-msvc2015 | 77:11:15
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 65:36:46
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only  | 58:55:13
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 44:46:26
 clang-atom-d525-fedora-rel | 40:12:22
 perf-x86_64-penryn-O3-polly| 35:11:44
 perf-x86_64-penryn-O3  | 25:42:32
 perf-x86_64-penryn-O3-polly-fast   | 24:44:01
 clang-with-lto-ubuntu  | 24:08:41
 perf-x86_64-penryn-O3-polly-parallel-fast  | 23:09:47
 perf-x86_64-penryn-O3-polly-unprofitable   | 23:04:12
 clang-with-thin-lto-ubuntu | 21:44:48
 llvm-hexagon-elf   | 20:03:08
 sanitizer-windows  | 13:41:45
 sanitizer-x86_64-linux-fast| 13:02:43
 clang-ppc64be-linux| 12:24:16
 sanitizer-x86_64-linux-bootstrap   | 10:22:10
 sanitizer-ppc64be-linux| 09:57:42
 clang-cmake-thumbv7-a15| 08:22:50
 clang-cmake-armv7-a15  | 08:12:13
 sanitizer-x86_64-linux-android | 07:06:57
 sanitizer-x86_64-linux | 06:57:07
 clang-ppc64le-linux-lnt| 06:52:33
 clang-ppc64le-linux| 06:34:04
 clang-ppc64be-linux-lnt| 06:32:56
 clang-s390x-linux-lnt  | 06:12:43
 sanitizer-ppc64le-linux| 06:12:16
 clang-ppc64be-linux-multistage | 05:48:46
 clang-s390x-linux-multistage   | 05:46:44
 clang-s390x-linux  | 05:34:41
 clang-x86_64-debian-fast   | 05:30:09
 clang-cmake-armv7-a15-selfhost | 04:50:24
 lld-x86_64-freebsd | 04:45:36
 clang-lld-x86_64-2stage| 04:42:19
 clang-x86_64-linux-selfhost-modules-2  | 04:29:19
 clang-cmake-armv7-a15-selfhost-neon| 04:29:01
 clang-cmake-aarch64-quick  | 03:59:32
 clang-cmake-aarch64-lld| 03:57:35
 sanitizer-x86_64-linux-autoconf| 03:56:08
 clang-x86_64-linux-abi-test| 03:55:38
 clang-cmake-armv7-a15-full | 03:43:54
 clang-cmake-thumbv7-a15-full-sh| 03:42:41
 clang-bpf-build| 03:40:52
 lld-x86_64-darwin13| 03:36:13
 libcxx-libcxxabi-libunwind-aarch64-linux   | 03:34:39
 ubuntu-gcc7.1-werror   | 03:32:24
 clang-cmake-aarch64-42vma  | 03:21:06
 polly-amd64-linux  | 03:01:14
 lldb-x86_64-ubuntu-14.04-cmake | 02:50:05
 clang-with-thin-lto-windows| 02:49:50
 clang-cmake-aarch64-global-isel| 02:29:21
 llvm-clang-x86_64-expensive-checks-win | 02:24:59
 lldb-x86_64-ubuntu-14.04-android   | 02:24:18
 lldb-windows7-android  | 02:20:33
 libcxx-libcxxabi-x86_64-linux-debian   | 02:06:29
 lldb-x86_64-darwin-13.4  

Buildbot numbers for the week of 07/16/2017 - 07/22/2017

2017-09-08 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 07/16/2017 - 07/22/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername | was_red
+-
 clang-x86_64-linux-selfhost-modules| 69:57:24
 sanitizer-windows  | 42:25:18
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions  | 33:46:22
 clang-cmake-aarch64-global-isel| 25:07:46
 libcxx-libcxxabi-libunwind-aarch64-linux   | 21:55:48
 clang-ppc64be-linux-multistage | 13:36:25
 lldb-windows7-android  | 13:23:53
 clang-x64-ninja-win7   | 12:59:55
 sanitizer-x86_64-linux-bootstrap   | 12:45:32
 clang-with-thin-lto-windows| 11:59:46
 clang-x86-windows-msvc2015 | 11:49:50
 lldb-x86_64-ubuntu-14.04-cmake | 11:40:20
 lldb-x86_64-ubuntu-14.04-android   | 11:19:36
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 11:18:57
 clang-ppc64le-linux-multistage | 10:22:28
 llvm-clang-x86_64-expensive-checks-win | 10:20:01
 sanitizer-x86_64-linux-fast| 10:19:13
 lldb-amd64-ninja-netbsd8   | 10:11:49
 clang-ppc64be-linux-lnt| 10:05:48
 clang-with-lto-ubuntu  | 08:48:01
 clang-ppc64be-linux| 07:38:15
 clang-bpf-build| 07:37:20
 sanitizer-ppc64le-linux| 06:54:57
 clang-cmake-thumbv7-a15-full-sh| 06:00:38
 clang-with-thin-lto-ubuntu | 05:38:52
 ubuntu-gcc7.1-werror   | 05:35:27
 clang-lld-x86_64-2stage| 05:27:24
 clang-cmake-armv7-a15-selfhost-neon| 05:03:05
 libomp-ompt-gcc-x86_64-linux-debian| 04:55:31
 libomp-gcc-x86_64-linux-debian | 04:54:28
 perf-x86_64-penryn-O3  | 04:49:10
 lldb-x86-windows-msvc2015  | 04:36:42
 sanitizer-x86_64-linux-android | 04:29:08
 clang-atom-d525-fedora-rel | 04:18:27
 lldb-x86_64-ubuntu-14.04-buildserver   | 04:15:20
 clang-cmake-aarch64-lld| 03:51:46
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 03:50:56
 lld-x86_64-freebsd | 03:50:18
 lld-x86_64-darwin13| 03:50:01
 lldb-amd64-ninja-freebsd11 | 03:44:14
 clang-s390x-linux-multistage   | 03:24:51
 sanitizer-x86_64-linux | 03:16:12
 clang-x86_64-linux-selfhost-modules-2  | 03:12:30
 clang-ppc64le-linux-lnt| 02:46:30
 clang-ppc64le-linux| 02:41:41
 clang-x86_64-debian-fast   | 02:20:46
 libcxx-libcxxabi-libunwind-x86_64-linux-debian | 02:20:29
 clang-cmake-aarch64-quick  | 02:00:39
 clang-s390x-linux-lnt  | 01:52:29
 clang-s390x-linux  | 01:42:42
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 01:40:13
 lldb-x86_64-darwin-13.4| 01:38:52
 clang-native-arm-lnt   | 01:37:32
 sanitizer-x86_64-linux-autoconf| 01:25:17
 clang-cmake-armv7-a15-full | 01:25:01
 sanitizer-x86_64-linux-fuzzer  | 01:24:08
 clang-cmake-thumbv7-a15| 01:22:57
 clang-cmake-armv7-a15  | 01:21:58
 lld-x86_64-win7| 01:20:00
 clang-cmake-aarch64-42vma

[PATCH] D37647: [ubsan-minimal] Document the new runtime

2017-09-08 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

https://reviews.llvm.org/D37647

Files:
  docs/ReleaseNotes.rst
  docs/UndefinedBehaviorSanitizer.rst


Index: docs/UndefinedBehaviorSanitizer.rst
===
--- docs/UndefinedBehaviorSanitizer.rst
+++ docs/UndefinedBehaviorSanitizer.rst
@@ -156,6 +156,19 @@
 The ``null``, ``alignment``, ``object-size``, and ``vptr`` checks do not apply
 to pointers to types with the ``volatile`` qualifier.
 
+Minimal Runtime
+===
+
+There is a minimal UBSan runtime available suitable for use in production
+environments. This runtime has a small attack surface. It only provides very
+basic issue logging and deduplication, and does not support ``-fsanitize=vptr``
+checking.
+
+To use the minimal runtime, add ``-fsanitize-minimal-runtime`` to the clang
+command line options. For example, if you're used to compiling with
+``-fsanitize=undefined``, you could enable the minimal runtime with
+``-fsanitize=undefined -fsanitize-minimal-runtime``.
+
 Stack traces and report symbolization
 =
 If you want UBSan to print symbolized stack trace for each error report, you
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -229,7 +229,10 @@
 Undefined Behavior Sanitizer (UBSan)
 
 
-...
+* A minimal runtime is now available. It is suitable for use in production
+  environments, and has a small attack surface. It only provides very basic
+  issue logging and deduplication, and does not support ``-fsanitize=vptr``
+  checking.
 
 Core Analysis Improvements
 ==


Index: docs/UndefinedBehaviorSanitizer.rst
===
--- docs/UndefinedBehaviorSanitizer.rst
+++ docs/UndefinedBehaviorSanitizer.rst
@@ -156,6 +156,19 @@
 The ``null``, ``alignment``, ``object-size``, and ``vptr`` checks do not apply
 to pointers to types with the ``volatile`` qualifier.
 
+Minimal Runtime
+===
+
+There is a minimal UBSan runtime available suitable for use in production
+environments. This runtime has a small attack surface. It only provides very
+basic issue logging and deduplication, and does not support ``-fsanitize=vptr``
+checking.
+
+To use the minimal runtime, add ``-fsanitize-minimal-runtime`` to the clang
+command line options. For example, if you're used to compiling with
+``-fsanitize=undefined``, you could enable the minimal runtime with
+``-fsanitize=undefined -fsanitize-minimal-runtime``.
+
 Stack traces and report symbolization
 =
 If you want UBSan to print symbolized stack trace for each error report, you
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -229,7 +229,10 @@
 Undefined Behavior Sanitizer (UBSan)
 
 
-...
+* A minimal runtime is now available. It is suitable for use in production
+  environments, and has a small attack surface. It only provides very basic
+  issue logging and deduplication, and does not support ``-fsanitize=vptr``
+  checking.
 
 Core Analysis Improvements
 ==
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37436: Initial implementation of C attributes (WG14 N2137)

2017-09-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 114447.
aaron.ballman marked 2 inline comments as done.
aaron.ballman added a comment.

Updated based on Richard's comments and some further discussion on IRC.


https://reviews.llvm.org/D37436

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/Attributes.h
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Parse/Parser.h
  include/clang/Sema/AttributeList.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Lex/Lexer.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/AttributeList.cpp
  test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp
  test/Misc/ast-dump-c-attr.c
  test/Parser/c2x-attributes.c
  test/Parser/cxx0x-attributes.cpp
  test/Sema/attr-deprecated-c2x.c
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -58,7 +58,7 @@
 
 assert(V != "GCC" && "Given a GCC spelling, which means this hasn't been"
"flattened!");
-if (V == "CXX11" || V == "Pragma")
+if (V == "CXX11" || V == "C2x" || V == "Pragma")
   NS = Spelling.getValueAsString("Namespace");
 bool Unset;
 K = Spelling.getValueAsBitOrUnset("KnownToGCC", Unset);
@@ -1326,7 +1326,7 @@
 if (Variety == "GNU") {
   Prefix = " __attribute__((";
   Suffix = "))";
-} else if (Variety == "CXX11") {
+} else if (Variety == "CXX11" || Variety == "C2x") {
   Prefix = " [[";
   Suffix = "]]";
   std::string Namespace = Spellings[I].nameSpace();
@@ -2716,10 +2716,14 @@
   // If this is the C++11 variety, also add in the LangOpts test.
   if (Variety == "CXX11")
 Test += " && LangOpts.CPlusPlus11";
+  else if (Variety == "C2x")
+Test += " && LangOpts.CAttributes";
 } else if (Variety == "CXX11")
   // C++11 mode should be checked against LangOpts, which is presumed to be
   // present in the caller.
   Test = "LangOpts.CPlusPlus11";
+else if (Variety == "C2x")
+  Test = "LangOpts.CAttributes";
 
 std::string TestStr =
 !Test.empty() ? Test + " ? " + llvm::itostr(Version) + " : 0" : "1";
@@ -2740,7 +2744,7 @@
   // and declspecs. Then generate a big switch statement for each of them.
   std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
   std::vector Declspec, Microsoft, GNU, Pragma;
-  std::map CXX;
+  std::map CXX, C2x;
 
   // Walk over the list of all attributes, and split them out based on the
   // spelling variety.
@@ -2756,6 +2760,8 @@
 Microsoft.push_back(R);
   else if (Variety == "CXX11")
 CXX[SI.nameSpace()].push_back(R);
+  else if (Variety == "C2x")
+C2x[SI.nameSpace()].push_back(R);
   else if (Variety == "Pragma")
 Pragma.push_back(R);
 }
@@ -2775,20 +2781,25 @@
   OS << "case AttrSyntax::Pragma:\n";
   OS << "  return llvm::StringSwitch(Name)\n";
   GenerateHasAttrSpellingStringSwitch(Pragma, OS, "Pragma");
-  OS << "case AttrSyntax::CXX: {\n";
-  // C++11-style attributes are further split out based on the Scope.
-  for (auto I = CXX.cbegin(), E = CXX.cend(); I != E; ++I) {
-if (I != CXX.begin())
-  OS << " else ";
-if (I->first.empty())
-  OS << "if (!Scope || Scope->getName() == \"\") {\n";
-else
-  OS << "if (Scope->getName() == \"" << I->first << "\") {\n";
-OS << "  return llvm::StringSwitch(Name)\n";
-GenerateHasAttrSpellingStringSwitch(I->second, OS, "CXX11", I->first);
-OS << "}";
-  }
-  OS << "\n}\n";
+  auto fn = [](const char *Spelling, const char *Variety,
+  const std::map ) {
+OS << "case AttrSyntax::" << Variety << ": {\n";
+// C++11-style attributes are further split out based on the Scope.
+for (auto I = List.cbegin(), E = List.cend(); I != E; ++I) {
+  if (I != List.cbegin())
+OS << " else ";
+  if (I->first.empty())
+OS << "if (!Scope || Scope->getName() == \"\") {\n";
+  else
+OS << "if (Scope->getName() == \"" << I->first << "\") {\n";
+  OS << "  return llvm::StringSwitch(Name)\n";
+  GenerateHasAttrSpellingStringSwitch(I->second, OS, Spelling, I->first);
+  OS << "}";
+}
+OS << "\n}\n";
+  };
+  fn("CXX11", "CXX", CXX);
+  fn("C2x", "C", C2x);
   OS << "}\n";
 }
 
@@ -2809,10 +2820,11 @@
  << StringSwitch(Spellings[I].variety())
 .Case("GNU", 0)
 .Case("CXX11", 1)
-.Case("Declspec", 2)
-.Case("Microsoft", 3)
-.Case("Keyword", 4)
-.Case("Pragma", 5)
+.Case("C2x", 2)
+.Case("Declspec", 3)
+.Case("Microsoft", 4)
+.Case("Keyword", 5)
+.Case("Pragma", 6)
 

[PATCH] D37643: Add objcImplementationDecl matcher

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

LGTM, thanks!


https://reviews.llvm.org/D37643



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


[PATCH] D37643: Add objcImplementationDecl matcher

2017-09-08 Thread Dave Lee via Phabricator via cfe-commits
kastiglione created this revision.
Herald added a subscriber: klimek.

Add the `objcImplementationDecl` matcher. See related: 
https://reviews.llvm.org/D30854

Tested with:

  ./tools/clang/unittests/ASTMatchers/ASTMatchersTests


https://reviews.llvm.org/D37643

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1610,6 +1610,9 @@
   EXPECT_TRUE(matchesObjC(
 ObjCString,
 objcProtocolDecl(hasName("Proto";
+  EXPECT_TRUE(matchesObjC(
+ObjCString,
+objcImplementationDecl(hasName("Thing";
   EXPECT_TRUE(matchesObjC(
 ObjCString,
 objcCategoryDecl(hasName("ABC";
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -374,6 +374,7 @@
   REGISTER_MATCHER(numSelectorArgs);
   REGISTER_MATCHER(ofClass);
   REGISTER_MATCHER(objcCategoryDecl);
+  REGISTER_MATCHER(objcImplementationDecl);
   REGISTER_MATCHER(objcInterfaceDecl);
   REGISTER_MATCHER(objcIvarDecl);
   REGISTER_MATCHER(objcMessageExpr);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1145,6 +1145,17 @@
   Decl,
   ObjCInterfaceDecl> objcInterfaceDecl;
 
+/// \brief Matches Objective-C implementation declarations.
+///
+/// Example matches Foo
+/// \code
+///   @implementation Foo
+///   @end
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher<
+  Decl,
+  ObjCImplementationDecl> objcImplementationDecl;
+
 /// \brief Matches Objective-C protocol declarations.
 ///
 /// Example matches FooDelegate
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -346,6 +346,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DeclobjcImplementationDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCImplementationDecl.html;>ObjCImplementationDecl...
+Matches 
Objective-C implementation declarations.
+
+Example matches Foo
+  @implementation Foo
+  @end
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DeclobjcInterfaceDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html;>ObjCInterfaceDecl...
 Matches 
Objective-C interface declarations.
 


Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1610,6 +1610,9 @@
   EXPECT_TRUE(matchesObjC(
 ObjCString,
 objcProtocolDecl(hasName("Proto";
+  EXPECT_TRUE(matchesObjC(
+ObjCString,
+objcImplementationDecl(hasName("Thing";
   EXPECT_TRUE(matchesObjC(
 ObjCString,
 objcCategoryDecl(hasName("ABC";
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -374,6 +374,7 @@
   REGISTER_MATCHER(numSelectorArgs);
   REGISTER_MATCHER(ofClass);
   REGISTER_MATCHER(objcCategoryDecl);
+  REGISTER_MATCHER(objcImplementationDecl);
   REGISTER_MATCHER(objcInterfaceDecl);
   REGISTER_MATCHER(objcIvarDecl);
   REGISTER_MATCHER(objcMessageExpr);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1145,6 +1145,17 @@
   Decl,
   ObjCInterfaceDecl> objcInterfaceDecl;
 
+/// \brief Matches Objective-C implementation declarations.
+///
+/// Example matches Foo
+/// \code
+///   @implementation Foo
+///   @end
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher<
+  Decl,
+  ObjCImplementationDecl> objcImplementationDecl;
+
 /// \brief Matches Objective-C protocol declarations.
 ///
 /// Example matches FooDelegate
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -346,6 +346,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DeclobjcImplementationDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCImplementationDecl.html;>ObjCImplementationDecl...
+Matches Objective-C implementation declarations.
+
+Example matches Foo
+  @implementation Foo
+  @end
+
+
+
 

[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-09-08 Thread Francis Ricci via Phabricator via cfe-commits
fjricci added inline comments.



Comment at: lib/Driver/ToolChain.cpp:851
+  XOpenMPTargetArg->setBaseArg(A);
+  A = XOpenMPTargetArg.release();
+  DAL->append(A);

Hahnfeld wrote:
> This is a memory leak that is currently triggered in 
> `tests/Driver/openmp-offload-gpu.c` and found by ASan. How to fix this? I'm 
> not really familiar with OptTable...
Even with the follow-up patch to fix the memory leak, I'm still seeing this 
pointer leaked (on Darwin with ASan and detect_leaks=1). I've tried playing 
around with a few fixes myself, but haven't been able to get anything working.


https://reviews.llvm.org/D34784



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


r312830 - Reinstall the patch "Use EmitPointerWithAlignment to get alignment information of the pointer used in atomic expr".

2017-09-08 Thread Wei Mi via cfe-commits
Author: wmi
Date: Fri Sep  8 14:58:18 2017
New Revision: 312830

URL: http://llvm.org/viewvc/llvm-project?rev=312830=rev
Log:
Reinstall the patch "Use EmitPointerWithAlignment to get alignment information 
of the pointer used in atomic expr".

This is to fix PR34347. EmitAtomicExpr now only uses alignment information from
Type, instead of Decl, so when the declaration of an atomic variable is marked
to have the alignment equal as its size, EmitAtomicExpr doesn't know about it 
and
will generate libcall instead of atomic op. The patch uses 
EmitPointerWithAlignment
to get the precise alignment information.

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

Added:
cfe/trunk/test/CodeGenCXX/atomic-align.cpp
Modified:
cfe/trunk/lib/CodeGen/CGAtomic.cpp

Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=312830=312829=312830=diff
==
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Fri Sep  8 14:58:18 2017
@@ -745,19 +745,19 @@ RValue CodeGenFunction::EmitAtomicExpr(A
   QualType MemTy = AtomicTy;
   if (const AtomicType *AT = AtomicTy->getAs())
 MemTy = AT->getValueType();
-  CharUnits sizeChars, alignChars;
-  std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy);
-  uint64_t Size = sizeChars.getQuantity();
-  unsigned MaxInlineWidthInBits = getTarget().getMaxAtomicInlineWidth();
-  bool UseLibcall = (sizeChars != alignChars ||
- getContext().toBits(sizeChars) > MaxInlineWidthInBits);
-
   llvm::Value *IsWeak = nullptr, *OrderFail = nullptr;
 
   Address Val1 = Address::invalid();
   Address Val2 = Address::invalid();
   Address Dest = Address::invalid();
-  Address Ptr(EmitScalarExpr(E->getPtr()), alignChars);
+  Address Ptr = EmitPointerWithAlignment(E->getPtr());
+
+  CharUnits sizeChars, alignChars;
+  std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy);
+  uint64_t Size = sizeChars.getQuantity();
+  unsigned MaxInlineWidthInBits = getTarget().getMaxAtomicInlineWidth();
+  bool UseLibcall = ((Ptr.getAlignment() % sizeChars) != 0 ||
+ getContext().toBits(sizeChars) > MaxInlineWidthInBits);
 
   if (E->getOp() == AtomicExpr::AO__c11_atomic_init ||
   E->getOp() == AtomicExpr::AO__opencl_atomic_init) {

Added: cfe/trunk/test/CodeGenCXX/atomic-align.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/atomic-align.cpp?rev=312830=auto
==
--- cfe/trunk/test/CodeGenCXX/atomic-align.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/atomic-align.cpp Fri Sep  8 14:58:18 2017
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - -triple=x86_64-linux-gnu | 
FileCheck %s
+
+struct AM {
+  int f1, f2;
+};
+alignas(8) AM m;
+AM load1() {
+  AM am;
+  // m is declared to align to 8bytes, so generate load atomic instead
+  // of libcall.
+  // CHECK-LABEL: @_Z5load1v
+  // CHECK: load atomic {{.*}} monotonic
+  __atomic_load(, , 0);
+  return am;
+}
+
+struct BM {
+  int f1;
+  alignas(8) AM f2;
+};
+BM bm;
+AM load2() {
+  AM am;
+  // BM::f2 is declared to align to 8bytes, so generate load atomic instead
+  // of libcall.
+  // CHECK-LABEL: @_Z5load2v
+  // CHECK: load atomic {{.*}} monotonic
+  __atomic_load(, , 0);
+  return am;
+}


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


Re: r312750 - [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-08 Thread Aaron Ballman via cfe-commits
On Fri, Sep 8, 2017 at 5:49 PM, Hans Wennborg via cfe-commits
 wrote:
> On Fri, Sep 8, 2017 at 2:26 PM, Friedman, Eli  wrote:
>> On 9/8/2017 2:18 PM, Hans Wennborg via cfe-commits wrote:
>>>
>>> On Fri, Sep 8, 2017 at 2:09 PM, Roman Lebedev 
>>> wrote:


 Interesting. My first thought was to explicitly specify enum as signed:

 enum MediaDeviceType : signed int {
 MEDIA_DEVICE_TYPE_AUDIO_INPUT = 0,
 MEDIA_DEVICE_TYPE_VIDEO_INPUT,
 MEDIA_DEVICE_TYPE_AUDIO_OUTPUT,
 NUM_MEDIA_DEVICE_TYPES,
 };

 inline bool IsValidMediaDeviceType(MediaDeviceType type) {
 return type >= 0U && type < NUM_MEDIA_DEVICE_TYPES;
 }

 But it still seem to warn, and *that* sounds like a bug.
 Please open a new bugreport.
>>>
>>> I'm reporting it here :-)
>>>
 As for different default signedness, i'm not sure what is there to do.
 Does
 not sound like a problem for this diagnostic to intentionally avoid to
 be honest.
>>>
>>> I think it is a problem for this warning. If a user sees the warning
>>> and removes the "type >= 0" check, thinking that it was unnecessary
>>> because the compiler told them so, they have now introduced a bug in
>>> the code.
>>
>>
>> Even if you declare the enum type as signed, it still isn't allowed to
>> contain a negative number; that's undefined behavior.  You can check for
>> this using ubsan's -fsanitize=enum.
>
> Is it? I thought if you define it as signed, it falls under "For an
> enumeration whose underlying type is fixed, the values of the
> enumeration are the values of the underlying type." (c++11 7.2p7)
>
> My standards-fu is weak though, so I could be wrong.

The enum values can be signed because of the fixed type, but the
comparison was enum_val <= 0U, so I believe the usual arithmetic
conversions will convert the enum value to an *unsigned* value, making
this a tautological comparison. If the value was 0, then I think the
comparison would not be tautological because there would be no
conversion needed.

> But I think you're right about the case when the underlying type is
> not specified. Even if it happens to be 'int' on Windows, negative
> values aren't allowed (unless there are negative enumerators). That
> doesn't mean it won't happen though, and lots of code isn't UB-clean
> :-/

Yes, but if the *optimizer* were ever clever enough to realize the
value cannot be negative, then your code still has a pretty serious
problem in the face of that same UB.

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


Re: r312750 - [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-08 Thread Roman Lebedev via cfe-commits
On Sat, Sep 9, 2017 at 12:18 AM, Hans Wennborg  wrote:
> On Fri, Sep 8, 2017 at 2:09 PM, Roman Lebedev  wrote:
>> On Fri, Sep 8, 2017 at 11:45 PM, Hans Wennborg  wrote:
>>> On Fri, Sep 8, 2017 at 4:48 AM, Sam McCall via cfe-commits
>>>  wrote:
 Nice fix! It catches a lot of new cases on our codebase, all technically
 correct so far.

 A couple of issues though:
 A) Rollout - until we've completely cleaned up, we need to disable
 -Wtautological-compare entirely, which is a valuable check. I imagine 
 anyone
 else using -Werror is in the same boat.
 What do you think about putting the new warnings behind a subcategory? 
 (e.g.
 -Wtautological-compare-unsigned-zero, implied by -Wtautological-compare)
 It's an ugly artifact of the history here, but allows this fix to be rolled
 out in a controlled way.

 B) Enums (not new I guess). Typical case: if (enum < 0 || enum > MAX)
 The warning strongly suggests that the enum < 0 check has no effect (for
 enums with nonnegative ranges).
 Clang doesn't seem to optimize such checks out though, and they seem likely
 to catch bugs in some cases. Yes, only if there's UB elsewhere, but I 
 assume
 not optimizing out these checks indicates a deliberate decision to stay
 somewhat compatible with a technically-incorrect mental model.
 If this is the case, should we move these to a -Wtautological-compare-enum
 subcategory?
>>>
>>> Just another data point: we're seeing this a lot in Chromium, e.g.
>>>
>>> enum MediaDeviceType {
>>>   MEDIA_DEVICE_TYPE_AUDIO_INPUT,
>>>   MEDIA_DEVICE_TYPE_VIDEO_INPUT,
>>>   MEDIA_DEVICE_TYPE_AUDIO_OUTPUT,
>>>   NUM_MEDIA_DEVICE_TYPES,
>>> };
>>>
>>> inline bool IsValidMediaDeviceType(MediaDeviceType type) {
>>>   return type >= 0 && type < NUM_MEDIA_DEVICE_TYPES;
>>> }
>>>
>>> ../../content/common/media/media_devices.h:53:15: warning: comparison
>>> of unsigned enum expression >= 0 is always true
>>> [-Wtautological-unsigned-zero-compare]
>>>   return type >= 0 && type < NUM_MEDIA_DEVICE_TYPES;
>>>   ^  ~
>>>
>>> The problem is that the signedness of the enum varies per platform.
>>> For example, when targeting Windows the underlying type is 'int' by
>>> default, and then the comparison isn't tautological.
>>
>> Interesting. My first thought was to explicitly specify enum as signed:
>>
>> enum MediaDeviceType : signed int {
>> MEDIA_DEVICE_TYPE_AUDIO_INPUT = 0,
>> MEDIA_DEVICE_TYPE_VIDEO_INPUT,
>> MEDIA_DEVICE_TYPE_AUDIO_OUTPUT,
>> NUM_MEDIA_DEVICE_TYPES,
>> };
>>
>> inline bool IsValidMediaDeviceType(MediaDeviceType type) {
>> return type >= 0U && type < NUM_MEDIA_DEVICE_TYPES;
>> }
>>
>> But it still seem to warn, and *that* sounds like a bug.
>> Please open a new bugreport.
>
> I'm reporting it here :-)
Here i might forget :)

But as soon as i get a LGTM on https://reviews.llvm.org/D37629
you will at least be able to silence that particular warning.

>> As for different default signedness, i'm not sure what is there to do. Does
>> not sound like a problem for this diagnostic to intentionally avoid to
>> be honest.
>
> I think it is a problem for this warning. If a user sees the warning
> and removes the "type >= 0" check, thinking that it was unnecessary
> because the compiler told them so, they have now introduced a bug in
> the code.
>
 On Fri, Sep 8, 2017 at 12:14 AM, Roman Lebedev via cfe-commits
  wrote:
>
> Author: lebedevri
> Date: Thu Sep  7 15:14:25 2017
> New Revision: 312750
>
> URL: http://llvm.org/viewvc/llvm-project?rev=312750=rev
> Log:
> [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.
>
> Summary:
> This is a first half(?) of a fix for the following bug:
> https://bugs.llvm.org/show_bug.cgi?id=34147 (gcc -Wtype-limits)
>
> GCC's -Wtype-limits does warn on comparison of unsigned value
> with signed zero (as in, with 0), but clang only warns if the
> zero is unsigned (i.e. 0U).
>
> Also, be careful not to double-warn, or falsely warn on
> comparison of signed/fp variable and signed 0.
>
> Yes, all these testcases are needed.
>
> Testing: $ ninja check-clang-sema check-clang-semacxx
> Also, no new warnings for clang stage-2 build.
>
> Reviewers: rjmccall, rsmith, aaron.ballman
>
> Reviewed By: rjmccall
>
> Subscribers: cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D37565
>
> Modified:
> cfe/trunk/docs/ReleaseNotes.rst
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/test/Sema/compare.c
> cfe/trunk/test/Sema/outof-range-constant-compare.c
> cfe/trunk/test/SemaCXX/compare.cpp
>
> Modified: cfe/trunk/docs/ReleaseNotes.rst
> URL:
> 

Re: r312750 - [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-08 Thread Hans Wennborg via cfe-commits
On Fri, Sep 8, 2017 at 2:26 PM, Friedman, Eli  wrote:
> On 9/8/2017 2:18 PM, Hans Wennborg via cfe-commits wrote:
>>
>> On Fri, Sep 8, 2017 at 2:09 PM, Roman Lebedev 
>> wrote:
>>>
>>>
>>> Interesting. My first thought was to explicitly specify enum as signed:
>>>
>>> enum MediaDeviceType : signed int {
>>> MEDIA_DEVICE_TYPE_AUDIO_INPUT = 0,
>>> MEDIA_DEVICE_TYPE_VIDEO_INPUT,
>>> MEDIA_DEVICE_TYPE_AUDIO_OUTPUT,
>>> NUM_MEDIA_DEVICE_TYPES,
>>> };
>>>
>>> inline bool IsValidMediaDeviceType(MediaDeviceType type) {
>>> return type >= 0U && type < NUM_MEDIA_DEVICE_TYPES;
>>> }
>>>
>>> But it still seem to warn, and *that* sounds like a bug.
>>> Please open a new bugreport.
>>
>> I'm reporting it here :-)
>>
>>> As for different default signedness, i'm not sure what is there to do.
>>> Does
>>> not sound like a problem for this diagnostic to intentionally avoid to
>>> be honest.
>>
>> I think it is a problem for this warning. If a user sees the warning
>> and removes the "type >= 0" check, thinking that it was unnecessary
>> because the compiler told them so, they have now introduced a bug in
>> the code.
>
>
> Even if you declare the enum type as signed, it still isn't allowed to
> contain a negative number; that's undefined behavior.  You can check for
> this using ubsan's -fsanitize=enum.

Is it? I thought if you define it as signed, it falls under "For an
enumeration whose underlying type is fixed, the values of the
enumeration are the values of the underlying type." (c++11 7.2p7)

My standards-fu is weak though, so I could be wrong.


But I think you're right about the case when the underlying type is
not specified. Even if it happens to be 'int' on Windows, negative
values aren't allowed (unless there are negative enumerators). That
doesn't mean it won't happen though, and lots of code isn't UB-clean
:-/
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37642: [pp-trace] Update skipped source ranges in tests

2017-09-08 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.
Herald added subscribers: kbarton, nemanjai.

Depends on https://reviews.llvm.org/D36642


https://reviews.llvm.org/D37642

Files:
  pp-trace/PPCallbacksTracker.cpp
  pp-trace/PPCallbacksTracker.h
  test/pp-trace/pp-trace-conditional.cpp
  test/pp-trace/pp-trace-macro.cpp

Index: test/pp-trace/pp-trace-macro.cpp
===
--- test/pp-trace/pp-trace-macro.cpp
+++ test/pp-trace/pp-trace-macro.cpp
@@ -64,7 +64,7 @@
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-macro.cpp:9:2"
 // CHECK-NEXT:   IfLoc: "{{.*}}{{[/\\]}}pp-trace-macro.cpp:8:2"
 // CHECK-NEXT: - Callback: SourceRangeSkipped
-// CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-macro.cpp:8:2", "{{.*}}{{[/\\]}}pp-trace-macro.cpp:9:2"]
+// CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-macro.cpp:8:1", "{{.*}}{{[/\\]}}pp-trace-macro.cpp:9:2"]
 // CHECK-NEXT: - Callback: MacroDefined
 // CHECK-NEXT:   MacroNameTok: FUNCMACRO
 // CHECK-NEXT:   MacroDirective: MD_Define
Index: test/pp-trace/pp-trace-conditional.cpp
===
--- test/pp-trace/pp-trace-conditional.cpp
+++ test/pp-trace/pp-trace-conditional.cpp
@@ -92,7 +92,7 @@
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:7:2"
 // CHECK-NEXT:   IfLoc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:6:2"
 // CHECK-NEXT: - Callback: SourceRangeSkipped
-// CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:6:2", "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:7:2"]
+// CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:6:1", "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:7:2"]
 // CHECK-NEXT: - Callback: If
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:9:2"
 // CHECK-NEXT:   ConditionRange: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:9:4", "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:10:1"]
@@ -104,7 +104,7 @@
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:11:2"
 // CHECK-NEXT:   IfLoc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:9:2"
 // CHECK-NEXT: - Callback: SourceRangeSkipped
-// CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:10:2", "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:11:2"]
+// CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:10:1", "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:11:2"]
 // CHECK-NEXT: - Callback: If
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:13:2"
 // CHECK-NEXT:   ConditionRange: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:13:4", "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:14:1"]
@@ -113,7 +113,7 @@
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:14:2"
 // CHECK-NEXT:   IfLoc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:13:2"
 // CHECK-NEXT: - Callback: SourceRangeSkipped
-// CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:13:2", "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:14:2"]
+// CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:13:1", "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:14:2"]
 // CHECK-NEXT: - Callback: Endif
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:15:2"
 // CHECK-NEXT:   IfLoc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:13:2"
@@ -130,7 +130,7 @@
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:19:2"
 // CHECK-NEXT:   IfLoc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:17:2"
 // CHECK-NEXT: - Callback: SourceRangeSkipped
-// CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:18:2", "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:19:2"]
+// CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:18:1", "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:19:2"]
 // CHECK-NEXT: - Callback: If
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:20:2"
 // CHECK-NEXT:   ConditionRange: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:20:4", "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:21:1"]
@@ -144,7 +144,7 @@
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:22:2"
 // CHECK-NEXT:   IfLoc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:20:2"
 // CHECK-NEXT: - Callback: SourceRangeSkipped
-// CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:21:2", "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:22:2"]
+// CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:21:1", "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:22:2"]
 // CHECK-NEXT: - Callback: If
 // CHECK-NEXT:   Loc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:24:2"
 // CHECK-NEXT:   ConditionRange: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:24:4", "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:25:1"]
@@ -155,7 +155,7 @@
 // CHECK-NEXT:   ConditionValue: CVK_True
 // CHECK-NEXT:   IfLoc: "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:24:2"
 // CHECK-NEXT: - Callback: SourceRangeSkipped
-// CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:24:2", "{{.*}}{{[/\\]}}pp-trace-conditional.cpp:25:2"]
+// CHECK-NEXT:   Range: ["{{.*}}{{[/\\]}}pp-trace-conditional.cpp:24:1", 

[PATCH] D36642: [Lexer] Report more precise skipped regions (PR34166)

2017-09-08 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 114433.
vsk added a comment.
Herald added subscribers: kbarton, nemanjai.

- Add an 'EndifLoc' parameter to the SourceRangeSkipped callback so that 
indexing clients can preserve their existing behavior.
- I'll submit a follow-up patch which updates the pp-trace tests.


https://reviews.llvm.org/D36642

Files:
  include/clang/Lex/PPCallbacks.h
  include/clang/Lex/PreprocessingRecord.h
  include/clang/Lex/Preprocessor.h
  lib/CodeGen/CoverageMappingGen.cpp
  lib/CodeGen/CoverageMappingGen.h
  lib/Lex/PPDirectives.cpp
  lib/Lex/PreprocessingRecord.cpp
  test/CoverageMapping/preprocessor.c
  test/Index/skipped-ranges.c
  tools/libclang/Indexing.cpp

Index: tools/libclang/Indexing.cpp
===
--- tools/libclang/Indexing.cpp
+++ tools/libclang/Indexing.cpp
@@ -272,7 +272,8 @@
   /// SourceRangeSkipped - This hook is called when a source range is skipped.
   /// \param Range The SourceRange that was skipped. The range begins at the
   /// #if/#else directive and ends after the #endif/#else directive.
-  void SourceRangeSkipped(SourceRange Range) override {}
+  void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc) override {
+  }
 };
 
 //===--===//
Index: test/Index/skipped-ranges.c
===
--- test/Index/skipped-ranges.c
+++ test/Index/skipped-ranges.c
@@ -20,6 +20,6 @@
 #endif // cool
 
 // RUN: env CINDEXTEST_SHOW_SKIPPED_RANGES=1 c-index-test -test-annotate-tokens=%s:1:1:16:1 %s | FileCheck %s
-// CHECK: Skipping: [5:2 - 6:7]
-// CHECK: Skipping: [8:2 - 12:7]
-// CHECK: Skipping: [14:2 - 20:7]
+// CHECK: Skipping: [5:1 - 6:7]
+// CHECK: Skipping: [8:1 - 12:7]
+// CHECK: Skipping: [14:1 - 20:7]
Index: test/CoverageMapping/preprocessor.c
===
--- test/CoverageMapping/preprocessor.c
+++ test/CoverageMapping/preprocessor.c
@@ -3,36 +3,69 @@
  // CHECK: func
 void func() {// CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0
   int i = 0;
-#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+2]]:2 = 0
+#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+3]]:1 = 0
   int x = i;
 #endif
 }
 
-#if 0
-  int g = 0;
-
-  void bar() { }
-#endif
-
  // CHECK: main
 int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
   int i = 0;
-#if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+4]]:2 = 0
+#  if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:1 = 0
   if(i == 0) {
 i = 1;
   }
-#endif
+#  endif // Mark me skipped!
 
 #if 1
  // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+1]]:12 = #0
   if(i == 0) {   // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #1
 i = 1;
   }
-#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+5]]:2 = 0
+#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+6]]:1 = 0
   if(i == 1) {
 i = 0;
   }
 }
 #endif
+
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+#\
+  if 0
+#\
+  endif // also skipped
+
+#if 1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1
+#\
+  elif 0
+#endif
+
+#if 1
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1
+#\
+  else
+#endif
+
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+#\
+  ifdef NOT_DEFINED
+#\
+  endif
+
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1
+#\
+  ifndef __FILE__
+#\
+  endif
+
+  // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+7]]:1
+#\
+  ifdef NOT_DEFINED
+#\
+  \
+   \
+endif // also skipped
+
   return 0;
 }
Index: lib/Lex/PreprocessingRecord.cpp
===
--- lib/Lex/PreprocessingRecord.cpp
+++ lib/Lex/PreprocessingRecord.cpp
@@ -400,8 +400,9 @@
   MacroNameTok.getLocation());
 }
 
-void PreprocessingRecord::SourceRangeSkipped(SourceRange Range) {
-  SkippedRanges.push_back(Range);
+void PreprocessingRecord::SourceRangeSkipped(SourceRange Range,
+ SourceLocation EndifLoc) {
+  SkippedRanges.emplace_back(Range.getBegin(), EndifLoc);
 }
 
 void PreprocessingRecord::MacroExpands(const Token ,
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -79,7 +79,8 @@
 }
 
 /// \brief Read and discard all tokens remaining on the current line until
-/// the tok::eod token is found.
+/// the tok::eod token is found. If the discarded tokens are in a skipped range,
+/// complete the range and pass it to the \c SourceRangeSkipped callback.
 void Preprocessor::DiscardUntilEndOfDirective() {
   Token Tmp;
   do {
@@ -350,7 +351,8 @@
 /// If ElseOk 

Re: r312750 - [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-08 Thread Friedman, Eli via cfe-commits

On 9/8/2017 2:18 PM, Hans Wennborg via cfe-commits wrote:

On Fri, Sep 8, 2017 at 2:09 PM, Roman Lebedev  wrote:


Interesting. My first thought was to explicitly specify enum as signed:

enum MediaDeviceType : signed int {
MEDIA_DEVICE_TYPE_AUDIO_INPUT = 0,
MEDIA_DEVICE_TYPE_VIDEO_INPUT,
MEDIA_DEVICE_TYPE_AUDIO_OUTPUT,
NUM_MEDIA_DEVICE_TYPES,
};

inline bool IsValidMediaDeviceType(MediaDeviceType type) {
return type >= 0U && type < NUM_MEDIA_DEVICE_TYPES;
}

But it still seem to warn, and *that* sounds like a bug.
Please open a new bugreport.

I'm reporting it here :-)


As for different default signedness, i'm not sure what is there to do. Does
not sound like a problem for this diagnostic to intentionally avoid to
be honest.

I think it is a problem for this warning. If a user sees the warning
and removes the "type >= 0" check, thinking that it was unnecessary
because the compiler told them so, they have now introduced a bug in
the code.


Even if you declare the enum type as signed, it still isn't allowed to 
contain a negative number; that's undefined behavior.  You can check for 
this using ubsan's -fsanitize=enum.


-Eli

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

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


Re: r312750 - [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-08 Thread Hans Wennborg via cfe-commits
On Fri, Sep 8, 2017 at 2:09 PM, Roman Lebedev  wrote:
> On Fri, Sep 8, 2017 at 11:45 PM, Hans Wennborg  wrote:
>> On Fri, Sep 8, 2017 at 4:48 AM, Sam McCall via cfe-commits
>>  wrote:
>>> Nice fix! It catches a lot of new cases on our codebase, all technically
>>> correct so far.
>>>
>>> A couple of issues though:
>>> A) Rollout - until we've completely cleaned up, we need to disable
>>> -Wtautological-compare entirely, which is a valuable check. I imagine anyone
>>> else using -Werror is in the same boat.
>>> What do you think about putting the new warnings behind a subcategory? (e.g.
>>> -Wtautological-compare-unsigned-zero, implied by -Wtautological-compare)
>>> It's an ugly artifact of the history here, but allows this fix to be rolled
>>> out in a controlled way.
>>>
>>> B) Enums (not new I guess). Typical case: if (enum < 0 || enum > MAX)
>>> The warning strongly suggests that the enum < 0 check has no effect (for
>>> enums with nonnegative ranges).
>>> Clang doesn't seem to optimize such checks out though, and they seem likely
>>> to catch bugs in some cases. Yes, only if there's UB elsewhere, but I assume
>>> not optimizing out these checks indicates a deliberate decision to stay
>>> somewhat compatible with a technically-incorrect mental model.
>>> If this is the case, should we move these to a -Wtautological-compare-enum
>>> subcategory?
>>
>> Just another data point: we're seeing this a lot in Chromium, e.g.
>>
>> enum MediaDeviceType {
>>   MEDIA_DEVICE_TYPE_AUDIO_INPUT,
>>   MEDIA_DEVICE_TYPE_VIDEO_INPUT,
>>   MEDIA_DEVICE_TYPE_AUDIO_OUTPUT,
>>   NUM_MEDIA_DEVICE_TYPES,
>> };
>>
>> inline bool IsValidMediaDeviceType(MediaDeviceType type) {
>>   return type >= 0 && type < NUM_MEDIA_DEVICE_TYPES;
>> }
>>
>> ../../content/common/media/media_devices.h:53:15: warning: comparison
>> of unsigned enum expression >= 0 is always true
>> [-Wtautological-unsigned-zero-compare]
>>   return type >= 0 && type < NUM_MEDIA_DEVICE_TYPES;
>>   ^  ~
>>
>> The problem is that the signedness of the enum varies per platform.
>> For example, when targeting Windows the underlying type is 'int' by
>> default, and then the comparison isn't tautological.
>
> Interesting. My first thought was to explicitly specify enum as signed:
>
> enum MediaDeviceType : signed int {
> MEDIA_DEVICE_TYPE_AUDIO_INPUT = 0,
> MEDIA_DEVICE_TYPE_VIDEO_INPUT,
> MEDIA_DEVICE_TYPE_AUDIO_OUTPUT,
> NUM_MEDIA_DEVICE_TYPES,
> };
>
> inline bool IsValidMediaDeviceType(MediaDeviceType type) {
> return type >= 0U && type < NUM_MEDIA_DEVICE_TYPES;
> }
>
> But it still seem to warn, and *that* sounds like a bug.
> Please open a new bugreport.

I'm reporting it here :-)

> As for different default signedness, i'm not sure what is there to do. Does
> not sound like a problem for this diagnostic to intentionally avoid to
> be honest.

I think it is a problem for this warning. If a user sees the warning
and removes the "type >= 0" check, thinking that it was unnecessary
because the compiler told them so, they have now introduced a bug in
the code.

>>> On Fri, Sep 8, 2017 at 12:14 AM, Roman Lebedev via cfe-commits
>>>  wrote:

 Author: lebedevri
 Date: Thu Sep  7 15:14:25 2017
 New Revision: 312750

 URL: http://llvm.org/viewvc/llvm-project?rev=312750=rev
 Log:
 [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

 Summary:
 This is a first half(?) of a fix for the following bug:
 https://bugs.llvm.org/show_bug.cgi?id=34147 (gcc -Wtype-limits)

 GCC's -Wtype-limits does warn on comparison of unsigned value
 with signed zero (as in, with 0), but clang only warns if the
 zero is unsigned (i.e. 0U).

 Also, be careful not to double-warn, or falsely warn on
 comparison of signed/fp variable and signed 0.

 Yes, all these testcases are needed.

 Testing: $ ninja check-clang-sema check-clang-semacxx
 Also, no new warnings for clang stage-2 build.

 Reviewers: rjmccall, rsmith, aaron.ballman

 Reviewed By: rjmccall

 Subscribers: cfe-commits

 Tags: #clang

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

 Modified:
 cfe/trunk/docs/ReleaseNotes.rst
 cfe/trunk/lib/Sema/SemaChecking.cpp
 cfe/trunk/test/Sema/compare.c
 cfe/trunk/test/Sema/outof-range-constant-compare.c
 cfe/trunk/test/SemaCXX/compare.cpp

 Modified: cfe/trunk/docs/ReleaseNotes.rst
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=312750=312749=312750=diff

 ==
 --- cfe/trunk/docs/ReleaseNotes.rst (original)
 +++ cfe/trunk/docs/ReleaseNotes.rst Thu Sep  7 15:14:25 2017
 @@ -71,6 +71,13 @@ Improvements to Clang's diagnostics
errors/warnings, 

[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI

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

Oh, you don't want to emit them by default. :)

I'm not sure what you're trying to do here... there are three possibilities:

1. The function could have an exception thrown through it, so we need an unwind 
table.
2. The function can't have an exception thrown through it, and we don't need an 
unwind table.
3. The function can't have an exception thrown through it, but we need an 
unwind table anyway for ABI reasons.

We don't really care whether "uwtable" is set in the first scenario; it's 
obvious we need the table anyway.  So I'm not sure what you're trying to 
accomplish here.  (This is why I suggested using needsUnwindTableEntry() on the 
LLVM patch.)


https://reviews.llvm.org/D31140



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


[PATCH] D37530: [MinGW] Don't link -lmsvcrt if a different msvcrt version is to be linked

2017-09-08 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 114429.
mstorsjo retitled this revision from "[MinGW] Allow overriding which version of 
msvcrt to link to" to "[MinGW] Don't link -lmsvcrt if a different msvcrt 
version is to be linked".
mstorsjo edited the summary of this revision.
mstorsjo added a comment.

Attempted implementing Reid's suggestion.

On the mingw-w64 mailing list 
(https://sourceforge.net/p/mingw-w64/mailman/message/36030072/), there were 
points made that it would be better with some mechanism that controls both 
linking the right msvcrt version and setting `__MSVCRT_VERSION__` in sync.

And someone pointed out some widely used (but not upstreamed) patches for GCC 
that adds an option `-mcrtdll` which does pretty much exactly what my 
`-mmsvcrt` option did in the previous iteration 
(https://raw.githubusercontent.com/Alexpux/MINGW-packages/master/mingw-w64-gcc-git/0006-gcc-7-branch-Windows-New-feature-to-allow-overriding.patch),
 which in another non-upstreamed patch also is used to set `__MSVCRT_VERSION__` 
(https://raw.githubusercontent.com/nak5124/build_env/master/gcc_build/patches/gcc/0020-MinGW-w64-Define-__MSVCRT_VERSION__.patch).


https://reviews.llvm.org/D37530

Files:
  lib/Driver/ToolChains/MinGW.cpp
  test/Driver/mingw-msvcrt.c


Index: test/Driver/mingw-msvcrt.c
===
--- /dev/null
+++ test/Driver/mingw-msvcrt.c
@@ -0,0 +1,5 @@
+// RUN: %clang -v -target i686-pc-windows-gnu -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_DEFAULT %s
+// RUN: %clang -v -target i686-pc-windows-gnu -lmsvcr120 -### %s 2>&1 | 
FileCheck -check-prefix=CHECK_MSVCR120 %s
+
+// CHECK_DEFAULT: "-lmingwex" "-lmsvcrt" "-ladvapi32"
+// CHECK_MSVCR120: "-lmingwex" "-ladvapi32"
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -82,6 +82,9 @@
 
   CmdArgs.push_back("-lmoldname");
   CmdArgs.push_back("-lmingwex");
+  for (auto Lib : Args.getAllArgValues(options::OPT_l))
+if (StringRef(Lib).startswith("msvcr") || Lib == "ucrtbase")
+  return;
   CmdArgs.push_back("-lmsvcrt");
 }
 


Index: test/Driver/mingw-msvcrt.c
===
--- /dev/null
+++ test/Driver/mingw-msvcrt.c
@@ -0,0 +1,5 @@
+// RUN: %clang -v -target i686-pc-windows-gnu -### %s 2>&1 | FileCheck -check-prefix=CHECK_DEFAULT %s
+// RUN: %clang -v -target i686-pc-windows-gnu -lmsvcr120 -### %s 2>&1 | FileCheck -check-prefix=CHECK_MSVCR120 %s
+
+// CHECK_DEFAULT: "-lmingwex" "-lmsvcrt" "-ladvapi32"
+// CHECK_MSVCR120: "-lmingwex" "-ladvapi32"
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -82,6 +82,9 @@
 
   CmdArgs.push_back("-lmoldname");
   CmdArgs.push_back("-lmingwex");
+  for (auto Lib : Args.getAllArgValues(options::OPT_l))
+if (StringRef(Lib).startswith("msvcr") || Lib == "ucrtbase")
+  return;
   CmdArgs.push_back("-lmsvcrt");
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r312750 - [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-08 Thread Roman Lebedev via cfe-commits
On Fri, Sep 8, 2017 at 11:45 PM, Hans Wennborg  wrote:
> On Fri, Sep 8, 2017 at 4:48 AM, Sam McCall via cfe-commits
>  wrote:
>> Nice fix! It catches a lot of new cases on our codebase, all technically
>> correct so far.
>>
>> A couple of issues though:
>> A) Rollout - until we've completely cleaned up, we need to disable
>> -Wtautological-compare entirely, which is a valuable check. I imagine anyone
>> else using -Werror is in the same boat.
>> What do you think about putting the new warnings behind a subcategory? (e.g.
>> -Wtautological-compare-unsigned-zero, implied by -Wtautological-compare)
>> It's an ugly artifact of the history here, but allows this fix to be rolled
>> out in a controlled way.
>>
>> B) Enums (not new I guess). Typical case: if (enum < 0 || enum > MAX)
>> The warning strongly suggests that the enum < 0 check has no effect (for
>> enums with nonnegative ranges).
>> Clang doesn't seem to optimize such checks out though, and they seem likely
>> to catch bugs in some cases. Yes, only if there's UB elsewhere, but I assume
>> not optimizing out these checks indicates a deliberate decision to stay
>> somewhat compatible with a technically-incorrect mental model.
>> If this is the case, should we move these to a -Wtautological-compare-enum
>> subcategory?
>
> Just another data point: we're seeing this a lot in Chromium, e.g.
>
> enum MediaDeviceType {
>   MEDIA_DEVICE_TYPE_AUDIO_INPUT,
>   MEDIA_DEVICE_TYPE_VIDEO_INPUT,
>   MEDIA_DEVICE_TYPE_AUDIO_OUTPUT,
>   NUM_MEDIA_DEVICE_TYPES,
> };
>
> inline bool IsValidMediaDeviceType(MediaDeviceType type) {
>   return type >= 0 && type < NUM_MEDIA_DEVICE_TYPES;
> }
>
> ../../content/common/media/media_devices.h:53:15: warning: comparison
> of unsigned enum expression >= 0 is always true
> [-Wtautological-unsigned-zero-compare]
>   return type >= 0 && type < NUM_MEDIA_DEVICE_TYPES;
>   ^  ~
>
> The problem is that the signedness of the enum varies per platform.
> For example, when targeting Windows the underlying type is 'int' by
> default, and then the comparison isn't tautological.

Interesting. My first thought was to explicitly specify enum as signed:

enum MediaDeviceType : signed int {
MEDIA_DEVICE_TYPE_AUDIO_INPUT = 0,
MEDIA_DEVICE_TYPE_VIDEO_INPUT,
MEDIA_DEVICE_TYPE_AUDIO_OUTPUT,
NUM_MEDIA_DEVICE_TYPES,
};

inline bool IsValidMediaDeviceType(MediaDeviceType type) {
return type >= 0U && type < NUM_MEDIA_DEVICE_TYPES;
}

But it still seem to warn, and *that* sounds like a bug.
Please open a new bugreport.

As for different default signedness, i'm not sure what is there to do. Does
not sound like a problem for this diagnostic to intentionally avoid to
be honest.

>> On Fri, Sep 8, 2017 at 12:14 AM, Roman Lebedev via cfe-commits
>>  wrote:
>>>
>>> Author: lebedevri
>>> Date: Thu Sep  7 15:14:25 2017
>>> New Revision: 312750
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=312750=rev
>>> Log:
>>> [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.
>>>
>>> Summary:
>>> This is a first half(?) of a fix for the following bug:
>>> https://bugs.llvm.org/show_bug.cgi?id=34147 (gcc -Wtype-limits)
>>>
>>> GCC's -Wtype-limits does warn on comparison of unsigned value
>>> with signed zero (as in, with 0), but clang only warns if the
>>> zero is unsigned (i.e. 0U).
>>>
>>> Also, be careful not to double-warn, or falsely warn on
>>> comparison of signed/fp variable and signed 0.
>>>
>>> Yes, all these testcases are needed.
>>>
>>> Testing: $ ninja check-clang-sema check-clang-semacxx
>>> Also, no new warnings for clang stage-2 build.
>>>
>>> Reviewers: rjmccall, rsmith, aaron.ballman
>>>
>>> Reviewed By: rjmccall
>>>
>>> Subscribers: cfe-commits
>>>
>>> Tags: #clang
>>>
>>> Differential Revision: https://reviews.llvm.org/D37565
>>>
>>> Modified:
>>> cfe/trunk/docs/ReleaseNotes.rst
>>> cfe/trunk/lib/Sema/SemaChecking.cpp
>>> cfe/trunk/test/Sema/compare.c
>>> cfe/trunk/test/Sema/outof-range-constant-compare.c
>>> cfe/trunk/test/SemaCXX/compare.cpp
>>>
>>> Modified: cfe/trunk/docs/ReleaseNotes.rst
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=312750=312749=312750=diff
>>>
>>> ==
>>> --- cfe/trunk/docs/ReleaseNotes.rst (original)
>>> +++ cfe/trunk/docs/ReleaseNotes.rst Thu Sep  7 15:14:25 2017
>>> @@ -71,6 +71,13 @@ Improvements to Clang's diagnostics
>>>errors/warnings, as the system frameworks might add a method with the
>>> same
>>>selector which could make the message send to ``id`` ambiguous.
>>>
>>> +- ``-Wtautological-compare`` now warns when comparing an unsigned integer
>>> and 0
>>> +  regardless of whether the constant is signed or unsigned."
>>> +
>>> +- ``-Wtautological-compare`` now warns about comparing a signed integer
>>> and 0
>>> +  when the signed integer is coerced to an unsigned type for the

[PATCH] D37308: Interface class with uuid base record

2017-09-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

1 more thing I missed.




Comment at: lib/Sema/SemaDeclCXX.cpp:2389
+  return RD->isStruct() && RD->getName() == "IUnknown" && RD->isEmpty() &&
+ Uuid && Uuid->getGuid() =="---C000-0046";
+}

This also has to ensure that IUnknown doesn't inherit from anyone AND that it 
is in the global namespace.


https://reviews.llvm.org/D37308



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


[PATCH] D37308: Interface class with uuid base record

2017-09-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane requested changes to this revision.
erichkeane added inline comments.
This revision now requires changes to proceed.



Comment at: lib/Sema/SemaDeclCXX.cpp:2377
+/// \brief Tests if the __interface base is public.
+static bool IsRecordPublicInterface(const CXXRecordDecl *RD,
+  AccessSpecifier spec) {

Not sure that 'Record' is the correct word here.  You should likely just do 
"IsDeclPublicInterface".  Additionally (though not necessary to change), the 
only requirement for this type is the isInterface, which comes from TagDecl.



Comment at: lib/Sema/SemaDeclCXX.cpp:2385
+/// behavior in the CL compiler.
+static bool IsUnknownType(const CXXRecordDecl *RD) {
+  auto *Uuid = RD->getAttr();

The type name is "IUnknown".  This function name (and the comment above) needs 
to match this.



Comment at: lib/Sema/SemaDeclCXX.cpp:2393
+/// \brief Test if record and records in inheritance tree is a an Unknown.
+static bool IsOrInheritsFromUnknown(const CXXRecordDecl *RD) {
+  if (RD->getNumBases()) {

This logic is completely wrong.  You are trying to test if RD is IUnknown OR if 
ANY of its bases are IUnknown (or if they inherit).  You absolutely have to 
loop over the bases here, which you aren't doing here at all.





Comment at: test/SemaCXX/ms-uuid.cpp:97
+
+struct __declspec(uuid("---C000-0046")) IUnknown {};
+__interface ISfFileIOPropertyPage : public IUnknown {};

Add some should-compile examples that show multiple inheritance.  Particularly 
where the IUnknown is inherited from the 2nd or later one.


https://reviews.llvm.org/D37308



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


[PATCH] D37308: Interface class with uuid base record

2017-09-08 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 114428.
zahiraam added a comment.

Responding to Erich 's and Aaron's reviews. Thanks.


https://reviews.llvm.org/D37308

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/SemaCXX/ms-uuid.cpp


Index: test/SemaCXX/ms-uuid.cpp
===
--- test/SemaCXX/ms-uuid.cpp
+++ test/SemaCXX/ms-uuid.cpp
@@ -93,3 +93,27 @@
 [uuid("00A0---C000-0049"),
  uuid("00A0---C000-0049")] class C10;
 }
+
+struct __declspec(uuid("---C000-0046")) IUnknown {};
+__interface ISfFileIOPropertyPage : public IUnknown {};
+
+struct __declspec(uuid("---C000-0045")) IUnknown1 {};
+__interface ISfFileIOPropertyPage1 : public IUnknown1 {};  // expected-error 
{{interface type cannot inherit from}}
+
+struct __declspec(uuid("---C000-0046")) IUnknown2 {};
+struct IPropertyPage2 : public IUnknown2 {};
+__interface ISfFileIOPropertyPage2 : public IPropertyPage2 {}; // 
expected-error {{interface type cannot inherit from}}
+
+struct IPropertyPage3 : public IUnknown {};
+__interface ISfFileIOPropertyPage3 : public IPropertyPage3 {};
+
+__interface __declspec(dllimport) ISfFileIOPropertyPage33 : public IUnknown {};
+
+struct __declspec(uuid("---C000-0046")) IUnknown4 {};
+__interface ISfFileIOPropertyPage4 : public IUnknown4 {}; // expected-error 
{{interface type cannot inherit from}}
+
+class __declspec(uuid("---C000-0046")) IUnknown5 {};
+__interface ISfFileIOPropertyPage5 : public IUnknown5 {}; // expected-error 
{{interface type cannot inherit from}}
+
+struct __declspec(dllexport) IUnknown6{};
+__interface foo : public IUnknown6{}; // expected-error {{interface type 
cannot inherit from}}
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -2373,6 +2373,35 @@
   return true;
 }
 
+/// \brief Tests if the __interface base is public.
+static bool IsRecordPublicInterface(const CXXRecordDecl *RD,
+  AccessSpecifier spec) {
+  return RD->isInterface() && spec == AS_public;
+}
+
+/// \brief Test if record is an uuid Unknown.
+/// This is an MS SDK specific type that has a special
+/// behavior in the CL compiler.
+static bool IsUnknownType(const CXXRecordDecl *RD) {
+  auto *Uuid = RD->getAttr();
+  
+  return RD->isStruct() && RD->getName() == "IUnknown" && RD->isEmpty() &&
+ Uuid && Uuid->getGuid() =="---C000-0046";
+}
+
+/// \brief Test if record and records in inheritance tree is a an Unknown.
+static bool IsOrInheritsFromUnknown(const CXXRecordDecl *RD) {
+  if (RD->getNumBases()) {
+const CXXRecordDecl *Base =
+  RD->bases_begin()->getType()->getAsCXXRecordDecl();
+
+return Base && IsUnknownType(Base) && !IsUnknownType(RD) &&
+   IsOrInheritsFromUnknown(Base);
+  } else {
+return IsUnknownType(RD);
+  }
+}
+
 /// Use small set to collect indirect bases.  As this is only used
 /// locally, there's no need to abstract the small size parameter.
 typedef llvm::SmallPtrSet IndirectBaseSet;
@@ -2450,8 +2479,8 @@
   if (const RecordType *Record = NewBaseType->getAs()) {
 const CXXRecordDecl *RD = cast(Record->getDecl());
 if (Class->isInterface() &&
-  (!RD->isInterface() ||
-   KnownBase->getAccessSpecifier() != AS_public)) {
+!IsRecordPublicInterface(RD, KnownBase->getAccessSpecifier()) &&
+!IsOrInheritsFromUnknown(RD)) {
   // The Microsoft extension __interface does not permit bases that
   // are not themselves public interfaces.
   Diag(KnownBase->getLocStart(), diag::err_invalid_base_in_interface)


Index: test/SemaCXX/ms-uuid.cpp
===
--- test/SemaCXX/ms-uuid.cpp
+++ test/SemaCXX/ms-uuid.cpp
@@ -93,3 +93,27 @@
 [uuid("00A0---C000-0049"),
  uuid("00A0---C000-0049")] class C10;
 }
+
+struct __declspec(uuid("---C000-0046")) IUnknown {};
+__interface ISfFileIOPropertyPage : public IUnknown {};
+
+struct __declspec(uuid("---C000-0045")) IUnknown1 {};
+__interface ISfFileIOPropertyPage1 : public IUnknown1 {};  // expected-error {{interface type cannot inherit from}}
+
+struct __declspec(uuid("---C000-0046")) IUnknown2 {};
+struct IPropertyPage2 : public IUnknown2 {};
+__interface ISfFileIOPropertyPage2 : public IPropertyPage2 {}; // expected-error {{interface type cannot inherit from}}
+
+struct IPropertyPage3 : public IUnknown {};
+__interface ISfFileIOPropertyPage3 : public IPropertyPage3 {};
+
+__interface __declspec(dllimport) ISfFileIOPropertyPage33 : public IUnknown {};
+
+struct 

Re: r312750 - [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-08 Thread Hans Wennborg via cfe-commits
On Fri, Sep 8, 2017 at 4:48 AM, Sam McCall via cfe-commits
 wrote:
> Nice fix! It catches a lot of new cases on our codebase, all technically
> correct so far.
>
> A couple of issues though:
> A) Rollout - until we've completely cleaned up, we need to disable
> -Wtautological-compare entirely, which is a valuable check. I imagine anyone
> else using -Werror is in the same boat.
> What do you think about putting the new warnings behind a subcategory? (e.g.
> -Wtautological-compare-unsigned-zero, implied by -Wtautological-compare)
> It's an ugly artifact of the history here, but allows this fix to be rolled
> out in a controlled way.
>
> B) Enums (not new I guess). Typical case: if (enum < 0 || enum > MAX)
> The warning strongly suggests that the enum < 0 check has no effect (for
> enums with nonnegative ranges).
> Clang doesn't seem to optimize such checks out though, and they seem likely
> to catch bugs in some cases. Yes, only if there's UB elsewhere, but I assume
> not optimizing out these checks indicates a deliberate decision to stay
> somewhat compatible with a technically-incorrect mental model.
> If this is the case, should we move these to a -Wtautological-compare-enum
> subcategory?

Just another data point: we're seeing this a lot in Chromium, e.g.

enum MediaDeviceType {
  MEDIA_DEVICE_TYPE_AUDIO_INPUT,
  MEDIA_DEVICE_TYPE_VIDEO_INPUT,
  MEDIA_DEVICE_TYPE_AUDIO_OUTPUT,
  NUM_MEDIA_DEVICE_TYPES,
};

inline bool IsValidMediaDeviceType(MediaDeviceType type) {
  return type >= 0 && type < NUM_MEDIA_DEVICE_TYPES;
}

../../content/common/media/media_devices.h:53:15: warning: comparison
of unsigned enum expression >= 0 is always true
[-Wtautological-unsigned-zero-compare]
  return type >= 0 && type < NUM_MEDIA_DEVICE_TYPES;
  ^  ~

The problem is that the signedness of the enum varies per platform.
For example, when targeting Windows the underlying type is 'int' by
default, and then the comparison isn't tautological.



> On Fri, Sep 8, 2017 at 12:14 AM, Roman Lebedev via cfe-commits
>  wrote:
>>
>> Author: lebedevri
>> Date: Thu Sep  7 15:14:25 2017
>> New Revision: 312750
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=312750=rev
>> Log:
>> [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.
>>
>> Summary:
>> This is a first half(?) of a fix for the following bug:
>> https://bugs.llvm.org/show_bug.cgi?id=34147 (gcc -Wtype-limits)
>>
>> GCC's -Wtype-limits does warn on comparison of unsigned value
>> with signed zero (as in, with 0), but clang only warns if the
>> zero is unsigned (i.e. 0U).
>>
>> Also, be careful not to double-warn, or falsely warn on
>> comparison of signed/fp variable and signed 0.
>>
>> Yes, all these testcases are needed.
>>
>> Testing: $ ninja check-clang-sema check-clang-semacxx
>> Also, no new warnings for clang stage-2 build.
>>
>> Reviewers: rjmccall, rsmith, aaron.ballman
>>
>> Reviewed By: rjmccall
>>
>> Subscribers: cfe-commits
>>
>> Tags: #clang
>>
>> Differential Revision: https://reviews.llvm.org/D37565
>>
>> Modified:
>> cfe/trunk/docs/ReleaseNotes.rst
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>> cfe/trunk/test/Sema/compare.c
>> cfe/trunk/test/Sema/outof-range-constant-compare.c
>> cfe/trunk/test/SemaCXX/compare.cpp
>>
>> Modified: cfe/trunk/docs/ReleaseNotes.rst
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=312750=312749=312750=diff
>>
>> ==
>> --- cfe/trunk/docs/ReleaseNotes.rst (original)
>> +++ cfe/trunk/docs/ReleaseNotes.rst Thu Sep  7 15:14:25 2017
>> @@ -71,6 +71,13 @@ Improvements to Clang's diagnostics
>>errors/warnings, as the system frameworks might add a method with the
>> same
>>selector which could make the message send to ``id`` ambiguous.
>>
>> +- ``-Wtautological-compare`` now warns when comparing an unsigned integer
>> and 0
>> +  regardless of whether the constant is signed or unsigned."
>> +
>> +- ``-Wtautological-compare`` now warns about comparing a signed integer
>> and 0
>> +  when the signed integer is coerced to an unsigned type for the
>> comparison.
>> +  ``-Wsign-compare`` was adjusted not to warn in this case.
>> +
>>  Non-comprehensive list of changes in this release
>>  -
>>
>>
>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=312750=312749=312750=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Sep  7 15:14:25 2017
>> @@ -8567,32 +8567,51 @@ bool HasEnumType(Expr *E) {
>>return E->getType()->isEnumeralType();
>>  }
>>
>> -void CheckTrivialUnsignedComparison(Sema , BinaryOperator *E) {
>> +bool isNonBooleanUnsignedValue(Expr *E) {
>> +  

[PATCH] D36642: [Lexer] Report more precise skipped regions (PR34166)

2017-09-08 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: test/Index/skipped-ranges.c:23
 // RUN: env CINDEXTEST_SHOW_SKIPPED_RANGES=1 c-index-test 
-test-annotate-tokens=%s:1:1:16:1 %s | FileCheck %s
-// CHECK: Skipping: [5:2 - 6:7]
-// CHECK: Skipping: [8:2 - 12:7]
-// CHECK: Skipping: [14:2 - 20:7]
+// CHECK: Skipping: [5:1 - 7:1]
+// CHECK: Skipping: [8:1 - 13:1]

arphaman wrote:
> Some editor clients might want to grey out the skipped PP ranges. The new end 
> location is not ideal as we wouldn't want to grey out the trailing comments 
> after the `#endif`.
It seems like the end location we want should be different for the coverage 
client and the indexer. I'll modify the callback so we pass along both end 
locations.


https://reviews.llvm.org/D36642



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


[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

2017-09-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/clang-tidy/cppcoreguidelines-owning-memory.cpp:39
+  return new int(42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning a 'gsl::owner<>' from a 
function but not declaring it; return type is 'int *'
+}

JonasToth wrote:
> aaron.ballman wrote:
> > This diagnostic confuses me -- there's no gsl::owner<> involved anywhere; 
> > am I missing something?
> `owner<>` is not involved, but the guidelines say, that `new` must be 
> assigned to an owner.
> 
> This is in line with the resource semantics. Everything that creates an 
> resource, that must be released (no RAII available) shall be annotated.
> 
> The diagnostic is bad, though.
> 
> `Returning a newly created resource from function 'functionname', without 
> declaring it as 'gsl::owner<>'; type is '...'`
Okay, that makes more sense to me. I don't think the name of the function helps 
all that much in the diagnostic, however. What about:

`"returning a newly created resource of type %0 from a function whose return 
type is not 'gsl::owner<>'"`


https://reviews.llvm.org/D36354



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


[PATCH] D37572: [clang-tidy] SuspiciousEnumUsageCheck bugfix

2017-09-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/clang-tidy/misc-suspicious-enum-usage.cpp:122
+struct a> {
+  enum { ah = ad::m,
+ ai = ae::m,

alexfh wrote:
> alexfh wrote:
> > aaron.ballman wrote:
> > > alexfh wrote:
> > > > aaron.ballman wrote:
> > > > > This seems like a lot of complicated code for the test case -- can 
> > > > > this be reduced further?
> > > > This is the best creduce could do. It should be possible to make this 
> > > > much shorter, but I wouldn't spend too much time on that.
> > > I'd appreciate the time spent because this is an almost-unintelligible 
> > > test for anyone reading it -- it's hard to understand what's going on 
> > > there.
> > namespace PR34400 {
> >   enum { E1 = 0 };
> >   enum { E2 = -1 };
> > 
> >   enum { l = E1 | E2 };
> > }
> > 
> This might not cover both code paths affected by the bug. But it should be 
> easy to construct a case for the second one.
It's certainly an easier case to grok, thank you! :-D


https://reviews.llvm.org/D37572



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


[PATCH] D36150: [clangd] LSP extension to switch between source/header file

2017-09-08 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 114424.
Nebiroth marked 7 inline comments as done.
Nebiroth added a comment.

Ran clang-format on modified files.
Minor refactoring.


https://reviews.llvm.org/D36150

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  clangd/tool/ClangdMain.cpp

Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -12,7 +12,6 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Program.h"
-
 #include 
 #include 
 #include 
Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -47,7 +47,9 @@
   virtual void onCompletion(TextDocumentPositionParams Params, StringRef ID,
 JSONOutput ) = 0;
   virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID,
-JSONOutput ) = 0;
+JSONOutput ) = 0;
+  virtual void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID,
+JSONOutput ) = 0;
 };
 
 void regiterCallbackHandlers(JSONRPCDispatcher , JSONOutput ,
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -204,6 +204,22 @@
   ProtocolCallbacks 
 };
 
+struct SwitchSourceHeaderHandler : Handler {
+  SwitchSourceHeaderHandler(JSONOutput , ProtocolCallbacks )
+  : Handler(Output), Callbacks(Callbacks) {}
+
+  void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override {
+auto TDPP = TextDocumentIdentifier::parse(Params);
+if (!TDPP)
+  return;
+
+Callbacks.onSwitchSourceHeader(*TDPP, ID, Output);
+  }
+
+private:
+  ProtocolCallbacks 
+};
+
 } // namespace
 
 void clangd::regiterCallbackHandlers(JSONRPCDispatcher ,
@@ -237,6 +253,10 @@
   Dispatcher.registerHandler(
   "textDocument/completion",
   llvm::make_unique(Out, Callbacks));
-  Dispatcher.registerHandler("textDocument/definition",
+  Dispatcher.registerHandler(
+  "textDocument/definition",
   llvm::make_unique(Out, Callbacks));
+  Dispatcher.registerHandler(
+  "textDocument/switchSourceHeader",
+  llvm::make_unique(Out, Callbacks));
 }
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -182,6 +182,9 @@
   /// Get definition of symbol at a specified \p Line and \p Column in \p File.
   Tagged findDefinitions(PathRef File, Position Pos);
 
+  /// Helper function that returns a path to the corresponding source file when given a header file and vice versa.
+  llvm::Optional switchSourceHeader(PathRef Path);
+
   /// Run formatting for \p Rng inside \p File.
   std::vector formatRange(PathRef File, Range Rng);
   /// Run formatting for the whole \p File.
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -15,9 +15,11 @@
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
+using namespace llvm;
 using namespace clang;
 using namespace clang::clangd;
 
@@ -273,16 +275,76 @@
   return DumpFuture.get();
 }
 
-Tagged
-ClangdServer::findDefinitions(PathRef File, Position Pos) {
+Tagged ClangdServer::findDefinitions(PathRef File,
+Position Pos) {
   auto FileContents = DraftMgr.getDraft(File);
-  assert(FileContents.Draft && "findDefinitions is called for non-added document");
+  assert(FileContents.Draft &&
+ "findDefinitions is called for non-added document");
 
   std::vector Result;
   auto TaggedFS = FSProvider.getTaggedFileSystem(File);
-  Units.runOnUnit(File, *FileContents.Draft, ResourceDir, CDB, PCHs,
-  TaggedFS.Value, [&](ClangdUnit ) {
-Result = Unit.findDefinitions(Pos);
-  });
+  Units.runOnUnit(
+  File, *FileContents.Draft, ResourceDir, CDB, PCHs, TaggedFS.Value,
+  [&](ClangdUnit ) { Result = Unit.findDefinitions(Pos); });
   return make_tagged(std::move(Result), TaggedFS.Tag);
 }
+
+llvm::Optional ClangdServer::switchSourceHeader(PathRef Path) {
+
+  StringRef SourceExtensions[] = {".cpp", ".c", ".cc", ".cxx",
+  ".c++", ".m", ".mm"};
+  StringRef HeaderExtensions[] = {".h", ".hh", ".hpp", ".hxx", ".inc"};
+
+  StringRef PathExt = llvm::sys::path::extension(Path);
+
+  // Lookup in a list of known extensions.
+  auto SourceIter =
+

[PATCH] D37491: [Preamble] Fixed preamble breaking with BOM presence (and particularly, fluctuating BOM presence)

2017-09-08 Thread Cameron via Phabricator via cfe-commits
cameron314 added a comment.

It seems there's other users of `PrecompiledPreamble` that would have to be 
fixed, yes. If we go with my original fix of taking into account the BOM in the 
preamble bounds, there's no way of reusing the PCH when the BOM 
appears/disappears. I still maintain this is a common use case for IDE-type 
clients. This type of performance bug is very hard to track down.

@erikjv: Yes, I think this will fix PR25023.
PR21144 is unrelated; clang uses UTF-8 byte offsets instead of 
logical-character offsets for column numbers, which makes sense to me.




Comment at: lib/Frontend/ASTUnit.cpp:1262
+  // This ensures offsets within and past the preamble stay valid.
+  if (MainFileBuffer->getBuffer().startswith("\xEF\xBB\xBF")) {
+MainFileBuffer = llvm::MemoryBuffer::getMemBufferSlice(

ilya-biryukov wrote:
> It seems that having only this chunk would fix your issue.
> Everything else is just a non-functional refactoring, maybe let's focus on 
> that part (and tests) in this review and send the rest as a separate change?
> To keep refactoring and functional changes logically separate.
Yes, with this form of the fix, the other changes are mostly cosmetic. I could 
simply revert them, it's not worth the hassle of submitting another patch.


https://reviews.llvm.org/D37491



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


[PATCH] D37101: [clangd] Add support for snippet completions

2017-09-08 Thread Raoul Wols via Phabricator via cfe-commits
rwols updated this revision to Diff 114415.
rwols added a comment.

Update the description for the "-enable-snippets" option.


https://reviews.llvm.org/D37101

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/clients/clangd-vscode/package.json
  clangd/tool/ClangdMain.cpp
  test/clangd/authority-less-uri.test
  test/clangd/completion-snippet.test
  test/clangd/completion.test

Index: test/clangd/completion.test
===
--- test/clangd/completion.test
+++ test/clangd/completion.test
@@ -16,25 +16,25 @@
 # nondeterministic, so we check regardless of order.
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a"}
-# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb"}
-# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc"}
-# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator="}
-# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake"}
-# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f"}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb","insertTextFormat":1}
+# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc","insertTextFormat":1}
+# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator=","insertTextFormat":1}
+# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake","insertTextFormat":1}
+# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f","insertTextFormat":1}
 # CHECK: ]}
 Content-Length: 148
 
 {"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}}
 # Repeat the completion request, expect the same results.
 #
 # CHECK: {"jsonrpc":"2.0","id":2,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a"}
-# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb"}
-# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc"}
-# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator="}
-# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake"}
-# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f"}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb","insertTextFormat":1}
+# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc","insertTextFormat":1}
+# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator=","insertTextFormat":1}
+# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake","insertTextFormat":1}
+# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f","insertTextFormat":1}
 # CHECK: ]}
 # Update the source file and check for completions again.
 Content-Length: 226
@@ -47,7 +47,7 @@
 # Repeat the completion request, expect the same results.
 #
 # CHECK: {"jsonrpc":"2.0","id":3,"result":[
-# CHECK-DAG: {"label":"func()","kind":2,"detail":"int (*)(int, int)","sortText":"00034func","filterText":"func","insertText":"func"}
+# CHECK-DAG: {"label":"func()","kind":2,"detail":"int (*)(int, int)","sortText":"00034func","filterText":"func","insertText":"func","insertTextFormat":1}
 # CHECK: ]}
 Content-Length: 44
 
Index: test/clangd/completion-snippet.test
===
--- /dev/null

[PATCH] D36973: [libclang] Add support for querying cursor availability

2017-09-08 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe requested changes to this revision.
jbcoe added inline comments.
This revision now requires changes to proceed.



Comment at: bindings/python/tests/cindex/test_cursor.py:399
+else:
+assert False, "Could not find cursor for deleted constructor"
+

Can you add tests for the other `AvailabilityKind`s?


https://reviews.llvm.org/D36973



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


[PATCH] D37474: [PCH] Allow VFS to be used for tests that generate PCH files

2017-09-08 Thread Cameron via Phabricator via cfe-commits
cameron314 updated this revision to Diff 114414.
cameron314 added a comment.

The latest patch. I think this one should do the trick :-)


https://reviews.llvm.org/D37474

Files:
  include/clang/Frontend/PrecompiledPreamble.h
  lib/Frontend/ASTUnit.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/PCHPreambleTest.cpp

Index: unittests/Frontend/PCHPreambleTest.cpp
===
--- /dev/null
+++ unittests/Frontend/PCHPreambleTest.cpp
@@ -0,0 +1,156 @@
+//-- unittests/Frontend/PCHPreambleTest.cpp - FrontendAction tests ---//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Frontend/ASTUnit.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/FrontendOptions.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/FileManager.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang;
+
+namespace {
+
+class ReadCountingInMemoryFileSystem : public vfs::InMemoryFileSystem
+{
+  std::map ReadCounts;
+
+public:
+  ErrorOr openFileForRead(const Twine ) override
+  {
+SmallVector PathVec;
+Path.toVector(PathVec);
+llvm::sys::path::remove_dots(PathVec, true);
+++ReadCounts[std::string(PathVec.begin(), PathVec.end())];
+return InMemoryFileSystem::openFileForRead(Path);
+  }
+
+  unsigned GetReadCount(const Twine ) const
+  {
+auto it = ReadCounts.find(Path.str());
+return it == ReadCounts.end() ? 0 : it->second;
+  }
+};
+
+class PCHPreambleTest : public ::testing::Test {
+  IntrusiveRefCntPtr VFS;
+  StringMap RemappedFiles;
+  std::shared_ptr PCHContainerOpts;
+  FileSystemOptions FSOpts;
+
+public:
+  void SetUp() override {
+VFS = new ReadCountingInMemoryFileSystem();
+// We need the working directory to be set to something absolute,
+// otherwise it ends up being inadvertently set to the current
+// working directory in the real file system due to a series of
+// unfortunate conditions interacting badly.
+// What's more, this path *must* be absolute on all (real)
+// filesystems, so just '/' won't work (e.g. on Win32).
+VFS->setCurrentWorkingDirectory("//./");
+  }
+
+  void TearDown() override {
+  }
+
+  void AddFile(const std::string , const std::string ) {
+::time_t now;
+::time();
+VFS->addFile(Filename, now, MemoryBuffer::getMemBufferCopy(Contents, Filename));
+  }
+
+  void RemapFile(const std::string , const std::string ) {
+RemappedFiles[Filename] = Contents;
+  }
+
+  std::unique_ptr ParseAST(const std::string ) {
+PCHContainerOpts = std::make_shared();
+std::shared_ptr CI(new CompilerInvocation);
+CI->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile(EntryFile, FrontendOptions::getInputKindForExtension(
+llvm::sys::path::extension(EntryFile).substr(1;
+
+CI->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+
+CI->getPreprocessorOpts().RemappedFileBuffers = GetRemappedFiles();
+
+PreprocessorOptions  = CI->getPreprocessorOpts();
+PPOpts.RemappedFilesKeepOriginalName = true;
+
+IntrusiveRefCntPtr
+  Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions, new DiagnosticConsumer));
+
+FileManager *FileMgr = new FileManager(FSOpts, VFS);
+
+std::unique_ptr AST = ASTUnit::LoadFromCompilerInvocation(
+  CI, PCHContainerOpts, Diags, FileMgr, false, false,
+  /*PrecompilePreambleAfterNParses=*/1);
+return AST;
+  }
+
+  bool ReparseAST(const std::unique_ptr ) {
+bool reparseFailed = AST->Reparse(PCHContainerOpts, GetRemappedFiles(), VFS);
+return !reparseFailed;
+  }
+
+  unsigned GetFileReadCount(const std::string ) const {
+return VFS->GetReadCount(Filename);
+  }
+
+private:
+  std::vector>
+  GetRemappedFiles() const {
+std::vector> Remapped;
+for (const auto  : RemappedFiles) {
+  std::unique_ptr buf = MemoryBuffer::getMemBufferCopy(
+RemappedFile.second, RemappedFile.first());
+  Remapped.emplace_back(RemappedFile.first(), buf.release());
+}
+return Remapped;
+  }
+};
+
+TEST_F(PCHPreambleTest, ReparseWithOverriddenFileDoesNotInvalidatePreamble) {
+  std::string Header1 = "//./header1.h";
+  std::string Header2 = "//./header2.h";
+  std::string MainName = "//./main.cpp";
+  AddFile(Header1, "");
+  AddFile(Header2, "#pragma once");
+  AddFile(MainName,
+"#include 

[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

2017-09-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: test/clang-tidy/cppcoreguidelines-owning-memory.cpp:39
+  return new int(42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning a 'gsl::owner<>' from a 
function but not declaring it; return type is 'int *'
+}

aaron.ballman wrote:
> This diagnostic confuses me -- there's no gsl::owner<> involved anywhere; am 
> I missing something?
`owner<>` is not involved, but the guidelines say, that `new` must be assigned 
to an owner.

This is in line with the resource semantics. Everything that creates an 
resource, that must be released (no RAII available) shall be annotated.

The diagnostic is bad, though.

`Returning a newly created resource from function 'functionname', without 
declaring it as 'gsl::owner<>'; type is '...'`


https://reviews.llvm.org/D36354



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


Re: [PATCH] D37604: Disable debuginfo-tests for non-native configurations

2017-09-08 Thread Adrian Prantl via cfe-commits

> On Sep 8, 2017, at 11:43 AM, Adrian Prantl  wrote:
> 
> 
>> On Sep 8, 2017, at 10:54 AM, Paul Robinson via Phabricator 
>>  wrote:
>> 
>> probinson added a comment.
>> 
>> In https://reviews.llvm.org/D37604#864187, @aprantl wrote:
>> 
>>> This seems reasonable to me, thanks!
>>> When you commit this, could you please double-check that the tests are 
>>> still running on the green dragon builders? I'll also keep an eye on them.
> 
>> 
>> I was able to google "llvm green dragon" and find what looks like the right 
>> page, but I kind of would have expected to see a link on the llvm.org front 
>> page?  Am I just not looking in the right place?
> 
> This is our canonical url: http://green.lab.llvm.org/green/
> I've CC'ed Mike, perhaps he can work with Tanya to feature the link more 
> prominently?
> 
> I just checked and the tests are running in the first green build after your 
> commit:
> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA_check/35303/consoleFull
> 

Sorry — there was an infrastructure issue this morning, that caused those 
builds to not finish chronologically, The run of the tests after your commit 
hasn't started yet. I'll watch out for it.

-- adrian

> PASS: Clang :: debuginfo-tests/aggregate-indirect-arg.cpp (11846 of 39540)
> PASS: Clang :: debuginfo-tests/vla.c (11847 of 39540)
> PASS: Clang :: debuginfo-tests/dbg-arg.c (11848 of 39540)
> PASS: Clang :: debuginfo-tests/sret.cpp (11849 of 39540)
> PASS: Clang :: debuginfo-tests/ctor.cpp (11850 of 39540)
> PASS: Clang :: debuginfo-tests/stack-var.c (11851 of 39540)
> 
> ...
> 
> thanks for checking!
> adrian

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


[PATCH] D37436: Initial implementation of C attributes (WG14 N2137)

2017-09-08 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Accepting this under `-std=c2x` is premature. We don't even know whether there 
will be such a standard yet, and this has not been voted into a working draft. 
But the `-f` flag form is OK.




Comment at: include/clang/Driver/Options.td:607
 
+def fcattributes : Flag<["-"], "fc-attributes">, Group,
+  Flags<[DriverOption, CC1Option]>, HelpText<"Enable '[[]]' attributes in C">;

Missing underscore between "fc" and "attributes".



Comment at: lib/Parse/ParseDecl.cpp:1512
 /// should try to parse it.
-bool Parser::DiagnoseProhibitedCXX11Attribute() {
+bool Parser::DiagnoseProhibitedAttribute() {
   assert(Tok.is(tok::l_square) && NextToken().is(tok::l_square));

This name should still reference the syntax used, since it is specific to 
[[...]] attribute syntax. Calling that CXX11 attribute syntax (even when used 
in C) doesn't seem overly confusing to me. If you want a different name for 
this, I'd be OK with that, but it should not be simply "Attribute".


https://reviews.llvm.org/D37436



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


r312818 - [Coverage] Precise region termination with deferred regions (reapply)

2017-09-08 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Sep  8 11:44:56 2017
New Revision: 312818

URL: http://llvm.org/viewvc/llvm-project?rev=312818=rev
Log:
[Coverage] Precise region termination with deferred regions (reapply)

The current coverage implementation doesn't handle region termination
very precisely. Take for example an `if' statement with a `return':

  void f() {
if (true) {
  return; // The `if' body's region is terminated here.
}
// This line gets the same coverage as the `if' condition.
  }

If the function `f' is called, the line containing the comment will be
marked as having executed once, which is not correct.

The solution here is to create a deferred region after terminating a
region. The deferred region is completed once the start location of the
next statement is known, and is then pushed onto the region stack.
In the cases where it's not possible to complete a deferred region, it
can safely be dropped.

Testing: lit test updates, a stage2 coverage-enabled build of clang

This is a reapplication but there are no changes from the original commit.
With D36813, the segment builder in llvm will be able to handle deferred
regions correctly.

Added:
cfe/trunk/test/CoverageMapping/deferred-region.cpp
Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/test/CoverageMapping/label.cpp
cfe/trunk/test/CoverageMapping/moremacros.c
cfe/trunk/test/CoverageMapping/return.c
cfe/trunk/test/CoverageMapping/switch.cpp
cfe/trunk/test/CoverageMapping/switchmacro.c
cfe/trunk/test/CoverageMapping/trycatch.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=312818=312817=312818=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Fri Sep  8 11:44:56 2017
@@ -45,10 +45,14 @@ class SourceMappingRegion {
   /// \brief The region's ending location.
   Optional LocEnd;
 
+  /// Whether this region should be emitted after its parent is emitted.
+  bool DeferRegion;
+
 public:
   SourceMappingRegion(Counter Count, Optional LocStart,
-  Optional LocEnd)
-  : Count(Count), LocStart(LocStart), LocEnd(LocEnd) {}
+  Optional LocEnd, bool DeferRegion = 
false)
+  : Count(Count), LocStart(LocStart), LocEnd(LocEnd),
+DeferRegion(DeferRegion) {}
 
   const Counter () const { return Count; }
 
@@ -71,6 +75,10 @@ public:
 assert(LocEnd && "Region has no end location");
 return *LocEnd;
   }
+
+  bool isDeferred() const { return DeferRegion; }
+
+  void setDeferred(bool Deferred) { DeferRegion = Deferred; }
 };
 
 /// Spelling locations for the start and end of a source region.
@@ -409,6 +417,10 @@ struct CounterCoverageMappingBuilder
   /// \brief A stack of currently live regions.
   std::vector RegionStack;
 
+  /// The currently deferred region: its end location and count can be set once
+  /// its parent has been popped from the region stack.
+  Optional DeferredRegion;
+
   CounterExpressionBuilder Builder;
 
   /// \brief A location in the most recently visited file or macro.
@@ -444,19 +456,60 @@ struct CounterCoverageMappingBuilder
   /// used with popRegions to exit a "scope", ending the region that was 
pushed.
   size_t pushRegion(Counter Count, Optional StartLoc = None,
 Optional EndLoc = None) {
-if (StartLoc)
+if (StartLoc) {
   MostRecentLocation = *StartLoc;
+  completeDeferred(Count, MostRecentLocation);
+}
 RegionStack.emplace_back(Count, StartLoc, EndLoc);
 
 return RegionStack.size() - 1;
   }
 
+  /// Complete any pending deferred region by setting its end location and
+  /// count, and then pushing it onto the region stack.
+  size_t completeDeferred(Counter Count, SourceLocation DeferredEndLoc) {
+size_t Index = RegionStack.size();
+if (!DeferredRegion)
+  return Index;
+
+// Consume the pending region.
+SourceMappingRegion DR = DeferredRegion.getValue();
+DeferredRegion = None;
+
+// If the region ends in an expansion, find the expansion site.
+if (SM.getFileID(DeferredEndLoc) != SM.getMainFileID()) {
+  FileID StartFile = SM.getFileID(DR.getStartLoc());
+  if (isNestedIn(DeferredEndLoc, StartFile)) {
+do {
+  DeferredEndLoc = getIncludeOrExpansionLoc(DeferredEndLoc);
+} while (StartFile != SM.getFileID(DeferredEndLoc));
+  }
+}
+
+// The parent of this deferred region ends where the containing decl ends,
+// so the region isn't useful.
+if (DR.getStartLoc() == DeferredEndLoc)
+  return Index;
+
+// If we're visiting statements in non-source order (e.g switch cases or
+// a loop condition) we can't construct a sensible deferred region.
+if (!SpellingRegion(SM, DR.getStartLoc(), 
DeferredEndLoc).isInSourceOrder())
+  

[PATCH] D33852: Enable __declspec(selectany) on linux

2017-09-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/AttrDocs.td:3154
+
+def SelectAnyDocs : Documentation {
+   let Content = [{This attribute makes global symbol have a weak definition

aaron.ballman wrote:
> majnemer wrote:
> > aaron.ballman wrote:
> > > Prazek wrote:
> > > > aaron.ballman wrote:
> > > > > Prazek wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > I think you need to set the `Category` as well.
> > > > > > > 
> > > > > > > To test this you should run something like (replacing  and 
> > > > > > > fixing up path separators as needed):
> > > > > > > ```
> > > > > > > clang-tblgen -gen-attr-docs -I \llvm\tools\clang\include 
> > > > > > > \llvm\tools\clang\include\clang\Basic\Attr.td -o 
> > > > > > > \llvm\tools\clang\docs\AttributeReference.rst
> > > > > > > ```
> > > > > > Thanks for the testing command. Should I do anything in order to 
> > > > > > check if docs build?
> > > > > > I enabled docs with -DLLVM_BUILD_DOCS=ON, and I have sphinx. 
> > > > > > Everything builds, but I don't see docs anywhere.
> > > > > > 
> > > > > > the docs looks like this:
> > > > > > +selectany (gnu::selectany)
> > > > > > +--
> > > > > > +.. csv-table:: Supported Syntaxes
> > > > > > +   :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma", 
> > > > > > "Pragma clang attribute"
> > > > > > +
> > > > > > +   "X","X","X","", "", ""
> > > > > > +
> > > > > > +This attribute appertains to a global symbol, causing it to have a 
> > > > > > weak
> > > > > > +definition (
> > > > > > +.. _`linkonce`: https://llvm.org/docs/LangRef.html#linkage-types
> > > > > > +), allowing the linker to select any definition.
> > > > > > +
> > > > > > +For more information see
> > > > > > +.. `gcc documentation`: 
> > > > > > https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Microsoft-Windows-Variable-Attributes.html
> > > > > > +
> > > > > > Thanks for the testing command. Should I do anything in order to 
> > > > > > check if docs build?
> > > > > 
> > > > > On Windows, I use `make html` within the clang\docs directory to 
> > > > > generate the actual sphinx docs -- that will tell you if there are 
> > > > > sphinx issues. Be sure you do *not* commit the AttributeReference.rst 
> > > > > file that it generates, however.
> > > > I tried building docs but it doesn't seem that there is any target like 
> > > > "html". Do you know if there is documentation on how to build docs? I 
> > > > couldn't find any.
> > > I don't know that we have any docs on that, but I believe the command you 
> > > want to execute is `sphinx-build -b html -d _build/doctrees . 
> > > _build/html` (I pulled this from make.bat in the docs directory.)
> > This is not the first time this has come up. Can you please add a comment 
> > to the top of AttrDocs.td which explains how to generate the HTML?
> Definitely a good idea, I'll tackle it when I have a moment.
I found the moment, and there are now some docs with r312811.

Btw, you want to use `make -f Makefile.sphinx html` (from within the docs 
directory) to generate the docs on non-Windows platforms.


https://reviews.llvm.org/D33852



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


Re: [PATCH] D37604: Disable debuginfo-tests for non-native configurations

2017-09-08 Thread Adrian Prantl via cfe-commits

> On Sep 8, 2017, at 10:54 AM, Paul Robinson via Phabricator 
>  wrote:
> 
> probinson added a comment.
> 
> In https://reviews.llvm.org/D37604#864187, @aprantl wrote:
> 
>> This seems reasonable to me, thanks!
>> When you commit this, could you please double-check that the tests are still 
>> running on the green dragon builders? I'll also keep an eye on them.

> 
> I was able to google "llvm green dragon" and find what looks like the right 
> page, but I kind of would have expected to see a link on the llvm.org front 
> page?  Am I just not looking in the right place?

This is our canonical url: http://green.lab.llvm.org/green/
I've CC'ed Mike, perhaps he can work with Tanya to feature the link more 
prominently?

I just checked and the tests are running in the first green build after your 
commit:
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA_check/35303/consoleFull

PASS: Clang :: debuginfo-tests/aggregate-indirect-arg.cpp (11846 of 39540)
PASS: Clang :: debuginfo-tests/vla.c (11847 of 39540)
PASS: Clang :: debuginfo-tests/dbg-arg.c (11848 of 39540)
PASS: Clang :: debuginfo-tests/sret.cpp (11849 of 39540)
PASS: Clang :: debuginfo-tests/ctor.cpp (11850 of 39540)
PASS: Clang :: debuginfo-tests/stack-var.c (11851 of 39540)

...

thanks for checking!
adrian
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r312811 - Add some documentation on how to generate the documentation.

2017-09-08 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Sep  8 11:40:39 2017
New Revision: 312811

URL: http://llvm.org/viewvc/llvm-project?rev=312811=rev
Log:
Add some documentation on how to generate the documentation.

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=312811=312810=312811=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri Sep  8 11:40:39 2017
@@ -7,6 +7,24 @@
 //
 //===-===//
 
+// To test that the documentation builds cleanly, you must run clang-tblgen to
+// convert the .td file into a .rst file, and then run sphinx to convert the
+// .rst file into an HTML file. After completing testing, you should revert the
+// generated .rst file so that the modified version does not get checked in to
+// version control.
+//
+// To run clang-tblgen to generate the .rst file:
+// clang-tblgen -gen-attr-docs -I /llvm/tools/clang/include
+//   /llvm/tools/clang/include/clang/Basic/Attr.td -o
+//   /llvm/tools/clang/docs/AttributeReference.rst
+//
+// To run sphinx to generate the .html files (note that sphinx-build must be
+// available on the PATH):
+// Windows (from within the clang\docs directory):
+//   make.bat html
+// Non-Windows (from within the clang\docs directory):
+//   make -f Makefile.sphinx html
+
 def GlobalDocumentation {
   code Intro =[{..
   ---


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


[PATCH] D37634: clang-rename: let -force handle multiple renames

2017-09-08 Thread Miklos Vajna via Phabricator via cfe-commits
vmiklos created this revision.

The use case is that renaming multiple symbols in a large enough codebase is
much faster if all of these can be done with a single invocation, but
there will be multiple translation units where one or more symbols are
not found.

  

Old behavior was to exit with an error (default) or exit without
reporting an error (-force). New behavior is that -force results in a
best-effort rename: rename symbols which are found and just ignore the
rest.

  

The existing help for -force sort of already implies this behavior.


https://reviews.llvm.org/D37634

Files:
  lib/Tooling/Refactoring/Rename/RenamingAction.cpp
  lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
  test/clang-rename/ForceMulti.cpp
  tools/clang-rename/ClangRename.cpp


Index: tools/clang-rename/ClangRename.cpp
===
--- tools/clang-rename/ClangRename.cpp
+++ tools/clang-rename/ClangRename.cpp
@@ -175,12 +175,6 @@
 return 1;
   }
 
-  if (Force && PrevNames.size() < NewNames.size()) {
-// No matching PrevName for all NewNames. Without Force this is an error
-// above already.
-return 0;
-  }
-
   // Perform the renaming.
   tooling::RenamingAction RenameAction(NewNames, PrevNames, USRList,
Tool.getReplacements(), PrintLocations);
Index: test/clang-rename/ForceMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ForceMulti.cpp
@@ -0,0 +1,8 @@
+class B /* Test 1 */ { // CHECK: class B2 /* Test 1 */ {
+};
+
+class D : public B /* Test 1 */ { // CHECK: class D : public B2 /* Test 1 */ {
+};
+
+// Test 1.
+// RUN: clang-rename -force -qualified-name B -new-name B2 -qualified-name E 
-new-name E2 %s -- | sed 's,//.*,,' | FileCheck %s
Index: lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
===
--- lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -198,8 +198,11 @@
 return false;
   }
 
-  if (Force)
+  if (Force) {
+SpellingNames.push_back(std::string());
+USRList.push_back(std::vector());
 return true;
+  }
 
   unsigned CouldNotFindSymbolNamed = Engine.getCustomDiagID(
   DiagnosticsEngine::Error, "clang-rename could not find symbol %0");
Index: lib/Tooling/Refactoring/Rename/RenamingAction.cpp
===
--- lib/Tooling/Refactoring/Rename/RenamingAction.cpp
+++ lib/Tooling/Refactoring/Rename/RenamingAction.cpp
@@ -84,8 +84,13 @@
 FileToReplaces(FileToReplaces), PrintLocations(PrintLocations) {}
 
   void HandleTranslationUnit(ASTContext ) override {
-for (unsigned I = 0; I < NewNames.size(); ++I)
+for (unsigned I = 0; I < NewNames.size(); ++I) {
+  // If the previous name was not found, ignore this rename request.
+  if (PrevNames[I].empty())
+continue;
+
   HandleOneRename(Context, NewNames[I], PrevNames[I], USRList[I]);
+}
   }
 
   void HandleOneRename(ASTContext , const std::string ,


Index: tools/clang-rename/ClangRename.cpp
===
--- tools/clang-rename/ClangRename.cpp
+++ tools/clang-rename/ClangRename.cpp
@@ -175,12 +175,6 @@
 return 1;
   }
 
-  if (Force && PrevNames.size() < NewNames.size()) {
-// No matching PrevName for all NewNames. Without Force this is an error
-// above already.
-return 0;
-  }
-
   // Perform the renaming.
   tooling::RenamingAction RenameAction(NewNames, PrevNames, USRList,
Tool.getReplacements(), PrintLocations);
Index: test/clang-rename/ForceMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ForceMulti.cpp
@@ -0,0 +1,8 @@
+class B /* Test 1 */ { // CHECK: class B2 /* Test 1 */ {
+};
+
+class D : public B /* Test 1 */ { // CHECK: class D : public B2 /* Test 1 */ {
+};
+
+// Test 1.
+// RUN: clang-rename -force -qualified-name B -new-name B2 -qualified-name E -new-name E2 %s -- | sed 's,//.*,,' | FileCheck %s
Index: lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
===
--- lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
+++ lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
@@ -198,8 +198,11 @@
 return false;
   }
 
-  if (Force)
+  if (Force) {
+SpellingNames.push_back(std::string());
+USRList.push_back(std::vector());
 return true;
+  }
 
   unsigned CouldNotFindSymbolNamed = Engine.getCustomDiagID(
   DiagnosticsEngine::Error, "clang-rename could not find symbol %0");
Index: lib/Tooling/Refactoring/Rename/RenamingAction.cpp
===
--- 

[PATCH] D37629: [Sema] Move some stuff into -Wtautological-unsigned-enum-zero-compare

2017-09-08 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D37629#865068, @lebedev.ri wrote:

> And finish reducing the code by for-range-loop`ing over array + use 
> `std::array`.


I will need to fix handling of the second edge-case (comparison with max 
unsigned value or with min/max for signed values), so having the code this way 
*might* help..


Repository:
  rL LLVM

https://reviews.llvm.org/D37629



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


r312810 - Delete empty file test/CodeGenCXX/atomic-align.cpp after the revert at rL312805.

2017-09-08 Thread Wei Mi via cfe-commits
Author: wmi
Date: Fri Sep  8 11:31:21 2017
New Revision: 312810

URL: http://llvm.org/viewvc/llvm-project?rev=312810=rev
Log:
Delete empty file test/CodeGenCXX/atomic-align.cpp after the revert at rL312805.

Removed:
cfe/trunk/test/CodeGenCXX/atomic-align.cpp

Removed: cfe/trunk/test/CodeGenCXX/atomic-align.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/atomic-align.cpp?rev=312809=auto
==
(empty)


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


r312805 - Revert rL312801 since it generated some calls from libatomic and broke some tests.

2017-09-08 Thread Wei Mi via cfe-commits
Author: wmi
Date: Fri Sep  8 11:10:13 2017
New Revision: 312805

URL: http://llvm.org/viewvc/llvm-project?rev=312805=rev
Log:
Revert rL312801 since it generated some calls from libatomic and broke some 
tests.

Modified:
cfe/trunk/lib/CodeGen/CGAtomic.cpp
cfe/trunk/test/CodeGenCXX/atomic-align.cpp

Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=312805=312804=312805=diff
==
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Fri Sep  8 11:10:13 2017
@@ -745,20 +745,20 @@ RValue CodeGenFunction::EmitAtomicExpr(A
   QualType MemTy = AtomicTy;
   if (const AtomicType *AT = AtomicTy->getAs())
 MemTy = AT->getValueType();
-  llvm::Value *IsWeak = nullptr, *OrderFail = nullptr;
-
-  Address Val1 = Address::invalid();
-  Address Val2 = Address::invalid();
-  Address Dest = Address::invalid();
-  Address Ptr = EmitPointerWithAlignment(E->getPtr());
-
   CharUnits sizeChars, alignChars;
   std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy);
   uint64_t Size = sizeChars.getQuantity();
   unsigned MaxInlineWidthInBits = getTarget().getMaxAtomicInlineWidth();
-  bool UseLibcall = (sizeChars != Ptr.getAlignment() ||
+  bool UseLibcall = (sizeChars != alignChars ||
  getContext().toBits(sizeChars) > MaxInlineWidthInBits);
 
+  llvm::Value *IsWeak = nullptr, *OrderFail = nullptr;
+
+  Address Val1 = Address::invalid();
+  Address Val2 = Address::invalid();
+  Address Dest = Address::invalid();
+  Address Ptr(EmitScalarExpr(E->getPtr()), alignChars);
+
   if (E->getOp() == AtomicExpr::AO__c11_atomic_init ||
   E->getOp() == AtomicExpr::AO__opencl_atomic_init) {
 LValue lvalue = MakeAddrLValue(Ptr, AtomicTy);

Modified: cfe/trunk/test/CodeGenCXX/atomic-align.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/atomic-align.cpp?rev=312805=312804=312805=diff
==
--- cfe/trunk/test/CodeGenCXX/atomic-align.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/atomic-align.cpp Fri Sep  8 11:10:13 2017
@@ -1,30 +0,0 @@
-// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - -triple=x86_64-linux-gnu | 
FileCheck %s
-
-struct AM {
-  int f1, f2;
-};
-alignas(8) AM m;
-AM load1() {
-  AM am;
-  // m is declared to align to 8bytes, so generate load atomic instead
-  // of libcall.
-  // CHECK-LABEL: @_Z5load1v
-  // CHECK: load atomic {{.*}} monotonic
-  __atomic_load(, , 0);
-  return am;
-}
-
-struct BM {
-  int f1;
-  alignas(8) AM f2;
-};
-BM bm;
-AM load2() {
-  AM am;
-  // BM::f2 is declared to align to 8bytes, so generate load atomic instead
-  // of libcall.
-  // CHECK-LABEL: @_Z5load2v
-  // CHECK: load atomic {{.*}} monotonic
-  __atomic_load(, , 0);
-  return am;
-}


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


[PATCH] D37629: [Sema] Move some stuff into -Wtautological-unsigned-enum-zero-compare

2017-09-08 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 114396.
lebedev.ri added a comment.

And finish reducing the code by for-range-loop`ing over array + use 
`std::array`.


Repository:
  rL LLVM

https://reviews.llvm.org/D37629

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/compare.c
  test/Sema/tautological-unsigned-enum-zero-compare.c

Index: test/Sema/tautological-unsigned-enum-zero-compare.c
===
--- /dev/null
+++ test/Sema/tautological-unsigned-enum-zero-compare.c
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-enum-zero-compare -verify %s
+
+int main() {
+  enum A { A_foo, A_bar };
+  enum A a;
+
+#ifdef TEST
+  if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
+return 0;
+  if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}}
+return 0;
+  if (0 <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}}
+return 0;
+  if (0 > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}}
+return 0;
+  if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
+return 0;
+  if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}}
+return 0;
+  if (0U <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}}
+return 0;
+  if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}}
+return 0;
+#else
+  // expected-no-diagnostics
+  if (a < 0)
+return 0;
+  if (a >= 0)
+return 0;
+  if (0 <= a)
+return 0;
+  if (0 > a)
+return 0;
+  if (a < 0U)
+return 0;
+  if (a >= 0U)
+return 0;
+  if (0U <= a)
+return 0;
+  if (0U > a)
+return 0;
+#endif
+
+  return 1;
+}
Index: test/Sema/compare.c
===
--- test/Sema/compare.c
+++ test/Sema/compare.c
@@ -308,8 +308,59 @@
 int rdar8511238() {
   enum A { A_foo, A_bar };
   enum A a;
+
+  if (a == 0)
+  return 0;
+  if (a != 0)
+  return 0;
   if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
-return 0;
+  return 0;
+  if (a <= 0)
+  return 0;
+  if (a > 0)
+  return 0;
+  if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}}
+  return 0;
+
+  if (0 == a)
+  return 0;
+  if (0 != a)
+  return 0;
+  if (0 < a)
+  return 0;
+  if (0 <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}}
+  return 0;
+  if (0 > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}}
+  return 0;
+  if (0 >= a)
+  return 0;
+
+  if (a == 0U)
+  return 0;
+  if (a != 0U)
+  return 0;
+  if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
+  return 0;
+  if (a <= 0U)
+  return 0;
+  if (a > 0U)
+  return 0;
+  if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}}
+  return 0;
+
+  if (0U == a)
+  return 0;
+  if (0U != a)
+  return 0;
+  if (0U < a)
+  return 0;
+  if (0U <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}}
+  return 0;
+  if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}}
+  return 0;
+  if (0U >= a)
+  return 0;
+
   return 20;
 }
 
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -8583,35 +8583,69 @@
 
   // bool values are handled by DiagnoseOutOfRangeComparison().
 
-  BinaryOperatorKind op = E->getOpcode();
   if (E->isValueDependent())
 return false;
 
   Expr *LHS = E->getLHS();
   Expr *RHS = E->getRHS();
 
-  bool Match = true;
+  enum IsEnum { False = false, True = true, SizeOfIsEnum };
+  struct TautologicalComparison {
+Expr *
+BinaryOperatorKind op;
+Expr *
+std::array DiagID;
+const char *cmp;
+bool Result;
+  };
 
-  if (op == BO_LT && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) {
-S.Diag(E->getOperatorLoc(), diag::warn_lunsigned_always_true_comparison)
-  << "< 0" << "false" << HasEnumType(LHS)
-  << LHS->getSourceRange() << RHS->getSourceRange();
-  } else if (op == BO_GE && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) {
-S.Diag(E->getOperatorLoc(), diag::warn_lunsigned_always_true_comparison)
-  << ">= 0" << "true" << HasEnumType(LHS)
-  << LHS->getSourceRange() << RHS->getSourceRange();
-  } else if (op == BO_GT && 

[PATCH] D37604: Disable debuginfo-tests for non-native configurations

2017-09-08 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In https://reviews.llvm.org/D37604#864187, @aprantl wrote:

> This seems reasonable to me, thanks!
>  When you commit this, could you please double-check that the tests are still 
> running on the green dragon builders? I'll also keep an eye on them.


I was able to google "llvm green dragon" and find what looks like the right 
page, but I kind of would have expected to see a link on the llvm.org front 
page?  Am I just not looking in the right place?


https://reviews.llvm.org/D37604



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


[PATCH] D37572: [clang-tidy] SuspiciousEnumUsageCheck bugfix

2017-09-08 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: test/clang-tidy/misc-suspicious-enum-usage.cpp:122
+struct a> {
+  enum { ah = ad::m,
+ ai = ae::m,

alexfh wrote:
> aaron.ballman wrote:
> > alexfh wrote:
> > > aaron.ballman wrote:
> > > > This seems like a lot of complicated code for the test case -- can this 
> > > > be reduced further?
> > > This is the best creduce could do. It should be possible to make this 
> > > much shorter, but I wouldn't spend too much time on that.
> > I'd appreciate the time spent because this is an almost-unintelligible test 
> > for anyone reading it -- it's hard to understand what's going on there.
> namespace PR34400 {
>   enum { E1 = 0 };
>   enum { E2 = -1 };
> 
>   enum { l = E1 | E2 };
> }
> 
This might not cover both code paths affected by the bug. But it should be easy 
to construct a case for the second one.


https://reviews.llvm.org/D37572



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


[PATCH] D37629: [Sema] Move some stuff into -Wtautological-unsigned-enum-zero-compare

2017-09-08 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

I'm not sure it's better than writing the if/elseif/elseif/elseif out 
explicitly :/


Repository:
  rL LLVM

https://reviews.llvm.org/D37629



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


[PATCH] D37572: [clang-tidy] SuspiciousEnumUsageCheck bugfix

2017-09-08 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: test/clang-tidy/misc-suspicious-enum-usage.cpp:122
+struct a> {
+  enum { ah = ad::m,
+ ai = ae::m,

aaron.ballman wrote:
> alexfh wrote:
> > aaron.ballman wrote:
> > > This seems like a lot of complicated code for the test case -- can this 
> > > be reduced further?
> > This is the best creduce could do. It should be possible to make this much 
> > shorter, but I wouldn't spend too much time on that.
> I'd appreciate the time spent because this is an almost-unintelligible test 
> for anyone reading it -- it's hard to understand what's going on there.
namespace PR34400 {
  enum { E1 = 0 };
  enum { E2 = -1 };

  enum { l = E1 | E2 };
}



https://reviews.llvm.org/D37572



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


[PATCH] D37474: [PCH] Allow VFS to be used for tests that generate PCH files

2017-09-08 Thread Cameron via Phabricator via cfe-commits
cameron314 added inline comments.



Comment at: lib/Frontend/ASTUnit.cpp:1014
+/// with another virtual file system.
+class PCHOverlayFileSystem : public vfs::FileSystem
+{

ilya-biryukov wrote:
> Maybe create a combination of `InMemoryFileSystem` and `OverlayFileSystem` 
> instead of custom filtering implementation?
> We really need to read only a single file given that `ASTUnit` never creates 
> directory PCHs.
> I bet it would make the code simpler and less error-prone.
I hadn't thought of that. Yes, that makes sense and is more concise.



Comment at: lib/Frontend/ASTUnit.cpp:1090
+  IntrusiveRefCntPtr RealFS = vfs::getRealFileSystem();
+  if (OverrideMainBuffer && VFS && RealFS && VFS != RealFS) {
+// We have a slight inconsistency here -- we're using the VFS to

ilya-biryukov wrote:
> Maybe create a PCH overlay only when `!VFS->exists(/*PreamblePath...*/)`?
> This seems like a good enough indication that `RealFS` is underneath the 
> `vfs::FileSystem` instance, even if pointer equality does not hold (i.e. in 
> case of overlays over `RealFS`).
Makes sense.



Comment at: unittests/Frontend/CMakeLists.txt:9
   CodeGenActionTest.cpp
+  PchPreambleTest.cpp
   )

ilya-biryukov wrote:
> Maybe rename to `PCHPreambleTest`?
> LLVM code generally capitalizes all letters in abbreviations.
Oops, overlooked this one. Will do!


https://reviews.llvm.org/D37474



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


[PATCH] D37624: add support for -fno-instrument-functions and -finstrument-functions-exclude-{file, function}-list=<arg1, arg2, ...> to match gcc options.

2017-09-08 Thread kchoi via Phabricator via cfe-commits
choikwa updated this revision to Diff 114388.
choikwa added a comment.

renamed and moved Cache to SourceLocToFileNameMap in CodeGenModule


https://reviews.llvm.org/D37624

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/instrument-functions.c

Index: test/CodeGen/instrument-functions.c
===
--- test/CodeGen/instrument-functions.c
+++ test/CodeGen/instrument-functions.c
@@ -1,18 +1,66 @@
-// RUN: %clang_cc1 -S -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-functions | FileCheck %s
+// RUN: %clang -S -emit-llvm -o - %s -finstrument-functions | FileCheck %s
+// RUN: %clang -S -emit-llvm -o - %s -fno-instrument-functions | FileCheck %s --check-prefix=NOINSTR
+
+// RUN: %clang -S -emit-llvm -o - %s -finstrument-functions -finstrument-functions-exclude-file-list=instrument | FileCheck %s --check-prefix=NOFILE
+// RUN: %clang -S -emit-llvm -o - %s -finstrument-functions -finstrument-functions-exclude-function-list=test3 | FileCheck %s --check-prefix=NOFUNC
 
 // CHECK: @test1
+// NOINSTR: @test1
+// NOFILE: @test1
+// NOFUNC: @test1
 int test1(int x) {
-// CHECK: call void @__cyg_profile_func_enter({{.*}}, !dbg
-// CHECK: call void @__cyg_profile_func_exit({{.*}}, !dbg
+// CHECK: __cyg_profile_func_enter
+// CHECK: __cyg_profile_func_exit
 // CHECK: ret
+// NOINSTR-NOT: __cyg_profile_func_enter
+// NOINSTR-NOT: __cyg_profile_func_exit
+// NOINSTR: ret
+// NOFILE-NOT: __cyg_profile_func_enter
+// NOFILE-NOT: __cyg_profile_func_exit
+// NOFILE: ret
+// NOFUNC: __cyg_profile_func_enter
+// NOFUNC: __cyg_profile_func_exit
+// NOFUNC: ret
   return x;
 }
 
 // CHECK: @test2
+// NOINSTR: @test2
+// NOFILE: @test2
+// NOFUNC: @test2
 int test2(int) __attribute__((no_instrument_function));
 int test2(int x) {
 // CHECK-NOT: __cyg_profile_func_enter
 // CHECK-NOT: __cyg_profile_func_exit
 // CHECK: ret
+// NOINSTR-NOT: __cyg_profile_func_enter
+// NOINSTR-NOT: __cyg_profile_func_exit
+// NOINSTR: ret
+// NOFILE-NOT: __cyg_profile_func_enter
+// NOFILE-NOT: __cyg_profile_func_exit
+// NOFILE: ret
+// NOFUNC-NOT: __cyg_profile_func_enter
+// NOFUNC-NOT: __cyg_profile_func_exit
+// NOFUNC: ret
+  return x;
+}
+
+// CHECK: @test3
+// NOINSTR: @test3
+// NOFILE: @test3
+// NOFUNC: @test3
+int test3(int x) {
+// CHECK: __cyg_profile_func_enter
+// CHECK: __cyg_profile_func_exit
+// CHECK: ret
+// NOINSTR-NOT: __cyg_profile_func_enter
+// NOINSTR-NOT: __cyg_profile_func_exit
+// NOINSTR: ret
+// NOFILE-NOT: __cyg_profile_func_enter
+// NOFILE-NOT: __cyg_profile_func_exit
+// NOFILE: ret
+// NOFUNC-NOT: __cyg_profile_func_enter
+// NOFUNC-NOT: __cyg_profile_func_exit
+// NOFUNC: ret
   return x;
 }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -771,6 +771,12 @@
 
   Opts.PreserveVec3Type = Args.hasArg(OPT_fpreserve_vec3_type);
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
+  if (Opts.InstrumentFunctions) {
+Opts.InstrumentFunctionExclusionsFunctions
+= Args.getAllArgValues(OPT_finstrument_functions_exclude_function_list);
+Opts.InstrumentFunctionExclusionsPathSegments
+= Args.getAllArgValues(OPT_finstrument_functions_exclude_file_list);
+  }
   Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
   Opts.XRayInstructionThreshold =
   getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3519,7 +3519,14 @@
 options::OPT_fno_unique_section_names, true))
 CmdArgs.push_back("-fno-unique-section-names");
 
-  Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
+  if (Args.hasArg(options::OPT_finstrument_functions,
+  options::OPT_fno_instrument_functions, false)) {
+Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
+Args.AddAllArgs(CmdArgs,
+options::OPT_finstrument_functions_exclude_file_list);
+Args.AddAllArgs(CmdArgs,
+options::OPT_finstrument_functions_exclude_function_list);
+  }
 
   addPGOAndCoverageFlags(C, D, Output, Args, CmdArgs);
 
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -499,6 +499,9 @@
   /// MDNodes.
   llvm::DenseMap MetadataIdMap;
 
+  /// Mapping from SourceLocation to PresumedLoc 

[PATCH] D37196: [Clang] Bug 32352 - Provide a way for OptimizationRemarkEmitter::allowExtraAnalysis to check if (specific) remarks are enabled

2017-09-08 Thread Adam Nemet via Phabricator via cfe-commits
anemet added a comment.

Please clean this up as well (don't have commented-out lines) so that it's 
ready to go with the LLVM patch.




Comment at: lib/CodeGen/CodeGenAction.cpp:302-305
 static void DiagnosticHandler(const llvm::DiagnosticInfo ,
   void *Context) {
   ((BackendConsumer *)Context)->DiagnosticHandlerImpl(DI);
 }

Remove this.



Comment at: lib/CodeGen/CodeGenAction.cpp:761
+public:
+  ClangDiagnosticHandler(const CodeGenOptions , void *DiagContext)
+  : DiagnosticHandler(DiagContext), CodeGenOpts(CGOpts) {}

Again don't overload DiagContext as such.  Have a dedicated field for the 
BackendConsumer.



Comment at: lib/CodeGen/CodeGenAction.cpp:882-883
   BEConsumer = Result.get();
-
+  VMContext->setDiagnosticHandler(llvm::make_unique(
+  CI.getCodeGenOpts(), Result.get()));
   // Enable generating macro debug info only when debug info is not disabled 
and

Any reason you moved where we set this up?


https://reviews.llvm.org/D37196



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


[PATCH] D37629: [Sema] Move some stuff into -Wtautological-unsigned-enum-zero-compare

2017-09-08 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 114387.
lebedev.ri added a subscriber: jroelofs.
lebedev.ri added a comment.

Rework as per @jroelofs's suggestion to have just one `switch`/`if` cascade 
that operates on `BinaryOperatorKind`


Repository:
  rL LLVM

https://reviews.llvm.org/D37629

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/compare.c
  test/Sema/tautological-unsigned-enum-zero-compare.c

Index: test/Sema/tautological-unsigned-enum-zero-compare.c
===
--- /dev/null
+++ test/Sema/tautological-unsigned-enum-zero-compare.c
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-enum-zero-compare -verify %s
+
+int main() {
+  enum A { A_foo, A_bar };
+  enum A a;
+
+#ifdef TEST
+  if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
+return 0;
+  if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}}
+return 0;
+  if (0 <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}}
+return 0;
+  if (0 > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}}
+return 0;
+  if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
+return 0;
+  if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}}
+return 0;
+  if (0U <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}}
+return 0;
+  if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}}
+return 0;
+#else
+  // expected-no-diagnostics
+  if (a < 0)
+return 0;
+  if (a >= 0)
+return 0;
+  if (0 <= a)
+return 0;
+  if (0 > a)
+return 0;
+  if (a < 0U)
+return 0;
+  if (a >= 0U)
+return 0;
+  if (0U <= a)
+return 0;
+  if (0U > a)
+return 0;
+#endif
+
+  return 1;
+}
Index: test/Sema/compare.c
===
--- test/Sema/compare.c
+++ test/Sema/compare.c
@@ -308,8 +308,59 @@
 int rdar8511238() {
   enum A { A_foo, A_bar };
   enum A a;
+
+  if (a == 0)
+  return 0;
+  if (a != 0)
+  return 0;
   if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
-return 0;
+  return 0;
+  if (a <= 0)
+  return 0;
+  if (a > 0)
+  return 0;
+  if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}}
+  return 0;
+
+  if (0 == a)
+  return 0;
+  if (0 != a)
+  return 0;
+  if (0 < a)
+  return 0;
+  if (0 <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}}
+  return 0;
+  if (0 > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}}
+  return 0;
+  if (0 >= a)
+  return 0;
+
+  if (a == 0U)
+  return 0;
+  if (a != 0U)
+  return 0;
+  if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
+  return 0;
+  if (a <= 0U)
+  return 0;
+  if (a > 0U)
+  return 0;
+  if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}}
+  return 0;
+
+  if (0U == a)
+  return 0;
+  if (0U != a)
+  return 0;
+  if (0U < a)
+  return 0;
+  if (0U <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}}
+  return 0;
+  if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}}
+  return 0;
+  if (0U >= a)
+  return 0;
+
   return 20;
 }
 
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -8590,28 +8590,73 @@
   Expr *LHS = E->getLHS();
   Expr *RHS = E->getRHS();
 
-  bool Match = true;
+  enum IsEnum { False, True, SizeOfIsEnum };
+  struct TautologicalComparison {
+unsigned DiagID[SizeOfIsEnum];
+Expr *
+Expr *
+const char *cmp;
+bool Result;
+  };
 
-  if (op == BO_LT && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) {
-S.Diag(E->getOperatorLoc(), diag::warn_lunsigned_always_true_comparison)
-  << "< 0" << "false" << HasEnumType(LHS)
-  << LHS->getSourceRange() << RHS->getSourceRange();
-  } else if (op == BO_GE && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) {
-S.Diag(E->getOperatorLoc(), diag::warn_lunsigned_always_true_comparison)
-  << ">= 0" << "true" << HasEnumType(LHS)
-  << LHS->getSourceRange() << RHS->getSourceRange();
-  } else if (op == BO_GT && isNonBooleanUnsignedValue(RHS) && IsZero(S, LHS)) {
-S.Diag(E->getOperatorLoc(), diag::warn_runsigned_always_true_comparison)
-  << "0 >" << "false" << 

[PATCH] D37604: Disable debuginfo-tests for non-native configurations

2017-09-08 Thread Paul Robinson via Phabricator via cfe-commits
probinson closed this revision.
probinson added a comment.

r312803.  Forgot to put the tag in the commit message


https://reviews.llvm.org/D37604



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


[PATCH] D37310: [Atomic] Merge alignment information from Decl and from Type when emit atomic expression.

2017-09-08 Thread Wei Mi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL312801: Use EmitPointerWithAlignment to get alignment 
information of the pointer used… (authored by wmi).

Changed prior to commit:
  https://reviews.llvm.org/D37310?vs=114300=114384#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37310

Files:
  cfe/trunk/lib/CodeGen/CGAtomic.cpp
  cfe/trunk/test/CodeGenCXX/atomic-align.cpp


Index: cfe/trunk/lib/CodeGen/CGAtomic.cpp
===
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp
@@ -745,19 +745,19 @@
   QualType MemTy = AtomicTy;
   if (const AtomicType *AT = AtomicTy->getAs())
 MemTy = AT->getValueType();
-  CharUnits sizeChars, alignChars;
-  std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy);
-  uint64_t Size = sizeChars.getQuantity();
-  unsigned MaxInlineWidthInBits = getTarget().getMaxAtomicInlineWidth();
-  bool UseLibcall = (sizeChars != alignChars ||
- getContext().toBits(sizeChars) > MaxInlineWidthInBits);
-
   llvm::Value *IsWeak = nullptr, *OrderFail = nullptr;
 
   Address Val1 = Address::invalid();
   Address Val2 = Address::invalid();
   Address Dest = Address::invalid();
-  Address Ptr(EmitScalarExpr(E->getPtr()), alignChars);
+  Address Ptr = EmitPointerWithAlignment(E->getPtr());
+
+  CharUnits sizeChars, alignChars;
+  std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy);
+  uint64_t Size = sizeChars.getQuantity();
+  unsigned MaxInlineWidthInBits = getTarget().getMaxAtomicInlineWidth();
+  bool UseLibcall = (sizeChars != Ptr.getAlignment() ||
+ getContext().toBits(sizeChars) > MaxInlineWidthInBits);
 
   if (E->getOp() == AtomicExpr::AO__c11_atomic_init ||
   E->getOp() == AtomicExpr::AO__opencl_atomic_init) {
Index: cfe/trunk/test/CodeGenCXX/atomic-align.cpp
===
--- cfe/trunk/test/CodeGenCXX/atomic-align.cpp
+++ cfe/trunk/test/CodeGenCXX/atomic-align.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - -triple=x86_64-linux-gnu | 
FileCheck %s
+
+struct AM {
+  int f1, f2;
+};
+alignas(8) AM m;
+AM load1() {
+  AM am;
+  // m is declared to align to 8bytes, so generate load atomic instead
+  // of libcall.
+  // CHECK-LABEL: @_Z5load1v
+  // CHECK: load atomic {{.*}} monotonic
+  __atomic_load(, , 0);
+  return am;
+}
+
+struct BM {
+  int f1;
+  alignas(8) AM f2;
+};
+BM bm;
+AM load2() {
+  AM am;
+  // BM::f2 is declared to align to 8bytes, so generate load atomic instead
+  // of libcall.
+  // CHECK-LABEL: @_Z5load2v
+  // CHECK: load atomic {{.*}} monotonic
+  __atomic_load(, , 0);
+  return am;
+}


Index: cfe/trunk/lib/CodeGen/CGAtomic.cpp
===
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp
@@ -745,19 +745,19 @@
   QualType MemTy = AtomicTy;
   if (const AtomicType *AT = AtomicTy->getAs())
 MemTy = AT->getValueType();
-  CharUnits sizeChars, alignChars;
-  std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy);
-  uint64_t Size = sizeChars.getQuantity();
-  unsigned MaxInlineWidthInBits = getTarget().getMaxAtomicInlineWidth();
-  bool UseLibcall = (sizeChars != alignChars ||
- getContext().toBits(sizeChars) > MaxInlineWidthInBits);
-
   llvm::Value *IsWeak = nullptr, *OrderFail = nullptr;
 
   Address Val1 = Address::invalid();
   Address Val2 = Address::invalid();
   Address Dest = Address::invalid();
-  Address Ptr(EmitScalarExpr(E->getPtr()), alignChars);
+  Address Ptr = EmitPointerWithAlignment(E->getPtr());
+
+  CharUnits sizeChars, alignChars;
+  std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy);
+  uint64_t Size = sizeChars.getQuantity();
+  unsigned MaxInlineWidthInBits = getTarget().getMaxAtomicInlineWidth();
+  bool UseLibcall = (sizeChars != Ptr.getAlignment() ||
+ getContext().toBits(sizeChars) > MaxInlineWidthInBits);
 
   if (E->getOp() == AtomicExpr::AO__c11_atomic_init ||
   E->getOp() == AtomicExpr::AO__opencl_atomic_init) {
Index: cfe/trunk/test/CodeGenCXX/atomic-align.cpp
===
--- cfe/trunk/test/CodeGenCXX/atomic-align.cpp
+++ cfe/trunk/test/CodeGenCXX/atomic-align.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - -triple=x86_64-linux-gnu | FileCheck %s
+
+struct AM {
+  int f1, f2;
+};
+alignas(8) AM m;
+AM load1() {
+  AM am;
+  // m is declared to align to 8bytes, so generate load atomic instead
+  // of libcall.
+  // CHECK-LABEL: @_Z5load1v
+  // CHECK: load atomic {{.*}} monotonic
+  __atomic_load(, , 0);
+  return am;
+}
+
+struct BM {
+  int f1;
+  alignas(8) AM f2;
+};
+BM bm;
+AM load2() {
+  AM am;
+  // BM::f2 is declared to align to 8bytes, so generate load atomic instead

r312801 - Use EmitPointerWithAlignment to get alignment information of the pointer used in atomic expr.

2017-09-08 Thread Wei Mi via cfe-commits
Author: wmi
Date: Fri Sep  8 10:07:32 2017
New Revision: 312801

URL: http://llvm.org/viewvc/llvm-project?rev=312801=rev
Log:
Use EmitPointerWithAlignment to get alignment information of the pointer used 
in atomic expr.

This is to fix PR34347. EmitAtomicExpr now only uses alignment information from
Type, instead of Decl, so when the declaration of an atomic variable is marked
to have the alignment equal as its size, EmitAtomicExpr doesn't know about it 
and
will generate libcall instead of atomic op. The patch uses 
EmitPointerWithAlignment
to get the precise alignment information.

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

Added:
cfe/trunk/test/CodeGenCXX/atomic-align.cpp
Modified:
cfe/trunk/lib/CodeGen/CGAtomic.cpp

Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=312801=312800=312801=diff
==
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Fri Sep  8 10:07:32 2017
@@ -745,19 +745,19 @@ RValue CodeGenFunction::EmitAtomicExpr(A
   QualType MemTy = AtomicTy;
   if (const AtomicType *AT = AtomicTy->getAs())
 MemTy = AT->getValueType();
-  CharUnits sizeChars, alignChars;
-  std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy);
-  uint64_t Size = sizeChars.getQuantity();
-  unsigned MaxInlineWidthInBits = getTarget().getMaxAtomicInlineWidth();
-  bool UseLibcall = (sizeChars != alignChars ||
- getContext().toBits(sizeChars) > MaxInlineWidthInBits);
-
   llvm::Value *IsWeak = nullptr, *OrderFail = nullptr;
 
   Address Val1 = Address::invalid();
   Address Val2 = Address::invalid();
   Address Dest = Address::invalid();
-  Address Ptr(EmitScalarExpr(E->getPtr()), alignChars);
+  Address Ptr = EmitPointerWithAlignment(E->getPtr());
+
+  CharUnits sizeChars, alignChars;
+  std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy);
+  uint64_t Size = sizeChars.getQuantity();
+  unsigned MaxInlineWidthInBits = getTarget().getMaxAtomicInlineWidth();
+  bool UseLibcall = (sizeChars != Ptr.getAlignment() ||
+ getContext().toBits(sizeChars) > MaxInlineWidthInBits);
 
   if (E->getOp() == AtomicExpr::AO__c11_atomic_init ||
   E->getOp() == AtomicExpr::AO__opencl_atomic_init) {

Added: cfe/trunk/test/CodeGenCXX/atomic-align.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/atomic-align.cpp?rev=312801=auto
==
--- cfe/trunk/test/CodeGenCXX/atomic-align.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/atomic-align.cpp Fri Sep  8 10:07:32 2017
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - -triple=x86_64-linux-gnu | 
FileCheck %s
+
+struct AM {
+  int f1, f2;
+};
+alignas(8) AM m;
+AM load1() {
+  AM am;
+  // m is declared to align to 8bytes, so generate load atomic instead
+  // of libcall.
+  // CHECK-LABEL: @_Z5load1v
+  // CHECK: load atomic {{.*}} monotonic
+  __atomic_load(, , 0);
+  return am;
+}
+
+struct BM {
+  int f1;
+  alignas(8) AM f2;
+};
+BM bm;
+AM load2() {
+  AM am;
+  // BM::f2 is declared to align to 8bytes, so generate load atomic instead
+  // of libcall.
+  // CHECK-LABEL: @_Z5load2v
+  // CHECK: load atomic {{.*}} monotonic
+  __atomic_load(, , 0);
+  return am;
+}


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


[PATCH] D33514: [WIP] Bug 32352 - Provide a way for OptimizationRemarkEmitter::allowExtraAnalysis to check if (specific) remarks are enabled

2017-09-08 Thread Adam Nemet via Phabricator via cfe-commits
anemet added a comment.

Only minor things at this point.  This is very close now.




Comment at: include/llvm/Analysis/OptimizationDiagnosticInfo.h:81
   /// detected by the user.
-  bool allowExtraAnalysis() const {
-// For now, only allow this with -fsave-optimization-record since the 
-Rpass
-// options are handled in the front-end.
-return F->getContext().getDiagnosticsOutputFile();
+  bool allowExtraAnalysis(StringRef &) const {
+return (F->getContext().getDiagnosticsOutputFile() ||

Why rvalue reference, you should just take this by value.  There is no 
ownership transfer here.



Comment at: include/llvm/Analysis/OptimizationDiagnosticInfo.h:84
+F->getContext().getDiagHandler()->isAnyRemarkEnabled(
+std::move(PassName)));
   }

No std::move here.  You have more of this later.



Comment at: include/llvm/IR/DiagnosticHandler.h:13
+
+#include "llvm/Support/Regex.h"
+

I don't think you need this.



Comment at: include/llvm/IR/DiagnosticHandler.h:18
+
+struct DiagnosticHandler {
+public:

Please add a comment before the class.



Comment at: include/llvm/IR/DiagnosticHandler.h:19
+struct DiagnosticHandler {
+public:
+  void *DiagnosticContext = nullptr;

No need for public for struct.



Comment at: include/llvm/IR/DiagnosticHandler.h:27
+
+  /// DiagHandlerCallback is settable from the C API and base implimentation
+  /// of DiagnosticHandler will call it from handleDiagnostics(). Any derived

implementation 



Comment at: include/llvm/IR/DiagnosticHandler.h:45
+
+  /// checks if remark requested with -pass-remarks-analysis, override
+  /// to provide different implementation

Capitalize first word and end with period; comments are full sentences. 



Comment at: include/llvm/IR/DiagnosticHandler.h:57
+
+  /// checks if remark requested with -pass-remarks{-missed/-analysis}
+  bool isAnyRemarkEnabled(StringRef &) const {

I would drop the flag names here since if those are overridden this is not 
true.  Just say "Return true if any remark type is enabled."



Comment at: lib/IR/DiagnosticInfo.cpp:47-65
 /// \brief Regular expression corresponding to the value given in one of the
 /// -pass-remarks* command line flags. Passes whose name matches this regexp
 /// will emit a diagnostic via ORE->emit(...);
 struct PassRemarksOpt {
   std::shared_ptr Pattern;
 
   void operator=(const std::string ) {

Is this still used here?



Comment at: lib/LTO/LTOCodeGenerator.cpp:667-668
-return Context.setDiagnosticHandler(nullptr, nullptr);
-  // Register the LTOCodeGenerator stub in the LLVMContext to forward the
-  // diagnostic to the external DiagHandler.
-  Context.setDiagnosticHandler(LTOCodeGenerator::DiagnosticHandler, this,

I think that this comment still applies.



Comment at: tools/llvm-lto/llvm-lto.cpp:39-72
+static std::string CurrentActivity;
+namespace {
+struct LLVMLTODiagnosticHandler : public DiagnosticHandler {
+  bool handleDiagnostics(const DiagnosticInfo ) override {
+raw_ostream  = errs();
+OS << "llvm-lto: ";
+switch (DI.getSeverity()) {

Don't move this code unless you have to.  The diff is easier to read that way.


https://reviews.llvm.org/D33514



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-09-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Sema/SemaType.cpp:6994
+  // OpenCL v1.2 s6.5:
+  // The generic address space name for arguments to a function in a
+  // program, or local variables of a function is __private. All function

yaxunl wrote:
> Anastasia wrote:
> > yaxunl wrote:
> > > Anastasia wrote:
> > > > The generic address space -> The default address space
> > > 'The generic address space name for arguments' is literally from the 
> > > OpenCL 1.2 spec. Note it refers 'generic address space name', which is 
> > > not the 'generic address space' defined by OpenCL 2.0 spec.
> > True, but this spec was written before v2.0 was released. And I feel now it 
> > makes things confusing considering that we have v2.0 implementation too.
> I can make the change. I just feel a little bit uneasy since this looks like 
> a citation but actually is rephrased.
Cool! Thanks!


https://reviews.llvm.org/D35082



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


[PATCH] D37599: Add '\n' in ClangDataCollectorsEmitter

2017-09-08 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

In https://reviews.llvm.org/D37599#864376, @arphaman wrote:

> LGTM. Do you have commit access?


Yep, committed. Thanks.


Repository:
  rL LLVM

https://reviews.llvm.org/D37599



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


r312798 - Add _Float16 as a C/C++ source language type

2017-09-08 Thread Sjoerd Meijer via cfe-commits
Author: sjoerdmeijer
Date: Fri Sep  8 09:43:10 2017
New Revision: 312798

URL: http://llvm.org/viewvc/llvm-project?rev=312798=rev
Log:
Add _Float16 as a C/C++ source language type

Pacify the windows builder; fixed the new test as on Windows some additional
attributes are printed.


Modified:
cfe/trunk/test/Frontend/float16.cpp

Modified: cfe/trunk/test/Frontend/float16.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/float16.cpp?rev=312798=312797=312798=diff
==
--- cfe/trunk/test/Frontend/float16.cpp (original)
+++ cfe/trunk/test/Frontend/float16.cpp Fri Sep  8 09:43:10 2017
@@ -116,7 +116,7 @@ public:
 //CHECK-NEXT: | |-VarDecl {{.*}} used f2c 'const _Float16' static
 //CHECK-NEXT: | |-FieldDecl {{.*}} f3c 'volatile _Float16'
 //CHECK-NEXT: | |-AccessSpecDecl
-//CHECK-NEXT: | |-CXXConstructorDecl {{.*}} used C1 'void (_Float16)'
+//CHECK-NEXT: | |-CXXConstructorDecl {{.*}} used C1 'void (_Float16)
 //CHECK-NEXT: | | |-ParmVarDecl {{.*}} used arg '_Float16'
 //CHECK-NEXT: | | |-CXXCtorInitializer Field {{.*}} 'f1c' '_Float16'
 //CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '_Float16' 
@@ -125,7 +125,7 @@ public:
 //CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '_Float16' 
 //CHECK-NEXT: | | |   `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 
'arg' '_Float16'
 //CHECK-NEXT: | | `-CompoundStmt
-//CHECK-NEXT: | |-CXXMethodDecl {{.*}} used func1c '_Float16 (_Float16)'
+//CHECK-NEXT: | |-CXXMethodDecl {{.*}} used func1c '_Float16 (_Float16)
 //CHECK-NEXT: | | |-ParmVarDecl {{.*}} used arg '_Float16'
 //CHECK-NEXT: | | `-CompoundStmt
 //CHECK-NEXT: | |   `-ReturnStmt
@@ -209,7 +209,7 @@ int main(void) {
 
   C1 c1(f1l);
 //CHECK:   | `-VarDecl{{.*}} used c1 'class C1' callinit
-//CHECK-NEXT:  |   `-CXXConstructExpr {{.*}} 'class C1' 'void (_Float16)'
+//CHECK-NEXT:  |   `-CXXConstructExpr {{.*}} 'class C1' 'void (_Float16)
 //CHECK-NEXT:  | `-ImplicitCastExpr {{.*}} '_Float16' 
 //CHECK-NEXT:  |   `-DeclRefExpr {{.*}} '_Float16' lvalue Var 0x{{.*}} 
'f1l' '_Float16'
 


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


[PATCH] D37624: add support for -fno-instrument-functions and -finstrument-functions-exclude-{file, function}-list=<arg1, arg2, ...> to match gcc options.

2017-09-08 Thread kchoi via Phabricator via cfe-commits
choikwa added a comment.

Forgot to hang Cache to CodeGenModule, will do that shortly


https://reviews.llvm.org/D37624



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


[PATCH] D37624: add support for -fno-instrument-functions and -finstrument-functions-exclude-{file, function}-list=<arg1, arg2, ...> to match gcc options.

2017-09-08 Thread kchoi via Phabricator via cfe-commits
choikwa updated this revision to Diff 114380.
choikwa added a comment.

addressed code review. made doc consistent with functionality.


https://reviews.llvm.org/D37624

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/instrument-functions.c

Index: test/CodeGen/instrument-functions.c
===
--- test/CodeGen/instrument-functions.c
+++ test/CodeGen/instrument-functions.c
@@ -1,18 +1,66 @@
-// RUN: %clang_cc1 -S -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-functions | FileCheck %s
+// RUN: %clang -S -emit-llvm -o - %s -finstrument-functions | FileCheck %s
+// RUN: %clang -S -emit-llvm -o - %s -fno-instrument-functions | FileCheck %s --check-prefix=NOINSTR
+
+// RUN: %clang -S -emit-llvm -o - %s -finstrument-functions -finstrument-functions-exclude-file-list=instrument | FileCheck %s --check-prefix=NOFILE
+// RUN: %clang -S -emit-llvm -o - %s -finstrument-functions -finstrument-functions-exclude-function-list=test3 | FileCheck %s --check-prefix=NOFUNC
 
 // CHECK: @test1
+// NOINSTR: @test1
+// NOFILE: @test1
+// NOFUNC: @test1
 int test1(int x) {
-// CHECK: call void @__cyg_profile_func_enter({{.*}}, !dbg
-// CHECK: call void @__cyg_profile_func_exit({{.*}}, !dbg
+// CHECK: __cyg_profile_func_enter
+// CHECK: __cyg_profile_func_exit
 // CHECK: ret
+// NOINSTR-NOT: __cyg_profile_func_enter
+// NOINSTR-NOT: __cyg_profile_func_exit
+// NOINSTR: ret
+// NOFILE-NOT: __cyg_profile_func_enter
+// NOFILE-NOT: __cyg_profile_func_exit
+// NOFILE: ret
+// NOFUNC: __cyg_profile_func_enter
+// NOFUNC: __cyg_profile_func_exit
+// NOFUNC: ret
   return x;
 }
 
 // CHECK: @test2
+// NOINSTR: @test2
+// NOFILE: @test2
+// NOFUNC: @test2
 int test2(int) __attribute__((no_instrument_function));
 int test2(int x) {
 // CHECK-NOT: __cyg_profile_func_enter
 // CHECK-NOT: __cyg_profile_func_exit
 // CHECK: ret
+// NOINSTR-NOT: __cyg_profile_func_enter
+// NOINSTR-NOT: __cyg_profile_func_exit
+// NOINSTR: ret
+// NOFILE-NOT: __cyg_profile_func_enter
+// NOFILE-NOT: __cyg_profile_func_exit
+// NOFILE: ret
+// NOFUNC-NOT: __cyg_profile_func_enter
+// NOFUNC-NOT: __cyg_profile_func_exit
+// NOFUNC: ret
+  return x;
+}
+
+// CHECK: @test3
+// NOINSTR: @test3
+// NOFILE: @test3
+// NOFUNC: @test3
+int test3(int x) {
+// CHECK: __cyg_profile_func_enter
+// CHECK: __cyg_profile_func_exit
+// CHECK: ret
+// NOINSTR-NOT: __cyg_profile_func_enter
+// NOINSTR-NOT: __cyg_profile_func_exit
+// NOINSTR: ret
+// NOFILE-NOT: __cyg_profile_func_enter
+// NOFILE-NOT: __cyg_profile_func_exit
+// NOFILE: ret
+// NOFUNC-NOT: __cyg_profile_func_enter
+// NOFUNC-NOT: __cyg_profile_func_exit
+// NOFUNC: ret
   return x;
 }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -771,6 +771,12 @@
 
   Opts.PreserveVec3Type = Args.hasArg(OPT_fpreserve_vec3_type);
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
+  if (Opts.InstrumentFunctions) {
+Opts.InstrumentFunctionExclusionsFunctions
+= Args.getAllArgValues(OPT_finstrument_functions_exclude_function_list);
+Opts.InstrumentFunctionExclusionsPathSegments
+= Args.getAllArgValues(OPT_finstrument_functions_exclude_file_list);
+  }
   Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
   Opts.XRayInstructionThreshold =
   getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3519,7 +3519,14 @@
 options::OPT_fno_unique_section_names, true))
 CmdArgs.push_back("-fno-unique-section-names");
 
-  Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
+  if (Args.hasArg(options::OPT_finstrument_functions,
+  options::OPT_fno_instrument_functions, false)) {
+Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
+Args.AddAllArgs(CmdArgs,
+options::OPT_finstrument_functions_exclude_file_list);
+Args.AddAllArgs(CmdArgs,
+options::OPT_finstrument_functions_exclude_function_list);
+  }
 
   addPGOAndCoverageFlags(C, D, Output, Args, CmdArgs);
 
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1762,7 +1762,7 @@
 
   /// ShouldInstrumentFunction - Return true if the current function should be
   /// instrumented with __cyg_profile_func_* calls
-  bool ShouldInstrumentFunction();
+  bool 

[PATCH] D37599: Add '\n' in ClangDataCollectorsEmitter

2017-09-08 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL312795: Add '\n' in ClangDataCollectorsEmitter (authored by 
kzhuravl).

Changed prior to commit:
  https://reviews.llvm.org/D37599?vs=114269=114376#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37599

Files:
  cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp


Index: cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp
@@ -8,7 +8,7 @@
   const auto  = RK.getClasses();
   for (const auto  : Defs) {
 Record  = *Entry.second;
-OS << "DEF_ADD_DATA(" << R.getName() << ", {";
+OS << "DEF_ADD_DATA(" << R.getName() << ", {\n";
 auto Code = R.getValue("Code")->getValue();
 OS << Code->getAsUnquotedString() << "}\n)";
 OS << "\n";


Index: cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp
@@ -8,7 +8,7 @@
   const auto  = RK.getClasses();
   for (const auto  : Defs) {
 Record  = *Entry.second;
-OS << "DEF_ADD_DATA(" << R.getName() << ", {";
+OS << "DEF_ADD_DATA(" << R.getName() << ", {\n";
 auto Code = R.getValue("Code")->getValue();
 OS << Code->getAsUnquotedString() << "}\n)";
 OS << "\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r312795 - Add '\n' in ClangDataCollectorsEmitter

2017-09-08 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Fri Sep  8 09:17:16 2017
New Revision: 312795

URL: http://llvm.org/viewvc/llvm-project?rev=312795=rev
Log:
Add '\n' in ClangDataCollectorsEmitter

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

Modified:
cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp?rev=312795=312794=312795=diff
==
--- cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp Fri Sep  8 09:17:16 
2017
@@ -8,7 +8,7 @@ void EmitClangDataCollectors(RecordKeepe
   const auto  = RK.getClasses();
   for (const auto  : Defs) {
 Record  = *Entry.second;
-OS << "DEF_ADD_DATA(" << R.getName() << ", {";
+OS << "DEF_ADD_DATA(" << R.getName() << ", {\n";
 auto Code = R.getValue("Code")->getValue();
 OS << Code->getAsUnquotedString() << "}\n)";
 OS << "\n";


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


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-09-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/AttrDocs.td:3154
+
+def SelectAnyDocs : Documentation {
+   let Content = [{This attribute makes global symbol have a weak definition

majnemer wrote:
> aaron.ballman wrote:
> > Prazek wrote:
> > > aaron.ballman wrote:
> > > > Prazek wrote:
> > > > > aaron.ballman wrote:
> > > > > > I think you need to set the `Category` as well.
> > > > > > 
> > > > > > To test this you should run something like (replacing  and 
> > > > > > fixing up path separators as needed):
> > > > > > ```
> > > > > > clang-tblgen -gen-attr-docs -I \llvm\tools\clang\include 
> > > > > > \llvm\tools\clang\include\clang\Basic\Attr.td -o 
> > > > > > \llvm\tools\clang\docs\AttributeReference.rst
> > > > > > ```
> > > > > Thanks for the testing command. Should I do anything in order to 
> > > > > check if docs build?
> > > > > I enabled docs with -DLLVM_BUILD_DOCS=ON, and I have sphinx. 
> > > > > Everything builds, but I don't see docs anywhere.
> > > > > 
> > > > > the docs looks like this:
> > > > > +selectany (gnu::selectany)
> > > > > +--
> > > > > +.. csv-table:: Supported Syntaxes
> > > > > +   :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma", 
> > > > > "Pragma clang attribute"
> > > > > +
> > > > > +   "X","X","X","", "", ""
> > > > > +
> > > > > +This attribute appertains to a global symbol, causing it to have a 
> > > > > weak
> > > > > +definition (
> > > > > +.. _`linkonce`: https://llvm.org/docs/LangRef.html#linkage-types
> > > > > +), allowing the linker to select any definition.
> > > > > +
> > > > > +For more information see
> > > > > +.. `gcc documentation`: 
> > > > > https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Microsoft-Windows-Variable-Attributes.html
> > > > > +
> > > > > Thanks for the testing command. Should I do anything in order to 
> > > > > check if docs build?
> > > > 
> > > > On Windows, I use `make html` within the clang\docs directory to 
> > > > generate the actual sphinx docs -- that will tell you if there are 
> > > > sphinx issues. Be sure you do *not* commit the AttributeReference.rst 
> > > > file that it generates, however.
> > > I tried building docs but it doesn't seem that there is any target like 
> > > "html". Do you know if there is documentation on how to build docs? I 
> > > couldn't find any.
> > I don't know that we have any docs on that, but I believe the command you 
> > want to execute is `sphinx-build -b html -d _build/doctrees . _build/html` 
> > (I pulled this from make.bat in the docs directory.)
> This is not the first time this has come up. Can you please add a comment to 
> the top of AttrDocs.td which explains how to generate the HTML?
Definitely a good idea, I'll tackle it when I have a moment.


https://reviews.llvm.org/D33852



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


[PATCH] D37299: [Modules] Add ability to specify module name to module file mapping in a file

2017-09-08 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added a comment.

Ping.


https://reviews.llvm.org/D37299



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


Re: r312750 - [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-08 Thread Roman Lebedev via cfe-commits
On Fri, Sep 8, 2017 at 3:26 PM, Roman Lebedev  wrote:
> On Fri, Sep 8, 2017 at 2:48 PM, Sam McCall  wrote:
> Hi.
>
>> Nice fix!
> Thank you!
>
>> It catches a lot of new cases on our codebase, all technically
>> correct so far.
>>
>> A couple of issues though:
>> A) Rollout - until we've completely cleaned up, we need to disable
>> -Wtautological-compare entirely, which is a valuable check. I imagine anyone
>> else using -Werror is in the same boat.
>> What do you think about putting the new warnings behind a subcategory? (e.g.
>> -Wtautological-compare-unsigned-zero, implied by -Wtautological-compare)
>> It's an ugly artifact of the history here, but allows this fix to be rolled
>> out in a controlled way.
> https://reviews.llvm.org/D37620
And landed.

>> B) Enums (not new I guess). Typical case: if (enum < 0 || enum > MAX)
>> The warning strongly suggests that the enum < 0 check has no effect (for
>> enums with nonnegative ranges).
>> Clang doesn't seem to optimize such checks out though, and they seem likely
>> to catch bugs in some cases. Yes, only if there's UB elsewhere, but I assume
>> not optimizing out these checks indicates a deliberate decision to stay
>> somewhat compatible with a technically-incorrect mental model.
>> If this is the case, should we move these to a -Wtautological-compare-enum
>> subcategory?
> (Did not look at this yet)
https://reviews.llvm.org/D37629 i hope that is what you meant.

> Roman.
Roman.

>> On Fri, Sep 8, 2017 at 12:14 AM, Roman Lebedev via cfe-commits
>>  wrote:
>>>
>>> Author: lebedevri
>>> Date: Thu Sep  7 15:14:25 2017
>>> New Revision: 312750
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=312750=rev
>>> Log:
>>> [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.
>>>
>>> Summary:
>>> This is a first half(?) of a fix for the following bug:
>>> https://bugs.llvm.org/show_bug.cgi?id=34147 (gcc -Wtype-limits)
>>>
>>> GCC's -Wtype-limits does warn on comparison of unsigned value
>>> with signed zero (as in, with 0), but clang only warns if the
>>> zero is unsigned (i.e. 0U).
>>>
>>> Also, be careful not to double-warn, or falsely warn on
>>> comparison of signed/fp variable and signed 0.
>>>
>>> Yes, all these testcases are needed.
>>>
>>> Testing: $ ninja check-clang-sema check-clang-semacxx
>>> Also, no new warnings for clang stage-2 build.
>>>
>>> Reviewers: rjmccall, rsmith, aaron.ballman
>>>
>>> Reviewed By: rjmccall
>>>
>>> Subscribers: cfe-commits
>>>
>>> Tags: #clang
>>>
>>> Differential Revision: https://reviews.llvm.org/D37565
>>>
>>> Modified:
>>> cfe/trunk/docs/ReleaseNotes.rst
>>> cfe/trunk/lib/Sema/SemaChecking.cpp
>>> cfe/trunk/test/Sema/compare.c
>>> cfe/trunk/test/Sema/outof-range-constant-compare.c
>>> cfe/trunk/test/SemaCXX/compare.cpp
>>>
>>> Modified: cfe/trunk/docs/ReleaseNotes.rst
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=312750=312749=312750=diff
>>>
>>> ==
>>> --- cfe/trunk/docs/ReleaseNotes.rst (original)
>>> +++ cfe/trunk/docs/ReleaseNotes.rst Thu Sep  7 15:14:25 2017
>>> @@ -71,6 +71,13 @@ Improvements to Clang's diagnostics
>>>errors/warnings, as the system frameworks might add a method with the
>>> same
>>>selector which could make the message send to ``id`` ambiguous.
>>>
>>> +- ``-Wtautological-compare`` now warns when comparing an unsigned integer
>>> and 0
>>> +  regardless of whether the constant is signed or unsigned."
>>> +
>>> +- ``-Wtautological-compare`` now warns about comparing a signed integer
>>> and 0
>>> +  when the signed integer is coerced to an unsigned type for the
>>> comparison.
>>> +  ``-Wsign-compare`` was adjusted not to warn in this case.
>>> +
>>>  Non-comprehensive list of changes in this release
>>>  -
>>>
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=312750=312749=312750=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Sep  7 15:14:25 2017
>>> @@ -8567,32 +8567,51 @@ bool HasEnumType(Expr *E) {
>>>return E->getType()->isEnumeralType();
>>>  }
>>>
>>> -void CheckTrivialUnsignedComparison(Sema , BinaryOperator *E) {
>>> +bool isNonBooleanUnsignedValue(Expr *E) {
>>> +  // We are checking that the expression is not known to have boolean
>>> value,
>>> +  // is an integer type; and is either unsigned after implicit casts,
>>> +  // or was unsigned before implicit casts.
>>> +  return !E->isKnownToHaveBooleanValue() && E->getType()->isIntegerType()
>>> &&
>>> + (!E->getType()->isSignedIntegerType() ||
>>> +  

[PATCH] D37629: [Sema] Move some stuff into -Wtautological-unsigned-enum-zero-compare

2017-09-08 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added a project: clang.

As requested by Sam McCall:

> Enums (not new I guess). Typical case: if (enum < 0 || enum > MAX)
>  The warning strongly suggests that the enum < 0 check has no effect
>  (for enums with nonnegative ranges).
>  Clang doesn't seem to optimize such checks out though, and they seem
>  likely to catch bugs in some cases. Yes, only if there's UB elsewhere,
>  but I assume not optimizing out these checks indicates a deliberate
>  decision to stay somewhat compatible with a technically-incorrect
>  mental model.
>  If this is the case, should we move these to a
>  -Wtautological-compare-enum subcategory?


Repository:
  rL LLVM

https://reviews.llvm.org/D37629

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/compare.c
  test/Sema/tautological-unsigned-enum-zero-compare.c

Index: test/Sema/tautological-unsigned-enum-zero-compare.c
===
--- /dev/null
+++ test/Sema/tautological-unsigned-enum-zero-compare.c
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-enum-zero-compare -verify %s
+
+int main() {
+  enum A { A_foo, A_bar };
+  enum A a;
+
+#ifdef TEST
+  if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
+return 0;
+  if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}}
+return 0;
+  if (0 <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}}
+return 0;
+  if (0 > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}}
+return 0;
+  if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
+return 0;
+  if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}}
+return 0;
+  if (0U <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}}
+return 0;
+  if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}}
+return 0;
+#else
+  // expected-no-diagnostics
+  if (a < 0)
+return 0;
+  if (a >= 0)
+return 0;
+  if (0 <= a)
+return 0;
+  if (0 > a)
+return 0;
+  if (a < 0U)
+return 0;
+  if (a >= 0U)
+return 0;
+  if (0U <= a)
+return 0;
+  if (0U > a)
+return 0;
+#endif
+
+  return 1;
+}
Index: test/Sema/compare.c
===
--- test/Sema/compare.c
+++ test/Sema/compare.c
@@ -308,8 +308,59 @@
 int rdar8511238() {
   enum A { A_foo, A_bar };
   enum A a;
+
+  if (a == 0)
+  return 0;
+  if (a != 0)
+  return 0;
   if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
-return 0;
+  return 0;
+  if (a <= 0)
+  return 0;
+  if (a > 0)
+  return 0;
+  if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}}
+  return 0;
+
+  if (0 == a)
+  return 0;
+  if (0 != a)
+  return 0;
+  if (0 < a)
+  return 0;
+  if (0 <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}}
+  return 0;
+  if (0 > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}}
+  return 0;
+  if (0 >= a)
+  return 0;
+
+  if (a == 0U)
+  return 0;
+  if (a != 0U)
+  return 0;
+  if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
+  return 0;
+  if (a <= 0U)
+  return 0;
+  if (a > 0U)
+  return 0;
+  if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}}
+  return 0;
+
+  if (0U == a)
+  return 0;
+  if (0U != a)
+  return 0;
+  if (0U < a)
+  return 0;
+  if (0U <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}}
+  return 0;
+  if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}}
+  return 0;
+  if (0U >= a)
+  return 0;
+
   return 20;
 }
 
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -8590,28 +8590,72 @@
   Expr *LHS = E->getLHS();
   Expr *RHS = E->getRHS();
 
-  bool Match = true;
+  // is this a tautological comparison? if yes, than contains the always-result
+  llvm::Optional Result;
+  Expr *Value; // which one is the value, and not a constant?
+  const char *cmp; // the comparison used, as string
 
   if (op == BO_LT && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) {
-S.Diag(E->getOperatorLoc(), diag::warn_lunsigned_always_true_comparison)
-  << "< 0" << "false" << HasEnumType(LHS)
-  << 

[PATCH] D33852: Enable __declspec(selectany) on linux

2017-09-08 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: include/clang/Basic/AttrDocs.td:3154
+
+def SelectAnyDocs : Documentation {
+   let Content = [{This attribute makes global symbol have a weak definition

aaron.ballman wrote:
> Prazek wrote:
> > aaron.ballman wrote:
> > > Prazek wrote:
> > > > aaron.ballman wrote:
> > > > > I think you need to set the `Category` as well.
> > > > > 
> > > > > To test this you should run something like (replacing  and 
> > > > > fixing up path separators as needed):
> > > > > ```
> > > > > clang-tblgen -gen-attr-docs -I \llvm\tools\clang\include 
> > > > > \llvm\tools\clang\include\clang\Basic\Attr.td -o 
> > > > > \llvm\tools\clang\docs\AttributeReference.rst
> > > > > ```
> > > > Thanks for the testing command. Should I do anything in order to check 
> > > > if docs build?
> > > > I enabled docs with -DLLVM_BUILD_DOCS=ON, and I have sphinx. Everything 
> > > > builds, but I don't see docs anywhere.
> > > > 
> > > > the docs looks like this:
> > > > +selectany (gnu::selectany)
> > > > +--
> > > > +.. csv-table:: Supported Syntaxes
> > > > +   :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma", "Pragma 
> > > > clang attribute"
> > > > +
> > > > +   "X","X","X","", "", ""
> > > > +
> > > > +This attribute appertains to a global symbol, causing it to have a weak
> > > > +definition (
> > > > +.. _`linkonce`: https://llvm.org/docs/LangRef.html#linkage-types
> > > > +), allowing the linker to select any definition.
> > > > +
> > > > +For more information see
> > > > +.. `gcc documentation`: 
> > > > https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Microsoft-Windows-Variable-Attributes.html
> > > > +
> > > > Thanks for the testing command. Should I do anything in order to check 
> > > > if docs build?
> > > 
> > > On Windows, I use `make html` within the clang\docs directory to generate 
> > > the actual sphinx docs -- that will tell you if there are sphinx issues. 
> > > Be sure you do *not* commit the AttributeReference.rst file that it 
> > > generates, however.
> > I tried building docs but it doesn't seem that there is any target like 
> > "html". Do you know if there is documentation on how to build docs? I 
> > couldn't find any.
> I don't know that we have any docs on that, but I believe the command you 
> want to execute is `sphinx-build -b html -d _build/doctrees . _build/html` (I 
> pulled this from make.bat in the docs directory.)
This is not the first time this has come up. Can you please add a comment to 
the top of AttrDocs.td which explains how to generate the HTML?


https://reviews.llvm.org/D33852



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


[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path

2017-09-08 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 114371.
Nebiroth marked 10 inline comments as done.
Nebiroth added a comment.

Ran clang-format on modified files.
More minor refactoring.


https://reviews.llvm.org/D37150

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/tool/ClangdMain.cpp

Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -11,8 +11,8 @@
 #include "JSONRPCDispatcher.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
-
 #include 
 #include 
 #include 
@@ -25,16 +25,43 @@
  llvm::cl::desc("parse on main thread"),
  llvm::cl::init(false), llvm::cl::Hidden);
 
+static llvm::cl::opt CompileCommandsDir(
+"compile-commands-dir",
+llvm::cl::desc("Specify a path to look for compile_commands.json. If path "
+   "is invalid, clangd will look in the current directory and "
+   "parent paths of each source file."));
+
 int main(int argc, char *argv[]) {
   llvm::cl::ParseCommandLineOptions(argc, argv, "clangd");
 
   llvm::raw_ostream  = llvm::outs();
   llvm::raw_ostream  = llvm::errs();
   JSONOutput Out(Outs, Logs);
 
+  // If --compile-commands-dir arg was invoked, check value and override default
+  // path.
+  namespace path = llvm::sys::path;
+
+  if (!llvm::sys::path::is_absolute(CompileCommandsDir)) {
+Out.log("Path specified by --compile-commands-dir must be an absolute "
+"path. The argument will be ignored.\n");
+CompileCommandsDir = "";
+  }
+
+  if (!llvm::sys::fs::exists(CompileCommandsDir)) {
+Out.log("Path specified by --compile-commands-dir. The argument will be "
+"ignored.\n");
+CompileCommandsDir = "";
+  }
+  llvm::Optional CompileCommandsDirPath;
+
   // Change stdin to binary to not lose \r\n on windows.
   llvm::sys::ChangeStdinToBinary();
+  if (CompileCommandsDir.empty())
+CompileCommandsDirPath = llvm::None;
+  else
+CompileCommandsDirPath = CompileCommandsDir;
 
-  ClangdLSPServer LSPServer(Out, RunSynchronously);
+  ClangdLSPServer LSPServer(Out, RunSynchronously, CompileCommandsDirPath);
   LSPServer.run(std::cin);
 }
Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -45,13 +45,18 @@
 class DirectoryBasedGlobalCompilationDatabase
 : public GlobalCompilationDatabase {
 public:
+  DirectoryBasedGlobalCompilationDatabase(
+  llvm::Optional NewCompileCommandsDir)
+  : CompileCommandsDir(NewCompileCommandsDir.getValue()) {}
   std::vector
   getCompileCommands(PathRef File) override;
 
   void setExtraFlagsForFile(PathRef File, std::vector ExtraFlags);
 
 private:
   tooling::CompilationDatabase *getCompilationDatabase(PathRef File);
+  Path CompileCommandsDir;
+  tooling::CompilationDatabase *tryLoadDatabaseFromPath(PathRef File);
 
   std::mutex Mutex;
   /// Caches compilation databases loaded from directories(keys are
Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -62,43 +62,55 @@
 }
 
 tooling::CompilationDatabase *
-DirectoryBasedGlobalCompilationDatabase::getCompilationDatabase(PathRef File) {
-  std::lock_guard Lock(Mutex);
-
+DirectoryBasedGlobalCompilationDatabase::tryLoadDatabaseFromPath(PathRef File) {
   namespace path = llvm::sys::path;
+  auto CachedIt = CompilationDatabases.find(File);
+  std::string Error = "";
 
   assert((path::is_absolute(File, path::Style::posix) ||
   path::is_absolute(File, path::Style::windows)) &&
  "path must be absolute");
 
-  for (auto Path = path::parent_path(File); !Path.empty();
-   Path = path::parent_path(Path)) {
-
-auto CachedIt = CompilationDatabases.find(Path);
-if (CachedIt != CompilationDatabases.end())
-  return CachedIt->second.get();
-std::string Error;
-auto CDB = tooling::CompilationDatabase::loadFromDirectory(Path, Error);
-if (!CDB) {
-  if (!Error.empty()) {
-// FIXME(ibiryukov): logging
-// Output.log("Error when trying to load compilation database from " +
-//Twine(Path) + ": " + Twine(Error) + "\n");
-  }
-  continue;
-}
+  if (CachedIt != CompilationDatabases.end())
+return (CachedIt->second.get());
+  auto CDB = tooling::CompilationDatabase::loadFromDirectory(File, Error);
+  if (CDB && Error.empty()) {
+auto result = CDB.get();
+CompilationDatabases.insert(std::make_pair(File, std::move(CDB)));
 
 // FIXME(ibiryukov): Invalidate cached compilation 

[PATCH] D37572: [clang-tidy] SuspiciousEnumUsageCheck bugfix

2017-09-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/clang-tidy/misc-suspicious-enum-usage.cpp:122
+struct a> {
+  enum { ah = ad::m,
+ ai = ae::m,

alexfh wrote:
> aaron.ballman wrote:
> > This seems like a lot of complicated code for the test case -- can this be 
> > reduced further?
> This is the best creduce could do. It should be possible to make this much 
> shorter, but I wouldn't spend too much time on that.
I'd appreciate the time spent because this is an almost-unintelligible test for 
anyone reading it -- it's hard to understand what's going on there.


https://reviews.llvm.org/D37572



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


[PATCH] D37624: add support for -fno-instrument-functions and -finstrument-functions-exclude-{file, function}-list=<arg1, arg2, ...> to match gcc options.

2017-09-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/CodeGen/CodeGenFunction.cpp:425
 /// instrumented with __cyg_profile_func_* calls
-bool CodeGenFunction::ShouldInstrumentFunction() {
+bool CodeGenFunction::ShouldInstrumentFunction(llvm::Function *Fn) {
+  typedef std::vector::const_iterator CIt;

This parameter can be `const`.



Comment at: lib/CodeGen/CodeGenFunction.cpp:436
+  // to resolve.
+  const FunctionDecl *ActualFuncDecl = dyn_cast(CurFuncDecl);
+  if (ActualFuncDecl &&

Can use `const auto *` here.



Comment at: lib/CodeGen/CodeGenFunction.cpp:444
+  SourceLocation SLoc = CurFuncDecl->getLocation();
+  static std::unordered_map cache;
+

This static has me worried. Does this data need to be cached across codegen 
modules? If not, perhaps this variable can be hung onto the CodeGenModule 
instead?

The variable should be named `Cache` instead of `cache`. Also, is an 
`unordered_map` the correct data structure to use? Would a `DenseMap` make more 
sense because the keys and values are both small (`PresumedLoc::getFilename()` 
returns a `const char *` that I believe can be used).



Comment at: lib/CodeGen/CodeGenFunction.cpp:447
+  if (SLoc.isFileID()) {
+unsigned key = SLoc.getRawEncoding();
+if (cache.find(key) == cache.end()) {

key -> Key



Comment at: lib/CodeGen/CodeGenFunction.cpp:449
+if (cache.find(key) == cache.end()) {
+  ASTContext  = CurFuncDecl->getASTContext();
+  const SourceManager  = ctx.getSourceManager();

ctx -> CTX, and I think this can be a const ref.



Comment at: lib/CodeGen/CodeGenFunction.cpp:460-461
+
+for (CIt i = PathSearch.begin(), e = PathSearch.end(); i != e; ++i) {
+  if(FunctionDeclPath.find(*i) != std::string::npos) {
+return false;

You can use a range-based for loop here instead, and then get rid of the 
typedef for `CIt`.



Comment at: lib/CodeGen/CodeGenFunction.cpp:467
+
+  std::string FunctionName = Fn->getName();
+

You can avoid the copy here by assigning to a `StringRef` instead.



Comment at: lib/CodeGen/CodeGenFunction.cpp:472
+  if (ActualFuncDecl && !ActualFuncDecl->isExternC()) {
+int status = 0;
+char *result = __cxa_demangle(FunctionName.c_str(), 0, 0, );

status -> Status



Comment at: lib/CodeGen/CodeGenFunction.cpp:473
+int status = 0;
+char *result = __cxa_demangle(FunctionName.c_str(), 0, 0, );
+

result -> Result



Comment at: lib/CodeGen/CodeGenFunction.cpp:486
+CGM.getCodeGenOpts().InstrumentFunctionExclusionsFunctions;
+  for (CIt i = FunctionSearch.begin(), e = FunctionSearch.end(); i != e; ++i) {
+if(FunctionName.find(*i) != std::string::npos) {

Can use a range-based for loop here.


https://reviews.llvm.org/D37624



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


[PATCH] D37572: [clang-tidy] SuspiciousEnumUsageCheck bugfix

2017-09-08 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG modulo comments. Thank you for the fix!




Comment at: test/clang-tidy/misc-suspicious-enum-usage.cpp:1
-// RUN: %check_clang_tidy %s misc-suspicious-enum-usage %t -- 
-config="{CheckOptions: [{key: misc-suspicious-enum-usage.StrictMode, value: 
0}]}" --
+// RUN: %check_clang_tidy %s misc-suspicious-enum-usage %t -- 
-config="{CheckOptions: [{key: misc-suspicious-enum-usage.StrictMode, value: 
0}]}" -- -std=c++11
 

aaron.ballman wrote:
> I thought we built in C++11 mode by default these days?
I'm not sure, but if we actually do, we could later remove `-std=c++11` from 
the test script and all tests.



Comment at: test/clang-tidy/misc-suspicious-enum-usage.cpp:92
+
+// Bug #34400
+template 

I'd suggest enclosing the test case in a `namespace PR34400 {}` for clarity and 
to avoid possible name conflicts.



Comment at: test/clang-tidy/misc-suspicious-enum-usage.cpp:122
+struct a> {
+  enum { ah = ad::m,
+ ai = ae::m,

aaron.ballman wrote:
> This seems like a lot of complicated code for the test case -- can this be 
> reduced further?
This is the best creduce could do. It should be possible to make this much 
shorter, but I wouldn't spend too much time on that.


https://reviews.llvm.org/D37572



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


Re: Patch bug 27628

2017-09-08 Thread Krzysztof Parzyszek via cfe-commits

Aaand the patch itself...

-K

On 9/8/2017 10:32 AM, Krzysztof Parzyszek via cfe-commits wrote:

This should to to cfe-commits.  Redirecting.

-Krzysztof

On 9/8/2017 10:25 AM, Antoni Boucher via llvm-commits wrote:

Hello.
I've fixed the bug 27628:
https://bugs.llvm.org/show_bug.cgi?id=27628

I attached the patch.

Thanks.


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





--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp   (révision 312787)
+++ clang-tidy/tool/ClangTidyMain.cpp   (copie de travail)
@@ -449,6 +449,10 @@
 return WErrorCount;
   }
 
+  if (FoundErrors) {
+  return 1;
+  }
+
   return 0;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36327: [OpenCL] Allow targets emit optimized pipe functions for power of 2 type sizes

2017-09-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl abandoned this revision.
yaxunl added a comment.

We implemented this optimization through some target specific llvm pass.


https://reviews.llvm.org/D36327



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


Re: Patch bug 27628

2017-09-08 Thread Krzysztof Parzyszek via cfe-commits

This should to to cfe-commits.  Redirecting.

-Krzysztof

On 9/8/2017 10:25 AM, Antoni Boucher via llvm-commits wrote:

Hello.
I've fixed the bug 27628:
https://bugs.llvm.org/show_bug.cgi?id=27628

I attached the patch.

Thanks.


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



--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation

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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-09-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.



Comment at: lib/Sema/SemaType.cpp:6994
+  // OpenCL v1.2 s6.5:
+  // The generic address space name for arguments to a function in a
+  // program, or local variables of a function is __private. All function

Anastasia wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > The generic address space -> The default address space
> > 'The generic address space name for arguments' is literally from the OpenCL 
> > 1.2 spec. Note it refers 'generic address space name', which is not the 
> > 'generic address space' defined by OpenCL 2.0 spec.
> True, but this spec was written before v2.0 was released. And I feel now it 
> makes things confusing considering that we have v2.0 implementation too.
I can make the change. I just feel a little bit uneasy since this looks like a 
citation but actually is rephrased.


https://reviews.llvm.org/D35082



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-09-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Sema/SemaType.cpp:6994
+  // OpenCL v1.2 s6.5:
+  // The generic address space name for arguments to a function in a
+  // program, or local variables of a function is __private. All function

yaxunl wrote:
> Anastasia wrote:
> > The generic address space -> The default address space
> 'The generic address space name for arguments' is literally from the OpenCL 
> 1.2 spec. Note it refers 'generic address space name', which is not the 
> 'generic address space' defined by OpenCL 2.0 spec.
True, but this spec was written before v2.0 was released. And I feel now it 
makes things confusing considering that we have v2.0 implementation too.


https://reviews.llvm.org/D35082



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


r312794 - Recommit "Add _Float16 as a C/C++ source language type"

2017-09-08 Thread Sjoerd Meijer via cfe-commits
Author: sjoerdmeijer
Date: Fri Sep  8 08:15:00 2017
New Revision: 312794

URL: http://llvm.org/viewvc/llvm-project?rev=312794=rev
Log:
Recommit "Add _Float16 as a C/C++ source language type"

This is a recommit of r312781; in some build configurations
variable names are omitted, so changed the new regression
test accordingly.

Added:
cfe/trunk/test/CodeGenCXX/float16-declarations.cpp
cfe/trunk/test/Frontend/float16.cpp
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/BuiltinTypes.def
cfe/trunk/include/clang/Basic/Specifiers.h
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Lex/LiteralSupport.h
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/NSAPI.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Format/FormatToken.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Lexer/half-literal.cpp
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=312794=312793=312794=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Fri Sep  8 08:15:00 2017
@@ -3115,8 +3115,9 @@ enum CXTypeKind {
   CXType_ObjCSel = 29,
   CXType_Float128 = 30,
   CXType_Half = 31,
+  CXType_Float16 = 32,
   CXType_FirstBuiltin = CXType_Void,
-  CXType_LastBuiltin  = CXType_Half,
+  CXType_LastBuiltin  = CXType_Float16,
 
   CXType_Complex = 100,
   CXType_Pointer = 101,

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=312794=312793=312794=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Fri Sep  8 08:15:00 2017
@@ -973,6 +973,7 @@ public:
   CanQualType UnsignedLongLongTy, UnsignedInt128Ty;
   CanQualType FloatTy, DoubleTy, LongDoubleTy, Float128Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
+  CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
   CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy;
   CanQualType Float128ComplexTy;
   CanQualType VoidPtrTy, NullPtrTy;

Modified: cfe/trunk/include/clang/AST/BuiltinTypes.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BuiltinTypes.def?rev=312794=312793=312794=diff
==
--- cfe/trunk/include/clang/AST/BuiltinTypes.def (original)
+++ cfe/trunk/include/clang/AST/BuiltinTypes.def Fri Sep  8 08:15:00 2017
@@ -133,6 +133,9 @@ FLOATING_TYPE(Double, DoubleTy)
 // 'long double'
 FLOATING_TYPE(LongDouble, LongDoubleTy)
 
+// '_Float16'
+FLOATING_TYPE(Float16, HalfTy)
+
 // '__float128'
 FLOATING_TYPE(Float128, Float128Ty)
 

Modified: cfe/trunk/include/clang/Basic/Specifiers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Specifiers.h?rev=312794=312793=312794=diff
==
--- cfe/trunk/include/clang/Basic/Specifiers.h (original)
+++ cfe/trunk/include/clang/Basic/Specifiers.h Fri Sep  8 08:15:00 2017
@@ -52,6 +52,7 @@ namespace clang {
 TST_int,
 TST_int128,
 TST_half, // OpenCL half, ARM NEON __fp16
+TST_Float16,  // C11 extension ISO/IEC TS 18661-3
 TST_float,
 TST_double,
 TST_float128,

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=312794=312793=312794=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Fri Sep  8 08:15:00 2017
@@ -379,6 +379,9 @@ KEYWORD(co_yield   

[PATCH] D37568: [AMDGPU] Allow flexible register names in inline asm constraints

2017-09-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 114367.
yaxunl edited the summary of this revision.
yaxunl added a comment.

Allow {v[n]} and {s[n]}. Add more tests.


https://reviews.llvm.org/D37568

Files:
  lib/Basic/Targets/AMDGPU.h
  test/CodeGenOpenCL/amdgcn-inline-asm.cl
  test/Sema/inline-asm-validate-amdgpu.cl

Index: test/Sema/inline-asm-validate-amdgpu.cl
===
--- test/Sema/inline-asm-validate-amdgpu.cl
+++ test/Sema/inline-asm-validate-amdgpu.cl
@@ -1,14 +1,76 @@
 // REQUIRES: amdgpu-registered-target
-// RUN: %clang_cc1 -x cl -triple amdgcn -fsyntax-only  %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -triple amdgcn -fsyntax-only -verify %s
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
 
 kernel void test () {
 
   int sgpr = 0, vgpr = 0, imm = 0;
 
   // sgpr constraints
   __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "s" (imm) : );
 
+  __asm__ ("s_mov_b32 %0, %1" : "={s1}" (sgpr) : "{exec}" (imm) : );
+  __asm__ ("s_mov_b32 %0, %1" : "={s1}" (sgpr) : "{exe" (imm) : ); // expected-error {{invalid input constraint '{exe' in asm}}
+  __asm__ ("s_mov_b32 %0, %1" : "={s1}" (sgpr) : "{exec" (imm) : ); // expected-error {{invalid input constraint '{exec' in asm}}
+  __asm__ ("s_mov_b32 %0, %1" : "={s1}" (sgpr) : "{exec}a" (imm) : ); // expected-error {{invalid input constraint '{exec}a' in asm}}
+
   // vgpr constraints
   __asm__ ("v_mov_b32 %0, %1" : "=v" (vgpr) : "v" (imm) : );
 }
+
+__kernel void
+test_float(const __global float *a, const __global float *b, __global float *c, unsigned i)
+{
+float ai = a[i];
+float bi = b[i];
+float ci;
+
+__asm("v_add_f32_e32 v1, v2, v3" : "={v1}"(ci) : "{v2}"(ai), "{v3}"(bi) : );
+__asm("v_add_f32_e32 v1, v2, v3" : ""(ci) : "{v2}"(ai), "{v3}"(bi) : ); // expected-error {{invalid output constraint '' in asm}}
+__asm("v_add_f32_e32 v1, v2, v3" : "="(ci) : "{v2}"(ai), "{v3}"(bi) : ); // expected-error {{invalid output constraint '=' in asm}}
+__asm("v_add_f32_e32 v1, v2, v3" : "={a}"(ci) : "{v2}"(ai), "{v3}"(bi) : ); // expected-error {{invalid output constraint '={a}' in asm}}
+__asm("v_add_f32_e32 v1, v2, v3" : "={"(ci) : "{v2}"(ai), "{v3}"(bi) : ); // expected-error {{invalid output constraint '={' in asm}}
+__asm("v_add_f32_e32 v1, v2, v3" : "={}"(ci) : "{v2}"(ai), "{v3}"(bi) : ); // expected-error {{invalid output constraint '={}' in asm}}
+__asm("v_add_f32_e32 v1, v2, v3" : "={v"(ci) : "{v2}"(ai), "{v3}"(bi) : ); // expected-error {{invalid output constraint '={v' in asm}}
+__asm("v_add_f32_e32 v1, v2, v3" : "={v1a}"(ci) : "{v2}"(ai), "{v3}"(bi) : ); // expected-error {{invalid output constraint '={v1a}' in asm}}
+__asm("v_add_f32_e32 v1, v2, v3" : "={va}"(ci) : "{v2}"(ai), "{v3}"(bi) : ); // expected-error {{invalid output constraint '={va}' in asm}}
+__asm("v_add_f32_e32 v1, v2, v3" : "={v1}a"(ci) : "{v2}"(ai), "{v3}"(bi) : ); // expected-error {{invalid output constraint '={v1}a' in asm}}
+__asm("v_add_f32_e32 v1, v2, v3" : "={v1"(ci) : "{v2}"(ai), "{v3}"(bi) : ); // expected-error {{invalid output constraint '={v1' in asm}}
+__asm("v_add_f32_e32 v1, v2, v3" : "=v1}"(ci) : "{v2}"(ai), "{v3}"(bi) : ); // expected-error {{invalid output constraint '=v1}' in asm}}
+
+__asm("v_add_f32_e32 v1, v2, v3" : "={v[1]}"(ci) : "{v[2]}"(ai), "{v[3]}"(bi) : );
+__asm("v_add_f32_e32 v1, v2, v3" : "={v[1}"(ci) : "{v[2]}"(ai), "{v[3]}"(bi) : ); // expected-error {{invalid output constraint '={v[1}' in asm}}
+__asm("v_add_f32_e32 v1, v2, v3" : "={v[1]"(ci) : "{v[2]}"(ai), "{v[3]}"(bi) : ); // expected-error {{invalid output constraint '={v[1]' in asm}}
+__asm("v_add_f32_e32 v1, v2, v3" : "={v[a]}"(ci) : "{v[2]}"(ai), "{v[3]}"(bi) : ); // expected-error {{invalid output constraint '={v[a]}' in asm}}
+
+__asm("v_add_f32_e32 v1, v2, v3" : "=v"(ci) : "v"(ai), "v"(bi) : );
+__asm("v_add_f32_e32 v1, v2, v3" : "=v1"(ci) : "v2"(ai), "v3"(bi) : ); /// expected-error {{invalid output constraint '=v1' in asm}}
+
+__asm("v_add_f32_e32 v1, v2, v3" : "={v1}"(ci) : "{a}"(ai), "{v3}"(bi) : ); // expected-error {{invalid input constraint '{a}' in asm}}
+__asm("v_add_f32_e32 v1, v2, v3" : "={v1}"(ci) : "{v2}"(ai), "{a}"(bi) : ); // expected-error {{invalid input constraint '{a}' in asm}}
+c[i] = ci;
+}
+
+__kernel void
+test_double(const __global double *a, const __global double *b, __global double *c, unsigned i)
+{
+double ai = a[i];
+double bi = b[i];
+double ci;
+
+__asm("v_add_f64_e64 v[1:2], v[3:4], v[5:6]" : "={v[1:2]}"(ci) : "{v[3:4]}"(ai), "{v[5:6]}"(bi) : );
+__asm("v_add_f64_e64 v[1:2], v[3:4], v[5:6]" : "=v{[1:2]}"(ci) : "{v[3:4]}"(ai), "{v[5:6]}"(bi) : ); //expected-error {{invalid output constraint '=v{[1:2]}' in asm}}
+__asm("v_add_f64_e64 v[1:2], v[3:4], v[5:6]" : "={v[1:2]a}"(ci) : "{v[3:4]}"(ai), "{v[5:6]}"(bi) : ); //expected-error {{invalid output constraint '={v[1:2]a}' in asm}}
+

[PATCH] D37572: [clang-tidy] SuspiciousEnumUsageCheck bugfix

2017-09-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:46
+  return llvm::APSInt::compareValues(E1->getInitVal(),
+ E2->getInitVal()) == -1;
 });

I would test for `< 0` rather than a direct equality test (compare functions 
generally follow the C idioms).



Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:61-62
   ValueRange Range1(Enum1), Range2(Enum2);
-  return (Range1.MaxVal < Range2.MinVal) || (Range2.MaxVal < Range1.MinVal);
+  bool Less1 = llvm::APSInt::compareValues(Range1.MaxVal, Range2.MinVal) == -1;
+  bool Less2 = llvm::APSInt::compareValues(Range2.MaxVal, Range1.MinVal) == -1;
+  return Less1 || Less2;

Same here, though I would also get rid of the local variables and just perform 
the comparison in the return statement.



Comment at: test/clang-tidy/misc-suspicious-enum-usage.cpp:1
-// RUN: %check_clang_tidy %s misc-suspicious-enum-usage %t -- 
-config="{CheckOptions: [{key: misc-suspicious-enum-usage.StrictMode, value: 
0}]}" --
+// RUN: %check_clang_tidy %s misc-suspicious-enum-usage %t -- 
-config="{CheckOptions: [{key: misc-suspicious-enum-usage.StrictMode, value: 
0}]}" -- -std=c++11
 

I thought we built in C++11 mode by default these days?



Comment at: test/clang-tidy/misc-suspicious-enum-usage.cpp:122
+struct a> {
+  enum { ah = ad::m,
+ ai = ae::m,

This seems like a lot of complicated code for the test case -- can this be 
reduced further?


https://reviews.llvm.org/D37572



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


[PATCH] D37140: [clang-format] Fixed one-line if statement

2017-09-08 Thread Pawel Maciocha via Phabricator via cfe-commits
PriMee added a comment.

Yes, would be great :) Thank you!


https://reviews.llvm.org/D37140



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


[PATCH] D37491: [Preamble] Fixed preamble breaking with BOM presence (and particularly, fluctuating BOM presence)

2017-09-08 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D37491#864649, @erikjv wrote:

> Will this fix PR25023 and PR21144?


PR25023  should be fixed by this 
change. It is essentially a repro of the same bug.
Could we add a `c-index-test`-based test here to make sure we addressed that 
particular use-case?

The state of PR21144   won't be 
affected, as this change does not touch the code invoked during normal 
compilation without preambles.
If PR21144  is fixed in a way that 
would make `SourceLocation`s the same regardless if BOM was present or not, we 
might have a better guarantee that nothing will break in case we want to reuse 
preamble between BOM/non-BOM versions.


https://reviews.llvm.org/D37491



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


  1   2   >