[PATCH] D66332: [clang-format] Fix the bug that joins template closer and > or >>

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

> Are there any other clang-format options that might lead to a lack-of-space 
> before `>`, `>=`, `==`, or `=`? I brought up `enable_if_t=0` 
> because that specifically is a construction I've run into in my own code, 
> even though I've never tried to clang-format it, let alone have it formatted 
> incorrectly.

Any token that starts with `>`, e.g., `>`, `>>`, `>=`, and `>>=`, are already 
taken care of by this patch. For tokens starting with `=`, only the assignment 
operator `=` has a problem and it only occurs when 
`SpaceBeforeAssignmentOperators` is set to true.

I can insert a space between a template closer `>` and an assignment operator 
`=` despite the value of `SpaceBeforeAssignmentOperators`, but the formatted 
code may be inconsistent...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66332



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


[PATCH] D66046: Add new tautological compare warning for bitwise-or with a non-zero constant

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

You should also probably add a note in the release notes (maybe for the others 
changes too)
thanks for the work btw!


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

https://reviews.llvm.org/D66046



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


r369183 - [X86] Support -mlong-double-80

2019-08-16 Thread Troy A. Johnson via cfe-commits
Author: troyj
Date: Fri Aug 16 21:20:24 2019
New Revision: 369183

URL: http://llvm.org/viewvc/llvm-project?rev=369183=rev
Log:
[X86] Support -mlong-double-80

Add an option group for all of the -mlong-double-* options and make
-mlong-double-80 restore the default long double behavior for X86.  The
motivations are that GNU accepts the -mlong-double-80 option and that complex
Makefiles often need a way of undoing earlier options. Prior to this commit, if
one chooses 64-bit or 128-bit long double for X86, there is no way to undo that
choice and restore the 80-bit behavior.

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/mlong-double-128.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=369183=369182=369183=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Aug 16 21:20:24 2019
@@ -2040,9 +2040,14 @@ def malign_jumps_EQ : Joined<["-"], "mal
 def mfancy_math_387 : Flag<["-"], "mfancy-math-387">, 
Group;
 def mlong_calls : Flag<["-"], "mlong-calls">, Group,
   HelpText<"Generate branches with extended addressability, usually via 
indirect jumps.">;
-def mlong_double_64 : Flag<["-"], "mlong-double-64">, Group, 
Flags<[CC1Option]>,
+def LongDouble_Group : OptionGroup<"">, Group,
+  DocName<"Long double flags">,
+  DocBrief<[{Selects the long double implementation}]>;
+def mlong_double_64 : Flag<["-"], "mlong-double-64">, Group, 
Flags<[CC1Option]>,
   HelpText<"Force long double to be 64 bits">;
-def mlong_double_128 : Flag<["-"], "mlong-double-128">, Group, 
Flags<[CC1Option]>,
+def mlong_double_80 : Flag<["-"], "mlong-double-80">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Force long double to be 80 bits, padded to 128 bits for storage">;
+def mlong_double_128 : Flag<["-"], "mlong-double-128">, 
Group, Flags<[CC1Option]>,
   HelpText<"Force long double to be 128 bits">;
 def mno_long_calls : Flag<["-"], "mno-long-calls">, Group,
   HelpText<"Restore the default behaviour of not generating long calls">;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=369183=369182=369183=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Aug 16 21:20:24 2019
@@ -4057,11 +4057,12 @@ void Clang::ConstructJob(Compilation ,
 
   RenderFloatingPointOptions(TC, D, OFastEnabled, Args, CmdArgs);
 
-  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64,
-   options::OPT_mlong_double_128)) {
+  if (Arg *A = Args.getLastArg(options::OPT_LongDouble_Group)) {
 if (TC.getArch() == llvm::Triple::x86 ||
-TC.getArch() == llvm::Triple::x86_64 ||
-TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64())
+TC.getArch() == llvm::Triple::x86_64)
+  A->render(Args, CmdArgs);
+else if ((TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64()) &&
+ (A->getOption().getID() != options::OPT_mlong_double_80))
   A->render(Args, CmdArgs);
 else
   D.Diag(diag::err_drv_unsupported_opt_for_target)

Modified: cfe/trunk/test/Driver/mlong-double-128.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mlong-double-128.c?rev=369183=369182=369183=diff
==
--- cfe/trunk/test/Driver/mlong-double-128.c (original)
+++ cfe/trunk/test/Driver/mlong-double-128.c Fri Aug 16 21:20:24 2019
@@ -2,10 +2,14 @@
 // RUN: %clang -target powerpc64-pc-freebsd12 -c -### %s -mlong-double-128 
2>&1 | FileCheck %s
 // RUN: %clang -target powerpc64le-linux-musl -c -### %s -mlong-double-128 
2>&1 | FileCheck %s
 // RUN: %clang -target i686-linux-gnu -c -### %s -mlong-double-128 2>&1 | 
FileCheck %s
-// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-128 2>&1 | 
FileCheck %s
+
+// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-128 
-mlong-double-80 2>&1 | FileCheck --implicit-check-not=-mlong-double-128 
/dev/null
+// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-80 
-mlong-double-128 2>&1 | FileCheck %s
 
 // CHECK: "-mlong-double-128"
 
 // RUN: %clang -target aarch64 -c -### %s -mlong-double-128 2>&1 | FileCheck 
--check-prefix=ERR %s
+// RUN: %clang -target powerpc -c -### %s -mlong-double-80 2>&1 | FileCheck 
--check-prefix=ERR2 %s
 
 // ERR: error: unsupported option '-mlong-double-128' for target 'aarch64'
+// ERR2: error: unsupported option '-mlong-double-80' for target 'powerpc'


___
cfe-commits mailing list

[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-08-16 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 215734.
paulkirth added a comment.

Remove frontend components of clang-misexpect in favor of backend 
implementations


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66324

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext
  clang/test/Profile/Inputs/misexpect-branch.proftext
  clang/test/Profile/Inputs/misexpect-switch-default-only.proftext
  clang/test/Profile/Inputs/misexpect-switch.proftext
  clang/test/Profile/misexpect-branch-cold.c
  clang/test/Profile/misexpect-branch-nonconst-expected-val.c
  clang/test/Profile/misexpect-branch.c
  clang/test/Profile/misexpect-no-warning-without-flag.c
  clang/test/Profile/misexpect-switch-default.c
  clang/test/Profile/misexpect-switch-nonconst.c
  clang/test/Profile/misexpect-switch-only-default-case.c
  clang/test/Profile/misexpect-switch.c
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/FixedMetadataKinds.def
  llvm/include/llvm/IR/MDBuilder.h
  llvm/include/llvm/Transforms/Utils/MisExpect.h
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/MDBuilder.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt
  llvm/lib/Transforms/Utils/MisExpect.cpp
  llvm/test/ThinLTO/X86/lazyload_metadata.ll
  llvm/test/Transforms/LowerExpectIntrinsic/basic.ll

Index: llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
===
--- llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
+++ llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
@@ -138,7 +138,7 @@
   %conv1 = sext i32 %conv to i64
   %expval = call i64 @llvm.expect.i64(i64 %conv1, i64 0)
   %tobool = icmp ne i64 %expval, 0
-; CHECK: !prof !1
+; CHECK: !prof !2
 ; CHECK-NOT: @llvm.expect
   br i1 %tobool, label %if.then, label %if.end
 
@@ -165,7 +165,7 @@
   %tmp = load i32, i32* %x.addr, align 4
   %conv = sext i32 %tmp to i64
   %expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
-; CHECK: !prof !2
+; CHECK: !prof !4
 ; CHECK-NOT: @llvm.expect
   switch i64 %expval, label %sw.epilog [
 i64 1, label %sw.bb
@@ -194,7 +194,7 @@
   %tmp = load i32, i32* %x.addr, align 4
   %conv = sext i32 %tmp to i64
   %expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
-; CHECK: !prof !3
+; CHECK: !prof !5
 ; CHECK-NOT: @llvm.expect
   switch i64 %expval, label %sw.epilog [
 i64 2, label %sw.bb
@@ -278,7 +278,7 @@
   %t7 = call i64 @llvm.expect.i64(i64 %t6, i64 0)
   %t8 = icmp ne i64 %t7, 0
   %t9 = select i1 %t8, i32 1, i32 2
-; CHECK: select{{.*}}, !prof !1
+; CHECK: select{{.*}}, !prof !2
   ret i32 %t9
 }
 
@@ -286,6 +286,6 @@
 declare i1 @llvm.expect.i1(i1, i1) nounwind readnone
 
 ; CHECK: !0 = !{!"branch_weights", i32 2000, i32 1}
-; CHECK: !1 = !{!"branch_weights", i32 1, i32 2000}
-; CHECK: !2 = !{!"branch_weights", i32 1, i32 2000, i32 1}
-; CHECK: !3 = !{!"branch_weights", i32 2000, i32 1, i32 1}
+; CHECK: !2 = !{!"branch_weights", i32 1, i32 2000}
+; CHECK: !4 = !{!"branch_weights", i32 1, i32 2000, i32 1}
+; CHECK: !5 = !{!"branch_weights", i32 2000, i32 1, i32 1}
Index: llvm/test/ThinLTO/X86/lazyload_metadata.ll
===
--- llvm/test/ThinLTO/X86/lazyload_metadata.ll
+++ llvm/test/ThinLTO/X86/lazyload_metadata.ll
@@ -10,13 +10,13 @@
 ; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t3.bc \
 ; RUN:  -o /dev/null -stats \
 ; RUN:  2>&1 | FileCheck %s -check-prefix=LAZY
-; LAZY: 61 bitcode-reader  - Number of Metadata records loaded
+; LAZY: 63 bitcode-reader  - Number of Metadata records loaded
 ; LAZY: 2 bitcode-reader  - Number of MDStrings loaded
 
 ; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t3.bc \
 ; RUN:  -o /dev/null -disable-ondemand-mds-loading -stats \
 ; RUN:  2>&1 | FileCheck %s -check-prefix=NOTLAZY
-; NOTLAZY: 70 bitcode-reader  - Number of Metadata records loaded
+; NOTLAZY: 72 bitcode-reader  - Number of Metadata records loaded
 ; NOTLAZY: 7 bitcode-reader  - Number of MDStrings loaded
 
 
Index: llvm/lib/Transforms/Utils/MisExpect.cpp
===
--- /dev/null
+++ llvm/lib/Transforms/Utils/MisExpect.cpp
@@ -0,0 +1,125 @@
+//===--- MisExpect.cpp - Check Use of __builtin_expect() with PGO data ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//

[PATCH] D66378: [clang-doc] Fix casting not working in gcc 5.4.0

2019-08-16 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added a comment.

LGTM, for posterity


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66378



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


[PATCH] D66378: [clang-doc] Fix casting not working in gcc 5.4.0

2019-08-16 Thread Diego Astiazarán via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369182: [clang-doc] Fix casting not working in gcc 5.4.0 
(authored by DiegoAstiazaran, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66378?vs=215730=215732#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66378

Files:
  clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp


Index: clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp
===
--- clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp
+++ clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp
@@ -89,7 +89,7 @@
 
   HTMLTag Tag; // Name of HTML Tag (p, div, h1)
   std::vector> Children; // List of child nodes
-  std::vector, llvm::SmallString<16>>>
+  std::vector>
   Attributes; // List of key-value attributes for tag
 
   void Render(llvm::raw_ostream , int IndentationLevel) override;
@@ -278,7 +278,7 @@
 llvm::sys::path::filename(FilePath));
 // Paths in HTML must be in posix-style
 llvm::sys::path::native(StylesheetPath, llvm::sys::path::Style::posix);
-LinkNode->Attributes.emplace_back("href", StylesheetPath);
+LinkNode->Attributes.emplace_back("href", StylesheetPath.str());
 Out.emplace_back(std::move(LinkNode));
   }
   return Out;
@@ -293,7 +293,7 @@
 llvm::sys::path::append(ScriptPath, llvm::sys::path::filename(FilePath));
 // Paths in HTML must be in posix-style
 llvm::sys::path::native(ScriptPath, llvm::sys::path::Style::posix);
-ScriptNode->Attributes.emplace_back("src", ScriptPath);
+ScriptNode->Attributes.emplace_back("src", ScriptPath.str());
 Out.emplace_back(std::move(ScriptNode));
   }
   return Out;
@@ -454,7 +454,7 @@
   Node->Children.emplace_back(std::make_unique(" of file "));
   auto LocFileNode = std::make_unique(
   HTMLTag::TAG_A, llvm::sys::path::filename(FileURL));
-  LocFileNode->Attributes.emplace_back("href", FileURL);
+  LocFileNode->Attributes.emplace_back("href", FileURL.str());
   Node->Children.emplace_back(std::move(LocFileNode));
   return Node;
 }


Index: clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp
===
--- clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp
+++ clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp
@@ -89,7 +89,7 @@
 
   HTMLTag Tag; // Name of HTML Tag (p, div, h1)
   std::vector> Children; // List of child nodes
-  std::vector, llvm::SmallString<16>>>
+  std::vector>
   Attributes; // List of key-value attributes for tag
 
   void Render(llvm::raw_ostream , int IndentationLevel) override;
@@ -278,7 +278,7 @@
 llvm::sys::path::filename(FilePath));
 // Paths in HTML must be in posix-style
 llvm::sys::path::native(StylesheetPath, llvm::sys::path::Style::posix);
-LinkNode->Attributes.emplace_back("href", StylesheetPath);
+LinkNode->Attributes.emplace_back("href", StylesheetPath.str());
 Out.emplace_back(std::move(LinkNode));
   }
   return Out;
@@ -293,7 +293,7 @@
 llvm::sys::path::append(ScriptPath, llvm::sys::path::filename(FilePath));
 // Paths in HTML must be in posix-style
 llvm::sys::path::native(ScriptPath, llvm::sys::path::Style::posix);
-ScriptNode->Attributes.emplace_back("src", ScriptPath);
+ScriptNode->Attributes.emplace_back("src", ScriptPath.str());
 Out.emplace_back(std::move(ScriptNode));
   }
   return Out;
@@ -454,7 +454,7 @@
   Node->Children.emplace_back(std::make_unique(" of file "));
   auto LocFileNode = std::make_unique(
   HTMLTag::TAG_A, llvm::sys::path::filename(FileURL));
-  LocFileNode->Attributes.emplace_back("href", FileURL);
+  LocFileNode->Attributes.emplace_back("href", FileURL.str());
   Node->Children.emplace_back(std::move(LocFileNode));
   return Node;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62731: [RFC] Add support for options -fp-model= and -fp-speculation= : specify floating point behavior

2019-08-16 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:126
+  case LangOptions::FPM_Precise:
+  case LangOptions::FPM_Fast:
+break;

mibintc wrote:
> mibintc wrote:
> > kpn wrote:
> > > Wait, so "fast" and "precise" are the same thing? That doesn't sound like 
> > > where the documentation you put in the ticket says "the compiler 
> > > preserves the source expression ordering and rounding properties of 
> > > floating-point".
> > > 
> > > (Yes, I saw below where "fast" turns on the fast math flags but "precise" 
> > > doesn't. That doesn't affect my point here.)
> > "precise" doesn't necessitate the use of Constrained Intrinsics, And 
> > likewise for "fast".   The words "compiler preserves the source expression 
> > ordering" were copied from the msdn documentation for /fp:precise as you 
> > explained it would be useful to have the msdn documentation for the option 
> > in case it goes offline in, say, 30 years.  The ICL Intel compiler also 
> > provides equivalent floating point options. The Intel documentation for 
> > precise is phrased differently "Disables optimizations that are not 
> > value-safe on floating-point data."  
> > 
> > fp-model=precise should enable contractions, if that's not true at default 
> > (I mean, clang -c) then this patch is missing that.
> > 
> > fp-model=fast is the same as requesting ffast-math 
> Well, we haven't heard from Andy yet, but he told me some time ago that 
> /fp:precise corresponds more or less (there was wiggle room) to clang's 
> default behavior.  It sounds like you think the description in the msdn of 
> /fp:precise isn't describing clang's default behavior, @kpn can you say more 
> about that, and do you think that ConstrainedIntrinsics should be created to 
> provide the semantics of /fp:precise? 
"Precise" means that no value unsafe optimizations will be performed. That's 
what LLVM does by default. As long as no fast math flags are set, we will not 
perform optimizations that are not value safe.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731



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


[PATCH] D66378: [clang-doc] Fix casting not working in gcc 5.4.0

2019-08-16 Thread Diego Astiazarán via Phabricator via cfe-commits
DiegoAstiazaran created this revision.
DiegoAstiazaran added a project: clang-tools-extra.

An implicit cast of std::string to llvm::SmallString<> was breaking GCC 5.4.0 
builder.
A pair using llvm::SmallString<> now uses std::string.


https://reviews.llvm.org/D66378

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp


Index: clang-tools-extra/clang-doc/HTMLGenerator.cpp
===
--- clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -89,7 +89,7 @@
 
   HTMLTag Tag; // Name of HTML Tag (p, div, h1)
   std::vector> Children; // List of child nodes
-  std::vector, llvm::SmallString<16>>>
+  std::vector>
   Attributes; // List of key-value attributes for tag
 
   void Render(llvm::raw_ostream , int IndentationLevel) override;
@@ -278,7 +278,7 @@
 llvm::sys::path::filename(FilePath));
 // Paths in HTML must be in posix-style
 llvm::sys::path::native(StylesheetPath, llvm::sys::path::Style::posix);
-LinkNode->Attributes.emplace_back("href", StylesheetPath);
+LinkNode->Attributes.emplace_back("href", StylesheetPath.str());
 Out.emplace_back(std::move(LinkNode));
   }
   return Out;
@@ -293,7 +293,7 @@
 llvm::sys::path::append(ScriptPath, llvm::sys::path::filename(FilePath));
 // Paths in HTML must be in posix-style
 llvm::sys::path::native(ScriptPath, llvm::sys::path::Style::posix);
-ScriptNode->Attributes.emplace_back("src", ScriptPath);
+ScriptNode->Attributes.emplace_back("src", ScriptPath.str());
 Out.emplace_back(std::move(ScriptNode));
   }
   return Out;
@@ -454,7 +454,7 @@
   Node->Children.emplace_back(std::make_unique(" of file "));
   auto LocFileNode = std::make_unique(
   HTMLTag::TAG_A, llvm::sys::path::filename(FileURL));
-  LocFileNode->Attributes.emplace_back("href", FileURL);
+  LocFileNode->Attributes.emplace_back("href", FileURL.str());
   Node->Children.emplace_back(std::move(LocFileNode));
   return Node;
 }


Index: clang-tools-extra/clang-doc/HTMLGenerator.cpp
===
--- clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -89,7 +89,7 @@
 
   HTMLTag Tag; // Name of HTML Tag (p, div, h1)
   std::vector> Children; // List of child nodes
-  std::vector, llvm::SmallString<16>>>
+  std::vector>
   Attributes; // List of key-value attributes for tag
 
   void Render(llvm::raw_ostream , int IndentationLevel) override;
@@ -278,7 +278,7 @@
 llvm::sys::path::filename(FilePath));
 // Paths in HTML must be in posix-style
 llvm::sys::path::native(StylesheetPath, llvm::sys::path::Style::posix);
-LinkNode->Attributes.emplace_back("href", StylesheetPath);
+LinkNode->Attributes.emplace_back("href", StylesheetPath.str());
 Out.emplace_back(std::move(LinkNode));
   }
   return Out;
@@ -293,7 +293,7 @@
 llvm::sys::path::append(ScriptPath, llvm::sys::path::filename(FilePath));
 // Paths in HTML must be in posix-style
 llvm::sys::path::native(ScriptPath, llvm::sys::path::Style::posix);
-ScriptNode->Attributes.emplace_back("src", ScriptPath);
+ScriptNode->Attributes.emplace_back("src", ScriptPath.str());
 Out.emplace_back(std::move(ScriptNode));
   }
   return Out;
@@ -454,7 +454,7 @@
   Node->Children.emplace_back(std::make_unique(" of file "));
   auto LocFileNode = std::make_unique(
   HTMLTag::TAG_A, llvm::sys::path::filename(FileURL));
-  LocFileNode->Attributes.emplace_back("href", FileURL);
+  LocFileNode->Attributes.emplace_back("href", FileURL.str());
   Node->Children.emplace_back(std::move(LocFileNode));
   return Node;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r369182 - [clang-doc] Fix casting not working in gcc 5.4.0

2019-08-16 Thread Diego Astiazaran via cfe-commits
Author: diegoastiazaran
Date: Fri Aug 16 18:45:03 2019
New Revision: 369182

URL: http://llvm.org/viewvc/llvm-project?rev=369182=rev
Log:
[clang-doc] Fix casting not working in gcc 5.4.0

An implicit cast of std::string to llvm::SmallString<> was breaking GCC 5.4.0 
builder.
A pair using llvm::SmallString<> now uses std::string.

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

Modified:
clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp

Modified: clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp?rev=369182=369181=369182=diff
==
--- clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp (original)
+++ clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp Fri Aug 16 18:45:03 2019
@@ -89,7 +89,7 @@ struct TagNode : public HTMLNode {
 
   HTMLTag Tag; // Name of HTML Tag (p, div, h1)
   std::vector> Children; // List of child nodes
-  std::vector, llvm::SmallString<16>>>
+  std::vector>
   Attributes; // List of key-value attributes for tag
 
   void Render(llvm::raw_ostream , int IndentationLevel) override;
@@ -278,7 +278,7 @@ genStylesheetsHTML(StringRef InfoPath, c
 llvm::sys::path::filename(FilePath));
 // Paths in HTML must be in posix-style
 llvm::sys::path::native(StylesheetPath, llvm::sys::path::Style::posix);
-LinkNode->Attributes.emplace_back("href", StylesheetPath);
+LinkNode->Attributes.emplace_back("href", StylesheetPath.str());
 Out.emplace_back(std::move(LinkNode));
   }
   return Out;
@@ -293,7 +293,7 @@ genJsScriptsHTML(StringRef InfoPath, con
 llvm::sys::path::append(ScriptPath, llvm::sys::path::filename(FilePath));
 // Paths in HTML must be in posix-style
 llvm::sys::path::native(ScriptPath, llvm::sys::path::Style::posix);
-ScriptNode->Attributes.emplace_back("src", ScriptPath);
+ScriptNode->Attributes.emplace_back("src", ScriptPath.str());
 Out.emplace_back(std::move(ScriptNode));
   }
   return Out;
