r371918 - [Driver] Fix multiple bugs related to dependency file options: -M -MM -MD -MMD -MT -MQ

2019-09-13 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Fri Sep 13 23:01:22 2019
New Revision: 371918

URL: http://llvm.org/viewvc/llvm-project?rev=371918=rev
Log:
[Driver] Fix multiple bugs related to dependency file options: -M -MM -MD -MMD 
-MT -MQ

-M -o test.i => dependency file is test.d, not test.i
-MM -o test.i => dependency file is test.d, not test.i
-M -MMD => bogus warning -Wunused-command-line-argument
-M MT dummy => -w not rendered

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/m-and-mm.c

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=371918=371917=371918=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Sep 13 23:01:22 2019
@@ -3450,8 +3450,10 @@ Action *Driver::ConstructPhaseAction(
 llvm_unreachable("link action invalid here.");
   case phases::Preprocess: {
 types::ID OutputTy;
-// -{M, MM} alter the output type.
-if (Args.hasArg(options::OPT_M, options::OPT_MM)) {
+// -M and -MM specify the dependency file name by altering the output type,
+// -if -MD and -MMD are not specified.
+if (Args.hasArg(options::OPT_M, options::OPT_MM) &&
+!Args.hasArg(options::OPT_MD, options::OPT_MMD)) {
   OutputTy = types::TY_Dependencies;
 } else {
   OutputTy = Input->getType();

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=371918=371917=371918=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Sep 13 23:01:22 2019
@@ -1061,7 +1061,6 @@ void Clang::AddPreprocessingOptions(Comp
 ArgStringList ,
 const InputInfo ,
 const InputInfoList ) const {
-  Arg *A;
   const bool IsIAMCU = getToolChain().getTriple().isOSIAMCU();
 
   CheckPreprocessingOptions(D, Args);
@@ -1070,9 +1069,20 @@ void Clang::AddPreprocessingOptions(Comp
   Args.AddLastArg(CmdArgs, options::OPT_CC);
 
   // Handle dependency file generation.
-  if ((A = Args.getLastArg(options::OPT_M, options::OPT_MM)) ||
-  (A = Args.getLastArg(options::OPT_MD)) ||
-  (A = Args.getLastArg(options::OPT_MMD))) {
+  Arg *ArgM = Args.getLastArg(options::OPT_MM);
+  if (!ArgM)
+ArgM = Args.getLastArg(options::OPT_M);
+  Arg *ArgMD = Args.getLastArg(options::OPT_MMD);
+  if (!ArgMD)
+ArgMD = Args.getLastArg(options::OPT_MD);
+
+  // -M and -MM imply -w.
+  if (ArgM)
+CmdArgs.push_back("-w");
+  else
+ArgM = ArgMD;
+
+  if (ArgM) {
 // Determine the output location.
 const char *DepFile;
 if (Arg *MF = Args.getLastArg(options::OPT_MF)) {
@@ -1080,8 +1090,7 @@ void Clang::AddPreprocessingOptions(Comp
   C.addFailureResultFile(DepFile, );
 } else if (Output.getType() == types::TY_Dependencies) {
   DepFile = Output.getFilename();
-} else if (A->getOption().matches(options::OPT_M) ||
-   A->getOption().matches(options::OPT_MM)) {
+} else if (!ArgMD) {
   DepFile = "-";
 } else {
   DepFile = getDependencyFileName(Args, Inputs);
@@ -1090,8 +1099,22 @@ void Clang::AddPreprocessingOptions(Comp
 CmdArgs.push_back("-dependency-file");
 CmdArgs.push_back(DepFile);
 
+bool HasTarget = false;
+for (const Arg *A : Args.filtered(options::OPT_MT, options::OPT_MQ)) {
+  HasTarget = true;
+  A->claim();
+  if (A->getOption().matches(options::OPT_MT)) {
+A->render(Args, CmdArgs);
+  } else {
+CmdArgs.push_back("-MT");
+SmallString<128> Quoted;
+QuoteTarget(A->getValue(), Quoted);
+CmdArgs.push_back(Args.MakeArgString(Quoted));
+  }
+}
+
 // Add a default target if one wasn't specified.
-if (!Args.hasArg(options::OPT_MT) && !Args.hasArg(options::OPT_MQ)) {
+if (!HasTarget) {
   const char *DepTarget;
 
   // If user provided -o, that is the dependency target, except
@@ -1108,17 +1131,14 @@ void Clang::AddPreprocessingOptions(Comp
 DepTarget = Args.MakeArgString(llvm::sys::path::filename(P));
   }
 
-  if (!A->getOption().matches(options::OPT_MD) && 
!A->getOption().matches(options::OPT_MMD)) {
-CmdArgs.push_back("-w");
-  }
   CmdArgs.push_back("-MT");
   SmallString<128> Quoted;
   QuoteTarget(DepTarget, Quoted);
   CmdArgs.push_back(Args.MakeArgString(Quoted));
 }
 
-if (A->getOption().matches(options::OPT_M) ||
-A->getOption().matches(options::OPT_MD))
+if (ArgM->getOption().matches(options::OPT_M) ||
+ArgM->getOption().matches(options::OPT_MD))
   CmdArgs.push_back("-sys-header-deps");
 if ((isa(JA) &&
 

r371917 - [Driver] Improve Clang::getDependencyFileName and its tests after rC371853

2019-09-13 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Fri Sep 13 21:13:15 2019
New Revision: 371917

URL: http://llvm.org/viewvc/llvm-project?rev=371917=rev
Log:
[Driver] Improve Clang::getDependencyFileName and its tests after rC371853

The test file name metadata-with-dots.c is confusing because -MD and -MMD
have nothing to do with metadata.

Added:
cfe/trunk/test/Driver/m-and-mm.c
Removed:
cfe/trunk/test/Driver/m_and_mm.c
cfe/trunk/test/Driver/metadata-with-dots.c
Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=371917=371916=371917=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Sep 13 21:13:15 2019
@@ -6073,7 +6073,7 @@ const char *Clang::getDependencyFileName
 return Args.MakeArgString(OutputFilename);
   }
 
-  return Args.MakeArgString(std::string(getBaseInputStem(Args, Inputs)) + 
".d");
+  return Args.MakeArgString(Twine(getBaseInputStem(Args, Inputs)) + ".d");
 }
 
 // Begin ClangAs

Added: cfe/trunk/test/Driver/m-and-mm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/m-and-mm.c?rev=371917=auto
==
--- cfe/trunk/test/Driver/m-and-mm.c (added)
+++ cfe/trunk/test/Driver/m-and-mm.c Fri Sep 13 21:13:15 2019
@@ -0,0 +1,17 @@
+// RUN: %clang -M -MM %s 2>&1 | FileCheck /dev/null 
--implicit-check-not=warning
+
+// RUN: mkdir -p %t.dir
+// RUN: rm -f %t.dir/test.d
+// RUN: %clang -fsyntax-only -MD %s -o %t.dir/test.i
+// RUN: test -f %t.dir/test.d
+
+/// If the output file name does not have a suffix, just append `.d`.
+// RUN: rm -f %t.dir/test.d
+// RUN: %clang -fsyntax-only -MD %s -o %t.dir/test
+// RUN: test -f %t.dir/test.d
+
+#warning "-M and -MM suppresses preprocessing, thus this warning shouldn't 
show up"
+int main(void)
+{
+return 0;
+}

Removed: cfe/trunk/test/Driver/m_and_mm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/m_and_mm.c?rev=371916=auto
==
--- cfe/trunk/test/Driver/m_and_mm.c (original)
+++ cfe/trunk/test/Driver/m_and_mm.c (removed)
@@ -1,15 +0,0 @@
-// RUN: %clang -### \
-// RUN:   -M -MM %s 2> %t
-// RUN: not grep '"-sys-header-deps"' %t
-
-// RUN: %clang -M -MM %s 2> %t
-// RUN: not grep "warning" %t
-
-// RUN: %clang -MMD -MD %s 2> %t || true
-// RUN: grep "warning" %t
-
-#warning "This warning shouldn't show up with -M and -MM"
-int main (void)
-{
-return 0;
-}

Removed: cfe/trunk/test/Driver/metadata-with-dots.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/metadata-with-dots.c?rev=371916=auto
==
--- cfe/trunk/test/Driver/metadata-with-dots.c (original)
+++ cfe/trunk/test/Driver/metadata-with-dots.c (removed)
@@ -1,11 +0,0 @@
-// REQUIRES: shell
-// RUN: mkdir -p %t/out.dir
-// RUN: cat %s > %t/out.dir/test.c
-// RUN: %clang -E -MMD %s -o %t/out.dir/test
-// RUN: test ! -f %out.d
-// RUN: test -f %t/out.dir/test.d
-// RUN: rm -rf %t/out.dir/test.d %t/out.dir/ out.d
-int main (void)
-{
-return 0;
-}


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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support -- NOT FOR SUBMIT

2019-09-13 Thread Steven Noonan via Phabricator via cfe-commits
tycho added a comment.

OK, those two problems were actually easy enough to fix.

  diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
  index 2f98cf9e04..93e974842f 100644
  --- a/lib/Driver/Driver.cpp
  +++ b/lib/Driver/Driver.cpp
  @@ -3241,8 +3241,8 @@ void Driver::BuildActions(Compilation , 
DerivedArgList ,
 }
 if (FinalPhase != phases::Preprocess) {
   if (Arg *A = Args.getLastArg(options::OPT__SLASH_MP)) {
  +  if (!StringRef(A->getValue()).getAsInteger(10, C.CoresToUse))
   C.CoresToUse = llvm::hardware_concurrency();
  -StringRef(A->getValue()).getAsInteger(10, C.CoresToUse);
   }
 }

And:

  diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
  index 93e974842f..c1e8e798d4 100644
  --- a/lib/Driver/Driver.cpp
  +++ b/lib/Driver/Driver.cpp
  @@ -3239,7 +3239,7 @@ void Driver::BuildActions(Compilation , 
DerivedArgList ,
   Args.eraseArg(options::OPT__SLASH_Yu);
   YcArg = YuArg = nullptr;
 }
  -  if (FinalPhase != phases::Preprocess) {
  +  if (!YcArg && FinalPhase != phases::Preprocess) {
   if (Arg *A = Args.getLastArg(options::OPT__SLASH_MP)) {
 if (!StringRef(A->getValue()).getAsInteger(10, C.CoresToUse))
   C.CoresToUse = llvm::hardware_concurrency();

The result is a thing of beauty:

F9989375: Taskmgr_GE0Zo74CYl.png 


Repository:
  rC Clang

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

https://reviews.llvm.org/D52193



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


[PATCH] D67368: [NFCI]Create CommonAttributeInfo Type as base type of *Attr and ParsedAttr.

2019-09-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: cfe/trunk/include/clang/Basic/AttributeCommonInfo.h:166
+   ? SpellingIndex
+   : calculateAttributeSpellingListIndex();
+  }

calculateAttributeSpellingListIndex is defined in clangSema. This can cause 
lib/libclangAST.so.10svn (-DBUILD_SHARED_LIBS=on) fail to link:

```
ld.lld: error: undefined symbol: 
clang::AttributeCommonInfo::calculateAttributeSpellingListIndex() const   
>>> referenced by AttributeCommonInfo.h:166 
>>> (../tools/clang/include/clang/Basic/AttributeCommonInfo.h:166) 
>>>   
>>> tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/AttrImpl.cpp.o:(clang::AttributeCommonInfo::getAttributeSpellingListIndex()
>>>  const)
```


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67368



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


[PATCH] D52193: RFC: [clang] Multithreaded compilation support -- NOT FOR SUBMIT

2019-09-13 Thread Steven Noonan via Phabricator via cfe-commits
tycho added a comment.

I rebased this myself on the release_90 branch and I was pleasantly surprised 
that I got the merge right on the first try (?!), and it actually works well 
without any significant changes (other than merge conflict resolutions).

I've run into two problems with it though:

- Running `clang-cl.exe /MP` without a number following the argument doesn't 
seem to automatically pick up the number of available available CPUs. I haven't 
debugged that yet, but it's probably a trivial fix.

- Precompiled headers aren't being built properly when using `clang-cl.exe /MP` 
under Visual Studio. If I do a clean build with e.g. `/MP16`, it errors 
immediately with this:

> 1>project_pch.cpp
>  1>CL : error : unable to read PCH file .\Release\.\/project_pch.pch: 'no 
> such file or directory'
>  1>CL : fatal error : PCH file '.\Release\.\/project_pch.pch' not found: 
> module file not found
>  1>Done building project "project.vcxproj" -- FAILED.

When running with `-v` on `clang-cl.exe`'s command line, I can see that it 
starts doing a compile with `-emit-pch` and another with `-emit-obj`, 
apparently running simultaneously. It looks like the object file needs the PCH 
to be compiled first, so it fails when it doesn't find the .pch file the other 
process should be working on. I bumped `msbuild.exe`'s verbosity up to see what 
it tried to do, and it only invoked clang-cl once, to compile one file 
(`project_pch.cpp`) with the "emit precompiled header" arguments on the command 
line. So this shouldn't be too crazy-tough to fix.

(I think my short-term/wrong workaround for this will be to ignore `/MP` when 
an input file is type `c++-header`. The more accurate solution would be to make 
the `.obj` depend on the `.pch`)

---

Has there been any further work on this change outside of what's recorded in 
this thread?


Repository:
  rC Clang

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

https://reviews.llvm.org/D52193



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


[PATCH] D67567: [clang-tidy] New check to warn when storing dispatch_once_t in non-static, non-global storage

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

FTR, we already have a similar Static Analyzer check, eg.: 
https://github.com/llvm-mirror/clang/blob/release_80/test/Analysis/dispatch-once.m#L15

Your check is a bit more aggressive but i don't see why didn't we do it that 
way in the first place :)


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

https://reviews.llvm.org/D67567



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


[PATCH] D67578: [clang-tidy] New check to warn when writing to a dispatch_once_t variable.

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



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/misc-dispatch-once-assignment.rst:9
+and making such direct writes may potentially violate the run-once protections
+intended by the library.

Does library documentation contain this recommendation? If so, will be good 
idea to add link. Same for other check.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D67578



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


[PATCH] D67542: Fix depfile name construction

2019-09-13 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: cfe/trunk/lib/Driver/ToolChains/Clang.cpp:6076
+
+  return Args.MakeArgString(std::string(getBaseInputStem(Args, Inputs)) + 
".d");
 }

Can you use llvm::Twine() instead of std::string() here?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67542



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


[PATCH] D66696: [ObjC generics] Fix not inheriting type bounds in categories/extensions.

2019-09-13 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In D66696#1663856 , @erik.pilkington 
wrote:

> I'm a bit curious about clients that use `getCanonicalType()` to get a full 
> desugaring, instead of doing a single step. It seems like they'd still get 
> the out of date type parameter type. Has that ever worked?


Good point. I believe it never worked but don't have specific examples. Suspect 
that we haven't seen such problems because `ObjCTypeParamType` has limited 
usage before it is substituted with a concrete type.

While checking the code I've noticed we can make a small cleanup - in

  QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl,
ArrayRef protocols,
QualType Canonical = QualType()) const;

remove the parameter `Canonical` because no caller provides it and it's not the 
best idea to allow to provide `Canonical` type that can be inconsistent with 
`ObjCTypeParamDecl` type. Plan to do the cleanup in a separate commit.


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

https://reviews.llvm.org/D66696



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


[PATCH] D63978: Clang Interface Stubs merger plumbing for Driver

2019-09-13 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: clang/include/clang/Driver/Phases.h:24
+Link,
+IfsMerge
   };

Trailing comma please



Comment at: clang/lib/Driver/Driver.cpp:3341
 llvm::SmallVector FullPL;
-types::getCompilationPhases(InputType, FullPL);
+types::getCompilationPhases(
+(Args.getLastArg(options::OPT_emit_iterface_stubs) ? types::TY_IFS

Bleh, this really should be something that we should be able to determine based 
on the input type.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3688
   .Case("experimental-ifs-v1", "experimental-ifs-v1")
-  .Default("");
+  .Default("experimental-ifs-v1");
 

cishida wrote:
> nit: no need to check `ArgStr` if all outcomes are the same 
Why have this switch and check below at all?  I think that it should just be an 
assertion that the string is equal to that value at the very most.  L3690-L3700 
is dead code.  Please remove, along with L3685-L3688.



Comment at: clang/lib/Driver/ToolChains/InterfaceStubs.cpp:15
+
+void tools::ifstool::Merger::ConstructJob(Compilation , const JobAction ,
+  const InputInfo ,

Why not:

```
namespace tools {
namespace ifstool {
```



Comment at: clang/lib/Driver/ToolChains/InterfaceStubs.cpp:26
+  else
+CmdArgs.push_back("write-bin");
+  CmdArgs.push_back("-o");

A ternary might be easier to read



Comment at: clang/lib/Driver/ToolChains/InterfaceStubs.cpp:29
+  CmdArgs.push_back(Output.getFilename());
+  for (auto Input : Inputs)
+CmdArgs.push_back(Input.getFilename());

`const auto `?



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1741
   .Case("experimental-ifs-v1", frontend::GenerateInterfaceIfsExpV1)
-  .Default(llvm::None);
+  .Default(frontend::GenerateInterfaceIfsExpV1);
   if (!ProgramAction) {

This seems entirely unnecessary, the default and case list is identical.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63978



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


[PATCH] D67425: [WebAssembly] Narrowing and widening SIMD ops

2019-09-13 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371906: [WebAssembly] Narrowing and widening SIMD ops 
(authored by tlively, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D67425?vs=219784=220189#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67425

Files:
  cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/builtins-wasm.c
  llvm/trunk/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/trunk/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/trunk/test/MC/WebAssembly/simd-encodings.s

Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -712,6 +712,42 @@
 defm "" : SIMDConvert;
 defm "" : SIMDConvert;
 
+// Widening operations
+multiclass SIMDWiden baseInst> {
+  defm "" : SIMDConvert;
+  defm "" : SIMDConvert;
+  defm "" : SIMDConvert;
+  defm "" : SIMDConvert;
+}
+
+defm "" : SIMDWiden;
+defm "" : SIMDWiden;
+
+// Narrowing operations
+multiclass SIMDNarrow baseInst> {
+  defm NARROW_S_#vec_t :
+SIMD_I<(outs V128:$dst), (ins V128:$low, V128:$high), (outs), (ins),
+   [(set (vec_t V128:$dst), (vec_t (int_wasm_narrow_signed
+ (arg_t V128:$low), (arg_t V128:$high],
+   vec#".narrow_"#arg#"_s\t$dst, $low, $high", vec#".narrow_"#arg#"_s",
+   baseInst>;
+  defm NARROW_U_#vec_t :
+SIMD_I<(outs V128:$dst), (ins V128:$low, V128:$high), (outs), (ins),
+   [(set (vec_t V128:$dst), (vec_t (int_wasm_narrow_unsigned
+ (arg_t V128:$low), (arg_t V128:$high],
+   vec#".narrow_"#arg#"_u\t$dst, $low, $high", vec#".narrow_"#arg#"_u",
+   !add(baseInst, 1)>;
+}
+
+defm "" : SIMDNarrow;
+defm "" : SIMDNarrow;
+
 // Lower llvm.wasm.trunc.saturate.* to saturating instructions
 def : Pat<(v4i32 (int_wasm_trunc_saturate_signed (v4f32 V128:$src))),
   (fp_to_sint_v4i32_v4f32 (v4f32 V128:$src))>;
Index: llvm/trunk/include/llvm/IR/IntrinsicsWebAssembly.td
===
--- llvm/trunk/include/llvm/IR/IntrinsicsWebAssembly.td
+++ llvm/trunk/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -117,6 +117,31 @@
   Intrinsic<[llvm_anyvector_ty],
 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
 [IntrNoMem, IntrSpeculatable]>;
+def int_wasm_narrow_signed :
+  Intrinsic<[llvm_anyvector_ty],
+[llvm_anyvector_ty, LLVMMatchType<1>],
+[IntrNoMem, IntrSpeculatable]>;
+def int_wasm_narrow_unsigned :
+  Intrinsic<[llvm_anyvector_ty],
+[llvm_anyvector_ty, LLVMMatchType<1>],
+[IntrNoMem, IntrSpeculatable]>;
+def int_wasm_widen_low_signed :
+  Intrinsic<[llvm_anyvector_ty],
+[llvm_anyvector_ty],
+[IntrNoMem, IntrSpeculatable]>;
+def int_wasm_widen_high_signed :
+  Intrinsic<[llvm_anyvector_ty],
+[llvm_anyvector_ty],
+[IntrNoMem, IntrSpeculatable]>;
+def int_wasm_widen_low_unsigned :
+  Intrinsic<[llvm_anyvector_ty],
+[llvm_anyvector_ty],
+[IntrNoMem, IntrSpeculatable]>;
+def int_wasm_widen_high_unsigned :
+  Intrinsic<[llvm_anyvector_ty],
+[llvm_anyvector_ty],
+[IntrNoMem, IntrSpeculatable]>;
+
 
 //===--===//
 // Bulk memory intrinsics
Index: llvm/trunk/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/trunk/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/trunk/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -87,6 +87,30 @@
   ret <16 x i8> %a
 }
 
+; CHECK-LABEL: narrow_signed_v16i8:
+; SIMD128-NEXT: .functype narrow_signed_v16i8 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: i8x16.narrow_i16x8_s $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <16 x i8> @llvm.wasm.narrow.signed.v16i8.v8i16(<8 x i16>, <8 x i16>)
+define <16 x i8> @narrow_signed_v16i8(<8 x i16> %low, <8 x i16> %high) {
+  %a = call <16 x i8> @llvm.wasm.narrow.signed.v16i8.v8i16(
+<8 x i16> %low, <8 x i16> %high
+  )
+  ret <16 x i8> %a
+}
+
+; CHECK-LABEL: narrow_unsigned_v16i8:
+; SIMD128-NEXT: .functype narrow_unsigned_v16i8 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: i8x16.narrow_i16x8_u $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <16 x i8> @llvm.wasm.narrow.unsigned.v16i8.v8i16(<8 x i16>, <8 x i16>)
+define <16 x i8> @narrow_unsigned_v16i8(<8 x i16> %low, <8 x i16> %high) {
+  %a = call <16 x i8> @llvm.wasm.narrow.unsigned.v16i8.v8i16(
+<8 x i16> %low, <8 x i16> %high
+  )
+  ret <16 x i8> 

r371906 - [WebAssembly] Narrowing and widening SIMD ops

2019-09-13 Thread Thomas Lively via cfe-commits
Author: tlively
Date: Fri Sep 13 15:54:41 2019
New Revision: 371906

URL: http://llvm.org/viewvc/llvm-project?rev=371906=rev
Log:
[WebAssembly] Narrowing and widening SIMD ops

Summary:
Implements target-specific LLVM intrinsics and clang builtins for
these new SIMD operations, as described at 
https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#integer-to-integer-narrowing.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, 
cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins-wasm.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def?rev=371906=371905=371906=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def Fri Sep 13 15:54:41 
2019
@@ -118,5 +118,19 @@ TARGET_BUILTIN(__builtin_wasm_trunc_satu
 TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i64x2_f64x2, "V2LLiV2d", "nc", 
"unimplemented-simd128")
 TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i64x2_f64x2, "V2LLiV2d", "nc", 
"unimplemented-simd128")
 
+TARGET_BUILTIN(__builtin_wasm_narrow_s_i8x16_i16x8, "V16cV8sV8s", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_narrow_u_i8x16_i16x8, "V16cV8sV8s", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_narrow_s_i16x8_i32x4, "V8sV4iV4i", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8sV4iV4i", "nc", 
"simd128")
+
+TARGET_BUILTIN(__builtin_wasm_widen_low_s_i16x8_i8x16, "V8sV16c", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_widen_high_s_i16x8_i8x16, "V8sV16c", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_widen_low_u_i16x8_i8x16, "V8sV16c", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_widen_high_u_i16x8_i8x16, "V8sV16c", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_widen_low_s_i32x4_i16x8, "V4iV8s", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_widen_high_s_i32x4_i16x8, "V4iV8s", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_widen_low_u_i32x4_i16x8, "V4iV8s", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_widen_high_u_i32x4_i16x8, "V4iV8s", "nc", 
"simd128")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=371906=371905=371906=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Sep 13 15:54:41 2019
@@ -14196,6 +14196,63 @@ Value *CodeGenFunction::EmitWebAssemblyB
 Function *Callee = CGM.getIntrinsic(IntNo, A->getType());
 return Builder.CreateCall(Callee, {A, B, C});
   }
+  case WebAssembly::BI__builtin_wasm_narrow_s_i8x16_i16x8:
+  case WebAssembly::BI__builtin_wasm_narrow_u_i8x16_i16x8:
+  case WebAssembly::BI__builtin_wasm_narrow_s_i16x8_i32x4:
+  case WebAssembly::BI__builtin_wasm_narrow_u_i16x8_i32x4: {
+Value *Low = EmitScalarExpr(E->getArg(0));
+Value *High = EmitScalarExpr(E->getArg(1));
+unsigned IntNo;
+switch (BuiltinID) {
+case WebAssembly::BI__builtin_wasm_narrow_s_i8x16_i16x8:
+case WebAssembly::BI__builtin_wasm_narrow_s_i16x8_i32x4:
+  IntNo = Intrinsic::wasm_narrow_signed;
+  break;
+case WebAssembly::BI__builtin_wasm_narrow_u_i8x16_i16x8:
+case WebAssembly::BI__builtin_wasm_narrow_u_i16x8_i32x4:
+  IntNo = Intrinsic::wasm_narrow_unsigned;
+  break;
+default:
+  llvm_unreachable("unexpected builtin ID");
+}
+Function *Callee =
+CGM.getIntrinsic(IntNo, {ConvertType(E->getType()), Low->getType()});
+return Builder.CreateCall(Callee, {Low, High});
+  }
+  case WebAssembly::BI__builtin_wasm_widen_low_s_i16x8_i8x16:
+  case WebAssembly::BI__builtin_wasm_widen_high_s_i16x8_i8x16:
+  case WebAssembly::BI__builtin_wasm_widen_low_u_i16x8_i8x16:
+  case WebAssembly::BI__builtin_wasm_widen_high_u_i16x8_i8x16:
+  case WebAssembly::BI__builtin_wasm_widen_low_s_i32x4_i16x8:
+  case WebAssembly::BI__builtin_wasm_widen_high_s_i32x4_i16x8:
+  case WebAssembly::BI__builtin_wasm_widen_low_u_i32x4_i16x8:
+  case WebAssembly::BI__builtin_wasm_widen_high_u_i32x4_i16x8: {
+Value *Vec = EmitScalarExpr(E->getArg(0));
+unsigned IntNo;
+switch (BuiltinID) {
+case WebAssembly::BI__builtin_wasm_widen_low_s_i16x8_i8x16:
+case WebAssembly::BI__builtin_wasm_widen_low_s_i32x4_i16x8:
+  IntNo = Intrinsic::wasm_widen_low_signed;
+  break;
+case WebAssembly::BI__builtin_wasm_widen_high_s_i16x8_i8x16:
+case WebAssembly::BI__builtin_wasm_widen_high_s_i32x4_i16x8:
+  IntNo = 

[PATCH] D67567: New ClangTidy check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-13 Thread Michael Wyman via Phabricator via cfe-commits
mwyman added a comment.

In D67567#1670035 , @lebedev.ri wrote:

> In D67567#1670017 , @mwyman wrote:
>
> > In D67567#1669866 , @lebedev.ri 
> > wrote:
> >
> > > 1. Please split each check into separate review.
> > > 2. Is `dispatch_once_t` OSX-specific thing? Should those checks be in 
> > > `osx` module?
> >
> >
> >
> >
> > 1. I split the review.
>
>
>
>
> > 2. I don't see an `osx` module—am I somehow missing seeing it?
>
> One can be added.
>
> > `dispatch_once_t` is something from `libdispatch`which is an Apple-created 
> > API, but is OSS and available outside Apple. It's also a C API, which is 
> > why I didn't feel `objc` was an appropriate module either. I'm open to a 
> > better home module for this check, it's just not clear to me where that 
> > might be.
>
> No opinion on my question, just thought it should be asked,


As Ben commented, I don't feel this should be in an `osx` module, as 
libdispatch is highly used on iOS and other Apple platforms. I know it's 
available elsewhere, but it may be so seldom used that I think a `darwin`module 
might be reasonable. I looked at the process for creating a new module, and can 
do that if we'd like, but should that be part of this same review?


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

https://reviews.llvm.org/D67567



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


[PATCH] D67249: [Modules][PCH] Hash input files content

2019-09-13 Thread Juergen Ributzka via Phabricator via cfe-commits
ributzka added a comment.

xxhash64 is apparently faster than MD5 and SHA1, and produces good quality 
hashes. I am not sure about the hash quality of hash_code for this purpose.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67249



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


[PATCH] D67578: New ClangTidy check to warn when writing to a dispatch_once_t variable.

2019-09-13 Thread Michael Wyman via Phabricator via cfe-commits
mwyman created this revision.
mwyman added reviewers: benhamilton, hokein, stephanemoore.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

Libdispatch documentation specifies that dispatch_once_ts must never have been 
non-zero, and assigning to them violates this.

Currently adding this to the `misc` module. Per discussion in 
https://reviews.llvm.org/D67567, perhaps this should be moved to a new, more 
specific module.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D67578

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/DispatchOnceAssignmentCheck.cpp
  clang-tools-extra/clang-tidy/misc/DispatchOnceAssignmentCheck.h
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-dispatch-once-assignment.rst
  clang-tools-extra/test/clang-tidy/misc-dispatch-once-assignment.cpp

Index: clang-tools-extra/test/clang-tidy/misc-dispatch-once-assignment.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/misc-dispatch-once-assignment.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s misc-dispatch-once-assignment %t
+
+typedef int dispatch_once_t;
+extern void dispatch_once(dispatch_once_t *pred, void(^block)(void));
+
+static dispatch_once_t onceToken;
+
+void DoOnce(void(^block)(void)) {
+  dispatch_once(, block);
+}
+
+void ResetOnce() {
+  onceToken = 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not assign to dispatch_once_t variables [misc-dispatch-once-assignment]
+}
Index: clang-tools-extra/docs/clang-tidy/checks/misc-dispatch-once-assignment.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/misc-dispatch-once-assignment.rst
@@ -0,0 +1,9 @@
+.. title:: clang-tidy - misc-dispatch-once-assignment
+
+misc-dispatch-once-assignment
+=
+
+Finds assignments to variables of type ``dispatch_once_t`` and warns to avoid
+assigning to them. Libdispatch intends that such writes should be guarded
+and making such direct writes may potentially violate the run-once protections
+intended by the library.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -278,6 +278,7 @@
llvm-prefer-register-over-unsigned
llvm-twine-local
misc-definitions-in-headers
+   misc-dispatch-once-assignment
misc-misplaced-const
misc-new-delete-overloads
misc-non-copyable-objects
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -73,6 +73,11 @@
   Finds instances where variables with static storage are initialized
   dynamically in header files.
 
+- New :doc:`misc-dispatch-once-assignment
+  ` check.
+
+  Finds instances of explicitly writing to ``dispatch_once_t`` variables.
+
 - New :doc:`linuxkernel-must-use-errs
   ` check.
 
Index: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "DefinitionsInHeadersCheck.h"
+#include "DispatchOnceAssignmentCheck.h"
 #include "MisplacedConstCheck.h"
 #include "NewDeleteOverloadsCheck.h"
 #include "NonCopyableObjects.h"
@@ -32,6 +33,8 @@
   void addCheckFactories(ClangTidyCheckFactories ) override {
 CheckFactories.registerCheck(
 "misc-definitions-in-headers");
+CheckFactories.registerCheck(
+"misc-dispatch-once-assignment");
 CheckFactories.registerCheck("misc-misplaced-const");
 CheckFactories.registerCheck(
 "misc-new-delete-overloads");
Index: clang-tools-extra/clang-tidy/misc/DispatchOnceAssignmentCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/misc/DispatchOnceAssignmentCheck.h
@@ -0,0 +1,36 @@
+//===--- DispatchOnceAssignmentCheck.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_MISC_DISPATCHONCEASSIGNMENTCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_DISPATCHONCEASSIGNMENTCHECK_H
+
+#include 

r371903 - [clang-scan-deps] Fix for headers having the same name as a directory

2019-09-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Sep 13 15:12:02 2019
New Revision: 371903

URL: http://llvm.org/viewvc/llvm-project?rev=371903=rev
Log:
[clang-scan-deps] Fix for headers having the same name as a directory

Scan deps tool crashes when called on a C++ file, containing an include
that has the same name as a directory.
The tool crashes since it finds foo/dir and tries to read that as a file and 
fails.

Patch by: kousikk (Kousik Kumar)

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

Added:
cfe/trunk/test/ClangScanDeps/Inputs/foodir
cfe/trunk/test/ClangScanDeps/Inputs/headerwithdirname.json
cfe/trunk/test/ClangScanDeps/headerwithdirname.cpp
Modified:

cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp

Modified: 
cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h?rev=371903=371902=371903=diff
==
--- 
cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
 (original)
+++ 
cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
 Fri Sep 13 15:12:02 2019
@@ -56,6 +56,9 @@ public:
   /// \returns True if the entry is valid.
   bool isValid() const { return !MaybeStat || MaybeStat->isStatusKnown(); }
 
+  /// \returns True if the current entry points to a directory.
+  bool isDirectory() const { return MaybeStat && MaybeStat->isDirectory(); }
+
   /// \returns The error or the file's contents.
   llvm::ErrorOr getContents() const {
 if (!MaybeStat)

Modified: 
cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp?rev=371903=371902=371903=diff
==
--- cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp 
(original)
+++ cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp 
Fri Sep 13 15:12:02 2019
@@ -193,6 +193,9 @@ private:
 llvm::ErrorOr>
 createFile(const CachedFileSystemEntry *Entry,
ExcludedPreprocessorDirectiveSkipMapping *PPSkipMappings) {
+  if (Entry->isDirectory())
+return llvm::ErrorOr>(
+std::make_error_code(std::errc::is_a_directory));
   llvm::ErrorOr Contents = Entry->getContents();
   if (!Contents)
 return Contents.getError();

Added: cfe/trunk/test/ClangScanDeps/Inputs/foodir
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/foodir?rev=371903=auto
==
--- cfe/trunk/test/ClangScanDeps/Inputs/foodir (added)
+++ cfe/trunk/test/ClangScanDeps/Inputs/foodir Fri Sep 13 15:12:02 2019
@@ -0,0 +1 @@
+// A C++ header with same name as that of a directory in the include path.

Added: cfe/trunk/test/ClangScanDeps/Inputs/headerwithdirname.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/headerwithdirname.json?rev=371903=auto
==
--- cfe/trunk/test/ClangScanDeps/Inputs/headerwithdirname.json (added)
+++ cfe/trunk/test/ClangScanDeps/Inputs/headerwithdirname.json Fri Sep 13 
15:12:02 2019
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -c -IDIR -IDIR/foodir -IInputs 
DIR/headerwithdirname_input.cpp",
+  "file": "DIR/headerwithdirname_input.cpp"
+}
+]

Added: cfe/trunk/test/ClangScanDeps/headerwithdirname.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/headerwithdirname.cpp?rev=371903=auto
==
--- cfe/trunk/test/ClangScanDeps/headerwithdirname.cpp (added)
+++ cfe/trunk/test/ClangScanDeps/headerwithdirname.cpp Fri Sep 13 15:12:02 2019
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.dir/foodir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir -p %t.dir/foodir
+// RUN: cp %s %t.dir/headerwithdirname_input.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/foodir %t.dir/Inputs/foodir
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/headerwithdirname.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s
+
+#include 
+
+// CHECK: headerwithdirname_input.o
+// CHECK-NEXT: headerwithdirname_input.cpp
+// CHECK-NEXT: Inputs{{/|\\}}foodir


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


r371904 - Make test check position independent as they sometimes come out reversed. NFCI.

2019-09-13 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Fri Sep 13 15:12:27 2019
New Revision: 371904

URL: http://llvm.org/viewvc/llvm-project?rev=371904=rev
Log:
Make test check position independent as they sometimes come out reversed. NFCI.

Modified:
cfe/trunk/test/Index/crash-recovery-modules.m

Modified: cfe/trunk/test/Index/crash-recovery-modules.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/crash-recovery-modules.m?rev=371904=371903=371904=diff
==
--- cfe/trunk/test/Index/crash-recovery-modules.m (original)
+++ cfe/trunk/test/Index/crash-recovery-modules.m Fri Sep 13 15:12:27 2019
@@ -31,5 +31,5 @@ void test() {
 // ...and with module building successful.
 // RUN: env CINDEXTEST_FAILONERROR=1 not c-index-test -test-load-source all 
-fmodules -fmodules-cache-path=%t -Xclang -fdisable-module-hash -I 
%S/Inputs/Headers -DLIBCLANG_CRASH %s > /dev/null 2> %t.err
 // RUN: FileCheck < %t.err -check-prefix=CHECK-LIBCLANG-CRASH %s
-// CHECK-LIBCLANG-CRASH: libclang: crash detected during parsing
-// CHECK-LIBCLANG-CRASH: Unable to load translation unit!
+// CHECK-LIBCLANG-CRASH-DAG: libclang: crash detected during parsing
+// CHECK-LIBCLANG-CRASH-DAG: Unable to load translation unit!


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


[PATCH] D67091: Fix for headers having the same name as a directory

2019-09-13 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371903: [clang-scan-deps] Fix for headers having the same 
name as a directory (authored by arphaman, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67091?vs=219976=220181#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67091

Files:
  
cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  cfe/trunk/test/ClangScanDeps/Inputs/foodir
  cfe/trunk/test/ClangScanDeps/Inputs/headerwithdirname.json
  cfe/trunk/test/ClangScanDeps/headerwithdirname.cpp


Index: cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -193,6 +193,9 @@
 llvm::ErrorOr>
 createFile(const CachedFileSystemEntry *Entry,
ExcludedPreprocessorDirectiveSkipMapping *PPSkipMappings) {
+  if (Entry->isDirectory())
+return llvm::ErrorOr>(
+std::make_error_code(std::errc::is_a_directory));
   llvm::ErrorOr Contents = Entry->getContents();
   if (!Contents)
 return Contents.getError();
Index: 
cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
===
--- 
cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ 
cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -56,6 +56,9 @@
   /// \returns True if the entry is valid.
   bool isValid() const { return !MaybeStat || MaybeStat->isStatusKnown(); }
 
+  /// \returns True if the current entry points to a directory.
+  bool isDirectory() const { return MaybeStat && MaybeStat->isDirectory(); }
+
   /// \returns The error or the file's contents.
   llvm::ErrorOr getContents() const {
 if (!MaybeStat)
Index: cfe/trunk/test/ClangScanDeps/headerwithdirname.cpp
===
--- cfe/trunk/test/ClangScanDeps/headerwithdirname.cpp
+++ cfe/trunk/test/ClangScanDeps/headerwithdirname.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.dir/foodir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir -p %t.dir/foodir
+// RUN: cp %s %t.dir/headerwithdirname_input.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/foodir %t.dir/Inputs/foodir
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/headerwithdirname.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s
+
+#include 
+
+// CHECK: headerwithdirname_input.o
+// CHECK-NEXT: headerwithdirname_input.cpp
+// CHECK-NEXT: Inputs{{/|\\}}foodir
Index: cfe/trunk/test/ClangScanDeps/Inputs/foodir
===
--- cfe/trunk/test/ClangScanDeps/Inputs/foodir
+++ cfe/trunk/test/ClangScanDeps/Inputs/foodir
@@ -0,0 +1 @@
+// A C++ header with same name as that of a directory in the include path.
Index: cfe/trunk/test/ClangScanDeps/Inputs/headerwithdirname.json
===
--- cfe/trunk/test/ClangScanDeps/Inputs/headerwithdirname.json
+++ cfe/trunk/test/ClangScanDeps/Inputs/headerwithdirname.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -c -IDIR -IDIR/foodir -IInputs 
DIR/headerwithdirname_input.cpp",
+  "file": "DIR/headerwithdirname_input.cpp"
+}
+]


Index: cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -193,6 +193,9 @@
 llvm::ErrorOr>
 createFile(const CachedFileSystemEntry *Entry,
ExcludedPreprocessorDirectiveSkipMapping *PPSkipMappings) {
+  if (Entry->isDirectory())
+return llvm::ErrorOr>(
+std::make_error_code(std::errc::is_a_directory));
   llvm::ErrorOr Contents = Entry->getContents();
   if (!Contents)
 return Contents.getError();
Index: cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
===
--- cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ cfe/trunk/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -56,6 +56,9 @@
   /// \returns True if the entry is valid.
   bool isValid() const { return !MaybeStat || MaybeStat->isStatusKnown(); }
 
+  /// \returns True if the current entry points to a 

[PATCH] D67573: Fix __atomic_is_lock_free's return type.

2019-09-13 Thread James Y Knight via Phabricator via cfe-commits
jyknight created this revision.
jyknight added a reviewer: rsmith.
Herald added subscribers: cfe-commits, jfb, kristof.beyls.
Herald added a project: clang.

It is specified to return a bool in GCC's documentation and
implementation, but the clang builtin says it returns an int. This
would be pretty much harmless, if it was just the builtin.

However, when clang translates the builtin into a libcall, it _also_
generates the libcall with an int return type, while the actual
library function in libatomic returns a bool.

This mismatch in return types results in an actual ABI mismatch and
thus incorrect results (interpreting false return value as true) on at
least x86_64.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67573

Files:
  clang/include/clang/Basic/Builtins.def
  clang/test/CodeGen/atomic-ops.c
  clang/test/CodeGen/big-atomic-ops.c


Index: clang/test/CodeGen/big-atomic-ops.c
===
--- clang/test/CodeGen/big-atomic-ops.c
+++ clang/test/CodeGen/big-atomic-ops.c
@@ -198,20 +198,20 @@
 int lock_free(struct Incomplete *incomplete) {
   // CHECK: @lock_free
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 3, i8* null)
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 3, i8* null)
   __c11_atomic_is_lock_free(3);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 16, i8* {{.*}}@sixteen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 16, i8* 
{{.*}}@sixteen{{.*}})
   __atomic_is_lock_free(16, );
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 17, i8* {{.*}}@seventeen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 17, i8* 
{{.*}}@seventeen{{.*}})
   __atomic_is_lock_free(17, );
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 4, {{.*}})
   __atomic_is_lock_free(4, incomplete);
 
   char cs[20];
-  // CHECK: call i32 @__atomic_is_lock_free(i64 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 4, {{.*}})
   __atomic_is_lock_free(4, cs+1);
 
   // CHECK-NOT: call
Index: clang/test/CodeGen/atomic-ops.c
===
--- clang/test/CodeGen/atomic-ops.c
+++ clang/test/CodeGen/atomic-ops.c
@@ -343,20 +343,20 @@
 int lock_free(struct Incomplete *incomplete) {
   // CHECK-LABEL: @lock_free
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 3, i8* null)
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 3, i8* null)
   __c11_atomic_is_lock_free(3);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 16, i8* {{.*}}@sixteen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 16, i8* 
{{.*}}@sixteen{{.*}})
   __atomic_is_lock_free(16, );
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 17, i8* {{.*}}@seventeen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 17, i8* 
{{.*}}@seventeen{{.*}})
   __atomic_is_lock_free(17, );
 
-  // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 4, {{.*}})
   __atomic_is_lock_free(4, incomplete);
 
   char cs[20];
-  // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i32 4, {{.*}})
   __atomic_is_lock_free(4, cs+1);
 
   // CHECK-NOT: call
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -720,7 +720,7 @@
 ATOMIC_BUILTIN(__c11_atomic_fetch_xor, "v.", "t")
 BUILTIN(__c11_atomic_thread_fence, "vi", "n")
 BUILTIN(__c11_atomic_signal_fence, "vi", "n")
-BUILTIN(__c11_atomic_is_lock_free, "iz", "n")
+BUILTIN(__c11_atomic_is_lock_free, "bz", "n")
 
 // GNU atomic builtins.
 ATOMIC_BUILTIN(__atomic_load, "v.", "t")
@@ -748,7 +748,7 @@
 BUILTIN(__atomic_thread_fence, "vi", "n")
 BUILTIN(__atomic_signal_fence, "vi", "n")
 BUILTIN(__atomic_always_lock_free, "izvCD*", "n")
-BUILTIN(__atomic_is_lock_free, "izvCD*", "n")
+BUILTIN(__atomic_is_lock_free, "bzvCD*", "n")
 
 // OpenCL 2.0 atomic builtins.
 ATOMIC_BUILTIN(__opencl_atomic_init, "v.", "t")


Index: clang/test/CodeGen/big-atomic-ops.c
===
--- clang/test/CodeGen/big-atomic-ops.c
+++ clang/test/CodeGen/big-atomic-ops.c
@@ -198,20 +198,20 @@
 int lock_free(struct Incomplete *incomplete) {
   // CHECK: @lock_free
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 3, i8* null)
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 3, i8* null)
   __c11_atomic_is_lock_free(3);
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 16, i8* {{.*}}@sixteen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 16, i8* {{.*}}@sixteen{{.*}})
   __atomic_is_lock_free(16, );
 
-  // CHECK: call i32 @__atomic_is_lock_free(i64 17, i8* {{.*}}@seventeen{{.*}})
+  // CHECK: call zeroext i1 @__atomic_is_lock_free(i64 17, i8* 

[PATCH] D67567: New ClangTidy check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-13 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

It definitely shouldn't be in an `osx` directory since it's available on iOS 
and other Darwin-like operating systems.

Probably `darwin` would be OK. Adding a new subdirectory isn't trivial, there's 
a lot of places to update last I looked.

Should we tackle moving things around in a separate diff?


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

https://reviews.llvm.org/D67567



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


[PATCH] D67567: New ClangTidy check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D67567#1670017 , @mwyman wrote:

> In D67567#1669866 , @lebedev.ri 
> wrote:
>
> > 1. Please split each check into separate review.
> > 2. Is `dispatch_once_t` OSX-specific thing? Should those checks be in `osx` 
> > module?
>
>
>
>
> 1. I split the review.




> 2. I don't see an `osx` module—am I somehow missing seeing it?

One can be added.

> `dispatch_once_t` is something from `libdispatch`which is an Apple-created 
> API, but is OSS and available outside Apple. It's also a C API, which is why 
> I didn't feel `objc` was an appropriate module either. I'm open to a better 
> home module for this check, it's just not clear to me where that might be.

No opinion on my question, just thought it should be asked,


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

https://reviews.llvm.org/D67567



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


[PATCH] D67567: New ClangTidy check to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-13 Thread Michael Wyman via Phabricator via cfe-commits
mwyman added a comment.

In D67567#1669866 , @lebedev.ri wrote:

> 1. Please split each check into separate review.
> 2. Is `dispatch_once_t` OSX-specific thing? Should those checks be in `osx` 
> module?




1. I split the review.
2. I don't see an `osx` module—am I somehow missing seeing it? 
`dispatch_once_t` is something from `libdispatch`which is an Apple-created API, 
but is OSS and available outside Apple. It's also a C API, which is why I 
didn't feel `objc` was an appropriate module either. I'm open to a better home 
module for this check, it's just not clear to me where that might be.


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

https://reviews.llvm.org/D67567



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


[PATCH] D67567: New ClangTidy checks to warn when storing dispatch_once_t in non-static, non-global storage

2019-09-13 Thread Michael Wyman via Phabricator via cfe-commits
mwyman updated this revision to Diff 220169.
mwyman retitled this revision from "New ClangTidy checks to warn about misusing 
dispatch_once_t" to "New ClangTidy checks to warn when storing dispatch_once_t 
in non-static, non-global storage".
mwyman added a comment.

Moved the assignment check to a separate review.


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

https://reviews.llvm.org/D67567

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/DispatchOnceNonstaticCheck.cpp
  clang-tools-extra/clang-tidy/misc/DispatchOnceNonstaticCheck.h
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-dispatch-once-nonstatic.rst
  clang-tools-extra/test/clang-tidy/misc-dispatch-once-nonstatic.mm

Index: clang-tools-extra/test/clang-tidy/misc-dispatch-once-nonstatic.mm
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/misc-dispatch-once-nonstatic.mm
@@ -0,0 +1,47 @@
+// RUN: %check_clang_tidy %s misc-dispatch-once-nonstatic %t
+
+typedef int dispatch_once_t;
+extern void dispatch_once(dispatch_once_t *pred, void(^block)(void));
+
+
+void bad_dispatch_once(dispatch_once_t once, void(^block)(void)) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: dispatch_once_ts must have static or global storage duration; function parameters should be pointer references [misc-dispatch-once-nonstatic]
+
+// file-scope dispatch_once_ts have static storage duration.
+dispatch_once_t global_once;
+static dispatch_once_t file_static_once;
+namespace {
+dispatch_once_t anonymous_once;
+} // end anonymous namespace
+
+int Correct(void) {
+  static int value;
+  static dispatch_once_t once;
+  dispatch_once(, ^{
+value = 1;
+  });
+  return value;
+}
+
+int Incorrect(void) {
+  static int value;
+  dispatch_once_t once;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: dispatch_once_t variables must have static or global storage duration [misc-dispatch-once-nonstatic]
+  // CHECK-FIXES: static dispatch_once_t once;
+  dispatch_once(, ^{
+value = 1;
+  });
+  return value;
+}
+
+struct OnceStruct {
+  static dispatch_once_t staticOnce; // Allowed
+  int value;
+  dispatch_once_t once;  // Allowed (at this time)
+};
+
+@interface MyObject {
+  dispatch_once_t _once;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: dispatch_once_t variables must have static or global storage duration and cannot be Objective-C instance variables [misc-dispatch-once-nonstatic]
+}
+@end
Index: clang-tools-extra/docs/clang-tidy/checks/misc-dispatch-once-nonstatic.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/misc-dispatch-once-nonstatic.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - misc-dispatch-once-nonstatic
+
+misc-dispatch-once-nonstatic
+
+
+Finds declarations of ``dispatch_once_t`` variables without static or global
+storage. The behavior of using ``dispatch_once_t`` predicates with automatic
+or dynamic storage is undefined by libdispatch, and should be avoided.
+
+It is a common paradigm to have functions initialize internal static or global
+data once when the function runs, but programmers have been known to miss the
+static on the ``dispatch_once_t`` predicate, leading to an uninitialized flag
+value at the mercy of the stack.
+
+Programmers have also been known to make ``dispatch_once_t``s be members of
+structs/classes, with the intent to lazily perform some expensive struct or
+class member initialization only once; however, this violates the libdispatch
+requirements.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -278,6 +278,7 @@
llvm-prefer-register-over-unsigned
llvm-twine-local
misc-definitions-in-headers
+   misc-dispatch-once-nonstatic
misc-misplaced-const
misc-new-delete-overloads
misc-non-copyable-objects
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -73,6 +73,12 @@
   Finds instances where variables with static storage are initialized
   dynamically in header files.
 
+- New :doc:`misc-dispatch-once-nonstatic
+  ` check.
+
+  Finds instances of ``dispatch_once_t`` variables not having static or global
+  storage.
+
 - New :doc:`linuxkernel-must-use-errs
   ` check.
 
Index: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
+++ 

r371897 - Fix test to use %t for newly created files.

2019-09-13 Thread Tim Shen via cfe-commits
Author: timshen
Date: Fri Sep 13 14:06:47 2019
New Revision: 371897

URL: http://llvm.org/viewvc/llvm-project?rev=371897=rev
Log:
Fix test to use %t for newly created files.

This is both for consistency with other `mkdir`s in tests, and
fixing permission issues with the non-temporary cwd during testing (they
are not always writable).

Modified:
cfe/trunk/test/Driver/metadata-with-dots.c

Modified: cfe/trunk/test/Driver/metadata-with-dots.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/metadata-with-dots.c?rev=371897=371896=371897=diff
==
--- cfe/trunk/test/Driver/metadata-with-dots.c (original)
+++ cfe/trunk/test/Driver/metadata-with-dots.c Fri Sep 13 14:06:47 2019
@@ -1,10 +1,10 @@
 // REQUIRES: shell
-// RUN: mkdir -p out.dir
-// RUN: cat %s > out.dir/test.c
-// RUN: %clang -E -MMD %s -o out.dir/test
+// RUN: mkdir -p %t/out.dir
+// RUN: cat %s > %t/out.dir/test.c
+// RUN: %clang -E -MMD %s -o %t/out.dir/test
 // RUN: test ! -f %out.d
-// RUN: test -f out.dir/test.d
-// RUN: rm -rf out.dir/test.d out.dir/ out.d
+// RUN: test -f %t/out.dir/test.d
+// RUN: rm -rf %t/out.dir/test.d %t/out.dir/ out.d
 int main (void)
 {
 return 0;


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


[PATCH] D67559: [Sema] Split of versions of -Wimplicit-{float,int}-conversion for Objective-C BOOL

2019-09-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Mostly LGTM but a few nits.




Comment at: clang/include/clang/Basic/DiagnosticGroups.td:65
+def ObjCSignedCharBoolImplicitIntConversion :
+  DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
+def ImplicitIntConversion : DiagGroup<"implicit-int-conversion",

This makes me wish that all shells would support autocomplete of program 
options. :-D



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3312
+def warn_impcast_float_to_objc_signed_char_bool : Warning<
+  "implicit conversion from floating-point type %0 to BOOL">,
+  InGroup;

Can you put single quotes around `BOOL` since it's a type name? Same below.



Comment at: clang/lib/AST/Expr.cpp:191
+
+  if (auto *OVE = dyn_cast(E))
+return OVE->getSourceExpr()->isKnownToHaveBooleanValue();

`const auto *` ?



Comment at: clang/test/SemaObjC/signed-char-bool-conversion.m:3
+// RUN: %clang_cc1 -xobjective-c++ %s -verify -Wobjc-signed-char-bool
+
+typedef signed char BOOL;

Can you add a test verifying the fix-it behaviors (with and without parens)?


Repository:
  rC Clang

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

https://reviews.llvm.org/D67559



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


r371892 - [OPENMP5.0]Add basic support for declare variant directive.

2019-09-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Sep 13 13:18:17 2019
New Revision: 371892

URL: http://llvm.org/viewvc/llvm-project?rev=371892=rev
Log:
[OPENMP5.0]Add basic support for declare variant directive.

Added basic support for declare variant directive and its match clause
with user context selector.

Added:
cfe/trunk/test/OpenMP/declare_variant_messages.c
cfe/trunk/test/OpenMP/declare_variant_messages.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=371892=371891=371892=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Sep 13 13:18:17 
2019
@@ -201,6 +201,7 @@ def err_invalid_token_after_declarator_s
   "invalid %0 at end of declaration; did you mean '='?">;
 def err_expected_statement : Error<"expected statement">;
 def err_expected_lparen_after : Error<"expected '(' after '%0'">;
+def err_expected_lbrace_after : Error<"expected '{' after '%0'">;
 def err_expected_rparen_after : Error<"expected ')' after '%0'">;
 def err_expected_punc : Error<"expected ')' or ',' after '%0'">;
 def err_expected_less_after : Error<"expected '<' after '%0'">;
@@ -1177,8 +1178,8 @@ def err_omp_expected_identifier_for_crit
   "expected identifier specifying the name of the 'omp critical' directive">;
 def err_omp_expected_reduction_identifier : Error<
   "expected identifier or one of the following operators: '+', '-', '*', '&', 
'|', '^', '&&', or '||'">;
-def err_omp_decl_in_declare_simd : Error<
-  "function declaration is expected after 'declare simd' directive">;
+def err_omp_decl_in_declare_simd_variant : Error<
+  "function declaration is expected after 'declare %select{simd|variant}0' 
directive">;
 def err_omp_unknown_map_type : Error<
   "incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 
'release', or 'delete'">;
 def err_omp_unknown_map_type_modifier : Error<
@@ -1199,6 +1200,12 @@ def err_omp_mapper_illegal_identifier :
   "illegal OpenMP user-defined mapper identifier">;
 def err_omp_mapper_expected_declarator : Error<
   "expected declarator on 'omp declare mapper' directive">;
+def err_omp_declare_variant_wrong_clause : Error<
+  "expected '%0' clause on 'omp declare variant' directive">;
+def err_omp_declare_variant_no_ctx_selector : Error<
+  "expected context selector in '%0' clause on 'omp declare variant' 
directive">;
+def err_omp_declare_variant_equal_expected : Error<
+  "expected '=' after '%0' context selector set name on 'omp declare variant' 
directive">;
 def warn_omp_more_one_device_type_clause : Warning<
   "more than one 'device_type' clause is specified">,
   InGroup;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=371892=371891=371892=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Sep 13 13:18:17 
2019
@@ -9213,10 +9213,10 @@ def err_omp_single_copyprivate_with_nowa
   "the 'copyprivate' clause must not be used with the 'nowait' clause">;
 def note_omp_nowait_clause_here : Note<
   "'nowait' clause is here">;
-def err_omp_single_decl_in_declare_simd : Error<
-  "single declaration is expected after 'declare simd' directive">;
+def err_omp_single_decl_in_declare_simd_variant : Error<
+  "single declaration is expected after 'declare %select{simd|variant}0' 
directive">;
 def err_omp_function_expected : Error<
-  "'#pragma omp declare simd' can only be applied to functions">;
+  "'#pragma omp declare %select{simd|variant}0' can only be applied to 
functions">;
 def err_omp_wrong_cancel_region : Error<
   "one of 'for', 'parallel', 'sections' or 'taskgroup' is expected">;
 def err_omp_parent_cancel_region_nowait : Error<
@@ -9408,6 +9408,27 @@ def note_omp_marked_device_type_here : N
 def warn_omp_declare_target_after_first_use : Warning<
   "declaration marked as declare target after first use, it may lead to 
incorrect results">,
   InGroup;
+def err_omp_declare_variant_incompat_attributes : Error<
+  "'#pragma omp declare variant' is not compatible with any target-specific 
attributes">;
+def 

[PATCH] D67509: [CUDA][HIP] Diagnose defaulted constructor only if it is used

2019-09-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Sorry I found some issue with the fix.

The following code:

  struct A {  virtual ~A(); };
  struct B: public A { B(); };
  B::B() = default;

will cause B::B() with external linkage emitted in IR, since `B::B() = 
default;` is a function definition.

This somehow defeats the intention not to emit B::B() in device code if its 
base class has virtual member function.

On the other hand, if we remove `B::B() = default;` from the above code, B::B() 
will become a `__host__` function.

I think host/device property of `B::B()` should be determined at declaration 
and should not be changed by its definition.

In the above example, it should always be a `__host__` function and should not 
be emitted in device code.


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

https://reviews.llvm.org/D67509



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


[PATCH] D66982: [Modules][Objective-C] Use complete decl from module when diagnosing missing import

2019-09-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66982



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


[clang-tools-extra] r371890 - [Support] Add overload writeFileAtomically(std::function Writer)

2019-09-13 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Fri Sep 13 13:08:27 2019
New Revision: 371890

URL: http://llvm.org/viewvc/llvm-project?rev=371890=rev
Log:
[Support] Add overload writeFileAtomically(std::function Writer)

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

Modified:
clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp

Modified: clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp?rev=371890=371889=371890=diff
==
--- clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp Fri Sep 13 
13:08:27 2019
@@ -18,6 +18,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include 
@@ -35,34 +36,6 @@ std::string getShardPathFromFilePath(llv
   return ShardRootSS.str();
 }
 
-llvm::Error
-writeAtomically(llvm::StringRef OutPath,
-llvm::function_ref Writer) {
-  // Write to a temporary file first.
-  llvm::SmallString<128> TempPath;
-  int FD;
-  auto EC =
-  llvm::sys::fs::createUniqueFile(OutPath + ".tmp.", FD, TempPath);
-  if (EC)
-return llvm::errorCodeToError(EC);
-  // Make sure temp file is destroyed on failure.
-  auto RemoveOnFail =
-  llvm::make_scope_exit([TempPath] { llvm::sys::fs::remove(TempPath); });
-  llvm::raw_fd_ostream OS(FD, /*shouldClose=*/true);
-  Writer(OS);
-  OS.close();
-  if (OS.has_error())
-return llvm::errorCodeToError(OS.error());
-  // Then move to real location.
-  EC = llvm::sys::fs::rename(TempPath, OutPath);
-  if (EC)
-return llvm::errorCodeToError(EC);
-  // If everything went well, we already moved the file to another name. So
-  // don't delete the file, as the name might be taken by another file.
-  RemoveOnFail.release();
-  return llvm::ErrorSuccess();
-}
-
 // Uses disk as a storage for index shards. Creates a directory called
 // ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
@@ -100,9 +73,12 @@ public:
 
   llvm::Error storeShard(llvm::StringRef ShardIdentifier,
  IndexFileOut Shard) const override {
-return writeAtomically(
-getShardPathFromFilePath(DiskShardRoot, ShardIdentifier),
-[](llvm::raw_ostream ) { OS << Shard; });
+auto ShardPath = getShardPathFromFilePath(DiskShardRoot, ShardIdentifier);
+return llvm::writeFileAtomically(ShardPath + ".tmp.", ShardPath,
+ [](llvm::raw_ostream ) {
+   OS << Shard;
+   return llvm::Error::success();
+ });
   }
 };
 


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


r371890 - [Support] Add overload writeFileAtomically(std::function Writer)

2019-09-13 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Fri Sep 13 13:08:27 2019
New Revision: 371890

URL: http://llvm.org/viewvc/llvm-project?rev=371890=rev
Log:
[Support] Add overload writeFileAtomically(std::function Writer)

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

Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=371890=371889=371890=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Fri Sep 13 13:08:27 2019
@@ -84,6 +84,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -2301,26 +2302,19 @@ bool ASTUnit::Save(StringRef File) {
   SmallString<128> TempPath;
   TempPath = File;
   TempPath += "-";
-  int fd;
-  if (llvm::sys::fs::createUniqueFile(TempPath, fd, TempPath))
-return true;
-
   // FIXME: Can we somehow regenerate the stat cache here, or do we need to
   // unconditionally create a stat cache when we parse the file?
-  llvm::raw_fd_ostream Out(fd, /*shouldClose=*/true);
-
-  serialize(Out);
-  Out.close();
-  if (Out.has_error()) {
-Out.clear_error();
-return true;
-  }
 
-  if (llvm::sys::fs::rename(TempPath, File)) {
-llvm::sys::fs::remove(TempPath);
+  if (llvm::Error Err = llvm::writeFileAtomically(
+  TempPath, File, [this](llvm::raw_ostream ) {
+return serialize(Out) ? llvm::make_error(
+"ASTUnit serialization failed",
+llvm::inconvertibleErrorCode())
+  : llvm::Error::success();
+  })) {
+consumeError(std::move(Err));
 return true;
   }
-
   return false;
 }
 

Modified: cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp?rev=371890=371889=371890=diff
==
--- cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp (original)
+++ cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp Fri Sep 13 13:08:27 2019
@@ -10,7 +10,6 @@
 //
 
//===--===//
 
-
 #include "ASTReaderInternals.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Lex/HeaderSearch.h"
@@ -21,10 +20,12 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Bitstream/BitstreamReader.h"
 #include "llvm/Bitstream/BitstreamWriter.h"
 #include "llvm/Support/DJB.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/LockFileManager.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/OnDiskHashTable.h"
@@ -912,37 +913,9 @@ GlobalModuleIndex::writeIndex(FileManage
  "failed writing index");
   }
 
-  // Write the global index file to a temporary file.
-  llvm::SmallString<128> IndexTmpPath;
-  int TmpFD;
-  if (llvm::sys::fs::createUniqueFile(IndexPath + "-", TmpFD,
-  IndexTmpPath))
-return llvm::createStringError(std::errc::io_error,
-   "failed creating unique file");
-
-  // Open the temporary global index file for output.
-  llvm::raw_fd_ostream Out(TmpFD, true);
-  if (Out.has_error())
-return llvm::createStringError(Out.error(), "failed outputting to stream");
-
-  // Write the index.
-  Out.write(OutputBuffer.data(), OutputBuffer.size());
-  Out.close();
-  if (Out.has_error())
-return llvm::createStringError(Out.error(), "failed writing to stream");
-
-  // Remove the old index file. It isn't relevant any more.
-  llvm::sys::fs::remove(IndexPath);
-
-  // Rename the newly-written index file to the proper name.
-  if (std::error_code Err = llvm::sys::fs::rename(IndexTmpPath, IndexPath)) {
-// Remove the file on failure, don't check whether removal succeeded.
-llvm::sys::fs::remove(IndexTmpPath);
-return llvm::createStringError(Err, "failed renaming file \"%s\" to 
\"%s\"",
-   IndexTmpPath.c_str(), IndexPath.c_str());
-  }
-
-  return llvm::Error::success();
+  return llvm::writeFileAtomically(
+  (IndexPath + "-").str(), IndexPath,
+  llvm::StringRef(OutputBuffer.data(), OutputBuffer.size()));
 }
 
 namespace {


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


[PATCH] D67091: Fix for headers having the same name as a directory

2019-09-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Sure, I can do that today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67091



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


[PATCH] D67091: Fix for headers having the same name as a directory

2019-09-13 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk added a comment.

I don't have commit access - do you mind submitting this for me? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67091



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


[PATCH] D67399: [ARM] Follow AACPS standard for volatile bitfields

2019-09-13 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D67399#1669568 , @jfb wrote:

> In D67399#1669038 , @dnsampaio wrote:
>
> > Indeed our main concern is regarding the access widths of loads. As 
> > mentioned by @rjmccall, most volatile bitfields are used to perform memory 
> > mapped I/O, and some hardware only support them with a specific access 
> > width.
> >  The spurious load I am more than glad to leave it disable behind a command 
> > flag, so it will only appear if the user requests it. See that volatile 
> > accesses might have side effects, and for example, an I/O read counter 
> > holding an odd number could define that the data is still being processed.
>
>
> Are the cases being addressed in the PR actually relevant to real MMIO, or is 
> this patch following the letter of AAPCS which doesn't actually matter?


Again, I think AAPCS is well within its rights to say that certain volatile 
accesses should be performed with loads and stores of certain widths.  If 
low-level programmers cannot use bit-fields today with memory-mapped I/O 
because they cannot trust compilers to produce reasonable accesses, that is a 
legitimate concern for ABI authors and a legitimate bug for compiler 
maintainers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67399



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


[PATCH] D67249: [Modules][PCH] Hash input files content

2019-09-13 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.



> Did you try xxHash64?

No, and I'm not planning to. I believe `hash_code` is enough here, already has 
low overhead on performance and size, and bunch of prior use elsewhere in 
LLVM/Clang. If there's a strong reason to do it I wanna know why that's the 
case first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67249



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


[PATCH] D66982: [Modules][Objective-C] Use complete decl from module when diagnosing missing import

2019-09-13 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Ping!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66982



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


[PATCH] D67091: Fix for headers having the same name as a directory

2019-09-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman 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/D67091/new/

https://reviews.llvm.org/D67091



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


[PATCH] D67567: New ClangTidy checks to warn about misusing dispatch_once_t

2019-09-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

1. Please split each check into separate review.
2. Is `dispatch_once_t` OSX-specific thing? Should those checks be in `osx` 
module?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D67567



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


[PATCH] D67567: New ClangTidy checks to warn about misusing dispatch_once_t

2019-09-13 Thread Michael Wyman via Phabricator via cfe-commits
mwyman created this revision.
mwyman added reviewers: benhamilton, hokein, stephanemoore.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

Adds two new ClangTidy checks:

- misc-dispatch-once-assignment: warns about assignment to a dispatch_once_t 
variable. In code reviews I've encountered enough attempts to "reset" a 
dispatch_once.
- misc-dispatch-once-nonstatic: warns about dispatch_once_t variables not in 
static or global storage. This catches a missing static for local variables in 
e.g. singleton initialization behavior, and also warns on storing 
dispatch_once_t values in Objective-C instance variables. C/C++ struct/class 
instances may potentially live in static/global storage, and are ignored for 
this check.

The osx.API static analysis checker can find the non-static storage use of 
dispatch_once_t; I thought it useful to also catch these issues in clang-tidy 
when possible.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D67567

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/DispatchOnceAssignmentCheck.cpp
  clang-tools-extra/clang-tidy/misc/DispatchOnceAssignmentCheck.h
  clang-tools-extra/clang-tidy/misc/DispatchOnceNonstaticCheck.cpp
  clang-tools-extra/clang-tidy/misc/DispatchOnceNonstaticCheck.h
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-dispatch-once-assignment.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-dispatch-once-nonstatic.rst
  clang-tools-extra/test/clang-tidy/misc-dispatch-once-assignment.cpp
  clang-tools-extra/test/clang-tidy/misc-dispatch-once-nonstatic.mm

Index: clang-tools-extra/test/clang-tidy/misc-dispatch-once-nonstatic.mm
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/misc-dispatch-once-nonstatic.mm
@@ -0,0 +1,47 @@
+// RUN: %check_clang_tidy %s misc-dispatch-once-nonstatic %t
+
+typedef int dispatch_once_t;
+extern void dispatch_once(dispatch_once_t *pred, void(^block)(void));
+
+
+void bad_dispatch_once(dispatch_once_t once, void(^block)(void)) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: dispatch_once_ts must have static or global storage duration; function parameters should be pointer references [misc-dispatch-once-nonstatic]
+
+// file-scope dispatch_once_ts have static storage duration.
+dispatch_once_t global_once;
+static dispatch_once_t file_static_once;
+namespace {
+dispatch_once_t anonymous_once;
+} // end anonymous namespace
+
+int Correct(void) {
+  static int value;
+  static dispatch_once_t once;
+  dispatch_once(, ^{
+value = 1;
+  });
+  return value;
+}
+
+int Incorrect(void) {
+  static int value;
+  dispatch_once_t once;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: dispatch_once_t variables must have static or global storage duration [misc-dispatch-once-nonstatic]
+  // CHECK-FIXES: static dispatch_once_t once;
+  dispatch_once(, ^{
+value = 1;
+  });
+  return value;
+}
+
+struct OnceStruct {
+  static dispatch_once_t staticOnce; // Allowed
+  int value;
+  dispatch_once_t once;  // Allowed (at this time)
+};
+
+@interface MyObject {
+  dispatch_once_t _once;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: dispatch_once_t variables must have static or global storage duration and cannot be Objective-C instance variables [misc-dispatch-once-nonstatic]
+}
+@end
Index: clang-tools-extra/test/clang-tidy/misc-dispatch-once-assignment.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/misc-dispatch-once-assignment.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s misc-dispatch-once-assignment %t
+
+typedef int dispatch_once_t;
+extern void dispatch_once(dispatch_once_t *pred, void(^block)(void));
+
+static dispatch_once_t onceToken;
+
+void DoOnce(void(^block)(void)) {
+  dispatch_once(, block);
+}
+
+void ResetOnce() {
+  onceToken = 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not assign to dispatch_once_t variables [misc-dispatch-once-assignment]
+}
Index: clang-tools-extra/docs/clang-tidy/checks/misc-dispatch-once-nonstatic.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/misc-dispatch-once-nonstatic.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - misc-dispatch-once-nonstatic
+
+misc-dispatch-once-nonstatic
+
+
+Finds declarations of ``dispatch_once_t`` variables without static or global
+storage. The behavior of using ``dispatch_once_t`` predicates with automatic
+or dynamic storage is undefined by libdispatch, and should be avoided.
+
+It is a common paradigm to have functions initialize internal static or global
+data once when the function runs, but programmers have been known to miss the
+static on the ``dispatch_once_t`` 

[PATCH] D67135: [clang-tidy] performance-inefficient-vector-operation: Support proto repeated field

2019-09-13 Thread Cong Liu via Phabricator via cfe-commits
congliu added a comment.

Could someone commit this for me? I failed to commit this change...


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

https://reviews.llvm.org/D67135



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


[PATCH] D67368: [NFCI]Create CommonAttributeInfo Type as base type of *Attr and ParsedAttr.

2019-09-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D67368#1669818 , @plotfi wrote:

> I think this change might be breaking builds: 
> http://lab.llvm.org:8011/builders/clang-aarch64-linux-build-cache/builds/16888


Yep! I fixed it in r371876.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67368



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


[PATCH] D67368: [NFCI]Create CommonAttributeInfo Type as base type of *Attr and ParsedAttr.

2019-09-13 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

I think this change might be breaking builds: 
http://lab.llvm.org:8011/builders/clang-aarch64-linux-build-cache/builds/16888


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67368



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


[PATCH] D67368: [NFCI]Create CommonAttributeInfo Type as base type of *Attr and ParsedAttr.

2019-09-13 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

I think this change might be breaking builds:


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67368



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


r371878 - Reland r371785: Add -Wpoison-system-directories warning

2019-09-13 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Fri Sep 13 11:00:51 2019
New Revision: 371878

URL: http://llvm.org/viewvc/llvm-project?rev=371878=rev
Log:
Reland r371785: Add -Wpoison-system-directories warning

When using clang as a cross-compiler, we should not use system
headers to do the compilation.
This CL adds support of a new warning flag -Wpoison-system-directories which
emits warnings if --sysroot is set and headers from common host system location
are used.
By default the warning is disabled.

The intention of the warning is to catch bad includes which are usually
generated by third party build system not targeting cross-compilation.
Such cases happen in Chrome OS when someone imports a new package or upgrade
one to a newer version from upstream.

This is reland of r371785 with a fix to test file.

Patch by: denik (Denis Nikitin)

Added:
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/.keep
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c++/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c++/.keep
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/.keep
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/include/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/include/.keep

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/lib/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/lib/.keep
cfe/trunk/test/Frontend/warning-poison-system-directories.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=371878=371877=371878=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Fri Sep 13 11:00:51 
2019
@@ -315,4 +315,9 @@ def err_unknown_analyzer_checker_or_pack
 "no analyzer checkers or packages are associated with '%0'">;
 def note_suggest_disabling_all_checkers : Note<
 "use -analyzer-disable-all-checks to disable all static analyzer 
checkers">;
+
+// Poison system directories.
+def warn_poison_system_directories : Warning <
+  "include location '%0' is unsafe for cross-compilation">,
+  InGroup>, DefaultIgnore;
 }

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=371878=371877=371878=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Fri Sep 13 11:00:51 2019
@@ -137,6 +137,13 @@ bool InitHeaderSearch::AddUnmappedPath(c
   SmallString<256> MappedPathStorage;
   StringRef MappedPathStr = Path.toStringRef(MappedPathStorage);
 
+  // If use system headers while cross-compiling, emit the warning.
+  if (HasSysroot && (MappedPathStr.startswith("/usr/include") ||
+ MappedPathStr.startswith("/usr/local/include"))) {
+Headers.getDiags().Report(diag::warn_poison_system_directories)
+<< MappedPathStr;
+  }
+
   // Compute the DirectoryLookup type.
   SrcMgr::CharacteristicKind Type;
   if (Group == Quoted || Group == Angled || Group == IndexHeaderMap) {

Added: cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/.keep?rev=371878=auto
==
(empty)

Added: 
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c++/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c%2B%2B/.keep?rev=371878=auto
==
(empty)

Added: 
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/.keep?rev=371878=auto

r371876 - Fix build error in 371875

2019-09-13 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Fri Sep 13 10:56:38 2019
New Revision: 371876

URL: http://llvm.org/viewvc/llvm-project?rev=371876=rev
Log:
Fix build error in 371875

Apparently Clang complains about the name hiding here in a way that my
GCC build does not, so a shocking number of buildbots decided to tell me
about it.  Change the name of the variable to prevent the name hiding
and hope we don't have to fix this again.

Modified:
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=371876=371875=371876=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Fri Sep 13 10:56:38 2019
@@ -2341,7 +2341,7 @@ void EmitClangAttrClass(RecordKeeper 
   OS << ", SourceRange Range, AttributeCommonInfo::Syntax Syntax";
   if (!ElideSpelling)
 OS << ", " << R.getName()
-   << "Attr::Spelling Spelling = "
+   << "Attr::Spelling S = "
   "static_cast(SpellingNotCalculated)";
   OS << ") {\n";
   OS << "AttributeCommonInfo I(Range, ";
@@ -2353,7 +2353,7 @@ void EmitClangAttrClass(RecordKeeper 
 
   OS << ", Syntax";
   if (!ElideSpelling)
-OS << ", Spelling";
+OS << ", S";
   OS << ");\n";
   OS << "return Create";
   if (Implicit)


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


[PATCH] D67559: [Sema] Split of versions of -Wimplicit-{float,int}-conversion for Objective-C BOOL

2019-09-13 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

The diagnostics message looks good to me.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67559



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


[PATCH] D66951: [ASTImporter] Add comprehensive tests for ODR violation handling strategies

2019-09-13 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

I have reorganized the tests to group the ones which test ODR violation 
strategy independent behaviour.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66951



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


[PATCH] D66951: [ASTImporter] Add comprehensive tests for ODR violation handling strategies

2019-09-13 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 220130.
martong added a comment.

- Reorganize ODRStrategy independent behaviour tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66951

Files:
  clang/unittests/AST/ASTImporterODRStrategiesTest.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/CMakeLists.txt

Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -11,6 +11,7 @@
   ASTImporterFixtures.cpp
   ASTImporterTest.cpp
   ASTImporterGenericRedeclTest.cpp
+  ASTImporterODRStrategiesTest.cpp
   ASTImporterVisibilityTest.cpp
   ASTTraverserTest.cpp
   ASTTypeTraitsTest.cpp
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5409,187 +5409,6 @@
   EXPECT_EQ(ImportedX->isAggregate(), FromX->isAggregate());
 }
 
-struct ConflictingDeclsWithLiberalStrategy : ASTImporterOptionSpecificTestBase {
-  ConflictingDeclsWithLiberalStrategy() {
-this->ODRHandling = ASTImporter::ODRHandlingType::Liberal;
-  }
-};
-
-// Check that a Decl has been successfully imported into a standalone redecl
-// chain.
-template 
-static void CheckImportedAsNew(llvm::Expected , Decl *ToTU,
-   PatternTy Pattern) {
-  ASSERT_TRUE(isSuccess(Result));
-  Decl *ImportedD = *Result;
-  ASSERT_TRUE(ImportedD);
-  auto *ToD = FirstDeclMatcher().match(ToTU, Pattern);
-  EXPECT_NE(ImportedD, ToD);
-  EXPECT_FALSE(ImportedD->getPreviousDecl());
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u);
-}
-
-TEST_P(ConflictingDeclsWithLiberalStrategy, Typedef) {
-  Decl *ToTU = getToTuDecl(
-  R"(
-  typedef int X;
-  )",
-  Lang_CXX11);
-  Decl *FromTU = getTuDecl(
-  R"(
-  typedef double X;
-  )",
-  Lang_CXX11);
-  auto Pattern = typedefNameDecl(hasName("X"));
-  auto *FromX = FirstDeclMatcher().match(FromTU, Pattern);
-
-  Expected Result = importOrError(FromX, Lang_CXX11);
-  CheckImportedAsNew(Result, ToTU, Pattern);
-}
-
-TEST_P(ConflictingDeclsWithLiberalStrategy, TypeAlias) {
-  Decl *ToTU = getToTuDecl(
-  R"(
-  using X = int;
-  )",
-  Lang_CXX11);
-  Decl *FromTU = getTuDecl(
-  R"(
-  using X = double;
-  )",
-  Lang_CXX11);
-  auto Pattern = typedefNameDecl(hasName("X"));
-  auto *FromX = FirstDeclMatcher().match(FromTU, Pattern);
-  Expected Result = importOrError(FromX, Lang_CXX11);
-  CheckImportedAsNew(Result, ToTU, Pattern);
-}
-
-TEST_P(ConflictingDeclsWithLiberalStrategy, EnumDecl) {
-  Decl *ToTU = getToTuDecl(
-  R"(
-  enum X { a, b };
-  )",
-  Lang_CXX11);
-  Decl *FromTU = getTuDecl(
-  R"(
-  enum X { a, b, c };
-  )",
-  Lang_CXX11);
-  auto Pattern = enumDecl(hasName("X"));
-  auto *FromX = FirstDeclMatcher().match(FromTU, Pattern);
-  Expected Result = importOrError(FromX, Lang_CXX11);
-  CheckImportedAsNew(Result, ToTU, Pattern);
-}
-
-TEST_P(ConflictingDeclsWithLiberalStrategy, EnumConstantDecl) {
-  Decl *ToTU = getToTuDecl(
-  R"(
-  enum E { X = 0 };
-  )",
-  Lang_CXX11);
-  Decl *FromTU = getTuDecl(
-  R"(
-  enum E { X = 1 };
-  )",
-  Lang_CXX11);
-  auto Pattern = enumConstantDecl(hasName("X"));
-  auto *FromX = FirstDeclMatcher().match(FromTU, Pattern);
-  Expected Result = importOrError(FromX, Lang_CXX11);
-  CheckImportedAsNew(Result, ToTU, Pattern);
-}
-
-TEST_P(ConflictingDeclsWithLiberalStrategy, RecordDecl) {
-  Decl *ToTU = getToTuDecl(
-  R"(
-  class X { int a; };
-  )",
-  Lang_CXX11);
-  Decl *FromTU = getTuDecl(
-  R"(
-  class X { int b; };
-  )",
-  Lang_CXX11);
-  auto Pattern = cxxRecordDecl(hasName("X"), unless(isImplicit()));
-  auto *FromX = FirstDeclMatcher().match(FromTU, Pattern);
-  Expected Result = importOrError(FromX, Lang_CXX11);
-  CheckImportedAsNew(Result, ToTU, Pattern);
-}
-
-TEST_P(ConflictingDeclsWithLiberalStrategy, VarDecl) {
-  Decl *ToTU = getToTuDecl(
-  R"(
-  int X;
-  )",
-  Lang_CXX11);
-  Decl *FromTU = getTuDecl(
-  R"(
-  double X;
-  )",
-  Lang_CXX11);
-  auto Pattern = varDecl(hasName("X"));
-  auto *FromX = FirstDeclMatcher().match(FromTU, Pattern);
-  Expected Result = importOrError(FromX, Lang_CXX11);
-  CheckImportedAsNew(Result, ToTU, Pattern);
-}
-
-TEST_P(ConflictingDeclsWithLiberalStrategy, FunctionDecl) {
-  Decl *ToTU = getToTuDecl(
-  R"(
-  void X(int);
-  )",
-  Lang_C); // C, no overloading!
-  Decl *FromTU = getTuDecl(
-  R"(
-  void X(double);
-  )",
-  Lang_C);
-  auto Pattern = functionDecl(hasName("X"));
-  auto *FromX = FirstDeclMatcher().match(FromTU, Pattern);
-  Expected Result = importOrError(FromX, 

[PATCH] D65043: [Format] Add C++20 standard to style options

2019-09-13 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

In D65043#1669410 , @sammccall wrote:

> (For actual coroutine support, treating `co_return` and `co_yield` like 
> `return` everywhere might make sense)


I agree, with one nit. `co_return` should be treated like `return`, but 
`co_yield` and `co_await` should both be treated like `throw` (because they can 
be subexpressions).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65043



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


[PATCH] D67414: [AST] Treat "inline gnu_inline" the same way as "extern inline gnu_inline" in C++ mode

2019-09-13 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/test/SemaCUDA/gnu-inline.cu:8
 void foo();
-inline __attribute__((gnu_inline)) void bar() { foo(); }
+inline __attribute__((gnu_inline)) void bar() { foo(); } // expected-warning 
{{'gnu_inline' attribute without 'extern' in C++ treated as externally 
available, this changed in Clang 10}}

>>! In D67414#1669156, @mstorsjo wrote:
> The warning did trigger in an existing CUDA test as well - I'm not familiar 
> with cuda and how it relates to other languages, so suggestions on what to do 
> wrt it, if anything, are also welcome.

I believe what we care about here is whether `gnu_inline` is handled at all.
If `gnu_inline` needs `extern`, you should add it here and revert the warning 
check.


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

https://reviews.llvm.org/D67414



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


[PATCH] D67414: [AST] Treat "inline gnu_inline" the same way as "extern inline gnu_inline" in C++ mode

2019-09-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo marked an inline comment as done.
mstorsjo added inline comments.



Comment at: clang/test/SemaCUDA/gnu-inline.cu:8
 void foo();
-inline __attribute__((gnu_inline)) void bar() { foo(); }
+inline __attribute__((gnu_inline)) void bar() { foo(); } // expected-warning 
{{'gnu_inline' attribute without 'extern' in C++ treated as externally 
available, this changed in Clang 10}}

tra wrote:
> >>! In D67414#1669156, @mstorsjo wrote:
> > The warning did trigger in an existing CUDA test as well - I'm not familiar 
> > with cuda and how it relates to other languages, so suggestions on what to 
> > do wrt it, if anything, are also welcome.
> 
> I believe what we care about here is whether `gnu_inline` is handled at all.
> If `gnu_inline` needs `extern`, you should add it here and revert the warning 
> check.
Ok, that makes sense, will change it.


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

https://reviews.llvm.org/D67414



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


[PATCH] D65917: [clang-tidy] Added check for the Google style guide's category method naming rule.

2019-09-13 Thread David Gatwood via Phabricator via cfe-commits
dgatwood updated this revision to Diff 220123.
dgatwood added a comment.

Switched to objcMethodDecl(hasDeclContext(objcCategoryDecl())).


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

https://reviews.llvm.org/D65917

Files:
  clang-tools-extra/clang-tidy/google/CMakeLists.txt
  clang-tools-extra/clang-tidy/google/GoogleTidyModule.cpp
  clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.cpp
  clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/google-objc-require-category-method-prefixes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/google-objc-require-category-method-prefixes.m

Index: clang-tools-extra/test/clang-tidy/google-objc-require-category-method-prefixes.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/google-objc-require-category-method-prefixes.m
@@ -0,0 +1,35 @@
+// RUN: %check_clang_tidy %s google-objc-require-category-method-prefixes %t -config="{CheckOptions: [{key: google-objc-require-category-method-prefixes.ExpectedPrefixes, value: GMO}]}"
+
+@class NSString;
+
+@interface NSURL
++ (nullable instancetype)URLWithString:(NSString *)URLString;
++ (instancetype)alloc;
+- (instancetype)init;
+@end
+
+@interface NSURL (CustomExtension)
+
+- (void)unprefixedMethod;
+- (void)unprefixed;
+- (void)justprefixed_;
+
+@end
+
+// CHECK-MESSAGES: :[[@LINE-6]]:1: warning: the category method 'unprefixedMethod' is not properly prefixed [google-objc-require-category-method-prefixes]
+// CHECK-MESSAGES: :[[@LINE-6]]:1: warning: the category method 'unprefixed' is not properly prefixed [google-objc-require-category-method-prefixes]
+// CHECK-MESSAGES: :[[@LINE-6]]:1: warning: the category method 'justprefixed_' is not properly prefixed [google-objc-require-category-method-prefixes]
+
+@interface NSURL (CustomExtension2)
+- (void)gmo_prefixedMethod;
+@end
+
+@interface GMOURL
++ (nullable instancetype)URLWithString:(NSString *)URLString;
++ (instancetype)alloc;
+- (instancetype)init;
+@end
+
+@interface GMOURL (CustomExtension3)
+- (void)unprefixedMethodInClassWithExpectedPrefix;
+@end
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -230,6 +230,7 @@
google-objc-avoid-throwing-exception
google-objc-function-naming
google-objc-global-variable-declaration
+   google-objc-require-category-method-prefixes
google-readability-avoid-underscore-in-googletest-name
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
google-readability-casting
Index: clang-tools-extra/docs/clang-tidy/checks/google-objc-require-category-method-prefixes.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/google-objc-require-category-method-prefixes.rst
@@ -0,0 +1,45 @@
+.. title:: clang-tidy - google-objc-require-category-method-prefixes
+
+google-objc-require-category-method-prefixes
+
+
+Warns when Objective-C category method names are not properly prefixed (e.g.
+``gmo_methodName``) unless the category is extending a class with an
+expected prefix (configurable).
+
+The Google Objective-C style guide requires
+`prefixes for methods http://go/objc-style#Category_Names`_ in categories on
+classes that you don't control (for example, categories on Apple or third-party
+framework classes or classes created by other teams) to prevent name collisions
+when those frameworks are updated.
+
+This checker ensures that all methods in categories have some sort of prefix
+(e.g. ``gmo_``).  It allows you to provide a list of expected three-letter
+prefixes specific to your project, and ignores non-prefixed methods in
+categories on classes whose names start with any of those prefixes.
+
+For example, the following code sample is a properly prefixed method on a
+non-owned class (``NSObject``):
+
+.. code-block:: objc
+  @interface NSObject (QEDMyCategory)
+  - (BOOL)qed_myCustomMethod;
+  @end
+
+If you specify ``QED`` as an expected three-letter prefix, the following code
+sample is also allowed:
+
+.. code-block:: objc
+
+  @interface QEDMyClass (MyCategory)
+  - (BOOL)myCustomMethod;
+  @end
+
+Options
+---
+
+.. option:: ExpectedPrefixes
+
+   A semicolon-delimited list of class name prefixes.  Methods in categories
+   that extend classes whose names begin with any of these prefixes are exempt
+   from the method name prefixing requirement.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ 

[PATCH] D67559: [Sema] Split of versions of -Wimplicit-{float,int}-conversion for Objective-C BOOL

2019-09-13 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: rjmccall, steven_wu, aaron.ballman.
Herald added subscribers: ributzka, dexonsmith, jkorous.
Herald added a project: clang.

Also, add a diagnostic group, -Wobjc-signed-char-bool, to control all these 
related diagnostics.

See also: D63912 , D63856 


rdar://problem/51954400 ObjC: Add diagnostics to catch incorrect usage of BOOL


Repository:
  rC Clang

https://reviews.llvm.org/D67559

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaObjC/signed-char-bool-conversion.m

Index: clang/test/SemaObjC/signed-char-bool-conversion.m
===
--- /dev/null
+++ clang/test/SemaObjC/signed-char-bool-conversion.m
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 %s -verify -Wobjc-signed-char-bool
+// RUN: %clang_cc1 -xobjective-c++ %s -verify -Wobjc-signed-char-bool
+
+typedef signed char BOOL;
+#define YES __objc_yes
+#define NO __objc_no
+
+typedef unsigned char Boolean;
+
+BOOL b;
+Boolean boolean;
+float fl;
+int i;
+int *ptr;
+
+void t1() {
+  b = boolean;
+  b = fl; // expected-warning {{implicit conversion from floating-point type 'float' to BOOL}}
+  b = i; // expected-warning {{implicit conversion from integral type 'int' to BOOL}}
+
+  b = 1.0;
+  b = 0.0;
+  b = 1.1; // expected-warning {{implicit conversion from 'double' to 'BOOL' (aka 'signed char') changes value from 1.1 to 1}}
+  b = 2.1; // expected-warning {{implicit conversion from constant value 2.1 to BOOL; the only well defined values for BOOL are YES and NO}}
+
+  b = YES;
+#ifndef __cplusplus
+  b = ptr; // expected-warning {{incompatible pointer to integer conversion assigning to 'BOOL' (aka 'signed char') from 'int *'}}
+#endif
+}
+
+@interface BoolProp
+@property BOOL p;
+@end
+
+void t2(BoolProp *bp) {
+  bp.p = YES;
+  bp.p = NO;
+  bp.p = boolean;
+  bp.p = fl; // expected-warning {{implicit conversion from floating-point type 'float' to BOOL}}
+  bp.p = i; // expected-warning {{implicit conversion from integral type 'int' to BOOL}}
+  bp.p = b;
+  bp.p = bp.p;
+#ifndef __cplusplus
+  bp.p = ptr; // expected-warning {{incompatible pointer to integer conversion assigning to 'BOOL' (aka 'signed char') from 'int *'}}
+#endif
+  bp.p = 1;
+  bp.p = 2; // expected-warning {{implicit conversion from constant value 2 to BOOL; the only well defined values for BOOL are YES and NO}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -10840,6 +10840,24 @@
   DiagnoseImpCast(S, E, E->getType(), T, CContext, diag, pruneControlFlow);
 }
 
+static bool isObjCSignedCharBool(Sema , QualType Ty) {
+  return Ty->isSpecificBuiltinType(BuiltinType::SChar) &&
+  S.getLangOpts().ObjC && S.NSAPIObj->isObjCBOOLType(Ty);
+}
+
+static void adornObjCBoolConversionDiagWithTernaryFixit(
+Sema , Expr *SourceExpr, const Sema::SemaDiagnosticBuilder ) {
+  Expr *Ignored = SourceExpr->IgnoreImplicit();
+  bool NeedsParens = isa(Ignored) ||
+ isa(Ignored) ||
+ isa(Ignored);
+  SourceLocation EndLoc = S.getLocForEndOfToken(SourceExpr->getEndLoc());
+  if (NeedsParens)
+Builder << FixItHint::CreateInsertion(SourceExpr->getBeginLoc(), "(")
+<< FixItHint::CreateInsertion(EndLoc, ")");
+  Builder << FixItHint::CreateInsertion(EndLoc, " ? YES : NO");
+}
+
 /// Diagnose an implicit cast from a floating point value to an integer value.
 static void DiagnoseFloatingImpCast(Sema , Expr *E, QualType T,
 SourceLocation CContext) {
@@ -10859,6 +10877,13 @@
   bool IsConstant =
 E->EvaluateAsFloat(Value, S.Context, Expr::SE_AllowSideEffects);
   if (!IsConstant) {
+if (isObjCSignedCharBool(S, T)) {
+  return adornObjCBoolConversionDiagWithTernaryFixit(
+  S, E,
+  S.Diag(CContext, diag::warn_impcast_float_to_objc_signed_char_bool)
+  << E->getType());
+}
+
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, PruneWarnings);
   }
@@ -10870,6 +10895,23 @@
   llvm::APFloat::opStatus Result = Value.convertToInteger(
   IntegerValue, llvm::APFloat::rmTowardZero, );
 
+  // FIXME: Force the precision of the source value down so we don't print
+  // digits which are usually useless (we don't really care here if we
+  // truncate a digit by accident in edge cases).  Ideally, APFloat::toString
+  // would automatically print the shortest representation, but it's a bit
+  // tricky to implement.
+  SmallString<16> PrettySourceValue;
+  unsigned precision = llvm::APFloat::semanticsPrecision(Value.getSemantics());
+  precision = (precision * 59 + 195) / 

[PATCH] D67368: [NFCI]Create CommonAttributeInfo Type as base type of *Attr and ParsedAttr.

2019-09-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM! Thank you for this refactoring -- it was large, but I think the results 
from it are really good.




Comment at: clang/include/clang/Basic/AttributeCommonInfo.h:66-69
+  unsigned AttrKind : 16;
+  /// Corresponds to the Syntax enum.
+  unsigned SyntaxUsed : 3;
+  unsigned SpellingIndex : 4;

erichkeane wrote:
> aaron.ballman wrote:
> > Do you want to do `= 0` here to give them in-class initializers? (well, 
> > `SpellingIndex` should probably be `SpellingNotCalculated`).
> Bitfield in-class initializers are a C++2a feature.
Details. Invent a time machine and add this to C++14. ;-)


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

https://reviews.llvm.org/D67368



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


[PATCH] D67399: [ARM] Follow AACPS standard for volatile bitfields

2019-09-13 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D67399#1669038 , @dnsampaio wrote:

> Indeed our main concern is regarding the access widths of loads. As mentioned 
> by @rjmccall, most volatile bitfields are used to perform memory mapped I/O, 
> and some hardware only support them with a specific access width.
>  The spurious load I am more than glad to leave it disable behind a command 
> flag, so it will only appear if the user requests it. See that volatile 
> accesses might have side effects, and for example, an I/O read counter 
> holding an odd number could define that the data is still being processed.


Are the cases being addressed in the PR actually relevant to real MMIO, or is 
this patch following the letter of AAPCS which doesn't actually matter?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67399



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


[PATCH] D65044: [Format] Add option to enable coroutines keywords

2019-09-13 Thread Brian Gesiak via Phabricator via cfe-commits
modocache abandoned this revision.
modocache added a comment.

I work on a C++17 codebase with coroutines enabled, but yes 
just formatting the codebase as if it were C++20 seems fine. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65044



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


[PATCH] D65043: [Format] Add C++20 standard to style options

2019-09-13 Thread Brian Gesiak via Phabricator via cfe-commits
modocache abandoned this revision.
modocache added a comment.

Oh, thank you! Yes, I had been meaning to abandon this and my other patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65043



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


[PATCH] D66951: [ASTImporter] Add comprehensive tests for ODR violation handling strategies

2019-09-13 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 3 inline comments as done.
martong added inline comments.



Comment at: clang/unittests/AST/ASTImporterODRStrategiesTest.cpp:118
+  template 
+  constexpr T X;
+  )";

shafik wrote:
> shafik wrote:
> > Note this is not well-formed b/c it is not initialized, [see 
> > godbolt](https://godbolt.org/z/8xvFwh)
> But it would be ok combined w/ a specialization:
> 
> ```
> template <>
> constexpr int X = 0;
> ```
Ok, I changed the template to have an init expression:
```
template 
constexpr T X = 0;
```



Comment at: clang/unittests/AST/ASTImporterODRStrategiesTest.cpp:151
+};
+
+template 

shafik wrote:
> martong wrote:
> > balazske wrote:
> > > `FunctionTemplate` and `FunctionTemplateSpec` are missing?
> > Yes, because `FunctionTemplates` overload with each other. So they are 
> > imported always "liberally".
> > 
> > There is no point to liberally import conflicting 
> > `FunctionTemplateSpecializations`.
> > The only thing we can do in that case is to omit the conflicting 
> > declaration.
> > And this is true in case of `ClassTemplateSpecialization`s too.
> > 
> > Perhaps we should remove `struct ClassTemplateSpec` as well from here (?).
> > Because they are never going to be handled "liberally".
> > 
> > @shafik , what do you think about this?
> What you say about `FunctionTemplateSpecializations` and 
> `ClassTemplateSpecializations` seems to make sense, importing them liberally 
> would require more than work in the importer.
I have added `FunctionTemplate`, `FunctionTemplateSpec` and `VarTemplateSpec`.

FunctionTemplate decls overload with each other. Thus, they are imported always 
"liberally". I have added a test for that.

Class and variable template specializations/instantiatons are always imported 
conservatively, because the AST holds the specializations in a set, and the key 
within the set is a hash calculated from the arguments of the specialization.
I have added tests for class template specializations, but put the 
VarTemplateSpec tests into a FIXME, because structural eq does not handle 
VarTemplates and their specs yet.

Function template specializations are different. They are all "full"
specializations. Structural equivalency does not check the body of
functions, so we cannot create conflicting function template specializations.
Thus, ODR handling strategies has nothing to do with function template
specializations. I have added this as a comment to the tests.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66951



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


[PATCH] D66951: [ASTImporter] Add comprehensive tests for ODR violation handling strategies

2019-09-13 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 220104.
martong marked an inline comment as done.
martong added a comment.

- Initialize the variable template in test
- Clean up tests for fun templates and for specializations


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66951

Files:
  clang/unittests/AST/ASTImporterODRStrategiesTest.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/CMakeLists.txt

Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -11,6 +11,7 @@
   ASTImporterFixtures.cpp
   ASTImporterTest.cpp
   ASTImporterGenericRedeclTest.cpp
+  ASTImporterODRStrategiesTest.cpp
   ASTImporterVisibilityTest.cpp
   ASTTraverserTest.cpp
   ASTTypeTraitsTest.cpp
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5409,187 +5409,6 @@
   EXPECT_EQ(ImportedX->isAggregate(), FromX->isAggregate());
 }
 
-struct ConflictingDeclsWithLiberalStrategy : ASTImporterOptionSpecificTestBase {
-  ConflictingDeclsWithLiberalStrategy() {
-this->ODRHandling = ASTImporter::ODRHandlingType::Liberal;
-  }
-};
-
-// Check that a Decl has been successfully imported into a standalone redecl
-// chain.
-template 
-static void CheckImportedAsNew(llvm::Expected , Decl *ToTU,
-   PatternTy Pattern) {
-  ASSERT_TRUE(isSuccess(Result));
-  Decl *ImportedD = *Result;
-  ASSERT_TRUE(ImportedD);
-  auto *ToD = FirstDeclMatcher().match(ToTU, Pattern);
-  EXPECT_NE(ImportedD, ToD);
-  EXPECT_FALSE(ImportedD->getPreviousDecl());
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u);
-}
-
-TEST_P(ConflictingDeclsWithLiberalStrategy, Typedef) {
-  Decl *ToTU = getToTuDecl(
-  R"(
-  typedef int X;
-  )",
-  Lang_CXX11);
-  Decl *FromTU = getTuDecl(
-  R"(
-  typedef double X;
-  )",
-  Lang_CXX11);
-  auto Pattern = typedefNameDecl(hasName("X"));
-  auto *FromX = FirstDeclMatcher().match(FromTU, Pattern);
-
-  Expected Result = importOrError(FromX, Lang_CXX11);
-  CheckImportedAsNew(Result, ToTU, Pattern);
-}
-
-TEST_P(ConflictingDeclsWithLiberalStrategy, TypeAlias) {
-  Decl *ToTU = getToTuDecl(
-  R"(
-  using X = int;
-  )",
-  Lang_CXX11);
-  Decl *FromTU = getTuDecl(
-  R"(
-  using X = double;
-  )",
-  Lang_CXX11);
-  auto Pattern = typedefNameDecl(hasName("X"));
-  auto *FromX = FirstDeclMatcher().match(FromTU, Pattern);
-  Expected Result = importOrError(FromX, Lang_CXX11);
-  CheckImportedAsNew(Result, ToTU, Pattern);
-}
-
-TEST_P(ConflictingDeclsWithLiberalStrategy, EnumDecl) {
-  Decl *ToTU = getToTuDecl(
-  R"(
-  enum X { a, b };
-  )",
-  Lang_CXX11);
-  Decl *FromTU = getTuDecl(
-  R"(
-  enum X { a, b, c };
-  )",
-  Lang_CXX11);
-  auto Pattern = enumDecl(hasName("X"));
-  auto *FromX = FirstDeclMatcher().match(FromTU, Pattern);
-  Expected Result = importOrError(FromX, Lang_CXX11);
-  CheckImportedAsNew(Result, ToTU, Pattern);
-}
-
-TEST_P(ConflictingDeclsWithLiberalStrategy, EnumConstantDecl) {
-  Decl *ToTU = getToTuDecl(
-  R"(
-  enum E { X = 0 };
-  )",
-  Lang_CXX11);
-  Decl *FromTU = getTuDecl(
-  R"(
-  enum E { X = 1 };
-  )",
-  Lang_CXX11);
-  auto Pattern = enumConstantDecl(hasName("X"));
-  auto *FromX = FirstDeclMatcher().match(FromTU, Pattern);
-  Expected Result = importOrError(FromX, Lang_CXX11);
-  CheckImportedAsNew(Result, ToTU, Pattern);
-}
-
-TEST_P(ConflictingDeclsWithLiberalStrategy, RecordDecl) {
-  Decl *ToTU = getToTuDecl(
-  R"(
-  class X { int a; };
-  )",
-  Lang_CXX11);
-  Decl *FromTU = getTuDecl(
-  R"(
-  class X { int b; };
-  )",
-  Lang_CXX11);
-  auto Pattern = cxxRecordDecl(hasName("X"), unless(isImplicit()));
-  auto *FromX = FirstDeclMatcher().match(FromTU, Pattern);
-  Expected Result = importOrError(FromX, Lang_CXX11);
-  CheckImportedAsNew(Result, ToTU, Pattern);
-}
-
-TEST_P(ConflictingDeclsWithLiberalStrategy, VarDecl) {
-  Decl *ToTU = getToTuDecl(
-  R"(
-  int X;
-  )",
-  Lang_CXX11);
-  Decl *FromTU = getTuDecl(
-  R"(
-  double X;
-  )",
-  Lang_CXX11);
-  auto Pattern = varDecl(hasName("X"));
-  auto *FromX = FirstDeclMatcher().match(FromTU, Pattern);
-  Expected Result = importOrError(FromX, Lang_CXX11);
-  CheckImportedAsNew(Result, ToTU, Pattern);
-}
-
-TEST_P(ConflictingDeclsWithLiberalStrategy, FunctionDecl) {
-  Decl *ToTU = getToTuDecl(
-  R"(
-  void X(int);
-  )",
-  Lang_C); // C, no overloading!
-  Decl *FromTU = getTuDecl(
-  R"(
-  void X(double);
-  )",
-  Lang_C);
-  auto Pattern = functionDecl(hasName("X"));
-  auto 

