[PATCH] D60107: [analyzer] NoStoreFuncVisitor: Suppress bug reports with no-store in system headers.

2019-04-04 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 193828.
NoQ marked 6 inline comments as done.
NoQ added a comment.

Address comments. Thanks!


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

https://reviews.llvm.org/D60107

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/Inputs/no-store-suppression.h
  clang/test/Analysis/no-store-suppression.cpp

Index: clang/test/Analysis/no-store-suppression.cpp
===
--- /dev/null
+++ clang/test/Analysis/no-store-suppression.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+
+#include "Inputs/no-store-suppression.h"
+
+using namespace std;
+
+namespace value_uninitialized_after_stream_shift {
+void use(char c);
+
+// Technically, it is absolutely necessary to check the status of cin after
+// read before using the value that just read from it. Practically, we don't
+// really care unless we eventually come up with a special security check
+// for just that purpose. Static Analyzer shouldn't be yelling at every person's
+// third program in their C++ 101.
+void foo() {
+  char c;
+  std::cin >> c;
+  use(c); // no-warning
+}
+} // namespace value_uninitialized_after_stream_shift
Index: clang/test/Analysis/Inputs/no-store-suppression.h
===
--- /dev/null
+++ clang/test/Analysis/Inputs/no-store-suppression.h
@@ -0,0 +1,17 @@
+#pragma clang system_header
+
+namespace std {
+class istream {
+public:
+  bool is_eof();
+  char get_char();
+};
+
+istream >>(istream , char ) {
+  if (is.is_eof())
+return;
+  c = is.get_char();
+}
+
+extern istream cin;
+};
Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -306,9 +306,14 @@
 ID.AddPointer(RegionOfInterest);
   }
 
+  void *getTag() const {
+static int Tag = 0;
+return static_cast();
+  }
+
   std::shared_ptr VisitNode(const ExplodedNode *N,
  BugReporterContext ,
- BugReport &) override {
+ BugReport ) override {
 
 const LocationContext *Ctx = N->getLocationContext();
 const StackFrameContext *SCtx = Ctx->getStackFrame();
@@ -322,9 +327,6 @@
 CallEventRef<> Call =
 BR.getStateManager().getCallEventManager().getCaller(SCtx, State);
 
-if (Call->isInSystemHeader())
-  return nullptr;
-
 // Region of interest corresponds to an IVar, exiting a method
 // which could have written into that IVar, but did not.
 if (const auto *MC = dyn_cast(Call)) {
@@ -333,8 +335,8 @@
 if (RegionOfInterest->isSubRegionOf(SelfRegion) &&
 potentiallyWritesIntoIvar(Call->getRuntimeDefinition().getDecl(),
   IvarR->getDecl()))
-  return notModifiedDiagnostics(N, {}, SelfRegion, "self",
-/*FirstIsReferenceType=*/false, 1);
+  return maybeEmitNode(R, *Call, N, {}, SelfRegion, "self",
+   /*FirstIsReferenceType=*/false, 1);
   }
 }
 
@@ -342,8 +344,8 @@
   const MemRegion *ThisR = CCall->getCXXThisVal().getAsRegion();
   if (RegionOfInterest->isSubRegionOf(ThisR)
   && !CCall->getDecl()->isImplicit())
-return notModifiedDiagnostics(N, {}, ThisR, "this",
-  /*FirstIsReferenceType=*/false, 1);
+return maybeEmitNode(R, *Call, N, {}, ThisR, "this",
+ /*FirstIsReferenceType=*/false, 1);
 
   // Do not generate diagnostics for not modified parameters in
   // constructors.
@@ -353,27 +355,26 @@
 ArrayRef parameters = getCallParameters(Call);
 for (unsigned I = 0; I < Call->getNumArgs() && I < parameters.size(); ++I) {
   const ParmVarDecl *PVD = parameters[I];
-  SVal S = Call->getArgSVal(I);
+  SVal V = Call->getArgSVal(I);
   bool ParamIsReferenceType = PVD->getType()->isReferenceType();
   std::string ParamName = PVD->getNameAsString();
 
   int IndirectionLevel = 1;
   QualType T = PVD->getType();
-  while (const MemRegion *R = S.getAsRegion()) {
-if (RegionOfInterest->isSubRegionOf(R) && !isPointerToConst(T))
-  return notModifiedDiagnostics(N, {}, R, ParamName,
-ParamIsReferenceType, IndirectionLevel);
+  while (const MemRegion *MR = V.getAsRegion()) {
+if (RegionOfInterest->isSubRegionOf(MR) && !isPointerToConst(T))
+  return maybeEmitNode(R, *Call, N, {}, MR, ParamName,
+   ParamIsReferenceType, IndirectionLevel);
 
 QualType PT = 

[PATCH] D60107: [analyzer] NoStoreFuncVisitor: Suppress bug reports with no-store in system headers.

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



Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:364
   QualType T = PVD->getType();
-  while (const MemRegion *R = S.getAsRegion()) {
-if (RegionOfInterest->isSubRegionOf(R) && !isPointerToConst(T))
-  return notModifiedDiagnostics(N, {}, R, ParamName,
-ParamIsReferenceType, 
IndirectionLevel);
+  while (const MemRegion *MR = S.getAsRegion()) {
+if (RegionOfInterest->isSubRegionOf(MR) && !isPointerToConst(T))

Charusso wrote:
> `R` was cool, that is our unspoken naming convention. What about 
> `CallR`/`CallRegion` and possibly `CallSVal`? If I am right usually the 
> `BugReport` object is named `BR` because of our regions.
My unspoken (well, not anymore, i guess) naming convention usually goes like 
this:
* `B` for `BinaryOperator` (emphasis on binary-ness, `U` for unary so they 
don't conflict)
* `R` for `BugReport` (emphasis on being a report)
* `BR` for `BugReporter` (for the lack of better name),
* `MR` for `MemRegion` (specific classes of regions go like `VR`, `FR`, `TR`, 
`SR`, or, well, `BR`)
* `BRC` for `BugReporterContext` (emphasis on being a context)

Also `V` for `SVal` (emphasis on value) because `S` for `Stmt`.



Comment at: clang/test/Analysis/no-store-suppression.cpp:3
+
+// expected-no-diagnostics
+

Charusso wrote:
> Could you inject a link for the diff or copy the information for further 
> improvements why no diagnostic happen?
Links to diffs are rarely included in the source code because they're usually 
two clicks away anyway: just do git blame and see the bottom of the commit 
message.


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

https://reviews.llvm.org/D60107



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


[PATCH] D60302: [CodeGen][ObjC] Emit the retainRV marker as a module flag instead of named metadata.

2019-04-04 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

Corresponding llvm patch is here: https://reviews.llvm.org/D60303.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60302



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


[PATCH] D60302: [CodeGen][ObjC] Emit the retainRV marker as a module flag instead of named metadata.

2019-04-04 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: steven_wu, dexonsmith, rjmccall.
ahatanak added a project: clang.
Herald added subscribers: jkorous, kristof.beyls, javed.absar, mehdi_amini.

This fixes a bug which causes the ARC contract pass to not insert the assembly 
marker that is needed for the runtime to do the `objc_autoreleaseReturnValue/ 
objc_retainAutoreleasedReturnValue` optimization when compiling on ARM64/ARM 
with LTO enabled. This happens because `IRLinker::linkNamedMDNodes()` adds all 
the operands from the source modules to the metadata's operand list in the 
merged module (see the example below) and ARC contract fails to extract the 
marker string if the metadata has more than one operand.

  clang.arc.retainAutoreleasedReturnValueMarker = !{!0, !0}
  !0 = !{!"mov\09fp, fp\09\09# marker for objc_retainAutoreleaseReturnValue"}

To fix the bug, this patch emits the marker as a module flag.

rdar://problem/49464214


Repository:
  rC Clang

https://reviews.llvm.org/D60302

Files:
  lib/CodeGen/CGObjC.cpp
  test/CodeGenObjC/arc-unsafeclaim.m


Index: test/CodeGenObjC/arc-unsafeclaim.m
===
--- test/CodeGenObjC/arc-unsafeclaim.m
+++ test/CodeGenObjC/arc-unsafeclaim.m
@@ -231,4 +231,5 @@
 
 // This is always at the end of the module.
 
-// CHECK-OPTIMIZED: !clang.arc.retainAutoreleasedReturnValueMarker = !{!0}
+// CHECK-OPTIMIZED: !llvm.module.flags = !{!0,
+// CHECK-OPTIMIZED: !0 = !{i32 1, 
!"clang.arc.retainAutoreleasedReturnValueMarker", !"mov{{.*}}marker for 
objc_retainAutoreleaseReturnValue"}
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2161,14 +2161,10 @@
 // with this marker yet, so leave a breadcrumb for the ARC
 // optimizer to pick up.
 } else {
-  llvm::NamedMDNode *metadata =
-CGF.CGM.getModule().getOrInsertNamedMetadata(
-"clang.arc.retainAutoreleasedReturnValueMarker");
-  assert(metadata->getNumOperands() <= 1);
-  if (metadata->getNumOperands() == 0) {
-auto  = CGF.getLLVMContext();
-metadata->addOperand(llvm::MDNode::get(ctx,
- llvm::MDString::get(ctx, assembly)));
+  const char *markerKey = "clang.arc.retainAutoreleasedReturnValueMarker";
+  if (!CGF.CGM.getModule().getModuleFlag(markerKey)) {
+auto *str = llvm::MDString::get(CGF.getLLVMContext(), assembly);
+CGF.CGM.getModule().addModuleFlag(llvm::Module::Error, markerKey, str);
   }
 }
   }


Index: test/CodeGenObjC/arc-unsafeclaim.m
===
--- test/CodeGenObjC/arc-unsafeclaim.m
+++ test/CodeGenObjC/arc-unsafeclaim.m
@@ -231,4 +231,5 @@
 
 // This is always at the end of the module.
 
-// CHECK-OPTIMIZED: !clang.arc.retainAutoreleasedReturnValueMarker = !{!0}
+// CHECK-OPTIMIZED: !llvm.module.flags = !{!0,
+// CHECK-OPTIMIZED: !0 = !{i32 1, !"clang.arc.retainAutoreleasedReturnValueMarker", !"mov{{.*}}marker for objc_retainAutoreleaseReturnValue"}
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2161,14 +2161,10 @@
 // with this marker yet, so leave a breadcrumb for the ARC
 // optimizer to pick up.
 } else {
-  llvm::NamedMDNode *metadata =
-CGF.CGM.getModule().getOrInsertNamedMetadata(
-"clang.arc.retainAutoreleasedReturnValueMarker");
-  assert(metadata->getNumOperands() <= 1);
-  if (metadata->getNumOperands() == 0) {
-auto  = CGF.getLLVMContext();
-metadata->addOperand(llvm::MDNode::get(ctx,
- llvm::MDString::get(ctx, assembly)));
+  const char *markerKey = "clang.arc.retainAutoreleasedReturnValueMarker";
+  if (!CGF.CGM.getModule().getModuleFlag(markerKey)) {
+auto *str = llvm::MDString::get(CGF.getLLVMContext(), assembly);
+CGF.CGM.getModule().addModuleFlag(llvm::Module::Error, markerKey, str);
   }
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r357713 - Verify that Android targets generate DWARF 4 by default.

2019-04-04 Thread Alex L via cfe-commits
Thanks! I committed the fix in r357740. The test should start passing now.

Cheers,
Alex

On Thu, 4 Apr 2019 at 18:32, Stephen Hines  wrote:

> Ah I just saw this. Please feel free to CC me on the fix CL and I will
> approve it. I didn't realize that the exact specification was missing
> for that.
>
> Thanks,
> Steve
>
> On Thu, Apr 4, 2019 at 6:31 PM Alex L  wrote:
> >
> > Thanks, for the explanation, it makes sense. It looks like an explicit
> `darwin14` in one of the non-versioned darwin triples fixes the issue. I
> will commit the fix right away.
> >
> > Cheers,
> > Alex
> >
> >
> > On Thu, 4 Apr 2019 at 18:24, Adrian Prantl  wrote:
> >>
> >> IIRC, the dwarf version on Darwin depends on the deployment target and
> is 2 for earlier versions of macOS and and 4 for newer ones (I need to dig
> through the driver code to determine the exact version).
> >>
> >> I can take a look at this tomorrow morning.
> >>
> >> -- adrian
> >>
> >> On Apr 4, 2019, at 6:21 PM, Alex L  wrote:
> >>
> >> Hi Stephen,
> >>
> >> It looks like your change has caused the 'debug-options.c' test to
> start failing on Darwin. It looks like we emit "-dwarf-version=4" by
> default, and not 2. Could you please take a look.
> >>
> >> Here's a link to a latest build on the public LLVM CI that contains the
> failure:
> >>
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental/59772/console
> >>
> >> Here's the failure itself:
> >> Command Output (stderr): --
> /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/tools/clang/test/Driver/debug-options.c:280:14:
> error: G_DWARF2: expected string not found in input // G_DWARF2:
> "-dwarf-version=2" ^ :5:515: note: scanning from here
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/bin/clang-9"
> "-cc1" "-triple" "x86_64-apple-macosx10.13.0" "-Wdeprecated-objc-isa-usage"
> "-Werror=deprecated-objc-isa-usage" "-emit-obj" "-mrelax-all"
> "-disable-free" "-main-file-name" "debug-options.c" "-mrelocation-model"
> "pic" "-pic-level" "2" "-mthread-model" "posix" "-mdisable-fp-elim"
> "-masm-verbose" "-munwind-tables" "-faligned-alloc-unavailable"
> "-target-cpu" "penryn" "-dwarf-column-info" "-debug-info-kind=standalone"
> "-dwarf-version=4" "-debugger-tuning=lldb" "-ggnu-pubnames"
> "-target-linker-version" "351.8" "-coverage-notes-file"
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver/debug-options.gcno"
> "-resource-dir"
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/lib/clang/9.0.0"
> "-fdebug-compilation-dir"
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver"
> "-ferror-limit" "19" "-fmessage-length" "0" "-stack-protector" "1"
> "-fblocks" "-fencode-extended-block-signature"
> "-fregister-global-dtors-with-atexit" "-fobjc-runtime=macosx-10.13.0"
> "-fmax-type-align=16" "-fdiagnostics-show-option" "-o" "debug-options.o"
> "-x" "c"
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/tools/clang/test/Driver/debug-options.c"
> ^
> >>
> >>
> >> Adrian, I've looped you in since you reviewed the commit it looks like.
> Do you know if that's expected behavior on Darwin?
> >>
> >> Cheers,
> >> Alex
> >>
> >> On Thu, 4 Apr 2019 at 11:16, Stephen Hines via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>>
> >>> Author: srhines
> >>> Date: Thu Apr  4 11:17:46 2019
> >>> New Revision: 357713
> >>>
> >>> URL: http://llvm.org/viewvc/llvm-project?rev=357713=rev
> >>> Log:
> >>> Verify that Android targets generate DWARF 4 by default.
> >>>
> >>> Summary:
> >>> In the future, Android releases will support DWARF 5, but we need to
> >>> ensure that older targets only have DWARF 4 generated for them. This
> >>> patch inserts that verification for all Android releases now. The patch
> >>> also fixes 2 minor mistakes (a mistakenly moved RUN line, and the
> >>> missing G_DWARF2 check label).
> >>>
> >>> Reviewers: aprantl
> >>>
> >>> Reviewed By: aprantl
> >>>
> >>> Subscribers: chh, pirama, cfe-commits
> >>>
> >>> Tags: #clang
> >>>
> >>> Differential Revision: https://reviews.llvm.org/D60238
> >>>
> >>> Modified:
> >>> cfe/trunk/test/Driver/debug-options.c
> >>>
> >>> Modified: cfe/trunk/test/Driver/debug-options.c
> >>> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=357713=357712=357713=diff
> >>>
> ==
> >>> --- cfe/trunk/test/Driver/debug-options.c (original)
> >>> +++ cfe/trunk/test/Driver/debug-options.c Thu Apr  4 11:17:46 2019
> >>> @@ -17,9 +17,14 @@
> >>>  // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
> >>>  // RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB
> %s
> >>>  // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
> >>> +// RUN: | FileCheck -check-prefix=G 

r357740 - [test] Specify an explicit darwin version in a triple in

2019-04-04 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Apr  4 18:48:11 2019
New Revision: 357740

URL: http://llvm.org/viewvc/llvm-project?rev=357740=rev
Log:
[test] Specify an explicit darwin version in a triple in
`test/Driver/debug-options.c` to ensure that the driver
selects the DWARF 2 version as intended by the test.

Fixes the `test/Driver/debug-options.c` test regression on GreenDragon
on macOS that started failing after r357713.

Modified:
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=357740=357739=357740=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Thu Apr  4 18:48:11 2019
@@ -25,7 +25,7 @@
 // RUN: | FileCheck -check-prefix=G -check-prefix=G_DWARF4 %s
 
 // Darwin.
-// RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -c -g %s -target x86_64-apple-darwin14 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF2 \
 // RUN: -check-prefix=G_LLDB %s


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


[PATCH] D60301: [CodeGen][ObjC] Emit the retainRV marker as a module flag instead of named metadata.

2019-04-04 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak abandoned this revision.
ahatanak added a comment.

I'll write the summary and send the patch again.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60301



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


[PATCH] D60301: [CodeGen][ObjC] Emit the retainRV marker as a module flag instead of named metadata.

2019-04-04 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: steven_wu, dexonsmith, rjmccall.
ahatanak added a project: clang.
Herald added a subscriber: jkorous.

Repository:
  rC Clang

https://reviews.llvm.org/D60301

Files:
  lib/CodeGen/CGObjC.cpp
  test/CodeGenObjC/arc-unsafeclaim.m


Index: test/CodeGenObjC/arc-unsafeclaim.m
===
--- test/CodeGenObjC/arc-unsafeclaim.m
+++ test/CodeGenObjC/arc-unsafeclaim.m
@@ -231,4 +231,5 @@
 
 // This is always at the end of the module.
 
-// CHECK-OPTIMIZED: !clang.arc.retainAutoreleasedReturnValueMarker = !{!0}
+// CHECK-OPTIMIZED: !llvm.module.flags = !{!0,
+// CHECK-OPTIMIZED: !0 = !{i32 1, 
!"clang.arc.retainAutoreleasedReturnValueMarker", !"mov{{.*}}marker for 
objc_retainAutoreleaseReturnValue"}
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2161,14 +2161,10 @@
 // with this marker yet, so leave a breadcrumb for the ARC
 // optimizer to pick up.
 } else {
-  llvm::NamedMDNode *metadata =
-CGF.CGM.getModule().getOrInsertNamedMetadata(
-"clang.arc.retainAutoreleasedReturnValueMarker");
-  assert(metadata->getNumOperands() <= 1);
-  if (metadata->getNumOperands() == 0) {
-auto  = CGF.getLLVMContext();
-metadata->addOperand(llvm::MDNode::get(ctx,
- llvm::MDString::get(ctx, assembly)));
+  const char *markerKey = "clang.arc.retainAutoreleasedReturnValueMarker";
+  if (!CGF.CGM.getModule().getModuleFlag(markerKey)) {
+auto *str = llvm::MDString::get(CGF.getLLVMContext(), assembly);
+CGF.CGM.getModule().addModuleFlag(llvm::Module::Error, markerKey, str);
   }
 }
   }


Index: test/CodeGenObjC/arc-unsafeclaim.m
===
--- test/CodeGenObjC/arc-unsafeclaim.m
+++ test/CodeGenObjC/arc-unsafeclaim.m
@@ -231,4 +231,5 @@
 
 // This is always at the end of the module.
 
-// CHECK-OPTIMIZED: !clang.arc.retainAutoreleasedReturnValueMarker = !{!0}
+// CHECK-OPTIMIZED: !llvm.module.flags = !{!0,
+// CHECK-OPTIMIZED: !0 = !{i32 1, !"clang.arc.retainAutoreleasedReturnValueMarker", !"mov{{.*}}marker for objc_retainAutoreleaseReturnValue"}
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2161,14 +2161,10 @@
 // with this marker yet, so leave a breadcrumb for the ARC
 // optimizer to pick up.
 } else {
-  llvm::NamedMDNode *metadata =
-CGF.CGM.getModule().getOrInsertNamedMetadata(
-"clang.arc.retainAutoreleasedReturnValueMarker");
-  assert(metadata->getNumOperands() <= 1);
-  if (metadata->getNumOperands() == 0) {
-auto  = CGF.getLLVMContext();
-metadata->addOperand(llvm::MDNode::get(ctx,
- llvm::MDString::get(ctx, assembly)));
+  const char *markerKey = "clang.arc.retainAutoreleasedReturnValueMarker";
+  if (!CGF.CGM.getModule().getModuleFlag(markerKey)) {
+auto *str = llvm::MDString::get(CGF.getLLVMContext(), assembly);
+CGF.CGM.getModule().addModuleFlag(llvm::Module::Error, markerKey, str);
   }
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r357713 - Verify that Android targets generate DWARF 4 by default.

2019-04-04 Thread Stephen Hines via cfe-commits
Ah I just saw this. Please feel free to CC me on the fix CL and I will
approve it. I didn't realize that the exact specification was missing
for that.

Thanks,
Steve

On Thu, Apr 4, 2019 at 6:31 PM Alex L  wrote:
>
> Thanks, for the explanation, it makes sense. It looks like an explicit 
> `darwin14` in one of the non-versioned darwin triples fixes the issue. I will 
> commit the fix right away.
>
> Cheers,
> Alex
>
>
> On Thu, 4 Apr 2019 at 18:24, Adrian Prantl  wrote:
>>
>> IIRC, the dwarf version on Darwin depends on the deployment target and is 2 
>> for earlier versions of macOS and and 4 for newer ones (I need to dig 
>> through the driver code to determine the exact version).
>>
>> I can take a look at this tomorrow morning.
>>
>> -- adrian
>>
>> On Apr 4, 2019, at 6:21 PM, Alex L  wrote:
>>
>> Hi Stephen,
>>
>> It looks like your change has caused the 'debug-options.c' test to start 
>> failing on Darwin. It looks like we emit "-dwarf-version=4" by default, and 
>> not 2. Could you please take a look.
>>
>> Here's a link to a latest build on the public LLVM CI that contains the 
>> failure:
>> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental/59772/console
>>
>> Here's the failure itself:
>> Command Output (stderr): -- 
>> /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/tools/clang/test/Driver/debug-options.c:280:14:
>>  error: G_DWARF2: expected string not found in input // G_DWARF2: 
>> "-dwarf-version=2" ^ :5:515: note: scanning from here 
>> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/bin/clang-9"
>>  "-cc1" "-triple" "x86_64-apple-macosx10.13.0" "-Wdeprecated-objc-isa-usage" 
>> "-Werror=deprecated-objc-isa-usage" "-emit-obj" "-mrelax-all" 
>> "-disable-free" "-main-file-name" "debug-options.c" "-mrelocation-model" 
>> "pic" "-pic-level" "2" "-mthread-model" "posix" "-mdisable-fp-elim" 
>> "-masm-verbose" "-munwind-tables" "-faligned-alloc-unavailable" 
>> "-target-cpu" "penryn" "-dwarf-column-info" "-debug-info-kind=standalone" 
>> "-dwarf-version=4" "-debugger-tuning=lldb" "-ggnu-pubnames" 
>> "-target-linker-version" "351.8" "-coverage-notes-file" 
>> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver/debug-options.gcno"
>>  "-resource-dir" 
>> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/lib/clang/9.0.0"
>>  "-fdebug-compilation-dir" 
>> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver"
>>  "-ferror-limit" "19" "-fmessage-length" "0" "-stack-protector" "1" 
>> "-fblocks" "-fencode-extended-block-signature" 
>> "-fregister-global-dtors-with-atexit" "-fobjc-runtime=macosx-10.13.0" 
>> "-fmax-type-align=16" "-fdiagnostics-show-option" "-o" "debug-options.o" 
>> "-x" "c" 
>> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/tools/clang/test/Driver/debug-options.c"
>>  ^
>>
>>
>> Adrian, I've looped you in since you reviewed the commit it looks like. Do 
>> you know if that's expected behavior on Darwin?
>>
>> Cheers,
>> Alex
>>
>> On Thu, 4 Apr 2019 at 11:16, Stephen Hines via cfe-commits 
>>  wrote:
>>>
>>> Author: srhines
>>> Date: Thu Apr  4 11:17:46 2019
>>> New Revision: 357713
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=357713=rev
>>> Log:
>>> Verify that Android targets generate DWARF 4 by default.
>>>
>>> Summary:
>>> In the future, Android releases will support DWARF 5, but we need to
>>> ensure that older targets only have DWARF 4 generated for them. This
>>> patch inserts that verification for all Android releases now. The patch
>>> also fixes 2 minor mistakes (a mistakenly moved RUN line, and the
>>> missing G_DWARF2 check label).
>>>
>>> Reviewers: aprantl
>>>
>>> Reviewed By: aprantl
>>>
>>> Subscribers: chh, pirama, cfe-commits
>>>
>>> Tags: #clang
>>>
>>> Differential Revision: https://reviews.llvm.org/D60238
>>>
>>> Modified:
>>> cfe/trunk/test/Driver/debug-options.c
>>>
>>> Modified: cfe/trunk/test/Driver/debug-options.c
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=357713=357712=357713=diff
>>> ==
>>> --- cfe/trunk/test/Driver/debug-options.c (original)
>>> +++ cfe/trunk/test/Driver/debug-options.c Thu Apr  4 11:17:46 2019
>>> @@ -17,9 +17,14 @@
>>>  // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
>>>  // RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
>>>  // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
>>> +// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
>>> +
>>> +// Android.
>>> +// Android should always generate DWARF4.
>>> +// RUN: %clang -### -c -g %s -target arm-linux-androideabi 2>&1 \
>>> +// RUN: | FileCheck -check-prefix=G -check-prefix=G_DWARF4 %s
>>>
>>>  // Darwin.
>>> -// RUN: 

Re: r357713 - Verify that Android targets generate DWARF 4 by default.

2019-04-04 Thread Alex L via cfe-commits
Thanks, for the explanation, it makes sense. It looks like an explicit
`darwin14` in one of the non-versioned darwin triples fixes the issue. I
will commit the fix right away.

Cheers,
Alex


On Thu, 4 Apr 2019 at 18:24, Adrian Prantl  wrote:

> IIRC, the dwarf version on Darwin depends on the deployment target and is
> 2 for earlier versions of macOS and and 4 for newer ones (I need to dig
> through the driver code to determine the exact version).
>
> I can take a look at this tomorrow morning.
>
> -- adrian
>
> On Apr 4, 2019, at 6:21 PM, Alex L  wrote:
>
> Hi Stephen,
>
> It looks like your change has caused the 'debug-options.c' test to start
> failing on Darwin. It looks like we emit "-dwarf-version=4" by default, and
> not 2. Could you please take a look.
>
> Here's a link to a latest build on the public LLVM CI that contains the
> failure:
>
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental/59772/console
>
> Here's the failure itself:
> Command Output (stderr): -- 
> /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/tools/clang/test/Driver/debug-options.c:280:14:
> error: G_DWARF2: expected string not found in input // G_DWARF2:
> "-dwarf-version=2" ^ :5:515: note: scanning from here
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/bin/clang-9"
> "-cc1" "-triple" "x86_64-apple-macosx10.13.0" "-Wdeprecated-objc-isa-usage"
> "-Werror=deprecated-objc-isa-usage" "-emit-obj" "-mrelax-all"
> "-disable-free" "-main-file-name" "debug-options.c" "-mrelocation-model"
> "pic" "-pic-level" "2" "-mthread-model" "posix" "-mdisable-fp-elim"
> "-masm-verbose" "-munwind-tables" "-faligned-alloc-unavailable"
> "-target-cpu" "penryn" "-dwarf-column-info" "-debug-info-kind=standalone"
> "-dwarf-version=4" "-debugger-tuning=lldb" "-ggnu-pubnames"
> "-target-linker-version" "351.8" "-coverage-notes-file"
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver/debug-options.gcno"
> "-resource-dir"
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/lib/clang/9.0.0"
> "-fdebug-compilation-dir"
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver"
> "-ferror-limit" "19" "-fmessage-length" "0" "-stack-protector" "1"
> "-fblocks" "-fencode-extended-block-signature"
> "-fregister-global-dtors-with-atexit" "-fobjc-runtime=macosx-10.13.0"
> "-fmax-type-align=16" "-fdiagnostics-show-option" "-o" "debug-options.o"
> "-x" "c"
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/tools/clang/test/Driver/debug-options.c"
> ^
>
>
> Adrian, I've looped you in since you reviewed the commit it looks like. Do
> you know if that's expected behavior on Darwin?
>
> Cheers,
> Alex
>
> On Thu, 4 Apr 2019 at 11:16, Stephen Hines via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: srhines
>> Date: Thu Apr  4 11:17:46 2019
>> New Revision: 357713
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=357713=rev
>> Log:
>> Verify that Android targets generate DWARF 4 by default.
>>
>> Summary:
>> In the future, Android releases will support DWARF 5, but we need to
>> ensure that older targets only have DWARF 4 generated for them. This
>> patch inserts that verification for all Android releases now. The patch
>> also fixes 2 minor mistakes (a mistakenly moved RUN line, and the
>> missing G_DWARF2 check label).
>>
>> Reviewers: aprantl
>>
>> Reviewed By: aprantl
>>
>> Subscribers: chh, pirama, cfe-commits
>>
>> Tags: #clang
>>
>> Differential Revision: https://reviews.llvm.org/D60238
>>
>> Modified:
>> cfe/trunk/test/Driver/debug-options.c
>>
>> Modified: cfe/trunk/test/Driver/debug-options.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=357713=357712=357713=diff
>>
>> ==
>> --- cfe/trunk/test/Driver/debug-options.c (original)
>> +++ cfe/trunk/test/Driver/debug-options.c Thu Apr  4 11:17:46 2019
>> @@ -17,9 +17,14 @@
>>  // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
>>  // RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
>>  // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
>> +// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
>> +
>> +// Android.
>> +// Android should always generate DWARF4.
>> +// RUN: %clang -### -c -g %s -target arm-linux-androideabi 2>&1 \
>> +// RUN: | FileCheck -check-prefix=G -check-prefix=G_DWARF4 %s
>>
>>  // Darwin.
>> -// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
>>  // RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
>>  // RUN: | FileCheck -check-prefix=G_STANDALONE \
>>  // RUN: -check-prefix=G_DWARF2 \
>> @@ -272,6 +277,7 @@
>>  //
>>  // G_STANDALONE: "-cc1"
>>  // G_STANDALONE: 

Re: r357713 - Verify that Android targets generate DWARF 4 by default.

2019-04-04 Thread Adrian Prantl via cfe-commits
IIRC, the dwarf version on Darwin depends on the deployment target and is 2 for 
earlier versions of macOS and and 4 for newer ones (I need to dig through the 
driver code to determine the exact version).

I can take a look at this tomorrow morning.

-- adrian

> On Apr 4, 2019, at 6:21 PM, Alex L  wrote:
> 
> Hi Stephen,
> 
> It looks like your change has caused the 'debug-options.c' test to start 
> failing on Darwin. It looks like we emit "-dwarf-version=4" by default, and 
> not 2. Could you please take a look.
> 
> Here's a link to a latest build on the public LLVM CI that contains the 
> failure:
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental/59772/console
>  
> 
> 
> Here's the failure itself:
> Command Output (stderr):
> --
>  
> <>/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/tools/clang/test/Driver/debug-options.c:280:14:
>  error: G_DWARF2: expected string not found in input
> // G_DWARF2: "-dwarf-version=2"
>  ^
> :5:515: note: scanning from here
>  
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/bin/clang-9"
>  "-cc1" "-triple" "x86_64-apple-macosx10.13.0" "-Wdeprecated-objc-isa-usage" 
> "-Werror=deprecated-objc-isa-usage" "-emit-obj" "-mrelax-all" "-disable-free" 
> "-main-file-name" "debug-options.c" "-mrelocation-model" "pic" "-pic-level" 
> "2" "-mthread-model" "posix" "-mdisable-fp-elim" "-masm-verbose" 
> "-munwind-tables" "-faligned-alloc-unavailable" "-target-cpu" "penryn" 
> "-dwarf-column-info" "-debug-info-kind=standalone" "-dwarf-version=4" 
> "-debugger-tuning=lldb" "-ggnu-pubnames" "-target-linker-version" "351.8" 
> "-coverage-notes-file" 
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver/debug-options.gcno"
>  "-resource-dir" 
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/lib/clang/9.0.0"
>  "-fdebug-compilation-dir" 
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver"
>  "-ferror-limit" "19" "-fmessage-length" "0" "-stack-protector" "1" 
> "-fblocks" "-fencode-extended-block-signature" 
> "-fregister-global-dtors-with-atexit" "-fobjc-runtime=macosx-10.13.0" 
> "-fmax-type-align=16" "-fdiagnostics-show-option" "-o" "debug-options.o" "-x" 
> "c" 
> "/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/tools/clang/test/Driver/debug-options.c"
>   
>   
>   
>   
>   
>   
>   ^
> 
> 
> Adrian, I've looped you in since you reviewed the commit it looks like. Do 
> you know if that's expected behavior on Darwin?
> 
> Cheers,
> Alex
> 
> On Thu, 4 Apr 2019 at 11:16, Stephen Hines via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: srhines
> Date: Thu Apr  4 11:17:46 2019
> New Revision: 357713
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=357713=rev 
> 
> Log:
> Verify that Android targets generate DWARF 4 by default.
> 
> Summary:
> In the future, Android releases will support DWARF 5, but we need to
> ensure that older targets only have DWARF 4 generated for them. This
> patch inserts that verification for all Android releases now. The patch
> also fixes 2 minor mistakes (a mistakenly moved RUN line, and the
> missing G_DWARF2 check label).
> 
> Reviewers: aprantl
> 
> Reviewed By: aprantl
> 
> Subscribers: chh, pirama, cfe-commits
> 
> Tags: #clang
> 
> Differential Revision: https://reviews.llvm.org/D60238 
> 
> 
> Modified:
> cfe/trunk/test/Driver/debug-options.c
> 
> Modified: cfe/trunk/test/Driver/debug-options.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=357713=357712=357713=diff
>  
> 
> ==
> --- cfe/trunk/test/Driver/debug-options.c (original)
> +++ cfe/trunk/test/Driver/debug-options.c Thu Apr  4 11:17:46 2019
> @@ -17,9 +17,14 @@
>  // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
>  // RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
>  // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
> +// RUN: | FileCheck -check-prefix=G 

Re: r357713 - Verify that Android targets generate DWARF 4 by default.

2019-04-04 Thread Alex L via cfe-commits
Hi Stephen,

It looks like your change has caused the 'debug-options.c' test to start
failing on Darwin. It looks like we emit "-dwarf-version=4" by default, and
not 2. Could you please take a look.

Here's a link to a latest build on the public LLVM CI that contains the
failure:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental/59772/console

Here's the failure itself:
Command Output (stderr): --
/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/tools/clang/test/Driver/debug-options.c:280:14:
error: G_DWARF2: expected string not found in input // G_DWARF2:
"-dwarf-version=2" ^ :5:515: note: scanning from here
"/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/bin/clang-9"
"-cc1" "-triple" "x86_64-apple-macosx10.13.0" "-Wdeprecated-objc-isa-usage"
"-Werror=deprecated-objc-isa-usage" "-emit-obj" "-mrelax-all"
"-disable-free" "-main-file-name" "debug-options.c" "-mrelocation-model"
"pic" "-pic-level" "2" "-mthread-model" "posix" "-mdisable-fp-elim"
"-masm-verbose" "-munwind-tables" "-faligned-alloc-unavailable"
"-target-cpu" "penryn" "-dwarf-column-info" "-debug-info-kind=standalone"
"-dwarf-version=4" "-debugger-tuning=lldb" "-ggnu-pubnames"
"-target-linker-version" "351.8" "-coverage-notes-file"
"/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver/debug-options.gcno"
"-resource-dir"
"/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/lib/clang/9.0.0"
"-fdebug-compilation-dir"
"/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver"
"-ferror-limit" "19" "-fmessage-length" "0" "-stack-protector" "1"
"-fblocks" "-fencode-extended-block-signature"
"-fregister-global-dtors-with-atexit" "-fobjc-runtime=macosx-10.13.0"
"-fmax-type-align=16" "-fdiagnostics-show-option" "-o" "debug-options.o"
"-x" "c"
"/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/tools/clang/test/Driver/debug-options.c"
^


Adrian, I've looped you in since you reviewed the commit it looks like. Do
you know if that's expected behavior on Darwin?

Cheers,
Alex

On Thu, 4 Apr 2019 at 11:16, Stephen Hines via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: srhines
> Date: Thu Apr  4 11:17:46 2019
> New Revision: 357713
>
> URL: http://llvm.org/viewvc/llvm-project?rev=357713=rev
> Log:
> Verify that Android targets generate DWARF 4 by default.
>
> Summary:
> In the future, Android releases will support DWARF 5, but we need to
> ensure that older targets only have DWARF 4 generated for them. This
> patch inserts that verification for all Android releases now. The patch
> also fixes 2 minor mistakes (a mistakenly moved RUN line, and the
> missing G_DWARF2 check label).
>
> Reviewers: aprantl
>
> Reviewed By: aprantl
>
> Subscribers: chh, pirama, cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D60238
>
> Modified:
> cfe/trunk/test/Driver/debug-options.c
>
> Modified: cfe/trunk/test/Driver/debug-options.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=357713=357712=357713=diff
>
> ==
> --- cfe/trunk/test/Driver/debug-options.c (original)
> +++ cfe/trunk/test/Driver/debug-options.c Thu Apr  4 11:17:46 2019
> @@ -17,9 +17,14 @@
>  // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
>  // RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
>  // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
> +// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
> +
> +// Android.
> +// Android should always generate DWARF4.
> +// RUN: %clang -### -c -g %s -target arm-linux-androideabi 2>&1 \
> +// RUN: | FileCheck -check-prefix=G -check-prefix=G_DWARF4 %s
>
>  // Darwin.
> -// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
>  // RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
>  // RUN: | FileCheck -check-prefix=G_STANDALONE \
>  // RUN: -check-prefix=G_DWARF2 \
> @@ -272,6 +277,7 @@
>  //
>  // G_STANDALONE: "-cc1"
>  // G_STANDALONE: "-debug-info-kind=standalone"
> +// G_DWARF2: "-dwarf-version=2"
>  // G_DWARF4: "-dwarf-version=4"
>  //
>  // G_GDB:  "-debugger-tuning=gdb"
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59806: [clang-tidy] Add a check for [super self] in initializers 

2019-04-04 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore planned changes to this revision.
stephanemoore marked an inline comment as done.
stephanemoore added inline comments.



Comment at: clang-tools-extra/clang-tidy/objc/SuperSelfCheck.cpp:112
+  << Message->getMethodDecl()
+  << FixItHint::CreateReplacement(Message->getSourceRange(),
+  StringRef("[super init]"));

aaron.ballman wrote:
> stephanemoore wrote:
> > aaron.ballman wrote:
> > > stephanemoore wrote:
> > > > stephanemoore wrote:
> > > > > aaron.ballman wrote:
> > > > > > This could be dangerous if the `[super self]` construct is in a 
> > > > > > macro, couldn't it? e.g.,
> > > > > > ```
> > > > > > #define DERP self
> > > > > > 
> > > > > > [super DERP];
> > > > > > ```
> > > > > Good point. Let me add some test cases and make sure this is handled 
> > > > > properly.
> > > > Added some test cases where `[super self]` is expanded from macros.
> > > You missed the test case I was worried about -- where the macro is mixed 
> > > into the expression. I don't think we want to try to add a fix-it in that 
> > > case.
> > Added a test case though at the moment it generates a fixit.
> > 
> > Before I investigate modifying the check to avoid generating a fixit in 
> > this case, I think it would be helpful for me to understand your concerns 
> > in that scenario better. Is your concern that a proper fix might involve 
> > fixing the macro itself rather than the message expression?
> > 
> > ```
> > #if FLAG
> > #define INVOCATION self
> > #else
> > #define INVOCATION init
> > #endif
> > 
> > - (instancetype)init {
> >   return [super INVOCATION];
> > }
> > ```
> > Before I investigate modifying the check to avoid generating a fixit in 
> > this case, I think it would be helpful for me to understand your concerns 
> > in that scenario better. Is your concern that a proper fix might involve 
> > fixing the macro itself rather than the message expression?
> 
> Essentially, yes. Macros can get arbitrarily complex and so our rule of thumb 
> is to not apply fix-its when the code being fixed is within a macro. Another 
> example that can be tricky is adding another layer of macros:
> ```
> #define FOO super
> #define BAR self
> #define BAZ FOO BAR
> 
> - (instancetype)init {
>   return [BAZ];
> }
> ```
Thanks for the explanation! I'll get started making the changes 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59806



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


[PATCH] D60279: [CUDA] Implemented _[bi]mma* builtins.

2019-04-04 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 193809.
tra added a comment.

- Added PTX64 to the list of builtins' constraints.


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

https://reviews.llvm.org/D60279

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/CodeGen/builtins-nvptx-mma.cu
  clang/test/CodeGen/builtins-nvptx-mma.py
  llvm/lib/Target/NVPTX/NVPTX.td

Index: llvm/lib/Target/NVPTX/NVPTX.td
===
--- llvm/lib/Target/NVPTX/NVPTX.td
+++ llvm/lib/Target/NVPTX/NVPTX.td
@@ -75,6 +75,8 @@
  "Use PTX version 6.1">;
 def PTX63 : SubtargetFeature<"ptx63", "PTXVersion", "63",
  "Use PTX version 6.3">;
+def PTX64 : SubtargetFeature<"ptx64", "PTXVersion", "64",
+ "Use PTX version 6.4">;
 
 //===--===//
 // NVPTX supported processors.
Index: clang/test/CodeGen/builtins-nvptx-mma.py
===
--- /dev/null
+++ clang/test/CodeGen/builtins-nvptx-mma.py
@@ -0,0 +1,343 @@
+# This script generates all variants of wmma builtins, verifies that clang calls
+# correct LLVM instrinsics, and checks that availability of specific builtins is
+# constrained by the correct PTX version and the target GPU variant.
+
+# Dummy test run to avoid lit warnings.
+# RUN: echo "This is not a real test. It's a generator for builtins-nvpts-mma.cu" >/dev/null
+
+from __future__ import print_function
+
+import argparse
+from collections import defaultdict
+from itertools import product
+from string import Template
+
+class MMAFrag:
+  def __init__(self, geom, frag, ptx_elt_type):
+self.geom = geom
+self.frag = frag
+self.ptx_type = ptx_elt_type;
+
+  def __repr__(self):
+return "%s:%s:%s" % (self.geom, self.frag, self.ptx_type)
+
+class MMAOp:
+  def __init__(self, a, b, c, d):
+self.a = a
+self.b = b
+self.c = c
+self.d = d
+
+  def __repr__(self):
+return ("{A:%s, B:%s, C:%s, D:%s}" % (self.a, self.b, self.c, self.d ))
+
+def make_mma_ops(geoms, types_a, types_b, types_c, types_d):
+  ops = []
+  for geom, type_a, type_c in product( geoms,  types_a, types_c):
+for type_b, type_d in product(types_b if types_b else [type_a],
+  types_d if types_d else [type_c]):
+  ops.append(MMAOp(MMAFrag(geom, "a", type_a),
+   MMAFrag(geom, "b", type_b),
+   MMAFrag(geom, "c", type_c),
+   MMAFrag(geom, "d", type_d)))
+  return ops
+
+def make_ldst_ops(geoms, frags, types):
+  return [MMAFrag(geom, frag, ptx_type) for (geom, frag, ptx_type)
+  in product(geoms, frags, types)]
+
+def get_mma_ops():
+  return (make_mma_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+   ["f16"], [], ["f16", "f32"], ["f16", "f32"]) +
+  make_mma_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+   ["s8", "u8"], [], ["s32"], []) +
+  make_mma_ops(["m8n8k32"],
+   ["s4", "u4"], [], ["s32"], []) +
+  make_mma_ops(["m8n8k128"],
+   ["b1"], [], ["s32"], []))
+def get_ldst_ops():
+  return (make_ldst_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+["a", "b"], ["f16", "u8", "s8"]) +
+  make_ldst_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+["c", "d"], ["f16", "f32", "s32"]) +
+  make_ldst_ops(["m8n8k32"], ["a", "b"], ["s4","u4"]) +
+  make_ldst_ops(["m8n8k128"], ["a", "b"], ["b1"]) +
+  make_ldst_ops(["m8n8k32", "m8n8k128"],  ["c", "d"], ["s32"]))
+
+def is_geom_supported(geom):
+  # geometries for FP and ints.
+  if geom in ["m8n32k16", "m32n8k16"]:
+return ptx_version >= 61
+  # geometries for sub-ints.
+  if geom in ["m8n8k32", "m8n8k128"]:
+return ptx_version >= 63 and gpu_arch >= 75
+  if geom == "m16n16k16":
+return ptx_version >= 60
+  assert(False) # Unexpected geometry.
+
+def is_type_supported(ptx_type):
+  if ptx_type in ["s8", "u8", "s32"]:
+return ptx_version >= 63 and gpu_arch >= 72
+  if ptx_type in ["s4", "u4", "b1"]:
+return ptx_version >= 63 and gpu_arch >= 75
+  return ptx_version >= 60 and gpu_arch >= 70
+
+def is_mma_variant_supported(op, layout_a, layout_b, satf):
+  if not (is_type_supported(op.a.ptx_type)
+  and is_geom_supported(op.a.geom)):
+return False
+  # sub-integer require row/col layout, and no satf.
+  if op.a.ptx_type in ["s4", "u4", "b1"]:
+if op.a.ptx_type == "b1" and satf:
+  return False
+return layout_a == "row" and layout_b == "col"
+  return True
+
+def is_ldst_variant_supported(frag, layout):
+  if not (is_type_supported(frag.ptx_type)
+  and is_geom_supported(frag.geom)):
+

[PATCH] D60287: [IR] Refactor attribute methods in Function class (NFC)

2019-04-04 Thread Evandro Menezes via Phabricator via cfe-commits
evandro added a comment.

If anyone could give me a tip on how to avoid the review to be collapsed to 
just the part of whichever repo was hit first by a commit, I'd appreciate it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60287



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


[PATCH] D60279: [CUDA] Implemented _[bi]mma* builtins.

2019-04-04 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 193796.
tra added a comment.

- Fixed minor issues with parameters of the new builtins:
  - __imma*_st_c_i32 builtins have 'const int * src'
  - __bmma_m8n8k128_mma_xor_popc_b1 does not have 'satf' argument.


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

https://reviews.llvm.org/D60279

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/CodeGen/builtins-nvptx-mma.cu
  clang/test/CodeGen/builtins-nvptx-mma.py
  llvm/lib/Target/NVPTX/NVPTX.td

Index: llvm/lib/Target/NVPTX/NVPTX.td
===
--- llvm/lib/Target/NVPTX/NVPTX.td
+++ llvm/lib/Target/NVPTX/NVPTX.td
@@ -75,6 +75,8 @@
  "Use PTX version 6.1">;
 def PTX63 : SubtargetFeature<"ptx63", "PTXVersion", "63",
  "Use PTX version 6.3">;
+def PTX64 : SubtargetFeature<"ptx64", "PTXVersion", "64",
+ "Use PTX version 6.4">;
 
 //===--===//
 // NVPTX supported processors.
Index: clang/test/CodeGen/builtins-nvptx-mma.py
===
--- /dev/null
+++ clang/test/CodeGen/builtins-nvptx-mma.py
@@ -0,0 +1,343 @@
+# This script generates all variants of wmma builtins, verifies that clang calls
+# correct LLVM instrinsics, and checks that availability of specific builtins is
+# constrained by the correct PTX version and the target GPU variant.
+
+# Dummy test run to avoid lit warnings.
+# RUN: echo "This is not a real test. It's a generator for builtins-nvpts-mma.cu" >/dev/null
+
+from __future__ import print_function
+
+import argparse
+from collections import defaultdict
+from itertools import product
+from string import Template
+
+class MMAFrag:
+  def __init__(self, geom, frag, ptx_elt_type):
+self.geom = geom
+self.frag = frag
+self.ptx_type = ptx_elt_type;
+
+  def __repr__(self):
+return "%s:%s:%s" % (self.geom, self.frag, self.ptx_type)
+
+class MMAOp:
+  def __init__(self, a, b, c, d):
+self.a = a
+self.b = b
+self.c = c
+self.d = d
+
+  def __repr__(self):
+return ("{A:%s, B:%s, C:%s, D:%s}" % (self.a, self.b, self.c, self.d ))
+
+def make_mma_ops(geoms, types_a, types_b, types_c, types_d):
+  ops = []
+  for geom, type_a, type_c in product( geoms,  types_a, types_c):
+for type_b, type_d in product(types_b if types_b else [type_a],
+  types_d if types_d else [type_c]):
+  ops.append(MMAOp(MMAFrag(geom, "a", type_a),
+   MMAFrag(geom, "b", type_b),
+   MMAFrag(geom, "c", type_c),
+   MMAFrag(geom, "d", type_d)))
+  return ops
+
+def make_ldst_ops(geoms, frags, types):
+  return [MMAFrag(geom, frag, ptx_type) for (geom, frag, ptx_type)
+  in product(geoms, frags, types)]
+
+def get_mma_ops():
+  return (make_mma_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+   ["f16"], [], ["f16", "f32"], ["f16", "f32"]) +
+  make_mma_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+   ["s8", "u8"], [], ["s32"], []) +
+  make_mma_ops(["m8n8k32"],
+   ["s4", "u4"], [], ["s32"], []) +
+  make_mma_ops(["m8n8k128"],
+   ["b1"], [], ["s32"], []))
+def get_ldst_ops():
+  return (make_ldst_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+["a", "b"], ["f16", "u8", "s8"]) +
+  make_ldst_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+["c", "d"], ["f16", "f32", "s32"]) +
+  make_ldst_ops(["m8n8k32"], ["a", "b"], ["s4","u4"]) +
+  make_ldst_ops(["m8n8k128"], ["a", "b"], ["b1"]) +
+  make_ldst_ops(["m8n8k32", "m8n8k128"],  ["c", "d"], ["s32"]))
+
+def is_geom_supported(geom):
+  # geometries for FP and ints.
+  if geom in ["m8n32k16", "m32n8k16"]:
+return ptx_version >= 61
+  # geometries for sub-ints.
+  if geom in ["m8n8k32", "m8n8k128"]:
+return ptx_version >= 63 and gpu_arch >= 75
+  if geom == "m16n16k16":
+return ptx_version >= 60
+  assert(False) # Unexpected geometry.
+
+def is_type_supported(ptx_type):
+  if ptx_type in ["s8", "u8", "s32"]:
+return ptx_version >= 63 and gpu_arch >= 72
+  if ptx_type in ["s4", "u4", "b1"]:
+return ptx_version >= 63 and gpu_arch >= 75
+  return ptx_version >= 60 and gpu_arch >= 70
+
+def is_mma_variant_supported(op, layout_a, layout_b, satf):
+  if not (is_type_supported(op.a.ptx_type)
+  and is_geom_supported(op.a.geom)):
+return False
+  # sub-integer require row/col layout, and no satf.
+  if op.a.ptx_type in ["s4", "u4", "b1"]:
+if op.a.ptx_type == "b1" and satf:
+  return False
+return layout_a == "row" and layout_b == "col"
+  return True
+
+def 

