[PATCH] D46140: [coroutines] Add std::experimental::task type

2019-04-08 Thread Lewis Baker via Phabricator via cfe-commits
lewissbaker marked an inline comment as done.
lewissbaker added a comment.

Gentle ping.

Is there anything else people would like to see changed?


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D46140



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


[PATCH] D60417: [libunwind] Add support for ARMv7-M architecture which uses the Thumb 2 ISA (unified syntax)

2019-04-08 Thread Jérémie Faucher-Goulet via Phabricator via cfe-commits
jeremfg added a comment.

In D60417#1458778 , @mstorsjo wrote:

> The change looks sensible to me, but should we maybe even skip the `#if` 
> altogether? If the files uses unified syntax and can't be parsed in thumb 
> mode otherwise, there's maybe no need for conditionals at all?


I'm no expert but I just read that UAL (Unified Assembler Language), while 
being backward compatible with the old ARM syntax, is **not** compatible with 
the previous Thumb syntax.
http://downloads.ti.com/docs/esd/SPNU118/unified-assembly-language-syntax-support-spnu118.html

But again, perhaps it doesn't matter in the specific case that concerns us 
here? I guess it depends on whether the code in the ###if 
!defined(__ARM_ARCH_ISA_ARM) && __ARM_ARCH_ISA_THUMB == 1## condition that 
follows contains only valid UAL syntax as well. Which I am not qualified to 
confirm or not.
If somebody can confirm that my understanding is correct, I could try and see 
if GCC throws an error during compilation for the ARMv4T, ARMv5T* and ARMv6 
architectures which only supports the legacy Thumb-1, but I don't trust myself 
enough to rely on my own tests alone and my weak understanding to ensure I 
won't break support for current Thumb-1 users. Hopefully somebody else can 
pitch in to confirm (or infirm) my understanding.

If that's all UAL-compatible instructions, then yes I think my ###if## could be 
removed and only the ##.syntax unified## should be kept. At least, that's how I 
understand it. I could be wrong...
Perhaps some assemblers simply refuses the **.sytanx unified** directive 
altogether when targeting legacy Thumb-1 architectures, making this all a moot 
discussion?


Repository:
  rUNW libunwind

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

https://reviews.llvm.org/D60417



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


[PATCH] D59987: Add support for detection of devtoolset-8

2019-04-08 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

In D59987#1454543 , @rpopescu wrote:

> In D59987#1454422 , @tstellar wrote:
>
> > Do you have commit access?
>
>
> Hi Tom, I don't think that I do. I have created the account just before 
> submitting the patch. Should I request it, or?


I'll commit it for you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59987



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


[PATCH] D60432: [clang][ASTContext] Simplify caching for declaration-related comments

2019-04-08 Thread Jan Korous via Phabricator via cfe-commits
jkorous created this revision.
jkorous added reviewers: gribozavr, arphaman, dexonsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- I assume we can cache comments for canonical declarations only, not for every 
redeclaration.
- Caching that we didn't find comments seems to be unnecessary since we try to 
search for comment again again next time if we find this data in cache.
  - We might implement proper cache invalidation in the future and get back to 
using this information.
- Origin of comment (directly from declaration / from some redeclaration) seems 
to not be used anywhere.

I plan to do some performance testing before committing but like to have some 
feedback first.

BTW there's another cache for comments in the `ASTContext` - `ParsedComments`. 
We could try to experiment with different caching approaches to see how it 
affects performance - maybe caching `mapping from canonical declarations to raw 
comments` and separately caching `mapping from raw comments to full comments`.


Repository:
  rC Clang

https://reviews.llvm.org/D60432

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp

Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -369,71 +369,43 @@
 const Decl *D,
 const Decl **OriginalDecl) const {
   D = adjustDeclToTemplate(D);
+  const Decl* CanonicalDecl = D->getCanonicalDecl();
 
   // Check whether we have cached a comment for this declaration already.
   {
 llvm::DenseMap::iterator Pos =
-RedeclComments.find(D);
+RedeclComments.find(CanonicalDecl);
 if (Pos != RedeclComments.end()) {
   const RawCommentAndCacheFlags  = Pos->second;
-  if (Raw.getKind() != RawCommentAndCacheFlags::NoCommentInDecl) {
-if (OriginalDecl)
-  *OriginalDecl = Raw.getOriginalDecl();
-return Raw.getRaw();
-  }
+  if (OriginalDecl)
+*OriginalDecl = Raw.getOriginalDecl();
+  return Raw.getRaw();
 }
   }
 
-  // Search for comments attached to declarations in the redeclaration chain.
-  const RawComment *RC = nullptr;
-  const Decl *OriginalDeclForRC = nullptr;
+  // We don't have comment for D in cache - search for any comment attached to
+  // declarations in the redeclaration chain.
   for (auto I : D->redecls()) {
-llvm::DenseMap::iterator Pos =
-RedeclComments.find(I);
-if (Pos != RedeclComments.end()) {
-  const RawCommentAndCacheFlags  = Pos->second;
-  if (Raw.getKind() != RawCommentAndCacheFlags::NoCommentInDecl) {
-RC = Raw.getRaw();
-OriginalDeclForRC = Raw.getOriginalDecl();
-break;
-  }
-} else {
-  RC = getRawCommentForDeclNoCache(I);
-  OriginalDeclForRC = I;
-  RawCommentAndCacheFlags Raw;
-  if (RC) {
-// Call order swapped to work around ICE in VS2015 RTM (Release Win32)
-// https://connect.microsoft.com/VisualStudio/feedback/details/1741530
-Raw.setKind(RawCommentAndCacheFlags::FromDecl);
-Raw.setRaw(RC);
-  } else
-Raw.setKind(RawCommentAndCacheFlags::NoCommentInDecl);
-  Raw.setOriginalDecl(I);
-  RedeclComments[I] = Raw;
-  if (RC)
-break;
-}
-  }
-
-  // If we found a comment, it should be a documentation comment.
-  assert(!RC || RC->isDocumentation() || LangOpts.CommentOpts.ParseAllComments);
+if (const RawComment *RC = getRawCommentForDeclNoCache(I)) {
+  // If we find a comment, it should be a documentation comment.
+  assert(RC->isDocumentation() || LangOpts.CommentOpts.ParseAllComments);
 
-  if (OriginalDecl)
-*OriginalDecl = OriginalDeclForRC;
+  if (OriginalDecl)
+*OriginalDecl = I;
 
-  // Update cache for every declaration in the redeclaration chain.
-  RawCommentAndCacheFlags Raw;
-  Raw.setRaw(RC);
-  Raw.setKind(RawCommentAndCacheFlags::FromRedecl);
-  Raw.setOriginalDecl(OriginalDeclForRC);
+  RawCommentAndCacheFlags NewCachedComment;
+  // Call order swapped to work around ICE in VS2015 RTM (Release Win32)
+  // https://connect.microsoft.com/VisualStudio/feedback/details/1741530
+  NewCachedComment.setRaw(RC);
+  NewCachedComment.setOriginalDecl(I);
+  RedeclComments[CanonicalDecl] = NewCachedComment;
 
-  for (auto I : D->redecls()) {
-RawCommentAndCacheFlags  = RedeclComments[I];
-if (R.getKind() == RawCommentAndCacheFlags::NoCommentInDecl)
-  R = Raw;
+  return RC;
+}
   }
 
-  return RC;
+  // We didn't find any comment attached to any redeclaration of D.
+  return nullptr;
 }
 
 static void addRedeclaredMethods(const ObjCMethodDecl *ObjCMethod,
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ 

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

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

- Converted class to struct+function as Tim suggested.


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] D60429: [AArch64][PowerPC][Driver] Allow setting crypto feature through -mcrypto.

2019-04-08 Thread Tiancong Wang via Phabricator via cfe-commits
tcwang created this revision.
tcwang added a project: LLVM.
Herald added subscribers: llvm-commits, cfe-commits, jsji, MaskRay, kbarton, 
kristof.beyls, arichardson, javed.absar, nemanjai, emaste.
Herald added a reviewer: espindola.
Herald added a project: clang.

This enables -mcrypto and -mno-crypto to enable/disable crypto feature to Clang.
Before this change, -m(no-)crypto is exclusively for Power8. We want to add 
this feature
to ARM/AArch64 as well. With -mcrypto is specified, +crypto will be passed as
a feature to ARM/AArch64/Power8, and -mno-cypto will pass -crypto.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60429

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/PPC.cpp
  clang/lib/Driver/ToolChains/Arch/PPC.h
  clang/test/Driver/aarch64-crypto.c
  clang/test/Driver/armv8-crypto.c
  lld/ELF/CallGraphSort.cpp
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/Options.td
  lld/test/ELF/cgprofile-print.s
  lld/test/ELF/cgprofile-reproduce.s

Index: lld/test/ELF/cgprofile-reproduce.s
===
--- /dev/null
+++ lld/test/ELF/cgprofile-reproduce.s
@@ -0,0 +1,42 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "A B 5" > %t.call_graph
+# RUN: echo "B C 50" >> %t.call_graph
+# RUN: echo "C D 40" >> %t.call_graph
+# RUN: echo "D B 10" >> %t.call_graph
+# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2 --print-symbol-order=%t3
+# RUN: ld.lld -e A %t --symbol-ordering-file %t3 -o %t2
+# RUN: llvm-readobj -symbols %t2 | FileCheck %s	
+
+# CHECK:  Name: A
+# CHECK-NEXT: Value: 0x201003
+# CHECK:  Name: B
+# CHECK-NEXT: Value: 0x201000
+# CHECK:  Name: C
+# CHECK-NEXT: Value: 0x201001
+# CHECK:  Name: D
+# CHECK-NEXT: Value: 0x201002
+
+.section.text.A,"ax",@progbits
+.globl  A
+A:
+ nop
+
+.section.text.B,"ax",@progbits
+.globl  B
+B:
+ nop
+
+.section.text.C,"ax",@progbits
+.globl  C
+C:
+ nop
+
+.section.text.D,"ax",@progbits
+.globl  D
+D:
+ nop
+
+
+
Index: lld/test/ELF/cgprofile-print.s
===
--- /dev/null
+++ lld/test/ELF/cgprofile-print.s
@@ -0,0 +1,37 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "A B 5" > %t.call_graph
+# RUN: echo "B C 50" >> %t.call_graph
+# RUN: echo "C D 40" >> %t.call_graph
+# RUN: echo "D B 10" >> %t.call_graph
+# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2 --print-symbol-order=%t3
+# RUN: FileCheck %s --input-file %t3
+
+# CHECK: B
+# CHECK-NEXT: C
+# CHECK-NEXT: D
+# CHECK-NEXT: A
+
+.section.text.A,"ax",@progbits
+.globl  A
+A:
+ nop
+
+.section.text.B,"ax",@progbits
+.globl  B
+B:
+ nop
+
+.section.text.C,"ax",@progbits
+.globl  C
+C:
+ nop
+
+.section.text.D,"ax",@progbits
+.globl  D
+D:
+ nop
+
+
+
Index: lld/ELF/Options.td
===
--- lld/ELF/Options.td
+++ lld/ELF/Options.td
@@ -274,6 +274,10 @@
 "List identical folded sections",
 "Do not list identical folded sections (default)">;
 
+defm print_symbol_order:
+  Eq<"print-symbol-order",
+  "Print a symbol order specified by --call-graph-ordering-file into the speficied file">;
+  
 def pop_state: F<"pop-state">,
   HelpText<"Undo the effect of -push-state">;
 
Index: lld/ELF/Driver.cpp
===
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -828,6 +828,8 @@
   Args.hasFlag(OPT_print_icf_sections, OPT_no_print_icf_sections, false);
   Config->PrintGcSections =
   Args.hasFlag(OPT_print_gc_sections, OPT_no_print_gc_sections, false);
+  Config->PrintSymbolOrder =
+  Args.getLastArgValue(OPT_print_symbol_order);
   Config->Rpath = getRpath(Args);
   Config->Relocatable = Args.hasArg(OPT_relocatable);
   Config->SaveTemps = Args.hasArg(OPT_save_temps);
Index: lld/ELF/Config.h
===
--- lld/ELF/Config.h
+++ lld/ELF/Config.h
@@ -101,6 +101,7 @@
   llvm::StringRef OptRemarksFilename;
   llvm::StringRef OptRemarksPasses;
   llvm::StringRef ProgName;
+  llvm::StringRef PrintSymbolOrder;
   llvm::StringRef SoName;
   llvm::StringRef Sysroot;
   llvm::StringRef ThinLTOCacheDir;
Index: lld/ELF/CallGraphSort.cpp
===
--- lld/ELF/CallGraphSort.cpp
+++ lld/ELF/CallGraphSort.cpp
@@ -226,6 +226,26 @@
 for (int SecIndex : C.Sections)
   OrderMap[Sections[SecIndex]] = CurOrder++;
 
