[PATCH] D61220: lib/Header: Fix Visual Studio builds try #2

2019-04-26 Thread Tom Stellard via Phabricator via cfe-commits
tstellar created this revision.
tstellar added reviewers: smeenai, vzakhari, phosek.
Herald added a subscriber: mgorny.
Herald added a project: clang.

This is a follow up to r355253 and a better fix than the first attempt
which was r359257.

We can't install anything from ${CMAKE_CFG_INTDIR}, because this value
is only defined at build time, but we still must make sure to copy the
headers into ${CMAKE_CFG_INTDIR}/lib/clang/$VERSION/include, because the lit
tests look for headers there.  So for this fix we revert to the
old behavior of copying the headers to 
${CMAKE_CFG_INTDIR}/lib/clang/$VERSION/include
during the build and then installing them from the source tree.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61220

Files:
  clang/lib/Headers/CMakeLists.txt


Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -128,6 +128,7 @@
 
 set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
 set(out_files)
+set(install_files)
 
 function(copy_header_to_output_dir src_dir file)
   set(src ${src_dir}/${file})
@@ -138,6 +139,8 @@
 COMMENT "Copying clang's ${file}...")
   list(APPEND out_files ${dst})
   set(out_files ${out_files} PARENT_SCOPE)
+  list(APPEND install_files ${src})
+  set(install_files ${install_files} PARENT_SCOPE)
 endfunction(copy_header_to_output_dir)
 
 function(clang_generate_header td_option td_file out_file)
@@ -147,6 +150,7 @@
 
   copy_header_to_output_dir(${CMAKE_CURRENT_BINARY_DIR} ${out_file})
   set(out_files ${out_files} PARENT_SCOPE)
+  set(install_files ${install_files} PARENT_SCOPE)
 endfunction(clang_generate_header)
 
 
@@ -169,7 +173,7 @@
 set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})
 
 install(
-  DIRECTORY ${output_dir}
+  FILES ${install_files}
   DESTINATION ${header_install_dir}
   COMPONENT clang-resource-headers)
 


Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -128,6 +128,7 @@
 
 set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
 set(out_files)
+set(install_files)
 
 function(copy_header_to_output_dir src_dir file)
   set(src ${src_dir}/${file})
@@ -138,6 +139,8 @@
 COMMENT "Copying clang's ${file}...")
   list(APPEND out_files ${dst})
   set(out_files ${out_files} PARENT_SCOPE)
+  list(APPEND install_files ${src})
+  set(install_files ${install_files} PARENT_SCOPE)
 endfunction(copy_header_to_output_dir)
 
 function(clang_generate_header td_option td_file out_file)
@@ -147,6 +150,7 @@
 
   copy_header_to_output_dir(${CMAKE_CURRENT_BINARY_DIR} ${out_file})
   set(out_files ${out_files} PARENT_SCOPE)
+  set(install_files ${install_files} PARENT_SCOPE)
 endfunction(clang_generate_header)
 
 
@@ -169,7 +173,7 @@
 set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})
 
 install(
-  DIRECTORY ${output_dir}
+  FILES ${install_files}
   DESTINATION ${header_install_dir}
   COMPONENT clang-resource-headers)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60763: Prototype OpenCL BIFs using Tablegen

2019-04-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added a comment.

In D60763#1478672 , @Pierre wrote:

> I also think we could reduce the size of the tables.
>  To sum up how this is working right now:
>
> 1. The isOpenCLBuiltin(char* functionName) funcion is called to determine if 
> a function is part of OpenCL builtin functions. If so, it returns its 
> associated pair (index, number of signatures) in the OpenCLBuiltinDecl, 
> otherwise it returns 0.
> 2. The OpenCLBuiltinDecl table is storing, for each OpenCL builtin function, 
> the list of the possible signature associated for this function (e.g. cos can 
> be "float cos(float)", "double cos(double)", ...). The available signatures 
> are stored in the OpenCLSignature table. In the OpenCLBuiltinDecl are stored 
> the indexes corresponding to the possible signature for each function.
> 3. The OpenCLSignature is storing the possible signatures.
>
> E.g.: For the prototype float cos(float):
>
> 1. isOpenCLBuiltin("cos") is returning the pair (345, 18)
> 2. OpenCLBuiltinDecl[345] to  OpenCLBuiltinDecl[345+18] are the available 
> signatures of the builtin function "cos". Let say OpenCLBuiltinDecl[346] is 
> containing our "float cos(float)" prototype.  OpenCLBuiltinDecl[346] is 
> containing the pair (123, 2), indexing the OpenCLSignature table and how many 
> entries we have to read.
> 3. OpenCLSignature[123] is storing the return type of the function, so the 
> "float" type. OpenCLSignature[124] is containing the type of the first 
> argument, so the float type again. We are not looking further in the table 
> because we are only looking for 2 types.
>
>   
> ---
>
>   In the "float cos(float)" prototype, the information about the "float" type 
> is duplicated. Plus, this "float" type is also the same as in the "float 
> sin(float)" function. A third table, storing the different types, would 
> discard duplicated definitions of types. The OpenCLSignature would store 
> indexes of the required types, and the third table the type itself. This 
> third table would be called OpenCLTypes, and would be as:
>
>   ``` struct OpenCLTypes { // A type (e.g.: float, int, ...) OpenCLTypeID ID; 
> // Size of the vector (if applicable) unsigned VectorWidth; // 0 if the type 
> is not a pointer unsigned isPointer; // Address space of the pointer (if 
> applicable) clang::LangAS AS; } ``` and OpenCLSignature:
>
>   ``` struct OpenCLSignature { unsigned OpenCLTypesIndex } ``` 
> ---
>  Another way to save space would be to group functions. The "sin" and "cos" 
> functions are similar (identical, we could say), regarding their use/ 
> signature. However, they have two distinct lists of signatures in the 
> OpenCLBuiltinDecl table. The consequence would be that isOpenCLBuiltin("cos") 
> and isOpenCLBuiltin("sin") would give the same output. Such group of 
> functions could be created manually by adding an attribute in the 
> OpenCLBuiltins.td file, or automatically generated in the 
> ClangOpenCLBuiltinEmitter.cpp file. The first solution would however make the 
> feature potentially less understandable/ more complex to add new functions. 
> The second solution is complex to implement/ could require a lot of time to 
> process.


I think it would be a good idea to investigate explore the solution you are 
proposing, but I suggest to do it once we add more functionality so we can 
benchmark a bit more.

Btw, can you upload a full diff next time please.




Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:11
+//
+//  The file is organized as:
+//-Base definitions: base classes/ definitions required in sections below

I would rather use the header comment to just describe what the purpose and 
overall functionality of this file is at a high level. There is a danger of 
structures to get outdated quite quickly. 



Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:48
+// 4 :: opencl_generic
+// (Following address spaces are not available for OpenCL)
+// 5 :: cuda_device

I think we don't have to say what ASes are not supported, they will evolve and 
this will become outdated anyway.



Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:63
+
+// Qualified Type. Allow to retrieve one ASTContext Qualtype.
+class QualType {

Qualtype -> QualType



Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:65
+class QualType {
+  // How to get the QualType. Can be one of ("field", "func")
+  string AccessMethod = _AccessMethod;

I don't think "field" and "func" are clear at this point.



Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:99
+  int HasSat = 0;
+  // Function arguments can have ab access 

r359367 - Reinstate r359059, reverted in r359361, with a fix to properly prevent

2019-04-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Apr 26 19:58:17 2019
New Revision: 359367

URL: http://llvm.org/viewvc/llvm-project?rev=359367=rev
Log:
Reinstate r359059, reverted in r359361, with a fix to properly prevent
us emitting the operand of __builtin_constant_p if it has side-effects.

Original commit message:

Fix interactions between __builtin_constant_p and constexpr to match
current trunk GCC.

GCC permits information from outside the operand of
__builtin_constant_p (but in the same constant evaluation context) to be
used within that operand; clang now does so too. A few other minor
deviations from GCC's behavior showed up in my testing and are also
fixed (matching GCC):
  * Clang now supports nullptr_t as the argument type for
__builtin_constant_p
* Clang now returns true from __builtin_constant_p if called with a
null pointer
* Clang now returns true from __builtin_constant_p if called with an
integer cast to pointer type

Added:
cfe/trunk/test/SemaCXX/builtin-constant-p.cpp
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/builtin-constant-p.c
cfe/trunk/test/SemaCXX/enable_if.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=359367=359366=359367=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Apr 26 19:58:17 2019
@@ -7801,19 +7801,33 @@ EvaluateBuiltinClassifyType(const CallEx
 }
 
 /// EvaluateBuiltinConstantPForLValue - Determine the result of
-/// __builtin_constant_p when applied to the given lvalue.
+/// __builtin_constant_p when applied to the given pointer.
 ///
-/// An lvalue is only "constant" if it is a pointer or reference to the first
-/// character of a string literal.
-template
-static bool EvaluateBuiltinConstantPForLValue(const LValue ) {
-  const Expr *E = LV.getLValueBase().template dyn_cast();
-  return E && isa(E) && LV.getLValueOffset().isZero();
+/// A pointer is only "constant" if it is null (or a pointer cast to integer)
+/// or it points to the first character of a string literal.
+static bool EvaluateBuiltinConstantPForLValue(const APValue ) {
+  APValue::LValueBase Base = LV.getLValueBase();
+  if (Base.isNull()) {
+// A null base is acceptable.
+return true;
+  } else if (const Expr *E = Base.dyn_cast()) {
+if (!isa(E))
+  return false;
+return LV.getLValueOffset().isZero();
+  } else {
+// Any other base is not constant enough for GCC.
+return false;
+  }
 }
 
 /// EvaluateBuiltinConstantP - Evaluate __builtin_constant_p as similarly to
 /// GCC as we can manage.
-static bool EvaluateBuiltinConstantP(ASTContext , const Expr *Arg) {
+static bool EvaluateBuiltinConstantP(EvalInfo , const Expr *Arg) {
+  // Constant-folding is always enabled for the operand of __builtin_constant_p
+  // (even when the enclosing evaluation context otherwise requires a strict
+  // language-specific constant expression).
+  FoldConstant Fold(Info, true);
+
   QualType ArgType = Arg->getType();
 
   // __builtin_constant_p always has one operand. The rules which gcc follows
@@ -7821,34 +7835,30 @@ static bool EvaluateBuiltinConstantP(AST
   //
   //  - If the operand is of integral, floating, complex or enumeration type,
   //and can be folded to a known value of that type, it returns 1.
-  //  - If the operand and can be folded to a pointer to the first character
-  //of a string literal (or such a pointer cast to an integral type), it
-  //returns 1.
+  //  - If the operand can be folded to a pointer to the first character
+  //of a string literal (or such a pointer cast to an integral type)
+  //or to a null pointer or an integer cast to a pointer, it returns 1.
   //
   // Otherwise, it returns 0.
   //
   // FIXME: GCC also intends to return 1 for literals of aggregate types, but
-  // its support for this does not currently work.
-  if (ArgType->isIntegralOrEnumerationType()) {
-Expr::EvalResult Result;
-if (!Arg->EvaluateAsRValue(Result, Ctx) || Result.HasSideEffects)
+  // its support for this did not work prior to GCC 9 and is not yet well
+  // understood.
+  if (ArgType->isIntegralOrEnumerationType() || ArgType->isFloatingType() ||
+  ArgType->isAnyComplexType() || ArgType->isPointerType() ||
+  ArgType->isNullPtrType()) {
+APValue V;
+if (!::EvaluateAsRValue(Info, Arg, V)) {
+  Fold.keepDiagnostics();
   return false;
+}
 
-APValue  = Result.Val;
-if (V.getKind() == APValue::Int)
-  return true;
+// For a pointer (possibly cast to integer), there are special rules.
 if (V.getKind() == APValue::LValue)
   return EvaluateBuiltinConstantPForLValue(V);
-  } else if (ArgType->isFloatingType() || ArgType->isAnyComplexType()) {
-return 

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-04-26 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 196945.
gtbercea marked 2 inline comments as done.
gtbercea added a comment.

- Add tests.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60568/new/

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp
  test/OpenMP/target_codegen.cpp
  test/OpenMP/target_codegen_registration.cpp
  test/OpenMP/target_depend_codegen.cpp
  test/OpenMP/target_parallel_codegen.cpp
  test/OpenMP/target_parallel_codegen_registration.cpp
  test/OpenMP/target_parallel_depend_codegen.cpp
  test/OpenMP/target_parallel_for_codegen.cpp
  test/OpenMP/target_parallel_for_codegen_registration.cpp
  test/OpenMP/target_parallel_for_depend_codegen.cpp
  test/OpenMP/target_parallel_for_simd_codegen.cpp
  test/OpenMP/target_parallel_for_simd_codegen_registration.cpp
  test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  test/OpenMP/target_parallel_if_codegen.cpp
  test/OpenMP/target_parallel_num_threads_codegen.cpp
  test/OpenMP/target_simd_codegen.cpp
  test/OpenMP/target_simd_codegen_registration.cpp
  test/OpenMP/target_simd_depend_codegen.cpp
  test/OpenMP/target_teams_codegen.cpp
  test/OpenMP/target_teams_codegen_registration.cpp
  test/OpenMP/target_teams_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_codegen.cpp
  test/OpenMP/target_teams_distribute_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_simd_codegen.cpp
  test/OpenMP/target_teams_distribute_simd_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
  test/OpenMP/target_teams_num_teams_codegen.cpp
  test/OpenMP/target_teams_thread_limit_codegen.cpp

Index: test/OpenMP/target_teams_thread_limit_codegen.cpp
===
--- test/OpenMP/target_teams_thread_limit_codegen.cpp
+++ test/OpenMP/target_teams_thread_limit_codegen.cpp
@@ -76,7 +76,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 
 template
Index: test/OpenMP/target_teams_num_teams_codegen.cpp
===
--- test/OpenMP/target_teams_num_teams_codegen.cpp
+++ test/OpenMP/target_teams_num_teams_codegen.cpp
@@ -76,7 +76,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 
 template
Index: test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
===
--- test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
+++ test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
@@ -64,7 +64,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 
 template
Index: 

[PATCH] D60485: [AArch64] Add support for MTE intrinsics

2019-04-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added subscribers: hctim, vitalybuka.
vitalybuka added a comment.

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-msan/builds/12035

  -- Testing: 14692 tests, 96 threads --
  Testing: 
  FAIL: Clang :: AST/float16.cpp (132 of 14692)
   TEST 'Clang :: AST/float16.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 1';   
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang -cc1 
-internal-isystem 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/lib/clang/9.0.0/include
 -nostdsysteminc -std=c++11 -ast-dump -triple aarch64-linux-gnu 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/test/AST/float16.cpp
 | /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/test/AST/float16.cpp
 --strict-whitespace
  : 'RUN: at line 2';   
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang -cc1 
-internal-isystem 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/lib/clang/9.0.0/include
 -nostdsysteminc -std=c++11 -ast-dump -triple aarch64-linux-gnu 
-fnative-half-type 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/test/AST/float16.cpp
 | /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/test/AST/float16.cpp
 --check-prefix=CHECK-NATIVE --strict-whitespace
  --
  Exit Code: 2
  
  Command Output (stderr):
  --
  ==12261==WARNING: MemorySanitizer: use-of-uninitialized-value
  #0 0xd4212a8 in 
clang::targets::AArch64TargetInfo::getTargetDefines(clang::LangOptions const&, 
clang::MacroBuilder&) const 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/Basic/Targets/AArch64.cpp:197:7
  #1 0xd422b5b in 
clang::targets::AArch64leTargetInfo::getTargetDefines(clang::LangOptions 
const&, clang::MacroBuilder&) const 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/Basic/Targets/AArch64.cpp:463:22
  #2 0xd3ee87e in 
clang::targets::OSTargetInfo::getTargetDefines(clang::LangOptions
 const&, clang::MacroBuilder&) const 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/Basic/Targets/OSTargets.h:33:14
  #3 0x784d4c7 in InitializePredefinedMacros(clang::TargetInfo const&, 
clang::LangOptions const&, clang::FrontendOptions const&, clang::MacroBuilder&) 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp:1087:6
  #4 0x7830b1f in clang::InitializePreprocessor(clang::Preprocessor&, 
clang::PreprocessorOptions const&, clang::PCHContainerReader const&, 
clang::FrontendOptions const&) 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp:1117:5
  #5 0x76a550e in 
clang::CompilerInstance::createPreprocessor(clang::TranslationUnitKind) 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:392:3
  #6 0x779314b in 
clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, 
clang::FrontendInputFile const&) 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:742:8
  #7 0x76b49f8 in 
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:943:13
  #8 0x79d07f6 in 
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:271:25
  #9 0xb19a3a in cc1_main(llvm::ArrayRef, char const*, void*) 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/tools/driver/cc1_main.cpp:225:15
  #10 0xb12983 in ExecuteCC1Tool 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/tools/driver/driver.cpp:309:12
  #11 0xb12983 in main 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/tools/driver/driver.cpp:381
  #12 0x7f69ddc1c2e0 in __libc_start_main 
(/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
  #13 0xa91139 in _start 
(/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-9+0xa91139)
  
  SUMMARY: MemorySanitizer: use-of-uninitialized-value 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/lib/Basic/Targets/AArch64.cpp:197:7
 in clang::targets::AArch64TargetInfo::getTargetDefines(clang::LangOptions 
const&, clang::MacroBuilder&) const
  Exiting
  FileCheck error: '-' is empty.
  FileCheck command line:  
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck 
/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm/tools/clang/test/AST/float16.cpp
 --strict-whitespace

FYI @hctim


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60485/new/

https://reviews.llvm.org/D60485




[PATCH] D60485: [AArch64] Add support for MTE intrinsics

2019-04-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

fixed with r359366


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60485/new/

https://reviews.llvm.org/D60485



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


r359366 - [AArch64] Initialize HasMTE

2019-04-26 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Fri Apr 26 19:40:01 2019
New Revision: 359366

URL: http://llvm.org/viewvc/llvm-project?rev=359366=rev
Log:
[AArch64] Initialize HasMTE

Modified:
cfe/trunk/lib/Basic/Targets/AArch64.cpp

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=359366=359365=359366=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Fri Apr 26 19:40:01 2019
@@ -238,6 +238,7 @@ bool AArch64TargetInfo::handleTargetFeat
   HasFullFP16 = 0;
   HasDotProd = 0;
   HasFP16FML = 0;
+  HasMTE = 0;
   ArchKind = llvm::AArch64::ArchKind::ARMV8A;
 
   for (const auto  : Features) {


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


r359361 - Revert Fix interactions between __builtin_constant_p and constexpr to match current trunk GCC.

2019-04-26 Thread Jorge Gorbe Moya via cfe-commits
Author: jgorbe
Date: Fri Apr 26 17:32:04 2019
New Revision: 359361

URL: http://llvm.org/viewvc/llvm-project?rev=359361=rev
Log:
Revert Fix interactions between __builtin_constant_p and constexpr to match 
current trunk GCC.

This reverts r359059 (git commit 0b098754b73f3b96d00ecb1c7605760b11c90298)

Removed:
cfe/trunk/test/SemaCXX/builtin-constant-p.cpp
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/enable_if.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=359361=359360=359361=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Apr 26 17:32:04 2019
@@ -7801,33 +7801,19 @@ EvaluateBuiltinClassifyType(const CallEx
 }
 
 /// EvaluateBuiltinConstantPForLValue - Determine the result of
-/// __builtin_constant_p when applied to the given pointer.
+/// __builtin_constant_p when applied to the given lvalue.
 ///
-/// A pointer is only "constant" if it is null (or a pointer cast to integer)
-/// or it points to the first character of a string literal.
-static bool EvaluateBuiltinConstantPForLValue(const APValue ) {
-  APValue::LValueBase Base = LV.getLValueBase();
-  if (Base.isNull()) {
-// A null base is acceptable.
-return true;
-  } else if (const Expr *E = Base.dyn_cast()) {
-if (!isa(E))
-  return false;
-return LV.getLValueOffset().isZero();
-  } else {
-// Any other base is not constant enough for GCC.
-return false;
-  }
+/// An lvalue is only "constant" if it is a pointer or reference to the first
+/// character of a string literal.
+template
+static bool EvaluateBuiltinConstantPForLValue(const LValue ) {
+  const Expr *E = LV.getLValueBase().template dyn_cast();
+  return E && isa(E) && LV.getLValueOffset().isZero();
 }
 
 /// EvaluateBuiltinConstantP - Evaluate __builtin_constant_p as similarly to
 /// GCC as we can manage.
-static bool EvaluateBuiltinConstantP(EvalInfo , const Expr *Arg) {
-  // Constant-folding is always enabled for the operand of __builtin_constant_p
-  // (even when the enclosing evaluation context otherwise requires a strict
-  // language-specific constant expression).
-  FoldConstant Fold(Info, true);
-
+static bool EvaluateBuiltinConstantP(ASTContext , const Expr *Arg) {
   QualType ArgType = Arg->getType();
 
   // __builtin_constant_p always has one operand. The rules which gcc follows
@@ -7835,27 +7821,34 @@ static bool EvaluateBuiltinConstantP(Eva
   //
   //  - If the operand is of integral, floating, complex or enumeration type,
   //and can be folded to a known value of that type, it returns 1.
-  //  - If the operand can be folded to a pointer to the first character
-  //of a string literal (or such a pointer cast to an integral type)
-  //or to a null pointer or an integer cast to a pointer, it returns 1.
+  //  - If the operand and can be folded to a pointer to the first character
+  //of a string literal (or such a pointer cast to an integral type), it
+  //returns 1.
   //
   // Otherwise, it returns 0.
   //
   // FIXME: GCC also intends to return 1 for literals of aggregate types, but
   // its support for this does not currently work.
-  if (ArgType->isIntegralOrEnumerationType() || ArgType->isFloatingType() ||
-  ArgType->isAnyComplexType() || ArgType->isPointerType() ||
-  ArgType->isNullPtrType()) {
-APValue V;
-if (!::EvaluateAsRValue(Info, Arg, V))
+  if (ArgType->isIntegralOrEnumerationType()) {
+Expr::EvalResult Result;
+if (!Arg->EvaluateAsRValue(Result, Ctx) || Result.HasSideEffects)
   return false;
 
-// For a pointer (possibly cast to integer), there are special rules.
+APValue  = Result.Val;
+if (V.getKind() == APValue::Int)
+  return true;
 if (V.getKind() == APValue::LValue)
   return EvaluateBuiltinConstantPForLValue(V);
-
-// Otherwise, any constant value is good enough.
-return V.getKind() != APValue::Uninitialized;
+  } else if (ArgType->isFloatingType() || ArgType->isAnyComplexType()) {
+return Arg->isEvaluatable(Ctx);
+  } else if (ArgType->isPointerType() || Arg->isGLValue()) {
+LValue LV;
+Expr::EvalStatus Status;
+EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantFold);
+if ((Arg->isGLValue() ? EvaluateLValue(Arg, LV, Info)
+  : EvaluatePointer(Arg, LV, Info)) &&
+!Status.HasSideEffects)
+  return EvaluateBuiltinConstantPForLValue(LV);
   }
 
   // Anything else isn't considered to be sufficiently constant.
@@ -8266,7 +8259,7 @@ bool IntExprEvaluator::VisitBuiltinCallE
 
   case Builtin::BI__builtin_constant_p: {
 auto Arg = E->getArg(0);
-if (EvaluateBuiltinConstantP(Info, Arg))
+if (EvaluateBuiltinConstantP(Info.Ctx, Arg))
   return Success(true, E);
 auto ArgTy = 

[PATCH] D60990: [Driver] Support priority for multilibs

2019-04-26 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC359359: [Driver] Support priority for multilibs (authored by 
phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60990?vs=196905=196933#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60990/new/

https://reviews.llvm.org/D60990

Files:
  include/clang/Driver/Multilib.h
  lib/Driver/Multilib.cpp
  unittests/Driver/MultilibTest.cpp


Index: include/clang/Driver/Multilib.h
===
--- include/clang/Driver/Multilib.h
+++ include/clang/Driver/Multilib.h
@@ -34,10 +34,11 @@
   std::string OSSuffix;
   std::string IncludeSuffix;
   flags_list Flags;
+  int Priority;
 
 public:
   Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
-   StringRef IncludeSuffix = {});
+   StringRef IncludeSuffix = {}, int Priority = 0);
 
   /// Get the detected GCC installation path suffix for the multi-arch
   /// target variant. Always starts with a '/', unless empty
@@ -77,6 +78,10 @@
   const flags_list () const { return Flags; }
   flags_list () { return Flags; }
 
+  /// Returns the multilib priority. When more than one multilib matches flags,
+  /// the one with the highest priority is selected, with 0 being the default.
+  int priority() const { return Priority; }
+
   /// Add a flag to the flags list
   /// \p Flag must be a flag accepted by the driver with its leading '-' 
removed,
   /// and replaced with either:
Index: lib/Driver/Multilib.cpp
===
--- lib/Driver/Multilib.cpp
+++ lib/Driver/Multilib.cpp
@@ -51,8 +51,9 @@
 }
 
 Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix,
-   StringRef IncludeSuffix)
-: GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix) {
+   StringRef IncludeSuffix, int Priority)
+: GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix),
+  Priority(Priority) {
   normalizePathSegment(this->GCCSuffix);
   normalizePathSegment(this->OSSuffix);
   normalizePathSegment(this->IncludeSuffix);
@@ -265,8 +266,19 @@
 return true;
   }
 
-  // TODO: pick the "best" multlib when more than one is suitable
-  assert(false);
+  // Sort multilibs by priority and select the one with the highest priority.
+  llvm::sort(Filtered.begin(), Filtered.end(),
+ [](const Multilib , const Multilib ) -> bool {
+   return a.priority() > b.priority();
+ });
+
+  if (Filtered[0].priority() > Filtered[1].priority()) {
+M = Filtered[0];
+return true;
+  }
+
+  // TODO: We should consider returning llvm::Error rather than aborting.
+  assert(false && "More than one multilib with the same priority");
   return false;
 }
 
Index: unittests/Driver/MultilibTest.cpp
===
--- unittests/Driver/MultilibTest.cpp
+++ unittests/Driver/MultilibTest.cpp
@@ -349,3 +349,27 @@
   Latte.combineWith(Milk);
   ASSERT_EQ(Latte.size(), (unsigned)2);
 }
+
+TEST(MultilibTest, SetPriority) {
+  MultilibSet MS;
+  MS.push_back(Multilib("foo", {}, {}, 1).flag("+foo"));
+  MS.push_back(Multilib("bar", {}, {}, 2).flag("+bar"));
+
+  Multilib::flags_list Flags1;
+  Flags1.push_back("+foo");
+  Flags1.push_back("-bar");
+  Multilib Selection1;
+  ASSERT_TRUE(MS.select(Flags1, Selection1))
+  << "Flag set was {\"+foo\"}, but selection not found";
+  ASSERT_TRUE(Selection1.gccSuffix() == "/foo")
+  << "Selection picked " << Selection1 << " which was not expected";
+
+  Multilib::flags_list Flags2;
+  Flags2.push_back("+foo");
+  Flags2.push_back("+bar");
+  Multilib Selection2;
+  ASSERT_TRUE(MS.select(Flags2, Selection2))
+  << "Flag set was {\"+bar\"}, but selection not found";
+  ASSERT_TRUE(Selection2.gccSuffix() == "/bar")
+  << "Selection picked " << Selection2 << " which was not expected";
+}


Index: include/clang/Driver/Multilib.h
===
--- include/clang/Driver/Multilib.h
+++ include/clang/Driver/Multilib.h
@@ -34,10 +34,11 @@
   std::string OSSuffix;
   std::string IncludeSuffix;
   flags_list Flags;
+  int Priority;
 
 public:
   Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
-   StringRef IncludeSuffix = {});
+   StringRef IncludeSuffix = {}, int Priority = 0);
 
   /// Get the detected GCC installation path suffix for the multi-arch
   /// target variant. Always starts with a '/', unless empty
@@ -77,6 +78,10 @@
   const flags_list () const { return Flags; }
   flags_list () { return Flags; }
 
+  /// Returns the multilib priority. When more than one multilib matches flags,
+  /// the one with the highest priority is selected, with 0 being the default.
+  int priority() const { return Priority; }
+
   /// Add a flag to the flags list
   /// \p 

[PATCH] D61040: [Fuchsia] Support multilib for -fsanitize=address and -fno-exceptions

2019-04-26 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC359360: [Fuchsia] Support multilib for -fsanitize=address 
and -fno-exceptions (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61040?vs=196791=196934#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61040/new/

https://reviews.llvm.org/D61040

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/CommonArgs.h
  lib/Driver/ToolChains/Fuchsia.cpp
  lib/Driver/ToolChains/Gnu.cpp
  
test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/noexcept/.keep
  
test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/noexcept/.keep
  test/Driver/fuchsia.cpp

Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -15,7 +15,9 @@
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/VirtualFileSystem.h"
 
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
@@ -23,6 +25,8 @@
 using namespace clang;
 using namespace llvm::opt;
 
+using tools::addMultilibFlag;
+
 void fuchsia::Linker::ConstructJob(Compilation , const JobAction ,
const InputInfo ,
const InputInfoList ,
@@ -98,8 +102,6 @@
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   Args.AddAllArgs(CmdArgs, options::OPT_u);
 
-  addSanitizerPathLibArgs(ToolChain, Args, CmdArgs);
-
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
   if (D.isUsingLTO()) {
@@ -169,6 +171,52 @@
 llvm::sys::path::append(P, "lib");
 getFilePaths().push_back(P.str());
   }
+
+  auto RuntimeDirs = [&](const Multilib ) -> std::vector {
+SmallString<128> P;
+std::vector RD;
+
+P.assign(D.ResourceDir);
+llvm::sys::path::append(P, D.getTargetTriple(), "lib", M.gccSuffix());
+if (getVFS().exists(P))
+  RD.push_back(P.str());
+
+P.assign(D.ResourceDir);
+llvm::sys::path::append(P, Triple.str(), "lib", M.gccSuffix());
+if (getVFS().exists(P))
+  RD.push_back(P.str());
+
+return RD;
+  };
+
+  Multilibs.push_back(Multilib());
+  // Use the noexcept variant with -fno-exceptions to avoid the extra overhead.
+  Multilibs.push_back(Multilib("noexcept", {}, {}, 1)
+  .flag("-fexceptions")
+  .flag("+fno-exceptions"));
+  // ASan has higher priority because we always want the instrumentated version.
+  Multilibs.push_back(Multilib("asan", {}, {}, 2)
+  .flag("+fsanitize=address"));
+  Multilibs.FilterOut([&](const Multilib ) {
+std::vector RD = RuntimeDirs(M);
+return std::all_of(RD.begin(), RD.end(), [&](std::string P) {
+  return !getVFS().exists(P);
+});
+  });
+
+  Multilib::flags_list Flags;
+  addMultilibFlag(
+  Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, true),
+  "fexceptions", Flags);
+  addMultilibFlag(getSanitizerArgs().needsAsanRt(), "fsanitize=address", Flags);
+  Multilibs.setFilePathsCallback(RuntimeDirs);
+
+  if (Multilibs.select(Flags, SelectedMultilib))
+if (!SelectedMultilib.isDefault())
+  if (const auto  = Multilibs.filePathsCallback())
+for (const auto  : PathsCallback(SelectedMultilib))
+  // We need to prepend the multilib path to ensure it takes precedence.
+  getLibraryPaths().insert(getLibraryPaths().begin(), Path);
 }
 
 std::string Fuchsia::ComputeEffectiveClangTriple(const ArgList ,
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -33,6 +33,8 @@
 using namespace clang;
 using namespace llvm::opt;
 
+using tools::addMultilibFlag;
+
 void tools::GnuTool::anchor() {}
 
 static bool forwardToGCC(const Option ) {
@@ -871,16 +873,6 @@
   A->getValue() == StringRef("soft"));
 }
 
-/// \p Flag must be a flag accepted by the driver with its leading '-' removed,
-// otherwise '-print-multi-lib' will not emit them correctly.
-static void addMultilibFlag(bool Enabled, const char *const Flag,
-std::vector ) {
-  if (Enabled)
-Flags.push_back(std::string("+") + Flag);
-  else
-Flags.push_back(std::string("-") + Flag);
-}
-
 static bool isArmOrThumbArch(llvm::Triple::ArchType Arch) {
   return Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb;
 }
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -570,40 +570,6 @@
   return false;
 }
 
-static void addSanitizerLibPath(const 

r359359 - [Driver] Support priority for multilibs

2019-04-26 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Fri Apr 26 17:25:11 2019
New Revision: 359359

URL: http://llvm.org/viewvc/llvm-project?rev=359359=rev
Log:
[Driver] Support priority for multilibs

When more than one multilib flag matches, try to select the best
possible match based on priority. When two different multilibs with
the same same priority match, we still throw an error matching the
existing behavior.

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

Modified:
cfe/trunk/include/clang/Driver/Multilib.h
cfe/trunk/lib/Driver/Multilib.cpp
cfe/trunk/unittests/Driver/MultilibTest.cpp

Modified: cfe/trunk/include/clang/Driver/Multilib.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Multilib.h?rev=359359=359358=359359=diff
==
--- cfe/trunk/include/clang/Driver/Multilib.h (original)
+++ cfe/trunk/include/clang/Driver/Multilib.h Fri Apr 26 17:25:11 2019
@@ -34,10 +34,11 @@ private:
   std::string OSSuffix;
   std::string IncludeSuffix;
   flags_list Flags;
+  int Priority;
 
 public:
   Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
-   StringRef IncludeSuffix = {});
+   StringRef IncludeSuffix = {}, int Priority = 0);
 
   /// Get the detected GCC installation path suffix for the multi-arch
   /// target variant. Always starts with a '/', unless empty
@@ -77,6 +78,10 @@ public:
   const flags_list () const { return Flags; }
   flags_list () { return Flags; }
 
+  /// Returns the multilib priority. When more than one multilib matches flags,
+  /// the one with the highest priority is selected, with 0 being the default.
+  int priority() const { return Priority; }
+
   /// Add a flag to the flags list
   /// \p Flag must be a flag accepted by the driver with its leading '-' 
removed,
   /// and replaced with either:

Modified: cfe/trunk/lib/Driver/Multilib.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Multilib.cpp?rev=359359=359358=359359=diff
==
--- cfe/trunk/lib/Driver/Multilib.cpp (original)
+++ cfe/trunk/lib/Driver/Multilib.cpp Fri Apr 26 17:25:11 2019
@@ -51,8 +51,9 @@ static void normalizePathSegment(std::st
 }
 
 Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix,
-   StringRef IncludeSuffix)
-: GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix) {
+   StringRef IncludeSuffix, int Priority)
+: GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix),
+  Priority(Priority) {
   normalizePathSegment(this->GCCSuffix);
   normalizePathSegment(this->OSSuffix);
   normalizePathSegment(this->IncludeSuffix);
@@ -265,8 +266,19 @@ bool MultilibSet::select(const Multilib:
 return true;
   }
 
-  // TODO: pick the "best" multlib when more than one is suitable
-  assert(false);
+  // Sort multilibs by priority and select the one with the highest priority.
+  llvm::sort(Filtered.begin(), Filtered.end(),
+ [](const Multilib , const Multilib ) -> bool {
+   return a.priority() > b.priority();
+ });
+
+  if (Filtered[0].priority() > Filtered[1].priority()) {
+M = Filtered[0];
+return true;
+  }
+
+  // TODO: We should consider returning llvm::Error rather than aborting.
+  assert(false && "More than one multilib with the same priority");
   return false;
 }
 

