[PATCH] D46685: [CodeGen] Disable structor optimizations at -O0

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

Well, internal and external types are important cases.  I'm fine with this.  
It's a pity that we can't express what we want with aliases, though.


Repository:
  rC Clang

https://reviews.llvm.org/D46685



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


[PATCH] D45898: [SemaCXX] Mark destructor as referenced

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

I agree that the new-expression case doesn't use the destructor, and all the 
other cases of list-initialization presumably use the destructor for the 
initialized type for separate reasons.  Ok.




Comment at: test/CodeGenObjCXX/arc-list-init-destruct.mm:1
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -std=c++1z -fobjc-arc 
-fobjc-exceptions -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck 
%s
+

ahatanak wrote:
> rjmccall wrote:
> > Does the corresponding C++ test case (replacing `Class0 *f;` with 
> > `HasExplicitNonTrivialDestructor f;`) not reproduce the problem?
> I wasn't able to reproduce the problem by changing the type of field 'f' to a 
> C++ class with a non-trivial destructor because, if I make that change, 
> Class1's destructor declaration gets added in 
> Sema::AddImplicitlyDeclaredMembersToClass. I don't fully understand the 
> reason behind it, but Class1's destructor declaration is added when the type 
> of one of its subobject has a user-declared destructor.
Interesting, alright.


Repository:
  rC Clang

https://reviews.llvm.org/D45898



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


[PATCH] D46910: [Support] Avoid normalization in sys::getDefaultTargetTriple

2018-05-17 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

Applied, thanks so much for looking into it.


Repository:
  rC Clang

https://reviews.llvm.org/D46910



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


[PATCH] D46910: [Support] Avoid normalization in sys::getDefaultTargetTriple

2018-05-17 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 147431.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D46910

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/cmake/modules/GetHostTriple.cmake
  llvm/lib/Support/Unix/Host.inc
  llvm/lib/Support/Windows/Host.inc


Index: llvm/lib/Support/Windows/Host.inc
===
--- llvm/lib/Support/Windows/Host.inc
+++ llvm/lib/Support/Windows/Host.inc
@@ -30,5 +30,5 @@
 Triple = EnvTriple;
 #endif
 
-  return Triple::normalize(Triple);
+  return Triple;
 }
Index: llvm/lib/Support/Unix/Host.inc
===
--- llvm/lib/Support/Unix/Host.inc
+++ llvm/lib/Support/Unix/Host.inc
@@ -64,5 +64,5 @@
 TargetTripleString = EnvTriple;
 #endif
 
-  return Triple::normalize(TargetTripleString);
+  return TargetTripleString;
 }
Index: llvm/cmake/modules/GetHostTriple.cmake
===
--- llvm/cmake/modules/GetHostTriple.cmake
+++ llvm/cmake/modules/GetHostTriple.cmake
@@ -4,15 +4,15 @@
 function( get_host_triple var )
   if( MSVC )
 if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
-  set( value "x86_64-pc-win32" )
+  set( value "x86_64-pc-windows-msvc" )
 else()
-  set( value "i686-pc-win32" )
+  set( value "i686-pc-windows-msvc" )
 endif()
   elseif( MINGW AND NOT MSYS )
 if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
-  set( value "x86_64-w64-mingw32" )
+  set( value "x86_64-w64-windows-gnu" )
 else()
-  set( value "i686-pc-mingw32" )
+  set( value "i686-pc-windows-gnu" )
 endif()
   else( MSVC )
 set(config_guess ${LLVM_MAIN_SRC_DIR}/cmake/config.guess)
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2916,10 +2916,11 @@
   Opts.FPMath = Args.getLastArgValue(OPT_mfpmath);
   Opts.FeaturesAsWritten = Args.getAllArgValues(OPT_target_feature);
   Opts.LinkerVersion = Args.getLastArgValue(OPT_target_linker_version);
-  Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
+  Opts.Triple = Args.getLastArgValue(OPT_triple);
   // Use the default target triple if unspecified.
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();
+  Opts.Triple = llvm::Triple::normalize(Opts.Triple);
   Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
   Opts.ForceEnableInt128 = Args.hasArg(OPT_fforce_enable_int128);
   Opts.NVPTXUseShortPointers = Args.hasFlag(


Index: llvm/lib/Support/Windows/Host.inc
===
--- llvm/lib/Support/Windows/Host.inc
+++ llvm/lib/Support/Windows/Host.inc
@@ -30,5 +30,5 @@
 Triple = EnvTriple;
 #endif
 
-  return Triple::normalize(Triple);
+  return Triple;
 }
Index: llvm/lib/Support/Unix/Host.inc
===
--- llvm/lib/Support/Unix/Host.inc
+++ llvm/lib/Support/Unix/Host.inc
@@ -64,5 +64,5 @@
 TargetTripleString = EnvTriple;
 #endif
 
-  return Triple::normalize(TargetTripleString);
+  return TargetTripleString;
 }
Index: llvm/cmake/modules/GetHostTriple.cmake
===
--- llvm/cmake/modules/GetHostTriple.cmake
+++ llvm/cmake/modules/GetHostTriple.cmake
@@ -4,15 +4,15 @@
 function( get_host_triple var )
   if( MSVC )
 if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
-  set( value "x86_64-pc-win32" )
+  set( value "x86_64-pc-windows-msvc" )
 else()
-  set( value "i686-pc-win32" )
+  set( value "i686-pc-windows-msvc" )
 endif()
   elseif( MINGW AND NOT MSYS )
 if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
-  set( value "x86_64-w64-mingw32" )
+  set( value "x86_64-w64-windows-gnu" )
 else()
-  set( value "i686-pc-mingw32" )
+  set( value "i686-pc-windows-gnu" )
 endif()
   else( MSVC )
 set(config_guess ${LLVM_MAIN_SRC_DIR}/cmake/config.guess)
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2916,10 +2916,11 @@
   Opts.FPMath = Args.getLastArgValue(OPT_mfpmath);
   Opts.FeaturesAsWritten = Args.getAllArgValues(OPT_target_feature);
   Opts.LinkerVersion = Args.getLastArgValue(OPT_target_linker_version);
-  Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
+  Opts.Triple = Args.getLastArgValue(OPT_triple);
   // Use the default target triple if unspecified.
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();
+  Opts.Triple = llvm::Triple::normalize(Opts.Triple);
   Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
   Opts.ForceEnableInt128 = Args.hasAr

[PATCH] D45898: [SemaCXX] Mark destructor as referenced

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

As it happens, the C++ committee fixed the language wording hole here very 
recently. The new rule can be found here: http://wg21.link/p0968r0#2227
In summary: we should to consider the destructor for all elements of the 
aggregate to be potentially-invoked.

@rjmccall Were you suggesting that we should also consider the destructor of 
the aggregate itself to be potentially-invoked, or just the elements? In the 
//new-expression// case at least, I don't think the former is permitted.


Repository:
  rC Clang

https://reviews.llvm.org/D45898



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


[PATCH] D46998: [XRay][clang+compiler-rt] Make XRay depend on a C++ standard lib

2018-05-17 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris added a comment.

In https://reviews.llvm.org/D46998#1103397, @dblaikie wrote:

> "In the future we can revisit this when we have a better idea as to why not 
> depending on the C++ ABI functionality is a better solution."  - this was 
> discussed previously in the thread linked from the bug.
>
> A big thing, so far as I understand it, is that Clang doesn't require some 
> specific C++ library, so wouldn't this break for users who didn't have the 
> specific C++ library installed that compiler-rt for XRay was built against?


We don't use anything from the C++ library directly, we depend on some features 
provided by the implementation. In some cases, this isn't a library:

  extern int g();
  
  int f() {
static int val = g();
return val;
  }

This will emit calls to guards for the thread-safe initialisation of val.

The alternatives here are that XRay just avoids these completely, and use 
pthreads instead to do a pthread_once_init(...).

The other alternative is to avoid pthreads and use the sanitizer_common mutexes 
too, to make it self-contained in compiler-rt.

The other alternative is to just link in the ABI library (libcxxabi or 
something else) instead of the standard library.

I can make one of those changes work, but that's also a lot of work, which I 
suppose is worth doing anyway (unless I'm missing something simpler).

Any preferences/stack-ranking of which solution might be more palatable?


https://reviews.llvm.org/D46998



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


[PATCH] D45898: [SemaCXX] Mark destructor as referenced

2018-05-17 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

Richard and Doug, do you have any thoughts on John's suggestion?




Comment at: test/CodeGenObjCXX/arc-list-init-destruct.mm:1
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -std=c++1z -fobjc-arc 
-fobjc-exceptions -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck 
%s
+

rjmccall wrote:
> Does the corresponding C++ test case (replacing `Class0 *f;` with 
> `HasExplicitNonTrivialDestructor f;`) not reproduce the problem?
I wasn't able to reproduce the problem by changing the type of field 'f' to a 
C++ class with a non-trivial destructor because, if I make that change, 
Class1's destructor declaration gets added in 
Sema::AddImplicitlyDeclaredMembersToClass. I don't fully understand the reason 
behind it, but Class1's destructor declaration is added when the type of one of 
its subobject has a user-declared destructor.


Repository:
  rC Clang

https://reviews.llvm.org/D45898



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


[PATCH] D47044: Ensure that we only visit a destructor for a reference if type information is available.

2018-05-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Mmm, i think loop widening simply shouldn't invalidate references (though it 
should invalidate objects bound to them). Simply because you can't really 
reassign a reference.

Could we mark them as "preserve contents", like in 
https://reviews.llvm.org/D45491?


Repository:
  rC Clang

https://reviews.llvm.org/D47044



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


[PATCH] D47044: Ensure that we only visit a destructor for a reference if type information is available.

2018-05-17 Thread Matthew Voss via Phabricator via cfe-commits
ormris created this revision.
ormris added reviewers: dcoughlin, NoQ, xazax.hun, george.karpenkov.
Herald added a subscriber: rnkovacs.

Loop widening can invalidate an object reference. If the analyzer attempts to 
visit the destructor to a non-existent object it will crash. This patch ensures 
that type information is available before attempting to visit the object.


Repository:
  rC Clang

https://reviews.llvm.org/D47044

Files:
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/loop-widening-invalid-type.cpp


Index: test/Analysis/loop-widening-invalid-type.cpp
===
--- /dev/null
+++ test/Analysis/loop-widening-invalid-type.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-max-loop 4 
-analyzer-config widen-loops=true -verify %s
+
+struct A {
+  ~A() {}
+};
+struct B : public A {};
+
+void invalid_type_region_access() { // expected-no-diagnostics
+  const A &x = B();
+  for(int i = 0; i < 10; ++i) {}
+}
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1044,6 +1044,10 @@
   return;
 }
 Region = ValueRegion->getBaseRegion();
+if (!isa(Region))
+  // Loop widening will sometimes invalidate typed regions.
+  return;
+ 
 varType = cast(Region)->getValueType();
   }
 


Index: test/Analysis/loop-widening-invalid-type.cpp
===
--- /dev/null
+++ test/Analysis/loop-widening-invalid-type.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-max-loop 4 -analyzer-config widen-loops=true -verify %s
+
+struct A {
+  ~A() {}
+};
+struct B : public A {};
+
+void invalid_type_region_access() { // expected-no-diagnostics
+  const A &x = B();
+  for(int i = 0; i < 10; ++i) {}
+}
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1044,6 +1044,10 @@
   return;
 }
 Region = ValueRegion->getBaseRegion();
+if (!isa(Region))
+  // Loop widening will sometimes invalidate typed regions.
+  return;
+ 
 varType = cast(Region)->getValueType();
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45015: [Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.

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

Eric, do you have more thoughts on this issue?


Repository:
  rC Clang

https://reviews.llvm.org/D45015



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


[PATCH] D46084: [Fixed Point Arithmetic] Addition of the Fixed Point _Accum type

2018-05-17 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 147406.
leonardchan marked an inline comment as done.
leonardchan added a comment.

Undid git-clang-formatting on ASTBitcodes.h


Repository:
  rC Clang

https://reviews.llvm.org/D46084

Files:
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/Basic/DiagnosticCommonKinds.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
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -53,6 +53,12 @@
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
+BTCASE(ShortAccum);
+BTCASE(Accum);
+BTCASE(LongAccum);
+BTCASE(UShortAccum);
+BTCASE(UAccum);
+BTCASE(ULongAccum);
 BTCASE(Float16);
 BTCASE(Float128);
 BTCASE(NullPtr);
@@ -542,6 +548,12 @@
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);
+TKIND(ShortAccum);
+TKIND(Accum);
+TKIND(LongAccum);
+TKIND(UShortAccum);
+TKIND(UAccum);
+TKIND(ULongAccum);
 TKIND(Float16);
 TKIND(Float128);
 TKIND(NullPtr);
Index: test/Frontend/accum_errors.cpp
===
--- /dev/null
+++ test/Frontend/accum_errors.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c++ %s -verify
+
+// Name namgling is not provided for fixed point types in c++
+
+signed short _Accum s_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed _Accum s_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed long _Accum s_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned short _Accum u_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned _Accum u_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned long _Accum u_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+
+short _Accum short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+_Accum accum; // expected-error{{Fixed point types are only allowed in C}}
+long _Accum long_accum;  // expected-error{{Fixed point types are only allowed in C}}
Index: test/Frontend/accum_errors.c
===
--- /dev/null
+++ test/Frontend/accum_errors.c
@@ -0,0 +1,4 @@
+// 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}}
Index: test/Frontend/accum.c
===
--- /dev/null
+++ test/Frontend/accum.c
@@ -0,0 +1,26 @@
+// RUN: %clang -cc1 -x c -ast-dump %s | FileCheck %s --strict-whitespace
+
+/*  Various contexts where type _Accum can appear. */
+
+// 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;
+
+// Aliased fixed point types
+short _Accum short_accum;
+_Accum accum;
+long _Accum long_accum;
+
+// CHECK:  |-VarDecl {{.*}} s_short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_accum '_Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_long_accum 'long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_short_accum 'unsigned short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_accum 'unsigned _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_long_accum 'unsigned long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} accum '_Accum'
+// CHECK-NEXT: `-VarDecl {{.*}} long_accum 'long _Accum'
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -6816,6 +6816,24 @@
 case PREDEF_TYPE_LONGDOUBLE_ID:
   T = Context.LongDoubleTy;
   break;
+case PREDEF_TYPE_SHORT_ACCUM_ID:
+  T = Context.ShortAccumTy;
+  break;
+case PREDEF_TYPE_ACCUM_ID:
+  T = Context.AccumTy;
+  break;
+

[libclc] r332677 - Add initial support for half precision builtins

2018-05-17 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu May 17 15:55:30 2018
New Revision: 332677

URL: http://llvm.org/viewvc/llvm-project?rev=332677&view=rev
Log:
Add initial support for half precision builtins

v2: fix fmax implementation
use consistent checks for __CLC_FP_SIZE
add missing TODOs
fix whitespace in definitions.h
v3: undef ZERO in modf.inc

Signed-off-by: Jan Vesely 
reviewer: Jeroen Ketema 
Reviewed-by: Aaron Watry 
Tested-by: Aaron Watry 

Modified:
libclc/trunk/amdgcn/lib/math/fmax.cl
libclc/trunk/amdgcn/lib/math/fmin.cl
libclc/trunk/amdgpu/lib/math/nextafter.cl
libclc/trunk/amdgpu/lib/math/sqrt.cl
libclc/trunk/generic/include/clc/as_type.h
libclc/trunk/generic/include/clc/async/gentype.inc
libclc/trunk/generic/include/clc/float/definitions.h
libclc/trunk/generic/include/clc/geometric/floatn.inc
libclc/trunk/generic/include/clc/math/binary_intrin.inc
libclc/trunk/generic/include/clc/math/gentype.inc
libclc/trunk/generic/include/clc/math/nan.inc
libclc/trunk/generic/include/clc/math/ternary_intrin.inc
libclc/trunk/generic/include/clc/math/unary_intrin.inc
libclc/trunk/generic/include/clc/relational/floatn.inc
libclc/trunk/generic/include/clc/relational/isequal.h
libclc/trunk/generic/include/clc/relational/isinf.h
libclc/trunk/generic/include/clc/relational/isnan.h
libclc/trunk/generic/include/math/clc_ldexp.h
libclc/trunk/generic/lib/geometric/dot.cl
libclc/trunk/generic/lib/geometric/length.cl
libclc/trunk/generic/lib/math/acos.inc
libclc/trunk/generic/lib/math/asin.inc
libclc/trunk/generic/lib/math/clc_nextafter.cl
libclc/trunk/generic/lib/math/clc_sqrt_impl.inc
libclc/trunk/generic/lib/math/clc_sw_binary.inc
libclc/trunk/generic/lib/math/clc_sw_unary.inc
libclc/trunk/generic/lib/math/copysign.cl
libclc/trunk/generic/lib/math/fmax.cl
libclc/trunk/generic/lib/math/fmax.inc
libclc/trunk/generic/lib/math/fmin.cl
libclc/trunk/generic/lib/math/fmin.inc
libclc/trunk/generic/lib/math/fract.inc
libclc/trunk/generic/lib/math/ldexp.cl
libclc/trunk/generic/lib/math/ldexp.inc
libclc/trunk/generic/lib/math/lgamma_r.inc
libclc/trunk/generic/lib/math/modf.inc
libclc/trunk/generic/lib/math/nan.inc
libclc/trunk/generic/lib/math/pown.inc
libclc/trunk/generic/lib/math/remquo.inc
libclc/trunk/generic/lib/math/rootn.inc
libclc/trunk/generic/lib/math/sincos.inc
libclc/trunk/generic/lib/math/sqrt.cl
libclc/trunk/generic/lib/relational/isequal.cl
libclc/trunk/generic/lib/relational/isfinite.cl
libclc/trunk/generic/lib/relational/isgreater.cl
libclc/trunk/generic/lib/relational/isgreaterequal.cl
libclc/trunk/generic/lib/relational/isinf.cl
libclc/trunk/generic/lib/relational/isless.cl
libclc/trunk/generic/lib/relational/islessequal.cl
libclc/trunk/generic/lib/relational/islessgreater.cl
libclc/trunk/generic/lib/relational/isnan.cl
libclc/trunk/generic/lib/relational/isnormal.cl
libclc/trunk/generic/lib/relational/isnotequal.cl
libclc/trunk/generic/lib/relational/isordered.cl
libclc/trunk/generic/lib/relational/isunordered.cl
libclc/trunk/generic/lib/relational/signbit.cl
libclc/trunk/generic/lib/shared/vstore_half.inc

Modified: libclc/trunk/amdgcn/lib/math/fmax.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/math/fmax.cl?rev=332677&r1=332676&r2=332677&view=diff
==
--- libclc/trunk/amdgcn/lib/math/fmax.cl (original)
+++ libclc/trunk/amdgcn/lib/math/fmax.cl Thu May 17 15:55:30 2018
@@ -26,6 +26,21 @@ _CLC_DEF _CLC_OVERLOAD double fmax(doubl
 _CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, fmax, double, double)
 
 #endif
+#ifdef cl_khr_fp16
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+_CLC_DEF _CLC_OVERLOAD half fmax(half x, half y)
+{
+   if (isnan(x))
+  return y;
+   if (isnan(y))
+  return x;
+   return (y < x) ? x : y;
+}
+_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, fmax, half, half)
+
+#endif
 
 #define __CLC_BODY <../../../generic/lib/math/fmax.inc>
 #include 

Modified: libclc/trunk/amdgcn/lib/math/fmin.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/math/fmin.cl?rev=332677&r1=332676&r2=332677&view=diff
==
--- libclc/trunk/amdgcn/lib/math/fmin.cl (original)
+++ libclc/trunk/amdgcn/lib/math/fmin.cl Thu May 17 15:55:30 2018
@@ -26,6 +26,21 @@ _CLC_DEF _CLC_OVERLOAD double fmin(doubl
 _CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, fmin, double, double)
 
 #endif
+#ifdef cl_khr_fp16
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+_CLC_DEF _CLC_OVERLOAD half fmin(half x, half y)
+{
+   if (isnan(x))
+  return y;
+   if (isnan(y))
+  return x;
+   return (y < x) ? y : x;
+}
+_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, fmin, half, half)
+
+#endif
 
 #define __

[PATCH] D46084: [Fixed Point Arithmetic] Addition of the Fixed Point _Accum type

2018-05-17 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan marked 2 inline comments as done.
leonardchan added inline comments.



Comment at: lib/Index/USRGeneration.cpp:691
+case BuiltinType::ULongAccum:
+  llvm_unreachable("No USR name mangling for fixed point types.");
 case BuiltinType::Float16:

phosek wrote:
> We need some solution for fixed point types.
Added character ~ to indicate fixed point type followed by string detailing the 
type. I have not added a test to it because logically, I do not think we will 
ever reach that point. This logic is implemented in the VisitType method, which 
mostly gets called by visitors to c++ nodes like VisitTemplateParameterList, 
but we have disabled the use of fixed point types in c++. VisitType does get 
called in VisitFunctionDecl but the function exits early since we are not 
reading c++ (line lib/Index/USRGeneration.cpp:238).


Repository:
  rC Clang

https://reviews.llvm.org/D46084



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


[PATCH] D46084: [Fixed Point Arithmetic] Addition of the Fixed Point _Accum type

2018-05-17 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 147400.
leonardchan added a comment.

Added break. We still assign `Result` since it cannot be null at the end of the 
switch stmt, though the value doesn't matter.

Added character `~` to indicate fixed point type followed by string detailing 
the type. I have not added a test to it because logically, I do not think we 
will ever reach that point. This logic is implemented in the `VisitType` 
method, which mostly gets called by visitors to c++ nodes like 
`VisitTemplateParameterList`, but we have disabled the use of fixed point types 
in c++. `VisitType` does get called in `VisitFunctionDecl` but the function 
exits early since we are not reading c++ (line lib/Index/USRGeneration.cpp:238).


Repository:
  rC Clang

https://reviews.llvm.org/D46084

Files:
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/Basic/DiagnosticCommonKinds.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
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -53,6 +53,12 @@
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
+BTCASE(ShortAccum);
+BTCASE(Accum);
+BTCASE(LongAccum);
+BTCASE(UShortAccum);
+BTCASE(UAccum);
+BTCASE(ULongAccum);
 BTCASE(Float16);
 BTCASE(Float128);
 BTCASE(NullPtr);
@@ -542,6 +548,12 @@
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);
+TKIND(ShortAccum);
+TKIND(Accum);
+TKIND(LongAccum);
+TKIND(UShortAccum);
+TKIND(UAccum);
+TKIND(ULongAccum);
 TKIND(Float16);
 TKIND(Float128);
 TKIND(NullPtr);
Index: test/Frontend/accum_errors.cpp
===
--- /dev/null
+++ test/Frontend/accum_errors.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c++ %s -verify
+
+// Name namgling is not provided for fixed point types in c++
+
+signed short _Accum s_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed _Accum s_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed long _Accum s_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned short _Accum u_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned _Accum u_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned long _Accum u_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+
+short _Accum short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+_Accum accum; // expected-error{{Fixed point types are only allowed in C}}
+long _Accum long_accum;  // expected-error{{Fixed point types are only allowed in C}}
Index: test/Frontend/accum_errors.c
===
--- /dev/null
+++ test/Frontend/accum_errors.c
@@ -0,0 +1,4 @@
+// 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}}
Index: test/Frontend/accum.c
===
--- /dev/null
+++ test/Frontend/accum.c
@@ -0,0 +1,26 @@
+// RUN: %clang -cc1 -x c -ast-dump %s | FileCheck %s --strict-whitespace
+
+/*  Various contexts where type _Accum can appear. */
+
+// 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;
+
+// Aliased fixed point types
+short _Accum short_accum;
+_Accum accum;
+long _Accum long_accum;
+
+// CHECK:  |-VarDecl {{.*}} s_short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_accum '_Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_long_accum 'long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_short_accum 'unsigned short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_accum 'unsigned _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_long_accum 'unsigned long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} short_a

[PATCH] D45177: CStringChecker, check strlcpy/strlcat

2018-05-17 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

I admit I do not due to much longer compilation time, I ll recompile all with 
and will see tomorrow if I can reproduce.


Repository:
  rC Clang

https://reviews.llvm.org/D45177



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


[PATCH] D45177: CStringChecker, check strlcpy/strlcat

2018-05-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D45177#1103774, @devnexen wrote:

> In https://reviews.llvm.org/D45177#1103162, @alexfh wrote:
>
> > See https://bugs.llvm.org/show_bug.cgi?id=37503 for a test case.
>
>
> I was unable to reproduce both FreeBSD and Linux. Plus my changes come after 
> checkNonNull.


I'm not 100% sure this was caused by your patch, but the stack trace looks 
suspiciously similar to what was changed here. As for not being able to 
reproduce: do you build Clang with assertions enabled?


Repository:
  rC Clang

https://reviews.llvm.org/D45177



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


r332675 - Support: Add a raw_ostream::write_zeros() function. NFCI.

2018-05-17 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Thu May 17 15:11:43 2018
New Revision: 332675

URL: http://llvm.org/viewvc/llvm-project?rev=332675&view=rev
Log:
Support: Add a raw_ostream::write_zeros() function. NFCI.

This will eventually replace MCObjectWriter::WriteZeros.

Part of PR37466.

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

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

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=332675&r1=332674&r2=332675&view=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Thu May 17 15:11:43 2018
@@ -1372,8 +1372,7 @@ void CoverageMappingModuleGen::emit() {
   // and coverage mappings is a multiple of 8.
   if (size_t Rem = OS.str().size() % 8) {
 CoverageMappingSize += 8 - Rem;
-for (size_t I = 0, S = 8 - Rem; I < S; ++I)
-  OS << '\0';
+OS.write_zeros(8 - Rem);
   }
   auto *FilenamesAndMappingsVal =
   llvm::ConstantDataArray::getString(Ctx, OS.str(), false);


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


[PATCH] D45177: CStringChecker, check strlcpy/strlcat

2018-05-17 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

In https://reviews.llvm.org/D45177#1103162, @alexfh wrote:

> See https://bugs.llvm.org/show_bug.cgi?id=37503 for a test case.


I was unable to reproduce both FreeBSD and Linux. Plus my changes come after 
checkNonNull.


Repository:
  rC Clang

https://reviews.llvm.org/D45177



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


[PATCH] D44954: [clangd] Add "member" symbols to the index

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

> It's also for textDocument/documentSymbol. For this, we technically don't 
> need them in the static index since we could collect symbols when the 
> document is opened, but we also want them for workspaceSymbols so we might as 
> well use the same symbol collector, etc. There should be more things that 
> would also use symbol in main files, like Type Hierarchy.

I see. Thanks! Looks like we would need to collect symbols in main file at some 
point. We could probably filter out main file symbols in dynamic index for code 
completion, but we would probably need a flag to turn off main file symbols in 
case this leads to a huge size increase. I would also expect different indexers 
(dynamic and static ) to share SymbolCollector, but it should be easily 
configured to behave differently via `SymbolCollector::Options`. Anyhow, let's 
discuss more about this when we are turning on main file symbols :)




Comment at: clangd/index/Index.h:160
+  /// The Decl::Kind for the context of the symbol, i.e. what contains it.
+  Decl::Kind DeclContextKind;
+  /// Whether or not this is an enumerator inside a scoped enum (C++11).

malaperle wrote:
> ioeric wrote:
> > ilya-biryukov wrote:
> > > How do we use `DeclContextKind`?
> > > Why did we decide to not go with a `bool ForCompletion` instead? (I'm 
> > > probably missing a conversation in the workspaceSymbol review, could you 
> > > point me to those instead?)
> > > 
> > > I'm asking because clang enums are very detailed and designed for use in 
> > > the compiler, using them in the index seems to complicate things.
> > > It feels we don't need this level of detail in the symbols. Similar to 
> > > how we don't store the whole structural type, but rely on string 
> > > representation of completion label instead.
> > +1
> > 
> > `ForCompletion` sounds reasonable as the current design of index-based code 
> > completion relies on assumptions about contexts. 
> My thinking was that the "ForCompletion" boolean was too specific and 
> tailored for one client use. I thought the Symbol information should not have 
> that much hard-coded knowledge on how it would be used. It would be odd to 
> have "ForWorkspaceSymbol", "ForDocumentSymbol", etc. That is why I was going 
> for a slightly more detailed symbol information that opened the door for more 
> arbitrary queries for symbol clients. But it complicates things a bit more 
> and I'd be happy to bring back the "ForCompletion" if it makes more sense for 
> now.
I think code completion, with the most complicated use of the index so far, 
probably deserves a flag :P I would expect/hope other features to be less 
"picky" about symbols. A high-level flag like `ForCompletion` would help keep 
knowledge about filtering for code completion (e.g. enums ...) inside symbol 
collector, which I think could be a win.