+  if (!Config->PrintSymbolOrder.empty()) {
+std::error_code EC;
+raw_fd_ostream OS(Config->PrintSymbolOrder, EC, sys::fs::F_None);
+if (EC) {
+  error("cannot open " + Config->PrintSymbolOrder + ": " + EC.message());

r357957 - [clang-format] Add AfterCaseLabel to BraceWrapping

2019-04-08 Thread Owen Pan via cfe-commits
Author: owenpan
Date: Mon Apr  8 16:36:25 2019
New Revision: 357957

URL: http://llvm.org/viewvc/llvm-project?rev=357957=rev
Log:
[clang-format] Add AfterCaseLabel to BraceWrapping

Fixes PR38686

llvm-svn: 52527

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=357957=357956=357957=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Mon Apr  8 16:36:25 2019
@@ -407,47 +407,46 @@ the configuration (without a prefix: ``A
   };
   void f() { bar(); }
 
+
+
 **AllowShortIfStatementsOnASingleLine** (``ShortIfStyle``)
-  Dependent on the value, ``if (a) return 0;`` can be put on a
-  single line.
+  If ``true``, ``if (a) return;`` can be put on a single line.
 
   Possible values:
 
   * ``SIS_Never`` (in configuration: ``Never``)
-Do not allow short if functions.
+Never put short ifs on the same line.
 
 .. code-block:: c++
 
-   if (a)
- return;
-   else
- return;
+  if (a)
+return ;
+  else {
+return;
+  }
 
   * ``SIS_WithoutElse`` (in configuration: ``WithoutElse``)
-Allow short if functions on the same line, as long as else
-is not a compound statement.
+Without else put short ifs on the same line only if
+the else is not a compound statement.
 
 .. code-block:: c++
 
-   if (a) return;
-   else
- return;
-
-   if (a)
- return;
-   else {
- return;
-   }
+  if (a) return;
+  else
+return;
 
   * ``SIS_Always`` (in configuration: ``Always``)
-Allow short if statements even if the else is a compound statement.
+Always put short ifs on the same line if
+the else is not a compound statement or not.
 
 .. code-block:: c++
 
-   if (a) return;
-   else {
-  return;
-   }
+  if (a) return;
+  else {
+return;
+  }
+
+
 
 **AllowShortLambdasOnASingleLine** (``ShortLambdaStyle``)
   Dependent on the value, ``auto lambda []() { return 0; }`` can be put on a
@@ -705,6 +704,23 @@ the configuration (without a prefix: ``A
   Nested configuration flags:
 
 
+  * ``bool AfterCaseLabel`` Wrap case labels.
+
+.. code-block:: c++
+
+  false:true:
+  switch (foo) {vs. switch (foo) {
+case 1: { case 1:
+  bar();  {
+  break;bar();
+}   break;
+default: {}
+  plop(); default:
+} {
+  } plop();
+  }
+}
+
   * ``bool AfterClass`` Wrap class definitions.
 
 .. code-block:: c++
@@ -1043,28 +1059,19 @@ the configuration (without a prefix: ``A
 
 .. code-block:: c++
 
-  try
-  {
+  try {
 foo();
   }
-  catch ()
-  {
+  catch () {
   }
   void foo() { bar(); }
-  class foo
-  {
+  class foo {
   };
-  if (foo())
-  {
+  if (foo()) {
   }
-  else
-  {
+  else {
   }
-  enum X : int
-  {
-A,
-B
-  };
+  enum X : int { A, B };
 
   * ``BS_GNU`` (in configuration: ``GNU``)
 Always break before braces and add an extra level of indentation to
@@ -1504,6 +1511,7 @@ the configuration (without a prefix: ``A
#endif
 
 
+
 **IndentWidth** (``unsigned``)
   The number of columns to use for indentation.
 
@@ -1954,6 +1962,7 @@ the configuration (without a prefix: ``A
 
 **SpaceAfterLogicalNot** (``bool``)
   If ``true``, a space is inserted after the logical not operator (``!``).
+
   .. code-block:: c++
 
  true:  false:
@@ -2033,6 +2042,19 @@ the configuration (without a prefix: ``A
  }
}
 
+  * ``SBPO_NonEmptyParentheses`` (in configuration: ``NonEmptyParentheses``)
+Put a space before opening parentheses only if the parentheses are not
+empty i.e. '()'
+
+.. code-block:: c++
+
+  void() {
+if (true) {
+  f();
+  g (x, y, z);
+}
+  }
+
   * ``SBPO_Always`` (in configuration: ``Always``)
 Always put a space before opening parentheses, except when it's
 prohibited by the syntax rules (in function-like macro definitions) or

Modified: cfe/trunk/include/clang/Format/Format.h

[PATCH] D52527: [clang-format] fix Bug 38686: add AfterCaseLabel to BraceWrapping

2019-04-08 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

@MyDeveloperDay :

> do you happen to know if this script is run by the build or is supposed to be 
> run by the developer after making the change to Format.h

I believe the developer must run it manually.

> If the latter, then I reckon the two are out of sync, perhaps I should submit 
> a change to realign them, but really there should be some sort of make target 
> that lets us determine when they diverge otherwise they'll keep changing

+1


Repository:
  rC Clang

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

https://reviews.llvm.org/D52527



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


[PATCH] D52527: [clang-format] fix Bug 38686: add AfterCaseLabel to BraceWrapping

2019-04-08 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 194219.
owenpan added a reviewer: reuk.
owenpan added a comment.

Thank you to all for reviewing this revision! Here is the update that addresses 
all of your comments.

(Also added @reuk to the reviewer list per @MyDeveloperDay 's suggestion.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D52527

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1117,6 +1117,7 @@
   Style.IndentCaseLabels = true;
   Style.AllowShortBlocksOnASingleLine = false;
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterCaseLabel = true;
   Style.BraceWrapping.AfterControlStatement = true;
   EXPECT_EQ("switch (n)\n"
 "{\n"
@@ -1138,6 +1139,27 @@
"  }\n"
"}",
Style));
+  Style.BraceWrapping.AfterCaseLabel = false;
+  EXPECT_EQ("switch (n)\n"
+"{\n"
+"  case 0: {\n"
+"return false;\n"
+"  }\n"
+"  default: {\n"
+"return true;\n"
+"  }\n"
+"}",
+format("switch (n) {\n"
+   "  case 0:\n"
+   "  {\n"
+   "return false;\n"
+   "  }\n"
+   "  default:\n"
+   "  {\n"
+   "return true;\n"
+   "  }\n"
+   "}",
+   Style));
 }
 
 TEST_F(FormatTest, CaseRanges) {
@@ -1291,6 +1313,7 @@
Style));
   Style.AllowShortCaseLabelsOnASingleLine = true;
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterCaseLabel = true;
   Style.BraceWrapping.AfterControlStatement = true;
   EXPECT_EQ("switch (n)\n"
 "{\n"
@@ -11356,6 +11379,7 @@
   CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
   CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
 
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterCaseLabel);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterClass);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterControlStatement);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterEnum);
@@ -12841,20 +12865,18 @@
 
 TEST_F(FormatTest, WrappedClosingParenthesisIndent) {
   FormatStyle Style = getLLVMStyle();
-  verifyFormat(
-  "int Foo::getter(\n"
-  "//\n"
-  ") const {\n"
-  "  return foo;\n"
-  "}",
-  Style);
-  verifyFormat(
-  "void Foo::setter(\n"
-  "//\n"
-  ") {\n"
-  "  foo = 1;\n"
-  "}",
-  Style);
+  verifyFormat("int Foo::getter(\n"
+   "//\n"
+   ") const {\n"
+   "  return foo;\n"
+   "}",
+   Style);
+  verifyFormat("void Foo::setter(\n"
+   "//\n"
+   ") {\n"
+   "  foo = 1;\n"
+   "}",
+   Style);
 }
 
 TEST_F(FormatTest, SpacesInAngles) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -172,10 +172,16 @@
 public:
   CompoundStatementIndenter(UnwrappedLineParser *Parser,
 const FormatStyle , unsigned )
+  : CompoundStatementIndenter(Parser, LineLevel,
+  Style.BraceWrapping.AfterControlStatement,
+  Style.BraceWrapping.IndentBraces) {
+  }
+  CompoundStatementIndenter(UnwrappedLineParser *Parser, unsigned ,
+bool WrapBrace, bool IndentBrace)
   : LineLevel(LineLevel), OldLineLevel(LineLevel) {
-if (Style.BraceWrapping.AfterControlStatement)
+if (WrapBrace)
   Parser->addUnwrappedLine();
-if (Style.BraceWrapping.IndentBraces)
+if (IndentBrace)
   ++LineLevel;
   }
   ~CompoundStatementIndenter() { LineLevel = OldLineLevel; }
@@ -1950,7 +1956,9 @@
   if (Line->Level > 1 || (!Line->InPPDirective && Line->Level > 0))
 --Line->Level;
   if (CommentsBeforeNextToken.empty() && FormatTok->Tok.is(tok::l_brace)) {
-CompoundStatementIndenter Indenter(this, Style, Line->Level);
+CompoundStatementIndenter Indenter(this, Line->Level,
+   Style.BraceWrapping.AfterCaseLabel,
+   Style.BraceWrapping.IndentBraces);
 parseBlock(/*MustBeDeclaration=*/false);
 if (FormatTok->Tok.is(tok::kw_break)) {
   if (Style.BraceWrapping.AfterControlStatement)
Index: clang/lib/Format/Format.cpp

r357952 - Revert "[MS] Add metadata for __declspec(allocator)"

2019-04-08 Thread Amy Huang via cfe-commits
Author: akhuang
Date: Mon Apr  8 15:46:41 2019
New Revision: 357952

URL: http://llvm.org/viewvc/llvm-project?rev=357952=rev
Log:
Revert "[MS] Add metadata for __declspec(allocator)"

This reverts commit e7bd735bb03a7b8141e32f7d6cb98e8914d8799e.
Reverting because of buildbot failure.

Removed:
cfe/trunk/test/CodeGen/debug-info-codeview-heapallocsite.c
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=357952=357951=357952=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Apr  8 15:46:41 2019
@@ -3800,8 +3800,6 @@ RValue CodeGenFunction::EmitCall(const C
 
   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
@@ -4290,7 +4288,11 @@ RValue CodeGenFunction::EmitCall(const C
   // Apply always_inline to all calls within flatten functions.
   // FIXME: should this really take priority over __try, below?
   if (CurCodeDecl && CurCodeDecl->hasAttr() &&
-  !(TargetDecl && TargetDecl->hasAttr())) {
+  !(Callee.getAbstractInfo().getCalleeDecl().getDecl() &&
+Callee.getAbstractInfo()
+.getCalleeDecl()
+.getDecl()
+->hasAttr())) {
 Attrs =
 Attrs.addAttribute(getLLVMContext(), 
llvm::AttributeList::FunctionIndex,
llvm::Attribute::AlwaysInline);
@@ -4374,16 +4376,11 @@ RValue CodeGenFunction::EmitCall(const C
 
   // 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
@@ -4540,6 +4537,7 @@ RValue CodeGenFunction::EmitCall(const C
   } ();
 
   // 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;

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=357952=357951=357952=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Apr  8 15:46:41 2019
@@ -1959,20 +1959,6 @@ llvm::DIType *CGDebugInfo::getOrCreateSt
   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;

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=357952=357951=357952=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Mon Apr  8 15:46:41 2019
@@ -476,10 +476,6 @@ public:
   /// 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);

Removed: cfe/trunk/test/CodeGen/debug-info-codeview-heapallocsite.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-codeview-heapallocsite.c?rev=357951=auto

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

2019-04-08 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

This patch caused the Windows sanitizer bot to break:  
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/44238

Please take a look.

  FAILED: 
projects/compiler-rt/lib/fuzzer/tests/FuzzerTestObjects.gtest-all.cc.x86_64.o 
  cmd.exe /C "cd /D 
C:\b\slave\sanitizer-windows\build\build\stage1\projects\compiler-rt\lib\fuzzer\tests
 && C:\b\slave\sanitizer-windows\build\build\stage1\.\bin\clang.exe -DWIN32 
-D_WINDOWS -Wno-unknown-warning-option -DGTEST_NO_LLVM_RAW_OSTREAM=1 
-DGTEST_HAS_RTTI=0 
-IC:/b/slave/sanitizer-windows/build/llvm.src/utils/unittest/googletest/include 
-IC:/b/slave/sanitizer-windows/build/llvm.src/utils/unittest/googletest 
-Wno-deprecated-declarations 
-IC:/b/slave/sanitizer-windows/build/llvm.src/projects/compiler-rt/lib/fuzzer 
-fno-rtti -O2 -c -o FuzzerTestObjects.gtest-all.cc.x86_64.o 
C:/b/slave/sanitizer-windows/build/llvm.src/utils/unittest/googletest/src/gtest-all.cc"
  Stack dump:
  
  0.Program arguments: 
C:\b\slave\sanitizer-windows\build\build\stage1\bin\clang.exe -cc1 -triple 
x86_64-pc-windows-msvc19.16.27026 -emit-obj -mincremental-linker-compatible 
-disable-free -main-file-name gtest-all.cc -mrelocation-model pic -pic-level 2 
-mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases 
-munwind-tables -target-cpu x86-64 -dwarf-column-info -momit-leaf-frame-pointer 
-coverage-notes-file 
C:\b\slave\sanitizer-windows\build\build\stage1\projects\compiler-rt\lib\fuzzer\tests\FuzzerTestObjects.gtest-all.cc.x86_64.gcno
 -resource-dir C:\b\slave\sanitizer-windows\build\build\stage1\lib\clang\9.0.0 
-D WIN32 -D _WINDOWS -D GTEST_NO_LLVM_RAW_OSTREAM=1 -D GTEST_HAS_RTTI=0 -I 
C:/b/slave/sanitizer-windows/build/llvm.src/utils/unittest/googletest/include 
-I C:/b/slave/sanitizer-windows/build/llvm.src/utils/unittest/googletest -I 
C:/b/slave/sanitizer-windows/build/llvm.src/projects/compiler-rt/lib/fuzzer 
-internal-isystem 
C:\b\slave\sanitizer-windows\build\build\stage1\lib\clang\9.0.0\include 
-internal-isystem C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\ATLMFC\include 
-internal-isystem C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include -internal-isystem 
C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um -internal-isystem 
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt 
-internal-isystem C:\Program Files (x86)\Windows 
Kits\10\include\10.0.17763.0\shared -internal-isystem C:\Program Files 
(x86)\Windows Kits\10\include\10.0.17763.0\um -internal-isystem C:\Program 
Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -internal-isystem 
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt -O2 
-Wno-unknown-warning-option -Wno-deprecated-declarations -fdeprecated-macro 
-fdebug-compilation-dir 
C:\b\slave\sanitizer-windows\build\build\stage1\projects\compiler-rt\lib\fuzzer\tests
 -ferror-limit 19 -fmessage-length 0 -fno-rtti -fno-use-cxa-atexit 
-fms-extensions -fms-compatibility -fms-compatibility-version=19.16.27026 
-std=c++14 -fdelayed-template-parsing -fobjc-runtime=gcc -fcxx-exceptions 
-fexceptions -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o 
FuzzerTestObjects.gtest-all.cc.x86_64.o -x c++ 
C:/b/slave/sanitizer-windows/build/llvm.src/utils/unittest/googletest/src/gtest-all.cc
 -faddrsig 
  
  1.
C:/b/slave/sanitizer-windows/build/llvm.src/utils/unittest/googletest\src/gtest-death-test.cc:79:1:
 current parser token 'namespace'
  
  2.
C:/b/slave/sanitizer-windows/build/llvm.src/utils/unittest/googletest\src/gtest.cc:149:11:
 LLVM IR generation of declaration 'testing'
  
  3.
C:/b/slave/sanitizer-windows/build/llvm.src/utils/unittest/googletest\src/gtest.cc:361:15:
 Generating code for declaration 'testing::internal::AssertHelper::AssertHelper'
  
   #0 0x7ff761d1de49 
clang::CodeGen::CGDebugInfo::addHeapAllocSiteMetadata(class llvm::Instruction 
*,class clang::QualType,class clang::SourceLocation) 
c:\b\slave\sanitizer-windows\build\llvm.src\tools\clang\lib\codegen\cgdebuginfo.cpp:1967:0
  
   #1 0x7ff761d9d462 clang::CodeGen::CodeGenFunction::EmitCall(class 
clang::CodeGen::CGFunctionInfo const &,class clang::CodeGen::CGCallee const 
&,class clang::CodeGen::ReturnValueSlot,class clang::CodeGen::CallArgList const 
&,class llvm::CallBase * *,class clang::SourceLocation) 
c:\b\slave\sanitizer-windows\build\llvm.src\tools\clang\lib\codegen\cgcall.cpp:4392:0
  
   #2 0x7ff76202a144 EmitNewDeleteCall 
c:\b\slave\sanitizer-windows\build\llvm.src\tools\clang\lib\codegen\cgexprcxx.cpp:1288:0
  
   #3 0x7ff762026a55 clang::CodeGen::CodeGenFunction::EmitCXXNewExpr(class 
clang::CXXNewExpr const *) 
c:\b\slave\sanitizer-windows\build\llvm.src\tools\clang\lib\codegen\cgexprcxx.cpp:1617:0
  
   #4 0x7ff761fdf0a6 clang::StmtVisitorBase::Visit 
c:\b\slave\sanitizer-windows\build\build\stage1\tools\clang\include\clang\ast\stmtnodes.inc:699:0
  
 

[PATCH] D60379: Make precompiled headers reproducible

2019-04-08 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In D60379#1458799 , @thakis wrote:

> In D60379#1458668 , @riccibruno 
> wrote:
>
> > After looking at the bug report (https://bugs.debian.org/877359), I would 
> > like to point out that there is currently *absolutely* no stability 
> > guarantee for the serialization format (ie, you need the exact same 
> > revision). In regard of this I am wondering how sane it is to ship pch 
> > files.
>
>
> I agree we shouldn't make guarantees about pch file format stability and that 
> distributing pch files isn't a good idea. Having said that, making clang 
> write the same output when given the same input is still a Good Thing as it 
> enables caching these outputs e.g. with tools like distcc.


Good point.

I went through each of the structures serialized in `ASTWriter.cpp`, and unless 
I missed one, `OpenCLDeclExtMap` and `OpenCLTypeExtMap` are the only one which 
are serialized in a non-deterministic way (so my earlier inline comment was 
mistaken).


Repository:
  rC Clang

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

https://reviews.llvm.org/D60379



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


r357940 - [ASTImporter] Call to HandleNameConflict in VisitEnumDecl mistakeningly using Name instead of SearchName

2019-04-08 Thread Shafik Yaghmour via cfe-commits
Author: shafik
Date: Mon Apr  8 13:50:21 2019
New Revision: 357940

URL: http://llvm.org/viewvc/llvm-project?rev=357940=rev
Log:
[ASTImporter] Call to HandleNameConflict in VisitEnumDecl mistakeningly using 
Name instead of SearchName

Summary:
https://reviews.llvm.org/D51633 added error handling to the 
ASTNodeImporter::VisitEnumDecl(...) for the conflicting names case. This could 
lead to erroneous return of an error in that case since we should have been 
using SearchName. Name may be empty in the case where we find the name via 
getTypedefNameForAnonDecl(...).

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

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

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=357940=357939=357940=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Apr  8 13:50:21 2019
@@ -2441,7 +2441,7 @@ ExpectedDecl ASTNodeImporter::VisitEnumD
 }
 
 if (!ConflictingDecls.empty()) {
-  Name = Importer.HandleNameConflict(Name, DC, IDNS,
+  Name = Importer.HandleNameConflict(SearchName, DC, IDNS,
  ConflictingDecls.data(),
  ConflictingDecls.size());
   if (!Name)


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


[PATCH] D59665: Call to HandleNameConflict in VisitEnumDecl mistakeningly using Name instead of SearchName

2019-04-08 Thread Shafik Yaghmour via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC357940: [ASTImporter] Call to HandleNameConflict in 
VisitEnumDecl mistakeningly using… (authored by shafik, committed by ).
Herald added a project: clang.

Repository:
  rC Clang

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

https://reviews.llvm.org/D59665

Files:
  lib/AST/ASTImporter.cpp


Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2441,7 +2441,7 @@
 }
 
 if (!ConflictingDecls.empty()) {
-  Name = Importer.HandleNameConflict(Name, DC, IDNS,
+  Name = Importer.HandleNameConflict(SearchName, DC, IDNS,
  ConflictingDecls.data(),
  ConflictingDecls.size());
   if (!Name)


Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2441,7 +2441,7 @@
 }
 
 if (!ConflictingDecls.empty()) {
-  Name = Importer.HandleNameConflict(Name, DC, IDNS,
+  Name = Importer.HandleNameConflict(SearchName, DC, IDNS,
  ConflictingDecls.data(),
  ConflictingDecls.size());
   if (!Name)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60379: Make precompiled headers reproducible

2019-04-08 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

To be clear, this isn't about format stability and distributing but making sure 
that two same runs of clang produces the same output.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60379



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


[PATCH] D57965: Clean up ObjCPropertyDecl printing

2019-04-08 Thread David Goldman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL357937: Clean up ObjCPropertyDecl printing (authored by 
dgoldman, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57965

Files:
  cfe/trunk/lib/AST/DeclPrinter.cpp
  cfe/trunk/test/AST/ast-print-objc-property.m
  cfe/trunk/test/Index/comment-objc-decls.m
  cfe/trunk/test/Index/comment-unqualified-objc-pointer.m
  cfe/trunk/test/PCH/chain-remap-types.m

Index: cfe/trunk/test/Index/comment-objc-decls.m
===
--- cfe/trunk/test/Index/comment-objc-decls.m
+++ cfe/trunk/test/Index/comment-objc-decls.m
@@ -32,7 +32,7 @@
 @end
 // CHECK: @protocol MyProto\n@end
 // CHECK: - (unsigned int)MethodMyProto:(nullable id)anObject inRange:(unsigned int)range;
-// CHECK: @optional\n@property(readwrite, copy, atomic, nonnull) id PropertyMyProto;
+// CHECK: @optional\n@property(atomic, copy, readwrite, nonnull) id PropertyMyProto;
 // CHECK: + (id)ClassMethodMyProto;
 
 /**
@@ -77,7 +77,7 @@
 // CHECK: id IvarMyClass
 // CHECK: - (id)MethodMyClass;
 // CHECK: + (id)ClassMethodMyClass;
-// CHECK: @property(readwrite, copy, atomic) id PropertyMyClass;@property(atomic, copy, readwrite) id PropertyMyClass;@interface MyClass (Category)\n@end
 // CHECK: - (void)MethodMyClassCategory;
-// CHECK: @property(readwrite, copy, atomic) id PropertyMyClassCategory;
+// CHECK: @property(atomic, copy, readwrite) id PropertyMyClassCategory;
 // CHECK: - (id)PropertyMyClassCategory;
 // CHECK: - (void)setPropertyMyClassCategory:(id)arg;
 
Index: cfe/trunk/test/Index/comment-unqualified-objc-pointer.m
===
--- cfe/trunk/test/Index/comment-unqualified-objc-pointer.m
+++ cfe/trunk/test/Index/comment-unqualified-objc-pointer.m
@@ -19,7 +19,7 @@
 
 //! This is a property to get the Name.
 @property (copy) NSString *Name;
-// CHECK: @property(readwrite, copy, atomic) NSString *Name;
+// CHECK: @property(atomic, copy, readwrite) NSString *Name;
 @end
 
 @implementation NSMutableArray
Index: cfe/trunk/test/AST/ast-print-objc-property.m
===
--- cfe/trunk/test/AST/ast-print-objc-property.m
+++ cfe/trunk/test/AST/ast-print-objc-property.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -ast-print %s -o - | FileCheck %s
+
+@interface NSObject
+@end
+
+@interface Properties : NSObject
+@property(class) int classFoo;
+@property(nonatomic) int atomicBar;
+@property(readonly) int readonlyConstant;
+@property(retain, nonatomic, setter=my_setter:, getter=my_getter) id   __crazy_name;
+@property(nonatomic, strong, nullable) NSObject *   objProperty;
+@property(nonatomic, weak, null_resettable) NSObject *   weakObj;
+@property(nonatomic, copy, nonnull) NSObject * copyObj;
+@end
+
+// CHECK: @property(class, atomic, assign, unsafe_unretained, readwrite) int classFoo;
+// CHECK: @property(nonatomic, assign, unsafe_unretained, readwrite) int atomicBar;
+// CHECK: @property(atomic, readonly) int readonlyConstant;
+// CHECK: @property(nonatomic, retain, readwrite, getter = my_getter, setter = my_setter:) id __crazy_name;
+// CHECK: @property(nonatomic, strong, readwrite, nullable) NSObject *objProperty;
+// CHECK: @property(nonatomic, weak, readwrite, null_resettable) NSObject *weakObj;
+// CHECK: @property(nonatomic, copy, readwrite, nonnull) NSObject *copyObj;
Index: cfe/trunk/test/PCH/chain-remap-types.m
===
--- cfe/trunk/test/PCH/chain-remap-types.m
+++ cfe/trunk/test/PCH/chain-remap-types.m
@@ -6,7 +6,7 @@
 
 // CHECK: @class X;
 // CHECK: struct Y 
-// CHECK: @property ( assign,readwrite,atomic ) X * prop
+// CHECK: @property(atomic, assign, unsafe_unretained, readwrite) X *prop
 // CHECK: void h(X *);
 // CHECK: @interface X(Blah)
 // CHECK: void g(X *);
Index: cfe/trunk/lib/AST/DeclPrinter.cpp
===
--- cfe/trunk/lib/AST/DeclPrinter.cpp
+++ cfe/trunk/lib/AST/DeclPrinter.cpp
@@ -1391,6 +1391,13 @@
 
 /// PrintObjCPropertyDecl - print a property declaration.
 ///
+/// Print attributes in the following order:
+/// - class
+/// - nonatomic | atomic
+/// - assign | retain | strong | copy | weak | unsafe_unretained
+/// - readwrite | readonly
+/// - getter & setter
+/// - nullability
 void DeclPrinter::VisitObjCPropertyDecl(ObjCPropertyDecl *PDecl) {
   if (PDecl->getPropertyImplementation() == ObjCPropertyDecl::Required)
 Out << "@required\n";
@@ -1402,58 +1409,69 @@
   Out << "@property";
   if (PDecl->getPropertyAttributes() != ObjCPropertyDecl::OBJC_PR_noattr) {
 bool first = true;
-Out << " (";
-if (PDecl->getPropertyAttributes() &
-

r357937 - Clean up ObjCPropertyDecl printing

2019-04-08 Thread David Goldman via cfe-commits
Author: dgoldman
Date: Mon Apr  8 12:52:45 2019
New Revision: 357937

URL: http://llvm.org/viewvc/llvm-project?rev=357937=rev
Log:
Clean up ObjCPropertyDecl printing

Summary:
- `@property(attr, attr2)` instead of `@property ( attr,attr2 )`.
- Change priority of attributes (see code/comments inline).
- Support for printing weak and unsafe_unretained attributes.

Subscribers: arphaman, jfb, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/AST/ast-print-objc-property.m
Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Index/comment-objc-decls.m
cfe/trunk/test/Index/comment-unqualified-objc-pointer.m
cfe/trunk/test/PCH/chain-remap-types.m

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=357937=357936=357937=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon Apr  8 12:52:45 2019
@@ -1391,6 +1391,13 @@ void DeclPrinter::VisitObjCCompatibleAli
 
 /// PrintObjCPropertyDecl - print a property declaration.
 ///
+/// Print attributes in the following order:
+/// - class
+/// - nonatomic | atomic
+/// - assign | retain | strong | copy | weak | unsafe_unretained
+/// - readwrite | readonly
+/// - getter & setter
+/// - nullability
 void DeclPrinter::VisitObjCPropertyDecl(ObjCPropertyDecl *PDecl) {
   if (PDecl->getPropertyImplementation() == ObjCPropertyDecl::Required)
 Out << "@required\n";
@@ -1402,58 +1409,69 @@ void DeclPrinter::VisitObjCPropertyDecl(
   Out << "@property";
   if (PDecl->getPropertyAttributes() != ObjCPropertyDecl::OBJC_PR_noattr) {
 bool first = true;
-Out << " (";
-if (PDecl->getPropertyAttributes() &
-ObjCPropertyDecl::OBJC_PR_readonly) {
-  Out << (first ? ' ' : ',') << "readonly";
+Out << "(";
+if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_class) {
+  Out << (first ? "" : ", ") << "class";
   first = false;
 }
 
-if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_getter) {
-  Out << (first ? ' ' : ',') << "getter = ";
-  PDecl->getGetterName().print(Out);
+if (PDecl->getPropertyAttributes() &
+ObjCPropertyDecl::OBJC_PR_nonatomic) {
+  Out << (first ? "" : ", ") << "nonatomic";
   first = false;
 }
-if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_setter) {
-  Out << (first ? ' ' : ',') << "setter = ";
-  PDecl->getSetterName().print(Out);
+if (PDecl->getPropertyAttributes() &
+ObjCPropertyDecl::OBJC_PR_atomic) {
+  Out << (first ? "" : ", ") << "atomic";
   first = false;
 }
 
 if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_assign) {
-  Out << (first ? ' ' : ',') << "assign";
-  first = false;
-}
-
-if (PDecl->getPropertyAttributes() &
-ObjCPropertyDecl::OBJC_PR_readwrite) {
-  Out << (first ? ' ' : ',') << "readwrite";
+  Out << (first ? "" : ", ") << "assign";
   first = false;
 }
-
 if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_retain) {
-  Out << (first ? ' ' : ',') << "retain";
+  Out << (first ? "" : ", ") << "retain";
   first = false;
 }
 
 if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_strong) {
-  Out << (first ? ' ' : ',') << "strong";
+  Out << (first ? "" : ", ") << "strong";
   first = false;
 }
-
 if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_copy) {
-  Out << (first ? ' ' : ',') << "copy";
+  Out << (first ? "" : ", ") << "copy";
+  first = false;
+}
+if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak) {
+  Out << (first ? "" : ", ") << "weak";
+  first = false;
+}
+if (PDecl->getPropertyAttributes()
+& ObjCPropertyDecl::OBJC_PR_unsafe_unretained) {
+  Out << (first ? "" : ", ") << "unsafe_unretained";
   first = false;
 }
 
 if (PDecl->getPropertyAttributes() &
-ObjCPropertyDecl::OBJC_PR_nonatomic) {
-  Out << (first ? ' ' : ',') << "nonatomic";
+ObjCPropertyDecl::OBJC_PR_readwrite) {
+  Out << (first ? "" : ", ") << "readwrite";
   first = false;
 }
 if (PDecl->getPropertyAttributes() &
-ObjCPropertyDecl::OBJC_PR_atomic) {
-  Out << (first ? ' ' : ',') << "atomic";
+ObjCPropertyDecl::OBJC_PR_readonly) {
+  Out << (first ? "" : ", ") << "readonly";
+  first = false;
+}
+
+if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_getter) {
+  Out << (first ? "" : ", ") << "getter = ";
+  PDecl->getGetterName().print(Out);
+  first = false;
+}
+if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_setter) {
+  Out << (first ? "" : ", ") << "setter = ";
+  PDecl->getSetterName().print(Out);
   

[PATCH] D60379: Make precompiled headers reproducible

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

In D60379#1458668 , @riccibruno wrote:

> After looking at the bug report (https://bugs.debian.org/877359), I would 
> like to point out that there is currently *absolutely* no stability guarantee 
> for the serialization format (ie, you need the exact same revision). In 
> regard of this I am wondering how sane it is to ship pch files.


I agree we shouldn't make guarantees about pch file format stability and that 
distributing pch files isn't a good idea. Having said that, making clang write 
the same output when given the same input is still a Good Thing as it enables 
caching these outputs e.g. with tools like distcc.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60379



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


[PATCH] D57965: Clean up ObjCPropertyDecl printing

2019-04-08 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 194195.
dgoldman added a comment.
Herald added a subscriber: dexonsmith.

- Rebase


Repository:
  rC Clang

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

https://reviews.llvm.org/D57965

Files:
  lib/AST/DeclPrinter.cpp
  test/AST/ast-print-objc-property.m
  test/Index/comment-objc-decls.m
  test/Index/comment-unqualified-objc-pointer.m
  test/PCH/chain-remap-types.m

Index: test/PCH/chain-remap-types.m
===
--- test/PCH/chain-remap-types.m
+++ test/PCH/chain-remap-types.m
@@ -6,7 +6,7 @@
 
 // CHECK: @class X;
 // CHECK: struct Y 
-// CHECK: @property ( assign,readwrite,atomic ) X * prop
+// CHECK: @property(atomic, assign, unsafe_unretained, readwrite) X *prop
 // CHECK: void h(X *);
 // CHECK: @interface X(Blah)
 // CHECK: void g(X *);
Index: test/Index/comment-unqualified-objc-pointer.m
===
--- test/Index/comment-unqualified-objc-pointer.m
+++ test/Index/comment-unqualified-objc-pointer.m
@@ -19,7 +19,7 @@
 
 //! This is a property to get the Name.
 @property (copy) NSString *Name;
-// CHECK: @property(readwrite, copy, atomic) NSString *Name;
+// CHECK: @property(atomic, copy, readwrite) NSString *Name;
 @end
 
 @implementation NSMutableArray
Index: test/Index/comment-objc-decls.m
===
--- test/Index/comment-objc-decls.m
+++ test/Index/comment-objc-decls.m
@@ -32,7 +32,7 @@
 @end
 // CHECK: @protocol MyProto\n@end
 // CHECK: - (unsigned int)MethodMyProto:(nullable id)anObject inRange:(unsigned int)range;
-// CHECK: @optional\n@property(readwrite, copy, atomic, nonnull) id PropertyMyProto;
+// CHECK: @optional\n@property(atomic, copy, readwrite, nonnull) id PropertyMyProto;
 // CHECK: + (id)ClassMethodMyProto;
 
 /**
@@ -77,7 +77,7 @@
 // CHECK: id IvarMyClass
 // CHECK: - (id)MethodMyClass;
 // CHECK: + (id)ClassMethodMyClass;
-// CHECK: @property(readwrite, copy, atomic) id PropertyMyClass;@property(atomic, copy, readwrite) id PropertyMyClass;@interface MyClass (Category)\n@end
 // CHECK: - (void)MethodMyClassCategory;
-// CHECK: @property(readwrite, copy, atomic) id PropertyMyClassCategory;
+// CHECK: @property(atomic, copy, readwrite) id PropertyMyClassCategory;
 // CHECK: - (id)PropertyMyClassCategory;
 // CHECK: - (void)setPropertyMyClassCategory:(id)arg;
 
Index: test/AST/ast-print-objc-property.m
===
--- /dev/null
+++ test/AST/ast-print-objc-property.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -ast-print %s -o - | FileCheck %s
+
+@interface NSObject
+@end
+
+@interface Properties : NSObject
+@property(class) int classFoo;
+@property(nonatomic) int atomicBar;
+@property(readonly) int readonlyConstant;
+@property(retain, nonatomic, setter=my_setter:, getter=my_getter) id   __crazy_name;
+@property(nonatomic, strong, nullable) NSObject *   objProperty;
+@property(nonatomic, weak, null_resettable) NSObject *   weakObj;
+@property(nonatomic, copy, nonnull) NSObject * copyObj;
+@end
+
+// CHECK: @property(class, atomic, assign, unsafe_unretained, readwrite) int classFoo;
+// CHECK: @property(nonatomic, assign, unsafe_unretained, readwrite) int atomicBar;
+// CHECK: @property(atomic, readonly) int readonlyConstant;
+// CHECK: @property(nonatomic, retain, readwrite, getter = my_getter, setter = my_setter:) id __crazy_name;
+// CHECK: @property(nonatomic, strong, readwrite, nullable) NSObject *objProperty;
+// CHECK: @property(nonatomic, weak, readwrite, null_resettable) NSObject *weakObj;
+// CHECK: @property(nonatomic, copy, readwrite, nonnull) NSObject *copyObj;
Index: lib/AST/DeclPrinter.cpp
===
--- lib/AST/DeclPrinter.cpp
+++ lib/AST/DeclPrinter.cpp
@@ -1391,6 +1391,13 @@
 
 /// PrintObjCPropertyDecl - print a property declaration.
 ///
+/// Print attributes in the following order:
+/// - class
+/// - nonatomic | atomic
+/// - assign | retain | strong | copy | weak | unsafe_unretained
+/// - readwrite | readonly
+/// - getter & setter
+/// - nullability
 void DeclPrinter::VisitObjCPropertyDecl(ObjCPropertyDecl *PDecl) {
   if (PDecl->getPropertyImplementation() == ObjCPropertyDecl::Required)
 Out << "@required\n";
@@ -1402,58 +1409,69 @@
   Out << "@property";
   if (PDecl->getPropertyAttributes() != ObjCPropertyDecl::OBJC_PR_noattr) {
 bool first = true;
-Out << " (";
-if (PDecl->getPropertyAttributes() &
-ObjCPropertyDecl::OBJC_PR_readonly) {
-  Out << (first ? ' ' : ',') << "readonly";
+Out << "(";
+if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_class) {
+  Out << (first ? "" : ", ") << "class";
   first = false;
 }
 
-if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_getter) {
-  Out << (first ? ' ' : ',') << 

[PATCH] D60418: inline asm: Don't copy llvm::MemoryBuffers when showing diagnostics

2019-04-08 Thread Nico Weber via Phabricator via cfe-commits
thakis marked an inline comment as done.
thakis added inline comments.



Comment at: clang/lib/Lex/Lexer.cpp:2355
+  // XXX so comment is handled before pp directive is done, so no linetable
+  // entry yet when the handler runs.
   if (ParsingPreprocessorDirective || CurPtr == BufferEnd) {

It doesn't show up well in the diff, but there's a call to HandleComment() 13 
lines further up that this refers to.


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

https://reviews.llvm.org/D60418



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


[PATCH] D60417: [libunwind] Add support for ARMv7-M architecture which uses the Thumb 2 ISA (unified syntax)

2019-04-08 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added reviewers: ldionne, EricWF, mclow.lists.
mstorsjo added a comment.
Herald added a subscriber: dexonsmith.

The change looks sensible to me, but should we maybe even skip the `#if` 
altogether? If the files uses unified syntax and can't be parsed in thumb mode 
otherwise, there's maybe no need for conditionals at all?


Repository:
  rUNW libunwind

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

https://reviews.llvm.org/D60417



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


[PATCH] D60418: inline asm: Don't copy llvm::MemoryBuffers when showing diagnostics

2019-04-08 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added reviewers: rnk, rsmith.

This fixes one TODO and one FIXME in ConvertBackendLocation() about not copying 
llvm::MemoryBuffers when converting from from llvm::SMDiagnostics to 
clang::Diagnostics.

The basic idea is to use 
`SourceManager::createFileID(clang::SourceManager::Unowned, …` to hand the 
llvm::SMDiagnostic's llvm::MemoryBuffer buffer directly to clang.

This has the implication that the SourceManager now has a reference to a 
MemoryBuffer that's only alive while LLVM's asm pass runs; in particular the 
buffer is gone by the time TextDiagnosticBuffer computes the expected line 
number for the diagnostics it records in -verify mode. To fix this, make 
TextDiagnosticBuffer do this conversion eagerly when the diagnostic is 
recorded. This in turn has two implications:

1. It matches how clang emits diagnostics in normal operation, which is a good 
thing. This e.g. identified a problem where clang's normal diagnostic emission 
code path works fine but the -verify code path is broken (PR41431).

2. Since HandleComment() for end-of-line comments in preprocessor directives is 
called _before_ the directive is completely processed, comments at the end of 
`#line` directives don't see the effect of the `#line` directive yet. Just 
update tests affected by this by moving the comments down a line and using the 
`@-1` syntax to refer to the previous line. (This is less weird than it appears 
at first: `@+1` lines for `#line` directives already don't work which is 
confusing some people – PR16952. But as you can see, only very few tests use 
this.) (See the `XXX` comment in the patch for details; I'll remove that 
comment before landing this.)

This is blocked on fixing PR41431.


https://reviews.llvm.org/D60418

Files:
  clang/include/clang/Frontend/TextDiagnosticBuffer.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Frontend/TextDiagnosticBuffer.cpp
  clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
  clang/lib/Lex/Lexer.cpp
  clang/test/Lexer/gnu-flags.c
  clang/test/Modules/explicit-build-missing-files.cpp
  clang/test/Preprocessor/line-directive.c

Index: clang/test/Preprocessor/line-directive.c
===
--- clang/test/Preprocessor/line-directive.c
+++ clang/test/Preprocessor/line-directive.c
@@ -3,9 +3,12 @@
 // RUN: not %clang_cc1 -E %s 2>&1 | grep 'blonk.c:93:2: error: DEF'
 
 #line 'a'// expected-error {{#line directive requires a positive integer argument}}
-#line 0  // expected-warning {{#line directive with zero argument is a GNU extension}}
-#line 00 // expected-warning {{#line directive with zero argument is a GNU extension}}
-#line 2147483648 // expected-warning {{C requires #line number to be less than 2147483648, allowed as extension}}
+#line 0
+// expected-warning@-1{{#line directive with zero argument is a GNU extension}}
+#line 00
+// expected-warning@-1{{#line directive with zero argument is a GNU extension}}
+#line 2147483648
+// expected-warning@-1{{C requires #line number to be less than 2147483648, allowed as extension}}
 #line 42 // ok
 #line 42 'a' // expected-error {{invalid filename for #line directive}}
 #line 42 "foo/bar/baz.h"  // ok
@@ -73,7 +76,8 @@
 // because #line is allowed to contain expanded tokens.
 #define EMPTY()
 #line 2 "foo.c" EMPTY( )
-#line 2 "foo.c" NONEMPTY( )  // expected-warning{{extra tokens at end of #line directive}}
+#line 2 "foo.c" NONEMPTY( )
+// expected-warning@-1{{extra tokens at end of #line directive}}
 
 // PR3940
 #line 0xf  // expected-error {{#line directive requires a simple digit sequence}}
@@ -82,11 +86,13 @@
 
 // Line markers are digit strings interpreted as decimal numbers, this is
 // 10, not 8.
-#line 010  // expected-warning {{#line directive interprets number as decimal, not octal}}
-extern int array[__LINE__ == 10 ? 1:-1];
+#line 010
+// expected-warning@-1{{#line directive interprets number as decimal, not octal}}
+extern int array[__LINE__ == 11 ? 1:-1];
 
-# 020  // expected-warning {{GNU line marker directive interprets number as decimal, not octal}}
-extern int array_gnuline[__LINE__ == 20 ? 1:-1];
+# 020
+// expected-warning@-1{{GNU line marker directive interprets number as decimal, not octal}}
+extern int array_gnuline[__LINE__ == 21 ? 1:-1];
 
 /* PR3917 */
 #line 41
@@ -100,7 +106,8 @@
 _LINE__ == 52 ? 1: -1];  /* line marker is location of first _ */
 
 // rdar://11550996
-#line 0 "line-directive.c" // expected-warning {{#line directive with zero argument is a GNU extension}}
+#line 0 "line-directive.c"
+// expected-warning@-1{{#line directive with zero argument is a GNU extension}}
 undefined t; // expected-error {{unknown type name 'undefined'}}
 
 
Index: clang/test/Modules/explicit-build-missing-files.cpp
===
--- clang/test/Modules/explicit-build-missing-files.cpp
+++ 

[PATCH] D60417: [libunwind] Add support for ARMv7-M architecture which uses the Thumb 2 ISA (unified syntax)

2019-04-08 Thread Jérémie Faucher-Goulet via Phabricator via cfe-commits
jeremfg created this revision.
jeremfg added a reviewer: mstorsjo.
Herald added subscribers: libcxx-commits, ldionne, kristof.beyls, javed.absar.

I'm a first time contributor to LLVM...

While attempting to compile the assembly files ( .S) for a Cortex-M4 device 
using GCC's arm-none-eabi, I encountered issue which this patch fixes.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D60417

Files:
  UnwindRegistersRestore.S
  UnwindRegistersSave.S


Index: UnwindRegistersSave.S
===
--- UnwindRegistersSave.S
+++ UnwindRegistersSave.S
@@ -750,6 +750,9 @@
 #elif defined(__arm__) && !defined(__APPLE__)
 
 #if !defined(__ARM_ARCH_ISA_ARM)
+#if (__ARM_ARCH_ISA_THUMB == 2)
+  .syntax unified
+#endif
   .thumb
 #endif
 
Index: UnwindRegistersRestore.S
===
--- UnwindRegistersRestore.S
+++ UnwindRegistersRestore.S
@@ -610,6 +610,9 @@
 #elif defined(__arm__) && !defined(__APPLE__)
 
 #if !defined(__ARM_ARCH_ISA_ARM)
+#if (__ARM_ARCH_ISA_THUMB == 2)
+  .syntax unified
+#endif
   .thumb
 #endif
 


Index: UnwindRegistersSave.S
===
--- UnwindRegistersSave.S
+++ UnwindRegistersSave.S
@@ -750,6 +750,9 @@
 #elif defined(__arm__) && !defined(__APPLE__)
 
 #if !defined(__ARM_ARCH_ISA_ARM)
+#if (__ARM_ARCH_ISA_THUMB == 2)
+  .syntax unified
+#endif
   .thumb
 #endif
 
Index: UnwindRegistersRestore.S
===
--- UnwindRegistersRestore.S
+++ UnwindRegistersRestore.S
@@ -610,6 +610,9 @@
 #elif defined(__arm__) && !defined(__APPLE__)
 
 #if !defined(__ARM_ARCH_ISA_ARM)
+#if (__ARM_ARCH_ISA_THUMB == 2)
+  .syntax unified
+#endif
   .thumb
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r357933 - [OPENMP] Sync __kmpc_alloc/_kmpc_free function with the runtime.

2019-04-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Apr  8 12:06:42 2019
New Revision: 357933

URL: http://llvm.org/viewvc/llvm-project?rev=357933=rev
Log:
[OPENMP] Sync __kmpc_alloc/_kmpc_free function with the runtime.

Functions __kmpc_alloc/__kmpc_free are updated with the new interfaces.
Patch synchronizes the compiler with the runtime.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/allocate_codegen.cpp
cfe/trunk/test/OpenMP/for_lastprivate_codegen.cpp
cfe/trunk/test/OpenMP/for_linear_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
cfe/trunk/test/OpenMP/parallel_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/parallel_private_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=357933=357932=357933=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon Apr  8 12:06:42 2019
@@ -667,9 +667,9 @@ enum OpenMPRTLFunction {
   // Call to void *__kmpc_task_reduction_get_th_data(int gtid, void *tg, void
   // *d);
   OMPRTL__kmpc_task_reduction_get_th_data,
-  // Call to void *__kmpc_alloc(int gtid, size_t sz, const omp_allocator_t 
*al);
+  // Call to void *__kmpc_alloc(int gtid, size_t sz, omp_allocator_handle_t 
al);
   OMPRTL__kmpc_alloc,
-  // Call to void __kmpc_free(int gtid, void *ptr, const omp_allocator_t *al);
+  // Call to void __kmpc_free(int gtid, void *ptr, omp_allocator_handle_t al);
   OMPRTL__kmpc_free,
 
   //
@@ -2200,20 +2200,18 @@ llvm::FunctionCallee CGOpenMPRuntime::cr
 break;
   }
   case OMPRTL__kmpc_alloc: {
-// Build to void *__kmpc_alloc(int gtid, size_t sz, const omp_allocator_t
-// *al);
-// omp_allocator_t type is void *.
-llvm::Type *TypeParams[] = {CGM.IntTy, CGM.SizeTy, CGM.VoidPtrPtrTy};
+// Build to void *__kmpc_alloc(int gtid, size_t sz, omp_allocator_handle_t
+// al); omp_allocator_handle_t type is void *.
+llvm::Type *TypeParams[] = {CGM.IntTy, CGM.SizeTy, CGM.VoidPtrTy};
 auto *FnTy =
 llvm::FunctionType::get(CGM.VoidPtrTy, TypeParams, /*isVarArg=*/false);
 RTLFn = CGM.CreateRuntimeFunction(FnTy, /*Name=*/"__kmpc_alloc");
 break;
   }
   case OMPRTL__kmpc_free: {
-// Build to void __kmpc_free(int gtid, void *ptr, const omp_allocator_t
-// *al);
-// omp_allocator_t type is void *.
-llvm::Type *TypeParams[] = {CGM.IntTy, CGM.VoidPtrTy, CGM.VoidPtrPtrTy};
+// Build to void __kmpc_free(int gtid, void *ptr, omp_allocator_handle_t
+// al); omp_allocator_handle_t type is void *.
+llvm::Type *TypeParams[] = {CGM.IntTy, CGM.VoidPtrTy, CGM.VoidPtrTy};
 auto *FnTy =
 llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg=*/false);
 RTLFn = CGM.CreateRuntimeFunction(FnTy, /*Name=*/"__kmpc_free");
@@ -9781,6 +9779,13 @@ Address CGOpenMPRuntime::getAddressOfLoc
   assert(AA->getAllocator() &&
  "Expected allocator expression for non-default allocator.");
   llvm::Value *Allocator = CGF.EmitScalarExpr(AA->getAllocator());
+  // According to the standard, the original allocator type is a enum 
(integer).
+  // Convert to pointer type, if required.
+  if (Allocator->getType()->isIntegerTy())
+Allocator = CGF.Builder.CreateIntToPtr(Allocator, CGM.VoidPtrTy);
+  else if (Allocator->getType()->isPointerTy())
+Allocator = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Allocator,
+CGM.VoidPtrTy);
   llvm::Value *Args[] = {ThreadID, Size, Allocator};
 
   llvm::Value *Addr =

Modified: cfe/trunk/test/OpenMP/allocate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/allocate_codegen.cpp?rev=357933=357932=357933=diff
==
--- cfe/trunk/test/OpenMP/allocate_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/allocate_codegen.cpp Mon Apr  8 12:06:42 2019
@@ -17,15 +17,18 @@
 #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;
+enum omp_allocator_handle_t {
+  omp_null_allocator = 0,
+  omp_default_mem_alloc = 1,
+  omp_large_cap_mem_alloc = 2,
+  omp_const_mem_alloc = 3,
+  omp_high_bw_mem_alloc = 4,
+  omp_low_lat_mem_alloc = 5,
+  omp_cgroup_mem_alloc = 6,
+  omp_pteam_mem_alloc = 7,
+  omp_thread_mem_alloc = 8,
+  KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__

[PATCH] D60379: Make precompiled headers reproducible

2019-04-08 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

After looking at the bug report (https://bugs.debian.org/877359), I would like 
to point out that there is currently *absolutely* no stability guarantee for 
the serialization format (ie, you need the exact same revision). In regard of 
this I am wondering how sane it is to ship pch files.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60379



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


[PATCH] D60379: Make precompiled headers reproducible

2019-04-08 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: lib/Serialization/ASTWriter.cpp:4283
+  // Sort to allow reproducible .pch files - https://bugs.debian.org/877359
+  std::map> sortedOpenCLTypeExtMap;
   for (const auto  : SemaRef.OpenCLTypeExtMap) {

lebedev.ri wrote:
> Anastasia wrote:
> > lebedev.ri wrote:
> > > Would it be better to just change the actual type of 
> > > `SemaRef.OpenCLTypeExtMap`?
> > > https://github.com/llvm-mirror/clang/blob/18917301298ad6df9e989983ed1e22cb0f9dff29/include/clang/Sema/Sema.h#L8710-L8712
> > What data structure would you suggest to use instead? I think sorting 
> > during serialization or de-serialization of AST isn't too bad because it's 
> > not a common use case.
> Just `std::map<>`?
Why is this a problem ? I thought that pch files where not supposed to be 
distributed. If we come to the conclusion that pch files must be reproducible, 
then I believe that this is by far not the only example.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60379



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


r357928 - [MS] Add metadata for __declspec(allocator)

2019-04-08 Thread Amy Huang via cfe-commits
Author: akhuang
Date: Mon Apr  8 10:58:29 2019
New Revision: 357928

URL: http://llvm.org/viewvc/llvm-project?rev=357928=rev
Log:
[MS] Add metadata for __declspec(allocator)

Summary:
Emit !heapallocsite in the metadata for calls to functions marked with
__declspec(allocator). Eventually this will be emitted as S_HEAPALLOCSITE debug
info in codeview.

Reviewers: rnk

Subscribers: jfb, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeGen/debug-info-codeview-heapallocsite.c
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=357928=357927=357928=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Apr  8 10:58:29 2019
@@ -3800,6 +3800,8 @@ RValue CodeGenFunction::EmitCall(const C
 
   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 @@ RValue CodeGenFunction::EmitCall(const C
   // 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 @@ RValue CodeGenFunction::EmitCall(const C
 
   // 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 @@ RValue CodeGenFunction::EmitCall(const C
   } ();
 
   // 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;

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=357928=357927=357928=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Apr  8 10:58:29 2019
@@ -1959,6 +1959,20 @@ llvm::DIType *CGDebugInfo::getOrCreateSt
   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;

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=357928=357927=357928=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Mon Apr  8 10:58:29 2019
@@ -476,6 +476,10 @@ public:
   /// 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);

Added: 

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

2019-04-08 Thread Amy Huang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL357928: [MS] Add metadata for __declspec(allocator) 
(authored by akhuang, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60237?vs=194164=194174#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60237

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

Index: cfe/trunk/test/CodeGen/debug-info-codeview-heapallocsite.c
===
--- cfe/trunk/test/CodeGen/debug-info-codeview-heapallocsite.c
+++ cfe/trunk/test/CodeGen/debug-info-codeview-heapallocsite.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -debug-info-kind=limited -gcodeview -fdeclspec -S -emit-llvm < %s | FileCheck %s
+
+struct Foo {
+  int x;
+};
+
+__declspec(allocator) void *alloc_void();
+__declspec(allocator) struct Foo *alloc_foo();
+
+void call_alloc_void() {
+  struct Foo *p = (struct Foo*)alloc_void();
+}
+
+void call_alloc_foo() {
+  struct Foo *p = alloc_foo();
+}
+
+// CHECK-LABEL: define {{.*}}void @call_alloc_void
+// CHECK: call i8* {{.*}}@alloc_void{{.*}} !heapallocsite [[DBG1:!.*]]
+
+// CHECK-LABEL: define {{.*}}void @call_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: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -1959,6 +1959,20 @@
   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: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/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) {
 if (const auto *AA = TargetDecl->getAttr()) {
   llvm::Value *OffsetValue = nullptr;
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.h
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h
@@ -476,6 +476,10 @@
   /// Emit standalone debug info for a type.
   llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation 

[PATCH] D60379: Make precompiled headers reproducible

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



Comment at: lib/Serialization/ASTWriter.cpp:4283
+  // Sort to allow reproducible .pch files - https://bugs.debian.org/877359
+  std::map> sortedOpenCLTypeExtMap;
   for (const auto  : SemaRef.OpenCLTypeExtMap) {

Anastasia wrote:
> lebedev.ri wrote:
> > Would it be better to just change the actual type of 
> > `SemaRef.OpenCLTypeExtMap`?
> > https://github.com/llvm-mirror/clang/blob/18917301298ad6df9e989983ed1e22cb0f9dff29/include/clang/Sema/Sema.h#L8710-L8712
> What data structure would you suggest to use instead? I think sorting during 
> serialization or de-serialization of AST isn't too bad because it's not a 
> common use case.
Just `std::map<>`?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60379



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


[PATCH] D60379: Make precompiled headers reproducible

2019-04-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Serialization/ASTWriter.cpp:4283
+  // Sort to allow reproducible .pch files - https://bugs.debian.org/877359
+  std::map> sortedOpenCLTypeExtMap;
   for (const auto  : SemaRef.OpenCLTypeExtMap) {

lebedev.ri wrote:
> Would it be better to just change the actual type of 
> `SemaRef.OpenCLTypeExtMap`?
> https://github.com/llvm-mirror/clang/blob/18917301298ad6df9e989983ed1e22cb0f9dff29/include/clang/Sema/Sema.h#L8710-L8712
What data structure would you suggest to use instead? I think sorting during 
serialization or de-serialization of AST isn't too bad because it's not a 
common use case.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60379



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


[PATCH] D59985: [OpenCL] Re-fix invalid address space generation for clk_event_t arguments of enqueue_kernel builtin function

2019-04-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Great! Thanks!




Comment at: lib/CodeGen/CGBuiltin.cpp:3709
+  llvm::Value *EventWaitList = nullptr;
+  if (E->getArg(4)->isNullPointerConstant(
+  getContext(), Expr::NPC_ValueDependentIsNotNull)) {

Just a minor issue of style, you could probably use a common lambda helper 
here. Although it's only used in this two places so definitely not that 
critical. It might be helpful mainly if we need to fix something later...


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

https://reviews.llvm.org/D59985



___
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-08 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 194164.
akhuang marked 2 inline comments as done.
akhuang added a comment.

Fixes to test case


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,27 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -debug-info-kind=limited -gcodeview -fdeclspec -S -emit-llvm < %s | FileCheck %s
+
+struct Foo {
+  int x;
+};
+
+__declspec(allocator) void *alloc_void();
+__declspec(allocator) struct Foo *alloc_foo();
+
+void call_alloc_void() {
+  struct Foo *p = (struct Foo*)alloc_void();
+}
+
+void call_alloc_foo() {
+  struct Foo *p = alloc_foo();
+}
+
+// CHECK-LABEL: define {{.*}}void @call_alloc_void
+// CHECK: call i8* {{.*}}@alloc_void{{.*}} !heapallocsite [[DBG1:!.*]]
+
+// CHECK-LABEL: define {{.*}}void @call_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) {
 if (const auto *AA = TargetDecl->getAttr()) {
   llvm::Value *OffsetValue = nullptr;

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

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

Will the ARC-contract pass recognize both, or are you adding a BC upgrader that 
rewrites the global metadata into a module flag?


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


r357924 - [X86] Add some fp to integer conversion intrinsics to Sema::CheckX86BuiltinRoundingOrSAE so their rounding controls will be checked.

2019-04-08 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon Apr  8 10:05:57 2019
New Revision: 357924

URL: http://llvm.org/viewvc/llvm-project?rev=357924=rev
Log:
[X86] Add some fp to integer conversion intrinsics to 
Sema::CheckX86BuiltinRoundingOrSAE so their rounding controls will be checked.

If we don't check this in the frontend we'll get an isel error in the backend 
later. This is far less friendly to users.

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=357924=357923=357924=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Apr  8 10:05:57 2019
@@ -3429,9 +3429,13 @@ bool Sema::CheckX86BuiltinRoundingOrSAE(
   case X86::BI__builtin_ia32_cvtdq2ps512_mask:
   case X86::BI__builtin_ia32_cvtudq2ps512_mask:
   case X86::BI__builtin_ia32_cvtpd2ps512_mask:
+  case X86::BI__builtin_ia32_cvtpd2dq512_mask:
   case X86::BI__builtin_ia32_cvtpd2qq512_mask:
+  case X86::BI__builtin_ia32_cvtpd2udq512_mask:
   case X86::BI__builtin_ia32_cvtpd2uqq512_mask:
+  case X86::BI__builtin_ia32_cvtps2dq512_mask:
   case X86::BI__builtin_ia32_cvtps2qq512_mask:
+  case X86::BI__builtin_ia32_cvtps2udq512_mask:
   case X86::BI__builtin_ia32_cvtps2uqq512_mask:
   case X86::BI__builtin_ia32_cvtqq2pd512_mask:
   case X86::BI__builtin_ia32_cvtqq2ps512_mask:


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


[PATCH] D60406: Move the builtin headers to use the new license file header.

2019-04-08 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel accepted this revision.
hfinkel added a comment.
This revision is now accepted and ready to land.

LGTM.  Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60406



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


r357923 - [OPENMP][NVPTX]Fixed processing of memory management directives.

2019-04-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Apr  8 09:53:57 2019
New Revision: 357923

URL: http://llvm.org/viewvc/llvm-project?rev=357923=rev
Log:
[OPENMP][NVPTX]Fixed processing of memory management directives.

Added special processing of the memory management directives/clauses for
NVPTX target. For private locals, omp_default_mem_alloc and
omp_thread_mem_alloc result in allocation in local memory.
omp_const_mem_alloc allocates const memory, omp_teams_mem_alloc
allocates shared memory, and omp_cgroup_mem_alloc and
omp_large_cap_mem_alloc allocate global memory.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_allocate_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=357923=357922=357923=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon Apr  8 09:53:57 2019
@@ -318,6 +318,9 @@ class CheckVarsEscapingDeclContext final
 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
   return;
 VD = cast(VD->getCanonicalDecl());
+// Use user-specified allocation.
+if (VD->hasAttrs() && VD->hasAttr())
+  return;
 // Variables captured by value must be globalized.
 if (auto *CSI = CGF.CapturedStmtInfo) {
   if (const FieldDecl *FD = CSI->lookup(cast(VD))) {
@@ -4725,7 +4728,6 @@ void CGOpenMPRuntimeNVPTX::emitFunctionP
 
 Address CGOpenMPRuntimeNVPTX::getAddressOfLocalVariable(CodeGenFunction ,
 const VarDecl *VD) {
-  bool UseDefaultAllocator = true;
   if (VD && VD->hasAttr()) {
 const auto *A = VD->getAttr();
 switch (A->getAllocatorType()) {
@@ -4733,17 +4735,48 @@ Address CGOpenMPRuntimeNVPTX::getAddress
   // threadlocal.
 case OMPAllocateDeclAttr::OMPDefaultMemAlloc:
 case OMPAllocateDeclAttr::OMPThreadMemAlloc:
-  // Just pass-through to check if the globalization is required.
-  break;
-case OMPAllocateDeclAttr::OMPLargeCapMemAlloc:
-case OMPAllocateDeclAttr::OMPCGroupMemAlloc:
 case OMPAllocateDeclAttr::OMPHighBWMemAlloc:
 case OMPAllocateDeclAttr::OMPLowLatMemAlloc:
-case OMPAllocateDeclAttr::OMPConstMemAlloc:
-case OMPAllocateDeclAttr::OMPPTeamMemAlloc:
+  // Follow the user decision - use default allocation.
+  return Address::invalid();
 case OMPAllocateDeclAttr::OMPUserDefinedMemAlloc:
-  UseDefaultAllocator = false;
-  break;
+  // TODO: implement aupport for user-defined allocators.
+  return Address::invalid();
+case OMPAllocateDeclAttr::OMPConstMemAlloc: {
+  llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());
+  auto *GV = new llvm::GlobalVariable(
+  CGM.getModule(), VarTy, /*isConstant=*/false,
+  llvm::GlobalValue::InternalLinkage,
+  llvm::Constant::getNullValue(VarTy), VD->getName(),
+  /*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal,
+  CGM.getContext().getTargetAddressSpace(LangAS::cuda_constant));
+  CharUnits Align = CGM.getContext().getDeclAlign(VD);
+  GV->setAlignment(Align.getQuantity());
+  return Address(GV, Align);
+}
+case OMPAllocateDeclAttr::OMPPTeamMemAlloc: {
+  llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());
+  auto *GV = new llvm::GlobalVariable(
+  CGM.getModule(), VarTy, /*isConstant=*/false,
+  llvm::GlobalValue::InternalLinkage,
+  llvm::Constant::getNullValue(VarTy), VD->getName(),
+  /*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal,
+  CGM.getContext().getTargetAddressSpace(LangAS::cuda_shared));
+  CharUnits Align = CGM.getContext().getDeclAlign(VD);
+  GV->setAlignment(Align.getQuantity());
+  return Address(GV, Align);
+}
+case OMPAllocateDeclAttr::OMPLargeCapMemAlloc:
+case OMPAllocateDeclAttr::OMPCGroupMemAlloc: {
+  llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());
+  auto *GV = new llvm::GlobalVariable(
+  CGM.getModule(), VarTy, /*isConstant=*/false,
+  llvm::GlobalValue::InternalLinkage,
+  llvm::Constant::getNullValue(VarTy), VD->getName());
+  CharUnits Align = CGM.getContext().getDeclAlign(VD);
+  GV->setAlignment(Align.getQuantity());
+  return Address(GV, Align);
+}
 }
   }
 
@@ -4769,11 +4802,6 @@ Address CGOpenMPRuntimeNVPTX::getAddress
 }
   }
 
-  // TODO: replace it with return
-  // UseDefaultAllocator ? Address::invalid :
-  // CGOpenMPRuntime::getAddressOfLocalVariable(CGF, VD); when NVPTX libomp
-  // supports __kmpc_alloc|__kmpc_free.
-  (void)UseDefaultAllocator; // Prevent a warning.
   return Address::invalid();
 }
 

Modified: cfe/trunk/test/OpenMP/nvptx_allocate_codegen.cpp
URL: 

[PATCH] D57265: [PM/CC1] Add -f[no-]split-cold-code CC1 options to toggle splitting

2019-04-08 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Ping.


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

https://reviews.llvm.org/D57265



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


r357922 - Remove a bogus sed option in test.

2019-04-08 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Apr  8 09:34:38 2019
New Revision: 357922

URL: http://llvm.org/viewvc/llvm-project?rev=357922=rev
Log:
Remove a bogus sed option in test.

Modified:
cfe/trunk/test/Tooling/clang-check-fixit.cpp

Modified: cfe/trunk/test/Tooling/clang-check-fixit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-fixit.cpp?rev=357922=357921=357922=diff
==
--- cfe/trunk/test/Tooling/clang-check-fixit.cpp (original)
+++ cfe/trunk/test/Tooling/clang-check-fixit.cpp Mon Apr  8 09:34:38 2019
@@ -1,10 +1,10 @@
 // RUN: rm -rf %t
 // RUN: mkdir %t
 //
-// RUN: sed -s 's,^//.*,//,' %s > %t/absolute-fixed.cpp
-// RUN: sed -s 's,^//.*,//,' %s > %t/absolute-json.cpp
-// RUN: sed -s 's,^//.*,//,' %s > %t/relative-fixed.cpp
-// RUN: sed -s 's,^//.*,//,' %s > %t/relative-json.cpp
+// RUN: sed 's,^//.*,//,' %s > %t/absolute-fixed.cpp
+// RUN: sed 's,^//.*,//,' %s > %t/absolute-json.cpp
+// RUN: sed 's,^//.*,//,' %s > %t/relative-fixed.cpp
+// RUN: sed 's,^//.*,//,' %s > %t/relative-json.cpp
 //
 // RUN: clang-check %t/absolute-fixed.cpp -fixit -- 2>&1 | FileCheck %s
 //


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


r357921 - Remove a useless assertion in clang-check.

2019-04-08 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Apr  8 09:29:43 2019
New Revision: 357921

URL: http://llvm.org/viewvc/llvm-project?rev=357921=rev
Log:
Remove a useless assertion in clang-check.

Re-commit r357915 with a fix for windows.

The assertion prevents it from applying fixes when used along with compilation
databases with relative paths. Added a test that demonstrates the assertion
failure.

An example of the assertion:
input.cpp:11:14: error: expected ';' after top level declarator
typedef int T
 ^
 ;
input.cpp:11:14: note: FIX-IT applied suggested code changes
clang-check: clang/tools/clang-check/ClangCheck.cpp:94: virtual std::string 
(anonymous namespace)::FixItOptions::RewriteFilename(const std::string &, int 
&): Assertion `llvm::sys::path::is_absolute(filename) && "clang-fixit expects 
absolute paths only."' failed.
  #0 llvm::sys::PrintStackTrace(llvm::raw_ostream&) 
llvm/lib/Support/Unix/Signals.inc:494:13
  #1 llvm::sys::RunSignalHandlers() llvm/lib/Support/Signals.cpp:69:18
  #2 SignalHandler(int) llvm/lib/Support/Unix/Signals.inc:357:1
  #3 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
  #4 raise (/lib/x86_64-linux-gnu/libc.so.6+0x32fcf)
  #5 abort (/lib/x86_64-linux-gnu/libc.so.6+0x343fa)
  #6 (/lib/x86_64-linux-gnu/libc.so.6+0x2be37)
  #7 (/lib/x86_64-linux-gnu/libc.so.6+0x2bee2)
  #8 void std::__cxx11::basic_string, 
std::allocator >::_M_construct(char*, char*, 
std::forward_iterator_tag)
  #9 void std::__cxx11::basic_string, 
std::allocator >::_M_construct_aux(char*, char*, std::__false_type)
 #10 void std::__cxx11::basic_string, 
std::allocator >::_M_construct(char*, char*)
 #11 std::__cxx11::basic_string, 
std::allocator >::basic_string(std::__cxx11::basic_string, std::allocator > const&)
 #12 (anonymous 
namespace)::FixItOptions::RewriteFilename(std::__cxx11::basic_string, std::allocator > const&, int&) 
clang/tools/clang-check/ClangCheck.cpp:101:0
 #13 std::__cxx11::basic_string, 
std::allocator >::_M_data() const
 #14 std::__cxx11::basic_string, 
std::allocator >::_M_is_local() const
 #15 std::__cxx11::basic_string, 
std::allocator >::_M_dispose()
 #16 std::__cxx11::basic_string, 
std::allocator >::~basic_string()
 #17 
clang::FixItRewriter::WriteFixedFiles(std::vector, std::allocator >, 
std::__cxx11::basic_string, std::allocator > 
>, std::allocator, std::allocator >, 
std::__cxx11::basic_string, std::allocator > 
> > >*) clang/lib/Frontend/Rewrite/FixItRewriter.cpp:98:0
 #18 std::__shared_ptr::get() const
 #19 std::__shared_ptr_access::_M_get() const
 #20 std::__shared_ptr_access::operator->() const
 #21 clang::CompilerInstance::getFrontendOpts() 
clang/include/clang/Frontend/CompilerInstance.h:290:0
 #22 clang::FrontendAction::EndSourceFile() 
clang/lib/Frontend/FrontendAction.cpp:966:0
 #23 __gnu_cxx::__normal_iterator 
> >::operator++()
 #24 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) 
clang/lib/Frontend/CompilerInstance.cpp:943:0
 #25 
clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr,
 clang::FileManager*, std::shared_ptr, 
clang::DiagnosticConsumer*) clang/lib/Tooling/Tooling.cpp:369:33
 #26 clang::tooling::ToolInvocation::runInvocation(char const*, 
clang::driver::Compilation*, std::shared_ptr, 
std::shared_ptr) 
clang/lib/Tooling/Tooling.cpp:344:18
 #27 clang::tooling::ToolInvocation::run() clang/lib/Tooling/Tooling.cpp:329:10
 #28 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) 
clang/lib/Tooling/Tooling.cpp:518:11
 #29 main clang/tools/clang-check/ClangCheck.cpp:187:15

Added:
cfe/trunk/test/Tooling/clang-check-fixit.cpp
Modified:
cfe/trunk/tools/clang-check/ClangCheck.cpp

Added: cfe/trunk/test/Tooling/clang-check-fixit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-fixit.cpp?rev=357921=auto
==
--- cfe/trunk/test/Tooling/clang-check-fixit.cpp (added)
+++ cfe/trunk/test/Tooling/clang-check-fixit.cpp Mon Apr  8 09:29:43 2019
@@ -0,0 +1,21 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// RUN: sed -s 's,^//.*,//,' %s > %t/absolute-fixed.cpp
+// RUN: sed -s 's,^//.*,//,' %s > %t/absolute-json.cpp
+// RUN: sed -s 's,^//.*,//,' %s > %t/relative-fixed.cpp
+// RUN: sed -s 's,^//.*,//,' %s > %t/relative-json.cpp
+//
+// RUN: clang-check %t/absolute-fixed.cpp -fixit -- 2>&1 | FileCheck %s
+//
+// RUN: echo "[{ \"directory\":\"%/t\", \"command\":\"/path/to/clang -c 
%/t/absolute-json.cpp\", \"file\": \"%/t/absolute-json.cpp\" }]" > 
%t/compile_commands.json
+// RUN: clang-check %t/absolute-json.cpp -fixit 2>&1 | FileCheck %s
+//
+// RUN: cd %t
+// RUN: clang-check relative-fixed.cpp -fixit -- 2>&1 | FileCheck %s
+//
+// RUN: echo "[{ \"directory\": \"%/t\", \"command\": \"/path/to/clang -c 
relative-json.cpp\", \"file\": \"relative-json.cpp\" }]" > 
%t/compile_commands.json
+// RUN: clang-check relative-json.cpp -fixit 2>&1 | FileCheck %s
+typedef int T
+// CHECK: .cpp:[[@LINE-1]]:14: error: 

[PATCH] D59746: [LibTooling] Fix '-h' option

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

In D59746#1458461 , @hintonda wrote:

> In D59746#1458432 , @klimek wrote:
>
> > If we make it an alias by default, can somebody overwrite that?
>
>
> Unfortunately, that produces a runtime error:
>
>   lan1:/Users/dhinton/projects/llvm_project/monorepo/build/Debug $ 
> bin/llvm-objdump -h
>   : CommandLine Error: Option 'h' registered more than once!
>   LLVM ERROR: inconsistency in registered CommandLine options
>
>
> The operative lines:
>
>   llvm/tools/llvm-objdump/llvm-objdump.cpp:187:static cl::alias 
> SectionHeadersShorter("h",
>   llvm/lib/Support/CommandLine.cpp:2149:static cl::alias HOpA("h", 
> cl::desc("Alias for -help"), cl::aliasopt(HOp));
>


The other problem is that these are statics, so you can't count on the order, 
i.e., did the user overwrite get processed before or after the one in 
`CommandLine.cpp`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59746



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


[PATCH] D60055: Check i < FD->getNumParams() before querying

2019-04-08 Thread Violet via Phabricator via cfe-commits
Violet marked 2 inline comments as done.
Violet added inline comments.



Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:2895
   // function and isn't necessarily referring to one of FD's parameters.
-  if (FD->getParamDecl(i) == PV)
+  if (i < FD->getNumParams() && FD->getParamDecl(i) == PV)
 return FD->getCanonicalDecl()->getParamDecl(i);

lebedev.ri wrote:
> Have you analyzed how we get here?
> Maybe the caller code is faulty?
It's not the caller's fault. The cause is that a function pointer or a function 
typedef isn't a declcontext, so even if the getDeclContext() of its parameter 
returns a function, it has nothing to do with its own ParmVarDecl. That's why 
we check if the corresponding ParmVarDecl is the same one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60055



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


[PATCH] D59371: [LibTooling] Add Stencil library for format-string style codegen.

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

Add `operator()` to Stencil for compatability with TextGenerator.

Stencil is technically independent of Transformer.  However, Transformers
replacements and explanations take a generic std::function (there abbreviated as
`TextGenerator`). This addition let's Stencils act as TextGenerators.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59371

Files:
  clang/include/clang/Tooling/Refactoring/Stencil.h
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Refactoring/Stencil.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -0,0 +1,222 @@
+//===- unittest/Tooling/StencilTest.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/Stencil.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/FixIt.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace tooling;
+using namespace ast_matchers;
+
+namespace {
+using ::testing::AllOf;
+using ::testing::Eq;
+using ::testing::HasSubstr;
+using MatchResult = MatchFinder::MatchResult;
+using tooling::stencil::node;
+using tooling::stencil::snode;
+using tooling::stencil::text;
+
+// In tests, we can't directly match on llvm::Expected since its accessors
+// mutate the object. So, we collapse it to an Optional.
+static llvm::Optional toOptional(llvm::Expected V) {
+  if (V)
+return *V;
+  ADD_FAILURE() << "Losing error in conversion to IsSomething: "
+<< llvm::toString(V.takeError());
+  return llvm::None;
+}
+
+// A very simple matcher for llvm::Optional values.
+MATCHER_P(IsSomething, ValueMatcher, "") {
+  if (!arg)
+return false;
+  return ::testing::ExplainMatchResult(ValueMatcher, *arg, result_listener);
+}
+
+// Create a valid translation-unit from a statement.
+static std::string wrapSnippet(llvm::Twine StatementCode) {
+  return ("auto stencil_test_snippet = []{" + StatementCode + "};").str();
+}
+
+static DeclarationMatcher wrapMatcher(const StatementMatcher ) {
+  return varDecl(hasName("stencil_test_snippet"),
+ hasDescendant(compoundStmt(hasAnySubstatement(Matcher;
+}
+
+struct TestMatch {
+  // The AST unit from which `result` is built. We bundle it because it backs
+  // the result. Users are not expected to access it.
+  std::unique_ptr AstUnit;
+  // The result to use in the test. References `ast_unit`.
+  MatchResult Result;
+};
+
+// Matches `Matcher` against the statement `StatementCode` and returns the
+// result. Handles putting the statement inside a function and modifying the
+// matcher correspondingly. `Matcher` should match `StatementCode` exactly --
+// that is, produce exactly one match.
+static llvm::Optional matchStmt(llvm::Twine StatementCode,
+   StatementMatcher Matcher) {
+  auto AstUnit = buildASTFromCode(wrapSnippet(StatementCode));
+  if (AstUnit == nullptr) {
+ADD_FAILURE() << "AST construction failed";
+return llvm::None;
+  }
+  ASTContext  = AstUnit->getASTContext();
+  auto Matches = ast_matchers::match(wrapMatcher(Matcher), Context);
+  // We expect a single, exact match for the statement.
+  if (Matches.size() != 1) {
+ADD_FAILURE() << "Wrong number of matches: " << Matches.size();
+return llvm::None;
+  }
+  return TestMatch{std::move(AstUnit), MatchResult(Matches[0], )};
+}
+
+class StencilTest : public ::testing::Test {
+protected:
+  // Verifies that the given stencil fails when evaluated on a valid match
+  // result. Binds a statement to "stmt", a (non-member) ctor-initializer to
+  // "init", an expression to "expr" and a (nameless) declaration to "decl".
+  void testError(const Stencil ,
+ ::testing::Matcher Matcher) {
+const std::string Snippet = R"cc(
+  struct A {};
+  class F : public A {
+   public:
+F(int) {}
+  };
+  F(1);
+)cc";
+auto StmtMatch = matchStmt(
+Snippet,
+stmt(hasDescendant(
+ cxxConstructExpr(
+ hasDeclaration(decl(hasDescendant(cxxCtorInitializer(
+   isBaseInitializer())
+   .bind("init")))
+.bind("decl")))
+ .bind("expr")))
+ 

r357918 - Revert rL357915 from cfe/trunk: Remove a useless assertion in clang-check.

2019-04-08 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Mon Apr  8 08:49:19 2019
New Revision: 357918

URL: http://llvm.org/viewvc/llvm-project?rev=357918=rev
Log:
Revert rL357915 from cfe/trunk: Remove a useless assertion in clang-check.

The assertion prevents it from applying fixes when used along with compilation
databases with relative paths. Added a test that demonstrates the assertion
failure.

An example of the assertion:
input.cpp:11:14: error: expected ';' after top level declarator
typedef int T
 ^
 ;
input.cpp:11:14: note: FIX-IT applied suggested code changes
clang-check: clang/tools/clang-check/ClangCheck.cpp:94: virtual std::string 
(anonymous namespace)::FixItOptions::RewriteFilename(const std::string &, int 
&): Assertion `llvm::sys::path::is_absolute(filename) && "clang-fixit expects 
absolute paths only."' failed.
  #0 llvm::sys::PrintStackTrace(llvm::raw_ostream&) 
llvm/lib/Support/Unix/Signals.inc:494:13
  #1 llvm::sys::RunSignalHandlers() llvm/lib/Support/Signals.cpp:69:18
  #2 SignalHandler(int) llvm/lib/Support/Unix/Signals.inc:357:1
  #3 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
  #4 raise (/lib/x86_64-linux-gnu/libc.so.6+0x32fcf)
  #5 abort (/lib/x86_64-linux-gnu/libc.so.6+0x343fa)
  #6 (/lib/x86_64-linux-gnu/libc.so.6+0x2be37)
  #7 (/lib/x86_64-linux-gnu/libc.so.6+0x2bee2)
  #8 void std::__cxx11::basic_string, 
std::allocator >::_M_construct(char*, char*, 
std::forward_iterator_tag)
  #9 void std::__cxx11::basic_string, 
std::allocator >::_M_construct_aux(char*, char*, std::__false_type)
 #10 void std::__cxx11::basic_string, 
std::allocator >::_M_construct(char*, char*)
 #11 std::__cxx11::basic_string, 
std::allocator >::basic_string(std::__cxx11::basic_string, std::allocator > const&)
 #12 (anonymous 
namespace)::FixItOptions::RewriteFilename(std::__cxx11::basic_string, std::allocator > const&, int&) 
clang/tools/clang-check/ClangCheck.cpp:101:0
 #13 std::__cxx11::basic_string, 
std::allocator >::_M_data() const
 #14 std::__cxx11::basic_string, 
std::allocator >::_M_is_local() const
 #15 std::__cxx11::basic_string, 
std::allocator >::_M_dispose()
 #16 std::__cxx11::basic_string, 
std::allocator >::~basic_string()
 #17 
clang::FixItRewriter::WriteFixedFiles(std::vector, std::allocator >, 
std::__cxx11::basic_string, std::allocator > 
>, std::allocator, std::allocator >, 
std::__cxx11::basic_string, std::allocator > 
> > >*) clang/lib/Frontend/Rewrite/FixItRewriter.cpp:98:0
 #18 std::__shared_ptr::get() const
 #19 std::__shared_ptr_access::_M_get() const
 #20 std::__shared_ptr_access::operator->() const
 #21 clang::CompilerInstance::getFrontendOpts() 
clang/include/clang/Frontend/CompilerInstance.h:290:0
 #22 clang::FrontendAction::EndSourceFile() 
clang/lib/Frontend/FrontendAction.cpp:966:0
 #23 __gnu_cxx::__normal_iterator 
> >::operator++()
 #24 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) 
clang/lib/Frontend/CompilerInstance.cpp:943:0
 #25 
clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr,
 clang::FileManager*, std::shared_ptr, 
clang::DiagnosticConsumer*) clang/lib/Tooling/Tooling.cpp:369:33
 #26 clang::tooling::ToolInvocation::runInvocation(char const*, 
clang::driver::Compilation*, std::shared_ptr, 
std::shared_ptr) 
clang/lib/Tooling/Tooling.cpp:344:18
 #27 clang::tooling::ToolInvocation::run() clang/lib/Tooling/Tooling.cpp:329:10
 #28 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) 
clang/lib/Tooling/Tooling.cpp:518:11
 #29 main clang/tools/clang-check/ClangCheck.cpp:187:15

Breaks windows buildbots

Removed:
cfe/trunk/test/Tooling/clang-check-fixit.cpp
Modified:
cfe/trunk/tools/clang-check/ClangCheck.cpp

Removed: cfe/trunk/test/Tooling/clang-check-fixit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-fixit.cpp?rev=357917=auto
==
--- cfe/trunk/test/Tooling/clang-check-fixit.cpp (original)
+++ cfe/trunk/test/Tooling/clang-check-fixit.cpp (removed)
@@ -1,25 +0,0 @@
-// RUN: rm -rf %t
-// RUN: mkdir %t
-//
-// RUN: sed -s 's,^//.*,//,' %s > %t/absolute-fixed.cpp
-// RUN: sed -s 's,^//.*,//,' %s > %t/absolute-json.cpp
-// RUN: sed -s 's,^//.*,//,' %s > %t/relative-fixed.cpp
-// RUN: sed -s 's,^//.*,//,' %s > %t/relative-json.cpp
-//
-// RUN: clang-check %t/absolute-fixed.cpp -fixit -- 2>&1 | FileCheck %s
-//
-// RUN: echo '[{ "directory": "%t", \
-// RUN:   "command": "/path/to/clang -c %t/absolute-json.cpp", \
-// RUN:   "file": "%t/absolute-json.cpp" }]' > %t/compile_commands.json
-// RUN: clang-check %t/absolute-json.cpp -fixit 2>&1 | FileCheck %s
-//
-// RUN: cd %t
-// RUN: clang-check relative-fixed.cpp -fixit -- 2>&1 | FileCheck %s
-//
-// RUN: echo '[{ "directory": "%t", \
-// RUN:   "command": "/path/to/clang -c relative-json.cpp", \
-// RUN:   "file": "relative-json.cpp" }]' > %t/compile_commands.json
-// RUN: clang-check relative-json.cpp -fixit 2>&1 | FileCheck %s
-typedef int T
-// 

[PATCH] D60055: Check i < FD->getNumParams() before querying

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



Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:2895
   // function and isn't necessarily referring to one of FD's parameters.
-  if (FD->getParamDecl(i) == PV)
+  if (i < FD->getNumParams() && FD->getParamDecl(i) == PV)
 return FD->getCanonicalDecl()->getParamDecl(i);

Have you analyzed how we get here?
Maybe the caller code is faulty?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60055



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


[PATCH] D60055: Check i < FD->getNumParams() before querying

2019-04-08 Thread Violet via Phabricator via cfe-commits
Violet updated this revision to Diff 194152.
Violet added a comment.

Address reviewer comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60055

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/SemaCXX/PR41139.cpp
  clang/test/SemaCXX/cxx1y-generic-lambdas.cpp


Index: clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
===
--- clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
+++ clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
@@ -944,6 +944,15 @@
   }(0)(0);
 }
 
+namespace PR41139 {
+  int y = [](auto outer) {
+return [](auto inner) {
+  using T = int(decltype(outer), decltype(inner));
+  return 0;
+};
+  }(0)(0);
+}
+
 namespace PR23716 {
 template
 auto f(T x) {
Index: clang/test/SemaCXX/PR41139.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/PR41139.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+
+// expected-no-diagnostics
+
+// This test should not crash.
+int f1( unsigned ) { return 0; }
+
+template 
+struct S1 {
+S1( R(*f)(Args...) ) {}
+};
+
+int main() {
+S1 s1( f1 );
+}
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2892,7 +2892,7 @@
   unsigned i = PV->getFunctionScopeIndex();
   // This parameter might be from a freestanding function type within the
   // function and isn't necessarily referring to one of FD's parameters.
-  if (FD->getParamDecl(i) == PV)
+  if (i < FD->getNumParams() && FD->getParamDecl(i) == PV)
 return FD->getCanonicalDecl()->getParamDecl(i);
 }
   }


Index: clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
===
--- clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
+++ clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
@@ -944,6 +944,15 @@
   }(0)(0);
 }
 
+namespace PR41139 {
+  int y = [](auto outer) {
+return [](auto inner) {
+  using T = int(decltype(outer), decltype(inner));
+  return 0;
+};
+  }(0)(0);
+}
+
 namespace PR23716 {
 template
 auto f(T x) {
Index: clang/test/SemaCXX/PR41139.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/PR41139.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+
+// expected-no-diagnostics
+
+// This test should not crash.
+int f1( unsigned ) { return 0; }
+
+template 
+struct S1 {
+S1( R(*f)(Args...) ) {}
+};
+
+int main() {
+S1 s1( f1 );
+}
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2892,7 +2892,7 @@
   unsigned i = PV->getFunctionScopeIndex();
   // This parameter might be from a freestanding function type within the
   // function and isn't necessarily referring to one of FD's parameters.
-  if (FD->getParamDecl(i) == PV)
+  if (i < FD->getNumParams() && FD->getParamDecl(i) == PV)
 return FD->getCanonicalDecl()->getParamDecl(i);
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59746: [LibTooling] Fix '-h' option

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

In D59746#1458432 , @klimek wrote:

> In D59746#1458424 , @hintonda wrote:
>
> > In D59746#1458086 , @klimek wrote:
> >
> > > In D59746#1440756 , @hintonda 
> > > wrote:
> > >
> > > > A better alternative would have been to add a cl::aliasopt for '-h' in 
> > > > llvm's CommandLineParser when '-help' was first added.  However, that's 
> > > > no longer possible since some llvm based tools already use '-h' for 
> > > > other purposes.
> > >
> > >
> > > Is that intentional? Can you point at samples?
> >
> >
> > A quick grep found these -- there could be more.
> >
> > llvm-opt-report adds `-h` for help and handles it after 
> > `ParseCommandLineOptions` returns.
> >  llvm-objdump adds `-h` as an alias for `--section-headers`.
> >  dsymutil adds `-h` for help and handles it after `ParseCommandLineOptions` 
> > returns.
> >  llvm-readobj adds `-h` as an alias for `--file-headers`.
> >  llvm-dwarfdump adds `-h` for help and handles it after 
> > `ParseCommandLineOptions` returns.
> >  llvm-mt rolls its own via llvm-tblgen.
> >
> > So, the only ones I found that aren't essentially aliases for help are in 
> > llvm-objdump and llvm-readobj.
>
>
> If we make it an alias by default, can somebody overwrite that?


Unfortunately, that produces a runtime error:

  lan1:/Users/dhinton/projects/llvm_project/monorepo/build/Debug $ 
bin/llvm-objdump -h
  : CommandLine Error: Option 'h' registered more than once!
  LLVM ERROR: inconsistency in registered CommandLine options

The operative lines:

  llvm/tools/llvm-objdump/llvm-objdump.cpp:187:static cl::alias 
SectionHeadersShorter("h",
  llvm/lib/Support/CommandLine.cpp:2149:static cl::alias HOpA("h", 
cl::desc("Alias for -help"), cl::aliasopt(HOp));




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59746



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


[PATCH] D60409: [clangd] Add -header-insertion=never flag to disable include insertion in code completion

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

lg!




Comment at: clangd/CodeComplete.cpp:1176
   // This is available after Sema has run.
-  llvm::Optional Inserter;  // Available during runWithSema.
+  llvm::Optional Inserter;  // Optional during runWithSema.
   llvm::Optional FileProximity; // Initialized once Sema runs.

Why optional? In the current implementation, it's always initialized.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60409



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


[PATCH] D60362: [clang-format] [PR39719] clang-format converting object-like macro to function-like macro

2019-04-08 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2467-2470
+  if (Line.InPPDirective && Right.is(tok::l_paren) &&
+  !Left.is(tok::identifier) && Left.Previous &&
+  Left.Previous->is(tok::identifier) && Left.Previous->Previous &&
+  Left.Previous->Previous->is(tok::hash))

MyDeveloperDay wrote:
> klimek wrote:
> > MyDeveloperDay wrote:
> > > klimek wrote:
> > > > owenpan wrote:
> > > > > I think it can be more precise and simplified to something like this:
> > > > > ```
> > > > >   if (Left.Previous && Left.Previous->is(tok::pp_define) &&
> > > > >   Left.isNot(tok::identifier) && Right.is(tok::l_paren))
> > > > > ```
> > > > Why don't we have the same problem for identifier? Is that already 
> > > > solved and the problem is that this is a keyword redefinition?
> > > > 
> > > Yes the identifier seems to work ok, but when its a keyword redfinition 
> > > the identifier is replaced with the token for the keyword i.e. 
> > > tok::kw_true or tok::kw_false
> > And the idea is that for non-ID
> > #define true(x) x
> > won't work anyway? (otherwise this patch would be incorrect, right?)
> > 
> > Have you looked at where we detect the diff between
> > #define a(x) x
> > and
> > #define a (x)
> > in the identifier case and looked we could add common keyword macro cases 
> > there?
> I see what you mean, this path will reformat the false #define incorrectly
> 
> ```
> #define true ((foo)1)
> #define false(x) x
> 
> ```
> will be transformed to
> 
> ```
> #define true ((foo)1)
> #define false (x) x
> ```
> 
> 
> 
> 
Exactly.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60362



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


[PATCH] D60409: [clangd] Add -header-insertion=never flag to disable include insertion in code completion

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

One clear use case: use with an editor that reacts poorly to edits above the 
cursor.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D60409

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -32,7 +32,6 @@
 using ::llvm::Failed;
 using ::testing::AllOf;
 using ::testing::Contains;
-using ::testing::Each;
 using ::testing::ElementsAre;
 using ::testing::Field;
 using ::testing::HasSubstr;
@@ -556,6 +555,16 @@
  {Sym});
   EXPECT_THAT(Results.Completions,
   ElementsAre(AllOf(Named("X"), InsertInclude("\"bar.h\"";
+  // Can be disabled via option.
+  CodeCompleteOptions NoInsertion;
+  NoInsertion.InsertIncludes = CodeCompleteOptions::NeverInsert;
+  Results = completions(Server,
+ R"cpp(
+  int main() { ns::^ }
+  )cpp",
+ {Sym}, NoInsertion);
+  EXPECT_THAT(Results.Completions,
+  ElementsAre(AllOf(Named("X"), Not(InsertInclude();
   // Duplicate based on inclusions in preamble.
   Results = completions(Server,
 R"cpp(
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -6,8 +6,9 @@
 //
 //===--===//
 
-#include "Features.inc"
 #include "ClangdLSPServer.h"
+#include "CodeComplete.h"
+#include "Features.inc"
 #include "Path.h"
 #include "Protocol.h"
 #include "Trace.h"
@@ -154,6 +155,20 @@
 "debug-origin", llvm::cl::desc("Show origins of completion items"),
 llvm::cl::init(CodeCompleteOptions().ShowOrigins), llvm::cl::Hidden);
 
+static llvm::cl::opt HeaderInsertion(
+"header-insertion",
+llvm::cl::desc("Add #include directives when accepting code completions"),
+llvm::cl::init(CodeCompleteOptions().InsertIncludes),
+llvm::cl::values(
+clEnumValN(CodeCompleteOptions::IWYU, "iwyu",
+   "Include what you use. "
+   "Insert the owning header for top-level symbols, unless the "
+   "header is already directly included or the symbol is "
+   "forward-declared."),
+clEnumValN(
+CodeCompleteOptions::NeverInsert, "never",
+"Never insert #include directives as part of code completion")));
+
 static llvm::cl::opt HeaderInsertionDecorators(
 "header-insertion-decorators",
 llvm::cl::desc("Prepend a circular dot or space before the completion "
@@ -430,6 +445,7 @@
   CCOpts.Limit = LimitResults;
   CCOpts.BundleOverloads = CompletionStyle != Detailed;
   CCOpts.ShowOrigins = ShowOrigins;
+  CCOpts.InsertIncludes = HeaderInsertion;
   if (!HeaderInsertionDecorators) {
 CCOpts.IncludeIndicator.Insert.clear();
 CCOpts.IncludeIndicator.NoInsert.clear();
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -68,6 +68,11 @@
   /// If more results are available, we set CompletionList.isIncomplete.
   size_t Limit = 0;
 
+  enum IncludeInsertion {
+IWYU,
+NeverInsert,
+  } InsertIncludes = IncludeInsertion::IWYU;
+
   /// A visual indicator to prepend to the completion label to indicate whether
   /// completion result would trigger an #include insertion or not.
   struct IncludeInsertionIndicator {
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -190,7 +190,9 @@
 
   // Returns a token identifying the overload set this is part of.
   // 0 indicates it's not part of any overload set.
-  size_t overloadSet() const {
+  size_t overloadSet(const CodeCompleteOptions ) const {
+if (!Opts.BundleOverloads)
+  return 0;
 llvm::SmallString<256> Scratch;
 if (IndexResult) {
   switch (IndexResult->SymInfo.Kind) {
@@ -207,7 +209,7 @@
 // This could break #include insertion.
 return llvm::hash_combine(
 (IndexResult->Scope + IndexResult->Name).toStringRef(Scratch),
-headerToInsertIfAllowed().getValueOr(""));
+headerToInsertIfAllowed(Opts).getValueOr(""));
   default:
 return 0;
   }
@@ -222,12 +224,14 @@
   D->printQualifiedName(OS);
 }
 return llvm::hash_combine(Scratch,
-  headerToInsertIfAllowed().getValueOr(""));
+  

[PATCH] D60055: Check i < FD->getNumParams() before querying

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



Comment at: clang/test/SemaCXX/PR41139.cpp:3
+
+// expected-no-diagnostics
+

Add a comment what this test does?
('just checking that the crash does not happen again')



Comment at: clang/test/SemaCXX/cxx1y-generic-lambdas.cpp:946
+
+  int y = [](auto outer) {
+return [](auto inner) {

Does this have to be in that namespace?
Can you put it into a new namespace referencing this review?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60055



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


[PATCH] D59924: [PowerPC][Clang] Port MMX intrinsics and basic test cases to Power

2019-04-08 Thread Jinsong Ji via Phabricator via cfe-commits
jsji requested changes to this revision.
jsji added a comment.
This revision now requires changes to proceed.

Since we are adding new headers that is not originated by this patch, 
please also update the description (and commit message) to include who actually 
contributed to `mmintrin.h` and other headers.
eg:headers are mostly based on headers developed by Steven Munroe, with some 
contribution of Paul Clarke, Bill Schmidt,  Jinsong, Zeson.




Comment at: clang/lib/Driver/ToolChains/PPCLinux.cpp:22
+  if (getArch() != llvm::Triple::ppc &&
+  !DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) &&
+  !DriverArgs.hasArg(options::OPT_nobuiltininc)) {

Why we want to exclude these includes when `nostdinc` is on? These include 
files are NOT standard include files.



Comment at: clang/lib/Driver/ToolChains/PPCLinux.h:30
+} // end namespace toolchains
+} // namespace driver
+} // namespace clang

missing `end` in comment?



Comment at: clang/test/CodeGen/ppc-mmintrin.c:24
+// CHECK: [[REG1:[0-9a-zA-Z_%.]+]] = call <8 x i16> @vec_cmplt
+// CHECK: store <8 x i16> [[REG1]], <8 x i16>* [[REG2:[0-9a-zA-Z_%.]+]], align 
16
+// CHECK: [[REG3:[0-9a-zA-Z_%.]+]] = call <16 x i8> @vec_packs

We should use `CHECK-NEXT` instead of `CHECK` here. This also apply to most of 
the following `CHECK`.



Comment at: clang/test/CodeGen/ppc-mmintrin.c:25
+// CHECK: store <8 x i16> [[REG1]], <8 x i16>* [[REG2:[0-9a-zA-Z_%.]+]], align 
16
+// CHECK: [[REG3:[0-9a-zA-Z_%.]+]] = call <16 x i8> @vec_packs
+// CHECK: store <16 x i8> [[REG3]], <16 x i8>* [[REG4:[0-9a-zA-Z_%.]+]], align 
16

Why we omit checking two `load` for `vec_packs` here?



Comment at: clang/test/CodeGen/ppc-mmintrin.c:36
+// CHECK: i64 @_mm_packs_pi16(i64 {{[0-9a-zA-Z_%.]+}}, i64 {{[0-9a-zA-Z_%.]+}})
+// CHECK: call <16 x i8> @vec_packs(short vector[8], short vector[8])
+

We should also check the `load` and make sure that the endian-specific code are 
working.



Comment at: clang/test/Headers/ppc-intrinsics.c:3
+
+// RUN: %clang -S -emit-llvm -DNO_WARN_X86_INTRINSICS -DTEST_MACRO -target 
powerpc64-gnu-linux %s -Xclang -verify -o - | FileCheck %s
+// RUN: %clang -S -emit-llvm -DNO_WARN_X86_INTRINSICS -target 
powerpc64-gnu-linux %s -Xclang -verify -x c++ -o - | FileCheck %s

Why `-DTEST_MACRO`?



Comment at: clang/test/Headers/ppc-intrinsics.c:7
+
+// RUN: NOT %clang -S -emit-llvm -target powerpc64-gnu-linux %s -o /dev/null 
2>&1 | FileCheck %s -check-prefix=CHECK-ERROR
+

NOT? 
` NOT: command not found ^`


Repository:
  rC Clang

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

https://reviews.llvm.org/D59924



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


[PATCH] D59746: [LibTooling] Fix '-h' option

2019-04-08 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In D59746#1458424 , @hintonda wrote:

> In D59746#1458086 , @klimek wrote:
>
> > In D59746#1440756 , @hintonda 
> > wrote:
> >
> > > A better alternative would have been to add a cl::aliasopt for '-h' in 
> > > llvm's CommandLineParser when '-help' was first added.  However, that's 
> > > no longer possible since some llvm based tools already use '-h' for other 
> > > purposes.
> >
> >
> > Is that intentional? Can you point at samples?
>
>
> A quick grep found these -- there could be more.
>
> llvm-opt-report adds `-h` for help and handles it after 
> `ParseCommandLineOptions` returns.
>  llvm-objdump adds `-h` as an alias for `--section-headers`.
>  dsymutil adds `-h` for help and handles it after `ParseCommandLineOptions` 
> returns.
>  llvm-readobj adds `-h` as an alias for `--file-headers`.
>  llvm-dwarfdump adds `-h` for help and handles it after 
> `ParseCommandLineOptions` returns.
>  llvm-mt rolls its own via llvm-tblgen.
>
> So, the only ones I found that aren't essentially aliases for help are in 
> llvm-objdump and llvm-readobj.


If we make it an alias by default, can somebody overwrite that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59746



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


[PATCH] D59135: Add check for matching HeaderFilter before emitting Diagnostic

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

In D59135#1458265 , @thorsten-klein 
wrote:

> Hello @alexfh ,
>  Let me extend your example
>
>   $ cat a.cc 
>   #include "b.h"
>   #include "d.h"
>   int main(){check(nullptr);}
>   $ cat b.h 
>   #include "c.h"
>   inline void b() { c(/*y=*/42); }
>   $ cat c.h 
>   void c(int x);
>   $ cat d.h 
>   inline char* check(char* buffer)
>   {
>   *buffer++=1; // Should be clang-analyzer-core.NullDereference
>   return buffer;
>   }
>  
>
>
> Now an additional warning is found and shown (=not suppressed):
>
>   $ clang-tidy -checks=-*,clang-*,bugprone-argument-comment a.cc --
>   2 warnings generated.
>   /home/default/Temp/clang-tidy-test/d.h:3:11: warning: Dereference of null 
> pointer [clang-analyzer-core.NullDereference]
>   *buffer++=1; // Should be clang-analyzer-core.NullDereference
>^
>   /home/default/Temp/clang-tidy-test/a.cc:3:12: note: Calling 'check'
>   int main(){check(0);}
>  ^
>   /home/default/Temp/clang-tidy-test/d.h:3:3: note: Null pointer value stored 
> to 'buffer'
>   *buffer++=1; // Should be clang-analyzer-core.NullDereference
>^
>   /home/default/Temp/clang-tidy-test/d.h:3:11: note: Dereference of null 
> pointer
>   *buffer++=1; // Should be clang-analyzer-core.NullDereference
>^
>   Suppressed 1 warnings (1 in non-user code).
>   Use -header-filter=.* to display errors from all non-system headers. Use 
> -system-headers to display errors from system headers as well.
>


The behavior in the case above seems to be correct. The null pointer 
dereference is happening in d.h:3:11, which is not included into the default 
header-filter (which is empty == no headers are considered "interesting" on 
their own). However, the (possible) cause of the problem is in a.cc:3:12, which 
is considered "interesting". Thus the whole diagnostic with all notes attached 
to it is displayed to the user.

The general rule is: a warning (together with all of its notes) is displayed if 
its location or location of any of it's notes is inside a the main file or a 
(non-system, unless -system-headers option is present) header matching the 
regex configured via the -header-filter option. The -line-filter works in a 
very similar way, but the whole main file is not whitelisted by default, only 
the ranges of lines in it that are parts of the -line-filter.

> **How can I use -header-filter now?**

This depends on what you're trying to achieve.

> With -header-filter=b.h clang-tidy shows both warnings:

This aligns well with the logic I described above.

> With -header-filter=c.h clang-tidy shows both warnings:

Same here: the bugprone-argument-comment warning is shown due to the 
-header-filter=c.h option. The clang-analyzer-core.NullDereference will be 
shown regardless of the -header-filter value, because it is related to the main 
file.

> With -header-filter=c.h clang-tidy shows both warnings:

It looks like you wanted to say that with -header-filter=d.h only the 
clang-analyzer-core.NullDereference warning is shown. Seems correct. See above.

> How can I suppress warning for my header file //**d.h**// so that only 
> warning from //**b.h**// is shown?

The warning in d.h is related to the main file (since it has a note in the main 
file). It will be displayed regardless of the -header-filter. This is by design.


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

https://reviews.llvm.org/D59135



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


[PATCH] D60055: Check i < FD->getNumParams() before querying

2019-04-08 Thread Violet via Phabricator via cfe-commits
Violet added a comment.

PING ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60055



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


[PATCH] D59746: [LibTooling] Fix '-h' option

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

In D59746#1458086 , @klimek wrote:

> In D59746#1440756 , @hintonda wrote:
>
> > A better alternative would have been to add a cl::aliasopt for '-h' in 
> > llvm's CommandLineParser when '-help' was first added.  However, that's no 
> > longer possible since some llvm based tools already use '-h' for other 
> > purposes.
>
>
> Is that intentional? Can you point at samples?


A quick grep found these -- there could be more.

llvm-opt-report adds `-h` for help and handles it after 
`ParseCommandLineOptions` returns.
llvm-objdump adds `-h` as an alias for `--section-headers`.
dsymutil adds `-h` for help and handles it after `ParseCommandLineOptions` 
returns.
llvm-readobj adds `-h` as an alias for `--file-headers`.
llvm-dwarfdump adds `-h` for help and handles it after 
`ParseCommandLineOptions` returns.
llvm-mt rolls its own via llvm-tblgen.

So, the only ones I found that aren't essentially aliases for help are in 
llvm-objdump and llvm-readobj.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59746



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


r357917 - [python, tests] Disable Clang Python tests on SPARC

2019-04-08 Thread Rainer Orth via cfe-commits
Author: ro
Date: Mon Apr  8 08:01:06 2019
New Revision: 357917

URL: http://llvm.org/viewvc/llvm-project?rev=357917=rev
Log:
[python, tests] Disable Clang Python tests on SPARC

Running `make check-all` fails on Solaris 11/SPARC since the clang python
tests FAIL:

  
  ==
  FAIL: test_extent (tests.cindex.test_location.TestLocation)
  --
  Traceback (most recent call last):
File "tests/cindex/test_location.py", line 87, in test_extent
  self.assert_location(one.extent.start,line=1,column=1,offset=0)
File "tests/cindex/test_location.py", line 22, in assert_location
  self.assertEqual(loc.column, column)
  AssertionError: 5 != 1
  
  ==
  FAIL: test_get_children (tests.cindex.test_cursor.TestCursor)
  --
  Traceback (most recent call last):
File "tests/cindex/test_cursor.py", line 70, in test_get_children
  self.assertEqual(tu_nodes[0].is_definition(), True)
  AssertionError: False != True
  
  --
  Ran 126 tests in 2.123s
  
  FAILED (failures=2, skipped=6)
  
Unfortunately, this aborts the rest of `make check-all`, even with `-k`, so
this patch disables the test as is already done on a couple of other
targets.
  
This allowed the `sparc-sun-solaris2.11` test to finish.

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

Modified:
cfe/trunk/bindings/python/tests/CMakeLists.txt

Modified: cfe/trunk/bindings/python/tests/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/CMakeLists.txt?rev=357917=357916=357917=diff
==
--- cfe/trunk/bindings/python/tests/CMakeLists.txt (original)
+++ cfe/trunk/bindings/python/tests/CMakeLists.txt Mon Apr  8 08:01:06 2019
@@ -32,11 +32,11 @@ if(WIN32)
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 
-# AArch64 and Hexagon have known test failures that need to be
+# AArch64, Hexagon, and Sparc have known test failures that need to be
 # addressed.
 # SystemZ has broken Python/FFI interface:
 # https://reviews.llvm.org/D52840#1265716
-if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$")
+if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|Sparc|SystemZ)$")
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 


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


[PATCH] D60046: [python, tests] Disable Clang Python tests on SPARC

2019-04-08 Thread Rainer Orth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC357917: [python, tests] Disable Clang Python tests on SPARC 
(authored by ro, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D60046

Files:
  bindings/python/tests/CMakeLists.txt


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -32,11 +32,11 @@
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 
-# AArch64 and Hexagon have known test failures that need to be
+# AArch64, Hexagon, and Sparc have known test failures that need to be
 # addressed.
 # SystemZ has broken Python/FFI interface:
 # https://reviews.llvm.org/D52840#1265716
-if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$")
+if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|Sparc|SystemZ)$")
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -32,11 +32,11 @@
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 
-# AArch64 and Hexagon have known test failures that need to be
+# AArch64, Hexagon, and Sparc have known test failures that need to be
 # addressed.
 # SystemZ has broken Python/FFI interface:
 # https://reviews.llvm.org/D52840#1265716
-if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$")
+if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|Sparc|SystemZ)$")
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60408: [LibTooling] Extend Transformer to support multiple simultaneous changes.

2019-04-08 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: ilya-biryukov.
Herald added a subscriber: jfb.
Herald added a project: clang.

This revision allows users to specify independent changes to multiple (related) 
sections of the input.  Previously, only a single section of input could be 
selected for replacement.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60408

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

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -13,36 +13,12 @@
 #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;
 
+using namespace clang;
+using namespace tooling;
+using namespace ast_matchers;
+
+namespace {
 constexpr char KHeaderContents[] = R"cc(
   struct string {
 string(const char*);
@@ -59,6 +35,9 @@
 PCFProto& GetProto();
   };
   }  // namespace proto
+  class Logger {};
+  void operator<<(Logger& l, string msg);
+  Logger& log(int level);
 )cc";
 
 static ast_matchers::internal::Matcher
@@ -141,18 +120,15 @@
 static RewriteRule ruleStrlenSize() {
   StringRef StringExpr = "strexpr";
   auto StringType = namedDecl(hasAnyName("::basic_string", "::string"));
-  return buildRule(
- callExpr(
- callee(functionDecl(hasName("strlen"))),
- hasArgument(0, cxxMemberCallExpr(
-on(expr(hasType(isOrPointsTo(StringType)))
-   .bind(StringExpr)),
-callee(cxxMethodDecl(hasName("c_str")))
-  // Specify the intended type explicitly, because the matcher "type" of
-  // `callExpr()` is `Stmt`, not `Expr`.
-  .as()
-  .replaceWith("REPLACED")
-  .because("Use size() method directly on string.");
+  return makeRule(
+  callExpr(callee(functionDecl(hasName("strlen"))),
+   hasArgument(0, cxxMemberCallExpr(
+  on(expr(hasType(isOrPointsTo(StringType)))
+ .bind(StringExpr)),
+  callee(cxxMethodDecl(hasName("c_str")),
+  changeRoot()
+  .to("REPLACED")
+  .because("Use size() method directly on string."));
 }
 
 TEST_F(TransformerTest, StrlenSize) {
@@ -181,15 +157,13 @@
 // Tests replacing an expression.
 TEST_F(TransformerTest, Flag) {
   StringRef Flag = "flag";
-  RewriteRule Rule =
-  buildRule(
-  cxxMemberCallExpr(on(expr(hasType(cxxRecordDecl(hasName(
-"proto::ProtoCommandLineFlag"
-   .bind(Flag)),
-unless(callee(cxxMethodDecl(hasName("GetProto"))
-  .change(Flag)
-  .replaceWith("EXPR")
-  .because("Use GetProto() to access proto fields.");
+  RewriteRule Rule = makeRule(
+  cxxMemberCallExpr(on(expr(hasType(cxxRecordDecl(
+hasName("proto::ProtoCommandLineFlag"
+   .bind(Flag)),
+unless(callee(cxxMethodDecl(hasName("GetProto"),
+  changeTextOf(Flag).to("EXPR").because(
+  "Use GetProto() to access proto fields."));
 
   std::string Input = R"cc(
 proto::ProtoCommandLineFlag flag;
@@ -207,9 +181,9 @@
 
 TEST_F(TransformerTest, NodePartNameNamedDecl) {
   StringRef Fun = "fun";
-  RewriteRule Rule = buildRule(functionDecl(hasName("bad")).bind(Fun))
- .change(Fun, NodePart::Name)
- .replaceWith("good");
+  RewriteRule Rule = makeRule(
+  functionDecl(hasName("bad")).bind(Fun),
+  changeTextOf(Fun, NodePart::Name).to("good"));
 
   std::string Input = R"cc(
 int bad(int x);
@@ -240,9 +214,8 @@
   )cc";
 
   StringRef Ref = "ref";
-  testRule(buildRule(declRefExpr(to(functionDecl(hasName("bad".bind(Ref))
-   .change(Ref, 

[PATCH] D60046: [python, tests] Disable Clang Python tests on SPARC

2019-04-08 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D60046#1458399 , @mgorny wrote:

> Thanks, looks good. Do you have commit access or do you need me to commit it 
> for you?


I do have commit access, so I'll do it myself.   Thanks.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60046



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


[PATCH] D59811: [clangd] Add fallback mode for code completion when compile command or preamble is not ready.

2019-04-08 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL357916: [clangd] Add fallback mode for code completion when 
compile command or preamble… (authored by ioeric, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59811

Files:
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/CodeComplete.h
  clang-tools-extra/trunk/clangd/TUScheduler.cpp
  clang-tools-extra/trunk/clangd/TUScheduler.h
  clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
  clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
@@ -13,8 +13,10 @@
 #include "Matchers.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
+#include "Threading.h"
 #include "URI.h"
 #include "clang/Config/config.h"
+#include "clang/Sema/CodeCompleteConsumer.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/Errc.h"
@@ -36,7 +38,6 @@
 namespace {
 
 using ::testing::ElementsAre;
-using ::testing::Eq;
 using ::testing::Field;
 using ::testing::Gt;
 using ::testing::IsEmpty;
@@ -1058,6 +1059,41 @@
   EXPECT_NE(Result, "");
 }
 
+TEST_F(ClangdVFSTest, FallbackWhenPreambleIsNotReady) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  auto FooCpp = testPath("foo.cpp");
+  Annotations Code(R"cpp(
+int main() {
+  int xyz;
+  xy^
+})cpp");
+  FS.Files[FooCpp] = FooCpp;
+
+  auto Opts = clangd::CodeCompleteOptions();
+  Opts.AllowFallback = true;
+
+  // This will make compile command broken and preamble absent.
+  CDB.ExtraClangFlags = {"yolo.cc"};
+  Server.addDocument(FooCpp, Code.code());
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  auto Res = cantFail(runCodeComplete(Server, FooCpp, Code.point(), Opts));
+  EXPECT_THAT(Res.Completions, IsEmpty());
+  EXPECT_EQ(Res.Context, CodeCompletionContext::CCC_Recovery);
+
+  // Make the compile command work again.
+  CDB.ExtraClangFlags = {"-std=c++11"};
+  Server.addDocument(FooCpp, Code.code());
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  EXPECT_THAT(cantFail(runCodeComplete(Server, FooCpp, Code.point(),
+   Opts))
+  .Completions,
+  ElementsAre(Field(::Name, "xyz")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp
@@ -11,7 +11,9 @@
 #include "CodeComplete.h"
 #include "FindSymbols.h"
 #include "Headers.h"
+#include "Protocol.h"
 #include "SourceCode.h"
+#include "TUScheduler.h"
 #include "Trace.h"
 #include "index/CanonicalIncludes.h"
 #include "index/FileIndex.h"
@@ -21,6 +23,7 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
@@ -152,6 +155,7 @@
   if (ClangTidyOptProvider)
 Opts.ClangTidyOpts = ClangTidyOptProvider->getOptions(File);
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;
+
   // FIXME: some build systems like Bazel will take time to preparing
   // environment to build the file, it would be nice if we could emit a
   // "PreparingBuild" status to inform users, it is non-trivial given the
@@ -183,6 +187,18 @@
   return CB(IP.takeError());
 if (isCancelled())
   return CB(llvm::make_error());
+if (!IP->Preamble) {
+  vlog("File {0} is not ready for code completion. Enter fallback mode.",
+   File);
+  CodeCompleteResult CCR;
+  CCR.Context = CodeCompletionContext::CCC_Recovery;
+
+  // FIXME: perform simple completion e.g. using identifiers in the current
+  // file and symbols in the index.
+  // FIXME: let clients know that we've entered fallback mode.
+
+  return CB(std::move(CCR));
+}
 
 llvm::Optional SpecFuzzyFind;
 if (CodeCompleteOpts.Index && CodeCompleteOpts.SpeculativeIndexRequest) {
@@ -214,7 +230,9 @@
   };
 
   // We use a potentially-stale preamble because latency is critical here.
-  WorkScheduler.runWithPreamble("CodeComplete", File, TUScheduler::Stale,
+  WorkScheduler.runWithPreamble("CodeComplete", File,
+Opts.AllowFallback ? 

[clang-tools-extra] r357916 - [clangd] Add fallback mode for code completion when compile command or preamble is not ready.

2019-04-08 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Apr  8 07:53:16 2019
New Revision: 357916

URL: http://llvm.org/viewvc/llvm-project?rev=357916=rev
Log:
[clangd] Add fallback mode for code completion when compile command or preamble 
is not ready.

Summary:
When calling TUScehduler::runWithPreamble (e.g. in code compleiton), allow
entering a fallback mode when compile command or preamble is not ready, instead 
of
waiting. This allows clangd to perform naive code completion e.g. using 
identifiers
in the current file or symbols in the index.

This patch simply returns empty result for code completion in fallback mode. 
Identifier-based
plus more advanced index-based completion will be added in followup patches.

Reviewers: ilya-biryukov, sammccall

Reviewed By: sammccall

Subscribers: sammccall, javed.absar, MaskRay, jkorous, arphaman, kadircet, 
jdoerfert, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/CodeComplete.h
clang-tools-extra/trunk/clangd/TUScheduler.cpp
clang-tools-extra/trunk/clangd/TUScheduler.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=357916=357915=357916=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Mon Apr  8 07:53:16 2019
@@ -11,7 +11,9 @@
 #include "CodeComplete.h"
 #include "FindSymbols.h"
 #include "Headers.h"
+#include "Protocol.h"
 #include "SourceCode.h"
+#include "TUScheduler.h"
 #include "Trace.h"
 #include "index/CanonicalIncludes.h"
 #include "index/FileIndex.h"
@@ -21,6 +23,7 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
@@ -152,6 +155,7 @@ void ClangdServer::addDocument(PathRef F
   if (ClangTidyOptProvider)
 Opts.ClangTidyOpts = ClangTidyOptProvider->getOptions(File);
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;
+
   // FIXME: some build systems like Bazel will take time to preparing
   // environment to build the file, it would be nice if we could emit a
   // "PreparingBuild" status to inform users, it is non-trivial given the
@@ -183,6 +187,18 @@ void ClangdServer::codeComplete(PathRef
   return CB(IP.takeError());
 if (isCancelled())
   return CB(llvm::make_error());
+if (!IP->Preamble) {
+  vlog("File {0} is not ready for code completion. Enter fallback mode.",
+   File);
+  CodeCompleteResult CCR;
+  CCR.Context = CodeCompletionContext::CCC_Recovery;
+
+  // FIXME: perform simple completion e.g. using identifiers in the current
+  // file and symbols in the index.
+  // FIXME: let clients know that we've entered fallback mode.
+
+  return CB(std::move(CCR));
+}
 
 llvm::Optional SpecFuzzyFind;
 if (CodeCompleteOpts.Index && CodeCompleteOpts.SpeculativeIndexRequest) {
@@ -214,7 +230,9 @@ void ClangdServer::codeComplete(PathRef
   };
 
   // We use a potentially-stale preamble because latency is critical here.
-  WorkScheduler.runWithPreamble("CodeComplete", File, TUScheduler::Stale,
+  WorkScheduler.runWithPreamble("CodeComplete", File,
+Opts.AllowFallback ? TUScheduler::StaleOrAbsent
+   : TUScheduler::Stale,
 Bind(Task, File.str(), std::move(CB)));
 }
 

Modified: clang-tools-extra/trunk/clangd/CodeComplete.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.h?rev=357916=357915=357916=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.h (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.h Mon Apr  8 07:53:16 2019
@@ -109,6 +109,12 @@ struct CodeCompleteOptions {
   ///
   /// Such completions can insert scope qualifiers.
   bool AllScopes = false;
+
+  /// Whether to allow falling back to code completion without compiling files
+  /// (using identifiers in the current file and symbol indexes), when file
+  /// cannot be built (e.g. missing compile command), or the build is not ready
+  /// (e.g. preamble is still being built).
+  bool AllowFallback = false;
 };
 
 // Semi-structured representation of a code-complete suggestion for our C++ 
API.

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

[PATCH] D60046: [python, tests] Disable Clang Python tests on SPARC

2019-04-08 Thread Michał Górny via Phabricator via cfe-commits
mgorny accepted this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

Thanks, looks good. Do you have commit access or do you need me to commit it 
for you?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60046



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


[PATCH] D59811: [clangd] Add fallback mode for code completion when compile command or preamble is not ready.

2019-04-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D59811



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


[PATCH] D60046: [python, tests] Disable Clang Python tests on SPARC

2019-04-08 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D60046#1456034 , @mgorny wrote:

> Just add it to the regex above.


Done now.  Initially I tried to check if it's also the ffi issue, until I 
noticed that some targets were skipped there for different reasons.
I cannot check anything but Solaris/SPARC, though, but assume that it's a 
generic SPARC issue, nothing Solaris-specific, given that Solaris/x86
passes the test.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60046



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


[PATCH] D60046: [python, tests] Disable Clang Python tests on Solaris/SPARC

2019-04-08 Thread Rainer Orth via Phabricator via cfe-commits
ro updated this revision to Diff 194144.
ro added a comment.

Skip SPARC like other targets.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60046

Files:
  bindings/python/tests/CMakeLists.txt


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -32,11 +32,11 @@
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 
-# AArch64 and Hexagon have known test failures that need to be
+# AArch64, Hexagon, and Sparc have known test failures that need to be
 # addressed.
 # SystemZ has broken Python/FFI interface:
 # https://reviews.llvm.org/D52840#1265716
-if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$")
+if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|Sparc|SystemZ)$")
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -32,11 +32,11 @@
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 
-# AArch64 and Hexagon have known test failures that need to be
+# AArch64, Hexagon, and Sparc have known test failures that need to be
 # addressed.
 # SystemZ has broken Python/FFI interface:
 # https://reviews.llvm.org/D52840#1265716
-if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$")
+if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|Sparc|SystemZ)$")
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r357915 - Remove a useless assertion in clang-check.

2019-04-08 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Apr  8 07:18:26 2019
New Revision: 357915

URL: http://llvm.org/viewvc/llvm-project?rev=357915=rev
Log:
Remove a useless assertion in clang-check.

The assertion prevents it from applying fixes when used along with compilation
databases with relative paths. Added a test that demonstrates the assertion
failure.

An example of the assertion:
input.cpp:11:14: error: expected ';' after top level declarator
typedef int T
 ^
 ;
input.cpp:11:14: note: FIX-IT applied suggested code changes
clang-check: clang/tools/clang-check/ClangCheck.cpp:94: virtual std::string 
(anonymous namespace)::FixItOptions::RewriteFilename(const std::string &, int 
&): Assertion `llvm::sys::path::is_absolute(filename) && "clang-fixit expects 
absolute paths only."' failed.
  #0 llvm::sys::PrintStackTrace(llvm::raw_ostream&) 
llvm/lib/Support/Unix/Signals.inc:494:13
  #1 llvm::sys::RunSignalHandlers() llvm/lib/Support/Signals.cpp:69:18
  #2 SignalHandler(int) llvm/lib/Support/Unix/Signals.inc:357:1
  #3 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
  #4 raise (/lib/x86_64-linux-gnu/libc.so.6+0x32fcf)
  #5 abort (/lib/x86_64-linux-gnu/libc.so.6+0x343fa)
  #6 (/lib/x86_64-linux-gnu/libc.so.6+0x2be37)
  #7 (/lib/x86_64-linux-gnu/libc.so.6+0x2bee2)
  #8 void std::__cxx11::basic_string, 
std::allocator >::_M_construct(char*, char*, 
std::forward_iterator_tag)
  #9 void std::__cxx11::basic_string, 
std::allocator >::_M_construct_aux(char*, char*, std::__false_type)
 #10 void std::__cxx11::basic_string, 
std::allocator >::_M_construct(char*, char*)
 #11 std::__cxx11::basic_string, 
std::allocator >::basic_string(std::__cxx11::basic_string, std::allocator > const&)
 #12 (anonymous 
namespace)::FixItOptions::RewriteFilename(std::__cxx11::basic_string, std::allocator > const&, int&) 
clang/tools/clang-check/ClangCheck.cpp:101:0
 #13 std::__cxx11::basic_string, 
std::allocator >::_M_data() const
 #14 std::__cxx11::basic_string, 
std::allocator >::_M_is_local() const
 #15 std::__cxx11::basic_string, 
std::allocator >::_M_dispose()
 #16 std::__cxx11::basic_string, 
std::allocator >::~basic_string()
 #17 
clang::FixItRewriter::WriteFixedFiles(std::vector, std::allocator >, 
std::__cxx11::basic_string, std::allocator > 
>, std::allocator, std::allocator >, 
std::__cxx11::basic_string, std::allocator > 
> > >*) clang/lib/Frontend/Rewrite/FixItRewriter.cpp:98:0
 #18 std::__shared_ptr::get() const
 #19 std::__shared_ptr_access::_M_get() const
 #20 std::__shared_ptr_access::operator->() const
 #21 clang::CompilerInstance::getFrontendOpts() 
clang/include/clang/Frontend/CompilerInstance.h:290:0
 #22 clang::FrontendAction::EndSourceFile() 
clang/lib/Frontend/FrontendAction.cpp:966:0
 #23 __gnu_cxx::__normal_iterator 
> >::operator++()
 #24 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) 
clang/lib/Frontend/CompilerInstance.cpp:943:0
 #25 
clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr,
 clang::FileManager*, std::shared_ptr, 
clang::DiagnosticConsumer*) clang/lib/Tooling/Tooling.cpp:369:33
 #26 clang::tooling::ToolInvocation::runInvocation(char const*, 
clang::driver::Compilation*, std::shared_ptr, 
std::shared_ptr) 
clang/lib/Tooling/Tooling.cpp:344:18
 #27 clang::tooling::ToolInvocation::run() clang/lib/Tooling/Tooling.cpp:329:10
 #28 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) 
clang/lib/Tooling/Tooling.cpp:518:11
 #29 main clang/tools/clang-check/ClangCheck.cpp:187:15

Added:
cfe/trunk/test/Tooling/clang-check-fixit.cpp
Modified:
cfe/trunk/tools/clang-check/ClangCheck.cpp

Added: cfe/trunk/test/Tooling/clang-check-fixit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-fixit.cpp?rev=357915=auto
==
--- cfe/trunk/test/Tooling/clang-check-fixit.cpp (added)
+++ cfe/trunk/test/Tooling/clang-check-fixit.cpp Mon Apr  8 07:18:26 2019
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// RUN: sed -s 's,^//.*,//,' %s > %t/absolute-fixed.cpp
+// RUN: sed -s 's,^//.*,//,' %s > %t/absolute-json.cpp
+// RUN: sed -s 's,^//.*,//,' %s > %t/relative-fixed.cpp
+// RUN: sed -s 's,^//.*,//,' %s > %t/relative-json.cpp
+//
+// RUN: clang-check %t/absolute-fixed.cpp -fixit -- 2>&1 | FileCheck %s
+//
+// RUN: echo '[{ "directory": "%t", \
+// RUN:   "command": "/path/to/clang -c %t/absolute-json.cpp", \
+// RUN:   "file": "%t/absolute-json.cpp" }]' > %t/compile_commands.json
+// RUN: clang-check %t/absolute-json.cpp -fixit 2>&1 | FileCheck %s
+//
+// RUN: cd %t
+// RUN: clang-check relative-fixed.cpp -fixit -- 2>&1 | FileCheck %s
+//
+// RUN: echo '[{ "directory": "%t", \
+// RUN:   "command": "/path/to/clang -c relative-json.cpp", \
+// RUN:   "file": "relative-json.cpp" }]' > %t/compile_commands.json
+// RUN: clang-check relative-json.cpp -fixit 2>&1 | FileCheck %s
+typedef int T
+// CHECK: .cpp:[[@LINE-1]]:14: error: expected ';' after top 

[PATCH] D59811: [clangd] Add fallback mode for code completion when compile command or preamble is not ready.

2019-04-08 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 194141.
ioeric marked 11 inline comments as done.
ioeric added a comment.

- address review comments


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D59811

Files:
  clangd/ClangdServer.cpp
  clangd/CodeComplete.h
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -13,8 +13,10 @@
 #include "Matchers.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
+#include "Threading.h"
 #include "URI.h"
 #include "clang/Config/config.h"
+#include "clang/Sema/CodeCompleteConsumer.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/Errc.h"
@@ -36,7 +38,6 @@
 namespace {
 
 using ::testing::ElementsAre;
-using ::testing::Eq;
 using ::testing::Field;
 using ::testing::Gt;
 using ::testing::IsEmpty;
@@ -1058,6 +1059,41 @@
   EXPECT_NE(Result, "");
 }
 
+TEST_F(ClangdVFSTest, FallbackWhenPreambleIsNotReady) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  auto FooCpp = testPath("foo.cpp");
+  Annotations Code(R"cpp(
+int main() {
+  int xyz;
+  xy^
+})cpp");
+  FS.Files[FooCpp] = FooCpp;
+
+  auto Opts = clangd::CodeCompleteOptions();
+  Opts.AllowFallback = true;
+
+  // This will make compile command broken and preamble absent.
+  CDB.ExtraClangFlags = {"yolo.cc"};
+  Server.addDocument(FooCpp, Code.code());
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  auto Res = cantFail(runCodeComplete(Server, FooCpp, Code.point(), Opts));
+  EXPECT_THAT(Res.Completions, IsEmpty());
+  EXPECT_EQ(Res.Context, CodeCompletionContext::CCC_Recovery);
+
+  // Make the compile command work again.
+  CDB.ExtraClangFlags = {"-std=c++11"};
+  Server.addDocument(FooCpp, Code.code());
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  EXPECT_THAT(cantFail(runCodeComplete(Server, FooCpp, Code.point(),
+   Opts))
+  .Completions,
+  ElementsAre(Field(::Name, "xyz")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -231,6 +231,14 @@
 "Offsets are in UTF-16 code units")),
 llvm::cl::init(OffsetEncoding::UnsupportedEncoding));
 
+static llvm::cl::opt AllowFallbackCompletion(
+"allow-fallback-completion",
+llvm::cl::desc(
+"Allow falling back to code completion without compiling files (using "
+"identifiers and symbol indexes), when file cannot be built or the "
+"build is not ready."),
+llvm::cl::init(false));
+
 namespace {
 
 /// \brief Supports a test URI scheme with relaxed constraints for lit tests.
@@ -437,6 +445,7 @@
   CCOpts.SpeculativeIndexRequest = Opts.StaticIndex;
   CCOpts.EnableFunctionArgSnippets = EnableFunctionArgSnippets;
   CCOpts.AllScopes = AllScopesCompletion;
+  CCOpts.AllowFallback = AllowFallbackCompletion;
 
   RealFileSystemProvider FSProvider;
   // Initialize and run ClangdLSPServer.
Index: clangd/TUScheduler.h
===
--- clangd/TUScheduler.h
+++ clangd/TUScheduler.h
@@ -13,7 +13,9 @@
 #include "Function.h"
 #include "Threading.h"
 #include "index/CanonicalIncludes.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
 #include 
 
 namespace clang {
@@ -32,6 +34,7 @@
 struct InputsAndPreamble {
   llvm::StringRef Contents;
   const tooling::CompileCommand 
+  // This can be nullptr if no preamble is availble.
   const PreambleData *Preamble;
 };
 
@@ -178,10 +181,14 @@
 ///   reading source code from headers.
 /// This is the fastest option, usually a preamble is available immediately.
 Stale,
+/// Besides accepting stale preamble, this also allow preamble to be absent
+/// (not ready or failed to build).
+StaleOrAbsent,
   };
+
   /// Schedule an async read of the preamble.
-  /// If there's no preamble yet (because the file was just opened), we'll wait
-  /// for it to build. The result may be null if it fails to build or is empty.
+  /// If there's no up-to-date preamble, we follow the PreambleConsistency
+  /// policy.
   /// If an error occurs, it is forwarded to the \p Action callback.
   /// Context cancellation is ignored and should be handled by the Action.
   /// (In practice, the Action is almost always executed immediately).
Index: clangd/TUScheduler.cpp

[PATCH] D59811: [clangd] Add fallback mode for code completion when compile command or preamble is not ready.

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



Comment at: clangd/TUScheduler.cpp:881
+  // asynchronous mode, as TU update should finish before this is run.
+  if (!It->second->Worker->isFirstPreambleBuilt() &&
+  Consistency == StaleOrAbsent && PreambleTasks) {

sammccall wrote:
> Does this need to be a special case at the top of 
> TUScheduler::runWithPreamble, rather than unified with the rest of the body?
> 
> e.g. the `if (!PreambleTasks)` appears to block appears to handle that case 
> correctly already, and the `Consistency == Consistent` block won't trigger.
> I think all you need to do is make the `Worker->waitForFirstPreamble()` line 
> conditional?
> 
> (This means no changes to ASTWorker, Notification etc)
whoops! absolutely right!



Comment at: unittests/clangd/ClangdTests.cpp:1080
+  // This will make compile command broken and preamble absent.
+  CDB.ExtraClangFlags = {"yolo.cc"};
+  Server.addDocument(FooCpp, Code.code());

sammccall wrote:
> (`-this-flag-does-not-exist` might be clearer)
This would still cause preamble to be built:
```
Updating file /clangd-test/foo.cpp with command [/clangd-test] clang 
-this-flag-does-not-exist /clangd-test/foo.cpp
Ignored diagnostic. unknown argument: '-this-flag-does-not-exist'
```


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D59811



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


[PATCH] D55049: Changed every use of ASTImporter::Import to Import_New

2019-04-08 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC357913: Changed every use of ASTImporter::Import to 
Import_New (authored by balazske, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55049?vs=192110=194140#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D55049

Files:
  lib/AST/ASTImporter.cpp
  lib/AST/ExternalASTMerger.cpp
  lib/CrossTU/CrossTranslationUnit.cpp
  lib/Frontend/ASTMerge.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -89,8 +89,8 @@
public ::testing::WithParamInterface {
 
   template 
-  NodeType importNode(ASTUnit *From, ASTUnit *To, ASTImporter ,
-  NodeType Node) {
+  llvm::Expected importNode(ASTUnit *From, ASTUnit *To,
+  ASTImporter , NodeType Node) {
 ASTContext  = To->getASTContext();
 
 // Add 'From' file to virtual file system so importer can 'find' it
@@ -100,17 +100,19 @@
 createVirtualFileIfNeeded(To, FromFileName,
   From->getBufferForFile(FromFileName));
 
-auto Imported = Importer.Import(Node);
+auto Imported = Importer.Import_New(Node);
 
-// This should dump source locations and assert if some source locations
-// were not imported.
-SmallString<1024> ImportChecker;
-llvm::raw_svector_ostream ToNothing(ImportChecker);
-ToCtx.getTranslationUnitDecl()->print(ToNothing);
-
-// This traverses the AST to catch certain bugs like poorly or not
-// implemented subtrees.
-Imported->dump(ToNothing);
+if (Imported) {
+  // This should dump source locations and assert if some source locations
+  // were not imported.
+  SmallString<1024> ImportChecker;
+  llvm::raw_svector_ostream ToNothing(ImportChecker);
+  ToCtx.getTranslationUnitDecl()->print(ToNothing);
+
+  // This traverses the AST to catch certain bugs like poorly or not
+  // implemented subtrees.
+  (*Imported)->dump(ToNothing);
+}
 
 return Imported;
   }
@@ -151,11 +153,16 @@
 EXPECT_TRUE(Verifier.match(ToImport, WrapperMatcher));
 
 auto Imported = importNode(FromAST.get(), ToAST.get(), Importer, ToImport);
-if (!Imported)
-  return testing::AssertionFailure() << "Import failed, nullptr returned!";
-
+if (!Imported) {
+  std::string ErrorText;
+  handleAllErrors(
+  Imported.takeError(),
+  [](const ImportError ) { ErrorText = Err.message(); });
+  return testing::AssertionFailure()
+ << "Import failed, error: \"" << ErrorText << "\"!";
+}
 
-return Verifier.match(Imported, WrapperMatcher);
+return Verifier.match(*Imported, WrapperMatcher);
   }
 
   template 
@@ -277,7 +284,9 @@
   EXPECT_TRUE(FoundDecl.size() == 1);
   const Decl *ToImport = selectFirst(DeclToImportID, FoundDecl);
   auto Imported = importNode(From, To, *ImporterRef, ToImport);
-  EXPECT_TRUE(Imported);
+  EXPECT_TRUE(static_cast(Imported));
+  if (!Imported)
+llvm::consumeError(Imported.takeError());
 }
 
 // Find the declaration and import it.
@@ -339,13 +348,23 @@
 Decl *import(ASTImporterLookupTable , ASTUnit *ToAST,
  Decl *FromDecl) {
   lazyInitImporter(LookupTable, ToAST);
-  return Importer->Import(FromDecl);
+  if (auto ImportedOrErr = Importer->Import_New(FromDecl))
+return *ImportedOrErr;
+  else {
+llvm::consumeError(ImportedOrErr.takeError());
+return nullptr;
+  }
 }
 
 QualType import(ASTImporterLookupTable , ASTUnit *ToAST,
 QualType FromType) {
   lazyInitImporter(LookupTable, ToAST);
-  return Importer->Import(FromType);
+  if (auto ImportedOrErr = Importer->Import_New(FromType))
+return *ImportedOrErr;
+  else {
+llvm::consumeError(ImportedOrErr.takeError());
+return QualType{};
+  }
 }
   };
 
Index: lib/CrossTU/CrossTranslationUnit.cpp
===
--- lib/CrossTU/CrossTranslationUnit.cpp
+++ lib/CrossTU/CrossTranslationUnit.cpp
@@ -357,13 +357,28 @@
   assert(FD->hasBody() && "Functions to be imported should have body.");
 
   ASTImporter  = getOrCreateASTImporter(FD->getASTContext());
-  auto *ToDecl =
-  cast_or_null(Importer.Import(const_cast(FD)));
-  if (!ToDecl)
+  auto ToDeclOrError = Importer.Import_New(FD);
+  if (!ToDeclOrError) {
+handleAllErrors(ToDeclOrError.takeError(),
+[&](const ImportError ) {
+  switch (IE.Error) {
+  case ImportError::NameConflict:
+// FIXME: Add statistic.
+ 

r357913 - Changed every use of ASTImporter::Import to Import_New

2019-04-08 Thread Balazs Keri via cfe-commits
Author: balazske
Date: Mon Apr  8 06:59:15 2019
New Revision: 357913

URL: http://llvm.org/viewvc/llvm-project?rev=357913=rev
Log:
Changed every use of ASTImporter::Import to Import_New

Reviewers: a.sidorin, shafik, martong, a_sidorin

Reviewed By: a_sidorin

Subscribers: rnkovacs, dkrupp, martong, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/ExternalASTMerger.cpp
cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
cfe/trunk/lib/Frontend/ASTMerge.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=357913=357912=357913=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Apr  8 06:59:15 2019
@@ -7792,9 +7792,10 @@ Expected ASTImporter::Imp
   if (!FromDC)
 return FromDC;
 
-  auto *ToDC = cast_or_null(Import(cast(FromDC)));
-  if (!ToDC)
-return nullptr;
+  ExpectedDecl ToDCOrErr = Import_New(cast(FromDC));
+  if (!ToDCOrErr)
+return ToDCOrErr.takeError();
+  auto *ToDC = cast(*ToDCOrErr);
 
   // When we're using a record/enum/Objective-C class/protocol as a context, we
   // need it to have a definition.
@@ -8590,10 +8591,16 @@ Decl *ASTImporter::MapImported(Decl *Fro
 
 bool ASTImporter::IsStructurallyEquivalent(QualType From, QualType To,
bool Complain) {
-  llvm::DenseMap::iterator Pos
-   = ImportedTypes.find(From.getTypePtr());
-  if (Pos != ImportedTypes.end() && ToContext.hasSameType(Import(From), To))
-return true;
+  llvm::DenseMap::iterator Pos =
+  ImportedTypes.find(From.getTypePtr());
+  if (Pos != ImportedTypes.end()) {
+if (ExpectedType ToFromOrErr = Import_New(From)) {
+  if (ToContext.hasSameType(*ToFromOrErr, To))
+return true;
+} else {
+  llvm::consumeError(ToFromOrErr.takeError());
+}
+  }
 
   StructuralEquivalenceContext Ctx(FromContext, ToContext, NonEquivalentDecls,
getStructuralEquivalenceKind(*this), false,

Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=357913=357912=357913=diff
==
--- cfe/trunk/lib/AST/ExternalASTMerger.cpp (original)
+++ cfe/trunk/lib/AST/ExternalASTMerger.cpp Mon Apr  8 06:59:15 2019
@@ -56,7 +56,12 @@ LookupSameContext(Source(DC);
   DeclarationName Name = ND->getDeclName();
-  Source SourceName = ReverseImporter.Import(Name);
+  auto SourceNameOrErr = ReverseImporter.Import_New(Name);
+  if (!SourceNameOrErr) {
+llvm::consumeError(SourceNameOrErr.takeError());
+return nullptr;
+  }
+  Source SourceName = *SourceNameOrErr;
   DeclContext::lookup_result SearchResult =
   SourceParentDC.get()->lookup(SourceName.get());
   size_t SearchResultSize = SearchResult.size();
@@ -354,9 +359,13 @@ void ExternalASTMerger::RemoveSources(ll
 
 template 
 static bool importSpecializations(DeclTy *D, ASTImporter *Importer) {
-  for (auto *Spec : D->specializations())
-if (!Importer->Import(Spec))
+  for (auto *Spec : D->specializations()) {
+auto ImportedSpecOrError = Importer->Import_New(Spec);
+if (!ImportedSpecOrError) {
+  llvm::consumeError(ImportedSpecOrError.takeError());
   return true;
+}
+  }
   return false;
 }
 
@@ -383,15 +392,21 @@ bool ExternalASTMerger::FindExternalVisi
  Candidates.push_back(C);
   };
 
-  ForEachMatchingDC(DC, [&](ASTImporter , ASTImporter ,
-Source SourceDC) -> bool {
-DeclarationName FromName = Reverse.Import(Name);
-DeclContextLookupResult Result = SourceDC.get()->lookup(FromName);
-for (NamedDecl *FromD : Result) {
-  FilterFoundDecl(std::make_pair(FromD, ));
-}
-return false;
-  });
+  ForEachMatchingDC(DC,
+[&](ASTImporter , ASTImporter ,
+Source SourceDC) -> bool {
+  auto FromNameOrErr = Reverse.Import_New(Name);
+  if (!FromNameOrErr) {
+llvm::consumeError(FromNameOrErr.takeError());
+return false;
+  }
+  DeclContextLookupResult Result =
+  SourceDC.get()->lookup(*FromNameOrErr);
+  for (NamedDecl *FromD : Result) {
+FilterFoundDecl(std::make_pair(FromD, ));
+  }
+  return false;
+});
 
   if (Candidates.empty())
 return false;
@@ -400,7 +415,10 @@ bool ExternalASTMerger::FindExternalVisi
   for (const Candidate  : Candidates) {
 Decl *LookupRes = C.first.get();
 

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

2019-04-08 Thread Dennis Luxen via Phabricator via cfe-commits
DennisL updated this revision to Diff 194137.

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

https://reviews.llvm.org/D60139

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

Index: test/clang-tidy/bugprone-placement-new-target-type-mismatch.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-placement-new-target-type-mismatch.cpp
@@ -0,0 +1,76 @@
+// RUN: %check_clang_tidy %s bugprone-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]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+void f2() {
+  int * ptr = new int;
+  new (ptr) Foo;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+void f3() {
+  char *ptr = new char[17*sizeof(char)];
+  new (ptr) float[13];
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+void f4() {
+  new (std::addressof(getT())) Foo;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+void f5() {
+  char *ptr = new char[17*sizeof(char)];
+  new (ptr) float{13.f};
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+void f6() {
+  new ((void *)std::addressof(getT())) Foo;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+// instances not emitting a warning
+
+void f7() {
+  Foo * ptr = new Foo;
+  new (ptr) Foo;
+}
+
+void f8() {
+  char *ptr = new char[17*sizeof(char)];
+  new((float *)ptr) float{13.f};
+}
\ No newline at end of file
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -55,6 +55,7 @@
bugprone-move-forwarding-reference
bugprone-multiple-statement-macro
bugprone-parent-virtual-call
+   bugprone-placement-new-target-type-mismatch
bugprone-sizeof-container
bugprone-sizeof-expression
bugprone-string-constructor
Index: docs/clang-tidy/checks/bugprone-placement-new-target-type-mismatch.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/bugprone-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/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -130,6 +130,12 @@
   ` now supports `OverrideSpelling`
   and `FinalSpelling` options.
 
+- New :doc:`bugprone-placement-new-target-type-mismatch
+  ` check.
+
+  Finds placement-new calls where the pointer type of the adress mismatches the
+  type of the created value.
+
 - New :doc:`openmp-exception-escape
   ` check.
 
Index: clang-tidy/bugprone/PlacementNewTargetTypeMismatch.h
===
--- /dev/null
+++ clang-tidy/bugprone/PlacementNewTargetTypeMismatch.h
@@ -0,0 +1,35 @@
+//===--- 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 LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_PLACEMENTNEWTARGETTYPEMISMATCHCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_PLACEMENTNEWTARGETTYPEMISMATCHCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+/// Finds 

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

2019-04-08 Thread Dennis Luxen via Phabricator via cfe-commits
DennisL updated this revision to Diff 194136.
DennisL retitled this revision from "[clang-tidy] Add 
misc-placement-new-target-type-mismatch check" to "[clang-tidy] Add 
bugprone-placement-new-target-type-mismatch check".
DennisL added a comment.

Removed debug output


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

https://reviews.llvm.org/D60139

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

Index: test/clang-tidy/bugprone-placement-new-target-type-mismatch.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-placement-new-target-type-mismatch.cpp
@@ -0,0 +1,76 @@
+// RUN: %check_clang_tidy %s bugprone-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]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+void f2() {
+  int * ptr = new int;
+  new (ptr) Foo;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+void f3() {
+  char *ptr = new char[17*sizeof(char)];
+  new (ptr) float[13];
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+void f4() {
+  new (std::addressof(getT())) Foo;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+void f5() {
+  char *ptr = new char[17*sizeof(char)];
+  new (ptr) float{13.f};
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+void f6() {
+  new ((void *)std::addressof(getT())) Foo;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+// instances not emitting a warning
+
+void f7() {
+  Foo * ptr = new Foo;
+  new (ptr) Foo;
+}
+
+void f8() {
+  char *ptr = new char[17*sizeof(char)];
+  new((float *)ptr) float{13.f};
+}
\ No newline at end of file
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -55,6 +55,7 @@
bugprone-move-forwarding-reference
bugprone-multiple-statement-macro
bugprone-parent-virtual-call
+   bugprone-placement-new-target-type-mismatch
bugprone-sizeof-container
bugprone-sizeof-expression
bugprone-string-constructor
Index: docs/clang-tidy/checks/bugprone-placement-new-target-type-mismatch.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/bugprone-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/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -130,6 +130,12 @@
   ` now supports `OverrideSpelling`
   and `FinalSpelling` options.
 
+- New :doc:`bugprone-placement-new-target-type-mismatch
+  ` check.
+
+  Finds placement-new calls where the pointer type of the adress mismatches the
+  type of the created value.
+
 - New :doc:`openmp-exception-escape
   ` check.
 
Index: clang-tidy/bugprone/PlacementNewTargetTypeMismatch.h
===
--- /dev/null
+++ clang-tidy/bugprone/PlacementNewTargetTypeMismatch.h
@@ -0,0 +1,35 @@
+//===--- 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 LLVM-exception
+//
+//===--===//
+
+#ifndef 

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

2019-04-08 Thread Dennis Luxen via Phabricator via cfe-commits
DennisL updated this revision to Diff 194135.
DennisL added a comment.

The following has been updated:

- moved check to bugprone instead of misc
- more tests
- rewritten check logic


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

https://reviews.llvm.org/D60139

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

Index: test/clang-tidy/bugprone-placement-new-target-type-mismatch.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-placement-new-target-type-mismatch.cpp
@@ -0,0 +1,76 @@
+// RUN: %check_clang_tidy %s bugprone-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]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+void f2() {
+  int * ptr = new int;
+  new (ptr) Foo;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+void f3() {
+  char *ptr = new char[17*sizeof(char)];
+  new (ptr) float[13];
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+void f4() {
+  new (std::addressof(getT())) Foo;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+void f5() {
+  char *ptr = new char[17*sizeof(char)];
+  new (ptr) float{13.f};
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+void f6() {
+  new ((void *)std::addressof(getT())) Foo;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: placement new of incompatible types [bugprone-placement-new-target-type-mismatch]
+}
+
+// instances not emitting a warning
+
+void f7() {
+  Foo * ptr = new Foo;
+  new (ptr) Foo;
+}
+
+void f8() {
+  char *ptr = new char[17*sizeof(char)];
+  new((float *)ptr) float{13.f};
+}
\ No newline at end of file
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -55,6 +55,7 @@
bugprone-move-forwarding-reference
bugprone-multiple-statement-macro
bugprone-parent-virtual-call
+   bugprone-placement-new-target-type-mismatch
bugprone-sizeof-container
bugprone-sizeof-expression
bugprone-string-constructor
Index: docs/clang-tidy/checks/bugprone-placement-new-target-type-mismatch.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/bugprone-placement-new-target-type-mismatch.rst
@@ -0,0 +1,8 @@
+.. title:: clang-tidy - bugprone-placement-new-target-type-mismatch
+
+bugprone-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/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -130,6 +130,12 @@
   ` now supports `OverrideSpelling`
   and `FinalSpelling` options.
 
+- New :doc:`bugprone-placement-new-target-type-mismatch
+  ` check.
+
+  Finds placement-new calls where the pointer type of the adress mismatches the
+  type of the created value.
+
 - New :doc:`openmp-exception-escape
   ` check.
 
Index: clang-tidy/bugprone/PlacementNewTargetTypeMismatch.h
===
--- /dev/null
+++ clang-tidy/bugprone/PlacementNewTargetTypeMismatch.h
@@ -0,0 +1,35 @@
+//===--- 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 LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_PLACEMENTNEWTARGETTYPEMISMATCHCHECK_H
+#define 

[PATCH] D59811: [clangd] Add fallback mode for code completion when compile command or preamble is not ready.

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



Comment at: unittests/clangd/ClangdTests.cpp:1082
+  EXPECT_EQ(Res.Context, CodeCompletionContext::CCC_Recovery);
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  EXPECT_THAT(cantFail(runCodeComplete(Server, FooCpp, Code.point(),

sammccall wrote:
> do I understand right that this test is currently racy?
Sorry, missed your comment. Test LG



Comment at: unittests/clangd/ClangdTests.cpp:1080
+  // This will make compile command broken and preamble absent.
+  CDB.ExtraClangFlags = {"yolo.cc"};
+  Server.addDocument(FooCpp, Code.code());

(`-this-flag-does-not-exist` might be clearer)


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D59811



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


[PATCH] D59811: [clangd] Add fallback mode for code completion when compile command or preamble is not ready.

2019-04-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

API looks good. Implementation looks like it can be simplified a bit, unless 
I'm missing something.




Comment at: clangd/CodeComplete.h:117
+  /// (e.g. preamble is still being built).
+  bool AllowFallbackMode = false;
 };

nit: "mode" doesn't add anything here



Comment at: clangd/TUScheduler.cpp:50
 #include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/PCHContainerOperations.h"
+#include "clang/Tooling/CompilationDatabase.h"

not needed or bad patch base?



Comment at: clangd/TUScheduler.cpp:51
+#include "clang/Frontend/PCHContainerOperations.h"
+#include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/Optional.h"

not needed?



Comment at: clangd/TUScheduler.cpp:881
+  // asynchronous mode, as TU update should finish before this is run.
+  if (!It->second->Worker->isFirstPreambleBuilt() &&
+  Consistency == StaleOrAbsent && PreambleTasks) {

Does this need to be a special case at the top of TUScheduler::runWithPreamble, 
rather than unified with the rest of the body?

e.g. the `if (!PreambleTasks)` appears to block appears to handle that case 
correctly already, and the `Consistency == Consistent` block won't trigger.
I think all you need to do is make the `Worker->waitForFirstPreamble()` line 
conditional?

(This means no changes to ASTWorker, Notification etc)



Comment at: clangd/TUScheduler.h:190
   /// Schedule an async read of the preamble.
-  /// If there's no preamble yet (because the file was just opened), we'll wait
-  /// for it to build. The result may be null if it fails to build or is empty.
-  /// If an error occurs, it is forwarded to the \p Action callback.
-  /// Context cancellation is ignored and should be handled by the Action.
-  /// (In practice, the Action is almost always executed immediately).
+  /// If there's no preamble yet (because the file was just opened), we'll
+  /// either run \p Action without preamble (if \p Consistency is

This sentence has grown unwieldy:can we just say "If there's no up-to-date 
preamble, we follow the PreambleConsistency policy"?
(I personally find the \p s hurt readability, but up to you)



Comment at: clangd/TUScheduler.h:193
+  /// `StaleOrAbsent`) or wait for it to build. The result may be null, if it
+  /// fails to build, or empty if there's no include. If an error occurs, it is
+  /// forwarded to the \p Action callback. Context cancellation is ignored and

bad reflow, break before "if an error occurs" (or just drop the sentence)



Comment at: clangd/TUScheduler.h:194
+  /// fails to build, or empty if there's no include. If an error occurs, it is
+  /// forwarded to the \p Action callback. Context cancellation is ignored and
+  /// should be handled by the Action. (In practice, the Action is almost 
always

I think this is a bad reflow, need a line break before "Context cancellation is 
ignored..."



Comment at: unittests/clangd/ClangdTests.cpp:1068
+
+  // XXX provide a broken command first and then a good command.
+  auto FooCpp = testPath("foo.cpp");

does this comment need an update?



Comment at: unittests/clangd/ClangdTests.cpp:1082
+  EXPECT_EQ(Res.Context, CodeCompletionContext::CCC_Recovery);
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  EXPECT_THAT(cantFail(runCodeComplete(Server, FooCpp, Code.point(),

do I understand right that this test is currently racy?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D59811



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


[PATCH] D59811: [clangd] Add fallback mode for code completion when compile command or preamble is not ready.

2019-04-08 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 194132.
ioeric added a comment.

- Fix unit test


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D59811

Files:
  clangd/ClangdServer.cpp
  clangd/CodeComplete.h
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  clangd/Threading.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -13,8 +13,10 @@
 #include "Matchers.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
+#include "Threading.h"
 #include "URI.h"
 #include "clang/Config/config.h"
+#include "clang/Sema/CodeCompleteConsumer.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/Errc.h"
@@ -36,7 +38,6 @@
 namespace {
 
 using ::testing::ElementsAre;
-using ::testing::Eq;
 using ::testing::Field;
 using ::testing::Gt;
 using ::testing::IsEmpty;
@@ -1058,6 +1059,41 @@
   EXPECT_NE(Result, "");
 }
 
+TEST_F(ClangdVFSTest, FallbackWhenPreambleIsNotReady) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  auto FooCpp = testPath("foo.cpp");
+  Annotations Code(R"cpp(
+int main() {
+  int xyz;
+  xy^
+})cpp");
+  FS.Files[FooCpp] = FooCpp;
+
+  auto Opts = clangd::CodeCompleteOptions();
+  Opts.AllowFallbackMode = true;
+
+  // This will make compile command broken and preamble absent.
+  CDB.ExtraClangFlags = {"yolo.cc"};
+  Server.addDocument(FooCpp, Code.code());
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  auto Res = cantFail(runCodeComplete(Server, FooCpp, Code.point(), Opts));
+  EXPECT_THAT(Res.Completions, IsEmpty());
+  EXPECT_EQ(Res.Context, CodeCompletionContext::CCC_Recovery);
+
+  // Make the compile command work again.
+  CDB.ExtraClangFlags = {"-std=c++11"};
+  Server.addDocument(FooCpp, Code.code());
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  EXPECT_THAT(cantFail(runCodeComplete(Server, FooCpp, Code.point(),
+   Opts))
+  .Completions,
+  ElementsAre(Field(::Name, "xyz")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -231,6 +231,14 @@
 "Offsets are in UTF-16 code units")),
 llvm::cl::init(OffsetEncoding::UnsupportedEncoding));
 
+static llvm::cl::opt AllowFallbackCompletion(
+"allow-fallback-completion",
+llvm::cl::desc(
+"Allow falling back to code completion without compiling files (using "
+"identifiers and symbol indexes), when file cannot be built or the "
+"build is not ready."),
+llvm::cl::init(false));
+
 namespace {
 
 /// \brief Supports a test URI scheme with relaxed constraints for lit tests.
@@ -437,6 +445,7 @@
   CCOpts.SpeculativeIndexRequest = Opts.StaticIndex;
   CCOpts.EnableFunctionArgSnippets = EnableFunctionArgSnippets;
   CCOpts.AllScopes = AllScopesCompletion;
+  CCOpts.AllowFallbackMode = AllowFallbackCompletion;
 
   RealFileSystemProvider FSProvider;
   // Initialize and run ClangdLSPServer.
Index: clangd/Threading.h
===
--- clangd/Threading.h
+++ clangd/Threading.h
@@ -27,6 +27,7 @@
 public:
   // Sets the flag. No-op if already set.
   void notify();
+  bool notified() const { return Notified; }
   // Blocks until flag is set.
   void wait() const;
 
Index: clangd/TUScheduler.h
===
--- clangd/TUScheduler.h
+++ clangd/TUScheduler.h
@@ -13,7 +13,9 @@
 #include "Function.h"
 #include "Threading.h"
 #include "index/CanonicalIncludes.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
 #include 
 
 namespace clang {
@@ -32,6 +34,7 @@
 struct InputsAndPreamble {
   llvm::StringRef Contents;
   const tooling::CompileCommand 
+  // This can be nullptr if no preamble is availble.
   const PreambleData *Preamble;
 };
 
@@ -178,13 +181,19 @@
 ///   reading source code from headers.
 /// This is the fastest option, usually a preamble is available immediately.
 Stale,
+/// Besides accepting stale preamble, this also allow preamble to be absent
+/// (not ready or failed to build).
+StaleOrAbsent,
   };
+
   /// Schedule an async read of the preamble.
-  /// If there's no preamble yet (because the file was just opened), we'll wait
-  /// for it to build. The result may be null if it fails to build or is empty.
-  /// If an error occurs, it is forwarded to the \p Action callback.
-  /// Context cancellation 

[PATCH] D59811: [clangd] Add fallback mode for code completion when compile command or preamble is not ready.

2019-04-08 Thread Eric Liu via Phabricator via cfe-commits
ioeric planned changes to this revision.
ioeric added a comment.

Oops, forgot to update tests...


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D59811



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


[PATCH] D59811: [clangd] Add fallback mode for code completion when compile command or preamble is not ready.

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



Comment at: clangd/TUScheduler.h:204
+   Callback Action,
+   bool AllowFallback = false);
 

ilya-biryukov wrote:
> sammccall wrote:
> > I think this isn't orthogonal to `PreambleConsistency`.
> > When would we use AllowFallback = true but PreambleConsistency = Consistent?
> > 
> > Two possible options:
> >  - adding a new `StaleOrAbsent` option to PreambleConsistency
> >  - changing `Stale` to these new semantics, as codeComplete is the only 
> > caller
> > The problem with the latter is we can't put it behind a flag.
> Ah, I was totally looking past the `PreambleConsistency` flag.
> Thanks for spotting this. Indeed, modeling the fallback in the 
> `PreambleConsistency` would make sense.
Sounds good. Thanks for the suggestion!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D59811



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


[PATCH] D59811: [clangd] Add fallback mode for code completion when compile command or preamble is not ready.

2019-04-08 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 194129.
ioeric marked 3 inline comments as done.
ioeric added a comment.

- split out the compile command change.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D59811

Files:
  clangd/ClangdServer.cpp
  clangd/CodeComplete.h
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  clangd/Threading.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -13,8 +13,10 @@
 #include "Matchers.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
+#include "Threading.h"
 #include "URI.h"
 #include "clang/Config/config.h"
+#include "clang/Sema/CodeCompleteConsumer.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/Errc.h"
@@ -36,7 +38,6 @@
 namespace {
 
 using ::testing::ElementsAre;
-using ::testing::Eq;
 using ::testing::Field;
 using ::testing::Gt;
 using ::testing::IsEmpty;
@@ -1058,6 +1059,33 @@
   EXPECT_NE(Result, "");
 }
 
+TEST_F(ClangdVFSTest, FallbackWhenPreambleIsNotReady) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  // XXX provide a broken command first and then a good command.
+  auto FooCpp = testPath("foo.cpp");
+  Annotations Code(R"cpp(
+int main() {
+  int xyz;
+  xy^
+})cpp");
+  FS.Files[FooCpp] = FooCpp;
+  Server.addDocument(FooCpp, Code.code());
+  auto Opts = clangd::CodeCompleteOptions();
+  Opts.AllowFallbackMode = true;
+  auto Res = cantFail(runCodeComplete(Server, FooCpp, Code.point(), Opts));
+  EXPECT_THAT(Res.Completions, IsEmpty());
+  EXPECT_EQ(Res.Context, CodeCompletionContext::CCC_Recovery);
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+  EXPECT_THAT(cantFail(runCodeComplete(Server, FooCpp, Code.point(),
+   clangd::CodeCompleteOptions()))
+  .Completions,
+  ElementsAre(Field(::Name, "xyz")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -231,6 +231,14 @@
 "Offsets are in UTF-16 code units")),
 llvm::cl::init(OffsetEncoding::UnsupportedEncoding));
 
+static llvm::cl::opt AllowFallbackCompletion(
+"allow-fallback-completion",
+llvm::cl::desc(
+"Allow falling back to code completion without compiling files (using "
+"identifiers and symbol indexes), when file cannot be built or the "
+"build is not ready."),
+llvm::cl::init(false));
+
 namespace {
 
 /// \brief Supports a test URI scheme with relaxed constraints for lit tests.
@@ -437,6 +445,7 @@
   CCOpts.SpeculativeIndexRequest = Opts.StaticIndex;
   CCOpts.EnableFunctionArgSnippets = EnableFunctionArgSnippets;
   CCOpts.AllScopes = AllScopesCompletion;
+  CCOpts.AllowFallbackMode = AllowFallbackCompletion;
 
   RealFileSystemProvider FSProvider;
   // Initialize and run ClangdLSPServer.
Index: clangd/Threading.h
===
--- clangd/Threading.h
+++ clangd/Threading.h
@@ -27,6 +27,7 @@
 public:
   // Sets the flag. No-op if already set.
   void notify();
+  bool notified() const { return Notified; }
   // Blocks until flag is set.
   void wait() const;
 
Index: clangd/TUScheduler.h
===
--- clangd/TUScheduler.h
+++ clangd/TUScheduler.h
@@ -13,7 +13,9 @@
 #include "Function.h"
 #include "Threading.h"
 #include "index/CanonicalIncludes.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
 #include 
 
 namespace clang {
@@ -32,6 +34,7 @@
 struct InputsAndPreamble {
   llvm::StringRef Contents;
   const tooling::CompileCommand 
+  // This can be nullptr if no preamble is availble.
   const PreambleData *Preamble;
 };
 
@@ -178,13 +181,19 @@
 ///   reading source code from headers.
 /// This is the fastest option, usually a preamble is available immediately.
 Stale,
+/// Besides accepting stale preamble, this also allow preamble to be absent
+/// (not ready or failed to build).
+StaleOrAbsent,
   };
+
   /// Schedule an async read of the preamble.
-  /// If there's no preamble yet (because the file was just opened), we'll wait
-  /// for it to build. The result may be null if it fails to build or is empty.
-  /// If an error occurs, it is forwarded to the \p Action callback.
-  /// Context cancellation is ignored and should be handled by the Action.
-  /// (In practice, the Action is almost always executed immediately).
+  /// If 

[PATCH] D58675: [clang] Adds `-ftime-trace` option to clang that produces Chrome `chrome://tracing` compatible JSON profiling output dumps

2019-04-08 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev added a comment.

Fix hashing update: https://reviews.llvm.org/D60404


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58675



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


[PATCH] D59135: Add check for matching HeaderFilter before emitting Diagnostic

2019-04-08 Thread Thorsten via Phabricator via cfe-commits
thorsten-klein added a comment.

Hello @alexfh ,
Let me extend your example

  $ cat a.cc 
  #include "b.h"
  #include "d.h"
  int main(){check(nullptr);}
  $ cat b.h 
  #include "c.h"
  inline void b() { c(/*y=*/42); }
  $ cat c.h 
  void c(int x);
  $ cat d.h 
  inline char* check(char* buffer)
  {
*buffer++=1; // Should be clang-analyzer-core.NullDereference
return buffer;
  }

Now an additional warning is found and shown (=not suppressed):

  $ clang-tidy -checks=-*,clang-*,bugprone-argument-comment a.cc --
  2 warnings generated.
  /home/default/Temp/clang-tidy-test/d.h:3:11: warning: Dereference of null 
pointer [clang-analyzer-core.NullDereference]
  *buffer++=1; // Should be clang-analyzer-core.NullDereference
   ^
  /home/default/Temp/clang-tidy-test/a.cc:3:12: note: Calling 'check'
  int main(){check(0);}
 ^
  /home/default/Temp/clang-tidy-test/d.h:3:3: note: Null pointer value stored 
to 'buffer'
  *buffer++=1; // Should be clang-analyzer-core.NullDereference
   ^
  /home/default/Temp/clang-tidy-test/d.h:3:11: note: Dereference of null pointer
  *buffer++=1; // Should be clang-analyzer-core.NullDereference
   ^
  Suppressed 1 warnings (1 in non-user code).
  Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.

**How can I use -header-filter now?**

With -header-filter=b.h clang-tidy shows both warnings:

  $ clang-tidy -checks=-*,clang-*,bugprone-argument-comment a.cc 
-header-filter=b.h --
  2 warnings generated.
  /home/default/Temp/clang-tidy-test/b.h:2:21: warning: argument name 'y' in 
comment does not match parameter name 'x' [bugprone-argument-comment]
  inline void b() { c(/*y=*/42); }
  ^~
  /*x=*/
  /home/default/Temp/clang-tidy-test/c.h:1:12: note: 'x' declared here
  void c(int x);
 ^
  /home/default/Temp/clang-tidy-test/d.h:3:11: warning: Dereference of null 
pointer [clang-analyzer-core.NullDereference]
  *buffer++=1; // Should be clang-analyzer-core.NullDereference
   ^
  /home/default/Temp/clang-tidy-test/a.cc:3:12: note: Calling 'check'
  int main(){check(0);}
 ^
  /home/default/Temp/clang-tidy-test/d.h:3:3: note: Null pointer value stored 
to 'buffer'
  *buffer++=1; // Should be clang-analyzer-core.NullDereference
   ^
  /home/default/Temp/clang-tidy-test/d.h:3:11: note: Dereference of null pointer
  *buffer++=1; // Should be clang-analyzer-core.NullDereference
   ^

With -header-filter=c.h clang-tidy shows both warnings:

  $ clang-tidy -checks=-*,clang-*,bugprone-argument-comment a.cc 
-header-filter=c.h --
  2 warnings generated.
  /home/default/Temp/clang-tidy-test/b.h:2:21: warning: argument name 'y' in 
comment does not match parameter name 'x' [bugprone-argument-comment]
  inline void b() { c(/*y=*/42); }
  ^~
  /*x=*/
  /home/default/Temp/clang-tidy-test/c.h:1:12: note: 'x' declared here
  void c(int x);
 ^
  /home/default/Temp/clang-tidy-test/d.h:3:11: warning: Dereference of null 
pointer [clang-analyzer-core.NullDereference]
  *buffer++=1; // Should be clang-analyzer-core.NullDereference
   ^
  /home/default/Temp/clang-tidy-test/a.cc:3:12: note: Calling 'check'
  int main(){check(0);}
 ^
  /home/default/Temp/clang-tidy-test/d.h:3:3: note: Null pointer value stored 
to 'buffer'
  *buffer++=1; // Should be clang-analyzer-core.NullDereference
   ^
  /home/default/Temp/clang-tidy-test/d.h:3:11: note: Dereference of null pointer
  *buffer++=1; // Should be clang-analyzer-core.NullDereference
   ^

With -header-filter=c.h clang-tidy shows both warnings:

  $ clang-tidy -checks=-*,clang-*,bugprone-argument-comment a.cc 
-header-filter=d.h --
  2 warnings generated.
  /home/default/Temp/clang-tidy-test/d.h:3:11: warning: Dereference of null 
pointer [clang-analyzer-core.NullDereference]
  *buffer++=1; // Should be clang-analyzer-core.NullDereference
   ^
  /home/default/Temp/clang-tidy-test/a.cc:3:12: note: Calling 'check'
  int main(){check(nullptr);}
 ^
  /home/default/Temp/clang-tidy-test/d.h:3:3: note: Null pointer value stored 
to 'buffer'
  *buffer++=1; // Should be clang-analyzer-core.NullDereference
   ^
  /home/default/Temp/clang-tidy-test/d.h:3:11: note: Dereference of null pointer
  *buffer++=1; // Should be clang-analyzer-core.NullDereference
   ^
  Suppressed 1 warnings (1 in non-user code).
  Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.

How can I suppress warning for my header file //**d.h**// so that only warning 
from //**b.h**// is shown?


CHANGES SINCE LAST 

[PATCH] D60320: [clang-format]: Add option to insert space after locical not operator

2019-04-08 Thread Reuben Thomas via Phabricator via cfe-commits
reuk closed this revision.
reuk added a comment.

Closed by https://reviews.llvm.org/rG91f60b44958f, 
https://reviews.llvm.org/rL357908, https://reviews.llvm.org/rC357908 (sorry, I 
forgot to update the body of the commit message to close this automatically)


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

https://reviews.llvm.org/D60320



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


r357908 - [clang-format] Optionally insert a space after unary ! operator

2019-04-08 Thread Reuben Thomas via cfe-commits
Author: reuk
Date: Mon Apr  8 05:54:48 2019
New Revision: 357908

URL: http://llvm.org/viewvc/llvm-project?rev=357908=rev
Log:
[clang-format] Optionally insert a space after unary ! operator

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=357908=357907=357908=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Mon Apr  8 05:54:48 2019
@@ -1952,6 +1952,13 @@ the configuration (without a prefix: ``A
  true:  false:
  (int) i;   vs. (int)i;
 
+**SpaceAfterLogicalNot** (``bool``)
+  If ``true``, a space is inserted after the logical not operator (``!``).
+  .. code-block:: c++
+
+ true:  false:
+ ! someExpression();vs. !someExpression();
+
 **SpaceAfterTemplateKeyword** (``bool``)
   If ``true``, a space will be inserted after the 'template' keyword.
 

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=357908=357907=357908=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Mon Apr  8 05:54:48 2019
@@ -1628,6 +1628,13 @@ struct FormatStyle {
   /// \endcode
   bool SpaceAfterCStyleCast;
 
+  /// If ``true``, a space is inserted after the logical not operator (``!``).
+  /// \code
+  ///true:  false:
+  ///! someExpression();vs. !someExpression();
+  /// \endcode
+  bool SpaceAfterLogicalNot;
+
   /// If \c true, a space will be inserted after the 'template' keyword.
   /// \code
   ///true:  false:
@@ -1911,6 +1918,7 @@ struct FormatStyle {
PointerAlignment == R.PointerAlignment &&
RawStringFormats == R.RawStringFormats &&
SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
+   SpaceAfterLogicalNot == R.SpaceAfterLogicalNot &&
SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators 
&&
SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=357908=357907=357908=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Apr  8 05:54:48 2019
@@ -478,6 +478,7 @@ template <> struct MappingTraitshttp://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=357908=357907=357908=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Apr  8 05:54:48 2019
@@ -2832,7 +2832,8 @@ bool TokenAnnotator::spaceRequiredBefore
 return true;
   }
   if (Left.is(TT_UnaryOperator))
-return Right.is(TT_BinaryOperator);
+return (Style.SpaceAfterLogicalNot && Left.is(tok::exclaim)) ||
+   Right.is(TT_BinaryOperator);
 
   // If the next token is a binary operator or a selector name, we have
   // incorrectly classified the parenthesis as a cast. FIXME: Detect correctly.

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=357908=357907=357908=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Apr  8 05:54:48 2019
@@ -9719,6 +9719,17 @@ TEST_F(FormatTest, ConfigurableSpaceBefo
   verifyFormat("auto lambda = []() { return 0; };", SomeSpace);
 }
 
+TEST_F(FormatTest, SpaceAfterLogicalNot) {
+  FormatStyle Spaces = getLLVMStyle();
+  Spaces.SpaceAfterLogicalNot = true;
+
+  verifyFormat("bool x = ! y", Spaces);
+  verifyFormat("if (! isFailure())", Spaces);
+  verifyFormat("if (! (a && b))", Spaces);
+  verifyFormat("\"Error!\"", Spaces);
+  verifyFormat("! ! x", Spaces);
+}
+
 TEST_F(FormatTest, ConfigurableSpacesInParentheses) {
   FormatStyle Spaces = getLLVMStyle();
 
@@ -11511,6 +11522,12 @@ TEST_F(FormatTest, ParsesConfiguration)
   CHECK_PARSE("SpaceAfterControlStatementKeyword: true", SpaceBeforeParens,
   FormatStyle::SBPO_ControlStatements);
 
+  Style.SpaceAfterLogicalNot 

[PATCH] D60316: [clangd] Include insertion: require header guards, drop other heuristics, treat .def like .inc.

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



Comment at: clangd/index/SymbolCollector.cpp:157
+  return Canonical.str();
+else if (Canonical != Filename)
+  return toURI(SM, Canonical, Opts);

nit: no need for `else`?



Comment at: unittests/clangd/FileIndexTests.cpp:214
 
 TEST(FileIndexTest, HasSystemHeaderMappingsInPreamble) {
+  TestTU TU;

sammccall wrote:
> I suspect we can replace most of these tests with TestTU - here I just 
> changed the ones where the include guard would otherwise be needed.
This looks good to me.

I think this test case tried to explicitly test that preamble callback has the 
expected `CanonicalIncludes`. Using `TestTU` seems to achieve the same goal but 
makes the intention a bit less clear though. 



Comment at: unittests/clangd/TestTU.h:55
 
+  // Simulate a header guard of the header (using an #import directive).
+  bool ImplicitHeaderGuard = true;

is this used?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60316



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


[PATCH] D52527: [clang-format] fix Bug 38686: add AfterCaseLabel to BraceWrapping

2019-04-08 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a subscriber: reuk.
MyDeveloperDay added a comment.

@ownenpan might be worth checking with @reuk who has been adding some options 
for the JUCE style guide and looking at the JUCE code it seems this style might 
match their style.




Comment at: include/clang/Format/Format.h:638
+/// \endcode
+bool AfterCaseLabel;
 /// Wrap class definitions.

krasimir wrote:
> This comment seems outdated (the one in `ClangFormatStyleOptions.rst` seems 
> more recent).
> 
> The `ClangFormatStyleOptions.rst` file is automatically generated from this 
> file. Please update this comment and regenerate `ClangFormatStyleOptions.rst` 
> by using the `clang/docs/tools/dump_format_style.py` script.
@krasimir do you happen to know if this script is run by the build or is 
supposed to be run by the developer after making the change to Format.h

If the latter, then I reckon the two are out of sync, perhaps I should submit a 
change to realign them, but really there should be some sort of make target 
that lets us determine when they diverge otherwise they'll keep changing


Repository:
  rC Clang

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

https://reviews.llvm.org/D52527



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


[PATCH] D52527: [clang-format] fix Bug 38686: add AfterCaseLabel to BraceWrapping

2019-04-08 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: include/clang/Format/Format.h:638
+/// \endcode
+bool AfterCaseLabel;
 /// Wrap class definitions.

This comment seems outdated (the one in `ClangFormatStyleOptions.rst` seems 
more recent).

The `ClangFormatStyleOptions.rst` file is automatically generated from this 
file. Please update this comment and regenerate `ClangFormatStyleOptions.rst` 
by using the `clang/docs/tools/dump_format_style.py` script.



Comment at: lib/Format/Format.cpp:611
 Expanded.BraceWrapping = {true, true, true, true, true, true, true, true,
-  true, true, true, true, true, true, true};
+  true, true, true, true, true, true, true, true};
 break;

If Allman and GNU styles both follow the style suggested by this new flag, my 
mistake: this would be enough to add it to clang-format.


Repository:
  rC Clang

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

https://reviews.llvm.org/D52527



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


[PATCH] D59087: [clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present

2019-04-08 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: cfe/trunk/docs/ClangFormatStyleOptions.rst:384
+
+  * ``SIS_WithoutElse`` (in configuration: ``WithoutElse``)
+Allow short if functions on the same line, as long as else

MyDeveloperDay wrote:
> klimek wrote:
> > Is that actually the status quo or is the current behavior missing?
> Yes that is "as was"
Ok, that seems... wrong :)
Specifically, I'd at least expect the first one to also do
  if (a) return;
  else return;

That would be SIS_Always now? If so, could we make "true" just be "Always"?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59087



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


[PATCH] D59509: Make static constructors + destructors minsize + cold (except for in -O0)

2019-04-08 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Looks reasonable to me.




Comment at: clang/test/CodeGen/static-attr.cpp:4
+
+// WITHOUT-NOT: cold minsize noinline
+// WITH: define internal void @__cxx_global_var_init() [[ATTR:#[0-9]]]

lebedev.ri wrote:
> This is fragile, it may have false-negative if they appear in other order.
I think we guarantee it's emitted in the same order, but it's certainly the 
case that nobody will ever notice if this is failing to fail the test, if other 
attributes get emitted in between in the future.

You can use 3 separate WITHOUT-NOT lines, instead, to avoid both of this kind 
of issue.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59509



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


[PATCH] D60323: [clangd] Include compile command inference in fileStatus API

2019-04-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/GlobalCompilationDatabase.cpp:70
  /*Output=*/"");
+  Result.Heuristic = "default flags for unknown file";
+  return Result;

`default flags` seems not quite clear to me, maybe use `fallback compile 
command for unknown file`?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60323



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


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

2019-04-08 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: test/CodeGen/x86_32-mmx-linux.c:2
+// RUN: %clang_cc1 -w -O2 -fblocks -triple i386-pc-linux-gnu -target-cpu 
pentium4 -emit-llvm -o %t %s
+// RUN: FileCheck < %t %s
+

Test on more triples and add the test file to trunk with current codegen so 
this patch shows the delta


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] D59087: [clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present

2019-04-08 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked 2 inline comments as done.
MyDeveloperDay added a comment.

In D59087#1456129 , @krasimir wrote:

> I believe there is no such thing as an "short else statement". The `else` is 
> part of the `if` statement and if it is present, I don't consider the whole 
> `if` statement short. As such, IMO the bug is invalid.


I understand your point, but that is just one viewpoint only.

The opinion of the person who logged the defect (and I'm not that user just 
someone who wants to address the defects), whether something is a bug or not is 
100% about their perspective, (that doesn't mean we have to address everything)

The question is does the change to the option hurt anyone who doesn't care? Is 
it useful the to the user requesting it? Does it significantly impact our 
ability to maintain the code, could it be useful to others.




Comment at: cfe/trunk/docs/ClangFormatStyleOptions.rst:384
+
+  * ``SIS_WithoutElse`` (in configuration: ``WithoutElse``)
+Allow short if functions on the same line, as long as else

klimek wrote:
> Is that actually the status quo or is the current behavior missing?
Yes that is "as was"


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59087



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


[PATCH] D46940: [ASTImporter] make sure that ACtx::getParents still works

2019-04-08 Thread Rafael Stahl via Phabricator via cfe-commits
r.stahl abandoned this revision.
r.stahl added a comment.
Herald added a reviewer: shafik.

ASTContext::getParents should not be used this way. This use-case is solved by 
function-scoped ParentMaps or AnalysisDeclContext::getParentMap. Discussion: 
http://lists.llvm.org/pipermail/cfe-dev/2019-April/061944.html


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

https://reviews.llvm.org/D46940



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


[PATCH] D59087: [clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present

2019-04-08 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: cfe/trunk/docs/ClangFormatStyleOptions.rst:384
+
+  * ``SIS_WithoutElse`` (in configuration: ``WithoutElse``)
+Allow short if functions on the same line, as long as else

Is that actually the status quo or is the current behavior missing?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59087



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


[PATCH] D59746: [LibTooling] Fix '-h' option

2019-04-08 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In D59746#1440756 , @hintonda wrote:

> A better alternative would have been to add a cl::aliasopt for '-h' in llvm's 
> CommandLineParser when '-help' was first added.  However, that's no longer 
> possible since some llvm based tools already use '-h' for other purposes.


Is that intentional? Can you point at samples?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59746



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


[PATCH] D59756: [clangd] Support dependent bases in type hierarchy

2019-04-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.



Comment at: clang-tools-extra/unittests/clangd/TypeHierarchyTests.cpp:405
+  *Result,
+  AllOf(WithName("S"), WithKind(SymbolKind::Struct),
+Parents(AllOf(WithName("S"), WithKind(SymbolKind::Struct),

nridge wrote:
> sammccall wrote:
> > Sorry, I realize this isn't related to this patch, but I didn't see the 
> > final form of the previous one.
> > 
> > This should be `WithName("S<0>"), ... Parents(AllOf(WithName("S<1>")), 
> > ...)`. S is the name of the template, not the name of the type.
> > 
> > Can you add a fixme?
> (I looked into what it would take to fix this, and it seems like we need 
> D59639, so I'm going to wait for that.)
AFAICS D59639 is something subtly different - it prints the args of 
*specializations* as written in the source code, not instantiations. i.e. if 
you try to use this for `vector`, it won't work as there's no 
specialization, you'll get `vector` instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59756



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


[PATCH] D55049: Changed every use of ASTImporter::Import to Import_New

2019-04-08 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55049



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


[PATCH] D60379: Make precompiled headers reproducible

2019-04-08 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

I won't have time to write the test for that (and would not know where to 
start). I am just the messenger :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D60379



___
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-08 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

It looks like there's a number of users of this function beyond what you've 
mentioned:
clang-tidy/readability/IsolateDeclarationCheck.cpp:210
clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp:43
clang-tidy/readability/NamespaceCommentCheck.cpp:106
clang/lib/ARCMigrate/PlistReporter.cpp:110
clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:192

Could you take a brief look at those as well?




Comment at: cfe/trunk/include/clang/Basic/PlistSupport.h:134
+  // even though it is incorrect.
+  EmitLocation(o, SM, R.getEnd().getLocWithOffset(-1), FM, indent + 1);
   Indent(o, indent) << "\n";

What kind of backwards compatibility are you trying to achieve? Where would the 
version skew come from?


Repository:
  rL LLVM

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] D52527: [clang-format] fix Bug 38686: add AfterCaseLabel to BraceWrapping

2019-04-08 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.

Apart from the typo I think this is a simple enough change and a widely enough 
used style that it LG.




Comment at: lib/Format/UnwrappedLineParser.cpp:181
+  CompoundStatementIndenter(UnwrappedLineParser *Parser, unsigned ,
+bool WrapeBrace, bool IndentBrace)
   : LineLevel(LineLevel), OldLineLevel(LineLevel) {

Typo: WrapBrace?


Repository:
  rC Clang

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

https://reviews.llvm.org/D52527



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


[PATCH] D60320: [clang-format]: Add option to insert space after locical not operator

2019-04-08 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.

lg


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

https://reviews.llvm.org/D60320



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


  1   2   >