[PATCH] D77311: clang-format: [JS] detect C++ keywords.

2020-04-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

I think this LGTM and brings more clarity as its much easier to look for things 
in the positive than the negative


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77311



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


[PATCH] D77311: clang-format: [JS] detect C++ keywords.

2020-04-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77311



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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2020-04-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D33029#1951346 , @bbassi wrote:

> @MyDeveloperDay Can you please share your thoughts on my comment above?


I'm tempted to agree that perhaps having  as an enumeration 
`BreakBeforeClosingBracket` with various options might give us greater control

its recently also come to my attention that perhaps we should NEVER use a 
boolean as an option, as nearly every option that started out as a boolean 
ended up either needing to add another additional new option or being changed 
from a boolean to an enumeration later.


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

https://reviews.llvm.org/D33029



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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2020-04-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.



> I personally say fuck backwards compatibility when maintaining it requires 
> ever more workarounds to fix an obviously flawed abstraction, but I'm just 
> some dude and AFAIK the guys in charge support the status quo.

When LLVM itself isn't prepared to run clang-format over the the whole project 
because of the churn and the annoyance it would cause for existing forks and 
"git blame" (despite their being work around to ignore whitespace change 
commits), Then I feel we have to keep one eye on ensuring we allow people to 
incrementally upgrade their clang-format.

Even including a new option to the .clang-format file is a problem because it 
forces all users of that project to upgrade to a version of clang-format that 
recognises the option or clang-format will complain. With this in mind it means 
we need to allow existing users to use new binaries which where possible has 
zero changes to the code UNLESS they use the option. (even if that means many 
people delaying in using an option until its been supported for some time)

With Visual Studio and ClangPower tools always lagging behind the current 
capabilities due to the binaries they ship, we need to understand it may be a 
year+ before the majority of users are on a version that supports such changes.

Then we can multiply that annoyance to every other project using clang-format 
(both public and private projects), and so whilst a commit that changes such 
things are good by their own merit, that goodness might be lost in the noise of 
the complaints that come from time to time that clang-format causes huge 
changes version to version (even when those changes are bug fixes, let alone 
new features)

