[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-10 Thread Florian Hahn via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb109c42d91c: [DSE] Switch to MemorySSA-backed DSE by 
default. (authored by fhahn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  clang/test/CodeGenObjC/exceptions.m
  llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
  llvm/test/Analysis/BasicAA/modref.ll
  llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/test/Transforms/Coroutines/ArgAddr.ll
  llvm/test/Transforms/Coroutines/coro-retcon.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/2011-03-25-DSEMiscompile.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/2011-09-06-EndOfFunction.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/2011-09-06-MemCpy.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/2016-07-17-UseAfterFree.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/OverwriteStoreBegin.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/OverwriteStoreEnd.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/PartialStore.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/PartialStore2.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/X86/gather-null-pointer.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/atomic-overlapping.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/atomic-todo.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/atomic.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/calloc-store.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/combined-partial-overwrites.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/const-pointers.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/crash.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/cs-cs-aliasing.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/debug-counter.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/debuginfo.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/dominate.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/fence-todo.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/fence.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/free.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/inst-limits.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/int_sideeffect.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/invariant.start.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/launder.invariant.group.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/libcalls.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/lifetime.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/mda-with-dbg-values.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/memcpy-complete-overwrite.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/memintrinsics.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/memoryssa-scan-limit.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/memset-and-memcpy.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/memset-missing-debugloc.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/memset-unknown-sizes.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/merge-stores-big-endian.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/merge-stores.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-captures.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-exceptions.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-loops.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-malloc-free.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-memintrinsics.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-memoryphis.ll
  
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-multipath-throwing.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-multipath.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-overlap.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-partial.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-simple.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-throwing.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-unreachable.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/no-targetdata.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/noop-stores.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/operand-bundles.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/overlap.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/pr11390.ll
  
llvm/test/Transforms/DeadStoreElimination/MSSA/pr47285-not-overwritten-on-all-exit-paths.ll
  llvm/test/Transforms/DeadStoreElimination/MSSA/simpl

[PATCH] D80409: [MS ABI] Add mangled type for auto template parameter whose argument kind is Integeral

2020-09-10 Thread Reid "Away June-Sep" Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:383
+const NonTypeTemplateParmDecl *PD = nullptr,
+QualType *TemplateArgType = nullptr);
+  void mangleExpression(const Expr *E, const NonTypeTemplateParmDecl *PD);

I see you need an optional QualType here. Can you do this: `QualType 
TemplateArgType = QualType()`? I believe it will create a null QualType, which 
you can then check for with `.isNull()`.

QualType is pointer-sized and is generally passed by value. I think it will 
help make the other call sites shorter, so they don't need to take the address 
of a local variable.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:1390
+QualType T = E->getType();
+mangleIntegerLiteral(Value, PD, &T);
 return;

For example, if you can avoid the pointer indirection, you can avoid the local 
variable here.


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

https://reviews.llvm.org/D80409

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


[PATCH] D87047: [clang] Add command line options for the Machine Function Splitter.

2020-09-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added inline comments.
This revision now requires changes to proceed.



Comment at: clang/include/clang/Driver/Options.td:1992
 
+def fsplit_machine_functions : Flag <["-"], "fsplit-machine-functions">,
+  Group, Flags<[CC1Option]>,

Please use `OptInFFlag` and see its comment.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4259
 options::OPT_fno_unique_basic_block_section_names,
+options::OPT_fsplit_machine_functions,
+options::OPT_fno_split_machine_functions,

This is not needed.

This is for fembed-bitcode and people seem to randomly add options here. Many 
options are probably not needed.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4922
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << "-fsplit-machine-functions" << TripleStr;
+  }

If you use getLastArg

A->getAsString(Args)



Comment at: clang/test/CodeGen/split-machine-functions.c:3
+
+// RUN: echo "foo"> %t.proftext
+// RUN: echo "# Func Hash:"   >> %t.proftext

Consider `RUN: split-file`

Search for this string for some examples.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87047

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


[PATCH] D87395: Sema: add support for `__attribute__((__swift_objc_members__))`

2020-09-10 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd marked an inline comment as done.
compnerd added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2121
 
+def SwiftObjCMembers : Attr {
+  let Spellings = [GNU<"swift_objc_members">];

aaron.ballman wrote:
> Should this be inherited by redeclarations, or is that not a thing with 
> `ObjCInterfaceDecl`s?
Objective-C interfaces cannot be redeclared, so this actually is correct I 
believe.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:7546
+  case ParsedAttr::AT_SwiftObjCMembers:
+handleSimpleAttribute(S, D, AL);
+break;

aaron.ballman wrote:
> Does it matter if the user writes this attribute on an interface that exposes 
> no members? e.g., are there warnings we may want to give the user about using 
> the attribute in a weird way? (Sorry if this should be obvious, but I don't 
> have experience with Swift.)
I think that the name is not exactly helpful in this case, but that ship has 
sailed since this is in production already.  AIUI the attribute should apply to 
empty interfaces as it results in the Swift interface being exposed back to 
Objective-C.



Comment at: clang/test/SemaObjC/attr-swift_objc_members.m:4
+#if !__has_attribute(swift_objc_members)
+#error cannot verify precense of swift_objc_members attribute
+#endif

aaron.ballman wrote:
> gribozavr2 wrote:
> > aaron.ballman wrote:
> > > gribozavr2 wrote:
> > > > 
> > > The typo fix makes sense to me, but for my own understanding, why switch 
> > > to a string literal?
> > IIUC, as it is now, the message is tokenized by the lexer -- and I think 
> > that's not the intent, none of these words are program code.
> Interesting and somewhat different from my understanding. My mental model for 
> `#error` is that it "replays" the tokens into the diagnostic message up to 
> the end of the line. Given that I prefer my diagnostics to be `warning: you 
> did the wrong thing` and not `warning: "you did the wrong thing"` (with 
> quotes), I usually leave the quotes off so that the error looks more 
> consistent with other errors.
> 
> Neither form is more right than the other in this case, so I don't really 
> care for this review (I was interested in it as a standards committee member 
> who recently had to look at the specification for `#error` though).
FWIW, the reason for the warning not being quoted currently is exactly what 
@aaron.ballman stated ... that is how I process the `#error` directive as well, 
and I tend to leave the quotes off to make the error match the other 
diagnostics.  Is the quoting really that important?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87395

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


[PATCH] D86621: [clang][Sparc] Default to -mcpu=v9 for SparcV8 on Solaris

2020-09-10 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

Ping?  It's been a week and AFAICT there's nothing left for me to do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86621

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


[PATCH] D86621: [clang][Sparc] Default to -mcpu=v9 for SparcV8 on Solaris

2020-09-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86621

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


[PATCH] D86796: [Sema] Address-space sensitive index check for unbounded arrays

2020-09-10 Thread Chris Hamilton via Phabricator via cfe-commits
chrish_ericsson_atx added a comment.

Thank you for the comments, @aaron.ballman .   I'll update with the changes you 
requested shortly.  I did have some requests for clarification of you, though.  
Thanks!




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8841-8844
+def warn_array_index_exceeds_max_addressable_bounds : Warning<
+  "array index %0 refers past the last possible element for an array in %1-bit 
"
+  "address space containing %2-bit (%3-byte) elements (max possible %4 
element%s5)">,
+  InGroup;

aaron.ballman wrote:
> I'd combine this with the above diagnostic given how similar they are:
> ```
> def warn_exceeds_max_addressable_bounds : Warning<
>   "%select{array index %1|the pointer incremented by %1}0 refers past the 
> last possible element for an array in %2-bit "
>   "address space containing %3-bit (%4-byte) elements (max possible %5 
> element%s6)">,
>   InGroup;
> ```
I was attempting to follow the pattern set by the preceding four definitions, 
which keep pointer math warnings and array index warnings separated, but are 
otherwise nearly identical.  If there's value in that pattern for those other 
warnings, I would assume the same value applies to keeping these separated.  
Please re-ping if you disagree, otherwise, I'll leave these as two separate 
warnings.



Comment at: clang/lib/Sema/SemaChecking.cpp:14063
+  if (isUnboundedArray) {
+if (index.isUnsigned() || !index.isNegative()) {
+  const auto &ASTC = getASTContext();

aaron.ballman wrote:
> ebevhan wrote:
> > This could be early return to avoid the indentation.
> +1 to using early return here. I might even get rid of `isUnboundedArray` and 
> just use `!BaseType`
@ebevhan's comment about early return was actually addressed in a previous 
diff... I should have marked it as such.  My apologies.

I'd prefer to keep `isUnboundedArray` (with the case corrected, of course), as 
it seems much clearer than `!BaseType` in terms of expressing what we are 
actually checking here, and why.



Comment at: clang/lib/Sema/SemaChecking.cpp:14100
+  // dependent CharUnits)
+  DiagRuntimeBehavior(BaseExpr->getBeginLoc(), BaseExpr,
+  PDiag(DiagID)

aaron.ballman wrote:
> It's not clear to me whether we need to pay the extra expense of doing 
> reachability checks for the diagnostic -- do you have evidence that there 
> would be a high false positive rate if we always emit the diagnostic?
Sorry-- I'm not following you here, @aaron.ballman. What reachability check are 
you referring to?  The diagnostic isn't conditioned on anything (at least not 
here, where your comment appears...), so I'm not sure what change you are 
suggesting that would "always emit the diagnostic"...  Sorry to be slow on the 
uptake here... Could you clarify that for me?



Comment at: clang/lib/Sema/SemaChecking.cpp:14111
+// Try harder to find a NamedDecl to point at in the note.
+while (const ArraySubscriptExpr *ASE =
+   dyn_cast(BaseExpr))

aaron.ballman wrote:
> You can use `const auto *` here since the type is spelled out in the 
> initialization. Same below.
Fair point -- this was just cut-and-paste from the code I had to duplicate in 
order to address the early return comment from @ebevhan.  :)  I'll change it in 
both places.



Comment at: clang/lib/Sema/SemaChecking.cpp:14121
+  if (ND)
+DiagRuntimeBehavior(ND->getBeginLoc(), BaseExpr,
+PDiag(diag::note_array_declared_here) << ND);

aaron.ballman wrote:
> Similar comment here about reachability.
Similar request for clarification.  ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86796

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


[PATCH] D87463: [clang][aarch64] Fix mangling of bfloat16 neon vectors

2020-09-10 Thread Ties Stuij via Phabricator via cfe-commits
stuij accepted this revision.
stuij added a comment.
This revision is now accepted and ready to land.

Thanks, this one crept in during mass-renaming.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87463

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


[PATCH] D87395: Sema: add support for `__attribute__((__swift_objc_members__))`

2020-09-10 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/test/SemaObjC/attr-swift_objc_members.m:4
+#if !__has_attribute(swift_objc_members)
+#error cannot verify precense of swift_objc_members attribute
+#endif

compnerd wrote:
> aaron.ballman wrote:
> > gribozavr2 wrote:
> > > aaron.ballman wrote:
> > > > gribozavr2 wrote:
> > > > > 
> > > > The typo fix makes sense to me, but for my own understanding, why 
> > > > switch to a string literal?
> > > IIUC, as it is now, the message is tokenized by the lexer -- and I think 
> > > that's not the intent, none of these words are program code.
> > Interesting and somewhat different from my understanding. My mental model 
> > for `#error` is that it "replays" the tokens into the diagnostic message up 
> > to the end of the line. Given that I prefer my diagnostics to be `warning: 
> > you did the wrong thing` and not `warning: "you did the wrong thing"` (with 
> > quotes), I usually leave the quotes off so that the error looks more 
> > consistent with other errors.
> > 
> > Neither form is more right than the other in this case, so I don't really 
> > care for this review (I was interested in it as a standards committee 
> > member who recently had to look at the specification for `#error` though).
> FWIW, the reason for the warning not being quoted currently is exactly what 
> @aaron.ballman stated ... that is how I process the `#error` directive as 
> well, and I tend to leave the quotes off to make the error match the other 
> diagnostics.  Is the quoting really that important?
No, not at all important.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87395

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


[PATCH] D87047: [clang] Add command line options for the Machine Function Splitter.

2020-09-10 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish updated this revision to Diff 291108.
snehasish added a comment.

Use OptInFFlag, split-file and update tests.

- Change the flag type to OptInFFlag.
- Use split-file in the test to avoid "RUN: echo" lines.
- Use an existing warn message (if no profile is available) and add a check for 
it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87047

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/split-machine-functions.c
  clang/test/Driver/fsplit-machine-functions.c

Index: clang/test/Driver/fsplit-machine-functions.c
===
--- /dev/null
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -0,0 +1,9 @@
+// RUN: %clang -### -target x86_64 -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
+// RUN: %clang -### -target x86_64 -fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
+// RUN: %clang -c -target x86_64 -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-WARN %s
+// RUN: not %clang -c -target arm-unknown-linux -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+
+// CHECK-OPT:   "-fsplit-machine-functions"
+// CHECK-NOOPT-NOT: "-fsplit-machine-functions"
+// CHECK-WARN:  ignored -fsplit-machine-functions, no profile provided via -fprofile-use
+// CHECK-TRIPLE:error: unsupported option '-fsplit-machine-functions' for target
Index: clang/test/CodeGen/split-machine-functions.c
===
--- /dev/null
+++ clang/test/CodeGen/split-machine-functions.c
@@ -0,0 +1,37 @@
+// REQUIRES: x86-registered-target
+// RUN: split-file %s %t
+// RUN: llvm-profdata merge -o %t/default.profdata %t/proftext
+// RUN: %clang_cc1 -triple x86_64 -O3 -S -fprofile-instrument-use-path=%t/default.profdata -fsplit-machine-functions -o - < %t/code | FileCheck %s
+
+// CHECK: .section .text.hot.,"ax",@progbits
+// CHECK: foo:
+// CHECK: section .text.unlikely.foo,"ax",@progbits
+// CHECK: foo.cold:
+// CHECK: callq exit@PLT
+
+//--- proftext
+foo
+#Func Hash:
+11262309905
+#Num Counters:
+2
+#Counter Values:
+100 0
+
+//--- code
+__attribute__((noinline)) int
+foo(int argc) {
+  if (argc % 2 == 0) {
+exit(argc);
+  } else {
+return argc + 1;
+  }
+}
+
+int main(int argc, char *argv[]) {
+  int total = 0;
+  for (int i = 0; i < 100; ++i) {
+total += foo(argc);
+  }
+  printf("%d\n", total);
+}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -998,6 +998,8 @@
   Opts.UniqueInternalLinkageNames =
   Args.hasArg(OPT_funique_internal_linkage_names);
 
+  Opts.SplitMachineFunctions = Args.hasArg(OPT_fsplit_machine_functions);
+
   Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4911,6 +4911,15 @@
options::OPT_fno_unique_basic_block_section_names, false))
 CmdArgs.push_back("-funique-basic-block-section-names");
 
+  if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
+   options::OPT_fno_split_machine_functions)) {
+if (Triple.isX86() && Triple.isOSBinFormatELF())
+  A->render(Args, CmdArgs);
+else
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+  }
+
   Args.AddLastArg(CmdArgs, options::OPT_finstrument_functions,
   options::OPT_finstrument_functions_after_inlining,
   options::OPT_finstrument_function_entry_bare);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -9,6 +9,7 @@
 #include "clang/CodeGen/BackendUtil.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticFrontend.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/TargetOptions.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
@@ -514,6 +515,15 @@
   Options.BBSectionsFuncListBuf = std::move(*MBOrErr);
   }
 