[PATCH] D67515: [Sema][Typo Correction] Fix potential infite loop on ambiguity checks

2019-09-13 Thread David Goldman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371859: [Sema][Typo Correction] Fix potential infite loop on 
ambiguity checks (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/D67515/new/

https://reviews.llvm.org/D67515

Files:
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/Sema/typo-correction-ambiguity.cpp


Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -7755,6 +7755,10 @@
 TypoCorrection TC = 
SemaRef.getTypoExprState(TE).Consumer->peekNextCorrection();
 TypoCorrection Next;
 do {
+  // Fetch the next correction by erasing the typo from the cache and 
calling
+  // `TryTransform` which will iterate through corrections in
+  // `TransformTypoExpr`.
+  TransformCache.erase(TE);
   ExprResult AmbigRes = CheckForRecursiveTypos(TryTransform(E), 
IsAmbiguous);
 
   if (!AmbigRes.isInvalid() || IsAmbiguous) {
Index: cfe/trunk/test/Sema/typo-correction-ambiguity.cpp
===
--- cfe/trunk/test/Sema/typo-correction-ambiguity.cpp
+++ cfe/trunk/test/Sema/typo-correction-ambiguity.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the following typo correction behavior in namespaces:
+// - no typos are diagnosed when an expression has ambiguous (multiple) 
corrections
+// - proper iteration through multiple potentially ambiguous corrections
+
+namespace AmbiguousCorrection
+{
+  void method_Bar();
+  void method_Foo();
+  void method_Zoo();
+};
+
+void testAmbiguousNoSuggestions()
+{
+  AmbiguousCorrection::method_Ace(); // expected-error {{no member named 
'method_Ace' in namespace 'AmbiguousCorrection'}}
+}
+
+namespace MultipleCorrectionsButNotAmbiguous
+{
+  int PrefixType_Name(int value);  // expected-note {{'PrefixType_Name' 
declared here}}
+  int PrefixType_MIN();
+  int PrefixType_MAX();
+};
+
+int testMultipleCorrectionsButNotAmbiguous() {
+  int val = MultipleCorrectionsButNotAmbiguous::PrefixType_Enum(0);  // 
expected-error {{no member named 'PrefixType_Enum' in namespace 
'MultipleCorrectionsButNotAmbiguous'; did you mean 'PrefixType_Name'?}}
+  return val;
+}


Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -7755,6 +7755,10 @@
 TypoCorrection TC = SemaRef.getTypoExprState(TE).Consumer->peekNextCorrection();
 TypoCorrection Next;
 do {
+  // Fetch the next correction by erasing the typo from the cache and calling
+  // `TryTransform` which will iterate through corrections in
+  // `TransformTypoExpr`.
+  TransformCache.erase(TE);
   ExprResult AmbigRes = CheckForRecursiveTypos(TryTransform(E), IsAmbiguous);
 
   if (!AmbigRes.isInvalid() || IsAmbiguous) {
Index: cfe/trunk/test/Sema/typo-correction-ambiguity.cpp
===
--- cfe/trunk/test/Sema/typo-correction-ambiguity.cpp
+++ cfe/trunk/test/Sema/typo-correction-ambiguity.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the following typo correction behavior in namespaces:
+// - no typos are diagnosed when an expression has ambiguous (multiple) corrections
+// - proper iteration through multiple potentially ambiguous corrections
+
+namespace AmbiguousCorrection
+{
+  void method_Bar();
+  void method_Foo();
+  void method_Zoo();
+};
+
+void testAmbiguousNoSuggestions()
+{
+  AmbiguousCorrection::method_Ace(); // expected-error {{no member named 'method_Ace' in namespace 'AmbiguousCorrection'}}
+}
+
+namespace MultipleCorrectionsButNotAmbiguous
+{
+  int PrefixType_Name(int value);  // expected-note {{'PrefixType_Name' declared here}}
+  int PrefixType_MIN();
+  int PrefixType_MAX();
+};
+
+int testMultipleCorrectionsButNotAmbiguous() {
+  int val = MultipleCorrectionsButNotAmbiguous::PrefixType_Enum(0);  // expected-error {{no member named 'PrefixType_Enum' in namespace 'MultipleCorrectionsButNotAmbiguous'; did you mean 'PrefixType_Name'?}}
+  return val;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67358: [clangd] Implement semantic selections.

2019-09-13 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.

Nice!

Please make sure you run clang-format (I think it'll add missing newlines at 
EOF)




Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:22
+// Assumes that only consecutive ranges can coincide.
+void addIfDistinct(const Range , std::vector *Result) {
+  if (Result->empty() || Result->back() != R) {

nit: it's idiomatic in LLVM to pass mutable references rather than pointers 
where possible



Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:52
+auto SR = toHalfOpenFileRange(SM, LangOpts, 
Node->ASTNode.getSourceRange());
+if (!SR.hasValue()) {
+  continue;

`|| SM.getFileID(SR->getBegin()) != SM.getMainFileID()`

(begin and end are guaranteed to be the same file, but it may not be the main 
file)



Comment at: clang-tools-extra/clangd/SemanticSelection.h:22
+
+// Returns the list of all interesting ranges around the Position \p Pos.
+// The interesting ranges corresponds to the AST nodes in the SelectionTree

nit: if you intend to use doxygen comments (with `\p` syntax) you probably want 
`///` so doxygen will render them


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67358



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


r371859 - [Sema][Typo Correction] Fix potential infite loop on ambiguity checks

2019-09-13 Thread David Goldman via cfe-commits
Author: dgoldman
Date: Fri Sep 13 07:43:24 2019
New Revision: 371859

URL: http://llvm.org/viewvc/llvm-project?rev=371859=rev
Log:
[Sema][Typo Correction] Fix potential infite loop on ambiguity checks

Summary:
This fixes a bug introduced in D62648, where Clang could infinite loop
if it became stuck on a single TypoCorrection when it was supposed to
be testing ambiguous corrections. Although not a common case, it could
happen if there are multiple possible corrections with the same edit
distance.

The fix is simply to wipe the TypoExpr from the `TransformCache` so that
the call to `TransformTypoExpr` doesn't use the `CachedEntry`.

Reviewers: rsmith

Subscribers: cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Sema/typo-correction-ambiguity.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=371859=371858=371859=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Sep 13 07:43:24 2019
@@ -7755,6 +7755,10 @@ class TransformTypos : public TreeTransf
 TypoCorrection TC = 
SemaRef.getTypoExprState(TE).Consumer->peekNextCorrection();
 TypoCorrection Next;
 do {
+  // Fetch the next correction by erasing the typo from the cache and 
calling
+  // `TryTransform` which will iterate through corrections in
+  // `TransformTypoExpr`.
+  TransformCache.erase(TE);
   ExprResult AmbigRes = CheckForRecursiveTypos(TryTransform(E), 
IsAmbiguous);
 
   if (!AmbigRes.isInvalid() || IsAmbiguous) {

Added: cfe/trunk/test/Sema/typo-correction-ambiguity.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction-ambiguity.cpp?rev=371859=auto
==
--- cfe/trunk/test/Sema/typo-correction-ambiguity.cpp (added)
+++ cfe/trunk/test/Sema/typo-correction-ambiguity.cpp Fri Sep 13 07:43:24 2019
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the following typo correction behavior in namespaces:
+// - no typos are diagnosed when an expression has ambiguous (multiple) 
corrections
+// - proper iteration through multiple potentially ambiguous corrections
+
+namespace AmbiguousCorrection
+{
+  void method_Bar();
+  void method_Foo();
+  void method_Zoo();
+};
+
+void testAmbiguousNoSuggestions()
+{
+  AmbiguousCorrection::method_Ace(); // expected-error {{no member named 
'method_Ace' in namespace 'AmbiguousCorrection'}}
+}
+
+namespace MultipleCorrectionsButNotAmbiguous
+{
+  int PrefixType_Name(int value);  // expected-note {{'PrefixType_Name' 
declared here}}
+  int PrefixType_MIN();
+  int PrefixType_MAX();
+};
+
+int testMultipleCorrectionsButNotAmbiguous() {
+  int val = MultipleCorrectionsButNotAmbiguous::PrefixType_Enum(0);  // 
expected-error {{no member named 'PrefixType_Enum' in namespace 
'MultipleCorrectionsButNotAmbiguous'; did you mean 'PrefixType_Name'?}}
+  return val;
+}


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


[PATCH] D67515: [Sema][Typo Correction] Fix potential infite loop on ambiguity checks

2019-09-13 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 220097.
dgoldman added a comment.

- Fix typo in test


Repository:
  rC Clang

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

https://reviews.llvm.org/D67515

Files:
  lib/Sema/SemaExprCXX.cpp
  test/Sema/typo-correction-ambiguity.cpp


Index: test/Sema/typo-correction-ambiguity.cpp
===
--- /dev/null
+++ test/Sema/typo-correction-ambiguity.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the following typo correction behavior in namespaces:
+// - no typos are diagnosed when an expression has ambiguous (multiple) 
corrections
+// - proper iteration through multiple potentially ambiguous corrections
+
+namespace AmbiguousCorrection
+{
+  void method_Bar();
+  void method_Foo();
+  void method_Zoo();
+};
+
+void testAmbiguousNoSuggestions()
+{
+  AmbiguousCorrection::method_Ace(); // expected-error {{no member named 
'method_Ace' in namespace 'AmbiguousCorrection'}}
+}
+
+namespace MultipleCorrectionsButNotAmbiguous
+{
+  int PrefixType_Name(int value);  // expected-note {{'PrefixType_Name' 
declared here}}
+  int PrefixType_MIN();
+  int PrefixType_MAX();
+};
+
+int testMultipleCorrectionsButNotAmbiguous() {
+  int val = MultipleCorrectionsButNotAmbiguous::PrefixType_Enum(0);  // 
expected-error {{no member named 'PrefixType_Enum' in namespace 
'MultipleCorrectionsButNotAmbiguous'; did you mean 'PrefixType_Name'?}}
+  return val;
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -7755,6 +7755,10 @@
 TypoCorrection TC = 
SemaRef.getTypoExprState(TE).Consumer->peekNextCorrection();
 TypoCorrection Next;
 do {
+  // Fetch the next correction by erasing the typo from the cache and 
calling
+  // `TryTransform` which will iterate through corrections in
+  // `TransformTypoExpr`.
+  TransformCache.erase(TE);
   ExprResult AmbigRes = CheckForRecursiveTypos(TryTransform(E), 
IsAmbiguous);
 
   if (!AmbigRes.isInvalid() || IsAmbiguous) {


Index: test/Sema/typo-correction-ambiguity.cpp
===
--- /dev/null
+++ test/Sema/typo-correction-ambiguity.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the following typo correction behavior in namespaces:
+// - no typos are diagnosed when an expression has ambiguous (multiple) corrections
+// - proper iteration through multiple potentially ambiguous corrections
+
+namespace AmbiguousCorrection
+{
+  void method_Bar();
+  void method_Foo();
+  void method_Zoo();
+};
+
+void testAmbiguousNoSuggestions()
+{
+  AmbiguousCorrection::method_Ace(); // expected-error {{no member named 'method_Ace' in namespace 'AmbiguousCorrection'}}
+}
+
+namespace MultipleCorrectionsButNotAmbiguous
+{
+  int PrefixType_Name(int value);  // expected-note {{'PrefixType_Name' declared here}}
+  int PrefixType_MIN();
+  int PrefixType_MAX();
+};
+
+int testMultipleCorrectionsButNotAmbiguous() {
+  int val = MultipleCorrectionsButNotAmbiguous::PrefixType_Enum(0);  // expected-error {{no member named 'PrefixType_Enum' in namespace 'MultipleCorrectionsButNotAmbiguous'; did you mean 'PrefixType_Name'?}}
+  return val;
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -7755,6 +7755,10 @@
 TypoCorrection TC = SemaRef.getTypoExprState(TE).Consumer->peekNextCorrection();
 TypoCorrection Next;
 do {
+  // Fetch the next correction by erasing the typo from the cache and calling
+  // `TryTransform` which will iterate through corrections in
+  // `TransformTypoExpr`.
+  TransformCache.erase(TE);
   ExprResult AmbigRes = CheckForRecursiveTypos(TryTransform(E), IsAmbiguous);
 
   if (!AmbigRes.isInvalid() || IsAmbiguous) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67536: [WIP] [clangd] Add support for an inactive regions notification

2019-09-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Rather than a separate method with parallel implementation, this seems very 
closely related to the syntax highlighting feature.

The minimal way to model this (no new protocol) would be for each disabled 
line, to add one token spanning the whole line with a TextMate scope like 
`comment.disabled` or `meta.disabled`.
There's no technical reason tokens can't overlap in the protocol, though it's 
possible editors will choose to turn off local heuristic highlighting on 
anything that's touched by an LSP-provided token.

Failing that, I'd suggest encoding a list of line-styles on 
`SemanticHighlightingInformation`, that should be combined with any tokens on 
that line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67536



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


[PATCH] D65043: [Format] Add C++20 standard to style options

2019-09-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Not sure if this patch is still live?

I implemented the suggestion from the last round in D67541 
.
I didn't add the coroutine tests, as clang-format doesn't seem to get any 
coroutine cases right in 20 mode that it missed in 17 mode. Instead I found a 
case that differed using `char8_t` and macros.

(For actual coroutine support, treating `co_return` and `co_yield` like 
`return` everywhere might make sense)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65043



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


[PATCH] D67551: [AArch64][SVE] Implement sdot and udot (lane) intrinsics

2019-09-13 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, SjoerdMeijer, greened.
Herald added subscribers: psnobl, rkruppe, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
kmclaughlin added a parent revision: D67549: [IntrinsicEmitter] Add overloaded 
types for SVE intrinsics (Subdivide2 & Subdivide4).

Implements the following arithmetic intrinsics:

- int_aarch64_sve_sdot
- int_aarch64_sve_sdot_lane
- int_aarch64_sve_udot
- int_aarch64_sve_udot_lane

This patch includes tests for the Subdivide4Argument type added by D67549 



https://reviews.llvm.org/D67551

Files:
  include/llvm/IR/IntrinsicsAArch64.td
  lib/Target/AArch64/AArch64InstrFormats.td
  lib/Target/AArch64/AArch64SVEInstrInfo.td
  lib/Target/AArch64/SVEInstrFormats.td
  test/CodeGen/AArch64/sve-intrinsics-int-arith.ll

Index: test/CodeGen/AArch64/sve-intrinsics-int-arith.ll
===
--- test/CodeGen/AArch64/sve-intrinsics-int-arith.ll
+++ test/CodeGen/AArch64/sve-intrinsics-int-arith.ll
@@ -88,6 +88,87 @@
   ret  %out
 }
 
+; SDOT
+
+define  @sdot_i32( %a,  %b,  %c) {
+; CHECK-LABEL: sdot_i32:
+; CHECK: sdot z0.s, z1.b, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sdot.nxv4i32( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @sdot_i64( %a,  %b,  %c) {
+; CHECK-LABEL: sdot_i64:
+; CHECK: sdot z0.d, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sdot.nxv2i64( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+; SDOT (Indexed)
+
+define  @sdot_lane_i32( %a,  %b,  %c) {
+; CHECK-LABEL: sdot_lane_i32:
+; CHECK: sdot z0.s, z1.b, z2.b[2]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sdot.lane.nxv4i32( %a,
+  %b,
+  %c,
+ i32 2)
+  ret  %out
+}
+
+define  @sdot_lane_i64( %a,  %b,  %c) {
+; CHECK-LABEL: sdot_lane_i64:
+; CHECK: sdot z0.d, z1.h, z2.h[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sdot.lane.nxv2i64( %a,
+  %b,
+  %c,
+ i32 1)
+  ret  %out
+}
+
+; UDOT
+
+define  @udot_i32( %a,  %b,  %c) {
+; CHECK-LABEL: udot_i32:
+; CHECK: udot z0.s, z1.b, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.udot.nxv4i32( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @udot_i64( %a,  %b,  %c) {
+; CHECK-LABEL: udot_i64:
+; CHECK: udot z0.d, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.udot.nxv2i64( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+; UDOT (Indexed)
+
+define  @udot_lane_i32( %a,  %b,  %c) {
+; CHECK-LABEL: udot_lane_i32:
+; CHECK: udot z0.s, z1.b, z2.b[2]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.udot.lane.nxv4i32( %a,
+  %b,
+  %c,
+ i32 2)
+  ret  %out
+}
+
 declare  @llvm.aarch64.sve.abs.nxv16i8(, , )
 declare  @llvm.aarch64.sve.abs.nxv8i16(, , )
 declare  @llvm.aarch64.sve.abs.nxv4i32(, , )
@@ -97,3 +178,15 @@
 declare  @llvm.aarch64.sve.neg.nxv8i16(, , )
 declare  @llvm.aarch64.sve.neg.nxv4i32(, , )
 declare  @llvm.aarch64.sve.neg.nxv2i64(, , )
+
+declare  @llvm.aarch64.sve.sdot.nxv4i32(, , )
+declare  @llvm.aarch64.sve.sdot.nxv2i64(, , )
+
+declare  @llvm.aarch64.sve.sdot.lane.nxv4i32(, , , i32)
+declare  @llvm.aarch64.sve.sdot.lane.nxv2i64(, , , i32)
+
+declare  @llvm.aarch64.sve.udot.nxv4i32(, , )
+declare  @llvm.aarch64.sve.udot.nxv2i64(, , )
+
+declare  @llvm.aarch64.sve.udot.lane.nxv4i32(, , , i32)
+declare  @llvm.aarch64.sve.udot.lane.nxv2i64(, , , i32)
Index: lib/Target/AArch64/SVEInstrFormats.td
===
--- lib/Target/AArch64/SVEInstrFormats.td
+++ lib/Target/AArch64/SVEInstrFormats.td
@@ -2017,12 +2017,14 @@
 
   let Constraints = "$Zda = $_Zda";
   let DestructiveInstType = Destructive;
-  let ElementSize = zprty1.ElementSize;
 }
 
-multiclass sve_intx_dot {
+multiclass sve_intx_dot {
   def _S : sve_intx_dot<0b0, opc, asm, ZPR32, ZPR8>;
   def _D : sve_intx_dot<0b1, opc, asm, ZPR64, ZPR16>;
+
+  def 

[PATCH] D67550: [AArch64][SVE] Implement unpack intrinsics

2019-09-13 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, SjoerdMeijer, greened.
Herald added subscribers: psnobl, rkruppe, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
kmclaughlin added a parent revision: D67549: [IntrinsicEmitter] Add overloaded 
types for SVE intrinsics (Subdivide2 & Subdivide4).

Implements the following intrinsics:

- int_aarch64_sve_sunpkhi
- int_aarch64_sve_sunpklo
- int_aarch64_sve_uunpkhi
- int_aarch64_sve_uunpklo

This patch also adds AArch64ISD nodes for UNPK instead of implementing
the intrinsics directly, as they are required for a future patch which
implements the sign/zero extension of legal vectors.

This patch includes tests for the Subdivide2Argument type added by D67549 



https://reviews.llvm.org/D67550

Files:
  include/llvm/IR/IntrinsicsAArch64.td
  lib/Target/AArch64/AArch64ISelLowering.cpp
  lib/Target/AArch64/AArch64ISelLowering.h
  lib/Target/AArch64/AArch64InstrInfo.td
  lib/Target/AArch64/AArch64SVEInstrInfo.td
  lib/Target/AArch64/SVEInstrFormats.td
  test/CodeGen/AArch64/sve-intrinsics-perm-select.ll

Index: test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
===
--- /dev/null
+++ test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
@@ -0,0 +1,129 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; SUNPKHI
+;
+
+define  @sunpkhi_i16( %a) {
+; CHECK-LABEL: sunpkhi_i16
+; CHECK: sunpkhi z0.h, z0.b
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.sunpkhi.nxv8i16( %a)
+  ret  %res
+}
+
+define  @sunpkhi_i32( %a) {
+; CHECK-LABEL: sunpkhi_i32
+; CHECK: sunpkhi z0.s, z0.h
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.sunpkhi.nxv4i32( %a)
+  ret  %res
+}
+
+define  @sunpkhi_i64( %a) {
+; CHECK-LABEL:  sunpkhi_i64
+; CHECK: sunpkhi z0.d, z0.s
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.sunpkhi.nxv2i64( %a)
+  ret  %res
+}
+
+;
+; SUNPKLO
+;
+
+define  @sunpklo_i16( %a) {
+; CHECK-LABEL: sunpklo_i16
+; CHECK: sunpklo z0.h, z0.b
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.sunpklo.nxv8i16( %a)
+  ret  %res
+}
+
+define  @sunpklo_i32( %a) {
+; CHECK-LABEL: sunpklo_i32
+; CHECK: sunpklo z0.s, z0.h
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.sunpklo.nxv4i32( %a)
+  ret  %res
+}
+
+define  @sunpklo_i64( %a) {
+; CHECK-LABEL:  sunpklo_i64
+; CHECK: sunpklo z0.d, z0.s
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.sunpklo.nxv2i64( %a)
+  ret  %res
+}
+
+;
+; UUNPKHI
+;
+
+define  @uunpkhi_i16( %a) {
+; CHECK-LABEL: uunpkhi_i16
+; CHECK: uunpkhi z0.h, z0.b
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.uunpkhi.nxv8i16( %a)
+  ret  %res
+}
+
+define  @uunpkhi_i32( %a) {
+; CHECK-LABEL: uunpkhi_i32
+; CHECK: uunpkhi z0.s, z0.h
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.uunpkhi.nxv4i32( %a)
+  ret  %res
+}
+
+define  @uunpkhi_i64( %a) {
+; CHECK-LABEL:  uunpkhi_i64
+; CHECK: uunpkhi z0.d, z0.s
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.uunpkhi.nxv2i64( %a)
+  ret  %res
+}
+
+;
+; UUNPKLO
+;
+
+define  @uunpklo_i16( %a) {
+; CHECK-LABEL: uunpklo_i16
+; CHECK: uunpklo z0.h, z0.b
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.uunpklo.nxv8i16( %a)
+  ret  %res
+}
+
+define  @uunpklo_i32( %a) {
+; CHECK-LABEL: uunpklo_i32
+; CHECK: uunpklo z0.s, z0.h
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.uunpklo.nxv4i32( %a)
+  ret  %res
+}
+
+define  @uunpklo_i64( %a) {
+; CHECK-LABEL:  uunpklo_i64
+; CHECK: uunpklo z0.d, z0.s
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.uunpklo.nxv2i64( %a)
+  ret  %res
+}
+
+declare  @llvm.aarch64.sve.sunpkhi.nxv8i16()
+declare  @llvm.aarch64.sve.sunpkhi.nxv4i32()
+declare  @llvm.aarch64.sve.sunpkhi.nxv2i64()
+
+declare  @llvm.aarch64.sve.sunpklo.nxv8i16()
+declare  @llvm.aarch64.sve.sunpklo.nxv4i32()
+declare  @llvm.aarch64.sve.sunpklo.nxv2i64()
+
+declare  @llvm.aarch64.sve.uunpkhi.nxv8i16()
+declare  @llvm.aarch64.sve.uunpkhi.nxv4i32()
+declare  @llvm.aarch64.sve.uunpkhi.nxv2i64()
+
+declare  @llvm.aarch64.sve.uunpklo.nxv8i16()
+declare  @llvm.aarch64.sve.uunpklo.nxv4i32()
+declare  @llvm.aarch64.sve.uunpklo.nxv2i64()
Index: lib/Target/AArch64/SVEInstrFormats.td
===
--- lib/Target/AArch64/SVEInstrFormats.td
+++ lib/Target/AArch64/SVEInstrFormats.td
@@ -283,6 +283,11 @@
 // SVE pattern match helpers.
 //===--===//
 
+class SVE_1_Op_Pat
+: Pat<(vtd (op vt1:$Op1)),
+  (inst $Op1)>;
+
 class SVE_3_Op_Pat
 : Pat<(vtd (op vt1:$Op1, vt2:$Op2, vt3:$Op3)),
@@ -828,7 +833,7 @@
 }
 
 class sve_int_perm_unpk sz16_64, bits<2> opc, string asm,
-ZPRRegOp zprty1, ZPRRegOp zprty2>
+ZPRRegOp zprty1, ZPRRegOp zprty2, SDPatternOperator op>
 : I<(outs zprty1:$Zd), (ins zprty2:$Zn),
   asm, "\t$Zd, $Zn",
   "", []>, Sched<[]> {
@@ -843,10 +848,14 @@
   

[PATCH] D67549: [IntrinsicEmitter] Add overloaded types for SVE intrinsics (Subdivide2 & Subdivide4)

2019-09-13 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, SjoerdMeijer, greened.
Herald added subscribers: jdoerfert, tschuett.
Herald added a project: LLVM.

Both match the type of another intrinsic parameter of a vector type, but where 
each element is subdivided to form a vector with more elements of a smaller 
type.

Subdivide2Argument allows intrinsics such as the following to be defined:

- declare  @llvm.something.nxv4i32()

Subdivide4Argument allows intrinsics such as:

- declare  @llvm.something.nxv4i32()

Tests are included in follow up patches which add intrinsics using these types.


Repository:
  rL LLVM

https://reviews.llvm.org/D67549

Files:
  include/llvm/IR/DerivedTypes.h
  include/llvm/IR/Intrinsics.h
  include/llvm/IR/Intrinsics.td
  lib/IR/Function.cpp
  utils/TableGen/IntrinsicEmitter.cpp

Index: utils/TableGen/IntrinsicEmitter.cpp
===
--- utils/TableGen/IntrinsicEmitter.cpp
+++ utils/TableGen/IntrinsicEmitter.cpp
@@ -221,7 +221,9 @@
   IIT_STRUCT8 = 40,
   IIT_F128 = 41,
   IIT_VEC_ELEMENT = 42,
-  IIT_SCALABLE_VEC = 43
+  IIT_SCALABLE_VEC = 43,
+  IIT_SUBDIVIDE2_ARG = 44,
+  IIT_SUBDIVIDE4_ARG = 45
 };
 
 static void EncodeFixedValueType(MVT::SimpleValueType VT,
@@ -293,6 +295,10 @@
   Sig.push_back(IIT_PTR_TO_ELT);
 else if (R->isSubClassOf("LLVMVectorElementType"))
   Sig.push_back(IIT_VEC_ELEMENT);
+else if (R->isSubClassOf("LLVMSubdivide2VectorType"))
+  Sig.push_back(IIT_SUBDIVIDE2_ARG);
+else if (R->isSubClassOf("LLVMSubdivide4VectorType"))
+  Sig.push_back(IIT_SUBDIVIDE4_ARG);
 else
   Sig.push_back(IIT_ARG);
 return Sig.push_back((Number << 3) | 7 /*IITDescriptor::AK_MatchType*/);
Index: lib/IR/Function.cpp
===
--- lib/IR/Function.cpp
+++ lib/IR/Function.cpp
@@ -703,7 +703,9 @@
   IIT_STRUCT8 = 40,
   IIT_F128 = 41,
   IIT_VEC_ELEMENT = 42,
-  IIT_SCALABLE_VEC = 43
+  IIT_SCALABLE_VEC = 43,
+  IIT_SUBDIVIDE2_ARG = 44,
+  IIT_SUBDIVIDE4_ARG = 45
 };
 
 static void DecodeIITType(unsigned , ArrayRef Infos,
@@ -868,6 +870,18 @@
   DecodeIITType(NextElt, Infos, OutputTable);
 return;
   }
+  case IIT_SUBDIVIDE2_ARG: {
+unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
+OutputTable.push_back(IITDescriptor::get(IITDescriptor::Subdivide2Argument,
+ ArgInfo));
+return;
+  }
+  case IIT_SUBDIVIDE4_ARG: {
+unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
+OutputTable.push_back(IITDescriptor::get(IITDescriptor::Subdivide4Argument,
+ ArgInfo));
+return;
+  }
   case IIT_VEC_ELEMENT: {
 unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
 OutputTable.push_back(IITDescriptor::get(IITDescriptor::VecElementArgument,
@@ -970,6 +984,18 @@
 assert(ITy->getBitWidth() % 2 == 0);
 return IntegerType::get(Context, ITy->getBitWidth() / 2);
   }
+  case IITDescriptor::Subdivide2Argument: {
+Type *Ty = Tys[D.getArgumentNumber()];
+if (VectorType *VTy = dyn_cast(Ty))
+  return VectorType::getSubdividedVectorType(VTy, 1);
+llvm_unreachable("unhandled");
+  }
+  case IITDescriptor::Subdivide4Argument: {
+Type *Ty = Tys[D.getArgumentNumber()];
+if (VectorType *VTy = dyn_cast(Ty))
+  return VectorType::getSubdividedVectorType(VTy, 2);
+llvm_unreachable("unhandled");
+  }
   case IITDescriptor::HalfVecArgument:
 return VectorType::getHalfElementsVectorType(cast(
   Tys[D.getArgumentNumber()]));
@@ -1269,6 +1295,32 @@
   auto *ReferenceType = dyn_cast(ArgTys[D.getArgumentNumber()]);
   return !ReferenceType || Ty != ReferenceType->getElementType();
 }
+case IITDescriptor::Subdivide2Argument: {
+  // This may only be used when referring to a previous vector argument.
+  if (D.getArgumentNumber() >= ArgTys.size())
+return IsDeferredCheck || DeferCheck(Ty);
+
+  Type *NewTy = ArgTys[D.getArgumentNumber()];
+  if (VectorType *VTy = dyn_cast(NewTy))
+NewTy = VectorType::getSubdividedVectorType(VTy, 1);
+  else
+return true;
+
+  return Ty != NewTy;
+}
+case IITDescriptor::Subdivide4Argument: {
+  // This may only be used when referring to a previous vector argument.
+  if (D.getArgumentNumber() >= ArgTys.size())
+return IsDeferredCheck || DeferCheck(Ty);
+
+  Type *NewTy = ArgTys[D.getArgumentNumber()];
+  if (VectorType *VTy = dyn_cast(NewTy))
+NewTy = VectorType::getSubdividedVectorType(VTy, 2);
+  else
+return true;
+
+  return Ty != NewTy;
+}
 case IITDescriptor::ScalableVecArgument: {
   VectorType *VTy = dyn_cast(Ty);
   if (!VTy || !VTy->isScalable())
Index: include/llvm/IR/Intrinsics.td

[PATCH] D67246: clang-format: Add support for formatting lambdas with explicit template parameters.

2019-09-13 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG41f4d68a50be: clang-format: Add support for formatting 
(some) lambdas with explicit template… (authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67246

Files:
  clang/lib/Format/TokenAnnotator.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
@@ -12923,6 +12923,10 @@
"  return 1; //\n"
"};");
 
+  // Lambdas with explicit template argument lists.
+  verifyFormat(
+  "auto L = [] class T, class U>(T &) {};\n");
+
   // Multiple lambdas in the same parentheses change indentation rules. These
   // lambdas are forced to start on new lines.
   verifyFormat("SomeFunction(\n"
@@ -12940,8 +12944,8 @@
"},\n"
"1);\n");
 
-  // A multi-line lambda passed as arg1 forces arg0 to be pushed out, just 
like the arg0
-  // case above.
+  // A multi-line lambda passed as arg1 forces arg0 to be pushed out, just like
+  // the arg0 case above.
   auto Style = getGoogleStyle();
   Style.BinPackArguments = false;
   verifyFormat("SomeFunction(\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1440,8 +1440,11 @@
 case tok::identifier:
 case tok::numeric_constant:
 case tok::coloncolon:
+case tok::kw_class:
 case tok::kw_mutable:
 case tok::kw_noexcept:
+case tok::kw_template:
+case tok::kw_typename:
   nextToken();
   break;
 // Specialization of a template with an integer parameter can contain
@@ -1455,6 +1458,9 @@
 // followed by an `a->b` expression, such as:
 // ([obj func:arg] + a->b)
 // Otherwise the code below would parse as a lambda.
+//
+// FIXME: This heuristic is incorrect for C++20 generic lambdas with
+// explicit template lists: [](U &){}
 case tok::plus:
 case tok::minus:
 case tok::exclaim:
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -40,6 +40,21 @@
   return Tok.Tok.getIdentifierInfo() != nullptr;
 }
 
+/// With `Left` being '(', check if we're at either `[...](` or
+/// `[...]<...>(`, where the [ opens a lambda capture list.
+static bool isLambdaParameterList(const FormatToken *Left) {
+  // Skip <...> if present.
+  if (Left->Previous && Left->Previous->is(tok::greater) &&
+  Left->Previous->MatchingParen &&
+  Left->Previous->MatchingParen->is(TT_TemplateOpener))
+Left = Left->Previous->MatchingParen;
+
+  // Check for `[...]`.
+  return Left->Previous && Left->Previous->is(tok::r_square) &&
+ Left->Previous->MatchingParen &&
+ Left->Previous->MatchingParen->is(TT_LambdaLSquare);
+}
+
 /// A parser that gathers additional information about tokens.
 ///
 /// The \c TokenAnnotator tries to match parenthesis and square brakets and
@@ -191,9 +206,7 @@
Left->Previous->is(TT_JsTypeColon)) {
   // let x: (SomeType);
   Contexts.back().IsExpression = false;
-} else if (Left->Previous && Left->Previous->is(tok::r_square) &&
-   Left->Previous->MatchingParen &&
-   Left->Previous->MatchingParen->is(TT_LambdaLSquare)) {
+} else if (isLambdaParameterList(Left)) {
   // This is a parameter list of a lambda expression.
   Contexts.back().IsExpression = false;
 } else if (Line.InPPDirective &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12923,6 +12923,10 @@
"  return 1; //\n"
"};");
 
+  // Lambdas with explicit template argument lists.
+  verifyFormat(
+  "auto L = [] class T, class U>(T &) {};\n");
+
   // Multiple lambdas in the same parentheses change indentation rules. These
   // lambdas are forced to start on new lines.
   verifyFormat("SomeFunction(\n"
@@ -12940,8 +12944,8 @@
"},\n"
"1);\n");
 
-  // A multi-line lambda passed as arg1 forces arg0 to be pushed out, just like the arg0
-  // case above.
+  // A multi-line lambda passed as arg1 forces arg0 to be pushed out, just like
+  // the arg0 case above.
   auto Style = getGoogleStyle();
   Style.BinPackArguments = false;
   verifyFormat("SomeFunction(\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp

r371854 - clang-format: Add support for formatting (some) lambdas with explicit template parameters.

2019-09-13 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Sep 13 06:18:55 2019
New Revision: 371854

URL: http://llvm.org/viewvc/llvm-project?rev=371854=rev
Log:
clang-format: Add support for formatting (some) lambdas with explicit template 
parameters.

This patch makes cases work where the lambda's template list doesn't
contain any of + - ! ~ / % << | || && ^ == != >= <= ? : true false
(see added FIXME).

Ports r359967 to clang-format.

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=371854=371853=371854=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Sep 13 06:18:55 2019
@@ -40,6 +40,21 @@ static bool canBeObjCSelectorComponent(c
   return Tok.Tok.getIdentifierInfo() != nullptr;
 }
 
+/// With `Left` being '(', check if we're at either `[...](` or
+/// `[...]<...>(`, where the [ opens a lambda capture list.
+static bool isLambdaParameterList(const FormatToken *Left) {
+  // Skip <...> if present.
+  if (Left->Previous && Left->Previous->is(tok::greater) &&
+  Left->Previous->MatchingParen &&
+  Left->Previous->MatchingParen->is(TT_TemplateOpener))
+Left = Left->Previous->MatchingParen;
+
+  // Check for `[...]`.
+  return Left->Previous && Left->Previous->is(tok::r_square) &&
+ Left->Previous->MatchingParen &&
+ Left->Previous->MatchingParen->is(TT_LambdaLSquare);
+}
+
 /// A parser that gathers additional information about tokens.
 ///
 /// The \c TokenAnnotator tries to match parenthesis and square brakets and
@@ -191,9 +206,7 @@ private:
Left->Previous->is(TT_JsTypeColon)) {
   // let x: (SomeType);
   Contexts.back().IsExpression = false;
-} else if (Left->Previous && Left->Previous->is(tok::r_square) &&
-   Left->Previous->MatchingParen &&
-   Left->Previous->MatchingParen->is(TT_LambdaLSquare)) {
+} else if (isLambdaParameterList(Left)) {
   // This is a parameter list of a lambda expression.
   Contexts.back().IsExpression = false;
 } else if (Line.InPPDirective &&

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=371854=371853=371854=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Sep 13 06:18:55 2019
@@ -1440,8 +1440,11 @@ bool UnwrappedLineParser::tryToParseLamb
 case tok::identifier:
 case tok::numeric_constant:
 case tok::coloncolon:
+case tok::kw_class:
 case tok::kw_mutable:
 case tok::kw_noexcept:
+case tok::kw_template:
+case tok::kw_typename:
   nextToken();
   break;
 // Specialization of a template with an integer parameter can contain
@@ -1455,6 +1458,9 @@ bool UnwrappedLineParser::tryToParseLamb
 // followed by an `a->b` expression, such as:
 // ([obj func:arg] + a->b)
 // Otherwise the code below would parse as a lambda.
+//
+// FIXME: This heuristic is incorrect for C++20 generic lambdas with
+// explicit template lists: [](U &){}
 case tok::plus:
 case tok::minus:
 case tok::exclaim:

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=371854=371853=371854=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Sep 13 06:18:55 2019
@@ -12923,6 +12923,10 @@ TEST_F(FormatTest, FormatsLambdas) {
"  return 1; //\n"
"};");
 
+  // Lambdas with explicit template argument lists.
+  verifyFormat(
+  "auto L = [] class T, class U>(T &) {};\n");
+
   // Multiple lambdas in the same parentheses change indentation rules. These
   // lambdas are forced to start on new lines.
   verifyFormat("SomeFunction(\n"
@@ -12940,8 +12944,8 @@ TEST_F(FormatTest, FormatsLambdas) {
"},\n"
"1);\n");
 
-  // A multi-line lambda passed as arg1 forces arg0 to be pushed out, just 
like the arg0
-  // case above.
+  // A multi-line lambda passed as arg1 forces arg0 to be pushed out, just like
+  // the arg0 case above.
   auto Style = getGoogleStyle();
   Style.BinPackArguments = false;
   verifyFormat("SomeFunction(\n"


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


[PATCH] D67542: Fix depfile name construction

2019-09-13 Thread Luke Cheeseman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371853: Fix depfile name construction (authored by 
LukeCheeseman, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67542?vs=220067=220083#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67542

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/metadata-with-dots.c


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -6066,15 +6066,14 @@
 const char *Clang::getDependencyFileName(const ArgList ,
  const InputInfoList ) {
   // FIXME: Think about this more.
-  std::string Res;
 
   if (Arg *OutputOpt = Args.getLastArg(options::OPT_o)) {
-std::string Str(OutputOpt->getValue());
-Res = Str.substr(0, Str.rfind('.'));
-  } else {
-Res = getBaseInputStem(Args, Inputs);
+SmallString<128> OutputFilename(OutputOpt->getValue());
+llvm::sys::path::replace_extension(OutputFilename, llvm::Twine('d'));
+return Args.MakeArgString(OutputFilename);
   }
-  return Args.MakeArgString(Res + ".d");
+
+  return Args.MakeArgString(std::string(getBaseInputStem(Args, Inputs)) + 
".d");
 }
 
 // Begin ClangAs
Index: cfe/trunk/test/Driver/metadata-with-dots.c
===
--- cfe/trunk/test/Driver/metadata-with-dots.c
+++ cfe/trunk/test/Driver/metadata-with-dots.c
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+// RUN: mkdir -p out.dir
+// RUN: cat %s > out.dir/test.c
+// RUN: %clang -E -MMD %s -o out.dir/test
+// RUN: test ! -f %out.d
+// RUN: test -f out.dir/test.d
+// RUN: rm -rf out.dir/test.d out.dir/ out.d
+int main (void)
+{
+return 0;
+}


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -6066,15 +6066,14 @@
 const char *Clang::getDependencyFileName(const ArgList ,
  const InputInfoList ) {
   // FIXME: Think about this more.
-  std::string Res;
 
   if (Arg *OutputOpt = Args.getLastArg(options::OPT_o)) {
-std::string Str(OutputOpt->getValue());
-Res = Str.substr(0, Str.rfind('.'));
-  } else {
-Res = getBaseInputStem(Args, Inputs);
+SmallString<128> OutputFilename(OutputOpt->getValue());
+llvm::sys::path::replace_extension(OutputFilename, llvm::Twine('d'));
+return Args.MakeArgString(OutputFilename);
   }
-  return Args.MakeArgString(Res + ".d");
+
+  return Args.MakeArgString(std::string(getBaseInputStem(Args, Inputs)) + ".d");
 }
 
 // Begin ClangAs
Index: cfe/trunk/test/Driver/metadata-with-dots.c
===
--- cfe/trunk/test/Driver/metadata-with-dots.c
+++ cfe/trunk/test/Driver/metadata-with-dots.c
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+// RUN: mkdir -p out.dir
+// RUN: cat %s > out.dir/test.c
+// RUN: %clang -E -MMD %s -o out.dir/test
+// RUN: test ! -f %out.d
+// RUN: test -f out.dir/test.d
+// RUN: rm -rf out.dir/test.d out.dir/ out.d
+int main (void)
+{
+return 0;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371853 - Fix depfile name construction

2019-09-13 Thread Luke Cheeseman via cfe-commits
Author: lukecheeseman
Date: Fri Sep 13 06:15:35 2019
New Revision: 371853

URL: http://llvm.org/viewvc/llvm-project?rev=371853=rev
Log:
Fix depfile name construction

- When using -o, the provided filename is using for constructing the depfile
  name (when -MMD is passed).
- The logic looks for the rightmost '.' character and replaces what comes after
  with 'd'.
- This works incorrectly when the filename has no extension and the directories
  have '.' in them (e.g. out.dir/test)
- This replaces the funciton to just llvm::sys::path functionality

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


Added:
cfe/trunk/test/Driver/metadata-with-dots.c
Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=371853=371852=371853=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Sep 13 06:15:35 2019
@@ -6066,15 +6066,14 @@ const char *Clang::getBaseInputStem(cons
 const char *Clang::getDependencyFileName(const ArgList ,
  const InputInfoList ) {
   // FIXME: Think about this more.
-  std::string Res;
 
   if (Arg *OutputOpt = Args.getLastArg(options::OPT_o)) {
-std::string Str(OutputOpt->getValue());
-Res = Str.substr(0, Str.rfind('.'));
-  } else {
-Res = getBaseInputStem(Args, Inputs);
+SmallString<128> OutputFilename(OutputOpt->getValue());
+llvm::sys::path::replace_extension(OutputFilename, llvm::Twine('d'));
+return Args.MakeArgString(OutputFilename);
   }
-  return Args.MakeArgString(Res + ".d");
+
+  return Args.MakeArgString(std::string(getBaseInputStem(Args, Inputs)) + 
".d");
 }
 
 // Begin ClangAs

Added: cfe/trunk/test/Driver/metadata-with-dots.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/metadata-with-dots.c?rev=371853=auto
==
--- cfe/trunk/test/Driver/metadata-with-dots.c (added)
+++ cfe/trunk/test/Driver/metadata-with-dots.c Fri Sep 13 06:15:35 2019
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+// RUN: mkdir -p out.dir
+// RUN: cat %s > out.dir/test.c
+// RUN: %clang -E -MMD %s -o out.dir/test
+// RUN: test ! -f %out.d
+// RUN: test -f out.dir/test.d
+// RUN: rm -rf out.dir/test.d out.dir/ out.d
+int main (void)
+{
+return 0;
+}


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


[PATCH] D66336: [ASTImporter] Add development internals docs

2019-09-13 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371839: [ASTImporter] Add development internals docs 
(authored by martong, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66336?vs=217171=220077#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66336

Files:
  cfe/trunk/docs/InternalsManual.rst

Index: cfe/trunk/docs/InternalsManual.rst
===
--- cfe/trunk/docs/InternalsManual.rst
+++ cfe/trunk/docs/InternalsManual.rst
@@ -1447,6 +1447,495 @@
 are not ``Redeclarable`` -- in that case, a ``Mergeable`` base class is used
 instead).
 
+The ASTImporter
+---
+
+The ``ASTImporter`` class imports nodes of an ``ASTContext`` into another
+``ASTContext``. Please refer to the document :doc:`ASTImporter: Merging Clang
+ASTs ` for an introduction. And please read through the
+high-level `description of the import algorithm
+`_, this is essential for
+understanding further implementation details of the importer.
+
+.. _templated:
+
+Abstract Syntax Graph
+^
+
+Despite the name, the Clang AST is not a tree. It is a directed graph with
+cycles. One example of a cycle is the connection between a
+``ClassTemplateDecl`` and its "templated" ``CXXRecordDecl``. The *templated*
+``CXXRecordDecl`` represents all the fields and methods inside the class
+template, while the ``ClassTemplateDecl`` holds the information which is
+related to being a template, i.e. template arguments, etc. We can get the
+*templated* class (the ``CXXRecordDecl``) of a ``ClassTemplateDecl`` with
+``ClassTemplateDecl::getTemplatedDecl()``. And we can get back a pointer of the
+"described" class template from the *templated* class:
+``CXXRecordDecl::getDescribedTemplate()``. So, this is a cycle between two
+nodes: between the *templated* and the *described* node. There may be various
+other kinds of cycles in the AST especially in case of declarations.
+
+.. _structural-eq:
+
+Structural Equivalency
+^^
+
+Importing one AST node copies that node into the destination ``ASTContext``. To
+copy one node means that we create a new node in the "to" context then we set
+its properties to be equal to the properties of the source node. Before the
+copy, we make sure that the source node is not *structurally equivalent* to any
+existing node in the destination context. If it happens to be equivalent then
+we skip the copy.
+
+The informal definition of structural equivalency is the following:
+Two nodes are **structurally equivalent** if they are
+
+- builtin types and refer to the same type, e.g. ``int`` and ``int`` are
+  structurally equivalent,
+- function types and all their parameters have structurally equivalent types,
+- record types and all their fields in order of their definition have the same
+  identifier names and structurally equivalent types,
+- variable or function declarations and they have the same identifier name and
+  their types are structurally equivalent.
+
+In C, two types are structurally equivalent if they are *compatible types*. For
+a formal definition of *compatible types*, please refer to 6.2.7/1 in the C11
+standard. However, there is no definition for *compatible types* in the C++
+standard. Still, we extend the definition of structural equivalency to
+templates and their instantiations similarly: besides checking the previously
+mentioned properties, we have to check for equivalent template
+parameters/arguments, etc.
+
+The structural equivalent check can be and is used independently from the
+ASTImporter, e.g. the ``clang::Sema`` class uses it also.
+
+The equivalence of nodes may depend on the equivalency of other pairs of nodes.
+Thus, the check is implemented as a parallel graph traversal. We traverse
+through the nodes of both graphs at the same time. The actual implementation is
+similar to breadth-first-search. Let's say we start the traverse with the 
+pair of nodes. Whenever the traversal reaches a pair  then the following
+statements are true:
+
+- A and X are nodes from the same ASTContext.
+- B and Y are nodes from the same ASTContext.
+- A and B may or may not be from the same ASTContext.
+- if A == X (pointer equivalency) then (there is a cycle during the traverse)
+
+  - A and B are structurally equivalent if and only if
+
+- B and Y are part of the same redeclaration chain,
+- All dependent nodes on the path from  to  are structurally
+  equivalent.
+
+When we compare two classes or enums and one of them is incomplete or has
+unloaded external lexical declarations then we cannot descend to compare their
+contained declarations. So in these cases they are considered equal if they
+have the same names. This is the way how we compare forward declarations with
+definitions.
+
+.. TODO 

r371839 - [ASTImporter] Add development internals docs

2019-09-13 Thread Gabor Marton via cfe-commits
Author: martong
Date: Fri Sep 13 04:21:52 2019
New Revision: 371839

URL: http://llvm.org/viewvc/llvm-project?rev=371839=rev
Log:
[ASTImporter] Add development internals docs

Reviewers: a_sidorin, shafik, teemperor, gamesh411, balazske, dkrupp, a.sidorin

Subscribers: rnkovacs, Szelethus, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/docs/InternalsManual.rst

Modified: cfe/trunk/docs/InternalsManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/InternalsManual.rst?rev=371839=371838=371839=diff
==
--- cfe/trunk/docs/InternalsManual.rst (original)
+++ cfe/trunk/docs/InternalsManual.rst Fri Sep 13 04:21:52 2019
@@ -1447,6 +1447,495 @@ or by simply a pointer to the canonical
 are not ``Redeclarable`` -- in that case, a ``Mergeable`` base class is used
 instead).
 
+The ASTImporter
+---
+
+The ``ASTImporter`` class imports nodes of an ``ASTContext`` into another
+``ASTContext``. Please refer to the document :doc:`ASTImporter: Merging Clang
+ASTs ` for an introduction. And please read through the
+high-level `description of the import algorithm
+`_, this is essential for
+understanding further implementation details of the importer.
+
+.. _templated:
+
+Abstract Syntax Graph
+^
+
+Despite the name, the Clang AST is not a tree. It is a directed graph with
+cycles. One example of a cycle is the connection between a
+``ClassTemplateDecl`` and its "templated" ``CXXRecordDecl``. The *templated*
+``CXXRecordDecl`` represents all the fields and methods inside the class
+template, while the ``ClassTemplateDecl`` holds the information which is
+related to being a template, i.e. template arguments, etc. We can get the
+*templated* class (the ``CXXRecordDecl``) of a ``ClassTemplateDecl`` with
+``ClassTemplateDecl::getTemplatedDecl()``. And we can get back a pointer of the
+"described" class template from the *templated* class:
+``CXXRecordDecl::getDescribedTemplate()``. So, this is a cycle between two
+nodes: between the *templated* and the *described* node. There may be various
+other kinds of cycles in the AST especially in case of declarations.
+
+.. _structural-eq:
+
+Structural Equivalency
+^^
+
+Importing one AST node copies that node into the destination ``ASTContext``. To
+copy one node means that we create a new node in the "to" context then we set
+its properties to be equal to the properties of the source node. Before the
+copy, we make sure that the source node is not *structurally equivalent* to any
+existing node in the destination context. If it happens to be equivalent then
+we skip the copy.
+
+The informal definition of structural equivalency is the following:
+Two nodes are **structurally equivalent** if they are
+
+- builtin types and refer to the same type, e.g. ``int`` and ``int`` are
+  structurally equivalent,
+- function types and all their parameters have structurally equivalent types,
+- record types and all their fields in order of their definition have the same
+  identifier names and structurally equivalent types,
+- variable or function declarations and they have the same identifier name and
+  their types are structurally equivalent.
+
+In C, two types are structurally equivalent if they are *compatible types*. For
+a formal definition of *compatible types*, please refer to 6.2.7/1 in the C11
+standard. However, there is no definition for *compatible types* in the C++
+standard. Still, we extend the definition of structural equivalency to
+templates and their instantiations similarly: besides checking the previously
+mentioned properties, we have to check for equivalent template
+parameters/arguments, etc.
+
+The structural equivalent check can be and is used independently from the
+ASTImporter, e.g. the ``clang::Sema`` class uses it also.
+
+The equivalence of nodes may depend on the equivalency of other pairs of nodes.
+Thus, the check is implemented as a parallel graph traversal. We traverse
+through the nodes of both graphs at the same time. The actual implementation is
+similar to breadth-first-search. Let's say we start the traverse with the 
+pair of nodes. Whenever the traversal reaches a pair  then the following
+statements are true:
+
+- A and X are nodes from the same ASTContext.
+- B and Y are nodes from the same ASTContext.
+- A and B may or may not be from the same ASTContext.
+- if A == X (pointer equivalency) then (there is a cycle during the traverse)
+
+  - A and B are structurally equivalent if and only if
+
+- B and Y are part of the same redeclaration chain,
+- All dependent nodes on the path from  to  are structurally
+  equivalent.
+
+When we compare two classes or enums and one of them is incomplete or has
+unloaded external lexical declarations then we cannot descend to compare their
+contained declarations. So in these cases they are considered equal 

[PATCH] D67358: [clangd] Implement semantic selections.

2019-09-13 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 220075.
usaxena95 added a comment.

Remove extraneous namespace comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67358

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/SemanticSelection.cpp
  clang-tools-extra/clangd/SemanticSelection.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -0,0 +1,143 @@
+//===-- SemanticSelectionTests.cpp  *- 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
+//
+//===--===//
+
+#include "Annotations.h"
+#include "Matchers.h"
+#include "Protocol.h"
+#include "SemanticSelection.h"
+#include "SourceCode.h"
+#include "TestTU.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "llvm/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+namespace clang {
+namespace clangd {
+namespace {
+using ::testing::ElementsAreArray;
+
+TEST(SemanticSelection, All) {
+  const char *Tests[] = {
+  R"cpp( // Single statement in a function body.
+[[void func() [[{
+  int v = [[1^00;]]
+}
+  )cpp",
+  R"cpp( // Expression
+[[void func() [[{
+  int a = 1;
+  // int v = (10 + 2) * (a + a);
+  int v = (10^]] + 2]])]] * (a + a);]]
+}
+  )cpp",
+  R"cpp( // Function call.
+int add(int x, int y) { return x + y; }
+[[void callee() [[{
+  // int res = add(11, 22);
+  int res = [[add([[1^1]], 22);]]
+}
+  )cpp",
+  R"cpp( // Tricky macros.
+#define MUL ) * (
+[[void func() [[{
+  // int var = (4 + 15 MUL 6 + 10);
+  int var = ([[4 + [[1^5 MUL]] 6 + 10);]]
+}
+   )cpp",
+  R"cpp( // Cursor inside a macro.
+#define HASH(x) ((x) % 10)
+[[void func() [[{
+  int a = [[HASH(2^3]] + 34]]);]]
+}
+   )cpp",
+  R"cpp( // Cursor on a macro.
+#define HASH(x) ((x) % 10)
+[[void func() [[{
+  int a = [[HA^SH(23);]]
+}
+   )cpp",
+  R"cpp( // Multiple declaration.
+[[void func() [[{
+  int var1, var^2]], var3;]]
+}
+   )cpp",
+  R"cpp( // Before comment.
+[[void func() [[{
+  int var1 = 1;
+  int var2 = var1]]^ /*some comment*/ + 41;]]
+}
+   )cpp",
+  // Empty file.
+  "^",
+  // FIXME: We should get the whole DeclStmt as a range.
+  R"cpp( // Single statement in TU.
+[[int v = [[1^00;
+  )cpp",
+  // FIXME: No node found associated to the position.
+  R"cpp( // Cursor at end of VarDecl.
+void func() {
+  int v = 100 + 100^;
+}
+  )cpp",
+  // FIXME: No node found associated to the position.
+  R"cpp( // Cursor in between spaces.
+void func() {
+  int v = 100 + ^  100;
+}
+  )cpp",
+  // Structs.
+  R"cpp(
+struct AAA { struct BBB { static int ccc(); };};
+[[void func() [[{
+  // int x = AAA::BBB::ccc();
+  int x = AAA::BBB::c^cc]]();]]
+}
+  )cpp",
+  R"cpp(
+struct AAA { struct BBB { static int ccc(); };};
+[[void func() [[{
+  // int x = AAA::BBB::ccc();
+  int x = [[AA^A]]::]]BBB::]]ccc]]();]]
+}
+  )cpp",
+  R"cpp( // Inside struct.
+struct A { static int a(); };
+[[struct B { 
+  [[static int b() [[{
+[[return 1^1]] + 2;
+  }
+}]];
+  )cpp",
+  // Namespaces.
+  R"cpp( 
+[[namespace nsa { 
+  [[namespace nsb { 
+static int ccc();
+[[void func() [[{
+  // int x = nsa::nsb::ccc();
+  int x = nsa::nsb::cc^c]]();]]
+}
+  }]]
+}]]
+  )cpp",
+
+  };
+
+  for (const char *Test : Tests) {
+auto T = Annotations(Test);
+auto AST = TestTU::withCode(T.code()).build();
+EXPECT_THAT(llvm::cantFail(getSemanticRanges(AST, T.point())),
+ElementsAreArray(T.ranges()))
+<< Test;
+  }
+}
+} // namespace
+} // namespace clangd
+} // namespace clang
\ No newline at end 

[PATCH] D67545: [clang-tidy] Added DefaultOperatorNewCheck.

2019-09-13 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dexonsmith, 
steven_wu, dkrupp, xazax.hun, inglorion, mgorny, mehdi_amini.
Herald added a project: clang.

Added new checker 'cert-default-operator-new' that checks for
CERT rule MEM57-CPP. Simple version.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67545

Files:
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/clang-tidy/cert/CMakeLists.txt
  clang-tools-extra/clang-tidy/cert/DefaultOperatorNewCheck.cpp
  clang-tools-extra/clang-tidy/cert/DefaultOperatorNewCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-default-operator-new.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/cert-default-operator-new.cpp

Index: clang-tools-extra/test/clang-tidy/cert-default-operator-new.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/cert-default-operator-new.cpp
@@ -0,0 +1,32 @@
+// RUN: %check_clang_tidy %s cert-default-operator-new %t
+
+namespace std {
+typedef __typeof(sizeof(int)) size_t;
+void *aligned_alloc(size_t, size_t);
+void free(void *);
+}
+
+struct alignas(32) Vector1 {
+  char elems[32];
+};
+
+struct Vector2 {
+  char elems[32];
+};
+
+struct alignas(32) Vector3 {
+  char elems[32];
+  static void *operator new(std::size_t nbytes) noexcept(true) {
+return std::aligned_alloc(alignof(Vector3), nbytes);
+  }
+  static void operator delete(void *p) {
+std::free(p);
+  }
+}; 
+
+void f() {
+  auto *V1 = new Vector1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: using default 'operator new' with over-aligned type 'Vector1' may result in undefined behavior [cert-default-operator-new]
+  auto *V2 = new Vector2;
+  auto *V3 = new Vector3;
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -4,7 +4,6 @@
 =
 
 .. toctree::
-
abseil-duration-addition
abseil-duration-comparison
abseil-duration-conversion-cast
@@ -89,6 +88,7 @@
cert-dcl54-cpp (redirects to misc-new-delete-overloads) 
cert-dcl58-cpp
cert-dcl59-cpp (redirects to google-build-namespaces) 
+   cert-default-operator-new
cert-env33-c
cert-err09-cpp (redirects to misc-throw-by-value-catch-by-reference) 
cert-err34-c
@@ -104,87 +104,87 @@
cert-msc51-cpp
cert-oop11-cpp (redirects to performance-move-constructor-init) 
cert-oop54-cpp (redirects to bugprone-unhandled-self-assignment) 
-   clang-analyzer-core.CallAndMessage
-   clang-analyzer-core.DivideZero
+   clang-analyzer-core.CallAndMessage (redirects to https://clang.llvm.org/docs/analyzer/checkers) 
+   clang-analyzer-core.DivideZero (redirects to https://clang.llvm.org/docs/analyzer/checkers) 
clang-analyzer-core.DynamicTypePropagation
-   clang-analyzer-core.NonNullParamChecker
-   clang-analyzer-core.NullDereference
-   clang-analyzer-core.StackAddressEscape
-   clang-analyzer-core.UndefinedBinaryOperatorResult
-   clang-analyzer-core.VLASize
-   clang-analyzer-core.uninitialized.ArraySubscript
-   clang-analyzer-core.uninitialized.Assign
-   clang-analyzer-core.uninitialized.Branch
+   clang-analyzer-core.NonNullParamChecker (redirects to https://clang.llvm.org/docs/analyzer/checkers) 
+   clang-analyzer-core.NullDereference (redirects to https://clang.llvm.org/docs/analyzer/checkers) 
+   clang-analyzer-core.StackAddressEscape (redirects to https://clang.llvm.org/docs/analyzer/checkers) 
+   clang-analyzer-core.UndefinedBinaryOperatorResult (redirects to https://clang.llvm.org/docs/analyzer/checkers) 
+   clang-analyzer-core.VLASize (redirects to https://clang.llvm.org/docs/analyzer/checkers) 
+   clang-analyzer-core.uninitialized.ArraySubscript (redirects to https://clang.llvm.org/docs/analyzer/checkers) 
+   clang-analyzer-core.uninitialized.Assign (redirects to https://clang.llvm.org/docs/analyzer/checkers) 
+   clang-analyzer-core.uninitialized.Branch (redirects to https://clang.llvm.org/docs/analyzer/checkers) 
clang-analyzer-core.uninitialized.CapturedBlockVariable
-   clang-analyzer-core.uninitialized.UndefReturn
+   clang-analyzer-core.uninitialized.UndefReturn (redirects to https://clang.llvm.org/docs/analyzer/checkers) 
clang-analyzer-cplusplus.InnerPointer
-   clang-analyzer-cplusplus.Move
-   clang-analyzer-cplusplus.NewDelete
-   clang-analyzer-cplusplus.NewDeleteLeaks
-   clang-analyzer-deadcode.DeadStores
-   clang-analyzer-nullability.NullPassedToNonnull
-   clang-analyzer-nullability.NullReturnedFromNonnull
-   clang-analyzer-nullability.NullableDereferenced
-   clang-analyzer-nullability.NullablePassedToNonnull
+   clang-analyzer-cplusplus.Move (redirects to https://clang.llvm.org/docs/analyzer/checkers) 
+   

[PATCH] D67358: [clangd] Implement semantic selections.

2019-09-13 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 220074.
usaxena95 added a comment.

Minor changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67358

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/SemanticSelection.cpp
  clang-tools-extra/clangd/SemanticSelection.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -0,0 +1,143 @@
+//===-- SemanticSelectionTests.cpp  *- 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
+//
+//===--===//
+
+#include "Annotations.h"
+#include "Matchers.h"
+#include "Protocol.h"
+#include "SemanticSelection.h"
+#include "SourceCode.h"
+#include "TestTU.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "llvm/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+namespace clang {
+namespace clangd {
+namespace {
+using ::testing::ElementsAreArray;
+
+TEST(SemanticSelection, All) {
+  const char *Tests[] = {
+  R"cpp( // Single statement in a function body.
+[[void func() [[{
+  int v = [[1^00;]]
+}
+  )cpp",
+  R"cpp( // Expression
+[[void func() [[{
+  int a = 1;
+  // int v = (10 + 2) * (a + a);
+  int v = (10^]] + 2]])]] * (a + a);]]
+}
+  )cpp",
+  R"cpp( // Function call.
+int add(int x, int y) { return x + y; }
+[[void callee() [[{
+  // int res = add(11, 22);
+  int res = [[add([[1^1]], 22);]]
+}
+  )cpp",
+  R"cpp( // Tricky macros.
+#define MUL ) * (
+[[void func() [[{
+  // int var = (4 + 15 MUL 6 + 10);
+  int var = ([[4 + [[1^5 MUL]] 6 + 10);]]
+}
+   )cpp",
+  R"cpp( // Cursor inside a macro.
+#define HASH(x) ((x) % 10)
+[[void func() [[{
+  int a = [[HASH(2^3]] + 34]]);]]
+}
+   )cpp",
+  R"cpp( // Cursor on a macro.
+#define HASH(x) ((x) % 10)
+[[void func() [[{
+  int a = [[HA^SH(23);]]
+}
+   )cpp",
+  R"cpp( // Multiple declaration.
+[[void func() [[{
+  int var1, var^2]], var3;]]
+}
+   )cpp",
+  R"cpp( // Before comment.
+[[void func() [[{
+  int var1 = 1;
+  int var2 = var1]]^ /*some comment*/ + 41;]]
+}
+   )cpp",
+  // Empty file.
+  "^",
+  // FIXME: We should get the whole DeclStmt as a range.
+  R"cpp( // Single statement in TU.
+[[int v = [[1^00;
+  )cpp",
+  // FIXME: No node found associated to the position.
+  R"cpp( // Cursor at end of VarDecl.
+void func() {
+  int v = 100 + 100^;
+}
+  )cpp",
+  // FIXME: No node found associated to the position.
+  R"cpp( // Cursor in between spaces.
+void func() {
+  int v = 100 + ^  100;
+}
+  )cpp",
+  // Structs.
+  R"cpp(
+struct AAA { struct BBB { static int ccc(); };};
+[[void func() [[{
+  // int x = AAA::BBB::ccc();
+  int x = AAA::BBB::c^cc]]();]]
+}
+  )cpp",
+  R"cpp(
+struct AAA { struct BBB { static int ccc(); };};
+[[void func() [[{
+  // int x = AAA::BBB::ccc();
+  int x = [[AA^A]]::]]BBB::]]ccc]]();]]
+}
+  )cpp",
+  R"cpp( // Inside struct.
+struct A { static int a(); };
+[[struct B { 
+  [[static int b() [[{
+[[return 1^1]] + 2;
+  }
+}]];
+  )cpp",
+  // Namespaces.
+  R"cpp( 
+[[namespace nsa { 
+  [[namespace nsb { 
+static int ccc();
+[[void func() [[{
+  // int x = nsa::nsb::ccc();
+  int x = nsa::nsb::cc^c]]();]]
+}
+  }]]
+}]]
+  )cpp",
+
+  };
+
+  for (const char *Test : Tests) {
+auto T = Annotations(Test);
+auto AST = TestTU::withCode(T.code()).build();
+EXPECT_THAT(llvm::cantFail(getSemanticRanges(AST, T.point())),
+ElementsAreArray(T.ranges()))
+<< Test;
+  }
+}
+} // namespace
+} // namespace clangd
+} // namespace clang
\ No newline at end of file
Index: 

[PATCH] D67358: [clangd] Implement semantic selections.

2019-09-13 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 added inline comments.



Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:33
+  if (!Offset) {
+llvm::errs() << "Unable to convert postion to offset";
+return {};

sammccall wrote:
> we use log() or elog() for this, make sure you include Offset.takeError() for 
> the original message
> 
> Alternatively, you might consider returning Expected 
> so the error gets propagated to the client (as this really is a client error)
Returning Expected> now to propagate the error.



Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:39
+  SelectionTree ST(AST.getASTContext(), AST.getTokens(), *Offset);
+  for (const auto *Node = ST.commonAncestor(); Node != nullptr;
+   Node = Node->Parent) {

sammccall wrote:
> I think you probably want to bail out once you hit TranslationUnitDecl.
> 
> And maybe at namespace decls? Though I have often in my editor wondered 
> "what's the enclosing namespace"...
Bailing out once we hit the TUDecl. I am not sure about exiting on namespace 
decl. I am keeping this for now. We can remove this later if the need be.



Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:45
+}
+SourceLocation BeginLoc = SR.getBegin();
+SourceLocation EndLoc =

sammccall wrote:
> Ah, this will work if the start and the end of the AST node are written 
> directly in the file, and no macros are involved. But try 
> `toHalfOpenFileRange` in `SourceCode.h`, which should work in a lot more 
> cases.
> 
> In particular, this should work:
> ```
> #define INC(X) X + 1
> int a, b;
> int c = INC(a * b);
> ^
> ~
> ~
> ~~
> ~~
> ```
Interesting. This works fine in such cases. Thanks.
Though it works strangely with these ugly macros. I guess this is because it 
tries to follow the macro expansion.
```
#define MUL ) * (
int var = (4 + 15 MUL 6 + 10);
^
   ~~
   ~~
  ~~~
```



Comment at: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp:115
+[[void func() [[{
+  // int x = nsa::nsb::ccc();
+  int x = nsa::nsb::cc^c]]();]]

sammccall wrote:
> why commented out?
Since the statement contains many [[ and ]], I have added the actual statement 
in comments to make it more readable. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67358



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


[PATCH] D67358: [clangd] Implement semantic selections.

2019-09-13 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 220071.
usaxena95 marked 13 inline comments as done.
usaxena95 added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67358

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/SemanticSelection.cpp
  clang-tools-extra/clangd/SemanticSelection.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -0,0 +1,143 @@
+//===-- SemanticSelectionTests.cpp  *- 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
+//
+//===--===//
+
+#include "Annotations.h"
+#include "Matchers.h"
+#include "Protocol.h"
+#include "SemanticSelection.h"
+#include "SourceCode.h"
+#include "TestTU.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "llvm/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+namespace clang {
+namespace clangd {
+namespace {
+using ::testing::ElementsAreArray;
+
+TEST(SemanticSelection, All) {
+  const char *Tests[] = {
+  R"cpp( // Single statement in a function body.
+[[void func() [[{
+  int v = [[1^00;]]
+}
+  )cpp",
+  R"cpp( // Expression
+[[void func() [[{
+  int a = 1;
+  // int v = (10 + 2) * (a + a);
+  int v = (10^]] + 2]])]] * (a + a);]]
+}
+  )cpp",
+  R"cpp( // Function call.
+int add(int x, int y) { return x + y; }
+[[void callee() [[{
+  // int res = add(11, 22);
+  int res = [[add([[1^1]], 22);]]
+}
+  )cpp",
+  R"cpp( // Tricky macros.
+#define MUL ) * (
+[[void func() [[{
+  // int var = (4 + 15 MUL 6 + 10);
+  int var = ([[4 + [[1^5 MUL]] 6 + 10);]]
+}
+   )cpp",
+  R"cpp( // Cursor inside a macro.
+#define HASH(x) ((x) % 10)
+[[void func() [[{
+  int a = [[HASH(2^3]] + 34]]);]]
+}
+   )cpp",
+  R"cpp( // Cursor on a macro.
+#define HASH(x) ((x) % 10)
+[[void func() [[{
+  int a = [[HA^SH(23);]]
+}
+   )cpp",
+  R"cpp( // Multiple declaration.
+[[void func() [[{
+  int var1, var^2]], var3;]]
+}
+   )cpp",
+  R"cpp( // Before comment.
+[[void func() [[{
+  int var1 = 1;
+  int var2 = var1]]^ /*some comment*/ + 41;]]
+}
+   )cpp",
+  // Empty file.
+  "^",
+  // FIXME: We should get the whole DeclStmt as a range.
+  R"cpp( // Single statement in TU.
+[[int v = [[1^00;
+  )cpp",
+  // FIXME: No node found associated to the position.
+  R"cpp( // Cursor at end of VarDecl.
+void func() {
+  int v = 100 + 100^;
+}
+  )cpp",
+  // FIXME: No node found associated to the position.
+  R"cpp( // Cursor in between spaces.
+void func() {
+  int v = 100 + ^  100;
+}
+  )cpp",
+  // Structs.
+  R"cpp(
+struct AAA { struct BBB { static int ccc(); };};
+[[void func() [[{
+  // int x = AAA::BBB::ccc();
+  int x = AAA::BBB::c^cc]]();]]
+}
+  )cpp",
+  R"cpp(
+struct AAA { struct BBB { static int ccc(); };};
+[[void func() [[{
+  // int x = AAA::BBB::ccc();
+  int x = [[AA^A]]::]]BBB::]]ccc]]();]]
+}
+  )cpp",
+  R"cpp( // Inside struct.
+struct A { static int a(); };
+[[struct B { 
+  [[static int b() [[{
+[[return 1^1]] + 2;
+  }
+}]];
+  )cpp",
+  // Namespaces.
+  R"cpp( 
+[[namespace nsa { 
+  [[namespace nsb { 
+static int ccc();
+[[void func() [[{
+  // int x = nsa::nsb::ccc();
+  int x = nsa::nsb::cc^c]]();]]
+}
+  }]]
+}]]
+  )cpp",
+
+  };
+
+  for (const char *Test : Tests) {
+auto T = Annotations(Test);
+auto AST = TestTU::withCode(T.code()).build();
+EXPECT_THAT(llvm::cantFail(getSemanticRanges(AST, T.point())),
+ElementsAreArray(T.ranges()))
+<< Test;
+  }
+}
+} // namespace
+} // namespace clangd
+} // namespace 

[libclc] r371837 - Creating release candidate rc5 from release_900 branch

2019-09-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Sep 13 03:45:50 2019
New Revision: 371837

URL: http://llvm.org/viewvc/llvm-project?rev=371837=rev
Log:
Creating release candidate rc5 from release_900 branch

Added:
libclc/tags/RELEASE_900/rc5/
  - copied from r371836, libclc/branches/release_90/

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


[libunwind] r371837 - Creating release candidate rc5 from release_900 branch

2019-09-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Sep 13 03:45:50 2019
New Revision: 371837

URL: http://llvm.org/viewvc/llvm-project?rev=371837=rev
Log:
Creating release candidate rc5 from release_900 branch

Added:
libunwind/tags/RELEASE_900/rc5/
  - copied from r371836, libunwind/branches/release_90/

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


[PATCH] D67542: Fix depfile name construction

2019-09-13 Thread Momchil Velikov via Phabricator via cfe-commits
chill accepted this revision.
chill added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D67542



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


[PATCH] D67543: [Clang][ASTImporter] Added visibility check for ClassTemplateDecl.

2019-09-13 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, teemperor, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

ASTImporter makes now difference between class templates with same
name in different translation units if these are not visible outside.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67543

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterVisibilityTest.cpp

Index: clang/unittests/AST/ASTImporterVisibilityTest.cpp
===
--- clang/unittests/AST/ASTImporterVisibilityTest.cpp
+++ clang/unittests/AST/ASTImporterVisibilityTest.cpp
@@ -49,6 +49,10 @@
 return functionTemplateDecl(hasName("f"));
   }
 };
+struct GetClassTemplPattern {
+  using DeclTy = ClassTemplateDecl;
+  BindableMatcher operator()() { return classTemplateDecl(hasName("X")); }
+};
 
 // Values for the value-parameterized test fixtures.
 // FunctionDecl:
@@ -74,6 +78,9 @@
 const auto *ExternFT = "template  void f();";
 const auto *StaticFT = "template  static void f();";
 const auto *AnonFT = "namespace { template  void f(); }";
+// ClassTemplateDecl:
+const auto *ExternCT = "template  class X;";
+const auto *AnonCT = "namespace { template  class X; }";
 
 // First value in tuple: Compile options.
 // Second value in tuple: Source code to be used in the test.
@@ -120,6 +127,8 @@
 using ImportClassesVisibilityChain = ImportVisibilityChain;
 using ImportFunctionTemplatesVisibilityChain =
 ImportVisibilityChain;
+using ImportClassTemplatesVisibilityChain =
+ImportVisibilityChain;
 
 // Value-parameterized test for functions.
 TEST_P(ImportFunctionsVisibilityChain, ImportChain) {
@@ -137,6 +146,10 @@
 TEST_P(ImportFunctionTemplatesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
 }
+// Value-parameterized test for class templates.
+TEST_P(ImportClassTemplatesVisibilityChain, ImportChain) {
+  TypedTest_ImportChain();
+}
 
 // Automatic instantiation of the value-parameterized tests.
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctionsVisibilityChain,
@@ -165,6 +178,10 @@
 ::testing::Combine(DefaultTestValuesForRunOptions,
::testing::Values(ExternFT, StaticFT,
  AnonFT)), );
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportClassTemplatesVisibilityChain,
+::testing::Combine(DefaultTestValuesForRunOptions,
+   ::testing::Values(ExternCT,
+ AnonCT)), );
 
 // First value in tuple: Compile options.
 // Second value in tuple: Tuple with informations for the test.
@@ -276,6 +293,7 @@
 using ImportEnumsVisibility = ImportVisibility;
 using ImportTypedefNameVisibility = ImportVisibility;
 using ImportFunctionTemplatesVisibility = ImportVisibility;
+using ImportClassTemplatesVisibility = ImportVisibility;
 
 // FunctionDecl.
 TEST_P(ImportFunctionsVisibility, ImportAfter) {
@@ -319,6 +337,11 @@
 TEST_P(ImportFunctionTemplatesVisibility, ImportAfterImport) {
   TypedTest_ImportAfterImport();
 }
+// ClassTemplateDecl.
+TEST_P(ImportClassTemplatesVisibility, ImportAfter) { TypedTest_ImportAfter(); }
+TEST_P(ImportClassTemplatesVisibility, ImportAfterImport) {
+  TypedTest_ImportAfterImport();
+}
 
 const bool ExpectLinkedDeclChain = true;
 const bool ExpectUnlinkedDeclChain = false;
@@ -411,6 +434,13 @@
 std::make_tuple(AnonFT, ExternFT, ExpectUnlinkedDeclChain),
 std::make_tuple(AnonFT, StaticFT, ExpectUnlinkedDeclChain),
 std::make_tuple(AnonFT, AnonFT, ExpectUnlinkedDeclChain))), );
-
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportClassTemplatesVisibility,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(std::make_tuple(ExternCT, ExternCT, ExpectLinkedDeclChain),
+  std::make_tuple(ExternCT, AnonCT, ExpectUnlinkedDeclChain),
+  std::make_tuple(AnonCT, ExternCT, ExpectUnlinkedDeclChain),
+  std::make_tuple(AnonCT, AnonCT, ExpectUnlinkedDeclChain))), );
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -5117,6 +5117,8 @@
   Decl *Found = FoundDecl;
   auto *FoundTemplate = dyn_cast(Found);
   if (FoundTemplate) {
+if (!hasSameVisibilityContext(FoundTemplate, D))
+  continue;
 
 if (IsStructuralMatch(D, FoundTemplate)) {
   ClassTemplateDecl *TemplateWithDef =
___
cfe-commits mailing list

[PATCH] D67414: [AST] Treat "inline gnu_inline" the same way as "extern inline gnu_inline" in C++ mode

2019-09-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo marked an inline comment as done.
mstorsjo added inline comments.



Comment at: clang/lib/AST/Decl.cpp:3334
 /// For an inline function definition in C, or for a gnu_inline function
 /// in C++, determine whether the definition will be externally visible.
 ///

As this method only expects to be called for `gnu_inline` in C++ mode ("nline 
function definition in C, or for a gnu_inline function in C++" from the 
comment), and we're changing the C++ case to a plain `if (C++) return false;`, 
one could also consider updating the caller and making this method only be used 
for C mode, but maybe that should be left as a separate refactoring step (if 
it's worth doing at all)?


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

https://reviews.llvm.org/D67414



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


[PATCH] D67414: [AST] Treat "inline gnu_inline" the same way as "extern inline gnu_inline" in C++ mode

2019-09-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 220053.
mstorsjo added a comment.

Adapted based on the feedback so far, suggestions on naming and grouping the 
warning are welcome.

The warning did trigger in an existing CUDA test as well - I'm not familiar 
with cuda and how it relates to other languages, so suggestions on what to do 
wrt it, if anything, are also welcome.


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

https://reviews.llvm.org/D67414

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/inline.c
  clang/test/SemaCUDA/gnu-inline.cu
  clang/test/SemaCXX/gnu_inline.cpp
  clang/test/SemaCXX/undefined-inline.cpp

Index: clang/test/SemaCXX/undefined-inline.cpp
===
--- clang/test/SemaCXX/undefined-inline.cpp
+++ clang/test/SemaCXX/undefined-inline.cpp
@@ -40,20 +40,20 @@
 }
 
 namespace test8 {
-  inline void foo() __attribute__((gnu_inline));
+  inline void foo() __attribute__((gnu_inline)); // expected-warning {{'gnu_inline' attribute without 'extern' in C++ treated as externally available, this changed in Clang 10}}
   void test() { foo(); }
 }
 
 namespace test9 {
   void foo();
   void test() { foo(); }
-  inline void foo() __attribute__((gnu_inline));
+  inline void foo() __attribute__((gnu_inline)); // expected-warning {{'gnu_inline' attribute without 'extern' in C++ treated as externally available, this changed in Clang 10}}
 }
 
 namespace test10 {
   inline void foo();
   void test() { foo(); }
-  inline void foo() __attribute__((gnu_inline));
+  inline void foo() __attribute__((gnu_inline)); // expected-warning {{'gnu_inline' attribute without 'extern' in C++ treated as externally available, this changed in Clang 10}}
 }
 
 namespace test11 {
Index: clang/test/SemaCXX/gnu_inline.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/gnu_inline.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+extern inline
+__attribute__((__gnu_inline__))
+void gnu_inline1() {}
+
+inline
+__attribute__((__gnu_inline__)) // expected-warning {{'gnu_inline' attribute without 'extern' in C++ treated as externally available, this changed in Clang 10}}
+void gnu_inline2() {}
Index: clang/test/SemaCUDA/gnu-inline.cu
===
--- clang/test/SemaCUDA/gnu-inline.cu
+++ clang/test/SemaCUDA/gnu-inline.cu
@@ -2,9 +2,7 @@
 
 #include "Inputs/cuda.h"
 
-// expected-no-diagnostics
-
 // Check that we can handle gnu_inline functions when compiling in CUDA mode.
 
 void foo();
-inline __attribute__((gnu_inline)) void bar() { foo(); }
+inline __attribute__((gnu_inline)) void bar() { foo(); } // expected-warning {{'gnu_inline' attribute without 'extern' in C++ treated as externally available, this changed in Clang 10}}
Index: clang/test/CodeGen/inline.c
===
--- clang/test/CodeGen/inline.c
+++ clang/test/CodeGen/inline.c
@@ -52,7 +52,7 @@
 // CHECK3-LABEL: define i32 @_Z3barv()
 // CHECK3-LABEL: define linkonce_odr i32 @_Z3foov()
 // CHECK3-NOT: unreferenced
-// CHECK3-LABEL: define void @_Z10gnu_inlinev()
+// CHECK3-LABEL: define available_externally void @_Z10gnu_inlinev()
 // CHECK3-LABEL: define available_externally void @_Z13gnu_ei_inlinev()
 // CHECK3-NOT: @_Z5testCv
 // CHECK3-LABEL: define linkonce_odr i32 @_Z2eiv()
@@ -85,6 +85,7 @@
 extern __inline void unreferenced2() {}
 
 __inline __attribute((__gnu_inline__)) void gnu_inline() {}
+void (*P1)() = gnu_inline;
 
 // PR3988
 extern __inline __attribute__((gnu_inline)) void gnu_ei_inline() {}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4423,6 +4423,9 @@
 return;
   }
 
+  if (S.LangOpts.CPlusPlus && Fn->getStorageClass() != SC_Extern)
+S.Diag(AL.getLoc(), diag::warn_gnu_inline_cplusplus_without_extern);
+
   D->addAttr(::new (S.Context)
  GNUInlineAttr(AL.getRange(), S.Context,
AL.getAttributeSpellingListIndex()));
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3251,6 +3251,9 @@
   return true;
   }
 
+  if (Context.getLangOpts().CPlusPlus)
+return false;
+
   if (Context.getLangOpts().GNUInline || hasAttr()) {
 // With GNU inlining, a declaration with 'inline' but not 'extern', forces
 // an externally visible definition.
@@ -3279,9 +3282,6 @@
 return FoundBody;
   }
 
-  if (Context.getLangOpts().CPlusPlus)
-return false;
-
   // C99 6.7.4p6:
   //   [...] If all of the file scope declarations for a function in a
   //   translation unit include the inline function specifier without extern,
@@ 

[PATCH] D67542: Fix depfile name construction

2019-09-13 Thread Luke Cheeseman via Phabricator via cfe-commits
LukeCheeseman updated this revision to Diff 220067.
LukeCheeseman added a comment.

- Add a requires shell


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

https://reviews.llvm.org/D67542

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/metadata-with-dots.c


Index: clang/test/Driver/metadata-with-dots.c
===
--- /dev/null
+++ clang/test/Driver/metadata-with-dots.c
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+// RUN: mkdir -p out.dir
+// RUN: cat %s > out.dir/test.c
+// RUN: %clang -E -MMD %s -o out.dir/test
+// RUN: test ! -f %out.d
+// RUN: test -f out.dir/test.d
+// RUN: rm -rf out.dir/test.d out.dir/ out.d
+int main (void)
+{
+return 0;
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6332,15 +6332,14 @@
 const char *Clang::getDependencyFileName(const ArgList ,
  const InputInfoList ) {
   // FIXME: Think about this more.
-  std::string Res;
 
   if (Arg *OutputOpt = Args.getLastArg(options::OPT_o)) {
-std::string Str(OutputOpt->getValue());
-Res = Str.substr(0, Str.rfind('.'));
-  } else {
-Res = getBaseInputStem(Args, Inputs);
+SmallString<128> OutputFilename(OutputOpt->getValue());
+llvm::sys::path::replace_extension(OutputFilename, llvm::Twine('d'));
+return Args.MakeArgString(OutputFilename);
   }
-  return Args.MakeArgString(Res + ".d");
+
+  return Args.MakeArgString(std::string(getBaseInputStem(Args, Inputs)) + 
".d");
 }
 
 // Begin ClangAs


Index: clang/test/Driver/metadata-with-dots.c
===
--- /dev/null
+++ clang/test/Driver/metadata-with-dots.c
@@ -0,0 +1,11 @@
+// REQUIRES: shell
+// RUN: mkdir -p out.dir
+// RUN: cat %s > out.dir/test.c
+// RUN: %clang -E -MMD %s -o out.dir/test
+// RUN: test ! -f %out.d
+// RUN: test -f out.dir/test.d
+// RUN: rm -rf out.dir/test.d out.dir/ out.d
+int main (void)
+{
+return 0;
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6332,15 +6332,14 @@
 const char *Clang::getDependencyFileName(const ArgList ,
  const InputInfoList ) {
   // FIXME: Think about this more.
-  std::string Res;
 
   if (Arg *OutputOpt = Args.getLastArg(options::OPT_o)) {
-std::string Str(OutputOpt->getValue());
-Res = Str.substr(0, Str.rfind('.'));
-  } else {
-Res = getBaseInputStem(Args, Inputs);
+SmallString<128> OutputFilename(OutputOpt->getValue());
+llvm::sys::path::replace_extension(OutputFilename, llvm::Twine('d'));
+return Args.MakeArgString(OutputFilename);
   }
-  return Args.MakeArgString(Res + ".d");
+
+  return Args.MakeArgString(std::string(getBaseInputStem(Args, Inputs)) + ".d");
 }
 
 // Begin ClangAs
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67541: [ClangFormat] Future-proof Standard option, allow floating or pinning to arbitrary lang version

2019-09-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 220066.
sammccall added a comment.

Add fairly contrived test that demonstrates the difference between c++17 and 
latest (20) parsing mode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67541

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9291,6 +9291,19 @@
 format("#define x(_a) printf(\"foo\"_a);", Style));
 }
 
+TEST_F(FormatTest, CppLexVersion) {
+  FormatStyle Style = getLLVMStyle();
+  // Formatting of x * y differs if x is a type.
+  verifyFormat("void foo() { MACRO(a * b); }", Style);
+  verifyFormat("void foo() { MACRO(int *b); }", Style);
+
+  // LLVM style uses latest lexer.
+  verifyFormat("void foo() { MACRO(char8_t *b); }", Style);
+  Style.Standard = FormatStyle::LS_Cpp17;
+  // But in c++17, char8_t isn't a keyword.
+  verifyFormat("void foo() { MACRO(char8_t * b); }", Style);
+}
+
 TEST_F(FormatTest, UnderstandsCpp1y) { verifyFormat("int bi{1'000'000};"); }
 
 TEST_F(FormatTest, BreakStringLiteralsBeforeUnbreakableTokenSequence) {
@@ -11888,11 +11901,18 @@
   FormatStyle::PAS_Middle);
 
   Style.Standard = FormatStyle::LS_Auto;
+  CHECK_PARSE("Standard: c++03", Standard, FormatStyle::LS_Cpp03);
+  CHECK_PARSE("Standard: c++11", Standard, FormatStyle::LS_Cpp11);
+  CHECK_PARSE("Standard: c++14", Standard, FormatStyle::LS_Cpp14);
+  CHECK_PARSE("Standard: c++17", Standard, FormatStyle::LS_Cpp17);
+  CHECK_PARSE("Standard: c++20", Standard, FormatStyle::LS_Cpp20);
+  CHECK_PARSE("Standard: Auto", Standard, FormatStyle::LS_Auto);
+  CHECK_PARSE("Standard: Latest", Standard, FormatStyle::LS_Latest);
+  // Legacy aliases:
   CHECK_PARSE("Standard: Cpp03", Standard, FormatStyle::LS_Cpp03);
-  CHECK_PARSE("Standard: Cpp11", Standard, FormatStyle::LS_Cpp11);
+  CHECK_PARSE("Standard: Cpp11", Standard, FormatStyle::LS_Latest);
   CHECK_PARSE("Standard: C++03", Standard, FormatStyle::LS_Cpp03);
   CHECK_PARSE("Standard: C++11", Standard, FormatStyle::LS_Cpp11);
-  CHECK_PARSE("Standard: Auto", Standard, FormatStyle::LS_Auto);
 
   Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
   CHECK_PARSE("BreakBeforeBinaryOperators: NonAssignment",
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -67,10 +67,19 @@
 
 template <> struct ScalarEnumerationTraits {
   static void enumeration(IO , FormatStyle::LanguageStandard ) {
-IO.enumCase(Value, "Cpp03", FormatStyle::LS_Cpp03);
-IO.enumCase(Value, "C++03", FormatStyle::LS_Cpp03);
-IO.enumCase(Value, "Cpp11", FormatStyle::LS_Cpp11);
-IO.enumCase(Value, "C++11", FormatStyle::LS_Cpp11);
+IO.enumCase(Value, "c++03", FormatStyle::LS_Cpp03);
+IO.enumCase(Value, "C++03", FormatStyle::LS_Cpp03); // Legacy alias
+IO.enumCase(Value, "Cpp03", FormatStyle::LS_Cpp03); // Legacy alias
+
+IO.enumCase(Value, "c++11", FormatStyle::LS_Cpp11);
+IO.enumCase(Value, "C++11", FormatStyle::LS_Cpp11); // Legacy alias
+
+IO.enumCase(Value, "c++14", FormatStyle::LS_Cpp14);
+IO.enumCase(Value, "c++17", FormatStyle::LS_Cpp17);
+IO.enumCase(Value, "c++20", FormatStyle::LS_Cpp20);
+
+IO.enumCase(Value, "Latest", FormatStyle::LS_Latest);
+IO.enumCase(Value, "Cpp11", FormatStyle::LS_Latest); // Legacy alias
 IO.enumCase(Value, "Auto", FormatStyle::LS_Auto);
   }
 };
@@ -742,7 +751,7 @@
   LLVMStyle.ObjCSpaceBeforeProtocolList = true;
   LLVMStyle.PointerAlignment = FormatStyle::PAS_Right;
   LLVMStyle.SpacesBeforeTrailingComments = 1;
-  LLVMStyle.Standard = FormatStyle::LS_Cpp11;
+  LLVMStyle.Standard = FormatStyle::LS_Latest;
   LLVMStyle.UseTab = FormatStyle::UT_Never;
   LLVMStyle.ReflowComments = true;
   LLVMStyle.SpacesInParentheses = false;
@@ -1383,7 +1392,7 @@
: FormatStyle::PAS_Right;
 if (Style.Standard == FormatStyle::LS_Auto)
   Style.Standard = hasCpp03IncompatibleFormat(AnnotatedLines)
-   ? FormatStyle::LS_Cpp11
+   ? FormatStyle::LS_Latest
: FormatStyle::LS_Cpp03;
 BinPackInconclusiveFunctions =
 HasBinPackedFunction || !HasOnePerLineFunction;
@@ -2402,14 +2411,18 @@
 
 LangOptions getFormattingLangOpts(const FormatStyle ) {
   LangOptions LangOpts;
-  FormatStyle::LanguageStandard LexingStd =
-  Style.Standard == FormatStyle::LS_Auto ? FormatStyle::LS_Cpp11
- : Style.Standard;
+
+  FormatStyle::LanguageStandard LexingStd = Style.Standard;
+  if (LexingStd == 

[PATCH] D67542: Fix depfile name construction

2019-09-13 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a reviewer: chill.
chill added inline comments.



Comment at: clang/test/Driver/metadata-with-dots.c:2
+// RUN: mkdir -p out.dir
+// RUN: cat %s > out.dir/test.c
+// RUN: %clang -E -MMD %s -o out.dir/test

Is this going to ruin on Windows ?




Comment at: clang/test/Driver/metadata-with-dots.c:4-6
+// RUN: test ! -f %out.d
+// RUN: test -f out.dir/test.d
+// RUN: rm -rf out.dir/test.d out.dir/ out.d

And these ?


Repository:
  rC Clang

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

https://reviews.llvm.org/D67542



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


[PATCH] D67541: [ClangFormat] Future-proof Standard option, allow floating or pinning to arbitrary lang version

2019-09-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: klimek, modocache.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The historical context:

- clang-format was written when C++11 was current, and the main 
language-version concern was >> vs > > template-closers. An option was added to 
allow selection of the 03/11 behavior, or auto-detection.
- there was no option to choose simply "latest standard" so anyone who didn't 
ever want 03 behavior or auto-detection specified Cpp11.
- In r185149 this option started to affect lexer mode.
- no options were added to cover c++14, as parsing/formatting didn't change 
that much. The usage of Cpp11 to mean "latest" became codified e.g. in r206263
- c++17 added some new constructs. These were mostly backwards-compatible and 
so not used in old programs, so having no way to turn them off was OK.
- c++20 added some new constructs and keywords (e.g. co_*) that changed the 
meaning of existing programs, and people started to complain that the c++20 
parsing couldn't be turned off.

New plan:

- Default ('Auto') behavior remains unchanged: parse as latest, format 
template-closers based on input.
- Add new 'Latest' option that more clearly expresses the intent "use modern 
features" that many projects have chosen for their .clang-format files.
- Allow pinning to *any* language version, using the same name as clang -std: 
c++03, c++11, c++14 etc. These set precise lexer options, and any clang-format 
code depending on these can use a >= check.
- For backwards compatibility, `Cpp11` is an alias for `Latest`, not `c++11`. 
This matches the historical documented semantics of this option. This spelling 
(and `Cpp03`) are deprecated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67541

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11888,11 +11888,18 @@
   FormatStyle::PAS_Middle);
 
   Style.Standard = FormatStyle::LS_Auto;
+  CHECK_PARSE("Standard: c++03", Standard, FormatStyle::LS_Cpp03);
+  CHECK_PARSE("Standard: c++11", Standard, FormatStyle::LS_Cpp11);
+  CHECK_PARSE("Standard: c++14", Standard, FormatStyle::LS_Cpp14);
+  CHECK_PARSE("Standard: c++17", Standard, FormatStyle::LS_Cpp17);
+  CHECK_PARSE("Standard: c++20", Standard, FormatStyle::LS_Cpp20);
+  CHECK_PARSE("Standard: Auto", Standard, FormatStyle::LS_Auto);
+  CHECK_PARSE("Standard: Latest", Standard, FormatStyle::LS_Latest);
+  // Legacy aliases:
   CHECK_PARSE("Standard: Cpp03", Standard, FormatStyle::LS_Cpp03);
-  CHECK_PARSE("Standard: Cpp11", Standard, FormatStyle::LS_Cpp11);
+  CHECK_PARSE("Standard: Cpp11", Standard, FormatStyle::LS_Latest);
   CHECK_PARSE("Standard: C++03", Standard, FormatStyle::LS_Cpp03);
   CHECK_PARSE("Standard: C++11", Standard, FormatStyle::LS_Cpp11);
-  CHECK_PARSE("Standard: Auto", Standard, FormatStyle::LS_Auto);
 
   Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
   CHECK_PARSE("BreakBeforeBinaryOperators: NonAssignment",
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -67,10 +67,19 @@
 
 template <> struct ScalarEnumerationTraits {
   static void enumeration(IO , FormatStyle::LanguageStandard ) {
-IO.enumCase(Value, "Cpp03", FormatStyle::LS_Cpp03);
-IO.enumCase(Value, "C++03", FormatStyle::LS_Cpp03);
-IO.enumCase(Value, "Cpp11", FormatStyle::LS_Cpp11);
-IO.enumCase(Value, "C++11", FormatStyle::LS_Cpp11);
+IO.enumCase(Value, "c++03", FormatStyle::LS_Cpp03);
+IO.enumCase(Value, "C++03", FormatStyle::LS_Cpp03); // Legacy alias
+IO.enumCase(Value, "Cpp03", FormatStyle::LS_Cpp03); // Legacy alias
+
+IO.enumCase(Value, "c++11", FormatStyle::LS_Cpp11);
+IO.enumCase(Value, "C++11", FormatStyle::LS_Cpp11); // Legacy alias
+
+IO.enumCase(Value, "c++14", FormatStyle::LS_Cpp14);
+IO.enumCase(Value, "c++17", FormatStyle::LS_Cpp17);
+IO.enumCase(Value, "c++20", FormatStyle::LS_Cpp20);
+
+IO.enumCase(Value, "Latest", FormatStyle::LS_Latest);
+IO.enumCase(Value, "Cpp11", FormatStyle::LS_Latest); // Legacy alias
 IO.enumCase(Value, "Auto", FormatStyle::LS_Auto);
   }
 };
@@ -742,7 +751,7 @@
   LLVMStyle.ObjCSpaceBeforeProtocolList = true;
   LLVMStyle.PointerAlignment = FormatStyle::PAS_Right;
   LLVMStyle.SpacesBeforeTrailingComments = 1;
-  LLVMStyle.Standard = FormatStyle::LS_Cpp11;
+  LLVMStyle.Standard = FormatStyle::LS_Latest;
   LLVMStyle.UseTab = FormatStyle::UT_Never;
   LLVMStyle.ReflowComments = true;
   LLVMStyle.SpacesInParentheses = false;
@@ -1383,7 +1392,7 @@
: FormatStyle::PAS_Right;
 

r371832 - Fix a perl warning: Scalar value @ArgParts[0] better written as $ArgParts[0] at /usr/share/clang/scan-build-10/libexec/ccc-analyzer line 502.

2019-09-13 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Fri Sep 13 02:31:19 2019
New Revision: 371832

URL: http://llvm.org/viewvc/llvm-project?rev=371832=rev
Log:
Fix a perl warning: Scalar value @ArgParts[0] better written as $ArgParts[0] at 
/usr/share/clang/scan-build-10/libexec/ccc-analyzer line 502.


Modified:
cfe/trunk/tools/scan-build/libexec/ccc-analyzer

Modified: cfe/trunk/tools/scan-build/libexec/ccc-analyzer
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/libexec/ccc-analyzer?rev=371832=371831=371832=diff
==
--- cfe/trunk/tools/scan-build/libexec/ccc-analyzer (original)
+++ cfe/trunk/tools/scan-build/libexec/ccc-analyzer Fri Sep 13 02:31:19 2019
@@ -499,7 +499,7 @@ my $HasSDK = 0;
 foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
   my $Arg = $ARGV[$i];
   my @ArgParts = split /=/,$Arg,2;
-  my $ArgKey = @ArgParts[0];
+  my $ArgKey = $ArgParts[0];
 
   # Be friendly to "" in the argument list.
   if (!defined($ArgKey)) {


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


[PATCH] D67135: [clang-tidy] performance-inefficient-vector-operation: Support proto repeated field

2019-09-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.

feel free to commit the patch.


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

https://reviews.llvm.org/D67135



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


[PATCH] D66653: [clang-format] Turn include regrouping on for Google ObjC style

2019-09-13 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir abandoned this revision.
krasimir added a comment.

This was for experimental purposes, abandoning.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66653



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


[PATCH] D67399: [ARM] Follow AACPS standard for volatile bitfields

2019-09-13 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio added a comment.

Indeed our main concern is regarding the access widths of loads. As mentioned 
by @rjmccall, most volatile bitfields are used to perform memory mapped I/O, 
and some hardware only support them with a specific access width.
The spurious load I am more than glad to leave it disable behind a command 
flag, so it will only appear if the user requests it. See that volatile 
accesses might have side effects, and for example, an I/O read counter holding 
an odd number could define that the data is still being processed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67399



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


[PATCH] D67246: clang-format: Add support for formatting lambdas with explicit template parameters.

2019-09-13 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

This looks good with the FIXME.


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

https://reviews.llvm.org/D67246



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


[PATCH] D64146: [Clang Interpreter] Initial patch for the constexpr interpreter

2019-09-13 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

Accepting this to remove the block


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64146



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


[PATCH] D67405: Make FormatToken::Type private.

2019-09-13 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.

This looks fine as it is, adding a side-effect to a function that's called 
`setType` and is called in lots of places may be hard to reason about.

You haven't mentioned how the interception will be used - if it's possible to 
express as a simple assignment an then some later operation, it might be 
clearer.




Comment at: clang/lib/Format/FormatToken.h:185
 
-  TokenType Type = TT_Unknown;
+  /// Returns the token's type, e.g. whether "<" is a template opener or
+  /// binary operator.

Hooray for adding documentation! While here... ;-)

consider moving this documentation to the enum, and elaborating slightly on the 
relationship between `TokenType` and `TokenKind`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67405



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


[PATCH] D67160: [clang, ARM] Default to -fno-lax-vector-conversions in ARM v8.1-M.

2019-09-13 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

FYI: rL371817 , in case it changes what is 
done here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67160



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


Re: r371766 - [Clang][CodeGen] support alias attribute w/ gnu_inline

2019-09-13 Thread Hans Wennborg via cfe-commits
Merged to release_90 in r371821.

On Thu, Sep 12, 2019 at 9:51 PM Nick Desaulniers via cfe-commits
 wrote:
>
> Author: nickdesaulniers
> Date: Thu Sep 12 12:53:35 2019
> New Revision: 371766
>
> URL: http://llvm.org/viewvc/llvm-project?rev=371766=rev
> Log:
> [Clang][CodeGen] support alias attribute w/ gnu_inline
>
> Summary:
> r369705 did not consider the addition of gnu_inline on function
> declarations of alias attributed functions. This resulted in a reported
> regression in the clang-9-rc4 release from the Zig developers building
> glibc, which was observable as a failed assertion:
>
> llvm-project/clang/lib/AST/Decl.cpp:3336: bool
> clang::FunctionDecl::isInlineDefinitionExternallyVisible() const:
> Assertion `(doesThisDeclarationHaveABody() || willHaveBody()) && "Must
> be a function definition"' failed.
>
> Alias function declarations do not have bodies, so allow us to proceed
> if we have the alias function attribute but no body/definition, and add
> a test case.  The emitted symbols and their linkage matches GCC for the
> added test case.
>
> Link: https://bugs.llvm.org/show_bug.cgi?id=43268
>
> Reviewers: aaron.ballman, rsmith, erichkeane, andrewrk
>
> Reviewed By: andrewrk
>
> Subscribers: cfe-commits, andrewrk, hans, srhines
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D67455
>
> Modified:
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/test/CodeGen/alias.c
>
> Modified: cfe/trunk/lib/AST/Decl.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=371766=371765=371766=diff
> ==
> --- cfe/trunk/lib/AST/Decl.cpp (original)
> +++ cfe/trunk/lib/AST/Decl.cpp Thu Sep 12 12:53:35 2019
> @@ -3348,7 +3348,8 @@ SourceRange FunctionDecl::getExceptionSp
>  /// an externally visible symbol, but "extern inline" will not create an
>  /// externally visible symbol.
>  bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
> -  assert((doesThisDeclarationHaveABody() || willHaveBody()) &&
> +  assert((doesThisDeclarationHaveABody() || willHaveBody() ||
> +  hasAttr()) &&
>   "Must be a function definition");
>assert(isInlined() && "Function must be inline");
>ASTContext  = getASTContext();
>
> Modified: cfe/trunk/test/CodeGen/alias.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/alias.c?rev=371766=371765=371766=diff
> ==
> --- cfe/trunk/test/CodeGen/alias.c (original)
> +++ cfe/trunk/test/CodeGen/alias.c Thu Sep 12 12:53:35 2019
> @@ -99,3 +99,8 @@ static int test10_foo __attribute__((ali
>  // CHECKGLOBALS-NOT: @test11_foo = dso_local
>  void test11(void) {}
>  static void test11_foo(void) __attribute__((alias("test11")));
> +
> +// Test that gnu_inline+alias work.
> +// CHECKGLOBALS: @test12_alias = alias void (), void ()* @test12
> +void test12(void) {}
> +inline void test12_alias(void) __attribute__((gnu_inline, alias("test12")));
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67490: [Clang][ASTImporter] Added visibility check for FunctionTemplateDecl.

2019-09-13 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371820: [Clang][ASTImporter] Added visibility check for 
FunctionTemplateDecl. (authored by balazske, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67490?vs=219879=220047#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67490

Files:
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp

Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -5638,17 +5638,16 @@
 continue;
 
   if (auto *FoundTemplate = dyn_cast(FoundDecl)) {
-if (FoundTemplate->hasExternalFormalLinkage() &&
-D->hasExternalFormalLinkage()) {
-  if (IsStructuralMatch(D, FoundTemplate)) {
-FunctionTemplateDecl *TemplateWithDef =
-getTemplateDefinition(FoundTemplate);
-if (D->isThisDeclarationADefinition() && TemplateWithDef) {
-  return Importer.MapImported(D, TemplateWithDef);
-}
-FoundByLookup = FoundTemplate;
-break;
-  }
+if (!hasSameVisibilityContext(FoundTemplate, D))
+  continue;
+if (IsStructuralMatch(D, FoundTemplate)) {
+  FunctionTemplateDecl *TemplateWithDef =
+  getTemplateDefinition(FoundTemplate);
+  if (D->isThisDeclarationADefinition() && TemplateWithDef)
+return Importer.MapImported(D, TemplateWithDef);
+
+  FoundByLookup = FoundTemplate;
+  break;
   // TODO: handle conflicting names
 }
   }
Index: cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp
@@ -43,6 +43,12 @@
   using DeclTy = TypedefNameDecl;
   BindableMatcher operator()() { return typedefNameDecl(hasName("T")); }
 };
+struct GetFunTemplPattern {
+  using DeclTy = FunctionTemplateDecl;
+  BindableMatcher operator()() {
+return functionTemplateDecl(hasName("f"));
+  }
+};
 
 // Values for the value-parameterized test fixtures.
 // FunctionDecl:
@@ -64,6 +70,10 @@
 const auto *AnonTypedef = "namespace { typedef int T; }";
 const auto *ExternUsing = "using T = int;";
 const auto *AnonUsing = "namespace { using T = int; }";
+// FunctionTemplateDecl:
+const auto *ExternFT = "template  void f();";
+const auto *StaticFT = "template  static void f();";
+const auto *AnonFT = "namespace { template  void f(); }";
 
 // First value in tuple: Compile options.
 // Second value in tuple: Source code to be used in the test.
@@ -108,6 +118,9 @@
 using ImportFunctionsVisibilityChain = ImportVisibilityChain;
 using ImportVariablesVisibilityChain = ImportVisibilityChain;
 using ImportClassesVisibilityChain = ImportVisibilityChain;
+using ImportFunctionTemplatesVisibilityChain =
+ImportVisibilityChain;
+
 // Value-parameterized test for functions.
 TEST_P(ImportFunctionsVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
@@ -120,6 +133,10 @@
 TEST_P(ImportClassesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
 }
+// Value-parameterized test for function templates.
+TEST_P(ImportFunctionTemplatesVisibilityChain, ImportChain) {
+  TypedTest_ImportChain();
+}
 
 // Automatic instantiation of the value-parameterized tests.
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctionsVisibilityChain,
@@ -143,6 +160,11 @@
 ::testing::Combine(
 DefaultTestValuesForRunOptions,
 ::testing::Values(ExternC, AnonC)), );
+INSTANTIATE_TEST_CASE_P(ParameterizedTests,
+ImportFunctionTemplatesVisibilityChain,
+::testing::Combine(DefaultTestValuesForRunOptions,
+   ::testing::Values(ExternFT, StaticFT,
+ AnonFT)), );
 
 // First value in tuple: Compile options.
 // Second value in tuple: Tuple with informations for the test.
@@ -253,6 +275,7 @@
 using ImportClassesVisibility = ImportVisibility;
 using ImportEnumsVisibility = ImportVisibility;
 using ImportTypedefNameVisibility = ImportVisibility;
+using ImportFunctionTemplatesVisibility = ImportVisibility;
 
 // FunctionDecl.
 TEST_P(ImportFunctionsVisibility, ImportAfter) {
@@ -289,6 +312,13 @@
 TEST_P(ImportTypedefNameVisibility, ImportAfterImport) {
   TypedTest_ImportAfterImportWithMerge();
 }
+// FunctionTemplateDecl.
+TEST_P(ImportFunctionTemplatesVisibility, ImportAfter) {
+  TypedTest_ImportAfter();
+}
+TEST_P(ImportFunctionTemplatesVisibility, ImportAfterImport) {
+  TypedTest_ImportAfterImport();
+}
 
 const bool 

r371820 - [Clang][ASTImporter] Added visibility check for FunctionTemplateDecl.

2019-09-13 Thread Balazs Keri via cfe-commits
Author: balazske
Date: Fri Sep 13 01:03:49 2019
New Revision: 371820

URL: http://llvm.org/viewvc/llvm-project?rev=371820=rev
Log:
[Clang][ASTImporter] Added visibility check for FunctionTemplateDecl.

Summary:
ASTImporter makes now difference between function templates with same
name in different translation units if these are not visible outside.

Reviewers: martong, a.sidorin, shafik, a_sidorin

Reviewed By: a_sidorin

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

Tags: #clang

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

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

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=371820=371819=371820=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Fri Sep 13 01:03:49 2019
@@ -5638,17 +5638,16 @@ ASTNodeImporter::VisitFunctionTemplateDe
 continue;
 
   if (auto *FoundTemplate = dyn_cast(FoundDecl)) {
-if (FoundTemplate->hasExternalFormalLinkage() &&
-D->hasExternalFormalLinkage()) {
-  if (IsStructuralMatch(D, FoundTemplate)) {
-FunctionTemplateDecl *TemplateWithDef =
-getTemplateDefinition(FoundTemplate);
-if (D->isThisDeclarationADefinition() && TemplateWithDef) {
-  return Importer.MapImported(D, TemplateWithDef);
-}
-FoundByLookup = FoundTemplate;
-break;
-  }
+if (!hasSameVisibilityContext(FoundTemplate, D))
+  continue;
+if (IsStructuralMatch(D, FoundTemplate)) {
+  FunctionTemplateDecl *TemplateWithDef =
+  getTemplateDefinition(FoundTemplate);
+  if (D->isThisDeclarationADefinition() && TemplateWithDef)
+return Importer.MapImported(D, TemplateWithDef);
+
+  FoundByLookup = FoundTemplate;
+  break;
   // TODO: handle conflicting names
 }
   }

Modified: cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp?rev=371820=371819=371820=diff
==
--- cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp Fri Sep 13 01:03:49 
2019
@@ -43,6 +43,12 @@ struct GetTypedefNamePattern {
   using DeclTy = TypedefNameDecl;
   BindableMatcher operator()() { return typedefNameDecl(hasName("T")); }
 };
+struct GetFunTemplPattern {
+  using DeclTy = FunctionTemplateDecl;
+  BindableMatcher operator()() {
+return functionTemplateDecl(hasName("f"));
+  }
+};
 
 // Values for the value-parameterized test fixtures.
 // FunctionDecl:
@@ -64,6 +70,10 @@ const auto *ExternTypedef = "typedef int
 const auto *AnonTypedef = "namespace { typedef int T; }";
 const auto *ExternUsing = "using T = int;";
 const auto *AnonUsing = "namespace { using T = int; }";
+// FunctionTemplateDecl:
+const auto *ExternFT = "template  void f();";
+const auto *StaticFT = "template  static void f();";
+const auto *AnonFT = "namespace { template  void f(); }";
 
 // First value in tuple: Compile options.
 // Second value in tuple: Source code to be used in the test.
@@ -108,6 +118,9 @@ protected:
 using ImportFunctionsVisibilityChain = ImportVisibilityChain;
 using ImportVariablesVisibilityChain = ImportVisibilityChain;
 using ImportClassesVisibilityChain = ImportVisibilityChain;
+using ImportFunctionTemplatesVisibilityChain =
+ImportVisibilityChain;
+
 // Value-parameterized test for functions.
 TEST_P(ImportFunctionsVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
@@ -120,6 +133,10 @@ TEST_P(ImportVariablesVisibilityChain, I
 TEST_P(ImportClassesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
 }
+// Value-parameterized test for function templates.
+TEST_P(ImportFunctionTemplatesVisibilityChain, ImportChain) {
+  TypedTest_ImportChain();
+}
 
 // Automatic instantiation of the value-parameterized tests.
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctionsVisibilityChain,
@@ -143,6 +160,11 @@ INSTANTIATE_TEST_CASE_P(
 ::testing::Combine(
 DefaultTestValuesForRunOptions,
 ::testing::Values(ExternC, AnonC)), );
+INSTANTIATE_TEST_CASE_P(ParameterizedTests,
+ImportFunctionTemplatesVisibilityChain,
+::testing::Combine(DefaultTestValuesForRunOptions,
+   ::testing::Values(ExternFT, 
StaticFT,
+ AnonFT)), );
 
 // First value in tuple: Compile options.
 // Second value in tuple: Tuple with informations for the test.
@@ -253,6 +275,7 @@ using ImportVariablesVisibility 

[PATCH] D61717: Fix arm_neon.h to be clean under -fno-lax-vector-conversions.

2019-09-13 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Yeah, sorry about that

Do you perhaps have a test case or error that I can look at? Perhaps I or 
someone else here can help out a bit here.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61717



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


  1   2   >