[PATCH] D60287: [IR] Refactor attribute methods in Function class (NFC)

2019-04-04 Thread Evandro Menezes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC357731: [IR] Refactor attribute methods in Function class 
(NFC) (authored by evandro, committed by ).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60287?vs=193787=193794#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D60287

Files:
  lib/CodeGen/CGCall.cpp


Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1809,7 +1809,7 @@
 
 void CodeGenModule::AddDefaultFnAttrs(llvm::Function ) {
   llvm::AttrBuilder FuncAttrs;
-  ConstructDefaultFnAttrList(F.getName(), F.optForNone(),
+  ConstructDefaultFnAttrList(F.getName(), F.hasOptNone(),
  /* AttrOnCallsite = */ false, FuncAttrs);
   F.addAttributes(llvm::AttributeList::FunctionIndex, FuncAttrs);
 }


Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1809,7 +1809,7 @@
 
 void CodeGenModule::AddDefaultFnAttrs(llvm::Function ) {
   llvm::AttrBuilder FuncAttrs;
-  ConstructDefaultFnAttrList(F.getName(), F.optForNone(),
+  ConstructDefaultFnAttrList(F.getName(), F.hasOptNone(),
  /* AttrOnCallsite = */ false, FuncAttrs);
   F.addAttributes(llvm::AttributeList::FunctionIndex, FuncAttrs);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r357731 - [IR] Refactor attribute methods in Function class (NFC)

2019-04-04 Thread Evandro Menezes via cfe-commits
Author: evandro
Date: Thu Apr  4 15:40:06 2019
New Revision: 357731

URL: http://llvm.org/viewvc/llvm-project?rev=357731=rev
Log:
[IR] Refactor attribute methods in Function class (NFC)

Rename the functions that query the optimization kind attributes.

Differential revision: https://reviews.llvm.org/D60287

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

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=357731=357730=357731=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Apr  4 15:40:06 2019
@@ -1809,7 +1809,7 @@ void CodeGenModule::ConstructDefaultFnAt
 
 void CodeGenModule::AddDefaultFnAttrs(llvm::Function ) {
   llvm::AttrBuilder FuncAttrs;
-  ConstructDefaultFnAttrList(F.getName(), F.optForNone(),
+  ConstructDefaultFnAttrList(F.getName(), F.hasOptNone(),
  /* AttrOnCallsite = */ false, FuncAttrs);
   F.addAttributes(llvm::AttributeList::FunctionIndex, FuncAttrs);
 }


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


[PATCH] D60237: [MS] Add metadata for __declspec(allocator)

2019-04-04 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 193792.
akhuang marked 3 inline comments as done.
akhuang added a comment.

-added struct case to test
-style fixes


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

https://reviews.llvm.org/D60237

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/debug-info-codeview-heapallocsite.c

Index: clang/test/CodeGen/debug-info-codeview-heapallocsite.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-codeview-heapallocsite.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -debug-info-kind=limited -gcodeview -fdeclspec -S -emit-llvm < %s | FileCheck %s
+
+char buf[1024];
+__declspec(allocator) void *myalloc(int s) {
+  return [0];
+}
+
+void call_alloc() {
+  char *p = (char*)myalloc(sizeof(char));
+}
+
+struct Foo {
+  int x;
+};
+
+struct Foo foo_buf[1024];
+__declspec(allocator) struct Foo *alloc_foo() {
+  return _buf[0];
+}
+
+void call_alloc_foo() {
+  struct Foo *p = alloc_foo();
+}
+
+// CHECK-LABEL: define {{.*}}void @call_alloc
+// CHECK: call i8* @myalloc(i32 1){{.*}} !heapallocsite [[DBG1:!.*]]
+
+// CHECK-LABEL: define {{.*}}%struct.Foo* @alloc_foo
+// CHECK: call %struct.Foo* @alloc_foo(){{.*}} !heapallocsite [[DBG2:!.*]]
+
+// CHECK: [[DBG1]] = !{}
+// CHECK: [[DBG2]] = distinct !DICompositeType(tag: DW_TAG_structure_type,
+// CHECK-SAME: name: "Foo"
+
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -476,6 +476,10 @@
   /// Emit standalone debug info for a type.
   llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);
 
+  /// Add heapallocsite metadata for MSAllocator calls.
+  void addHeapAllocSiteMetadata(llvm::Instruction *CallSite, QualType Ty,
+SourceLocation Loc);
+
   void completeType(const EnumDecl *ED);
   void completeType(const RecordDecl *RD);
   void completeRequiredType(const RecordDecl *RD);
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1959,6 +1959,21 @@
   return T;
 }
 
+void CGDebugInfo::addHeapAllocSiteMetadata(llvm::Instruction *CI,
+   QualType D,
+   SourceLocation Loc) {
+  llvm::MDNode *node;
+  if (D.getTypePtr()->isVoidPointerType()) {
+node = llvm::MDNode::get(CGM.getLLVMContext(), None);
+  } else {
+QualType PointeeTy = D.getTypePtr()->getPointeeType();
+node = getOrCreateType(PointeeTy, getOrCreateFile(Loc));
+  }
+
+  CI->setMetadata("heapallocsite", node);
+}
+
+
 void CGDebugInfo::completeType(const EnumDecl *ED) {
   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
 return;
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3800,6 +3800,8 @@
 
   llvm::FunctionType *IRFuncTy = getTypes().GetFunctionType(CallInfo);
 
+  const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
+
 #ifndef NDEBUG
   if (!(CallInfo.isVariadic() && CallInfo.getArgStruct())) {
 // For an inalloca varargs function, we don't expect CallInfo to match the
@@ -4288,11 +4290,7 @@
   // Apply always_inline to all calls within flatten functions.
   // FIXME: should this really take priority over __try, below?
   if (CurCodeDecl && CurCodeDecl->hasAttr() &&
-  !(Callee.getAbstractInfo().getCalleeDecl().getDecl() &&
-Callee.getAbstractInfo()
-.getCalleeDecl()
-.getDecl()
-->hasAttr())) {
+  !(TargetDecl && TargetDecl->hasAttr())) {
 Attrs =
 Attrs.addAttribute(getLLVMContext(), llvm::AttributeList::FunctionIndex,
llvm::Attribute::AlwaysInline);
@@ -4376,11 +4374,16 @@
 
   // Suppress tail calls if requested.
   if (llvm::CallInst *Call = dyn_cast(CI)) {
-const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
 if (TargetDecl && TargetDecl->hasAttr())
   Call->setTailCallKind(llvm::CallInst::TCK_NoTail);
   }
 
+  // Add metadata for calls to MSAllocator functions
+  // FIXME: Get the type that the return value is cast to.
+  if (!DisableDebugInfo && TargetDecl &&
+  TargetDecl->hasAttr())
+getDebugInfo()->addHeapAllocSiteMetadata(CI, RetTy, Loc);
+
   // 4. Finish the call.
 
   // If the call doesn't return, finish the basic block and clear the
@@ -4537,7 +4540,6 @@
   } ();
 
   // Emit the assume_aligned check on the return value.
-  const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
   if (Ret.isScalar() && TargetDecl) {
  

[PATCH] D59744: Fix i386 ABI "__m64" type bug

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



Comment at: lib/CodeGen/TargetInfo.cpp:9473-9474
   IsWin32FloatStructABI, CodeGenOpts.NumRegisterParameters));
+} else if (Triple.getOS() == llvm::Triple::Linux) {
+  // System V i386 ABI requires __m64 value passing by MMX registers.
+  bool EnableMMX = getContext().getTargetInfo().getABI() != "no-mmx";

The Sys V rules apply to every non-Windows OS, not just Linux. I think you 
should add the parameter regardless of the OS


Repository:
  rC Clang

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

https://reviews.llvm.org/D59744



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


[PATCH] D55229: [COFF] Statically link certain runtime library functions

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

This patch fixes a lot of LNK4286 warnings when running `check-asan` on 
Windows, so I'd like to get it committed upstream. Are there any remaining 
objections? Is it OK if I commandeer the revision and make some minor aesthetic 
adjustments and land it?


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

https://reviews.llvm.org/D55229



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


[PATCH] D60247: Make SourceManager::createFileID(UnownedTag, ...) take a const llvm::MemoryBuffer*

2019-04-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE357724: Make SourceManager::createFileID(UnownedTag, ...) 
take a const llvm… (authored by nico, committed by ).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D60247?vs=193655=193776#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60247

Files:
  clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
  clang-tidy/misc/StaticAssertCheck.cpp


Index: clang-tidy/misc/StaticAssertCheck.cpp
===
--- clang-tidy/misc/StaticAssertCheck.cpp
+++ clang-tidy/misc/StaticAssertCheck.cpp
@@ -145,7 +145,7 @@
   const LangOptions  = ASTCtx->getLangOpts();
   const SourceManager  = ASTCtx->getSourceManager();
 
-  llvm::MemoryBuffer *Buffer = SM.getBuffer(SM.getFileID(AssertLoc));
+  const llvm::MemoryBuffer *Buffer = SM.getBuffer(SM.getFileID(AssertLoc));
   if (!Buffer)
 return SourceLocation();
 
Index: clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
===
--- clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
+++ clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
@@ -53,7 +53,7 @@
 
   SourceLocation LocEnd = Semicolon->getEndLoc();
   FileID FID = SM.getFileID(LocEnd);
-  llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, LocEnd);
+  const llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, LocEnd);
   Lexer Lexer(SM.getLocForStartOfFile(FID), Ctxt.getLangOpts(),
   Buffer->getBufferStart(), SM.getCharacterData(LocEnd) + 1,
   Buffer->getBufferEnd());


Index: clang-tidy/misc/StaticAssertCheck.cpp
===
--- clang-tidy/misc/StaticAssertCheck.cpp
+++ clang-tidy/misc/StaticAssertCheck.cpp
@@ -145,7 +145,7 @@
   const LangOptions  = ASTCtx->getLangOpts();
   const SourceManager  = ASTCtx->getSourceManager();
 
-  llvm::MemoryBuffer *Buffer = SM.getBuffer(SM.getFileID(AssertLoc));
+  const llvm::MemoryBuffer *Buffer = SM.getBuffer(SM.getFileID(AssertLoc));
   if (!Buffer)
 return SourceLocation();
 
Index: clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
===
--- clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
+++ clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
@@ -53,7 +53,7 @@
 
   SourceLocation LocEnd = Semicolon->getEndLoc();
   FileID FID = SM.getFileID(LocEnd);
-  llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, LocEnd);
+  const llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, LocEnd);
   Lexer Lexer(SM.getLocForStartOfFile(FID), Ctxt.getLangOpts(),
   Buffer->getBufferStart(), SM.getCharacterData(LocEnd) + 1,
   Buffer->getBufferEnd());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r357724 - Make SourceManager::createFileID(UnownedTag, ...) take a const llvm::MemoryBuffer*