Modified: cfe/trunk/unittests/Driver/MultilibTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Driver/MultilibTest.cpp?rev=359359=359358=359359=diff
==
--- cfe/trunk/unittests/Driver/MultilibTest.cpp (original)
+++ cfe/trunk/unittests/Driver/MultilibTest.cpp Fri Apr 26 17:25:11 2019
@@ -349,3 +349,27 @@ TEST(MultilibTest, SetCombineWith) {
   Latte.combineWith(Milk);
   ASSERT_EQ(Latte.size(), (unsigned)2);
 }
+
+TEST(MultilibTest, SetPriority) {
+  MultilibSet MS;
+  MS.push_back(Multilib("foo", {}, {}, 1).flag("+foo"));
+  MS.push_back(Multilib("bar", {}, {}, 2).flag("+bar"));
+
+  Multilib::flags_list Flags1;
+  Flags1.push_back("+foo");
+  Flags1.push_back("-bar");
+  Multilib Selection1;
+  ASSERT_TRUE(MS.select(Flags1, Selection1))
+  << "Flag set was {\"+foo\"}, but selection not found";
+  ASSERT_TRUE(Selection1.gccSuffix() == "/foo")
+  << "Selection picked " << Selection1 << " which was not expected";
+
+  Multilib::flags_list Flags2;
+  Flags2.push_back("+foo");
+  Flags2.push_back("+bar");
+  Multilib Selection2;
+  ASSERT_TRUE(MS.select(Flags2, Selection2))
+  << "Flag set was {\"+bar\"}, but selection not found";
+  ASSERT_TRUE(Selection2.gccSuffix() == "/bar")
+  << "Selection picked " << Selection2 << " which was not expected";
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r359360 - [Fuchsia] Support multilib for -fsanitize=address and -fno-exceptions

2019-04-26 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Fri Apr 26 17:25:13 2019
New Revision: 359360

URL: http://llvm.org/viewvc/llvm-project?rev=359360=rev
Log:
[Fuchsia] Support multilib for -fsanitize=address and -fno-exceptions

This introduces a support for multilibs to Fuchsia driver. Unlike the
existing multilibs that are used primarily for handling different
architecture variants, we use multilibs to handle different variants
of Clang runtime libraries: -fsanitize=address and -fno-exceptions
are the two we support initially. This replaces the existing support
for sanitized runtimes libraries that was only used by Fuchsia driver
and it also refactors some of the logic to allow sharing between GNU
and Fuchsia drivers.

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

Added:

cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/noexcept/

cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/noexcept/.keep

cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/noexcept/

cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/noexcept/.keep
Modified:
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/fuchsia.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=359360=359359=359360=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Fri Apr 26 17:25:13 2019
@@ -570,40 +570,6 @@ static bool addSanitizerDynamicList(cons
   return false;
 }
 
-static void addSanitizerLibPath(const ToolChain , const ArgList ,
-ArgStringList , StringRef Name) {
-  for (const auto  : TC.getLibraryPaths()) {
-if (!LibPath.empty()) {
-  SmallString<128> P(LibPath);
-  llvm::sys::path::append(P, Name);
-  if (TC.getVFS().exists(P))
-CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + P));
-}
-  }
-}
-
-void tools::addSanitizerPathLibArgs(const ToolChain , const ArgList ,
-ArgStringList ) {
-  const SanitizerArgs  = TC.getSanitizerArgs();
-  if (SanArgs.needsAsanRt()) {
-addSanitizerLibPath(TC, Args, CmdArgs, "asan");
-  }
-  if (SanArgs.needsHwasanRt()) {
-addSanitizerLibPath(TC, Args, CmdArgs, "hwasan");
-  }
-  if (SanArgs.needsLsanRt()) {
-addSanitizerLibPath(TC, Args, CmdArgs, "lsan");
-  }
-  if (SanArgs.needsMsanRt()) {
-addSanitizerLibPath(TC, Args, CmdArgs, "msan");
-  }
-  if (SanArgs.needsTsanRt()) {
-addSanitizerLibPath(TC, Args, CmdArgs, "tsan");
-  }
-}
-
-
-
 void tools::linkSanitizerRuntimeDeps(const ToolChain ,
  ArgStringList ) {
   // Force linking against the system libraries sanitizers depends on
@@ -1535,3 +1501,8 @@ SmallString<128> tools::getStatsFileName
   llvm::sys::path::replace_extension(StatsFile, "stats");
   return StatsFile;
 }
+
+void tools::addMultilibFlag(bool Enabled, const char *const Flag,
+Multilib::flags_list ) {
+  Flags.push_back(std::string(Enabled ? "+" : "-") + Flag);
+}

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.h?rev=359360=359359=359360=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.h Fri Apr 26 17:25:13 2019
@@ -11,6 +11,7 @@
 
 #include "InputInfo.h"
 #include "clang/Driver/Driver.h"
+#include "clang/Driver/Multilib.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
 #include "llvm/Support/CodeGen.h"
@@ -31,10 +32,6 @@ void claimNoWarnArgs(const llvm::opt::Ar
 bool addSanitizerRuntimes(const ToolChain , const llvm::opt::ArgList ,
   llvm::opt::ArgStringList );
 
-void addSanitizerPathLibArgs(const ToolChain ,
- const llvm::opt::ArgList ,
- llvm::opt::ArgStringList );
-
 void linkSanitizerRuntimeDeps(const ToolChain ,
   llvm::opt::ArgStringList );
 
@@ -121,6 +118,12 @@ void handleTargetFeaturesGroup(const llv
 SmallString<128> getStatsFileName(const llvm::opt::ArgList ,
   const InputInfo ,
   const InputInfo , const Driver );
+
+/// \p Flag must be a flag accepted by the driver with its leading '-' removed,
+// otherwise '-print-multi-lib' will not emit them correctly.
+void addMultilibFlag(bool Enabled, const char *const Flag,
+ 

[PATCH] D60967: Move setTargetAttributes after setGVProperties in SetFunctionAttributes

2019-04-26 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

@rjmccall I'm not sure if this is the right place to continue discussing this, 
but I don't have a patch I am happy with and I would rather not post something 
half-baked.

Currently for AMDGPU we have the behavior that the user can set the visibility 
of these symbols with explicit attributes. If we consider the `kernel` 
attribute itself as an explicit visibility declaration how do we support this 
flexibility when we will have effectively mandated a single visibility that the 
user cannot interact with? Even if we are OK with mandating something like 
default visibility, we do not currently support preemptible symbols so 
`protected` is the optimal visibility. This may not be true of other targets, 
and it may not even be true of AMDGPU in the future, so hardcoding the 
visibility of `kernel` symbols to anything doesn't seem correct. Is something 
like "not-hidden" reasonable?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60967/new/

https://reviews.llvm.org/D60967



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


[PATCH] D61217: Fix PCH skipping to handle all Lexers

2019-04-26 Thread Mike Rice via Phabricator via cfe-commits
mikerice created this revision.
mikerice added reviewers: rnk, cfe-commits.

When skipping code at the start of a file during PCH use, Preprocessor::Lex is 
not used since it consumes all preprocessor directives until it returns a real 
token.  Using the specific Lexer (i.e. CurLexer->Lex) makes it possible to stop 
skipping after an #include or #pragma hdrstop.  Previously the skipping code 
was only handling CurLexer, now all will be handled correctly.

Fixes: llvm.org/PR41585


https://reviews.llvm.org/D61217

Files:
  lib/Lex/Preprocessor.cpp
  test/PCH/Inputs/pch-through-macro.h
  test/PCH/pch-through4.cpp
  test/PCH/pch-through4a.cpp


Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -625,8 +625,23 @@
   bool UsingPragmaHdrStop = SkippingUntilPragmaHdrStop;
   Token Tok;
   while (true) {
-bool InPredefines = (CurLexer->getFileID() == getPredefinesFileID());
-CurLexer->Lex(Tok);
+bool InPredefines =
+(CurLexer && CurLexer->getFileID() == getPredefinesFileID());
+switch (CurLexerKind) {
+case CLK_Lexer:
+  CurLexer->Lex(Tok);
+ break;
+case CLK_TokenLexer:
+  CurTokenLexer->Lex(Tok);
+  break;
+case CLK_CachingLexer:
+  bool IsNewToken;
+  CachingLex(Tok, IsNewToken);
+  break;
+case CLK_LexAfterModuleImport:
+  LexAfterModuleImport(Tok);
+  break;
+}
 if (Tok.is(tok::eof) && !InPredefines) {
   ReachedMainFileEOF = true;
   break;
Index: test/PCH/pch-through4a.cpp
===
--- test/PCH/pch-through4a.cpp
+++ test/PCH/pch-through4a.cpp
@@ -0,0 +1,16 @@
+// expected-no-diagnostics
+// Create PCH with a through header.
+// RUN: %clang_cc1 -verify -I %S -emit-pch \
+// RUN: -pch-through-header=Inputs/pch-through1.h \
+// RUN:   -fms-extensions -o %t.pch -x c++-header %s
+
+// Create the PCH object
+// RUN: %clang_cc1 -verify -I %S -emit-obj -include-pch %t.pch \
+// RUN:   -pch-through-header=Inputs/pch-through1.h \
+// RUN:   -fms-extensions -o %t.obj -x c++ %s
+
+#define Source(x,y)
+#define InOut(size) Source(InOut, (size))
+void f(InOut(a) char *b, unsigned long a);
+#include "Inputs/pch-through1.h"
+int other;
Index: test/PCH/pch-through4.cpp
===
--- test/PCH/pch-through4.cpp
+++ test/PCH/pch-through4.cpp
@@ -0,0 +1,12 @@
+// expected-no-diagnostics
+// Create PCH with #pragma hdrstop processing.
+// RUN: %clang_cc1 -verify -I %S -emit-pch -pch-through-hdrstop-create \
+// RUN:   -fms-extensions -o %t.pch -x c++-header %s
+
+// Create the PCH object
+// RUN: %clang_cc1 -verify -I %S -emit-obj -include-pch %t.pch \
+// RUN:   -pch-through-hdrstop-create -fms-extensions -o %t.obj -x c++ %s
+
+#pragma once
+#include "Inputs/pch-through-macro.h"
+void f(InOut(a) char *b, unsigned long a);
Index: test/PCH/Inputs/pch-through-macro.h
===
--- test/PCH/Inputs/pch-through-macro.h
+++ test/PCH/Inputs/pch-through-macro.h
@@ -0,0 +1,3 @@
+#pragma once
+#define Source(x,y)
+#define InOut(size) Source(InOut, (size))


Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -625,8 +625,23 @@
   bool UsingPragmaHdrStop = SkippingUntilPragmaHdrStop;
   Token Tok;
   while (true) {
-bool InPredefines = (CurLexer->getFileID() == getPredefinesFileID());
-CurLexer->Lex(Tok);
+bool InPredefines =
+(CurLexer && CurLexer->getFileID() == getPredefinesFileID());
+switch (CurLexerKind) {
+case CLK_Lexer:
+  CurLexer->Lex(Tok);
+ break;
+case CLK_TokenLexer:
+  CurTokenLexer->Lex(Tok);
+  break;
+case CLK_CachingLexer:
+  bool IsNewToken;
+  CachingLex(Tok, IsNewToken);
+  break;
+case CLK_LexAfterModuleImport:
+  LexAfterModuleImport(Tok);
+  break;
+}
 if (Tok.is(tok::eof) && !InPredefines) {
   ReachedMainFileEOF = true;
   break;
Index: test/PCH/pch-through4a.cpp
===
--- test/PCH/pch-through4a.cpp
+++ test/PCH/pch-through4a.cpp
@@ -0,0 +1,16 @@
+// expected-no-diagnostics
+// Create PCH with a through header.
+// RUN: %clang_cc1 -verify -I %S -emit-pch \
+// RUN: -pch-through-header=Inputs/pch-through1.h \
+// RUN:   -fms-extensions -o %t.pch -x c++-header %s
+
+// Create the PCH object
+// RUN: %clang_cc1 -verify -I %S -emit-obj -include-pch %t.pch \
+// RUN:   -pch-through-header=Inputs/pch-through1.h \
+// RUN:   -fms-extensions -o %t.obj -x c++ %s
+
+#define Source(x,y)
+#define InOut(size) Source(InOut, (size))
+void f(InOut(a) char *b, unsigned long a);
+#include "Inputs/pch-through1.h"
+int other;
Index: test/PCH/pch-through4.cpp

[PATCH] D61209: [clang-tidy] Fix readability-redundant-smartptr-get for MSVC STL

2019-04-26 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-msvc.cpp:37
+void Positive() {
+
+  std::unique_ptr* up;

Unnecessary empty line.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61209/new/

https://reviews.llvm.org/D61209



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


r359356 - [clang][driver] Weaken the test from 359353 to appease Windows bots

2019-04-26 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Apr 26 15:58:31 2019
New Revision: 359356

URL: http://llvm.org/viewvc/llvm-project?rev=359356=rev
Log:
[clang][driver] Weaken the test from 359353 to appease Windows bots

Modified:
cfe/trunk/test/Driver/arclite-link-external-toolchain.c

Modified: cfe/trunk/test/Driver/arclite-link-external-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arclite-link-external-toolchain.c?rev=359356=359355=359356=diff
==
--- cfe/trunk/test/Driver/arclite-link-external-toolchain.c (original)
+++ cfe/trunk/test/Driver/arclite-link-external-toolchain.c Fri Apr 26 15:58:31 
2019
@@ -5,4 +5,4 @@
 // RUN:   %s 2>&1 | FileCheck %s
 
 // CHECK: -lfoo
-// CHECK: 
.tmpdir/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_macosx.a
+// CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a


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


[PATCH] D60943: Delay diagnosing "n" constraint until after inlining

2019-04-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D60943#1475038 , @void wrote:

> In D60943#1474926 , @rsmith wrote:
>
> > Is `"n"` really special in this regard, or is it just the first one that 
> > we've encountered?
>
>
> I think it's just the first one we've encountered. There could be other 
> constraints which require immediates, but they're probably target-specific. 
> E.g. `e` and `K` for x86.


OK, then I think we should apply whatever we do here to all constraints for 
which `Info.requiresImmediateConstant()` is `true`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943



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


r359353 - [driver][macOS] Link libarclite from the default toolchain when clang

2019-04-26 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Apr 26 15:40:47 2019
New Revision: 359353

URL: http://llvm.org/viewvc/llvm-project?rev=359353=rev
Log:
[driver][macOS] Link libarclite from the default toolchain when clang
is running in a toolchain outside of xcode

'libarclite' usually lives in the same toolchain as 'clang'. However, the
Swift open source toolchains for macOS distribute Clang without 'libarclite'.
In that case, to allow the linker to find 'libarclite', we point to the
'libarclite' that should be in the XcodeDefault toolchain instead. The
path to the toolchain is inferred from the SDK path if it's specified.

https://bugs.swift.org/browse/SR-9972
rdar://49947573

Added:
cfe/trunk/test/Driver/arclite-link-external-toolchain.c
Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=359353=359352=359353=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Fri Apr 26 15:40:47 2019
@@ -893,6 +893,18 @@ void DarwinClang::addClangWarningOptions
   }
 }
 
+/// Take a path that speculatively points into Xcode and return the
+/// `XCODE/Contents/Developer` path if it is an Xcode path, or an empty path
+/// otherwise.
+static StringRef getXcodeDeveloperPath(StringRef PathIntoXcode) {
+  static constexpr llvm::StringLiteral XcodeAppSuffix(
+  ".app/Contents/Developer");
+  size_t Index = PathIntoXcode.find(XcodeAppSuffix);
+  if (Index == StringRef::npos)
+return "";
+  return PathIntoXcode.take_front(Index + XcodeAppSuffix.size());
+}
+
 void DarwinClang::AddLinkARCArgs(const ArgList ,
  ArgStringList ) const {
   // Avoid linking compatibility stubs on i386 mac.
@@ -905,10 +917,27 @@ void DarwinClang::AddLinkARCArgs(const A
   runtime.hasSubscripting())
 return;
 
-  CmdArgs.push_back("-force_load");
   SmallString<128> P(getDriver().ClangExecutable);
   llvm::sys::path::remove_filename(P); // 'clang'
   llvm::sys::path::remove_filename(P); // 'bin'
+
+  // 'libarclite' usually lives in the same toolchain as 'clang'. However, the
+  // Swift open source toolchains for macOS distribute Clang without 
libarclite.
+  // In that case, to allow the linker to find 'libarclite', we point to the
+  // 'libarclite' in the XcodeDefault toolchain instead.
+  if (getXcodeDeveloperPath(P).empty()) {
+if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
+  // Try to infer the path to 'libarclite' in the toolchain from the
+  // specified SDK path.
+  StringRef XcodePathForSDK = getXcodeDeveloperPath(A->getValue());
+  if (!XcodePathForSDK.empty()) {
+P = XcodePathForSDK;
+llvm::sys::path::append(P, "Toolchains/XcodeDefault.xctoolchain/usr");
+  }
+}
+  }
+
+  CmdArgs.push_back("-force_load");
   llvm::sys::path::append(P, "lib", "arc", "libarclite_");
   // Mash in the platform.
   if (isTargetWatchOSSimulator())

Added: cfe/trunk/test/Driver/arclite-link-external-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arclite-link-external-toolchain.c?rev=359353=auto
==
--- cfe/trunk/test/Driver/arclite-link-external-toolchain.c (added)
+++ cfe/trunk/test/Driver/arclite-link-external-toolchain.c Fri Apr 26 15:40:47 
2019
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t.tmpdir
+// RUN: mkdir -p 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
+// RUN: %clang -### -target x86_64-apple-macos10.10 -fobjc-link-runtime -lfoo \
+// RUN:   -isysroot 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 \
+// RUN:   %s 2>&1 | FileCheck %s
+
+// CHECK: -lfoo
+// CHECK: 
.tmpdir/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_macosx.a


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


[PATCH] D52521: [Sema] DR727: Ensure we pick up enclosing template instantiation arguments for a class-scope explicit specialization.

2019-04-26 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

No worries! It happens, I probably should have pinged this more aggressively.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D52521/new/

https://reviews.llvm.org/D52521



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


[PATCH] D52521: [Sema] DR727: Ensure we pick up enclosing template instantiation arguments for a class-scope explicit specialization.

2019-04-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D52521#1479907 , @erik.pilkington 
wrote:

> Looks like @rsmith fixed this in r359266.


Sorry, I completely forgot about the existence of this when working on that 
patch! :(


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D52521/new/

https://reviews.llvm.org/D52521



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


[PATCH] D61165: Fix a crash where a [[no_destroy]] destructor was not emitted in an array

2019-04-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay, SGTM.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61165/new/

https://reviews.llvm.org/D61165



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


[PATCH] D61165: Fix a crash where a [[no_destroy]] destructor was not emitted in an array

2019-04-26 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington planned changes to this revision.
erik.pilkington added a comment.

In D61165#1480976 , @rjmccall wrote:

> I believe at least one of the goals of `nodestroy` is to allow the type to 
> potentially not provide a destructor at all, so if we're going to implicitly 
> require the destructor anyway in certain situations, we should clearly 
> document that, and we should be aware that we may be making the attribute 
> less useful.
>
> Since I believe the dominant use-case here is a true global, does only 
> requiring the destructor for arrays in the static-local case when exceptions 
> are enabled at least make it acceptable to do proper access checking, or is 
> that still a source-compatibility problem for existing clients?


It's hard to say exactly how bad the source compatibility problem is, we 
haven't been pushing on this much internally (yet), so I doubt we'll run into 
any issues. There was included in an open-source release though. If we only 
checked access when we needed it, the sequence of steps to actually break 
anything is pretty far: you'd have to have a type with a private dtor, used in 
a static local array, with the attribute, and be compiling with exceptions. I'd 
actually be quite surprised if we ran into any issues, so I guess we should do 
the right thing with access checking.

I'll update the patch and the docs.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61165/new/

https://reviews.llvm.org/D61165



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


r359350 - Add to the release notes the fact that UninitializedObject checker is now

2019-04-26 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Fri Apr 26 14:46:33 2019
New Revision: 359350

URL: http://llvm.org/viewvc/llvm-project?rev=359350=rev
Log:
Add to the release notes the fact that UninitializedObject checker is now
considered as stable


Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=359350=359349=359350=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri Apr 26 14:46:33 2019
@@ -190,7 +190,8 @@ libclang
 Static Analyzer
 ---
 
-- ...
+- The UninitializedObject checker is now considered as stable.
+  (moved from the 'alpha.cplusplus' to the 'optin.cplusplus' package)
 
 ...
 


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


[PATCH] D61165: Fix a crash where a [[no_destroy]] destructor was not emitted in an array

2019-04-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I believe at least one of the goals of `nodestroy` is to allow the type to 
potentially not provide a destructor at all, so if we're going to implicitly 
require the destructor anyway in certain situations, we should clearly document 
that, and we should be aware that we may be making the attribute less useful.

Since I believe the dominant use-case here is a true global, does only 
requiring the destructor for arrays in the static-local case when exceptions 
are enabled at least make it acceptable to do proper access checking, or is 
that still a source-compatibility problem for existing clients?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61165/new/

https://reviews.llvm.org/D61165



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


[PATCH] D61165: Fix a crash where a [[no_destroy]] destructor was not emitted in an array

2019-04-26 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

By using `no_destroy`, you're saying that exit-time destructor doesn't matter 
because the OS will either reclaim the resources automatically, or its just 
doesn't matter since the process is going down. I don't think that implies that 
we can safely ignore the destructor in the middle of the program's execution.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61165/new/

https://reviews.llvm.org/D61165



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


[PATCH] D61165: Fix a crash where a [[no_destroy]] destructor was not emitted in an array

2019-04-26 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

JF, Michael, and I were talking about this offline, and we think that the right 
choice of semantics for the static local case is to call the destructors.

  struct HoldsResource {
HoldsResource() { tryToAcquireItMayThrow(); }
~HoldsResource() { releaseIt(); }
  };
  
  void doSomeThings() {
try { 
  [[clang::no_destroy]] static HoldsResource MyResources[10];
} catch (...) {
  /* recover gracefully somehow */
}
  }

Here, its possible to call `doSomeThings` many times, until it actually manages 
to construct `MyResources`. Just not calling the dtor doesn't seem right since 
we'd be leaking resources. Calling `terminate` doesn't make sense either, since 
its possible to recover from this and try again or continue. `no_destroy` 
doesn't mean don't destroy (lol), it means don't register exit-time dtors, 
that's why it only applies to static/thread local declarations. @rjmccall: 
WDYT? This is obviously a pretty narrow edge-case.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61165/new/

https://reviews.llvm.org/D61165



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


[PATCH] D60485: [AArch64] Add support for MTE intrinsics

2019-04-26 Thread Javed Absar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC359348: [AArch64] Add support for MTE intrinsics (authored 
by javed.absar, committed by ).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D60485?vs=196297=196915#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60485/new/

https://reviews.llvm.org/D60485

Files:
  include/clang/Basic/BuiltinsAArch64.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Basic/Targets/AArch64.cpp
  lib/Basic/Targets/AArch64.h
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/arm_acle.h
  lib/Sema/SemaChecking.cpp
  test/CodeGen/arm64-mte.c
  test/Preprocessor/aarch64-target-features.c
  test/Sema/builtins-arm64-mte.c

Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -9621,6 +9621,18 @@
"the type is not trivially copyable|"
"the type does not have the expected form}1">;
 
+// Memory Tagging Extensions (MTE) diagnostics
+def err_memtag_arg_null_or_pointer : Error<
+  "%0 argument of MTE builtin function must be a null or a pointer (%1 invalid)">;
+def err_memtag_any2arg_pointer : Error<
+  "at least one argument of MTE builtin function must be a pointer (%0, %1 invalid)">;
+def err_memtag_arg_must_be_pointer : Error<
+  "%0 argument of MTE builtin function must be a pointer (%1 invalid)">;
+def err_memtag_arg_must_be_integer : Error<
+  "%0 argument of MTE builtin function must be an integer type (%1 invalid)">;
+def err_memtag_arg_must_be_unsigned : Error<
+  "%0 argument  of MTE builtin function must be an unsigned integer type (%1 invalid)">;
+
 def warn_dereference_of_noderef_type : Warning<
   "dereferencing %0; was declared with a 'noderef' type">, InGroup;
 def warn_dereference_of_noderef_type_no_decl : Warning<
Index: include/clang/Basic/BuiltinsAArch64.def
===
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -52,6 +52,14 @@
 BUILTIN(__builtin_arm_crc32d, "UiUiWUi", "nc")
 BUILTIN(__builtin_arm_crc32cd, "UiUiWUi", "nc")
 
+// Memory Tagging Extensions (MTE)
+BUILTIN(__builtin_arm_irg, "v*v*Ui", "t")
+BUILTIN(__builtin_arm_addg, "v*v*Ui", "t")
+BUILTIN(__builtin_arm_gmi, "Uiv*Ui", "t")
+BUILTIN(__builtin_arm_ldg, "v*v*", "t")
+BUILTIN(__builtin_arm_stg, "vv*", "t")
+BUILTIN(__builtin_arm_subp, "Uiv*v*", "t")
+
 // Memory barrier
 BUILTIN(__builtin_arm_dmb, "vUi", "nc")
 BUILTIN(__builtin_arm_dsb, "vUi", "nc")
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -10759,6 +10759,7 @@
   bool SemaBuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall,
 int ArgNum, unsigned ExpectedFieldNum,
 bool AllowName);
+  bool SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall);
 public:
   enum FormatStringType {
 FST_Scanf,
Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -316,3 +316,6 @@
 // CHECK-V81A-FEATURE-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+v8.1a" "-target-feature" "-crypto"
 // CHECK-V81A-FEATURE-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.1a" "-target-feature" "-neon"
 
+// == Check Memory Tagging Extensions (MTE).
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8.5-a+memtag -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-MEMTAG %s
+// CHECK-MEMTAG: __ARM_FEATURE_MEMORY_TAGGING 1
Index: test/Sema/builtins-arm64-mte.c
===
--- test/Sema/builtins-arm64-mte.c
+++ test/Sema/builtins-arm64-mte.c
@@ -0,0 +1,136 @@
+// RUN: %clang_cc1 -triple arm64-arm-eabi %s -target-feature +mte -fsyntax-only -verify
+// RUN: %clang_cc1 -triple arm64-arm-eabi %s -target-feature +mte -x c++ -fsyntax-only -verify
+#include 
+#include 
+
+int  *create_tag1(int a, unsigned b) {
+  // expected-error@+1 {{first argument of MTE builtin function must be a pointer ('int' invalid)}}
+  return __arm_mte_create_random_tag(a,b);
+}
+
+int  *create_tag2(int *a, unsigned *b) {
+  // expected-error@+1 {{second argument of MTE builtin function must be an integer type ('unsigned int *' invalid)}}
+  return __arm_mte_create_random_tag(a,b);
+}
+
+int  *create_tag3(const int *a, unsigned b) {
+#ifdef __cplusplus
+  // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const int *'}}
+  return __arm_mte_create_random_tag(a,b);
+#else
+  

r359348 - [AArch64] Add support for MTE intrinsics

2019-04-26 Thread Javed Absar via cfe-commits
Author: javed.absar
Date: Fri Apr 26 14:08:11 2019
New Revision: 359348

URL: http://llvm.org/viewvc/llvm-project?rev=359348=rev
Log:
[AArch64] Add support for MTE intrinsics
This provides intrinsics support for Memory Tagging Extension (MTE),
which was introduced with the Armv8.5-a architecture.
These intrinsics are available when __ARM_FEATURE_MEMORY_TAGGING is defined.
Each intrinsic is described in detail in the ACLE Q1 2019 documentation:
https://developer.arm.com/docs/101028/latest
Reviewed By: Tim Nortover, David Spickett
Differential Revision: https://reviews.llvm.org/D60485


Added:
cfe/trunk/test/CodeGen/arm64-mte.c
cfe/trunk/test/Sema/builtins-arm64-mte.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Basic/Targets/AArch64.cpp
cfe/trunk/lib/Basic/Targets/AArch64.h
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/arm_acle.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Preprocessor/aarch64-target-features.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAArch64.def?rev=359348=359347=359348=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def Fri Apr 26 14:08:11 2019
@@ -52,6 +52,14 @@ BUILTIN(__builtin_arm_crc32cw, "UiUiUi",
 BUILTIN(__builtin_arm_crc32d, "UiUiWUi", "nc")
 BUILTIN(__builtin_arm_crc32cd, "UiUiWUi", "nc")
 
+// Memory Tagging Extensions (MTE)
+BUILTIN(__builtin_arm_irg, "v*v*Ui", "t")
+BUILTIN(__builtin_arm_addg, "v*v*Ui", "t")
+BUILTIN(__builtin_arm_gmi, "Uiv*Ui", "t")
+BUILTIN(__builtin_arm_ldg, "v*v*", "t")
+BUILTIN(__builtin_arm_stg, "vv*", "t")
+BUILTIN(__builtin_arm_subp, "Uiv*v*", "t")
+
 // Memory barrier
 BUILTIN(__builtin_arm_dmb, "vUi", "nc")
 BUILTIN(__builtin_arm_dsb, "vUi", "nc")

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=359348=359347=359348=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Apr 26 14:08:11 
2019
@@ -9621,6 +9621,18 @@ def err_std_compare_type_not_supported :
"the type is not trivially copyable|"
"the type does not have the expected form}1">;
 
+// Memory Tagging Extensions (MTE) diagnostics
+def err_memtag_arg_null_or_pointer : Error<
+  "%0 argument of MTE builtin function must be a null or a pointer (%1 
invalid)">;
+def err_memtag_any2arg_pointer : Error<
+  "at least one argument of MTE builtin function must be a pointer (%0, %1 
invalid)">;
+def err_memtag_arg_must_be_pointer : Error<
+  "%0 argument of MTE builtin function must be a pointer (%1 invalid)">;
+def err_memtag_arg_must_be_integer : Error<
+  "%0 argument of MTE builtin function must be an integer type (%1 invalid)">;
+def err_memtag_arg_must_be_unsigned : Error<
+  "%0 argument  of MTE builtin function must be an unsigned integer type (%1 
invalid)">;
+
 def warn_dereference_of_noderef_type : Warning<
   "dereferencing %0; was declared with a 'noderef' type">, InGroup;
 def warn_dereference_of_noderef_type_no_decl : Warning<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=359348=359347=359348=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Apr 26 14:08:11 2019
@@ -10759,6 +10759,7 @@ private:
   bool SemaBuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall,
 int ArgNum, unsigned ExpectedFieldNum,
 bool AllowName);
+  bool SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall);
 public:
   enum FormatStringType {
 FST_Scanf,

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=359348=359347=359348=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Fri Apr 26 14:08:11 2019
@@ -194,6 +194,9 @@ void AArch64TargetInfo::getTargetDefines
   if (HasDotProd)
 Builder.defineMacro("__ARM_FEATURE_DOTPROD", "1");
 
+  if (HasMTE)
+Builder.defineMacro("__ARM_FEATURE_MEMORY_TAGGING", "1");
+
   if ((FPU & NeonMode) && HasFP16FML)
 Builder.defineMacro("__ARM_FEATURE_FP16FML", "1");
 
@@ -258,6 +261,8 @@ bool AArch64TargetInfo::handleTargetFeat
   HasDotProd = 1;
 if (Feature 

[PATCH] D61209: [clang-tidy] Fix readability-redundant-smartptr-get for MSVC STL

2019-04-26 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-msvc.cpp:96
+}
\ No newline at end of file


Please add new line.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61209/new/

https://reviews.llvm.org/D61209



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


[PATCH] D61147: [Sema][ObjC] Add a flavor of -Wunused-parameter that doesn't diagnose unused parameters of ObjC methods

2019-04-26 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

In D61147#1479956 , @rjmccall wrote:

> In D61147#1479940 , @erik.pilkington 
> wrote:
>
> > In D61147#1479932 , @rjmccall 
> > wrote:
> >
> > > I do not think the ObjC version of this diagnostic is useful as it's been 
> > > explained here, and I would strongly recommend just not including such a 
> > > warning for the time being.
> >
> >
> > Why? It seems to me like the vast majority of methods only declared in an 
> > `@implementation` are used as local helpers (even if people probably should 
> > be using functions for this), where this warning would be useful. Maybe I'm 
> > missing something? Still trying to learn more about Objective-C.
>
>
> What rule are you suggesting for whether a method is "only declared in an 
> `@implementation`"?  Where exactly are you proposing to look for other 
> declarations?
>
> Objective-C does not have a formalized notion of an `@implementation`-private 
> method, or really even an unambiguous convention for them (underscoring is 
> *library*-private by convention, not class-private).  The Objective-C 
> ecosystem includes a lot of informal protocols and conventions based around 
> discovery via naming, and Objective-C programmers do (admittedly rarely) just 
> override methods that they know are there but which they can't see.  These 
> things make me very worried about trying to port assumptions from other 
> languages.


Concretely, I was just thinking of using something like 
`ObjCMethodDecl::isOverriding`, but if that isn't a good enough heuristic for 
finding local methods then I guess we should just forgo methods entirely.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61147/new/

https://reviews.llvm.org/D61147



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


[PATCH] D61209: [clang-tidy] Fix readability-redundant-smartptr-get for MSVC STL

2019-04-26 Thread Florian Gross via Phabricator via cfe-commits
fgross updated this revision to Diff 196911.
fgross added a comment.

Fixed format


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61209/new/

https://reviews.llvm.org/D61209

Files:
  clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
  clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-msvc.cpp

Index: clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-msvc.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-msvc.cpp
@@ -0,0 +1,95 @@
+// RUN: %check_clang_tidy %s readability-redundant-smartptr-get %t
+
+#define NULL __null
+
+namespace std {
+
+// MSVC headers define operator templates instead of plain operators.
+
+template 
+struct unique_ptr {
+  template 
+  T2& operator*() const;
+  template 
+  T2* operator->() const;
+  T* get() const;
+  explicit operator bool() const noexcept;
+};
+
+template 
+struct shared_ptr {
+  template 
+  T2& operator*() const;
+  template 
+  T2* operator->() const;
+  T* get() const;
+  explicit operator bool() const noexcept;
+};
+
+}  // namespace std
+
+struct Bar {
+  void Do();
+  void ConstDo() const;
+};
+
+void Positive() {
+
+  std::unique_ptr* up;
+  (*up->get()).Do();
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant get() call
+  // CHECK-MESSAGES: (*up->get()).Do();
+  // CHECK-FIXES: (**up).Do();
+
+  std::unique_ptr uu;
+  std::shared_ptr *ss;
+  bool bb = uu.get() == nullptr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: redundant get() call
+  // CHECK-MESSAGES: uu.get() == nullptr;
+  // CHECK-FIXES: bool bb = uu == nullptr;
+
+  if (up->get());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call
+  // CHECK-MESSAGES: if (up->get());
+  // CHECK-FIXES: if (*up);
+  if ((uu.get()));
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: if ((uu.get()));
+  // CHECK-FIXES: if ((uu));
+  bb = !ss->get();
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: redundant get() call
+  // CHECK-MESSAGES: bb = !ss->get();
+  // CHECK-FIXES: bb = !*ss;
+
+  bb = nullptr != ss->get();
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: redundant get() call
+  // CHECK-MESSAGES: nullptr != ss->get();
+  // CHECK-FIXES: bb = nullptr != *ss;
+
+  bb = std::unique_ptr().get() == NULL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: bb = std::unique_ptr().get() == NULL;
+  // CHECK-FIXES: bb = std::unique_ptr() == NULL;
+  bb = ss->get() == NULL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: bb = ss->get() == NULL;
+  // CHECK-FIXES: bb = *ss == NULL;
+
+  std::unique_ptr x, y;
+  if (x.get() == nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call
+  // CHECK-MESSAGES: if (x.get() == nullptr);
+  // CHECK-FIXES: if (x == nullptr);
+  if (nullptr == y.get());
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: redundant get() call
+  // CHECK-MESSAGES: if (nullptr == y.get());
+  // CHECK-FIXES: if (nullptr == y);
+  if (x.get() == NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call
+  // CHECK-MESSAGES: if (x.get() == NULL);
+  // CHECK-FIXES: if (x == NULL);
+  if (NULL == x.get());
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: redundant get() call
+  // CHECK-MESSAGES: if (NULL == x.get());
+  // CHECK-FIXES: if (NULL == x);
+}
\ No newline at end of file
Index: clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
@@ -30,6 +30,10 @@
   .bind("redundant_get");
 }
 
+internal::Matcher knownSmartptr() {
+  return recordDecl(hasAnyName("::std::unique_ptr", "::std::shared_ptr"));
+}
+
 void registerMatchersForGetArrowStart(MatchFinder *Finder,
   MatchFinder::MatchCallback *Callback) {
   const auto QuacksLikeASmartptr = recordDecl(
@@ -39,21 +43,23 @@
   has(cxxMethodDecl(hasName("operator*"), returns(qualType(references(
   type().bind("op*Type")));
 
+  // Make sure we are not missing the known standard types
+  const auto Smartptr = anyOf(knownSmartptr(), QuacksLikeASmartptr);
+
   // Catch 'ptr.get()->Foo()'
-  Finder->addMatcher(memberExpr(expr().bind("memberExpr"), isArrow(),
-hasObjectExpression(ignoringImpCasts(
-callToGet(QuacksLikeASmartptr,
- Callback);
+  Finder->addMatcher(
+  memberExpr(expr().bind("memberExpr"), isArrow(),
+ hasObjectExpression(ignoringImpCasts(callToGet(Smartptr,
+  Callback);
 
   // Catch '*ptr.get()' or '*ptr->get()'
   Finder->addMatcher(
-

[PATCH] D59474: [OpenMP 5.0] Codegen support for user-defined mappers

2019-04-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8021
+  /// the extracted map clauses.
+  void generateAllInfoForMapper(MapBaseValuesArrayTy ,
+MapValuesArrayTy ,

This code has too many common parts with the existing one. Is it possible to 
merge it somehow or outline into a function?



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8530
+  // dynamically.
+  QualType MapArrayType = Ctx.getConstantArrayType(
+  Ctx.getIntTypeForBitwidth(/*DestWidth*/ 64, /*Signed*/ true),

Hmm, how could you calculate the required size of the array for the mapper? Or 
this is constant?



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8588
+
+  if (IsMapper) {
+// Combine the map type inherited from user-defined mapper with that

I think it would be good to move this part to the runtime. We should just pass 
the mapper function to the runtime functions and the runtime should call those 
mapper functions and get base pointers, pointers, sizes and maptypes.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:8795
+  // Generate an asynchronous mapper function.
+  llvm::Function *AsyncFn = emitUDMapperFunc(D, /*NoWait=*/true);
+  // Add the generated mapper functions to UDMMap.

With the buffering-based implementation we need only function.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:351
+  /// is the asynchronous version.
+  llvm::DenseMap>

lildmh wrote:
> ABataev wrote:
> > You should be very careful with this map. If the mapper is declared in the 
> > function context, it must be removed from this map as soon as the function 
> > processing is completed. All local declarations are removed after this and 
> > their address might be used again.
> Yes, I plan to have this part in the next patch, which will implement to look 
> up the corresponding mapper function for map. to, from clauses
Noope, this must be the part of this patch, because it may cause the crash of 
the compiler during testing.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:800
+  /// Emit a function for a user defined mapper. Whether it is synchronous or
+  /// asynchronous depends on \a NoWait.
+  virtual llvm::Function *emitUDMapperFunc(const OMPDeclareMapperDecl *D,

I don't remember precisely, but probably `\a`->`\p`



Comment at: lib/CodeGen/CGOpenMPRuntime.h:804
+
+  // Emit the array initialization or deletion portion for user-defined mapper
+  // code generation.

Use `///` style of comment


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59474/new/

https://reviews.llvm.org/D59474



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


[PATCH] D61209: [clang-tidy] Fix readability-redundant-smartptr-get for MSVC STL

2019-04-26 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp:60
   // Catch '!ptr.get()'
-  const auto CallToGetAsBool = ignoringParenImpCasts(callToGet(recordDecl(
-  QuacksLikeASmartptr, has(cxxConversionDecl(returns(booleanType()));
+  const auto CallToGetAsBool = 
ignoringParenImpCasts(callToGet(recordDecl(Smartptr, 
has(cxxConversionDecl(returns(booleanType()));
   Finder->addMatcher(

not clang-formatted


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61209/new/

https://reviews.llvm.org/D61209



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


[PATCH] D60990: [Driver] Support priority for multilibs

2019-04-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 196905.
phosek marked an inline comment as done.
Herald added a subscriber: ormris.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60990/new/

https://reviews.llvm.org/D60990

Files:
  clang/include/clang/Driver/Multilib.h
  clang/lib/Driver/Multilib.cpp
  clang/unittests/Driver/MultilibTest.cpp


Index: clang/unittests/Driver/MultilibTest.cpp
===
--- clang/unittests/Driver/MultilibTest.cpp
+++ clang/unittests/Driver/MultilibTest.cpp
@@ -349,3 +349,27 @@
   Latte.combineWith(Milk);
   ASSERT_EQ(Latte.size(), (unsigned)2);
 }
+
+TEST(MultilibTest, SetPriority) {
+  MultilibSet MS;
+  MS.push_back(Multilib("noexcept", {}, {}, 1).flag("+fno-exceptions"));
+  MS.push_back(Multilib("asan", {}, {}, 2).flag("+fsanitize=address"));
+
+  Multilib::flags_list Flags1;
+  Flags1.push_back("+fno-exceptions");
+  Flags1.push_back("-fsanitize=address");
+  Multilib SelectionNoExcept;
+  ASSERT_TRUE(MS.select(Flags1, SelectionNoExcept))
+  << "Flag set was {\"+fno-exceptions\"}, but selection not found";
+  ASSERT_TRUE(SelectionNoExcept.gccSuffix() == "/noexcept")
+  << "Selection picked " << SelectionNoExcept << " which was not expected";
+
+  Multilib::flags_list Flags2;
+  Flags2.push_back("+fno-exceptions");
+  Flags2.push_back("+fsanitize=address");
+  Multilib SelectionASan;
+  ASSERT_TRUE(MS.select(Flags2, SelectionASan))
+  << "Flag set was {\"+fsanitize=address\"}, but selection not found";
+  ASSERT_TRUE(SelectionASan.gccSuffix() == "/asan")
+  << "Selection picked " << SelectionASan << " which was not expected";
+}
Index: clang/lib/Driver/Multilib.cpp
===
--- clang/lib/Driver/Multilib.cpp
+++ clang/lib/Driver/Multilib.cpp
@@ -51,8 +51,9 @@
 }
 
 Multilib::Multilib(StringRef GCCSuffix, StringRef OSSuffix,
-   StringRef IncludeSuffix)
-: GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix) {
+   StringRef IncludeSuffix, int Priority)
+: GCCSuffix(GCCSuffix), OSSuffix(OSSuffix), IncludeSuffix(IncludeSuffix),
+  Priority(Priority) {
   normalizePathSegment(this->GCCSuffix);
   normalizePathSegment(this->OSSuffix);
   normalizePathSegment(this->IncludeSuffix);
@@ -265,8 +266,19 @@
 return true;
   }
 
-  // TODO: pick the "best" multlib when more than one is suitable
-  assert(false);
+  // Sort multilibs by priority and select the one with the highest priority.
+  llvm::sort(Filtered.begin(), Filtered.end(),
+ [](const Multilib , const Multilib ) -> bool {
+   return a.priority() > b.priority();
+ });
+
+  if (Filtered[0].priority() > Filtered[1].priority()) {
+M = Filtered[0];
+return true;
+  }
+
+  // TODO: We should consider returning llvm::Error rather than aborting.
+  assert(false && "More than one multilib with the same priority");
   return false;
 }
 
Index: clang/include/clang/Driver/Multilib.h
===
--- clang/include/clang/Driver/Multilib.h
+++ clang/include/clang/Driver/Multilib.h
@@ -34,10 +34,11 @@
   std::string OSSuffix;
   std::string IncludeSuffix;
   flags_list Flags;
+  int Priority;
 
 public:
   Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
-   StringRef IncludeSuffix = {});
+   StringRef IncludeSuffix = {}, int Priority = 0);
 
   /// Get the detected GCC installation path suffix for the multi-arch
   /// target variant. Always starts with a '/', unless empty
@@ -77,6 +78,10 @@
   const flags_list () const { return Flags; }
   flags_list () { return Flags; }
 
+  /// Returns the multilib priority. When more than one multilib matches flags,
+  /// the one with the highest priority is selected, with 0 being the default.
+  int priority() const { return Priority; }
+
   /// Add a flag to the flags list
   /// \p Flag must be a flag accepted by the driver with its leading '-' 
removed,
   /// and replaced with either:


Index: clang/unittests/Driver/MultilibTest.cpp
===
--- clang/unittests/Driver/MultilibTest.cpp
+++ clang/unittests/Driver/MultilibTest.cpp
@@ -349,3 +349,27 @@
   Latte.combineWith(Milk);
   ASSERT_EQ(Latte.size(), (unsigned)2);
 }
+
+TEST(MultilibTest, SetPriority) {
+  MultilibSet MS;
+  MS.push_back(Multilib("noexcept", {}, {}, 1).flag("+fno-exceptions"));
+  MS.push_back(Multilib("asan", {}, {}, 2).flag("+fsanitize=address"));
+
+  Multilib::flags_list Flags1;
+  Flags1.push_back("+fno-exceptions");
+  Flags1.push_back("-fsanitize=address");
+  Multilib SelectionNoExcept;
+  ASSERT_TRUE(MS.select(Flags1, SelectionNoExcept))
+  << "Flag set was {\"+fno-exceptions\"}, but selection not found";
+  ASSERT_TRUE(SelectionNoExcept.gccSuffix() == "/noexcept")
+  << "Selection picked " << SelectionNoExcept << " which was not 

[PATCH] D61209: Fix readability-redundant-smartptr-get for MSVC STL

2019-04-26 Thread Florian Gross via Phabricator via cfe-commits
fgross created this revision.
fgross added reviewers: aaron.ballman, alexfh, sbenza.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The MSVC STL defines smart pointer `operator*` and `operator->` as method 
templates. The existing duck typing implementation doesn't catch this 
implementation. To keep the duck typing simple, I added the already existing 
list of known standard to the matchers in `registerMatchersForGetArrowStart`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D61209

Files:
  clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
  clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-msvc.cpp

Index: clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-msvc.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-msvc.cpp
@@ -0,0 +1,95 @@
+// RUN: %check_clang_tidy %s readability-redundant-smartptr-get %t
+
+#define NULL __null
+
+namespace std {
+
+// MSVC headers define operator templates instead of plain operators.
+
+template 
+struct unique_ptr {
+  template 
+  T2& operator*() const;
+  template 
+  T2* operator->() const;
+  T* get() const;
+  explicit operator bool() const noexcept;
+};
+
+template 
+struct shared_ptr {
+  template 
+  T2& operator*() const;
+  template 
+  T2* operator->() const;
+  T* get() const;
+  explicit operator bool() const noexcept;
+};
+
+}  // namespace std
+
+struct Bar {
+  void Do();
+  void ConstDo() const;
+};
+
+void Positive() {
+
+  std::unique_ptr* up;
+  (*up->get()).Do();
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant get() call
+  // CHECK-MESSAGES: (*up->get()).Do();
+  // CHECK-FIXES: (**up).Do();
+
+  std::unique_ptr uu;
+  std::shared_ptr *ss;
+  bool bb = uu.get() == nullptr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: redundant get() call
+  // CHECK-MESSAGES: uu.get() == nullptr;
+  // CHECK-FIXES: bool bb = uu == nullptr;
+
+  if (up->get());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call
+  // CHECK-MESSAGES: if (up->get());
+  // CHECK-FIXES: if (*up);
+  if ((uu.get()));
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: if ((uu.get()));
+  // CHECK-FIXES: if ((uu));
+  bb = !ss->get();
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: redundant get() call
+  // CHECK-MESSAGES: bb = !ss->get();
+  // CHECK-FIXES: bb = !*ss;
+
+  bb = nullptr != ss->get();
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: redundant get() call
+  // CHECK-MESSAGES: nullptr != ss->get();
+  // CHECK-FIXES: bb = nullptr != *ss;
+
+  bb = std::unique_ptr().get() == NULL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: bb = std::unique_ptr().get() == NULL;
+  // CHECK-FIXES: bb = std::unique_ptr() == NULL;
+  bb = ss->get() == NULL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+  // CHECK-MESSAGES: bb = ss->get() == NULL;
+  // CHECK-FIXES: bb = *ss == NULL;
+
+  std::unique_ptr x, y;
+  if (x.get() == nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call
+  // CHECK-MESSAGES: if (x.get() == nullptr);
+  // CHECK-FIXES: if (x == nullptr);
+  if (nullptr == y.get());
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: redundant get() call
+  // CHECK-MESSAGES: if (nullptr == y.get());
+  // CHECK-FIXES: if (nullptr == y);
+  if (x.get() == NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call
+  // CHECK-MESSAGES: if (x.get() == NULL);
+  // CHECK-FIXES: if (x == NULL);
+  if (NULL == x.get());
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: redundant get() call
+  // CHECK-MESSAGES: if (NULL == x.get());
+  // CHECK-FIXES: if (NULL == x);
+}
\ No newline at end of file
Index: clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
@@ -30,6 +30,10 @@
   .bind("redundant_get");
 }
 
+internal::Matcher knownSmartptr() {
+  return recordDecl(hasAnyName("::std::unique_ptr", "::std::shared_ptr"));
+}
+
 void registerMatchersForGetArrowStart(MatchFinder *Finder,
   MatchFinder::MatchCallback *Callback) {
   const auto QuacksLikeASmartptr = recordDecl(
@@ -39,21 +43,21 @@
   has(cxxMethodDecl(hasName("operator*"), returns(qualType(references(
   type().bind("op*Type")));
 
+  // Make sure we are not missing the known standard types
+  const auto Smartptr = anyOf(knownSmartptr(), QuacksLikeASmartptr);
+
   // Catch 'ptr.get()->Foo()'
   Finder->addMatcher(memberExpr(expr().bind("memberExpr"), isArrow(),
-hasObjectExpression(ignoringImpCasts(
-

[PATCH] D60990: [Driver] Support priority for multilibs

2019-04-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D60990#1475116 , @lebedev.ri wrote:

> Can this have test coverage?


Done, I've added a test.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60990/new/

https://reviews.llvm.org/D60990



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


[PATCH] D61177: [MinGW] Always emit local typeinfo

2019-04-26 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC359345: [MinGW] Always emit local typeinfo (authored by 
mstorsjo, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61177/new/

https://reviews.llvm.org/D61177

Files:
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/vtable-key-function-ios.cpp


Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2959,7 +2959,7 @@
 bool IsDLLImport = RD->hasAttr();
 
 // Don't import the RTTI but emit it locally.
-if (CGM.getTriple().isWindowsGNUEnvironment() && IsDLLImport)
+if (CGM.getTriple().isWindowsGNUEnvironment())
   return false;
 
 if (CGM.getVTables().isVTableExternal(RD))
Index: test/CodeGenCXX/vtable-key-function-ios.cpp
===
--- test/CodeGenCXX/vtable-key-function-ios.cpp
+++ test/CodeGenCXX/vtable-key-function-ios.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck 
-check-prefixes=CHECK,CHECK-UNIX %s
 // RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck 
-check-prefix=CHECK-LATE %s
 
-// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | 
FileCheck -check-prefixes=CHECK,CHECK-MINGW %s
 // RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | 
FileCheck -check-prefix=CHECK-LATE %s
 
 // The 'a' variants ask for the vtable first.
@@ -29,7 +29,8 @@
 // V-table should be defined externally.
 Test0a::Test0a() { use(typeid(Test0a)); }
 // CHECK: @_ZTV6Test0a = external {{(dso_local )?}}unnamed_addr constant 
-// CHECK: @_ZTI6Test0a = external {{(dso_local )?}}constant
+// CHECK-UNIX: @_ZTI6Test0a = external {{(dso_local )?}}constant
+// CHECK-MINGW: @_ZTI6Test0a = linkonce_odr {{(dso_local )?}}constant
 
 // This is not a key function.
 void Test0a::foo() {}
@@ -48,7 +49,8 @@
 // V-table should be defined externally.
 Test0b::Test0b() { use(typeid(Test0b)); }
 // CHECK: @_ZTV6Test0b = external {{(dso_local )?}}unnamed_addr constant 
-// CHECK: @_ZTI6Test0b = external {{(dso_local )?}}constant
+// CHECK-UNIX: @_ZTI6Test0b = external {{(dso_local )?}}constant
+// CHECK-MINGW: @_ZTI6Test0b = linkonce_odr {{(dso_local )?}}constant
 
 /*** Test1a **/
 


Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2959,7 +2959,7 @@
 bool IsDLLImport = RD->hasAttr();
 
 // Don't import the RTTI but emit it locally.
-if (CGM.getTriple().isWindowsGNUEnvironment() && IsDLLImport)
+if (CGM.getTriple().isWindowsGNUEnvironment())
   return false;
 
 if (CGM.getVTables().isVTableExternal(RD))
Index: test/CodeGenCXX/vtable-key-function-ios.cpp
===
--- test/CodeGenCXX/vtable-key-function-ios.cpp
+++ test/CodeGenCXX/vtable-key-function-ios.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck -check-prefixes=CHECK,CHECK-UNIX %s
 // RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s
 
-// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck -check-prefixes=CHECK,CHECK-MINGW %s
 // RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s
 
 // The 'a' variants ask for the vtable first.
@@ -29,7 +29,8 @@
 // V-table should be defined externally.
 Test0a::Test0a() { use(typeid(Test0a)); }
 // CHECK: @_ZTV6Test0a = external {{(dso_local )?}}unnamed_addr constant 
-// CHECK: @_ZTI6Test0a = external {{(dso_local )?}}constant
+// CHECK-UNIX: @_ZTI6Test0a = external {{(dso_local )?}}constant
+// CHECK-MINGW: @_ZTI6Test0a = linkonce_odr {{(dso_local )?}}constant
 
 // This is not a key function.
 void Test0a::foo() {}
@@ -48,7 +49,8 @@
 // V-table should be defined externally.
 Test0b::Test0b() { use(typeid(Test0b)); }
 // CHECK: @_ZTV6Test0b = external {{(dso_local )?}}unnamed_addr constant 
-// CHECK: @_ZTI6Test0b = external {{(dso_local )?}}constant
+// CHECK-UNIX: @_ZTI6Test0b = external {{(dso_local )?}}constant
+// CHECK-MINGW: @_ZTI6Test0b = linkonce_odr {{(dso_local )?}}constant
 
 /*** Test1a **/
 
___
cfe-commits mailing list

[PATCH] D61194: [HIP] Fix visibility of `__constant__` variables.

2019-04-26 Thread Michael Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC359344: [HIP] Fix visibility of `__constant__` variables. 
(authored by hliao, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61194?vs=196857=196902#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61194/new/

https://reviews.llvm.org/D61194

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenCUDA/amdgpu-visibility.cu


Index: test/CodeGenCUDA/amdgpu-visibility.cu
===
--- test/CodeGenCUDA/amdgpu-visibility.cu
+++ test/CodeGenCUDA/amdgpu-visibility.cu
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device 
-fapply-global-visibility-to-externs -fvisibility default -emit-llvm -o - %s | 
FileCheck --check-prefix=CHECK-DEFAULT %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device 
-fapply-global-visibility-to-externs -fvisibility protected -emit-llvm -o - %s 
| FileCheck --check-prefix=CHECK-PROTECTED %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device 
-fapply-global-visibility-to-externs -fvisibility hidden -emit-llvm -o - %s | 
FileCheck --check-prefix=CHECK-HIDDEN %s
+
+#include "Inputs/cuda.h"
+
+// CHECK-DEFAULT: @c = addrspace(4) externally_initialized global
+// CHECK-DEFAULT: @g = addrspace(1) externally_initialized global
+// CHECK-PROTECTED: @c = protected addrspace(4) externally_initialized global
+// CHECK-PROTECTED: @g = protected addrspace(1) externally_initialized global
+// CHECK-HIDDEN: @c = protected addrspace(4) externally_initialized global
+// CHECK-HIDDEN: @g = protected addrspace(1) externally_initialized global
+__constant__ int c;
+__device__ int g;
+
+// CHECK-DEFAULT: define amdgpu_kernel void @_Z3foov()
+// CHECK-PROTECTED: define protected amdgpu_kernel void @_Z3foov()
+// CHECK-HIDDEN: define protected amdgpu_kernel void @_Z3foov()
+__global__ void foo() {
+  g = c;
+}
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7847,7 +7847,8 @@
 
   return D->hasAttr() ||
  (isa(D) && D->hasAttr()) ||
- (isa(D) && D->hasAttr());
+ (isa(D) &&
+  (D->hasAttr() || D->hasAttr()));
 }
 
 void AMDGPUTargetCodeGenInfo::setTargetAttributes(


Index: test/CodeGenCUDA/amdgpu-visibility.cu
===
--- test/CodeGenCUDA/amdgpu-visibility.cu
+++ test/CodeGenCUDA/amdgpu-visibility.cu
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -fapply-global-visibility-to-externs -fvisibility default -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-DEFAULT %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -fapply-global-visibility-to-externs -fvisibility protected -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-PROTECTED %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -fapply-global-visibility-to-externs -fvisibility hidden -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-HIDDEN %s
+
+#include "Inputs/cuda.h"
+
+// CHECK-DEFAULT: @c = addrspace(4) externally_initialized global
+// CHECK-DEFAULT: @g = addrspace(1) externally_initialized global
+// CHECK-PROTECTED: @c = protected addrspace(4) externally_initialized global
+// CHECK-PROTECTED: @g = protected addrspace(1) externally_initialized global
+// CHECK-HIDDEN: @c = protected addrspace(4) externally_initialized global
+// CHECK-HIDDEN: @g = protected addrspace(1) externally_initialized global
+__constant__ int c;
+__device__ int g;
+
+// CHECK-DEFAULT: define amdgpu_kernel void @_Z3foov()
+// CHECK-PROTECTED: define protected amdgpu_kernel void @_Z3foov()
+// CHECK-HIDDEN: define protected amdgpu_kernel void @_Z3foov()
+__global__ void foo() {
+  g = c;
+}
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7847,7 +7847,8 @@
 
   return D->hasAttr() ||
  (isa(D) && D->hasAttr()) ||
- (isa(D) && D->hasAttr());
+ (isa(D) &&
+  (D->hasAttr() || D->hasAttr()));
 }
 
 void AMDGPUTargetCodeGenInfo::setTargetAttributes(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61176: [MinGW] Do dllexport inline methods in template instantiation

2019-04-26 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC359343: [MinGW] Do dllexport inline methods in template 
instantiation (authored by mstorsjo, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61176/new/

https://reviews.llvm.org/D61176

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/CodeGenCXX/mingw-template-dllexport.cpp


Index: test/CodeGenCXX/mingw-template-dllexport.cpp
===
--- test/CodeGenCXX/mingw-template-dllexport.cpp
+++ test/CodeGenCXX/mingw-template-dllexport.cpp
@@ -7,11 +7,9 @@
 
 template 
 class c {
-  void f();
+  void f() {}
 };
 
-template  void c::f() {}
-
 template class __declspec(dllexport) c;
 
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiE1fEv
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -5726,9 +5726,12 @@
 continue;
 
   if (MD->isInlined()) {
-// MinGW does not import or export inline methods.
+// MinGW does not import or export inline methods. But do it for
+// template instantiations.
 if (!Context.getTargetInfo().getCXXABI().isMicrosoft() &&
-!Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())
+!Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment() 
&&
+TSK != TSK_ExplicitInstantiationDeclaration &&
+TSK != TSK_ExplicitInstantiationDefinition)
   continue;
 
 // MSVC versions before 2015 don't export the move assignment operators


Index: test/CodeGenCXX/mingw-template-dllexport.cpp
===
--- test/CodeGenCXX/mingw-template-dllexport.cpp
+++ test/CodeGenCXX/mingw-template-dllexport.cpp
@@ -7,11 +7,9 @@
 
 template 
 class c {
-  void f();
+  void f() {}
 };
 
-template  void c::f() {}
-
 template class __declspec(dllexport) c;
 
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiE1fEv
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -5726,9 +5726,12 @@
 continue;
 
   if (MD->isInlined()) {
-// MinGW does not import or export inline methods.
+// MinGW does not import or export inline methods. But do it for
+// template instantiations.
 if (!Context.getTargetInfo().getCXXABI().isMicrosoft() &&
-!Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())
+!Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment() &&
+TSK != TSK_ExplicitInstantiationDeclaration &&
+TSK != TSK_ExplicitInstantiationDefinition)
   continue;
 
 // MSVC versions before 2015 don't export the move assignment operators
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61175: [MinGW] Don't let template instantiation declarations cover nested classes

2019-04-26 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC359342: [MinGW] Dont let template instantiation 
declarations cover nested classes (authored by mstorsjo, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61175/new/

https://reviews.llvm.org/D61175

Files:
  lib/Sema/SemaTemplateInstantiate.cpp
  test/CodeGenCXX/mingw-template-dllexport.cpp


Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -2685,10 +2685,14 @@
 continue;
 
   if ((Context.getTargetInfo().getCXXABI().isMicrosoft() ||
-   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) 
&&
+   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment() ||
+   Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) &&
   TSK == TSK_ExplicitInstantiationDeclaration) {
 // In MSVC and Windows Itanium mode, explicit instantiation decl of the
 // outer class doesn't affect the inner class.
+// In GNU mode, inner classes aren't dllexported. Don't let the
+// instantiation cover the inner class, to avoid undefined references
+// to inner classes that weren't exported.
 continue;
   }
 
Index: test/CodeGenCXX/mingw-template-dllexport.cpp
===
--- test/CodeGenCXX/mingw-template-dllexport.cpp
+++ test/CodeGenCXX/mingw-template-dllexport.cpp
@@ -1,5 +1,10 @@
 // RUN: %clang_cc1 -emit-llvm -triple i686-mingw32 %s -o - | FileCheck %s
 
+#define JOIN2(x, y) x##y
+#define JOIN(x, y) JOIN2(x, y)
+#define UNIQ(name) JOIN(name, __LINE__)
+#define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return 
::func; }
+
 template 
 class c {
   void f();
@@ -36,3 +41,10 @@
 
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN5outerIiE1fEv
 // CHECK-NOT: define {{.*}} dllexport {{.*}} @_ZN5outerIiE5inner1fEv
+
+extern template class __declspec(dllimport) outer;
+USEMEMFUNC(outer, f)
+USEMEMFUNC(outer::inner, f)
+
+// CHECK: declare dllimport {{.*}} @_ZN5outerIcE1fEv
+// CHECK: define {{.*}} @_ZN5outerIcE5inner1fEv


Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -2685,10 +2685,14 @@
 continue;
 
   if ((Context.getTargetInfo().getCXXABI().isMicrosoft() ||
-   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) &&
+   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment() ||
+   Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) &&
   TSK == TSK_ExplicitInstantiationDeclaration) {
 // In MSVC and Windows Itanium mode, explicit instantiation decl of the
 // outer class doesn't affect the inner class.
+// In GNU mode, inner classes aren't dllexported. Don't let the
+// instantiation cover the inner class, to avoid undefined references
+// to inner classes that weren't exported.
 continue;
   }
 
Index: test/CodeGenCXX/mingw-template-dllexport.cpp
===
--- test/CodeGenCXX/mingw-template-dllexport.cpp
+++ test/CodeGenCXX/mingw-template-dllexport.cpp
@@ -1,5 +1,10 @@
 // RUN: %clang_cc1 -emit-llvm -triple i686-mingw32 %s -o - | FileCheck %s
 
+#define JOIN2(x, y) x##y
+#define JOIN(x, y) JOIN2(x, y)
+#define UNIQ(name) JOIN(name, __LINE__)
+#define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return ::func; }
+
 template 
 class c {
   void f();
@@ -36,3 +41,10 @@
 
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN5outerIiE1fEv
 // CHECK-NOT: define {{.*}} dllexport {{.*}} @_ZN5outerIiE5inner1fEv
+
+extern template class __declspec(dllimport) outer;
+USEMEMFUNC(outer, f)
+USEMEMFUNC(outer::inner, f)
+
+// CHECK: declare dllimport {{.*}} @_ZN5outerIcE1fEv
+// CHECK: define {{.*}} @_ZN5outerIcE5inner1fEv
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r359343 - [MinGW] Do dllexport inline methods in template instantiation

2019-04-26 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Fri Apr 26 12:31:46 2019
New Revision: 359343

URL: http://llvm.org/viewvc/llvm-project?rev=359343=rev
Log:
[MinGW] Do dllexport inline methods in template instantiation

Normally, in MinGW mode, inline methods aren't dllexported.

However, in the case of a dllimported template instantiation,
the inline methods aren't instantiated locally, but referenced
from the instantiation. Therefore, those methods also need to
be dllexported, in the case of an instantiation.

GCC suffers from the same issue, reported at [1], but the issue
is still unresolved there.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89088

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

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=359343=359342=359343=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Apr 26 12:31:46 2019
@@ -5726,9 +5726,12 @@ void Sema::checkClassLevelDLLAttribute(C
 continue;
 
   if (MD->isInlined()) {
-// MinGW does not import or export inline methods.
+// MinGW does not import or export inline methods. But do it for
+// template instantiations.
 if (!Context.getTargetInfo().getCXXABI().isMicrosoft() &&
-!Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())
+!Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment() 
&&
+TSK != TSK_ExplicitInstantiationDeclaration &&
+TSK != TSK_ExplicitInstantiationDefinition)
   continue;
 
 // MSVC versions before 2015 don't export the move assignment operators

Modified: cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp?rev=359343=359342=359343=diff
==
--- cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp Fri Apr 26 12:31:46 
2019
@@ -7,11 +7,9 @@
 
 template 
 class c {
-  void f();
+  void f() {}
 };
 
-template  void c::f() {}
-
 template class __declspec(dllexport) c;
 
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiE1fEv


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


r359345 - [MinGW] Always emit local typeinfo

2019-04-26 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Fri Apr 26 12:31:51 2019
New Revision: 359345

URL: http://llvm.org/viewvc/llvm-project?rev=359345=rev
Log:
[MinGW] Always emit local typeinfo

This makes sure that code built with headers for a statically linked
libc++ also works when linking to the DLL version, when the DLL
hasn't been built with --export-all-symbols.

This matches what GCC for MinGW does for this test case.

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

Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/vtable-key-function-ios.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=359345=359344=359345=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Fri Apr 26 12:31:51 2019
@@ -2959,7 +2959,7 @@ static bool ShouldUseExternalRTTIDescrip
 bool IsDLLImport = RD->hasAttr();
 
 // Don't import the RTTI but emit it locally.
-if (CGM.getTriple().isWindowsGNUEnvironment() && IsDLLImport)
+if (CGM.getTriple().isWindowsGNUEnvironment())
   return false;
 
 if (CGM.getVTables().isVTableExternal(RD))

Modified: cfe/trunk/test/CodeGenCXX/vtable-key-function-ios.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtable-key-function-ios.cpp?rev=359345=359344=359345=diff
==
--- cfe/trunk/test/CodeGenCXX/vtable-key-function-ios.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/vtable-key-function-ios.cpp Fri Apr 26 12:31:51 
2019
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck 
-check-prefixes=CHECK,CHECK-UNIX %s
 // RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck 
-check-prefix=CHECK-LATE %s
 
-// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | 
FileCheck -check-prefixes=CHECK,CHECK-MINGW %s
 // RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | 
FileCheck -check-prefix=CHECK-LATE %s
 
 // The 'a' variants ask for the vtable first.
@@ -29,7 +29,8 @@ struct Test0a {
 // V-table should be defined externally.
 Test0a::Test0a() { use(typeid(Test0a)); }
 // CHECK: @_ZTV6Test0a = external {{(dso_local )?}}unnamed_addr constant 
-// CHECK: @_ZTI6Test0a = external {{(dso_local )?}}constant
+// CHECK-UNIX: @_ZTI6Test0a = external {{(dso_local )?}}constant
+// CHECK-MINGW: @_ZTI6Test0a = linkonce_odr {{(dso_local )?}}constant
 
 // This is not a key function.
 void Test0a::foo() {}
@@ -48,7 +49,8 @@ void Test0b::foo() {}
 // V-table should be defined externally.
 Test0b::Test0b() { use(typeid(Test0b)); }
 // CHECK: @_ZTV6Test0b = external {{(dso_local )?}}unnamed_addr constant 
-// CHECK: @_ZTI6Test0b = external {{(dso_local )?}}constant
+// CHECK-UNIX: @_ZTI6Test0b = external {{(dso_local )?}}constant
+// CHECK-MINGW: @_ZTI6Test0b = linkonce_odr {{(dso_local )?}}constant
 
 /*** Test1a **/
 


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


r359342 - [MinGW] Don't let template instantiation declarations cover nested classes

2019-04-26 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Fri Apr 26 12:31:39 2019
New Revision: 359342

URL: http://llvm.org/viewvc/llvm-project?rev=359342=rev
Log:
[MinGW] Don't let template instantiation declarations cover nested classes

An explicit template instantiation declaration used to let
callers assume both outer and nested classes instantiations were
defined in a different translation unit.

If the instantiation is marked dllexport, only the outer class
is exported, but the caller will try to reference the instantiation
of both outer and inner classes.

This makes MinGW mode match both MSVC and Windows Itanium, by
having instantations only cover the outer class, and locally emitting
definitions of the nested classes. Windows Itanium was changed to
use this behavious in SVN r300804.

This deviates from what GCC does, but should be safe (and only
inflate the object file size a bit, but MSVC and Windows Itanium
modes do the same), and fixes cases where inner classes aren't
dllexported.

This fixes missing references in combination with dllexported/imported
template intantiations.

GCC suffers from the same issue, reported at [1], but the issue
is still unresolved there. The issue can probably be solved either
by making dllexport cover all nested classes as well, or this
way (matching MSVC).

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89087

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

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=359342=359341=359342=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Fri Apr 26 12:31:39 2019
@@ -2685,10 +2685,14 @@ Sema::InstantiateClassMembers(SourceLoca
 continue;
 
   if ((Context.getTargetInfo().getCXXABI().isMicrosoft() ||
-   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) 
&&
+   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment() ||
+   Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) &&
   TSK == TSK_ExplicitInstantiationDeclaration) {
 // In MSVC and Windows Itanium mode, explicit instantiation decl of the
 // outer class doesn't affect the inner class.
+// In GNU mode, inner classes aren't dllexported. Don't let the
+// instantiation cover the inner class, to avoid undefined references
+// to inner classes that weren't exported.
 continue;
   }
 

Modified: cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp?rev=359342=359341=359342=diff
==
--- cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp Fri Apr 26 12:31:39 
2019
@@ -1,5 +1,10 @@
 // RUN: %clang_cc1 -emit-llvm -triple i686-mingw32 %s -o - | FileCheck %s
 
+#define JOIN2(x, y) x##y
+#define JOIN(x, y) JOIN2(x, y)
+#define UNIQ(name) JOIN(name, __LINE__)
+#define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return 
::func; }
+
 template 
 class c {
   void f();
@@ -36,3 +41,10 @@ template class __declspec(dllexport) out
 
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN5outerIiE1fEv
 // CHECK-NOT: define {{.*}} dllexport {{.*}} @_ZN5outerIiE5inner1fEv
+
+extern template class __declspec(dllimport) outer;
+USEMEMFUNC(outer, f)
+USEMEMFUNC(outer::inner, f)
+
+// CHECK: declare dllimport {{.*}} @_ZN5outerIcE1fEv
+// CHECK: define {{.*}} @_ZN5outerIcE5inner1fEv


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


r359344 - [HIP] Fix visibility of `__constant__` variables.

2019-04-26 Thread Michael Liao via cfe-commits
Author: hliao
Date: Fri Apr 26 12:31:48 2019
New Revision: 359344

URL: http://llvm.org/viewvc/llvm-project?rev=359344=rev
Log:
[HIP] Fix visibility of `__constant__` variables.

Summary:
- `__constant__` variables should not be `hidden` as the linker may turn
  them into `LOCAL` symbols.

Reviewers: yaxunl

Subscribers: jvesely, nhaehnle, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeGenCUDA/amdgpu-visibility.cu
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=359344=359343=359344=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Apr 26 12:31:48 2019
@@ -7847,7 +7847,8 @@ static bool requiresAMDGPUProtectedVisib
 
   return D->hasAttr() ||
  (isa(D) && D->hasAttr()) ||
- (isa(D) && D->hasAttr());
+ (isa(D) &&
+  (D->hasAttr() || D->hasAttr()));
 }
 
 void AMDGPUTargetCodeGenInfo::setTargetAttributes(

Added: cfe/trunk/test/CodeGenCUDA/amdgpu-visibility.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/amdgpu-visibility.cu?rev=359344=auto
==
--- cfe/trunk/test/CodeGenCUDA/amdgpu-visibility.cu (added)
+++ cfe/trunk/test/CodeGenCUDA/amdgpu-visibility.cu Fri Apr 26 12:31:48 2019
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device 
-fapply-global-visibility-to-externs -fvisibility default -emit-llvm -o - %s | 
FileCheck --check-prefix=CHECK-DEFAULT %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device 
-fapply-global-visibility-to-externs -fvisibility protected -emit-llvm -o - %s 
| FileCheck --check-prefix=CHECK-PROTECTED %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device 
-fapply-global-visibility-to-externs -fvisibility hidden -emit-llvm -o - %s | 
FileCheck --check-prefix=CHECK-HIDDEN %s
+
+#include "Inputs/cuda.h"
+
+// CHECK-DEFAULT: @c = addrspace(4) externally_initialized global
+// CHECK-DEFAULT: @g = addrspace(1) externally_initialized global
+// CHECK-PROTECTED: @c = protected addrspace(4) externally_initialized global
+// CHECK-PROTECTED: @g = protected addrspace(1) externally_initialized global
+// CHECK-HIDDEN: @c = protected addrspace(4) externally_initialized global
+// CHECK-HIDDEN: @g = protected addrspace(1) externally_initialized global
+__constant__ int c;
+__device__ int g;
+
+// CHECK-DEFAULT: define amdgpu_kernel void @_Z3foov()
+// CHECK-PROTECTED: define protected amdgpu_kernel void @_Z3foov()
+// CHECK-HIDDEN: define protected amdgpu_kernel void @_Z3foov()
+__global__ void foo() {
+  g = c;
+}


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


r359340 - [OPENMP]Added check for non-random access types for the dependent loop

2019-04-26 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Apr 26 12:28:37 2019
New Revision: 359340

URL: http://llvm.org/viewvc/llvm-project?rev=359340=rev
Log:
[OPENMP]Added check for non-random access types for the dependent loop
counters.

According to the OpenMP 5.0, For any associated loop where the b or lb
expression is not loop invariant with respect to the outermost loop, the
var-outer that appears in the expression may not have a random access
iterator type.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_loop_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=359340=359339=359340=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Apr 26 12:28:37 
2019
@@ -9177,8 +9177,10 @@ def err_omp_expected_private_copy_for_al
   "the referenced item is not found in any private clause on the same 
directive">;
 def err_omp_stmt_depends_on_loop_counter : Error<
   "the loop %select{initializer|condition}0 expression depends on the current 
loop control variable">;
-def err_omp_invariant_or_linear_dependancy : Error<
+def err_omp_invariant_or_linear_dependency : Error<
   "expected loop invariant expression or ' * %0 + ' 
kind of expression">;
+def err_omp_wrong_dependency_iterator_type : Error<
+  "expected an integer or a pointer type of the outer loop counter '%0' for 
non-rectangular nests">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=359340=359339=359340=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Apr 26 12:28:37 2019
@@ -4520,8 +4520,16 @@ class OpenMPIterationSpaceChecker {
   bool TestIsStrictOp = false;
   /// This flag is true when step is subtracted on each iteration.
   bool SubtractStep = false;
+  /// The outer loop counter this loop depends on (if any).
+  const ValueDecl *DepDecl = nullptr;
+  /// Contains number of loop (starts from 1) on which loop counter init
+  /// expression of this loop depends on.
+  Optional InitDependOnLC;
+  /// Contains number of loop (starts from 1) on which loop counter condition
+  /// expression of this loop depends on.
+  Optional CondDependOnLC;
   /// Checks if the provide statement depends on the loop counter.
-  bool doesDependOnLoopCounter(const Stmt *S, bool IsInitializer) const;
+  Optional doesDependOnLoopCounter(const Stmt *S, bool 
IsInitializer);
 
 public:
   OpenMPIterationSpaceChecker(Sema , DSAStackTy ,
@@ -4622,7 +4630,7 @@ bool OpenMPIterationSpaceChecker::setLCD
 NewLB = CE->getArg(0)->IgnoreParenImpCasts();
   LB = NewLB;
   if (EmitDiags)
-(void)doesDependOnLoopCounter(LB, /*IsInitializer=*/true);
+InitDependOnLC = doesDependOnLoopCounter(LB, /*IsInitializer=*/true);
   return false;
 }
 
@@ -4641,7 +4649,7 @@ bool OpenMPIterationSpaceChecker::setUB(
   TestIsStrictOp = StrictOp;
   ConditionSrcRange = SR;
   ConditionLoc = SL;
-  (void)doesDependOnLoopCounter(UB, /*IsInitializer=*/false);
+  CondDependOnLC = doesDependOnLoopCounter(UB, /*IsInitializer=*/false);
   return false;
 }
 
@@ -4716,58 +4724,62 @@ class LoopCounterRefChecker final
   DSAStackTy 
   const ValueDecl *CurLCDecl = nullptr;
   const ValueDecl *DepDecl = nullptr;
+  const ValueDecl *PrevDepDecl = nullptr;
   bool IsInitializer = true;
+  unsigned BaseLoopId = 0;
+  bool checkDecl(const Expr *E, const ValueDecl *VD) {
+if (getCanonicalDecl(VD) == getCanonicalDecl(CurLCDecl)) {
+  SemaRef.Diag(E->getExprLoc(), diag::err_omp_stmt_depends_on_loop_counter)
+  << (IsInitializer ? 0 : 1);
+  return false;
+}
+const auto & = Stack.isLoopControlVariable(VD);
+// OpenMP, 2.9.1 Canonical Loop Form, Restrictions.
+// The type of the loop iterator on which we depend may not have a random
+// access iterator type.
+if (Data.first && VD->getType()->isRecordType()) {
+  SmallString<128> Name;
+  llvm::raw_svector_ostream OS(Name);
+  VD->getNameForDiagnostic(OS, SemaRef.getPrintingPolicy(),
+   /*Qualified=*/true);
+  SemaRef.Diag(E->getExprLoc(),
+   diag::err_omp_wrong_dependency_iterator_type)
+  << OS.str();
+  SemaRef.Diag(VD->getLocation(), diag::note_previous_decl) << VD;
+  return false;
+}
+if (Data.first &&
+(DepDecl || (PrevDepDecl &&
+ getCanonicalDecl(VD) != getCanonicalDecl(PrevDepDecl {
+  if (!DepDecl && PrevDepDecl)
+DepDecl = PrevDepDecl;
+  

[PATCH] D61194: [HIP] Fix visibility of `__constant__` variables.

2019-04-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61194/new/

https://reviews.llvm.org/D61194



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


[PATCH] D60349: [COFF, ARM64] Fix ABI implementation of struct returns

2019-04-26 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 196894.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60349/new/

https://reviews.llvm.org/D60349

Files:
  include/clang/AST/DeclCXX.h
  include/clang/CodeGen/CGFunctionInfo.h
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/CodeGen/arm64-microsoft-arguments.cpp
  test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp

Index: test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
===
--- test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
+++ test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
@@ -69,6 +69,11 @@
   int bb;
 };
 
+struct SmallWithPrivate {
+private:
+ int i;
+};
+
 // WIN32: declare dso_local void @"{{.*take_bools_and_chars.*}}"
 // WIN32:   (<{ i8, [3 x i8], i8, [3 x i8], %struct.SmallWithDtor,
 // WIN32:   i8, [3 x i8], i8, [3 x i8], i32, i8, [3 x i8] }>* inalloca)
@@ -165,7 +170,7 @@
 // WIN64:   call void @"??1SmallWithDtor@@QEAA@XZ"
 // WIN64: }
 // WOA64: define dso_local void @"?small_arg_with_dtor@@YAXUSmallWithDtor@@@Z"(i64 %s.coerce) {{.*}} {
-// WOA64:   call void @"??1SmallWithDtor@@QEAA@XZ"
+// WOA64:   call void @"??1SmallWithDtor@@QEAA@XZ"(%struct.SmallWithDtor* %s)
 // WOA64: }
 
 // FIXME: MSVC incompatible!
@@ -173,6 +178,12 @@
 // WOA:   call arm_aapcs_vfpcc void @"??1SmallWithDtor@@QAA@XZ"(%struct.SmallWithDtor* %s)
 // WOA: }
 
+
+// Test that the eligible non-aggregate is passed directly, but returned
+// indirectly on ARM64 Windows.
+// WOA64: define dso_local void @"?small_arg_with_private_member@@YA?AUSmallWithPrivate@@U1@@Z"(%struct.SmallWithPrivate* inreg noalias sret %agg.result, i64 %s.coerce) {{.*}} {
+SmallWithPrivate small_arg_with_private_member(SmallWithPrivate s) { return s; }
+
 void call_small_arg_with_dtor() {
   small_arg_with_dtor(SmallWithDtor());
 }
Index: test/CodeGen/arm64-microsoft-arguments.cpp
===
--- test/CodeGen/arm64-microsoft-arguments.cpp
+++ test/CodeGen/arm64-microsoft-arguments.cpp
@@ -1,25 +1,88 @@
 // RUN: %clang_cc1 -triple aarch64-windows -ffreestanding -emit-llvm -O0 \
 // RUN: -x c++ -o - %s | FileCheck %s
 
-struct pod { int a, b, c, d, e; };
+// Pass and return for type size <= 8 bytes.
+// CHECK: define {{.*}} i64 @{{.*}}f1{{.*}}()
+// CHECK: call i64 {{.*}}func1{{.*}}(i64 %3)
+struct S1 {
+  int a[2];
+};
+
+S1 func1(S1 x);
+S1 f1() {
+  S1 x;
+  return func1(x);
+}
 
-struct non_pod {
-  int a;
-  non_pod() {}
+// Pass and return type size <= 16 bytes.
+// CHECK: define {{.*}} [2 x i64] @{{.*}}f2{{.*}}()
+// CHECK: call [2 x i64] {{.*}}func2{{.*}}([2 x i64] %3)
+struct S2 {
+  int a[4];
 };
 
-struct pod s;
-struct non_pod t;
+S2 func2(S2 x);
+S2 f2() {
+  S2 x;
+  return func2(x);
+}
+
+// Pass and return for type size > 16 bytes.
+// CHECK: define {{.*}} void @{{.*}}f3{{.*}}(%struct.S3* noalias sret %agg.result)
+// CHECK: call void {{.*}}func3{{.*}}(%struct.S3* sret %agg.result, %struct.S3* %agg.tmp)
+struct S3 {
+  int a[5];
+};
+
+S3 func3(S3 x);
+S3 f3() {
+  S3 x;
+  return func3(x);
+}
+
+// Pass and return aggregate (of size < 16 bytes) with non-trivial destructor.
+// Passed directly but returned indirectly.
+// CHECK: define {{.*}} void {{.*}}f4{{.*}}(%struct.S4* inreg noalias sret %agg.result)
+// CHECK: call void {{.*}}func4{{.*}}(%struct.S4* inreg sret %agg.result, [2 x i64] %4)
+struct S4 {
+  int a[3];
+  ~S4();
+};
 
-struct pod bar() { return s; }
-struct non_pod foo() { return t; }
-// CHECK: define {{.*}} void @{{.*}}bar{{.*}}(%struct.pod* noalias sret %agg.result)
-// CHECK: define {{.*}} void @{{.*}}foo{{.*}}(%struct.non_pod* noalias %agg.result)
+S4 func4(S4 x);
+S4 f4() {
+  S4 x;
+  return func4(x);
+}
 
+// Pass and return from instance method called from instance method.
+// CHECK: define {{.*}} void @{{.*}}bar@Q1{{.*}}(%class.Q1* %this, %class.P1* inreg noalias sret %agg.result)
+// CHECK: call void {{.*}}foo@P1{{.*}}(%class.P1* %ref.tmp, %class.P1* inreg sret %agg.result, i8 %0)
 
-// Check instance methods.
-struct pod2 { int x; };
-struct Baz { pod2 baz(); };
+class P1 {
+public:
+  P1 foo(P1 x);
+};
+
+class Q1 {
+public:
+  P1 bar();
+};
+
+P1 Q1::bar() {
+  P1 p1;
+  return P1().foo(p1);
+}
+
+// Pass and return from instance method called from free function.
+// CHECK: define {{.*}} void {{.*}}bar{{.*}}()
+// CHECK: call void {{.*}}foo@P2{{.*}}(%class.P2* %ref.tmp, %class.P2* inreg sret %retval, i8 %0)
+class P2 {
+public:
+  P2 foo(P2 x);
+};
 
-int qux() { return Baz().baz().x; }
-// CHECK: declare {{.*}} void @{{.*}}baz@Baz{{.*}}(%struct.Baz*, %struct.pod2*)
+P2 bar() {
+  P2 p2;
+  return P2().foo(p2);
+}
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -5952,8 +5952,11 @@
 
 // Note: This permits small classes with nontrivial destructors to be
 // passed in 

[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-04-26 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In D60283#1480546 , @aganea wrote:

> Thanks Paul, your solution is even better. I'll apply rL11 
>  locally - if everything's fine, do you 
> mind if I re-land it again?


I suggest you do *not* use my patch unmodified, because it stops generating any 
checksums as soon as it finds one preprocessed file.  The functionality in your 
patch seems better, to skip checksums only for those files that look like they 
were preprocessed.   If you want to take my patch and remove the extra flag 
from CGDebugInfo that "remembers" that we've previously seen a file with line 
directives, that would be fine.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60283/new/

https://reviews.llvm.org/D60283



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


r359338 - [ASTImporter] Copy Argument Passing Restrictions setting when importing a CXXRecordDecl definition

2019-04-26 Thread Shafik Yaghmour via cfe-commits
Author: shafik
Date: Fri Apr 26 11:51:28 2019
New Revision: 359338

URL: http://llvm.org/viewvc/llvm-project?rev=359338=rev
Log:
[ASTImporter] Copy Argument Passing Restrictions setting when importing a 
CXXRecordDecl definition

Summary:
For a CXXRecordDecl the RecordDeclBits are stored in the DeclContext. Currently 
when we import the definition of a CXXRecordDecl via the ASTImporter we do not 
copy over this data.
This change will add support for copying the ArgPassingRestrictions from 
RecordDeclBits to fix an LLDB expression parsing bug where we would set it to 
not pass in registers.
Note, we did not copy over any other of the RecordDeclBits since we don't have 
tests for those. We know that copying over LoadedFieldsFromExternalStorage 
would be a error and that may be the case for others as well.

The companion LLDB review: https://reviews.llvm.org/D61146

Differential Review: https://reviews.llvm.org/D61140

Added:
cfe/trunk/test/Import/cxx-record-flags/
cfe/trunk/test/Import/cxx-record-flags/Inputs/
cfe/trunk/test/Import/cxx-record-flags/Inputs/F.cpp
cfe/trunk/test/Import/cxx-record-flags/test.cpp
Modified:
cfe/trunk/lib/AST/ASTImporter.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=359338=359337=359338=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Fri Apr 26 11:51:28 2019
@@ -1767,6 +1767,9 @@ Error ASTNodeImporter::ImportDefinition(
 ToData.HasDeclaredCopyAssignmentWithConstParam
   = FromData.HasDeclaredCopyAssignmentWithConstParam;
 
+// Copy over the data stored in RecordDeclBits
+ToCXX->setArgPassingRestrictions(FromCXX->getArgPassingRestrictions());
+
 SmallVector Bases;
 for (const auto  : FromCXX->bases()) {
   ExpectedType TyOrErr = import(Base1.getType());

Added: cfe/trunk/test/Import/cxx-record-flags/Inputs/F.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-record-flags/Inputs/F.cpp?rev=359338=auto
==
--- cfe/trunk/test/Import/cxx-record-flags/Inputs/F.cpp (added)
+++ cfe/trunk/test/Import/cxx-record-flags/Inputs/F.cpp Fri Apr 26 11:51:28 2019
@@ -0,0 +1,9 @@
+class FTrivial {
+  int i;
+};
+
+struct FNonTrivial {
+  virtual ~FNonTrivial() = default;
+  int i;
+};
+

Added: cfe/trunk/test/Import/cxx-record-flags/test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-record-flags/test.cpp?rev=359338=auto
==
--- cfe/trunk/test/Import/cxx-record-flags/test.cpp (added)
+++ cfe/trunk/test/Import/cxx-record-flags/test.cpp Fri Apr 26 11:51:28 2019
@@ -0,0 +1,14 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: FTrivial
+// CHECK: DefinitionData
+// CHECK-SAME: pass_in_registers
+
+// CHECK: FNonTrivial
+// CHECK-NOT: pass_in_registers
+// CHECK: DefaultConstructor
+
+void expr() {
+  FTrivial f1;
+  FNonTrivial f2;
+}


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


[PATCH] D61194: [HIP] Fix visibility of `__constant__` variables.

2019-04-26 Thread Michael Liao via Phabricator via cfe-commits
hliao marked an inline comment as done.
hliao added inline comments.



Comment at: clang/test/CodeGenCUDA/amdgpu-visibility.cu:1
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device 
-fapply-global-visibility-to-externs -fvisibility default -emit-llvm -o - %s | 
FileCheck --check-prefix=CHECK-DEFAULT %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device 
-fapply-global-visibility-to-externs -fvisibility protected -emit-llvm -o - %s 
| FileCheck --check-prefix=CHECK-PROTECTED %s

yaxunl wrote:
> do we need -fapply-global-visibility-to-externs?
that's so far the option applied for both AMDGPU & HIP (targetting non-MS) by 
default in clang frontend. Check AMDGPUToolChain::addClangTargetOptions and  
HIPToolChain::addClangTargetOptions


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61194/new/

https://reviews.llvm.org/D61194



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


[PATCH] D61194: [HIP] Fix visibility of `__constant__` variables.

2019-04-26 Thread Michael Liao via Phabricator via cfe-commits
hliao marked an inline comment as done.
hliao added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:7851
+ (isa(D) &&
+  (D->hasAttr() || D->hasAttr()));
 }

yaxunl wrote:
> is format right?
yeah, it's the format after clang-format. It seems that clang-format try to 
apply the same indent for LHS & RHS of a binary operator. With the leading 
parenthesis, RHS in a newline is indented with one more space.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61194/new/

https://reviews.llvm.org/D61194



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


[PATCH] D61194: [HIP] Fix visibility of `__constant__` variables.

2019-04-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:7851
+ (isa(D) &&
+  (D->hasAttr() || D->hasAttr()));
 }

is format right?



Comment at: clang/test/CodeGenCUDA/amdgpu-visibility.cu:1
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device 
-fapply-global-visibility-to-externs -fvisibility default -emit-llvm -o - %s | 
FileCheck --check-prefix=CHECK-DEFAULT %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device 
-fapply-global-visibility-to-externs -fvisibility protected -emit-llvm -o - %s 
| FileCheck --check-prefix=CHECK-PROTECTED %s

do we need -fapply-global-visibility-to-externs?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61194/new/

https://reviews.llvm.org/D61194



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


[PATCH] D59168: [runtimes] Move libunwind, libc++abi and libc++ to lib/clang/ and include/

2019-04-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D59168#1480428 , @jdenny wrote:

> It seems we have roughly the same situation for their ABIs.  That is, for .so 
> files, someone noted that libc++ and libunwind have always used the same 
> version, .1, and openmp doesn't use a version (except in Debian packages).  
> In other words, for each of these three, a change in ABI compatibility has 
> never been indicated.  For openmp only, it's apparently assumed a change 
> never will need to be indicated (except in Debian packages).


They already use `.2` for ABI v2 which is currently considered unstable but 
some project like Fuchsia already use. There's also an ongoing discussion to 
stabilize v2 
. However, 
this is only affecting the ABI and therefore `.so`, not headers which will 
continue using v1 as far as I'm aware (since the API is defined by the C++ 
standard after all).

> There may be some very good rationale for why openmp is different in this 
> way, but I haven't yet learned what it is.

@EricWF might have some insight into this.

> We duplicate c++, openmp, etc. in each $target instead.  If you have only one 
> target, I guess that's better.  Otherwise, does it matter?

Not every target may distribute or even support every runtime. For example, we 
don't currently ship openmp on Fuchsia because we haven't ported it yet. 
Similarly we don't ship every compiler-rt runtime.

>> and it matches the layout of the resource directory
> 
> Does the resource directory have any subproject directories, like c++, 
> openmp, etc?  If not, then it matches just as well either way.  You just 
> remove the level of subproject directories, right?

Not at the moment, but when designing the current resource directory layout, I 
haven't given this much though to various aspect so I wouldn't take it as 
indicative.

> To be clear, I'm not opposed to your proposals.  I'm just trying to 
> understand the relative advantages.  Thanks.

That makes sense, I'd like to understand various requirements for different 
runtimes before settling on the final layout. Updating this patch should be 
straightforward.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59168/new/

https://reviews.llvm.org/D59168



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


[clang-tools-extra] r359329 - Fix typo in documentation.

2019-04-26 Thread Nick Lewycky via cfe-commits
Author: nicholas
Date: Fri Apr 26 10:56:22 2019
New Revision: 359329

URL: http://llvm.org/viewvc/llvm-project?rev=359329=rev
Log:
Fix typo in documentation.

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-time-comparison.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-time-comparison.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-time-comparison.rst?rev=359329=359328=359329=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-time-comparison.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-time-comparison.rst 
Fri Apr 26 10:56:22 2019
@@ -6,7 +6,7 @@ abseil-time-comparison
 Prefer comparisons in the ``absl::Time`` domain instead of the integer domain.
 
 N.B.: In cases where an ``absl::Time`` is being converted to an integer,
-alignment may occur. If the comparison depends on this alingment, doing the
+alignment may occur. If the comparison depends on this alignment, doing the
 comparison in the ``absl::Time`` domain may yield a different result. In
 practice this is very rare, and still indicates a bug which should be fixed.
 


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


[PATCH] D60349: [COFF, ARM64] Fix ABI implementation of struct returns

2019-04-26 Thread Richard Townsend (Arm) via Phabricator via cfe-commits
richard.townsend.arm added a comment.

Confirmed just now that the current diff (196774) does work, but it'd be good 
to correct user-provided constructors and trivial destructors before this lands.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60349/new/

https://reviews.llvm.org/D60349



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


[PATCH] D59474: [OpenMP 5.0] Codegen support for user-defined mappers

2019-04-26 Thread Lingda Li via Phabricator via cfe-commits
lildmh marked 3 inline comments as done.
lildmh added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2390
   }
+  case OMPRTL__tgt_target_data_mapper: {
+// Build void __tgt_target_data_mapper(int64_t device_id, int32_t arg_num,

ABataev wrote:
> You need to implement these mapper functions first.
The runtime part is on hold for now.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:351
+  /// is the asynchronous version.
+  llvm::DenseMap>

ABataev wrote:
> You should be very careful with this map. If the mapper is declared in the 
> function context, it must be removed from this map as soon as the function 
> processing is completed. All local declarations are removed after this and 
> their address might be used again.
Yes, I plan to have this part in the next patch, which will implement to look 
up the corresponding mapper function for map. to, from clauses


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59474/new/

https://reviews.llvm.org/D59474



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


[PATCH] D59474: [OpenMP 5.0] Codegen support for user-defined mappers

2019-04-26 Thread Lingda Li via Phabricator via cfe-commits
lildmh updated this revision to Diff 196880.
lildmh added a comment.

Combine 2 pointers into one.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59474/new/

https://reviews.llvm.org/D59474

Files:
  include/clang/AST/GlobalDecl.h
  lib/AST/ASTContext.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ModuleBuilder.cpp
  test/OpenMP/declare_mapper_codegen.cpp

Index: test/OpenMP/declare_mapper_codegen.cpp
===
--- test/OpenMP/declare_mapper_codegen.cpp
+++ test/OpenMP/declare_mapper_codegen.cpp
@@ -1,92 +1,770 @@
-///==///
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s
-
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
 
+///==///
+// RUN: %clang_cc1 -DCK0 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK0 --check-prefix CK0-64 %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK0 --check-prefix CK0-64 %s
+// RUN: %clang_cc1 -DCK0 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK0 --check-prefix CK0-32 %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK0 --check-prefix CK0-32 %s
+
+// RUN: %clang_cc1 -DCK0 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK0 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
+// RUN: %clang_cc1 -DCK0 

[PATCH] D61165: Fix a crash where a [[no_destroy]] destructor was not emitted in an array

2019-04-26 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D61165#1479937 , @rjmccall wrote:

> Are you sure these are the right semantics for `nodestroy`?  I think there's 
> a reasonable argument that we should not destroy previous elements of a 
> `nodestroy` array just because an element constructor throws.  It's basically 
> academic for true globals because the exception will terminate the process 
> anyway, and even for `thread_local`s and `static` locals (where I believe the 
> exception is theoretically recoverable) it's at least arguable that we should 
> either decline to destroy (possibly causing leaks) or simply call 
> `std::terminate`.


I think `std::terminate` makes the most sense. Getting teardown correctly is 
always tricky, and I'm willing to bet that teardown caused by an exception in 
construction of an array is even harder and done wrong.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61165/new/

https://reviews.llvm.org/D61165



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


[PATCH] D60934: [clang] adding explicit(bool) from c++2a

2019-04-26 Thread Gauthier via Phabricator via cfe-commits
Tyker marked 2 inline comments as done.
Tyker added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:2033
+
+  void setExplicitSpecifier(ExplicitSpecInfo ESI);
+

rsmith wrote:
> Generally we don't want to have setters in the AST; the AST is intended to be 
> immutable after creation. Is this necessary?
this is used in 2 cases:
- for deserialization.
- for in `Sema::ActOnFunctionDeclarator` to make every declaration of the same 
function have the same explicit specifier as the canonical one. there is 
probably a better way to do this but i didn't find how.

the second use case will need to be changed because the constructor's explicit 
specifier will be tail-allocated so the explicit specifier from the canonical 
declaration will need to be recovered before construction to allocate storage. 

how can we find the canonical declaration of a function before it is 
constructed ?



Comment at: clang/lib/Sema/SemaInit.cpp:3819
+AllowExplicit = AllowExplicit && !CopyInitializing;
+if (AllowExplicit || Conv->isMaybeNotExplicit()) {
   if (ConvTemplate)

rsmith wrote:
> Consider just removing this `if`. It's not clear that it carries its weight.
this if prevent conversion that are already known not to be valid from being 
added to the overload set. removing it is still correct because it will be 
removed later. but we would be doing "useless" work because we are adding the 
to the overload set knowing they will be removed.
the only benefit i see of removing this if is to make all explicit conversion 
appear in overload resolution failure messages. is it the intent ?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60934/new/

https://reviews.llvm.org/D60934



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


[PATCH] D60605: [clangd] Revamp textDocument/onTypeFormatting.

2019-04-26 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 196864.
sammccall added a comment.

Fix more comment contination cases.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60605/new/

https://reviews.llvm.org/D60605

Files:
  clangd/CMakeLists.txt
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/Format.cpp
  clangd/Format.h
  test/clangd/formatting.test
  test/clangd/initialize-params.test
  unittests/clangd/CMakeLists.txt
  unittests/clangd/FormatTests.cpp

Index: unittests/clangd/FormatTests.cpp
===
--- /dev/null
+++ unittests/clangd/FormatTests.cpp
@@ -0,0 +1,275 @@
+//===-- FormatTests.cpp - Automatic code formatting tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Format.h"
+#include "Annotations.h"
+#include "SourceCode.h"
+#include "TestFS.h"
+#include "clang/Format/Format.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+std::string afterTyped(llvm::StringRef CodeWithCursor,
+   llvm::StringRef Typed) {
+  Annotations Code(CodeWithCursor);
+  unsigned Cursor = llvm::cantFail(positionToOffset(Code.code(), Code.point()));
+  auto Changes =
+  formatIncremental(Code.code(), Cursor, Typed,
+format::getGoogleStyle(format::FormatStyle::LK_Cpp));
+  tooling::Replacements Merged;
+  for (const auto& R : Changes)
+if (llvm::Error E = Merged.add(R))
+  ADD_FAILURE() << llvm::toString(std::move(E));
+  auto NewCode = tooling::applyAllReplacements(Code.code(), Merged);
+  EXPECT_TRUE(bool(NewCode))
+  << "Bad replacements: " << llvm::toString(NewCode.takeError());
+  NewCode->insert(transformCursorPosition(Cursor, Changes), "^");
+  return *NewCode;
+}
+
+// We can't pass raw strings directly to EXPECT_EQ because of gcc bugs.
+void expectAfterNewline(const char *Before, const char *After) {
+  EXPECT_EQ(After, afterTyped(Before, "\n")) << Before;
+}
+void expectAfter(const char *Typed, const char *Before, const char *After) {
+  EXPECT_EQ(After, afterTyped(Before, Typed)) << Before;
+}
+
+TEST(FormatIncremental, SplitComment) {
+  expectAfterNewline(R"cpp(
+// this comment was
+^split
+)cpp",
+   R"cpp(
+// this comment was
+// ^split
+)cpp");
+
+  expectAfterNewline(R"cpp(
+// trailing whitespace is not a split
+^   
+)cpp",
+   R"cpp(
+// trailing whitespace is not a split
+^
+)cpp");
+
+  expectAfterNewline(R"cpp(
+// splitting a
+^
+// multiline comment
+)cpp",
+ R"cpp(
+// splitting a
+// ^
+// multiline comment
+)cpp");
+
+  expectAfterNewline(R"cpp(
+// extra   
+^ whitespace
+)cpp",
+   R"cpp(
+// extra
+// ^whitespace
+)cpp");
+
+  expectAfterNewline(R"cpp(
+/// triple
+^slash
+)cpp",
+   R"cpp(
+/// triple
+/// ^slash
+)cpp");
+
+  expectAfterNewline(R"cpp(
+/// editor continuation
+//^
+)cpp",
+   R"cpp(
+/// editor continuation
+/// ^
+)cpp");
+
+  expectAfterNewline(R"cpp(
+// break before
+^ // slashes
+)cpp",
+   R"cpp(
+// break before
+^// slashes
+)cpp");
+
+
+  expectAfterNewline(R"cpp(
+int x;  // aligned
+^comment
+)cpp",
+   R"cpp(
+int x;  // aligned
+// ^comment
+)cpp");
+}
+
+TEST(FormatIncremental, Indentation) {
+  expectAfterNewline(R"cpp(
+void foo() {
+  if (bar)
+^
+)cpp",
+   R"cpp(
+void foo() {
+  if (bar)
+^
+)cpp");
+
+  expectAfterNewline(R"cpp(
+void foo() {
+  bar(baz(
+^
+)cpp",
+   R"cpp(
+void foo() {
+  bar(baz(
+  ^
+)cpp");
+
+  expectAfterNewline(R"cpp(
+void foo() {
+^}
+)cpp",
+   R"cpp(
+void foo() {
+  ^
+}
+)cpp");
+
+  expectAfterNewline(R"cpp(
+class X {
+protected:
+^
+)cpp",
+   R"cpp(
+class X {
+ protected:
+  ^
+)cpp");
+
+// Mismatched brackets (1)
+  expectAfterNewline(R"cpp(
+void foo() {
+  foo{bar(
+^}
+}
+)cpp",
+   R"cpp(
+void foo() {
+  foo {
+bar(
+^}
+}
+)cpp");
+// Mismatched brackets (2)
+  expectAfterNewline(R"cpp(
+void foo() {
+  foo{bar(
+^text}
+}
+)cpp",
+   R"cpp(
+void foo() {
+  foo {
+bar(
+^text}
+}
+)cpp");
+// Matched brackets
+  expectAfterNewline(R"cpp(
+void foo() {
+  foo{bar(
+^)
+}
+)cpp",
+   R"cpp(
+void foo() {
+  foo {
+bar(
+^)
+}
+)cpp");
+}
+
+TEST(FormatIncremental, FormatPreviousLine) {
+  expectAfterNewline(R"cpp(
+void foo() {
+   untouched( );
+int x=2;
+^
+)cpp",
+ R"cpp(
+void foo() {
+   untouched( );
+   int x = 2;
+   ^
+)cpp");
+
+  expectAfterNewline(R"cpp(
+int x=untouched( );
+auto L = []{return;return;};
+^
+)cpp",
+   R"cpp(
+int x=untouched( );
+auto L = [] {
+  return;
+  return;

[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-04-26 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Thanks Paul, your solution is even better. I'll apply rL11 
 locally - if everything's fine, do you mind 
if I re-land it again?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60283/new/

https://reviews.llvm.org/D60283



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


[PATCH] D61173: [BPF] do not generate predefined macro bpf

2019-04-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL359310: [BPF] do not generate predefined macro bpf (authored 
by yhs, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61173?vs=196799=196859#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61173/new/

https://reviews.llvm.org/D61173

Files:
  cfe/trunk/lib/Basic/Targets/BPF.cpp
  cfe/trunk/test/Preprocessor/bpf-predefined-macros.c


Index: cfe/trunk/test/Preprocessor/bpf-predefined-macros.c
===
--- cfe/trunk/test/Preprocessor/bpf-predefined-macros.c
+++ cfe/trunk/test/Preprocessor/bpf-predefined-macros.c
@@ -0,0 +1,16 @@
+// RUN: %clang -E -target bpfel -x c -o - %s | FileCheck %s
+// RUN: %clang -E -target bpfeb -x c -o - %s | FileCheck %s
+
+#ifdef __bpf__
+int b;
+#endif
+#ifdef __BPF__
+int c;
+#endif
+#ifdef bpf
+int d;
+#endif
+
+// CHECK: int b;
+// CHECK: int c;
+// CHECK-NOT: int d;
Index: cfe/trunk/lib/Basic/Targets/BPF.cpp
===
--- cfe/trunk/lib/Basic/Targets/BPF.cpp
+++ cfe/trunk/lib/Basic/Targets/BPF.cpp
@@ -20,7 +20,7 @@
 
 void BPFTargetInfo::getTargetDefines(const LangOptions ,
  MacroBuilder ) const {
-  DefineStd(Builder, "bpf", Opts);
+  Builder.defineMacro("__bpf__");
   Builder.defineMacro("__BPF__");
 }
 


Index: cfe/trunk/test/Preprocessor/bpf-predefined-macros.c
===
--- cfe/trunk/test/Preprocessor/bpf-predefined-macros.c
+++ cfe/trunk/test/Preprocessor/bpf-predefined-macros.c
@@ -0,0 +1,16 @@
+// RUN: %clang -E -target bpfel -x c -o - %s | FileCheck %s
+// RUN: %clang -E -target bpfeb -x c -o - %s | FileCheck %s
+
+#ifdef __bpf__
+int b;
+#endif
+#ifdef __BPF__
+int c;
+#endif
+#ifdef bpf
+int d;
+#endif
+
+// CHECK: int b;
+// CHECK: int c;
+// CHECK-NOT: int d;
Index: cfe/trunk/lib/Basic/Targets/BPF.cpp
===
--- cfe/trunk/lib/Basic/Targets/BPF.cpp
+++ cfe/trunk/lib/Basic/Targets/BPF.cpp
@@ -20,7 +20,7 @@
 
 void BPFTargetInfo::getTargetDefines(const LangOptions ,
  MacroBuilder ) const {
-  DefineStd(Builder, "bpf", Opts);
+  Builder.defineMacro("__bpf__");
   Builder.defineMacro("__BPF__");
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r359310 - [BPF] do not generate predefined macro bpf

2019-04-26 Thread Yonghong Song via cfe-commits
Author: yhs
Date: Fri Apr 26 08:35:51 2019
New Revision: 359310

URL: http://llvm.org/viewvc/llvm-project?rev=359310=rev
Log:
[BPF] do not generate predefined macro bpf

"DefineStd(Builder, "bpf", Opts)" generates the following three
macros:
  bpf
  __bpf
  __bpf__
and the macro "bpf" is due to the fact that the target language
is C which allows GNU extensions.

The name "bpf" could be easily used as variable name or type
field name. For example, in current linux kernel, there are
four places where bpf is used as a field name. If the corresponding
types are included in bpf program, the compilation error will
occur.

This patch removed predefined macro "bpf" as well as "__bpf" which
is rarely used if used at all.

Signed-off-by: Yonghong Song 

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

Added:
cfe/trunk/test/Preprocessor/bpf-predefined-macros.c
Modified:
cfe/trunk/lib/Basic/Targets/BPF.cpp

Modified: cfe/trunk/lib/Basic/Targets/BPF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/BPF.cpp?rev=359310=359309=359310=diff
==
--- cfe/trunk/lib/Basic/Targets/BPF.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/BPF.cpp Fri Apr 26 08:35:51 2019
@@ -20,7 +20,7 @@ using namespace clang::targets;
 
 void BPFTargetInfo::getTargetDefines(const LangOptions ,
  MacroBuilder ) const {
-  DefineStd(Builder, "bpf", Opts);
+  Builder.defineMacro("__bpf__");
   Builder.defineMacro("__BPF__");
 }
 

Added: cfe/trunk/test/Preprocessor/bpf-predefined-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/bpf-predefined-macros.c?rev=359310=auto
==
--- cfe/trunk/test/Preprocessor/bpf-predefined-macros.c (added)
+++ cfe/trunk/test/Preprocessor/bpf-predefined-macros.c Fri Apr 26 08:35:51 2019
@@ -0,0 +1,16 @@
+// RUN: %clang -E -target bpfel -x c -o - %s | FileCheck %s
+// RUN: %clang -E -target bpfeb -x c -o - %s | FileCheck %s
+
+#ifdef __bpf__
+int b;
+#endif
+#ifdef __BPF__
+int c;
+#endif
+#ifdef bpf
+int d;
+#endif
+
+// CHECK: int b;
+// CHECK: int c;
+// CHECK-NOT: int d;


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


[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-04-26 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

I had tried to do this in r11 but some bots complained, so I reverted it 
and then didn't follow through.  Thanks for doing this!
When I tried it, I took advantage of existing tracking of line directives at 
the file level, so there shouldn't be a need to add a Line flag to PresumedLoc?
What I did was something like this, in computeChecksum():

  const SrcMgr::SLocEntry  = SM.getSLocEntry(FID, );
  if (Invalid || !Entry.isFile() || Entry.getFile().hasLineDirectives())
return None;


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60283/new/

https://reviews.llvm.org/D60283



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


[PATCH] D61194: [HIP] Fix visibility of `__constant__` variables.

2019-04-26 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added a reviewer: yaxunl.
Herald added subscribers: cfe-commits, nhaehnle, jvesely.
Herald added a project: clang.

- `__constant__` variables should not be `hidden` as the linker may turn them 
into `LOCAL` symbols.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61194

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenCUDA/amdgpu-visibility.cu


Index: clang/test/CodeGenCUDA/amdgpu-visibility.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-visibility.cu
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device 
-fapply-global-visibility-to-externs -fvisibility default -emit-llvm -o - %s | 
FileCheck --check-prefix=CHECK-DEFAULT %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device 
-fapply-global-visibility-to-externs -fvisibility protected -emit-llvm -o - %s 
| FileCheck --check-prefix=CHECK-PROTECTED %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device 
-fapply-global-visibility-to-externs -fvisibility hidden -emit-llvm -o - %s | 
FileCheck --check-prefix=CHECK-HIDDEN %s
+
+#include "Inputs/cuda.h"
+
+// CHECK-DEFAULT: @c = addrspace(4) externally_initialized global
+// CHECK-DEFAULT: @g = addrspace(1) externally_initialized global
+// CHECK-PROTECTED: @c = protected addrspace(4) externally_initialized global
+// CHECK-PROTECTED: @g = protected addrspace(1) externally_initialized global
+// CHECK-HIDDEN: @c = protected addrspace(4) externally_initialized global
+// CHECK-HIDDEN: @g = protected addrspace(1) externally_initialized global
+__constant__ int c;
+__device__ int g;
+
+// CHECK-DEFAULT: define amdgpu_kernel void @_Z3foov()
+// CHECK-PROTECTED: define protected amdgpu_kernel void @_Z3foov()
+// CHECK-HIDDEN: define protected amdgpu_kernel void @_Z3foov()
+__global__ void foo() {
+  g = c;
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -7847,7 +7847,8 @@
 
   return D->hasAttr() ||
  (isa(D) && D->hasAttr()) ||
- (isa(D) && D->hasAttr());
+ (isa(D) &&
+  (D->hasAttr() || D->hasAttr()));
 }
 
 void AMDGPUTargetCodeGenInfo::setTargetAttributes(


Index: clang/test/CodeGenCUDA/amdgpu-visibility.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-visibility.cu
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -fapply-global-visibility-to-externs -fvisibility default -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-DEFAULT %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -fapply-global-visibility-to-externs -fvisibility protected -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-PROTECTED %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -fapply-global-visibility-to-externs -fvisibility hidden -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-HIDDEN %s
+
+#include "Inputs/cuda.h"
+
+// CHECK-DEFAULT: @c = addrspace(4) externally_initialized global
+// CHECK-DEFAULT: @g = addrspace(1) externally_initialized global
+// CHECK-PROTECTED: @c = protected addrspace(4) externally_initialized global
+// CHECK-PROTECTED: @g = protected addrspace(1) externally_initialized global
+// CHECK-HIDDEN: @c = protected addrspace(4) externally_initialized global
+// CHECK-HIDDEN: @g = protected addrspace(1) externally_initialized global
+__constant__ int c;
+__device__ int g;
+
+// CHECK-DEFAULT: define amdgpu_kernel void @_Z3foov()
+// CHECK-PROTECTED: define protected amdgpu_kernel void @_Z3foov()
+// CHECK-HIDDEN: define protected amdgpu_kernel void @_Z3foov()
+__global__ void foo() {
+  g = c;
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -7847,7 +7847,8 @@
 
   return D->hasAttr() ||
  (isa(D) && D->hasAttr()) ||
- (isa(D) && D->hasAttr());
+ (isa(D) &&
+  (D->hasAttr() || D->hasAttr()));
 }
 
 void AMDGPUTargetCodeGenInfo::setTargetAttributes(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60934: [clang] adding explicit(bool) from c++2a

2019-04-26 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/AST/ASTStructuralEquivalence.cpp:965
 auto *Conversion2 = cast(Method2);
-if (Conversion1->isExplicit() != Conversion2->isExplicit())
+if 
(!Conversion1->isEquivalentExplicit(Conversion2->getExplicitSpecifier()))
   return false;

martong wrote:
> Would it work if `Method1` has a different `ASTContext` than `Method2?
> That is exactly the case when we import an AST into another with ASTImporter.
`isEquivalentExplicit` calls `EquivalentExplicit`, which in turn calls 
`Stmt::Profile`.
Seems like `Stmt::Profile` relies on pointer equivalencies, however, here we 
may have two different `ASTContext`s for each Method, so we must not rely on 
pointer values.
I suggest to use a version of `EquivalentExplicit` which uses 
`Stmt::ProcessODRHash`, that one does not rely on pointer values.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60934/new/

https://reviews.llvm.org/D60934



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


[PATCH] D61097: [Sema] Emit warning for visibility attribute on internal-linkage declaration

2019-04-26 Thread Scott Linder via Phabricator via cfe-commits
scott.linder updated this revision to Diff 196853.
scott.linder added a comment.

Clean up use of `auto`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61097/new/

https://reviews.llvm.org/D61097

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/attr-visibility.c
  test/SemaCXX/ast-print.cpp
  test/SemaCXX/attr-visibility.cpp


Index: test/SemaCXX/attr-visibility.cpp
===
--- test/SemaCXX/attr-visibility.cpp
+++ test/SemaCXX/attr-visibility.cpp
@@ -18,3 +18,9 @@
 struct x3 {
   static int y;
 } __attribute((visibility("default"))); // expected-warning {{attribute 
'visibility' after definition is ignored}}
+
+const int test4 __attribute__((visibility("default"))) = 0; // 
expected-warning {{'visibility' attribute ignored}}
+
+namespace {
+  int test5 __attribute__((visibility("default"))); // expected-warning 
{{'visibility' attribute ignored}}
+};
Index: test/SemaCXX/ast-print.cpp
===
--- test/SemaCXX/ast-print.cpp
+++ test/SemaCXX/ast-print.cpp
@@ -209,10 +209,8 @@
 }
 }
 
-namespace {
 // CHECK: struct {{\[\[gnu::visibility\(\"hidden\"\)\]\]}} S;
 struct [[gnu::visibility("hidden")]] S;
-}
 
 // CHECK:  struct CXXFunctionalCastExprPrint {
 // CHECK-NEXT: } fce = CXXFunctionalCastExprPrint{};
Index: test/Sema/attr-visibility.c
===
--- test/Sema/attr-visibility.c
+++ test/Sema/attr-visibility.c
@@ -26,3 +26,9 @@
 int x __attribute__((type_visibility("default"))); // expected-error 
{{'type_visibility' attribute only applies to types and namespaces}}
 
 int PR17105 __attribute__((visibility(hidden))); // expected-error 
{{'visibility' attribute requires a string}}
+
+static int test8 __attribute__((visibility("default"))); // expected-warning 
{{'visibility' attribute ignored}}
+static int test9 __attribute__((visibility("hidden"))); // expected-warning 
{{'visibility' attribute ignored}}
+static int test10 __attribute__((visibility("internal"))); // expected-warning 
{{'visibility' attribute ignored}}
+
+static int test11() __attribute__((visibility("default"))); // 
expected-warning {{'visibility' attribute ignored}}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -2615,6 +2615,14 @@
 return;
   }
 
+  // Visibility attributes have no effect on symbols with internal linkage.
+  if (const auto *ND = dyn_cast(D)) {
+if (!ND->isExternallyVisible()) {
+  S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored) << AL;
+  return;
+}
+  }
+
   // Check that the argument is a string literal.
   StringRef TypeStr;
   SourceLocation LiteralLoc;


Index: test/SemaCXX/attr-visibility.cpp
===
--- test/SemaCXX/attr-visibility.cpp
+++ test/SemaCXX/attr-visibility.cpp
@@ -18,3 +18,9 @@
 struct x3 {
   static int y;
 } __attribute((visibility("default"))); // expected-warning {{attribute 'visibility' after definition is ignored}}
+
+const int test4 __attribute__((visibility("default"))) = 0; // expected-warning {{'visibility' attribute ignored}}
+
+namespace {
+  int test5 __attribute__((visibility("default"))); // expected-warning {{'visibility' attribute ignored}}
+};
Index: test/SemaCXX/ast-print.cpp
===
--- test/SemaCXX/ast-print.cpp
+++ test/SemaCXX/ast-print.cpp
@@ -209,10 +209,8 @@
 }
 }
 
-namespace {
 // CHECK: struct {{\[\[gnu::visibility\(\"hidden\"\)\]\]}} S;
 struct [[gnu::visibility("hidden")]] S;
-}
 
 // CHECK:  struct CXXFunctionalCastExprPrint {
 // CHECK-NEXT: } fce = CXXFunctionalCastExprPrint{};
Index: test/Sema/attr-visibility.c
===
--- test/Sema/attr-visibility.c
+++ test/Sema/attr-visibility.c
@@ -26,3 +26,9 @@
 int x __attribute__((type_visibility("default"))); // expected-error {{'type_visibility' attribute only applies to types and namespaces}}
 
 int PR17105 __attribute__((visibility(hidden))); // expected-error {{'visibility' attribute requires a string}}
+
+static int test8 __attribute__((visibility("default"))); // expected-warning {{'visibility' attribute ignored}}
+static int test9 __attribute__((visibility("hidden"))); // expected-warning {{'visibility' attribute ignored}}
+static int test10 __attribute__((visibility("internal"))); // expected-warning {{'visibility' attribute ignored}}
+
+static int test11() __attribute__((visibility("default"))); // expected-warning {{'visibility' attribute ignored}}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -2615,6 +2615,14 @@
 return;
   }
 
+  // Visibility attributes have no effect on symbols 

[PATCH] D61097: [Sema] Emit warning for visibility attribute on internal-linkage declaration

2019-04-26 Thread Scott Linder via Phabricator via cfe-commits
scott.linder marked 3 inline comments as done.
scott.linder added inline comments.



Comment at: lib/Sema/SemaDeclAttr.cpp:2621
+if (!ND->isExternallyVisible()) {
+  S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored) << AL;
+  return;

aaron.ballman wrote:
> I think it would be more helpful for users if we introduced a new diagnostic 
> here that explained why the attribute is being ignored, otherwise the 
> diagnostic is somewhat indecipherable.
Sure, I am amenable to anything here. GCC uses the same short message, but it 
does seem to indicate e.g. that the keyword `static` played some role by using 
additional source ranges. I don't know how we would go about that with the 
Sema/AST split? We could just go with a more explicit message. Do you have any 
thoughts on the wording?

```
warning: 'visibility' attribute ignored on non-external symbol
```



Comment at: lib/Sema/SemaDeclAttr.cpp:2622
+  S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored) << AL;
+  return;
+}

aaron.ballman wrote:
> We shouldn't early return here (it's not an error, just a warning), so that 
> the other diagnostics can also trigger if needed.
Should I also fix the other early-return-on-warning's in the same function, 
e.g. the function begins with:

```
// Visibility attributes don't mean anything on a typedef.
if (isa(D)) {
  S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored) << AL;
  return;
}
```

I suppose the difference is that the attribute "can" be placed on the symbol in 
this case, but it is ignored just the same.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61097/new/

https://reviews.llvm.org/D61097



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


[PATCH] D59168: [runtimes] Move libunwind, libc++abi and libc++ to lib/clang/ and include/

2019-04-26 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In D59168#1479939 , @phosek wrote:

> In D59168#1474715 , @jdenny wrote:
>
> > Does the following match what you have in mind?
> >
> >   $prefix/
> > include/
> >   c++/
> > v1/
> >   limits.h
> >   ...
> >   openmp/
> > v1/ <-- I don't think openmp has anything like this now
>
>
> Iibc++ uses this scheme to allow the possibility of evolving the API but I'm 
> not sure if it's necessary for openmp.


It seems we have roughly the same situation for their ABIs.  That is, for .so 
files, someone noted that libc++ and libunwind have always used the same 
version, .1, and openmp doesn't use a version (except in Debian packages).  In 
other words, for each of these three, a change in ABI compatibility has never 
been indicated.  For openmp only, it's apparently assumed a change never will 
need to be indicated (except in Debian packages).

There may be some very good rationale for why openmp is different in this way, 
but I haven't yet learned what it is.

> 
> 
>> omp.h
>> ompt.h
>> ...
>>   lib/
>> c++/
>>   $target/
>> libc++abi.so
>> ...
>> openmp/
>>   $target/
>> libomp.so
>> ...
>> clang/
>>   9.0.0/ <- resource directory
>> include/
>> lib/
>>   $target/
>> libclang_rt.asan_cxx.a
>> ...
>> 
>>   
> 
> Almost with a small variation:
> 
>   $prefix/
> include/
>   c++/
> v1/
>   limits.h
>   ...
>   openmp/
> omp.h
> ompt.h
> ...
> lib/
>   $target/ <--- This way we don't have to duplicate $target in each 
> subdirectory

We duplicate c++, openmp, etc. in each $target instead.  If you have only one 
target, I guess that's better.  Otherwise, does it matter?

> and it matches the layout of the resource directory

Does the resource directory have any subproject directories, like c++, openmp, 
etc?  If not, then it matches just as well either way.  You just remove the 
level of subproject directories, right?

> c++/
>   libc++abi.so
>   ...
> openmp/
>   libomp.so
>   ...
>   clang/
> 9.0.0/
>   include/
>   lib/
> $target/
>   libclang_rt.asan_cxx.a
>   ...
> 
>   WDYT?

To be clear, I'm not opposed to your proposals.  I'm just trying to understand 
the relative advantages.  Thanks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59168/new/

https://reviews.llvm.org/D59168



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


[PATCH] D61187: [clangd] Move clangd tests to clangd directory. check-clangd is no longer part of check-clang-tools.

2019-04-26 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.
Herald added a subscriber: ormris.

@ilya-biryukov Can you check this with a shared library build?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61187/new/

https://reviews.llvm.org/D61187



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


[PATCH] D59887: [Syntax] Introduce TokenBuffer, start clangToolingSyntax library

2019-04-26 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 196849.
ilya-biryukov added a comment.

- Update a comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59887/new/

https://reviews.llvm.org/D59887

Files:
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/TokensTest.cpp

Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -0,0 +1,624 @@
+//===- TokensTest.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/Expr.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.def"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Frontend/Utils.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Lex/Token.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include "llvm/Support/raw_os_ostream.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Testing/Support/Annotations.h"
+#include "llvm/Testing/Support/SupportHelpers.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/gmock-more-matchers.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+using namespace clang;
+using namespace clang::syntax;
+
+using llvm::ValueIs;
+using ::testing::AllOf;
+using ::testing::Contains;
+using ::testing::ElementsAre;
+using ::testing::Matcher;
+using ::testing::Not;
+using ::testing::StartsWith;
+
+namespace {
+// Checks the passed ArrayRef has the same begin() and end() iterators as the
+// argument.
+MATCHER_P(SameRange, A, "") {
+  return A.begin() == arg.begin() && A.end() == arg.end();
+}
+// Matchers for syntax::Token.
+MATCHER_P(Kind, K, "") { return arg.kind() == K; }
+MATCHER_P2(HasText, Text, SourceMgr, "") {
+  return arg.text(*SourceMgr) == Text;
+}
+/// Checks the start and end location of a token are equal to SourceRng.
+MATCHER_P(RangeIs, SourceRng, "") {
+  return arg.location() == SourceRng.first &&
+ arg.endLocation() == SourceRng.second;
+}
+
+class TokenCollectorTest : public ::testing::Test {
+public:
+  /// Run the clang frontend, collect the preprocessed tokens from the frontend
+  /// invocation and store them in this->Buffer.
+  /// This also clears SourceManager before running the compiler.
+  void recordTokens(llvm::StringRef Code) {
+class RecordTokens : public ASTFrontendAction {
+public:
+  explicit RecordTokens(TokenBuffer ) : Result(Result) {}
+
+  bool BeginSourceFileAction(CompilerInstance ) override {
+assert(!Collector && "expected only a single call to BeginSourceFile");
+Collector.emplace(CI.getPreprocessor());
+return true;
+  }
+  void EndSourceFileAction() override {
+assert(Collector && "BeginSourceFileAction was never called");
+Result = std::move(*Collector).consume();
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(CompilerInstance , StringRef InFile) override {
+return llvm::make_unique();
+  }
+
+private:
+  TokenBuffer 
+  llvm::Optional Collector;
+};
+
+constexpr const char *FileName = "./input.cpp";
+FS->addFile(FileName, time_t(), llvm::MemoryBuffer::getMemBufferCopy(""));
+// Prepare to run a compiler.
+std::vector Args = {"tok-test", "-std=c++03", "-fsyntax-only",
+  FileName};
+auto CI = createInvocationFromCommandLine(Args, Diags, FS);
+assert(CI);
+CI->getFrontendOpts().DisableFree = false;
+CI->getPreprocessorOpts().addRemappedFile(
+FileName, 

[PATCH] D61187: [clangd] Move clangd tests to clangd directory. check-clangd is no longer part of check-clang-tools.

2019-04-26 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: gribozavr.
Herald added subscribers: cfe-commits, jfb, kadircet, arphaman, jkorous, 
MaskRay, javed.absar, mgorny.
Herald added a project: clang.
sammccall added a comment.
Herald added a subscriber: ormris.

@ilya-biryukov Can you check this with a shared library build?


Motivation:

- this layout is a pain to work with
- without a common root, it's painful to express things like "disable clangd" 
(D61122 )
- CMake/lit configs are a maintenance hazard, and the more the one-off hacks 
for various tools are entangled, the more we see apathy and non-ownership.

This attempts to use the bare-minimum configuration needed (while still
supporting the difficult cases: windows, standalone clang build, dynamic libs).
In particular the lit.cfg.py and lit.site.cfg.py.in are merged into lit.cfg.in.
The logic in these files is now minimal.

(Much of clang-tools-extra's lit configs can probably be cleaned up by reusing
lit.llvm.llvm_config.use_clang(), and every llvm project does its own version of
LDPATH mangling. I haven't attempted to fix any of those).

Docs are still in clang-tools-extra/docs, I don't have any plans to touch those.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D61187

Files:
  CMakeLists.txt
  clangd/CMakeLists.txt
  clangd/test/CMakeLists.txt
  clangd/test/Inputs/BenchmarkHeader.h
  clangd/test/Inputs/BenchmarkSource.cpp
  clangd/test/Inputs/background-index/compile_commands.json
  clangd/test/Inputs/background-index/definition.jsonrpc
  clangd/test/Inputs/background-index/foo.cpp
  clangd/test/Inputs/background-index/foo.h
  clangd/test/Inputs/requests.json
  clangd/test/Inputs/symbols.test.yaml
  clangd/test/Unit/lit.cfg.in
  clangd/test/background-index.test
  clangd/test/compile-commands-path-in-initialize.test
  clangd/test/completion-auto-trigger.test
  clangd/test/completion-snippets.test
  clangd/test/completion.test
  clangd/test/crash-non-added-files.test
  clangd/test/delimited-input-comment-at-the-end.test
  clangd/test/diagnostic-category.test
  clangd/test/diagnostics-notes.test
  clangd/test/diagnostics.test
  clangd/test/did-change-configuration-params.test
  clangd/test/execute-command.test
  clangd/test/exit-with-shutdown.test
  clangd/test/exit-without-shutdown.test
  clangd/test/filestatus.test
  clangd/test/fixits-codeaction.test
  clangd/test/fixits-command.test
  clangd/test/fixits-embed-in-diagnostic.test
  clangd/test/formatting.test
  clangd/test/hover.test
  clangd/test/index-tools.test
  clangd/test/initialize-params-invalid.test
  clangd/test/initialize-params.test
  clangd/test/initialize-sequence.test
  clangd/test/input-mirror.test
  clangd/test/lit.cfg.in
  clangd/test/lit.local.cfg
  clangd/test/protocol.test
  clangd/test/references.test
  clangd/test/rename.test
  clangd/test/signature-help.test
  clangd/test/spaces-in-delimited-input.test
  clangd/test/symbol-info.test
  clangd/test/symbols.test
  clangd/test/test-uri-posix.test
  clangd/test/test-uri-windows.test
  clangd/test/textdocument-didchange-fail.test
  clangd/test/too_large.test
  clangd/test/trace.test
  clangd/test/tweaks-format.test
  clangd/test/type-hierarchy.test
  clangd/test/unsupported-method.test
  clangd/test/utf8.test
  clangd/test/xpc/initialize.test
  clangd/test/xrefs.test
  clangd/unittests/Annotations.cpp
  clangd/unittests/Annotations.h
  clangd/unittests/BackgroundIndexTests.cpp
  clangd/unittests/CMakeLists.txt
  clangd/unittests/CancellationTests.cpp
  clangd/unittests/ClangdTests.cpp
  clangd/unittests/ClangdUnitTests.cpp
  clangd/unittests/CodeCompleteTests.cpp
  clangd/unittests/CodeCompletionStringsTests.cpp
  clangd/unittests/ContextTests.cpp
  clangd/unittests/DexTests.cpp
  clangd/unittests/DiagnosticsTests.cpp
  clangd/unittests/DraftStoreTests.cpp
  clangd/unittests/ExpectedTypeTest.cpp
  clangd/unittests/FSTests.cpp
  clangd/unittests/FileDistanceTests.cpp
  clangd/unittests/FileIndexTests.cpp
  clangd/unittests/FindSymbolsTests.cpp
  clangd/unittests/FunctionTests.cpp
  clangd/unittests/FuzzyMatchTests.cpp
  clangd/unittests/GlobalCompilationDatabaseTests.cpp
  clangd/unittests/HeadersTests.cpp
  clangd/unittests/IndexActionTests.cpp
  clangd/unittests/IndexTests.cpp
  clangd/unittests/JSONTransportTests.cpp
  clangd/unittests/Matchers.h
  clangd/unittests/PrintASTTests.cpp
  clangd/unittests/QualityTests.cpp
  clangd/unittests/RIFFTests.cpp
  clangd/unittests/SelectionTests.cpp
  clangd/unittests/SerializationTests.cpp
  clangd/unittests/SourceCodeTests.cpp
  clangd/unittests/SymbolCollectorTests.cpp
  clangd/unittests/SymbolInfoTests.cpp
  clangd/unittests/SyncAPI.cpp
  clangd/unittests/SyncAPI.h
  clangd/unittests/TUSchedulerTests.cpp
  clangd/unittests/TestFS.cpp
  clangd/unittests/TestFS.h
  clangd/unittests/TestIndex.cpp
  clangd/unittests/TestIndex.h
  clangd/unittests/TestScheme.h
  clangd/unittests/TestTU.cpp
  clangd/unittests/TestTU.h
  

[PATCH] D59887: [Syntax] Introduce TokenBuffer, start clangToolingSyntax library

2019-04-26 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

@sammccall, could we do another round of review? I think it's perfect now...
(Just kidding :-) )


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59887/new/

https://reviews.llvm.org/D59887



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


[PATCH] D59887: [Syntax] Introduce TokenBuffer, start clangToolingSyntax library

2019-04-26 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 196847.
ilya-biryukov added a comment.

- s/llvm::unittest::ValueIs/llvm::ValueIs.
- Add tests for empty macro expansions and directives around macro expansions.
- Record all gaps between spelled and expanded tokens.
- Tweak test dump to distinguish different tokens with the same spelling.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59887/new/

https://reviews.llvm.org/D59887

Files:
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/TokensTest.cpp

Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -0,0 +1,624 @@
+//===- TokensTest.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/Expr.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.def"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Frontend/Utils.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Lex/Token.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include "llvm/Support/raw_os_ostream.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Testing/Support/Annotations.h"
+#include "llvm/Testing/Support/SupportHelpers.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/gmock-more-matchers.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+using namespace clang;
+using namespace clang::syntax;
+
+using llvm::ValueIs;
+using ::testing::AllOf;
+using ::testing::Contains;
+using ::testing::ElementsAre;
+using ::testing::Matcher;
+using ::testing::Not;
+using ::testing::StartsWith;
+
+namespace {
+// Checks the passed ArrayRef has the same begin() and end() iterators as the
+// argument.
+MATCHER_P(SameRange, A, "") {
+  return A.begin() == arg.begin() && A.end() == arg.end();
+}
+// Matchers for syntax::Token.
+MATCHER_P(Kind, K, "") { return arg.kind() == K; }
+MATCHER_P2(HasText, Text, SourceMgr, "") {
+  return arg.text(*SourceMgr) == Text;
+}
+/// Checks the start and end location of a token are equal to SourceRng.
+MATCHER_P(RangeIs, SourceRng, "") {
+  return arg.location() == SourceRng.first &&
+ arg.endLocation() == SourceRng.second;
+}
+
+class TokenCollectorTest : public ::testing::Test {
+public:
+  /// Run the clang frontend, collect the preprocessed tokens from the frontend
+  /// invocation and store them in this->Buffer.
+  /// This also clears SourceManager before running the compiler.
+  void recordTokens(llvm::StringRef Code) {
+class RecordTokens : public ASTFrontendAction {
+public:
+  explicit RecordTokens(TokenBuffer ) : Result(Result) {}
+
+  bool BeginSourceFileAction(CompilerInstance ) override {
+assert(!Collector && "expected only a single call to BeginSourceFile");
+Collector.emplace(CI.getPreprocessor());
+return true;
+  }
+  void EndSourceFileAction() override {
+assert(Collector && "BeginSourceFileAction was never called");
+Result = std::move(*Collector).consume();
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(CompilerInstance , StringRef InFile) override {
+return llvm::make_unique();
+  }
+
+private:
+  TokenBuffer 
+  llvm::Optional Collector;
+};
+
+constexpr const char *FileName = "./input.cpp";
+FS->addFile(FileName, time_t(), llvm::MemoryBuffer::getMemBufferCopy(""));
+// Prepare to run a compiler.
+std::vector Args = {"tok-test", "-std=c++03", "-fsyntax-only",
+  FileName};

[PATCH] D42642: [CUDA] Detect installation in PATH

2019-04-26 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld marked an inline comment as done.
Hahnfeld added a comment.
Herald added a subscriber: ormris.

In D42642#1479013 , @aganea wrote:

> Just a quick heads-up - the `cuda-detect-path.cu` test fails on WSL/Ubuntu 
> 18.04:


Hmm, maybe that's because of symlinks. By chance, can you debug print the 
values of `real_path` and `parent_path`? They are supposed to resolve the links 
which is required for the candidate search to work and the test to pass.




Comment at: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp:98-101
+SmallString<256> ptxasAbsolutePath;
+llvm::sys::fs::real_path(*ptxas, ptxasAbsolutePath);
+
+StringRef ptxasDir = llvm::sys::path::parent_path(ptxasAbsolutePath);

These calls.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D42642/new/

https://reviews.llvm.org/D42642



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


[PATCH] D60605: [clangd] Revamp textDocument/onTypeFormatting.

2019-04-26 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Input:

  if (something)
foo; // a comment^

Expected:

  if (something)
foo; // a comment
  ^

Actual (indented to align with a comment):

  if (something)
foo; // a comment
 ^


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60605/new/

https://reviews.llvm.org/D60605



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


[PATCH] D60605: [clangd] Revamp textDocument/onTypeFormatting.

2019-04-26 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Input:

  // this is my comment. ^
  // and it continues on the next line.

Expected:

  // this is my comment.
  // ^
  // and it continues on the next line.

Actual:

  // this is my comment.
  ^
  // and it continues on the next line.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60605/new/

https://reviews.llvm.org/D60605



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


[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-04-26 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert edited reviewers, added: riccibruno; removed: efriedma.
aaronpuchert removed a subscriber: riccibruno.
aaronpuchert added a comment.

Ping?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59402/new/

https://reviews.llvm.org/D59402



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


[PATCH] D58573: [analyzer] Move UninitializedObjectChecker out of alpha

2019-04-26 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I suspect the problem is similar. I'll take a look at this either today or 
tomorrow, thanks!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58573/new/

https://reviews.llvm.org/D58573



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


[PATCH] D58573: [analyzer] Move UninitializedObjectChecker out of alpha

2019-04-26 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

Thank you for the fix!  Another crash: 
https://bugs.llvm.org/show_bug.cgi?id=41611


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58573/new/

https://reviews.llvm.org/D58573



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


[PATCH] D59302: [clangd] Surface diagnostics from headers inside main file

2019-04-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 196822.
kadircet marked 5 inline comments as done.
kadircet added a comment.

- Address comments
- Drop include stack


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59302/new/

https://reviews.llvm.org/D59302

Files:
  clangd/Diagnostics.cpp
  clangd/Diagnostics.h
  unittests/clangd/DiagnosticsTests.cpp
  unittests/clangd/TestTU.cpp
  unittests/clangd/TestTU.h

Index: unittests/clangd/TestTU.h
===
--- unittests/clangd/TestTU.h
+++ unittests/clangd/TestTU.h
@@ -18,8 +18,13 @@
 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTTU_H
 
 #include "ClangdUnit.h"
+#include "Path.h"
 #include "index/Index.h"
+#include "llvm/ADT/StringMap.h"
 #include "gtest/gtest.h"
+#include 
+#include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -45,6 +50,9 @@
   std::string HeaderCode;
   std::string HeaderFilename = "TestTU.h";
 
+  // Name and contents of each file.
+  llvm::StringMap AdditionalFiles;
+
   // Extra arguments for the compiler invocation.
   std::vector ExtraArgs;
 
Index: unittests/clangd/TestTU.cpp
===
--- unittests/clangd/TestTU.cpp
+++ unittests/clangd/TestTU.cpp
@@ -21,11 +21,17 @@
   std::string FullFilename = testPath(Filename),
   FullHeaderName = testPath(HeaderFilename),
   ImportThunk = testPath("import_thunk.h");
-  std::vector Cmd = {"clang", FullFilename.c_str()};
   // We want to implicitly include HeaderFilename without messing up offsets.
   // -include achieves this, but sometimes we want #import (to simulate a header
   // guard without messing up offsets). In this case, use an intermediate file.
   std::string ThunkContents = "#import \"" + FullHeaderName + "\"\n";
+
+  llvm::StringMap Files(AdditionalFiles);
+  Files[FullFilename] = Code;
+  Files[FullHeaderName] = HeaderCode;
+  Files[ImportThunk] = ThunkContents;
+
+  std::vector Cmd = {"clang", FullFilename.c_str()};
   // FIXME: this shouldn't need to be conditional, but it breaks a
   // GoToDefinition test for some reason (getMacroArgExpandedLocation fails).
   if (!HeaderCode.empty()) {
@@ -39,9 +45,7 @@
   Inputs.CompileCommand.CommandLine = {Cmd.begin(), Cmd.end()};
   Inputs.CompileCommand.Directory = testRoot();
   Inputs.Contents = Code;
-  Inputs.FS = buildTestFS({{FullFilename, Code},
-   {FullHeaderName, HeaderCode},
-   {ImportThunk, ThunkContents}});
+  Inputs.FS = buildTestFS(Files);
   Inputs.Opts = ParseOptions();
   Inputs.Opts.ClangTidyOpts.Checks = ClangTidyChecks;
   Inputs.Index = ExternalIndex;
Index: unittests/clangd/DiagnosticsTests.cpp
===
--- unittests/clangd/DiagnosticsTests.cpp
+++ unittests/clangd/DiagnosticsTests.cpp
@@ -9,10 +9,11 @@
 #include "Annotations.h"
 #include "ClangdUnit.h"
 #include "Diagnostics.h"
+#include "Path.h"
 #include "Protocol.h"
 #include "SourceCode.h"
-#include "TestIndex.h"
 #include "TestFS.h"
+#include "TestIndex.h"
 #include "TestTU.h"
 #include "index/MemIndex.h"
 #include "clang/Basic/Diagnostic.h"
@@ -20,6 +21,7 @@
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -61,7 +63,8 @@
   "LSP diagnostic " + llvm::to_string(LSPDiag)) {
   if (toJSON(arg) != toJSON(LSPDiag)) {
 *result_listener << llvm::formatv("expected:\n{0:2}\ngot\n{1:2}",
-  toJSON(LSPDiag), toJSON(arg)).str();
+  toJSON(LSPDiag), toJSON(arg))
+.str();
 return false;
   }
   return true;
@@ -83,7 +86,6 @@
   return true;
 }
 
-
 // Helper function to make tests shorter.
 Position pos(int line, int character) {
   Position Res;
@@ -114,8 +116,7 @@
   // This range spans lines.
   AllOf(Diag(Test.range("typo"),
  "use of undeclared identifier 'goo'; did you mean 'foo'?"),
-DiagSource(Diag::Clang),
-DiagName("undeclared_var_use_suggest"),
+DiagSource(Diag::Clang), DiagName("undeclared_var_use_suggest"),
 WithFix(
 Fix(Test.range("typo"), "foo", "change 'go\\ o' to 'foo'")),
 // This is a pretty normal range.
@@ -301,7 +302,8 @@
   MainLSP.severity = getSeverity(DiagnosticsEngine::Error);
   MainLSP.code = "enum_class_reference";
   MainLSP.source = "clang";
-  MainLSP.message = R"(Something terrible happened (fix available)
+  MainLSP.message =
+  R"(Something terrible happened (fix available)
 
 main.cpp:6:7: remark: declared somewhere in the main file
 
@@ -354,9 +356,8 @@
   NoteInHeaderDRI.location.range = NoteInHeader.Range;
   NoteInHeaderDRI.location.uri = HeaderFile;
   MainLSP.relatedInformation = 

[PATCH] D59302: [clangd] Surface diagnostics from headers inside main file

2019-04-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clangd/Diagnostics.cpp:78
+// offsets when displaying that information to users.
+Position toOneBased(Position P) {
+  ++P.line;

ilya-biryukov wrote:
> Could we avoid introducing a function that breaks the invariant of a type?
> Having a function to print `Position` differently would be a much better fit.
No longer needed reverting.



Comment at: clangd/Diagnostics.cpp:225
+const auto  = D.IncludeStack[I];
+OS << "\nIn file included from: " << Inc.first << ':'
+   << toOneBased(Inc.second);

ilya-biryukov wrote:
> WDYT about changing this to a shorter form?
> ```
> include stack:
> 
> ./project/foo.h:312
> /usr/include/vector:344
> ```
> Note that it does not mention column numbers as they aren't useful and is 
> shorter.
> Since we're already not 100% aligned with clang, why not have a more concise 
> representation?
As discussed offline getting rid of include stack in this version of the patch.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59302/new/

https://reviews.llvm.org/D59302



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


[clang-tools-extra] r359291 - [clangd] Remove unused ClangdServer::dynamicIndex(). NFC

2019-04-26 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Fri Apr 26 02:36:22 2019
New Revision: 359291

URL: http://llvm.org/viewvc/llvm-project?rev=359291=rev
Log:
[clangd] Remove unused ClangdServer::dynamicIndex(). NFC

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.h

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=359291=359290=359291=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Fri Apr 26 02:36:22 2019
@@ -250,10 +250,6 @@ public:
   /// FIXME: those metrics might be useful too, we should add them.
   std::vector> getUsedBytesPerFile() const;
 
-  /// Returns the active dynamic index if one was built.
-  /// This can be useful for testing, debugging, or observing memory usage.
-  const SymbolIndex *dynamicIndex() const { return DynamicIdx.get(); }
-
   // Blocks the main thread until the server is idle. Only for use in tests.
   // Returns false if the timeout expires.
   LLVM_NODISCARD bool


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


[clang-tools-extra] r359289 - filecheck etc are not clangd-specific deps. NFC

2019-04-26 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Apr 26 02:20:36 2019
New Revision: 359289

URL: http://llvm.org/viewvc/llvm-project?rev=359289=rev
Log:
filecheck etc are not clangd-specific deps. NFC

Modified:
clang-tools-extra/trunk/test/CMakeLists.txt

Modified: clang-tools-extra/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/CMakeLists.txt?rev=359289=359288=359289=diff
==
--- clang-tools-extra/trunk/test/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/test/CMakeLists.txt Fri Apr 26 02:20:36 2019
@@ -89,7 +89,7 @@ set(LLVM_UTILS_DEPS
 )
 foreach(dep ${LLVM_UTILS_DEPS})
   if(TARGET ${dep})
-list(APPEND CLANGD_TEST_DEPS ${dep})
+list(APPEND CLANG_TOOLS_TEST_DEPS ${dep})
   endif()
 endforeach()
 


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


[PATCH] D61177: [MinGW] Always emit local typeinfo

2019-04-26 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61177/new/

https://reviews.llvm.org/D61177



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


[PATCH] D61176: [MinGW] Do dllexport inline methods in template instantiation

2019-04-26 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61176/new/

https://reviews.llvm.org/D61176



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


[PATCH] D61175: [MinGW] Don't let template instantiation declarations cover nested classes

2019-04-26 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Seems okay to me.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61175/new/

https://reviews.llvm.org/D61175



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


[PATCH] D60605: [clangd] Revamp textDocument/onTypeFormatting.

2019-04-26 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D60605#1478922 , @sammccall wrote:

> In D60605#1478581 , @ilya-biryukov 
> wrote:
>
> > Input:
> >
> >   int test() {
> >   }^
> >
> >
> > Actual:
> >
> >   int test() {}
> >   ^
> >
>
>
> I really do think this is the right thing in particular if you typed the 
> brace.
>  It's visually confusing that hitting \n results in the cursor staying on the 
> same line and the } moving.
>  And this interacts badly with the previous bug.
>  But can you see if this is something you could live with, and if not, 
> explain why you don't want the {} formatted?


In general, I have high tolerance for quirks in IDE features. But this one 
really makes me itchy. I'd say clangd should never remove lines while I'm 
trying to add them. Are there examples where this behavior is useful?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60605/new/

https://reviews.llvm.org/D60605



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


[PATCH] D61118: [MinGW] Fix dllexport of explicit template instantiation

2019-04-26 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL359285: [MinGW] Fix dllexport of explicit template 
instantiation (authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61118?vs=196704=196814#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61118/new/

https://reviews.llvm.org/D61118

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp
  cfe/trunk/test/SemaCXX/dllexport.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2863,6 +2863,9 @@
 def warn_attribute_dllexport_explicit_instantiation_decl : Warning<
   "explicit instantiation declaration should not be 'dllexport'">,
   InGroup>;
+def warn_attribute_dllexport_explicit_instantiation_def : Warning<
+  "'dllexport' attribute ignored on explicit instantiation definition">,
+  InGroup;
 def warn_invalid_initializer_from_system_header : Warning<
   "invalid constructor form class in system header, should not be explicit">,
   InGroup>;
Index: cfe/trunk/test/SemaCXX/dllexport.cpp
===
--- cfe/trunk/test/SemaCXX/dllexport.cpp
+++ cfe/trunk/test/SemaCXX/dllexport.cpp
@@ -367,10 +367,16 @@
 
 // Don't instantiate class members of templates with explicit instantiation declarations, even if they are exported.
 struct IncompleteType2;
-template  struct __declspec(dllexport) ExportedTemplateWithExplicitInstantiationDecl { // expected-note{{attribute is here}}
+#ifdef MS
+// expected-note@+2{{attribute is here}}
+#endif
+template  struct __declspec(dllexport) ExportedTemplateWithExplicitInstantiationDecl {
   int f() { return sizeof(T); } // no-error
 };
-extern template struct ExportedTemplateWithExplicitInstantiationDecl; // expected-warning{{explicit instantiation declaration should not be 'dllexport'}}
+#ifdef MS
+// expected-warning@+2{{explicit instantiation declaration should not be 'dllexport'}}
+#endif
+extern template struct ExportedTemplateWithExplicitInstantiationDecl;
 
 // Instantiate class members for explicitly instantiated exported templates.
 struct IncompleteType3; // expected-note{{forward declaration of 'IncompleteType3'}}
@@ -402,10 +408,17 @@
 
 // Warn about explicit instantiation declarations of dllexport classes.
 template  struct ExplicitInstantiationDeclTemplate {};
-extern template struct __declspec(dllexport) ExplicitInstantiationDeclTemplate; // expected-warning{{explicit instantiation declaration should not be 'dllexport'}} expected-note{{attribute is here}}
+#ifdef MS
+// expected-warning@+2{{explicit instantiation declaration should not be 'dllexport'}} expected-note@+2{{attribute is here}}
+#endif
+extern template struct __declspec(dllexport) ExplicitInstantiationDeclTemplate;
 
-template  struct __declspec(dllexport) ExplicitInstantiationDeclExportedTemplate {}; // expected-note{{attribute is here}}
-extern template struct ExplicitInstantiationDeclExportedTemplate; // expected-warning{{explicit instantiation declaration should not be 'dllexport'}}
+template  struct __declspec(dllexport) ExplicitInstantiationDeclExportedTemplate {};
+#ifdef MS
+// expected-note@-2{{attribute is here}}
+// expected-warning@+2{{explicit instantiation declaration should not be 'dllexport'}}
+#endif
+extern template struct ExplicitInstantiationDeclExportedTemplate;
 
 namespace { struct InternalLinkageType {}; }
 struct __declspec(dllexport) PR23308 {
@@ -438,6 +451,12 @@
 template struct ExplicitlyInstantiatedTemplate;
 template  struct ExplicitlyExportInstantiatedTemplate { void func() {} };
 template struct __declspec(dllexport) ExplicitlyExportInstantiatedTemplate;
+template  struct ExplicitlyExportDeclaredInstantiatedTemplate { void func() {} };
+extern template struct ExplicitlyExportDeclaredInstantiatedTemplate;
+#ifndef MS
+// expected-warning@+2{{'dllexport' attribute ignored on explicit instantiation definition}}
+#endif
+template struct __declspec(dllexport) ExplicitlyExportDeclaredInstantiatedTemplate;
 template  struct ExplicitlyImportInstantiatedTemplate { void func() {} };
 template struct __declspec(dllimport) ExplicitlyImportInstantiatedTemplate;
 
Index: cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp
===
--- cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp
+++ cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -emit-llvm -triple i686-mingw32 %s -o - | FileCheck %s
+
+template 
+class c {
+  void f();
+};
+
+template  void c::f() {}
+

r359285 - [MinGW] Fix dllexport of explicit template instantiation

2019-04-26 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Fri Apr 26 01:09:51 2019
New Revision: 359285

URL: http://llvm.org/viewvc/llvm-project?rev=359285=rev
Log:
[MinGW] Fix dllexport of explicit template instantiation

Contrary to MSVC, GCC/MinGW needs to have the dllexport attribute
on the template instantiation declaration, not on the definition.

Previously clang never marked explicit template instantiations as
dllexport in MinGW mode, if the instantiation had a previous
declaration, regardless of where the attribute was placed. This
makes Clang behave like GCC in this regard, and allows using the
same attribute form for both MinGW compilers.

This fixes PR40256.

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

Added:
cfe/trunk/test/CodeGenCXX/mingw-template-dllexport.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/dllexport.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=359285=359284=359285=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Apr 26 01:09:51 
2019
@@ -2863,6 +2863,9 @@ def warn_attribute_dllimport_static_fiel
 def warn_attribute_dllexport_explicit_instantiation_decl : Warning<
   "explicit instantiation declaration should not be 'dllexport'">,
   InGroup>;
+def warn_attribute_dllexport_explicit_instantiation_def : Warning<
+  "'dllexport' attribute ignored on explicit instantiation definition">,
+  InGroup;
 def warn_invalid_initializer_from_system_header : Warning<
   "invalid constructor form class in system header, should not be explicit">,
   InGroup>;

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=359285=359284=359285=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Apr 26 01:09:51 2019
@@ -5697,9 +5697,11 @@ void Sema::checkClassLevelDLLAttribute(C
 
   TemplateSpecializationKind TSK = Class->getTemplateSpecializationKind();
 
-  // Ignore explicit dllexport on explicit class template instantiation 
declarations.
+  // Ignore explicit dllexport on explicit class template instantiation
+  // declarations, except in MinGW mode.
   if (ClassExported && !ClassAttr->isInherited() &&
-  TSK == TSK_ExplicitInstantiationDeclaration) {
+  TSK == TSK_ExplicitInstantiationDeclaration &&
+  !Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
 Class->dropAttr();
 return;
   }

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=359285=359284=359285=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Apr 26 01:09:51 2019
@@ -8732,8 +8732,10 @@ DeclResult Sema::ActOnExplicitInstantiat
? TSK_ExplicitInstantiationDefinition
: TSK_ExplicitInstantiationDeclaration;
 
-  if (TSK == TSK_ExplicitInstantiationDeclaration) {
-// Check for dllexport class template instantiation declarations.
+  if (TSK == TSK_ExplicitInstantiationDeclaration &&
+  !Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
+// Check for dllexport class template instantiation declarations,
+// except for MinGW mode.
 for (const ParsedAttr  : Attr) {
   if (AL.getKind() == ParsedAttr::AT_DLLExport) {
 Diag(ExternLoc,
@@ -8793,6 +8795,19 @@ DeclResult Sema::ActOnExplicitInstantiat
   TemplateSpecializationKind PrevDecl_TSK
 = PrevDecl ? PrevDecl->getTemplateSpecializationKind() : TSK_Undeclared;
 
+  if (TSK == TSK_ExplicitInstantiationDefinition && PrevDecl != nullptr &&
+  Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
+// Check for dllexport class template instantiation definitions in MinGW
+// mode, if a previous declaration of the instantiation was seen.
+for (const ParsedAttr  : Attr) {
+  if (AL.getKind() == ParsedAttr::AT_DLLExport) {
+Diag(AL.getLoc(),
+ diag::warn_attribute_dllexport_explicit_instantiation_def);
+break;
+  }
+}
+  }
+
   if (CheckExplicitInstantiation(*this, ClassTemplate, TemplateNameLoc,
  SS.isSet(), TSK))
 return true;
@@ -8949,6 +8964,14 @@ DeclResult Sema::ActOnExplicitInstantiat
   dllExportImportClassTemplateSpecialization(*this, Def);
 }
 
+// In MinGW mode, export the template instantiation if the declaration
+// was marked 

[PATCH] D61177: [MinGW] Always emit local typeinfo

2019-04-26 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: rnk, hans, smeenai.
Herald added a project: clang.

This makes sure that code built with headers for a statically linked libc++ 
also works when linking to the DLL version, when the DLL hasn't been built with 
--export-all-symbols.

This matches what GCC for MinGW does for this test case.


Repository:
  rC Clang

https://reviews.llvm.org/D61177

Files:
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/vtable-key-function-ios.cpp


Index: test/CodeGenCXX/vtable-key-function-ios.cpp
===
--- test/CodeGenCXX/vtable-key-function-ios.cpp
+++ test/CodeGenCXX/vtable-key-function-ios.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck 
-check-prefixes=CHECK,CHECK-UNIX %s
 // RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck 
-check-prefix=CHECK-LATE %s
 
-// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | 
FileCheck -check-prefixes=CHECK,CHECK-MINGW %s
 // RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | 
FileCheck -check-prefix=CHECK-LATE %s
 
 // The 'a' variants ask for the vtable first.
@@ -29,7 +29,8 @@
 // V-table should be defined externally.
 Test0a::Test0a() { use(typeid(Test0a)); }
 // CHECK: @_ZTV6Test0a = external {{(dso_local )?}}unnamed_addr constant 
-// CHECK: @_ZTI6Test0a = external {{(dso_local )?}}constant
+// CHECK-UNIX: @_ZTI6Test0a = external {{(dso_local )?}}constant
+// CHECK-MINGW: @_ZTI6Test0a = linkonce_odr {{(dso_local )?}}constant
 
 // This is not a key function.
 void Test0a::foo() {}
@@ -48,7 +49,8 @@
 // V-table should be defined externally.
 Test0b::Test0b() { use(typeid(Test0b)); }
 // CHECK: @_ZTV6Test0b = external {{(dso_local )?}}unnamed_addr constant 
-// CHECK: @_ZTI6Test0b = external {{(dso_local )?}}constant
+// CHECK-UNIX: @_ZTI6Test0b = external {{(dso_local )?}}constant
+// CHECK-MINGW: @_ZTI6Test0b = linkonce_odr {{(dso_local )?}}constant
 
 /*** Test1a **/
 
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2959,7 +2959,7 @@
 bool IsDLLImport = RD->hasAttr();
 
 // Don't import the RTTI but emit it locally.
-if (CGM.getTriple().isWindowsGNUEnvironment() && IsDLLImport)
+if (CGM.getTriple().isWindowsGNUEnvironment())
   return false;
 
 if (CGM.getVTables().isVTableExternal(RD))


Index: test/CodeGenCXX/vtable-key-function-ios.cpp
===
--- test/CodeGenCXX/vtable-key-function-ios.cpp
+++ test/CodeGenCXX/vtable-key-function-ios.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck -check-prefixes=CHECK,CHECK-UNIX %s
 // RUN: %clang_cc1 %s -triple=armv7-apple-darwin -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s
 
-// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck -check-prefixes=CHECK,CHECK-MINGW %s
 // RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s
 
 // The 'a' variants ask for the vtable first.
@@ -29,7 +29,8 @@
 // V-table should be defined externally.
 Test0a::Test0a() { use(typeid(Test0a)); }
 // CHECK: @_ZTV6Test0a = external {{(dso_local )?}}unnamed_addr constant 
-// CHECK: @_ZTI6Test0a = external {{(dso_local )?}}constant
+// CHECK-UNIX: @_ZTI6Test0a = external {{(dso_local )?}}constant
+// CHECK-MINGW: @_ZTI6Test0a = linkonce_odr {{(dso_local )?}}constant
 
 // This is not a key function.
 void Test0a::foo() {}
@@ -48,7 +49,8 @@
 // V-table should be defined externally.
 Test0b::Test0b() { use(typeid(Test0b)); }
 // CHECK: @_ZTV6Test0b = external {{(dso_local )?}}unnamed_addr constant 
-// CHECK: @_ZTI6Test0b = external {{(dso_local )?}}constant
+// CHECK-UNIX: @_ZTI6Test0b = external {{(dso_local )?}}constant
+// CHECK-MINGW: @_ZTI6Test0b = linkonce_odr {{(dso_local )?}}constant
 
 /*** Test1a **/
 
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2959,7 +2959,7 @@
 bool IsDLLImport = RD->hasAttr();
 
 // Don't import the RTTI but emit it locally.
-if (CGM.getTriple().isWindowsGNUEnvironment() && IsDLLImport)
+if (CGM.getTriple().isWindowsGNUEnvironment())
   return false;
 
 if 

[PATCH] D61176: [MinGW] Do dllexport inline methods in template instantiation

2019-04-26 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: rnk, hans, smeenai.
Herald added a project: clang.

Normally, in MinGW mode, inline methods aren't dllexported.

However, in the case of a dllimported template instantiation, the inline 
methods aren't instantiated locally, but referenced from the instantiation. 
Therefore, those methods also need to be dllexported, in the case of an 
instantiation.

GCC suffers from the same issue, reported at [1], but the issue is still 
unresolved there.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89088


Repository:
  rC Clang

https://reviews.llvm.org/D61176

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/CodeGenCXX/mingw-template-dllexport.cpp


Index: test/CodeGenCXX/mingw-template-dllexport.cpp
===
--- test/CodeGenCXX/mingw-template-dllexport.cpp
+++ test/CodeGenCXX/mingw-template-dllexport.cpp
@@ -7,11 +7,9 @@
 
 template 
 class c {
-  void f();
+  void f() {}
 };
 
-template  void c::f() {}
-
 template class __declspec(dllexport) c;
 
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiE1fEv
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -5726,9 +5726,12 @@
 continue;
 
   if (MD->isInlined()) {
-// MinGW does not import or export inline methods.
+// MinGW does not import or export inline methods. But do it for
+// template instantiations.
 if (!Context.getTargetInfo().getCXXABI().isMicrosoft() &&
-!Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())
+!Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment() 
&&
+TSK != TSK_ExplicitInstantiationDeclaration &&
+TSK != TSK_ExplicitInstantiationDefinition)
   continue;
 
 // MSVC versions before 2015 don't export the move assignment operators


Index: test/CodeGenCXX/mingw-template-dllexport.cpp
===
--- test/CodeGenCXX/mingw-template-dllexport.cpp
+++ test/CodeGenCXX/mingw-template-dllexport.cpp
@@ -7,11 +7,9 @@
 
 template 
 class c {
-  void f();
+  void f() {}
 };
 
-template  void c::f() {}
-
 template class __declspec(dllexport) c;
 
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiE1fEv
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -5726,9 +5726,12 @@
 continue;
 
   if (MD->isInlined()) {
-// MinGW does not import or export inline methods.
+// MinGW does not import or export inline methods. But do it for
+// template instantiations.
 if (!Context.getTargetInfo().getCXXABI().isMicrosoft() &&
-!Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())
+!Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment() &&
+TSK != TSK_ExplicitInstantiationDeclaration &&
+TSK != TSK_ExplicitInstantiationDefinition)
   continue;
 
 // MSVC versions before 2015 don't export the move assignment operators
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61175: [MinGW] Don't let template instantiation declarations cover nested classes

2019-04-26 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: rnk, hans, smeenai.
Herald added a project: clang.

An explicit template instantiation declaration used to let callers assume both 
outer and nested classes instantiations were defined in a different translation 
unit.

If the instantiation is marked dllexport, only the outer class is exported, but 
the caller will try to reference the instantiation of both outer and inner 
classes.

This makes MinGW mode match both MSVC and Windows Itanium, by having 
instantations only cover the outer class, and locally emitting definitions of 
the nested classes. Windows Itanium was changed to use this behavious in SVN 
r300804.

This deviates from what GCC does, but should be safe (and only inflate the 
object file size a bit, but MSVC and Windows Itanium modes do the same), and 
fixes cases where inner classes aren't dllexported.

This fixes missing references in combination with dllexported/imported template 
intantiations.

GCC suffers from the same issue, reported at [1], but the issue is still 
unresolved there. The issue can probably be solved either by making dllexport 
cover all nested classes as well, or this way (matching MSVC).

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89087


Repository:
  rC Clang

https://reviews.llvm.org/D61175

Files:
  lib/Sema/SemaTemplateInstantiate.cpp
  test/CodeGenCXX/mingw-template-dllexport.cpp


Index: test/CodeGenCXX/mingw-template-dllexport.cpp
===
--- test/CodeGenCXX/mingw-template-dllexport.cpp
+++ test/CodeGenCXX/mingw-template-dllexport.cpp
@@ -1,5 +1,10 @@
 // RUN: %clang_cc1 -emit-llvm -triple i686-mingw32 %s -o - | FileCheck %s
 
+#define JOIN2(x, y) x##y
+#define JOIN(x, y) JOIN2(x, y)
+#define UNIQ(name) JOIN(name, __LINE__)
+#define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return 
::func; }
+
 template 
 class c {
   void f();
@@ -36,3 +41,10 @@
 
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN5outerIiE1fEv
 // CHECK-NOT: define {{.*}} dllexport {{.*}} @_ZN5outerIiE5inner1fEv
+
+extern template class __declspec(dllimport) outer;
+USEMEMFUNC(outer, f)
+USEMEMFUNC(outer::inner, f)
+
+// CHECK: declare dllimport {{.*}} @_ZN5outerIcE1fEv
+// CHECK: define {{.*}} @_ZN5outerIcE5inner1fEv
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -2681,10 +2681,14 @@
 continue;
 
   if ((Context.getTargetInfo().getCXXABI().isMicrosoft() ||
-   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) 
&&
+   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment() ||
+   Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) &&
   TSK == TSK_ExplicitInstantiationDeclaration) {
 // In MSVC and Windows Itanium mode, explicit instantiation decl of the
 // outer class doesn't affect the inner class.
+// In GNU mode, inner classes aren't dllexported. Don't let the
+// instantiation cover the inner class, to avoid undefined references
+// to inner classes that weren't exported.
 continue;
   }
 


Index: test/CodeGenCXX/mingw-template-dllexport.cpp
===
--- test/CodeGenCXX/mingw-template-dllexport.cpp
+++ test/CodeGenCXX/mingw-template-dllexport.cpp
@@ -1,5 +1,10 @@
 // RUN: %clang_cc1 -emit-llvm -triple i686-mingw32 %s -o - | FileCheck %s
 
+#define JOIN2(x, y) x##y
+#define JOIN(x, y) JOIN2(x, y)
+#define UNIQ(name) JOIN(name, __LINE__)
+#define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return ::func; }
+
 template 
 class c {
   void f();
@@ -36,3 +41,10 @@
 
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN5outerIiE1fEv
 // CHECK-NOT: define {{.*}} dllexport {{.*}} @_ZN5outerIiE5inner1fEv
+
+extern template class __declspec(dllimport) outer;
+USEMEMFUNC(outer, f)
+USEMEMFUNC(outer::inner, f)
+
+// CHECK: declare dllimport {{.*}} @_ZN5outerIcE1fEv
+// CHECK: define {{.*}} @_ZN5outerIcE5inner1fEv
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -2681,10 +2681,14 @@
 continue;
 
   if ((Context.getTargetInfo().getCXXABI().isMicrosoft() ||
-   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment()) &&
+   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment() ||
+   Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) &&
   TSK == TSK_ExplicitInstantiationDeclaration) {
 // In MSVC and Windows Itanium mode, explicit instantiation decl of the
 // outer class doesn't affect the inner class.
+// In GNU mode, inner classes aren't dllexported. Don't let the
+// 

[PATCH] D61077: [clangd] Query index in code completion no-compile mode.

2019-04-26 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL359284: [clangd] Query index in code completion no-compile 
mode. (authored by sammccall, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61077/new/

https://reviews.llvm.org/D61077

Files:
  clang-tools-extra/trunk/clangd/CodeComplete.cpp
  clang-tools-extra/trunk/clangd/SourceCode.cpp
  clang-tools-extra/trunk/clangd/SourceCode.h
  clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
  clang-tools-extra/trunk/unittests/clangd/SourceCodeTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/SourceCodeTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/SourceCodeTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/SourceCodeTests.cpp
@@ -322,6 +322,74 @@
   EXPECT_EQ(IDs["foo"], 2u);
 }
 
+TEST(SourceCodeTests, VisibleNamespaces) {
+  std::vector>> Cases = {
+  {
+  R"cpp(
+// Using directive resolved against enclosing namespaces.
+using namespace foo;
+namespace ns {
+using namespace bar;
+  )cpp",
+  {"ns", "", "bar", "foo", "ns::bar"},
+  },
+  {
+  R"cpp(
+// Don't include namespaces we've closed, ignore namespace aliases.
+using namespace clang;
+using std::swap;
+namespace clang {
+namespace clangd {}
+namespace ll = ::llvm;
+}
+namespace clang {
+  )cpp",
+  {"clang", ""},
+  },
+  {
+  R"cpp(
+// Using directives visible even if a namespace is reopened.
+// Ignore anonymous namespaces.
+namespace foo{ using namespace bar; }
+namespace foo{ namespace {
+  )cpp",
+  {"foo", "", "bar", "foo::bar"},
+  },
+  {
+  R"cpp(
+// Mismatched braces
+namespace foo{}
+}}}
+namespace bar{
+  )cpp",
+  {"bar", ""},
+  },
+  {
+  R"cpp(
+// Namespaces with multiple chunks.
+namespace a::b {
+  using namespace c::d;
+  namespace e::f {
+  )cpp",
+  {
+  "a::b::e::f",
+  "",
+  "a",
+  "a::b",
+  "a::b::c::d",
+  "a::b::e",
+  "a::c::d",
+  "c::d",
+  },
+  },
+  };
+  for (const auto& Case : Cases) {
+EXPECT_EQ(Case.second,
+  visibleNamespaces(Case.first, format::getLLVMStyle()))
+<< Case.first;
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -18,6 +18,7 @@
 #include "TestFS.h"
 #include "TestIndex.h"
 #include "TestTU.h"
+#include "index/Index.h"
 #include "index/MemIndex.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Tooling/CompilationDatabase.h"
@@ -2452,6 +2453,71 @@
   UnorderedElementsAre(Named("sym1"), Named("sym2")));
 }
 
+TEST(NoCompileCompletionTest, WithIndex) {
+  std::vector Syms = {func("xxx"), func("a::xxx"), func("ns::b::xxx"),
+  func("c::xxx"), func("ns::d::xxx")};
+  auto Results = completionsNoCompile(
+  R"cpp(
+// Current-scopes, unqualified completion.
+using namespace a;
+namespace ns {
+using namespace b;
+void foo() {
+xx^
+}
+  )cpp",
+  Syms);
+  EXPECT_THAT(Results.Completions,
+  UnorderedElementsAre(AllOf(Qualifier(""), Scope("")),
+   AllOf(Qualifier(""), Scope("a::")),
+   AllOf(Qualifier(""), Scope("ns::b::";
+  CodeCompleteOptions Opts;
+  Opts.AllScopes = true;
+  Results = completionsNoCompile(
+  R"cpp(
+// All-scopes unqualified completion.
+using namespace a;
+namespace ns {
+using namespace b;
+void foo() {
+xx^
+}
+  )cpp",
+  Syms, Opts);
+  EXPECT_THAT(Results.Completions,
+  UnorderedElementsAre(AllOf(Qualifier(""), Scope("")),
+   AllOf(Qualifier(""), Scope("a::")),
+   AllOf(Qualifier(""), Scope("ns::b::")),
+   AllOf(Qualifier("c::"), Scope("c::")),
+   AllOf(Qualifier("d::"), Scope("ns::d::";
+  Results = completionsNoCompile(
+  R"cpp(
+// Qualified completion.
+using namespace a;
+  

[PATCH] D61136: [Analyzer] IteratorChecker - Ensure end()>=begin() and refactor begin and end symbol creation

2019-04-26 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 2 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:1929-1930
+
+  auto  = State->getSymbolManager();
+  auto Sym = SymMgr.conjureSymbol(E, LCtx, T, BlockCount, "end");
+  State = assumeNoOverflow(State, Sym, 4);

NoQ wrote:
> This is a bit more `auto` than allowed by [[ 
> https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable
>  | our coding standards ]] (it pretty much disallows `auto` unless it's some 
> sort of `dyn_cast` (`getAs`) or an iterator.
I can add the type, of course. However, until now I understood and it is also 
in the coding standard that "other places where the type is already obvious 
from the context". For me it is obvious that `conjureSymbol()` returns a 
`SymbolRef`. Even more obvious is the `getSymbolManager()` returns a 
`SymbolManager`.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:2247
 
+ProgramStateRef ensureNonNegativeDiff(ProgramStateRef State, SymbolRef Sym1,
+  SymbolRef Sym2) {

NoQ wrote:
> This looks like a new feature. Is it testable?
I am not sure I can test it alone. Maybe I should leave it for now and add it 
in another patch together with modelling of `empty()` or `size()`. Then I 
should also rename this patch which remains pure refactoring.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61136/new/

https://reviews.llvm.org/D61136



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


[clang-tools-extra] r359284 - [clangd] Query index in code completion no-compile mode.

2019-04-26 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Apr 26 00:45:49 2019
New Revision: 359284

URL: http://llvm.org/viewvc/llvm-project?rev=359284=rev
Log:
[clangd] Query index in code completion no-compile mode.

Summary: We scrape the enclosing scopes from the source file, and use them in 
the query.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/SourceCode.cpp
clang-tools-extra/trunk/clangd/SourceCode.h
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
clang-tools-extra/trunk/unittests/clangd/SourceCodeTests.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=359284=359283=359284=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Fri Apr 26 00:45:49 2019
@@ -1269,7 +1269,11 @@ public:
 
 semaCodeComplete(std::move(RecorderOwner), Opts.getClangCompleteOpts(),
  SemaCCInput, );
+logResults(Output, Tracer);
+return Output;
+  }
 
+  void logResults(const CodeCompleteResult , const trace::Span ) 
{
 SPAN_ATTACH(Tracer, "sema_results", NSema);
 SPAN_ATTACH(Tracer, "index_results", NIndex);
 SPAN_ATTACH(Tracer, "merged_results", NSemaAndIndex);
@@ -1283,28 +1287,24 @@ public:
 assert(!Opts.Limit || Output.Completions.size() <= Opts.Limit);
 // We don't assert that isIncomplete means we hit a limit.
 // Indexes may choose to impose their own limits even if we don't have one.
-return Output;
   }
 
   CodeCompleteResult
   runWithoutSema(llvm::StringRef Content, size_t Offset,
  llvm::IntrusiveRefCntPtr VFS) && {
-auto CCPrefix = guessCompletionPrefix(Content, Offset);
+trace::Span Tracer("CodeCompleteWithoutSema");
 // Fill in fields normally set by runWithSema()
+HeuristicPrefix = guessCompletionPrefix(Content, Offset);
 CCContextKind = CodeCompletionContext::CCC_Recovery;
-Filter = FuzzyMatcher(CCPrefix.Name);
+Filter = FuzzyMatcher(HeuristicPrefix.Name);
 auto Pos = offsetToPosition(Content, Offset);
 ReplacedRange.start = ReplacedRange.end = Pos;
-ReplacedRange.start.character -= CCPrefix.Name.size();
+ReplacedRange.start.character -= HeuristicPrefix.Name.size();
 
 llvm::StringMap ProxSources;
 ProxSources[FileName].Cost = 0;
 FileProximity.emplace(ProxSources);
 
-// FIXME: collect typed scope specifier and potentially parse the enclosing
-// namespaces.
-// FIXME: initialize ScopeProximity when scopes are added.
-
 auto Style = getFormatStyleForFile(FileName, Content, VFS.get());
 // This will only insert verbatim headers.
 Inserter.emplace(FileName, Content, Style,
@@ -1317,16 +1317,38 @@ public:
   ID.Name = IDAndCount.first();
   ID.References = IDAndCount.second;
   // Avoid treating typed filter as an identifier.
-  if (ID.Name == CCPrefix.Name)
+  if (ID.Name == HeuristicPrefix.Name)
 --ID.References;
   if (ID.References > 0)
 IdentifierResults.push_back(std::move(ID));
 }
 
-// FIXME: add results from Opts.Index when we know more about scopes (e.g.
-// typed scope specifier).
-return toCodeCompleteResult(mergeResults(
-/*SemaResults=*/{}, /*IndexResults*/ {}, IdentifierResults));
+// Simplified version of getQueryScopes():
+//  - accessible scopes are determined heuristically.
+//  - all-scopes query if no qualifier was typed (and it's allowed).
+SpecifiedScope Scopes;
+Scopes.AccessibleScopes =
+visibleNamespaces(Content.take_front(Offset), Style);
+for (std::string  : Scopes.AccessibleScopes)
+  if (!S.empty())
+S.append("::"); // visibleNamespaces doesn't include trailing ::.
+if (HeuristicPrefix.Qualifier.empty())
+  AllScopes = Opts.AllScopes;
+else if (HeuristicPrefix.Qualifier.startswith("::")) {
+  Scopes.AccessibleScopes = {""};
+  Scopes.UnresolvedQualifier = HeuristicPrefix.Qualifier.drop_front(2);
+} else
+  Scopes.UnresolvedQualifier = HeuristicPrefix.Qualifier;
+// First scope is the (modified) enclosing scope.
+QueryScopes = Scopes.scopesForIndexQuery();
+ScopeProximity.emplace(QueryScopes);
+
+SymbolSlab IndexResults = Opts.Index ? queryIndex() : SymbolSlab();
+
+CodeCompleteResult Output = toCodeCompleteResult(mergeResults(
+/*SemaResults=*/{}, IndexResults, IdentifierResults));
+logResults(Output, Tracer);
+return Output;
   }
 
 private:

Modified: clang-tools-extra/trunk/clangd/SourceCode.cpp
URL: 

[PATCH] D61077: [clangd] Query index in code completion no-compile mode.

2019-04-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!




Comment at: unittests/clangd/SourceCodeTests.cpp:325
 
+TEST(SourceCodeTests, VisibleNamespaces) {
+  std::vector>> Cases = {

sammccall wrote:
> kadircet wrote:
> > NIT: maybe switch to TEST_P ?
> I find TEST_P much less readable and prefer to avoid it unless absolutely 
> necessary.
> Does it buy anything here?(
I just wanted to make sure we don't have more huge test cases as in 
`Hover.All`. I believe it would've helped if we've kept cases in small groups. 

But I guess we won't gain much here, since number of cases is not huge and I 
think there won't be many additions.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61077/new/

https://reviews.llvm.org/D61077



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


[PATCH] D61136: [Analyzer] IteratorChecker - Ensure end()>=begin() and refactor begin and end symbol creation

2019-04-26 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D61136#1479454 , @NoQ wrote:

> Aha, yup, thx!
>
> Do you plan to centralize other code paths on which you conjure symbols?


Only in a small rework of `handleAssign()` because that is a place where we 
conjure a symbol for a new `end()`. I only plan to centralize conjuration of 
`begin()` and `end()` symbols of containers.

> 'Cause i still believe that given that we now support C++ (our prvalues are 
> now properly materialized) (most of the time), you should be able to remove 
> support for symbol-like iterators, and then replace your position symbols 
> with `SymbolMetadata`.

Abstract iterator positions are represented by symbolic expressions because we 
must be able to do simple calculations with them. This has nothing to do with 
iterator objects represented as symbols. Or what do you mean exactly by 
"replacing position symbols with `SymbolMetadata`"?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61136/new/

https://reviews.llvm.org/D61136



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


r359283 - [Analyzer] Iterator Checkers - Do an early return after handling calls

2019-04-26 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Fri Apr 26 00:30:07 2019
New Revision: 359283

URL: http://llvm.org/viewvc/llvm-project?rev=359283=rev
Log:
[Analyzer] Iterator Checkers - Do an early return after handling calls

This patch is more of a fix than a real improvement: in checkPostCall()
we should return immediately after finding the right call and handling
it. This both saves unnecessary processing and double-handling calls by
mistake.

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


Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp?rev=359283=359282=359283=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp Fri Apr 26 
00:30:07 2019
@@ -563,12 +563,14 @@ void IteratorChecker::checkPostCall(cons
 const auto Op = Func->getOverloadedOperator();
 if (isAssignmentOperator(Op)) {
   const auto *InstCall = dyn_cast();
-  if (Func->getParamDecl(0)->getType()->isRValueReferenceType()) {
+  if (cast(Func)->isMoveAssignmentOperator()) {
 handleAssign(C, InstCall->getCXXThisVal(), Call.getOriginExpr(),
  Call.getArgSVal(0));
-  } else {
-handleAssign(C, InstCall->getCXXThisVal());
+return;
   }
+
+  handleAssign(C, InstCall->getCXXThisVal());
+  return;
 } else if (isSimpleComparisonOperator(Op)) {
   const auto *OrigExpr = Call.getOriginExpr();
   if (!OrigExpr)
@@ -577,68 +579,107 @@ void IteratorChecker::checkPostCall(cons
   if (const auto *InstCall = dyn_cast()) {
 handleComparison(C, OrigExpr, Call.getReturnValue(),
  InstCall->getCXXThisVal(), Call.getArgSVal(0), Op);
-  } else {
-handleComparison(C, OrigExpr, Call.getReturnValue(), 
Call.getArgSVal(0),
- Call.getArgSVal(1), Op);
+return;
   }
+
+  handleComparison(C, OrigExpr, Call.getReturnValue(), Call.getArgSVal(0),
+ Call.getArgSVal(1), Op);
+  return;
 } else if (isRandomIncrOrDecrOperator(Func->getOverloadedOperator())) {
   if (const auto *InstCall = dyn_cast()) {
 if (Call.getNumArgs() >= 1) {
   handleRandomIncrOrDecr(C, Func->getOverloadedOperator(),
  Call.getReturnValue(),
  InstCall->getCXXThisVal(), 
Call.getArgSVal(0));
+  return;
 }
   } else {
 if (Call.getNumArgs() >= 2) {
   handleRandomIncrOrDecr(C, Func->getOverloadedOperator(),
  Call.getReturnValue(), Call.getArgSVal(0),
  Call.getArgSVal(1));
+  return;
 }
   }
 } else if (isIncrementOperator(Func->getOverloadedOperator())) {
   if (const auto *InstCall = dyn_cast()) {
 handleIncrement(C, Call.getReturnValue(), InstCall->getCXXThisVal(),
 Call.getNumArgs());
-  } else {
-handleIncrement(C, Call.getReturnValue(), Call.getArgSVal(0),
-Call.getNumArgs());
+return;
   }
+
+  handleIncrement(C, Call.getReturnValue(), Call.getArgSVal(0),
+  Call.getNumArgs());
+  return;
 } else if (isDecrementOperator(Func->getOverloadedOperator())) {
   if (const auto *InstCall = dyn_cast()) {
 handleDecrement(C, Call.getReturnValue(), InstCall->getCXXThisVal(),
 Call.getNumArgs());
-  } else {
-handleDecrement(C, Call.getReturnValue(), Call.getArgSVal(0),
-Call.getNumArgs());
+return;
   }
+
+  handleDecrement(C, Call.getReturnValue(), Call.getArgSVal(0),
+Call.getNumArgs());
+  return;
 }
   } else {
 if (const auto *InstCall = dyn_cast()) {
   if (isAssignCall(Func)) {
 handleAssign(C, InstCall->getCXXThisVal());
-  } else if (isClearCall(Func)) {
+return;
+  }
+
+  if (isClearCall(Func)) {
 handleClear(C, InstCall->getCXXThisVal());
-  } else if (isPushBackCall(Func) || isEmplaceBackCall(Func)) {
+return;
+  }
+
+  if (isPushBackCall(Func) || isEmplaceBackCall(Func)) {
 handlePushBack(C, InstCall->getCXXThisVal());
-  } else if (isPopBackCall(Func)) {
+return;
+  }
+
+  if (isPopBackCall(Func)) {
 handlePopBack(C, InstCall->getCXXThisVal());
-  } else if (isPushFrontCall(Func) || isEmplaceFrontCall(Func)) {
+return;
+  }
+
+  if (isPushFrontCall(Func) || isEmplaceFrontCall(Func)) {
 handlePushFront(C, InstCall->getCXXThisVal());
-  } else if (isPopFrontCall(Func)) {
+ 

[PATCH] D61134: [Analyzer] Iterator Checkers - Do an early return after handling calls

2019-04-26 Thread Balogh, Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC359283: [Analyzer] Iterator Checkers - Do an early return 
after handling calls (authored by baloghadamsoftware, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61134?vs=196641=196807#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61134/new/

https://reviews.llvm.org/D61134

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp

Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -563,12 +563,14 @@
 const auto Op = Func->getOverloadedOperator();
 if (isAssignmentOperator(Op)) {
   const auto *InstCall = dyn_cast();
-  if (Func->getParamDecl(0)->getType()->isRValueReferenceType()) {
+  if (cast(Func)->isMoveAssignmentOperator()) {
 handleAssign(C, InstCall->getCXXThisVal(), Call.getOriginExpr(),
  Call.getArgSVal(0));
-  } else {
-handleAssign(C, InstCall->getCXXThisVal());
+return;
   }
+
+  handleAssign(C, InstCall->getCXXThisVal());
+  return;
 } else if (isSimpleComparisonOperator(Op)) {
   const auto *OrigExpr = Call.getOriginExpr();
   if (!OrigExpr)
@@ -577,68 +579,107 @@
   if (const auto *InstCall = dyn_cast()) {
 handleComparison(C, OrigExpr, Call.getReturnValue(),
  InstCall->getCXXThisVal(), Call.getArgSVal(0), Op);
-  } else {
-handleComparison(C, OrigExpr, Call.getReturnValue(), Call.getArgSVal(0),
- Call.getArgSVal(1), Op);
+return;
   }
+
+  handleComparison(C, OrigExpr, Call.getReturnValue(), Call.getArgSVal(0),
+ Call.getArgSVal(1), Op);
+  return;
 } else if (isRandomIncrOrDecrOperator(Func->getOverloadedOperator())) {
   if (const auto *InstCall = dyn_cast()) {
 if (Call.getNumArgs() >= 1) {
   handleRandomIncrOrDecr(C, Func->getOverloadedOperator(),
  Call.getReturnValue(),
  InstCall->getCXXThisVal(), Call.getArgSVal(0));
+  return;
 }
   } else {
 if (Call.getNumArgs() >= 2) {
   handleRandomIncrOrDecr(C, Func->getOverloadedOperator(),
  Call.getReturnValue(), Call.getArgSVal(0),
  Call.getArgSVal(1));
+  return;
 }
   }
 } else if (isIncrementOperator(Func->getOverloadedOperator())) {
   if (const auto *InstCall = dyn_cast()) {
 handleIncrement(C, Call.getReturnValue(), InstCall->getCXXThisVal(),
 Call.getNumArgs());
-  } else {
-handleIncrement(C, Call.getReturnValue(), Call.getArgSVal(0),
-Call.getNumArgs());
+return;
   }
+
+  handleIncrement(C, Call.getReturnValue(), Call.getArgSVal(0),
+  Call.getNumArgs());
+  return;
 } else if (isDecrementOperator(Func->getOverloadedOperator())) {
   if (const auto *InstCall = dyn_cast()) {
 handleDecrement(C, Call.getReturnValue(), InstCall->getCXXThisVal(),
 Call.getNumArgs());
-  } else {
-handleDecrement(C, Call.getReturnValue(), Call.getArgSVal(0),
-Call.getNumArgs());
+return;
   }
+
+  handleDecrement(C, Call.getReturnValue(), Call.getArgSVal(0),
+Call.getNumArgs());
+  return;
 }
   } else {
 if (const auto *InstCall = dyn_cast()) {
   if (isAssignCall(Func)) {
 handleAssign(C, InstCall->getCXXThisVal());
-  } else if (isClearCall(Func)) {
+return;
+  }
+
+  if (isClearCall(Func)) {
 handleClear(C, InstCall->getCXXThisVal());
-  } else if (isPushBackCall(Func) || isEmplaceBackCall(Func)) {
+return;
+  }
+
+  if (isPushBackCall(Func) || isEmplaceBackCall(Func)) {
 handlePushBack(C, InstCall->getCXXThisVal());
-  } else if (isPopBackCall(Func)) {
+return;
+  }
+
+  if (isPopBackCall(Func)) {
 handlePopBack(C, InstCall->getCXXThisVal());
-  } else if (isPushFrontCall(Func) || isEmplaceFrontCall(Func)) {
+return;
+  }
+
+  if (isPushFrontCall(Func) || isEmplaceFrontCall(Func)) {
 handlePushFront(C, InstCall->getCXXThisVal());
-  } else if (isPopFrontCall(Func)) {
+return;
+  }
+
+  if (isPopFrontCall(Func)) {
 handlePopFront(C, InstCall->getCXXThisVal());
-  } else if (isInsertCall(Func) || isEmplaceCall(Func)) {
+return;
+  }
+
+  if (isInsertCall(Func) || isEmplaceCall(Func)) {
 handleInsert(C, Call.getArgSVal(0));
-  } else if (isEraseCall(Func)) {
+return;
+  }
+
+ 

  1   2   >