FWIW, `ForCompletion` makes it sound like a symbols is collected specifically 
for code completion. Maybe something like `bool SupportGlobalCompletion` would 
be better?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44954



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


Re: r332639 - Fix a mangling failure on clang-cl C++17

2018-05-17 Thread Reid Kleckner via cfe-commits
Thanks! Added in 332646

On Thu, May 17, 2018 at 11:30 AM Nico Weber  wrote:

> You might've forgotten to svn add the test :-)
>
> On Thu, May 17, 2018, 2:16 PM Reid Kleckner via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rnk
>> Date: Thu May 17 11:12:18 2018
>> New Revision: 332639
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=332639&view=rev
>> Log:
>> Fix a mangling failure on clang-cl C++17
>>
>> MethodVFTableLocations in MigrosoftVTableContext contains canonicalized
>> decl. But, it's sometimes asked to lookup for non-canonicalized decl,
>> and that causes assertion failure, and compilation failure.
>>
>> Fixes PR37481.
>>
>> Patch by Taiju Tsuiki!
>>
>> Differential Revision: https://reviews.llvm.org/D46929
>>
>> Modified:
>> cfe/trunk/lib/AST/VTableBuilder.cpp
>> cfe/trunk/lib/CodeGen/CGCXX.cpp
>> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
>> cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
>>
>> Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=332639&r1=332638&r2=332639&view=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/VTableBuilder.cpp (original)
>> +++ cfe/trunk/lib/AST/VTableBuilder.cpp Thu May 17 11:12:18 2018
>> @@ -2223,6 +2223,7 @@ ItaniumVTableContext::ItaniumVTableConte
>>  ItaniumVTableContext::~ItaniumVTableContext() {}
>>
>>  uint64_t ItaniumVTableContext::getMethodVTableIndex(GlobalDecl GD) {
>> +  GD = GD.getCanonicalDecl();
>>MethodVTableIndicesTy::iterator I = MethodVTableIndices.find(GD);
>>if (I != MethodVTableIndices.end())
>>  return I->second;
>> @@ -2503,6 +2504,8 @@ private:
>>  for (const auto &I : MethodInfoMap) {
>>const CXXMethodDecl *MD = I.first;
>>const MethodInfo &MI = I.second;
>> +  assert(MD == MD->getCanonicalDecl());
>> +
>>// Skip the methods that the MostDerivedClass didn't override
>>// and the entries shadowed by return adjusting thunks.
>>if (MD->getParent() != MostDerivedClass || MI.Shadowed)
>> @@ -3737,6 +3740,8 @@ MicrosoftVTableContext::getMethodVFTable
>>if (isa(GD.getDecl()))
>>  assert(GD.getDtorType() == Dtor_Deleting);
>>
>> +  GD = GD.getCanonicalDecl();
>> +
>>MethodVFTableLocationsTy::iterator I = MethodVFTableLocations.find(GD);
>>if (I != MethodVFTableLocations.end())
>>  return I->second;
>>
>> Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=332639&r1=332638&r2=332639&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Thu May 17 11:12:18 2018
>> @@ -267,7 +267,6 @@ static CGCallee BuildAppleKextVirtualCal
>>const CXXRecordDecl *RD) {
>>assert(!CGF.CGM.getTarget().getCXXABI().isMicrosoft() &&
>>   "No kext in Microsoft ABI");
>> -  GD = GD.getCanonicalDecl();
>>CodeGenModule &CGM = CGF.CGM;
>>llvm::Value *VTable = CGM.getCXXABI().getAddrOfVTable(RD, CharUnits());
>>Ty = Ty->getPointerTo()->getPointerTo();
>> @@ -283,7 +282,7 @@ static CGCallee BuildAppleKextVirtualCal
>>  CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex,
>> "vfnkxt");
>>llvm::Value *VFunc =
>>  CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.PointerAlignInBytes);
>> -  CGCallee Callee(GD.getDecl(), VFunc);
>> +  CGCallee Callee(GD.getDecl()->getCanonicalDecl(), VFunc);
>>return Callee;
>>  }
>>
>>
>> Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=332639&r1=332638&r2=332639&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu May 17 11:12:18 2018
>> @@ -825,7 +825,6 @@ ItaniumCXXABI::EmitMemberFunctionPointer
>>  llvm::Constant *ItaniumCXXABI::BuildMemberPointer(const CXXMethodDecl
>> *MD,
>>CharUnits
>> ThisAdjustment) {
>>assert(MD->isInstance() && "Member function must not be static!");
>> -  MD = MD->getCanonicalDecl();
>>
>>CodeGenTypes &Types = CGM.getTypes();
>>
>> @@ -1640,7 +1639,6 @@ CGCallee ItaniumCXXABI::getVirtualFuncti
>>Address This,
>>llvm::Type *Ty,
>>SourceLocation Loc) {
>> -  GD = GD.getCanonicalDecl();
>>Ty = Ty->getPointerTo()->getPointerTo();
>>auto *MethodDecl = cast(GD.getDecl());
>>llvm::Value *VTable = CGF.GetVTablePtr(This, Ty,
>> MethodDecl->getParent());
>> @@ -1674,7 +1672,7 @@ CGCallee ItaniumCXXABI::getVirtualFuncti
>>  V

[PATCH] D46084: [Fixed Point Arithmetic] Addition of the Fixed Point _Accum type

2018-05-17 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 147386.
leonardchan added a comment.

Ran git-clang-tidy on all affected files


Repository:
  rC Clang

https://reviews.llvm.org/D46084

Files:
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/Basic/DiagnosticCommonKinds.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
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -53,6 +53,12 @@
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
+BTCASE(ShortAccum);
+BTCASE(Accum);
+BTCASE(LongAccum);
+BTCASE(UShortAccum);
+BTCASE(UAccum);
+BTCASE(ULongAccum);
 BTCASE(Float16);
 BTCASE(Float128);
 BTCASE(NullPtr);
@@ -542,6 +548,12 @@
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);
+TKIND(ShortAccum);
+TKIND(Accum);
+TKIND(LongAccum);
+TKIND(UShortAccum);
+TKIND(UAccum);
+TKIND(ULongAccum);
 TKIND(Float16);
 TKIND(Float128);
 TKIND(NullPtr);
Index: test/Frontend/accum_errors.cpp
===
--- /dev/null
+++ test/Frontend/accum_errors.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c++ %s -verify
+
+// Name namgling is not provided for fixed point types in c++
+
+signed short _Accum s_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed _Accum s_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed long _Accum s_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned short _Accum u_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned _Accum u_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned long _Accum u_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+
+short _Accum short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+_Accum accum; // expected-error{{Fixed point types are only allowed in C}}
+long _Accum long_accum;  // expected-error{{Fixed point types are only allowed in C}}
Index: test/Frontend/accum_errors.c
===
--- /dev/null
+++ test/Frontend/accum_errors.c
@@ -0,0 +1,4 @@
+// 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}}
Index: test/Frontend/accum.c
===
--- /dev/null
+++ test/Frontend/accum.c
@@ -0,0 +1,26 @@
+// RUN: %clang -cc1 -x c -ast-dump %s | FileCheck %s --strict-whitespace
+
+/*  Various contexts where type _Accum can appear. */
+
+// 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;
+
+// Aliased fixed point types
+short _Accum short_accum;
+_Accum accum;
+long _Accum long_accum;
+
+// CHECK:  |-VarDecl {{.*}} s_short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_accum '_Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_long_accum 'long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_short_accum 'unsigned short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_accum 'unsigned _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_long_accum 'unsigned long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} accum '_Accum'
+// CHECK-NEXT: `-VarDecl {{.*}} long_accum 'long _Accum'
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -6816,6 +6816,24 @@
 case PREDEF_TYPE_LONGDOUBLE_ID:
   T = Context.LongDoubleTy;
   break;
+case PREDEF_TYPE_SHORT_ACCUM_ID:
+  T = Context.ShortAccumTy;
+  break;
+case PREDEF_TYPE_ACCUM_ID:
+  T = Context.AccumTy;
+  break;
+case PREDEF_TYPE_LONG_ACCUM_ID:
+  T = Co

[PATCH] D44954: [clangd] Add "member" symbols to the index

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

In https://reviews.llvm.org/D44954#1102807, @ilya-biryukov wrote:

> A few questions regarding class members. To pinpoint some interesting cases 
> and agree on how we want those to behave in the long run.
>
> How do we handle template specializations? What will the qualified names of 
> those instantiations be?
>  I.e. how do I query for `push_back` inside a vector?  Which of the following 
> queries should produce a result?
>
> - `vector::push_back`. Should it match both `vector::push_back` and 
> `vector::push_back` or only the first one?
> - `vector::push_back`
> - `vector::push_back`


It's probably better to consider this in a future patch. Maybe something like 
the first suggestion: vector::push_back and match both. Otherwise, I would 
think it might be a bit too verbose to have to spell out all of the 
specialization. Maybe we could allow it too. So... all of the above? :)

> What scopes will non-scoped enum members have?
>  E.g. if I have `enum En { A,B,C}`, which of the following queries will and 
> won't find enumerators?
> 
> - `En::A`
> - `::A`
> - `A`

Hmm. I think all of them, since you can refer them like that in code too. Case 
#1 doesn't work but that was the case before this patch so it can probably be 
addressed separately. I'll add some tests though!

In https://reviews.llvm.org/D44954#1103026, @ioeric wrote:

> In https://reviews.llvm.org/D44954#1101922, @malaperle wrote:
>
> > @ioeric You mentioned in https://reviews.llvm.org/D46751 that it would make 
> > sense to add a flag to disable indexing members. Could you comment on that? 
> > What kind of granularity were you thinking? Would a "member" flag cover 
> > both class members (member vars and functions) and enum class enumerators 
> > for example? I think that would be reasonable. But I will also add symbols 
> > in main files too, so another flag for that? Hmmm.
>
>
> Sam convinced me that members would still be interesting for our internal 
> index service (e.g. locations of members would be useful for go-to-def). I'll 
> investigate how much impact that would be by running the indexer with your 
> change patched in, but I don't want to block you on that, so I'm fine with 
> checking this in without any filter. We could revisit the filter design when 
> needed.
>
> We actually had an option for indexing symbols in main files :) But it was 
> removed as it turned out to be unused for the features clangd had at that 
> point. I think it would be reasonable to add it back if we start supporting 
> collecting main file symbols again. Maybe out of the scope of this patch, but 
> I am interested in the use cases you have for symbols in main files, besides 
> in `workspaceSymbols`?


It's also for textDocument/documentSymbol. For this, we technically don't need 
them in the static index since we could collect symbols when the document is 
opened, but we also want them for workspaceSymbols so we might as well use the 
same symbol collector, etc. There should be more things that would also use 
symbol in main files, like Type Hierarchy.




Comment at: clangd/CodeComplete.cpp:932
 Req.Query = Filter->pattern();
+Req.DeclContexts = {Decl::Kind::Namespace, Decl::Kind::TranslationUnit,
+Decl::Kind::LinkageSpec, Decl::Kind::Enum};

ilya-biryukov wrote:
> malaperle wrote:
> > I want to add a comment here, but I want to make sure I understand why in 
> > the first place we were not indexing symbols outside these contexts for the 
> > purpose of code completion. Is it because those will be available by Sema 
> > code completion anyway?
> C++ lookup rules inside classes are way more complicated than in namespaces 
> and we can't possibly hope to give a decent approximation for those.
> Moreover, completion inside classes does not require any non-local 
> information, so there does not seem to be a win when using the index anyway.
> So we'd rather rely on clang to do completion there, it will give way more 
> useful results than any index implementation.
Makes sense. Thanks! I'll be able to document this better now with the full 
picture.



Comment at: clangd/index/Index.h:160
+  /// The Decl::Kind for the context of the symbol, i.e. what contains it.
+  Decl::Kind DeclContextKind;
+  /// Whether or not this is an enumerator inside a scoped enum (C++11).

ioeric wrote:
> ilya-biryukov wrote:
> > How do we use `DeclContextKind`?
> > Why did we decide to not go with a `bool ForCompletion` instead? (I'm 
> > probably missing a conversation in the workspaceSymbol review, could you 
> > point me to those instead?)
> > 
> > I'm asking because clang enums are very detailed and designed for use in 
> > the compiler, using them in the index seems to complicate things.
> > It feels we don't need this level of detail in the symbols. Similar to how 
> > we don't store the whole structural type, but rely on string representation 
> > o

[PATCH] D43424: [clang-doc] Implement a (simple) Markdown generator

2018-05-17 Thread Joe via Phabricator via cfe-commits
rja added inline comments.



Comment at: clang-doc/generators/MDGenerator.cpp:57
+  sys::path::native(NamespacesPath, Path);
+  // for (const auto &Namespace : I->Namespace)
+  //   sys::path::append(Path, IS->find(Namespace)->Name);

remove commented code?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43424



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


[PATCH] D46994: [test-suite] Test CUDA in C++14 mode with C++11 stdlibs.

2018-05-17 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332659: [test-suite] Test CUDA in C++14 mode with C++11 
stdlibs. (authored by jlebar, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46994?vs=147225&id=147383#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46994

Files:
  test-suite/trunk/External/CUDA/CMakeLists.txt
  test-suite/trunk/External/CUDA/algorithm.cu
  test-suite/trunk/External/CUDA/cmath.cu
  test-suite/trunk/External/CUDA/complex.cu

Index: test-suite/trunk/External/CUDA/complex.cu
===
--- test-suite/trunk/External/CUDA/complex.cu
+++ test-suite/trunk/External/CUDA/complex.cu
@@ -7,25 +7,29 @@
 //
 //===--===//
 
-#include 
-#include 
-#include 
-
 // These are loosely adapted from libc++'s tests.  In general, we don't care a
 // ton about verifying the return types or results we get, on the assumption
 // that our standard library is correct. But we care deeply about calling every
 // overload of every function (so that we verify that everything compiles).
 //
 // We do care about the results of complex multiplication / division, since
 // these use code we've written.
 
+#include 
+
 // These tests are pretty annoying to write without C++11, so we require that.
 // In addition, these tests currently don't compile with libc++, because of the
 // issue in https://reviews.llvm.org/D25403.
 //
 // TODO: Once that issue is resolved, take out !defined(_LIBCPP_VERSION) here.
-#if __cplusplus >= 201103L && !defined(_LIBCPP_VERSION)
+//
+// In addition, these tests don't work in C++14 mode with pre-C++14 versions of
+// libstdc++ (compile errors in ).
+#if __cplusplus >= 201103L && !defined(_LIBCPP_VERSION) && \
+(__cplusplus < 201402L || STDLIB_VERSION >= 2014)
 
+#include 
+#include 
 #include 
 
 template 
@@ -69,7 +73,7 @@
 }
 
 __device__ void test_literals() {
-#if __cplusplus >= 201402L
+#if __cplusplus >= 201402L && STDLIB_VERSION >= 2014
   using namespace std::literals::complex_literals;
 
   {
Index: test-suite/trunk/External/CUDA/CMakeLists.txt
===
--- test-suite/trunk/External/CUDA/CMakeLists.txt
+++ test-suite/trunk/External/CUDA/CMakeLists.txt
@@ -316,28 +316,33 @@
   set(_Std_LDFLAGS -std=${_Std})
   foreach(_GccPath IN LISTS GCC_PATHS)
 get_version(_GccVersion ${_GccPath})
-# libstdc++ seems not to support C++14 before version 5.0.
-if(${_Std} STREQUAL "c++14" AND ${_GccVersion} VERSION_LESS "5.0")
-  continue()
-endif()
 set(_Gcc_Suffix "libstdc++-${_GccVersion}")
 # Tell clang to use libstdc++ and where to find it.
 set(_Stdlib_CPPFLAGS -stdlib=libstdc++ -gcc-toolchain ${_GccPath})
 set(_Stdlib_LDFLAGS  -stdlib=libstdc++)
 # Add libstdc++ as link dependency.
 set(_Stdlib_Libs libstdcxx-${_GccVersion})
 
+# libstdc++ seems not to support C++14 before version 5.0.  We still
+# want to run in C++14 mode with old libstdc++s to test compiler C++14
+# with stdlib C++11, but we add a -D so that our tests can detect this.
+if (${_GccVersion} VERSION_LESS "5.0")
+  list(APPEND _Stdlib_CPPFLAGS -DSTDLIB_VERSION=2011)
+else()
+  list(APPEND _Stdlib_CPPFLAGS -DSTDLIB_VERSION=2014)
+endif()
+
 create_cuda_test_variant(${_Std} "${_Cuda_Suffix}-${_Std_Suffix}-${_Gcc_Suffix}")
   endforeach()
 
   if(HAVE_LIBCXX)
-	# Same as above, but for libc++
-	# Tell clang to use libc++
-	# We also need to add compiler's include path for cxxabi.h
-	get_filename_component(_compiler_path ${CMAKE_CXX_COMPILER} DIRECTORY)
-	set(_Stdlib_CPPFLAGS -stdlib=libc++ -I${_compiler_path}/../include/c++-build)
-	set(_Stdlib_LDFLAGS  -stdlib=libc++)
-	set(_Stdlib_Libs libcxx)
+# Same as above, but for libc++
+# Tell clang to use libc++
+# We also need to add compiler's include path for cxxabi.h
+get_filename_component(_compiler_path ${CMAKE_CXX_COMPILER} DIRECTORY)
+set(_Stdlib_CPPFLAGS -stdlib=libc++ -I${_compiler_path}/../include/c++-build -DSTDLIB_VERSION=2017)
+set(_Stdlib_LDFLAGS  -stdlib=libc++)
+set(_Stdlib_Libs libcxx)
 create_cuda_test_variant(${_Std} "${_Cuda_Suffix}-${_Std_Suffix}-libc++")
   endif()
 endforeach()
Index: test-suite/trunk/External/CUDA/cmath.cu
===
--- test-suite/trunk/External/CUDA/cmath.cu
+++ test-suite/trunk/External/CUDA/cmath.cu
@@ -1145,7 +1145,7 @@
 assert(std::hypot(3.f, 4.) == 5);
 assert(std::hypot(3.f, 4.f) == 5);
 
-#if TEST_STD_VER > 14
+#if __cplusplus >= 201703L && STDLIB_VERSION >= 2017
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert(

[PATCH] D46995: [test-suite] Enable CUDA complex tests with libc++ now that D25403 is resolved.

2018-05-17 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
jlebar marked an inline comment as done.
Closed by commit rL332660: [test-suite] Enable CUDA complex tests with libc++ 
now that D25403 is resolved. (authored by jlebar, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D46995

Files:
  test-suite/trunk/External/CUDA/complex.cu


Index: test-suite/trunk/External/CUDA/complex.cu
===
--- test-suite/trunk/External/CUDA/complex.cu
+++ test-suite/trunk/External/CUDA/complex.cu
@@ -18,15 +18,10 @@
 #include 
 
 // These tests are pretty annoying to write without C++11, so we require that.
-// In addition, these tests currently don't compile with libc++, because of the
-// issue in https://reviews.llvm.org/D25403.
-//
-// TODO: Once that issue is resolved, take out !defined(_LIBCPP_VERSION) here.
 //
 // In addition, these tests don't work in C++14 mode with pre-C++14 versions of
 // libstdc++ (compile errors in ).
-#if __cplusplus >= 201103L && !defined(_LIBCPP_VERSION) && \
-(__cplusplus < 201402L || STDLIB_VERSION >= 2014)
+#if __cplusplus >= 201103L && (__cplusplus < 201402L || STDLIB_VERSION >= 2014)
 
 #include 
 #include 


Index: test-suite/trunk/External/CUDA/complex.cu
===
--- test-suite/trunk/External/CUDA/complex.cu
+++ test-suite/trunk/External/CUDA/complex.cu
@@ -18,15 +18,10 @@
 #include 
 
 // These tests are pretty annoying to write without C++11, so we require that.
-// In addition, these tests currently don't compile with libc++, because of the
-// issue in https://reviews.llvm.org/D25403.
-//
-// TODO: Once that issue is resolved, take out !defined(_LIBCPP_VERSION) here.
 //
 // In addition, these tests don't work in C++14 mode with pre-C++14 versions of
 // libstdc++ (compile errors in ).
-#if __cplusplus >= 201103L && !defined(_LIBCPP_VERSION) && \
-(__cplusplus < 201402L || STDLIB_VERSION >= 2014)
+#if __cplusplus >= 201103L && (__cplusplus < 201402L || STDLIB_VERSION >= 2014)
 
 #include 
 #include 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46994: [test-suite] Test CUDA in C++14 mode with C++11 stdlibs.

2018-05-17 Thread Justin Lebar via Phabricator via cfe-commits
jlebar marked an inline comment as done.
jlebar added a comment.

Thanks for the reviews, Art.  Submitting with this change...


Repository:
  rT test-suite

https://reviews.llvm.org/D46994



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


[PATCH] D46995: [test-suite] Enable CUDA complex tests with libc++ now that D25403 is resolved.

2018-05-17 Thread Justin Lebar via Phabricator via cfe-commits
jlebar marked an inline comment as done.
jlebar added inline comments.



Comment at: External/CUDA/complex.cu:24
 // libstdc++ (compile errors in ).
-#if __cplusplus >= 201103L && !defined(_LIBCPP_VERSION) && \
-(__cplusplus < 201402L || STDLIB_VERSION >= 2014)
+#if __cplusplus >= 201103L && (__cplusplus < 201402L || STDLIB_VERSION >= 2014)
 

tra wrote:
> Is this specific to c++14 only, or will we have similar conditions for 
> c++17,20, etc?
> Perhaps we could express library version requirements as `STDLIB_VERSION >= 
> (__cplusplus / 100)` ?
> I'm OK with either way.
> 
> 
I think it's specific to c++14 -- or at least, it's not necessarily a general 
problem.  The other benchmarks work with C++14 compiler plus C++11 stdlib -- 
it's just  that gives us problems in the particular gcc versions we 
happen to use.


Repository:
  rT test-suite

https://reviews.llvm.org/D46995



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


[PATCH] D47007: [Sanitizer] CStringChecker fix for strlcpy when no bytes are copied to the dest buffer

2018-05-17 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

In https://reviews.llvm.org/D47007#1103551, @george.karpenkov wrote:

> Is it a fix for https://bugs.llvm.org/show_bug.cgi?id=37503 ?


Nope. more for last NoQ comment. Will try for this one once I finish setting it 
up.


Repository:
  rC Clang

https://reviews.llvm.org/D47007



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


[PATCH] D46472: [HIP] Support offloading by linker script

2018-05-17 Thread Tony Tye via Phabricator via cfe-commits
t-tye accepted this revision.
t-tye added a comment.
This revision is now accepted and ready to land.

LGTM except for minor suggestions.




Comment at: lib/CodeGen/CGCUDANV.cpp:361-373
+  if (IsHIP)
+FatbinConstantName = ".hip_fatbin";
+  else if (RelocatableDeviceCode)
 // TODO: Figure out how this is called on mac OS!
 FatbinConstantName = "__nv_relfatbin";
   else
 FatbinConstantName =

Should this all be inside an if (IsHip) so the names can be different for HIP 
and NV CUDA? Seems HIP should not be using names with VV_CUDA in them. In fact 
maybe the following IF should be included as well to consilidate the NV CUDA 
code and HIP code together.



Comment at: lib/CodeGen/CGCUDANV.cpp:394-398
   // Fatbin wrapper magic.
   Values.addInt(IntTy, 0x466243b1);
   // Fatbin version.
   Values.addInt(IntTy, 1);
   // Data.

Should HIP use the same magic value and version number? Perhaps this should 
also be moved into the IsHip IF.



Comment at: lib/CodeGen/CGCUDANV.cpp:438
 
 // void __cudaRegisterLinkedBinary%NVModuleID%(void (*)(void *), void *,
 // void *, void (*)(void **))

Update comment for HIP



Comment at: lib/Driver/ToolChains/CommonArgs.cpp:150
+// If the current tool chain refers to an OpenMP or HIP offloading host, we
+// should ignore inputs that refer to OpenMP offloading devices - they will
+// be embedded according to a proper linker script.

OpenMP -> OpenMP or HIP



Comment at: lib/Driver/ToolChains/CommonArgs.cpp:1321-1322
+
+  // Construct clang-offload-bundler command to bundle object files for
+  // for different GPU archs.
+  ArgStringList BundlerArgs;

for for -> for


https://reviews.llvm.org/D46472



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


[PATCH] D47030: [Fixed Point Arithmetic] Checks for Precision Macros

2018-05-17 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 patch includes checks that the precision macros used for the fixed point 
fractional and integral bits meet the requirements for clause 6.2.6.3 in 
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf.

Checks for any disagreements with the recommendations will throw warnings.

I also added my own warning that recommends the integral and fractional bits 
for _Accum types take up the width of the whole underlying integer to prevent 
having to mask out the padding bits when performing comparisons.


Repository:
  rC Clang

https://reviews.llvm.org/D47030

Files:
  cmake/modules/InitFixedPointBits.cmake

Index: cmake/modules/InitFixedPointBits.cmake
===
--- cmake/modules/InitFixedPointBits.cmake
+++ cmake/modules/InitFixedPointBits.cmake
@@ -60,26 +60,170 @@
   set(ULACCUM_IBIT 32)
 endif()
 
-# Checks for each bit size
+# Checks for each bit size defined in clause 6.2.6.3
+
+# Cannot go below the minimum number of fractional and integral bits for the
+# various types specified in clause 7.18a.3.
+function(assert_min_bits macro min_bits)
+  set("macro_name" ${macro})
+  set("macro_val" ${${macro}})
+  if(${macro_val} LESS ${min_bits})
+message(FATAL_ERROR "The minimum value allowed for ${macro_name} is ${min_bits}. "
+	"${macro_val} was provided.")
+  endif()
+endfunction()
+
+assert_min_bits(SFRACT_FBIT 7)
+assert_min_bits(FRACT_FBIT 15)
+assert_min_bits(LFRACT_FBIT 23)
+assert_min_bits(USFRACT_FBIT 7)
+assert_min_bits(UFRACT_FBIT 15)
+assert_min_bits(ULFRACT_FBIT 23)
+
+assert_min_bits(SACCUM_FBIT 7)
+assert_min_bits(ACCUM_FBIT 15)
+assert_min_bits(LACCUM_FBIT 23)
+assert_min_bits(USACCUM_FBIT 7)
+assert_min_bits(UACCUM_FBIT 15)
+assert_min_bits(ULACCUM_FBIT 23)
+
+assert_min_bits(SACCUM_IBIT 4)
+assert_min_bits(ACCUM_IBIT 4)
+assert_min_bits(LACCUM_IBIT 4)
+assert_min_bits(USACCUM_IBIT 4)
+assert_min_bits(UACCUM_IBIT 4)
+assert_min_bits(ULACCUM_IBIT 4)
+
 # Each unsigned fract type has either the same number of fractional bits as,
 # or one more fractional bit than, its corresponding signed fract type.
-# TODO: Implement remaining checks in clause 6.2.6.3.
-function(check_diff_at_most_1 sfract_fbits ufract_fbits)
-  if(sfract_fbits EQUAL ufract_fbits)
-return()
-  endif()
+function(assert_fract_diff sfract_fbits ufract_fbits)
   math(EXPR diff "${ufract_fbits} - ${sfract_fbits}")
-  if(diff EQUAL 1)
-return()
+  if(NOT((${diff} EQUAL 0) OR (${diff} EQUAL 1)))
+message(FATAL_ERROR "Each unsigned fract type must have either the same number of "
+  	"fractional bits as, or one more fractional bit than, its corresponding "
+  	"signed fract type.")
+  endif()
+endfunction()
+
+assert_fract_diff(${SFRACT_FBIT} ${USFRACT_FBIT})
+assert_fract_diff(${FRACT_FBIT} ${UFRACT_FBIT})
+assert_fract_diff(${LFRACT_FBIT} ${ULFRACT_FBIT})
+
+# When arranged in order of increasing rank (see 6.3.1.3a), the number of
+# fractional bits is nondecreasing for each of the following sets of
+# fixed-point types:
+# - signed fract types
+# - unsigned fract types
+# - signed accum types
+# - unsigned accum types.
+function(assert_non_decreasing short_type_bits middle_type_bits long_type_bits
+	 type_family bit_type)
+  if((${short_type_bits} GREATER ${middle_type_bits}) OR
+ (${middle_type_bits} GREATER ${long_type_bits}))
+message(FATAL_ERROR "The number of ${bit_type} bits in ${type_family} types must be "
+  	"non decreasing in order of increasing rank.")
+  endif()
+endfunction()
+
+assert_non_decreasing(${SFRACT_FBIT} ${FRACT_FBIT} ${LFRACT_FBIT} "signed _Fract" "fractional")
+assert_non_decreasing(${USFRACT_FBIT} ${UFRACT_FBIT} ${ULFRACT_FBIT} "unsigned _Fract" "fractional")
+assert_non_decreasing(${SACCUM_FBIT} ${ACCUM_FBIT} ${LACCUM_FBIT} "signed _Accum" "fractional")
+assert_non_decreasing(${USACCUM_FBIT} ${UACCUM_FBIT} ${ULACCUM_FBIT} "unsigned _Accum" "fractional")
+
+# When arranged in order of increasing rank (see 6.3.1.3a), the number of
+# integral bits is nondecreasing for each of the following sets of
+# fixed-point types:
+# - signed accum types
+# - unsigned accum types.
+assert_non_decreasing(${SACCUM_IBIT} ${ACCUM_IBIT} ${LACCUM_IBIT} "signed _Accum" "integral")
+assert_non_decreasing(${USACCUM_IBIT} ${UACCUM_IBIT} ${ULACCUM_IBIT} "unsigned _Accum" "integral")
+
+# Each signed accum type has at least as many integral bits as its
+# corresponding unsigned accum type.
+function(assert_integral_diff saccum_ibits uaccum_ibits)
+  if(${saccum_ibits} LESS ${uaccum_ibits})
+message(FATAL_ERROR "Each signed accum type must have at least as many integral bits as its "
+	"corresponding unsigned accum type.")
+  endif()
+endfunction()
+
+assert_integral_diff(${SACCUM_IBIT} ${USACCUM_IBIT})
+assert_integral_diff(${ACCUM_IBIT} ${UACCUM_IBIT})

[PATCH] D47007: [Sanitizer] CStringChecker fix for strlcpy when no bytes are copied to the dest buffer

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

Is it a fix for https://bugs.llvm.org/show_bug.cgi?id=37503 ?


Repository:
  rC Clang

https://reviews.llvm.org/D47007



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


[PATCH] D47029: [X86] Remove some preprocessor feature checks from intrinsic headers

2018-05-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: echristo, RKSimon, spatel.

These look to be a couple things that weren't remvoed when we switched to 
target attribute.

The popcnt makes including just smmintrin.h also include popcntintrin.h. The 
popcnt file itself already contains target attrributes.

The prefetch ones are just wrappers around __builtin_prefetch which we have 
graceful fallbacks for in the backend if the exact instruction isn't available. 
So there's no reason to hide them. And it makes them available in functions 
that have the write target attribute but not a -march command line flag.


https://reviews.llvm.org/D47029

Files:
  lib/Headers/prfchwintrin.h
  lib/Headers/smmintrin.h


Index: lib/Headers/smmintrin.h
===
--- lib/Headers/smmintrin.h
+++ lib/Headers/smmintrin.h
@@ -2458,8 +2458,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
-#ifdef __POPCNT__
 #include 
-#endif
 
 #endif /* __SMMINTRIN_H */
Index: lib/Headers/prfchwintrin.h
===
--- lib/Headers/prfchwintrin.h
+++ lib/Headers/prfchwintrin.h
@@ -28,7 +28,6 @@
 #ifndef __PRFCHWINTRIN_H
 #define __PRFCHWINTRIN_H
 
-#if defined(__PRFCHW__) || defined(__3dNOW__)
 /// Loads a memory sequence containing the specified memory address into
 ///all data cache levels. The cache-coherency state is set to exclusive.
 ///Data can be read from and written to the cache line without additional
@@ -66,6 +65,5 @@
 {
   __builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */);
 }
-#endif
 
 #endif /* __PRFCHWINTRIN_H */


Index: lib/Headers/smmintrin.h
===
--- lib/Headers/smmintrin.h
+++ lib/Headers/smmintrin.h
@@ -2458,8 +2458,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
-#ifdef __POPCNT__
 #include 
-#endif
 
 #endif /* __SMMINTRIN_H */
Index: lib/Headers/prfchwintrin.h
===
--- lib/Headers/prfchwintrin.h
+++ lib/Headers/prfchwintrin.h
@@ -28,7 +28,6 @@
 #ifndef __PRFCHWINTRIN_H
 #define __PRFCHWINTRIN_H
 
-#if defined(__PRFCHW__) || defined(__3dNOW__)
 /// Loads a memory sequence containing the specified memory address into
 ///all data cache levels. The cache-coherency state is set to exclusive.
 ///Data can be read from and written to the cache line without additional
@@ -66,6 +65,5 @@
 {
   __builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */);
 }
-#endif
 
 #endif /* __PRFCHWINTRIN_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47028: [clang-format/ObjC] Correctly annotate single-component ObjC method invocations

2018-05-17 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: djasper, jolesiak.
Herald added subscribers: cfe-commits, klimek.

Previously, clang-format's parser would fail to annotate the
selector in a single-component Objective-C method invocation with
`TT_SelectorName`. For example, the following:

  [foo bar];

would parse `bar` as `TT_Unknown`:

  M=0 C=1 T=Unknown S=0 B=0 BK=0 P=140 Name=identifier L=34 PPK=2
  FakeLParens= FakeRParens=0 II=0x559d5db51770 Text='bar'

This caused us to fail to insert a space after a closing cast rparen,
so the following:

  [((Foo *)foo) bar];

would format as:

  [((Foo *)foo)bar];

This diff fixes the issue by ensuring we annotate the selector
in a single-component Objective-C method invocation as
`TT_SelectorName`.

Test Plan: New tests added. Ran tests with:

  % make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D47028

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestObjC.cpp


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -792,6 +792,10 @@
"  a = 42;\n"
"}];");
 
+  // Space between cast rparen and selector name component.
+  verifyFormat("[((Foo *)foo) bar];");
+  verifyFormat("[((Foo *)foo) bar:1 blech:2];");
+
   // Message receiver taking multiple lines.
   Style.ColumnLimit = 20;
   // Non-corner case.
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -501,6 +501,13 @@
 }
 if (StartsObjCMethodExpr && CurrentToken->Previous != Left) {
   CurrentToken->Type = TT_ObjCMethodExpr;
+  // If we haven't seen a colon yet, make sure the last identifier
+  // before the r_square is tagged as a selector name component.
+  if (!ColonFound && CurrentToken->Previous &&
+  CurrentToken->Previous->is(TT_Unknown) &&
+  canBeObjCSelectorComponent(*CurrentToken->Previous)) {
+CurrentToken->Previous->Type = TT_SelectorName;
+  }
   // determineStarAmpUsage() thinks that '*' '[' is allocating an
   // array of pointers, but if '[' starts a selector then '*' is a
   // binary operator.


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -792,6 +792,10 @@
"  a = 42;\n"
"}];");
 