2019-04-04 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Apr  4 14:06:41 2019
New Revision: 357724

URL: http://llvm.org/viewvc/llvm-project?rev=357724=rev
Log:
Make SourceManager::createFileID(UnownedTag, ...) take a const 
llvm::MemoryBuffer*

Requires making the llvm::MemoryBuffer* stored by SourceManager const,
which in turn requires making the accessors for that return const
llvm::MemoryBuffer*s and updating all call sites.

The original motivation for this was to use it and fix the TODO in
CodeGenAction.cpp's ConvertBackendLocation() by using the UnownedTag
version of createFileID, and since llvm::SourceMgr* hands out a const
llvm::MemoryBuffer* this is required. I'm not sure if fixing the TODO
this way actually works, but this seems like a good change on its own
anyways.

No intended behavior change.

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

Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp?rev=357724=357723=357724=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp 
Thu Apr  4 14:06:41 2019
@@ -53,7 +53,7 @@ void SuspiciousSemicolonCheck::check(con
 
   SourceLocation LocEnd = Semicolon->getEndLoc();
   FileID FID = SM.getFileID(LocEnd);
-  llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, LocEnd);
+  const llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, LocEnd);
   Lexer Lexer(SM.getLocForStartOfFile(FID), Ctxt.getLangOpts(),
   Buffer->getBufferStart(), SM.getCharacterData(LocEnd) + 1,
   Buffer->getBufferEnd());

Modified: clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp?rev=357724=357723=357724=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp Thu Apr  4 
14:06:41 2019
@@ -145,7 +145,7 @@ SourceLocation StaticAssertCheck::getLas
   const LangOptions  = ASTCtx->getLangOpts();
   const SourceManager  = ASTCtx->getSourceManager();
 
-  llvm::MemoryBuffer *Buffer = SM.getBuffer(SM.getFileID(AssertLoc));
+  const llvm::MemoryBuffer *Buffer = SM.getBuffer(SM.getFileID(AssertLoc));
   if (!Buffer)
 return SourceLocation();
 


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


r357724 - Make SourceManager::createFileID(UnownedTag, ...) take a const llvm::MemoryBuffer*

2019-04-04 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Apr  4 14:06:41 2019
New Revision: 357724

URL: http://llvm.org/viewvc/llvm-project?rev=357724=rev
Log:
Make SourceManager::createFileID(UnownedTag, ...) take a const 
llvm::MemoryBuffer*

Requires making the llvm::MemoryBuffer* stored by SourceManager const,
which in turn requires making the accessors for that return const
llvm::MemoryBuffer*s and updating all call sites.

The original motivation for this was to use it and fix the TODO in
CodeGenAction.cpp's ConvertBackendLocation() by using the UnownedTag
version of createFileID, and since llvm::SourceMgr* hands out a const
llvm::MemoryBuffer* this is required. I'm not sure if fixing the TODO
this way actually works, but this seems like a good change on its own
anyways.

No intended behavior change.

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

Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/lib/Basic/SourceManager.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/IssueHash.cpp
cfe/trunk/tools/clang-import-test/clang-import-test.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=357724=357723=357724=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Thu Apr  4 14:06:41 2019
@@ -105,7 +105,7 @@ namespace SrcMgr {
 ///
 /// This is owned by the ContentCache object.  The bits indicate
 /// whether the buffer is invalid.
-mutable llvm::PointerIntPair Buffer;
+mutable llvm::PointerIntPair Buffer;
 
   public:
 /// Reference to the file entry representing this ContentCache.
@@ -184,10 +184,10 @@ namespace SrcMgr {
 ///   will be emitted at.
 ///
 /// \param Invalid If non-NULL, will be set \c true if an error occurred.
-llvm::MemoryBuffer *getBuffer(DiagnosticsEngine ,
-  const SourceManager ,
-  SourceLocation Loc = SourceLocation(),
-  bool *Invalid = nullptr) const;
+const llvm::MemoryBuffer *getBuffer(DiagnosticsEngine ,
+const SourceManager ,
+SourceLocation Loc = SourceLocation(),
+bool *Invalid = nullptr) const;
 
 /// Returns the size of the content encapsulated by this
 /// ContentCache.
@@ -209,11 +209,13 @@ namespace SrcMgr {
 
 /// Get the underlying buffer, returning NULL if the buffer is not
 /// yet available.
-llvm::MemoryBuffer *getRawBuffer() const { return Buffer.getPointer(); }
+const llvm::MemoryBuffer *getRawBuffer() const {
+  return Buffer.getPointer();
+}
 
 /// Replace the existing buffer (which will be deleted)
 /// with the given buffer.
-void replaceBuffer(llvm::MemoryBuffer *B, bool DoNotFree = false);
+void replaceBuffer(const llvm::MemoryBuffer *B, bool DoNotFree = false);
 
 /// Determine whether the buffer itself is invalid.
 bool isBufferInvalid() const {
@@ -841,7 +843,7 @@ public:
   ///
   /// This does no caching of the buffer and takes ownership of the
   /// MemoryBuffer, so only pass a MemoryBuffer to this once.
-  FileID createFileID(UnownedTag, llvm::MemoryBuffer *Buffer,
+  FileID createFileID(UnownedTag, const llvm::MemoryBuffer *Buffer,
   SrcMgr::CharacteristicKind FileCharacter = 
SrcMgr::C_User,
   int LoadedID = 0, unsigned LoadedOffset = 0,
   SourceLocation IncludeLoc = SourceLocation()) {
@@ -887,8 +889,8 @@ public:
   ///
   /// \param Invalid If non-NULL, will be set \c true if an error
   /// occurs while retrieving the memory buffer.
-  llvm::MemoryBuffer *getMemoryBufferForFile(const FileEntry *File,
- bool *Invalid = nullptr);
+  const llvm::MemoryBuffer *getMemoryBufferForFile(const FileEntry *File,
+   bool *Invalid = nullptr);
 
   /// Override the contents of the given source file by providing an
   /// already-allocated buffer.
@@ -951,8 +953,8 @@ public:
   ///
   /// If there is an error opening this buffer the first time, this
   /// manufactures a temporary buffer and returns a non-empty error string.
-  llvm::MemoryBuffer *getBuffer(FileID FID, SourceLocation Loc,
-bool *Invalid = nullptr) const {
+  const llvm::MemoryBuffer *getBuffer(FileID FID, SourceLocation Loc,
+  bool 

[PATCH] D60279: [CUDA] Implemented _[bi]mma* builtins.

2019-04-04 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 193774.
tra edited the summary of this revision.
tra added a comment.

Cleaned up mma test generation.


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

https://reviews.llvm.org/D60279

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/CodeGen/builtins-nvptx-mma.cu
  clang/test/CodeGen/builtins-nvptx-mma.py
  llvm/lib/Target/NVPTX/NVPTX.td

Index: llvm/lib/Target/NVPTX/NVPTX.td
===
--- llvm/lib/Target/NVPTX/NVPTX.td
+++ llvm/lib/Target/NVPTX/NVPTX.td
@@ -75,6 +75,8 @@
  "Use PTX version 6.1">;
 def PTX63 : SubtargetFeature<"ptx63", "PTXVersion", "63",
  "Use PTX version 6.3">;
+def PTX64 : SubtargetFeature<"ptx64", "PTXVersion", "64",
+ "Use PTX version 6.4">;
 
 //===--===//
 // NVPTX supported processors.
Index: clang/test/CodeGen/builtins-nvptx-mma.py
===
--- /dev/null
+++ clang/test/CodeGen/builtins-nvptx-mma.py
@@ -0,0 +1,339 @@
+# This script generates all variants of wmma builtins, verifies that clang calls
+# correct LLVM instrinsics, and checks that availability of specific builtins is
+# constrained by the correct PTX version and the target GPU variant.
+
+# Dummy test run to avoid lit warnings.
+# RUN: echo "This is not a real test. It's a generator for builtins-nvpts-mma.cu" >/dev/null
+
+from __future__ import print_function
+
+import argparse
+from collections import defaultdict
+from itertools import product
+from string import Template
+
+class MMAFrag:
+  def __init__(self, geom, frag, ptx_elt_type):
+self.geom = geom
+self.frag = frag
+self.ptx_type = ptx_elt_type;
+
+  def __repr__(self):
+return "%s:%s:%s" % (self.geom, self.frag, self.ptx_type)
+
+class MMAOp:
+  def __init__(self, a, b, c, d):
+self.a = a
+self.b = b
+self.c = c
+self.d = d
+
+  def __repr__(self):
+return ("{A:%s, B:%s, C:%s, D:%s}" % (self.a, self.b, self.c, self.d ))
+
+def make_mma_ops(geoms, types_a, types_b, types_c, types_d):
+  ops = []
+  for geom, type_a, type_c in product( geoms,  types_a, types_c):
+for type_b, type_d in product(types_b if types_b else [type_a],
+  types_d if types_d else [type_c]):
+  ops.append(MMAOp(MMAFrag(geom, "a", type_a),
+   MMAFrag(geom, "b", type_b),
+   MMAFrag(geom, "c", type_c),
+   MMAFrag(geom, "d", type_d)))
+  return ops
+
+def make_ldst_ops(geoms, frags, types):
+  return [MMAFrag(geom, frag, ptx_type) for (geom, frag, ptx_type)
+  in product(geoms, frags, types)]
+
+def get_mma_ops():
+  return (make_mma_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+   ["f16"], [], ["f16", "f32"], ["f16", "f32"]) +
+  make_mma_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+   ["s8", "u8"], [], ["s32"], []) +
+  make_mma_ops(["m8n8k32"],
+   ["s4", "u4"], [], ["s32"], []) +
+  make_mma_ops(["m8n8k128"],
+   ["b1"], [], ["s32"], []))
+def get_ldst_ops():
+  return (make_ldst_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+["a", "b"], ["f16", "u8", "s8"]) +
+  make_ldst_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+["c", "d"], ["f16", "f32", "s32"]) +
+  make_ldst_ops(["m8n8k32"], ["a", "b"], ["s4","u4"]) +
+  make_ldst_ops(["m8n8k128"], ["a", "b"], ["b1"]) +
+  make_ldst_ops(["m8n8k32", "m8n8k128"],  ["c", "d"], ["s32"]))
+
+def is_geom_supported(geom):
+  # geometries for FP and ints.
+  if geom in ["m8n32k16", "m32n8k16"]:
+return ptx_version >= 61
+  # geometries for sub-ints.
+  if geom in ["m8n8k32", "m8n8k128"]:
+return ptx_version >= 63 and gpu_arch >= 75
+  if geom == "m16n16k16":
+return ptx_version >= 60
+  assert(False) # Unexpected geometry.
+
+def is_type_supported(ptx_type):
+  if ptx_type in ["s8", "u8", "s32"]:
+return ptx_version >= 63 and gpu_arch >= 72
+  if ptx_type in ["s4", "u4", "b1"]:
+return ptx_version >= 63 and gpu_arch >= 75
+  return ptx_version >= 60 and gpu_arch >= 70
+
+def is_mma_variant_supported(op, layout_a, layout_b, satf):
+  if not (is_type_supported(op.a.ptx_type)
+  and is_geom_supported(op.a.geom)):
+return False
+  # sub-integer require row/col layout, and no satf.
+  if op.a.ptx_type in ["s4", "u4", "b1"]:
+if op.a.ptx_type == "b1" and satf:
+  return False
+return layout_a == "row" and layout_b == "col"
+  return True
+
+def is_ldst_variant_supported(frag, layout):
+  if not (is_type_supported(frag.ptx_type)
+  and 

[PATCH] D60247: Make SourceManager::createFileID(UnownedTag, ...) take a const llvm::MemoryBuffer*

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

lgtm!


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

https://reviews.llvm.org/D60247



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


[PATCH] D60094: [MSVC] If unable to find link.exe relative to MSVC, look for link.exe in the path

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



Comment at: lib/Driver/ToolChains/MSVC.cpp:493
   C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found);
+  linkPath = TC.GetProgramPath("link.exe");
+}

mstorsjo wrote:
> rnk wrote:
> > amccarth wrote:
> > > The comment above explains one reason why we shouldn't use link.exe on 
> > > the path.
> > > 
> > > If it is an appropriate fallback, modify the comment or add another one 
> > > here explaining why this is better than failing.  I think you hit on it 
> > > in the patch summary, but it should be captured in the code.
> > Right, and this code block is inside some crazy getenv check for 
> > USE_PATH_LINK, so I think we don't want to do a path search here. Then 
> > again, I bet someone added that because they wanted clang to just do a path 
> > search. I guess, there's your workaround.
> Sorry for the confusion - the getenv USE_PATH_LINK thingie there isn't 
> present upstream, it's my other initial hack to get around this issue; I 
> should have reordered the patches before making this diff.
> 
> So that getenv hack is an ugly but convenient (for me) way around the issue. 
> Another alternative is to use `-fuse-ld=link.exe` (which happens to miss the 
> `Linker.equals_lower("link")` check).
> 
> Prior to switching to lld, how did chromium do this? I presume the cross 
> compilation setup did exist already before lld. Although in practice I guess 
> most people don't use (clang-)cl for linking but just invoke `link` directly 
> so maybe it didn't matter at all.
> 
> Another approach (which also works fine for me) is to look for `$(dirname 
> $(which cl))/link.exe`.
I think it's worth implementing `$(dirname $(which cl))/link.exe` because 
/usr/bin/link exists on Linux and in many Unix shell environments for Windows.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60094



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


[PATCH] D60283: [clang-cl] Don't emit checksums when compiling a preprocessed CPP

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



Comment at: lib/CodeGen/CGDebugInfo.cpp:429-430
+  const FileEntry *fileEntry = SM.getFileEntryForID(foundIdFromLoc);
+  if (!fileEntry || fileEntry->getName().empty() ||
+  fileEntry->getName().equals(FileName)) {
+CSKind = computeChecksum(foundIdFromLoc, Checksum);

I was unhappy with this check. It seems a bit ridiculous to compare the 
filenames by string when we surely have ids we could look at, but I wasn't able 
to figure out how.



Comment at: test/Driver/cl-preprocess-md5.cpp:1
+// RUN: %clang_cl /c %s /Z7 /Fo%t.obj
+// RUN: llvm-pdbutil dump -l %t.obj | grep -E " \(MD5: ([0-9A-F]+)\)" | sed -n 
-e 's/^.*MD5: //p' | sort | uniq | wc -l | FileCheck %s --check-prefix=GOOD-SIZE

This should be a much smaller test in test/CodeGen. You can check in an already 
pre-processed file with line markers in it, run clang -cc1 -emit-llvm, and 
check that the DIFile has no checksum. Clang's test suite can't depend on lld, 
and I'm not sure if it has deps on llvm-pdbutil either.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60283



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


[PATCH] D56924: Special case ObjCPropertyDecl for printing

2019-04-04 Thread David Goldman via Phabricator via cfe-commits
dgoldman closed this revision.
dgoldman added a comment.

Closed via rL357720 


Repository:
  rC Clang

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

https://reviews.llvm.org/D56924



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


r357720 - Special case ObjCPropertyDecl for printing

2019-04-04 Thread David Goldman via cfe-commits
Author: dgoldman
Date: Thu Apr  4 13:13:22 2019
New Revision: 357720

URL: http://llvm.org/viewvc/llvm-project?rev=357720=rev
Log:
Special case ObjCPropertyDecl for printing

ObjCPropertyDecl should use the category interface as a context similar to what 
is done for methods.

Previously category methods would be printed as `::property`; now they are 
printed as `Class::property`.

Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/unittests/AST/NamedDeclPrinterTest.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=357720=357719=357720=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Apr  4 13:13:22 2019
@@ -1531,10 +1531,16 @@ void NamedDecl::printQualifiedName(raw_o
const PrintingPolicy ) const {
   const DeclContext *Ctx = getDeclContext();
 
-  // For ObjC methods, look through categories and use the interface as 
context.
+  // For ObjC methods and properties, look through categories and use the
+  // interface as context.
   if (auto *MD = dyn_cast(this))
 if (auto *ID = MD->getClassInterface())
   Ctx = ID;
+  if (auto *PD = dyn_cast(this)) {
+if (auto *MD = PD->getGetterMethodDecl())
+  if (auto *ID = MD->getClassInterface())
+Ctx = ID;
+  }
 
   if (Ctx->isFunctionOrMethod()) {
 printName(OS);

Modified: cfe/trunk/unittests/AST/NamedDeclPrinterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/NamedDeclPrinterTest.cpp?rev=357720=357719=357720=diff
==
--- cfe/trunk/unittests/AST/NamedDeclPrinterTest.cpp (original)
+++ cfe/trunk/unittests/AST/NamedDeclPrinterTest.cpp Thu Apr  4 13:13:22 2019
@@ -115,6 +115,18 @@ PrintedWrittenNamedDeclCXX11Matches(Stri
  "input.cc");
 }
 
+::testing::AssertionResult
+PrintedWrittenPropertyDeclObjCMatches(StringRef Code, StringRef DeclName,
+   StringRef ExpectedPrinted) {
+  std::vector Args{"-std=c++11", "-xobjective-c++"};
+  return PrintedNamedDeclMatches(Code,
+ Args,
+ /*SuppressUnwrittenScope*/ true,
+ 
objcPropertyDecl(hasName(DeclName)).bind("id"),
+ ExpectedPrinted,
+ "input.m");
+}
+
 } // unnamed namespace
 
 TEST(NamedDeclPrinter, TestNamespace1) {
@@ -179,3 +191,31 @@ TEST(NamedDeclPrinter, TestLinkageInName
 "A",
 "X::A"));
 }
+
+TEST(NamedDeclPrinter, TestObjCClassExtension) {
+  ASSERT_TRUE(PrintedWrittenPropertyDeclObjCMatches(
+R"(
+  @interface Obj
+  @end
+
+  @interface Obj ()
+  @property(nonatomic) int property;
+  @end
+)",
+"property",
+"Obj::property"));
+}
+
+TEST(NamedDeclPrinter, TestObjCClassExtensionWithGetter) {
+  ASSERT_TRUE(PrintedWrittenPropertyDeclObjCMatches(
+R"(
+  @interface Obj
+  @end
+
+  @interface Obj ()
+  @property(nonatomic, getter=myPropertyGetter) int property;
+  @end
+)",
+"property",
+"Obj::property"));
+}


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


[PATCH] D60283: [clang-cl] Don't emit checksums when compiling a preprocessed CPP

2019-04-04 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: rnk, scott.linder, uabelho, aprantl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When compiling from an already preprocessed CPP, the checksums generated in the 
debug info would be those of the (input) preprocessed CPP, not those of the 
actual #includes.
Note how all the files have the same checksum below:

  ** Module: "E:\RD\tests\clang_hash\main.obj"
  
   0 E:\RD\tests\clang_hash\lib.h (MD5: 136293700AE501A1FB76EBD273C8D288)
   1 C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.17763.0\ucrt\stdio.h (MD5: 
136293700AE501A1FB76EBD273C8D288)
   2 E:\RD\tests\clang_hash\main.cpp (MD5: 136293700AE501A1FB76EBD273C8D288)
   3 C:\Program Files (x86)\Windows 
Kits\10\Include\10.0.17763.0\ucrt\corecrt_stdio_config.h (MD5: 
136293700AE501A1FB76EBD273C8D288)

When debugging in Visual Studio an EXE linked with the OBJ above, Visual Studio 
complains about the source files being different from when they were compiled, 
since the sources are compared by hash.

This patch simply clears the checksums to match MSVC behavior. Visual Studio 
will simply bypass the hash checking in that case, and hapily open the source 
file.

  ** Module: "E:\RD\tests\clang_hash\main.obj"
  
   0 c:\program files (x86)\windows 
kits\10\include\10.0.17763.0\ucrt\stdio.h (None)
   1 c:\program files (x86)\windows 
kits\10\include\10.0.17763.0\ucrt\corecrt_wstdio.h (None)
   2 c:\program files (x86)\windows 
kits\10\include\10.0.17763.0\ucrt\corecrt_stdio_config.h (None)
   3 c:\program files (x86)\microsoft visual 
studio\2017\professional\vc\tools\msvc\14.16.27023\include\vcruntime_new.h 
(None)
   4 e:\rd\tests\clang_hash\main.cpp (None)
   5 e:\rd\tests\clang_hash\lib.h (None)

We could write more complicated code to open the files from the corresponding 
#line directives, but we have no guarantee the preprocessed CPP is compiled in 
the same conditions as when it was pre-processed. Actually, when using 
Fastbuild, the files are preprocessed locally on the user's PC; then the 
preprocessed content is sent and compiled remotely on another PC that does not 
have the source code.

Fixes PR41215


Repository:
  rC Clang

https://reviews.llvm.org/D60283

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/Driver/cl-preprocess-md5.cpp


Index: test/Driver/cl-preprocess-md5.cpp
===
--- test/Driver/cl-preprocess-md5.cpp
+++ test/Driver/cl-preprocess-md5.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cl /c %s /Z7 /Fo%t.obj
+// RUN: llvm-pdbutil dump -l %t.obj | grep -E " \(MD5: ([0-9A-F]+)\)" | sed -n 
-e 's/^.*MD5: //p' | sort | uniq | wc -l | FileCheck %s --check-prefix=GOOD-SIZE
+// GOOD-SIZE-NOT: 1
+
+// RUN: %clang_cl /c %s /Z7 /E >%t.cpp
+// RUN: %clang_cl /c %t.cpp /Z7 /Fo%t.obj
+// RUN: llvm-pdbutil dump -l %t.obj | not grep -E " \(MD5: ([0-9A-F]+)\)"
+// RUN: llvm-pdbutil dump -l %t.obj | grep " (no checksum)"
+// 
+
+#include 
+int main() {
+  std::string A{"a"};
+  return 0;
+}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -421,13 +421,18 @@
   return cast(V);
   }
 
+  const FileID foundIdFromLoc = SM.getFileID(Loc);
   SmallString<32> Checksum;
-  Optional CSKind =
-  computeChecksum(SM.getFileID(Loc), Checksum);
+  Optional CSKind;
   Optional> CSInfo;
-  if (CSKind)
-CSInfo.emplace(*CSKind, Checksum);
-  return createFile(FileName, CSInfo, getSource(SM, SM.getFileID(Loc)));
+  const FileEntry *fileEntry = SM.getFileEntryForID(foundIdFromLoc);
+  if (!fileEntry || fileEntry->getName().empty() ||
+  fileEntry->getName().equals(FileName)) {
+CSKind = computeChecksum(foundIdFromLoc, Checksum);
+if (CSKind)
+  CSInfo.emplace(*CSKind, Checksum);
+  }
+  return createFile(FileName, CSInfo, getSource(SM, foundIdFromLoc));
 }
 
 llvm::DIFile *


Index: test/Driver/cl-preprocess-md5.cpp
===
--- test/Driver/cl-preprocess-md5.cpp
+++ test/Driver/cl-preprocess-md5.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cl /c %s /Z7 /Fo%t.obj
+// RUN: llvm-pdbutil dump -l %t.obj | grep -E " \(MD5: ([0-9A-F]+)\)" | sed -n -e 's/^.*MD5: //p' | sort | uniq | wc -l | FileCheck %s --check-prefix=GOOD-SIZE
+// GOOD-SIZE-NOT: 1
+
+// RUN: %clang_cl /c %s /Z7 /E >%t.cpp
+// RUN: %clang_cl /c %t.cpp /Z7 /Fo%t.obj
+// RUN: llvm-pdbutil dump -l %t.obj | not grep -E " \(MD5: ([0-9A-F]+)\)"
+// RUN: llvm-pdbutil dump -l %t.obj | grep " (no checksum)"
+// 
+
+#include 
+int main() {
+  std::string A{"a"};
+  return 0;
+}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -421,13 +421,18 @@
   return cast(V);
   }
 
+  const FileID foundIdFromLoc = SM.getFileID(Loc);
   

[PATCH] D60120: check-clang-tools: Actually build and run XPC test

2019-04-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE357719: check-clang-tools: Actually build and run XPC test 
(authored by nico, committed by ).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D60120?vs=193256=193770#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60120

Files:
  test/CMakeLists.txt
  test/lit.site.cfg.py.in


Index: test/lit.site.cfg.py.in
===
--- test/lit.site.cfg.py.in
+++ test/lit.site.cfg.py.in
@@ -11,7 +11,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
-config.clangd_xpc_support = @CLANGD_BUILD_XPC_SUPPORT@
+config.clangd_xpc_support = @CLANGD_BUILD_XPC@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -17,7 +17,7 @@
 
 llvm_canonicalize_cmake_booleans(
   CLANG_ENABLE_STATIC_ANALYZER
-  CLANGD_BUILD_XPC_SUPPORT)
+  CLANGD_BUILD_XPC)
 
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
@@ -70,7 +70,7 @@
   clang
 )
 
-if(CLANGD_BUILD_XPC_SUPPORT)
+if(CLANGD_BUILD_XPC)
   list(APPEND CLANG_TOOLS_TEST_DEPS clangd-xpc-test-client)
 endif()
 


Index: test/lit.site.cfg.py.in
===
--- test/lit.site.cfg.py.in
+++ test/lit.site.cfg.py.in
@@ -11,7 +11,7 @@
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
-config.clangd_xpc_support = @CLANGD_BUILD_XPC_SUPPORT@
+config.clangd_xpc_support = @CLANGD_BUILD_XPC@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -17,7 +17,7 @@
 
 llvm_canonicalize_cmake_booleans(
   CLANG_ENABLE_STATIC_ANALYZER
-  CLANGD_BUILD_XPC_SUPPORT)
+  CLANGD_BUILD_XPC)
 
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
@@ -70,7 +70,7 @@
   clang
 )
 
-if(CLANGD_BUILD_XPC_SUPPORT)
+if(CLANGD_BUILD_XPC)
   list(APPEND CLANG_TOOLS_TEST_DEPS clangd-xpc-test-client)
 endif()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r357719 - check-clang-tools: Actually build and run XPC test

2019-04-04 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Apr  4 13:08:04 2019
New Revision: 357719

URL: http://llvm.org/viewvc/llvm-project?rev=357719=rev
Log:
check-clang-tools: Actually build and run XPC test

The CMake variable controlling if XPC code is built is called
CLANGD_BUILD_XPC but three places unintentionally checked the
non-existent variable CLANGD_BUILD_XPC_SUPPORT instead, which (due to
being nonexistent, and due to cmake) always silently evaluated to false.

Luckily the test still seems to pass, despite never running after being
added almost 3 months ago in r351280.

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

Modified:
clang-tools-extra/trunk/test/CMakeLists.txt
clang-tools-extra/trunk/test/lit.site.cfg.py.in

Modified: clang-tools-extra/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/CMakeLists.txt?rev=357719=357718=357719=diff
==
--- clang-tools-extra/trunk/test/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/test/CMakeLists.txt Thu Apr  4 13:08:04 2019
@@ -17,7 +17,7 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLV
 
 llvm_canonicalize_cmake_booleans(
   CLANG_ENABLE_STATIC_ANALYZER
-  CLANGD_BUILD_XPC_SUPPORT)
+  CLANGD_BUILD_XPC)
 
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
@@ -70,7 +70,7 @@ set(CLANG_TOOLS_TEST_DEPS
   clang
 )
 
-if(CLANGD_BUILD_XPC_SUPPORT)
+if(CLANGD_BUILD_XPC)
   list(APPEND CLANG_TOOLS_TEST_DEPS clangd-xpc-test-client)
 endif()
 

