[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-04-04 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 255008.
craig.topper added a comment.
This revision is now accepted and ready to land.

Use std::unique_ptr for arrays in the graph. I started trying to use 
std::vector, but it kept crashing. Which initially I thought was some issue 
with the fact that we store pointers into the vectors in other places and that 
somehow std::move of the vector was breaking that. I think I now realize its 
because the array is 1 larger than the real number of nodes and my std::vector 
version didn't take that into account.  But thinking about it more, since we 
are storing pointers into the array, it probably makes more sense for it to 
just be a plain array than a vector since resizing a vector would invalidate 
those pointers. Using an array makes it more clear than we don't resize.


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

https://reviews.llvm.org/D75936

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/ImmutableGraph.h
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/O3-pipeline.ll
  llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll

Index: llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll
@@ -0,0 +1,129 @@
+; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown -x86-lvi-load-dot-verify -o %t < %s | FileCheck %s
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local i32 @test(i32* %untrusted_user_ptr, i32* %secret, i32 %secret_size) #0 {
+entry:
+  %untrusted_user_ptr.addr = alloca i32*, align 8
+  %secret.addr = alloca i32*, align 8
+  %secret_size.addr = alloca i32, align 4
+  %ret_val = alloca i32, align 4
+  %i = alloca i32, align 4
+  store i32* %untrusted_user_ptr, i32** %untrusted_user_ptr.addr, align 8
+  store i32* %secret, i32** %secret.addr, align 8
+  store i32 %secret_size, i32* %secret_size.addr, align 4
+  store i32 0, i32* %ret_val, align 4
+  call void @llvm.x86.sse2.lfence()
+  store i32 0, i32* %i, align 4
+  br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+  %0 = load i32, i32* %i, align 4
+  %1 = load i32, i32* %secret_size.addr, align 4
+  %cmp = icmp slt i32 %0, %1
+  br i1 %cmp, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+  %2 = load i32, i32* %i, align 4
+  %rem = srem i32 %2, 2
+  %cmp1 = icmp eq i32 %rem, 0
+  br i1 %cmp1, label %if.then, label %if.else
+
+if.then:  ; preds = %for.body
+  %3 = load i32*, i32** %secret.addr, align 8
+  %4 = load i32, i32* %ret_val, align 4
+  %idxprom = sext i32 %4 to i64
+  %arrayidx = getelementptr inbounds i32, i32* %3, i64 %idxprom
+  %5 = load i32, i32* %arrayidx, align 4
+  %6 = load i32*, i32** %untrusted_user_ptr.addr, align 8
+  store i32 %5, i32* %6, align 4
+  br label %if.end
+
+if.else:  ; preds = %for.body
+  %7 = load i32*, i32** %secret.addr, align 8
+  %8 = load i32, i32* %ret_val, align 4
+  %idxprom2 = sext i32 %8 to i64
+  %arrayidx3 = getelementptr inbounds i32, i32* %7, i64 %idxprom2
+  store i32 42, i32* %arrayidx3, align 4
+  br label %if.end
+
+if.end:   ; preds = %if.else, %if.then
+  %9 = load i32*, i32** %untrusted_user_ptr.addr, align 8
+  %10 = load i32, i32* %9, align 4
+  store i32 %10, i32* %ret_val, align 4
+  br label %for.inc
+
+for.inc:  ; preds = %if.end
+  %11 = load i32, i32* %i, align 4
+  %inc = add nsw i32 %11, 1
+  store i32 %inc, i32* %i, align 4
+  br label %for.cond
+
+for.end:  ; preds = %for.cond
+  %12 = load i32, i32* %ret_val, align 4
+  ret i32 %12
+}
+
+; CHECK:  digraph "Speculative gadgets for \"test\" function" {
+; CHECK-NEXT: label="Speculative gadgets for \"test\" function";
+; CHECK:  Node0x{{[0-9a-f]+}} [shape=record,color = green,label="{LFENCE\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 0];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{renamable $eax = MOV32rm %stack.4.i, 1, $noreg, 0, $noreg :: (dereferenceable load 4 from %ir.i)\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[color = red, style = "dashed"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{JCC_1 %bb.6, 13, implicit killed $eflags\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHE

[PATCH] D77456: [clangd] Parse `foo` in documentation comments and render as code.

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

Some saturday morning procrastination.

But I'm wondering how good an idea this is for plaintext: "Returns 'foo' on 
failure" is better than "Returns foo on failure", right? (With backticks 
instead of single quotes, phab is eating my formatting)
Maybe we should have an Emphasis flag or something on plaintext to preserve the 
quotes? (We don't want to include them e.g. in the return type chunks)

Also, realized our model for whitespace around paragraph chunks isn't ideal 
after all :-(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77456



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


[PATCH] D77456: [clangd] Parse `foo` in documentation comments and render as code.

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

Some saturday morning procrastination.

But I'm wondering how good an idea this is for plaintext: "Returns 'foo' on 
failure" is better than "Returns foo on failure", right? (With backticks 
instead of single quotes, phab is eating my formatting)
Maybe we should have an Emphasis flag or something on plaintext to preserve the 
quotes? (We don't want to include them e.g. in the return type chunks)

Also, realized our model for whitespace around paragraph chunks isn't ideal 
after all :-(


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77456

Files:
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/FormattedString.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1935,7 +1935,7 @@
   }
 }
 
-TEST(Hover, DocCommentLineBreakConversion) {
+TEST(Hover, ParseDocumentation) {
   struct Case {
 llvm::StringRef Documentation;
 llvm::StringRef ExpectedRenderMarkdown;
@@ -1994,6 +1994,22 @@
"foo\nbar",
"foo bar",
"foo bar",
+   },
+   {
+   // FIXME: we insert spaces between code and text chunk.
+   "Tests primality of `p`.",
+   "Tests primality of `p` .",
+   "Tests primality of p .",
+   },
+   {
+   "'`' should not occur in `Code`",
+   "'\\`' should not occur in `Code`",
+   "'`' should not occur in Code",
+   },
+   {
+   "`not\nparsed`",
+   "\\`not parsed\\`",
+   "`not parsed`",
}};
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -747,7 +747,7 @@
   // https://github.com/microsoft/vscode/issues/88417 for details.
   markup::Paragraph &Header = Output.addHeading(3);
   if (Kind != index::SymbolKind::Unknown)
-Header.appendText(std::string(index::getSymbolKindString(Kind)));
+Header.appendText(index::getSymbolKindString(Kind));
   assert(!Name.empty() && "hover triggered on a nameless symbol");
   Header.appendCode(Name);
 
@@ -806,6 +806,53 @@
   return Output;
 }
 
+// If the backtick at `Offset` starts a probable quoted range, return the range
+// (including the quotes).
+llvm::Optional getBacktickQuoteRange(llvm::StringRef Line,
+  unsigned Offset) {
+  assert(Line[Offset] == '`');
+
+  // The open-quote is usually preceded by whitespace.
+  llvm::StringRef Prefix = Line.substr(0, Offset);
+  constexpr llvm::StringLiteral BeforeStartChars = " \t(=";
+  if (!Prefix.empty() && !BeforeStartChars.contains(Prefix.back()))
+return llvm::None;
+
+  // The quoted string must be nonempty and usually has no leading/trailing ws.
+  auto Next = Line.find('`', Offset + 1);
+  if (Next == llvm::StringRef::npos)
+return llvm::None;
+  llvm::StringRef Contents = Line.slice(Offset + 1, Next);
+  if (Contents.empty() || isWhitespace(Contents.front()) ||
+  isWhitespace(Contents.back()))
+return llvm::None;
+
+  // The close-quote is usually followed by whitespace or punctuation.
+  llvm::StringRef Suffix = Line.substr(Next + 1);
+  constexpr llvm::StringLiteral AfterEndChars = " \t)=.,;:";
+  if (!Suffix.empty() && !AfterEndChars.contains(Suffix.front()))
+return llvm::None;
+
+  return Line.slice(Offset, Next+1);
+}
+
+void parseDocumentationLine(llvm::StringRef Line, markup::Paragraph &Out) {
+  // Probably this is appendText(Input), but scan for something interesting.
+  for (unsigned I = 0; I < Line.size(); ++I) {
+switch (Line[I]) {
+  case '`':
+if (auto Range = getBacktickQuoteRange(Line, I)) {
+  Out.appendText(Line.substr(0, I));
+  Out.appendCode(Range->trim("`"));
+  return parseDocumentationLine(Line.substr(I+Range->size()), Out);
+}
+break;
+
+}
+  }
+  Out.appendText(Line);
+}
+
 void parseDocumentation(llvm::StringRef Input, markup::Document &Output) {
   std::vector ParagraphLines;
   auto FlushParagraph = [&] {
@@ -813,7 +860,7 @@
   return;
 auto &P = Output.addParagraph();
 for (llvm::StringRef Line : ParagraphLines)
-  P.appendText(Line.str());
+  parseDocumentationLine(Line, P);
 ParagraphLines.clear();
   };
 
Index: clang-

[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-04-04 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 255011.
craig.topper added a comment.

Use unique_ptr::operator[] in a few places.


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

https://reviews.llvm.org/D75936

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/ImmutableGraph.h
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/O3-pipeline.ll
  llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll

Index: llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll
@@ -0,0 +1,129 @@
+; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown -x86-lvi-load-dot-verify -o %t < %s | FileCheck %s
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local i32 @test(i32* %untrusted_user_ptr, i32* %secret, i32 %secret_size) #0 {
+entry:
+  %untrusted_user_ptr.addr = alloca i32*, align 8
+  %secret.addr = alloca i32*, align 8
+  %secret_size.addr = alloca i32, align 4
+  %ret_val = alloca i32, align 4
+  %i = alloca i32, align 4
+  store i32* %untrusted_user_ptr, i32** %untrusted_user_ptr.addr, align 8
+  store i32* %secret, i32** %secret.addr, align 8
+  store i32 %secret_size, i32* %secret_size.addr, align 4
+  store i32 0, i32* %ret_val, align 4
+  call void @llvm.x86.sse2.lfence()
+  store i32 0, i32* %i, align 4
+  br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+  %0 = load i32, i32* %i, align 4
+  %1 = load i32, i32* %secret_size.addr, align 4
+  %cmp = icmp slt i32 %0, %1
+  br i1 %cmp, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+  %2 = load i32, i32* %i, align 4
+  %rem = srem i32 %2, 2
+  %cmp1 = icmp eq i32 %rem, 0
+  br i1 %cmp1, label %if.then, label %if.else
+
+if.then:  ; preds = %for.body
+  %3 = load i32*, i32** %secret.addr, align 8
+  %4 = load i32, i32* %ret_val, align 4
+  %idxprom = sext i32 %4 to i64
+  %arrayidx = getelementptr inbounds i32, i32* %3, i64 %idxprom
+  %5 = load i32, i32* %arrayidx, align 4
+  %6 = load i32*, i32** %untrusted_user_ptr.addr, align 8
+  store i32 %5, i32* %6, align 4
+  br label %if.end
+
+if.else:  ; preds = %for.body
+  %7 = load i32*, i32** %secret.addr, align 8
+  %8 = load i32, i32* %ret_val, align 4
+  %idxprom2 = sext i32 %8 to i64
+  %arrayidx3 = getelementptr inbounds i32, i32* %7, i64 %idxprom2
+  store i32 42, i32* %arrayidx3, align 4
+  br label %if.end
+
+if.end:   ; preds = %if.else, %if.then
+  %9 = load i32*, i32** %untrusted_user_ptr.addr, align 8
+  %10 = load i32, i32* %9, align 4
+  store i32 %10, i32* %ret_val, align 4
+  br label %for.inc
+
+for.inc:  ; preds = %if.end
+  %11 = load i32, i32* %i, align 4
+  %inc = add nsw i32 %11, 1
+  store i32 %inc, i32* %i, align 4
+  br label %for.cond
+
+for.end:  ; preds = %for.cond
+  %12 = load i32, i32* %ret_val, align 4
+  ret i32 %12
+}
+
+; CHECK:  digraph "Speculative gadgets for \"test\" function" {
+; CHECK-NEXT: label="Speculative gadgets for \"test\" function";
+; CHECK:  Node0x{{[0-9a-f]+}} [shape=record,color = green,label="{LFENCE\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 0];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{renamable $eax = MOV32rm %stack.4.i, 1, $noreg, 0, $noreg :: (dereferenceable load 4 from %ir.i)\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[color = red, style = "dashed"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{JCC_1 %bb.6, 13, implicit killed $eflags\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{CMP32rm killed renamable $eax, %stack.2.secret_size.addr, 1, $noreg, 0, $noreg, implicit-def $eflags :: (dereferenceable load 4 from %ir.secret_size.addr)\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[color = red, style = "dashed"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{renamable $eax = MOV32rm %stack.4.i, 1, $noreg, 0, $noreg :: (dereferenceable load 4 from %ir.i)\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[color = red, style = "dashed"];
+; C

[PATCH] D77150: [Analyzer] New Option for ContainerModeling: AggressiveEraseModeling

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



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:647-653
 CmdLineOption
   ]>,

Szelethus wrote:
> Ah, okay, I see which one you refer to. We should totally make this non-user 
> facing as well. 
The option is not about state split! It is for choosing between the (default) 
conservative approach and a more aggressive one. It is absolutely for the user 
to set. Some users prefer less false positive for the price of losing true 
positives. However, some other users prefer more true positives for the price 
of additional false positives. This is why we have checker options to be able 
to serve both groups.

This feature was explicitly requested by our users who first disabled iterator 
checkers because of the too many false positives but later re-enabled them 
because they run into a bug in a production system which could have been 
prevented by enabling them. However, they run into another bug that our checker 
did not find because of its conservative behavior. They requested a more 
aggressive one but we must not do it for everyone. The concept of the Analyzer 
is that we apply the conservative approach by default and the aggressive can be 
enabled by analyzer and checker options.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77150



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


[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-04-04 Thread Matthew Riley via Phabricator via cfe-commits
mattdr added inline comments.



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:318
+}
+auto *VertexArray = new Node[VertexSize + 1 /* terminator node */];
+auto *EdgeArray = new Edge[EdgeSize];

sconstab wrote:
> mattdr wrote:
> > As a general rule `new` is a code-smell in modern C++. This should be a 
> > `vector`.
> @mattdr I do agree with the general rule. I also think that in this case 
> where the structure is immutable, std::vector is wasteful because it needs to 
> keep separate values for the current number of elements and the current 
> capacity. At local scope within a function the unneeded value would likely be 
> optimized away, but then there would be an awkward handoff to transfer the 
> data from the vector to the array members.
> 
> I would not want to see the array members changed to vectors, unless LLVM 
> provides an encapsulated array structure that does not need to grow and 
> shrink.
So, first: I'm glad you removed the unnecessary use of `new[]` here and the 
corresponding (and error-prone!) use of `delete[]` later. That removes a memory 
leak LLVM won't have to debug.

You suggest here that something other than `std::vector` would be more 
efficient. If so, would `std::array` suffice? If not, can you explain why 
static allocation is impossible but dynamic allocation would be too expensive?



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:13
+/// The advantages to this implementation are two-fold:
+/// 1. Iteration and traversal operations should experience terrific caching
+///performance.

erm, "terrific"? If there's a substantive argument w.r.t. cache locality etc., 
please make it explicit.



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:16
+/// 2. Set representations and operations on nodes and edges become
+///extraordinarily efficient. For instance, a set of edges is implemented 
as
+///a bit vector, wherein each bit corresponds to one edge in the edge

"extraordinarily" is, again, not a useful engineering categorization. Please 
restrict comments to describing quantifiable claims of complexity.



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:40
+
+template 
+class ImmutableGraph {

Every template argument for a class represents combinatorial addition of 
complexity for the resulting code. Why do each of these template arguments need 
to exist? in particular, why does SizeT need to exist?


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

https://reviews.llvm.org/D75936



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


[PATCH] D77374: Fix -fsanitize=array-bounds with comma operator

2020-04-04 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 255016.
vitalybuka added a comment.

try arc diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77374

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/bounds-checking.c
  clang/test/CodeGen/bounds-checking.cpp


Index: clang/test/CodeGen/bounds-checking.cpp
===
--- clang/test/CodeGen/bounds-checking.cpp
+++ clang/test/CodeGen/bounds-checking.cpp
@@ -98,3 +98,19 @@
   return s->a[i];
   // CHECK: }
 }
+
+// CHECK-LABEL: define {{.*}} @_Z10SFlexComma
+int SFlexComma(struct SFlex *s, int i) {
+  // a and b are treated as flexible array members.
+  // CHECK-NOT: @llvm.trap
+  return (s->t, s->a)[i];
+  // CHECK: }
+}
+
+// CHECK-LABEL: define {{.*}} @_Z7S1Comma
+int S1Comma(struct S1 *s, int i) {
+  // a and b are treated as flexible array members.
+  // CHECK-NOT: @llvm.trap
+  return ((s->t, (1, s->a)))[i];
+  // CHECK: }
+}
Index: clang/test/CodeGen/bounds-checking.c
===
--- clang/test/CodeGen/bounds-checking.c
+++ clang/test/CodeGen/bounds-checking.c
@@ -100,3 +100,19 @@
   return s->a[i];
   // CHECK: }
 }
+
+// CHECK-LABEL: define {{.*}} @SFlexComma
+int SFlexComma(struct SFlex *s, int i) {
+  // a and b are treated as flexible array members.
+  // CHECK-NOT: @llvm.trap
+  return (s->t, s->a)[i];
+  // CHECK: }
+}
+
+// CHECK-LABEL: define {{.*}} @S1Comma
+int S1Comma(struct S1 *s, int i) {
+  // a and b are treated as flexible array members.
+  // CHECK-NOT: @llvm.trap
+  return (s->t, s->a)[i];
+  // CHECK: }
+}
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -879,6 +879,13 @@
 
   E = E->IgnoreParens();
 
+  while (const BinaryOperator *BO = dyn_cast(E)) {
+if (!BO->isCommaOp())
+  break;
+E = BO->getRHS();
+E = E->IgnoreParens();
+  }
+
   // A flexible array member must be the last member in the class.
   if (const auto *ME = dyn_cast(E)) {
 // FIXME: If the base type of the member expr is not FD->getParent(),


Index: clang/test/CodeGen/bounds-checking.cpp
===
--- clang/test/CodeGen/bounds-checking.cpp
+++ clang/test/CodeGen/bounds-checking.cpp
@@ -98,3 +98,19 @@
   return s->a[i];
   // CHECK: }
 }
+
+// CHECK-LABEL: define {{.*}} @_Z10SFlexComma
+int SFlexComma(struct SFlex *s, int i) {
+  // a and b are treated as flexible array members.
+  // CHECK-NOT: @llvm.trap
+  return (s->t, s->a)[i];
+  // CHECK: }
+}
+
+// CHECK-LABEL: define {{.*}} @_Z7S1Comma
+int S1Comma(struct S1 *s, int i) {
+  // a and b are treated as flexible array members.
+  // CHECK-NOT: @llvm.trap
+  return ((s->t, (1, s->a)))[i];
+  // CHECK: }
+}
Index: clang/test/CodeGen/bounds-checking.c
===
--- clang/test/CodeGen/bounds-checking.c
+++ clang/test/CodeGen/bounds-checking.c
@@ -100,3 +100,19 @@
   return s->a[i];
   // CHECK: }
 }
+
+// CHECK-LABEL: define {{.*}} @SFlexComma
+int SFlexComma(struct SFlex *s, int i) {
+  // a and b are treated as flexible array members.
+  // CHECK-NOT: @llvm.trap
+  return (s->t, s->a)[i];
+  // CHECK: }
+}
+
+// CHECK-LABEL: define {{.*}} @S1Comma
+int S1Comma(struct S1 *s, int i) {
+  // a and b are treated as flexible array members.
+  // CHECK-NOT: @llvm.trap
+  return (s->t, s->a)[i];
+  // CHECK: }
+}
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -879,6 +879,13 @@
 
   E = E->IgnoreParens();
 
+  while (const BinaryOperator *BO = dyn_cast(E)) {
+if (!BO->isCommaOp())
+  break;
+E = BO->getRHS();
+E = E->IgnoreParens();
+  }
+
   // A flexible array member must be the last member in the class.
   if (const auto *ME = dyn_cast(E)) {
 // FIXME: If the base type of the member expr is not FD->getParent(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77456: [clangd] Parse `foo` in documentation comments and render as code.

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

LGTM, thanks!

Regarding spaces between code and text chunks, are you suggesting we should 
print:

  Tests primality of`p`

if so, i do believe having a space before the backtick vs not having it is two 
totally different rendering decisions. And I think the former is more common, 
why do you think we should not put that space?
I suppose we can modify the spacing logic for markdown to only put a separator 
between same chunk types, but I don't think that'll look any better especially 
in plugins like coc.nvim.




Comment at: clang-tools-extra/clangd/Hover.cpp:840
+void parseDocumentationLine(llvm::StringRef Line, markup::Paragraph &Out) {
+  // Probably this is appendText(Input), but scan for something interesting.
+  for (unsigned I = 0; I < Line.size(); ++I) {

nit: s/Input/Line/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77456



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


[PATCH] D77456: [clangd] Parse `foo` in documentation comments and render as code.

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

> But I'm wondering how good an idea this is for plaintext: "Returns 'foo' on 
> failure" is better than "Returns foo on failure", right? (With backticks 
> instead of single quotes, phab is eating my formatting)

ah sorry missed that one.

That's actually a good point, I didn't dwell on it too much because I don't 
think having backticks in plaintext is that useful. But thinking about it again 
some people might find it useful especially in long
documentations to figure out which parts of it to focus on. So this might be a 
regression for them, it would be nice to have some feedback mechanism for 
driving such decisions. So far it has been just
the reviewer and the author of the patch :D

So having a `raw` paragraph chunk(in addition to plaintext and inline code). 
might be a middle ground here.  Plaintext renderers will keep showing the 
documentation as it is written in the source code,
including backticks, whereas markdown renderers would display a more `rich` 
text. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77456



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


[PATCH] D77458: [clang-tools-extra] NFC: Fix trivial typo in documents and comments

2020-04-04 Thread Kazuaki Ishizaki via Phabricator via cfe-commits
kiszk created this revision.
Herald added subscribers: cfe-commits, phosek, usaxena95, kadircet, jfb, 
arphaman, jkorous, kbarton, nemanjai.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77458

Files:
  clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
  clang-tools-extra/clang-change-namespace/ChangeNamespace.h
  clang-tools-extra/clang-doc/Generators.cpp
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-include-fixer/IncludeFixer.h
  clang-tools-extra/clang-include-fixer/IncludeFixerContext.h
  clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
  
clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py
  clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
  clang-tools-extra/clang-move/Move.cpp
  clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
  clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
  clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
  clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/FoldInitTypeCheck.cpp
  
clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
  clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h
  clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
  clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
  clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
  clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
  clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/FindSymbols.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/PathMapping.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/QueryDriverDatabase.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolOrigin.h
  clang-tools-extra/clangd/index/dex/Trigram.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp
  clang-tools-extra/clangd/unittests/PathMappingTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp
  clang-tools-extra/docs/clang-tidy/checks/abseil-no-internal-dependencies.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-pointer-arithmetic-in-alloc.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-vector-operation.r

[PATCH] D77458: [clang-tools-extra] NFC: Fix trivial typo in documents and comments

2020-04-04 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.
Herald added a subscriber: wuzish.

You used codespell for this?
Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77458



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


[PATCH] D77385: [clangd] Add index export to dexp

2020-04-04 Thread Mark Nauwelaerts via Phabricator via cfe-commits
mnauw updated this revision to Diff 255019.
mnauw retitled this revision from "[clangd] Add index inspection helper tool" 
to "[clangd] Add index export to dexp".
mnauw edited the summary of this revision.

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

https://reviews.llvm.org/D77385

Files:
  clang-tools-extra/clangd/index/YAMLSerialization.cpp
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp

Index: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -25,6 +25,10 @@
 namespace clangd {
 namespace {
 
+static llvm::cl::opt
+Export("export", llvm::cl::desc("Export index non-interactively"),
+   llvm::cl::init(false));
+
 llvm::cl::opt IndexPath("index-path",
  llvm::cl::desc("Path to the index"),
  llvm::cl::Positional, llvm::cl::Required);
@@ -252,6 +256,44 @@
   }
 };
 
+class ExportImpl {
+  llvm::cl::opt Format{
+  "format", llvm::cl::desc("Format of index export"),
+  llvm::cl::values(
+  clEnumValN(IndexFileFormat::YAML, "yaml",
+ "human-readable YAML format"),
+  clEnumValN(IndexFileFormat::RIFF, "binary", "binary RIFF format")),
+  llvm::cl::init(IndexFileFormat::YAML)};
+
+public:
+  int dump() {
+using namespace clang::clangd;
+// Read input file (as specified in global option)
+auto Buffer = llvm::MemoryBuffer::getFile(IndexPath);
+if (!Buffer) {
+  llvm::errs() << llvm::formatv("Can't open {0}", IndexPath) << "\n";
+  return 1;
+}
+
+// Auto-detects input format when parsing
+auto IndexIn = clang::clangd::readIndexFile(Buffer->get()->getBuffer());
+if (!IndexIn) {
+  llvm::errs() << llvm::toString(IndexIn.takeError()) << "\n";
+  return 1;
+}
+
+// Dump output file
+clang::clangd::IndexFileOut IndexOut(IndexIn.get());
+IndexOut.Format = Format;
+llvm::outs() << IndexOut;
+return 0;
+  }
+};
+
+class ExportCmd : public ExportImpl, public Command {
+  void run() override { dump(); }
+};
+
 struct {
   const char *Name;
   const char *Description;
@@ -262,6 +304,7 @@
  std::make_unique},
 {"refs", "Find references by ID or qualified name",
  std::make_unique},
+{"export", "Export index", std::make_unique},
 };
 
 std::unique_ptr openIndex(llvm::StringRef Index) {
@@ -275,10 +318,20 @@
 int main(int argc, const char *argv[]) {
   using namespace clang::clangd;
 
+  // Make Export command option(s) available on command line.
+  // That allows for convenient (piping/redirecting) a dump non-interactively
+  // without passing through REPL.
+  auto NonInteractiveExport = std::make_unique();
   llvm::cl::ParseCommandLineOptions(argc, argv, Overview);
-  llvm::cl::ResetCommandLineParser(); // We reuse it for REPL commands.
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
+  if (Export)
+return NonInteractiveExport->dump();
+
+  // Back to normal
+  llvm::cl::ResetCommandLineParser(); // We reuse it for REPL commands.
+  NonInteractiveExport.reset();
+
   std::unique_ptr Index;
   reportTime("Dex build", [&]() {
 Index = openIndex(IndexPath);
Index: clang-tools-extra/clangd/index/YAMLSerialization.cpp
===
--- clang-tools-extra/clangd/index/YAMLSerialization.cpp
+++ clang-tools-extra/clangd/index/YAMLSerialization.cpp
@@ -41,6 +41,8 @@
   llvm::Optional Symbol;
   llvm::Optional Refs;
   llvm::Optional Relation;
+  llvm::Optional Source;
+  llvm::Optional Cmd;
 };
 // A class helps YAML to serialize the 32-bit encoded position (Line&Column),
 // as YAMLIO can't directly map bitfields.
@@ -53,6 +55,9 @@
 namespace llvm {
 namespace yaml {
 
+using clang::clangd::FileDigest;
+using clang::clangd::IncludeGraph;
+using clang::clangd::IncludeGraphNode;
 using clang::clangd::Ref;
 using clang::clangd::RefKind;
 using clang::clangd::Relation;
@@ -65,6 +70,7 @@
 using clang::index::SymbolKind;
 using clang::index::SymbolLanguage;
 using clang::index::SymbolRole;
+using clang::tooling::CompileCommand;
 
 // Helper to (de)serialize the SymbolID. We serialize it as a hex string.
 struct NormalizedSymbolID {
@@ -308,6 +314,76 @@
   }
 };
 
+struct NormalizedSourceFlag {
+  NormalizedSourceFlag(IO &) {}
+  NormalizedSourceFlag(IO &, IncludeGraphNode::SourceFlag O) {
+Flag = static_cast(O);
+  }
+
+  IncludeGraphNode::SourceFlag denormalize(IO &) {
+return static_cast(Flag);
+  }
+
+  uint8_t Flag = 0;
+};
+
+struct NormalizedFileDigest {
+  NormalizedFileDigest(IO &) {}
+  NormalizedFileDigest(IO &, const FileDigest &Digest) {
+HexString = llvm::toHex(Digest);
+  }
+
+  static FileDigest fromRaw(llvm::StringRef Raw) {
+FileDigest Digest;
+assert(Raw.size() == sizeof(Digest));
+memcpy(Digest.data(), Raw.data(), 

[PATCH] D77085: [clang-tidy] Added support for validating configuration options

2020-04-04 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I added support for bools. The previous integer parsing behaviour is still 
there, however now it also responds to `true` or `false`.
This won't parse `True|TRUE|False|FALSE` etc as I wanted it to be in line with 
`.clang-format` configuration files for handling of bool.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77085



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


[PATCH] D77085: [clang-tidy] Added support for validating configuration options

2020-04-04 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 255023.
njames93 added a comment.

- Extended support for boolean types


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77085

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -1,6 +1,8 @@
 #include "ClangTidyOptions.h"
-#include "gtest/gtest.h"
+#include "ClangTidyCheck.h"
+#include "ClangTidyDiagnosticConsumer.h"
 #include "llvm/ADT/StringExtras.h"
+#include "gtest/gtest.h"
 
 namespace clang {
 namespace tidy {
@@ -97,6 +99,172 @@
 llvm::join(Options.ExtraArgsBefore->begin(),
Options.ExtraArgsBefore->end(), ","));
 }
+
+class TestCheck : public ClangTidyCheck {
+public:
+  TestCheck(ClangTidyContext *Context) : ClangTidyCheck("test", Context) {}
+
+  template  auto getLocal(Args &&... Arguments) {
+return Options.get(std::forward(Arguments)...);
+  }
+
+  template  auto getGlobal(Args &&... Arguments) {
+return Options.getLocalOrGlobal(std::forward(Arguments)...);
+  }
+
+  template 
+  auto getIntLocal(Args &&... Arguments) {
+return Options.get(std::forward(Arguments)...);
+  }
+
+  template 
+  auto getIntGlobal(Args &&... Arguments) {
+return Options.getLocalOrGlobal(std::forward(Arguments)...);
+  }
+};
+
+#define CHECK_VAL(Value, Expected) \
+  do { \
+auto Item = Value; \
+ASSERT_TRUE(!!Item);   \
+EXPECT_EQ(*Item, Expected);\
+  } while (false)
+
+#define CHECK_ERROR(Value, ErrorType, ExpectedMessage) \
+  do { \
+auto Item = Value; \
+ASSERT_FALSE(Item);\
+ASSERT_TRUE(Item.errorIsA());   \
+ASSERT_FALSE(llvm::handleErrors(   \
+Item.takeError(), [&](const ErrorType &Err) -> llvm::Error {   \
+  EXPECT_EQ(Err.message(), ExpectedMessage);   \
+  return llvm::Error::success();   \
+}));   \
+  } while (false)
+
+TEST(CheckOptionsValidation, MissingOptions) {
+  ClangTidyOptions Options;
+  ClangTidyContext Context(std::make_unique(
+  ClangTidyGlobalOptions(), Options));
+  TestCheck TestCheck(&Context);
+  CHECK_ERROR(TestCheck.getLocal("Opt"), MissingOptionError,
+  "option not found 'test.Opt'");
+  EXPECT_EQ(TestCheck.getLocal("Opt", "Unknown"), "Unknown");
+}
+
+TEST(CheckOptionsValidation, ValidIntOptions) {
+  ClangTidyOptions Options;
+  auto &CheckOptions = Options.CheckOptions;
+  CheckOptions["test.IntExpected1"] = "1";
+  CheckOptions["test.IntExpected2"] = "1WithMore";
+  CheckOptions["test.IntExpected3"] = "NoInt";
+  CheckOptions["GlobalIntExpected1"] = "1";
+  CheckOptions["GlobalIntExpected2"] = "NoInt";
+  CheckOptions["test.DefaultedIntInvalid"] = "NoInt";
+  CheckOptions["GlobalIntInvalid"] = "NoInt";
+  CheckOptions["test.BoolITrueValue"] = "1";
+  CheckOptions["test.BoolIFalseValue"] = "0";
+  CheckOptions["test.BoolTrueValue"] = "true";
+  CheckOptions["test.BoolFalseValue"] = "false";
+  CheckOptions["test.BoolUnparseable"] = "Nothing";
+  CheckOptions["test.BoolCaseMismatch"] = "True";
+
+  ClangTidyContext Context(std::make_unique(
+  ClangTidyGlobalOptions(), Options));
+  TestCheck TestCheck(&Context);
+
+#define CHECK_ERROR_INT(Name, Expected)\
+  CHECK_ERROR(Name, UnparseableIntegerOptionError, Expected)
+
+  CHECK_VAL(TestCheck.getIntLocal("IntExpected1"), 1);
+  CHECK_VAL(TestCheck.getIntGlobal("GlobalIntExpected1"), 1);
+  CHECK_ERROR_INT(TestCheck.getIntLocal("IntExpected2"),
+  "invalid configuration value '1WithMore' for option "
+  "'test.IntExpected2'; expected an integer value");
+  CHECK_ERROR_INT(TestCheck.getIntLocal("IntExpected3"),
+  "invalid configuration value 'NoInt' for option "
+  "'test.IntExpected3'; expected an integer value");
+  CHECK_ERROR_INT(TestCheck.getIntGlobal("GlobalIntExpected2"),
+  "invalid configura

[PATCH] D76606: [clang-tidy] Change checks that take enum configurations to use a new access method.

2020-04-04 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 255027.
njames93 added a comment.
Herald added subscribers: arphaman, kbarton, nemanjai.

- Change checks that take enum configurations to use a new access method.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76606

Files:
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
  clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
  clang-tools-extra/clang-tidy/utils/IncludeSorter.h
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
@@ -0,0 +1,15 @@
+// RUN: clang-tidy %s -checks=readability-identifier-naming \
+// RUN:   -config="{CheckOptions: [\
+// RUN:   {key: readability-identifier-naming.FunctionCase, value: camelback}, \
+// RUN:   {key: readability-identifier-naming.VariableCase, value: camelBack}, \
+// RUN:   {key: readability-identifier-naming.ClassCase, value: UUPER_CASE}, \
+// RUN:   {key: readability-identifier-naming.StructCase, value: CAMEL}, \
+// RUN:   {key: readability-identifier-naming.EnumCase, value: AnY_cASe}, \
+// RUN:   ]}" 2>&1 | FileCheck %s --implicit-check-not warning
+
+// CHECK-DAG: warning: invalid configuration value 'camelback' for option 'readability-identifier-naming.FunctionCase'; did you mean 'camelBack'?{{$}}
+// CHECK-DAG: warning: invalid configuration value 'UUPER_CASE' for option 'readability-identifier-naming.ClassCase'; did you mean 'UPPER_CASE'?{{$}}
+// Don't try to suggest an alternative for 'CAMEL'
+// CHECK-DAG: warning: invalid configuration value 'CAMEL' for option 'readability-identifier-naming.StructCase'{{$}}
+// This fails on the EditDistance, but as it matches ignoring case suggest the correct value
+// CHECK-DAG: warning: invalid configuration value 'AnY_cASe' for option 'readability-identifier-naming.EnumCase'; did you mean 'aNy_CasE'?{{$}}
Index: clang-tools-extra/clang-tidy/utils/IncludeSorter.h
===
--- clang-tools-extra/clang-tidy/utils/IncludeSorter.h
+++ clang-tools-extra/clang-tidy/utils/IncludeSorter.h
@@ -25,11 +25,7 @@
   /// Supported include styles.
   enum IncludeStyle { IS_LLVM = 0, IS_Google = 1 };
 
-  /// Converts "llvm" to ``IS_LLVM``, otherwise returns ``IS_Google``.
-  static IncludeStyle parseIncludeStyle(const std::string &Value);
-
-  /// Converts ``IncludeStyle`` to string representation.
-  static StringRef toString(IncludeStyle Style);
+  static ArrayRef> getMapping();
 
   /// The classifications of inclusions, in the order they should be sorted.
   enum IncludeKinds {
Index: clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
===
--- clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
+++ clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
@@ -275,13 +275,11 @@
   return Fixes;
 }
 
-IncludeSorter::IncludeStyle
-IncludeSorter::parseIncludeStyle(const std::string &Value) {
-  return Value == "llvm" ? IS_LLVM : IS_Google;
-}
-
-StringRef IncludeSorter::toString(IncludeStyle Style) {
-  return Style == IS_LLVM ? "llvm" : "google";
+llvm::ArrayRef>
+IncludeSorter::getMapping() {
+  static constexpr std::pair Mapping[] =
+  {{"llvm", IS_LLVM}, {"google", IS_Google}};
+  return makeArrayRef(Mapping);
 }
 
 } // namespace utils
Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -11,8 +11,10 @@
 #include "clang/AST/CXXInheritance.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/Error.h"
 #include "llvm/S

[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-04-04 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 255028.
craig.topper added a comment.

-Add edge_begin()/edge_end()/edges() to Node class. Hides the N+1 trick used to 
find the end of a Node's edges.
-Add nodes()/edges() and use range-based for loops.
-Stop using things in the traits class since it doesn't have range-based for 
loops.
-Const-correct as required since nodes()/edges() return an ArrayRef that ends 
up making the range for loops const.
-Use llvm::for_each instead of std::for_each.
-Rename Node::value()/Edge::value() to getValue() to align with llvm naming 
convention.


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

https://reviews.llvm.org/D75936

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/ImmutableGraph.h
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/O3-pipeline.ll
  llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll

Index: llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll
@@ -0,0 +1,129 @@
+; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown -x86-lvi-load-dot-verify -o %t < %s | FileCheck %s
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local i32 @test(i32* %untrusted_user_ptr, i32* %secret, i32 %secret_size) #0 {
+entry:
+  %untrusted_user_ptr.addr = alloca i32*, align 8
+  %secret.addr = alloca i32*, align 8
+  %secret_size.addr = alloca i32, align 4
+  %ret_val = alloca i32, align 4
+  %i = alloca i32, align 4
+  store i32* %untrusted_user_ptr, i32** %untrusted_user_ptr.addr, align 8
+  store i32* %secret, i32** %secret.addr, align 8
+  store i32 %secret_size, i32* %secret_size.addr, align 4
+  store i32 0, i32* %ret_val, align 4
+  call void @llvm.x86.sse2.lfence()
+  store i32 0, i32* %i, align 4
+  br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+  %0 = load i32, i32* %i, align 4
+  %1 = load i32, i32* %secret_size.addr, align 4
+  %cmp = icmp slt i32 %0, %1
+  br i1 %cmp, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+  %2 = load i32, i32* %i, align 4
+  %rem = srem i32 %2, 2
+  %cmp1 = icmp eq i32 %rem, 0
+  br i1 %cmp1, label %if.then, label %if.else
+
+if.then:  ; preds = %for.body
+  %3 = load i32*, i32** %secret.addr, align 8
+  %4 = load i32, i32* %ret_val, align 4
+  %idxprom = sext i32 %4 to i64
+  %arrayidx = getelementptr inbounds i32, i32* %3, i64 %idxprom
+  %5 = load i32, i32* %arrayidx, align 4
+  %6 = load i32*, i32** %untrusted_user_ptr.addr, align 8
+  store i32 %5, i32* %6, align 4
+  br label %if.end
+
+if.else:  ; preds = %for.body
+  %7 = load i32*, i32** %secret.addr, align 8
+  %8 = load i32, i32* %ret_val, align 4
+  %idxprom2 = sext i32 %8 to i64
+  %arrayidx3 = getelementptr inbounds i32, i32* %7, i64 %idxprom2
+  store i32 42, i32* %arrayidx3, align 4
+  br label %if.end
+
+if.end:   ; preds = %if.else, %if.then
+  %9 = load i32*, i32** %untrusted_user_ptr.addr, align 8
+  %10 = load i32, i32* %9, align 4
+  store i32 %10, i32* %ret_val, align 4
+  br label %for.inc
+
+for.inc:  ; preds = %if.end
+  %11 = load i32, i32* %i, align 4
+  %inc = add nsw i32 %11, 1
+  store i32 %inc, i32* %i, align 4
+  br label %for.cond
+
+for.end:  ; preds = %for.cond
+  %12 = load i32, i32* %ret_val, align 4
+  ret i32 %12
+}
+
+; CHECK:  digraph "Speculative gadgets for \"test\" function" {
+; CHECK-NEXT: label="Speculative gadgets for \"test\" function";
+; CHECK:  Node0x{{[0-9a-f]+}} [shape=record,color = green,label="{LFENCE\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 0];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{renamable $eax = MOV32rm %stack.4.i, 1, $noreg, 0, $noreg :: (dereferenceable load 4 from %ir.i)\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[color = red, style = "dashed"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{JCC_1 %bb.6, 13, implicit killed $eflags\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{CMP32rm killed renamable $eax, %stack.2.secret_size.addr, 1, $noreg, 0, $noreg, implicit-def $eflags :: (dereferenceab

[PATCH] D77184: Make it possible for lit.site.cfg to contain relative paths, and use it for llvm and clang

2020-04-04 Thread Carlos Alberto Enciso via Phabricator via cfe-commits
CarlosAlbertoEnciso added a comment.

In D77184#1960473 , @thakis wrote:

> I pushed Andrew's fix (thanks!) (with minor formatting tweaks) in 
> dbb0d8ecb3a024bd6817ebd8ad8c5c199a51d933 
>  . Let 
> me know if you still see issues.


It fixes the Windows issues when building from different drive. Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77184



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


[PATCH] D77458: [clang-tools-extra] NFC: Fix trivial typo in documents and comments

2020-04-04 Thread Kazuaki Ishizaki via Phabricator via cfe-commits
kiszk added a comment.

I used aspell for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77458



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


Re: [clang] 4ede887 - PR45402: Make the restrictions on constant evaluation of memcmp and

2020-04-04 Thread David Zarzycki via cfe-commits
Hi Richard,

This breaks libcxx. Can we please revert this or is a quick fix to libcxx 
possible?


FAIL: libc++ :: 
std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/compare.pass.cpp
 (58624 of 62672)
 TEST 'libc++ :: 
std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/compare.pass.cpp'
 FAILED 
Command: ['/p/tllvm/bin/clang++', '-o', 
'/tmp/_update_lc/t/projects/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/Output/compare.pass.cpp.o',
 '-x', 'c++', 
'/home/dave/s/lp/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/compare.pass.cpp',
 '-c', '-v', '-Werror=thread-safety', '-std=c++2a', '-include', 
'/home/dave/s/lp/libcxx/test/support/nasty_macros.h', '-nostdinc++', 
'-I/home/dave/s/lp/libcxx/include', 
'-I/tmp/_update_lc/t/projects/libcxx/include/c++build', 
'-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', 
'-I/home/dave/s/lp/libcxx/test/support', '-ftemplate-depth=270', 
'-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER', '-Wall', '-Wextra', '-Werror', 
'-Wuser-defined-warnings', '-Wshadow', '-Wno-unused-command-line-argument', 
'-Wno-attributes', '-Wno-pessimizing-move', '-Wno-c++11-extensions', 
'-Wno-user-defined-literals', '-Wno-noexcept-type', '-Wsign-compare', 
'-Wunused-variable', '-Wunused-parameter', '-Wunreachable-code', '-c']
Exit Code: 1
Standard Error:
--
clang version 11.0.0 (https://github.com/llvm/llvm-project.git 
22127da8f17c03c69231f3631472f7f99ad9cb7f)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /p/tllvm/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/9
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
 (in-process)
 "/p/tllvm/bin/clang-11" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj 
-mrelax-all -disable-free -disable-llvm-verifier -discard-value-names 
-main-file-name compare.pass.cpp -mrelocation-model static -mthread-model posix 
-mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases 
-munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining 
-debugger-tuning=gdb -v -nostdinc++ -resource-dir /p/tllvm/lib64/clang/11.0.0 
-include /home/dave/s/lp/libcxx/test/support/nasty_macros.h -I 
/home/dave/s/lp/libcxx/include -I 
/tmp/_update_lc/t/projects/libcxx/include/c++build -D __STDC_FORMAT_MACROS -D 
__STDC_LIMIT_MACROS -D __STDC_CONSTANT_MACROS -I 
/home/dave/s/lp/libcxx/test/support -D _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 
-internal-isystem /usr/local/include -internal-isystem 
/p/tllvm/lib64/clang/11.0.0/include -internal-externc-isystem /include 
-internal-externc-isystem /usr/include -Werror=thread-safety -Wall -Wextra 
-Werror -Wuser-defined-warnings -Wshadow -Wno-unused-command-line-argument 
-Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions 
-Wno-user-defined-literals -Wno-noexcept-type -Wsign-compare -Wunused-variable 
-Wunused-parameter -Wunreachable-code -std=c++2a -fdeprecated-macro 
-fdebug-compilation-dir 
/tmp/_update_lc/t/projects/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t
 -ftemplate-depth 270 -ferror-limit 19 -fgnuc-version=4.2.1 
-fno-implicit-modules -fcxx-exceptions -fexceptions -faddrsig -o 
/tmp/_update_lc/t/projects/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/Output/compare.pass.cpp.o
 -x c++ 
/home/dave/s/lp/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/compare.pass.cpp
clang -cc1 version 11.0.0 based upon LLVM 11.0.0git default target 
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/dave/s/lp/libcxx/include
 /tmp/_update_lc/t/projects/libcxx/include/c++build
 /home/dave/s/lp/libcxx/test/support
 /usr/local/include
 /p/tllvm/lib64/clang/11.0.0/include
 /usr/include
End of search list.
/home/dave/s/lp/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/compare.pass.cpp:53:19:
 error: static_assert expression is not an integral constant expression
static_assert(test_constexpr(), "" );
  ^~~~
/home/dave/s/lp/libcxx/include/__string:662:12: note: constant evaluation of 
'__builtin_memcmp' between arrays of types 'const char8_t' and 'const char8_t' 
is not supported; only arrays of narrow character types can be compared
return __builtin_memcmp(__s1, __s2, __n);
   ^
/home/dave/s/lp/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/compare.pass.cpp:24:12:
 note: in call to 'compare(&u8"123"[0], &u8"223"[0], 3)'
return std::char_traits::compare

[PATCH] D63616: Implement `-fsanitize-coverage-whitelist` and `-fsanitize-coverage-blacklist` for clang

2020-04-04 Thread Yannis Juglaret via Phabricator via cfe-commits
tuktuk updated this revision to Diff 255032.
tuktuk added a comment.

Thank you for your interest in this feature! It is unfortunate indeed that the 
patch was not merged when accepted, so here is an update that matches the 
current status of the code base.

Dear reviewers, can you please make sure that this time, the patch gets merged 
if accepted?
Also, this time I was unable to run the new test that this patch adds from 
within the test system, because of my limited understanding; so I gave up and 
followed the test myself, command by command.
Am I missing an additional step for test integration, after adding the test 
file?
Thanks a lot.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63616

Files:
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cc
  llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp

Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -35,6 +35,8 @@
 #include "llvm/InitializePasses.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/SpecialCaseList.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
@@ -185,8 +187,11 @@
 class ModuleSanitizerCoverage {
 public:
   ModuleSanitizerCoverage(
-  const SanitizerCoverageOptions &Options = SanitizerCoverageOptions())
-  : Options(OverrideFromCL(Options)) {}
+  const SanitizerCoverageOptions &Options = SanitizerCoverageOptions(),
+  const SpecialCaseList *Whitelist = nullptr,
+  const SpecialCaseList *Blacklist = nullptr)
+  : Options(OverrideFromCL(Options)), Whitelist(Whitelist),
+Blacklist(Blacklist) {}
   bool instrumentModule(Module &M, DomTreeCallback DTCallback,
 PostDomTreeCallback PDTCallback);
 
@@ -249,18 +254,32 @@
   SmallVector GlobalsToAppendToCompilerUsed;
 
   SanitizerCoverageOptions Options;
+
+  const SpecialCaseList *Whitelist;
+  const SpecialCaseList *Blacklist;
 };
 
 class ModuleSanitizerCoverageLegacyPass : public ModulePass {
 public:
   ModuleSanitizerCoverageLegacyPass(
-  const SanitizerCoverageOptions &Options = SanitizerCoverageOptions())
+  const SanitizerCoverageOptions &Options = SanitizerCoverageOptions(),
+  const std::vector &WhitelistFiles =
+  std::vector(),
+  const std::vector &BlacklistFiles =
+  std::vector())
   : ModulePass(ID), Options(Options) {
+if (WhitelistFiles.size() > 0)
+  Whitelist = SpecialCaseList::createOrDie(WhitelistFiles,
+   *vfs::getRealFileSystem());
+if (BlacklistFiles.size() > 0)
+  Blacklist = SpecialCaseList::createOrDie(BlacklistFiles,
+   *vfs::getRealFileSystem());
 initializeModuleSanitizerCoverageLegacyPassPass(
 *PassRegistry::getPassRegistry());
   }
   bool runOnModule(Module &M) override {
-ModuleSanitizerCoverage ModuleSancov(Options);
+ModuleSanitizerCoverage ModuleSancov(Options, Whitelist.get(),
+ Blacklist.get());
 auto DTCallback = [this](Function &F) -> const DominatorTree * {
   return &this->getAnalysis(F).getDomTree();
 };
@@ -281,6 +300,9 @@
 
 private:
   SanitizerCoverageOptions Options;
+
+  std::unique_ptr Whitelist;
+  std::unique_ptr Blacklist;
 };
 
 } // namespace
@@ -360,6 +382,12 @@
 Module &M, DomTreeCallback DTCallback, PostDomTreeCallback PDTCallback) {
   if (Options.CoverageType == SanitizerCoverageOptions::SCK_None)
 return false;
+  if (Whitelist &&
+  !Whitelist->inSection("coverage", "src", M.getSourceFileName()))
+return false;
+  if (Blacklist &&
+  Blacklist->inSection("coverage", "src", M.getSourceFileName()))
+return false;
   C = &(M.getContext());
   DL = &M.getDataLayout();
   CurModule = &M;
@@ -589,6 +617,10 @@
   if (F.hasPersonalityFn() &&
   isAsynchronousEHPersonality(classifyEHPersonality(F.getPersonalityFn(
 return;
+  if (Whitelist && !Whitelist->inSection("coverage", "fun", F.getName()))
+return;
+  if (Blacklist && Blacklist->inSection("coverage", "fun", F.getName()))
+return;
   if (Options.CoverageType >= Sa

[PATCH] D71739: [WIP] Use operand bundles to encode alignment assumptions

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

What's the status here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71739



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


[PATCH] D77461: [clang-tidy] Remove false positive in AvoidNonConstGlobalVariables

2020-04-04 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal added a comment.
Herald added a subscriber: wuzish.

After looking in to it I got less certain of where the error lies and 
eventually I got uncertain if this even is a false negative, so I started out 
with just posting a change where the unit test is updated to detect the issue.
This is just to have a start for a discussion of how this should actually work 
and what is the best way forward.

The purpose of the rule is to avoid code which causes hidden dependencies. The 
given example of a potential false positive is a free function with a static 
variable.
Now, wouldn't a static variable inside a function body make the function 
stateful thereby risking that the function gives different results for the same 
input, in ways that might look arbitrary or random to the caller.
I think that might actually be a good example of what the rule is meant to 
prevent so maybe this isn't a false positive after all?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77461



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


[PATCH] D77461: [clang-tidy] Remove false positive in AvoidNonConstGlobalVariables

2020-04-04 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal created this revision.
Herald added subscribers: cfe-commits, kbarton, xazax.hun, nemanjai.
Herald added a project: clang.
vingeldal added a comment.
Herald added a subscriber: wuzish.

After looking in to it I got less certain of where the error lies and 
eventually I got uncertain if this even is a false negative, so I started out 
with just posting a change where the unit test is updated to detect the issue.
This is just to have a start for a discussion of how this should actually work 
and what is the best way forward.

The purpose of the rule is to avoid code which causes hidden dependencies. The 
given example of a potential false positive is a free function with a static 
variable.
Now, wouldn't a static variable inside a function body make the function 
stateful thereby risking that the function gives different results for the same 
input, in ways that might look arbitrary or random to the caller.
I think that might actually be a good example of what the rule is meant to 
prevent so maybe this isn't a false positive after all?


There was a post merge comment about a possible false negative for this check:
https://reviews.llvm.org/D70265


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77461

Files:
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
@@ -231,7 +231,8 @@
 // CHECKING AGAINST FALSE POSITIVES INSIDE FUNCTION SCOPE /
 int main() {
   for (int i = 0; i < 3; ++i) {
+static int staticNonConstLoopVariable = 42;
 int nonConstLoopVariable = 42;
-nonConstInt = nonConstLoopVariable + i;
+nonConstInt = nonConstLoopVariable + i + staticNonConstLoopVariable;
   }
 }


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
@@ -231,7 +231,8 @@
 // CHECKING AGAINST FALSE POSITIVES INSIDE FUNCTION SCOPE /
 int main() {
   for (int i = 0; i < 3; ++i) {
+static int staticNonConstLoopVariable = 42;
 int nonConstLoopVariable = 42;
-nonConstInt = nonConstLoopVariable + i;
+nonConstInt = nonConstLoopVariable + i + staticNonConstLoopVariable;
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76990: [clang-tidy]: fix false positive of cert-oop54-cpp check.

2020-04-04 Thread Tamás Zolnai via Phabricator via cfe-commits
ztamas updated this revision to Diff 255038.
ztamas added a comment.

Add suggested test case and rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76990

Files:
  clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
@@ -212,6 +212,21 @@
   T *p;
 };
 
+// https://bugs.llvm.org/show_bug.cgi?id=44499
+class Foo2;
+template 
+bool operator!=(Foo2 &, Foo2 &) {
+  class Bar2 {
+Bar2 &operator=(const Bar2 &other) {
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: operator=() does not handle 
self-assignment properly [bugprone-unhandled-self-assignment]
+  p = other.p;
+  return *this;
+}
+
+int *p;
+  };
+}
+
 ///
 /// Test cases correctly ignored by the check.
 
@@ -283,6 +298,21 @@
   T *p;
 };
 
+// https://bugs.llvm.org/show_bug.cgi?id=44499
+class Foo;
+template 
+bool operator!=(Foo &, Foo &) {
+  class Bar {
+Bar &operator=(const Bar &other) {
+  if (this != &other) {
+  }
+  return *this;
+}
+
+int *p;
+  };
+}
+
 // There is no warning if the copy assignment operator gets the object by 
value.
 class PassedByValue {
 public:
Index: clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
@@ -40,9 +40,12 @@
 
   // Self-check: Code compares something with 'this' pointer. We don't check
   // whether it is actually the parameter what we compare.
-  const auto HasNoSelfCheck = cxxMethodDecl(unless(
+  const auto HasNoSelfCheck = cxxMethodDecl(unless(anyOf(
   hasDescendant(binaryOperator(hasAnyOperatorName("==", "!="),
-   has(ignoringParenCasts(cxxThisExpr()));
+   has(ignoringParenCasts(cxxThisExpr(),
+  hasDescendant(cxxOperatorCallExpr(
+  hasAnyOverloadedOperatorName("==", "!="), argumentCountIs(2),
+  has(ignoringParenCasts(cxxThisExpr(;
 
   // Both copy-and-swap and copy-and-move method creates a copy first and
   // assign it to 'this' with swap or move.


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
@@ -212,6 +212,21 @@
   T *p;
 };
 
+// https://bugs.llvm.org/show_bug.cgi?id=44499
+class Foo2;
+template 
+bool operator!=(Foo2 &, Foo2 &) {
+  class Bar2 {
+Bar2 &operator=(const Bar2 &other) {
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: operator=() does not handle self-assignment properly [bugprone-unhandled-self-assignment]
+  p = other.p;
+  return *this;
+}
+
+int *p;
+  };
+}
+
 ///
 /// Test cases correctly ignored by the check.
 
@@ -283,6 +298,21 @@
   T *p;
 };
 
+// https://bugs.llvm.org/show_bug.cgi?id=44499
+class Foo;
+template 
+bool operator!=(Foo &, Foo &) {
+  class Bar {
+Bar &operator=(const Bar &other) {
+  if (this != &other) {
+  }
+  return *this;
+}
+
+int *p;
+  };
+}
+
 // There is no warning if the copy assignment operator gets the object by value.
 class PassedByValue {
 public:
Index: clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
@@ -40,9 +40,12 @@
 
   // Self-check: Code compares something with 'this' pointer. We don't check
   // whether it is actually the parameter what we compare.
-  const auto HasNoSelfCheck = cxxMethodDecl(unless(
+  const auto HasNoSelfCheck = cxxMethodDecl(unless(anyOf(
   hasDescendant(binaryOperator(hasAnyOperatorName("==", "!="),
-   has(ignoringParenCasts(cxxThisExpr()));
+   has(ignoringParenCasts(cxxThisExpr(),
+  hasDescendant(cxxOperatorCallExpr(
+  hasAnyOverloadedOperatorName("==", "!="), argumentCountIs(2),
+  has(ignoringParenCasts(cxxThisExpr(;

[PATCH] D77113: [OpenMP][NFC] Move and simplify directive -> allowed clause mapping

2020-04-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 255041.
jdoerfert added a comment.
Herald added subscribers: yaxunl, mgorny.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77113

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/Transformer/CMakeLists.txt
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/ASTMatchers/CMakeLists.txt
  clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
  clang/unittests/Analysis/CMakeLists.txt
  clang/unittests/Rename/CMakeLists.txt
  clang/unittests/Sema/CMakeLists.txt
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/Tooling/CMakeLists.txt
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPConstants.cpp

Index: llvm/lib/Frontend/OpenMP/OMPConstants.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPConstants.cpp
+++ llvm/lib/Frontend/OpenMP/OMPConstants.cpp
@@ -54,6 +54,17 @@
   llvm_unreachable("Invalid OpenMP clause kind");
 }
 
+bool llvm::omp::isAllowedClauseForDirective(Directive D, Clause C,
+unsigned Version) {
+  assert(unsigned(D) <= unsigned(OMPD_unknown));
+  assert(unsigned(C) <= unsigned(OMPC_unknown));
+#define OMP_DIRECTIVE_CLAUSE(Dir, MinVersion, MaxVersion, Cl)  \
+  if (D == Dir && C == Cl && MinVersion <= Version && MaxVersion >= Version)   \
+return true;
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
+  return false;
+}
+
 /// Declarations for LLVM-IR types (simple, array, function and structure) are
 /// generated below. Their names are defined and used in OpenMPKinds.def. Here
 /// we provide the declarations, the initializeTypes function will provide the
Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -710,3 +710,732 @@
 #undef __OMP_REQUIRES_TRAIT
 #undef OMP_REQUIRES_TRAIT
 ///}
+
+
+/// Clauses allowed per directive
+///
+///{
+
+#ifndef OMP_DIRECTIVE_CLAUSE
+#define OMP_DIRECTIVE_CLAUSE(Directive, MinVersion, MaxVersion, Clause)
+#endif
+
+#define __OMP_DIRECTIVE_CLAUSE(Directive, MinVersion, MaxVersion, Clause)  \
+  OMP_DIRECTIVE_CLAUSE(OMPD_##Directive, unsigned(MinVersion), \
+   unsigned(MaxVersion), OMPC_##Clause)
+
+__OMP_DIRECTIVE_CLAUSE(scan, 50, ~0, inclusive)
+__OMP_DIRECTIVE_CLAUSE(scan, 50, ~0, exclusive)
+
+__OMP_DIRECTIVE_CLAUSE(parallel, 1, ~0, if)
+__OMP_DIRECTIVE_CLAUSE(parallel, 1, ~0, num_threads)
+__OMP_DIRECTIVE_CLAUSE(parallel, 1, ~0, default)
+__OMP_DIRECTIVE_CLAUSE(parallel, 1, ~0, proc_bind)
+__OMP_DIRECTIVE_CLAUSE(parallel, 1, ~0, private)
+__OMP_DIRECTIVE_CLAUSE(parallel, 1, ~0, firstprivate)
+__OMP_DIRECTIVE_CLAUSE(parallel, 1, ~0, shared)
+__OMP_DIRECTIVE_CLAUSE(parallel, 1, ~0, reduction)
+__OMP_DIRECTIVE_CLAUSE(parallel, 1, ~0, copyin)
+__OMP_DIRECTIVE_CLAUSE(parallel, 1, ~0, allocate)
+
+__OMP_DIRECTIVE_CLAUSE(simd, 1, ~0, private)
+__OMP_DIRECTIVE_CLAUSE(simd, 1, ~0, lastprivate)
+__OMP_DIRECTIVE_CLAUSE(simd, 1, ~0, linear)
+__OMP_DIRECTIVE_CLAUSE(simd, 1, ~0, aligned)
+__OMP_DIRECTIVE_CLAUSE(simd, 1, ~0, safelen)
+__OMP_DIRECTIVE_CLAUSE(simd, 1, ~0, simdlen)
+__OMP_DIRECTIVE_CLAUSE(simd, 1, ~0, collapse)
+__OMP_DIRECTIVE_CLAUSE(simd, 1, ~0, reduction)
+__OMP_DIRECTIVE_CLAUSE(simd, 1, ~0, allocate)
+__OMP_DIRECTIVE_CLAUSE(simd, 50, ~0, if)
+__OMP_DIRECTIVE_CLAUSE(simd, 50, ~0, nontemporal)
+__OMP_DIRECTIVE_CLAUSE(simd, 50, ~0, order)
+
+__OMP_DIRECTIVE_CLAUSE(for, 1, ~0, private)
+__OMP_DIRECTIVE_CLAUSE(for, 1, ~0, lastprivate)
+__OMP_DIRECTIVE_CLAUSE(for, 1, ~0, firstprivate)
+__OMP_DIRECTIVE_CLAUSE(for, 1, ~0, reduction)
+__OMP_DIRECTIVE_CLAUSE(for, 1, ~0, collapse)
+__OMP_DIRECTIVE_CLAUSE(for, 1, ~0, schedule)
+__OMP_DIRECTIVE_CLAUSE(for, 1, ~0, ordered)
+__OMP_DIRECTIVE_CLAUSE(for, 1, ~0, nowait)
+__OMP_DIRECTIVE_CLAUSE(for, 1, ~0, linear)
+__OMP_DIRECTIVE_CLAUSE(for, 1, ~0, allocate)
+__OMP_DIRECTIVE_CLAUSE(for, 50, ~0, order)
+
+__OMP_DIRECTIVE_CLAUSE(for_simd, 1, ~0, private)
+__OMP_DIRECTIVE_CLAUSE(for_simd, 1, ~0, firstprivate)
+__OMP_DIRECTIVE_CLAUSE(for_simd, 1, ~0, lastprivate)
+__OMP_DIRECTIVE_CLAUSE(for_simd, 1, ~0, reduction)
+__OMP_DIRECTIVE_CLAUSE(for_simd, 1, ~0, schedule)
+__OMP_DIRECTIVE_CLAUSE(for_simd, 1, ~0, collapse)
+__OMP_DIRECTIVE_CLAUSE(for_simd, 1, ~0, nowait)
+__OMP_DIRECTIVE_CLAUSE(for_simd, 1, ~0, safelen)
+__OMP_DIRECTIVE_CLAUSE(for_simd, 1, ~0, simdlen)
+__OMP_DIRECTIVE_CLAUSE(for_simd, 1, ~0, linear)
+__OMP_DIRECTIVE_CLAUSE(for_simd, 1, ~0, alig

[PATCH] D77184: Make it possible for lit.site.cfg to contain relative paths, and use it for llvm and clang

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

In D77184#1961220 , @rsmith wrote:

> In D77184#1961214 , @rsmith wrote:
>
> > In D77184#1961208 , @rsmith wrote:
> >
> > > This has broken my ability to run the `check-clang` target on Linux. 
> > > There are symlinks in the path from which I run my builds, and this patch 
> > > is computing incorrect relative paths in that situation.
> >
> >
> > This patch appears to fix the problem:
>
>
> Turns out that's only a partial fix (it fixes `ninja clang-check` but not the 
> general problem). Running `lit` from inside the source directory is still 
> broken. Eg, this used to work:
>
>   clang/test$ $BUILDDIR/bin/llvm-lit SemaCXX/constant-expression.cpp
>
>
> ... and doesn't work any more because the relative paths in `lit.site.cfg.py` 
> don't seem to resolve to the right places. Please can you fix or revert?


Can you describe your symlink setup in enough detail that I can recreate it 
locally please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77184



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


[PATCH] D76996: [analyzer] Improve PlacementNewChecker

2020-04-04 Thread Karasev Nikita via Phabricator via cfe-commits
f00kat updated this revision to Diff 255039.
f00kat added a comment.

1. Maybe build fix
2. Added tests for nested arrays of structures
3. Fixed bugs in implementation for ElementRegion cases


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

https://reviews.llvm.org/D76996

Files:
  clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
  clang/test/Analysis/placement-new.cpp

Index: clang/test/Analysis/placement-new.cpp
===
--- clang/test/Analysis/placement-new.cpp
+++ clang/test/Analysis/placement-new.cpp
@@ -155,3 +155,312 @@
   (void)dp;
 }
 } // namespace testHierarchy
+
+namespace testArrayTypesAllocation {
+void f1() {
+  struct S {
+short a;
+  };
+
+  // bad (not enough space).
+  const unsigned N = 32;
+  alignas(S) unsigned char buffer1[sizeof(S) * N]; // expected-note {{'buffer1' initialized here}}
+  ::new (buffer1) S[N];// expected-warning{{Storage provided to placement new is only 64 bytes, whereas the allocated array type requires more space for internal needs}} expected-note 1 {{}}
+}
+
+void f2() {
+  struct S {
+short a;
+  };
+
+  // maybe ok but we need to warn.
+  const unsigned N = 32;
+  alignas(S) unsigned char buffer2[sizeof(S) * N + sizeof(int)]; // expected-note {{'buffer2' initialized here}}
+  ::new (buffer2) S[N];  // expected-warning{{68 bytes is possibly not enough for array allocation which requires 64 bytes. Current overhead requires the size of 4 bytes}} expected-note 1 {{}}
+}
+} // namespace testArrayTypesAllocation
+
+namespace testStructAlign {
+void f1() {
+  struct X {
+char a[9];
+  } Xi; // expected-note {{'Xi' initialized here}}
+
+  // bad (struct X is aligned to char).
+  ::new (&Xi.a) long; // expected-warning{{Storage type is aligned to 1 bytes but allocated type is aligned to 8 bytes}} expected-note 1 {{}}
+}
+
+void f2() {
+  struct X {
+char a;
+char b;
+long c;
+  } Xi;
+
+  // ok (struct X is aligned to long).
+  ::new (&Xi.a) long;
+}
+
+void f3() {
+  struct X {
+char a;
+char b;
+long c;
+  } Xi; // expected-note {{'Xi' initialized here}}
+
+  // bad (struct X is aligned to long but field 'b' is aligned to 1 because of its offset)
+  ::new (&Xi.b) long; // expected-warning{{Storage type is aligned to 1 bytes but allocated type is aligned to 8 bytes}} expected-note 1 {{}}
+}
+
+void f4() {
+  struct X {
+char a;
+struct alignas(alignof(short)) Y {
+  char b;
+  char c;
+} y;
+long d;
+  } Xi; // expected-note {{'Xi' initialized here}}
+
+  // bad. 'b' is aligned to short
+  ::new (&Xi.y.b) long; // expected-warning{{Storage type is aligned to 2 bytes but allocated type is aligned to 8 bytes}} expected-note 1 {{}}
+}
+
+void f5() {
+  short b[10]; // expected-note {{'b' initialized here}}
+
+  ::new (&b) long; // expected-warning{{Storage type is aligned to 2 bytes but allocated type is aligned to 8 bytes}} expected-note 1 {{}}
+}
+
+void f6() {
+  short b[10]; // expected-note {{'b' initialized here}}
+
+  // bad (same as previous but checks ElementRegion case)
+  ::new (&b[0]) long; // expected-warning{{Storage type is aligned to 2 bytes but allocated type is aligned to 8 bytes}} expected-note 1 {{}}
+}
+
+void f7() {
+  short b[10];
+
+  // ok. 2(short align) + 3*2(index '3' offset)
+  ::new (&b[3]) long;
+}
+
+void f8() {
+  short b[10]; // expected-note {{'b' initialized here}}
+
+  // bad. 2(short align) + 2*2(index '2' offset)
+  ::new (&b[2]) long; // expected-warning{{Storage type is aligned to 6 bytes but allocated type is aligned to 8 bytes}} expected-note 1 {{}}
+}
+
+void f9() {
+  struct X {
+char a;
+alignas(alignof(short)) char b[20];
+  } Xi; // expected-note {{'Xi' initialized here}}
+
+  // ok 2(custom align) + 6*1(index '6' offset)
+  ::new (&Xi.b[6]) long;
+
+  // bad 2(custom align) + 1*1(index '1' offset)
+  ::new (&Xi.b[1]) long; // expected-warning{{Storage type is aligned to 3 bytes but allocated type is aligned to 8 bytes}} expected-note 1 {{}}
+}
+
+void f10() {
+  struct X {
+char a[8];
+alignas(2) char b;
+  } Xi; // expected-note {{'Xi' initialized here}}
+
+  // bad (struct X is aligned to 2).
+  ::new (&Xi.a) long; // expected-warning{{Storage type is aligned to 2 bytes but allocated type is aligned to 8 bytes}} expected-note 1 {{}}
+}
+
+void f11() {
+  struct X {
+char a;
+char b;
+struct Y {
+  long c;
+} d;
+  } Xi;
+
+  // ok (struct X is aligned to long).
+  ::new (&Xi.a) long;
+}
+
+void f12() {
+  struct alignas(alignof(long)) X {
+char a;
+char b;
+  } Xi;
+
+  // ok (struct X is aligned to long).
+  ::new (&Xi.a) long;
+}
+
+void test13() {
+  struct Y {
+char a[10];
+  };
+
+  struct X {
+Y b[10];
+  } Xi; // expected-note {{'Xi' initialized here}}
+
+  // bad. X,A are aligned to 'char'
+  ::new (&Xi.b[0].a) long;  // expected-warning{{Storage type is

[clang-tools-extra] 0f9e1e3 - [clang-tidy]: fix false positive of cert-oop54-cpp check.

2020-04-04 Thread Tamás Zolnai via cfe-commits

Author: Tamás Zolnai
Date: 2020-04-04T17:19:17+02:00
New Revision: 0f9e1e3ae750df483b7fff905a8bc89262e3179e

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

LOG: [clang-tidy]: fix false positive of cert-oop54-cpp check.

Summary:
It seems we need a different matcher for binary operator
in a template context.

Fixes this issue:
https://bugs.llvm.org/show_bug.cgi?id=44499

Reviewers: aaron.ballman, alexfh, hokein, njames93

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
index f2de9fbde2a6..d91353e21fb1 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
@@ -40,9 +40,12 @@ void 
UnhandledSelfAssignmentCheck::registerMatchers(MatchFinder *Finder) {
 
   // Self-check: Code compares something with 'this' pointer. We don't check
   // whether it is actually the parameter what we compare.
-  const auto HasNoSelfCheck = cxxMethodDecl(unless(
+  const auto HasNoSelfCheck = cxxMethodDecl(unless(anyOf(
   hasDescendant(binaryOperator(hasAnyOperatorName("==", "!="),
-   has(ignoringParenCasts(cxxThisExpr()));
+   has(ignoringParenCasts(cxxThisExpr(),
+  hasDescendant(cxxOperatorCallExpr(
+  hasAnyOverloadedOperatorName("==", "!="), argumentCountIs(2),
+  has(ignoringParenCasts(cxxThisExpr(;
 
   // Both copy-and-swap and copy-and-move method creates a copy first and
   // assign it to 'this' with swap or move.

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
index 49bb5314f9eb..fb7c089ae8cd 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
@@ -212,6 +212,21 @@ class WrongTemplateCopyAndMove {
   T *p;
 };
 
+// https://bugs.llvm.org/show_bug.cgi?id=44499
+class Foo2;
+template 
+bool operator!=(Foo2 &, Foo2 &) {
+  class Bar2 {
+Bar2 &operator=(const Bar2 &other) {
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: operator=() does not handle 
self-assignment properly [bugprone-unhandled-self-assignment]
+  p = other.p;
+  return *this;
+}
+
+int *p;
+  };
+}
+
 ///
 /// Test cases correctly ignored by the check.
 
@@ -283,6 +298,21 @@ class TemplateSelfCheck {
   T *p;
 };
 
+// https://bugs.llvm.org/show_bug.cgi?id=44499
+class Foo;
+template 
+bool operator!=(Foo &, Foo &) {
+  class Bar {
+Bar &operator=(const Bar &other) {
+  if (this != &other) {
+  }
+  return *this;
+}
+
+int *p;
+  };
+}
+
 // There is no warning if the copy assignment operator gets the object by 
value.
 class PassedByValue {
 public:



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


[PATCH] D71739: [WIP] Use operand bundles to encode alignment assumptions

2020-04-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

@lebedev.ri  We'd need to identify other uses of the alignment encoding in-tree 
so we can replace them as well. Also, this patch uses not only the alignment 
but also the offset in the operand bundle. We can either allow that or encode 
the offset via a gep in the IR. I guess the latter is easier to implement until 
we have more reasons to allow more complex operand bundles (which we will need 
to have eventually).

@Tyker Do you want to take this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71739



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


[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-04-04 Thread Scott Constable via Phabricator via cfe-commits
sconstab added inline comments.



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:318
+}
+auto *VertexArray = new Node[VertexSize + 1 /* terminator node */];
+auto *EdgeArray = new Edge[EdgeSize];

mattdr wrote:
> sconstab wrote:
> > mattdr wrote:
> > > As a general rule `new` is a code-smell in modern C++. This should be a 
> > > `vector`.
> > @mattdr I do agree with the general rule. I also think that in this case 
> > where the structure is immutable, std::vector is wasteful because it needs 
> > to keep separate values for the current number of elements and the current 
> > capacity. At local scope within a function the unneeded value would likely 
> > be optimized away, but then there would be an awkward handoff to transfer 
> > the data from the vector to the array members.
> > 
> > I would not want to see the array members changed to vectors, unless LLVM 
> > provides an encapsulated array structure that does not need to grow and 
> > shrink.
> So, first: I'm glad you removed the unnecessary use of `new[]` here and the 
> corresponding (and error-prone!) use of `delete[]` later. That removes a 
> memory leak LLVM won't have to debug.
> 
> You suggest here that something other than `std::vector` would be more 
> efficient. If so, would `std::array` suffice? If not, can you explain why 
> static allocation is impossible but dynamic allocation would be too expensive?
A statically sized array (e.g., std::array) is insufficient because the size in 
this case is not compiler determinable; a dynamically sized and dynamically 
resizable array (e.g., std::vector) is sufficient but overly costly; a 
dynamically sized and dynamically //unresizable// array is sufficient and has 
minimal cost.



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:13
+/// The advantages to this implementation are two-fold:
+/// 1. Iteration and traversal operations should experience terrific caching
+///performance.

mattdr wrote:
> erm, "terrific"? If there's a substantive argument w.r.t. cache locality 
> etc., please make it explicit.
This is valid. I will reword.



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:16
+/// 2. Set representations and operations on nodes and edges become
+///extraordinarily efficient. For instance, a set of edges is implemented 
as
+///a bit vector, wherein each bit corresponds to one edge in the edge

mattdr wrote:
> "extraordinarily" is, again, not a useful engineering categorization. Please 
> restrict comments to describing quantifiable claims of complexity.
AFAIK there is not a precise engineering term for "tiny O(1)." Nonetheless I 
will reword.



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:40
+
+template 
+class ImmutableGraph {

mattdr wrote:
> Every template argument for a class represents combinatorial addition of 
> complexity for the resulting code. Why do each of these template arguments 
> need to exist? in particular, why does SizeT need to exist?
I suspect that there may be more uses for this data structure and that 
eventually it may migrate to ADT. I have SizeT as a template argument because I 
found it plenty sufficient to have `int` as the size parameter for the array 
bounds, but I suspect other uses may require `size_t`.


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

https://reviews.llvm.org/D75936



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


[PATCH] D77290: [OpenMP] Specialize OpenMP calls after template instantiation

2020-04-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 255043.
jdoerfert edited the summary of this revision.
jdoerfert added a comment.

Rebase on D77252 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77290

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_1.cpp

Index: clang/test/AST/ast-dump-openmp-begin-declare-variant_template_1.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-openmp-begin-declare-variant_template_1.cpp
@@ -0,0 +1,170 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s   | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s -x c++| FileCheck %s
+// expected-no-diagnostics
+
+int also_before() {
+  return 1;
+}
+
+#pragma omp begin declare variant match(implementation={vendor(score(100):llvm)})
+int also_after(void) {
+  return 2;
+}
+int also_after(int) {
+  return 3;
+}
+int also_after(double) {
+  return 0;
+}
+#pragma omp end declare variant
+#pragma omp begin declare variant match(implementation={vendor(score(0):llvm)})
+int also_before() {
+  return 0;
+}
+#pragma omp end declare variant
+
+int also_after(void) {
+  return 4;
+}
+int also_after(int) {
+  return 5;
+}
+int also_after(double) {
+  return 6;
+}
+
+template
+int test1() {
+  // Should return 0.
+  return also_after(T(0));
+}
+
+typedef int(*Ty)();
+
+template
+int test2() {
+  // Should return 0.
+  return fn();
+}
+
+int test() {
+  // Should return 0.
+  return test1() + test2();
+}
+
+// CHECK:  |-FunctionDecl [[ADDR_0:0x[a-z0-9]*]] <{{.*}}, line:7:1> line:5:5 implicit used also_before 'int ({{.*}})'
+// CHECK-NEXT: | |-CompoundStmt [[ADDR_1:0x[a-z0-9]*]] 
+// CHECK-NEXT: | | `-ReturnStmt [[ADDR_2:0x[a-z0-9]*]] 
+// CHECK-NEXT: | |   `-IntegerLiteral [[ADDR_3:0x[a-z0-9]*]]  'int' 1
+// CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_4:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(0): llvm)}
+// CHECK-NEXT: |   `-DeclRefExpr [[ADDR_5:0x[a-z0-9]*]]  'int ({{.*}})' Function [[ADDR_6:0x[a-z0-9]*]] 'also_before[implementation={vendor(llvm)}]' 'int ({{.*}})'
+// CHECK-NEXT: |-FunctionDecl [[ADDR_7:0x[a-z0-9]*]]  line:10:5 also_after[implementation={vendor(llvm)}] 'int ({{.*}})'
+// CHECK-NEXT: | `-CompoundStmt [[ADDR_8:0x[a-z0-9]*]] 
+// CHECK-NEXT: |   `-ReturnStmt [[ADDR_9:0x[a-z0-9]*]] 
+// CHECK-NEXT: | `-IntegerLiteral [[ADDR_10:0x[a-z0-9]*]]  'int' 2
+// CHECK-NEXT: |-FunctionDecl [[ADDR_11:0x[a-z0-9]*]]  col:5 implicit also_after 'int ({{.*}})'
+// CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_12:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(100): llvm)}
+// CHECK-NEXT: |   `-DeclRefExpr [[ADDR_13:0x[a-z0-9]*]]  'int ({{.*}})' Function [[ADDR_7]] 'also_after[implementation={vendor(llvm)}]' 'int ({{.*}})'
+// CHECK-NEXT: |-FunctionDecl [[ADDR_14:0x[a-z0-9]*]]  line:13:5 also_after[implementation={vendor(llvm)}] 'int (int)'
+// CHECK-NEXT: | |-ParmVarDecl [[ADDR_15:0x[a-z0-9]*]]  col:19 'int'
+// CHECK-NEXT: | `-CompoundStmt [[ADDR_16:0x[a-z0-9]*]] 
+// CHECK-NEXT: |   `-ReturnStmt [[ADDR_17:0x[a-z0-9]*]] 
+// CHECK-NEXT: | `-IntegerLiteral [[ADDR_18:0x[a-z0-9]*]]  'int' 3
+// CHECK-NEXT: |-FunctionDecl [[ADDR_19:0x[a-z0-9]*]]  col:5 implicit also_after 'int (int)'
+// CHECK-NEXT: | |-ParmVarDecl [[ADDR_20:0x[a-z0-9]*]]  col:5 implicit 'int'
+// CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_21:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(100): llvm)}
+// CHECK-NEXT: |   `-DeclRefExpr [[ADDR_22:0x[a-z0-9]*]]  'int (int)' Function [[ADDR_14]] 'also_after[implementation={vendor(llvm)}]' 'int (int)'
+// CHECK-NEXT: |-FunctionDecl [[ADDR_23:0x[a-z0-9]*]]  line:16:5 also_after[implementation={vendor(llvm)}] 'int (double)'
+// CHECK-NEXT: | |-ParmVarDecl [[ADDR_24:0x[a-z0-9]*]]  col:22 'double'
+// CHECK-NEXT: | `-CompoundStmt [[ADDR_25:0x[a-z0-9]*]] 
+// CHECK-NEXT: |   `-ReturnStmt [[ADDR_26:0x[a-z0-9]*]] 
+// CHECK-NEXT: | `-IntegerLiteral [[ADDR_27:0x[a-z0-9]*]]  'int' 0
+// CHECK-NEXT: |-FunctionDecl [[ADDR_28:0x[a-z0-9]*]]  col:5 implicit used also_after 'int (double)'
+// CHECK-NEXT: | |-ParmVarDecl [[ADDR_29:0x[a-z0-9]*]]  col:5 implicit 'double'
+// CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_30:0x[a-z0-9]*]] <> Implicit implementation={vendor(score(100): llvm)}
+// CHECK-NEXT: |   `-DeclRefExpr [[ADDR_31:0x[a-z0-9]*]]  'int (double)' Function [[ADDR_23]] 'also_after[implementation={vendor(llvm)}]' 'int (double)'
+// CHECK-NEXT: |-FunctionDecl [[ADDR_6]]  line:21:5 also_before[implementation={vendor(llvm)}] 'int ({{.*}})'
+// CHECK-NEXT: | `-CompoundStmt [[ADDR_32:0x[a-z0-9]*]] 
+// CHECK-NEXT: |   `-ReturnStmt [[ADDR_33:0x[a-z0-9]*]] 
+// CHECK-NEXT: | `-IntegerLiteral [[ADDR_34:0x[a-z0-9]*]]  'int' 0
+// CHECK-NEXT: |-FunctionDecl [[ADDR_35:0x[a-z0-9]*]] prev

[PATCH] D76990: [clang-tidy]: fix false positive of cert-oop54-cpp check.

2020-04-04 Thread Tamás Zolnai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0f9e1e3ae750: [clang-tidy]: fix false positive of 
cert-oop54-cpp check. (authored by ztamas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76990

Files:
  clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
@@ -212,6 +212,21 @@
   T *p;
 };
 
+// https://bugs.llvm.org/show_bug.cgi?id=44499
+class Foo2;
+template 
+bool operator!=(Foo2 &, Foo2 &) {
+  class Bar2 {
+Bar2 &operator=(const Bar2 &other) {
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: operator=() does not handle 
self-assignment properly [bugprone-unhandled-self-assignment]
+  p = other.p;
+  return *this;
+}
+
+int *p;
+  };
+}
+
 ///
 /// Test cases correctly ignored by the check.
 
@@ -283,6 +298,21 @@
   T *p;
 };
 
+// https://bugs.llvm.org/show_bug.cgi?id=44499
+class Foo;
+template 
+bool operator!=(Foo &, Foo &) {
+  class Bar {
+Bar &operator=(const Bar &other) {
+  if (this != &other) {
+  }
+  return *this;
+}
+
+int *p;
+  };
+}
+
 // There is no warning if the copy assignment operator gets the object by 
value.
 class PassedByValue {
 public:
Index: clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
@@ -40,9 +40,12 @@
 
   // Self-check: Code compares something with 'this' pointer. We don't check
   // whether it is actually the parameter what we compare.
-  const auto HasNoSelfCheck = cxxMethodDecl(unless(
+  const auto HasNoSelfCheck = cxxMethodDecl(unless(anyOf(
   hasDescendant(binaryOperator(hasAnyOperatorName("==", "!="),
-   has(ignoringParenCasts(cxxThisExpr()));
+   has(ignoringParenCasts(cxxThisExpr(),
+  hasDescendant(cxxOperatorCallExpr(
+  hasAnyOverloadedOperatorName("==", "!="), argumentCountIs(2),
+  has(ignoringParenCasts(cxxThisExpr(;
 
   // Both copy-and-swap and copy-and-move method creates a copy first and
   // assign it to 'this' with swap or move.


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp
@@ -212,6 +212,21 @@
   T *p;
 };
 
+// https://bugs.llvm.org/show_bug.cgi?id=44499
+class Foo2;
+template 
+bool operator!=(Foo2 &, Foo2 &) {
+  class Bar2 {
+Bar2 &operator=(const Bar2 &other) {
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: operator=() does not handle self-assignment properly [bugprone-unhandled-self-assignment]
+  p = other.p;
+  return *this;
+}
+
+int *p;
+  };
+}
+
 ///
 /// Test cases correctly ignored by the check.
 
@@ -283,6 +298,21 @@
   T *p;
 };
 
+// https://bugs.llvm.org/show_bug.cgi?id=44499
+class Foo;
+template 
+bool operator!=(Foo &, Foo &) {
+  class Bar {
+Bar &operator=(const Bar &other) {
+  if (this != &other) {
+  }
+  return *this;
+}
+
+int *p;
+  };
+}
+
 // There is no warning if the copy assignment operator gets the object by value.
 class PassedByValue {
 public:
Index: clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
@@ -40,9 +40,12 @@
 
   // Self-check: Code compares something with 'this' pointer. We don't check
   // whether it is actually the parameter what we compare.
-  const auto HasNoSelfCheck = cxxMethodDecl(unless(
+  const auto HasNoSelfCheck = cxxMethodDecl(unless(anyOf(
   hasDescendant(binaryOperator(hasAnyOperatorName("==", "!="),
-   has(ignoringParenCasts(cxxThisExpr()));
+   has(ignoringParenCasts(cxxThisExpr(),
+  hasDescendant(cxxOperatorCallExpr(
+  hasAnyOverloadedOperatorName("==", "

[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-04-04 Thread Scott Constable via Phabricator via cfe-commits
sconstab added inline comments.



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:285
+  std::unique_ptr Edges;
+  size_type EdgesSize;
+};

@craig.topper It now occurs to me that these fields should probably be 
reordered to:
```
  std::unique_ptr Nodes;
  std::unique_ptr Edges;
  size_type NodesSize;
  size_type EdgesSize;
```
The current ordering will cause internal fragmentation.

Old ordering:
```
static_assert(sizeof(ImmutableGraph) == 32);
```
New ordering:
```
static_assert(sizeof(ImmutableGraph) == 24);
```
With vectors instead of arrays:
```
static_assert(sizeof(ImmutableGraph) == 48);
```


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

https://reviews.llvm.org/D75936



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


[PATCH] D75788: [OpenMP] Provide math functions in OpenMP device code via OpenMP variants

2020-04-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 255050.
jdoerfert added a comment.

Cleanup and rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75788

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_cmath.h
  clang/lib/Headers/__clang_cuda_device_functions.h
  clang/lib/Headers/__clang_cuda_math.h
  clang/lib/Headers/__clang_cuda_math_forward_declares.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_math.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
  clang/lib/Headers/openmp_wrappers/cmath
  clang/lib/Headers/openmp_wrappers/math.h
  clang/lib/Headers/openmp_wrappers/time.h
  clang/test/Headers/Inputs/include/climits
  clang/test/Headers/Inputs/include/cmath
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/Inputs/include/math.h
  clang/test/Headers/Inputs/include/stdlib.h
  clang/test/Headers/nvptx_device_cmath_functions.c
  clang/test/Headers/nvptx_device_cmath_functions.cpp
  clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_complex.c
  clang/test/Headers/nvptx_device_math_functions.c
  clang/test/Headers/nvptx_device_math_functions.cpp
  clang/test/Headers/nvptx_device_math_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_macro.cpp
  clang/test/Headers/nvptx_device_math_modf.cpp
  clang/test/Headers/nvptx_device_math_sin.c
  clang/test/Headers/nvptx_device_math_sin.cpp
  clang/test/Headers/nvptx_device_math_sin_cos.cpp
  clang/test/Headers/nvptx_device_math_sincos.cpp

Index: clang/test/Headers/nvptx_device_math_sincos.cpp
===
--- /dev/null
+++ clang/test/Headers/nvptx_device_math_sincos.cpp
@@ -0,0 +1,58 @@
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+
+#include 
+
+// 4 calls to sincos(f), all translated to __nv_sincos calls:
+
+// CHECK-NOT: _Z.sincos
+// CHECK: call void @__nv_sincos(double
+// CHECK-NOT: _Z.sincos
+// CHECK: call void @__nv_sincosf(float
+// CHECK-NOT: _Z.sincos
+// CHECK: call void @__nv_sincos(double
+// CHECK-NOT: _Z.sincos
+// CHECK: call void @__nv_sincosf(float
+// CHECK-NOT: _Z.sincos
+
+// single precision wrapper
+inline void sincos(float x, float* __restrict__ sin, float* __restrict__ cos)
+{
+  sincosf(x, sin, cos);
+}
+
+template
+void test_sincos(T x)
+{
+  T res_sin, res_cos;
+
+  #pragma omp target map(from: res_sin, res_cos)
+  {
+sincos(x, &res_sin, &res_cos);
+  }
+
+}
+
+int main(int argc, char **argv)
+{
+
+#if !defined(C_ONLY)
+  test_sincos(0.0);
+  test_sincos(0.0);
+#endif
+
+  #pragma omp target
+  {
+double s, c;
+sincos(0, &s, &c);
+  }
+
+  #pragma omp target
+  {
+float s, c;
+sincosf(0.f, &s, &c);
+  }
+
+  return 0;
+}
Index: clang/test/Headers/nvptx_device_math_sin_cos.cpp
===
--- /dev/null
+++ clang/test/Headers/nvptx_device_math_sin_cos.cpp
@@ -0,0 +1,63 @@
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+
+#include 
+
+// 6 calls to sin/cos(f), all translated to __nv_sin/__nv_cos calls:
+
+// CHECK-NOT: _Z.sin
+// CHECK-NOT: _Z.cos
+// CHECK: call double @__nv_sin(double
+// CHECK-NOT: _Z.sin
+// CHECK-NOT: _Z.cos
+// CHECK: call float @__nv_sinf(float
+// CHECK-NOT: _Z.sin
+// CHECK-NOT: _Z.cos
+// CHECK: call double @__nv_sin(double
+// CHECK-NOT: _Z.sin
+// CHECK-NOT: _Z.cos
+// CHECK: call double @__nv_cos(double
+// CHECK-NOT: _Z.sin
+// CHECK-NOT: _Z.cos
+// CHECK: call float @__nv_sinf(float
+// CHECK-NOT: _Z.sin
+// CHECK-NOT: _Z.cos
+// CHECK: call float @__nv_cosf(float
+// CHECK-NOT: _Z.sin
+// CHECK-NOT: _Z.cos
+
+template
+void test_sin_cos(T x)
+{
+  T res_sin, res_cos;
+
+  #pragma omp target map(from: res_sin, res_cos)
+  {
+res_si

[clang] ceed44a - [OpenMP][NFC] Remove unnecessary argument

2020-04-04 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2020-04-04T11:34:58-05:00
New Revision: ceed44adfd1ae9d714eaa4f0e7fa5a1a149b4dc5

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

LOG: [OpenMP][NFC] Remove unnecessary argument

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 7c689c2a13e8..10e2d69f3d9e 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9892,7 +9892,7 @@ class Sema final {
   /// specialization via the OpenMP declare variant mechanism available. If
   /// there is, return the specialized call expression, otherwise return the
   /// original \p Call.
-  ExprResult ActOnOpenMPCall(Sema &S, ExprResult Call, Scope *Scope,
+  ExprResult ActOnOpenMPCall(ExprResult Call, Scope *Scope,
  SourceLocation LParenLoc, MultiExprArg ArgExprs,
  SourceLocation RParenLoc, Expr *ExecConfig);
 

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 8d0e97c85771..b311aad84816 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5997,7 +5997,7 @@ ExprResult Sema::ActOnCallExpr(Scope *Scope, Expr *Fn, 
SourceLocation LParenLoc,
   }
 
   if (LangOpts.OpenMP)
-Call = ActOnOpenMPCall(*this, Call, Scope, LParenLoc, ArgExprs, RParenLoc,
+Call = ActOnOpenMPCall(Call, Scope, LParenLoc, ArgExprs, RParenLoc,
ExecConfig);
 
   return Call;

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index f663b1d43659..cfaf981983c1 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -5584,7 +5584,7 @@ void 
Sema::ActOnFinishedFunctionDefinitionInOpenMPDeclareVariantScope(
   BaseFD->setImplicit(true);
 }
 
-ExprResult Sema::ActOnOpenMPCall(Sema &S, ExprResult Call, Scope *Scope,
+ExprResult Sema::ActOnOpenMPCall(ExprResult Call, Scope *Scope,
  SourceLocation LParenLoc,
  MultiExprArg ArgExprs,
  SourceLocation RParenLoc, Expr *ExecConfig) {
@@ -5601,8 +5601,8 @@ ExprResult Sema::ActOnOpenMPCall(Sema &S, ExprResult 
Call, Scope *Scope,
   if (!CalleeFnDecl->hasAttr())
 return Call;
 
-  ASTContext &Context = S.getASTContext();
-  OMPContext OMPCtx(S.getLangOpts().OpenMPIsDevice,
+  ASTContext &Context = getASTContext();
+  OMPContext OMPCtx(getLangOpts().OpenMPIsDevice,
 Context.getTargetInfo().getTriple());
 
   SmallVector Exprs;
@@ -5650,12 +5650,12 @@ ExprResult Sema::ActOnOpenMPCall(Sema &S, ExprResult 
Call, Scope *Scope,
   if (auto *SpecializedMethod = dyn_cast(BestDecl)) {
 auto *MemberCall = dyn_cast(CE);
 BestExpr = MemberExpr::CreateImplicit(
-S.Context, MemberCall->getImplicitObjectArgument(),
-/* IsArrow */ false, SpecializedMethod, S.Context.BoundMemberTy,
+Context, MemberCall->getImplicitObjectArgument(),
+/* IsArrow */ false, SpecializedMethod, Context.BoundMemberTy,
 MemberCall->getValueKind(), MemberCall->getObjectKind());
   }
-  NewCall = S.BuildCallExpr(Scope, BestExpr, LParenLoc, ArgExprs, 
RParenLoc,
-ExecConfig);
+  NewCall = BuildCallExpr(Scope, BestExpr, LParenLoc, ArgExprs, RParenLoc,
+  ExecConfig);
   if (NewCall.isUsable())
 break;
 }
@@ -5666,7 +5666,6 @@ ExprResult Sema::ActOnOpenMPCall(Sema &S, ExprResult 
Call, Scope *Scope,
 
   if (!NewCall.isUsable())
 return Call;
-
   return PseudoObjectExpr::Create(Context, CE, {NewCall.get()}, 0);
 }
 



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


[PATCH] D75364: [clang-format] Handle macros in function params and return value

2020-04-04 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:313
+// for example:
+//   void f(volatile ElfW(Addr)* addr = nullptr);
+if (HasStarToken) {

I assume it could be almost anything?

void f(volatile ElfW(Addr)& addr);
void f(volatile ElfW(Addr)&& addr);
void f(volatile ElfW(Addr) const & addr);

void f(volatile ElfW(Addr,foo)* addr);
void f(volatile ElfW(Addr,ElfW(Addr) *foo)* addr);

? you seem to handle only the * case


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

https://reviews.llvm.org/D75364



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


[PATCH] D77184: Make it possible for lit.site.cfg to contain relative paths, and use it for llvm and clang

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

> Can you describe your symlink setup in enough detail that I can recreate it 
> locally please?

I've landed a workaround that should make things go for you again in 
7db64e202f9 
. I'd 
still be curious to hear details about your setup, so that I can see if I can 
make it work better. (Right now, this now bails out when it sees a symlink and 
keeps an absolute path as before, which is a bit lame.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77184



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


[PATCH] D77290: [OpenMP] Specialize OpenMP calls after template instantiation

2020-04-04 Thread Mike Rice via Phabricator via cfe-commits
mikerice added inline comments.



Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:1693
+ExprResult TemplateInstantiator::TransformCallExpr(CallExpr *E) {
+  ExprResult R = TreeTransform::TransformCallExpr(E);
+  if (!SemaRef.getLangOpts().OpenMP || !R.isUsable() || 
!isa(R.get()))

Is there a reason you are adding this here as opposed to in the base class 
RebuildCallExpr?  Are there cases where we rebuild call expressions that we 
don't want to do this variant processing?



Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:1698
+  auto *CE = cast(R.get());
+  return SemaRef.ActOnOpenMPCall(R, nullptr, CE->getRParenLoc(),
+ MultiExprArg(CE->getArgs(), CE->getNumArgs()),

Comments on nullptr arguments would be nice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77290



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


[PATCH] D77468: [clang] fix undefined behaviour in RawComment::getFormattedText()

2020-04-04 Thread Oliver Bruns via Phabricator via cfe-commits
obruns created this revision.
obruns added reviewers: teemperor, ioeric, cfe-commits.
Herald added subscribers: usaxena95, kadircet, ilya-biryukov.
Herald added a project: clang.

Calling `back()` and `pop_back()` on the empty string is undefined
behavior [1,2].

The issue manifested itself as an uncaught `std::out_of_range` exception
when running `clangd` compiled on RHEL7 using devtoolset-9.

[1] https://en.cppreference.com/w/cpp/string/basic_string/back
[2] https://en.cppreference.com/w/cpp/string/basic_string/pop_back

Fixes: 1ff7c32fc91c607b690d4bb9cf42f406be8dde68


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77468

Files:
  clang/lib/AST/RawCommentList.cpp


Index: clang/lib/AST/RawCommentList.cpp
===
--- clang/lib/AST/RawCommentList.cpp
+++ clang/lib/AST/RawCommentList.cpp
@@ -431,7 +431,7 @@
   };
 
   auto DropTrailingNewLines = [](std::string &Str) {
-while (Str.back() == '\n')
+while (not Str.empty() and Str.back() == '\n')
   Str.pop_back();
   };
 


Index: clang/lib/AST/RawCommentList.cpp
===
--- clang/lib/AST/RawCommentList.cpp
+++ clang/lib/AST/RawCommentList.cpp
@@ -431,7 +431,7 @@
   };
 
   auto DropTrailingNewLines = [](std::string &Str) {
-while (Str.back() == '\n')
+while (not Str.empty() and Str.back() == '\n')
   Str.pop_back();
   };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77470: [clang] NFC: Fix trivial typo in comments and document

2020-04-04 Thread Kazuaki Ishizaki via Phabricator via cfe-commits
kiszk created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`the the` -> `the`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77470

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/AST/ASTStructuralEquivalence.h
  clang/include/clang/AST/ComparisonCategories.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
  clang/include/clang/Tooling/Transformer/RangeSelector.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Sema/SemaAvailability.cpp

Index: clang/lib/Sema/SemaAvailability.cpp
===
--- clang/lib/Sema/SemaAvailability.cpp
+++ clang/lib/Sema/SemaAvailability.cpp
@@ -57,7 +57,7 @@
 /// \param D The declaration to check.
 /// \param Message If non-null, this will be populated with the message from
 /// the availability attribute that is selected.
-/// \param ClassReceiver If we're checking the the method of a class message
+/// \param ClassReceiver If we're checking the method of a class message
 /// send, the class. Otherwise nullptr.
 static std::pair
 ShouldDiagnoseAvailabilityOfDecl(Sema &S, const NamedDecl *D,
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -124,7 +124,7 @@
 // the specified module, meaning clang won't build the specified module. This is
 // useful in a number of situations, for instance, when building a library that
 // vends a module map, one might want to avoid hitting intermediate build
-// products containimg the the module map or avoid finding the system installed
+// products containimg the module map or avoid finding the system installed
 // modulemap for that library.
 static bool isForModuleBuilding(Module *M, StringRef CurrentModule,
 StringRef ModuleName) {
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -4708,7 +4708,7 @@
 
   auto *GEP = cast(GEPVal);
   assert(GEP->getPointerOperand() == BasePtr &&
- "BasePtr must be the the base of the GEP.");
+ "BasePtr must be the base of the GEP.");
   assert(GEP->isInBounds() && "Expected inbounds GEP");
 
   auto *IntPtrTy = DL.getIntPtrType(GEP->getPointerOperandType());
Index: clang/include/clang/Tooling/Transformer/RangeSelector.h
===
--- clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ clang/include/clang/Tooling/Transformer/RangeSelector.h
@@ -40,7 +40,7 @@
 /// Selects the (empty) range [B,B) when \p Selector selects the range [B,E).
 RangeSelector before(RangeSelector Selector);
 
-/// Selects the the point immediately following \p Selector. That is, the
+/// Selects the point immediately following \p Selector. That is, the
 /// (empty) range [E,E), when \p Selector selects either
 /// * the CharRange [B,E) or
 /// * the TokenRange [B,E'] where the token at E' spans the range [E,E').
Index: clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
===
--- clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
+++ clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
@@ -20,7 +20,7 @@
 /// Provides notifications for file changes in a directory.
 ///
 /// Invokes client-provided function on every filesystem event in the watched
-/// directory. Initially the the watched directory is scanned and for every file
+/// directory. Initially the watched directory is scanned and for every file
 /// found, an event is synthesized as if the file was added.
 ///
 /// This is not a general purpose directory monitoring tool - list of
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -303,7 +303,7 @@
 
 /// Matches statements that are (transitively) expanded from the named macro.
 /// Does not match if only part of the statement is expanded from that macro or
-/// if different parts of the the statement are expanded from different
+/// if different parts of the statement are expanded from different
 /// appearances of the macro.
 ///
 /// FIXME: Change to be a polymorphic matcher that works on any syntactic
Index: clang/include/clang/AST/OpenMPClause.h
===
--- clang/include/clang/AST/OpenMPClause.h
+++ clang/include/clang/AST/OpenMPClause.h
@@ -1788,13 +1788,13 @@
 return IsExtended ? 2 : 0;
   }
 
-  /// Sets the the location of '(' in clause for 'depobj' directive.
+  /// Se

[PATCH] D77458: [clang-tools-extra] NFC: Fix trivial typo in documents and comments

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

Thank you!




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/fuchsia-multiple-inheritance.cpp:48
 // Inherits from multiple concrete classes.
-// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes that 
aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that 
aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
 // CHECK-NEXT: class Bad_Child1 : public Base_A, Base_B {};

Did you update the actual generated diagnostic in 
clang-tidy/fuchsia/MultipleInheritanceCheck.cpp? I don't see it in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77458



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


[PATCH] D77471: address review comment

2020-04-04 Thread Kazuaki Ishizaki via Phabricator via cfe-commits
kiszk added a comment.

Sorry, I made a mistake. This should not be reviewed. This should be deleted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77471



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


[PATCH] D77471: address review comment

2020-04-04 Thread Kazuaki Ishizaki via Phabricator via cfe-commits
kiszk created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
kiszk added a comment.
kiszk removed a project: clang.
kiszk removed a subscriber: cfe-commits.
Herald added a project: clang.

Sorry, I made a mistake. This should not be reviewed. This should be deleted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77471

Files:
  clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp


Index: clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
===
--- clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -116,7 +116,7 @@
 }
 
 if (NumConcrete > 1) {
-  diag(D->getBeginLoc(), "inheriting mulitple classes that aren't "
+  diag(D->getBeginLoc(), "inheriting multiple classes that aren't "
  "pure virtual is discouraged");
 }
   }


Index: clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
===
--- clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -116,7 +116,7 @@
 }
 
 if (NumConcrete > 1) {
-  diag(D->getBeginLoc(), "inheriting mulitple classes that aren't "
+  diag(D->getBeginLoc(), "inheriting multiple classes that aren't "
  "pure virtual is discouraged");
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77458: [clang-tools-extra] NFC: Fix trivial typo in documents and comments

2020-04-04 Thread Kazuaki Ishizaki via Phabricator via cfe-commits
kiszk updated this revision to Diff 255071.
kiszk added a comment.

address review comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77458

Files:
  clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp


Index: clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
===
--- clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -116,7 +116,7 @@
 }
 
 if (NumConcrete > 1) {
-  diag(D->getBeginLoc(), "inheriting mulitple classes that aren't "
+  diag(D->getBeginLoc(), "inheriting multiple classes that aren't "
  "pure virtual is discouraged");
 }
   }


Index: clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
===
--- clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -116,7 +116,7 @@
 }
 
 if (NumConcrete > 1) {
-  diag(D->getBeginLoc(), "inheriting mulitple classes that aren't "
+  diag(D->getBeginLoc(), "inheriting multiple classes that aren't "
  "pure virtual is discouraged");
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77458: [clang-tools-extra] NFC: Fix trivial typo in documents and comments

2020-04-04 Thread Kazuaki Ishizaki via Phabricator via cfe-commits
kiszk added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/fuchsia-multiple-inheritance.cpp:48
 // Inherits from multiple concrete classes.
-// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes that 
aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that 
aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
 // CHECK-NEXT: class Bad_Child1 : public Base_A, Base_B {};

sammccall wrote:
> Did you update the actual generated diagnostic in 
> clang-tidy/fuchsia/MultipleInheritanceCheck.cpp? I don't see it in this patch.
Good catch. I also updated clang-tidy/fuchsia/MultipleInheritanceCheck.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77458



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


[PATCH] D77474: [analyzer][MallocChecker] Make NewDeleteLeaks depend on DynamicMemoryModeling rather than NewDelete

2020-04-04 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, xazax.hun, baloghadamsoftware, martong, 
balazske, dcoughlin.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, 
gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
whisperity.
Szelethus edited the summary of this revision.

If you remember the mail [1] I sent out about how I envision the future of the 
already existing checkers to look dependencywise, one my main points was that 
no checker that emits diagnostics should be a dependency. This is more 
problematic for some checkers (ahem, RetainCount [2]) more than for others, 
like this one.

The MallocChecker family is a mostly big monolithic modeling class some small 
reporting checkers that only come to action when we are constructing a warning 
message, //after// the actual bug was detected. The implication of this is that 
NewDeleteChecker doesn't really do anything to depend on, so this change was 
relatively simple.

The only thing that complicates this change is that `FreeMemAux` 
(MallocCheckers method that models general memory deallocation) returns after 
calling a bug reporting method, regardless whether the report was ever emitted 
(which may not always happen, for instance, if the checker responsible for the 
report isn't enabled). This return unfortunately happens before cleaning up the 
maps in the GDM keeping track of the state of symbols (whether they are 
released, whether that release was successful, etc). What this means is that 
upon disabling some checkers, we would never clean up the map and that could've 
lead to false positives, e.g.:

  error: 'warning' diagnostics seen but not expected: 
File clang/test/Analysis/NewDelete-intersections.mm Line 66: Potential leak 
of memory pointed to by 'p'
File clang/test/Analysis/NewDelete-intersections.mm Line 73: Potential leak 
of memory pointed to by 'p'
File clang/test/Analysis/NewDelete-intersections.mm Line 77: Potential leak 
of memory pointed to by 'p'
  
  error: 'warning' diagnostics seen but not expected: 
File clang/test/Analysis/NewDelete-checker-test.cpp Line 111: Undefined or 
garbage value returned to caller
File clang/test/Analysis/NewDelete-checker-test.cpp Line 200: Potential 
leak of memory pointed to by 'p'
  
  error: 'warning' diagnostics seen but not expected: 
File clang/test/Analysis/new.cpp Line 137: Potential leak of memory pointed 
to by 'x'

There two possible approaches I had in mind:

- Make bug reporting methods of MallocChecker returns whether they succeeded, 
and proceed with the rest of `FreeMemAux` if not,
- Halt execution with a sink node upon failure. I decided to go with this, as 
described in the code.

As you can see from the removed/changed test files, before the big checker 
dependency effort landed, there were tests to check for all the weird 
configurations of enabled/disabled checkers and their messy interactions, I 
largely repurposed these.

[1] http://lists.llvm.org/pipermail/cfe-dev/2019-August/063070.html
[2] http://lists.llvm.org/pipermail/cfe-dev/2019-August/063205.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77474

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/test/Analysis/Malloc+NewDelete_intersections.cpp
  clang/test/Analysis/NewDelete-checker-test.cpp
  clang/test/Analysis/NewDelete-intersections.mm
  clang/test/Analysis/new.cpp

Index: clang/test/Analysis/new.cpp
===
--- clang/test/Analysis/new.cpp
+++ clang/test/Analysis/new.cpp
@@ -115,11 +115,6 @@
   delete c;
 }
 
-//
-// Check for intersection with other checkers from MallocChecker.cpp 
-// bounded with unix.Malloc
-//
-
 // new/delete oparators are subjects of cplusplus.NewDelete.
 void testNewDeleteNoWarn() {
   int i;
@@ -135,11 +130,11 @@
   int *p3 = new int; // no-warning
 }
 
-// unix.Malloc does not know about operators new/delete.
 void testDeleteMallocked() {
   int *x = (int *)malloc(sizeof(int));
-  delete x; // FIXME: Should detect pointer escape and keep silent after 'delete' is modeled properly.
-} // expected-warning{{Potential leak of memory pointed to by 'x'}}
+  // unix.MismatchedDeallocator would catch this, but we're not testing it here.
+  delete x;
+}
 
 void testDeleteOpAfterFree() {
   int *p = (int *)malloc(sizeof(int));
Index: clang/test/Analysis/NewDelete-intersections.mm
===
--- clang/test/Analysis/NewDelete-intersections.mm
+++ clang/test/Analysis/NewDelete-intersections.mm
@@ -1,7 +1,20 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,c

[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-04-04 Thread Scott Constable via Phabricator via cfe-commits
sconstab added a comment.

Overall, the restyling by @craig.topper looks much better than what I had 
committed before. I agree that `std::unique_ptr` is the right "container" 
in this circumstance. And the addition of `ArrayRef<>` accessors is also a nice 
touch. A few extra inline comments.




Comment at: llvm/lib/Target/X86/ImmutableGraph.h:13
+/// The advantages to this implementation are two-fold:
+/// 1. Iteration and traversal operations should experience terrific caching
+///performance.

sconstab wrote:
> mattdr wrote:
> > erm, "terrific"? If there's a substantive argument w.r.t. cache locality 
> > etc., please make it explicit.
> This is valid. I will reword.
"Iteration and traversal operations benefit from cache locality."



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:16
+/// 2. Set representations and operations on nodes and edges become
+///extraordinarily efficient. For instance, a set of edges is implemented 
as
+///a bit vector, wherein each bit corresponds to one edge in the edge

sconstab wrote:
> mattdr wrote:
> > "extraordinarily" is, again, not a useful engineering categorization. 
> > Please restrict comments to describing quantifiable claims of complexity.
> AFAIK there is not a precise engineering term for "tiny O(1)." Nonetheless I 
> will reword.
"Operations on sets of nodes/edges are efficient, and representations of those 
sets in memory are compact. For instance..."



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:84
+  : Nodes(std::move(Nodes)), NodesSize(NodesSize), Edges(std::move(Edges)),
+EdgesSize(EdgesSize) {}
+  ImmutableGraph(const ImmutableGraph &) = delete;

After the members are reordered, this list must also be reordered.



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:103
+
+  class NodeSet {
+friend class iterator;

This had not occurred to me until now, but a lot of code is shared between 
`NodeSet` and `EdgeSet`. Maybe a template could reduce the redundancy?


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

https://reviews.llvm.org/D75936



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


[PATCH] D77252: [OpenMP] Try to find an existing base for `omp begin/end declare variant`

2020-04-04 Thread Mike Rice via Phabricator via cfe-commits
mikerice added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:5512
+
+  if (!BaseFD) {
+// TODO: Determine if we can reuse the declarator to create a declaration

I think if you do the base lookup in 
ActOnStartOfFunctionDefinitionInOpenMPDeclareVariantScope instead of here you 
might have better success using the declarator.  You would need to get the type 
and  constexpr/consteval info from the declarator and declspec but if the 
lookup fails you can just use ActOnDeclarator to get a base declaration like 
you were before.  I tried this in my sandbox and it seems to work (AST tests 
fail I'm guessing that is just order change).  If that works we could get rid 
of these hacky bits.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:5551
+  BaseFD->addAttr(OMPDeclareVariantA);
   BaseFD->setImplicit(true);
 }

BaseFD is only implicit now if you created it, not when one was found in the 
lookup case right? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77252



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


[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-04-04 Thread Scott Constable via Phabricator via cfe-commits
sconstab added inline comments.



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:307
+public:
+  using NodeRef = size_type;
+

Just noticed that `ImmutableGraphBuilder` and `ImmutableGraph` have 
non-identical types called `NodeRef`. Suggest renaming this one to 
`BuilderNodeRef`.


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

https://reviews.llvm.org/D75936



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


[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-04-04 Thread Craig Topper via Phabricator via cfe-commits
craig.topper marked 2 inline comments as done.
craig.topper added inline comments.



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:285
+  std::unique_ptr Edges;
+  size_type EdgesSize;
+};

sconstab wrote:
> @craig.topper It now occurs to me that these fields should probably be 
> reordered to:
> ```
>   std::unique_ptr Nodes;
>   std::unique_ptr Edges;
>   size_type NodesSize;
>   size_type EdgesSize;
> ```
> The current ordering will cause internal fragmentation.
> 
> Old ordering:
> ```
> static_assert(sizeof(ImmutableGraph) == 32);
> ```
> New ordering:
> ```
> static_assert(sizeof(ImmutableGraph) == 24);
> ```
> With vectors instead of arrays:
> ```
> static_assert(sizeof(ImmutableGraph) == 48);
> ```
I noticed that too. I just didn't focus on it since we only ever one in memory 
at a time. I'll change in my next update.



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:307
+public:
+  using NodeRef = size_type;
+

sconstab wrote:
> Just noticed that `ImmutableGraphBuilder` and `ImmutableGraph` have 
> non-identical types called `NodeRef`. Suggest renaming this one to 
> `BuilderNodeRef`.
NodeRef is in the Traits class not the ImmutableGraph, but I will rename the 
builder one.


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

https://reviews.llvm.org/D75936



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


[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-04-04 Thread Craig Topper via Phabricator via cfe-commits
craig.topper marked 2 inline comments as done.
craig.topper added inline comments.



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:329
+size_type VI = 0, EI = 0;
+for (; VI < static_cast(AdjList.size()); ++VI) {
+  VertexArray[VI].Value = std::move(AdjList[VI].first);

Can this be changed to VI < VertexSize?



Comment at: llvm/lib/Target/X86/ImmutableGraph.h:369
+continue;
+  size_type NewNumEdges = std::count_if(
+  NI->edges_begin(), NI->edges_end(),

I think I'll change this to llvm::count_if.  Also there was previously a 
conditional here that made sure the distance between edges was >0, but it 
didn't seem necessary. Please let me know if there's a reason I should put that 
back


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

https://reviews.llvm.org/D75936



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


[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-04-04 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 255084.
craig.topper added a comment.

-Apply updates to comments.
-Use nodes()/edges() to implement nodes_begin/end and edges_begin/end to 
simplify the code a little
-Reorder fields in the Graph class.


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

https://reviews.llvm.org/D75936

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/ImmutableGraph.h
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/O3-pipeline.ll
  llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll

Index: llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll
@@ -0,0 +1,129 @@
+; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown -x86-lvi-load-dot-verify -o %t < %s | FileCheck %s
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local i32 @test(i32* %untrusted_user_ptr, i32* %secret, i32 %secret_size) #0 {
+entry:
+  %untrusted_user_ptr.addr = alloca i32*, align 8
+  %secret.addr = alloca i32*, align 8
+  %secret_size.addr = alloca i32, align 4
+  %ret_val = alloca i32, align 4
+  %i = alloca i32, align 4
+  store i32* %untrusted_user_ptr, i32** %untrusted_user_ptr.addr, align 8
+  store i32* %secret, i32** %secret.addr, align 8
+  store i32 %secret_size, i32* %secret_size.addr, align 4
+  store i32 0, i32* %ret_val, align 4
+  call void @llvm.x86.sse2.lfence()
+  store i32 0, i32* %i, align 4
+  br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+  %0 = load i32, i32* %i, align 4
+  %1 = load i32, i32* %secret_size.addr, align 4
+  %cmp = icmp slt i32 %0, %1
+  br i1 %cmp, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+  %2 = load i32, i32* %i, align 4
+  %rem = srem i32 %2, 2
+  %cmp1 = icmp eq i32 %rem, 0
+  br i1 %cmp1, label %if.then, label %if.else
+
+if.then:  ; preds = %for.body
+  %3 = load i32*, i32** %secret.addr, align 8
+  %4 = load i32, i32* %ret_val, align 4
+  %idxprom = sext i32 %4 to i64
+  %arrayidx = getelementptr inbounds i32, i32* %3, i64 %idxprom
+  %5 = load i32, i32* %arrayidx, align 4
+  %6 = load i32*, i32** %untrusted_user_ptr.addr, align 8
+  store i32 %5, i32* %6, align 4
+  br label %if.end
+
+if.else:  ; preds = %for.body
+  %7 = load i32*, i32** %secret.addr, align 8
+  %8 = load i32, i32* %ret_val, align 4
+  %idxprom2 = sext i32 %8 to i64
+  %arrayidx3 = getelementptr inbounds i32, i32* %7, i64 %idxprom2
+  store i32 42, i32* %arrayidx3, align 4
+  br label %if.end
+
+if.end:   ; preds = %if.else, %if.then
+  %9 = load i32*, i32** %untrusted_user_ptr.addr, align 8
+  %10 = load i32, i32* %9, align 4
+  store i32 %10, i32* %ret_val, align 4
+  br label %for.inc
+
+for.inc:  ; preds = %if.end
+  %11 = load i32, i32* %i, align 4
+  %inc = add nsw i32 %11, 1
+  store i32 %inc, i32* %i, align 4
+  br label %for.cond
+
+for.end:  ; preds = %for.cond
+  %12 = load i32, i32* %ret_val, align 4
+  ret i32 %12
+}
+
+; CHECK:  digraph "Speculative gadgets for \"test\" function" {
+; CHECK-NEXT: label="Speculative gadgets for \"test\" function";
+; CHECK:  Node0x{{[0-9a-f]+}} [shape=record,color = green,label="{LFENCE\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 0];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{renamable $eax = MOV32rm %stack.4.i, 1, $noreg, 0, $noreg :: (dereferenceable load 4 from %ir.i)\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[color = red, style = "dashed"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{JCC_1 %bb.6, 13, implicit killed $eflags\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{CMP32rm killed renamable $eax, %stack.2.secret_size.addr, 1, $noreg, 0, $noreg, implicit-def $eflags :: (dereferenceable load 4 from %ir.secret_size.addr)\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[color = red, style = "dashed"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{renamable $eax = MOV32rm %stack.4.i, 1, $noreg, 0, $noreg :: (dereferenceabl

[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-04-04 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 255086.
craig.topper added a comment.

-Add methods to get the index of a Node or Edge to remove calls to 
std::distance in various places


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

https://reviews.llvm.org/D75936

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/ImmutableGraph.h
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/O3-pipeline.ll
  llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll

Index: llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/lvi-hardening-gadget-graph.ll
@@ -0,0 +1,129 @@
+; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown -x86-lvi-load-dot-verify -o %t < %s | FileCheck %s
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local i32 @test(i32* %untrusted_user_ptr, i32* %secret, i32 %secret_size) #0 {
+entry:
+  %untrusted_user_ptr.addr = alloca i32*, align 8
+  %secret.addr = alloca i32*, align 8
+  %secret_size.addr = alloca i32, align 4
+  %ret_val = alloca i32, align 4
+  %i = alloca i32, align 4
+  store i32* %untrusted_user_ptr, i32** %untrusted_user_ptr.addr, align 8
+  store i32* %secret, i32** %secret.addr, align 8
+  store i32 %secret_size, i32* %secret_size.addr, align 4
+  store i32 0, i32* %ret_val, align 4
+  call void @llvm.x86.sse2.lfence()
+  store i32 0, i32* %i, align 4
+  br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+  %0 = load i32, i32* %i, align 4
+  %1 = load i32, i32* %secret_size.addr, align 4
+  %cmp = icmp slt i32 %0, %1
+  br i1 %cmp, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+  %2 = load i32, i32* %i, align 4
+  %rem = srem i32 %2, 2
+  %cmp1 = icmp eq i32 %rem, 0
+  br i1 %cmp1, label %if.then, label %if.else
+
+if.then:  ; preds = %for.body
+  %3 = load i32*, i32** %secret.addr, align 8
+  %4 = load i32, i32* %ret_val, align 4
+  %idxprom = sext i32 %4 to i64
+  %arrayidx = getelementptr inbounds i32, i32* %3, i64 %idxprom
+  %5 = load i32, i32* %arrayidx, align 4
+  %6 = load i32*, i32** %untrusted_user_ptr.addr, align 8
+  store i32 %5, i32* %6, align 4
+  br label %if.end
+
+if.else:  ; preds = %for.body
+  %7 = load i32*, i32** %secret.addr, align 8
+  %8 = load i32, i32* %ret_val, align 4
+  %idxprom2 = sext i32 %8 to i64
+  %arrayidx3 = getelementptr inbounds i32, i32* %7, i64 %idxprom2
+  store i32 42, i32* %arrayidx3, align 4
+  br label %if.end
+
+if.end:   ; preds = %if.else, %if.then
+  %9 = load i32*, i32** %untrusted_user_ptr.addr, align 8
+  %10 = load i32, i32* %9, align 4
+  store i32 %10, i32* %ret_val, align 4
+  br label %for.inc
+
+for.inc:  ; preds = %if.end
+  %11 = load i32, i32* %i, align 4
+  %inc = add nsw i32 %11, 1
+  store i32 %inc, i32* %i, align 4
+  br label %for.cond
+
+for.end:  ; preds = %for.cond
+  %12 = load i32, i32* %ret_val, align 4
+  ret i32 %12
+}
+
+; CHECK:  digraph "Speculative gadgets for \"test\" function" {
+; CHECK-NEXT: label="Speculative gadgets for \"test\" function";
+; CHECK:  Node0x{{[0-9a-f]+}} [shape=record,color = green,label="{LFENCE\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 0];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{renamable $eax = MOV32rm %stack.4.i, 1, $noreg, 0, $noreg :: (dereferenceable load 4 from %ir.i)\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[color = red, style = "dashed"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{JCC_1 %bb.6, 13, implicit killed $eflags\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{CMP32rm killed renamable $eax, %stack.2.secret_size.addr, 1, $noreg, 0, $noreg, implicit-def $eflags :: (dereferenceable load 4 from %ir.secret_size.addr)\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[color = red, style = "dashed"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> Node0x{{[0-9a-f]+}}[label = 1];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} [shape=record,label="{renamable $eax = MOV32rm %stack.4.i, 1, $noreg, 0, $noreg :: (dereferenceable load 4 from %ir.i)\n}"];
+; CHECK-NEXT: Node0x{{[0-9a-f]+}} -> 

[PATCH] D77252: [OpenMP] Try to find an existing base for `omp begin/end declare variant`

2020-04-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked 2 inline comments as done.
jdoerfert added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:5512
+
+  if (!BaseFD) {
+// TODO: Determine if we can reuse the declarator to create a declaration

mikerice wrote:
> I think if you do the base lookup in 
> ActOnStartOfFunctionDefinitionInOpenMPDeclareVariantScope instead of here you 
> might have better success using the declarator.  You would need to get the 
> type and  constexpr/consteval info from the declarator and declspec but if 
> the lookup fails you can just use ActOnDeclarator to get a base declaration 
> like you were before.  I tried this in my sandbox and it seems to work (AST 
> tests fail I'm guessing that is just order change).  If that works we could 
> get rid of these hacky bits.
Can you share how you do the lookup and the type comparison with the 
Declarator? I mean, name lookup is simple but determining the right overload 
wrt. type and the namespace was something I always had problems with. If you 
want to stress test your solution and don't mind, take the math patch and run 
the `https://github.com/TApplencourt/OmpVal` tests:
`CXX='clang++' CXXFLAGS='-fopenmp -fopenmp-targets=nvptx64-nvidia-cuda' 
./omphval.sh run ./tests/math_cpp11`
You'll see compile or link errors if it doesn't work for any reason. Doesn't 
mean we could not make it work by changing in the math wrappers but that 
depends on the errors (if any).



Comment at: clang/lib/Sema/SemaOpenMP.cpp:5551
+  BaseFD->addAttr(OMPDeclareVariantA);
   BaseFD->setImplicit(true);
 }

mikerice wrote:
> BaseFD is only implicit now if you created it, not when one was found in the 
> lookup case right? 
Correct. Need to be changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77252



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


[PATCH] D77252: [OpenMP] Try to find an existing base for `omp begin/end declare variant`

2020-04-04 Thread Mike Rice via Phabricator via cfe-commits
mikerice added a comment.

I just moved your lookup code and tried to get the same info from the 
declarator.  The function looks like this:

  FunctionDecl *
  Sema::ActOnStartOfFunctionDefinitionInOpenMPDeclareVariantScope(Scope *S,
  Declarator 
&D) {
IdentifierInfo *BaseII = D.getIdentifier();
LookupResult Lookup(*this, DeclarationName(BaseII), D.getIdentifierLoc(),
LookupOrdinaryName);
LookupParsedName(Lookup, S, &D.getCXXScopeSpec());
  
TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S);
QualType FType = TInfo->getType();
  
bool IsConstexpr = D.getDeclSpec().getConstexprSpecifier() == CSK_constexpr;
bool IsConsteval = D.getDeclSpec().getConstexprSpecifier() == CSK_consteval;
  
FunctionDecl *BaseFD = nullptr;
for (auto *Candidate : Lookup) {
  auto *UDecl = dyn_cast(Candidate->getUnderlyingDecl());
  if (!UDecl)
continue;
  
  // Don't specialize constexpr/consteval functions with
  // non-constexpr/consteval functions.
  if (UDecl->isConstexpr() && !IsConstexpr)
continue;
  if (UDecl->isConsteval() && !IsConsteval)
continue;
  
  QualType NewType = Context.mergeFunctionTypes(
  FType, UDecl->getType(), /* OfBlockPointer */ false,
  /* Unqualified */ false, /* AllowCXX */ true);
  if (NewType.isNull())
continue;
  
  // Found a base!
  BaseFD = UDecl;
  break;
}
if (!BaseFD) {
  BaseFD = cast(ActOnDeclarator(S, D));
  BaseFD->setImplicit(true);
}
OMPDeclareVariantScope &DVScope = OMPDeclareVariantScopes.back();
std::string MangledName;
MangledName += D.getIdentifier()->getName();
MangledName += getOpenMPVariantManglingSeparatorStr();
MangledName += DVScope.NameSuffix;
IdentifierInfo &VariantII = Context.Idents.get(MangledName);
  
VariantII.setMangledOpenMPVariantName(true);
D.SetIdentifier(&VariantII, D.getBeginLoc());
return BaseFD;
  }

I just tried a few tests so I didn't spend too much time verifying it.  I'll 
see if I can get the test your suggest running.

I'm not sure I have any better ideas on how to correctly pick the base 
function.  This seems like a reasonable first attempt.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77252



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


[clang-tools-extra] abdd042 - [clang-tools-extra] NFC: Fix trivial typo in documents and comments

2020-04-04 Thread Kazuaki Ishizaki via cfe-commits

Author: Kazuaki Ishizaki
Date: 2020-04-05T11:26:19+09:00
New Revision: abdd042bb7a58bdb2511f0c776ced2c7cb71cac4

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

LOG: [clang-tools-extra] NFC: Fix trivial typo in documents and comments

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp 
b/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
index 357ecb016173..76b8ac02990e 100644
--- a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -116,7 +116,7 @@ void MultipleInheritanceCheck::check(const 
MatchFinder::MatchResult &Result) {
 }
 
 if (NumConcrete > 1) {
-  diag(D->getBeginLoc(), "inheriting mulitple classes that aren't "
+  diag(D->getBeginLoc(), "inheriting multiple classes that aren't "
  "pure virtual is discouraged");
 }
   }



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


[PATCH] D77252: [OpenMP] Try to find an existing base for `omp begin/end declare variant`

2020-04-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D77252#1961913 , @mikerice wrote:

> [...]
>
>[...]
>   TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S);
>   QualType FType = TInfo->getType();
>   [...]
>   


I think this is a key part of what I was missing. I'll try out your patch with 
the all the tests and update the patch if it works (which I assume). Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77252



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


[PATCH] D57835: Fix -ftime-report with -x ir

2020-04-04 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 255095.
arsenm added a comment.

Rebase, add new PM run line


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

https://reviews.llvm.org/D57835

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/test/Frontend/ftime-report-bitcode.ll


Index: clang/test/Frontend/ftime-report-bitcode.ll
===
--- /dev/null
+++ clang/test/Frontend/ftime-report-bitcode.ll
@@ -0,0 +1,15 @@
+; RUN: %clang_cc1 -triple x86_64-apple-darwin10 -ftime-report -emit-obj -o 
/dev/null %s 2>&1 | FileCheck %s
+; RUN: %clang_cc1 -triple x86_64-apple-darwin10 
-fexperimental-new-pass-manager -ftime-report -emit-obj -o /dev/null %s 2>&1 | 
FileCheck %s
+
+target triple ="x86_64-apple-darwin10"
+
+; Make sure the backend time reports are produced when compiling an IR
+; input
+
+; CHECK: Pass execution timing report
+; CHECK: LLVM IR Parsing
+; CHECK: Clang front-end time report
+
+define i32 @foo() {
+  ret i32 0
+}
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -37,6 +37,7 @@
 #include "clang/Serialization/GlobalModuleIndex.h"
 #include "clang/Serialization/InMemoryModuleCache.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/Pass.h"
 #include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/Errc.h"
@@ -957,8 +958,10 @@
<< " based upon " << BACKEND_PACKAGE_STRING
<< " default target " << llvm::sys::getDefaultTargetTriple() << "\n";
 
-  if (getFrontendOpts().ShowTimers)
+  if (getFrontendOpts().ShowTimers) {
+llvm::TimePassesIsEnabled = true;
 createFrontendTimer();
+  }
 
   if (getFrontendOpts().ShowStats || !getFrontendOpts().StatsFile.empty())
 llvm::EnableStatistics(false);
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -172,7 +172,6 @@
 CodeGenOpts, C, CoverageInfo)),
   LinkModules(std::move(LinkModules)) {
   FrontendTimesIsEnabled = TimePasses;
-  llvm::TimePassesIsEnabled = TimePasses;
 }
 llvm::Module *getModule() const { return Gen->GetModule(); }
 std::unique_ptr takeModule() {


Index: clang/test/Frontend/ftime-report-bitcode.ll
===
--- /dev/null
+++ clang/test/Frontend/ftime-report-bitcode.ll
@@ -0,0 +1,15 @@
+; RUN: %clang_cc1 -triple x86_64-apple-darwin10 -ftime-report -emit-obj -o /dev/null %s 2>&1 | FileCheck %s
+; RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fexperimental-new-pass-manager -ftime-report -emit-obj -o /dev/null %s 2>&1 | FileCheck %s
+
+target triple ="x86_64-apple-darwin10"
+
+; Make sure the backend time reports are produced when compiling an IR
+; input
+
+; CHECK: Pass execution timing report
+; CHECK: LLVM IR Parsing
+; CHECK: Clang front-end time report
+
+define i32 @foo() {
+  ret i32 0
+}
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -37,6 +37,7 @@
 #include "clang/Serialization/GlobalModuleIndex.h"
 #include "clang/Serialization/InMemoryModuleCache.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/Pass.h"
 #include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/Errc.h"
@@ -957,8 +958,10 @@
<< " based upon " << BACKEND_PACKAGE_STRING
<< " default target " << llvm::sys::getDefaultTargetTriple() << "\n";
 
-  if (getFrontendOpts().ShowTimers)
+  if (getFrontendOpts().ShowTimers) {
+llvm::TimePassesIsEnabled = true;
 createFrontendTimer();
+  }
 
   if (getFrontendOpts().ShowStats || !getFrontendOpts().StatsFile.empty())
 llvm::EnableStatistics(false);
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -172,7 +172,6 @@
 CodeGenOpts, C, CoverageInfo)),
   LinkModules(std::move(LinkModules)) {
   FrontendTimesIsEnabled = TimePasses;
-  llvm::TimePassesIsEnabled = TimePasses;
 }
 llvm::Module *getModule() const { return Gen->GetModule(); }
 std::unique_ptr takeModule() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77458: [clang-tools-extra] NFC: Fix trivial typo in documents and comments

2020-04-04 Thread Kazuaki Ishizaki via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGabdd042bb7a5: [clang-tools-extra] NFC: Fix trivial typo in 
documents and comments (authored by kiszk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77458

Files:
  clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp


Index: clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
===
--- clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -116,7 +116,7 @@
 }
 
 if (NumConcrete > 1) {
-  diag(D->getBeginLoc(), "inheriting mulitple classes that aren't "
+  diag(D->getBeginLoc(), "inheriting multiple classes that aren't "
  "pure virtual is discouraged");
 }
   }


Index: clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
===
--- clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -116,7 +116,7 @@
 }
 
 if (NumConcrete > 1) {
-  diag(D->getBeginLoc(), "inheriting mulitple classes that aren't "
+  diag(D->getBeginLoc(), "inheriting multiple classes that aren't "
  "pure virtual is discouraged");
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77482: [clang-tools-extra] NFC: Fix trivial typo in documents and comments

2020-04-04 Thread Kazuaki Ishizaki via Phabricator via cfe-commits
kiszk created this revision.
Herald added subscribers: cfe-commits, phosek, usaxena95, kadircet, jfb, 
arphaman, jkorous, kbarton, nemanjai.
Herald added a project: clang.

This also includes the build failure due to https://reviews.llvm.org/D77458


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77482

Files:
  clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
  clang-tools-extra/clang-change-namespace/ChangeNamespace.h
  clang-tools-extra/clang-doc/Generators.cpp
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-include-fixer/IncludeFixer.h
  clang-tools-extra/clang-include-fixer/IncludeFixerContext.h
  clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
  
clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py
  clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
  clang-tools-extra/clang-move/Move.cpp
  clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
  clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
  clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
  clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/FoldInitTypeCheck.cpp
  
clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
  clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h
  clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
  clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
  clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
  clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
  clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/FindSymbols.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/PathMapping.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/QueryDriverDatabase.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolOrigin.h
  clang-tools-extra/clangd/index/dex/Trigram.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp
  clang-tools-extra/clangd/unittests/PathMappingTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp
  clang-tools-extra/docs/clang-tidy/checks/abseil-no-internal-dependencies.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-pointer-arithmetic-in-alloc.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
  
clang

[PATCH] D77482: [clang-tools-extra] NFC: Fix trivial typo in documents and comments

2020-04-04 Thread Kazuaki Ishizaki via Phabricator via cfe-commits
kiszk added a subscriber: sammccall.
kiszk added a comment.
Herald added a subscriber: wuzish.

@sammccall, I am very sorry that I led to the build break due to my 
misoperation in https://reviews.llvm.org/D77458


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77482



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


[PATCH] D77184: Make it possible for lit.site.cfg to contain relative paths, and use it for llvm and clang

2020-04-04 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D77184#1961495 , @thakis wrote:

> In D77184#1961220 , @rsmith wrote:
>
> > In D77184#1961214 , @rsmith wrote:
> >
> > > In D77184#1961208 , @rsmith 
> > > wrote:
> > >
> > > > This has broken my ability to run the `check-clang` target on Linux. 
> > > > There are symlinks in the path from which I run my builds, and this 
> > > > patch is computing incorrect relative paths in that situation.
> > >
> > >
> > > This patch appears to fix the problem:
> >
> >
> > Turns out that's only a partial fix (it fixes `ninja clang-check` but not 
> > the general problem). Running `lit` from inside the source directory is 
> > still broken. Eg, this used to work:
> >
> >   clang/test$ $BUILDDIR/bin/llvm-lit SemaCXX/constant-expression.cpp
> >
> >
> > ... and doesn't work any more because the relative paths in 
> > `lit.site.cfg.py` don't seem to resolve to the right places. Please can you 
> > fix or revert?
>
>
> Can you describe your symlink setup in enough detail that I can recreate it 
> locally please?


Two directories $s and $d within $HOME.

Source git checkout in $s
Build dir is $d/build
Symlink $d/src -> $s
Symlink $s/clang/build -> $d/build
Symlink $c -> $s/clang

Configured from $d/build with `cmake ../src`
Actual build is run from $c/build
Manual `lit` commands are run from $c/test

I can provide you with the scripts I use to create my checkouts, symlinks, and 
to run cmake if you like.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77184



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


[PATCH] D77484: [Vector] Pass VectLib to LTO backend so TLI build correct vector function list

2020-04-04 Thread Wenlei He via Phabricator via cfe-commits
wenlei created this revision.
wenlei added reviewers: hoyFB, spatel.
Herald added subscribers: cfe-commits, dang, dexonsmith, steven_wu, MaskRay, 
hiraditya, arichardson, inglorion, emaste.
Herald added a reviewer: espindola.
Herald added a project: clang.

-fveclib switch not propagated to LTO backends, and as a result, LTO populates 
vector list as if no math lib is used. This change fixed the driver to lld, and 
to backend propagation of -fveclib setting.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77484

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/LTO.cpp
  lld/ELF/Options.td
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/LTO/LTOBackend.cpp

Index: llvm/lib/LTO/LTOBackend.cpp
===
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -279,6 +279,7 @@
 
   PassManagerBuilder PMB;
   PMB.LibraryInfo = new TargetLibraryInfoImpl(Triple(TM->getTargetTriple()));
+  PMB.LibraryInfo->addVectorizableFunctionsFromVecLib(Conf.Options.VectLib);
   PMB.Inliner = createFunctionInliningPass();
   PMB.ExportSummary = ExportSummary;
   PMB.ImportSummary = ImportSummary;
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -15,6 +15,7 @@
 #define LLVM_TARGET_TARGETOPTIONS_H
 
 #include "llvm/ADT/FloatingPointMode.h"
+#include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/MC/MCTargetOptions.h"
 
 #include 
@@ -320,6 +321,10 @@
 /// the value of this option.
 FPOpFusion::FPOpFusionMode AllowFPOpFusion = FPOpFusion::Standard;
 
+/// Vector library used for vectorizable math function calls
+TargetLibraryInfoImpl::VectorLibrary VectLib =
+TargetLibraryInfoImpl::NoLibrary;
+
 /// ThreadModel - This flag specifies the type of threading model to assume
 /// for things like atomics
 ThreadModel::Model ThreadModel = ThreadModel::POSIX;
Index: lld/ELF/Options.td
===
--- lld/ELF/Options.td
+++ lld/ELF/Options.td
@@ -488,6 +488,8 @@
 def lto_obj_path_eq: J<"lto-obj-path=">;
 def lto_sample_profile: J<"lto-sample-profile=">,
   HelpText<"Sample profile file path">;
+def lto_vector_library: J<"lto-vector-library=">,
+  HelpText<"Vector functions library">;
 def lto_whole_program_visibility: F<"lto-whole-program-visibility">,
   HelpText<"Asserts that the LTO link has whole program visibility">;
 def disable_verify: F<"disable-verify">;
@@ -552,6 +554,9 @@
 def: J<"plugin-opt=thinlto-prefix-replace=">,
   Alias,
   HelpText<"Alias for --thinlto-prefix-replace=">;
+def: J<"plugin-opt=vector-library=">,
+  Alias,
+  HelpText<"Alias for -lto-vector-library=">;
 
 // Ignore LTO plugin-related options.
 // clang -flto passes -plugin and -plugin-opt to the linker. This is required
Index: lld/ELF/LTO.cpp
===
--- lld/ELF/LTO.cpp
+++ lld/ELF/LTO.cpp
@@ -110,6 +110,7 @@
   c.UseNewPM = config->ltoNewPassManager;
   c.DebugPassManager = config->ltoDebugPassManager;
   c.DwoDir = std::string(config->dwoDir);
+  c.Options.VectLib = config->VectLib;
 
   c.HasWholeProgramVisibility = config->ltoWholeProgramVisibility;
 
Index: lld/ELF/Driver.cpp
===
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -704,6 +704,20 @@
   return OrphanHandlingPolicy::Place;
 }
 
+static llvm::TargetLibraryInfoImpl::VectorLibrary
+getVectLib(opt::InputArgList &args) {
+  StringRef s = args.getLastArgValue(OPT_lto_vector_library);
+  if (s == "Accelerate")
+return llvm::TargetLibraryInfoImpl::Accelerate;
+  if (s == "MASSV")
+return llvm::TargetLibraryInfoImpl::MASSV;
+  if (s == "SVML")
+return llvm::TargetLibraryInfoImpl::SVML;
+  if (!s.empty() && s != "none")
+error("unknown --vector-library type: " + s);
+  return llvm::TargetLibraryInfoImpl::NoLibrary;
+}
+
 // Parse --build-id or --build-id=

[PATCH] D77482: [clang-tools-extra] NFC: Fix trivial typo in documents and comments

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

In D77482#1962000 , @kiszk wrote:

> @sammccall, I am very sorry that I led to the build break due to my 
> misoperation in https://reviews.llvm.org/D77458


You could just update diff in existing revision. No need to create new one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77482



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


[PATCH] D77482: [clang-tools-extra] NFC: Fix trivial typo in documents and comments

2020-04-04 Thread Kazuaki Ishizaki via Phabricator via cfe-commits
kiszk added a comment.

Thank you for letting me know. I will do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77482



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


[PATCH] D77484: [Vector] Pass VectLib to LTO backend so TLI build correct vector function list

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

Added usual lld and LTO side reviewers. I am just a bit worried that option 
name changes like this patch and D77231  could 
accidentally slip through if I did not react in time...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77484



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


[PATCH] D77458: [clang-tools-extra] NFC: Fix trivial typo in documents and comments

2020-04-04 Thread Kazuaki Ishizaki via Phabricator via cfe-commits
kiszk updated this revision to Diff 255119.
kiszk added a comment.

This includes a fix to break the llvm build


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

https://reviews.llvm.org/D77458

Files:
  clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
  clang-tools-extra/clang-change-namespace/ChangeNamespace.h
  clang-tools-extra/clang-doc/Generators.cpp
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-include-fixer/IncludeFixer.h
  clang-tools-extra/clang-include-fixer/IncludeFixerContext.h
  clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
  
clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py
  clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
  clang-tools-extra/clang-move/Move.cpp
  clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
  clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
  clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
  clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/FoldInitTypeCheck.cpp
  
clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
  clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h
  clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
  clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
  clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
  clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
  clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/FindSymbols.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/PathMapping.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/QueryDriverDatabase.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolOrigin.h
  clang-tools-extra/clangd/index/dex/Trigram.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp
  clang-tools-extra/clangd/unittests/PathMappingTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp
  clang-tools-extra/docs/clang-tidy/checks/abseil-no-internal-dependencies.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-pointer-arithmetic-in-alloc.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
  
clang-tools-extra/docs/cla

[clang-tools-extra] dd5571d - [clang-tools-extra] NFC: Fix trivial typo in documents and comments

2020-04-04 Thread Kazuaki Ishizaki via cfe-commits

Author: Kazuaki Ishizaki
Date: 2020-04-05T15:28:40+09:00
New Revision: dd5571d51a0f6164cb66d02c8cd0e7032e42abe4

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

LOG: [clang-tools-extra] NFC: Fix trivial typo in documents and comments

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

Added: 


Modified: 
clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
clang-tools-extra/clang-change-namespace/ChangeNamespace.h
clang-tools-extra/clang-doc/Generators.cpp
clang-tools-extra/clang-doc/Serialize.cpp
clang-tools-extra/clang-include-fixer/IncludeFixer.h
clang-tools-extra/clang-include-fixer/IncludeFixerContext.h
clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp

clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py
clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
clang-tools-extra/clang-move/Move.cpp
clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
clang-tools-extra/clang-tidy/bugprone/FoldInitTypeCheck.cpp

clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h
clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/Diagnostics.cpp
clang-tools-extra/clangd/FindSymbols.h
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/FindTarget.h
clang-tools-extra/clangd/FormattedString.cpp
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/Hover.h
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/PathMapping.cpp
clang-tools-extra/clangd/Preamble.cpp
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/QueryDriverDatabase.cpp
clang-tools-extra/clangd/index/Background.cpp
clang-tools-extra/clangd/index/Serialization.cpp
clang-tools-extra/clangd/index/SymbolOrigin.h
clang-tools-extra/clangd/index/dex/Trigram.cpp
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/refactor/Rename.h
clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp
clang-tools-extra/clangd/unittests/PathMappingTests.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp
clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
clang-tools-extra/clangd/u

[PATCH] D77458: [clang-tools-extra] NFC: Fix trivial typo in documents and comments

2020-04-04 Thread Kazuaki Ishizaki via Phabricator via cfe-commits
kiszk updated this revision to Diff 255120.
kiszk added a comment.

This include the fix of the build failure at 
http://lab.llvm.org:8011/builders/clang-cmake-armv7-global-isel/builds/7450/steps/ninja%20check%201/logs/FAIL%3A%20Clang%20Tools%3A%3Afuchsia-multiple-inheritance.cpp


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

https://reviews.llvm.org/D77458

Files:
  clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
  clang-tools-extra/clang-change-namespace/ChangeNamespace.h
  clang-tools-extra/clang-doc/Generators.cpp
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-include-fixer/IncludeFixer.h
  clang-tools-extra/clang-include-fixer/IncludeFixerContext.h
  clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
  
clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py
  clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.py
  clang-tools-extra/clang-move/Move.cpp
  clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp
  clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
  clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
  clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/FoldInitTypeCheck.cpp
  
clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
  clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h
  clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
  clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
  clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
  clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
  clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/FindSymbols.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/PathMapping.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/QueryDriverDatabase.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolOrigin.h
  clang-tools-extra/clangd/index/dex/Trigram.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp
  clang-tools-extra/clangd/unittests/PathMappingTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-pointer-arithmetic-in-alloc.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
  
clang-tools-extra/docs/cl