This is not about supporting the status quo, but about ensuring we aren't 
fairly/unfairly the brunt of peoples complaints. 
(https://travisdowns.github.io/blog/2019/11/19/toupper.html, 
http://lists.llvm.org/pipermail/cfe-dev/2017-June/054342.html)


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

https://reviews.llvm.org/D33029



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


[PATCH] D77311: clang-format: [JS] detect C++ keywords.

2020-04-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: clang/lib/Format/FormatToken.h:913
   bool IsJavaScriptIdentifier(const FormatToken &Tok) const {
-return Tok.is(tok::identifier) &&
-   JsExtraKeywords.find(Tok.Tok.getIdentifierInfo()) ==
-   JsExtraKeywords.end();
+switch (Tok.Tok.getKind()) {
+case tok::kw_break:

nit: may be worth adding a comment linking to:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77311



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


[PATCH] D77311: clang-format: [JS] detect C++ keywords.

2020-04-03 Thread Martin Probst via Phabricator via cfe-commits
mprobst marked 2 inline comments as done.
mprobst added inline comments.



Comment at: clang/lib/Format/FormatToken.h:913
   bool IsJavaScriptIdentifier(const FormatToken &Tok) const {
-return Tok.is(tok::identifier) &&
-   JsExtraKeywords.find(Tok.Tok.getIdentifierInfo()) ==
-   JsExtraKeywords.end();
+switch (Tok.Tok.getKind()) {
+case tok::kw_break:

krasimir wrote:
> nit: may be worth adding a comment linking to:
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords
Done, though I used the TS list of keywords (as it's a superset of the JS 
keywords).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77311



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


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

2020-04-03 Thread Andrew Ng via Phabricator via cfe-commits
andrewng added a comment.

The following patch fixes my issues on Windows, but I haven't tested that it 
doesn't break anything else:

  diff --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
  index 91bec7d8081..f630af211fd 100644
  --- a/llvm/cmake/modules/AddLLVM.cmake
  +++ b/llvm/cmake/modules/AddLLVM.cmake
  @@ -1495,7 +1495,7 @@ function(configure_lit_site_cfg site_in site_out)
   string(REPLACE ";" "\\;" ARG_PATH_VALUES_ESCAPED "${ARG_PATH_VALUES}")
   get_filename_component(OUTPUT_DIR ${site_out} DIRECTORY)
   execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
  -  "import os, sys; sys.stdout.write(';'.join(os.path.relpath(p, 
sys.argv[1]).replace(os.sep, '/') if p else '' for p in 
sys.argv[2].split(';')))"
  +  "import os, sys; drive = os.path.splitdrive(sys.argv[1])[0]; 
sys.stdout.write(';'.join('' if not p else p if os.path.splitdrive(p)[0] != 
drive else os.path.relpath(p, sys.argv[1]).replace(os.sep, '/') for p in 
sys.argv[2].split(';')))"
 ${OUTPUT_DIR}
 ${ARG_PATH_VALUES_ESCAPED}
 OUTPUT_VARIABLE ARG_PATH_VALUES_RELATIVE)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77184



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


[PATCH] D76929: [AArch64][SVE] Add SVE intrinsic for LD1RQ

2020-04-03 Thread Andrzej Warzynski via Phabricator via cfe-commits
andwar added a comment.

Btw, could you also add some negative tests? (e.g. out-of-range immediate)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76929



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


[clang] 146d685 - clang-format: [JS] detect C++ keywords.

2020-04-03 Thread Martin Probst via cfe-commits

Author: Martin Probst
Date: 2020-04-03T14:23:56+02:00
New Revision: 146d685cd657399a4698015f16cc5910cc828728

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

LOG: clang-format: [JS] detect C++ keywords.

Summary:
C++ defines a number of keywords that are regular identifiers in
JavaScript, e.g. `concept`:

const concept = 1; // legit JS

This change expands the existing `IsJavaScriptIdentifier(Tok)` function
to return false for C++ keywords that aren't keywords in JS.

Reviewers: krasimir

Subscribers: jfb, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestJS.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 10a5f0e96f96..48ec7602c21c 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -910,9 +910,64 @@ struct AdditionalKeywords {
   /// Returns \c true if \p Tok is a true JavaScript identifier, returns
   /// \c false if it is a keyword or a pseudo keyword.
   bool IsJavaScriptIdentifier(const FormatToken &Tok) const {
-return Tok.is(tok::identifier) &&
-   JsExtraKeywords.find(Tok.Tok.getIdentifierInfo()) ==
-   JsExtraKeywords.end();
+// Based on the list of JavaScript & TypeScript keywords here:
+// 
https://github.com/microsoft/TypeScript/blob/master/src/compiler/scanner.ts#L74
+switch (Tok.Tok.getKind()) {
+case tok::kw_break:
+case tok::kw_case:
+case tok::kw_catch:
+case tok::kw_class:
+case tok::kw_continue:
+case tok::kw_const:
+case tok::kw_default:
+case tok::kw_delete:
+case tok::kw_do:
+case tok::kw_else:
+case tok::kw_enum:
+case tok::kw_export:
+case tok::kw_false:
+case tok::kw_for:
+case tok::kw_if:
+case tok::kw_import:
+case tok::kw_module:
+case tok::kw_new:
+case tok::kw_private:
+case tok::kw_protected:
+case tok::kw_public:
+case tok::kw_return:
+case tok::kw_static:
+case tok::kw_switch:
+case tok::kw_this:
+case tok::kw_throw:
+case tok::kw_true:
+case tok::kw_try:
+case tok::kw_typeof:
+case tok::kw_void:
+case tok::kw_while:
+  // These are JS keywords that are lexed by LLVM/clang as keywords.
+  return false;
+case tok::identifier:
+  // For identifiers, make sure they are true identifiers, excluding the
+  // JavaScript pseudo-keywords (not lexed by LLVM/clang as keywords).
+  return JsExtraKeywords.find(Tok.Tok.getIdentifierInfo()) ==
+ JsExtraKeywords.end();
+default:
+  // Other keywords are handled in the switch below, to avoid problems due
+  // to duplicate case labels when using the #include trick.
+  break;
+}
+
+switch (Tok.Tok.getKind()) {
+  // Handle C++ keywords not included above: these are all JS identifiers.
+#define KEYWORD(X, Y) case tok::kw_##X:
+#include "clang/Basic/TokenKinds.def"
+  // #undef KEYWORD is not needed -- it's #undef-ed at the end of
+  // TokenKinds.def
+  return true;
+default:
+  // All other tokens (punctuation etc) are not JS identifiers.
+  return false;
+}
   }
 
   /// Returns \c true if \p Tok is a C# keyword, returns

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index a3cd4f42f8f8..029741c3dce7 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1522,9 +1522,9 @@ class AnnotatingParser {
 if (Style.Language == FormatStyle::LK_JavaScript) {
   if (Current.is(tok::exclaim)) {
 if (Current.Previous &&
-(Current.Previous->isOneOf(tok::identifier, tok::kw_namespace,
-   tok::r_paren, tok::r_square,
-   tok::r_brace) ||
+(Keywords.IsJavaScriptIdentifier(*Current.Previous) ||
+ Current.Previous->isOneOf(tok::kw_namespace, tok::r_paren,
+   tok::r_square, tok::r_brace) ||
  Current.Previous->Tok.isLiteral())) {
   Current.Type = TT_JsNonNullAssertion;
   return;
@@ -3070,10 +3070,8 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
 (Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
   return false;
 // In tagged template literals ("html`bar baz`"), there is no space between
-// the tag identifier and the template string. getIdentifierInfo makes sure
-// that the identifier is not a pseudo keyword like `yield`, either.
-if (Left.is(tok::identifier) && Keywords.IsJavaScriptIdentifier(Lef

[PATCH] D77311: clang-format: [JS] detect C++ keywords.

2020-04-03 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
mprobst marked an inline comment as done.
Closed by commit rG146d685cd657: clang-format: [JS] detect C++ keywords. 
(authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D77311?vs=254741&id=254763#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77311

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestJS.cpp

Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -386,13 +386,6 @@
"return (x);\n");
 }
 
-TEST_F(FormatTestJS, CppKeywords) {
-  // Make sure we don't mess stuff up because of C++ keywords.
-  verifyFormat("return operator && (aa);");
-  // .. or QT ones.
-  verifyFormat("slots: Slot[];");
-}
-
 TEST_F(FormatTestJS, ES6DestructuringAssignment) {
   verifyFormat("var [a, b, c] = [1, 2, 3];");
   verifyFormat("const [a, b, c] = [1, 2, 3];");
@@ -2366,6 +2359,61 @@
   verifyFormat("return !!x;\n");
 }
 
+TEST_F(FormatTestJS, CppKeywords) {
+  // Make sure we don't mess stuff up because of C++ keywords.
+  verifyFormat("return operator && (aa);");
+  // .. or QT ones.
+  verifyFormat("const slots: Slot[];");
+  // use the "!" assertion operator to validate that clang-format understands
+  // these C++ keywords aren't keywords in JS/TS.
+  verifyFormat("auto!;");
+  verifyFormat("char!;");
+  verifyFormat("concept!;");
+  verifyFormat("double!;");
+  verifyFormat("extern!;");
+  verifyFormat("float!;");
+  verifyFormat("inline!;");
+  verifyFormat("int!;");
+  verifyFormat("long!;");
+  verifyFormat("register!;");
+  verifyFormat("restrict!;");
+  verifyFormat("sizeof!;");
+  verifyFormat("struct!;");
+  verifyFormat("typedef!;");
+  verifyFormat("union!;");
+  verifyFormat("unsigned!;");
+  verifyFormat("volatile!;");
+  verifyFormat("_Alignas!;");
+  verifyFormat("_Alignof!;");
+  verifyFormat("_Atomic!;");
+  verifyFormat("_Bool!;");
+  verifyFormat("_Complex!;");
+  verifyFormat("_Generic!;");
+  verifyFormat("_Imaginary!;");
+  verifyFormat("_Noreturn!;");
+  verifyFormat("_Static_assert!;");
+  verifyFormat("_Thread_local!;");
+  verifyFormat("__func__!;");
+  verifyFormat("__objc_yes!;");
+  verifyFormat("__objc_no!;");
+  verifyFormat("asm!;");
+  verifyFormat("bool!;");
+  verifyFormat("const_cast!;");
+  verifyFormat("dynamic_cast!;");
+  verifyFormat("explicit!;");
+  verifyFormat("friend!;");
+  verifyFormat("mutable!;");
+  verifyFormat("operator!;");
+  verifyFormat("reinterpret_cast!;");
+  verifyFormat("static_cast!;");
+  verifyFormat("template!;");
+  verifyFormat("typename!;");
+  verifyFormat("typeid!;");
+  verifyFormat("using!;");
+  verifyFormat("virtual!;");
+  verifyFormat("wchar_t!;");
+}
+
 TEST_F(FormatTestJS, NullPropagatingOperator) {
   verifyFormat("let x = foo?.bar?.baz();\n");
   verifyFormat("let x = foo?.(foo);\n");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1522,9 +1522,9 @@
 if (Style.Language == FormatStyle::LK_JavaScript) {
   if (Current.is(tok::exclaim)) {
 if (Current.Previous &&
-(Current.Previous->isOneOf(tok::identifier, tok::kw_namespace,
-   tok::r_paren, tok::r_square,
-   tok::r_brace) ||
+(Keywords.IsJavaScriptIdentifier(*Current.Previous) ||
+ Current.Previous->isOneOf(tok::kw_namespace, tok::r_paren,
+   tok::r_square, tok::r_brace) ||
  Current.Previous->Tok.isLiteral())) {
   Current.Type = TT_JsNonNullAssertion;
   return;
@@ -3070,10 +3070,8 @@
 (Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
   return false;
 // In tagged template literals ("html`bar baz`"), there is no space between
-// the tag identifier and the template string. getIdentifierInfo makes sure
-// that the identifier is not a pseudo keyword like `yield`, either.
-if (Left.is(tok::identifier) && Keywords.IsJavaScriptIdentifier(Left) &&
-Right.is(TT_TemplateString))
+// the tag identifier and the template string.
+if (Keywords.IsJavaScriptIdentifier(Left) && Right.is(TT_TemplateString))
   return false;
 if (Right.is(tok::star) &&
 Left.isOneOf(Keywords.kw_function, Keywords.kw_yield))
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -910,9 +910,64 @@
   /// Returns \c true if \p Tok is a true JavaScript identifier, returns
   /// \c fa

[clang] a46e7d7 - [AMDGPU] Allow AGPR in inline asm

2020-04-03 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-04-03T09:08:13-04:00
New Revision: a46e7d7a5f60b452340eb8ebc873538659c73e78

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

LOG: [AMDGPU] Allow AGPR in inline asm

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

Added: 


Modified: 
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl

Removed: 




diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 55d7c081ceac..3fd9008e4660 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -124,7 +124,36 @@ const char *const AMDGPUTargetInfo::GCCRegNames[] = {
   "s113", "s114", "s115", "s116", "s117", "s118", "s119", "s120", "s121",
   "s122", "s123", "s124", "s125", "s126", "s127", "exec", "vcc", "scc",
   "m0", "flat_scratch", "exec_lo", "exec_hi", "vcc_lo", "vcc_hi",
-  "flat_scratch_lo", "flat_scratch_hi"
+  "flat_scratch_lo", "flat_scratch_hi",
+  "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8",
+  "a9", "a10", "a11", "a12", "a13", "a14", "a15", "a16", "a17",
+  "a18", "a19", "a20", "a21", "a22", "a23", "a24", "a25", "a26",
+  "a27", "a28", "a29", "a30", "a31", "a32", "a33", "a34", "a35",
+  "a36", "a37", "a38", "a39", "a40", "a41", "a42", "a43", "a44",
+  "a45", "a46", "a47", "a48", "a49", "a50", "a51", "a52", "a53",
+  "a54", "a55", "a56", "a57", "a58", "a59", "a60", "a61", "a62",
+  "a63", "a64", "a65", "a66", "a67", "a68", "a69", "a70", "a71",
+  "a72", "a73", "a74", "a75", "a76", "a77", "a78", "a79", "a80",
+  "a81", "a82", "a83", "a84", "a85", "a86", "a87", "a88", "a89",
+  "a90", "a91", "a92", "a93", "a94", "a95", "a96", "a97", "a98",
+  "a99", "a100", "a101", "a102", "a103", "a104", "a105", "a106", "a107",
+  "a108", "a109", "a110", "a111", "a112", "a113", "a114", "a115", "a116",
+  "a117", "a118", "a119", "a120", "a121", "a122", "a123", "a124", "a125",
+  "a126", "a127", "a128", "a129", "a130", "a131", "a132", "a133", "a134",
+  "a135", "a136", "a137", "a138", "a139", "a140", "a141", "a142", "a143",
+  "a144", "a145", "a146", "a147", "a148", "a149", "a150", "a151", "a152",
+  "a153", "a154", "a155", "a156", "a157", "a158", "a159", "a160", "a161",
+  "a162", "a163", "a164", "a165", "a166", "a167", "a168", "a169", "a170",
+  "a171", "a172", "a173", "a174", "a175", "a176", "a177", "a178", "a179",
+  "a180", "a181", "a182", "a183", "a184", "a185", "a186", "a187", "a188",
+  "a189", "a190", "a191", "a192", "a193", "a194", "a195", "a196", "a197",
+  "a198", "a199", "a200", "a201", "a202", "a203", "a204", "a205", "a206",
+  "a207", "a208", "a209", "a210", "a211", "a212", "a213", "a214", "a215",
+  "a216", "a217", "a218", "a219", "a220", "a221", "a222", "a223", "a224",
+  "a225", "a226", "a227", "a228", "a229", "a230", "a231", "a232", "a233",
+  "a234", "a235", "a236", "a237", "a238", "a239", "a240", "a241", "a242",
+  "a243", "a244", "a245", "a246", "a247", "a248", "a249", "a250", "a251",
+  "a252", "a253", "a254", "a255"
 };
 
 ArrayRef AMDGPUTargetInfo::getGCCRegNames() const {

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index 46ddc401fb6f..548cadcab9ab 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -114,11 +114,14 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
   /// Accepted register names: (n, m is unsigned integer, n < m)
   /// v
   /// s
+  /// a
   /// {vn}, {v[n]}
   /// {sn}, {s[n]}
+  /// {an}, {a[n]}
   /// {S} , where S is a special register name
   {v[n:m]}
   /// {s[n:m]}
+  /// {a[n:m]}
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &Info) const override {
 static const ::llvm::StringSet<> SpecialRegs({
@@ -135,7 +138,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
 }
 if (S.empty())
   return false;
-if (S.front() != 'v' && S.front() != 's') {
+if (S.front() != 'v' && S.front() != 's' && S.front() != 'a') {
   if (!HasLeftParen)
 return false;
   auto E = S.find('}');
@@ -153,7 +156,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
 if (!HasLeftParen) {
   if (!S.empty())
 return false;
-  // Found s or v.
+  // Found s, v or a.
   Info.setAllowsRegister();
   Name = S.data() - 1;
   return true;
@@ -184,7 +187,8 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
 S = S.drop_front();
 if (!S.empty())
   return false;
-// Found {vn}, {sn}, {v[n]}, {s[n]}, {v[n:m]}, or {s[n:m]}.
+// Found {vn}, {sn}, {an}, {v[n]}, {s[n]}, {a[n]}, {v[n:m]}, {s[n:m]}
+// or {a[

[PATCH] D76831: [AST] Preserve the DeclRefExpr when it refers to an invalid decl.

2020-04-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D76831#1952425 , @sammccall wrote:

> I like the idea, but it seems to regress quite a lot of diagnostics... e.g. 
> where we fail to deduce auto and then say it's not a pointer.
>
> Also this is regressing things in the -fno-recovery-ast case, because of the 
> changes to CheckDeclInExpr with the existing callsites that allow invalid 
> decls. (I'm not sure what passing AcceptInvalid actually *did* before)


Yeah, the solution makes diagnostics worse...

The motivation of the patch is to preserve the DeclRefExpr nodes even the 
referenced var-decl is invalid, so that clangd features can still work, e.g. 
the case we care about

  struct A { A(int); }
  void t() {
A a; // VarDecl a is invalid.
a.^ // none of clangd features would work as we don't have any AST node
  }

we have a few options:

1. build DeclRefExpr regardless the validity of VarDecl;
2. mark VarDecl valid even when there are errors during initialization;
3. using RecoveryExpr, e.g. build a RecoveryExpr that wraps a DeclRefExpr if 
the VarDecl is invalid;

as shown in this patch, 1 is not ideal and hurts about clang diagnostics. 2 
looks promising, and safer (probably not regress clang diagnostic a lot).

I think VarDecls in following cases should be valid. Interestingly, clang 
doesn't seem to have consistent behavior -- some of them are valid already, so 
2 has the greatest chance of not introducing large regressions.

  struct A {
A(int, int);
  };
  
  void test() {
// 1) default initialization (without any initializers)
A a1; // invalid
  
// 2) direct initialization
A a2(1); // invalid
A a3{1}; // invalid
A a4(invalid()); // valid
A a5{invalid()}; // valid
  
int var;
// 3) copy initializaiton
A a6 = 1; // invalid
A a7 = A(1); // valid
A a8 = A(var); // valid
A a10 = A{1}; // valid
A a9 = {1}; // invalid
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76831



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


[PATCH] D77385: [clangd] Add index inspection helper tool

2020-04-03 Thread Mark Nauwelaerts via Phabricator via cfe-commits
mnauw created this revision.
mnauw added a reviewer: sammccall.
mnauw added a project: clang-tools-extra.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov, mgorny.
Herald added a project: clang.

Add a standalone executable that can read indexed data and output in requested 
format.

Typical use is to read RIFF data to dump to YAML for inspection of indexed 
data.  The YAML (de)serialization has also been extended to aid in this regard.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77385

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index-dump/CMakeLists.txt
  clang-tools-extra/clangd/index-dump/IndexDumpMain.cpp
  clang-tools-extra/clangd/index/YAMLSerialization.cpp
  clang-tools-extra/clangd/test/CMakeLists.txt

Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -13,6 +13,7 @@
   ClangdTests
   # No tests for these, but we should still make sure they build.
   clangd-indexer
+  clangd-index-dump
   dexp
   )
 
Index: clang-tools-extra/clangd/index/YAMLSerialization.cpp
===
--- clang-tools-extra/clangd/index/YAMLSerialization.cpp
+++ clang-tools-extra/clangd/index/YAMLSerialization.cpp
@@ -41,6 +41,8 @@
   llvm::Optional Symbol;
   llvm::Optional Refs;
   llvm::Optional Relation;
+  llvm::Optional Source;
+  llvm::Optional Cmd;
 };
 // A class helps YAML to serialize the 32-bit encoded position (Line&Column),
 // as YAMLIO can't directly map bitfields.
@@ -53,6 +55,9 @@
 namespace llvm {
 namespace yaml {
 
+using clang::clangd::FileDigest;
+using clang::clangd::IncludeGraph;
+using clang::clangd::IncludeGraphNode;
 using clang::clangd::Ref;
 using clang::clangd::RefKind;
 using clang::clangd::Relation;
@@ -65,6 +70,7 @@
 using clang::index::SymbolKind;
 using clang::index::SymbolLanguage;
 using clang::index::SymbolRole;
+using clang::tooling::CompileCommand;
 
 // Helper to (de)serialize the SymbolID. We serialize it as a hex string.
 struct NormalizedSymbolID {
@@ -308,6 +314,76 @@
   }
 };
 
+struct NormalizedSourceFlag {
+  NormalizedSourceFlag(IO &) {}
+  NormalizedSourceFlag(IO &, IncludeGraphNode::SourceFlag O) {
+Flag = static_cast(O);
+  }
+
+  IncludeGraphNode::SourceFlag denormalize(IO &) {
+return static_cast(Flag);
+  }
+
+  uint8_t Flag = 0;
+};
+
+struct NormalizedFileDigest {
+  NormalizedFileDigest(IO &) {}
+  NormalizedFileDigest(IO &, const FileDigest &Digest) {
+HexString = llvm::toHex(Digest);
+  }
+
+  static FileDigest fromRaw(llvm::StringRef Raw) {
+FileDigest Digest;
+assert(Raw.size() == sizeof(Digest));
+memcpy(Digest.data(), Raw.data(), Raw.size());
+return Digest;
+  }
+
+  static llvm::Expected fromStr(llvm::StringRef Str) {
+const int RawSize = sizeof(FileDigest);
+if (Str.size() != RawSize * 2)
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Bad ID length");
+for (char C : Str)
+  if (!llvm::isHexDigit(C))
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Bad hex ID");
+return fromRaw(llvm::fromHex(Str));
+  }
+
+  FileDigest denormalize(IO &I) {
+auto Digest = fromStr(HexString);
+if (!Digest) {
+  I.setError(llvm::toString(Digest.takeError()));
+  return FileDigest();
+}
+return *Digest;
+  }
+
+  std::string HexString;
+};
+
+template <> struct MappingTraits {
+  static void mapping(IO &IO, IncludeGraphNode &Node) {
+IO.mapRequired("URI", Node.URI);
+MappingNormalization
+NSourceFlag(IO, Node.Flags);
+IO.mapRequired("Flags", NSourceFlag->Flag);
+MappingNormalization NDigest(IO,
+   Node.Digest);
+IO.mapRequired("Digest", NDigest->HexString);
+IO.mapRequired("DirectIncludes", Node.DirectIncludes);
+  }
+};
+
+template <> struct MappingTraits {
+  static void mapping(IO &IO, CompileCommand &Cmd) {
+IO.mapRequired("Directory", Cmd.Directory);
+IO.mapRequired("CommandLine", Cmd.CommandLine);
+  }
+};
+
 template <> struct MappingTraits {
   static void mapping(IO &IO, VariantEntry &Variant) {
 if (IO.mapTag("!Symbol", Variant.Symbol.hasValue())) {
@@ -322,6 +398,14 @@
   if (!IO.outputting())
 Variant.Relation.emplace();
   MappingTraits::mapping(IO, *Variant.Relation);
+} else if (IO.mapTag("!Source", Variant.Source.hasValue())) {
+  if (!IO.outputting())
+Variant.Source.emplace();
+  MappingTraits::mapping(IO, *Variant.Source);
+} else if (IO.mapTag("!Cmd", Variant.Cmd.hasValue())) {
+  if (!IO.outputting())
+Variant.Cmd.emplace();
+  MappingTraits::mapping(IO, *Variant.Cmd);
 }
   }
 };
@@ -35

[PATCH] D75181: [AArch64] Handle BTI/PAC in case of generated functions.

2020-04-03 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss updated this revision to Diff 254761.
danielkiss added a comment.

The patched is rebased and the hopefully the logic is now simpler.


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

https://reviews.llvm.org/D75181

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aarch64-branch-protection-attr.c
  clang/test/CodeGenCXX/aarch64-branch-target_clang_call_terminate.cpp
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/lib/Target/AArch64/AArch64BranchTargets.cpp
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-0.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-1.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-2.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-3.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-5.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-6.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-7.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-9.ll

Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-9.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-9.ll
@@ -0,0 +1,27 @@
+; RUN: llc -mtriple=aarch64-linux %s   -o - | \
+; RUN:   FileCheck %s --check-prefix=ASM
+; RUN: llc -mtriple=aarch64-linux %s -filetype=obj -o - | \
+; RUN:   llvm-readelf --notes | FileCheck %s --check-prefix=OBJ
+
+define dso_local i32 @f() #0 {
+entry:
+  ret i32 0
+}
+
+define dso_local i32 @g() {
+entry:
+  ret i32 0
+}
+
+attributes #0 = { "branch-target-enforcement" }
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 4, !"branch-target-enforcement", i32 1}
+
+; Only the common atttribute (BTI)
+; ASM:	.word	3221225472
+; ASM-NEXT:	.word	4
+; ASM-NEXT	.word	1
+
+; OBJ: Properties: aarch64 feature: BTI
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
===
--- llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
+++ llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
@@ -13,6 +13,10 @@
 
 attributes #0 = { "branch-target-enforcement" }
 
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 4, !"branch-target-enforcement", i32 1}
+
 ; Declarations don't prevent setting BTI
 ; ASM:	.word	3221225472
 ; ASM-NEXT:	.word	4
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-7.ll
===
--- llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-7.ll
+++ llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-7.ll
@@ -13,10 +13,14 @@
   ret i32 0
 }
 
-attributes #0 = { "sign-return-address"="non-leaf" }
+attributes #0 = { "ignore-branch-target-enforcement" "sign-return-address"="non-leaf" }
 
 attributes #1 = { "branch-target-enforcement" }
 
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 4, !"branch-target-enforcement", i32 1}
+
 ; No common attribute, no note section
 ; ASM: warning: not setting BTI in feature flags
 ; ASM-NOT: .note.gnu.property
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-6.ll
===
--- llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-6.ll
+++ llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-6.ll
@@ -17,6 +17,11 @@
 
 attributes #1 = { "sign-return-address"="none" }
 
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 4, !"sign-return-address", !"non-leaf"}
+
+
 ; No common attribute, no note section
 ; ASM-NOT: .note.gnu.property
 ; OBJ-NOT: .note.gnu.property
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-5.ll
===
--- llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-5.ll
+++ llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-5.ll
@@ -15,7 +15,13 @@
 
 attributes #0 = { "branch-target-enforcement" "sign-return-address"="non-leaf" }
 
-attributes #1 = { "sign-return-address"="all" }
+attributes #1 = { "ignore-branch-target-enforcement" "sign-return-address"="all" }
+
+!llvm.module.flags = !{!0, !1}
+
+!0 = !{i32 4, !"branch-target-enforcement", i32 1}
+!1 = !{i32 4, !"sign-return-address", !"all"}
+
 
 ; Only the common atttribute (PAC)
 ; ASM: warning: not setting BTI in feature flags
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll
===
--- llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll
+++ llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll
@@ -17,6 +17,10 @@
 
 attributes #1 = { "branch-target-enforcement" }
 
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 4, !"branch-target-enforcement", i32 1}
+
 ; Only the common atttribute (BTI)
 ; ASM:	.word	3221225472
 ; ASM-NEXT:	.word	4
Index: llvm/test/CodeGen/AArch64/note-gnu-property-p

[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

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



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:112
 
+Optional ExprEngine::retrieveFromConstructionContext(
+ProgramStateRef State, const LocationContext *LCtx,

Maybe we should merge we should merge this function into 
`handleConstructionContext()`?


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

https://reviews.llvm.org/D77229



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-03 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 254765.
baloghadamsoftware added a comment.

Lots of things seem to work now. However, I have a question: what to do with 
the return values of non-inlined calls? It may also be a `LazyCompoundVal`, but 
non-inlined calls do not have `StackFrameContext`. How to retrieve the 
`ConstructionContext` in such cases?


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

https://reviews.llvm.org/D77229

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/test/Analysis/iterator-modeling.cpp

Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -28,7 +28,7 @@
 void clang_analyzer_eval(bool);
 void clang_analyzer_warnIfReached();
 
-void begin(const std::vector &v) {
+/*void begin(const std::vector &v) {
   auto i = v.begin();
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i) == &v); // expected-warning{{TRUE}}
@@ -888,7 +888,7 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.begin() + 1}}
   // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $L.begin()
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}}
-}
+}*/
 
 template  Iter return_any_iterator(const Iter &It);
 
@@ -911,7 +911,7 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}}
 }
 
-void list_insert_ahead_of_end(std::list &L, int n) {
+/*void list_insert_ahead_of_end(std::list &L, int n) {
   auto i0 = L.cbegin(), i1 = --L.cend(), i2 = L.cend();
 
   clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()");
@@ -1880,3 +1880,4 @@
 // CHECK-NEXT: "i1 : Valid ; Container == SymRegion{reg_$[[#]] & V>} ; Offset == conj_$[[#]]{long, LC[[#]], S[[#]], #[[#]]}"
 // CHECK-NEXT:   ]}
 }
+*/
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -109,6 +109,96 @@
   return LValue;
 }
 
+Optional ExprEngine::retrieveFromConstructionContext(
+ProgramStateRef State, const LocationContext *LCtx,
+const ConstructionContext *CC) const {
+  if (CC) {
+switch (CC->getKind()) {
+case ConstructionContext::CXX17ElidedCopyVariableKind:
+case ConstructionContext::SimpleVariableKind: {
+  const auto *DSCC = cast(CC);
+  const auto *DS = DSCC->getDeclStmt();
+  return getObjectUnderConstruction(State, DS, LCtx);
+}
+case ConstructionContext::CXX17ElidedCopyConstructorInitializerKind:
+case ConstructionContext::SimpleConstructorInitializerKind: {
+  const auto *ICC = cast(CC);
+  const auto *Init = ICC->getCXXCtorInitializer();
+  return getObjectUnderConstruction(State, Init, LCtx);
+}
+case ConstructionContext::SimpleReturnedValueKind:
+case ConstructionContext::CXX17ElidedCopyReturnedValueKind: {
+  const StackFrameContext *SFC = LCtx->getStackFrame();
+  if (const LocationContext *CallerLCtx = SFC->getParent()) {
+auto RTC = (*SFC->getCallSiteBlock())[SFC->getIndex()]
+   .getAs();
+if (!RTC) {
+  // We were unable to find the correct construction context for the
+  // call in the parent stack frame. This is equivalent to not being
+  // able to find construction context at all.
+  break;
+}
+if (isa(CallerLCtx)) {
+  // Unwrap block invocation contexts. They're mostly part of
+  // the current stack frame.
+  CallerLCtx = CallerLCtx->getParent();
+  assert(!isa(CallerLCtx));
+}
+return retrieveFromConstructionContext(
+  State, CallerLCtx, RTC->getConstructionContext());
+  }
+  break;
+}
+case ConstructionContext::ElidedTemporaryObjectKind: {
+  assert(AMgr.getAnalyzerOptions().ShouldElideConstructors);
+  const auto *TCC = cast(CC);
+  Optional RetVal = retrieveFromConstructionContext(
+  State, LCtx, TCC->getConstructionContextAfterElision());
+  if (RetVal.hasValue())
+return RetVal;
+  
+  LLVM_FALLTHROUGH;
+}
+case ConstructionContext::SimpleTemporaryObjectKind: {
+  const auto *TCC = cast(CC);
+  const CXXBindTemporaryExpr *BTE = TC

[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

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

Output of

  /home/edmbalo/llvm-project/build/bin/clang -cc1 -internal-isystem 
/mnt/ssd/edmbalo/llvm-project/build/lib/clang/11.0.0/include -nostdsysteminc 
-analyze -analyzer-constraints=range -setup-static-analyzer -std=c++11 
-analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection
 -analyzer-config aggressive-binary-operation-simplification=true 
-analyzer-config c++-container-inlining=false 
/home/edmbalo/llvm-project/clang/test/Analysis/iterator-modeling.cpp

is the following:

  Container PostCall
  Original RetVal: lazyCompoundVal{0x55563691e490,i0}
Retrieving Original
  Updated RetVal: &i0
  Generic PostCall
  Original RetVal: lazyCompoundVal{0x55563691e490,i0}
Retrieving Original
  Updated RetVal: &i0
  Container PostCall
  Original RetVal: 
lazyCompoundVal{0x555636921ba0,temp_object{std::list::const_iterator, 
S48444}}
Retrieving Original
  Updated RetVal: &temp_object{std::list::const_iterator, S48444}
  Generic PostCall
  Original RetVal: 
lazyCompoundVal{0x555636921ba0,temp_object{std::list::const_iterator, 
S48444}}
Retrieving Original
  Updated RetVal: &temp_object{std::list::const_iterator, S48444}
  Container PostCall
  Original RetVal: lazyCompoundVal{0x555636922d28,i1}
  No Stack Frame!
No construction context!!!
  Generic PostCall
  Original RetVal: lazyCompoundVal{0x555636922d28,i1}
  No Stack Frame!
No construction context!!!
  Container PostCall
  Original RetVal: lazyCompoundVal{0x555636925348,i2}
Retrieving Original
  Updated RetVal: &i2
  Generic PostCall
  Original RetVal: lazyCompoundVal{0x555636925348,i2}
Retrieving Original
  Updated RetVal: &i2
  Container PostCall
  Original RetVal: conj_$3{long, LC1, S45775, #1}
  Updated RetVal: conj_$3{long, LC1, S45775, #1}
  Container PostCall
  Original RetVal: Unknown
  Updated RetVal: Unknown
  Container PostCall
  Original RetVal: conj_$11{long, LC1, S48640, #1}
  Updated RetVal: conj_$11{long, LC1, S48640, #1}
  Container PostCall
  Original RetVal: Unknown
  Updated RetVal: Unknown
  Container PostCall
  Original RetVal: 0 S64b
  Updated RetVal: 0 S64b
  Container PostCall
  Original RetVal: Unknown
  Updated RetVal: Unknown
  Bind Old: lazyCompoundVal{0x555636925348,i1}
  Bind New: &temp_object{std::list::const_iterator, S49796}
  Container PostCall
  Original RetVal: 
lazyCompoundVal{0x555636921918,temp_object{std::list::const_iterator, 
S49796}}
Retrieving Original
Handling New
  Updated RetVal: &temp_object{std::list::const_iterator, S49796}
  Generic PostCall
  Original RetVal: 
lazyCompoundVal{0x555636921918,temp_object{std::list::const_iterator, 
S49796}}
Retrieving Original
Handling New
  Updated RetVal: &temp_object{std::list::const_iterator, S49796}
  Container PostCall
  Original RetVal: lazyCompoundVal{0x55563692ea10,i3}
  No Stack Frame!
No construction context!!!
  Generic PostCall
  Original RetVal: lazyCompoundVal{0x55563692ea10,i3}
  No Stack Frame!
No construction context!!!
  Container PostCall
  Original RetVal: 1 S64b
  Updated RetVal: 1 S64b
  Container PostCall
  Original RetVal: Unknown
  Updated RetVal: Unknown
  Container PostCall
  Original RetVal: 0 S64b
  Updated RetVal: 0 S64b
  Container PostCall
  Original RetVal: Unknown
  Updated RetVal: Unknown
  Container PostCall
  Original RetVal: 1 S64b
  Updated RetVal: 1 S64b
  Container PostCall
  Original RetVal: Unknown
  Updated RetVal: Unknown
  Container PostCall
  Original RetVal: conj_$3{long, LC1, S45775, #1}
  Updated RetVal: conj_$3{long, LC1, S45775, #1}
  Container PostCall
  Original RetVal: Unknown
  Updated RetVal: Unknown
  Container PostCall
  Original RetVal: 0 S64b
  Updated RetVal: 0 S64b
  Container PostCall
  Original RetVal: Unknown
  Updated RetVal: Unknown
  Container PostCall
  Original RetVal: conj_$11{long, LC1, S48640, #1}
  Updated RetVal: conj_$11{long, LC1, S48640, #1}
  Container PostCall
  Original RetVal: Unknown
  Updated RetVal: Unknown
  /home/edmbalo/llvm-project/clang/test/Analysis/iterator-modeling.cpp:900:3: 
warning: Not a symbol
clang_analyzer_denote(clang_analyzer_iterator_position(i1), "$i1");
^~
  /home/edmbalo/llvm-project/clang/test/Analysis/iterator-modeling.cpp:904:3: 
warning: TRUE
clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); 
//expected-warning{{TRUE}}
^
  /home/edmbalo/llvm-project/clang/test/Analysis/iterator-modeling.cpp:905:3: 
warning: FALSE
clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); 
//expected-warning{{TRUE}}
^
  /home/edmbalo/llvm-project/clang/test/Analysis/iterator-modeling.cpp:906:3: 
warning: TRUE
clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); 
//expected-warning{{TRUE}}
^~~

[PATCH] D77335: [AST] clang::VectorType supports any size (that fits in unsigned)

2020-04-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 254769.
sammccall added a comment.

Store NumElements in the bitfield after all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77335

Files:
  clang/include/clang/AST/Type.h
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/types.c
  clang/test/SemaCXX/vector.cpp

Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -335,7 +335,7 @@
 typedef bool bad __attribute__((__vector_size__(16)));  // expected-error {{invalid vector element type 'bool'}}
 
 namespace Templates {
-template 
+template 
 struct TemplateVectorType {
   typedef Elt __attribute__((__vector_size__(Size))) type; // #1
 };
@@ -343,7 +343,7 @@
 template 
 struct PR15730 {
   typedef T __attribute__((vector_size(N * sizeof(T type;
-  typedef T __attribute__((vector_size(8192))) type2; // #2
+  typedef T __attribute__((vector_size(0x10))) type2; // #2
   typedef T __attribute__((vector_size(3))) type3; // #3
 };
 
@@ -352,19 +352,20 @@
   const TemplateVectorType::type Works2 = {};
   // expected-error@#1 {{invalid vector element type 'bool'}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoBool;
+  const TemplateVectorType::type NoBool = {};
   // expected-error@#1 {{invalid vector element type 'int __attribute__((ext_vector_type(4)))' (vector of 4 'int' values)}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoComplex;
+  const TemplateVectorType::type NoComplex = {};
   // expected-error@#1 {{vector size not an integral multiple of component size}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type BadSize;
+  const TemplateVectorType::type BadSize = {};
+  const TemplateVectorType::type Large = {};
   // expected-error@#1 {{vector size too large}}
-  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type TooLarge;
+  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
+  const TemplateVectorType::type TooLarge = {};
   // expected-error@#1 {{zero vector size}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type Zero;
+  const TemplateVectorType::type Zero = {};
 
   // expected-error@#2 {{vector size too large}}
   // expected-error@#3 {{vector size not an integral multiple of component size}}
Index: clang/test/Sema/types.c
===
--- clang/test/Sema/types.c
+++ clang/test/Sema/types.c
@@ -69,9 +69,15 @@
   char c = (char __attribute__((may_alias))) i;
 }
 
-// vector size too large
-int __attribute__ ((vector_size(8192))) x1; // expected-error {{vector size too large}}
-typedef int __attribute__ ((ext_vector_type(8192))) x2; // expected-error {{vector size too large}}
+// vector size
+int __attribute__((vector_size(123456))) v1;
+int __attribute__((vector_size(0x10))) v2; // expected-error {{vector size too large}}
+int __attribute__((vector_size((__int128_t)1 << 100))) v3; // expected-error {{vector size too large}}
+int __attribute__((vector_size(0))) v4;// expected-error {{zero vector size}}
+typedef int __attribute__((ext_vector_type(123456))) e1;
+typedef int __attribute__((ext_vector_type(0x1))) e2;  // expected-error {{vector size too large}}
+typedef int __attribute__((vector_size((__int128_t)1 << 100))) e3; // expected-error {{vector size too large}}
+typedef int __attribute__((ext_vector_type(0))) e4;// expected-error {{zero vector size}}
 
 // no support for vector enum type
 enum { e_2 } x3 __attribute__((vector_size(64))); // expected-error {{invalid vector element type}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2436,28 +2436,34 @@
 return Context.getDependentVectorType(CurType, SizeExpr, AttrLoc,
VectorType::GenericVector);
 
-  unsigned VectorSize = static_cast(VecSize.getZExtValue() * 8);
+  // vecSize is specified in bytes - convert to bits.
+  if (!VecSize.isIntN(61)) {
+// Bit size will overflow uint64.
+Diag(AttrLoc, diag::err_attribute_size_too_large)
+<< SizeExpr->getSourceRange();
+return QualType();
+  }
+  uint64_t VectorSizeBits = VecSize.getZExtValue() * 8;
   unsigned TypeSize = static_cast(Context.getTypeSize(CurType));
 
-  if (

[PATCH] D77335: [AST] clang::VectorType supports any size (that fits in unsigned)

2020-04-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked an inline comment as done.
sammccall added inline comments.



Comment at: clang/include/clang/AST/Type.h:3236
   QualType ElementType;
+  unsigned NumElements;
 

fhahn wrote:
> I think you could keep NumElements in VectorTypeBitfields (just remove the 
> bit specifier), as the size of those bitfields can be up to 8 bytes (see the 
> static asserts around line 1775). That should be fine as long as NumTypeBits 
> + 3 <= 32.
Ah, you're right. I just assumed it was taking all the rest of the bits, but 
there are another 4 bytes free :-\
Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77335



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


[PATCH] D77329: [AMDGPU] Allow AGPR in inline asm

2020-04-03 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa46e7d7a5f60: [AMDGPU] Allow AGPR in inline asm (authored by 
yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D77329?vs=254668&id=254772#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77329

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl

Index: clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
===
--- clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
+++ clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
@@ -1,8 +1,35 @@
 // REQUIRES: amdgpu-registered-target
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O0 -o - -triple amdgcn %s | FileCheck %s
+
+typedef float float32 __attribute__((ext_vector_type(32)));
 
 kernel void test_long(int arg0) {
   long v15_16;
-  // CHECK: tail call i64 asm sideeffect "v_lshlrev_b64 v[15:16], 0, $0", "={v[15:16]},v"(i32 %arg0)
+  // CHECK: call i64 asm sideeffect "v_lshlrev_b64 v[15:16], 0, $0", "={v[15:16]},v"
   __asm volatile("v_lshlrev_b64 v[15:16], 0, %0" : "={v[15:16]}"(v15_16) : "v"(arg0));
 }
+
+kernel void test_agpr() {
+  float32 acc_c;
+  float reg_a;
+  float reg_b;
+  float32 reg_c;
+  // CHECK:  call <32 x float> asm "v_mfma_f32_32x32x1f32 $0, $1, $2, $3", "=a,v,v,a,~{a0},~{a1},~{a2},~{a3},~{a4},~{a5},~{a6},~{a7},~{a8},~{a9},~{a10},~{a11},~{a12},~{a13},~{a14},~{a15},~{a16},~{a17},~{a18},~{a19},~{a20},~{a21},~{a22},~{a23},~{a24},~{a25},~{a26},~{a27},~{a28},~{a29},~{a30},~{a31}"
+  __asm ("v_mfma_f32_32x32x1f32 %0, %1, %2, %3"
+ : "=a"(acc_c)
+ : "v"(reg_a), "v"(reg_b), "a"(reg_c)
+ : "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
+   "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15",
+   "a16", "a17", "a18", "a19", "a20", "a21", "a22", "a23",
+   "a24", "a25", "a26", "a27", "a28", "a29", "a30", "a31");
+
+   // CHECK: call <32 x float> asm sideeffect "v_mfma_f32_32x32x1f32 a[0:31], $0, $1, a[0:31]", "={a[0:31]},v,v,{a[0:31]}"
+  __asm volatile("v_mfma_f32_32x32x1f32 a[0:31], %0, %1, a[0:31]"
+ : "={a[0:31]}"(acc_c)
+ : "v"(reg_a),"v"(reg_b), "{a[0:31]}"(reg_c));
+
+  // CHECK: call float asm "v_accvgpr_read_b32 $0, $1", "={a1},{a1}"
+  __asm ("v_accvgpr_read_b32 %0, %1"
+ : "={a1}"(reg_a)
+ : "{a1}"(reg_b));
+}
Index: clang/lib/Basic/Targets/AMDGPU.h
===
--- clang/lib/Basic/Targets/AMDGPU.h
+++ clang/lib/Basic/Targets/AMDGPU.h
@@ -114,11 +114,14 @@
   /// Accepted register names: (n, m is unsigned integer, n < m)
   /// v
   /// s
+  /// a
   /// {vn}, {v[n]}
   /// {sn}, {s[n]}
+  /// {an}, {a[n]}
   /// {S} , where S is a special register name
   {v[n:m]}
   /// {s[n:m]}
+  /// {a[n:m]}
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &Info) const override {
 static const ::llvm::StringSet<> SpecialRegs({
@@ -135,7 +138,7 @@
 }
 if (S.empty())
   return false;
-if (S.front() != 'v' && S.front() != 's') {
+if (S.front() != 'v' && S.front() != 's' && S.front() != 'a') {
   if (!HasLeftParen)
 return false;
   auto E = S.find('}');
@@ -153,7 +156,7 @@
 if (!HasLeftParen) {
   if (!S.empty())
 return false;
-  // Found s or v.
+  // Found s, v or a.
   Info.setAllowsRegister();
   Name = S.data() - 1;
   return true;
@@ -184,7 +187,8 @@
 S = S.drop_front();
 if (!S.empty())
   return false;
-// Found {vn}, {sn}, {v[n]}, {s[n]}, {v[n:m]}, or {s[n:m]}.
+// Found {vn}, {sn}, {an}, {v[n]}, {s[n]}, {a[n]}, {v[n:m]}, {s[n:m]}
+// or {a[n:m]}.
 Info.setAllowsRegister();
 Name = S.data() - 1;
 return true;
Index: clang/lib/Basic/Targets/AMDGPU.cpp
===
--- clang/lib/Basic/Targets/AMDGPU.cpp
+++ clang/lib/Basic/Targets/AMDGPU.cpp
@@ -124,7 +124,36 @@
   "s113", "s114", "s115", "s116", "s117", "s118", "s119", "s120", "s121",
   "s122", "s123", "s124", "s125", "s126", "s127", "exec", "vcc", "scc",
   "m0", "flat_scratch", "exec_lo", "exec_hi", "vcc_lo", "vcc_hi",
-  "flat_scratch_lo", "flat_scratch_hi"
+  "flat_scratch_lo", "flat_scratch_hi",
+  "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8",
+  "a9", "a10", "a11", "a12", "a13", "a14", "a15", "a16", "a17",
+  "a18", "a19", "a20", "a21", "a22", "a23", "a24", "a25", "a26",
+  "a27", "a28", "a29", "a30", "a31", "a32", "a33", "a34", "a35",
+  "a36", "a37", "a38", "a39", "a40", "a41", "a42", "a43", "a44",
+  "a45", "a46", "a47", "a48", "a49", "a50", "a51", "a52", "a53",
+  "a54", "a55", "a56", "a57", "a58", "a59", "a60", "a61

[clang-tools-extra] 164ed7b - [clangd] Enable some nice clang-tidy checks by default.

2020-04-03 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-04-03T15:40:07+02:00
New Revision: 164ed7b1d0446400123189c9cd168df5448e4233

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

LOG: [clangd] Enable some nice clang-tidy checks by default.

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/tool/ClangdMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp 
b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index 9bfc58b55f71..4b3b565ac2b6 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -691,18 +691,42 @@ clangd accepts flags on the commandline, and in the 
CLANGD_FLAGS environment var
   std::unique_ptr
   ClangTidyOptProvider; /*GUARDED_BY(ClangTidyOptMu)*/
   if (EnableClangTidy) {
-auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
-OverrideClangTidyOptions.Checks = ClangTidyChecks;
+auto EmptyDefaults = tidy::ClangTidyOptions::getDefaults();
+EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
+tidy::ClangTidyOptions OverrideClangTidyOptions;
+if (!ClangTidyChecks.empty())
+  OverrideClangTidyOptions.Checks = ClangTidyChecks;
 ClangTidyOptProvider = std::make_unique(
 tidy::ClangTidyGlobalOptions(),
-/* Default */ tidy::ClangTidyOptions::getDefaults(),
+/* Default */ EmptyDefaults,
 /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
 Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,
llvm::StringRef File) {
   // This function must be thread-safe and tidy option providers are not.
-  std::lock_guard Lock(ClangTidyOptMu);
-  // FIXME: use the FS provided to the function.
-  return ClangTidyOptProvider->getOptions(File);
+  tidy::ClangTidyOptions Opts;
+  {
+std::lock_guard Lock(ClangTidyOptMu);
+// FIXME: use the FS provided to the function.
+Opts = ClangTidyOptProvider->getOptions(File);
+  }
+  if (!Opts.Checks) {
+// If the user hasn't configured clang-tidy checks at all, including
+// via .clang-tidy, give them a nice set of checks.
+// (This should be what the "default" options does, but it isn't...)
+//
+// These default checks are chosen for:
+//  - low false-positive rate
+//  - providing a lot of value
+//  - being reasonably efficient
+Opts.Checks = llvm::join_items(
+",", "readability-misleading-indentation",
+"readability-deleted-default", "bugprone-integer-division",
+"bugprone-sizeof-expression", "bugprone-suspicious-missing-comma",
+"bugprone-unused-raii", "bugprone-unused-return-value",
+"misc-unused-using-decls", "misc-unused-alias-decls",
+"misc-definitions-in-headers");
+  }
+  return Opts;
 };
   }
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;



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


[clang] b72fce1 - Fix __builtin_amdgcn_workgroup_size_x/y/z return type

2020-04-03 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-04-03T09:56:30-04:00
New Revision: b72fce1ffd0a0de5b46b486c7030d54cc5d8c225

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

LOG: Fix __builtin_amdgcn_workgroup_size_x/y/z return type

https://reviews.llvm.org/D77390

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsAMDGPU.def
clang/test/CodeGenOpenCL/builtins-amdgcn.cl

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index e5b256c07a49..b42c8a77c4bc 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -33,9 +33,9 @@ BUILTIN(__builtin_amdgcn_workitem_id_x, "Ui", "nc")
 BUILTIN(__builtin_amdgcn_workitem_id_y, "Ui", "nc")
 BUILTIN(__builtin_amdgcn_workitem_id_z, "Ui", "nc")
 
-BUILTIN(__builtin_amdgcn_workgroup_size_x, "Ui", "nc")
-BUILTIN(__builtin_amdgcn_workgroup_size_y, "Ui", "nc")
-BUILTIN(__builtin_amdgcn_workgroup_size_z, "Ui", "nc")
+BUILTIN(__builtin_amdgcn_workgroup_size_x, "Us", "nc")
+BUILTIN(__builtin_amdgcn_workgroup_size_y, "Us", "nc")
+BUILTIN(__builtin_amdgcn_workgroup_size_z, "Us", "nc")
 
 BUILTIN(__builtin_amdgcn_mbcnt_hi, "UiUiUi", "nc")
 BUILTIN(__builtin_amdgcn_mbcnt_lo, "UiUiUi", "nc")

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
index 9d7916c236c5..8f2f149103b3 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -538,7 +538,7 @@ void test_get_local_id(int d, global int *out)
 void test_get_workgroup_size(int d, global int *out)
 {
switch (d) {
-   case 0: *out = __builtin_amdgcn_workgroup_size_x(); break;
+   case 0: *out = __builtin_amdgcn_workgroup_size_x() + 1; break;
case 1: *out = __builtin_amdgcn_workgroup_size_y(); break;
case 2: *out = __builtin_amdgcn_workgroup_size_z(); break;
default: *out = 0;



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


[PATCH] D77390: Fix __builtin_amdgcn_workgroup_size_x/y/z return type

2020-04-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: b-sumner, arsenm.
Herald added subscribers: kerbowa, nhaehnle, wdng, jvesely.
arsenm accepted this revision.
This revision is now accepted and ready to land.

https://reviews.llvm.org/D77390

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl


Index: clang/test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -538,7 +538,7 @@
 void test_get_workgroup_size(int d, global int *out)
 {
switch (d) {
-   case 0: *out = __builtin_amdgcn_workgroup_size_x(); break;
+   case 0: *out = __builtin_amdgcn_workgroup_size_x() + 1; break;
case 1: *out = __builtin_amdgcn_workgroup_size_y(); break;
case 2: *out = __builtin_amdgcn_workgroup_size_z(); break;
default: *out = 0;
Index: clang/include/clang/Basic/BuiltinsAMDGPU.def
===
--- clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -33,9 +33,9 @@
 BUILTIN(__builtin_amdgcn_workitem_id_y, "Ui", "nc")
 BUILTIN(__builtin_amdgcn_workitem_id_z, "Ui", "nc")
 
-BUILTIN(__builtin_amdgcn_workgroup_size_x, "Ui", "nc")
-BUILTIN(__builtin_amdgcn_workgroup_size_y, "Ui", "nc")
-BUILTIN(__builtin_amdgcn_workgroup_size_z, "Ui", "nc")
+BUILTIN(__builtin_amdgcn_workgroup_size_x, "Us", "nc")
+BUILTIN(__builtin_amdgcn_workgroup_size_y, "Us", "nc")
+BUILTIN(__builtin_amdgcn_workgroup_size_z, "Us", "nc")
 
 BUILTIN(__builtin_amdgcn_mbcnt_hi, "UiUiUi", "nc")
 BUILTIN(__builtin_amdgcn_mbcnt_lo, "UiUiUi", "nc")


Index: clang/test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -538,7 +538,7 @@
 void test_get_workgroup_size(int d, global int *out)
 {
 	switch (d) {
-	case 0: *out = __builtin_amdgcn_workgroup_size_x(); break;
+	case 0: *out = __builtin_amdgcn_workgroup_size_x() + 1; break;
 	case 1: *out = __builtin_amdgcn_workgroup_size_y(); break;
 	case 2: *out = __builtin_amdgcn_workgroup_size_z(); break;
 	default: *out = 0;
Index: clang/include/clang/Basic/BuiltinsAMDGPU.def
===
--- clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -33,9 +33,9 @@
 BUILTIN(__builtin_amdgcn_workitem_id_y, "Ui", "nc")
 BUILTIN(__builtin_amdgcn_workitem_id_z, "Ui", "nc")
 
-BUILTIN(__builtin_amdgcn_workgroup_size_x, "Ui", "nc")
-BUILTIN(__builtin_amdgcn_workgroup_size_y, "Ui", "nc")
-BUILTIN(__builtin_amdgcn_workgroup_size_z, "Ui", "nc")
+BUILTIN(__builtin_amdgcn_workgroup_size_x, "Us", "nc")
+BUILTIN(__builtin_amdgcn_workgroup_size_y, "Us", "nc")
+BUILTIN(__builtin_amdgcn_workgroup_size_z, "Us", "nc")
 
 BUILTIN(__builtin_amdgcn_mbcnt_hi, "UiUiUi", "nc")
 BUILTIN(__builtin_amdgcn_mbcnt_lo, "UiUiUi", "nc")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77391: [analyzer][AnalysisOrder] Display the CallEvent type for preCall/postCall

2020-04-03 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, baloghadamsoftware, martong, balazske, 
steakhal, xazax.hun, rnkovacs.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, gamesh411, 
dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, szepet, whisperity.
Szelethus added a child revision: D75430: [analyzer][NFC] Introduce 
CXXDeallocatorCall, deploy it in MallocChecker.

Exactly what it says on the tin! The included testfile demonstrates why this is 
important -- for C++ dynamic memory operators, we don't always recognize 
custom, or even standard-specified new/delete operators as `CXXAllocatorCall` 
or `CXXDeallocatorCall`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77391

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/cxx-dynamic-memory-analysis-order.cpp
  clang/test/Analysis/diagnostics/explicit-suppression.cpp

Index: clang/test/Analysis/diagnostics/explicit-suppression.cpp
===
--- clang/test/Analysis/diagnostics/explicit-suppression.cpp
+++ clang/test/Analysis/diagnostics/explicit-suppression.cpp
@@ -19,6 +19,6 @@
 void testCopyNull(C *I, C *E) {
   std::copy(I, E, (C *)0);
 #ifndef SUPPRESSED
-  // expected-warning@../Inputs/system-header-simulator-cxx.h:698 {{Called C++ object pointer is null}}
+  // expected-warning@../Inputs/system-header-simulator-cxx.h:699 {{Called C++ object pointer is null}}
 #endif
 }
Index: clang/test/Analysis/cxx-dynamic-memory-analysis-order.cpp
===
--- /dev/null
+++ clang/test/Analysis/cxx-dynamic-memory-analysis-order.cpp
@@ -0,0 +1,130 @@
+// RUN: %clang_analyze_cc1 -std=c++20 -fblocks -verify %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.AnalysisOrder \
+// RUN:   -analyzer-config debug.AnalysisOrder:PreStmtCXXNewExpr=true \
+// RUN:   -analyzer-config debug.AnalysisOrder:PostStmtCXXNewExpr=true \
+// RUN:   -analyzer-config debug.AnalysisOrder:PreStmtCXXDeleteExpr=true \
+// RUN:   -analyzer-config debug.AnalysisOrder:PostStmtCXXDeleteExpr=true \
+// RUN:   -analyzer-config debug.AnalysisOrder:PreCall=true \
+// RUN:   -analyzer-config debug.AnalysisOrder:PostCall=true \
+// RUN:   2>&1 | FileCheck %s
+
+// expected-no-diagnostics
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+void f() {
+  // C++20 standard draft 17.6.1.15:
+  // Required behavior: A call to an operator delete with a size parameter may
+  // be changed to a call to the corresponding operator delete without a size
+  // parameter, without affecting memory allocation. [ Note: A conforming
+  // implementation is for operator delete(void* ptr, size_t size) to simply
+  // call operator delete(ptr). — end note ]
+  //
+  // C++20 standard draft 17.6.1.24, about nothrow operator delete:
+  //   void operator delete(void* ptr, const std::nothrow_t&) noexcept;
+  //   void operator delete(void* ptr, std::align_val_t alignment,
+  //const std::nothrow_t&) noexcept;
+  // Default behavior: Calls operator delete(ptr), or operator delete(ptr,
+  // alignment), respectively.
+
+  // FIXME: All calls to operator new should be CXXAllocatorCall.
+  // FIXME: PostStmt should be present.
+  {
+int *p = new int;
+delete p;
+// CHECK:  PreCall (operator new) [CXXAllocatorCall]
+// CHECK-NEXT: PostCall (operator new) [CXXAllocatorCall]
+// CHECK-NEXT: PreStmt
+// CHECK-NEXT: PostStmt
+// CHECK-NEXT: PreStmt
+
+p = new int;
+operator delete(p, 23542368);
+// CHECK-NEXT: PreCall (operator new) [CXXAllocatorCall]
+// CHECK-NEXT: PostCall (operator new) [CXXAllocatorCall]
+// CHECK-NEXT: PreStmt
+// CHECK-NEXT: PostStmt
+// CHECK-NEXT: PreCall (operator delete) [SimpleFunctionCall]
+// CHECK-NEXT: PostCall (operator delete) [SimpleFunctionCall]
+
+void *v = operator new(sizeof(int[2]), std::align_val_t(2));
+operator delete(v, std::align_val_t(2));
+// CHECK-NEXT: PreCall (operator new) [SimpleFunctionCall]
+// CHECK-NEXT: PostCall (operator new) [SimpleFunctionCall]
+// CHECK-NEXT: PreCall (operator delete) [SimpleFunctionCall]
+// CHECK-NEXT: PostCall (operator delete) [SimpleFunctionCall]
+
+v = operator new(sizeof(int[2]), std::align_val_t(2));
+operator delete(v, 345345, std::align_val_t(2));
+// CHECK-NEXT: PreCall (operator new) [SimpleFunctionCall]
+// CHECK-NEXT: PostCall (operator new) [SimpleFunctionCall]
+// CHECK-NEXT: PreCall (operator delete) [SimpleFunctionCall]
+// CHECK-NEXT: PostCall (operator delete) [SimpleFunctionCall

[PATCH] D77385: [clangd] Add index inspection helper tool

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

Thanks for the patch!

We already have one introspection tool called `dexp` have you give it a try? It 
can read both RIFF and YAML and allows you to run queries on the index.

If it is not enough for your use case, can you describe it a little more? Maybe 
it would be easier to extend dexp to accommodate your use case instead of 
introducing a new binary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77385



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


[PATCH] D77348: [clangd] Enable some nice clang-tidy checks by default.

2020-04-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 2 inline comments as done.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:695
+auto EmptyDefaults = tidy::ClangTidyOptions::getDefaults();
+EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
+tidy::ClangTidyOptions OverrideClangTidyOptions;

hokein wrote:
> `EmptyDefaults.Checks` is not none, but it is an empty string I think , we 
> could even assign our default checks to `EmptyDefaults.Checks` (instead of 
> setting it in `GetCalngTidyOptions`).
That doesn't work :-(
The clang tidy options config is a tangled mess.
Ultimately it produces a vector of optionses that are merged in order to 
produce the final options.
In our case this vector is [EmptyDefaults, options from .clang-tidy, 
OverrideClangTidyOptions].

For the "Checks" field, the merge just joins the comma-separated lists together.
So the checks from EmptyDefaults would be enabled unless .clang-tidy 
*specifically* disables them, which is not the behavior I want - the existence 
of .clang-tidy should override the defaults.

This is what the complainy comment below is supposed to indicate...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77348



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


[PATCH] D77392: [clangd] Make signatureHelp work with stale preambles

2020-04-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, jfb, arphaman, mgrang, 
jkorous, MaskRay, javed.absar, ilya-biryukov.
Herald added a project: clang.

This is achieved by calculating newly added includes and implicitly
parsing them as if they were part of the main file.

This also gets rid of the need for consistent preamble reads.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77392

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -242,63 +242,6 @@
   EXPECT_EQ(2, CallbackCount);
 }
 
-static std::vector includes(const PreambleData *Preamble) {
-  std::vector Result;
-  if (Preamble)
-for (const auto &Inclusion : Preamble->Includes.MainFileIncludes)
-  Result.push_back(Inclusion.Written);
-  return Result;
-}
-
-TEST_F(TUSchedulerTests, PreambleConsistency) {
-  std::atomic CallbackCount(0);
-  {
-Notification InconsistentReadDone; // Must live longest.
-TUScheduler S(CDB, optsForTest());
-auto Path = testPath("foo.cpp");
-// Schedule two updates (A, B) and two preamble reads (stale, consistent).
-// The stale read should see A, and the consistent read should see B.
-// (We recognize the preambles by their included files).
-auto Inputs = getInputs(Path, "#include ");
-Inputs.Version = "A";
-updateWithCallback(S, Path, Inputs, WantDiagnostics::Yes, [&]() {
-  // This callback runs in between the two preamble updates.
-
-  // This blocks update B, preventing it from winning the race
-  // against the stale read.
-  // If the first read was instead consistent, this would deadlock.
-  InconsistentReadDone.wait();
-  // This delays update B, preventing it from winning a race
-  // against the consistent read. The consistent read sees B
-  // only because it waits for it.
-  // If the second read was stale, it would usually see A.
-  std::this_thread::sleep_for(std::chrono::milliseconds(100));
-});
-Inputs.Contents = "#include ";
-Inputs.Version = "B";
-S.update(Path, Inputs, WantDiagnostics::Yes);
-
-S.runWithPreamble("StaleRead", Path, TUScheduler::Stale,
-  [&](Expected Pre) {
-ASSERT_TRUE(bool(Pre));
-EXPECT_EQ(Pre->Preamble->Version, "A");
-EXPECT_THAT(includes(Pre->Preamble),
-ElementsAre(""));
-InconsistentReadDone.notify();
-++CallbackCount;
-  });
-S.runWithPreamble("ConsistentRead", Path, TUScheduler::Consistent,
-  [&](Expected Pre) {
-ASSERT_TRUE(bool(Pre));
-EXPECT_EQ(Pre->Preamble->Version, "B");
-EXPECT_THAT(includes(Pre->Preamble),
-ElementsAre(""));
-++CallbackCount;
-  });
-  }
-  EXPECT_EQ(2, CallbackCount);
-}
-
 TEST_F(TUSchedulerTests, Cancellation) {
   // We have the following update/read sequence
   //   U0
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "Annotations.h"
 #include "Headers.h"
 
 #include "Compiler.h"
@@ -15,9 +16,13 @@
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Path.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include "gtest/internal/gtest-port.h"
+#include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -136,6 +141,13 @@
   return arg.getKey() == File && arg.getValue() == D;
 }
 
+MATCHER(EqInc, "") {
+  Inclusion Actual = testing::get<0>(arg);
+  Inclusion Expected = testing::get<1>(arg);
+  return std::tie(Actual.HashOffset, Actual.R, Actual.Written) ==
+ std::tie(Expected.HashOffset, Expected.R, Expected.Written);
+}
+
 TEST_F(HeadersTest,

[PATCH] D77335: [AST] clang::VectorType supports any size (that fits in unsigned)

2020-04-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.

still LG.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77335



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


[PATCH] D75430: [analyzer][NFC] Introduce CXXDeallocatorCall, deploy it in MallocChecker

2020-04-03 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 254780.
Szelethus marked 2 inline comments as done.
Szelethus added a comment.
Herald added a subscriber: mgorny.

- Add `PostStmt`
- Add PostCall for `CXXDeallocatorCall`
- Add a unittest, which is kind of pointless as-is, but I realized only later 
that most of the delete operators aren't recognized as `CXXDeleteExpr`
- Add a bunch of `TODO`s about incorrect `CallEvent` types.


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

https://reviews.llvm.org/D75430

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/test/Analysis/cxx-dynamic-memory-analysis-order.cpp
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/CallEventTest.cpp

Index: clang/unittests/StaticAnalyzer/CallEventTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/CallEventTest.cpp
@@ -0,0 +1,89 @@
+//===--===//
+//
+// 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/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "CheckerRegistration.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
+#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ento {
+namespace {
+
+void reportBug(const CheckerBase *Checker, const CallEvent &Call,
+   CheckerContext &C, StringRef WarningMsg) {
+  C.getBugReporter().EmitBasicReport(
+  nullptr, Checker, "", categories::LogicError, WarningMsg,
+  PathDiagnosticLocation(Call.getOriginExpr(), C.getSourceManager(),
+ C.getLocationContext()),
+  {});
+}
+
+class CXXDeallocatorChecker : public Checker {
+  std::unique_ptr BT_uninitField;
+
+public:
+  CXXDeallocatorChecker()
+  : BT_uninitField(new BuiltinBug(this, "CXXDeallocator")) {}
+
+  void checkPreCall(const CallEvent &Call, CheckerContext &C) const {
+const auto *DC = dyn_cast(&Call);
+if (!DC) {
+  return;
+}
+
+SmallString<100> WarningBuf;
+llvm::raw_svector_ostream WarningOS(WarningBuf);
+WarningOS << "NumArgs: " << DC->getNumArgs();
+
+reportBug(this, *DC, C, WarningBuf);
+  }
+};
+
+void addCXXDeallocatorChecker(AnalysisASTConsumer &AnalysisConsumer,
+  AnalyzerOptions &AnOpts) {
+  AnOpts.CheckersAndPackages = {{"test.CXXDeallocator", true}};
+  AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
+Registry.addChecker("test.CXXDeallocator",
+   "Description", "");
+  });
+}
+
+// TODO: What we should really be testing here is all the different varieties
+// of delete operators, and wether the retrieval of their arguments works as
+// intended. At the time of writing this file, CXXDeallocatorCall doesn't pick
+// up on much of those due to the AST not containing CXXDeleteExpr for most of
+// the standard/custom deletes.
+TEST(CXXDeallocatorCall, SimpleDestructor) {
+  std::string Diags;
+  EXPECT_TRUE(runCheckerOnCode(R"(
+struct A {};
+
+void f() {
+  A *a = new A;
+  delete a;
+}
+  )",
+ Diags));
+  EXPECT_EQ(Diags, "test.CXXDeallocator:NumArgs: 1\n");
+}
+
+} // namespace
+} // namespace ento
+} // namespace clang
Index: clang/unittests/StaticAnalyzer/CMakeLists.txt
===
--- clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -5,6 +5,7 @@
 add_clang_unittest(StaticAnalysisTests
   AnalyzerOptionsTest.cpp
   CallDescriptionTest.cpp
+  CallEventTest.cpp
   StoreTest.cpp
   RegisterCustomCheckersTest.cpp
   SymbolReaperTest.cpp
Index: clang/test/Analysis/cxx-dynamic-memor

[PATCH] D75430: [analyzer][NFC] Introduce CXXDeallocatorCall, deploy it in MallocChecker

2020-04-03 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested review of this revision.
Szelethus added a comment.

Since this change had a few blocking issues, I'm placing it back to review for 
greater visibility.




Comment at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:67
   CE_CXXAllocator,
+  CE_CXXDeallocator,
   CE_BEG_FUNCTION_CALLS = CE_Function,

NoQ wrote:
> After this you probably received compiler warnings saying "case isn't covered 
> in switch". You'll need to clean them up.
> 
> Another thing to do would be to update `CallEventManager`'s `getCall()` and 
> `getCaller()` methods that'd allow the users to construct the new `CallEvent` 
> easily without thinking about what specific kind of call event it is.
No, I did not, infuriatingly. I did however get //errors// after trying to make 
a `toString` function for `CallEventKind`, apparently both `CE_CXXDeallocator` 
and `CE_Block` has the value of 7. When I moved the enum, everything was fine, 
and I did get the warnings you mentioned.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:958
+
+  unsigned getNumArgs() const override { return getDecl()->getNumParams(); }
+

steakhal wrote:
> NoQ wrote:
> > Charusso wrote:
> > > `return getOriginExpr()->getNumArgs()`
> > This wouldn't compile. `CXXDeleteExpr` is not a `CallExpr`.
> > 
> > It sounds like there are currently [[ 
> > http://www.cplusplus.com/reference/new/operator%20delete/ | five different 
> > `operator delete`s ]]:
> > {F11474783}
> > 
> > And, unlike `operator new`, there's no option to provide custom "placement" 
> > arguments.
> > 
> > So i think the logic in this patch is correct but we should do some custom 
> > logic for all 5 cases in the `getArgExpr` method, where argument 
> > expressions for the extra arguments will have to be conjured out of thin 
> > air (or we might as well return null).
> > It sounds like there are currently five different `operator delete`s:
> I think it is even worse since C++17 and C++20 introduced a couple of others 
> like:
>  - overloads with `std::align_val_t` parameter (C++17)
>  - overloads with `std::destroying_delete_t` parameter (C++20) which I 
> haven't heard of yet :D
> 
> You can check it in the draft: http://eel.is/c++draft/new.delete
> And of course at cppreference as well: 
> https://en.cppreference.com/w/cpp/memory/new/operator_delete
Okay so here is the biggest issue: non-simple `delete`s don't appear in the AST 
as `CXXDeleteExpr`, but rather as a `CXXOperatorCall`. This is a big problem, 
what could be the reason for it?


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

https://reviews.llvm.org/D75430



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


[PATCH] D76680: [SveEmitter] Add immediate checks for lanes and complex imms

2020-04-03 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

In D76680#1959217 , @SjoerdMeijer 
wrote:

> Looks good to me, but just one question about the tests. If I haven't 
> overlooked anything, I don't see tests that check the new diagnostics:
>  "argument should be the value 90 or 270"
>  "argument should be the value 0,90,180 or 270"
>
> Should they be here, or are they somewhere else?


Good point, I seem to have forgotten to add these tests. I'll update the patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76680



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


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

2020-04-03 Thread George Rimar via Phabricator via cfe-commits
grimar added a comment.

In D77184#1959351 , @andrewng wrote:

> The following patch fixes my issues on Windows, but I haven't tested that it 
> doesn't break anything else:
>
>   diff --git a/llvm/cmake/modules/AddLLVM.cmake 
> b/llvm/cmake/modules/AddLLVM.cmake
>   index 91bec7d8081..f630af211fd 100644
>   --- a/llvm/cmake/modules/AddLLVM.cmake
>   +++ b/llvm/cmake/modules/AddLLVM.cmake
>   @@ -1495,7 +1495,7 @@ function(configure_lit_site_cfg site_in site_out)
>string(REPLACE ";" "\\;" ARG_PATH_VALUES_ESCAPED "${ARG_PATH_VALUES}")
>get_filename_component(OUTPUT_DIR ${site_out} DIRECTORY)
>execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
>   -  "import os, sys; sys.stdout.write(';'.join(os.path.relpath(p, 
> sys.argv[1]).replace(os.sep, '/') if p else '' for p in 
> sys.argv[2].split(';')))"
>   +  "import os, sys; drive = os.path.splitdrive(sys.argv[1])[0]; 
> sys.stdout.write(';'.join('' if not p else p if os.path.splitdrive(p)[0] != 
> drive else os.path.relpath(p, sys.argv[1]).replace(os.sep, '/') for p in 
> sys.argv[2].split(';')))"
>  ${OUTPUT_DIR}
>  ${ARG_PATH_VALUES_ESCAPED}
>  OUTPUT_VARIABLE ARG_PATH_VALUES_RELATIVE)
>


This helped me, thanks for posting this! (I've just updated and faced the build 
issue on windows. Seems it doesn't like that I build it on `D:` drive)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77184



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


[PATCH] D77393: [X86] Fix implicit sign conversion warnings in X86 headers.

2020-04-03 Thread pierre gousseau via Phabricator via cfe-commits
pgousseau created this revision.
pgousseau added reviewers: craig.topper, probinson, filcab.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Warnings in emmintrin.h and xmmintrin.h are reported by 
-fsanitize=implicit-integer-sign-change


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77393

Files:
  clang/lib/Headers/emmintrin.h
  clang/lib/Headers/xmmintrin.h
  clang/test/Headers/warn-cleanup.c

Index: clang/test/Headers/warn-cleanup.c
===
--- /dev/null
+++ clang/test/Headers/warn-cleanup.c
@@ -0,0 +1,43 @@
+// Fix sign conversion warnings found by fsanitize=implicit-integer-sign-change
+// in intrinsic headers.
+// Preprocess file to workaround no warnings in system headers.
+// RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -ffreestanding -E 2>&1 \
+// RUN: | %clang_cc1 -x c - -triple x86_64-pc-linux-gnu -ffreestanding -Wsign-conversion %s 2>&1 \
+// RUN: | FileCheck --allow-empty %s
+// REQUIRES: x86-registered-target
+
+#include 
+#include 
+
+void test() {
+  // CHECK-NOT: warning:
+  _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
+  _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_OFF);
+  _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_MASK);
+
+  _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_INVALID);
+  _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_DENORM);
+  _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_DIV_ZERO);
+  _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_OVERFLOW);
+  _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_UNDERFLOW);
+  _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_INEXACT);
+  _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_MASK);
+
+  _MM_SET_EXCEPTION_MASK(_MM_MASK_INVALID);
+  _MM_SET_EXCEPTION_MASK(_MM_MASK_DENORM);
+  _MM_SET_EXCEPTION_MASK(_MM_MASK_DIV_ZERO);
+  _MM_SET_EXCEPTION_MASK(_MM_MASK_OVERFLOW);
+  _MM_SET_EXCEPTION_MASK(_MM_MASK_UNDERFLOW);
+  _MM_SET_EXCEPTION_MASK(_MM_MASK_INEXACT);
+  _MM_SET_EXCEPTION_MASK(_MM_MASK_MASK);
+
+  _MM_SET_ROUNDING_MODE(_MM_ROUND_NEAREST);
+  _MM_SET_ROUNDING_MODE(_MM_ROUND_DOWN);
+  _MM_SET_ROUNDING_MODE(_MM_ROUND_UP);
+  _MM_SET_ROUNDING_MODE(_MM_ROUND_TOWARD_ZERO);
+  _MM_SET_ROUNDING_MODE(_MM_ROUND_MASK);
+
+  _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_MASK);
+  _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
+  _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_OFF);
+}
Index: clang/lib/Headers/xmmintrin.h
===
--- clang/lib/Headers/xmmintrin.h
+++ clang/lib/Headers/xmmintrin.h
@@ -2931,31 +2931,31 @@
 
 #define _MM_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w))
 
-#define _MM_EXCEPT_INVALID(0x0001)
-#define _MM_EXCEPT_DENORM (0x0002)
-#define _MM_EXCEPT_DIV_ZERO   (0x0004)
-#define _MM_EXCEPT_OVERFLOW   (0x0008)
-#define _MM_EXCEPT_UNDERFLOW  (0x0010)
-#define _MM_EXCEPT_INEXACT(0x0020)
-#define _MM_EXCEPT_MASK   (0x003f)
-
-#define _MM_MASK_INVALID  (0x0080)
-#define _MM_MASK_DENORM   (0x0100)
-#define _MM_MASK_DIV_ZERO (0x0200)
-#define _MM_MASK_OVERFLOW (0x0400)
-#define _MM_MASK_UNDERFLOW(0x0800)
-#define _MM_MASK_INEXACT  (0x1000)
-#define _MM_MASK_MASK (0x1f80)
-
-#define _MM_ROUND_NEAREST (0x)
-#define _MM_ROUND_DOWN(0x2000)
-#define _MM_ROUND_UP  (0x4000)
-#define _MM_ROUND_TOWARD_ZERO (0x6000)
-#define _MM_ROUND_MASK(0x6000)
-
-#define _MM_FLUSH_ZERO_MASK   (0x8000)
-#define _MM_FLUSH_ZERO_ON (0x8000)
-#define _MM_FLUSH_ZERO_OFF(0x)
+#define _MM_EXCEPT_INVALID(0x0001U)
+#define _MM_EXCEPT_DENORM (0x0002U)
+#define _MM_EXCEPT_DIV_ZERO   (0x0004U)
+#define _MM_EXCEPT_OVERFLOW   (0x0008U)
+#define _MM_EXCEPT_UNDERFLOW  (0x0010U)
+#define _MM_EXCEPT_INEXACT(0x0020U)
+#define _MM_EXCEPT_MASK   (0x003fU)
+
+#define _MM_MASK_INVALID  (0x0080U)
+#define _MM_MASK_DENORM   (0x0100U)
+#define _MM_MASK_DIV_ZERO (0x0200U)
+#define _MM_MASK_OVERFLOW (0x0400U)
+#define _MM_MASK_UNDERFLOW(0x0800U)
+#define _MM_MASK_INEXACT  (0x1000U)
+#define _MM_MASK_MASK (0x1f80U)
+
+#define _MM_ROUND_NEAREST (0xU)
+#define _MM_ROUND_DOWN(0x2000U)
+#define _MM_ROUND_UP  (0x4000U)
+#define _MM_ROUND_TOWARD_ZERO (0x6000U)
+#define _MM_ROUND_MASK(0x6000U)
+
+#define _MM_FLUSH_ZERO_MASK   (0x8000U)
+#define _MM_FLUSH_ZERO_ON (0x8000U)
+#define _MM_FLUSH_ZERO_OFF(0xU)
 
 #define _MM_GET_EXCEPTION_MASK() (_mm_getcsr() & _MM_MASK_MASK)
 #define _MM_GET_EXCEPTION_STATE() (_mm_getcsr() & _MM_EXCEPT_MASK)
Index: clang/lib/Headers/emmintrin.h
===
--- clang/lib/Headers/emmintrin.h
+++ clang/lib/Headers/emmintrin.h
@@ -4970,10 +4970,10 @@
 
 #define _MM_SHUFFLE2(x, y) (((x) << 1) | (y))
 
-#define _MM_DENORMALS_ZERO_ON   (0x0040)
-#define _MM_DENORMALS_ZERO_OFF  (0x)
+#define _MM_DENORMALS_ZERO_ON   (0x0040U)
+#define _MM_DENORMALS_ZERO_OFF  (0xU)
 
-#define _MM_DENORMALS_ZERO_MASK (0x0040)
+#define _MM_DENOR

[PATCH] D77355: [clangd] show layout info when hovering on a class/field definition.

2020-04-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 254786.
sammccall marked 5 inline comments as done.
sammccall added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77355

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -66,7 +66,7 @@
   {R"cpp(
   namespace ns1 { namespace ns2 {
 struct Foo {
-  int [[b^ar]];
+  char [[b^ar]];
 };
   }}
   )cpp",
@@ -75,8 +75,10 @@
  HI.LocalScope = "Foo::";
  HI.Name = "bar";
  HI.Kind = index::SymbolKind::Field;
- HI.Definition = "int bar";
- HI.Type = "int";
+ HI.Definition = "char bar";
+ HI.Type = "char";
+ HI.Offset = 0;
+ HI.Size = 1;
}},
   // Local to class method.
   {R"cpp(
@@ -100,7 +102,7 @@
   {R"cpp(
   namespace ns1 { namespace {
 struct {
-  int [[b^ar]];
+  char [[b^ar]];
 } T;
   }}
   )cpp",
@@ -109,8 +111,21 @@
  HI.LocalScope = "(anonymous struct)::";
  HI.Name = "bar";
  HI.Kind = index::SymbolKind::Field;
- HI.Definition = "int bar";
- HI.Type = "int";
+ HI.Definition = "char bar";
+ HI.Type = "char";
+ HI.Offset = 0;
+ HI.Size = 1;
+   }},
+  // Struct definition shows size.
+  {R"cpp(
+  struct [[^X]]{};
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "X";
+ HI.Kind = index::SymbolKind::Struct;
+ HI.Definition = "struct X {}";
+ HI.Size = 1;
}},
   // Variable with template type
   {R"cpp(
@@ -646,6 +661,8 @@
 EXPECT_EQ(H->TemplateParameters, Expected.TemplateParameters);
 EXPECT_EQ(H->SymRange, Expected.SymRange);
 EXPECT_EQ(H->Value, Expected.Value);
+EXPECT_EQ(H->Size, Expected.Size);
+EXPECT_EQ(H->Offset, Expected.Offset);
   }
 }
 
@@ -1810,6 +1827,7 @@
   {
   [](HoverInfo &HI) {
 HI.Kind = index::SymbolKind::Class;
+HI.Size = 10;
 HI.TemplateParameters = {
 {std::string("typename"), std::string("T"), llvm::None},
 {std::string("typename"), std::string("C"),
@@ -1823,6 +1841,7 @@
   },
   R"(class foo
 
+Size: 10 bytes
 documentation
 
 template  class Foo {})",
@@ -1859,19 +1878,23 @@
   },
   {
   [](HoverInfo &HI) {
-HI.Kind = index::SymbolKind::Variable;
-HI.LocalScope = "test::bar::";
+HI.Kind = index::SymbolKind::Field;
+HI.LocalScope = "test::Bar::";
 HI.Value = "value";
 HI.Name = "foo";
 HI.Type = "type";
 HI.Definition = "def";
+HI.Size = 4;
+HI.Offset = 12;
   },
-  R"(variable foo
+  R"(field foo
 
 Type: type
 Value = value
+Offset: 12 bytes
+Size: 4 bytes
 
-// In test::bar
+// In test::Bar
 def)",
   },
   };
Index: clang-tools-extra/clangd/Hover.h
===
--- clang-tools-extra/clangd/Hover.h
+++ clang-tools-extra/clangd/Hover.h
@@ -70,6 +70,10 @@
   llvm::Optional> TemplateParameters;
   /// Contains the evaluated value of the symbol if available.
   llvm::Optional Value;
+  /// Contains the byte-size of fields and types where it's interesting.
+  llvm::Optional Size;
+  /// Contains the offset of fields within the enclosing class.
+  llvm::Optional Offset;
 
   /// Produce a user-readable information.
   markup::Document present() const;
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -563,6 +563,28 @@
  isFollowedByHardLineBreakIndicator(Str, LineBreakIndex);
 }
 
+void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) {
+  const auto &Ctx = ND.getASTContext();
+
+  if (auto *RD = llvm::dyn_cast(&ND)) {
+if (auto Size = Ctx.getTypeSizeInCharsIfKnown(RD->getTypeForDecl()))
+  HI.Size = Size->getQuantity();
+return;
+  }
+
+  if (const auto *FD = llvm::dyn_cast(&ND)) {
+const auto *Record = FD->getParent()->getDefinition();
+if (Record && !Record->isDependentType()) {
+  uint64_t OffsetBits = Ctx.getFieldOffset(FD);
+  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) {
+HI.Size = Size->getQuantity();
+HI.Offset = OffsetBits / 8;
+  }
+}
+retur

[PATCH] D77355: [clangd] show layout info when hovering on a class/field definition.

2020-04-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:69
 struct Foo {
-  int [[b^ar]];
+  char [[b^ar]];
 };

kadircet wrote:
> any reason for changing these from int to char ?
hardcoding sizeof(int) isn't portable unless we want to set the target 
explicitly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77355



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


[PATCH] D77209: [Syntax] Add mapping from spelled to expanded tokens for TokenBuffer

2020-04-03 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:239
+
+  auto It = llvm::partition_point(F.Mappings, [SpelledI](const Mapping &M) {
+return M.BeginSpelled <= SpelledI;

It would be great to add an is_sorted assertion to the builder to check 
ordering of mappings based on both spelled and expanded token indices.



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:259
+  const MarkedFile &File = It->second;
+  // assert that Spelled is a subarray of File.SpelledTokens.
+  assert(File.SpelledTokens.data() <= Spelled.data());

s/subarray/subrange/

Also no need to repeat "assert".

"`Spelled` must be a subrange of `File.SpelledTokens`."



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:261
+  assert(File.SpelledTokens.data() <= Spelled.data());
+  assert(Spelled.size() <= File.SpelledTokens.size());
+

I think we can improve the precision of this assertion. Comparing the sizes 
does not ensure that we really have a subrange. I think the second assert 
should be comparing end pointers instead of sizes. Something like:

`assert(&Spelled.back() <= &File.SpelledTokens.back());`



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:264
+  auto *FrontMapping = mappingStartingBeforeSpelled(File, &Spelled.front());
+  unsigned SpelledFrontI = &Spelled.front() - File.SpelledTokens.data();
+  unsigned ExpandedBegin;

Or assert that SpelledFrontI is less than File.SpelledTokens.size().


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77209



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


[PATCH] D77348: [clangd] Enable some nice clang-tidy checks by default.

2020-04-03 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG164ed7b1d044: [clangd] Enable some nice clang-tidy checks by 
default. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D77348?vs=254650&id=254789#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77348

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -691,18 +691,42 @@
   std::unique_ptr
   ClangTidyOptProvider; /*GUARDED_BY(ClangTidyOptMu)*/
   if (EnableClangTidy) {
-auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
-OverrideClangTidyOptions.Checks = ClangTidyChecks;
+auto EmptyDefaults = tidy::ClangTidyOptions::getDefaults();
+EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
+tidy::ClangTidyOptions OverrideClangTidyOptions;
+if (!ClangTidyChecks.empty())
+  OverrideClangTidyOptions.Checks = ClangTidyChecks;
 ClangTidyOptProvider = std::make_unique(
 tidy::ClangTidyGlobalOptions(),
-/* Default */ tidy::ClangTidyOptions::getDefaults(),
+/* Default */ EmptyDefaults,
 /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
 Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,
llvm::StringRef File) {
   // This function must be thread-safe and tidy option providers are not.
-  std::lock_guard Lock(ClangTidyOptMu);
-  // FIXME: use the FS provided to the function.
-  return ClangTidyOptProvider->getOptions(File);
+  tidy::ClangTidyOptions Opts;
+  {
+std::lock_guard Lock(ClangTidyOptMu);
+// FIXME: use the FS provided to the function.
+Opts = ClangTidyOptProvider->getOptions(File);
+  }
+  if (!Opts.Checks) {
+// If the user hasn't configured clang-tidy checks at all, including
+// via .clang-tidy, give them a nice set of checks.
+// (This should be what the "default" options does, but it isn't...)
+//
+// These default checks are chosen for:
+//  - low false-positive rate
+//  - providing a lot of value
+//  - being reasonably efficient
+Opts.Checks = llvm::join_items(
+",", "readability-misleading-indentation",
+"readability-deleted-default", "bugprone-integer-division",
+"bugprone-sizeof-expression", "bugprone-suspicious-missing-comma",
+"bugprone-unused-raii", "bugprone-unused-return-value",
+"misc-unused-using-decls", "misc-unused-alias-decls",
+"misc-definitions-in-headers");
+  }
+  return Opts;
 };
   }
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -691,18 +691,42 @@
   std::unique_ptr
   ClangTidyOptProvider; /*GUARDED_BY(ClangTidyOptMu)*/
   if (EnableClangTidy) {
-auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
-OverrideClangTidyOptions.Checks = ClangTidyChecks;
+auto EmptyDefaults = tidy::ClangTidyOptions::getDefaults();
+EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
+tidy::ClangTidyOptions OverrideClangTidyOptions;
+if (!ClangTidyChecks.empty())
+  OverrideClangTidyOptions.Checks = ClangTidyChecks;
 ClangTidyOptProvider = std::make_unique(
 tidy::ClangTidyGlobalOptions(),
-/* Default */ tidy::ClangTidyOptions::getDefaults(),
+/* Default */ EmptyDefaults,
 /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
 Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,
llvm::StringRef File) {
   // This function must be thread-safe and tidy option providers are not.
-  std::lock_guard Lock(ClangTidyOptMu);
-  // FIXME: use the FS provided to the function.
-  return ClangTidyOptProvider->getOptions(File);
+  tidy::ClangTidyOptions Opts;
+  {
+std::lock_guard Lock(ClangTidyOptMu);
+// FIXME: use the FS provided to the function.
+Opts = ClangTidyOptProvider->getOptions(File);
+  }
+  if (!Opts.Checks) {
+// If the user hasn't configured clang-tidy checks at all, including
+// via .clang-tidy, give them a nice set of checks.
+// (This should be what the "default" options does, but it isn't...)
+//
+// These default checks are chosen for:
+//  - low false-positive rate
+//  - providing a lot 

[PATCH] D77355: [clangd] show layout info when hovering on a class/field definition.

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

thanks!




Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:69
 struct Foo {
-  int [[b^ar]];
+  char [[b^ar]];
 };

sammccall wrote:
> kadircet wrote:
> > any reason for changing these from int to char ?
> hardcoding sizeof(int) isn't portable unless we want to set the target 
> explicitly
right, the test already sets the target though.

I suppose relying less on it is better, so feel free to keep it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77355



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


[PATCH] D77395: [AST] Dont invalidate VarDecl even the default initializaiton is failed.

2020-04-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
hokein edited the summary of this revision.
hokein edited the summary of this revision.
hokein added a reviewer: sammccall.
hokein retitled this revision from "[AST] Dont invalide VarDecl even the 
default initializaiton is failed." to "[AST] Dont invalidate VarDecl even the 
default initializaiton is failed.".

This patch would cause clang emit more diagnostics, but it is much better than 
https://reviews.llvm.org/D76831

  cpp
  struct A {
A(int);
~A() = delete;
  };
  void k() {
A a;
  }

before the patch:

  /tmp/t3.cpp:24:5: error: no matching constructor for initialization of 'A'
A a;
  ^
  /tmp/t3.cpp:20:3: note: candidate constructor not viable: requires 1 
argument, but 0 were provided
A(int);
^
  /tmp/t3.cpp:19:8: note: candidate constructor (the implicit copy constructor) 
not viable: requires 1 argument, but 0 were provided
  struct A {

After the patch:

  /tmp/t3.cpp:24:5: error: no matching constructor for initialization of 'A'
A a;
  ^
  /tmp/t3.cpp:20:3: note: candidate constructor not viable: requires 1 
argument, but 0 were provided
A(int);
^
  /tmp/t3.cpp:19:8: note: candidate constructor (the implicit copy constructor) 
not viable: requires 1 argument, but 0 were provided
  struct A {
 ^
  /tmp/t3.cpp:24:5: error: attempt to use a deleted function
A a;
  ^
  /tmp/t3.cpp:21:3: note: '~A' has been explicitly marked deleted here
~A() = delete;


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77395

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/ast-dump-invalid-initialized.cpp
  clang/test/CXX/class.access/p4.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/special/class.ctor/p5-0x.cpp
  clang/test/CodeCompletion/invalid-initialized-class.cpp
  clang/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
  clang/test/SemaObjCXX/arc-0x.mm

Index: clang/test/SemaObjCXX/arc-0x.mm
===
--- clang/test/SemaObjCXX/arc-0x.mm
+++ clang/test/SemaObjCXX/arc-0x.mm
@@ -116,13 +116,13 @@
   // Implicitly-declared special functions of a union are deleted by default if
   // ARC is enabled and the union has an ObjC pointer field.
   union U0 {
-id f0; // expected-note 6 {{'U0' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+id f0; // expected-note 7 {{'U0' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
   };
 
   union U1 {
-__weak id f0; // expected-note 12 {{'U1' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+__weak id f0; // expected-note 13 {{'U1' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
 U1() = default; // expected-warning {{explicitly defaulted default constructor is implicitly deleted}} expected-note {{explicitly defaulted function was implicitly deleted here}}
-~U1() = default; // expected-warning {{explicitly defaulted destructor is implicitly deleted}} expected-note {{explicitly defaulted function was implicitly deleted here}}
+~U1() = default; // expected-warning {{explicitly defaulted destructor is implicitly deleted}} expected-note 2{{explicitly defaulted function was implicitly deleted here}}
 U1(const U1 &) = default; // expected-warning {{explicitly defaulted copy constructor is implicitly deleted}} expected-note 2 {{explicitly defaulted function was implicitly deleted here}}
 U1(U1 &&) = default; // expected-warning {{explicitly defaulted move constructor is implicitly deleted}}
 U1 & operator=(const U1 &) = default; // expected-warning {{explicitly defaulted copy assignment operator is implicitly deleted}} expected-note 2 {{explicitly defaulted function was implicitly deleted here}}
@@ -154,15 +154,15 @@
   // functions of the containing class.
   struct S0 {
 union {
-  id f0; // expected-note 6 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+  id f0; // expected-note 7 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
   char f1;
 };
   };
 
   struct S1 {
 union {
-  union { // expected-note 2 {{'S1' is implicitly deleted because variant field '' has a non-trivial}} expected-note 4 {{'S1' is implicitly deleted because field '' has a deleted}}
-id f0; // expected-note 2 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+  union { // expected-note 2 {{'S1' is implicitly deleted because variant field '' has a non-trivial}} expected-note 5 {{'S1' is implicitly deleted because field '' has a deleted}}
+id f0; // expected-note 3 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
 char f1;
   };
   int f2;
@@ -172,7 +172,7 @@
   struct S2 {
 union {
   // FIXME: the note should say 'f0' is causing the special functions to be deleted.
-  st

[PATCH] D77398: [cuda][hip] Fix `RegisterVar` function prototype.

2020-04-03 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added reviewers: tra, yaxunl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- `RegisterVar` has `void` return type and `size_t` in its variable size 
parameter in HIP or CUDA 9.0+.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77398

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/test/CodeGenCUDA/device-stub.cu


Index: clang/test/CodeGenCUDA/device-stub.cu
===
--- clang/test/CodeGenCUDA/device-stub.cu
+++ clang/test/CodeGenCUDA/device-stub.cu
@@ -181,10 +181,10 @@
 // Test that we've built a function to register kernels and global vars.
 // ALL: define internal void @__[[PREFIX]]_register_globals
 // ALL: call{{.*}}[[PREFIX]]RegisterFunction(i8** %0, 
{{.*}}kernelfunc{{[^,]*}}, {{[^@]*}}@0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}device_var{{[^,]*}}, {{[^@]*}}@1, {{.*}}i32 0, i32 4, i32 0, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}constant_var{{[^,]*}}, {{[^@]*}}@2, {{.*}}i32 0, i32 4, i32 1, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_device_var_def{{[^,]*}}, {{[^@]*}}@3, {{.*}}i32 0, i32 4, i32 0, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_constant_var_def{{[^,]*}}, {{[^@]*}}@4, {{.*}}i32 0, i32 4, i32 1, 
i32 0
+// ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}device_var{{[^,]*}}, {{[^@]*}}@1, {{.*}}i32 0, {{i32|i64}} 4, i32 0, i32 0
+// ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}constant_var{{[^,]*}}, {{[^@]*}}@2, {{.*}}i32 0, {{i32|i64}} 4, i32 1, 
i32 0
+// ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_device_var_def{{[^,]*}}, {{[^@]*}}@3, {{.*}}i32 0, {{i32|i64}} 4, i32 
0, i32 0
+// ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_constant_var_def{{[^,]*}}, {{[^@]*}}@4, {{.*}}i32 0, {{i32|i64}} 4, 
i32 1, i32 0
 // ALL: ret void
 
 // Test that we've built a constructor.
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -440,13 +440,19 @@
 Builder.CreateCall(RegisterFunc, Args);
   }
 
+  llvm::Type *VarSizeTy = IntTy;
+  // For HIP or CUDA 9.0+, device variable size is type of `size_t`.
+  if (CGM.getLangOpts().HIP ||
+  ToCudaVersion(CGM.getTarget().getSDKVersion()) >= CudaVersion::CUDA_90)
+VarSizeTy = SizeTy;
+
   // void __cudaRegisterVar(void **, char *, char *, const char *,
   //int, int, int, int)
   llvm::Type *RegisterVarParams[] = {VoidPtrPtrTy, CharPtrTy, CharPtrTy,
- CharPtrTy,IntTy, IntTy,
+ CharPtrTy,IntTy, VarSizeTy,
  IntTy,IntTy};
   llvm::FunctionCallee RegisterVar = CGM.CreateRuntimeFunction(
-  llvm::FunctionType::get(IntTy, RegisterVarParams, false),
+  llvm::FunctionType::get(VoidTy, RegisterVarParams, false),
   addUnderscoredPrefixToName("RegisterVar"));
   // void __cudaRegisterSurface(void **, const struct surfaceReference *,
   //const void **, const char *, int, int);
@@ -476,7 +482,7 @@
   VarName,
   VarName,
   llvm::ConstantInt::get(IntTy, Info.Flags.isExtern()),
-  llvm::ConstantInt::get(IntTy, VarSize),
+  llvm::ConstantInt::get(VarSizeTy, VarSize),
   llvm::ConstantInt::get(IntTy, Info.Flags.isConstant()),
   llvm::ConstantInt::get(IntTy, 0)};
   Builder.CreateCall(RegisterVar, Args);
Index: clang/lib/Basic/Cuda.cpp
===
--- clang/lib/Basic/Cuda.cpp
+++ clang/lib/Basic/Cuda.cpp
@@ -365,7 +365,7 @@
   }
 }
 
-static CudaVersion ToCudaVersion(llvm::VersionTuple Version) {
+CudaVersion ToCudaVersion(llvm::VersionTuple Version) {
   int IVer =
   Version.getMajor() * 10 + Version.getMinor().getValueOr(0);
   switch(IVer) {
Index: clang/include/clang/Basic/Cuda.h
===
--- clang/include/clang/Basic/Cuda.h
+++ clang/include/clang/Basic/Cuda.h
@@ -118,6 +118,7 @@
   CUDA_USES_FATBIN_REGISTER_END,
 };
 
+CudaVersion ToCudaVersion(llvm::VersionTuple);
 bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
 bool CudaFeatureEnabled(CudaVersion, CudaFeature);
 


Index: clang/test/CodeGenCUDA/device-stub.cu
===
--- clang/test/CodeGenCUDA/device-stub.cu
+++ clang/test/CodeGenCUDA/device-stub.cu
@@ -181,10 +181,10 @@
 // Test that we've built a function to register kernels and global vars.
 // ALL: define internal void @__[[PREFIX]]_register_globals
 // ALL: call{{.*}}[[PREFIX]]RegisterFunction(i8** %0, {{.*}}kerne

[PATCH] D77393: [X86] Fix implicit sign conversion warnings in X86 headers.

2020-04-03 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a reviewer: RKSimon.
RKSimon added a comment.

Rename test file to x86-header-warnings.c or something similarly specific?




Comment at: clang/test/Headers/warn-cleanup.c:10
+#include 
+#include 
+

Use x8intrin.h directly so its easier to expand in the future?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77393



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


[PATCH] D77398: [cuda][hip] Fix `RegisterVar` function prototype.

2020-04-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77398



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


[PATCH] D77390: Fix __builtin_amdgcn_workgroup_size_x/y/z return type

2020-04-03 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

LGTM


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

https://reviews.llvm.org/D77390



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


[clang] 88fbadd - [AST] clang::VectorType supports any size (that fits in unsigned)

2020-04-03 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-04-03T17:30:31+02:00
New Revision: 88fbadd0f5d50ea1d310fb63da6da15b82a9be05

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

LOG: [AST] clang::VectorType supports any size (that fits in unsigned)

Summary:
This matches llvm::VectorType.
It moves the size from the type bitfield into VectorType, increasing size by 8
bytes (including padding of 4). This is OK as we don't expect to create terribly
many of these types.

c.f. D77313 which enables large power-of-two sizes without growing VectorType.

Reviewers: efriedma, hokein

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/Type.h
clang/lib/Sema/SemaType.cpp
clang/test/Sema/types.c
clang/test/SemaCXX/vector.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 5d2c035ea0fe..f78d9d7670a7 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1650,11 +1650,8 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
 /// The kind of vector, either a generic vector type or some
 /// target-specific vector type such as for AltiVec or Neon.
 unsigned VecKind : 3;
-
 /// The number of elements in the vector.
-unsigned NumElements : 29 - NumTypeBits;
-
-enum { MaxNumElements = (1 << (29 - NumTypeBits)) - 1 };
+uint32_t NumElements;
   };
 
   class AttributedTypeBitfields {
@@ -3249,10 +3246,6 @@ class VectorType : public Type, public 
llvm::FoldingSetNode {
   QualType getElementType() const { return ElementType; }
   unsigned getNumElements() const { return VectorTypeBits.NumElements; }
 
-  static bool isVectorSizeTooLarge(unsigned NumElements) {
-return NumElements > VectorTypeBitfields::MaxNumElements;
-  }
-
   bool isSugared() const { return false; }
   QualType desugar() const { return QualType(this, 0); }
 

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index e128ebf31270..49a5dcbe0c79 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -2436,28 +2436,34 @@ QualType Sema::BuildVectorType(QualType CurType, Expr 
*SizeExpr,
 return Context.getDependentVectorType(CurType, SizeExpr, AttrLoc,
VectorType::GenericVector);
 
-  unsigned VectorSize = static_cast(VecSize.getZExtValue() * 8);
+  // vecSize is specified in bytes - convert to bits.
+  if (!VecSize.isIntN(61)) {
+// Bit size will overflow uint64.
+Diag(AttrLoc, diag::err_attribute_size_too_large)
+<< SizeExpr->getSourceRange();
+return QualType();
+  }
+  uint64_t VectorSizeBits = VecSize.getZExtValue() * 8;
   unsigned TypeSize = static_cast(Context.getTypeSize(CurType));
 
-  if (VectorSize == 0) {
+  if (VectorSizeBits == 0) {
 Diag(AttrLoc, diag::err_attribute_zero_size) << SizeExpr->getSourceRange();
 return QualType();
   }
 
-  // vecSize is specified in bytes - convert to bits.
-  if (VectorSize % TypeSize) {
+  if (VectorSizeBits % TypeSize) {
 Diag(AttrLoc, diag::err_attribute_invalid_size)
 << SizeExpr->getSourceRange();
 return QualType();
   }
 
-  if (VectorType::isVectorSizeTooLarge(VectorSize / TypeSize)) {
+  if (VectorSizeBits / TypeSize > std::numeric_limits::max()) {
 Diag(AttrLoc, diag::err_attribute_size_too_large)
 << SizeExpr->getSourceRange();
 return QualType();
   }
 
-  return Context.getVectorType(CurType, VectorSize / TypeSize,
+  return Context.getVectorType(CurType, VectorSizeBits / TypeSize,
VectorType::GenericVector);
 }
 
@@ -2489,6 +2495,11 @@ QualType Sema::BuildExtVectorType(QualType T, Expr 
*ArraySize,
   return QualType();
 }
 
+if (!vecSize.isIntN(32)) {
+  Diag(AttrLoc, diag::err_attribute_size_too_large)
+  << ArraySize->getSourceRange();
+  return QualType();
+}
 // Unlike gcc's vector_size attribute, the size is specified as the
 // number of elements, not the number of bytes.
 unsigned vectorSize = static_cast(vecSize.getZExtValue());
@@ -2499,12 +2510,6 @@ QualType Sema::BuildExtVectorType(QualType T, Expr 
*ArraySize,
   return QualType();
 }
 
-if (VectorType::isVectorSizeTooLarge(vectorSize)) {
-  Diag(AttrLoc, diag::err_attribute_size_too_large)
-<< ArraySize->getSourceRange();
-  return QualType();
-}
-
 return Context.getExtVectorType(T, vectorSize);
   }
 

diff  --git a/clang/test/Sema/types.c b/clang/test/Sema/types.c
index 8869b3427dc5..177e5fbd9704 100644
--- a/clang/test/Sema/types.c
+++ b/clang/test/Sema/types.c
@@ -69,9 +69,15 @@ void test2(int i) {
   char c = (char __attribute__((may_alias))) i;
 }
 
-

[PATCH] D73245: Avoid using std::max_align_t in pre-C++11 mode

2020-04-03 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

ping2

Louis, did I answer your questions?


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

https://reviews.llvm.org/D73245



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


[PATCH] D77408: [clang] Annotate trivial getters and setters on hover.

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

(Only if their definitions are visible and they have no other docs)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77408

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -616,6 +616,58 @@
  HI.LocalScope = "foo::";
  HI.Type = "int";
}},
+
+  {// Getter
+   R"cpp(
+  struct X { int Y; float [[^y]]() { return Y; } };
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "y";
+ HI.Kind = index::SymbolKind::InstanceMethod;
+ HI.NamespaceScope = "";
+ HI.Definition = "float y()";
+ HI.LocalScope = "X::";
+ HI.Documentation = "Trivial accessor for `Y`.";
+ HI.Type = "float ()";
+ HI.ReturnType = "float";
+ HI.Parameters.emplace();
+   }},
+  {// Setter
+   R"cpp(
+  struct X { int Y; void [[^setY]](float v) { Y = v; } };
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "setY";
+ HI.Kind = index::SymbolKind::InstanceMethod;
+ HI.NamespaceScope = "";
+ HI.Definition = "void setY(float v)";
+ HI.LocalScope = "X::";
+ HI.Documentation = "Trivial setter for `Y`.";
+ HI.Type = "void (float)";
+ HI.ReturnType = "void";
+ HI.Parameters.emplace();
+ HI.Parameters->emplace_back();
+ HI.Parameters->back().Type = "float";
+ HI.Parameters->back().Name = "v";
+   }},
+  {// Setter (builder)
+   R"cpp(
+  struct X { int Y; X& [[^setY]](float v) { Y = v; return *this; } };
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "setY";
+ HI.Kind = index::SymbolKind::InstanceMethod;
+ HI.NamespaceScope = "";
+ HI.Definition = "X &setY(float v)";
+ HI.LocalScope = "X::";
+ HI.Documentation = "Trivial setter for `Y`.";
+ HI.Type = "struct X &(float)";
+ HI.ReturnType = "struct X &";
+ HI.Parameters.emplace();
+ HI.Parameters->emplace_back();
+ HI.Parameters->back().Type = "float";
+ HI.Parameters->back().Name = "v";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -21,9 +21,11 @@
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/OperationKinds.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/SourceLocation.h"
@@ -370,6 +372,95 @@
   return llvm::None;
 }
 
+llvm::Optional fieldName(const Expr *E) {
+  const auto *ReturnedMember = llvm::dyn_cast(E->IgnoreCasts());
+  const auto *Field =
+  llvm::dyn_cast(ReturnedMember->getMemberDecl());
+  if (!Field || !Field->getDeclName().isIdentifier())
+return llvm::None;
+  return Field->getDeclName().getAsIdentifierInfo()->getName();
+}
+
+// If CMD is of the form T foo() { return FieldName; } then returns "FieldName".
+llvm::Optional getterVariableName(const CXXMethodDecl *CMD) {
+  assert(CMD->hasBody());
+  if (CMD->getNumParams() != 0 || CMD->isVariadic())
+return llvm::None;
+  const auto *Body = llvm::dyn_cast(CMD->getBody());
+  const auto *OnlyReturn = (Body && Body->size() == 1)
+   ? llvm::dyn_cast(Body->body_front())
+   : nullptr;
+  if (!OnlyReturn || !OnlyReturn->getRetValue())
+return llvm::None;
+  return fieldName(OnlyReturn->getRetValue());
+}
+
+// If CMD is one of the forms:
+//   void foo(T arg) { FieldName = arg; }
+//   R foo(T arg) { FieldName = arg; return *this; }
+// then returns "FieldName"
+llvm::Optional setterVariableName(const CXXMethodDecl *CMD) {
+  assert(CMD->hasBody());
+  if (CMD->isConst() || CMD->getNumParams() != 1 || CMD->isVariadic())
+return llvm::None;
+  const ParmVarDecl *Arg = CMD->getParamDecl(0);
+  if (Arg->isParameterPack())
+return llvm::None;
+
+  const auto *Body = llvm::dyn_cast(CMD->getBody());
+  if (!Body || Body->size() == 0 || Body->size() > 2)
+return llvm::None;
+  // If the second statement exists, it must be `return this` or `return *this`.
+  if (Body->size() == 2) {
+auto *Ret = llvm::dyn_cast(Body->body_back());
+if (!Ret || !Ret->getRetValue())
+

[PATCH] D75431: [analyzer][NFC] Merge checkNewAllocator's paramaters into CXXAllocatorCall

2020-04-03 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 254816.
Szelethus marked 2 inline comments as done.
Szelethus added a comment.
Herald added a subscriber: ASDenysPetrov.

Inlines addressed, rebase.


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

https://reviews.llvm.org/D75431

Files:
  clang/include/clang/StaticAnalyzer/Core/Checker.h
  clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Index: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -21,6 +21,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/SaveAndRestore.h"
 
@@ -325,17 +326,14 @@
 CallEventRef<> UpdatedCall = Call.cloneWithState(CEEState);
 
 ExplodedNodeSet DstPostCall;
-if (const CXXNewExpr *CNE = dyn_cast_or_null(CE)) {
+if (llvm::isa_and_nonnull(CE)) {
   ExplodedNodeSet DstPostPostCallCallback;
   getCheckerManager().runCheckersForPostCall(DstPostPostCallCallback,
  CEENode, *UpdatedCall, *this,
  /*wasInlined=*/true);
-  for (auto I : DstPostPostCallCallback) {
+  for (ExplodedNode *I : DstPostPostCallCallback) {
 getCheckerManager().runCheckersForNewAllocator(
-CNE,
-*getObjectUnderConstruction(I->getState(), CNE,
-calleeCtx->getParent()),
-DstPostCall, I, *this,
+cast(*UpdatedCall), DstPostCall, I, *this,
 /*wasInlined=*/true);
   }
 } else {
@@ -591,7 +589,7 @@
   // If there were other constructors called for object-type arguments
   // of this call, clean them up.
   ExplodedNodeSet dstArgumentCleanup;
-  for (auto I : dstCallEvaluated)
+  for (ExplodedNode *I : dstCallEvaluated)
 finishArgumentConstruction(dstArgumentCleanup, I, Call);
 
   ExplodedNodeSet dstPostCall;
@@ -605,7 +603,7 @@
 
   // Run pointerEscape callback with the newly conjured symbols.
   SmallVector, 8> Escaped;
-  for (auto I : dstPostCall) {
+  for (ExplodedNode *I : dstPostCall) {
 NodeBuilder B(I, Dst, *currBldrCtx);
 ProgramStateRef State = I->getState();
 Escaped.clear();
@@ -743,7 +741,7 @@
 const ConstructionContext *CC = CCE ? CCE->getConstructionContext()
 : nullptr;
 
-if (CC && isa(CC) &&
+if (llvm::isa_and_nonnull(CC) &&
 !Opts.MayInlineCXXAllocator)
   return CIP_DisallowedOnce;
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -577,9 +577,10 @@
   // paths when no-return temporary destructors are used for assertions.
   const AnalysisDeclContext *ADC = LCtx->getAnalysisDeclContext();
   if (!ADC->getCFGBuildOptions().AddTemporaryDtors) {
-if (TargetRegion && isa(TargetRegion) &&
+if (llvm::isa_and_nonnull(TargetRegion) &&
 cast(Call->getDecl())
-->getParent()->isAnyDestructorNoReturn()) {
+->getParent()
+->isAnyDestructorNoReturn()) {
 
   // If we've inlined the constructor, then DstEvaluated would be empty.
   // In this case we still want a sink, which could be implemented
@@ -603,7 +604,7 @@
   }
 
   ExplodedNodeSet DstPostArgumentCleanup;
-  for (auto I : DstEvaluated)
+  for (ExplodedNode *I : DstEvaluated)
 finishArgumentConstruction(DstPostArgumentCleanup, I, *Call);
 
   // If there were other constructors called for object-type arguments
@@ -712,7 +713,7 @@
 
   ExplodedNodeSet DstPostCall;
   StmtNodeBuilder CallBldr(DstPreCall, DstPostCall, *currBldrCtx);
-  for (auto I : DstPreCall) {
+  for (ExplodedNode *I : DstPreCall) {
 // FIXME: Provide evalCall for checkers?
 defaultEvalCall(CallBldr, I, *Call);
   }
@@ -722,7 +723,7 @@
   // CXXNewExpr gets processed.
   ExplodedNodeSet DstPostValue;
   StmtNodeBuilder ValueBldr(DstPostCall, DstPostValue, *currBldrCtx);
-  for (auto I : DstPostCall) {
+  for (ExplodedNode *I : DstPostCall) {
 // FIXME: Because CNE serves as the "call site" for the allocator (due to
 // lack of a better expression in the AST), the conjured return value symbol
 // is going to be of the same type (C++

[PATCH] D77410: [analyzer] StdLibraryFunctionsChecker: match signature based on FunctionDecl

2020-04-03 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: NoQ, Szelethus, gamesh411, baloghadamsoftware.
Herald added subscribers: cfe-commits, ASDenysPetrov, danielkiss, steakhal, 
Charusso, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
kristof.beyls, xazax.hun, whisperity.
Herald added a project: clang.

Currently we match the summary signature based on the arguments in the CallExpr.
There are a few problems with this approach.

1. Variadic arguments are handled badly. Consider the below code: int foo(void 
*stream, const char *format, ...); void test_arg_constraint_on_variadic_fun() { 
foo(0, "%d%d", 1, 2); // CallExpr } Here the call expression holds 4 arguments, 
whereas the function declaration has only 2 `ParmVarDecl`s. So there is no way 
to create a summary that matches the call expression, because the discrepancy 
in the number of arguments causes a mismatch.
2. The call expression does not handle the `restrict` type qualifier. In C99, 
fwrite's signature is the following: size_t fwrite(const void *restrict, 
size_t, size_t, FILE *restrict); However, in a call expression, like below, the 
type of the argument does not have the restrict qualifier. void 
test_fread_fwrite(FILE *fp, int *buf) { size_t x = fwrite(buf, sizeof(int), 10, 
fp); } This can result in an unmatches signature, so the summary is not applied.

The solution is to match the summary against the referened callee
`FunctionDecl` that we can query from the `CallExpr`.

Further patches will continue with additional refactoring where I am going to
do a lookup during the checker initialization and the signature match will
happen there. That way, we will not check the signature during every call,
rather we will compare only two `FunctionDecl` pointers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77410

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

Index: clang/test/Analysis/std-c-library-functions.c
===
--- clang/test/Analysis/std-c-library-functions.c
+++ clang/test/Analysis/std-c-library-functions.c
@@ -75,7 +75,7 @@
   }
 }
 
-size_t fread(void *, size_t, size_t, FILE *);
+size_t fread(void *restrict, size_t, size_t, FILE *);
 size_t fwrite(const void *restrict, size_t, size_t, FILE *restrict);
 void test_fread_fwrite(FILE *fp, int *buf) {
 
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -64,7 +64,7 @@
 
 typedef struct FILE FILE;
 typedef typeof(sizeof(int)) size_t;
-size_t fread(void *, size_t, size_t, FILE *);
+size_t fread(void *restrict, size_t, size_t, FILE *);
 void test_notnull_concrete(FILE *fp) {
   fread(0, sizeof(int), 10, fp); // \
   // report-warning{{Function argument constraint is not satisfied}} \
@@ -114,3 +114,11 @@
   // bugpath-note{{Assuming 'x' is < 1}} \
   // bugpath-note{{Left side of '||' is true}}
 }
+
+int __variadic(void *stream, const char *format, ...);
+void test_arg_constraint_on_variadic_fun() {
+  __variadic(0, "%d%d", 1, 2); // \
+  // report-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-warning{{Function argument constraint is not satisfied}} \
+  // bugpath-note{{Function argument constraint is not satisfied}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -268,7 +268,7 @@
 
 /// Try our best to figure out if the call expression is the call of
 /// *the* library function to which this specification applies.
-bool matchesCall(const CallExpr *CE) const;
+bool matchesCall(const FunctionDecl *FD) const;
   };
 
   // The same function (as in, function identifier) may have different
@@ -316,7 +316,6 @@
 
 private:
   Optional findFunctionSummary(const FunctionDecl *FD,
-const CallExpr *CE,
 CheckerContext &C) const;
   Optional findFunctionSummary(const CallEvent &Call,
 CheckerContext &C) const;
@@ -532,13 +531,13 @@
 }
 
 bool StdLibraryFunctionsChecker::Summary::matchesCall(
-const CallExpr *CE) const {
+const FunctionDecl *FD) const {
   // Check number of arguments:
-  if (CE->getNumArgs() != ArgTys.size())
+  if (FD->param_size() != ArgTys.size())
 return false;
 
   // Check return type if relevant:
-  if (!RetTy.isNull() && RetTy != CE->getType().getCanonicalType())
+  if (!RetTy.isNull() && RetTy != FD->getReturnType().getCan

[PATCH] D77335: [AST] clang::VectorType supports any size (that fits in unsigned)

2020-04-03 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG88fbadd0f5d5: [AST] clang::VectorType supports any size 
(that fits in unsigned) (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77335

Files:
  clang/include/clang/AST/Type.h
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/types.c
  clang/test/SemaCXX/vector.cpp

Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -335,7 +335,7 @@
 typedef bool bad __attribute__((__vector_size__(16)));  // expected-error {{invalid vector element type 'bool'}}
 
 namespace Templates {
-template 
+template 
 struct TemplateVectorType {
   typedef Elt __attribute__((__vector_size__(Size))) type; // #1
 };
@@ -343,7 +343,7 @@
 template 
 struct PR15730 {
   typedef T __attribute__((vector_size(N * sizeof(T type;
-  typedef T __attribute__((vector_size(8192))) type2; // #2
+  typedef T __attribute__((vector_size(0x10))) type2; // #2
   typedef T __attribute__((vector_size(3))) type3; // #3
 };
 
@@ -352,19 +352,20 @@
   const TemplateVectorType::type Works2 = {};
   // expected-error@#1 {{invalid vector element type 'bool'}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoBool;
+  const TemplateVectorType::type NoBool = {};
   // expected-error@#1 {{invalid vector element type 'int __attribute__((ext_vector_type(4)))' (vector of 4 'int' values)}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoComplex;
+  const TemplateVectorType::type NoComplex = {};
   // expected-error@#1 {{vector size not an integral multiple of component size}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type BadSize;
+  const TemplateVectorType::type BadSize = {};
+  const TemplateVectorType::type Large = {};
   // expected-error@#1 {{vector size too large}}
-  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type TooLarge;
+  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
+  const TemplateVectorType::type TooLarge = {};
   // expected-error@#1 {{zero vector size}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type Zero;
+  const TemplateVectorType::type Zero = {};
 
   // expected-error@#2 {{vector size too large}}
   // expected-error@#3 {{vector size not an integral multiple of component size}}
Index: clang/test/Sema/types.c
===
--- clang/test/Sema/types.c
+++ clang/test/Sema/types.c
@@ -69,9 +69,15 @@
   char c = (char __attribute__((may_alias))) i;
 }
 
-// vector size too large
-int __attribute__ ((vector_size(8192))) x1; // expected-error {{vector size too large}}
-typedef int __attribute__ ((ext_vector_type(8192))) x2; // expected-error {{vector size too large}}
+// vector size
+int __attribute__((vector_size(123456))) v1;
+int __attribute__((vector_size(0x10))) v2; // expected-error {{vector size too large}}
+int __attribute__((vector_size((__int128_t)1 << 100))) v3; // expected-error {{vector size too large}}
+int __attribute__((vector_size(0))) v4;// expected-error {{zero vector size}}
+typedef int __attribute__((ext_vector_type(123456))) e1;
+typedef int __attribute__((ext_vector_type(0x1))) e2;  // expected-error {{vector size too large}}
+typedef int __attribute__((vector_size((__int128_t)1 << 100))) e3; // expected-error {{vector size too large}}
+typedef int __attribute__((ext_vector_type(0))) e4;// expected-error {{zero vector size}}
 
 // no support for vector enum type
 enum { e_2 } x3 __attribute__((vector_size(64))); // expected-error {{invalid vector element type}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2436,28 +2436,34 @@
 return Context.getDependentVectorType(CurType, SizeExpr, AttrLoc,
VectorType::GenericVector);
 
-  unsigned VectorSize = static_cast(VecSize.getZExtValue() * 8);
+  // vecSize is specified in bytes - convert to bits.
+  if (!VecSize.isIntN(61)) {
+// Bit size will overflow uint64.
+Diag(AttrLoc, diag::err_attribute_size_too_large)
+<< SizeExpr->getSourceRange();
+return QualType();
+  }
+  uint64_t VectorSizeBits = VecSize.getZExtValue() * 8

[PATCH] D77393: [X86] Fix implicit sign conversion warnings in X86 headers.

2020-04-03 Thread pierre gousseau via Phabricator via cfe-commits
pgousseau updated this revision to Diff 254827.
pgousseau added a comment.

Renaming test and including x86intrin.h instead.


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

https://reviews.llvm.org/D77393

Files:
  clang/lib/Headers/emmintrin.h
  clang/lib/Headers/xmmintrin.h
  clang/test/Headers/x86-header-warnings.c

Index: clang/test/Headers/x86-header-warnings.c
===
--- /dev/null
+++ clang/test/Headers/x86-header-warnings.c
@@ -0,0 +1,42 @@
+// Fix sign conversion warnings found by fsanitize=implicit-integer-sign-change
+// in intrinsic headers.
+// Preprocess file to workaround no warnings in system headers.
+// RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -ffreestanding -E 2>&1 \
+// RUN: | %clang_cc1 -x c - -triple x86_64-pc-linux-gnu -ffreestanding -Wsign-conversion %s 2>&1 \
+// RUN: | FileCheck --allow-empty %s
+// REQUIRES: x86-registered-target
+
+#include 
+
+void test() {
+  // CHECK-NOT: warning:
+  _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
+  _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_OFF);
+  _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_MASK);
+
+  _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_INVALID);
+  _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_DENORM);
+  _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_DIV_ZERO);
+  _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_OVERFLOW);
+  _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_UNDERFLOW);
+  _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_INEXACT);
+  _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_MASK);
+
+  _MM_SET_EXCEPTION_MASK(_MM_MASK_INVALID);
+  _MM_SET_EXCEPTION_MASK(_MM_MASK_DENORM);
+  _MM_SET_EXCEPTION_MASK(_MM_MASK_DIV_ZERO);
+  _MM_SET_EXCEPTION_MASK(_MM_MASK_OVERFLOW);
+  _MM_SET_EXCEPTION_MASK(_MM_MASK_UNDERFLOW);
+  _MM_SET_EXCEPTION_MASK(_MM_MASK_INEXACT);
+  _MM_SET_EXCEPTION_MASK(_MM_MASK_MASK);
+
+  _MM_SET_ROUNDING_MODE(_MM_ROUND_NEAREST);
+  _MM_SET_ROUNDING_MODE(_MM_ROUND_DOWN);
+  _MM_SET_ROUNDING_MODE(_MM_ROUND_UP);
+  _MM_SET_ROUNDING_MODE(_MM_ROUND_TOWARD_ZERO);
+  _MM_SET_ROUNDING_MODE(_MM_ROUND_MASK);
+
+  _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_MASK);
+  _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
+  _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_OFF);
+}
Index: clang/lib/Headers/xmmintrin.h
===
--- clang/lib/Headers/xmmintrin.h
+++ clang/lib/Headers/xmmintrin.h
@@ -2931,31 +2931,31 @@
 
 #define _MM_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w))
 
-#define _MM_EXCEPT_INVALID(0x0001)
-#define _MM_EXCEPT_DENORM (0x0002)
-#define _MM_EXCEPT_DIV_ZERO   (0x0004)
-#define _MM_EXCEPT_OVERFLOW   (0x0008)
-#define _MM_EXCEPT_UNDERFLOW  (0x0010)
-#define _MM_EXCEPT_INEXACT(0x0020)
-#define _MM_EXCEPT_MASK   (0x003f)
-
-#define _MM_MASK_INVALID  (0x0080)
-#define _MM_MASK_DENORM   (0x0100)
-#define _MM_MASK_DIV_ZERO (0x0200)
-#define _MM_MASK_OVERFLOW (0x0400)
-#define _MM_MASK_UNDERFLOW(0x0800)
-#define _MM_MASK_INEXACT  (0x1000)
-#define _MM_MASK_MASK (0x1f80)
-
-#define _MM_ROUND_NEAREST (0x)
-#define _MM_ROUND_DOWN(0x2000)
-#define _MM_ROUND_UP  (0x4000)
-#define _MM_ROUND_TOWARD_ZERO (0x6000)
-#define _MM_ROUND_MASK(0x6000)
-
-#define _MM_FLUSH_ZERO_MASK   (0x8000)
-#define _MM_FLUSH_ZERO_ON (0x8000)
-#define _MM_FLUSH_ZERO_OFF(0x)
+#define _MM_EXCEPT_INVALID(0x0001U)
+#define _MM_EXCEPT_DENORM (0x0002U)
+#define _MM_EXCEPT_DIV_ZERO   (0x0004U)
+#define _MM_EXCEPT_OVERFLOW   (0x0008U)
+#define _MM_EXCEPT_UNDERFLOW  (0x0010U)
+#define _MM_EXCEPT_INEXACT(0x0020U)
+#define _MM_EXCEPT_MASK   (0x003fU)
+
+#define _MM_MASK_INVALID  (0x0080U)
+#define _MM_MASK_DENORM   (0x0100U)
+#define _MM_MASK_DIV_ZERO (0x0200U)
+#define _MM_MASK_OVERFLOW (0x0400U)
+#define _MM_MASK_UNDERFLOW(0x0800U)
+#define _MM_MASK_INEXACT  (0x1000U)
+#define _MM_MASK_MASK (0x1f80U)
+
+#define _MM_ROUND_NEAREST (0xU)
+#define _MM_ROUND_DOWN(0x2000U)
+#define _MM_ROUND_UP  (0x4000U)
+#define _MM_ROUND_TOWARD_ZERO (0x6000U)
+#define _MM_ROUND_MASK(0x6000U)
+
+#define _MM_FLUSH_ZERO_MASK   (0x8000U)
+#define _MM_FLUSH_ZERO_ON (0x8000U)
+#define _MM_FLUSH_ZERO_OFF(0xU)
 
 #define _MM_GET_EXCEPTION_MASK() (_mm_getcsr() & _MM_MASK_MASK)
 #define _MM_GET_EXCEPTION_STATE() (_mm_getcsr() & _MM_EXCEPT_MASK)
Index: clang/lib/Headers/emmintrin.h
===
--- clang/lib/Headers/emmintrin.h
+++ clang/lib/Headers/emmintrin.h
@@ -4970,10 +4970,10 @@
 
 #define _MM_SHUFFLE2(x, y) (((x) << 1) | (y))
 
-#define _MM_DENORMALS_ZERO_ON   (0x0040)
-#define _MM_DENORMALS_ZERO_OFF  (0x)
+#define _MM_DENORMALS_ZERO_ON   (0x0040U)
+#define _MM_DENORMALS_ZERO_OFF  (0xU)
 
-#define _MM_DENORMALS_ZERO_MASK (0x0040)
+#define _MM_DENORMALS_ZERO_MASK (0x0040U)
 
 #define _MM_GET_DENORMALS_ZERO_MODE() (_mm_getcsr() & _MM_DENORMALS_ZERO

[PATCH] D70265: [clang-tidy] Add CppCoreGuidelines I.2 "Avoid non-const global variables" check

2020-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D70265#1954925 , @vingeldal wrote:

> After looking more closely at the code I think the issue is within 
> hasLocalStorage() which is called in hasGlobalStorage(). My expectation would 
> be that anything inside of function scope would be considered local but I'm 
> not very certain.
>  Any thoughts on whether hasLocalStorage() should be modified or if I should 
> change the check and use some more ad-hoc implementation, instead of 
> hasGlobalStorage(), to determine if the variable is local or global?


Not everything at function scope has local storage -- for instance, a variable 
declared with `static` or `extern` at local scope would not have local storage 
(storage != scope). `isLocalVarDeclOrParm()` or `isLocalVarDecl()` may help you 
out here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70265



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


[PATCH] D77411: [analyzer] StdLibraryFunctionsChecker: Add test for function with default parameter

2020-04-03 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: Szelethus, baloghadamsoftware, gamesh411, steakhal, 
balazske.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77411

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


Index: clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple i686-unknown-linux \
+// RUN:   -verify
+
+void clang_analyzer_eval(int);
+
+int __defaultparam(void *, int y = 3);
+
+void test_arg_constraint_on_fun_with_default_param() {
+  __defaultparam(nullptr); // \
+  // expected-warning{{Function argument constraint is not satisfied}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -960,6 +960,9 @@
ArgumentCondition(0U, OutOfRange, SingleValue(1)))
.ArgConstraint(
ArgumentCondition(0U, OutOfRange, 
SingleValue(2)))}},
+{"__defaultparam", Summaries{Summary(ArgTypes{Irrelevant, IntTy},
+ RetType{IntTy}, EvalCallAsPure)
+ .ArgConstraint(NotNull(ArgNo(0)))}},
 };
 for (auto &E : TestFunctionSummaryMap) {
   auto InsertRes =


Index: clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple i686-unknown-linux \
+// RUN:   -verify
+
+void clang_analyzer_eval(int);
+
+int __defaultparam(void *, int y = 3);
+
+void test_arg_constraint_on_fun_with_default_param() {
+  __defaultparam(nullptr); // \
+  // expected-warning{{Function argument constraint is not satisfied}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -960,6 +960,9 @@
ArgumentCondition(0U, OutOfRange, SingleValue(1)))
.ArgConstraint(
ArgumentCondition(0U, OutOfRange, SingleValue(2)))}},
+{"__defaultparam", Summaries{Summary(ArgTypes{Irrelevant, IntTy},
+ RetType{IntTy}, EvalCallAsPure)
+ .ArgConstraint(NotNull(ArgNo(0)))}},
 };
 for (auto &E : TestFunctionSummaryMap) {
   auto InsertRes =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75181: [AArch64] Handle BTI/PAC in case of generated functions.

2020-04-03 Thread Tamas Petz via Phabricator via cfe-commits
tamas.petz added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:1827-1828
+
+  auto RASignKind = getLangOpts().getSignReturnAddressScope();
+  if (RASignKind != LangOptions::SignReturnAddressScopeKind::None) {
+FuncAttrs.addAttribute("sign-return-address",

LangOptions has the following functions:

 - hasSignReturnAddress()
 - isSignReturnAddressWithAKey()
 - isSignReturnAddressScopeAll()

With these functions some of these lines can be significantly reduced.



Comment at: clang/lib/CodeGen/CGCall.cpp:1837
+"sign-return-address-key",
+RASignKey == LangOptions::SignReturnAddressKeyKind::AKey ? "a_key"
+ : "b_key");

Use getLangOpts(). isSignReturnAddressWithAKey()



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:596
+
+  LangOptions::SignReturnAddressScopeKind Scope =
+  Context.getLangOpts().getSignReturnAddressScope();

Use new functions please.


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

https://reviews.llvm.org/D75181



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


[PATCH] D76617: [SveEmitter] Fix encoding/decoding of SVETypeFlags

2020-04-03 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 254832.
sdesmalen marked an inline comment as done.
sdesmalen added a comment.

- Updated encode functions to take/return uint64_t instead of unsigned.


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

https://reviews.llvm.org/D76617

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -65,9 +65,6 @@
 applyModifier(CharMod);
   }
 
-  /// Return the value in SVETypeFlags for this type.
-  unsigned getTypeFlags() const;
-
   bool isPointer() const { return Pointer; }
   bool isVoidPointer() const { return Pointer && Void; }
   bool isSigned() const { return Signed; }
@@ -138,36 +135,22 @@
   /// The architectural #ifdef guard.
   std::string Guard;
 
+  // The merge suffix such as _m, _x or _z.
+  std::string MergeSuffix;
+
   /// The types of return value [0] and parameters [1..].
   std::vector Types;
 
   /// The "base type", which is VarType('d', BaseTypeSpec).
   SVEType BaseType;
 
-  unsigned Flags;
+  uint64_t Flags;
 
 public:
-  /// The type of predication.
-  enum MergeType {
-MergeNone,
-MergeAny,
-MergeOp1,
-MergeZero,
-MergeAnyExp,
-MergeZeroExp,
-MergeInvalid
-  } Merge;
-
-  Intrinsic(StringRef Name, StringRef Proto, int64_t MT, StringRef LLVMName,
-unsigned Flags, TypeSpec BT, ClassKind Class, SVEEmitter &Emitter,
-StringRef Guard)
-  : Name(Name.str()), LLVMName(LLVMName), Proto(Proto.str()),
-BaseTypeSpec(BT), Class(Class), Guard(Guard.str()), BaseType(BT, 'd'),
-Flags(Flags), Merge(MergeType(MT)) {
-// Types[0] is the return value.
-for (unsigned I = 0; I < Proto.size(); ++I)
-  Types.emplace_back(BaseTypeSpec, Proto[I]);
-  }
+  Intrinsic(StringRef Name, StringRef Proto, uint64_t MergeTy,
+StringRef MergeSuffix, uint64_t MemoryElementTy, StringRef LLVMName,
+uint64_t Flags, TypeSpec BT, ClassKind Class, SVEEmitter &Emitter,
+StringRef Guard);
 
   ~Intrinsic()=default;
 
@@ -179,14 +162,13 @@
 
   StringRef getGuard() const { return Guard; }
   ClassKind getClassKind() const { return Class; }
-  MergeType getMergeType() const { return Merge; }
 
   SVEType getReturnType() const { return Types[0]; }
   ArrayRef getTypes() const { return Types; }
   SVEType getParamType(unsigned I) const { return Types[I + 1]; }
   unsigned getNumParams() const { return Proto.size() - 1; }
 
-  unsigned getFlags() const { return Flags; }
+  uint64_t getFlags() const { return Flags; }
   bool isFlagSet(uint64_t Flag) const { return Flags & Flag;}
 
   /// Return the type string for a BUILTIN() macro in Builtins.def.
@@ -209,7 +191,7 @@
   void emitIntrinsic(raw_ostream &OS) const;
 
 private:
-  std::string getMergeSuffix() const;
+  std::string getMergeSuffix() const { return MergeSuffix; }
   std::string mangleName(ClassKind LocalCK) const;
   std::string replaceTemplatedArgs(std::string Name, TypeSpec TS,
std::string Proto) const;
@@ -221,8 +203,8 @@
   llvm::StringMap EltTypes;
   llvm::StringMap MemEltTypes;
   llvm::StringMap FlagTypes;
+  llvm::StringMap MergeTypes;
 
-  unsigned getTypeFlags(const SVEType &T);
 public:
   SVEEmitter(RecordKeeper &R) : Records(R) {
 for (auto *RV : Records.getAllDerivedDefinitions("EltType"))
@@ -231,8 +213,42 @@
   MemEltTypes[RV->getNameInitAsString()] = RV->getValueAsInt("Value");
 for (auto *RV : Records.getAllDerivedDefinitions("FlagType"))
   FlagTypes[RV->getNameInitAsString()] = RV->getValueAsInt("Value");
+for (auto *RV : Records.getAllDerivedDefinitions("MergeType"))
+  MergeTypes[RV->getNameInitAsString()] = RV->getValueAsInt("Value");
+  }
+
+  // Returns the SVETypeFlags for a given value and mask.
+  uint64_t encodeFlag(uint64_t V, StringRef MaskName) const {
+auto It = FlagTypes.find(MaskName);
+if (It != FlagTypes.end()) {
+  uint64_t Mask = It->getValue();
+  unsigned Shift = llvm::countTrailingZeros(Mask);
+  return (V << Shift) & Mask;
+}
+llvm_unreachable("Unsupported flag");
+  }
+
+  // Returns the SVETypeFlags for the given element type.
+  uint64_t encodeEltType(StringRef EltName) {
+auto It = EltTypes.find(EltName);
+if (It != EltTypes.end())
+  return encodeFlag(It->getValue(), "EltTypeMask");
+llvm_unreachable("Unsupported EltType");
+  }
+
+  // Returns the SVETypeFlags for the given memory element type.
+  uint64_t encodeMemoryElementType(unsigned MT) {
+return encodeFlag(MT, "MemEltTypeMask");
   }
 
+  // Returns the SVETypeFlags for the given merge type.
+  uint64_t encodeMergeType(unsigned MT) {
+return encodeFlag(MT, "MergeTypeMask");
+  }
+
+  // Returns the SVETypeFlags value

[PATCH] D76617: [SveEmitter] Fix encoding/decoding of SVETypeFlags

2020-04-03 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: clang/utils/TableGen/SveEmitter.cpp:229
+  // Returns the SVETypeFlags for a given value and mask.
+  unsigned encodeFlag(unsigned V, StringRef MaskName) const {
+auto It = FlagTypes.find(MaskName);

SjoerdMeijer wrote:
> Should `V` now be an `uint64_t`?
Yes, good spot!


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

https://reviews.llvm.org/D76617



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


[PATCH] D76679: [SveEmitter] Add more immediate operand checks.

2020-04-03 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

In D76679#1957399 , @SjoerdMeijer 
wrote:

> I think the float16 discussion is an interesting one, but doesn't necessarily 
> need to be done here. I am asking some questions offline, but if we ever come 
> to a different opinion on it, then we can follow up so it's somewhat 
> orthogonal to this change, and so this looks fine to me.


Thanks for reviewing the patch Sjoerd!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76679



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


[PATCH] D76066: [ARM][MachineOutliner] Add Machine Outliner support for ARM

2020-04-03 Thread Yvan Roux via Phabricator via cfe-commits
yroux updated this revision to Diff 254834.
yroux added a comment.

Here is an update of the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76066

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/include/llvm/CodeGen/TargetPassConfig.h
  llvm/lib/CodeGen/MachineOutliner.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
  llvm/lib/Target/ARM/ARMBaseInstrInfo.h
  llvm/lib/Target/ARM/ARMTargetMachine.cpp
  llvm/test/CodeGen/ARM/machine-outliner-tail.ll
  llvm/test/CodeGen/ARM/machine-outliner-thunk.ll
  llvm/test/CodeGen/ARM/machine-outliner-unoutlinable.mir
  llvm/test/CodeGen/ARM/machine-outliner-unsafe-registers.mir

Index: llvm/test/CodeGen/ARM/machine-outliner-unsafe-registers.mir
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/machine-outliner-unsafe-registers.mir
@@ -0,0 +1,76 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=arm-- -run-pass=machine-outliner -verify-machineinstrs \
+# RUN: %s -o - | FileCheck %s
+
+--- |
+  define void @outline_cpsr_r12_ok() #0 { ret void }
+  define void @dont_outline_cpsr() #0 { ret void }
+  define void @dont_outline_r12() #0 { ret void }
+  declare void @z(i32, i32, i32, i32)
+
+  attributes #0 = { minsize optsize }
+...
+---
+
+name:   outline_cpsr_r12_ok
+tracksRegLiveness: true
+body: |
+  ; CHECK-LABEL: name: outline_cpsr_r12_ok
+  ; CHECK: bb.0:
+  ; CHECK:   BL @OUTLINED_FUNCTION_0
+  ; CHECK: bb.1:
+  ; CHECK:   $r12 = MOVi 1, 14 /* CC::al */, $noreg, $noreg
+  ; CHECK:   CMPri $r12, 42, 14 /* CC::al */, $noreg, implicit-def $cpsr
+  ; CHECK:   BL @OUTLINED_FUNCTION_0
+  bb.0:
+liveins: $cpsr, $r12
+$r0 = MOVi 1, 14, $noreg, $noreg
+$r1 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r3 = MOVi 1, 14, $noreg, $noreg
+BL @z
+  bb.1:
+$r12 = MOVi 1, 14, $noreg, $noreg
+CMPri $r12, 42, 14, $noreg, implicit-def $cpsr
+$r0 = MOVi 1, 14, $noreg, $noreg
+$r1 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r3 = MOVi 1, 14, $noreg, $noreg
+BL @z
+  bb.2:
+BX_RET 14, $noreg
+...
+---
+
+name:   dont_outline_cpsr
+tracksRegLiveness: true
+body: |
+  ; CHECK-LABEL: name: dont_outline_cpsr
+  ; CHECK-NOT: BL @OUTLINED_FUNCTION_0
+  bb.0:
+liveins: $cpsr
+$r0 = MOVi 1, 14, $noreg, $noreg
+$r1 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r3 = MOVi 1, 14, $noreg, $noreg
+BL @z
+  bb.1:
+liveins: $cpsr
+BX_RET 14, $noreg
+...
+---
+
+name:   dont_outline_r12
+tracksRegLiveness: true
+body: |
+  bb.0:
+liveins: $r12
+; CHECK-LABEL: name: dont_outline_r12
+; CHECK-NOT: BL @OUTLINED_FUNCTION_0
+$r0 = MOVi 1, 14, $noreg, $noreg
+$r1 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r3 = MOVi 1, 14, $noreg, $noreg
+BL @z
+$r2 = MOVr $r12, 14, $noreg, $noreg
+BX_RET 14, $noreg
Index: llvm/test/CodeGen/ARM/machine-outliner-unoutlinable.mir
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/machine-outliner-unoutlinable.mir
@@ -0,0 +1,113 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=thumbv7-- -run-pass=machine-outliner -verify-machineinstrs \
+# RUN: %s -o - | FileCheck %s
+
+--- |
+  define void @dont_outline_asm() #0 { ret void }
+  define void @dont_outline_lr() #0 { ret void }
+  define void @dont_outline_it() #0 { ret void }
+  define void @dont_outline_pic() #0 { ret void }
+  declare void @z(i32, i32, i32, i32)
+
+  attributes #0 = { minsize optsize }
+...
+---
+
+name:   dont_outline_asm
+tracksRegLiveness: true
+body: |
+  ; CHECK-LABEL: name: dont_outline_asm
+  ; CHECK: bb.0:
+  ; CHECK:   INLINEASM &"movs  r0, #42", 1
+  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_0
+  ; CHECK: bb.1:
+  ; CHECK:   INLINEASM &"movs  r0, #42", 1
+  ; CHECK:   tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION_0
+  bb.0:
+INLINEASM &"movs  r0, #42", 1
+$r0, dead $cpsr = tMOVi8 1, 14, $noreg
+$r1, dead $cpsr = tMOVi8 1, 14, $noreg
+$r2, dead $cpsr = tMOVi8 1, 14, $noreg
+$r3, dead $cpsr = tMOVi8 1, 14, $noreg
+tBL 14, $noreg, @z
+  bb.1:
+INLINEASM &"movs  r0, #42", 1
+$r0, dead $cpsr = tMOVi8 1, 14, $noreg
+$r1, dead $cpsr = tMOVi8 1, 14, $noreg
+$r2, dead $cpsr = tMOVi8 1, 14, $noreg
+$r3, dead $cpsr = tMOVi8 1, 14, $noreg
+tBL 14, $noreg, @z
+  bb.2:
+tBX_RET 14, $noreg
+...
+---
+
+name:   dont_outline_lr
+tracksRegLiveness: true
+body: |
+  ; CHECK-LABEL: name: dont_outline_lr
+  ; CHECK-NOT: tBL 14 /* CC::al */, $noreg, @OUTLINED_FUNCTION
+  bb.0:
+liveins: $lr
+$r0 = t

[PATCH] D76083: [clang-tidy] Expand the list of functions in bugprone-unused-return-value

2020-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp:98
+   "::access;"
+   "::bind;"
+   "::connect;"

sammccall wrote:
> aaron.ballman wrote:
> > jranieri-grammatech wrote:
> > > alexfh wrote:
> > > > bind has a side effect and returns a success status. Thus, the result 
> > > > being unused isn't necessarily a bug. Same for `connect`. And probably 
> > > > for `setjmp` as well.
> > > In terms of bind, connect, and setjmp: while I personally would say that 
> > > code not using the return value is bugprone, the data suggests that the 
> > > vast majority of developers are using these functions in the intended 
> > > manner and the false-positive rate should be low.
> > I think we have sufficient statistical data to suggest that these APIs 
> > should be on the list because the majority of programmers *do not* use them 
> > solely for side effects without using the return value, so my preference is 
> > to keep them in the list.
> I stumbled upon this review as we're considering turning this check on by 
> default in clangd.
> 
> There's a significant difference between unused std::async() (programmer 
> misunderstood contract) and unused ::connect() (ignoring error conditions). 
> The former is ~never noise, and the latter may be (e.g. in experimental or 
> incomplete code).
> 
> So there's some value in separating these two lists out either as an option 
> or a separate named check (bugprone-unhandled-error?) I think we probably 
> wouldn't enable this check by default if it includes the error-code functions.
> 
> > the majority of programmers *do not* use them solely for side effects
> ...in popular, distributed software :-)
> So there's some value in separating these two lists out either as an option 
> or a separate named check (bugprone-unhandled-error?) I think we probably 
> wouldn't enable this check by default if it includes the error-code functions.

I think that adds complexity to this check when the complexity isn't necessary. 
clang-tidy has traditionally been a place for checks that are chattier than 
what the compiler should provide, and this check has a trivial, well-understood 
mechanism to silence the diagnostics (cast to void) which also expresses intent 
properly to the toolchain.

>>the majority of programmers *do not* use them solely for side effects
> ...in popular, distributed software :-)

I have not seen anyone provide data to suggest that the functions in question 
appear in any statistically significant amount in practice without checking the 
return value, just worries that they *could*. I don't think that's compelling 
in the face of data. Remember, this is for bugprone patterns, not bugknown 
patterns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76083



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


[PATCH] D77028: [NFC] Refactor DeferredDiagsEmitter and skip redundant visit

2020-04-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 4 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1508
   void checkFunc(SourceLocation Loc, FunctionDecl *FD) {
+auto DiagsCountIt = DiagsCount.find(FD);
 FunctionDecl *Caller = UseStack.empty() ? nullptr : UseStack.back();

rjmccall wrote:
> yaxunl wrote:
> > rjmccall wrote:
> > > It makes me a little uncomfortable to be holding an iterator this long 
> > > while calling a fair amount of other stuff in the meantime.
> > > 
> > > Your use of DiagsCount is subtle enough that it really needs to be 
> > > explained in some comments.  You're doing stuff conditionally based on 
> > > both whether the entry exists but also whether it's non-zero.
> > added comments
> Okay, thanks for that.  Two points, then.  First, it looks like the count is 
> really just a boolean for whether the function recursively triggers any 
> diagnostics.   And second, can't it just be as simple as whether we've 
> visited that function at all in a context that's forcing diagnostics to be 
> emitted?  The logic seems to be to try to emit the diagnostics for each 
> use-path, but why would we want that?
For the second comment, we need to visit a function again for each use-path 
because we need to report each use-path that triggers a diagnostic, otherwise 
users will see a new error after they fix one error, instead of seeing all the 
errors at once.

For the first comment, I will change the count to two flags: one for the case 
where the function is not in device context, the other is for the case where 
the function is in device context. This will allow us to avoid redundant visits 
whether or not we are in a device context.



Comment at: clang/lib/Sema/Sema.cpp:1553
 if (!Caller)
   ShouldEmit = IsKnownEmitted;
 if ((!ShouldEmit && !S.getLangOpts().OpenMP && !Caller) ||

rjmccall wrote:
> This becomes global state for the visitor; that doesn't seem like it can be 
> right.
This state is for the root node of each traversal initiated from the items in 
DeclsToCheckForDeferredDiags. It only needs to be set once. Will rename it as 
ShouldEmitRootNode and move it to checkRecordedDecl.


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

https://reviews.llvm.org/D77028



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


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

2020-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this, I think it's going to be a very useful interface!




Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp:25
+  llvm::raw_svector_ostream Output(Buffer);
+  Output << "warning: Option not found '" << OptionName << "'\n";
+  return std::string(Buffer);

I think the diagnostic text should probably not start with a capital letter. 
Also, the name of the classes are confusing in that they say error but the 
diagnostic is a warning. When I hear "error", the class name makes me think 
this would stop compilation and give a nonzero result code from the program.



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp:108-113
+  if (CheckGlobal && Iter == CheckOptions.end()) {
+Iter = CheckOptions.find(LocalName.str());
+  }
+  if (Iter == CheckOptions.end()) {
+return llvm::make_error((NamePrefix + 
LocalName).str());
+  }

Elide braces



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp:122-124
+} else if (Value.equals(NameAndEnum.first))
+  return NameAndEnum.second;
+else if (Value.equals_lower(NameAndEnum.first)) {

Preference to add the braces to this case because the surrounding ones do as 
well.



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.h:41
+public:
+  MissingOptionError(std::string OptionName) : OptionName(OptionName) {}
+

Make the constructor `explicit`? (May want to consider the same for the other 
ctors, but this one seems more dangerous.)



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.h:197
+std::string get(StringRef LocalName, StringRef Default) const {
+  if (auto Val = get(LocalName))
+return *Val;

Don't use `auto` as the type is not spelled out.



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.h:201
+llvm::consumeError(Val.takeError());
+  return std::string(Default);
+}

`Default.str()` instead?



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.h:219-223
+  if (auto Val = getLocalOrGlobal(LocalName))
+return *Val;
+  else
+llvm::consumeError(Val.takeError());
+  return std::string(Default);

Same here as above.



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.h:280
+ValueOr = getLocalOrGlobal(LocalName);
+if (!ValueOr) {
+  return std::move(ValueOr.takeError());

Elide braces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77085



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


[PATCH] D77028: [NFC] Refactor DeferredDiagsEmitter and skip redundant visit

2020-04-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 254840.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

revised by John's comments


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

https://reviews.llvm.org/D77028

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp

Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1436,63 +1436,87 @@
 }
 
 // Print notes showing how we can reach FD starting from an a priori
-// known-callable function.
-static void emitCallStackNotes(Sema &S, FunctionDecl *FD) {
+// known-callable function. If \HasDiags is not null pointer, the flag
+// about whether diagnostics emitted for a function is set.
+static void emitCallStackNotes(
+Sema &S, FunctionDecl *FD,
+llvm::DenseMap, bool> *HasDiags = nullptr) {
   auto FnIt = S.DeviceKnownEmittedFns.find(FD);
   while (FnIt != S.DeviceKnownEmittedFns.end()) {
 DiagnosticBuilder Builder(
 S.Diags.Report(FnIt->second.Loc, diag::note_called_by));
 Builder << FnIt->second.FD;
 Builder.setForceEmit();
+// Set the flag about whether deferred diagnostics directly or indirectly
+// triggered by a function.
+if (HasDiags)
+  (*HasDiags)[FnIt->second.FD] = true;
 
 FnIt = S.DeviceKnownEmittedFns.find(FnIt->second.FD);
   }
 }
 
-// Emit any deferred diagnostics for FD and erase them from the map in which
-// they're stored.
-void Sema::emitDeferredDiags(FunctionDecl *FD, bool ShowCallStack) {
-  auto It = DeviceDeferredDiags.find(FD);
-  if (It == DeviceDeferredDiags.end())
-return;
-  bool HasWarningOrError = false;
-  bool FirstDiag = true;
-  for (PartialDiagnosticAt &PDAt : It->second) {
-const SourceLocation &Loc = PDAt.first;
-const PartialDiagnostic &PD = PDAt.second;
-HasWarningOrError |= getDiagnostics().getDiagnosticLevel(
- PD.getDiagID(), Loc) >= DiagnosticsEngine::Warning;
-{
-  DiagnosticBuilder Builder(Diags.Report(Loc, PD.getDiagID()));
-  Builder.setForceEmit();
-  PD.Emit(Builder);
-}
-
-// Emit the note on the first diagnostic in case too many diagnostics cause
-// the note not emitted.
-if (FirstDiag && HasWarningOrError && ShowCallStack) {
-  emitCallStackNotes(*this, FD);
-  FirstDiag = false;
-}
-  }
-
-}
-
 namespace {
+
 /// Helper class that emits deferred diagnostic messages if an entity directly
 /// or indirectly using the function that causes the deferred diagnostic
 /// messages is known to be emitted.
+///
+/// During parsing of AST, certain diagnostic messages are recorded as deferred
+/// diagnostics since it is unknown whether the functions containing such
+/// diagnostics will be emitted. A list of potentially emitted functions and
+/// variables that may potentially trigger emission of functions are also
+/// recorded. DeferredDiagnosticsEmitter recursively visits used functions
+/// by each function to emit deferred diagnostics.
+///
+/// During the visit, certain OpenMP directives or initializer of variables
+/// with certain OpenMP attributes will cause subsequent visiting of any
+/// functions enter a state which is called OpenMP device context in this
+/// implementation. The state is exited when the directive or initializer is
+/// exited. This state can change the emission states of subsequent uses
+/// of functions.
+///
+/// Conceptually the functions or variables to be visited form a use graph
+/// where the parent node uses the child node. At any point of the visit,
+/// the tree nodes traversed from the tree root to the current node form a use
+/// stack. The emission state of the current node depends on two factors:
+///1. the emission state of the root node
+///2. whether the current node is in OpenMP device context
+/// If the function is decided to be emitted, its contained deferred diagnostics
+/// are emitted, together with the information about the use stack.
+///
+/// The flag about whether deferred diagnostics directly or indirectly triggered
+/// by a function is added. A function is visited at least once to add the flag
+/// about whether it triggers diagnostics. For subsequent visits, if the flag
+/// for deferred diagnostics triggered by the function is false, the function
+/// is skipped, since the subtree starting at this node does not trigger any
+/// deferred diagnostics and does not trigger any OpenMP device context,
+/// otherwise the flag cannot be false.
+///
 class DeferredDiagnosticsEmitter
 : public UsedDeclVisitor {
 public:
   typedef UsedDeclVisitor Inherited;
   llvm::SmallSet, 4> Visited;
   llvm::SmallVector, 4> UseStack;
-  bool ShouldEmit;
+
+  // Whether deferred diagnostics are triggered directly or indirectly by
+  // a declaration. HasDiags[0] is for the case not in OpenMP device context.
+  // HasDiags[1] is for the case in OpenMP device context. We need two maps
+  // 

[PATCH] D77199: [clang-tidy] Address false positive in modernize-use-default-member-init

2020-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with a testing request.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp:436
+
+struct PR45363 {
+  // Ensure no warning is emitted here

Can you add a test where the value is elided but braced init is still used:
```
struct PR45363 {
  PR45363() : m_i{} {} // This should still warn
  int m_i;
};
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77199



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


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

2020-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with a testing request. I agree that the Clang AST is a bit surprising, 
but not so surprising that I could definitely call it a bug.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-self-assignment.cpp:286-299
+// https://bugs.llvm.org/show_bug.cgi?id=44499
+class Foo;
+template 
+bool operator!=(Foo &, Foo &) {
+  class Bar {
+Bar &operator=(const Bar &other) {
+  if (this != &other) {

Thank you for this! Can you also add a test case where the diagnostic should 
trigger? e.g.,
```
class Foo;
template 
bool operator!=(Foo &, Foo &) {
  class Bar {
Bar &operator=(const Bar &other) {
  p = other.p;
  return *this;
}

int *p;
  };
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76990



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


[PATCH] D77408: [clang] Annotate trivial getters and setters on hover.

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

LGTM, thanks!




Comment at: clang-tools-extra/clangd/Hover.cpp:376
+llvm::Optional fieldName(const Expr *E) {
+  const auto *ReturnedMember = llvm::dyn_cast(E->IgnoreCasts());
+  const auto *Field =

if(!ReturnedMember) return None


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77408



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


[clang] b952d79 - [cuda][hip] Fix `RegisterVar` function prototype.

2020-04-03 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2020-04-03T12:57:09-04:00
New Revision: b952d799cacdb7efd44c1c9468bb11471cc16874

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

LOG: [cuda][hip] Fix `RegisterVar` function prototype.

Summary:
- `RegisterVar` has `void` return type and `size_t` in its variable size
  parameter in HIP or CUDA 9.0+.

Reviewers: tra, yaxunl

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/Cuda.h
clang/lib/Basic/Cuda.cpp
clang/lib/CodeGen/CGCUDANV.cpp
clang/test/CodeGenCUDA/device-stub.cu

Removed: 




diff  --git a/clang/include/clang/Basic/Cuda.h 
b/clang/include/clang/Basic/Cuda.h
index da572957d10d..c2ebf8734304 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -117,6 +117,7 @@ enum class CudaFeature {
   CUDA_USES_FATBIN_REGISTER_END,
 };
 
+CudaVersion ToCudaVersion(llvm::VersionTuple);
 bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
 bool CudaFeatureEnabled(CudaVersion, CudaFeature);
 

diff  --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index e06d120c58bf..74eb5473b71d 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -362,7 +362,7 @@ CudaVersion MaxVersionForCudaArch(CudaArch A) {
   }
 }
 
-static CudaVersion ToCudaVersion(llvm::VersionTuple Version) {
+CudaVersion ToCudaVersion(llvm::VersionTuple Version) {
   int IVer =
   Version.getMajor() * 10 + Version.getMinor().getValueOr(0);
   switch(IVer) {

diff  --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 6d92ef33b885..351c5058aa4c 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -440,13 +440,19 @@ llvm::Function *CGNVCUDARuntime::makeRegisterGlobalsFn() {
 Builder.CreateCall(RegisterFunc, Args);
   }
 
+  llvm::Type *VarSizeTy = IntTy;
+  // For HIP or CUDA 9.0+, device variable size is type of `size_t`.
+  if (CGM.getLangOpts().HIP ||
+  ToCudaVersion(CGM.getTarget().getSDKVersion()) >= CudaVersion::CUDA_90)
+VarSizeTy = SizeTy;
+
   // void __cudaRegisterVar(void **, char *, char *, const char *,
   //int, int, int, int)
   llvm::Type *RegisterVarParams[] = {VoidPtrPtrTy, CharPtrTy, CharPtrTy,
- CharPtrTy,IntTy, IntTy,
+ CharPtrTy,IntTy, VarSizeTy,
  IntTy,IntTy};
   llvm::FunctionCallee RegisterVar = CGM.CreateRuntimeFunction(
-  llvm::FunctionType::get(IntTy, RegisterVarParams, false),
+  llvm::FunctionType::get(VoidTy, RegisterVarParams, false),
   addUnderscoredPrefixToName("RegisterVar"));
   // void __cudaRegisterSurface(void **, const struct surfaceReference *,
   //const void **, const char *, int, int);
@@ -476,7 +482,7 @@ llvm::Function *CGNVCUDARuntime::makeRegisterGlobalsFn() {
   VarName,
   VarName,
   llvm::ConstantInt::get(IntTy, Info.Flags.isExtern()),
-  llvm::ConstantInt::get(IntTy, VarSize),
+  llvm::ConstantInt::get(VarSizeTy, VarSize),
   llvm::ConstantInt::get(IntTy, Info.Flags.isConstant()),
   llvm::ConstantInt::get(IntTy, 0)};
   Builder.CreateCall(RegisterVar, Args);

diff  --git a/clang/test/CodeGenCUDA/device-stub.cu 
b/clang/test/CodeGenCUDA/device-stub.cu
index 9db5738cdede..0f4a5644fd48 100644
--- a/clang/test/CodeGenCUDA/device-stub.cu
+++ b/clang/test/CodeGenCUDA/device-stub.cu
@@ -181,10 +181,10 @@ void hostfunc(void) { kernelfunc<<<1, 1>>>(1, 1, 1); }
 // Test that we've built a function to register kernels and global vars.
 // ALL: define internal void @__[[PREFIX]]_register_globals
 // ALL: call{{.*}}[[PREFIX]]RegisterFunction(i8** %0, 
{{.*}}kernelfunc{{[^,]*}}, {{[^@]*}}@0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}device_var{{[^,]*}}, {{[^@]*}}@1, {{.*}}i32 0, i32 4, i32 0, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}constant_var{{[^,]*}}, {{[^@]*}}@2, {{.*}}i32 0, i32 4, i32 1, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_device_var_def{{[^,]*}}, {{[^@]*}}@3, {{.*}}i32 0, i32 4, i32 0, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_constant_var_def{{[^,]*}}, {{[^@]*}}@4, {{.*}}i32 0, i32 4, i32 1, 
i32 0
+// ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}device_var{{[^,]*}}, {{[^@]*}}@1, {{.*}}i32 0, {{i32|i64}} 4, i32 0, i32 0
+// ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}constant_var{{[^,]*}}, {{[^@]*}}@2, {{.*}}i32 0, {{i32|i64}} 4, i32 1, 
i32 0
+// ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_

[PATCH] D76932: [AIX] emit .extern and .weak directive linkage

2020-04-03 Thread Digger via Phabricator via cfe-commits
DiggerLin updated this revision to Diff 254846.
DiggerLin marked 7 inline comments as done.
DiggerLin added a comment.

1. address comment
2. add two new test cases.
3. split a bit test case into three small test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76932

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-as.c
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/include/llvm/MC/MCDirectives.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/MC/MCAsmInfoXCOFF.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/MC/MCXCOFFStreamer.cpp
  llvm/lib/MC/XCOFFObjectWriter.cpp
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/test/CodeGen/PowerPC/aix-LinkOnceAnyLinkage.ll
  llvm/test/CodeGen/PowerPC/aix-LinkOnceODRLinkage.ll
  llvm/test/CodeGen/PowerPC/aix-WeakODRLinkage.ll
  llvm/test/CodeGen/PowerPC/aix-extern-weak.ll
  llvm/test/CodeGen/PowerPC/aix-extern.ll
  llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll
  llvm/test/CodeGen/PowerPC/aix-weak.ll

Index: llvm/test/CodeGen/PowerPC/aix-weak.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-weak.ll
@@ -0,0 +1,358 @@
+; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec < %s | FileCheck --check-prefixes=COMMON,BIT32 %s
+
+; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec < %s | FileCheck --check-prefixes=COMMON,BIT64 %s
+
+; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec -filetype=obj -o %t.o < %s
+; RUN: llvm-readobj  --symbols %t.o | FileCheck --check-prefix=CHECKSYM %s
+
+@foo_weak_p = global void (...)* bitcast (void ()* @foo_ref_weak to void (...)*), align 4
+@b = weak global i32 0, align 4
+
+define weak void @foo_weak(i32* %p)  {
+entry:
+  %p.addr = alloca i32*, align 4
+  store i32* %p, i32** %p.addr, align 4
+  %0 = load i32*, i32** %p.addr, align 4
+  %1 = load i32, i32* %0, align 4
+  %inc = add nsw i32 %1, 1
+  store i32 %inc, i32* %0, align 4
+  ret void
+}
+
+define weak void @foo_ref_weak()  {
+entry:
+  ret void
+}
+
+define i32 @main()  {
+entry:
+  %0 = load void (...)*, void (...)** @foo_weak_p, align 4
+  %callee.knr.cast = bitcast void (...)* %0 to void ()*
+  call void %callee.knr.cast()
+  call void @foo_weak(i32* @b)
+  call void @foo_ref_weak()
+  ret i32 0
+}
+
+; COMMON:  	.weak	foo_weak[DS]# -- Begin function foo_weak
+; COMMON-NEXT:  .weak	.foo_weak
+; COMMON-NEXT:  .align	4
+; COMMON-NEXT:  .csect foo_weak[DS]
+; BIT32-NEXT:   .long	.foo_weak   # @foo_weak
+; BIT32-NEXT:   .long	TOC[TC0]
+; BIT32-NEXT:   .long	0
+; BIT64-NEXT:   .llong	.foo_weak   # @foo_weak
+; BIT64-NEXT:   .llong	TOC[TC0]
+; BIT64-NEXT:   .llong	0
+; COMMON-NEXT:  .csect .text[PR]
+; COMMON-NEXT:  .foo_weak:
+
+; COMMON:	.weak	foo_ref_weak[DS]# -- Begin function foo_ref_weak
+; COMMON-NEXT:  .weak	.foo_ref_weak
+; COMMON-NEXT:  .align	4
+; COMMON-NEXT:  .csect foo_ref_weak[DS]
+; BIT32-NEXT:   .long	.foo_ref_weak   # @foo_ref_weak
+; BIT32-NEXT:   .long	TOC[TC0]
+; BIT32-NEXT:   .long	0
+; BIT64-NEXT:   .llong	.foo_ref_weak   # @foo_ref_weak
+; BIT64-NEXT:   .llong	TOC[TC0]
+; BIT64-NEXT:   .llong	0
+; COMMON-NEXT:  .csect .text[PR]
+; COMMON-NEXT:  .foo_ref_weak:
+
+; COMMON:  	.globl	main[DS]# -- Begin function main
+; COMMON-NEXT:  .globl	.main
+; COMMON-NEXT:  .align	4
+; COMMON-NEXT:  .csect main[DS]
+; BIT32-NEXT:   .long	.main   # @main
+; BIT32-NEXT:   .long	TOC[TC0]
+; BIT32-NEXT:   .long	0
+; BIT64-NEXT:   .llong	.main   # @main
+; BIT64-NEXT:   .llong	TOC[TC0]
+; BIT64-NEXT:   .llong	0
+; COMMON-NEXT:  .csect .text[PR]
+; COMMON-NEXT:  .main:
+
+; COMMON: 	.csect .data[RW]
+; COMMON-NEXT:  .globl	foo_weak_p
+; BIT32-NEXT:   .align	2
+; BIT64-NEXT:   .align	3
+; COMMON-NEXT:  foo_weak_p:
+; BIT32-NEXT:   .long	foo_ref_weak[DS]
+; BIT64-NEXT:   .llong	foo_ref_weak[DS]
+; COMMON-NEXT:  .weak	b
+; COMMON-NEXT:  .align	2
+; COMMON-NEXT:  b:
+; COMMON-NEXT:  .long	0   # 0x0
+; COMMON-NEXT:  .toc
+; COMMON-NEXT:  LC0:
+; COMMON-NEXT:  .tc foo_weak_p[TC],foo_weak_p
+; COMMON-NEXT:  LC1:
+; COMMON-NEXT:  .tc b[TC],b
+
+
+; CHECKSYM:  Symbols [
+; CHECKSYM-NEXT:   Symbol {
+; CHECKSYM-NEXT: Index: [[#Index:]]
+; CHECKSYM-NEXT: Name: .text
+; CHECKSYM-NEXT: Value (Reloca

[PATCH] D77414: [OpenMP] Add match_{all,any,none} declare variant selector extensions.

2020-04-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: mikerice, kiranchandramohan, ABataev, 
RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, 
fghanim, aaron.ballman.
Herald added subscribers: guansong, bollu, hiraditya, yaxunl.
Herald added a project: clang.

By default, all traits in the OpenMP context selector have to match for
it to be acceptable. Though, we sometimes want a single property out of
multiple to match (=any) or no match at all (=none). We offer these
choices as extensions via

  `implementation={extension(match_{all,any,none})}`

to the user. The choice will affect the entire context selector not only
the traits following the match property.

The first user will be D75788 . There we can 
replace

  #pragma omp begin declare variant match(device={arch(nvptx64)})
  #define __CUDA__
  
  #include <__clang_cuda_cmath.h>
  
  // TODO: Hack until we support an extension to the match clause that allows 
"or".
  #undef __CLANG_CUDA_CMATH_H__
  
  #undef __CUDA__
  #pragma omp end declare variant
  
  #pragma omp begin declare variant match(device={arch(nvptx)})
  #define __CUDA__
  
  #include <__clang_cuda_cmath.h>
  
  #undef __CUDA__
  #pragma omp end declare variant

with the much simpler

  #pragma omp begin declare variant match(device={arch(nvptx, nvptx64)}, 
implementation={extension(match_any)})
  #define __CUDA__
  
  #include <__clang_cuda_cmath.h>
  
  #undef __CUDA__
  #pragma omp end declare variant


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77414

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/AST/ast-dump-openmp-declare-variant-extensions-messages.c
  clang/test/AST/ast-dump-openmp-declare-variant-extensions.c
  clang/test/OpenMP/declare_variant_ast_print.c
  clang/test/OpenMP/declare_variant_messages.c
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPContext.cpp

Index: llvm/lib/Frontend/OpenMP/OMPContext.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPContext.cpp
+++ llvm/lib/Frontend/OpenMP/OMPContext.cpp
@@ -139,16 +139,61 @@
 const VariantMatchInfo &VMI, const OMPContext &Ctx,
 SmallVectorImpl *ConstructMatches) {
 
+  // The match kind determines if we need to match all traits, any of the
+  // traits, or none of the traits for it to be an applicable context.
+  enum MatchKind { MK_ALL, MK_ANY, MK_NONE };
+
+  MatchKind MK = MK_ALL;
+  // Determine the match kind the user wants, "all" is the default and provided
+  // to the user only for completeness.
+  if (VMI.RequiredTraits.test(
+  unsigned(TraitProperty::implementation_extension_match_any)))
+MK = MK_ANY;
+  if (VMI.RequiredTraits.test(
+  unsigned(TraitProperty::implementation_extension_match_none)))
+MK = MK_NONE;
+
+  // Helper to deal with a single property that was (not) found in the OpenMP
+  // context based on the match kind selected by the user via
+  // `implementation={extensions(match_[all,any,none])}'
+  auto HandleTrait = [MK](TraitProperty Property,
+  bool WasFound) -> Optional /* Result */ {
+// A single match is enough for match kind any.
+if (WasFound && MK == MK_ANY)
+  return true;
+
+// In "all" or "none" mode we accept a matching or non-matching property
+// respectively and move on. We are not done yet!
+if ((WasFound && MK == MK_ALL) || (!WasFound && MK == MK_NONE))
+  return None;
+
+// We missed a property, provide some debug output and indicate failure.
+LLVM_DEBUG({
+  if (MK == MK_ALL)
+dbgs() << "[" << DEBUG_TYPE << "] Property "
+   << getOpenMPContextTraitPropertyName(Property)
+   << " was not in the OpenMP context but match kind is all.\n";
+  if (MK == MK_NONE)
+dbgs() << "[" << DEBUG_TYPE << "] Property "
+   << getOpenMPContextTraitPropertyName(Property)
+   << " was in the OpenMP context but match kind is none.\n";
+});
+return false;
+  };
+
   for (unsigned Bit : VMI.RequiredTraits.set_bits()) {
 TraitProperty Property = TraitProperty(Bit);
 
+// So far all extensions are handled elsewhere, we skip them here as they
+// are not part of the OpenMP context.
+if (getOpenMPContextTraitSelectorForProperty(Property) ==
+TraitSelector::implementation_extension)
+  continue;
+
 bool IsActiveTrait = Ctx.ActiveTraits.test(unsigned(Property));
-if (!IsActiveTrait) {
-  LLVM_DEBUG(dbgs() << "[" << DEBUG_TYPE << "] Property "
-<< getOpenMPContextTraitPropertyName(Property)
-<< " was not in the OpenMP context.\n");
-  return false;
-}
+Optional Result = HandleTrait(Property, IsActiveTrait);
+if (Result.hasValue())
+  return Result.getValue();
   }
 

[PATCH] D76083: [clang-tidy] Expand the list of functions in bugprone-unused-return-value

2020-04-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp:98
+   "::access;"
+   "::bind;"
+   "::connect;"

aaron.ballman wrote:
> sammccall wrote:
> > aaron.ballman wrote:
> > > jranieri-grammatech wrote:
> > > > alexfh wrote:
> > > > > bind has a side effect and returns a success status. Thus, the result 
> > > > > being unused isn't necessarily a bug. Same for `connect`. And 
> > > > > probably for `setjmp` as well.
> > > > In terms of bind, connect, and setjmp: while I personally would say 
> > > > that code not using the return value is bugprone, the data suggests 
> > > > that the vast majority of developers are using these functions in the 
> > > > intended manner and the false-positive rate should be low.
> > > I think we have sufficient statistical data to suggest that these APIs 
> > > should be on the list because the majority of programmers *do not* use 
> > > them solely for side effects without using the return value, so my 
> > > preference is to keep them in the list.
> > I stumbled upon this review as we're considering turning this check on by 
> > default in clangd.
> > 
> > There's a significant difference between unused std::async() (programmer 
> > misunderstood contract) and unused ::connect() (ignoring error conditions). 
> > The former is ~never noise, and the latter may be (e.g. in experimental or 
> > incomplete code).
> > 
> > So there's some value in separating these two lists out either as an option 
> > or a separate named check (bugprone-unhandled-error?) I think we probably 
> > wouldn't enable this check by default if it includes the error-code 
> > functions.
> > 
> > > the majority of programmers *do not* use them solely for side effects
> > ...in popular, distributed software :-)
> > So there's some value in separating these two lists out either as an option 
> > or a separate named check (bugprone-unhandled-error?) I think we probably 
> > wouldn't enable this check by default if it includes the error-code 
> > functions.
> 
> I think that adds complexity to this check when the complexity isn't 
> necessary. clang-tidy has traditionally been a place for checks that are 
> chattier than what the compiler should provide, and this check has a trivial, 
> well-understood mechanism to silence the diagnostics (cast to void) which 
> also expresses intent properly to the toolchain.
> 
> >>the majority of programmers *do not* use them solely for side effects
> > ...in popular, distributed software :-)
> 
> I have not seen anyone provide data to suggest that the functions in question 
> appear in any statistically significant amount in practice without checking 
> the return value, just worries that they *could*. I don't think that's 
> compelling in the face of data. Remember, this is for bugprone patterns, not 
> bugknown patterns.
I think we're talking past each other here. I'm not saying clang-tidy shouldn't 
have the check, or that it's not a bugprone pattern, or that the clang-tidy 
default should be different.

But there are scenarios where you want one but not the other. Concretely, 
warnings shown in an IDE **as you type and by default**. If you're misusing an 
API rendering it completely useless, you should see that ASAP. If you fail to 
check an error code, some users won't want to be warned about that until later.

By bundling them into a single check without options (other than duplicating 
the whole list), it's hard to create that useful but inoffensive default setup. 
That's OK, clangd can remove the check from the whitelist, but I think we'd get 
a lot of value out of it.

> I have not seen anyone provide data to suggest that the functions in question 
> appear in any statistically significant amount in practice
Right, we don't have data either way on incomplete code. Based on experience of 
writing code and watching others write code, I believe people write sloppy code 
they'd never check in, and appreciate being told early when it doesn't do what 
they intend, but some don't appreciate being told to be less sloppy. Is your 
intuition different? Do you think the data provided addresses this question?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76083



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


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

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



Comment at: clang/lib/Format/TokenAnnotator.cpp:164
+  /// Parses CPP qualified function names.
+  bool parse_function_qname(FormatToken *Tok) const {
+while (Tok && Tok->isOneOf(tok::coloncolon, tok::identifier)) {

your naming convention is incorrect it would be `parseFunctionQualifiedName`

what are your trying to do here? are you just trying to skip the to the `(`


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

https://reviews.llvm.org/D75364



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


[PATCH] D77398: [cuda][hip] Fix `RegisterVar` function prototype.

2020-04-03 Thread Michael Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb952d799cacd: [cuda][hip] Fix `RegisterVar` function 
prototype. (authored by hliao).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77398

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/test/CodeGenCUDA/device-stub.cu


Index: clang/test/CodeGenCUDA/device-stub.cu
===
--- clang/test/CodeGenCUDA/device-stub.cu
+++ clang/test/CodeGenCUDA/device-stub.cu
@@ -181,10 +181,10 @@
 // Test that we've built a function to register kernels and global vars.
 // ALL: define internal void @__[[PREFIX]]_register_globals
 // ALL: call{{.*}}[[PREFIX]]RegisterFunction(i8** %0, 
{{.*}}kernelfunc{{[^,]*}}, {{[^@]*}}@0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}device_var{{[^,]*}}, {{[^@]*}}@1, {{.*}}i32 0, i32 4, i32 0, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}constant_var{{[^,]*}}, {{[^@]*}}@2, {{.*}}i32 0, i32 4, i32 1, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_device_var_def{{[^,]*}}, {{[^@]*}}@3, {{.*}}i32 0, i32 4, i32 0, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_constant_var_def{{[^,]*}}, {{[^@]*}}@4, {{.*}}i32 0, i32 4, i32 1, 
i32 0
+// ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}device_var{{[^,]*}}, {{[^@]*}}@1, {{.*}}i32 0, {{i32|i64}} 4, i32 0, i32 0
+// ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}constant_var{{[^,]*}}, {{[^@]*}}@2, {{.*}}i32 0, {{i32|i64}} 4, i32 1, 
i32 0
+// ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_device_var_def{{[^,]*}}, {{[^@]*}}@3, {{.*}}i32 0, {{i32|i64}} 4, i32 
0, i32 0
+// ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_constant_var_def{{[^,]*}}, {{[^@]*}}@4, {{.*}}i32 0, {{i32|i64}} 4, 
i32 1, i32 0
 // ALL: ret void
 
 // Test that we've built a constructor.
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -440,13 +440,19 @@
 Builder.CreateCall(RegisterFunc, Args);
   }
 
+  llvm::Type *VarSizeTy = IntTy;
+  // For HIP or CUDA 9.0+, device variable size is type of `size_t`.
+  if (CGM.getLangOpts().HIP ||
+  ToCudaVersion(CGM.getTarget().getSDKVersion()) >= CudaVersion::CUDA_90)
+VarSizeTy = SizeTy;
+
   // void __cudaRegisterVar(void **, char *, char *, const char *,
   //int, int, int, int)
   llvm::Type *RegisterVarParams[] = {VoidPtrPtrTy, CharPtrTy, CharPtrTy,
- CharPtrTy,IntTy, IntTy,
+ CharPtrTy,IntTy, VarSizeTy,
  IntTy,IntTy};
   llvm::FunctionCallee RegisterVar = CGM.CreateRuntimeFunction(
-  llvm::FunctionType::get(IntTy, RegisterVarParams, false),
+  llvm::FunctionType::get(VoidTy, RegisterVarParams, false),
   addUnderscoredPrefixToName("RegisterVar"));
   // void __cudaRegisterSurface(void **, const struct surfaceReference *,
   //const void **, const char *, int, int);
@@ -476,7 +482,7 @@
   VarName,
   VarName,
   llvm::ConstantInt::get(IntTy, Info.Flags.isExtern()),
-  llvm::ConstantInt::get(IntTy, VarSize),
+  llvm::ConstantInt::get(VarSizeTy, VarSize),
   llvm::ConstantInt::get(IntTy, Info.Flags.isConstant()),
   llvm::ConstantInt::get(IntTy, 0)};
   Builder.CreateCall(RegisterVar, Args);
Index: clang/lib/Basic/Cuda.cpp
===
--- clang/lib/Basic/Cuda.cpp
+++ clang/lib/Basic/Cuda.cpp
@@ -362,7 +362,7 @@
   }
 }
 
-static CudaVersion ToCudaVersion(llvm::VersionTuple Version) {
+CudaVersion ToCudaVersion(llvm::VersionTuple Version) {
   int IVer =
   Version.getMajor() * 10 + Version.getMinor().getValueOr(0);
   switch(IVer) {
Index: clang/include/clang/Basic/Cuda.h
===
--- clang/include/clang/Basic/Cuda.h
+++ clang/include/clang/Basic/Cuda.h
@@ -117,6 +117,7 @@
   CUDA_USES_FATBIN_REGISTER_END,
 };
 
+CudaVersion ToCudaVersion(llvm::VersionTuple);
 bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
 bool CudaFeatureEnabled(CudaVersion, CudaFeature);
 


Index: clang/test/CodeGenCUDA/device-stub.cu
===
--- clang/test/CodeGenCUDA/device-stub.cu
+++ clang/test/CodeGenCUDA/device-stub.cu
@@ -181,10 +181,10 @@
 // Test that we've built a function to register kernels and global vars.
 // ALL: define internal void @__[[PREFIX]]_register_globals
 // ALL: call{{.*}}[[PREFIX]]RegisterFunction(i8** %0, {{.*}}ker

[PATCH] D77028: [NFC] Refactor DeferredDiagsEmitter and skip redundant visit

2020-04-03 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1508
   void checkFunc(SourceLocation Loc, FunctionDecl *FD) {
+auto DiagsCountIt = DiagsCount.find(FD);
 FunctionDecl *Caller = UseStack.empty() ? nullptr : UseStack.back();

yaxunl wrote:
> rjmccall wrote:
> > yaxunl wrote:
> > > rjmccall wrote:
> > > > It makes me a little uncomfortable to be holding an iterator this long 
> > > > while calling a fair amount of other stuff in the meantime.
> > > > 
> > > > Your use of DiagsCount is subtle enough that it really needs to be 
> > > > explained in some comments.  You're doing stuff conditionally based on 
> > > > both whether the entry exists but also whether it's non-zero.
> > > added comments
> > Okay, thanks for that.  Two points, then.  First, it looks like the count 
> > is really just a boolean for whether the function recursively triggers any 
> > diagnostics.   And second, can't it just be as simple as whether we've 
> > visited that function at all in a context that's forcing diagnostics to be 
> > emitted?  The logic seems to be to try to emit the diagnostics for each 
> > use-path, but why would we want that?
> For the second comment, we need to visit a function again for each use-path 
> because we need to report each use-path that triggers a diagnostic, otherwise 
> users will see a new error after they fix one error, instead of seeing all 
> the errors at once.
> 
> For the first comment, I will change the count to two flags: one for the case 
> where the function is not in device context, the other is for the case where 
> the function is in device context. This will allow us to avoid redundant 
> visits whether or not we are in a device context.
> For the second comment, we need to visit a function again for each use-path 
> because we need to report each use-path that triggers a diagnostic, otherwise 
> users will see a new error after they fix one error, instead of seeing all 
> the errors at once.

This is not what we do in analogous cases where errors are triggered by a use, 
like in template instantiation.   The bug might be that the device program is 
using a function that it shouldn't be using, or the bug might be that a 
function that's supposed  to be usable from the device is written incorrectly.  
In the former case, yes, not reporting the errors for each use-path may force 
the programmer to build multiple times to find all the problematic uses.  
However, in the latter case you can easily end up emitting a massive number of 
errors that completely drowns out everything else.  It's also non-linear: the 
number of different use-paths of a particular function can be combinatoric.


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

https://reviews.llvm.org/D77028



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


[clang] ae044c5 - [CMAKE] Plumb include_directories() into tablegen()

2020-04-03 Thread Stephen Neuendorffer via cfe-commits

Author: Stephen Neuendorffer
Date: 2020-04-03T10:38:25-07:00
New Revision: ae044c5b0caa095602b6ef4cca40d57efc26a8f6

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

LOG: [CMAKE] Plumb include_directories() into tablegen()

Previously, the tablegen() cmake command, which defines custom
commands for running tablegen, included several hardcoded paths.  This
becomes unwieldy as there are more users for which these paths are
insufficient.  For most targets, cmake uses include_directories() and
the INCLUDE_DIRECTORIES directory property to specify include paths.
This change picks up the INCLUDE_DIRECTORIES property and adds it
to the include path used when running tablegen.  As a side effect, this
allows us to remove several hard coded paths to tablegen that are redundant
with specified include_directories().

I haven't removed the hardcoded path to CMAKE_CURRENT_SOURCE_DIR, which
seems generically useful.  There are several users in clang which apparently
don't have the current directory as an include_directories().  This could
be considered separately.

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

Added: 


Modified: 
clang/cmake/modules/AddClang.cmake
llvm/cmake/modules/TableGen.cmake
mlir/cmake/modules/AddMLIR.cmake
mlir/examples/toy/Ch3/CMakeLists.txt
mlir/examples/toy/Ch4/CMakeLists.txt
mlir/examples/toy/Ch4/include/toy/CMakeLists.txt
mlir/examples/toy/Ch5/CMakeLists.txt
mlir/examples/toy/Ch5/include/toy/CMakeLists.txt
mlir/examples/toy/Ch6/CMakeLists.txt
mlir/examples/toy/Ch6/include/toy/CMakeLists.txt
mlir/examples/toy/Ch7/CMakeLists.txt
mlir/examples/toy/Ch7/include/toy/CMakeLists.txt

Removed: 




diff  --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index 577cc11ab015..c1bb386de6f7 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -17,7 +17,7 @@ function(clang_tablegen)
 message(FATAL_ERROR "SOURCE source-file required by clang_tablegen")
   endif()
 
-  set( CLANG_TABLEGEN_ARGUMENTS -I ${CLANG_SOURCE_DIR}/include )
+  set( CLANG_TABLEGEN_ARGUMENTS "" )
   set( LLVM_TARGET_DEFINITIONS ${CTG_SOURCE} )
   tablegen(CLANG ${CTG_UNPARSED_ARGUMENTS} ${CLANG_TABLEGEN_ARGUMENTS})
 

diff  --git a/llvm/cmake/modules/TableGen.cmake 
b/llvm/cmake/modules/TableGen.cmake
index 632f69aa3386..8d0c5afabe96 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -2,10 +2,6 @@
 # Extra parameters for `tblgen' may come after `ofn' parameter.
 # Adds the name of the generated file to TABLEGEN_OUTPUT.
 
-if(LLVM_MAIN_INCLUDE_DIR)
-  set(LLVM_TABLEGEN_FLAGS -I ${LLVM_MAIN_INCLUDE_DIR})
-endif()
-
 function(tablegen project ofn)
   # Validate calling context.
   if(NOT ${project}_TABLEGEN_EXE)
@@ -75,6 +71,8 @@ function(tablegen project ofn)
 set(tblgen_change_flag "--write-if-changed")
   endif()
 
+  get_directory_property(includes "INCLUDE_DIRECTORIES")
+  list(TRANSFORM includes PREPEND -I)
   # We need both _TABLEGEN_TARGET and _TABLEGEN_EXE in the  DEPENDS list
   # (both the target and the file) to have .inc files rebuilt on
   # a tablegen change, as cmake does not propagate file-level dependencies
@@ -86,6 +84,7 @@ function(tablegen project ofn)
   # but lets us having smaller and cleaner code here.
   add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
 COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
+${includes}
 ${LLVM_TABLEGEN_FLAGS}
 ${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
 ${tblgen_change_flag}

diff  --git a/mlir/cmake/modules/AddMLIR.cmake 
b/mlir/cmake/modules/AddMLIR.cmake
index 2adb8f2f2935..7449f54ea877 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -1,5 +1,5 @@
 function(mlir_tablegen ofn)
-  tablegen(MLIR ${ARGV} "-I${MLIR_MAIN_SRC_DIR}" "-I${MLIR_INCLUDE_DIR}")
+  tablegen(MLIR ${ARGV})
   set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
   PARENT_SCOPE)
 endfunction()

diff  --git a/mlir/examples/toy/Ch3/CMakeLists.txt 
b/mlir/examples/toy/Ch3/CMakeLists.txt
index 4dab5e4d0626..ef70dcbac309 100644
--- a/mlir/examples/toy/Ch3/CMakeLists.txt
+++ b/mlir/examples/toy/Ch3/CMakeLists.txt
@@ -1,3 +1,4 @@
+include_directories(include)
 add_subdirectory(include)
 
 set(LLVM_LINK_COMPONENTS
@@ -5,7 +6,7 @@ set(LLVM_LINK_COMPONENTS
   )
 
 set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)
-mlir_tablegen(ToyCombine.inc -gen-rewriters 
"-I${CMAKE_CURRENT_SOURCE_DIR}/include")
+mlir_tablegen(ToyCombine.inc -gen-rewriters)
 add_public_tablegen_target(ToyCh3CombineIncGen)
 
 add_toy_chapter(toyc-ch3
@@ -20,7 +21,6 @@ add_toy_chapter(toyc-ch3
   ToyCh3CombineIncGen
   )
 
-include_directories(include

[PATCH] D76818: [clang-tidy] Add check llvmlibc-implementation-in-namespace.

2020-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp:21
+  Finder->addMatcher(
+  decl(hasParent(translationUnitDecl()), unless(linkageSpecDecl()))
+  .bind("child_of_translation_unit"),

This skips linkage spec declarations, but are there other declarations that 
should be similarly skipped? For instance `static_assert` declarations?



Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp:33-34
+
+  if (isa(MatchedDecl)) {
+const auto *NS = cast(MatchedDecl);
+if (NS->getName() != RequiredNamespace) {

Instead of doing an `isa<>` followed by a `cast<>`, the more common pattern is 
to do:
```
if (const auto *NS = dyn_cast(MatchedDecl)) {
```



Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp:36
+if (NS->getName() != RequiredNamespace) {
+  diag(NS->getLocation(), "'%0' needs to be the outermost namespace.")
+  << RequiredNamespace;

clang-tidy diagnostics don't have punctuation, so you should drop the full stop.



Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp:42
+  diag(MatchedDecl->getLocation(),
+   "Please wrap implentation in '%0' namespace.")
+  << RequiredNamespace;

They also aren't grammatically correct sentences, so the capital P and period 
should both go. While this definitely gets points for politeness, I think a 
more typical diagnostic might be: `declaration must be declared within the '%0' 
namespace`



Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.h:35
+private:
+  std::string RequiredNamespace;
+};

njames93 wrote:
> This can be made const
Will there only ever be a single namespace? Or should this be a list (for 
instance, a main namespace and a details namespace)?



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/llvmlibc-implementation-in-namespace.rst:6
+
+Checks all llvm-libc implementation is within the correct namespace.
+

Checks that all declarations in the llvm-libc implementation are within the 
correct namespace.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/llvmlibc-implementation-in-namespace.rst:32-35
+.. option:: RequiredNamespace
+
+The namespace that llvm-libc implementations must be wrapped in. The 
default
+is `__llvm_libc`.

Given that this check is specific to llvm-libc, why is the option needed at all?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76818



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


[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-04-03 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.h:394
+ return true;
+  }
+

rjmccall wrote:
> sepavloff wrote:
> > erichkeane wrote:
> > > rjmccall wrote:
> > > > erichkeane wrote:
> > > > > rjmccall wrote:
> > > > > > rjmccall wrote:
> > > > > > > erichkeane wrote:
> > > > > > > > rjmccall wrote:
> > > > > > > > > The problem with having both functions that take 
> > > > > > > > > `ASTContext`s and functions that don't is that it's easy to 
> > > > > > > > > mix them, so they either need to have the same behavior (in 
> > > > > > > > > which case it's pointless to have an overload that takes the 
> > > > > > > > > `ASTContext`) or you're making something really error-prone.
> > > > > > > > > 
> > > > > > > > > I would feel a lot more confident that you were designing and 
> > > > > > > > > using these APIs correctly if you actually took advantage of 
> > > > > > > > > the ability to not store trailing FPOptions in some case, 
> > > > > > > > > like when they match the global settings in the ASTContext.  
> > > > > > > > > That way you'll actually be verifying that everything behaves 
> > > > > > > > > correctly if nodes don't store FPOptions.  If you do that, I 
> > > > > > > > > think you'll see my point about not having all these 
> > > > > > > > > easily-confusable functions that do or do not take 
> > > > > > > > > `ASTContext`s..
> > > > > > > > I think I disagree with @rjmccall that these 
> > > > > > > > requiresTrailingStorage should be here at all.  I think we 
> > > > > > > > should store in the AST ANY programmer opinion, even if they 
> > > > > > > > match the global setting.  It seems to me that this would be 
> > > > > > > > more tolerant of any global-setting rewrites that modules/et-al 
> > > > > > > > introduce, as well as make the AST Print consistent.  Always 
> > > > > > > > storing FPOptions when the user has explicitly overriding it 
> > > > > > > > also better captures the programmer's intent.
> > > > > > > I covered this elsewhere in the review.  If you want to have that 
> > > > > > > tolerance — and I think you should — then expressions should 
> > > > > > > store (and Sema should track) the active pragma state, which can 
> > > > > > > be most easily expressed as a pair of an FPOptions and a mask to 
> > > > > > > apply to the global FPOptions.  When you enter a pragma, you 
> > > > > > > clear the relevant bits from the global FPOptions mask.
> > > > > > > 
> > > > > > > But the whole point of putting this stuff in trailing storage is 
> > > > > > > so that you can make FPOptions as big as you need without 
> > > > > > > actually inflating the AST size for a million nodes that don't 
> > > > > > > care in the slightest about FPOptions.
> > > > > > > But the whole point of putting this stuff in trailing storage is 
> > > > > > > so that you can make FPOptions as big as you need without 
> > > > > > > actually inflating the AST size for a million nodes that don't 
> > > > > > > care in the slightest about FPOptions.
> > > > > > 
> > > > > > I meant to say: for a million nodes that don't care in the 
> > > > > > slightest about FPOptions, as well as for a million more nodes that 
> > > > > > aren't using pragma overrides.
> > > > > Right, I get the intent, and I completely agree with that.  My point 
> > > > > was EVERY Expr that is affected by a #pragma should store it.  
> > > > > Though, after looking at your Macro concern above, I'm less compelled.
> > > > > 
> > > > > I guess was suggesting that the logic for "requiresTrailingStorage" 
> > > > > should just be "modified by a pragma" instead of "FPOptions != The 
> > > > > global setting".
> > > > Well, "modified by a pragma" still wouldn't make the AST agnostic to 
> > > > global settings, since the pragmas don't override everything in 
> > > > FPOptions at once.  But I agree that would achieve the most important 
> > > > goal, which is to stop inflating the AST when pragmas *aren't* in 
> > > > effect, which is approximately 100% of the time.  In order to do that, 
> > > > though, we'll need to start tracking pragmas, which we should do but 
> > > > which can wait for a follow-up patch.  In the meantime, I don't think 
> > > > you're ever going to get the interfaces right for queries like 
> > > > `BinaryOperator::getFPOptions` unless you actually stop relying on the 
> > > > fact that you're unconditionally storing `FPOptions`.  You need to 
> > > > passing around ASTContexts for that.  That's why I'm suggesting using 
> > > > an exact match with the global settings as a simple thing you can 
> > > > easily check without modifying what data you collect in `FPOptions`.
> > > That sounds like a good plan to me.  Thanks for entertaining my 
> > > conversation/questions.
> > > we'll need to start tracking pragmas
> > 
> > This is made in D76599 by representing floating point pragmas with a 
> > special statement node. These nodes allow an AST consumer li

[PATCH] D76932: [AIX] emit .extern and .weak directive linkage

2020-04-03 Thread Digger via Phabricator via cfe-commits
DiggerLin added inline comments.



Comment at: llvm/lib/MC/MCXCOFFStreamer.cpp:48
+Symbol->setStorageClass(XCOFF::C_WEAKEXT);
+Symbol->setExternal(true);
+break;

jasonliu wrote:
> Maybe we should just move `Symbol->setExternal(true);` outside of the switch, 
> as it is set for every attribute that we are going to emit. 
I think there is Symbol->setExternal(false ) in other switch cases later . 



Comment at: llvm/lib/MC/XCOFFObjectWriter.cpp:351
+  if (nameShouldBeInStringTable(ContainingCsect->getSectionName()))
+Strings.add(ContainingCsect->getSectionName());
+}

jasonliu wrote:
> We should `continue` here if the rest of the logic does not matter. 
thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76932



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


[PATCH] D77156: [CMAKE] Plumb include_directories() into tablegen()

2020-04-03 Thread Stephen Neuendorffer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGae044c5b0caa: [CMAKE] Plumb include_directories() into 
tablegen() (authored by stephenneuendorffer).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77156

Files:
  clang/cmake/modules/AddClang.cmake
  llvm/cmake/modules/TableGen.cmake
  mlir/cmake/modules/AddMLIR.cmake
  mlir/examples/toy/Ch3/CMakeLists.txt
  mlir/examples/toy/Ch4/CMakeLists.txt
  mlir/examples/toy/Ch4/include/toy/CMakeLists.txt
  mlir/examples/toy/Ch5/CMakeLists.txt
  mlir/examples/toy/Ch5/include/toy/CMakeLists.txt
  mlir/examples/toy/Ch6/CMakeLists.txt
  mlir/examples/toy/Ch6/include/toy/CMakeLists.txt
  mlir/examples/toy/Ch7/CMakeLists.txt
  mlir/examples/toy/Ch7/include/toy/CMakeLists.txt

Index: mlir/examples/toy/Ch7/include/toy/CMakeLists.txt
===
--- mlir/examples/toy/Ch7/include/toy/CMakeLists.txt
+++ mlir/examples/toy/Ch7/include/toy/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_TARGET_DEFINITIONS Ops.td)
-mlir_tablegen(Ops.h.inc -gen-op-decls "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
-mlir_tablegen(Ops.cpp.inc -gen-op-defs "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
+mlir_tablegen(Ops.h.inc -gen-op-decls)
+mlir_tablegen(Ops.cpp.inc -gen-op-defs)
 add_public_tablegen_target(ToyCh7OpsIncGen)
 
 set(LLVM_TARGET_DEFINITIONS ShapeInferenceInterface.td)
Index: mlir/examples/toy/Ch7/CMakeLists.txt
===
--- mlir/examples/toy/Ch7/CMakeLists.txt
+++ mlir/examples/toy/Ch7/CMakeLists.txt
@@ -1,3 +1,4 @@
+include_directories(include)
 add_subdirectory(include)
 
 set(LLVM_LINK_COMPONENTS
@@ -6,7 +7,7 @@
   )
 
 set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)
-mlir_tablegen(ToyCombine.inc -gen-rewriters "-I${CMAKE_CURRENT_SOURCE_DIR}/include")
+mlir_tablegen(ToyCombine.inc -gen-rewriters)
 add_public_tablegen_target(ToyCh7CombineIncGen)
 
 add_toy_chapter(toyc-ch7
@@ -25,7 +26,6 @@
   ToyCh7CombineIncGen
   )
 
-include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
Index: mlir/examples/toy/Ch6/include/toy/CMakeLists.txt
===
--- mlir/examples/toy/Ch6/include/toy/CMakeLists.txt
+++ mlir/examples/toy/Ch6/include/toy/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_TARGET_DEFINITIONS Ops.td)
-mlir_tablegen(Ops.h.inc -gen-op-decls "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
-mlir_tablegen(Ops.cpp.inc -gen-op-defs "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
+mlir_tablegen(Ops.h.inc -gen-op-decls)
+mlir_tablegen(Ops.cpp.inc -gen-op-defs)
 add_public_tablegen_target(ToyCh6OpsIncGen)
 
 set(LLVM_TARGET_DEFINITIONS ShapeInferenceInterface.td)
Index: mlir/examples/toy/Ch6/CMakeLists.txt
===
--- mlir/examples/toy/Ch6/CMakeLists.txt
+++ mlir/examples/toy/Ch6/CMakeLists.txt
@@ -1,3 +1,4 @@
+include_directories(include)
 add_subdirectory(include)
 
 set(LLVM_LINK_COMPONENTS
@@ -6,7 +7,7 @@
   )
 
 set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)
-mlir_tablegen(ToyCombine.inc -gen-rewriters "-I${CMAKE_CURRENT_SOURCE_DIR}/include")
+mlir_tablegen(ToyCombine.inc -gen-rewriters)
 add_public_tablegen_target(ToyCh6CombineIncGen)
 
 add_toy_chapter(toyc-ch6
@@ -25,7 +26,6 @@
   ToyCh6CombineIncGen
   )
 
-include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
Index: mlir/examples/toy/Ch5/include/toy/CMakeLists.txt
===
--- mlir/examples/toy/Ch5/include/toy/CMakeLists.txt
+++ mlir/examples/toy/Ch5/include/toy/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_TARGET_DEFINITIONS Ops.td)
-mlir_tablegen(Ops.h.inc -gen-op-decls "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
-mlir_tablegen(Ops.cpp.inc -gen-op-defs "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
+mlir_tablegen(Ops.h.inc -gen-op-decls)
+mlir_tablegen(Ops.cpp.inc -gen-op-defs)
 add_public_tablegen_target(ToyCh5OpsIncGen)
 
 set(LLVM_TARGET_DEFINITIONS ShapeInferenceInterface.td)
Index: mlir/examples/toy/Ch5/CMakeLists.txt
===
--- mlir/examples/toy/Ch5/CMakeLists.txt
+++ mlir/examples/toy/Ch5/CMakeLists.txt
@@ -1,3 +1,4 @@
+include_directories(include)
 add_subdirectory(include)
 
 set(LLVM_LINK_COMPONENTS
@@ -5,7 +6,7 @@
   )
 
 set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)
-mlir_tablegen(ToyCombine.inc -gen-rewriters "-I${CMAKE_CURRENT_SOURCE_DIR}/include")
+mlir_tablegen(ToyCombine.inc -gen-rewriters)
 add_public_tablegen_target(ToyCh5CombineIncGen)
 
 add_toy_chapter(toyc-ch5
@@ -23,7 +24,6 @@
   ToyCh5CombineIncGen
   )
 
-include_director

[clang] f288c21 - Revert "[CMAKE] Plumb include_directories() into tablegen()"

2020-04-03 Thread Stephen Neuendorffer via cfe-commits

Author: Stephen Neuendorffer
Date: 2020-04-03T10:47:36-07:00
New Revision: f288c216875d6cba6465230cbb0677e839775cd9

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

LOG: Revert "[CMAKE] Plumb include_directories() into tablegen()"

This reverts commit ae044c5b0caa095602b6ef4cca40d57efc26a8f6.

This breaks the buildbots, which use an older version of cmake.

Added: 


Modified: 
clang/cmake/modules/AddClang.cmake
llvm/cmake/modules/TableGen.cmake
mlir/cmake/modules/AddMLIR.cmake
mlir/examples/toy/Ch3/CMakeLists.txt
mlir/examples/toy/Ch4/CMakeLists.txt
mlir/examples/toy/Ch4/include/toy/CMakeLists.txt
mlir/examples/toy/Ch5/CMakeLists.txt
mlir/examples/toy/Ch5/include/toy/CMakeLists.txt
mlir/examples/toy/Ch6/CMakeLists.txt
mlir/examples/toy/Ch6/include/toy/CMakeLists.txt
mlir/examples/toy/Ch7/CMakeLists.txt
mlir/examples/toy/Ch7/include/toy/CMakeLists.txt

Removed: 




diff  --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index c1bb386de6f7..577cc11ab015 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -17,7 +17,7 @@ function(clang_tablegen)
 message(FATAL_ERROR "SOURCE source-file required by clang_tablegen")
   endif()
 
-  set( CLANG_TABLEGEN_ARGUMENTS "" )
+  set( CLANG_TABLEGEN_ARGUMENTS -I ${CLANG_SOURCE_DIR}/include )
   set( LLVM_TARGET_DEFINITIONS ${CTG_SOURCE} )
   tablegen(CLANG ${CTG_UNPARSED_ARGUMENTS} ${CLANG_TABLEGEN_ARGUMENTS})
 

diff  --git a/llvm/cmake/modules/TableGen.cmake 
b/llvm/cmake/modules/TableGen.cmake
index 8d0c5afabe96..632f69aa3386 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -2,6 +2,10 @@
 # Extra parameters for `tblgen' may come after `ofn' parameter.
 # Adds the name of the generated file to TABLEGEN_OUTPUT.
 
+if(LLVM_MAIN_INCLUDE_DIR)
+  set(LLVM_TABLEGEN_FLAGS -I ${LLVM_MAIN_INCLUDE_DIR})
+endif()
+
 function(tablegen project ofn)
   # Validate calling context.
   if(NOT ${project}_TABLEGEN_EXE)
@@ -71,8 +75,6 @@ function(tablegen project ofn)
 set(tblgen_change_flag "--write-if-changed")
   endif()
 
-  get_directory_property(includes "INCLUDE_DIRECTORIES")
-  list(TRANSFORM includes PREPEND -I)
   # We need both _TABLEGEN_TARGET and _TABLEGEN_EXE in the  DEPENDS list
   # (both the target and the file) to have .inc files rebuilt on
   # a tablegen change, as cmake does not propagate file-level dependencies
@@ -84,7 +86,6 @@ function(tablegen project ofn)
   # but lets us having smaller and cleaner code here.
   add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
 COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
-${includes}
 ${LLVM_TABLEGEN_FLAGS}
 ${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
 ${tblgen_change_flag}

diff  --git a/mlir/cmake/modules/AddMLIR.cmake 
b/mlir/cmake/modules/AddMLIR.cmake
index 7449f54ea877..2adb8f2f2935 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -1,5 +1,5 @@
 function(mlir_tablegen ofn)
-  tablegen(MLIR ${ARGV})
+  tablegen(MLIR ${ARGV} "-I${MLIR_MAIN_SRC_DIR}" "-I${MLIR_INCLUDE_DIR}")
   set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
   PARENT_SCOPE)
 endfunction()

diff  --git a/mlir/examples/toy/Ch3/CMakeLists.txt 
b/mlir/examples/toy/Ch3/CMakeLists.txt
index ef70dcbac309..4dab5e4d0626 100644
--- a/mlir/examples/toy/Ch3/CMakeLists.txt
+++ b/mlir/examples/toy/Ch3/CMakeLists.txt
@@ -1,4 +1,3 @@
-include_directories(include)
 add_subdirectory(include)
 
 set(LLVM_LINK_COMPONENTS
@@ -6,7 +5,7 @@ set(LLVM_LINK_COMPONENTS
   )
 
 set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)
-mlir_tablegen(ToyCombine.inc -gen-rewriters)
+mlir_tablegen(ToyCombine.inc -gen-rewriters 
"-I${CMAKE_CURRENT_SOURCE_DIR}/include")
 add_public_tablegen_target(ToyCh3CombineIncGen)
 
 add_toy_chapter(toyc-ch3
@@ -21,6 +20,7 @@ add_toy_chapter(toyc-ch3
   ToyCh3CombineIncGen
   )
 
+include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
 target_link_libraries(toyc-ch3

diff  --git a/mlir/examples/toy/Ch4/CMakeLists.txt 
b/mlir/examples/toy/Ch4/CMakeLists.txt
index ae30a691894e..3589b10645a6 100644
--- a/mlir/examples/toy/Ch4/CMakeLists.txt
+++ b/mlir/examples/toy/Ch4/CMakeLists.txt
@@ -1,4 +1,3 @@
-include_directories(include)
 add_subdirectory(include)
 
 set(LLVM_LINK_COMPONENTS
@@ -6,7 +5,7 @@ set(LLVM_LINK_COMPONENTS
   )
 
 set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)
-mlir_tablegen(ToyCombine.inc -gen-rewriters)
+mlir_tablegen(ToyCombine.inc -gen-rewriters 
"-I${CMAKE_CURRENT_SOURCE_DIR}/include")
 add_public_tablegen_target(ToyCh4CombineIncGen)
 
 add_toy_chapter(t

[PATCH] D77385: [clangd] Add index inspection helper tool

2020-04-03 Thread Mark Nauwelaerts via Phabricator via cfe-commits
mnauw added a comment.

Thanks for having a look at this patch.  My use-case/goal would be to have a 
way to run/do a command that reads some index and dumps it (in e.g. YAML) to 
(e.g.) stdout. That way it can be inspected/viewed all at once by plain viewer. 
 And not only symbols, refs, but also recorded paths (that form the 
include-graph).  The latter in particular was/is useful when investigating some 
not-entirely-consistent symlink-resolution issues.  The goal is not necessarily 
a separate binary, so if it's ok to extend dexp to achieve the former (e.g. by 
adding option(s)) then I can also update to patch that way accordingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77385



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


[PATCH] D76083: [clang-tidy] Expand the list of functions in bugprone-unused-return-value

2020-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp:98
+   "::access;"
+   "::bind;"
+   "::connect;"

sammccall wrote:
> aaron.ballman wrote:
> > sammccall wrote:
> > > aaron.ballman wrote:
> > > > jranieri-grammatech wrote:
> > > > > alexfh wrote:
> > > > > > bind has a side effect and returns a success status. Thus, the 
> > > > > > result being unused isn't necessarily a bug. Same for `connect`. 
> > > > > > And probably for `setjmp` as well.
> > > > > In terms of bind, connect, and setjmp: while I personally would say 
> > > > > that code not using the return value is bugprone, the data suggests 
> > > > > that the vast majority of developers are using these functions in the 
> > > > > intended manner and the false-positive rate should be low.
> > > > I think we have sufficient statistical data to suggest that these APIs 
> > > > should be on the list because the majority of programmers *do not* use 
> > > > them solely for side effects without using the return value, so my 
> > > > preference is to keep them in the list.
> > > I stumbled upon this review as we're considering turning this check on by 
> > > default in clangd.
> > > 
> > > There's a significant difference between unused std::async() (programmer 
> > > misunderstood contract) and unused ::connect() (ignoring error 
> > > conditions). The former is ~never noise, and the latter may be (e.g. in 
> > > experimental or incomplete code).
> > > 
> > > So there's some value in separating these two lists out either as an 
> > > option or a separate named check (bugprone-unhandled-error?) I think we 
> > > probably wouldn't enable this check by default if it includes the 
> > > error-code functions.
> > > 
> > > > the majority of programmers *do not* use them solely for side effects
> > > ...in popular, distributed software :-)
> > > So there's some value in separating these two lists out either as an 
> > > option or a separate named check (bugprone-unhandled-error?) I think we 
> > > probably wouldn't enable this check by default if it includes the 
> > > error-code functions.
> > 
> > I think that adds complexity to this check when the complexity isn't 
> > necessary. clang-tidy has traditionally been a place for checks that are 
> > chattier than what the compiler should provide, and this check has a 
> > trivial, well-understood mechanism to silence the diagnostics (cast to 
> > void) which also expresses intent properly to the toolchain.
> > 
> > >>the majority of programmers *do not* use them solely for side effects
> > > ...in popular, distributed software :-)
> > 
> > I have not seen anyone provide data to suggest that the functions in 
> > question appear in any statistically significant amount in practice without 
> > checking the return value, just worries that they *could*. I don't think 
> > that's compelling in the face of data. Remember, this is for bugprone 
> > patterns, not bugknown patterns.
> I think we're talking past each other here. I'm not saying clang-tidy 
> shouldn't have the check, or that it's not a bugprone pattern, or that the 
> clang-tidy default should be different.
> 
> But there are scenarios where you want one but not the other. Concretely, 
> warnings shown in an IDE **as you type and by default**. If you're misusing 
> an API rendering it completely useless, you should see that ASAP. If you fail 
> to check an error code, some users won't want to be warned about that until 
> later.
> 
> By bundling them into a single check without options (other than duplicating 
> the whole list), it's hard to create that useful but inoffensive default 
> setup. That's OK, clangd can remove the check from the whitelist, but I think 
> we'd get a lot of value out of it.
> 
> > I have not seen anyone provide data to suggest that the functions in 
> > question appear in any statistically significant amount in practice
> Right, we don't have data either way on incomplete code. Based on experience 
> of writing code and watching others write code, I believe people write sloppy 
> code they'd never check in, and appreciate being told early when it doesn't 
> do what they intend, but some don't appreciate being told to be less sloppy. 
> Is your intuition different? Do you think the data provided addresses this 
> question?
> But there are scenarios where you want one but not the other. Concretely, 
> warnings shown in an IDE as you type and by default. If you're misusing an 
> API rendering it completely useless, you should see that ASAP. If you fail to 
> check an error code, some users won't want to be warned about that until 
> later.

You're right, we were talking past one another because this was not a scenario 
I had in mind at all. Thank you for raising it!

> Is your intuition different? Do you think the data provided addresses th

[PATCH] D77419: [libTooling] Simplify the representation of Transformer's RewriteRules.

2020-04-03 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: gribozavr2.
Herald added a subscriber: jfb.
Herald added a project: clang.

This revision simplifies the representation of edits in rewrite rules. The
simplified form is more general, allowing the user more flexibility in building
custom edit specifications.

The changes extend the API, without changing the signature of existing
functions. So this only risks breaking users that directly accessed the
`RewriteRule` struct.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77419

Files:
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang/include/clang/Tooling/Transformer/RewriteRule.h
  clang/lib/Tooling/Transformer/RewriteRule.cpp
  clang/lib/Tooling/Transformer/Transformer.cpp

Index: clang/lib/Tooling/Transformer/Transformer.cpp
===
--- clang/lib/Tooling/Transformer/Transformer.cpp
+++ clang/lib/Tooling/Transformer/Transformer.cpp
@@ -31,7 +31,7 @@
 
   transformer::RewriteRule::Case Case =
   transformer::detail::findSelectedCase(Result, Rule);
-  auto Transformations = transformer::detail::translateEdits(Result, Case.Edits);
+  auto Transformations = Case.Edits(Result);
   if (!Transformations) {
 Consumer(Transformations.takeError());
 return;
Index: clang/lib/Tooling/Transformer/RewriteRule.cpp
===
--- clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -28,12 +28,11 @@
 
 using MatchResult = MatchFinder::MatchResult;
 
-Expected>
-transformer::detail::translateEdits(const MatchResult &Result,
-llvm::ArrayRef Edits) {
-  SmallVector Transformations;
-  for (const auto &Edit : Edits) {
-Expected Range = Edit.TargetRange(Result);
+static Expected>
+translateEdits(const MatchResult &Result, ArrayRef ASTEdits) {
+  SmallVector Edits;
+  for (const auto &E : ASTEdits) {
+Expected Range = E.TargetRange(Result);
 if (!Range)
   return Range.takeError();
 llvm::Optional EditRange =
@@ -41,21 +40,33 @@
 // FIXME: let user specify whether to treat this case as an error or ignore
 // it as is currently done.
 if (!EditRange)
-  return SmallVector();
-auto Replacement = Edit.Replacement->eval(Result);
+  return SmallVector();
+auto Replacement = E.Replacement->eval(Result);
 if (!Replacement)
   return Replacement.takeError();
-transformer::detail::Transformation T;
+transformer::Edit T;
 T.Range = *EditRange;
 T.Replacement = std::move(*Replacement);
-Transformations.push_back(std::move(T));
+Edits.push_back(std::move(T));
   }
-  return Transformations;
+  return Edits;
 }
 
-ASTEdit transformer::changeTo(RangeSelector S, TextGenerator Replacement) {
+EditList transformer::editList(SmallVector Edits) {
+  return [Edits = std::move(Edits)](const MatchResult &Result) {
+return translateEdits(Result, Edits);
+  };
+}
+
+EditList transformer::edit(ASTEdit Edit) {
+  return [Edit = std::move(Edit)](const MatchResult &Result) {
+return translateEdits(Result, {Edit});
+  };
+}
+
+ASTEdit transformer::changeTo(RangeSelector Target, TextGenerator Replacement) {
   ASTEdit E;
-  E.TargetRange = std::move(S);
+  E.TargetRange = std::move(Target);
   E.Replacement = std::move(Replacement);
   return E;
 }
@@ -82,8 +93,8 @@
   return change(std::move(S), std::make_shared(""));
 }
 
-RewriteRule transformer::makeRule(DynTypedMatcher M, SmallVector Edits,
-  TextGenerator Explanation) {
+RewriteRule transformer::makeRule(ast_matchers::internal::DynTypedMatcher M,
+  EditList Edits, TextGenerator Explanation) {
   return RewriteRule{{RewriteRule::Case{
   std::move(M), std::move(Edits), std::move(Explanation), {;
 }
Index: clang/include/clang/Tooling/Transformer/RewriteRule.h
===
--- clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -30,6 +30,19 @@
 
 namespace clang {
 namespace transformer {
+/// A concrete description of a source edit, represented by a character range in
+/// the source to be replaced and a corresponding replacement string.
+struct Edit {
+  CharSourceRange Range;
+  std::string Replacement;
+};
+
+/// A map from a match result to a list of concrete errors (with possible
+/// failure). This type is a building block of rewrite rules, but users will
+/// generally work in terms of `ASTEdit`s (below) rather than directly in terms
+/// of `EditList`.
+using EditList = MatchConsumer>;
+
 using TextGenerator = std::shared_ptr>;
 
 // Description of a source-code edit, expressed in terms of an AST node.
@@ -74,6 +87,19 @@
   TextGenerator Note;
 };
 
+/// Lifts a list of `ASTEdit`s into an `EditList`.
+///
+/// The `EditList`

[PATCH] D77411: [analyzer] StdLibraryFunctionsChecker: Add test for function with default parameter

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

Yay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77411



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


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

2020-04-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:7359
   verifyIndependentOfContext("bool a = f() && final.f();");
+  verifyFormat("int f(M(x) *p1 = nullptr, M(x) *p2, volatile M(x) *p3);");
+  verifyFormat("M(x) *foo();");

I would like to see the macro definitions in your tests. It's not clear from 
looking at just the test line that `M` is supposed to be a macro. It looks like 
a syntax error.


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

https://reviews.llvm.org/D75364



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


[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-04-03 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.h:394
+ return true;
+  }
+

sepavloff wrote:
> rjmccall wrote:
> > sepavloff wrote:
> > > erichkeane wrote:
> > > > rjmccall wrote:
> > > > > erichkeane wrote:
> > > > > > rjmccall wrote:
> > > > > > > rjmccall wrote:
> > > > > > > > erichkeane wrote:
> > > > > > > > > rjmccall wrote:
> > > > > > > > > > The problem with having both functions that take 
> > > > > > > > > > `ASTContext`s and functions that don't is that it's easy to 
> > > > > > > > > > mix them, so they either need to have the same behavior (in 
> > > > > > > > > > which case it's pointless to have an overload that takes 
> > > > > > > > > > the `ASTContext`) or you're making something really 
> > > > > > > > > > error-prone.
> > > > > > > > > > 
> > > > > > > > > > I would feel a lot more confident that you were designing 
> > > > > > > > > > and using these APIs correctly if you actually took 
> > > > > > > > > > advantage of the ability to not store trailing FPOptions in 
> > > > > > > > > > some case, like when they match the global settings in the 
> > > > > > > > > > ASTContext.  That way you'll actually be verifying that 
> > > > > > > > > > everything behaves correctly if nodes don't store 
> > > > > > > > > > FPOptions.  If you do that, I think you'll see my point 
> > > > > > > > > > about not having all these easily-confusable functions that 
> > > > > > > > > > do or do not take `ASTContext`s..
> > > > > > > > > I think I disagree with @rjmccall that these 
> > > > > > > > > requiresTrailingStorage should be here at all.  I think we 
> > > > > > > > > should store in the AST ANY programmer opinion, even if they 
> > > > > > > > > match the global setting.  It seems to me that this would be 
> > > > > > > > > more tolerant of any global-setting rewrites that 
> > > > > > > > > modules/et-al introduce, as well as make the AST Print 
> > > > > > > > > consistent.  Always storing FPOptions when the user has 
> > > > > > > > > explicitly overriding it also better captures the 
> > > > > > > > > programmer's intent.
> > > > > > > > I covered this elsewhere in the review.  If you want to have 
> > > > > > > > that tolerance — and I think you should — then expressions 
> > > > > > > > should store (and Sema should track) the active pragma state, 
> > > > > > > > which can be most easily expressed as a pair of an FPOptions 
> > > > > > > > and a mask to apply to the global FPOptions.  When you enter a 
> > > > > > > > pragma, you clear the relevant bits from the global FPOptions 
> > > > > > > > mask.
> > > > > > > > 
> > > > > > > > But the whole point of putting this stuff in trailing storage 
> > > > > > > > is so that you can make FPOptions as big as you need without 
> > > > > > > > actually inflating the AST size for a million nodes that don't 
> > > > > > > > care in the slightest about FPOptions.
> > > > > > > > But the whole point of putting this stuff in trailing storage 
> > > > > > > > is so that you can make FPOptions as big as you need without 
> > > > > > > > actually inflating the AST size for a million nodes that don't 
> > > > > > > > care in the slightest about FPOptions.
> > > > > > > 
> > > > > > > I meant to say: for a million nodes that don't care in the 
> > > > > > > slightest about FPOptions, as well as for a million more nodes 
> > > > > > > that aren't using pragma overrides.
> > > > > > Right, I get the intent, and I completely agree with that.  My 
> > > > > > point was EVERY Expr that is affected by a #pragma should store it. 
> > > > > >  Though, after looking at your Macro concern above, I'm less 
> > > > > > compelled.
> > > > > > 
> > > > > > I guess was suggesting that the logic for "requiresTrailingStorage" 
> > > > > > should just be "modified by a pragma" instead of "FPOptions != The 
> > > > > > global setting".
> > > > > Well, "modified by a pragma" still wouldn't make the AST agnostic to 
> > > > > global settings, since the pragmas don't override everything in 
> > > > > FPOptions at once.  But I agree that would achieve the most important 
> > > > > goal, which is to stop inflating the AST when pragmas *aren't* in 
> > > > > effect, which is approximately 100% of the time.  In order to do 
> > > > > that, though, we'll need to start tracking pragmas, which we should 
> > > > > do but which can wait for a follow-up patch.  In the meantime, I 
> > > > > don't think you're ever going to get the interfaces right for queries 
> > > > > like `BinaryOperator::getFPOptions` unless you actually stop relying 
> > > > > on the fact that you're unconditionally storing `FPOptions`.  You 
> > > > > need to passing around ASTContexts for that.  That's why I'm 
> > > > > suggesting using an exact match with the global settings as a simple 
> > > > > thing you can easily check without modifying what data you collect in 
> > > > > `FPOptions`.
> > > > That sounds like a good plan to me.  Tha

[PATCH] D77420: Also look for devtoolset-9 gcc toolchain

2020-04-03 Thread Stephan Dollberg via Phabricator via cfe-commits
stephan.dollberg created this revision.
stephan.dollberg added a reviewer: chandlerc.
Herald added a project: clang.

devtoolset-9 has been out for a while so also look for it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77420

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1977,6 +1977,7 @@
   // Non-Solaris is much simpler - most systems just go with "/usr".
   if (SysRoot.empty() && TargetTriple.getOS() == llvm::Triple::Linux) {
 // Yet, still look for RHEL devtoolsets.
+Prefixes.push_back("/opt/rh/devtoolset-9/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-8/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-7/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-6/root/usr");


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1977,6 +1977,7 @@
   // Non-Solaris is much simpler - most systems just go with "/usr".
   if (SysRoot.empty() && TargetTriple.getOS() == llvm::Triple::Linux) {
 // Yet, still look for RHEL devtoolsets.
+Prefixes.push_back("/opt/rh/devtoolset-9/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-8/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-7/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-6/root/usr");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76612: [Matrix] Add draft specification for matrix support in Clang.

2020-04-03 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 254861.
fhahn added a comment.

Specify that standard conversion rules do not apply to assignments for matrix 
types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76612

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/MatrixSupport.rst

Index: clang/docs/MatrixSupport.rst
===
--- /dev/null
+++ clang/docs/MatrixSupport.rst
@@ -0,0 +1,303 @@
+==
+Matrix Support
+==
+
+.. contents::
+   :local:
+
+.. _matrixsupport:
+
+Clang provides a language extension that allows users to express high-level
+matrix math on the C/C++ level. The draft specification can be found
+:ref:`below `.
+
+Note that the implementation is currently in progress.
+
+.. _matrixsupport-draftspec:
+
+Draft Specification
+===
+
+Matrix Type Attribute
+-
+
+The *attribute-token* ``matrix_type`` is used to declare a matrix type. It shall
+appear at most once in each *attribute-list*. The attribute shall only appertain
+to a *typedef-name* of a typedef of a non-volatile type that is a *signed
+integer type*, an *unsigned integer type*, or a *floating-point type*. The
+element type must be unqualified and qualifiers are applied to the matrix type
+directly. An *attribute-argument-clause* must be present and it shall have the
+form:
+
+``(constant-expression, constant-expression)``
+
+Both *constant-expressions* shall be a positive non-zero integral constant
+expressions. The maximum of the product of the constants is implementation
+defined. If that implementation defined limit is exceeded, the program is
+ill-formed.
+
+An *attribute* of the form ``matrix_type(R, C)`` forms a matrix type with an
+element type of the cv-qualified type the attribute appertains to and *R* rows
+and *C* columns.
+
+If a declaration of a *typedef-name* has a ``matrix_type`` attribute, then all
+declaration of that *typedef-name* shall have a matrix_type attribute with the
+same element type, number of rows, and number of columns.
+
+Matrix Type
+---
+
+A matrix type has an underlying *element type*, a constant number of rows, and
+a constant number of columns. Matrix types with the same element type, rows,
+and columns are the same type. A value of a matrix type contains ``rows *
+columns`` values of the *element type* laid out in column-major order without
+padding in a way compatible with an array of at least that many elements of the
+underlying *element type*.
+
+A matrix type is a *scalar type* and its alignment is implementation defined.
+
+TODO: Does it make sense to allow M::element_type, M::rows, and M::columns
+where M is a matrix type? We don’t support this anywhere else, but it’s
+convenient. The alternative is using template deduction to extract this
+information. Also add spelling for C.
+
+TODO: Specify how matrix values are passed to functions.
+
+Future Work: Initialization syntax.
+
+Standard Conversions
+
+
+The standard conversions are extended as follows, with the exception that for
+matrix types, standard conversions are not permissible for assignments.
+
+For integral promotions, floating-point promotion, integral conversions,
+floating-point conversions, and floating-integral conversions: apply the rules
+to the underlying type of the matrix type. The resulting type is a matrix type
+with that underlying element type. If the number of rows or columns differ
+between the original and resulting type, the program is ill-formed. Otherwise
+the resulting value is as follows:
+
+* If the original value was of matrix type, each element is converted element
+  by element.
+* If the original value was not of matrix type, each element takes the value of
+  the original value.
+
+Arithmetic Conversions
+--
+
+The usual arithmetic conversions are extended as follows.
+
+Insert at the start:
+
+* If both operands are of matrix type, no arithmetic conversion is performed.
+* If one operand is of matrix type and the other operand is of an integer or
+  floating point type, convert the integer or floating point operand to the
+  underlying element type of the operand of matrix type.
+
+Matrix Type Element Access Operator
+---
+
+An expression of the form ``postfix-expression [expression][expression]`` where
+the ``postfix-expression`` is of matrix type is a matrix element access
+expression. ``expression`` shall not be a comma expression, and shall be a
+prvalue of unscoped enumeration or integral type. Given the expression
+``E1[E2][E3]`` the result is an lvalue of the same type as the underlying
+element type of the matrix that refers to the value at E2 row and E3 column in
+the matrix. The expression E1 is sequenced before E2 and E3. The expressions
+E2 and E3 are unsequenced.
+
+**Note**: We considered providing an e

[clang] 0c0831f - [CMAKE] Plumb include_directories() into tablegen()

2020-04-03 Thread Stephen Neuendorffer via cfe-commits

Author: Stephen Neuendorffer
Date: 2020-04-03T11:23:38-07:00
New Revision: 0c0831f74b7181268a777a39ee087c9337ffa0c5

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

LOG: [CMAKE] Plumb include_directories() into tablegen()

Previously, the tablegen() cmake command, which defines custom
commands for running tablegen, included several hardcoded paths.  This
becomes unwieldy as there are more users for which these paths are
insufficient.  For most targets, cmake uses include_directories() and
the INCLUDE_DIRECTORIES directory property to specify include paths.
This change picks up the INCLUDE_DIRECTORIES property and adds it
to the include path used when running tablegen.  As a side effect, this
allows us to remove several hard coded paths to tablegen that are redundant
with specified include_directories().

I haven't removed the hardcoded path to CMAKE_CURRENT_SOURCE_DIR, which
seems generically useful.  There are several users in clang which apparently
don't have the current directory as an include_directories().  This could
be considered separately.

The new version of this path uses list APPEND rather than list TRANSFORM,
in order to be compatible with cmake 3.4.3. If we update to cmake 3.12 then
we can use list TRANSFORM instead.

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

Added: 


Modified: 
clang/cmake/modules/AddClang.cmake
llvm/cmake/modules/TableGen.cmake
mlir/cmake/modules/AddMLIR.cmake
mlir/examples/toy/Ch3/CMakeLists.txt
mlir/examples/toy/Ch4/CMakeLists.txt
mlir/examples/toy/Ch4/include/toy/CMakeLists.txt
mlir/examples/toy/Ch5/CMakeLists.txt
mlir/examples/toy/Ch5/include/toy/CMakeLists.txt
mlir/examples/toy/Ch6/CMakeLists.txt
mlir/examples/toy/Ch6/include/toy/CMakeLists.txt
mlir/examples/toy/Ch7/CMakeLists.txt
mlir/examples/toy/Ch7/include/toy/CMakeLists.txt

Removed: 




diff  --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index 577cc11ab015..c1bb386de6f7 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -17,7 +17,7 @@ function(clang_tablegen)
 message(FATAL_ERROR "SOURCE source-file required by clang_tablegen")
   endif()
 
-  set( CLANG_TABLEGEN_ARGUMENTS -I ${CLANG_SOURCE_DIR}/include )
+  set( CLANG_TABLEGEN_ARGUMENTS "" )
   set( LLVM_TARGET_DEFINITIONS ${CTG_SOURCE} )
   tablegen(CLANG ${CTG_UNPARSED_ARGUMENTS} ${CLANG_TABLEGEN_ARGUMENTS})
 

diff  --git a/llvm/cmake/modules/TableGen.cmake 
b/llvm/cmake/modules/TableGen.cmake
index 632f69aa3386..65e31d0624f0 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -2,10 +2,6 @@
 # Extra parameters for `tblgen' may come after `ofn' parameter.
 # Adds the name of the generated file to TABLEGEN_OUTPUT.
 
-if(LLVM_MAIN_INCLUDE_DIR)
-  set(LLVM_TABLEGEN_FLAGS -I ${LLVM_MAIN_INCLUDE_DIR})
-endif()
-
 function(tablegen project ofn)
   # Validate calling context.
   if(NOT ${project}_TABLEGEN_EXE)
@@ -75,6 +71,14 @@ function(tablegen project ofn)
 set(tblgen_change_flag "--write-if-changed")
   endif()
 
+  # With CMake 3.12 this can be reduced to:
+  # get_directory_property(tblgen_includes "INCLUDE_DIRECTORIES")
+  # list(TRANSFORM tblgen_includes PREPEND -I)
+  set(tblgen_includes)
+  get_directory_property(includes "INCLUDE_DIRECTORIES")
+  foreach(include ${includes})
+list(APPEND tblgen_includes -I ${include})
+  endforeach()
   # We need both _TABLEGEN_TARGET and _TABLEGEN_EXE in the  DEPENDS list
   # (both the target and the file) to have .inc files rebuilt on
   # a tablegen change, as cmake does not propagate file-level dependencies
@@ -86,6 +90,7 @@ function(tablegen project ofn)
   # but lets us having smaller and cleaner code here.
   add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
 COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
+${tblgen_includes}
 ${LLVM_TABLEGEN_FLAGS}
 ${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
 ${tblgen_change_flag}

diff  --git a/mlir/cmake/modules/AddMLIR.cmake 
b/mlir/cmake/modules/AddMLIR.cmake
index 2adb8f2f2935..7449f54ea877 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -1,5 +1,5 @@
 function(mlir_tablegen ofn)
-  tablegen(MLIR ${ARGV} "-I${MLIR_MAIN_SRC_DIR}" "-I${MLIR_INCLUDE_DIR}")
+  tablegen(MLIR ${ARGV})
   set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
   PARENT_SCOPE)
 endfunction()

diff  --git a/mlir/examples/toy/Ch3/CMakeLists.txt 
b/mlir/examples/toy/Ch3/CMakeLists.txt
index 4dab5e4d0626..ef70dcbac309 100644
--- a/mlir/examples/toy/Ch3/CMakeLists.txt
+++ b/mlir/examples/toy/Ch3/CMakeLists.txt
@@ -1,3 +1,4 @@
+include_directories(include)
 add_subdirectory(include)
 

[clang-tools-extra] 2c7ea1c - [clang-tidy] Address false positive in modernize-use-default-member-init

2020-04-03 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-04-03T19:43:46+01:00
New Revision: 2c7ea1c4c5f7dde562bac684a59ad67f1f062726

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

LOG: [clang-tidy] Address false positive in modernize-use-default-member-init

Summary: Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=45363 | incorrect 
warning emitted by "modernize-use-default-member-init" (new to 10.0.0) ]].

Reviewers: aaron.ballman, alexfh, gribozavr2

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

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

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
index cb275ab58f1b..04cc7aa9d449 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -17,6 +17,12 @@ namespace clang {
 namespace tidy {
 namespace modernize {
 
+namespace {
+AST_MATCHER_P(InitListExpr, initCountIs, unsigned, N) {
+  return Node.getNumInits() == N;
+}
+} // namespace
+
 static StringRef getValueOfValueInit(const QualType InitType) {
   switch (InitType->getScalarTypeKind()) {
   case Type::STK_CPointer:
@@ -190,7 +196,7 @@ void UseDefaultMemberInitCheck::storeOptions(
 }
 
 void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
-  auto Init =
+  auto InitBase =
   anyOf(stringLiteral(), characterLiteral(), integerLiteral(),
 unaryOperator(hasAnyOperatorName("+", "-"),
   hasUnaryOperand(integerLiteral())),
@@ -198,7 +204,13 @@ void 
UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
 unaryOperator(hasAnyOperatorName("+", "-"),
   hasUnaryOperand(floatLiteral())),
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-initListExpr(), declRefExpr(to(enumConstantDecl(;
+declRefExpr(to(enumConstantDecl(;
+
+  auto Init =
+  anyOf(initListExpr(anyOf(
+allOf(initCountIs(1), hasInit(0, ignoringImplicit(InitBase))),
+initCountIs(0))),
+InitBase);
 
   Finder->addMatcher(
   cxxConstructorDecl(

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
index 3570fcff4a5c..60344e06dc31 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -432,3 +432,17 @@ class FunctionTryBlock {
   // CHECK-MESSAGES: :[[@LINE-2]]:10: warning: use default member initializer 
for 'k' [modernize-use-default-member-init]
   // CHECK-FIXES: int i{5}, k{8};
 };
+
+struct PR45363 {
+  // Ensure no warning is emitted here
+  PR45363(int i = 0) : m_i{i} {}
+  int m_i;
+};
+
+struct EmptyBracedIntDefault {
+  EmptyBracedIntDefault() : m_i{} {}
+  int m_i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer 
for 'm_i' [modernize-use-default-member-init]
+  // CHECK-FIXES:  {{^  }}EmptyBracedIntDefault()  {}
+  // CHECK-FIXES-NEXT: {{^  }}int m_i{};
+};



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


[PATCH] D77408: [clang] Annotate trivial getters and setters on hover.

2020-04-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 2 inline comments as done.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:376
+llvm::Optional fieldName(const Expr *E) {
+  const auto *ReturnedMember = llvm::dyn_cast(E->IgnoreCasts());
+  const auto *Field =

kadircet wrote:
> if(!ReturnedMember) return None
Oops, also forgot to check the base of the MemberExpr was CXXThisExpr.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77408



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


[PATCH] D77156: [CMAKE] Plumb include_directories() into tablegen()

2020-04-03 Thread Stephen Neuendorffer via Phabricator via cfe-commits
stephenneuendorffer edited the summary of this revision.
stephenneuendorffer updated this revision to Diff 254867.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77156

Files:
  clang/cmake/modules/AddClang.cmake
  llvm/cmake/modules/TableGen.cmake
  mlir/cmake/modules/AddMLIR.cmake
  mlir/examples/toy/Ch3/CMakeLists.txt
  mlir/examples/toy/Ch4/CMakeLists.txt
  mlir/examples/toy/Ch4/include/toy/CMakeLists.txt
  mlir/examples/toy/Ch5/CMakeLists.txt
  mlir/examples/toy/Ch5/include/toy/CMakeLists.txt
  mlir/examples/toy/Ch6/CMakeLists.txt
  mlir/examples/toy/Ch6/include/toy/CMakeLists.txt
  mlir/examples/toy/Ch7/CMakeLists.txt
  mlir/examples/toy/Ch7/include/toy/CMakeLists.txt

Index: mlir/examples/toy/Ch7/include/toy/CMakeLists.txt
===
--- mlir/examples/toy/Ch7/include/toy/CMakeLists.txt
+++ mlir/examples/toy/Ch7/include/toy/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_TARGET_DEFINITIONS Ops.td)
-mlir_tablegen(Ops.h.inc -gen-op-decls "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
-mlir_tablegen(Ops.cpp.inc -gen-op-defs "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
+mlir_tablegen(Ops.h.inc -gen-op-decls)
+mlir_tablegen(Ops.cpp.inc -gen-op-defs)
 add_public_tablegen_target(ToyCh7OpsIncGen)
 
 set(LLVM_TARGET_DEFINITIONS ShapeInferenceInterface.td)
Index: mlir/examples/toy/Ch7/CMakeLists.txt
===
--- mlir/examples/toy/Ch7/CMakeLists.txt
+++ mlir/examples/toy/Ch7/CMakeLists.txt
@@ -1,3 +1,4 @@
+include_directories(include)
 add_subdirectory(include)
 
 set(LLVM_LINK_COMPONENTS
@@ -6,7 +7,7 @@
   )
 
 set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)
-mlir_tablegen(ToyCombine.inc -gen-rewriters "-I${CMAKE_CURRENT_SOURCE_DIR}/include")
+mlir_tablegen(ToyCombine.inc -gen-rewriters)
 add_public_tablegen_target(ToyCh7CombineIncGen)
 
 add_toy_chapter(toyc-ch7
@@ -25,7 +26,6 @@
   ToyCh7CombineIncGen
   )
 
-include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
Index: mlir/examples/toy/Ch6/include/toy/CMakeLists.txt
===
--- mlir/examples/toy/Ch6/include/toy/CMakeLists.txt
+++ mlir/examples/toy/Ch6/include/toy/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_TARGET_DEFINITIONS Ops.td)
-mlir_tablegen(Ops.h.inc -gen-op-decls "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
-mlir_tablegen(Ops.cpp.inc -gen-op-defs "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
+mlir_tablegen(Ops.h.inc -gen-op-decls)
+mlir_tablegen(Ops.cpp.inc -gen-op-defs)
 add_public_tablegen_target(ToyCh6OpsIncGen)
 
 set(LLVM_TARGET_DEFINITIONS ShapeInferenceInterface.td)
Index: mlir/examples/toy/Ch6/CMakeLists.txt
===
--- mlir/examples/toy/Ch6/CMakeLists.txt
+++ mlir/examples/toy/Ch6/CMakeLists.txt
@@ -1,3 +1,4 @@
+include_directories(include)
 add_subdirectory(include)
 
 set(LLVM_LINK_COMPONENTS
@@ -6,7 +7,7 @@
   )
 
 set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)
-mlir_tablegen(ToyCombine.inc -gen-rewriters "-I${CMAKE_CURRENT_SOURCE_DIR}/include")
+mlir_tablegen(ToyCombine.inc -gen-rewriters)
 add_public_tablegen_target(ToyCh6CombineIncGen)
 
 add_toy_chapter(toyc-ch6
@@ -25,7 +26,6 @@
   ToyCh6CombineIncGen
   )
 
-include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
Index: mlir/examples/toy/Ch5/include/toy/CMakeLists.txt
===
--- mlir/examples/toy/Ch5/include/toy/CMakeLists.txt
+++ mlir/examples/toy/Ch5/include/toy/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_TARGET_DEFINITIONS Ops.td)
-mlir_tablegen(Ops.h.inc -gen-op-decls "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
-mlir_tablegen(Ops.cpp.inc -gen-op-defs "-I${CMAKE_CURRENT_SOURCE_DIR}/..")
+mlir_tablegen(Ops.h.inc -gen-op-decls)
+mlir_tablegen(Ops.cpp.inc -gen-op-defs)
 add_public_tablegen_target(ToyCh5OpsIncGen)
 
 set(LLVM_TARGET_DEFINITIONS ShapeInferenceInterface.td)
Index: mlir/examples/toy/Ch5/CMakeLists.txt
===
--- mlir/examples/toy/Ch5/CMakeLists.txt
+++ mlir/examples/toy/Ch5/CMakeLists.txt
@@ -1,3 +1,4 @@
+include_directories(include)
 add_subdirectory(include)
 
 set(LLVM_LINK_COMPONENTS
@@ -5,7 +6,7 @@
   )
 
 set(LLVM_TARGET_DEFINITIONS mlir/ToyCombine.td)
-mlir_tablegen(ToyCombine.inc -gen-rewriters "-I${CMAKE_CURRENT_SOURCE_DIR}/include")
+mlir_tablegen(ToyCombine.inc -gen-rewriters)
 add_public_tablegen_target(ToyCh5CombineIncGen)
 
 add_toy_chapter(toyc-ch5
@@ -23,7 +24,6 @@
   ToyCh5CombineIncGen
   )
 
-include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directo

[PATCH] D73245: Avoid using std::max_align_t in pre-C++11 mode

2020-04-03 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.

LGTM


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

https://reviews.llvm.org/D73245



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


[PATCH] D77385: [clangd] Add index inspection helper tool

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

Yeah, I think adding a dump/export command to dexp would be nice.
We'd have to make dexp keep the parsed input file around, or just the path and 
reopen it when the command is issued, but that seems OK to me.

(One of the costs of adding a new binary is you have to at least build it to 
keep the code from rotting, and linking binaries is often the bottleneck for 
iterating with `check-clangd`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77385



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


[PATCH] D66490: [NewPM] Enable the New Pass Manager by Default in Clang

2020-04-03 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D66490#1958747 , @aeubanks wrote:

> In D66490#1638708 , @hfinkel wrote:
>
> > In D66490#1638162 , @rupprecht 
> > wrote:
> >
> > > We already know that we don't want this enabled for tsan builds due to 
> > > https://bugs.llvm.org/show_bug.cgi?id=42877, but I don't even know if 
> > > anyone else will hit it (it's only when building one particular library).
> >
> >
> > Under the circumstances, that seems like one particular library too many. 
> > PR42877 looks like a generic bug, so if we're hitting it here, I see no 
> > reason to suspect that others would not hit it elsewhere.
>
>
> https://bugs.llvm.org/show_bug.cgi?id=42877 is marked fixed, any update on 
> this? LLVM 10.0.0 has branched.


It seems that we can go ahead with this patch if there's no other objections. I 
reran a `ninja check-clang` with this patch and all tests seem to pass (at 
least when running on x64-linux).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66490



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


[PATCH] D77054: [AArch64][SVE] Add SVE intrinsics for saturating add & subtract

2020-04-03 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D77054



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


[PATCH] D77199: [clang-tidy] Address false positive in modernize-use-default-member-init

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

- Added test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77199

Files:
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -432,3 +432,17 @@
   // CHECK-MESSAGES: :[[@LINE-2]]:10: warning: use default member initializer 
for 'k' [modernize-use-default-member-init]
   // CHECK-FIXES: int i{5}, k{8};
 };
+
+struct PR45363 {
+  // Ensure no warning is emitted here
+  PR45363(int i = 0) : m_i{i} {}
+  int m_i;
+};
+
+struct EmptyBracedIntDefault {
+  EmptyBracedIntDefault() : m_i{} {}
+  int m_i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer 
for 'm_i' [modernize-use-default-member-init]
+  // CHECK-FIXES:  {{^  }}EmptyBracedIntDefault()  {}
+  // CHECK-FIXES-NEXT: {{^  }}int m_i{};
+};
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -17,6 +17,12 @@
 namespace tidy {
 namespace modernize {
 
+namespace {
+AST_MATCHER_P(InitListExpr, initCountIs, unsigned, N) {
+  return Node.getNumInits() == N;
+}
+} // namespace
+
 static StringRef getValueOfValueInit(const QualType InitType) {
   switch (InitType->getScalarTypeKind()) {
   case Type::STK_CPointer:
@@ -190,7 +196,7 @@
 }
 
 void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
-  auto Init =
+  auto InitBase =
   anyOf(stringLiteral(), characterLiteral(), integerLiteral(),
 unaryOperator(hasAnyOperatorName("+", "-"),
   hasUnaryOperand(integerLiteral())),
@@ -198,7 +204,13 @@
 unaryOperator(hasAnyOperatorName("+", "-"),
   hasUnaryOperand(floatLiteral())),
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-initListExpr(), declRefExpr(to(enumConstantDecl(;
+declRefExpr(to(enumConstantDecl(;
+
+  auto Init =
+  anyOf(initListExpr(anyOf(
+allOf(initCountIs(1), hasInit(0, ignoringImplicit(InitBase))),
+initCountIs(0))),
+InitBase);
 
   Finder->addMatcher(
   cxxConstructorDecl(


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -432,3 +432,17 @@
   // CHECK-MESSAGES: :[[@LINE-2]]:10: warning: use default member initializer for 'k' [modernize-use-default-member-init]
   // CHECK-FIXES: int i{5}, k{8};
 };
+
+struct PR45363 {
+  // Ensure no warning is emitted here
+  PR45363(int i = 0) : m_i{i} {}
+  int m_i;
+};
+
+struct EmptyBracedIntDefault {
+  EmptyBracedIntDefault() : m_i{} {}
+  int m_i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'm_i' [modernize-use-default-member-init]
+  // CHECK-FIXES:  {{^  }}EmptyBracedIntDefault()  {}
+  // CHECK-FIXES-NEXT: {{^  }}int m_i{};
+};
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -17,6 +17,12 @@
 namespace tidy {
 namespace modernize {
 
+namespace {
+AST_MATCHER_P(InitListExpr, initCountIs, unsigned, N) {
+  return Node.getNumInits() == N;
+}
+} // namespace
+
 static StringRef getValueOfValueInit(const QualType InitType) {
   switch (InitType->getScalarTypeKind()) {
   case Type::STK_CPointer:
@@ -190,7 +196,7 @@
 }
 
 void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
-  auto Init =
+  auto InitBase =
   anyOf(stringLiteral(), characterLiteral(), integerLiteral(),
 unaryOperator(hasAnyOperatorName("+", "-"),
   hasUnaryOperand(integerLiteral())),
@@ -198,7 +204,13 @@
 unaryOperator(hasAnyOperatorName("+", "-"),
   hasUnaryOperand(floatLiteral())),
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-initListExpr(), declRefExpr(to(enumConstantDecl())

[PATCH] D70366: Add new 'flatten' LLVM attribute to fix clang's 'flatten' function attribute

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

I'm fine with this. I would hope a C/C++/Clang person will also take a look 
though.




Comment at: llvm/docs/LangRef.rst:1398
+This attribute is similar to ``alwaysinline``, but also applies 
recursively to
+all inlined function calls.
 ``builtin``

Maybe mention the correspondence to the `flatten` C/C++ attribute here.


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

https://reviews.llvm.org/D70366



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


[PATCH] D77199: [clang-tidy] Address false positive in modernize-use-default-member-init

2020-04-03 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2c7ea1c4c5f7: [clang-tidy] Address false positive in 
modernize-use-default-member-init (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77199

Files:
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -432,3 +432,17 @@
   // CHECK-MESSAGES: :[[@LINE-2]]:10: warning: use default member initializer 
for 'k' [modernize-use-default-member-init]
   // CHECK-FIXES: int i{5}, k{8};
 };
+
+struct PR45363 {
+  // Ensure no warning is emitted here
+  PR45363(int i = 0) : m_i{i} {}
+  int m_i;
+};
+
+struct EmptyBracedIntDefault {
+  EmptyBracedIntDefault() : m_i{} {}
+  int m_i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer 
for 'm_i' [modernize-use-default-member-init]
+  // CHECK-FIXES:  {{^  }}EmptyBracedIntDefault()  {}
+  // CHECK-FIXES-NEXT: {{^  }}int m_i{};
+};
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -17,6 +17,12 @@
 namespace tidy {
 namespace modernize {
 
+namespace {
+AST_MATCHER_P(InitListExpr, initCountIs, unsigned, N) {
+  return Node.getNumInits() == N;
+}
+} // namespace
+
 static StringRef getValueOfValueInit(const QualType InitType) {
   switch (InitType->getScalarTypeKind()) {
   case Type::STK_CPointer:
@@ -190,7 +196,7 @@
 }
 
 void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
-  auto Init =
+  auto InitBase =
   anyOf(stringLiteral(), characterLiteral(), integerLiteral(),
 unaryOperator(hasAnyOperatorName("+", "-"),
   hasUnaryOperand(integerLiteral())),
@@ -198,7 +204,13 @@
 unaryOperator(hasAnyOperatorName("+", "-"),
   hasUnaryOperand(floatLiteral())),
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-initListExpr(), declRefExpr(to(enumConstantDecl(;
+declRefExpr(to(enumConstantDecl(;
+
+  auto Init =
+  anyOf(initListExpr(anyOf(
+allOf(initCountIs(1), hasInit(0, ignoringImplicit(InitBase))),
+initCountIs(0))),
+InitBase);
 
   Finder->addMatcher(
   cxxConstructorDecl(


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -432,3 +432,17 @@
   // CHECK-MESSAGES: :[[@LINE-2]]:10: warning: use default member initializer for 'k' [modernize-use-default-member-init]
   // CHECK-FIXES: int i{5}, k{8};
 };
+
+struct PR45363 {
+  // Ensure no warning is emitted here
+  PR45363(int i = 0) : m_i{i} {}
+  int m_i;
+};
+
+struct EmptyBracedIntDefault {
+  EmptyBracedIntDefault() : m_i{} {}
+  int m_i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'm_i' [modernize-use-default-member-init]
+  // CHECK-FIXES:  {{^  }}EmptyBracedIntDefault()  {}
+  // CHECK-FIXES-NEXT: {{^  }}int m_i{};
+};
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -17,6 +17,12 @@
 namespace tidy {
 namespace modernize {
 
+namespace {
+AST_MATCHER_P(InitListExpr, initCountIs, unsigned, N) {
+  return Node.getNumInits() == N;
+}
+} // namespace
+
 static StringRef getValueOfValueInit(const QualType InitType) {
   switch (InitType->getScalarTypeKind()) {
   case Type::STK_CPointer:
@@ -190,7 +196,7 @@
 }
 
 void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
-  auto Init =
+  auto InitBase =
   anyOf(stringLiteral(), characterLiteral(), integerLiteral(),
 unaryOperator(hasAnyOperatorName("+", "-"),
   hasUnaryOperand(integerLiteral())),
@@ -198,7 +204,13 @@
 unaryOperator(hasAnyOperatorName("+", "-"),
   hasUnaryOperand(floatLiteral())),
 cxxBoolLiteral(), c

[PATCH] D77249: [MSan] Pass command line options to MSan with new pass manager

2020-04-03 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: compiler-rt/test/msan/chained_origin_empty_stack_npm.cpp:4
+// this test.
+// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 \
+// RUN: -fexperimental-new-pass-manager -O3 %s -o %t && \

nemanjai wrote:
> nemanjai wrote:
> > vitalybuka wrote:
> > > Why not to add RUN: section with -fexperimental-new-pass-manager into 
> > > original tests?
> > I just felt that this is a simpler way forward for a couple of reasons:
> > 1. Once the default switches, it is a very obvious change to just delete 
> > these files rather than digging through the code inside the existing ones
> > 2. Many of the tests actually contain the testing that is split up into 
> > multiple steps so I would have to duplicate all the steps for the NPM vs. 
> > default builds:
> > - compile/link
> > - run with one option set and FileCheck
> > - run with another option set and FileCheck
> > - rinse/repeat
> > (example: chained_origin_limits.cpp)
> > 
> > But of course, if there are strong objections to this approach, I can 
> > certainly go the other way.
> Seems Phabricator reformatted what I wrote here. Points 3, 4, 5, 6 were 
> supposed to be sub-bullets for 2.
> Basically, I tried to describe that in the mentioned test case, I would have 
> to replicate a number of subsequent steps for each `RUN` directive that 
> invokes the compiler.
If we're going this way, I think the original tests should explicitly have 
`-fno-experimental-new-pass-manager`. Also no strong preference towards either 
way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77249



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


[PATCH] D70366: Add new 'flatten' LLVM attribute to fix clang's 'flatten' function attribute

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

In D70366#1960300 , @jdoerfert wrote:

> I'm fine with this. I would hope a C/C++/Clang person will also take a look 
> though.


This is missing clang codegen test[s].
Seems to look fine to me otherwise.


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

https://reviews.llvm.org/D70366



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


[clang] ba87430 - [PowerPC] Replace subtract-from-zero float in version with fneg in PowerPC special fma compiler builtins

2020-04-03 Thread Kevin P. Neal via cfe-commits

Author: Andrew Wock
Date: 2020-04-03T14:59:33-04:00
New Revision: ba87430cadb2d5d0ee8e4b75101d7abcf6b321bf

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

LOG: [PowerPC] Replace subtract-from-zero float in version with fneg in PowerPC 
special fma compiler builtins

This patch adds a test for the PowerPC fma compiler builtins, some variations
of which negate inputs and outputs. The code to generate IR for these
builtins was untested before this patch.

Originally, the code used the outdated method of subtracting floating point
values from -0.0 as floating point negation. This patch remedies that.

Patch by: Drew Wock 
Differential Revision: https://reviews.llvm.org/D76949

Added: 
clang/test/CodeGen/builtins-ppc-fma.c

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 880fe0e271f5..3545ccda5d4d 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -13214,25 +13214,24 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
 Value *X = EmitScalarExpr(E->getArg(0));
 Value *Y = EmitScalarExpr(E->getArg(1));
 Value *Z = EmitScalarExpr(E->getArg(2));
-Value *Zero = llvm::ConstantFP::getZeroValueForNegation(ResultType);
 llvm::Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
 switch (BuiltinID) {
   case PPC::BI__builtin_vsx_xvmaddadp:
   case PPC::BI__builtin_vsx_xvmaddasp:
 return Builder.CreateCall(F, {X, Y, Z});
+
   case PPC::BI__builtin_vsx_xvnmaddadp:
   case PPC::BI__builtin_vsx_xvnmaddasp:
-return Builder.CreateFSub(Zero,
-  Builder.CreateCall(F, {X, Y, Z}), "sub");
+return Builder.CreateFNeg(Builder.CreateCall(F, {X, Y, Z}), "neg");
+
   case PPC::BI__builtin_vsx_xvmsubadp:
   case PPC::BI__builtin_vsx_xvmsubasp:
-return Builder.CreateCall(F,
-  {X, Y, Builder.CreateFSub(Zero, Z, "sub")});
+return Builder.CreateCall(F, {X, Y, Builder.CreateFNeg(Z, "neg")});
+
   case PPC::BI__builtin_vsx_xvnmsubadp:
   case PPC::BI__builtin_vsx_xvnmsubasp:
-Value *FsubRes =
-  Builder.CreateCall(F, {X, Y, Builder.CreateFSub(Zero, Z, "sub")});
-return Builder.CreateFSub(Zero, FsubRes, "sub");
+return Builder.CreateFNeg(
+Builder.CreateCall(F, {X, Y, Builder.CreateFNeg(Z, "neg")}), 
"neg");
 }
 llvm_unreachable("Unknown FMA operation");
 return nullptr; // Suppress no-return warning

diff  --git a/clang/test/CodeGen/builtins-ppc-fma.c 
b/clang/test/CodeGen/builtins-ppc-fma.c
new file mode 100644
index ..3a628f7613b5
--- /dev/null
+++ b/clang/test/CodeGen/builtins-ppc-fma.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux \
+// RUN: -target-feature +altivec -Wall -Wno-unused -Werror -emit-llvm %s -o - 
| FileCheck  \
+// RUN: %s
+
+typedef __attribute__((vector_size(4 * sizeof(float float vec_float;
+typedef __attribute__((vector_size(2 * sizeof(double double vec_double;
+
+volatile vec_double vd;
+volatile vec_float vf;
+
+void test_fma(void) {
+  vf = __builtin_vsx_xvmaddasp(vf, vf, vf);
+  // CHECK: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> %{{.*}})
+
+  vd = __builtin_vsx_xvmaddadp(vd, vd, vd);
+  // CHECK: @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x 
double> %{{.*}})
+
+  vf = __builtin_vsx_xvnmaddasp(vf, vf, vf);
+  // CHECK: [[RESULT:%[^ ]+]] = call <4 x float> @llvm.fma.v4f32(<4 x float> 
%{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
+  // CHECK: fneg <4 x float> [[RESULT]]
+
+  vd = __builtin_vsx_xvnmaddadp(vd, vd, vd);
+  // CHECK: [[RESULT:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x double> 
%{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
+  // CHECK: fneg <2 x double> [[RESULT]]
+
+  vf = __builtin_vsx_xvmsubasp(vf, vf, vf);
+  // CHECK: [[RESULT:%[^ ]+]] fneg <4 x float> %{{.*}}
+  // CHECK: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> [[RESULT]])
+
+  vd = __builtin_vsx_xvmsubadp(vd, vd, vd);
+  // CHECK: fneg <2 x double> [[RESULT]]
+  // CHECK: [[RESULT:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x double> 
%{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
+
+  vf = __builtin_vsx_xvnmsubasp(vf, vf, vf);
+  // CHECK: [[RESULT:%[^ ]+]] = fneg <4 x float> %{{.*}}
+  // CHECK: [[RESULT2:%[^ ]+]] = call <4 x float> @llvm.fma.v2f64(<4 x float> 
%{{.*}}, <4 x float> %{{.*}}, <4 x float> [[RESULT]])
+  // CHECK: fneg <4 x float> [[RESULT2]]
+
+  vd = __builtin_vsx_xvnmsubadp(vd, vd, vd);
+  // CHECK: [[RESULT:%[^ ]+]] = fneg <2 x double> %{{.*}}
+  // CHECK: [[RESULT2:%[^ ]+]] = call <2 x

[clang] d7a0516 - Fix typo in test.

2020-04-03 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-04-03T15:23:49-04:00
New Revision: d7a0516ddcfe373bb780d6fc19d76fe74ecc0061

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

LOG: Fix typo in test.

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

Added: 


Modified: 
clang/test/CodeGen/builtins-ppc-fma.c

Removed: 




diff  --git a/clang/test/CodeGen/builtins-ppc-fma.c 
b/clang/test/CodeGen/builtins-ppc-fma.c
index 3a628f7613b5..e91b45b0daa7 100644
--- a/clang/test/CodeGen/builtins-ppc-fma.c
+++ b/clang/test/CodeGen/builtins-ppc-fma.c
@@ -24,7 +24,7 @@ void test_fma(void) {
   // CHECK: fneg <2 x double> [[RESULT]]
 
   vf = __builtin_vsx_xvmsubasp(vf, vf, vf);
-  // CHECK: [[RESULT:%[^ ]+]] fneg <4 x float> %{{.*}}
+  // CHECK: [[RESULT:%[^ ]+]] = fneg <4 x float> %{{.*}}
   // CHECK: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> [[RESULT]])
 
   vd = __builtin_vsx_xvmsubadp(vd, vd, vd);



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


  1   2   3   >