Modified: clang-tools-extra/trunk/test/lit.site.cfg.py.in
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/lit.site.cfg.py.in?rev=357719=357718=357719=diff
==
--- clang-tools-extra/trunk/test/lit.site.cfg.py.in (original)
+++ clang-tools-extra/trunk/test/lit.site.cfg.py.in Thu Apr  4 13:08:04 2019
@@ -11,7 +11,7 @@ config.clang_libs_dir = "@SHLIBDIR@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
-config.clangd_xpc_support = @CLANGD_BUILD_XPC_SUPPORT@
+config.clangd_xpc_support = @CLANGD_BUILD_XPC@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.


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


[PATCH] D56924: Special case ObjCPropertyDecl for printing

2019-04-04 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 193769.
dgoldman added a comment.

Rebase


Repository:
  rC Clang

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

https://reviews.llvm.org/D56924

Files:
  lib/AST/Decl.cpp
  unittests/AST/NamedDeclPrinterTest.cpp


Index: unittests/AST/NamedDeclPrinterTest.cpp
===
--- unittests/AST/NamedDeclPrinterTest.cpp
+++ unittests/AST/NamedDeclPrinterTest.cpp
@@ -115,6 +115,18 @@
  "input.cc");
 }
 
+::testing::AssertionResult
+PrintedWrittenPropertyDeclObjCMatches(StringRef Code, StringRef DeclName,
+   StringRef ExpectedPrinted) {
+  std::vector Args{"-std=c++11", "-xobjective-c++"};
+  return PrintedNamedDeclMatches(Code,
+ Args,
+ /*SuppressUnwrittenScope*/ true,
+ 
objcPropertyDecl(hasName(DeclName)).bind("id"),
+ ExpectedPrinted,
+ "input.m");
+}
+
 } // unnamed namespace
 
 TEST(NamedDeclPrinter, TestNamespace1) {
@@ -179,3 +191,31 @@
 "A",
 "X::A"));
 }
+
+TEST(NamedDeclPrinter, TestObjCClassExtension) {
+  ASSERT_TRUE(PrintedWrittenPropertyDeclObjCMatches(
+R"(
+  @interface Obj
+  @end
+
+  @interface Obj ()
+  @property(nonatomic) int property;
+  @end
+)",
+"property",
+"Obj::property"));
+}
+
+TEST(NamedDeclPrinter, TestObjCClassExtensionWithGetter) {
+  ASSERT_TRUE(PrintedWrittenPropertyDeclObjCMatches(
+R"(
+  @interface Obj
+  @end
+
+  @interface Obj ()
+  @property(nonatomic, getter=myPropertyGetter) int property;
+  @end
+)",
+"property",
+"Obj::property"));
+}
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1531,10 +1531,16 @@
const PrintingPolicy ) const {
   const DeclContext *Ctx = getDeclContext();
 
-  // For ObjC methods, look through categories and use the interface as 
context.
+  // For ObjC methods and properties, look through categories and use the
+  // interface as context.
   if (auto *MD = dyn_cast(this))
 if (auto *ID = MD->getClassInterface())
   Ctx = ID;
+  if (auto *PD = dyn_cast(this)) {
+if (auto *MD = PD->getGetterMethodDecl())
+  if (auto *ID = MD->getClassInterface())
+Ctx = ID;
+  }
 
   if (Ctx->isFunctionOrMethod()) {
 printName(OS);


Index: unittests/AST/NamedDeclPrinterTest.cpp
===
--- unittests/AST/NamedDeclPrinterTest.cpp
+++ unittests/AST/NamedDeclPrinterTest.cpp
@@ -115,6 +115,18 @@
  "input.cc");
 }
 
+::testing::AssertionResult
+PrintedWrittenPropertyDeclObjCMatches(StringRef Code, StringRef DeclName,
+   StringRef ExpectedPrinted) {
+  std::vector Args{"-std=c++11", "-xobjective-c++"};
+  return PrintedNamedDeclMatches(Code,
+ Args,
+ /*SuppressUnwrittenScope*/ true,
+ objcPropertyDecl(hasName(DeclName)).bind("id"),
+ ExpectedPrinted,
+ "input.m");
+}
+
 } // unnamed namespace
 
 TEST(NamedDeclPrinter, TestNamespace1) {
@@ -179,3 +191,31 @@
 "A",
 "X::A"));
 }