+  if (CodeGenOpts.SplitMachineFunctions) {
+if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
+  Options.EnableMachineFunctionSpli

[PATCH] D87047: [clang] Add command line options for the Machine Function Splitter.

2020-09-10 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish marked 3 inline comments as done.
snehasish added a comment.

PTAL, thanks!




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4259
 options::OPT_fno_unique_basic_block_section_names,
+options::OPT_fsplit_machine_functions,
+options::OPT_fno_split_machine_functions,

MaskRay wrote:
> This is not needed.
> 
> This is for fembed-bitcode and people seem to randomly add options here. Many 
> options are probably not needed.
Thanks for catching this. I read this list as "options which should be ignored 
for embedding bitcode". In this case we do want to save this flag to pass back 
to clang if necessary (as mtrofin@ pointed out offline). Perhaps the 
documentation around this could be enhanced.



Comment at: clang/test/CodeGen/split-machine-functions.c:3
+
+// RUN: echo "foo"> %t.proftext
+// RUN: echo "# Func Hash:"   >> %t.proftext

MaskRay wrote:
> Consider `RUN: split-file`
> 
> Search for this string for some examples.
Looks much cleaner with split-file overall, though it doesn't play well with 
clang-format since this is a .c file. Should we just ignore clang-format 
complaints for this file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87047

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


[PATCH] D87470: [Coroutine][Sema] Tighten the lifetime of symmetric transfer returned handle

2020-09-10 Thread JunMa via Phabricator via cfe-commits
junparser added a comment.

Thanks for the change. LGTM, and testcase?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87470

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


[PATCH] D80409: [MS ABI] Add mangled type for auto template parameter whose argument kind is Integeral

2020-09-10 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 29.
zequanwu marked 2 inline comments as done.
zequanwu retitled this revision from "[MS ABI] Add mangled type for auto 
template parameter whose argument kind is Integeral " to "[MS ABI] Add mangled 
type for auto template parameter whose argument kind is Integeral".
zequanwu added a comment.

rebase and address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80409

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/lib/AST/MicrosoftMangle.cpp
  clang/test/CodeGenCXX/mangle-ms-auto-templates.cpp

Index: clang/test/CodeGenCXX/mangle-ms-auto-templates.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/mangle-ms-auto-templates.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++17 -fms-compatibility-version=19.20 -emit-llvm %s -o - -fms-extensions -fdelayed-template-parsing -triple=x86_64-pc-windows-msvc | FileCheck %s
+
+template 
+class AutoParmTemplate {
+public:
+  AutoParmTemplate() {}
+};
+
+template 
+class AutoParmsTemplate {
+public:
+  AutoParmsTemplate() {}
+};
+
+void template_mangling() {
+  AutoParmTemplate<0> auto_int;
+  // CHECK: call {{.*}} @"??0?$AutoParmTemplate@$MH0A@@@QEAA@XZ"
+  AutoParmTemplate auto_bool;
+  // CHECK: call {{.*}} @"??0?$AutoParmTemplate@$M_N0A@@@QEAA@XZ"
+  AutoParmTemplate<'a'> auto_char;
+  // CHECK: call {{.*}} @"??0?$AutoParmTemplate@$MD0GB@@@QEAA@XZ"
+  AutoParmTemplate<9223372036854775807LL> int64_max;
+  // CHECK: call {{.*}} @"??0?$AutoParmTemplate@$M_J0HPPP@@@QEAA@XZ"
+  AutoParmTemplate<-9223372036854775807LL - 1LL> int64_min;
+  // CHECK: call {{.*}} @"??0?$AutoParmTemplate@$M_J0?IAAA@@@QEAA@XZ"
+  AutoParmTemplate<(unsigned long long)-1> uint64_neg_1;
+  // CHECK: call {{.*}} @"??0?$AutoParmTemplate@$M_K0?0@@QEAA@XZ"
+
+  AutoParmsTemplate<0, false, 'a'> c1;
+  // CHECK: call {{.*}} @"??0?$AutoParmsTemplate@$MH0A@$M_N0A@$MD0GB@@@QEAA@XZ"
+  AutoParmsTemplate<(unsigned long)1, 9223372036854775807LL> c2;
+  // CHECK: call {{.*}} @"??0?$AutoParmsTemplate@$MK00$M_J0HPPP@@@QEAA@XZ"
+}
Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -378,8 +378,10 @@
   void mangleFunctionClass(const FunctionDecl *FD);
   void mangleCallingConvention(CallingConv CC);
   void mangleCallingConvention(const FunctionType *T);
-  void mangleIntegerLiteral(const llvm::APSInt &Number, bool IsBoolean);
-  void mangleExpression(const Expr *E);
+  void mangleIntegerLiteral(const llvm::APSInt &Number,
+const NonTypeTemplateParmDecl *PD = nullptr,
+QualType TemplateArgType = QualType());
+  void mangleExpression(const Expr *E, const NonTypeTemplateParmDecl *PD);
   void mangleThrowSpecification(const FunctionProtoType *T);
 
   void mangleTemplateArgs(const TemplateDecl *TD,
@@ -1357,24 +1359,35 @@
   mangleUnqualifiedName(TD);
 }
 
-void MicrosoftCXXNameMangler::mangleIntegerLiteral(const llvm::APSInt &Value,
-   bool IsBoolean) {
-  //  ::= $0 
-  Out << "$0";
-  // Make sure booleans are encoded as 0/1.
-  if (IsBoolean && Value.getBoolValue())
-mangleNumber(1);
-  else if (Value.isSigned())
+void MicrosoftCXXNameMangler::mangleIntegerLiteral(
+const llvm::APSInt &Value, const NonTypeTemplateParmDecl *PD,
+QualType TemplateArgType) {
+  //  ::= $ [] 0 
+  Out << "$";
+
+  // mangle argument type if parmeter is auto
+  if (getASTContext().getLangOpts().isCompatibleWithMSVC(
+  LangOptions::MSVC2019) &&
+  PD && PD->getType()->getTypeClass() == Type::Auto &&
+  !TemplateArgType.isNull()) {
+Out << "M";
+mangleType(TemplateArgType, SourceRange(), QMM_Drop);
+  }
+
+  Out << "0";
+
+  if (Value.isSigned())
 mangleNumber(Value.getSExtValue());
   else
 mangleNumber(Value.getZExtValue());
 }
 
-void MicrosoftCXXNameMangler::mangleExpression(const Expr *E) {
+void MicrosoftCXXNameMangler::mangleExpression(
+const Expr *E, const NonTypeTemplateParmDecl *PD) {
   // See if this is a constant expression.
   if (Optional Value =
   E->getIntegerConstantExpr(Context.getASTContext())) {
-mangleIntegerLiteral(*Value, E->getType()->isBooleanType());
+mangleIntegerLiteral(*Value, PD, E->getType());
 return;
   }
 
@@ -1448,10 +1461,12 @@
 }
 break;
   }
-  case TemplateArgument::Integral:
+  case TemplateArgument::Integral: {
+QualType T = TA.getIntegralType();
 mangleIntegerLiteral(TA.getAsIntegral(),
- TA.getIntegralType()->isBooleanType());
+ cast(Parm), T);
 break;
+  }
   case TemplateArgument::NullPtr: {
 QualType T = TA.getNullPtrType();
 if (const MemberPointerType *MPT = T->getAs()

Re: r364428 - Make CodeGen depend on ASTMatchers

2020-09-10 Thread Michael LIAO via cfe-commits
That change was added long ago to fix the shared library build.
Possibly, there are changes removing that dependency then. Just
verified that removing that dependency is just fine.

On Thu, Sep 10, 2020 at 6:48 AM Vassil Vassilev  wrote:
>
> Hello,
>
>IIUC, clang's CodeGen does not immediately depend on ASTMatchers. I
> was wondering what is the reason for inserting such a dependency to fix
> the shared library builds?
>
>Can you give more details about the failure you are fixing?
>
>Sorry for the late question.
>
> Best, Vassil
> On 6/26/19 5:13 PM, Michael Liao via cfe-commits wrote:
> > Author: hliao
> > Date: Wed Jun 26 07:13:43 2019
> > New Revision: 364428
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=364428&view=rev
> > Log:
> > Make CodeGen depend on ASTMatchers
> >
> > - Shared library builds are broken due to the missing dependency.
> >
> > Modified:
> >  cfe/trunk/lib/CodeGen/CMakeLists.txt
> >
> > Modified: cfe/trunk/lib/CodeGen/CMakeLists.txt
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CMakeLists.txt?rev=364428&r1=364427&r2=364428&view=diff
> > ==
> > --- cfe/trunk/lib/CodeGen/CMakeLists.txt (original)
> > +++ cfe/trunk/lib/CodeGen/CMakeLists.txt Wed Jun 26 07:13:43 2019
> > @@ -101,6 +101,7 @@ add_clang_library(clangCodeGen
> > LINK_LIBS
> > clangAnalysis
> > clangAST
> > +  clangASTMatchers
> > clangBasic
> > clangFrontend
> > clangLex
> >
> >
> > ___
> > 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


[clang] b22d450 - Remove dependency on clangASTMatchers.

2020-09-10 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2020-09-10T22:17:48-04:00
New Revision: b22d45049682d1461b6b786f159681e2e5c2ce24

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

LOG: Remove dependency on clangASTMatchers.

- It seems no long required for shared library builds.

Added: 


Modified: 
clang/lib/CodeGen/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/CodeGen/CMakeLists.txt 
b/clang/lib/CodeGen/CMakeLists.txt
index f47ecd9bf846..4039277707c5 100644
--- a/clang/lib/CodeGen/CMakeLists.txt
+++ b/clang/lib/CodeGen/CMakeLists.txt
@@ -92,7 +92,6 @@ add_clang_library(clangCodeGen
   LINK_LIBS
   clangAnalysis
   clangAST
-  clangASTMatchers
   clangBasic
   clangFrontend
   clangLex



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


[PATCH] D84988: [Coverage] Add empty line regions to SkippedRegions

2020-09-10 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 291118.
zequanwu added a comment.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

- Address comment.
- Add cl::opt to disable emitting skipped regions for empty lines and comments 
(used on test case only), and update test cases under CoverageMapping with 
`-mllvm -emptyline-comment-coverage=false`.
- Remove the logic which only emits skipped regions for comments and empty 
lines parsing function body, because can't tell if it's inside class member 
function.
- Always set `SR.ColumnStart` to 1 in `adjustSkippedRange`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84988

Files:
  clang/include/clang/Lex/Lexer.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/test/CoverageMapping/abspath.cpp
  clang/test/CoverageMapping/block-storage-starts-region.m
  clang/test/CoverageMapping/break.c
  clang/test/CoverageMapping/builtinmacro.c
  clang/test/CoverageMapping/casts.c
  clang/test/CoverageMapping/classtemplate.cpp
  clang/test/CoverageMapping/comment-in-macro.c
  clang/test/CoverageMapping/continue.c
  clang/test/CoverageMapping/control-flow-macro.c
  clang/test/CoverageMapping/coroutine.cpp
  clang/test/CoverageMapping/decl.c
  clang/test/CoverageMapping/default-method.cpp
  clang/test/CoverageMapping/deferred-region.cpp
  clang/test/CoverageMapping/empty-destructor.cpp
  clang/test/CoverageMapping/header.cpp
  clang/test/CoverageMapping/if.cpp
  clang/test/CoverageMapping/implicit-def-in-macro.m
  clang/test/CoverageMapping/include-macros.c
  clang/test/CoverageMapping/includehell.cpp
  clang/test/CoverageMapping/ir.c
  clang/test/CoverageMapping/label.cpp
  clang/test/CoverageMapping/lambda.cpp
  clang/test/CoverageMapping/logical.cpp
  clang/test/CoverageMapping/loopmacro.c
  clang/test/CoverageMapping/loops.cpp
  clang/test/CoverageMapping/macro-expansion.c
  clang/test/CoverageMapping/macro-expressions.cpp
  clang/test/CoverageMapping/macro-stringize-twice.cpp
  clang/test/CoverageMapping/macroception.c
  clang/test/CoverageMapping/macroparams.c
  clang/test/CoverageMapping/macroparams2.c
  clang/test/CoverageMapping/macros.c
  clang/test/CoverageMapping/macroscopes.cpp
  clang/test/CoverageMapping/md.cpp
  clang/test/CoverageMapping/moremacros.c
  clang/test/CoverageMapping/nestedclass.cpp
  clang/test/CoverageMapping/objc.m
  clang/test/CoverageMapping/openmp.c
  clang/test/CoverageMapping/pr32679.cpp
  clang/test/CoverageMapping/preprocessor.c
  clang/test/CoverageMapping/return.c
  clang/test/CoverageMapping/switch.cpp
  clang/test/CoverageMapping/switchmacro.c
  clang/test/CoverageMapping/system_macro.cpp
  clang/test/CoverageMapping/templates.cpp
  clang/test/CoverageMapping/test.c
  clang/test/CoverageMapping/trycatch.cpp
  clang/test/CoverageMapping/trymacro.cpp
  clang/test/CoverageMapping/unreachable-macro.c
  clang/test/CoverageMapping/unused_function.cpp
  clang/test/CoverageMapping/unused_names.c
  clang/test/CoverageMapping/while.c
  clang/test/lit.cfg.py
  compiler-rt/test/profile/coverage_emptylines.cpp
  compiler-rt/test/profile/instrprof-set-file-object-merging.c
  compiler-rt/test/profile/instrprof-set-file-object.c
  llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Index: llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
===
--- llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -485,9 +485,15 @@
   if (CurStartLoc == CR.value().endLoc()) {
 // Avoid making zero-length regions active. If it's the last region,
 // emit a skipped segment. Otherwise use its predecessor's count.
-const bool Skipped = (CR.index() + 1) == Regions.size();
+const bool Skipped =
+(CR.index() + 1) == Regions.size() ||
+CR.value().Kind == CounterMappingRegion::SkippedRegion;
 startSegment(ActiveRegions.empty() ? CR.value() : *ActiveRegions.back(),
  CurStartLoc, !GapRegion, Skipped);
+// If it is skipped segment, create a segment with last pushed
+// regions's count at CurStartLoc.
+if (Skipped && !ActiveRegions.empty())
+  startSegment(*ActiveRegions.back(), CurStartLoc, false);
 continue;
   }
   if (CR.index() + 1 == Regions.size() ||
@@ -587,6 +593,8 @@
   const auto &L = Segments[I - 1];
   const auto &R = Segments[I];
   if (!(L.Line < R.Line) && !(L.Line == R.Line && L.Col < R.Col)) {
+if (L.Line == R.Line && L.Col == R.Col && !L.HasCount)
+  continue;
 LLVM_DEBUG(dbgs() << " ! Segment " << L.Line << ":" << L.Col
   << " followed by " << R.Line << ":" << R.Col << "\n");
 assert(false && "Coverage

LLVM buildmaster will be updated and restarted soon

2020-09-10 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted in an hour.

Thanks

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


[PATCH] D87047: [clang] Add command line options for the Machine Function Splitter.

2020-09-10 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish updated this revision to Diff 291122.
snehasish marked an inline comment as done.
snehasish added a comment.

Fix test formatting.

Added clang-format off to disable clang format for the test which contains both 
profile data (as text) and c code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87047

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/split-machine-functions.c
  clang/test/Driver/fsplit-machine-functions.c

Index: clang/test/Driver/fsplit-machine-functions.c
===
--- /dev/null
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -0,0 +1,9 @@
+// RUN: %clang -### -target x86_64 -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
+// RUN: %clang -### -target x86_64 -fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
+// RUN: %clang -c -target x86_64 -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-WARN %s
+// RUN: not %clang -c -target arm-unknown-linux -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+
+// CHECK-OPT:   "-fsplit-machine-functions"
+// CHECK-NOOPT-NOT: "-fsplit-machine-functions"
+// CHECK-WARN:  ignored -fsplit-machine-functions, no profile provided via -fprofile-use
+// CHECK-TRIPLE:error: unsupported option '-fsplit-machine-functions' for target
Index: clang/test/CodeGen/split-machine-functions.c
===
--- /dev/null
+++ clang/test/CodeGen/split-machine-functions.c
@@ -0,0 +1,38 @@
+// clang-format off
+// REQUIRES: x86-registered-target
+// RUN: split-file %s %t
+// RUN: llvm-profdata merge -o %t/default.profdata %t/proftext
+// RUN: %clang_cc1 -triple x86_64 -O3 -S -fprofile-instrument-use-path=%t/default.profdata -fsplit-machine-functions -o - < %t/code | FileCheck %s
+
+// CHECK: .section .text.hot.,"ax",@progbits
+// CHECK: foo:
+// CHECK: section .text.unlikely.foo,"ax",@progbits
+// CHECK: foo.cold:
+// CHECK: callq exit@PLT
+
+//--- proftext
+foo
+# Func Hash:
+11262309905
+# Num Counters:
+2
+# Counter Values:
+100
+0
+
+//--- code
+__attribute__((noinline)) int foo(int argc) {
+  if (argc % 2 == 0) {
+exit(argc);
+  } else {
+return argc + 1;
+  }
+}
+
+int main(int argc, char *argv[]) {
+  int total = 0;
+  for (int i = 0; i < 100; ++i) {
+total += foo(argc);
+  }
+  printf("%d\n", total);
+}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -998,6 +998,8 @@
   Opts.UniqueInternalLinkageNames =
   Args.hasArg(OPT_funique_internal_linkage_names);
 
+  Opts.SplitMachineFunctions = Args.hasArg(OPT_fsplit_machine_functions);
+
   Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4911,6 +4911,15 @@
options::OPT_fno_unique_basic_block_section_names, false))
 CmdArgs.push_back("-funique-basic-block-section-names");
 
+  if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
+   options::OPT_fno_split_machine_functions)) {
+if (Triple.isX86() && Triple.isOSBinFormatELF())
+  A->render(Args, CmdArgs);
+else
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+  }
+
   Args.AddLastArg(CmdArgs, options::OPT_finstrument_functions,
   options::OPT_finstrument_functions_after_inlining,
   options::OPT_finstrument_function_entry_bare);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -9,6 +9,7 @@
 #include "clang/CodeGen/BackendUtil.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticFrontend.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/TargetOptions.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
@@ -514,6 +515,15 @@
   Options.BBSectionsFuncListBuf = std::move(*MBOrErr);
   }
 
+  if (CodeGenOpts.SplitMachineFunctions) {
+if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
+  Options.EnableMachineFunctionSplitter = true;
+else
+  Diags.Report(d

[PATCH] D87047: [clang] Add command line options for the Machine Function Splitter.

2020-09-10 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish marked an inline comment as done.
snehasish added inline comments.



Comment at: clang/test/CodeGen/split-machine-functions.c:3
+
+// RUN: echo "foo"> %t.proftext
+// RUN: echo "# Func Hash:"   >> %t.proftext

snehasish wrote:
> MaskRay wrote:
> > Consider `RUN: split-file`
> > 
> > Search for this string for some examples.
> Looks much cleaner with split-file overall, though it doesn't play well with 
> clang-format since this is a .c file. Should we just ignore clang-format 
> complaints for this file?
Fixed the formatting by adding a `clang-format off` directive at the top of 
this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87047

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


[libclc] 16ba78e - libclc/spirv: Add missing files from D85911

2020-09-10 Thread Jan Vesely via cfe-commits

Author: Jan Vesely
Date: 2020-09-10T23:41:38-04:00
New Revision: 16ba78ee627c3fe66906349e8c90ee8cc1224298

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

LOG: libclc/spirv: Add missing files from D85911

Fixes: 060c8e083dd637866854acb6a0823c45b2ef68ef
Signed-off-by: Jan Vesely 

Added: 
libclc/spirv/lib/math/fma.cl
libclc/spirv/lib/math/fma.inc
libclc/spirv64/lib/math/fma.cl
libclc/spirv64/lib/math/fma.inc

Modified: 


Removed: 




diff  --git a/libclc/spirv/lib/math/fma.cl b/libclc/spirv/lib/math/fma.cl
new file mode 100644
index ..982ddc4374f3
--- /dev/null
+++ b/libclc/spirv/lib/math/fma.cl
@@ -0,0 +1,6 @@
+#include 
+#include 
+
+#define __CLC_BODY 
+#define __FLOAT_ONLY
+#include 

diff  --git a/libclc/spirv/lib/math/fma.inc b/libclc/spirv/lib/math/fma.inc
new file mode 100644
index ..0f12c565758f
--- /dev/null
+++ b/libclc/spirv/lib/math/fma.inc
@@ -0,0 +1,3 @@
+_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE fma(__CLC_GENTYPE a, __CLC_GENTYPE b, 
__CLC_GENTYPE c) {
+   return __clc_sw_fma(a, b, c);
+}

diff  --git a/libclc/spirv64/lib/math/fma.cl b/libclc/spirv64/lib/math/fma.cl
new file mode 100644
index ..982ddc4374f3
--- /dev/null
+++ b/libclc/spirv64/lib/math/fma.cl
@@ -0,0 +1,6 @@
+#include 
+#include 
+
+#define __CLC_BODY 
+#define __FLOAT_ONLY
+#include 

diff  --git a/libclc/spirv64/lib/math/fma.inc b/libclc/spirv64/lib/math/fma.inc
new file mode 100644
index ..0f12c565758f
--- /dev/null
+++ b/libclc/spirv64/lib/math/fma.inc
@@ -0,0 +1,3 @@
+_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE fma(__CLC_GENTYPE a, __CLC_GENTYPE b, 
__CLC_GENTYPE c) {
+   return __clc_sw_fma(a, b, c);
+}



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


Upcoming upgrade of LLVM buildbot

2020-09-10 Thread Galina Kistanova via cfe-commits
Hello everyone,

The buildbot upgrade is entering the phase when the results to become
visible.

No change is required at this time on any of the builders. The bot owners
could upgrade the buildbot on build computers later, at their convenience,
as this is not on the critical path.

We are going to upgrade the staging bot first. Then, once that is stable
and all detected issues are resolved, we will upgrade the production bot.

I will need some help with testing, and will be asking to move some of the
builders temporarily to the staging. LLVM buildbot is a piece of critical
infrastructure, so more eyes and hands in making sure it works properly the
better.

I'll be posting updates and ETA of particular changes in this thread.

Please feel free to ask if you have any questions or concerns.

Thanks

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


[PATCH] D87470: [Coroutine][Sema] Tighten the lifetime of symmetric transfer returned handle

2020-09-10 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D87470#2267060 , @junparser wrote:

> Thanks for the change. LGTM, and testcase?

Not sure how to add a test case for this though. We don't seem to explicitly 
test AST output.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87470

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


[PATCH] D75574: RFC: Implement objc_direct_protocol attribute to remove protocol metadata

2020-09-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D75574#2262622 , @lanza wrote:

>> I don't think it'll actually error out at link time: protocol objects get 
>> emitted eagerly on use, cross-module linking is just a code-size 
>> optimization. This actually has caused longstanding problems.
>
> But if it's just a forward declaration there's nothing to emit. The above 
> code compiles just fine as is with just a warning. Here's the result of 
> `clang protocol.m -lobjc`
>
>   proto.m:10:31: warning: cannot find protocol definition for 
> 'NonRuntimeProto'
>   @interface Implementer : Root
> ^
>   proto.m:8:11: note: protocol 'NonRuntimeProto' has no definition
>   @protocol NonRuntimeProto;
> ^
>   1 warning generated.
>   Undefined symbols for architecture x86_64:
> "__OBJC_PROTOCOL_$_NonRuntimeProto", referenced from:
> __OBJC_CLASS_PROTOCOLS_$_Implementer in proto-bd4a43.o
>   ld: symbol(s) not found for architecture x86_64
>   clang-12: error: linker command failed with exit code 1 (use -v to see 
> invocation)
>
> The protocol definition isn't actually required to compile an implementation. 
> And if that protocol is declared as `objc_non_runtime_protocol` it won't ever 
> see one.
>
> Simply requiring that it is annotated accordingly also isn't satisfactory for 
> the same inheritance problem you mentioned above. Annotating a forward decl 
> can tell clang not to emit it but won't let clang know if there's a base 
> protocol that still needs to be emitted. e.g. if we have
>
>   // SomeHeader.h
>   @protocol Base
>   @end
>   __attribute__((objc_non_runtime_protocol))
>   @protocol NonRuntime 
>   @end
>   
>   
>   // and in main.m
>   __attribute__((objc_non_runtime_protocol))
>   @protocol NonRuntime
>   @interface AClass : Root
>   @end
>   @implementation AClass
>   @end
>
> we'll get a compile warning but no link error. But it will be wrong as the 
> protocol `Base` should still be in the protocollist for `AClass`.
>
> I'm not sure how big of an issue it would be introducing a new error here for 
> code that used to compile, but that's really the only way I see this working.

Hmm, I thought we actually just generated a bogus definition for the protocol 
when it was forward-declared; really, this is better behavior that I expected.  
Regardless, I don't think it's worthwhile to diagnose this more strongly than a 
warning because of the history of not doing so.

Not really important for this PR anyway.  Was your question answered well 
enough to move forward?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75574

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


[PATCH] D87470: [Coroutine][Sema] Tighten the lifetime of symmetric transfer returned handle

2020-09-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Also LGTM with a testcase.  It's fine to test the result of IRGen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87470

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


[PATCH] D85960: [AST][FPEnv] Keep FP options in trailing storage of CastExpr

2020-09-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Follow-up on my previous request.  It's fine by me if you commit with that fix.




Comment at: clang/lib/Analysis/BodyFarm.cpp:188
+  const_cast(Arg), nullptr, VK_RValue,
+  FPOptionsOverride());
 }

rjmccall wrote:
> Can these call sites just be changed to use `makeImplicitCast`?
Can you do the one in makeIntegralCast, too?  Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85960

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


[PATCH] D85473: [Clang] Add option to allow marking pass-by-value args as noalias.

2020-09-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added a reviewer: ahatanak.
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2198
+// reference to the underlying object. Mark it accordingly.
+Attrs.addAttribute(llvm::Attribute::NoAlias);
+

fhahn wrote:
> rjmccall wrote:
> > This definitely can't be added unconditionally to all types; you need to 
> > rule out non-trivial C++ class types, as well as types with ObjC weak 
> > references.
> Updated to rule out non trivially-copyable types.
> 
> I am not sure how to best handle types with weak references. I did not manage 
> to find any helpers that traverse a whole type to check if it contains weak 
> references. 
> 
> I added `clang/test/CodeGenObjC/pass-by-value-noalias.m` and IIUC `noalias` 
> should not be added for that case.
The restriction should not be by triviality but by whether indirectness is 
forced semantically.  That may currently only be available on RecordDecl (as 
`RecordDecl::getArgPassingRestrictions`), but you could definitely add an 
accessor to `Type` which checked for a RecordType and otherwise returned that 
there are no passing constraints.  Tagging Akira, who worked on this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85473

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


[PATCH] D87047: [clang] Add command line options for the Machine Function Splitter.

2020-09-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:2131
 
+.. option:: -fsplit-machine-functions, -fno-split-machine-functions
+

You don't need to edit this file. It is auto-generated from Options.td



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4917
+if (Triple.isX86() && Triple.isOSBinFormatELF())
+  A->render(Args, CmdArgs);
+else

OPT_fno_split_machine_functions is a driver option but not a CC1 option. 
Rendering OPT_fno_split_machine_functions will error when processing CC1 
options.



Comment at: clang/test/CodeGen/split-machine-functions.c:1
+// clang-format off
+// REQUIRES: x86-registered-target

You can ignore clang-format/clang-tidy issues in test/ and there is no need to 
annotate the tests (otherwise we will annotate essentially every file)



Comment at: clang/test/CodeGen/split-machine-functions.c:5
+// RUN: llvm-profdata merge -o %t/default.profdata %t/proftext
+// RUN: %clang_cc1 -triple x86_64 -O3 -S 
-fprofile-instrument-use-path=%t/default.profdata -fsplit-machine-functions -o 
- < %t/code | FileCheck %s
+

See https://reviews.llvm.org/D85408#2266559

It feels wrong that the assembly+llvm-profdata test is in clang/test



Comment at: clang/test/Driver/fsplit-machine-functions.c:1
+// RUN: %clang -### -target x86_64 -fsplit-machine-functions %s -c 2>&1 | 
FileCheck -check-prefix=CHECK-OPT %s
+// RUN: %clang -### -target x86_64 -fsplit-machine-functions 
-fno-split-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s

Add `-fprofile-use` to the canonical usage line



Comment at: clang/test/Driver/fsplit-machine-functions.c:3
+// RUN: %clang -### -target x86_64 -fsplit-machine-functions 
-fno-split-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
+// RUN: %clang -c -target x86_64 -fsplit-machine-functions %s -c 2>&1 | 
FileCheck -check-prefix=CHECK-WARN %s
+// RUN: not %clang -c -target arm-unknown-linux -fsplit-machine-functions %s 
-c 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s

Two -c?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87047

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


[PATCH] D86632: [Fixed Point] Add codegen for conversion between fixed-point and floating point.

2020-09-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: llvm/include/llvm/IR/FixedPointBuilder.h:126
+  /// \p Ty, or a floating point type with a larger exponent than Ty.
+  Type *getAccommodatingFloatType(Type *Ty, const FixedPointSemantics &Sema) {
+const fltSemantics *FloatSema = &Ty->getFltSemantics();

I like this method name.  Does this have the same problem as I asked about in 
the other patch about really needing to be about whether the *unscaled* 
fixed-point type fits in the given type?



Comment at: llvm/include/llvm/IR/FixedPointBuilder.h:131
+// There's seemingly no way to convert fltSemantics to Type.
+return ConstantFP::get(Ty->getContext(), APFloat(*FloatSema))->getType();
+  }

Could you just extract that code out of `llvm::ConstantFP::get` and put it on 
`llvm::Type`?  Might be better as a separate patch.

While you're at it, there's also a `TypeToFloatSemantics` function in 
Constants.cpp that's completely redundant with `llvm::Type::getFltSemantics`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86632

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


[PATCH] D87470: [Coroutine][Sema] Tighten the lifetime of symmetric transfer returned handle

2020-09-10 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 291140.
lxfind added a comment.

Add test case. Verify that the size of the frame reduced by 8.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87470

Files:
  clang/lib/Sema/SemaCoroutine.cpp
  clang/test/CodeGenCoroutines/Inputs/coroutine.h
  clang/test/CodeGenCoroutines/coro-semmetric-transfer.cpp

Index: clang/test/CodeGenCoroutines/coro-semmetric-transfer.cpp
===
--- /dev/null
+++ clang/test/CodeGenCoroutines/coro-semmetric-transfer.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang -std=c++14 -fcoroutines-ts -fsanitize=address -emit-llvm -S -o - %s | FileCheck %s
+
+#include "Inputs/coroutine.h"
+
+namespace coro = std::experimental::coroutines_v1;
+
+struct detached_task {
+  struct promise_type {
+detached_task get_return_object() noexcept {
+  return detached_task{coro::coroutine_handle::from_promise(*this)};
+}
+
+void return_void() noexcept {}
+
+struct final_awaiter {
+  bool await_ready() noexcept { return false; }
+  coro::coroutine_handle<> await_suspend(coro::coroutine_handle h) noexcept {
+h.destroy();
+return coro::noop_coroutine();
+  }
+  void await_resume() noexcept {}
+};
+
+void unhandled_exception() noexcept {}
+
+final_awaiter final_suspend() noexcept { return {}; }
+
+coro::suspend_always initial_suspend() noexcept { return {}; }
+  };
+
+  ~detached_task() {
+if (coro_) {
+  coro_.destroy();
+  coro_ = {};
+}
+  }
+
+  void start() && {
+auto tmp = coro_;
+coro_ = {};
+tmp.resume();
+  }
+
+  coro::coroutine_handle coro_;
+};
+
+detached_task foo() {
+  co_return;
+}
+
+// This is to check that temporary handle returned by the symmetric transfer is not put in the frame.
+// CHECK: {{.*}} = call nonnull i8* @_Znwm(i64 48)
Index: clang/test/CodeGenCoroutines/Inputs/coroutine.h
===
--- clang/test/CodeGenCoroutines/Inputs/coroutine.h
+++ clang/test/CodeGenCoroutines/Inputs/coroutine.h
@@ -15,7 +15,7 @@
 return me;
   }
   void operator()() { resume(); }
-  void *address() const { return ptr; }
+  void *address() const noexcept { return ptr; }
   void resume() const { __builtin_coro_resume(ptr); }
   void destroy() const { __builtin_coro_destroy(ptr); }
   bool done() const { return __builtin_coro_done(ptr); }
@@ -52,19 +52,21 @@
   }
 };
 
-  template 
-  bool operator==(coroutine_handle<_PromiseT> const& _Left,
-coroutine_handle<_PromiseT> const& _Right) noexcept
-  {
-return _Left.address() == _Right.address();
-  }
+struct noop_coroutine_promise {};
+using noop_coroutine_handle = coroutine_handle;
+coroutine_handle<> noop_coroutine() { return {}; }
 
-  template 
-  bool operator!=(coroutine_handle<_PromiseT> const& _Left,
-coroutine_handle<_PromiseT> const& _Right) noexcept
-  {
-return !(_Left == _Right);
-  }
+template 
+bool operator==(coroutine_handle<_PromiseT> const &_Left,
+coroutine_handle<_PromiseT> const &_Right) noexcept {
+  return _Left.address() == _Right.address();
+}
+
+template 
+bool operator!=(coroutine_handle<_PromiseT> const &_Left,
+coroutine_handle<_PromiseT> const &_Right) noexcept {
+  return !(_Left == _Right);
+}
 
 struct suspend_always {
   bool await_ready() { return false; }
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -398,8 +398,8 @@
diag::warn_coroutine_handle_address_invalid_return_type)
 << JustAddress->getType();
 
-  return buildBuiltinCall(S, Loc, Builtin::BI__builtin_coro_resume,
-  JustAddress);
+  return S.MaybeCreateExprWithCleanups(
+  buildBuiltinCall(S, Loc, Builtin::BI__builtin_coro_resume, JustAddress));
 }
 
 /// Build calls to await_ready, await_suspend, and await_resume for a co_await
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87426: Disallow fbasic-block-sections on non-ELF, non-x86 targets.

2020-09-10 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish updated this revision to Diff 290884.
snehasish marked an inline comment as done.
snehasish added a comment.

Update test to use `not` tool and `-c` flag.

- Use the not tool to indicate failure is expected.
- Use -c instead of -### for failing invocations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87426

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fbasic-block-sections.c


Index: clang/test/Driver/fbasic-block-sections.c
===
--- clang/test/Driver/fbasic-block-sections.c
+++ clang/test/Driver/fbasic-block-sections.c
@@ -1,9 +1,12 @@
-// RUN: %clang -### -fbasic-block-sections=none %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-NONE %s
-// RUN: %clang -### -fbasic-block-sections=all %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-ALL %s
-// RUN: %clang -### -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-LIST %s
-// RUN: %clang -### -fbasic-block-sections=labels %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-LABELS %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=none %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-NONE %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=all %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-ALL %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=list=%s %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-LIST %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=labels %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-LABELS %s
+// RUN: not %clang -c -target arm-unknown-linux -fbasic-block-sections=all %s 
-S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: not %clang -c -target x86_64-apple-darwin10 -fbasic-block-sections=all 
%s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 //
-// CHECK-OPT-NONE: "-fbasic-block-sections=none"
-// CHECK-OPT-ALL: "-fbasic-block-sections=all"
-// CHECK-OPT-LIST: "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
+// CHECK-OPT-NONE:   "-fbasic-block-sections=none"
+// CHECK-OPT-ALL:"-fbasic-block-sections=all"
+// CHECK-OPT-LIST:   "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
 // CHECK-OPT-LABELS: "-fbasic-block-sections=labels"
