[PATCH] D46485: Add python tool to dump and construct header maps

2018-05-15 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 146992.
bruno added a comment.

Update after Jan review.


https://reviews.llvm.org/D46485

Files:
  CMakeLists.txt
  test/CMakeLists.txt
  test/Preprocessor/Inputs/headermap-rel/foo.hmap
  test/Preprocessor/Inputs/headermap-rel/foo.hmap.json
  test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap
  test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap.json
  test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap
  test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json
  test/Preprocessor/headermap-rel.c
  test/Preprocessor/headermap-rel2.c
  test/Preprocessor/nonportable-include-with-hmap.c
  utils/hmaptool/CMakeLists.txt
  utils/hmaptool/hmaptool

Index: utils/hmaptool/hmaptool
===
--- /dev/null
+++ utils/hmaptool/hmaptool
@@ -0,0 +1,289 @@
+#!/usr/bin/env python
+
+import json
+import optparse
+import os
+import struct
+import sys
+
+###
+
+k_header_magic_LE = 'pamh'
+k_header_magic_BE = 'hmap'
+
+def hmap_hash(str):
+"""hash(str) -> int
+
+Apply the "well-known" headermap hash function.
+"""
+
+return sum((ord(c.lower()) * 13
+for c in str), 0)
+
+class HeaderMap(object):
+@staticmethod
+def frompath(path):
+with open(path, 'rb') as f:
+magic = f.read(4)
+if magic == k_header_magic_LE:
+endian_code = '<'
+elif magic == k_header_magic_BE:
+endian_code = '>'
+else:
+raise SystemExit("error: %s: not a headermap" % (
+path,))
+
+# Read the header information.
+header_fmt = endian_code + 'HH'
+header_size = struct.calcsize(header_fmt)
+data = f.read(header_size)
+if len(data) != header_size:
+raise SystemExit("error: %s: truncated headermap header" % (
+path,))
+
+(version, reserved, strtable_offset, num_entries,
+ num_buckets, max_value_len) = struct.unpack(header_fmt, data)
+
+if version != 1:
+raise SystemExit("error: %s: unknown headermap version: %r" % (
+path, version))
+if reserved != 0:
+raise SystemExit("error: %s: invalid reserved value in header" % (
+path,))
+
+# The number of buckets must be a power of two.
+if num_buckets == 0 or (num_buckets & num_buckets - 1) != 0:
+raise SystemExit("error: %s: invalid number of buckets" % (
+path,))
+
+# Read all of the buckets.
+bucket_fmt = endian_code + 'III'
+bucket_size = struct.calcsize(bucket_fmt)
+buckets_data = f.read(num_buckets * bucket_size)
+if len(buckets_data) != num_buckets * bucket_size:
+raise SystemExit("error: %s: truncated headermap buckets" % (
+path,))
+buckets = [struct.unpack(bucket_fmt,
+ buckets_data[i*bucket_size:(i+1)*bucket_size])
+   for i in range(num_buckets)]
+
+# Read the string table; the format doesn't explicitly communicate the
+# size of the string table (which is dumb), so assume it is the rest of
+# the file.
+f.seek(0, 2)
+strtable_size = f.tell() - strtable_offset
+f.seek(strtable_offset)
+
+strtable = f.read(strtable_size)
+if len(strtable) != strtable_size:
+raise SystemExit("error: %s: unable to read complete string table"%(
+path,))
+if strtable[-1] != '\0':
+raise SystemExit("error: %s: invalid string table in headermap" % (
+path,))
+
+return HeaderMap(num_entries, buckets, strtable)
+
+def __init__(self, num_entries, buckets, strtable):
+self.num_entries = num_entries
+self.buckets = buckets
+self.strtable = strtable
+
+def get_string(self, idx):
+if idx >= len(self.strtable):
+raise SystemExit("error: %s: invalid string index" % (
+path,))
+end_idx = self.strtable.index('\0', idx)
+return self.strtable[idx:end_idx]
+
+@property
+def mappings(self):
+for key_idx,prefix_idx,suffix_idx in self.buckets:
+if key_idx == 0:
+continue
+yield (self.get_string(key_idx),
+   self.get_string(prefix_idx) + self.get_string(suffix_idx))
+
+###
+
+def action_dump(name, args):
+"dump a headermap file"
+
+parser = optparse.OptionParser("%%prog %s [options] " % (
+name,))
+parser.add_option("-v", "--verbose", dest="verbose",
+  help="show more verbose output [%default]",
+  

[PATCH] D46485: Add python tool to dump and construct header maps

2018-05-15 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno marked an inline comment as done.
bruno added inline comments.



Comment at: utils/hmaptool/hmaptool:55
+# The number of buckets must be a power of two.
+if num_buckets == 0 or (num_buckets & num_buckets - 1) != 0:
+raise SystemExit("error: %s: invalid number of buckets" % (

jkorous wrote:
> Wouldn't it be simpler to use modulo 2?
> 
> ```
> if num_buckets % 2 == 0
> ```
We want it to be a power of two, not just a multiple.



Comment at: utils/hmaptool/hmaptool:234
+
+if len(args) != 2:
+parser.error("invalid number of arguments")

jkorous wrote:
> Aren't we expecting just single argument () here?
We also need the  from --build-path 


Repository:
  rC Clang

https://reviews.llvm.org/D46485



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


[PATCH] D46927: Augmented Assignment for Fixed Point Types

2018-05-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr, jakehehrlich.
leonardchan added a project: clang.

This patch contains the changes and tests for augmented assignments for primary 
fixed point types.

  s_accum = 7.5hk;
  s_accum2 = 2.0hk;
  s_accum += s_accum2;
  assert(s_accum == 9.5hk);
  s_accum += 2.5k;
  assert(s_accum == 12);

This is a parent of https://reviews.llvm.org/D46926


Repository:
  rC Clang

https://reviews.llvm.org/D46927

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Sema/SemaExpr.cpp
  test/Frontend/fixed_point_validation.c

Index: test/Frontend/fixed_point_validation.c
===
--- test/Frontend/fixed_point_validation.c
+++ test/Frontend/fixed_point_validation.c
@@ -279,4 +279,35 @@
   float laccum_diff = abs(base - 2.333lk);
   assert(accum_diff < saccum_diff);
   assert(laccum_diff < accum_diff);
+
+  / Auxillary assignments ***/
+
+  s_accum = 7.5hk;
+  s_accum2 = 2.0hk;
+  s_accum += s_accum2;
+  assert(s_accum == 9.5hk);
+  s_accum += 2.5k;
+  assert(s_accum == 12);
+
+  s_accum -= s_accum2;
+  assert(s_accum == 10);
+  s_accum -= 2.5lk;
+  assert(s_accum == 7.5k);
+
+  s_accum2 = 3.0k;
+  s_accum *= s_accum2;
+  assert(s_accum == 22.5k);
+  s_accum *= 0.5r;
+  assert(s_accum == 11.25hk);
+
+  s_accum /= s_accum2;
+  assert(s_accum == 3.75k);
+  s_accum /= 0.5hr;
+  assert(s_accum == 7.5k);
+
+  s_accum <<= 3;
+  assert(s_accum == 60);
+
+  s_accum >>= 3;
+  assert(s_accum == 7.5k);
 }
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -6057,7 +6057,7 @@
   default: llvm_unreachable("Unable to convert from fixed point type");
   case Type::STK_Integral: llvm_unreachable("Unimplemented scalar cast from fixed point to int");  // TODO
   case Type::STK_Floating: return CK_FixedPointToFloating;
-  case Type::STK_FixedPoint: llvm_unreachable("Unimplemented scalar cast from fixed point to fixed point");  // TODO
+  case Type::STK_FixedPoint: return CK_FixedPointCast;
 }
   }
 
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -308,6 +308,17 @@
   Value *EmitScalarConversion(Value *Src, QualType SrcTy, QualType DstTy,
   SourceLocation Loc, bool TreatBooleanAsSigned);
 
+  /// Emit a conversion between fixed point types by moving the radix point.
+  /// This does not take into account resizing of the underlying llvm type
+  /// which should be handled either before or after calling this function.
+  /// 
+  /// If the type is being scaled up, this method should be called after
+  /// performing an intcast. If the type is scaled down, this method should be
+  /// called before performing an intcast. This is necessary such that the
+  /// shift operations retain as much of the original data as possible before
+  /// truncation or after extension.
+  Value *EmitFixedPointRadixShift(Value *Src, QualType SrcTy, QualType DstTy);
+
   /// Emit a conversion from the specified complex type to the specified
   /// destination type, where the destination type is an LLVM scalar type.
   Value *EmitComplexToScalarConversion(CodeGenFunction::ComplexPairTy Src,
@@ -957,6 +968,50 @@
 SanitizerHandler::FloatCastOverflow, StaticArgs, OrigSrc);
 }
 
+
+/// Emit a conversion between fixed point types by moving the radix point.
+/// This does not take into account resizing of the underlying llvm type
+/// which should be handled either before or after calling this function.
+/// 
+/// If the type is being scaled up, this method should be called after
+/// performing an intcast. If the type is scaled down, this method should be
+/// called before performing an intcast. This is necessary such that the
+/// shift operations retain as much of the original data as possible before
+/// truncation or after extension.
+Value *ScalarExprEmitter::EmitFixedPointRadixShift(Value *Src, QualType SrcTy,
+   QualType DstTy) {
+  assert(DstTy->isFixedPointType());
+  assert(SrcTy->isFixedPointType());
+
+  Value* Res = Src;
+
+  // Casting between fixed point types involves separating the integral and
+  // fractional bits, potentially shifting them, then joining back together.
+  unsigned dest_fbits = getFixedPointFBits(DstTy);
+  unsigned src_fbits = getFixedPointFBits(SrcTy);
+  unsigned dest_ibits = getFixedPointIBits(DstTy);
+  unsigned src_ibits = getFixedPointIBits(SrcTy);
+
+  // If the number of integral bits is decreasing, trim off any extra bits while
+  // retaining the sign.
+  if (dest_ibits < src_ibits) {
+Res = Builder.CreateShl(Res, src_ibits - dest_ibits);
+Res = Builder.CreateAShr(Res, src_ibits - 

[PATCH] D45900: CodeGen: Fix invalid bitcast for lifetime.start/end

2018-05-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 146987.
yaxunl edited the summary of this revision.
yaxunl added a comment.

Add optional argument to CreateMemTemp and CreateTempAlloca to get the original 
alloca and use it for lifetime intrinsic.


https://reviews.llvm.org/D45900

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/amdgcn_declspec_get.cpp

Index: test/CodeGenCXX/amdgcn_declspec_get.cpp
===
--- /dev/null
+++ test/CodeGenCXX/amdgcn_declspec_get.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm -O3 -fdeclspec \
+// RUN: -disable-llvm-passes -o - %s | FileCheck %s
+
+int get_x();
+
+struct A {
+   __declspec(property(get = _get_x)) int x;
+   static int _get_x(void) {
+ return get_x();
+   };
+};
+
+extern const A a;
+
+// CHECK-LABEL: define void @_Z4testv()
+// CHECK:  %i = alloca i32, align 4, addrspace(5)
+// CHECK:  %[[ii:.*]] = addrspacecast i32 addrspace(5)* %i to i32*
+// CHECK:  %[[cast:.*]] = bitcast i32 addrspace(5)* %i to i8 addrspace(5)*
+// CHECK:  call void @llvm.lifetime.start.p5i8(i64 4, i8 addrspace(5)* %[[cast]])
+// CHECK:  %call = call i32 @_ZN1A6_get_xEv()
+// CHECK:  store i32 %call, i32* %[[ii]]
+// CHECK:  %[[cast2:.*]] = bitcast i32 addrspace(5)* %i to i8 addrspace(5)*
+// CHECK:  call void @llvm.lifetime.end.p5i8(i64 4, i8 addrspace(5)* %[[cast2]])
+void test()
+{
+  int i = a.x;
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2023,11 +2023,14 @@
   /// various ways, this function will perform the cast by default. The cast
   /// may be avoided by passing false as \p CastToDefaultAddrSpace; this is
   /// more efficient if the caller knows that the address will not be exposed.
+  /// The original alloca instruction is returned through \p Alloca if it is
+  /// not nullptr.
   llvm::AllocaInst *CreateTempAlloca(llvm::Type *Ty, const Twine  = "tmp",
  llvm::Value *ArraySize = nullptr);
   Address CreateTempAlloca(llvm::Type *Ty, CharUnits align,
const Twine  = "tmp",
llvm::Value *ArraySize = nullptr,
+   Address *Alloca = nullptr,
bool CastToDefaultAddrSpace = true);
 
   /// CreateDefaultAlignedTempAlloca - This creates an alloca with the
@@ -2064,10 +2067,13 @@
 
   /// CreateMemTemp - Create a temporary memory object of the given type, with
   /// appropriate alignment. Cast it to the default address space if
-  /// \p CastToDefaultAddrSpace is true.
+  /// \p CastToDefaultAddrSpace is true. Returns the original alloca
+  /// instruction by \p Alloca if it is not nullptr.
   Address CreateMemTemp(QualType T, const Twine  = "tmp",
+Address *Alloca = nullptr,
 bool CastToDefaultAddrSpace = true);
   Address CreateMemTemp(QualType T, CharUnits Align, const Twine  = "tmp",
+Address *Alloca = nullptr,
 bool CastToDefaultAddrSpace = true);
 
   /// CreateAggTemp - Create a temporary memory object for the given
@@ -2515,7 +2521,9 @@
 
 const VarDecl *Variable;
 
-/// The address of the alloca.  Invalid if the variable was emitted
+/// The address of the alloca for languages with explicit address space
+/// (e.g. OpenCL) or alloca casted to generic pointer for address space
+/// agnostic languages (e.g. C++). Invalid if the variable was emitted
 /// as a global constant.
 Address Addr;
 
@@ -2531,13 +2539,19 @@
 /// Non-null if we should use lifetime annotations.
 llvm::Value *SizeForLifetimeMarkers;
 
+/// Address with original alloca instruction. Invalid if the variable was
+/// emitted as a global constant.
+Address AllocaAddr;
+
 struct Invalid {};
-AutoVarEmission(Invalid) : Variable(nullptr), Addr(Address::invalid()) {}
+AutoVarEmission(Invalid)
+: Variable(nullptr), Addr(Address::invalid()),
+  AllocaAddr(Address::invalid()) {}
 
 AutoVarEmission(const VarDecl )
-  : Variable(), Addr(Address::invalid()), NRVOFlag(nullptr),
-IsByRef(false), IsConstantAggregate(false),
-SizeForLifetimeMarkers(nullptr) {}
+: Variable(), Addr(Address::invalid()), NRVOFlag(nullptr),
+  IsByRef(false), IsConstantAggregate(false),
+  SizeForLifetimeMarkers(nullptr), AllocaAddr(Address::invalid()) {}
 
 bool wasEmittedAsGlobal() const { return !Addr.isValid(); }
 
@@ -2553,11 +2567,15 @@
 }
 
 /// Returns the raw, allocated address, which is not necessarily
-/// the address of the object itself.
+/// the address of the object itself. It is casted to default
+/// address space for 

[PATCH] D46926: Conversion between Fixed Point and Floating Point Numbers

2018-05-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr, jakehehrlich.
leonardchan added a project: clang.

This patch has the implementation and tests for converting between fixed point 
and floating point numbers.

The conversion process is simply dividing the fixed point value, as an integer, 
by 2^(# of fractional bits) as a float.

This is a parent of https://reviews.llvm.org/D46925


Repository:
  rC Clang

https://reviews.llvm.org/D46926

Files:
  include/clang/AST/OperationKinds.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaExpr.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Frontend/fixed_point_validation.c

Index: test/Frontend/fixed_point_validation.c
===
--- test/Frontend/fixed_point_validation.c
+++ test/Frontend/fixed_point_validation.c
@@ -30,6 +30,7 @@
 // Run simple validation tests
 
 #define assert(b) if (!(b)) { return 1; }
+#define abs(x) x < 0 ? -x : x
 
 int main(){
   short _Accum s_accum = 0.0hk;
@@ -264,4 +265,18 @@
   assert(5.0hk >> 2 == 1.25hk);
   assert(-5.0hk >> 2 == -1.25k);
   assert(0.0hr >> 2 == 0);
+
+  / Float conversions ***/
+
+  float f = (float)2.5k;
+  assert(f > 2.4999 && f < 2.5001);  // High precision since the fractional value can be evenly
+ // represented.
+  assert((float)2.333hk != 2.333f);
+
+  float base = 2.333f;
+  float saccum_diff = abs(base - 2.333hk);
+  float accum_diff = abs(base - 2.333k);
+  float laccum_diff = abs(base - 2.333lk);
+  assert(accum_diff < saccum_diff);
+  assert(laccum_diff < accum_diff);
 }
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -321,6 +321,7 @@
 const LocationContext *LCtx = Pred->getLocationContext();
 
 switch (CastE->getCastKind()) {
+  case CK_FixedPointToFloating: llvm_unreachable("Unimplemented logic for CK_FixedPointToFloating");
   case CK_IntegralToFixedPoint: llvm_unreachable("ExprEngine::VisitCast CK_IntegralToFixedPoint"); // TODO
   case CK_FixedPointCast: llvm_unreachable("CK_FixedPointCast"); // TODO
   case CK_LValueToRValue:
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -1029,6 +1029,18 @@
   return result;
 }
 
+/// \brief Handle arithmetic conversion from fixed point to floating.  Helper function
+/// of UsualArithmeticConversions()
+static QualType handleFixedPointToFloatConversion(Sema , ExprResult ,
+  ExprResult ,
+  QualType FloatTy, QualType FixedPointTy) {
+  assert(FloatTy->isFloatingType());
+  assert(FixedPointTy->isFixedPointType());
+
+  FixedPointExpr = S.ImpCastExprToType(FixedPointExpr.get(), FloatTy, CK_FixedPointToFloating);
+  return FloatTy;
+}
+
 /// \brief Handle arithmethic conversion with floating point types.  Helper
 /// function of UsualArithmeticConversions()
 static QualType handleFloatConversion(Sema , ExprResult ,
@@ -1057,11 +1069,22 @@
 if (LHSType->isHalfType() && !S.getLangOpts().NativeHalfType)
   LHSType = S.Context.FloatTy;
 
+if (RHSType->isFixedPointType()) {
+  return handleFixedPointToFloatConversion(S, LHS, RHS, LHSType,
+   RHSType);
+}
+
 return handleIntToFloatConversion(S, LHS, RHS, LHSType, RHSType,
   /*convertFloat=*/!IsCompAssign,
   /*convertInt=*/ true);
   }
   assert(RHSFloat);
+
+  if (LHSType->isFixedPointType()) {
+return handleFixedPointToFloatConversion(S, RHS, LHS, RHSType,
+ LHSType);
+  }
+
   return handleIntToFloatConversion(S, RHS, LHS, RHSType, LHSType,
 /*convertInt=*/ true,
 /*convertFloat=*/!IsCompAssign);
@@ -1218,6 +1241,7 @@
   CK_IntegralRealToComplex);
   return ComplexType;
 }
+
 /// \brief Handle arithmetic conversion from integer to fixed point.  Helper function
 /// of UsualArithmeticConversions()
 static QualType handleIntToFixedPointConversion(Sema , ExprResult ,
@@ -6028,7 +6052,14 @@
 }
 llvm_unreachable("Should have returned before this");
 
-  case Type::STK_FixedPoint: llvm_unreachable("Sema::PrepareScalarCast from STK_FixedPoint to anything");  // TODO
+  case Type::STK_FixedPoint: {
+switch 

[PATCH] D46925: Remaining Binary Operations on Primary Fixed Point Types

2018-05-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr, jakehehrlich.
leonardchan added a project: clang.

This patch implements the remaining arithmetic and logical operations on the 
primary fixed point types.

The operations are `+`, `-`, `*`, `/`, `<<`, and `>>`.

  // Addition
   s_accum = 3.0hk;
   short _Accum s_accum_sum = s_accum + s_accum2;
   assert(s_accum_sum == 5);
   assert(s_fract + s_fract2 == 0);
  
   // Subtraction
   short _Accum s_accum_diff = s_accum - s_accum2;
   assert(s_accum_diff == 1);
   assert(s_accum2 - s_accum == -1);
  
   // Multiplication
   short _Accum s_accum_mul = s_accum * s_accum2;
   assert(s_accum_mul == 6);
   assert(2.0hk * 3.0hk == 6);
   assert(2.0hk * 3 == 6);
   assert(2.5hk * 3 == 7.5k);
   assert(-2.5hk * 3 == -7.5lk);
   assert(3 * -2.5hk == -7.5hk);
   assert(-2.5hk * 0 == 0);
  
   // Division
   const short _Accum s_accum3 = 2.5hk;
   short _Accum s_accum_div = s_accum3 / s_accum2;
   assert(s_accum_div == 1.25hk);
   assert(5.0hk / s_accum3 == 2);
   assert(-5.0hk / s_accum3 == -2);
   assert(9.9k / 3.3k == 3);
   assert(9.9hk / 3.3k != 3);  // We lose precision when converting between 
types of different
   // fractional width.
   assert(6.75hk / 2.25k == 3);  // Unless the fractional part can be evenly 
represented with
 // sums of powers of 2.
   assert(0 / 2.0hk == 0);

`%` is not a valod operation on fixed point types.

This is the parent of https://reviews.llvm.org/D46917


Repository:
  rC Clang

https://reviews.llvm.org/D46925

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/OperationKinds.def
  include/clang/AST/Type.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/Type.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Sema/SemaExpr.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Frontend/fixed_point_validation.c

Index: test/Frontend/fixed_point_validation.c
===
--- test/Frontend/fixed_point_validation.c
+++ test/Frontend/fixed_point_validation.c
@@ -1,5 +1,5 @@
-// RUN: %clang -S -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -S -emit-llvm -o - %s | lli
+// RUN: %clang -S -emit-llvm %s -o - | FileCheck %s
 
 // The first test checks the emitted llvm IR.
 // The second test checks the output.
@@ -74,6 +74,9 @@
   assert(2 == s_accum);
   // CHECK:  {{.*}} = icmp eq i16 256, {{.*}}
 
+  assert(2 == 2.0hk);
+  assert(2 != 2.01hk);
+
   int x = 2;
   assert(s_accum == x);
   // CHECK:  {{.*}} = load i32, i32* %x, align 4
@@ -128,6 +131,46 @@
   // numbers.
   assert(2 == 2.001hk);  // This is valid if SACCUM_FBITS == 7
 
+  // Comparisons between fixed-point types
+  // Signed _Accum to signed _Accum types.
+  assert(2.5hk == 2.5k);
+  assert(2.5k == 2.5lk);
+  assert(-2.5hk == -2.5k);
+  assert(-2.5k == -2.5lk);
+
+  // Unsigned _Accum to unigned _Accum
+  assert(2.5uhk == 2.5uk);
+  assert(2.5uk == 2.5ulk);
+
+  // Signed _Fract to signed _Fract types.
+  assert(0.333hr != 0.333r);  // Loss of precision since different fractional widths
+  assert(0.333r != 0.333lr);
+  assert(-0.333hr != -0.333r);
+  assert(-0.333r != -0.333lr);
+
+  // Unsigned _Fract to unsigned _Fract types.
+  assert(0.333uhr != 0.333ur);
+  assert(0.333ur != 0.333ulr);
+
+  // Signed _Accum to signed _Fract
+  assert(0.333hk == 0.333hr);
+  assert(0.333k == 0.333r);
+  assert(0.333lk == 0.333lr);
+  assert(0.333hk == 0.333r);  // Although _Fract has higher precision, it gets casted up to
+  // short _Accum which (using default precisions)
+  // has fewer fractional bits.
+
+  // Signed _Accum to unsigned _Fract
+  assert(0.333hk == 0.333uhr);
+  assert(0.333k == 0.333ur);
+  assert(0.333lk == 0.333ulr);
+
+  // Signed _Accum to unsigned _Accum
+  assert(2.5hk == 2.5uhk);
+  assert(2.5k == 2.5uk);
+  assert(2.5lk == 2.5ulk);
+
+
   / Unary operations ***/
 
   s_accum = 0.0hk;
@@ -167,4 +210,58 @@
   assert(+s_fract == s_fract);
   assert(+s_fract2 == s_fract2);  // s_fract2 is negative
   assert(-s_fract == s_fract2);
+
+  / Binary operations ***/
+
+  // Addition
+  s_accum = 3.0hk;
+  short _Accum s_accum_sum = s_accum + s_accum2;
+  assert(s_accum_sum == 5);
+  assert(s_fract + s_fract2 == 0);
+
+  // Subtraction
+  short _Accum s_accum_diff = s_accum - s_accum2;
+  assert(s_accum_diff == 1);
+  assert(s_accum2 - s_accum == -1);
+
+  // Multiplication
+  short _Accum s_accum_mul = s_accum * s_accum2;
+  assert(s_accum_mul == 6);
+  assert(2.0hk * 3.0hk == 6);
+  assert(2.0hk * 3 == 6);
+  assert(2.5hk * 3 == 7.5k);
+  assert(-2.5hk * 3 == -7.5lk);
+  assert(3 * -2.5hk == -7.5hk);
+  assert(-2.5hk * 

[PATCH] D46881: [X86][CET] Changing -fcf-protection behavior to comply with gcc (clang part)

2018-05-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D46881



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


[PATCH] D46919: [libclang] Deprecate CXPrintingPolicy_IncludeTagDefinition

2018-05-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

The deprecated enumerator is also referenced by 
`tools/c-index-test/c-index-test.c`

This looks fine to me, but let's leave this review thread open for a week or 
so, to give people a bit more time to object in case they're using the flag for 
something.




Comment at: include/clang/AST/PrettyPrinter.h:97-99
+  /// This flag is deprecated and no longer has any effect.
+  bool IncludeTagDefinition : 1;
+

There's no need to keep this around. We have no API stability guarantees for 
our C++ API.



Comment at: include/clang/AST/PrettyPrinter.h:100-108
+  /// When true, print any tag declaration owned by an elaborated type.
   ///
-  /// This is used to place the definition of a struct
-  /// in the middle of another declaration as with:
+  /// This is used to faithfully print the exact tag declaration that appears
+  /// within another declaration.  For example:
   ///
   /// \code
+  /// typedef struct T { int x, y; } Point;

Please explicitly mark this as being transient state that's internal to the 
printing algorithm and not part of its external configuration, so that people 
don't try to expose it again in the future. The same is true for a bunch of the 
other flags around here -- if we're going to do this, we should systematically 
examine these flags to see which ones are external configuration and which ones 
are internal state that we're (hackily) passing between printing steps via the 
`PrintingPolicy`. It would also make sense to move the internal state flags to 
a separate struct from the policy.


https://reviews.llvm.org/D46919



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


[PATCH] D40864: [Darwin] Add a new -mstack-probe option and enable by default

2018-05-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Did this eventually go in?


Repository:
  rC Clang

https://reviews.llvm.org/D40864



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


Re: r332286 - PR37450: Fix bug that disabled some type checks for variables with deduced types.

2018-05-15 Thread Richard Smith via cfe-commits
Should be fixed in r332425. Apologies for the delay addressing this.

On 15 May 2018 at 18:10, Richard Smith  wrote:

> Sorry for the delay, looking now.
>
> On 15 May 2018 at 02:24, Maxim Kuvyrkov  wrote:
>
>> Hi Richard,
>>
>> The for-range-examples.cpp test fails on 32-bit arm buildbots, e.g.:
>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/840 .
>> Would you please investigate?
>>
>> You didn't get a notification because your commit was around the same
>> time as a fix for an unrelated testcase issue that caused same bots to be
>> red.
>>
>> --
>> Maxim Kuvyrkov
>> www.linaro.org
>>
>>
>>
>> > On May 14, 2018, at 11:15 PM, Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>> >
>> > Author: rsmith
>> > Date: Mon May 14 13:15:04 2018
>> > New Revision: 332286
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=332286=rev
>> > Log:
>> > PR37450: Fix bug that disabled some type checks for variables with
>> deduced types.
>> >
>> > Also improve diagnostic for the case where a type is non-literal
>> because it's a lambda.
>> >
>> > Modified:
>> >cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> >cfe/trunk/lib/Sema/SemaDecl.cpp
>> >cfe/trunk/lib/Sema/SemaType.cpp
>> >cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp
>> >cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
>> >cfe/trunk/test/SemaCXX/for-range-examples.cpp
>> >
>> > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/DiagnosticSemaKinds.td?rev=332286=332285=332286=diff
>> > 
>> ==
>> > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon May 14
>> 13:15:04 2018
>> > @@ -2381,6 +2381,8 @@ def note_non_literal_user_provided_dtor
>> >   "%0 is not literal because it has a user-provided destructor">;
>> > def note_non_literal_nontrivial_dtor : Note<
>> >   "%0 is not literal because it has a non-trivial destructor">;
>> > +def note_non_literal_lambda : Note<
>> > +  "lambda closure types are non-literal types before C++17">;
>> > def warn_private_extern : Warning<
>> >   "use of __private_extern__ on a declaration may not produce external
>> symbol "
>> >   "private to the linkage unit and is deprecated">,
>> InGroup;
>> >
>> > Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
>> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaD
>> ecl.cpp?rev=332286=332285=332286=diff
>> > 
>> ==
>> > --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
>> > +++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon May 14 13:15:04 2018
>> > @@ -7293,8 +7293,7 @@ void Sema::CheckVariableDeclarationType(
>> >   if (NewVD->isInvalidDecl())
>> > return;
>> >
>> > -  TypeSourceInfo *TInfo = NewVD->getTypeSourceInfo();
>> > -  QualType T = TInfo->getType();
>> > +  QualType T = NewVD->getType();
>> >
>> >   // Defer checking an 'auto' type until its initializer is attached.
>> >   if (T->isUndeducedType())
>> > @@ -7438,10 +7437,18 @@ void Sema::CheckVariableDeclarationType(
>> >   (T->isVariableArrayType() && NewVD->hasGlobalStorage())) {
>> > bool SizeIsNegative;
>> > llvm::APSInt Oversized;
>> > -TypeSourceInfo *FixedTInfo =
>> > -  TryToFixInvalidVariablyModifiedTypeSourceInfo(TInfo, Context,
>> > -SizeIsNegative,
>> Oversized);
>> > -if (!FixedTInfo && T->isVariableArrayType()) {
>> > +TypeSourceInfo *FixedTInfo = TryToFixInvalidVariablyModifie
>> dTypeSourceInfo(
>> > +NewVD->getTypeSourceInfo(), Context, SizeIsNegative,
>> Oversized);
>> > +QualType FixedT;
>> > +if (FixedTInfo &&  T == NewVD->getTypeSourceInfo()->getType())
>> > +  FixedT = FixedTInfo->getType();
>> > +else if (FixedTInfo) {
>> > +  // Type and type-as-written are canonically different. We need
>> to fix up
>> > +  // both types separately.
>> > +  FixedT = TryToFixInvalidVariablyModifiedType(T, Context,
>> SizeIsNegative,
>> > +   Oversized);
>> > +}
>> > +if ((!FixedTInfo || FixedT.isNull()) && T->isVariableArrayType()) {
>> >   const VariableArrayType *VAT = Context.getAsVariableArrayType(T);
>> >   // FIXME: This won't give the correct result for
>> >   // int a[10][n];
>> > @@ -7470,7 +7477,7 @@ void Sema::CheckVariableDeclarationType(
>> > }
>> >
>> > Diag(NewVD->getLocation(), diag::warn_illegal_constant_array_size);
>> > -NewVD->setType(FixedTInfo->getType());
>> > +NewVD->setType(FixedT);
>> > NewVD->setTypeSourceInfo(FixedTInfo);
>> >   }
>> >
>> >
>> > Modified: cfe/trunk/lib/Sema/SemaType.cpp
>> > URL: 

r332425 - Fix 32-bit buildbots.

2018-05-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue May 15 18:08:07 2018
New Revision: 332425

URL: http://llvm.org/viewvc/llvm-project?rev=332425=rev
Log:
Fix 32-bit buildbots.

Modified:
cfe/trunk/test/SemaCXX/for-range-examples.cpp

Modified: cfe/trunk/test/SemaCXX/for-range-examples.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/for-range-examples.cpp?rev=332425=332424=332425=diff
==
--- cfe/trunk/test/SemaCXX/for-range-examples.cpp (original)
+++ cfe/trunk/test/SemaCXX/for-range-examples.cpp Tue May 15 18:08:07 2018
@@ -221,7 +221,7 @@ namespace test7 {
 for (c alignas(8) : arr) { // expected-error {{requires type for loop 
variable}}
   static_assert(alignof(c) == 8, ""); // expected-warning {{extension}}
 }
-for (d alignas(1) : arr) {} // expected-error {{requested alignment is 
less than minimum alignment of 8 for type 'int &'}} expected-error {{requires 
type for loop variable}}
+for (d alignas(1) : arr) {} // expected-error {{requested alignment is 
less than minimum}} expected-error {{requires type for loop variable}}
 for (e [[deprecated]] : arr) { e = 0; } // expected-warning {{deprecated}} 
expected-note {{here}} expected-error {{requires type for loop variable}}
   }
 }


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