+
+TEST(NamedDeclPrinter, TestObjCClassExtension) {
+  ASSERT_TRUE(PrintedWrittenPropertyDeclObjCMatches(
+R"(
+  @interface Obj
+  @end
+
+  @interface Obj ()
+  @property(nonatomic) int property;
+  @end
+)",
+"property",
+"Obj::property"));
+}
+
+TEST(NamedDeclPrinter, TestObjCClassExtensionWithGetter) {
+  ASSERT_TRUE(PrintedWrittenPropertyDeclObjCMatches(
+R"(
+  @interface Obj
+  @end
+
+  @interface Obj ()
+  @property(nonatomic, getter=myPropertyGetter) int property;
+  @end
+)",
+"property",
+"Obj::property"));
+}
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1531,10 +1531,16 @@
const PrintingPolicy ) const {
   const DeclContext *Ctx = getDeclContext();
 
-  // For ObjC methods, look through categories and use the interface as context.
+  // For ObjC methods and properties, look through categories and use the
+  // interface as context.
   if (auto *MD = dyn_cast(this))
 if (auto *ID = MD->getClassInterface())
   Ctx = ID;
+  if (auto *PD = dyn_cast(this)) {
+if (auto *MD = PD->getGetterMethodDecl())
+  if (auto *ID = MD->getClassInterface())
+Ctx = ID;
+  }
 
   if (Ctx->isFunctionOrMethod()) {
 printName(OS);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D60237: [MS] Add metadata for __declspec(allocator)

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



Comment at: clang/lib/CodeGen/CGCall.cpp:4382-4383
+  // Add metadata for calls to MSAllocator functions
+  if (!DisableDebugInfo) {
+if (TargetDecl && TargetDecl->hasAttr())
+  getDebugInfo()->addHeapAllocSiteMetadata(CI, RetTy, Loc);

I think you can combine the ifs: `!DisableDebugInfo && TargetDecl ...`



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1965
+   SourceLocation Loc) {
+  // FIXME: use the type that return value is cast to
+  llvm::MDNode *node;

This method takes the type in, so I think it's better to put the FIXME in 
CGCall.cpp. It should also be capitalized like a complete sentence 
(https://llvm.org/docs/CodingStandards.html#commenting).



Comment at: clang/test/CodeGen/debug-info-codeview-heapallocsite.c:4
+char buf[1024];
+__declspec(allocator) void *myalloc(int s) {
+  void *p = [0];

I think it would be interesting to add an allocator that returns a pointer to a 
struct, so something like:
```
struct Foo { int x; };
__declspec(allocator) Foo *alloc_foo();
Foo *call_alloc_foo() { return alloc_foo(); }
```

Then we can check for the right DICompositeType.


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

https://reviews.llvm.org/D60237



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


[PATCH] D60120: check-clang-tools: Actually build and run XPC test

2019-04-04 Thread Jan Korous via Phabricator via cfe-commits
jkorous accepted this revision.
jkorous added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for fixing this!


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

https://reviews.llvm.org/D60120



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


[PATCH] D59977: [Lexer] Fix an off-by-one bug in Lexer::getAsCharRange() - NFC.

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

I guess i'll commit, given that i don't know anybody else who uses these 
functions anyway.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59977



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


[PATCH] D60120: check-clang-tools: Actually build and run XPC test

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

erik.pilkington, could you stamp this maybe?


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

https://reviews.llvm.org/D60120



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


[PATCH] D60281: [analyzer] Add docs for cplusplus.InnerPointer

2019-04-04 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs created this revision.
rnkovacs added reviewers: NoQ, xazax.hun, Szelethus, dcoughlin, dkrupp.
Herald added subscribers: cfe-commits, Charusso, gamesh411, donat.nagy, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, whisperity.
Herald added a project: clang.

Tried to pick two interesting examples from the tests.
This check has no options.


Repository:
  rC Clang

https://reviews.llvm.org/D60281

Files:
  docs/analyzer/checkers.rst


Index: docs/analyzer/checkers.rst
===
--- docs/analyzer/checkers.rst
+++ docs/analyzer/checkers.rst
@@ -216,10 +216,34 @@
 
 C++ Checkers.
 
-cplusplus.InnerPointer
-""
+cplusplus.InnerPointer (C++)
+
 Check for inner pointers of C++ containers used after re/deallocation.
 
+In its present state, the check detects incorrect uses of raw inner pointers of
+``std::string``s, by recognizing member functions that may re/deallocate the 
buffer
+before use. In the future, it would be great to add support for other STL and
+non-STL containers, and most notably, ``std::string_view``s.
+
+.. code-block:: cpp
+
+ void consume(const char *);
+
+ void test_deref_after_equals() {
+   std::string s = "llvm";
+   const char *c = s.data(); // note: pointer to inner buffer of 'std::string' 
obtained here
+   s = "clang"; // note: inner buffer of 'std::string' reallocated by call to 
'operator='
+   consume(c); // warn: inner pointer of container used after re/deallocation
+ }
+
+ const char *test_return_temp() {
+   int x;
+   return std::to_string(x).c_str(); // warn: inner pointer of container used 
after re/deallocation
+   // note: pointer to inner buffer of 'std::string' obtained here
+   // note: inner buffer of 'std::string' deallocated by call to destructor
+ }
+
+
 cplusplus.NewDelete (C++)
 "
 Check for double-free and use-after-free problems. Traces memory managed by 
new/delete.


Index: docs/analyzer/checkers.rst
===
--- docs/analyzer/checkers.rst
+++ docs/analyzer/checkers.rst
@@ -216,10 +216,34 @@
 
 C++ Checkers.
 
-cplusplus.InnerPointer
-""
+cplusplus.InnerPointer (C++)
+
 Check for inner pointers of C++ containers used after re/deallocation.
 
+In its present state, the check detects incorrect uses of raw inner pointers of
+``std::string``s, by recognizing member functions that may re/deallocate the buffer
+before use. In the future, it would be great to add support for other STL and
+non-STL containers, and most notably, ``std::string_view``s.
+
+.. code-block:: cpp
+
+ void consume(const char *);
+
+ void test_deref_after_equals() {
+   std::string s = "llvm";
+   const char *c = s.data(); // note: pointer to inner buffer of 'std::string' obtained here
+   s = "clang"; // note: inner buffer of 'std::string' reallocated by call to 'operator='
+   consume(c); // warn: inner pointer of container used after re/deallocation
+ }
+
+ const char *test_return_temp() {
+   int x;
+   return std::to_string(x).c_str(); // warn: inner pointer of container used after re/deallocation
+   // note: pointer to inner buffer of 'std::string' obtained here
+   // note: inner buffer of 'std::string' deallocated by call to destructor
+ }
+
+
 cplusplus.NewDelete (C++)
 "
 Check for double-free and use-after-free problems. Traces memory managed by new/delete.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r357717 - [OPENMP]Add codegen for task reduction vars with allocate clause, NFC.

2019-04-04 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Apr  4 11:58:17 2019
New Revision: 357717

URL: http://llvm.org/viewvc/llvm-project?rev=357717=rev
Log:
[OPENMP]Add codegen for task reduction vars with allocate clause, NFC.

Added test for the task reduction variables with the allocate clause.

Modified:
cfe/trunk/test/OpenMP/task_in_reduction_codegen.cpp
cfe/trunk/test/OpenMP/taskgroup_task_reduction_codegen.cpp

Modified: cfe/trunk/test/OpenMP/task_in_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/task_in_reduction_codegen.cpp?rev=357717=357716=357717=diff
==
--- cfe/trunk/test/OpenMP/task_in_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/task_in_reduction_codegen.cpp Thu Apr  4 11:58:17 2019
@@ -10,6 +10,16 @@
 #ifndef HEADER
 #define HEADER
 
+typedef void **omp_allocator_handle_t;
+extern const omp_allocator_handle_t omp_default_mem_alloc;
+extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
+extern const omp_allocator_handle_t omp_const_mem_alloc;
+extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
+extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
+extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
+extern const omp_allocator_handle_t omp_pteam_mem_alloc;
+extern const omp_allocator_handle_t omp_thread_mem_alloc;
+
 // CHECK: [[PRIVATES:%.+]] = type { i8*, i8* }
 
 struct S {
@@ -31,7 +41,7 @@ int main(int argc, char **argv) {
   {
 #pragma omp taskgroup task_reduction(-:c, d)
 #pragma omp parallel
-#pragma omp task in_reduction(+:a) in_reduction(-:d)
+#pragma omp task in_reduction(+:a) in_reduction(-:d) 
allocate(omp_high_bw_mem_alloc: d)
 a += d[a];
   }
   return 0;

Modified: cfe/trunk/test/OpenMP/taskgroup_task_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskgroup_task_reduction_codegen.cpp?rev=357717=357716=357717=diff
==
--- cfe/trunk/test/OpenMP/taskgroup_task_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/taskgroup_task_reduction_codegen.cpp Thu Apr  4 
11:58:17 2019
@@ -12,6 +12,16 @@
 #ifndef HEADER
 #define HEADER
 
+typedef void **omp_allocator_handle_t;
+extern const omp_allocator_handle_t omp_default_mem_alloc;
+extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
+extern const omp_allocator_handle_t omp_const_mem_alloc;
+extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
+extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
+extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
+extern const omp_allocator_handle_t omp_pteam_mem_alloc;
+extern const omp_allocator_handle_t omp_thread_mem_alloc;
+
 // CHECK-DAG: @reduction_size.[[ID:.+]]_[[CID:[0-9]+]].artificial.
 // CHECK-DAG: @reduction_size.[[ID]]_[[CID]].artificial..cache.
 
@@ -29,7 +39,7 @@ int main(int argc, char **argv) {
   float b;
   S c[5];
   short d[argc];
-#pragma omp taskgroup task_reduction(+: a, b, argc)
+#pragma omp taskgroup allocate(omp_pteam_mem_alloc: a) task_reduction(+: a, b, 
argc)
   {
 #pragma omp taskgroup task_reduction(-:c, d)
 ;


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


[PATCH] D60107: [analyzer] NoStoreFuncVisitor: Suppress bug reports with no-store in system headers.

2019-04-04 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso accepted this revision.
Charusso added a comment.
This revision is now accepted and ready to land.

It is very good to try one improvement in another similar function.




Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:364
   QualType T = PVD->getType();
-  while (const MemRegion *R = S.getAsRegion()) {
-if (RegionOfInterest->isSubRegionOf(R) && !isPointerToConst(T))
-  return notModifiedDiagnostics(N, {}, R, ParamName,
-ParamIsReferenceType, 
IndirectionLevel);
+  while (const MemRegion *MR = S.getAsRegion()) {
+if (RegionOfInterest->isSubRegionOf(MR) && !isPointerToConst(T))

`R` was cool, that is our unspoken naming convention. What about 
`CallR`/`CallRegion` and possibly `CallSVal`? If I am right usually the 
`BugReport` object is named `BR` because of our regions.



Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:547
 
   /// \return Diagnostics piece for region not modified in the current 
function.
   std::shared_ptr

Update that comment?



Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:552
+ const MemRegion *MatchedRegion, StringRef FirstElement,
+ bool FirstIsReferenceType, unsigned IndirectionLevel) {
+// Optimistically suppress uninitialized value bugs that result

What about `tryToEmitNote()`? This 'or' condition is very uncommon for a 
function name. Also there is another `R` what could be `BR`.



Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:567
+  // other functions that have more paths within them, this suppression
+  // would still apply when we visit these inner functions.
+  if (N->getStackFrame()->getCFG()->size() > 3)

The Phabricator comment is better because it has a cool example. What about 
merging that into this one?



Comment at: clang/test/Analysis/no-store-suppression.cpp:3
+
+// expected-no-diagnostics
+

Could you inject a link for the diff or copy the information for further 
improvements why no diagnostic happen?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60107



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


[PATCH] D60279: [CUDA] Implemented _[bi]mma* builtins.

2019-04-04 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added reviewers: timshen, jlebar.
Herald added subscribers: llvm-commits, bixia, hiraditya, jholewinski.
Herald added a project: LLVM.

These builtins provide access to the new integer and
sub-integer variants of MMA (matrix multiply-accumulate) instructions
provided by CUDA-10.x on sm_75 (AKA Turing) GPUs.

Also added a feature for PTX 6.4. While Clang/LLVM does not generate
any PTX instructions that need it, we still need to pass it through to
ptxas in order to be able to compile code that uses the new 'mma'
instruction as inline assembly (e.g used by NVIDIA's CUTLASS library
https://github.com/NVIDIA/cutlass/blob/master/cutlass/arch/mma.h#L101)


https://reviews.llvm.org/D60279

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/CodeGen/builtins-nvptx-mma.cu
  clang/test/CodeGen/builtins-nvptx-mma.py
  llvm/lib/Target/NVPTX/NVPTX.td

Index: llvm/lib/Target/NVPTX/NVPTX.td
===
--- llvm/lib/Target/NVPTX/NVPTX.td
+++ llvm/lib/Target/NVPTX/NVPTX.td
@@ -75,6 +75,8 @@
  "Use PTX version 6.1">;
 def PTX63 : SubtargetFeature<"ptx63", "PTXVersion", "63",
  "Use PTX version 6.3">;
+def PTX64 : SubtargetFeature<"ptx64", "PTXVersion", "64",
+ "Use PTX version 6.4">;
 
 //===--===//
 // NVPTX supported processors.
Index: clang/test/CodeGen/builtins-nvptx-mma.py
===
--- /dev/null
+++ clang/test/CodeGen/builtins-nvptx-mma.py
@@ -0,0 +1,339 @@
+# This script generates all variants of wmma builtins, verifies that clang calls
+# correct LLVM instrinsics, and checks that availability of specific builtins is
+# constrained by the correct PTX version and the target GPU variant.
+
+# Dummy test run to avoid lit warnings.
+# RUN: echo "This is not a real test. It's a generator for builtins-nvpts-mma.cu" >/dev/null
+
+from __future__ import print_function
+
+import argparse
+from collections import defaultdict
+from itertools import product
+from string import Template
+
+class MMAFrag:
+  def __init__(self, geom, frag, ptx_elt_type):
+self.geom = geom
+self.frag = frag
+self.ptx_type = ptx_elt_type;
+
+  def __repr__(self):
+return "%s:%s:%s" % (self.geom, self.frag, self.ptx_type)
+
+class MMAOp:
+  def __init__(self, a, b, c, d):
+self.a = a
+self.b = b
+self.c = c
+self.d = d
+
+  def __repr__(self):
+return ("{A:%s, B:%s, C:%s, D:%s}" % (self.a, self.b, self.c, self.d ))
+
+def make_mma_ops(geoms, types_a, types_b, types_c, types_d):
+  ops = []
+  for geom, type_a, type_c in product( geoms,  types_a, types_c):
+for type_b, type_d in product(types_b if types_b else [type_a],
+  types_d if types_d else [type_c]):
+  ops.append(MMAOp(MMAFrag(geom, "a", type_a),
+   MMAFrag(geom, "b", type_b),
+   MMAFrag(geom, "c", type_c),
+   MMAFrag(geom, "d", type_d)))
+  return ops
+
+def make_ldst_ops(geoms, frags, types):
+  return [MMAFrag(geom, frag, ptx_type) for (geom, frag, ptx_type)
+  in product(geoms, frags, types)]
+
+def get_mma_ops():
+  return (make_mma_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+   ["f16"], [], ["f16", "f32"], ["f16", "f32"]) +
+  make_mma_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+   ["s8", "u8"], [], ["s32"], []) +
+  make_mma_ops(["m8n8k32"],
+   ["s4", "u4"], [], ["s32"], []) +
+  make_mma_ops(["m8n8k128"],
+   ["b1"], [], ["s32"], []))
+def get_ldst_ops():
+  return (make_ldst_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+["a", "b"], ["f16", "u8", "s8"]) +
+  make_ldst_ops(["m16n16k16", "m32n8k16", "m8n32k16"],
+["c", "d"], ["f16", "f32", "s32"]) +
+  make_ldst_ops(["m8n8k32"], ["a", "b"], ["s4","u4"]) +
+  make_ldst_ops(["m8n8k128"], ["a", "b"], ["b1"]) +
+  make_ldst_ops(["m8n8k32", "m8n8k128"],  ["c", "d"], ["s32"]))
+
+def is_geom_supported(geom):
+  # geometries for FP and ints.
+  if geom in ["m8n32k16", "m32n8k16"]:
+return ptx_version >= 61
+  # geometries for sub-ints.
+  if geom in ["m8n8k32", "m8n8k128"]:
+return ptx_version >= 63 and gpu_arch >= 75
+  if geom == "m16n16k16":
+return ptx_version >= 60
+  assert(False) # Unexpected geometry.
+
+def is_type_supported(ptx_type):
+  if ptx_type in ["s8", "u8", "s32"]:
+return ptx_version >= 63 and gpu_arch >= 72
+  if ptx_type in ["s4", "u4", "b1"]:
+return ptx_version >= 63 and gpu_arch >= 75
+  return ptx_version >= 60 and gpu_arch >= 70
+
+def is_mma_variant_supported(op, 

[PATCH] D60236: add periods

2019-04-04 Thread Amy Huang via Phabricator via cfe-commits
akhuang abandoned this revision.
akhuang added a comment.

test commit with incorrect diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60236



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


[PATCH] D60238: Verify that Android targets generate DWARF 4 by default.

2019-04-04 Thread Stephen Hines via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL357713: Verify that Android targets generate DWARF 4 by 
default. (authored by srhines, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60238?vs=193621=193753#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60238

Files:
  cfe/trunk/test/Driver/debug-options.c


Index: cfe/trunk/test/Driver/debug-options.c
===
--- cfe/trunk/test/Driver/debug-options.c
+++ cfe/trunk/test/Driver/debug-options.c
@@ -17,9 +17,14 @@
 // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
 // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
+
+// Android.
+// Android should always generate DWARF4.
+// RUN: %clang -### -c -g %s -target arm-linux-androideabi 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_DWARF4 %s
 
 // Darwin.
-// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF2 \
@@ -272,6 +277,7 @@
 //
 // G_STANDALONE: "-cc1"
 // G_STANDALONE: "-debug-info-kind=standalone"
+// G_DWARF2: "-dwarf-version=2"
 // G_DWARF4: "-dwarf-version=4"
 //
 // G_GDB:  "-debugger-tuning=gdb"


Index: cfe/trunk/test/Driver/debug-options.c
===
--- cfe/trunk/test/Driver/debug-options.c
+++ cfe/trunk/test/Driver/debug-options.c
@@ -17,9 +17,14 @@
 // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
 // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
+
+// Android.
+// Android should always generate DWARF4.
+// RUN: %clang -### -c -g %s -target arm-linux-androideabi 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_DWARF4 %s
 
 // Darwin.
-// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF2 \
@@ -272,6 +277,7 @@
 //
 // G_STANDALONE: "-cc1"
 // G_STANDALONE: "-debug-info-kind=standalone"
+// G_DWARF2: "-dwarf-version=2"
 // G_DWARF4: "-dwarf-version=4"
 //
 // G_GDB:  "-debugger-tuning=gdb"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r357713 - Verify that Android targets generate DWARF 4 by default.

2019-04-04 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Thu Apr  4 11:17:46 2019
New Revision: 357713

URL: http://llvm.org/viewvc/llvm-project?rev=357713=rev
Log:
Verify that Android targets generate DWARF 4 by default.

Summary:
In the future, Android releases will support DWARF 5, but we need to
ensure that older targets only have DWARF 4 generated for them. This
patch inserts that verification for all Android releases now. The patch
also fixes 2 minor mistakes (a mistakenly moved RUN line, and the
missing G_DWARF2 check label).

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: chh, pirama, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=357713=357712=357713=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Thu Apr  4 11:17:46 2019
@@ -17,9 +17,14 @@
 // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
 // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
+
+// Android.
+// Android should always generate DWARF4.
+// RUN: %clang -### -c -g %s -target arm-linux-androideabi 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_DWARF4 %s
 
 // Darwin.
-// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF2 \
@@ -272,6 +277,7 @@
 //
 // G_STANDALONE: "-cc1"
 // G_STANDALONE: "-debug-info-kind=standalone"
+// G_DWARF2: "-dwarf-version=2"
 // G_DWARF4: "-dwarf-version=4"
 //
 // G_GDB:  "-debugger-tuning=gdb"


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


[PATCH] D60237: [MS] Add metadata for __declspec(allocator)

2019-04-04 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 193751.
akhuang marked 2 inline comments as done.

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

https://reviews.llvm.org/D60237

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/debug-info-codeview-heapallocsite.c

Index: clang/test/CodeGen/debug-info-codeview-heapallocsite.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-codeview-heapallocsite.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -debug-info-kind=limited -gcodeview -fdeclspec -S -emit-llvm < %s | FileCheck %s
+
+char buf[1024];
+__declspec(allocator) void *myalloc(int s) {
+  void *p = [0];
+  return p;
+}
+
+void call_alloc() {
+  char *p = (char*)myalloc(sizeof(char));
+}
+
+// CHECK-LABEL: define {{.*}}void @call_alloc
+// CHECK: call i8* @myalloc(i32 1){{.*}} !heapallocsite [[DBG_F1:!.*]]
+// CHECK: [[DBG_F1:!.*]] = !{}
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -476,6 +476,10 @@
   /// Emit standalone debug info for a type.
   llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);
 
+  /// Add heapallocsite metadata for MSAllocator calls.
+  void addHeapAllocSiteMetadata(llvm::Instruction *CallSite, QualType Ty,
+SourceLocation Loc);
+
   void completeType(const EnumDecl *ED);
   void completeType(const RecordDecl *RD);
   void completeRequiredType(const RecordDecl *RD);
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1959,6 +1959,22 @@
   return T;
 }
 
+void CGDebugInfo::addHeapAllocSiteMetadata(llvm::Instruction *CI,
+   QualType D,
+   SourceLocation Loc) {
+  // FIXME: use the type that return value is cast to
+  llvm::MDNode *node;
+  if (D.getTypePtr()->isVoidPointerType()) {
+node = llvm::MDNode::get(CGM.getLLVMContext(), None);
+  } else {
+QualType PointeeTy = D.getTypePtr()->getPointeeType();
+node = getOrCreateType(PointeeTy, getOrCreateFile(Loc));
+  }
+
+  CI->setMetadata("heapallocsite", node);
+}
+
+
 void CGDebugInfo::completeType(const EnumDecl *ED) {
   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
 return;
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3800,6 +3800,8 @@
 
   llvm::FunctionType *IRFuncTy = getTypes().GetFunctionType(CallInfo);
 
+  const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
+
 #ifndef NDEBUG
   if (!(CallInfo.isVariadic() && CallInfo.getArgStruct())) {
 // For an inalloca varargs function, we don't expect CallInfo to match the
@@ -4288,11 +4290,7 @@
   // Apply always_inline to all calls within flatten functions.
   // FIXME: should this really take priority over __try, below?
   if (CurCodeDecl && CurCodeDecl->hasAttr() &&
-  !(Callee.getAbstractInfo().getCalleeDecl().getDecl() &&
-Callee.getAbstractInfo()
-.getCalleeDecl()
-.getDecl()
-->hasAttr())) {
+  !(TargetDecl && TargetDecl->hasAttr())) {
 Attrs =
 Attrs.addAttribute(getLLVMContext(), llvm::AttributeList::FunctionIndex,
llvm::Attribute::AlwaysInline);
@@ -4376,11 +4374,16 @@
 
   // Suppress tail calls if requested.
   if (llvm::CallInst *Call = dyn_cast(CI)) {
-const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
 if (TargetDecl && TargetDecl->hasAttr())
   Call->setTailCallKind(llvm::CallInst::TCK_NoTail);
   }
 
+  // Add metadata for calls to MSAllocator functions
+  if (!DisableDebugInfo) {
+if (TargetDecl && TargetDecl->hasAttr())
+  getDebugInfo()->addHeapAllocSiteMetadata(CI, RetTy, Loc);
+  }
+
   // 4. Finish the call.
 
   // If the call doesn't return, finish the basic block and clear the
@@ -4537,7 +4540,6 @@
   } ();
 
   // Emit the assume_aligned check on the return value.
-  const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
   if (Ret.isScalar() && TargetDecl) {
 if (const auto *AA = TargetDecl->getAttr()) {
   llvm::Value *OffsetValue = nullptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60237: [MS] Add metadata for __declspec(allocator)

2019-04-04 Thread Amy Huang via Phabricator via cfe-commits
akhuang marked an inline comment as done.
akhuang added inline comments.



Comment at: clang/lib/CodeGen/CGAtomic.cpp:1691
   } else {
-// Build new lvalue for temp address
+// Build new lvalue for temp address.
 Address Ptr = Atomics.materializeRValue(OldRVal);

rnk wrote:
> I don't have an issue with these changes if you want to make them, but they 
> should be committed separately.
Whoops, these were supposed to be a separate test commit but I guess they ended 
up in here too. 



Comment at: clang/lib/CodeGen/CGCall.cpp:4384-4385
+if (TargetDecl && TargetDecl->hasAttr())
+  CI->setMetadata("heapallocsite", getDebugInfo()->
+   getMSAllocatorMetadata(RetTy, Loc));
+  }

rnk wrote:
> I think we should make CGDebugInfo responsible for calling setMetadata. In 
> some sense, "heapallocsite" metadata is debug info, so it makes sense that it 
> would be documented there. Also, if there are other places where we need to 
> add this metadata, we won't have to duplicate this string literal.
> 
> So, CGDebugInfo should have some new method 
> `addHeapAllocSiteMetadata(Instruction *CallSite, QualType Ty)`, and that can 
> call the private getOrCreateType method. Sound good?
Makes sense.


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

https://reviews.llvm.org/D60237



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


r357712 - [OPENMP]Add codegen for linear vars with allocate clause, NFC.

2019-04-04 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Apr  4 11:06:53 2019
New Revision: 357712

URL: http://llvm.org/viewvc/llvm-project?rev=357712=rev
Log:
[OPENMP]Add codegen for linear vars with allocate clause, NFC.

Added test for the linear variables with the allocate clause.

Modified:
cfe/trunk/test/OpenMP/for_linear_codegen.cpp

Modified: cfe/trunk/test/OpenMP/for_linear_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_linear_codegen.cpp?rev=357712=357711=357712=diff
==
--- cfe/trunk/test/OpenMP/for_linear_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_linear_codegen.cpp Thu Apr  4 11:06:53 2019
@@ -14,6 +14,16 @@
 #ifndef HEADER
 #define HEADER
 
+typedef void **omp_allocator_handle_t;
+extern const omp_allocator_handle_t omp_default_mem_alloc;
+extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
+extern const omp_allocator_handle_t omp_const_mem_alloc;
+extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
+extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
+extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
+extern const omp_allocator_handle_t omp_pteam_mem_alloc;
+extern const omp_allocator_handle_t omp_thread_mem_alloc;
+
 template 
 struct S {
   T f;
@@ -344,7 +354,7 @@ int main() {
   float *pvar = 
   long long lvar = 0;
 #pragma omp parallel
-#pragma omp for linear(pvar, lvar : 3)
+#pragma omp for linear(pvar, lvar : 3) allocate(omp_low_lat_mem_alloc: lvar)
   for (int i = 0; i < 2; ++i) {
 pvar += 3, lvar += 3;
   }
@@ -370,7 +380,6 @@ int main() {
 // CHECK: alloca i{{[0-9]+}},
 // CHECK: alloca i{{[0-9]+}},
 // CHECK: [[PVAR_PRIV:%.+]] = alloca float*,
-// CHECK: [[LVAR_PRIV:%.+]] = alloca i64,
 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_REF:%.+]]
 
 // Check for default initialization.
@@ -380,7 +389,10 @@ int main() {
 // CHECK: store float* [[PVAR_VAL]], float** [[PVAR_START]],
 // CHECK: [[LVAR_VAL:%.+]] = load i64, i64* [[LVAR_REF]],
 // CHECK: store i64 [[LVAR_VAL]], i64* [[LVAR_START]],
-// CHECK: call {{.+}} @__kmpc_for_static_init_4(%{{.+}}* @{{.+}}, i32 
[[GTID:%.+]], i32 34, i32* [[IS_LAST_ADDR:%.+]], i32* %{{.+}}, i32* %{{.+}}, 
i32* %{{.+}}, i32 1, i32 1)
+// CHECK: [[ALLOCATOR:%.+]] = load i8**, i8*** @omp_low_lat_mem_alloc,
+// CHECK: [[LVAR_VOID_PTR:%.+]] = call i8* @__kmpc_alloc(i32 [[GTID:%.+]], i64 
8, i8** [[ALLOCATOR]])
+// CHECK: [[LVAR_PRIV:%.+]] = bitcast i8* [[LVAR_VOID_PTR]] to i64*
+// CHECK: call {{.+}} @__kmpc_for_static_init_4(%{{.+}}* @{{.+}}, i32 
[[GTID]], i32 34, i32* [[IS_LAST_ADDR:%.+]], i32* %{{.+}}, i32* %{{.+}}, i32* 
%{{.+}}, i32 1, i32 1)
 // CHECK: [[PVAR_VAL:%.+]] = load float*, float** [[PVAR_START]],
 // CHECK: [[CNT:%.+]] = load i32, i32*
 // CHECK: [[MUL:%.+]] = mul nsw i32 [[CNT]], 3
@@ -400,6 +412,7 @@ int main() {
 // CHECK: [[ADD:%.+]] = add nsw i64 [[LVAR_VAL]], 3
 // CHECK: store i64 [[ADD]], i64* [[LVAR_PRIV]],
 // CHECK: call void @__kmpc_for_static_fini(%{{.+}}* @{{.+}}, i32 %{{.+}})
+// CHECK: call void @__kmpc_free(i32 [[GTID]], i8* [[LVAR_VOID_PTR]], i8** 
[[ALLOCATOR]])
 // CHECK: call void @__kmpc_barrier(%{{.+}}* [[IMPLICIT_BARRIER_LOC]], 
i{{[0-9]+}} [[GTID]])
 // CHECK: ret void
 


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


[libunwind] r357711 - Move the alias definition of unw_getcontext to within !defined(__USING_SJLJ_EXCEPTIONS__)

2019-04-04 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Thu Apr  4 10:50:14 2019
New Revision: 357711

URL: http://llvm.org/viewvc/llvm-project?rev=357711=rev
Log:
Move the alias definition of unw_getcontext to within 
!defined(__USING_SJLJ_EXCEPTIONS__)

For builds with SJLJ, there is no __unw_getcontext symbol. On Windows,
the weak alias macro also expands to a dllexport directive, which fails
if the symbol doesn't exist.

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

Modified:
libunwind/trunk/src/UnwindRegistersSave.S

Modified: libunwind/trunk/src/UnwindRegistersSave.S
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindRegistersSave.S?rev=357711=357710=357711=diff
==
--- libunwind/trunk/src/UnwindRegistersSave.S (original)
+++ libunwind/trunk/src/UnwindRegistersSave.S Thu Apr  4 10:50:14 2019
@@ -972,8 +972,9 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getconte
   jmp %o7
clr %o0   // return UNW_ESUCCESS
 #endif
-#endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */
 
   WEAK_ALIAS(__unw_getcontext, unw_getcontext)
 
+#endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */
+
 NO_EXEC_STACK_DIRECTIVE


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


[PATCH] D60233: [clang-scan-deps] initial outline of the tool that runs preprocessor to find dependencies over a JSON compilation database

2019-04-04 Thread Matthew Voss via Phabricator via cfe-commits
ormris added inline comments.



Comment at: test/ClangScanDeps/regular_cdb.cpp:14
+// CHECK: regular_cdb.cpp
+// CHECK-NEXT: Inputs/header.h

Quick drive-by nit: This test won't work under Windows due to the path 
separator. To account for both platforms, you could use a pattern like 
"{{/|\\}}".


Repository:
  rC Clang

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

https://reviews.llvm.org/D60233



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


[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-04 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 193750.
ymandel added a comment.

Rebasing to parent D60269  so that diffs show 
correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59376

Files:
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Refactoring/Transformer.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -0,0 +1,389 @@
+//===- unittest/Tooling/TransformerTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Refactoring/Transformer.h"
+
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tooling {
+namespace {
+using ast_matchers::anyOf;
+using ast_matchers::argumentCountIs;
+using ast_matchers::callee;
+using ast_matchers::callExpr;
+using ast_matchers::cxxMemberCallExpr;
+using ast_matchers::cxxMethodDecl;
+using ast_matchers::cxxRecordDecl;
+using ast_matchers::declRefExpr;
+using ast_matchers::expr;
+using ast_matchers::functionDecl;
+using ast_matchers::hasAnyName;
+using ast_matchers::hasArgument;
+using ast_matchers::hasDeclaration;
+using ast_matchers::hasElse;
+using ast_matchers::hasName;
+using ast_matchers::hasType;
+using ast_matchers::ifStmt;
+using ast_matchers::member;
+using ast_matchers::memberExpr;
+using ast_matchers::namedDecl;
+using ast_matchers::on;
+using ast_matchers::pointsTo;
+using ast_matchers::to;
+using ast_matchers::unless;
+
+using llvm::StringRef;
+
+constexpr char KHeaderContents[] = R"cc(
+  struct string {
+string(const char*);
+char* c_str();
+int size();
+  };
+  int strlen(const char*);
+
+  namespace proto {
+  struct PCFProto {
+int foo();
+  };
+  struct ProtoCommandLineFlag : PCFProto {
+PCFProto& GetProto();
+  };
+  }  // namespace proto
+)cc";
+
+static ast_matchers::internal::Matcher
+isOrPointsTo(const clang::ast_matchers::DeclarationMatcher ) {
+  return anyOf(hasDeclaration(TypeMatcher), pointsTo(TypeMatcher));
+}
+
+static std::string format(StringRef Code) {
+  const std::vector Ranges(1, Range(0, Code.size()));
+  auto Style = format::getLLVMStyle();
+  const auto Replacements = format::reformat(Style, Code, Ranges);
+  auto Formatted = applyAllReplacements(Code, Replacements);
+  if (!Formatted) {
+ADD_FAILURE() << "Could not format code: "
+  << llvm::toString(Formatted.takeError());
+return std::string();
+  }
+  return *Formatted;
+}
+
+static void compareSnippets(StringRef Expected,
+ const llvm::Optional ) {
+  ASSERT_TRUE(MaybeActual) << "Rewrite failed. Expecting: " << Expected;
+  auto Actual = *MaybeActual;
+  std::string HL = "#include \"header.h\"\n";
+  auto I = Actual.find(HL);
+  if (I != std::string::npos)
+Actual.erase(I, HL.size());
+  EXPECT_EQ(format(Expected), format(Actual));
+}
+
+// FIXME: consider separating this class into its own file(s).
+class ClangRefactoringTestBase : public testing::Test {
+protected:
+  void appendToHeader(StringRef S) { FileContents[0].second += S; }
+
+  void addFile(StringRef Filename, StringRef Content) {
+FileContents.emplace_back(Filename, Content);
+  }
+
+  llvm::Optional rewrite(StringRef Input) {
+std::string Code = ("#include \"header.h\"\n" + Input).str();
+auto Factory = newFrontendActionFactory();
+if (!runToolOnCodeWithArgs(
+Factory->create(), Code, std::vector(), "input.cc",
+"clang-tool", std::make_shared(),
+FileContents)) {
+  return None;
+}
+auto ChangedCodeOrErr =
+applyAtomicChanges("input.cc", Code, Changes, ApplyChangesSpec());
+if (auto Err = ChangedCodeOrErr.takeError()) {
+  llvm::errs() << "Change failed: " << llvm::toString(std::move(Err))
+   << "\n";
+  return None;
+}
+return *ChangedCodeOrErr;
+  }
+
+  void testRule(RewriteRule Rule, StringRef Input, StringRef Expected) {
+Transformer T(std::move(Rule),
+  [this](const AtomicChange ) { Changes.push_back(C); });
+T.registerMatchers();
+compareSnippets(Expected, rewrite(Input));
+  }
+
+  clang::ast_matchers::MatchFinder MatchFinder;
+  AtomicChanges Changes;
+
+private:
+  FileContentMappings FileContents = {{"header.h", ""}};
+};
+
+class TransformerTest : public 

[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-04 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 193748.
ymandel added a comment.

Switch from using FixIt to SourceCode, as solution to circular dependency 
problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59376

Files:
  clang/include/clang/Tooling/FixIt.h
  clang/include/clang/Tooling/Refactoring/SourceCode.h
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/lib/Tooling/FixIt.cpp
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Refactoring/SourceCode.cpp
  clang/lib/Tooling/Refactoring/Transformer.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/FixItTest.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -0,0 +1,389 @@
+//===- unittest/Tooling/TransformerTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Refactoring/Transformer.h"
+
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tooling {
+namespace {
+using ast_matchers::anyOf;
+using ast_matchers::argumentCountIs;
+using ast_matchers::callee;
+using ast_matchers::callExpr;
+using ast_matchers::cxxMemberCallExpr;
+using ast_matchers::cxxMethodDecl;
+using ast_matchers::cxxRecordDecl;
+using ast_matchers::declRefExpr;
+using ast_matchers::expr;
+using ast_matchers::functionDecl;
+using ast_matchers::hasAnyName;
+using ast_matchers::hasArgument;
+using ast_matchers::hasDeclaration;
+using ast_matchers::hasElse;
+using ast_matchers::hasName;
+using ast_matchers::hasType;
+using ast_matchers::ifStmt;
+using ast_matchers::member;
+using ast_matchers::memberExpr;
+using ast_matchers::namedDecl;
+using ast_matchers::on;
+using ast_matchers::pointsTo;
+using ast_matchers::to;
+using ast_matchers::unless;
+
+using llvm::StringRef;
+
+constexpr char KHeaderContents[] = R"cc(
+  struct string {
+string(const char*);
+char* c_str();
+int size();
+  };
+  int strlen(const char*);
+
+  namespace proto {
+  struct PCFProto {
+int foo();
+  };
+  struct ProtoCommandLineFlag : PCFProto {
+PCFProto& GetProto();
+  };
+  }  // namespace proto
+)cc";
+
+static ast_matchers::internal::Matcher
+isOrPointsTo(const clang::ast_matchers::DeclarationMatcher ) {
+  return anyOf(hasDeclaration(TypeMatcher), pointsTo(TypeMatcher));
+}
+
+static std::string format(StringRef Code) {
+  const std::vector Ranges(1, Range(0, Code.size()));
+  auto Style = format::getLLVMStyle();
+  const auto Replacements = format::reformat(Style, Code, Ranges);
+  auto Formatted = applyAllReplacements(Code, Replacements);
+  if (!Formatted) {
+ADD_FAILURE() << "Could not format code: "
+  << llvm::toString(Formatted.takeError());
+return std::string();
+  }
+  return *Formatted;
+}
+
+static void compareSnippets(StringRef Expected,
+ const llvm::Optional ) {
+  ASSERT_TRUE(MaybeActual) << "Rewrite failed. Expecting: " << Expected;
+  auto Actual = *MaybeActual;
+  std::string HL = "#include \"header.h\"\n";
+  auto I = Actual.find(HL);
+  if (I != std::string::npos)
+Actual.erase(I, HL.size());
+  EXPECT_EQ(format(Expected), format(Actual));
+}
+
+// FIXME: consider separating this class into its own file(s).
+class ClangRefactoringTestBase : public testing::Test {
+protected:
+  void appendToHeader(StringRef S) { FileContents[0].second += S; }
+
+  void addFile(StringRef Filename, StringRef Content) {
+FileContents.emplace_back(Filename, Content);
+  }
+
+  llvm::Optional rewrite(StringRef Input) {
+std::string Code = ("#include \"header.h\"\n" + Input).str();
+auto Factory = newFrontendActionFactory();
+if (!runToolOnCodeWithArgs(
+Factory->create(), Code, std::vector(), "input.cc",
+"clang-tool", std::make_shared(),
+FileContents)) {
+  return None;
+}
+auto ChangedCodeOrErr =
+applyAtomicChanges("input.cc", Code, Changes, ApplyChangesSpec());
+if (auto Err = ChangedCodeOrErr.takeError()) {
+  llvm::errs() << "Change failed: " << llvm::toString(std::move(Err))
+   << "\n";
+  return None;
+}
+return *ChangedCodeOrErr;
+  }
+
+  void testRule(RewriteRule Rule, StringRef Input, StringRef Expected) {
+Transformer T(std::move(Rule),
+  [this](const AtomicChange ) { Changes.push_back(C); });
+T.registerMatchers();
+

r357708 - [OPENMP]Fix lookup of the user-defined reductions in C.

2019-04-04 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Apr  4 10:28:22 2019
New Revision: 357708

URL: http://llvm.org/viewvc/llvm-project?rev=357708=rev
Log:
[OPENMP]Fix lookup of the user-defined reductions in C.

Fixed the regression of the lookup of user-defined reductions for C.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/declare_reduction_ast_print.c

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=357708=357707=357708=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Apr  4 10:28:22 2019
@@ -11269,17 +11269,18 @@ buildDeclareReductionRef(Sema ,
 }
   }
   // Perform ADL.
-  if (SemaRef.getLangOpts().CPlusPlus) {
+  if (SemaRef.getLangOpts().CPlusPlus)
 argumentDependentLookup(SemaRef, ReductionId, Loc, Ty, Lookups);
-if (auto *VD = filterLookupForUDReductionAndMapper(
-Lookups, [, Ty](ValueDecl *D) -> ValueDecl * {
-  if (!D->isInvalidDecl() &&
-  SemaRef.Context.hasSameType(D->getType(), Ty))
-return D;
-  return nullptr;
-}))
-  return SemaRef.BuildDeclRefExpr(VD, VD->getType().getNonReferenceType(),
-  VK_LValue, Loc);
+  if (auto *VD = filterLookupForUDReductionAndMapper(
+  Lookups, [, Ty](ValueDecl *D) -> ValueDecl * {
+if (!D->isInvalidDecl() &&
+SemaRef.Context.hasSameType(D->getType(), Ty))
+  return D;
+return nullptr;
+  }))
+return SemaRef.BuildDeclRefExpr(VD, VD->getType().getNonReferenceType(),
+VK_LValue, Loc);
+  if (SemaRef.getLangOpts().CPlusPlus) {
 if (auto *VD = filterLookupForUDReductionAndMapper(
 Lookups, [, Ty, Loc](ValueDecl *D) -> ValueDecl * {
   if (!D->isInvalidDecl() &&
@@ -11893,7 +11894,8 @@ static bool actOnOMPReductionKindClause(
   S.ActOnUninitializedDecl(RHSVD);
 if (RHSVD->isInvalidDecl())
   continue;
-if (!RHSVD->hasInit() && DeclareReductionRef.isUnset()) {
+if (!RHSVD->hasInit() &&
+(DeclareReductionRef.isUnset() || !S.LangOpts.CPlusPlus)) {
   S.Diag(ELoc, diag::err_omp_reduction_id_not_compatible)
   << Type << ReductionIdRange;
   bool IsDecl = !VD || VD->isThisDeclarationADefinition(Context) ==

Modified: cfe/trunk/test/OpenMP/declare_reduction_ast_print.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_reduction_ast_print.c?rev=357708=357707=357708=diff
==
--- cfe/trunk/test/OpenMP/declare_reduction_ast_print.c (original)
+++ cfe/trunk/test/OpenMP/declare_reduction_ast_print.c Thu Apr  4 10:28:22 2019
@@ -43,4 +43,17 @@ int main() {
 }
 // CHECK: }
 
+#pragma omp declare reduction(mymin:int
\
+  : omp_out = omp_out > omp_in ? omp_in : omp_out) 
\
+initializer(omp_priv = 2147483647)
+
+int foo(int argc, char **argv) {
+  int x;
+#pragma omp parallel for reduction(mymin : x)
+  for (int i = 0; i < 1000; i++)
+;
+  return 0;
+}
+
+// CHECK: #pragma omp parallel for reduction(mymin: x)
 #endif


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


[PATCH] D60269: [LibTooling] Add "SourceCode" library for functions relating to source-code manipulation.

2019-04-04 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 193741.
ymandel added a comment.

Various tweaks to get tests compiling/passing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60269

Files:
  clang/include/clang/Tooling/FixIt.h
  clang/include/clang/Tooling/Refactoring/SourceCode.h
  clang/lib/Tooling/FixIt.cpp
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Refactoring/SourceCode.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/FixItTest.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp

Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -0,0 +1,101 @@
+//===- unittest/Tooling/SourceCodeTest.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Tooling/Refactoring/SourceCode.h"
+
+using namespace clang;
+
+using tooling::getText;
+using tooling::getExtendedText;
+
+namespace {
+
+struct CallsVisitor : TestVisitor {
+  bool VisitCallExpr(CallExpr *Expr) {
+OnCall(Expr, Context);
+return true;
+  }
+
+  std::function OnCall;
+};
+
+std::string LocationToString(SourceLocation Loc, ASTContext *Context) {
+  return Loc.printToString(Context->getSourceManager());
+}
+
+TEST(SourceCodeTest, getText) {
+  CallsVisitor Visitor;
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("foo(x, y)", getText(*CE, *Context));
+  };
+  Visitor.runOver("void foo(int x, int y) { foo(x, y); }");
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("APPLY(foo, x, y)", getText(*CE, *Context));
+  };
+  Visitor.runOver("#define APPLY(f, x, y) f(x, y)\n"
+  "void foo(int x, int y) { APPLY(foo, x, y); }");
+}
+
+TEST(SourceCodeTest, getTextWithMacro) {
+  CallsVisitor Visitor;
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("F OO", getText(*CE, *Context));
+Expr *P0 = CE->getArg(0);
+Expr *P1 = CE->getArg(1);
+EXPECT_EQ("", getText(*P0, *Context));
+EXPECT_EQ("", getText(*P1, *Context));
+  };
+  Visitor.runOver("#define F foo(\n"
+  "#define OO x, y)\n"
+  "void foo(int x, int y) { F OO ; }");
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("", getText(*CE, *Context));
+Expr *P0 = CE->getArg(0);
+Expr *P1 = CE->getArg(1);
+EXPECT_EQ("x", getText(*P0, *Context));
+EXPECT_EQ("y", getText(*P1, *Context));
+  };
+  Visitor.runOver("#define FOO(x, y) (void)x; (void)y; foo(x, y);\n"
+  "void foo(int x, int y) { FOO(x,y) }");
+}
+
+TEST(SourceCodeTest, getExtendedText) {
+  CallsVisitor Visitor;
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("foo(x, y);",
+  getExtendedText(*CE, tok::TokenKind::semi, *Context));
+
+Expr *P0 = CE->getArg(0);
+Expr *P1 = CE->getArg(1);
+EXPECT_EQ("x", getExtendedText(*P0, tok::TokenKind::semi, *Context));
+EXPECT_EQ("x,", getExtendedText(*P0, tok::TokenKind::comma, *Context));
+EXPECT_EQ("y", getExtendedText(*P1, tok::TokenKind::semi, *Context));
+  };
+  Visitor.runOver("void foo(int x, int y) { foo(x, y); }");
+  Visitor.runOver("void foo(int x, int y) { if (true) foo(x, y); }");
+  Visitor.runOver("int foo(int x, int y) { if (true) return 3 + foo(x, y); }");
+  Visitor.runOver("void foo(int x, int y) { for (foo(x, y);;) ++x; }");
+  Visitor.runOver(
+  "bool foo(int x, int y) { for (;foo(x, y);) x = 1; return true; }");
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("foo()", getExtendedText(*CE, tok::TokenKind::semi, *Context));
+  };
+  Visitor.runOver("bool foo() { if (foo()) return true; return false; }");
+  Visitor.runOver("void foo() { int x; for (;; foo()) ++x; }");
+  Visitor.runOver("int foo() { return foo() + 3; }");
+}
+
+} // end anonymous namespace
Index: clang/unittests/Tooling/FixItTest.cpp
===
--- clang/unittests/Tooling/FixItTest.cpp
+++ clang/unittests/Tooling/FixItTest.cpp
@@ -13,7 +13,6 @@
 using namespace clang;
 
 using tooling::fixit::getText;
-using tooling::fixit::getExtendedText;
 using tooling::fixit::createRemoval;
 using tooling::fixit::createReplacement;
 
@@ -78,34 +77,6 @@
   "void foo(int x, int y) { FOO(x,y) }");
 }
 
-TEST(FixItTest, getExtendedText) {
-  CallsVisitor Visitor;
-
-  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
-EXPECT_EQ("foo(x, y);",
-  

[PATCH] D60269: [LibTooling] Add "SourceCode" library for functions relating to source-code manipulation.

2019-04-04 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 193736.
ymandel added a comment.
Herald added a subscriber: mgorny.

Update CMakeLists.txt and rename (misnamed) test file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60269

Files:
  clang/include/clang/Tooling/FixIt.h
  clang/include/clang/Tooling/Refactoring/SourceCode.h
  clang/lib/Tooling/FixIt.cpp
  clang/lib/Tooling/Refactoring/SourceCode.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/FixItTest.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp

Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -0,0 +1,101 @@
+//===- unittest/Tooling/SourceCodeTest.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Tooling/Refactoring/SourceCode.h"
+
+using namespace clang;
+
+using tooling::getText;
+using tooling::getExtendedText;
+
+namespace {
+
+struct CallsVisitor : TestVisitor {
+  bool VisitCallExpr(CallExpr *Expr) {
+OnCall(Expr, Context);
+return true;
+  }
+
+  std::function OnCall;
+};
+
+std::string LocationToString(SourceLocation Loc, ASTContext *Context) {
+  return Loc.printToString(Context->getSourceManager());
+}
+
+TEST(SourceCodeTest, getText) {
+  CallsVisitor Visitor;
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("foo(x, y)", getText(*CE, *Context));
+  };
+  Visitor.runOver("void foo(int x, int y) { foo(x, y); }");
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("APPLY(foo, x, y)", getText(*CE, *Context));
+  };
+  Visitor.runOver("#define APPLY(f, x, y) f(x, y)\n"
+  "void foo(int x, int y) { APPLY(foo, x, y); }");
+}
+
+TEST(SourceCodeTest, getTextWithMacro) {
+  CallsVisitor Visitor;
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("F OO", getText(*CE, *Context));
+Expr *P0 = CE->getArg(0);
+Expr *P1 = CE->getArg(1);
+EXPECT_EQ("", getText(*P0, *Context));
+EXPECT_EQ("", getText(*P1, *Context));
+  };
+  Visitor.runOver("#define F foo(\n"
+  "#define OO x, y)\n"
+  "void foo(int x, int y) { F OO ; }");
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("", getText(*CE, *Context));
+Expr *P0 = CE->getArg(0);
+Expr *P1 = CE->getArg(1);
+EXPECT_EQ("x", getText(*P0, *Context));
+EXPECT_EQ("y", getText(*P1, *Context));
+  };
+  Visitor.runOver("#define FOO(x, y) (void)x; (void)y; foo(x, y);\n"
+  "void foo(int x, int y) { FOO(x,y) }");
+}
+
+TEST(SourceCodeTest, getExtendedText) {
+  CallsVisitor Visitor;
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("foo(x, y);",
+  getExtendedText(*CE, tok::TokenKind::semi, *Context));
+
+Expr *P0 = CE->getArg(0);
+Expr *P1 = CE->getArg(1);
+EXPECT_EQ("x", getExtendedText(*P0, tok::TokenKind::semi, *Context));
+EXPECT_EQ("x,", getExtendedText(*P0, tok::TokenKind::comma, *Context));
+EXPECT_EQ("y", getExtendedText(*P1, tok::TokenKind::semi, *Context));
+  };
+  Visitor.runOver("void foo(int x, int y) { foo(x, y); }");
+  Visitor.runOver("void foo(int x, int y) { if (true) foo(x, y); }");
+  Visitor.runOver("int foo(int x, int y) { if (true) return 3 + foo(x, y); }");
+  Visitor.runOver("void foo(int x, int y) { for (foo(x, y);;) ++x; }");
+  Visitor.runOver(
+  "bool foo(int x, int y) { for (;foo(x, y);) x = 1; return true; }");
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("foo()", getExtendedText(*CE, tok::TokenKind::semi, *Context));
+  };
+  Visitor.runOver("bool foo() { if (foo()) return true; return false; }");
+  Visitor.runOver("void foo() { int x; for (;; foo()) ++x; }");
+  Visitor.runOver("int foo() { return foo() + 3; }");
+}
+
+} // end anonymous namespace
Index: clang/unittests/Tooling/FixItTest.cpp
===
--- clang/unittests/Tooling/FixItTest.cpp
+++ clang/unittests/Tooling/FixItTest.cpp
@@ -78,34 +78,6 @@
   "void foo(int x, int y) { FOO(x,y) }");
 }
 
-TEST(FixItTest, getExtendedText) {
-  CallsVisitor Visitor;
-
-  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
-EXPECT_EQ("foo(x, y);",
-  getExtendedText(*CE, tok::TokenKind::semi, *Context));
-
-Expr *P0 = CE->getArg(0);
-Expr *P1 = CE->getArg(1);
-EXPECT_EQ("x", getExtendedText(*P0, tok::TokenKind::semi, *Context));
-

[PATCH] D60269: [LibTooling] Add "SourceCode" library for functions relating to source-code manipulation.

2019-04-04 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 193735.
ymandel added a comment.

Add tests for SourceCode and remove corresponding tests from FixIt tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60269

Files:
  clang/include/clang/Tooling/FixIt.h
  clang/include/clang/Tooling/Refactoring/SourceCode.h
  clang/lib/Tooling/FixIt.cpp
  clang/lib/Tooling/Refactoring/SourceCode.cpp
  clang/unittests/Tooling/FixItTest.cpp
  clang/unittests/Tooling/SourceCodeText.cpp

Index: clang/unittests/Tooling/SourceCodeText.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/SourceCodeText.cpp
@@ -0,0 +1,101 @@
+//===- unittest/Tooling/SourceCodeTest.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Tooling/Refactoring/SourceCode.h"
+
+using namespace clang;
+
+using tooling::getText;
+using tooling::getExtendedText;
+
+namespace {
+
+struct CallsVisitor : TestVisitor {
+  bool VisitCallExpr(CallExpr *Expr) {
+OnCall(Expr, Context);
+return true;
+  }
+
+  std::function OnCall;
+};
+
+std::string LocationToString(SourceLocation Loc, ASTContext *Context) {
+  return Loc.printToString(Context->getSourceManager());
+}
+
+TEST(SourceCodeTest, getText) {
+  CallsVisitor Visitor;
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("foo(x, y)", getText(*CE, *Context));
+  };
+  Visitor.runOver("void foo(int x, int y) { foo(x, y); }");
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("APPLY(foo, x, y)", getText(*CE, *Context));
+  };
+  Visitor.runOver("#define APPLY(f, x, y) f(x, y)\n"
+  "void foo(int x, int y) { APPLY(foo, x, y); }");
+}
+
+TEST(SourceCodeTest, getTextWithMacro) {
+  CallsVisitor Visitor;
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("F OO", getText(*CE, *Context));
+Expr *P0 = CE->getArg(0);
+Expr *P1 = CE->getArg(1);
+EXPECT_EQ("", getText(*P0, *Context));
+EXPECT_EQ("", getText(*P1, *Context));
+  };
+  Visitor.runOver("#define F foo(\n"
+  "#define OO x, y)\n"
+  "void foo(int x, int y) { F OO ; }");
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("", getText(*CE, *Context));
+Expr *P0 = CE->getArg(0);
+Expr *P1 = CE->getArg(1);
+EXPECT_EQ("x", getText(*P0, *Context));
+EXPECT_EQ("y", getText(*P1, *Context));
+  };
+  Visitor.runOver("#define FOO(x, y) (void)x; (void)y; foo(x, y);\n"
+  "void foo(int x, int y) { FOO(x,y) }");
+}
+
+TEST(SourceCodeTest, getExtendedText) {
+  CallsVisitor Visitor;
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("foo(x, y);",
+  getExtendedText(*CE, tok::TokenKind::semi, *Context));
+
+Expr *P0 = CE->getArg(0);
+Expr *P1 = CE->getArg(1);
+EXPECT_EQ("x", getExtendedText(*P0, tok::TokenKind::semi, *Context));
+EXPECT_EQ("x,", getExtendedText(*P0, tok::TokenKind::comma, *Context));
+EXPECT_EQ("y", getExtendedText(*P1, tok::TokenKind::semi, *Context));
+  };
+  Visitor.runOver("void foo(int x, int y) { foo(x, y); }");
+  Visitor.runOver("void foo(int x, int y) { if (true) foo(x, y); }");
+  Visitor.runOver("int foo(int x, int y) { if (true) return 3 + foo(x, y); }");
+  Visitor.runOver("void foo(int x, int y) { for (foo(x, y);;) ++x; }");
+  Visitor.runOver(
+  "bool foo(int x, int y) { for (;foo(x, y);) x = 1; return true; }");
+
+  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
+EXPECT_EQ("foo()", getExtendedText(*CE, tok::TokenKind::semi, *Context));
+  };
+  Visitor.runOver("bool foo() { if (foo()) return true; return false; }");
+  Visitor.runOver("void foo() { int x; for (;; foo()) ++x; }");
+  Visitor.runOver("int foo() { return foo() + 3; }");
+}
+
+} // end anonymous namespace
Index: clang/unittests/Tooling/FixItTest.cpp
===
--- clang/unittests/Tooling/FixItTest.cpp
+++ clang/unittests/Tooling/FixItTest.cpp
@@ -78,34 +78,6 @@
   "void foo(int x, int y) { FOO(x,y) }");
 }
 
-TEST(FixItTest, getExtendedText) {
-  CallsVisitor Visitor;
-
-  Visitor.OnCall = [](CallExpr *CE, ASTContext *Context) {
-EXPECT_EQ("foo(x, y);",
-  getExtendedText(*CE, tok::TokenKind::semi, *Context));
-
-Expr *P0 = CE->getArg(0);
-Expr *P1 = CE->getArg(1);
-EXPECT_EQ("x", getExtendedText(*P0, tok::TokenKind::semi, *Context));
-EXPECT_EQ("x,", getExtendedText(*P0, tok::TokenKind::comma, 

[PATCH] D60139: [clang-tidy] Add misc-placement-new-target-type-mismatch check

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



Comment at: docs/ReleaseNotes.rst:136
+
+  Finds placement-new calls where the size of the pointee type of the 
placement 
+  parameter is smaller than the size of the constructed type and the pointer is

Please synchronize with documentation.


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

https://reviews.llvm.org/D60139



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


[PATCH] D60272: [Aarch64] Add v8.2-a half precision element extract intrinsics

2019-04-04 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio created this revision.
dnsampaio added reviewers: pablooliveira, olista01, LukeGeeson.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.

Implements the intrinsics define on the ACLE to extract half precision fp 
scalar elements from float16x4_t and float16x8_t vector types.
a.k.a:
vduph_lane_f16
vduph_laneq_f16


Repository:
  rC Clang

https://reviews.llvm.org/D60272

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/aarch64-v8.2a-neon-intrinsics.c


Index: test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
===
--- test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
+++ test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
@@ -1618,3 +1618,16 @@
   return vtrn2q_f16(a, b);
 }
 
+// CHECK-LABEL: @test_vduph_laneq_f16(
+// CHECK:[[V:%.*]] = extractelement <8 x half> [[V2:%.*]], i32 7
+// CHECK-NEXT:   ret half [[V]]
+float16_t test_vduph_laneq_f16 (float16x8_t vec) {
+return vduph_laneq_f16 (vec, 7);
+}
+
+// CHECK-LABEL: @test_vduph_lane_f16(
+// CHECK:[[V:%.*]] = extractelement <4 x half> [[V2:%.*]], i32 3
+// CHECK-NEXT:   ret half [[V]]
+float16_t test_vduph_lane_f16 (float16x4_t vec) {
+return vduph_lane_f16 (vec, 3);
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7810,6 +7810,14 @@
   : Intrinsic::aarch64_neon_sqsub;
 return EmitNeonCall(CGM.getIntrinsic(AccInt, Int64Ty), Ops, "vqdmlXl");
   }
+  case NEON::BI__builtin_neon_vduph_lane_f16:{
+return Builder.CreateExtractElement(Ops[0], EmitScalarExpr(E->getArg(1)),
+"vget_lane");
+  }
+  case NEON::BI__builtin_neon_vduph_laneq_f16:{
+return Builder.CreateExtractElement(Ops[0], EmitScalarExpr(E->getArg(1)),
+"vgetq_lane");
+  }
   }
 
   llvm::VectorType *VTy = GetNeonType(this, Type);


Index: test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
===
--- test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
+++ test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
@@ -1618,3 +1618,16 @@
   return vtrn2q_f16(a, b);
 }
 
+// CHECK-LABEL: @test_vduph_laneq_f16(
+// CHECK:[[V:%.*]] = extractelement <8 x half> [[V2:%.*]], i32 7
+// CHECK-NEXT:   ret half [[V]]
+float16_t test_vduph_laneq_f16 (float16x8_t vec) {
+return vduph_laneq_f16 (vec, 7);
+}
+
+// CHECK-LABEL: @test_vduph_lane_f16(
+// CHECK:[[V:%.*]] = extractelement <4 x half> [[V2:%.*]], i32 3
+// CHECK-NEXT:   ret half [[V]]
+float16_t test_vduph_lane_f16 (float16x4_t vec) {
+return vduph_lane_f16 (vec, 3);
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7810,6 +7810,14 @@
   : Intrinsic::aarch64_neon_sqsub;
 return EmitNeonCall(CGM.getIntrinsic(AccInt, Int64Ty), Ops, "vqdmlXl");
   }
+  case NEON::BI__builtin_neon_vduph_lane_f16:{
+return Builder.CreateExtractElement(Ops[0], EmitScalarExpr(E->getArg(1)),
+"vget_lane");
+  }
+  case NEON::BI__builtin_neon_vduph_laneq_f16:{
+return Builder.CreateExtractElement(Ops[0], EmitScalarExpr(E->getArg(1)),
+"vgetq_lane");
+  }
   }
 
   llvm::VectorType *VTy = GetNeonType(this, Type);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59264: [Driver] Support compiler-rt crtbegin.o/crtend.o for Linux

2019-04-04 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 193733.

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

https://reviews.llvm.org/D59264

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/Inputs/resource_dir/lib/linux/clang_rt.crtbegin-i386.o
  clang/test/Driver/Inputs/resource_dir/lib/linux/clang_rt.crtbegin-x86_64.o
  clang/test/Driver/Inputs/resource_dir/lib/linux/clang_rt.crtend-i386.o
  clang/test/Driver/Inputs/resource_dir/lib/linux/clang_rt.crtend-x86_64.o
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -2,7 +2,7 @@
 // sysroot to make these tests independent of the host system.
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=i386-unknown-linux \
+// RUN: --target=i386-unknown-linux -rtlib=platform \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-32 %s
@@ -51,16 +51,18 @@
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN: --rtlib=compiler-rt \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-RT %s
 // CHECK-LD-RT-NOT: warning:
+// CHECK-LD-RT: "-resource-dir" "[[RESDIR:[^"]*]]"
 // CHECK-LD-RT: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-LD-RT: "--eh-frame-hdr"
 // CHECK-LD-RT: "-m" "elf_x86_64"
 // CHECK-LD-RT: "-dynamic-linker"
-// CHECK-LD-RT: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0{{/|}}crtbegin.o"
+// CHECK-LD-RT: "[[RESDIR]]{{/|}}lib{{/|}}linux{{/|}}clang_rt.crtbegin-x86_64.o"
 // CHECK-LD-RT: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
 // CHECK-LD-RT: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib"
 // CHECK-LD-RT: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.."
@@ -69,19 +71,22 @@
 // CHECK-LD-RT: libclang_rt.builtins-x86_64.a"
 // CHECK-LD-RT: "-lc"
 // CHECK-LD-RT: libclang_rt.builtins-x86_64.a"
+// CHECK-LD-RT: "[[RESDIR]]{{/|}}lib{{/|}}linux{{/|}}clang_rt.crtend-x86_64.o"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN: --rtlib=compiler-rt \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-RT-I686 %s
 // CHECK-LD-RT-I686-NOT: warning:
+// CHECK-LD-RT-I686: "-resource-dir" "[[RESDIR:[^"]*]]"
 // CHECK-LD-RT-I686: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-LD-RT-I686: "--eh-frame-hdr"
 // CHECK-LD-RT-I686: "-m" "elf_i386"
 // CHECK-LD-RT-I686: "-dynamic-linker"
-// CHECK-LD-RT-I686: "{{.*}}/usr/lib/gcc/i686-unknown-linux/4.6.0{{/|}}crtbegin.o"
+// CHECK-LD-RT-I686: "[[RESDIR]]{{/|}}lib{{/|}}linux{{/|}}clang_rt.crtbegin-i386.o"
 // CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0"
 // CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../../../i686-unknown-linux/lib"
 // CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../.."
@@ -90,6 +95,7 @@
 // CHECK-LD-RT-I686: libclang_rt.builtins-i386.a"
 // CHECK-LD-RT-I686: "-lc"
 // CHECK-LD-RT-I686: libclang_rt.builtins-i386.a"
+// CHECK-LD-RT-I686: "[[RESDIR]]{{/|}}lib{{/|}}linux{{/|}}clang_rt.crtend-i386.o"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=arm-linux-androideabi \
@@ -110,7 +116,6 @@
 // RUN: --target=x86_64-unknown-linux -rtlib=platform \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
-// RUN: --rtlib=libgcc \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-GCC %s
 // CHECK-LD-GCC-NOT: warning:
 // CHECK-LD-GCC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -291,7 +296,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LD-64-STATIC %s
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=i386-unknown-linux -m32 \
+// RUN: --target=i386-unknown-linux -rtlib=platform -m32 \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-32-TO-32 %s
@@ -308,7 +313,7 @@
 // CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=i386-unknown-linux -m64 \
+// RUN: --target=i386-unknown-linux -rtlib=platform -m64 \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-32-TO-64 %s
@@ -326,7 +331,7 @@
 // CHECK-32-TO-64: 

[PATCH] D60269: [LibTooling] Add "SourceCode" library for functions relating to source-code manipulation.

2019-04-04 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: ilya-biryukov, ioeric.
Herald added a project: clang.

Introduces a utility library in Refactoring/ to collect routines related to
source-code manipulation.  In this change, we move "extended-range" functions
from the FixIt library (in clangTooling) to this new library.

We need to use this functionality in Refactoring/ and cannot access it if it
resides in Tooling/, because that would cause clangToolingRefactor to depend on
clangTooling, which would be a circular dependency.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60269

Files:
  clang/include/clang/Tooling/FixIt.h
  clang/include/clang/Tooling/Refactoring/SourceCode.h
  clang/lib/Tooling/FixIt.cpp
  clang/lib/Tooling/Refactoring/SourceCode.cpp

Index: clang/lib/Tooling/Refactoring/SourceCode.cpp
===
--- clang/lib/Tooling/Refactoring/SourceCode.cpp
+++ clang/lib/Tooling/Refactoring/SourceCode.cpp
@@ -1,4 +1,4 @@
-//===--- FixIt.cpp - FixIt Hint utilities ---*- C++ -*-===//
+//===--- SourceCode.cpp - Source code manipulation routines -*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,33 +6,26 @@
 //
 //===--===//
 //
-// This file contains implementations of utitilies to ease source code rewriting
-// by providing helper functions related to FixItHint.
+//  This file provides functions that simplify extraction of source code.
 //
 //===--===//
-#include "clang/Tooling/FixIt.h"
+#include "clang/Tooling/Refactoring/SourceCode.h"
 #include "clang/Lex/Lexer.h"
 
-namespace clang {
-namespace tooling {
-namespace fixit {
+using namespace clang;
 
-namespace internal {
-StringRef getText(CharSourceRange Range, const ASTContext ) {
+StringRef clang::tooling::getText(CharSourceRange Range,
+  const ASTContext ) {
   return Lexer::getSourceText(Range, Context.getSourceManager(),
   Context.getLangOpts());
 }
 
-CharSourceRange maybeExtendRange(CharSourceRange Range, tok::TokenKind Next,
- ASTContext ) {
+CharSourceRange clang::tooling::maybeExtendRange(CharSourceRange Range,
+ tok::TokenKind Next,
+ ASTContext ) {
   Optional Tok = Lexer::findNextToken(
   Range.getEnd(), Context.getSourceManager(), Context.getLangOpts());
   if (!Tok || !Tok->is(Next))
 return Range;
   return CharSourceRange::getTokenRange(Range.getBegin(), Tok->getLocation());
 }
-} // namespace internal
-
-} // end namespace fixit
-} // end namespace tooling
-} // end namespace clang
Index: clang/lib/Tooling/FixIt.cpp
===
--- clang/lib/Tooling/FixIt.cpp
+++ clang/lib/Tooling/FixIt.cpp
@@ -22,15 +22,6 @@
   return Lexer::getSourceText(Range, Context.getSourceManager(),
   Context.getLangOpts());
 }
-
-CharSourceRange maybeExtendRange(CharSourceRange Range, tok::TokenKind Next,
- ASTContext ) {
-  Optional Tok = Lexer::findNextToken(
-  Range.getEnd(), Context.getSourceManager(), Context.getLangOpts());
-  if (!Tok || !Tok->is(Next))
-return Range;
-  return CharSourceRange::getTokenRange(Range.getBegin(), Tok->getLocation());
-}
 } // namespace internal
 
 } // end namespace fixit
Index: clang/include/clang/Tooling/Refactoring/SourceCode.h
===
--- /dev/null
+++ clang/include/clang/Tooling/Refactoring/SourceCode.h
@@ -0,0 +1,70 @@
+//===--- SourceCode.h - Source code manipulation routines ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file provides functions that simplify extraction of source code.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_REFACTOR_SOURCE_CODE_H
+#define LLVM_CLANG_TOOLING_REFACTOR_SOURCE_CODE_H
+
+#include "clang/AST/ASTContext.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TokenKinds.h"
+
+namespace clang {
+namespace tooling {
+
+/// Extends \p Range to include the token \p Next, if it immediately follows the
+/// end of the range. Otherwise, returns \p Range unchanged.
+CharSourceRange maybeExtendRange(CharSourceRange Range, tok::TokenKind Next,
+ ASTContext );
+
+/// 

[PATCH] D59628: Add support for __attribute__((objc_class_stub))

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



Comment at: include/clang/Basic/Attr.td:290
 
-class LangOpt {
+class LangOpt {
   string Name = name;

I think there's a grand total of one use of `negated`, so you might as well 
rewrite it to use `customCode`; see below.



Comment at: include/clang/Basic/Attr.td:306
+def ObjCNonFragileRuntime : LangOpt<"ObjCNonFragileRuntime", 0,
+"LangOpts.ObjCRuntime.allowsClassStubs()">;
 

This is not an appropriate name for this `LangOpt`.  How about 
`ObjCAllowsClassStubs`?



Comment at: include/clang/Basic/AttrDocs.td:1100
+implementations defined for them. This attribute is intended for use in
+Swift generated headers for classes defined in Swift.
+}];

We should add something here to make it clear what the evolution story with 
this attribute is.  Presumably you can't add it to an existing class without 
breaking ABI.  Are there circumstances under which we're willing to guarantee 
that it can be removed (under a sufficiently-recent deployment target)?



Comment at: utils/TableGen/ClangAttrEmitter.cpp:3442
+if (!Code.empty()) {
+  Test += "S.";
+  Test += Code;

I think the contract with `CustomCode` ought to be that `LangOpts` will be 
bound as an unqualified name, so that the custom code can be an arbitrary 
expression in terms of that.  That will allow e.g. compound and negated 
`LangOpt`s to be defined, like `LangOpts.OpenCL && LangOpts.CPlusPlus`.  So you 
need to generate `auto  = S.LangOpts;` at the top of the function, at 
least when custom code is present; and you should probably add parens around 
the code just to be safe.

Alternatively, you could make the contract that `CustomCode` should contain 
`%0` or some other string that'll be expanded to an expression for the language 
options, but that sounds pretty complex compared to just binding `LangOpts` in 
the context.


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

https://reviews.llvm.org/D59628



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


[PATCH] D60139: [clang-tidy] Add misc-placement-new-target-type-mismatch check

2019-04-04 Thread Dennis Luxen via Phabricator via cfe-commits
DennisL updated this revision to Diff 193715.
DennisL marked an inline comment as done.
DennisL retitled this revision from "[clang-tidy] Add 
misc-placement-new-target-size check" to "[clang-tidy] Add 
misc-placement-new-target-type-mismatch check".
DennisL edited the summary of this revision.
DennisL added a comment.

Addressed reviewer feedback and also simplified the implementation, renamed the 
test to be more concise, and added more test cases.


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

https://reviews.llvm.org/D60139

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/PlacementNewTargetTypeMismatch.cpp
  clang-tidy/misc/PlacementNewTargetTypeMismatch.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-placement-new-target-type-mismatch.rst
  test/clang-tidy/misc-placement-new-target-type-mismatch.cpp

Index: test/clang-tidy/misc-placement-new-target-type-mismatch.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-placement-new-target-type-mismatch.cpp
@@ -0,0 +1,82 @@
+// RUN: %check_clang_tidy %s misc-placement-new-target-type-mismatch %t
+
+// definitions
+
+using size_type = unsigned long;
+void *operator new(size_type, void *);
+void *operator new[](size_type, void *);
+
+namespace std {
+template T* addressof(T& arg) noexcept;
+} // namespace std
+
+struct Foo {
+  int a;
+  int b;
+  int c;
+  int d;
+};
+
+template
+T& getT() {
+  static T f;
+  return f;
+}
+
+// instances emitting warnings
+
+void f1() {
+  struct Dummy {
+int a;
+int b;
+  };
+  int *ptr = new int;
+  new (ptr) Dummy;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: placement new of incompatible types [misc-placement-new-target-type-mismatch]
+  delete ptr;
+}
+
+void f2() {
+  int * ptr = new int;
+  new (ptr) Foo;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: placement new of incompatible types [misc-placement-new-target-type-mismatch]
+  delete ptr;
+}
+
+void f3() {
+  char *ptr = new char[17*sizeof(char)];
+  new(ptr) float[13];
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: placement new of incompatible types [misc-placement-new-target-type-mismatch]
+  delete[] ptr;
+}
+
+void f4() {
+  new (std::addressof(getT())) Foo;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: placement new of incompatible types [misc-placement-new-target-type-mismatch]
+}
+
+void f5() {
+  char *ptr = new char[17*sizeof(char)];
+  new(ptr) float{13.f};
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: placement new of incompatible types [misc-placement-new-target-type-mismatch]
+  delete[] ptr;
+}
+
+// instances not emitting a warning
+
+void f6() {
+  Foo * ptr = new Foo;
+  new (ptr) Foo;
+  delete ptr;
+}
+
+void f7() {
+  new ((void *)std::addressof(getT())) Foo;
+}
+
+void f8() {
+  char *ptr = new char[17*sizeof(char)];
+  new((float *)ptr) float{13.f};
+
+  delete[] ptr;
+}
\ No newline at end of file
Index: docs/clang-tidy/checks/misc-placement-new-target-type-mismatch.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-placement-new-target-type-mismatch.rst
@@ -0,0 +1,8 @@
+.. title:: clang-tidy - misc-placement-new-target-type-mismatch
+
+misc-placement-new-target-type-mismatch
+===
+
+Finds placement-new calls where the pointer type of the adress mismatches the
+type of the created value.
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -184,6 +184,7 @@
misc-new-delete-overloads
misc-non-copyable-objects
misc-non-private-member-variables-in-classes
+   misc-placement-new-target-type-mismatch
misc-redundant-expression
misc-static-assert
misc-throw-by-value-catch-by-reference
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -130,6 +130,13 @@
   ` now supports `OverrideSpelling`
   and `FinalSpelling` options.
 
+- New :doc:`misc-placement-new-target-type-mismatch
+  ` check.
+
+  Finds placement-new calls where the size of the pointee type of the placement 
+  parameter is smaller than the size of the constructed type and the pointer is
+  implicitly cast to ``void *``.
+
 - New :doc:`openmp-exception-escape
   ` check.
 
Index: clang-tidy/misc/PlacementNewTargetTypeMismatch.h
===
--- /dev/null
+++ clang-tidy/misc/PlacementNewTargetTypeMismatch.h
@@ -0,0 +1,36 @@
+//===--- PlacementNewTargetTypeMismatch.h - clang-tidy -*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH 

[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

2019-04-04 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.cpp:18
+
+AST_MATCHER(Expr, isMacroID) { return Node.getExprLoc().isMacroID(); }
+} // namespace ast_matchers

aaron.ballman wrote:
> hintonda wrote:
> > aaron.ballman wrote:
> > > hintonda wrote:
> > > > @aaron.ballman:  This matcher seems genuinely useful.  What do you 
> > > > think about moving it to ASTMatchers.h? 
> > > I think that adding something like this might be a good idea. We don't 
> > > have any notion of source locations in the AST matching syntax currently, 
> > > and I'm not certain whether that's a good thing or not here. I'm mildly 
> > > uncomfortable that this matcher operates on an `Expr` but then internally 
> > > uses a source location from that expression and I wonder if we would 
> > > rather introduce source location matching. For instance, what if the user 
> > > cares about the difference between `getExprLoc()` and `getBeginLoc()` for 
> > > some reason?
> > Well, you can attach it to whatever you want, so I'm not sure that's a 
> > problem.  Alternatively, you have to check each location yourself.  In my 
> > case, that was multiple places, so putting it in the matcher cleaned up the 
> > code.
> > 
> > I need to verify it, but it seems that it triggered when any macros were in 
> > the range, but I need to look closer into that to understand the behavior.  
> >  I'll check it out and get back to you.
> > Well, you can attach it to whatever you want, so I'm not sure that's a 
> > problem. 
> 
> How does a caller of this AST matcher indicate that they want it to match on 
> `Node.getBeingLoc().isMacroID()` instead of what's written now? If the answer 
> is "they write a different matcher", then that's what I think could be a 
> problem. There's a lot of ways to get a source location (and a lot of 
> different kinds of source locations), and I think matching on those can be 
> very useful functionality. So I think the idea of the matcher is good, I'm 
> just not certain whether we want it to look like `AST_MATCHER(Expr, 
> isMacroID);` or `AST_MATCHER(SourceLocation, isMacroID);` or something else.
I'll workup a separate patch with tests and examples, and see if I can allay 
your concerns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59802



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


r357702 - [RISCV] Fix rL357699 by adding missing zero-length files

2019-04-04 Thread Alex Bradbury via cfe-commits
Author: asb
Date: Thu Apr  4 07:36:07 2019
New Revision: 357702

URL: http://llvm.org/viewvc/llvm-project?rev=357702=rev
Log:
[RISCV] Fix rL357699 by adding missing zero-length files

svn add doesn't play very nicely here...

Added:

cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/crtbegin.o

cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/crtend.o

cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib/crt0.o

Added: 
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/crtbegin.o
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/crtbegin.o?rev=357702=auto
==
(empty)

Added: 
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/crtend.o
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/crtend.o?rev=357702=auto
==
(empty)

Added: 
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib/crt0.o
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib/crt0.o?rev=357702=auto
==
(empty)


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


[PATCH] D59516: [analyzer] Add custom filter functions for GenericTaintChecker

2019-04-04 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 updated this revision to Diff 193705.
boga95 added a comment.

Rebase after https://reviews.llvm.org/D59861.
Fix custom filter test case: functions without definition always remove 
taintedness.


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

https://reviews.llvm.org/D59516

Files:
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  lib/StaticAnalyzer/Checkers/Taint.cpp
  lib/StaticAnalyzer/Checkers/Taint.h
  test/Analysis/Inputs/taint-generic-config.yaml
  test/Analysis/taint-generic.c

Index: test/Analysis/taint-generic.c
===
--- test/Analysis/taint-generic.c
+++ test/Analysis/taint-generic.c
@@ -296,13 +296,15 @@
 *(volatile int *) 0; // no-warning
 }
 
-
 // Test configuration
 int mySource1();
 void mySource2(int*);
 void myScanf(const char*, ...);
 int myPropagator(int, int*);
 int mySnprintf(char*, size_t, const char*, ...);
+void myFilter1(int* x) {}
+void myFilter2(const int*);
+void myFilter3(int);
 void mySink(int, int, int);
 
 void testConfigurationSources1() {
@@ -329,6 +331,24 @@
   Buffer[y] = 1; // expected-warning {{Out of bound memory access }}
 }
 
+void testConfigurationFilter1() {
+  int x = mySource1();
+  myFilter1();
+  Buffer[x] = 1; // no-warning
+}
+
+void testConfigurationFilter2() {
+  int x = mySource1();
+  myFilter2(); // Pass by const int*
+  Buffer[x] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void testConfigurationFilter3() {
+  int x = mySource1();
+  myFilter3(x); // Pass by value
+  Buffer[x] = 1; // expected-warning {{Out of bound memory access }}
+}
+
 void testConfigurationSinks() {
   int x = mySource1();
   mySink(x, 1, 2); // expected-warning {{Untrusted data is passed to a user defined sink}}
Index: test/Analysis/Inputs/taint-generic-config.yaml
===
--- test/Analysis/Inputs/taint-generic-config.yaml
+++ test/Analysis/Inputs/taint-generic-config.yaml
@@ -36,8 +36,8 @@
 # A list of filter functions
 Filters:
   # int x; // x is tainted
-  # myFilter(); // x is not tainted anymore
-  - Name: myFilter
+  # myFilter1(); // x is not tainted anymore
+  - Name: myFilter1
 Args: [0]
 
 # A list of sink functions
Index: lib/StaticAnalyzer/Checkers/Taint.h
===
--- lib/StaticAnalyzer/Checkers/Taint.h
+++ lib/StaticAnalyzer/Checkers/Taint.h
@@ -24,37 +24,35 @@
 /// taint.
 using TaintTagType = unsigned;
 
-static constexpr TaintTagType TaintTagGeneric = 0;
+static constexpr TaintTagType TaintTagNotTainted = 0;
+static constexpr TaintTagType TaintTagGeneric = 1;
 
 /// Create a new state in which the value of the statement is marked as tainted.
-LLVM_NODISCARD ProgramStateRef
-addTaint(ProgramStateRef State, const Stmt *S, const LocationContext *LCtx,
- TaintTagType Kind = TaintTagGeneric);
+LLVM_NODISCARD ProgramStateRef addTaint(ProgramStateRef State, const Stmt *S,
+const LocationContext *LCtx,
+TaintTagType Kind = TaintTagGeneric);
 
 /// Create a new state in which the value is marked as tainted.
-LLVM_NODISCARD ProgramStateRef
-addTaint(ProgramStateRef State, SVal V,
- TaintTagType Kind = TaintTagGeneric);
+LLVM_NODISCARD ProgramStateRef addTaint(ProgramStateRef State, SVal V,
+TaintTagType Kind = TaintTagGeneric);
 
 /// Create a new state in which the symbol is marked as tainted.
-LLVM_NODISCARD ProgramStateRef
-addTaint(ProgramStateRef State, SymbolRef Sym,
- TaintTagType Kind = TaintTagGeneric);
+LLVM_NODISCARD ProgramStateRef addTaint(ProgramStateRef State, SymbolRef Sym,
+TaintTagType Kind = TaintTagGeneric);
 
 /// Create a new state in which the pointer represented by the region
 /// is marked as tainted.
-LLVM_NODISCARD ProgramStateRef
-addTaint(ProgramStateRef State, const MemRegion *R,
- TaintTagType Kind = TaintTagGeneric);
+LLVM_NODISCARD ProgramStateRef addTaint(ProgramStateRef State,
+const MemRegion *R,
+TaintTagType Kind = TaintTagGeneric);
 
 /// Create a new state in a which a sub-region of a given symbol is tainted.
 /// This might be necessary when referring to regions that can not have an
 /// individual symbol, e.g. if they are represented by the default binding of
 /// a LazyCompoundVal.
-LLVM_NODISCARD ProgramStateRef
-addPartialTaint(ProgramStateRef State,
-SymbolRef ParentSym, const SubRegion *SubRegion,
-TaintTagType Kind = TaintTagGeneric);
+LLVM_NODISCARD ProgramStateRef addPartialTaint(
+ProgramStateRef State, SymbolRef ParentSym, const SubRegion *SubRegion,
+TaintTagType Kind = TaintTagGeneric);
 
 /// Check if the statement has a tainted value in the given state.
 bool 

[PATCH] D53392: [RISCV] Collect library directories and triples for riscv64 triple too

2019-04-04 Thread Alex Bradbury via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL357699: [RISCV] Collect library directories and triples for 
riscv64 triple too (authored by asb, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53392?vs=170374=193709#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D53392

Files:
  cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
  cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/bin/riscv64-unknown-elf-ld
  
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/include/c++/8.0.1/.keep
  cfe/trunk/test/Driver/riscv64-toolchain.c

Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -1976,10 +1976,14 @@
   "powerpc64le-linux-gnu", "powerpc64le-unknown-linux-gnu",
   "powerpc64le-suse-linux", "ppc64le-redhat-linux"};
 
-  static const char *const RISCV32LibDirs[] = {"/lib", "/lib32"};
-  static const char *const RISCVTriples[] = {"riscv32-unknown-linux-gnu",
- "riscv64-unknown-linux-gnu",
- "riscv32-unknown-elf"};
+  static const char *const RISCV32LibDirs[] = {"/lib32", "/lib"};
+  static const char *const RISCV32Triples[] = {"riscv32-unknown-linux-gnu",
+   "riscv32-linux-gnu",
+   "riscv32-unknown-elf"};
+  static const char *const RISCV64LibDirs[] = {"/lib64", "/lib"};
+  static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu",
+   "riscv64-linux-gnu",
+   "riscv64-unknown-elf"};
 
   static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"};
   static const char *const SPARCv8Triples[] = {"sparc-linux-gnu",
@@ -2209,9 +2213,15 @@
 break;
   case llvm::Triple::riscv32:
 LibDirs.append(begin(RISCV32LibDirs), end(RISCV32LibDirs));
+TripleAliases.append(begin(RISCV32Triples), end(RISCV32Triples));
+BiarchLibDirs.append(begin(RISCV64LibDirs), end(RISCV64LibDirs));
+BiarchTripleAliases.append(begin(RISCV64Triples), end(RISCV64Triples));
+break;
+  case llvm::Triple::riscv64:
+LibDirs.append(begin(RISCV64LibDirs), end(RISCV64LibDirs));
+TripleAliases.append(begin(RISCV64Triples), end(RISCV64Triples));
 BiarchLibDirs.append(begin(RISCV32LibDirs), end(RISCV32LibDirs));
-TripleAliases.append(begin(RISCVTriples), end(RISCVTriples));
-BiarchTripleAliases.append(begin(RISCVTriples), end(RISCVTriples));
+BiarchTripleAliases.append(begin(RISCV32Triples), end(RISCV32Triples));
 break;
   case llvm::Triple::sparc:
   case llvm::Triple::sparcel:
Index: cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/bin/riscv64-unknown-elf-ld
===
--- cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/bin/riscv64-unknown-elf-ld
+++ cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/bin/riscv64-unknown-elf-ld
@@ -0,0 +1 @@
+#!/bin/true
Index: cfe/trunk/test/Driver/riscv64-toolchain.c
===
--- cfe/trunk/test/Driver/riscv64-toolchain.c
+++ cfe/trunk/test/Driver/riscv64-toolchain.c
@@ -3,6 +3,102 @@
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
 
+// RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   -target riscv64-unknown-elf \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree \
+// RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
+// RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-LP64 %s
+
+// C-RV64-BAREMETAL-LP64: "-fuse-init-array"
+// C-RV64-BAREMETAL-LP64: "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../../../bin{{/|}}riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64: "--sysroot={{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf"
+// C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib{{/|}}crt0.o"
+// C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
+// C-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64: "-L{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1"
+// C-RV64-BAREMETAL-LP64: "--start-group" "-lc" "-lgloss" "--end-group" "-lgcc"
+// C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
+
+// RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   -target riscv64-unknown-elf \
+// RUN:   --sysroot= \
+// RUN:   

[PATCH] D60203: Updating Chromium's Java import order

2019-04-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC357700: Updating Chromiums Java import order (authored 
by nico, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D60203

Files:
  lib/Format/Format.cpp


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -898,9 +898,16 @@
 // See styleguide for import groups:
 // 
https://chromium.googlesource.com/chromium/src/+/master/styleguide/java/java.md#Import-Order
 ChromiumStyle.JavaImportGroups = {
-"android",  "com",  "dalvik",
-"junit","org",  "com.google.android.apps.chrome",
-"org.chromium", "java", "javax",
+"android",
+"androidx",
+"com",
+"dalvik",
+"junit",
+"org",
+"com.google.android.apps.chrome",
+"org.chromium",
+"java",
+"javax",
 };
 ChromiumStyle.SortIncludes = true;
   } else if (Language == FormatStyle::LK_JavaScript) {


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -898,9 +898,16 @@
 // See styleguide for import groups:
 // https://chromium.googlesource.com/chromium/src/+/master/styleguide/java/java.md#Import-Order
 ChromiumStyle.JavaImportGroups = {
-"android",  "com",  "dalvik",
-"junit","org",  "com.google.android.apps.chrome",
-"org.chromium", "java", "javax",
+"android",
+"androidx",
+"com",
+"dalvik",
+"junit",
+"org",
+"com.google.android.apps.chrome",
+"org.chromium",
+"java",
+"javax",
 };
 ChromiumStyle.SortIncludes = true;
   } else if (Language == FormatStyle::LK_JavaScript) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53392: [RISCV] Collect library directories and triples for riscv64 triple too

2019-04-04 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.
This revision is now accepted and ready to land.
Herald added subscribers: benna, psnobl, MaskRay.

This got missed somehow as I had a functionally identical patch in my local 
development tree (though not with as thorough tests - thanks for that!). LGTM, 
thanks Ed.


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

https://reviews.llvm.org/D53392



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


[PATCH] D60267: [clangd] Support relatedInformation in diagnostics.

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

We already have the structure internally, we just need to expose it.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D60267

Files:
  clangd/Diagnostics.cpp
  clangd/Diagnostics.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/SourceCode.cpp
  unittests/clangd/DiagnosticsTests.cpp

Index: unittests/clangd/DiagnosticsTests.cpp
===
--- unittests/clangd/DiagnosticsTests.cpp
+++ unittests/clangd/DiagnosticsTests.cpp
@@ -8,6 +8,8 @@
 
 #include "Annotations.h"
 #include "ClangdUnit.h"
+#include "Diagnostics.h"
+#include "Protocol.h"
 #include "SourceCode.h"
 #include "TestIndex.h"
 #include "TestTU.h"
@@ -54,8 +56,15 @@
 
 MATCHER_P(EqualToLSPDiag, LSPDiag,
   "LSP diagnostic " + llvm::to_string(LSPDiag)) {
-  return std::tie(arg.range, arg.severity, arg.message) ==
- std::tie(LSPDiag.range, LSPDiag.severity, LSPDiag.message);
+  if (std::tie(arg.range, arg.severity, arg.message) !=
+  std::tie(LSPDiag.range, LSPDiag.severity, LSPDiag.message))
+return false;
+  if (toJSON(arg) != toJSON(LSPDiag)) {
+*result_listener << llvm::formatv("expected:\n{0:2}\ngot\n{1:2}",
+  toJSON(LSPDiag), toJSON(arg)).str();
+return false;
+  }
+  return true;
 }
 
 MATCHER_P(DiagSource, Source, "") { return arg.S == Source; }
@@ -245,12 +254,28 @@
 }
 
 TEST(DiagnosticsTest, ToLSP) {
+  URIForFile MainFile = URIForFile::canonicalize(
+#ifdef _WIN32
+  "c:\\path\\to\\foo\\bar\\main.cpp",
+#else
+  "/path/to/foo/bar/main.cpp",
+#endif
+  /*TUPath=*/"");
+  URIForFile HeaderFile = URIForFile::canonicalize(
+#ifdef _WIN32
+  "c:\\path\\to\\foo\\bar\\header.h",
+#else
+  "/path/to/foo/bar/header.h",
+#endif
+  /*TUPath=*/"");
+
   clangd::Diag D;
   D.Message = "something terrible happened";
   D.Range = {pos(1, 2), pos(3, 4)};
   D.InsideMainFile = true;
   D.Severity = DiagnosticsEngine::Error;
   D.File = "foo/bar/main.cpp";
+  D.AbsFile = MainFile.file();
 
   clangd::Note NoteInMain;
   NoteInMain.Message = "declared somewhere in the main file";
@@ -258,6 +283,8 @@
   NoteInMain.Severity = DiagnosticsEngine::Remark;
   NoteInMain.File = "../foo/bar/main.cpp";
   NoteInMain.InsideMainFile = true;
+  NoteInMain.AbsFile = MainFile.file();
+
   D.Notes.push_back(NoteInMain);
 
   clangd::Note NoteInHeader;
@@ -266,6 +293,7 @@
   NoteInHeader.Severity = DiagnosticsEngine::Note;
   NoteInHeader.File = "../foo/baz/header.h";
   NoteInHeader.InsideMainFile = false;
+  NoteInHeader.AbsFile = HeaderFile.file();
   D.Notes.push_back(NoteInHeader);
 
   clangd::Fix F;
@@ -294,16 +322,10 @@
 
 main.cpp:2:3: error: something terrible happened)");
 
-  // Transform dianostics and check the results.
+  ClangdDiagnosticOptions Opts;
+  // Transform diagnostics and check the results.
   std::vector>> LSPDiags;
-  toLSPDiags(D,
-#ifdef _WIN32
- URIForFile::canonicalize("c:\\path\\to\\foo\\bar\\main.cpp",
-  /*TUPath=*/""),
-#else
-  URIForFile::canonicalize("/path/to/foo/bar/main.cpp", /*TUPath=*/""),
-#endif
- ClangdDiagnosticOptions(),
+  toLSPDiags(D, MainFile, Opts,
  [&](clangd::Diagnostic LSPDiag, ArrayRef Fixes) {
LSPDiags.push_back(
{std::move(LSPDiag),
@@ -314,6 +336,30 @@
   LSPDiags,
   ElementsAre(Pair(EqualToLSPDiag(MainLSP), ElementsAre(EqualToFix(F))),
   Pair(EqualToLSPDiag(NoteInMainLSP), IsEmpty(;
+
+  // Same thing, but don't flatten notes into the main list.
+  LSPDiags.clear();
+  Opts.EmitRelatedLocations = true;
+  toLSPDiags(D, MainFile, Opts,
+ [&](clangd::Diagnostic LSPDiag, ArrayRef Fixes) {
+   LSPDiags.push_back(
+   {std::move(LSPDiag),
+std::vector(Fixes.begin(), Fixes.end())});
+ });
+  MainLSP.message = "Something terrible happened (fix available)";
+  DiagnosticRelatedInformation NoteInMainDRI;
+  NoteInMainDRI.message = "Declared somewhere in the main file";
+  NoteInMainDRI.location.range = NoteInMain.Range;
+  NoteInMainDRI.location.uri = MainFile;
+  MainLSP.relatedInformation = {NoteInMainDRI};
+  DiagnosticRelatedInformation NoteInHeaderDRI;
+  NoteInHeaderDRI.message = "Declared somewhere in the header file";
+  NoteInHeaderDRI.location.range = NoteInHeader.Range;
+  NoteInHeaderDRI.location.uri = HeaderFile;
+  MainLSP.relatedInformation = {NoteInMainDRI, NoteInHeaderDRI};
+  EXPECT_THAT(
+  LSPDiags,
+  ElementsAre(Pair(EqualToLSPDiag(MainLSP), ElementsAre(EqualToFix(F);
 }
 
 struct SymbolWithHeader {
Index: clangd/SourceCode.cpp
===
--- clangd/SourceCode.cpp

[PATCH] D60203: Updating Chromium's Java import order

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

Ah, ok. Probably want to add tests at some point, but I'll land this as-is for 
now then.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60203



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


[PATCH] D60263: [clang-format] Preserve include blocks in ObjC Google style

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

Please don't land changes with open discussion.

Objective-C++ basically is C++ code. I don't think it makes sense to make a 
distinction here.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60263



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


[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-04 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

In D59376#1454834 , @ymandel wrote:

> In D59376#1454768 , @ilya-biryukov 
> wrote:
>
> > Per @ioeric's suggestion: why not move the helper into 
> > `Tooling/Refactoring/ExtendedRange.h`?
> >  If it's in `ToolingRefactoring`, both stencil and transformer can access 
> > it.
> >
> > For external users, a dependency on either `ToolingCore` or 
> > `ToolingRefactoring` should be fine, since they're fine with a dependency 
> > on `Tooling` already.
>
>
> This sounds perfect. Can I do the same for the future additions -- small, 
> focused libraries for each group of functions? I just want to be sure that we 
> don't regret the name "ExtendedRange" when I need to add the next batch.


In clangd, we have a library called `SourceCode.h` that keeps source code 
related helpers including those that deal with ranges. I think it's reasonable 
to use SourceCode.h or something similar here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59376



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


r357700 - Updating Chromium's Java import order

2019-04-04 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Apr  4 07:19:45 2019
New Revision: 357700

URL: http://llvm.org/viewvc/llvm-project?rev=357700=rev
Log:
Updating Chromium's Java import order

Adding in androidx as another import group.

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

Patch from Sam Maier !

Modified:
cfe/trunk/lib/Format/Format.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=357700=357699=357700=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu Apr  4 07:19:45 2019
@@ -898,9 +898,16 @@ FormatStyle getChromiumStyle(FormatStyle
 // See styleguide for import groups:
 // 
https://chromium.googlesource.com/chromium/src/+/master/styleguide/java/java.md#Import-Order
 ChromiumStyle.JavaImportGroups = {
-"android",  "com",  "dalvik",
-"junit","org",  "com.google.android.apps.chrome",
-"org.chromium", "java", "javax",
+"android",
+"androidx",
+"com",
+"dalvik",
+"junit",
+"org",
+"com.google.android.apps.chrome",
+"org.chromium",
+"java",
+"javax",
 };
 ChromiumStyle.SortIncludes = true;
   } else if (Language == FormatStyle::LK_JavaScript) {


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


r357699 - [RISCV] Collect library directories and triples for riscv64 triple too

2019-04-04 Thread Alex Bradbury via cfe-commits
Author: asb
Date: Thu Apr  4 07:18:26 2019
New Revision: 357699

URL: http://llvm.org/viewvc/llvm-project?rev=357699=rev
Log:
[RISCV] Collect library directories and triples for riscv64 triple too

When setting up library and tools paths when detecting an accompanying GCC
installation only riscv32 was handled. As a consequence when targetting
riscv64 neither the linker nor libraries would be found. This adds handling
and tests for riscv64.

Differential Revision: https://reviews.llvm.org/D53392
Patch by Edward Jones.


Added:
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/bin/
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/bin/riscv64-unknown-elf-ld  
 (with props)
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/lib/
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/lib/gcc/
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/

cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/include/

cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/include/c++/

cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/include/c++/8.0.1/

cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/include/c++/8.0.1/.keep
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib/
Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/riscv64-toolchain.c

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=357699=357698=357699=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Thu Apr  4 07:18:26 2019
@@ -1976,10 +1976,14 @@ void Generic_GCC::GCCInstallationDetecto
   "powerpc64le-linux-gnu", "powerpc64le-unknown-linux-gnu",
   "powerpc64le-suse-linux", "ppc64le-redhat-linux"};
 
-  static const char *const RISCV32LibDirs[] = {"/lib", "/lib32"};
-  static const char *const RISCVTriples[] = {"riscv32-unknown-linux-gnu",
- "riscv64-unknown-linux-gnu",
- "riscv32-unknown-elf"};
+  static const char *const RISCV32LibDirs[] = {"/lib32", "/lib"};
+  static const char *const RISCV32Triples[] = {"riscv32-unknown-linux-gnu",
+   "riscv32-linux-gnu",
+   "riscv32-unknown-elf"};
+  static const char *const RISCV64LibDirs[] = {"/lib64", "/lib"};
+  static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu",
+   "riscv64-linux-gnu",
+   "riscv64-unknown-elf"};
 
   static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"};
   static const char *const SPARCv8Triples[] = {"sparc-linux-gnu",
@@ -2209,9 +2213,15 @@ void Generic_GCC::GCCInstallationDetecto
 break;
   case llvm::Triple::riscv32:
 LibDirs.append(begin(RISCV32LibDirs), end(RISCV32LibDirs));
+TripleAliases.append(begin(RISCV32Triples), end(RISCV32Triples));
+BiarchLibDirs.append(begin(RISCV64LibDirs), end(RISCV64LibDirs));
+BiarchTripleAliases.append(begin(RISCV64Triples), end(RISCV64Triples));
+break;
+  case llvm::Triple::riscv64:
+LibDirs.append(begin(RISCV64LibDirs), end(RISCV64LibDirs));
+TripleAliases.append(begin(RISCV64Triples), end(RISCV64Triples));
 BiarchLibDirs.append(begin(RISCV32LibDirs), end(RISCV32LibDirs));
-TripleAliases.append(begin(RISCVTriples), end(RISCVTriples));
-BiarchTripleAliases.append(begin(RISCVTriples), end(RISCVTriples));
+BiarchTripleAliases.append(begin(RISCV32Triples), end(RISCV32Triples));
 break;
   case llvm::Triple::sparc:
   case llvm::Triple::sparcel:

Added: 
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/bin/riscv64-unknown-elf-ld
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/bin/riscv64-unknown-elf-ld?rev=357699=auto
==
--- cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/bin/riscv64-unknown-elf-ld 
(added)
+++ cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/bin/riscv64-unknown-elf-ld 
Thu Apr  4 07:18:26 2019
@@ -0,0 +1 @@
+#!/bin/true

Propchange: 
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/bin/riscv64-unknown-elf-ld
--
svn:executable = *

Added: 
cfe/trunk/test/Driver/Inputs/basic_riscv64_tree/riscv64-unknown-elf/include/c++/8.0.1/.keep
URL: 

[PATCH] D60263: [clang-format] Preserve include blocks in ObjC Google style

2019-04-04 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL357695: [clang-format] Preserve include blocks in ObjC 
Google style (authored by krasimir, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60263

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/unittests/Format/SortIncludesTest.cpp


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -877,6 +877,11 @@
   } else if (Language == FormatStyle::LK_ObjC) {
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.ColumnLimit = 100;
+// "Regroup" doesn't work well for ObjC yet (main header heuristic,
+// relationship between ObjC standard library headers and other heades,
+// #imports, etc.)
+GoogleStyle.IncludeStyle.IncludeBlocks =
+tooling::IncludeStyle::IBS_Preserve;
   }
 
   return GoogleStyle;
Index: cfe/trunk/unittests/Format/SortIncludesTest.cpp
===
--- cfe/trunk/unittests/Format/SortIncludesTest.cpp
+++ cfe/trunk/unittests/Format/SortIncludesTest.cpp
@@ -653,6 +653,18 @@
   EXPECT_EQ(Code, sort(Code, "input.h", 0));
 }
 
+
+TEST_F(SortIncludesTest, DoNotRegroupGroupsInGoogleObjCStyle) {
+  FmtStyle = getGoogleStyle(FormatStyle::LK_ObjC);
+
+  EXPECT_EQ("#include \n"
+"#include \n"
+"#include \"a.h\"",
+sort("#include \n"
+ "#include \n"
+ "#include \"a.h\""));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -877,6 +877,11 @@
   } else if (Language == FormatStyle::LK_ObjC) {
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.ColumnLimit = 100;
+// "Regroup" doesn't work well for ObjC yet (main header heuristic,
+// relationship between ObjC standard library headers and other heades,
+// #imports, etc.)
+GoogleStyle.IncludeStyle.IncludeBlocks =
+tooling::IncludeStyle::IBS_Preserve;
   }
 
   return GoogleStyle;
Index: cfe/trunk/unittests/Format/SortIncludesTest.cpp
===
--- cfe/trunk/unittests/Format/SortIncludesTest.cpp
+++ cfe/trunk/unittests/Format/SortIncludesTest.cpp
@@ -653,6 +653,18 @@
   EXPECT_EQ(Code, sort(Code, "input.h", 0));
 }
 
+
+TEST_F(SortIncludesTest, DoNotRegroupGroupsInGoogleObjCStyle) {
+  FmtStyle = getGoogleStyle(FormatStyle::LK_ObjC);
+
+  EXPECT_EQ("#include \n"
+"#include \n"
+"#include \"a.h\"",
+sort("#include \n"
+ "#include \n"
+ "#include \"a.h\""));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r357696 - Fix clangd-fuzzer build

2019-04-04 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Apr  4 07:08:35 2019
New Revision: 357696

URL: http://llvm.org/viewvc/llvm-project?rev=357696=rev
Log:
Fix clangd-fuzzer build

r357102 made clangd-fuzzer no longer compile, but before
r357654 / r357694 we didn't notice. Fix the compile.

Also add a dep on FuzzMutate which I forgot to do in r357654.

Modified:
clang-tools-extra/trunk/clangd/fuzzer/CMakeLists.txt
clang-tools-extra/trunk/clangd/fuzzer/clangd-fuzzer.cpp

Modified: clang-tools-extra/trunk/clangd/fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/fuzzer/CMakeLists.txt?rev=357696=357695=357696=diff
==
--- clang-tools-extra/trunk/clangd/fuzzer/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/fuzzer/CMakeLists.txt Thu Apr  4 07:08:35 
2019
@@ -1,6 +1,9 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-set(LLVM_LINK_COMPONENTS support)
+set(LLVM_LINK_COMPONENTS
+  FuzzMutate
+  Support
+  )
 
 # This fuzzer runs on oss-fuzz, so keep it around even if it looks 
unreferenced.
 add_llvm_fuzzer(clangd-fuzzer

Modified: clang-tools-extra/trunk/clangd/fuzzer/clangd-fuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/fuzzer/clangd-fuzzer.cpp?rev=357696=357695=357696=diff
==
--- clang-tools-extra/trunk/clangd/fuzzer/clangd-fuzzer.cpp (original)
+++ clang-tools-extra/trunk/clangd/fuzzer/clangd-fuzzer.cpp Thu Apr  4 07:08:35 
2019
@@ -36,7 +36,8 @@ extern "C" int LLVMFuzzerTestOneInput(ui
   ClangdServer::Options Opts;
 
   // Initialize and run ClangdLSPServer.
-  ClangdLSPServer LSPServer(*Transport, FS, CCOpts, llvm::None, false, Opts);
+  ClangdLSPServer LSPServer(*Transport, FS, CCOpts, llvm::None, false,
+llvm::None, Opts);
   LSPServer.run();
   return 0;
 }


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


[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

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

In D59376#1454768 , @ilya-biryukov 
wrote:

> Per @ioeric's suggestion: why not move the helper into 
> `Tooling/Refactoring/ExtendedRange.h`?
>  If it's in `ToolingRefactoring`, both stencil and transformer can access it.
>
> For external users, a dependency on either `ToolingCore` or 
> `ToolingRefactoring` should be fine, since they're fine with a dependency on 
> `Tooling` already.


This sounds perfect. Can I do the same for the future additions -- small, 
focused libraries for each group of functions? I just want to be sure that we 
don't regret the name "ExtendedRange" when I need to add the next batch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59376



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


r357695 - [clang-format] Preserve include blocks in ObjC Google style

2019-04-04 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Apr  4 07:04:26 2019
New Revision: 357695

URL: http://llvm.org/viewvc/llvm-project?rev=357695=rev
Log:
[clang-format] Preserve include blocks in ObjC Google style

Summary:
r357567 started to regroup include block for Google style; it was meant to apply
only for C++. This patch reverts this for ObjC.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: thakis, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/SortIncludesTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=357695=357694=357695=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu Apr  4 07:04:26 2019
@@ -877,6 +877,11 @@ FormatStyle getGoogleStyle(FormatStyle::
   } else if (Language == FormatStyle::LK_ObjC) {
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.ColumnLimit = 100;
+// "Regroup" doesn't work well for ObjC yet (main header heuristic,
+// relationship between ObjC standard library headers and other heades,
+// #imports, etc.)
+GoogleStyle.IncludeStyle.IncludeBlocks =
+tooling::IncludeStyle::IBS_Preserve;
   }
 
   return GoogleStyle;

Modified: cfe/trunk/unittests/Format/SortIncludesTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/SortIncludesTest.cpp?rev=357695=357694=357695=diff
==
--- cfe/trunk/unittests/Format/SortIncludesTest.cpp (original)
+++ cfe/trunk/unittests/Format/SortIncludesTest.cpp Thu Apr  4 07:04:26 2019
@@ -653,6 +653,18 @@ TEST_F(SortIncludesTest, DoNotOutputRepl
   EXPECT_EQ(Code, sort(Code, "input.h", 0));
 }
 
+
+TEST_F(SortIncludesTest, DoNotRegroupGroupsInGoogleObjCStyle) {
+  FmtStyle = getGoogleStyle(FormatStyle::LK_ObjC);
+
+  EXPECT_EQ("#include \n"
+"#include \n"
+"#include \"a.h\"",
+sort("#include \n"
+ "#include \n"
+ "#include \"a.h\""));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang


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


[PATCH] D60263: [clang-format] Preserve include blocks in ObjC Google style

2019-04-04 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 193699.
krasimir added a comment.

- Add a note about intent


Repository:
  rC Clang

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

https://reviews.llvm.org/D60263

Files:
  lib/Format/Format.cpp
  unittests/Format/SortIncludesTest.cpp


Index: unittests/Format/SortIncludesTest.cpp
===
--- unittests/Format/SortIncludesTest.cpp
+++ unittests/Format/SortIncludesTest.cpp
@@ -653,6 +653,18 @@
   EXPECT_EQ(Code, sort(Code, "input.h", 0));
 }
 
+
+TEST_F(SortIncludesTest, DoNotRegroupGroupsInGoogleObjCStyle) {
+  FmtStyle = getGoogleStyle(FormatStyle::LK_ObjC);
+
+  EXPECT_EQ("#include \n"
+"#include \n"
+"#include \"a.h\"",
+sort("#include \n"
+ "#include \n"
+ "#include \"a.h\""));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -877,6 +877,11 @@
   } else if (Language == FormatStyle::LK_ObjC) {
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.ColumnLimit = 100;
+// "Regroup" doesn't work well for ObjC yet (main header heuristic,
+// relationship between ObjC standard library headers and other heades,
+// #imports, etc.)
+GoogleStyle.IncludeStyle.IncludeBlocks =
+tooling::IncludeStyle::IBS_Preserve;
   }
 
   return GoogleStyle;


Index: unittests/Format/SortIncludesTest.cpp
===
--- unittests/Format/SortIncludesTest.cpp
+++ unittests/Format/SortIncludesTest.cpp
@@ -653,6 +653,18 @@
   EXPECT_EQ(Code, sort(Code, "input.h", 0));
 }
 
+
+TEST_F(SortIncludesTest, DoNotRegroupGroupsInGoogleObjCStyle) {
+  FmtStyle = getGoogleStyle(FormatStyle::LK_ObjC);
+
+  EXPECT_EQ("#include \n"
+"#include \n"
+"#include \"a.h\"",
+sort("#include \n"
+ "#include \n"
+ "#include \"a.h\""));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -877,6 +877,11 @@
   } else if (Language == FormatStyle::LK_ObjC) {
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.ColumnLimit = 100;
+// "Regroup" doesn't work well for ObjC yet (main header heuristic,
+// relationship between ObjC standard library headers and other heades,
+// #imports, etc.)
+GoogleStyle.IncludeStyle.IncludeBlocks =
+tooling::IncludeStyle::IBS_Preserve;
   }
 
   return GoogleStyle;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r357694 - Use a cmake check for linux that actually works.

2019-04-04 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Apr  4 06:54:01 2019
New Revision: 357694

URL: http://llvm.org/viewvc/llvm-project?rev=357694=rev
Log:
Use a cmake check for linux that actually works.

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

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=357694=357693=357694=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Thu Apr  4 06:54:01 2019
@@ -116,7 +116,7 @@ add_clang_library(clangDaemon
   )
 
 add_subdirectory(refactor/tweaks)
-if (LINUX)
+if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
   # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
   add_subdirectory(fuzzer)
 endif()


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


r357693 - [RISCV][NFC] s/riscv32-linux-unknown-elf/riscv32-unknown-linux-gnu in test/Driver/riscv32-toolchain.c

2019-04-04 Thread Alex Bradbury via cfe-commits
Author: asb
Date: Thu Apr  4 06:51:41 2019
New Revision: 357693

URL: http://llvm.org/viewvc/llvm-project?rev=357693=rev
Log:
[RISCV][NFC] s/riscv32-linux-unknown-elf/riscv32-unknown-linux-gnu in 
test/Driver/riscv32-toolchain.c

riscv32-linux-unknown-elf was a weird thing to test for as it doesn't match
the triple used in any common RISC-V toolchain distributions (e.g.
riscv-gnu-toolchain scripts produce riscv{32,64}-unknown-linux-gnu).


Modified:
cfe/trunk/test/Driver/riscv32-toolchain.c

Modified: cfe/trunk/test/Driver/riscv32-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv32-toolchain.c?rev=357693=357692=357693=diff
==
--- cfe/trunk/test/Driver/riscv32-toolchain.c (original)
+++ cfe/trunk/test/Driver/riscv32-toolchain.c Thu Apr  4 06:51:41 2019
@@ -68,7 +68,7 @@
 // CXX-RV32-BAREMETAL-NOSYSROOT-ILP32: 
"{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv32-linux-unknown-elf \
+// RUN:   -target riscv32-unknown-linux-gnu \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV32-LINUX-MULTI-ILP32 %s
@@ -84,7 +84,7 @@
 // C-RV32-LINUX-MULTI-ILP32: 
"-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv32-linux-unknown-elf -march=rv32imafd -mabi=ilp32d \
+// RUN:   -target riscv32-unknown-linux-gnu -march=rv32imafd -mabi=ilp32d \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV32-LINUX-MULTI-ILP32D %s


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


[PATCH] D60263: [clang-format] Preserve include blocks in ObjC Google style

2019-04-04 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir marked an inline comment as done.
krasimir added a comment.

In D60263#1454812 , @thakis wrote:

> Why would we want this to be different in Obj-C and C++?


Only the C++ Style Guide had been updated.
Practically, clang-format would need to be updated to recognize ObjC-specific 
code patterns better before being able to apply regrouping to ObjC code in the 
wild.

I'd expect that sometime in the future the ObjC-style catches up.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60263



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


[PATCH] D60203: Updating Chromium's Java import order

2019-04-04 Thread Sam Maier via Phabricator via cfe-commits
SamMaier added a comment.

In D60203#1453313 , @thakis wrote:

> Thanks!
>
> (Test?)


We currently don't have tests for Chromium's specific Java import order. The 
tests for Java import order use their own order. Should this change?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60203



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


[PATCH] D60263: [clang-format] Preserve include blocks in ObjC Google style

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

Why would we want this to be different in Obj-C and C++?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60263



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


Re: [PATCH] D60263: [clang-format] Preserve include blocks in ObjC Google style

2019-04-04 Thread Nico Weber via cfe-commits
Why would we want this to be different in Obj-C and C++?

On Thu, Apr 4, 2019 at 9:34 AM Krasimir Georgiev via Phabricator via
cfe-commits  wrote:

> krasimir marked 2 inline comments as done.
> krasimir added inline comments.
>
>
> 
> Comment at: lib/Format/Format.cpp:787
>GoogleStyle.IncludeStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
>GoogleStyle.IncludeStyle.IncludeBlocks =
> tooling::IncludeStyle::IBS_Regroup;
>GoogleStyle.IndentCaseLabels = true;
> 
> ioeric wrote:
> > maybe we should also only use regroup for cpp? `regroup` is only
> supported in `sortCppIncludes` after all.
> Yeah, but they are just not used for unrelated languages. This argument
> applies to the other fields in the IncludeStyle group above this. I'd lean
> on keeping this as-is.
>
>
> Repository:
>   rC Clang
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D60263/new/
>
> https://reviews.llvm.org/D60263
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60151: [clang-tidy] Rename llvm checkers to llvm-project

2019-04-04 Thread Don Hinton via Phabricator via cfe-commits
hintonda added a comment.

In D60151#1454741 , @alexfh wrote:

> In D60151#1454105 , @hintonda wrote:
>
> > - Rename llvm directory to llvm_project.
> > - Change llvm- to llvm-project-.
> > - Rename files.
>
>
> Awesome! Thanks for doing this. Could you ensure that the add_new_check.py 
> script still works?


Thanks for mentioning this.  Found a missing rename discovered by 
add_new_check.py which I'll checkin shortly.  However, I'm not sure how best to 
solve a rename issue.

In rename_check.py, module names can't be hyphenated, e.g.:

  190:  old_module = args.old_check_name.split('-')[0]
  191:  new_module = args.new_check_name.split('-')[0]

If we keep this pattern, then "llvm-project" won't work.  It would need to be 
something like "llvmproject" or something else.  Please let me know your 
preference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60151



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


[PATCH] D60263: [clang-format] Preserve include blocks in ObjC Google style

2019-04-04 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir marked 2 inline comments as done.
krasimir added inline comments.



Comment at: lib/Format/Format.cpp:787
   GoogleStyle.IncludeStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
   GoogleStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
   GoogleStyle.IndentCaseLabels = true;

ioeric wrote:
> maybe we should also only use regroup for cpp? `regroup` is only supported in 
> `sortCppIncludes` after all.
Yeah, but they are just not used for unrelated languages. This argument applies 
to the other fields in the IncludeStyle group above this. I'd lean on keeping 
this as-is.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60263



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


[PATCH] D60263: [clang-format] Preserve include blocks in ObjC Google style

2019-04-04 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: lib/Format/Format.cpp:787
   GoogleStyle.IncludeStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
   GoogleStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
   GoogleStyle.IndentCaseLabels = true;

maybe we should also only use regroup for cpp? `regroup` is only supported in 
`sortCppIncludes` after all.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60263



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


[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

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

Per @ioeric's suggestion: why not move the helper into 
`Tooling/Refactoring/ExtendedRange.h`?
If it's in `ToolingRefactoring`, both stencil and transformer can access it.

For external users, a dependency on either `ToolingCore` or 
`ToolingRefactoring` should be fine, since they're fine with a dependency on 
`Tooling` already.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59376



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


[PATCH] D60263: [clang-format] Preserve include blocks in ObjC Google style

2019-04-04 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
krasimir added a reviewer: ioeric.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

r357567 started to regroup include block for Google style; it was meant to apply
only for C++. This patch reverts this for ObjC.


Repository:
  rC Clang

https://reviews.llvm.org/D60263

Files:
  lib/Format/Format.cpp
  unittests/Format/SortIncludesTest.cpp


Index: unittests/Format/SortIncludesTest.cpp
===
--- unittests/Format/SortIncludesTest.cpp
+++ unittests/Format/SortIncludesTest.cpp
@@ -653,6 +653,18 @@
   EXPECT_EQ(Code, sort(Code, "input.h", 0));
 }
 
+
+TEST_F(SortIncludesTest, DoNotRegroupGroupsInGoogleObjCStyle) {
+  FmtStyle = getGoogleStyle(FormatStyle::LK_ObjC);
+
+  EXPECT_EQ("#include \n"
+"#include \n"
+"#include \"a.h\"",
+sort("#include \n"
+ "#include \n"
+ "#include \"a.h\""));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -877,6 +877,8 @@
   } else if (Language == FormatStyle::LK_ObjC) {
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.ColumnLimit = 100;
+GoogleStyle.IncludeStyle.IncludeBlocks =
+tooling::IncludeStyle::IBS_Preserve;
   }
 
   return GoogleStyle;


Index: unittests/Format/SortIncludesTest.cpp
===
--- unittests/Format/SortIncludesTest.cpp
+++ unittests/Format/SortIncludesTest.cpp
@@ -653,6 +653,18 @@
   EXPECT_EQ(Code, sort(Code, "input.h", 0));
 }
 
+
+TEST_F(SortIncludesTest, DoNotRegroupGroupsInGoogleObjCStyle) {
+  FmtStyle = getGoogleStyle(FormatStyle::LK_ObjC);
+
+  EXPECT_EQ("#include \n"
+"#include \n"
+"#include \"a.h\"",
+sort("#include \n"
+ "#include \n"
+ "#include \"a.h\""));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -877,6 +877,8 @@
   } else if (Language == FormatStyle::LK_ObjC) {
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.ColumnLimit = 100;
+GoogleStyle.IncludeStyle.IncludeBlocks =
+tooling::IncludeStyle::IBS_Preserve;
   }
 
   return GoogleStyle;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r357690 - [clangd] Test #import directive go-to-definition. NFC

2019-04-04 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Apr  4 06:09:02 2019
New Revision: 357690

URL: http://llvm.org/viewvc/llvm-project?rev=357690=rev
Log:
[clangd] Test #import directive go-to-definition. NFC

Modified:
clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp?rev=357690=357689=357690=diff
==
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp Thu Apr  4 06:09:02 
2019
@@ -1237,6 +1237,18 @@ TEST(GoToInclude, All) {
   Locations = runLocateSymbolAt(Server, FooCpp, SourceAnnotations.point("7"));
   ASSERT_TRUE(bool(Locations)) << "locateSymbolAt returned an error";
   EXPECT_THAT(*Locations, ElementsAre(Sym("foo.h", 
HeaderAnnotations.range(;
+
+  // Objective C #import directive.
+  Annotations ObjC(R"objc(
+  #import "^foo.h"
+  )objc");
+  auto FooM = testPath("foo.m");
+  FS.Files[FooM] = ObjC.code();
+
+  Server.addDocument(FooM, ObjC.code());
+  Locations = runLocateSymbolAt(Server, FooM, ObjC.point());
+  ASSERT_TRUE(bool(Locations)) << "locateSymbolAt returned an error";
+  EXPECT_THAT(*Locations, ElementsAre(Sym("foo.h", 
HeaderAnnotations.range(;
 }
 
 TEST(LocateSymbol, WithPreamble) {


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


[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

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

In D59376#1454748 , @ymandel wrote:

> I propose that I create a new library in Core with `getExtendedRange()` and 
> remove it from FixIt. The other  utility functions that I need will also go 
> there.  We can separately investigate moving the remaining pieces of FixIt 
> into Core.


Moving this to `Core` makes sense to me, the only concern that I have is that 
it's actually a small and focused library as it stands today and adding utility 
functions to it would seem to cause some chaos.
But it's fine as long as the maintainers of the library are ok with this. I'll 
ask around to find out who's actually responsible for the library and get back 
to you...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59376



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


[clang-tools-extra] r357689 - [clangd] Stop passing around PCHContainerOperations, just create it in place. NFC

2019-04-04 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Apr  4 05:56:03 2019
New Revision: 357689

URL: http://llvm.org/viewvc/llvm-project?rev=357689=rev
Log:
[clangd] Stop passing around PCHContainerOperations, just create it in place. 
NFC

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/ClangdUnit.h
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/CodeComplete.h
clang-tools-extra/trunk/clangd/Compiler.cpp
clang-tools-extra/trunk/clangd/Compiler.h
clang-tools-extra/trunk/clangd/TUScheduler.cpp
clang-tools-extra/trunk/clangd/TUScheduler.h
clang-tools-extra/trunk/clangd/index/Background.cpp
clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
clang-tools-extra/trunk/unittests/clangd/HeadersTests.cpp
clang-tools-extra/trunk/unittests/clangd/TestTU.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=357689=357688=357689=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Thu Apr  4 05:56:03 2019
@@ -114,7 +114,6 @@ ClangdServer::ClangdServer(const GlobalC
   ClangTidyOptProvider(Opts.ClangTidyOptProvider),
   SuggestMissingIncludes(Opts.SuggestMissingIncludes),
   WorkspaceRoot(Opts.WorkspaceRoot),
-  PCHs(std::make_shared()),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
   // parsed file and rebuild the file index synchronously each time an AST
   // is parsed.
@@ -176,11 +175,8 @@ void ClangdServer::codeComplete(PathRef
   if (!CodeCompleteOpts.Index) // Respect overridden index.
 CodeCompleteOpts.Index = Index;
 
-  // Copy PCHs to avoid accessing this->PCHs concurrently
-  std::shared_ptr PCHs = this->PCHs;
   auto FS = FSProvider.getFileSystem();
-
-  auto Task = [PCHs, Pos, FS, CodeCompleteOpts,
+  auto Task = [Pos, FS, CodeCompleteOpts,
this](Path File, Callback CB,
  llvm::Expected IP) {
 if (!IP)
@@ -200,7 +196,7 @@ void ClangdServer::codeComplete(PathRef
 // FIXME(ibiryukov): even if Preamble is non-null, we may want to check
 // both the old and the new version in case only one of them matches.
 CodeCompleteResult Result = clangd::codeComplete(
-File, IP->Command, IP->Preamble, IP->Contents, Pos, FS, PCHs,
+File, IP->Command, IP->Preamble, IP->Contents, Pos, FS,
 CodeCompleteOpts, SpecFuzzyFind ? SpecFuzzyFind.getPointer() : 
nullptr);
 {
   clang::clangd::trace::Span Tracer("Completion results callback");
@@ -225,17 +221,16 @@ void ClangdServer::codeComplete(PathRef
 void ClangdServer::signatureHelp(PathRef File, Position Pos,
  Callback CB) {
 
-  auto PCHs = this->PCHs;
   auto FS = FSProvider.getFileSystem();
   auto *Index = this->Index;
-  auto Action = [Pos, FS, PCHs, Index](Path File, Callback CB,
-   llvm::Expected IP) {
+  auto Action = [Pos, FS, Index](Path File, Callback CB,
+ llvm::Expected IP) {
 if (!IP)
   return CB(IP.takeError());
 
 auto PreambleData = IP->Preamble;
 CB(clangd::signatureHelp(File, IP->Command, PreambleData, IP->Contents, 
Pos,
- FS, PCHs, Index));
+ FS, Index));
   };
 
   // Unlike code completion, we wait for an up-to-date preamble here.

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=357689=357688=357689=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Thu Apr  4 05:56:03 2019
@@ -36,8 +36,6 @@
 #include 
 
 namespace clang {
-class PCHContainerOperations;
-
 namespace clangd {
 
 // FIXME: find a better name.
@@ -300,7 +298,6 @@ private:
   mutable std::mutex CachedCompletionFuzzyFindRequestMutex;
 
   llvm::Optional WorkspaceRoot;
-  std::shared_ptr PCHs;
   // WorkScheduler has to be the last member, because its destructor has to be
   // called before all other members to stop the worker thread that references
   // ClangdServer.

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=357689=357688=357689=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Thu Apr  4 05:56:03 2019
@@ -32,6 +32,7 @@
 #include 

[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

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

In D59376#1454617 , @ilya-biryukov 
wrote:

> Keeping it **only** in the cpp file also LG if we don't plan to have other 
> usages for now, but please remove the version from `FixIt.h`


The Stencil library will need this as well and I've heard from another user 
who's already using this (a standalone tool, not in clang), so it seems to have 
a general value.  Might the fixit library belong in Core?  I have a whole bunch 
more utility functions coming along, so we need a place for them as well.

I propose that I create a new library in Core with `getExtendedRange()` and 
remove it from FixIt. The other  utility functions that I need will also go 
there.  We can separately investigate moving the remaining pieces of FixIt into 
Core.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59376



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


[PATCH] D60151: [clang-tidy] Rename llvm checkers to llvm-project

2019-04-04 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In D60151#1454105 , @hintonda wrote:

> - Rename llvm directory to llvm_project.
> - Change llvm- to llvm-project-.
> - Rename files.


Awesome! Thanks for doing this. Could you ensure that the add_new_check.py 
script still works?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60151



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


[PATCH] D60126: [clangd] Use identifiers in file as completion candidates when build is not ready.

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



Comment at: clangd/CodeComplete.cpp:1136
+std::unique_ptr
+indexIdentifiers(llvm::StringRef FileName, llvm::StringRef Content,
+ const format::FormatStyle ) {

as discussed offline, I love the lexer approach but returning it as an index 
seems like the wrong level of abstraction.
These are just strings, and if we want to tweak e.g. the scoring or merging of 
these we'll be in a better position to do so if we don't pretend they have 
Symbol semantics (their own signals, ids, etc).
So I'd suggest this fn should return something like `StringSet<>` or 
`StringMap` for counts.

Can we move it to `SourceCode.h` too?



Comment at: clangd/CodeComplete.cpp:1136
+std::unique_ptr
+indexIdentifiers(llvm::StringRef FileName, llvm::StringRef Content,
+ const format::FormatStyle ) {

sammccall wrote:
> as discussed offline, I love the lexer approach but returning it as an index 
> seems like the wrong level of abstraction.
> These are just strings, and if we want to tweak e.g. the scoring or merging 
> of these we'll be in a better position to do so if we don't pretend they have 
> Symbol semantics (their own signals, ids, etc).
> So I'd suggest this fn should return something like `StringSet<>` or 
> `StringMap` for counts.
> 
> Can we move it to `SourceCode.h` too?
I don't think we need FileName as a parameter - it shouldn't affect the return 
value, so we can just use a dummy value.



Comment at: clangd/CodeComplete.cpp:1209
+
+  // The following fields are initialized once Sema runs or run without 
compile.
+  CodeCompletionContext::Kind CCContextKind = CodeCompletionContext::CCC_Other;

I'm not sure these changes (mostly to comment formatting) improve clarity.
I think it would be enough to add a comment inside the top of runWithoutCompile 
saying `// Fill in fields normally set by runWithSema()` or so



Comment at: clangd/CodeComplete.cpp:1212
+  llvm::Optional Filter;
+  Range TextEditRange;
+  std::vector QueryScopes;

ReplacedRange?



Comment at: clangd/CodeComplete.cpp:1318
+  CodeCompleteResult
+  runWithoutCompile(llvm::StringRef Content, Position Pos,
+llvm::IntrusiveRefCntPtr VFS) && {

runWithoutSema maybe? - compile is a fine name but this file calls this concept 
sema for whatever reason



Comment at: clangd/CodeComplete.cpp:1320
+llvm::IntrusiveRefCntPtr VFS) && {
+auto CompletionFilter = speculateCompletionFilter(Content, Pos);
+if (!CompletionFilter) {

hmm, this function should likely also move to SourceCode, use Offset instead of 
Position, and move to SourceCode.h. But probably a different patch.



Comment at: clangd/CodeComplete.cpp:1341
+
+// Carve out the typed filter from the content so that we don't treat it as
+// an identifier.

you could just erase the typed filter from the suggestion list.
(It may be a valid word spelled elsewhere, but there's no point suggesting it)



Comment at: clangd/CodeComplete.cpp:1357
+auto Results = queryIndex(*Idx);
+return toCodeCompleteResult(mergeResults(/*SemaResults=*/{}, Results));
+  }

I suspect you want to pass the filtered strings through to mergeResults and 
have it/CompletionCandidate do the scoring.



Comment at: clangd/CodeComplete.h:241
+CodeCompleteResult
+codeCompleteNoCompile(PathRef FileName, llvm::StringRef Content, Position Pos,
+  llvm::IntrusiveRefCntPtr VFS,

It seems a little odd to have a different entrypoint here.
Could we simply indicate this with Preamble=nullptr?

It seems it might even make sense to use the same speculative fuzzyfind?
So I think PCHContainerOperations would be the only odd one out. I'm going to 
send a patch to remove that anyway :-)


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60126



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

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



Comment at: clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.cpp:18
+
+AST_MATCHER(Expr, isMacroID) { return Node.getExprLoc().isMacroID(); }
+} // namespace ast_matchers

hintonda wrote:
> aaron.ballman wrote:
> > hintonda wrote:
> > > @aaron.ballman:  This matcher seems genuinely useful.  What do you think 
> > > about moving it to ASTMatchers.h? 
> > I think that adding something like this might be a good idea. We don't have 
> > any notion of source locations in the AST matching syntax currently, and 
> > I'm not certain whether that's a good thing or not here. I'm mildly 
> > uncomfortable that this matcher operates on an `Expr` but then internally 
> > uses a source location from that expression and I wonder if we would rather 
> > introduce source location matching. For instance, what if the user cares 
> > about the difference between `getExprLoc()` and `getBeginLoc()` for some 
> > reason?
> Well, you can attach it to whatever you want, so I'm not sure that's a 
> problem.  Alternatively, you have to check each location yourself.  In my 
> case, that was multiple places, so putting it in the matcher cleaned up the 
> code.
> 
> I need to verify it, but it seems that it triggered when any macros were in 
> the range, but I need to look closer into that to understand the behavior.   
> I'll check it out and get back to you.
> Well, you can attach it to whatever you want, so I'm not sure that's a 
> problem. 

How does a caller of this AST matcher indicate that they want it to match on 
`Node.getBeingLoc().isMacroID()` instead of what's written now? If the answer 
is "they write a different matcher", then that's what I think could be a 
problem. There's a lot of ways to get a source location (and a lot of different 
kinds of source locations), and I think matching on those can be very useful 
functionality. So I think the idea of the matcher is good, I'm just not certain 
whether we want it to look like `AST_MATCHER(Expr, isMacroID);` or 
`AST_MATCHER(SourceLocation, isMacroID);` or something else.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59802



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

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



Comment at: 
clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.cpp:145
+
+diag(MatchedDecl->getBeginLoc(), "use dyn_cast_or_null")
+<< FixItHint::CreateReplacement(SourceRange(MatchedDecl->getBeginLoc(),

hintonda wrote:
> hintonda wrote:
> > aaron.ballman wrote:
> > > hintonda wrote:
> > > > aaron.ballman wrote:
> > > > > hintonda wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > This diagnostic doesn't tell the user what they've done wrong 
> > > > > > > with the code or why this is a better choice.
> > > > > > Yes, but I'm not yet sure what it should say.  Was sorta hoping for 
> > > > > > a suggestion.  
> > > > > Do you have any evidence that this situation happens in practice? I 
> > > > > kind of feel like this entire branch could be eliminated from this 
> > > > > patch unless it actually catches problems that happen.
> > > > Yes, here are a few from clang/lib -- let me know if you think it's 
> > > > worth it or not to keep this:
> > > > 
> > > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > > >   FileOffset: 305293
> > > >   FilePath: 
> > > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaTemplate.cpp
> > > >   Message: method 'getAsTemplateDecl' is called twice and could be 
> > > > expensive
> > > >   Replacements:
> > > >   - FilePath: 
> > > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaTemplate.cpp
> > > > Length: 93
> > > > Offset: 305293
> > > > ReplacementText: 
> > > > dyn_cast_or_null(Name.getAsTemplateDecl())
> > > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > > >   FileOffset: 153442
> > > >   FilePath: 
> > > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/ASTContext.cpp
> > > >   Message: method 'getAsTemplateDecl' is called twice and could be 
> > > > expensive
> > > >   Replacements:
> > > >   - FilePath: 
> > > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/ASTContext.cpp
> > > > Length: 92
> > > > Offset: 153442
> > > > ReplacementText: 
> > > > dyn_cast_or_null(Template.getAsTemplateDecl())
> > > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > > >   FileOffset: 97556
> > > >   FilePath: 
> > > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/Expr.cpp
> > > >   Message: method 'getMethodDecl' is called twice and could be expensive
> > > >   Replacements:
> > > >   - FilePath: 
> > > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/Expr.cpp
> > > > Length: 68
> > > > Offset: 97556
> > > > ReplacementText: 
> > > > dyn_cast_or_null(MCE->getMethodDecl())
> > > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > > >   FileOffset: 301950
> > > >   FilePath: 
> > > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaInit.cpp
> > > >   Message: method 'get' is called twice and could be expensive
> > > >   Replacements:
> > > >   - FilePath: 
> > > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaInit.cpp
> > > > Length: 49
> > > > Offset: 301950
> > > > ReplacementText: dyn_cast_or_null(CurInit.get())
> > > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > > >   FileOffset: 14335
> > > >   FilePath: 
> > > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > > >   Message: method 'operator bool' is called twice and could be expensive
> > > >   Replacements:
> > > >   - FilePath: 
> > > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > > > Length: 57
> > > > Offset: 14335
> > > > ReplacementText: dyn_cast_or_null(B->getTerminator())
> > > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > > >   FileOffset: 15997
> > > >   FilePath: 
> > > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > > >   Message: method 'operator bool' is called twice and could be expensive
> > > >   Replacements:
> > > >   - FilePath: 
> > > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > > > Length: 55
> > > > Offset: 15997
> > > > ReplacementText: dyn_cast_or_null(B.getTerminator())
> > > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > > >   FileOffset: 9492
> > > >   FilePath: 
> > > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
> > > >   Message: method 'sexpr' is called twice and could be expensive
> > > >   Replacements:
> > > >   - FilePath: 
> > > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
> > > > Length: 39
> > > > Offset: 9492
> > > > ReplacementText: dyn_cast_or_null(sexpr())
> > > > - 

[PATCH] D60258: [CodeComplete] Fix crash when completing ObjC block parameter with a broken type

2019-04-04 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL357686: [CodeComplete] Fix crash when completing ObjC block 
parameter with a broken type (authored by sammccall, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60258

Files:
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/test/Index/complete-blocks.m


Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -2605,6 +2605,11 @@
 FormatFunctionParameter(const PrintingPolicy , const ParmVarDecl *Param,
 bool SuppressName = false, bool SuppressBlock = false,
 Optional> ObjCSubsts = None) {
+  // Params are unavailable in FunctionTypeLoc if the FunctionType is invalid.
+  // It would be better to pass in the param Type, which is usually avaliable.
+  // But this case is rare, so just pretend we fell back to int as elsewhere.
+  if (!Param)
+return "int";
   bool ObjCMethodParam = isa(Param->getDeclContext());
   if (Param->getType()->isDependentType() ||
   !Param->getType()->isBlockPointerType()) {
Index: cfe/trunk/test/Index/complete-blocks.m
===
--- cfe/trunk/test/Index/complete-blocks.m
+++ cfe/trunk/test/Index/complete-blocks.m
@@ -50,6 +50,15 @@
   [o method7:0];
 }
 
+// Crash regression test. Param info for broken function types isn't available.
+typedef UnresolvedType *(^XXX)(float);
+@interface Foo
+-(void) foo:(XXX)arg;
+@end
+void testUnresolved(Foo* f) {
+  [f foo:0];
+}
+
 // RUN: c-index-test -code-completion-at=%s:8:1 %s | FileCheck 
-check-prefix=CHECK-CC1 %s
 // CHECK-CC1: FunctionDecl:{ResultType void}{TypedText f}{LeftParen 
(}{Placeholder ^int(int x, int y)block}{RightParen )} (50)
 // CHECK-CC1: FunctionDecl:{ResultType void}{TypedText g}{LeftParen 
(}{Placeholder ^(float f, double d)b}{RightParen )} (50)
@@ -74,3 +83,6 @@
 // CHECK-CC7: FunctionDecl:{ResultType void}{TypedText f2}{LeftParen 
(}{Placeholder ^int(int x, int y)block}{RightParen )} (50)
 // RUN: c-index-test -code-completion-at=%s:50:6 %s | FileCheck 
-check-prefix=CHECK-CC8 %s
 // CHECK-CC8: ObjCInstanceMethodDecl:{ResultType id}{TypedText 
method7:}{Placeholder ^int(int x, int y)b} (35)
+
+// RUN: c-index-test -code-completion-at=%s:59:6 %s | FileCheck 
-check-prefix=CHECK-CC9 %s
+// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType void}{TypedText 
foo:}{Placeholder ^int *(int)arg} (35)


Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -2605,6 +2605,11 @@
 FormatFunctionParameter(const PrintingPolicy , const ParmVarDecl *Param,
 bool SuppressName = false, bool SuppressBlock = false,
 Optional> ObjCSubsts = None) {
+  // Params are unavailable in FunctionTypeLoc if the FunctionType is invalid.
+  // It would be better to pass in the param Type, which is usually avaliable.
+  // But this case is rare, so just pretend we fell back to int as elsewhere.
+  if (!Param)
+return "int";
   bool ObjCMethodParam = isa(Param->getDeclContext());
   if (Param->getType()->isDependentType() ||
   !Param->getType()->isBlockPointerType()) {
Index: cfe/trunk/test/Index/complete-blocks.m
===
--- cfe/trunk/test/Index/complete-blocks.m
+++ cfe/trunk/test/Index/complete-blocks.m
@@ -50,6 +50,15 @@
   [o method7:0];
 }
 
+// Crash regression test. Param info for broken function types isn't available.
+typedef UnresolvedType *(^XXX)(float);
+@interface Foo
+-(void) foo:(XXX)arg;
+@end
+void testUnresolved(Foo* f) {
+  [f foo:0];
+}
+
 // RUN: c-index-test -code-completion-at=%s:8:1 %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder ^int(int x, int y)block}{RightParen )} (50)
 // CHECK-CC1: FunctionDecl:{ResultType void}{TypedText g}{LeftParen (}{Placeholder ^(float f, double d)b}{RightParen )} (50)
@@ -74,3 +83,6 @@
 // CHECK-CC7: FunctionDecl:{ResultType void}{TypedText f2}{LeftParen (}{Placeholder ^int(int x, int y)block}{RightParen )} (50)
 // RUN: c-index-test -code-completion-at=%s:50:6 %s | FileCheck -check-prefix=CHECK-CC8 %s
 // CHECK-CC8: ObjCInstanceMethodDecl:{ResultType id}{TypedText method7:}{Placeholder ^int(int x, int y)b} (35)
+
+// RUN: c-index-test -code-completion-at=%s:59:6 %s | FileCheck -check-prefix=CHECK-CC9 %s
+// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType void}{TypedText foo:}{Placeholder ^int *(int)arg} (35)
___

r357686 - [CodeComplete] Fix crash when completing ObjC block parameter with a broken type

2019-04-04 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Apr  4 04:34:18 2019
New Revision: 357686

URL: http://llvm.org/viewvc/llvm-project?rev=357686=rev
Log:
[CodeComplete] Fix crash when completing ObjC block parameter with a broken type

Summary:
The fix isn't great, but it's hard to fix properly because the completion
code sensibly uses ParmVarDecl to represent parameters, but the AST-building
code sensibly doesn't synthesize them if the type is broken.
Also this case is apparently really rare, so it's probably not worth bending
over backwards for.

Reviewers: ilya-biryukov

Subscribers: javed.absar, kristof.beyls, arphaman, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/Index/complete-blocks.m

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=357686=357685=357686=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu Apr  4 04:34:18 2019
@@ -2605,6 +2605,11 @@ static std::string
 FormatFunctionParameter(const PrintingPolicy , const ParmVarDecl *Param,
 bool SuppressName = false, bool SuppressBlock = false,
 Optional> ObjCSubsts = None) {
+  // Params are unavailable in FunctionTypeLoc if the FunctionType is invalid.
+  // It would be better to pass in the param Type, which is usually avaliable.
+  // But this case is rare, so just pretend we fell back to int as elsewhere.
+  if (!Param)
+return "int";
   bool ObjCMethodParam = isa(Param->getDeclContext());
   if (Param->getType()->isDependentType() ||
   !Param->getType()->isBlockPointerType()) {

Modified: cfe/trunk/test/Index/complete-blocks.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-blocks.m?rev=357686=357685=357686=diff
==
--- cfe/trunk/test/Index/complete-blocks.m (original)
+++ cfe/trunk/test/Index/complete-blocks.m Thu Apr  4 04:34:18 2019
@@ -50,6 +50,15 @@ void test_f2(I1 *o) {
   [o method7:0];
 }
 
+// Crash regression test. Param info for broken function types isn't available.
+typedef UnresolvedType *(^XXX)(float);
+@interface Foo
+-(void) foo:(XXX)arg;
+@end
+void testUnresolved(Foo* f) {
+  [f foo:0];
+}
+
 // RUN: c-index-test -code-completion-at=%s:8:1 %s | FileCheck 
-check-prefix=CHECK-CC1 %s
 // CHECK-CC1: FunctionDecl:{ResultType void}{TypedText f}{LeftParen 
(}{Placeholder ^int(int x, int y)block}{RightParen )} (50)
 // CHECK-CC1: FunctionDecl:{ResultType void}{TypedText g}{LeftParen 
(}{Placeholder ^(float f, double d)b}{RightParen )} (50)
@@ -74,3 +83,6 @@ void test_f2(I1 *o) {
 // CHECK-CC7: FunctionDecl:{ResultType void}{TypedText f2}{LeftParen 
(}{Placeholder ^int(int x, int y)block}{RightParen )} (50)
 // RUN: c-index-test -code-completion-at=%s:50:6 %s | FileCheck 
-check-prefix=CHECK-CC8 %s
 // CHECK-CC8: ObjCInstanceMethodDecl:{ResultType id}{TypedText 
method7:}{Placeholder ^int(int x, int y)b} (35)
+
+// RUN: c-index-test -code-completion-at=%s:59:6 %s | FileCheck 
-check-prefix=CHECK-CC9 %s
+// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType void}{TypedText 
foo:}{Placeholder ^int *(int)arg} (35)


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


  1   2   >