+  // Space between cast rparen and selector name component.
+  verifyFormat("[((Foo *)foo) bar];");
+  verifyFormat("[((Foo *)foo) bar:1 blech:2];");
+
   // Message receiver taking multiple lines.
   Style.ColumnLimit = 20;
   // Non-corner case.
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -501,6 +501,13 @@
 }
 if (StartsObjCMethodExpr && CurrentToken->Previous != Left) {
   CurrentToken->Type = TT_ObjCMethodExpr;
+  // If we haven't seen a colon yet, make sure the last identifier
+  // before the r_square is tagged as a selector name component.
+  if (!ColonFound && CurrentToken->Previous &&
+  CurrentToken->Previous->is(TT_Unknown) &&
+  canBeObjCSelectorComponent(*CurrentToken->Previous)) {
+CurrentToken->Previous->Type = TT_SelectorName;
+  }
   // determineStarAmpUsage() thinks that '*' '[' is allocating an
   // array of pointers, but if '[' starts a selector then '*' is a
   // binary operator.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-05-17 Thread Kim Gräsman via Phabricator via cfe-commits
kimgr added a comment.



>> Can you test what happens when you do clang-cl.exe /Yc stdafx.h /Tp 
>> stdafx.h, i.e. compile the header
>  > directly as C++ code and generate .pch from it? The normal MSVC modus 
> operandi is to have stdafx.h
>  > included in all source files (with /Yu) and stdafx.cpp to generate it 
> (with /Yc). That stdafx.cpp file serves
>  > no purpose, so I've played this trick to generate PCH from the header 
> directly. If it works, it might also
>  > be useful for your tests.
> 
> It isn't always the case that the .cpp file serves no purpose. It's true that 
> the MS project generators give you this setup but we've seen many projects 
> over the years that use a regular source file with code in it to generate the 
> PCH. The > object file generated during PCH create can have real code and the 
> compiler can take advantage of that fact by compiling less code in the 
> compilation units that use the PCH [...]

Cool, it's never occurred to me that the source file has any other purpose than 
including the pch header.

> I am not sure about your command: clang-cl.exe /Yc stdafx.h /Tp stdafx.h. The 
> space makes this a compile with just
>  /Yc (no through header). This patch doesn't address /Yc without the through 
> header. Something like clang-cl /Yc 
> /Tpstdafx.h would probably work if/when that is implemented.

I no longer have access to an MSVC environment, so I can't spell out the exact 
command, but I was trying to phrase a command that generates a PCH from the 
through-header *without a distinct source file*. It's proved to be a useful 
trick. I didn't mean to omit the through header, let's try again:

  cl.exe /Ycstdafx.h /TP stdafx.h

or if that doesn't work, a /FI switch may be required, I can't remember for 
sure what we did:

  cl.exe /Ycstdafx.h /TP /FI stdafx.h stdafx.h

>> I think the current skip-warning is over-specific -- what if I put an inline 
>> function before my PCH include?
>  >  A global variable? A #pragma? Or am I misunderstanding what skipping 
> does? It seems to me that any
>  > non-comment tokens before the PCH #include should raise a warning.
> 
> Not any tokens. The through header "feature" compiles all the code in the 
> file up to the through header.
>  So normally you are used to seeing just comments and #include . 
> That's one usage but your
>  PCH can be created from a source like this [...]

Thanks for the example, I must have misunderstood how MSVC PCHs work. With that 
background, the warning seems fine.

>> I find the "through header" terminology is a little hard to interpret, but I 
>> did find it on MSDN, so maybe it's well established.
> 
> Sorry about the terminology. I've been responsible for emulating this PCH 
> mechanism for many years so I may be one
>  of the few that understands it. I did try to keep that terminology out of 
> the diagnostics but I don't really have a better
>  name for through header.

:) Sounds like it's well-established!


https://reviews.llvm.org/D46652



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


[PATCH] D45212: [HIP] Let CUDA toolchain support HIP language mode and amdgpu

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

ping


https://reviews.llvm.org/D45212



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


[PATCH] D46472: [HIP] Support offloading by linker script

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

ping


https://reviews.llvm.org/D46472



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


[PATCH] D46476: [HIP] Add action builder for HIP

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

ping


https://reviews.llvm.org/D46476



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


r332646 - Add missing test case for r332639

2018-05-17 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu May 17 11:34:05 2018
New Revision: 332646

URL: http://llvm.org/viewvc/llvm-project?rev=332646&view=rev
Log:
Add missing test case for r332639

Added:
cfe/trunk/test/CodeGenCXX/PR37481.cpp

Added: cfe/trunk/test/CodeGenCXX/PR37481.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR37481.cpp?rev=332646&view=auto
==
--- cfe/trunk/test/CodeGenCXX/PR37481.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/PR37481.cpp Thu May 17 11:34:05 2018
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -o /dev/null -emit-llvm -std=c++17 -triple 
x86_64-pc-windows-msvc %s
+
+struct Foo {
+  virtual void f();
+  virtual void g();
+};
+
+void Foo::f() {}
+void Foo::g() {}
+
+template 
+void h() {}
+
+void x() {
+  h<&Foo::f>();
+  h<&Foo::g>();
+}


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


Re: r332639 - Fix a mangling failure on clang-cl C++17

2018-05-17 Thread Nico Weber via cfe-commits
You might've forgotten to svn add the test :-)

On Thu, May 17, 2018, 2:16 PM Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rnk
> Date: Thu May 17 11:12:18 2018
> New Revision: 332639
>
> URL: http://llvm.org/viewvc/llvm-project?rev=332639&view=rev
> Log:
> Fix a mangling failure on clang-cl C++17
>
> MethodVFTableLocations in MigrosoftVTableContext contains canonicalized
> decl. But, it's sometimes asked to lookup for non-canonicalized decl,
> and that causes assertion failure, and compilation failure.
>
> Fixes PR37481.
>
> Patch by Taiju Tsuiki!
>
> Differential Revision: https://reviews.llvm.org/D46929
>
> Modified:
> cfe/trunk/lib/AST/VTableBuilder.cpp
> cfe/trunk/lib/CodeGen/CGCXX.cpp
> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
>
> Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=332639&r1=332638&r2=332639&view=diff
>
> ==
> --- cfe/trunk/lib/AST/VTableBuilder.cpp (original)
> +++ cfe/trunk/lib/AST/VTableBuilder.cpp Thu May 17 11:12:18 2018
> @@ -2223,6 +2223,7 @@ ItaniumVTableContext::ItaniumVTableConte
>  ItaniumVTableContext::~ItaniumVTableContext() {}
>
>  uint64_t ItaniumVTableContext::getMethodVTableIndex(GlobalDecl GD) {
> +  GD = GD.getCanonicalDecl();
>MethodVTableIndicesTy::iterator I = MethodVTableIndices.find(GD);
>if (I != MethodVTableIndices.end())
>  return I->second;
> @@ -2503,6 +2504,8 @@ private:
>  for (const auto &I : MethodInfoMap) {
>const CXXMethodDecl *MD = I.first;
>const MethodInfo &MI = I.second;
> +  assert(MD == MD->getCanonicalDecl());
> +
>// Skip the methods that the MostDerivedClass didn't override
>// and the entries shadowed by return adjusting thunks.
>if (MD->getParent() != MostDerivedClass || MI.Shadowed)
> @@ -3737,6 +3740,8 @@ MicrosoftVTableContext::getMethodVFTable
>if (isa(GD.getDecl()))
>  assert(GD.getDtorType() == Dtor_Deleting);
>
> +  GD = GD.getCanonicalDecl();
> +
>MethodVFTableLocationsTy::iterator I = MethodVFTableLocations.find(GD);
>if (I != MethodVFTableLocations.end())
>  return I->second;
>
> Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=332639&r1=332638&r2=332639&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Thu May 17 11:12:18 2018
> @@ -267,7 +267,6 @@ static CGCallee BuildAppleKextVirtualCal
>const CXXRecordDecl *RD) {
>assert(!CGF.CGM.getTarget().getCXXABI().isMicrosoft() &&
>   "No kext in Microsoft ABI");
> -  GD = GD.getCanonicalDecl();
>CodeGenModule &CGM = CGF.CGM;
>llvm::Value *VTable = CGM.getCXXABI().getAddrOfVTable(RD, CharUnits());
>Ty = Ty->getPointerTo()->getPointerTo();
> @@ -283,7 +282,7 @@ static CGCallee BuildAppleKextVirtualCal
>  CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt");
>llvm::Value *VFunc =
>  CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.PointerAlignInBytes);
> -  CGCallee Callee(GD.getDecl(), VFunc);
> +  CGCallee Callee(GD.getDecl()->getCanonicalDecl(), VFunc);
>return Callee;
>  }
>
>
> Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=332639&r1=332638&r2=332639&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
> +++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu May 17 11:12:18 2018
> @@ -825,7 +825,6 @@ ItaniumCXXABI::EmitMemberFunctionPointer
>  llvm::Constant *ItaniumCXXABI::BuildMemberPointer(const CXXMethodDecl *MD,
>CharUnits
> ThisAdjustment) {
>assert(MD->isInstance() && "Member function must not be static!");
> -  MD = MD->getCanonicalDecl();
>
>CodeGenTypes &Types = CGM.getTypes();
>
> @@ -1640,7 +1639,6 @@ CGCallee ItaniumCXXABI::getVirtualFuncti
>Address This,
>llvm::Type *Ty,
>SourceLocation Loc) {
> -  GD = GD.getCanonicalDecl();
>Ty = Ty->getPointerTo()->getPointerTo();
>auto *MethodDecl = cast(GD.getDecl());
>llvm::Value *VTable = CGF.GetVTablePtr(This, Ty,
> MethodDecl->getParent());
> @@ -1674,7 +1672,7 @@ CGCallee ItaniumCXXABI::getVirtualFuncti
>  VFunc = VFuncLoad;
>}
>
> -  CGCallee Callee(MethodDecl, VFunc);
> +  CGCallee Callee(MethodDecl->getCanonicalDecl(), VFunc);
>return Callee;
>  }
>
>
> Modified: cfe/trunk/lib/CodeGen/MicrosoftC

[PATCH] D46998: [XRay][clang+compiler-rt] Make XRay depend on a C++ standard lib

2018-05-17 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

"In the future we can revisit this when we have a better idea as to why not 
depending on the C++ ABI functionality is a better solution."  - this was 
discussed previously in the thread linked from the bug.

A big thing, so far as I understand it, is that Clang doesn't require some 
specific C++ library, so wouldn't this break for users who didn't have the 
specific C++ library installed that compiler-rt for XRay was built against?


https://reviews.llvm.org/D46998



___
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-17 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 147360.
vsk added a comment.

- Add a regression test for switches.


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,18 @@
   return; // CHECK: [[@LINE]]:3 -> [[@LINE+4]]:2 = (#0 - #1)
 
 out:
-	return; // CHECK: Gap,File 0, [[@LINE]]:8 -> [[@LINE+1]]:2 = 0
+	return; // CHECK-NOT: Gap,File 0, [[@LINE]]:8
+}
+
+// CHECK-LABEL: _Z8switchesv:
+void switches() {
+  int x;
+  switch (x) {
+case 0:
+  return;
+default:
+  return; // CHECK-NOT: Gap,File 0, [[@LINE]]
+  }
 }
 
 #include "deferred-region-helper.h"
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp

[PATCH] D46929: Fix a mangling failure on clang-cl C++17

2018-05-17 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332639: Fix a mangling failure on clang-cl C++17 (authored 
by rnk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46929?vs=147244&id=147359#toc

Repository:
  rC Clang

https://reviews.llvm.org/D46929

Files:
  lib/AST/VTableBuilder.cpp
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp

Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -825,7 +825,6 @@
 llvm::Constant *ItaniumCXXABI::BuildMemberPointer(const CXXMethodDecl *MD,
   CharUnits ThisAdjustment) {
   assert(MD->isInstance() && "Member function must not be static!");
-  MD = MD->getCanonicalDecl();
 
   CodeGenTypes &Types = CGM.getTypes();
 
@@ -1640,7 +1639,6 @@
   Address This,
   llvm::Type *Ty,
   SourceLocation Loc) {
-  GD = GD.getCanonicalDecl();
   Ty = Ty->getPointerTo()->getPointerTo();
   auto *MethodDecl = cast(GD.getDecl());
   llvm::Value *VTable = CGF.GetVTablePtr(This, Ty, MethodDecl->getParent());
@@ -1674,7 +1672,7 @@
 VFunc = VFuncLoad;
   }
 
-  CGCallee Callee(MethodDecl, VFunc);
+  CGCallee Callee(MethodDecl->getCanonicalDecl(), VFunc);
   return Callee;
 }
 
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -228,7 +228,6 @@
 
   const CXXRecordDecl *
   getThisArgumentTypeForMethod(const CXXMethodDecl *MD) override {
-MD = MD->getCanonicalDecl();
 if (MD->isVirtual() && !isa(MD)) {
   MethodVFTableLocation ML =
   CGM.getMicrosoftVTableContext().getMethodVFTableLocation(MD);
@@ -1320,23 +1319,21 @@
 
 CharUnits
 MicrosoftCXXABI::getVirtualFunctionPrologueThisAdjustment(GlobalDecl GD) {
-  GD = GD.getCanonicalDecl();
   const CXXMethodDecl *MD = cast(GD.getDecl());
 
-  GlobalDecl LookupGD = GD;
   if (const CXXDestructorDecl *DD = dyn_cast(MD)) {
 // Complete destructors take a pointer to the complete object as a
 // parameter, thus don't need this adjustment.
 if (GD.getDtorType() == Dtor_Complete)
   return CharUnits();
 
 // There's no Dtor_Base in vftable but it shares the this adjustment with
 // the deleting one, so look it up instead.
-LookupGD = GlobalDecl(DD, Dtor_Deleting);
+GD = GlobalDecl(DD, Dtor_Deleting);
   }
 
   MethodVFTableLocation ML =
-  CGM.getMicrosoftVTableContext().getMethodVFTableLocation(LookupGD);
+  CGM.getMicrosoftVTableContext().getMethodVFTableLocation(GD);
   CharUnits Adjustment = ML.VFPtrOffset;
 
   // Normal virtual instance methods need to adjust from the vfptr that first
@@ -1370,7 +1367,6 @@
 return CGF.Builder.CreateConstByteGEP(This, Adjustment);
   }
 
-  GD = GD.getCanonicalDecl();
   const CXXMethodDecl *MD = cast(GD.getDecl());
 
   GlobalDecl LookupGD = GD;
@@ -1839,7 +1835,6 @@
 Address This,
 llvm::Type *Ty,
 SourceLocation Loc) {
-  GD = GD.getCanonicalDecl();
   CGBuilderTy &Builder = CGF.Builder;
 
   Ty = Ty->getPointerTo()->getPointerTo();
@@ -1878,7 +1873,7 @@
 VFunc = Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
   }
 
-  CGCallee Callee(MethodDecl, VFunc);
+  CGCallee Callee(MethodDecl->getCanonicalDecl(), VFunc);
   return Callee;
 }
 
@@ -2737,7 +2732,6 @@
 MicrosoftCXXABI::EmitMemberFunctionPointer(const CXXMethodDecl *MD) {
   assert(MD->isInstance() && "Member function must not be static!");
 
-  MD = MD->getCanonicalDecl();
   CharUnits NonVirtualBaseAdjustment = CharUnits::Zero();
   const CXXRecordDecl *RD = MD->getParent()->getMostRecentDecl();
   CodeGenTypes &Types = CGM.getTypes();
Index: lib/CodeGen/CGCXX.cpp
===
--- lib/CodeGen/CGCXX.cpp
+++ lib/CodeGen/CGCXX.cpp
@@ -267,7 +267,6 @@
   const CXXRecordDecl *RD) {
   assert(!CGF.CGM.getTarget().getCXXABI().isMicrosoft() &&
  "No kext in Microsoft ABI");
-  GD = GD.getCanonicalDecl();
   CodeGenModule &CGM = CGF.CGM;
   llvm::Value *VTable = CGM.getCXXABI().getAddrOfVTable(RD, CharUnits());
   Ty = Ty->getPointerTo()->getPointerTo();
@@ -283,7 +282,7 @@
 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt");
   llvm::Value *VFunc =
 CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.PointerAlignInBytes);
-  CGCallee Callee(GD.getDecl(), VFunc);
+  CGCallee Callee(GD.getDecl()->getCanonicalDecl(), VFunc);
   return Callee;
 }
 
Index: lib/AST/VTab

r332639 - Fix a mangling failure on clang-cl C++17

2018-05-17 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu May 17 11:12:18 2018
New Revision: 332639

URL: http://llvm.org/viewvc/llvm-project?rev=332639&view=rev
Log:
Fix a mangling failure on clang-cl C++17

MethodVFTableLocations in MigrosoftVTableContext contains canonicalized
decl. But, it's sometimes asked to lookup for non-canonicalized decl,
and that causes assertion failure, and compilation failure.

Fixes PR37481.

Patch by Taiju Tsuiki!

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

Modified:
cfe/trunk/lib/AST/VTableBuilder.cpp
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp

Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=332639&r1=332638&r2=332639&view=diff
==
--- cfe/trunk/lib/AST/VTableBuilder.cpp (original)
+++ cfe/trunk/lib/AST/VTableBuilder.cpp Thu May 17 11:12:18 2018
@@ -2223,6 +2223,7 @@ ItaniumVTableContext::ItaniumVTableConte
 ItaniumVTableContext::~ItaniumVTableContext() {}
 
 uint64_t ItaniumVTableContext::getMethodVTableIndex(GlobalDecl GD) {
+  GD = GD.getCanonicalDecl();
   MethodVTableIndicesTy::iterator I = MethodVTableIndices.find(GD);
   if (I != MethodVTableIndices.end())
 return I->second;
@@ -2503,6 +2504,8 @@ private:
 for (const auto &I : MethodInfoMap) {
   const CXXMethodDecl *MD = I.first;
   const MethodInfo &MI = I.second;
+  assert(MD == MD->getCanonicalDecl());
+
   // Skip the methods that the MostDerivedClass didn't override
   // and the entries shadowed by return adjusting thunks.
   if (MD->getParent() != MostDerivedClass || MI.Shadowed)
@@ -3737,6 +3740,8 @@ MicrosoftVTableContext::getMethodVFTable
   if (isa(GD.getDecl()))
 assert(GD.getDtorType() == Dtor_Deleting);
 
+  GD = GD.getCanonicalDecl();
+
   MethodVFTableLocationsTy::iterator I = MethodVFTableLocations.find(GD);
   if (I != MethodVFTableLocations.end())
 return I->second;

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=332639&r1=332638&r2=332639&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Thu May 17 11:12:18 2018
@@ -267,7 +267,6 @@ static CGCallee BuildAppleKextVirtualCal
   const CXXRecordDecl *RD) {
   assert(!CGF.CGM.getTarget().getCXXABI().isMicrosoft() &&
  "No kext in Microsoft ABI");
-  GD = GD.getCanonicalDecl();
   CodeGenModule &CGM = CGF.CGM;
   llvm::Value *VTable = CGM.getCXXABI().getAddrOfVTable(RD, CharUnits());
   Ty = Ty->getPointerTo()->getPointerTo();
@@ -283,7 +282,7 @@ static CGCallee BuildAppleKextVirtualCal
 CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt");
   llvm::Value *VFunc =
 CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.PointerAlignInBytes);
-  CGCallee Callee(GD.getDecl(), VFunc);
+  CGCallee Callee(GD.getDecl()->getCanonicalDecl(), VFunc);
   return Callee;
 }
 

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=332639&r1=332638&r2=332639&view=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu May 17 11:12:18 2018
@@ -825,7 +825,6 @@ ItaniumCXXABI::EmitMemberFunctionPointer
 llvm::Constant *ItaniumCXXABI::BuildMemberPointer(const CXXMethodDecl *MD,
   CharUnits ThisAdjustment) {
   assert(MD->isInstance() && "Member function must not be static!");
-  MD = MD->getCanonicalDecl();
 
   CodeGenTypes &Types = CGM.getTypes();
 
@@ -1640,7 +1639,6 @@ CGCallee ItaniumCXXABI::getVirtualFuncti
   Address This,
   llvm::Type *Ty,
   SourceLocation Loc) {
-  GD = GD.getCanonicalDecl();
   Ty = Ty->getPointerTo()->getPointerTo();
   auto *MethodDecl = cast(GD.getDecl());
   llvm::Value *VTable = CGF.GetVTablePtr(This, Ty, MethodDecl->getParent());
@@ -1674,7 +1672,7 @@ CGCallee ItaniumCXXABI::getVirtualFuncti
 VFunc = VFuncLoad;
   }
 
-  CGCallee Callee(MethodDecl, VFunc);
+  CGCallee Callee(MethodDecl->getCanonicalDecl(), VFunc);
   return Callee;
 }
 

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=332639&r1=332638&r2=332639&view=diff
==
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Thu May 17 11:12:18 2018
@@ -228,7 +228,

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