Re: r332286 - PR37450: Fix bug that disabled some type checks for variables with deduced types.

2018-05-15 Thread Richard Smith via cfe-commits
Sorry for the delay, looking now.

On 15 May 2018 at 02:24, Maxim Kuvyrkov  wrote:

> Hi Richard,
>
> The for-range-examples.cpp test fails on 32-bit arm buildbots, e.g.:
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/840 .
> Would you please investigate?
>
> You didn't get a notification because your commit was around the same time
> as a fix for an unrelated testcase issue that caused same bots to be red.
>
> --
> Maxim Kuvyrkov
> www.linaro.org
>
>
>
> > On May 14, 2018, at 11:15 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> > Author: rsmith
> > Date: Mon May 14 13:15:04 2018
> > New Revision: 332286
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=332286=rev
> > Log:
> > PR37450: Fix bug that disabled some type checks for variables with
> deduced types.
> >
> > Also improve diagnostic for the case where a type is non-literal because
> it's a lambda.
> >
> > Modified:
> >cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> >cfe/trunk/lib/Sema/SemaDecl.cpp
> >cfe/trunk/lib/Sema/SemaType.cpp
> >cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp
> >cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
> >cfe/trunk/test/SemaCXX/for-range-examples.cpp
> >
> > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=332286=332285=332286=diff
> > 
> ==
> > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon May 14
> 13:15:04 2018
> > @@ -2381,6 +2381,8 @@ def note_non_literal_user_provided_dtor
> >   "%0 is not literal because it has a user-provided destructor">;
> > def note_non_literal_nontrivial_dtor : Note<
> >   "%0 is not literal because it has a non-trivial destructor">;
> > +def note_non_literal_lambda : Note<
> > +  "lambda closure types are non-literal types before C++17">;
> > def warn_private_extern : Warning<
> >   "use of __private_extern__ on a declaration may not produce external
> symbol "
> >   "private to the linkage unit and is deprecated">,
> InGroup;
> >
> > Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaDecl.cpp?rev=332286=332285=332286=diff
> > 
> ==
> > --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon May 14 13:15:04 2018
> > @@ -7293,8 +7293,7 @@ void Sema::CheckVariableDeclarationType(
> >   if (NewVD->isInvalidDecl())
> > return;
> >
> > -  TypeSourceInfo *TInfo = NewVD->getTypeSourceInfo();
> > -  QualType T = TInfo->getType();
> > +  QualType T = NewVD->getType();
> >
> >   // Defer checking an 'auto' type until its initializer is attached.
> >   if (T->isUndeducedType())
> > @@ -7438,10 +7437,18 @@ void Sema::CheckVariableDeclarationType(
> >   (T->isVariableArrayType() && NewVD->hasGlobalStorage())) {
> > bool SizeIsNegative;
> > llvm::APSInt Oversized;
> > -TypeSourceInfo *FixedTInfo =
> > -  TryToFixInvalidVariablyModifiedTypeSourceInfo(TInfo, Context,
> > -SizeIsNegative,
> Oversized);
> > -if (!FixedTInfo && T->isVariableArrayType()) {
> > +TypeSourceInfo *FixedTInfo = TryToFixInvalidVariablyModifie
> dTypeSourceInfo(
> > +NewVD->getTypeSourceInfo(), Context, SizeIsNegative, Oversized);
> > +QualType FixedT;
> > +if (FixedTInfo &&  T == NewVD->getTypeSourceInfo()->getType())
> > +  FixedT = FixedTInfo->getType();
> > +else if (FixedTInfo) {
> > +  // Type and type-as-written are canonically different. We need to
> fix up
> > +  // both types separately.
> > +  FixedT = TryToFixInvalidVariablyModifiedType(T, Context,
> SizeIsNegative,
> > +   Oversized);
> > +}
> > +if ((!FixedTInfo || FixedT.isNull()) && T->isVariableArrayType()) {
> >   const VariableArrayType *VAT = Context.getAsVariableArrayType(T);
> >   // FIXME: This won't give the correct result for
> >   // int a[10][n];
> > @@ -7470,7 +7477,7 @@ void Sema::CheckVariableDeclarationType(
> > }
> >
> > Diag(NewVD->getLocation(), diag::warn_illegal_constant_array_size);
> > -NewVD->setType(FixedTInfo->getType());
> > +NewVD->setType(FixedT);
> > NewVD->setTypeSourceInfo(FixedTInfo);
> >   }
> >
> >
> > Modified: cfe/trunk/lib/Sema/SemaType.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaType.cpp?rev=332286=332285=332286=diff
> > 
> ==
> > --- cfe/trunk/lib/Sema/SemaType.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaType.cpp Mon May 14 13:15:04 2018
> > @@ 

[PATCH] D46791: Make -gsplit-dwarf generally available

2018-05-15 Thread Tom Rix via Phabricator via cfe-commits
trixirt updated this revision to Diff 146970.
trixirt added a comment.

Improve comment in CLANG_DEFAULT_OBJCOPY to specify what is required of objcopy.
Remove the llvm- prefix from testing to allow for override of default value.


https://reviews.llvm.org/D46791

Files:
  CMakeLists.txt
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/FreeBSD.cpp
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/split-debug.c
  test/Driver/split-debug.s

Index: test/Driver/split-debug.s
===
--- test/Driver/split-debug.s
+++ test/Driver/split-debug.s
@@ -6,12 +6,17 @@
 // CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
 // CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
 
+// RUN: %clang -target x86_64-unknown-freebsd11.0 -gsplit-dwarf -c -### %s 2> %t
+// RUN: FileCheck -check-prefix=FREEBSD-CHECK-ACTIONS < %t %s
+//
+// FREEBSD-CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
+// FREEBSD-CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
 
 // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t
-// RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s
+// RUN: FileCheck -check-prefix=MACOSX-CHECK-ACTIONS < %t %s
 //
-// CHECK-NO-ACTIONS-NOT: -split-dwarf
-
+// MACOSX-CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
+// MACOSX-CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -o Bad.x -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-BAD < %t %s
Index: test/Driver/split-debug.c
===
--- test/Driver/split-debug.c
+++ test/Driver/split-debug.c
@@ -1,17 +1,31 @@
 // Check that we split debug output properly
 //
+// Linux
 // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s
 //
 // CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
 // CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
 
+// FreeBSD
+// RUN: %clang -fno-integrated-as -target x86_64-unknown-freebsd11.0 -gsplit-dwarf -c -### %s 2> %t
+// RUN: FileCheck -check-prefix=FREEBSD-NOIA-CHECK-ACTIONS < %t %s
+//
+// FREEBSD-NOIA-CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
+// FREEBSD-NOIA-CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
+//
+// RUN: %clang -fintegrated-as -target x86_64-unknown-freebsd11.0 -gsplit-dwarf -c -### %s 2> %t
+// RUN: FileCheck -check-prefix=FREEBSD-IA-CHECK-ACTIONS < %t %s
+//
+// FREEBSD-IA-CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
+// FREEBSD-IA-CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
 
+// Macosx
 // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t
-// RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s
+// RUN: FileCheck -check-prefix=MACOSX-CHECK-ACTIONS < %t %s
 //
-// CHECK-NO-ACTIONS-NOT: -split-dwarf
-
+// MACOSX-CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
+// MACOSX-CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -o Bad.x -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-BAD < %t %s
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -784,9 +784,7 @@
 
   // Handle the debug info splitting at object creation time if we're
   // creating an object.
-  // TODO: Currently only works on linux with newer objcopy.
-  if (Args.hasArg(options::OPT_gsplit_dwarf) &&
-  getToolChain().getTriple().isOSLinux())
+  if (Args.hasArg(options::OPT_gsplit_dwarf))
 SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
SplitDebugName(Args, Inputs[0]));
 }
Index: lib/Driver/ToolChains/FreeBSD.cpp
===
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -115,6 +115,12 @@
 
   const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
+
+  // Handle the debug info splitting at object creation time if we're
+  // creating an object.
+  if (Args.hasArg(options::OPT_gsplit_dwarf))
+SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
+   SplitDebugName(Args, Inputs[0]));
 }
 
 void freebsd::Linker::ConstructJob(Compilation , const JobAction ,
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3020,16 +3020,13 @@
 
   // -gsplit-dwarf should turn on -g and enable the backend dwarf
   // splitting and extraction.
-  // FIXME: Currently only works on Linux.
-  if (T.isOSLinux()) {
-if 

[PATCH] D46891: [StaticAnalyzer] Added a getLValue method to ProgramState for bases

2018-05-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:732
+   const SubRegion *Super) const {
+  const auto Base = BaseSpec.getType()->getAsCXXRecordDecl();
+  return loc::MemRegionVal(

I think you wanted to say `const auto *` here. It's not really important that 
the local variable is const, but that the pointer points to const.


Repository:
  rC Clang

https://reviews.llvm.org/D46891



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


[PATCH] D46891: [StaticAnalyzer] Added a getLValue method to ProgramState for bases

2018-05-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Looks good, thanks! Yeah, seems that these were accidentally omitted.

You may want to add the `const CXXRecordDecl *` variant as well.


Repository:
  rC Clang

https://reviews.llvm.org/D46891



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


r332422 - [analyzer] Do not crash on callback for call_once passed by value

2018-05-15 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue May 15 17:29:13 2018
New Revision: 332422

URL: http://llvm.org/viewvc/llvm-project?rev=332422=rev
Log:
[analyzer] Do not crash on callback for call_once passed by value

https://bugs.llvm.org/show_bug.cgi?id=37312
rdar://40270582

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

Modified:
cfe/trunk/lib/Analysis/BodyFarm.cpp
cfe/trunk/test/Analysis/call_once.cpp

Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=332422=332421=332422=diff
==
--- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp Tue May 15 17:29:13 2018
@@ -254,21 +254,24 @@ static CallExpr *create_call_once_funcpt
 
   QualType Ty = Callback->getType();
   DeclRefExpr *Call = M.makeDeclRefExpr(Callback);
-  CastKind CK;
+  Expr *SubExpr;
   if (Ty->isRValueReferenceType()) {
-CK = CK_LValueToRValue;
-  } else {
-assert(Ty->isLValueReferenceType());
-CK = CK_FunctionToPointerDecay;
+SubExpr = M.makeImplicitCast(
+Call, Ty.getNonReferenceType(), CK_LValueToRValue);
+  } else if (Ty->isLValueReferenceType() &&
+ Call->getType()->isFunctionType()) {
 Ty = C.getPointerType(Ty.getNonReferenceType());
+SubExpr = M.makeImplicitCast(Call, Ty, CK_FunctionToPointerDecay);
+  } else if (Ty->isLValueReferenceType()
+ && Call->getType()->isPointerType()
+ && Call->getType()->getPointeeType()->isFunctionType()){
+SubExpr = Call;
+  } else {
+llvm_unreachable("Unexpected state");
   }
 
   return new (C)
-  CallExpr(C, M.makeImplicitCast(Call, Ty.getNonReferenceType(), CK),
-   /*args=*/CallArgs,
-   /*QualType=*/C.VoidTy,
-   /*ExprValueType=*/VK_RValue,
-   /*SourceLocation=*/SourceLocation());
+  CallExpr(C, SubExpr, CallArgs, C.VoidTy, VK_RValue, SourceLocation());
 }
 
 static CallExpr *create_call_once_lambda_call(ASTContext , ASTMaker M,

Modified: cfe/trunk/test/Analysis/call_once.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/call_once.cpp?rev=332422=332421=332422=diff
==
--- cfe/trunk/test/Analysis/call_once.cpp (original)
+++ cfe/trunk/test/Analysis/call_once.cpp Tue May 15 17:29:13 2018
@@ -403,3 +403,12 @@ void callback_with_implicit_cast() {
   std::once_flag flag;
   call_once(flag, callback_taking_func, callback_with_implicit_cast);
 }
+
+std::once_flag another_once_flag;
+typedef void (*my_callback_t)(int *);
+my_callback_t callback;
+int global_int;
+
+void rdar40270582() {
+  call_once(another_once_flag, callback, _int);
+}


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


[PATCH] D46603: [Support] TimerGroup changes

2018-05-15 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

I see four separate changes: s/.sys/mem one (can be committed without review), 
exposing printJSONValues and consequent adding of a lock, adding a constructor 
accepting a map, and fixing formatting in `printJSONValue`. All four look good 
to me, but probably should be reviewed separately.




Comment at: lib/Support/Timer.cpp:385
+  constexpr auto max_digits10 = std::numeric_limits::max_digits10;
+  OS << "\t\"time." << Name << '.' << R.Name << suffix
+ << "\": " << format("%.*e", max_digits10 - 1, Value);

This change seems unrelated to the new constructor accepting map, right?



Comment at: lib/Support/Timer.cpp:405
   OS << delim;
-  printJSONValue(OS, R, ".sys", T.getMemUsed());
+  printJSONValue(OS, R, ".mem", T.getMemUsed());
 }

That's independent from this change, right?


Repository:
  rL LLVM

https://reviews.llvm.org/D46603



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


r332421 - Revert commits r332160, r332164, r332236.

2018-05-15 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Tue May 15 17:27:43 2018
New Revision: 332421

URL: http://llvm.org/viewvc/llvm-project?rev=332421=rev
Log:
Revert commits r332160, r332164, r332236.

It was decided this is the wrong approach to fix this issue.

Removed:
cfe/trunk/test/Driver/clang-abi-compat.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGenCXX/alignment.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=332421=332420=332421=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue May 15 17:27:43 
2018
@@ -150,9 +150,6 @@ def warn_drv_unknown_argument_clang_cl :
 def warn_drv_unknown_argument_clang_cl_with_suggestion : Warning<
   "unknown argument ignored in clang-cl '%0' (did you mean '%1'?)">,
   InGroup;
-def warn_drv_ignored_clang_abi_version : Warning<
-  "target requires clang ABI version %0, ignoring requested version">,
-  InGroup;
 
 def warn_drv_ycyu_no_arg_clang_cl : Warning<
   "support for '%0' without a filename not implemented yet; flag ignored">,

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=332421=332420=332421=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue May 15 17:27:43 2018
@@ -2751,16 +2751,6 @@ static void ParseLangArgs(LangOptions 
   << A->getAsString(Args) << A->getValue();
 }
   }
-  // The PS4 requires version 6 of the clang ABI.
-  if (T.isPS4()) {
-// Issue a warning if another version of the ABI was requested.
-if (Args.getLastArg(OPT_fclang_abi_compat_EQ) &&
-Opts.getClangABICompat() != LangOptions::ClangABI::Ver6) {
-  Diags.Report(diag::warn_drv_ignored_clang_abi_version)
-<< 6;
-}
-Opts.setClangABICompat(LangOptions::ClangABI::Ver6);
-  }
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {

Modified: cfe/trunk/test/CodeGenCXX/alignment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/alignment.cpp?rev=332421=332420=332421=diff
==
--- cfe/trunk/test/CodeGenCXX/alignment.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/alignment.cpp Tue May 15 17:27:43 2018
@@ -1,8 +1,5 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin10 | 
FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOCOMPAT
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin10 
-fclang-abi-compat=6.0 | FileCheck %s --check-prefix=CHECK 
--check-prefix=CHECK-V6COMPAT
-// Check that the PS4 target uses the 6.0 compat settings.
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-scei-ps4 | FileCheck %s 
--check-prefix=CHECK --check-prefix=CHECK-V6COMPAT
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-scei-ps4 
-fclang-abi-compat=latest | FileCheck %s --check-prefix=CHECK 
--check-prefix=CHECK-V6COMPAT
 
 extern int int_source();
 extern void int_sink(int x);

Removed: cfe/trunk/test/Driver/clang-abi-compat.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-abi-compat.cpp?rev=332420=auto
==
--- cfe/trunk/test/Driver/clang-abi-compat.cpp (original)
+++ cfe/trunk/test/Driver/clang-abi-compat.cpp (removed)
@@ -1,8 +0,0 @@
-// PS4 target requires clang ABI version 6, check that a warning is emitted 
when a version other than 6 is requested.
-// RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=4 %s -o 
/dev/null 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
-// RUN: %clang -S --target=x86_64-scei-ps4 -fclang-abi-compat=latest %s -o 
/dev/null 2>&1 | FileCheck %s -check-prefix=CHECK-WARNING
-
-// REQUIRES: x86-registered-target
-
-// CHECK-WARNING: warning: target requires clang ABI version 6, ignoring 
requested version
-


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


[PATCH] D46919: [libclang] Deprecate CXPrintingPolicy_IncludeTagDefinition

2018-05-15 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.
jdenny added a reviewer: rsmith.

And make it have no effect.  Suggested at:

https://reviews.llvm.org/D45463#1096629

I'm not sure of the proper way to deprecate something in libclang.
Let me know if something else is needed.


https://reviews.llvm.org/D46919

Files:
  include/clang-c/Index.h
  include/clang/AST/PrettyPrinter.h
  lib/AST/DeclPrinter.cpp
  lib/AST/TypePrinter.cpp

Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -454,7 +454,7 @@
 OS << '(';
 
   PrintingPolicy InnerPolicy(Policy);
-  InnerPolicy.IncludeTagDefinition = false;
+  InnerPolicy.PrintOwnedTagDecl = false;
   TypePrinter(InnerPolicy).print(QualType(T->getClass(), 0), OS, StringRef());
 
   OS << "::*";
@@ -1054,9 +1054,9 @@
 }
 
 void TypePrinter::printTag(TagDecl *D, raw_ostream ) {
-  if (Policy.IncludeTagDefinition) {
+  if (Policy.PrintOwnedTagDecl) {
 PrintingPolicy SubPolicy = Policy;
-SubPolicy.IncludeTagDefinition = false;
+SubPolicy.PrintOwnedTagDecl = false;
 D->print(OS, SubPolicy, Indentation);
 spaceBeforePlaceHolder(OS);
 return;
@@ -1209,35 +1209,34 @@
 
 void TypePrinter::printElaboratedBefore(const ElaboratedType *T,
 raw_ostream ) {
-  if (Policy.IncludeTagDefinition && T->getOwnedTagDecl()) {
+  if (Policy.PrintOwnedTagDecl && T->getOwnedTagDecl()) {
 TagDecl *OwnedTagDecl = T->getOwnedTagDecl();
 assert(OwnedTagDecl->getTypeForDecl() == T->getNamedType().getTypePtr() &&
"OwnedTagDecl expected to be a declaration for the type");
 PrintingPolicy SubPolicy = Policy;
-SubPolicy.IncludeTagDefinition = false;
+SubPolicy.PrintOwnedTagDecl = false;
 OwnedTagDecl->print(OS, SubPolicy, Indentation);
 spaceBeforePlaceHolder(OS);
 return;
   }
 
   // The tag definition will take care of these.
-  if (!Policy.IncludeTagDefinition)
-  {
+  if (!Policy.PrintOwnedTagDecl) {
 OS << TypeWithKeyword::getKeywordName(T->getKeyword());
 if (T->getKeyword() != ETK_None)
   OS << " ";
 NestedNameSpecifier *Qualifier = T->getQualifier();
 if (Qualifier)
   Qualifier->print(OS, Policy);
   }
-  
+
   ElaboratedTypePolicyRAII PolicyRAII(Policy);
   printBefore(T->getNamedType(), OS);
 }
 
 void TypePrinter::printElaboratedAfter(const ElaboratedType *T,
 raw_ostream ) {
-  if (Policy.IncludeTagDefinition && T->getOwnedTagDecl())
+  if (Policy.PrintOwnedTagDecl && T->getOwnedTagDecl())
 return;
   ElaboratedTypePolicyRAII PolicyRAII(Policy);
   printAfter(T->getNamedType(), OS);
Index: lib/AST/DeclPrinter.cpp
===
--- lib/AST/DeclPrinter.cpp
+++ lib/AST/DeclPrinter.cpp
@@ -178,12 +178,12 @@
   for ( ; Begin != End; ++Begin) {
 if (isFirst) {
   if(TD)
-SubPolicy.IncludeTagDefinition = true;
+SubPolicy.PrintOwnedTagDecl = true;
   SubPolicy.SuppressSpecifiers = false;
   isFirst = false;
 } else {
   if (!isFirst) Out << ", ";
-  SubPolicy.IncludeTagDefinition = false;
+  SubPolicy.PrintOwnedTagDecl = false;
   SubPolicy.SuppressSpecifiers = true;
 }
 
@@ -849,7 +849,7 @@
   }
   PrintingPolicy SubPolicy(Policy);
   SubPolicy.SuppressSpecifiers = false;
-  SubPolicy.IncludeTagDefinition = false;
+  SubPolicy.PrintOwnedTagDecl = false;
   Init->printPretty(Out, nullptr, SubPolicy, Indentation);
   if ((D->getInitStyle() == VarDecl::CallInit) && !isa(Init))
 Out << ")";
Index: include/clang/AST/PrettyPrinter.h
===
--- include/clang/AST/PrettyPrinter.h
+++ include/clang/AST/PrettyPrinter.h
@@ -40,7 +40,8 @@
   PrintingPolicy(const LangOptions )
 : Indentation(2), SuppressSpecifiers(false),
   SuppressTagKeyword(LO.CPlusPlus),
-  IncludeTagDefinition(false), SuppressScope(false),
+  IncludeTagDefinition(false), PrintOwnedTagDecl(false),
+  SuppressScope(false),
   SuppressUnwrittenScope(false), SuppressInitializers(false),
   ConstantArraySizeAsWritten(false), AnonymousTagLocations(true),
   SuppressStrongLifetime(false), SuppressLifetimeQualifiers(false),
@@ -93,15 +94,18 @@
   /// \endcode
   bool SuppressTagKeyword : 1;
 
-  /// When true, include the body of a tag definition.
+  /// This flag is deprecated and no longer has any effect.
+  bool IncludeTagDefinition : 1;
+
+  /// When true, print any tag declaration owned by an elaborated type.
   ///
-  /// This is used to place the definition of a struct
-  /// in the middle of another declaration as with:
+  /// This is used to faithfully print the exact tag declaration that appears
+  /// within another declaration.  For example:
   ///
   /// \code
-  /// typedef struct { int x, y; } Point;
+  /// typedef struct T { int x, y; 

[PATCH] D46902: [analyzer] Make plist-html multi-file.

2018-05-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332417: [analyzer] Make plist-html diagnostic consumer 
produce multi-file reports. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46902?vs=146902=146966#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46902

Files:
  cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  cfe/trunk/test/Analysis/diagnostics/plist-multi-file.c
  cfe/trunk/test/Analysis/diagnostics/plist-multi-file.h

Index: cfe/trunk/test/Analysis/diagnostics/plist-multi-file.c
===
--- cfe/trunk/test/Analysis/diagnostics/plist-multi-file.c
+++ cfe/trunk/test/Analysis/diagnostics/plist-multi-file.c
@@ -0,0 +1,205 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-html -o %t.plist -verify %s
+// RUN: FileCheck --input-file=%t.plist %s
+
+#include "plist-multi-file.h"
+
+void bar() {
+  foo(0);
+}
+
+// CHECK: diagnostics
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   path
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: kindevent
+// CHECK-NEXT: location
+// CHECK-NEXT: 
+// CHECK-NEXT:  line7
+// CHECK-NEXT:  col7
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: ranges
+// CHECK-NEXT: 
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: line7
+// CHECK-NEXT: col7
+// CHECK-NEXT: file0
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: line7
+// CHECK-NEXT: col7
+// CHECK-NEXT: file0
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: depth0
+// CHECK-NEXT: extended_message
+// CHECK-NEXT: Passing null pointer value via 1st parameter ptr
+// CHECK-NEXT: message
+// CHECK-NEXT: Passing null pointer value via 1st parameter ptr
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindevent
+// CHECK-NEXT: location
+// CHECK-NEXT: 
+// CHECK-NEXT:  line7
+// CHECK-NEXT:  col3
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: ranges
+// CHECK-NEXT: 
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: line7
+// CHECK-NEXT: col3
+// CHECK-NEXT: file0
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: line7
+// CHECK-NEXT: col8
+// CHECK-NEXT: file0
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: depth0
+// CHECK-NEXT: extended_message
+// CHECK-NEXT: Calling foo
+// CHECK-NEXT: message
+// CHECK-NEXT: Calling foo
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindevent
+// CHECK-NEXT: location
+// CHECK-NEXT: 
+// CHECK-NEXT:  line1
+// CHECK-NEXT:  col1
+// CHECK-NEXT:  file1
+// CHECK-NEXT: 
+// CHECK-NEXT: depth1
+// CHECK-NEXT: extended_message
+// CHECK-NEXT: Entered call from bar
+// CHECK-NEXT: message
+// CHECK-NEXT: Entered call from bar
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindcontrol
+// CHECK-NEXT: edges
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:start
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line1
+// CHECK-NEXT:   col1
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line1
+// CHECK-NEXT:   col4
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:end
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line2
+// CHECK-NEXT:   col3
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line2
+// CHECK-NEXT:   col3
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindcontrol
+// CHECK-NEXT: edges
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:start
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line2
+// CHECK-NEXT:   col3
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line2
+// CHECK-NEXT:   col3
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:end
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line2
+// CHECK-NEXT:   col8
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line2
+// CHECK-NEXT:   col8
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:   
+// CHECK-NEXT:   

r332417 - [analyzer] Make plist-html diagnostic consumer produce multi-file reports.

2018-05-15 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue May 15 17:11:24 2018
New Revision: 332417

URL: http://llvm.org/viewvc/llvm-project?rev=332417=rev
Log:
[analyzer] Make plist-html diagnostic consumer produce multi-file reports.

Previously plist-html output produced multi-file HTML reports
but only single-file Plist reports.

Change plist-html output to produce multi-file Plist reports as well.

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

Added:
cfe/trunk/test/Analysis/diagnostics/plist-multi-file.c
cfe/trunk/test/Analysis/diagnostics/plist-multi-file.h
Modified:
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=332417=332416=332417=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Tue May 15 
17:11:24 2018
@@ -73,7 +73,7 @@ void ento::createPlistHTMLDiagnosticCons
  const Preprocessor ) {
   createHTMLDiagnosticConsumer(AnalyzerOpts, C,
llvm::sys::path::parent_path(prefix), PP);
-  createPlistDiagnosticConsumer(AnalyzerOpts, C, prefix, PP);
+  createPlistMultiFileDiagnosticConsumer(AnalyzerOpts, C, prefix, PP);
 }
 
 void ento::createTextPathDiagnosticConsumer(AnalyzerOptions ,

Added: cfe/trunk/test/Analysis/diagnostics/plist-multi-file.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/plist-multi-file.c?rev=332417=auto
==
--- cfe/trunk/test/Analysis/diagnostics/plist-multi-file.c (added)
+++ cfe/trunk/test/Analysis/diagnostics/plist-multi-file.c Tue May 15 17:11:24 
2018
@@ -0,0 +1,205 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-html 
-o %t.plist -verify %s
+// RUN: FileCheck --input-file=%t.plist %s
+
+#include "plist-multi-file.h"
+
+void bar() {
+  foo(0);
+}
+
+// CHECK: diagnostics
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   path
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: kindevent
+// CHECK-NEXT: location
+// CHECK-NEXT: 
+// CHECK-NEXT:  line7
+// CHECK-NEXT:  col7
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: ranges
+// CHECK-NEXT: 
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: line7
+// CHECK-NEXT: col7
+// CHECK-NEXT: file0
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: line7
+// CHECK-NEXT: col7
+// CHECK-NEXT: file0
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: depth0
+// CHECK-NEXT: extended_message
+// CHECK-NEXT: Passing null pointer value via 1st parameter 
ptr
+// CHECK-NEXT: message
+// CHECK-NEXT: Passing null pointer value via 1st parameter 
ptr
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindevent
+// CHECK-NEXT: location
+// CHECK-NEXT: 
+// CHECK-NEXT:  line7
+// CHECK-NEXT:  col3
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: ranges
+// CHECK-NEXT: 
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: line7
+// CHECK-NEXT: col3
+// CHECK-NEXT: file0
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: line7
+// CHECK-NEXT: col8
+// CHECK-NEXT: file0
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: depth0
+// CHECK-NEXT: extended_message
+// CHECK-NEXT: Calling foo
+// CHECK-NEXT: message
+// CHECK-NEXT: Calling foo
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindevent
+// CHECK-NEXT: location
+// CHECK-NEXT: 
+// CHECK-NEXT:  line1
+// CHECK-NEXT:  col1
+// CHECK-NEXT:  file1
+// CHECK-NEXT: 
+// CHECK-NEXT: depth1
+// CHECK-NEXT: extended_message
+// CHECK-NEXT: Entered call from bar
+// CHECK-NEXT: message
+// CHECK-NEXT: Entered call from bar
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindcontrol
+// CHECK-NEXT: edges
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:start
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line1
+// CHECK-NEXT:   col1
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line1
+// CHECK-NEXT:   col4
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:end
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line2
+// CHECK-NEXT:   col3
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// 

[PATCH] D46902: [analyzer] Make plist-html multi-file.

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

LGTM! with stable-filename option we could even avoid the regexp.


Repository:
  rC Clang

https://reviews.llvm.org/D46902



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


[PATCH] D46918: [Coverage] Discard the last uncompleted deferred region in a decl

2018-05-15 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.
vsk added a reviewer: arphaman.

Discard the last uncompleted deferred region in a decl, if one exists.
This prevents lines at the end of a function containing only whitespace
or closing braces from being marked as uncovered, if they follow a
region terminator (return/break/etc).

The previous behavior was to heuristically complete deferred regions at
the end of a decl. In practice this ended up being too brittle for too
little gain. Users would complain that there was no way to reach full
code coverage because whitespace at the end of a function would be
marked uncovered.

rdar://40238228


https://reviews.llvm.org/D46918

Files:
  lib/CodeGen/CoverageMappingGen.cpp
  test/CoverageMapping/deferred-region.cpp
  test/CoverageMapping/label.cpp
  test/CoverageMapping/moremacros.c
  test/CoverageMapping/trycatch.cpp

Index: test/CoverageMapping/trycatch.cpp
===
--- test/CoverageMapping/trycatch.cpp
+++ test/CoverageMapping/trycatch.cpp
@@ -18,7 +18,7 @@
   // CHECK: File 0, [[@LINE+1]]:10 -> [[@LINE+2]]:27 = (#0 - #1)
   } else if(i == 8)   // CHECK-NEXT: File 0, [[@LINE]]:13 -> [[@LINE]]:19 = (#0 - #1)
 throw ImportantError();   // CHECK: File 0, [[@LINE]]:5 -> [[@LINE]]:27 = #2
-} // CHECK-NEXT: File 0, [[@LINE-1]]:27 -> [[@LINE]]:2 = ((#0 - #1) - #2)
+}
 
   // CHECK-NEXT: main
 int main() {  // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+13]]:2 = #0
Index: test/CoverageMapping/moremacros.c
===
--- test/CoverageMapping/moremacros.c
+++ test/CoverageMapping/moremacros.c
@@ -31,7 +31,7 @@
   if (!argc) {
 return 0;
   // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:8 = #4
-  RBRAC // CHECK-NEXT: [[@LINE]]:8 -> [[@LINE+1]]:2 = (((#0 - #2) - #3) - #4)
+  RBRAC
 }
 
 // CHECK-NEXT: File 1, 3:15 -> 3:16 = #2
Index: test/CoverageMapping/label.cpp
===
--- test/CoverageMapping/label.cpp
+++ test/CoverageMapping/label.cpp
@@ -16,19 +16,18 @@
   goto x;// CHECK: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = (#1 - #2)
 int k = 3;   // CHECK-NEXT: File 0, [[@LINE-1]]:13 -> [[@LINE]]:5 = #3
   }  // CHECK-NEXT: File 0, [[@LINE-1]]:5 -> [[@LINE]]:4 = #3
-  static int j = 0;  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+5]]:2 = ((#0 + #3) - #1)
+  static int j = 0;  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+4]]:2 = ((#0 + #3) - #1)
   ++j;
   if(j == 1) // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE]]:12 = ((#0 + #3) - #1)
 goto x;  // CHECK: File 0, [[@LINE]]:5 -> [[@LINE]]:11 = #4
- // CHECK-NEXT: File 0, [[@LINE-1]]:11 -> [[@LINE+1]]:2 = (((#0 + #3) - #1) - #4)
 }
 
  // CHECK-NEXT: test1
 void test1(int x) {  // CHECK-NEXT: File 0, [[@LINE]]:19 -> {{[0-9]+}}:2 = #0
   if(x == 0) // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE]]:12 = #0
 goto a;  // CHECK: File 0, [[@LINE]]:5 -> [[@LINE]]:11 = #1
  // CHECK-NEXT: File 0, [[@LINE-1]]:11 -> [[@LINE+1]]:3 = (#0 - #1)
-  goto b;// CHECK: Gap,File 0, [[@LINE]]:3 -> [[@LINE+5]]:2 = #3
+  goto b;// CHECK: File 0, [[@LINE]]:3 -> [[@LINE+5]]:2 = (#0 - #1)
  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:9 -> [[@LINE+1]]:1 = #2
 a:   // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE+3]]:2 = #2
 b:   // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE+2]]:2 = #3
Index: test/CoverageMapping/deferred-region.cpp
===
--- test/CoverageMapping/deferred-region.cpp
+++ test/CoverageMapping/deferred-region.cpp
@@ -7,19 +7,20 @@
 void foo(int x) {
   if (x == 0) {
 return;
-  } // CHECK: Gap,File 0, [[@LINE]]:4 -> [[@LINE+2]]:2 = (#0 - #1)
-
+  } // CHECK-NOT: Gap,File 0, [[@LINE]]:4
+//< Don't complete the last deferred region in a decl, even though it may
+//< leave some whitespace marked with the same counter as the final return.
 }
 
-// CHECK-NEXT: _Z4foooi:
+// CHECK-LABEL: _Z4foooi:
 void fooo(int x) {
   if (x == 0) {
 return;
   } // CHECK: Gap,File 0, [[@LINE]]:4 -> [[@LINE+2]]:3 = (#0 - #1)
 
   if (x == 1) {
 return;
-  } // CHECK: Gap,File 0, [[@LINE]]:4 -> [[@LINE+2]]:2 = ((#0 - #1) - #2)
+  } // CHECK-NOT: Gap,File 0, [[@LINE]]:4
 
 }
 
@@ -108,7 +109,7 @@
   }
 
   if (false)
-return; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+1]]:2
+return; // CHECK-NOT: Gap,File 0, [[@LINE]]:11
 }
 
 // CHECK-LABEL: _Z8for_loopv:
@@ -167,7 +168,7 @@
   return; // CHECK: 

[PATCH] D46917: Comparison and Unary Operations for Fixed Point Types

2018-05-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr.
leonardchan added a project: clang.

This patch contains logic and tests for different unary and comparison 
operations on fixed point types, and casting between integers and fixed point 
types.

The operations are `==`, `!=`, `>`, `<`, `>=`, `<=`, `!`, `+`, `-`, `++`, and 
`--`.

`~` is not a supported operation on fixed point types.

This is a parent of https://reviews.llvm.org/D46915


Repository:
  rC Clang

https://reviews.llvm.org/D46917

Files:
  lib/CodeGen/CGExprScalar.cpp
  lib/Sema/SemaExpr.cpp
  test/Frontend/fixed_point_declarations.c
  test/Frontend/fixed_point_validation.c

Index: test/Frontend/fixed_point_validation.c
===
--- test/Frontend/fixed_point_validation.c
+++ test/Frontend/fixed_point_validation.c
@@ -1,19 +1,170 @@
+// RUN: %clang -S -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -S -emit-llvm -o - %s | lli
 
+// The first test checks the emitted llvm IR.
+// The second test checks the output.
+// Both these test require that the default bit widths for the fixed point types
+// are used since we check for bit shifted literals that were converted from
+// ints and floats.
+
+// Primary fixed point types
+signed short _Accum s_short_accum;// CHECK-DAG: @s_short_accum =  common dso_local global i16 0, align 2
+signed _Accum s_accum;// CHECK-DAG: @s_accum =common dso_local global i32 0, align 4
+signed long _Accum s_long_accum;  // CHECK-DAG: @s_long_accum =   common dso_local global i64 0, align 8
+unsigned short _Accum u_short_accum;  // CHECK-DAG: @u_short_accum =  common dso_local global i16 0, align 2
+unsigned _Accum u_accum;  // CHECK-DAG: @u_accum =common dso_local global i32 0, align 4
+unsigned long _Accum u_long_accum;// CHECK-DAG: @u_long_accum =   common dso_local global i64 0, align 8
+signed short _Fract s_short_fract;// CHECK-DAG: @s_short_fract =  common dso_local global i16 0, align 2
+signed _Fract s_fract;// CHECK-DAG: @s_fract =common dso_local global i32 0, align 4
+signed long _Fract s_long_fract;  // CHECK-DAG: @s_long_fract =   common dso_local global i64 0, align 8
+unsigned short _Fract u_short_fract;  // CHECK-DAG: @u_short_fract =  common dso_local global i16 0, align 2
+unsigned _Fract u_fract;  // CHECK-DAG: @u_fract =common dso_local global i32 0, align 4
+unsigned long _Fract u_long_fract;// CHECK-DAG: @u_long_fract =   common dso_local global i64 0, align 8
+
+// There are 7 bits allocated to the fractional part and 8
+// bits allocated to the integral part of a short _Accum by default.
+
+signed short _Accum s_short_accum2 = 2.5hk;  // CHECK-DAG: @s_short_accum2 = dso_local global i16 320, align 2
+short _Fract short_fract = 0.333hr;  // CHECK-DAG: @short_fract = dso_local global i16 42, align 2
+
 // Run simple validation tests
 
 #define assert(b) if (!(b)) { return 1; }
 
 int main(){
-  short _Accum s_accum;
+  short _Accum s_accum = 0.0hk;
   short _Accum s_accum2 = 2.0hk;
   short _Fract s_fract = 0.999hr;
   short _Fract s_fract2 = -0.999hr;
+  const _Fract fract_zero = 0.0r;
+  // CHECK:  %s_accum = alloca i16, align 2
+  // CHECK:  %s_accum2 = alloca i16, align 2
+  // CHECK:  %s_fract = alloca i16, align 2
+  // CHECK:  %s_fract2 = alloca i16, align 2
+  // CHECK:  %fract_zero = alloca i32, align 4
+  // CHECK:  store i16 0, i16* %s_accum, align 2
+  // CHECK:  store i16 256, i16* %s_accum2, align 2
+  // CHECK:  store i16 127, i16* %s_fract, align 2
+  // CHECK:  store i16 -127, i16* %s_fract2, align 2
+  // CHECK:  store i32 0, i32* %fract_zero, align 4
+
+  / Simple Comparisons ***/
 
   assert(s_accum == 0);
+  // CHECK:  {{.*}} = load i16, i16* %s_accum, align 2
+  // CHECK-NEXT: {{.*}} = icmp eq i16 {{.*}}, 0
 
   s_accum = s_accum2;
+  // CHECK:  {{.*}} = load i16, i16* %s_accum2, align 2
+  // CHECK-NEXT: store i16 %1, i16* %s_accum, align 2
 
   assert(s_accum == s_accum2);
+  // CHECK:  {{.*}} = load i16, i16* %s_accum, align 2
+  // CHECK-NEXT: {{.*}} = load i16, i16* %s_accum2, align 2
+  // CHECK-NEXT: {{.*}} = icmp eq i16 {{.*}}, {{.*}}
+
+  assert(s_accum2 == s_accum);
+  // CHECK:  {{.*}} = load i16, i16* %s_accum2, align 2
+  // CHECK-NEXT: {{.*}} = load i16, i16* %s_accum, align 2
+  // CHECK-NEXT: {{.*}} = icmp eq i16 {{.*}}, {{.*}}
+
   assert(s_accum == 2);
+  // CHECK:  {{.*}} = icmp eq i16 {{.*}}, 256
+
+  assert(2 == s_accum);
+  // CHECK:  {{.*}} = icmp eq i16 256, {{.*}}
+
+  int x = 2;
+  assert(s_accum == x);
+  // CHECK:  {{.*}} = load i32, i32* %x, align 4
+  // CHECK-NEXT: {{.*}} = trunc i32 {{.*}} to i16
+  // CHECK-NEXT: {{.*}} = shl i16 {{.*}}, 7
+  // CHECK-NEXT: {{.*}} = icmp eq i16 {{.*}}, {{.*}}
+
+  assert(x == s_accum);
+
+  

[PATCH] D46915: Set Fixed Point Precision Bits and Create Fixed Point Literals

2018-05-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr, jakehehrlich.
leonardchan added a project: clang.
Herald added a subscriber: mgorny.

This diff includes the logic for setting the precision bits for each primary 
fixed point type when building clang and logic for initializing a fixed point 
literal.

The precision bits are set when building cmake via the flags

  SACCUM_FBIT
  ACCUM_FBIT
  LACCUM_FBIT
  ...

More checks to ensure the bit values used are valid will be added in future 
patches.

Fixed point literals are declared using the suffixes

  hr: short _Fract
  uhr: unsigned short _Fract
  r: _Fract
  ur: unsigned _Fract
  lr: long _Fract
  ulr: unsigned long _Fract
  hk: short _Accum
  uhk: unsigned short _Accum
  k: _Accum
  uk: unsigned _Accum

Errors are also thrown for literal values that exceed the range of the type 
corresponding to the suffix

  unsigned short _Accum u_short_accum = 256.0uhk;   // expected-error{{the 
integral part of this literal is too large for this unsigned _Accum type}}

This is a parent of https://reviews.llvm.org/D46911


Repository:
  rC Clang

https://reviews.llvm.org/D46915

Files:
  CMakeLists.txt
  cmake/modules/InitFixedPointBits.cmake
  include/clang/AST/Expr.h
  include/clang/AST/OperationKinds.def
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/FixedPoint.h.in
  include/clang/Basic/StmtNodes.td
  include/clang/Lex/LiteralSupport.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/AST/Type.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Lex/LiteralSupport.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Frontend/fixed_point.c
  test/Frontend/fixed_point_declarations.c
  test/Frontend/fixed_point_errors.c
  test/Frontend/fixed_point_validation.c
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -305,6 +305,10 @@
 K = CXCursor_IntegerLiteral;
 break;
 
+  case Stmt::FixedPointLiteralClass:
+llvm_unreachable("No cursor for FixedPointLiteralClass");
+break;
+
   case Stmt::FloatingLiteralClass:
 K = CXCursor_FloatingLiteral;
 break;
Index: test/Frontend/fixed_point_validation.c
===
--- /dev/null
+++ test/Frontend/fixed_point_validation.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -S -emit-llvm -o - %s | lli
+
+// Run simple validation tests
+
+#define assert(b) if (!(b)) { return 1; }
+
+int main(){
+  short _Accum s_accum;
+  short _Accum s_accum2 = 2.0hk;
+  short _Fract s_fract = 0.999hr;
+  short _Fract s_fract2 = -0.999hr;
+
+  assert(s_accum == 0);
+
+  s_accum = s_accum2;
+
+  assert(s_accum == s_accum2);
+  assert(s_accum == 2);
+}
Index: test/Frontend/fixed_point_errors.c
===
--- test/Frontend/fixed_point_errors.c
+++ test/Frontend/fixed_point_errors.c
@@ -1,14 +1,23 @@
 // RUN: %clang_cc1 -x c -fsyntax-only -verify -pedantic %s
 
-long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
-unsigned long long _Accum u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
-long long _Fract longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
-unsigned long long _Fract u_longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
+long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+unsigned long long _Accum u_longlong_accum;   // expected-error{{'long long _Accum' is invalid}}
+long long _Fract longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
+unsigned long long _Fract u_longlong_fract;   // expected-error{{'long long _Fract' is invalid}}
 
 _Sat int i;  // expected-error{{'int' cannot be saturated. Only _Fract and _Accum can.}}
 _Sat _Sat _Fract fract;  // expected-warning{{duplicate '_Sat' declaration specifier}}
 
-_Sat long long _Accum sat_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+_Sat long long _Accum sat_longlong_accum; // expected-error{{'long long _Accum' is invalid}}
 _Sat unsigned long long _Accum sat_u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
-_Sat long long _Fract sat_longlong_fract;  // 

[PATCH] D46914: Run scan-view on systems with python3 as default python provider

2018-05-15 Thread Khem Raj via Phabricator via cfe-commits
raj.khem created this revision.
Herald added a subscriber: cfe-commits.

Linux Distros e.g. archlinux have started to use python3 as default python 
interpreter, therefore we need to be specific if we need python2


Repository:
  rC Clang

https://reviews.llvm.org/D46914

Files:
  tools/scan-view/bin/scan-view


Index: tools/scan-view/bin/scan-view
===
--- tools/scan-view/bin/scan-view
+++ tools/scan-view/bin/scan-view
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 
 """The clang static analyzer results viewer.
 """


Index: tools/scan-view/bin/scan-view
===
--- tools/scan-view/bin/scan-view
+++ tools/scan-view/bin/scan-view
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 
 """The clang static analyzer results viewer.
 """
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46911: Addition of the remaining fixed point types and their saturated equivalents

2018-05-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added a project: clang.

This diff includes changes for the remaining _Fract and _Sat fixed point types.

  signed short _Fract s_short_fract;
  signed _Fract s_fract;
  signed long _Fract s_long_fract;
  unsigned short _Fract u_short_fract;
  unsigned _Fract u_fract;
  unsigned long _Fract u_long_fract;
  
  // Aliased fixed point types
  short _Accum short_accum;
  _Accum accum;
  long _Accum long_accum;
  short _Fract short_fract;
  _Fract fract;
  long _Fract long_fract;
  
  // Saturated fixed point types
  _Sat signed short _Accum sat_s_short_accum;
  _Sat signed _Accum sat_s_accum;
  _Sat signed long _Accum sat_s_long_accum;
  _Sat unsigned short _Accum sat_u_short_accum;
  _Sat unsigned _Accum sat_u_accum;
  _Sat unsigned long _Accum sat_u_long_accum;
  _Sat signed short _Fract sat_s_short_fract;
  _Sat signed _Fract sat_s_fract;
  _Sat signed long _Fract sat_s_long_fract;
  _Sat unsigned short _Fract sat_u_short_fract;
  _Sat unsigned _Fract sat_u_fract;
  _Sat unsigned long _Fract sat_u_long_fract;
  
  // Aliased saturated fixed point types
  _Sat short _Accum sat_short_accum;
  _Sat _Accum sat_accum;
  _Sat long _Accum sat_long_accum;
  _Sat short _Fract sat_short_fract;
  _Sat _Fract sat_fract;
  _Sat long _Fract sat_long_fract;

This diff only allows for declaration of these fixed point types. Assignment 
and other operations done on fixed point types according to 
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf will be added in 
future patches.

This is a parent of https://reviews.llvm.org/D46084


Repository:
  rC Clang

https://reviews.llvm.org/D46911

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/Frontend/accum.c
  test/Frontend/accum_errors.c
  test/Frontend/accum_errors.cpp
  test/Frontend/fixed_point.c
  test/Frontend/fixed_point_errors.c
  test/Frontend/fixed_point_errors.cpp

Index: test/Frontend/fixed_point_errors.c
===
--- /dev/null
+++ test/Frontend/fixed_point_errors.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -pedantic %s
+
+long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+unsigned long long _Accum u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+long long _Fract longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
+unsigned long long _Fract u_longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
+
+_Sat int i;  // expected-error{{'int' cannot be saturated. Only _Fract and _Accum can.}}
+_Sat _Sat _Fract fract;  // expected-warning{{duplicate '_Sat' declaration specifier}}
+
+_Sat long long _Accum sat_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+_Sat unsigned long long _Accum sat_u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+_Sat long long _Fract sat_longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
+_Sat unsigned long long _Fract sat_u_longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
Index: test/Frontend/fixed_point.c
===
--- /dev/null
+++ test/Frontend/fixed_point.c
@@ -0,0 +1,82 @@
+// RUN: %clang -cc1 -x c -ast-dump %s | FileCheck %s --strict-whitespace
+
+// Primary fixed point types
+signed short _Accum s_short_accum;
+signed _Accum s_accum;
+signed long _Accum s_long_accum;
+unsigned short _Accum u_short_accum;
+unsigned _Accum u_accum;
+unsigned long _Accum u_long_accum;
+signed short _Fract s_short_fract;
+signed _Fract s_fract;
+signed long _Fract s_long_fract;
+unsigned short _Fract u_short_fract;
+unsigned _Fract u_fract;
+unsigned long _Fract u_long_fract;
+
+// Aliased fixed point types
+short _Accum short_accum;
+_Accum accum;
+long _Accum long_accum;
+short _Fract short_fract;
+_Fract fract;
+long _Fract long_fract;
+
+// Saturated fixed point types
+_Sat signed short _Accum sat_s_short_accum;
+_Sat signed _Accum sat_s_accum;
+_Sat signed long _Accum sat_s_long_accum;
+_Sat unsigned short _Accum sat_u_short_accum;
+_Sat unsigned _Accum sat_u_accum;
+_Sat unsigned long _Accum sat_u_long_accum;
+_Sat signed short _Fract sat_s_short_fract;
+_Sat signed _Fract 

[PATCH] D46909: [Sema] Fix assertion when constructor is disabled with partially specialized template.

2018-05-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Looks good. It might be beneficial to do the lookup twice in this case and then 
issue a diagnostic if the results differ, but given how rarely this is 
happening, it doesn't really seem worthwhile.


https://reviews.llvm.org/D46909



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


[PATCH] D41968: [libunwind][MIPS] Support MIPS floating-point registers for hard-float ABIs.

2018-05-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332414: [libunwind][MIPS] Support MIPS floating-point 
registers for hard-float ABIs. (authored by jhb, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D41968

Files:
  libunwind/trunk/include/__libunwind_config.h
  libunwind/trunk/include/libunwind.h
  libunwind/trunk/src/Registers.hpp
  libunwind/trunk/src/UnwindRegistersRestore.S
  libunwind/trunk/src/UnwindRegistersSave.S
  libunwind/trunk/src/libunwind.cpp

Index: libunwind/trunk/src/Registers.hpp
===
--- libunwind/trunk/src/Registers.hpp
+++ libunwind/trunk/src/Registers.hpp
@@ -2718,6 +2718,14 @@
   };
 
   mips_o32_thread_state_t _registers;