+// CHECK-TRIPLE: error: unsupported option '-fbasic-block-sections=all' 
for target
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4880,13 +4880,18 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_fbasic_block_sections_EQ)) {
-StringRef Val = A->getValue();
-if (Val != "all" && Val != "labels" && Val != "none" &&
-!(Val.startswith("list=") && llvm::sys::fs::exists(Val.substr(5
-  D.Diag(diag::err_drv_invalid_value)
-  << A->getAsString(Args) << A->getValue();
-else
-  A->render(Args, CmdArgs);
+if (Triple.isX86() && Triple.isOSBinFormatELF()) {
+  StringRef Val = A->getValue();
+  if (Val != "all" && Val != "labels" && Val != "none" &&
+  !(Val.startswith("list=") && llvm::sys::fs::exists(Val.substr(5
+D.Diag(diag::err_drv_invalid_value)
+<< A->getAsString(Args) << A->getValue();
+  else
+A->render(Args, CmdArgs);
+} else {
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+}
   }
 
   if (Args.hasFlag(options::OPT_fdata_sections, options::OPT_fno_data_sections,


Index: clang/test/Driver/fbasic-block-sections.c
===
--- clang/test/Driver/fbasic-block-sections.c
+++ clang/test/Driver/fbasic-block-sections.c
@@ -1,9 +1,12 @@
-// RUN: %clang -### -fbasic-block-sections=none %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-NONE %s
-// RUN: %clang -### -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-ALL %s
-// RUN: %clang -### -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LIST %s
-// RUN: %clang -### -fbasic-block-sections=labels %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LABELS %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=none %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-NONE %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-ALL %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LIST %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=labels %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LABELS %s
+// RUN: not %clang -c -target arm-unknown-linux -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: not %clang -c -target x86_64-apple-darwin10 -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHEC

[PATCH] D87426: Disallow fbasic-block-sections on non-ELF, non-x86 targets.

2020-09-10 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish marked 4 inline comments as done.
snehasish added a comment.

Thanks for explaining the rationale, PTAL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87426

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


[PATCH] D87426: Disallow fbasic-block-sections on non-ELF, non-x86 targets.

2020-09-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

Looks great!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87426

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


[clang] 157cd93 - [clang] Disallow fbasic-block-sections on non-ELF, non-x86 targets.

2020-09-10 Thread Snehasish Kumar via cfe-commits

Author: Snehasish Kumar
Date: 2020-09-10T00:15:33-07:00
New Revision: 157cd93b48a90f484e9eb2ed9997e0372b9c7ebb

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

LOG: [clang] Disallow fbasic-block-sections on non-ELF, non-x86 targets.

Basic block sections is untested on other platforms and binary formats apart
from x86,elf. This patch emits a warning and drops the flag if the platform
and binary format are not compatible. Add a test to ensure that
specifying an incompatible target in the driver does not enable the
feature.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/fbasic-block-sections.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1680f2ad91ea..40659ebb1395 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4880,13 +4880,18 @@ void Clang::ConstructJob(Compilation &C, const 
JobAction &JA,
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_fbasic_block_sections_EQ)) {
-StringRef Val = A->getValue();
-if (Val != "all" && Val != "labels" && Val != "none" &&
-!(Val.startswith("list=") && llvm::sys::fs::exists(Val.substr(5
-  D.Diag(diag::err_drv_invalid_value)
-  << A->getAsString(Args) << A->getValue();
-else
-  A->render(Args, CmdArgs);
+if (Triple.isX86() && Triple.isOSBinFormatELF()) {
+  StringRef Val = A->getValue();
+  if (Val != "all" && Val != "labels" && Val != "none" &&
+  !(Val.startswith("list=") && llvm::sys::fs::exists(Val.substr(5
+D.Diag(diag::err_drv_invalid_value)
+<< A->getAsString(Args) << A->getValue();
+  else
+A->render(Args, CmdArgs);
+} else {
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+}
   }
 
   if (Args.hasFlag(options::OPT_fdata_sections, options::OPT_fno_data_sections,

diff  --git a/clang/test/Driver/fbasic-block-sections.c 
b/clang/test/Driver/fbasic-block-sections.c
index 2ff98c94222b..93c7fe9fc069 100644
--- a/clang/test/Driver/fbasic-block-sections.c
+++ b/clang/test/Driver/fbasic-block-sections.c
@@ -1,9 +1,12 @@
-// RUN: %clang -### -fbasic-block-sections=none %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-NONE %s
-// RUN: %clang -### -fbasic-block-sections=all %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-ALL %s
-// RUN: %clang -### -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-LIST %s
-// RUN: %clang -### -fbasic-block-sections=labels %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-LABELS %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=none %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-NONE %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=all %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-ALL %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=list=%s %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-LIST %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=labels %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-LABELS %s
+// RUN: not %clang -c -target arm-unknown-linux -fbasic-block-sections=all %s 
-S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: not %clang -c -target x86_64-apple-darwin10 -fbasic-block-sections=all 
%s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 //
-// CHECK-OPT-NONE: "-fbasic-block-sections=none"
-// CHECK-OPT-ALL: "-fbasic-block-sections=all"
-// CHECK-OPT-LIST: "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
+// CHECK-OPT-NONE:   "-fbasic-block-sections=none"
+// CHECK-OPT-ALL:"-fbasic-block-sections=all"
+// CHECK-OPT-LIST:   "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
 // CHECK-OPT-LABELS: "-fbasic-block-sections=labels"
+// CHECK-TRIPLE: error: unsupported option '-fbasic-block-sections=all' 
for target



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


[PATCH] D87426: Disallow fbasic-block-sections on non-ELF, non-x86 targets.

2020-09-10 Thread Snehasish Kumar via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG157cd93b48a9: [clang] Disallow fbasic-block-sections on 
non-ELF, non-x86 targets. (authored by snehasish).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87426

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fbasic-block-sections.c


Index: clang/test/Driver/fbasic-block-sections.c
===
--- clang/test/Driver/fbasic-block-sections.c
+++ clang/test/Driver/fbasic-block-sections.c
@@ -1,9 +1,12 @@
-// RUN: %clang -### -fbasic-block-sections=none %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-NONE %s
-// RUN: %clang -### -fbasic-block-sections=all %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-ALL %s
-// RUN: %clang -### -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-LIST %s
-// RUN: %clang -### -fbasic-block-sections=labels %s -S 2>&1 | FileCheck 
-check-prefix=CHECK-OPT-LABELS %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=none %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-NONE %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=all %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-ALL %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=list=%s %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-LIST %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=labels %s -S 2>&1 | 
FileCheck -check-prefix=CHECK-OPT-LABELS %s
+// RUN: not %clang -c -target arm-unknown-linux -fbasic-block-sections=all %s 
-S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: not %clang -c -target x86_64-apple-darwin10 -fbasic-block-sections=all 
%s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 //
-// CHECK-OPT-NONE: "-fbasic-block-sections=none"
-// CHECK-OPT-ALL: "-fbasic-block-sections=all"
-// CHECK-OPT-LIST: "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
+// CHECK-OPT-NONE:   "-fbasic-block-sections=none"
+// CHECK-OPT-ALL:"-fbasic-block-sections=all"
+// CHECK-OPT-LIST:   "-fbasic-block-sections={{[^ ]*}}fbasic-block-sections.c"
 // CHECK-OPT-LABELS: "-fbasic-block-sections=labels"
+// CHECK-TRIPLE: error: unsupported option '-fbasic-block-sections=all' 
for target
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4880,13 +4880,18 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_fbasic_block_sections_EQ)) {
-StringRef Val = A->getValue();
-if (Val != "all" && Val != "labels" && Val != "none" &&
-!(Val.startswith("list=") && llvm::sys::fs::exists(Val.substr(5
-  D.Diag(diag::err_drv_invalid_value)
-  << A->getAsString(Args) << A->getValue();
-else
-  A->render(Args, CmdArgs);
+if (Triple.isX86() && Triple.isOSBinFormatELF()) {
+  StringRef Val = A->getValue();
+  if (Val != "all" && Val != "labels" && Val != "none" &&
+  !(Val.startswith("list=") && llvm::sys::fs::exists(Val.substr(5
+D.Diag(diag::err_drv_invalid_value)
+<< A->getAsString(Args) << A->getValue();
+  else
+A->render(Args, CmdArgs);
+} else {
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+}
   }
 
   if (Args.hasFlag(options::OPT_fdata_sections, options::OPT_fno_data_sections,


Index: clang/test/Driver/fbasic-block-sections.c
===
--- clang/test/Driver/fbasic-block-sections.c
+++ clang/test/Driver/fbasic-block-sections.c
@@ -1,9 +1,12 @@
-// RUN: %clang -### -fbasic-block-sections=none %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-NONE %s
-// RUN: %clang -### -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-ALL %s
-// RUN: %clang -### -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LIST %s
-// RUN: %clang -### -fbasic-block-sections=labels %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LABELS %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=none %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-NONE %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-ALL %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=list=%s %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LIST %s
+// RUN: %clang -### -target x86_64 -fbasic-block-sections=labels %s -S 2>&1 | FileCheck -check-prefix=CHECK-OPT-LABELS %s
+// RUN: not %clang -c -target arm-unknown-linux -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: not %clang -c -target x86_64-apple-darwin10 -fbasic-block-sections=all %s -S 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s

[PATCH] D79431: [analyzer] StdLibraryFunctionsChecker: Add better diagnostics

2020-09-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

In D79431#2263693 , @martong wrote:

> In D79431#2263690 , @martong wrote:
>
>> What if we'd add a `toString` method to the constraints and we'd add this to 
>> `Msg`? This way we'd know the contents of the constraint, thus we we'd know 
>> //how// the constraint is violated.
>
> I mean we'd know what is not satisfied. But, to know why exactly that is not 
> satisfied we should dump the whole `State` but that's obviously not an 
> option. Perhaps we could track which symbols and expressions are 
> participating in the assumption related to the constraint and we could dump 
> only those, but this seems to be a very complex approach.

I realize that the //how// and //why// phrases in this context a bit too vague 
:) What do you mean under having to dump the whole `State`? I didn't mean to 
compress a bug path into a warning message, only what I mentioned in 
D79431#2020951 . In any case, I think 
its okay to just move on with this patch. LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79431

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


[PATCH] D83660: [analyzer] Fix a crash for dereferencing an empty llvm::Optional variable in SMTConstraintManager.h.

2020-09-10 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D83660#2264963 , @OikawaKirie wrote:

> After reviewing the code of this snippet, I think it would be very difficult 
> to make a regression test case for the crash, as far as what I know about Z3 
> and SMT solvers.
>
> First of all, all calls to `Solver->check()` will return `true` for sat, 
> `false` for unsat, and empty for a timeout.
> On line 132, the manager invokes Z3 for solving the constraints under the 
> current state.
> On line 137, the manager invokes Z3 for getting a model (a valid result) 
> satisfying the constraints.
> On line 141, the manager adds another constraint to exclude the model gotten 
> from the model.
> On line 149, the manager invokes Z3 for solving the excluded constraint.
> In summary, the manager will first solver the constraint for a result of the 
> queried symbolic variable. If there is a valid value, it excludes the value 
> and solves again to check whether it is the only valid result.
>
> To trigger the crash, we need to construct a group of constraints that are 
> sat. Then, we need to exclude a valid value for a symbolic variable and make 
> the constraints lead to a **timeout** (rather than an unsat). Simple linear 
> constraints have very few chances to lead to a timeout. I tried to create a 
> group of constraints from 
> https://stackoverflow.com/questions/20536435/z3-what-might-be-the-reason-for-timeout,
>  which are a group of non-linear unsat constraints that can trigger a timeout 
> (under a timeout of 10 seconds). However, I have not successfully made one, 
> as it has too many things to do with mathematics. And my SMT solver 
> colleagues also think it is quite difficult to make one.

I suspected this one due to my previous investigation.

> As far as I am thinking, it is also very tricky to trigger a constraint 
> solver timeout. Since it can be impacted by which version of the constraint 
> solver is used, how much time is set for the timeout, how fast your computer 
> runs, and so on. Chances are that even if I reproduced the crash with a test 
> case, the same test case may not work on your computer.

I highly agree.
This was the exact reason why I raised a discussion on the mailing list 
 about //Limit 
Z3 without timeouts//.
That way we could reproduce this crash without depending on the actual machine.
However, we would still depend on an implementation detail of the solver - and 
I suspect that this option is highly Z3 specific, so would not fit into the 
solver-agnostic API very well.
I'm still open to discuss any ideas regarding this, but I can't put any effort 
into that :|

> Is it possible to hack the SMT solver creator to make a mock solver for 
> triggering the problem?

I suspect, no. We don't have a mechanism to do dependency injection into the 
SMT constant manager implementation. It would be nice to have IMO.

I see two options here:

1. Implement the dependency injection to let the //SMT constant manager 
implementation// use the given //SMT solver//. Create a mock solver and a 
unit-test.
2. Implement the //resource limit// option in the API. Introduce a flag driving 
this option and create a LIT test where we set this limit to a really small 
one, and check a toy example.

I think the second option is easier and the preferred one. At the same time, 
that would require a greater consensus about changing the corresponding API 
since that is potentially used by different out-of-tree projects of LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83660

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


[PATCH] D87374: [SyntaxTree] Specialize `TreeTestBase` for `BuildTreeTest` and `MutationsTest`

2020-09-10 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/unittests/Tooling/Syntax/MutationsTest.cpp:48
+
+TEST_P(MutationTest, Mutations) {
+  if (!GetParam().isCXX11OrLater()) {





Comment at: clang/unittests/Tooling/Syntax/MutationsTest.cpp:70
"void test() { if (true) ; else {} }"},
   {"void test() { [[;]] }", "void test() {  }"}};
   for (const auto &C : Cases)

Could we split it into multiple test cases?

```
TEST_P(MutationTest, RemoveStatement_BinaryExpression) {
  CheckTransformation(
RemoveStatement,
"void test() { [[100+100;]] test(); }",
"void test() {  test(); }");
}
```

Also consider moving the std::function argument in CheckTransformation to the 
first position for readability of the call.



Comment at: clang/unittests/Tooling/Syntax/SynthesisTest.cpp:1-2
+
+//===- MutationsTest.cpp 
--===//
+//




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87374

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


[PATCH] D79431: [analyzer] StdLibraryFunctionsChecker: Add better diagnostics

2020-09-10 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D79431#2265155 , @Szelethus wrote:

> In D79431#2263693 , @martong wrote:
>
>> In D79431#2263690 , @martong wrote:
>>
>>> What if we'd add a `toString` method to the constraints and we'd add this 
>>> to `Msg`? This way we'd know the contents of the constraint, thus we we'd 
>>> know //how// the constraint is violated.
>>
>> I mean we'd know what is not satisfied. But, to know why exactly that is not 
>> satisfied we should dump the whole `State` but that's obviously not an 
>> option. Perhaps we could track which symbols and expressions are 
>> participating in the assumption related to the constraint and we could dump 
>> only those, but this seems to be a very complex approach.
>
> I realize that the //how// and //why// phrases in this context a bit too 
> vague :) What do you mean under having to dump the whole `State`? I didn't 
> mean to compress a bug path into a warning message, only what I mentioned in 
> D79431#2020951 . In any case, I 
> think its okay to just move on with this patch. LGTM!

First, thanks for the review!

Second, "dumping the whole State" is an overstatement. What I meant is this: to 
properly explain to the user how the constraint is failed is a hard task. 
Because we should dig up all symbols and expressions that are related to the 
constraint and we should dump their values. E.g. consider the violation of a 
range constraint here,

  ssize_t send(int socket, const void *buffer, size_t length, int flags);
  void foo() {
if (socket < 0)
  send(socket, buf, buflen, flags); // constraint violation for 'socket' it 
should be in [0, IntMax]
  }

We should print something like this: `'socket' it should be in [0, IntMax] but 
it is in [IntMin, -1]`
In this example, the related symbol is only `socket` but this could be more 
complex, e.g. if the constraint is related to a buffer size ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79431

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


[PATCH] D86736: [analyzer][NFC] Don't bind values to ObjCForCollectionStmt, replace it with a GDM trait

2020-09-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D86736#2257880 , @NoQ wrote:

> i'm very glad that we now consistently use expressions in our Environment.

*except for `ReturnStmt`, but I haven't dug myself into that pit just yet :) 
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86736

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


[PATCH] D87118: Add an explicit toggle for the static analyzer in clang-tidy

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

lgtm


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

https://reviews.llvm.org/D87118

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


[PATCH] D87347: [NFC] Fix compiler warnings due to integer comparison of different signedness

2020-09-10 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp updated this revision to Diff 290886.
nullptr.cpp added a comment.

[NFC] Fix pessimizing-move warnings due to std::move in return statements

Gcc warning:

  warning: moving a local object in a return statement prevents copy elision 
[-Wpessimizing-move]
 return std::move(Err);
 ^

Fix by removing redundant `std::move` in return statements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87347

Files:
  clang/lib/Lex/Pragma.cpp
  llvm/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp


Index: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -2037,8 +2037,7 @@
 if (Mask[i] == UndefMaskElem)
   continue;
 uint64_t LSBIndex = IsBigEndian ? (i + 1) * TruncRatio - 1 : i * 
TruncRatio;
-assert(LSBIndex <= std::numeric_limits::max() &&
-   "Overflowed 32-bits");
+assert(LSBIndex <= INT32_MAX && "Overflowed 32-bits");
 if (Mask[i] != (int)LSBIndex)
   return nullptr;
   }
Index: llvm/lib/MC/WasmObjectWriter.cpp
===
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -939,9 +939,8 @@
 if (Segment.InitFlags & wasm::WASM_SEGMENT_HAS_MEMINDEX)
   encodeULEB128(0, W.OS); // memory index
 if ((Segment.InitFlags & wasm::WASM_SEGMENT_IS_PASSIVE) == 0) {
-  W.OS << char(Segment.Offset > std::numeric_limits().max()
- ? wasm::WASM_OPCODE_I64_CONST
- : wasm::WASM_OPCODE_I32_CONST);
+  W.OS << char(Segment.Offset > INT32_MAX ? wasm::WASM_OPCODE_I64_CONST
+  : wasm::WASM_OPCODE_I32_CONST);
   encodeSLEB128(Segment.Offset, W.OS); // offset
   W.OS << char(wasm::WASM_OPCODE_END);
 }
Index: llvm/lib/Analysis/VectorUtils.cpp
===
--- llvm/lib/Analysis/VectorUtils.cpp
+++ llvm/lib/Analysis/VectorUtils.cpp
@@ -416,8 +416,7 @@
   ScaledMask.clear();
   for (int MaskElt : Mask) {
 if (MaskElt >= 0) {
-  assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <=
- std::numeric_limits::max() &&
+  assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <= INT32_MAX &&
  "Overflowed 32-bits");
 }
 for (int SliceElt = 0; SliceElt != Scale; ++SliceElt)
Index: llvm/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h
===
--- llvm/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h
+++ llvm/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h
@@ -1525,20 +1525,20 @@
 Args...)) {
   detail::ResultTraits::consumeAbandoned(
   std::move(Result));
-  return std::move(Err);
+  return Err;
 }
 
 if (auto Err = this->C.send()) {
   detail::ResultTraits::consumeAbandoned(
   std::move(Result));
-  return std::move(Err);
+  return Err;
 }
 
 while (!ReceivedResponse) {
   if (auto Err = this->handleOne()) {
 detail::ResultTraits::consumeAbandoned(
 std::move(Result));
-return std::move(Err);
+return Err;
   }
 }
 
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -1356,7 +1356,7 @@
 while (Tok.is(tok::numeric_constant)) {
   uint64_t Value;
   if (!PP.parseSimpleIntegerLiteral(Tok, Value) || Value == 0 ||
-  Value > std::numeric_limits::max()) {
+  Value > INT_MAX) {
 PP.Diag(Tok, diag::warn_pragma_warning_expected_number);
 return;
   }


Index: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -2037,8 +2037,7 @@
 if (Mask[i] == UndefMaskElem)
   continue;
 uint64_t LSBIndex = IsBigEndian ? (i + 1) * TruncRatio - 1 : i * TruncRatio;
-assert(LSBIndex <= std::numeric_limits::max() &&
-   "Overflowed 32-bits");
+assert(LSBIndex <= INT32_MAX && "Overflowed 32-bits");
 if (Mask[i] != (int)LSBIndex)
   return nullptr;
   }
Index: llvm/lib/MC/WasmObjectWriter.cpp
===
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -939,9 +939,8 @@
 if (Segment.InitFlags & wasm::WASM_SEGMENT_HAS_MEMINDEX)
   

[PATCH] D85351: [Analyzer] Fix for `ExprEngine::computeObjectUnderConstruction()` for base and delegating consturctor initializers

2020-09-10 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 290917.
baloghadamsoftware added a comment.

Fix for base constructors, test extended.


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

https://reviews.llvm.org/D85351

Files:
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp

Index: clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp
===
--- clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp
+++ clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp
@@ -23,8 +23,8 @@
   : public Checker {
 public:
   void checkPostCall(const CallEvent &Call, CheckerContext &C) const {
-// Only calls with origin expression are checked. These are `returnC()`
-// and C::C().
+// Only calls with origin expression are checked. These are `returnC()`,
+// `returnD()`, C::C() and D::D().
 if (!Call.getOriginExpr())
   return;
 
@@ -35,6 +35,10 @@
 Optional RetVal = Call.getReturnValueUnderConstruction();
 ASSERT_TRUE(RetVal);
 ASSERT_TRUE(RetVal->getAsRegion());
+
+const auto *RetReg = cast(RetVal->getAsRegion());
+const Expr *OrigExpr = Call.getOriginExpr();
+ASSERT_EQ(OrigExpr->getType(), RetReg->getValueType());
   }
 };
 
@@ -51,22 +55,65 @@
 TEST(TestReturnValueUnderConstructionChecker,
  ReturnValueUnderConstructionChecker) {
   EXPECT_TRUE(runCheckerOnCode(
-  R"(class C {
- public:
-   C(int nn): n(nn) {}
-   virtual ~C() {}
- private:
-   int n;
- };
-
- C returnC(int m) {
-   C c(m);
-   return c;
- }
-
- void foo() {
-   C c = returnC(1); 
- })"));
+  R"(class C {
+ public:
+   C(int nn): n(nn) {}
+   virtual ~C() {}
+ private:
+   int n;
+ };
+
+ C returnC(int m) {
+   C c(m);
+   return c;
+ }
+
+ void foo() {
+   C c = returnC(1);
+ })"));
+
+  EXPECT_TRUE(runCheckerOnCode(
+  R"(class C {
+ public:
+   C(int nn): n(nn) {}
+   explicit C(): C(0) {}
+   virtual ~C() {}
+ private:
+   int n;
+ };
+
+ C returnC() {
+   C c;
+   return c;
+ }
+
+ void foo() {
+   C c = returnC();
+ })"));
+
+  EXPECT_TRUE(runCheckerOnCode(
+  R"(class C {
+ public:
+   C(int nn): n(nn) {}
+   virtual ~C() {}
+ private:
+   int n;
+ };
+
+ class D: public C {
+ public:
+   D(int nn): C(nn) {}
+   virtual ~D() {}
+ };
+
+ D returnD(int m) {
+   D d(m);
+   return d;
+ }
+
+ void foo() {
+   D d = returnD(1); 
+ })"));
 }
 
 } // namespace
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -132,10 +132,20 @@
 case ConstructionContext::SimpleConstructorInitializerKind: {
   const auto *ICC = cast(CC);
   const auto *Init = ICC->getCXXCtorInitializer();
-  assert(Init->isAnyMemberInitializer());
   const CXXMethodDecl *CurCtor = cast(LCtx->getDecl());
   Loc ThisPtr = SVB.getCXXThis(CurCtor, LCtx->getStackFrame());
   SVal ThisVal = State->getSVal(ThisPtr);
+  if (Init->isBaseInitializer()) {
+const auto *ThisReg = cast(ThisVal.getAsRegion());
+const CXXRecordDecl *BaseClass =
+  Init->getBaseClass()->getAsCXXRecordDecl();
+const auto *BaseReg =
+  MRMgr.getCXXBaseObjectRegion(BaseClass, ThisReg,
+   Init->isBaseVirtual());
+return SVB.makeLoc(BaseReg);
+}
+  if (Init->isDelegatingInitializer())
+return ThisVal;
 
   const ValueDecl *Field;
   SVal FieldVal;
@@ -364,6 +374,8 @@
 case ConstructionContext::CXX17ElidedCopyConstructorInitializerKind:
 case ConstructionContext::SimpleConstructorInitializerKind: {
   const auto *ICC = cast(CC);
+  const auto *Init = ICC->getCXXCtorInitializer();
+  assert(Init->isAnyMemberInitializer());
   return addObjectUnderConstruction(State, ICC->getCXXCtorInitializer(),
 LCtx, V);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85351: [Analyzer] Fix for `ExprEngine::computeObjectUnderConstruction()` for base and delegating consturctor initializers

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



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:138-139
   SVal ThisVal = State->getSVal(ThisPtr);
+  if (Init->isBaseInitializer() || Init->isDelegatingInitializer())
+return ThisVal;
 

NoQ wrote:
> For base initializer you probably want the base class region. It may have a 
> non-trivial offset and it also has the correct type and extent.
Thank you for noticing this! You are completely right! Now I extended the tests 
with comparing the type of the returned region with the type of the expression. 
It failed when I just returned `ThisVal` but it passes with the fixed code.


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

https://reviews.llvm.org/D85351

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


[PATCH] D82784: [clang-tidy] For `run-clang-tidy.py` do not treat `allow_enabling_alpha_checkers` as a none value.

2020-09-10 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth accepted this revision.
JonasToth 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/D82784/new/

https://reviews.llvm.org/D82784

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


[PATCH] D87338: [Driver][PGO] Driver support for de-Optimizing cold functions (PATCH 2/2)

2020-09-10 Thread Renato Golin via Phabricator via cfe-commits
rengolin added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:2021
+
+Adds ``optnone`` attributes to functions whose instrumentation-based PGO 
profiling counts are equal to zero (i.e. "cold").
+

Following discussions in the mailing list, I'm wondering if we want to join the 
`optsize` and `optnone` implementations into one flag.


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

https://reviews.llvm.org/D87338

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


[PATCH] D87239: [analyzer][StdLibraryFunctionsChecker] Remove strcasecmp

2020-09-10 Thread Gabor Marton via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb7586afc4dcd: [analyzer][StdLibraryFunctionsChecker] Remove 
strcasecmp (authored by martong).

Changed prior to commit:
  https://reviews.llvm.org/D87239?vs=290293&id=290925#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87239

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-POSIX.c
  clang/test/Analysis/std-c-library-functions-arg-cstring-dependency.c


Index: clang/test/Analysis/std-c-library-functions-arg-cstring-dependency.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-arg-cstring-dependency.c
@@ -0,0 +1,21 @@
+// This test case crashes if strncasecmp is modeled in StdCLibraryFunctions.
+// Either we fix CStringChecker to handle the call prerequisites in
+// checkPreCall, or we must not evaluate any pure functions in
+// StdCLibraryFunctions that are also handled in CStringChecker.
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=unix.cstring.NullArg \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true \
+// RUN:   -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \
+// RUN:   -triple x86_64-unknown-linux-gnu \
+// RUN:   -verify
+
+typedef __typeof(sizeof(int)) size_t;
+int strncasecmp(const char *s1, const char *s2, size_t n);
+
+int strncasecmp_null_argument(char *a, size_t n) {
+  char *b = 0;
+  return strncasecmp(a, b, n); // expected-warning{{Null pointer passed as 2nd 
argument to string comparison function}}
+}
Index: clang/test/Analysis/std-c-library-functions-POSIX.c
===
--- clang/test/Analysis/std-c-library-functions-POSIX.c
+++ clang/test/Analysis/std-c-library-functions-POSIX.c
@@ -63,8 +63,6 @@
 // CHECK: Loaded summary for: void rewinddir(DIR *dir)
 // CHECK: Loaded summary for: void seekdir(DIR *dirp, long loc)
 // CHECK: Loaded summary for: int rand_r(unsigned int *seedp)
-// CHECK: Loaded summary for: int strcasecmp(const char *s1, const char *s2)
-// CHECK: Loaded summary for: int strncasecmp(const char *s1, const char *s2, 
size_t n)
 // CHECK: Loaded summary for: int fileno(FILE *stream)
 // CHECK: Loaded summary for: int fseeko(FILE *stream, off_t offset, int 
whence)
 // CHECK: Loaded summary for: off_t ftello(FILE *stream)
@@ -195,8 +193,6 @@
 void rewinddir(DIR *dir);
 void seekdir(DIR *dirp, long loc);
 int rand_r(unsigned int *seedp);
-int strcasecmp(const char *s1, const char *s2);
-int strncasecmp(const char *s1, const char *s2, size_t n);
 int fileno(FILE *stream);
 int fseeko(FILE *stream, off_t offset, int whence);
 off_t ftello(FILE *stream);
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -1676,22 +1676,6 @@
   RetType{IntTy}, NoEvalCall)
   .ArgConstraint(NotNull(ArgNo(0;
 
-// int strcasecmp(const char *s1, const char *s2);
-addToFunctionSummaryMap("strcasecmp",
-Summary(ArgTypes{ConstCharPtrTy, ConstCharPtrTy},
-RetType{IntTy}, EvalCallAsPure)
-.ArgConstraint(NotNull(ArgNo(0)))
-.ArgConstraint(NotNull(ArgNo(1;
-
-// int strncasecmp(const char *s1, const char *s2, size_t n);
-addToFunctionSummaryMap(
-"strncasecmp", Summary(ArgTypes{ConstCharPtrTy, ConstCharPtrTy, 
SizeTy},
-   RetType{IntTy}, EvalCallAsPure)
-   .ArgConstraint(NotNull(ArgNo(0)))
-   .ArgConstraint(NotNull(ArgNo(1)))
-   .ArgConstraint(ArgumentCondition(
-   2, WithinRange, Range(0, SizeMax;
-
 // int fileno(FILE *stream);
 addToFunctionSummaryMap(
 "fileno", Summary(ArgTypes{FilePtrTy}, RetType{IntTy}, NoEvalCall)


Index: clang/test/Analysis/std-c-library-functions-arg-cstring-dependency.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-arg-cstring-dependency.c
@@ -0,0 +1,21 @@
+// This test case crashes if strncasecmp is modeled in StdCLibraryFunctions.
+// Either we fix CStringChecker to handle the call prerequisites in
+// checkPreCall, or we must not evaluate any pure functions in
+// StdCLibraryFunctions th

[clang] b7586af - [analyzer][StdLibraryFunctionsChecker] Remove strcasecmp

2020-09-10 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-09-10T12:29:39+02:00
New Revision: b7586afc4dcddd1abc70724585c3eb3857e27f43

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

LOG: [analyzer][StdLibraryFunctionsChecker] Remove strcasecmp

There are 2 reasons to remove strcasecmp and strncasecmp.
1) They are also modeled in CStringChecker and the related argumentum
   contraints are checked there.
2) The argument constraints are checked in CStringChecker::evalCall.
   This is fundamentally flawed, they should be checked in checkPreCall.
   Even if we set up CStringChecker as a weak dependency for
   StdLibraryFunctionsChecker then the latter reports the warning always.
   Besides, CStringChecker fails to discover the constraint violation
   before the call, so, its evalCall returns with `true` and then
   StdCLibraryFunctions also tries to evaluate, this causes an assertion
   in CheckerManager.

Either we fix CStringChecker to handle the call prerequisites in
checkPreCall, or we must not evaluate any pure functions in
StdCLibraryFunctions that are also handled in CStringChecker.
We do the latter in this patch.

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

Added: 
clang/test/Analysis/std-c-library-functions-arg-cstring-dependency.c

Modified: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/test/Analysis/std-c-library-functions-POSIX.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index b71c19a80da9..c6c37a85306e 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -1676,22 +1676,6 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
   RetType{IntTy}, NoEvalCall)
   .ArgConstraint(NotNull(ArgNo(0;
 
-// int strcasecmp(const char *s1, const char *s2);
-addToFunctionSummaryMap("strcasecmp",
-Summary(ArgTypes{ConstCharPtrTy, ConstCharPtrTy},
-RetType{IntTy}, EvalCallAsPure)
-.ArgConstraint(NotNull(ArgNo(0)))
-.ArgConstraint(NotNull(ArgNo(1;
-
-// int strncasecmp(const char *s1, const char *s2, size_t n);
-addToFunctionSummaryMap(
-"strncasecmp", Summary(ArgTypes{ConstCharPtrTy, ConstCharPtrTy, 
SizeTy},
-   RetType{IntTy}, EvalCallAsPure)
-   .ArgConstraint(NotNull(ArgNo(0)))
-   .ArgConstraint(NotNull(ArgNo(1)))
-   .ArgConstraint(ArgumentCondition(
-   2, WithinRange, Range(0, SizeMax;
-
 // int fileno(FILE *stream);
 addToFunctionSummaryMap(
 "fileno", Summary(ArgTypes{FilePtrTy}, RetType{IntTy}, NoEvalCall)

diff  --git a/clang/test/Analysis/std-c-library-functions-POSIX.c 
b/clang/test/Analysis/std-c-library-functions-POSIX.c
index c2c98df86489..9285aee6178b 100644
--- a/clang/test/Analysis/std-c-library-functions-POSIX.c
+++ b/clang/test/Analysis/std-c-library-functions-POSIX.c
@@ -63,8 +63,6 @@
 // CHECK: Loaded summary for: void rewinddir(DIR *dir)
 // CHECK: Loaded summary for: void seekdir(DIR *dirp, long loc)
 // CHECK: Loaded summary for: int rand_r(unsigned int *seedp)
-// CHECK: Loaded summary for: int strcasecmp(const char *s1, const char *s2)
-// CHECK: Loaded summary for: int strncasecmp(const char *s1, const char *s2, 
size_t n)
 // CHECK: Loaded summary for: int fileno(FILE *stream)
 // CHECK: Loaded summary for: int fseeko(FILE *stream, off_t offset, int 
whence)
 // CHECK: Loaded summary for: off_t ftello(FILE *stream)
@@ -195,8 +193,6 @@ FILE *fdopen(int fd, const char *mode);
 void rewinddir(DIR *dir);
 void seekdir(DIR *dirp, long loc);
 int rand_r(unsigned int *seedp);
-int strcasecmp(const char *s1, const char *s2);
-int strncasecmp(const char *s1, const char *s2, size_t n);
 int fileno(FILE *stream);
 int fseeko(FILE *stream, off_t offset, int whence);
 off_t ftello(FILE *stream);

diff  --git 
a/clang/test/Analysis/std-c-library-functions-arg-cstring-dependency.c 
b/clang/test/Analysis/std-c-library-functions-arg-cstring-dependency.c
new file mode 100644
index ..37425e4e3e16
--- /dev/null
+++ b/clang/test/Analysis/std-c-library-functions-arg-cstring-dependency.c
@@ -0,0 +1,21 @@
+// This test case crashes if strncasecmp is modeled in StdCLibraryFunctions.
+// Either we fix CStringChecker to handle the call prerequisites in
+// checkPreCall, or we must not evaluate any pure functions in
+// StdCLibraryFunctions that are a

[clang] a97648b - [analyzer][StdLibraryFunctionsChecker] Add better diagnostics

2020-09-10 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-09-10T12:43:40+02:00
New Revision: a97648b93846f163af262b9a0db684c7f5efc43f

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

LOG: [analyzer][StdLibraryFunctionsChecker] Add better diagnostics

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index c6c37a85306e..f5ad80950ef1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -126,6 +126,8 @@ class StdLibraryFunctionsChecker
 }
 ArgNo getArgNo() const { return ArgN; }
 
+virtual StringRef getName() const = 0;
+
   protected:
 ArgNo ArgN; // Argument to which we apply the constraint.
 
@@ -152,6 +154,7 @@ class StdLibraryFunctionsChecker
 IntRangeVector Ranges;
 
   public:
+StringRef getName() const override { return "Range"; }
 RangeConstraint(ArgNo ArgN, RangeKind Kind, const IntRangeVector &Ranges)
 : ValueConstraint(ArgN), Kind(Kind), Ranges(Ranges) {}
 
@@ -205,6 +208,7 @@ class StdLibraryFunctionsChecker
 ArgNo OtherArgN;
 
   public:
+virtual StringRef getName() const override { return "Comparison"; };
 ComparisonConstraint(ArgNo ArgN, BinaryOperator::Opcode Opcode,
  ArgNo OtherArgN)
 : ValueConstraint(ArgN), Opcode(Opcode), OtherArgN(OtherArgN) {}
@@ -221,6 +225,7 @@ class StdLibraryFunctionsChecker
 bool CannotBeNull = true;
 
   public:
+StringRef getName() const override { return "NonNull"; }
 ProgramStateRef apply(ProgramStateRef State, const CallEvent &Call,
   const Summary &Summary,
   CheckerContext &C) const override {
@@ -272,6 +277,7 @@ class StdLibraryFunctionsChecker
 BinaryOperator::Opcode Op = BO_LE;
 
   public:
+StringRef getName() const override { return "BufferSize"; }
 BufferSizeConstraint(ArgNo Buffer, llvm::APSInt BufMinSize)
 : ValueConstraint(Buffer), ConcreteSize(BufMinSize) {}
 BufferSizeConstraint(ArgNo Buffer, ArgNo BufSize)
@@ -466,6 +472,8 @@ class StdLibraryFunctionsChecker
   return *this;
 }
 Summary &ArgConstraint(ValueConstraintPtr VC) {
+  assert(VC->getArgNo() != Ret &&
+ "Arg constraint should not refer to the return value");
   ArgConstraints.push_back(VC);
   return *this;
 }
@@ -549,17 +557,24 @@ class StdLibraryFunctionsChecker
   void initFunctionSummaries(CheckerContext &C) const;
 
   void reportBug(const CallEvent &Call, ExplodedNode *N,
- CheckerContext &C) const {
+ const ValueConstraint *VC, CheckerContext &C) const {
 if (!ChecksEnabled[CK_StdCLibraryFunctionArgsChecker])
   return;
-// TODO Add detailed diagnostic.
-StringRef Msg = "Function argument constraint is not satisfied";
+// TODO Add more detailed diagnostic.
+std::string Msg =
+(Twine("Function argument constraint is not satisfied, constraint: ") +
+ VC->getName().data() + ", ArgN: " + Twine(VC->getArgNo()))
+.str();
 if (!BT_InvalidArg)
   BT_InvalidArg = std::make_unique(
   CheckNames[CK_StdCLibraryFunctionArgsChecker],
   "Unsatisfied argument constraints", categories::LogicError);
 auto R = std::make_unique(*BT_InvalidArg, Msg, N);
-bugreporter::trackExpressionValue(N, Call.getArgExpr(0), *R);
+bugreporter::trackExpressionValue(N, Call.getArgExpr(VC->getArgNo()), *R);
+
+// Highlight the range of the argument that was violated.
+R->addRange(Call.getArgSourceRange(VC->getArgNo()));
+
 C.emitReport(std::move(R));
   }
 };
@@ -696,7 +711,7 @@ void StdLibraryFunctionsChecker::checkPreCall(const 
CallEvent &Call,
 // The argument constraint is not satisfied.
 if (FailureSt && !SuccessSt) {
   if (ExplodedNode *N = C.generateErrorNode(NewState))
-reportBug(Call, N, C);
+reportBug(Call, N, Constraint.get(), C);
   break;
 } else {
   // We will apply the constraint even if we cannot reason about the



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


[PATCH] D79431: [analyzer] StdLibraryFunctionsChecker: Add better diagnostics

2020-09-10 Thread Gabor Marton via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa97648b93846: [analyzer][StdLibraryFunctionsChecker] Add 
better diagnostics (authored by martong).

Changed prior to commit:
  https://reviews.llvm.org/D79431?vs=280376&id=290930#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79431

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -126,6 +126,8 @@
 }
 ArgNo getArgNo() const { return ArgN; }
 
+virtual StringRef getName() const = 0;
+
   protected:
 ArgNo ArgN; // Argument to which we apply the constraint.
 
@@ -152,6 +154,7 @@
 IntRangeVector Ranges;
 
   public:
+StringRef getName() const override { return "Range"; }
 RangeConstraint(ArgNo ArgN, RangeKind Kind, const IntRangeVector &Ranges)
 : ValueConstraint(ArgN), Kind(Kind), Ranges(Ranges) {}
 
@@ -205,6 +208,7 @@
 ArgNo OtherArgN;
 
   public:
+virtual StringRef getName() const override { return "Comparison"; };
 ComparisonConstraint(ArgNo ArgN, BinaryOperator::Opcode Opcode,
  ArgNo OtherArgN)
 : ValueConstraint(ArgN), Opcode(Opcode), OtherArgN(OtherArgN) {}
@@ -221,6 +225,7 @@
 bool CannotBeNull = true;
 
   public:
+StringRef getName() const override { return "NonNull"; }
 ProgramStateRef apply(ProgramStateRef State, const CallEvent &Call,
   const Summary &Summary,
   CheckerContext &C) const override {
@@ -272,6 +277,7 @@
 BinaryOperator::Opcode Op = BO_LE;
 
   public:
+StringRef getName() const override { return "BufferSize"; }
 BufferSizeConstraint(ArgNo Buffer, llvm::APSInt BufMinSize)
 : ValueConstraint(Buffer), ConcreteSize(BufMinSize) {}
 BufferSizeConstraint(ArgNo Buffer, ArgNo BufSize)
@@ -466,6 +472,8 @@
   return *this;
 }
 Summary &ArgConstraint(ValueConstraintPtr VC) {
+  assert(VC->getArgNo() != Ret &&
+ "Arg constraint should not refer to the return value");
   ArgConstraints.push_back(VC);
   return *this;
 }
@@ -549,17 +557,24 @@
   void initFunctionSummaries(CheckerContext &C) const;
 
   void reportBug(const CallEvent &Call, ExplodedNode *N,
- CheckerContext &C) const {
+ const ValueConstraint *VC, CheckerContext &C) const {
 if (!ChecksEnabled[CK_StdCLibraryFunctionArgsChecker])
   return;
-// TODO Add detailed diagnostic.
-StringRef Msg = "Function argument constraint is not satisfied";
+// TODO Add more detailed diagnostic.
+std::string Msg =
+(Twine("Function argument constraint is not satisfied, constraint: ") +
+ VC->getName().data() + ", ArgN: " + Twine(VC->getArgNo()))
+.str();
 if (!BT_InvalidArg)
   BT_InvalidArg = std::make_unique(
   CheckNames[CK_StdCLibraryFunctionArgsChecker],
   "Unsatisfied argument constraints", categories::LogicError);
 auto R = std::make_unique(*BT_InvalidArg, Msg, N);
-bugreporter::trackExpressionValue(N, Call.getArgExpr(0), *R);
+bugreporter::trackExpressionValue(N, Call.getArgExpr(VC->getArgNo()), *R);
+
+// Highlight the range of the argument that was violated.
+R->addRange(Call.getArgSourceRange(VC->getArgNo()));
+
 C.emitReport(std::move(R));
   }
 };
@@ -696,7 +711,7 @@
 // The argument constraint is not satisfied.
 if (FailureSt && !SuccessSt) {
   if (ExplodedNode *N = C.generateErrorNode(NewState))
-reportBug(Call, N, C);
+reportBug(Call, N, Constraint.get(), C);
   break;
 } else {
   // We will apply the constraint even if we cannot reason about the


Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -126,6 +126,8 @@
 }
 ArgNo getArgNo() const { return ArgN; }
 
+virtual StringRef getName() const = 0;
+
   protected:
 ArgNo ArgN; // Argument to which we apply the constraint.
 
@@ -152,6 +154,7 @@
 IntRangeVector Ranges;
 
   public:
+StringRef getName() const override { return "Range"; }
 RangeConstraint(ArgNo ArgN, RangeKind Kind, const IntRangeVector &Ranges)
 : ValueConstraint(ArgN), Kind(Kind), Ranges(Ranges) {}
 
@@ -205,6 +208,7 @@
 ArgNo OtherArgN;
 
   public:
+virtual StringRef getName() const override { return "Comparison"; };
 ComparisonCon

Re: r364428 - Make CodeGen depend on ASTMatchers

2020-09-10 Thread Vassil Vassilev via cfe-commits

Hello,

  IIUC, clang's CodeGen does not immediately depend on ASTMatchers. I 
was wondering what is the reason for inserting such a dependency to fix 
the shared library builds?


  Can you give more details about the failure you are fixing?

  Sorry for the late question.

Best, Vassil
On 6/26/19 5:13 PM, Michael Liao via cfe-commits wrote:

Author: hliao
Date: Wed Jun 26 07:13:43 2019
New Revision: 364428

URL: http://llvm.org/viewvc/llvm-project?rev=364428&view=rev
Log:
Make CodeGen depend on ASTMatchers

- Shared library builds are broken due to the missing dependency.

Modified:
 cfe/trunk/lib/CodeGen/CMakeLists.txt

Modified: cfe/trunk/lib/CodeGen/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CMakeLists.txt?rev=364428&r1=364427&r2=364428&view=diff
==
--- cfe/trunk/lib/CodeGen/CMakeLists.txt (original)
+++ cfe/trunk/lib/CodeGen/CMakeLists.txt Wed Jun 26 07:13:43 2019
@@ -101,6 +101,7 @@ add_clang_library(clangCodeGen
LINK_LIBS
clangAnalysis
clangAST
+  clangASTMatchers
clangBasic
clangFrontend
clangLex


___
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] D86089: [flang][driver]Add experimental flang driver and frontend with help screen

2020-09-10 Thread Richard Barton via Phabricator via cfe-commits
richard.barton.arm accepted this revision.
richard.barton.arm added a comment.
This revision is now accepted and ready to land.

This LGTM. I think all the previous comments from other reviewers and me have 
been dealt with so I am happy to accept this revision based on the reviews so 
far.

I have a few small inline comments to resolve in PrintHelp now we have reverted 
the functional changes there. Happy to approve on the assumption that they are 
dealt with and I don't need to see another patch, you can accept it yourself.

I think the non-flang changes to clang and llvm are in-line with what we said 
in our RFC. I think the summary of these changes are:

- Don't hard-code the name of the driver in the object constructor, pass it in 
as an argument + fix up all the clang callsites.
- Tweak the --help and --version logic to be conditional on driver mode
- Add some new FlangOption flags to Options.td
- Change the flang driver binary name to flang-new (in the already approved 
flang mods)




Comment at: flang/test/Flang-Driver/emit-obj.f90:2
+! RUN: %flang-new  %s 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: %flang-new  -fc1 -emit-obj %s 2>&1 | FileCheck %s --check-prefix=ERROR
+

awarzynski wrote:
> richard.barton.arm wrote:
> > Seems like it would be helpful to have also implemented `-###` in this 
> > patch so that you don't need to write tests like this. You could simply run 
> > flang-new -### then check the -fc1 line that would have been emitted for 
> > the presence of -emit-obj.
> > 
> > Same comment above regarding exit code.
> > Seems like it would be helpful to have also implemented -### in this patch
> 
> As`flang-new` is based on libclangDriver, we get `-###` for free (i.e. it's 
> already supported).
> 
> However, there's a catch: 
> https://github.com/llvm/llvm-project/blob/master/clang/include/clang/Driver/Options.td#L369-L370.
>  Currently `flang-new --help` will not display `-###`  because the the 
> corresponding option definition hasn't been updated (i.e. it is not flagged 
> as a Flang option):
> ```
> def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[DriverOption, CoreOption]>,
> HelpText<"Print (but do not run) the commands to run for this 
> compilation">;
> ``` 
> We have three options:
> 1. Make `flang-new --help` display options that are flagged as `DriverOption` 
> or `CoreOption`. Note this will include many other options (currently 
> unsupported) and extra filtering would be required.
> 2. Add `FlangOption` to the definition of `_HASH_HASH_HASH`, but IMO that's a 
> bit controversial. Is that what we want to do long-term? Or shall we create a 
> separate category for generic driver options that apply to both Clang and 
> Flang?
> 3. Delay the decision until there is more code to base our design on.
> 
> I'm in favor of Option 3.
Fair enough. Happy to cross this bridge when we come to it later on. I 
certainly think that flang-new should support -### one day.



Comment at: llvm/include/llvm/Option/OptTable.h:228
   /// \param FlagsToInclude - If non-zero, only include options with any
-  /// of these flags set.
   /// \param FlagsToExclude - Exclude options with any of these flags set.

I don't think this change is correct now that you have reverted the code change 
to the function.

If I have the same bit set in FlagsToInclude and FlagsToExclude, the 
FlagsToExclude check fires second and would mean the option is not printed. So 
FlagsToExclude takes precedence. 

Suggest to drop the edit or to correct it.



Comment at: llvm/lib/Option/OptTable.cpp:613
 unsigned Flags = getInfo(Id).Flags;
+
 if (FlagsToInclude && !(Flags & FlagsToInclude))

With the diff to this logic gone, we should also remove the new newlines so as 
not to make textual changes unrelated to this patch.



Comment at: llvm/lib/Option/OptTable.cpp:621
+// If `Flags` is empty (i.e. it's an option without any flags) then this is
+// a Clang-only option. If:
+// * we _are not_ in Flang Mode (FlagsToExclude contains FlangMode), then

awarzynski wrote:
> richard.barton.arm wrote:
> > awarzynski wrote:
> > > richard.barton.arm wrote:
> > > > This is not the sort of change I expect to see in an llvm support 
> > > > library given that it seems very clang and flang specific. 
> > > > 
> > > > I think this needs to be re-written to be more generic, perhaps 
> > > > tweaking the interface to be able to express the logic you want to use 
> > > > for flang and clang.
> > > > 
> > > > Why is it not sufficient to call this function unchanged from both 
> > > > flang and clang but with a different set of 
> > > > FlagsToInclude/FlagsToExclude passed in using this logic to set that on 
> > > > the clang/flang side?
> > > I agree and have updated this. Thanks for pointing it out!
> > > 
> > > This part is particularly tricky for Flang. Flang has o

[PATCH] D87395: Sema: add support for `__attribute__((__swift_objc_members__))`

2020-09-10 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:3386-3388
+The ``swift_objc_members`` attribute maps to the ``@objcMembers`` Swift
+attribute, which indicates that Swift members of this class, its subclasses, 
and
+all extensions thereof, will implicitly be exposed back to Objective-C.





Comment at: clang/test/SemaObjC/attr-swift_objc_members.m:4
+#if !__has_attribute(swift_objc_members)
+#error cannot verify precense of swift_objc_members attribute
+#endif





Comment at: clang/test/SemaObjC/attr-swift_objc_members.m:19
+extern void f(void);
+// expected-error@-2 {{'swift_objc_members' attribute only applies to 
Objective-C interfaces}}

Please also add a test for (erroneously) passing arguments to the attribute.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87395

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


[PATCH] D87331: Sema: add support for `__attribute__((__swift_error__))`

2020-09-10 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:3377-3382
+def SwiftDocs : DocumentationCategory<"Controlling Swift Import"> {
+  let Content = [{
+Clang supports additional attributes for controlling how APIs are imported into
+Swift.
+  }];
+}





Comment at: clang/include/clang/Basic/AttrDocs.td:3399
+* ``swift_error(none)`` means that the function should not be imported as
+throwing. The error parameter and result type will be left alone.
+





Comment at: clang/test/SemaObjC/attr-swift-error.m:55
+
+// This is unconventional and very odd but we do process it.
+- (int)q0:(const NSError **)error 
__attribute__((__swift_error__(nonzero_result)));





Comment at: clang/test/SemaObjC/attr-swift-error.m:97
+
+// This is unconventional and very odd but we do process it.
+extern void *q0(const CFErrorRef *) 
__attribute__((__swift_error__(null_result)));




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87331

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


[clang] 576bd52 - [Codegen][X86] Move AMX specific codegen tests into X86 subfolder.

2020-09-10 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-09-10T12:38:23+01:00
New Revision: 576bd52f778405de08f309678e4fe4f7523bf7c4

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

LOG: [Codegen][X86] Move AMX specific codegen tests into X86 subfolder.

Added: 
clang/test/CodeGen/X86/amx.c
clang/test/CodeGen/X86/amx_errors.c
clang/test/CodeGen/X86/amx_inline_asm.c

Modified: 


Removed: 
clang/test/CodeGen/AMX/amx.c
clang/test/CodeGen/AMX/amx_errors.c
clang/test/CodeGen/AMX/amx_inline_asm.c



diff  --git a/clang/test/CodeGen/AMX/amx.c b/clang/test/CodeGen/X86/amx.c
similarity index 100%
rename from clang/test/CodeGen/AMX/amx.c
rename to clang/test/CodeGen/X86/amx.c

diff  --git a/clang/test/CodeGen/AMX/amx_errors.c 
b/clang/test/CodeGen/X86/amx_errors.c
similarity index 100%
rename from clang/test/CodeGen/AMX/amx_errors.c
rename to clang/test/CodeGen/X86/amx_errors.c

diff  --git a/clang/test/CodeGen/AMX/amx_inline_asm.c 
b/clang/test/CodeGen/X86/amx_inline_asm.c
similarity index 100%
rename from clang/test/CodeGen/AMX/amx_inline_asm.c
rename to clang/test/CodeGen/X86/amx_inline_asm.c



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


[clang-tools-extra] 875b853 - [clang-tidy] Fix reST syntax

2020-09-10 Thread via cfe-commits

Author: serge-sans-paille
Date: 2020-09-10T13:56:57+02:00
New Revision: 875b8537eea0662ead820979f18c83d5e31b4b8b

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

LOG: [clang-tidy] Fix reST syntax

Authored by Eisuke Kawashima [https://github.com/llvm/llvm-project/pull/245]

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-argument-comment.rst
clang-tools-extra/docs/clang-tidy/checks/bugprone-exception-escape.rst

clang-tools-extra/docs/clang-tidy/checks/bugprone-forwarding-reference-overload.rst
clang-tools-extra/docs/clang-tidy/checks/bugprone-lambda-function-name.rst

clang-tools-extra/docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst

clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-missing-comma.rst
clang-tools-extra/docs/clang-tidy/checks/bugprone-terminating-continue.rst
clang-tools-extra/docs/clang-tidy/checks/cert-con36-c.rst
clang-tools-extra/docs/clang-tidy/checks/cert-con54-cpp.rst

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-avoid-non-const-global-variables.rst

clang-tools-extra/docs/clang-tidy/checks/google-objc-global-variable-declaration.rst
clang-tools-extra/docs/clang-tidy/checks/google-readability-casting.rst
clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-const.rst
clang-tools-extra/docs/clang-tidy/checks/misc-no-recursion.rst
clang-tools-extra/docs/clang-tidy/checks/misc-unused-parameters.rst

clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
clang-tools-extra/docs/clang-tidy/checks/modernize-use-noexcept.rst

clang-tools-extra/docs/clang-tidy/checks/modernize-use-uncaught-exceptions.rst
clang-tools-extra/docs/clang-tidy/checks/readability-const-return-type.rst
clang-tools-extra/docs/clang-tidy/checks/zircon-temporary-objects.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone-argument-comment.rst 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone-argument-comment.rst
index 8484c393a12b..8c59541b8d42 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone-argument-comment.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-argument-comment.rst
@@ -29,6 +29,7 @@ Options
account.
 
 .. option:: IgnoreSingleArgument
+
When true, the check will ignore the single argument.
 
 .. option:: CommentBoolLiterals

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone-exception-escape.rst 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone-exception-escape.rst
index 9c7f113a1bf3..52f3ceff2814 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone-exception-escape.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-exception-escape.rst
@@ -5,6 +5,7 @@ bugprone-exception-escape
 
 Finds functions which may throw an exception directly or indirectly, but they
 should not. The functions which should not throw exceptions are the following:
+
 * Destructors
 * Move constructors
 * Move assignment operators

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone-forwarding-reference-overload.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone-forwarding-reference-overload.rst
index 61255e7596b4..b2a9e0f3b3df 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone-forwarding-reference-overload.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone-forwarding-reference-overload.rst
@@ -37,7 +37,7 @@ The check warns for constructors C1 and C2, because those can 
hide copy and move
 constructors. We suppress warnings if the copy and the move constructors are 
both
 disabled (deleted or private), because there is nothing the perfect forwarding
 constructor could hide in this case. We also suppress warnings for constructors
-like C3 that are guarded with an enable_if, assuming the programmer was aware 
of
+like C3 that are guarded with an ``enable_if``, assuming the programmer was 
aware of
 the possible hiding.
 
 Background
@@ -45,5 +45,5 @@ Background
 
 For deciding whether a constructor is guarded with enable_if, we consider the
 default values of the type parameters and the types of the constructor
-parameters. If any part of these types is std::enable_if or std::enable_if_t, 
we
-assume the constructor is guarded.
+parameters. If any part of these types is ``std::enable_if`` or 
``std::enable_if_t``,
+we assume the constructor is guarded.

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone-lambda-function-name.rst 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone-lambda-function-name.rst
index 683977a3d2c0..6f0ba836fdf5 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone-l

[PATCH] D87347: [NFC] Fix compiler warnings due to integer comparison of different signedness

2020-09-10 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp updated this revision to Diff 290944.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87347

Files:
  clang/lib/Lex/Pragma.cpp
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp


Index: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -2037,8 +2037,7 @@
 if (Mask[i] == UndefMaskElem)
   continue;
 uint64_t LSBIndex = IsBigEndian ? (i + 1) * TruncRatio - 1 : i * 
TruncRatio;
-assert(LSBIndex <= std::numeric_limits::max() &&
-   "Overflowed 32-bits");
+assert(LSBIndex <= INT32_MAX && "Overflowed 32-bits");
 if (Mask[i] != (int)LSBIndex)
   return nullptr;
   }
Index: llvm/lib/MC/WasmObjectWriter.cpp
===
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -939,9 +939,8 @@
 if (Segment.InitFlags & wasm::WASM_SEGMENT_HAS_MEMINDEX)
   encodeULEB128(0, W.OS); // memory index
 if ((Segment.InitFlags & wasm::WASM_SEGMENT_IS_PASSIVE) == 0) {
-  W.OS << char(Segment.Offset > std::numeric_limits().max()
- ? wasm::WASM_OPCODE_I64_CONST
- : wasm::WASM_OPCODE_I32_CONST);
+  W.OS << char(Segment.Offset > INT32_MAX ? wasm::WASM_OPCODE_I64_CONST
+  : wasm::WASM_OPCODE_I32_CONST);
   encodeSLEB128(Segment.Offset, W.OS); // offset
   W.OS << char(wasm::WASM_OPCODE_END);
 }
Index: llvm/lib/Analysis/VectorUtils.cpp
===
--- llvm/lib/Analysis/VectorUtils.cpp
+++ llvm/lib/Analysis/VectorUtils.cpp
@@ -416,8 +416,7 @@
   ScaledMask.clear();
   for (int MaskElt : Mask) {
 if (MaskElt >= 0) {
-  assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <=
- std::numeric_limits::max() &&
+  assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <= INT32_MAX &&
  "Overflowed 32-bits");
 }
 for (int SliceElt = 0; SliceElt != Scale; ++SliceElt)
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -1356,7 +1356,7 @@
 while (Tok.is(tok::numeric_constant)) {
   uint64_t Value;
   if (!PP.parseSimpleIntegerLiteral(Tok, Value) || Value == 0 ||
-  Value > std::numeric_limits::max()) {
+  Value > INT_MAX) {
 PP.Diag(Tok, diag::warn_pragma_warning_expected_number);
 return;
   }


Index: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -2037,8 +2037,7 @@
 if (Mask[i] == UndefMaskElem)
   continue;
 uint64_t LSBIndex = IsBigEndian ? (i + 1) * TruncRatio - 1 : i * TruncRatio;
-assert(LSBIndex <= std::numeric_limits::max() &&
-   "Overflowed 32-bits");
+assert(LSBIndex <= INT32_MAX && "Overflowed 32-bits");
 if (Mask[i] != (int)LSBIndex)
   return nullptr;
   }
Index: llvm/lib/MC/WasmObjectWriter.cpp
===
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -939,9 +939,8 @@
 if (Segment.InitFlags & wasm::WASM_SEGMENT_HAS_MEMINDEX)
   encodeULEB128(0, W.OS); // memory index
 if ((Segment.InitFlags & wasm::WASM_SEGMENT_IS_PASSIVE) == 0) {
-  W.OS << char(Segment.Offset > std::numeric_limits().max()
- ? wasm::WASM_OPCODE_I64_CONST
- : wasm::WASM_OPCODE_I32_CONST);
+  W.OS << char(Segment.Offset > INT32_MAX ? wasm::WASM_OPCODE_I64_CONST
+  : wasm::WASM_OPCODE_I32_CONST);
   encodeSLEB128(Segment.Offset, W.OS); // offset
   W.OS << char(wasm::WASM_OPCODE_END);
 }
Index: llvm/lib/Analysis/VectorUtils.cpp
===
--- llvm/lib/Analysis/VectorUtils.cpp
+++ llvm/lib/Analysis/VectorUtils.cpp
@@ -416,8 +416,7 @@
   ScaledMask.clear();
   for (int MaskElt : Mask) {
 if (MaskElt >= 0) {
-  assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <=
- std::numeric_limits::max() &&
+  assert(((uint64_t)Scale * MaskElt + (Scale - 1)) <= INT32_MAX &&
  "Overflowed 32-bits");
 }
 for (int SliceElt = 0; SliceElt != Scale; ++SliceElt)
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Prag

[clang] 2239882 - [CodeGen][X86] Move x86 builtin intrinsic/codegen tests into X86 subfolder.

2020-09-10 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-09-10T12:58:21+01:00
New Revision: 2239882f7d0e4e6d5702bc20ba071a92ec75d37c

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

LOG: [CodeGen][X86] Move x86 builtin intrinsic/codegen tests into X86 subfolder.

There are still plenty of tests that specify x86 as a triple but most shouldn't 
be doing anything very target specific - we can move any ones that I have 
missed on a case by case basis.

Added: 
clang/test/CodeGen/X86/3dnow-builtins.c
clang/test/CodeGen/X86/adc-builtins.c
clang/test/CodeGen/X86/adx-builtins.c
clang/test/CodeGen/X86/avx-builtins-constrained-cmp.c
clang/test/CodeGen/X86/avx-builtins.c
clang/test/CodeGen/X86/avx-cmp-builtins.c
clang/test/CodeGen/X86/avx-shuffle-builtins.c
clang/test/CodeGen/X86/avx2-builtins.c
clang/test/CodeGen/X86/avx512-inline-asm-kregisters-basics.c
clang/test/CodeGen/X86/avx512-kconstraints-att_inline_asm.c
clang/test/CodeGen/X86/avx512-reduceIntrin.c
clang/test/CodeGen/X86/avx512-reduceMinMaxIntrin.c
clang/test/CodeGen/X86/avx512bf16-builtins.c
clang/test/CodeGen/X86/avx512bitalg-builtins.c
clang/test/CodeGen/X86/avx512bw-builtins.c
clang/test/CodeGen/X86/avx512cdintrin.c
clang/test/CodeGen/X86/avx512dq-builtins.c
clang/test/CodeGen/X86/avx512er-builtins.c
clang/test/CodeGen/X86/avx512f-builtins-constrained-cmp.c
clang/test/CodeGen/X86/avx512f-builtins-constrained.c
clang/test/CodeGen/X86/avx512f-builtins.c
clang/test/CodeGen/X86/avx512ifma-builtins.c
clang/test/CodeGen/X86/avx512ifmavl-builtins.c
clang/test/CodeGen/X86/avx512pf-builtins.c
clang/test/CodeGen/X86/avx512vbmi-builtins.c
clang/test/CodeGen/X86/avx512vbmi2-builtins.c
clang/test/CodeGen/X86/avx512vbmivl-builtin.c
clang/test/CodeGen/X86/avx512vl-builtins-constrained-cmp.c
clang/test/CodeGen/X86/avx512vl-builtins-constrained.c
clang/test/CodeGen/X86/avx512vl-builtins.c
clang/test/CodeGen/X86/avx512vlbf16-builtins.c
clang/test/CodeGen/X86/avx512vlbitalg-builtins.c
clang/test/CodeGen/X86/avx512vlbw-builtins.c
clang/test/CodeGen/X86/avx512vlcd-builtins.c
clang/test/CodeGen/X86/avx512vldq-builtins.c
clang/test/CodeGen/X86/avx512vlvbmi2-builtins.c
clang/test/CodeGen/X86/avx512vlvnni-builtins.c
clang/test/CodeGen/X86/avx512vnni-builtins.c
clang/test/CodeGen/X86/avx512vpopcntdqintrin.c
clang/test/CodeGen/X86/avx512vpopcntdqvlintrin.c
clang/test/CodeGen/X86/bitscan-builtins.c
clang/test/CodeGen/X86/bmi-builtins.c
clang/test/CodeGen/X86/bmi2-builtins.c
clang/test/CodeGen/X86/builtin-clflushopt.c
clang/test/CodeGen/X86/builtin-clwb.c
clang/test/CodeGen/X86/builtin-clzero.c
clang/test/CodeGen/X86/builtin-movdir.c
clang/test/CodeGen/X86/builtin-wbinvd.c
clang/test/CodeGen/X86/builtin-wbnoinvd.c
clang/test/CodeGen/X86/cetintrin.c
clang/test/CodeGen/X86/cldemote.c
clang/test/CodeGen/X86/f16c-builtins-constrained.c
clang/test/CodeGen/X86/f16c-builtins.c
clang/test/CodeGen/X86/fma-builtins-constrained.c
clang/test/CodeGen/X86/fma-builtins.c
clang/test/CodeGen/X86/fma4-builtins.c
clang/test/CodeGen/X86/fsgsbase-builtins.c
clang/test/CodeGen/X86/gfni-builtins.c
clang/test/CodeGen/X86/intel-avx512vlvp2intersect.c
clang/test/CodeGen/X86/intel-avx512vp2intersect.c
clang/test/CodeGen/X86/invpcid.c
clang/test/CodeGen/X86/lwp-builtins.c
clang/test/CodeGen/X86/lzcnt-builtins.c
clang/test/CodeGen/X86/mmx-builtins.c
clang/test/CodeGen/X86/mmx-inline-asm-error.c
clang/test/CodeGen/X86/mmx-inline-asm.c
clang/test/CodeGen/X86/mmx-shift-with-immediate.c
clang/test/CodeGen/X86/movbe-builtins.c
clang/test/CodeGen/X86/pause.c
clang/test/CodeGen/X86/pclmul-builtins.c
clang/test/CodeGen/X86/pku.c
clang/test/CodeGen/X86/popcnt-builtins.c
clang/test/CodeGen/X86/prefetchw-builtins.c
clang/test/CodeGen/X86/ptwrite.c
clang/test/CodeGen/X86/rd-builtins.c
clang/test/CodeGen/X86/rdpid-builtins.c
clang/test/CodeGen/X86/rdrand-builtins.c
clang/test/CodeGen/X86/rot-intrinsics.c
clang/test/CodeGen/X86/rtm-builtins.c
clang/test/CodeGen/X86/sha-builtins.c
clang/test/CodeGen/X86/sse-builtins-constrained-cmp.c
clang/test/CodeGen/X86/sse-builtins-constrained.c
clang/test/CodeGen/X86/sse-builtins-dbg.c
clang/test/CodeGen/X86/sse-builtins.c
clang/test/CodeGen/X86/sse.c
clang/test/CodeGen/X86/sse2-builtins-constrained-cmp.c
clang/test/CodeGen/X86/sse2-builtins.c
clang/test/CodeGen/X86/sse3-builtins.c
clang/test/CodeGen/X86/sse41-builtins.c
clang/test/CodeGen/X86/sse42-builtins.c
clang/test/CodeGen/X86/sse4a-builtins.c
clang/test/CodeGen/X86/ssse3-builtins.c
clang/test/CodeGen/X86/tbm-builtins.c
clang/test/CodeGen/X86/vae

[PATCH] D87347: [NFC] Fix compiler warnings due to integer comparison of different signedness

2020-09-10 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.

LGTM - I'll try to commit this later today


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87347

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


[PATCH] D87425: [CodeGen][typeid] Emit typeinfo directly if type is known at compile-time

2020-09-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I'm not sure that changing isPotentiallyEvaluated() is the right thing to do. 
The meaning of that corresponds to text in the standard: 
https://eel.is/c++draft/expr.typeid#3 so changing it to something that doesn't 
match the standard exactly seems wrong.

I think it would be safer to do the change purely as an optimization in codegen 
(maybe we could add a new helper method that could also be used by the warning).

Also, I found another interesting test case: https://godbolt.org/z/aW4ojr

  #include 
  
  class B {
  public:
virtual void f();
  };
  
  B f();
  
   const std::type_info& g() {
return typeid(f());
  }

Here MSVC warns about /GR- and emits the call to  __RTtypeid even though I 
think it's not necessary since the type is statically known. Actually, if I 
understand things correctly, f() shouldn't even be evaluated here since the 
expression is not a glvalue, and Clang gets that right. So that's a case where 
our codegen is better than MSVC :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87425

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


[clang] 05d02e5 - Fix invalid link format in Clang LanguageExtension

2020-09-10 Thread Guillaume Chatelet via cfe-commits

Author: Guillaume Chatelet
Date: 2020-09-10T12:27:50Z
New Revision: 05d02e5a4e54a04f050b52ee30d1860073bd8b34

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

LOG: Fix invalid link format in Clang LanguageExtension

Added: 


Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index c89f924c58ba..60b3f21b3e50 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -2416,9 +2416,9 @@ Memory builtins
 
 ``__builtin_memcpy_inline(dst, src, size)`` is identical to
 ``__builtin_memcpy(dst, src, size)`` except that the generated code is
-guaranteed not to call any external functions. See [LLVM IR 
‘llvm.memcpy.inline’
-Intrinsic](https://llvm.org/docs/LangRef.html#llvm-memcpy-inline-intrinsic) for
-more information.
+guaranteed not to call any external functions. See LLVM IR `llvm.memcpy.inline
+`_ Intrinsic 
+for more information.
 
 Note that the `size` argument must be a compile time constant.
 



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


Clang-Format, Clang-Tidy - Absolute Path to config files

2020-09-10 Thread via cfe-commits
Hi all,


I have recently started to work with Clang-Format and Clang-Tidy tools as part 
of a methodology project in my company.
We want to have a uniform style and format in the entire department and for 
that we want to use the two tools to automatically keep this in order. For this 
we need to be able to store the config files somewhere available for everybody 
and for any project.

In my research, I did not find the possibility to give an Absolute Path to the 
config files of the tools.

This is why I added the feature myself and recompiled the tools. Could some 
body help me with the integration of the feature in the community?


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


[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-10 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:312
 switch (II->getIntrinsicID()) {
 default: llvm_unreachable("doesn't pass 'hasAnalyzableMemoryWrite' 
predicate");
 case Intrinsic::lifetime_end:

asbirlea wrote:
> The crash is hitting this unreachable for the intrinsic "llvm.memcpy.inline".
> Simple repro: opt -dse test1.ll
> ```
> define void @test(i8* noalias nocapture %0, i8* noalias nocapture readonly 
> %1) {
>   tail call void @llvm.memcpy.inline(i8* align 1 %0, i8* align 1 %1, i64 3, 
> i1 false)
>   ret void
> }
> 
> declare void @llvm.memcpy.inline(i8* noalias nocapture writeonly, i8* noalias 
> nocapture readonly, i64 immarg, i1 immarg)
> ```
Thanks! The problem was that MemorySSA-based DSE only relies on whether we can 
find read/write memory locations. For `memcpy.inline`, MemoryLocation knows how 
to extract the arguments, but the DSE functions where not updated to account 
for that.

In the legacy DSE, we silently failed to optimized/eliminate `memcpy.inline` 
calls, but with the MemorySSA version we got a crash highlighting that the code 
needs updating.

That should be fixed by a5ec99da6ea7


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


[PATCH] D87449: [clang-tidy] Add new check for SEI CERT rule SIG30-C.

2020-09-10 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, martong, phosek, gamesh411, Szelethus, 
dkrupp, xazax.hun, whisperity, mgorny.
Herald added a project: clang.
balazske requested review of this revision.

SIG30-C. Call only asynchronous-safe functions within signal handlers

First version of this check, only minimal list of functions is allowed
("strictly conforming" case). Later a checker option can be added
to support the POSIX list of allowed functions (taken from the rule's
description).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87449

Files:
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/clang-tidy/cert/CMakeLists.txt
  clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.cpp
  clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.h
  clang-tools-extra/docs/clang-tidy/checks/cert-sig30-c.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/signal.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdlib.h
  clang-tools-extra/test/clang-tidy/checkers/cert-sig30-c.c

Index: clang-tools-extra/test/clang-tidy/checkers/cert-sig30-c.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cert-sig30-c.c
@@ -0,0 +1,72 @@
+// RUN: %check_clang_tidy %s cert-sig30-c %t -- -- -isystem %S/Inputs/Headers
+
+#include "signal.h"
+#include "stdio.h"
+#include "stdlib.h"
+
+void handler_abort(int) {
+  abort();
+}
+
+void handler__Exit(int) {
+  _Exit(0);
+}
+
+void handler_quick_exit(int) {
+  quick_exit(0);
+}
+
+void handler_other(int) {
+  printf("1234");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Signal handler potentially calls non asynchronous-safe function. This may result in undefined behavior. [cert-sig30-c]
+}
+
+void handler_signal(int) {
+  // FIXME: It is only OK to call signal with the current signal number.
+  signal(0, SIG_DFL);
+}
+
+void f_ok() {
+  abort();
+}
+
+void f_bad() {
+  printf("1234");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Signal handler potentially calls non asynchronous-safe function. This may result in undefined behavior. [cert-sig30-c]
+}
+
+void f_extern();
+
+void handler_ok(int) {
+  f_ok();
+  f_extern();
+}
+
+void handler_bad(int) {
+  f_bad();
+}
+
+// Function called "signal" that is not to be recognized by the checker.
+typedef void (*callback_t)(int);
+void signal(int, callback_t, int);
+
+void test() {
+  signal(SIGINT, handler_abort);
+  signal(SIGINT, handler__Exit);
+  signal(SIGINT, handler_quick_exit);
+  signal(SIGINT, handler_signal);
+  signal(SIGINT, handler_other);
+
+  signal(SIGINT, handler_ok);
+  signal(SIGINT, handler_bad);
+
+  signal(SIGINT, quick_exit);
+  signal(SIGINT, other_call);
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: Signal handler potentially calls non asynchronous-safe function. This may result in undefined behavior. [cert-sig30-c]
+
+  signal(SIGINT, SIG_IGN);
+  signal(SIGINT, SIG_DFL);
+
+  // Do not find problems here.
+  signal(SIGINT, handler_bad, 1);
+}
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdlib.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdlib.h
@@ -0,0 +1,18 @@
+//===--- stdio.h - Stub header for tests *- 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 _STDLIB_H_
+#define _STDLIB_H_
+
+void abort(void);
+void _Exit(int __status);
+void quick_exit(int __status);
+
+void other_call(int);
+
+#endif // _STDLIB_H_
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/signal.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/signal.h
@@ -0,0 +1,22 @@
+//===--- stdio.h - Stub header for tests *- 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 _SIGNAL_H_
+#define _SIGNAL_H_
+
+void _sig_ign(int);
+void _sig_dfl(int);
+
+#define SIGINT 1
+#define SIG_IGN _sig_ign
+#define SIG_DFL _sig_dfl
+
+typedef void (*sighandler_t)(int);
+sighandler_t signal(int signum, sighandler_t handler);
+
+#endif // _SIGNAL_H_
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extr

[PATCH] D87374: [SyntaxTree] Specialize `TreeTestBase` for `BuildTreeTest` and `MutationsTest`

2020-09-10 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 290951.
eduucaldas marked 3 inline comments as done.
eduucaldas added a comment.

- `MutationsTest`: Split tests and infrastructure
- `SynthesisTest`: Split tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87374

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/MutationsTest.cpp
  clang/unittests/Tooling/Syntax/SynthesisTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.h

Index: clang/unittests/Tooling/Syntax/TreeTestBase.h
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -32,11 +32,6 @@
   TranslationUnit *buildTree(StringRef Code,
  const TestClangConfig &ClangConfig);
 
-  ::testing::AssertionResult treeDumpEqual(StringRef Code, StringRef Tree);
-
-  ::testing::AssertionResult
-  treeDumpEqualOnAnnotations(StringRef CodeWithAnnotations,
- ArrayRef TreeDumps);
   /// Finds the deepest node in the tree that covers exactly \p R.
   /// FIXME: implement this efficiently and move to public syntax tree API.
   syntax::Node *nodeByRange(llvm::Annotations::Range R, syntax::Node *Root);
@@ -56,6 +51,8 @@
   std::unique_ptr TB;
   std::unique_ptr Arena;
 };
+
+std::vector allTestClangConfigs();
 } // namespace syntax
 } // namespace clang
 #endif // LLVM_CLANG_UNITTESTS_TOOLING_SYNTAX_TREETESTBASE_H
Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -43,8 +43,9 @@
   return llvm::makeArrayRef(T->firstLeaf()->token(),
 T->lastLeaf()->token() + 1);
 }
+} // namespace
 
-std::vector allTestClangConfigs() {
+std::vector clang::syntax::allTestClangConfigs() {
   std::vector all_configs;
   for (TestLanguage lang : {Lang_C89, Lang_C99, Lang_CXX03, Lang_CXX11,
 Lang_CXX14, Lang_CXX17, Lang_CXX20}) {
@@ -61,10 +62,6 @@
   return all_configs;
 }
 
-INSTANTIATE_TEST_CASE_P(SyntaxTreeTests, SyntaxTreeTest,
-testing::ValuesIn(allTestClangConfigs()), );
-} // namespace
-
 syntax::TranslationUnit *
 SyntaxTreeTest::buildTree(StringRef Code, const TestClangConfig &ClangConfig) {
   // FIXME: this code is almost the identical to the one in TokensTest. Share
@@ -161,62 +158,6 @@
   return Root;
 }
 
-::testing::AssertionResult SyntaxTreeTest::treeDumpEqual(StringRef Code,
- StringRef Tree) {
-  SCOPED_TRACE(llvm::join(GetParam().getCommandLineArgs(), " "));
-
-  auto *Root = buildTree(Code, GetParam());
-  if (Diags->getClient()->getNumErrors() != 0) {
-return ::testing::AssertionFailure()
-   << "Source file has syntax errors, they were printed to the test "
-  "log";
-  }
-  auto Actual = StringRef(Root->dump(Arena->sourceManager())).trim().str();
-  // EXPECT_EQ shows the diff between the two strings if they are different.
-  EXPECT_EQ(Tree.trim().str(), Actual);
-  if (Actual != Tree.trim().str()) {
-return ::testing::AssertionFailure();
-  }
-  return ::testing::AssertionSuccess();
-}
-
-::testing::AssertionResult
-SyntaxTreeTest::treeDumpEqualOnAnnotations(StringRef CodeWithAnnotations,
-   ArrayRef TreeDumps) {
-  SCOPED_TRACE(llvm::join(GetParam().getCommandLineArgs(), " "));
-
-  auto AnnotatedCode = llvm::Annotations(CodeWithAnnotations);
-  auto *Root = buildTree(AnnotatedCode.code(), GetParam());
-
-  if (Diags->getClient()->getNumErrors() != 0) {
-return ::testing::AssertionFailure()
-   << "Source file has syntax errors, they were printed to the test "
-  "log";
-  }
-
-  auto AnnotatedRanges = AnnotatedCode.ranges();
-  if (AnnotatedRanges.size() != TreeDumps.size()) {
-return ::testing::AssertionFailure()
-   << "The number of annotated ranges in the source code is different "
-  "to the number of their corresponding tree dumps.";
-  }
-  bool Failed = false;
-  for (unsigned i = 0; i < AnnotatedRanges.size(); i++) {
-auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root);
-assert(AnnotatedNode);
-auto AnnotatedNodeDump =
-StringRef(AnnotatedNode->dump(Arena->sourceManager())).trim().str();
-// EXPECT_EQ shows the diff between the two strings if they are different.
-EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump)
-<< "Dumps diverged for the code:\n"
-<< AnnotatedCode.code().slice(AnnotatedRanges[i].Begin,
-  AnnotatedRanges[i].End);
-if (AnnotatedNode

[PATCH] D87374: [SyntaxTree] Specialize `TreeTestBase` for `BuildTreeTest` and `MutationsTest`

2020-09-10 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 290952.
eduucaldas added a comment.

nit 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87374

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/MutationsTest.cpp
  clang/unittests/Tooling/Syntax/SynthesisTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.h

Index: clang/unittests/Tooling/Syntax/TreeTestBase.h
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -32,11 +32,6 @@
   TranslationUnit *buildTree(StringRef Code,
  const TestClangConfig &ClangConfig);
 
-  ::testing::AssertionResult treeDumpEqual(StringRef Code, StringRef Tree);
-
-  ::testing::AssertionResult
-  treeDumpEqualOnAnnotations(StringRef CodeWithAnnotations,
- ArrayRef TreeDumps);
   /// Finds the deepest node in the tree that covers exactly \p R.
   /// FIXME: implement this efficiently and move to public syntax tree API.
   syntax::Node *nodeByRange(llvm::Annotations::Range R, syntax::Node *Root);
@@ -56,6 +51,8 @@
   std::unique_ptr TB;
   std::unique_ptr Arena;
 };
+
+std::vector allTestClangConfigs();
 } // namespace syntax
 } // namespace clang
 #endif // LLVM_CLANG_UNITTESTS_TOOLING_SYNTAX_TREETESTBASE_H
Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -43,8 +43,9 @@
   return llvm::makeArrayRef(T->firstLeaf()->token(),
 T->lastLeaf()->token() + 1);
 }
+} // namespace
 
-std::vector allTestClangConfigs() {
+std::vector clang::syntax::allTestClangConfigs() {
   std::vector all_configs;
   for (TestLanguage lang : {Lang_C89, Lang_C99, Lang_CXX03, Lang_CXX11,
 Lang_CXX14, Lang_CXX17, Lang_CXX20}) {
@@ -61,10 +62,6 @@
   return all_configs;
 }
 
-INSTANTIATE_TEST_CASE_P(SyntaxTreeTests, SyntaxTreeTest,
-testing::ValuesIn(allTestClangConfigs()), );
-} // namespace
-
 syntax::TranslationUnit *
 SyntaxTreeTest::buildTree(StringRef Code, const TestClangConfig &ClangConfig) {
   // FIXME: this code is almost the identical to the one in TokensTest. Share
@@ -161,62 +158,6 @@
   return Root;
 }
 
-::testing::AssertionResult SyntaxTreeTest::treeDumpEqual(StringRef Code,
- StringRef Tree) {
-  SCOPED_TRACE(llvm::join(GetParam().getCommandLineArgs(), " "));
-
-  auto *Root = buildTree(Code, GetParam());
-  if (Diags->getClient()->getNumErrors() != 0) {
-return ::testing::AssertionFailure()
-   << "Source file has syntax errors, they were printed to the test "
-  "log";
-  }
-  auto Actual = StringRef(Root->dump(Arena->sourceManager())).trim().str();
-  // EXPECT_EQ shows the diff between the two strings if they are different.
-  EXPECT_EQ(Tree.trim().str(), Actual);
-  if (Actual != Tree.trim().str()) {
-return ::testing::AssertionFailure();
-  }
-  return ::testing::AssertionSuccess();
-}
-
-::testing::AssertionResult
-SyntaxTreeTest::treeDumpEqualOnAnnotations(StringRef CodeWithAnnotations,
-   ArrayRef TreeDumps) {
-  SCOPED_TRACE(llvm::join(GetParam().getCommandLineArgs(), " "));
-
-  auto AnnotatedCode = llvm::Annotations(CodeWithAnnotations);
-  auto *Root = buildTree(AnnotatedCode.code(), GetParam());
-
-  if (Diags->getClient()->getNumErrors() != 0) {
-return ::testing::AssertionFailure()
-   << "Source file has syntax errors, they were printed to the test "
-  "log";
-  }
-
-  auto AnnotatedRanges = AnnotatedCode.ranges();
-  if (AnnotatedRanges.size() != TreeDumps.size()) {
-return ::testing::AssertionFailure()
-   << "The number of annotated ranges in the source code is different "
-  "to the number of their corresponding tree dumps.";
-  }
-  bool Failed = false;
-  for (unsigned i = 0; i < AnnotatedRanges.size(); i++) {
-auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root);
-assert(AnnotatedNode);
-auto AnnotatedNodeDump =
-StringRef(AnnotatedNode->dump(Arena->sourceManager())).trim().str();
-// EXPECT_EQ shows the diff between the two strings if they are different.
-EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump)
-<< "Dumps diverged for the code:\n"
-<< AnnotatedCode.code().slice(AnnotatedRanges[i].Begin,
-  AnnotatedRanges[i].End);
-if (AnnotatedNodeDump != TreeDumps[i].trim().

[PATCH] D87450: [clangd] Implement hot index reloading for clangd-index-server

2020-09-10 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous.
Herald added a project: clang.
kbobyrev requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

This patch adds a mechanism to load new versions of index into
clangd-index-server using SwapIndex and FileStatus information about last
modification time without downtime.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87450

Files:
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -14,13 +14,18 @@
 #include "support/Logger.h"
 #include "support/Trace.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
 
+#include 
 #include 
 #include 
+#include 
+#include 
 
 #include "Index.grpc.pb.h"
 
@@ -69,8 +74,7 @@
 
 class RemoteIndexServer final : public SymbolIndex::Service {
 public:
-  RemoteIndexServer(std::unique_ptr Index,
-llvm::StringRef IndexRoot)
+  RemoteIndexServer(clangd::SwapIndex *Index, llvm::StringRef IndexRoot)
   : Index(std::move(Index)) {
 llvm::SmallString<256> NativePath = IndexRoot;
 llvm::sys::path::native(NativePath);
@@ -79,6 +83,8 @@
 /*LocalIndexRoot=*/""));
   }
 
+  clangd::SwapIndex *Index;
+
 private:
   grpc::Status Lookup(grpc::ServerContext *Context,
   const LookupRequest *Request,
@@ -210,21 +216,52 @@
 return grpc::Status::OK;
   }
 
-  std::unique_ptr Index;
   std::unique_ptr ProtobufMarshaller;
 };
 
-void runServer(std::unique_ptr Index,
-   const std::string &ServerAddress) {
-  RemoteIndexServer Service(std::move(Index), IndexRoot);
+// Detect changes in \p IndexPath file and load new versions of the index
+// whenever they become available.
+void hotReload(clangd::SwapIndex **Index, llvm::StringRef IndexPath) {
+  llvm::sys::TimePoint<> LastModificationTime =
+  std::chrono::system_clock::now();
+  for (;; std::this_thread::sleep_for(std::chrono::seconds(90))) {
+llvm::sys::fs::file_status Status;
+const auto EC = llvm::sys::fs::status(IndexPath, Status, /*Follow=*/true);
+if (EC)
+  continue;
+const auto NewModificationTime = Status.getLastModificationTime();
+// Current index is newer than the one before: no reload is needed.
+if (NewModificationTime <= LastModificationTime)
+  continue;
+vlog("Found new index version: existing index was modified at {0}, new "
+ "index was modified at {1}. Attempting to reload.",
+ LastModificationTime, NewModificationTime);
+std::unique_ptr NewIndex = openIndex(IndexPath);
+if (!NewIndex) {
+  vlog("Failed to load new index. Old index will be served.");
+  continue;
+}
+(*Index)->reset(std::move(NewIndex));
+log("New index version loaded. Last modification time: {0}.",
+NewModificationTime);
+LastModificationTime = NewModificationTime;
+  }
+}
+
+void runServer(std::unique_ptr Index,
+   llvm::StringRef ServerAddress, llvm::StringRef IndexPath) {
+  RemoteIndexServer Service(Index.get(), IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
   grpc::ServerBuilder Builder;
-  Builder.AddListeningPort(ServerAddress, grpc::InsecureServerCredentials());
+  Builder.AddListeningPort(ServerAddress.str(),
+   grpc::InsecureServerCredentials());
   Builder.RegisterService(&Service);
   std::unique_ptr Server(Builder.BuildAndStart());
   log("Server listening on {0}", ServerAddress);
 
+  std::thread HotReloadThread(hotReload, &Service.Index, IndexPath);
+
   Server->Wait();
 }
 
@@ -273,12 +310,13 @@
   if (Tracer)
 TracingSession.emplace(*Tracer);
 
-  std::unique_ptr Index = openIndex(IndexPath);
+  std::unique_ptr Index(
+  new clang::clangd::SwapIndex(openIndex(IndexPath)));
 
   if (!Index) {
 llvm::errs() << "Failed to open the index.\n";
 return -1;
   }
 
-  runServer(std::move(Index), ServerAddress);
+  runServer(std::move(Index), ServerAddress, IndexPath);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] ebf496d - Revert "[clang-tidy] New check readability-prefer-member-initializer"

2020-09-10 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2020-09-10T16:32:18+03:00
New Revision: ebf496d805521b53022a351f35854de977fee844

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

LOG: Revert "[clang-tidy] New check readability-prefer-member-initializer"

Either contains unbounded loops, or has *very* high runtime,
100+x of all the current clang-tidy checks.

This reverts commit f5fd7486d6c0debb465de3e927fcc31884874280.

Added: 


Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 

clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.h

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-member-initializer.rst

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-modernize-use-default-member-init-assignment.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-modernize-use-default-member-init.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp



diff  --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
index a9f5b3e0c15b..39c2c552eb73 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
@@ -13,7 +13,6 @@ add_clang_library(clangTidyCppCoreGuidelinesModule
   NarrowingConversionsCheck.cpp
   NoMallocCheck.cpp
   OwningMemoryCheck.cpp
-  PreferMemberInitializerCheck.cpp
   ProBoundsArrayToPointerDecayCheck.cpp
   ProBoundsConstantArrayIndexCheck.cpp
   ProBoundsPointerArithmeticCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
index bf613109f0eb..4cb5022888d3 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
@@ -22,7 +22,6 @@
 #include "NarrowingConversionsCheck.h"
 #include "NoMallocCheck.h"
 #include "OwningMemoryCheck.h"
-#include "PreferMemberInitializerCheck.h"
 #include "ProBoundsArrayToPointerDecayCheck.h"
 #include "ProBoundsConstantArrayIndexCheck.h"
 #include "ProBoundsPointerArithmeticCheck.h"
@@ -67,8 +66,6 @@ class CppCoreGuidelinesModule : public ClangTidyModule {
 "cppcoreguidelines-non-private-member-variables-in-classes");
 CheckFactories.registerCheck(
 "cppcoreguidelines-owning-memory");
-CheckFactories.registerCheck(
-"cppcoreguidelines-prefer-member-initializer");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-bounds-array-to-pointer-decay");
 CheckFactories.registerCheck(

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
deleted file mode 100644
index 97ae586f9fdb..
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-//===--- PreferMemberInitializerCheck.cpp - clang-tidy ---===//
-//
-// 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 "PreferMemberInitializerCheck.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Lex/Lexer.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace cppcoreguidelines {
-
-static bool isControlStatement(const Stmt *S) {
-  return isa(S) || isa(S) || isa(S) ||
- isa(S) || isa(S) || isa(S) ||
- isa(S) || isa(S) || isa(S);
-}
-
-static bool isNoReturnCallStatement(const Stmt *S) {
-  const auto *Call = dyn_cast(S);
-  if (!Call)
-return false;
-
-  const FunctionDecl *Func = Call->getDirectCallee();
-  if (!Func)
-return false;
-
-  return Func->isNoReturn();
-}
-
-static bool isLiteral(const Expr *E) {
-  return isa(E) || isa(E) ||
- isa(E) || isa(E) ||
- isa(E) || isa(E);
-}
-
-static bool isUnaryExprOfLiteral(const Expr *E) {
-  if (const auto *UnOp = dyn_cast(E))
-return isLiteral(UnOp->getSubExpr());
-  

[PATCH] D71199: [clang-tidy] New check cppcoreguidelines-prefer-member-initializer

2020-09-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri reopened this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

So i've just reverted this.

@aaron.ballman @baloghadamsoftware how's QC going on nowadays here?
Was this evaluated on anything other than it's tests?

It appears to be either unacceptably slow, or subtly broken, because it takes 
at least 100x time more than all of the other clang-tidy checks enabled, and 
e.g.
`clang-tidy-12 --checks="-*,cppcoreguidelines-prefer-member-initializer" -p . 
/repositories/llvm-project/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp`
never finishes (minutes and counting).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71199

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


[PATCH] D87451: add new clang option -fnovisibility.

2020-09-10 Thread Digger via Phabricator via cfe-commits
DiggerLin created this revision.
DiggerLin added reviewers: hubert.reinterpretcast, jasonliu, daltenty.
Herald added subscribers: cfe-commits, dang, steven.zhang.
Herald added a project: clang.
DiggerLin requested review of this revision.

In IBM compiler Xlclang , there is option -fnovisibiilty. The option is 
description as

  
https://www.ibm.com/support/knowledgecenter/SSGH3R_16.1.0/com.ibm.xlcpp161.aix.doc/compiler_ref/opt_visibility.html
 
   
  we need to add the option -fnovisibiilty for clang in the IBM AIX OS(and the 
option is enabled by default in AIX OS).  
  I will implement the option in the other OS platform.(but the option is 
disabled by default in other OS).
   
  For example, the file test.c
   

bash-4.2$ test.c
 __attribute__((visibility ("protected"))) int b;

1 In AIX OS:

1.1 Compiled with

  clang -fnovisibility-target powerpc-unknown-aix  -emit-llvm  -S test.c

or

  clang -target powerpc-unknown-aix  -emit-llvm  -S test.c  ( the 
-fnovisibility is enabled by default in AIX OS)

Generate IR as :

  @b = global i32 0, align 4
   

1.2 Compiled with

  (If have "-fnovisibility  -fvisibility=*" at the same time.  the compile will 
ignore the -fnovisibility). 
   
  clang -fnovisibility  -fvisibility=default   -target powerpc-unknown-aix   
-emit-llvm  -S test.c

Or

  clang -fvisibility=default   -target powerpc-unknown-aix   -emit-llvm  -S 
test.c
   
  Generate IR as :
  @b = protected global i32 0, align 4
   

2. In Other OS(not AIX) 2.1 clang -fnovisibility-target 
powerpc-unknown-linux  -emit-llvm  -S test.c

  Generate IR as : @b = global i32 0, align 4

  2.2 clang -target powerpc-unknown-linux  -emit-llvm  -S test.c ( the 
-fnovisibility is disabled by default in not AIX OS) Or (if have 
"-fnovisibility  -fvisibility=*" at the same time.  the compile will ignore the 
-fnovisibility). clang -fnovisibility  -fvisibility=default   -target 
powerpc-unknown-linux   -emit-llvm  -S test.c Or clang -fvisibility=default   
-target powerpc-unknown-linux   -emit-llvm  -S test.c

  Generate IR as : @b = protected global i32 0, align 4


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87451

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Decl.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fnovisibility.cpp

Index: clang/test/Driver/fnovisibility.cpp
===
--- /dev/null
+++ clang/test/Driver/fnovisibility.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang-target powerpc-unknown-aix  -emit-llvm  -o - -S  %s  |\
+// RUN:   FileCheck --check-prefixes=NOVISIBILITY,AIX-NOVISIBILITY %s
+
+// RUN: %clang -fnovisibility -target powerpc-unknown-aix  -emit-llvm -o -  -S %s  | \
+// RUN: FileCheck -check-prefixes=NOVISIBILITY,AIX-NOVISIBILITY %s
+
+// RUN: %clang -fnovisibility -target powerpc-unknown-linux  -emit-llvm -o - -S %s  | \
+// RUN: FileCheck -check-prefixes=NOVISIBILITY,LINUX-NOVISIBILITY %s
+
+// RUN: %clang -fnovisibility -fvisibility=default -target powerpc-unknown-aix  -emit-llvm  -o - -S %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY %s
+
+// RUN: %clang -target powerpc-unknown-linux  -emit-llvm  -o - -S %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY %s
+
+// RUN: %clang -fnovisibility -fvisibility=default -target powerpc-unknown-linux  -emit-llvm -o - -S %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY %s
+
+__attribute__((visibility("hidden"))) void foo_h(int *p) {
+  (*p)++;
+}
+
+__attribute__((visibility("protected"))) int b;
+
+extern __attribute__((visibility("hidden"))) void zoo_extern_h(void);
+
+void (*foo_p)(void) = zoo_extern_h;
+
+__attribute__((visibility("protected"))) void bar() {
+  foo_h(&b);
+  foo_p();
+}
+
+class TestClass {
+public:
+  __attribute__((__visibility__("hidden"))) int value() const noexcept { return 0; }
+};
+
+int main() {
+  TestClass TC;
+  return TC.value();
+}
+
+template 
+class basic {
+public:
+  __attribute__((__visibility__("protected"))) int getdata() { return 1; }
+};
+
+template class basic;
+
+// AIX-NOVISIBILITY:@b = global i32 0
+// LINUX-NOVISIBILITY:  @b = dso_local global i32 0
+// AIX-NOVISIBILITY:define void @_Z5foo_hPi(i32* %p)
+// LINUX-NOVISIBILITY:  define dso_local void @_Z5foo_hPi(i32* %p)
+// NOVISIBILITY:declare void @_Z12zoo_extern_hv()
+// AIX-NOVISIBILITY:define void @_Z3barv()
+// LINUX-NOVISIBILITY:  define dso_local void @_Z3barv()
+// AIX-NOVISIBILITY:define linkonce_odr i32 @_ZNK9TestClass5valueEv(%class.TestClass* %this)
+// LINUX-NOVISIBILITY:  define linkonce_odr dso_local i32 @_ZNK9TestClass5valueEv(%class.TestClass* %this)
+// AIX-NOVISIBILITY:define weak_odr i32 @_ZN5basicIiE7getdataEv(%class.basic* %this)
+// LINUX-NOVISIBILITY:  define weak_odr dso_local i32 @_ZN5basicIiE7getdataEv(%class.basic* %this)
+
+// VISIBILITY:@b 

[PATCH] D87449: [clang-tidy] Add new check for SEI CERT rule SIG30-C.

2020-09-10 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please add entry in Release Notes.




Comment at: clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.cpp:26
+namespace {
+constexpr StringRef SignalFun = "signal";
+constexpr StringRef AbortFun = "abort";

Only type definitions should be in anonymous namespace.  Everything else must 
be `static`.



Comment at: clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.cpp:142
+} // namespace clang
\ No newline at end of file


Please add newline.



Comment at: clang-tools-extra/clang-tidy/cert/SignalHandlerCheck.h:35
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_SIGNALHANDLERCHECK_H
\ No newline at end of file


Please add newline.



Comment at: clang-tools-extra/docs/clang-tidy/checks/cert-sig30-c.rst:6
+
+This check finds functions registered as signal handlers that call non 
asynchronous-safe functions.
+User functions called from the handlers are checked too, as far as possible.

Please remove `This check`.



Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:15
 
-   `abseil-duration-addition `_, "Yes"
-   `abseil-duration-comparison `_, "Yes"
-   `abseil-duration-conversion-cast `_, 
"Yes"
-   `abseil-duration-division `_, "Yes"
-   `abseil-duration-factory-float `_, "Yes"
-   `abseil-duration-factory-scale `_, "Yes"
-   `abseil-duration-subtraction `_, "Yes"
-   `abseil-duration-unnecessary-conversion 
`_, "Yes"
-   `abseil-faster-strsplit-delimiter 
`_, "Yes"
+   `abseil-duration-addition `_,
+   `abseil-duration-comparison `_,

A lot of unrelated changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87449

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


[PATCH] D87451: add new clang option -fnovisibility.

2020-09-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Bad commit message - links will go dead eventually, all the relevant stuff 
needs to be specified in the commit message itself.




Comment at: clang/docs/ClangCommandLineReference.rst:2310-2320
 .. option:: -fvisibility-ms-compat
 
+Ignore all the visibility attributes in source code
+
+.. option:: -fnovisibility
+
 Give global types 'default' visibility and global functions and variables 
'hidden' visibility by default




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87451

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


[PATCH] D71199: [clang-tidy] New check cppcoreguidelines-prefer-member-initializer

2020-09-10 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D71199#2265594 , @lebedev.ri wrote:

> So i've just reverted this in rGebf496d805521b53022a351f35854de977fee844 
> .
>
> @aaron.ballman @baloghadamsoftware how's QC going on nowadays here?
> Was this evaluated on anything other than it's tests?

Surely. After I commit a patch, lots of buildbots verify it. They passed so far.

> It appears to be either unacceptably slow, or subtly broken, because it takes 
> at least 100x time more than all of the other clang-tidy checks enabled, and 
> e.g.
> `clang-tidy-12 --checks="-*,cppcoreguidelines-prefer-member-initializer" -p . 
> /repositories/llvm-project/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp`
> never finishes (minutes and counting).

I see nothing there that could be slow, thus this is probably some hang. I will 
investigate it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71199

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


[PATCH] D71199: [clang-tidy] New check cppcoreguidelines-prefer-member-initializer

2020-09-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D71199#2265692 , 
@baloghadamsoftware wrote:

> In D71199#2265594 , @lebedev.ri 
> wrote:
>
>> So i've just reverted this in rGebf496d805521b53022a351f35854de977fee844 
>> .
>>
>> @aaron.ballman @baloghadamsoftware how's QC going on nowadays here?
>> Was this evaluated on anything other than it's tests?
>
> Surely. After I commit a patch, lots of buildbots verify it. They passed so 
> far.

@baloghadamsoftware, i think you understand that wasn't the question.

>> It appears to be either unacceptably slow, or subtly broken, because it 
>> takes at least 100x time more than all of the other clang-tidy checks 
>> enabled, and e.g.
>> `clang-tidy-12 --checks="-*,cppcoreguidelines-prefer-member-initializer" -p 
>> . 
>> /repositories/llvm-project/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp`
>> never finishes (minutes and counting).
>
> I see nothing there that could be slow, thus this is probably some hang. I 
> will investigate it.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71199

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


[PATCH] D85424: [Analyzer] Crash fix for alpha.cplusplus.IteratorRange

2020-09-10 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 290967.
baloghadamsoftware added a comment.

Test added. Thank you for the test @steakhal!


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

https://reviews.llvm.org/D85424

Files:
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/test/Analysis/iterator-range.cpp


Index: clang/test/Analysis/iterator-range.cpp
===
--- clang/test/Analysis/iterator-range.cpp
+++ clang/test/Analysis/iterator-range.cpp
@@ -939,3 +939,9 @@
   auto i0 = c.begin(), i1 = c.end();
   ptrdiff_t len = i1 - i0; // no-crash
 }
+
+int uninit_var(int n) {
+  int uninit; // expected-note{{'uninit' declared without an initial value}}
+  return n - uninit; // expected-warning{{The right operand of '-' is a 
garbage value}}
+ // expected-note@-1{{The right operand of '-' is a 
garbage value}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
@@ -228,7 +228,8 @@
 Value = State->getRawSVal(*ValAsLoc);
   }
 
-  if (Value.isUnknown())
+  if (Value.isUnknownOrUndef())
+//  if (Value.isUnknownOrUndef())
 return;
 
   // Incremention or decremention by 0 is never a bug.


Index: clang/test/Analysis/iterator-range.cpp
===
--- clang/test/Analysis/iterator-range.cpp
+++ clang/test/Analysis/iterator-range.cpp
@@ -939,3 +939,9 @@
   auto i0 = c.begin(), i1 = c.end();
   ptrdiff_t len = i1 - i0; // no-crash
 }
+
+int uninit_var(int n) {
+  int uninit; // expected-note{{'uninit' declared without an initial value}}
+  return n - uninit; // expected-warning{{The right operand of '-' is a garbage value}}
+ // expected-note@-1{{The right operand of '-' is a garbage value}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
@@ -228,7 +228,8 @@
 Value = State->getRawSVal(*ValAsLoc);
   }
 
-  if (Value.isUnknown())
+  if (Value.isUnknownOrUndef())
+//  if (Value.isUnknownOrUndef())
 return;
 
   // Incremention or decremention by 0 is never a bug.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85424: [Analyzer] Crash fix for alpha.cplusplus.IteratorRange

2020-09-10 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D85424#2258886 , @steakhal wrote:

> void foo(int x) {
>
>   int uninit;
>   x - uninit; // will-crash
>
> }

This is not even related to the iterators. We could check first whether `LHS` 
is an iterator and early exit if not. However, that does not help, the checker 
crashes if we try to add or subtract an unitialized value to/from an iterator.


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

https://reviews.llvm.org/D85424

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


[PATCH] D71199: [clang-tidy] New check cppcoreguidelines-prefer-member-initializer

2020-09-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D71199#2265693 , @lebedev.ri wrote:

> In D71199#2265692 , 
> @baloghadamsoftware wrote:
>
>> In D71199#2265594 , @lebedev.ri 
>> wrote:
>>
>>> So i've just reverted this in rGebf496d805521b53022a351f35854de977fee844 
>>> .
>>>
>>> @aaron.ballman @baloghadamsoftware how's QC going on nowadays here?
>>> Was this evaluated on anything other than it's tests?
>>
>> Surely. After I commit a patch, lots of buildbots verify it. They passed so 
>> far.
>
> @baloghadamsoftware, i think you understand that wasn't the question.

This feedback is a bit terse and not very constructive. FWIW, we don't 
typically ask patch authors to run their patch over a large corpus of code 
unless a reviewer expects there to be a performance concern and asks 
explicitly. Given that this checks constructor bodies, there was no obvious 
reason to ask for that here. Also, I can't recall a time when we expected a 
patch reviewer to do that work. I appreciate that you noticed an issue and 
reverted so we could investigate, but when reporting an issue like this, please 
try to keep in mind that we're all in the same community trying to make a great 
product.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71199

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


[PATCH] D86819: [PowerPC][Power10] Implementation of 128-bit Binary Vector Rotate builtins

2020-09-10 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added inline comments.



Comment at: clang/lib/Headers/altivec.h:7743
+  return __builtin_altivec_vrlqnm(__a, ((__c << ShiftMask) |
+(__b << ShiftRotation)));
+}

While correct, this implementation will require two constant pool loads (for 
the two shift amounts), then two `vrlq`'s to shift the two vectors and finally 
an `xxlor` to OR them together. We should be able to do this with a single 
constant pool load and `vperm`.
Presumably the implementation would be something like:
```
  // Merge __b and __c using an appropriate shuffle.
  vector unsigned char TmpB = (vector unsigned char)__b;
  vector unsigned char TmpC = (vector unsigned char)__c;
  vector unsigned char MaskAndShift =
#ifdef __LITTLE_ENDIAN__
  __builtin_shufflevector(TmpB, TmpC, -1, -1, -1, -1, -1, -1, -1, -1, 16, 1,
  0, -1, -1, -1, -1, -1);
#else
  __builtin_shufflevector(TmpB, TmpC, -1, -1, -1, -1, -1, 30, 31, 15, -1,
  -1, -1, -1, -1, -1, -1, -1);
#endif
  return __builtin_altivec_vrlqnm(__a, MaskAndShift);
```
(but of course, double-check that the numbers are correct).



Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:996
+  // CHECK-COMMON-LABEL: @test_vec_rlnm_s128(
+  // CHECK-COMMON: call <1 x i128> @llvm.ppc.altivec.vrlqnm(<1 x i128>
+  // CHECK-COMMON-NEXT: ret <1 x i128>

Please show the shift in the test case as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86819

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


[clang-tools-extra] 33c9dbb - Add an explicit toggle for the static analyzer in clang-tidy

2020-09-10 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-09-10T10:48:17-04:00
New Revision: 33c9dbbd380913e8ab7e5a8e82468f9f7d092187

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

LOG: Add an explicit toggle for the static analyzer in clang-tidy

Instead of using CLANG_ENABLE_STATIC_ANALYZER for use of the
static analyzer in both clang and clang-tidy, add a second
toggle CLANG_TIDY_ENABLE_STATIC_ANALYZER.

This allows enabling the static analyzer in clang-tidy while
disabling it in clang.

Differential Revison: https://reviews.llvm.org/D87118

Added: 
clang-tools-extra/clang-tidy/clang-tidy-config.h.cmake
llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/enable.gni

Modified: 
clang-tools-extra/CMakeLists.txt
clang-tools-extra/clang-tidy/CMakeLists.txt
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
clang-tools-extra/docs/clang-tidy/Contributing.rst
clang-tools-extra/test/CMakeLists.txt
clang-tools-extra/test/lit.cfg.py
clang-tools-extra/test/lit.site.cfg.py.in
clang/CMakeLists.txt
clang/cmake/caches/Android.cmake
clang/lib/CMakeLists.txt
llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/BUILD.gn
llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/tool/BUILD.gn
llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn

Removed: 




diff  --git a/clang-tools-extra/CMakeLists.txt 
b/clang-tools-extra/CMakeLists.txt
index 57bb97057560..2e73b6ba81d2 100644
--- a/clang-tools-extra/CMakeLists.txt
+++ b/clang-tools-extra/CMakeLists.txt
@@ -1,5 +1,8 @@
 include(CMakeDependentOption)
 
+option(CLANG_TIDY_ENABLE_STATIC_ANALYZER
+  "Include static analyzer checks in clang-tidy" ON)
+
 add_subdirectory(clang-apply-replacements)
 add_subdirectory(clang-reorder-fields)
 add_subdirectory(modularize)

diff  --git a/clang-tools-extra/clang-tidy/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/CMakeLists.txt
index 923976197ebe..ca7a5afed6b0 100644
--- a/clang-tools-extra/clang-tidy/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/CMakeLists.txt
@@ -3,6 +3,11 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
+configure_file(
+  ${CMAKE_CURRENT_SOURCE_DIR}/clang-tidy-config.h.cmake
+  ${CMAKE_CURRENT_BINARY_DIR}/clang-tidy-config.h)
+include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
+
 add_clang_library(clangTidy
   ClangTidy.cpp
   ClangTidyCheck.cpp
@@ -34,7 +39,7 @@ clang_target_link_libraries(clangTidy
   clangToolingCore
   )
 
-if(CLANG_ENABLE_STATIC_ANALYZER)
+if(CLANG_TIDY_ENABLE_STATIC_ANALYZER)
   clang_target_link_libraries(clangTidy
 PRIVATE
 clangStaticAnalyzerCore
@@ -60,7 +65,7 @@ add_subdirectory(llvm)
 add_subdirectory(llvmlibc)
 add_subdirectory(misc)
 add_subdirectory(modernize)
-if(CLANG_ENABLE_STATIC_ANALYZER)
+if(CLANG_TIDY_ENABLE_STATIC_ANALYZER)
   add_subdirectory(mpi)
 endif()
 add_subdirectory(objc)
@@ -93,7 +98,7 @@ set(ALL_CLANG_TIDY_CHECKS
   clangTidyReadabilityModule
   clangTidyZirconModule
   )
-if(CLANG_ENABLE_STATIC_ANALYZER)
+if(CLANG_TIDY_ENABLE_STATIC_ANALYZER)
   list(APPEND ALL_CLANG_TIDY_CHECKS clangTidyMPIModule)
 endif()
 set(ALL_CLANG_TIDY_CHECKS ${ALL_CLANG_TIDY_CHECKS} PARENT_SCOPE)

diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 90b39347bc9a..1f94ab4977c2 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -20,11 +20,11 @@
 #include "ClangTidyModuleRegistry.h"
 #include "ClangTidyProfiling.h"
 #include "ExpandModularHeadersPPCallbacks.h"
+#include "clang-tidy-config.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Config/config.h"
 #include "clang/Format/Format.h"
 #include "clang/Frontend/ASTConsumers.h"
 #include "clang/Frontend/CompilerInstance.h"
@@ -47,10 +47,10 @@
 #include 
 #include 
 
-#if CLANG_ENABLE_STATIC_ANALYZER
+#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
 #include "clang/Analysis/PathDiagnostic.h"
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
-#endif // CLANG_ENABLE_STATIC_ANALYZER
+#endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
 
 using namespace clang::ast_matchers;
 using namespace clang::driver;
@@ -63,7 +63,7 @@ namespace clang {
 namespace tidy {
 
 namespace {
-#if CLANG_ENABLE_STATIC_ANALYZER
+#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
 static const char *AnalyzerCheckNamePrefix = "clang-analyzer-";
 
 class AnalyzerDiagnosticConsumer : public ento::PathDiagnosticConsumer {
@@ -95,7 +95,7 @@ class AnalyzerDiagnosticConsumer : public 
ento::PathDiagnosticConsumer {
 private:
   ClangTidyContext &Context;
 };
-#endif // CLANG_ENABLE_STATIC_ANALYZER
+#endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
 
 class E

[PATCH] D87358: [clang][aarch64] Fix ILP32 ABI for arm_sve_vector_bits

2020-09-10 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes updated this revision to Diff 290974.
c-rhodes edited the summary of this revision.
c-rhodes added a comment.

- Get the element type of scalable vectors from `getBuiltinVectorTypeInfo` when 
creating VLS types. This fixes the ABI issue since it calls 
`ASTContext::getIntTypeForBitwidth` which gets the correct type for a given 
target.
- Element type for `svfloat16_t` is changed from `Float16Ty` to `HalfTy` for 
VLS types since this is what’s used elsewhere.


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

https://reviews.llvm.org/D87358

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/attr-arm-sve-vector-bits-types.c


Index: clang/test/CodeGen/attr-arm-sve-vector-bits-types.c
===
--- clang/test/CodeGen/attr-arm-sve-vector-bits-types.c
+++ clang/test/CodeGen/attr-arm-sve-vector-bits-types.c
@@ -4,6 +4,7 @@
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -msve-vector-bits=512 -fallow-half-arguments-and-returns 
-S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-512
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -msve-vector-bits=1024 -fallow-half-arguments-and-returns 
-S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-1024
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -msve-vector-bits=2048 -fallow-half-arguments-and-returns 
-S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-2048
+// RUN: %clang_cc1 -triple aarch64_32-unknown-darwin -target-feature +sve 
-target-feature +bf16 -msve-vector-bits=512 -fallow-half-arguments-and-returns 
-S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-ILP32
 
 #include 
 
@@ -579,3 +580,11 @@
 // CHECK-2048-NEXT:  %local_arr_f64 = alloca [3 x <32 x double>], align 16
 // CHECK-2048-NEXT:  %local_arr_bf16 = alloca [3 x <128 x bfloat>], align 16
 // CHECK-2048-NEXT:  %local_arr_bool = alloca [3 x <32 x i8>], align 2
+
+//===--===//
+// ILP32 ABI
+//===--===//
+// CHECK-ILP32: @global_i32 = global <16 x i32> zeroinitializer, align 16
+// CHECK-ILP32: @global_i64 = global <8 x i64> zeroinitializer, align 16
+// CHECK-ILP32: @global_u32 = global <16 x i32> zeroinitializer, align 16
+// CHECK-ILP32: @global_u64 = global <8 x i64> zeroinitializer, align 16
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5627,7 +5627,7 @@
   ResType = llvm::ScalableVectorType::get(
   llvm::Type::getInt64Ty(getVMContext()), 2);
   break;
-case BuiltinType::Float16:
+case BuiltinType::Half:
   ResType = llvm::ScalableVectorType::get(
   llvm::Type::getHalfTy(getVMContext()), 8);
   break;
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2317,38 +2317,13 @@
   assert(isVLSTBuiltinType() && "unsupported type!");
 
   const BuiltinType *BTy = getAs();
-  switch (BTy->getKind()) {
-  default:
-llvm_unreachable("Unknown builtin SVE type!");
-  case BuiltinType::SveInt8:
-return Ctx.SignedCharTy;
-  case BuiltinType::SveUint8:
-  case BuiltinType::SveBool:
+  if (BTy->getKind() == BuiltinType::SveBool)
 // Represent predicates as i8 rather than i1 to avoid any layout issues.
 // The type is bitcasted to a scalable predicate type when casting between
 // scalable and fixed-length vectors.
-return Ctx.UnsignedCharTy;
-  case BuiltinType::SveInt16:
-return Ctx.ShortTy;
-  case BuiltinType::SveUint16:
-return Ctx.UnsignedShortTy;
-  case BuiltinType::SveInt32:
-return Ctx.IntTy;
-  case BuiltinType::SveUint32:
-return Ctx.UnsignedIntTy;
-  case BuiltinType::SveInt64:
-return Ctx.LongTy;
-  case BuiltinType::SveUint64:
-return Ctx.UnsignedLongTy;
-  case BuiltinType::SveFloat16:
-return Ctx.Float16Ty;
-  case BuiltinType::SveBFloat16:
-return Ctx.BFloat16Ty;
-  case BuiltinType::SveFloat32:
-return Ctx.FloatTy;
-  case BuiltinType::SveFloat64:
-return Ctx.DoubleTy;
-  }
+return Ctx.getIntTypeForBitwidth(8, /*Signed=*/0);
+  else
+return Ctx.getBuiltinVectorTypeInfo(BTy).ElementType;
 }
 
 bool QualType::isPODType(const ASTContext &Context) const {
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -3388,7 +3388,7 @@
   case BuiltinType::ULong:
 TypeName = "__SVUint64_t";
 break;
-  case BuiltinType::Float16:
+  case BuiltinType::Half:
 TypeName = "__SVFl

[PATCH] D87358: [clang][aarch64] Fix ILP32 ABI for arm_sve_vector_bits

2020-09-10 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: clang/lib/AST/Type.cpp:2339
   case BuiltinType::SveInt32:
-return Ctx.IntTy;
+return IsILP32 ? Ctx.LongTy : Ctx.IntTy;
   case BuiltinType::SveUint32:

efriedma wrote:
> sdesmalen wrote:
> > Rather than comparing with a specific triple, how about getting the 
> > information from `TargetInfo`, i.e.
> > 
> >   case BuiltinType::SveInt32:
> > Ctx.getTargetInfo().getLongWidth() == 32 ? Ctx.LongTy : Ctx.IntTy
> The type that actually corresponds to int64_t is TargetInfo::getInt64Type().  
> Not sure if you need that here.
I realised `ASTContext::getIntTypeForBitwidth` handles this and noticed 
`getBuiltinVectorTypeInfo` which Sander recently added makes use of it so I've 
updated it to use that instead for all types except predicates since we still 
need to represent them as i8.


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

https://reviews.llvm.org/D87358

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


[PATCH] D87455: Restrict UnnecessaryCopyInitialization check to variables initialized from methods/functions without arguments

2020-09-10 Thread Felix Berger via Phabricator via cfe-commits
flx created this revision.
flx added reviewers: alexfh, sbenza.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
flx requested review of this revision.

This restriction avoids cases where an alias is returned to an argument and 
which could lead to to a false positive change. Example:

  struct S {
S(const S&);
void modify();
  };
  
  const S& alias(const S& a) {
return a;
  }
  
  void f(S a) {
const S c = alias(a);
a.modify();
  }

Taking a const reference of the return value of alias would not be safe since a 
is modified.

Still allow methods and functions with default arguments if they are called 
with their default arguments.

A more involved alternative approach would be to inspect each argument passed 
to these functions for its constness, but this can get complex quickly.

As I'm writing this I'm realizing though that this precludes catching repeated 
protobuff messages:

  Message m;
  const auto field = m.repeated_field(0);

Maybe this approach should be refined to allowing functions and methods that 
take all parameters by value?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87455

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -6,6 +6,8 @@
   const ExpensiveToCopyType &reference() const;
   void nonConstMethod();
   bool constMethod() const;
+  const ExpensiveToCopyType &methodWithArg(const ExpensiveToCopyType &) const;
+  const ExpensiveToCopyType &methodWithDefaultArg(int arg = 0) const;
 };
 
 struct TrivialToCopyType {
@@ -23,6 +25,9 @@
 ExpensiveToCopyType global_expensive_to_copy_type;
 
 const ExpensiveToCopyType &ExpensiveTypeReference();
+const ExpensiveToCopyType &freeFunctionWithArg(const ExpensiveToCopyType &);
+const ExpensiveToCopyType &freeFunctionWithDefaultArg(
+const ExpensiveToCopyType *arg = nullptr);
 const TrivialToCopyType &TrivialTypeReference();
 
 void mutate(ExpensiveToCopyType &);
@@ -387,3 +392,38 @@
   for (const Element &E : Container()) {
   }
 }
+
+// This should not trigger the check as the argument could introduce an alias.
+void negativeInitializedFromMethodWithArg() {
+  ExpensiveToCopyType Orig;
+  const ExpensiveToCopyType Copy = Orig.methodWithArg(Orig);
+}
+
+// This should not trigger the check as the argument could introduce an alias.
+void negativeInitializedFromFreeFunctionWithArg() {
+  ExpensiveToCopyType Orig;
+  const ExpensiveToCopyType Copy = freeFunctionWithArg(Orig);
+}
+
+void positiveInitializedFromMethodWithDefaultArg() {
+  ExpensiveToCopyType Orig;
+  const ExpensiveToCopyType Copy = Orig.methodWithDefaultArg();
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'Copy'
+  // CHECK-FIXES: const ExpensiveToCopyType& Copy = Orig.methodWithDefaultArg();
+}
+
+void negativeInitializedFromMethodWithNonDefaultArg() {
+  ExpensiveToCopyType Orig;
+  const ExpensiveToCopyType Copy = Orig.methodWithDefaultArg(5);
+}
+
+void positiveInitializedFromFreeFunctionWithDefaultArg() {
+  const ExpensiveToCopyType Copy = freeFunctionWithDefaultArg();
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'Copy'
+  // CHECK-FIXES: const ExpensiveToCopyType& Copy = freeFunctionWithDefaultArg();
+}
+
+void negativeInitialzedFromFreeFunctionWithNonDefaultArg() {
+  ExpensiveToCopyType Orig;
+  const ExpensiveToCopyType Copy = freeFunctionWithDefaultArg(&Orig);
+}
Index: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h
===
--- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h
+++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h
@@ -36,6 +36,7 @@
 private:
   void handleCopyFromMethodReturn(const VarDecl &Var, const Stmt &BlockStmt,
   bool IssueFix, const VarDecl *ObjectArg,
+  const CallExpr *InitCallExpr,
   ASTContext &Context);
   void handleCopyFromLocalVar(const VarDecl &NewVar, const VarDecl &OldVar,
   const Stmt &BlockStmt, bool IssueFix,
Index: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitial

Re: Clang-Format, Clang-Tidy - Absolute Path to config files

2020-09-10 Thread Typz via cfe-commits
Hello,

I worked on adding a similar feature some time back :
https://reviews.llvm.org/D50147
It supports specifying styles by absolute file name as well as lookup of a
style by name in various locations (like ~/.local/share/clang-format or
/usr/share/clang-format), allowing to install styles on the machine and use
them similarly to "integrated" styles : e.g. reference them in BasedOnStyle
tag or specify them via the --style parameter...

Unfortunately there was no consensus on this approach, and I did not get
the time yet to finalize something that could be integrated. But as long as
you are ready to recompile clang-format, it should work fine.
Best regards,

-- 
Francois

On Thu, Sep 10, 2020 at 2:28 PM via cfe-commits 
wrote:

> Hi all,
>
>
>
>
>
> I have recently started to work with Clang-Format and Clang-Tidy tools as
> part of a methodology project in my company.
>
> We want to have a uniform style and format in the entire department and
> for that we want to use the two tools to automatically keep this in order.
> For this we need to be able to store the config files somewhere available
> for everybody and for any project.
>
>
>
> In my research, I did not find the possibility to give an Absolute Path to
> the config files of the tools.
>
>
>
> This is why I added the feature myself and recompiled the tools. Could
> some body help me with the integration of the feature in the community?
>
>
>
>
>
> Best regards,
>
> Cezar
> ___
> 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] D86465: [analyzer][solver] Redesign constraint ranges data structure

2020-09-10 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

Here is my five cents. I haven't done with the review yet. I'm gonna return to 
it a bit later.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:56
+  bool operator==(const Range &RHS) const { return Impl == RHS.Impl; }
+  bool operator!=(const Range &RHS) const { return !(*this == RHS); }
+

I'm not sure about optimizations but it seems like it could have less commands 
by omiting `this`.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:139
+/// @{
+RangeSet getSet(Range Origin);
+RangeSet getSet(const llvm::APSInt &From, const llvm::APSInt &To) {

IMO function's name should match to what it does. If it creates smth, so its 
name should starts with `create`. Even if all other functions have misleading 
names it doesn't mean we are delegated to ignore this fact.
My another suggestion is that `Set` is a common term to `RangeSet`. So I'd 
prefer to use `getRangeSet` instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


[clang-tools-extra] 29cecbc - Fix clangd build after 33c9dbbd380

2020-09-10 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-09-10T11:05:53-04:00
New Revision: 29cecbc5d6fe2ee36635d593171d59eab631639f

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

LOG: Fix clangd build after 33c9dbbd380

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt
llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index 639441e8130a..3a1a034ed17b 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -33,6 +33,8 @@ if(MSVC AND NOT CLANG_CL)
  set_source_files_properties(CompileCommands.cpp PROPERTIES COMPILE_FLAGS 
-wd4130) # disables C4130: logical operation on address of string constant
 endif()
 
+include_directories(BEFORE "${CMAKE_CURRENT_BINARY_DIR}/../clang-tidy")
+
 add_clang_library(clangDaemon
   AST.cpp
   ClangdLSPServer.cpp

diff  --git a/llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn 
b/llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
index 84d3f14bb2f2..7fa4cc8fd32c 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
@@ -27,6 +27,7 @@ static_library("clangd") {
 ":features",
 "//clang-tools-extra/clang-tidy",
 "//clang-tools-extra/clang-tidy:all-checks",
+"//clang-tools-extra/clang-tidy:clang-tidy-config",
 "//clang-tools-extra/clangd/support",
 "//clang/lib/AST",
 "//clang/lib/ASTMatchers",



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


[PATCH] D87451: add new clang option -fnovisibility.

2020-09-10 Thread Digger via Phabricator via cfe-commits
DiggerLin updated this revision to Diff 290978.
DiggerLin added a comment.

add a pragmas test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87451

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Decl.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fnovisibility.cpp

Index: clang/test/Driver/fnovisibility.cpp
===
--- /dev/null
+++ clang/test/Driver/fnovisibility.cpp
@@ -0,0 +1,81 @@
+// RUN: %clang-target powerpc-unknown-aix  -emit-llvm  -o - -S  %s  |\
+// RUN:   FileCheck --check-prefixes=NOVISIBILITY,AIX-NOVISIBILITY %s
+
+// RUN: %clang -fnovisibility -target powerpc-unknown-aix  -emit-llvm -o -  -S %s  | \
+// RUN: FileCheck -check-prefixes=NOVISIBILITY,AIX-NOVISIBILITY %s
+
+// RUN: %clang -fnovisibility -target powerpc-unknown-linux  -emit-llvm -o - -S %s  | \
+// RUN: FileCheck -check-prefixes=NOVISIBILITY,LINUX-NOVISIBILITY %s
+
+// RUN: %clang -fnovisibility -fvisibility=default -target powerpc-unknown-aix  -emit-llvm  -o - -S %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY %s
+
+// RUN: %clang -target powerpc-unknown-linux  -emit-llvm  -o - -S %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY %s
+
+// RUN: %clang -fnovisibility -fvisibility=default -target powerpc-unknown-linux  -emit-llvm -o - -S %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY %s
+
+__attribute__((visibility("hidden"))) void foo_h(int *p) {
+  (*p)++;
+}
+
+__attribute__((visibility("protected"))) int b;
+
+extern __attribute__((visibility("hidden"))) void zoo_extern_h(void);
+
+void (*foo_p)(void) = zoo_extern_h;
+
+__attribute__((visibility("protected"))) void bar() {
+  foo_h(&b);
+  foo_p();
+}
+
+class TestClass {
+public:
+  __attribute__((__visibility__("hidden"))) int value() const noexcept { return 0; }
+};
+
+int main() {
+  TestClass TC;
+  return TC.value();
+}
+
+template 
+class basic {
+public:
+  __attribute__((__visibility__("protected"))) int getdata() { return 1; }
+};
+
+template class basic;
+
+#pragma GCC visibility push(hidden)
+ int pramb;
+ void prambar() {}
+#pragma GCC visibility pop
+
+
+// AIX-NOVISIBILITY:@b = global i32 0
+// LINUX-NOVISIBILITY:  @b = dso_local global i32 0
+// AIX-NOVISIBILITY:@pramb = global i32 0
+// LINUX-NOVISIBILITY:  @pramb = dso_local global i32 0
+// AIX-NOVISIBILITY:define void @_Z5foo_hPi(i32* %p)
+// LINUX-NOVISIBILITY:  define dso_local void @_Z5foo_hPi(i32* %p)
+// NOVISIBILITY:declare void @_Z12zoo_extern_hv()
+// AIX-NOVISIBILITY:define void @_Z3barv()
+// LINUX-NOVISIBILITY:  define dso_local void @_Z3barv()
+// AIX-NOVISIBILITY:define linkonce_odr i32 @_ZNK9TestClass5valueEv(%class.TestClass* %this)
+// LINUX-NOVISIBILITY:  define linkonce_odr dso_local i32 @_ZNK9TestClass5valueEv(%class.TestClass* %this)
+// AIX-NOVISIBILITY:define weak_odr i32 @_ZN5basicIiE7getdataEv(%class.basic* %this)
+// LINUX-NOVISIBILITY:  define weak_odr dso_local i32 @_ZN5basicIiE7getdataEv(%class.basic* %this)
+// AIX-NOVISIBILITY:define void @_Z7prambarv()
+// LINUX-NOVISIBILITY:  define dso_local void @_Z7prambarv()
+
+// VISIBILITY:@b = protected global i32 0
+// VISIBILITY:@pramb = hidden global i32 0
+// VISIBILITY:define hidden void @_Z5foo_hPi(i32* %p)
+// VISIBILITY:declare hidden void @_Z12zoo_extern_hv()
+// VISIBILITY:define protected void @_Z3barv()
+// VISIBILITY:define linkonce_odr hidden i32 @_ZNK9TestClass5valueEv(%class.TestClass* %this)
+// VISIBILITY:define weak_odr protected i32 @_ZN5basicIiE7getdataEv(%class.basic* %this)
+// VISIBILITY:define hidden void @_Z7prambarv()
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2752,6 +2752,9 @@
 Opts.setValueVisibilityMode(parseVisibility(visOpt, Args, Diags));
   } else {
 Opts.setValueVisibilityMode(DefaultVisibility);
+// In AIX oS, the -fnovisibility is enable by default.
+if (T.isOSAIX() || Args.hasArg(OPT_fnovisibility))
+  Opts.NoVisibility = 1;
   }
 
   // The type-visibility mode defaults to the value-visibility mode.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5198,6 +5198,9 @@
 }
   }
 
+  if (Args.getLastArg(options::OPT_fnovisibility))
+CmdArgs.push_back("-fnovisibility");
+
   Args.AddLastArg(CmdArgs, options::OPT_fvisibility_inlines_hidden);
   Args.AddLastArg(CmdArgs, options::OPT_fvisibility_global_new_delete_hidden);
 
Index: clang/lib/AST/Decl.cpp
==

Re: [clang-tools-extra] 156b127 - Add a new altera check for structure packing and alignment.

2020-09-10 Thread Nico Weber via cfe-commits
Looks like this broke the sphinx bot:
http://lab.llvm.org:8011/builders/clang-tools-sphinx-docs/builds/65757/steps/docs-clang-tools-html/logs/stdio

Can you take a look?

On Tue, Sep 8, 2020 at 9:36 AM Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Frank Derry Wanye
> Date: 2020-09-08T09:35:14-04:00
> New Revision: 156b127945a8c923d141e608b7380427da024376
>
> URL:
> https://github.com/llvm/llvm-project/commit/156b127945a8c923d141e608b7380427da024376
> DIFF:
> https://github.com/llvm/llvm-project/commit/156b127945a8c923d141e608b7380427da024376.diff
>
> LOG: Add a new altera check for structure packing and alignment.
>
> The altera struct pack align lint check finds structs that are
> inefficiently
> packed or aligned and recommends packing/aligning of the structs using the
> packed and aligned attributes as needed in a warning.
>
> Added:
> clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
> clang-tools-extra/clang-tidy/altera/CMakeLists.txt
> clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
> clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.h
> clang-tools-extra/docs/clang-tidy/checks/altera-struct-pack-align.rst
> clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
>
> Modified:
> clang-tools-extra/clang-tidy/CMakeLists.txt
> clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
> clang-tools-extra/docs/ReleaseNotes.rst
> clang-tools-extra/docs/clang-tidy/checks/list.rst
> clang-tools-extra/docs/clang-tidy/index.rst
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang-tools-extra/clang-tidy/CMakeLists.txt
> b/clang-tools-extra/clang-tidy/CMakeLists.txt
> index 02573534ccae..923976197ebe 100644
> --- a/clang-tools-extra/clang-tidy/CMakeLists.txt
> +++ b/clang-tools-extra/clang-tidy/CMakeLists.txt
> @@ -46,6 +46,7 @@ endif()
>  # If you add a check, also add it to ClangTidyForceLinker.h in this
> directory.
>  add_subdirectory(android)
>  add_subdirectory(abseil)
> +add_subdirectory(altera)
>  add_subdirectory(boost)
>  add_subdirectory(bugprone)
>  add_subdirectory(cert)
> @@ -71,6 +72,7 @@ add_subdirectory(zircon)
>  set(ALL_CLANG_TIDY_CHECKS
>clangTidyAndroidModule
>clangTidyAbseilModule
> +  clangTidyAlteraModule
>clangTidyBoostModule
>clangTidyBugproneModule
>clangTidyCERTModule
>
> diff  --git a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
> b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
> index 1d6bd2a4fd62..63e681f878db 100644
> --- a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
> +++ b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
> @@ -20,6 +20,11 @@ extern volatile int AbseilModuleAnchorSource;
>  static int LLVM_ATTRIBUTE_UNUSED AbseilModuleAnchorDestination =
>  AbseilModuleAnchorSource;
>
> +// This anchor is used to force the linker to link the AlteraModule.
> +extern volatile int AlteraModuleAnchorSource;
> +static int LLVM_ATTRIBUTE_UNUSED AlteraModuleAnchorDestination =
> +AlteraModuleAnchorSource;
> +
>  // This anchor is used to force the linker to link the AndroidModule.
>  extern volatile int AndroidModuleAnchorSource;
>  static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
>
> diff  --git a/clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
> b/clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
> new file mode 100644
> index ..d91f67ac1485
> --- /dev/null
> +++ b/clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
> @@ -0,0 +1,39 @@
> +//===--- AlteraTidyModule.cpp - clang-tidy
> ===//
> +//
> +// 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 "../ClangTidy.h"
> +#include "../ClangTidyModule.h"
> +#include "../ClangTidyModuleRegistry.h"
> +#include "StructPackAlignCheck.h"
> +
> +using namespace clang::ast_matchers;
> +
> +namespace clang {
> +namespace tidy {
> +namespace altera {
> +
> +class AlteraModule : public ClangTidyModule {
> +public:
> +  void addCheckFactories(ClangTidyCheckFactories &CheckFactories)
> override {
> +CheckFactories.registerCheck(
> +"altera-struct-pack-align");
> +  }
> +};
> +
> +} // namespace altera
> +
> +// Register the AlteraTidyModule using this statically initialized
> variable.
> +static ClangTidyModuleRegistry::Add
> +X("altera-module", "Adds Altera FPGA OpenCL lint checks.");
> +
> +// This anchor is used to force the linker to link in the generated
> object file
> +// and thus register the AlteraModule.
> +volatile int AlteraModuleAnchorSource = 0;
> +
> +} // namespace tidy
> +} // namespace clang
>
> diff  --git a/clang-tools-extra/clang-tidy/alter

[PATCH] D87458: [Clang] Clarify __builtin_memcpy_inline documentation

2020-09-10 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet created this revision.
gchatelet added a reviewer: courbet.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
gchatelet requested review of this revision.

This patch updates the documentation about `__builtin_memcpy_inline` and 
reorders the sections so it is more consitent and understandable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87458

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -2408,20 +2408,6 @@
 Memory builtins
 ---
 
- * ``__builtin_memcpy_inline``
-
-.. code-block:: c
-
-  void __builtin_memcpy_inline(void *dst, const void *src, size_t size);
-
-``__builtin_memcpy_inline(dst, src, size)`` is identical to
-``__builtin_memcpy(dst, src, size)`` except that the generated code is
-guaranteed not to call any external functions. See LLVM IR `llvm.memcpy.inline
-`_ Intrinsic 
-for more information.
-
-Note that the `size` argument must be a compile time constant.
-
 Clang provides constant expression evaluation support for builtin forms of the
 following functions from the C standard library headers
  and :
@@ -2439,7 +2425,27 @@
 given size is an exact multiple of the element size that is no greater than
 the number of elements accessible through the source and destination operands.
 
-Constant evaluation support is not yet provided for 
``__builtin_memcpy_inline``.
+Guaranteed inlined copy
+^^^
+
+.. code-block:: c
+
+  void __builtin_memcpy_inline(void *dst, const void *src, size_t size);
+
+
+``__builtin_memcpy_inline`` has been designed as a building block for efficient
+``memcpy`` implementations. It is identical to ``__builtin_memcpy`` but also
+guarantees not to call any external functions. See LLVM IR `llvm.memcpy.inline
+`_ Intrinsic 
+for more information.
+
+This is useful to implement a custom version of ``memcpy``, implemement a
+``libc`` memcpy or work around the absence of a ``libc``.
+
+Note that the `size` argument must be a compile time constant.
+
+Note that this intrinsic cannot yet be called in a ``constexpr`` context.
+
 
 Atomic Min/Max builtins with memory ordering
 


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -2408,20 +2408,6 @@
 Memory builtins
 ---
 
- * ``__builtin_memcpy_inline``
-
-.. code-block:: c
-
-  void __builtin_memcpy_inline(void *dst, const void *src, size_t size);
-
-``__builtin_memcpy_inline(dst, src, size)`` is identical to
-``__builtin_memcpy(dst, src, size)`` except that the generated code is
-guaranteed not to call any external functions. See LLVM IR `llvm.memcpy.inline
-`_ Intrinsic 
-for more information.
-
-Note that the `size` argument must be a compile time constant.
-
 Clang provides constant expression evaluation support for builtin forms of the
 following functions from the C standard library headers
  and :
@@ -2439,7 +2425,27 @@
 given size is an exact multiple of the element size that is no greater than
 the number of elements accessible through the source and destination operands.
 
-Constant evaluation support is not yet provided for ``__builtin_memcpy_inline``.
+Guaranteed inlined copy
+^^^
+
+.. code-block:: c
+
+  void __builtin_memcpy_inline(void *dst, const void *src, size_t size);
+
+
+``__builtin_memcpy_inline`` has been designed as a building block for efficient
+``memcpy`` implementations. It is identical to ``__builtin_memcpy`` but also
+guarantees not to call any external functions. See LLVM IR `llvm.memcpy.inline
+`_ Intrinsic 
+for more information.
+
+This is useful to implement a custom version of ``memcpy``, implemement a
+``libc`` memcpy or work around the absence of a ``libc``.
+
+Note that the `size` argument must be a compile time constant.
+
+Note that this intrinsic cannot yet be called in a ``constexpr`` context.
+
 
 Atomic Min/Max builtins with memory ordering
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87459: [libcxx][test] ostream{,buf}_iterator::difference_type changes in C++20

2020-09-10 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: ldionne, mclow.lists, EricWF.
Herald added subscribers: libcxx-commits, dexonsmith.
Herald added a project: libc++.
Herald added a reviewer: libc++.
CaseyCarter requested review of this revision.

Although libc++ doesn't yet implement this change, these tests should expect 
the difference type of `std::ostream_iterator` and `std::ostreambuf_iterator` 
specializations to be `std::ptrdiff_t` instead of `void` when testing C++ 
versions greater than 17 if the library under test is not libc++.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87459

Files:
  libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
  libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp


Index: 
libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
===
--- 
libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
+++ 
libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
@@ -19,6 +19,7 @@
 //   typedef basic_ostream   ostream_type;
 //   ...
 
+#include 
 #include 
 #include 
 #include 
@@ -34,7 +35,11 @@
 #else
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+#if TEST_STD_VER <= 17 || defined(_LIBCPP_VERSION)
 static_assert((std::is_same::value), "");
+#else
+static_assert((std::is_same::value), 
"");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 #endif
@@ -50,7 +55,11 @@
 #else
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+#if TEST_STD_VER <= 17 || defined(_LIBCPP_VERSION)
 static_assert((std::is_same::value), "");
+#else
+static_assert((std::is_same::value), 
"");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 #endif
Index: 
libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
===
--- libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
+++ libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
@@ -19,6 +19,7 @@
 // typedef basic_istream istream_type;
 // ...
 
+#include 
 #include 
 #include 
 
@@ -33,7 +34,11 @@
 #else
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+#if TEST_STD_VER <= 17 || defined(_LIBCPP_VERSION)
 static_assert((std::is_same::value), "");
+#else
+static_assert((std::is_same::value), 
"");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 #endif
@@ -47,7 +52,11 @@
 #else
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+#if TEST_STD_VER <= 17 || defined(_LIBCPP_VERSION)
 static_assert((std::is_same::value), "");
+#else
+static_assert((std::is_same::value), 
"");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 #endif


Index: libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
===
--- libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
+++ libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
@@ -19,6 +19,7 @@
 //   typedef basic_ostream   ostream_type;
 //   ...
 
+#include 
 #include 
 #include 
 #include 
@@ -34,7 +35,11 @@
 #else
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+#if TEST_STD_VER <= 17 || defined(_LIBCPP_VERSION)
 static_assert((std::is_same::value), "");
+#else
+static_assert((std::is_same::value), "");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 #endif
@@ -50,7 +55,11 @@
 #else
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+#if TEST_STD_VER <= 17 || defined(_LIBCPP_VERSION)
 static_assert((std::is_same::value), "");
+#else
+static_assert((std::is_same::value), "");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 #endif
Index: libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
===
--- libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
+++ libcxx/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
@@ -19,6 +19,7 @@
 // typedef basic_istream istream_type;
 // ...
 
+#include 
 #include 
 #include 
 
@@ -33,7 +34,11 @@
 #else
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+#if TEST_STD_VER <= 17 || defined(_LIBCPP_VERSION)
 static_

[clang-tools-extra] 66ac212 - Speculatively fix the Sphinx builder.

2020-09-10 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-09-10T11:35:10-04:00
New Revision: 66ac212ea97a529e171a7b8aea10638d7b9b9907

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

LOG: Speculatively fix the Sphinx builder.

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 192f200f34ac..563c0eced92e 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -70,7 +70,7 @@ Improvements to clang-tidy
 New modules
 ^^^
 
-- New :doc:`altera ` module.
+- New ``altera`` module.
 
   Includes checks related to OpenCL for FPGA coding guidelines, based on the
   `Altera SDK for OpenCL: Best Practices Guide



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


[PATCH] D87451: add new clang option -fnovisibility.

2020-09-10 Thread Digger via Phabricator via cfe-commits
DiggerLin updated this revision to Diff 290987.
DiggerLin added a comment.

address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87451

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Decl.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fnovisibility.cpp

Index: clang/test/Driver/fnovisibility.cpp
===
--- /dev/null
+++ clang/test/Driver/fnovisibility.cpp
@@ -0,0 +1,81 @@
+// RUN: %clang-target powerpc-unknown-aix  -emit-llvm  -o - -S  %s  |\
+// RUN:   FileCheck --check-prefixes=NOVISIBILITY,AIX-NOVISIBILITY %s
+
+// RUN: %clang -fnovisibility -target powerpc-unknown-aix  -emit-llvm -o -  -S %s  | \
+// RUN: FileCheck -check-prefixes=NOVISIBILITY,AIX-NOVISIBILITY %s
+
+// RUN: %clang -fnovisibility -target powerpc-unknown-linux  -emit-llvm -o - -S %s  | \
+// RUN: FileCheck -check-prefixes=NOVISIBILITY,LINUX-NOVISIBILITY %s
+
+// RUN: %clang -fnovisibility -fvisibility=default -target powerpc-unknown-aix  -emit-llvm  -o - -S %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY %s
+
+// RUN: %clang -target powerpc-unknown-linux  -emit-llvm  -o - -S %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY %s
+
+// RUN: %clang -fnovisibility -fvisibility=default -target powerpc-unknown-linux  -emit-llvm -o - -S %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY %s
+
+__attribute__((visibility("hidden"))) void foo_h(int *p) {
+  (*p)++;
+}
+
+__attribute__((visibility("protected"))) int b;
+
+extern __attribute__((visibility("hidden"))) void zoo_extern_h(void);
+
+void (*foo_p)(void) = zoo_extern_h;
+
+__attribute__((visibility("protected"))) void bar() {
+  foo_h(&b);
+  foo_p();
+}
+
+class TestClass {
+public:
+  __attribute__((__visibility__("hidden"))) int value() const noexcept { return 0; }
+};
+
+int main() {
+  TestClass TC;
+  return TC.value();
+}
+
+template 
+class basic {
+public:
+  __attribute__((__visibility__("protected"))) int getdata() { return 1; }
+};
+
+template class basic;
+
+#pragma GCC visibility push(hidden)
+ int pramb;
+ void prambar() {}
+#pragma GCC visibility pop
+
+
+// AIX-NOVISIBILITY:@b = global i32 0
+// LINUX-NOVISIBILITY:  @b = dso_local global i32 0
+// AIX-NOVISIBILITY:@pramb = global i32 0
+// LINUX-NOVISIBILITY:  @pramb = dso_local global i32 0
+// AIX-NOVISIBILITY:define void @_Z5foo_hPi(i32* %p)
+// LINUX-NOVISIBILITY:  define dso_local void @_Z5foo_hPi(i32* %p)
+// NOVISIBILITY:declare void @_Z12zoo_extern_hv()
+// AIX-NOVISIBILITY:define void @_Z3barv()
+// LINUX-NOVISIBILITY:  define dso_local void @_Z3barv()
+// AIX-NOVISIBILITY:define linkonce_odr i32 @_ZNK9TestClass5valueEv(%class.TestClass* %this)
+// LINUX-NOVISIBILITY:  define linkonce_odr dso_local i32 @_ZNK9TestClass5valueEv(%class.TestClass* %this)
+// AIX-NOVISIBILITY:define weak_odr i32 @_ZN5basicIiE7getdataEv(%class.basic* %this)
+// LINUX-NOVISIBILITY:  define weak_odr dso_local i32 @_ZN5basicIiE7getdataEv(%class.basic* %this)
+// AIX-NOVISIBILITY:define void @_Z7prambarv()
+// LINUX-NOVISIBILITY:  define dso_local void @_Z7prambarv()
+
+// VISIBILITY:@b = protected global i32 0
+// VISIBILITY:@pramb = hidden global i32 0
+// VISIBILITY:define hidden void @_Z5foo_hPi(i32* %p)
+// VISIBILITY:declare hidden void @_Z12zoo_extern_hv()
+// VISIBILITY:define protected void @_Z3barv()
+// VISIBILITY:define linkonce_odr hidden i32 @_ZNK9TestClass5valueEv(%class.TestClass* %this)
+// VISIBILITY:define weak_odr protected i32 @_ZN5basicIiE7getdataEv(%class.basic* %this)
+// VISIBILITY:define hidden void @_Z7prambarv()
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2752,6 +2752,9 @@
 Opts.setValueVisibilityMode(parseVisibility(visOpt, Args, Diags));
   } else {
 Opts.setValueVisibilityMode(DefaultVisibility);
+// In AIX oS, the -fnovisibility is enable by default.
+if (T.isOSAIX() || Args.hasArg(OPT_fnovisibility))
+  Opts.NoVisibility = 1;
   }
 
   // The type-visibility mode defaults to the value-visibility mode.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5198,6 +5198,9 @@
 }
   }
 
+  if (Args.getLastArg(options::OPT_fnovisibility))
+CmdArgs.push_back("-fnovisibility");
+
   Args.AddLastArg(CmdArgs, options::OPT_fvisibility_inlines_hidden);
   Args.AddLastArg(CmdArgs, options::OPT_fvisibility_global_new_delete_hidden);
 
Index: clang/lib/AST/Decl.cpp
==

Re: [clang-tools-extra] 156b127 - Add a new altera check for structure packing and alignment.

2020-09-10 Thread Aaron Ballman via cfe-commits
On Thu, Sep 10, 2020 at 11:27 AM Nico Weber  wrote:
>
> Looks like this broke the sphinx bot: 
> http://lab.llvm.org:8011/builders/clang-tools-sphinx-docs/builds/65757/steps/docs-clang-tools-html/logs/stdio
>
> Can you take a look?

Hopefully 66ac212ea97a529e171a7b8aea10638d7b9b9907 will resolve the
issue while I get sphinx up and running on this box in case it
doesn't.

~Aaron

>
> On Tue, Sep 8, 2020 at 9:36 AM Aaron Ballman via cfe-commits 
>  wrote:
>>
>>
>> Author: Frank Derry Wanye
>> Date: 2020-09-08T09:35:14-04:00
>> New Revision: 156b127945a8c923d141e608b7380427da024376
>>
>> URL: 
>> https://github.com/llvm/llvm-project/commit/156b127945a8c923d141e608b7380427da024376
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/156b127945a8c923d141e608b7380427da024376.diff
>>
>> LOG: Add a new altera check for structure packing and alignment.
>>
>> The altera struct pack align lint check finds structs that are inefficiently
>> packed or aligned and recommends packing/aligning of the structs using the
>> packed and aligned attributes as needed in a warning.
>>
>> Added:
>> clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
>> clang-tools-extra/clang-tidy/altera/CMakeLists.txt
>> clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
>> clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.h
>> clang-tools-extra/docs/clang-tidy/checks/altera-struct-pack-align.rst
>> clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
>>
>> Modified:
>> clang-tools-extra/clang-tidy/CMakeLists.txt
>> clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
>> clang-tools-extra/docs/ReleaseNotes.rst
>> clang-tools-extra/docs/clang-tidy/checks/list.rst
>> clang-tools-extra/docs/clang-tidy/index.rst
>>
>> Removed:
>>
>>
>>
>> 
>> diff  --git a/clang-tools-extra/clang-tidy/CMakeLists.txt 
>> b/clang-tools-extra/clang-tidy/CMakeLists.txt
>> index 02573534ccae..923976197ebe 100644
>> --- a/clang-tools-extra/clang-tidy/CMakeLists.txt
>> +++ b/clang-tools-extra/clang-tidy/CMakeLists.txt
>> @@ -46,6 +46,7 @@ endif()
>>  # If you add a check, also add it to ClangTidyForceLinker.h in this 
>> directory.
>>  add_subdirectory(android)
>>  add_subdirectory(abseil)
>> +add_subdirectory(altera)
>>  add_subdirectory(boost)
>>  add_subdirectory(bugprone)
>>  add_subdirectory(cert)
>> @@ -71,6 +72,7 @@ add_subdirectory(zircon)
>>  set(ALL_CLANG_TIDY_CHECKS
>>clangTidyAndroidModule
>>clangTidyAbseilModule
>> +  clangTidyAlteraModule
>>clangTidyBoostModule
>>clangTidyBugproneModule
>>clangTidyCERTModule
>>
>> diff  --git a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h 
>> b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
>> index 1d6bd2a4fd62..63e681f878db 100644
>> --- a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
>> +++ b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
>> @@ -20,6 +20,11 @@ extern volatile int AbseilModuleAnchorSource;
>>  static int LLVM_ATTRIBUTE_UNUSED AbseilModuleAnchorDestination =
>>  AbseilModuleAnchorSource;
>>
>> +// This anchor is used to force the linker to link the AlteraModule.
>> +extern volatile int AlteraModuleAnchorSource;
>> +static int LLVM_ATTRIBUTE_UNUSED AlteraModuleAnchorDestination =
>> +AlteraModuleAnchorSource;
>> +
>>  // This anchor is used to force the linker to link the AndroidModule.
>>  extern volatile int AndroidModuleAnchorSource;
>>  static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
>>
>> diff  --git a/clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp 
>> b/clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
>> new file mode 100644
>> index ..d91f67ac1485
>> --- /dev/null
>> +++ b/clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
>> @@ -0,0 +1,39 @@
>> +//===--- AlteraTidyModule.cpp - clang-tidy 
>> ===//
>> +//
>> +// 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 "../ClangTidy.h"
>> +#include "../ClangTidyModule.h"
>> +#include "../ClangTidyModuleRegistry.h"
>> +#include "StructPackAlignCheck.h"
>> +
>> +using namespace clang::ast_matchers;
>> +
>> +namespace clang {
>> +namespace tidy {
>> +namespace altera {
>> +
>> +class AlteraModule : public ClangTidyModule {
>> +public:
>> +  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
>> +CheckFactories.registerCheck(
>> +"altera-struct-pack-align");
>> +  }
>> +};
>> +
>> +} // namespace altera
>> +
>> +// Register the AlteraTidyModule using this statically initialized variable.
>> +static ClangTidyModuleRegistry::Add
>> +X("altera-module", "Adds Altera F

RE: Clang-Format, Clang-Tidy - Absolute Path to config files

2020-09-10 Thread via cfe-commits
Hi Francois,

I read your usecase. Our usecase is similar, but the difference is that we use 
Artifactory to store our tools and Conan to manage and install them. This way, 
having a Conan package with everything in it, including the config file is very 
scalable and maintainable.

I did not quite understand the last statement: “But as long as you are ready to 
recompile clang-format, it should work fine.” . I am a noob to contributing to 
open source software and I really do not know how to contribute, how to 
integrate the code. The idea would be to integrate this feature, so if we want 
to use future releases of Clang, they will also contain this feature and we 
will not need to integrate it again at every release.

Best regards,
Cezar

From: Typz 
Sent: joi, 10 septembrie 2020 17:58
To: Diplasu Cezar (IFRO DCBUC ATV SC D DD) 
Cc: cfe-commits@lists.llvm.org
Subject: Re: Clang-Format, Clang-Tidy - Absolute Path to config files

Caution: This e-mail originated outside Infineon Technologies. Do not click on 
links or open attachments unless you validate it is 
safe.


Hello,

I worked on adding a similar feature some time back : 
https://reviews.llvm.org/D50147
It supports specifying styles by absolute file name as well as lookup of a 
style by name in various locations (like ~/.local/share/clang-format or 
/usr/share/clang-format), allowing to install styles on the machine and use 
them similarly to "integrated" styles : e.g. reference them in BasedOnStyle tag 
or specify them via the --style parameter...

Unfortunately there was no consensus on this approach, and I did not get the 
time yet to finalize something that could be integrated. But as long as you are 
ready to recompile clang-format, it should work fine.
Best regards,

--
Francois

On Thu, Sep 10, 2020 at 2:28 PM via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Hi all,


I have recently started to work with Clang-Format and Clang-Tidy tools as part 
of a methodology project in my company.
We want to have a uniform style and format in the entire department and for 
that we want to use the two tools to automatically keep this in order. For this 
we need to be able to store the config files somewhere available for everybody 
and for any project.

In my research, I did not find the possibility to give an Absolute Path to the 
config files of the tools.

This is why I added the feature myself and recompiled the tools. Could some 
body help me with the integration of the feature in the community?


Best regards,
Cezar
___
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] D87459: [libcxx][test] ostream{,buf}_iterator::difference_type changes in C++20

2020-09-10 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

What paper is this? I searched but failed to find a paper this falls off from.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87459

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


[PATCH] D87331: Sema: add support for `__attribute__((__swift_error__))`

2020-09-10 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd marked 2 inline comments as done.
compnerd added inline comments.



Comment at: clang/test/SemaObjC/attr-swift-error.m:55
+
+// This is unconventional and very odd but we do process it.
+- (int)q0:(const NSError **)error 
__attribute__((__swift_error__(nonzero_result)));

gribozavr2 wrote:
> 
Removed the test case in light of John's comment.



Comment at: clang/test/SemaObjC/attr-swift-error.m:97
+
+// This is unconventional and very odd but we do process it.
+extern void *q0(const CFErrorRef *) 
__attribute__((__swift_error__(null_result)));

gribozavr2 wrote:
> 
Similar


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87331

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


[PATCH] D87459: [libcxx][test] ostream{,buf}_iterator::difference_type changes in C++20

2020-09-10 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

In D87459#2265864 , @ldionne wrote:

> What paper is this? I searched but failed to find a paper this falls off from.

P0896R4 "The One Ranges Proposal" - Ranges demands that all iterators have 
useful difference types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87459

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


[PATCH] D87331: Sema: add support for `__attribute__((__swift_error__))`

2020-09-10 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 290990.
compnerd added a comment.

Address @gribozavr2's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87331

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/attr-swift-error.m

Index: clang/test/SemaObjC/attr-swift-error.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-swift-error.m
@@ -0,0 +1,93 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc -fblocks %s
+
+@class NSError;
+
+#if __SIZEOF_POINTER__ == 4
+typedef unsigned char BOOL;
+#else
+typedef _Bool BOOL;
+#endif
+
+typedef struct __attribute__((__objc_bridge__(NSError))) __CFError *CFErrorRef;
+
+extern int f0(void) __attribute__((__swift_error__));
+// expected-error@-1 {{'__swift_error__' attribute takes one argument}}
+extern int f1(void) __attribute__((__swift_error__(invalid)));
+// expected-warning@-1 {{'__swift_error__' attribute argument not supported: 'invalid'}}
+extern int f2(void) __attribute__((__swift_error__(none,zero_result)));
+// expected-error@-1 {{use of undeclared identifier 'zero_result'}}
+
+@interface Erroneous
+- (BOOL)m0:(NSError **)error __attribute__((__swift_error__(none)));
+- (BOOL)m1:(NSError **)error __attribute__((__swift_error__(nonnull_error)));
+- (BOOL)m2:(NSError **)error __attribute__((__swift_error__(null_result)));
+// expected-error@-1 {{'__swift_error__' attribute with 'null_result' convention can only be applied to a method returning a pointer}}
+- (BOOL)m3:(NSError **)error __attribute__((__swift_error__(nonzero_result)));
+- (BOOL)m4:(NSError **)error __attribute__((__swift_error__(zero_result)));
+
+- (Undeclared)n0:(NSError **)error __attribute__((__swift_error__(none)));
+// expected-error@-1 {{expected a type}}
+- (Undeclared)n1:(NSError **)error __attribute__((__swift_error__(nonnull_error)));
+// expected-error@-1 {{expected a type}}
+- (Undeclared)n2:(NSError **)error __attribute__((__swift_error__(null_result)));
+// expected-error@-1 {{expected a type}}
+- (Undeclared)n3:(NSError **)error __attribute__((__swift_error__(nonzero_result)));
+// expected-error@-1 {{expected a type}}
+// FIXME: the follow-on warning should really be suppressed, but apparently
+// having an ill-formed return type doesn't mark anything as invalid.
+// expected-error@-4 {{can only be applied}}
+- (Undeclared)n4:(NSError **)error __attribute__((__swift_error__(zero_result)));
+// expected-error@-1 {{expected a type}}
+// FIXME: the follow-on warning should really be suppressed, but apparently
+// having an ill-formed return type doesn't mark anything as invalid.
+// expected-error@-4 {{can only be applied}}
+
+- (instancetype)o0 __attribute__((__swift_error__(none)));
+- (instancetype)o1 __attribute__((__swift_error__(nonnull_error)));
+// expected-error@-1 {{'__swift_error__' attribute can only be applied to a method with an error parameter}}
+- (instancetype)o2 __attribute__((__swift_error__(null_result)));
+// expected-error@-1 {{'__swift_error__' attribute can only be applied to a method with an error parameter}}
+- (instancetype)o3 __attribute__((__swift_error__(nonzero_result)));
+// expected-error@-1 {{'__swift_error__' attribute can only be applied to a method with an error parameter}}
+- (instancetype)o4 __attribute__((__swift_error__(zero_result)));
+// expected-error@-1 {{'__swift_error__' attribute can only be applied to a method with an error parameter}}
+@end
+
+extern BOOL m0(CFErrorRef *) __attribute__((__swift_error__(none)));
+extern BOOL m1(CFErrorRef *) __attribute__((__swift_error__(nonnull_error)));
+extern BOOL m2(CFErrorRef *) __attribute__((__swift_error__(null_result)));
+// expected-error@-1 {{'__swift_error__' attribute with 'null_result' convention can only be applied to a function returning a pointer}}
+extern BOOL m3(CFErrorRef *) __attribute__((__swift_error__(nonzero_result)));
+extern BOOL m4(CFErrorRef *) __attribute__((__swift_error__(zero_result)));
+
+extern Undeclared n0(CFErrorRef *) __attribute__((__swift_error__(none)));
+// expected-error@-1 {{unknown type name 'Undeclared'}}
+extern Undeclared n1(CFErrorRef *) __attribute__((__swift_error__(nonnull_error)));
+// expected-error@-1 {{unknown type name 'Undeclared'}}
+extern Undeclared n2(CFErrorRef *) __attribute__((__swift_error__(null_result)));
+// expected-error@-1 {{unknown type name 'Undeclared'}}
+extern Undeclared n3(CFErrorRef *) __attribute__((__swift_error__(nonzero_result)));
+// expected-error@-1 {{unknown type name 'Undeclared'}}
+extern Undeclared n4(CFErrorRef *) __attribute__((__swift_error__(zero_result)));
+// expected-error@-1 {{unknown type name 'Undeclared'}}
+
+extern void *o0(CFErrorRef *) __attrib

[PATCH] D87459: [libcxx][test] ostream{,buf}_iterator::difference_type changes in C++20

2020-09-10 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D87459#2265871 , @CaseyCarter wrote:

> In D87459#2265864 , @ldionne wrote:
>
>> What paper is this? I searched but failed to find a paper this falls off 
>> from.
>
> P0896R4 "The One Ranges Proposal" - Ranges demands that all iterators have 
> useful difference types.

Ah, I see it. I'll add that bit to libc++ so we don't need special casing in 
the tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87459

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


[PATCH] D87459: [libcxx][test] ostream{,buf}_iterator::difference_type changes in C++20

2020-09-10 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

> Ah, I see it. I'll add that bit to libc++ so we don't need special casing in 
> the tests.

Feel free to steal this for your test changes. Shall I close this differential 
then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87459

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


[PATCH] D87461: Disable sanitizer options for AMDGPU

2020-09-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, ashi1.
Herald added subscribers: t-tye, tpr, dstuttard, kzhuravl.
yaxunl requested review of this revision.
Herald added a subscriber: wdng.

Currently AMDGPU does not support sanitizer. Disable sanitizer options for now 
until they are supported.


https://reviews.llvm.org/D87461

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/Driver/hip-sanitize-options.hip


Index: clang/test/Driver/hip-sanitize-options.hip
===
--- /dev/null
+++ clang/test/Driver/hip-sanitize-options.hip
@@ -0,0 +1,9 @@
+// REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx906 \
+// RUN:   -fsanitize=address \
+// RUN:   -nogpuinc -nogpulib \
+// RUN:   %s 2>&1 | FileCheck %s
+
+// CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address"}}
+// CHECK: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-fsanitize=address"}}
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -929,10 +929,10 @@
 void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList 
&Args,
 llvm::opt::ArgStringList &CmdArgs,
 types::ID InputType) const {
-  // NVPTX doesn't currently support sanitizers.  Bailing out here means that
-  // e.g. -fsanitize=address applies only to host code, which is what we want
-  // for now.
-  if (TC.getTriple().isNVPTX())
+  // NVPTX/AMDGPU doesn't currently support sanitizers.  Bailing out here means
+  // that e.g. -fsanitize=address applies only to host code, which is what we
+  // want for now.
+  if (TC.getTriple().isNVPTX() || TC.getTriple().isAMDGPU())
 return;
 
   // Translate available CoverageFeatures to corresponding clang-cc1 flags.


Index: clang/test/Driver/hip-sanitize-options.hip
===
--- /dev/null
+++ clang/test/Driver/hip-sanitize-options.hip
@@ -0,0 +1,9 @@
+// REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx906 \
+// RUN:   -fsanitize=address \
+// RUN:   -nogpuinc -nogpulib \
+// RUN:   %s 2>&1 | FileCheck %s
+
+// CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address"}}
+// CHECK: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* "-fsanitize=address"}}
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -929,10 +929,10 @@
 void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs,
 types::ID InputType) const {
-  // NVPTX doesn't currently support sanitizers.  Bailing out here means that
-  // e.g. -fsanitize=address applies only to host code, which is what we want
-  // for now.
-  if (TC.getTriple().isNVPTX())
+  // NVPTX/AMDGPU doesn't currently support sanitizers.  Bailing out here means
+  // that e.g. -fsanitize=address applies only to host code, which is what we
+  // want for now.
+  if (TC.getTriple().isNVPTX() || TC.getTriple().isAMDGPU())
 return;
 
   // Translate available CoverageFeatures to corresponding clang-cc1 flags.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87463: [clang][aarch64] Fix mangling of bfloat16 neon vectors

2020-09-10 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes created this revision.
c-rhodes added reviewers: sdesmalen, SjoerdMeijer, stuij.
Herald added subscribers: danielkiss, kristof.beyls.
Herald added a project: clang.
c-rhodes requested review of this revision.

The AAPCS64 specifies the internal type is used for c++ mangling. For
bfloat16 it was defined as `BFloat16` when it should be `Bfloat16`, i.e.
lowercase 'f'.

For more information, see:

https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#appendix-support-for-advanced-simd-extensions


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87463

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CodeGenCXX/mangle-neon-vectors.cpp


Index: clang/test/CodeGenCXX/mangle-neon-vectors.cpp
===
--- clang/test/CodeGenCXX/mangle-neon-vectors.cpp
+++ clang/test/CodeGenCXX/mangle-neon-vectors.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple armv7-apple-ios -target-feature +neon  %s 
-emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 -triple arm64-apple-ios -target-feature +neon %s -emit-llvm 
-o - | FileCheck %s
 // RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon %s -emit-llvm 
-o - | FileCheck %s --check-prefix=CHECK-AARCH64
+// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon 
-target-feature +bf16 %s -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-AARCH64-BF16
 
 typedef float float32_t;
 typedef double float64_t;
@@ -14,6 +15,10 @@
 #endif
 typedef unsigned __INT64_TYPE__ uint64_t;
 
+#if defined(__ARM_FEATURE_BF16)
+typedef __bf16 bfloat16_t;
+#endif
+
 typedef __attribute__((neon_vector_type(2))) int int32x2_t;
 typedef __attribute__((neon_vector_type(4))) int int32x4_t;
 typedef __attribute__((neon_vector_type(1))) uint64_t uint64x1_t;
@@ -28,6 +33,10 @@
 typedef __attribute__((neon_polyvector_type(16))) poly8_t  poly8x16_t;
 typedef __attribute__((neon_polyvector_type(8)))  poly16_t poly16x8_t;
 
+#if defined(__ARM_FEATURE_BF16)
+typedef __attribute__((neon_vector_type(4))) __bf16 bfloat16x4_t;
+#endif
+
 // CHECK: 16__simd64_int32_t
 // CHECK-AARCH64: 11__Int32x2_t
 void f1(int32x2_t v) { }
@@ -72,3 +81,8 @@
 // CHECK-AARCH64: 13__Float64x2_t
 void f11(float64x2_t v) { }
 #endif
+
+#if defined(__ARM_FEATURE_BF16)
+// CHECK-AARCH64-BF16: 14__Bfloat16x4_t
+void f12(bfloat16x4_t v) {}
+#endif
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -3275,7 +3275,7 @@
   case BuiltinType::Double:
 return "Float64";
   case BuiltinType::BFloat16:
-return "BFloat16";
+return "Bfloat16";
   default:
 llvm_unreachable("Unexpected vector element base type");
   }


Index: clang/test/CodeGenCXX/mangle-neon-vectors.cpp
===
--- clang/test/CodeGenCXX/mangle-neon-vectors.cpp
+++ clang/test/CodeGenCXX/mangle-neon-vectors.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple armv7-apple-ios -target-feature +neon  %s -emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 -triple arm64-apple-ios -target-feature +neon %s -emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-AARCH64
+// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -target-feature +bf16 %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-AARCH64-BF16
 
 typedef float float32_t;
 typedef double float64_t;
@@ -14,6 +15,10 @@
 #endif
 typedef unsigned __INT64_TYPE__ uint64_t;
 
+#if defined(__ARM_FEATURE_BF16)
+typedef __bf16 bfloat16_t;
+#endif
+
 typedef __attribute__((neon_vector_type(2))) int int32x2_t;
 typedef __attribute__((neon_vector_type(4))) int int32x4_t;
 typedef __attribute__((neon_vector_type(1))) uint64_t uint64x1_t;
@@ -28,6 +33,10 @@
 typedef __attribute__((neon_polyvector_type(16))) poly8_t  poly8x16_t;
 typedef __attribute__((neon_polyvector_type(8)))  poly16_t poly16x8_t;
 
+#if defined(__ARM_FEATURE_BF16)
+typedef __attribute__((neon_vector_type(4))) __bf16 bfloat16x4_t;
+#endif
+
 // CHECK: 16__simd64_int32_t
 // CHECK-AARCH64: 11__Int32x2_t
 void f1(int32x2_t v) { }
@@ -72,3 +81,8 @@
 // CHECK-AARCH64: 13__Float64x2_t
 void f11(float64x2_t v) { }
 #endif
+
+#if defined(__ARM_FEATURE_BF16)
+// CHECK-AARCH64-BF16: 14__Bfloat16x4_t
+void f12(bfloat16x4_t v) {}
+#endif
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -3275,7 +3275,7 @@
   case BuiltinType::Double:
 return "Float64";
   case BuiltinType::BFloat16:
-return "BFloat16";
+return "Bfloat16";
   default:
 llvm_unreachable("Unexpected vector element base type");
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-b

  1   2   >