[PATCH] D54489: Implement -frecord-command-line (-frecord-gcc-switches)

2020-03-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D54489#1331249 , @scott.linder 
wrote:

> rL349155 


@scott.linder Hi Scott, you may have an opion on 
https://gcc.gnu.org/ml/gcc-patches/2020-03/msg00230.html . I also started a 
thread on cfe-dev: 
http://lists.llvm.org/pipermail/cfe-dev/2020-March/064795.html


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

https://reviews.llvm.org/D54489



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


[PATCH] D75569: [clang-tidy] New check for methods marked __attribute__((unavailable)) that do not override a method from a superclass.

2020-03-04 Thread Michael Wyman via Phabricator via cfe-commits
mwyman updated this revision to Diff 248399.
mwyman added a comment.

Updated documentation per review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75569

Files:
  clang-tools-extra/clang-tidy/objc/CMakeLists.txt
  clang-tools-extra/clang-tidy/objc/MethodUnavailableNotOverrideCheck.cpp
  clang-tools-extra/clang-tidy/objc/MethodUnavailableNotOverrideCheck.h
  clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/objc-method-unavailable-not-override.rst
  
clang-tools-extra/test/clang-tidy/checkers/objc-method-unavailable-not-override.m

Index: clang-tools-extra/test/clang-tidy/checkers/objc-method-unavailable-not-override.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/objc-method-unavailable-not-override.m
@@ -0,0 +1,51 @@
+// RUN: %check_clang_tidy %s objc-method-unavailable-not-override -target x86_64-apple-macosx %t
+
+__attribute__((objc_root_class))
+@interface Object
+- (instancetype)init;
+
+// Define conditionally-available methods; when unavailable due to platform
+// availability, these methods should not warn.
+- (void)macMethod __attribute__((availability(macosx,introduced=10.10))) __attribute__((availability(ios,unavailable)));
+- (void)iosMethod __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(macosx,unavailable)));
+@end
+
+@interface MyObject : Object
+- (instancetype)init __attribute__((unavailable));
+
+// A new method that is not overriding, and is available, should not trigger.
+- (void)notOverridingMethod;
+
+// Test that marking methods unavailable, that were defined in a superclass but
+// conditionally unavailable based on target, don't warn.
+- (void)macMethod __attribute__((unavailable));
+- (void)iosMethod __attribute__((unavailable));
+
+- (void)methodA __attribute__((unavailable));
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: method 'methodA' is marked unavailable but does not override a superclass method [objc-method-unavailable-not-override]
+
+// Verify check when unavailable attribute has a message.
+- (void)methodB __attribute__((unavailable("use methodD")));
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: method 'methodB' is marked unavailable but does not override a superclass method [objc-method-unavailable-not-override]
+
+#define NS_UNAVAILABLE __attribute__((unavailable))
+
+// Verify check when using a macro that expands to the unavailable attribute.
+- (void)methodC NS_UNAVAILABLE;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: method 'methodC' is marked unavailable but does not override a superclass method [objc-method-unavailable-not-override]
+@end
+
+
+@implementation MyObject
+
+- (void)notOverridingMethod {}
+
+// Should not flag implementations for methods declared unavailable; sometimes
+// implemementations are provided that assert, to catch such codepaths that
+// lead to those calls during development.
+- (void)methodA {}
+
+@end
+
+// Verify that fixes exist to delete entire method declarations:
+// CHECK-FIXES: {{^\s*$}}
Index: clang-tools-extra/docs/clang-tidy/checks/objc-method-unavailable-not-override.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/objc-method-unavailable-not-override.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - objc-method-unavailable-not-override
+
+objc-method-unavailable-not-override
+
+
+Checks that a method marked with ``__attribute__((unavailable))`` is overriding
+a method declaration from a superclass. That declaration can usually be
+deleted entirely.
+
+.. code-block:: objc
+
+   @interface ClassA : NSObject
+   // Neither ClassA nor any superclasses define method -foo.
+   @end
+
+   @interface ClassB : ClassA
+   - (void)foo __attribute__((unavailable));
+   @end
+
+Suggests a fix to remove the method declaration entirely.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -236,6 +236,7 @@
`objc-avoid-nserror-init `_,
`objc-dealloc-in-category `_,
`objc-forbidden-subclassing `_,
+   `objc-method-unavailable-not-override `_, "Yes"
`objc-missing-hash `_,
`objc-property-declaration `_, "Yes"
`objc-super-self `_, "Yes"
@@ -283,7 +284,7 @@
`readability-redundant-member-init `_, "Yes"
`readability-redundant-preprocessor `_,
`readability-redundant-smartptr-get `_, "Yes"
-   `readability-redundant-string-cstr `_,
+   `readability-redundant-string-cstr `_, "Yes"
`readability-redundant-string-init `_, "Yes"
`readability-simplify-boolean-expr `_, "Yes"

[PATCH] D75569: [clang-tidy] New check for methods marked __attribute__((unavailable)) that do not override a method from a superclass.

2020-03-04 Thread Michael Wyman via Phabricator via cfe-commits
mwyman updated this revision to Diff 248396.
mwyman added a comment.

Updated to explicitly check for __attribute__((unavailable)), to avoid flagging 
methods marked based on platform availability. Updated test file to validate 
this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75569

Files:
  clang-tools-extra/clang-tidy/objc/CMakeLists.txt
  clang-tools-extra/clang-tidy/objc/MethodUnavailableNotOverrideCheck.cpp
  clang-tools-extra/clang-tidy/objc/MethodUnavailableNotOverrideCheck.h
  clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/objc-method-unavailable-not-override.rst
  
clang-tools-extra/test/clang-tidy/checkers/objc-method-unavailable-not-override.m