+#ifdef __mips_hard_float
+  /// O32 with 32-bit floating point registers only uses half of this
+  /// space.  However, using the same layout for 32-bit vs 64-bit
+  /// floating point registers results in a single context size for
+  /// O32 with hard float.
+  uint32_t _padding;
+  double _floats[32];
+#endif
 };
 
 inline Registers_mips_o32::Registers_mips_o32(const void *registers) {
@@ -2744,13 +2752,28 @@
 return true;
   if (regNum == UNW_MIPS_LO)
 return true;
-  // FIXME: Hard float, DSP accumulator registers, MSA registers
+#if defined(__mips_hard_float) && __mips_fpr == 32
+  if (regNum >= UNW_MIPS_F0 && regNum <= UNW_MIPS_F31)
+return true;
+#endif
+  // FIXME: DSP accumulator registers, MSA registers
   return false;
 }
 
 inline uint32_t Registers_mips_o32::getRegister(int regNum) const {
   if (regNum >= UNW_MIPS_R0 && regNum <= UNW_MIPS_R31)
 return _registers.__r[regNum - UNW_MIPS_R0];
+#if defined(__mips_hard_float) && __mips_fpr == 32
+  if (regNum >= UNW_MIPS_F0 && regNum <= UNW_MIPS_F31) {
+uint32_t *p;
+
+if (regNum % 2 == 0)
+  p = (uint32_t *)&_floats[regNum - UNW_MIPS_F0];
+else
+  p = (uint32_t *)&_floats[(regNum - 1) - UNW_MIPS_F0] + 1;
+return *p;
+  }
+#endif
 
   switch (regNum) {
   case UNW_REG_IP:
@@ -2770,6 +2793,18 @@
 _registers.__r[regNum - UNW_MIPS_R0] = value;
 return;
   }
+#if defined(__mips_hard_float) && __mips_fpr == 32
+  if (regNum >= UNW_MIPS_F0 && regNum <= UNW_MIPS_F31) {
+uint32_t *p;
+
+if (regNum % 2 == 0)
+  p = (uint32_t *)&_floats[regNum - UNW_MIPS_F0];
+else
+  p = (uint32_t *)&_floats[(regNum - 1) - UNW_MIPS_F0] + 1;
+*p = value;
+return;
+  }
+#endif
 
   switch (regNum) {
   case UNW_REG_IP:
@@ -2788,17 +2823,31 @@
   _LIBUNWIND_ABORT("unsupported mips_o32 register");
 }
 
-inline bool Registers_mips_o32::validFloatRegister(int /* regNum */) const {
+inline bool Registers_mips_o32::validFloatRegister(int regNum) const {
+#if defined(__mips_hard_float) && __mips_fpr == 64
+  if (regNum >= UNW_MIPS_F0 && regNum <= UNW_MIPS_F31)
+return true;
+#endif
   return false;
 }
 
-inline double Registers_mips_o32::getFloatRegister(int /* regNum */) const {
+inline double Registers_mips_o32::getFloatRegister(int regNum) const {
+#if defined(__mips_hard_float) && __mips_fpr == 64
+  assert(validFloatRegister(regNum));
+  return _floats[regNum - UNW_MIPS_F0];
+#else
   _LIBUNWIND_ABORT("mips_o32 float support not implemented");
+#endif
 }
 
-inline void Registers_mips_o32::setFloatRegister(int /* regNum */,
- double /* value */) {
+inline void Registers_mips_o32::setFloatRegister(int regNum,
+ double value) {
+#if defined(__mips_hard_float) && __mips_fpr == 64
+  assert(validFloatRegister(regNum));
+  _floats[regNum - UNW_MIPS_F0] = value;
+#else
   _LIBUNWIND_ABORT("mips_o32 float support not implemented");
+#endif
 }
 
 inline bool Registers_mips_o32::validVectorRegister(int /* regNum */) const {
@@ -2879,6 +2928,70 @@
 return "$30";
   case UNW_MIPS_R31:
 return "$31";
+  case UNW_MIPS_F0:
+return "$f0";
+  case UNW_MIPS_F1:
+return "$f1";
+  case UNW_MIPS_F2:
+return "$f2";
+  case UNW_MIPS_F3:
+return "$f3";
+  case UNW_MIPS_F4:
+return "$f4";
+  case UNW_MIPS_F5:
+return "$f5";
+  case UNW_MIPS_F6:
+return "$f6";
+  case UNW_MIPS_F7:
+return "$f7";
+  case UNW_MIPS_F8:
+return "$f8";
+  case UNW_MIPS_F9:
+return "$f9";
+  case UNW_MIPS_F10:
+return "$f10";
+  case UNW_MIPS_F11:
+return "$f11";
+  case UNW_MIPS_F12:
+return "$f12";
+  case UNW_MIPS_F13:
+return "$f13";
+  case UNW_MIPS_F14:
+return "$f14";
+  case UNW_MIPS_F15:
+return "$f15";
+  case UNW_MIPS_F16:
+return "$f16";
+  case UNW_MIPS_F17:
+return "$f17";
+  case UNW_MIPS_F18:
+return "$f18";
+  case UNW_MIPS_F19:
+return "$f19";
+  case UNW_MIPS_F20:
+return "$f20";
+  case UNW_MIPS_F21:
+return "$f21";
+  case UNW_MIPS_F22:
+return "$f22";
+  case UNW_MIPS_F23:
+return "$f23";
+  case UNW_MIPS_F24:
+return 

[libunwind] r332414 - [libunwind][MIPS] Support MIPS floating-point registers for hard-float ABIs.

2018-05-15 Thread John Baldwin via cfe-commits
Author: jhb
Date: Tue May 15 15:44:56 2018
New Revision: 332414

URL: http://llvm.org/viewvc/llvm-project?rev=332414=rev
Log:
[libunwind][MIPS] Support MIPS floating-point registers for hard-float ABIs.

Summary:
For MIPS ABIs with 64-bit floating point registers including newabi
and O32 with 64-bit floating point registers, just save and restore the
32 floating-point registers as doubles.

For O32 MIPS with 32-bit floating-point registers, save and restore the
individual floating-point registers as "plain" registers.  These registers
are encoded as floats rather than doubles, but the DWARF unwinder
assumes that floating-point registers are stored as doubles when reading
them from memory (via AddressSpace::getDouble()).  Treating the
registers as "normal" registers instead causes the DWARF unwinder to
fetch them from memory as a 32-bit register.  This does mean that for
O32 with 32-bit floating-point registers unw_get_fpreg() and
unw_set_fpreg() do not work.  One would have to use unw_get_reg()
and unw_set_reg() instead.  However, DWARF unwinding works
correctly as the DWARF CFI emits records for individual 32-bit
floating-point registers even when they are treated as doubles stored
in paired registers.  If the lack of unw_get/set_fpreg() becomes a pressing
need in the future for O32 MIPS we could add in special handling to
make it work.

Reviewers: sdardis, compnerd

Reviewed By: sdardis

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

Modified:
libunwind/trunk/include/__libunwind_config.h
libunwind/trunk/include/libunwind.h
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/UnwindRegistersRestore.S
libunwind/trunk/src/UnwindRegistersSave.S
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/include/__libunwind_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/__libunwind_config.h?rev=332414=332413=332414=diff
==
--- libunwind/trunk/include/__libunwind_config.h (original)
+++ libunwind/trunk/include/__libunwind_config.h Tue May 15 15:44:56 2018
@@ -71,18 +71,33 @@
 #  define _LIBUNWIND_CURSOR_SIZE 24
 #  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K
 # elif defined(__mips__)
-#  if defined(_ABIO32) && _MIPS_SIM == _ABIO32 && defined(__mips_soft_float)
+#  if defined(_ABIO32) && _MIPS_SIM == _ABIO32
 #define _LIBUNWIND_TARGET_MIPS_O32 1
-#define _LIBUNWIND_CONTEXT_SIZE 18
-#define _LIBUNWIND_CURSOR_SIZE 24
-#  elif defined(_ABIN32) && _MIPS_SIM == _ABIN32 && defined(__mips_soft_float)
+#if defined(__mips_hard_float)
+#  define _LIBUNWIND_CONTEXT_SIZE 50
+#  define _LIBUNWIND_CURSOR_SIZE 57
+#else
+#  define _LIBUNWIND_CONTEXT_SIZE 18
+#  define _LIBUNWIND_CURSOR_SIZE 24
+#endif
+#  elif defined(_ABIN32) && _MIPS_SIM == _ABIN32
 #define _LIBUNWIND_TARGET_MIPS_NEWABI 1
-#define _LIBUNWIND_CONTEXT_SIZE 35
-#define _LIBUNWIND_CURSOR_SIZE 42
-#  elif defined(_ABI64) && _MIPS_SIM == _ABI64 && defined(__mips_soft_float)
+#if defined(__mips_hard_float)
+#  define _LIBUNWIND_CONTEXT_SIZE 67
+#  define _LIBUNWIND_CURSOR_SIZE 74
+#else
+#  define _LIBUNWIND_CONTEXT_SIZE 35
+#  define _LIBUNWIND_CURSOR_SIZE 42
+#endif
+#  elif defined(_ABI64) && _MIPS_SIM == _ABI64
 #define _LIBUNWIND_TARGET_MIPS_NEWABI 1
-#define _LIBUNWIND_CONTEXT_SIZE 35
-#define _LIBUNWIND_CURSOR_SIZE 47
+#if defined(__mips_hard_float)
+#  define _LIBUNWIND_CONTEXT_SIZE 67
+#  define _LIBUNWIND_CURSOR_SIZE 79
+#else
+#  define _LIBUNWIND_CONTEXT_SIZE 35
+#  define _LIBUNWIND_CURSOR_SIZE 47
+#endif
 #  else
 #error "Unsupported MIPS ABI and/or environment"
 #  endif

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=332414=332413=332414=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Tue May 15 15:44:56 2018
@@ -781,6 +781,38 @@ enum {
   UNW_MIPS_R29 = 29,
   UNW_MIPS_R30 = 30,
   UNW_MIPS_R31 = 31,
+  UNW_MIPS_F0  = 32,
+  UNW_MIPS_F1  = 33,
+  UNW_MIPS_F2  = 34,
+  UNW_MIPS_F3  = 35,
+  UNW_MIPS_F4  = 36,
+  UNW_MIPS_F5  = 37,
+  UNW_MIPS_F6  = 38,
+  UNW_MIPS_F7  = 39,
+  UNW_MIPS_F8  = 40,
+  UNW_MIPS_F9  = 41,
+  UNW_MIPS_F10 = 42,
+  UNW_MIPS_F11 = 43,
+  UNW_MIPS_F12 = 44,
+  UNW_MIPS_F13 = 45,
+  UNW_MIPS_F14 = 46,
+  UNW_MIPS_F15 = 47,
+  UNW_MIPS_F16 = 48,
+  UNW_MIPS_F17 = 49,
+  UNW_MIPS_F18 = 50,
+  UNW_MIPS_F19 = 51,
+  UNW_MIPS_F20 = 52,
+  UNW_MIPS_F21 = 53,
+  UNW_MIPS_F22 = 54,
+  UNW_MIPS_F23 = 55,
+  UNW_MIPS_F24 = 56,
+  UNW_MIPS_F25 = 57,
+  UNW_MIPS_F26 = 58,
+  UNW_MIPS_F27 = 59,
+  UNW_MIPS_F28 = 60,
+  UNW_MIPS_F29 = 61,
+  UNW_MIPS_F30 = 62,
+  UNW_MIPS_F31 = 63,
   UNW_MIPS_HI = 64,
   UNW_MIPS_LO = 65,
 };

Modified: 

[PATCH] D45470: Emit an error when include after

2018-05-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for review.


Repository:
  rL LLVM

https://reviews.llvm.org/D45470



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


[libcxx] r332413 - Emit an error when include after

2018-05-15 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Tue May 15 15:38:31 2018
New Revision: 332413

URL: http://llvm.org/viewvc/llvm-project?rev=332413=rev
Log:
Emit an error when include  after 

C11 defines `kill_dependency` as a macro in . When you
include  after , the macro clashes with
`std::kill_dependency` and causes multiple errors. Explicit error should
help in diagnosing those errors.

No change for working code that includes  before .

rdar://problem/27435938

Reviewers: rsmith, EricWF, mclow.lists, jfb

Reviewed By: jfb

Subscribers: jfb, jkorous-apple, christof, bumblebritches57, JonChesterfield, 
smeenai, cfe-commits

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


Modified:
libcxx/trunk/include/atomic

Modified: libcxx/trunk/include/atomic
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/atomic?rev=332413=332412=332413=diff
==
--- libcxx/trunk/include/atomic (original)
+++ libcxx/trunk/include/atomic Tue May 15 15:38:31 2018
@@ -555,6 +555,9 @@ void atomic_signal_fence(memory_order m)
 #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
 #error  is not implemented
 #endif
+#ifdef kill_dependency
+#error C++ standard library is incompatible with 
+#endif
 
 #if _LIBCPP_STD_VER > 14
 # define __cpp_lib_atomic_is_always_lock_free 201603L


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


[PATCH] D45470: Emit an error when include after

2018-05-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332413: Emit an error when include atomic after 
stdatomic.h (authored by vsapsai, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45470?vs=145817=146946#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45470

Files:
  libcxx/trunk/include/atomic


Index: libcxx/trunk/include/atomic
===
--- libcxx/trunk/include/atomic
+++ libcxx/trunk/include/atomic
@@ -555,6 +555,9 @@
 #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
 #error  is not implemented
 #endif
+#ifdef kill_dependency
+#error C++ standard library is incompatible with 
+#endif
 
 #if _LIBCPP_STD_VER > 14
 # define __cpp_lib_atomic_is_always_lock_free 201603L


Index: libcxx/trunk/include/atomic
===
--- libcxx/trunk/include/atomic
+++ libcxx/trunk/include/atomic
@@ -555,6 +555,9 @@
 #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
 #error  is not implemented
 #endif
+#ifdef kill_dependency
+#error C++ standard library is incompatible with 
+#endif
 
 #if _LIBCPP_STD_VER > 14
 # define __cpp_lib_atomic_is_always_lock_free 201603L
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46909: [Sema] Fix assertion when constructor is disabled with partially specialized template.

2018-05-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 146944.
vsapsai added a comment.

Potentially, VarTemplateDecl is susceptible to the same bug as
ClassTemplateSpecializationDecl. But I wasn't able to trigger it. And based on
code I've convinced myself that the mentioned early exit in
Sema::CheckVarTemplateId is equivalent to reusing available partial
specialization. So seems like no changes for VarTemplateDecl are required.


https://reviews.llvm.org/D46909

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/SemaTemplate/partial-spec-instantiate.cpp

Index: clang/test/SemaTemplate/partial-spec-instantiate.cpp
===
--- clang/test/SemaTemplate/partial-spec-instantiate.cpp
+++ clang/test/SemaTemplate/partial-spec-instantiate.cpp
@@ -55,3 +55,46 @@
   // expected-no-diagnostics
 #endif
 }
+
+// rdar://problem/39524996
+namespace rdar39524996 {
+  template 
+  struct enable_if_not_same
+  {
+typedef void type;
+  };
+  template 
+  struct enable_if_not_same;
+
+  template 
+  struct Wrapper {
+// Assertion triggered on trying to set twice the same partial specialization
+// enable_if_not_same
+template 
+Wrapper(const Wrapper& other,
+typename enable_if_not_same::type* = 0) {}
+
+explicit Wrapper(int i) {}
+  };
+
+  template 
+  struct Container {
+// It is important that the struct has implicit copy and move constructors.
+Container() : x() {}
+
+template 
+Container(const Container& other) : x(static_cast(other.x)) {}
+
+// Implicit constructors are member-wise, so the field triggers instantiation
+// of T constructors and we instantiate all of them for overloading purposes.
+T x;
+  };
+
+  void takesWrapperInContainer(const Container< Wrapper >& c);
+  void test() {
+// Type mismatch triggers initialization with conversion which requires
+// implicit constructors to be instantiated.
+Container c;
+takesWrapperInContainer(c);
+  }
+}
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2398,127 +2398,137 @@
   if (Inst.isInvalid() || Inst.isAlreadyInstantiating())
 return nullptr;
 
-  ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate();
-  CXXRecordDecl *Pattern = nullptr;
-
-  // C++ [temp.class.spec.match]p1:
-  //   When a class template is used in a context that requires an
-  //   instantiation of the class, it is necessary to determine
-  //   whether the instantiation is to be generated using the primary
-  //   template or one of the partial specializations. This is done by
-  //   matching the template arguments of the class template
-  //   specialization with the template argument lists of the partial
-  //   specializations.
-  typedef PartialSpecMatchResult MatchResult;
-  SmallVector Matched;
-  SmallVector PartialSpecs;
-  Template->getPartialSpecializations(PartialSpecs);
-  TemplateSpecCandidateSet FailedCandidates(PointOfInstantiation);
-  for (unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
-ClassTemplatePartialSpecializationDecl *Partial = PartialSpecs[I];
-TemplateDeductionInfo Info(FailedCandidates.getLocation());
-if (Sema::TemplateDeductionResult Result = S.DeduceTemplateArguments(
-Partial, ClassTemplateSpec->getTemplateArgs(), Info)) {
-  // Store the failed-deduction information for use in diagnostics, later.
-  // TODO: Actually use the failed-deduction info?
-  FailedCandidates.addCandidate().set(
-  DeclAccessPair::make(Template, AS_public), Partial,
-  MakeDeductionFailureInfo(S.Context, Result, Info));
-  (void)Result;
-} else {
-  Matched.push_back(PartialSpecMatchResult());
-  Matched.back().Partial = Partial;
-  Matched.back().Args = Info.take();
+  llvm::PointerUnion
+  Specialized = ClassTemplateSpec->getSpecializedTemplateOrPartial();
+  if (!Specialized.is()) {
+// Find best matching specialization.
+ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate();
+
+// C++ [temp.class.spec.match]p1:
+//   When a class template is used in a context that requires an
+//   instantiation of the class, it is necessary to determine
+//   whether the instantiation is to be generated using the primary
+//   template or one of the partial specializations. This is done by
+//   matching the template arguments of the class template
+//   specialization with the template argument lists of the partial
+//   specializations.
+typedef PartialSpecMatchResult MatchResult;
+SmallVector Matched;
+SmallVector PartialSpecs;
+Template->getPartialSpecializations(PartialSpecs);
+TemplateSpecCandidateSet FailedCandidates(PointOfInstantiation);
+for 

[PATCH] D46909: [Sema] Fix assertion when constructor is disabled with partially specialized template.

2018-05-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:3873-3881
   // Find the variable template specialization declaration that
   // corresponds to these arguments.
   void *InsertPos = nullptr;
   if (VarTemplateSpecializationDecl *Spec = Template->findSpecialization(
   Converted, InsertPos)) {
 checkSpecializationVisibility(TemplateNameLoc, Spec);
 // If we already have a variable template specialization, return it.

Code of interest (will refer to it later).


https://reviews.llvm.org/D46909



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


[PATCH] D46909: [Sema] Fix assertion when constructor is disabled with partially specialized template.

2018-05-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: rsmith, arphaman.

The added test case was triggering assertion

> Assertion failed: 
> (!SpecializedTemplate.is() && "Already set 
> to a class template partial specialization!"), function setInstantiationOf, 
> file clang/include/clang/AST/DeclTemplate.h, line 1825.

It was happening with ClassTemplateSpecializationDecl
`enable_if_not_same`. Because this template is specialized for
equal types not to have a definition, it wasn't instantiated and its
specialization kind remained TSK_Undeclared. And because it was implicit
instantiation, we didn't mark the decl as invalid. So when we try to
find the best matching partial specialization the second time, we hit
the assertion as partial specialization is already set.

Fix by reusing stored partial specialization when available, instead of
looking for the best match every time.

rdar://problem/39524996


https://reviews.llvm.org/D46909

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/SemaTemplate/partial-spec-instantiate.cpp

Index: clang/test/SemaTemplate/partial-spec-instantiate.cpp
===
--- clang/test/SemaTemplate/partial-spec-instantiate.cpp
+++ clang/test/SemaTemplate/partial-spec-instantiate.cpp
@@ -55,3 +55,46 @@
   // expected-no-diagnostics
 #endif
 }
+
+// rdar://problem/39524996
+namespace rdar39524996 {
+  template 
+  struct enable_if_not_same
+  {
+typedef void type;
+  };
+  template 
+  struct enable_if_not_same;
+
+  template 
+  struct Wrapper {
+// Assertion triggered on trying to set twice the same partial specialization
+// enable_if_not_same
+template 
+Wrapper(const Wrapper& other,
+typename enable_if_not_same::type* = 0) {}
+
+explicit Wrapper(int i) {}
+  };
+
+  template 
+  struct Container {
+// It is important that the struct has implicit copy and move constructors.
+Container() : x() {}
+
+template 
+Container(const Container& other) : x(static_cast(other.x)) {}
+
+// Implicit constructors are member-wise, so the field triggers instantiation
+// of T constructors and we instantiate all of them for overloading purposes.
+T x;
+  };
+
+  void takesWrapperInContainer(const Container< Wrapper >& c);
+  void test() {
+// Type mismatch triggers initialization with conversion which requires
+// implicit constructors to be instantiated.
+Container c;
+takesWrapperInContainer(c);
+  }
+}
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2398,127 +2398,137 @@
   if (Inst.isInvalid() || Inst.isAlreadyInstantiating())
 return nullptr;
 
-  ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate();
-  CXXRecordDecl *Pattern = nullptr;
-
-  // C++ [temp.class.spec.match]p1:
-  //   When a class template is used in a context that requires an
-  //   instantiation of the class, it is necessary to determine
-  //   whether the instantiation is to be generated using the primary
-  //   template or one of the partial specializations. This is done by
-  //   matching the template arguments of the class template
-  //   specialization with the template argument lists of the partial
-  //   specializations.
-  typedef PartialSpecMatchResult MatchResult;
-  SmallVector Matched;
-  SmallVector PartialSpecs;
-  Template->getPartialSpecializations(PartialSpecs);
-  TemplateSpecCandidateSet FailedCandidates(PointOfInstantiation);
-  for (unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
-ClassTemplatePartialSpecializationDecl *Partial = PartialSpecs[I];
-TemplateDeductionInfo Info(FailedCandidates.getLocation());
-if (Sema::TemplateDeductionResult Result = S.DeduceTemplateArguments(
-Partial, ClassTemplateSpec->getTemplateArgs(), Info)) {
-  // Store the failed-deduction information for use in diagnostics, later.
-  // TODO: Actually use the failed-deduction info?
-  FailedCandidates.addCandidate().set(
-  DeclAccessPair::make(Template, AS_public), Partial,
-  MakeDeductionFailureInfo(S.Context, Result, Info));
-  (void)Result;
-} else {
-  Matched.push_back(PartialSpecMatchResult());
-  Matched.back().Partial = Partial;
-  Matched.back().Args = Info.take();
+  llvm::PointerUnion
+  Specialized = ClassTemplateSpec->getSpecializedTemplateOrPartial();
+  if (!Specialized.is()) {
+// Find best matching specialization.
+ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate();
+
+// C++ [temp.class.spec.match]p1:
+//   When a class template is used in a context that requires an
+//   instantiation of the class, it is necessary to 

[PATCH] D46894: [Attr] Don't print implicit attributes

2018-05-15 Thread Joel E. Denny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332411: [Attr] Dont print implicit attributes 
(authored by jdenny, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D46894

Files:
  lib/AST/DeclPrinter.cpp
  test/Misc/ast-print-record-decl.c


Index: test/Misc/ast-print-record-decl.c
===
--- test/Misc/ast-print-record-decl.c
+++ test/Misc/ast-print-record-decl.c
@@ -54,20 +54,34 @@
 //   RUN:-DKW=struct -DBASES=' : B' -o - -xc++ %s \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print -DKW=struct 
-DBASES=' : B' -xc++ %s \
-//   RUN: > %t.cpp
+//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++ %s \
+//   RUN:> %t.cpp
 //   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
 //   RUN:   -DBASES=' : B' %s --input-file %t.cpp
 //
 //   Now check compiling and printing of the printed file.
 //
-//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.cpp
-//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.cpp
+//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" > %t.diags
+//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.diags
+//   RUN: cat %t.diags >> %t.cpp
 //
 //   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm -o - 
%t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print %t.cpp \
+//   RUN: %clang_cc1 -verify -ast-print %t.cpp \
+//   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
+//   RUN: -DBASES=' : B' %s
+//
+//   Make sure implicit attributes aren't printed.  See comments in inMemberPtr
+//   for details.
+//
+//   RUN: %clang_cc1 -triple i686-pc-win32 -verify -ast-print -DKW=struct \
+//   RUN:-DBASES=' : B' -xc++ %s > %t.cpp
+//   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
+//   RUN:   -DBASES=' : B' %s --input-file %t.cpp
+//
+//   RUN: cat %t.diags >> %t.cpp
+//   RUN: %clang_cc1 -triple i686-pc-win32 -verify -ast-print %t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
 //   RUN: -DBASES=' : B' %s
 
@@ -236,6 +250,9 @@
 #ifdef __cplusplus
 // PRINT-CXX-LABEL: inMemberPtr
 void inMemberPtr() {
+  // Under windows, the implicit attribute __single_inheritance used to print
+  // between KW and T1 here, but that wasn't faithful to the original source.
+  //
   // PRINT-CXX-NEXT: [[KW]] T1 {
   // PRINT-CXX-NEXT:   int i;
   // PRINT-CXX-NEXT: };
Index: lib/AST/DeclPrinter.cpp
===
--- lib/AST/DeclPrinter.cpp
+++ lib/AST/DeclPrinter.cpp
@@ -215,7 +215,7 @@
   if (D->hasAttrs()) {
 AttrVec  = D->getAttrs();
 for (auto *A : Attrs) {
-  if (A->isInherited())
+  if (A->isInherited() || A->isImplicit())
 continue;
   switch (A->getKind()) {
 #define ATTR(X)


Index: test/Misc/ast-print-record-decl.c
===
--- test/Misc/ast-print-record-decl.c
+++ test/Misc/ast-print-record-decl.c
@@ -54,20 +54,34 @@
 //   RUN:-DKW=struct -DBASES=' : B' -o - -xc++ %s \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print -DKW=struct -DBASES=' : B' -xc++ %s \
-//   RUN: > %t.cpp
+//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++ %s \
+//   RUN:> %t.cpp
 //   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
 //   RUN:   -DBASES=' : B' %s --input-file %t.cpp
 //
 //   Now check compiling and printing of the printed file.
 //
-//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.cpp
-//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked deprecated here}}" >> %t.cpp
+//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" > %t.diags
+//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked deprecated here}}" >> %t.diags
+//   RUN: cat %t.diags >> %t.cpp
 //
 //   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm -o - %t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print %t.cpp \
+//   RUN: %clang_cc1 -verify -ast-print %t.cpp \
+//   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
+//   RUN: -DBASES=' : B' %s
+//
+//   Make sure implicit attributes aren't printed.  See comments in inMemberPtr
+//   for details.
+//
+//   RUN: %clang_cc1 -triple i686-pc-win32 -verify -ast-print -DKW=struct \
+//   RUN:-DBASES=' : B' -xc++ %s > %t.cpp
+//   RUN: FileCheck 

r332411 - [Attr] Don't print implicit attributes

2018-05-15 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Tue May 15 15:16:47 2018
New Revision: 332411

URL: http://llvm.org/viewvc/llvm-project?rev=332411=rev
Log:
[Attr] Don't print implicit attributes

Fixes bug reported at:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180514/228390.html

Reviewed by: aaron.ballman

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

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Misc/ast-print-record-decl.c

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=332411=332410=332411=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Tue May 15 15:16:47 2018
@@ -215,7 +215,7 @@ void DeclPrinter::prettyPrintAttributes(
   if (D->hasAttrs()) {
 AttrVec  = D->getAttrs();
 for (auto *A : Attrs) {
-  if (A->isInherited())
+  if (A->isInherited() || A->isImplicit())
 continue;
   switch (A->getKind()) {
 #define ATTR(X)

Modified: cfe/trunk/test/Misc/ast-print-record-decl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-record-decl.c?rev=332411=332410=332411=diff
==
--- cfe/trunk/test/Misc/ast-print-record-decl.c (original)
+++ cfe/trunk/test/Misc/ast-print-record-decl.c Tue May 15 15:16:47 2018
@@ -54,20 +54,34 @@
 //   RUN:-DKW=struct -DBASES=' : B' -o - -xc++ %s \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print -DKW=struct 
-DBASES=' : B' -xc++ %s \
-//   RUN: > %t.cpp
+//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++ %s \
+//   RUN:> %t.cpp
 //   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
 //   RUN:   -DBASES=' : B' %s --input-file %t.cpp
 //
 //   Now check compiling and printing of the printed file.
 //
-//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.cpp
-//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.cpp
+//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" > %t.diags
+//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.diags
+//   RUN: cat %t.diags >> %t.cpp
 //
 //   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm -o - 
%t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print %t.cpp \
+//   RUN: %clang_cc1 -verify -ast-print %t.cpp \
+//   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
+//   RUN: -DBASES=' : B' %s
+//
+//   Make sure implicit attributes aren't printed.  See comments in inMemberPtr
+//   for details.
+//
+//   RUN: %clang_cc1 -triple i686-pc-win32 -verify -ast-print -DKW=struct \
+//   RUN:-DBASES=' : B' -xc++ %s > %t.cpp
+//   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
+//   RUN:   -DBASES=' : B' %s --input-file %t.cpp
+//
+//   RUN: cat %t.diags >> %t.cpp
+//   RUN: %clang_cc1 -triple i686-pc-win32 -verify -ast-print %t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
 //   RUN: -DBASES=' : B' %s
 
@@ -236,6 +250,9 @@ void inInit() {
 #ifdef __cplusplus
 // PRINT-CXX-LABEL: inMemberPtr
 void inMemberPtr() {
+  // Under windows, the implicit attribute __single_inheritance used to print
+  // between KW and T1 here, but that wasn't faithful to the original source.
+  //
   // PRINT-CXX-NEXT: [[KW]] T1 {
   // PRINT-CXX-NEXT:   int i;
   // PRINT-CXX-NEXT: };


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


[PATCH] D46906: [clangd] Fix a link failure in unittests

2018-05-15 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin created this revision.
aheejin added a reviewer: sammccall.
Herald added subscribers: cfe-commits, jkorous, MaskRay, ioeric, ilya-biryukov, 
mgorny, klimek.
aheejin edited the summary of this revision.

https://reviews.llvm.org/D46524 (https://reviews.llvm.org/rL332378) introduced 
a link failure when built with `-DSHARED_LIB=ON`, which this patch fixes.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46906

Files:
  unittests/clangd/CMakeLists.txt


Index: unittests/clangd/CMakeLists.txt
===
--- unittests/clangd/CMakeLists.txt
+++ unittests/clangd/CMakeLists.txt
@@ -38,6 +38,7 @@
 
 target_link_libraries(ClangdTests
   PRIVATE
+  clangAST
   clangBasic
   clangDaemon
   clangFormat


Index: unittests/clangd/CMakeLists.txt
===
--- unittests/clangd/CMakeLists.txt
+++ unittests/clangd/CMakeLists.txt
@@ -38,6 +38,7 @@
 
 target_link_libraries(ClangdTests
   PRIVATE
+  clangAST
   clangBasic
   clangDaemon
   clangFormat
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44934: [analyzer] Improve the modeling of `memset()`.

2018-05-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Thanks! This looks great now.




Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1055
+std::tie(StateNullChar, StateNonNullChar) =
+assumeZero(C, State, CharVal, Ctx.UnsignedCharTy);
+

MTC wrote:
> NoQ wrote:
> > I think this should use `IntTy` here. Because that's the type of the 
> > `memset`'s argument, and that's what `assumeZero()` expects.
> I confirmed again that `memset()` will convert the value to `unsigned char` 
> first, see http://en.cppreference.com/w/c/string/byte/memset. 
> 
> In the next update, I will `evalCast(value, UnsignedCharTy, IntTy)` first, 
> therefore, I will continue to use `UnsignedCharTy`.
Aha, yup, it does convert to `unsigned char`, but `assumeZero()` doesn't. The 
new code looks correct.


Repository:
  rC Clang

https://reviews.llvm.org/D44934



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


[PATCH] D46452: [sanitizer] Don't add --export-dynamic for Myriad

2018-05-15 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
alekseyshl added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:706
   // to be dynamic to be sure we export sanitizer interface functions.
-  if (AddExportDynamic)
+  if (AddExportDynamic && TC.getTriple().getVendor() != llvm::Triple::Myriad)
 CmdArgs.push_back("--export-dynamic");

Maybe this logic should be in addSanitizerDynamicList, similar to how it is 
handled for Solaris?


Repository:
  rL LLVM

https://reviews.llvm.org/D46452



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


[PATCH] D46905: [Attr] Don't print fake MSInheritance argument

2018-05-15 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.
jdenny added reviewers: aaron.ballman, rsmith, hfinkel.

This was discovered at:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180514/228390.html


https://reviews.llvm.org/D46905

Files:
  include/clang/Basic/Attr.td
  test/SemaCXX/attr-print.cpp


Index: test/SemaCXX/attr-print.cpp
===
--- test/SemaCXX/attr-print.cpp
+++ test/SemaCXX/attr-print.cpp
@@ -34,3 +34,12 @@
   // CHECK: void callableWhen() __attribute__((callable_when("unconsumed", 
"consumed")));
   void callableWhen()  __attribute__((callable_when("unconsumed", 
"consumed")));
 };
+
+// CHECK: class __single_inheritance SingleInheritance;
+class __single_inheritance SingleInheritance;
+
+// CHECK: class __multiple_inheritance MultipleInheritance;
+class __multiple_inheritance MultipleInheritance;
+
+// CHECK: class __virtual_inheritance VirtualInheritance;
+class __virtual_inheritance VirtualInheritance;
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -184,7 +184,8 @@
 class AlignedArgument : Argument;
 
 // A bool argument with a default value
-class DefaultBoolArgument : BoolArgument {
+class DefaultBoolArgument
+: BoolArgument {
   bit Default = default;
 }
 
@@ -2617,7 +2618,7 @@
 
 def MSInheritance : InheritableAttr {
   let LangOpts = [MicrosoftExt];
-  let Args = [DefaultBoolArgument<"BestCase", 1>];
+  let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>];
   let Spellings = [Keyword<"__single_inheritance">,
Keyword<"__multiple_inheritance">,
Keyword<"__virtual_inheritance">,


Index: test/SemaCXX/attr-print.cpp
===
--- test/SemaCXX/attr-print.cpp
+++ test/SemaCXX/attr-print.cpp
@@ -34,3 +34,12 @@
   // CHECK: void callableWhen() __attribute__((callable_when("unconsumed", "consumed")));
   void callableWhen()  __attribute__((callable_when("unconsumed", "consumed")));
 };
+
+// CHECK: class __single_inheritance SingleInheritance;
+class __single_inheritance SingleInheritance;
+
+// CHECK: class __multiple_inheritance MultipleInheritance;
+class __multiple_inheritance MultipleInheritance;
+
+// CHECK: class __virtual_inheritance VirtualInheritance;
+class __virtual_inheritance VirtualInheritance;
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -184,7 +184,8 @@
 class AlignedArgument : Argument;
 
 // A bool argument with a default value
-class DefaultBoolArgument : BoolArgument {
+class DefaultBoolArgument
+: BoolArgument {
   bit Default = default;
 }
 
@@ -2617,7 +2618,7 @@
 
 def MSInheritance : InheritableAttr {
   let LangOpts = [MicrosoftExt];
-  let Args = [DefaultBoolArgument<"BestCase", 1>];
+  let Args = [DefaultBoolArgument<"BestCase", /*default*/1, /*fake*/1>];
   let Spellings = [Keyword<"__single_inheritance">,
Keyword<"__multiple_inheritance">,
Keyword<"__virtual_inheritance">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46903: [Attr] Don't print attr arg with default value

2018-05-15 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny abandoned this revision.
jdenny added a comment.

After further thought, this patch doesn't seem worthwhile.  Sorry for all the 
noise.


https://reviews.llvm.org/D46903



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


r332405 - [Documentation] Fix Release Notes format issues.

2018-05-15 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Tue May 15 14:45:01 2018
New Revision: 332405

URL: http://llvm.org/viewvc/llvm-project?rev=332405=rev
Log:
[Documentation] Fix Release Notes format issues.

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=332405=332404=332405=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue May 15 14:45:01 2018
@@ -99,12 +99,13 @@ New Compiler Flags
 --
 
 - :option:`-fstrict-float-cast-overflow` and
-  :option:`-fno-strict-float-cast-overflow` -
-   When a floating-point value is not representable in a destination integer
-   type, the code has undefined behavior according to the language standard.
-   By default, Clang will not guarantee any particular result in that case.
-   With the 'no-strict' option, Clang attempts to match the overflowing 
behavior
-   of the target's native float-to-int conversion instructions.
+  :option:`-fno-strict-float-cast-overflow`.
+
+  When a floating-point value is not representable in a destination integer
+  type, the code has undefined behavior according to the language standard. By
+  default, Clang will not guarantee any particular result in that case. With 
the
+  'no-strict' option, Clang attempts to match the overflowing behavior of the
+  target's native float-to-int conversion instructions.
 
 - ...
 
@@ -127,7 +128,7 @@ Modified Compiler Flags
   this: `clang --autocomplete=-cc1,-xc++,-fsyn`.
 
 New Pragmas in Clang

+
 
 Clang now supports the ...
 


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


r332401 - Don't produce a redundant "auto type is incompatible with C++98" on every lambda with no explicit return type.

2018-05-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue May 15 14:27:30 2018
New Revision: 332401

URL: http://llvm.org/viewvc/llvm-project?rev=332401=rev
Log:
Don't produce a redundant "auto type is incompatible with C++98" on every 
lambda with no explicit return type.

We already warned about the lambda, and we don't have a source location for the 
imagined "auto" anyway.

Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaCXX/cxx98-compat.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=332401=332400=332401=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue May 15 14:27:30 2018
@@ -2962,9 +2962,11 @@ static QualType GetDeclSpecTypeForDeclar
 
   T = SemaRef.Context.IntTy;
   D.setInvalidType(true);
-} else if (!HaveTrailing) {
+} else if (!HaveTrailing &&
+   D.getContext() != DeclaratorContext::LambdaExprContext) {
   // If there was a trailing return type, we already got
   // warn_cxx98_compat_trailing_return_type in the parser.
+  // If this was a lambda, we already warned on that too.
   SemaRef.Diag(AutoRange.getBegin(),
diag::warn_cxx98_compat_auto_type_specifier)
 << AutoRange;

Modified: cfe/trunk/test/SemaCXX/cxx98-compat.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx98-compat.cpp?rev=332401=332400=332401=diff
==
--- cfe/trunk/test/SemaCXX/cxx98-compat.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx98-compat.cpp Tue May 15 14:27:30 2018
@@ -47,6 +47,8 @@ namespace TemplateParsing {
 
 void Lambda() {
   []{}(); // expected-warning {{lambda expressions are incompatible with 
C++98}}
+  // Don't warn about implicit "-> auto" here.
+  [](){}(); // expected-warning {{lambda expressions are incompatible with 
C++98}}
 }
 
 struct Ctor {


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


r332400 - Move helper classes into anonymous namespaces. NFCI.

2018-05-15 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue May 15 14:26:47 2018
New Revision: 332400

URL: http://llvm.org/viewvc/llvm-project?rev=332400=rev
Log:
Move helper classes into anonymous namespaces. NFCI.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=332400=332399=332400=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue May 15 14:26:47 2018
@@ -1470,9 +1470,10 @@ createConstantGlobalStruct(CodeGenModule
 }
 
 template 
-void createConstantGlobalStructAndAddToParent(CodeGenModule , QualType Ty,
-  ArrayRef Data,
-  T ) {
+static void
+createConstantGlobalStructAndAddToParent(CodeGenModule , QualType Ty,
+ ArrayRef Data,
+ T ) {
   const auto *RD = cast(Ty->getAsTagDecl());
   const CGRecordLayout  = CGM.getTypes().getCGRecordLayout(RD);
   ConstantStructBuilder Fields = Parent.beginStruct(RL.getLLVMType());

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=332400=332399=332400=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue May 15 14:26:47 2018
@@ -2552,11 +2552,11 @@ void ASTDeclReader::mergeRedeclarable(Re
 /// 6.1.2.6/1). Although most merging is done in Sema, we need to guarantee
 /// that some types are mergeable during deserialization, otherwise name
 /// lookup fails. This is the case for EnumConstantDecl.
-bool allowODRLikeMergeInC(NamedDecl *ND) {
+static bool allowODRLikeMergeInC(NamedDecl *ND) {
   if (!ND)
 return false;
   // TODO: implement merge for other necessary decls.
-  if (dyn_cast(ND))
+  if (isa(ND))
 return true;
   return false;
 }


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


[PATCH] D46822: [RISCV] Add driver for riscv32-unknown-elf baremetal target

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

Just a brief comment in the code explaining that would be fine.


Repository:
  rC Clang

https://reviews.llvm.org/D46822



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


[PATCH] D46903: [Attr] Don't print attr arg with default value

2018-05-15 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

I occurs to me now that I could have fixed __single_inheritance by declaring 
its argument "fake".  However, I still prefer the above solution because (1) it 
should help with any other attributes where arguments should have been declared 
fake (but no, I haven't identified any yet), and (2) it generally makes 
attribute printing more succinct, including cases where originally implicit 
values were printing as explicit.  Again, the sacrifice is that some explicit 
values now print as implicit, but at least the semantics don't change.

If others disagree, I can change this.


https://reviews.llvm.org/D46903



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


r332397 - Address post-commit review comments after r328731. NFC.

2018-05-15 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Tue May 15 14:00:30 2018
New Revision: 332397

URL: http://llvm.org/viewvc/llvm-project?rev=332397=rev
Log:
Address post-commit review comments after r328731. NFC.

- Define a function (canPassInRegisters) that determines whether a
record can be passed in registers based on language rules and
target-specific ABI rules.

- Set flag RecordDecl::ParamDestroyedInCallee to true in MSVC mode and
remove ASTContext::isParamDestroyedInCallee, which is no longer needed.

- Use the same type (unsigned) for RecordDecl's bit-field members.

For more background, see the following discussions that took place on
cfe-commits.

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180326/223498.html
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180402/223688.html
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180409/224754.html
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226494.html
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180507/227647.html

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=332397=332396=332397=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue May 15 14:00:30 2018
@@ -1181,10 +1181,6 @@ public:
const FunctionProtoType::ExceptionSpecInfo ,
bool AsWritten = false);
 
-  /// Determine whether a type is a class that should be detructed in the
-  /// callee function.
-  bool isParamDestroyedInCallee(QualType T) const;
-
   /// Return the uniqued reference to the type for a complex
   /// number with the specified element type.
   QualType getComplexType(QualType T) const;

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=332397=332396=332397=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue May 15 14:00:30 2018
@@ -3572,40 +3572,38 @@ private:
   /// This is true if this struct ends with a flexible
   /// array member (e.g. int X[]) or if this union contains a struct that does.
   /// If so, this cannot be contained in arrays or other structs as a member.
-  bool HasFlexibleArrayMember : 1;
+  unsigned HasFlexibleArrayMember : 1;
 
   /// Whether this is the type of an anonymous struct or union.
-  bool AnonymousStructOrUnion : 1;
+  unsigned AnonymousStructOrUnion : 1;
 
   /// This is true if this struct has at least one member
   /// containing an Objective-C object pointer type.
-  bool HasObjectMember : 1;
+  unsigned HasObjectMember : 1;
 
   /// This is true if struct has at least one member of
   /// 'volatile' type.
-  bool HasVolatileMember : 1;
+  unsigned HasVolatileMember : 1;
 
   /// Whether the field declarations of this record have been loaded
   /// from external storage. To avoid unnecessary deserialization of
   /// methods/nested types we allow deserialization of just the fields
   /// when needed.
-  mutable bool LoadedFieldsFromExternalStorage : 1;
+  mutable unsigned LoadedFieldsFromExternalStorage : 1;
 
   /// Basic properties of non-trivial C structs.
-  bool NonTrivialToPrimitiveDefaultInitialize : 1;
-  bool NonTrivialToPrimitiveCopy : 1;
-  bool NonTrivialToPrimitiveDestroy : 1;
-
-  /// Indicates whether this struct is destroyed in the callee. This flag is
-  /// meaningless when Microsoft ABI is used since parameters are always
-  /// destroyed in the callee.
+  unsigned NonTrivialToPrimitiveDefaultInitialize : 1;
+  unsigned NonTrivialToPrimitiveCopy : 1;
+  unsigned NonTrivialToPrimitiveDestroy : 1;
+
+  /// Indicates whether this struct is destroyed in the callee.
   ///
   /// Please note that MSVC won't merge adjacent bitfields if they don't have
   /// the same type.
-  uint8_t ParamDestroyedInCallee : 1;
+  unsigned ParamDestroyedInCallee : 1;
 
   /// Represents the way this type is passed to a function.
-  uint8_t ArgPassingRestrictions : 2;
+  unsigned ArgPassingRestrictions : 2;
 
 protected:
   RecordDecl(Kind DK, TagKind TK, const ASTContext , DeclContext *DC,

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=332397=332396=332397=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue May 15 14:00:30 2018
@@ -2649,14 +2649,6 @@ void 

[PATCH] D46822: [RISCV] Add driver for riscv32-unknown-elf baremetal target

2018-05-15 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

In https://reviews.llvm.org/D46822#1098764, @efriedma wrote:

> Could you include some documentation for how to construct a baremetal 
> environment like the one this code expects?  It's not clear what exactly you 
> expect to be installed where.


Thanks for taking a look Eli.

Building gcc+binutils+newlib will spit out a directory tree with the expected 
setup. e.g. a while ago I wrote a blog post 

 trying to show how to build upstream RISC-V gcc+binutils+newlib in the 
simplest way possible. You need a multistage build for C++ support and other 
features, but those instructions are enough to get a baremetal cross compiler. 
The directory layout is the same as if you use the build script in the 
riscv-gnu-toolchain repo , doing 
`./configure --prefix=/my/target/path --with-arch=rv32i --with-abi=ilp32; make 
-j$(nproc)`. This is a more advanced multi-stage build.

Would you like to see more information on this added to the commit message, as 
comments in the code, or elsewhere?

e.g. this is the directory listing of the build output if you follow the linked 
blog instructions: https://pastebin.com/8HeCMpxF


Repository:
  rC Clang

https://reviews.llvm.org/D46822



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


[PATCH] D46485: Add python tool to dump and construct header maps

2018-05-15 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

@jkorous, thanks for taking a look. This is an old python script which I 
haven't touched before, maybe there were answers to your questions but they are 
now lost in time. I'll address the review though and upload a new version.


Repository:
  rC Clang

https://reviews.llvm.org/D46485



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


[PATCH] D46903: [Attr] Don't print attr arg with default value

2018-05-15 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.
jdenny added reviewers: aaron.ballman, rsmith, hfinkel.

For example, given:

  class __single_inheritance T;

-ast-print -fms-extensions used to print:

  class __single_inheritance(1) T;

Clang fails to parse that because the "(1)" is not valid syntax.

This was discovered at:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180514/228390.html

To fix that, this patch generally suppresses printing any attribute
argument that has its default value unless other arguments will be
printed after it.  Doing so should always maintain the original source
semantics and produce valid syntax.

However, doing so also drops arguments where attributes are legally
specified explicitly with their default values but are not followed by
other arguments.  Correct syntax in the previous case seems more
important than exact textual fidelity in this case.


https://reviews.llvm.org/D46903

Files:
  test/SemaCXX/attr-print.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -374,6 +374,11 @@
 OS << Default;
   OS << ";";
 }
+
+std::string getIsOmitted() const override {
+  return "Default" + getUpperName().str() + " == get" +
+ getUpperName().str() + "()";
+}
   };
 
   class StringArgument : public Argument {
@@ -1432,6 +1437,7 @@
   unsigned NonFakeArgs = 0;
   unsigned TrailingOptArgs = 0;
   bool FoundNonOptArg = false;
+  std::string Indent = "";
   for (const auto  : llvm::reverse(Args)) {
 if (arg->isFake())
   continue;
@@ -1446,9 +1452,14 @@
 }
 if (!TrailingOptArgs++)
   OS << "\";\n"
- << "unsigned TrailingOmittedArgs = 0;\n";
-OS << "if (" << arg->getIsOmitted() << ")\n"
-   << "  ++TrailingOmittedArgs;\n";
+ << Indent << "unsigned TrailingOmittedArgs = 0;\n";
+OS << Indent << "if (" << arg->getIsOmitted() << ") {\n";
+Indent += "  ";
+OS << Indent << "++TrailingOmittedArgs;\n";
+  }
+  for (unsigned i = 0; i < TrailingOptArgs; ++i) {
+Indent.resize(Indent.size() - 2);
+OS << Indent << "}\n";
   }
   if (TrailingOptArgs)
 OS << "OS << \"";
@@ -1463,26 +1474,21 @@
   for (const auto  : Args) {
 if (arg->isFake())
   continue;
-if (ArgIndex) {
-  if (ArgIndex >= NonFakeArgs - TrailingOptArgs)
-OS << "\";\n"
-   << "if (" << ArgIndex << " < " << NonFakeArgs
-   << " - TrailingOmittedArgs)\n"
-   << "  OS << \", \";\n"
-   << "OS << \"";
-  else
-OS << ", ";
-}
-std::string IsOmitted = arg->getIsOmitted();
-if (arg->isOptional() && IsOmitted != "false")
+if (ArgIndex >= NonFakeArgs - TrailingOptArgs) {
   OS << "\";\n"
- << "if (!(" << IsOmitted << ")) {\n"
- << "  OS << \"";
+ << "if (" << ArgIndex << " < " << NonFakeArgs
+ << " - TrailingOmittedArgs) {\n";
+  if (ArgIndex)
+OS << "  OS << \", \";\n";
+  OS << "  OS << \"";
+} else if (ArgIndex)
+  OS << ", ";
 arg->writeValue(OS);
-if (arg->isOptional() && IsOmitted != "false")
+if (ArgIndex >= NonFakeArgs - TrailingOptArgs) {
   OS << "\";\n"
  << "}\n"
  << "OS << \"";
+}
 ++ArgIndex;
   }
   if (TrailingOptArgs < NonFakeArgs)
Index: test/SemaCXX/attr-print.cpp
===
--- test/SemaCXX/attr-print.cpp
+++ test/SemaCXX/attr-print.cpp
@@ -34,3 +34,27 @@
   // CHECK: void callableWhen() __attribute__((callable_when("unconsumed", "consumed")));
   void callableWhen()  __attribute__((callable_when("unconsumed", "consumed")));
 };
+
+// CHECK: class __single_inheritance SingleInheritance;
+class __single_inheritance SingleInheritance;
+
+// CHECK: void sentinel(int a, ...) __attribute__((sentinel));
+void sentinel(int a, ...) __attribute__((sentinel));
+
+// CHECK: void sentinel_1n(int a, ...) __attribute__((sentinel(1)));
+void sentinel_1n(int a, ...) __attribute__((sentinel(1)));
+
+// CHECK: void sentinel_1d2n(int a, ...) __attribute__((sentinel(0, 1)));
+void sentinel_1d2n(int a, ...) __attribute__((sentinel(0, 1)));
+
+// CHECK: void sentinel_1n2n(int a, ...) __attribute__((sentinel(1, 1)));
+void sentinel_1n2n(int a, ...) __attribute__((sentinel(1, 1)));
+
+// It would be better if we didn't lose arguments in the following cases, but
+// at least the default values have the same semantics.
+
+// CHECK: void sentinel_1d(int a, ...) __attribute__((sentinel));
+void sentinel_1d(int a, ...) 

[PATCH] D46902: [analyzer] Make plist-html multi-file.

2018-05-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/diagnostics/plist-multi-file.c:202
+// CHECK-NEXT:  
+// CHECK-NEXT:   report-{{([0-9a-f]{6})}}.html
+// CHECK-NEXT:  

Yay we have regular expressions.
`()` are needed so that not to confuse `}``}}` with `}}``}`.


Repository:
  rC Clang

https://reviews.llvm.org/D46902



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


[PATCH] D46902: [analyzer] Make plist-html multi-file.

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

Plist diagnostics support multi-file reports since forever. HTML diagnostics 
support multi-file reports since 
https://reviews.llvm.org/D30406/https://reviews.llvm.org/rC309968.

plist-html is the diagnostic output mode that produces both html and plist 
files. It's mostly useful for testing the analyzer itself because plist output 
is helpful for comparing results produced by different versions of the analyzer 
via the `utils/analyzer/CmpRuns.py` and html output allows you to immediately 
have a look at the changed reports.

Previously plist-html output produced multi-file HTML reports but only 
single-file Plist reports.

Change plist-html output to produce multi-file Plist reports as well.

I don't think we should care about backwards compatibility here because not 
only the old mode made no sense but also it doesn't make sense to use 
plist-html in any user-facing UI anyway.


Repository:
  rC Clang

https://reviews.llvm.org/D46902

Files:
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/diagnostics/plist-multi-file.c
  test/Analysis/diagnostics/plist-multi-file.h

Index: test/Analysis/diagnostics/plist-multi-file.h
===
--- /dev/null
+++ test/Analysis/diagnostics/plist-multi-file.h
@@ -0,0 +1,3 @@
+void foo(int *ptr) {
+  *ptr = 1; // expected-warning{{Dereference of null pointer (loaded from variable 'ptr')}}
+}
Index: test/Analysis/diagnostics/plist-multi-file.c
===
--- /dev/null
+++ test/Analysis/diagnostics/plist-multi-file.c
@@ -0,0 +1,205 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-html -o %t.plist -verify %s
+// RUN: FileCheck --input-file=%t.plist %s
+
+#include "plist-multi-file.h"
+
+void bar() {
+  foo(0);
+}
+
+// CHECK: diagnostics
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   path
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: kindevent
+// CHECK-NEXT: location
+// CHECK-NEXT: 
+// CHECK-NEXT:  line7
+// CHECK-NEXT:  col7
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: ranges
+// CHECK-NEXT: 
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: line7
+// CHECK-NEXT: col7
+// CHECK-NEXT: file0
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: line7
+// CHECK-NEXT: col7
+// CHECK-NEXT: file0
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: depth0
+// CHECK-NEXT: extended_message
+// CHECK-NEXT: Passing null pointer value via 1st parameter ptr
+// CHECK-NEXT: message
+// CHECK-NEXT: Passing null pointer value via 1st parameter ptr
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindevent
+// CHECK-NEXT: location
+// CHECK-NEXT: 
+// CHECK-NEXT:  line7
+// CHECK-NEXT:  col3
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: ranges
+// CHECK-NEXT: 
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: line7
+// CHECK-NEXT: col3
+// CHECK-NEXT: file0
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: line7
+// CHECK-NEXT: col8
+// CHECK-NEXT: file0
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: depth0
+// CHECK-NEXT: extended_message
+// CHECK-NEXT: Calling foo
+// CHECK-NEXT: message
+// CHECK-NEXT: Calling foo
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindevent
+// CHECK-NEXT: location
+// CHECK-NEXT: 
+// CHECK-NEXT:  line1
+// CHECK-NEXT:  col1
+// CHECK-NEXT:  file1
+// CHECK-NEXT: 
+// CHECK-NEXT: depth1
+// CHECK-NEXT: extended_message
+// CHECK-NEXT: Entered call from bar
+// CHECK-NEXT: message
+// CHECK-NEXT: Entered call from bar
+// CHECK-NEXT:
+// CHECK-NEXT:
+// CHECK-NEXT: kindcontrol
+// CHECK-NEXT: edges
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:start
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line1
+// CHECK-NEXT:   col1
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line1
+// CHECK-NEXT:   col4
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:end
+// CHECK-NEXT: 
+// CHECK-NEXT:  
+// CHECK-NEXT:   line2
+// CHECK-NEXT:   col3
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   line2
+// CHECK-NEXT:   col3
+// CHECK-NEXT:   file1
+// CHECK-NEXT:  
+// CHECK-NEXT: 
+// CHECK-NEXT:  

[PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2018-05-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a reviewer: vsapsai.
dexonsmith added a comment.

In https://reviews.llvm.org/D17741#1067816, @weimingz wrote:

> split the original into two parts. This one supports 
> -ffile-macro-prefix-to-remove function.
>
> I locally verified it.  To add a test case, do we need to use VFS?


VFS might work.


https://reviews.llvm.org/D17741



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


[PATCH] D46489: [HIP] Let assembler output bitcode for amdgcn

2018-05-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D46489#1099979, @yaxunl wrote:

> In https://reviews.llvm.org/D46489#1088940, @rjmccall wrote:
>
> > I think the right solution here is to make a CompileJobAction with type 
> > TY_LLVM_BC in the first place.  You should get the advice of a driver 
> > expert, though.
>
>
> There is already JobAction for TY_LLVM_BC. I just want to skip the backend 
> and assemble phase when offloading HIP. I will try achieving that through HIP 
> action builder.


Right, that's what I mean.  This is something we already support for LTO and 
other purposes.  You can just check what happens in the driver if you pass `-c 
-emit-llvm`.


https://reviews.llvm.org/D46489



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


[PATCH] D46489: [HIP] Let assembler output bitcode for amdgcn

2018-05-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D46489#1088940, @rjmccall wrote:

> I think the right solution here is to make a CompileJobAction with type 
> TY_LLVM_BC in the first place.  You should get the advice of a driver expert, 
> though.


There is already JobAction for TY_LLVM_BC. I just want to skip the backend and 
assemble phase when offloading HIP. I will try achieving that through HIP 
action builder.


https://reviews.llvm.org/D46489



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


[PATCH] D46863: [X86] Use __builtin_convertvector to implement some of the packed integer to packed flow conversion intrinsics.

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

> I'm concerned about constant folding not taking into account runtime rounding 
> mode

Changing the rounding mode is UB without FENV_ACCESS.  And with FENV_ACCESS, 
__builtin_convertvector should lower to @llvm.experimental.constrained.sitofp 
etc., which won't constant-fold.  (llvm.experimental.constrained.sitofp doesn't 
actually exist yet, but I assume it will eventually get added.)


Repository:
  rC Clang

https://reviews.llvm.org/D46863



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


[PATCH] D46541: [CodeGen] Improve diagnostics related to target attributes

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

Ping @echristo


https://reviews.llvm.org/D46541



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


[PATCH] D46836: Fix some rtti-options tests

2018-05-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332384: Fixed some rtti-options tests. (authored by 
ssrivastava, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46836?vs=146632=146893#toc

Repository:
  rC Clang

https://reviews.llvm.org/D46836

Files:
  test/Driver/rtti-options.cpp


Index: test/Driver/rtti-options.cpp
===
--- test/Driver/rtti-options.cpp
+++ test/Driver/rtti-options.cpp
@@ -5,8 +5,8 @@
 
 // Special cases: -fcxx-exceptions in C code should warn about unused arguments
 // We should also not have any rtti-related arguments
-// RUN: %clang -x c -### -target x86_64-scei-ps4 -c -fcxx-exceptions %s 2>&1 | 
FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI 
-check-prefix=CHECK-NO-RTTI %s
-// RUN: %clang -x c -### -target x86_64-unknown-unknown -c -fcxx-exceptions %s 
2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI 
-check-prefix=CHECK-NO-RTTI %s
+// RUN: %clang -x c -### -target x86_64-scei-ps4 -c -fcxx-exceptions %s 2>&1 | 
FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s
+// RUN: %clang -x c -### -target x86_64-unknown-unknown -c -fcxx-exceptions %s 
2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s
 
 // Make sure we keep the last -frtti/-fno-rtti argument
 // RUN: %clang -### -c -fno-rtti -frtti %s 2>&1 | FileCheck 
-check-prefix=CHECK-RTTI %s
@@ -56,6 +56,6 @@
 // CHECK-EXC-ERROR: invalid argument '-fno-rtti' not allowed with 
'-fexceptions'
 // CHECK-EXC-ERROR-CXX: invalid argument '-fno-rtti' not allowed with 
'-fcxx-exceptions'
 // CHECK-RTTI-NOT: "-fno-rtti"
-// CHECK-NO-RTTI-NOT: "-frtti"
+// CHECK-NO-RTTI: "-fno-rtti"
 
 // CHECK-OK-NOT: {{warning:|error:}}


Index: test/Driver/rtti-options.cpp
===
--- test/Driver/rtti-options.cpp
+++ test/Driver/rtti-options.cpp
@@ -5,8 +5,8 @@
 
 // Special cases: -fcxx-exceptions in C code should warn about unused arguments
 // We should also not have any rtti-related arguments
-// RUN: %clang -x c -### -target x86_64-scei-ps4 -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI -check-prefix=CHECK-NO-RTTI %s
-// RUN: %clang -x c -### -target x86_64-unknown-unknown -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI -check-prefix=CHECK-NO-RTTI %s
+// RUN: %clang -x c -### -target x86_64-scei-ps4 -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s
+// RUN: %clang -x c -### -target x86_64-unknown-unknown -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s
 
 // Make sure we keep the last -frtti/-fno-rtti argument
 // RUN: %clang -### -c -fno-rtti -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s
@@ -56,6 +56,6 @@
 // CHECK-EXC-ERROR: invalid argument '-fno-rtti' not allowed with '-fexceptions'
 // CHECK-EXC-ERROR-CXX: invalid argument '-fno-rtti' not allowed with '-fcxx-exceptions'
 // CHECK-RTTI-NOT: "-fno-rtti"
-// CHECK-NO-RTTI-NOT: "-frtti"
+// CHECK-NO-RTTI: "-fno-rtti"
 
 // CHECK-OK-NOT: {{warning:|error:}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r332384 - Fixed some rtti-options tests.

2018-05-15 Thread Sunil Srivastava via cfe-commits
Author: ssrivastava
Date: Tue May 15 11:28:42 2018
New Revision: 332384

URL: http://llvm.org/viewvc/llvm-project?rev=332384=rev
Log:
Fixed some rtti-options tests.

Certain tests in rtti-options.cpp are not really testing anything because they 
are testing for the absence of -frtti option to the cc1 process. Since the cc1 
process does not take -frtti option, these tests are passing tautologically.

The RTTI mode is enabled by default in cc1, and -fno-rtti disables it. 
Therefore the correct way to check for enabling of RTTI is to check for the 
absence of -fno-rtti to cc1, and the correct way to check for disabling of RTTI 
is to check for the presence of -fno-rtti to cc1.

This patch fixes those tests.

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

Modified:
cfe/trunk/test/Driver/rtti-options.cpp

Modified: cfe/trunk/test/Driver/rtti-options.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/rtti-options.cpp?rev=332384=332383=332384=diff
==
--- cfe/trunk/test/Driver/rtti-options.cpp (original)
+++ cfe/trunk/test/Driver/rtti-options.cpp Tue May 15 11:28:42 2018
@@ -5,8 +5,8 @@
 
 // Special cases: -fcxx-exceptions in C code should warn about unused arguments
 // We should also not have any rtti-related arguments
-// RUN: %clang -x c -### -target x86_64-scei-ps4 -c -fcxx-exceptions %s 2>&1 | 
FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI 
-check-prefix=CHECK-NO-RTTI %s
-// RUN: %clang -x c -### -target x86_64-unknown-unknown -c -fcxx-exceptions %s 
2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI 
-check-prefix=CHECK-NO-RTTI %s
+// RUN: %clang -x c -### -target x86_64-scei-ps4 -c -fcxx-exceptions %s 2>&1 | 
FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s
+// RUN: %clang -x c -### -target x86_64-unknown-unknown -c -fcxx-exceptions %s 
2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s
 
 // Make sure we keep the last -frtti/-fno-rtti argument
 // RUN: %clang -### -c -fno-rtti -frtti %s 2>&1 | FileCheck 
-check-prefix=CHECK-RTTI %s
@@ -56,6 +56,6 @@
 // CHECK-EXC-ERROR: invalid argument '-fno-rtti' not allowed with 
'-fexceptions'
 // CHECK-EXC-ERROR-CXX: invalid argument '-fno-rtti' not allowed with 
'-fcxx-exceptions'
 // CHECK-RTTI-NOT: "-fno-rtti"
-// CHECK-NO-RTTI-NOT: "-frtti"
+// CHECK-NO-RTTI: "-fno-rtti"
 
 // CHECK-OK-NOT: {{warning:|error:}}


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


r332383 - [Hexagon] Add driver options for subtarget features

2018-05-15 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Tue May 15 11:15:59 2018
New Revision: 332383

URL: http://llvm.org/viewvc/llvm-project?rev=332383=rev
Log:
[Hexagon] Add driver options for subtarget features

Added:
cfe/trunk/test/Driver/hexagon-memops.c
cfe/trunk/test/Driver/hexagon-nvj.c
cfe/trunk/test/Driver/hexagon-nvs.c
Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=332383=332382=332383=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue May 15 11:15:59 2018
@@ -2562,23 +2562,35 @@ def mv62 : Flag<["-"], "mv62">, Group, AliasArgs<["hexagonv62"]>;
 def mv65 : Flag<["-"], "mv65">, Group,
   Alias, AliasArgs<["hexagonv65"]>;
-def mhexagon_hvx : Flag<[ "-" ], "mhvx">, Group,
+def mhexagon_hvx : Flag<["-"], "mhvx">, Group,
   HelpText<"Enable Hexagon Vector eXtensions">;
-def mhexagon_hvx_EQ : Joined<[ "-" ], "mhvx=">,
+def mhexagon_hvx_EQ : Joined<["-"], "mhvx=">,
   Group,
   HelpText<"Enable Hexagon Vector eXtensions">;
-def mno_hexagon_hvx : Flag<[ "-" ], "mno-hvx">,
+def mno_hexagon_hvx : Flag<["-"], "mno-hvx">,
   Group,
   HelpText<"Disable Hexagon Vector eXtensions">;
-def mhexagon_hvx_length_EQ : Joined<[ "-" ], "mhvx-length=">,
+def mhexagon_hvx_length_EQ : Joined<["-"], "mhvx-length=">,
   Group, HelpText<"Set Hexagon Vector Length">,
   Values<"64B,128B">;
 def ffixed_r19: Flag<["-"], "ffixed-r19">,
-  HelpText<"Reserve the r19 register (Hexagon only)">;
+  HelpText<"Reserve register r19 (Hexagon only)">;
+def mmemops : Flag<["-"], "mmemops">, Group,
+  Flags<[CC1Option]>, HelpText<"Enable generation of memop instructions">;
+def mno_memops : Flag<["-"], "mno-memops">, Group,
+  Flags<[CC1Option]>, HelpText<"Disable generation of memop instructions">;
 def mpackets : Flag<["-"], "mpackets">, Group,
   Flags<[CC1Option]>, HelpText<"Enable generation of instruction packets">;
 def mno_packets : Flag<["-"], "mno-packets">, Group,
   Flags<[CC1Option]>, HelpText<"Disable generation of instruction packets">;
+def mnvj : Flag<["-"], "mnvj">, Group,
+  Flags<[CC1Option]>, HelpText<"Enable generation of new-value jumps">;
+def mno_nvj : Flag<["-"], "mno-nvj">, Group,
+  Flags<[CC1Option]>, HelpText<"Disable generation of new-value jumps">;
+def mnvs : Flag<["-"], "mnvs">, Group,
+  Flags<[CC1Option]>, HelpText<"Enable generation of new-value stores">;
+def mno_nvs : Flag<["-"], "mno-nvs">, Group,
+  Flags<[CC1Option]>, HelpText<"Disable generation of new-value stores">;
 
 
 // X86 feature flags

Added: cfe/trunk/test/Driver/hexagon-memops.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-memops.c?rev=332383=auto
==
--- cfe/trunk/test/Driver/hexagon-memops.c (added)
+++ cfe/trunk/test/Driver/hexagon-memops.c Tue May 15 11:15:59 2018
@@ -0,0 +1,10 @@
+// RUN: %clang -target hexagon -### -mmemops %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-MEMOPS
+
+// RUN: %clang -target hexagon -### -mno-memops %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-MEMOPS
+
+// CHECK-MEMOPS: "-target-feature" "+memops"
+
+// CHECK-NO-MEMOPS: "-target-feature" "-memops"
+

Added: cfe/trunk/test/Driver/hexagon-nvj.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-nvj.c?rev=332383=auto
==
--- cfe/trunk/test/Driver/hexagon-nvj.c (added)
+++ cfe/trunk/test/Driver/hexagon-nvj.c Tue May 15 11:15:59 2018
@@ -0,0 +1,10 @@
+// RUN: %clang -target hexagon -### -mnvj %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NVJ
+
+// RUN: %clang -target hexagon -### -mno-nvj %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-NVJ
+
+// CHECK-NVJ: "-target-feature" "+nvj"
+
+// CHECK-NO-NVJ: "-target-feature" "-nvj"
+

Added: cfe/trunk/test/Driver/hexagon-nvs.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-nvs.c?rev=332383=auto
==
--- cfe/trunk/test/Driver/hexagon-nvs.c (added)
+++ cfe/trunk/test/Driver/hexagon-nvs.c Tue May 15 11:15:59 2018
@@ -0,0 +1,10 @@
+// RUN: %clang -target hexagon -### -mnvs %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NVS
+
+// RUN: %clang -target hexagon -### -mno-nvs %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-NVS
+
+// CHECK-NVS: "-target-feature" "+nvs"
+
+// CHECK-NO-NVS: "-target-feature" "-nvs"
+


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


[PATCH] D46895: add AR to acronyms of clang-tidy property check

2018-05-15 Thread Yan Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE332382: add AR to acronyms of clang-tidy property check 
(authored by Wizard, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46895?vs=146874=146886#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46895

Files:
  clang-tidy/objc/PropertyDeclarationCheck.cpp


Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -42,6 +42,7 @@
 "[2-9]G",
 "ACL",
 "API",
+"AR",
 "ARGB",
 "ASCII",
 "BGRA",


Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -42,6 +42,7 @@
 "[2-9]G",
 "ACL",
 "API",
+"AR",
 "ARGB",
 "ASCII",
 "BGRA",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r332382 - add AR to acronyms of clang-tidy property check

2018-05-15 Thread Yan Zhang via cfe-commits
Author: wizard
Date: Tue May 15 11:13:51 2018
New Revision: 332382

URL: http://llvm.org/viewvc/llvm-project?rev=332382=rev
Log:
add AR to acronyms of clang-tidy property check

Reviewers: hokein, benhamilton

Reviewed By: benhamilton

Subscribers: klimek, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp?rev=332382=332381=332382=diff
==
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Tue 
May 15 11:13:51 2018
@@ -42,6 +42,7 @@ constexpr llvm::StringLiteral DefaultSpe
 "[2-9]G",
 "ACL",
 "API",
+"AR",
 "ARGB",
 "ASCII",
 "BGRA",


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


[PATCH] D46894: [Attr] Don't print implicit attributes

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

LGTM!


https://reviews.llvm.org/D46894



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


r332380 - [OPENMP, NVPTX] Do not globalize variables with reference/pointer types.

2018-05-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue May 15 11:01:01 2018
New Revision: 332380

URL: http://llvm.org/viewvc/llvm-project?rev=332380=rev
Log:
[OPENMP, NVPTX] Do not globalize variables with reference/pointer types.

In generic data-sharing mode we do not need to globalize
variables/parameters of reference/pointer types. They already are placed
in the global memory.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_parallel_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp

cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=332380=332379=332380=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue May 15 11:01:01 2018
@@ -220,7 +220,10 @@ class CheckVarsEscapingDeclContext final
"Parameter captured by value with variably modified type");
 EscapedParameters.insert(VD);
   }
-}
+} else if (VD->getType()->isAnyPointerType() ||
+   VD->getType()->isReferenceType())
+  // Do not globalize variables with reference or pointer type.
+  return;
 if (VD->getType()->isVariablyModifiedType())
   EscapedVariableLengthDecls.insert(VD);
 else
@@ -602,9 +605,12 @@ static const Stmt *getSingleCompoundChil
 }
 
 /// Check if the parallel directive has an 'if' clause with non-constant or
-/// false condition.
-static bool hasParallelIfClause(ASTContext ,
-const OMPExecutableDirective ) {
+/// false condition. Also, check if the number of threads is strictly specified
+/// and run those directives in non-SPMD mode.
+static bool hasParallelIfNumThreadsClause(ASTContext ,
+  const OMPExecutableDirective ) {
+  if (D.hasClausesOfKind())
+return true;
   for (const auto *C : D.getClausesOfKind()) {
 OpenMPDirectiveKind NameModifier = C->getNameModifier();
 if (NameModifier != OMPD_parallel && NameModifier != OMPD_unknown)
@@ -629,7 +635,7 @@ static bool hasNestedSPMDDirective(ASTCo
 switch (D.getDirectiveKind()) {
 case OMPD_target:
   if (isOpenMPParallelDirective(DKind) &&
-  !hasParallelIfClause(Ctx, *NestedDir))
+  !hasParallelIfNumThreadsClause(Ctx, *NestedDir))
 return true;
   if (DKind == OMPD_teams || DKind == OMPD_teams_distribute) {
 Body = NestedDir->getInnermostCapturedStmt()->IgnoreContainers();
@@ -639,7 +645,7 @@ static bool hasNestedSPMDDirective(ASTCo
 if (const auto *NND = dyn_cast(ChildStmt)) {
   DKind = NND->getDirectiveKind();
   if (isOpenMPParallelDirective(DKind) &&
-  !hasParallelIfClause(Ctx, *NND))
+  !hasParallelIfNumThreadsClause(Ctx, *NND))
 return true;
   if (DKind == OMPD_distribute) {
 Body = NestedDir->getInnermostCapturedStmt()->IgnoreContainers();
@@ -651,7 +657,7 @@ static bool hasNestedSPMDDirective(ASTCo
 if (const auto *NND = dyn_cast(ChildStmt)) 
{
   DKind = NND->getDirectiveKind();
   return isOpenMPParallelDirective(DKind) &&
- !hasParallelIfClause(Ctx, *NND);
+ !hasParallelIfNumThreadsClause(Ctx, *NND);
 }
   }
 }
@@ -659,7 +665,7 @@ static bool hasNestedSPMDDirective(ASTCo
   return false;
 case OMPD_target_teams:
   if (isOpenMPParallelDirective(DKind) &&
-  !hasParallelIfClause(Ctx, *NestedDir))
+  !hasParallelIfNumThreadsClause(Ctx, *NestedDir))
 return true;
   if (DKind == OMPD_distribute) {
 Body = NestedDir->getInnermostCapturedStmt()->IgnoreContainers();
@@ -669,13 +675,13 @@ static bool hasNestedSPMDDirective(ASTCo
 if (const auto *NND = dyn_cast(ChildStmt)) {
   DKind = NND->getDirectiveKind();
   return isOpenMPParallelDirective(DKind) &&
- !hasParallelIfClause(Ctx, *NND);
+ !hasParallelIfNumThreadsClause(Ctx, *NND);
 }
   }
   return false;
 case OMPD_target_teams_distribute:
   return isOpenMPParallelDirective(DKind) &&
- !hasParallelIfClause(Ctx, *NestedDir);
+ !hasParallelIfNumThreadsClause(Ctx, *NestedDir);
 case OMPD_target_simd:
 case OMPD_target_parallel:
 case OMPD_target_parallel_for:
@@ -746,7 +752,7 @@ static bool supportsSPMDExecutionMode(AS
   case OMPD_target_parallel_for_simd:
   case OMPD_target_teams_distribute_parallel_for:
   case OMPD_target_teams_distribute_parallel_for_simd:
-

[PATCH] D46524: [clangd] Extract scoring/ranking logic, and shave yaks.

2018-05-15 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332378: [clangd] Extract scoring/ranking logic, and shave 
yaks. (authored by sammccall, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46524?vs=146591=146881#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46524

Files:
  clang-tools-extra/trunk/clangd/CMakeLists.txt
  clang-tools-extra/trunk/clangd/CodeComplete.cpp
  clang-tools-extra/trunk/clangd/Quality.cpp
  clang-tools-extra/trunk/clangd/Quality.h
  clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
  clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
  clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
  clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp
  clang-tools-extra/trunk/unittests/clangd/TestFS.cpp
  clang-tools-extra/trunk/unittests/clangd/TestTU.cpp
  clang-tools-extra/trunk/unittests/clangd/TestTU.h
  clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp

Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
@@ -20,6 +20,7 @@
 #include "FuzzyMatch.h"
 #include "Headers.h"
 #include "Logger.h"
+#include "Quality.h"
 #include "SourceCode.h"
 #include "Trace.h"
 #include "URI.h"
@@ -34,6 +35,9 @@
 #include "llvm/Support/Format.h"
 #include 
 
+// We log detailed candidate here if you run with -debug-only=codecomplete.
+#define DEBUG_TYPE "codecomplete"
+
 namespace clang {
 namespace clangd {
 namespace {
@@ -192,35 +196,6 @@
   return Result;
 }
 
-// Produces an integer that sorts in the same order as F.
-// That is: a < b <==> encodeFloat(a) < encodeFloat(b).
-uint32_t encodeFloat(float F) {
-  static_assert(std::numeric_limits::is_iec559, "");
-  static_assert(sizeof(float) == sizeof(uint32_t), "");
-  constexpr uint32_t TopBit = ~(~uint32_t{0} >> 1);
-
-  // Get the bits of the float. Endianness is the same as for integers.
-  uint32_t U;
-  memcpy(, , sizeof(float));
-  // IEEE 754 floats compare like sign-magnitude integers.
-  if (U & TopBit)// Negative float.
-return 0 - U;// Map onto the low half of integers, order reversed.
-  return U + TopBit; // Positive floats map onto the high half of integers.
-}
-
-// Returns a string that sorts in the same order as (-Score, Name), for LSP.
-std::string sortText(float Score, llvm::StringRef Name) {
-  // We convert -Score to an integer, and hex-encode for readability.
-  // Example: [0.5, "foo"] -> "4100foo"
-  std::string S;
-  llvm::raw_string_ostream OS(S);
-  write_hex(OS, encodeFloat(-Score), llvm::HexPrintStyle::Lower,
-/*Width=*/2 * sizeof(Score));
-  OS << Name;
-  OS.flush();
-  return S;
-}
-
 /// Creates a `HeaderFile` from \p Header which can be either a URI or a literal
 /// include.
 static llvm::Expected toHeaderFile(StringRef Header,
@@ -251,33 +226,6 @@
   const CodeCompletionResult *SemaResult = nullptr;
   const Symbol *IndexResult = nullptr;
 
-  // Computes the "symbol quality" score for this completion. Higher is better.
-  float score() const {
-float Score = 1;
-if (IndexResult)
-  Score *= quality(*IndexResult);
-if (SemaResult) {
-  // For now we just use the Sema priority, mapping it onto a 0-2 interval.
-  // That makes 1 neutral-ish, so we don't reward/penalize non-Sema results.
-  // Priority 80 is a really bad score.
-  Score *= 2 - std::min(80, SemaResult->Priority) / 40;
-
-  switch (static_cast(SemaResult->Availability)) {
-  case CXAvailability_Available:
-// No penalty.
-break;
-  case CXAvailability_Deprecated:
-Score *= 0.1f;
-break;
-  case CXAvailability_NotAccessible:
-  case CXAvailability_NotAvailable:
-Score = 0;
-break;
-  }
-}
-return Score;
-  }
-
   // Builds an LSP completion item.
   CompletionItem build(StringRef FileName, const CompletionItemScores ,
const CodeCompleteOptions ,
@@ -346,6 +294,7 @@
 return I;
   }
 };
+using ScoredCandidate = std::pair;
 
 // Determine the symbol ID for a Sema code completion result, if possible.
 llvm::Optional getSymbolID(const CodeCompletionResult ) {
@@ -552,50 +501,12 @@
   UniqueFunction ResultsCallback;
 };
 
-// Tracks a bounded number of candidates with the best scores.
-class TopN {
-public:
-  using value_type = std::pair;
-  static constexpr size_t Unbounded = std::numeric_limits::max();
-
-  TopN(size_t N) : N(N) {}
-
-  // Adds a candidate to the set.
-  // Returns true if a candidate was dropped to get back under N.
-  bool push(value_type &) {
-bool Dropped = false;
-if (Heap.size() >= N) {
-  Dropped = true;
-  if (N > 0 && greater(V, Heap.front())) {
-  

[clang-tools-extra] r332378 - [clangd] Extract scoring/ranking logic, and shave yaks.

2018-05-15 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue May 15 10:43:27 2018
New Revision: 332378

URL: http://llvm.org/viewvc/llvm-project?rev=332378=rev
Log:
[clangd] Extract scoring/ranking logic, and shave yaks.

Summary:
Code completion scoring was embedded in CodeComplete.cpp, which is bad:
 - awkward to test. The mechanisms (extracting info from index/sema) can be
   unit-tested well, the policy (scoring) should be quantitatively measured.
   Neither was easily possible, and debugging was hard.
   The intermediate signal struct makes this easier.
 - hard to reuse. This is a bug in workspaceSymbols: it just presents the
   results in the index order, which is not sorted in practice, it needs to rank
   them!
   Also, index implementations care about scoring (both query-dependent and
   independent) in order to truncate result lists appropriately.

The main yak shaved here is the build() function that had 3 variants across
unit tests is unified in TestTU.h (rather than adding a 4th variant).

Reviewers: ilya-biryukov

Subscribers: klimek, mgorny, ioeric, MaskRay, jkorous, mgrang, cfe-commits

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

Added:
clang-tools-extra/trunk/clangd/Quality.cpp
clang-tools-extra/trunk/clangd/Quality.h
clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp
clang-tools-extra/trunk/unittests/clangd/TestTU.cpp
clang-tools-extra/trunk/unittests/clangd/TestTU.h
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
clang-tools-extra/trunk/unittests/clangd/TestFS.cpp
clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=332378=332377=332378=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Tue May 15 10:43:27 2018
@@ -28,6 +28,7 @@ add_clang_library(clangDaemon
   Logger.cpp
   Protocol.cpp
   ProtocolHandlers.cpp
+  Quality.cpp
   SourceCode.cpp
   Threading.cpp
   Trace.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=332378=332377=332378=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Tue May 15 10:43:27 2018
@@ -20,6 +20,7 @@
 #include "FuzzyMatch.h"
 #include "Headers.h"
 #include "Logger.h"
+#include "Quality.h"
 #include "SourceCode.h"
 #include "Trace.h"
 #include "URI.h"
@@ -34,6 +35,9 @@
 #include "llvm/Support/Format.h"
 #include 
 
+// We log detailed candidate here if you run with -debug-only=codecomplete.
+#define DEBUG_TYPE "codecomplete"
+
 namespace clang {
 namespace clangd {
 namespace {
@@ -192,35 +196,6 @@ getOptionalParameters(const CodeCompleti
   return Result;
 }
 
-// Produces an integer that sorts in the same order as F.
-// That is: a < b <==> encodeFloat(a) < encodeFloat(b).
-uint32_t encodeFloat(float F) {
-  static_assert(std::numeric_limits::is_iec559, "");
-  static_assert(sizeof(float) == sizeof(uint32_t), "");
-  constexpr uint32_t TopBit = ~(~uint32_t{0} >> 1);
-
-  // Get the bits of the float. Endianness is the same as for integers.
-  uint32_t U;
-  memcpy(, , sizeof(float));
-  // IEEE 754 floats compare like sign-magnitude integers.
-  if (U & TopBit)// Negative float.
-return 0 - U;// Map onto the low half of integers, order reversed.
-  return U + TopBit; // Positive floats map onto the high half of integers.
-}
-
-// Returns a string that sorts in the same order as (-Score, Name), for LSP.
-std::string sortText(float Score, llvm::StringRef Name) {
-  // We convert -Score to an integer, and hex-encode for readability.
-  // Example: [0.5, "foo"] -> "4100foo"
-  std::string S;
-  llvm::raw_string_ostream OS(S);
-  write_hex(OS, encodeFloat(-Score), llvm::HexPrintStyle::Lower,
-/*Width=*/2 * sizeof(Score));
-  OS << Name;
-  OS.flush();
-  return S;
-}
-
 /// Creates a `HeaderFile` from \p Header which can be either a URI or a 
literal
 /// include.
 static llvm::Expected toHeaderFile(StringRef Header,
@@ -251,33 +226,6 @@ struct CompletionCandidate {
   const CodeCompletionResult *SemaResult = nullptr;
   const Symbol *IndexResult = nullptr;
 
-  // Computes the "symbol quality" score for this completion. Higher is better.
-  float score() const {
-float Score = 1;
-if (IndexResult)
-  Score *= quality(*IndexResult);
-if (SemaResult) {
-  // For now we just use the Sema priority, mapping it onto 

[PATCH] D46845: [libcxx][c++17] P0083R5: Splicing Maps and Sets

2018-05-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D46845#1099732, @mclow.lists wrote:

> >> One way we could deal with this is by adding an attribute to the compiler 
> >> to indicate "the const is a lie", that we can apply to std::pair::first, 
> >> with the semantics being that a top-level const is ignored when 
> >> determining the "real" type of the member (and so mutating the member 
> >> after a const_cast has defined behavior). This would apply to all 
> >> std::pairs, not just the node_handle case, but in practice we don't 
> >> optimize on the basis of a member being declared const *anyway*, so this 
> >> isn't such a big deal right now.
> > 
> > I'm a fan of this idea, this would also have the bonus of fixing some 
> > pre-existing type-punning between pair and pair (see 
> > __hash_value_type and __value_type in  and ).
>
> This was //supposed// to be taken care of by [class.mem]/21 (common initial 
> sequence), but that foundered on "standard-layout".


Also, the common initial sequence rule only allows loads through the wrong 
type, not stores, and in any case does not alter the rule that modifying a 
const object results in UB.


https://reviews.llvm.org/D46845



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


[PATCH] D46747: [Sema] Use dotted form of macOS version for unguarded availability FixIts

2018-05-15 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

> I am now thinking about just switching to dot format in 
> ParseAvailabilityAttribute() because it's much simpler to maintain 
> consistency that way.

Okay, but if we're going to treat underscores as dots while printing 
diagnostics and fixits (which I think we should), then we shouldn't track the 
spelling in VersionTuple: we no longer have any use for it. The only reason 
that VersionTuple supports this is because of r219124, which was written so 
that diagnostic printing would be consistent with how the attribute was 
spelled. Maybe there was a good reason for this, but I can't see the radar that 
was linked in the commit message. Can you look up that radar to see what 
r219124 was actually trying to fix? I don't think we should move forward with 
this until we have that context.

Thanks! 
Erik


https://reviews.llvm.org/D46747



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


[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types

2018-05-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/charconv:89
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+enum class _LIBCPP_ENUM_VIS chars_format

lichray wrote:
> EricWF wrote:
> > We need to hide these names when `_LIBCPP_STD_VER < 17`, since we're not 
> > allowed to introduce new names into namespace `std` in older dialects.
> But this header is backported to C++11, so I intended to not to guard it.
> But this header is backported to C++11, so I intended to not to guard it.

In general, we don't provide new features for old language versions.

The only time we've ever done that is for `string_view`, and I'm **still** not 
sure I did the right thing there.



Comment at: src/charconv.cpp:34
+
+#define APPEND1(i)  \
+do  \

I'd really like to see some numbers here showing how this (somewhat awkward) 
code performs better than the straightforward versions.

Because maintenance is forever.

Note: I'm sure that this was true on older compilers - but is it true today?



Comment at: test/support/charconv_test_helpers.h:24
+
+template 
+constexpr auto

If this is supposed to be a C++17 or later header (and I'm pretty sure it is), 
you should add a `static_assert(TEST_STD_VER > 14, "");` to this header.



Repository:
  rCXX libc++

https://reviews.llvm.org/D41458



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


[PATCH] D39308: [libcxx] Keep track of heap allocated regex states

2018-05-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.
Herald added subscribers: bixia, christof.

What we need to do here is to here is to add a new macro 
`_LIBCPP_ABI_REGEX_MEMORY` in `<__config>` (around line 89) and then make these 
changes available only when this macro is defined.

By default - we get no change.
If `_LIBCPP_ABI_REGEX_MEMORY` is defined, we get the new behavior.

Then we can start adding other ABI changes as well.


https://reviews.llvm.org/D39308



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


[PATCH] D45900: CodeGen: Fix invalid bitcast for lifetime.start/end

2018-05-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

That would work.  I think it would be reasonable for AutoVarEmission to store 
that pointer if it makes things easier.


https://reviews.llvm.org/D45900



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


Re: r332314 - [AST] Fix printing tag decl groups in decl contexts

2018-05-15 Thread Joel E. Denny via cfe-commits
Hi Hans,

On Tue, May 15, 2018 at 6:23 AM, Hans Wennborg  wrote:

> This broke the ast-print-record-decl.c test on Windows, see for
> example http://lab.llvm.org:8011/builders/clang-with-thin-lto-
> windows/builds/9066
>
> One way to reproduce the failure on Linux is to pass a Windows triple
> to this ast-print command:
>
> --- a/test/Misc/ast-print-record-decl.c
> +++ b/test/Misc/ast-print-record-decl.c
> @@ -54,7 +54,7 @@
>  //   RUN:-DKW=struct -DBASES=' : B' -o - -xc++ %s \
>  //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
>  //
> -//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++
> %s \
> +//   RUN: %clang_cc1 -verify -triple i686-pc-win32 -ast-print
> -DKW=struct -DBASES=' : B' -xc++ %s \
>  //   RUN: > %t.cpp
>  //   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
>  //   RUN:   -DBASES=' : B' %s --input-file %t.cpp
>
> What's happening is that on Windows, "__single_inheritance(1)" is
> printed before T1. But if I change the test to allow that in the
> output, it still doesn't pass as Clang doesn't seem able to parse it.
>

The underlying bug is present at least as far back as 4.0.1.  The bug is
revealed by an earlier patch, r332281, simply because it introduces this
test.

There are two parts to this bug.  First, implicit attributes shouldn't
print as that's not faithful to the original source.  I'm addressing that at

https://reviews.llvm.org/D46894

Second, when this attribute is explicit, the "(1)" shouldn't print as it's
not part of the accepted syntax.  I'll address that in another patch.

Thanks.

Joel



>
> I've worked around the problem by adding a Linux triple here in
> r332335, but someone should probably look into it properly.
>
> Thanks,
> Hans
>
> On Tue, May 15, 2018 at 2:44 AM, Joel E. Denny via cfe-commits
>  wrote:
> > Author: jdenny
> > Date: Mon May 14 17:44:14 2018
> > New Revision: 332314
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=332314=rev
> > Log:
> > [AST] Fix printing tag decl groups in decl contexts
> >
> > For example, given:
> >
> >   struct T1 {
> > struct T2 *p0;
> >   };
> >
> > -ast-print produced:
> >
> >   struct T1 {
> > struct T2;
> > struct T2 *p0;
> >   };
> >
> > Compiling that produces a warning that the first struct T2 declaration
> > does not declare anything.
> >
> > Details:
> >
> > A tag decl group is one or more decls that share a type specifier that
> > is a tag decl (that is, a struct/union/class/enum decl).  Within
> > functions, the parser builds such a tag decl group as part of a
> > DeclStmt.  However, in decl contexts, such as file scope or a member
> > list, the parser does not group together the members of a tag decl
> > group.  Previously, detection of tag decl groups during printing was
> > implemented but only if the tag decl was unnamed.  Otherwise, as in
> > the above example, the members of the group did not print together and
> > so sometimes introduced warnings.
> >
> > This patch extends detection of tag decl groups in decl contexts to
> > any tag decl that is recorded in the AST as not free-standing.
> >
> > Reviewed by: rsmith
> >
> > Differential Revision: https://reviews.llvm.org/D45465
> >
> > Modified:
> > cfe/trunk/lib/AST/DeclPrinter.cpp
> > cfe/trunk/test/Misc/ast-print-enum-decl.c
> > cfe/trunk/test/Misc/ast-print-record-decl.c
> > cfe/trunk/test/Sema/ast-print.c
> > cfe/trunk/test/SemaCXX/ast-print.cpp
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46895: add AR to acronyms of clang-tidy property check

2018-05-15 Thread Yan Zhang via Phabricator via cfe-commits
Wizard created this revision.
Herald added subscribers: cfe-commits, klimek.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46895

Files:
  clang-tidy/objc/PropertyDeclarationCheck.cpp


Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -42,6 +42,7 @@
 "[2-9]G",
 "ACL",
 "API",
+"AR",
 "ARGB",
 "ASCII",
 "BGRA",


Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -42,6 +42,7 @@
 "[2-9]G",
 "ACL",
 "API",
+"AR",
 "ARGB",
 "ASCII",
 "BGRA",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46894: [Attr] Don't print implicit attributes

2018-05-15 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.
jdenny added reviewers: aaron.ballman, rsmith, hfinkel.

Fixes bug reported at:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180514/228390.html


https://reviews.llvm.org/D46894

Files:
  lib/AST/DeclPrinter.cpp
  test/Misc/ast-print-record-decl.c


Index: test/Misc/ast-print-record-decl.c
===
--- test/Misc/ast-print-record-decl.c
+++ test/Misc/ast-print-record-decl.c
@@ -54,20 +54,34 @@
 //   RUN:-DKW=struct -DBASES=' : B' -o - -xc++ %s \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print -DKW=struct 
-DBASES=' : B' -xc++ %s \
-//   RUN: > %t.cpp
+//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++ %s \
+//   RUN:> %t.cpp
 //   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
 //   RUN:   -DBASES=' : B' %s --input-file %t.cpp
 //
 //   Now check compiling and printing of the printed file.
 //
-//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.cpp
-//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.cpp
+//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" > %t.diags
+//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked 
deprecated here}}" >> %t.diags
+//   RUN: cat %t.diags >> %t.cpp
 //
 //   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm -o - 
%t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print %t.cpp \
+//   RUN: %clang_cc1 -verify -ast-print %t.cpp \
+//   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
+//   RUN: -DBASES=' : B' %s
+//
+//   Make sure implicit attributes aren't printed.  See comments in inMemberPtr
+//   for details.
+//
+//   RUN: %clang_cc1 -triple i686-pc-win32 -verify -ast-print -DKW=struct \
+//   RUN:-DBASES=' : B' -xc++ %s > %t.cpp
+//   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
+//   RUN:   -DBASES=' : B' %s --input-file %t.cpp
+//
+//   RUN: cat %t.diags >> %t.cpp
+//   RUN: %clang_cc1 -triple i686-pc-win32 -verify -ast-print %t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
 //   RUN: -DBASES=' : B' %s
 
@@ -236,6 +250,9 @@
 #ifdef __cplusplus
 // PRINT-CXX-LABEL: inMemberPtr
 void inMemberPtr() {
+  // Under windows, the implicit attribute __single_inheritance used to print
+  // between KW and T1 here, but that wasn't faithful to the original source.
+  //
   // PRINT-CXX-NEXT: [[KW]] T1 {
   // PRINT-CXX-NEXT:   int i;
   // PRINT-CXX-NEXT: };
Index: lib/AST/DeclPrinter.cpp
===
--- lib/AST/DeclPrinter.cpp
+++ lib/AST/DeclPrinter.cpp
@@ -215,7 +215,7 @@
   if (D->hasAttrs()) {
 AttrVec  = D->getAttrs();
 for (auto *A : Attrs) {
-  if (A->isInherited())
+  if (A->isInherited() || A->isImplicit())
 continue;
   switch (A->getKind()) {
 #define ATTR(X)


Index: test/Misc/ast-print-record-decl.c
===
--- test/Misc/ast-print-record-decl.c
+++ test/Misc/ast-print-record-decl.c
@@ -54,20 +54,34 @@
 //   RUN:-DKW=struct -DBASES=' : B' -o - -xc++ %s \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print -DKW=struct -DBASES=' : B' -xc++ %s \
-//   RUN: > %t.cpp
+//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++ %s \
+//   RUN:> %t.cpp
 //   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
 //   RUN:   -DBASES=' : B' %s --input-file %t.cpp
 //
 //   Now check compiling and printing of the printed file.
 //
-//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.cpp
-//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked deprecated here}}" >> %t.cpp
+//   RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" > %t.diags
+//   RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked deprecated here}}" >> %t.diags
+//   RUN: cat %t.diags >> %t.cpp
 //
 //   RUN: %clang -target x86_64-linux -Xclang -verify -S -emit-llvm -o - %t.cpp \
 //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
 //
-//   RUN: %clang_cc1 -verify -triple x86_64-linux -ast-print %t.cpp \
+//   RUN: %clang_cc1 -verify -ast-print %t.cpp \
+//   RUN: | FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
+//   RUN: -DBASES=' : B' %s
+//
+//   Make sure implicit attributes aren't printed.  See comments in inMemberPtr
+//   for details.
+//
+//   RUN: %clang_cc1 -triple i686-pc-win32 -verify -ast-print -DKW=struct \
+//   RUN:-DBASES=' : B' -xc++ %s > %t.cpp
+//   RUN: FileCheck 

[PATCH] D41347: [libc++] Lift std::errc into a separated header

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

Sorry this took so long. Please update `test/libcxx/double_include.sh.cpp` and 
commit.


Repository:
  rCXX libc++

https://reviews.llvm.org/D41347



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


[PATCH] D46747: [Sema] Use dotted form of macOS version for unguarded availability FixIts

2018-05-15 Thread Jan Korous via Phabricator via cfe-commits
jkorous planned changes to this revision.
jkorous added a comment.

Sorry for me being dense here - since the output format is determined by input 
source code there's more work to do.

I tried to change format of introduced version in couple of tests and the 
output mirrors the change. That basically means that whenever someone uses 
underscore

  __attribute__((availability(macosx, introduced = 10_12)))

instead of dot

  __attribute__((availability(macosx, introduced = 10.12)))

Warnings and FixIts get underscore as well.

I am now thinking about just switching to dot format in 
ParseAvailabilityAttribute() because it's much simpler to maintain consistency 
that way.


https://reviews.llvm.org/D46747



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


[PATCH] D46751: [clangd] Filter out private proto symbols in SymbolCollector.

2018-05-15 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

In https://reviews.llvm.org/D46751#1099786, @sammccall wrote:

> In https://reviews.llvm.org/D46751#1099633, @malaperle wrote:
>
> > In https://reviews.llvm.org/D46751#1099235, @sammccall wrote:
> >
> > > @malaperle to expand on what Eric said, adding proto hacks with false 
> > > positives and no way to turn them off is indeed not the way to go here!
> > >  There's probably going to be other places we want to filter symbols too, 
> > > and it should probably be extensible/customizable in some way.
> > >  We don't yet have enough examples to know what the structure should be 
> > > (something regex based, a code-plugin system based on `Registry`, or 
> > > something in between), thus the simplest/least invasive option for now 
> > > (it's important for our internal rollout to have *some* mitigation in 
> > > place).
> > >  @ioeric can you add a comment near the proto-filtering stuff indicating 
> > > we should work out how to make this extensible?
> >
> >
> > I agree with all of that. What I don't quite understand is why a flag is 
> > not ok? Just a fail-safe switch in the mean time? You can even leave it on 
> > by default so your internal service is not affected.
>
>
> I think a flag doesn't solve much of the problem, and adds new ones:
>
> - users have to find the flag, and work out how to turn it on in their 
> editor, and (other than embedders) few will bother. And each flag hurts the 
> usability of all the other flags.
> - if this heuristic is usable only sometimes, that's at codebase granularity, 
> not user granularity. Flags don't work that way. (Static index currently has 
> this problem...)
> - these flags end up in config files, so if we later remove the flag we'll 
> *completely* break clangd for such users


I don't really agree with those points, but...

>> We know for a fact that some code bases like Houdini won't work with this, 
>> at least there will be an option to make it work.
> 
> Is this still the case after the last revision (with the comment check?)
>  Agree we should only hardwire this on if we are confident that false 
> positives are vanishingly small.

...I hadn't noticed the latest version. I think it's safe enough in the new 
version that we don't need to discuss this much further until it becomes a 
bigger problem (more libraries, etc).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46751



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


[PATCH] D46892: [X86] Lowering adds/addus/subs/subus intrinsics to native IR (Clang part)

2018-05-15 Thread Tomasz Krupa via Phabricator via cfe-commits
tkrupa created this revision.
Herald added a subscriber: cfe-commits.
tkrupa added reviewers: craig.topper, RKSimon, spatel.

This is the patch that lowers x86 intrinsics to native IR
in order to enable optimizations.

Corresponding LLVM part: https://reviews.llvm.org/D46179

Previous https://reviews.llvm.org/D44786 version was reverted due to crashes 
caused by LLVM part. This revision includes a more optimal pattern for addus.


Repository:
  rC Clang

https://reviews.llvm.org/D46892

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/avx2-builtins.c
  test/CodeGen/avx512bw-builtins.c
  test/CodeGen/avx512vlbw-builtins.c
  test/CodeGen/sse2-builtins.c

Index: test/CodeGen/sse2-builtins.c
===
--- test/CodeGen/sse2-builtins.c
+++ test/CodeGen/sse2-builtins.c
@@ -47,25 +47,47 @@
 
 __m128i test_mm_adds_epi8(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_adds_epi8
-  // CHECK: call <16 x i8> @llvm.x86.sse2.padds.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+  // CHECK-NOT: call <16 x i8> @llvm.x86.sse2.padds.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+  // CHECK: sext <16 x i8> %{{.*}} to <16 x i16>
+  // CHECK: sext <16 x i8> %{{.*}} to <16 x i16>
+  // CHECK: add <16 x i16> %{{.*}}, %{{.*}}
+  // CHECK: icmp sle <16 x i16> %{{.*}}, 
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> 
+  // CHECK: icmp slt <16 x i16> %{{.*}}, 
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i16> , <16 x i16> %{{.*}}
+  // CHECK: trunc <16 x i16> %{{.*}} to <16 x i8>
   return _mm_adds_epi8(A, B);
 }
 
 __m128i test_mm_adds_epi16(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_adds_epi16
-  // CHECK: call <8 x i16> @llvm.x86.sse2.padds.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
+  // CHECK-NOT: call <8 x i16> @llvm.x86.sse2.padds.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
+  // CHECK: sext <8 x i16> %{{.*}} to <8 x i32>
+  // CHECK: sext <8 x i16> %{{.*}} to <8 x i32>
+  // CHECK: add <8 x i32> %{{.*}}, %{{.*}}
+  // CHECK: icmp sle <8 x i32> %{{.*}}, 
+  // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> 
+  // CHECK: icmp slt <8 x i32> %{{.*}}, 
+  // CHECK: select <8 x i1> %{{.*}}, <8 x i32> , <8 x i32> %{{.*}}
+  // CHECK: trunc <8 x i32> %{{.*}} to <8 x i16>
   return _mm_adds_epi16(A, B);
 }
 
 __m128i test_mm_adds_epu8(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_adds_epu8
-  // CHECK: call <16 x i8> @llvm.x86.sse2.paddus.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+  // CHECK-NOT: call <16 x i8> @llvm.x86.sse2.paddus.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+  // CHECK: add <16 x i8> %{{.*}}, %{{.*}}
+  // CHECK: icmp ugt <16 x i8> %{{.*}}, %{{.*}}
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i8> , <16 x i8> {{.*}}
   return _mm_adds_epu8(A, B);
 }
 
 __m128i test_mm_adds_epu16(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_adds_epu16
-  // CHECK: call <8 x i16> @llvm.x86.sse2.paddus.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
+  // CHECK-NOT: call <8 x i16> @llvm.x86.sse2.paddus.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
+  // CHECK: add <8 x i16> %{{.*}}, %{{.*}}
+  // CHECK: icmp ugt <8 x i16> %{{.*}}, %{{.*}}
+  // CHECK: select <8 x i1> %{{.*}}, <8 x i16> , <8 x i16> {{.*}}
   return _mm_adds_epu16(A, B);
 }
 
@@ -1416,25 +1438,47 @@
 
 __m128i test_mm_subs_epi8(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_subs_epi8
-  // CHECK: call <16 x i8> @llvm.x86.sse2.psubs.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+  // CHECK-NOT: call <16 x i8> @llvm.x86.sse2.psubs.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+  // CHECK: sext <16 x i8> %{{.*}} to <16 x i16>
+  // CHECK: sext <16 x i8> %{{.*}} to <16 x i16>
+  // CHECK: sub <16 x i16> %{{.*}}, %{{.*}}
+  // CHECK: icmp sle <16 x i16> %{{.*}}, 
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> 
+  // CHECK: icmp slt <16 x i16> %{{.*}}, 
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i16> , <16 x i16> %{{.*}}
+  // CHECK: trunc <16 x i16> %{{.*}} to <16 x i8>
   return _mm_subs_epi8(A, B);
 }
 
 __m128i test_mm_subs_epi16(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_subs_epi16
-  // CHECK: call <8 x i16> @llvm.x86.sse2.psubs.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
+  // CHECK-NOT: call <8 x i16> @llvm.x86.sse2.psubs.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
+  // CHECK: sext <8 x i16> %{{.*}} to <8 x i32>
+  // CHECK: sext <8 x i16> %{{.*}} to <8 x i32>
+  // CHECK: sub <8 x i32> %{{.*}}, %{{.*}}
+  // CHECK: icmp sle <8 x i32> %{{.*}}, 
+  // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> 
+  // CHECK: icmp slt <8 x i32> %{{.*}},  
+  // CHECK: select <8 x i1> %{{.*}}, <8 x i32>  , <8 x i32> %{{.*}}
+  // CHECK: trunc <8 x i32> %{{.*}} to <8 x i16>
   return _mm_subs_epi16(A, B);
 }
 
 __m128i test_mm_subs_epu8(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_subs_epu8
-  // CHECK: call <16 x i8> @llvm.x86.sse2.psubus.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+  // CHECK-NOT: call <16 x i8> @llvm.x86.sse2.psubus.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+  

[PATCH] D46751: [clangd] Filter out private proto symbols in SymbolCollector.

2018-05-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In https://reviews.llvm.org/D46751#1099633, @malaperle wrote:

> In https://reviews.llvm.org/D46751#1099235, @sammccall wrote:
>
> > @malaperle to expand on what Eric said, adding proto hacks with false 
> > positives and no way to turn them off is indeed not the way to go here!
> >  There's probably going to be other places we want to filter symbols too, 
> > and it should probably be extensible/customizable in some way.
> >  We don't yet have enough examples to know what the structure should be 
> > (something regex based, a code-plugin system based on `Registry`, or 
> > something in between), thus the simplest/least invasive option for now 
> > (it's important for our internal rollout to have *some* mitigation in 
> > place).
> >  @ioeric can you add a comment near the proto-filtering stuff indicating we 
> > should work out how to make this extensible?
>
>
> I agree with all of that. What I don't quite understand is why a flag is not 
> ok? Just a fail-safe switch in the mean time? You can even leave it on by 
> default so your internal service is not affected.


I think a flag doesn't solve much of the problem, and adds new ones:

- users have to find the flag, and work out how to turn it on in their editor, 
and (other than embedders) few will bother. And each flag hurts the usability 
of all the other flags.
- if this heuristic is usable only sometimes, that's at codebase granularity, 
not user granularity. Flags don't work that way. (Static index currently has 
this problem...)
- these flags end up in config files, so if we later remove the flag we'll 
*completely* break clangd for such users

> We know for a fact that some code bases like Houdini won't work with this, at 
> least there will be an option to make it work.

Is this still the case after the last revision (with the comment check?)
Agree we should only hardwire this on if we are confident that false positives 
are vanishingly small.




Comment at: clangd/index/SymbolCollector.cpp:101
+// we check whether it starts with PROTO_HEADER_COMMENT.
+bool isPrivateProtoSymbol(const NamedDecl ) {
+  const auto  = ND.getASTContext().getSourceManager();

We're going to end up calling this code on every decl/def we see.
Am I being paranoid by thinking we should check whether the file is a proto 
once, rather than doing a bunch of string matching every time?



Comment at: clangd/index/SymbolCollector.cpp:112
+
+  auto Name = ND.getName();
+  if (!Name.contains('_'))

this asserts if the name is not a simple identifier (Maybe operators or 
something will trigger this?).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46751



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


[PATCH] D46891: [StaticAnalyzer] Added a getLValue method to ProgramState for bases

2018-05-15 Thread Umann KristĂłf via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: xazax.hun, NoQ.
Herald added subscribers: cfe-commits, a.sidorin, rnkovacs, szepet, whisperity.
Herald added a reviewer: george.karpenkov.

Repository:
  rC Clang

https://reviews.llvm.org/D46891

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h


Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -294,6 +294,9 @@
   ProgramStateRef enterStackFrame(const CallEvent ,
   const StackFrameContext *CalleeCtx) const;
 
+  /// Get the lvalue for a base class object reference.
+  Loc getLValue(const CXXBaseSpecifier , const SubRegion *Super) 
const;
+
   /// Get the lvalue for a variable reference.
   Loc getLValue(const VarDecl *D, const LocationContext *LC) const;
 
@@ -724,6 +727,14 @@
   return this;
 }
 
+inline Loc ProgramState::getLValue(const CXXBaseSpecifier ,
+   const SubRegion *Super) const {
+  const auto Base = BaseSpec.getType()->getAsCXXRecordDecl();
+  return loc::MemRegionVal(
+  getStateManager().getRegionManager().getCXXBaseObjectRegion(
+Base, Super, 
BaseSpec.isVirtual()));
+}
+
 inline Loc ProgramState::getLValue(const VarDecl *VD,
const LocationContext *LC) const {
   return getStateManager().StoreMgr->getLValueVar(VD, LC);


Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -294,6 +294,9 @@
   ProgramStateRef enterStackFrame(const CallEvent ,
   const StackFrameContext *CalleeCtx) const;
 
+  /// Get the lvalue for a base class object reference.
+  Loc getLValue(const CXXBaseSpecifier , const SubRegion *Super) const;
+
   /// Get the lvalue for a variable reference.
   Loc getLValue(const VarDecl *D, const LocationContext *LC) const;
 
@@ -724,6 +727,14 @@
   return this;
 }
 
+inline Loc ProgramState::getLValue(const CXXBaseSpecifier ,
+   const SubRegion *Super) const {
+  const auto Base = BaseSpec.getType()->getAsCXXRecordDecl();
+  return loc::MemRegionVal(
+  getStateManager().getRegionManager().getCXXBaseObjectRegion(
+Base, Super, BaseSpec.isVirtual()));
+}
+
 inline Loc ProgramState::getLValue(const VarDecl *VD,
const LocationContext *LC) const {
   return getStateManager().StoreMgr->getLValueVar(VD, LC);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44976: Change DEBUG() macro to LLVM_DEBUG() in clang-tools-extra

2018-05-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332371: [clang-tools-extra] Update uses of DEBUG macro to 
LLVM_DEBUG. (authored by nzaghen, committed by ).
Herald added subscribers: llvm-commits, klimek.

Changed prior to commit:
  https://reviews.llvm.org/D44976?vs=140056=146860#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44976

Files:
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/clang-move/HelperDeclRefGraph.cpp
  clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
  clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp

Index: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
===
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
@@ -97,8 +97,8 @@
   Symbols.insert(Symbols.end(), Res.begin(), Res.end());
 }
 
-DEBUG(llvm::dbgs() << "Searching " << Names.back() << "... got "
-   << Symbols.size() << " results...\n");
+LLVM_DEBUG(llvm::dbgs() << "Searching " << Names.back() << "... got "
+<< Symbols.size() << " results...\n");
 
 for (auto  : Symbols) {
   const SymbolInfo  = SymAndSig.Symbol;
Index: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
===
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
@@ -156,7 +156,8 @@
   clang::ASTContext  = CI->getASTContext();
   std::string QueryString = QualType(T->getUnqualifiedDesugaredType(), 0)
 .getAsString(context.getPrintingPolicy());
-  DEBUG(llvm::dbgs() << "Query missing complete type '" << QueryString << "'");
+  LLVM_DEBUG(llvm::dbgs() << "Query missing complete type '" << QueryString
+  << "'");
   // Pass an empty range here since we don't add qualifier in this case.
   std::vector MatchedSymbols =
   query(QueryString, "", tooling::Range());
@@ -276,7 +277,8 @@
 SymbolRange = CreateToolingRange(Typo.getLoc());
   }
 
-  DEBUG(llvm::dbgs() << "TypoScopeQualifiers: " << TypoScopeString << "\n");
+  LLVM_DEBUG(llvm::dbgs() << "TypoScopeQualifiers: " << TypoScopeString
+  << "\n");
   std::vector MatchedSymbols =
   query(QueryString, TypoScopeString, SymbolRange);
 
@@ -357,12 +359,12 @@
 return {};
   }
 
-  DEBUG(llvm::dbgs() << "Looking up '" << Query << "' at ");
-  DEBUG(CI->getSourceManager()
-.getLocForStartOfFile(CI->getSourceManager().getMainFileID())
-.getLocWithOffset(Range.getOffset())
-.print(llvm::dbgs(), CI->getSourceManager()));
-  DEBUG(llvm::dbgs() << " ...");
+  LLVM_DEBUG(llvm::dbgs() << "Looking up '" << Query << "' at ");
+  LLVM_DEBUG(CI->getSourceManager()
+ .getLocForStartOfFile(CI->getSourceManager().getMainFileID())
+ .getLocWithOffset(Range.getOffset())
+ .print(llvm::dbgs(), CI->getSourceManager()));
+  LLVM_DEBUG(llvm::dbgs() << " ...");
   llvm::StringRef FileName = CI->getSourceManager().getFilename(
   CI->getSourceManager().getLocForStartOfFile(
   CI->getSourceManager().getMainFileID()));
@@ -390,8 +392,8 @@
   if (MatchedSymbols.empty())
 MatchedSymbols =
 SymbolIndexMgr.search(Query, /*IsNestedSearch=*/true, FileName);
-  DEBUG(llvm::dbgs() << "Having found " << MatchedSymbols.size()
- << " symbols\n");
+  LLVM_DEBUG(llvm::dbgs() << "Having found " << MatchedSymbols.size()
+  << " symbols\n");
   // We store a copy of MatchedSymbols in a place where it's globally reachable.
   // This is used by the standalone version of the tool.
   this->MatchedSymbols = MatchedSymbols;
Index: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
@@ -225,7 +225,8 @@
 // similar.
 std::vector
 FileOptionsProvider::getRawOptions(StringRef FileName) {
-  DEBUG(llvm::dbgs() << "Getting options for file " << FileName << "...\n");
+  LLVM_DEBUG(llvm::dbgs() << "Getting options for file " << FileName
+  << "...\n");
   assert(FS && "FS must be set.");
 
   llvm::SmallString<128> AbsoluteFilePath(FileName);
@@ -254,8 +255,8 @@
 if (Result) {
   // Store cached value for all intermediate directories.
   while (Path != CurrentPath) {
-DEBUG(llvm::dbgs() << "Caching configuration for path " << Path
-   << ".\n");
+LLVM_DEBUG(llvm::dbgs()
+

[clang-tools-extra] r332371 - [clang-tools-extra] Update uses of DEBUG macro to LLVM_DEBUG.

2018-05-15 Thread Nicola Zaghen via cfe-commits
Author: nzaghen
Date: Tue May 15 09:37:45 2018
New Revision: 332371

URL: http://llvm.org/viewvc/llvm-project?rev=332371=rev
Log:
[clang-tools-extra] Update uses of DEBUG macro to LLVM_DEBUG.

The DEBUG() macro is very generic so it might clash with other projects.
The renaming was done as follows:
- git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g'
- git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 
-style LLVM

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


Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/clang-move/HelperDeclRefGraph.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=332371=332370=332371=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Tue May 15 09:37:45 2018
@@ -680,8 +680,8 @@ void ClangMoveTool::run(const ast_matche
  Result.Nodes.getNodeAs("helper_decls")) {
 MovedDecls.push_back(ND);
 HelperDeclarations.push_back(ND);
-DEBUG(llvm::dbgs() << "Add helper : "
-   << ND->getNameAsString() << " (" << ND << ")\n");
+LLVM_DEBUG(llvm::dbgs() << "Add helper : " << ND->getNameAsString() << " ("
+<< ND << ")\n");
   } else if (const auto *UD =
  Result.Nodes.getNodeAs("using_decl")) {
 MovedDecls.push_back(UD);
@@ -741,12 +741,12 @@ void ClangMoveTool::removeDeclsInOldFile
 // We remove the helper declarations which are not used in the old.cc after
 // moving the given declarations.
 for (const auto *D : HelperDeclarations) {
-  DEBUG(llvm::dbgs() << "Check helper is used: "
- << D->getNameAsString() << " (" << D << ")\n");
+  LLVM_DEBUG(llvm::dbgs() << "Check helper is used: "
+  << D->getNameAsString() << " (" << D << ")\n");
   if (!UsedDecls.count(HelperDeclRGBuilder::getOutmostClassOrFunDecl(
   D->getCanonicalDecl( {
-DEBUG(llvm::dbgs() << "Helper removed in old.cc: "
-   << D->getNameAsString() << " (" << D << ")\n");
+LLVM_DEBUG(llvm::dbgs() << "Helper removed in old.cc: "
+<< D->getNameAsString() << " (" << D << ")\n");
 RemovedDecls.push_back(D);
   }
 }
@@ -826,8 +826,8 @@ void ClangMoveTool::moveDeclsToNewFiles(
 D->getCanonicalDecl(
   continue;
 
-DEBUG(llvm::dbgs() << "Helper used in new.cc: " << D->getNameAsString()
-   << " " << D << "\n");
+LLVM_DEBUG(llvm::dbgs() << "Helper used in new.cc: " << 
D->getNameAsString()
+<< " " << D << "\n");
 ActualNewCCDecls.push_back(D);
   }
 
@@ -937,7 +937,7 @@ void ClangMoveTool::onEndOfTranslationUn
 moveAll(SM, Context->Spec.OldCC, Context->Spec.NewCC);
 return;
   }
-  DEBUG(RGBuilder.getGraph()->dump());
+  LLVM_DEBUG(RGBuilder.getGraph()->dump());
   moveDeclsToNewFiles();
   removeDeclsInOldFiles();
 }

Modified: clang-tools-extra/trunk/clang-move/HelperDeclRefGraph.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/HelperDeclRefGraph.cpp?rev=332371=332370=332371=diff
==
--- clang-tools-extra/trunk/clang-move/HelperDeclRefGraph.cpp (original)
+++ clang-tools-extra/trunk/clang-move/HelperDeclRefGraph.cpp Tue May 15 
09:37:45 2018
@@ -116,9 +116,9 @@ void HelperDeclRGBuilder::run(
   if (const auto *FuncRef = Result.Nodes.getNodeAs("func_ref")) {
 const auto *DC = Result.Nodes.getNodeAs("dc");
 assert(DC);
-DEBUG(llvm::dbgs() << "Find helper function usage: "
-   << FuncRef->getDecl()->getNameAsString() << " ("
-   << FuncRef->getDecl() << ")\n");
+LLVM_DEBUG(llvm::dbgs() << "Find helper function usage: "
+<< FuncRef->getDecl()->getNameAsString() << " ("
+<< FuncRef->getDecl() << ")\n");
 RG->addEdge(
 getOutmostClassOrFunDecl(DC->getCanonicalDecl()),
 getOutmostClassOrFunDecl(FuncRef->getDecl()->getCanonicalDecl()));
@@ -126,9 +126,9 @@ void HelperDeclRGBuilder::run(
  Result.Nodes.getNodeAs("used_class")) {
 const auto *DC = Result.Nodes.getNodeAs("dc");
 assert(DC);
-DEBUG(llvm::dbgs() << "Find helper class usage: "
-   << UsedClass->getNameAsString() << " (" << UsedClass
- 

r332370 - update two comments as suggested on https://reviews.llvm.org/D46843

2018-05-15 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue May 15 09:37:00 2018
New Revision: 332370

URL: http://llvm.org/viewvc/llvm-project?rev=332370=rev
Log:
update two comments as suggested on https://reviews.llvm.org/D46843

Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=332370=332369=332370=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Tue May 15 09:37:00 2018
@@ -9,8 +9,7 @@ elseif(LLVM_USE_SANITIZE_COVERAGE)
   unset(DUMMY_MAIN)
 endif()
 
-# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
-# executables from this directory.
+# Needed by LLVM's CMake checks because this file defines multiple targets.
 set(LLVM_OPTIONAL_SOURCES
   ClangFuzzer.cpp
   DummyClangFuzzer.cpp

Modified: cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt?rev=332370=332369=332370=diff
==
--- cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt Tue May 15 
09:37:00 2018
@@ -1,8 +1,7 @@
 set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
 set(CMAKE_CXX_FLAGS ${CXX_FLAGS_NOFUZZ})
 
-# Hack to bypass LLVM's CMake source checks so we can have both a library and
-# an executable built from this directory.
+# Needed by LLVM's CMake checks because this file defines multiple targets.
 set(LLVM_OPTIONAL_SOURCES proto_to_cxx.cpp proto_to_cxx_main.cpp)
 
 add_clang_library(clangProtoToCXX proto_to_cxx.cpp


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


[PATCH] D46845: [libcxx][c++17] P0083R5: Splicing Maps and Sets

2018-05-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

>> One way we could deal with this is by adding an attribute to the compiler to 
>> indicate "the const is a lie", that we can apply to std::pair::first, with 
>> the semantics being that a top-level const is ignored when determining the 
>> "real" type of the member (and so mutating the member after a const_cast has 
>> defined behavior). This would apply to all std::pairs, not just the 
>> node_handle case, but in practice we don't optimize on the basis of a member 
>> being declared const *anyway*, so this isn't such a big deal right now.
> 
> I'm a fan of this idea, this would also have the bonus of fixing some 
> pre-existing type-punning between pair and pair (see 
> __hash_value_type and __value_type in  and ).

This was //supposed// to be taken care of by [class.mem]/21 (common initial 
sequence), but that foundered on "standard-layout".


https://reviews.llvm.org/D46845



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


[clang-tools-extra] r332366 - [clangd] Log error message instead write to errs(). NFC

2018-05-15 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue May 15 09:22:43 2018
New Revision: 332366

URL: http://llvm.org/viewvc/llvm-project?rev=332366=rev
Log:
[clangd] Log error message instead write to errs(). NFC

Modified:
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=332366=332365=332366=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Tue May 15 
09:22:43 2018
@@ -51,8 +51,7 @@ llvm::Optional toURI(const
   if (std::error_code EC =
   SM.getFileManager().getVirtualFileSystem()->makeAbsolute(
   AbsolutePath))
-llvm::errs() << "Warning: could not make absolute file: '" << EC.message()
- << '\n';
+log("Warning: could not make absolute file: " + EC.message());
   if (llvm::sys::path::is_absolute(AbsolutePath)) {
 // Handle the symbolic link path case where the current working directory
 // (getCurrentWorkingDirectory) is a symlink./ We always want to the real


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


[PATCH] D46835: [ASTImporter] Do not try to remove invisible Decls from DeclContext

2018-05-15 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 146847.
martong added a comment.

- Remove unrelated CXX14 changes


Repository:
  rC Clang

https://reviews.llvm.org/D46835

Files:
  lib/AST/DeclBase.cpp
  unittests/AST/ASTImporterTest.cpp
  unittests/AST/MatchVerifier.h


Index: unittests/AST/MatchVerifier.h
===
--- unittests/AST/MatchVerifier.h
+++ unittests/AST/MatchVerifier.h
@@ -28,7 +28,7 @@
 namespace clang {
 namespace ast_matchers {
 
-enum Language { 
+enum Language {
 Lang_C,
 Lang_C89,
 Lang_CXX,
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -1764,5 +1764,38 @@
  compoundStmt(has(callExpr(has(unresolvedMemberExpr());
 }
 
+struct DeclContextTest : ASTImporterTestBase {};
+
+TEST_P(DeclContextTest, removeDeclOfClassTemplateSpecialization) {
+  Decl *TU = getTuDecl(
+  R"(
+  namespace NS {
+
+  template 
+  struct S {};
+  template struct S;
+
+  inline namespace INS {
+template 
+struct S {};
+template struct S;
+  }
+
+  }
+  )", Lang_CXX11, "input0.cc");
+  auto *NS = FirstDeclMatcher().match(
+  TU, namespaceDecl());
+  auto *Spec = FirstDeclMatcher().match(
+  TU, classTemplateSpecializationDecl());
+  ASSERT_TRUE(NS->containsDecl(Spec));
+
+  NS->removeDecl(Spec);
+  EXPECT_FALSE(NS->containsDecl(Spec));
+}
+
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, DeclContextTest,
+::testing::Values(ArgVector(), ArgVector{"-fdelayed-template-parsing"}),);
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/DeclBase.cpp
===
--- lib/AST/DeclBase.cpp
+++ lib/AST/DeclBase.cpp
@@ -1350,6 +1350,8 @@
   (D->NextInContextAndBits.getPointer() || D == LastDecl));
 }
 
+static bool shouldBeHidden(NamedDecl *D);
+
 void DeclContext::removeDecl(Decl *D) {
   assert(D->getLexicalDeclContext() == this &&
  "decl being removed from non-lexical context");
@@ -1372,14 +1374,18 @@
   }
 }
   }
-  
+
   // Mark that D is no longer in the decl chain.
   D->NextInContextAndBits.setPointer(nullptr);
 
   // Remove D from the lookup table if necessary.
   if (isa(D)) {
 auto *ND = cast(D);
 
+// Do not try to remove the declaration if that is invisible to qualified
+// lookup.  E.g. template specializations are skipped.
+if (shouldBeHidden(ND)) return;
+
 // Remove only decls that have a name
 if (!ND->getDeclName()) return;
 


Index: unittests/AST/MatchVerifier.h
===
--- unittests/AST/MatchVerifier.h
+++ unittests/AST/MatchVerifier.h
@@ -28,7 +28,7 @@
 namespace clang {
 namespace ast_matchers {
 
-enum Language { 
+enum Language {
 Lang_C,
 Lang_C89,
 Lang_CXX,
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -1764,5 +1764,38 @@
  compoundStmt(has(callExpr(has(unresolvedMemberExpr());
 }
 
+struct DeclContextTest : ASTImporterTestBase {};
+
+TEST_P(DeclContextTest, removeDeclOfClassTemplateSpecialization) {
+  Decl *TU = getTuDecl(
+  R"(
+  namespace NS {
+
+  template 
+  struct S {};
+  template struct S;
+
+  inline namespace INS {
+template 
+struct S {};
+template struct S;
+  }
+
+  }
+  )", Lang_CXX11, "input0.cc");
+  auto *NS = FirstDeclMatcher().match(
+  TU, namespaceDecl());
+  auto *Spec = FirstDeclMatcher().match(
+  TU, classTemplateSpecializationDecl());
+  ASSERT_TRUE(NS->containsDecl(Spec));
+
+  NS->removeDecl(Spec);
+  EXPECT_FALSE(NS->containsDecl(Spec));
+}
+
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, DeclContextTest,
+::testing::Values(ArgVector(), ArgVector{"-fdelayed-template-parsing"}),);
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/DeclBase.cpp
===
--- lib/AST/DeclBase.cpp
+++ lib/AST/DeclBase.cpp
@@ -1350,6 +1350,8 @@
   (D->NextInContextAndBits.getPointer() || D == LastDecl));
 }
 
+static bool shouldBeHidden(NamedDecl *D);
+
 void DeclContext::removeDecl(Decl *D) {
   assert(D->getLexicalDeclContext() == this &&
  "decl being removed from non-lexical context");
@@ -1372,14 +1374,18 @@
   }
 }
   }
-  
+
   // Mark that D is no longer in the decl chain.
   D->NextInContextAndBits.setPointer(nullptr);
 
   // Remove D from the lookup table if necessary.
   if (isa(D)) {
 auto *ND = cast(D);
 
+// Do not try to remove the declaration if that is invisible to qualified
+// lookup.  E.g. template specializations are 

[PATCH] D46835: [ASTImporter] Do not try to remove invisible Decls from DeclContext

2018-05-15 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 146845.
martong marked 4 inline comments as done.
martong added a comment.

- Add test for removeDecl, remove unrelated tests


Repository:
  rC Clang

https://reviews.llvm.org/D46835

Files:
  lib/AST/DeclBase.cpp
  unittests/AST/ASTImporterTest.cpp
  unittests/AST/MatchVerifier.h

Index: unittests/AST/MatchVerifier.h
===
--- unittests/AST/MatchVerifier.h
+++ unittests/AST/MatchVerifier.h
@@ -28,11 +28,12 @@
 namespace clang {
 namespace ast_matchers {
 
-enum Language { 
+enum Language {
 Lang_C,
 Lang_C89,
 Lang_CXX,
 Lang_CXX11,
+Lang_CXX14,
 Lang_OpenCL,
 Lang_OBJCXX
 };
@@ -113,6 +114,10 @@
 Args.push_back("-std=c++11");
 FileName = "input.cc";
 break;
+  case Lang_CXX14:
+Args.push_back("-std=c++14");
+FileName = "input.cc";
+break;
   case Lang_OpenCL:
 FileName = "input.cl";
 break;
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -52,6 +52,9 @@
   case Lang_CXX11:
 BasicArgs = {"-std=c++11", "-frtti"};
 break;
+  case Lang_CXX14:
+BasicArgs = {"-std=c++14", "-frtti"};
+break;
   case Lang_OpenCL:
   case Lang_OBJCXX:
 llvm_unreachable("Not implemented yet!");
@@ -1764,5 +1767,38 @@
  compoundStmt(has(callExpr(has(unresolvedMemberExpr());
 }
 
+struct DeclContextTest : ASTImporterTestBase {};
+
+TEST_P(DeclContextTest, removeDeclOfClassTemplateSpecialization) {
+  Decl *TU = getTuDecl(
+  R"(
+  namespace NS {
+
+  template 
+  struct S {};
+  template struct S;
+
+  inline namespace INS {
+template 
+struct S {};
+template struct S;
+  }
+
+  }
+  )", Lang_CXX11, "input0.cc");
+  auto *NS = FirstDeclMatcher().match(
+  TU, namespaceDecl());
+  auto *Spec = FirstDeclMatcher().match(
+  TU, classTemplateSpecializationDecl());
+  ASSERT_TRUE(NS->containsDecl(Spec));
+
+  NS->removeDecl(Spec);
+  EXPECT_FALSE(NS->containsDecl(Spec));
+}
+
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, DeclContextTest,
+::testing::Values(ArgVector(), ArgVector{"-fdelayed-template-parsing"}),);
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/DeclBase.cpp
===
--- lib/AST/DeclBase.cpp
+++ lib/AST/DeclBase.cpp
@@ -1350,6 +1350,8 @@
   (D->NextInContextAndBits.getPointer() || D == LastDecl));
 }
 
+static bool shouldBeHidden(NamedDecl *D);
+
 void DeclContext::removeDecl(Decl *D) {
   assert(D->getLexicalDeclContext() == this &&
  "decl being removed from non-lexical context");
@@ -1372,14 +1374,18 @@
   }
 }
   }
-  
+
   // Mark that D is no longer in the decl chain.
   D->NextInContextAndBits.setPointer(nullptr);
 
   // Remove D from the lookup table if necessary.
   if (isa(D)) {
 auto *ND = cast(D);
 
+// Do not try to remove the declaration if that is invisible to qualified
+// lookup.  E.g. template specializations are skipped.
+if (shouldBeHidden(ND)) return;
+
 // Remove only decls that have a name
 if (!ND->getDeclName()) return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46835: [ASTImporter] Do not try to remove invisible Decls from DeclContext

2018-05-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Hi Aleksei,

Thanks for reviewing this.
I could synthesize a test which exercises only the `DeclContext::removeDecl` 
function. This test causes an assertion without the fix.
Removed the rest of the testcases, which are not strictly connected to this 
change.




Comment at: unittests/AST/ASTImporterTest.cpp:1827
+
+TEST_P(ASTImporterTestBase, DISABLED_ImportOfRecordWithDifferentFriends) {
+  Decl *ToR1;

a.sidorin wrote:
> For this change, we should create a separate patch.
This test is disabled ATM, but I agree it would be better to bring this in when 
we fix the import of friends.


Repository:
  rC Clang

https://reviews.llvm.org/D46835



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


[PATCH] D46834: [Sema][Cxx17] Error message for C++17 static_assert(pred) without string literal

2018-05-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

(Somehow I missed Richard's comment when I replied last night, even though it 
preceded mine by 5 hours...)

In https://reviews.llvm.org/D46834#1098727, @rsmith wrote:

> This would violate our guidelines for diagnostic messages; see 
> https://clang.llvm.org/docs/InternalsManual.html#the-format-string
>
> In particular: "Take advantage of location information. The user will be able 
> to see the line and location of the caret, so you don’t need to tell them 
> that the problem is with the 4th argument to the function: just point to it."
>
> > Reasons why printing assert expression in absence of string literal is 
> > useful are:
> > 
> > 1. Serialized diagnostics (--serialize-diagnostics) don't contain code 
> > snippet and thus error message lack context.
> > 2. Not all tools scraping clang diagnostics use caret snippet provided by 
> > -fcaret-diagnostics.
>
> This seems like an excellent reason to fix those tools -- per our 
> documentation, Clang's diagnostics are not designed to be used without the 
> caret and snippet.
>
> If you want to change our diagnostic policy from "the diagnostic text plus 
> the line and location of the caret should be enough to identify the problem; 
> do not repeat information in the diagnostic that the caret portion shows" to 
> "the diagnostic text alone should be sufficient", that's certainly something 
> we can discuss, but you'll need to make the case for why that's a good change 
> of policy.


I wasn't aware of the policy.  I can't convince myself that `static_assert` 
should be an exception to it.

It's ironic, though.  What I'm concerned about are interfaces like a Vim 
location list, a condensed view of diagnostics that won't show the source until 
you select a particular diagnostic.  The status quo may lead some users to 
leverage a macro like this to hack the location list view:

  #define MY_STATIC_ASSERT(X) static_assert(X, #X)

getting rid of which was the motivation for the single-argument `static_assert` 
in the first place.


Repository:
  rC Clang

https://reviews.llvm.org/D46834



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


[clang-tools-extra] r332363 - [clangd] Populate #include insertions as additional edits in completion items.

2018-05-15 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue May 15 08:29:32 2018
New Revision: 332363

URL: http://llvm.org/viewvc/llvm-project?rev=332363=rev
Log:
[clangd] Populate #include insertions as additional edits in completion items.

Summary:
o Remove IncludeInsertion LSP command.
o Populate include insertion edits synchromously in completion items.
o Share the code completion compiler instance and precompiled preamble to get 
existing inclusions in main file.
o Include insertion logic lives only in CodeComplete now.
o Use tooling::HeaderIncludes for inserting new includes.
o Refactored tests.

Reviewers: sammccall

Reviewed By: sammccall

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

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

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/CodeComplete.h
clang-tools-extra/trunk/clangd/Headers.cpp
clang-tools-extra/trunk/clangd/Headers.h
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
clang-tools-extra/trunk/unittests/clangd/HeadersTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=332363=332362=332363=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue May 15 08:29:32 2018
@@ -161,6 +161,7 @@ void ClangdServer::codeComplete(PathRef
 // both the old and the new version in case only one of them matches.
 CompletionList Result = clangd::codeComplete(
 File, IP->Command, PreambleData ? >Preamble : nullptr,
+PreambleData ? PreambleData->Inclusions : std::vector(),
 IP->Contents, Pos, FS, PCHs, CodeCompleteOpts);
 CB(std::move(Result));
   };

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=332363=332362=332363=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Tue May 15 08:29:32 2018
@@ -18,9 +18,11 @@
 #include "CodeCompletionStrings.h"
 #include "Compiler.h"
 #include "FuzzyMatch.h"
+#include "Headers.h"
 #include "Logger.h"
 #include "SourceCode.h"
 #include "Trace.h"
+#include "URI.h"
 #include "index/Index.h"
 #include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
@@ -219,6 +221,28 @@ std::string sortText(float Score, llvm::
   return S;
 }
 
+/// Creates a `HeaderFile` from \p Header which can be either a URI or a 
literal
+/// include.
+static llvm::Expected toHeaderFile(StringRef Header,
+   llvm::StringRef HintPath) {
+  if (isLiteralInclude(Header))
+return HeaderFile{Header.str(), /*Verbatim=*/true};
+  auto U = URI::parse(Header);
+  if (!U)
+return U.takeError();
+
+  auto IncludePath = URI::includeSpelling(*U);
+  if (!IncludePath)
+return IncludePath.takeError();
+  if (!IncludePath->empty())
+return HeaderFile{std::move(*IncludePath), /*Verbatim=*/true};
+
+  auto Resolved = URI::resolve(*U, HintPath);
+  if (!Resolved)
+return Resolved.takeError();
+  return HeaderFile{std::move(*Resolved), /*Verbatim=*/false};
+}
+
 /// A code completion result, in clang-native form.
 /// It may be promoted to a CompletionItem if it's among the top-ranked 
results.
 struct CompletionCandidate {
@@ -255,10 +279,10 @@ struct CompletionCandidate {
   }
 
   // Builds an LSP completion item.
-  CompletionItem build(llvm::StringRef FileName,
-   const CompletionItemScores ,
+  CompletionItem build(StringRef FileName, const CompletionItemScores ,
const CodeCompleteOptions ,
-   CodeCompletionString *SemaCCS) const {
+   CodeCompletionString *SemaCCS,
+   const IncludeInserter *Includes) const {
 assert(bool(SemaResult) == bool(SemaCCS));
 CompletionItem I;
 if (SemaResult) {
@@ -289,6 +313,30 @@ struct CompletionCandidate {
   I.documentation = D->Documentation;
 if (I.detail.empty())
   I.detail = D->CompletionDetail;
+if (Includes && !D->IncludeHeader.empty()) {
+  auto Edit = [&]() -> Expected {
+auto ResolvedDeclaring = toHeaderFile(
+IndexResult->CanonicalDeclaration.FileURI, FileName);
+if (!ResolvedDeclaring)
+  return ResolvedDeclaring.takeError();
+auto ResolvedInserted = toHeaderFile(D->IncludeHeader, FileName);
+if (!ResolvedInserted)
+  return ResolvedInserted.takeError();
+return 

[PATCH] D46497: [clangd] Populate #include insertions as additional edits in completion items.

2018-05-15 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE332363: [clangd] Populate #include insertions as 
additional edits in completion items. (authored by ioeric, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46497?vs=146843=146844#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46497

Files:
  clangd/ClangdServer.cpp
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/Headers.cpp
  clangd/Headers.h
  clangd/Protocol.h
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/HeadersTests.cpp

Index: clangd/Headers.h
===
--- clangd/Headers.h
+++ clangd/Headers.h
@@ -12,10 +12,14 @@
 
 #include "Path.h"
 #include "Protocol.h"
+#include "SourceCode.h"
 #include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Format/Format.h"
+#include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/PPCallbacks.h"
-#include "clang/Tooling/CompilationDatabase.h"
+#include "clang/Tooling/Core/HeaderIncludes.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Error.h"
 
 namespace clang {
@@ -51,20 +55,51 @@
 /// 'Foo/Bar.h' over a longer one like 'Baz/include/Foo/Bar.h'.
 ///
 /// \param File is an absolute file path.
+/// \param Inclusions Existing inclusions in the main file.
 /// \param DeclaringHeader is the original header corresponding to \p
 /// InsertedHeader e.g. the header that declares a symbol.
 /// \param InsertedHeader The preferred header to be inserted. This could be the
 /// same as DeclaringHeader but must be provided.
 //  \return A quoted "path" or . This returns an empty string if:
 ///   - Either \p DeclaringHeader or \p InsertedHeader is already (directly)
-///   included in the file (including those included via different paths).
+///   in \p Inclusions (including those included via different paths).
 ///   - \p DeclaringHeader or \p InsertedHeader is the same as \p File.
-llvm::Expected
-calculateIncludePath(PathRef File, llvm::StringRef Code,
- const HeaderFile ,
- const HeaderFile ,
- const tooling::CompileCommand ,
- IntrusiveRefCntPtr FS);
+llvm::Expected calculateIncludePath(
+PathRef File, StringRef BuildDir, HeaderSearch ,
+const std::vector , const HeaderFile ,
+const HeaderFile );
+
+// Calculates insertion edit for including a new header in a file.
+class IncludeInserter {
+public:
+  IncludeInserter(StringRef FileName, StringRef Code,
+  const format::FormatStyle , StringRef BuildDir,
+  HeaderSearch )
+  : FileName(FileName), Code(Code), BuildDir(BuildDir),
+HeaderSearchInfo(HeaderSearchInfo),
+Inserter(FileName, Code, Style.IncludeStyle) {}
+
+  void addExisting(Inclusion Inc) { Inclusions.push_back(std::move(Inc)); }
+
+  /// Returns a TextEdit that inserts a new header; if the header is not
+  /// inserted e.g. it's an existing header, this returns None. If any header is
+  /// invalid, this returns error.
+  ///
+  /// \param DeclaringHeader is the original header corresponding to \p
+  /// InsertedHeader e.g. the header that declares a symbol.
+  /// \param InsertedHeader The preferred header to be inserted. This could be
+  /// the same as DeclaringHeader but must be provided.
+  Expected insert(const HeaderFile ,
+  const HeaderFile ) const;
+
+private:
+  StringRef FileName;
+  StringRef Code;
+  StringRef BuildDir;
+  HeaderSearch 
+  std::vector Inclusions;
+  tooling::HeaderIncludes Inserter; // Computers insertion replacement.
+};
 
 } // namespace clangd
 } // namespace clang
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETE_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETE_H
 
+#include "Headers.h"
 #include "Logger.h"
 #include "Path.h"
 #include "Protocol.h"
@@ -69,6 +70,7 @@
 CompletionList codeComplete(PathRef FileName,
 const tooling::CompileCommand ,
 PrecompiledPreamble const *Preamble,
+const std::vector ,
 StringRef Contents, Position Pos,
 IntrusiveRefCntPtr VFS,
 std::shared_ptr PCHs,
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -161,6 +161,7 @@
 // both the old and the new version in case only one of them matches.
 CompletionList Result = clangd::codeComplete(
 File, IP->Command, PreambleData ? >Preamble : nullptr,
+PreambleData ? PreambleData->Inclusions : std::vector(),
 IP->Contents, Pos, FS, PCHs, 

[PATCH] D46751: [clangd] Filter out private proto symbols in SymbolCollector.

2018-05-15 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

In https://reviews.llvm.org/D46751#1099235, @sammccall wrote:

> @malaperle to expand on what Eric said, adding proto hacks with false 
> positives and no way to turn them off is indeed not the way to go here!
>  There's probably going to be other places we want to filter symbols too, and 
> it should probably be extensible/customizable in some way.
>  We don't yet have enough examples to know what the structure should be 
> (something regex based, a code-plugin system based on `Registry`, or 
> something in between), thus the simplest/least invasive option for now (it's 
> important for our internal rollout to have *some* mitigation in place).
>  @ioeric can you add a comment near the proto-filtering stuff indicating we 
> should work out how to make this extensible?


I agree with all of that. What I don't quite understand is why a flag is not 
ok? Just a fail-safe switch in the mean time? You can even leave it on by 
default so your internal service is not affected. We know for a fact that some 
code bases like Houdini won't work with this, at least there will be an option 
to make it work.

In https://reviews.llvm.org/D46751#1099537, @ioeric wrote:

> In https://reviews.llvm.org/D46751#1099479, @malaperle wrote:
>
> > In https://reviews.llvm.org/D46751#1099097, @ioeric wrote:
> >
> > > > I think this is good if that's true that the comment is always there. I 
> > > > think it would be OK for this to be enabled by default, with a general 
> > > > option to turn heuristics off. Not sure what to call it... 
> > > > -use-symbol-filtering-heuristics :)
> > >
> > > We have other filters in the symbol collector that we think could improve 
> > > user experience, and we don't provide options for those.
> >
> >
> > What others filters do you mean? If you mean skipping "members", symbols in 
> > main files, etc, I a working on making them not skipped, see 
> > https://reviews.llvm.org/D44954.
>
>
> I meant the filters in 
> https://github.com/llvm-mirror/clang-tools-extra/blob/master/clangd/index/SymbolCollector.cpp#L93
>  e.g. filtering symbols in anonymous namespace, which we think should never 
> appear in the index.


I'll be looking at adding them too. For workspaceSymbols it's useful to be able 
to find them and matches what we had before. But completion will not pull them 
from the index.

> I think members are more interesting than the private proto symbols. We want 
> to un-filter members because there are features that would use them, so 
> indexing them makes sense. But private proto symbols should never be shown to 
> users (e.g. in code completion or workspaceSymbols).
> 
> I also think adding an option for indexing members would actually make more 
> sense because they might significantly increase the index size, and it would 
> be good to have options to disable it if users don't use members (e.g. 
> including members can increase size of our internal global index service, and 
> we are not sure if we are ready for that).

It sounds like we'll need both flags. We should discuss that because I'm 
planning to add even more (almost all?) symbols. I don't think it's common that 
users won't want members for workspaceSymbols though, but I see how this is not 
good for the internal indexing service.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46751



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


[PATCH] D46497: [clangd] Populate #include insertions as additional edits in completion items.

2018-05-15 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 146843.
ioeric added a comment.

- Merged with origin/master


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46497

Files:
  clangd/ClangdServer.cpp
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/Headers.cpp
  clangd/Headers.h
  clangd/Protocol.h
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/HeadersTests.cpp

Index: unittests/clangd/HeadersTests.cpp
===
--- unittests/clangd/HeadersTests.cpp
+++ unittests/clangd/HeadersTests.cpp
@@ -8,38 +8,97 @@
 //===--===//
 
 #include "Headers.h"
+
+#include "Compiler.h"
 #include "TestFS.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace clangd {
 namespace {
 
+using ::testing::AllOf;
+using ::testing::UnorderedElementsAre;
+
 class HeadersTest : public ::testing::Test {
 public:
   HeadersTest() {
 CDB.ExtraClangFlags = {SearchDirArg.c_str()};
 FS.Files[MainFile] = "";
+// Make sure directory sub/ exists.
+FS.Files[testPath("sub/EMPTY")] = "";
+  }
+
+private:
+  std::unique_ptr setupClang() {
+auto Cmd = CDB.getCompileCommand(MainFile);
+assert(static_cast(Cmd));
+auto VFS = FS.getFileSystem();
+VFS->setCurrentWorkingDirectory(Cmd->Directory);
+
+std::vector Argv;
+for (const auto  : Cmd->CommandLine)
+  Argv.push_back(S.c_str());
+auto CI = clang::createInvocationFromCommandLine(
+Argv,
+CompilerInstance::createDiagnostics(new DiagnosticOptions(),
+, false),
+VFS);
+EXPECT_TRUE(static_cast(CI));
+CI->getFrontendOpts().DisableFree = false;
+
+// The diagnostic options must be set before creating a CompilerInstance.
+CI->getDiagnosticOpts().IgnoreWarnings = true;
+auto Clang = prepareCompilerInstance(
+std::move(CI), /*Preamble=*/nullptr,
+llvm::MemoryBuffer::getMemBuffer(FS.Files[MainFile], MainFile),
+std::make_shared(), VFS, IgnoreDiags);
+
+EXPECT_FALSE(Clang->getFrontendOpts().Inputs.empty());
+return Clang;
   }
 
 protected:
+  std::vector collectIncludes() {
+auto Clang = setupClang();
+PreprocessOnlyAction Action;
+EXPECT_TRUE(
+Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]));
+std::vector Inclusions;
+Clang->getPreprocessor().addPPCallbacks(collectInclusionsInMainFileCallback(
+Clang->getSourceManager(),
+[&](Inclusion Inc) { Inclusions.push_back(std::move(Inc)); }));
+EXPECT_TRUE(Action.Execute());
+Action.EndSourceFile();
+return Inclusions;
+  }
+
   // Calculates the include path, or returns "" on error.
   std::string calculate(PathRef Original, PathRef Preferred = "",
+const std::vector  = {},
 bool ExpectError = false) {
+auto Clang = setupClang();
+PreprocessOnlyAction Action;
+EXPECT_TRUE(
+Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]));
+
 if (Preferred.empty())
   Preferred = Original;
-auto VFS = FS.getFileSystem();
-auto Cmd = CDB.getCompileCommand(MainFile);
-assert(static_cast(Cmd));
-VFS->setCurrentWorkingDirectory(Cmd->Directory);
 auto ToHeaderFile = [](llvm::StringRef Header) {
   return HeaderFile{Header,
 /*Verbatim=*/!llvm::sys::path::is_absolute(Header)};
 };
-auto Path = calculateIncludePath(MainFile, FS.Files[MainFile],
- ToHeaderFile(Original),
- ToHeaderFile(Preferred), *Cmd, VFS);
+
+auto Path = calculateIncludePath(
+MainFile, CDB.getCompileCommand(MainFile)->Directory,
+Clang->getPreprocessor().getHeaderSearchInfo(), Inclusions,
+ToHeaderFile(Original), ToHeaderFile(Preferred));
+Action.EndSourceFile();
 if (!Path) {
   llvm::consumeError(Path.takeError());
   EXPECT_TRUE(ExpectError);
@@ -49,52 +108,50 @@
 }
 return std::move(*Path);
   }
+
+  Expected
+  insert(const HeaderFile , const HeaderFile ,
+ const std::vector  = {}) {
+auto Clang = setupClang();
+PreprocessOnlyAction Action;
+EXPECT_TRUE(
+Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]));
+
+IncludeInserter Inserter(MainFile, /*Code=*/"", format::getLLVMStyle(),
+ CDB.getCompileCommand(MainFile)->Directory,
+ Clang->getPreprocessor().getHeaderSearchInfo());
+for (const auto  : ExistingInclusions)
+  Inserter.addExisting(Inc);
+
+auto Edit = Inserter.insert(DeclaringHeader, InsertedHeader);
+

[PATCH] D46676: [clangd] Remove LSP command-based #include insertion.

2018-05-15 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
ioeric marked an inline comment as done.
Closed by commit rL332362: [clangd] Remove LSP command-based #include 
insertion. (authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D46676

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/CodeComplete.cpp
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test
  clang-tools-extra/trunk/test/clangd/initialize-params.test
  clang-tools-extra/trunk/test/clangd/insert-include.test
  clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Index: clang-tools-extra/trunk/clangd/Protocol.h
===
--- clang-tools-extra/trunk/clangd/Protocol.h
+++ clang-tools-extra/trunk/clangd/Protocol.h
@@ -538,26 +538,6 @@
 bool fromJSON(const json::Expr &, WorkspaceEdit &);
 json::Expr toJSON(const WorkspaceEdit );
 
-struct IncludeInsertion {
-  /// The document in which the command was invoked.
-  /// If either originalHeader or preferredHeader has been (directly) included
-  /// in the current file, no new include will be inserted.
-  TextDocumentIdentifier textDocument;
-
-  /// The declaring header corresponding to this insertion e.g. the header that
-  /// declares a symbol. This could be either a URI or a literal string quoted
-  /// with <> or "" that can be #included directly.
-  std::string declaringHeader;
-  /// The preferred header to be inserted. This may be different from
-  /// originalHeader as a header file can have a different canonical include.
-  /// This could be either a URI or a literal string quoted with <> or "" that
-  /// can be #included directly. If empty, declaringHeader is used to calculate
-  /// the #include path.
-  std::string preferredHeader;
-};
-bool fromJSON(const json::Expr &, IncludeInsertion &);
-json::Expr toJSON(const IncludeInsertion );
-
 /// Exact commands are not specified in the protocol so we define the
 /// ones supported by Clangd here. The protocol specifies the command arguments
 /// to be "any[]" but to make this safer and more manageable, each command we
@@ -569,16 +549,12 @@
 struct ExecuteCommandParams {
   // Command to apply fix-its. Uses WorkspaceEdit as argument.
   const static llvm::StringLiteral CLANGD_APPLY_FIX_COMMAND;
-  // Command to insert an #include into code.
-  const static llvm::StringLiteral CLANGD_INSERT_HEADER_INCLUDE;
 
   /// The command identifier, e.g. CLANGD_APPLY_FIX_COMMAND
   std::string command;
 
   // Arguments
   llvm::Optional workspaceEdit;
-
-  llvm::Optional includeInsertion;
 };
 bool fromJSON(const json::Expr &, ExecuteCommandParams &);
 
@@ -750,7 +726,6 @@
   /// themselves.
   std::vector additionalTextEdits;
 
-  llvm::Optional command;
   // TODO(krasimir): The following optional fields defined by the language
   // server protocol are unsupported:
   //
Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
@@ -289,27 +289,6 @@
   I.documentation = D->Documentation;
 if (I.detail.empty())
   I.detail = D->CompletionDetail;
-// FIXME: delay creating include insertion command to
-// "completionItem/resolve", when it is supported
-if (!D->IncludeHeader.empty()) {
-  // LSP favors additionalTextEdits over command. But we are still using
-  // command here because it would be expensive to calculate #include
-  // insertion edits for all candidates, and the include insertion edit
-  // is unlikely to conflict with the code completion edits.
-  Command Cmd;
-  // Command title is not added since this is not a user-facing command.
-  Cmd.command = ExecuteCommandParams::CLANGD_INSERT_HEADER_INCLUDE;
-  IncludeInsertion Insertion;
-  // Fallback to canonical header if declaration location is invalid.
-  Insertion.declaringHeader =
-  IndexResult->CanonicalDeclaration.FileURI.empty()
-  ? D->IncludeHeader
-  : IndexResult->CanonicalDeclaration.FileURI;
-  Insertion.preferredHeader = D->IncludeHeader;
-  Insertion.textDocument.uri = URIForFile(FileName);
-  Cmd.includeInsertion = std::move(Insertion);
-  I.command = std::move(Cmd);
-}
   }
 }
 I.scoreInfo = Scores;
Index: clang-tools-extra/trunk/clangd/ClangdServer.h
===
--- clang-tools-extra/trunk/clangd/ClangdServer.h
+++ 

[clang-tools-extra] r332362 - [clangd] Remove LSP command-based #include insertion.

2018-05-15 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue May 15 08:23:53 2018
New Revision: 332362

URL: http://llvm.org/viewvc/llvm-project?rev=332362=rev
Log:
[clangd] Remove LSP command-based #include insertion.

Summary:
clangd will populate #include insertions as addtionalEdits in completion items.

The code completion tests in ClangdServerTest will be added back in D46497.

Reviewers: ilya-biryukov, sammccall

Reviewed By: ilya-biryukov

Subscribers: klimek, MaskRay, jkorous, cfe-commits

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

Removed:
clang-tools-extra/trunk/test/clangd/insert-include.test
Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test
clang-tools-extra/trunk/test/clangd/initialize-params.test
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=332362=332361=332362=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue May 15 08:23:53 2018
@@ -115,9 +115,7 @@ void ClangdLSPServer::onInitialize(Initi
 {"workspaceSymbolProvider", true},
 {"executeCommandProvider",
  json::obj{
- {"commands",
-  {ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND,
-   ExecuteCommandParams::CLANGD_INSERT_HEADER_INCLUDE}},
+ {"commands", 
{ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND}},
  }},
 );
 }
@@ -190,42 +188,6 @@ void ClangdLSPServer::onCommand(ExecuteC
 
 reply("Fix applied.");
 ApplyEdit(*Params.workspaceEdit);
-  } else if (Params.command ==
- ExecuteCommandParams::CLANGD_INSERT_HEADER_INCLUDE) {
-auto  = Params.includeInsertion->textDocument.uri;
-auto Code = DraftMgr.getDraft(FileURI.file());
-if (!Code)
-  return replyError(ErrorCode::InvalidParams,
-("command " +
- ExecuteCommandParams::CLANGD_INSERT_HEADER_INCLUDE +
- " called on non-added file " + FileURI.file())
-.str());
-llvm::StringRef DeclaringHeader = Params.includeInsertion->declaringHeader;
-if (DeclaringHeader.empty())
-  return replyError(
-  ErrorCode::InvalidParams,
-  "declaringHeader must be provided for include insertion.");
-llvm::StringRef PreferredHeader = Params.includeInsertion->preferredHeader;
-auto Replaces = Server.insertInclude(
-FileURI.file(), *Code, DeclaringHeader,
-PreferredHeader.empty() ? DeclaringHeader : PreferredHeader);
-if (!Replaces) {
-  std::string ErrMsg =
-  ("Failed to generate include insertion edits for adding " +
-   DeclaringHeader + " (" + PreferredHeader + ") into " +
-   FileURI.file())
-  .str();
-  log(ErrMsg + ":" + llvm::toString(Replaces.takeError()));
-  replyError(ErrorCode::InternalError, ErrMsg);
-  return;
-}
-auto Edits = replacementsToEdits(*Code, *Replaces);
-WorkspaceEdit WE;
-WE.changes = {{FileURI.uri(), Edits}};
-
-reply(("Inserted header " + DeclaringHeader + " (" + PreferredHeader + ")")
-  .str());
-ApplyEdit(std::move(WE));
   } else {
 // We should not get here because ExecuteCommandParams would not have
 // parsed in the first place and this handler should not be called. But if

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=332362=332361=332362=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue May 15 08:23:53 2018
@@ -272,66 +272,6 @@ void ClangdServer::rename(PathRef File,
   "Rename", File, Bind(Action, File.str(), NewName.str(), std::move(CB)));
 }
 
-/// Creates a `HeaderFile` from \p Header which can be either a URI or a 
literal
-/// include.
-static llvm::Expected toHeaderFile(StringRef Header,
-   llvm::StringRef HintPath) {
-  if (isLiteralInclude(Header))
-return HeaderFile{Header.str(), /*Verbatim=*/true};
-  auto U = URI::parse(Header);
-  if (!U)
-return U.takeError();
-
-  auto IncludePath = URI::includeSpelling(*U);
-  if (!IncludePath)
-return IncludePath.takeError();
-  if (!IncludePath->empty())
-return 

[PATCH] D46497: [clangd] Populate #include insertions as additional edits in completion items.

2018-05-15 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 146839.
ioeric added a comment.

- Rebase...


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46497

Files:
  clangd/ClangdServer.cpp
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/Headers.cpp
  clangd/Headers.h
  clangd/Protocol.h
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/HeadersTests.cpp

Index: unittests/clangd/HeadersTests.cpp
===
--- unittests/clangd/HeadersTests.cpp
+++ unittests/clangd/HeadersTests.cpp
@@ -8,38 +8,97 @@
 //===--===//
 
 #include "Headers.h"
+
+#include "Compiler.h"
 #include "TestFS.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace clangd {
 namespace {
 
+using ::testing::AllOf;
+using ::testing::UnorderedElementsAre;
+
 class HeadersTest : public ::testing::Test {
 public:
   HeadersTest() {
 CDB.ExtraClangFlags = {SearchDirArg.c_str()};
 FS.Files[MainFile] = "";
+// Make sure directory sub/ exists.
+FS.Files[testPath("sub/EMPTY")] = "";
+  }
+
+private:
+  std::unique_ptr setupClang() {
+auto Cmd = CDB.getCompileCommand(MainFile);
+assert(static_cast(Cmd));
+auto VFS = FS.getFileSystem();
+VFS->setCurrentWorkingDirectory(Cmd->Directory);
+
+std::vector Argv;
+for (const auto  : Cmd->CommandLine)
+  Argv.push_back(S.c_str());
+auto CI = clang::createInvocationFromCommandLine(
+Argv,
+CompilerInstance::createDiagnostics(new DiagnosticOptions(),
+, false),
+VFS);
+EXPECT_TRUE(static_cast(CI));
+CI->getFrontendOpts().DisableFree = false;
+
+// The diagnostic options must be set before creating a CompilerInstance.
+CI->getDiagnosticOpts().IgnoreWarnings = true;
+auto Clang = prepareCompilerInstance(
+std::move(CI), /*Preamble=*/nullptr,
+llvm::MemoryBuffer::getMemBuffer(FS.Files[MainFile], MainFile),
+std::make_shared(), VFS, IgnoreDiags);
+
+EXPECT_FALSE(Clang->getFrontendOpts().Inputs.empty());
+return Clang;
   }
 
 protected:
+  std::vector collectIncludes() {
+auto Clang = setupClang();
+PreprocessOnlyAction Action;
+EXPECT_TRUE(
+Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]));
+std::vector Inclusions;
+Clang->getPreprocessor().addPPCallbacks(collectInclusionsInMainFileCallback(
+Clang->getSourceManager(),
+[&](Inclusion Inc) { Inclusions.push_back(std::move(Inc)); }));
+EXPECT_TRUE(Action.Execute());
+Action.EndSourceFile();
+return Inclusions;
+  }
+
   // Calculates the include path, or returns "" on error.
   std::string calculate(PathRef Original, PathRef Preferred = "",
+const std::vector  = {},
 bool ExpectError = false) {
+auto Clang = setupClang();
+PreprocessOnlyAction Action;
+EXPECT_TRUE(
+Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]));
+
 if (Preferred.empty())
   Preferred = Original;
-auto VFS = FS.getFileSystem();
-auto Cmd = CDB.getCompileCommand(MainFile);
-assert(static_cast(Cmd));
-VFS->setCurrentWorkingDirectory(Cmd->Directory);
 auto ToHeaderFile = [](llvm::StringRef Header) {
   return HeaderFile{Header,
 /*Verbatim=*/!llvm::sys::path::is_absolute(Header)};
 };
-auto Path = calculateIncludePath(MainFile, FS.Files[MainFile],
- ToHeaderFile(Original),
- ToHeaderFile(Preferred), *Cmd, VFS);
+
+auto Path = calculateIncludePath(
+MainFile, CDB.getCompileCommand(MainFile)->Directory,
+Clang->getPreprocessor().getHeaderSearchInfo(), Inclusions,
+ToHeaderFile(Original), ToHeaderFile(Preferred));
+Action.EndSourceFile();
 if (!Path) {
   llvm::consumeError(Path.takeError());
   EXPECT_TRUE(ExpectError);
@@ -49,52 +108,50 @@
 }
 return std::move(*Path);
   }
+
+  Expected
+  insert(const HeaderFile , const HeaderFile ,
+ const std::vector  = {}) {
+auto Clang = setupClang();
+PreprocessOnlyAction Action;
+EXPECT_TRUE(
+Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]));
+
+IncludeInserter Inserter(MainFile, /*Code=*/"", format::getLLVMStyle(),
+ CDB.getCompileCommand(MainFile)->Directory,
+ Clang->getPreprocessor().getHeaderSearchInfo());
+for (const auto  : ExistingInclusions)
+  Inserter.addExisting(Inc);
+
+auto Edit = Inserter.insert(DeclaringHeader, InsertedHeader);
+Action.EndSourceFile();
+  

[PATCH] D46497: [clangd] Populate #include insertions as additional edits in completion items.

2018-05-15 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 146838.
ioeric added a comment.

- Rebase on https://reviews.llvm.org/D46676


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46497

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/Headers.cpp
  clangd/Headers.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test
  test/clangd/insert-include.test
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/HeadersTests.cpp

Index: unittests/clangd/HeadersTests.cpp
===
--- unittests/clangd/HeadersTests.cpp
+++ unittests/clangd/HeadersTests.cpp
@@ -8,38 +8,97 @@
 //===--===//
 
 #include "Headers.h"
+
+#include "Compiler.h"
 #include "TestFS.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace clangd {
 namespace {
 
+using ::testing::AllOf;
+using ::testing::UnorderedElementsAre;
+
 class HeadersTest : public ::testing::Test {
 public:
   HeadersTest() {
 CDB.ExtraClangFlags = {SearchDirArg.c_str()};
 FS.Files[MainFile] = "";
+// Make sure directory sub/ exists.
+FS.Files[testPath("sub/EMPTY")] = "";
+  }
+
+private:
+  std::unique_ptr setupClang() {
+auto Cmd = CDB.getCompileCommand(MainFile);
+assert(static_cast(Cmd));
+auto VFS = FS.getFileSystem();
+VFS->setCurrentWorkingDirectory(Cmd->Directory);
+
+std::vector Argv;
+for (const auto  : Cmd->CommandLine)
+  Argv.push_back(S.c_str());
+auto CI = clang::createInvocationFromCommandLine(
+Argv,
+CompilerInstance::createDiagnostics(new DiagnosticOptions(),
+, false),
+VFS);
+EXPECT_TRUE(static_cast(CI));
+CI->getFrontendOpts().DisableFree = false;
+
+// The diagnostic options must be set before creating a CompilerInstance.
+CI->getDiagnosticOpts().IgnoreWarnings = true;
+auto Clang = prepareCompilerInstance(
+std::move(CI), /*Preamble=*/nullptr,
+llvm::MemoryBuffer::getMemBuffer(FS.Files[MainFile], MainFile),
+std::make_shared(), VFS, IgnoreDiags);
+
+EXPECT_FALSE(Clang->getFrontendOpts().Inputs.empty());
+return Clang;
   }
 
 protected:
+  std::vector collectIncludes() {
+auto Clang = setupClang();
+PreprocessOnlyAction Action;
+EXPECT_TRUE(
+Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]));
+std::vector Inclusions;
+Clang->getPreprocessor().addPPCallbacks(collectInclusionsInMainFileCallback(
+Clang->getSourceManager(),
+[&](Inclusion Inc) { Inclusions.push_back(std::move(Inc)); }));
+EXPECT_TRUE(Action.Execute());
+Action.EndSourceFile();
+return Inclusions;
+  }
+
   // Calculates the include path, or returns "" on error.
   std::string calculate(PathRef Original, PathRef Preferred = "",
+const std::vector  = {},
 bool ExpectError = false) {
+auto Clang = setupClang();
+PreprocessOnlyAction Action;
+EXPECT_TRUE(
+Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]));
+
 if (Preferred.empty())
   Preferred = Original;
-auto VFS = FS.getFileSystem();
-auto Cmd = CDB.getCompileCommand(MainFile);
-assert(static_cast(Cmd));
-VFS->setCurrentWorkingDirectory(Cmd->Directory);
 auto ToHeaderFile = [](llvm::StringRef Header) {
   return HeaderFile{Header,
 /*Verbatim=*/!llvm::sys::path::is_absolute(Header)};
 };
-auto Path = calculateIncludePath(MainFile, FS.Files[MainFile],
- ToHeaderFile(Original),
- ToHeaderFile(Preferred), *Cmd, VFS);
+
+auto Path = calculateIncludePath(
+MainFile, CDB.getCompileCommand(MainFile)->Directory,
+Clang->getPreprocessor().getHeaderSearchInfo(), Inclusions,
+ToHeaderFile(Original), ToHeaderFile(Preferred));
+Action.EndSourceFile();
 if (!Path) {
   llvm::consumeError(Path.takeError());
   EXPECT_TRUE(ExpectError);
@@ -49,52 +108,50 @@
 }
 return std::move(*Path);
   }
+
+  Expected
+  insert(const HeaderFile , const HeaderFile ,
+ const std::vector  = {}) {
+auto Clang = setupClang();
+PreprocessOnlyAction Action;
+EXPECT_TRUE(
+Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]));
+
+IncludeInserter Inserter(MainFile, /*Code=*/"", format::getLLVMStyle(),
+ CDB.getCompileCommand(MainFile)->Directory,

[PATCH] D46700: [ThinLTO] Add testing of new summary index format to a couple CFI tests

2018-05-15 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 146836.
tejohnson added a comment.

Update tests for changes to https://reviews.llvm.org/D46699


Repository:
  rC Clang

https://reviews.llvm.org/D46700

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


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


  1   2   >