@@ -454,7 +454,7 @@ writeFileDefinition(const Location ,
   Node->Children.emplace_back(std::make_unique(" of file "));
   auto LocFileNode = std::make_unique(
   HTMLTag::TAG_A, llvm::sys::path::filename(FileURL));
-  LocFileNode->Attributes.emplace_back("href", FileURL);
+  LocFileNode->Attributes.emplace_back("href", FileURL.str());
   Node->Children.emplace_back(std::move(LocFileNode));
   return Node;
 }


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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-08-16 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev marked 2 inline comments as done.
sdmitriev added inline comments.



Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:72
+private:
+  IntegerType *getSizeTTy() {
+switch (M.getDataLayout().getPointerTypeSize(Type::getInt8PtrTy(C))) {

ABataev wrote:
> 1. Markt it `const`.
> 2. This still is not the best solution, since `size_t` not necessarily has 
> the pointer size. I don't know if there is a better solution. @hfinkel? If 
> this is the best, why not just to use `getIntPtrType(C)`?
It cannot be const because of Type::getIntXXTy(LLVMContext ) calls.



Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:171
+  // Global variable that represents BinDesc is returned.
+  GlobalVariable *createBinDesc(const SmallVectorImpl ) {
+// Create external begin/end symbols for the offload entries table.

ABataev wrote:
> Use `ArrayRef` instead of `const SmallVectorImpl &`
Done. And I have also changed MemoryBufferRef => ArrayRef (as you earlier 
suggested).


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

https://reviews.llvm.org/D64943



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


[PATCH] D66122: [CodeGen] Emit dynamic initializers for static TLS vars in outlined scopes

2019-08-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> in the proper order

I would prefer lexical order, if possible.  (At least, the order should be 
deterministic.)

> clang should either generate an error or do "the right thing."

Agreed.

I think we should send a defect report to the C++ standards committee to 
clarify the ambiguity here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66122



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


[PATCH] D66364: Diagnose use of _Thread_local as an extension when appropriate

2019-08-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D66364#1633775 , @rsmith wrote:

> `_Thread_local` is a reserved identifier; we generally don't produce 
> extension warnings for uses of reserved identifiers. (Eg, there's no warning 
> for `_Atomic` in C++ or `_Bool` in C89, and no warning for uses of 
> `__type_traits` or `__builtins`.)
>
> But I note that we *do* warn for some of these already (eg, `_Generic`, 
> `_Static_assert`, `_Alignas`, and `_Alignof` get a warning). We should choose 
> a rule and apply it consistently.
>
> What's the motivation for warning on this? Maybe that can inform whether 
> these warnings are useful in general.


My motivation is for portability. _Thread_local (and all the rest) do not exist 
in C99 or earlier (or C++), so having some way to warn users of that is useful. 
I agree that we should be consistent and go with all or none, but my preference 
is for all (esp since this is a -pedantic warning class).

That said, I think `__builtins` and `__type_traits` are a separate question, 
and a somewhat interesting one. I could see some value in a pedantic warning 
for use of a reserved identifier which is an implementation detail outside of a 
system header in theory, but I'm not entirely sure what such a diagnostic would 
look like in practice. Is `__clang__` an implementation detail? I don't think 
we should warn on uses of it! What about `_UNICODE` when working with MSVC 
compat? Same situation. Rather than try to answer that question, I think I draw 
the line with only pedantically warning on reserved identifiers in the 
standard. WDYT?


Repository:
  rC Clang

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

https://reviews.llvm.org/D66364



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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-08-16 Thread Vyacheslav Zakharin via Phabricator via cfe-commits
vzakhari added a comment.

FYI, llvm.global_dtor fix is in https://reviews.llvm.org/D66373


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

https://reviews.llvm.org/D64943



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


[PATCH] D66332: [clang-format] Fix the bug that joins template closer and > or >>

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

In D66332#1633749 , @owenpan wrote:

> Do you have `SpaceBeforeAssignmentOperators` off?


Yes; I mean, that's what I tested in order to produce the buggy behavior. I 
don't believe anyone should be using that option in production, though, and 
would totally support a patch to remove it completely because it can't possibly 
be doing anyone any good.  It feels like someone meant to implement 
`SpacesAroundAssignmentOperators` but then got the name wrong, and then someone 
fixed the behavior to match the name, and at this point it's just completely 
broken. :)

> The documentation 
> 
>  should be fixed.

Also agreed.

Are there any other clang-format options that might lead to a lack-of-space 
before `>`, `>=`, `==`, or `=`? I brought up `enable_if_t=0` because 
that specifically is a construction I've run into in my own code, even though 
I've never tried to clang-format it, let alone have it formatted incorrectly.

(Clang-format probably does not promise to preserve the AST of pathological 
input like `i++ ++;` or C++03-specific input such as `A >` or `A< ::B>`.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66332



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


[PATCH] D66044: Extend -Wtautological-overlap-compare to accept negative values and integer conversions

2019-08-16 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

//*appreciates CFG tests*//




Comment at: test/Analysis/cfg.cpp:504-506
+// CHECK-NEXT:  2: return [B2.1];
+// CHECK-NEXT:  Preds (1): B3(Unreachable)
+// CHECK-NEXT:  Succs (1): B0

Looks like runaway formatting.


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

https://reviews.llvm.org/D66044



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


[PATCH] D65907: Introduce FileEntryRef and use it when handling includes to report correct dependencies when the FileManager is reused across invocations

2019-08-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 215719.
arphaman added a comment.

remove accidentally include diff's `.rej` file.


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

https://reviews.llvm.org/D65907

Files:
  clang/include/clang/Basic/FileManager.h
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Lex/DirectoryLookup.h
  clang/include/clang/Lex/HeaderMap.h
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
  clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
  clang/lib/Lex/HeaderMap.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/VFS/external-names.c
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/DependencyScannerTest.cpp

Index: clang/unittests/Tooling/DependencyScannerTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/DependencyScannerTest.cpp
@@ -0,0 +1,118 @@
+//===- unittest/Tooling/ToolingTest.cpp - Tooling unit tests --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclGroup.h"
+#include "clang/Frontend/ASTUnit.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Tooling/CompilationDatabase.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/TargetRegistry.h"
+#include "llvm/Support/TargetSelect.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace tooling {
+
+namespace {
+
+/// Prints out all of the gathered dependencies into a string.
+class TestFileCollector : public DependencyFileGenerator {
+public:
+  TestFileCollector(DependencyOutputOptions ,
+std::vector )
+  : DependencyFileGenerator(Opts), Deps(Deps) {}
+
+  void finishedMainFile(DiagnosticsEngine ) override {
+Deps = getDependencies();
+  }
+
+private:
+  std::vector 
+};
+
+class TestDependencyScanningAction : public tooling::ToolAction {
+public:
+  TestDependencyScanningAction(std::vector ) : Deps(Deps) {}
+
+  bool runInvocation(std::shared_ptr Invocation,
+ FileManager *FileMgr,
+ std::shared_ptr PCHContainerOps,
+ DiagnosticConsumer *DiagConsumer) override {
+CompilerInstance Compiler(std::move(PCHContainerOps));
+Compiler.setInvocation(std::move(Invocation));
+Compiler.setFileManager(FileMgr);
+
+Compiler.createDiagnostics(DiagConsumer, /*ShouldOwnClient=*/false);
+if (!Compiler.hasDiagnostics())
+  return false;
+
+Compiler.createSourceManager(*FileMgr);
+Compiler.addDependencyCollector(std::make_shared(
+Compiler.getInvocation().getDependencyOutputOpts(), Deps));
+
+auto Action = std::make_unique();
+return Compiler.ExecuteAction(*Action);
+  }
+
+private:
+  std::vector 
+};
+
+} // namespace
+
+TEST(DependencyScanner, ScanDepsReuseFilemanager) {
+  std::vector Compilation = {"-c", "-E", "-MT", "test.cpp.o"};
+  StringRef CWD = "/root";
+  FixedCompilationDatabase CDB(CWD, Compilation);
+
+  auto VFS = new llvm::vfs::InMemoryFileSystem();
+  VFS->setCurrentWorkingDirectory(CWD);
+  VFS->addFile("/root/header.h", 0, llvm::MemoryBuffer::getMemBuffer("\n"));
+  VFS->addHardLink("/root/symlink.h", "/root/header.h");
+  VFS->addFile("/root/test.cpp", 0,
+   llvm::MemoryBuffer::getMemBuffer(
+   "#include \"symlink.h\"\n#include \"header.h\"\n"));
+
+  ClangTool Tool(CDB, {"test.cpp"}, std::make_shared(),
+ VFS);
+  Tool.clearArgumentsAdjusters();
+  std::vector Deps;
+  TestDependencyScanningAction Action(Deps);
+  Tool.run();
+  // The first invocation should return dependencies in order of access.
+  ASSERT_EQ(Deps.size(), 3u);
+  EXPECT_EQ(Deps[0], "/root/test.cpp");
+  EXPECT_EQ(Deps[1], "/root/symlink.h");
+  EXPECT_EQ(Deps[2], "/root/header.h");
+
+  // The file manager should still have two FileEntries, as one file is a
+  // hardlink.
+  FileManager  = Tool.getFiles();
+  EXPECT_EQ(Files.getNumUniqueRealFiles(), 2u);
+
+  Deps.clear();
+  Tool.run();
+  // The second invocation should have the 

[PATCH] D65907: Introduce FileEntryRef and use it when handling includes to report correct dependencies when the FileManager is reused across invocations

2019-08-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 215718.
arphaman marked 8 inline comments as done.
arphaman added a comment.

Address review comments and proper `use-external-names` support.


Repository:
  rC Clang

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

https://reviews.llvm.org/D65907

Files:
  clang/include/clang/Basic/FileManager.h
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Lex/DirectoryLookup.h
  clang/include/clang/Lex/HeaderMap.h
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
  clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
  clang/lib/Lex/HeaderMap.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/HeaderSearch.cpp.rej
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/VFS/external-names.c
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/DependencyScannerTest.cpp

Index: clang/unittests/Tooling/DependencyScannerTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/DependencyScannerTest.cpp
@@ -0,0 +1,118 @@
+//===- unittest/Tooling/ToolingTest.cpp - Tooling unit tests --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclGroup.h"
+#include "clang/Frontend/ASTUnit.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Tooling/CompilationDatabase.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/TargetRegistry.h"
+#include "llvm/Support/TargetSelect.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace tooling {
+
+namespace {
+
+/// Prints out all of the gathered dependencies into a string.
+class TestFileCollector : public DependencyFileGenerator {
+public:
+  TestFileCollector(DependencyOutputOptions ,
+std::vector )
+  : DependencyFileGenerator(Opts), Deps(Deps) {}
+
+  void finishedMainFile(DiagnosticsEngine ) override {
+Deps = getDependencies();
+  }
+
+private:
+  std::vector 
+};
+
+class TestDependencyScanningAction : public tooling::ToolAction {
+public:
+  TestDependencyScanningAction(std::vector ) : Deps(Deps) {}
+
+  bool runInvocation(std::shared_ptr Invocation,
+ FileManager *FileMgr,
+ std::shared_ptr PCHContainerOps,
+ DiagnosticConsumer *DiagConsumer) override {
+CompilerInstance Compiler(std::move(PCHContainerOps));
+Compiler.setInvocation(std::move(Invocation));
+Compiler.setFileManager(FileMgr);
+
+Compiler.createDiagnostics(DiagConsumer, /*ShouldOwnClient=*/false);
+if (!Compiler.hasDiagnostics())
+  return false;
+
+Compiler.createSourceManager(*FileMgr);
+Compiler.addDependencyCollector(std::make_shared(
+Compiler.getInvocation().getDependencyOutputOpts(), Deps));
+
+auto Action = std::make_unique();
+return Compiler.ExecuteAction(*Action);
+  }
+
+private:
+  std::vector 
+};
+
+} // namespace
+
+TEST(DependencyScanner, ScanDepsReuseFilemanager) {
+  std::vector Compilation = {"-c", "-E", "-MT", "test.cpp.o"};
+  StringRef CWD = "/root";
+  FixedCompilationDatabase CDB(CWD, Compilation);
+
+  auto VFS = new llvm::vfs::InMemoryFileSystem();
+  VFS->setCurrentWorkingDirectory(CWD);
+  VFS->addFile("/root/header.h", 0, llvm::MemoryBuffer::getMemBuffer("\n"));
+  VFS->addHardLink("/root/symlink.h", "/root/header.h");
+  VFS->addFile("/root/test.cpp", 0,
+   llvm::MemoryBuffer::getMemBuffer(
+   "#include \"symlink.h\"\n#include \"header.h\"\n"));
+
+  ClangTool Tool(CDB, {"test.cpp"}, std::make_shared(),
+ VFS);
+  Tool.clearArgumentsAdjusters();
+  std::vector Deps;
+  TestDependencyScanningAction Action(Deps);
+  Tool.run();
+  // The first invocation should return dependencies in order of access.
+  ASSERT_EQ(Deps.size(), 3u);
+  EXPECT_EQ(Deps[0], "/root/test.cpp");
+  EXPECT_EQ(Deps[1], "/root/symlink.h");
+  EXPECT_EQ(Deps[2], "/root/header.h");
+
+  // The file manager should still have two FileEntries, as one file is a
+  // hardlink.
+  FileManager  = Tool.getFiles();
+  

[PATCH] D65907: Introduce FileEntryRef and use it when handling includes to report correct dependencies when the FileManager is reused across invocations

2019-08-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: clang/include/clang/Basic/FileManager.h:110
+/// A reference to a \c FileEntry that includes the name of the file as it was
+/// accessed by the FileManager's client.
+class FileEntryRef {

bruno wrote:
> How does that work with the VFS? Will it keep the virtual path as the 
> FileName to return with getName() or the external-content? Should it change 
> when in face of `use-external-names` attribute?
Good catch. In the first patch `getFileRef` didn't honor `use-external-names` 
correctly (specifically once a file was opened once, for subsequent open of 
that file, it returned the VFS name, not the external name). 

I fixed this issue by introducing a potential indirection to `SeenFileEntries` 
in the update patch. Now the `getFileRef` should always return the virtual 
path, unless `use-external-names` is specified, and then it will return the 
external path.



Comment at: clang/include/clang/Basic/FileManager.h:130
+
+  const DirectoryEntry *getDir() const { return Entry.getDir(); }
+

Bigcheese wrote:
> Isn't this incorrect in the case of symlinks?
Right, I was planning to provide another way to get a directory with name. For 
now I'll just remove this method, so clients will have to call into FileEntry.



Comment at: clang/include/clang/Basic/FileManager.h:249-251
+  /// This function is deprecated and will be removed at some point in the
+  /// future, new clients should use
+  ///  \c getFileRef.

bruno wrote:
> Bigcheese wrote:
> > `LLVM_DEPRECATED()`?  (or w/e the name is of our depreciation attribute 
> > macro).
> Probably can't be done until we move all uses over? There's probably still 
> enough of them that the warning would be very annoying?
That's right, I can't mark the function as deprecated just yet, as you'll get a 
lot of warnings when building clang.


Repository:
  rC Clang

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

https://reviews.llvm.org/D65907



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


[PATCH] D66045: Improve detection of same value in comparisons

2019-08-16 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Thanks from me as well.




Comment at: lib/AST/Expr.cpp:4009
+  auto getAnyDecl = [](const Expr *E) -> const ValueDecl * {
+if (auto *DRE = dyn_cast(E))
+  return DRE->getDecl();

`const auto *`?


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

https://reviews.llvm.org/D66045



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


[PATCH] D59922: [Attributor] Deduce "no-capture" argument attribute

2019-08-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 215716.
jdoerfert added a comment.

Add tests accidentally removed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59922

Files:
  llvm/include/llvm/Transforms/IPO/Attributor.h
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/test/Transforms/FunctionAttrs/align.ll
  llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll
  llvm/test/Transforms/FunctionAttrs/arg_returned.ll
  llvm/test/Transforms/FunctionAttrs/dereferenceable.ll
  llvm/test/Transforms/FunctionAttrs/noalias_returned.ll
  llvm/test/Transforms/FunctionAttrs/nocapture.ll
  llvm/test/Transforms/FunctionAttrs/nonnull.ll
  llvm/test/Transforms/FunctionAttrs/nosync.ll
  llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll

Index: llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll
===
--- llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll
+++ llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll
@@ -103,7 +103,7 @@
 }
 
 ; CHECK: Function Attrs: nofree norecurse nosync nounwind
-; CHECK-NEXT: define i32* @external_sink_ret2_nrw(i32* readnone %n0, i32* nocapture readonly %r0, i32* returned %w0)
+; CHECK-NEXT: define i32* @external_sink_ret2_nrw(i32* readnone %n0, i32* nocapture readonly %r0, i32* returned "no-capture-maybe-returned" %w0)
 define i32* @external_sink_ret2_nrw(i32* %n0, i32* %r0, i32* %w0) {
 entry:
   %tobool = icmp ne i32* %n0, null
Index: llvm/test/Transforms/FunctionAttrs/nosync.ll
===
--- llvm/test/Transforms/FunctionAttrs/nosync.ll
+++ llvm/test/Transforms/FunctionAttrs/nosync.ll
@@ -28,7 +28,7 @@
 ; FNATTR: Function Attrs: norecurse nounwind optsize readnone ssp uwtable
 ; FNATTR-NEXT: define nonnull i32* @foo(%struct.ST* readnone %s)
 ; ATTRIBUTOR: Function Attrs: nofree nosync nounwind optsize readnone ssp uwtable
-; ATTRIBUTOR-NEXT: define nonnull i32* @foo(%struct.ST* %s)
+; ATTRIBUTOR-NEXT: define nonnull i32* @foo(%struct.ST* "no-capture-maybe-returned" %s)
 define i32* @foo(%struct.ST* %s) nounwind uwtable readnone optsize ssp {
 entry:
   %arrayidx = getelementptr inbounds %struct.ST, %struct.ST* %s, i64 1, i32 2, i32 1, i64 5, i64 13
@@ -186,7 +186,7 @@
 ; FNATTR: Function Attrs: nofree noinline nounwind uwtable
 ; FNATTR-NEXT: define i32 @scc1(i32* %0)
 ; ATTRIBUTOR: Function Attrs: nofree noinline noreturn nosync nounwind uwtable
-; ATTRIBUTOR-NEXT: define i32 @scc1(i32* %0)
+; ATTRIBUTOR-NEXT: define i32 @scc1(i32* nocapture %0)
 define i32 @scc1(i32* %0) noinline nounwind uwtable {
   tail call void @scc2(i32* %0);
   %val = tail call i32 @volatile_load(i32* %0);
@@ -196,7 +196,7 @@
 ; FNATTR: Function Attrs: nofree noinline nounwind uwtable
 ; FNATTR-NEXT: define void @scc2(i32* %0)
 ; ATTRIBUTOR: Function Attrs: nofree noinline noreturn nosync nounwind uwtable
-; ATTRIBUTOR-NEXT: define void @scc2(i32* %0)
+; ATTRIBUTOR-NEXT: define void @scc2(i32* nocapture %0)
 define void @scc2(i32* %0) noinline nounwind uwtable {
   tail call i32 @scc1(i32* %0);
   ret void;
@@ -224,7 +224,7 @@
 ; FNATTR: Function Attrs: nofree norecurse nounwind
 ; FNATTR-NEXT: define void @foo1(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
 ; ATTRIBUTOR-NOT: nosync
-; ATTRIBUTOR: define void @foo1(i32* %0, %"struct.std::atomic"* %1)
+; ATTRIBUTOR: define void @foo1(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
 define void @foo1(i32* %0, %"struct.std::atomic"* %1) {
   store i32 100, i32* %0, align 4
   fence release
@@ -236,7 +236,7 @@
 ; FNATTR: Function Attrs: nofree norecurse nounwind
 ; FNATTR-NEXT: define void @bar(i32* nocapture readnone %0, %"struct.std::atomic"* nocapture readonly %1)
 ; ATTRIBUTOR-NOT: nosync
-; ATTRIBUTOR: define void @bar(i32* %0, %"struct.std::atomic"* %1)
+; ATTRIBUTOR: define void @bar(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
 define void @bar(i32* %0, %"struct.std::atomic"* %1) {
   %3 = getelementptr inbounds %"struct.std::atomic", %"struct.std::atomic"* %1, i64 0, i32 0, i32 0
   br label %4
@@ -256,7 +256,7 @@
 ; FNATTR: Function Attrs: nofree norecurse nounwind
 ; FNATTR-NEXT: define void @foo1_singlethread(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
 ; ATTRIBUTOR: Function Attrs: nofree nosync
-; ATTRIBUTOR: define void @foo1_singlethread(i32* %0, %"struct.std::atomic"* %1)
+; ATTRIBUTOR: define void @foo1_singlethread(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
 define void @foo1_singlethread(i32* %0, %"struct.std::atomic"* %1) {
   store i32 100, i32* %0, align 4
   fence syncscope("singlethread") release
@@ -268,7 +268,7 @@
 ; FNATTR: Function Attrs: nofree norecurse nounwind
 ; FNATTR-NEXT: define void @bar_singlethread(i32* nocapture readnone %0, %"struct.std::atomic"* nocapture readonly %1)
 ; ATTRIBUTOR: Function 

[PATCH] D65019: [ARM] push LR before __gnu_mcount_nc

2019-08-16 Thread Jian Cai via Phabricator via cfe-commits
jcai19 closed this revision.
jcai19 added a comment.

Upsteamed to r369173.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65019



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


[PATCH] D66046: Add new tautological compare warning for bitwise-or with a non-zero constant

2019-08-16 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Looks great, thank you!




Comment at: lib/Analysis/CFG.cpp:1118
+Expr::EvalResult Result;
+if (!Constant->EvaluateAsInt(Result, *Context))
+  return {};

rtrieu wrote:
> NoQ wrote:
> > It's kinda strange to me that we first confirm that it's a constant by 
> > doing `tryTransformToIntOrEnumConstant`, but then fire up the heavy 
> > machinery of `EvaluateAsInt` anyway. Did you consider using only 
> > `EvaluateAsInt()` to begin with? I guess you're trying to make sure that 
> > "the user's intent is clear" as other similar warnings do, right? Could you 
> > comment on that?
> A new function has been created to check the zero-ness of the Expr.  Since we 
> know it the Expr comes from tryTransformToIntOrEnumConstant, this function 
> doesn't have to handle the full Expr sub-classes.
Whoa!


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

https://reviews.llvm.org/D66046



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


[PATCH] D59922: [Attributor] Deduce "no-capture" argument attribute

2019-08-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 215713.
jdoerfert added a comment.

Add more test coverage and improve capture information based on 
dereferenceability


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59922

Files:
  llvm/include/llvm/Transforms/IPO/Attributor.h
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/test/Transforms/FunctionAttrs/align.ll
  llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll
  llvm/test/Transforms/FunctionAttrs/arg_returned.ll
  llvm/test/Transforms/FunctionAttrs/dereferenceable.ll
  llvm/test/Transforms/FunctionAttrs/noalias_returned.ll
  llvm/test/Transforms/FunctionAttrs/nocapture.ll
  llvm/test/Transforms/FunctionAttrs/nonnull.ll
  llvm/test/Transforms/FunctionAttrs/nosync.ll
  llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll

Index: llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll
===
--- llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll
+++ llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll
@@ -103,7 +103,7 @@
 }
 
 ; CHECK: Function Attrs: nofree norecurse nosync nounwind
-; CHECK-NEXT: define i32* @external_sink_ret2_nrw(i32* readnone %n0, i32* nocapture readonly %r0, i32* returned %w0)
+; CHECK-NEXT: define i32* @external_sink_ret2_nrw(i32* readnone %n0, i32* nocapture readonly %r0, i32* returned "no-capture-maybe-returned" %w0)
 define i32* @external_sink_ret2_nrw(i32* %n0, i32* %r0, i32* %w0) {
 entry:
   %tobool = icmp ne i32* %n0, null
Index: llvm/test/Transforms/FunctionAttrs/nosync.ll
===
--- llvm/test/Transforms/FunctionAttrs/nosync.ll
+++ llvm/test/Transforms/FunctionAttrs/nosync.ll
@@ -28,7 +28,7 @@
 ; FNATTR: Function Attrs: norecurse nounwind optsize readnone ssp uwtable
 ; FNATTR-NEXT: define nonnull i32* @foo(%struct.ST* readnone %s)
 ; ATTRIBUTOR: Function Attrs: nofree nosync nounwind optsize readnone ssp uwtable
-; ATTRIBUTOR-NEXT: define nonnull i32* @foo(%struct.ST* %s)
+; ATTRIBUTOR-NEXT: define nonnull i32* @foo(%struct.ST* "no-capture-maybe-returned" %s)
 define i32* @foo(%struct.ST* %s) nounwind uwtable readnone optsize ssp {
 entry:
   %arrayidx = getelementptr inbounds %struct.ST, %struct.ST* %s, i64 1, i32 2, i32 1, i64 5, i64 13
@@ -186,7 +186,7 @@
 ; FNATTR: Function Attrs: nofree noinline nounwind uwtable
 ; FNATTR-NEXT: define i32 @scc1(i32* %0)
 ; ATTRIBUTOR: Function Attrs: nofree noinline noreturn nosync nounwind uwtable
-; ATTRIBUTOR-NEXT: define i32 @scc1(i32* %0)
+; ATTRIBUTOR-NEXT: define i32 @scc1(i32* nocapture %0)
 define i32 @scc1(i32* %0) noinline nounwind uwtable {
   tail call void @scc2(i32* %0);
   %val = tail call i32 @volatile_load(i32* %0);
@@ -196,7 +196,7 @@
 ; FNATTR: Function Attrs: nofree noinline nounwind uwtable
 ; FNATTR-NEXT: define void @scc2(i32* %0)
 ; ATTRIBUTOR: Function Attrs: nofree noinline noreturn nosync nounwind uwtable
-; ATTRIBUTOR-NEXT: define void @scc2(i32* %0)
+; ATTRIBUTOR-NEXT: define void @scc2(i32* nocapture %0)
 define void @scc2(i32* %0) noinline nounwind uwtable {
   tail call i32 @scc1(i32* %0);
   ret void;
@@ -224,7 +224,7 @@
 ; FNATTR: Function Attrs: nofree norecurse nounwind
 ; FNATTR-NEXT: define void @foo1(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
 ; ATTRIBUTOR-NOT: nosync
-; ATTRIBUTOR: define void @foo1(i32* %0, %"struct.std::atomic"* %1)
+; ATTRIBUTOR: define void @foo1(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
 define void @foo1(i32* %0, %"struct.std::atomic"* %1) {
   store i32 100, i32* %0, align 4
   fence release
@@ -236,7 +236,7 @@
 ; FNATTR: Function Attrs: nofree norecurse nounwind
 ; FNATTR-NEXT: define void @bar(i32* nocapture readnone %0, %"struct.std::atomic"* nocapture readonly %1)
 ; ATTRIBUTOR-NOT: nosync
-; ATTRIBUTOR: define void @bar(i32* %0, %"struct.std::atomic"* %1)
+; ATTRIBUTOR: define void @bar(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
 define void @bar(i32* %0, %"struct.std::atomic"* %1) {
   %3 = getelementptr inbounds %"struct.std::atomic", %"struct.std::atomic"* %1, i64 0, i32 0, i32 0
   br label %4
@@ -256,7 +256,7 @@
 ; FNATTR: Function Attrs: nofree norecurse nounwind
 ; FNATTR-NEXT: define void @foo1_singlethread(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
 ; ATTRIBUTOR: Function Attrs: nofree nosync
-; ATTRIBUTOR: define void @foo1_singlethread(i32* %0, %"struct.std::atomic"* %1)
+; ATTRIBUTOR: define void @foo1_singlethread(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
 define void @foo1_singlethread(i32* %0, %"struct.std::atomic"* %1) {
   store i32 100, i32* %0, align 4
   fence syncscope("singlethread") release
@@ -268,7 +268,7 @@
 ; FNATTR: Function Attrs: nofree norecurse nounwind
 ; FNATTR-NEXT: define void @bar_singlethread(i32* nocapture readnone %0, %"struct.std::atomic"* 

r369173 - Reland "[ARM] push LR before __gnu_mcount_nc"

2019-08-16 Thread Jian Cai via cfe-commits
Author: jcai19
Date: Fri Aug 16 16:30:16 2019
New Revision: 369173

URL: http://llvm.org/viewvc/llvm-project?rev=369173=rev
Log:
Reland "[ARM] push LR before __gnu_mcount_nc"

This relands r369147 with fixes to unit tests.

https://reviews.llvm.org/D65019

Modified:
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/test/Frontend/gnu-mcount.c

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=369173=369172=369173=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Fri Aug 16 16:30:16 2019
@@ -322,7 +322,7 @@ ARMTargetInfo::ARMTargetInfo(const llvm:
   if (Triple.getOS() == llvm::Triple::Linux ||
   Triple.getOS() == llvm::Triple::UnknownOS)
 this->MCountName = Opts.EABIVersion == llvm::EABI::GNU
-   ? "\01__gnu_mcount_nc"
+   ? "llvm.arm.gnu.eabi.mcount"
: "\01mcount";
 
   SoftFloatABI = llvm::is_contained(Opts.FeaturesAsWritten, "+soft-float-abi");

Modified: cfe/trunk/test/Frontend/gnu-mcount.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/gnu-mcount.c?rev=369173=369172=369173=diff
==
--- cfe/trunk/test/Frontend/gnu-mcount.c (original)
+++ cfe/trunk/test/Frontend/gnu-mcount.c Fri Aug 16 16:30:16 2019
@@ -66,7 +66,7 @@ int f() {
 // CHECK-ARM64-EABI-OPENBSD: attributes #{{[0-9]+}} = { 
{{.*}}"instrument-function-entry-inlined"="__mcount"{{.*}} }
 // CHECK-ARM64-EABI-OPENBSD-NOT: attributes #{{[0-9]+}} = { 
{{.*}}"instrument-function-entry-inlined"="\01__gnu_mcount_nc"{{.*}} }
 // CHECK-ARM-EABI-MEABI-GNU-NOT: attributes #{{[0-9]+}} = { 
{{.*}}"instrument-function-entry-inlined"="mcount"{{.*}} }
-// CHECK-ARM-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { 
{{.*}}"instrument-function-entry-inlined"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { 
{{.*}}"instrument-function-entry-inlined"="llvm.arm.gnu.eabi.mcount"{{.*}} }
 // CHECK-ARM-EABI-RTEMS: attributes #{{[0-9]+}} = { 
{{.*}}"instrument-function-entry-inlined"="mcount"{{.*}} }
 // CHECK-ARM-EABI-RTEMS-NOT: attributes #{{[0-9]+}} = { 
{{.*}}"instrument-function-entry-inlined"="\01__gnu_mcount_nc"{{.*}} }
 // CHECK-ARM64-EABI-RTEMS: attributes #{{[0-9]+}} = { 
{{.*}}"instrument-function-entry-inlined"="mcount"{{.*}} }


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


[PATCH] D65019: [ARM] push LR before __gnu_mcount_nc

2019-08-16 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 215710.
jcai19 added a comment.

Fix frontend mcount unit tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65019

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Frontend/gnu-mcount.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.h
  llvm/lib/Target/ARM/ARMInstrInfo.td
  llvm/lib/Target/ARM/ARMInstrThumb.td
  llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
  llvm/test/CodeGen/ARM/gnu_mcount_nc.ll
  llvm/test/Transforms/EntryExitInstrumenter/mcount.ll

Index: llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
===
--- llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
+++ llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
@@ -54,7 +54,7 @@
 
 define void @f2() #2 { entry: ret void }
 ; CHECK-LABEL: define void @f2
-; CHECK: call void @"\01__gnu_mcount_nc"
+; CHECK: call void @llvm.arm.gnu.eabi.mcount
 
 define void @f3() #3 { entry: ret void }
 ; CHECK-LABEL: define void @f3
@@ -105,7 +105,7 @@
 
 attributes #0 = { "instrument-function-entry-inlined"="mcount" "instrument-function-entry"="__cyg_profile_func_enter" "instrument-function-exit"="__cyg_profile_func_exit" }
 attributes #1 = { "instrument-function-entry-inlined"=".mcount" }
-attributes #2 = { "instrument-function-entry-inlined"="\01__gnu_mcount_nc" }
+attributes #2 = { "instrument-function-entry-inlined"="llvm.arm.gnu.eabi.mcount" }
 attributes #3 = { "instrument-function-entry-inlined"="\01_mcount" }
 attributes #4 = { "instrument-function-entry-inlined"="\01mcount" }
 attributes #5 = { "instrument-function-entry-inlined"="__mcount" }
Index: llvm/test/CodeGen/ARM/gnu_mcount_nc.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/gnu_mcount_nc.ll
@@ -0,0 +1,41 @@
+; RUN: llc -mtriple=armv7a-linux-gnueabihf -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=CHECK-ARM
+; RUN: llc -mtriple=armv7a-linux-gnueabihf -verify-machineinstrs -fast-isel %s -o - | FileCheck %s --check-prefix=CHECK-ARM-FAST-ISEL
+; RUN: llc -mtriple=armv7a-linux-gnueabihf -verify-machineinstrs -global-isel -global-isel-abort=2 %s -o - | FileCheck %s --check-prefix=CHECK-ARM-GLOBAL-ISEL
+; RUN: llc -mtriple=thumbv7a-linux-gnueabihf -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=CHECK-THUMB
+; RUN: llc -mtriple=thumbv7a-linux-gnueabihf -verify-machineinstrs -fast-isel %s -o - | FileCheck %s --check-prefix=CHECK-THUMB-FAST-ISEL
+; RUN: llc -mtriple=thumbv7a-linux-gnueabihf -verify-machineinstrs -global-isel -global-isel-abort=2 %s -o - | FileCheck %s --check-prefix=CHECK-THUMB-GLOBAL-ISEL
+
+define dso_local void @callee() #0 {
+; CHECK-ARM:stmdb   sp!, {lr}
+; CHECK-ARM-NEXT:   bl  __gnu_mcount_nc
+; CHECK-ARM-FAST-ISEL:  stmdb   sp!, {lr}
+; CHECK-ARM-FAST-ISEL-NEXT: bl  __gnu_mcount_nc
+; CHECK-ARM-GLOBAL-ISEL:stmdb   sp!, {lr}
+; CHECK-ARM-GLOBAL-ISEL-NEXT:   bl  __gnu_mcount_nc
+; CHECK-THUMB:  push{lr}
+; CHECK-THUMB-NEXT: bl  __gnu_mcount_nc
+; CHECK-THUMB-FAST-ISEL:push{lr}
+; CHECK-THUMB-FAST-ISEL-NEXT:   bl  __gnu_mcount_nc
+; CHECK-THUMB-GLOBAL-ISEL:  push{lr}
+; CHECK-THUMB-GLOBAL-ISEL-NEXT: bl  __gnu_mcount_nc
+  ret void
+}
+
+define dso_local void @caller() #0 {
+; CHECK-ARM:stmdb   sp!, {lr}
+; CHECK-ARM-NEXT:   bl  __gnu_mcount_nc
+; CHECK-ARM-FAST-ISEL:  stmdb   sp!, {lr}
+; CHECK-ARM-FAST-ISEL-NEXT: bl  __gnu_mcount_nc
+; CHECK-ARM-GLOBAL-ISEL:stmdb   sp!, {lr}
+; CHECK-ARM-GLOBAL-ISEL-NEXT:   bl  __gnu_mcount_nc
+; CHECK-THUMB:  push{lr}
+; CHECK-THUMB-NEXT: bl  __gnu_mcount_nc
+; CHECK-THUMB-FAST-ISEL:push{lr}
+; CHECK-THUMB-FAST-ISEL-NEXT:   bl  __gnu_mcount_nc
+; CHECK-THUMB-GLOBAL-ISEL:  push{lr}
+; CHECK-THUMB-GLOBAL-ISEL-NEXT: bl  __gnu_mcount_nc
+  call void @callee()
+  ret void
+}
+
+attributes #0 = { nofree nounwind "instrument-function-entry-inlined"="llvm.arm.gnu.eabi.mcount" }
Index: llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
===
--- llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
+++ llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
@@ -24,7 +24,7 @@
 
   if (Func == "mcount" ||
   Func == ".mcount" ||
-  Func == "\01__gnu_mcount_nc" ||
+  Func == "llvm.arm.gnu.eabi.mcount" ||
   Func == "\01_mcount" ||
   Func == "\01mcount" ||
   Func == "__mcount" ||
Index: llvm/lib/Target/ARM/ARMInstrThumb.td
===
--- 

[PATCH] D66122: [CodeGen] Emit dynamic initializers for static TLS vars in outlined scopes

2019-08-16 Thread Princeton Ferro via Phabricator via cfe-commits
Prince781 updated this revision to Diff 215709.
Prince781 added a comment.

Use range-based version of llvm::sort


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66122

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCXX/cxx11-thread-local.cpp

Index: clang/test/CodeGenCXX/cxx11-thread-local.cpp
===
--- clang/test/CodeGenCXX/cxx11-thread-local.cpp
+++ clang/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -268,6 +268,33 @@
   return this->n;
 }
 
+namespace static_tls_in_lambda {
+  struct X {
+X() {}
+  };
+
+
+  X (*f())() {
+static thread_local X x;
+
+return [] { return x; };
+  }
+
+  auto y = f();
+
+  void g() { y(); }
+
+  void bar(X**, X**, X**);
+  void baz(void());
+  void f2() {
+  thread_local X x;
+  thread_local X* p = 
+  thread_local X* q = p;
+  thread_local X* r = q;
+  baz([]{bar(, , );});
+  }
+}
+
 namespace {
 thread_local int anon_i{1};
 }
@@ -303,6 +330,42 @@
 // CHECK: store i64 1, i64* @_ZGVN1XIiE1mE
 // CHECK: br label
 
+// CHECK: define internal void @"_ZZN20static_tls_in_lambda1fEvENK3$_1clEv"
+// CHECK: %[[static_tls_guard_val:.*]] = load i8, i8* @_ZGVZN20static_tls_in_lambda1fEvE1x
+// CHECK: %[[static_tls_guard_init:.*]] = icmp eq i8 %[[static_tls_guard_val]], 0
+// CHECK: br i1 %[[static_tls_guard_init]],
+// CHECK: call void @_ZN20static_tls_in_lambda1XC1Ev(%"struct.static_tls_in_lambda::X"* @_ZZN20static_tls_in_lambda1fEvE1x)
+// CHECK: store i8 1, i8* @_ZGVZN20static_tls_in_lambda1fEvE1x, align 1
+
+// CHECK: define internal void @"_ZZN20static_tls_in_lambda2f2EvENK3$_2clEv"
+// init x
+// CHECK: %[[static_tls_guard_val:.*]] = load i8, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1x
+// CHECK: %[[static_tls_guard_init:.*]] = icmp eq i8 %[[static_tls_guard_val]], 0
+// CHECK: br i1 %[[static_tls_guard_init]],
+// CHECK: call void @_ZN20static_tls_in_lambda1XC1Ev(%"struct.static_tls_in_lambda::X"* @_ZZN20static_tls_in_lambda2f2EvE1x)
+// CHECK: store i8 1, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1x, align 1
+// init p
+// CHECK: %[[static_tls_guard_val:.*]] = load i8, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1p
+// CHECK: %[[static_tls_guard_init:.*]] = icmp eq i8 %[[static_tls_guard_val]], 0
+// CHECK: br i1 %[[static_tls_guard_init]],
+// CHECK: store %"struct.static_tls_in_lambda::X"* @_ZZN20static_tls_in_lambda2f2EvE1x, %"struct.static_tls_in_lambda::X"** @_ZZN20static_tls_in_lambda2f2EvE1p
+// CHECK: store i8 1, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1p, align 1
+// init q
+// CHECK: %[[static_tls_guard_val:.*]] = load i8, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1q
+// CHECK: %[[static_tls_guard_init:.*]] = icmp eq i8 %[[static_tls_guard_val]], 0
+// CHECK: br i1 %[[static_tls_guard_init]],
+// CHECK: %[[static_tls_var_prev:.*]] = load %"struct.static_tls_in_lambda::X"*, %"struct.static_tls_in_lambda::X"** @_ZZN20static_tls_in_lambda2f2EvE1p, align 8
+// CHECK: store %"struct.static_tls_in_lambda::X"* %[[static_tls_var_prev]], %"struct.static_tls_in_lambda::X"** @_ZZN20static_tls_in_lambda2f2EvE1q, align 8
+// CHECK: store i8 1, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1q, align 1
+// init r
+// CHECK: %[[static_tls_guard_val:.*]] = load i8, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1r
+// CHECK: %[[static_tls_guard_init:.*]] = icmp eq i8 %[[static_tls_guard_val]], 0
+// CHECK: br i1 %[[static_tls_guard_init]],
+// CHECK: %[[static_tls_var_prev:.*]] = load %"struct.static_tls_in_lambda::X"*, %"struct.static_tls_in_lambda::X"** @_ZZN20static_tls_in_lambda2f2EvE1q, align 8
+// CHECK: store %"struct.static_tls_in_lambda::X"* %[[static_tls_var_prev]], %"struct.static_tls_in_lambda::X"** @_ZZN20static_tls_in_lambda2f2EvE1r, align 8
+// CHECK: store i8 1, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1r, align 1
+
+
 // CHECK: define {{.*}}@[[GLOBAL_INIT:.*]]()
 // CHECK: call void @[[C_INIT]]()
 // CHECK: call void @[[E_INIT]]()
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -467,6 +467,10 @@
   /// should emit cleanups.
   bool CurFuncIsThunk = false;
 
+  /// static thread-local variables we've referenced that were declared in a
+  /// parent function.
+  llvm::SmallSet ForeignStaticTLSVars;
+
   /// In ARC, whether we should autorelease the return value.
   bool AutoreleaseResult = false;
 
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -31,6 +31,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
+#include "llvm/ADT/STLExtras.h"
 #include 

r369170 - Revert "[X86] Support -mlong-double-80"

2019-08-16 Thread Troy A. Johnson via cfe-commits
Author: troyj
Date: Fri Aug 16 16:18:22 2019
New Revision: 369170

URL: http://llvm.org/viewvc/llvm-project?rev=369170=rev
Log:
Revert "[X86] Support -mlong-double-80"

This reverts commit 250aafa2c4a1bc2395edfe8d4365545bbe56fffe.
Caused buildbot failures -- still investigating.

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/mlong-double-128.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=369170=369169=369170=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Aug 16 16:18:22 2019
@@ -2040,14 +2040,9 @@ def malign_jumps_EQ : Joined<["-"], "mal
 def mfancy_math_387 : Flag<["-"], "mfancy-math-387">, 
Group;
 def mlong_calls : Flag<["-"], "mlong-calls">, Group,
   HelpText<"Generate branches with extended addressability, usually via 
indirect jumps.">;
-def LongDouble_Group : OptionGroup<"">, Group,
-  DocName<"Long double flags">,
-  DocBrief<[{Selects the long double implementation}]>;
-def mlong_double_64 : Flag<["-"], "mlong-double-64">, Group, 
Flags<[CC1Option]>,
+def mlong_double_64 : Flag<["-"], "mlong-double-64">, Group, 
Flags<[CC1Option]>,
   HelpText<"Force long double to be 64 bits">;
-def mlong_double_80 : Flag<["-"], "mlong-double-80">, Group, 
Flags<[CC1Option]>,
-  HelpText<"Force long double to be 80 bits, padded to 128 bits for storage">;
-def mlong_double_128 : Flag<["-"], "mlong-double-128">, 
Group, Flags<[CC1Option]>,
+def mlong_double_128 : Flag<["-"], "mlong-double-128">, Group, 
Flags<[CC1Option]>,
   HelpText<"Force long double to be 128 bits">;
 def mno_long_calls : Flag<["-"], "mno-long-calls">, Group,
   HelpText<"Restore the default behaviour of not generating long calls">;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=369170=369169=369170=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Aug 16 16:18:22 2019
@@ -4057,13 +4057,11 @@ void Clang::ConstructJob(Compilation ,
 
   RenderFloatingPointOptions(TC, D, OFastEnabled, Args, CmdArgs);
 
-  if (Arg *A = Args.getLastArg(options::OPT_LongDouble_Group)) {
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64,
+   options::OPT_mlong_double_128)) {
 if (TC.getArch() == llvm::Triple::x86 ||
-TC.getArch() == llvm::Triple::x86_64)
-  A->render(Args, CmdArgs);
-else if ((TC.getArch() == llvm::Triple::ppc ||
-  TC.getArch() == TC.getTriple().isPPC64()) &&
- (A->getOption().getID() != options::OPT_mlong_double_80))
+TC.getArch() == llvm::Triple::x86_64 ||
+TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64())
   A->render(Args, CmdArgs);
 else
   D.Diag(diag::err_drv_unsupported_opt_for_target)

Modified: cfe/trunk/test/Driver/mlong-double-128.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mlong-double-128.c?rev=369170=369169=369170=diff
==
--- cfe/trunk/test/Driver/mlong-double-128.c (original)
+++ cfe/trunk/test/Driver/mlong-double-128.c Fri Aug 16 16:18:22 2019
@@ -2,14 +2,10 @@
 // RUN: %clang -target powerpc64-pc-freebsd12 -c -### %s -mlong-double-128 
2>&1 | FileCheck %s
 // RUN: %clang -target powerpc64le-linux-musl -c -### %s -mlong-double-128 
2>&1 | FileCheck %s
 // RUN: %clang -target i686-linux-gnu -c -### %s -mlong-double-128 2>&1 | 
FileCheck %s
-
-// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-128 
-mlong-double-80 2>&1 | FileCheck --implicit-check-not=-mlong-double- /dev/null
-// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-80 
-mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-128 2>&1 | 
FileCheck %s
 
 // CHECK: "-mlong-double-128"
 
 // RUN: %clang -target aarch64 -c -### %s -mlong-double-128 2>&1 | FileCheck 
--check-prefix=ERR %s
-// RUN: %clang -target powerpc -c -### %s -mlong-double-80 2>&1 | FileCheck 
--check-prefix=ERR2 %s
 
 // ERR: error: unsupported option '-mlong-double-128' for target 'aarch64'
-// ERR2: error: unsupported option '-mlong-double-80' for target 
'powerpc-linux-musl'


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


[PATCH] D66122: [CodeGen] Emit dynamic initializers for static TLS vars in outlined scopes

2019-08-16 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:472
+
+  llvm::sort(OrderedVarInits.begin(), OrderedVarInits.end(),
+  [](const VarDecl *a, const VarDecl *b) {

You can use the range-based version of llvm::sort here:

`llvm::sort(OrderedVarInits);`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66122



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


[PATCH] D65037: push LR before mcount on ARM

2019-08-16 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 215703.
jcai19 added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix frontend unit tests for __gnu_mcount_nc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65037

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Frontend/gnu-mcount.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.h
  llvm/lib/Target/ARM/ARMInstrInfo.td
  llvm/lib/Target/ARM/ARMInstrThumb.td
  llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
  llvm/test/CodeGen/ARM/gnu_mcount_nc.ll
  llvm/test/Transforms/EntryExitInstrumenter/mcount.ll

Index: llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
===
--- llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
+++ llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
@@ -54,7 +54,7 @@
 
 define void @f2() #2 { entry: ret void }
 ; CHECK-LABEL: define void @f2
-; CHECK: call void @"\01__gnu_mcount_nc"
+; CHECK: call void @llvm.arm.gnu.eabi.mcount
 
 define void @f3() #3 { entry: ret void }
 ; CHECK-LABEL: define void @f3
@@ -105,7 +105,7 @@
 
 attributes #0 = { "instrument-function-entry-inlined"="mcount" "instrument-function-entry"="__cyg_profile_func_enter" "instrument-function-exit"="__cyg_profile_func_exit" }
 attributes #1 = { "instrument-function-entry-inlined"=".mcount" }
-attributes #2 = { "instrument-function-entry-inlined"="\01__gnu_mcount_nc" }
+attributes #2 = { "instrument-function-entry-inlined"="llvm.arm.gnu.eabi.mcount" }
 attributes #3 = { "instrument-function-entry-inlined"="\01_mcount" }
 attributes #4 = { "instrument-function-entry-inlined"="\01mcount" }
 attributes #5 = { "instrument-function-entry-inlined"="__mcount" }
Index: llvm/test/CodeGen/ARM/gnu_mcount_nc.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/gnu_mcount_nc.ll
@@ -0,0 +1,41 @@
+; RUN: llc -mtriple=armv7a-linux-gnueabihf -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=CHECK-ARM
+; RUN: llc -mtriple=armv7a-linux-gnueabihf -verify-machineinstrs -fast-isel %s -o - | FileCheck %s --check-prefix=CHECK-ARM-FAST-ISEL
+; RUN: llc -mtriple=armv7a-linux-gnueabihf -verify-machineinstrs -global-isel -global-isel-abort=2 %s -o - | FileCheck %s --check-prefix=CHECK-ARM-GLOBAL-ISEL
+; RUN: llc -mtriple=thumbv7a-linux-gnueabihf -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=CHECK-THUMB
+; RUN: llc -mtriple=thumbv7a-linux-gnueabihf -verify-machineinstrs -fast-isel %s -o - | FileCheck %s --check-prefix=CHECK-THUMB-FAST-ISEL
+; RUN: llc -mtriple=thumbv7a-linux-gnueabihf -verify-machineinstrs -global-isel -global-isel-abort=2 %s -o - | FileCheck %s --check-prefix=CHECK-THUMB-GLOBAL-ISEL
+
+define dso_local void @callee() #0 {
+; CHECK-ARM:stmdb   sp!, {lr}
+; CHECK-ARM-NEXT:   bl  __gnu_mcount_nc
+; CHECK-ARM-FAST-ISEL:  stmdb   sp!, {lr}
+; CHECK-ARM-FAST-ISEL-NEXT: bl  __gnu_mcount_nc
+; CHECK-ARM-GLOBAL-ISEL:stmdb   sp!, {lr}
+; CHECK-ARM-GLOBAL-ISEL-NEXT:   bl  __gnu_mcount_nc
+; CHECK-THUMB:  push{lr}
+; CHECK-THUMB-NEXT: bl  __gnu_mcount_nc
+; CHECK-THUMB-FAST-ISEL:push{lr}
+; CHECK-THUMB-FAST-ISEL-NEXT:   bl  __gnu_mcount_nc
+; CHECK-THUMB-GLOBAL-ISEL:  push{lr}
+; CHECK-THUMB-GLOBAL-ISEL-NEXT: bl  __gnu_mcount_nc
+  ret void
+}
+
+define dso_local void @caller() #0 {
+; CHECK-ARM:stmdb   sp!, {lr}
+; CHECK-ARM-NEXT:   bl  __gnu_mcount_nc
+; CHECK-ARM-FAST-ISEL:  stmdb   sp!, {lr}
+; CHECK-ARM-FAST-ISEL-NEXT: bl  __gnu_mcount_nc
+; CHECK-ARM-GLOBAL-ISEL:stmdb   sp!, {lr}
+; CHECK-ARM-GLOBAL-ISEL-NEXT:   bl  __gnu_mcount_nc
+; CHECK-THUMB:  push{lr}
+; CHECK-THUMB-NEXT: bl  __gnu_mcount_nc
+; CHECK-THUMB-FAST-ISEL:push{lr}
+; CHECK-THUMB-FAST-ISEL-NEXT:   bl  __gnu_mcount_nc
+; CHECK-THUMB-GLOBAL-ISEL:  push{lr}
+; CHECK-THUMB-GLOBAL-ISEL-NEXT: bl  __gnu_mcount_nc
+  call void @callee()
+  ret void
+}
+
+attributes #0 = { nofree nounwind "instrument-function-entry-inlined"="llvm.arm.gnu.eabi.mcount" }
Index: llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
===
--- llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
+++ llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
@@ -24,7 +24,7 @@
 
   if (Func == "mcount" ||
   Func == ".mcount" ||
-  Func == "\01__gnu_mcount_nc" ||
+  Func == "llvm.arm.gnu.eabi.mcount" ||
   Func == "\01_mcount" ||
   Func == "\01mcount" ||
   Func == "__mcount" ||
Index: llvm/lib/Target/ARM/ARMInstrThumb.td

[PATCH] D66092: [CodeGen] Generate constrained fp intrinsics depending on FPOptions

2019-08-16 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added a comment.

It took some digging, but I finally found the e-mail thread where we initially 
agreed that we can't mix constrained FP intrinsics and non-constrained FP 
operations within a function. Here it is: 
http://lists.llvm.org/pipermail/cfe-dev/2017-August/055325.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66092



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


[PATCH] D63889: Check possible warnings on global initializers for reachability

2019-08-16 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry marked 4 inline comments as done.
Nathan-Huckleberry added inline comments.



Comment at: clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp:360
 
-constexpr int ok_byte = (__builtin_bit_cast(std::byte[8], pad{1, 2}), 0);
-constexpr int ok_uchar = (__builtin_bit_cast(unsigned char[8], pad{1, 2}), 0);
+constexpr int ok_byte = (__builtin_bit_cast(std::byte[8], pad{1, 2}), 0);  
// expected-warning {{expression result unused}}
+constexpr int ok_uchar = (__builtin_bit_cast(unsigned char[8], pad{1, 2}), 0); 
// expected-warning {{expression result unused}}

These new warnings seem valid.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63889



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


[PATCH] D63889: Check possible warnings on global initializers for reachability

2019-08-16 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 215699.
Nathan-Huckleberry added a comment.

- Use ExprEvalContext and remove mangling context code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63889

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/AnalysisBasedWarnings.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Analysis/AnalysisDeclContext.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/warn-unreachable-warning-var-decl.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
  clang/test/SemaTemplate/instantiate-static-var.cpp

Index: clang/test/SemaTemplate/instantiate-static-var.cpp
===
--- clang/test/SemaTemplate/instantiate-static-var.cpp
+++ clang/test/SemaTemplate/instantiate-static-var.cpp
@@ -6,6 +6,7 @@
 class X {
 public:
   static const T value = 10 / Divisor; // expected-error{{in-class initializer for static data member is not a constant expression}}
+  //expected-warning@-1 {{division by zero is undefined}}
 };
 
 int array1[X::value == 5? 1 : -1];
Index: clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
===
--- clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
+++ clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
@@ -357,8 +357,8 @@
   int b;
 };
 
-constexpr int ok_byte = (__builtin_bit_cast(std::byte[8], pad{1, 2}), 0);
-constexpr int ok_uchar = (__builtin_bit_cast(unsigned char[8], pad{1, 2}), 0);
+constexpr int ok_byte = (__builtin_bit_cast(std::byte[8], pad{1, 2}), 0);  // expected-warning {{expression result unused}}
+constexpr int ok_uchar = (__builtin_bit_cast(unsigned char[8], pad{1, 2}), 0); // expected-warning {{expression result unused}}
 
 #ifdef __CHAR_UNSIGNED__
 // expected-note@+5 {{indeterminate value can only initialize an object of type 'unsigned char', 'char', or 'std::byte'; 'my_byte' is invalid
@@ -366,12 +366,12 @@
 // expected-note@+3 {{indeterminate value can only initialize an object of type 'unsigned char' or 'std::byte'; 'my_byte' is invalid}}
 #endif
 // expected-error@+1 {{constexpr variable 'bad_my_byte' must be initialized by a constant expression}}
-constexpr int bad_my_byte = (__builtin_bit_cast(my_byte[8], pad{1, 2}), 0);
+constexpr int bad_my_byte = (__builtin_bit_cast(my_byte[8], pad{1, 2}), 0); // expected-warning {{expression result unused}}
 #ifndef __CHAR_UNSIGNED__
 // expected-error@+3 {{constexpr variable 'bad_char' must be initialized by a constant expression}}
 // expected-note@+2 {{indeterminate value can only initialize an object of type 'unsigned char' or 'std::byte'; 'char' is invalid}}
 #endif
-constexpr int bad_char =  (__builtin_bit_cast(char[8], pad{1, 2}), 0);
+constexpr int bad_char = (__builtin_bit_cast(char[8], pad{1, 2}), 0); // expected-warning {{expression result unused}}
 
 struct pad_buffer { unsigned char data[sizeof(pad)]; };
 constexpr bool test_pad_buffer() {
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -383,7 +383,7 @@
   constexpr B b3 { { 1 }, { 2 } }; // expected-error {{constant expression}} expected-note {{reference to temporary}} expected-note {{here}}
 }
 
-constexpr B & = ((1, 2), 3, 4, B { {10}, {{20}} });
+constexpr B & = ((1, 2), 3, 4, B{{10}, {{20}}}); //expected-warning {{expression result unused}}
 static_assert( != , "");
 
 // Proposed DR: copy-elision doesn't trigger lifetime extension.
Index: clang/test/Sema/warn-unreachable-warning-var-decl.cpp
===
--- /dev/null
+++ clang/test/Sema/warn-unreachable-warning-var-decl.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -verify %s
+int e = 1 ? 0 : 1 / 0;
+int g = 1 ? 1 / 0 : 0; // expected-warning{{division by zero is undefined}}
+
+#define SHIFT(n) (((n) == 32) ? 0 : ((1 << (n)) - 1))
+
+int x = SHIFT(32);
+int y = SHIFT(0);
+
+// FIXME: Expressions in lambdas aren't ignored
+int z = []() {
+  return 1 ? 0 : 1 / 0; // expected-warning{{division by zero is undefined}}
+}();
+
+int f(void) {
+  int x = 1 ? 0 : 1 / 0;
+  return x;
+}
+
+template 
+struct X0 {
+  static T value;
+};
+
+template 
+struct X1 {
+  static T value;
+};
+
+template 
+T X0::value = 3.14; // expected-warning{{implicit conversion from 'double' to 'int' changes value from 3.14 to 3}}
+
+template 
+T X1::value = 1 ? 0 : 1 / 0;
+
+template struct X0; // expected-note{{in instantiation of static data member 'X0::value' requested here}}
+
+constexpr 

[PATCH] D66122: [CodeGen] Emit dynamic initializers for static TLS vars in outlined scopes

2019-08-16 Thread Princeton Ferro via Phabricator via cfe-commits
Prince781 updated this revision to Diff 215695.
Prince781 added a comment.
Herald added a subscriber: mgrang.

I've updated the patch to initialize, in the proper order, all foreign static 
TLS variables and the variables they depend on for initialization. I've also 
cleaned up the patch a bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66122

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCXX/cxx11-thread-local.cpp

Index: clang/test/CodeGenCXX/cxx11-thread-local.cpp
===
--- clang/test/CodeGenCXX/cxx11-thread-local.cpp
+++ clang/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -268,6 +268,33 @@
   return this->n;
 }
 
+namespace static_tls_in_lambda {
+  struct X {
+X() {}
+  };
+
+
+  X (*f())() {
+static thread_local X x;
+
+return [] { return x; };
+  }
+
+  auto y = f();
+
+  void g() { y(); }
+
+  void bar(X**, X**, X**);
+  void baz(void());
+  void f2() {
+  thread_local X x;
+  thread_local X* p = 
+  thread_local X* q = p;
+  thread_local X* r = q;
+  baz([]{bar(, , );});
+  }
+}
+
 namespace {
 thread_local int anon_i{1};
 }
@@ -303,6 +330,42 @@
 // CHECK: store i64 1, i64* @_ZGVN1XIiE1mE
 // CHECK: br label
 
+// CHECK: define internal void @"_ZZN20static_tls_in_lambda1fEvENK3$_1clEv"
+// CHECK: %[[static_tls_guard_val:.*]] = load i8, i8* @_ZGVZN20static_tls_in_lambda1fEvE1x
+// CHECK: %[[static_tls_guard_init:.*]] = icmp eq i8 %[[static_tls_guard_val]], 0
+// CHECK: br i1 %[[static_tls_guard_init]],
+// CHECK: call void @_ZN20static_tls_in_lambda1XC1Ev(%"struct.static_tls_in_lambda::X"* @_ZZN20static_tls_in_lambda1fEvE1x)
+// CHECK: store i8 1, i8* @_ZGVZN20static_tls_in_lambda1fEvE1x, align 1
+
+// CHECK: define internal void @"_ZZN20static_tls_in_lambda2f2EvENK3$_2clEv"
+// init x
+// CHECK: %[[static_tls_guard_val:.*]] = load i8, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1x
+// CHECK: %[[static_tls_guard_init:.*]] = icmp eq i8 %[[static_tls_guard_val]], 0
+// CHECK: br i1 %[[static_tls_guard_init]],
+// CHECK: call void @_ZN20static_tls_in_lambda1XC1Ev(%"struct.static_tls_in_lambda::X"* @_ZZN20static_tls_in_lambda2f2EvE1x)
+// CHECK: store i8 1, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1x, align 1
+// init p
+// CHECK: %[[static_tls_guard_val:.*]] = load i8, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1p
+// CHECK: %[[static_tls_guard_init:.*]] = icmp eq i8 %[[static_tls_guard_val]], 0
+// CHECK: br i1 %[[static_tls_guard_init]],
+// CHECK: store %"struct.static_tls_in_lambda::X"* @_ZZN20static_tls_in_lambda2f2EvE1x, %"struct.static_tls_in_lambda::X"** @_ZZN20static_tls_in_lambda2f2EvE1p
+// CHECK: store i8 1, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1p, align 1
+// init q
+// CHECK: %[[static_tls_guard_val:.*]] = load i8, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1q
+// CHECK: %[[static_tls_guard_init:.*]] = icmp eq i8 %[[static_tls_guard_val]], 0
+// CHECK: br i1 %[[static_tls_guard_init]],
+// CHECK: %[[static_tls_var_prev:.*]] = load %"struct.static_tls_in_lambda::X"*, %"struct.static_tls_in_lambda::X"** @_ZZN20static_tls_in_lambda2f2EvE1p, align 8
+// CHECK: store %"struct.static_tls_in_lambda::X"* %[[static_tls_var_prev]], %"struct.static_tls_in_lambda::X"** @_ZZN20static_tls_in_lambda2f2EvE1q, align 8
+// CHECK: store i8 1, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1q, align 1
+// init r
+// CHECK: %[[static_tls_guard_val:.*]] = load i8, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1r
+// CHECK: %[[static_tls_guard_init:.*]] = icmp eq i8 %[[static_tls_guard_val]], 0
+// CHECK: br i1 %[[static_tls_guard_init]],
+// CHECK: %[[static_tls_var_prev:.*]] = load %"struct.static_tls_in_lambda::X"*, %"struct.static_tls_in_lambda::X"** @_ZZN20static_tls_in_lambda2f2EvE1q, align 8
+// CHECK: store %"struct.static_tls_in_lambda::X"* %[[static_tls_var_prev]], %"struct.static_tls_in_lambda::X"** @_ZZN20static_tls_in_lambda2f2EvE1r, align 8
+// CHECK: store i8 1, i8* @_ZGVZN20static_tls_in_lambda2f2EvE1r, align 1
+
+
 // CHECK: define {{.*}}@[[GLOBAL_INIT:.*]]()
 // CHECK: call void @[[C_INIT]]()
 // CHECK: call void @[[E_INIT]]()
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -467,6 +467,10 @@
   /// should emit cleanups.
   bool CurFuncIsThunk = false;
 
+  /// static thread-local variables we've referenced that were declared in a
+  /// parent function.
+  llvm::SmallSet ForeignStaticTLSVars;
+
   /// In ARC, whether we should autorelease the return value.
   bool AutoreleaseResult = false;
 
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -31,6 +31,7 @@
 

[PATCH] D63423: [Diagnostics] Diagnose misused xor as pow

2019-08-16 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 215693.
xbolva00 added a comment.

Better comparison for "xor".


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

https://reviews.llvm.org/D63423

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/warn-xor-as-pow.cpp

Index: test/SemaCXX/warn-xor-as-pow.cpp
===
--- test/SemaCXX/warn-xor-as-pow.cpp
+++ test/SemaCXX/warn-xor-as-pow.cpp
@@ -0,0 +1,105 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wxor-used-as-pow %s
+// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wxor-used-as-pow %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+#define FOOBAR(x, y) (x * y)
+#define XOR(x, y) (x ^ y)
+#define TWO 2
+#define TEN 10
+#define TWO_ULL 2ULL
+#define EPSILON 10 ^ -300
+
+#define flexor 7
+
+#ifdef __cplusplus
+constexpr long long operator"" _xor(unsigned long long v) { return v; }
+
+constexpr long long operator"" _0b(unsigned long long v) { return v; }
+constexpr long long operator"" _0X(unsigned long long v) { return v; }
+#else
+#define xor^ // iso646.h
+#endif
+
+void test(unsigned a, unsigned b) {
+  unsigned res;
+  res = a ^ 5;
+  res = 2 ^ b;
+  res = a ^ b;
+  res = 2 ^ -1;
+  res = 2 ^ 0; // expected-warning {{result of '2 ^ 0' is 2; did you mean '1 << 0' (1)?}}
+   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1"
+   // expected-note@-2 {{replace expression with '0x2 ^ 0' to silence this warning}}
+  res = 2 ^ 1; // expected-warning {{result of '2 ^ 1' is 3; did you mean '1 << 1' (2)?}}
+   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 1"
+   // expected-note@-2 {{replace expression with '0x2 ^ 1' to silence this warning}}
+  res = 2 ^ 2; // expected-warning {{result of '2 ^ 2' is 0; did you mean '1 << 2' (4)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 2"
+  // expected-note@-2 {{replace expression with '0x2 ^ 2' to silence this warning}}
+  res = 2 ^ 8; // expected-warning {{result of '2 ^ 8' is 10; did you mean '1 << 8' (256)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 8"
+  // expected-note@-2 {{replace expression with '0x2 ^ 8' to silence this warning}}
+  res = TWO ^ 8; // expected-warning {{result of 'TWO ^ 8' is 10; did you mean '1 << 8' (256)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1 << 8"
+  // expected-note@-2 {{replace expression with '0x2 ^ 8' to silence this warning}}
+  res = 2 ^ 16; // expected-warning {{result of '2 ^ 16' is 18; did you mean '1 << 16' (65536)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1 << 16"
+  // expected-note@-2 {{replace expression with '0x2 ^ 16' to silence this warning}}
+  res = 2 ^ TEN; // expected-warning {{result of '2 ^ TEN' is 8; did you mean '1 << TEN' (1024)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1 << TEN"
+  // expected-note@-2 {{replace expression with '0x2 ^ TEN' to silence this warning}}
+  res = 0x2 ^ 16;
+  res = 2 xor 16;
+
+  res = 2 ^ 0x4;
+  res = 2 ^ 04;
+  res = 0x2 ^ 10;
+  res = 0X2 ^ 10;
+  res = 02 ^ 10;
+  res = FOOBAR(2, 16);
+  res = 0b10 ^ 16;
+  res = 0B10 ^ 16;
+  res = 2 ^ 0b100;
+  res = XOR(2, 16);
+  unsigned char two = 2;
+  res = two ^ 16;
+  res = TWO_ULL ^ 16;
+  res = 2 ^ 32; // expected-warning {{result of '2 ^ 32' is 34; did you mean '1LL << 32'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1LL << 32"
+  // expected-note@-2 {{replace expression with '0x2 ^ 32' to silence this warning}}
+  res = 2 ^ 64;
+
+  res = EPSILON;
+  res = 10 ^ 0; // expected-warning {{result of '10 ^ 0' is 10; did you mean '1e0'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1e0"
+  // expected-note@-2 {{replace expression with '0xA ^ 0' to silence this warning}}
+  res = 10 ^ 1; // expected-warning {{result of '10 ^ 1' is 11; did you mean '1e1'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1e1"
+  // expected-note@-2 {{replace expression with '0xA ^ 1' to silence this warning}}
+  res = 10 ^ 2; // expected-warning {{result of '10 ^ 2' is 8; did you mean '1e2'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1e2"
+  // expected-note@-2 {{replace expression with '0xA ^ 2' to silence this warning}}
+  res = 10 ^ 4; // expected-warning {{result of '10 ^ 4' is 14; did you mean '1e4'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1e4"
+  // expected-note@-2 {{replace expression with '0xA ^ 4' to silence this warning}}
+  res = 10 ^ 10; // expected-warning {{result of '10 ^ 10' is 0; did you mean '1e10'?}}
+  // CHECK: 

[PATCH] D66364: Diagnose use of _Thread_local as an extension when appropriate

2019-08-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

`_Thread_local` is a reserved identifier; we generally don't produce extension 
warnings for uses of reserved identifiers. (Eg, there's no warning for 
`_Atomic` in C++ or `_Bool` in C89, and no warning for uses of `__type_traits` 
or `__builtins`.)

But I note that we *do* warn for some of these already (eg, `_Generic`, 
`_Static_assert`, `_Alignas`, and `_Alignof` get a warning). We should choose a 
rule and apply it consistently.

What's the motivation for warning on this? Maybe that can inform whether these 
warnings are useful in general.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66364



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


[PATCH] D66092: [CodeGen] Generate constrained fp intrinsics depending on FPOptions

2019-08-16 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added a comment.

In D66092#1632642 , @sepavloff wrote:

> - What is the issue with moving `a = b/c`? If it moves ahead of `if` 
> statement it seems OK, because the rounding mode is the same in that point. 
> It cannot be moved inside the block (where rounding mode is different) 
> because it breaks semantics.


It may be that the optimizer can prove that 'someCondition' is always true and 
it will eliminate the if statement and there is nothing to prevent the 
operation from migrating between the calls that change the rounding mode.

This is my main point -- "call i32 @fesetround" does not act as a barrier to an 
fdiv instruction (for example), but it does act as a barrier to a constrained 
FP intrinsic. It is not acceptable, for performance reasons in the general 
case, to have calls act as barriers to unconstrained FP operations. Therefore, 
to keep everything semantically correct, it is necessary to use constrained 
intrinsics in any function where the floating point environment may be changed.

I agree that impact on performance must be minimized, but this is necessary for 
correctness.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66092



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


[PATCH] D65997: Add options rounding and exceptions to pragma fp

2019-08-16 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:3152
+rounding mode. This option is experimental; the compiler may ignore an explicit
+rounding mode in some situations.
+

sepavloff wrote:
> andrew.w.kaylor wrote:
> > You should say something about whether the rounding mode is applied or 
> > assumed. The rounding mode argument in the constrained FP intrinsics is 
> > assumed. The compiler is not required to do anything to force the hardware 
> > into that rounding mode. I think we want that behavior here as well. I 
> > believe this follows the semantics of the STDC FENV_ROUND pragmas that were 
> > introduced by ISO TS-18661.
> Hm. I understood the proposal as if pragma FENV_ROUND is applied. If I am 
> wrong, and that pragma is only a hint to compiler, it is not suitable for our 
> purposes. We need a mean to generate constrained intrinsics from C/C++ code. 
> it would facilitate adaptation of LLVM passes for specific floating point 
> options, including rounding, exception behavior, FENV_ACCESS an so on. It 
> also would allow users to tune code generation. In this case `pragma 
> FENV_ROUND` is a different functionality, which should be developed 
> separately.
Sorry, I didn't mean to introduce confusion by bringing up FENV_ROUND, and 
after reading the description you linked on the other review I'm not sure it 
does what I was previously told it would anyway. Let's ignore that and just 
talk about what you're intending to do here.

If you only generate constrained intrinsics and do not generate an explicit 
rounding mode control change instruction (such as a call to fesetround) then 
the declared rounding mode may not actually be used. According to the 
definition in the LLVM Language Reference, when you set a rounding mode in a 
constrained FP intrinsic, the optimizer will assume that rounding mode is in 
effect and it may use it to perform transformations like constant folding. 
However, there is no requirement for the compiler to generate code (in response 
to the constrained intrinsic) to set the rounding mode. Architectures that 
encode the rounding mode in the instructions may use the rounding mode 
information (though the LLVM back end isn't currently well structured to enable 
that), but in cases where the rounding mode is controlled by processor state, 
the constrained intrinsic will not change it.

Hopefully that clarifies what I was asking about here. Do you intend for use of 
these pragmas to actually change the rounding mode or merely describe it? If 
the pragmas are intended to change the rounding mode, you will need to generate 
instructions to do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65997



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


r369161 - [doc] Fix some minor formatting issues.

2019-08-16 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Aug 16 15:08:39 2019
New Revision: 369161

URL: http://llvm.org/viewvc/llvm-project?rev=369161=rev
Log:
[doc] Fix some minor formatting issues.

Modified:
cfe/trunk/docs/LanguageExtensions.rst

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=369161=369160=369161=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Fri Aug 16 15:08:39 2019
@@ -496,9 +496,11 @@ Clang supports two half-precision (16-bi
 ``__fp16`` is supported on every target, as it is purely a storage format; see 
below.
 ``_Float16`` is currently only supported on the following targets, with further
 targets pending ABI standardization:
-- 32-bit ARM
-- 64-bit ARM (AArch64)
-- SPIR
+
+* 32-bit ARM
+* 64-bit ARM (AArch64)
+* SPIR
+
 ``_Float16`` will be supported on more targets as they define ABIs for it.
 
 ``__fp16`` is a storage and interchange format only.  This means that values of
@@ -531,10 +533,8 @@ Because ``__fp16`` operands are always i
 common real type of ``__fp16`` and ``_Float16`` for the purposes of the usual
 arithmetic conversions is ``float``.
 
-A literal can be given ``_Float16`` type using the suffix ``f16``; for example:
-```
-3.14f16
-```
+A literal can be given ``_Float16`` type using the suffix ``f16``. For example,
+``3.14f16``.
 
 Because default argument promotion only applies to the standard floating-point
 types, ``_Float16`` values are not promoted to ``double`` when passed as 
variadic


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


[PATCH] D66332: [clang-format] Fix the bug that joins template closer and > or >>

2019-08-16 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac67414618df: [clang-format] Fix the bug that joins template 
closer and  or  (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66332

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6618,7 +6618,10 @@
   EXPECT_EQ("auto x = [] { A>> a; };",
 format("auto x=[]{A >> a;};", getGoogleStyle()));
 
-  verifyFormat("A> a;", getChromiumStyle(FormatStyle::LK_Cpp));
+  verifyFormat("A> a;", getChromiumStyle(FormatStyle::LK_Cpp));
+
+  verifyFormat("int i = a<1> >> 1;");
+  verifyFormat("bool b = a<1> > 1;");
 
   verifyFormat("test >> a >> b;");
   verifyFormat("test << a >> b;");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -919,6 +919,8 @@
 case tok::greater:
   if (Style.Language != FormatStyle::LK_TextProto)
 Tok->Type = TT_BinaryOperator;
+  if (Tok->Previous && Tok->Previous->is(TT_TemplateCloser))
+Tok->SpacesRequiredBefore = 1;
   break;
 case tok::kw_operator:
   if (Style.Language == FormatStyle::LK_TextProto ||


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6618,7 +6618,10 @@
   EXPECT_EQ("auto x = [] { A>> a; };",
 format("auto x=[]{A >> a;};", getGoogleStyle()));
 
-  verifyFormat("A> a;", getChromiumStyle(FormatStyle::LK_Cpp));
+  verifyFormat("A> a;", getChromiumStyle(FormatStyle::LK_Cpp));
+
+  verifyFormat("int i = a<1> >> 1;");
+  verifyFormat("bool b = a<1> > 1;");
 
   verifyFormat("test >> a >> b;");
   verifyFormat("test << a >> b;");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -919,6 +919,8 @@
 case tok::greater:
   if (Style.Language != FormatStyle::LK_TextProto)
 Tok->Type = TT_BinaryOperator;
+  if (Tok->Previous && Tok->Previous->is(TT_TemplateCloser))
+Tok->SpacesRequiredBefore = 1;
   break;
 case tok::kw_operator:
   if (Style.Language == FormatStyle::LK_TextProto ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r369157 - [clang-format] Fix the bug that joins template closer and > or >>

2019-08-16 Thread Owen Pan via cfe-commits
Author: owenpan
Date: Fri Aug 16 14:49:17 2019
New Revision: 369157

URL: http://llvm.org/viewvc/llvm-project?rev=369157=rev
Log:
[clang-format] Fix the bug that joins template closer and > or >>

Also fixes a buggy test case.

See PR42404

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

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=369157=369156=369157=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Aug 16 14:49:17 2019
@@ -919,6 +919,8 @@ private:
 case tok::greater:
   if (Style.Language != FormatStyle::LK_TextProto)
 Tok->Type = TT_BinaryOperator;
+  if (Tok->Previous && Tok->Previous->is(TT_TemplateCloser))
+Tok->SpacesRequiredBefore = 1;
   break;
 case tok::kw_operator:
   if (Style.Language == FormatStyle::LK_TextProto ||

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=369157=369156=369157=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Aug 16 14:49:17 2019
@@ -6618,7 +6618,10 @@ TEST_F(FormatTest, UnderstandsTemplatePa
   EXPECT_EQ("auto x = [] { A>> a; };",
 format("auto x=[]{A >> a;};", getGoogleStyle()));
 
-  verifyFormat("A> a;", getChromiumStyle(FormatStyle::LK_Cpp));
+  verifyFormat("A> a;", getChromiumStyle(FormatStyle::LK_Cpp));
+
+  verifyFormat("int i = a<1> >> 1;");
+  verifyFormat("bool b = a<1> > 1;");
 
   verifyFormat("test >> a >> b;");
   verifyFormat("test << a >> b;");


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


[PATCH] D66332: [clang-format] Fix the bug that joins template closer and > or >>

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

In D66332#1633448 , @Quuxplusone wrote:

> Drive-by observation: My experiments with 
> https://zed0.co.uk/clang-format-configurator/ show that there is a similar 
> bug where clang-format accidentally produces `>=` via reformatting of 
> `template` `=0>`, `pi` `=3;`, and so on. Is it 
> possible to fix that bug as part of this patch, and/or would you be 
> interested in patching that bug as a follow-up to this one?


Do you have `SpaceBeforeAssignmentOperators` off? I am more than happy to fix 
it as a follow-up, but the current behavior of `SpaceBeforeAssignmentOperators` 
is:
`true`:

  int a = 5;
  a += 42;

`false`:

  int a= 5;
  a+= 42;

It's weird that there is a space after the assignment operators regardless.

The documentation 

 should be fixed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66332



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


[PATCH] D66361: Improve behavior in the case of stack exhaustion.

2019-08-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Basic/Stack.cpp:53-54
+  // If the stack pointer has a surprising value, we do not understand this
+  // stack usage scheme. (Perhaps the target allocates new stack regions on
+  // demand for us.) Don't try to guess what's going on.
+  if (StackUsage > DesiredStackSize)

rnk wrote:
> So, for example, ASan with UAR, where frames are heap allocated. I suppose in 
> that case we will go down the __builtin_frame_address path, though.
Can we detect that? It seems better to turn this all off if we think there's 
anything funny going on with the stack layout.



Comment at: test/SemaTemplate/stack-exhaustion.cpp:10
+template struct tuple {};
+template auto f(tuple t) -> decltype(f(tuple(t))) 
{} // expected-error {{exceeded maximum depth}}
+void g() { f(tuple()); }

rnk wrote:
> This test seems like it could be fragile. If threads are disabled, it will 
> probably crash.
I've handled the "threads are disabled" case. Is there anything else that can 
meaningfully be detected here? (ASan maybe? Are there any other cases that lead 
to a non-linear stack layout that we can detect?)


Repository:
  rC Clang

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

https://reviews.llvm.org/D66361



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


[PATCH] D66361: Improve behavior in the case of stack exhaustion.

2019-08-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 215680.
rsmith added a comment.

- Disable stack exhaustion test if threads are disabled.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66361

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Stack.h
  include/clang/Sema/Sema.h
  lib/Basic/CMakeLists.txt
  lib/Basic/Stack.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  test/CMakeLists.txt
  test/SemaTemplate/stack-exhaustion.cpp
  test/lit.cfg.py
  test/lit.site.cfg.py.in
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -13,6 +13,7 @@
 
 #include "clang/Driver/Driver.h"
 #include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/Stack.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
@@ -319,6 +320,7 @@
 }
 
 int main(int argc_, const char **argv_) {
+  noteBottomOfStack();
   llvm::InitLLVM X(argc_, argv_);
   SmallVector argv(argv_, argv_ + argc_);
 
Index: test/lit.site.cfg.py.in
===
--- test/lit.site.cfg.py.in
+++ test/lit.site.cfg.py.in
@@ -25,6 +25,7 @@
 config.enable_shared = @ENABLE_SHARED@
 config.enable_backtrace = @ENABLE_BACKTRACES@
 config.enable_experimental_new_pass_manager = @ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER@
+config.enable_threads = @LLVM_ENABLE_THREADS@
 config.host_arch = "@HOST_ARCH@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@")
Index: test/lit.cfg.py
===
--- test/lit.cfg.py
+++ test/lit.cfg.py
@@ -175,6 +175,9 @@
 if config.enable_backtrace:
 config.available_features.add('backtrace')
 
+if config.enable_threads:
+config.available_features.add('thread_support')
+
 # Check if we should allow outputs to console.
 run_console_tests = int(lit_config.params.get('enable_console', '0'))
 if run_console_tests != 0:
Index: test/SemaTemplate/stack-exhaustion.cpp
===
--- /dev/null
+++ test/SemaTemplate/stack-exhaustion.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify %s
+// REQUIRES: thread_support
+
+// expected-warning@* 0-1{{stack nearly exhausted}}
+// expected-note@* 0+{{}}
+
+template struct X : X {};
+template<> struct X<0> {};
+X<1000> x;
+
+template struct tuple {};
+template auto f(tuple t) -> decltype(f(tuple(t))) {} // expected-error {{exceeded maximum depth}}
+void g() { f(tuple()); }
+
+int f(X<0>);
+template auto f(X) -> f(X());
+
+int k = f(X<1000>());
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -26,7 +26,8 @@
   ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
   HAVE_LIBZ
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
-  LLVM_ENABLE_PLUGINS)
+  LLVM_ENABLE_PLUGINS
+  LLVM_ENABLE_THREADS)
 
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7715,7 +7715,9 @@
 auto *Def = Var->getDefinition();
 if (!Def) {
   SourceLocation PointOfInstantiation = E->getExprLoc();
-  InstantiateVariableDefinition(PointOfInstantiation, Var);
+  runWithSufficientStackSpace(PointOfInstantiation, [&] {
+InstantiateVariableDefinition(PointOfInstantiation, Var);
+  });
   Def = Var->getDefinition();
 
   // If we don't already have a point of instantiation, and we managed
@@ -8053,9 +8055,11 @@
 } else if (auto *ClassTemplateSpec =
 dyn_cast(RD)) {
   if (ClassTemplateSpec->getSpecializationKind() == TSK_Undeclared) {
-Diagnosed = InstantiateClassTemplateSpecialization(
-Loc, ClassTemplateSpec, TSK_ImplicitInstantiation,
-/*Complain=*/Diagnoser);
+runWithSufficientStackSpace(Loc, [&] {
+  Diagnosed = InstantiateClassTemplateSpecialization(
+  Loc, ClassTemplateSpec, TSK_ImplicitInstantiation,
+  /*Complain=*/Diagnoser);
+});
 Instantiated = true;
   }
 } else {
@@ -8066,10 +8070,12 @@
 // This record was instantiated from a class within a template.
 if (MSI->getTemplateSpecializationKind() !=
 TSK_ExplicitSpecialization) {
-  Diagnosed = InstantiateClass(Loc, RD, Pattern,
-

[PATCH] D66361: Improve behavior in the case of stack exhaustion.

2019-08-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 215678.
rsmith marked 2 inline comments as done.
rsmith added a comment.

- Review feedback: use _AddressOfReturnAddress with MSVC, and simplify


Repository:
  rC Clang

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

https://reviews.llvm.org/D66361

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Stack.h
  include/clang/Sema/Sema.h
  lib/Basic/CMakeLists.txt
  lib/Basic/Stack.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  test/SemaTemplate/stack-exhaustion.cpp
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -13,6 +13,7 @@
 
 #include "clang/Driver/Driver.h"
 #include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/Stack.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
@@ -319,6 +320,7 @@
 }
 
 int main(int argc_, const char **argv_) {
+  noteBottomOfStack();
   llvm::InitLLVM X(argc_, argv_);
   SmallVector argv(argv_, argv_ + argc_);
 
Index: test/SemaTemplate/stack-exhaustion.cpp
===
--- /dev/null
+++ test/SemaTemplate/stack-exhaustion.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -verify %s
+// expected-warning@* 0-1{{stack nearly exhausted}}
+// expected-note@* 0+{{}}
+
+template struct X : X {};
+template<> struct X<0> {};
+X<1000> x;
+
+template struct tuple {};
+template auto f(tuple t) -> decltype(f(tuple(t))) {} // expected-error {{exceeded maximum depth}}
+void g() { f(tuple()); }
+
+int f(X<0>);
+template auto f(X) -> f(X());
+
+int k = f(X<1000>());
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7715,7 +7715,9 @@
 auto *Def = Var->getDefinition();
 if (!Def) {
   SourceLocation PointOfInstantiation = E->getExprLoc();
-  InstantiateVariableDefinition(PointOfInstantiation, Var);
+  runWithSufficientStackSpace(PointOfInstantiation, [&] {
+InstantiateVariableDefinition(PointOfInstantiation, Var);
+  });
   Def = Var->getDefinition();
 
   // If we don't already have a point of instantiation, and we managed
@@ -8053,9 +8055,11 @@
 } else if (auto *ClassTemplateSpec =
 dyn_cast(RD)) {
   if (ClassTemplateSpec->getSpecializationKind() == TSK_Undeclared) {
-Diagnosed = InstantiateClassTemplateSpecialization(
-Loc, ClassTemplateSpec, TSK_ImplicitInstantiation,
-/*Complain=*/Diagnoser);
+runWithSufficientStackSpace(Loc, [&] {
+  Diagnosed = InstantiateClassTemplateSpecialization(
+  Loc, ClassTemplateSpec, TSK_ImplicitInstantiation,
+  /*Complain=*/Diagnoser);
+});
 Instantiated = true;
   }
 } else {
@@ -8066,10 +8070,12 @@
 // This record was instantiated from a class within a template.
 if (MSI->getTemplateSpecializationKind() !=
 TSK_ExplicitSpecialization) {
-  Diagnosed = InstantiateClass(Loc, RD, Pattern,
-   getTemplateInstantiationArgs(RD),
-   TSK_ImplicitInstantiation,
-   /*Complain=*/Diagnoser);
+  runWithSufficientStackSpace(Loc, [&] {
+Diagnosed = InstantiateClass(Loc, RD, Pattern,
+ getTemplateInstantiationArgs(RD),
+ TSK_ImplicitInstantiation,
+ /*Complain=*/Diagnoser);
+  });
   Instantiated = true;
 }
   }
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3415,7 +3415,11 @@
   if (D->isInvalidDecl())
 return nullptr;
 
-  return Instantiator.Visit(D);
+  Decl *SubstD;
+  runWithSufficientStackSpace(D->getLocation(), [&] {
+SubstD = Instantiator.Visit(D);
+  });
+  return SubstD;
 }
 
 /// Instantiates a nested template parameter list in the current
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -19,6 +19,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/AST/PrettyDeclStackTrace.h"
 #include "clang/Basic/LangOptions.h"
+#include "clang/Basic/Stack.h"
 #include 

[PATCH] D65545: Handle some fs::remove failures

2019-08-16 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.

LGTM with one minor change.




Comment at: clang/lib/Frontend/PrecompiledPreamble.cpp:38
 
+#define DEBUG_TYPE "pch"
+

`pch-preamble` is more accurate here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65545



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


[PATCH] D65907: Introduce FileEntryRef and use it when handling includes to report correct dependencies when the FileManager is reused across invocations

2019-08-16 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added inline comments.



Comment at: clang/include/clang/Basic/FileManager.h:110
+/// A reference to a \c FileEntry that includes the name of the file as it was
+/// accessed by the FileManager's client.
+class FileEntryRef {

How does that work with the VFS? Will it keep the virtual path as the FileName 
to return with getName() or the external-content? Should it change when in face 
of `use-external-names` attribute?



Comment at: clang/include/clang/Basic/FileManager.h:249-251
+  /// This function is deprecated and will be removed at some point in the
+  /// future, new clients should use
+  ///  \c getFileRef.

Bigcheese wrote:
> `LLVM_DEPRECATED()`?  (or w/e the name is of our depreciation attribute 
> macro).
Probably can't be done until we move all uses over? There's probably still 
enough of them that the warning would be very annoying?



Comment at: clang/lib/Basic/FileManager.cpp:194
+static llvm::ErrorOr
+promoteFileRef(StringRef name, llvm::ErrorOr value) {
+  if (value)

I know the surrounding functions are not consistent with capitalization, but 
maybe `name` and `value` here should?


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

https://reviews.llvm.org/D65907



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


[PATCH] D64931: Change X86 datalayout for three address spaces that specify pointer sizes.

2019-08-16 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D64931#1633669 , @akhuang wrote:

> > Address space have backend defined semantics, and aren’t really reserved 
> > for front end use. I think the fact that non-0 address spaces on X86 
> > codegen the same as address space 0 and could be used for something by a 
> > front end is an accident of how SelectionDAG is implemented. If X86 wants 
> > to reserve address space ranges for frontend use, that would need to be 
> > decided and documented. You don’t necessarily get the current behavior for 
> > free in GlobalISel since pointer types are distinct, so this would 
> > specifically need to be implemented.
>
> By this do you mean that this would be an instance of address spaces being 
> used by the frontend? Or just that adding meaning to address spaces shouldn't 
> be breaking other frontends?


I mean if frontends are relying on current specific behavior for these address 
spaces, that’s not something that’s documented to work. It just happens to


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64931



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


[PATCH] D66361: Improve behavior in the case of stack exhaustion.

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



Comment at: include/clang/Basic/Stack.h:42
+  llvm::function_ref Fn) {
+if (LLVM_UNLIKELY(isStackNearlyExhausted())) {
+  runWithSufficientStackSpaceSlow(Diag, Fn);

For LLVM_THREADS_DISABLED builds used by Chromium today, maybe we should skip 
this completely?



Comment at: lib/Basic/Stack.cpp:23
+  return __builtin_frame_address(0);
+#else
+  char CharOnStack = 0;

I think `_AddressOfReturnAddress()` ifdef _MSC_VER would be the proper way to 
ask MSVC for a reasonable stack pointer, if we're worried about returning the 
address of a local.



Comment at: lib/Basic/Stack.cpp:53-54
+  // If the stack pointer has a surprising value, we do not understand this
+  // stack usage scheme. (Perhaps the target allocates new stack regions on
+  // demand for us.) Don't try to guess what's going on.
+  if (StackUsage > DesiredStackSize)

So, for example, ASan with UAR, where frames are heap allocated. I suppose in 
that case we will go down the __builtin_frame_address path, though.



Comment at: test/SemaTemplate/stack-exhaustion.cpp:10
+template struct tuple {};
+template auto f(tuple t) -> decltype(f(tuple(t))) 
{} // expected-error {{exceeded maximum depth}}
+void g() { f(tuple()); }

This test seems like it could be fragile. If threads are disabled, it will 
probably crash.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66361



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


r369152 - [X86] Support -mlong-double-80

2019-08-16 Thread Troy A. Johnson via cfe-commits
Author: troyj
Date: Fri Aug 16 14:00:22 2019
New Revision: 369152

URL: http://llvm.org/viewvc/llvm-project?rev=369152=rev
Log:
[X86] Support -mlong-double-80

Add an option group for all of the -mlong-double-* options and make
-mlong-double-80 restore the default long double behavior for X86.  The
motivations are that GNU accepts the -mlong-double-80 option and that complex
Makefiles often need a way of undoing earlier options. Prior to this commit, if
one chooses 64-bit or 128-bit long double for X86, there is no way to undo that
choice and restore the 80-bit behavior.

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/mlong-double-128.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=369152=369151=369152=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Aug 16 14:00:22 2019
@@ -2040,9 +2040,14 @@ def malign_jumps_EQ : Joined<["-"], "mal
 def mfancy_math_387 : Flag<["-"], "mfancy-math-387">, 
Group;
 def mlong_calls : Flag<["-"], "mlong-calls">, Group,
   HelpText<"Generate branches with extended addressability, usually via 
indirect jumps.">;
-def mlong_double_64 : Flag<["-"], "mlong-double-64">, Group, 
Flags<[CC1Option]>,
+def LongDouble_Group : OptionGroup<"">, Group,
+  DocName<"Long double flags">,
+  DocBrief<[{Selects the long double implementation}]>;
+def mlong_double_64 : Flag<["-"], "mlong-double-64">, Group, 
Flags<[CC1Option]>,
   HelpText<"Force long double to be 64 bits">;
-def mlong_double_128 : Flag<["-"], "mlong-double-128">, Group, 
Flags<[CC1Option]>,
+def mlong_double_80 : Flag<["-"], "mlong-double-80">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Force long double to be 80 bits, padded to 128 bits for storage">;
+def mlong_double_128 : Flag<["-"], "mlong-double-128">, 
Group, Flags<[CC1Option]>,
   HelpText<"Force long double to be 128 bits">;
 def mno_long_calls : Flag<["-"], "mno-long-calls">, Group,
   HelpText<"Restore the default behaviour of not generating long calls">;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=369152=369151=369152=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Aug 16 14:00:22 2019
@@ -4057,11 +4057,13 @@ void Clang::ConstructJob(Compilation ,
 
   RenderFloatingPointOptions(TC, D, OFastEnabled, Args, CmdArgs);
 
-  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64,
-   options::OPT_mlong_double_128)) {
+  if (Arg *A = Args.getLastArg(options::OPT_LongDouble_Group)) {
 if (TC.getArch() == llvm::Triple::x86 ||
-TC.getArch() == llvm::Triple::x86_64 ||
-TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64())
+TC.getArch() == llvm::Triple::x86_64)
+  A->render(Args, CmdArgs);
+else if ((TC.getArch() == llvm::Triple::ppc ||
+  TC.getArch() == TC.getTriple().isPPC64()) &&
+ (A->getOption().getID() != options::OPT_mlong_double_80))
   A->render(Args, CmdArgs);
 else
   D.Diag(diag::err_drv_unsupported_opt_for_target)

Modified: cfe/trunk/test/Driver/mlong-double-128.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mlong-double-128.c?rev=369152=369151=369152=diff
==
--- cfe/trunk/test/Driver/mlong-double-128.c (original)
+++ cfe/trunk/test/Driver/mlong-double-128.c Fri Aug 16 14:00:22 2019
@@ -2,10 +2,14 @@
 // RUN: %clang -target powerpc64-pc-freebsd12 -c -### %s -mlong-double-128 
2>&1 | FileCheck %s
 // RUN: %clang -target powerpc64le-linux-musl -c -### %s -mlong-double-128 
2>&1 | FileCheck %s
 // RUN: %clang -target i686-linux-gnu -c -### %s -mlong-double-128 2>&1 | 
FileCheck %s
-// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-128 2>&1 | 
FileCheck %s
+
+// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-128 
-mlong-double-80 2>&1 | FileCheck --implicit-check-not=-mlong-double- /dev/null
+// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-80 
-mlong-double-128 2>&1 | FileCheck %s
 
 // CHECK: "-mlong-double-128"
 
 // RUN: %clang -target aarch64 -c -### %s -mlong-double-128 2>&1 | FileCheck 
--check-prefix=ERR %s
+// RUN: %clang -target powerpc -c -### %s -mlong-double-80 2>&1 | FileCheck 
--check-prefix=ERR2 %s
 
 // ERR: error: unsupported option '-mlong-double-128' for target 'aarch64'
+// ERR2: error: unsupported option '-mlong-double-80' for target 
'powerpc-linux-musl'



[PATCH] D62731: [RFC] Add support for options -fp-model= and -fp-speculation= : specify floating point behavior

2019-08-16 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 215666.
mibintc marked an inline comment as not done.
mibintc edited the summary of this revision.
mibintc added a comment.

I addressed some comments from @kpn: I corrected the documentation formatting 
and added some details, and used Diag instead of llvm_unreachable.

I decided to change -fp-model=except- to -fp-model=noexcept

When the user requests -fp-model=strict I explicitly set the FMA Contraction 
mode to off.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/fpconstrained.c
  clang/test/Driver/clang_f_opts.c

Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -217,6 +217,11 @@
 // RUN: %clang -### -S -fexec-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
 // CHECK-INVALID-INPUT-CHARSET: error: invalid value 'iso-8859-1' in '-fexec-charset=iso-8859-1'
 
+// RUN: %clang -### -S -fp-model=fast -fp-model=except -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-FAST-EXCEPT %s
+// RUN: %clang -### -S -fp-model=fast -fp-model=except -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-FAST-EXCEPT %s
+// CHECK-INVALID-FAST-EXCEPT: error: invalid argument 'fp-model=fast' not allowed with 'fp-model=except'
+//
+
 // Test that we don't error on these.
 // RUN: %clang -### -S -Werror\
 // RUN: -falign-functions -falign-functions=2 -fno-align-functions\
Index: clang/test/CodeGen/fpconstrained.c
===
--- /dev/null
+++ clang/test/CodeGen/fpconstrained.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fp-model=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=STRICT
+// RUN: %clang_cc1 -fp-model=strict -fp-model-except -emit-llvm -o - %s | FileCheck %s -check-prefix=STRICTEXCEPT
+// RUN: %clang_cc1 -fp-model=strict -no-fp-model-except -emit-llvm -o - %s | FileCheck %s -check-prefix=STRICTNOEXCEPT
+// RUN: %clang_cc1 -fp-model-except -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT
+// RUN: %clang_cc1 -no-fp-model-except -emit-llvm -o - %s | FileCheck %s -check-prefix=NOEXCEPT
+// RUN: %clang_cc1 -fp-model=precise -emit-llvm -o - %s | FileCheck %s -check-prefix=PRECISE
+// RUN: %clang_cc1 -fp-model=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
+// RUN: %clang_cc1 -fp-model=fast -fp-speculation=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=NOEXCEPT
+// RUN: %clang_cc1 -fp-model=fast -fp-speculation=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT
+// RUN: %clang_cc1 -fp-model=fast -fp-speculation=safe -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP
+float f0, f1, f2;
+
+void foo(void) {
+  // CHECK-LABEL: define {{.*}}void @foo()
+
+  // MAYTRAP: llvm.experimental.constrained.fadd.f32(float %0, float %1, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
+  // EXCEPT: llvm.experimental.constrained.fadd.f32(float %0, float %1, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NOEXCEPT: llvm.experimental.constrained.fadd.f32(float %0, float %1, metadata !"round.tonearest", metadata !"fpexcept.ignore")
+  // STRICT: llvm.experimental.constrained.fadd.f32(float %0, float %1, metadata !"round.dynamic", metadata !"fpexcept.strict")
+  // STRICTEXCEPT: llvm.experimental.constrained.fadd.f32(float %0, float %1, metadata !"round.dynamic", metadata !"fpexcept.strict")
+  // STRICTNOEXCEPT: llvm.experimental.constrained.fadd.f32(float %0, float %1, metadata !"round.dynamic", metadata !"fpexcept.ignore")
+  // PRECISE: fadd float
+  // FAST: fadd fast
+  f0 = f1 + f2;
+
+  // CHECK: ret
+}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3039,6 +3039,59 @@
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
   }
 
+  LangOptions::FPModelKind FPM = LangOptions::FPM_Off;
+  if (Arg *A = Args.getLastArg(OPT_fp_model_EQ)) {
+StringRef Val = A->getValue();
+if (Val == "precise")
+  FPM = LangOptions::FPM_Precise;
+else if (Val == "strict")
+  FPM = LangOptions::FPM_Strict;
+else if (Val == "fast")
+  FPM = LangOptions::FPM_Fast;
+else
+  llvm_unreachable("invalid -fp-model setting");
+  }
+  Opts.getFPMOptions().setFPModelSetting(FPM);
+
+  LangOptions::FPModelExceptKind FPME 

[PATCH] D64931: Change X86 datalayout for three address spaces that specify pointer sizes.

2019-08-16 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

> Address space have backend defined semantics, and aren’t really reserved for 
> front end use. I think the fact that non-0 address spaces on X86 codegen the 
> same as address space 0 and could be used for something by a front end is an 
> accident of how SelectionDAG is implemented. If X86 wants to reserve address 
> space ranges for frontend use, that would need to be decided and documented. 
> You don’t necessarily get the current behavior for free in GlobalISel since 
> pointer types are distinct, so this would specifically need to be implemented.

By this do you mean that this would be an instance of address spaces being used 
by the frontend? Or just that adding meaning to address spaces shouldn't be 
breaking other frontends?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64931



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


[PATCH] D65453: [analyzer] Improve the accuracy of the Clang call graph analysis

2019-08-16 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I hope you dont mind me changing the revision title -- many of us are 
subscribed to the "analyzer" tag and like learning about whats changing :)

This is not an objection to the patch or anything of course, just adding some 
lurkers.


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

https://reviews.llvm.org/D65453



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


[PATCH] D66179: [LifetimeAnalysis] Support more STL idioms (template forward declaration and DependentNameType)

2019-08-16 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre marked 4 inline comments as done.
mgehre added a comment.

I now start to wonder if we should instead put the attribute on all 
declarations (instead of just the canonical). Later redeclarations 
automatically inherit the attributes.
This would make both the checking easier (just check any declaration, no need 
to obtain the canonical first), and remove the special
case for adding to the definition of templated record for ClassTemplateDecls.




Comment at: clang/lib/Sema/SemaAttr.cpp:200
 CXXRecordDecl *Canonical = Record->getCanonicalDecl();
 if (Canonical->hasAttr() || Canonical->hasAttr())
   return;

gribozavr wrote:
> mgehre wrote:
> > gribozavr wrote:
> > > Should this code not do this short-circuit check? It is prone to going 
> > > out of sync with the code in `addGslOwnerPointerAttributeIfNotExisting`, 
> > > like it did just now.
> > > 
> > > If you want to check for attribute before doing the string search, you 
> > > could pass the string set into 
> > > `addGslOwnerPointerAttributeIfNotExisting`, and let that decide if it 
> > > should infer the attribute or not.
> > Yes, the `hasAttr` check here is an optimization to avoid the string 
> > search. I don't think I can move the string search into 
> > `addGslOwnerPointerAttributeIfNotExisting`, because that function is called 
> > from other call sites that don't care about a set of names.
> Sorry I wasn't clear enough -- the issue that I noticed is that this check 
> looks at the canonical decl, while `addGslOwnerPointerAttributeIfNotExisting` 
> attaches the attribute to the decl itself -- that's what I meant by "out of 
> sync".
I make sure that `addGslOwnerPointerAttributeIfNotExisting` is only called with 
the canonical decl as argument, which the caller usually has around. The only 
exception to this is when addGslOwnerPointerAttributeIfNotExisting calls itself 
to attach an attribute to the definition of templated class.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66179



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


r369149 - Revert "[ARM] push LR before __gnu_mcount_nc"

2019-08-16 Thread Jian Cai via cfe-commits
Author: jcai19
Date: Fri Aug 16 13:40:21 2019
New Revision: 369149

URL: http://llvm.org/viewvc/llvm-project?rev=369149=rev
Log:
Revert "[ARM] push LR before __gnu_mcount_nc"

This reverts commit f4cf3b959333f62b7a7b2d7771f7010c9d8da388.

Modified:
cfe/trunk/lib/Basic/Targets/ARM.cpp

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=369149=369148=369149=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Fri Aug 16 13:40:21 2019
@@ -322,7 +322,7 @@ ARMTargetInfo::ARMTargetInfo(const llvm:
   if (Triple.getOS() == llvm::Triple::Linux ||
   Triple.getOS() == llvm::Triple::UnknownOS)
 this->MCountName = Opts.EABIVersion == llvm::EABI::GNU
-   ? "llvm.arm.gnu.eabi.mcount"
+   ? "\01__gnu_mcount_nc"
: "\01mcount";
 
   SoftFloatABI = llvm::is_contained(Opts.FeaturesAsWritten, "+soft-float-abi");


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


[PATCH] D66365: [clang-tidy] [readability-convert-member-functions-to-static] ignore functions that hide base class methods

2019-08-16 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre created this revision.
mgehre added reviewers: aaron.ballman, Eugene.Zelenko.
Herald added a subscriber: xazax.hun.
Herald added a project: clang.

Fixes bug https://bugs.llvm.org/show_bug.cgi?id=43002


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66365

Files:
  clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
  
clang-tools-extra/test/clang-tidy/readability-convert-member-functions-to-static.cpp


Index: 
clang-tools-extra/test/clang-tidy/readability-convert-member-functions-to-static.cpp
===
--- 
clang-tools-extra/test/clang-tidy/readability-convert-member-functions-to-static.cpp
+++ 
clang-tools-extra/test/clang-tidy/readability-convert-member-functions-to-static.cpp
@@ -216,3 +216,21 @@
 return;
   }
 };
+
+class HiddingBase {
+  int f();
+
+  static int g();
+};
+
+class HiddingDerived : public HiddingBase {
+  int f() {
+return 0;
+  }
+
+  int g() {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: method 'g' can be made static
+// CHECK-FIXES: {{^}}  static int g() {
+return 0;
+  }
+};
Index: 
clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
+++ clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
@@ -71,6 +71,31 @@
   return UsageOfThis.Used;
 }
 
+/// Does any base class have a non-static method with the same name?
+AST_MATCHER(CXXMethodDecl, isHiding) {
+  const IdentifierInfo *ThisIdentifier = Node.getIdentifier();
+  if (!ThisIdentifier)
+return false;
+
+  const CXXRecordDecl *Record = Node.getParent();
+
+  auto StaticOrDifferentName = [ThisIdentifier](const CXXMethodDecl *Method) {
+  if (Method->isStatic())
+return true;
+
+  const IdentifierInfo *Ident = 
Method->getIdentifier();
+  if (!Ident)
+return true;
+
+  return Ident->getName() != ThisIdentifier->getName();
+};
+
+  return !Record->forallBases([StaticOrDifferentName](const CXXRecordDecl 
*Base) {
+return llvm::all_of(Base->methods(),
+StaticOrDifferentName);
+  });
+}
+
 void ConvertMemberFunctionsToStatic::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
   cxxMethodDecl(
@@ -86,7 +111,8 @@
   // depending on template base class.
   ),
   isInsideMacroDefinition(),
-  hasCanonicalDecl(isInsideMacroDefinition()), usesThis(
+  hasCanonicalDecl(isInsideMacroDefinition()), isHiding(),
+  usesThis(
   .bind("x"),
   this);
 }


Index: clang-tools-extra/test/clang-tidy/readability-convert-member-functions-to-static.cpp
===
--- clang-tools-extra/test/clang-tidy/readability-convert-member-functions-to-static.cpp
+++ clang-tools-extra/test/clang-tidy/readability-convert-member-functions-to-static.cpp
@@ -216,3 +216,21 @@
 return;
   }
 };
+
+class HiddingBase {
+  int f();
+
+  static int g();
+};
+
+class HiddingDerived : public HiddingBase {
+  int f() {
+return 0;
+  }
+
+  int g() {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: method 'g' can be made static
+// CHECK-FIXES: {{^}}  static int g() {
+return 0;
+  }
+};
Index: clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
+++ clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
@@ -71,6 +71,31 @@
   return UsageOfThis.Used;
 }
 
+/// Does any base class have a non-static method with the same name?
+AST_MATCHER(CXXMethodDecl, isHiding) {
+  const IdentifierInfo *ThisIdentifier = Node.getIdentifier();
+  if (!ThisIdentifier)
+return false;
+
+  const CXXRecordDecl *Record = Node.getParent();
+
+  auto StaticOrDifferentName = [ThisIdentifier](const CXXMethodDecl *Method) {
+  if (Method->isStatic())
+return true;
+
+  const IdentifierInfo *Ident = Method->getIdentifier();
+  if (!Ident)
+return true;
+
+  return Ident->getName() != ThisIdentifier->getName();
+};
+
+  return !Record->forallBases([StaticOrDifferentName](const CXXRecordDecl *Base) {
+return llvm::all_of(Base->methods(),
+StaticOrDifferentName);
+  });
+}
+
 void ConvertMemberFunctionsToStatic::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
   

[PATCH] D62731: [RFC] Add support for options -fp-model= and -fp-speculation= : specify floating point behavior

2019-08-16 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked 3 inline comments as not done.
mibintc added a comment.

I added an inline reply and unmarked some things that had been inadvertently 
marked done.




Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:126
+  case LangOptions::FPM_Precise:
+  case LangOptions::FPM_Fast:
+break;

mibintc wrote:
> kpn wrote:
> > Wait, so "fast" and "precise" are the same thing? That doesn't sound like 
> > where the documentation you put in the ticket says "the compiler preserves 
> > the source expression ordering and rounding properties of floating-point".
> > 
> > (Yes, I saw below where "fast" turns on the fast math flags but "precise" 
> > doesn't. That doesn't affect my point here.)
> "precise" doesn't necessitate the use of Constrained Intrinsics, And likewise 
> for "fast".   The words "compiler preserves the source expression ordering" 
> were copied from the msdn documentation for /fp:precise as you explained it 
> would be useful to have the msdn documentation for the option in case it goes 
> offline in, say, 30 years.  The ICL Intel compiler also provides equivalent 
> floating point options. The Intel documentation for precise is phrased 
> differently "Disables optimizations that are not value-safe on floating-point 
> data."  
> 
> fp-model=precise should enable contractions, if that's not true at default (I 
> mean, clang -c) then this patch is missing that.
> 
> fp-model=fast is the same as requesting ffast-math 
Well, we haven't heard from Andy yet, but he told me some time ago that 
/fp:precise corresponds more or less (there was wiggle room) to clang's default 
behavior.  It sounds like you think the description in the msdn of /fp:precise 
isn't describing clang's default behavior, @kpn can you say more about that, 
and do you think that ConstrainedIntrinsics should be created to provide the 
semantics of /fp:precise? 


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731



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


r369148 - [Test Commit] Fix typo in diagtool.rst

2019-08-16 Thread Troy A. Johnson via cfe-commits
Author: troyj
Date: Fri Aug 16 13:26:48 2019
New Revision: 369148

URL: http://llvm.org/viewvc/llvm-project?rev=369148=rev
Log:
[Test Commit] Fix typo in diagtool.rst

Test commit after obtaining commit access.

Modified:
cfe/trunk/docs/CommandGuide/diagtool.rst

Modified: cfe/trunk/docs/CommandGuide/diagtool.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/diagtool.rst?rev=369148=369147=369148=diff
==
--- cfe/trunk/docs/CommandGuide/diagtool.rst (original)
+++ cfe/trunk/docs/CommandGuide/diagtool.rst Fri Aug 16 13:26:48 2019
@@ -9,7 +9,7 @@ SYNOPSIS
 DESCRIPTION
 ---
 
-:program:`diagtool` is a combination of four tool for dealing with diagnostics 
in :program:`clang`.
+:program:`diagtool` is a combination of four tools for dealing with 
diagnostics in :program:`clang`.
 
 SUBCOMMANDS
 ---


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


[PATCH] D65019: [ARM] push LR before __gnu_mcount_nc

2019-08-16 Thread Jian Cai via Phabricator via cfe-commits
jcai19 added a comment.

The changes have been upstreamed to r369147.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D65019



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


[PATCH] D66333: [analyzer] NonNullParamChecker and CStringChecker parameter number in checker message

2019-08-16 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Thanks! I'm happy to accept this as soon as other reviewers are happy.




Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1548
 
-  state = checkNonNull(C, state, Dst, DstVal);
+  state = checkNonNull(C, state, Dst, DstVal, 1);
   if (!state)

You could also pass a description of the parameter (eg., "source" or 
"destination").


Repository:
  rC Clang

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

https://reviews.llvm.org/D66333



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


[PATCH] D65019: [ARM] push LR before __gnu_mcount_nc

2019-08-16 Thread Jian Cai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369147: [ARM] push LR before __gnu_mcount_nc (authored by 
jcai19, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D65019?vs=214945=215664#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D65019

Files:
  cfe/trunk/lib/Basic/Targets/ARM.cpp
  llvm/trunk/include/llvm/IR/IntrinsicsARM.td
  llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp
  llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
  llvm/trunk/lib/Target/ARM/ARMISelLowering.h
  llvm/trunk/lib/Target/ARM/ARMInstrInfo.td
  llvm/trunk/lib/Target/ARM/ARMInstrThumb.td
  llvm/trunk/lib/Transforms/Utils/EntryExitInstrumenter.cpp
  llvm/trunk/test/CodeGen/ARM/gnu_mcount_nc.ll

Index: llvm/trunk/include/llvm/IR/IntrinsicsARM.td
===
--- llvm/trunk/include/llvm/IR/IntrinsicsARM.td
+++ llvm/trunk/include/llvm/IR/IntrinsicsARM.td
@@ -778,4 +778,9 @@
 def int_arm_neon_sdot : Neon_Dot_Intrinsic;
 
 
+// GNU eabi mcount
+def int_arm_gnu_eabi_mcount : Intrinsic<[],
+[],
+[IntrReadMem, IntrWriteMem]>;
+
 } // end TargetPrefix
Index: llvm/trunk/test/CodeGen/ARM/gnu_mcount_nc.ll
===
--- llvm/trunk/test/CodeGen/ARM/gnu_mcount_nc.ll
+++ llvm/trunk/test/CodeGen/ARM/gnu_mcount_nc.ll
@@ -0,0 +1,41 @@
+; RUN: llc -mtriple=armv7a-linux-gnueabihf -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=CHECK-ARM
+; RUN: llc -mtriple=armv7a-linux-gnueabihf -verify-machineinstrs -fast-isel %s -o - | FileCheck %s --check-prefix=CHECK-ARM-FAST-ISEL
+; RUN: llc -mtriple=armv7a-linux-gnueabihf -verify-machineinstrs -global-isel -global-isel-abort=2 %s -o - | FileCheck %s --check-prefix=CHECK-ARM-GLOBAL-ISEL
+; RUN: llc -mtriple=thumbv7a-linux-gnueabihf -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=CHECK-THUMB
+; RUN: llc -mtriple=thumbv7a-linux-gnueabihf -verify-machineinstrs -fast-isel %s -o - | FileCheck %s --check-prefix=CHECK-THUMB-FAST-ISEL
+; RUN: llc -mtriple=thumbv7a-linux-gnueabihf -verify-machineinstrs -global-isel -global-isel-abort=2 %s -o - | FileCheck %s --check-prefix=CHECK-THUMB-GLOBAL-ISEL
+
+define dso_local void @callee() #0 {
+; CHECK-ARM:stmdb   sp!, {lr}
+; CHECK-ARM-NEXT:   bl  __gnu_mcount_nc
+; CHECK-ARM-FAST-ISEL:  stmdb   sp!, {lr}
+; CHECK-ARM-FAST-ISEL-NEXT: bl  __gnu_mcount_nc
+; CHECK-ARM-GLOBAL-ISEL:stmdb   sp!, {lr}
+; CHECK-ARM-GLOBAL-ISEL-NEXT:   bl  __gnu_mcount_nc
+; CHECK-THUMB:  push{lr}
+; CHECK-THUMB-NEXT: bl  __gnu_mcount_nc
+; CHECK-THUMB-FAST-ISEL:push{lr}
+; CHECK-THUMB-FAST-ISEL-NEXT:   bl  __gnu_mcount_nc
+; CHECK-THUMB-GLOBAL-ISEL:  push{lr}
+; CHECK-THUMB-GLOBAL-ISEL-NEXT: bl  __gnu_mcount_nc
+  ret void
+}
+
+define dso_local void @caller() #0 {
+; CHECK-ARM:stmdb   sp!, {lr}
+; CHECK-ARM-NEXT:   bl  __gnu_mcount_nc
+; CHECK-ARM-FAST-ISEL:  stmdb   sp!, {lr}
+; CHECK-ARM-FAST-ISEL-NEXT: bl  __gnu_mcount_nc
+; CHECK-ARM-GLOBAL-ISEL:stmdb   sp!, {lr}
+; CHECK-ARM-GLOBAL-ISEL-NEXT:   bl  __gnu_mcount_nc
+; CHECK-THUMB:  push{lr}
+; CHECK-THUMB-NEXT: bl  __gnu_mcount_nc
+; CHECK-THUMB-FAST-ISEL:push{lr}
+; CHECK-THUMB-FAST-ISEL-NEXT:   bl  __gnu_mcount_nc
+; CHECK-THUMB-GLOBAL-ISEL:  push{lr}
+; CHECK-THUMB-GLOBAL-ISEL-NEXT: bl  __gnu_mcount_nc
+  call void @callee()
+  ret void
+}
+
+attributes #0 = { nofree nounwind "instrument-function-entry-inlined"="llvm.arm.gnu.eabi.mcount" }
Index: llvm/trunk/lib/Transforms/Utils/EntryExitInstrumenter.cpp
===
--- llvm/trunk/lib/Transforms/Utils/EntryExitInstrumenter.cpp
+++ llvm/trunk/lib/Transforms/Utils/EntryExitInstrumenter.cpp
@@ -24,7 +24,7 @@
 
   if (Func == "mcount" ||
   Func == ".mcount" ||
-  Func == "\01__gnu_mcount_nc" ||
+  Func == "llvm.arm.gnu.eabi.mcount" ||
   Func == "\01_mcount" ||
   Func == "\01mcount" ||
   Func == "__mcount" ||
Index: llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp
===
--- llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp
+++ llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp
@@ -1916,6 +1916,37 @@
 
 case ARM::CMP_SWAP_64:
   return ExpandCMP_SWAP_64(MBB, MBBI, NextMBBI);
+
+case ARM::tBL_PUSHLR:
+case ARM::BL_PUSHLR: {
+  const bool Thumb = Opcode == ARM::tBL_PUSHLR;
+  Register Reg = MI.getOperand(0).getReg();
+  assert(Reg == ARM::LR && "expect LR register!");
+  MachineInstrBuilder MIB;
+  if (Thumb) {
+// push 

[PATCH] D66364: Diagnose use of _Thread_local as an extension when appropriate

2019-08-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added a reviewer: rsmith.
Herald added a project: clang.

We currently accept use of _Thread_local in all C and C++ modes, but we do not 
issue a warning about it being an extension when used outside of C11 mode. This 
patch adds the warning and adjusts tests for the fallout.


Repository:
  rC Clang

https://reviews.llvm.org/D66364

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/test/PCH/thread-local.cpp
  clang/test/Sema/thread-specifier.c
  clang/test/SemaOpenCLCXX/restricted.cl

Index: clang/test/SemaOpenCLCXX/restricted.cl
===
--- clang/test/SemaOpenCLCXX/restricted.cl
+++ clang/test/SemaOpenCLCXX/restricted.cl
@@ -31,6 +31,8 @@
 // Test storage class qualifiers.
 __constant _Thread_local int a = 1;
 // expected-error@-1 {{C++ for OpenCL version 1.0 does not support the '_Thread_local' storage class specifier}}
+// expected-warning@-2 {{_Thread_local is a C11-specific feature}}
+
 __constant __thread int b = 2;
 // expected-error@-1 {{C++ for OpenCL version 1.0 does not support the '__thread' storage class specifier}}
 kernel void test_storage_classes() {
Index: clang/test/Sema/thread-specifier.c
===
--- clang/test/Sema/thread-specifier.c
+++ clang/test/Sema/thread-specifier.c
@@ -1,9 +1,10 @@
 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s -DGNU
 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DGNU -std=c++98
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s -DC11 -D__thread=_Thread_local
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DC11 -D__thread=_Thread_local -std=c++98
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s -std=c11 -DC11 -D__thread=_Thread_local
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DC11 -D__thread=_Thread_local -std=c++98 -DWARN_ON_THREAD_LOCAL
 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DCXX11 -D__thread=thread_local -std=c++11 -Wno-deprecated
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DC11 -D__thread=_Thread_local -std=c++11 -Wno-deprecated
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DC11 -D__thread=_Thread_local -std=c++11 -Wno-deprecated -DWARN_ON_THREAD_LOCAL
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s -std=c99 -D__thread=_Thread_local -DWARN_ON_THREAD_LOCAL -DC99
 
 #ifdef __cplusplus
 // In C++, we define __private_extern__ to extern.
@@ -30,7 +31,7 @@
 __thread int t6();
 #if defined(GNU)
 // expected-error@-2 {{'__thread' is only allowed on variable declarations}}
-#elif defined(C11)
+#elif defined(C11) || defined(C99)
 // expected-error@-4 {{'_Thread_local' is only allowed on variable declarations}}
 #else
 // expected-error@-6 {{'thread_local' is only allowed on variable declarations}}
@@ -40,7 +41,7 @@
   __thread int t8;
 #if defined(GNU)
   // expected-error@-2 {{'__thread' variables must have global storage}}
-#elif defined(C11)
+#elif defined(C11) || defined(C99)
   // expected-error@-4 {{'_Thread_local' variables must have global storage}}
 #endif
   extern __thread int t9;
@@ -121,3 +122,41 @@
 #endif
 
 __thread int aggregate[10] = {0};
+
+#ifdef WARN_ON_THREAD_LOCAL
+// expected-warning@14 {{_Thread_local is a C11-specific feature}}
+// expected-warning@15 {{_Thread_local is a C11-specific feature}}
+// expected-warning@16 {{_Thread_local is a C11-specific feature}}
+// expected-warning@22 {{_Thread_local is a C11-specific feature}}
+// expected-warning@23 {{_Thread_local is a C11-specific feature}}
+// expected-warning@31 {{_Thread_local is a C11-specific feature}}
+// expected-warning@40 {{_Thread_local is a C11-specific feature}}
+// expected-warning@41 {{_Thread_local is a C11-specific feature}}
+// expected-warning@47 {{_Thread_local is a C11-specific feature}}
+// expected-warning@48 {{_Thread_local is a C11-specific feature}}
+// expected-warning@49 {{_Thread_local is a C11-specific feature}}
+#if __cplusplus < 201103L
+// expected-warning@51 {{_Thread_local is a C11-specific feature}}
+// expected-warning@52 {{_Thread_local is a C11-specific feature}}
+#elif !defined(CXX11)
+// expected-warning@54 {{_Thread_local is a C11-specific feature}}
+// expected-warning@55 {{_Thread_local is a C11-specific feature}}
+#endif
+// expected-warning@57 {{_Thread_local is a C11-specific feature}}
+// expected-warning@58 

r369147 - [ARM] push LR before __gnu_mcount_nc

2019-08-16 Thread Jian Cai via cfe-commits
Author: jcai19
Date: Fri Aug 16 13:21:08 2019
New Revision: 369147

URL: http://llvm.org/viewvc/llvm-project?rev=369147=rev
Log:
[ARM] push LR before __gnu_mcount_nc

Push LR register before calling __gnu_mcount_nc as it expects the value of LR 
register to be the top value of
the stack on ARM32.

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

Modified:
cfe/trunk/lib/Basic/Targets/ARM.cpp

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=369147=369146=369147=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Fri Aug 16 13:21:08 2019
@@ -322,7 +322,7 @@ ARMTargetInfo::ARMTargetInfo(const llvm:
   if (Triple.getOS() == llvm::Triple::Linux ||
   Triple.getOS() == llvm::Triple::UnknownOS)
 this->MCountName = Opts.EABIVersion == llvm::EABI::GNU
-   ? "\01__gnu_mcount_nc"
+   ? "llvm.arm.gnu.eabi.mcount"
: "\01mcount";
 
   SoftFloatABI = llvm::is_contained(Opts.FeaturesAsWritten, "+soft-float-abi");


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


r369146 - [OPENMP5.0]Diagnose global variables in lambda not marked as declare

2019-08-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Aug 16 13:15:02 2019
New Revision: 369146

URL: http://llvm.org/viewvc/llvm-project?rev=369146=rev
Log:
[OPENMP5.0]Diagnose global variables in lambda not marked as declare
target.

According to OpenMP 5.0, if a lambda declaration and definition appears between 
a declare target directive and the matching end declare target directive, all 
variables that are captured by the lambda expression must also appear in a to 
clause.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/declare_target_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=369146=369145=369146=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Aug 16 13:15:02 
2019
@@ -9318,6 +9318,8 @@ def err_omp_wrong_dependency_iterator_ty
   "expected an integer or a pointer type of the outer loop counter '%0' for 
non-rectangular nests">;
 def err_omp_unsupported_type : Error <
   "host requires %0 bit size %1 type support, but device '%2' does not support 
it">;
+def omp_lambda_capture_in_declare_target_not_to : Error<
+  "variable captured in declare target region must appear in a to clause">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=369146=369145=369146=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Aug 16 13:15:02 2019
@@ -1796,7 +1796,8 @@ VarDecl *Sema::isOpenMPCapturedDecl(Valu
 if (isInOpenMPDeclareTargetContext()) {
   // Try to mark variable as declare target if it is used in capturing
   // regions.
-  if (!OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
+  if (LangOpts.OpenMP <= 45 &&
+  !OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
 checkDeclIsAllowedInOpenMPTarget(nullptr, VD);
   return nullptr;
 } else if (isInOpenMPTargetExecutionDirective()) {
@@ -15349,7 +15350,28 @@ static void checkDeclInTargetContext(Sou
   if (!D || !isa(D))
 return;
   auto *VD = cast(D);
-  if (OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
+  Optional MapTy =
+  OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
+  if (SemaRef.LangOpts.OpenMP >= 50 &&
+  (SemaRef.getCurLambda(/*IgnoreNonLambdaCapturingScope=*/true) ||
+   SemaRef.getCurBlock() || SemaRef.getCurCapturedRegion()) &&
+  VD->hasGlobalStorage()) {
+llvm::Optional MapTy =
+OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
+if (!MapTy || *MapTy != OMPDeclareTargetDeclAttr::MT_To) {
+  // OpenMP 5.0, 2.12.7 declare target Directive, Restrictions
+  // If a lambda declaration and definition appears between a
+  // declare target directive and the matching end declare target
+  // directive, all variables that are captured by the lambda
+  // expression must also appear in a to clause.
+  SemaRef.Diag(VD->getLocation(),
+   diag::omp_lambda_capture_in_declare_target_not_to);
+  SemaRef.Diag(SL, diag::note_var_explicitly_captured_here)
+  << VD << 0 << SR;
+  return;
+}
+  }
+  if (MapTy.hasValue())
 return;
   SemaRef.Diag(VD->getLocation(), diag::warn_omp_not_in_target_context);
   SemaRef.Diag(SL, diag::note_used_here) << SR;

Modified: cfe/trunk/test/OpenMP/declare_target_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_messages.cpp?rev=369146=369145=369146=diff
==
--- cfe/trunk/test/OpenMP/declare_target_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_messages.cpp Fri Aug 16 13:15:02 2019
@@ -1,10 +1,11 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp 
-fnoopenmp-use-tls -ferror-limit 100 -o - %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp5 
-fopenmp -fopenmp-version=50 -fnoopenmp-use-tls -ferror-limit 100 -o - %s
 
 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd 
-fnoopenmp-use-tls -ferror-limit 100 -o - %s
 
 #pragma omp end declare target // expected-error {{unexpected OpenMP directive 
'#pragma omp end declare target'}}
 
-int a, b;
+int a, b, z; // omp5-error {{variable captured in declare target region must 
appear in a to clause}}
 __thread int t; // expected-note {{defined as threadprivate or thread local}}
 
 #pragma omp declare target . // expected-error {{expected '(' after 'declare 
target'}}
@@ -65,11 

[PATCH] D66360: Expose constructing a virtual method dispatch through the include/clang/CodeGen APIs.

2019-08-16 Thread Parker Schuh via Phabricator via cfe-commits
pschuh created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In swift, we want to be able to call c++ virtual methods by looking up in the 
virtual table. There appears to exist no way currently, via the standard APIs, 
to take a CXXMethodDecl and a llvm::Value representing a this-ptr and construct 
the llvm instructions necessary to extract the method from the virtual table as 
well as adjust the this-ptr.

For reference, this is used in https://github.com/apple/swift/pull/26658.


Repository:
  rC Clang

https://reviews.llvm.org/D66360

Files:
  include/clang/CodeGen/CodeGenABITypes.h
  include/clang/CodeGen/SwiftCallingConv.h
  lib/CodeGen/CodeGenABITypes.cpp
  lib/CodeGen/SwiftCallingConv.cpp

Index: lib/CodeGen/SwiftCallingConv.cpp
===
--- lib/CodeGen/SwiftCallingConv.cpp
+++ lib/CodeGen/SwiftCallingConv.cpp
@@ -11,9 +11,11 @@
 //===--===//
 
 #include "clang/CodeGen/SwiftCallingConv.h"
-#include "clang/Basic/TargetInfo.h"
+#include "CGCXXABI.h"
+#include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "TargetInfo.h"
+#include "clang/Basic/TargetInfo.h"
 
 using namespace clang;
 using namespace CodeGen;
@@ -862,3 +864,25 @@
 bool swiftcall::isSwiftErrorLoweredInRegister(CodeGenModule ) {
   return getSwiftABIInfo(CGM).isSwiftErrorInRegister();
 }
+
+llvm::Value *swiftcall::lowerCXXVirtualMethodDeclReference(
+CodeGenModule , const CXXMethodDecl *MD, llvm::Value *,
+CharUnits alignment, llvm::FunctionType *type,
+llvm::IRBuilderBase *builder) {
+  assert(MD->isVirtual());
+
+  CodeGenFunction CGF(CGM, true);
+  CGF.Builder.SetInsertPoint(builder->GetInsertBlock(),
+ builder->GetInsertPoint());
+  Address thisAddr(thisPtr, alignment);
+  auto callee = CGCallee::forVirtual(nullptr, MD, thisAddr, type);
+  const CGCallee  = callee.prepareConcreteCallee(CGF);
+  Address newThisAddr =
+  CGM.getCXXABI().adjustThisArgumentForVirtualFunctionCall(CGF, MD,
+   thisAddr, true);
+  thisPtr = newThisAddr.getPointer();
+  auto *result = concreteCallee.getFunctionPointer();
+  builder->SetInsertPoint(CGF.Builder.GetInsertBlock(),
+  CGF.Builder.GetInsertPoint());
+  return result;
+}
Index: lib/CodeGen/CodeGenABITypes.cpp
===
--- lib/CodeGen/CodeGenABITypes.cpp
+++ lib/CodeGen/CodeGenABITypes.cpp
@@ -52,6 +52,17 @@
   return CGM.getTypes().arrangeCXXMethodType(RD, FTP, MD);
 }
 
+const CGFunctionInfo &
+CodeGen::arrangeCXXMethodDeclaration(CodeGenModule ,
+ const CXXMethodDecl *MD) {
+  return CGM.getTypes().arrangeCXXMethodDeclaration(MD);
+}
+
+llvm::FunctionType *CodeGen::getFunctionType(CodeGenModule ,
+ const CGFunctionInfo ) {
+  return CGM.getTypes().GetFunctionType(FI);
+}
+
 const CGFunctionInfo &
 CodeGen::arrangeFreeFunctionCall(CodeGenModule ,
  CanQualType returnType,
Index: include/clang/CodeGen/SwiftCallingConv.h
===
--- include/clang/CodeGen/SwiftCallingConv.h
+++ include/clang/CodeGen/SwiftCallingConv.h
@@ -22,14 +22,18 @@
 namespace llvm {
   class IntegerType;
   class Type;
+  class Value;
   class StructType;
   class VectorType;
+  class FunctionType;
+  class IRBuilderBase;
 }
 
 namespace clang {
 class Decl;
 class FieldDecl;
 class ASTRecordLayout;
+class CXXMethodDecl;
 
 namespace CodeGen {
 class ABIArgInfo;
@@ -177,6 +181,14 @@
 /// Is swifterror lowered to a register by the target ABI?
 bool isSwiftErrorLoweredInRegister(CodeGenModule );
 
+/// Lookup a virtual method `MD` from the vtable and adjusts the this ptr.
+llvm::Value *lowerCXXVirtualMethodDeclReference(CodeGenModule ,
+const CXXMethodDecl *MD,
+llvm::Value *,
+CharUnits alignment,
+llvm::FunctionType *type,
+llvm::IRBuilderBase *builder);
+
 } // end namespace swiftcall
 } // end namespace CodeGen
 } // end namespace clang
Index: include/clang/CodeGen/CodeGenABITypes.h
===
--- include/clang/CodeGen/CodeGenABITypes.h
+++ include/clang/CodeGen/CodeGenABITypes.h
@@ -65,6 +65,9 @@
const FunctionProtoType *FTP,
const CXXMethodDecl *MD);
 
+const CGFunctionInfo (CodeGenModule ,
+  const CXXMethodDecl *MD);
+
 const CGFunctionInfo (CodeGenModule ,

[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-08-16 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.



> So it is possible to handle this completely in the backed, but the diagnostic 
> output is not fantastic when using clang based instrumentation. In 
> particular, we would need to emit the diagnostic in LowerExpectIntrisic.cpp 
> by checking if the branch weight metadata already exists, and processing it 
> there before it is overwritten. For some reason emitting the diagnostic at 
> that point will not also emit the helpful source listing if there is a macro, 
> even though a FullSourceLoc is available. This isn't an issue for either the 
> handling in SampleProfile.cpp or in PGOInstrumentation.cpp.

Actually, I made a mistake evaluating the diagnostic output. I redid my test 
for handling everything the Clang based instrumentation in 
LowerExpectIntrinsic.cpp and the output now looks as expected, so I must have 
had a logic error somewhere.

I think this can be handled 100% in the backend.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66324



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


[PATCH] D66361: Improve behavior in the case of stack exhaustion.

2019-08-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
rsmith added reviewers: rnk, aaron.ballman.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

Clang performs various recursive operations (such as template instantiation),
and may use non-trivial amounts of stack space in each recursive step (for
instance, due to recursive AST walks). While we try to keep the stack space
used by such steps to a minimum and we have explicit limits on the number of
such steps we perform, it's impractical to guarantee that we won't blow out the
stack on deeply recursive template instantiations on complex ASTs, even with
only a moderately high instantiation depth limit.

The user experience in these cases is generally terrible: we crash with
no hint of what went wrong. Under this patch, we attempt to do better:

- Detect when the stack is nearly exhausted, and produce a warning with a nice 
template instantiation backtrace, telling the user that we might run slowly or 
crash.
- For cases where we're forced to trigger recursive template instantiation in 
arbitrarily-deeply-nested contexts, check whether we're nearly out of stack 
space and allocate a new stack (by spawning a new thread) after producing the 
warning.


Repository:
  rC Clang

https://reviews.llvm.org/D66361

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Stack.h
  include/clang/Sema/Sema.h
  lib/Basic/CMakeLists.txt
  lib/Basic/Stack.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  test/SemaTemplate/stack-exhaustion.cpp
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -13,6 +13,7 @@
 
 #include "clang/Driver/Driver.h"
 #include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/Stack.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
@@ -319,6 +320,7 @@
 }
 
 int main(int argc_, const char **argv_) {
+  noteBottomOfStack();
   llvm::InitLLVM X(argc_, argv_);
   SmallVector argv(argv_, argv_ + argc_);
 
Index: test/SemaTemplate/stack-exhaustion.cpp
===
--- /dev/null
+++ test/SemaTemplate/stack-exhaustion.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -verify %s
+// expected-warning@* 0-1{{stack nearly exhausted}}
+// expected-note@* 0+{{}}
+
+template struct X : X {};
+template<> struct X<0> {};
+X<1000> x;
+
+template struct tuple {};
+template auto f(tuple t) -> decltype(f(tuple(t))) {} // expected-error {{exceeded maximum depth}}
+void g() { f(tuple()); }
+
+int f(X<0>);
+template auto f(X) -> f(X());
+
+int k = f(X<1000>());
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7715,7 +7715,9 @@
 auto *Def = Var->getDefinition();
 if (!Def) {
   SourceLocation PointOfInstantiation = E->getExprLoc();
-  InstantiateVariableDefinition(PointOfInstantiation, Var);
+  runWithSufficientStackSpace(PointOfInstantiation, [&] {
+InstantiateVariableDefinition(PointOfInstantiation, Var);
+  });
   Def = Var->getDefinition();
 
   // If we don't already have a point of instantiation, and we managed
@@ -8053,9 +8055,11 @@
 } else if (auto *ClassTemplateSpec =
 dyn_cast(RD)) {
   if (ClassTemplateSpec->getSpecializationKind() == TSK_Undeclared) {
-Diagnosed = InstantiateClassTemplateSpecialization(
-Loc, ClassTemplateSpec, TSK_ImplicitInstantiation,
-/*Complain=*/Diagnoser);
+runWithSufficientStackSpace(Loc, [&] {
+  Diagnosed = InstantiateClassTemplateSpecialization(
+  Loc, ClassTemplateSpec, TSK_ImplicitInstantiation,
+  /*Complain=*/Diagnoser);
+});
 Instantiated = true;
   }
 } else {
@@ -8066,10 +8070,12 @@
 // This record was instantiated from a class within a template.
 if (MSI->getTemplateSpecializationKind() !=
 TSK_ExplicitSpecialization) {
-  Diagnosed = InstantiateClass(Loc, RD, Pattern,
-   getTemplateInstantiationArgs(RD),
-   TSK_ImplicitInstantiation,
-   /*Complain=*/Diagnoser);
+  runWithSufficientStackSpace(Loc, [&] {
+Diagnosed = InstantiateClass(Loc, RD, Pattern,
+ getTemplateInstantiationArgs(RD),
+ TSK_ImplicitInstantiation,
+ 

r369145 - Stop abusing SuppressAllDiagnostics when speculatively determining

2019-08-16 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Aug 16 12:53:22 2019
New Revision: 369145

URL: http://llvm.org/viewvc/llvm-project?rev=369145=rev
Log:
Stop abusing SuppressAllDiagnostics when speculatively determining
whether an expression would be valid during error recovery.

Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=369145=369144=369145=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Fri Aug 16 12:53:22 2019
@@ -1772,12 +1772,12 @@ Parser::ParsePostfixExpressionSuffix(Exp
 OpKind == tok::arrow ? tok::period : tok::arrow;
 ExprResult CorrectedLHS(/*Invalid=*/true);
 if (getLangOpts().CPlusPlus && OrigLHS) {
-  const bool DiagsAreSuppressed = Diags.getSuppressAllDiagnostics();
-  Diags.setSuppressAllDiagnostics(true);
+  // FIXME: Creating a TentativeAnalysisScope from outside Sema is a
+  // hack.
+  Sema::TentativeAnalysisScope Trap(Actions);
   CorrectedLHS = Actions.ActOnStartCXXMemberReference(
   getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
   MayBePseudoDestructor);
-  Diags.setSuppressAllDiagnostics(DiagsAreSuppressed);
 }
 
 Expr *Base = LHS.get();

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=369145=369144=369145=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Fri Aug 16 12:53:22 2019
@@ -1929,11 +1929,9 @@ bool Sema::tryExprAsCall(Expr , QualTy
   // member templates with defaults/deduction of template arguments, overloads
   // with default arguments, etc.
   if (IsMemExpr && !E.isTypeDependent()) {
-bool Suppress = getDiagnostics().getSuppressAllDiagnostics();
-getDiagnostics().setSuppressAllDiagnostics(true);
+Sema::TentativeAnalysisScope Trap(*this);
 ExprResult R = BuildCallToMemberFunction(nullptr, , SourceLocation(),
  None, SourceLocation());
-getDiagnostics().setSuppressAllDiagnostics(Suppress);
 if (R.isUsable()) {
   ZeroArgCallReturnTy = R.get()->getType();
   return true;

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=369145=369144=369145=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Aug 16 12:53:22 2019
@@ -5798,8 +5798,7 @@ Expr *OpenMPIterationSpaceChecker::build
 Scope *S, Expr *Cond,
 llvm::MapVector ) const {
   // Try to build LB  UB, where  is <, >, <=, or >=.
-  bool Suppress = SemaRef.getDiagnostics().getSuppressAllDiagnostics();
-  SemaRef.getDiagnostics().setSuppressAllDiagnostics(/*Val=*/true);
+  Sema::TentativeAnalysisScope Trap(SemaRef);
 
   ExprResult NewLB =
   InitDependOnLC ? LB : tryBuildCapture(SemaRef, LB, Captures);
@@ -5821,7 +5820,7 @@ Expr *OpenMPIterationSpaceChecker::build
   CondExpr.get(), SemaRef.Context.BoolTy, /*Action=*/Sema::AA_Casting,
   /*AllowExplicit=*/true);
   }
-  SemaRef.getDiagnostics().setSuppressAllDiagnostics(Suppress);
+
   // Otherwise use original loop condition and evaluate it in runtime.
   return CondExpr.isUsable() ? CondExpr.get() : Cond;
 }
@@ -6243,8 +6242,8 @@ static ExprResult buildCounterUpdate(
   if (VarRef.get()->getType()->isOverloadableType() ||
   NewStart.get()->getType()->isOverloadableType() ||
   Update.get()->getType()->isOverloadableType()) {
-bool Suppress = SemaRef.getDiagnostics().getSuppressAllDiagnostics();
-SemaRef.getDiagnostics().setSuppressAllDiagnostics(/*Val=*/true);
+Sema::TentativeAnalysisScope Trap(SemaRef);
+
 Update =
 SemaRef.BuildBinOp(S, Loc, BO_Assign, VarRef.get(), NewStart.get());
 if (Update.isUsable()) {
@@ -6256,7 +6255,6 @@ static ExprResult buildCounterUpdate(
 UpdateVal.get());
   }
 }
-SemaRef.getDiagnostics().setSuppressAllDiagnostics(Suppress);
   }
 
   // Second attempt: try to build 'VarRef = Start (+|-) Iter * Step'.
@@ -13605,11 +13603,13 @@ Sema::ActOnOpenMPDependClause(OpenMPDepe
 << RefExpr->getSourceRange();
 continue;
   }
-  bool Suppress = getDiagnostics().getSuppressAllDiagnostics();
-  getDiagnostics().setSuppressAllDiagnostics(/*Val=*/true);
-  ExprResult Res =
-  CreateBuiltinUnaryOp(ELoc, UO_AddrOf, 
RefExpr->IgnoreParenImpCasts());
-  getDiagnostics().setSuppressAllDiagnostics(Suppress);
+
+  ExprResult 

[PATCH] D66353: [clang-doc] Redesign of generated HTML files

2019-08-16 Thread Diego Astiazarán via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369139: [clang-doc] Redesign of generated HTML files 
(authored by DiegoAstiazaran, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66353?vs=215642=215649#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66353

Files:
  clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/trunk/clang-doc/Representation.cpp
  clang-tools-extra/trunk/clang-doc/Representation.h
  clang-tools-extra/trunk/clang-doc/assets/clang-doc-default-stylesheet.css
  clang-tools-extra/trunk/clang-doc/assets/index.js
  clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/trunk/docs/clang-doc.rst
  clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp

Index: clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -10,11 +10,15 @@
 #include "Generators.h"
 #include "Representation.h"
 #include "Serialize.h"
+#include "clang/Basic/Version.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace doc {
 
+static const std::string ClangDocVersion =
+clang::getClangToolFullVersion("clang-doc");
+
 std::unique_ptr getHTMLGenerator() {
   auto G = doc::findGeneratorByName("html");
   if (!G)
@@ -25,7 +29,8 @@
 ClangDocContext
 getClangDocContext(std::vector UserStylesheets = {},
StringRef RepositoryUrl = "") {
-  ClangDocContext CDCtx{{}, {}, {}, {}, RepositoryUrl, UserStylesheets, {}};
+  ClangDocContext CDCtx{
+  {}, "test-project", {}, {}, {}, RepositoryUrl, UserStylesheets, {}};
   CDCtx.UserStylesheets.insert(
   CDCtx.UserStylesheets.begin(),
   "../share/clang/clang-doc-default-stylesheet.css");
@@ -61,67 +66,76 @@
 
 
 
-
-
-  
-
-  Namespaces
-
-  
-  
-
-  Records
-
-  
-  
-
-  Functions
-
+test-project
+
+  
+  
+namespace Namespace
+Namespaces
 
   
-
-  OneFunction
-
+ChildNamespace
   
 
-  
-  
-
-  Enums
-
+Records
 
   
-
-  OneEnum
-
+ChildStruct
   
 
-  
-
-
-  namespace Namespace
-  Namespaces
-  
-
-  ChildNamespace
-
-  
-  Records
-  
-
-  ChildStruct
-
-  
-  Functions
-  
-OneFunction
-OneFunction()
+Functions
+
+  OneFunction
+  OneFunction()
+
+Enums
+
+  enum OneEnum
+
   
-  Enums
-  
-enum OneEnum
+  
+
+  
+
+  Namespaces
+
+  
+  
+
+  Records
+
+  
+  
+
+  Functions
+
+
+  
+
+  OneFunction
+
+  
+
+  
+  
+
+  Enums
+
+
+  
+
+  OneEnum
+
+  
+
+  
+
   
-
+
+
+  )raw" +
+ ClangDocVersion + R"raw(
+
 )raw";
 
   EXPECT_EQ(Expected, Actual.str());
@@ -162,80 +176,89 @@
 class r
 
 
-
-
-  
-
-  Members
-
-  
-  
-
-  Records
-
-  
-  
-
-  Functions
-
+test-project
+
+  
+  
+class r
+
+  Defined at line 
+  http://www.repository.com/dir/test.cpp#10;>10
+   of file 
+  http://www.repository.com/dir/test.cpp;>test.cpp
+
+
+  Inherits from 
+  F
+  , G
+
+Members
 
   
-
-  OneFunction
-
+private 
+int
+ X
   
 
-  
-  
-
-  Enums
-
+Records
 
   
-
-  OneEnum
-
+ChildStruct
   
 
-  
-
-
-  class r
-  
-Defined at line 
-http://www.repository.com/dir/test.cpp#10;>10
- of file 
-http://www.repository.com/dir/test.cpp;>test.cpp
-  
-  
-Inherits from 
-F
-, G
-  
-  Members
-  
-
-  private 
-  int
-   X
-
-  
-  Records
-  
-
-  ChildStruct
-
-  
-  Functions
-  
-OneFunction
-public OneFunction()
+Functions
+
+  OneFunction
+  public OneFunction()
+
+Enums
+
+  enum OneEnum
+
   
-  Enums
-  
-enum OneEnum
+  
+
+  
+
+  Members
+
+  
+  
+
+  Records
+
+  
+  
+
+  Functions
+
+
+  
+
+  OneFunction
+
+  
+
+  
+  
+
+  Enums
+
+
+  
+
+  OneEnum
+
+  
+
+ 

[clang-tools-extra] r369139 - [clang-doc] Redesign of generated HTML files

2019-08-16 Thread Diego Astiazaran via cfe-commits
Author: diegoastiazaran
Date: Fri Aug 16 11:38:11 2019
New Revision: 369139

URL: http://llvm.org/viewvc/llvm-project?rev=369139=rev
Log:
[clang-doc] Redesign of generated HTML files

The new design includes a header (contains the project name), a main section, 
and a footer.
The main section is divided into three subsections. Left, middle, right. The 
left section contains the general index, the middle contains the info's data, 
and the right contains the index for the info's content.
The CSS has been updated.
A flag --project-name is added.
The Attributes attribute of the TagNode struct is now a vector of pairs because 
these attributes should be rendered in the insertion order.
The functions (cpp and js) that converts an Index tree structure into HTML were 
slightly modified; the first ul tag created is now a ol tag. The inner lists 
are still ul.

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

Modified:
clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp
clang-tools-extra/trunk/clang-doc/Representation.cpp
clang-tools-extra/trunk/clang-doc/Representation.h
clang-tools-extra/trunk/clang-doc/assets/clang-doc-default-stylesheet.css
clang-tools-extra/trunk/clang-doc/assets/index.js
clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp
clang-tools-extra/trunk/docs/clang-doc.rst
clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp

Modified: clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp?rev=369139=369138=369139=diff
==
--- clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp (original)
+++ clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp Fri Aug 16 11:38:11 2019
@@ -8,6 +8,7 @@
 
 #include "Generators.h"
 #include "Representation.h"
+#include "clang/Basic/Version.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/FileSystem.h"
@@ -29,12 +30,16 @@ public:
   enum TagType {
 TAG_A,
 TAG_DIV,
+TAG_FOOTER,
 TAG_H1,
 TAG_H2,
 TAG_H3,
+TAG_HEADER,
 TAG_LI,
 TAG_LINK,
+TAG_MAIN,
 TAG_META,
+TAG_OL,
 TAG_P,
 TAG_SCRIPT,
 TAG_SPAN,
@@ -84,7 +89,7 @@ struct TagNode : public HTMLNode {
 
   HTMLTag Tag; // Name of HTML Tag (p, div, h1)
   std::vector> Children; // List of child nodes
-  llvm::StringMap>
+  std::vector, llvm::SmallString<16>>>
   Attributes; // List of key-value attributes for tag
 
   void Render(llvm::raw_ostream , int IndentationLevel) override;
@@ -112,10 +117,14 @@ bool HTMLTag::IsSelfClosing() const {
 return true;
   case HTMLTag::TAG_A:
   case HTMLTag::TAG_DIV:
+  case HTMLTag::TAG_FOOTER:
   case HTMLTag::TAG_H1:
   case HTMLTag::TAG_H2:
   case HTMLTag::TAG_H3:
+  case HTMLTag::TAG_HEADER:
   case HTMLTag::TAG_LI:
+  case HTMLTag::TAG_MAIN:
+  case HTMLTag::TAG_OL:
   case HTMLTag::TAG_P:
   case HTMLTag::TAG_SCRIPT:
   case HTMLTag::TAG_SPAN:
@@ -132,18 +141,26 @@ llvm::SmallString<16> HTMLTag::ToString(
 return llvm::SmallString<16>("a");
   case HTMLTag::TAG_DIV:
 return llvm::SmallString<16>("div");
+  case HTMLTag::TAG_FOOTER:
+return llvm::SmallString<16>("footer");
   case HTMLTag::TAG_H1:
 return llvm::SmallString<16>("h1");
   case HTMLTag::TAG_H2:
 return llvm::SmallString<16>("h2");
   case HTMLTag::TAG_H3:
 return llvm::SmallString<16>("h3");
+  case HTMLTag::TAG_HEADER:
+return llvm::SmallString<16>("header");
   case HTMLTag::TAG_LI:
 return llvm::SmallString<16>("li");
   case HTMLTag::TAG_LINK:
 return llvm::SmallString<16>("link");
+  case HTMLTag::TAG_MAIN:
+return llvm::SmallString<16>("main");
   case HTMLTag::TAG_META:
 return llvm::SmallString<16>("meta");
+  case HTMLTag::TAG_OL:
+return llvm::SmallString<16>("ol");
   case HTMLTag::TAG_P:
 return llvm::SmallString<16>("p");
   case HTMLTag::TAG_SCRIPT:
@@ -174,7 +191,7 @@ void TagNode::Render(llvm::raw_ostream &
   OS.indent(IndentationLevel * 2);
   OS << "<" << Tag.ToString();
   for (const auto  : Attributes)
-OS << " " << A.getKey() << "=\"" << A.getValue() << "\"";
+OS << " " << A.first << "=\"" << A.second << "\"";
   if (Tag.IsSelfClosing()) {
 OS << "/>";
 return;
@@ -255,13 +272,13 @@ genStylesheetsHTML(StringRef InfoPath, c
   std::vector> Out;
   for (const auto  : CDCtx.UserStylesheets) {
 auto LinkNode = std::make_unique(HTMLTag::TAG_LINK);
-LinkNode->Attributes.try_emplace("rel", "stylesheet");
+LinkNode->Attributes.emplace_back("rel", "stylesheet");
 SmallString<128> StylesheetPath = computeRelativePath("", InfoPath);
 llvm::sys::path::append(StylesheetPath,
 llvm::sys::path::filename(FilePath));
 // Paths in HTML must be in posix-style
 llvm::sys::path::native(StylesheetPath, llvm::sys::path::Style::posix);
-

[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-08-16 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 215646.
paulkirth added a comment.

Remove reference to clang-misexpect from CMakeLists.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66324

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/MisExpect.cpp
  clang/lib/CodeGen/MisExpect.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext
  clang/test/Profile/Inputs/misexpect-branch.proftext
  clang/test/Profile/Inputs/misexpect-switch-default-only.proftext
  clang/test/Profile/Inputs/misexpect-switch.proftext
  clang/test/Profile/misexpect-branch-cold.c
  clang/test/Profile/misexpect-branch-nonconst-expected-val.c
  clang/test/Profile/misexpect-branch.c
  clang/test/Profile/misexpect-no-warning-without-flag.c
  clang/test/Profile/misexpect-switch-default.c
  clang/test/Profile/misexpect-switch-nonconst.c
  clang/test/Profile/misexpect-switch-only-default-case.c
  clang/test/Profile/misexpect-switch.c
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/FixedMetadataKinds.def
  llvm/include/llvm/IR/MDBuilder.h
  llvm/include/llvm/Transforms/Utils/MisExpect.h
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/MDBuilder.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt
  llvm/lib/Transforms/Utils/MisExpect.cpp
  llvm/test/ThinLTO/X86/lazyload_metadata.ll
  llvm/test/Transforms/LowerExpectIntrinsic/basic.ll

Index: llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
===
--- llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
+++ llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
@@ -138,7 +138,7 @@
   %conv1 = sext i32 %conv to i64
   %expval = call i64 @llvm.expect.i64(i64 %conv1, i64 0)
   %tobool = icmp ne i64 %expval, 0
-; CHECK: !prof !1
+; CHECK: !prof !2
 ; CHECK-NOT: @llvm.expect
   br i1 %tobool, label %if.then, label %if.end
 
@@ -165,7 +165,7 @@
   %tmp = load i32, i32* %x.addr, align 4
   %conv = sext i32 %tmp to i64
   %expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
-; CHECK: !prof !2
+; CHECK: !prof !4
 ; CHECK-NOT: @llvm.expect
   switch i64 %expval, label %sw.epilog [
 i64 1, label %sw.bb
@@ -194,7 +194,7 @@
   %tmp = load i32, i32* %x.addr, align 4
   %conv = sext i32 %tmp to i64
   %expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
-; CHECK: !prof !3
+; CHECK: !prof !5
 ; CHECK-NOT: @llvm.expect
   switch i64 %expval, label %sw.epilog [
 i64 2, label %sw.bb
@@ -278,7 +278,7 @@
   %t7 = call i64 @llvm.expect.i64(i64 %t6, i64 0)
   %t8 = icmp ne i64 %t7, 0
   %t9 = select i1 %t8, i32 1, i32 2
-; CHECK: select{{.*}}, !prof !1
+; CHECK: select{{.*}}, !prof !2
   ret i32 %t9
 }
 
@@ -286,6 +286,6 @@
 declare i1 @llvm.expect.i1(i1, i1) nounwind readnone
 
 ; CHECK: !0 = !{!"branch_weights", i32 2000, i32 1}
-; CHECK: !1 = !{!"branch_weights", i32 1, i32 2000}
-; CHECK: !2 = !{!"branch_weights", i32 1, i32 2000, i32 1}
-; CHECK: !3 = !{!"branch_weights", i32 2000, i32 1, i32 1}
+; CHECK: !2 = !{!"branch_weights", i32 1, i32 2000}
+; CHECK: !4 = !{!"branch_weights", i32 1, i32 2000, i32 1}
+; CHECK: !5 = !{!"branch_weights", i32 2000, i32 1, i32 1}
Index: llvm/test/ThinLTO/X86/lazyload_metadata.ll
===
--- llvm/test/ThinLTO/X86/lazyload_metadata.ll
+++ llvm/test/ThinLTO/X86/lazyload_metadata.ll
@@ -10,13 +10,13 @@
 ; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t3.bc \
 ; RUN:  -o /dev/null -stats \
 ; RUN:  2>&1 | FileCheck %s -check-prefix=LAZY
-; LAZY: 61 bitcode-reader  - Number of Metadata records loaded
+; LAZY: 63 bitcode-reader  - Number of Metadata records loaded
 ; LAZY: 2 bitcode-reader  - Number of MDStrings loaded
 
 ; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t3.bc \
 ; RUN:  -o /dev/null -disable-ondemand-mds-loading -stats \
 ; RUN:  2>&1 | FileCheck %s -check-prefix=NOTLAZY
-; NOTLAZY: 70 bitcode-reader  - Number of Metadata records loaded
+; NOTLAZY: 72 bitcode-reader  - Number of Metadata records loaded
 ; NOTLAZY: 7 bitcode-reader  - Number of MDStrings loaded
 
 
Index: llvm/lib/Transforms/Utils/MisExpect.cpp
===
--- /dev/null
+++ llvm/lib/Transforms/Utils/MisExpect.cpp
@@ -0,0 +1,105 @@
+//===--- MisExpect.cpp - Check Use of __builtin_expect() with PGO data ===//
+//
+// Part 

[PATCH] D66353: [clang-doc] Redesign of generated HTML files

2019-08-16 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett accepted this revision.
juliehockett added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D66353



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


[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-08-16 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 215643.
paulkirth edited the summary of this revision.
paulkirth added a comment.
Herald added subscribers: dexonsmith, steven_wu, mehdi_amini.

Removes standalone clang-misexpect from revision


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66324

Files:
  clang-tools-extra/CMakeLists.txt
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/MisExpect.cpp
  clang/lib/CodeGen/MisExpect.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext
  clang/test/Profile/Inputs/misexpect-branch.proftext
  clang/test/Profile/Inputs/misexpect-switch-default-only.proftext
  clang/test/Profile/Inputs/misexpect-switch.proftext
  clang/test/Profile/misexpect-branch-cold.c
  clang/test/Profile/misexpect-branch-nonconst-expected-val.c
  clang/test/Profile/misexpect-branch.c
  clang/test/Profile/misexpect-no-warning-without-flag.c
  clang/test/Profile/misexpect-switch-default.c
  clang/test/Profile/misexpect-switch-nonconst.c
  clang/test/Profile/misexpect-switch-only-default-case.c
  clang/test/Profile/misexpect-switch.c
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/FixedMetadataKinds.def
  llvm/include/llvm/IR/MDBuilder.h
  llvm/include/llvm/Transforms/Utils/MisExpect.h
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/MDBuilder.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt
  llvm/lib/Transforms/Utils/MisExpect.cpp
  llvm/test/ThinLTO/X86/lazyload_metadata.ll
  llvm/test/Transforms/LowerExpectIntrinsic/basic.ll

Index: llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
===
--- llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
+++ llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
@@ -138,7 +138,7 @@
   %conv1 = sext i32 %conv to i64
   %expval = call i64 @llvm.expect.i64(i64 %conv1, i64 0)
   %tobool = icmp ne i64 %expval, 0
-; CHECK: !prof !1
+; CHECK: !prof !2
 ; CHECK-NOT: @llvm.expect
   br i1 %tobool, label %if.then, label %if.end
 
@@ -165,7 +165,7 @@
   %tmp = load i32, i32* %x.addr, align 4
   %conv = sext i32 %tmp to i64
   %expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
-; CHECK: !prof !2
+; CHECK: !prof !4
 ; CHECK-NOT: @llvm.expect
   switch i64 %expval, label %sw.epilog [
 i64 1, label %sw.bb
@@ -194,7 +194,7 @@
   %tmp = load i32, i32* %x.addr, align 4
   %conv = sext i32 %tmp to i64
   %expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
-; CHECK: !prof !3
+; CHECK: !prof !5
 ; CHECK-NOT: @llvm.expect
   switch i64 %expval, label %sw.epilog [
 i64 2, label %sw.bb
@@ -278,7 +278,7 @@
   %t7 = call i64 @llvm.expect.i64(i64 %t6, i64 0)
   %t8 = icmp ne i64 %t7, 0
   %t9 = select i1 %t8, i32 1, i32 2
-; CHECK: select{{.*}}, !prof !1
+; CHECK: select{{.*}}, !prof !2
   ret i32 %t9
 }
 
@@ -286,6 +286,6 @@
 declare i1 @llvm.expect.i1(i1, i1) nounwind readnone
 
 ; CHECK: !0 = !{!"branch_weights", i32 2000, i32 1}
-; CHECK: !1 = !{!"branch_weights", i32 1, i32 2000}
-; CHECK: !2 = !{!"branch_weights", i32 1, i32 2000, i32 1}
-; CHECK: !3 = !{!"branch_weights", i32 2000, i32 1, i32 1}
+; CHECK: !2 = !{!"branch_weights", i32 1, i32 2000}
+; CHECK: !4 = !{!"branch_weights", i32 1, i32 2000, i32 1}
+; CHECK: !5 = !{!"branch_weights", i32 2000, i32 1, i32 1}
Index: llvm/test/ThinLTO/X86/lazyload_metadata.ll
===
--- llvm/test/ThinLTO/X86/lazyload_metadata.ll
+++ llvm/test/ThinLTO/X86/lazyload_metadata.ll
@@ -10,13 +10,13 @@
 ; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t3.bc \
 ; RUN:  -o /dev/null -stats \
 ; RUN:  2>&1 | FileCheck %s -check-prefix=LAZY
-; LAZY: 61 bitcode-reader  - Number of Metadata records loaded
+; LAZY: 63 bitcode-reader  - Number of Metadata records loaded
 ; LAZY: 2 bitcode-reader  - Number of MDStrings loaded
 
 ; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t3.bc \
 ; RUN:  -o /dev/null -disable-ondemand-mds-loading -stats \
 ; RUN:  2>&1 | FileCheck %s -check-prefix=NOTLAZY
-; NOTLAZY: 70 bitcode-reader  - Number of Metadata records loaded
+; NOTLAZY: 72 bitcode-reader  - Number of Metadata records loaded
 ; NOTLAZY: 7 bitcode-reader  - Number of MDStrings loaded
 
 
Index: llvm/lib/Transforms/Utils/MisExpect.cpp
===
--- /dev/null
+++ 

[PATCH] D66353: [clang-doc] Redesign of generated HTML files

2019-08-16 Thread Diego Astiazarán via Phabricator via cfe-commits
DiegoAstiazaran updated this revision to Diff 215642.
DiegoAstiazaran marked 3 inline comments as done.
DiegoAstiazaran added a comment.

Add comments.
Fix clang-doc version.


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

https://reviews.llvm.org/D66353

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/assets/clang-doc-default-stylesheet.css
  clang-tools-extra/clang-doc/assets/index.js
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/docs/clang-doc.rst
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -10,11 +10,15 @@
 #include "Generators.h"
 #include "Representation.h"
 #include "Serialize.h"
+#include "clang/Basic/Version.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace doc {
 
+static const std::string ClangDocVersion =
+clang::getClangToolFullVersion("clang-doc");
+
 std::unique_ptr getHTMLGenerator() {
   auto G = doc::findGeneratorByName("html");
   if (!G)
@@ -25,7 +29,8 @@
 ClangDocContext
 getClangDocContext(std::vector UserStylesheets = {},
StringRef RepositoryUrl = "") {
-  ClangDocContext CDCtx{{}, {}, {}, {}, RepositoryUrl, UserStylesheets, {}};
+  ClangDocContext CDCtx{
+  {}, "test-project", {}, {}, {}, RepositoryUrl, UserStylesheets, {}};
   CDCtx.UserStylesheets.insert(
   CDCtx.UserStylesheets.begin(),
   "../share/clang/clang-doc-default-stylesheet.css");
@@ -61,67 +66,76 @@
 
 
 
-
-
-  
-
-  Namespaces
-
-  
-  
-
-  Records
-
-  
-  
-
-  Functions
-
+test-project
+
+  
+  
+namespace Namespace
+Namespaces
 
   
-
-  OneFunction
-
+ChildNamespace
   
 
-  
-  
-
-  Enums
-
+Records
 
   
-
-  OneEnum
-
+ChildStruct
   
 
-  
-
-
-  namespace Namespace
-  Namespaces
-  
-
-  ChildNamespace
-
-  
-  Records
-  
-
-  ChildStruct
-
-  
-  Functions
-  
-OneFunction
-OneFunction()
+Functions
+
+  OneFunction
+  OneFunction()
+
+Enums
+
+  enum OneEnum
+
   
-  Enums
-  
-enum OneEnum
+  
+
+  
+
+  Namespaces
+
+  
+  
+
+  Records
+
+  
+  
+
+  Functions
+
+
+  
+
+  OneFunction
+
+  
+
+  
+  
+
+  Enums
+
+
+  
+
+  OneEnum
+
+  
+
+  
+
   
-
+
+
+  )raw" +
+ ClangDocVersion + R"raw(
+
 )raw";
 
   EXPECT_EQ(Expected, Actual.str());
@@ -162,80 +176,89 @@
 class r
 
 
-
-
-  
-
-  Members
-
-  
-  
-
-  Records
-
-  
-  
-
-  Functions
-
+test-project
+
+  
+  
+class r
+
+  Defined at line 
+  http://www.repository.com/dir/test.cpp#10;>10
+   of file 
+  http://www.repository.com/dir/test.cpp;>test.cpp
+
+
+  Inherits from 
+  F
+  , G
+
+Members
 
   
-
-  OneFunction
-
+private 
+int
+ X
   
 
-  
-  
-
-  Enums
-
+Records
 
   
-
-  OneEnum
-
+ChildStruct
   
 
-  
-
-
-  class r
-  
-Defined at line 
-http://www.repository.com/dir/test.cpp#10;>10
- of file 
-http://www.repository.com/dir/test.cpp;>test.cpp
-  
-  
-Inherits from 
-F
-, G
-  
-  Members
-  
-
-  private 
-  int
-   X
-
-  
-  Records
-  
-
-  ChildStruct
-
-  
-  Functions
-  
-OneFunction
-public OneFunction()
+Functions
+
+  OneFunction
+  public OneFunction()
+
+Enums
+
+  enum OneEnum
+
   
-  Enums
-  
-enum OneEnum
+  
+
+  
+
+  Members
+
+  
+  
+
+  Records
+
+  
+  
+
+  Functions
+
+
+  
+
+  OneFunction
+
+  
+
+  
+  
+
+  Enums
+
+
+  
+
+  OneEnum
+
+  
+
+  
+
   
-
+
+
+  )raw" +
+ ClangDocVersion + R"raw(
+
 )raw";
 
   EXPECT_EQ(Expected, Actual.str());
@@ -270,17 +293,25 @@
 
 
 
-
-
-  f
-  
-float
- f(
-int
- P)
-  
-  Defined at line 10 of file dir/test.cpp
-

[PATCH] D66332: [clang-format] Fix the bug that joins template closer and > or >>

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

Drive-by observation: My experiments with 
https://zed0.co.uk/clang-format-configurator/ show that there is a similar bug 
where clang-format accidentally produces `>=` via reformatting of 
`template` `=0>`, `pi` `=3;`, and so on. Is it 
possible to fix that bug as part of this patch, and/or would you be interested 
in patching that bug as a follow-up to this one?


Repository:
  rC Clang

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

https://reviews.llvm.org/D66332



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


[PATCH] D66332: [clang-format] Fix the bug that joins template closer and > or >>

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

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D66332



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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-08-16 Thread Vyacheslav Zakharin via Phabricator via cfe-commits
vzakhari added a comment.

In D64943#1633372 , @lebedev.ri wrote:

> In D64943#1633357 , @vzakhari wrote:
>
> > In D64943#1633175 , @ABataev wrote:
> >
> > > In D64943#1633170 , @lebedev.ri 
> > > wrote:
> > >
> > > > In D64943#1633164 , @ABataev 
> > > > wrote:
> > > >
> > > > > In D64943#1619958 , 
> > > > > @sdmitriev wrote:
> > > > >
> > > > > > As I understand ‘atexit’ solution would be target dependent 
> > > > > > (‘__cxa_atexit’ on Linux and ‘atexit’ on Windows) whereas 
> > > > > > @llvm.global_ctors/dtors variables offer similar and platform 
> > > > > > neutral functionality 
> > > > > > (http://llvm.org/docs/LangRef.html#the-llvm-global-ctors-global-variable).
> > > > > >  Why do you think that ‘atexit’ is a better choice?
> > > > >
> > > > >
> > > > > Because it does not work on Windows, better to have portable 
> > > > > solution, if possible.
> > > >
> > > >
> > > > Is there a bug # ?
> > >
> > >
> > > @vzakhari?
> >
> >
> > I do not have bug #, but the issue was introduced with the following commit:
> >  commit f803b23879d9e1d9415ec1875713534dcc203df5 
> > 
> >  Author: Reid Kleckner 
> >  Date:   Fri Sep 7 23:07:55 2018 +
> >
> >   [COFF] Implement llvm.global_ctors priorities for MSVC COFF targets
> >   
> >   Summary:
> >   MSVC and LLD sort sections ASCII-betically, so we need to use section
> >   names that sort between .CRT$XCA (the start) and .CRT$XCU (the default
> >   priority).
> >   
> >   In the general case, use .CRT$XCT12345 as the section name, and let the
> >   linker sort the zero-padded digits.
> >   
> >   Users with low priorities typically want to initialize as early as
> >   possible, so use .CRT$XCA00199 for prioties less than 200. This number
> >   is arbitrary.
> >   
> >   Implements PR38552.
> >   
> >   Reviewers: majnemer, mstorsjo
> >   
> >   Subscribers: hiraditya, llvm-commits
> >   
> >   Differential Revision: https://reviews.llvm.org/D51820
> >   
> >   llvm-svn: 341727
> >   
> >   
> >
> > The destructors are still in .CRT$XT for default priority (65535) now, but 
> > for non-default priority they will go into .CRT$XC.  I will upload a fixing 
> > patch with a LIT test shortly.
> >
> > This clang-offload-wrapper commit will work properly, if we use default 
> > priority for the destructors.
>
>
> 'IMHO' if there is a problem with lowering of LLVM IR constructs for some
>  particular targets, that problem must be resolved instead of adding 
> workarounds.


I completely agree with you!  I am testing the patch for destructors.


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

https://reviews.llvm.org/D64943



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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-08-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D64943#1633357 , @vzakhari wrote:

> In D64943#1633175 , @ABataev wrote:
>
> > In D64943#1633170 , @lebedev.ri 
> > wrote:
> >
> > > In D64943#1633164 , @ABataev 
> > > wrote:
> > >
> > > > In D64943#1619958 , @sdmitriev 
> > > > wrote:
> > > >
> > > > > As I understand ‘atexit’ solution would be target dependent 
> > > > > (‘__cxa_atexit’ on Linux and ‘atexit’ on Windows) whereas 
> > > > > @llvm.global_ctors/dtors variables offer similar and platform neutral 
> > > > > functionality 
> > > > > (http://llvm.org/docs/LangRef.html#the-llvm-global-ctors-global-variable).
> > > > >  Why do you think that ‘atexit’ is a better choice?
> > > >
> > > >
> > > > Because it does not work on Windows, better to have portable solution, 
> > > > if possible.
> > >
> > >
> > > Is there a bug # ?
> >
> >
> > @vzakhari?
>
>
> I do not have bug #, but the issue was introduced with the following commit:
>  commit f803b23879d9e1d9415ec1875713534dcc203df5 
> 
>  Author: Reid Kleckner 
>  Date:   Fri Sep 7 23:07:55 2018 +
>
>   [COFF] Implement llvm.global_ctors priorities for MSVC COFF targets
>   
>   Summary:
>   MSVC and LLD sort sections ASCII-betically, so we need to use section
>   names that sort between .CRT$XCA (the start) and .CRT$XCU (the default
>   priority).
>   
>   In the general case, use .CRT$XCT12345 as the section name, and let the
>   linker sort the zero-padded digits.
>   
>   Users with low priorities typically want to initialize as early as
>   possible, so use .CRT$XCA00199 for prioties less than 200. This number
>   is arbitrary.
>   
>   Implements PR38552.
>   
>   Reviewers: majnemer, mstorsjo
>   
>   Subscribers: hiraditya, llvm-commits
>   
>   Differential Revision: https://reviews.llvm.org/D51820
>   
>   llvm-svn: 341727
>   
>   
>
> The destructors are still in .CRT$XT for default priority (65535) now, but 
> for non-default priority they will go into .CRT$XC.  I will upload a fixing 
> patch with a LIT test shortly.
>
> This clang-offload-wrapper commit will work properly, if we use default 
> priority for the destructors.


'IMHO' if there is a problem with lowering of LLVM IR constructs for some
particular targets, that problem must be resolved instead of adding workarounds.


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

https://reviews.llvm.org/D64943



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


[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-08-16 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

In D66324#1632653 , @lebedev.ri wrote:

> This is marked as child revision of D65300  
> but it seems like they both add
>  the same logic, just into different components, D65300 
>  to clang, this to llvm.
>  Is this duplication or are the diffs concurrent?


So this change extends and revises what is in D65300 
.  The diffs are somewhat concurrent. For 
example the backend changes rely on the frontend warning being available. i.e. 
diag::warn_profile_data_misexpect.  But yes the logic is mostly the same.

I'm also not terribly familiar with Phabricator, so maybe I should have 
uploaded a diff between my two revisions, rather than between the my changes 
and top of tree?

> Can D65300  be re-implemented to just use 
> this llvm code?

So it is possible to handle this completely in the backed, but the diagnostic 
output is not fantastic when using clang based instrumentation. In particular, 
we would need to emit the diagnostic in LowerExpectIntrisic.cpp by checking if 
the branch weight metadata already exists, and processing it there before it is 
overwritten. For some reason emitting the diagnostic at that point will not 
also emit the helpful source listing if there is a macro, even though a 
FullSourceLoc is available. This isn't an issue for either the handling in 
SampleProfile.cpp or in PGOInstrumentation.cpp.

In the end, I decided that it actually made sense for clang to handle the clang 
based instrumentation, and llvm to handle the IR/Sampling instrumentation.

> I'm also thinking the clang-misexpect *tool* should be a separate change,
>  it's misleading to have it here as it gives impression that it **has** to be 
> used,
>  which i'm not sure is so?

Sure, I can update this so that the standalone tool is in a separate change. 
The thought was to consolidate all the related changes needed for the 
standalone tool, but I see your point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66324



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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-08-16 Thread Vyacheslav Zakharin via Phabricator via cfe-commits
vzakhari added a comment.

In D64943#1633175 , @ABataev wrote:

> In D64943#1633170 , @lebedev.ri 
> wrote:
>
> > In D64943#1633164 , @ABataev wrote:
> >
> > > In D64943#1619958 , @sdmitriev 
> > > wrote:
> > >
> > > > As I understand ‘atexit’ solution would be target dependent 
> > > > (‘__cxa_atexit’ on Linux and ‘atexit’ on Windows) whereas 
> > > > @llvm.global_ctors/dtors variables offer similar and platform neutral 
> > > > functionality 
> > > > (http://llvm.org/docs/LangRef.html#the-llvm-global-ctors-global-variable).
> > > >  Why do you think that ‘atexit’ is a better choice?
> > >
> > >
> > > Because it does not work on Windows, better to have portable solution, if 
> > > possible.
> >
> >
> > Is there a bug # ?
>
>
> @vzakhari?


I do not have bug #, but the issue was introduced with the following commit:
commit f803b23879d9e1d9415ec1875713534dcc203df5 

Author: Reid Kleckner 
Date:   Fri Sep 7 23:07:55 2018 +

  [COFF] Implement llvm.global_ctors priorities for MSVC COFF targets
  
  Summary:
  MSVC and LLD sort sections ASCII-betically, so we need to use section
  names that sort between .CRT$XCA (the start) and .CRT$XCU (the default
  priority).
  
  In the general case, use .CRT$XCT12345 as the section name, and let the
  linker sort the zero-padded digits.
  
  Users with low priorities typically want to initialize as early as
  possible, so use .CRT$XCA00199 for prioties less than 200. This number
  is arbitrary.
  
  Implements PR38552.
  
  Reviewers: majnemer, mstorsjo
  
  Subscribers: hiraditya, llvm-commits
  
  Differential Revision: https://reviews.llvm.org/D51820
  
  llvm-svn: 341727

The destructors are still in .CRT$XT for default priority (65535) now, but for 
non-default priority they will go into .CRT$XC.  I will upload a fixing patch 
with a LIT test shortly.

This clang-offload-wrapper commit will work properly, if we use default 
priority for the destructors.


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

https://reviews.llvm.org/D64943



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


[PATCH] D66353: [clang-doc] Redesign of generated HTML files

2019-08-16 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-tools-extra/clang-doc/HTMLGenerator.cpp:487-489
+static std::unique_ptr
+genFileMainNode(StringRef InfoPath,
+std::vector> ,

Would you be able to briefly comment on each of these `gen*Node` functions on 
what exactly they're doing? I'm having trouble getting a picture of what the 
flow is there



Comment at: clang-tools-extra/clang-doc/HTMLGenerator.cpp:523
+  auto SpanNode =
+  std::make_unique(HTMLTag::TAG_SPAN, "clang-doc version 
unknown");
+  SpanNode->Attributes.emplace_back("class", "no-break");

Try using `getClangToolFullVersion` for here? 
https://clang.llvm.org/doxygen/namespaceclang.html#a35fdf9e05d2640414289e62cc837bf78



Comment at: clang-tools-extra/clang-doc/HTMLGenerator.cpp:828
+  std::vector> MainContentNodes;
+  std::make_unique(HTMLTag::TAG_DIV);
   Index InfoIndex;

This isn't doing anything


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

https://reviews.llvm.org/D66353



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


[PATCH] D63325: [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks

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

Ping!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63325



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


[PATCH] D66353: [clang-doc] Redesign of generated HTML files

2019-08-16 Thread Diego Astiazarán via Phabricator via cfe-commits
DiegoAstiazaran updated this revision to Diff 215624.
DiegoAstiazaran added a comment.

Run clang-format


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

https://reviews.llvm.org/D66353

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/assets/clang-doc-default-stylesheet.css
  clang-tools-extra/clang-doc/assets/index.js
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/docs/clang-doc.rst
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -25,7 +25,8 @@
 ClangDocContext
 getClangDocContext(std::vector UserStylesheets = {},
StringRef RepositoryUrl = "") {
-  ClangDocContext CDCtx{{}, {}, {}, {}, RepositoryUrl, UserStylesheets, {}};
+  ClangDocContext CDCtx{
+  {}, "test-project", {}, {}, {}, RepositoryUrl, UserStylesheets, {}};
   CDCtx.UserStylesheets.insert(
   CDCtx.UserStylesheets.begin(),
   "../share/clang/clang-doc-default-stylesheet.css");
@@ -61,67 +62,75 @@
 
 
 
-
-
-  
-
-  Namespaces
-
-  
-  
-
-  Records
-
-  
-  
-
-  Functions
-
+test-project
+
+  
+  
+namespace Namespace
+Namespaces
 
   
-
-  OneFunction
-
+ChildNamespace
   
 
-  
-  
-
-  Enums
-
+Records
 
   
-
-  OneEnum
-
+ChildStruct
   
 
-  
-
-
-  namespace Namespace
-  Namespaces
-  
-
-  ChildNamespace
-
-  
-  Records
-  
-
-  ChildStruct
-
-  
-  Functions
-  
-OneFunction
-OneFunction()
+Functions
+
+  OneFunction
+  OneFunction()
+
+Enums
+
+  enum OneEnum
+
   
-  Enums
-  
-enum OneEnum
+  
+
+  
+
+  Namespaces
+
+  
+  
+
+  Records
+
+  
+  
+
+  Functions
+
+
+  
+
+  OneFunction
+
+  
+
+  
+  
+
+  Enums
+
+
+  
+
+  OneEnum
+
+  
+
+  
+
   
-
+
+
+  clang-doc version unknown
+
 )raw";
 
   EXPECT_EQ(Expected, Actual.str());
@@ -162,80 +171,88 @@
 class r
 
 
-
-
-  
-
-  Members
-
-  
-  
-
-  Records
-
-  
-  
-
-  Functions
-
+test-project
+
+  
+  
+class r
+
+  Defined at line 
+  http://www.repository.com/dir/test.cpp#10;>10
+   of file 
+  http://www.repository.com/dir/test.cpp;>test.cpp
+
+
+  Inherits from 
+  F
+  , G
+
+Members
 
   
-
-  OneFunction
-
+private 
+int
+ X
   
 
-  
-  
-
-  Enums
-
+Records
 
   
-
-  OneEnum
-
+ChildStruct
   
 
-  
-
-
-  class r
-  
-Defined at line 
-http://www.repository.com/dir/test.cpp#10;>10
- of file 
-http://www.repository.com/dir/test.cpp;>test.cpp
-  
-  
-Inherits from 
-F
-, G
-  
-  Members
-  
-
-  private 
-  int
-   X
-
-  
-  Records
-  
-
-  ChildStruct
-
-  
-  Functions
-  
-OneFunction
-public OneFunction()
+Functions
+
+  OneFunction
+  public OneFunction()
+
+Enums
+
+  enum OneEnum
+
   
-  Enums
-  
-enum OneEnum
+  
+
+  
+
+  Members
+
+  
+  
+
+  Records
+
+  
+  
+
+  Functions
+
+
+  
+
+  OneFunction
+
+  
+
+  
+  
+
+  Enums
+
+
+  
+
+  OneEnum
+
+  
+
+  
+
   
-
+
+
+  clang-doc version unknown
+
 )raw";
 
   EXPECT_EQ(Expected, Actual.str());
@@ -270,17 +287,24 @@
 
 
 
-
-
-  f
-  
-float
- f(
-int
- P)
-  
-  Defined at line 10 of file dir/test.cpp
-
+test-project
+
+  
+  
+f
+
+  float
+   f(
+  int
+   P)
+
+Defined at line 10 of file dir/test.cpp
+  
+  
+
+
+  clang-doc version unknown
+
 )raw";
 
   EXPECT_EQ(Expected, Actual.str());
@@ -309,19 +333,26 @@
 
 
 
-
-
-  enum class e
-  
-X
-  
-  
-Defined at line 
-https://www.repository.com/test.cpp#10;>10
- of file 
-https://www.repository.com/test.cpp;>test.cpp
-  
-
+test-project
+
+  
+  
+enum class e
+
+  X
+
+
+  Defined at 

[PATCH] D66298: [clang-doc] Fix records in global namespace

2019-08-16 Thread Diego Astiazarán via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369123: [clang-doc] Fix records in global namespace 
(authored by DiegoAstiazaran, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66298?vs=215537=215618#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66298

Files:
  clang-tools-extra/trunk/clang-doc/Serialize.cpp
  clang-tools-extra/trunk/test/clang-doc/single-file-public.cpp
  clang-tools-extra/trunk/unittests/clang-doc/SerializeTest.cpp

Index: clang-tools-extra/trunk/unittests/clang-doc/SerializeTest.cpp
===
--- clang-tools-extra/trunk/unittests/clang-doc/SerializeTest.cpp
+++ clang-tools-extra/trunk/unittests/clang-doc/SerializeTest.cpp
@@ -137,7 +137,9 @@
10, /*Public=*/false, Infos);
 
   RecordInfo *E = InfoAsRecord(Infos[0].get());
-  RecordInfo ExpectedE(EmptySID, "E");
+  RecordInfo ExpectedE(EmptySID, /*Name=*/"E", /*Path=*/"GlobalNamespace");
+  ExpectedE.Namespace.emplace_back(EmptySID, "GlobalNamespace",
+   InfoType::IT_namespace);
   ExpectedE.TagType = TagTypeKind::TTK_Class;
   ExpectedE.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
   CheckRecordInfo(, E);
@@ -150,6 +152,8 @@
   EConstructor.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default);
   EConstructor.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
   EConstructor.Namespace.emplace_back(EmptySID, "E", InfoType::IT_record);
+  EConstructor.Namespace.emplace_back(EmptySID, "GlobalNamespace",
+  InfoType::IT_namespace);
   EConstructor.Access = AccessSpecifier::AS_public;
   EConstructor.IsMethod = true;
   ExpectedRecordWithEConstructor.ChildFunctions.emplace_back(
@@ -164,13 +168,17 @@
   Method.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default);
   Method.Loc.emplace_back(0, llvm::SmallString<16>{"test.cpp"});
   Method.Namespace.emplace_back(EmptySID, "E", InfoType::IT_record);
+  Method.Namespace.emplace_back(EmptySID, "GlobalNamespace",
+InfoType::IT_namespace);
   Method.Access = AccessSpecifier::AS_protected;
   Method.IsMethod = true;
   ExpectedRecordWithMethod.ChildFunctions.emplace_back(std::move(Method));
   CheckRecordInfo(, RecordWithMethod);
 
   RecordInfo *F = InfoAsRecord(Infos[4].get());
-  RecordInfo ExpectedF(EmptySID, "F");
+  RecordInfo ExpectedF(EmptySID, /*Name=*/"F", /*Path=*/"GlobalNamespace");
+  ExpectedF.Namespace.emplace_back(EmptySID, "GlobalNamespace",
+   InfoType::IT_namespace);
   ExpectedF.TagType = TagTypeKind::TTK_Struct;
   ExpectedF.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
   CheckRecordInfo(, F);
@@ -183,6 +191,8 @@
   TemplateMethod.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default);
   TemplateMethod.Loc.emplace_back(0, llvm::SmallString<16>{"test.cpp"});
   TemplateMethod.Namespace.emplace_back(EmptySID, "F", InfoType::IT_record);
+  TemplateMethod.Namespace.emplace_back(EmptySID, "GlobalNamespace",
+InfoType::IT_namespace);
   TemplateMethod.Access = AccessSpecifier::AS_public;
   TemplateMethod.IsMethod = true;
   ExpectedRecordWithTemplateMethod.ChildFunctions.emplace_back(
@@ -201,6 +211,8 @@
  llvm::SmallString<16>{"test.cpp"});
   SpecializedTemplateMethod.Namespace.emplace_back(EmptySID, "F",
InfoType::IT_record);
+  SpecializedTemplateMethod.Namespace.emplace_back(EmptySID, "GlobalNamespace",
+   InfoType::IT_namespace);
   SpecializedTemplateMethod.Access = AccessSpecifier::AS_public;
   SpecializedTemplateMethod.IsMethod = true;
   ExpectedTemplatedRecord.ChildFunctions.emplace_back(
@@ -208,7 +220,9 @@
   CheckRecordInfo(, TemplatedRecord);
 
   RecordInfo *G = InfoAsRecord(Infos[8].get());
-  RecordInfo ExpectedG(EmptySID, "G");
+  RecordInfo ExpectedG(EmptySID, /*Name=*/"G", /*Path=*/"GlobalNamespace");
+  ExpectedG.Namespace.emplace_back(EmptySID, "GlobalNamespace",
+   InfoType::IT_namespace);
   ExpectedG.TagType = TagTypeKind::TTK_Struct;
   ExpectedG.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
   ExpectedG.IsTypeDef = true;
@@ -248,7 +262,9 @@
   ExtractInfosFromCode("class E;", 2, /*Public=*/false, Infos);
 
   RecordInfo *E = InfoAsRecord(Infos[0].get());
-  RecordInfo ExpectedE(EmptySID, "E");
+  RecordInfo ExpectedE(EmptySID, /*Name=*/"E", /*Path=*/"GlobalNamespace");
+  ExpectedE.Namespace.emplace_back(EmptySID, "GlobalNamespace",
+   InfoType::IT_namespace);
   ExpectedE.TagType = TagTypeKind::TTK_Class;
   

[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-16 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl requested changes to this revision.
aprantl added inline comments.
This revision now requires changes to proceed.



Comment at: test/CodeGen/debug-info-no-location.cpp:4
+// CHECK-NEXT: ret void, !dbg !51
+// CHECK: !48 = distinct !DISubprogram(name: "`dynamic atexit destructor for 
'f'", scope: !3, file: !3, line: 16, type: !49, scopeLine: 16, spFlags: 
DISPFlagLocalToUnit | DISPFlagDefinition, unit: !27, retainedNodes: !29)
+// CHECK: !51 = !DILocation(line: 16, scope: !48)

Please don't hardcode metadata numbers in the tests, this is bound to break 
almost immediately.

It seems like this function is compiler-generated and thus should be marked as 
artificial?


Repository:
  rC Clang

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

https://reviews.llvm.org/D66328



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


[clang-tools-extra] r369123 - [clang-doc] Fix records in global namespace

2019-08-16 Thread Diego Astiazaran via cfe-commits
Author: diegoastiazaran
Date: Fri Aug 16 09:10:32 2019
New Revision: 369123

URL: http://llvm.org/viewvc/llvm-project?rev=369123=rev
Log:
[clang-doc] Fix records in global namespace

When a Record is declared in the global namespace, clang-doc serializes
it as a child of the global namespace, so the global namespace is now
one if its parent namespaces. This namespace was not being included in
the list of namespaces of the Info causing paths to be incorrect and the
index rendered incorrectly.
Affected tests have been fixed.

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

Modified:
clang-tools-extra/trunk/clang-doc/Serialize.cpp
clang-tools-extra/trunk/test/clang-doc/single-file-public.cpp
clang-tools-extra/trunk/unittests/clang-doc/SerializeTest.cpp

Modified: clang-tools-extra/trunk/clang-doc/Serialize.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/Serialize.cpp?rev=369123=369122=369123=diff
==
--- clang-tools-extra/trunk/clang-doc/Serialize.cpp (original)
+++ clang-tools-extra/trunk/clang-doc/Serialize.cpp Fri Aug 16 09:10:32 2019
@@ -378,6 +378,14 @@ populateParentNamespaces(llvm::SmallVect
   Namespaces.emplace_back(getUSRForDecl(N), N->getNameAsString(),
   InfoType::IT_enum);
   }
+  // The global namespace should be added to the list of namespaces if the decl
+  // corresponds to a Record and if it doesn't have any namespace (because this
+  // means it's in the global namespace). Also if its outermost namespace is a
+  // record because that record matches the previous condition mentioned.
+  if ((Namespaces.empty() && dyn_cast(D)) ||
+  (!Namespaces.empty() && Namespaces.back().RefType == 
InfoType::IT_record))
+Namespaces.emplace_back(SymbolID(), "GlobalNamespace",
+InfoType::IT_namespace);
 }
 
 template 
@@ -528,16 +536,6 @@ emitInfo(const RecordDecl *D, const Full
   }
   I->Path = getInfoRelativePath(I->Namespace);
 
-  if (I->Namespace.empty()) {
-auto ParentI = std::make_unique();
-ParentI->USR = SymbolID();
-ParentI->ChildRecords.emplace_back(I->USR, I->Name, InfoType::IT_record,
-   getInfoRelativePath(I->Namespace));
-ParentI->Path = getInfoRelativePath(ParentI->Namespace);
-return {std::unique_ptr{std::move(I)},
-std::unique_ptr{std::move(ParentI)}};
-  }
-
   switch (I->Namespace[0].RefType) {
   case InfoType::IT_namespace: {
 auto ParentI = std::make_unique();
@@ -611,8 +609,6 @@ emitInfo(const CXXMethodDecl *D, const F
   // Wrap in enclosing scope
   auto ParentI = std::make_unique();
   ParentI->USR = ParentUSR;
-  if (Func.Namespace.empty())
-ParentI->Path = getInfoRelativePath(ParentI->Namespace);
   ParentI->ChildFunctions.emplace_back(std::move(Func));
   // Info is wrapped in its parent scope so it's returned in the second 
position
   return {nullptr, std::unique_ptr{std::move(ParentI)}};

Modified: clang-tools-extra/trunk/test/clang-doc/single-file-public.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-doc/single-file-public.cpp?rev=369123=369122=369123=diff
==
--- clang-tools-extra/trunk/test/clang-doc/single-file-public.cpp (original)
+++ clang-tools-extra/trunk/test/clang-doc/single-file-public.cpp Fri Aug 16 
09:10:32 2019
@@ -3,7 +3,7 @@
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: clang-doc --doxygen --public --executor=standalone -p %t %t/test.cpp 
-output=%t/docs
-// RUN: cat %t/docs/Record.yaml | FileCheck %s --check-prefix=CHECK
+// RUN: cat %t/docs/GlobalNamespace/Record.yaml | FileCheck %s 
--check-prefix=CHECK
 // RUN: rm -rf %t
 
 class Record {
@@ -21,8 +21,12 @@ void Record::function_public() {}
 // CHECK: ---
 // CHECK-NEXT: USR: 
'{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
 // CHECK-NEXT: Name:'Record'
+// CHECK-NEXT: Path:'GlobalNamespace'
+// CHECK-NEXT: Namespace:
+// CHECK-NEXT:   - Type: Namespace
+// CHECK-NEXT: Name: 'GlobalNamespace'
 // CHECK-NEXT: DefLocation:
-// CHECK-NEXT:   LineNumber:  [[@LINE-16]]
+// CHECK-NEXT:   LineNumber:  [[@LINE-20]]
 // CHECK-NEXT:   Filename:'{{.*}}'
 // CHECK-NEXT: TagType: Class
 // CHECK-NEXT: ChildFunctions:
@@ -32,11 +36,13 @@ void Record::function_public() {}
 // CHECK-NEXT:   - Type:Record
 // CHECK-NEXT: Name:'Record'
 // CHECK-NEXT: USR: 

[PATCH] D65526: [Clangd] Initial prototype version of ExtractFunction

2019-08-16 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah updated this revision to Diff 215615.
SureYeaah added a comment.

Fixed semicolon bug


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65526

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -599,6 +599,117 @@
 R"cpp(const char * x = "test")cpp");
 }
 
+TWEAK_TEST(ExtractFunction);
+TEST_F(ExtractFunctionTest, PrepareFunctionTest) {
+  Header = R"cpp(
+#define F(BODY) void FFF() { BODY }
+  )cpp";
+  Context = Function;
+  EXPECT_AVAILABLE(R"cpp(
+[[int sum = 0;
+for(;;)
+  sum++;]]
+for(int i = 0; i < 5; i++) {
+  sum += i;
+}
+  )cpp");
+  EXPECT_AVAILABLE(R"cpp([[int x;]])cpp");
+  // TODO: Add tests for macros after selectionTree works properly for macros.
+  // EXPECT_AVAILABLE(R"cpp( F (int x = 0; [[x = 1;]])cpp");
+  // FIXME: This should be unavailable since partially selected but
+  // selectionTree doesn't always work correctly for VarDecls.
+  //EXPECT_UNAVAILABLE(R"cpp(int [[x = 0]];)cpp");
+  EXPECT_UNAVAILABLE(R"cpp(
+int sum = 0;
+for(;;)
+  [[sum++;
+sum++;]]
+  )cpp");
+  // Expressions aren't extracted.
+  EXPECT_UNAVAILABLE(R"cpp(int x = 0; [[x++;]])cpp");
+  // FIXME: ExtractFunction should be unavailable inside loop construct
+  // initalizer/condition.
+  // EXPECT_UNAVAILABLE(R"cpp( for([[int i = 0; i < 5;]] i++) )cpp");
+}
+
+TEST_F(ExtractFunctionTest, PrepareMethodTest) {
+  EXPECT_UNAVAILABLE(R"cpp(
+class T {
+  void f() {
+[[int x;]]
+  }
+};
+  )cpp");
+}
+
+TEST_F(ExtractFunctionTest, ApplyTest) {
+  // We can extract from templated functions as long as no reference in the
+  // extraction depends on the template.
+  // Checks const qualifier and extraction parameters.
+  Header = R"cpp(
+  )cpp";
+  EXPECT_EQ(apply(
+R"cpp(
+struct FOO {
+  int x;
+};
+template
+void f(int a) {
+  int b = N; T t; const int c; FOO foo;
+  int *ptr = 
+  [[a += foo.x;
+  b = c; 
+  *ptr++;
+  for(;;)
+int d = 5 /* check if comment is extracted */ ;]]
+})cpp"),
+R"cpp(
+struct FOO {
+  int x;
+};
+void extracted(int , int , const int , struct FOO , int * ) {
+a += foo.x;
+  b = c; 
+  *ptr++;
+  for(;;)
+int d = 5 /* check if comment is extracted */ ;
+}
+template
+void f(int a) {
+  int b = N; T t; const int c; FOO foo;
+  int *ptr = 
+  extracted(a, b, c, foo, ptr);
+})cpp");
+  auto ShouldSucceed = [&](llvm::StringRef Code) {
+EXPECT_THAT(apply(Code), HasSubstr("extracted"));
+  };
+  auto ShouldFail = [&](llvm::StringRef Code) {
+EXPECT_THAT(apply(Code), StartsWith("fail:"));
+  };
+  // Ensure the last break isn't included in the Source since the end of source
+  // and beginning of break are adjacent.
+  ShouldSucceed(R"cpp(
+void f() {
+  for(;;) {
+[[{}]]break;
+  }
+}
+  )cpp");
+  // Don't extract because needs hoisting.
+  ShouldFail(R"cpp( void f() { [[int a = 5;]] a++;})cpp");
+  // Don't extract parameters that depend on template.
+  ShouldFail(R"cpp( template void f() { [[int a = N;]] })cpp");
+  ShouldFail(R"cpp( template void f() { [[T t;]] })cpp");
+  // Don't extract return
+  ShouldFail(R"cpp( int f() { int a = 5; [[return a;]]})cpp");
+  // Don't extract break and continue.
+  // FIXME: We should be able to extract this.
+  ShouldFail(R"cpp( int f() { [[for(;;) break;]]})cpp");
+  ShouldFail(R"cpp( int f() { for(;;) [[continue;]]})cpp");
+  // Don't extract when we need to make a function as a parameter.
+  ShouldFail(R"cpp( void f() { [[int a; f();]] } )cpp");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -0,0 +1,546 @@
+//===--- ExtractFunction.cpp -*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "ClangdUnit.h"
+#include "Logger.h"
+#include "Selection.h"
+#include "SourceCode.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Stmt.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"

[PATCH] D65065: [clang-tidy] Possibility of displaying duplicate warnings

2019-08-16 Thread Tibor Brunner via Phabricator via cfe-commits
bruntib added a comment.

Thank you for the valuable comments and the review!
I'm just planning to register to the bug tracker, because it is getting more 
relevant due to some other contributions as well.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D65065



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


[PATCH] D66349: [clangd] Fix one testcase in XRefsTests.

2019-08-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:389
 llvm::sort(References, [](const Reference , const Reference ) {
-  return std::tie(L.Loc, L.CanonicalTarget, L.Role) <
- std::tie(R.Loc, R.CanonicalTarget, R.Role);
+  return L.Loc < R.Loc;
 });

What are the elements `References` for the problematic case?

If we have duplicate elements, then `sort()` would now give us one of the 
items. Which exact `Decl` we're gonna end up seeing is not well-defined, i.e. 
it's non-deterministic.



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:2079
   ExpectedLocations.push_back(RangeIs(R));
+ASSERT_TRUE(!ExpectedLocations.empty()) << "Testcase must provide ranges!";
 EXPECT_THAT(findReferences(AST, T.point(), 0),

NIT: use `ASSERT_THAT(ExpectedLocations, Not(IsEmpty()))` for more detailed 
output in case of assertion failures.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66349



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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-08-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D64943#1633170 , @lebedev.ri wrote:

> In D64943#1633164 , @ABataev wrote:
>
> > In D64943#1619958 , @sdmitriev 
> > wrote:
> >
> > > As I understand ‘atexit’ solution would be target dependent 
> > > (‘__cxa_atexit’ on Linux and ‘atexit’ on Windows) whereas 
> > > @llvm.global_ctors/dtors variables offer similar and platform neutral 
> > > functionality 
> > > (http://llvm.org/docs/LangRef.html#the-llvm-global-ctors-global-variable).
> > >  Why do you think that ‘atexit’ is a better choice?
> >
> >
> > Because it does not work on Windows, better to have portable solution, if 
> > possible.
>
>
> Is there a bug # ?


@vzakhari?


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

https://reviews.llvm.org/D64943



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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-08-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D64943#1633164 , @ABataev wrote:

> In D64943#1619958 , @sdmitriev wrote:
>
> > As I understand ‘atexit’ solution would be target dependent (‘__cxa_atexit’ 
> > on Linux and ‘atexit’ on Windows) whereas @llvm.global_ctors/dtors 
> > variables offer similar and platform neutral functionality 
> > (http://llvm.org/docs/LangRef.html#the-llvm-global-ctors-global-variable). 
> > Why do you think that ‘atexit’ is a better choice?
>
>
> Because it does not work on Windows, better to have portable solution, if 
> possible.


Is there a bug # ?


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

https://reviews.llvm.org/D64943



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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-08-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D64943#1619958 , @sdmitriev wrote:

> As I understand ‘atexit’ solution would be target dependent (‘__cxa_atexit’ 
> on Linux and ‘atexit’ on Windows) whereas @llvm.global_ctors/dtors variables 
> offer similar and platform neutral functionality 
> (http://llvm.org/docs/LangRef.html#the-llvm-global-ctors-global-variable). 
> Why do you think that ‘atexit’ is a better choice?


Because it does not work on Windows, better to have portable solution, if 
possible.




Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:72
+private:
+  IntegerType *getSizeTTy() {
+switch (M.getDataLayout().getPointerTypeSize(Type::getInt8PtrTy(C))) {

1. Markt it `const`.
2. This still is not the best solution, since `size_t` not necessarily has the 
pointer size. I don't know if there is a better solution. @hfinkel? If this is 
the best, why not just to use `getIntPtrType(C)`?



Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:135
+
+  // Creates binary descriptor for the given device images. Binary descriptor 
is
+  // an object that is passed to the offloading runtime at program startup and

Use `\\\` style for comments here



Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:171
+  // Global variable that represents BinDesc is returned.
+  GlobalVariable *createBinDesc(const SmallVectorImpl ) {
+// Create external begin/end symbols for the offload entries table.

Use `ArrayRef` instead of `const SmallVectorImpl &`



Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:330
+  BufferRefs.reserve(Inputs.size());
+  for (const auto  : Inputs) {
+auto BufOrErr = MemoryBuffer::getFileOrSTDIN(File);

Use `std:string` instead of `auto`



Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:331
+  for (const auto  : Inputs) {
+auto BufOrErr = MemoryBuffer::getFileOrSTDIN(File);
+if (!BufOrErr) {

Also, better to specify type expplicitly.


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

https://reviews.llvm.org/D64943



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


[PATCH] D57450: [RISCV] Set MaxAtomicInlineWidth and MaxAtomicPromoteWidth for RV32/RV64 targets with atomics

2019-08-16 Thread Sam Elliott via Phabricator via cfe-commits
lenary planned changes to this revision.
lenary added a comment.

Upon further thought, I realise that `MaxAtomicPromoteWidth` should be set to 
128 regardless of whether a target `HasA`. I will be updating the patch with 
the new width and conditions early next week.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57450



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


[PATCH] D66350: Rudimentary support for Doxygen \retval command

2019-08-16 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg created this revision.
sberg added a reviewer: gribozavr.
sberg added a project: clang.
Herald added a subscriber: cfe-commits.

...so that at least a preceding \param etc. that lacks a description gets a 
-Wdocumentation warning (instead of erroneously treating the \retval ... text 
as its paragraph).


Repository:
  rC Clang

https://reviews.llvm.org/D66350

Files:
  clang/include/clang/AST/CommentCommands.td
  clang/test/Sema/warn-documentation.cpp


Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -288,6 +288,11 @@
 /// \param x2 Ccc.
 int test_param22(int x1, int x2, int x3);
 
+// expected-warning@+1 {{empty paragraph passed to '\param' command}}
+/// \param a
+/// \retval 0 Blah blah.
+int test_param23(int a);
+
 //===---
 // Test that we treat typedefs to some non-function types as functions for the
 // purposes of documentation comment parsing.
Index: clang/include/clang/AST/CommentCommands.td
===
--- clang/include/clang/AST/CommentCommands.td
+++ clang/include/clang/AST/CommentCommands.td
@@ -139,6 +139,7 @@
 def Pre: BlockCommand<"pre">;
 def Remark : BlockCommand<"remark">;
 def Remarks: BlockCommand<"remarks">;
+def Retval : BlockCommand<"retval">;
 def Sa : BlockCommand<"sa">;
 def See: BlockCommand<"see">;
 def Since  : BlockCommand<"since">;


Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -288,6 +288,11 @@
 /// \param x2 Ccc.
 int test_param22(int x1, int x2, int x3);
 
+// expected-warning@+1 {{empty paragraph passed to '\param' command}}
+/// \param a
+/// \retval 0 Blah blah.
+int test_param23(int a);
+
 //===---
 // Test that we treat typedefs to some non-function types as functions for the
 // purposes of documentation comment parsing.
Index: clang/include/clang/AST/CommentCommands.td
===
--- clang/include/clang/AST/CommentCommands.td
+++ clang/include/clang/AST/CommentCommands.td
@@ -139,6 +139,7 @@
 def Pre: BlockCommand<"pre">;
 def Remark : BlockCommand<"remark">;
 def Remarks: BlockCommand<"remarks">;
+def Retval : BlockCommand<"retval">;
 def Sa : BlockCommand<"sa">;
 def See: BlockCommand<"see">;
 def Since  : BlockCommand<"since">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66349: [clangd] Fix one testcase in XRefsTests.

2019-08-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

The test didn't test anything actually -- it used "[]" as annotation which 
should be
"[[]]".

This patch also fixes a bug in XRef where we may return duplicated refs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66349

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -2037,35 +2037,36 @@
 TEST(FindReferences, ExplicitSymbols) {
   const char *Tests[] = {
   R"cpp(
-  struct Foo { Foo* [self]() const; };
+  struct Foo { Foo* [[self]]() const; };
   void f() {
-if (Foo* T = foo.[^self]()) {} // Foo member call expr.
+Foo foo;
+if (Foo* T = foo.[[^self]]()) {} // Foo member call expr.
   }
   )cpp",
 
   R"cpp(
   struct Foo { Foo(int); };
   Foo f() {
-int [b];
-return [^b]; // Foo constructor expr.
+int [[b]];
+return [[^b]]; // Foo constructor expr.
   }
   )cpp",
 
   R"cpp(
   struct Foo {};
   void g(Foo);
-  Foo [f]();
+  Foo [[f]]();
   void call() {
-g([^f]());  // Foo constructor expr.
+g([[^f]]());  // Foo constructor expr.
   }
   )cpp",
 
   R"cpp(
-  void [foo](int);
-  void [foo](double);
+  void [[foo]](int);
+  void [[foo]](double);
 
   namespace ns {
-  using ::[fo^o];
+  using ::[[fo^o]];
   }
   )cpp",
   };
@@ -2075,6 +2076,7 @@
 std::vector> ExpectedLocations;
 for (const auto  : T.ranges())
   ExpectedLocations.push_back(RangeIs(R));
+ASSERT_TRUE(!ExpectedLocations.empty()) << "Testcase must provide ranges!";
 EXPECT_THAT(findReferences(AST, T.point(), 0),
 ElementsAreArray(ExpectedLocations))
 << Test;
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -383,18 +383,17 @@
   }
 
   std::vector take() && {
+// We only use the Loc to do the comparsion as a location can refer
+// to different declarations, e.g. usingDecl refers to overload functions.
 llvm::sort(References, [](const Reference , const Reference ) {
-  return std::tie(L.Loc, L.CanonicalTarget, L.Role) <
- std::tie(R.Loc, R.CanonicalTarget, R.Role);
+  return L.Loc < R.Loc;
 });
 // We sometimes see duplicates when parts of the AST get traversed twice.
-References.erase(
-std::unique(References.begin(), References.end(),
-[](const Reference , const Reference ) {
-  return std::tie(L.CanonicalTarget, L.Loc, L.Role) ==
- std::tie(R.CanonicalTarget, R.Loc, R.Role);
-}),
-References.end());
+References.erase(std::unique(References.begin(), References.end(),
+ [](const Reference , const Reference ) {
+   return L.Loc == R.Loc;
+ }),
+ References.end());
 return std::move(References);
   }
 


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -2037,35 +2037,36 @@
 TEST(FindReferences, ExplicitSymbols) {
   const char *Tests[] = {
   R"cpp(
-  struct Foo { Foo* [self]() const; };
+  struct Foo { Foo* [[self]]() const; };
   void f() {
-if (Foo* T = foo.[^self]()) {} // Foo member call expr.
+Foo foo;
+if (Foo* T = foo.[[^self]]()) {} // Foo member call expr.
   }
   )cpp",
 
   R"cpp(
   struct Foo { Foo(int); };
   Foo f() {
-int [b];
-return [^b]; // Foo constructor expr.
+int [[b]];
+return [[^b]]; // Foo constructor expr.
   }
   )cpp",
 
   R"cpp(
   struct Foo {};
   void g(Foo);
-  Foo [f]();
+  Foo [[f]]();
   void call() {
-g([^f]());  // Foo constructor expr.
+g([[^f]]());  // Foo constructor expr.
   }
   )cpp",
 
   R"cpp(
-  void [foo](int);
-  void [foo](double);
+  void [[foo]](int);
+  void [[foo]](double);
 
   namespace ns {
-  using ::[fo^o];
+  using ::[[fo^o]];
   }
   )cpp",
   };
@@ -2075,6 +2076,7 @@
 std::vector> ExpectedLocations;
 for (const auto  : T.ranges())
   ExpectedLocations.push_back(RangeIs(R));
+

[PATCH] D66294: [Docs][OpenCL] Release 9.0 notes for OpenCL

2019-08-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 215598.

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

https://reviews.llvm.org/D66294

Files:
  docs/ReleaseNotes.rst

Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -46,6 +46,8 @@
 Major New Features
 --
 
+- Experimental support for :ref:`C++ for OpenCL ` has been
+  added.
 - ...
 
 Improvements to Clang's diagnostics
@@ -133,6 +135,14 @@
 C++ Language Changes in Clang
 -
 
+- Support for the address space attribute in various C++ features was improved,
+  refer to :ref:`C++ for OpenCL ` for more details. The following
+  features deviated from OpenCL:
+
+  (1) Address spaces as method qualifiers are not accepted yet;
+
+  (2) There is no address space deduction.
+
 - ...
 
 C++1z Feature Support
@@ -152,10 +162,86 @@
   // clang used to encode this as "^{NSArray=#}" instead of "@".
   const char *s0 = @encode(MyArray *);
 
-OpenCL C Language Changes in Clang
---
+OpenCL Kernel Language Changes in Clang
+---
 
-...
+OpenCL C
+
+
+- Enabled use of variadic macro as a Clang extension.
+
+- Added initial support for implicitly including OpenCL builtin
+  fuctions using efficient trie lookup generated by TableGen.
+  A corresponding frontend-only flag ``-fdeclare-opencl-builtins``
+  has been added to enable trie during parsing.
+
+- Refactored header file to be used for common parts between
+  regular header added using ``-finclude-default-header`` and trie
+  based declarations added using ``-fdeclare-opencl-builtins``.
+
+- Improved string formatting diagnostics in printf for vector types.
+
+- Simplified the internal representation of blocks, including their
+  generation in IR. Furthermore, indirect calls to block function
+  has been changed to direct function calls.
+
+- Added diagnostics for conversions of nested pointers with
+  different address spaces.
+
+- Added ``cl_arm_integer_dot_product`` extension.
+
+- Fixed global samplers in OpenCL v2.0.
+
+- Improved math builtin functions with parameters of type ``long
+  long`` for x86.
+
+.. _openclcpp:
+
+C++ for OpenCL
+^^
+
+Experimental support for C++17 features in OpenCL has been added
+and backwards compatibility with OpenCL C v2.0 was enabled.
+The documentation has been added for supported language features
+into :doc:`LanguageExtensions` and :doc:`UsersManual`.
+
+Implemented features are:
+- Address space behavior is improved in majority of C++ features:
+
+  - Templates parameters and arguments
+
+  - Reference types;
+
+  - Type deduction;
+
+  - Objects and member functions, including special member
+functions;
+
+  - Builtin operators;
+
+  - Method qualifiers now include address space;
+
+  - Address space deduction has been extended for C++ use cases;
+
+  - Improved overload ranking rules.
+
+  - All standard cast operators now prevent converting address
+spaces (except for conversions allowed implicitly). They
+can still be cast using C-style cast.
+
+- Vector types as in OpenCL C, including compound vector
+  initialization.
+
+- OpenCL-specific types: images, samplers, events, pipes, are
+  accepted with exception of blocks.
+
+- OpenCL standard header in Clang can be compiled in C++ mode.
+
+- Global constructors can be invoked from the host side using
+  a specific, compiler-generated kernel.
+
+- Overloads with generic address space are added to all atomic
+  builtin functions, including the ones prior to OpenCL v2.0.
 
 ABI Changes in Clang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64078: [ASTImporter] Fix structural ineq of lambdas with different sloc

2019-08-16 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D64078#1572675 , @a_sidorin wrote:

> Hi Gabor,
>  it is a nice design question if source locations can participate in 
> structural match or not. The comparison tells us that the same code written 
> in different files is not structurally equivalent and I cannot agree with it. 
> They can be not the same, but their structure is the same. The question is: 
> why do we get to this comparison? Do we find a non-equivalent decl by lookup? 
> I guess there can be another way to resolve this issue, and I'll be happy to 
> help if you share what is the problem behind the patch.


Hey Alexei, thanks for looking into this. I agree, that those lambdas are 
actually "structurally" equivalent even if they are defined in different 
locations...
But still we have to differentiate them somehow.
Consider this code:

  void f() {
auto L0 = [](){};
auto L1 = [](){};
  }

First we import `L0` then `L1`. Currently we end up having only one 
CXXRecordDecl for the two different lambdas. And that is a problem if the body 
of their op() is different.
This happens because when we import `L1` then lookup finds the existing `L0` 
and since they are structurally equivalent we just map the imported L0 to be 
the counterpart of L1 .

I tried to use `getLambdaManglingNumber()` as you suggested in 
https://reviews.llvm.org/D64075 and that does solve this particular case, but 
cannot solve to other issue we have in the test case 
`LambdasInFunctionParamsAreDifferentiated`:

  template 
  void f(F0 L0 = [](){}, F1 L1 = [](){}) {}

Here after importing L0, L1  is mapped to L0 again.

I tried an alternative solution, which is to disable lookup completely if the 
decl in the "from" context is a lambda. That passed all tests.
However, that could have other problems: what if the lambda is defined in a 
header file and included in several TUs? I think we'd have as many duplicates 
as many includes we have. I think we could live with that, because the lambda 
classes are TU local anyway, we cannot just access them from another TU.
I have created another patch for that solution: https://reviews.llvm.org/D66348


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64078



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


[PATCH] D66348: [ASTImporter] Do not look up lambda classes

2019-08-16 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added a reviewer: a_sidorin.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp, rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

Consider this code:

  void f() {
auto L0 = [](){};
auto L1 = [](){};
  }

First we import `L0` then `L1`. Currently we end up having only one
CXXRecordDecl for the two different lambdas. And that is a problem if
the body of their op() is different. This happens because when we import
`L1` then lookup finds the existing `L0` and since they are structurally
equivalent we just map the imported L0 to be the counterpart of L1 
.

We have the same problem in this case:

  template 
  void f(F0 L0 = [](){}, F1 L1 = [](){}) {}

In StructuralEquivalenceContext we could distinquish lambdas only by
their source location in these cases. But we the lambdas are actually
structrually equivalent they differn only by the source location.

Thus, the  solution is to disable lookup completely if the decl in
the "from" context is a lambda.
However, that could have other problems: what if the lambda is defined
in a header file and included in several TUs? I think we'd have as many
duplicates as many includes we have. I think we could live with that,
because the lambda classes are TU local anyway, we cannot just access
them from another TU.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66348

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


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5366,6 +5366,70 @@
 ::testing::Values(ArgVector{"-target",
 "aarch64-linux-gnu"}), );
 
+TEST_P(ASTImporterOptionSpecificTestBase, LambdasAreDifferentiated) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  void f() {
+auto L0 = [](){};
+auto L1 = [](){};
+  }
+  )",
+  Lang_CXX11, "input0.cc");
+  auto Pattern = lambdaExpr();
+  CXXRecordDecl *FromL0 =
+  FirstDeclMatcher().match(FromTU, Pattern)->getLambdaClass();
+  CXXRecordDecl *FromL1 =
+  LastDeclMatcher().match(FromTU, Pattern)->getLambdaClass();
+  ASSERT_NE(FromL0, FromL1);
+
+  CXXRecordDecl *ToL0 = Import(FromL0, Lang_CXX11);
+  CXXRecordDecl *ToL1 = Import(FromL1, Lang_CXX11);
+  EXPECT_NE(ToL0, ToL1);
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase,
+   LambdasInFunctionParamsAreDifferentiated) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  template 
+  void f(F0 L0 = [](){}, F1 L1 = [](){}) {}
+  )",
+  Lang_CXX11, "input0.cc");
+  auto Pattern = cxxRecordDecl(isLambda());
+  CXXRecordDecl *FromL0 =
+  FirstDeclMatcher().match(FromTU, Pattern);
+  CXXRecordDecl *FromL1 =
+  LastDeclMatcher().match(FromTU, Pattern);
+  ASSERT_NE(FromL0, FromL1);
+
+  CXXRecordDecl *ToL0 = Import(FromL0, Lang_CXX11);
+  CXXRecordDecl *ToL1 = Import(FromL1, Lang_CXX11);
+  ASSERT_NE(ToL0, ToL1);
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase,
+   LambdasInFunctionParamsAreDifferentiatedWhenMacroIsUsed) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  #define LAMBDA [](){}
+  template 
+  void f(F0 L0 = LAMBDA, F1 L1 = LAMBDA) {}
+  )",
+  Lang_CXX11, "input0.cc");
+  auto Pattern = cxxRecordDecl(isLambda());
+  CXXRecordDecl *FromL0 =
+  FirstDeclMatcher().match(FromTU, Pattern);
+  CXXRecordDecl *FromL1 =
+  LastDeclMatcher().match(FromTU, Pattern);
+  ASSERT_NE(FromL0, FromL1);
+
+  Import(FromL0, Lang_CXX11);
+  Import(FromL1, Lang_CXX11);
+  CXXRecordDecl *ToL0 = Import(FromL0, Lang_CXX11);
+  CXXRecordDecl *ToL1 = Import(FromL1, Lang_CXX11);
+  ASSERT_NE(ToL0, ToL1);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -2627,7 +2627,7 @@
 
   // We may already have a record of the same name; try to find and match it.
   RecordDecl *PrevDecl = nullptr;
-  if (!DC->isFunctionOrMethod()) {
+  if (!DC->isFunctionOrMethod() && !D->isLambda()) {
 SmallVector ConflictingDecls;
 auto FoundDecls =
 Importer.findDeclsInToCtx(DC, SearchName);


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5366,6 +5366,70 @@
 ::testing::Values(ArgVector{"-target",
 "aarch64-linux-gnu"}), );
 
+TEST_P(ASTImporterOptionSpecificTestBase, LambdasAreDifferentiated) {
+  

[PATCH] D63423: [Diagnostics] Diagnose misused xor as pow

2019-08-16 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 215592.
xbolva00 added a comment.

Fixed nits.


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

https://reviews.llvm.org/D63423

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/warn-xor-as-pow.cpp

Index: test/SemaCXX/warn-xor-as-pow.cpp
===
--- test/SemaCXX/warn-xor-as-pow.cpp
+++ test/SemaCXX/warn-xor-as-pow.cpp
@@ -0,0 +1,105 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wxor-used-as-pow %s
+// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wxor-used-as-pow %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+#define FOOBAR(x, y) (x * y)
+#define XOR(x, y) (x ^ y)
+#define TWO 2
+#define TEN 10
+#define TWO_ULL 2ULL
+#define EPSILON 10 ^ -300
+
+#define flexor 7
+
+#ifdef __cplusplus
+constexpr long long operator"" _xor(unsigned long long v) { return v; }
+
+constexpr long long operator"" _0b(unsigned long long v) { return v; }
+constexpr long long operator"" _0X(unsigned long long v) { return v; }
+#else
+#define xor^ // iso646.h
+#endif
+
+void test(unsigned a, unsigned b) {
+  unsigned res;
+  res = a ^ 5;
+  res = 2 ^ b;
+  res = a ^ b;
+  res = 2 ^ -1;
+  res = 2 ^ 0; // expected-warning {{result of '2 ^ 0' is 2; did you mean '1 << 0' (1)?}}
+   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1"
+   // expected-note@-2 {{replace expression with '0x2 ^ 0' to silence this warning}}
+  res = 2 ^ 1; // expected-warning {{result of '2 ^ 1' is 3; did you mean '1 << 1' (2)?}}
+   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 1"
+   // expected-note@-2 {{replace expression with '0x2 ^ 1' to silence this warning}}
+  res = 2 ^ 2; // expected-warning {{result of '2 ^ 2' is 0; did you mean '1 << 2' (4)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 2"
+  // expected-note@-2 {{replace expression with '0x2 ^ 2' to silence this warning}}
+  res = 2 ^ 8; // expected-warning {{result of '2 ^ 8' is 10; did you mean '1 << 8' (256)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"1 << 8"
+  // expected-note@-2 {{replace expression with '0x2 ^ 8' to silence this warning}}
+  res = TWO ^ 8; // expected-warning {{result of 'TWO ^ 8' is 10; did you mean '1 << 8' (256)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1 << 8"
+  // expected-note@-2 {{replace expression with '0x2 ^ 8' to silence this warning}}
+  res = 2 ^ 16; // expected-warning {{result of '2 ^ 16' is 18; did you mean '1 << 16' (65536)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1 << 16"
+  // expected-note@-2 {{replace expression with '0x2 ^ 16' to silence this warning}}
+  res = 2 ^ TEN; // expected-warning {{result of '2 ^ TEN' is 8; did you mean '1 << TEN' (1024)?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1 << TEN"
+  // expected-note@-2 {{replace expression with '0x2 ^ TEN' to silence this warning}}
+  res = 0x2 ^ 16;
+  res = 2 xor 16;
+
+  res = 2 ^ 0x4;
+  res = 2 ^ 04;
+  res = 0x2 ^ 10;
+  res = 0X2 ^ 10;
+  res = 02 ^ 10;
+  res = FOOBAR(2, 16);
+  res = 0b10 ^ 16;
+  res = 0B10 ^ 16;
+  res = 2 ^ 0b100;
+  res = XOR(2, 16);
+  unsigned char two = 2;
+  res = two ^ 16;
+  res = TWO_ULL ^ 16;
+  res = 2 ^ 32; // expected-warning {{result of '2 ^ 32' is 34; did you mean '1LL << 32'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1LL << 32"
+  // expected-note@-2 {{replace expression with '0x2 ^ 32' to silence this warning}}
+  res = 2 ^ 64;
+
+  res = EPSILON;
+  res = 10 ^ 0; // expected-warning {{result of '10 ^ 0' is 10; did you mean '1e0'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1e0"
+  // expected-note@-2 {{replace expression with '0xA ^ 0' to silence this warning}}
+  res = 10 ^ 1; // expected-warning {{result of '10 ^ 1' is 11; did you mean '1e1'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1e1"
+  // expected-note@-2 {{replace expression with '0xA ^ 1' to silence this warning}}
+  res = 10 ^ 2; // expected-warning {{result of '10 ^ 2' is 8; did you mean '1e2'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1e2"
+  // expected-note@-2 {{replace expression with '0xA ^ 2' to silence this warning}}
+  res = 10 ^ 4; // expected-warning {{result of '10 ^ 4' is 14; did you mean '1e4'?}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:15}:"1e4"
+  // expected-note@-2 {{replace expression with '0xA ^ 4' to silence this warning}}
+  res = 10 ^ 10; // expected-warning {{result of '10 ^ 10' is 0; did you mean '1e10'?}}
+  // CHECK: 

[PATCH] D66294: [Docs][OpenCL] Release 9.0 notes for OpenCL

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



Comment at: docs/ReleaseNotes.rst:173
+
+- Added initial support for implicitly including OpenCL BIFs using
+  efficient trie lookup generated by TableGen. A corresponding

svenvh wrote:
> mantognini wrote:
> > If the BIF acronym wasn't introduced before, it should be replaced with 
> > "builtin functions". It seems we don't have more file context in this 
> > review so I cannot tell.
> BIFs -> built-in functions
builtin is a more common spelling in Clang docs.



Comment at: docs/ReleaseNotes.rst:176
+  frontend only flag ``-fadd-opencl-builtins`` has been added to
+  enable trie during parsing.
+

svenvh wrote:
> The option does not only "enable a trie" during parsing.  I'd suggest to just 
> drop "to enable trie during parsing".
We don't have to describe all details here btw, but just the main ones. I would 
like to say what the flag is used for explicitly rather than leaving the room 
for interpretations.

Btw, would it make sense to document this flag in UserManual? 
https://clang.llvm.org/docs/UsersManual.html#opencl-specific-options



Comment at: docs/ReleaseNotes.rst:220
+
+  - Method qualifiers are allowed with address spaces;
+

mantognini wrote:
> Maybe something along these line would be better?
> 
> Methods can be overloaded for different address spaces.
> 
> Or, if you want to emphasis the qualifiers,
> 
> Method qualifiers now include address space.
I prefer the second one, as the first one can be read as parameter address 
space.



Comment at: docs/ReleaseNotes.rst:222
+
+  - Address space deduction has been extended for C++ use cases;
+

mantognini wrote:
> This seems to be already included in previous point.
Do you mean method qualifiers? I don't see the connection?



Comment at: docs/ReleaseNotes.rst:232-233
+
+- OpenCL specific type: images, samplers, events, pipes, except
+  for blocks.
+

mantognini wrote:
> I would suggest this:
> 
> OpenCL-specific types, except within blocks: [...]
I mean  with the exception of blocks here.


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

https://reviews.llvm.org/D66294



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


[PATCH] D66294: [Docs][OpenCL] Release 9.0 notes for OpenCL

2019-08-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 215591.
Anastasia marked 5 inline comments as done.

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

https://reviews.llvm.org/D66294

Files:
  docs/ReleaseNotes.rst

Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -46,6 +46,8 @@
 Major New Features
 --
 
+- Experimental support for :ref:`C++ for OpenCL ` has been
+  added.
 - ...
 
 Improvements to Clang's diagnostics
@@ -133,6 +135,14 @@
 C++ Language Changes in Clang
 -
 
+- Support for the address space attribute in various C++ features was improved,
+  refer to :ref:`C++ for OpenCL ` for more details. The following
+  features deviated from OpenCL:
+
+  (1) Address spaces as method qualifiers are not accepted yet;
+
+  (2) There is no address space deduction.
+
 - ...
 
 C++1z Feature Support
@@ -152,10 +162,88 @@
   // clang used to encode this as "^{NSArray=#}" instead of "@".
   const char *s0 = @encode(MyArray *);
 
-OpenCL C Language Changes in Clang
---
+OpenCL Kernel Language Changes in Clang
+---
+
+OpenCL C
+
+
+- Enabled use of variadic macro as a Clang extension.
+
+- Added initial support for implicitly including OpenCL builtin
+  fuctions using efficient trie lookup generated by TableGen.
+  A corresponding frontend-only flag ``-fdeclare-opencl-builtins``
+  has been added to enable trie during parsing.
+
+- Refactored header file to be used for common parts between
+  regular header added using ``-finclude-default-header`` and trie
+  based declarations added using ``-fdeclare-opencl-builtins``.
+
+- Improved string formatting diagnostics in printf for vector types.
+
+- Simplified the internal representation of blocks, including their
+  generation in IR. Furthermore, indirect calls to block function
+  has been changed to direct function calls.
+
+- Added diagnostics for conversions of nested pointers with
+  different address spaces.
+
+- Added ``cl_arm_integer_dot_product`` extension.
+
+- Fixed global samplers in OpenCL v2.0.
+
+- Improved math builtin functions with parameters of type ``long
+  long`` for x86. 
+
+.. _openclcpp:
+
+C++ for OpenCL
+^^
+
+Experimental support for C++17 features in OpenCL has been added
+and backwards compatibility with OpenCL C v2.0 was enabled.
+The documentation has been added for supported language features
+into :doc:`LanguageExtensions` and :doc:`UsersManual`. 
+
+Implemented features are:
+- Address space behavior is improved in majority of C++ features:
+
+  - Templates parameters and arguments
+
+  - Reference types;
+
+  - Type deduction;
+
+  - Objects and member functions, including special member
+functions;
+
+  - Builtin operators;
+
+  - Method qualifiers now include address space;
+
+  - Address space deduction has been extended for C++ use cases;
+
+  - Improved overload ranking rules.
+
+  - All standard cast operators now prevent converting address 
+spaces (except for conversions allowed implicitly). They
+can still be cast using C-style cast.
+
+- Vector types as in OpenCL C, including compound vector
+  initialization.
+
+- OpenCL-specific types: images, samplers, events, pipes, are
+  accepted with exception of blocks.
+
+- OpenCL standard header in Clang can be compiled in C++ mode.
+
+- Global constructors can be invoked from the host side using
+  a specific, compiler-generated kernel.
+
+- Overloads with generic address space are added to all atomic
+  builtin functions, including the ones from prior to OpenCL
+  v2.0.
 
-...
 
 ABI Changes in Clang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >