[PATCH] D73891: [RISCV] Support experimental/unratified extensions

2020-02-04 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:50
 
+static bool isExperimentalExtension(StringRef Ext) {
+  // Currently 'b' is the only supported experimental extension

Suggestion: I think we can avoid these two functions (`isExperimentalExtension` 
and `getExperimentalExtensionVersion`) going out of sync if we have only one of 
them and make it return an `llvm::Optional` of the pair of versions.

Thent it can be used like this

```lang=cpp
if (auto ExperimentalExtension = isExperimentalExtension(Ext)) {
   std::pair SupportedVers = *ExperimentalVersion;
   ...
}
```

I'd also add a comment that the pair's `first` is the major version and 
`second` is the minor version (or alternative use a struct with two public 
fields `Major` and `Minor`)



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:396
+  I += Minor.size() + 1 /*'p'*/;
+if (*I == '_')
+  ++I;

There is no test for that case but I'm afraid we can't test it yet, can we?


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

https://reviews.llvm.org/D73891



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


[PATCH] D73937: [Driver] Change -fmax-tokens $arg to -fmax-tokens=$arg

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

Thank for noticing!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73937



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


[PATCH] D72222: [Driver][CodeGen] Add -fpatchable-function-entry=N[,0]

2020-02-04 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D7#1849326 , @hans wrote:

> > I created D73680  to place the patch label 
> > after BTI.
> > 
> > @hans Is there still time to cherry pick the patch to release/10.x? See 
> > above, Linux developers really want the Clang release to have compatible 
> > behavior with GCC.
>
> Yes, there is still time. Just let me know which commits to cherry-pick.


Just to follow up: D73680  was cherry-picked 
to 10.x. Does that mean all issues are resolved here, and the kernel folks are 
happy, or is there more work expected that might affect the release?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D7



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


[PATCH] D73891: [RISCV] Support experimental/unratified extensions

2020-02-04 Thread Simon Cook via Phabricator via cfe-commits
simoncook marked 2 inline comments as done.
simoncook added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:50
 
+static bool isExperimentalExtension(StringRef Ext) {
+  // Currently 'b' is the only supported experimental extension

rogfer01 wrote:
> Suggestion: I think we can avoid these two functions 
> (`isExperimentalExtension` and `getExperimentalExtensionVersion`) going out 
> of sync if we have only one of them and make it return an `llvm::Optional` of 
> the pair of versions.
> 
> Thent it can be used like this
> 
> ```lang=cpp
> if (auto ExperimentalExtension = isExperimentalExtension(Ext)) {
>std::pair SupportedVers = *ExperimentalVersion;
>...
> }
> ```
> 
> I'd also add a comment that the pair's `first` is the major version and 
> `second` is the minor version (or alternative use a struct with two public 
> fields `Major` and `Minor`)
That's a good idea, I'll update this to use this pattern.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:396
+  I += Minor.size() + 1 /*'p'*/;
+if (*I == '_')
+  ++I;

rogfer01 wrote:
> There is no test for that case but I'm afraid we can't test it yet, can we?
We can test for e.g. `rv32i_m` which is now accepted (GCC also accepts this 
option we didn't before), but the version number code I don't think there is 
until we support versions on more than one extension.


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

https://reviews.llvm.org/D73891



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


[clang] 89b8b42 - [OpenCL] Tidy up OpenCLBuiltins.td

2020-02-04 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-02-04T10:56:53Z
New Revision: 89b8b42184745ee31992275194b925b1b1e3d5b6

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

LOG: [OpenCL] Tidy up OpenCLBuiltins.td

Align `Type` names to their actual OpenCL C type names, such that we
can print OpenCL C types from TableGen.  This is particularly helpful
for completeness comparisons with `opencl-c.h`.

Drop the "Name" field from `TypeList`, as it is unused.

Minor formatting changes.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 9d6bb411eff8..0cbdc05700e9 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -120,7 +120,7 @@ class VectorType : Type<_Ty.Name, 
_Ty.QTName> {
 
 // OpenCL pointer types (e.g. int*, float*, ...).
 class PointerType :
-  Type<_Ty.Name, _Ty.QTName> {
+Type<_Ty.Name, _Ty.QTName> {
   let AddrSpace = _AS.Name;
   // Inherited fields
   let VecWidth = _Ty.VecWidth;
@@ -154,7 +154,7 @@ class VolatileType : Type<_Ty.Name, _Ty.QTName> {
 
 // OpenCL image types (e.g. image2d).
 class ImageType :
-  Type<_Ty.Name, QualType<_Ty.QTName.Name#_AccessQualifier#"Ty", 0>> {
+Type<_Ty.Name, QualType<_Ty.QTName.Name#_AccessQualifier#"Ty", 0>> {
   let VecWidth = 0;
   let AccessQualifier = _AccessQualifier;
   // Inherited fields
@@ -165,8 +165,7 @@ class ImageType :
 }
 
 // List of Types.
-class TypeList _Type> {
-  string Name = _Name;
+class TypeList _Type> {
   list List = _Type;
 }
 
@@ -195,7 +194,7 @@ class TypeList _Type> {
 //  A declaration f(GenT, SGenT) results in the combinations
 //f(half, half), f(half2, half), f(int, int), f(int2, int) .
 class GenericType :
-Type<_Ty, QualType<"null", 1>> {
+Type<_Ty, QualType<"null", 1>> {
   // Possible element types of the generic type.
   TypeList TypeList = _TypeList;
   // Possible vector sizes of the types in the TypeList.
@@ -260,7 +259,7 @@ def Size  : Type<"size_t",
QualType<"getSizeType()">>;
 def PtrDiff   : Type<"ptr
diff _t", QualType<"getPointerDiffType()">>;
 def IntPtr: Type<"intptr_t",  QualType<"getIntPtrType()">>;
 def UIntPtr   : Type<"uintPtr_t", QualType<"getUIntPtrType()">>;
-def Void  : Type<"void_t",QualType<"VoidTy">>;
+def Void  : Type<"void",  QualType<"VoidTy">>;
 
 // OpenCL v1.0/1.2/2.0 s6.1.2: Built-in Vector Data Types.
 // Built-in vector data types are created by TableGen's OpenCLBuiltinEmitter.
@@ -268,21 +267,21 @@ def Void  : Type<"void_t",QualType<"VoidTy">>;
 // OpenCL v1.0/1.2/2.0 s6.1.3: Other Built-in Data Types.
 // The image definitions are "abstract".  They should not be used without
 // specifying an access qualifier (RO/WO/RW).
-def Image1d   : Type<"Image1d", QualType<"OCLImage1d", 1>>;
-def Image2d   : Type<"Image2d", QualType<"OCLImage2d", 1>>;
-def Image3d   : Type<"Image3d", QualType<"OCLImage3d", 1>>;
-def Image1dArray  : Type<"Image1dArray", QualType<"OCLImage1dArray", 
1>>;
-def Image1dBuffer : Type<"Image1dBuffer", QualType<"OCLImage1dBuffer", 
1>>;
-def Image2dArray  : Type<"Image2dArray", QualType<"OCLImage2dArray", 
1>>;
-def Image2dDepth  : Type<"Image2dDepth", QualType<"OCLImage2dDepth", 
1>>;
-def Image2dArrayDepth : Type<"Image2dArrayDepth", 
QualType<"OCLImage2dArrayDepth", 1>>;
-def Image2dMsaa   : Type<"Image2dMsaa", QualType<"OCLImage2dMSAA", 1>>;
-def Image2dArrayMsaa  : Type<"Image2dArrayMsaa", 
QualType<"OCLImage2dArrayMSAA", 1>>;
-def Image2dMsaaDepth  : Type<"Image2dMsaaDepth", 
QualType<"OCLImage2dMSAADepth", 1>>;
-def Image2dArrayMsaaDepth : Type<"Image2dArrayMsaaDepth", 
QualType<"OCLImage2dArrayMSAADepth", 1>>;
-
-def Sampler   : Type<"Sampler", QualType<"OCLSamplerTy">>;
-def Event : Type<"Event", QualType<"OCLEventTy">>;
+def Image1d   : Type<"image1d_t", QualType<"OCLImage1d", 1>>;
+def Image2d   : Type<"image2d_t", QualType<"OCLImage2d", 1>>;
+def Image3d   : Type<"image3d_t", QualType<"OCLImage3d", 1>>;
+def Image1dArray  : Type<"image1d_array_t", 
QualType<"OCLImage1dArray", 1>>;
+def Image1dBuffer : Type<"image1d_buffer_t", 
QualType<"OCLImage1dBuffer", 1>>;
+def Image2dArray  : Type<"image2d_array_t", 
QualType<"OCLImage2dArray", 1>>;
+def Image2dDepth  : Type<"image2d_depth_t", 
QualType<"OCLImage2dDepth", 1>>;
+def Image2dArrayDepth : Type<"image2d_array_depth_t", 
QualType<"OCLImage2dArrayDepth", 1>>;
+def Image2dMsaa   : Type<"image2d_msaa_t", QualType<"OCLImage2dMSAA", 

[PATCH] D73651: [OpenCL][CUDA][HIP][SYCL] Add norecurse

2020-02-04 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:914
+  //
+  // OpenCL C++ 1.0 v2.1-11 s2.9:
+  // recursive function calls (ISO C++ Section 5.2.2, item 9) unless

Can we remove reference to OpenCL C++ since it's not implemented. Feel free to 
add C++ for OpenCL instead. The comment explanation still makes sense. You can 
just remove references to docs.


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

https://reviews.llvm.org/D73651



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


[PATCH] D73906: [ARM] Make ARM::ArchExtKind use 64-bit underlying type, NFCI

2020-02-04 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki updated this revision to Diff 242277.
miyuki added a comment.

More missing unsigned->uint64_t changes, removed a redundant `getAEKID` 
function (identical to `parseArchExt`).


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

https://reviews.llvm.org/D73906

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  llvm/include/llvm/Support/ARMTargetParser.h
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -32,14 +32,14 @@
 };
 
 bool testARMCPU(StringRef CPUName, StringRef ExpectedArch,
-StringRef ExpectedFPU, unsigned ExpectedFlags,
+StringRef ExpectedFPU, uint64_t ExpectedFlags,
 StringRef CPUAttr) {
   ARM::ArchKind AK = ARM::parseCPUArch(CPUName);
   bool pass = ARM::getArchName(AK).equals(ExpectedArch);
   unsigned FPUKind = ARM::getDefaultFPU(CPUName, AK);
   pass &= ARM::getFPUName(FPUKind).equals(ExpectedFPU);
 
-  unsigned ExtKind = ARM::getDefaultExtensions(CPUName, AK);
+  uint64_t ExtKind = ARM::getDefaultExtensions(CPUName, AK);
   if (ExtKind > 1 && (ExtKind & ARM::AEK_NONE))
 pass &= ((ExtKind ^ ARM::AEK_NONE) == ExpectedFlags);
   else
@@ -565,7 +565,7 @@
 }
 
 TEST(TargetParserTest, ARMExtensionFeatures) {
-  std::map> Extensions;
+  std::map> Extensions;
 
   for (auto &Ext : ARM::ARCHExtNames) {
 if (Ext.Feature && Ext.NegFeature)
Index: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===
--- llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -11726,7 +11726,7 @@
   // when we start to table-generate them, and we can use the ARM
   // flags below, that were generated by table-gen.
   static const struct {
-const unsigned Kind;
+const uint64_t Kind;
 const FeatureBitset ArchCheck;
 const FeatureBitset Features;
   } Extensions[] = {
@@ -11775,7 +11775,7 @@
 EnableFeature = false;
 Name = Name.substr(2);
   }
-  unsigned FeatureKind = ARM::parseArchExt(Name);
+  uint64_t FeatureKind = ARM::parseArchExt(Name);
   if (FeatureKind == ARM::AEK_INVALID)
 return Error(ExtLoc, "unknown architectural extension: " + Name);
 
Index: llvm/lib/Support/ARMTargetParser.cpp
===
--- llvm/lib/Support/ARMTargetParser.cpp
+++ llvm/lib/Support/ARMTargetParser.cpp
@@ -367,11 +367,11 @@
.Default(ARM::FK_INVALID);
 }
 
-unsigned ARM::getDefaultExtensions(StringRef CPU, ARM::ArchKind AK) {
+uint64_t ARM::getDefaultExtensions(StringRef CPU, ARM::ArchKind AK) {
   if (CPU == "generic")
 return ARM::ARCHNames[static_cast(AK)].ArchBaseExtensions;
 
-  return StringSwitch(CPU)
+  return StringSwitch(CPU)
 #define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT)   \
   .Case(NAME,  \
 ARCHNames[static_cast(ArchKind::ID)].ArchBaseExtensions |\
@@ -380,7 +380,7 @@
   .Default(ARM::AEK_INVALID);
 }
 
-bool ARM::getHWDivFeatures(unsigned HWDivKind,
+bool ARM::getHWDivFeatures(uint64_t HWDivKind,
std::vector &Features) {
 
   if (HWDivKind == AEK_INVALID)
@@ -399,7 +399,7 @@
   return true;
 }
 
-bool ARM::getExtensionFeatures(unsigned Extensions,
+bool ARM::getExtensionFeatures(uint64_t Extensions,
std::vector &Features) {
 
   if (Extensions == AEK_INVALID)
@@ -431,7 +431,7 @@
   return ARCHNames[static_cast(AK)].ArchAttr;
 }
 
-StringRef ARM::getArchExtName(unsigned ArchExtKind) {
+StringRef ARM::getArchExtName(uint64_t ArchExtKind) {
   for (const auto AE : ARCHExtNames) {
 if (ArchExtKind == AE.ID)
   return AE.getName();
@@ -486,20 +486,13 @@
   return ARM::FK_INVALID;
 }
 
-static unsigned getAEKID(StringRef ArchExtName) {
-  for (const auto AE : ARM::ARCHExtNames)
-if (AE.getName() == ArchExtName)
-  return AE.ID;
-  return ARM::AEK_INVALID;
-}
-
 bool ARM::appendArchExtFeatures(
   StringRef CPU, ARM::ArchKind AK, StringRef ArchExt,
   std::vector &Features) {
 
   size_t StartingNumFeatures = Features.size();
   const bool Negated = stripNegationPrefix(ArchExt);
-  unsigned ID = getAEKID(ArchExt);
+  uint64_t ID = parseArchExt(ArchExt);
 
   if (ID == AEK_INVALID)
 return false;
@@ -532,7 +525,7 @@
   return StartingNumFeatures != Features.size();
 }
 
-StringRef ARM::getHWDivName(unsigned HWDivKind) {
+StringRef ARM::getHWDivName(uint64_t HWDivKind) {
   for (const auto D : HWDivNames) {
 if (HWDivKind == D.ID)
   return D.getName();
@@ -555,7 +548,7 @@
   return "generic";
 }
 
-unsigned ARM::parseHWDiv(StringRef HWD

[PATCH] D73360: [OpenCL] Restrict address space conversions in nested pointers

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

In D73360#1852147 , @rjmccall wrote:

> If it's reasonable to persist the failure kind, that would probably be good, 
> but it might be a lot of work.


I have looked at it earlier and it indeed affects a lot of Sema in C++ mode. 
Besides amount of work I am not sure I understand the flow enough to come up 
with a good approach.

Maybe we can finalize this review first to fix the regression. Because I would 
like it to be ported to the release 10 branch too. Then I can spend some time 
to see if I can come up with something better for the diagnostic too. :)


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

https://reviews.llvm.org/D73360



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


[PATCH] D73354: clang-format: insert trailing commas into containers.

2020-02-04 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D73354#1854115 , @mprobst wrote:

> This has landed as https://reviews.llvm.org/rGa324fcf1ae6 (not sure why this 
> hasn't closed automatically).


Thank you,

as for not autoclosing my guess it because perhaps you dropped the 
"Differential Revision" line from the commit message. I know there was some 
discussion about people not keeping all the Phabricator tags (Subscribers 
etc..), but I think if the commit message doesn't have the Differential 
Revision you won't get the AutoClose behaviour


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73354



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


[PATCH] D73906: [ARM] Make ARM::ArchExtKind use 64-bit underlying type, NFCI

2020-02-04 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

Thanks. LGTM.


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

https://reviews.llvm.org/D73906



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


[clang] 7128aac - [ARM] Make ARM::ArchExtKind use 64-bit underlying type, NFCI

2020-02-04 Thread Mikhail Maltsev via cfe-commits

Author: Mikhail Maltsev
Date: 2020-02-04T11:24:18Z
New Revision: 7128aace600f29c81f735c3b1d3f5f51464c4630

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

LOG: [ARM] Make ARM::ArchExtKind use 64-bit underlying type, NFCI

Summary:
This patch changes the underlying type of the ARM::ArchExtKind
enumeration to uint64_t and adjusts the related code.

The goal of the patch is to prepare the code base for a new
architecture extension.

Reviewers: simon_tatham, eli.friedman, ostannard, dmgreen

Reviewed By: dmgreen

Subscribers: merge_guards_bot, kristof.beyls, hiraditya, cfe-commits, 
llvm-commits, pbarrio

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/lib/Basic/Targets/ARM.cpp
clang/lib/Driver/ToolChains/Arch/ARM.cpp
llvm/include/llvm/Support/ARMTargetParser.h
llvm/lib/Support/ARMTargetParser.cpp
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index c51a18216b83..c6f661fdec99 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -372,7 +372,7 @@ bool ARMTargetInfo::initFeatureMap(
   llvm::ARM::getFPUFeatures(FPUKind, TargetFeatures);
 
   // get default Extension features
-  unsigned Extensions = llvm::ARM::getDefaultExtensions(CPU, Arch);
+  uint64_t Extensions = llvm::ARM::getDefaultExtensions(CPU, Arch);
   llvm::ARM::getExtensionFeatures(Extensions, TargetFeatures);
 
   for (auto Feature : TargetFeatures)

diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index e7133607aedb..ce3990038a4b 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -57,7 +57,7 @@ void arm::getARMArchCPUFromArgs(const ArgList &Args, 
llvm::StringRef &Arch,
 static void getARMHWDivFeatures(const Driver &D, const Arg *A,
 const ArgList &Args, StringRef HWDiv,
 std::vector &Features) {
-  unsigned HWDivID = llvm::ARM::parseHWDiv(HWDiv);
+  uint64_t HWDivID = llvm::ARM::parseHWDiv(HWDiv);
   if (!llvm::ARM::getHWDivFeatures(HWDivID, Features))
 D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
 }
@@ -91,7 +91,7 @@ static void DecodeARMFeaturesFromCPU(const Driver &D, 
StringRef CPU,
   CPU = CPU.split("+").first;
   if (CPU != "generic") {
 llvm::ARM::ArchKind ArchKind = llvm::ARM::parseCPUArch(CPU);
-unsigned Extension = llvm::ARM::getDefaultExtensions(CPU, ArchKind);
+uint64_t Extension = llvm::ARM::getDefaultExtensions(CPU, ArchKind);
 llvm::ARM::getExtensionFeatures(Extension, Features);
   }
 }

diff  --git a/llvm/include/llvm/Support/ARMTargetParser.h 
b/llvm/include/llvm/Support/ARMTargetParser.h
index 02d4c975129f..ac2cd259826d 100644
--- a/llvm/include/llvm/Support/ARMTargetParser.h
+++ b/llvm/include/llvm/Support/ARMTargetParser.h
@@ -24,7 +24,7 @@ namespace ARM {
 
 // Arch extension modifiers for CPUs.
 // Note that this is not the same as the AArch64 list
-enum ArchExtKind : unsigned {
+enum ArchExtKind : uint64_t {
   AEK_INVALID = 0,
   AEK_NONE =1,
   AEK_CRC = 1 << 1,
@@ -47,11 +47,11 @@ enum ArchExtKind : unsigned {
   AEK_FP_DP   = 1 << 18,
   AEK_LOB = 1 << 19,
   // Unsupported extensions.
-  AEK_OS = 0x800,
-  AEK_IWMMXT = 0x1000,
-  AEK_IWMMXT2 = 0x2000,
-  AEK_MAVERICK = 0x4000,
-  AEK_XSCALE = 0x8000,
+  AEK_OS   =1ULL << 59,
+  AEK_IWMMXT   =1ULL << 60,
+  AEK_IWMMXT2  =1ULL << 61,
+  AEK_MAVERICK =1ULL << 62,
+  AEK_XSCALE   =1ULL << 63,
 };
 
 // List of Arch Extension names.
@@ -59,7 +59,7 @@ enum ArchExtKind : unsigned {
 struct ExtName {
   const char *NameCStr;
   size_t NameLength;
-  unsigned ID;
+  uint64_t ID;
   const char *Feature;
   const char *NegFeature;
 
@@ -102,7 +102,7 @@ template  struct CpuNames {
   size_t NameLength;
   T ArchID;
   bool Default; // is $Name the default CPU for $ArchID ?
-  unsigned DefaultExtensions;
+  uint64_t DefaultExtensions;
 
   StringRef getName() const { return StringRef(NameCStr, NameLength); }
 };
@@ -193,7 +193,7 @@ template  struct ArchNames {
   const char *SubArchCStr;
   size_t SubArchLength;
   unsigned DefaultFPU;
-  unsigned ArchBaseExtensions;
+  uint64_t ArchBaseExtensions;
   T ID;
   ARMBuildAttrs::CPUArch ArchAttr; // Arch ID in build attributes.
 
@@ -225,33 +225,33 @@ FPURestriction getFPURestriction(unsigned FPUKind);
 
 // FIXME: These should be moved to TargetTuple once it exists
 bool getFPUFeatures(unsigned FPUKind, std::vector &Features);
-bool getHWDivFeatures(unsigned HWDivKind, std::ve

[PATCH] D73906: [ARM] Make ARM::ArchExtKind use 64-bit underlying type, NFCI

2020-02-04 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

In D73906#1856615 , @simon_tatham 
wrote:

> I wonder if it's worth temporarily redefining all the existing `AEK_FOO` ids 
> to values that don't fit in 32 bits, and making sure the whole test suite 
> still passes. That should catch any remaining cases where an integer type 
> should have been widened.


I will try that locally.


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

https://reviews.llvm.org/D73906



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


[PATCH] D73906: [ARM] Make ARM::ArchExtKind use 64-bit underlying type, NFCI

2020-02-04 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

I wonder if it's worth temporarily redefining all the existing `AEK_FOO` ids to 
values that don't fit in 32 bits, and making sure the whole test suite still 
passes. That should catch any remaining cases where an integer type should have 
been widened.


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

https://reviews.llvm.org/D73906



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


[PATCH] D73906: [ARM] Make ARM::ArchExtKind use 64-bit underlying type, NFCI

2020-02-04 Thread Mikhail Maltsev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7128aace600f: [ARM] Make ARM::ArchExtKind use 64-bit 
underlying type, NFCI (authored by miyuki).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73906

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  llvm/include/llvm/Support/ARMTargetParser.h
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -32,14 +32,14 @@
 };
 
 bool testARMCPU(StringRef CPUName, StringRef ExpectedArch,
-StringRef ExpectedFPU, unsigned ExpectedFlags,
+StringRef ExpectedFPU, uint64_t ExpectedFlags,
 StringRef CPUAttr) {
   ARM::ArchKind AK = ARM::parseCPUArch(CPUName);
   bool pass = ARM::getArchName(AK).equals(ExpectedArch);
   unsigned FPUKind = ARM::getDefaultFPU(CPUName, AK);
   pass &= ARM::getFPUName(FPUKind).equals(ExpectedFPU);
 
-  unsigned ExtKind = ARM::getDefaultExtensions(CPUName, AK);
+  uint64_t ExtKind = ARM::getDefaultExtensions(CPUName, AK);
   if (ExtKind > 1 && (ExtKind & ARM::AEK_NONE))
 pass &= ((ExtKind ^ ARM::AEK_NONE) == ExpectedFlags);
   else
@@ -565,7 +565,7 @@
 }
 
 TEST(TargetParserTest, ARMExtensionFeatures) {
-  std::map> Extensions;
+  std::map> Extensions;
 
   for (auto &Ext : ARM::ARCHExtNames) {
 if (Ext.Feature && Ext.NegFeature)
Index: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===
--- llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -11726,7 +11726,7 @@
   // when we start to table-generate them, and we can use the ARM
   // flags below, that were generated by table-gen.
   static const struct {
-const unsigned Kind;
+const uint64_t Kind;
 const FeatureBitset ArchCheck;
 const FeatureBitset Features;
   } Extensions[] = {
@@ -11775,7 +11775,7 @@
 EnableFeature = false;
 Name = Name.substr(2);
   }
-  unsigned FeatureKind = ARM::parseArchExt(Name);
+  uint64_t FeatureKind = ARM::parseArchExt(Name);
   if (FeatureKind == ARM::AEK_INVALID)
 return Error(ExtLoc, "unknown architectural extension: " + Name);
 
Index: llvm/lib/Support/ARMTargetParser.cpp
===
--- llvm/lib/Support/ARMTargetParser.cpp
+++ llvm/lib/Support/ARMTargetParser.cpp
@@ -367,11 +367,11 @@
.Default(ARM::FK_INVALID);
 }
 
-unsigned ARM::getDefaultExtensions(StringRef CPU, ARM::ArchKind AK) {
+uint64_t ARM::getDefaultExtensions(StringRef CPU, ARM::ArchKind AK) {
   if (CPU == "generic")
 return ARM::ARCHNames[static_cast(AK)].ArchBaseExtensions;
 
-  return StringSwitch(CPU)
+  return StringSwitch(CPU)
 #define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT)   \
   .Case(NAME,  \
 ARCHNames[static_cast(ArchKind::ID)].ArchBaseExtensions |\
@@ -380,7 +380,7 @@
   .Default(ARM::AEK_INVALID);
 }
 
-bool ARM::getHWDivFeatures(unsigned HWDivKind,
+bool ARM::getHWDivFeatures(uint64_t HWDivKind,
std::vector &Features) {
 
   if (HWDivKind == AEK_INVALID)
@@ -399,7 +399,7 @@
   return true;
 }
 
-bool ARM::getExtensionFeatures(unsigned Extensions,
+bool ARM::getExtensionFeatures(uint64_t Extensions,
std::vector &Features) {
 
   if (Extensions == AEK_INVALID)
@@ -431,7 +431,7 @@
   return ARCHNames[static_cast(AK)].ArchAttr;
 }
 
-StringRef ARM::getArchExtName(unsigned ArchExtKind) {
+StringRef ARM::getArchExtName(uint64_t ArchExtKind) {
   for (const auto AE : ARCHExtNames) {
 if (ArchExtKind == AE.ID)
   return AE.getName();
@@ -486,20 +486,13 @@
   return ARM::FK_INVALID;
 }
 
-static unsigned getAEKID(StringRef ArchExtName) {
-  for (const auto AE : ARM::ARCHExtNames)
-if (AE.getName() == ArchExtName)
-  return AE.ID;
-  return ARM::AEK_INVALID;
-}
-
 bool ARM::appendArchExtFeatures(
   StringRef CPU, ARM::ArchKind AK, StringRef ArchExt,
   std::vector &Features) {
 
   size_t StartingNumFeatures = Features.size();
   const bool Negated = stripNegationPrefix(ArchExt);
-  unsigned ID = getAEKID(ArchExt);
+  uint64_t ID = parseArchExt(ArchExt);
 
   if (ID == AEK_INVALID)
 return false;
@@ -532,7 +525,7 @@
   return StartingNumFeatures != Features.size();
 }
 
-StringRef ARM::getHWDivName(unsigned HWDivKind) {
+StringRef ARM::getHWDivName(uint64_t HWDivKind) {
   for (const auto D : HWDivNames) {
 if (HWDivKind == D.ID)
   return D.getName();
@@ -555,7 +548,7 @@
   return "generic"

[clang-tools-extra] 9257071 - [clangd] Mechanism to make update debounce responsive to rebuild speed.

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

Author: Sam McCall
Date: 2020-02-04T12:28:20+01:00
New Revision: 92570718a86cc4c23108b596002114ab25857b14

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

LOG: [clangd] Mechanism to make update debounce responsive to rebuild speed.

Summary:
Currently we delay AST rebuilds by 500ms after each edit, to wait for
further edits. This is a win if a rebuild takes 5s, and a loss if it
takes 50ms.

This patch sets debouncepolicy = clamp(min, ratio * rebuild_time, max).
However it sets min = max = 500ms so there's no policy change or actual
customizability - will do that in a separate patch.

See https://github.com/clangd/clangd/issues/275

Reviewers: hokein

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

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 00da7af06741..3e22a4dfe667 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -106,7 +106,7 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
 
 ClangdServer::Options ClangdServer::optsForTest() {
   ClangdServer::Options Opts;
-  Opts.UpdateDebounce = std::chrono::steady_clock::duration::zero(); // Faster!
+  Opts.UpdateDebounce = DebouncePolicy::fixed(/*zero*/ {});
   Opts.StorePreamblesInMemory = true;
   Opts.AsyncThreadsCount = 4; // Consistent!
   Opts.SemanticHighlighting = true;

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 2d0957f441bb..3c3505295a75 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -130,8 +130,8 @@ class ClangdServer {
 llvm::Optional ResourceDir = llvm::None;
 
 /// Time to wait after a new file version before computing diagnostics.
-std::chrono::steady_clock::duration UpdateDebounce =
-std::chrono::milliseconds(500);
+DebouncePolicy UpdateDebounce =
+DebouncePolicy::fixed(std::chrono::milliseconds(500));
 
 bool SuggestMissingIncludes = false;
 

diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp 
b/clang-tools-extra/clangd/TUScheduler.cpp
index 9218ae9a03ce..237c4c4d7ba6 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -61,6 +61,7 @@
 #include "llvm/Support/Threading.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -164,7 +165,7 @@ class ASTWorker {
   friend class ASTWorkerHandle;
   ASTWorker(PathRef FileName, const GlobalCompilationDatabase &CDB,
 TUScheduler::ASTCache &LRUCache, Semaphore &Barrier, bool RunSync,
-steady_clock::duration UpdateDebounce, bool StorePreamblesInMemory,
+DebouncePolicy UpdateDebounce, bool StorePreamblesInMemory,
 ParsingCallbacks &Callbacks);
 
 public:
@@ -176,7 +177,7 @@ class ASTWorker {
   static ASTWorkerHandle
   create(PathRef FileName, const GlobalCompilationDatabase &CDB,
  TUScheduler::ASTCache &IdleASTs, AsyncTaskRunner *Tasks,
- Semaphore &Barrier, steady_clock::duration UpdateDebounce,
+ Semaphore &Barrier, DebouncePolicy UpdateDebounce,
  bool StorePreamblesInMemory, ParsingCallbacks &Callbacks);
   ~ASTWorker();
 
@@ -242,7 +243,7 @@ class ASTWorker {
   TUScheduler::ASTCache &IdleASTs;
   const bool RunSync;
   /// Time to wait after an update to see whether another update obsoletes it.
-  const steady_clock::duration UpdateDebounce;
+  const DebouncePolicy UpdateDebounce;
   /// File that ASTWorker is responsible for.
   const Path FileName;
   const GlobalCompilationDatabase &CDB;
@@ -263,6 +264,9 @@ class ASTWorker {
   /// be consumed by clients of ASTWorker.
   std::shared_ptr FileInputs; /* GUARDED_BY(Mutex) 
*/
   std::shared_ptr LastBuiltPreamble; /* GUARDED_BY(Mutex) 
*/
+  /// Times of recent AST rebuilds, used for UpdateDebounce computation.
+  llvm::SmallVector
+  RebuildTimes; /* GUARDED_BY(Mutex) */
   /// Becomes ready when the first preamble build finishes.
   Notification PreambleWasBuilt;
   /// Set to true to signal run() to finish processing.
@@ -326,7 +330,7 @@ class ASTWorkerHandle {
 ASTWorkerHandle
 ASTWorker::create(PathRef FileName, const GlobalCompilationDatabase &CDB,
   TUScheduler::ASTCache &IdleASTs, AsyncTaskRunner *Tasks,
-  Semaphore &Barrier, steady_clock::duration UpdateDebounce,

[PATCH] D73873: [clangd] Mechanism to make update debounce responsive to rebuild speed.

2020-02-04 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked 4 inline comments as done.
Closed by commit rG92570718a86c: [clangd] Mechanism to make update debounce 
responsive to rebuild speed. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D73873?vs=242016&id=242281#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73873

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  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
@@ -23,6 +23,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -208,7 +209,7 @@
   std::atomic CallbackCount(0);
   {
 auto Opts = optsForTest();
-Opts.UpdateDebounce = std::chrono::seconds(1);
+Opts.UpdateDebounce = DebouncePolicy::fixed(std::chrono::seconds(1));
 TUScheduler S(CDB, Opts, captureDiags());
 // FIXME: we could probably use timeouts lower than 1 second here.
 auto Path = testPath("foo.cpp");
@@ -361,7 +362,7 @@
   // Run TUScheduler and collect some stats.
   {
 auto Opts = optsForTest();
-Opts.UpdateDebounce = std::chrono::milliseconds(50);
+Opts.UpdateDebounce = DebouncePolicy::fixed(std::chrono::milliseconds(50));
 TUScheduler S(CDB, Opts, captureDiags());
 
 std::vector Files;
@@ -754,6 +755,32 @@
   EXPECT_THAT(Diagnostics, IsEmpty());
 }
 
+TEST(DebouncePolicy, Compute) {
+  namespace c = std::chrono;
+  std::vector History = {
+  c::seconds(0),
+  c::seconds(5),
+  c::seconds(10),
+  c::seconds(20),
+  };
+  DebouncePolicy Policy;
+  Policy.Min = c::seconds(3);
+  Policy.Max = c::seconds(25);
+  // Call Policy.compute(History) and return seconds as a float.
+  auto Compute = [&](llvm::ArrayRef History) {
+using FloatingSeconds = c::duration;
+return static_cast(Policy.compute(History) / FloatingSeconds(1));
+  };
+  EXPECT_NEAR(10, Compute(History), 0.01) << "(upper) median = 10";
+  Policy.RebuildRatio = 1.5;
+  EXPECT_NEAR(15, Compute(History), 0.01) << "median = 10, ratio = 1.5";
+  Policy.RebuildRatio = 3;
+  EXPECT_NEAR(25, Compute(History), 0.01) << "constrained by max";
+  Policy.RebuildRatio = 0;
+  EXPECT_NEAR(3, Compute(History), 0.01) << "constrained by min";
+  EXPECT_NEAR(25, Compute({}), 0.01) << "no history -> max";
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/TUScheduler.h
===
--- clang-tools-extra/clangd/TUScheduler.h
+++ clang-tools-extra/clangd/TUScheduler.h
@@ -61,6 +61,28 @@
   unsigned MaxRetainedASTs = 3;
 };
 
+/// Clangd may wait after an update to see if another one comes along.
+/// This is so we rebuild once the user stops typing, not when they start.
+/// Debounce may be disabled/interrupted if we must build this version.
+/// The debounce time is responsive to user preferences and rebuild time.
+/// In the future, we could also consider different types of edits.
+struct DebouncePolicy {
+  using clock = std::chrono::steady_clock;
+
+  /// The minimum time that we always debounce for.
+  clock::duration Min = /*zero*/ {};
+  /// The maximum time we may debounce for.
+  clock::duration Max = /*zero*/ {};
+  /// Target debounce, as a fraction of file rebuild time.
+  /// e.g. RebuildRatio = 2, recent builds took 200ms => debounce for 400ms.
+  float RebuildRatio = 1;
+
+  /// Compute the time to debounce based on this policy and recent build times.
+  clock::duration compute(llvm::ArrayRef History) const;
+  /// A policy that always returns the same duration, useful for tests.
+  static DebouncePolicy fixed(clock::duration);
+};
+
 struct TUAction {
   enum State {
 Queued,   // The TU is pending in the thread task queue to be built.
@@ -158,7 +180,7 @@
 
 /// Time to wait after an update to see if another one comes along.
 /// This tries to ensure we rebuild once the user stops typing.
-std::chrono::steady_clock::duration UpdateDebounce = /*zero*/ {};
+DebouncePolicy UpdateDebounce;
 
 /// Determines when to keep idle ASTs in memory for future use.
 ASTRetentionPolicy RetentionPolicy;
@@ -273,7 +295,7 @@
   // asynchronously.
   llvm::Optional PreambleTasks;
   llvm::Optional WorkerThreads;
-  std::chrono::steady_clock::duration UpdateDebounce;
+  DebouncePolicy UpdateDebounce;
 };
 
 } // namespace clangd
Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-e

[PATCH] D73949: [clangd] Debounce rebuilds responsively to rebuild times.

2020-02-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.

Old: 500ms always. New: rebuild time, up to 500ms.

Fixes https://github.com/clangd/clangd/issues/275


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73949

Files:
  clang-tools-extra/clangd/ClangdServer.h


Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -130,8 +130,11 @@
 llvm::Optional ResourceDir = llvm::None;
 
 /// Time to wait after a new file version before computing diagnostics.
-DebouncePolicy UpdateDebounce =
-DebouncePolicy::fixed(std::chrono::milliseconds(500));
+DebouncePolicy UpdateDebounce = DebouncePolicy{
+/*Min=*/std::chrono::milliseconds(50),
+/*Max=*/std::chrono::milliseconds(500),
+/*RebuildRatio=*/1,
+};
 
 bool SuggestMissingIncludes = false;
 


Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -130,8 +130,11 @@
 llvm::Optional ResourceDir = llvm::None;
 
 /// Time to wait after a new file version before computing diagnostics.
-DebouncePolicy UpdateDebounce =
-DebouncePolicy::fixed(std::chrono::milliseconds(500));
+DebouncePolicy UpdateDebounce = DebouncePolicy{
+/*Min=*/std::chrono::milliseconds(50),
+/*Max=*/std::chrono::milliseconds(500),
+/*RebuildRatio=*/1,
+};
 
 bool SuggestMissingIncludes = false;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73891: [RISCV] Support experimental/unratified extensions

2020-02-04 Thread Simon Cook via Phabricator via cfe-commits
simoncook updated this revision to Diff 242286.
simoncook added a comment.

Switch to using `Optional` for returning version numbers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73891

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c

Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -327,3 +327,22 @@
 // RUN: %clang -target riscv64-unknown-elf -march=rv64i -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64-TARGET %s
 // RV64-TARGET: "-triple" "riscv64-unknown-unknown-elf"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ib -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-NOFLAG %s
+// RV32-EXPERIMENTAL-NOFLAG: error: invalid arch name 'rv32ib'
+// RV32-EXPERIMENTAL-NOFLAG: requires '-menable-experimental-extensions'
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ib -menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-NOVERS %s
+// RV32-EXPERIMENTAL-NOVERS: error: invalid arch name 'rv32ib'
+// RV32-EXPERIMENTAL-NOVERS: experimental extension requires explicit version number
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ib0p1 -menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-BADVERS %s
+// RV32-EXPERIMENTAL-BADVERS: error: invalid arch name 'rv32ib0p1'
+// RV32-EXPERIMENTAL-BADVERS: unsupported version number 0.1 for experimental extension
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ib0p92 -menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-GOODVERS %s
+// RV32-EXPERIMENTAL-GOODVERS: "-target-feature" "+b"
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -22,6 +22,14 @@
 using namespace clang;
 using namespace llvm::opt;
 
+namespace {
+// Represents the major and version number components of a RISC-V extension
+struct RISCVExtensionVersion {
+  StringRef Major;
+  StringRef Minor;
+};
+} // end anonymous namespace
+
 static StringRef getExtensionTypeDesc(StringRef Ext) {
   if (Ext.startswith("sx"))
 return "non-standard supervisor-level extension";
@@ -47,20 +55,27 @@
   return false;
 }
 
+// If the extension is supported as experimental, return the version of that
+// extension that the compiler currently supports.
+static Optional
+isExperimentalExtension(StringRef Ext) {
+  if (Ext == "b")
+return RISCVExtensionVersion{"0", "92"};
+  return None;
+}
+
 // Extensions may have a version number, and may be separated by
 // an underscore '_' e.g.: rv32i2_m2.
 // Version number is divided into major and minor version numbers,
 // separated by a 'p'. If the minor version is 0 then 'p0' can be
 // omitted from the version string. E.g., rv32i2p0, rv32i2, rv32i2p1.
-static bool getExtensionVersion(const Driver &D, StringRef MArch,
-StringRef Ext, StringRef In,
+static bool getExtensionVersion(const Driver &D, const ArgList &Args,
+StringRef MArch, StringRef Ext, StringRef In,
 std::string &Major, std::string &Minor) {
   Major = std::string(In.take_while(isDigit));
   In = In.substr(Major.size());
-  if (Major.empty())
-return true;
 
-  if (In.consume_front("p")) {
+  if (Major.size() && In.consume_front("p")) {
 Minor = std::string(In.take_while(isDigit));
 In = In.substr(Major.size());
 
@@ -74,7 +89,43 @@
 }
   }
 
-  // TODO: Handle extensions with version number.
+  // If experimental extension, require use of current version number number
+  if (auto ExperimentalExtension = isExperimentalExtension(Ext)) {
+if (!Args.hasArg(options::OPT_menable_experimental_extensions)) {
+  std::string Error =
+  "requires '-menable-experimental-extensions' for experimental extension";
+  D.Diag(diag::err_drv_invalid_riscv_ext_arch_name)
+  << MArch << Error << Ext;
+  return false;
+} else if (Major.empty() && Minor.empty()) {
+  std::string Error =
+  "experimental extension requires explicit version number";
+  D.Diag(diag::err_drv_invalid_riscv_ext_arch_name)
+  << MArch << Error << Ext;
+  return false;
+}
+auto SupportedVers = *ExperimentalExtension;
+if (Major != SupportedVers.Major || Minor != SupportedVers.Minor) {
+  std::string Error =
+  "unsupported version number " + Major;
+  if (!Minor.empty())
+Error += "." + Minor;
+  Error += " for experimental extensi

[PATCH] D73949: [clangd] Debounce rebuilds responsively to rebuild times.

2020-02-04 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62438 tests passed, 0 failed 
and 845 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73949



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


[PATCH] D73951: [Clang] Add logic to search for flang frontend

2020-02-04 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto created this revision.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

This patch adds more logic to Flang.cpp to search for the
flang frontend.

A new flag(ffc-fortran-name) was created in this patch to
implement the logic in Flang driver.

The patch searches for the appropriated flang frontend path according to:
-if the flag ffc-fortran-name is being set use the name given by
the flag to search for the flang frontend path

- esle the frontend name is hard-coded to "flang", use that to

search the frontend path.

To set the custom fortran frontend this patch created a new internal driver
flag named "ffc-fortran-name" in Options.td.
The flag sets flang frontend for a custom fortran compiler. The logic for
ffc-fortran-name is the same as the one used by GNU to set ccc-gcc-name.

Signed-off-by: Caroline Concatto 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73951

Files:
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/test/Driver/flang/clang-driver-2-frontend01.f90
  clang/test/Driver/flang/driver-2-frontend01.f90
  clang/test/Driver/flang/driver-2-frontend02.f90
  clang/test/Driver/flang/flang-driver-2-frontend01.f90
  clang/test/Driver/flang/flang-driver-2-frontend02.f90

Index: clang/test/Driver/flang/flang-driver-2-frontend02.f90
===
--- /dev/null
+++ clang/test/Driver/flang/flang-driver-2-frontend02.f90
@@ -0,0 +1,19 @@
+! Check wich name of flang frontend is invoked by the driver
+
+! Driver name has flang, but the flag -ffc-fortran-name is passed by the driver.
+! The flag has preference over any other name that the Driver may have.
+! Therefore the driver invokes the FE given by the flag.
+
+! The invocations should begin with .tmp2 -fc1.
+! ALL-LABEL: "{{[^"]*}}flang-driver-2-frontend02.f90.tmp2" "-fc1"
+
+! Copy clang to two temporary file.
+! t1 is the driver name. %t2 is the frontend name
+! RUN: cp %clang %t1
+! RUN: cp %clang %t2
+! RUN: %t1 --driver-mode=flang -ffc-fortran-name %basename_t.tmp2 -### %s 2>&1 | FileCheck --check-prefixes=ALL,CHECK-EMIT-OBJ %s
+! CHECK-EMIT-OBJ-DAG: "-emit-obj"
+! CHECK-EMIT-OBJ-DAG: "-o" "{{[^"]*}}.o
+
+! Should end in the input file.
+! ALL: "{{.*}}flang-driver-2-frontend02.f90"{{$}}
Index: clang/test/Driver/flang/flang-driver-2-frontend01.f90
===
--- /dev/null
+++ clang/test/Driver/flang/flang-driver-2-frontend01.f90
@@ -0,0 +1,16 @@
+! Check wich name of flang frontend is invoked by the driver
+
+! Driver name has flang, therefore the Driver invokes FE
+! with the same name as the driver.
+
+! The invocations should begin with .tmp1 -fc1.
+! ALL-LABEL: "{{[^"]*}}flang" "-fc1"
+
+! Copy clang to a temporary file to be the driver name
+! RUN: cp %clang %t1
+! RUN: %t1 --driver-mode=flang -###  %s 2>&1 | FileCheck --check-prefixes=ALL,CHECK-EMIT-OBJ %s
+! CHECK-EMIT-OBJ-DAG: "-emit-obj"
+! CHECK-EMIT-OBJ-DAG: "-o" "{{[^"]*}}.o
+
+! Should end in the input file.
+! ALL: "{{.*}}flang-driver-2-frontend01.f90"{{$}}
Index: clang/test/Driver/flang/driver-2-frontend02.f90
===
--- /dev/null
+++ clang/test/Driver/flang/driver-2-frontend02.f90
@@ -0,0 +1,19 @@
+! Check wich name of flang frontend is invoked by the driver
+
+! Driver name is a randon name. It does not contain flang or clang,
+! but the driver gives a flag with the desired FE to be used.
+! Therefore it should use the FE given by the flag.
+
+! The invocations should begin with .tmp2 -fc1.
+! ALL-LABEL: "{{[^"]*}}driver-2-frontend02.f90.tmp2" "-fc1"
+
+! Copy clang to two temporary file.
+! t1 is the driver name. t2 is the frontend name
+! RUN: cp %clang %t1
+! RUN: cp %clang %t2
+! RUN: %t1 --driver-mode=flang -### -ffc-fortran-name %basename_t.tmp2 %s 2>&1 | FileCheck --check-prefixes=ALL,CHECK-EMIT-OBJ %s
+! CHECK-EMIT-OBJ-DAG: "-emit-obj"
+! CHECK-EMIT-OBJ-DAG: "-o" "{{[^"]*}}.o
+
+! Should end in the input file.
+! ALL: "{{.*}}driver-2-frontend02.f90"{{$}}
Index: clang/test/Driver/flang/driver-2-frontend01.f90
===
--- /dev/null
+++ clang/test/Driver/flang/driver-2-frontend01.f90
@@ -0,0 +1,18 @@
+! Check wich name of flang frontend is invoked by the driver
+
+! Driver name is a randon name. It does not contain flag, flang or clang,
+! therefore the driver invokes flang FE.
+
+! The invocations should begin with flang -fc1.
+! ALL-LABEL: "{{[^"]*}}flang" "-fc1"
+
+! Copy clang to two temporary file
+! t1 is the new driver name.
+! RUN: cp %clang %t1
+! RUN: %t1 --driver-mode=flang -###  %s 2>&1 | FileCheck --check-prefixes=ALL,CHECK-EMIT-OBJ %s
+! CHECK-EMIT-OBJ-DAG: "-emit-obj"
+! CHECK-EMIT-OBJ-DAG: "-o" "{{[^"]*}}.o
+
+! Should end in the input file.
+! ALL: "{{.*}}dr

[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-02-04 Thread Ruyman via Phabricator via cfe-commits
Ruyk added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.def:206
 LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "C++ for OpenCL version")
+ENUM_LANGOPT(SYCLVersion, SYCLVersionList, 4, SYCLVersionList::undefined, 
"Version of the SYCL standard used")
 LANGOPT(NativeHalfType, 1, 0, "Native half type support")

bader wrote:
> All other language options controlling standard versions are added as 
> "LANGOPT" i.e. `int`. Why SYCLVersion is different?
> @Ruyk, do you think we should convert other options (e.g. `OpenCL`) to enums 
> as well?
Thats a good point. I don't see strong reasons for the enum, basically I read 
the comment in 
https://code.woboq.org/llvm/clang/include/clang/Basic/LangOptions.def.html#22


```
// ENUM_LANGOPT: for options that have enumeration, rather than unsigned, type.
```

And since there is a known set of SYCL specifications, made more sense to 
enumerate it.
It also simplifies writing variants to 1.2.1 (e.g. 1.2.1-oneapi) in the code 
since then you can add another entry to the enum.

But no strong feelings, so feel free to change it.




Comment at: clang/include/clang/Driver/Options.td:3401
+def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, 
Flags<[CC1Option]>,
+  HelpText<"SYCL language standard to compile for.">, Values<"1.2.1">;
 

bader wrote:
> What do you think we integrate sycl versions to existing clang options 
> controlling language version: `-std`.
> As far as I can see it's used for all the C/C+ extensions like 
> OpenMP/OpenCL/CUDA/HIP/ObjC.
> 
> If I understand correctly clang supports `-cl-std` only because it's required 
> by OpenCL standard. Similar option (i.e. `-sycl-std`) is not required by the 
> SYCL specification, so using `-std` is more aligned with existing clang 
> design.
> 
> See clang/include/clang/Basic/LangStandard.h and 
> clang/include/clang/Basic/LangStandards.def.
In the case of SYCL, you may want to compile your code with C++17 and SYCL 
2015, in which case you need both -std=c++17 and -sycl=sycl-2015 . 
SYCL specification mandates a minimum C++ version but users can write code on 
newer versions as long as the code in the kernel scope is still valid.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3989
+// Ensure the default version in SYCL mode is 1.2.1
+CmdArgs.push_back("-sycl-std=1.2.1");
+  }

This should probably change to 2015 if we are allowing that, just for 
consistency


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857



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


[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 242296.
yaxunl marked 4 inline comments as done.
yaxunl added a comment.

revised by John's comments.


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

https://reviews.llvm.org/D70172

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/UsedDeclVisitor.h
  clang/test/OpenMP/declare_target_messages.cpp
  clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
  clang/test/SemaCUDA/bad-calls-on-same-line.cu
  clang/test/SemaCUDA/call-device-fn-from-host.cu
  clang/test/SemaCUDA/call-host-fn-from-device.cu
  clang/test/SemaCUDA/openmp-target.cu
  clang/test/SemaCUDA/trace-through-global.cu

Index: clang/test/SemaCUDA/trace-through-global.cu
===
--- clang/test/SemaCUDA/trace-through-global.cu
+++ clang/test/SemaCUDA/trace-through-global.cu
@@ -38,7 +38,7 @@
   // Notice that these two diagnostics are different: Because the call to hd1
   // is not dependent on T, the call to hd1 comes from 'launch_kernel', while
   // the call to hd3, being dependent, comes from 'launch_kernel'.
-  hd1(); // expected-note {{called by 'launch_kernel'}}
+  hd1(); // expected-note {{called by 'launch_kernel'}}
   hd3(T()); // expected-note {{called by 'launch_kernel'}}
 }
 
Index: clang/test/SemaCUDA/openmp-target.cu
===
--- clang/test/SemaCUDA/openmp-target.cu
+++ clang/test/SemaCUDA/openmp-target.cu
@@ -16,9 +16,9 @@
 void bazzz() {bazz();}
 #pragma omp declare target to(bazzz) device_type(nohost)
 void any() {bazz();} // expected-error {{function with 'device_type(nohost)' is not available on host}}
-void host1() {bazz();}
+void host1() {bazz();} // expected-error {{function with 'device_type(nohost)' is not available on host}}
 #pragma omp declare target to(host1) device_type(host)
-void host2() {bazz();}
+void host2() {bazz();} // expected-error {{function with 'device_type(nohost)' is not available on host}}
 #pragma omp declare target to(host2)
 void device() {host1();}
 #pragma omp declare target to(device) device_type(nohost)
Index: clang/test/SemaCUDA/call-host-fn-from-device.cu
===
--- clang/test/SemaCUDA/call-host-fn-from-device.cu
+++ clang/test/SemaCUDA/call-host-fn-from-device.cu
@@ -56,14 +56,14 @@
 }
 
 template  __host__ __device__ void hd2() { host_fn(); }
-// expected-error@-1 2 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
+// expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
 __global__ void kernel() { hd2(); }
 
 __host__ __device__ void hd() { host_fn(); }
 // expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
 
 template  __host__ __device__ void hd3() { host_fn(); }
-// expected-error@-1 2 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
+// expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
 __device__ void device_fn() { hd3(); }
 
 // No error because this is never instantiated.
Index: clang/test/SemaCUDA/call-device-fn-from-host.cu
===
--- clang/test/SemaCUDA/call-device-fn-from-host.cu
+++ clang/test/SemaCUDA/call-device-fn-from-host.cu
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - \
 // RUN:   -verify -verify-ignore-unexpected=note
 // RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - \
-// RUN:   -verify -verify-ignore-unexpected=note -fopenmp
+// RUN:   -verify=expected,omp -verify-ignore-unexpected=note -fopenmp
 
 // Note: This test won't work with -fsyntax-only, because some of these errors
 // are emitted during codegen.
@@ -39,7 +39,7 @@
 }
 
 template  __host__ __device__ void hd2() { device_fn(); }
-// expected-error@-1 2 {{reference to __device__ function 'device_fn' in __host__ __device__ function}}
+// expected-error@-1 {{reference to __device__ function 'device_fn' in __host__ __device__ function}}
 void host_fn() { hd2(); }
 
 __host__ __device__ void hd() { device_fn(); }
Index: clang/test/SemaCUDA/bad-calls-on-same-line.cu
===
--- clang/test/SemaCUDA/bad-calls-on-same-line.cu
+++ clang/test/SemaCUDA/bad-calls-on-same-line.cu
@@ -33,8 +33,8 @@
 
 void host_fn() {
   hd();
-  hd();  // expected-note {{function template specialization 'hd'}}
+  hd();
   // expected-note@-1 {{called by 'host_fn'}}
-  hd();  // expected-note {{function template specialization 'hd'}}
+  hd();
   // expected-note@-1 {{called by 'host_fn'}}
 }
Index: clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
===

[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:17254
+SourceLocation(), Context.getTranslationUnitDecl());
+  }
 

rjmccall wrote:
> Thanks, this looks a lot better.
> 
> Should this be moved to SemaOpenMP.cpp (and renamed to be OpenMP-specific), 
> or do you think it's going to be useful in other modes?
It is not just for OpenMP. Deferred diagnostics are also emitted by CUDA/HIP.


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

https://reviews.llvm.org/D70172



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


[PATCH] D73651: [OpenCL][CUDA][HIP][SYCL] Add norecurse

2020-02-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 242300.
yaxunl marked 5 inline comments as done.
yaxunl added a comment.

revised by Anastasia's comments.


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

https://reviews.llvm.org/D73651

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGenCUDA/norecurse.cu
  clang/test/CodeGenOpenCL/norecurse.cl
  clang/test/SemaCUDA/call-kernel-from-kernel.cu


Index: clang/test/SemaCUDA/call-kernel-from-kernel.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/call-kernel-from-kernel.cu
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - 
\
+// RUN:   -verify -fsyntax-only -verify-ignore-unexpected=note
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1();
+__global__ void kernel2() {
+  kernel1<<<1,1>>>(); // expected-error {{reference to __global__ function 
'kernel1' in __global__ function}}
+}
Index: clang/test/CodeGenOpenCL/norecurse.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/norecurse.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -O0 -emit-llvm -o - %s | FileCheck %s
+
+kernel void kernel1(int a) {}
+// CHECK: define{{.*}}@kernel1{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/test/CodeGenCUDA/norecurse.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/norecurse.cu
@@ -0,0 +1,15 @@
+// REQUIRES: amdgpu-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx-nvidia-cuda -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - -x hip %s | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1(int a) {}
+// CHECK: define{{.*}}@_Z7kernel1i{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -907,10 +907,20 @@
   // If we're in C++ mode and the function name is "main", it is guaranteed
   // to be norecurse by the standard (3.6.1.3 "The function main shall not be
   // used within a program").
-  if (getLangOpts().CPlusPlus)
-if (const FunctionDecl *FD = dyn_cast_or_null(D))
-  if (FD->isMain())
-Fn->addFnAttr(llvm::Attribute::NoRecurse);
+  //
+  // OpenCL C 2.0 v2.2-11 s6.9.i:
+  // Recursion is not supported.
+  //
+  // SYCL v1.2.1 s3.10:
+  // kernels cannot include RTTI information, exception classes,
+  // recursive code, virtual functions or make use of C++ libraries that
+  // are not compiled for the device.
+  if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+if ((getLangOpts().CPlusPlus && FD->isMain()) || getLangOpts().OpenCL ||
+getLangOpts().SYCLIsDevice ||
+(getLangOpts().CUDA && FD->hasAttr()))
+  Fn->addFnAttr(llvm::Attribute::NoRecurse);
+  }
 
   if (const FunctionDecl *FD = dyn_cast_or_null(D))
 if (FD->usesFPIntrin())


Index: clang/test/SemaCUDA/call-kernel-from-kernel.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/call-kernel-from-kernel.cu
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - \
+// RUN:   -verify -fsyntax-only -verify-ignore-unexpected=note
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1();
+__global__ void kernel2() {
+  kernel1<<<1,1>>>(); // expected-error {{reference to __global__ function 'kernel1' in __global__ function}}
+}
Index: clang/test/CodeGenOpenCL/norecurse.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/norecurse.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -O0 -emit-llvm -o - %s | FileCheck %s
+
+kernel void kernel1(int a) {}
+// CHECK: define{{.*}}@kernel1{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/test/CodeGenCUDA/norecurse.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/norecurse.cu
@@ -0,0 +1,15 @@
+// REQUIRES: amdgpu-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx-nvidia-cuda -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN: -emit-llvm -disable-llvm-passes -o - -x hip %s | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+__global__ void kernel1(int a) {}
+// CHECK: define{{.*}}@_Z7kernel1i{{.*}}#[[ATTR:[0-9]*]]
+
+// CHECK: attributes #[[ATTR]] = {{.*}}norecurse
Index: clang/lib/CodeGen/CodeGenFunction.cpp
=

[PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP

2020-02-04 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 added inline comments.



Comment at: llvm/lib/Passes/PassBuilder.cpp:1380
+  // in ICP (which is performed earlier than this in the regular LTO pipeline).
+  MPM.addPass(LowerTypeTestsPass(nullptr, nullptr, true));
 

tejohnson wrote:
> evgeny777 wrote:
> > Can we get rid of two identical passes here (and in other places also)? For 
> > instance 
> > ```
> > MPM.addPass(LowerTypeTestsPass(ExportSummary, nullptr, true));
> > ```
> > can both lower type metadata and do final cleanup.
> The problem is that currently under DropTypeTests=true, LTT will drop the 
> type tests up front and return without doing any other lowering. Which is 
> what we want in the already existing callers of LTT with DropTypeTests=true. 
> Here, we want LTT to perform its usual lowering, and only afterwards do the 
> dropping. We want to do this only during regular LTO, but unfortunately we 
> can't just key off of the ExportSummary (e.g. drop at the start if 
> ExportSummary is nullptr, and drop at the end if ExportSummary is 
> non-nullptr), since in some cases here ExportSummary may be nullptr (i.e. 
> regular LTO invoked via the old LTO API). So I would need to introduce 
> another option to essentially say "drop them after lowering". I can certainly 
> do this if you think it would be better (I was thinking about that before, 
> but thought it might be more confusing). WDYT?
> So I would need to introduce another option to essentially say "drop them 
> after lowering". I can certainly do this if you think it would be better (I 
> was thinking about that before, but thought it might be more confusing). WDYT?

Ok, I see. I don't think having this another option is significantly better. So 
let's leave it as is for now



Comment at: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:1678
+// breaks any uses on assumes.
+if (TypeIdMap.count(TypeId))
+  continue;

tejohnson wrote:
> evgeny777 wrote:
> > I don't think, I understand this.
> > It looks like that if (a) we have type.test in the module and (b) we don't 
> > have vtable definition with corresponding type metadata in the same module 
> > then we'll remove type.test/assume sequence before even getting to ICP. 
> > This seems strange in the context of previous discussion because virtual 
> > function may be called in different module from one where vtable is 
> > defined, like so:
> > ```
> > struct A { virtual int foo() { return 42; } };
> > 
> > // calls pA->foo
> > extern int callFoo(A *pA);
> > int main() { A a; return callFoo(&a); }
> > ```
> > 
> We will only be able to do ICP this way if we have the target vtable in the 
> module (similar to how we currently can only do ICP if the target function is 
> in the module). I anticipate doing something similar for vtable defs as to 
> what we do for virtual functions, where a fake call edge is added to the 
> summary based on the value profile results to ensure they are imported before 
> the LTO backend ICP.
> We will only be able to do ICP this way if we have the target vtable in the 
> module (similar to how we currently can only do ICP if the target function is 
> in the module).

I was thinking of slightly different approach: it seems you have required type 
information in combined index together with type name in the module, so you 
probably can add external declarations of required vtables (this may require 
promotion) to the module in the ICP pass and run ICP over them. Do you think 
this can work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73242



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


[PATCH] D73775: [clang-tidy] Cover cases like (b && c && b) in the redundant expression check

2020-02-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D73775#1851553 , @alexeyr wrote:

> Also I am not sure why, but the ranges added to the diagnostic in lines 
> 1222-1226 don't show up in the message.


Do you mean that there are no squiggly underlines under the range, or something 
else? Passing in a range to the diagnostics engine gives it something to put an 
underline under, as in what's under the -12 in: https://godbolt.org/z/GeQzYg


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

https://reviews.llvm.org/D73775



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


[PATCH] D73960: [clangd] Don't assert when completing a lambda variable inside the lambda.

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

This is a fairly ugly hack - we back off several features for any variable
whose type isn't deduced, to avoid computing/caching linkage.
Better suggestions welcome.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73960

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Quality.cpp
  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
@@ -2664,6 +2664,17 @@
   ElementsAre(AllOf(ReturnType("int"), Named("size";
 }
 
+TEST(CompletionTest, NoCrashWithIncompleteLambda) {
+  auto Completions = completions("auto&& x = []{^").Completions;
+  // The completion of x itself can cause a problem: in the code completion
+  // callback, its type is not known, which affects the linkage calculation.
+  // A bad linkage value gets cached, and subsequently updated.
+  EXPECT_THAT(Completions, Contains(Named("x")));
+
+  auto Signatures = signatures("auto x() { x(^").signatures;
+  EXPECT_THAT(Signatures, Contains(Sig("x() -> auto")));
+}
+
 TEST(NoCompileCompletionTest, Basic) {
   auto Results = completionsNoCompile(R"cpp(
 void func() {
Index: clang-tools-extra/clangd/Quality.cpp
===
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -275,8 +275,9 @@
   }
   if (InClass)
 return SymbolRelevanceSignals::ClassScope;
-  // This threshold could be tweaked, e.g. to treat module-visible as global.
-  if (D->getLinkageInternal() < ExternalLinkage)
+  // ExternalLinkage threshold could be tweaked, e.g. module-visible as global.
+  // Avoid caching linkage if it may change after enclosing code completion.
+  if (hasUnstableLinkage(D) || D->getLinkageInternal() < ExternalLinkage)
 return SymbolRelevanceSignals::FileScope;
   return SymbolRelevanceSignals::GlobalScope;
 }
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -489,6 +489,9 @@
   switch (R.Kind) {
   case CodeCompletionResult::RK_Declaration:
   case CodeCompletionResult::RK_Pattern: {
+// Computing USR caches linkage, which may change after code completion.
+if (hasUnstableLinkage(R.Declaration))
+  return llvm::None;
 return clang::clangd::getSymbolID(R.Declaration);
   }
   case CodeCompletionResult::RK_Macro:
@@ -1001,10 +1004,11 @@
 ScoredSignature Result;
 Result.Signature = std::move(Signature);
 Result.Quality = Signal;
-Result.IDForDoc =
-Result.Signature.documentation.empty() && Candidate.getFunction()
-? clangd::getSymbolID(Candidate.getFunction())
-: None;
+if (Result.Signature.documentation.empty() && Candidate.getFunction()) {
+  // Computing USR caches linkage, which may change after code completion.
+  if (!hasUnstableLinkage(Candidate.getFunction()))
+  Result.IDForDoc = clangd::getSymbolID(Candidate.getFunction());
+}
 return Result;
   }
 
Index: clang-tools-extra/clangd/AST.h
===
--- clang-tools-extra/clangd/AST.h
+++ clang-tools-extra/clangd/AST.h
@@ -148,6 +148,21 @@
  const NamedDecl *ND,
  llvm::ArrayRef VisibleNamespaces);
 
+/// Whether we must avoid computing linkage for D during code completion.
+/// Clang aggressively caches linkage computation, which is stable after the AST
+/// is built. Unfortunately the AST is incomplete during code completion, so
+/// linkage may still change.
+///
+/// Example: `auto x = []{^}` at file scope.
+/// During code completion, the initializer for x hasn't been parsed yet.
+/// x has type `undeduced auto`, and external linkage.
+/// If we compute linkage at this point, the external linkage will be cached.
+///
+/// After code completion the initializer is attached, and x has a lambda type.
+/// This means x has "unique external" linkage. If we computed linkage above,
+/// the cached value is incorrect. (clang catches this with an assertion).
+bool hasUnstableLinkage(const Decl *D);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -473,5 +473,12 @@
   });
 }
 
+bool h

[PATCH] D73775: [clang-tidy] Cover cases like (b && c && b) in the redundant expression check

2020-02-04 Thread Alexey Romanov via Phabricator via cfe-commits
alexeyr added a comment.

In D73775#1856765 , @aaron.ballman 
wrote:

> In D73775#1851553 , @alexeyr wrote:
>
> > Also I am not sure why, but the ranges added to the diagnostic in lines 
> > 1222-1226 don't show up in the message.
>
>
> Do you mean that there are no squiggly underlines under the range, or 
> something else? Passing in a range to the diagnostics engine gives it 
> something to put an underline under, as in what's under the -12 in: 
> https://godbolt.org/z/GeQzYg


Yes, exactly. I expect to see the underlines, but don't; only the `^` in the 
location provided to `diag` call.


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

https://reviews.llvm.org/D73775



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


[PATCH] D73360: [OpenCL] Restrict address space conversions in nested pointers

2020-02-04 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 242312.
Anastasia added a comment.

Add warning into `IncompatiblePointerTypesDiscardsQualifiers` group.


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

https://reviews.llvm.org/D73360

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  clang/test/SemaOpenCL/address-spaces.cl
  clang/test/SemaOpenCLCXX/address-space-castoperators.cl
  clang/test/SemaOpenCLCXX/address-space-deduction.cl
  clang/test/SemaOpenCLCXX/address-space-references.cl

Index: clang/test/SemaOpenCLCXX/address-space-references.cl
===
--- clang/test/SemaOpenCLCXX/address-space-references.cl
+++ clang/test/SemaOpenCLCXX/address-space-references.cl
@@ -13,3 +13,16 @@
 void foo() {
   bar(1) // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
 }
+
+// Test addr space conversion with nested pointers
+
+extern void nestptr(int *&); // expected-note {{candidate function not viable: no known conversion from '__global int *__private' to '__generic int *__generic &__private' for 1st argument}}
+extern void nestptr_const(int * const &); // expected-note {{candidate function not viable: cannot pass pointer to address space '__constant' as a pointer to address space '__generic' in 1st argument}}
+int test_nestptr(__global int *glob, __constant int *cons, int* gen) {
+  nestptr(glob); // expected-error{{no matching function for call to 'nestptr'}}
+  // Addr space conversion first occurs on a temporary.
+  nestptr_const(glob);
+  // No legal conversion between disjoint addr spaces.
+  nestptr_const(cons); // expected-error{{no matching function for call to 'nestptr_const'}}
+  return *(*cons ? glob : gen);
+}
Index: clang/test/SemaOpenCLCXX/address-space-deduction.cl
===
--- clang/test/SemaOpenCLCXX/address-space-deduction.cl
+++ clang/test/SemaOpenCLCXX/address-space-deduction.cl
@@ -105,7 +105,7 @@
 
 __kernel void k() {
   __local float x[2];
-  __local float(*p)[2];
+  float(*p)[2];
   t1(x);
   t2(&x);
   t3(&x);
Index: clang/test/SemaOpenCLCXX/address-space-castoperators.cl
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/address-space-castoperators.cl
@@ -0,0 +1,12 @@
+//RUN: %clang_cc1 %s -cl-std=clc++ -pedantic -ast-dump -verify | FileCheck %s
+
+void nester_ptr() {
+  local int * * locgen;
+  constant int * * congen;
+  int * * gengen;
+
+  gengen = const_cast(locgen); //expected-error{{const_cast from '__local int *__generic *' to '__generic int *__generic *' is not allowed}}
+  gengen = static_cast(locgen); //expected-error{{static_cast from '__local int *__generic *' to '__generic int *__generic *' is not allowed}}
+// CHECK-NOT: AddressSpaceConversion
+  gengen = reinterpret_cast(locgen); //expected-warning{{reinterpret_cast from '__local int *__generic *' to '__generic int *__generic *' changes address space of nested pointers}}
+}
Index: clang/test/SemaOpenCL/address-spaces.cl
===
--- clang/test/SemaOpenCL/address-spaces.cl
+++ clang/test/SemaOpenCL/address-spaces.cl
@@ -198,9 +198,7 @@
   ll = gg;   // expected-error {{assigning to '__local int *__private *' from incompatible type '__global int *__private *__private'}}
   ll = l;// expected-error {{assigning to '__local int *__private *' from incompatible type '__local int *__private'; take the address with &}}
   ll = gg_f; // expected-error {{assigning to '__local int *__private *' from incompatible type '__global float *__private *__private'}}
-  // FIXME: The below becomes a reinterpret_cast, and therefore does not emit an error
-  // even though the address space mismatches in the nested pointers.
-  ll = (__local int * __private *)gg;
+  ll = (__local int *__private *)gg; //expected-warning{{C-style cast from '__global int *__private *' to '__local int *__private *' changes address space of nested pointers}}
 
   gg_f = g;  // expected-error {{assigning to '__global float *__private *' from incompatible type '__global int *__private'}}
   gg_f = gg; // expected-error {{assigning to '__global float *__private *' from incompatible type '__global int *__private *__private'}}
Index: clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
===
--- clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
+++ clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
@@ -513,17 +513,37 @@
 #endif
 
   // Case 3: Corresponded inner pointees has overlapping but not equivalent address spaces.
-  // FIXME: Should this really be allowed in C++ mode?
   var_as_as_int = var_asc_asc_int;
-#if !__OPENCL_CPP_VERSION__
 

[PATCH] D73775: [clang-tidy] Cover cases like (b && c && b) in the redundant expression check

2020-02-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D73775#1856848 , @alexeyr wrote:

> In D73775#1856765 , @aaron.ballman 
> wrote:
>
> > In D73775#1851553 , @alexeyr wrote:
> >
> > > Also I am not sure why, but the ranges added to the diagnostic in lines 
> > > 1222-1226 don't show up in the message.
> >
> >
> > Do you mean that there are no squiggly underlines under the range, or 
> > something else? Passing in a range to the diagnostics engine gives it 
> > something to put an underline under, as in what's under the -12 in: 
> > https://godbolt.org/z/GeQzYg
>
>
> Yes, exactly. I expect to see the underlines, but don't; only the `^` in the 
> location provided to `diag` call.


The only time I've seen that happen is when the range is invalid. I'm guessing 
you'll have to step through the diagnostics code to see what's going on.




Comment at: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp:1242
+StringRef Message =
+Call ? "Overloaded operator has equivalent nested operands"
+ : "Operator has equivalent nested operands";

Diagnostics in clang tidy are not capitalized, so this should be `overloaded 
operator` and `operator`.


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

https://reviews.llvm.org/D73775



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


[PATCH] D73960: [clangd] Don't assert when completing a lambda variable inside the lambda.

2020-02-04 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62439 tests passed, 0 failed 
and 845 were skipped.

{icon times-circle color=red} clang-tidy: fail. clang-tidy found 0 errors and 1 
warnings 
.
 1 of them are added as review comments below (why? 
).

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73960



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


[PATCH] D73873: [clangd] Mechanism to make update debounce responsive to rebuild speed.

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

This seems to break tests: http://45.33.8.238/linux/9296/step_9.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73873



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


[clang-tools-extra] 69a39dc - [clangd] Increase stack size of the new threads on macOS

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

Author: Sam McCall
Date: 2020-02-04T15:21:27+01:00
New Revision: 69a39dc1f0d08ea43bac03a87bb8bff3937ce2e7

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

LOG: [clangd] Increase stack size of the new threads on macOS

Summary: By default it's 512K, which is way to small for clang parser to run 
on. There is no way to do it via platform-independent API, so it's implemented 
via pthreads directly in clangd/Threading.cpp.

Fixes https://github.com/clangd/clangd/issues/273

Patch by Dmitry Kozhevnikov!

Reviewers: ilya-biryukov, sammccall, arphaman

Reviewed By: ilya-biryukov, sammccall, arphaman

Subscribers: dexonsmith, umanwizard, jfb, ioeric, MaskRay, jkorous, arphaman, 
kadircet, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/Threading.cpp
clang-tools-extra/clangd/unittests/ClangdTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Threading.cpp 
b/clang-tools-extra/clangd/Threading.cpp
index 47c91f449d3f..a651b70f02a6 100644
--- a/clang-tools-extra/clangd/Threading.cpp
+++ b/clang-tools-extra/clangd/Threading.cpp
@@ -1,5 +1,6 @@
 #include "Threading.h"
 #include "Trace.h"
+#include "clang/Basic/Stack.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Threading.h"
@@ -86,16 +87,16 @@ void AsyncTaskRunner::runAsync(const llvm::Twine &Name,
 }
   });
 
-  std::thread(
-  [](std::string Name, decltype(Action) Action, decltype(CleanupTask)) {
-llvm::set_thread_name(Name);
-Action();
-// Make sure function stored by Action is destroyed before CleanupTask
-// is run.
-Action = nullptr;
-  },
-  Name.str(), std::move(Action), std::move(CleanupTask))
-  .detach();
+  auto Task = [Name = Name.str(), Action = std::move(Action),
+   Cleanup = std::move(CleanupTask)]() mutable {
+llvm::set_thread_name(Name);
+Action();
+// Make sure function stored by ThreadFunc is destroyed before Cleanup 
runs.
+Action = nullptr;
+  };
+
+  // Ensure our worker threads have big enough stacks to run clang.
+  llvm::llvm_execute_on_thread_async(std::move(Task), clang::DesiredStackSize);
 }
 
 Deadline timeoutSeconds(llvm::Optional Seconds) {

diff  --git a/clang-tools-extra/clangd/unittests/ClangdTests.cpp 
b/clang-tools-extra/clangd/unittests/ClangdTests.cpp
index 6306a3243703..6fc944831567 100644
--- a/clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -1065,6 +1065,27 @@ TEST_F(ClangdVFSTest, 
FallbackWhenWaitingForCompileCommand) {
 Field(&CodeCompletion::Scope, "ns::";
 }
 
+TEST_F(ClangdVFSTest, TestStackOverflow) {
+  MockFSProvider FS;
+  ErrorCheckingCallbacks DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer);
+
+  const char *SourceContents = R"cpp(
+constexpr int foo() { return foo(); }
+static_assert(foo());
+  )cpp";
+
+  auto FooCpp = testPath("foo.cpp");
+  FS.Files[FooCpp] = SourceContents;
+
+  Server.addDocument(FooCpp, SourceContents);
+  ASSERT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";
+  // check that we got a constexpr depth error, and not crashed by stack
+  // overflow
+  EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang



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


[PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP

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



Comment at: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:1678
+// breaks any uses on assumes.
+if (TypeIdMap.count(TypeId))
+  continue;

evgeny777 wrote:
> tejohnson wrote:
> > evgeny777 wrote:
> > > I don't think, I understand this.
> > > It looks like that if (a) we have type.test in the module and (b) we 
> > > don't have vtable definition with corresponding type metadata in the same 
> > > module then we'll remove type.test/assume sequence before even getting to 
> > > ICP. This seems strange in the context of previous discussion because 
> > > virtual function may be called in different module from one where vtable 
> > > is defined, like so:
> > > ```
> > > struct A { virtual int foo() { return 42; } };
> > > 
> > > // calls pA->foo
> > > extern int callFoo(A *pA);
> > > int main() { A a; return callFoo(&a); }
> > > ```
> > > 
> > We will only be able to do ICP this way if we have the target vtable in the 
> > module (similar to how we currently can only do ICP if the target function 
> > is in the module). I anticipate doing something similar for vtable defs as 
> > to what we do for virtual functions, where a fake call edge is added to the 
> > summary based on the value profile results to ensure they are imported 
> > before the LTO backend ICP.
> > We will only be able to do ICP this way if we have the target vtable in the 
> > module (similar to how we currently can only do ICP if the target function 
> > is in the module).
> 
> I was thinking of slightly different approach: it seems you have required 
> type information in combined index together with type name in the module, so 
> you probably can add external declarations of required vtables (this may 
> require promotion) to the module in the ICP pass and run ICP over them. Do 
> you think this can work?
Possibly, but we'd still need to have type metadata on those vtable 
declarations, because the type metadata provides the address point offset which 
is needed in the comparison sequence.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73242



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


[PATCH] D73245: Depend stddef.h to provide max_align_t for C++11 and provide better fallback in

2020-02-04 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg updated this revision to Diff 242317.
joerg retitled this revision from "Don't define std::max_align_t if not used in 
C++03 mode" to "Depend stddef.h to provide max_align_t for C++11 and provide 
better fallback in ".
joerg edited the summary of this revision.
Herald added a subscriber: krytarowski.

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

https://reviews.llvm.org/D73245

Files:
  libcxx/include/cstddef
  libcxx/include/new
  libcxx/include/stddef.h


Index: libcxx/include/stddef.h
===
--- libcxx/include/stddef.h
+++ libcxx/include/stddef.h
@@ -51,12 +51,6 @@
 using std::nullptr_t;
 }
 
-// Re-use the compiler's  max_align_t where possible.
-#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \
-!defined(__DEFINED_max_align_t) && !defined(__NetBSD__)
-typedef long double max_align_t;
-#endif
-
 #endif
 
 #endif  // _LIBCPP_STDDEF_H
Index: libcxx/include/new
===
--- libcxx/include/new
+++ libcxx/include/new
@@ -226,11 +226,21 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#if !defined(_LIBCPP_CXX03_LANG)
+using __libcpp_max_align_t = max_align_t;
+#else
+union __libcpp_max_align_t {
+  void * __f1;
+  long long int __f2;
+  long double __f3;
+};
+#endif
+
 _LIBCPP_CONSTEXPR inline _LIBCPP_INLINE_VISIBILITY bool 
__is_overaligned_for_new(size_t __align) _NOEXCEPT {
 #ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
   return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
 #else
-  return __align > alignment_of::value;
+  return __align > alignment_of<__libcpp_max_align_t>::value;
 #endif
 }
 
Index: libcxx/include/cstddef
===
--- libcxx/include/cstddef
+++ libcxx/include/cstddef
@@ -25,7 +25,7 @@
 
 ptrdiff_t
 size_t
-max_align_t
+max_align_t // C++11
 nullptr_t
 byte // C++17
 
@@ -49,12 +49,8 @@
 using ::ptrdiff_t;
 using ::size_t;
 
-#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
-defined(__DEFINED_max_align_t) || defined(__NetBSD__)
-// Re-use the compiler's  max_align_t where possible.
+#if !defined(_LIBCPP_CXX03_LANG)
 using ::max_align_t;
-#else
-typedef long double max_align_t;
 #endif
 
 _LIBCPP_END_NAMESPACE_STD


Index: libcxx/include/stddef.h
===
--- libcxx/include/stddef.h
+++ libcxx/include/stddef.h
@@ -51,12 +51,6 @@
 using std::nullptr_t;
 }
 
-// Re-use the compiler's  max_align_t where possible.
-#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \
-!defined(__DEFINED_max_align_t) && !defined(__NetBSD__)
-typedef long double max_align_t;
-#endif
-
 #endif
 
 #endif  // _LIBCPP_STDDEF_H
Index: libcxx/include/new
===
--- libcxx/include/new
+++ libcxx/include/new
@@ -226,11 +226,21 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#if !defined(_LIBCPP_CXX03_LANG)
+using __libcpp_max_align_t = max_align_t;
+#else
+union __libcpp_max_align_t {
+  void * __f1;
+  long long int __f2;
+  long double __f3;
+};
+#endif
+
 _LIBCPP_CONSTEXPR inline _LIBCPP_INLINE_VISIBILITY bool __is_overaligned_for_new(size_t __align) _NOEXCEPT {
 #ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
   return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
 #else
-  return __align > alignment_of::value;
+  return __align > alignment_of<__libcpp_max_align_t>::value;
 #endif
 }
 
Index: libcxx/include/cstddef
===
--- libcxx/include/cstddef
+++ libcxx/include/cstddef
@@ -25,7 +25,7 @@
 
 ptrdiff_t
 size_t
-max_align_t
+max_align_t // C++11
 nullptr_t
 byte // C++17
 
@@ -49,12 +49,8 @@
 using ::ptrdiff_t;
 using ::size_t;
 
-#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
-defined(__DEFINED_max_align_t) || defined(__NetBSD__)
-// Re-use the compiler's  max_align_t where possible.
+#if !defined(_LIBCPP_CXX03_LANG)
 using ::max_align_t;
-#else
-typedef long double max_align_t;
 #endif
 
 _LIBCPP_END_NAMESPACE_STD
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50993: [clangd] Increase stack size of the new threads on macOS

2020-02-04 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.
Herald added a subscriber: usaxena95.

Sorry we let this last piece get stuck in limbo, of course I was reminded of it 
when someone else hit this problem.

Thanks for working on this @Dmitry.Kozhevnikov, I'll update for c++14 and 
(finally) land it now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D50993



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


[PATCH] D50993: [clangd] Increase stack size of the new threads on macOS

2020-02-04 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG69a39dc1f0d0: [clangd] Increase stack size of the new 
threads on macOS (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D50993?vs=200432&id=242319#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D50993

Files:
  clang-tools-extra/clangd/Threading.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp


Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -1065,6 +1065,27 @@
 Field(&CodeCompletion::Scope, "ns::";
 }
 
+TEST_F(ClangdVFSTest, TestStackOverflow) {
+  MockFSProvider FS;
+  ErrorCheckingCallbacks DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer);
+
+  const char *SourceContents = R"cpp(
+constexpr int foo() { return foo(); }
+static_assert(foo());
+  )cpp";
+
+  auto FooCpp = testPath("foo.cpp");
+  FS.Files[FooCpp] = SourceContents;
+
+  Server.addDocument(FooCpp, SourceContents);
+  ASSERT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";
+  // check that we got a constexpr depth error, and not crashed by stack
+  // overflow
+  EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Threading.cpp
===
--- clang-tools-extra/clangd/Threading.cpp
+++ clang-tools-extra/clangd/Threading.cpp
@@ -1,5 +1,6 @@
 #include "Threading.h"
 #include "Trace.h"
+#include "clang/Basic/Stack.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Threading.h"
@@ -86,16 +87,16 @@
 }
   });
 
-  std::thread(
-  [](std::string Name, decltype(Action) Action, decltype(CleanupTask)) {
-llvm::set_thread_name(Name);
-Action();
-// Make sure function stored by Action is destroyed before CleanupTask
-// is run.
-Action = nullptr;
-  },
-  Name.str(), std::move(Action), std::move(CleanupTask))
-  .detach();
+  auto Task = [Name = Name.str(), Action = std::move(Action),
+   Cleanup = std::move(CleanupTask)]() mutable {
+llvm::set_thread_name(Name);
+Action();
+// Make sure function stored by ThreadFunc is destroyed before Cleanup 
runs.
+Action = nullptr;
+  };
+
+  // Ensure our worker threads have big enough stacks to run clang.
+  llvm::llvm_execute_on_thread_async(std::move(Task), clang::DesiredStackSize);
 }
 
 Deadline timeoutSeconds(llvm::Optional Seconds) {


Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -1065,6 +1065,27 @@
 Field(&CodeCompletion::Scope, "ns::";
 }
 
+TEST_F(ClangdVFSTest, TestStackOverflow) {
+  MockFSProvider FS;
+  ErrorCheckingCallbacks DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer);
+
+  const char *SourceContents = R"cpp(
+constexpr int foo() { return foo(); }
+static_assert(foo());
+  )cpp";
+
+  auto FooCpp = testPath("foo.cpp");
+  FS.Files[FooCpp] = SourceContents;
+
+  Server.addDocument(FooCpp, SourceContents);
+  ASSERT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";
+  // check that we got a constexpr depth error, and not crashed by stack
+  // overflow
+  EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Threading.cpp
===
--- clang-tools-extra/clangd/Threading.cpp
+++ clang-tools-extra/clangd/Threading.cpp
@@ -1,5 +1,6 @@
 #include "Threading.h"
 #include "Trace.h"
+#include "clang/Basic/Stack.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Threading.h"
@@ -86,16 +87,16 @@
 }
   });
 
-  std::thread(
-  [](std::string Name, decltype(Action) Action, decltype(CleanupTask)) {
-llvm::set_thread_name(Name);
-Action();
-// Make sure function stored by Action is destroyed before CleanupTask
-// is run.
-Action = nullptr;
-  },
-  Name.str(), std::move(Action), std::move(CleanupTask))
-  .detach();
+  auto Task = [Name = Name.str(), Action = std::move(Action),
+   Cleanup = std::move(CleanupTask)]() mutable {
+llvm::set_thread_name(Name);
+Action();
+// Make sure functio

[clang-tools-extra] ed98994 - Revert "[clangd] Mechanism to make update debounce responsive to rebuild speed."

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

Author: Sam McCall
Date: 2020-02-04T15:34:10+01:00
New Revision: ed98994f64b8fe6443aef57a5faa953e86d9fc0e

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

LOG: Revert "[clangd] Mechanism to make update debounce responsive to rebuild 
speed."

This reverts commit 92570718a86cc4c23108b596002114ab25857b14.
Breaking tests: http://45.33.8.238/linux/9296/step_9.txt

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 3e22a4dfe667..00da7af06741 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -106,7 +106,7 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
 
 ClangdServer::Options ClangdServer::optsForTest() {
   ClangdServer::Options Opts;
-  Opts.UpdateDebounce = DebouncePolicy::fixed(/*zero*/ {});
+  Opts.UpdateDebounce = std::chrono::steady_clock::duration::zero(); // Faster!
   Opts.StorePreamblesInMemory = true;
   Opts.AsyncThreadsCount = 4; // Consistent!
   Opts.SemanticHighlighting = true;

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 3c3505295a75..2d0957f441bb 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -130,8 +130,8 @@ class ClangdServer {
 llvm::Optional ResourceDir = llvm::None;
 
 /// Time to wait after a new file version before computing diagnostics.
-DebouncePolicy UpdateDebounce =
-DebouncePolicy::fixed(std::chrono::milliseconds(500));
+std::chrono::steady_clock::duration UpdateDebounce =
+std::chrono::milliseconds(500);
 
 bool SuggestMissingIncludes = false;
 

diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp 
b/clang-tools-extra/clangd/TUScheduler.cpp
index 237c4c4d7ba6..9218ae9a03ce 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -61,7 +61,6 @@
 #include "llvm/Support/Threading.h"
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -165,7 +164,7 @@ class ASTWorker {
   friend class ASTWorkerHandle;
   ASTWorker(PathRef FileName, const GlobalCompilationDatabase &CDB,
 TUScheduler::ASTCache &LRUCache, Semaphore &Barrier, bool RunSync,
-DebouncePolicy UpdateDebounce, bool StorePreamblesInMemory,
+steady_clock::duration UpdateDebounce, bool StorePreamblesInMemory,
 ParsingCallbacks &Callbacks);
 
 public:
@@ -177,7 +176,7 @@ class ASTWorker {
   static ASTWorkerHandle
   create(PathRef FileName, const GlobalCompilationDatabase &CDB,
  TUScheduler::ASTCache &IdleASTs, AsyncTaskRunner *Tasks,
- Semaphore &Barrier, DebouncePolicy UpdateDebounce,
+ Semaphore &Barrier, steady_clock::duration UpdateDebounce,
  bool StorePreamblesInMemory, ParsingCallbacks &Callbacks);
   ~ASTWorker();
 
@@ -243,7 +242,7 @@ class ASTWorker {
   TUScheduler::ASTCache &IdleASTs;
   const bool RunSync;
   /// Time to wait after an update to see whether another update obsoletes it.
-  const DebouncePolicy UpdateDebounce;
+  const steady_clock::duration UpdateDebounce;
   /// File that ASTWorker is responsible for.
   const Path FileName;
   const GlobalCompilationDatabase &CDB;
@@ -264,9 +263,6 @@ class ASTWorker {
   /// be consumed by clients of ASTWorker.
   std::shared_ptr FileInputs; /* GUARDED_BY(Mutex) 
*/
   std::shared_ptr LastBuiltPreamble; /* GUARDED_BY(Mutex) 
*/
-  /// Times of recent AST rebuilds, used for UpdateDebounce computation.
-  llvm::SmallVector
-  RebuildTimes; /* GUARDED_BY(Mutex) */
   /// Becomes ready when the first preamble build finishes.
   Notification PreambleWasBuilt;
   /// Set to true to signal run() to finish processing.
@@ -330,7 +326,7 @@ class ASTWorkerHandle {
 ASTWorkerHandle
 ASTWorker::create(PathRef FileName, const GlobalCompilationDatabase &CDB,
   TUScheduler::ASTCache &IdleASTs, AsyncTaskRunner *Tasks,
-  Semaphore &Barrier, DebouncePolicy UpdateDebounce,
+  Semaphore &Barrier, steady_clock::duration UpdateDebounce,
   bool StorePreamblesInMemory, ParsingCallbacks &Callbacks) {
   std::shared_ptr Worker(
   new ASTWorker(FileName, CDB, IdleASTs, Barrier, /*RunSync=*/!Tasks,
@@ -344,7 +340,7 @@ ASTWorker::create(PathRef FileName, const 
GlobalCompilationDatabase &CDB,
 
 ASTWorker::ASTWorker(PathRef FileName, const GlobalCompilationDatabase &CDB,
  TUScheduler::ASTCache 

[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-02-04 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp:731
+  }
+  return C.getNoteTag([Text, Name](BugReport &BR) -> std::string {
+  SmallString<256> Msg;

NoQ wrote:
> You'll need to check whether the container is actually of interest to the bug 
> report. We don't want notes to be added about changes to irrelevant 
> containers.
> 
> You can use a combination of "Report `BR` was emitted by one of the iterator 
> checkers" and "The memory region of the container is marked as interesting" 
> (while also actually marking it as interesting in the checker).
> 
> Ideally we should instead make a new generic storage inside the `BugReport` 
> object, in order to pass down the interesting information from the call site 
> of `emitReport` ("Hi, i'm an iterator checker who emitted this report and i'm 
> interested in changes made to the size of this container").
Are you sure in this? I already wondered how it works so I added a test that 
checks one container and changes another one and there were no note tags 
displayed for the one we did not check but change. See the last test.


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

https://reviews.llvm.org/D73720



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


[PATCH] D73780: [clangd] Separate protobuf-related functions to a dedicated file.

2020-02-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D73780#1851920 , @hokein wrote:

> In D73780#1851654 , @kadircet wrote:
>
> > LG. I might be missing some context though, what's the reasoning behind? 
> > Because, I think it is not necessary to treat protobufs differently.
> >
> > It might be sensible to have a more generic `isSymbolFromGeneratedFile` 
> > filter, but also for this one I don't see any developments in the near 
> > future.
>
>
> the motivation of this change is that we will blacklist the proto symbols for 
> rename, we need a place to put protobuf-related functions (and we might 
> improve clangd on better supporting protobuf symbol navigation this year) , I 
> think it is sensible to lift them into a separate file.


if that's the case, I would still go with having a more generic 
`isGeneratedSymbol`, that only supports filtering protobuf-related symbols for 
now. and would rather put it into AST.h


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73780



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


[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-02-04 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 242323.
baloghadamsoftware added a comment.

`const SVal &` -> `SVal`


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

https://reviews.llvm.org/D73720

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/test/Analysis/container-modeling.cpp

Index: clang/test/Analysis/container-modeling.cpp
===
--- clang/test/Analysis/container-modeling.cpp
+++ clang/test/Analysis/container-modeling.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -analyzer-output=text -verify
 
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -analyzer-output=text -verify
 
 // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true %s 2>&1 | FileCheck %s
 
@@ -20,14 +20,16 @@
   V.begin();
 
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
-  clang_analyzer_express(clang_analyzer_container_begin(V)); //expected-warning{{$V.begin()}}
+  clang_analyzer_express(clang_analyzer_container_begin(V)); // expected-warning{{$V.begin()}}
+ // expected-note@-1{{$V.begin()}}
 }
 
 void end(const std::vector &V) {
   V.end();
 
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
-  clang_analyzer_express(clang_analyzer_container_end(V)); //expected-warning{{$V.end()}}
+  clang_analyzer_express(clang_analyzer_container_end(V)); // expected-warning{{$V.end()}}
+   // expected-note@-1{{$V.end()}}
 }
 
 
@@ -48,8 +50,10 @@
   long B2 = clang_analyzer_container_begin(V2);
   long E2 = clang_analyzer_container_end(V2);
   V1 = std::move(V2);
-  clang_analyzer_eval(clang_analyzer_container_begin(V1) == B2); //expected-warning{{TRUE}}
-  clang_analyzer_eval(clang_analyzer_container_end(V2) == E2); //expected-warning{{TRUE}}
+  clang_analyzer_eval(clang_analyzer_container_begin(V1) == B2); // expected-warning{{TRUE}}
+ // expected-note@-1{{TRUE}}
+  clang_analyzer_eval(clang_analyzer_container_end(V2) == E2); // expected-warning{{TRUE}}
+   // expected-note@-1{{TRUE}}
 }
 
 
@@ -70,10 +74,13 @@
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
 
-  V.push_back(n);
+  V.push_back(n); // expected-note{{Container 'V' extended to the right by 1 position}}
+  // expected-note@-1{{Container 'V' extended to the right by 1 position}}
 
   clang_analyzer_express(clang_analyzer_container_begin(V)); // expected-warning{{$V.begin()}}
+ // expected-note@-1{{$V.begin()}}
   clang_analyzer_express(clang_analyzer_container_end(V)); // expected-warning{{$V.end() + 1}}
+   // expected-note@-1{{$V.end() + 1}}
 }
 
 /// emplace_back()
@@ -88,10 +95,14 @@
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
 
-  V.emplace_back(n);
+  V.emplace_back(n); // expected-note{{Container 'V' extended to the right by 1 position}}
+ // expected-note@-1{{Container 'V' extended to the right by 1 position}}
+
 
   clang_analyzer_express(clang_analyzer_container_begin(V)); // expected-warning{{$V.begin()}}
+ // expected-note@-1{{$V.begin()}}
   clang_analyzer_express(clang_analyzer_container_end(V)); // expected-warning{{$V.end() + 1}}
+   // expected

[PATCH] D73873: [clangd] Mechanism to make update debounce responsive to rebuild speed.

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

In D73873#1856880 , @thakis wrote:

> This seems to break tests: http://45.33.8.238/linux/9296/step_9.txt


Thanks, I've reverted to take a look. It's weird though:

- don't see this on any lab buildbots or locally
- the lit test stack traces are all in one specific codepath (in selectiontree) 
that's totally unrelated
- the unit test traces aren't symbolized, but if it's the same stack then they 
never even use TUScheduler

So possible i'm tickling something latent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73873



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


[PATCH] D73951: [Clang] [Driver]Add logic to search for flang frontend

2020-02-04 Thread David Truby via Phabricator via cfe-commits
DavidTruby requested changes to this revision.
DavidTruby added a comment.
This revision now requires changes to proceed.

If what I've suggested above doesn't work then the patch lgtm as is




Comment at: clang/lib/Driver/Driver.cpp:131
   CCLogDiagnostics(false), CCGenDiagnostics(false),
-  TargetTriple(TargetTriple), CCCGenericGCCName(""), Saver(Alloc),
-  CheckInputsExist(true), GenReproducer(false),
+  TargetTriple(TargetTriple), CCCGenericGCCName(""), 
FFCGenericFortranName(""),
+  Saver(Alloc), CheckInputsExist(true), GenReproducer(false),

I think you can default this to "flang" here instead of "", and then you don't 
need to check if it is empty later (see my later comment)



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:13-14
 
 #include "clang/Driver/Options.h"
-
 #include 
 

Nit: stray space here



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:71-77
+  const std::string &customFortranName = D.getFFCGenericFortranName();
+  const char *FortranName;
+  if (!customFortranName.empty())
+FortranName = customFortranName.c_str();
+  else FortranName = "flang";
+
+  const char *Exec = 
Args.MakeArgString(getToolChain().GetProgramPath(FortranName));

I think here you can just do `FortranName = D.getFFCGenericFortranName();`
and then 
`getToolChain().GetProgramPath(FortranName.c_str())`
as long as you have defaulted to "flang" earlier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73951



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


[PATCH] D73965: [clang] Add matcher to identify macro expansions.

2020-02-04 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: gribozavr.
Herald added a project: clang.

This revision adds a matcher `isExpandedFromMacro` that determines whether a
statement is (transitively) expanded from a given macro.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73965

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -18,6 +18,120 @@
 namespace clang {
 namespace ast_matchers {
 
+TEST(IsExpandedFromMacro, ShouldMatchInFile) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+void Test() { MY_MACRO(4); }
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchNested) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+#define WRAPPER(a) MY_MACRO(a)
+void Test() { WRAPPER(4); }
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchIntermediate) {
+  std::string input = R"cc(
+#define IMPL(a) (4 + (a))
+#define MY_MACRO(a) IMPL(a)
+#define WRAPPER(a) MY_MACRO(a)
+void Test() { WRAPPER(4); }
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchTransitive) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+#define WRAPPER(a) MY_MACRO(a)
+void Test() { WRAPPER(4); }
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("WRAPPER";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchArgument) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+void Test() {
+  int x = 5;
+  MY_MACRO(x);
+}
+  )cc";
+  EXPECT_TRUE(matches(input, declRefExpr(isExpandedFromMacro("MY_MACRO";
+}
+
+// Like IsExpandedFromMacroShouldMatchArgumentMacro, but the argument is itself
+// a macro.
+TEST(IsExpandedFromMacro, ShouldMatchArgumentMacroExpansion) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+#define IDENTITY(a) (a)
+void Test() {
+  IDENTITY(MY_MACRO(2));
+}
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("IDENTITY";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchWhenInArgument) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+#define IDENTITY(a) (a)
+void Test() {
+  IDENTITY(MY_MACRO(2));
+}
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchObjectMacro) {
+  std::string input = R"cc(
+#define PLUS (2 + 2)
+void Test() {
+  PLUS;
+}
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("PLUS";
+}
+
+TEST(IsExpandedFromMacro, ShouldNotMatchBeginOnly) {
+  std::string input = R"cc(
+#define ONE_PLUS 1+
+  void Test() { ONE_PLUS 4; }
+  )cc";
+  EXPECT_TRUE(
+  notMatches(input, binaryOperator(isExpandedFromMacro("ONE_PLUS";
+}
+
+TEST(IsExpandedFromMacro, ShouldNotMatchEndOnly) {
+  std::string input = R"cc(
+#define PLUS_ONE +1
+  void Test() { 4 PLUS_ONE; }
+  )cc";
+  EXPECT_TRUE(
+  notMatches(input, binaryOperator(isExpandedFromMacro("PLUS_ONE";
+}
+
+TEST(IsExpandedFromMacro, ShouldNotMatchDifferentMacro) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+void Test() { MY_MACRO(4); }
+  )cc";
+  EXPECT_TRUE(notMatches(input, binaryOperator(isExpandedFromMacro("OTHER";
+}
+
+TEST(IsExpandedFromMacro, ShouldNotMatchDifferentInstances) {
+  std::string input = R"cc(
+#define FOUR 4
+void Test() { FOUR + FOUR; }
+  )cc";
+  EXPECT_TRUE(notMatches(input, binaryOperator(isExpandedFromMacro("FOUR";
+}
 
 TEST(AllOf, AllOverloadsWork) {
   const char Program[] =
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -18,6 +18,7 @@
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Lex/Lexer.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/None.h"
@@ -592,6 +593,38 @@
   return matchesNodeFullFast(Node);
 }
 
+// Checks whether \p Loc points to a token with source text of \p TokenText.
+static bool isTokenAtLoc(const SourceManager &SM, const LangOptions &LangOpts,
+ StringRef Text, SourceLocation Loc) {
+  llvm::SmallString<16> Buffer;
+  bool Invalid = false;
+  // Since `Loc` may point into an expa

[PATCH] D73966: [analyzer][WIP] Add 10.0.0 release notes.

2020-02-04 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a reviewer: dcoughlin.
Szelethus marked an inline comment as done.
Szelethus added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:427
+
+- ObjectiveC++ changes:
+

I tried my best here but didn't get far. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73966



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


[PATCH] D73967: Implement _ExtInt as an extended int type specifier.

2020-02-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: martong, aaron.ballman, mgehre, mibintc, 
mikhail.ramalho, arichardson, dmgreen, ebevhan, riccibruno.
Herald added subscribers: arphaman, rnkovacs, kosarev.

Introduction/Motivation:
LLVM-IR supports integers of non-power-of-2 bitwidth, in the iN syntax.
Integers of non-power-of-two aren't particularly interesting or useful
on most hardware, so much so that no language in Clang has been
motivated to expose it before.

However, in the case of FPGA hardware normal integer types where the
full bitwidth isn't used, is extremely wasteful and has severe
performance/space concerns.  Because of this, Intel has introduced this
functionality in the High Level Synthesis compiler[0]
under the name "Arbitrary Precision Integer" (ap_int for short). This
has been extremely useful and effective for our users, permitting them
to optimize their storage and operation space on an architecture where
both can be extremely expensive.

We are proposing upstreaming a more palatable version of this to the
community, in the form of this proposal and accompanying patch.  We are
proposing the syntax _ExtInt(N).  We intend to propose this to the WG14
committee[1], and the underscore-capital seems like the active direction
for a WG14 paper's acceptance.  An alternative that Richard Smith
suggested on the initial review was __int(N), however we believe that
is much less acceptable by WG14.  We considered _Int, however _Int is
used as an identifier in libstdc++ and there is no good way to fall
back to an identifier (since _Int(5) is indistinguishable from an
unnamed initializer of a template type named _Int).

[0]https://www.intel.com/content/www/us/en/software/programmable/quartus-prime/hls-compiler.html)
[1]http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2472.pdf


https://reviews.llvm.org/D73967

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Basic/TypeNodes.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/TypeBitCodes.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenTBAA.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/CodeGenTypes.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGen/ext-int-sanitizer.cpp
  clang/test/CodeGen/ext-int.cpp
  clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp
  clang/test/CodeGenOpenCL/ext-int-shift.cl
  clang/test/SemaCXX/ext-int.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1804,6 +1804,8 @@
 DEFAULT_TYPELOC_IMPL(SubstTemplateTypeParm, Type)
 DEFAULT_TYPELOC_IMPL(SubstTemplateTypeParmPack, Type)
 DEFAULT_TYPELOC_IMPL(Auto, Type)
+DEFAULT_TYPELOC_IMPL(ExtInt, Type)
+DEFAULT_TYPELOC_IMPL(DependentExtInt, Type)
 
 bool CursorVisitor::VisitCXXRecordDecl(CXXRecordDecl *D) {
   // Visit the nested-name-specifier, if present.
Index: clang/test/SemaCXX/ext-int.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/ext-int.cpp
@@ -0,0 +1,228 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template
+struct HasExtInt {
+  _ExtInt(Bounds) b;
+  unsigned _ExtInt(Bounds) b2;
+};
+
+// Delcaring variables:
+_ExtInt(33) Declarations(_ExtInt(48) &Param) { // Useable in params and returns.
+  short _ExtInt(43) a; // expected-error {{'short _ExtInt' is invalid}}
+  _ExtInt(43) long b;  // expected-error {{'long _ExtInt' is invalid}}
+
+  // These should all be fine:
+  const

[PATCH] D73966: [analyzer][WIP] Add 10.0.0 release notes.

2020-02-04 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: hans, NoQ, Charusso, xazax.hun, baloghadamsoftware, 
balazske, gamesh411, rnkovacs.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, phosek, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, szepet, whisperity.
Szelethus added a reviewer: dcoughlin.
Szelethus marked an inline comment as done.
Szelethus added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:427
+
+- ObjectiveC++ changes:
+

I tried my best here but didn't get far. :)


I was MIA for a couple months, so I'm very unsure whether I caught everything, 
but here is what happened since 9.0.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73966

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -402,10 +402,31 @@
 Static Analyzer
 ---
 
+- New checker: ``fuchsia.HandleChecker`` to detect leaks related to Fuchsia
+  handles.
+
+- New checker: ``alpha.plusplus.PlacementNew`` to detect whether the storage
+  provided for default placement new is sufficiently large.
+
 - The Clang analyzer checker ``DeadStores`` gets a new option called
   ``WarnForDeadNestedAssignments`` to detect nested dead assignments
   (enabled by default).
-- ...
+
+- Condition values that greatly affect the occurance of a bug are now far 
better
+  explained in bug reports (further reading on the related
+  `GSoC'19 summary page `_).
+
+- Despite still in being in alpha stage, checkers implementing taint analyses
+  and C++ iterator rules were improved greatly.
+
+- Analyses on LLVM's own source code are far more precise due to the modeling 
of
+  several LLVM specific techniques, like its custom RTTI, informing the 
analyzer
+  of the return values of core functions, and much more (further reading on the
+  related `GSoC'19 summary page 
`_)
 .
+
+- ObjectiveC++ changes:
+
+- Numerous smaller false positive fixes.
 
 .. _release-notes-ubsan:
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -402,10 +402,31 @@
 Static Analyzer
 ---
 
+- New checker: ``fuchsia.HandleChecker`` to detect leaks related to Fuchsia
+  handles.
+
+- New checker: ``alpha.plusplus.PlacementNew`` to detect whether the storage
+  provided for default placement new is sufficiently large.
+
 - The Clang analyzer checker ``DeadStores`` gets a new option called
   ``WarnForDeadNestedAssignments`` to detect nested dead assignments
   (enabled by default).
-- ...
+
+- Condition values that greatly affect the occurance of a bug are now far better
+  explained in bug reports (further reading on the related
+  `GSoC'19 summary page `_).
+
+- Despite still in being in alpha stage, checkers implementing taint analyses
+  and C++ iterator rules were improved greatly.
+
+- Analyses on LLVM's own source code are far more precise due to the modeling of
+  several LLVM specific techniques, like its custom RTTI, informing the analyzer
+  of the return values of core functions, and much more (further reading on the
+  related `GSoC'19 summary page `_) .
+
+- ObjectiveC++ changes:
+
+- Numerous smaller false positive fixes.
 
 .. _release-notes-ubsan:
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59105: [RFC] Create an Arbitrary Precision Integer Type.

2020-02-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane abandoned this revision.
erichkeane added a comment.

Superceded by: https://reviews.llvm.org/D73967


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

https://reviews.llvm.org/D59105



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


[PATCH] D73453: Preserve -nostdinc and --sysroot when calling query driver

2020-02-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

it seems like the last diff is same as the previous one, maybe you've uploaded 
the wrong diff ?


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

https://reviews.llvm.org/D73453



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


[PATCH] D73873: [clangd] Mechanism to make update debounce responsive to rebuild speed.

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

I agree it's a bit strange. The linux bot didn't recover after the revert 
either, so something's amiss.

My Win bot has been hanging since this landed and I just CRD'd in and it's 
hanging in check-clangd and there are tens of ClangdTests processes hanging 
around and doing nothing.

On the more official win bot, instead the link of ClangdTests has been failing 
since this landed, which on Windows is likely caused by the processes still 
hanging around 
(http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/14120/steps/stage%201%20check/logs/stdio).
 This is the first bad build: 
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/14113/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73873



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


[PATCH] D68923: Don't warn about missing declarations for partial template specializations

2020-02-04 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D68923#1853527 , @aaronpuchert 
wrote:

> In D68923#1853303 , @aaron.ballman 
> wrote:
>
> > I think it's a simple enough fix that it may be worth it, but it isn't 
> > fixing a regression in behavior so it's not critical.
>
>
> Exactly, it would just be a bug fix.


Actually it is a regression, but one that we already had in Clang 9. Try 
 this code:

  template 
  constexpr bool X = true;
  
  template 
  constexpr bool X = false;

Clang 9 emits the following false positive warning, which Clang 8 doesn't emit:

  :5:16: warning: no previous extern declaration for non-static 
variable 'X' [-Wmissing-variable-declarations]
  constexpr bool X = false;
 ^
  :5:11: note: declare 'static' if the variable is not intended to be 
used outside of this translation unit
  constexpr bool X = false;
^


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68923



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


[clang] 563e847 - [SystemZ] Support -msoft-float

2020-02-04 Thread Jonas Paulsson via cfe-commits

Author: Jonas Paulsson
Date: 2020-02-04T10:32:45-05:00
New Revision: 563e84790f41f9f71c3cb10d0bb9feaa7a339c36

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

LOG: [SystemZ]  Support -msoft-float

This is needed when building the Linux kernel.

Review: Ulrich Weigand

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

Added: 
clang/test/Driver/systemz-float-01.c
clang/test/Driver/systemz-float-02.c
llvm/test/CodeGen/SystemZ/soft-float-01.ll
llvm/test/CodeGen/SystemZ/soft-float-02.ll
llvm/test/CodeGen/SystemZ/soft-float-03.ll
llvm/test/CodeGen/SystemZ/soft-float-04.ll
llvm/test/CodeGen/SystemZ/soft-float-args.ll
llvm/test/CodeGen/SystemZ/soft-float-inline-asm-01.ll
llvm/test/CodeGen/SystemZ/soft-float-inline-asm-02.ll
llvm/test/CodeGen/SystemZ/soft-float-inline-asm-03.ll

Modified: 
clang/lib/Basic/Targets/SystemZ.h
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
clang/lib/Driver/ToolChains/Arch/SystemZ.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/systemz-abi.c
clang/test/CodeGen/systemz-abi.cpp
clang/test/CodeGen/target-data.c
llvm/lib/Target/SystemZ/SystemZFeatures.td
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
llvm/lib/Target/SystemZ/SystemZISelLowering.h
llvm/lib/Target/SystemZ/SystemZSubtarget.cpp
llvm/lib/Target/SystemZ/SystemZSubtarget.h
llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
llvm/test/CodeGen/SystemZ/args-07.ll
llvm/test/CodeGen/SystemZ/vec-abi-align.ll
llvm/test/CodeGen/SystemZ/vec-args-06.ll
llvm/test/CodeGen/SystemZ/vec-args-07.ll

Removed: 




diff  --git a/clang/lib/Basic/Targets/SystemZ.h 
b/clang/lib/Basic/Targets/SystemZ.h
index e751806f4747..9f7ce62d2ce6 100644
--- a/clang/lib/Basic/Targets/SystemZ.h
+++ b/clang/lib/Basic/Targets/SystemZ.h
@@ -29,11 +29,12 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public 
TargetInfo {
   int ISARevision;
   bool HasTransactionalExecution;
   bool HasVector;
+  bool SoftFloat;
 
 public:
   SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), CPU("z10"), ISARevision(8),
-HasTransactionalExecution(false), HasVector(false) {
+HasTransactionalExecution(false), HasVector(false), SoftFloat(false) {
 IntMaxType = SignedLong;
 Int64Type = SignedLong;
 TLSSupported = true;
@@ -109,12 +110,17 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public 
TargetInfo {
 DiagnosticsEngine &Diags) override {
 HasTransactionalExecution = false;
 HasVector = false;
+SoftFloat = false;
 for (const auto &Feature : Features) {
   if (Feature == "+transactional-execution")
 HasTransactionalExecution = true;
   else if (Feature == "+vector")
 HasVector = true;
+  else if (Feature == "+soft-float")
+SoftFloat = true;
 }
+HasVector &= !SoftFloat;
+
 // If we use the vector ABI, vector types are 64-bit aligned.
 if (HasVector) {
   MaxVectorAlign = 64;

diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index c803785435ff..94d0f3dac70a 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -6565,10 +6565,11 @@ namespace {
 
 class SystemZABIInfo : public SwiftABIInfo {
   bool HasVector;
+  bool IsSoftFloatABI;
 
 public:
-  SystemZABIInfo(CodeGenTypes &CGT, bool HV)
-: SwiftABIInfo(CGT), HasVector(HV) {}
+  SystemZABIInfo(CodeGenTypes &CGT, bool HV, bool SF)
+: SwiftABIInfo(CGT), HasVector(HV), IsSoftFloatABI(SF) {}
 
   bool isPromotableIntegerType(QualType Ty) const;
   bool isCompoundType(QualType Ty) const;
@@ -6600,8 +6601,8 @@ class SystemZABIInfo : public SwiftABIInfo {
 
 class SystemZTargetCodeGenInfo : public TargetCodeGenInfo {
 public:
-  SystemZTargetCodeGenInfo(CodeGenTypes &CGT, bool HasVector)
-: TargetCodeGenInfo(new SystemZABIInfo(CGT, HasVector)) {}
+  SystemZTargetCodeGenInfo(CodeGenTypes &CGT, bool HasVector, bool 
SoftFloatABI)
+: TargetCodeGenInfo(new SystemZABIInfo(CGT, HasVector, SoftFloatABI)) {}
 };
 
 }
@@ -6640,6 +6641,9 @@ bool SystemZABIInfo::isVectorArgumentType(QualType Ty) 
const {
 }
 
 bool SystemZABIInfo::isFPArgumentType(QualType Ty) const {
+  if (IsSoftFloatABI)
+return false;
+
   if (const BuiltinType *BT = Ty->getAs())
 switch (BT->getKind()) {
 case BuiltinType::Float:
@@ -6725,7 +6729,7 @@ Address SystemZABIInfo::EmitVAArg(CodeGenFunction &CGF, 
Address VAListAddr,
   } else {
 if (AI.getCoerceToType())
   ArgTy = AI.getCoerceToType();
-InFPRs = ArgTy->isFloatTy() || ArgTy->isDoubleTy();
+InFPRs = (!IsSoftFloatABI && (ArgTy->isFloatTy() || ArgTy->isDoubleT

[PATCH] D73965: [clang] Add matcher to identify macro expansions.

2020-02-04 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 242335.
ymandel added a comment.

Fix to get it to link correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73965

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -18,6 +18,120 @@
 namespace clang {
 namespace ast_matchers {
 
+TEST(IsExpandedFromMacro, ShouldMatchInFile) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+void Test() { MY_MACRO(4); }
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchNested) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+#define WRAPPER(a) MY_MACRO(a)
+void Test() { WRAPPER(4); }
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchIntermediate) {
+  std::string input = R"cc(
+#define IMPL(a) (4 + (a))
+#define MY_MACRO(a) IMPL(a)
+#define WRAPPER(a) MY_MACRO(a)
+void Test() { WRAPPER(4); }
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchTransitive) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+#define WRAPPER(a) MY_MACRO(a)
+void Test() { WRAPPER(4); }
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("WRAPPER";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchArgument) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+void Test() {
+  int x = 5;
+  MY_MACRO(x);
+}
+  )cc";
+  EXPECT_TRUE(matches(input, declRefExpr(isExpandedFromMacro("MY_MACRO";
+}
+
+// Like IsExpandedFromMacroShouldMatchArgumentMacro, but the argument is itself
+// a macro.
+TEST(IsExpandedFromMacro, ShouldMatchArgumentMacroExpansion) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+#define IDENTITY(a) (a)
+void Test() {
+  IDENTITY(MY_MACRO(2));
+}
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("IDENTITY";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchWhenInArgument) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+#define IDENTITY(a) (a)
+void Test() {
+  IDENTITY(MY_MACRO(2));
+}
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchObjectMacro) {
+  std::string input = R"cc(
+#define PLUS (2 + 2)
+void Test() {
+  PLUS;
+}
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("PLUS";
+}
+
+TEST(IsExpandedFromMacro, ShouldNotMatchBeginOnly) {
+  std::string input = R"cc(
+#define ONE_PLUS 1+
+  void Test() { ONE_PLUS 4; }
+  )cc";
+  EXPECT_TRUE(
+  notMatches(input, binaryOperator(isExpandedFromMacro("ONE_PLUS";
+}
+
+TEST(IsExpandedFromMacro, ShouldNotMatchEndOnly) {
+  std::string input = R"cc(
+#define PLUS_ONE +1
+  void Test() { 4 PLUS_ONE; }
+  )cc";
+  EXPECT_TRUE(
+  notMatches(input, binaryOperator(isExpandedFromMacro("PLUS_ONE";
+}
+
+TEST(IsExpandedFromMacro, ShouldNotMatchDifferentMacro) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+void Test() { MY_MACRO(4); }
+  )cc";
+  EXPECT_TRUE(notMatches(input, binaryOperator(isExpandedFromMacro("OTHER";
+}
+
+TEST(IsExpandedFromMacro, ShouldNotMatchDifferentInstances) {
+  std::string input = R"cc(
+#define FOUR 4
+void Test() { FOUR + FOUR; }
+  )cc";
+  EXPECT_TRUE(notMatches(input, binaryOperator(isExpandedFromMacro("FOUR";
+}
 
 TEST(AllOf, AllOverloadsWork) {
   const char Program[] =
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -18,6 +18,7 @@
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Lex/Lexer.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/None.h"
@@ -592,6 +593,38 @@
   return matchesNodeFullFast(Node);
 }
 
+// Checks whether \p Loc points to a token with source text of \p TokenText.
+static bool isTokenAtLoc(const SourceManager &SM, const LangOptions &LangOpts,
+ StringRef Text, SourceLocation Loc) {
+  llvm::SmallString<16> Buffer;
+  bool Invalid = false;
+  // Since `Loc` may point into an expansion buffer, which has no corresponding
+  // source, we need 

[PATCH] D73453: Preserve -nostdinc and --sysroot when calling query driver

2020-02-04 Thread Tobias Pisani via Phabricator via cfe-commits
topisani updated this revision to Diff 242334.
topisani added a comment.

Woops yeah, still getting used to using git like this


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

https://reviews.llvm.org/D73453

Files:
  clang-tools-extra/clangd/QueryDriverDatabase.cpp
  clang-tools-extra/clangd/test/system-include-extractor.test

Index: clang-tools-extra/clangd/test/system-include-extractor.test
===
--- clang-tools-extra/clangd/test/system-include-extractor.test
+++ clang-tools-extra/clangd/test/system-include-extractor.test
@@ -5,8 +5,12 @@
 
 # Generate a mock-driver that will print %temp_dir%/my/dir and
 # %temp_dir%/my/dir2 as include search paths.
-# RUN: echo '#!/bin/bash' >> %t.dir/my_driver.sh
+# RUN: echo '#!/bin/sh' >> %t.dir/my_driver.sh
 # RUN: echo '[ "$0" = "%t.dir/my_driver.sh" ] || exit' >> %t.dir/my_driver.sh
+# RUN: echo 'args="$*"' >> %t.dir/my_driver.sh
+# RUN: echo '[ -z "${args##*"-nostdinc"*}" ] || exit' >> %t.dir/my_driver.sh
+# RUN: echo '[ -z "${args##*"-isysroot=/isysroot"*}" ] || exit' >> %t.dir/my_driver.sh
+# RUN: echo 'echo " $* " | grep " --sysroot /my/sysroot/path " || exit' >> %t.dir/my_driver.sh
 # RUN: echo 'echo line to ignore >&2' >> %t.dir/my_driver.sh
 # RUN: echo 'echo -e "#include <...> search starts here:\r" >&2' >> %t.dir/my_driver.sh
 # RUN: echo 'echo %t.dir/my/dir/ >&2' >> %t.dir/my_driver.sh
@@ -22,7 +26,7 @@
 
 # Generate a compile_commands.json that will query the mock driver we've
 # created. Which should add a.h and b.h into include search path.
-# RUN: echo '[{"directory": "%/t.dir", "command": "%/t.dir/my_driver.sh the-file.cpp", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
+# RUN: echo '[{"directory": "%/t.dir", "command": "%/t.dir/my_driver.sh the-file.cpp -nostdinc --sysroot /my/sysroot/path -isysroot=/isysroot", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
 
 # RUN: sed -e "s|INPUT_DIR|%/t.dir|g" %s > %t.test.1
 # On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
Index: clang-tools-extra/clangd/QueryDriverDatabase.cpp
===
--- clang-tools-extra/clangd/QueryDriverDatabase.cpp
+++ clang-tools-extra/clangd/QueryDriverDatabase.cpp
@@ -85,9 +85,10 @@
   return SystemIncludes;
 }
 
-std::vector extractSystemIncludes(PathRef Driver,
-   llvm::StringRef Lang,
-   llvm::Regex &QueryDriverRegex) {
+std::vector
+extractSystemIncludes(PathRef Driver, llvm::StringRef Lang,
+  llvm::ArrayRef CommandLine,
+  llvm::Regex &QueryDriverRegex) {
   trace::Span Tracer("Extract system includes");
   SPAN_ATTACH(Tracer, "driver", Driver);
   SPAN_ATTACH(Tracer, "lang", Lang);
@@ -120,14 +121,43 @@
   llvm::Optional Redirects[] = {
   {""}, {""}, llvm::StringRef(StdErrPath)};
 
-  // Should we also preserve flags like "-sysroot", "-nostdinc" ?
-  const llvm::StringRef Args[] = {Driver, "-E", "-x", Lang, "-", "-v"};
+  llvm::SmallVector Args = {Driver, "-E", "-x",
+ Lang,   "-",  "-v"};
+
+  // These flags will be preserved
+  const llvm::StringRef FlagsToPreserve[] = {
+  "-nostdinc", "--no-standard-includes", "-nostdinc++", "-nobuiltininc"};
+  // Preserves these flags and their values, either as separate args or with an
+  // equalsbetween them
+  const llvm::StringRef ArgsToPreserve[] = {"--sysroot", "-isysroot"};
+
+  for (size_t I = 0, E = CommandLine.size(); I < E; ++I) {
+llvm::StringRef Arg = CommandLine[I];
+if (llvm::any_of(FlagsToPreserve,
+ [&Arg](llvm::StringRef S) { return S == Arg; })) {
+  Args.push_back(Arg);
+} else {
+  const auto *Found =
+  llvm::find_if(ArgsToPreserve, [&Arg](llvm::StringRef S) {
+return Arg.startswith(S);
+  });
+  if (Found == std::end(ArgsToPreserve))
+continue;
+  Arg.consume_front(*Found);
+  if (Arg.empty() && I + 1 < E) {
+Args.push_back(CommandLine[I]);
+Args.push_back(CommandLine[++I]);
+  } else if (Arg.startswith("=")) {
+Args.push_back(CommandLine[I]);
+  }
+}
+  }
 
   if (int RC = llvm::sys::ExecuteAndWait(Driver, Args, /*Env=*/llvm::None,
  Redirects)) {
 elog("System include extraction: driver execution failed with return code: "
- "{0}",
- llvm::to_string(RC));
+ "{0}. Args: ['{1}']",
+ llvm::to_string(RC), llvm::join(Args, "', '"));
 return {};
   }
 
@@ -247,8 +277,8 @@
   if (It != DriverToIncludesCache.end())
 SystemIncludes = It->second;
   else
-DriverToIncludesCache[Key] = SystemIncludes =
-extractSystemIncludes(Key.first, Key.second, QueryDriverRegex);
+DriverToIncludesCache[Key] = SystemIncludes

[PATCH] D73960: [clangd] Don't assert when completing a lambda variable inside the lambda.

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

thanks, lgtm!




Comment at: clang-tools-extra/clangd/CodeComplete.cpp:1007
 Result.Quality = Signal;
-Result.IDForDoc =
-Result.Signature.documentation.empty() && Candidate.getFunction()
-? clangd::getSymbolID(Candidate.getFunction())
-: None;
+if (Result.Signature.documentation.empty() && Candidate.getFunction()) {
+  // Computing USR caches linkage, which may change after code completion.

nit: maybe decrease # of `Candidate.getFunction`s via
```
if(!doc.empty())
  return Result;
if(const auto *FD = Candidate->getFunction()) {

}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73960



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


[PATCH] D72189: [SystemZ] Support -msoft-float

2020-02-04 Thread Jonas Paulsson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG563e84790f41: [SystemZ]  Support -msoft-float (authored by 
jonpa).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72189

Files:
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
  clang/lib/Driver/ToolChains/Arch/SystemZ.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/systemz-abi.c
  clang/test/CodeGen/systemz-abi.cpp
  clang/test/CodeGen/target-data.c
  clang/test/Driver/systemz-float-01.c
  clang/test/Driver/systemz-float-02.c
  llvm/lib/Target/SystemZ/SystemZFeatures.td
  llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
  llvm/lib/Target/SystemZ/SystemZISelLowering.h
  llvm/lib/Target/SystemZ/SystemZSubtarget.cpp
  llvm/lib/Target/SystemZ/SystemZSubtarget.h
  llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
  llvm/test/CodeGen/SystemZ/args-07.ll
  llvm/test/CodeGen/SystemZ/soft-float-01.ll
  llvm/test/CodeGen/SystemZ/soft-float-02.ll
  llvm/test/CodeGen/SystemZ/soft-float-03.ll
  llvm/test/CodeGen/SystemZ/soft-float-04.ll
  llvm/test/CodeGen/SystemZ/soft-float-args.ll
  llvm/test/CodeGen/SystemZ/soft-float-inline-asm-01.ll
  llvm/test/CodeGen/SystemZ/soft-float-inline-asm-02.ll
  llvm/test/CodeGen/SystemZ/soft-float-inline-asm-03.ll
  llvm/test/CodeGen/SystemZ/vec-abi-align.ll
  llvm/test/CodeGen/SystemZ/vec-args-06.ll
  llvm/test/CodeGen/SystemZ/vec-args-07.ll

Index: llvm/test/CodeGen/SystemZ/vec-args-07.ll
===
--- llvm/test/CodeGen/SystemZ/vec-args-07.ll
+++ llvm/test/CodeGen/SystemZ/vec-args-07.ll
@@ -1,6 +1,8 @@
 ; Test calling functions with multiple return values (LLVM ABI extension)
 ;
 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
+; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 -mattr=soft-float \
+; RUN:   | FileCheck %s --check-prefix=SOFT-FLOAT
 
 ; Up to eight vector return values fit into VRs.
 declare { <2 x double>, <2 x double>, <2 x double>, <2 x double>,
@@ -11,6 +13,14 @@
 ; CHECK: brasl %r14, bar1
 ; CHECK: vlr %v24, %v31
 ; CHECK: br %r14
+
+; SOFT-FLOAT-LABEL: f1:
+; SOFT-FLOAT-NOT: %{{[fv]}}
+; SOFT-FLOAT: brasl   %r14, bar1
+; SOFT-FLOAT-NEXT: lg  %r3, 280(%r15)
+; SOFT-FLOAT-NEXT: lg  %r2, 272(%r15)
+; SOFT-FLOAT-NEXT: lmg %r14, %r15, 400(%r15)
+; SOFT-FLOAT-NEXT: br  %r14
   %mret = call { <2 x double>, <2 x double>,
  <2 x double>, <2 x double>,
  <2 x double>, <2 x double>,
@@ -33,6 +43,14 @@
 ; CHECK: brasl %r14, bar2
 ; CHECK: vl  %v24, 288(%r15)
 ; CHECK: br %r14
+
+; SOFT-FLOAT-LABEL: f2:
+; SOFT-FLOAT-NOT: %{{[fv]}}
+; SOFT-FLOAT: brasl   %r14, bar2
+; SOFT-FLOAT-NEXT: lg  %r3, 296(%r15)
+; SOFT-FLOAT-NEXT: lg  %r2, 288(%r15)
+; SOFT-FLOAT-NEXT: lmg %r14, %r15, 416(%r15)
+; SOFT-FLOAT-NEXT: br  %r14
   %mret = call { <2 x double>, <2 x double>,
  <2 x double>, <2 x double>,
  <2 x double>, <2 x double>,
Index: llvm/test/CodeGen/SystemZ/vec-args-06.ll
===
--- llvm/test/CodeGen/SystemZ/vec-args-06.ll
+++ llvm/test/CodeGen/SystemZ/vec-args-06.ll
@@ -1,6 +1,8 @@
 ; Test multiple return values (LLVM ABI extension)
 ;
 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
+; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 -mattr=soft-float \
+; RUN:   | FileCheck %s --check-prefix=SOFT-FLOAT
 
 ; Up to eight vector return values fit into VRs.
 define { <2 x double>, <2 x double>, <2 x double>, <2 x double>,
@@ -23,6 +25,17 @@
 ; CHECK: larl [[TMP:%r[0-5]]], .LCPI
 ; CHECK: vl %v31, 0([[TMP]])
 ; CHECK: br %r14
+
+; SOFT-FLOAT-LABEL: f1:
+; SOFT-FLOAT-NOT: %{{[fv]}}
+; SOFT-FLOAT: llihf
+; SOFT-FLOAT-NEXT: oilf
+; SOFT-FLOAT-NEXT: stg
+; SOFT-FLOAT-NEXT: llihh
+; SOFT-FLOAT-NEXT: stg
+; SOFT-FLOAT-NEXT: llihf
+; SOFT-FLOAT-NOT: %{{[fv]}}
+; SOFT-FLOAT: br  %r14
   ret { <2 x double>, <2 x double>, <2 x double>, <2 x double>,
 <2 x double>, <2 x double>, <2 x double>, <2 x double> }
   { <2 x double> ,
@@ -68,6 +81,17 @@
 ; CHECK: vl [[VTMP:%v[0-9]+]], 0([[TMP]])
 ; CHECK: vst [[VTMP]], 0(%r2)
 ; CHECK: br %r14
+
+; SOFT-FLOAT-LABEL: f2:
+; SOFT-FLOAT-NOT: %{{[fv]}}
+; SOFT-FLOAT: llihf
+; SOFT-FLOAT-NEXT: oilf
+; SOFT-FLOAT-NEXT: stg
+; SOFT-FLOAT-NEXT: llihh
+; SOFT-FLOAT-NEXT: stg
+; SOFT-FLOAT-NEXT: llihf
+; SOFT-FLOAT-NOT: %{{[fv]}}
+; SOFT-FLOAT: br  %r14
   ret { <2 x double>, <2 x double>, <2 x double>, <2 x double>,
 <2 x double>, <2 x double>, <2 x double>, <2 x double>,
 <2 x double> }
Index: llvm/test/CodeGen/SystemZ/vec-abi-align.ll
===
--- llvm/test/CodeGen/SystemZ/vec-abi-align.ll
++

[PATCH] D73360: [OpenCL] Restrict address space conversions in nested pointers

2020-02-04 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Okay, we can go with this for now, since it does fix a bug.


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

https://reviews.llvm.org/D73360



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


[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-04 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

One minor request, but otherwise LGTM; feel free to commit with that change.




Comment at: clang/lib/Sema/SemaExpr.cpp:17254
+SourceLocation(), Context.getTranslationUnitDecl());
+  }
 

yaxunl wrote:
> rjmccall wrote:
> > Thanks, this looks a lot better.
> > 
> > Should this be moved to SemaOpenMP.cpp (and renamed to be OpenMP-specific), 
> > or do you think it's going to be useful in other modes?
> It is not just for OpenMP. Deferred diagnostics are also emitted by CUDA/HIP.
Okay.  Can it go in Sema.cpp next to the other overload of `emitDeferredDiags`, 
then?  There isn't really much purpose to it being in this file.


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

https://reviews.llvm.org/D70172



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


[PATCH] D72742: Don't assume promotable integers are zero/sign-extended already in x86-64 ABI.

2020-02-04 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D72742#1854594 , @emilio wrote:

> Could anyone update me with how do they want me to proceed here? Is fixing 
> the coercions enough to allow this to land? Do I need to make it 
> target-specific?


It needs to be target-specific.

> If so, which targets should keep the current behavior?

At least Darwin and PS4, maybe some others.  BSD?

> Another slightly more backwards-compatible alternative (though hacky, 
> arguably) is to just not use the zext for optimization purposes in the 
> backend. This would be simpler and should keep clang always sign-extending on 
> the caller too, for now. We could then after a while, switch to this 
> approach. D71178  contains such a patch, for 
> comparison.

It wouldn't be unreasonable to have a way to request this behavior, but I'm not 
sure about switching to it for all `zext` / `sext`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72742



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


[clang] e943329 - [SystemZ] Add 'REQUIRES:' or '-mtriple' to some newly added tests.

2020-02-04 Thread Jonas Paulsson via cfe-commits

Author: Jonas Paulsson
Date: 2020-02-04T10:52:10-05:00
New Revision: e943329ba00772f96fbc1fe5dec836cfd0707a38

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

LOG: [SystemZ]  Add 'REQUIRES:' or '-mtriple' to some newly added tests.

Needed to fix buildbots.

Added: 


Modified: 
clang/test/Driver/systemz-float-02.c
llvm/test/CodeGen/SystemZ/soft-float-01.ll
llvm/test/CodeGen/SystemZ/soft-float-03.ll
llvm/test/CodeGen/SystemZ/soft-float-04.ll
llvm/test/CodeGen/SystemZ/soft-float-args.ll
llvm/test/CodeGen/SystemZ/soft-float-inline-asm-01.ll
llvm/test/CodeGen/SystemZ/soft-float-inline-asm-02.ll
llvm/test/CodeGen/SystemZ/soft-float-inline-asm-03.ll

Removed: 




diff  --git a/clang/test/Driver/systemz-float-02.c 
b/clang/test/Driver/systemz-float-02.c
index c18a7fa6cdf1..d9ec329485a4 100644
--- a/clang/test/Driver/systemz-float-02.c
+++ b/clang/test/Driver/systemz-float-02.c
@@ -1,4 +1,5 @@
 // RUN: %clang -target s390x-linux-gnu -march=z13 -S %s -o - -msoft-float | 
FileCheck %s
+// REQUIRES: systemz-registered-target
 //
 // Check that -msoft-float works all the way to assembly output.
 

diff  --git a/llvm/test/CodeGen/SystemZ/soft-float-01.ll 
b/llvm/test/CodeGen/SystemZ/soft-float-01.ll
index 0d70075d5df5..cba8124a6141 100644
--- a/llvm/test/CodeGen/SystemZ/soft-float-01.ll
+++ b/llvm/test/CodeGen/SystemZ/soft-float-01.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mcpu=z10 -mattr=soft-float -O0 < %s | FileCheck %s
+; RUN: llc -mtriple=s390x-linux-gnu -mcpu=z10 -mattr=soft-float -O0 < %s | 
FileCheck %s
 
 ; Arithmetic functions
 

diff  --git a/llvm/test/CodeGen/SystemZ/soft-float-03.ll 
b/llvm/test/CodeGen/SystemZ/soft-float-03.ll
index 96cc03676e30..a53bf357d60b 100644
--- a/llvm/test/CodeGen/SystemZ/soft-float-03.ll
+++ b/llvm/test/CodeGen/SystemZ/soft-float-03.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mcpu=z13 -mattr=soft-float -O3 < %s | FileCheck %s
+; RUN: llc -mtriple=s390x-linux-gnu -mcpu=z13 -mattr=soft-float -O3 < %s | 
FileCheck %s
 ;
 ; Check that soft-float implies "-vector".
 

diff  --git a/llvm/test/CodeGen/SystemZ/soft-float-04.ll 
b/llvm/test/CodeGen/SystemZ/soft-float-04.ll
index e939b300c842..1dbe843090b0 100644
--- a/llvm/test/CodeGen/SystemZ/soft-float-04.ll
+++ b/llvm/test/CodeGen/SystemZ/soft-float-04.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mcpu=z14 -O3 -mattr=soft-float < %s  | FileCheck %s
+; RUN: llc -mtriple=s390x-linux-gnu -mcpu=z14 -O3 -mattr=soft-float < %s  | 
FileCheck %s
 ;
 ; Check that this function with soft-float does not result in a s390.tdc
 ; intrinsic (which cannot be handled by SoftenFloatOperand).

diff  --git a/llvm/test/CodeGen/SystemZ/soft-float-args.ll 
b/llvm/test/CodeGen/SystemZ/soft-float-args.ll
index d9dc305502c3..06b362672b1f 100644
--- a/llvm/test/CodeGen/SystemZ/soft-float-args.ll
+++ b/llvm/test/CodeGen/SystemZ/soft-float-args.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mcpu=z13 -mattr=soft-float -O3 < %s | FileCheck %s
+; RUN: llc -mtriple=s390x-linux-gnu -mcpu=z13 -mattr=soft-float -O3 < %s | 
FileCheck %s
 ;
 ; Test that arguments and return values of fp/vector types are always handled
 ; with gprs with soft-float.

diff  --git a/llvm/test/CodeGen/SystemZ/soft-float-inline-asm-01.ll 
b/llvm/test/CodeGen/SystemZ/soft-float-inline-asm-01.ll
index 0d84c9056f51..728ff2f51263 100644
--- a/llvm/test/CodeGen/SystemZ/soft-float-inline-asm-01.ll
+++ b/llvm/test/CodeGen/SystemZ/soft-float-inline-asm-01.ll
@@ -1,4 +1,4 @@
-; RUN: not llc < %s -mcpu=z13 -mattr=soft-float -O3 2>&1 | FileCheck %s
+; RUN: not llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 -mattr=soft-float -O3 
2>&1 | FileCheck %s
 ;
 ; Verify that inline asms cannot use fp/vector registers with soft-float.
 

diff  --git a/llvm/test/CodeGen/SystemZ/soft-float-inline-asm-02.ll 
b/llvm/test/CodeGen/SystemZ/soft-float-inline-asm-02.ll
index 3db346d8214c..c523c05981d8 100644
--- a/llvm/test/CodeGen/SystemZ/soft-float-inline-asm-02.ll
+++ b/llvm/test/CodeGen/SystemZ/soft-float-inline-asm-02.ll
@@ -1,4 +1,4 @@
-; RUN: not llc < %s -mcpu=z13 -mattr=soft-float -O3 2>&1 | FileCheck %s
+; RUN: not llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 -mattr=soft-float -O3 
2>&1 | FileCheck %s
 ;
 ; Verify that inline asms cannot use fp/vector registers with soft-float.
 

diff  --git a/llvm/test/CodeGen/SystemZ/soft-float-inline-asm-03.ll 
b/llvm/test/CodeGen/SystemZ/soft-float-inline-asm-03.ll
index e31434c5b55d..f382ad367aaa 100644
--- a/llvm/test/CodeGen/SystemZ/soft-float-inline-asm-03.ll
+++ b/llvm/test/CodeGen/SystemZ/soft-float-inline-asm-03.ll
@@ -1,4 +1,4 @@
-; RUN: not llc < %s -mcpu=z13 -mattr=soft-float -O3 2>&1 | FileCheck %s
+; RUN: not llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 -mattr=soft-float -O3 
2>&1 | FileCheck %s
 ;
 ; Verify that inline asms cannot use fp/vector registers with

[PATCH] D72189: [SystemZ] Support -msoft-float

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

Hello, this breaks tests on all platforms (e.g.: 
http://45.33.8.238/mac/7170/step_11.txt) Please revert immediately and please 
run tests locally before committing next time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72189



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


[PATCH] D73453: Preserve -nostdinc and --sysroot when calling query driver

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

LGTM, thanks

let me know if you need me to commit this.


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

https://reviews.llvm.org/D73453



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


[PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP

2020-02-04 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 added inline comments.



Comment at: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:1678
+// breaks any uses on assumes.
+if (TypeIdMap.count(TypeId))
+  continue;

tejohnson wrote:
> evgeny777 wrote:
> > tejohnson wrote:
> > > evgeny777 wrote:
> > > > I don't think, I understand this.
> > > > It looks like that if (a) we have type.test in the module and (b) we 
> > > > don't have vtable definition with corresponding type metadata in the 
> > > > same module then we'll remove type.test/assume sequence before even 
> > > > getting to ICP. This seems strange in the context of previous 
> > > > discussion because virtual function may be called in different module 
> > > > from one where vtable is defined, like so:
> > > > ```
> > > > struct A { virtual int foo() { return 42; } };
> > > > 
> > > > // calls pA->foo
> > > > extern int callFoo(A *pA);
> > > > int main() { A a; return callFoo(&a); }
> > > > ```
> > > > 
> > > We will only be able to do ICP this way if we have the target vtable in 
> > > the module (similar to how we currently can only do ICP if the target 
> > > function is in the module). I anticipate doing something similar for 
> > > vtable defs as to what we do for virtual functions, where a fake call 
> > > edge is added to the summary based on the value profile results to ensure 
> > > they are imported before the LTO backend ICP.
> > > We will only be able to do ICP this way if we have the target vtable in 
> > > the module (similar to how we currently can only do ICP if the target 
> > > function is in the module).
> > 
> > I was thinking of slightly different approach: it seems you have required 
> > type information in combined index together with type name in the module, 
> > so you probably can add external declarations of required vtables (this may 
> > require promotion) to the module in the ICP pass and run ICP over them. Do 
> > you think this can work?
> Possibly, but we'd still need to have type metadata on those vtable 
> declarations, because the type metadata provides the address point offset 
> which is needed in the comparison sequence.
> Possibly, but we'd still need to have type metadata on those vtable 
> declarations, because the type metadata provides the address point offset 
> which is needed in the comparison sequence.

I think it's stored in the index in VFuncId structures. Isn't it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73242



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


[PATCH] D72189: [SystemZ] Support -msoft-float

2020-02-04 Thread Jonas Paulsson via Phabricator via cfe-commits
jonpa added a comment.

In D72189#1857098 , @thakis wrote:

> Hello, this breaks tests on all platforms (e.g.: 
> http://45.33.8.238/mac/7170/step_11.txt) Please revert immediately and please 
> run tests locally before committing next time.


I have added the missing 'REQUIRES', and -mtriple:s to the tests which was not 
needed when I tested locally. Sorry for the noise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72189



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


[PATCH] D73873: [clangd] Mechanism to make update debounce responsive to rebuild speed.

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

In D73873#1857042 , @thakis wrote:

> I agree it's a bit strange. The linux bot didn't recover after the revert 
> either, so something's amiss.
>
> My Win bot has been hanging since this landed and I just CRD'd in and it's 
> hanging in check-clangd and there are tens of ClangdTests processes hanging 
> around and doing nothing.
>
> On the more official win bot, instead the link of ClangdTests has been 
> failing since this landed, which on Windows is likely caused by the processes 
> still hanging around 
> (http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/14120/steps/stage%201%20check/logs/stdio).
>  This is the first bad build: 
> http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/14113/


Windows: the stacktrace in the first bad build is almost certainly the bug 
above.
The processes hanging around after a crash (on the main thread) is surprising. 
The crash is on the main thread, though there are others. Something I should 
look into.

Linux: (some of) the stacktraces seem very unrelated to this code, and a revert 
didn't fix them, but a clean rebuild did (thanks @thakis!).

Next step: wait for the gn linux bot to be back in a good state, reland with 
the double-unlock fixed.




Comment at: clang-tools-extra/clangd/TUScheduler.cpp:528
+  RebuildTimes.push_back(RebuildDuration);
+  Mutex.unlock();
+}

Here's a double-unlock (thanks @kadircet)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73873



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


[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:17254
+SourceLocation(), Context.getTranslationUnitDecl());
+  }
 

rjmccall wrote:
> yaxunl wrote:
> > rjmccall wrote:
> > > Thanks, this looks a lot better.
> > > 
> > > Should this be moved to SemaOpenMP.cpp (and renamed to be 
> > > OpenMP-specific), or do you think it's going to be useful in other modes?
> > It is not just for OpenMP. Deferred diagnostics are also emitted by 
> > CUDA/HIP.
> Okay.  Can it go in Sema.cpp next to the other overload of 
> `emitDeferredDiags`, then?  There isn't really much purpose to it being in 
> this file.
will do when committing. thanks.


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

https://reviews.llvm.org/D70172



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


[clang-tools-extra] 2f4c4d0 - Reland "[clangd] Mechanism to make update debounce responsive to rebuild speed."

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

Author: Sam McCall
Date: 2020-02-04T17:17:53+01:00
New Revision: 2f4c4d0a78e352e33f903d96f406999753d23e07

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

LOG: Reland "[clangd] Mechanism to make update debounce responsive to rebuild 
speed."

This reverts commit ed98994f64b8fe6443aef57a5faa953e86d9fc0e.
Removed the accidental double-mutex-unlock.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 00da7af06741..3e22a4dfe667 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -106,7 +106,7 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
 
 ClangdServer::Options ClangdServer::optsForTest() {
   ClangdServer::Options Opts;
-  Opts.UpdateDebounce = std::chrono::steady_clock::duration::zero(); // Faster!
+  Opts.UpdateDebounce = DebouncePolicy::fixed(/*zero*/ {});
   Opts.StorePreamblesInMemory = true;
   Opts.AsyncThreadsCount = 4; // Consistent!
   Opts.SemanticHighlighting = true;

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 2d0957f441bb..3c3505295a75 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -130,8 +130,8 @@ class ClangdServer {
 llvm::Optional ResourceDir = llvm::None;
 
 /// Time to wait after a new file version before computing diagnostics.
-std::chrono::steady_clock::duration UpdateDebounce =
-std::chrono::milliseconds(500);
+DebouncePolicy UpdateDebounce =
+DebouncePolicy::fixed(std::chrono::milliseconds(500));
 
 bool SuggestMissingIncludes = false;
 

diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp 
b/clang-tools-extra/clangd/TUScheduler.cpp
index 9218ae9a03ce..12a062378202 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -61,6 +61,7 @@
 #include "llvm/Support/Threading.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -164,7 +165,7 @@ class ASTWorker {
   friend class ASTWorkerHandle;
   ASTWorker(PathRef FileName, const GlobalCompilationDatabase &CDB,
 TUScheduler::ASTCache &LRUCache, Semaphore &Barrier, bool RunSync,
-steady_clock::duration UpdateDebounce, bool StorePreamblesInMemory,
+DebouncePolicy UpdateDebounce, bool StorePreamblesInMemory,
 ParsingCallbacks &Callbacks);
 
 public:
@@ -176,7 +177,7 @@ class ASTWorker {
   static ASTWorkerHandle
   create(PathRef FileName, const GlobalCompilationDatabase &CDB,
  TUScheduler::ASTCache &IdleASTs, AsyncTaskRunner *Tasks,
- Semaphore &Barrier, steady_clock::duration UpdateDebounce,
+ Semaphore &Barrier, DebouncePolicy UpdateDebounce,
  bool StorePreamblesInMemory, ParsingCallbacks &Callbacks);
   ~ASTWorker();
 
@@ -242,7 +243,7 @@ class ASTWorker {
   TUScheduler::ASTCache &IdleASTs;
   const bool RunSync;
   /// Time to wait after an update to see whether another update obsoletes it.
-  const steady_clock::duration UpdateDebounce;
+  const DebouncePolicy UpdateDebounce;
   /// File that ASTWorker is responsible for.
   const Path FileName;
   const GlobalCompilationDatabase &CDB;
@@ -263,6 +264,9 @@ class ASTWorker {
   /// be consumed by clients of ASTWorker.
   std::shared_ptr FileInputs; /* GUARDED_BY(Mutex) 
*/
   std::shared_ptr LastBuiltPreamble; /* GUARDED_BY(Mutex) 
*/
+  /// Times of recent AST rebuilds, used for UpdateDebounce computation.
+  llvm::SmallVector
+  RebuildTimes; /* GUARDED_BY(Mutex) */
   /// Becomes ready when the first preamble build finishes.
   Notification PreambleWasBuilt;
   /// Set to true to signal run() to finish processing.
@@ -326,7 +330,7 @@ class ASTWorkerHandle {
 ASTWorkerHandle
 ASTWorker::create(PathRef FileName, const GlobalCompilationDatabase &CDB,
   TUScheduler::ASTCache &IdleASTs, AsyncTaskRunner *Tasks,
-  Semaphore &Barrier, steady_clock::duration UpdateDebounce,
+  Semaphore &Barrier, DebouncePolicy UpdateDebounce,
   bool StorePreamblesInMemory, ParsingCallbacks &Callbacks) {
   std::shared_ptr Worker(
   new ASTWorker(FileName, CDB, IdleASTs, Barrier, /*RunSync=*/!Tasks,
@@ -340,7 +344,7 @@ ASTWorker::create(PathRef FileName, const 
GlobalCompilationDatabase &CDB,
 
 ASTWorker::ASTWorker(PathRef FileName, const GlobalCompilationDatabase &CDB,
  TUScheduler::ASTCache &LRUCache, Se

[PATCH] D31337: Use virtual functions in ParsedAttrInfo instead of function pointers

2020-02-04 Thread John Brawn via Phabricator via cfe-commits
john.brawn marked 2 inline comments as done.
john.brawn added inline comments.



Comment at: clang/lib/Sema/ParsedAttr.cpp:141
 
+static ParsedAttrInfo DefaultParsedAttrInfo;
 static const ParsedAttrInfo &getInfo(const ParsedAttr &A) {

aaron.ballman wrote:
> Might as well lower this variable into the function -- no real need for it to 
> have file scope.
Sure.



Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:3400
 
-static std::string GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) {
+static void GenerateAppertainsTo(const Record &Attr, raw_ostream &SS,
+ raw_ostream &OS) {

aaron.ballman wrote:
> erichkeane wrote:
> > john.brawn wrote:
> > > erichkeane wrote:
> > > > Why does this take SS AND OS.  What is the difference here?  Does this 
> > > > actually use OS anymore?
> > > It's because of GenerateCustomAppertainsTo.  That generates a function 
> > > that expects to be at file scope (because emitAttributeMatchRules re-uses 
> > > the same function), but at the time GenerateAppertainsTo is called SS is 
> > > in the middle of the ParsedAttrInfo. Previously both the function that 
> > > GenerateCustomAppertainsTo generates and that this file generates would 
> > > be at file scope, so both were written to OS.
> > Thanks!
> I think the stream parameter names should be a bit more descriptive here (and 
> perhaps some comments on the function would be a good idea as well). Perhaps 
> `FileScopeStream` and `LexicalScopeStream`?
Actually, looking at this again there's no reason we can't generate the 
CustomApperatinsTo functions in a loop at the start of 
EmitClangAttrParsedAttrImpl. That way everything can just go to a single output 
stream and we don't have this problem. I'll rearrange things to do that instead.


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

https://reviews.llvm.org/D31337



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


[PATCH] D73966: [analyzer][WIP] Add 10.0.0 release notes.

2020-02-04 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:429
+
+- Numerous smaller false positive fixes.
 

I'd just say `Numerous smaller fixes.` or `Numerous other improvements.`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73966



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


[clang-tools-extra] 2629035 - [clangd] Don't assert when completing a lambda variable inside the lambda.

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

Author: Sam McCall
Date: 2020-02-04T17:24:26+01:00
New Revision: 2629035a009095f62f48413e175437261165ecd7

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

LOG: [clangd] Don't assert when completing a lambda variable inside the lambda.

Summary:
This is a fairly ugly hack - we back off several features for any variable
whose type isn't deduced, to avoid computing/caching linkage.
Better suggestions welcome.

Fixes https://github.com/clangd/clangd/issues/274

Reviewers: kadircet, kbobyrev

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/AST.h
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index c800ee870dc9..836eb6a36459 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -473,5 +473,12 @@ std::string getQualification(ASTContext &Context,
   });
 }
 
+bool hasUnstableLinkage(const Decl *D) {
+  // Linkage of a ValueDecl depends on the type.
+  // If that's not deduced yet, deducing it may change the linkage.
+  auto *VD = llvm::dyn_cast_or_null(D);
+  return VD && !VD->getType().isNull() && VD->getType()->isUndeducedType();
+}
+
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/AST.h b/clang-tools-extra/clangd/AST.h
index 6cae719986a0..a40aeaf32a77 100644
--- a/clang-tools-extra/clangd/AST.h
+++ b/clang-tools-extra/clangd/AST.h
@@ -148,6 +148,21 @@ std::string getQualification(ASTContext &Context,
  const NamedDecl *ND,
  llvm::ArrayRef VisibleNamespaces);
 
+/// Whether we must avoid computing linkage for D during code completion.
+/// Clang aggressively caches linkage computation, which is stable after the 
AST
+/// is built. Unfortunately the AST is incomplete during code completion, so
+/// linkage may still change.
+///
+/// Example: `auto x = []{^}` at file scope.
+/// During code completion, the initializer for x hasn't been parsed yet.
+/// x has type `undeduced auto`, and external linkage.
+/// If we compute linkage at this point, the external linkage will be cached.
+///
+/// After code completion the initializer is attached, and x has a lambda type.
+/// This means x has "unique external" linkage. If we computed linkage above,
+/// the cached value is incorrect. (clang catches this with an assertion).
+bool hasUnstableLinkage(const Decl *D);
+
 } // namespace clangd
 } // namespace clang
 

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 830d4b224413..4d4d15b0efae 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -489,6 +489,9 @@ llvm::Optional getSymbolID(const 
CodeCompletionResult &R,
   switch (R.Kind) {
   case CodeCompletionResult::RK_Declaration:
   case CodeCompletionResult::RK_Pattern: {
+// Computing USR caches linkage, which may change after code completion.
+if (hasUnstableLinkage(R.Declaration))
+  return llvm::None;
 return clang::clangd::getSymbolID(R.Declaration);
   }
   case CodeCompletionResult::RK_Macro:
@@ -1001,10 +1004,12 @@ class SignatureHelpCollector final : public 
CodeCompleteConsumer {
 ScoredSignature Result;
 Result.Signature = std::move(Signature);
 Result.Quality = Signal;
-Result.IDForDoc =
-Result.Signature.documentation.empty() && Candidate.getFunction()
-? clangd::getSymbolID(Candidate.getFunction())
-: None;
+const FunctionDecl *Func = Candidate.getFunction();
+if (Func && Result.Signature.documentation.empty()) {
+  // Computing USR caches linkage, which may change after code completion.
+  if (!hasUnstableLinkage(Func))
+Result.IDForDoc = clangd::getSymbolID(Func);
+}
 return Result;
   }
 

diff  --git a/clang-tools-extra/clangd/Quality.cpp 
b/clang-tools-extra/clangd/Quality.cpp
index bd25256904cd..d80790fc9808 100644
--- a/clang-tools-extra/clangd/Quality.cpp
+++ b/clang-tools-extra/clangd/Quality.cpp
@@ -275,8 +275,9 @@ computeScope(const NamedDecl *D) {
   }
   if (InClass)
 return SymbolRelevanceSignals::ClassScope;
-  // This threshold could be tweaked, e.g. to treat module-visible as global.
-  if (D->getLinkageInternal() < ExternalLinkage)
+  // ExternalLinkage threshold could be tweaked, e.g. module-visible as global.
+  // Avoid caching linkage if it may change after enclosing code completion.
+  if (h

[PATCH] D73960: [clangd] Don't assert when completing a lambda variable inside the lambda.

2020-02-04 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rG2629035a0090: [clangd] Don't assert when completing a 
lambda variable inside the lambda. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D73960?vs=242311&id=242344#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73960

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Quality.cpp
  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
@@ -2664,6 +2664,17 @@
   ElementsAre(AllOf(ReturnType("int"), Named("size";
 }
 
+TEST(CompletionTest, NoCrashWithIncompleteLambda) {
+  auto Completions = completions("auto&& x = []{^").Completions;
+  // The completion of x itself can cause a problem: in the code completion
+  // callback, its type is not known, which affects the linkage calculation.
+  // A bad linkage value gets cached, and subsequently updated.
+  EXPECT_THAT(Completions, Contains(Named("x")));
+
+  auto Signatures = signatures("auto x() { x(^").signatures;
+  EXPECT_THAT(Signatures, Contains(Sig("x() -> auto")));
+}
+
 TEST(NoCompileCompletionTest, Basic) {
   auto Results = completionsNoCompile(R"cpp(
 void func() {
Index: clang-tools-extra/clangd/Quality.cpp
===
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -275,8 +275,9 @@
   }
   if (InClass)
 return SymbolRelevanceSignals::ClassScope;
-  // This threshold could be tweaked, e.g. to treat module-visible as global.
-  if (D->getLinkageInternal() < ExternalLinkage)
+  // ExternalLinkage threshold could be tweaked, e.g. module-visible as global.
+  // Avoid caching linkage if it may change after enclosing code completion.
+  if (hasUnstableLinkage(D) || D->getLinkageInternal() < ExternalLinkage)
 return SymbolRelevanceSignals::FileScope;
   return SymbolRelevanceSignals::GlobalScope;
 }
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -489,6 +489,9 @@
   switch (R.Kind) {
   case CodeCompletionResult::RK_Declaration:
   case CodeCompletionResult::RK_Pattern: {
+// Computing USR caches linkage, which may change after code completion.
+if (hasUnstableLinkage(R.Declaration))
+  return llvm::None;
 return clang::clangd::getSymbolID(R.Declaration);
   }
   case CodeCompletionResult::RK_Macro:
@@ -1001,10 +1004,12 @@
 ScoredSignature Result;
 Result.Signature = std::move(Signature);
 Result.Quality = Signal;
-Result.IDForDoc =
-Result.Signature.documentation.empty() && Candidate.getFunction()
-? clangd::getSymbolID(Candidate.getFunction())
-: None;
+const FunctionDecl *Func = Candidate.getFunction();
+if (Func && Result.Signature.documentation.empty()) {
+  // Computing USR caches linkage, which may change after code completion.
+  if (!hasUnstableLinkage(Func))
+Result.IDForDoc = clangd::getSymbolID(Func);
+}
 return Result;
   }
 
Index: clang-tools-extra/clangd/AST.h
===
--- clang-tools-extra/clangd/AST.h
+++ clang-tools-extra/clangd/AST.h
@@ -148,6 +148,21 @@
  const NamedDecl *ND,
  llvm::ArrayRef VisibleNamespaces);
 
+/// Whether we must avoid computing linkage for D during code completion.
+/// Clang aggressively caches linkage computation, which is stable after the AST
+/// is built. Unfortunately the AST is incomplete during code completion, so
+/// linkage may still change.
+///
+/// Example: `auto x = []{^}` at file scope.
+/// During code completion, the initializer for x hasn't been parsed yet.
+/// x has type `undeduced auto`, and external linkage.
+/// If we compute linkage at this point, the external linkage will be cached.
+///
+/// After code completion the initializer is attached, and x has a lambda type.
+/// This means x has "unique external" linkage. If we computed linkage above,
+/// the cached value is incorrect. (clang catches this with an assertion).
+bool hasUnstableLinkage(const Decl *D);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -473,5 +473,1

[PATCH] D68923: Don't warn about missing declarations for partial template specializations

2020-02-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D68923#1857046 , @aaronpuchert 
wrote:

> In D68923#1853527 , @aaronpuchert 
> wrote:
>
> > In D68923#1853303 , @aaron.ballman 
> > wrote:
> >
> > > I think it's a simple enough fix that it may be worth it, but it isn't 
> > > fixing a regression in behavior so it's not critical.
> >
> >
> > Exactly, it would just be a bug fix.
>
>
> Actually it is a regression, but one that we already had in Clang 9. Try 
>  this code:
>
>   template 
>   constexpr bool X = true;
>  
>   template 
>   constexpr bool X = false;
>
>
> Clang 9 emits the following false positive warning, which Clang 8 doesn't 
> emit:
>
>   :5:16: warning: no previous extern declaration for non-static 
> variable 'X' [-Wmissing-variable-declarations]
>   constexpr bool X = false;
>  ^
>   :5:11: note: declare 'static' if the variable is not intended to be 
> used outside of this translation unit
>   constexpr bool X = false;
> ^
>


Feel free to suggest to Hans to add this to the 10.0 release.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68923



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


[PATCH] D65050: [SemaTemplate] Mark a function type as dependent when its parameter list contains pack expansion

2020-02-04 Thread S. B. Tam via Phabricator via cfe-commits
cpplearner added a comment.

ping @rsmith


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

https://reviews.llvm.org/D65050



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


[clang] 386fd2c - [clang] Add matcher to identify macro expansions.

2020-02-04 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2020-02-04T11:43:06-05:00
New Revision: 386fd2c170a78798a097650b8714183d5a9d93c6

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

LOG: [clang] Add matcher to identify macro expansions.

Summary:
This revision adds a matcher `isExpandedFromMacro` that determines whether a
statement is (transitively) expanded from a given macro.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 2bd24ef4cf6b..ec969b42c6ae 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -300,6 +300,26 @@ AST_POLYMORPHIC_MATCHER_P(isExpansionInFileMatching,
   return RE.match(Filename);
 }
 
+/// Matches statements that are (transitively) expanded from the named macro.
+/// Does not match if only part of the statement is expanded from that macro or
+/// if 
diff erent parts of the the statement are expanded from 
diff erent
+/// appearances of the macro.
+///
+/// FIXME: Change to be a polymorphic matcher that works on any syntactic
+/// node. There's nothing `Stmt`-specific about it.
+AST_MATCHER_P(clang::Stmt, isExpandedFromMacro, llvm::StringRef, MacroName) {
+  // Verifies that the statement' beginning and ending are both expanded from
+  // the same instance of the given macro.
+  auto& Context = Finder->getASTContext();
+  auto B =
+  internal::getExpansionLocOfMacro(MacroName, Node.getBeginLoc(), Context);
+  if (!B) return false;
+  auto E =
+  internal::getExpansionLocOfMacro(MacroName, Node.getEndLoc(), Context);
+  if (!E) return false;
+  return *B == *E;
+}
+
 /// Matches declarations.
 ///
 /// Examples matches \c X, \c C, and the friend declaration inside \c C;

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 55c86302b93d..696eca1aa643 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1872,6 +1872,13 @@ CompoundStmtMatcher::get(const StmtExpr &Node) 
{
   return Node.getSubStmt();
 }
 
+/// If \p Loc is (transitively) expanded from macro \p MacroName, returns the
+/// location (in the chain of expansions) at which \p MacroName was
+/// expanded. Since the macro may have been expanded inside a series of
+/// expansions, that location may itself be a MacroID.
+llvm::Optional
+getExpansionLocOfMacro(StringRef MacroName, SourceLocation Loc,
+   const ASTContext &Context);
 } // namespace internal
 
 } // namespace ast_matchers

diff  --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 03b56fae9038..53f6e1d1d278 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -19,6 +19,7 @@
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Lex/Lexer.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/None.h"
@@ -595,6 +596,38 @@ bool HasNameMatcher::matchesNode(const NamedDecl &Node) 
const {
   return matchesNodeFullFast(Node);
 }
 
+// Checks whether \p Loc points to a token with source text of \p TokenText.
+static bool isTokenAtLoc(const SourceManager &SM, const LangOptions &LangOpts,
+ StringRef Text, SourceLocation Loc) {
+  llvm::SmallString<16> Buffer;
+  bool Invalid = false;
+  // Since `Loc` may point into an expansion buffer, which has no corresponding
+  // source, we need to look at the spelling location to read the actual 
source.
+  StringRef TokenText = clang::Lexer::getSpelling(
+  SM.getSpellingLoc(Loc), Buffer, SM, LangOpts, &Invalid);
+  return !Invalid && Text == TokenText;
+}
+
+llvm::Optional
+getExpansionLocOfMacro(StringRef MacroName, SourceLocation Loc,
+   const ASTContext &Context) {
+  auto& SM = Context.getSourceManager();
+  const auto& LangOpts = Context.getLangOpts();
+  while (Loc.isMacroID()) {
+auto Expansion = SM.getSLocEntry(SM.getFileID(Loc)).getExpansion();
+if (Expansion.isMacroArgExpansion())
+  // Check macro argument for an expansion of the given macro. For example,
+  // `F(G(3))`, where `MacroName` is `G`.
+  if (auto ArgLoc = getExpansionLocOfMacro(
+  

[PATCH] D73966: [analyzer][WIP] Add 10.0.0 release notes.

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

Thanks!!




Comment at: clang/docs/ReleaseNotes.rst:408
+
+- New checker: ``alpha.plusplus.PlacementNew`` to detect whether the storage
+  provided for default placement new is sufficiently large.

I think this one's out of alpha already (i.e., `cplusplus.PlacementNew`). I'd 
also bump it to the top because it applies to more users.



Comment at: clang/docs/ReleaseNotes.rst:417
+  explained in bug reports (further reading on the related
+  `GSoC'19 summary page `_).
+

I think we don't traditionally highlight in release notes that something was a 
result of GSoC. I don't have an opinion here, just don't see much of it.



Comment at: clang/docs/ReleaseNotes.rst:422
+
+- Analyses on LLVM's own source code are far more precise due to the modeling 
of
+  several LLVM specific techniques, like its custom RTTI, informing the 
analyzer

@Charusso's work was already mentioned in the [[ 
http://releases.llvm.org/9.0.0/tools/clang/docs/ReleaseNotes.html#static-analyzer
 | previous release notes ]] because it was already partially enabled 
mid-summer.



Comment at: clang/docs/ReleaseNotes.rst:427
+
+- ObjectiveC++ changes:
+

Szelethus wrote:
> I tried my best here but didn't get far. :)
Not much here, mostly bugfixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73966



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


[PATCH] D73965: [clang] Add matcher to identify macro expansions.

2020-02-04 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG386fd2c170a7: [clang] Add matcher to identify macro 
expansions. (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73965

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -18,6 +18,120 @@
 namespace clang {
 namespace ast_matchers {
 
+TEST(IsExpandedFromMacro, ShouldMatchInFile) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+void Test() { MY_MACRO(4); }
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchNested) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+#define WRAPPER(a) MY_MACRO(a)
+void Test() { WRAPPER(4); }
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchIntermediate) {
+  std::string input = R"cc(
+#define IMPL(a) (4 + (a))
+#define MY_MACRO(a) IMPL(a)
+#define WRAPPER(a) MY_MACRO(a)
+void Test() { WRAPPER(4); }
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchTransitive) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+#define WRAPPER(a) MY_MACRO(a)
+void Test() { WRAPPER(4); }
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("WRAPPER";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchArgument) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+void Test() {
+  int x = 5;
+  MY_MACRO(x);
+}
+  )cc";
+  EXPECT_TRUE(matches(input, declRefExpr(isExpandedFromMacro("MY_MACRO";
+}
+
+// Like IsExpandedFromMacroShouldMatchArgumentMacro, but the argument is itself
+// a macro.
+TEST(IsExpandedFromMacro, ShouldMatchArgumentMacroExpansion) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+#define IDENTITY(a) (a)
+void Test() {
+  IDENTITY(MY_MACRO(2));
+}
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("IDENTITY";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchWhenInArgument) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+#define IDENTITY(a) (a)
+void Test() {
+  IDENTITY(MY_MACRO(2));
+}
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("MY_MACRO";
+}
+
+TEST(IsExpandedFromMacro, ShouldMatchObjectMacro) {
+  std::string input = R"cc(
+#define PLUS (2 + 2)
+void Test() {
+  PLUS;
+}
+  )cc";
+  EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("PLUS";
+}
+
+TEST(IsExpandedFromMacro, ShouldNotMatchBeginOnly) {
+  std::string input = R"cc(
+#define ONE_PLUS 1+
+  void Test() { ONE_PLUS 4; }
+  )cc";
+  EXPECT_TRUE(
+  notMatches(input, binaryOperator(isExpandedFromMacro("ONE_PLUS";
+}
+
+TEST(IsExpandedFromMacro, ShouldNotMatchEndOnly) {
+  std::string input = R"cc(
+#define PLUS_ONE +1
+  void Test() { 4 PLUS_ONE; }
+  )cc";
+  EXPECT_TRUE(
+  notMatches(input, binaryOperator(isExpandedFromMacro("PLUS_ONE";
+}
+
+TEST(IsExpandedFromMacro, ShouldNotMatchDifferentMacro) {
+  std::string input = R"cc(
+#define MY_MACRO(a) (4 + (a))
+void Test() { MY_MACRO(4); }
+  )cc";
+  EXPECT_TRUE(notMatches(input, binaryOperator(isExpandedFromMacro("OTHER";
+}
+
+TEST(IsExpandedFromMacro, ShouldNotMatchDifferentInstances) {
+  std::string input = R"cc(
+#define FOUR 4
+void Test() { FOUR + FOUR; }
+  )cc";
+  EXPECT_TRUE(notMatches(input, binaryOperator(isExpandedFromMacro("FOUR";
+}
 
 TEST(AllOf, AllOverloadsWork) {
   const char Program[] =
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -19,6 +19,7 @@
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Lex/Lexer.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/None.h"
@@ -595,6 +596,38 @@
   return matchesNodeFullFast(Node);
 }
 
+// Checks whether \p Loc points to a token with source text of \p TokenText.
+static bool isTokenAtLoc(const SourceManager &SM, const LangOptions &LangOpts,
+ StringRef Text, SourceLocation Loc) {
+  llvm::SmallString<16> Buffer;
+  bool Invalid = false;
+  // Since `Loc` may point 

[PATCH] D73965: [clang] Add matcher to identify macro expansions.

2020-02-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:313-317
+  auto& Context = Finder->getASTContext();
+  auto B =
+  internal::getExpansionLocOfMacro(MacroName, Node.getBeginLoc(), Context);
+  if (!B) return false;
+  auto E =

Please do not use auto when the type is not spelled out in the initialization.



Comment at: clang/lib/ASTMatchers/ASTMatchersInternal.cpp:614
+   const ASTContext &Context) {
+  auto& SM = Context.getSourceManager();
+  const auto& LangOpts = Context.getLangOpts();

Same comments here about use of `auto`.



Comment at: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:128
+
+TEST(IsExpandedFromMacro, ShouldNotMatchDifferentInstances) {
+  std::string input = R"cc(

One test that's missing which is important are macros defined on the command 
line rather than defined in source, as those have expansion locations that are 
in the scratch buffer rather than a source file. Are you able to add such a 
test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73965



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


[PATCH] D73965: [clang] Add matcher to identify macro expansions.

2020-02-04 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Aaron -- I missed your comments before submitting. I'll send a follow up with 
fixes. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73965



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


[PATCH] D73453: Preserve -nostdinc and --sysroot when calling query driver

2020-02-04 Thread Tobias Pisani via Phabricator via cfe-commits
topisani added a comment.

In D73453#1857095 , @kadircet wrote:

> let me know if you need me to commit this.


Yes please, thanks for your time!


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

https://reviews.llvm.org/D73453



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


[clang] 9271cab - [BPF] use base lvalue type for preserve_{struct, union}_access_index metadata

2020-02-04 Thread Yonghong Song via cfe-commits

Author: Yonghong Song
Date: 2020-02-04T09:28:30-08:00
New Revision: 9271cab270a52b5200ef45a16f1a9d9baaccaba0

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

LOG: [BPF] use base lvalue type for preserve_{struct,union}_access_index 
metadata

Linux commit
  
https://github.com/torvalds/linux/commit/1cf5b23988ea0086a252a5c8b005b075f1e9b030#diff-289313b9fec99c6f0acfea19d9cfd949
uses "#pragma clang attribute push (__attribute__((preserve_access_index)),
  apply_to = record)"
to apply CO-RE relocations to all records including the following pattern:
  #pragma clang attribute push (__attribute__((preserve_access_index)), 
apply_to = record)
  typedef struct {
int a;
  } __t;
  #pragma clang attribute pop
  int test(__t *arg) { return arg->a; }

The current approach to use struct type in the relocation record will
result in an anonymous struct, which make later type matching difficult
in bpf loader. In fact, current BPF backend will fail the above program
with assertion:
  clang: ../lib/Target/BPF/BPFAbstractMemberAccess.cpp:796: ...
 Assertion `TypeName.size()' failed.

The patch use the base lvalue type for the "base" value to annotate
preservee_{struct,union}_access_index intrinsics. In the above example,
the type will be "__t" which preserved the type name.

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

Added: 
clang/test/CodeGen/builtin-preserve-access-index-typedef.c

Modified: 
clang/lib/CodeGen/CGExpr.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 4b8a31c180c8..17fc16a1fe5b 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -4024,17 +4024,17 @@ static Address emitAddrOfFieldStorage(CodeGenFunction 
&CGF, Address base,
   return CGF.Builder.CreateStructGEP(base, idx, field->getName());
 }
 
-static Address emitPreserveStructAccess(CodeGenFunction &CGF, Address base,
-const FieldDecl *field) {
+static Address emitPreserveStructAccess(CodeGenFunction &CGF, LValue base,
+Address addr, const FieldDecl *field) {
   const RecordDecl *rec = field->getParent();
-  llvm::DIType *DbgInfo = CGF.getDebugInfo()->getOrCreateRecordType(
-  CGF.getContext().getRecordType(rec), rec->getLocation());
+  llvm::DIType *DbgInfo = CGF.getDebugInfo()->getOrCreateStandaloneType(
+  base.getType(), rec->getLocation());
 
   unsigned idx =
   CGF.CGM.getTypes().getCGRecordLayout(rec).getLLVMFieldNo(field);
 
   return CGF.Builder.CreatePreserveStructAccessIndex(
-  base, idx, CGF.getDebugInfoFIndex(rec, field->getFieldIndex()), DbgInfo);
+  addr, idx, CGF.getDebugInfoFIndex(rec, field->getFieldIndex()), DbgInfo);
 }
 
 static bool hasAnyVptr(const QualType Type, const ASTContext &Context) {
@@ -4158,8 +4158,8 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
 if (IsInPreservedAIRegion ||
 (getDebugInfo() && rec->hasAttr())) {
   // Remember the original union field index
-  llvm::DIType *DbgInfo = getDebugInfo()->getOrCreateRecordType(
-  getContext().getRecordType(rec), rec->getLocation());
+  llvm::DIType *DbgInfo = 
getDebugInfo()->getOrCreateStandaloneType(base.getType(),
+  rec->getLocation());
   addr = Address(
   Builder.CreatePreserveUnionAccessIndex(
   addr.getPointer(), getDebugInfoFIndex(rec, 
field->getFieldIndex()), DbgInfo),
@@ -4176,7 +4176,7 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
   addr = emitAddrOfFieldStorage(*this, addr, field);
 else
   // Remember the original struct field index
-  addr = emitPreserveStructAccess(*this, addr, field);
+  addr = emitPreserveStructAccess(*this, base, addr, field);
   }
 
   // If this is a reference field, load the reference right now.

diff  --git a/clang/test/CodeGen/builtin-preserve-access-index-typedef.c 
b/clang/test/CodeGen/builtin-preserve-access-index-typedef.c
new file mode 100644
index ..c7752cd23abd
--- /dev/null
+++ b/clang/test/CodeGen/builtin-preserve-access-index-typedef.c
@@ -0,0 +1,24 @@
+// REQUIRES: bpf-registered-target
+// RUN: %clang -target bpf -emit-llvm -S -g %s -o - | FileCheck %s
+
+#pragma clang attribute push (__attribute__((preserve_access_index)), apply_to 
= record)
+typedef struct {
+   int a;
+} __t;
+typedef union {
+   int b;
+} __u;
+#pragma clang attribute pop
+
+int test1(__t *arg) { return arg->a; }
+int test2(const __u *arg) { return arg->b; }
+
+
+// CHECK: define dso_local i32 @test1
+// CHECK: call i32* 
@llvm.preserve.struct.access.index.p0i32.p0s_struct.__ts(%struct.__t* 
%{{[0-9a-z]+}}, i32 0, i32 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index 
![[TYPEDEF_STRUCT:[0-9]+]]
+//

[PATCH] D73900: [BPF] use base lvalue type for preserve_{struct,union}_access_index metadata

2020-02-04 Thread Yonghong Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9271cab270a5: [BPF] use base lvalue type for 
preserve_{struct,union}_access_index metadata (authored by yonghong-song).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73900

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/builtin-preserve-access-index-typedef.c


Index: clang/test/CodeGen/builtin-preserve-access-index-typedef.c
===
--- /dev/null
+++ clang/test/CodeGen/builtin-preserve-access-index-typedef.c
@@ -0,0 +1,24 @@
+// REQUIRES: bpf-registered-target
+// RUN: %clang -target bpf -emit-llvm -S -g %s -o - | FileCheck %s
+
+#pragma clang attribute push (__attribute__((preserve_access_index)), apply_to 
= record)
+typedef struct {
+   int a;
+} __t;
+typedef union {
+   int b;
+} __u;
+#pragma clang attribute pop
+
+int test1(__t *arg) { return arg->a; }
+int test2(const __u *arg) { return arg->b; }
+
+
+// CHECK: define dso_local i32 @test1
+// CHECK: call i32* 
@llvm.preserve.struct.access.index.p0i32.p0s_struct.__ts(%struct.__t* 
%{{[0-9a-z]+}}, i32 0, i32 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index 
![[TYPEDEF_STRUCT:[0-9]+]]
+// CHECK: define dso_local i32 @test2
+// CHECK: call %union.__u* 
@llvm.preserve.union.access.index.p0s_union.__us.p0s_union.__us(%union.__u* 
%{{[0-9a-z]+}}, i32 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index 
![[CONST_TYPEDEF:[0-9]+]]
+//
+// CHECK: ![[TYPEDEF_STRUCT]] = !DIDerivedType(tag: DW_TAG_typedef, name: "__t"
+// CHECK: ![[CONST_TYPEDEF]] = !DIDerivedType(tag: DW_TAG_const_type, 
baseType: ![[TYPEDEF_UNION:[0-9]+]]
+// CHECK: ![[TYPEDEF_UNION]] = !DIDerivedType(tag: DW_TAG_typedef, name: "__u"
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -4024,17 +4024,17 @@
   return CGF.Builder.CreateStructGEP(base, idx, field->getName());
 }
 
-static Address emitPreserveStructAccess(CodeGenFunction &CGF, Address base,
-const FieldDecl *field) {
+static Address emitPreserveStructAccess(CodeGenFunction &CGF, LValue base,
+Address addr, const FieldDecl *field) {
   const RecordDecl *rec = field->getParent();
-  llvm::DIType *DbgInfo = CGF.getDebugInfo()->getOrCreateRecordType(
-  CGF.getContext().getRecordType(rec), rec->getLocation());
+  llvm::DIType *DbgInfo = CGF.getDebugInfo()->getOrCreateStandaloneType(
+  base.getType(), rec->getLocation());
 
   unsigned idx =
   CGF.CGM.getTypes().getCGRecordLayout(rec).getLLVMFieldNo(field);
 
   return CGF.Builder.CreatePreserveStructAccessIndex(
-  base, idx, CGF.getDebugInfoFIndex(rec, field->getFieldIndex()), DbgInfo);
+  addr, idx, CGF.getDebugInfoFIndex(rec, field->getFieldIndex()), DbgInfo);
 }
 
 static bool hasAnyVptr(const QualType Type, const ASTContext &Context) {
@@ -4158,8 +4158,8 @@
 if (IsInPreservedAIRegion ||
 (getDebugInfo() && rec->hasAttr())) {
   // Remember the original union field index
-  llvm::DIType *DbgInfo = getDebugInfo()->getOrCreateRecordType(
-  getContext().getRecordType(rec), rec->getLocation());
+  llvm::DIType *DbgInfo = 
getDebugInfo()->getOrCreateStandaloneType(base.getType(),
+  rec->getLocation());
   addr = Address(
   Builder.CreatePreserveUnionAccessIndex(
   addr.getPointer(), getDebugInfoFIndex(rec, 
field->getFieldIndex()), DbgInfo),
@@ -4176,7 +4176,7 @@
   addr = emitAddrOfFieldStorage(*this, addr, field);
 else
   // Remember the original struct field index
-  addr = emitPreserveStructAccess(*this, addr, field);
+  addr = emitPreserveStructAccess(*this, base, addr, field);
   }
 
   // If this is a reference field, load the reference right now.


Index: clang/test/CodeGen/builtin-preserve-access-index-typedef.c
===
--- /dev/null
+++ clang/test/CodeGen/builtin-preserve-access-index-typedef.c
@@ -0,0 +1,24 @@
+// REQUIRES: bpf-registered-target
+// RUN: %clang -target bpf -emit-llvm -S -g %s -o - | FileCheck %s
+
+#pragma clang attribute push (__attribute__((preserve_access_index)), apply_to = record)
+typedef struct {
+   int a;
+} __t;
+typedef union {
+   int b;
+} __u;
+#pragma clang attribute pop
+
+int test1(__t *arg) { return arg->a; }
+int test2(const __u *arg) { return arg->b; }
+
+
+// CHECK: define dso_local i32 @test1
+// CHECK: call i32* @llvm.preserve.struct.access.index.p0i32.p0s_struct.__ts(%struct.__t* %{{[0-9a-z]+}}, i32 0, i32 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[TYPEDEF_STRUCT:[0-9]+]]
+// CHECK: define dso_local i32 @test2
+// CHECK: call %union.__u* @llvm.preserve.union.access.index.p0s_union.__us.p0s_union.__us(%union.__u* %

[clang] 2513118 - [Driver] Change -fmax-tokens $arg to -fmax-tokens=$arg

2020-02-04 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-02-04T09:39:48-08:00
New Revision: 2513118afa385b9df3662050e3aa0a1e3f5e2a8a

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

LOG: [Driver] Change -fmax-tokens $arg to -fmax-tokens=$arg

Reviewed By: hans

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Parse/Parser.cpp
clang/test/Parser/max-tokens.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 12551b13e7bb..2dcedcb60340 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1168,14 +1168,14 @@ the token limit, which can be set in three ways:
.. code-block: c++
   #pragma clang max_tokens_here 1234
 
-2. As a per-translation unit limit, using the ``-fmax-tokens`` command-line
+2. As a per-translation unit limit, using the ``-fmax-tokens=`` command-line
flag:
 
.. code-block: console
-  clang -c a.cpp -fmax-tokens 1234
+  clang -c a.cpp -fmax-tokens=1234
 
 3. As a per-translation unit limit using the ``clang max_tokens_total`` pragma,
-   which works like and overrides the ``-fmax-tokens`` flag:
+   which works like and overrides the ``-fmax-tokens=`` flag:
 
.. code-block: c++
   #pragma clang max_file_tokens 1234

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index dcec7e6fde1e..388ff094ae44 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -646,9 +646,8 @@ def emit_merged_ifs : Flag<["-"], "emit-merged-ifs">,
 def interface_stub_version_EQ : JoinedOrSeparate<["-"], 
"interface-stub-version=">, Flags<[CC1Option]>;
 def exported__symbols__list : Separate<["-"], "exported_symbols_list">;
 def e : JoinedOrSeparate<["-"], "e">, Group;
-def fmax_tokens : Separate<["-"], "fmax-tokens">,
-  HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">,
-  Group, Flags<[CC1Option]>;
+def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">;
 def fPIC : Flag<["-"], "fPIC">, Group;
 def fno_PIC : Flag<["-"], "fno-PIC">, Group;
 def fPIE : Flag<["-"], "fPIE">, Group;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 64bba78ac26f..aa599b02e44a 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5731,7 +5731,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   Args.AddLastArg(CmdArgs, options::OPT_dM);
   Args.AddLastArg(CmdArgs, options::OPT_dD);
 
-  Args.AddLastArg(CmdArgs, options::OPT_fmax_tokens);
+  Args.AddLastArg(CmdArgs, options::OPT_fmax_tokens_EQ);
 
   // Handle serialized diagnostics.
   if (Arg *A = Args.getLastArg(options::OPT__serialize_diags)) {

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index a71145202052..9f51c8478327 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3320,7 +3320,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   Opts.CompleteMemberPointers = Args.hasArg(OPT_fcomplete_member_pointers);
   Opts.BuildingPCHWithObjectFile = Args.hasArg(OPT_building_pch_with_obj);
 
-  Opts.MaxTokens = getLastArgIntValue(Args, OPT_fmax_tokens, 0, Diags);
+  Opts.MaxTokens = getLastArgIntValue(Args, OPT_fmax_tokens_EQ, 0, Diags);
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {

diff  --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index fd05b760cc90..f23742f67e3b 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -650,7 +650,7 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result, bool 
IsFirstDecl) {
 return false;
 
   case tok::eof:
-// Check whether -fmax-tokens was reached.
+// Check whether -fmax-tokens= was reached.
 if (PP.getMaxTokens() != 0 && PP.getTokenCount() > PP.getMaxTokens()) {
   PP.Diag(Tok.getLocation(), diag::warn_max_tokens_total)
   << PP.getTokenCount() << PP.getMaxTokens();

diff  --git a/clang/test/Parser/max-tokens.cpp 
b/clang/test/Parser/max-tokens.cpp
index 982432e8a65c..5be892773fe4 100644
--- a/clang/test/Parser/max-tokens.cpp
+++ b/clang/test/Parser/max-tokens.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS  -fmax-tokens 
2
-// RUN

[PATCH] D73937: [Driver] Change -fmax-tokens $arg to -fmax-tokens=$arg

2020-02-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 242359.
MaskRay added a comment.

Rename to fmax_tokens_EQ as a convention


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73937

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/max-tokens.cpp


Index: clang/test/Parser/max-tokens.cpp
===
--- clang/test/Parser/max-tokens.cpp
+++ clang/test/Parser/max-tokens.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS  -fmax-tokens 
2
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS_OVERRIDE -fmax-tokens 
9
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS  
-fmax-tokens=2
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS_OVERRIDE 
-fmax-tokens=9
 
 int x, y, z;
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -650,7 +650,7 @@
 return false;
 
   case tok::eof:
-// Check whether -fmax-tokens was reached.
+// Check whether -fmax-tokens= was reached.
 if (PP.getMaxTokens() != 0 && PP.getTokenCount() > PP.getMaxTokens()) {
   PP.Diag(Tok.getLocation(), diag::warn_max_tokens_total)
   << PP.getTokenCount() << PP.getMaxTokens();
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3320,7 +3320,7 @@
   Opts.CompleteMemberPointers = Args.hasArg(OPT_fcomplete_member_pointers);
   Opts.BuildingPCHWithObjectFile = Args.hasArg(OPT_building_pch_with_obj);
 
-  Opts.MaxTokens = getLastArgIntValue(Args, OPT_fmax_tokens, 0, Diags);
+  Opts.MaxTokens = getLastArgIntValue(Args, OPT_fmax_tokens_EQ, 0, Diags);
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5731,7 +5731,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_dM);
   Args.AddLastArg(CmdArgs, options::OPT_dD);
 
-  Args.AddLastArg(CmdArgs, options::OPT_fmax_tokens);
+  Args.AddLastArg(CmdArgs, options::OPT_fmax_tokens_EQ);
 
   // Handle serialized diagnostics.
   if (Arg *A = Args.getLastArg(options::OPT__serialize_diags)) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -646,9 +646,8 @@
 def interface_stub_version_EQ : JoinedOrSeparate<["-"], 
"interface-stub-version=">, Flags<[CC1Option]>;
 def exported__symbols__list : Separate<["-"], "exported_symbols_list">;
 def e : JoinedOrSeparate<["-"], "e">, Group;
-def fmax_tokens : Separate<["-"], "fmax-tokens">,
-  HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">,
-  Group, Flags<[CC1Option]>;
+def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">;
 def fPIC : Flag<["-"], "fPIC">, Group;
 def fno_PIC : Flag<["-"], "fno-PIC">, Group;
 def fPIE : Flag<["-"], "fPIE">, Group;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1168,14 +1168,14 @@
.. code-block: c++
   #pragma clang max_tokens_here 1234
 
-2. As a per-translation unit limit, using the ``-fmax-tokens`` command-line
+2. As a per-translation unit limit, using the ``-fmax-tokens=`` command-line
flag:
 
.. code-block: console
-  clang -c a.cpp -fmax-tokens 1234
+  clang -c a.cpp -fmax-tokens=1234
 
 3. As a per-translation unit limit using the ``clang max_tokens_total`` pragma,
-   which works like and overrides the ``-fmax-tokens`` flag:
+   which works like and overrides the ``-fmax-tokens=`` flag:
 
.. code-block: c++
   #pragma clang max_file_tokens 1234


Index: clang/test/Parser/max-tokens.cpp
===
--- clang/test/Parser/max-tokens.cpp
+++ clang/test/Parser/max-tokens.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS  -fmax-tokens 2
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS_OVERRIDE -fmax-tokens 9
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS  -fmax-tokens=2
+// RUN: %clang_cc1

[PATCH] D73975: [clang][NFC] Expand some `auto`s and add another test for matcher `isExpandedFromMacro`.

2020-02-04 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: aaron.ballman.
Herald added a project: clang.

Spells out some `auto`s explicitly and adds another test for the matcher 
`isExpandedFromMacro`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73975

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -99,6 +99,15 @@
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("PLUS";
 }
 
+TEST(IsExpandedFromMacro, ShouldMatchFromCommandLine) {
+  std::string input = R"cc(
+void Test() { FOUR_PLUS_FOUR; }
+  )cc";
+  EXPECT_TRUE(matchesConditionally(input,
+   
binaryOperator(isExpandedFromMacro("FOUR_PLUS_FOUR")),
+   true, {"-std=c++11", 
"-DFOUR_PLUS_FOUR=4+4"}));
+}
+
 TEST(IsExpandedFromMacro, ShouldNotMatchBeginOnly) {
   std::string input = R"cc(
 #define ONE_PLUS 1+
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -603,22 +603,23 @@
   bool Invalid = false;
   // Since `Loc` may point into an expansion buffer, which has no corresponding
   // source, we need to look at the spelling location to read the actual 
source.
-  StringRef TokenText = clang::Lexer::getSpelling(
-  SM.getSpellingLoc(Loc), Buffer, SM, LangOpts, &Invalid);
+  StringRef TokenText = Lexer::getSpelling(SM.getSpellingLoc(Loc), Buffer, SM,
+   LangOpts, &Invalid);
   return !Invalid && Text == TokenText;
 }
 
 llvm::Optional
 getExpansionLocOfMacro(StringRef MacroName, SourceLocation Loc,
const ASTContext &Context) {
-  auto& SM = Context.getSourceManager();
-  const auto& LangOpts = Context.getLangOpts();
+  auto &SM = Context.getSourceManager();
+  const LangOptions &LangOpts = Context.getLangOpts();
   while (Loc.isMacroID()) {
-auto Expansion = SM.getSLocEntry(SM.getFileID(Loc)).getExpansion();
+SrcMgr::ExpansionInfo Expansion =
+SM.getSLocEntry(SM.getFileID(Loc)).getExpansion();
 if (Expansion.isMacroArgExpansion())
   // Check macro argument for an expansion of the given macro. For example,
   // `F(G(3))`, where `MacroName` is `G`.
-  if (auto ArgLoc = getExpansionLocOfMacro(
+  if (llvm::Optional ArgLoc = getExpansionLocOfMacro(
   MacroName, Expansion.getSpellingLoc(), Context))
 return ArgLoc;
 Loc = Expansion.getExpansionLocStart();
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -311,10 +311,10 @@
   // Verifies that the statement' beginning and ending are both expanded from
   // the same instance of the given macro.
   auto& Context = Finder->getASTContext();
-  auto B =
+  llvm::Optional B =
   internal::getExpansionLocOfMacro(MacroName, Node.getBeginLoc(), Context);
   if (!B) return false;
-  auto E =
+  llvm::Optional E =
   internal::getExpansionLocOfMacro(MacroName, Node.getEndLoc(), Context);
   if (!E) return false;
   return *B == *E;


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -99,6 +99,15 @@
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("PLUS";
 }
 
+TEST(IsExpandedFromMacro, ShouldMatchFromCommandLine) {
+  std::string input = R"cc(
+void Test() { FOUR_PLUS_FOUR; }
+  )cc";
+  EXPECT_TRUE(matchesConditionally(input,
+   binaryOperator(isExpandedFromMacro("FOUR_PLUS_FOUR")),
+   true, {"-std=c++11", "-DFOUR_PLUS_FOUR=4+4"}));
+}
+
 TEST(IsExpandedFromMacro, ShouldNotMatchBeginOnly) {
   std::string input = R"cc(
 #define ONE_PLUS 1+
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -603,22 +603,23 @@
   bool Invalid = false;
   // Since `Loc` may point into an expansion buffer, which has no corresponding
   // source, we need to look at the spelling location to read the actual source.
-  StringRef TokenText = clang::Lexer::getSpelling(
-  SM.getSpellingLoc(Loc), Buffer, SM, LangOpts, &Invalid);

[PATCH] D73937: [Driver] Change -fmax-tokens $arg to -fmax-tokens=$arg

2020-02-04 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2513118afa38: [Driver] Change -fmax-tokens $arg to 
-fmax-tokens=$arg (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73937

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/max-tokens.cpp


Index: clang/test/Parser/max-tokens.cpp
===
--- clang/test/Parser/max-tokens.cpp
+++ clang/test/Parser/max-tokens.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS  -fmax-tokens 
2
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS_OVERRIDE -fmax-tokens 
9
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS  
-fmax-tokens=2
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS_OVERRIDE 
-fmax-tokens=9
 
 int x, y, z;
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -650,7 +650,7 @@
 return false;
 
   case tok::eof:
-// Check whether -fmax-tokens was reached.
+// Check whether -fmax-tokens= was reached.
 if (PP.getMaxTokens() != 0 && PP.getTokenCount() > PP.getMaxTokens()) {
   PP.Diag(Tok.getLocation(), diag::warn_max_tokens_total)
   << PP.getTokenCount() << PP.getMaxTokens();
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3320,7 +3320,7 @@
   Opts.CompleteMemberPointers = Args.hasArg(OPT_fcomplete_member_pointers);
   Opts.BuildingPCHWithObjectFile = Args.hasArg(OPT_building_pch_with_obj);
 
-  Opts.MaxTokens = getLastArgIntValue(Args, OPT_fmax_tokens, 0, Diags);
+  Opts.MaxTokens = getLastArgIntValue(Args, OPT_fmax_tokens_EQ, 0, Diags);
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5731,7 +5731,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_dM);
   Args.AddLastArg(CmdArgs, options::OPT_dD);
 
-  Args.AddLastArg(CmdArgs, options::OPT_fmax_tokens);
+  Args.AddLastArg(CmdArgs, options::OPT_fmax_tokens_EQ);
 
   // Handle serialized diagnostics.
   if (Arg *A = Args.getLastArg(options::OPT__serialize_diags)) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -646,9 +646,8 @@
 def interface_stub_version_EQ : JoinedOrSeparate<["-"], 
"interface-stub-version=">, Flags<[CC1Option]>;
 def exported__symbols__list : Separate<["-"], "exported_symbols_list">;
 def e : JoinedOrSeparate<["-"], "e">, Group;
-def fmax_tokens : Separate<["-"], "fmax-tokens">,
-  HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">,
-  Group, Flags<[CC1Option]>;
+def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">;
 def fPIC : Flag<["-"], "fPIC">, Group;
 def fno_PIC : Flag<["-"], "fno-PIC">, Group;
 def fPIE : Flag<["-"], "fPIE">, Group;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1168,14 +1168,14 @@
.. code-block: c++
   #pragma clang max_tokens_here 1234
 
-2. As a per-translation unit limit, using the ``-fmax-tokens`` command-line
+2. As a per-translation unit limit, using the ``-fmax-tokens=`` command-line
flag:
 
.. code-block: console
-  clang -c a.cpp -fmax-tokens 1234
+  clang -c a.cpp -fmax-tokens=1234
 
 3. As a per-translation unit limit using the ``clang max_tokens_total`` pragma,
-   which works like and overrides the ``-fmax-tokens`` flag:
+   which works like and overrides the ``-fmax-tokens=`` flag:
 
.. code-block: c++
   #pragma clang max_file_tokens 1234


Index: clang/test/Parser/max-tokens.cpp
===
--- clang/test/Parser/max-tokens.cpp
+++ clang/test/Parser/max-tokens.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS  -fmax-tokens 2
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS_OVERRIDE -fmax-tokens 9
+// RUN: %clang_cc1 -fsyntax-

[PATCH] D73975: [clang][NFC] Expand some `auto`s and add another test for matcher `isExpandedFromMacro`.

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

LGTM, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73975



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


[PATCH] D31337: Use virtual functions in ParsedAttrInfo instead of function pointers

2020-02-04 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 242363.
john.brawn added a comment.

Move DefaultParsedAttrInfo out of file scope, and move custom appertains-to 
function generation out of the loop in EmitClangAttrParsedAttrImpl so we only 
need to use one output stream.


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

https://reviews.llvm.org/D31337

Files:
  clang/lib/Sema/ParsedAttr.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1807,7 +1807,7 @@
 
   void emitMatchRuleList(raw_ostream &OS);
 
-  std::string generateStrictConformsTo(const Record &Attr, raw_ostream &OS);
+  void generateStrictConformsTo(const Record &Attr, raw_ostream &OS);
 
   void generateParsingHelpers(raw_ostream &OS);
 };
@@ -1968,21 +1968,17 @@
   return Test;
 }
 
-std::string
+void
 PragmaClangAttributeSupport::generateStrictConformsTo(const Record &Attr,
   raw_ostream &OS) {
-  if (!isAttributedSupported(Attr))
-return "nullptr";
+  if (!isAttributedSupported(Attr) || Attr.isValueUnset("Subjects"))
+return;
   // Generate a function that constructs a set of matching rules that describe
   // to which declarations the attribute should apply to.
-  std::string FnName = "matchRulesFor" + Attr.getName().str();
-  OS << "static void " << FnName << "(llvm::SmallVectorImpl> &MatchRules, const LangOptions &LangOpts) {\n";
-  if (Attr.isValueUnset("Subjects")) {
-OS << "}\n\n";
-return FnName;
-  }
+ << ", bool>> &MatchRules, const LangOptions &LangOpts) const {\n";
   const Record *SubjectObj = Attr.getValueAsDef("Subjects");
   std::vector Subjects = SubjectObj->getValueAsListOfDefs("Subjects");
   for (const auto *Subject : Subjects) {
@@ -1999,7 +1995,6 @@
 }
   }
   OS << "}\n\n";
-  return FnName;
 }
 
 void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
@@ -3293,14 +3288,8 @@
 
   // If there is a variadic argument, we will set the optional argument count
   // to its largest value. Since it's currently a 4-bit number, we set it to 15.
-  OS << ArgCount << ", " << (HasVariadic ? 15 : OptCount);
-}
-
-static void GenerateDefaultAppertainsTo(raw_ostream &OS) {
-  OS << "static bool defaultAppertainsTo(Sema &, const ParsedAttr &,";
-  OS << "const Decl *) {\n";
-  OS << "  return true;\n";
-  OS << "}\n\n";
+  OS << "NumArgs = " << ArgCount << ";\n";
+  OS << "OptArgs = " << (HasVariadic ? 15 : OptCount) << ";\n";
 }
 
 static std::string GetDiagnosticSpelling(const Record &R) {
@@ -3381,16 +3370,14 @@
   return "is" + Subject.getName().str();
 }
 
-static std::string GenerateCustomAppertainsTo(const Record &Subject,
-  raw_ostream &OS) {
+static void GenerateCustomAppertainsTo(const Record &Subject, raw_ostream &OS) {
   std::string FnName = functionNameForCustomAppertainsTo(Subject);
 
-  // If this code has already been generated, simply return the previous
-  // instance of it.
+  // If this code has already been generated, we don't need to do anything.
   static std::set CustomSubjectSet;
   auto I = CustomSubjectSet.find(FnName);
   if (I != CustomSubjectSet.end())
-return *I;
+return;
 
   // This only works with non-root Decls.
   Record *Base = Subject.getValueAsDef(BaseFieldName);
@@ -3399,7 +3386,7 @@
   if (Base->isSubClassOf("SubsetSubject")) {
 PrintFatalError(Subject.getLoc(),
 "SubsetSubjects within SubsetSubjects is not supported");
-return "";
+return;
   }
 
   OS << "static bool " << FnName << "(const Decl *D) {\n";
@@ -3411,14 +3398,13 @@
   OS << "}\n\n";
 
   CustomSubjectSet.insert(FnName);
-  return FnName;
 }
 
-static std::string GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) {
+static void GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) {
   // If the attribute does not contain a Subjects definition, then use the
   // default appertainsTo logic.
   if (Attr.isValueUnset("Subjects"))
-return "defaultAppertainsTo";
+return;
 
   const Record *SubjectObj = Attr.getValueAsDef("Subjects");
   std::vector Subjects = SubjectObj->getValueAsListOfDefs("Subjects");
@@ -3426,52 +3412,46 @@
   // If the list of subjects is empty, it is assumed that the attribute
   // appertains to everything.
   if (Subjects.empty())
-return "defaultAppertainsTo";
+return;
 
   bool Warn = SubjectObj->getValueAsDef("Diag")->getValueAsBit("Warn");
 
   // Otherwise, generate an appertainsTo check specific to this attribute which
-  // checks all of the given subjects against the Decl passed in. Return the
-  // name of that check to the caller.
+  // checks all of the given subjects against the Decl passed in.
   //
   // If D is null, that means the attribute was not applied to a dec

[PATCH] D68923: Don't warn about missing declarations for partial template specializations

2020-02-04 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a subscriber: hans.
aaronpuchert added a comment.

@hans, could you cherry-pick this on the version 10 branch? As I wrote in 
D68923#1857046 , this is a regression 
from Clang 8.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68923



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


[PATCH] D73937: [Driver] Change -fmax-tokens $arg to -fmax-tokens=$arg

2020-02-04 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73937



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


[clang] fce1eef - [clang] fix lib/ASTMatchers for BUILD_SHARED_LIBS=ON

2020-02-04 Thread Stephen Neuendorffer via cfe-commits

Author: Stephen Neuendorffer
Date: 2020-02-04T09:54:28-08:00
New Revision: fce1eefb467e2bc3cd737ce78386e4970beefb7a

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

LOG: [clang] fix lib/ASTMatchers for BUILD_SHARED_LIBS=ON

Added: 


Modified: 
clang/lib/ASTMatchers/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/ASTMatchers/CMakeLists.txt 
b/clang/lib/ASTMatchers/CMakeLists.txt
index b49528ede227..cd88d1db9ce4 100644
--- a/clang/lib/ASTMatchers/CMakeLists.txt
+++ b/clang/lib/ASTMatchers/CMakeLists.txt
@@ -9,4 +9,5 @@ add_clang_library(clangASTMatchers
   LINK_LIBS
   clangAST
   clangBasic
+  clangLex
   )



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


[clang] a3c814d - Separately track input and output denormal mode

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

Author: Matt Arsenault
Date: 2020-02-04T12:59:21-05:00
New Revision: a3c814d23497bc71b8ed53c35f773366aff02922

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

LOG: Separately track input and output denormal mode

AMDGPU and x86 at least both have separate controls for whether
denormal results are flushed on output, and for whether denormals are
implicitly treated as 0 as an input. The current DAGCombiner use only
really cares about the input treatment of denormals.

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Driver/ToolChain.h
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Cuda.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/denormalfpmode.c
clang/test/CodeGenCUDA/flush-denormals.cu
clang/test/CodeGenCUDA/propagate-metadata.cu
clang/test/Driver/cl-denorms-are-zero.cl
clang/test/Driver/cuda-flush-denormals-to-zero.cu
clang/test/Driver/denormal-fp-math.c
llvm/docs/LangRef.rst
llvm/include/llvm/ADT/FloatingPointMode.h
llvm/lib/CodeGen/MachineFunction.cpp
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/unittests/ADT/FloatingPointMode.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 6962b6022e85..0a28edefa1e6 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::Invalid;
+  llvm::DenormalMode FPDenormalMode;
 
   /// The floating-point subnormal mode to use, for float.
-  llvm::DenormalMode FP32DenormalMode = llvm::DenormalMode::Invalid;
+  llvm::DenormalMode FP32DenormalMode;
 
   /// 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 53e00c14c0ca..09f145844641 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -617,7 +617,7 @@ class ToolChain {
   Action::OffloadKind DeviceOffloadKind,
   const llvm::fltSemantics *FPType = nullptr) const {
 // FIXME: This should be IEEE when default handling is fixed.
-return llvm::DenormalMode::Invalid;
+return llvm::DenormalMode::getInvalid();
   }
 };
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 0aaf6813442a..a34d3d8b4353 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -247,7 +247,7 @@ void AMDGPUTargetInfo::adjustTargetOptions(const 
CodeGenOptions &CGOpts,
   if (!hasFP32Denormals)
 TargetOpts.Features.push_back(
   (Twine(hasFastFMAF() && hasFullRateDenormalsF32() &&
- CGOpts.FP32DenormalMode == llvm::DenormalMode::IEEE
+ CGOpts.FP32DenormalMode.Output == llvm::DenormalMode::IEEE
  ? '+' : '-') + Twine("fp32-denormals"))
 .str());
   // Always do not flush fp64 or fp16 denorms.

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 9ed2ccd54487..cdd3ca474edf 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1749,14 +1749,14 @@ void 
CodeGenModule::ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone,
   FuncAttrs.addAttribute("null-pointer-is-valid", "true");
 
 // TODO: Omit attribute when the default is IEEE.
-if (CodeGenOpts.FPDenormalMode != llvm::DenormalMode::Invalid)
+if (CodeGenOpts.FPDenormalMode.isValid())
   FuncAttrs.addAttribute("denormal-fp-math",
- 
llvm::denormalModeName(CodeGenOpts.FPDenormalMode));
-
-if (CodeGenOpts.FP32DenormalMode != llvm::DenormalMode::Invalid)
+ CodeGenOpts.FPDenormalMode.str());
+if (CodeGenOpts.FP32DenormalMode.isValid()) {
   FuncAttrs.addAttribute(
   "denormal-fp-math-f32",
-  llvm::denormalModeName(CodeGenOpts.FP32DenormalMode));
+  CodeGenOpts.FP32DenormalMode.str());
+}
 
 FuncAttrs.addAttribute("no-trapping-math",
llvm::toStringRef(CodeGenOpts.NoTrappingMath));

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 6a43b6bba627..4e730025ac4f 100644
--- a/clang/lib/CodeGen/Co

[PATCH] D69978: Separately track input and output denormal mode

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

a3c814d23497bc71b8ed53c35f773366aff02922 



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

https://reviews.llvm.org/D69978



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


[clang] e5ff92e - [clang][NFC] Expand some `auto`s and add another test for matcher `isExpandedFromMacro`.

2020-02-04 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2020-02-04T13:05:58-05:00
New Revision: e5ff92e049b5b60d208d8b87f5ee693a7464d076

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

LOG: [clang][NFC] Expand some `auto`s and add another test for matcher 
`isExpandedFromMacro`.

Summary: Spells out some `auto`s explicitly and adds another test for the 
matcher `isExpandedFromMacro`.

Reviewers: aaron.ballman

Subscribers: gribozavr, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index ec969b42c6ae..eadf167dcefe 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -311,10 +311,10 @@ AST_MATCHER_P(clang::Stmt, isExpandedFromMacro, 
llvm::StringRef, MacroName) {
   // Verifies that the statement' beginning and ending are both expanded from
   // the same instance of the given macro.
   auto& Context = Finder->getASTContext();
-  auto B =
+  llvm::Optional B =
   internal::getExpansionLocOfMacro(MacroName, Node.getBeginLoc(), Context);
   if (!B) return false;
-  auto E =
+  llvm::Optional E =
   internal::getExpansionLocOfMacro(MacroName, Node.getEndLoc(), Context);
   if (!E) return false;
   return *B == *E;

diff  --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 53f6e1d1d278..e8f06358b932 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -603,22 +603,23 @@ static bool isTokenAtLoc(const SourceManager &SM, const 
LangOptions &LangOpts,
   bool Invalid = false;
   // Since `Loc` may point into an expansion buffer, which has no corresponding
   // source, we need to look at the spelling location to read the actual 
source.
-  StringRef TokenText = clang::Lexer::getSpelling(
-  SM.getSpellingLoc(Loc), Buffer, SM, LangOpts, &Invalid);
+  StringRef TokenText = Lexer::getSpelling(SM.getSpellingLoc(Loc), Buffer, SM,
+   LangOpts, &Invalid);
   return !Invalid && Text == TokenText;
 }
 
 llvm::Optional
 getExpansionLocOfMacro(StringRef MacroName, SourceLocation Loc,
const ASTContext &Context) {
-  auto& SM = Context.getSourceManager();
-  const auto& LangOpts = Context.getLangOpts();
+  auto &SM = Context.getSourceManager();
+  const LangOptions &LangOpts = Context.getLangOpts();
   while (Loc.isMacroID()) {
-auto Expansion = SM.getSLocEntry(SM.getFileID(Loc)).getExpansion();
+SrcMgr::ExpansionInfo Expansion =
+SM.getSLocEntry(SM.getFileID(Loc)).getExpansion();
 if (Expansion.isMacroArgExpansion())
   // Check macro argument for an expansion of the given macro. For example,
   // `F(G(3))`, where `MacroName` is `G`.
-  if (auto ArgLoc = getExpansionLocOfMacro(
+  if (llvm::Optional ArgLoc = getExpansionLocOfMacro(
   MacroName, Expansion.getSpellingLoc(), Context))
 return ArgLoc;
 Loc = Expansion.getExpansionLocStart();

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 2d6ce84b13ff..4b9fce9e3107 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -99,6 +99,15 @@ TEST(IsExpandedFromMacro, ShouldMatchObjectMacro) {
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("PLUS";
 }
 
+TEST(IsExpandedFromMacro, ShouldMatchFromCommandLine) {
+  std::string input = R"cc(
+void Test() { FOUR_PLUS_FOUR; }
+  )cc";
+  EXPECT_TRUE(matchesConditionally(input,
+   
binaryOperator(isExpandedFromMacro("FOUR_PLUS_FOUR")),
+   true, {"-std=c++11", 
"-DFOUR_PLUS_FOUR=4+4"}));
+}
+
 TEST(IsExpandedFromMacro, ShouldNotMatchBeginOnly) {
   std::string input = R"cc(
 #define ONE_PLUS 1+



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


[PATCH] D31338: Move ParsedAttrInfos into a registry and point to one in ParsedAttr

2020-02-04 Thread John Brawn via Phabricator via cfe-commits
john.brawn marked an inline comment as done.
john.brawn added inline comments.



Comment at: clang/lib/Basic/Attributes.cpp:101-103
+  for (ParsedAttrInfoRegistry::iterator it = ParsedAttrInfoRegistry::begin(),
+ie = ParsedAttrInfoRegistry::end();
+   it != ie; ++it) {

aaron.ballman wrote:
> Range-based for loop? Also, `it` and `ie` don't meet the usual naming 
> conventions.
> 
> One thing I'm not keen on with this is the performance hit. We spent a decent 
> amount of effort making this lookup fast and it's now a linear search through 
> all of the attributes and requires memory allocations and deallocations to 
> perform the search.
Yes, I've done some experiments and in the pathological case (lots of trivial 
functions with the xray_log_args attribute) the slowdown is noticeable. I've 
done some tinkering and I think the best way to resolve this is to first use a 
generated function (i.e. something like the current getAttrKind) to look up the 
attributes that are compiled into clang, then if that fails look in the 
registry to find a match.


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

https://reviews.llvm.org/D31338



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


[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-02-04 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp:731
+  }
+  return C.getNoteTag([Text, Name](BugReport &BR) -> std::string {
+  SmallString<256> Msg;

baloghadamsoftware wrote:
> NoQ wrote:
> > You'll need to check whether the container is actually of interest to the 
> > bug report. We don't want notes to be added about changes to irrelevant 
> > containers.
> > 
> > You can use a combination of "Report `BR` was emitted by one of the 
> > iterator checkers" and "The memory region of the container is marked as 
> > interesting" (while also actually marking it as interesting in the checker).
> > 
> > Ideally we should instead make a new generic storage inside the `BugReport` 
> > object, in order to pass down the interesting information from the call 
> > site of `emitReport` ("Hi, i'm an iterator checker who emitted this report 
> > and i'm interested in changes made to the size of this container").
> Are you sure in this? I already wondered how it works so I added a test that 
> checks one container and changes another one and there were no note tags 
> displayed for the one we did not check but change. See the last test.
That's because you didn't do
```lang=c++
  V2.cbegin();
  V2.cend();
```
in the beginning.


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

https://reviews.llvm.org/D73720



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


[PATCH] D73975: [clang][NFC] Expand some `auto`s and add another test for matcher `isExpandedFromMacro`.

2020-02-04 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe5ff92e049b5: [clang][NFC] Expand some `auto`s and add 
another test for matcher… (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73975

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -99,6 +99,15 @@
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("PLUS";
 }
 
+TEST(IsExpandedFromMacro, ShouldMatchFromCommandLine) {
+  std::string input = R"cc(
+void Test() { FOUR_PLUS_FOUR; }
+  )cc";
+  EXPECT_TRUE(matchesConditionally(input,
+   
binaryOperator(isExpandedFromMacro("FOUR_PLUS_FOUR")),
+   true, {"-std=c++11", 
"-DFOUR_PLUS_FOUR=4+4"}));
+}
+
 TEST(IsExpandedFromMacro, ShouldNotMatchBeginOnly) {
   std::string input = R"cc(
 #define ONE_PLUS 1+
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -603,22 +603,23 @@
   bool Invalid = false;
   // Since `Loc` may point into an expansion buffer, which has no corresponding
   // source, we need to look at the spelling location to read the actual 
source.
-  StringRef TokenText = clang::Lexer::getSpelling(
-  SM.getSpellingLoc(Loc), Buffer, SM, LangOpts, &Invalid);
+  StringRef TokenText = Lexer::getSpelling(SM.getSpellingLoc(Loc), Buffer, SM,
+   LangOpts, &Invalid);
   return !Invalid && Text == TokenText;
 }
 
 llvm::Optional
 getExpansionLocOfMacro(StringRef MacroName, SourceLocation Loc,
const ASTContext &Context) {
-  auto& SM = Context.getSourceManager();
-  const auto& LangOpts = Context.getLangOpts();
+  auto &SM = Context.getSourceManager();
+  const LangOptions &LangOpts = Context.getLangOpts();
   while (Loc.isMacroID()) {
-auto Expansion = SM.getSLocEntry(SM.getFileID(Loc)).getExpansion();
+SrcMgr::ExpansionInfo Expansion =
+SM.getSLocEntry(SM.getFileID(Loc)).getExpansion();
 if (Expansion.isMacroArgExpansion())
   // Check macro argument for an expansion of the given macro. For example,
   // `F(G(3))`, where `MacroName` is `G`.
-  if (auto ArgLoc = getExpansionLocOfMacro(
+  if (llvm::Optional ArgLoc = getExpansionLocOfMacro(
   MacroName, Expansion.getSpellingLoc(), Context))
 return ArgLoc;
 Loc = Expansion.getExpansionLocStart();
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -311,10 +311,10 @@
   // Verifies that the statement' beginning and ending are both expanded from
   // the same instance of the given macro.
   auto& Context = Finder->getASTContext();
-  auto B =
+  llvm::Optional B =
   internal::getExpansionLocOfMacro(MacroName, Node.getBeginLoc(), Context);
   if (!B) return false;
-  auto E =
+  llvm::Optional E =
   internal::getExpansionLocOfMacro(MacroName, Node.getEndLoc(), Context);
   if (!E) return false;
   return *B == *E;


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -99,6 +99,15 @@
   EXPECT_TRUE(matches(input, binaryOperator(isExpandedFromMacro("PLUS";
 }
 
+TEST(IsExpandedFromMacro, ShouldMatchFromCommandLine) {
+  std::string input = R"cc(
+void Test() { FOUR_PLUS_FOUR; }
+  )cc";
+  EXPECT_TRUE(matchesConditionally(input,
+   binaryOperator(isExpandedFromMacro("FOUR_PLUS_FOUR")),
+   true, {"-std=c++11", "-DFOUR_PLUS_FOUR=4+4"}));
+}
+
 TEST(IsExpandedFromMacro, ShouldNotMatchBeginOnly) {
   std::string input = R"cc(
 #define ONE_PLUS 1+
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -603,22 +603,23 @@
   bool Invalid = false;
   // Since `Loc` may point into an expansion buffer, which has no corresponding
   // source, we need to look at the spelling location to read the actual source.
-  StringRef TokenText = clang::Lexer::getSpelling(
-

[PATCH] D72222: [Driver][CodeGen] Add -fpatchable-function-entry=N[,0]

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

In D7#1856587 , @hans wrote:

> In D7#1849326 , @hans wrote:
>
> > > I created D73680  to place the patch 
> > > label after BTI.
> > > 
> > > @hans Is there still time to cherry pick the patch to release/10.x? See 
> > > above, Linux developers really want the Clang release to have compatible 
> > > behavior with GCC.
> >
> > Yes, there is still time. Just let me know which commits to cherry-pick.
>
>
> Just to follow up: D73680  was cherry-picked 
> to 10.x. Does that mean all issues are resolved here, and the kernel folks 
> are happy, or is there more work expected that might affect the release?


@hans Thanks for following up!

All known AArch64 -fpatchable-function-entry= issues are resolved after D73680 
.
D73760  is an x86 counterpart of D73680 
. It changed the placement of the label 
`.Lpatch0`, which has been agreed to be superior.

hjl is working on the GCC side issue 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93492. I don't know whether that 
fix will be included in GCC 10.
From the discussions, what we did in D73760  
is a consensus and GCC will eventually do it as well. D73760 
 will be nice to be cherry picked if there is 
not much trouble, so we won't have a major release with unsatisfactory label 
placement if Linux x86 developers ever want to adopt 
-fpatchable-function-entry=.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D7



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


[PATCH] D73966: [analyzer][WIP] Add 10.0.0 release notes.

2020-02-04 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:411-413
 - The Clang analyzer checker ``DeadStores`` gets a new option called
   ``WarnForDeadNestedAssignments`` to detect nested dead assignments
   (enabled by default).

Let's make this more concise: "Dead stores checker now warns about nested dead 
stores.". While it was originally unclear whether this should be on by default, 
i think there's relatively little motivation in disabling this option now that 
everybody liked it :)



Comment at: clang/docs/ReleaseNotes.rst:427
+
+- ObjectiveC++ changes:
+

NoQ wrote:
> Szelethus wrote:
> > I tried my best here but didn't get far. :)
> Not much here, mostly bugfixes.
Oh, wait, there was this D71728 thing.

> New checker: `security.insecureAPI.decodeValueOfObjCType` warns about 
> potential buffer overflows when using `[NSCoder decodeValueOfObjCType:at:]`.

(probably no need for a separate section for Objective-C)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73966



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


[PATCH] D73942: [hip] Properly populate macros based on host processor.

2020-02-04 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

On one hand the change makes sense to me and fits well with what we've done so 
far.
On the other hand, I worry that this is likely to break things.
We sort of have been implicitly relying on not having the macros related to 
advanced CPU features enabled on device side which typically results in 
device-side compilation seeing a more portable/simpler version of the code.
Defining the macros that enable more host-side CPU-specific code may trigger 
interesting compatibility features. Postponed diagnostics combined with `ignore 
(some) errors in the wrong-side-only code` should probably deal with most of 
them, but I suspect we'll see new interesting failure cases. We would not know 
until we try.

I would be more comfortable if we could have an option to disable this 
functionality with a command line option, at least temporarily. If things 
break, the option will avoid turning it into an emergency. If my concern turns 
out to be false, we can remove the option later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73942



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


[PATCH] D73979: [HIP] Allow non-incomplete array type for extern shared var

2020-02-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.

https://reviews.llvm.org/D73979

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGenCUDA/extern-shared.cu
  clang/test/SemaCUDA/extern-shared.cu


Index: clang/test/SemaCUDA/extern-shared.cu
===
--- clang/test/SemaCUDA/extern-shared.cu
+++ clang/test/SemaCUDA/extern-shared.cu
@@ -1,11 +1,16 @@
 // RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -verify %s
 // RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -fcuda-is-device -verify 
%s
 
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -verify=hip -x hip %s
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -fcuda-is-device \
+// RUN:   -verify=hip -x hip %s
+
 // RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -fgpu-rdc -verify=rdc %s
 // RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -fcuda-is-device 
-fgpu-rdc -verify=rdc %s
 
 // Most of these declarations are fine in separate compilation mode.
 
+// hip-no-diagnostics
 #include "Inputs/cuda.h"
 
 __device__ void foo() {
Index: clang/test/CodeGenCUDA/extern-shared.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/extern-shared.cu
@@ -0,0 +1,35 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm -o - -fcuda-is-device \
+// RUN:   -target-cpu gfx906 -x hip %s | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: @global = external addrspace(3) global i32, align 4
+// CHECK: @global_arr = external addrspace(3) global [0 x i32], align 4
+// CHECK: @global_arr1 = external addrspace(3) global [1 x i32], align 4
+// CHECK: @global_ptr = external addrspace(3) global i32*, align 8
+// CHECK: @x = external addrspace(3) global i32, align 4
+// CHECK: @arr = external addrspace(3) global [0 x i32], align 4
+// CHECK: @arr1 = external addrspace(3) global [1 x i32], align 4
+// CHECK: @ptr = external addrspace(3) global i32*, align 8
+
+extern __shared__ int global;
+extern __shared__ int global_arr[];
+extern __shared__ int global_arr1[1];
+extern __shared__ int* global_ptr;
+
+__global__ void foo() {
+  extern __shared__ int x;
+  extern __shared__ int arr[];
+  extern __shared__ int arr1[1];
+  extern __shared__ int* ptr;
+  global = 1;
+  global_arr[0] = 1;
+  global_arr1[0] = 1;
+  *global_ptr = 1;
+  x = 1;
+  arr[0] = 1;
+  arr1[0] = 1;
+  *ptr = 1;
+}
+
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4297,7 +4297,7 @@
   // extern __shared__ is only allowed on arrays with no length (e.g.
   // "int x[]").
   if (!S.getLangOpts().GPURelocatableDeviceCode && VD->hasExternalStorage() &&
-  !isa(VD->getType())) {
+  !isa(VD->getType()) && !S.getLangOpts().HIP) {
 S.Diag(AL.getLoc(), diag::err_cuda_extern_shared) << VD;
 return;
   }


Index: clang/test/SemaCUDA/extern-shared.cu
===
--- clang/test/SemaCUDA/extern-shared.cu
+++ clang/test/SemaCUDA/extern-shared.cu
@@ -1,11 +1,16 @@
 // RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -verify %s
 // RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -fcuda-is-device -verify %s
 
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -verify=hip -x hip %s
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -fcuda-is-device \
+// RUN:   -verify=hip -x hip %s
+
 // RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -fgpu-rdc -verify=rdc %s
 // RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -fcuda-is-device -fgpu-rdc -verify=rdc %s
 
 // Most of these declarations are fine in separate compilation mode.
 
+// hip-no-diagnostics
 #include "Inputs/cuda.h"
 
 __device__ void foo() {
Index: clang/test/CodeGenCUDA/extern-shared.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/extern-shared.cu
@@ -0,0 +1,35 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm -o - -fcuda-is-device \
+// RUN:   -target-cpu gfx906 -x hip %s | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: @global = external addrspace(3) global i32, align 4
+// CHECK: @global_arr = external addrspace(3) global [0 x i32], align 4
+// CHECK: @global_arr1 = external addrspace(3) global [1 x i32], align 4
+// CHECK: @global_ptr = external addrspace(3) global i32*, align 8
+// CHECK: @x = external addrspace(3) global i32, align 4
+// CHECK: @arr = external addrspace(3) global [0 x i32], align 4
+// CHECK: @arr1 = external addrspace(3) global [1 x i32], align 4
+// CHECK: @ptr = external addrspace(3) global i32*, align 8
+
+extern __shared__ int global;
+extern __shared__ int global_arr[];
+extern __shared__ int global_arr1[1];
+extern __shared__ int* global_ptr;
+
+__global__ void foo() {
+  extern __shared__ int x;
+  ex

  1   2   >