2018-05-17 Thread Walter Lee via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332635: [sanitizer] Don't add --export-dynamic for 
Myriad (authored by waltl, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46452?vs=147233&id=147355#toc

Repository:
  rC Clang

https://reviews.llvm.org/D46452

Files:
  lib/Driver/ToolChains/CommonArgs.cpp


Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -538,6 +538,11 @@
   // the option, so don't try to pass it.
   if (TC.getTriple().getOS() == llvm::Triple::Solaris)
 return true;
+  // Myriad is static linking only.  Furthermore, some versions of its
+  // linker have the bug where --export-dynamic overrides -static, so
+  // don't use --export-dynamic on that platform.
+  if (TC.getTriple().getVendor() == llvm::Triple::Myriad)
+return true;
   SmallString<128> SanRT(TC.getCompilerRT(Args, Sanitizer));
   if (llvm::sys::fs::exists(SanRT + ".syms")) {
 CmdArgs.push_back(Args.MakeArgString("--dynamic-list=" + SanRT + ".syms"));


Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -538,6 +538,11 @@
   // the option, so don't try to pass it.
   if (TC.getTriple().getOS() == llvm::Triple::Solaris)
 return true;
+  // Myriad is static linking only.  Furthermore, some versions of its
+  // linker have the bug where --export-dynamic overrides -static, so
+  // don't use --export-dynamic on that platform.
+  if (TC.getTriple().getVendor() == llvm::Triple::Myriad)
+return true;
   SmallString<128> SanRT(TC.getCompilerRT(Args, Sanitizer));
   if (llvm::sys::fs::exists(SanRT + ".syms")) {
 CmdArgs.push_back(Args.MakeArgString("--dynamic-list=" + SanRT + ".syms"));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r332635 - [sanitizer] Don't add --export-dynamic for Myriad

2018-05-17 Thread Walter Lee via cfe-commits
Author: waltl
Date: Thu May 17 11:04:39 2018
New Revision: 332635

URL: http://llvm.org/viewvc/llvm-project?rev=332635&view=rev
Log:
[sanitizer] Don't add --export-dynamic for Myriad

This is to work around a bug in some versions of gnu ld, where
--export-dynamic implies -shared even if -static is explicitly given.
Myriad supports static linking only, so --export-dynamic is never
needed.

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

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

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=332635&r1=332634&r2=332635&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Thu May 17 11:04:39 2018
@@ -538,6 +538,11 @@ static bool addSanitizerDynamicList(cons
   // the option, so don't try to pass it.
   if (TC.getTriple().getOS() == llvm::Triple::Solaris)
 return true;
+  // Myriad is static linking only.  Furthermore, some versions of its
+  // linker have the bug where --export-dynamic overrides -static, so
+  // don't use --export-dynamic on that platform.
+  if (TC.getTriple().getVendor() == llvm::Triple::Myriad)
+return true;
   SmallString<128> SanRT(TC.getCompilerRT(Args, Sanitizer));
   if (llvm::sys::fs::exists(SanRT + ".syms")) {
 CmdArgs.push_back(Args.MakeArgString("--dynamic-list=" + SanRT + ".syms"));


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


[PATCH] D46929: Fix a mangling failure on clang-cl C++17

2018-05-17 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Please do, tzik doesn't have commit access yet.


Repository:
  rC Clang

https://reviews.llvm.org/D46929



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


[PATCH] D46929: Fix a mangling failure on clang-cl C++17

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

lgtm

Shall I go ahead and commit this for you?




Comment at: lib/AST/VTableBuilder.cpp:2507
   const MethodInfo &MI = I.second;
+  assert(MD == MD->getCanonicalDecl());
+

Thanks for that!


Repository:
  rC Clang

https://reviews.llvm.org/D46929



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


[PATCH] D46995: [test-suite] Enable CUDA complex tests with libc++ now that D25403 is resolved.

2018-05-17 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: External/CUDA/complex.cu:24
 // libstdc++ (compile errors in ).
-#if __cplusplus >= 201103L && !defined(_LIBCPP_VERSION) && \
-(__cplusplus < 201402L || STDLIB_VERSION >= 2014)
+#if __cplusplus >= 201103L && (__cplusplus < 201402L || STDLIB_VERSION >= 2014)
 

Is this specific to c++14 only, or will we have similar conditions for 
c++17,20, etc?
Perhaps we could express library version requirements as `STDLIB_VERSION >= 
(__cplusplus / 100)` ?
I'm OK with either way.




Repository:
  rT test-suite

https://reviews.llvm.org/D46995



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


[PATCH] D46994: [test-suite] Test CUDA in C++14 mode with C++11 stdlibs.

2018-05-17 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: External/CUDA/CMakeLists.txt:339-345
# Same as above, but for libc++
# Tell clang to use libc++
# We also need to add compiler's include path for cxxabi.h
get_filename_component(_compiler_path ${CMAKE_CXX_COMPILER} DIRECTORY)
-   set(_Stdlib_CPPFLAGS -stdlib=libc++ 
-I${_compiler_path}/../include/c++-build)
+set(_Stdlib_CPPFLAGS -stdlib=libc++ 
-I${_compiler_path}/../include/c++-build -DSTDLIB_VERSION=2017)
set(_Stdlib_LDFLAGS  -stdlib=libc++)
set(_Stdlib_Libs libcxx)

Looks like the file should be un-tabified.


Repository:
  rT test-suite

https://reviews.llvm.org/D46994



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


[PATCH] D46550: Support Swift calling convention for PPC64 targets

2018-05-17 Thread Arnold Schwaighofer via Phabricator via cfe-commits
aschwaighofer accepted this revision.
aschwaighofer added a comment.
This revision is now accepted and ready to land.

Looks good.


Repository:
  rC Clang

https://reviews.llvm.org/D46550



___
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-17 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: test/Preprocessor/headermap-rel.c:2-3
 
 // This uses a headermap with this entry:
 //   Foo.h -> Foo/Foo.h
 

Should we delete this comment now that the header map is human-readable?



Comment at: test/Preprocessor/headermap-rel.c:6
+// RUN: rm -f %t.hmap
+// RUN: hmaptool write %S/Inputs/headermap-rel/foo.hmap.json %t.hmap
+// RUN: %clang_cc1 -E %s -o %t.i -I %t.hmap -F %S/Inputs/headermap-rel

Should there be some sort of `REQUIRES:` clause for using `hmaptool`?


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] D46881: [X86][CET] Changing -fcf-protection behavior to comply with gcc (clang part)

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

LGTM


https://reviews.llvm.org/D46881



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


r332621 - [CUDA] Allow "extern __shared__ Foo foo[]" within anon. namespaces.

2018-05-17 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu May 17 09:15:07 2018
New Revision: 332621

URL: http://llvm.org/viewvc/llvm-project?rev=332621&view=rev
Log:
[CUDA] Allow "extern __shared__ Foo foo[]" within anon. namespaces.

Summary:
Previously this triggered a -Wundefined-internal warning.  But it's not
an undefined variable -- any variable of this form is a pointer to the
base of GPU core's shared memory.

Reviewers: tra

Subscribers: sanjoy, rsmith

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

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/test/SemaCUDA/extern-shared.cu

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=332621&r1=332620&r2=332621&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu May 17 09:15:07 2018
@@ -1456,6 +1456,11 @@ public:
 
   void setDescribedVarTemplate(VarTemplateDecl *Template);
 
+  // Is this variable known to have a definition somewhere in the complete
+  // program? This may be true even if the declaration has internal linkage and
+  // has no definition within this source file.
+  bool isKnownToBeDefined() const;
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K >= firstVar && K <= lastVar; }

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=332621&r1=332620&r2=332621&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu May 17 09:15:07 2018
@@ -2432,6 +2432,23 @@ void VarDecl::setDescribedVarTemplate(Va
   getASTContext().setTemplateOrSpecializationInfo(this, Template);
 }
 
+bool VarDecl::isKnownToBeDefined() const {
+  const auto &LangOpts = getASTContext().getLangOpts();
+  // In CUDA mode without relocatable device code, variables of form 'extern
+  // __shared__ Foo foo[]' are pointers to the base of the GPU core's shared
+  // memory pool.  These are never undefined variables, even if they appear
+  // inside of an anon namespace or static function.
+  //
+  // With CUDA relocatable device code enabled, these variables don't get
+  // special handling; they're treated like regular extern variables.
+  if (LangOpts.CUDA && !LangOpts.CUDARelocatableDeviceCode &&
+  hasExternalStorage() && hasAttr() &&
+  isa(getType()))
+return true;
+
+  return hasDefinition();
+}
+
 MemberSpecializationInfo *VarDecl::getMemberSpecializationInfo() const {
   if (isStaticDataMember())
 // FIXME: Remove ?

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=332621&r1=332620&r2=332621&view=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Thu May 17 09:15:07 2018
@@ -653,6 +653,11 @@ void Sema::getUndefinedButUsed(
   !isExternalWithNoLinkageType(VD) &&
   !VD->getMostRecentDecl()->isInline())
 continue;
+
+  // Skip VarDecls that lack formal definitions but which we know are in
+  // fact defined somewhere.
+  if (VD->isKnownToBeDefined())
+continue;
 }
 
 Undefined.push_back(std::make_pair(ND, UndefinedUse.second));

Modified: cfe/trunk/test/SemaCUDA/extern-shared.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/extern-shared.cu?rev=332621&r1=332620&r2=332621&view=diff
==
--- cfe/trunk/test/SemaCUDA/extern-shared.cu (original)
+++ cfe/trunk/test/SemaCUDA/extern-shared.cu Thu May 17 09:15:07 2018
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -fcuda-is-device -verify 
%s
 
-// RUN: %clang_cc1 -fsyntax-only -fcuda-rdc -verify=rdc %s
-// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -fcuda-rdc -verify=rdc %s
-// These declarations are fine in separate compilation mode:
-// rdc-no-diagnostics
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -fcuda-rdc -verify=rdc %s
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -fcuda-is-device 
-fcuda-rdc -verify=rdc %s
+
+// Most of these declarations are fine in separate compilation mode.
 
 #include "Inputs/cuda.h"
 
@@ -26,3 +26,18 @@ __host__ __device__ void bar() {
 extern __shared__ int global; // expected-error {{__shared__ variable 'global' 
cannot be 'extern'}}
 extern __shared__ int global_arr[]; // ok
 extern __shared__ int global_arr1[1]; // expected-

[PATCH] D46782: [CUDA] Allow "extern __shared__ Foo foo[]" within anon. namespaces.

2018-05-17 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332621: [CUDA] Allow "extern __shared__ Foo foo[]" 
within anon. namespaces. (authored by jlebar, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46782?vs=147216&id=147331#toc

Repository:
  rC Clang

https://reviews.llvm.org/D46782

Files:
  include/clang/AST/Decl.h
  lib/AST/Decl.cpp
  lib/Sema/Sema.cpp
  test/SemaCUDA/extern-shared.cu


Index: include/clang/AST/Decl.h
===
--- include/clang/AST/Decl.h
+++ include/clang/AST/Decl.h
@@ -1456,6 +1456,11 @@
 
   void setDescribedVarTemplate(VarTemplateDecl *Template);
 
+  // Is this variable known to have a definition somewhere in the complete
+  // program? This may be true even if the declaration has internal linkage and
+  // has no definition within this source file.
+  bool isKnownToBeDefined() const;
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K >= firstVar && K <= lastVar; }
Index: test/SemaCUDA/extern-shared.cu
===
--- test/SemaCUDA/extern-shared.cu
+++ test/SemaCUDA/extern-shared.cu
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -fcuda-is-device -verify 
%s
 
-// RUN: %clang_cc1 -fsyntax-only -fcuda-rdc -verify=rdc %s
-// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -fcuda-rdc -verify=rdc %s
-// These declarations are fine in separate compilation mode:
-// rdc-no-diagnostics
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -fcuda-rdc -verify=rdc %s
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -fcuda-is-device 
-fcuda-rdc -verify=rdc %s
+
+// Most of these declarations are fine in separate compilation mode.
 
 #include "Inputs/cuda.h"
 
@@ -26,3 +26,18 @@
 extern __shared__ int global; // expected-error {{__shared__ variable 'global' 
cannot be 'extern'}}
 extern __shared__ int global_arr[]; // ok
 extern __shared__ int global_arr1[1]; // expected-error {{__shared__ variable 
'global_arr1' cannot be 'extern'}}
+
+// Check that, iff we're not in rdc mode, extern __shared__ can appear in an
+// anonymous namespace / in a static function without generating a warning
+// about a variable with internal linkage but no definition
+// (-Wundefined-internal).
+namespace {
+extern __shared__ int global_arr[]; // rdc-warning {{has internal linkage but 
is not defined}}
+__global__ void in_anon_ns() {
+  extern __shared__ int local_arr[]; // rdc-warning {{has internal linkage but 
is not defined}}
+
+  // Touch arrays to generate the warning.
+  local_arr[0] = 0;  // rdc-note {{used here}}
+  global_arr[0] = 0; // rdc-note {{used here}}
+}
+} // namespace
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -2432,6 +2432,23 @@
   getASTContext().setTemplateOrSpecializationInfo(this, Template);
 }
 
+bool VarDecl::isKnownToBeDefined() const {
+  const auto &LangOpts = getASTContext().getLangOpts();
+  // In CUDA mode without relocatable device code, variables of form 'extern
+  // __shared__ Foo foo[]' are pointers to the base of the GPU core's shared
+  // memory pool.  These are never undefined variables, even if they appear
+  // inside of an anon namespace or static function.
+  //
+  // With CUDA relocatable device code enabled, these variables don't get
+  // special handling; they're treated like regular extern variables.
+  if (LangOpts.CUDA && !LangOpts.CUDARelocatableDeviceCode &&
+  hasExternalStorage() && hasAttr() &&
+  isa(getType()))
+return true;
+
+  return hasDefinition();
+}
+
 MemberSpecializationInfo *VarDecl::getMemberSpecializationInfo() const {
   if (isStaticDataMember())
 // FIXME: Remove ?
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -653,6 +653,11 @@
   !isExternalWithNoLinkageType(VD) &&
   !VD->getMostRecentDecl()->isInline())
 continue;
+
+  // Skip VarDecls that lack formal definitions but which we know are in
+  // fact defined somewhere.
+  if (VD->isKnownToBeDefined())
+continue;
 }
 
 Undefined.push_back(std::make_pair(ND, UndefinedUse.second));


Index: include/clang/AST/Decl.h
===
--- include/clang/AST/Decl.h
+++ include/clang/AST/Decl.h
@@ -1456,6 +1456,11 @@
 
   void setDescribedVarTemplate(VarTemplateDecl *Template);
 
+  // Is this variable known to have a definition somewhere in the complete
+  // program? This

[clang-tools-extra] r332620 - Disable a failing clang-move test on windows.

2018-05-17 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu May 17 09:13:36 2018
New Revision: 332620

URL: http://llvm.org/viewvc/llvm-project?rev=332620&view=rev
Log:
Disable a failing clang-move test on windows.

This was broken by r332590 but is likely caused by a bug in clang-move.

http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12007

I don't have a windows machine to effectively debug the issue, so I'll 
investigate
further but for now disable the failing test on windows to unbreak build bots.

Modified:
clang-tools-extra/trunk/test/clang-move/move-class.cpp

Modified: clang-tools-extra/trunk/test/clang-move/move-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-class.cpp?rev=332620&r1=332619&r2=332620&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/move-class.cpp (original)
+++ clang-tools-extra/trunk/test/clang-move/move-class.cpp Thu May 17 09:13:36 
2018
@@ -1,3 +1,7 @@
+// UNSUPPORTED: system-windows
+// new_test.cpp contains #include of old test.h when running on windows. This 
is
+// probably by a bug for path handling in clang-move.
+//
 // RUN: mkdir -p %T/clang-move/build
 // RUN: mkdir -p %T/clang-move/include
 // RUN: mkdir -p %T/clang-move/src


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


[PATCH] D46993: [CUDA] Make std::min/max work when compiling in C++14 mode with a C++11 stdlib.