Index: clang-tools-extra/test/clang-tidy/checkers/objc-method-unavailable-not-override.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/objc-method-unavailable-not-override.m
@@ -0,0 +1,51 @@
+// RUN: %check_clang_tidy %s objc-method-unavailable-not-override -target x86_64-apple-macosx %t
+
+__attribute__((objc_root_class))
+@interface Object
+- (instancetype)init;
+
+// Define conditionally-available methods; when unavailable due to platform
+// availability, these methods should not warn.
+- (void)macMethod __attribute__((availability(macosx,introduced=10.10))) __attribute__((availability(ios,unavailable)));
+- (void)iosMethod __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(macosx,unavailable)));
+@end
+
+@interface MyObject : Object
+- (instancetype)init __attribute__((unavailable));
+
+// A new method that is not overriding, and is available, should not trigger.
+- (void)notOverridingMethod;
+
+// Test that marking methods unavailable, that were defined in a superclass but
+// conditionally unavailable based on target, don't warn.
+- (void)macMethod __attribute__((unavailable));
+- (void)iosMethod __attribute__((unavailable));
+
+- (void)methodA __attribute__((unavailable));
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: method 'methodA' is marked unavailable but does not override a superclass method [objc-method-unavailable-not-override]
+
+// Verify check when unavailable attribute has a message.
+- (void)methodB __attribute__((unavailable("use methodD")));
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: method 'methodB' is marked unavailable but does not override a superclass method [objc-method-unavailable-not-override]
+
+#define NS_UNAVAILABLE __attribute__((unavailable))
+
+// Verify check when using a macro that expands to the unavailable attribute.
+- (void)methodC NS_UNAVAILABLE;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: method 'methodC' is marked unavailable but does not override a superclass method [objc-method-unavailable-not-override]
+@end
+
+
+@implementation MyObject
+
+- (void)notOverridingMethod {}
+
+// Should not flag implementations for methods declared unavailable; sometimes
+// implemementations are provided that assert, to catch such codepaths that
+// lead to those calls during development.
+- (void)methodA {}
+
+@end
+
+// Verify that fixes exist to delete entire method declarations:
+// CHECK-FIXES: {{^\s*$}}
Index: clang-tools-extra/docs/clang-tidy/checks/objc-method-unavailable-not-override.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/objc-method-unavailable-not-override.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - objc-method-unavailable-not-override
+
+objc-method-unavailable-not-override
+
+
+Checks that a method marked with __attribute__((unavailable)) is overriding
+a method declaration from a superclass. That declaration can usually be
+deleted entirely.
+
+.. code-block:: objc
+
+   @interface ClassA : NSObject
+   // Neither ClassA nor any superclasses define method -foo.
+   @end
+
+   @interface ClassB : ClassA
+   - (void)foo __attribute__((unavailable));
+   @end
+
+Suggests a fix to remove the method declaration entirely.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -236,6 +236,7 @@
`objc-avoid-nserror-init `_,
`objc-dealloc-in-category `_,
`objc-forbidden-subclassing `_,
+   `objc-method-unavailable-not-override `_, "Yes"
`objc-missing-hash `_,
`objc-property-declaration `_, "Yes"
`objc-super-self `_, "Yes"
@@ -283,7 +284,7 @@
`readability-redundant-member-init `_, "Yes"
`readability-redundant-preprocessor `_,
`readability-redundant-smartptr-get `_, "Yes"
-   `readability-redundant-string-cstr `_,
+   `readability-redundant-st

[PATCH] D74735: [analyzer] Add support for CXXInheritedCtorInitExpr.

2020-03-04 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D74735#1906764 , @rsmith wrote:

> Just in case this isn't clear: the reason why `CXXInheritedCtorInitExpr` 
> doesn't take arguments and doesn't model parameter initialization is because 
> there is none: the arguments in the outer `CXXConstructExpr` directly 
> initialize the parameters of the base class constructor, and no copies are 
> made. (Making a copy of the parameter is incorrect, at least if it's done in 
> an observable way.) The derived class constructor doesn't even exist in the 
> formal model.


Damn, that's interesting! I wonder if the rest of our code will find it less 
surprising if we omit this whole stack frame entirely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74735



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


[PATCH] D74500: clang: Treat ieee mode as the default for denormal-fp-math

2020-03-04 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

c64ca93053af235bac0ca4dcdcd21c8882478310 



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

https://reviews.llvm.org/D74500



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


[clang] c64ca93 - clang: Treat ieee mode as the default for denormal-fp-math

2020-03-04 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2020-03-04T23:34:02-05:00
New Revision: c64ca93053af235bac0ca4dcdcd21c8882478310

URL: 
https://github.com/llvm/llvm-project/commit/c64ca93053af235bac0ca4dcdcd21c8882478310
DIFF: 
https://github.com/llvm/llvm-project/commit/c64ca93053af235bac0ca4dcdcd21c8882478310.diff

LOG: clang: Treat ieee mode as the default for denormal-fp-math

The IR hasn't switched the default yet, so explicitly add the ieee
attributes.

I'm still not really sure how the target default denormal mode should
interact with -fno-unsafe-math-optimizations. The target may have
selected the default mode to be non-IEEE based on the flags or based
on its true behavior, but we don't know which is the case. Since the
only users of a non-IEEE mode without a flag still support IEEE mode,
just reset to IEEE.

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGenCUDA/flush-denormals.cu
clang/test/CodeGenCUDA/propagate-metadata.cu
clang/test/CodeGenOpenCL/amdgpu-features.cl
clang/test/Driver/cuda-flush-denormals-to-zero.cu
clang/test/Driver/denormal-fp-math.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 0a28edefa1e6..d435bebcdcf9 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -164,10 +164,10 @@ class CodeGenOptions : public CodeGenOptionsBase {
   std::string FloatABI;
 
   /// The floating-point denormal mode to use.
-  llvm::DenormalMode FPDenormalMode;
+  llvm::DenormalMode FPDenormalMode = llvm::DenormalMode::getIEEE();
 
-  /// The floating-point subnormal mode to use, for float.
-  llvm::DenormalMode FP32DenormalMode;
+  /// The floating-point denormal mode to use, for float.
+  llvm::DenormalMode FP32DenormalMode = llvm::DenormalMode::getIEEE();
 
   /// The float precision limit to use, if non-empty.
   std::string LimitFloatPrecision;

diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 400ff9d86664..88ce205228fd 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -623,8 +623,7 @@ class ToolChain {
   const llvm::opt::ArgList &DriverArgs,
   Action::OffloadKind DeviceOffloadKind,
   const llvm::fltSemantics *FPType = nullptr) const {
-// FIXME: This should be IEEE when default handling is fixed.
-return llvm::DenormalMode::getInvalid();
+return llvm::DenormalMode::getIEEE();
   }
 };
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index d387a1dc2079..c8da2d86490f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2548,8 +2548,13 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
   ReciprocalMath = false;
   SignedZeros = true;
   // -fno_fast_math restores default denormal and fpcontract handling
-  DenormalFPMath = DefaultDenormalFPMath;
   FPContract = "";
+  DenormalFPMath = DefaultDenormalFPMath;
+
+  // FIXME: The target may have picked a non-IEEE default mode here based 
on
+  // -cl-denorms-are-zero. Should the target consider -fp-model 
interaction?
+  DenormalFP32Math = DefaultDenormalFP32Math;
+
   StringRef Val = A->getValue();
   if (OFastEnabled && !Val.equals("fast")) {
   // Only -ffp-model=fast is compatible with OFast, ignore.
@@ -2726,7 +2731,9 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
   FPExceptionBehavior = "strict";
   // -fno_unsafe_math_optimizations restores default denormal handling
   DenormalFPMath = DefaultDenormalFPMath;
-  DenormalFP32Math = DefaultDenormalFP32Math;
+
+  // The target may have opted to flush just f32 by default, so force IEEE.
+  DenormalFP32Math = llvm::DenormalMode::getIEEE();
   break;
 
 case options::OPT_Ofast:
@@ -2767,11 +2774,12 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
 if (StrictFPModel) {
   // If -ffp-model=strict has been specified on command line but
   // subsequent options conflict then emit warning diagnostic.
-  // TODO: How should this interact with DenormalFP32Math?
   if (HonorINFs && HonorNaNs &&
 !AssociativeMath && !ReciprocalMath &&
 SignedZeros && TrappingMath && RoundingFPMath &&
-(FPContract.equals("off") || FPContract.empty()))
+(FPContract.equals("off") || FPContract.empty()) &&
+DenormalFPMath == llvm::DenormalMode::getIEEE() &&
+DenormalFP32Math == llvm::DenormalMode::getIEEE())
 // OK: Current Arg doesn't conflict with -ffp-model=strict
 ;
   else {

LLVM buildmaster will be restarted soon

2020-03-04 Thread Galina Kistanova via cfe-commits
  Hello everyone,

LLVM buildmaster will be updated and restarted at 9:00 PM PST.

Thanks

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


[PATCH] D75661: Remove SequentialType from the type heirarchy.

2020-03-04 Thread Eli Friedman via Phabricator via cfe-commits
efriedma created this revision.
Herald added subscribers: cfe-commits, kerbowa, hiraditya, nhaehnle, jvesely, 
arsenm.
Herald added projects: clang, LLVM.
efriedma added a parent revision: D75660: Remove CompositeType class.

This is a bit more dubious than removing CompositeType, given the number of 
uses of "getSequentialElementType()" and "getSequentialNumElements()" I'm 
introducing here.  But there's a distinction here that isn't getting captured 
in the original SequentialType: getSequentialElementType() makes sense on any 
vector, but getSequentialNumElements() only makes sense for non-scalable 
vectors.  So some of these changes are probably necessary anyway.

Chris Tetrault is working on a proposal to make "SequentialType" refer to 
either an array or a fixed-length vector.  This would probably help in some of 
the places this patch currently uses getSequentialNumElements(), or introduces 
multiple codepaths for vectors vs. arrays.  This patch should help evaluate 
whether that's worthwhile.

I might end up splitting this into pieces, depending on what we decide to do; 
some of the cleanups make sense independent of the fate of SequentialType.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75661

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/DerivedTypes.h
  llvm/include/llvm/IR/GetElementPtrTypeIterator.h
  llvm/include/llvm/IR/Type.h
  llvm/lib/Analysis/BasicAliasAnalysis.cpp
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
  llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
  llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
  llvm/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/lib/Transforms/IPO/StripSymbols.cpp
  llvm/lib/Transforms/Scalar/SROA.cpp
  llvm/lib/Transforms/Utils/FunctionComparator.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -3116,7 +3116,8 @@
   unsigned N = 1;
   Type *EltTy = T;
 
-  while (isa(EltTy) || isa(EltTy)) {
+  while (isa(EltTy) || isa(EltTy) ||
+ isa(EltTy)) {
 if (auto *ST = dyn_cast(EltTy)) {
   // Check that struct is homogeneous.
   for (const auto *Ty : ST->elements())
@@ -3125,9 +3126,8 @@
   N *= ST->getNumElements();
   EltTy = *ST->element_begin();
 } else {
-  auto *SeqT = cast(EltTy);
-  N *= SeqT->getNumElements();
-  EltTy = SeqT->getElementType();
+  N *= EltTy->getSequentialNumElements();
+  EltTy = EltTy->getSequentialElementType();
 }
   }
 
Index: llvm/lib/Transforms/Utils/FunctionComparator.cpp
===
--- llvm/lib/Transforms/Utils/FunctionComparator.cpp
+++ llvm/lib/Transforms/Utils/FunctionComparator.cpp
@@ -476,10 +476,17 @@
 return 0;
   }
 
-  case Type::ArrayTyID:
+  case Type::ArrayTyID: {
+auto *STyL = cast(TyL);
+auto *STyR = cast(TyR);
+if (STyL->getNumElements() != STyR->getNumElements())
+  return cmpNumbers(STyL->getNumElements(), STyR->getNumElements());
+return cmpTypes(STyL->getElementType(), STyR->getElementType());
+  }
   case Type::VectorTyID: {
-auto *STyL = cast(TyL);
-auto *STyR = cast(TyR);
+auto *STyL = cast(TyL);
+auto *STyR = cast(TyR);
+// FIXME: Handle scalable vectors
 if (STyL->getNumElements() != STyR->getNumElements())
   return cmpNumbers(STyL->getNumElements(), STyR->getNumElements());
 return cmpTypes(STyL->getElementType(), STyR->getElementType());
Index: llvm/lib/Transforms/Scalar/SROA.cpp
===
--- llvm/lib/Transforms/Scalar/SROA.cpp
+++ llvm/lib/Transforms/Scalar/SROA.cpp
@@ -3507,11 +3507,11 @@
   (DL.getTypeAllocSize(Ty) - Offset) < Size)
 return nullptr;
 
-  if (SequentialType *SeqTy = dyn_cast(Ty)) {
-Type *ElementTy = SeqTy->getElementType();
+  if (isa(Ty) || isa(Ty)) {
+Type *ElementTy = Ty->getSequentialElementType();
 uint64_t ElementSize = DL.getTypeAllocSize(ElementTy);
 uint64_t NumSkippedElements = Offset / ElementSize;
-if (NumSkippedElements >= SeqTy->getNumElements())
+if (NumSkippedElements >= Ty->getSequentialNumElements())
   return nullptr;
 Offset -= NumSkippedElements * ElementSize;
 
Index: llvm/lib/Transforms/IPO/StripSymbols.cpp
===
--- llvm/lib/Transf

[PATCH] D58164: Block+lambda: allow reference capture

2020-03-04 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 248371.
ahatanak changed the repository for this revision from rC Clang to rG LLVM 
Github Monorepo.
ahatanak added a comment.
Herald added a subscriber: ributzka.

Rebase and ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58164

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenObjCXX/block-nested-in-lambda.mm

Index: clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
===
--- clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
+++ clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -std=c++11 -fblocks -fobjc-arc -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -std=c++14 -fblocks -fobjc-arc -o - %s | FileCheck %s
 
 // CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 }
+// CHECK: %[[S:.*]] = type { i32 }
+// CHECK: %[[CLASS_ANON_2:.*]] = type { %[[S]]* }
+// CHECK: %[[CLASS_ANON_3:.*]] = type { %[[S]] }
 
 // CHECK: %[[BLOCK_CAPTURED0:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK:.*]], i32 0, i32 5
 // CHECK: %[[V0:.*]] = getelementptr inbounds %[[LAMBDA_CLASS:.*]], %[[LAMBDA_CLASS]]* %[[THIS:.*]], i32 0, i32 0
@@ -33,7 +36,7 @@
 // reference.
 
 // CHECK-LABEL: define void @_ZN18CaptureByReference5test0Ev(
-// CHECK-LABEL: define internal void @"_ZZN18CaptureByReference5test0EvENK3$_1clEv"(
+// CHECK-LABEL: define internal void @"_ZZN18CaptureByReference5test0EvENK3$_3clEv"(
 // CHECK: %[[BLOCK_DESCRIPTOR:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8** }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8** }>* %{{.*}}, i32 0, i32 4
 // CHECK: store %[[STRUCT_BLOCK_DESCRIPTOR]]* bitcast ({ i64, i64, i8*, i64 }* @"__block_descriptor_40_e5_v8\01?0ls32l8" to %[[STRUCT_BLOCK_DESCRIPTOR]]*), %[[STRUCT_BLOCK_DESCRIPTOR]]** %[[BLOCK_DESCRIPTOR]], align 8
 
@@ -46,10 +49,60 @@
 // is captured by reference.
 
 // CHECK-LABEL: define void @_ZN18CaptureByReference5test1Ev(
-// CHECK-LABEL: define internal void @"_ZZN18CaptureByReference5test1EvENK3$_2clEv"(
+// CHECK-LABEL: define internal void @"_ZZN18CaptureByReference5test1EvENK3$_4clEv"(
 // CHECK: %[[BLOCK_DESCRIPTOR:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8** }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8** }>* %{{.*}}, i32 0, i32 4
 // CHECK: store %[[STRUCT_BLOCK_DESCRIPTOR]]* bitcast ({ i64, i64, i8*, i8*, i8*, i64 }* @"__block_descriptor_56_8_32s40s_e5_v8\01?0l" to %[[STRUCT_BLOCK_DESCRIPTOR]]*), %[[STRUCT_BLOCK_DESCRIPTOR]]** %[[BLOCK_DESCRIPTOR]], align 8
 
+void test1() {
+  id a = getObj(), b = getObj(), c = getObj();
+  [&a, b, c]{ ^{ a = 0; use(b); use(c); }(); }();
+}
+
+struct S {
+  int val() const;
+  int a;
+  S();
+  S(const S&);
+  S &operator=(const S&);
+  S(S&&);
+  S &operator=(S&&);
+};
+
+S getS();
+
+// CHECK: define internal i32 @"_ZZN18CaptureByReference5test2EvENK3$_1clIiEEDaT_"(%[[CLASS_ANON_2]]* %{{.*}}, i32 %{{.*}})
+// CHECK: %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, %{{.*}}, %[[S]]* }>, align 8
+// CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %{{.*}}, %[[S]]* }>, <{ i8*, i32, i32, i8*, %{{.*}}, %[[S]]* }>* %[[BLOCK]], i32 0, i32 5
+// CHECK: %[[V0:.*]] = getelementptr inbounds %[[CLASS_ANON_2]], %[[CLASS_ANON_2]]* %{{.*}}, i32 0, i32 0
+// CHECK: %[[V1:.*]] = load %[[S]]*, %[[S]]** %[[V0]], align 8
+// CHECK: store %[[S]]* %[[V1]], %[[S]]** %[[BLOCK_CAPTURED]], align 8
+
+int test2() {
+  S s;
+  auto fn = [&](const auto a){
+return ^{
+  return s.val();
+}();
+  };
+  return fn(123);
+}
+
+// CHECK: define internal i32 @"_ZZN18CaptureByReference5test3EvENK3$_2clIiEEDaT_"(%[[CLASS_ANON_3]]* %{{.*}}, i32 %{{.*}})
+// CHECK: %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, %{{.*}}*, %[[S]] }>, align 8
+// CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %{{.*}}*, %[[S]] }>, <{ i8*, i32, i32, i8*, %{{.*}}*, %[[S]] }>* %[[BLOCK]], i32 0, i32 5
+// CHECK: %[[V0:.*]] = getelementptr inbounds %[[CLASS_ANON_3]], %[[CLASS_ANON_3]]* %{{.*}}, i32 0, i32 0
+// CHECK: call void @_ZN18CaptureByReference1SC1ERKS0_(%[[S]]* %[[BLOCK_CAPTURED]], %[[S]]* {{.*}} %[[V0]])
+
+int test3() {
+  const S &s = getS();
+  auto fn = [=](const auto a){
+return ^{
+  return s.val();
+}();
+  };
+  return fn(123);
+}
+
 // CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_8_32s40s(
 // CHECK-NOT: call void @llvm.objc.storeStrong(
 // CHECK: %[[V4:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8** }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTO

[PATCH] D75153: [ThinLTO] Allow usage of all SMT threads in the system

2020-03-04 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added inline comments.



Comment at: llvm/include/llvm/Support/Threading.h:201
+  /// hardware core is used.
+  inline ThreadPoolStrategy heavyweight_hardware_concurrency(StringRef Num) {
+Optional S =

Nit: Remove `inline` 
https://llvm.org/docs/CodingStandards.html#don-t-use-inline-when-defining-a-function-in-a-class-definition


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

https://reviews.llvm.org/D75153



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


[PATCH] D74735: [analyzer] Add support for CXXInheritedCtorInitExpr.

2020-03-04 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

> There are also no argument expressions, even though the inherited constructor 
> for `A` takes one argument `x`. The current patch takes argument expressions 
> from the topmost `CXXConstructExpr`, which also requires a different location 
> context to access. As far as i can see, the result of such substitution is 
> always correct, i.e., the resulting argument `SVal` obtained from the 
> `Environment` this way will always be `evalBinOp`-equal to the correct 
> argument value.

Just in case this isn't clear: the reason why `CXXInheritedCtorInitExpr` 
doesn't take arguments and doesn't model parameter initialization is because 
there is none: the arguments in the outer `CXXConstructExpr` directly 
initialize the parameters of the base class constructor, and no copies are 
made. (Making a copy of the parameter is incorrect, at least if it's done in an 
observable way.) The derived class constructor doesn't even exist in the formal 
model.

Eg, in:

  struct X { X *p = this; ~X() {} };
  struct A { A(X x) : b(x.p == &x) {} bool b; };
  struct B : A { using A::A; };
  B b = X{};

... `b.b` is initialized to `true`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74735



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


[PATCH] D74500: clang: Treat ieee mode as the default for denormal-fp-math

2020-03-04 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor accepted this revision.
andrew.w.kaylor added a comment.
This revision is now accepted and ready to land.

lgtm


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

https://reviews.llvm.org/D74500



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


[PATCH] D66094: [CodeGen] Emit destructor calls for non-trivial C structs returned by function calls and loaded from volatile objects

2020-03-04 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 248363.
ahatanak marked 2 inline comments as done.
ahatanak removed a project: LLVM.
ahatanak removed a subscriber: llvm-commits.
ahatanak added a comment.
Herald added a subscriber: ributzka.

Address review comments.

- Declare the flags in `ReturnValueSlot` as bitfields.
- Replace flag `RequiresDestruction` with flag `IsExternallyDestructed` and 
move the `pushDestroy` call to `EmitCall`. I audited all the places where 
`ReturnValueSlot` is constructed and there were only a few places where 
`IsExternallyDestructed` had to be set to true.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66094

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGCall.h
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/test/CodeGenObjC/arc.m
  clang/test/CodeGenObjC/strong-in-c-struct.m

Index: clang/test/CodeGenObjC/strong-in-c-struct.m
===
--- clang/test/CodeGenObjC/strong-in-c-struct.m
+++ clang/test/CodeGenObjC/strong-in-c-struct.m
@@ -89,6 +89,13 @@
 void calleeStrongSmall(StrongSmall);
 void func(Strong *);
 
+@interface C
+- (StrongSmall)getStrongSmall;
++ (StrongSmall)getStrongSmallClass;
+@end
+
+id g0;
+
 // CHECK: %[[STRUCT_STRONGOUTER:.*]] = type { %[[STRUCT_STRONG:.*]], i8*, double }
 // CHECK: %[[STRUCT_STRONG]] = type { %[[STRUCT_TRIVIAL:.*]], i8* }
 // CHECK: %[[STRUCT_TRIVIAL]] = type { [4 x i32] }
@@ -476,6 +483,18 @@
   getStrongSmall();
 }
 
+// CHECK: define void @test_destructor_ignored_result2(%{{.*}}* %[[C:.*]])
+// CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
+// CHECK: %[[CALL:.*]] = call [2 x i64]{{.*}}@objc_msgSend
+// CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to [2 x i64]*
+// CHECK: store [2 x i64] %[[CALL]], [2 x i64]* %[[V5]], align 8
+// CHECK: %[[V6:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V6]])
+
+void test_destructor_ignored_result2(C *c) {
+  [c getStrongSmall];
+}
+
 // CHECK: define void @test_copy_constructor_StrongBlock(
 // CHECK: call void @__copy_constructor_8_8_sb0(
 // CHECK: call void @__destructor_8_sb0(
@@ -520,7 +539,9 @@
 
 // CHECK: define void @test_copy_constructor_StrongVolatile0(
 // CHECK: call void @__copy_constructor_8_8_t0w4_sv8(
+// CHECK-NOT: call
 // CHECK: call void @__destructor_8_sv8(
+// CHECK-NOT: call
 
 // CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_t0w4_sv8(
 // CHECK: %[[V8:.*]] = load volatile i8*, i8** %{{.*}}, align 8
@@ -709,4 +730,66 @@
   VolatileArray t = *a;
 }
 
+// CHECK: define void @test_member_access(
+// CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]],
+// CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V3]])
+// CHECK: call void @func(
+
+void test_member_access(void) {
+  g0 = getStrongSmall().f1;
+  func(0);
+}
+
+// CHECK: define void @test_member_access2(%{{.*}}* %[[C:.*]])
+// CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
+// CHECK: %[[V8:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V8]])
+// CHECK: call void @func(
+
+void test_member_access2(C *c) {
+  g0 = [c getStrongSmall].f1;
+  func(0);
+}
+
+// CHECK: define void @test_member_access3(
+// CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
+// CHECK: %[[V8:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V8]])
+// CHECK: call void @func(
+
+void test_member_access3(void) {
+  g0 = [C getStrongSmallClass].f1;
+  func(0);
+}
+
+// CHECK: define void @test_member_access4()
+// CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
+// CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V5]])
+// CHECK: call void @func(
+
+void test_member_access4(void) {
+  g0 = ^{
+StrongSmall s;
+return s;
+  }()
+.f1;
+  func(0);
+}
+
+// CHECK: define void @test_volatile_variable_reference(
+// CHECK: %[[AGG_TMP_ENSURED:.*]] = alloca %[[STRUCT_STRONGSMALL]],
+// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[AGG_TMP_ENSURED]] to i8**
+// CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %{{.*}} to i8**
+// CHECK: call void @__copy_constructor_8_8_tv0w32_sv8(i8** %[[V1]], i8** %[[V2]])
+// CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[AGG_TMP_ENSURED]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V3]])
+// CHECK: call void @func(
+
+void test_volatile_variable_reference(volatile StrongSmall *a) {
+  (void)*a;
+  func(0);
+}
+
 #endif /* USESTRUCT *

[PATCH] D75621: [clang-tidy] Use ; as separator for HeaderFileExtensions

2020-03-04 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 248357.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75621

Files:
  clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
  clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
  clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h
  clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
  clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
  clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h
  clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
  clang-tools-extra/clang-tidy/utils/HeaderGuard.h

Index: clang-tools-extra/clang-tidy/utils/HeaderGuard.h
===
--- clang-tools-extra/clang-tidy/utils/HeaderGuard.h
+++ clang-tools-extra/clang-tidy/utils/HeaderGuard.h
@@ -18,11 +18,12 @@
 
 /// Finds and fixes header guards.
 /// The check supports these options:
-///   - `HeaderFileExtensions`: a comma-separated list of filename extensions of
-/// header files (The filename extension should not contain "." prefix).
-/// ",h,hh,hpp,hxx" by default.
+///   - `HeaderFileExtensions`: a semicolon-separated list of filename
+/// extensions of header files (The filename extension should not contain
+/// "." prefix). ";h;hh;hpp;hxx" by default.
+///
 /// For extension-less header files, using an empty string or leaving an
-/// empty string between "," if there are other filename extensions.
+/// empty string between ";" if there are other filename extensions.
 class HeaderGuardCheck : public ClangTidyCheck {
 public:
   HeaderGuardCheck(StringRef Name, ClangTidyContext *Context)
@@ -30,7 +31,8 @@
 RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
 "HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
 utils::parseFileExtensions(RawStringHeaderFileExtensions,
-   HeaderFileExtensions, ',');
+   HeaderFileExtensions,
+   utils::defaultFileExtensionDelimiters());
   }
   void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override;
Index: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
===
--- clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
+++ clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
@@ -34,11 +34,16 @@
 
 /// Returns recommended default value for the list of header file
 /// extensions.
-inline StringRef defaultHeaderFileExtensions() { return ",h,hh,hpp,hxx"; }
+inline StringRef defaultHeaderFileExtensions() { return ";h;hh;hpp;hxx"; }
+
+/// Returns recommended default value for the list of file extension
+/// delimiters.
+inline StringRef defaultFileExtensionDelimiters() { return ",;"; }
 
 /// Parses header file extensions from a semicolon-separated list.
 bool parseFileExtensions(StringRef AllFileExtensions,
- FileExtensionsSet &FileExtensions, char Delimiter);
+ FileExtensionsSet &FileExtensions,
+ StringRef Delimiters);
 
 /// Decides whether a file has one of the specified file extensions.
 bool isFileExtension(StringRef FileName,
Index: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
@@ -9,6 +9,7 @@
 #include "FileExtensionsUtils.h"
 #include "clang/Basic/CharInfo.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 
 namespace clang {
 namespace tidy {
@@ -33,9 +34,21 @@
 }
 
 bool parseFileExtensions(StringRef AllFileExtensions,
- FileExtensionsSet &FileExtensions, char Delimiter) {
+ FileExtensionsSet &FileExtensions,
+ StringRef Delimiters) {
   SmallVector Suffixes;
-  AllFileExtensions.split(Suffixes, Delimiter);
+  for (const char Delimiter : Delimiters) {
+if (AllFileExtensions.contains(Delimiter)) {
+  if (Delimiter == ',') {
+llvm::errs()
+<< "Using ',' as a file extension delimiter is deprecated. Please "
+   "switch your configuration to use ';'.\n";
+  }
+  AllFileExtensions.split(Suffixes, Delimiter);
+  break;
+}
+  }
+
   FileExtensions.clear();
   for (StringRef Suffix : Suffixes) {
 StringRef Extension = Suffix.trim();
Index: cl

[PATCH] D75582: [clangd] Track document versions, include them with diags, enhance logs

2020-03-04 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2cd33e6fe60f: [clangd] Track document versions, include them 
with diags, enhance logs (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D75582?vs=248351&id=248355#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75582

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/test/diagnostic-category.test
  clang-tools-extra/clangd/test/diagnostics-no-tidy.test
  clang-tools-extra/clangd/test/diagnostics-notes.test
  clang-tools-extra/clangd/test/diagnostics.test
  clang-tools-extra/clangd/test/did-change-configuration-params.test
  clang-tools-extra/clangd/test/execute-command.test
  clang-tools-extra/clangd/test/fixits-codeaction.test
  clang-tools-extra/clangd/test/fixits-command.test
  clang-tools-extra/clangd/test/fixits-embed-in-diagnostic.test
  clang-tools-extra/clangd/test/path-mappings.test
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/test/version.test
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -849,7 +849,8 @@
   ElementsAre(Sym("foo.h", FooHeader.range(;
 
   // Only preamble is built, and no AST is built in this request.
-  Server.addDocument(FooCpp, FooWithoutHeader.code(), WantDiagnostics::No);
+  Server.addDocument(FooCpp, FooWithoutHeader.code(), "null",
+ WantDiagnostics::No);
   // We build AST here, and it should use the latest preamble rather than the
   // stale one.
   EXPECT_THAT(
@@ -859,7 +860,8 @@
   // Reset test environment.
   runAddDocument(Server, FooCpp, FooWithHeader.code());
   // Both preamble and AST are built in this request.
-  Server.addDocument(FooCpp, FooWithoutHeader.code(), WantDiagnostics::Yes);
+  Server.addDocument(FooCpp, FooWithoutHeader.code(), "null",
+ WantDiagnostics::Yes);
   // Use the AST being built in above request.
   EXPECT_THAT(
   cantFail(runLocateSymbolAt(Server, FooCpp, FooWithoutHeader.point())),
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -97,7 +97,7 @@
 
 SymbolSlab TestTU::headerSymbols() const {
   auto AST = build();
-  return std::get<0>(indexHeaderSymbols(AST.getASTContext(),
+  return std::get<0>(indexHeaderSymbols(/*Version=*/"null", AST.getASTContext(),
 AST.getPreprocessorPtr(),
 AST.getCanonicalIncludes()));
 }
@@ -105,8 +105,8 @@
 std::unique_ptr TestTU::index() const {
   auto AST = build();
   auto Idx = std::make_unique(/*UseDex=*/true);
-  Idx->updatePreamble(Filename, AST.getASTContext(), AST.getPreprocessorPtr(),
-  AST.getCanonicalIncludes());
+  Idx->updatePreamble(Filename, /*Version=*/"null", AST.getASTContext(),
+  AST.getPreprocessorPtr(), AST.getCanonicalIncludes());
   Idx->updateMain(Filename, AST);
   return std::move(Idx);
 }
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -41,7 +41,15 @@
 using ::testing::UnorderedElementsAre;
 
 MATCHER_P2(TUState, State, ActionName, "") {
-  return arg.Action.S == State && arg.Action.Name == ActionName;
+  if (arg.Action.S != State) {
+*result_listener << "state is " << arg.Action.S;
+return false;
+  }
+  if (arg

[clang-tools-extra] 2cd33e6 - [clangd] Track document versions, include them with diags, enhance logs

2020-03-04 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-03-05T01:22:32+01:00
New Revision: 2cd33e6fe60f1fe1155ae86ef7e843df55066bda

URL: 
https://github.com/llvm/llvm-project/commit/2cd33e6fe60f1fe1155ae86ef7e843df55066bda
DIFF: 
https://github.com/llvm/llvm-project/commit/2cd33e6fe60f1fe1155ae86ef7e843df55066bda.diff

LOG: [clangd] Track document versions, include them with diags, enhance logs

Summary:
This ties to an LSP feature (diagnostic versioning) but really a lot
of the value is in being able to log what's happening with file versions
and queues more descriptively and clearly.

As such it's fairly invasive, for a logging patch :-\

Key decisions:
 - at the LSP layer, we don't reqire the client to provide versions (LSP
   makes it mandatory but we never enforced it). If not provided,
   versions start at 0 and increment. DraftStore handles this.
 - don't propagate magically using contexts, but rather manually:
   addDocument -> ParseInputs -> (ParsedAST, Preamble, various callbacks)
   Context-propagation would hide the versions from ClangdServer, which
   would make producing good log messages hard
 - within ClangdServer, treat versions as opaque and unordered.
   std::string is a convenient type for this, and allows richer versions
   for embedders. They're "mandatory" but "null" is a reasonable default.

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, kadircet, 
usaxena95, cfe-commits

Tags: #clang

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

Added: 
clang-tools-extra/clangd/test/version.test

Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/Compiler.h
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/ParsedAST.h
clang-tools-extra/clangd/Preamble.cpp
clang-tools-extra/clangd/Preamble.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/TUScheduler.h
clang-tools-extra/clangd/index/FileIndex.cpp
clang-tools-extra/clangd/index/FileIndex.h
clang-tools-extra/clangd/test/diagnostic-category.test
clang-tools-extra/clangd/test/diagnostics-no-tidy.test
clang-tools-extra/clangd/test/diagnostics-notes.test
clang-tools-extra/clangd/test/diagnostics.test
clang-tools-extra/clangd/test/did-change-configuration-params.test
clang-tools-extra/clangd/test/execute-command.test
clang-tools-extra/clangd/test/fixits-codeaction.test
clang-tools-extra/clangd/test/fixits-command.test
clang-tools-extra/clangd/test/fixits-embed-in-diagnostic.test
clang-tools-extra/clangd/test/path-mappings.test
clang-tools-extra/clangd/test/semantic-highlighting.test
clang-tools-extra/clangd/unittests/ClangdTests.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang-tools-extra/clangd/unittests/FileIndexTests.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
clang-tools-extra/clangd/unittests/SyncAPI.cpp
clang-tools-extra/clangd/unittests/SyncAPI.h
clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
clang-tools-extra/clangd/unittests/TestTU.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 44288eb7274d..748269d5aef4 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -41,6 +41,21 @@
 namespace clang {
 namespace clangd {
 namespace {
+
+// LSP defines file versions as numbers that increase.
+// ClangdServer treats them as opaque and therefore uses strings instead.
+std::string encodeVersion(int64_t LSPVersion) {
+  return llvm::to_string(LSPVersion);
+}
+llvm::Optional decodeVersion(llvm::StringRef Encoded) {
+  int64_t Result;
+  if (llvm::to_integer(Encoded, Result, 10))
+return Result;
+  else if (!Encoded.empty()) // Empty can be e.g. diagnostics on close.
+elog("unexpected non-numeric version {0}", Encoded);
+  return llvm::None;
+}
+
 /// Transforms a tweak into a code action that would apply it if executed.
 /// EXPECTS: T.prepare() was called and returned true.
 CodeAction toCodeAction(const ClangdServer::TweakRef &T, const URIForFile 
&File,
@@ -630,8 +645,9 @@ void ClangdLSPServer::onDocumentDidOpen(
 
   const std::string &Contents = Params.textDocument.text;
 
-  DraftMgr.addDraft(File, Params.textDocument.version, Contents);
-  Server->addDocument(File, Contents, WantDiagnostics::Yes);
+  auto Version = DraftMgr.addDraft(File, Params.textDocument.version, 
Contents);
+  Server->addDocument(File, Contents, encodeVersion(Version),
+  WantDiagnostics::Yes);
 }
 
 void ClangdLSPServer::onDocu

[PATCH] D75582: [clangd] Track document versions, include them with diags, enhance logs

2020-03-04 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked an inline comment as done.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.h:73
 virtual void onDiagnosticsReady(PathRef File,
+const llvm::json::Value &Version,
 std::vector Diagnostics) {}

kadircet wrote:
> can we rather have `Optional`s here(both for callbacks and 
> `addDocument`)?
> 
> as clangdserver layer doesn't touch json objects at all currently.
I really do want to make these opaque at the lower layer.
json is a bit fiddly though, reworked to use strings instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75582



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


[PATCH] D75560: Make Decl:: setOwningModuleID() public. (NFC)

2020-03-04 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/AST/DeclBase.h:629-630
 
+public:
+  void setFromASTFile() { FromASTFile = true; }
+

Setting this after creating a `Decl` is not safe in general; declarations with 
this flag set have 8 bytes of additional storage allocated before their start.

An `assert(FromASTFile || hasLocalOwningModuleStorage());` would at least catch 
the unsafe cases. This also needs a comment saying that it's not safe to use in 
general, and perhaps a scarier name to discourage people from calling it. 
(Unless you're creating declarations with `::CreateDeserialized` -- in which 
case you'd need all the `Decl` subclasses to befriend the creator, making this 
function unnecessary -- this is currently only going to be safe if 
`ModulesLocalVisibility` is enabled.)


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

https://reviews.llvm.org/D75560



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


[PATCH] D72860: [modules] Do not cache invalid state for modules that we attempted to load.

2020-03-04 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai marked an inline comment as done.
vsapsai added inline comments.



Comment at: clang/lib/Serialization/ModuleManager.cpp:183
   // Get a buffer of the file and close the file descriptor when done.
-  Buf = FileMgr.getBufferForFile(NewModule->File, /*isVolatile=*/false);
+  Buf = FileMgr.getBufferForFile(NewModule->File, /*isVolatile=*/true);
 }

dexonsmith wrote:
> rsmith wrote:
> > dexonsmith wrote:
> > > vsapsai wrote:
> > > > Made this change because if we don't have a valid module but opened a 
> > > > corresponding .pcm file earlier, there is a high chance that .pcm file 
> > > > was rebuilt.
> > > Please add a comment in the code explaining that.
> > This change is proving really bad for us. This prevents using `mmap` for 
> > loading module files, and instead forces the entire file to be loaded every 
> > time. Please revert.
> Can we limit the revert to explicit vs. implicit module builds?  The scenario 
> Volodymyr was defending against is implicit-only.
Richard, can you please tell what is your modules configuration and how you are 
invoking clang? For implicit builds loading a module instead of `mmap` is still 
better than building a module. But for explicit modules I see there is no need 
to use `isVolatile` as modules aren't changing all the time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72860



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


[PATCH] D75571: [Sema][SVE] Add tests for valid and invalid type usage

2020-03-04 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/test/SemaCXX/sizeless-1.cpp:8
+// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall 
-Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++17 %s
+// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall 
-Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++17 
%s
+

This is a lot of RUN lines (both here and in the other file).  Are you really 
getting any significant benefit from them?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75571



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


[PATCH] D75602: [clangd] Cancel certain operations if the file changes before we start.

2020-03-04 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D75602#1906587 , @thakis wrote:

> This broke building on my bots:
>
> http://45.33.8.238/linux/11862/step_4.txt
>
> `ld.lld: error: undefined symbol: 
> clang::clangd::TUScheduler::InvalidatedError::ID`
>
> Looks like that is indeed declared in this change, but it doesn't have a 
> definition.


Sorry about that, fixing. (I didn't see this on other linkers, maybe because 
the class itself wasn't used in this patch)




Comment at: clang-tools-extra/clangd/Cancellation.cpp:39
+  return true;
   return false; // Not in scope of a task.
 }

kadircet wrote:
> comment seems to be out-of-date.
> 
> `Either not cancelled or not in a cancellable task` ?
Yeah, just removed the comment, this is now pretty obvious.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75602



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


[PATCH] D75572: [Sema][SVE] Reject sizeof and alignof for sizeless types

2020-03-04 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a reviewer: rsmith.
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM

Please give it a day or two before you merge in case someone else has an 
opinion on the new API.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75572



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


[PATCH] D75582: [clangd] Track document versions, include them with diags, enhance logs

2020-03-04 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 248351.
sammccall added a comment.

Use string instead of json Value


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75582

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/test/diagnostic-category.test
  clang-tools-extra/clangd/test/diagnostics-no-tidy.test
  clang-tools-extra/clangd/test/diagnostics-notes.test
  clang-tools-extra/clangd/test/diagnostics.test
  clang-tools-extra/clangd/test/did-change-configuration-params.test
  clang-tools-extra/clangd/test/execute-command.test
  clang-tools-extra/clangd/test/fixits-codeaction.test
  clang-tools-extra/clangd/test/fixits-command.test
  clang-tools-extra/clangd/test/fixits-embed-in-diagnostic.test
  clang-tools-extra/clangd/test/path-mappings.test
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/test/version.test
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -849,7 +849,8 @@
   ElementsAre(Sym("foo.h", FooHeader.range(;
 
   // Only preamble is built, and no AST is built in this request.
-  Server.addDocument(FooCpp, FooWithoutHeader.code(), WantDiagnostics::No);
+  Server.addDocument(FooCpp, FooWithoutHeader.code(), "null",
+ WantDiagnostics::No);
   // We build AST here, and it should use the latest preamble rather than the
   // stale one.
   EXPECT_THAT(
@@ -859,7 +860,8 @@
   // Reset test environment.
   runAddDocument(Server, FooCpp, FooWithHeader.code());
   // Both preamble and AST are built in this request.
-  Server.addDocument(FooCpp, FooWithoutHeader.code(), WantDiagnostics::Yes);
+  Server.addDocument(FooCpp, FooWithoutHeader.code(), "null",
+ WantDiagnostics::Yes);
   // Use the AST being built in above request.
   EXPECT_THAT(
   cantFail(runLocateSymbolAt(Server, FooCpp, FooWithoutHeader.point())),
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -97,16 +97,16 @@
 
 SymbolSlab TestTU::headerSymbols() const {
   auto AST = build();
-  return std::get<0>(indexHeaderSymbols(AST.getASTContext(),
-AST.getPreprocessorPtr(),
-AST.getCanonicalIncludes()));
+  return std::get<0>(
+  indexHeaderSymbols(/*Version=*/"null", AST.getASTContext(),
+ AST.getPreprocessorPtr(), AST.getCanonicalIncludes()));
 }
 
 std::unique_ptr TestTU::index() const {
   auto AST = build();
   auto Idx = std::make_unique(/*UseDex=*/true);
-  Idx->updatePreamble(Filename, AST.getASTContext(), AST.getPreprocessorPtr(),
-  AST.getCanonicalIncludes());
+  Idx->updatePreamble(Filename, /*Version=*/"null", AST.getASTContext(),
+  AST.getPreprocessorPtr(), AST.getCanonicalIncludes());
   Idx->updateMain(Filename, AST);
   return std::move(Idx);
 }
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -41,7 +41,15 @@
 using ::testing::UnorderedElementsAre;
 
 MATCHER_P2(TUState, State, ActionName, "") {
-  return arg.Action.S == State && arg.Action.Name == ActionName;
+  if (arg.Action.S != State) {
+*result_listener << "state is " << arg.Action.S;
+return false;
+  }
+  if (arg.Action.Name != ActionName) {
+*result_listener << "name is " << arg.Action.Name;
+return false;

[clang-tools-extra] e6d9b2c - [clangd] Remove unused+broken InvalidationError class.

2020-03-04 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-03-05T01:08:40+01:00
New Revision: e6d9b2cb92dd8ad544f43dc97e82fa98e07e977c

URL: 
https://github.com/llvm/llvm-project/commit/e6d9b2cb92dd8ad544f43dc97e82fa98e07e977c
DIFF: 
https://github.com/llvm/llvm-project/commit/e6d9b2cb92dd8ad544f43dc97e82fa98e07e977c.diff

LOG: [clangd] Remove unused+broken InvalidationError class.

Added: 


Modified: 
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/TUScheduler.h

Removed: 




diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp 
b/clang-tools-extra/clangd/TUScheduler.cpp
index 714bc7217b8b..2ddfae623677 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -1093,15 +1093,5 @@ DebouncePolicy DebouncePolicy::fixed(clock::duration T) {
   return P;
 }
 
-void TUScheduler::InvalidatedError::log(llvm::raw_ostream &OS) const {
-  switch (Policy) {
-  case InvalidateOnUpdate:
-OS << "Task was cancelled due to a subsequent change to the file.";
-break;
-  case NoInvalidation:
-llvm_unreachable("Invalidated for no reason?");
-  }
-}
-
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/TUScheduler.h 
b/clang-tools-extra/clangd/TUScheduler.h
index 074404c23c11..b2901c42bb62 100644
--- a/clang-tools-extra/clangd/TUScheduler.h
+++ b/clang-tools-extra/clangd/TUScheduler.h
@@ -230,27 +230,14 @@ class TUScheduler {
 InvalidateOnUpdate,
   };
 
-  /// Error to return when an ASTActionInvalidation policy fires.
-  class InvalidatedError : public llvm::ErrorInfo {
-  public:
-static char ID;
-ASTActionInvalidation Policy;
-
-void log(llvm::raw_ostream &OS) const override;
-std::error_code convertToErrorCode() const override {
-  return std::make_error_code(std::errc::interrupted);
-}
-  };
-
   /// Schedule an async read of the AST. \p Action will be called when AST is
   /// ready. The AST passed to \p Action refers to the version of \p File
   /// tracked at the time of the call, even if new updates are received before
   /// \p Action is executed.
   /// If an error occurs during processing, it is forwarded to the \p Action
   /// callback.
-  /// If the context is cancelled before the AST is ready, the callback will
-  /// receive a CancelledError. If the invalidation policy is triggered, the
-  /// callback will receive an InvalidatedError.
+  /// If the context is cancelled before the AST is ready, or the invalidation
+  /// policy is triggered, the callback will receive a CancelledError.
   void runWithAST(llvm::StringRef Name, PathRef File,
   Callback Action,
   ASTActionInvalidation = NoInvalidation);



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


[clang-tools-extra] ea086d1 - Revert "[clang-doc] Improving Markdown Output"

2020-03-04 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2020-03-04T16:00:22-08:00
New Revision: ea086d10ceafb5ad04e4cb37a0f19b916652e74d

URL: 
https://github.com/llvm/llvm-project/commit/ea086d10ceafb5ad04e4cb37a0f19b916652e74d
DIFF: 
https://github.com/llvm/llvm-project/commit/ea086d10ceafb5ad04e4cb37a0f19b916652e74d.diff

LOG: Revert "[clang-doc] Improving Markdown Output"

This reverts commit 45499f3801d8a00919deaf38c801885d8e75b942, it's
still failing on Windows bots.

Added: 


Modified: 
clang-tools-extra/clang-doc/HTMLGenerator.cpp
clang-tools-extra/clang-doc/MDGenerator.cpp
clang-tools-extra/clang-doc/Representation.cpp
clang-tools-extra/clang-doc/Representation.h
clang-tools-extra/clang-doc/assets/index.js
clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
clang-tools-extra/test/clang-doc/single-file.cpp
clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index dc569e2a482c..249d577e8580 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -314,9 +314,9 @@ genReference(const Reference &Type, StringRef 
CurrentDirectory,
 else
   return genLink(Type.Name, "#" + JumpToSection.getValue());
   }
-  llvm::SmallString<64> Path = Type.getRelativeFilePath(CurrentDirectory);
-  llvm::sys::path::append(Path, Type.getFileBaseName() + ".html");
-
+  llvm::SmallString<128> Path =
+  computeRelativePath(Type.Path, CurrentDirectory);
+  llvm::sys::path::append(Path, Type.Name + ".html");
   // Paths in HTML must be in posix-style
   llvm::sys::path::native(Path, llvm::sys::path::Style::posix);
   if (JumpToSection)
@@ -730,17 +730,15 @@ genHTML(const NamespaceInfo &I, Index &InfoIndex, const 
ClangDocContext &CDCtx,
   if (!I.Description.empty())
 Out.emplace_back(genHTML(I.Description));
 
-  llvm::SmallString<64> BasePath = I.getRelativeFilePath("");
-
   std::vector> ChildNamespaces =
-  genReferencesBlock(I.ChildNamespaces, "Namespaces", BasePath);
+  genReferencesBlock(I.ChildNamespaces, "Namespaces", I.Path);
   AppendVector(std::move(ChildNamespaces), Out);
   std::vector> ChildRecords =
-  genReferencesBlock(I.ChildRecords, "Records", BasePath);
+  genReferencesBlock(I.ChildRecords, "Records", I.Path);
   AppendVector(std::move(ChildRecords), Out);
 
   std::vector> ChildFunctions =
-  genFunctionsBlock(I.ChildFunctions, CDCtx, BasePath);
+  genFunctionsBlock(I.ChildFunctions, CDCtx, I.Path);
   AppendVector(std::move(ChildFunctions), Out);
   std::vector> ChildEnums =
   genEnumsBlock(I.ChildEnums, CDCtx);
@@ -862,8 +860,8 @@ llvm::Error HTMLGenerator::generateDocForInfo(Info *I, 
llvm::raw_ostream &OS,
"unexpected info type");
   }
 
-  HTMLFile F = genInfoFile(InfoTitle, I->getRelativeFilePath(""),
-   MainContentNodes, InfoIndex, CDCtx);
+  HTMLFile F =
+  genInfoFile(InfoTitle, I->Path, MainContentNodes, InfoIndex, CDCtx);
   F.Render(OS);
 
   return llvm::Error::success();
@@ -904,7 +902,7 @@ static llvm::Error SerializeIndex(ClangDocContext &CDCtx) {
   J.attribute("USR", toHex(llvm::toStringRef(I.USR)));
   J.attribute("Name", I.Name);
   J.attribute("RefType", getRefType(I.RefType));
-  J.attribute("Path", I.getRelativeFilePath(""));
+  J.attribute("Path", I.Path);
   J.attributeArray("Children", [&] {
 for (const Index &C : I.Children)
   IndexToJSON(C);

diff  --git a/clang-tools-extra/clang-doc/MDGenerator.cpp 
b/clang-tools-extra/clang-doc/MDGenerator.cpp
index 0193d47a13cd..ff99c9001349 100644
--- a/clang-tools-extra/clang-doc/MDGenerator.cpp
+++ b/clang-tools-extra/clang-doc/MDGenerator.cpp
@@ -50,20 +50,10 @@ static void writeHeader(const Twine &Text, unsigned int 
Num, raw_ostream &OS) {
   OS << std::string(Num, '#') + " " + Text << "\n\n";
 }
 
-static void writeFileDefinition(const ClangDocContext &CDCtx, const Location 
&L,
-raw_ostream &OS) {
-
-  if (!CDCtx.RepositoryUrl) {
-OS << "*Defined at " << L.Filename << "#" << std::to_string(L.LineNumber)
-   << "*";
-  } else {
-OS << "*Defined at [" << L.Filename << "#" << std::to_string(L.LineNumber)
-   << "](" << StringRef{CDCtx.RepositoryUrl.getValue()}
-   << llvm::sys::path::relative_path(L.Filename) << "#"
-   << std::to_string(L.LineNumber) << ")"
-   << "*";
-  }
-  OS << "\n\n";
+static void writeFileDefinition(const Location &L, raw_ostream &OS) {
+  OS << genItalic("Defined at line " + std::to_string(L.LineNumber) + " of " +
+  L.Filename)
+ << "\n\n";
 }
 
 static void writeDescription(const CommentInfo &I, raw_ostream &OS) {
@@ -114,19 +104,7 @@ static void wri

[PATCH] D74500: clang: Treat ieee mode as the default for denormal-fp-math

2020-03-04 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 248349.
arsenm added a comment.

Split out constexpr change


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

https://reviews.llvm.org/D74500

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenCUDA/flush-denormals.cu
  clang/test/CodeGenCUDA/propagate-metadata.cu
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/Driver/cuda-flush-denormals-to-zero.cu
  clang/test/Driver/denormal-fp-math.c
  clang/test/Driver/fp-model.c

Index: clang/test/Driver/fp-model.c
===
--- clang/test/Driver/fp-model.c
+++ clang/test/Driver/fp-model.c
@@ -63,6 +63,10 @@
 // RUN:   | FileCheck --check-prefix=WARNf %s
 // WARNf: warning: overriding '-ffp-model=strict' option with '-Ofast' [-Woverriding-t-option]
 
+// RUN: %clang -### -ffp-model=strict -fdenormal-fp-math=preserve-sign,preserve-sign -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN10 %s
+// WARN10: warning: overriding '-ffp-model=strict' option with '-fdenormal-fp-math=preserve-sign,preserve-sign' [-Woverriding-t-option]
+
 // RUN: %clang -### -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NOROUND %s
 // CHECK-NOROUND: "-cc1"
Index: clang/test/Driver/denormal-fp-math.c
===
--- clang/test/Driver/denormal-fp-math.c
+++ clang/test/Driver/denormal-fp-math.c
@@ -8,7 +8,8 @@
 // RUN: not %clang -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=foo,ieee -v 2>&1 | FileCheck -check-prefix=CHECK-INVALID2 %s
 // RUN: not %clang -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=foo,foo -v 2>&1 | FileCheck -check-prefix=CHECK-INVALID3 %s
 
-// CHECK-IEEE: -fdenormal-fp-math=ieee,ieee
+// TODO: ieee is the implied default, and the flag is not passed.
+// CHECK-IEEE: "-fdenormal-fp-math=ieee,ieee"
 // CHECK-PS: "-fdenormal-fp-math=preserve-sign,preserve-sign"
 // CHECK-PZ: "-fdenormal-fp-math=positive-zero,positive-zero"
 // CHECK-NO-UNSAFE-NOT: "-fdenormal-fp-math=ieee"
Index: clang/test/Driver/cuda-flush-denormals-to-zero.cu
===
--- clang/test/Driver/cuda-flush-denormals-to-zero.cu
+++ clang/test/Driver/cuda-flush-denormals-to-zero.cu
@@ -9,5 +9,9 @@
 
 // CPUFTZ-NOT: -fdenormal-fp-math
 
+// FTZ-NOT: -fdenormal-fp-math-f32=
 // FTZ: "-fdenormal-fp-math-f32=preserve-sign,preserve-sign"
-// NOFTZ: "-fdenormal-fp-math=ieee,ieee"
+
+// The default of ieee is omitted
+// NOFTZ-NOT: "-fdenormal-fp-math"
+// NOFTZ-NOT: "-fdenormal-fp-math-f32"
Index: clang/test/CodeGenOpenCL/amdgpu-features.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -14,13 +14,13 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx600 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX600 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx601 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX601 %s
 
-// GFX904: "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+fp64-fp16-denormals,+gfx8-insts,+gfx9-insts,+s-memrealtime,-fp32-denormals"
-// GFX906: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dpp,+flat-address-space,+fp64-fp16-denormals,+gfx8-insts,+gfx9-insts,+s-memrealtime,-fp32-denormals"
-// GFX908: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+fp64-fp16-denormals,+gfx8-insts,+gfx9-insts,+mai-insts,+s-memrealtime,-fp32-denormals"
-// GFX1010: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dpp,+flat-address-space,+fp64-fp16-denormals,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime,-fp32-denormals"
-// GFX1011: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+fp64-fp16-denormals,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime,-fp32-denormals"
-// GFX1012: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+fp64-fp16-denormals,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime,-fp32-denormals"
-// GFX801: "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+fp64-fp16-denormals,+gfx8-insts,+s-memrealtime,-fp32-denormals"
+// GFX904: "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+fp32-denormals,+fp64-fp16-denormals,+gfx8-insts,+gfx9-insts,+s-memrealtime"
+// GFX906: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dpp,+flat-address-space,+fp32-denormals,+fp64-fp16-denormals,+gfx8-insts,+gfx9-insts,+s-memrealtime"
+// GFX908: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-

[PATCH] D75579: [WIP] Replace MCTargetOptionsCommandFlags.inc and CommandFlags.inc by libraries

2020-03-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt:14
+
+#target_link_libraries(llvm-mc-assemble-fuzzer PUBLIC LLVMMCCommandFlags)

Delete comment.


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

https://reviews.llvm.org/D75579



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


[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-03-04 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This is still failing on Windows:

   TEST 'Extra Tools Unit Tests :: 
clang-doc/./ClangDocTests.exe/MDGeneratorTest.emitNamespaceMD' FAILED 

  Note: Google Test filter = MDGeneratorTest.emitNamespaceMD
  
  [==] Running 1 test from 1 test case.
  
  [--] Global test environment set-up.
  
  [--] 1 test from MDGeneratorTest
  
  [ RUN  ] MDGeneratorTest.emitNamespaceMD
  
  
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm-project\clang-tools-extra\unittests\clang-doc\MDGeneratorTest.cpp(77):
 error:   Expected: Expected
  
Which is: "# namespace Namespace\n\n\n\n## Namespaces\n\n* 
[ChildNamespace](../ChildNamespace/index.md)\n\n\n## Records\n\n* 
[ChildStruct](../ChildStruct.md)\n\n\n## Functions\n\n### OneFunction\n\n* 
OneFunction()*\n\n\n\n## Enums\n\n| enum OneEnum |\n\n--\n\n\n\n\n\n"
  
  To be equal to: Actual.str()
  
Which is: "# namespace Namespace\n\n\n\n## Namespaces\n\n* 
[ChildNamespace](../ChildNamespace/index.md)\n\n\n## Records\n\n* 
[ChildStruct](..//ChildStruct.md)\n\n\n## Functions\n\n### OneFunction\n\n* 
OneFunction()*\n\n\n\n## Enums\n\n| enum OneEnum |\n\n--\n\n\n\n\n\n"
  
  With diff:
  
  @@ -10,5 +10,5 @@
  
   ## Records
  
   
  
  -* [ChildStruct](../ChildStruct.md)
  
  +* [ChildStruct](..//ChildStruct.md)
  
   
  
   
  
  
  
  [  FAILED  ] MDGeneratorTest.emitNamespaceMD (1 ms)
  
  [--] 1 test from MDGeneratorTest (1 ms total)
  
  
  
  [--] Global test environment tear-down
  
  [==] 1 test from 1 test case ran. (1 ms total)
  
  [  PASSED  ] 0 tests.
  
  [  FAILED  ] 1 test, listed below:
  
  [  FAILED  ] MDGeneratorTest.emitNamespaceMD
  
  
  
   1 FAILED TEST


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72954



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


[PATCH] D75153: [ThinLTO] Allow usage of all SMT threads in the system

2020-03-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Does `taskset -c 0-3 lld -flavor ...` restrict the number of cores?

  cpu_set_t cpu;
  sched_getaffinity(0, sizeof(cpu), &cpu);
  CPU_COUNT(&cpu)


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

https://reviews.llvm.org/D75153



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


[PATCH] D75602: [clangd] Cancel certain operations if the file changes before we start.

2020-03-04 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This broke building on my bots:

http://45.33.8.238/linux/11862/step_4.txt

`ld.lld: error: undefined symbol: 
clang::clangd::TUScheduler::InvalidatedError::ID`

Looks like that is indeed declared in this change, but it doesn't have a 
definition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75602



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


[PATCH] D75655: [Docs] Document -lto-whole-program-visibility

2020-03-04 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added a reviewer: pcc.
Herald added subscribers: dexonsmith, steven_wu, hiraditya, inglorion.
Herald added a project: clang.

Documents interaction of linker option added in D71913 
 with LTO
visibility.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75655

Files:
  clang/docs/LTOVisibility.rst


Index: clang/docs/LTOVisibility.rst
===
--- clang/docs/LTOVisibility.rst
+++ clang/docs/LTOVisibility.rst
@@ -35,6 +35,16 @@
 (e.g. classes declared in unnamed namespaces) also receive hidden LTO
 visibility.
 
+During the LTO link, all classes with public LTO visibility will be refined
+to hidden LTO visibility when the ``-lto-whole-program-visibility`` lld linker
+option is applied (``-plugin-opt=whole_program_visibility`` for gold). This
+can be used when it is known that the LTO link has whole program visibility,
+because we are LTO linking all translation units as bitcode, except certain
+(e.g.  system) libraries or other native objects known to be safe by the user 
or
+build system, and the binary will not dlopen any libraries deriving from the
+binary’s classes. This is useful in situations where it is not safe to specify
+``-fvisibility=hidden`` at compile time.
+
 A class defined in a translation unit built without LTO receives public
 LTO visibility regardless of its object file visibility, linkage or other
 attributes.


Index: clang/docs/LTOVisibility.rst
===
--- clang/docs/LTOVisibility.rst
+++ clang/docs/LTOVisibility.rst
@@ -35,6 +35,16 @@
 (e.g. classes declared in unnamed namespaces) also receive hidden LTO
 visibility.
 
+During the LTO link, all classes with public LTO visibility will be refined
+to hidden LTO visibility when the ``-lto-whole-program-visibility`` lld linker
+option is applied (``-plugin-opt=whole_program_visibility`` for gold). This
+can be used when it is known that the LTO link has whole program visibility,
+because we are LTO linking all translation units as bitcode, except certain
+(e.g.  system) libraries or other native objects known to be safe by the user or
+build system, and the binary will not dlopen any libraries deriving from the
+binary’s classes. This is useful in situations where it is not safe to specify
+``-fvisibility=hidden`` at compile time.
+
 A class defined in a translation unit built without LTO receives public
 LTO visibility regardless of its object file visibility, linkage or other
 attributes.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72235: [clang-tidy] new altera unroll loops check

2020-03-04 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:41
+  }
+  if (Unroll == PartiallyUnrolled) {
+return;

Please elide braces.



Comment at: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:66
+const auto *ParentStmt = Parent.get();
+if (!ParentStmt) {
+  continue;

Please elide braces.



Comment at: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:93
+  const Expr *Conditional = getCondExpr(Statement);
+  if (!Conditional) {
+return false;

Please elide braces.



Comment at: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:130
+  const Expr *Conditional = getCondExpr(Statement);
+  if (!Conditional) {
+return false;

Please elide braces.



Comment at: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:138
+Expr::EvalResult result;
+if (LHS->isEvaluatable(*Context) && !(RHS->isEvaluatable(*Context))) {
+  return exprHasLargeNumIterations(LHS, Context);

Please elide braces.



Comment at: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:141
+}
+if (RHS->isEvaluatable(*Context) && !(LHS->isEvaluatable(*Context))) {
+  return exprHasLargeNumIterations(RHS, Context);

Please elide braces.



Comment at: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:152
+  if (Expression->EvaluateAsRValue(Result, *Context)) {
+if (!(Result.Val.isInt())) {
+  return false; // Cannot check number of iterations, return false to be

Please elide braces.



Comment at: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:156
+}
+if (Result.Val.getInt() > MaxLoopIterations) {
+  return true; // Assumes values go from 0 to Val in increments of 1.

Please elide braces.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:85
+
+  Finds inner loops that have not been unrolled, as well as fully unrolled
+  loops with unknown loops bounds or a large number of iterations.

Please synchronize with first statement in documentation.


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

https://reviews.llvm.org/D72235



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


[PATCH] D75602: [clangd] Cancel certain operations if the file changes before we start.

2020-03-04 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc627b120eb8b: [clangd] Cancel certain operations if the file 
changes before we start. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75602

Files:
  clang-tools-extra/clangd/Cancellation.cpp
  clang-tools-extra/clangd/Cancellation.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/unittests/CancellationTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "Annotations.h"
+#include "Cancellation.h"
 #include "Context.h"
 #include "Diagnostics.h"
 #include "Matchers.h"
@@ -346,6 +347,63 @@
   << "All reads other than R2B were cancelled";
 }
 
+TEST_F(TUSchedulerTests, Invalidation) {
+  auto Path = testPath("foo.cpp");
+  TUScheduler S(CDB, optsForTest(), captureDiags());
+  std::atomic Builds(0), Actions(0);
+
+  Notification Start;
+  updateWithDiags(S, Path, "a", WantDiagnostics::Yes, [&](std::vector) {
+++Builds;
+Start.wait();
+  });
+  S.runWithAST(
+  "invalidatable", Path,
+  [&](llvm::Expected AST) {
+++Actions;
+EXPECT_FALSE(bool(AST));
+llvm::Error E = AST.takeError();
+EXPECT_TRUE(E.isA());
+consumeError(std::move(E));
+  },
+  TUScheduler::InvalidateOnUpdate);
+  S.runWithAST(
+  "not-invalidatable", Path,
+  [&](llvm::Expected AST) {
+++Actions;
+EXPECT_TRUE(bool(AST));
+  },
+  TUScheduler::NoInvalidation);
+  updateWithDiags(S, Path, "b", WantDiagnostics::Auto, [&](std::vector) {
+++Builds;
+ADD_FAILURE() << "Shouldn't build, all dependents invalidated";
+  });
+  S.runWithAST(
+  "invalidatable", Path,
+  [&](llvm::Expected AST) {
+++Actions;
+EXPECT_FALSE(bool(AST));
+llvm::Error E = AST.takeError();
+EXPECT_TRUE(E.isA());
+consumeError(std::move(E));
+  },
+  TUScheduler::InvalidateOnUpdate);
+  updateWithDiags(S, Path, "c", WantDiagnostics::Auto,
+  [&](std::vector) { ++Builds; });
+  S.runWithAST(
+  "invalidatable", Path,
+  [&](llvm::Expected AST) {
+++Actions;
+EXPECT_TRUE(bool(AST)) << "Shouldn't be invalidated, no update follows";
+  },
+  TUScheduler::InvalidateOnUpdate);
+  Start.notify();
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+
+  EXPECT_EQ(2, Builds.load()) << "Middle build should be skipped";
+  EXPECT_EQ(4, Actions.load()) << "All actions should run (some with error)";
+}
+
 TEST_F(TUSchedulerTests, ManyUpdates) {
   const int FilesCount = 3;
   const int UpdatesPerFile = 10;
Index: clang-tools-extra/clangd/unittests/CancellationTests.cpp
===
--- clang-tools-extra/clangd/unittests/CancellationTests.cpp
+++ clang-tools-extra/clangd/unittests/CancellationTests.cpp
@@ -44,6 +44,30 @@
   Task.second();
 }
 
+struct NestedTasks {
+  std::pair Outer, Inner;
+  NestedTasks() {
+Outer = cancelableTask();
+{
+  WithContext WithOuter(Outer.first.clone());
+  Inner = cancelableTask();
+}
+  }
+};
+
+TEST(CancellationTest, Nested) {
+  // Cancelling inner task works but leaves outer task unaffected.
+  NestedTasks CancelInner;
+  CancelInner.Inner.second();
+  EXPECT_TRUE(isCancelled(CancelInner.Inner.first));
+  EXPECT_FALSE(isCancelled(CancelInner.Outer.first));
+  // Cancellation of outer task is inherited by inner task.
+  NestedTasks CancelOuter;
+  CancelOuter.Outer.second();
+  EXPECT_TRUE(isCancelled(CancelOuter.Inner.first));
+  EXPECT_TRUE(isCancelled(CancelOuter.Outer.first));
+}
+
 TEST(CancellationTest, AsynCancellationTest) {
   std::atomic HasCancelled(false);
   Notification Cancelled;
Index: clang-tools-extra/clangd/TUScheduler.h
===
--- clang-tools-extra/clangd/TUScheduler.h
+++ clang-tools-extra/clangd/TUScheduler.h
@@ -219,6 +219,29 @@
   /// Schedule an async task with no dependencies.
   void run(llvm::StringRef Name, llvm::unique_function Action);
 
+  /// Defines how a runWithAST action is implicitly cancelled by other actions.
+  enum ASTActionInvalidation {
+/// The request will run unless explicitly cancelled.
+NoInvalidation,
+/// The request will be implicitly cancelled by a subsequent update().
+/// (Only if the request was not yet cancelled).
+/// Usefu

[PATCH] D75460: [clangd] Fix isInsideMainFile to be aware of preamble.

2020-03-04 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2be456971935: [clangd] Fix isInsideMainFile to be aware of 
preamble. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75460

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp


Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -461,10 +461,12 @@
 class Header {};
   )cpp";
   TU.Code = R"cpp(
+#define DEFINE_MAIN4 class Main4{};
 class Main1 {};
 DEFINE_CLASS(Main2)
 DEFINE_YY
 class Main {};
+DEFINE_MAIN4
   )cpp";
   TU.ExtraArgs.push_back("-DHeader=Header3");
   TU.ExtraArgs.push_back("-DMain=Main3");
@@ -474,10 +476,13 @@
 return findDecl(AST, Name).getLocation();
   };
   for (const auto *HeaderDecl : {"Header1", "Header2", "Header3"})
-EXPECT_FALSE(isInsideMainFile(DeclLoc(HeaderDecl), SM));
+EXPECT_FALSE(isInsideMainFile(DeclLoc(HeaderDecl), SM)) << HeaderDecl;
 
-  for (const auto *MainDecl : {"Main1", "Main2", "Main3", "YY"})
-EXPECT_TRUE(isInsideMainFile(DeclLoc(MainDecl), SM));
+  for (const auto *MainDecl : {"Main1", "Main2", "Main3", "Main4", "YY"})
+EXPECT_TRUE(isInsideMainFile(DeclLoc(MainDecl), SM)) << MainDecl;
+
+  // Main4 is *spelled* in the preamble, but in the main-file part of it.
+  EXPECT_TRUE(isInsideMainFile(SM.getSpellingLoc(DeclLoc("Main4")), SM));
 }
 
 // Test for functions toHalfOpenFileRange and getHalfOpenFileRange
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -420,7 +420,10 @@
 }
 
 bool isInsideMainFile(SourceLocation Loc, const SourceManager &SM) {
-  return Loc.isValid() && SM.isWrittenInMainFile(SM.getExpansionLoc(Loc));
+  if (!Loc.isValid())
+return false;
+  FileID FID = SM.getFileID(SM.getExpansionLoc(Loc));
+  return FID == SM.getMainFileID() || FID == SM.getPreambleFileID();
 }
 
 llvm::Optional toHalfOpenFileRange(const SourceManager &SM,


Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -461,10 +461,12 @@
 class Header {};
   )cpp";
   TU.Code = R"cpp(
+#define DEFINE_MAIN4 class Main4{};
 class Main1 {};
 DEFINE_CLASS(Main2)
 DEFINE_YY
 class Main {};
+DEFINE_MAIN4
   )cpp";
   TU.ExtraArgs.push_back("-DHeader=Header3");
   TU.ExtraArgs.push_back("-DMain=Main3");
@@ -474,10 +476,13 @@
 return findDecl(AST, Name).getLocation();
   };
   for (const auto *HeaderDecl : {"Header1", "Header2", "Header3"})
-EXPECT_FALSE(isInsideMainFile(DeclLoc(HeaderDecl), SM));
+EXPECT_FALSE(isInsideMainFile(DeclLoc(HeaderDecl), SM)) << HeaderDecl;
 
-  for (const auto *MainDecl : {"Main1", "Main2", "Main3", "YY"})
-EXPECT_TRUE(isInsideMainFile(DeclLoc(MainDecl), SM));
+  for (const auto *MainDecl : {"Main1", "Main2", "Main3", "Main4", "YY"})
+EXPECT_TRUE(isInsideMainFile(DeclLoc(MainDecl), SM)) << MainDecl;
+
+  // Main4 is *spelled* in the preamble, but in the main-file part of it.
+  EXPECT_TRUE(isInsideMainFile(SM.getSpellingLoc(DeclLoc("Main4")), SM));
 }
 
 // Test for functions toHalfOpenFileRange and getHalfOpenFileRange
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -420,7 +420,10 @@
 }
 
 bool isInsideMainFile(SourceLocation Loc, const SourceManager &SM) {
-  return Loc.isValid() && SM.isWrittenInMainFile(SM.getExpansionLoc(Loc));
+  if (!Loc.isValid())
+return false;
+  FileID FID = SM.getFileID(SM.getExpansionLoc(Loc));
+  return FID == SM.getMainFileID() || FID == SM.getPreambleFileID();
 }
 
 llvm::Optional toHalfOpenFileRange(const SourceManager &SM,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75153: [ThinLTO] Allow usage of all SMT threads in the system

2020-03-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I think making the build system responsible for running the backend actions is 
the ideal solution, actually. The main reason we have all this threading logic 
in the linker is to make it easy for users of traditional build systems to use 
ThinLTO with a few flag flips. We haven't actually made build system changes 
for Chrome yet. Instead, we replaced the linker with a script that wraps the 
thin link + backend jobs + native link steps. https://crbug.com/877722 has a 
partial record of ideas we had and stuff we tried for Chrome.


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

https://reviews.llvm.org/D75153



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


[clang-tools-extra] c627b12 - [clangd] Cancel certain operations if the file changes before we start.

2020-03-04 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-03-05T00:10:07+01:00
New Revision: c627b120eb8b7add3f9cf893721335c367d9f037

URL: 
https://github.com/llvm/llvm-project/commit/c627b120eb8b7add3f9cf893721335c367d9f037
DIFF: 
https://github.com/llvm/llvm-project/commit/c627b120eb8b7add3f9cf893721335c367d9f037.diff

LOG: [clangd] Cancel certain operations if the file changes before we start.

Summary:
Otherwise they can force us to build lots of snapshots that we don't need.
Particularly, try to do this for operations that are frequently
generated by editors without explicit user interaction, and where
editing the file makes the result less useful. (Code action
enumeration is a good example).

https://github.com/clangd/clangd/issues/298

This doesn't return the "right" LSP error code (ContentModified) to the client,
we need to teach the cancellation API to distinguish between different causes.

Reviewers: kadircet

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, jfb, 
usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/Cancellation.cpp
clang-tools-extra/clangd/Cancellation.h
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/JSONTransport.cpp
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/TUScheduler.h
clang-tools-extra/clangd/unittests/CancellationTests.cpp
clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Cancellation.cpp 
b/clang-tools-extra/clangd/Cancellation.cpp
index 6b0e21d34e77..ccd27a1452d1 100644
--- a/clang-tools-extra/clangd/Cancellation.cpp
+++ b/clang-tools-extra/clangd/Cancellation.cpp
@@ -13,20 +13,30 @@ namespace clang {
 namespace clangd {
 
 char CancelledError::ID = 0;
-static Key>> FlagKey;
+
+// We don't want a cancelable scope to "shadow" an enclosing one.
+struct CancelState {
+  std::shared_ptr> Cancelled;
+  const CancelState *Parent;
+};
+static Key StateKey;
 
 std::pair cancelableTask() {
-  auto Flag = std::make_shared>();
+  CancelState State;
+  State.Cancelled = std::make_shared>();
+  State.Parent = Context::current().get(StateKey);
   return {
-  Context::current().derive(FlagKey, Flag),
-  [Flag] { *Flag = true; },
+  Context::current().derive(StateKey, State),
+  [Flag(State.Cancelled)] { *Flag = true; },
   };
 }
 
 bool isCancelled(const Context &Ctx) {
-  if (auto *Flag = Ctx.get(FlagKey))
-return **Flag;
-  return false; // Not in scope of a task.
+  for (const CancelState *State = Ctx.get(StateKey); State != nullptr;
+   State = State->Parent)
+if (State->Cancelled->load())
+  return true;
+  return false;
 }
 
 } // namespace clangd

diff  --git a/clang-tools-extra/clangd/Cancellation.h 
b/clang-tools-extra/clangd/Cancellation.h
index 6872c448de86..bdb0bd4ef09f 100644
--- a/clang-tools-extra/clangd/Cancellation.h
+++ b/clang-tools-extra/clangd/Cancellation.h
@@ -76,6 +76,7 @@ using Canceler = std::function;
 std::pair cancelableTask();
 
 /// True if the current context is within a cancelable task which was 
cancelled.
+/// (If the context is within multiple nested tasks, true if any are 
cancelled).
 /// Always false if there is no active cancelable task.
 /// This isn't free (context lookup) - don't call it in a tight loop.
 bool isCancelled(const Context &Ctx = Context::current());

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 5dd00322a5ab..cd833af13e49 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -437,7 +437,8 @@ void ClangdServer::enumerateTweaks(PathRef File, Range Sel,
 CB(std::move(Res));
   };
 
-  WorkScheduler.runWithAST("EnumerateTweaks", File, std::move(Action));
+  WorkScheduler.runWithAST("EnumerateTweaks", File, std::move(Action),
+   TUScheduler::InvalidateOnUpdate);
 }
 
 void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
@@ -556,7 +557,8 @@ void ClangdServer::findDocumentHighlights(
 CB(clangd::findDocumentHighlights(InpAST->AST, Pos));
   };
 
-  WorkScheduler.runWithAST("Highlights", File, std::move(Action));
+  WorkScheduler.runWithAST("Highlights", File, std::move(Action),
+   TUScheduler::InvalidateOnUpdate);
 }
 
 void ClangdServer::findHover(PathRef File, Position Pos,
@@ -570,7 +572,8 @@ void ClangdServer::findHover(PathRef File, Position Pos,
 CB(clangd::getHover(InpAST->AST, Pos, std::move(Style), Index));
   };
 
-  WorkScheduler.runWithAST("Hover", File, std::move(Action));
+  WorkScheduler.runWithAST("Hover", File, std::move(Action),
+   TUScheduler::InvalidateOnUpdate);
 }
 
 void ClangdServer::typeHierarchy(PathRef File, Position Pos, int Resolve,
@@ -618,7 +621,8 @@ 

[PATCH] D75602: [clangd] Cancel certain operations if the file changes before we start.

2020-03-04 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 248336.
sammccall marked 7 inline comments as done.
sammccall added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75602

Files:
  clang-tools-extra/clangd/Cancellation.cpp
  clang-tools-extra/clangd/Cancellation.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/unittests/CancellationTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "Annotations.h"
+#include "Cancellation.h"
 #include "Context.h"
 #include "Diagnostics.h"
 #include "Matchers.h"
@@ -346,6 +347,63 @@
   << "All reads other than R2B were cancelled";
 }
 
+TEST_F(TUSchedulerTests, Invalidation) {
+  auto Path = testPath("foo.cpp");
+  TUScheduler S(CDB, optsForTest(), captureDiags());
+  std::atomic Builds(0), Actions(0);
+
+  Notification Start;
+  updateWithDiags(S, Path, "a", WantDiagnostics::Yes, [&](std::vector) {
+++Builds;
+Start.wait();
+  });
+  S.runWithAST(
+  "invalidatable", Path,
+  [&](llvm::Expected AST) {
+++Actions;
+EXPECT_FALSE(bool(AST));
+llvm::Error E = AST.takeError();
+EXPECT_TRUE(E.isA());
+consumeError(std::move(E));
+  },
+  TUScheduler::InvalidateOnUpdate);
+  S.runWithAST(
+  "not-invalidatable", Path,
+  [&](llvm::Expected AST) {
+++Actions;
+EXPECT_TRUE(bool(AST));
+  },
+  TUScheduler::NoInvalidation);
+  updateWithDiags(S, Path, "b", WantDiagnostics::Auto, [&](std::vector) {
+++Builds;
+ADD_FAILURE() << "Shouldn't build, all dependents invalidated";
+  });
+  S.runWithAST(
+  "invalidatable", Path,
+  [&](llvm::Expected AST) {
+++Actions;
+EXPECT_FALSE(bool(AST));
+llvm::Error E = AST.takeError();
+EXPECT_TRUE(E.isA());
+consumeError(std::move(E));
+  },
+  TUScheduler::InvalidateOnUpdate);
+  updateWithDiags(S, Path, "c", WantDiagnostics::Auto,
+  [&](std::vector) { ++Builds; });
+  S.runWithAST(
+  "invalidatable", Path,
+  [&](llvm::Expected AST) {
+++Actions;
+EXPECT_TRUE(bool(AST)) << "Shouldn't be invalidated, no update follows";
+  },
+  TUScheduler::InvalidateOnUpdate);
+  Start.notify();
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+
+  EXPECT_EQ(2, Builds.load()) << "Middle build should be skipped";
+  EXPECT_EQ(4, Actions.load()) << "All actions should run (some with error)";
+}
+
 TEST_F(TUSchedulerTests, ManyUpdates) {
   const int FilesCount = 3;
   const int UpdatesPerFile = 10;
Index: clang-tools-extra/clangd/unittests/CancellationTests.cpp
===
--- clang-tools-extra/clangd/unittests/CancellationTests.cpp
+++ clang-tools-extra/clangd/unittests/CancellationTests.cpp
@@ -44,6 +44,30 @@
   Task.second();
 }
 
+struct NestedTasks {
+  std::pair Outer, Inner;
+  NestedTasks() {
+Outer = cancelableTask();
+{
+  WithContext WithOuter(Outer.first.clone());
+  Inner = cancelableTask();
+}
+  }
+};
+
+TEST(CancellationTest, Nested) {
+  // Cancelling inner task works but leaves outer task unaffected.
+  NestedTasks CancelInner;
+  CancelInner.Inner.second();
+  EXPECT_TRUE(isCancelled(CancelInner.Inner.first));
+  EXPECT_FALSE(isCancelled(CancelInner.Outer.first));
+  // Cancellation of outer task is inherited by inner task.
+  NestedTasks CancelOuter;
+  CancelOuter.Outer.second();
+  EXPECT_TRUE(isCancelled(CancelOuter.Inner.first));
+  EXPECT_TRUE(isCancelled(CancelOuter.Outer.first));
+}
+
 TEST(CancellationTest, AsynCancellationTest) {
   std::atomic HasCancelled(false);
   Notification Cancelled;
Index: clang-tools-extra/clangd/TUScheduler.h
===
--- clang-tools-extra/clangd/TUScheduler.h
+++ clang-tools-extra/clangd/TUScheduler.h
@@ -219,6 +219,29 @@
   /// Schedule an async task with no dependencies.
   void run(llvm::StringRef Name, llvm::unique_function Action);
 
+  /// Defines how a runWithAST action is implicitly cancelled by other actions.
+  enum ASTActionInvalidation {
+/// The request will run unless explicitly cancelled.
+NoInvalidation,
+/// The request will be implicitly cancelled by a subsequent update().
+/// (Only if the request was not yet cancelled).
+/// Useful for requests that are generated by clients, without any explicit

[PATCH] D72954: [clang-doc] Improving Markdown Output

2020-03-04 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG45499f3801d8: [clang-doc] Improving Markdown Output 
(authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72954

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/assets/index.js
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/test/clang-doc/single-file.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
@@ -47,14 +47,12 @@
 
 ## Namespaces
 
-ChildNamespace
-
+* [ChildNamespace](../ChildNamespace/index.md)
 
 
 ## Records
 
-ChildStruct
-
+* [ChildStruct](../ChildStruct.md)
 
 
 ## Functions
@@ -106,7 +104,7 @@
   assert(!Err);
   std::string Expected = R"raw(# class r
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 Inherits from F, G
 
@@ -171,7 +169,7 @@
 
 *void f(int P)*
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 )raw";
 
@@ -202,7 +200,7 @@
 | X |
 
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 )raw";
 
@@ -331,7 +329,7 @@
 
 *void f(int I, int J)*
 
-*Defined at line 10 of test.cpp*
+*Defined at test.cpp#10*
 
 
 
Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -63,24 +63,24 @@
   std::string Expected = R"raw(
 
 namespace Namespace
-
-
-
+
+
+
 test-project
 
-  
+  
   
 namespace Namespace
 Namespaces
 
   
-ChildNamespace
+ChildNamespace
   
 
 Records
 
   
-ChildStruct
+ChildStruct
   
 
 Functions
@@ -196,14 +196,14 @@
 
   
 private 
-int
+int
  X
   
 
 Records
 
   
-ChildStruct
+ChildStruct
   
 
 Functions
Index: clang-tools-extra/test/clang-doc/single-file.cpp
===
--- clang-tools-extra/test/clang-doc/single-file.cpp
+++ clang-tools-extra/test/clang-doc/single-file.cpp
@@ -3,7 +3,7 @@
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: clang-doc --doxygen --executor=standalone -p %t %t/test.cpp -output=%t/docs
-// RUN: cat %t/docs/GlobalNamespace.yaml | FileCheck %s --check-prefix=CHECK
+// RUN: cat %t/docs/GlobalNamespace/index.yaml | FileCheck %s --check-prefix=CHECK
 // RUN: rm -rf %t
 
 void function(int x);
@@ -12,20 +12,20 @@
 
 // CHECK: ---
 // CHECK-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
-// CHECK-NEXT: ChildFunctions:  
+// CHECK-NEXT: ChildFunctions:
 // CHECK-NEXT:   - USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
 // CHECK-NEXT:Name:'function'
-// CHECK-NEXT:DefLocation: 
+// CHECK-NEXT:DefLocation:
 // CHECK-NEXT:  LineNumber:  [[@LINE-8]]
 // CHECK-NEXT:  Filename:'{{.*}}
-// CHECK-NEXT:Location:
+// CHECK-NEXT:Location:
 // CHECK-NEXT:  - LineNumber:  [[@LINE-13]]
 // CHECK-NEXT:Filename:'{{.*}}'
-// CHECK-NEXT:Params:  
-// CHECK-NEXT:  - Type:
+// CHECK-NEXT:Params:
+// CHECK-NEXT:  - Type:
 // CHECK-NEXT:  Name:'int'
 // CHECK-NEXT:Name:'x'
-// CHECK-NEXT:ReturnType:  
-// CHECK-NEXT:  Type:
+// CHECK-NEXT:ReturnType:
+// CHECK-NEXT:  Type:
 // CHECK-NEXT:Name:'void'
 // CHECK-NEXT:...
Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -293

[PATCH] D75643: [Sema] Don't emit pointer to int cast warnings under -Wmicrosoft-cast

2020-03-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a subscriber: rsmith.
rnk added a comment.

Looking at the review, I think @rsmith requested this -Wmicrosoft-cast behavior 
here:
https://reviews.llvm.org/D72231#1857660

This change looks good to me, but I wanted to get his input before we undo his 
request.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75643



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


[PATCH] D75579: [WIP] Replace MCTargetOptionsCommandFlags.inc and CommandFlags.inc by libraries

2020-03-04 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 248328.
serge-sans-paille added a comment.

This passes the following configurations:

-DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;lld' -DBUILD_SHARED_LIBS=on 
-DLLVM_LINK_LLVM_DYLIB=off -DCLANG_LINK_CLANG_DYLIB=off

-DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;lld' -DBUILD_SHARED_LIBS=off 
-DLLVM_LINK_LLVM_DYLIB=off -DCLANG_LINK_CLANG_DYLIB=off

-DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;lld' -DBUILD_SHARED_LIBS=off 
-DLLVM_LINK_LLVM_DYLIB=on -DCLANG_LINK_CLANG_DYLIB=on


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

https://reviews.llvm.org/D75579

Files:
  clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
  lld/Common/CMakeLists.txt
  lld/Common/TargetOptionsCommandFlags.cpp
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/CodeGen/CommandFlags.inc
  llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
  llvm/include/llvm/MC/MCTargetOptionsCommandFlags.inc
  llvm/include/llvm/module.modulemap
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/CommandFlags/CMakeLists.txt
  llvm/lib/CodeGen/CommandFlags/CommandFlags.cpp
  llvm/lib/MC/CMakeLists.txt
  llvm/lib/MC/CommandFlags/CMakeLists.txt
  llvm/lib/MC/CommandFlags/MCTargetOptionsCommandFlags.cpp
  llvm/tools/dsymutil/CMakeLists.txt
  llvm/tools/dsymutil/DwarfStreamer.cpp
  llvm/tools/gold/CMakeLists.txt
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llc/CMakeLists.txt
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/CMakeLists.txt
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-dwp/CMakeLists.txt
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
  llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
  llvm/tools/llvm-lto/CMakeLists.txt
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/CMakeLists.txt
  llvm/tools/llvm-lto2/llvm-lto2.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/CMakeLists.txt
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/CMakeLists.txt
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/CMakeLists.txt
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-opt-fuzzer/CMakeLists.txt
  llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/lto/lto.cpp
  llvm/tools/opt/CMakeLists.txt
  llvm/tools/opt/opt.cpp
  llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
  llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp

Index: llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
+++ llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
@@ -25,7 +25,7 @@
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSubtargetInfo.h"
-#include "llvm/MC/MCTargetOptionsCommandFlags.inc"
+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
 #include "llvm/PassAnalysisSupport.h"
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -433,7 +433,7 @@
TripleName,
inconvertibleErrorCode());
 
-  MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags();
+  MCTargetOptions MCOptions = mc::InitMCTargetOptionsFromFlags();
   MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
   if (!MAI)
 return make_error("no asm info for target " + TripleName,
Index: llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
===
--- llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
+++ llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
@@ -22,3 +22,4 @@
   )
 
 target_link_libraries(DebugInfoDWARFTests PRIVATE LLVMTestingSupport)
+target_link_libraries(DebugInfoDWARFTests PUBLIC LLVMMCCommandFlags)
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -22,7 +22,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Bitcode/BitcodeWriterPass.h"
-#include "llvm/CodeGen/CommandFlags.inc"
+#include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/CodeGen/TargetPassConfig.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/DataLayout.h"
@@ -471,16 +471,17 @@
StringRef FeaturesStr,
const TargetOptions &Options) {
   std::string Error;
-  const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple,
- Error);
+  const Target *TheTarget =
+  TargetRegistry::lookupTarget(codegen::getMArch(), TheTriple, Error);
   // Some modules don't specify a triple, and this is okay.
   if (!TheTarget) {
 return nullptr;
   }
 
-  return TheTarget->createTargetMachine(TheTriple.getT

[PATCH] D75613: [Sema] Reword -Wrange-loop-analysis warning messages

2020-03-04 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 248332.
aaronpuchert added a comment.

Drop SpelledAsLValue = false, which seems to be wrong.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75613

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaStmt.cpp
  clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
  clang/test/SemaCXX/warn-range-loop-analysis.cpp

Index: clang/test/SemaCXX/warn-range-loop-analysis.cpp
===
--- clang/test/SemaCXX/warn-range-loop-analysis.cpp
+++ clang/test/SemaCXX/warn-range-loop-analysis.cpp
@@ -71,17 +71,17 @@
   Container bar_container;
 
   for (const int &x : int_non_ref_container) {}
-  // expected-warning@-1 {{loop variable 'x' is always a copy because the range of type 'Container' does not return a reference}}
+  // expected-warning@-1 {{loop variable 'x' binds to a temporary value produced by a range of type 'Container'}}
   // expected-note@-2 {{use non-reference type 'int'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:18-[[@LINE-3]]:19}:""
 
   for (const double &x : int_container) {}
-  // expected-warning@-1 {{loop variable 'x' has type 'const double &' but is initialized with type 'int' resulting in a copy}}
-  // expected-note@-2 {{use non-reference type 'double' to keep the copy or type 'const int &' to prevent copying}}
+  // expected-warning@-1 {{loop variable 'x' of type 'const double &' binds to a temporary constructed from type 'int &'}}
+  // expected-note@-2 {{use non-reference type 'double' to make construction explicit or type 'const int &' to prevent copying}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:21-[[@LINE-3]]:22}:""
 
   for (const Bar x : bar_container) {}
-  // expected-warning@-1 {{loop variable 'x' of type 'const Bar' creates a copy from type 'const Bar'}}
+  // expected-warning@-1 {{loop variable 'x' creates a copy from type 'const Bar'}}
   // expected-note@-2 {{use reference type 'const Bar &' to prevent copying}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:18-[[@LINE-3]]:18}:"&"
 }
@@ -92,7 +92,7 @@
   for (const int &&x : A) {}
   // No warning, rvalue-reference to the temporary
   for (const int &x : A) {}
-  // expected-warning@-1 {{always a copy}}
+  // expected-warning@-1 {{binds to a temporary value produced by a range}}
   // expected-note@-2 {{'int'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:18-[[@LINE-3]]:19}:""
   for (const int x : A) {}
@@ -107,7 +107,7 @@
   for (const double &&x : A) {}
   // No warning, rvalue-reference to the temporary
   for (const double &x : A) {}
-  // expected-warning@-1 {{always a copy}}
+  // expected-warning@-1 {{binds to a temporary value produced by a range}}
   // expected-note@-2 {{'double'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:21-[[@LINE-3]]:22}:""
   for (const double x : A) {}
@@ -122,7 +122,7 @@
   for (const Bar &&x : A) {}
   // No warning, rvalue-reference to the temporary
   for (const Bar &x : A) {}
-  // expected-warning@-1 {{always a copy}}
+  // expected-warning@-1 {{binds to a temporary value produced by a range}}
   // expected-note@-2 {{'Bar'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:18-[[@LINE-3]]:19}:""
   for (const Bar x : A) {}
@@ -152,16 +152,16 @@
   // No warning
 
   for (const double &&x : B) {}
-  // expected-warning@-1 {{resulting in a copy}}
+  // expected-warning@-1 {{binds to a temporary constructed from}}
   // expected-note-re@-2 {{'double'{{.*}}'const int &'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:21-[[@LINE-3]]:23}:""
   for (const double &x : B) {}
-  // expected-warning@-1 {{resulting in a copy}}
+  // expected-warning@-1 {{binds to a temporary constructed from}}
   // expected-note-re@-2 {{'double'{{.*}}'const int &'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:21-[[@LINE-3]]:22}:""
   for (const double x : B) {}
   for (double &&x : B) {}
-  // expected-warning@-1 {{resulting in a copy}}
+  // expected-warning@-1 {{binds to a temporary constructed from}}
   // expected-note-re@-2 {{'double'{{.*}}'const int &'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:17}:""
   //for (double &x : B) {}
@@ -170,16 +170,16 @@
   // No warning
 
   for (const Bar &&x : B) {}
-  // expected-warning@-1 {{resulting in a copy}}
+  // expected-warning@-1 {{binds to a temporary constructed from}}
   // expected-note@-2 {{'Bar'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:18-[[@LINE-3]]:20}:""
   for (const Bar &x : B) {}
-  // expected-warning@-1 {{resulting in a copy}}
+  // expected-warning@-1 {{binds to a temporary constructed from}}
   // expected-note@-2 {{'Bar'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:18-[[@LINE-3]]:19}:""
   for (const Bar x : B) {}
   for (Bar &&x : B) {}
-  // expected-warning@-1 {{resulting in a copy}}
+  // expected-warning@-1 {{binds to a temporary constructed from}}
   // expected-note@-2 {{'Bar'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[

[PATCH] D75613: [Sema] Reword -Wrange-loop-analysis warning messages

2020-03-04 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 248325.
aaronpuchert added a comment.

- Change diagnostic names to reflect the changed messages.
- Also change the wording of note_use_type_or_non_reference.
- The warning that was warn_for_range_const_reference_copy is only emitted if 
the operator* call returns a reference, so we should also print a reference 
type in the warning message. Otherwise this would be confusing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75613

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaStmt.cpp
  clang/test/SemaCXX/warn-range-loop-analysis-trivially-copyable.cpp
  clang/test/SemaCXX/warn-range-loop-analysis.cpp

Index: clang/test/SemaCXX/warn-range-loop-analysis.cpp
===
--- clang/test/SemaCXX/warn-range-loop-analysis.cpp
+++ clang/test/SemaCXX/warn-range-loop-analysis.cpp
@@ -71,17 +71,17 @@
   Container bar_container;
 
   for (const int &x : int_non_ref_container) {}
-  // expected-warning@-1 {{loop variable 'x' is always a copy because the range of type 'Container' does not return a reference}}
+  // expected-warning@-1 {{loop variable 'x' binds to a temporary value produced by a range of type 'Container'}}
   // expected-note@-2 {{use non-reference type 'int'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:18-[[@LINE-3]]:19}:""
 
   for (const double &x : int_container) {}
-  // expected-warning@-1 {{loop variable 'x' has type 'const double &' but is initialized with type 'int' resulting in a copy}}
-  // expected-note@-2 {{use non-reference type 'double' to keep the copy or type 'const int &' to prevent copying}}
+  // expected-warning@-1 {{loop variable 'x' of type 'const double &' binds to a temporary constructed from type 'int &'}}
+  // expected-note@-2 {{use non-reference type 'double' to make construction explicit or type 'const int &' to prevent copying}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:21-[[@LINE-3]]:22}:""
 
   for (const Bar x : bar_container) {}
-  // expected-warning@-1 {{loop variable 'x' of type 'const Bar' creates a copy from type 'const Bar'}}
+  // expected-warning@-1 {{loop variable 'x' creates a copy from type 'const Bar'}}
   // expected-note@-2 {{use reference type 'const Bar &' to prevent copying}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:18-[[@LINE-3]]:18}:"&"
 }
@@ -92,7 +92,7 @@
   for (const int &&x : A) {}
   // No warning, rvalue-reference to the temporary
   for (const int &x : A) {}
-  // expected-warning@-1 {{always a copy}}
+  // expected-warning@-1 {{binds to a temporary value produced by a range}}
   // expected-note@-2 {{'int'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:18-[[@LINE-3]]:19}:""
   for (const int x : A) {}
@@ -107,7 +107,7 @@
   for (const double &&x : A) {}
   // No warning, rvalue-reference to the temporary
   for (const double &x : A) {}
-  // expected-warning@-1 {{always a copy}}
+  // expected-warning@-1 {{binds to a temporary value produced by a range}}
   // expected-note@-2 {{'double'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:21-[[@LINE-3]]:22}:""
   for (const double x : A) {}
@@ -122,7 +122,7 @@
   for (const Bar &&x : A) {}
   // No warning, rvalue-reference to the temporary
   for (const Bar &x : A) {}
-  // expected-warning@-1 {{always a copy}}
+  // expected-warning@-1 {{binds to a temporary value produced by a range}}
   // expected-note@-2 {{'Bar'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:18-[[@LINE-3]]:19}:""
   for (const Bar x : A) {}
@@ -152,16 +152,16 @@
   // No warning
 
   for (const double &&x : B) {}
-  // expected-warning@-1 {{resulting in a copy}}
+  // expected-warning@-1 {{binds to a temporary constructed from}}
   // expected-note-re@-2 {{'double'{{.*}}'const int &'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:21-[[@LINE-3]]:23}:""
   for (const double &x : B) {}
-  // expected-warning@-1 {{resulting in a copy}}
+  // expected-warning@-1 {{binds to a temporary constructed from}}
   // expected-note-re@-2 {{'double'{{.*}}'const int &'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:21-[[@LINE-3]]:22}:""
   for (const double x : B) {}
   for (double &&x : B) {}
-  // expected-warning@-1 {{resulting in a copy}}
+  // expected-warning@-1 {{binds to a temporary constructed from}}
   // expected-note-re@-2 {{'double'{{.*}}'const int &'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:17}:""
   //for (double &x : B) {}
@@ -170,16 +170,16 @@
   // No warning
 
   for (const Bar &&x : B) {}
-  // expected-warning@-1 {{resulting in a copy}}
+  // expected-warning@-1 {{binds to a temporary constructed from}}
   // expected-note@-2 {{'Bar'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:18-[[@LINE-3]]:20}:""
   for (const Bar &x : B) {}
-  // expected-warning@-1 {{resulting in a copy}}
+  // expected-warning@-1 {{binds to a temporary constructed from}}
   // expected-note@-2 {{'Bar'}}
   // CHECK: fix-it:"{{.*}}":

[PATCH] D75286: [clangd] Handle clang-tidy suppression comments for diagnostics inside macro expansions

2020-03-04 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:353
+SM.getFileID(Loc) != FileFilter) {
+  return false;
+}

why are we breaking the loop if we hit another file ID, rather than just not 
checking it?
I think a macro token can be expanded into another macro (with a non-main file 
ID) which in turn expands into the main-file - we'd want to reach the main file 
in that case.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:215
 /// to this function.
-/// The `CheckMacroExpansion` parameter determines whether the function should
-/// handle the case where the diagnostic is inside a macro expansion. A degree
-/// of control over this is needed because handling this case can require
-/// examining source files other than the one in which the diagnostic is
-/// located, and in some use cases we cannot rely on such other files being
-/// mapped in the SourceMapper.
+/// If a valid FileID is passed as `FileFilter`, the function does not attempt
+/// to read source files other than the one identified by the filter. A degree

I do wonder a how hard it would be to approach this more directly: 
(conditionally )use some API for pulling code out of the SourceManager that 
*won't* silently do IO.
ContentCache::getRawBuffer() or something?

Up to you whether to look at this at all of course, this approach is better 
than what we have now.



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:288
   // source buffer for preamble files. For the same reason, we ask
   // shouldSuppressDiagnostic not to follow macro expansions, since
   // those might take us into a preamble file as well.

this part of the comment seems stale



Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:278
+  #define BAD 8 / i
+  double f = BAD;  // NOLINT
+  double g = [[8]] / i;

you may want a case with two levels of expansion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75286



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


[PATCH] D72235: [clang-tidy] new altera unroll loops check

2020-03-04 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 248322.
ffrankies added a comment.

@Eugene.Zelenko It turns out we were using an old mirror 
 of the clang-tools-extra 
repository, that no longer seems to be updated. I switched to the llvm-project 
 repo, and updated the documentation 
accordingly (some of the formatting is different now). Let me know if I missed 
anything - if not, I will be switching the other checks over to the 
llvm-project repo as well over the coming weeks.


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

https://reviews.llvm.org/D72235

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/altera-unroll-loops.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
@@ -0,0 +1,359 @@
+// RUN: %check_clang_tidy %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 50}]}" -header-filter=.* "--" --include opencl-c.h -cl-std=CL1.2 -c
+
+// Inner loops should be unrolled
+__kernel void nested_simple_loops(__global int *A) {
+for (int i = 0; i < 1000; ++i) {
+for (int j = 0; j < 2000; ++j) { 
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[0] += i + j;
+}
+}
+
+for (int i = 0; i < 1000; ++i) {
+int j = 0;
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[1] += i + j;
+j++;
+}
+}
+
+for (int i = 0; i < 1000; ++i) {
+int j = 0; 
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[2] += i + j;
+j++;
+} while (j < 2000);
+}
+
+int i = 0;
+while (i < 1000) {
+for (int j = 0; j < 2000; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[3] += i + j;
+}
+i++;
+}
+
+i = 0;
+while (i < 1000) {
+int j = 0;
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[4] += i + j;
+j++;
+}
+i++;
+}
+
+i = 0;
+while (i < 1000) {
+int j = 0;
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[5] += i + j;
+j++;
+} while (j < 2000);
+i++;
+}
+
+i = 0;
+do {
+for (int j = 0; j < 2000; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[6] += i + j;
+}
+i++;
+} while (i < 1000);
+
+i = 0;
+do {
+int j = 0;
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[7] += i + j;
+j++;
+}
+i++;
+} while (i < 1000);
+
+i = 0;
+do {
+int j = 0;
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[8] += i + j;
+j++;
+} while (j < 2000);
+i++;
+} while (i < 1000);
+
+for (int i = 0; i < 100; ++i) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+printf("Hello");
+}
+
+i = 0;

[clang-tools-extra] 2be4569 - [clangd] Fix isInsideMainFile to be aware of preamble.

2020-03-04 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-03-04T23:57:21+01:00
New Revision: 2be4569719357c55fa9680265bbdcfb798468e9a

URL: 
https://github.com/llvm/llvm-project/commit/2be4569719357c55fa9680265bbdcfb798468e9a
DIFF: 
https://github.com/llvm/llvm-project/commit/2be4569719357c55fa9680265bbdcfb798468e9a.diff

LOG: [clangd] Fix isInsideMainFile to be aware of preamble.

Reviewers: kadircet

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index d18daa910d18..75154723bb72 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -420,7 +420,10 @@ static SourceRange getTokenFileRange(SourceLocation Loc,
 }
 
 bool isInsideMainFile(SourceLocation Loc, const SourceManager &SM) {
-  return Loc.isValid() && SM.isWrittenInMainFile(SM.getExpansionLoc(Loc));
+  if (!Loc.isValid())
+return false;
+  FileID FID = SM.getFileID(SM.getExpansionLoc(Loc));
+  return FID == SM.getMainFileID() || FID == SM.getPreambleFileID();
 }
 
 llvm::Optional toHalfOpenFileRange(const SourceManager &SM,

diff  --git a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp 
b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
index 5c45675ab74d..49f6a73cec48 100644
--- a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -461,10 +461,12 @@ TEST(SourceCodeTests, IsInsideMainFile){
 class Header {};
   )cpp";
   TU.Code = R"cpp(
+#define DEFINE_MAIN4 class Main4{};
 class Main1 {};
 DEFINE_CLASS(Main2)
 DEFINE_YY
 class Main {};
+DEFINE_MAIN4
   )cpp";
   TU.ExtraArgs.push_back("-DHeader=Header3");
   TU.ExtraArgs.push_back("-DMain=Main3");
@@ -474,10 +476,13 @@ TEST(SourceCodeTests, IsInsideMainFile){
 return findDecl(AST, Name).getLocation();
   };
   for (const auto *HeaderDecl : {"Header1", "Header2", "Header3"})
-EXPECT_FALSE(isInsideMainFile(DeclLoc(HeaderDecl), SM));
+EXPECT_FALSE(isInsideMainFile(DeclLoc(HeaderDecl), SM)) << HeaderDecl;
 
-  for (const auto *MainDecl : {"Main1", "Main2", "Main3", "YY"})
-EXPECT_TRUE(isInsideMainFile(DeclLoc(MainDecl), SM));
+  for (const auto *MainDecl : {"Main1", "Main2", "Main3", "Main4", "YY"})
+EXPECT_TRUE(isInsideMainFile(DeclLoc(MainDecl), SM)) << MainDecl;
+
+  // Main4 is *spelled* in the preamble, but in the main-file part of it.
+  EXPECT_TRUE(isInsideMainFile(SM.getSpellingLoc(DeclLoc("Main4")), SM));
 }
 
 // Test for functions toHalfOpenFileRange and getHalfOpenFileRange



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


[clang-tools-extra] 45499f3 - [clang-doc] Improving Markdown Output

2020-03-04 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2020-03-04T14:42:07-08:00
New Revision: 45499f3801d8a00919deaf38c801885d8e75b942

URL: 
https://github.com/llvm/llvm-project/commit/45499f3801d8a00919deaf38c801885d8e75b942
DIFF: 
https://github.com/llvm/llvm-project/commit/45499f3801d8a00919deaf38c801885d8e75b942.diff

LOG: [clang-doc] Improving Markdown Output

This change has two components. The moves the generated file
for a namespace to the directory named after the namespace in
a file named 'index.'. This greatly improves the browsing
experience since the index page is shown by default for a directory.

The second improves the markdown output by adding the links to the
referenced pages for children objects and the link back to the source
code.

Patch By: Clayton

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

Added: 


Modified: 
clang-tools-extra/clang-doc/HTMLGenerator.cpp
clang-tools-extra/clang-doc/MDGenerator.cpp
clang-tools-extra/clang-doc/Representation.cpp
clang-tools-extra/clang-doc/Representation.h
clang-tools-extra/clang-doc/assets/index.js
clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
clang-tools-extra/test/clang-doc/single-file.cpp
clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index 249d577e8580..dc569e2a482c 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -314,9 +314,9 @@ genReference(const Reference &Type, StringRef 
CurrentDirectory,
 else
   return genLink(Type.Name, "#" + JumpToSection.getValue());
   }
-  llvm::SmallString<128> Path =
-  computeRelativePath(Type.Path, CurrentDirectory);
-  llvm::sys::path::append(Path, Type.Name + ".html");
+  llvm::SmallString<64> Path = Type.getRelativeFilePath(CurrentDirectory);
+  llvm::sys::path::append(Path, Type.getFileBaseName() + ".html");
+
   // Paths in HTML must be in posix-style
   llvm::sys::path::native(Path, llvm::sys::path::Style::posix);
   if (JumpToSection)
@@ -730,15 +730,17 @@ genHTML(const NamespaceInfo &I, Index &InfoIndex, const 
ClangDocContext &CDCtx,
   if (!I.Description.empty())
 Out.emplace_back(genHTML(I.Description));
 
+  llvm::SmallString<64> BasePath = I.getRelativeFilePath("");
+
   std::vector> ChildNamespaces =
-  genReferencesBlock(I.ChildNamespaces, "Namespaces", I.Path);
+  genReferencesBlock(I.ChildNamespaces, "Namespaces", BasePath);
   AppendVector(std::move(ChildNamespaces), Out);
   std::vector> ChildRecords =
-  genReferencesBlock(I.ChildRecords, "Records", I.Path);
+  genReferencesBlock(I.ChildRecords, "Records", BasePath);
   AppendVector(std::move(ChildRecords), Out);
 
   std::vector> ChildFunctions =
-  genFunctionsBlock(I.ChildFunctions, CDCtx, I.Path);
+  genFunctionsBlock(I.ChildFunctions, CDCtx, BasePath);
   AppendVector(std::move(ChildFunctions), Out);
   std::vector> ChildEnums =
   genEnumsBlock(I.ChildEnums, CDCtx);
@@ -860,8 +862,8 @@ llvm::Error HTMLGenerator::generateDocForInfo(Info *I, 
llvm::raw_ostream &OS,
"unexpected info type");
   }
 
-  HTMLFile F =
-  genInfoFile(InfoTitle, I->Path, MainContentNodes, InfoIndex, CDCtx);
+  HTMLFile F = genInfoFile(InfoTitle, I->getRelativeFilePath(""),
+   MainContentNodes, InfoIndex, CDCtx);
   F.Render(OS);
 
   return llvm::Error::success();
@@ -902,7 +904,7 @@ static llvm::Error SerializeIndex(ClangDocContext &CDCtx) {
   J.attribute("USR", toHex(llvm::toStringRef(I.USR)));
   J.attribute("Name", I.Name);
   J.attribute("RefType", getRefType(I.RefType));
-  J.attribute("Path", I.Path);
+  J.attribute("Path", I.getRelativeFilePath(""));
   J.attributeArray("Children", [&] {
 for (const Index &C : I.Children)
   IndexToJSON(C);

diff  --git a/clang-tools-extra/clang-doc/MDGenerator.cpp 
b/clang-tools-extra/clang-doc/MDGenerator.cpp
index ff99c9001349..0193d47a13cd 100644
--- a/clang-tools-extra/clang-doc/MDGenerator.cpp
+++ b/clang-tools-extra/clang-doc/MDGenerator.cpp
@@ -50,10 +50,20 @@ static void writeHeader(const Twine &Text, unsigned int 
Num, raw_ostream &OS) {
   OS << std::string(Num, '#') + " " + Text << "\n\n";
 }
 
-static void writeFileDefinition(const Location &L, raw_ostream &OS) {
-  OS << genItalic("Defined at line " + std::to_string(L.LineNumber) + " of " +
-  L.Filename)
- << "\n\n";
+static void writeFileDefinition(const ClangDocContext &CDCtx, const Location 
&L,
+raw_ostream &OS) {
+
+  if (!CDCtx.RepositoryUrl) {
+OS << "*Defined at " << L.Filename << "#" << std::to_string(L.LineNumber)
+   << "*";
+  } else {
+OS << "*Defined at [" << L.Filen

[PATCH] D75604: [clangd] Round WorkDoneProgressBegin.percentage down

2020-03-04 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1409
   (Stats.Enqueued - Stats.LastIdle);
+  // Round down to 2 decimal places for readability.
+  Report.percentage = std::floor(*Report.percentage * 100.0) / 100.0;

Yikes, rounding a float value in the protocol is pretty weird and would deserve 
more of a comment.

Also this seems like a fairly... improbable bug, in that it's trivial to fix in 
the editor and would usually be visible if the implementer tried the feature 
even once.

Which editors specifically are you seeing bad display in? Can we just send them 
a PR?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75604



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


[PATCH] D75153: [ThinLTO] Allow usage of all SMT threads in the system

2020-03-04 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Thanks Reid! I will leave this open for a few days, in case there are any other 
feedbacks.

As for `-fthinlto-index`, we have someone looking at distributing it remotely 
with Fastbuild. I think it is reasonable on the short-term to let the build 
system handle that (I assume that's what you did). One adjacent question is how 
to address the size of the local cache folder (ie. `lto.cache` when compiling 
LLVM) which grows big very quickly. Pruning periodically is fine, but I wonder 
if we could keep it compressed on disk. Maybe do `DeviceIoControl 
(...FSCTL_SET_COMPRESSION..)` and let Windows handle that? I'll take a look in 
the weeks to come.


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

https://reviews.llvm.org/D75153



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


[PATCH] D75603: [clangd] Add instrumentation mode in clangd for metrics collection.

2020-03-04 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Forgot to mention: I also think the trace approach certainly has things going 
for it, or even parsing out the messages from the existing logs.
But in this particular case the callback happens to be extremely convenient and 
also not invasive (since the data structures are already exposed, code complete 
has an opts struct etc). And since this is for analysis we have a lot of 
flexibility to rework if it stops being easy to maintain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75603



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


[PATCH] D72841: [RFC] Add support for pragma float_control, to control precision and exception behavior at the source level

2020-03-04 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/AST/Stmt.h:1104
+static_assert(sizeof(*this) <= 16,
   "changing bitfields changed sizeof(Stmt)");
 static_assert(sizeof(*this) % alignof(void *) == 0,

mibintc wrote:
> rjmccall wrote:
> > What's happening here is exactly what this assertion is supposed to 
> > prevent.   If you need more bits in one of these classes (I assume it's 
> > `CXXOperatorCallExpr`), you need to either make a field in the actual class 
> > or investigate more arcane mechanisms like  trailing storage to reduce the 
> > normal impact.  The latter is probably unnecessary for 
> > `CXXOperatorCallExpr`.
> @rjmccall The reason i changed the assertion is because FPOptions is now 
> wider, so I had to change the assertion.  See line 609 above. Is there 
> something I need to do differently? 
Because `Stmt` is a common base class for so much of the AST but only needs to 
store a small amount of state itself, we have a complicated system for 
optimizing space usage in subclasses by allocating bit-fields into `Stmt`.  
Letting an individual subclass's bit-field usage run over the expected size and 
therefore inflate `Stmt` for all subclasses would be counter-productive, hence 
the `static_assert` and why it shouldn't be changed.  You need to move the 
storage of `FPOptions` into the appropriate subclass wherever it would cause 
the `static_assert` to fail.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

2020-03-04 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel updated this revision to Diff 248310.
atmnpatel added a comment.
Herald added a reviewer: lebedev.ri.

Modifies clang-tidy to include the new clause, and changes the value of 
DSA_firstprivate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75591

Files:
  clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst
  clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/parallel_default_messages.cpp
  clang/test/OpenMP/parallel_for_default_messages.cpp
  clang/test/OpenMP/parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_default_messages.cpp
  clang/test/OpenMP/parallel_sections_default_messages.cpp
  clang/test/OpenMP/target_parallel_default_messages.cpp
  clang/test/OpenMP/target_parallel_for_default_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/target_teams_default_messages.cpp
  clang/test/OpenMP/target_teams_distribute_default_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/task_default_messages.cpp
  clang/test/OpenMP/task_messages.cpp
  clang/test/OpenMP/teams_default_messages.cpp
  clang/test/OpenMP/teams_distribute_default_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -381,6 +381,7 @@
 
 __OMP_DEFAULT_KIND(none)
 __OMP_DEFAULT_KIND(shared)
+__OMP_DEFAULT_KIND(firstprivate)
 __OMP_DEFAULT_KIND(unknown)
 
 #undef __OMP_DEFAULT_KIND
Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1843,11 +1843,18 @@
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   const std::string Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP(Source4, Matcher));
+
+  const std::string Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(MatchFinderAPI, matchesDynamic) {
Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2812,11 +2812,18 @@
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   const std::string Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP(Source4, Matcher));
+
+  const std::string Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(matchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(matchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(OMPDefaultClause, isNoneKind) {
@@ -2852,10 +2859,17 @@
 
   const std::string Source4 = R"(
 void x(int x) {
-#pragma omp parallel num_threads(x)
+#pragma omp parallel default(firstprivate)
 ;
 })";
   EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+
+  const std::string Source5 = R"(
+void x(int x) {
+#pragma omp parallel num_threads(x)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(OMPDefaultClause, isSharedKind) {
@@ -2891,10 +2905,63 @@
 
   const std::string Source4 = R"(
 void x(int x) {
-#pragma omp parallel num_threads(x)
+#pragma omp parallel default(firstprivate)
 ;
 })";
   EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+
+  const std::string Source5 = R"(
+void x(int x) {
+#pragma omp parallel num_threads(x)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
+}
+
+TEST(OMPDefaultClause, isFirstPrivateKind) {
+  auto Matcher = ompExecutableDirective(
+  hasAnyClause(ompDefaultClause(isFirstPrivateKind(;
+
+  const std::string Source0 = 

[PATCH] D74813: [RFC] Add hash of block contents to function block names

2020-03-04 Thread Alex Borcan via Phabricator via cfe-commits
alexbdv added a comment.

@vsk  / @dexonsmith - I've added some more info in latest comments. Let me know 
if I can provide more info / context on this to be able to reach a conclusion. 
Or if you think it is clear at this point that the hash-based approach is a 
no-go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74813



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


[PATCH] D74935: [LangRef][AliasAnalysis] Clarify `noalias` affects only modified objects

2020-03-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D74935#1905026 , @jeroen.dobbelaere 
wrote:

> The reason I bring this up, is that in the full restrict implementation 
> (D68484 ), the alias analysis will do a 
> recursive analysis, proving that *pA and *pB will never alias, because pA and 
> pB will never alias. But this phrasing will break that assumption.


I don't understand how this will break. It will just mean in the IR below we 
*cannot* assume %0 and %1 are different. Given that the IR below does not 
represent the nested restrict it seems like this is exactly what we want. After 
all, we cannot determine if the IR came from your example or one with a single 
restrict qualifier per argument.

  ; Function Attrs: nofree norecurse nounwind uwtable
  define dso_local void @f(i32** noalias nocapture readonly %0, i32** noalias 
nocapture readonly %1) local_unnamed_addr #0 {
%3 = load i32*, i32** %1, align 8, !tbaa !2
%4 = load i32, i32* %3, align 4, !tbaa !6
%5 = load i32*, i32** %0, align 8, !tbaa !2
store i32 %4, i32* %5, align 4, !tbaa !6
ret void
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74935



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


[PATCH] D75643: Don't emit pointer to int cast warnings under -Wmicrosoft-cast

2020-03-04 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
aeubanks added reviewers: rnk, thakis, Mordante.

MSVC also warns on this:
$ cat /tmp/a.c
int f(void* p) { return (int) p; }

$ cl /c /tmp/a.c
C:/src/tmp/a.c(1): warning C4311: 'type cast': pointer truncation from
'void *' to 'int'

Warnings originally added in https://reviews.llvm.org/D72231.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75643

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCast.cpp
  clang/test/Sema/MicrosoftExtensions.c


Index: clang/test/Sema/MicrosoftExtensions.c
===
--- clang/test/Sema/MicrosoftExtensions.c
+++ clang/test/Sema/MicrosoftExtensions.c
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value 
-Wmicrosoft -verify -fms-extensions
-
+// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value 
-Wno-pointer-to-int-cast -Wmicrosoft -verify -fms-extensions
 
 struct A
 {
@@ -93,13 +92,13 @@
 };
 
 void pointer_to_integral_type_conv(char* ptr) {
-   char ch = (char)ptr; // expected-warning{{cast to smaller integer type 
'char' from 'char *' is a Microsoft extension}}
-   short sh = (short)ptr; // expected-warning{{cast to smaller integer type 
'short' from 'char *' is a Microsoft extension}}
-   ch = (char)ptr; // expected-warning{{cast to smaller integer type 'char' 
from 'char *' is a Microsoft extension}}
-   sh = (short)ptr; // expected-warning{{cast to smaller integer type 'short' 
from 'char *' is a Microsoft extension}}
+  char ch = (char)ptr;
+  short sh = (short)ptr;
+  ch = (char)ptr;
+  sh = (short)ptr;
 
-   // This is valid ISO C.
-   _Bool b = (_Bool)ptr;
+  // This is valid ISO C.
+  _Bool b = (_Bool)ptr;
 }
 
 typedef struct {
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2771,11 +2771,9 @@
   // If the result cannot be represented in the integer type, the behavior
   // is undefined. The result need not be in the range of values of any
   // integer type.
-  unsigned Diag = Self.getLangOpts().MicrosoftExt
-  ? diag::ext_ms_pointer_to_int_cast
-  : SrcType->isVoidPointerType()
-? diag::warn_void_pointer_to_int_cast
-: diag::warn_pointer_to_int_cast;
+  unsigned Diag = SrcType->isVoidPointerType()
+  ? diag::warn_void_pointer_to_int_cast
+  : diag::warn_pointer_to_int_cast;
   Self.Diag(OpRange.getBegin(), Diag) << SrcType << DestType << OpRange;
 }
   }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3672,9 +3672,6 @@
 def warn_void_pointer_to_int_cast : Warning<
   "cast to smaller integer type %1 from %0">,
   InGroup;
-def ext_ms_pointer_to_int_cast : ExtWarn<
-  "cast to smaller integer type %1 from %0 is a Microsoft extension">,
-InGroup;
 
 def warn_attribute_ignored_for_field_of_type : Warning<
   "%0 attribute ignored for field of type %1">,


Index: clang/test/Sema/MicrosoftExtensions.c
===
--- clang/test/Sema/MicrosoftExtensions.c
+++ clang/test/Sema/MicrosoftExtensions.c
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions
-
+// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value -Wno-pointer-to-int-cast -Wmicrosoft -verify -fms-extensions
 
 struct A
 {
@@ -93,13 +92,13 @@
 };
 
 void pointer_to_integral_type_conv(char* ptr) {
-   char ch = (char)ptr; // expected-warning{{cast to smaller integer type 'char' from 'char *' is a Microsoft extension}}
-   short sh = (short)ptr; // expected-warning{{cast to smaller integer type 'short' from 'char *' is a Microsoft extension}}
-   ch = (char)ptr; // expected-warning{{cast to smaller integer type 'char' from 'char *' is a Microsoft extension}}
-   sh = (short)ptr; // expected-warning{{cast to smaller integer type 'short' from 'char *' is a Microsoft extension}}
+  char ch = (char)ptr;
+  short sh = (short)ptr;
+  ch = (char)ptr;
+  sh = (short)ptr;
 
-   // This is valid ISO C.
-   _Bool b = (_Bool)ptr;
+  // This is valid ISO C.
+  _Bool b = (_Bool)ptr;
 }
 
 typedef struct {
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2771,11 +2771,9 @@
   // If the result cannot be represented in the integer type, the behavior
   // is undefined. The result need not be in the r

[clang] b27ff4d - [OPENMP50]Codegen for 'destroy' clause in depobj directive.

2020-03-04 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-03-04T16:30:34-05:00
New Revision: b27ff4d07ddcf6aff8aec36aa05e212da0ab6adf

URL: 
https://github.com/llvm/llvm-project/commit/b27ff4d07ddcf6aff8aec36aa05e212da0ab6adf
DIFF: 
https://github.com/llvm/llvm-project/commit/b27ff4d07ddcf6aff8aec36aa05e212da0ab6adf.diff

LOG: [OPENMP50]Codegen for 'destroy' clause in depobj directive.

If the destroy clause is appplied, the previously allocated memory for
the dependency object must be destroyed.

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/depobj_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index ce23434e1a52..09749270b830 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -5318,6 +5318,18 @@ Address CGOpenMPRuntime::emitDependClause(
   return DependenciesArray;
 }
 
+void CGOpenMPRuntime::emitDestroyClause(CodeGenFunction &CGF, LValue 
DepobjLVal,
+SourceLocation Loc) {
+  llvm::Value *DepObjAddr = CGF.EmitLoadOfScalar(DepobjLVal, Loc);
+  llvm::Value *ThreadID = getThreadID(CGF, Loc);
+  // Use default allocator.
+  llvm::Value *Allocator = llvm::ConstantPointerNull::get(CGF.VoidPtrTy);
+  llvm::Value *Args[] = {ThreadID, DepObjAddr, Allocator};
+
+  // _kmpc_free(gtid, addr, nullptr);
+  (void)CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_free), Args);
+}
+
 void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc,
const OMPExecutableDirective &D,
llvm::Function *TaskFunction,

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.h 
b/clang/lib/CodeGen/CGOpenMPRuntime.h
index 54223d390057..fe526464bb1d 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -1786,6 +1786,11 @@ class CGOpenMPRuntime {
   CodeGenFunction &CGF,
   ArrayRef> Dependencies,
   bool ForDepobj, SourceLocation Loc);
+
+  /// Emits the code to destroy the dependency object provided in depobj
+  /// directive.
+  void emitDestroyClause(CodeGenFunction &CGF, LValue DepobjLVal,
+ SourceLocation Loc);
 };
 
 /// Class supports emissionof SIMD-only code.

diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 822542df1bc4..2de1fe65c71b 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3811,6 +3811,11 @@ void CodeGenFunction::EmitOMPDepobjDirective(const 
OMPDepobjDirective &S) {
 Address DepAddr = CGM.getOpenMPRuntime().emitDependClause(
 *this, Dependencies, /*ForDepobj=*/true, DC->getBeginLoc());
 EmitStoreOfScalar(DepAddr.getPointer(), DOLVal);
+return;
+  }
+  if (const auto *DC = S.getSingleClause()) {
+CGM.getOpenMPRuntime().emitDestroyClause(*this, DOLVal, DC->getBeginLoc());
+return;
   }
 }
 

diff  --git a/clang/test/OpenMP/depobj_codegen.cpp 
b/clang/test/OpenMP/depobj_codegen.cpp
index 7a8264a81cad..1d1809b2155c 100644
--- a/clang/test/OpenMP/depobj_codegen.cpp
+++ b/clang/test/OpenMP/depobj_codegen.cpp
@@ -38,6 +38,7 @@ int main(int argc, char **argv) {
 }
 
 // CHECK-LABEL: @main
+// CHECK: [[B_ADDR:%.+]] = alloca i8*,
 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(
 // CHECK: [[DEP_ADDR_VOID:%.+]] = call i8* @__kmpc_alloc(i32 [[GTID]], i64 72, 
i8* null)
 // CHECK: [[DEP_ADDR:%.+]] = bitcast i8* [[DEP_ADDR_VOID]] to [3 x 
%struct.kmp_depend_info]*
@@ -61,8 +62,11 @@ int main(int argc, char **argv) {
 // CHECK: [[BASE_ADDR:%.+]] = getelementptr inbounds [3 x 
%struct.kmp_depend_info], [3 x %struct.kmp_depend_info]* [[DEP_ADDR]], i{{.+}} 
0, i{{.+}} 0
 // CHECK: [[DEP:%.+]] = bitcast %struct.kmp_depend_info* [[BASE_ADDR]] to i8*
 // CHECK: store i8* [[DEP]], i8** [[MAIN_A]],
+// CHECK: [[B:%.+]] = load i8*, i8** [[B_ADDR]],
+// CHECK: call void @__kmpc_free(i32 [[GTID]], i8* [[B]], i8* null)
 
 // CHECK-LABEL: tmain
+// CHECK: [[ARGC_ADDR:%.+]] = alloca i8*,
 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(
 // CHECK: [[DEP_ADDR_VOID:%.+]] = call i8* @__kmpc_alloc(i32 [[GTID]], i64 48, 
i8* null)
 // CHECK: [[DEP_ADDR:%.+]] = bitcast i8* [[DEP_ADDR_VOID]] to [2 x 
%struct.kmp_depend_info]*
@@ -79,5 +83,7 @@ int main(int argc, char **argv) {
 // CHECK: [[BASE_ADDR:%.+]] = getelementptr inbounds [2 x 
%struct.kmp_depend_info], [2 x %struct.kmp_depend_info]* [[DEP_ADDR]], i{{.+}} 
0, i{{.+}} 0
 // CHECK: [[DEP:%.+]] = bitcast %struct.kmp_depend_info* [[BASE_ADDR]] to i8*
 // CHECK: store i8* [[DEP]], i8** [[TMAIN_A]],
+// CHECK: [[ARGC:%.+]] = load i8*, i8** [[ARGC_ADDR]],
+// CHECK: call void @__kmpc_free(i32 [[GTID]], i8* [[ARGC]], i8* null)
 
 #endif



_

[PATCH] D72841: [RFC] Add support for pragma float_control, to control precision and exception behavior at the source level

2020-03-04 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked 12 inline comments as done.
mibintc added a comment.
Herald added a subscriber: rnkovacs.

some inline replies and comments




Comment at: clang/include/clang/AST/Stmt.h:1104
+static_assert(sizeof(*this) <= 16,
   "changing bitfields changed sizeof(Stmt)");
 static_assert(sizeof(*this) % alignof(void *) == 0,

rjmccall wrote:
> What's happening here is exactly what this assertion is supposed to prevent.  
>  If you need more bits in one of these classes (I assume it's 
> `CXXOperatorCallExpr`), you need to either make a field in the actual class 
> or investigate more arcane mechanisms like  trailing storage to reduce the 
> normal impact.  The latter is probably unnecessary for `CXXOperatorCallExpr`.
@rjmccall The reason i changed the assertion is because FPOptions is now wider, 
so I had to change the assertion.  See line 609 above. Is there something I 
need to do differently? 



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1138
+def err_pragma_float_control_unknown_kind : Error<
+  "unknown kind of pragma float_control">;
 // - #pragma pointers_to_members

rjmccall wrote:
> Maybe "operation" would be a better user-facing name than "kind"?   Also, 
> this diagnostic is more specific but less helpful than the diagnostic just 
> above.
I got rid of the diagnostic with the unhelpful string and just using the single 
diagnostic which has full information about how to form the pragma



Comment at: clang/include/clang/Basic/LangOptions.def:196
+COMPATIBLE_LANGOPT(AllowRecip, 1, 0, "Permit Floating Point 
reciprocal")
+COMPATIBLE_LANGOPT(ApproxFunc, 1, 0, "Permit Floating Point 
approximation")
 

rjmccall wrote:
> Please align the commas.
> 
> Would it make more sense to just store an `FPOptions` in `LangOptions` 
> instead of breaking all of the bits down separately?
> 
> We may need to reconsider at some point whether any of these are really 
> "compatible" language options.  Headers can contain inline code, and we 
> shouldn't compile that incorrectly just because we reused a module we built 
> under different language settings.  Although... maybe we can figure out a way 
> to store just the ways that an expression's context overrides the default 
> semantics and then merge those semantics into the default set for the 
> translation unit; that would make them actually compatible.  Of course, it 
> would also require more bits in expressions where it matters, and you might 
> need to investigate trailing storage at that point.
I aligned the commas.  I didn't put FPOptions into LangOptions, would you like 
me to make that change too?  I don't know about trailing storage. I see that 
term in the code but I didn't see details about what that is/how that works. 



Comment at: clang/include/clang/Basic/LangOptions.h:468
+  bool allowReciprocal() const { return allow_reciprocal; }
+  bool approxFunc() const  { return approx_func; }
+

rjmccall wrote:
> Somewhere in this type, it should be obvious where I can go in order to 
> understand what any of these flags means precisely.  Ideally that would be 
> reinforced by the method names, instead of using non-term-of-art 
> abbreviations like "reassoc".
I put the comments on the field declarations in the private part. I changed the 
names of the accessor methods to be more descriptive. (Previously I was using 
the same names as LLVM uses for those fields).



Comment at: clang/include/clang/Basic/LangOptions.h:517
+approx_func = ((I>>13) & 1);
   }
 

rjmccall wrote:
> The more conventional method names here would an instance method called 
> something like `getAsOpaqueInt` and then a static method called something 
> like `getFromOpaqueInt`.
I changed the names like you suggested but not using the static method, is this 
OK?



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:4085
 // this should improve codegen just a little.
-RHS = Visit(E->getRHS());
-LHS = EmitCheckedLValue(E->getLHS(), CodeGenFunction::TCK_Store);
+if (E->getType()->isFloatingType()) {
+  //  Preserve the old values, enable FPFeatures for these expressions

In the previous rendition of this patch, when the Builder.FMF settings were 
modified at Visit(BinaryExpression), the assign is seen as a binary expression 
and so the FPFeatures was passed into IRBuilder. I'm not confident this patch 
is in the right place, I'd really like to put FPFeatures onto the CallExpr 
node, because if you call a builtin intrinsic function, and the mode is set to 
float_control(except, on), the call node for the intrinsic doesn't have the 
FPFeature bits, so it isn't marked as expected. Before I make that change I 
want @rjmccall to take another look;  If FPFeatures was on CallExpr then I'd 
remove it here and modify IRBuilder.FM

[PATCH] D75615: Revert "[CGBlocks] Improve line info in backtraces containing *_helper_block"

2020-03-04 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Nice! Lgtm, thanks.


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

https://reviews.llvm.org/D75615



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


[PATCH] D75153: [ThinLTO] Allow usage of all SMT threads in the system

2020-03-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

I'm busy and I haven't looked at the code in detail, but I'm OK with going back 
to the old way of doing things. I think honoring user requests to use more 
threads than cores is an important use case. We had plans at one point to add 
indirection points to allow us to distribute these backend actions to other 
machines. Essentially, this would be done by having LLD invoke `$mydiscc clang 
-c foo.o -fuse-thin-lto-index=foo.thinlto.bc`. We've gone a different 
direction, so that change is not likely to come soon, but it seems like a 
reasonable use case where one would want to pass -j LARGE and have it be 
honored.


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

https://reviews.llvm.org/D75153



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


Re: [clang] bdad0a1 - PR45083: Mark statement expressions as being dependent if they appear in

2020-03-04 Thread Richard Smith via cfe-commits
We found a regression introduced by this patch; fixed
in f545ede91c9d9f271e7504282cab7bf509607ead.

On Wed, 4 Mar 2020 at 00:30, Hans Wennborg via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Pushed to 10.x as 3a843031a5ad83a00d2603f623881cb2b2bf719d. Please let
> me know if you hear about any follow-up issues.
>
> Thanks!
>
> On Wed, Mar 4, 2020 at 12:28 AM Richard Smith via cfe-commits
>  wrote:
> >
> >
> > Author: Richard Smith
> > Date: 2020-03-03T15:20:40-08:00
> > New Revision: bdad0a1b79273733df9acc1be4e992fa5d70ec56
> >
> > URL:
> https://github.com/llvm/llvm-project/commit/bdad0a1b79273733df9acc1be4e992fa5d70ec56
> > DIFF:
> https://github.com/llvm/llvm-project/commit/bdad0a1b79273733df9acc1be4e992fa5d70ec56.diff
> >
> > LOG: PR45083: Mark statement expressions as being dependent if they
> appear in
> > dependent contexts.
> >
> > We previously assumed they were neither value- nor
> > instantiation-dependent under any circumstances, which would lead to
> > crashes and other misbehavior.
> >
> > Added:
> >
> >
> > Modified:
> > clang/include/clang/AST/Expr.h
> > clang/include/clang/Sema/Sema.h
> > clang/lib/AST/ASTImporter.cpp
> > clang/lib/Parse/ParseExpr.cpp
> > clang/lib/Sema/SemaExpr.cpp
> > clang/lib/Sema/SemaExprCXX.cpp
> > clang/lib/Sema/TreeTransform.h
> > clang/test/SemaTemplate/dependent-expr.cpp
> >
> > Removed:
> >
> >
> >
> >
> 
> > diff  --git a/clang/include/clang/AST/Expr.h
> b/clang/include/clang/AST/Expr.h
> > index fcdb0b992134..87f9b883486a 100644
> > --- a/clang/include/clang/AST/Expr.h
> > +++ b/clang/include/clang/AST/Expr.h
> > @@ -3960,14 +3960,14 @@ class StmtExpr : public Expr {
> >Stmt *SubStmt;
> >SourceLocation LParenLoc, RParenLoc;
> >  public:
> > -  // FIXME: Does type-dependence need to be computed
> > diff erently?
> > -  // FIXME: Do we need to compute instantiation
> instantiation-dependence for
> > -  // statements? (ugh!)
> >StmtExpr(CompoundStmt *substmt, QualType T,
> > -   SourceLocation lp, SourceLocation rp) :
> > +   SourceLocation lp, SourceLocation rp, bool
> InDependentContext) :
> > +// Note: we treat a statement-expression in a dependent context as
> always
> > +// being value- and instantiation-dependent. This matches the
> behavior of
> > +// lambda-expressions and GCC.
> >  Expr(StmtExprClass, T, VK_RValue, OK_Ordinary,
> > - T->isDependentType(), false, false, false),
> > -SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) { }
> > + T->isDependentType(), InDependentContext, InDependentContext,
> false),
> > +SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) {}
> >
> >/// Build an empty statement expression.
> >explicit StmtExpr(EmptyShell Empty) : Expr(StmtExprClass, Empty) { }
> >
> > diff  --git a/clang/include/clang/Sema/Sema.h
> b/clang/include/clang/Sema/Sema.h
> > index 2304a9718567..5739808753e3 100644
> > --- a/clang/include/clang/Sema/Sema.h
> > +++ b/clang/include/clang/Sema/Sema.h
> > @@ -4964,7 +4964,7 @@ class Sema final {
> >  LabelDecl *TheDecl);
> >
> >void ActOnStartStmtExpr();
> > -  ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
> > +  ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt
> *SubStmt,
> > SourceLocation RPLoc); // "({..})"
> >// Handle the final expression in a statement expression.
> >ExprResult ActOnStmtExprResult(ExprResult E);
> >
> > diff  --git a/clang/lib/AST/ASTImporter.cpp
> b/clang/lib/AST/ASTImporter.cpp
> > index 52288318337d..0cf00f6ca15b 100644
> > --- a/clang/lib/AST/ASTImporter.cpp
> > +++ b/clang/lib/AST/ASTImporter.cpp
> > @@ -6631,8 +6631,9 @@ ExpectedStmt
> ASTNodeImporter::VisitStmtExpr(StmtExpr *E) {
> >if (Err)
> >  return std::move(Err);
> >
> > -  return new (Importer.getToContext()) StmtExpr(
> > -  ToSubStmt, ToType, ToLParenLoc, ToRParenLoc);
> > +  return new (Importer.getToContext())
> > +  StmtExpr(ToSubStmt, ToType, ToLParenLoc, ToRParenLoc,
> > +   E->isInstantiationDependent());
> >  }
> >
> >  ExpectedStmt ASTNodeImporter::VisitUnaryOperator(UnaryOperator *E) {
> >
> > diff  --git a/clang/lib/Parse/ParseExpr.cpp
> b/clang/lib/Parse/ParseExpr.cpp
> > index 584de6b87d90..b038e6935d87 100644
> > --- a/clang/lib/Parse/ParseExpr.cpp
> > +++ b/clang/lib/Parse/ParseExpr.cpp
> > @@ -2655,7 +2655,8 @@ Parser::ParseParenExpression(ParenParseOption
> &ExprType, bool stopIfCastExpr,
> >
> >// If the substmt parsed correctly, build the AST node.
> >if (!Stmt.isInvalid()) {
> > -Result = Actions.ActOnStmtExpr(OpenLoc, Stmt.get(),
> Tok.getLocation());
> > +Result = Actions.ActOnStmtExpr(getCurScope(), OpenLoc,
> Stmt.get(),
> > +   Tok.getLocation());
> >} else {
> >  Actions.ActOnStmtExprError();
> >  

[clang] f545ede - Fix regression in bdad0a1: force rebuilding of StmtExpr nodes in

2020-03-04 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-03-04T13:19:49-08:00
New Revision: f545ede91c9d9f271e7504282cab7bf509607ead

URL: 
https://github.com/llvm/llvm-project/commit/f545ede91c9d9f271e7504282cab7bf509607ead
DIFF: 
https://github.com/llvm/llvm-project/commit/f545ede91c9d9f271e7504282cab7bf509607ead.diff

LOG: Fix regression in bdad0a1: force rebuilding of StmtExpr nodes in
TreeTransform if the 'dependent' flag would change.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/TreeTransform.h
clang/test/SemaTemplate/dependent-expr.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5739808753e3..8e4d0828e2d0 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4965,7 +4965,9 @@ class Sema final {
 
   void ActOnStartStmtExpr();
   ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
-   SourceLocation RPLoc); // "({..})"
+   SourceLocation RPLoc);
+  ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
+   SourceLocation RPLoc, bool IsDependent);
   // Handle the final expression in a statement expression.
   ExprResult ActOnStmtExprResult(ExprResult E);
   void ActOnStmtExprError();

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 1870e440199d..291c38ab20b4 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -13912,7 +13912,13 @@ void Sema::ActOnStmtExprError() {
 }
 
 ExprResult Sema::ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
-   SourceLocation RPLoc) { // "({..})"
+   SourceLocation RPLoc) {
+  return BuildStmtExpr(LPLoc, SubStmt, RPLoc,
+   S->getTemplateParamParent() != nullptr);
+}
+
+ExprResult Sema::BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
+   SourceLocation RPLoc, bool IsDependent) {
   assert(SubStmt && isa(SubStmt) && "Invalid action 
invocation!");
   CompoundStmt *Compound = cast(SubStmt);
 
@@ -13941,18 +13947,10 @@ ExprResult Sema::ActOnStmtExpr(Scope *S, 
SourceLocation LPLoc, Stmt *SubStmt,
 }
   }
 
-  bool IsDependentContext = false;
-  if (S)
-IsDependentContext = S->getTemplateParamParent() != nullptr;
-  else
-// FIXME: This is not correct when substituting inside a templated
-// context that isn't a DeclContext (such as a variable template).
-IsDependentContext = CurContext->isDependentContext();
-
   // FIXME: Check that expression type is complete/non-abstract; statement
   // expressions are not lvalues.
   Expr *ResStmtExpr =
-  new (Context) StmtExpr(Compound, Ty, LPLoc, RPLoc, IsDependentContext);
+  new (Context) StmtExpr(Compound, Ty, LPLoc, RPLoc, IsDependent);
   if (StmtExprMayBindToTemp)
 return MaybeBindToTemporary(ResStmtExpr);
   return ResStmtExpr;

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 05b41aa53da6..382496dad3d5 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -2550,8 +2550,8 @@ class TreeTransform {
   /// By default, performs semantic analysis to build the new expression.
   /// Subclasses may override this routine to provide 
diff erent behavior.
   ExprResult RebuildStmtExpr(SourceLocation LParenLoc, Stmt *SubStmt,
- SourceLocation RParenLoc) {
-return getSema().ActOnStmtExpr(nullptr, LParenLoc, SubStmt, RParenLoc);
+ SourceLocation RParenLoc, bool IsDependent) {
+return getSema().BuildStmtExpr(LParenLoc, SubStmt, RParenLoc, IsDependent);
   }
 
   /// Build a new __builtin_choose_expr expression.
@@ -10432,16 +10432,20 @@ TreeTransform::TransformStmtExpr(StmtExpr 
*E) {
 return ExprError();
   }
 
+  // FIXME: This is not correct when substituting inside a templated
+  // context that isn't a DeclContext (such as a variable template).
+  bool IsDependent = getSema().CurContext->isDependentContext();
+
   if (!getDerived().AlwaysRebuild() &&
+  IsDependent == E->isInstantiationDependent() &&
   SubStmt.get() == E->getSubStmt()) {
 // Calling this an 'error' is unintuitive, but it does the right thing.
 SemaRef.ActOnStmtExprError();
 return SemaRef.MaybeBindToTemporary(E);
   }
 
-  return getDerived().RebuildStmtExpr(E->getLParenLoc(),
-  SubStmt.get(),
-  E->getRParenLoc());
+  return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
+  E->getRParenLoc(), IsDependent);
 }
 
 template

diff  --git a/clang/test/SemaTemplate/dependent-expr.cpp 
b/clang/test/SemaTemplate/dependent-expr.cpp
index e333ed927b9e..97d157f86424 100644
--- a/clang/te

[PATCH] D75638: [Hexagon] Support for Linux/Musl ABI.

2020-03-04 Thread Sid Manning via Phabricator via cfe-commits
sidneym created this revision.
sidneym added reviewers: kparzysz, bcain, adasgupt.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The clang driver updates needed to support Hexagon's Linux ABI.

This builds on what was added by 
https://reviews.llvm.org/rG7fee4fed4c75c13d0cec7ff3a043e0313a3abc55


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75638

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/Targets/Hexagon.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/hexagon-linux-vararg.c

Index: clang/test/CodeGen/hexagon-linux-vararg.c
===
--- /dev/null
+++ clang/test/CodeGen/hexagon-linux-vararg.c
@@ -0,0 +1,65 @@
+// REQUIRES: hexagon-registered-target
+// RUN: %clang_cc1 -emit-llvm -triple hexagon-unknown-linux-musl %s -o - | FileCheck %s
+#include 
+
+struct AAA {
+  int x; int y; int z; int d;
+};
+
+// CHECK:   call void @llvm.va_start(i8* %arraydecay1)
+// CHECK:   %arraydecay2 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0
+// CHECK:   br label %vaarg.maybe_reg
+
+// CHECK: vaarg.maybe_reg:  ; preds = %entry
+// CHECK:   %__current_saved_reg_area_pointer_p = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %arraydecay2, i32 0, i32 0
+// CHECK:   %__current_saved_reg_area_pointer = load i8*, i8** %__current_saved_reg_area_pointer_p
+// CHECK:   %__saved_reg_area_end_pointer_p = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %arraydecay2, i32 0, i32 1
+// CHECK:   %__saved_reg_area_end_pointer = load i8*, i8** %__saved_reg_area_end_pointer_p
+// CHECK:   %__new_saved_reg_area_pointer = getelementptr i8, i8* %__current_saved_reg_area_pointer, i32 4
+// CHECK:   %0 = icmp sgt i8* %__new_saved_reg_area_pointer, %__saved_reg_area_end_pointer
+// CHECK:   br i1 %0, label %vaarg.on_stack, label %vaarg.in_reg
+
+// CHECK: vaarg.in_reg: ; preds = %vaarg.maybe_reg
+// CHECK:   %1 = bitcast i8* %__current_saved_reg_area_pointer to i32*
+// CHECK:   store i8* %__new_saved_reg_area_pointer, i8** %__current_saved_reg_area_pointer_p
+// CHECK:   br label %vaarg.end
+
+// CHECK: vaarg.on_stack:   ; preds = %vaarg.maybe_reg
+// CHECK:   %__overflow_area_pointer_p = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %arraydecay2, i32 0, i32 2
+// CHECK:   %__overflow_area_pointer = load i8*, i8** %__overflow_area_pointer_p
+// CHECK:   %__overflow_area_pointer.next = getelementptr i8, i8* %__overflow_area_pointer, i32 4
+// CHECK:   store i8* %__overflow_area_pointer.next, i8** %__overflow_area_pointer_p
+// CHECK:   store i8* %__overflow_area_pointer.next, i8** %__current_saved_reg_area_pointer_p
+// CHECK:   %2 = bitcast i8* %__overflow_area_pointer to i32*
+// CHECK:   br label %vaarg.end
+
+// CHECK: vaarg.end:; preds = %vaarg.on_stack, %vaarg.in_reg
+// CHECK:   %vaarg.addr = phi i32* [ %1, %vaarg.in_reg ], [ %2, %vaarg.on_stack ]
+// CHECK:   %3 = load i32, i32* %vaarg.addr
+
+struct AAA aaa = { 100, 200, 300, 400 };
+
+int foo(int xx, ...)
+{
+  va_list ap;
+  int d;
+  int ret = 0;
+  struct AAA bbb;
+  va_start(ap, xx);
+  d = va_arg(ap, int);
+  ret += d;
+  bbb = va_arg(ap, struct AAA);
+  ret += bbb.d;
+  d = va_arg(ap, int);
+  ret += d;
+  va_end(ap);
+  return ret;
+}
+
+int
+main(void)
+{
+  int x;
+  x = foo(1, 2, aaa, 4);
+  return x;
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -7511,18 +7511,25 @@
 
 namespace {
 
-class HexagonABIInfo : public ABIInfo {
+class HexagonABIInfo : public DefaultABIInfo {
 public:
-  HexagonABIInfo(CodeGenTypes &CGT) : ABIInfo(CGT) {}
+  HexagonABIInfo(CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
 
 private:
   ABIArgInfo classifyReturnType(QualType RetTy) const;
   ABIArgInfo classifyArgumentType(QualType RetTy) const;
+  ABIArgInfo classifyArgumentType(QualType RetTy, unsigned *RegsLeft) const;
 
   void computeInfo(CGFunctionInfo &FI) const override;
 
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty) const override;
+  Address EmitVAArgFromMemory(CodeGenFunction &CFG, Address VAListAddr,
+  QualType Ty) const;
+  Address EmitVAArgForHexagon(CodeGenFunction &CFG, Address VAListAddr,
+  QualType Ty) const;
+  Address EmitVAArgForHexagonLinux(CodeGenFunction &CFG, Address VAListAddr,
+   QualType Ty) const;
 };
 
 class HexagonTargetCodeGenInfo : public TargetCodeGenInfo {
@@ -7533,23 +7540,58 @@
   int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override {
 return 29;
  

[PATCH] D75615: Revert "[CGBlocks] Improve line info in backtraces containing *_helper_block"

2020-03-04 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl updated this revision to Diff 248285.
aprantl added a comment.

Good catch, and non-obvious resolution.


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

https://reviews.llvm.org/D75615

Files:
  clang/lib/CodeGen/CGBlocks.cpp
  clang/test/CodeGenObjC/debug-info-blocks.m


Index: clang/test/CodeGenObjC/debug-info-blocks.m
===
--- clang/test/CodeGenObjC/debug-info-blocks.m
+++ clang/test/CodeGenObjC/debug-info-blocks.m
@@ -17,13 +17,17 @@
 // CHECK-NOT: ret
 // CHECK: call {{.*}}, !dbg ![[DBG_LINE:[0-9]+]]
 // CHECK-NOT: ret
-// CHECK: load {{.*}}, !dbg ![[COPY_LINE:[0-9]+]]
-// CHECK: ret void, !dbg ![[COPY_LINE]]
-// CHECK: define {{.*}} @__destroy_helper_block_{{.*}}(i8* %0)
+// CHECK: load {{.*}}, !dbg ![[DBG_LINE]]
+// CHECK: ret {{.*}}, !dbg ![[DBG_LINE]]
+// CHECK: define {{.*}} @__destroy_helper_block_{{.*}}(i8*
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[DESTROY_LINE:[0-9]+]]
-// CHECK: ret void, !dbg ![[DESTROY_LINE]]
+// CHECK: ret {{.*}}, !dbg ![[DESTROY_LINE]]
 
+// CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
+// CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(name: "__copy_helper_block_
+// CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: 0, scope: 
![[DESTROY_SP:[0-9]+]])
+// CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(name: 
"__destroy_helper_block_
 typedef unsigned int NSUInteger;
 
 @protocol NSObject
@@ -57,11 +61,6 @@
 - (id)init
 {
 if ((self = [super init])) {
-  // CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: 
![[COPY_SP:[0-9]+]])
-  // CHECK-DAG: [[COPY_LINE]] = !DILocation(line: [[@LINE+7]], scope: 
![[COPY_SP:[0-9]+]])
-  // CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(name: 
"__copy_helper_block_8_32o"
-  // CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: [[@LINE+5]], scope: 
![[DESTROY_SP:[0-9]+]])
-  // CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(name: 
"__destroy_helper_block_8_32o"
   // CHECK-DAG: !DILocalVariable(arg: 1, scope: ![[COPY_SP]], {{.*}}, 
flags: DIFlagArtificial)
   // CHECK-DAG: !DILocalVariable(arg: 2, scope: ![[COPY_SP]], {{.*}}, 
flags: DIFlagArtificial)
   // CHECK-DAG: !DILocalVariable(arg: 1, scope: ![[DESTROY_SP]], {{.*}}, 
flags: DIFlagArtificial)
Index: clang/lib/CodeGen/CGBlocks.cpp
===
--- clang/lib/CodeGen/CGBlocks.cpp
+++ clang/lib/CodeGen/CGBlocks.cpp
@@ -2032,11 +2032,13 @@
   FunctionDecl *FD = FunctionDecl::Create(
   C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II,
   FunctionTy, nullptr, SC_Static, false, false);
-
   setBlockHelperAttributesVisibility(blockInfo.CapturesNonExternalType, Fn, FI,
  CGM);
+  // This is necessary to avoid inheriting the previous line number.
+  FD->setImplicit();
   StartFunction(FD, ReturnTy, Fn, FI, args);
-  ApplyDebugLocation NL{*this, blockInfo.getBlockExpr()->getBeginLoc()};
+  auto AL = ApplyDebugLocation::CreateArtificial(*this);
+
   llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
 
   Address src = GetAddrOfLocalVar(&SrcDecl);
@@ -2227,10 +2229,12 @@
 
   setBlockHelperAttributesVisibility(blockInfo.CapturesNonExternalType, Fn, FI,
  CGM);
+  // This is necessary to avoid inheriting the previous line number.
+  FD->setImplicit();
   StartFunction(FD, ReturnTy, Fn, FI, args);
   markAsIgnoreThreadCheckingAtRuntime(Fn);
 
-  ApplyDebugLocation NL{*this, blockInfo.getBlockExpr()->getBeginLoc()};
+  auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
 


Index: clang/test/CodeGenObjC/debug-info-blocks.m
===
--- clang/test/CodeGenObjC/debug-info-blocks.m
+++ clang/test/CodeGenObjC/debug-info-blocks.m
@@ -17,13 +17,17 @@
 // CHECK-NOT: ret
 // CHECK: call {{.*}}, !dbg ![[DBG_LINE:[0-9]+]]
 // CHECK-NOT: ret
-// CHECK: load {{.*}}, !dbg ![[COPY_LINE:[0-9]+]]
-// CHECK: ret void, !dbg ![[COPY_LINE]]
-// CHECK: define {{.*}} @__destroy_helper_block_{{.*}}(i8* %0)
+// CHECK: load {{.*}}, !dbg ![[DBG_LINE]]
+// CHECK: ret {{.*}}, !dbg ![[DBG_LINE]]
+// CHECK: define {{.*}} @__destroy_helper_block_{{.*}}(i8*
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[DESTROY_LINE:[0-9]+]]
-// CHECK: ret void, !dbg ![[DESTROY_LINE]]
+// CHECK: ret {{.*}}, !dbg ![[DESTROY_LINE]]
 
+// CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
+// CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(name: "__copy_helper_block_
+// CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: 0, scope: ![[DESTROY_SP:[0-9]+]])
+// CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(name: "__destroy_helper_block_
 typedef unsigned int NSUInteger;
 
 @protocol NSObject
@@ -57,11 +61,6 @@
 - (id)init
 {
 if ((self = [super init]

[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-03-04 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:283
   llvm::FunctionCallee atexit =
-  CGM.CreateRuntimeFunction(atexitTy, "atexit", llvm::AttributeList(),
-/*Local=*/true);
+  CGM.CreateRuntimeFunction(atexitTy, "atexit", llvm::AttributeList());
   if (llvm::Function *atexitFn = dyn_cast(atexit.getCallee()))

The default value for `Local` is false, was this change intentional? If so why 
is it needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166



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


[PATCH] D75613: [Sema] Reword -Wrange-loop-analysis warning messages

2020-03-04 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

Thanks for the patch! I've some minor nits, but other then that it looks fine.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2427
   "selected '%select{begin|end}0' %select{function|template }1%2 with iterator 
type %3">;
 def warn_for_range_const_reference_copy : Warning<
   "loop variable %0 "

I'd like to change this name to reflect the changed diagnostic.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2434
   "use non-reference type %0 to keep the copy or type %1 to prevent copying">;
 def warn_for_range_variable_always_copy : Warning<
-  "loop variable %0 is always a copy because the range of type %1 does not "

I'd like to change this name to reflect the changed diagnostic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75613



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


[PATCH] D74238: [clang] Improve diagnostic note for implicit conversion sequences that would work if more than one implicit user-defined conversion were allowed.

2020-03-04 Thread Logan Smith via Phabricator via cfe-commits
logan-5 added a comment.

Pinging this and the patches it depends on. I figured it would need a rebase by 
now, but it still applies cleanly to trunk.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74238



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-03-04 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added a comment.

Please fix the formatting issues flagged by the pre-merge checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166



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


[clang] e46f0fe - [OPENMP50]Codegen for 'depend' clause in depobj directive.

2020-03-04 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-03-04T15:01:53-05:00
New Revision: e46f0fee3066240389e20dc847a281274dc81d2e

URL: 
https://github.com/llvm/llvm-project/commit/e46f0fee3066240389e20dc847a281274dc81d2e
DIFF: 
https://github.com/llvm/llvm-project/commit/e46f0fee3066240389e20dc847a281274dc81d2e.diff

LOG: [OPENMP50]Codegen for 'depend' clause in depobj directive.

Added codegen for 'depend' clause in depobj directive. The depend clause
is emitted as kmp_depend_info [ + 1]. The
first element in this array is reserved for storing the number of
elements in this array: [0].base_addr =
;

This extra element is required to implement 'update' and 'destroy'
clauses. It is required to know the size of array to destroy it
correctly and to update depency kind.

Added: 
clang/test/OpenMP/depobj_codegen.cpp

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 9fe03069a44e..ce23434e1a52 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -29,6 +29,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
+#include "llvm/IR/Constants.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/GlobalValue.h"
 #include "llvm/IR/Value.h"
@@ -5185,29 +5186,21 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, 
SourceLocation Loc,
   return Result;
 }
 
-void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc,
-   const OMPExecutableDirective &D,
-   llvm::Function *TaskFunction,
-   QualType SharedsTy, Address Shareds,
-   const Expr *IfCond,
-   const OMPTaskDataTy &Data) {
-  if (!CGF.HaveInsertPoint())
-return;
-
-  TaskResultTy Result =
-  emitTaskInit(CGF, Loc, D, TaskFunction, SharedsTy, Shareds, Data);
-  llvm::Value *NewTask = Result.NewTask;
-  llvm::Function *TaskEntry = Result.TaskEntry;
-  llvm::Value *NewTaskNewTaskTTy = Result.NewTaskNewTaskTTy;
-  LValue TDBase = Result.TDBase;
-  const RecordDecl *KmpTaskTQTyRD = Result.KmpTaskTQTyRD;
+Address CGOpenMPRuntime::emitDependClause(
+CodeGenFunction &CGF,
+ArrayRef> Dependencies,
+bool ForDepobj, SourceLocation Loc) {
+  // Process list of dependencies.
   ASTContext &C = CGM.getContext();
-  // Process list of dependences.
   Address DependenciesArray = Address::invalid();
-  unsigned NumDependencies = Data.Dependences.size();
+  unsigned NumDependencies = Dependencies.size();
   if (NumDependencies) {
 // Dependence kind for RTL.
-enum RTLDependenceKindTy { DepIn = 0x01, DepInOut = 0x3, DepMutexInOutSet 
= 0x4 };
+enum RTLDependenceKindTy {
+  DepIn = 0x01,
+  DepInOut = 0x3,
+  DepMutexInOutSet = 0x4
+};
 enum RTLDependInfoFieldsTy { BaseAddr, Len, Flags };
 RecordDecl *KmpDependInfoRD;
 QualType FlagsTy =
@@ -5224,15 +5217,47 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction 
&CGF, SourceLocation Loc,
 } else {
   KmpDependInfoRD = cast(KmpDependInfoTy->getAsTagDecl());
 }
-// Define type kmp_depend_info[];
+// Define type kmp_depend_info[];
+// For depobj reserve one extra element to store the number of elements.
+// It is required to handle depobj(x) update(in) construct.
 QualType KmpDependInfoArrayTy = C.getConstantArrayType(
-KmpDependInfoTy, llvm::APInt(/*numBits=*/64, NumDependencies),
+KmpDependInfoTy,
+llvm::APInt(/*numBits=*/64, NumDependencies + (ForDepobj ? 1 : 0)),
 nullptr, ArrayType::Normal, /*IndexTypeQuals=*/0);
-// kmp_depend_info[] deps;
-DependenciesArray =
-CGF.CreateMemTemp(KmpDependInfoArrayTy, ".dep.arr.addr");
+// kmp_depend_info[] deps;
+if (ForDepobj) {
+  // Need to allocate on the dynamic memory.
+  llvm::Value *ThreadID = getThreadID(CGF, Loc);
+  // Use default allocator.
+  llvm::Value *Allocator = llvm::ConstantPointerNull::get(CGF.VoidPtrTy);
+  CharUnits Align = C.getTypeAlignInChars(KmpDependInfoArrayTy);
+  CharUnits Sz = C.getTypeSizeInChars(KmpDependInfoArrayTy);
+  llvm::Value *Size = CGF.CGM.getSize(Sz.alignTo(Align));
+  llvm::Value *Args[] = {ThreadID, Size, Allocator};
+
+  llvm::Value *Addr = CGF.EmitRuntimeCall(
+  createRuntimeFunction(OMPRTL__kmpc_alloc), Args, ".dep.arr.addr");
+  Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
+  Addr, CGF.ConvertTypeForMem(KmpDependInfoArrayTy)->getPointerTo());
+  DependenciesArray = Address(Addr, Align);
+} else {
+  DependenciesArray =
+  CGF.CreateMemTemp(KmpDependInfoArray

[PATCH] D75632: Comment parsing: Treat \ref as inline command

2020-03-04 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added a reviewer: gribozavr2.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It's basically Doxygen's version of a link and can happen anywhere
inside of a paragraph. Fixes a bogus warning about empty paragraphs when
a parameter description starts with a link.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75632

Files:
  clang/include/clang/AST/CommentCommands.td
  clang/test/Sema/warn-documentation.cpp


Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -294,6 +294,9 @@
 /// \retval 0 Blah blah.
 int test_param23(int a);
 
+/// \param a \ref test_param23 has an empty paragraph, this doesn't.
+int test_param24(int a);
+
 //===---
 // Test that we treat typedefs to some non-function types as functions for the
 // purposes of documentation comment parsing.
Index: clang/include/clang/AST/CommentCommands.td
===
--- clang/include/clang/AST/CommentCommands.td
+++ clang/include/clang/AST/CommentCommands.td
@@ -87,6 +87,7 @@
 def A  : InlineCommand<"a">;
 def E  : InlineCommand<"e">;
 def Em : InlineCommand<"em">;
+def Ref: InlineCommand<"ref">;
 def Anchor : InlineCommand<"anchor">;
 
 
//===--===//
@@ -205,7 +206,6 @@
 
 def Mainpage : VerbatimLineCommand<"mainpage">;
 def Subpage  : VerbatimLineCommand<"subpage">;
-def Ref  : VerbatimLineCommand<"ref">;
 
 def Relates : VerbatimLineCommand<"relates">;
 def Related : VerbatimLineCommand<"related">;


Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -294,6 +294,9 @@
 /// \retval 0 Blah blah.
 int test_param23(int a);
 
+/// \param a \ref test_param23 has an empty paragraph, this doesn't.
+int test_param24(int a);
+
 //===---
 // Test that we treat typedefs to some non-function types as functions for the
 // purposes of documentation comment parsing.
Index: clang/include/clang/AST/CommentCommands.td
===
--- clang/include/clang/AST/CommentCommands.td
+++ clang/include/clang/AST/CommentCommands.td
@@ -87,6 +87,7 @@
 def A  : InlineCommand<"a">;
 def E  : InlineCommand<"e">;
 def Em : InlineCommand<"em">;
+def Ref: InlineCommand<"ref">;
 def Anchor : InlineCommand<"anchor">;
 
 //===--===//
@@ -205,7 +206,6 @@
 
 def Mainpage : VerbatimLineCommand<"mainpage">;
 def Subpage  : VerbatimLineCommand<"subpage">;
-def Ref  : VerbatimLineCommand<"ref">;
 
 def Relates : VerbatimLineCommand<"relates">;
 def Related : VerbatimLineCommand<"related">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71913: [LTO/WPD] Enable aggressive WPD under LTO option

2020-03-04 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson marked an inline comment as done.
tejohnson added inline comments.



Comment at: clang/test/CodeGenCXX/lto-visibility-inference.cpp:73
   c1->f();
-  // ITANIUM-NOT: type.test{{.*}}!"_ZTS2C2"
+  // ITANIUM: type.test{{.*}}!"_ZTS2C2"
   // MS: type.test{{.*}}!"?AUC2@@"

pcc wrote:
> tejohnson wrote:
> > evgeny777 wrote:
> > > tejohnson wrote:
> > > > evgeny777 wrote:
> > > > > tejohnson wrote:
> > > > > > evgeny777 wrote:
> > > > > > > What caused this and other changes in this file?
> > > > > > Because we now will insert type tests for non-hidden vtables. This 
> > > > > > is enabled by the changes to LTO to interpret these based on the 
> > > > > > vcall_visibility metadata.
> > > > > The results of this test case
> > > > > ```
> > > > > %clang_cc1 -flto -triple x86_64-pc-windows-msvc -std=c++11 
> > > > > -fms-extensions -fwhole-program-vtables -flto-visibility-public-std 
> > > > > -emit-llvm -o - %s | FileCheck --check-prefix=MS 
> > > > > --check-prefix=MS-NOSTD %s
> > > > > ```
> > > > > look not correct to me. I think you shouldn't generate type tests for 
> > > > > standard library classes with  `-flto-visibility-public-std`. 
> > > > > Currently if this flag is given, clang doesn't do this either even 
> > > > > with `-fvisibility=hidden`
> > > > The associated vtables would get the vcall_visibility public metadata, 
> > > > so the type tests themselves aren't problematic. I tend to think that 
> > > > an application using such options should simply stick with 
> > > > -fvisibility=hidden to get WPD and not use the new LTO option to 
> > > > convert all public vcall_visibility metadata to hidden.
> > > > The associated vtables would get the vcall_visibility public metadata, 
> > > > so the type tests themselves aren't problematic. I tend to think that 
> > > > an application using such options should simply stick with 
> > > > -fvisibility=hidden to get WPD and not use the new LTO option to 
> > > > convert all public vcall_visibility metadata to hidden.
> > > 
> > > I see two issues here:
> > > 1) It's not always good option to force hidden visibility for everything. 
> > > For instance I work on proprietary platform which demands public 
> > > visibility for certain symbols in order for dynamic loader to work 
> > > properly. In this context your patch does a great job.
> > > 
> > > 2) Standard library is almost never LTOed so in general we can't narrow 
> > > std::* vtables visibility to linkage unit
> > > 
> > > Is there anything which prevents from implementing the same functionality 
> > > with new -lto-whole-program-visibility option (i.e without forcing hidden 
> > > visibility)? In other words the following looks good to me:
> > > 
> > > ```
> > > # Compile with lto/devirtualization support
> > > clang -flto=thin -flto-visibility-public-std -fwhole-program-vtables -c 
> > > *.cpp
> > > 
> > > # Link: everything is devirtualized except standard library classes 
> > > virtual methods
> > > clang -Wl,-lto-whole-program-visibility -fuse-ld=lld *.o
> > > ```
> > Ok, thanks for the info. I will go ahead and change the code to not insert 
> > the type tests in this case to support this usage.
> > 
> > Ultimately, I would like to decouple the existence of the type tests from 
> > visibility implications. I'm working on another change to delay 
> > lowering/removal of type tests until after indirect call promotion, so we 
> > can use them in other cases (streamlined indirect call promotion checks 
> > against the vtable instead of the function pointers, also useful if we want 
> > to implement speculative devirtualization based on WPD info). In those 
> > cases we need the type tests, either to locate information in the summary, 
> > or to get the address point offset for a vtable address compare. In that 
> > case it would be helpful to have the type tests in this type of code as 
> > well. So we'll need another way to communicate down to WPD that they should 
> > never be devirtualized. But I don't think it makes sense to design this 
> > support until there is a concrete use case and need. In the meantime I will 
> > change the code to be conservative and not insert the type tests in this 
> > case.
> Note that `-flto-visibility-public-std` is a cc1-only option and only used on 
> Windows, and further that `-lto-whole-program-visibility` as implemented 
> doesn't really make sense on Windows because the classes with public 
> visibility are going to be marked dllimport/dllexport/uuid (COM), and 
> `-lto-whole-program-visibility` corresponds to flags such as 
> `--version-script` or the absence of `-shared` in which the linker 
> automatically relaxes the visibility of some symbols, while there is no such 
> concept of relaxing symbol visibility on Windows.
> 
>  I would be inclined to remove this support and either let the public 
> visibility automatically derive from the absence of 
> `-lto-whole-program-visibility` at link time in COFF links or omit

[PATCH] D75215: [DebugInfo] Fix for adding "returns cxx udt" option to functions in CodeView.

2020-03-04 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: llvm/include/llvm/IR/DebugInfoFlags.def:61
 HANDLE_DI_FLAG((1 << 29), AllCallsDescribed)
+HANDLE_DI_FLAG((1 << 30), CxxReturnUdt)
 

aprantl wrote:
> dblaikie wrote:
> > rnk wrote:
> > > @dblaikie @aprantl, does this seem like a reasonable flag to add, or 
> > > should we mark record forward decls as trivial/nontrivial instead?
> > Currently we only have a trivial/nontrivial flag that goes one way, right? 
> > (ie: true/false, not three state true/false/unknown)
> > 
> > That would present a problem for forward declarations - because for a true 
> > forward decl you can't know if it's trivial/non-trivial for passing, right? 
> > so that'd present a subtle difference between trivial/non-trivial on a decl 
> > (where it might be trivial/unknown) and on a def (where it's 
> > trivial/non-trivial), yes?
> Should this perhaps be a DI_SPFLAG instead?
It's true that there is an ambiguity between known trivial, known non-trivial, 
and forward declared, unknown triviality. Amy's solution to this problem was to 
mark forward declarations as nontrivial, which matches the logic MSVC uses to 
set CxxReturnUdt, but might not be the right thing for other consumers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75215



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


[PATCH] D75215: [DebugInfo] Fix for adding "returns cxx udt" option to functions in CodeView.

2020-03-04 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: llvm/include/llvm/IR/DebugInfoFlags.def:61
 HANDLE_DI_FLAG((1 << 29), AllCallsDescribed)
+HANDLE_DI_FLAG((1 << 30), CxxReturnUdt)
 

dblaikie wrote:
> rnk wrote:
> > @dblaikie @aprantl, does this seem like a reasonable flag to add, or should 
> > we mark record forward decls as trivial/nontrivial instead?
> Currently we only have a trivial/nontrivial flag that goes one way, right? 
> (ie: true/false, not three state true/false/unknown)
> 
> That would present a problem for forward declarations - because for a true 
> forward decl you can't know if it's trivial/non-trivial for passing, right? 
> so that'd present a subtle difference between trivial/non-trivial on a decl 
> (where it might be trivial/unknown) and on a def (where it's 
> trivial/non-trivial), yes?
Should this perhaps be a DI_SPFLAG instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75215



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


[PATCH] D75153: [ThinLTO] Allow usage of all SMT threads in the system

2020-03-04 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 248254.
aganea edited the summary of this revision.
aganea edited reviewers, added: dexonsmith, ruiu; removed: RobRich999, 
espindola.
aganea added subscribers: ruiu, RobRich999.
aganea added a comment.
Herald added a reviewer: espindola.

Simplify. Revert to previous behavior, where any number of threads can be 
specified on the cmd-line, as suggested by @mehdi_amini. See the updated 
Summary for cmd-line usage.

+ @dexonsmith for the Darwin part.
+ @ruiu for the LLD part.


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

https://reviews.llvm.org/D75153

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  lld/COFF/Config.h
  lld/COFF/Driver.cpp
  lld/COFF/LTO.cpp
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/LTO.cpp
  lld/test/COFF/thinlto.ll
  lld/test/ELF/basic.s
  lld/test/ELF/lto/thinlto.ll
  lld/test/wasm/lto/thinlto.ll
  lld/wasm/Config.h
  lld/wasm/Driver.cpp
  lld/wasm/LTO.cpp
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/Support/Threading.h
  llvm/lib/LTO/LTO.cpp
  llvm/lib/Support/Threading.cpp
  llvm/lib/Support/Windows/Threading.inc
  llvm/test/Transforms/PGOProfile/thinlto_samplepgo_icp3.ll
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp

Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -66,9 +66,10 @@
"distributed backend case"));
 
 // Default to using all available threads in the system, but using only one
-// thread per core, as indicated by the usage of
-// heavyweight_hardware_concurrency() in the InProcessThinBackend constructor.
-static cl::opt Threads("thinlto-threads", cl::init(0));
+// thread per core (no SMT).
+// Use -thinlto-threads=all to use hardware_concurrency() instead, which means
+// to use all hardware threads or cores in the system.
+static cl::opt Threads("thinlto-threads");
 
 static cl::list SymbolResolutions(
 "r",
@@ -284,7 +285,8 @@
 /* LinkedObjectsFile */ nullptr,
 /* OnWrite */ {});
   else
-Backend = createInProcessThinBackend(Threads);
+Backend = createInProcessThinBackend(
+llvm::heavyweight_hardware_concurrency(Threads));
   LTO Lto(std::move(Conf), std::move(Backend));
 
   bool HasErrors = false;
Index: llvm/tools/gold/gold-plugin.cpp
===
--- llvm/tools/gold/gold-plugin.cpp
+++ llvm/tools/gold/gold-plugin.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/Threading.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -132,11 +133,9 @@
   };
   static OutputType TheOutputType = OT_NORMAL;
   static unsigned OptLevel = 2;
-  // Default parallelism of 0 used to indicate that user did not specify.
-  // Actual parallelism default value depends on implementation.
   // Currently only affects ThinLTO, where the default is the max cores in the
-  // system.
-  static unsigned Parallelism = 0;
+  // system. See llvm::get_threadpool_strategy() for acceptable values.
+  static std::string Parallelism;
   // Default regular LTO codegen parallelism (number of partitions).
   static unsigned ParallelCodeGenParallelismLevel = 1;
 #ifdef NDEBUG
@@ -270,8 +269,10 @@
 message(LDPL_FATAL, "Optimization level must be between 0 and 3");
   OptLevel = opt[1] - '0';
 } else if (opt.startswith("jobs=")) {
-  if (StringRef(opt_ + 5).getAsInteger(10, Parallelism))
-message(LDPL_FATAL, "Invalid parallelism level: %s", opt_ + 5);
+  StringRef Num(opt_ + 5);
+  if (!get_threadpool_strategy(Num))
+message(LDPL_FATAL, "Invalid parallelism level: %s", Num.data());
+  Parallelism = Num;
 } else if (opt.startswith("lto-partitions=")) {
   if (opt.substr(strlen("lto-partitions="))
   .getAsInteger(10, ParallelCodeGenParallelismLevel))
@@ -875,14 +876,15 @@
   Conf.PTO.LoopVectorization = options::OptLevel > 1;
   Conf.PTO.SLPVectorization = options::OptLevel > 1;
 
-  if (options::Parallelism)
-Backend = createInProcessThinBackend(options::Parallelism);
   if (options::thinlto_index_only) {
 std::string OldPrefix, NewPrefix;
 getThinLTOOldAndNewPrefix(OldPrefix, NewPrefix);
 Backend = createWriteIndexesThinBackend(OldPrefix, NewPrefix,
 options::thinlto_emit_imports_files,
 LinkedObjectsFile, OnIndexWrite);
+  } else {
+Backend = createInProcessThinBackend(
+llvm::heavyweight_hardware_concurrency(options::Parallelism));
   }
 
   Conf.OverrideTriple = options::triple;
Index

[PATCH] D75621: [clang-tidy] Use ; as separator for HeaderFileExtensions

2020-03-04 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D75621#1905879 , @jroelofs wrote:

> Preserve backwards compatibility of ',' as a delimiter (for now).
>
> > The llvm::StringRef::split function can take multiple split characters,
>
> AFAIU, that's for multi-character delimiters, not multiple delimiters.


Yeah just checked it out my bad.




Comment at: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp:41
+  for (const char Delimiter : Delimiters) {
+if (StringRef::npos != AllFileExtensions.find(Delimiter)) {
+  if (Delimiter == ',') {

`if (AllFileExtensions.contains(Delimeter)) {`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75621



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


[PATCH] D75603: [clangd] Add instrumentation mode in clangd for metrics collection.

2020-03-04 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/CodeComplete.h:136
+
+  /// Allows capturing various internal structures used by clangd during code
+  /// completion. Eg: Symbol quality and relevance signals of all the 
candidates

First say what the behavior/API is (called once for each result...), Then 
justify it :)



Comment at: clang-tools-extra/clangd/CodeComplete.h:139
+  /// in the output.
+  std::function *RecordCCResult = 
nullptr;

I'd suggest including the final score in the signature rather than recompute 
it, just so the contract is really clear and simple (results yielded in 
arbitrary order, will be ranked by -score). Please spell this out.



Comment at: clang-tools-extra/clangd/CodeComplete.h:140
+  std::function *RecordCCResult = 
nullptr;
 };

This doesn't need to be a pointer, std::function is copy/movable and supports 
nullptr as a sentinel value.



Comment at: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp:1048
+  std::vector RecordedCompletions;
+  std::function

Nit: typically `auto` here (the anonymous lambda type) and let it convert to 
function implicitly when needed.

No need for `-> type` in trivial cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75603



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


[PATCH] D75215: [DebugInfo] Fix for adding "returns cxx udt" option to functions in CodeView.

2020-03-04 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: llvm/include/llvm/IR/DebugInfoFlags.def:61
 HANDLE_DI_FLAG((1 << 29), AllCallsDescribed)
+HANDLE_DI_FLAG((1 << 30), CxxReturnUdt)
 

rnk wrote:
> @dblaikie @aprantl, does this seem like a reasonable flag to add, or should 
> we mark record forward decls as trivial/nontrivial instead?
Currently we only have a trivial/nontrivial flag that goes one way, right? (ie: 
true/false, not three state true/false/unknown)

That would present a problem for forward declarations - because for a true 
forward decl you can't know if it's trivial/non-trivial for passing, right? so 
that'd present a subtle difference between trivial/non-trivial on a decl (where 
it might be trivial/unknown) and on a def (where it's trivial/non-trivial), yes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75215



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


[PATCH] D75621: [clang-tidy] Use ; as separator for HeaderFileExtensions

2020-03-04 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 248245.
jroelofs added a comment.

Preserve backwards compatibility of ',' as a delimiter (for now).

> The llvm::StringRef::split function can take multiple split characters,

AFAIU, that's for multi-character delimiters, not multiple delimiters.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75621

Files:
  clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
  clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
  clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h
  clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
  clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
  clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h
  clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
  clang-tools-extra/clang-tidy/utils/HeaderGuard.h

Index: clang-tools-extra/clang-tidy/utils/HeaderGuard.h
===
--- clang-tools-extra/clang-tidy/utils/HeaderGuard.h
+++ clang-tools-extra/clang-tidy/utils/HeaderGuard.h
@@ -18,11 +18,12 @@
 
 /// Finds and fixes header guards.
 /// The check supports these options:
-///   - `HeaderFileExtensions`: a comma-separated list of filename extensions of
-/// header files (The filename extension should not contain "." prefix).
-/// ",h,hh,hpp,hxx" by default.
+///   - `HeaderFileExtensions`: a semicolon-separated list of filename
+/// extensions of header files (The filename extension should not contain
+/// "." prefix). ";h;hh;hpp;hxx" by default.
+///
 /// For extension-less header files, using an empty string or leaving an
-/// empty string between "," if there are other filename extensions.
+/// empty string between ";" if there are other filename extensions.
 class HeaderGuardCheck : public ClangTidyCheck {
 public:
   HeaderGuardCheck(StringRef Name, ClangTidyContext *Context)
@@ -30,7 +31,8 @@
 RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
 "HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
 utils::parseFileExtensions(RawStringHeaderFileExtensions,
-   HeaderFileExtensions, ',');
+   HeaderFileExtensions,
+   utils::defaultFileExtensionDelimiters());
   }
   void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override;
Index: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
===
--- clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
+++ clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
@@ -34,11 +34,16 @@
 
 /// Returns recommended default value for the list of header file
 /// extensions.
-inline StringRef defaultHeaderFileExtensions() { return ",h,hh,hpp,hxx"; }
+inline StringRef defaultHeaderFileExtensions() { return ";h;hh;hpp;hxx"; }
+
+/// Returns recommended default value for the list of file extension
+/// delimiters.
+inline StringRef defaultFileExtensionDelimiters() { return ",;"; }
 
 /// Parses header file extensions from a semicolon-separated list.
 bool parseFileExtensions(StringRef AllFileExtensions,
- FileExtensionsSet &FileExtensions, char Delimiter);
+ FileExtensionsSet &FileExtensions,
+ StringRef Delimiters);
 
 /// Decides whether a file has one of the specified file extensions.
 bool isFileExtension(StringRef FileName,
Index: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
@@ -9,6 +9,7 @@
 #include "FileExtensionsUtils.h"
 #include "clang/Basic/CharInfo.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 
 namespace clang {
 namespace tidy {
@@ -33,9 +34,21 @@
 }
 
 bool parseFileExtensions(StringRef AllFileExtensions,
- FileExtensionsSet &FileExtensions, char Delimiter) {
+ FileExtensionsSet &FileExtensions,
+ StringRef Delimiters) {
   SmallVector Suffixes;
-  AllFileExtensions.split(Suffixes, Delimiter);
+  for (const char Delimiter : Delimiters) {
+if (StringRef::npos != AllFileExtensions.find(Delimiter)) {
+  if (Delimiter == ',') {
+llvm::errs()
+<< "Using ',' as a file extension delimiter is deprecated. Please "
+ 

[PATCH] D74669: [clang-tidy] New check: bugprone-suspicious-include

2020-03-04 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 248246.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.hpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.c
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cc
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cxx
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
@@ -0,0 +1,23 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-include %t -- -- -isystem %S/Inputs/Headers -fmodules
+
+// clang-format off
+
+// CHECK-MESSAGES: [[@LINE+4]]:11: warning: suspicious #include of file with '.cpp' extension
+// CHECK-MESSAGES: [[@LINE+3]]:11: note: did you mean to include 'a'?
+// CHECK-MESSAGES: [[@LINE+2]]:11: note: did you mean to include 'a.h'?
+// CHECK-MESSAGES: [[@LINE+1]]:11: note: did you mean to include 'a.hpp'?
+#include "a.cpp"
+
+#include "b.h"
+
+// CHECK-MESSAGES: [[@LINE+1]]:10: warning: suspicious #import of file with '.c' extension
+#import "c.c"
+
+// CHECK-MESSAGES: [[@LINE+1]]:16: warning: suspicious #include_next of file with '.c' extension
+#include_next 
+
+// CHECK-MESSAGES: [[@LINE+1]]:13: warning: suspicious #include of file with '.cc' extension
+# include  
+
+// CHECK-MESSAGES: [[@LINE+1]]:14: warning: suspicious #include of file with '.cxx' extension
+#  include  
Index: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
===
--- clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
+++ clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
@@ -11,6 +11,7 @@
 
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringRef.h"
 
@@ -36,6 +37,12 @@
 /// extensions.
 inline StringRef defaultHeaderFileExtensions() { return ";h;hh;hpp;hxx"; }
 
+/// Returns recommended default value for the list of implementaiton file
+/// extensions.
+inline StringRef defaultImplementationFileExtensions() {
+  return "c;cc;cpp;cxx";
+}
+
 /// Returns recommended default value for the list of file extension
 /// delimiters.
 inline StringRef defaultFileExtensionDelimiters() { return ",;"; }
@@ -45,6 +52,11 @@
  FileExtensionsSet &FileExtensions,
  StringRef Delimiters);
 
+/// Decides whether a file has a header file extension.
+/// Returns the file extension, if included in the provided set.
+llvm::Optional
+getFileExtension(StringRef FileName, const FileExtensionsSet &FileExtensions);
+
 /// Decides whether a file has one of the specified file extensions.
 bool isFileExtension(StringRef FileName,
  const FileExtensionsSet &FileExtensions);
Index: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
@@ -59,13 +59,20 @@
   return true;
 }
 
-bool isFileExtension(StringRef FileName,
- const FileExtensionsSet &FileExtensions) {
+llvm::Optional
+getFileExtension(StringRef FileName, const FileExtensionsSet &FileExtensions) {
   StringRef Extension = llvm::sys::path::extension(FileName);
   if (Extension.empty())
-return false;
+return llvm::None;
   // Skip "." prefix.
-  return FileExtensions.count(Extension.substr(1)) > 0;
+  if (!FileExtensions.count(Extension.substr(1)))
+return llvm::None;
+  return Extension;
+}
+
+bool isFileExtension(StringRef FileName,
+ const FileExtensionsSet &FileExtensions) {
+  return getFileExtension(FileName, FileExtensions).hasValue();
 }
 
 } // namespace utils
Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
@@ -0,0 +1,57 @@
+//===--- SuspiciousIncludeCheck.h - clang-tidy --*- C++ -*-===//
+//
+// Part of th

[PATCH] D75606: [clang-format] Improve identification of C# nullables

2020-03-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfe61bc1a0b5a: [clang-format] Improve identification of C# 
nullables (authored by Jonathan Coe ).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75606

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -631,7 +631,17 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
   Style.SpacesInSquareBrackets = false;
 
+  verifyFormat(R"(//
+public class A {
+  void foo() { int? value = some.bar(); }
+})",
+   Style); // int? is nullable not a conditional expression.
+
+  verifyFormat(R"(void foo(int? x, int? y, int? z) {})",
+   Style); // Nullables in function definitions.
+
   verifyFormat(R"(public float? Value;)", Style); // no space before `?`.
+
   verifyFormat(R"(int?[] arr = new int?[10];)",
Style); // An array of a nullable type.
 }
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1011,7 +1011,12 @@
   Style.Language == FormatStyle::LK_JavaScript)
 break;
   if (Style.isCSharp()) {
-if (Line.MustBeDeclaration && !Contexts.back().IsExpression) {
+// `Type? name;` and `Type? name =` can only be nullable types.
+// Line.MustBeDeclaration will be true for `Type? name;`.
+if (!Contexts.back().IsExpression &&
+(Line.MustBeDeclaration ||
+ (Tok->Next && Tok->Next->is(tok::identifier) && Tok->Next->Next &&
+  Tok->Next->Next->is(tok::equal {
   Tok->Type = TT_CSharpNullable;
   break;
 }


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -631,7 +631,17 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
   Style.SpacesInSquareBrackets = false;
 
+  verifyFormat(R"(//
+public class A {
+  void foo() { int? value = some.bar(); }
+})",
+   Style); // int? is nullable not a conditional expression.
+
+  verifyFormat(R"(void foo(int? x, int? y, int? z) {})",
+   Style); // Nullables in function definitions.
+
   verifyFormat(R"(public float? Value;)", Style); // no space before `?`.
+
   verifyFormat(R"(int?[] arr = new int?[10];)",
Style); // An array of a nullable type.
 }
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1011,7 +1011,12 @@
   Style.Language == FormatStyle::LK_JavaScript)
 break;
   if (Style.isCSharp()) {
-if (Line.MustBeDeclaration && !Contexts.back().IsExpression) {
+// `Type? name;` and `Type? name =` can only be nullable types.
+// Line.MustBeDeclaration will be true for `Type? name;`.
+if (!Contexts.back().IsExpression &&
+(Line.MustBeDeclaration ||
+ (Tok->Next && Tok->Next->is(tok::identifier) && Tok->Next->Next &&
+  Tok->Next->Next->is(tok::equal {
   Tok->Type = TT_CSharpNullable;
   break;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75603: [clangd] Add instrumentation mode in clangd for metrics collection.

2020-03-04 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 marked 3 inline comments as done.
usaxena95 added inline comments.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:1465
+if (Opts.EnableInstrumentationMode)
+  (*Opts.RecordCCResults)(toCodeCompleteResult(Top));
+

kadircet wrote:
> can't we make use of the trace::Span instead ?
CMIIW. I believe with `trace::Span` we can send only JSON messages from clangd 
to the tool running it. This doesn't allow us to get access to internal DS of 
CodeCompleteFlow that are used along with Quality and Relevance signals (like 
Distances of file and scopes).
You can argue that all this information can be serialized as a JSON (including 
features derived from these internal DS) but this then must be done on clangd 
side (not on tools side).

IMO this gives more freedom to the tool to use and derive more features which 
makes experimentation easier.



Comment at: clang-tools-extra/clangd/CodeComplete.h:141
+  /// Ideally this must be disabled when being used by ClangdLSPServer.
+  bool EnableInstrumentationMode = false;
+  std::function* RecordCCResults;

sammccall wrote:
> I'm wondering if we can simplify this interface a bit. I'm not sure why we 
> need another callback rather than just returning the CodeCompleteResult in 
> the usual way.
> 
> Another option:
>  - if we invoke a callback for each completion instead of for the result set 
> as a whole, we don't need to work out where to stash anything.
>  - the work done after `addCandidate` is pretty trivial, so invoking a 
> callback there provides basically all the information about the result set. 
> The Top-N truncation is probably something you'd rather *not* have for 
> analysis.
>  - code completion always ends with the callback being invoked, so 
> cross-result analysis can be done at that point.
> 
> So I think this could just be a single
> `std::function const SymbolRelevanceSignals &)>`.
> If it's non-null, addCandidate would call toCodeCompletion on the bundle and 
> pass it to the callback at the end.
> why we need another callback rather than just returning the 
> CodeCompleteResult in the usual way.
There are some data structures from CodeCompleteFlow referred to in Reference 
signals like `ScopeDistance` which were needed to compute distances. But think 
can be addressed in your suggested "per completion" callback approach.

> Another option: ...
I had given this approach some thought previously and had concerns about 
mapping the items to the final ranked items in the TopN result. But on a second 
thought we can completely ignore the final result (assuming no significant 
changes are done after `addCandidate`) and **score** and **rank** the results 
ourselves in the FlumeTool. 





Comment at: clang-tools-extra/clangd/CodeComplete.h:218
+// Signals captured when instrumentation is enabled during code completion.
+std::shared_ptr QualitySignals;
+std::shared_ptr RelevanceSignals;

sammccall wrote:
> why shared rather than unique?
A not-so-proud hack to keep `Score` copyable (this is removed now).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75603



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


[PATCH] D75603: [clangd] Add instrumentation mode in clangd for metrics collection.

2020-03-04 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 248240.
usaxena95 marked 2 inline comments as done.
usaxena95 added a comment.

Remove ununsed import.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75603

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


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -29,7 +29,9 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include 
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -1041,6 +1043,24 @@
   EXPECT_THAT(Completions, Contains(Named("TT")));
 }
 
+TEST(CompletionTest, EnableInstrumentationMode) {
+  std::vector RecordedCompletions;
+  std::function
+  ResultRecorder =
+  [&RecordedCompletions](const CodeCompletion &CC,
+ const SymbolQualitySignals &,
+ const SymbolRelevanceSignals &) -> void {
+RecordedCompletions.push_back(CC);
+  };
+  CodeCompleteOptions Opts;
+  Opts.RecordCCResult = &ResultRecorder;
+
+  completions("int xy1, xy2; int a = xy^", /*IndexSymbols=*/{}, Opts);
+  EXPECT_THAT(RecordedCompletions,
+  UnorderedElementsAre(Named("xy1"), Named("xy2")));
+}
+
 SignatureHelp signatures(llvm::StringRef Text, Position Point,
  std::vector IndexSymbols = {}) {
   std::unique_ptr Index;
Index: clang-tools-extra/clangd/CodeComplete.h
===
--- clang-tools-extra/clangd/CodeComplete.h
+++ clang-tools-extra/clangd/CodeComplete.h
@@ -19,6 +19,7 @@
 #include "Logger.h"
 #include "Path.h"
 #include "Protocol.h"
+#include "Quality.h"
 #include "index/Index.h"
 #include "index/Symbol.h"
 #include "index/SymbolOrigin.h"
@@ -29,12 +30,14 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include 
 #include 
 
 namespace clang {
 class NamedDecl;
 namespace clangd {
 struct PreambleData;
+struct CodeCompletion;
 
 struct CodeCompleteOptions {
   /// Returns options that can be passed to clang's completion engine.
@@ -129,6 +132,12 @@
 /// Always use text-based completion.
 NeverParse,
   } RunParser = ParseIfReady;
+
+  /// Allows capturing various internal structures used by clangd during code
+  /// completion. Eg: Symbol quality and relevance signals of all the 
candidates
+  /// in the output.
+  std::function *RecordCCResult = 
nullptr;
 };
 
 // Semi-structured representation of a code-complete suggestion for our C++ 
API.
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1660,6 +1660,9 @@
? Scores.Total / Relevance.NameMatch
: Scores.Quality;
 
+if (Opts.RecordCCResult)
+  (*Opts.RecordCCResult)(toCodeCompletion(Bundle), Quality, Relevance);
+
 dlog("CodeComplete: {0} ({1}) = {2}\n{3}{4}\n", First.Name,
  llvm::to_string(Origin), Scores.Total, llvm::to_string(Quality),
  llvm::to_string(Relevance));


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -29,7 +29,9 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include 
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -1041,6 +1043,24 @@
   EXPECT_THAT(Completions, Contains(Named("TT")));
 }
 
+TEST(CompletionTest, EnableInstrumentationMode) {
+  std::vector RecordedCompletions;
+  std::function
+  ResultRecorder =
+  [&RecordedCompletions](const CodeCompletion &CC,
+ const SymbolQualitySignals &,
+ const SymbolRelevanceSignals &) -> void {
+RecordedCompletions.push_back(CC);
+  };
+  CodeCompleteOptions Opts;
+  Opts.RecordCCResult = &ResultRecorder;
+
+  completions("int xy1, xy2; int a = xy^", /*IndexSymbols=*/{}, Opts);
+  EXPECT_THAT(RecordedCompletions,
+  UnorderedElementsAre(Named("xy1"), Named("xy2")));
+}
+
 SignatureHelp signatures(llvm::StringRef Text, Position Point,
  std::vector IndexSymbols = {}) {
   std::unique_ptr Index;
Index: clang-tools-extra/clangd/CodeComplete.h
===
--- clang-tools-extra/clangd/CodeComplete.h
+++ clang-tools-extra/clangd/CodeComplete.h
@@ -19,6 +19,

[PATCH] D75603: [clangd] Add instrumentation mode in clangd for metrics collection.

2020-03-04 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 248233.
usaxena95 marked 3 inline comments as done.
usaxena95 added a comment.

Changed to invoke callback on all code completion items.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75603

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

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -29,7 +29,9 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include 
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -1041,6 +1043,24 @@
   EXPECT_THAT(Completions, Contains(Named("TT")));
 }
 
+TEST(CompletionTest, EnableInstrumentationMode) {
+  std::vector RecordedCompletions;
+  std::function
+  ResultRecorder =
+  [&RecordedCompletions](const CodeCompletion &CC,
+ const SymbolQualitySignals &,
+ const SymbolRelevanceSignals &) -> void {
+RecordedCompletions.push_back(CC);
+  };
+  CodeCompleteOptions Opts;
+  Opts.RecordCCResult = &ResultRecorder;
+
+  completions("int xy1, xy2; int a = xy^", /*IndexSymbols=*/{}, Opts);
+  EXPECT_THAT(RecordedCompletions,
+  UnorderedElementsAre(Named("xy1"), Named("xy2")));
+}
+
 SignatureHelp signatures(llvm::StringRef Text, Position Point,
  std::vector IndexSymbols = {}) {
   std::unique_ptr Index;
Index: clang-tools-extra/clangd/CodeComplete.h
===
--- clang-tools-extra/clangd/CodeComplete.h
+++ clang-tools-extra/clangd/CodeComplete.h
@@ -19,6 +19,7 @@
 #include "Logger.h"
 #include "Path.h"
 #include "Protocol.h"
+#include "Quality.h"
 #include "index/Index.h"
 #include "index/Symbol.h"
 #include "index/SymbolOrigin.h"
@@ -29,12 +30,14 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include 
 #include 
 
 namespace clang {
 class NamedDecl;
 namespace clangd {
 struct PreambleData;
+struct CodeCompletion;
 
 struct CodeCompleteOptions {
   /// Returns options that can be passed to clang's completion engine.
@@ -129,6 +132,12 @@
 /// Always use text-based completion.
 NeverParse,
   } RunParser = ParseIfReady;
+
+  /// Allows capturing various internal structures used by clangd during code
+  /// completion. Eg: Symbol quality and relevance signals of all the candidates
+  /// in the output.
+  std::function *RecordCCResult = nullptr;
 };
 
 // Semi-structured representation of a code-complete suggestion for our C++ API.
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -66,6 +66,7 @@
 #include "llvm/Support/ScopedPrinter.h"
 #include 
 #include 
+#include 
 
 // We log detailed candidate here if you run with -debug-only=codecomplete.
 #define DEBUG_TYPE "CodeComplete"
@@ -1660,6 +1661,9 @@
? Scores.Total / Relevance.NameMatch
: Scores.Quality;
 
+if (Opts.RecordCCResult)
+  (*Opts.RecordCCResult)(toCodeCompletion(Bundle), Quality, Relevance);
+
 dlog("CodeComplete: {0} ({1}) = {2}\n{3}{4}\n", First.Name,
  llvm::to_string(Origin), Scores.Total, llvm::to_string(Quality),
  llvm::to_string(Relevance));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75285: Mark restrict pointer or reference to const as invariant

2020-03-04 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D75285#1903611 , @yaxunl wrote:

> In D75285#1903444 , @rjmccall wrote:
>
> > That is not true for two reasons: first, `restrict` guarantees that the 
> > variable is not accessed through any non-derived l-value within its scope, 
> > and that would certainly include from other threads; and second, it is 
> > undefined behavior for two threads to access the same object without 
> > synchronizing anyway (unless they're both just reading from it).
>
>
> How about the cases where users cannot use restrict but they still want to 
> mark a pointer as invariant? Or even though restrict is used but it is too 
> complicated for alias analysis to deduce invariance?


If we can reuse existing attributes it is better than adding new ones so my 
preference would be to make `restrict` work unless it's absolutely impossible 
for the use case you consider.


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

https://reviews.llvm.org/D75285



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


[PATCH] D72860: [modules] Do not cache invalid state for modules that we attempted to load.

2020-03-04 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/lib/Serialization/ModuleManager.cpp:183
   // Get a buffer of the file and close the file descriptor when done.
-  Buf = FileMgr.getBufferForFile(NewModule->File, /*isVolatile=*/false);
+  Buf = FileMgr.getBufferForFile(NewModule->File, /*isVolatile=*/true);
 }

rsmith wrote:
> dexonsmith wrote:
> > vsapsai wrote:
> > > Made this change because if we don't have a valid module but opened a 
> > > corresponding .pcm file earlier, there is a high chance that .pcm file 
> > > was rebuilt.
> > Please add a comment in the code explaining that.
> This change is proving really bad for us. This prevents using `mmap` for 
> loading module files, and instead forces the entire file to be loaded every 
> time. Please revert.
Can we limit the revert to explicit vs. implicit module builds?  The scenario 
Volodymyr was defending against is implicit-only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72860



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


[clang] fe61bc1 - [clang-format] Improve identification of C# nullables

2020-03-04 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-03-04T18:10:27Z
New Revision: fe61bc1a0b5a00badae9334e01e103769af4fa6c

URL: 
https://github.com/llvm/llvm-project/commit/fe61bc1a0b5a00badae9334e01e103769af4fa6c
DIFF: 
https://github.com/llvm/llvm-project/commit/fe61bc1a0b5a00badae9334e01e103769af4fa6c.diff

LOG: [clang-format] Improve identification of C# nullables

Summary: Consider `? identifier =` and `? identifier;` to be nullable within 
function bodies.

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: cfe-commits, MyDeveloperDay

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 493454eb2239..e491de85babd 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1011,7 +1011,12 @@ class AnnotatingParser {
   Style.Language == FormatStyle::LK_JavaScript)
 break;
   if (Style.isCSharp()) {
-if (Line.MustBeDeclaration && !Contexts.back().IsExpression) {
+// `Type? name;` and `Type? name =` can only be nullable types.
+// Line.MustBeDeclaration will be true for `Type? name;`.
+if (!Contexts.back().IsExpression &&
+(Line.MustBeDeclaration ||
+ (Tok->Next && Tok->Next->is(tok::identifier) && Tok->Next->Next &&
+  Tok->Next->Next->is(tok::equal {
   Tok->Type = TT_CSharpNullable;
   break;
 }

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index 3f14de9b75da..7e60fdbdba26 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -631,7 +631,17 @@ TEST_F(FormatTestCSharp, CSharpNullableTypes) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
   Style.SpacesInSquareBrackets = false;
 
+  verifyFormat(R"(//
+public class A {
+  void foo() { int? value = some.bar(); }
+})",
+   Style); // int? is nullable not a conditional expression.
+
+  verifyFormat(R"(void foo(int? x, int? y, int? z) {})",
+   Style); // Nullables in function definitions.
+
   verifyFormat(R"(public float? Value;)", Style); // no space before `?`.
+
   verifyFormat(R"(int?[] arr = new int?[10];)",
Style); // An array of a nullable type.
 }



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


[PATCH] D75606: [clang-format] Improve identification of C# nullables

2020-03-04 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe updated this revision to Diff 248232.
jbcoe marked an inline comment as done.
jbcoe added a comment.

Remove duplicate check following review comment.


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

https://reviews.llvm.org/D75606

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -631,7 +631,17 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
   Style.SpacesInSquareBrackets = false;
 
+  verifyFormat(R"(//
+public class A {
+  void foo() { int? value = some.bar(); }
+})",
+   Style); // int? is nullable not a conditional expression.
+
+  verifyFormat(R"(void foo(int? x, int? y, int? z) {})",
+   Style); // Nullables in function definitions.
+
   verifyFormat(R"(public float? Value;)", Style); // no space before `?`.
+
   verifyFormat(R"(int?[] arr = new int?[10];)",
Style); // An array of a nullable type.
 }
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1011,7 +1011,12 @@
   Style.Language == FormatStyle::LK_JavaScript)
 break;
   if (Style.isCSharp()) {
-if (Line.MustBeDeclaration && !Contexts.back().IsExpression) {
+// `Type? name;` and `Type? name =` can only be nullable types.
+// Line.MustBeDeclaration will be true for `Type? name;`.
+if (!Contexts.back().IsExpression &&
+(Line.MustBeDeclaration ||
+ (Tok->Next && Tok->Next->is(tok::identifier) && Tok->Next->Next &&
+  Tok->Next->Next->is(tok::equal {
   Tok->Type = TT_CSharpNullable;
   break;
 }


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -631,7 +631,17 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
   Style.SpacesInSquareBrackets = false;
 
+  verifyFormat(R"(//
+public class A {
+  void foo() { int? value = some.bar(); }
+})",
+   Style); // int? is nullable not a conditional expression.
+
+  verifyFormat(R"(void foo(int? x, int? y, int? z) {})",
+   Style); // Nullables in function definitions.
+
   verifyFormat(R"(public float? Value;)", Style); // no space before `?`.
+
   verifyFormat(R"(int?[] arr = new int?[10];)",
Style); // An array of a nullable type.
 }
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1011,7 +1011,12 @@
   Style.Language == FormatStyle::LK_JavaScript)
 break;
   if (Style.isCSharp()) {
-if (Line.MustBeDeclaration && !Contexts.back().IsExpression) {
+// `Type? name;` and `Type? name =` can only be nullable types.
+// Line.MustBeDeclaration will be true for `Type? name;`.
+if (!Contexts.back().IsExpression &&
+(Line.MustBeDeclaration ||
+ (Tok->Next && Tok->Next->is(tok::identifier) && Tok->Next->Next &&
+  Tok->Next->Next->is(tok::equal {
   Tok->Type = TT_CSharpNullable;
   break;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-04 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked an inline comment as done.
nickdesaulniers added inline comments.



Comment at: clang/lib/Parse/ParseStmtAsm.cpp:746-755
   ParseTypeQualifierListOpt(DS, AR_VendorAttributesParsed);
 
   // GNU asms accept, but warn, about type-qualifiers other than volatile.
   if (DS.getTypeQualifiers() & DeclSpec::TQ_const)
 Diag(Loc, diag::warn_asm_qualifier_ignored) << "const";
   if (DS.getTypeQualifiers() & DeclSpec::TQ_restrict)
 Diag(Loc, diag::warn_asm_qualifier_ignored) << "restrict";

I think in a follow up commit, I'll just delete this (the call to 
`ParseTypeQualifierListOpt` and subsequent `warn_asm_qualifier_ignored` 
emission); making it a parse error to put type qualifiers after the keyword 
`asm`, which would match the behavior of GCC, and not waste time looking for 
and parsing type qualifiers.  It maybe made sense when 
`ParseTypeQualifierListOpt` was being abused to parse `volatile`, but this 
patch fixes that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563



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


[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-04 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 248226.
nickdesaulniers marked an inline comment as done.
nickdesaulniers added a comment.

- git-clang-format HEAD~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/test/Parser/asm-qualifiers.c

Index: clang/test/Parser/asm-qualifiers.c
===
--- /dev/null
+++ clang/test/Parser/asm-qualifiers.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+
+void qualifiers(void) {
+  asm("");
+  asm volatile("");
+  asm inline("");
+  asm goto("" foo);
+foo:;
+}
+
+void underscores(void) {
+  __asm__("");
+  __asm__ __volatile__("");
+  __asm__ __inline__("");
+  // Note: goto is not supported with underscore prefix+suffix.
+  __asm__ goto("" foo);
+foo:;
+}
+
+void permutations(void) {
+  asm goto inline volatile("" foo);
+  asm goto inline("");
+  asm goto volatile inline("" foo);
+  asm goto volatile("");
+  asm inline goto volatile("" foo);
+  asm inline goto("" foo);
+  asm inline volatile goto("" foo);
+  asm inline volatile("");
+  asm volatile goto("" foo);
+  asm volatile inline goto("" foo);
+  asm volatile inline("");
+foo:;
+}
+
+void duplicates(void) {
+  asm volatile volatile(""); // expected-error {{duplicate asm qualifier volatile}}
+  __asm__ __volatile__ __volatile__(""); // expected-error {{duplicate asm qualifier volatile}}
+  asm inline inline(""); // expected-error {{duplicate asm qualifier inline}}
+  __asm__ __inline__ __inline__(""); // expected-error {{duplicate asm qualifier inline}}
+  asm goto goto("" foo); // expected-error {{duplicate asm qualifier goto}}
+  __asm__ goto goto("" foo); // expected-error {{duplicate asm qualifier goto}}
+foo:;
+}
Index: clang/lib/Sema/DeclSpec.cpp
===
--- clang/lib/Sema/DeclSpec.cpp
+++ clang/lib/Sema/DeclSpec.cpp
@@ -589,6 +589,16 @@
   llvm_unreachable("Unknown typespec!");
 }
 
+const char *DeclSpec::getSpecifierName(AQ A) {
+  switch (A) {
+case DeclSpec::AQ_unspecified: return "unspecified";
+case DeclSpec::AQ_volatile: return "volatile";
+case DeclSpec::AQ_inline: return "inline";
+case DeclSpec::AQ_goto: return "goto";
+  }
+  llvm_unreachable("Unknown GNUAsmQualifier!");
+}
+
 bool DeclSpec::SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc,
const char *&PrevSpec,
unsigned &DiagID,
@@ -938,6 +948,12 @@
   llvm_unreachable("Unknown type qualifier!");
 }
 
+bool DeclSpec::SetGNUAsmQual(AQ A, SourceLocation Loc) {
+  bool IsInvalid = GNUAsmQualifiers & A;
+  GNUAsmQualifiers |= A;
+  return IsInvalid;
+}
+
 bool DeclSpec::setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec,
  unsigned &DiagID) {
   // 'inline inline' is ok.  However, since this is likely not what the user
Index: clang/lib/Parse/ParseStmtAsm.cpp
===
--- clang/lib/Parse/ParseStmtAsm.cpp
+++ clang/lib/Parse/ParseStmtAsm.cpp
@@ -684,13 +684,41 @@
 ClobberRefs, Exprs, EndLoc);
 }
 
+/// ParseGNUAsmQualifierListOpt - Parse a GNU extended asm qualifier list.
+///   asm-qualifiers:
+/// volatile
+/// inline
+/// goto
+void Parser::ParseGNUAsmQualifierListOpt(DeclSpec &DS) {
+  SourceLocation EndLoc;
+  while (1) {
+SourceLocation Loc = Tok.getLocation();
+DeclSpec::AQ AQ = DeclSpec::AQ_unspecified;
+
+if (Tok.getKind() == tok::kw_volatile)
+  AQ = DeclSpec::AQ_volatile;
+else if (Tok.getKind() == tok::kw_inline)
+  AQ = DeclSpec::AQ_inline;
+else if (Tok.getKind() == tok::kw_goto)
+  AQ = DeclSpec::AQ_goto;
+else {
+  if (EndLoc.isValid())
+DS.SetRangeEnd(EndLoc);
+  return;
+}
+if (DS.SetGNUAsmQual(AQ, Loc))
+  Diag(Loc, diag::err_asm_duplicate_qual) << DeclSpec::getSpecifierName(AQ);
+EndLoc = ConsumeToken();
+  }
+}
+
 /// ParseAsmStatement - Parse a GNU extended asm statement.
 ///   asm-statement:
 /// gnu-asm-statement
 /// ms-asm-statement
 ///
 /// [GNU] gnu-asm-statement:
-/// 'asm' type-qualifier[opt] '(' asm-argument ')' ';'
+/// 'asm' asm-qualifier[opt] '(' asm-argument ')' ';'
 ///
 /// [GNU] asm-argument:
 /// asm-string-literal
@@ -713,6 +741,7 @@
   }
 
   DeclSpec DS(AttrFactory);
+  ParseGNUAsmQualifierListOpt(DS);
   SourceLocation Loc = Tok.getLocation();
   ParseTypeQualifierLis

[PATCH] D75572: [Sema][SVE] Reject sizeof and alignof for sizeless types

2020-03-04 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added a comment.

In D75572#1904517 , @efriedma wrote:

> I think the specialized error messages are useful.  I don't have a strong 
> opinion on what order the patches should land.


OK.  The new version keeps the tailored diagnostic but emits it from 
RequireCompleteTypeImpl instead.

> The difference between emitting the diagnostic in RequireCompleteType, vs. 
> letting the caller do it, is basically just that it's harder to forget to 
> check whether the type is sizeless.  I think that's important enough to be 
> worth complicating the API a bit; better to forbid scalable types, rather 
> than crash or miscompile later.  Probably the entry point that allows 
> sizeless types should have a different name.

Yeah, the plan is to make RequireCompleteType reject sizeless types unless the 
caller has explicitly said otherwise.  We want to do that whatever approach is 
taken for emitting the diagnostics.  However, starting off with a patch that 
makes the types incomplete and then gradually relaxing the rules would 
interfere too much with other people's work, so the idea was to do it the other 
way around.  By building the series up this way, the final patch that makes 
sizeless types incomplete ends up being much smaller (and hopefully more 
reviewable!) than D62962  was.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75572



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


[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-04 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked 4 inline comments as done.
nickdesaulniers added inline comments.



Comment at: clang/test/Parser/asm-qualifiers.c:20
+
+void combinations(void) {
+  asm volatile inline("");

nathanchance wrote:
> nickdesaulniers wrote:
> > nathanchance wrote:
> > > I'm probably being dense but what is intended to be tested differently 
> > > between `combinations` and `permutations`? I assume the order of the 
> > > qualifiers? Wouldn't it just be better to merge `combinations` into 
> > > `permutations` or was there some deeper reasoning for the 
> > > compartmentalization?
> > `combinations` tests a combination of different `asm-qualifiers` together. 
> > `permutations` are just permutations of the combinations that have not been 
> > tested above. I may not even have my nomenclature correct.  Shall I combine 
> > them?
> I assume that you want permutations since you want to make sure that the 
> ordering does not matter, right? If you just care about combinations then
> 
> ```
>   asm inline goto volatile("" foo);
>   asm inline volatile goto("" foo);
> 
>   asm goto inline volatile("" foo);
>   asm goto volatile inline("" foo);
> 
>   asm volatile goto inline("" foo); // note, this one should probably be 
> added in permutations
>   asm volatile inline goto("" foo);
> ``` 
> 
> could just be distilled down to one of those since they are the same 
> combination of qualifiers (combinations do not care about order). I would say 
> that moving `combinations` into `permutations` would be wise since 
> `permutations` tests the same thing that `combinations` does and more.
Great suggestion, done. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563



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


[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-04 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 248225.
nickdesaulniers added a comment.

- combine combinations into permutations test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/test/Parser/asm-qualifiers.c

Index: clang/test/Parser/asm-qualifiers.c
===
--- /dev/null
+++ clang/test/Parser/asm-qualifiers.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+
+void qualifiers(void) {
+  asm("");
+  asm volatile("");
+  asm inline("");
+  asm goto("" foo);
+foo:;
+}
+
+void underscores(void) {
+  __asm__("");
+  __asm__ __volatile__("");
+  __asm__ __inline__("");
+  // Note: goto is not supported with underscore prefix+suffix.
+  __asm__ goto("" foo);
+foo:;
+}
+
+void permutations(void) {
+  asm goto inline volatile("" foo);
+  asm goto inline("");
+  asm goto volatile inline("" foo);
+  asm goto volatile("");
+  asm inline goto volatile("" foo);
+  asm inline goto("" foo);
+  asm inline volatile goto("" foo);
+  asm inline volatile("");
+  asm volatile goto("" foo);
+  asm volatile inline goto("" foo);
+  asm volatile inline("");
+foo:;
+}
+
+void duplicates(void) {
+  asm volatile volatile(""); // expected-error {{duplicate asm qualifier volatile}}
+  __asm__ __volatile__ __volatile__(""); // expected-error {{duplicate asm qualifier volatile}}
+  asm inline inline(""); // expected-error {{duplicate asm qualifier inline}}
+  __asm__ __inline__ __inline__(""); // expected-error {{duplicate asm qualifier inline}}
+  asm goto goto("" foo); // expected-error {{duplicate asm qualifier goto}}
+  __asm__ goto goto("" foo); // expected-error {{duplicate asm qualifier goto}}
+foo:;
+}
Index: clang/lib/Sema/DeclSpec.cpp
===
--- clang/lib/Sema/DeclSpec.cpp
+++ clang/lib/Sema/DeclSpec.cpp
@@ -589,6 +589,16 @@
   llvm_unreachable("Unknown typespec!");
 }
 
+const char *DeclSpec::getSpecifierName(AQ A) {
+  switch (A) {
+case DeclSpec::AQ_unspecified: return "unspecified";
+case DeclSpec::AQ_volatile: return "volatile";
+case DeclSpec::AQ_inline: return "inline";
+case DeclSpec::AQ_goto: return "goto";
+  }
+  llvm_unreachable("Unknown GNUAsmQualifier!");
+}
+
 bool DeclSpec::SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc,
const char *&PrevSpec,
unsigned &DiagID,
@@ -938,6 +948,12 @@
   llvm_unreachable("Unknown type qualifier!");
 }
 
+bool DeclSpec::SetGNUAsmQual(AQ A, SourceLocation Loc) {
+  bool IsInvalid = GNUAsmQualifiers & A;
+  GNUAsmQualifiers |= A;
+  return IsInvalid;
+}
+
 bool DeclSpec::setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec,
  unsigned &DiagID) {
   // 'inline inline' is ok.  However, since this is likely not what the user
Index: clang/lib/Parse/ParseStmtAsm.cpp
===
--- clang/lib/Parse/ParseStmtAsm.cpp
+++ clang/lib/Parse/ParseStmtAsm.cpp
@@ -684,13 +684,42 @@
 ClobberRefs, Exprs, EndLoc);
 }
 
+/// ParseGNUAsmQualifierListOpt - Parse a GNU extended asm qualifier list.
+///   asm-qualifiers:
+/// volatile
+/// inline
+/// goto
+void Parser::ParseGNUAsmQualifierListOpt(DeclSpec &DS) {
+  SourceLocation EndLoc;
+  while (1) {
+SourceLocation Loc = Tok.getLocation();
+DeclSpec::AQ AQ = DeclSpec::AQ_unspecified;
+
+if (Tok.getKind() == tok::kw_volatile)
+  AQ = DeclSpec::AQ_volatile;
+else if (Tok.getKind() == tok::kw_inline)
+  AQ = DeclSpec::AQ_inline;
+else if (Tok.getKind() == tok::kw_goto)
+  AQ = DeclSpec::AQ_goto;
+else {
+  if (EndLoc.isValid())
+DS.SetRangeEnd(EndLoc);
+  return;
+}
+if (DS.SetGNUAsmQual(AQ, Loc))
+  Diag(Loc, diag::err_asm_duplicate_qual)
+  << DeclSpec::getSpecifierName(AQ);
+EndLoc = ConsumeToken();
+  }
+}
+
 /// ParseAsmStatement - Parse a GNU extended asm statement.
 ///   asm-statement:
 /// gnu-asm-statement
 /// ms-asm-statement
 ///
 /// [GNU] gnu-asm-statement:
-/// 'asm' type-qualifier[opt] '(' asm-argument ')' ';'
+/// 'asm' asm-qualifier[opt] '(' asm-argument ')' ';'
 ///
 /// [GNU] asm-argument:
 /// asm-string-literal
@@ -713,6 +742,7 @@
   }
 
   DeclSpec DS(AttrFactory);
+  ParseGNUAsmQualifierListOpt(DS);
   SourceLocation Loc = Tok.getLocation();
   ParseTypeQualifierListOpt(DS, AR_Vendor

[PATCH] D75621: [clang-tidy] Use ; as separator for HeaderFileExtensions

2020-03-04 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

The `llvm::StringRef::split` function can take multiple split characters, So it 
would be best to split on both for the time being but mark cases where `,` is 
used as deprecated. This way we keep the options in line with other clang-tidy 
checks but keep some backwards compatibility but in future change it to just 
using `;`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75621



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


[PATCH] D72860: [modules] Do not cache invalid state for modules that we attempted to load.

2020-03-04 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Serialization/ModuleManager.cpp:183
   // Get a buffer of the file and close the file descriptor when done.
-  Buf = FileMgr.getBufferForFile(NewModule->File, /*isVolatile=*/false);
+  Buf = FileMgr.getBufferForFile(NewModule->File, /*isVolatile=*/true);
 }

dexonsmith wrote:
> vsapsai wrote:
> > Made this change because if we don't have a valid module but opened a 
> > corresponding .pcm file earlier, there is a high chance that .pcm file was 
> > rebuilt.
> Please add a comment in the code explaining that.
This change is proving really bad for us. This prevents using `mmap` for 
loading module files, and instead forces the entire file to be loaded every 
time. Please revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72860



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


[PATCH] D75623: [clangd][VSCode] Force VSCode to use the ranking provided by clangd.

2020-03-04 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I tested this with an example like:

  int a_b_c;
  char *abc;
  int x = ab^ // prefer a_b_c due to type match.

before this patch, we see [abc, a_b_c]. After this patch, [a_b_c, abc].


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75623



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


[PATCH] D75181: [AArch64] Handle BTI/PAC in case of generated functions.

2020-03-04 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss updated this revision to Diff 248222.
danielkiss marked an inline comment as done.

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

https://reviews.llvm.org/D75181

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aarch64-branch-protection-attr.c
  clang/test/CodeGen/aarch64-sign-return-address.c
  clang/test/CodeGenCXX/aarch64-branch-target_clang_call_terminate.cpp
  clang/test/CodeGenCXX/aarch64-sign-return-address-static-ctor.cpp
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/lib/Target/AArch64/AArch64BranchTargets.cpp
  llvm/lib/Target/AArch64/AArch64CallLowering.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/branch-target-enforcement-indirect-calls.ll
  llvm/test/CodeGen/AArch64/branch-target-enforcement.mir
  llvm/test/CodeGen/AArch64/bti-branch-relaxation.ll
  llvm/test/CodeGen/AArch64/machine-outliner-bti.mir
  llvm/test/CodeGen/AArch64/machine-outliner-outline-bti.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-0.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-1.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-2.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-3.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-5.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-6.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-7.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-9.ll
  llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll

Index: llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
===
--- llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
+++ llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
@@ -1,6 +1,6 @@
 ; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s
 
-define void @f0() "patchable-function-entry"="0" "branch-target-enforcement" {
+define void @f0() "patchable-function-entry"="0" "branch-target-enforcement"="true" {
 ; CHECK-LABEL: f0:
 ; CHECK-NEXT: .Lfunc_begin0:
 ; CHECK:  // %bb.0:
@@ -12,7 +12,7 @@
 
 ;; -fpatchable-function-entry=1 -mbranch-protection=bti
 ;; For M=0, place the label .Lpatch0 after the initial BTI.
-define void @f1() "patchable-function-entry"="1" "branch-target-enforcement" {
+define void @f1() "patchable-function-entry"="1" "branch-target-enforcement"="true" {
 ; CHECK-LABEL: f1:
 ; CHECK-NEXT: .Lfunc_begin1:
 ; CHECK-NEXT: .cfi_startproc
@@ -28,7 +28,7 @@
 }
 
 ;; -fpatchable-function-entry=2,1 -mbranch-protection=bti
-define void @f2_1() "patchable-function-entry"="1" "patchable-function-prefix"="1" "branch-target-enforcement" {
+define void @f2_1() "patchable-function-entry"="1" "patchable-function-prefix"="1" "branch-target-enforcement"="true" {
 ; CHECK-LABEL: .type f2_1,@function
 ; CHECK-NEXT: .Ltmp0:
 ; CHECK-NEXT:  nop
@@ -50,7 +50,7 @@
 ;; -fpatchable-function-entry=1 -mbranch-protection=bti
 ;; For M=0, don't create .Lpatch0 if the initial instruction is not BTI,
 ;; even if other basic blocks may have BTI.
-define internal void @f1i(i64 %v) "patchable-function-entry"="1" "branch-target-enforcement" {
+define internal void @f1i(i64 %v) "patchable-function-entry"="1" "branch-target-enforcement"="true" {
 ; CHECK-LABEL: f1i:
 ; CHECK-NEXT: .Lfunc_begin3:
 ; CHECK:  // %bb.0:
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-9.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-9.ll
@@ -0,0 +1,27 @@
+; RUN: llc -mtriple=aarch64-linux %s   -o - | \
+; RUN:   FileCheck %s --check-prefix=ASM
+; RUN: llc -mtriple=aarch64-linux %s -filetype=obj -o - | \
+; RUN:   llvm-readelf --notes | FileCheck %s --check-prefix=OBJ
+
+define dso_local i32 @f() #0 {
+entry:
+  ret i32 0
+}
+
+define dso_local i32 @g() {
+entry:
+  ret i32 0
+}
+
+attributes #0 = { "branch-target-enforcement"="true" }
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 4, !"branch-target-enforcement", i32 1}
+
+; Only the common atttribute (BTI)
+; ASM:	.word	3221225472
+; ASM-NEXT:	.word	4
+; ASM-NEXT	.word	1
+
+; OBJ: Properties: aarch64 feature: BTI
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
===
--- llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
+++ llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
@@ -11,7 +11,11 @@
 
 declare dso_local i32 @g()
 
-attributes #0 = { "branch-target-enforcement" }
+attributes #0 = { "branch-target-enforcement"="true" }
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 4, !"branch-target-enforcement", i32 1}
 
 ; Declarations don't prevent setting BTI
 ; ASM:	  

[PATCH] D75623: [clangd][VSCode] Force VSCode to use the ranking provided by clangd.

2020-03-04 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.
sammccall added a comment.

I tested this with an example like:

  int a_b_c;
  char *abc;
  int x = ab^ // prefer a_b_c due to type match.

before this patch, we see [abc, a_b_c]. After this patch, [a_b_c, abc].


Clangd's approach is to provide lots of completions, and let ranking sort them
out. This relies on various important signals (Quality.h), without which the
large completion lists are extremely spammy.

Even with a completion result exactly at the cursor, vscode looks backwards and
tries to match the presumed partial-identifier against filterText, and uses
the result to rank, with sortText only used as a tiebreak.
By prepending the partial-identifier to the filterText, we can force the match
to be perfect and so give sortText full control of the ranking.

It's possible to do this on the server side too of course, and switch it on
with an initialization option. But it's a little easier in the extension, it
will get the fix to users of old clangd versions, and other editors


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75623

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -98,7 +98,32 @@
 },
 initializationOptions: { clangdFileStatus: true },
 // Do not switch to output window when clangd returns output
-revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never
+revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never,
+
+// We hack up the completion items a bit to prevent VSCode from 
re-ranking them
+// and throwing away all our delicious signals like type information.
+//
+// VSCode sorts by (fuzzymatch(prefix, item.filterText), item.sortText)
+// By adding the prefix to the beginning of the filterText, we get a 
perfect
+// fuzzymatch score for every item.
+// The sortText (which reflects clangd ranking) breaks the tie.
+//
+// We also have to mark the list as incomplete to force retrieving new 
rankings.
+// See https://github.com/microsoft/language-server-protocol/issues/898
+middleware: {
+  provideCompletionItem: async (document, position, context, token, 
next) => {
+// Get the incomplete identifier before the cursor.
+let word = document.getWordRangeAtPosition(position);
+let prefix = document.getText(new vscode.Range(word.start, 
position));
+
+let list = await next(document, position, context, token);
+let items = (Array.isArray(list) ? list : list.items).map(item => {
+  item.filterText = prefix + "_" + item.filterText;
+  return item;
+})
+return new vscode.CompletionList(items, true);
+  }
+},
 };
 
   const clangdClient = new ClangdLanguageClient('Clang Language Server',


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -98,7 +98,32 @@
 },
 initializationOptions: { clangdFileStatus: true },
 // Do not switch to output window when clangd returns output
-revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never
+revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never,
+
+// We hack up the completion items a bit to prevent VSCode from re-ranking them
+// and throwing away all our delicious signals like type information.
+//
+// VSCode sorts by (fuzzymatch(prefix, item.filterText), item.sortText)
+// By adding the prefix to the beginning of the filterText, we get a perfect
+// fuzzymatch score for every item.
+// The sortText (which reflects clangd ranking) breaks the tie.
+//
+// We also have to mark the list as incomplete to force retrieving new rankings.
+// See https://github.com/microsoft/language-server-protocol/issues/898
+middleware: {
+  provideCompletionItem: async (document, position, context, token, next) => {
+// Get the incomplete identifier before the cursor.
+let word = document.getWordRangeAtPosition(position);
+let prefix = document.getText(new vscode.Range(word.start, position));
+
+let list = await next(document, position, context, token);
+  

[PATCH] D75538: [clang-tidy] Updated language supported restrictions on some checks

2020-03-04 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-nullptr-basic.cpp:1
-// RUN: %check_clang_tidy -std=c++98 %s modernize-use-nullptr %t -- -- 
-Wno-non-literal-null-conversion
-//

alexfh wrote:
> gribozavr2 wrote:
> > njames93 wrote:
> > > alexfh wrote:
> > > > IIRC, some of the modernize- checks were meant to be useful to make the 
> > > > pre-C++11 code compile in C++11. This check is an example of this 
> > > > (maybe the only one?). Limiting the check to C++11 and deleting this 
> > > > test is a bit too radical.
> > > I'm lost, this check is all about replacing assignment of pointer to 0 
> > > with `nullptr` a keyword which doesn't exist pre c++11, so this test case 
> > > will just result in invalid code. Or am I missing the point?
> > The idea, if I understand correctly, is that you start with C++98 code, 
> > apply modernize-* checks, and get C++11 code.
> Yep, at least for this particular check there are cases, which won't compile 
> in C++11, but will compile after its fixes are applied. Not sure if this was 
> ever used like this though.
My understanding of the modernize module was its designed to convert the old 
c++98/03 code to use newer (safer) c++ constructs. Its purpose isn't to fix 
compiler errors in c++11 mode that compile OK in c++98 mode


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75538



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


[PATCH] D75572: [Sema][SVE] Reject sizeof and alignof for sizeless types

2020-03-04 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm updated this revision to Diff 248215.
rsandifo-arm added a comment.

Changes in v2:

- Emit the diagnostic from RequireCompleteTypeImpl instead of checking for 
sizeless types separately.  This implements option 3. from the earlier 
discussion.

- Reformat the patch using git-clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75572

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/aarch64-sve-types.c
  clang/test/Sema/sizeless-1.c
  clang/test/SemaCXX/sizeless-1.cpp

Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -21,6 +21,20 @@
 typedef svint8_t int8_typedef;
 typedef svint8_t *int8_ptr_typedef;
 
+int sizeof_int8 = sizeof(svint8_t); // expected-error {{invalid application of 'sizeof' to sizeless type 'svint8_t'}}
+int sizeof_int8_var = sizeof(*extern_int8_ptr); // expected-error {{invalid application of 'sizeof' to sizeless type 'svint8_t'}}
+int sizeof_int8_var_ptr = sizeof(extern_int8_ptr);
+
+#if __cplusplus >= 201103L
+int alignof_int8 = alignof(svint8_t);// expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
+int alignof_int8_var = alignof(*extern_int8_ptr);// expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}} expected-warning {{GNU extension}}
+int alignof_int8_var_ptr = alignof(extern_int8_ptr); // expected-warning {{GNU extension}}
+#else
+int alignof_int8 = _Alignof(svint8_t);// expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
+int alignof_int8_var = _Alignof(*extern_int8_ptr);// expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}} expected-warning {{GNU extension}}
+int alignof_int8_var_ptr = _Alignof(extern_int8_ptr); // expected-warning {{GNU extension}}
+#endif
+
 void pass_int8(svint8_t); // expected-note {{no known conversion}}
 
 svint8_t return_int8();
@@ -51,6 +65,8 @@
   svint8_t local_int8;
   svint16_t local_int16;
 
+  int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
+
   // Using pointers to sizeless data isn't wrong here, but because the
   // type is incomplete, it doesn't provide any alignment guarantees.
   _Static_assert(__atomic_is_lock_free(1, &local_int8) == __atomic_is_lock_free(1, incomplete_ptr), "");
Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -15,6 +15,14 @@
 typedef svint8_t int8_typedef;
 typedef svint8_t *int8_ptr_typedef;
 
+int sizeof_int8 = sizeof(svint8_t); // expected-error {{invalid application of 'sizeof' to sizeless type 'svint8_t'}}
+int sizeof_int8_var = sizeof(*extern_int8_ptr); // expected-error {{invalid application of 'sizeof' to sizeless type 'svint8_t'}}
+int sizeof_int8_var_ptr = sizeof(extern_int8_ptr);
+
+int alignof_int8 = _Alignof(svint8_t);// expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
+int alignof_int8_var = _Alignof(*extern_int8_ptr);// expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}} expected-warning {{GNU extension}}
+int alignof_int8_var_ptr = _Alignof(extern_int8_ptr); // expected-warning {{GNU extension}}
+
 void pass_int8(svint8_t); // expected-note {{passing argument to parameter here}}
 
 svint8_t return_int8();
@@ -46,6 +54,8 @@
   svint8_t local_int8;
   svint16_t local_int16;
 
+  int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
+
   // Using pointers to sizeless data isn't wrong here, but because the
   // type is incomplete, it doesn't provide any alignment guarantees.
   _Static_assert(__atomic_is_lock_free(1, &local_int8) == __atomic_is_lock_free(1, incomplete_ptr), "");
Index: clang/test/Sema/aarch64-sve-types.c
===
--- clang/test/Sema/aarch64-sve-types.c
+++ clang/test/Sema/aarch64-sve-types.c
@@ -1,52 +1,39 @@
 // RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve -fsyntax-only -verify
 
-// This test is invalid under the sizeless type extension and is a stop-gap
-// until that extension is added.  The test makes sure that sizeof and
-// alignof queries are handled without assertion failures, since at
-// present there is nothing to prevent such queries being made.
-//
-// Under this scheme, sizeof returns 0 for all built-in sizeless types.
-// This is compatible with correct usage but it relies on the user being
-// careful to avoid constructs that depe

[PATCH] D75621: [clang-tidy] Use ; as separator for HeaderFileExtensions

2020-03-04 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri requested changes to this revision.
lebedev.ri added a comment.
This revision now requires changes to proceed.

This will break existing `.clang-tidy` configs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75621



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


[PATCH] D75181: [AArch64] Handle BTI/PAC in case of generated functions.

2020-03-04 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss updated this revision to Diff 248201.
danielkiss added a comment.

Thanks for the comments, patch is improved
isStringAttribute() check removed, the attribute is always a string in this 
case or "null" so the check is not needed.
Function level the attribute is now only change when needed, so as the function 
level attribute is expected to be rare I hope the performance won't be impacted 
by the patch.
I kept the "tri-state" logic because of the emitted functions. Introducing a 
"branch-target-enforcement-disabled" attribute seems even more confusing for me.


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

https://reviews.llvm.org/D75181

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aarch64-branch-protection-attr.c
  clang/test/CodeGen/aarch64-sign-return-address.c
  clang/test/CodeGenCXX/aarch64-branch-target_clang_call_terminate.cpp
  clang/test/CodeGenCXX/aarch64-sign-return-address-static-ctor.cpp
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/lib/Target/AArch64/AArch64BranchTargets.cpp
  llvm/lib/Target/AArch64/AArch64CallLowering.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/branch-target-enforcement-indirect-calls.ll
  llvm/test/CodeGen/AArch64/branch-target-enforcement.mir
  llvm/test/CodeGen/AArch64/bti-branch-relaxation.ll
  llvm/test/CodeGen/AArch64/machine-outliner-bti.mir
  llvm/test/CodeGen/AArch64/machine-outliner-outline-bti.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-0.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-1.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-2.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-3.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-5.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-6.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-7.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-9.ll
  llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll

Index: llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
===
--- llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
+++ llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
@@ -1,6 +1,6 @@
 ; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s
 
-define void @f0() "patchable-function-entry"="0" "branch-target-enforcement" {
+define void @f0() "patchable-function-entry"="0" "branch-target-enforcement"="true" {
 ; CHECK-LABEL: f0:
 ; CHECK-NEXT: .Lfunc_begin0:
 ; CHECK:  // %bb.0:
@@ -12,7 +12,7 @@
 
 ;; -fpatchable-function-entry=1 -mbranch-protection=bti
 ;; For M=0, place the label .Lpatch0 after the initial BTI.
-define void @f1() "patchable-function-entry"="1" "branch-target-enforcement" {
+define void @f1() "patchable-function-entry"="1" "branch-target-enforcement"="true" {
 ; CHECK-LABEL: f1:
 ; CHECK-NEXT: .Lfunc_begin1:
 ; CHECK-NEXT: .cfi_startproc
@@ -28,7 +28,7 @@
 }
 
 ;; -fpatchable-function-entry=2,1 -mbranch-protection=bti
-define void @f2_1() "patchable-function-entry"="1" "patchable-function-prefix"="1" "branch-target-enforcement" {
+define void @f2_1() "patchable-function-entry"="1" "patchable-function-prefix"="1" "branch-target-enforcement"="true" {
 ; CHECK-LABEL: .type f2_1,@function
 ; CHECK-NEXT: .Ltmp0:
 ; CHECK-NEXT:  nop
@@ -50,7 +50,7 @@
 ;; -fpatchable-function-entry=1 -mbranch-protection=bti
 ;; For M=0, don't create .Lpatch0 if the initial instruction is not BTI,
 ;; even if other basic blocks may have BTI.
-define internal void @f1i(i64 %v) "patchable-function-entry"="1" "branch-target-enforcement" {
+define internal void @f1i(i64 %v) "patchable-function-entry"="1" "branch-target-enforcement"="true" {
 ; CHECK-LABEL: f1i:
 ; CHECK-NEXT: .Lfunc_begin3:
 ; CHECK:  // %bb.0:
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-9.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-9.ll
@@ -0,0 +1,27 @@
+; RUN: llc -mtriple=aarch64-linux %s   -o - | \
+; RUN:   FileCheck %s --check-prefix=ASM
+; RUN: llc -mtriple=aarch64-linux %s -filetype=obj -o - | \
+; RUN:   llvm-readelf --notes | FileCheck %s --check-prefix=OBJ
+
+define dso_local i32 @f() #0 {
+entry:
+  ret i32 0
+}
+
+define dso_local i32 @g() {
+entry:
+  ret i32 0
+}
+
+attributes #0 = { "branch-target-enforcement"="true" }
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 4, !"branch-target-enforcement", i32 1}
+
+; Only the common atttribute (BTI)
+; ASM:	.word	3221225472
+; ASM-NEXT:	.word	4
+; ASM-NEXT	.word	1
+
+; OBJ: Properties: aarch64 feature: BTI
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
=

[PATCH] D75181: [AArch64] Handle BTI/PAC in case of generated functions.

2020-03-04 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss marked 4 inline comments as done.
danielkiss added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:1828
+  if (CodeGenOpts.BranchTargetEnforcement) {
+FuncAttrs.addAttribute("branch-target-enforcement", "true");
+  }

chill wrote:
> I would really prefer to not set values "true" or "false" for the attribute: 
> we don't really have tri-state logic there 
> (absent/present-true/present-false), and those values just add some not-very 
> useful string processing.
> 
the attribute will be  "absent" for the runtime emitted function.



Comment at: clang/lib/CodeGen/CGCall.cpp:1831
+
+  auto RASignKind = CodeGenOpts.getSignReturnAddress();
+  if (RASignKind != CodeGenOptions::SignReturnAddressScope::None) {

chill wrote:
> What do we get from setting the PACBTI state in the  default function 
> attributes? We still have 
> to do a per function processing, we can just as well avoid repeating the 
> logic, and spare us some
> adding and potentially removing attributes churn.
> 
in the new patch the per function processing will change the attribute only if 
really need.



Comment at: llvm/lib/Target/AArch64/AArch64BranchTargets.cpp:62
+
+  // LLVM emmited function won't have the attribute.
+  if (!F.hasFnAttribute("branch-target-enforcement")) {

emmited -> emitted


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

https://reviews.llvm.org/D75181



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


  1   2   >