2018-05-17 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332619: [CUDA] Make std::min/max work when compiling in 
C++14 mode with a C++11 stdlib. (authored by jlebar, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46993?vs=147224&id=147330#toc

Repository:
  rC Clang

https://reviews.llvm.org/D46993

Files:
  lib/Headers/cuda_wrappers/algorithm


Index: lib/Headers/cuda_wrappers/algorithm
===
--- lib/Headers/cuda_wrappers/algorithm
+++ lib/Headers/cuda_wrappers/algorithm
@@ -24,28 +24,36 @@
 #ifndef __CLANG_CUDA_WRAPPERS_ALGORITHM
 #define __CLANG_CUDA_WRAPPERS_ALGORITHM
 
-// This header defines __device__ overloads of std::min/max, but only if we're
-// <= C++11.  In C++14, these functions are constexpr, and so are implicitly
-// __host__ __device__.
+// This header defines __device__ overloads of std::min/max.
 //
-// We don't support the initializer_list overloads because
-// initializer_list::begin() and end() are not __host__ __device__ functions.
+// Ideally we'd declare these functions only if we're <= C++11.  In C++14,
+// these functions are constexpr, and so are implicitly __host__ __device__.
 //
-// When compiling in C++14 mode, we could force std::min/max to have different
-// implementations for host and device, by declaring the device overloads
-// before the constexpr overloads appear.  We choose not to do this because
-
-//  a) why write our own implementation when we can use one from the standard
-// library? and
-//  b) libstdc++ is evil and declares min/max inside a header that is included
-// *before* we include .  So we'd have to unconditionally
-// declare our __device__ overloads of min/max, but that would pollute
-// things for people who choose not to include .
+// However, the compiler being in C++14 mode does not imply that the standard
+// library supports C++14.  There is no macro we can test to check that the
+// stdlib has constexpr std::min/max.  Thus we have to unconditionally define
+// our device overloads.
+//
+// A host+device function cannot be overloaded, and a constexpr function
+// implicitly become host device if there's no explicitly host or device
+// overload preceding it.  So the simple thing to do would be to declare our
+// device min/max overloads, and then #include_next .  This way our
+// device overloads would come first, and so if we have a C++14 stdlib, its
+// min/max won't become host+device and conflict with our device overloads.
+//
+// But that also doesn't work.  libstdc++ is evil and declares std::min/max in
+// an internal header that is included *before* .  Thus by the time
+// we're inside of this file, std::min/max may already have been declared, and
+// thus we can't prevent them from becoming host+device if they're constexpr.
+//
+// Therefore we perpetrate the following hack: We mark our __device__ overloads
+// with __attribute__((enable_if(true, ""))).  This causes the signature of the
+// function to change without changing anything else about it.  (Except that
+// overload resolution will prefer it over the __host__ __device__ version
+// rather than considering them equally good).
 
 #include_next 
 
-#if __cplusplus <= 201103L
-
 // We need to define these overloads in exactly the namespace our standard
 // library uses (including the right inline namespace), otherwise they won't be
 // picked up by other functions in the standard library (e.g. functions in
@@ -60,24 +68,28 @@
 #endif
 
 template 
+__attribute__((enable_if(true, "")))
 inline __device__ const __T &
 max(const __T &__a, const __T &__b, __Cmp __cmp) {
   return __cmp(__a, __b) ? __b : __a;
 }
 
 template 
+__attribute__((enable_if(true, "")))
 inline __device__ const __T &
 max(const __T &__a, const __T &__b) {
   return __a < __b ? __b : __a;
 }
 
 template 
+__attribute__((enable_if(true, "")))
 inline __device__ const __T &
 min(const __T &__a, const __T &__b, __Cmp __cmp) {
   return __cmp(__b, __a) ? __b : __a;
 }
 
 template 
+__attribute__((enable_if(true, "")))
 inline __device__ const __T &
 min(const __T &__a, const __T &__b) {
   return __a < __b ? __a : __b;
@@ -92,5 +104,4 @@
 } // namespace std
 #endif
 
-#endif // __cplusplus <= 201103L
 #endif // __CLANG_CUDA_WRAPPERS_ALGORITHM


Index: lib/Headers/cuda_wrappers/algorithm
===
--- lib/Headers/cuda_wrappers/algorithm
+++ lib/Headers/cuda_wrappers/algorithm
@@ -24,28 +24,36 @@
 #ifndef __CLANG_CUDA_WRAPPERS_ALGORITHM
 #define __CLANG_CUDA_WRAPPERS_ALGORITHM
 
-// This header defines __device__ overloads of std::min/max, but only if we're
-// <= C++11.  In C++14, these functions are constexpr, and so are implicitly
-// __host__ __device__.
+// This header defines __device__ overloads of std::min/max.
 //
-// We don't support the initializer_list overloads because
-// initializer_list::begin() and end() are

r332619 - [CUDA] Make std::min/max work when compiling in C++14 mode with a C++11 stdlib.

2018-05-17 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu May 17 09:12:42 2018
New Revision: 332619

URL: http://llvm.org/viewvc/llvm-project?rev=332619&view=rev
Log:
[CUDA] Make std::min/max work when compiling in C++14 mode with a C++11 stdlib.

Reviewers: rsmith

Subscribers: sanjoy, cfe-commits, tra

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

Modified:
cfe/trunk/lib/Headers/cuda_wrappers/algorithm

Modified: cfe/trunk/lib/Headers/cuda_wrappers/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/cuda_wrappers/algorithm?rev=332619&r1=332618&r2=332619&view=diff
==
--- cfe/trunk/lib/Headers/cuda_wrappers/algorithm (original)
+++ cfe/trunk/lib/Headers/cuda_wrappers/algorithm Thu May 17 09:12:42 2018
@@ -24,28 +24,36 @@
 #ifndef __CLANG_CUDA_WRAPPERS_ALGORITHM
 #define __CLANG_CUDA_WRAPPERS_ALGORITHM
 
-// This header defines __device__ overloads of std::min/max, but only if we're
-// <= C++11.  In C++14, these functions are constexpr, and so are implicitly
-// __host__ __device__.
+// This header defines __device__ overloads of std::min/max.
 //
-// We don't support the initializer_list overloads because
-// initializer_list::begin() and end() are not __host__ __device__ functions.
+// Ideally we'd declare these functions only if we're <= C++11.  In C++14,
+// these functions are constexpr, and so are implicitly __host__ __device__.
 //
-// When compiling in C++14 mode, we could force std::min/max to have different
-// implementations for host and device, by declaring the device overloads
-// before the constexpr overloads appear.  We choose not to do this because
-
-//  a) why write our own implementation when we can use one from the standard
-// library? and
-//  b) libstdc++ is evil and declares min/max inside a header that is included
-// *before* we include .  So we'd have to unconditionally
-// declare our __device__ overloads of min/max, but that would pollute
-// things for people who choose not to include .
+// However, the compiler being in C++14 mode does not imply that the standard
+// library supports C++14.  There is no macro we can test to check that the
+// stdlib has constexpr std::min/max.  Thus we have to unconditionally define
+// our device overloads.
+//
+// A host+device function cannot be overloaded, and a constexpr function
+// implicitly become host device if there's no explicitly host or device
+// overload preceding it.  So the simple thing to do would be to declare our
+// device min/max overloads, and then #include_next .  This way our
+// device overloads would come first, and so if we have a C++14 stdlib, its
+// min/max won't become host+device and conflict with our device overloads.
+//
+// But that also doesn't work.  libstdc++ is evil and declares std::min/max in
+// an internal header that is included *before* .  Thus by the time
+// we're inside of this file, std::min/max may already have been declared, and
+// thus we can't prevent them from becoming host+device if they're constexpr.
+//
+// Therefore we perpetrate the following hack: We mark our __device__ overloads
+// with __attribute__((enable_if(true, ""))).  This causes the signature of the
+// function to change without changing anything else about it.  (Except that
+// overload resolution will prefer it over the __host__ __device__ version
+// rather than considering them equally good).
 
 #include_next 
 
-#if __cplusplus <= 201103L
-
 // We need to define these overloads in exactly the namespace our standard
 // library uses (including the right inline namespace), otherwise they won't be
 // picked up by other functions in the standard library (e.g. functions in
@@ -60,24 +68,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
 template 
+__attribute__((enable_if(true, "")))
 inline __device__ const __T &
 max(const __T &__a, const __T &__b, __Cmp __cmp) {
   return __cmp(__a, __b) ? __b : __a;
 }
 
 template 
+__attribute__((enable_if(true, "")))
 inline __device__ const __T &
 max(const __T &__a, const __T &__b) {
   return __a < __b ? __b : __a;
 }
 
 template 
+__attribute__((enable_if(true, "")))
 inline __device__ const __T &
 min(const __T &__a, const __T &__b, __Cmp __cmp) {
   return __cmp(__b, __a) ? __b : __a;
 }
 
 template 
+__attribute__((enable_if(true, "")))
 inline __device__ const __T &
 min(const __T &__a, const __T &__b) {
   return __a < __b ? __a : __b;
@@ -92,5 +104,4 @@ _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 #endif
 
-#endif // __cplusplus <= 201103L
 #endif // __CLANG_CUDA_WRAPPERS_ALGORITHM


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


[PATCH] D46993: [CUDA] Make std::min/max work when compiling in C++14 mode with a C++11 stdlib.

2018-05-17 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

Thank you for the review!


https://reviews.llvm.org/D46993



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


[PATCH] D45177: CStringChecker, check strlcpy/strlcat

2018-05-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

See https://bugs.llvm.org/show_bug.cgi?id=37503 for a test case.


Repository:
  rC Clang

https://reviews.llvm.org/D45177



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


[PATCH] D46820: Fix __uuidof handling on non-type template parameter in C++17

2018-05-17 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r332614, thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D46820



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


r332614 - Fix __uuidof handling on non-type template parameter in C++17

2018-05-17 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu May 17 08:26:37 2018
New Revision: 332614

URL: http://llvm.org/viewvc/llvm-project?rev=332614&view=rev
Log:
Fix __uuidof handling on non-type template parameter in C++17

Clang used to pass the base lvalue of a non-type template parameter
to the template instantiation phase when the base part is __uuidof
and it's running in C++17 mode.
However, that drops its LValuePath, and unintentionally transforms
&__uuidof(...) to __uuidof(...).

This CL fixes that by passing whole expr. Fixes PR24986.

https://reviews.llvm.org/D46820?id=146557
Patch from Taiju Tsuiki !

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/ms-uuid.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=332614&r1=332613&r2=332614&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu May 17 08:26:37 2018
@@ -6245,7 +6245,7 @@ ExprResult Sema::CheckTemplateArgument(N
   // -- a predefined __func__ variable
   if (auto *E = Value.getLValueBase().dyn_cast()) {
 if (isa(E)) {
-  Converted = TemplateArgument(const_cast(E));
+  Converted = TemplateArgument(ArgResult.get());
   break;
 }
 Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)

Modified: cfe/trunk/test/SemaCXX/ms-uuid.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-uuid.cpp?rev=332614&r1=332613&r2=332614&view=diff
==
--- cfe/trunk/test/SemaCXX/ms-uuid.cpp (original)
+++ cfe/trunk/test/SemaCXX/ms-uuid.cpp Thu May 17 08:26:37 2018
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s 
-Wno-deprecated-declarations
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify -fms-extensions %s 
-Wno-deprecated-declarations
 
 typedef struct _GUID {
   unsigned long Data1;
@@ -92,4 +93,16 @@ class __declspec(uuid("00A0--000
 // the previous case).
 [uuid("00A0---C000-0049"),
  uuid("00A0---C000-0049")] class C10;
+
+template 
+void F1() {
+  // Regression test for PR24986. The given GUID should just work as a pointer.
+  const GUID* q = p;
+}
+
+void F2() {
+  // The UUID should work for a non-type template parameter.
+  F1<&__uuidof(C1)>();
+}
+
 }


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


[PATCH] D44954: [clangd] Add "member" symbols to the index

2018-05-17 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/index/SymbolCollector.cpp:113
 
-  // We only want:
-  //   * symbols in namespaces or translation unit scopes (e.g. no class
-  // members)
-  //   * enum constants in unscoped enum decl (e.g. "red" in "enum {red};")
-  auto InTopLevelScope = hasDeclContext(
-  anyOf(namespaceDecl(), translationUnitDecl(), linkageSpecDecl()));
-  // Don't index template specializations.
+  // Don't index template specializations and expansions in main files.
   auto IsSpecialization =

We should be careful when removing the `InTopLevelScope` filter. According to 
clang/AST/DeclBase.h, `DeclContext` can be any of the following. For example, 
indexing symbols in functions seems to be out of the scope of this patch. I 
think we should keep a whitelist instead of turning them all at once. It's 
unfortunately we don't have tests to catch those...
```
///   TranslationUnitDecl
///   NamespaceDecl
///   FunctionDecl
///   TagDecl
///   ObjCMethodDecl
///   ObjCContainerDecl
///   LinkageSpecDecl
///   ExportDecl
///   BlockDecl
///   OMPDeclareReductionDecl
```

For class members, I would be good to add more tests for symbol collector e.g. 
more realistic class layouts with constructor, friends etc.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44954



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


[PATCH] D47017: [Fixed Point Arithmetic] Validation Test for Saturated Shift Left, Saturated Unsigned _Fract Types, and Fix for Saturated Unsigned Addition

2018-05-17 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 includes changes for the shift left operator involving saturated 
fixed point types.

For unsigned shifting, overflow occurs if the number of bits we shift exceeds 
the number of leading zeros in the number. This number is found using the 
intrinsic llvm function `ctlz`.

For signed shifting, if the number is positive, we cap at the max value for 
that type if the number of bits we shift exceeds the number of leading zeros. 
If the number is negative, we cap at the min value for that type if the number 
of bits we shift exceeds the number of leading ones. `ctlz` can be used in this 
case after flipping the bits in the number.

- Saturation tests were also added for saturated unsigned _Fract types.
- Added a fix to unsigned addition for saturated fixed point types where we 
would not be able to get the overflow if the number of data bits was equal to 
the underlying integer width. In this case, we need to use the intrinsic 
function `uadd.with.overflow` to detect overflow on this carry bit.

This is a child of https://reviews.llvm.org/D47016


Repository:
  rC Clang

https://reviews.llvm.org/D47017

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

Index: test/Frontend/fixed_point_all_builtin_operations.c
===
--- test/Frontend/fixed_point_all_builtin_operations.c
+++ test/Frontend/fixed_point_all_builtin_operations.c
@@ -105,6 +105,20 @@
 a = -0.8 ## SUFFIX; \
 b = 0.5 ## SUFFIX; \
 ASSERT(a / b == -0.5 ## SUFFIX - 0.5 ## SUFFIX); \
+a = 0.1 ## SUFFIX; \
+ASSERT(a << 4 == 1.0 ## SUFFIX); \
+a = -0.8 ## SUFFIX; \
+ASSERT(a << 4 == -0.5 ## SUFFIX - 0.5 ## SUFFIX); \
+  }
+
+#define FRACT_SATU_BINARY_OPS(TYPE, ID, SUFFIX) \
+  { \
+TYPE a = 0.7 ## SUFFIX; \
+TYPE b = 0.9 ## SUFFIX; \
+ASSERT(a + b == 1.0 ## SUFFIX); \
+ASSERT(a - b == 0.0 ## SUFFIX); \
+ASSERT(b / a == 1.0 ## SUFFIX); \
+ASSERT(a << 1 == 1.0 ## SUFFIX); \
   }
 
 int main(){
@@ -119,5 +133,9 @@
   FRACT_SAT_BINARY_OPS(_Sat _Fract, SatFract, r);
   FRACT_SAT_BINARY_OPS(_Sat long _Fract, SatLongFract, lr);
 
+  FRACT_SATU_BINARY_OPS(_Sat unsigned short _Fract, SatUnsignedShortFract, uhr);
+  FRACT_SATU_BINARY_OPS(_Sat unsigned _Fract, SatUnsignedFract, ur);
+  FRACT_SATU_BINARY_OPS(_Sat unsigned long _Fract, SatUnsignedLongFract, ulr);
+
   return 0;
 }
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -1144,7 +1144,9 @@
   }
 
   // Ignore conversions like int -> uint.
-  if (SrcTy == DstTy)
+  // Except for fixed point types which may need radix transformations.
+  bool WorkingOnFixedPoints = DstType->isFixedPointType() && SrcType->isFixedPointType();
+  if (SrcTy == DstTy && !WorkingOnFixedPoints)
 return Src;
 
   // Handle pointer conversions next: pointers can only be converted to/from
@@ -1248,7 +1250,6 @@
 DstTy = CGF.FloatTy;
   }
 
-  bool WorkingOnFixedPoints = DstType->isFixedPointType() && SrcType->isFixedPointType();
   int order = WorkingOnFixedPoints ? CGF.getContext().getFixedPointTypeOrder(DstType, SrcType) : 0;
 
   if (WorkingOnFixedPoints && order < 0) {
@@ -2876,7 +2877,7 @@
 
   // Number of data + sign bits used in division
   unsigned DividendBits = FixedPointBits + fbits;
-  unsigned BitMask = (1 << DividendBits) - 1;
+  uint64_t BitMask = (static_cast<__int128_t>(1ULL) << DividendBits) - 1;
   llvm::Value *MaskedDivResult = Builder.CreateAnd(DivResult, BitMask);
 
   if (Ops.Ty->isSignedFixedPointType()) {
@@ -3310,19 +3311,19 @@
 llvm::Value *SatMinVal = llvm::ConstantInt::get(
 opTy, getFixedPointMinVal(op.Ty));
 
-unsigned MSBBitShift;
 if (op.Ty->isSignedFixedPointType()) {
-  MSBBitShift = getFixedPointIBits(op.Ty) + getFixedPointFBits(op.Ty);
-} else {
-  MSBBitShift = getFixedPointIBits(op.Ty) + getFixedPointFBits(op.Ty) - 1;
-}
+  unsigned MSBBitShift;
+  if (op.Ty->isSignedFixedPointType()) {
+MSBBitShift = getFixedPointIBits(op.Ty) + getFixedPointFBits(op.Ty);
+  } else {
+MSBBitShift = getFixedPointIBits(op.Ty) + getFixedPointFBits(op.Ty) - 1;
+  }
 
-llvm::Value *Sum = Builder.CreateAdd(op.LHS, op.RHS);
-llvm::Value *LHSMSB = Builder.CreateLShr(op.LHS, MSBBitShift);
-llvm::Value *RHSMSB = Builder.CreateLShr(op.RHS, MSBBitShift);
-llvm::Value *ResultMSB = Builder.CreateLShr(Sum, MSBBitShift);
+  llvm::Value *Sum = Builder.CreateAdd(op.LHS, op.RHS);
+  llvm::Value *LHSMSB = Builder.CreateLShr(op.LHS, MSBBitShift);
+  llvm::Value *RHSMSB = Builder.CreateLShr(op.RHS, MSBBitShift);
+  llvm::Value *ResultMSB = Builder.CreateLShr(Sum, MSBBit

[clang-tools-extra] r332612 - Second attempt to fix clang-move tests broken by r332590 on windows

2018-05-17 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu May 17 07:59:15 2018
New Revision: 332612

URL: http://llvm.org/viewvc/llvm-project?rev=332612&view=rev
Log:
Second attempt to fix clang-move tests broken by r332590 on windows

http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12010

Add back a path conversion removed in a previous attempt. I removed it
because it didn't seem necessary. Added it back to see if this would fix
the bot.

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.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=332612&r1=332611&r2=332612&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Thu May 17 07:59:15 2018
@@ -64,6 +64,8 @@ AST_MATCHER_P(CXXMethodDecl, ofOutermost
 std::string CleanPath(StringRef PathRef) {
   llvm::SmallString<128> Path(PathRef);
   llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
+  // FIXME: figure out why this is necessary.
+  llvm::sys::path::native(Path);
   return Path.str();
 }
 


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


[PATCH] D47016: [Fixed Point Arithmetic] Validation Test for Saturated Division and Comparison Fix

2018-05-17 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 includes changes for division on saturated fixed point types. 
Overflow occurs when the resulting value cannot fit into the number of data 
bits for the resulting type.

For signed division, we cap at the max value of the type when the dividend sign 
is positive, divisor sign is negative, but the quotient is still positive. 
Reciprocally, we cap at the min value if the dividend is negative, divisor is 
positive, and quotient is negative.

For unsigned division, overflow occurs if the resulting value exceeds the max 
possible value that this type can hold.

The logic for comparisons between fixed point types was also fixed to account 
for padding bits. Since the padding bits contains values we do not care about, 
we mask the fixed point data bits in the underlying integral that we do care 
about and compare them.

This is a child of https://reviews.llvm.org/D46990


Repository:
  rC Clang

https://reviews.llvm.org/D47016

Files:
  include/clang/AST/Type.h
  include/clang/Basic/FixedPoint.h.in
  lib/AST/Type.cpp
  lib/CodeGen/CGExprScalar.cpp
  test/Frontend/fixed_point_all_builtin_operations.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
@@ -57,7 +57,7 @@
 
   s_accum = s_accum2;
   // CHECK:  {{.*}} = load i16, i16* %s_accum2, align 2
-  // CHECK-NEXT: store i16 %1, i16* %s_accum, align 2
+  // CHECK-NEXT: store i16 {{.*}}, i16* %s_accum, align 2
 
   assert(s_accum == s_accum2);
   // CHECK:  {{.*}} = load i16, i16* %s_accum, align 2
@@ -114,9 +114,13 @@
   // CHECK:  {{.*}} = icmp sgt i16 {{.*}}, {{.*}}
 
   assert(s_fract2 < s_fract);
-  // CHECK:  {{.*}} = load i16, i16* %s_fract2, align 2
-  // CHECK-NEXT: {{.*}} = load i16, i16* %s_fract, align 2
-  // CHECK-NEXT: {{.*}} = icmp slt i16 {{.*}}, {{.*}}
+  // CHECK:  [[VAL:%.+]] = load i16, i16* %s_fract2, align 2
+  // CHECK-NEXT: [[VAL2:%.+]] = load i16, i16* %s_fract, align 2
+  // CHECK-NEXT: [[SHIFTED_VAL:%.+]] = shl i16 [[VAL]], 8
+  // CHECK-NEXT: [[CORRECTED_VAL:%.+]] = ashr i16 [[SHIFTED_VAL]], 8
+  // CHECK-NEXT: [[SHIFTED_VAL2:%.+]] = shl i16 [[VAL2]], 8
+  // CHECK-NEXT: [[CORRECTED_VAL2:%.+]] = ashr i16 [[SHIFTED_VAL2]], 8
+  // CHECK-NEXT: {{.*}} = icmp slt i16 [[CORRECTED_VAL]], [[CORRECTED_VAL2]]
 
   assert(s_fract >= s_fract);
   // CHECK:  {{.*}} = icmp sge i16 {{.*}}, {{.*}}
Index: test/Frontend/fixed_point_all_builtin_operations.c
===
--- test/Frontend/fixed_point_all_builtin_operations.c
+++ test/Frontend/fixed_point_all_builtin_operations.c
@@ -99,6 +99,12 @@
 ASSERT(sub ## ID(a, b) == -0.5 ## SUFFIX - 0.5 ## SUFFIX); \
 a = -0.5 ## SUFFIX - 0.5 ## SUFFIX; \
 ASSERT(mul ## ID(a, a) == 1.0 ## SUFFIX); \
+a = 0.8 ## SUFFIX; \
+b = 0.5 ## SUFFIX; \
+ASSERT(a / b == 1.0 ## SUFFIX); \
+a = -0.8 ## SUFFIX; \
+b = 0.5 ## SUFFIX; \
+ASSERT(a / b == -0.5 ## SUFFIX - 0.5 ## SUFFIX); \
   }
 
 int main(){
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2837,6 +2837,14 @@
 assert(LHSTy == RHSTy);
 
 bool isSignedResult = LHSTy->isSignedFixedPointType() || RHSTy->isSignedFixedPointType();
+unsigned fbits = getFixedPointFBits(Ops.Ty);
+unsigned ibits = getFixedPointIBits(Ops.Ty);
+unsigned FixedPointBits;
+if (isSignedResult) {
+  FixedPointBits = fbits + ibits + 1;
+} else {
+  FixedPointBits = fbits + ibits;
+}
 
 // Round up the bit widths to allocate enough space for calculating the
 // result.
@@ -2848,9 +2856,85 @@
 
 LHSVal = Builder.CreateIntCast(LHSVal, Builder.getIntNTy(bufferWidth), isSignedResult);
 RHSVal = Builder.CreateIntCast(RHSVal, Builder.getIntNTy(bufferWidth), isSignedResult);
-LHSVal = Builder.CreateShl(LHSVal, getFixedPointFBits(LHSTy));
 
+LHSVal = Builder.CreateShl(LHSVal, fbits);
 llvm::Value* DivResult = Builder.CreateSDiv(LHSVal, RHSVal);
+
+if (Ops.Ty->isSaturatedFixedPointType()) {
+  llvm::Value *SatMaxVal = llvm::ConstantInt::get(
+  DivResult->getType(), getFixedPointMaxVal(Ops.Ty));
+  llvm::Value *SatMinVal = llvm::ConstantInt::get(
+  DivResult->getType(), getFixedPointMinVal(Ops.Ty));
+
+  unsigned FixedPointBits;
+  if (Ops.Ty->isSignedFixedPointType()) {
+FixedPointBits = getFixedPointIBits(Ops.Ty) + getFixedPointFBits(Ops.Ty) + 1;
+  } else {
+FixedPointBits = getFixedPointIBits(Ops.Ty) + getFixedPointFBits(Ops.Ty);
+  }
+  unsigned MSBBitShift = FixedPointBits - 1;
+
+  // Number of data + s

[PATCH] D46975: Implement deduction guides for `std::deque`

2018-05-17 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 147317.
mclow.lists added a comment.

Added tests (and fix!) for the implicit deduction guides.


https://reviews.llvm.org/D46975

Files:
  include/deque
  test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp

Index: test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
===
--- test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
+++ test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
@@ -0,0 +1,98 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// XFAIL: libcpp-no-deduction-guides
+
+
+// template ::value_type>>
+//deque(InputIterator, InputIterator, Allocator = Allocator())
+//-> deque::value_type, Allocator>;
+//
+
+
+#include 
+#include 
+#include 
+#include 
+#include  // INT_MAX
+
+#include "test_macros.h"
+#include "test_iterators.h"
+#include "test_allocator.h"
+
+struct A {};
+
+int main()
+{
+  
+//  Test the explicit deduction guides
+{
+const int arr[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+std::deque deq(std::begin(arr), std::end(arr));
+
+static_assert(std::is_same_v>, "");
+assert(std::equal(deq.begin(), deq.end(), std::begin(arr), std::end(arr)));
+}
+
+{
+const long arr[] = {INT_MAX, 1L + INT_MAX, 2L, 3L };
+std::deque deq(std::begin(arr), std::end(arr), std::allocator());
+static_assert(std::is_same_v, "");
+assert(deq.size() == 4);
+assert(deq[0] == INT_MAX);
+assert(deq[1] == 1L + INT_MAX);
+assert(deq[2] == 2L);
+}
+
+//  Test the implicit deduction guides
+
+{
+//  We don't expect this one to work.
+//  std::deque deq(std::allocator()); // deque (allocator &)
+}
+
+{
+std::deque deq(1, A{}); // deque (size_type, T)
+static_assert(std::is_same_v, "");
+static_assert(std::is_same_v>, "");
+assert(deq.size() == 1);
+}
+
+{
+std::deque deq(1, A{}, test_allocator()); // deque (size_type, T, allocator)
+static_assert(std::is_same_v, "");
+static_assert(std::is_same_v>, "");
+assert(deq.size() == 1);
+}
+
+{
+std::deque deq{1U, 2U, 3U, 4U, 5U}; // deque(initializer-list)
+static_assert(std::is_same_v, "");
+assert(deq.size() == 5);
+assert(deq[2] == 3U);
+}
+
+{
+std::deque deq({1.0, 2.0, 3.0, 4.0}, test_allocator()); // deque(initializer-list, allocator)
+static_assert(std::is_same_v, "");
+static_assert(std::is_same_v>, "");
+assert(deq.size() == 4);
+assert(deq[3] == 4.0);
+}
+
+{
+std::deque source;
+std::deque deq(source); // deque(deque &)
+static_assert(std::is_same_v, "");
+static_assert(std::is_same_v>, "");
+assert(deq.size() == 0);
+}
+}
Index: include/deque
===
--- include/deque
+++ include/deque
@@ -128,6 +128,10 @@
 void clear() noexcept;
 };
 
+template ::value_type>>
+   deque(InputIterator, InputIterator, Allocator = Allocator())
+   -> deque::value_type, Allocator>;
+
 template 
 bool operator==(const deque& x, const deque& y);
 template 
@@ -921,13 +925,14 @@
 {
 __deque_base(const __deque_base& __c);
 __deque_base& operator=(const __deque_base& __c);
+public:
+typedef _Allocator   allocator_type;
+typedef allocator_traits __alloc_traits;
+typedef typename __alloc_traits::size_type   size_type;
 protected:
 typedef _Tp  value_type;
-typedef _Allocator   allocator_type;
-typedef allocator_traits __alloc_traits;
 typedef value_type&  reference;
 typedef const value_type&const_reference;
-typedef typename __alloc_traits::size_type   size_type;
 typedef typename __alloc_traits::difference_type difference_type;
 typedef typename __alloc_traits::pointer pointer;
 typedef typename __alloc_traits::const_pointer   const_pointer;
@@ -946,6 +951,7 @@
 typedef __deque_iteratorconst_iterator;
 
+protected:
 __map __map_;
 size_type __start_;
 __compressed_pair __size_;
@@ -1461,6 +1467,23 @@
 void __move_assign(deque& __c, false_type);
 };
 
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template::value_type>,
+ class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+ >
+deque(_InputIterator, _InputIterator)
+  -> deque::value_type, _Alloc>;
+
+template::value, void>::type
+ >
+deque(_InputIterator, _InputIterator, _Alloc)

[PATCH] D46943: [clangd] Boost scores for decls from current file in completion

2018-05-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/Quality.cpp:24
+  if (SemaCCResult.Declaration)
+AllDeclsInMainFile = allDeclsInMainFile(SemaCCResult.Declaration);
   if (SemaCCResult.Availability == CXAvailability_Deprecated)

ioeric wrote:
> ioeric wrote:
> > ilya-biryukov wrote:
> > > sammccall wrote:
> > > > ioeric wrote:
> > > > > Could you explain why `AllDeclsInMainFile` is necessary? I think it 
> > > > > might still be fine to boost score for symbols with a declaration in 
> > > > > the main file even if it has redecls in other files (e.g. function 
> > > > > fwd in headers).
> > > > Agree. I think the better signal is (any) decl in main file.
> > > My intuition was that it does not make any sense to functions if there 
> > > definitions are in the same cpp file, because it does not give any useful 
> > > signals on whether those should be preferably called in the same file.
> > > Also, some defs may not be visible to the compiler at the point of 
> > > completion and, therefore, won't get a boost, even if they are in the 
> > > same file. This is inconsistent.
> > > 
> > > E.g., 
> > > 
> > > ```
> > > // === foo.h
> > > class Foo {
> > >   int foo();
> > >   int bar();
> > >   int baz();
> > >   int test();
> > > };
> > > 
> > > int glob_foo();
> > > int glob_bar();
> > > int glob_baz();
> > > 
> > > // === foo.cpp
> > > #include "foo.h"
> > > static some_local_func() {}
> > > 
> > > Foo::foo() {
> > > };
> > > 
> > > int ::glob_foo() {
> > > }
> > > 
> > > Foo::test() {
> > >^
> > >// out of all functions declared in headers, only foo and global_foo 
> > > will get a boost here. That does not make much sense, since:
> > >// - glob_bar() and Foo::bar() are also declared in the same file, but 
> > > compiler hasn't seen them yet, so they won't get a boost.
> > >// - glob_baz() and Foo::baz() are not declared in the same file, but 
> > > they are so close to `bar` in the header, 
> > >//   and it doesn't seem to make sense to rank them differently.
> > > }
> > > 
> > > Foo::bar() {
> > > }
> > > 
> > > int ::glob_bar() {
> > > }
> > > ```
> > > 
> > > Why upranking decls **only** in the current file is still useful?
> > >  - Those are usually helpers that are very relevant to the file. 
> > > Especially true for small files.
> > >  - As a side-effect, we'll uprank local vars and parameters (they can't 
> > > have decls in other files :-)), that seems useful. Maybe such implicit 
> > > effects are not desirable, though.
> > > 
> > > I should've definitely documented this better. If we decide this change 
> > > is useful, I'll add more docs.
> > > My intuition was that it does not make any sense to functions if there 
> > > definitions are in the same cpp file, because it does not give any useful 
> > > signals on whether those should be preferably called in the same file.
> > Not sure if I understand this. Could you explain why?
> > 
> > > Also, some defs may not be visible to the compiler at the point of 
> > > completion and, therefore, won't get a boost, even if they are in the 
> > > same file. This is inconsistent.
> > I think this is somewhat expected as that symbol might not be visible to me 
> > e.g. a helper function defined after me.
> > 
> > > out of all functions declared in headers, only foo and global_foo will 
> > > get a boost here. That does not make much sense, since: 
> > I think you made a very good point here: for a .cc main file, symbols 
> > declared/defined in the main header (e.g. `x.h` for `x.cc`) are also 
> > interesting and should get a boost, so instead of only boosting symbols 
> > that are only declared in the main file, I would suggest also boost symbols 
> > in its corresponding header. We would need some heuristics to identify main 
> > header though (clang-format uses base file name sans extension which seems 
> > to work pretty well).
> > 
> > Thanks for the example! I think it's very useful for discussions.
> > 
> > 
> > 
> >> I think this is somewhat expected as that symbol might not be visible to 
> >> me e.g. a helper function defined after me.
> By "me", I mean I am a decl ;)
> 
> 
>> My intuition was that it does not make any sense to functions if there 
>> definitions are in the same cpp file, because it does not give any useful 
>> signals on whether those should be preferably called in the same file.
> Not sure if I understand this. Could you explain why?
If I'm implementing a class, relevance of all class methods for me is probably 
the same, no matter if I have a definition for some of those in the current 
file or not.
Probably the same point you make later about boosting symbols in the matching 
header.

> I think this is somewhat expected as that symbol might not be visible to me 
> e.g. a helper function defined after me.

A helper function defined later **only** in the current file is not visible in 
completion and this is (arguably) fine, since you can't refer to it anymore.

[PATCH] D46685: [CodeGen] Disable structor optimizations at -O0

2018-05-17 Thread Pavel Labath via Phabricator via cfe-commits
labath updated this revision to Diff 147315.
labath added a comment.

Updating with a new version of the patch. The problem with the previous version
was that it caused us to use C5/https://reviews.llvm.org/D5 comdats very 
aggressively (at -O0), and this
is not always correct. This uses a more nuanced approach:

- for local symbols we can use aliases because we don't have to worry about 
comdats or other compilation units.
- for linkonce symbols, we must emit each structor separately. Theoretically it 
would be possible to emit a C5 comdat, but then we would need to make sure it 
contains both (in case of destructors, all three) symbols. As linkonce symbols 
are emitted lazily, I did not find an easy way to ensure that this is always 
the case.
- for available_externally, I also emit the structor, as the code seemed to be 
worried about emitting an alias in this case.
- other linkage types are not affected by the optimization level. They either 
get put into a comdat (weak) or get aliased (external).

I also add more thorough tests for this behavior.

Overall I am not sure if this extra complexity is worth the few extra aliases we
can emit this way at -O0. Let me know what you think.


Repository:
  rC Clang

https://reviews.llvm.org/D46685

Files:
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/ctor-dtor-alias.cpp
  test/CodeGenCXX/float16-declarations.cpp

Index: test/CodeGenCXX/float16-declarations.cpp
===
--- test/CodeGenCXX/float16-declarations.cpp
+++ test/CodeGenCXX/float16-declarations.cpp
@@ -103,7 +103,7 @@
 
   C1 c1(f1l);
 // CHECK-DAG:  [[F1L:%[a-z0-9]+]] = load half, half* %{{.*}}, align 2
-// CHECK-DAG:  call void @_ZN2C1C2EDF16_(%class.C1* %{{.*}}, half %{{.*}})
+// CHECK-DAG:  call void @_ZN2C1C1EDF16_(%class.C1* %{{.*}}, half %{{.*}})
 
   S1<_Float16> s1 = { 132.f16 };
 // CHECK-DAG: @_ZZ4mainE2s1 = private unnamed_addr constant %struct.S1 { half 0xH5820 }, align 2
Index: test/CodeGenCXX/ctor-dtor-alias.cpp
===
--- test/CodeGenCXX/ctor-dtor-alias.cpp
+++ test/CodeGenCXX/ctor-dtor-alias.cpp
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases | FileCheck --check-prefix=NOOPT %s
-
+// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases > %t
+// RUN: FileCheck --check-prefix=NOOPT1 --input-file=%t %s
+// RUN: FileCheck --check-prefix=NOOPT2 --input-file=%t %s
+// RUN: FileCheck --check-prefix=NOOPT3 --input-file=%t %s
 // RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases -O1 -disable-llvm-passes > %t
 // RUN: FileCheck --check-prefix=CHECK1 --input-file=%t %s
 // RUN: FileCheck --check-prefix=CHECK2 --input-file=%t %s
@@ -21,6 +23,13 @@
 // CHECK1: define weak_odr void @_ZN5test16foobarIvED0Ev({{.*}} comdat($_ZN5test16foobarIvED5Ev)
 // CHECK1-NOT: comdat
 
+// This should happen regardless of the opt level.
+// NOOPT1: @_ZN5test16foobarIvEC1Ev = weak_odr alias void {{.*}} @_ZN5test16foobarIvEC2Ev
+// NOOPT1: @_ZN5test16foobarIvED1Ev = weak_odr alias void (%"struct.test1::foobar"*), void (%"struct.test1::foobar"*)* @_ZN5test16foobarIvED2Ev
+// NOOPT1: define weak_odr void @_ZN5test16foobarIvEC2Ev({{.*}} comdat($_ZN5test16foobarIvEC5Ev)
+// NOOPT1: define weak_odr void @_ZN5test16foobarIvED2Ev({{.*}} comdat($_ZN5test16foobarIvED5Ev)
+// NOOPT1: define weak_odr void @_ZN5test16foobarIvED0Ev({{.*}} comdat($_ZN5test16foobarIvED5Ev)
+
 // COFF doesn't support comdats with arbitrary names (C5/D5).
 // COFF: define weak_odr {{.*}} void @_ZN5test16foobarIvEC2Ev({{.*}} comdat align
 // COFF: define weak_odr {{.*}} void @_ZN5test16foobarIvEC1Ev({{.*}} comdat align
@@ -37,12 +46,17 @@
 }
 
 namespace test2 {
-// test that when the destrucor is linkonce_odr we just replace every use of
+// test that when the destructor is linkonce_odr we just replace every use of
 // C1 with C2.
 
 // CHECK1: define internal void @__cxx_global_var_init()
 // CHECK1: call void @_ZN5test26foobarIvEC2Ev
 // CHECK1: define linkonce_odr void @_ZN5test26foobarIvEC2Ev({{.*}} comdat align
+
+// At -O0, we should still emit the complete constructor.
+// NOOPT1: define internal void @__cxx_global_var_init()
+// NOOPT1: call void @_ZN5test26foobarIvEC1Ev
+// NOOPT1: define linkonce_odr void @_ZN5test26foobarIvEC1Ev({{.*}} comdat align
 void g();
 template  struct foobar {
   foobar() { g(); }
@@ -57,6 +71,11 @@
 // CHECK1: define internal void @__cxx_global_var_init.1()
 // CHECK1: call i32 @__cxa_atexit{{.*}}_ZN5test312_GLOBAL__N_11AD2Ev
 // CHECK1: define internal void @_ZN5test312_GLOBAL__N_11AD2Ev(
+
+// We can use an alias for internal symbols at -O0.
+// NOOPT2: _ZN5test312_GLOBAL__N_11BD1Ev = internal alias void {{.*}} @_ZN5test312_GLOBAL__N_11BD2Ev
+// NOOPT2: define internal void @__cxx_global_var_init.1()
+// NOOPT2: call i32 @__cxa_atexit{{.*}}_ZN5test312_GLOBAL__N_11BD1Ev
 namespace {
 struct A {
 

[PATCH] D46943: [clangd] Boost scores for decls from current file in completion

2018-05-17 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/Quality.cpp:24
+  if (SemaCCResult.Declaration)
+AllDeclsInMainFile = allDeclsInMainFile(SemaCCResult.Declaration);
   if (SemaCCResult.Availability == CXAvailability_Deprecated)

ioeric wrote:
> ilya-biryukov wrote:
> > sammccall wrote:
> > > ioeric wrote:
> > > > Could you explain why `AllDeclsInMainFile` is necessary? I think it 
> > > > might still be fine to boost score for symbols with a declaration in 
> > > > the main file even if it has redecls in other files (e.g. function fwd 
> > > > in headers).
> > > Agree. I think the better signal is (any) decl in main file.
> > My intuition was that it does not make any sense to functions if there 
> > definitions are in the same cpp file, because it does not give any useful 
> > signals on whether those should be preferably called in the same file.
> > Also, some defs may not be visible to the compiler at the point of 
> > completion and, therefore, won't get a boost, even if they are in the same 
> > file. This is inconsistent.
> > 
> > E.g., 
> > 
> > ```
> > // === foo.h
> > class Foo {
> >   int foo();
> >   int bar();
> >   int baz();
> >   int test();
> > };
> > 
> > int glob_foo();
> > int glob_bar();
> > int glob_baz();
> > 
> > // === foo.cpp
> > #include "foo.h"
> > static some_local_func() {}
> > 
> > Foo::foo() {
> > };
> > 
> > int ::glob_foo() {
> > }
> > 
> > Foo::test() {
> >^
> >// out of all functions declared in headers, only foo and global_foo 
> > will get a boost here. That does not make much sense, since:
> >// - glob_bar() and Foo::bar() are also declared in the same file, but 
> > compiler hasn't seen them yet, so they won't get a boost.
> >// - glob_baz() and Foo::baz() are not declared in the same file, but 
> > they are so close to `bar` in the header, 
> >//   and it doesn't seem to make sense to rank them differently.
> > }
> > 
> > Foo::bar() {
> > }
> > 
> > int ::glob_bar() {
> > }
> > ```
> > 
> > Why upranking decls **only** in the current file is still useful?
> >  - Those are usually helpers that are very relevant to the file. Especially 
> > true for small files.
> >  - As a side-effect, we'll uprank local vars and parameters (they can't 
> > have decls in other files :-)), that seems useful. Maybe such implicit 
> > effects are not desirable, though.
> > 
> > I should've definitely documented this better. If we decide this change is 
> > useful, I'll add more docs.
> > My intuition was that it does not make any sense to functions if there 
> > definitions are in the same cpp file, because it does not give any useful 
> > signals on whether those should be preferably called in the same file.
> Not sure if I understand this. Could you explain why?
> 
> > Also, some defs may not be visible to the compiler at the point of 
> > completion and, therefore, won't get a boost, even if they are in the same 
> > file. This is inconsistent.
> I think this is somewhat expected as that symbol might not be visible to me 
> e.g. a helper function defined after me.
> 
> > out of all functions declared in headers, only foo and global_foo will get 
> > a boost here. That does not make much sense, since: 
> I think you made a very good point here: for a .cc main file, symbols 
> declared/defined in the main header (e.g. `x.h` for `x.cc`) are also 
> interesting and should get a boost, so instead of only boosting symbols that 
> are only declared in the main file, I would suggest also boost symbols in its 
> corresponding header. We would need some heuristics to identify main header 
> though (clang-format uses base file name sans extension which seems to work 
> pretty well).
> 
> Thanks for the example! I think it's very useful for discussions.
> 
> 
> 
>> I think this is somewhat expected as that symbol might not be visible to me 
>> e.g. a helper function defined after me.
By "me", I mean I am a decl ;)




Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46943



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


[PATCH] D46943: [clangd] Boost scores for decls from current file in completion

2018-05-17 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/Quality.cpp:24
+  if (SemaCCResult.Declaration)
+AllDeclsInMainFile = allDeclsInMainFile(SemaCCResult.Declaration);
   if (SemaCCResult.Availability == CXAvailability_Deprecated)

ilya-biryukov wrote:
> sammccall wrote:
> > ioeric wrote:
> > > Could you explain why `AllDeclsInMainFile` is necessary? I think it might 
> > > still be fine to boost score for symbols with a declaration in the main 
> > > file even if it has redecls in other files (e.g. function fwd in headers).
> > Agree. I think the better signal is (any) decl in main file.
> My intuition was that it does not make any sense to functions if there 
> definitions are in the same cpp file, because it does not give any useful 
> signals on whether those should be preferably called in the same file.
> Also, some defs may not be visible to the compiler at the point of completion 
> and, therefore, won't get a boost, even if they are in the same file. This is 
> inconsistent.
> 
> E.g., 
> 
> ```
> // === foo.h
> class Foo {
>   int foo();
>   int bar();
>   int baz();
>   int test();
> };
> 
> int glob_foo();
> int glob_bar();
> int glob_baz();
> 
> // === foo.cpp
> #include "foo.h"
> static some_local_func() {}
> 
> Foo::foo() {
> };
> 
> int ::glob_foo() {
> }
> 
> Foo::test() {
>^
>// out of all functions declared in headers, only foo and global_foo will 
> get a boost here. That does not make much sense, since:
>// - glob_bar() and Foo::bar() are also declared in the same file, but 
> compiler hasn't seen them yet, so they won't get a boost.
>// - glob_baz() and Foo::baz() are not declared in the same file, but they 
> are so close to `bar` in the header, 
>//   and it doesn't seem to make sense to rank them differently.
> }
> 
> Foo::bar() {
> }
> 
> int ::glob_bar() {
> }
> ```
> 
> Why upranking decls **only** in the current file is still useful?
>  - Those are usually helpers that are very relevant to the file. Especially 
> true for small files.
>  - As a side-effect, we'll uprank local vars and parameters (they can't have 
> decls in other files :-)), that seems useful. Maybe such implicit effects are 
> not desirable, though.
> 
> I should've definitely documented this better. If we decide this change is 
> useful, I'll add more docs.
> My intuition was that it does not make any sense to functions if there 
> definitions are in the same cpp file, because it does not give any useful 
> signals on whether those should be preferably called in the same file.
Not sure if I understand this. Could you explain why?

> Also, some defs may not be visible to the compiler at the point of completion 
> and, therefore, won't get a boost, even if they are in the same file. This is 
> inconsistent.
I think this is somewhat expected as that symbol might not be visible to me 
e.g. a helper function defined after me.

> out of all functions declared in headers, only foo and global_foo will get a 
> boost here. That does not make much sense, since: 
I think you made a very good point here: for a .cc main file, symbols 
declared/defined in the main header (e.g. `x.h` for `x.cc`) are also 
interesting and should get a boost, so instead of only boosting symbols that 
are only declared in the main file, I would suggest also boost symbols in its 
corresponding header. We would need some heuristics to identify main header 
though (clang-format uses base file name sans extension which seems to work 
pretty well).

Thanks for the example! I think it's very useful for discussions.





Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46943



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


[clang-tools-extra] r332609 - [clang-tidy] Add a flag to enable alpha checkers

2018-05-17 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu May 17 07:04:27 2018
New Revision: 332609

URL: http://llvm.org/viewvc/llvm-project?rev=332609&view=rev
Log:
[clang-tidy] Add a flag to enable alpha checkers

Summary: The alpha checkers can already be enabled using the clang driver, this 
allows them to be enabled using the clang-tidy as well. This can make it easier 
to test the alpha checkers with projects which already support the 
compile_commands.json. It will also allow more people to give feedback and 
patches about the alpha checkers since they can run it as part of clang tidy 
checks.

Reviewers: aaron.ballman, hokein, ilya-biryukov, alexfh, lebedev.ri, xbolva00

Reviewed By: aaron.ballman, alexfh, lebedev.ri, xbolva00

Subscribers: xbolva00, NoQ, dcoughlin, lebedev.ri, xazax.hun, cfe-commits

Patch by Paul Fultz II!

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

Added:
clang-tools-extra/trunk/test/clang-tidy/enable-alpha-checks.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidy.h
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=332609&r1=332608&r2=332609&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu May 17 07:04:27 2018
@@ -309,11 +309,12 @@ static void setStaticAnalyzerCheckerOpts
 
 typedef std::vector> CheckersList;
 
-static CheckersList getCheckersControlList(ClangTidyContext &Context) {
+static CheckersList getCheckersControlList(ClangTidyContext &Context,
+   bool IncludeExperimental) {
   CheckersList List;
 
   const auto &RegisteredCheckers =
-  AnalyzerOptions::getRegisteredCheckers(/*IncludeExperimental=*/false);
+  AnalyzerOptions::getRegisteredCheckers(IncludeExperimental);
   bool AnalyzerChecksEnabled = false;
   for (StringRef CheckName : RegisteredCheckers) {
 std::string ClangTidyCheckName((AnalyzerCheckNamePrefix + 
CheckName).str());
@@ -379,7 +380,8 @@ ClangTidyASTConsumerFactory::CreateASTCo
 Consumers.push_back(Finder->newASTConsumer());
 
   AnalyzerOptionsRef AnalyzerOptions = Compiler.getAnalyzerOpts();
-  AnalyzerOptions->CheckersControlList = getCheckersControlList(Context);
+  AnalyzerOptions->CheckersControlList =
+  getCheckersControlList(Context, 
Context.canEnableAnalyzerAlphaCheckers());
   if (!AnalyzerOptions->CheckersControlList.empty()) {
 setStaticAnalyzerCheckerOpts(Context.getOptions(), AnalyzerOptions);
 AnalyzerOptions->AnalysisStoreOpt = RegionStoreModel;
@@ -404,7 +406,8 @@ std::vector ClangTidyASTCon
   CheckNames.push_back(CheckFactory.first);
   }
 
-  for (const auto &AnalyzerCheck : getCheckersControlList(Context))
+  for (const auto &AnalyzerCheck : getCheckersControlList(
+   Context, Context.canEnableAnalyzerAlphaCheckers()))
 CheckNames.push_back(AnalyzerCheckNamePrefix + AnalyzerCheck.first);
 
   std::sort(CheckNames.begin(), CheckNames.end());
@@ -463,18 +466,24 @@ void OptionsView::store(ClangTidyOptions
   store(Options, LocalName, llvm::itostr(Value));
 }
 
-std::vector getCheckNames(const ClangTidyOptions &Options) {
+std::vector
+getCheckNames(const ClangTidyOptions &Options,
+  bool AllowEnablingAnalyzerAlphaCheckers) {
   clang::tidy::ClangTidyContext Context(
   llvm::make_unique(ClangTidyGlobalOptions(),
-Options));
+Options),
+  AllowEnablingAnalyzerAlphaCheckers);
   ClangTidyASTConsumerFactory Factory(Context);
   return Factory.getCheckNames();
 }
 
-ClangTidyOptions::OptionMap getCheckOptions(const ClangTidyOptions &Options) {
+ClangTidyOptions::OptionMap
+getCheckOptions(const ClangTidyOptions &Options,
+bool AllowEnablingAnalyzerAlphaCheckers) {
   clang::tidy::ClangTidyContext Context(
   llvm::make_unique(ClangTidyGlobalOptions(),
-Options));
+Options),
+  AllowEnablingAnalyzerAlphaCheckers);
   ClangTidyASTConsumerFactory Factory(Context);
   return Factory.getCheckOptions();
 }

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.h?rev=332609&r1=332608&r2=332609&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.h Thu May 17 07:04:27 2018
@@ -210,7 +210,

[PATCH] D46159: [clang-tidy] Add a flag to enable alpha checkers

2018-05-17 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332609: [clang-tidy] Add a flag to enable alpha checkers 
(authored by alexfh, committed by ).
Herald added subscribers: llvm-commits, klimek.

Changed prior to commit:
  https://reviews.llvm.org/D46159?vs=146719&id=147311#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46159

Files:
  clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
  clang-tools-extra/trunk/clang-tidy/ClangTidy.h
  clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/trunk/test/clang-tidy/enable-alpha-checks.cpp

Index: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -177,9 +177,11 @@
 };
 
 ClangTidyContext::ClangTidyContext(
-std::unique_ptr OptionsProvider)
+std::unique_ptr OptionsProvider,
+bool AllowEnablingAnalyzerAlphaCheckers)
 : DiagEngine(nullptr), OptionsProvider(std::move(OptionsProvider)),
-  Profile(false) {
+  Profile(false),
+  AllowEnablingAnalyzerAlphaCheckers(AllowEnablingAnalyzerAlphaCheckers) {
   // Before the first translation unit we can get errors related to command-line
   // parsing, use empty string for the file name in this case.
   setCurrentFile("");
Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
@@ -309,11 +309,12 @@
 
 typedef std::vector> CheckersList;
 
-static CheckersList getCheckersControlList(ClangTidyContext &Context) {
+static CheckersList getCheckersControlList(ClangTidyContext &Context,
+   bool IncludeExperimental) {
   CheckersList List;
 
   const auto &RegisteredCheckers =
-  AnalyzerOptions::getRegisteredCheckers(/*IncludeExperimental=*/false);
+  AnalyzerOptions::getRegisteredCheckers(IncludeExperimental);
   bool AnalyzerChecksEnabled = false;
   for (StringRef CheckName : RegisteredCheckers) {
 std::string ClangTidyCheckName((AnalyzerCheckNamePrefix + CheckName).str());
@@ -379,7 +380,8 @@
 Consumers.push_back(Finder->newASTConsumer());
 
   AnalyzerOptionsRef AnalyzerOptions = Compiler.getAnalyzerOpts();
-  AnalyzerOptions->CheckersControlList = getCheckersControlList(Context);
+  AnalyzerOptions->CheckersControlList =
+  getCheckersControlList(Context, Context.canEnableAnalyzerAlphaCheckers());
   if (!AnalyzerOptions->CheckersControlList.empty()) {
 setStaticAnalyzerCheckerOpts(Context.getOptions(), AnalyzerOptions);
 AnalyzerOptions->AnalysisStoreOpt = RegionStoreModel;
@@ -404,7 +406,8 @@
   CheckNames.push_back(CheckFactory.first);
   }
 
-  for (const auto &AnalyzerCheck : getCheckersControlList(Context))
+  for (const auto &AnalyzerCheck : getCheckersControlList(
+   Context, Context.canEnableAnalyzerAlphaCheckers()))
 CheckNames.push_back(AnalyzerCheckNamePrefix + AnalyzerCheck.first);
 
   std::sort(CheckNames.begin(), CheckNames.end());
@@ -463,18 +466,24 @@
   store(Options, LocalName, llvm::itostr(Value));
 }
 
-std::vector getCheckNames(const ClangTidyOptions &Options) {
+std::vector
+getCheckNames(const ClangTidyOptions &Options,
+  bool AllowEnablingAnalyzerAlphaCheckers) {
   clang::tidy::ClangTidyContext Context(
   llvm::make_unique(ClangTidyGlobalOptions(),
-Options));
+Options),
+  AllowEnablingAnalyzerAlphaCheckers);
   ClangTidyASTConsumerFactory Factory(Context);
   return Factory.getCheckNames();
 }
 
-ClangTidyOptions::OptionMap getCheckOptions(const ClangTidyOptions &Options) {
+ClangTidyOptions::OptionMap
+getCheckOptions(const ClangTidyOptions &Options,
+bool AllowEnablingAnalyzerAlphaCheckers) {
   clang::tidy::ClangTidyContext Context(
   llvm::make_unique(ClangTidyGlobalOptions(),
-Options));
+Options),
+  AllowEnablingAnalyzerAlphaCheckers);
   ClangTidyASTConsumerFactory Factory(Context);
   return Factory.getCheckOptions();
 }
Index: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -99,7 +99,8 @@
 class ClangTidyContext {
 public:
   /// \brief Initializes \c ClangTidyContext instance.
-  ClangTidyContext(std::unique_ptr OptionsP

[PATCH] D44954: [clangd] Add "member" symbols to the index

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

In https://reviews.llvm.org/D44954#1101922, @malaperle wrote:

> @ioeric You mentioned in https://reviews.llvm.org/D46751 that it would make 
> sense to add a flag to disable indexing members. Could you comment on that? 
> What kind of granularity were you thinking? Would a "member" flag cover both 
> class members (member vars and functions) and enum class enumerators for 
> example? I think that would be reasonable. But I will also add symbols in 
> main files too, so another flag for that? Hmmm.


Sam convinced me that members would still be interesting for our internal index 
service (e.g. locations of members would be useful for go-to-def). I'll 
investigate how much impact that would be by running the indexer with your 
change patched in, but I don't want to block you on that, so I'm fine with 
checking this in without any filter. We could revisit the filter design when 
needed.

We actually had an option for indexing symbols in main files :) But it was 
removed as it turned out to be unused for the features clangd had at that 
point. I think it would be reasonable to add it back if we start supporting 
collecting main file symbols again. Maybe out of the scope of this patch, but I 
am interested in the use cases you have for symbols in main files, besides in 
`workspaceSymbols`?




Comment at: clangd/index/Index.h:160
+  /// The Decl::Kind for the context of the symbol, i.e. what contains it.
+  Decl::Kind DeclContextKind;
+  /// Whether or not this is an enumerator inside a scoped enum (C++11).

ilya-biryukov wrote:
> How do we use `DeclContextKind`?
> Why did we decide to not go with a `bool ForCompletion` instead? (I'm 
> probably missing a conversation in the workspaceSymbol review, could you 
> point me to those instead?)
> 
> I'm asking because clang enums are very detailed and designed for use in the 
> compiler, using them in the index seems to complicate things.
> It feels we don't need this level of detail in the symbols. Similar to how we 
> don't store the whole structural type, but rely on string representation of 
> completion label instead.
+1

`ForCompletion` sounds reasonable as the current design of index-based code 
completion relies on assumptions about contexts. 



Comment at: clangd/index/Index.h:162
+  /// Whether or not this is an enumerator inside a scoped enum (C++11).
+  bool InScopedEnum = false;
   /// A brief description of the symbol that can be displayed in the completion

In case we do need these fields, I think they should go into 
`index::SymbolInfo` (i.e. `SymInfo` above)? As Ilya said, `Symbol` might be the 
wrong level to put these. And we would want them in index-while-build anyway.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44954



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


[PATCH] D46932: [AArch64] Correct inline assembly test case for S modifier [NFC]

2018-05-17 Thread Peter Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332606: [AArch64] Correct inline assembly test case for S 
modifier [NFC] (authored by psmith, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D46932

Files:
  test/CodeGen/aarch64-inline-asm.c


Index: test/CodeGen/aarch64-inline-asm.c
===
--- test/CodeGen/aarch64-inline-asm.c
+++ test/CodeGen/aarch64-inline-asm.c
@@ -44,9 +44,9 @@
 
 void test_constraint_S(void) {
 int *addr;
-asm("adrp %0, %A1\n\t"
-"add %0, %0, %L1" : "=r"(addr) : "S"(&var));
-// CHECK: call i32* asm "adrp $0, ${1:A}\0A\09add $0, $0, ${1:L}", "=r,S"(i64* 
@var)
+asm("adrp %0, %1\n\t"
+"add %0, %0, :lo12:%1" : "=r"(addr) : "S"(&var));
+// CHECK: call i32* asm "adrp $0, $1\0A\09add $0, $0, :lo12:$1", "=r,S"(i64* 
@var)
 }
 
 void test_constraint_Q(void) {


Index: test/CodeGen/aarch64-inline-asm.c
===
--- test/CodeGen/aarch64-inline-asm.c
+++ test/CodeGen/aarch64-inline-asm.c
@@ -44,9 +44,9 @@
 
 void test_constraint_S(void) {
 int *addr;
-asm("adrp %0, %A1\n\t"
-"add %0, %0, %L1" : "=r"(addr) : "S"(&var));
-// CHECK: call i32* asm "adrp $0, ${1:A}\0A\09add $0, $0, ${1:L}", "=r,S"(i64* @var)
+asm("adrp %0, %1\n\t"
+"add %0, %0, :lo12:%1" : "=r"(addr) : "S"(&var));
+// CHECK: call i32* asm "adrp $0, $1\0A\09add $0, $0, :lo12:$1", "=r,S"(i64* @var)
 }
 
 void test_constraint_Q(void) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46867: [ASTImporter] Add unit tests for structural equivalence

2018-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 147304.
martong marked an inline comment as done.
martong added a comment.

- Address aleksei's comments


Repository:
  rC Clang

https://reviews.llvm.org/D46867

Files:
  unittests/AST/ASTImporterTest.cpp
  unittests/AST/CMakeLists.txt
  unittests/AST/Language.cpp
  unittests/AST/Language.h
  unittests/AST/MatchVerifier.h
  unittests/AST/StructuralEquivalenceTest.cpp

Index: unittests/AST/StructuralEquivalenceTest.cpp
===
--- /dev/null
+++ unittests/AST/StructuralEquivalenceTest.cpp
@@ -0,0 +1,208 @@
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/AST/ASTStructuralEquivalence.h"
+#include "clang/Frontend/ASTUnit.h"
+#include "clang/Tooling/Tooling.h"
+
+#include "Language.h"
+#include "DeclMatcher.h"
+
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ast_matchers {
+
+struct StructuralEquivalenceTest : ::testing::Test {
+  std::unique_ptr AST0, AST1;
+  std::string Code0, Code1; // Buffers for SourceManager
+
+  // Get a pair of Decl pointers to the synthetised declarations from the given
+  // code snipets. By default we search for the unique Decl with name 'foo' in
+  // both snippets.
+  std::tuple
+  makeNamedDecls(const std::string &SrcCode0, const std::string &SrcCode1,
+ Language Lang, const char *const Identifier = "foo") {
+
+this->Code0 = SrcCode0;
+this->Code1 = SrcCode1;
+ArgVector Args = getBasicRunOptionsForLanguage(Lang);
+
+const char *const InputFileName = "input.cc";
+
+AST0 = tooling::buildASTFromCodeWithArgs(Code0, Args, InputFileName);
+AST1 = tooling::buildASTFromCodeWithArgs(Code1, Args, InputFileName);
+
+ASTContext &Ctx0 = AST0->getASTContext(), &Ctx1 = AST1->getASTContext();
+
+auto getDecl = [](ASTContext &Ctx, const std::string &Name) -> NamedDecl * {
+  IdentifierInfo *SearchedII = &Ctx.Idents.get(Name);
+  assert(SearchedII && "Declaration with the identifier "
+   "should be specified in test!");
+  DeclarationName SearchDeclName(SearchedII);
+  SmallVector FoundDecls;
+  Ctx.getTranslationUnitDecl()->localUncachedLookup(SearchDeclName,
+FoundDecls);
+
+  // We should find one Decl but one only.
+  assert(FoundDecls.size() == 1);
+
+  return FoundDecls[0];
+};
+
+NamedDecl *D0 = getDecl(Ctx0, Identifier);
+NamedDecl *D1 = getDecl(Ctx1, Identifier);
+assert(D0);
+assert(D1);
+return std::make_tuple(D0, D1);
+  }
+
+  bool testStructuralMatch(NamedDecl *D0, NamedDecl *D1) {
+llvm::DenseSet> NonEquivalentDecls;
+StructuralEquivalenceContext Ctx(D0->getASTContext(), D1->getASTContext(),
+ NonEquivalentDecls, false, false);
+return Ctx.IsStructurallyEquivalent(D0, D1);
+  }
+
+  bool testStructuralMatch(std::tuple t) {
+using std::get;
+return testStructuralMatch(get<0>(t), get<1>(t));
+  }
+};
+
+using std::get;
+
+TEST_F(StructuralEquivalenceTest, Int) {
+  auto Decls = makeNamedDecls("int foo;", "int foo;", Lang_CXX);
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceTest, IntVsSignedInt) {
+  auto Decls = makeNamedDecls("int foo;", "signed int foo;", Lang_CXX);
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceTest, Char) {
+  auto Decls = makeNamedDecls("char foo;", "char foo;", Lang_CXX);
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+// This test is disabled for now.
+// FIXME Whether this is equivalent is dependendant on the target.
+TEST_F(StructuralEquivalenceTest, DISABLED_CharVsSignedChar) {
+  auto Decls = makeNamedDecls("char foo;", "signed char foo;", Lang_CXX);
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceTest, ForwardRecordDecl) {
+  auto Decls = makeNamedDecls("struct foo;", "struct foo;", Lang_CXX);
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceTest, IntVsSignedIntInStruct) {
+  auto Decls = makeNamedDecls("struct foo { int x; };",
+  "struct foo { signed int x; };", Lang_CXX);
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceTest, CharVsSignedCharInStruct) {
+  auto Decls = makeNamedDecls("struct foo { char x; };",
+  "struct foo { signed char x; };", Lang_CXX);
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceTest, IntVsSignedIntTemplateSpec) {
+  auto Decls = makeNamedDecls(
+  "template  struct foo; template<> struct foo{};",
+  "template  struct foo; template<> struct foo{};",
+  Lang_CXX);
+  ClassTemplateSpecializationDecl *Spec0 =
+  *cast(get<0>(Decls))->spec_begin();
+  ClassTemplateSpecializationDecl *Spec1 =
+  *cast(get<1>(Decls))->spec_begin();
+  ASSERT_TRUE(Spec0 != nullptr);
+  ASSERT_TRUE(Spec1 !

r332606 - [AArch64] Correct inline assembly test case for S modifier [NFC]

2018-05-17 Thread Peter Smith via cfe-commits
Author: psmith
Date: Thu May 17 06:17:33 2018
New Revision: 332606

URL: http://llvm.org/viewvc/llvm-project?rev=332606&view=rev
Log:
[AArch64] Correct inline assembly test case for S modifier [NFC]

The existing test for the AArch64 inline assembly constraint S uses the
A and L modifiers. These modifiers were implemented in the original
AArch64 backend but were not carried forward to the merged backend. The
A is associated with ADRP and does nothing, the L is associated with
:lo12: . Given that A and L are not supported by GCC and not supported
by the new implementation of constraint S in LLVM (see D46745) I've
altered the test to put :lo12: directly in the string so that A and L
are not needed.

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


Modified:
cfe/trunk/test/CodeGen/aarch64-inline-asm.c

Modified: cfe/trunk/test/CodeGen/aarch64-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-inline-asm.c?rev=332606&r1=332605&r2=332606&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-inline-asm.c Thu May 17 06:17:33 2018
@@ -44,9 +44,9 @@ void test_constraints_immed(void) {
 
 void test_constraint_S(void) {
 int *addr;
-asm("adrp %0, %A1\n\t"
-"add %0, %0, %L1" : "=r"(addr) : "S"(&var));
-// CHECK: call i32* asm "adrp $0, ${1:A}\0A\09add $0, $0, ${1:L}", "=r,S"(i64* 
@var)
+asm("adrp %0, %1\n\t"
+"add %0, %0, :lo12:%1" : "=r"(addr) : "S"(&var));
+// CHECK: call i32* asm "adrp $0, $1\0A\09add $0, $0, :lo12:$1", "=r,S"(i64* 
@var)
 }
 
 void test_constraint_Q(void) {


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


[PATCH] D46867: [ASTImporter] Add unit tests for structural equivalence

2018-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 14 inline comments as done.
martong added a comment.

> Do you plan to enable this functionality for AST import checking?

Yes. We'd like to test the structural equivalency independently from 
ASTImporter, because in certain cases it may have faulty behavior. This can be 
very handy also when we further extend structural equivalency.




Comment at: unittests/AST/StructuralEquivalenceTest.cpp:119
+  *cast(get<1>(t))->spec_begin();
+  ASSERT_TRUE(Spec0 != nullptr);
+  ASSERT_TRUE(Spec1 != nullptr);

a.sidorin wrote:
> Should we assert for `spec_begin() != spec_end()` instead or within these 
> assertions?
I think that is not needed, because the previous `cast` in line 116 and 118 
would assert if `spec_begin() == spec_end()` was  true.



Comment at: unittests/AST/StructuralEquivalenceTest.cpp:174
+  )";
+  auto t = makeNamedDecls( Code0, Code0, Lang_CXX);
+

a.sidorin wrote:
> 1. It's better to use more meaningful names than `t`. DeclTuple?
> 2. The space after `(` is redundant.
Renamed `t` to `Decls`.


Repository:
  rC Clang

https://reviews.llvm.org/D46867



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


[PATCH] D46943: [clangd] Boost scores for decls from current file in completion

2018-05-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/AST.h:32
+/// Returns true iff all redecls of \p D are in the main file.
+bool allDeclsInMainFile(const Decl *D);
 

sammccall wrote:
> Do you expect this to be reused?
> If so, unit test? Otherwise this seems small enough to move where it's used.
I'd say we could reuse it, yes. Even though the function is pretty 
straightforward, there are details that should be consistent across the whole 
codebase (i.e. which locations to check, spelling, expansion?)
I'll add unittests.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46943



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


[PATCH] D46943: [clangd] Boost scores for decls from current file in completion

2018-05-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 147301.
ilya-biryukov added a comment.

- Move tests to QualityTests.cpp
- Fix findDecl() assertion on redecls of the same thing
- Fix file comment of TestTU.cpp


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46943

Files:
  clangd/AST.cpp
  clangd/AST.h
  clangd/Quality.cpp
  clangd/Quality.h
  unittests/clangd/QualityTests.cpp
  unittests/clangd/TestTU.cpp

Index: unittests/clangd/TestTU.cpp
===
--- unittests/clangd/TestTU.cpp
+++ unittests/clangd/TestTU.cpp
@@ -1,5 +1,4 @@
-//===--- TestTU.cpp - Scratch source files for testing *-
-//C++-*-===//
+//===--- TestTU.cpp - Scratch source files for testing ---===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -78,11 +77,11 @@
 auto *ND = dyn_cast(D);
 if (!ND || ND->getNameAsString() != QName)
   continue;
-if (Result) {
+if (Result && ND->getCanonicalDecl() != Result) {
   ADD_FAILURE() << "Multiple Decls named " << QName;
   assert(false && "QName is not unique");
 }
-Result = ND;
+Result = cast(ND->getCanonicalDecl());
   }
   if (!Result) {
 ADD_FAILURE() << "No Decl named " << QName << " in AST";
Index: unittests/clangd/QualityTests.cpp
===
--- unittests/clangd/QualityTests.cpp
+++ unittests/clangd/QualityTests.cpp
@@ -118,6 +118,45 @@
   EXPECT_LT(sortText(0, "a"), sortText(0, "z"));
 }
 
+TEST(QualityTests, BoostCurrentFileDecls) {
+  TestTU Test;
+  Test.HeaderFilename = "foo.h";
+  Test.HeaderCode = R"cpp(
+int test_func_in_header();
+int test_func_in_header_and_cpp();
+)cpp";
+  Test.Code = R"cpp(
+#include "foo.h"
+int ::test_func_in_header_and_cpp() {
+}
+int test_func_in_cpp();
+
+int test() {
+  test_func_^
+}
+  )cpp";
+
+  ParsedAST AST = Test.build();
+
+  SymbolQualitySignals FuncInCpp;
+  FuncInCpp.merge(CodeCompletionResult(&findDecl(AST, "test_func_in_cpp"),
+   CCP_Declaration));
+  EXPECT_TRUE(FuncInCpp.AllDeclsInMainFile);
+
+  SymbolQualitySignals FuncInHeader;
+  FuncInHeader.merge(CodeCompletionResult(&findDecl(AST, "test_func_in_header"),
+  CCP_Declaration));
+  EXPECT_FALSE(FuncInHeader.AllDeclsInMainFile);
+
+  SymbolQualitySignals FuncInHeaderAndCpp;
+  FuncInHeaderAndCpp.merge(CodeCompletionResult(
+  &findDecl(AST, "test_func_in_header_and_cpp"), CCP_Declaration));
+  EXPECT_FALSE(FuncInHeaderAndCpp.AllDeclsInMainFile);
+
+  EXPECT_LE(FuncInHeader.evaluate(), FuncInCpp.evaluate());
+  EXPECT_FLOAT_EQ(FuncInHeader.evaluate(), FuncInHeaderAndCpp.evaluate());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/Quality.h
===
--- clangd/Quality.h
+++ clangd/Quality.h
@@ -47,6 +47,7 @@
   unsigned SemaCCPriority = 0; // 1-80, 1 is best. 0 means absent.
// FIXME: this is actually a mix of symbol
//quality and relevance. Untangle this.
+  bool AllDeclsInMainFile = false;
   bool Deprecated = false;
   unsigned References = 0;
 
Index: clangd/Quality.cpp
===
--- clangd/Quality.cpp
+++ clangd/Quality.cpp
@@ -7,6 +7,7 @@
 //
 //===-===//
 #include "Quality.h"
+#include "AST.h"
 #include "index/Index.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -19,7 +20,8 @@
 
 void SymbolQualitySignals::merge(const CodeCompletionResult &SemaCCResult) {
   SemaCCPriority = SemaCCResult.Priority;
-
+  if (SemaCCResult.Declaration)
+AllDeclsInMainFile = allDeclsInMainFile(SemaCCResult.Declaration);
   if (SemaCCResult.Availability == CXAvailability_Deprecated)
 Deprecated = true;
 }
@@ -41,6 +43,10 @@
 // Priority 80 is a really bad score.
 Score *= 2 - std::min(80, SemaCCPriority) / 40;
 
+  // Things declared in the main file get a large boost.
+  if (AllDeclsInMainFile)
+Score *= 2;
+
   if (Deprecated)
 Score *= 0.1;
 
Index: clangd/AST.h
===
--- clangd/AST.h
+++ clangd/AST.h
@@ -26,7 +26,10 @@
 ///
 /// The returned location is usually the spelling location where the name of the
 /// decl occurs in the code.
-SourceLocation findNameLoc(const clang::Decl* D);
+SourceLocation findNameLoc(const Decl *D);
+
+/// Returns true iff all redecls of \p D are in the main file.
+bool allDeclsInMainFile(const Decl *D);
 
 } // namespace clangd
 } // namespace clang
Index: clangd/AST.cpp
===
--- clangd/AST.cpp
+++ clangd/AST.cpp
@@ -17,8 +17,8 @@
 namespace clangd {
 using names

[clang-tools-extra] r332603 - Attempt to fix clang-move tests broken by r332590 on windows

2018-05-17 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu May 17 05:40:50 2018
New Revision: 332603

URL: http://llvm.org/viewvc/llvm-project?rev=332603&view=rev
Log:
Attempt to fix clang-move tests broken by r332590 on windows

http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12007

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.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=332603&r1=332602&r2=332603&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Thu May 17 05:40:50 2018
@@ -61,6 +61,12 @@ AST_MATCHER_P(CXXMethodDecl, ofOutermost
   return InnerMatcher.matches(*Parent, Finder, Builder);
 }
 
+std::string CleanPath(StringRef PathRef) {
+  llvm::SmallString<128> Path(PathRef);
+  llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
+  return Path.str();
+}
+
 // Make the Path absolute using the CurrentDir if the Path is not an absolute
 // path. An empty Path will result in an empty string.
 std::string MakeAbsolutePath(StringRef CurrentDir, StringRef Path) {
@@ -72,9 +78,7 @@ std::string MakeAbsolutePath(StringRef C
   llvm::sys::fs::make_absolute(InitialDirectory, AbsolutePath))
 llvm::errs() << "Warning: could not make absolute file: '" << EC.message()
  << '\n';
-  llvm::sys::path::remove_dots(AbsolutePath, /*remove_dot_dot=*/true);
-  llvm::sys::path::native(AbsolutePath);
-  return AbsolutePath.str();
+  return CleanPath(std::move(AbsolutePath));
 }
 
 // Make the Path absolute using the current working directory of the given
@@ -97,15 +101,13 @@ std::string MakeAbsolutePath(const Sourc
 StringRef DirName = SM.getFileManager().getCanonicalName(Dir);
 // FIXME: getCanonicalName might fail to get real path on VFS.
 if (llvm::sys::path::is_absolute(DirName)) {
-  SmallVector AbsoluteFilename;
+  SmallString<128> AbsoluteFilename;
   llvm::sys::path::append(AbsoluteFilename, DirName,
   llvm::sys::path::filename(AbsolutePath.str()));
-  return llvm::StringRef(AbsoluteFilename.data(), AbsoluteFilename.size())
-  .str();
+  return CleanPath(AbsoluteFilename);
 }
   }
-  llvm::sys::path::remove_dots(AbsolutePath, /*remove_dot_dot=*/true);
-  return AbsolutePath.str();
+  return CleanPath(AbsolutePath);
 }
 
 // Matches AST nodes that are expanded within the given AbsoluteFilePath.


___
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-17 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


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


r332588 - [ASTImporter] Fix missing implict CXXRecordDecl

2018-05-17 Thread Gabor Marton via cfe-commits
Author: martong
Date: Thu May 17 02:46:07 2018
New Revision: 332588

URL: http://llvm.org/viewvc/llvm-project?rev=332588&view=rev
Log:
[ASTImporter] Fix missing implict CXXRecordDecl

Summary:
Implicit CXXRecordDecl is not added to its DeclContext during import, but in
the original AST it is. This patch fixes this.

Reviewers: xazax.hun, a.sidorin, szepet

Subscribers: rnkovacs, dkrupp, cfe-commits

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

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=332588&r1=332587&r2=332588&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Thu May 17 02:46:07 2018
@@ -2110,7 +2110,7 @@ Decl *ASTNodeImporter::VisitRecordDecl(R
   D2 = D2CXX;
   D2->setAccess(D->getAccess());
   D2->setLexicalDeclContext(LexicalDC);
-  if (!DCXX->getDescribedClassTemplate())
+  if (!DCXX->getDescribedClassTemplate() || DCXX->isImplicit())
 LexicalDC->addDeclInternal(D2);
 
   Importer.Imported(D, D2);

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=332588&r1=332587&r2=332588&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Thu May 17 02:46:07 2018
@@ -1348,7 +1348,7 @@ TEST_P(ASTImporterTestBase,
   Verifier.match(To, cxxRecordDecl(hasFieldOrder({"a", "b", "c"};
 }
 
-TEST_P(ASTImporterTestBase, DISABLED_ShouldImportImplicitCXXRecordDecl) {
+TEST_P(ASTImporterTestBase, ShouldImportImplicitCXXRecordDecl) {
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(
   R"(


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


[PATCH] D45177: CStringChecker, check strlcpy/strlcat

2018-05-17 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

In https://reviews.llvm.org/D45177#1102887, @alexfh wrote:

> This is reproducible in r332425.


I posted this PR https://reviews.llvm.org/D47007 hopes it helps.


Repository:
  rC Clang

https://reviews.llvm.org/D45177



___
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-17 Thread Jan Korous via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332598: Use dotted format of version tuple for availability 
diagnostics (authored by jkorous, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46747?vs=147184&id=147295#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46747

Files:
  cfe/trunk/include/clang/Basic/VersionTuple.h
  cfe/trunk/lib/AST/DeclBase.cpp
  cfe/trunk/lib/Basic/VersionTuple.cpp
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/test/Misc/ast-print-objectivec.m
  cfe/trunk/test/Sema/availability-guard-format.mm
  cfe/trunk/test/SemaObjC/attr-availability-1.m

Index: cfe/trunk/include/clang/Basic/VersionTuple.h
===
--- cfe/trunk/include/clang/Basic/VersionTuple.h
+++ cfe/trunk/include/clang/Basic/VersionTuple.h
@@ -24,9 +24,7 @@
 
 /// Represents a version number in the form major[.minor[.subminor[.build]]].
 class VersionTuple {
-  unsigned Major : 31;
-
-  unsigned UsesUnderscores : 1;
+  unsigned Major : 32;
 
   unsigned Minor : 31;
   unsigned HasMinor : 1;
@@ -39,30 +37,25 @@
 
 public:
   VersionTuple()
-  : Major(0), UsesUnderscores(false), Minor(0), HasMinor(false),
-Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}
+  : Major(0), Minor(0), HasMinor(false), Subminor(0), HasSubminor(false),
+Build(0), HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major)
-  : Major(Major), UsesUnderscores(false), Minor(0), HasMinor(false),
-Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}
-
-  explicit VersionTuple(unsigned Major, unsigned Minor,
-bool UsesUnderscores = false)
-  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
-HasMinor(true), Subminor(0), HasSubminor(false), Build(0),
-HasBuild(false) {}
+  : Major(Major), Minor(0), HasMinor(false), Subminor(0),
+HasSubminor(false), Build(0), HasBuild(false) {}
 
-  explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
-bool UsesUnderscores = false)
-  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
-HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(0),
-HasBuild(false) {}
+  explicit VersionTuple(unsigned Major, unsigned Minor)
+  : Major(Major), Minor(Minor), HasMinor(true), Subminor(0),
+HasSubminor(false), Build(0), HasBuild(false) {}
+
+  explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor)
+  : Major(Major), Minor(Minor), HasMinor(true), Subminor(Subminor),
+HasSubminor(true), Build(0), HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
-unsigned Build, bool UsesUnderscores = false)
-  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
-HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(Build),
-HasBuild(true) {}
+unsigned Build)
+  : Major(Major), Minor(Minor), HasMinor(true), Subminor(Subminor),
+HasSubminor(true), Build(Build), HasBuild(true) {}
 
   /// Determine whether this version information is empty
   /// (e.g., all version components are zero).
@@ -93,14 +86,6 @@
   return None;
 return Build;
   }
-
-  bool usesUnderscores() const {
-return UsesUnderscores;
-  }
-
-  void UseDotAsSeparator() {
-UsesUnderscores = false;
-  }
   
   /// Determine if two version numbers are equivalent. If not
   /// provided, minor and subminor version numbers are considered to be zero.
Index: cfe/trunk/test/Misc/ast-print-objectivec.m
===
--- cfe/trunk/test/Misc/ast-print-objectivec.m
+++ cfe/trunk/test/Misc/ast-print-objectivec.m
@@ -30,7 +30,7 @@
 // CHECK: @end
 
 // CHECK: @interface I(CAT)
-// CHECK: - (void)MethCAT __attribute__((availability(macos, introduced=10_1_0, deprecated=10_2)));
+// CHECK: - (void)MethCAT __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2)));
 // CHECK: @end
 
 // CHECK: @implementation I
Index: cfe/trunk/test/Sema/availability-guard-format.mm
===
--- cfe/trunk/test/Sema/availability-guard-format.mm
+++ cfe/trunk/test/Sema/availability-guard-format.mm
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx-10.11 -Wunguarded-availability -fdiagnostics-parseable-fixits -fsyntax-only -verify %s
+
+// Testing that even for source code using '_' as a delimiter in availability version tuple '.' is actually used in diagnostic output as a delimiter.
+
+@interface foo
+- (void) method_bar __attribute__((availability(macosx, introduced = 10_12))); // expected-note {{'method_bar' has been explicitly marked partial here}}
+@end
+
+int main() {
+[foo method_bar]; // \
+  

r332598 - Use dotted format of version tuple for availability diagnostics

2018-05-17 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu May 17 04:51:49 2018
New Revision: 332598

URL: http://llvm.org/viewvc/llvm-project?rev=332598&view=rev
Log:
Use dotted format of version tuple for availability diagnostics

E. g. use "10.11" instead of "10_11".

We are maintaining backward compatibility by parsing underscore-delimited 
version tuples but no longer keep track of the separator and using dot format 
for output.

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

rdar://problem/39845032

Added:
cfe/trunk/test/Sema/availability-guard-format.mm
Modified:
cfe/trunk/include/clang/Basic/VersionTuple.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Basic/VersionTuple.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/Misc/ast-print-objectivec.m
cfe/trunk/test/SemaObjC/attr-availability-1.m

Modified: cfe/trunk/include/clang/Basic/VersionTuple.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VersionTuple.h?rev=332598&r1=332597&r2=332598&view=diff
==
--- cfe/trunk/include/clang/Basic/VersionTuple.h (original)
+++ cfe/trunk/include/clang/Basic/VersionTuple.h Thu May 17 04:51:49 2018
@@ -24,9 +24,7 @@ namespace clang {
 
 /// Represents a version number in the form major[.minor[.subminor[.build]]].
 class VersionTuple {
-  unsigned Major : 31;
-
-  unsigned UsesUnderscores : 1;
+  unsigned Major : 32;
 
   unsigned Minor : 31;
   unsigned HasMinor : 1;
@@ -39,30 +37,25 @@ class VersionTuple {
 
 public:
   VersionTuple()
-  : Major(0), UsesUnderscores(false), Minor(0), HasMinor(false),
-Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}
+  : Major(0), Minor(0), HasMinor(false), Subminor(0), HasSubminor(false),
+Build(0), HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major)
-  : Major(Major), UsesUnderscores(false), Minor(0), HasMinor(false),
-Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}
-
-  explicit VersionTuple(unsigned Major, unsigned Minor,
-bool UsesUnderscores = false)
-  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
-HasMinor(true), Subminor(0), HasSubminor(false), Build(0),
-HasBuild(false) {}
+  : Major(Major), Minor(0), HasMinor(false), Subminor(0),
+HasSubminor(false), Build(0), HasBuild(false) {}
 
-  explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
-bool UsesUnderscores = false)
-  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
-HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(0),
-HasBuild(false) {}
+  explicit VersionTuple(unsigned Major, unsigned Minor)
+  : Major(Major), Minor(Minor), HasMinor(true), Subminor(0),
+HasSubminor(false), Build(0), HasBuild(false) {}
+
+  explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor)
+  : Major(Major), Minor(Minor), HasMinor(true), Subminor(Subminor),
+HasSubminor(true), Build(0), HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
-unsigned Build, bool UsesUnderscores = false)
-  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
-HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(Build),
-HasBuild(true) {}
+unsigned Build)
+  : Major(Major), Minor(Minor), HasMinor(true), Subminor(Subminor),
+HasSubminor(true), Build(Build), HasBuild(true) {}
 
   /// Determine whether this version information is empty
   /// (e.g., all version components are zero).
@@ -93,14 +86,6 @@ public:
   return None;
 return Build;
   }
-
-  bool usesUnderscores() const {
-return UsesUnderscores;
-  }
-
-  void UseDotAsSeparator() {
-UsesUnderscores = false;
-  }
   
   /// Determine if two version numbers are equivalent. If not
   /// provided, minor and subminor version numbers are considered to be zero.

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=332598&r1=332597&r2=332598&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Thu May 17 04:51:49 2018
@@ -550,7 +550,6 @@ static AvailabilityResult CheckAvailabil
   Message->clear();
   llvm::raw_string_ostream Out(*Message);
   VersionTuple VTI(A->getIntroduced());
-  VTI.UseDotAsSeparator();
   Out << "introduced in " << PrettyPlatformName << ' ' 
   << VTI << HintMessage;
 }
@@ -564,7 +563,6 @@ static AvailabilityResult CheckAvailabil
   Message->clear();
   llvm::raw_string_ostream Out(*Message);
   VersionTuple VTO(A->getObsoleted());
-  VTO.UseDotAsSeparator();
   Out << "obsoleted in " << PrettyPlatformName << ' ' 
   << 

[PATCH] D33440: clang-format: better handle statement macros

2018-05-17 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 147293.
Typz marked an inline comment as done.
Typz added a comment.

Address review comments


Repository:
  rC Clang

https://reviews.llvm.org/D33440

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2472,6 +2472,45 @@
getLLVMStyleWithColumns(40)));
 
   verifyFormat("MACRO(>)");
+
+  // Some macros contain an implicit semicolon.
+  FormatStyle Style = getLLVMStyle();
+  Style.StatementMacros.push_back("FOO");
+  verifyFormat("FOO(a) int b = 0;");
+  verifyFormat("FOO(a)\n"
+   "int b = 0;",
+   Style);
+  verifyFormat("FOO(a);\n"
+   "int b = 0;",
+   Style);
+  verifyFormat("FOO(argc, argv, \"4.0.2\")\n"
+   "int b = 0;",
+   Style);
+  verifyFormat("FOO()\n"
+   "int b = 0;",
+   Style);
+  verifyFormat("FOO\n"
+   "int b = 0;",
+   Style);
+  verifyFormat("void f() {\n"
+   "  FOO(a)\n"
+   "  return a;\n"
+   "}",
+   Style);
+  verifyFormat("FOO(a)\n"
+   "FOO(b)",
+   Style);
+  verifyFormat("int a = 0;\n"
+   "FOO(b)\n"
+   "int c = 0;",
+   Style);
+  verifyFormat("int a = 0;\n"
+   "int x = FOO(a)\n"
+   "int b = 0;",
+   Style);
+  verifyFormat("void foo(int a) { FOO(a) }\n"
+   "uint32_t bar() {}",
+   Style);
 }
 
 TEST_F(FormatTest, LayoutMacroDefinitionsStatementsSpanningBlocks) {
@@ -10728,6 +10767,12 @@
   CHECK_PARSE("ForEachMacros: [BOOST_FOREACH, Q_FOREACH]", ForEachMacros,
   BoostAndQForeach);
 
+  Style.StatementMacros.clear();
+  CHECK_PARSE("StatementMacros: [QUNUSED]", StatementMacros,
+  std::vector{"QUNUSED"});
+  CHECK_PARSE("StatementMacros: [QUNUSED, QT_REQUIRE_VERSION]", StatementMacros,
+  std::vector({"QUNUSED", "QT_REQUIRE_VERSION"}));
+
   Style.IncludeStyle.IncludeCategories.clear();
   std::vector ExpectedCategories = {
   {"abc/.*", 2}, {".*", 1}};
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -125,6 +125,7 @@
   void parseObjCInterfaceOrImplementation();
   bool parseObjCProtocol();
   void parseJavaScriptEs6ImportExport();
+  void parseStatementMacro();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
   void tryToParseJSFunction();
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -473,6 +473,10 @@
   }
   LBraceStack.pop_back();
   break;
+case tok::identifier:
+  if (!Tok->is(TT_StatementMacro))
+  break;
+  LLVM_FALLTHROUGH;
 case tok::at:
 case tok::semi:
 case tok::kw_if:
@@ -1098,6 +1102,10 @@
 return;
   }
 }
+if (Style.isCpp() && FormatTok->is(TT_StatementMacro)) {
+  parseStatementMacro();
+  return;
+}
 // In all other cases, parse the declaration.
 break;
   default:
@@ -1297,6 +1305,11 @@
 return;
   }
 
+  if (Style.isCpp() && FormatTok->is(TT_StatementMacro)) {
+parseStatementMacro();
+return;
+  }
+
   // See if the following token should start a new unwrapped line.
   StringRef Text = FormatTok->TokenText;
   nextToken();
@@ -2295,6 +2308,16 @@
   }
 }
 
+void UnwrappedLineParser::parseStatementMacro()
+{
+  nextToken();
+  if (FormatTok->is(tok::l_paren))
+parseParens();
+  if (FormatTok->is(tok::semi))
+nextToken();
+  addUnwrappedLine();
+}
+
 LLVM_ATTRIBUTE_UNUSED static void printDebugInfo(const UnwrappedLine &Line,
  StringRef Prefix = "") {
   llvm::dbgs() << Prefix << "Line(" << Line.Level
Index: lib/Format/FormatTokenLexer.h
===
--- lib/Format/FormatTokenLexer.h
+++ lib/Format/FormatTokenLexer.h
@@ -22,6 +22,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Format/Format.h"
 #include "llvm/Support/Regex.h"
+#include "llvm/ADT/MapVector.h"
 
 #include 
 
@@ -99,7 +100,8 @@
   // Index (in 'Tokens') of the last token that starts a new line.
   unsigned FirstInLineIndex;
   SmallVector Tokens;
-  SmallVector ForEachMacros;
+
+  llvm::SmallMapVector Macros;
 
   bool FormattingDisabled;
 
Index: lib/Format/FormatTokenLexer.cpp

[PATCH] D33440: clang-format: better handle statement macros

2018-05-17 Thread Francois Ferrand via Phabricator via cfe-commits
Typz marked an inline comment as done.
Typz added inline comments.



Comment at: lib/Format/Format.cpp:647-648
   LLVMStyle.SortUsingDeclarations = true;
+  LLVMStyle.StatementMacros.push_back("Q_UNUSED");
+  LLVMStyle.StatementMacros.push_back("QT_REQUIRE_VERSION");
 

alexfh wrote:
> What's the reason to have these in the LLVM style? The macros aren't used in 
> LLVM code.
This is similar to the default foreach macros (foreach, Q_FOREACH and 
BOOST_FOREACH) : the macros are added here so that they are the default values 
for any style, since LLVM style is also both the default style and the base 
style for any style.



Repository:
  rC Clang

https://reviews.llvm.org/D33440



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


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

2018-05-17 Thread Mikhail Dvoretckii via Phabricator via cfe-commits
mike.dvoretsky updated this revision to Diff 147292.
mike.dvoretsky added a comment.

Removed the unused HasIBT variable declaration from X86.h.


https://reviews.llvm.org/D46881

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/attributes.c
  clang/test/CodeGen/builtins-x86.c
  clang/test/CodeGen/x86-cf-protection.c
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/x86_target_features.c
  clang/test/Sema/attr-nocf_check.c
  clang/test/Sema/attr-nocf_check.cpp

Index: clang/test/Sema/attr-nocf_check.cpp
===
--- clang/test/Sema/attr-nocf_check.cpp
+++ clang/test/Sema/attr-nocf_check.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple=i386-unknown-unknown -verify -fcf-protection=branch -target-feature +ibt -std=c++11 -fsyntax-only %s
+// RUN: %clang_cc1 -triple=i386-unknown-unknown -verify -fcf-protection=branch -std=c++11 -fsyntax-only %s
 
 // Function pointer definition.
 [[gnu::nocf_check]] typedef void (*FuncPointerWithNoCfCheck)(void); // no-warning
Index: clang/test/Sema/attr-nocf_check.c
===
--- clang/test/Sema/attr-nocf_check.c
+++ clang/test/Sema/attr-nocf_check.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -verify -fcf-protection=branch -target-feature +ibt -fsyntax-only %s
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -verify -fcf-protection=branch -fsyntax-only %s
 
 // Function pointer definition.
 typedef void (*FuncPointerWithNoCfCheck)(void) __attribute__((nocf_check)); // no-warning
Index: clang/test/Preprocessor/x86_target_features.c
===
--- clang/test/Preprocessor/x86_target_features.c
+++ clang/test/Preprocessor/x86_target_features.c
@@ -380,10 +380,6 @@
 
 // SHSTK: #define __SHSTK__ 1
 
-// RUN: %clang -target i386-unknown-unknown -mibt -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=IBT %s
-
-// IBT: #define __IBT__ 1
-
 // RUN: %clang -target i386-unknown-unknown -march=atom -mrdseed -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=RDSEED %s
 
 // RDSEED: #define __RDSEED__ 1
Index: clang/test/Driver/x86-target-features.c
===
--- clang/test/Driver/x86-target-features.c
+++ clang/test/Driver/x86-target-features.c
@@ -80,11 +80,6 @@
 // CETSS: "-target-feature" "+shstk"
 // NO-CETSS: "-target-feature" "-shstk"
 
-// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mibt %s -### -o %t.o 2>&1 | FileCheck -check-prefix=CETIBT %s
-// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-ibt %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-CETIBT %s
-// CETIBT: "-target-feature" "+ibt"
-// NO-CETIBT: "-target-feature" "-ibt"
-
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -msgx %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SGX %s
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-sgx %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-SGX %s
 // SGX: "-target-feature" "+sgx"
Index: clang/test/CodeGen/x86-cf-protection.c
===
--- clang/test/CodeGen/x86-cf-protection.c
+++ clang/test/CodeGen/x86-cf-protection.c
@@ -1,6 +1,8 @@
-// RUN: not %clang_cc1 -fsyntax-only -S -o %t -triple i386-unknown-unknown -fcf-protection=return %s 2>&1 | FileCheck %s --check-prefix=RETURN
-// RUN: not %clang_cc1 -fsyntax-only -S -o %t -triple i386-unknown-unknown -fcf-protection=branch %s 2>&1 | FileCheck %s --check-prefix=BRANCH
+// RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - -fcf-protection=return %s | FileCheck %s --check-prefix=RETURN
+// RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - -fcf-protection=branch %s | FileCheck %s --check-prefix=BRANCH
+// RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - -fcf-protection=full %s   | FileCheck %s --check-prefix=FULL
 
-// RETURN: error: option 'cf-protection=return' cannot be specified without '-mshstk'
-// BRANCH: error: option 'cf-protection=branch' cannot be specified without '-mibt'
+// RETURN: #define __CET__ 2
+// BRANCH: #define __CET__ 1
+// FULL: #define __CET__ 3
 void foo() {}
Index: clang/test/CodeGen/builtins-x86.c
===
--- clang/test/CodeGen/builtins-x86.c
+++ clang/test/CodeGen/builtins-x86.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -DUSE_64 -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -target-feature +clzero -target-fea

[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-05-17 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



Comment at: lib/CodeGen/CGException.cpp:1241-1245
+while (llvm::TerminatorInst *TI = RethrowBlock->getTerminator()) {
+  llvm::BranchInst *BI = cast(TI);
+  assert(BI->isConditional());
+  RethrowBlock = BI->getSuccessor(1);
+}

aheejin wrote:
> majnemer wrote:
> > This seems pretty fragile, why is this guaranteed to work? Could we 
> > maintain a map from CatchSwitchInst to catch-all block?
> The function call sequence here is `CodeGenFunction::ExitCXXTryStmt` -> 
> `emitCatchDispatchBlock` (static) -> `emitWasmCatchDispatchBlock` (static) 
> and `emitCatchDispatchBlock` also has other callers, so it is a little 
> cumbersome to pass a map to those functions to be filled in. (We have to make 
> a parameter that's only gonna be used for wasm to both 
> `emitCatchDispatchBlock` and `emitWasmCatchDispatchBlock`)
> 
> The other way is also change those static `emit` functions into 
> `CodeGenFunction` class's member functions and make the map as a member 
> variable.
> 
> But first, in which case do you think this will be fragile? 
> `emitWasmCatchDispatchBlock` follows the structure of the landingpad model, 
> so for a C++ code like this
> ```
> try {
>   ...
> } catch (int) {
>   ...
> } catch (float) {
>   ...
> }
> ```
> the BB structure that starts from wasm's `catch.start` block will look like
> ```
> catch.dispatch:   ; preds = %entry
>   %0 = catchswitch within none [label %catch.start] unwind to caller
> 
> catch.start:  ; preds = %catch.dispatch
>   %1 = catchpad within %0 [i8* bitcast (i8** @_ZTIi to i8*), i8* bitcast 
> (i8** @_ZTIf to i8*)]
>   %2 = call i8* @llvm.wasm.get.exception()
>   %3 = call i32 @llvm.wasm.get.ehselector()
>   %4 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2
>   %matches = icmp eq i32 %3, %4
>   br i1 %matches, label %catch12, label %catch.fallthrough
> 
> catch12:  ; preds = %catch.start
>   body of catch (int)
> 
> catch.fallthrough:; preds = %catch.start
>   %8 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIf to i8*)) #2
>   %matches1 = icmp eq i32 %3, %8
>   br i1 %matches1, label %catch, label %rethrow
> 
> catch:; preds = %catch.fallthrough
>   body of catch (float)
> 
> rethrow:  ; preds = %catch.fallthrough
>   call void @__cxa_rethrow() #5 [ "funclet"(token %1) ]
>   unreachable
> ```
> 
> So to me it looks like, no matter how the bodies of `catch (int)` or `catch 
> (float)` are complicated, there should always be blocks like `catch.start` 
> and `catch.fallthrough`, which compares typeids and divide control flow 
> depending on the typeid comparison. I could very well be mistaken, so please 
> let me know if so.
Oh and the `RethrowBlock` in the code is not the same as the `catch_all` 
block... cleanuppads will be `catch_all` blocks in wasm, and catchpads will be 
`catch `. That `RethrowBlock` belongs to `catch ` block, and is 
entered when the current exception caught is a C++ exception but does not match 
any of the catch clauses, so it can be rethrown to the enclosing scope.


Repository:
  rC Clang

https://reviews.llvm.org/D44931



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


[PATCH] D45177: CStringChecker, check strlcpy/strlcat

2018-05-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

This is reproducible in r332425.


Repository:
  rC Clang

https://reviews.llvm.org/D45177



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


[PATCH] D45177: CStringChecker, check strlcpy/strlcat

2018-05-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

This patch seems to cause an assertion failure:

assert.h assertion failed at clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:427 
in clang::ento::SVal 
clang::ento::SValBuilder::evalBinOp(clang::ento::ProgramStateRef, 
BinaryOperator::Opcode, clang::ento::SVal, clang::ento::SVal, clang::QualType): 
op == BO_Add

The stack trace is:
__assert_fail
clang::ento::SValBuilder::evalBinOp
clang::ento::SValBuilder::evalEQ
clang::ento::SValBuilder::evalEQ
::CStringChecker::assumeZero
::CStringChecker::checkNonNull
::CStringChecker::evalStrcpyCommon
::CStringChecker::evalStrcpy
::CStringChecker::evalCall
clang::ento::eval::Call::_evalCall
clang::ento::CheckerFn::operator()
clang::ento::CheckerManager::runCheckersForEvalCall
clang::ento::ExprEngine::evalCall
clang::ento::ExprEngine::VisitCallExpr
clang::ento::ExprEngine::Visit
clang::ento::ExprEngine::ProcessStmt
clang::ento::ExprEngine::processCFGElement
clang::ento::CoreEngine::HandlePostStmt
clang::ento::CoreEngine::dispatchWorkItem
clang::ento::CoreEngine::ExecuteWorkList
clang::ento::ExprEngine::ExecuteWorkList
::AnalysisConsumer::ActionExprEngine
::AnalysisConsumer::HandleCode
::AnalysisConsumer::HandleDeclsCallGraph
::AnalysisConsumer::runAnalysisOnTranslationUnit
::AnalysisConsumer::HandleTranslationUnit

I'm trying to reduce a test case.


Repository:
  rC Clang

https://reviews.llvm.org/D45177



___
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-17 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332593: CodeGen: Fix invalid bitcast for lifetime.start/end 
(authored by yaxunl, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45900?vs=146987&id=147289#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45900

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

Index: cfe/trunk/test/CodeGenCXX/amdgcn_declspec_get.cpp
===
--- cfe/trunk/test/CodeGenCXX/amdgcn_declspec_get.cpp
+++ cfe/trunk/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: cfe/trunk/lib/CodeGen/CGDecl.cpp
===
--- cfe/trunk/lib/CodeGen/CGDecl.cpp
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp
@@ -965,6 +965,9 @@
   if (!ShouldEmitLifetimeMarkers)
 return nullptr;
 
+  assert(Addr->getType()->getPointerAddressSpace() ==
+ CGM.getDataLayout().getAllocaAddrSpace() &&
+ "Pointer should be in alloca address space");
   llvm::Value *SizeV = llvm::ConstantInt::get(Int64Ty, Size);
   Addr = Builder.CreateBitCast(Addr, AllocaInt8PtrTy);
   llvm::CallInst *C =
@@ -974,6 +977,9 @@
 }
 
 void CodeGenFunction::EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr) {
+  assert(Addr->getType()->getPointerAddressSpace() ==
+ CGM.getDataLayout().getAllocaAddrSpace() &&
+ "Pointer should be in alloca address space");
   Addr = Builder.CreateBitCast(Addr, AllocaInt8PtrTy);
   llvm::CallInst *C =
   Builder.CreateCall(CGM.getLLVMLifetimeEndFn(), {Size, Addr});
@@ -1058,6 +1064,7 @@
  codegenoptions::LimitedDebugInfo;
 
   Address address = Address::invalid();
+  Address AllocaAddr = Address::invalid();
   if (Ty->isConstantSizeType()) {
 bool NRVO = getLangOpts().ElideConstructors &&
   D.isNRVOVariable();
@@ -1148,7 +1155,8 @@
   // Create the alloca.  Note that we set the name separately from
   // building the instruction so that it's there even in no-asserts
   // builds.
-  address = CreateTempAlloca(allocaTy, allocaAlignment, D.getName());
+  address = CreateTempAlloca(allocaTy, allocaAlignment, D.getName(),
+ /*ArraySize=*/nullptr, &AllocaAddr);
 
   // Don't emit lifetime markers for MSVC catch parameters. The lifetime of
   // the catch parameter starts in the catchpad instruction, and we can't
@@ -1176,7 +1184,7 @@
 !(!getLangOpts().CPlusPlus && hasLabelBeenSeenInCurrentScope())) {
   uint64_t size = CGM.getDataLayout().getTypeAllocSize(allocaTy);
   emission.SizeForLifetimeMarkers =
-  EmitLifetimeStart(size, address.getPointer());
+  EmitLifetimeStart(size, AllocaAddr.getPointer());
 }
   } else {
 assert(!emission.useLifetimeMarkers());
@@ -1205,7 +1213,8 @@
 llvm::Type *llvmTy = ConvertTypeForMem(VlaSize.Type);
 
 // Allocate memory for the array.
-address = CreateTempAlloca(llvmTy, alignment, "vla", VlaSize.NumElts);
+address = CreateTempAlloca(llvmTy, alignment, "vla", VlaSize.NumElts,
+   &AllocaAddr);
 
 // If we have debug info enabled, properly describe the VLA dimensions for
 // this type by registering the vla size expression for each of the
@@ -1215,6 +1224,7 @@
 
   setAddrOfLocalVar(&D, address);
   emission.Addr = address;
+  emission.AllocaAddr = AllocaAddr;
 
   // Emit debug info for local var declaration.
   if (EmitDebugInfo && HaveInsertPoint()) {
@@ -1228,7 +1238,7 @@
   // Make sure we call @llvm.lifetime.end.
   if (emission.useLifetimeMarkers())
 EHStack.pushCleanup(NormalEHLifetimeMarker,
- emission.getAllocatedAddress(),
+   

r332593 - CodeGen: Fix invalid bitcast for lifetime.start/end

2018-05-17 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Thu May 17 04:16:35 2018
New Revision: 332593

URL: http://llvm.org/viewvc/llvm-project?rev=332593&view=rev
Log:
CodeGen: Fix invalid bitcast for lifetime.start/end

lifetime.start/end expects pointer argument in alloca address space.
However in C++ a temporary variable is in default address space.

This patch changes API CreateMemTemp and CreateTempAlloca to
get the original alloca instruction and pass it lifetime.start/end.

It only affects targets with non-zero alloca address space.

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

Added:
cfe/trunk/test/CodeGenCXX/amdgcn_declspec_get.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=332593&r1=332592&r2=332593&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu May 17 04:16:35 2018
@@ -3812,16 +3812,17 @@ RValue CodeGenFunction::EmitCall(const C
   // If the call returns a temporary with struct return, create a temporary
   // alloca to hold the result, unless one is given to us.
   Address SRetPtr = Address::invalid();
+  Address SRetAlloca = Address::invalid();
   llvm::Value *UnusedReturnSizePtr = nullptr;
   if (RetAI.isIndirect() || RetAI.isInAlloca() || RetAI.isCoerceAndExpand()) {
 if (!ReturnValue.isNull()) {
   SRetPtr = ReturnValue.getValue();
 } else {
-  SRetPtr = CreateMemTemp(RetTy);
+  SRetPtr = CreateMemTemp(RetTy, "tmp", &SRetAlloca);
   if (HaveInsertPoint() && ReturnValue.isUnused()) {
 uint64_t size =
 CGM.getDataLayout().getTypeAllocSize(ConvertTypeForMem(RetTy));
-UnusedReturnSizePtr = EmitLifetimeStart(size, SRetPtr.getPointer());
+UnusedReturnSizePtr = EmitLifetimeStart(size, SRetAlloca.getPointer());
   }
 }
 if (IRFunctionArgs.hasSRetArg()) {
@@ -3888,7 +3889,8 @@ RValue CodeGenFunction::EmitCall(const C
   if (!I->isAggregate()) {
 // Make a temporary alloca to pass the argument.
 Address Addr = CreateMemTemp(I->Ty, ArgInfo.getIndirectAlign(),
- "indirect-arg-temp", false);
+ "indirect-arg-temp", /*Alloca=*/nullptr,
+ /*Cast=*/false);
 IRCallArgs[FirstIRArg] = Addr.getPointer();
 
 I->copyInto(*this, Addr);
@@ -3934,7 +3936,8 @@ RValue CodeGenFunction::EmitCall(const C
 if (NeedCopy) {
   // Create an aligned temporary, and copy to it.
   Address AI = CreateMemTemp(I->Ty, ArgInfo.getIndirectAlign(),
- "byval-temp", false);
+ "byval-temp", /*Alloca=*/nullptr,
+ /*Cast=*/false);
   IRCallArgs[FirstIRArg] = AI.getPointer();
   I->copyInto(*this, AI);
 } else {
@@ -4062,6 +4065,7 @@ RValue CodeGenFunction::EmitCall(const C
 
   llvm::Value *tempSize = nullptr;
   Address addr = Address::invalid();
+  Address AllocaAddr = Address::invalid();
   if (I->isAggregate()) {
 addr = I->hasLValue() ? I->getKnownLValue().getAddress()
   : I->getKnownRValue().getAggregateAddress();
@@ -4076,9 +4080,11 @@ RValue CodeGenFunction::EmitCall(const C
 
 // Materialize to a temporary.
 addr = CreateTempAlloca(RV.getScalarVal()->getType(),
- CharUnits::fromQuantity(std::max(layout->getAlignment(),
-  scalarAlign)));
-tempSize = EmitLifetimeStart(scalarSize, addr.getPointer());
+CharUnits::fromQuantity(std::max(
+layout->getAlignment(), scalarAlign)),
+"tmp",
+/*ArraySize=*/nullptr, &AllocaAddr);
+tempSize = EmitLifetimeStart(scalarSize, AllocaAddr.getPointer());
 
 Builder.CreateStore(RV.getScalarVal(), addr);
   }
@@ -4096,7 +4102,7 @@ RValue CodeGenFunction::EmitCall(const C
   assert(IRArgPos == FirstIRArg + NumIRArgs);
 
   if (tempSize) {
-EmitLifetimeEnd(tempSize, addr.getPointer());
+EmitLifetimeEnd(tempSize, AllocaAddr.getPointer());
   }
 
   break;
@@ -4258,7 +4264,7 @@ RValue CodeGenFunction::EmitCall(const C
   // pop this cleanup later on. Being eager about this is OK, since this
   // temporary is 'invisible' outside of the callee.
   if (UnusedReturnSizePtr)
-pushFullExprCleanup(NormalEHLifetimeMarker, SRetPtr,
+pushFullExprCleanup(NormalEHLifetimeMarker, SRetAlloca,
  Unuse

[PATCH] D46943: [clangd] Boost scores for decls from current file in completion

2018-05-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/Quality.cpp:24
+  if (SemaCCResult.Declaration)
+AllDeclsInMainFile = allDeclsInMainFile(SemaCCResult.Declaration);
   if (SemaCCResult.Availability == CXAvailability_Deprecated)

sammccall wrote:
> ioeric wrote:
> > Could you explain why `AllDeclsInMainFile` is necessary? I think it might 
> > still be fine to boost score for symbols with a declaration in the main 
> > file even if it has redecls in other files (e.g. function fwd in headers).
> Agree. I think the better signal is (any) decl in main file.
My intuition was that it does not make any sense to functions if there 
definitions are in the same cpp file, because it does not give any useful 
signals on whether those should be preferably called in the same file.
Also, some defs may not be visible to the compiler at the point of completion 
and, therefore, won't get a boost, even if they are in the same file. This is 
inconsistent.

E.g., 

```
// === foo.h
class Foo {
  int foo();
  int bar();
  int baz();
  int test();
};

int glob_foo();
int glob_bar();
int glob_baz();

// === foo.cpp
#include "foo.h"
static some_local_func() {}

Foo::foo() {
};

int ::glob_foo() {
}

Foo::test() {
   ^
   // out of all functions declared in headers, only foo and global_foo will 
get a boost here. That does not make much sense, since:
   // - glob_bar() and Foo::bar() are also declared in the same file, but 
compiler hasn't seen them yet, so they won't get a boost.
   // - glob_baz() and Foo::baz() are not declared in the same file, but they 
are so close to `bar` in the header, 
   //   and it doesn't seem to make sense to rank them differently.
}

Foo::bar() {
}

int ::glob_bar() {
}
```

Why upranking decls **only** in the current file is still useful?
 - Those are usually helpers that are very relevant to the file. Especially 
true for small files.
 - As a side-effect, we'll uprank local vars and parameters (they can't have 
decls in other files :-)), that seems useful. Maybe such implicit effects are 
not desirable, though.

I should've definitely documented this better. If we decide this change is 
useful, I'll add more docs.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46943



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


[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-05-17 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added a comment.

Thank you for the reviews!




Comment at: lib/CodeGen/CGException.cpp:1173
+cast(CatchStartBlock->getFirstNonPHI());
+CurrentFuncletPad = CPI;
+  }

majnemer wrote:
> Hmm, why is this done? Won't RestoreCurrentFuncletPad undo this?
Isn't `RestoreCurrentFuncletPad` outside of `if 
(EHPersonality::get(*this).isWasmPersonality())`? Isn't this supposed to stay 
until this function finishes?



Comment at: lib/CodeGen/CGException.cpp:1241-1245
+while (llvm::TerminatorInst *TI = RethrowBlock->getTerminator()) {
+  llvm::BranchInst *BI = cast(TI);
+  assert(BI->isConditional());
+  RethrowBlock = BI->getSuccessor(1);
+}

majnemer wrote:
> This seems pretty fragile, why is this guaranteed to work? Could we maintain 
> a map from CatchSwitchInst to catch-all block?
The function call sequence here is `CodeGenFunction::ExitCXXTryStmt` -> 
`emitCatchDispatchBlock` (static) -> `emitWasmCatchDispatchBlock` (static) and 
`emitCatchDispatchBlock` also has other callers, so it is a little cumbersome 
to pass a map to those functions to be filled in. (We have to make a parameter 
that's only gonna be used for wasm to both `emitCatchDispatchBlock` and 
`emitWasmCatchDispatchBlock`)

The other way is also change those static `emit` functions into 
`CodeGenFunction` class's member functions and make the map as a member 
variable.

But first, in which case do you think this will be fragile? 
`emitWasmCatchDispatchBlock` follows the structure of the landingpad model, so 
for a C++ code like this
```
try {
  ...
} catch (int) {
  ...
} catch (float) {
  ...
}
```
the BB structure that starts from wasm's `catch.start` block will look like
```
catch.dispatch:   ; preds = %entry
  %0 = catchswitch within none [label %catch.start] unwind to caller

catch.start:  ; preds = %catch.dispatch
  %1 = catchpad within %0 [i8* bitcast (i8** @_ZTIi to i8*), i8* bitcast (i8** 
@_ZTIf to i8*)]
  %2 = call i8* @llvm.wasm.get.exception()
  %3 = call i32 @llvm.wasm.get.ehselector()
  %4 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2
  %matches = icmp eq i32 %3, %4
  br i1 %matches, label %catch12, label %catch.fallthrough

catch12:  ; preds = %catch.start
  body of catch (int)

catch.fallthrough:; preds = %catch.start
  %8 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIf to i8*)) #2
  %matches1 = icmp eq i32 %3, %8
  br i1 %matches1, label %catch, label %rethrow

catch:; preds = %catch.fallthrough
  body of catch (float)

rethrow:  ; preds = %catch.fallthrough
  call void @__cxa_rethrow() #5 [ "funclet"(token %1) ]
  unreachable
```

So to me it looks like, no matter how the bodies of `catch (int)` or `catch 
(float)` are complicated, there should always be blocks like `catch.start` and 
`catch.fallthrough`, which compares typeids and divide control flow depending 
on the typeid comparison. I could very well be mistaken, so please let me know 
if so.


Repository:
  rC Clang

https://reviews.llvm.org/D44931



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


[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-05-17 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin updated this revision to Diff 147287.
aheejin marked an inline comment as done.
aheejin added a comment.

`CatchStartBlock` -> `WasmCatchStartBlock`


Repository:
  rC Clang

https://reviews.llvm.org/D44931

Files:
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGCleanup.h
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/wasm-eh.cpp

Index: test/CodeGenCXX/wasm-eh.cpp
===
--- /dev/null
+++ test/CodeGenCXX/wasm-eh.cpp
@@ -0,0 +1,392 @@
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+
+void may_throw();
+void dont_throw() noexcept;
+
+struct Cleanup {
+  ~Cleanup() { dont_throw(); }
+};
+
+// Multiple catch clauses w/o catch-all
+void test0() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (double) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: define void @_Z5test0v() {{.*}} personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*)
+
+// CHECK:   %[[INT_ALLOCA:.*]] = alloca i32
+// CHECK:   invoke void @_Z9may_throwv()
+// CHECK-NEXT:   to label %[[NORMAL_BB:.*]] unwind label %[[CATCHDISPATCH_BB:.*]]
+
+// CHECK: [[CATCHDISPATCH_BB]]:
+// CHECK-NEXT:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* bitcast (i8** @_ZTId to i8*)]
+// CHECK-NEXT:   %[[EXN:.*]] = call i8* @llvm.wasm.get.exception()
+// CHECK-NEXT:   store i8* %[[EXN]], i8** %exn.slot
+// CHECK-NEXT:   %[[SELECTOR:.*]] = call i32 @llvm.wasm.get.ehselector()
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_INT_BB:.*]], label %[[CATCH_FALLTHROUGH_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK-NEXT:   %[[EXN:.*]] = load i8*, i8** %exn.slot
+// CHECK-NEXT:   %[[ADDR:.*]] = call i8* @__cxa_begin_catch(i8* %[[EXN]]) {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   %[[ADDR_CAST:.*]] = bitcast i8* %[[ADDR]] to i32*
+// CHECK-NEXT:   %[[INT_VAL:.*]] = load i32, i32* %[[ADDR_CAST]]
+// CHECK-NEXT:   store i32 %[[INT_VAL]], i32* %[[INT_ALLOCA]]
+// CHECK-NEXT:   call void @_Z10dont_throwv() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   call void @__cxa_end_catch() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB0:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB0]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB:.*]]
+
+// CHECK: [[CATCH_FALLTHROUGH_BB]]
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTId to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_FLOAT_BB:.*]], label %[[RETHROW_BB:.*]]
+
+// CHECK: [[CATCH_FLOAT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB1:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB1]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB]]
+
+// CHECK: [[RETHROW_BB]]:
+// CHECK-NEXT:   call void @__cxa_rethrow() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   unreachable
+
+
+// Single catch-all
+void test1() {
+  try {
+may_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CATCH-LABEL: @_Z5test1v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* null]
+// CHECK:   br label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+
+// Multiple catch clauses w/ catch-all
+void test2() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: @_Z5test2v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* null]
+// CHECK:   br i1 %{{.*}}, label %[[CATCH_INT_BB:.*]], label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+
+// Cleanup
+void test3() {
+  Cleanup c;
+  may_throw();
+}
+
+// CHECK-LABEL: @_Z5test3v()
+
+// CHECK:   invoke void @_Z9may_throw

[PATCH] D46942: Add vfs::FileSystem::getRealPath

2018-05-17 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332590: Add vfs::FileSystem::getRealPath (authored by 
ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D46942

Files:
  cfe/trunk/include/clang/Basic/VirtualFileSystem.h
  cfe/trunk/lib/Basic/FileManager.cpp
  cfe/trunk/lib/Basic/VirtualFileSystem.cpp


Index: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
===
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp
@@ -139,6 +139,11 @@
   return llvm::sys::fs::make_absolute(WorkingDir.get(), Path);
 }
 
+std::error_code FileSystem::getRealPath(const Twine &Path,
+SmallVectorImpl &Output) const {
+  return errc::operation_not_permitted;
+}
+
 bool FileSystem::exists(const Twine &Path) {
   auto Status = status(Path);
   return Status && Status->exists();
@@ -236,6 +241,8 @@
 
   llvm::ErrorOr getCurrentWorkingDirectory() const override;
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override;
 };
 
 } // namespace
@@ -274,6 +281,12 @@
   return llvm::sys::fs::set_current_path(Path);
 }
 
+std::error_code
+RealFileSystem::getRealPath(const Twine &Path,
+SmallVectorImpl &Output) const {
+  return llvm::sys::fs::real_path(Path, Output);
+}
+
 IntrusiveRefCntPtr vfs::getRealFileSystem() {
   static IntrusiveRefCntPtr FS = new RealFileSystem();
   return FS;
Index: cfe/trunk/lib/Basic/FileManager.cpp
===
--- cfe/trunk/lib/Basic/FileManager.cpp
+++ cfe/trunk/lib/Basic/FileManager.cpp
@@ -534,23 +534,9 @@
 
   StringRef CanonicalName(Dir->getName());
 
-#ifdef LLVM_ON_UNIX
-  char CanonicalNameBuf[PATH_MAX];
-  if (realpath(Dir->getName().str().c_str(), CanonicalNameBuf))
+  SmallString<4096> CanonicalNameBuf;
+  if (!FS->getRealPath(Dir->getName(), CanonicalNameBuf))
 CanonicalName = StringRef(CanonicalNameBuf).copy(CanonicalNameStorage);
-#else
-  SmallString<256> CanonicalNameBuf(CanonicalName);
-  llvm::sys::fs::make_absolute(CanonicalNameBuf);
-  llvm::sys::path::native(CanonicalNameBuf);
-  // We've run into needing to remove '..' here in the wild though, so
-  // remove it.
-  // On Windows, symlinks are significantly less prevalent, so removing
-  // '..' is pretty safe.
-  // Ideally we'd have an equivalent of `realpath` and could implement
-  // sys::fs::canonical across all the platforms.
-  llvm::sys::path::remove_dots(CanonicalNameBuf, /* remove_dot_dot */ true);
-  CanonicalName = StringRef(CanonicalNameBuf).copy(CanonicalNameStorage);
-#endif
 
   CanonicalDirNames.insert(std::make_pair(Dir, CanonicalName));
   return CanonicalName;
Index: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
===
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h
@@ -248,6 +248,12 @@
   /// Get the working directory of this file system.
   virtual llvm::ErrorOr getCurrentWorkingDirectory() const = 0;
 
+  /// Gets real path of \p Path e.g. collapse all . and .. patterns, resolve
+  /// symlinks. For real file system, this uses `llvm::sys::fs::real_path`.
+  /// This returns errc::operation_not_permitted if not implemented by 
subclass.
+  virtual std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const;
+
   /// Check whether a file exists. Provided for convenience.
   bool exists(const Twine &Path);
 


Index: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
===
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp
@@ -139,6 +139,11 @@
   return llvm::sys::fs::make_absolute(WorkingDir.get(), Path);
 }
 
+std::error_code FileSystem::getRealPath(const Twine &Path,
+SmallVectorImpl &Output) const {
+  return errc::operation_not_permitted;
+}
+
 bool FileSystem::exists(const Twine &Path) {
   auto Status = status(Path);
   return Status && Status->exists();
@@ -236,6 +241,8 @@
 
   llvm::ErrorOr getCurrentWorkingDirectory() const override;
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override;
 };
 
 } // namespace
@@ -274,6 +281,12 @@
   return llvm::sys::fs::set_current_path(Path);
 }
 
+std::error_code
+RealFileSystem::getRealPath(const Twine &Path,
+SmallVectorImpl &Output) const {
+  return llvm::sys::fs::real_path(Path, Output);
+}
+
 IntrusiveRefCntPtr vfs::getRealFileS

r332590 - Add vfs::FileSystem::getRealPath

2018-05-17 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu May 17 03:26:23 2018
New Revision: 332590

URL: http://llvm.org/viewvc/llvm-project?rev=332590&view=rev
Log:
Add vfs::FileSystem::getRealPath

Summary: And change `FileManager::getCanonicalName` to use getRealPath.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/lib/Basic/VirtualFileSystem.cpp

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=332590&r1=332589&r2=332590&view=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Thu May 17 03:26:23 2018
@@ -248,6 +248,12 @@ public:
   /// Get the working directory of this file system.
   virtual llvm::ErrorOr getCurrentWorkingDirectory() const = 0;
 
+  /// Gets real path of \p Path e.g. collapse all . and .. patterns, resolve
+  /// symlinks. For real file system, this uses `llvm::sys::fs::real_path`.
+  /// This returns errc::operation_not_permitted if not implemented by 
subclass.
+  virtual std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const;
+
   /// Check whether a file exists. Provided for convenience.
   bool exists(const Twine &Path);
 

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=332590&r1=332589&r2=332590&view=diff
==
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Thu May 17 03:26:23 2018
@@ -534,23 +534,9 @@ StringRef FileManager::getCanonicalName(
 
   StringRef CanonicalName(Dir->getName());
 
-#ifdef LLVM_ON_UNIX
-  char CanonicalNameBuf[PATH_MAX];
-  if (realpath(Dir->getName().str().c_str(), CanonicalNameBuf))
+  SmallString<4096> CanonicalNameBuf;
+  if (!FS->getRealPath(Dir->getName(), CanonicalNameBuf))
 CanonicalName = StringRef(CanonicalNameBuf).copy(CanonicalNameStorage);
-#else
-  SmallString<256> CanonicalNameBuf(CanonicalName);
-  llvm::sys::fs::make_absolute(CanonicalNameBuf);
-  llvm::sys::path::native(CanonicalNameBuf);
-  // We've run into needing to remove '..' here in the wild though, so
-  // remove it.
-  // On Windows, symlinks are significantly less prevalent, so removing
-  // '..' is pretty safe.
-  // Ideally we'd have an equivalent of `realpath` and could implement
-  // sys::fs::canonical across all the platforms.
-  llvm::sys::path::remove_dots(CanonicalNameBuf, /* remove_dot_dot */ true);
-  CanonicalName = StringRef(CanonicalNameBuf).copy(CanonicalNameStorage);
-#endif
 
   CanonicalDirNames.insert(std::make_pair(Dir, CanonicalName));
   return CanonicalName;

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=332590&r1=332589&r2=332590&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Thu May 17 03:26:23 2018
@@ -139,6 +139,11 @@ std::error_code FileSystem::makeAbsolute
   return llvm::sys::fs::make_absolute(WorkingDir.get(), Path);
 }
 
+std::error_code FileSystem::getRealPath(const Twine &Path,
+SmallVectorImpl &Output) const {
+  return errc::operation_not_permitted;
+}
+
 bool FileSystem::exists(const Twine &Path) {
   auto Status = status(Path);
   return Status && Status->exists();
@@ -236,6 +241,8 @@ public:
 
   llvm::ErrorOr getCurrentWorkingDirectory() const override;
   std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override;
 };
 
 } // namespace
@@ -274,6 +281,12 @@ std::error_code RealFileSystem::setCurre
   return llvm::sys::fs::set_current_path(Path);
 }
 
+std::error_code
+RealFileSystem::getRealPath(const Twine &Path,
+SmallVectorImpl &Output) const {
+  return llvm::sys::fs::real_path(Path, Output);
+}
+
 IntrusiveRefCntPtr vfs::getRealFileSystem() {
   static IntrusiveRefCntPtr FS = new RealFileSystem();
   return FS;


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


[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags

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

I wonder if it would be safer to change this patch so it adds -mrelax and 
-mno-relax but doesn't compile with linker relaxation by default. That makes it 
easier to test linker relaxation support, and gives more time for testing 
before then flipping to -mrelax as the default.




Comment at: test/Driver/riscv-features.c:8
+// RUN: %clang -target riscv32-unknown-elf -### %s -mno-relax 2>&1 | FileCheck 
%s -check-prefix=NO-RELAX
+
+// RELAX: "-target-feature" "+relax"

We need a another RUN line and CHECK here to determine the default whether 
+relax is passed or not when the user specifies neither -mrelax or -mno-relax.


Repository:
  rL LLVM

https://reviews.llvm.org/D44888



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


[PATCH] D43424: [clang-doc] Implement a (simple) Markdown generator

2018-05-17 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clang-doc/generators/Generators.h:44
 
+class MDGenerator : public Generator {
+public:

Could you add high-level comment on what this does? This seems to build up some 
directory structure and write different infos into different sub-directories. 
Could you elaborate a bit on this?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43424



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


  1   2   >