[PATCH] D81135: Add support for IntegerLiteral in SyntaxTree

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81135

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -314,7 +314,7 @@
   |-SimpleDeclarator
   | |-b
   | |-=
-  | `-UnknownExpression
+  | `-IntegerLiteralExpression
   |   `-42
   `-;
 )txt");
@@ -371,7 +371,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
@@ -380,7 +380,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | |-CompoundStatement
@@ -390,7 +390,7 @@
 | `-IfStatement
 |   |-if
 |   |-(
-|   |-UnknownExpression
+|   |-IntegerLiteralExpression
 |   | `-0
 |   |-)
 |   `-CompoundStatement
@@ -461,7 +461,7 @@
 | |   |-a
 | |   `-ArraySubscript
 | | |-[
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-3
 | | `-]
 | `-;
@@ -501,7 +501,7 @@
 | | `-SimpleDeclarator
 | |   |-a
 | |   |-=
-| |   `-UnknownExpression
+| |   `-IntegerLiteralExpression
 | | `-10
 | `-;
 `-}
@@ -532,14 +532,14 @@
 |-SwitchStatement
 | |-switch
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
 |   |-{
 |   |-CaseStatement
 |   | |-case
-|   | |-UnknownExpression
+|   | |-IntegerLiteralExpression
 |   | | `-0
 |   | |-:
 |   | `-DefaultStatement
@@ -573,7 +573,7 @@
 |-WhileStatement
 | |-while
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
@@ -610,7 +610,7 @@
 | |-:
 | `-ReturnStatement
 |   |-return
-|   |-UnknownExpression
+|   |-IntegerLiteralExpression
 |   | `-100
 |   `-;
 `-}
@@ -648,7 +648,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | |-ExpressionStatement
@@ -699,6 +699,32 @@
 )txt");
 }
 
+TEST_P(SyntaxTreeTest, IntegerLiteralExpression) {
+  expectTreeDumpEqual(
+  R"cpp(
+void test() {
+  42;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-42
+| `-;
+`-}
+)txt");
+}
+
 TEST_P(SyntaxTreeTest, PostfixUnaryOperator) {
   expectTreeDumpEqual(
   R"cpp(
@@ -914,18 +940,18 @@
 |-{
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-1
 | | |--
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-2
 | `-;
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-1
 | | |-==
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-2
 | `-;
 |-ExpressionStatement
@@ -933,7 +959,7 @@
 | | |-UnknownExpression
 | | | `-a
 | | |-=
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-1
 | `-;
 |-ExpressionStatement
@@ -941,23 +967,23 @@
 | | |-UnknownExpression
 | | | `-a
 | | |-<<=
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-1
 | `-;
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-1
 | | |-||
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-0
 | `-;
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-1
 | | |-&
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-2
 | `-;
 |-ExpressionStatement
@@ -965,7 +991,7 @@
 | | |-UnknownExpression
 | | | `-a
 | | |-^=
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-3
 | `-;
 `-}
@@ -1018,10 +1044,10 @@
 | `-;
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-1
 | | |-bitand
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-2
 | `-;
 |-ExpressionS

[PATCH] D80887: [clang-tidy] ignore builtin varargs from pro-type-vararg-check

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

Hopefully fixed windows buildn


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80887

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
@@ -39,13 +39,22 @@
 #include 
 void my_printf(const char* format, ...) {
   va_list ap;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
   va_start(ap, format);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call c-style vararg functions
   va_list n;
-  va_copy(n, ap); // Don't warn, va_copy is anyway useless without va_start
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
+  va_copy(n, ap);
   int i = va_arg(ap, int);
-  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use va_start/va_arg to define c-style vararg functions; use variadic templates instead
-  va_end(ap); // Don't warn, va_end is anyway useless without va_start
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use va_arg to define c-style vararg functions; use variadic templates instead
+  va_end(ap);
 }
 
 int my_vprintf(const char* format, va_list arg ); // OK to declare function taking va_list
+
+void ignoredBuiltinsTest() {
+  (void)__builtin_assume_aligned(0, 8);
+  (void)__builtin_constant_p(0);
+  (void)__builtin_fpclassify(0, 0, 0, 0, 0, 0.f);
+  (void)__builtin_isinf_sign(0.f);
+  (void)__builtin_prefetch(nullptr);
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -9,6 +9,7 @@
 #include "ProTypeVarargCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 
 using namespace clang::ast_matchers;
 
@@ -18,11 +19,72 @@
 
 const internal::VariadicDynCastAllOfMatcher vAArgExpr;
 
+static constexpr StringRef AllowedVariadics[] = {
+// clang-format off
+"__builtin_isgreater", 
+"__builtin_isgreaterequal", 
+"__builtin_isless",
+"__builtin_islessequal", 
+"__builtin_islessgreater", 
+"__builtin_isunordered",
+"__builtin_fpclassify", 
+"__builtin_isfinite", 
+"__builtin_isinf",
+"__builtin_isinf_sign", 
+"__builtin_isnan", 
+"__builtin_isnormal",
+"__builtin_signbit", 
+"__builtin_constant_p", 
+"__builtin_classify_type",
+"__builtin_va_start",
+"__builtin_assume_aligned", // Documented as variadic to support default 
+// parameters.
+"__builtin_prefetch",   // Documented as variadic to support default
+// parameters.
+"__builtin_shufflevector",  // Documented as variadic but with a defined
+// number of args based on vector size.
+"__builtin_convertvector", 
+"__builtin_call_with_static_chain",
+"__builtin_annotation", 
+"__builtin_add_overflow", 
+"__builtin_sub_overflow",
+"__builtin_mul_overflow", 
+"__builtin_preserve_access_index",
+"__builtin_nontemporal_store", 
+"__builtin_nontemporal_load",
+"__builtin_ms_va_start",
+// clang-format on
+};
+
+namespace {
+AST_MATCHER(QualType, isVAList) {
+  ASTContext &Context = Finder->getASTContext();
+  QualType Desugar = Node.getDesugaredType(Context);
+  return Context.getBuiltinVaListType().getDesugaredType(Context) == Desugar ||
+ Context.getBuiltinMSVaListType().getDesugaredType(Context) == Desugar;
+}
+
+AST_MATCHER_P(AdjustedType, hasOriginalType,
+  ast_matchers::internal::Matcher, InnerType) {
+  return InnerType.matches(Node.getOriginalType(), Finder, Builder);
+}
+} // namespace
+
 void ProTypeVarargCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(vAArgExpr().bind("va_use"), this);
 
   Finder->addMatcher(
-  callExpr(callee(functionDecl(isVariadic(.bind("callvararg"), this);
+  callExpr(callee(functionDecl(isVariadic(),
+   unless(hasAnyName(AllowedVariadics)
+  .bind("callvararg"),
+  this);
+
+  Finder->addMatcher(
+  varDecl(unless(parmVarDecl()),
+  hasType(qualType(
+  anyOf(isVAList(), decayedType(hasOriginalType(isVAList()

[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2020-06-04 Thread Ten Tzen via Phabricator via cfe-commits
tentzen updated this revision to Diff 268375.
tentzen marked an inline comment as done.
tentzen edited the summary of this revision.
tentzen added a comment.

update a couple of changes per David Majnemer's suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

Files:
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCleanup.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp
  clang/test/CodeGen/windows-seh-EHa-CppDtors01.cpp
  clang/test/CodeGen/windows-seh-EHa-TryInFinally.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/Verifier.cpp

Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -4223,6 +4223,10 @@
   Assert(
   !F->isIntrinsic() || isa(I) ||
   F->getIntrinsicID() == Intrinsic::donothing ||
+  F->getIntrinsicID() == Intrinsic::seh_try_begin ||
+  F->getIntrinsicID() == Intrinsic::seh_try_end ||
+  F->getIntrinsicID() == Intrinsic::eha_scope_begin ||
+  F->getIntrinsicID() == Intrinsic::eha_scope_end ||
   F->getIntrinsicID() == Intrinsic::coro_resume ||
   F->getIntrinsicID() == Intrinsic::coro_destroy ||
   F->getIntrinsicID() == Intrinsic::experimental_patchpoint_void ||
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -2789,6 +2789,10 @@
   llvm_unreachable("Cannot invoke this intrinsic");
 case Intrinsic::donothing:
   // Ignore invokes to @llvm.donothing: jump directly to the next BB.
+case Intrinsic::seh_try_begin:
+case Intrinsic::eha_scope_begin:
+case Intrinsic::seh_try_end:
+case Intrinsic::eha_scope_end:
   break;
 case Intrinsic::experimental_patchpoint_void:
 case Intrinsic::experimental_patchpoint_i64:
@@ -6583,6 +6587,10 @@
   lowerCallToExternalSymbol(I, FunctionName);
 return;
   case Intrinsic::donothing:
+  case Intrinsic::seh_try_begin:
+  case Intrinsic::eha_scope_begin:
+  case Intrinsic::seh_try_end:
+  case Intrinsic::eha_scope_end:
 // ignore
 return;
   case Intrinsic::experimental_stackmap:
Index: llvm/include/llvm/IR/Intrinsics.td
===
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -456,6 +456,16 @@
  [llvm_ptr_ty, llvm_ptr_ty],
  [IntrNoMem]>;
 
+// To mark the beginning/end of a try-scope for Windows SEH -EHa
+//  calls/invokes to these intrinsics are placed to model control flows
+//caused by HW exceptions under option -EHa.
+//  calls/invokes to these intrinsics will be discarded during a codegen pass
+//   after EH tables are generated
+def int_seh_try_begin : Intrinsic<[], [], [IntrReadMem, IntrWriteMem, IntrWillReturn]>;
+def int_seh_try_end : Intrinsic<[], [], [IntrReadMem, IntrWriteMem, IntrWillReturn]>;
+def int_eha_scope_begin : Intrinsic<[], [], [IntrNoMem]>;
+def int_eha_scope_end : Intrinsic<[], [], [IntrNoMem]>;
+
 // Note: we treat stacksave/stackrestore as writemem because we don't otherwise
 // model their dependencies on allocas.
 def int_stacksave : Intrinsic<[llvm_ptr_ty]>,
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -11530,6 +11530,59 @@
 the escaped allocas are allocated, which would break attempts to use
 '``llvm.localrecover``'.
 
+'``llvm.seh.try.begin``' and '``llvm.seh.try.end``' Intrinsics
+
+
+Syntax:
+"""
+
+::
+
+  declare void @llvm.seh.try.begin()
+  declare void @llvm.seh.try.end()
+
+Overview:
+"
+
+The '``llvm.seh.try.begin``' and '``llvm.seh.try.end``' intrinsics mark
+the boundary of a _try region for Windows SEH Asynchrous Exception Handling.
+
+Semantics:
+""
+
+When a C-function is compiled with Windows SEH Asynchrous Exception option,
+-feh_asynch (aka MSVC -EHa), these two intrinsics are injected to mark _try
+boundary and to prevent from potential exceptions being moved across boun

[PATCH] D80896: [clang-tidy][misc-redundant-expression] Support for CXXFoldExpr

2020-06-04 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

@njames93, @aaron.ballman do you have any other comments?


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

https://reviews.llvm.org/D80896



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


[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-06-04 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76077



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


[PATCH] D81107: Make syntax tree test print the line number when it fails

2020-06-04 Thread Marcel Hlopko via Phabricator via cfe-commits
hlopko accepted this revision.
hlopko added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81107



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


[PATCH] D80781: [clang] Always allow including builtin headers in [no_undeclared_headers] modules.

2020-06-04 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

Committed as 
https://github.com/llvm/llvm-project/commit/8d74de9de6d6cca552d7de7d0bfd36b6dd7d58dc.

I thought I had added a "Differential Revision:" to the commit message, but 
something must have gone wrong.


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

https://reviews.llvm.org/D80781



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


[PATCH] D81135: Add support for IntegerLiteral in SyntaxTree

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 268382.
eduucaldas added a comment.

Add support for IntegerLiteral in SyntaxTree


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81135

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -314,7 +314,7 @@
   |-SimpleDeclarator
   | |-b
   | |-=
-  | `-UnknownExpression
+  | `-IntegerLiteralExpression
   |   `-42
   `-;
 )txt");
@@ -371,7 +371,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
@@ -380,7 +380,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | |-CompoundStatement
@@ -390,7 +390,7 @@
 | `-IfStatement
 |   |-if
 |   |-(
-|   |-UnknownExpression
+|   |-IntegerLiteralExpression
 |   | `-0
 |   |-)
 |   `-CompoundStatement
@@ -461,7 +461,7 @@
 | |   |-a
 | |   `-ArraySubscript
 | | |-[
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-3
 | | `-]
 | `-;
@@ -501,7 +501,7 @@
 | | `-SimpleDeclarator
 | |   |-a
 | |   |-=
-| |   `-UnknownExpression
+| |   `-IntegerLiteralExpression
 | | `-10
 | `-;
 `-}
@@ -532,14 +532,14 @@
 |-SwitchStatement
 | |-switch
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
 |   |-{
 |   |-CaseStatement
 |   | |-case
-|   | |-UnknownExpression
+|   | |-IntegerLiteralExpression
 |   | | `-0
 |   | |-:
 |   | `-DefaultStatement
@@ -573,7 +573,7 @@
 |-WhileStatement
 | |-while
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
@@ -610,7 +610,7 @@
 | |-:
 | `-ReturnStatement
 |   |-return
-|   |-UnknownExpression
+|   |-IntegerLiteralExpression
 |   | `-100
 |   `-;
 `-}
@@ -648,7 +648,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | |-ExpressionStatement
@@ -699,6 +699,32 @@
 )txt");
 }
 
+TEST_P(SyntaxTreeTest, IntegerLiteralExpression) {
+  expectTreeDumpEqual(
+  R"cpp(
+void test() {
+  42;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-42
+| `-;
+`-}
+)txt");
+}
+
 TEST_P(SyntaxTreeTest, PostfixUnaryOperator) {
   expectTreeDumpEqual(
   R"cpp(
@@ -914,18 +940,18 @@
 |-{
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-1
 | | |--
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-2
 | `-;
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-1
 | | |-==
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-2
 | `-;
 |-ExpressionStatement
@@ -933,7 +959,7 @@
 | | |-UnknownExpression
 | | | `-a
 | | |-=
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-1
 | `-;
 |-ExpressionStatement
@@ -941,23 +967,23 @@
 | | |-UnknownExpression
 | | | `-a
 | | |-<<=
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-1
 | `-;
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-1
 | | |-||
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-0
 | `-;
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-1
 | | |-&
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-2
 | `-;
 |-ExpressionStatement
@@ -965,7 +991,7 @@
 | | |-UnknownExpression
 | | | `-a
 | | |-^=
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-3
 | `-;
 `-}
@@ -1018,10 +1044,10 @@
 | `-;
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-1
 | | |-bitand
-| | `-UnknownExpres

[PATCH] D80950: [clang-format] [PR44542,38872] String << String always get a forced newline.

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

@sammccall  in the example

  LOG_IF(DFATAL, exp_await_calls < num_await_calls_)
  << "Equality condition can never be satisfied:"
  << " exp_await_calls=" << exp_await_calls
  << " num_await_calls_=" << num_await_calls_;

I agree this is more pleasing, however Its ONLY broken this was because of your 
LineLimit and the variable lengths

The same function with smaller variables isn't quite so readable

  LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
<< " foo=" << a << " bar=" << b;

and there is inconsistency between

  LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
<< " foo=" << a << " is less than "
<< " bar=" << b;



  std::string reason = " is less than ";
  LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
<< " foo=" << a << reason << " bar=" << b;

I could see value in allowing (AlwaysBreak) (as this really help to show the 
need for a space before the `"foo=,is less and bar="`)

  LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
<< " foo="
<< a
<< " is less than "
<< " bar="
<< b;

and also not enforcing any breaking other than line length (Never)

  std::string reason = " is less than ";
  LOG_IF(DFATAL, a < b) << "=" << " foo=" << a << reason << " bar=" << b;

because that actually looks a little better IMHO than

  std::string reason = " is less than ";
  LOG_IF(DFATAL, a < b) << "="
<< " foo=" << a << reason << " bar=" << b;

But whatever we do I think we should leave the current one as the default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80950



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


[clang] 06cf7ad - Make syntax tree test print the line number when it fails

2020-06-04 Thread Dmitri Gribenko via cfe-commits
Author: Dmitri Gribenko
Date: 2020-06-04T10:42:44+02:00
New Revision: 06cf7adcc88178f887984fa74cdefb20cd8cd124

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

LOG: Make syntax tree test print the line number when it fails

Summary:
The syntax tree test uses a helper function that executes all testing
assertions. When an assertion fails, the only line number that gets
printed to the log refers to the helper function. After this change, we
would also get the line number of the EXPECT_TRUE macro invocation
(unfortunately, the line number of the last token of it, not the first
one, but there's not much I can do about it).

Reviewers: hlopko, eduucaldas

Reviewed By: hlopko, eduucaldas

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp 
b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index b8a188a1a76b..c7a2b14b4f3f 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -209,15 +209,22 @@ class SyntaxTreeTest : public ::testing::Test,
 return Root;
   }
 
-  void expectTreeDumpEqual(StringRef Code, StringRef Tree) {
+  ::testing::AssertionResult treeDumpEqual(StringRef Code, StringRef Tree) {
 SCOPED_TRACE(llvm::join(GetParam().getCommandLineArgs(), " "));
-SCOPED_TRACE(Code);
 
 auto *Root = buildTree(Code, GetParam());
-EXPECT_EQ(Diags->getClient()->getNumErrors(), 0u)
-<< "Source file has syntax errors, they were printed to the test log";
+if (Diags->getClient()->getNumErrors() != 0) {
+  return ::testing::AssertionFailure()
+ << "Source file has syntax errors, they were printed to the test "
+"log";
+}
 std::string Actual = std::string(StringRef(Root->dump(*Arena)).trim());
+// EXPECT_EQ shows the 
diff  between the two strings if they are 
diff erent.
 EXPECT_EQ(Tree.trim().str(), Actual);
+if (Actual != Tree.trim().str()) {
+  return ::testing::AssertionFailure();
+}
+return ::testing::AssertionSuccess();
   }
 
   // Adds a file to the test VFS.
@@ -266,11 +273,11 @@ class SyntaxTreeTest : public ::testing::Test,
 };
 
 TEST_P(SyntaxTreeTest, Simple) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 int main() {}
 void foo() {}
-)cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -293,15 +300,15 @@ void foo() {}
   `-CompoundStatement
 |-{
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, SimpleVariable) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 int a;
 int b = 42;
-)cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -317,14 +324,14 @@ int b = 42;
   | `-UnknownExpression
   |   `-42
   `-;
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, SimpleFunction) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void foo(int a, int b) {}
-)cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -346,17 +353,17 @@ void foo(int a, int b) {}
   `-CompoundStatement
 |-{
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, If) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 int main() {
   if (1) {}
   if (1) {} else if (0) {}
 }
-)cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -397,11 +404,11 @@ int main() {
 | |-{
 | `-}
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, For) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void test() {
   for (;;)  {}
@@ -428,21 +435,21 @@ void test() {
 |   |-{
 |   `-}
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, RangeBasedFor) {
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void test() {
   int a[3];
   for (int x : a)
 ;
 }
-  )cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -479,12 +486,17 @@ void test() {
 | `-EmptyStatement
 |   `-;
 `-}
-   )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, DeclarationStatement) {
-  expectTreeDumpEqual("void test() { int a = 10; }",
-  R"txt(
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+  int a = 10;
+}
+)cpp",
+  R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
   |-void
@@ -505,11 +517,11 @@ TEST_P(SyntaxTreeTest, DeclarationStatement) {
 | | `-10
 | `-;
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, Switch) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void test() {
   switch (1) {
@@

[PATCH] D81135: Add support for IntegerLiteral in SyntaxTree

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



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:190
+  }
+  syntax::Leaf *literal();
+};

"literalToken"?



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:706
+void test() {
+  42;
+}

Please add more tests for integers with suffixes (0u, 0ll etc.), different 
bases (hex, octal etc.), digit separators.

http://eel.is/c++draft/lex.icon
https://en.cppreference.com/w/cpp/language/integer_literal



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81135



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


[PATCH] D80950: [clang-format] [PR44542,38872] String << String always get a forced newline.

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

Just to add, I also think although because there are no tests to enforce it the 
primary reason is for when we see '\n', breaking the stream on endl but this is 
actually covered by another rule this also in mustBreak()

  if (Current.is(tok::lessless) &&
  ((Previous.is(tok::identifier) && Previous.TokenText == "endl") ||
   (Previous.Tok.isLiteral() && (Previous.TokenText.endswith("\\n\"") ||
 Previous.TokenText == "\'\\n\'"
return true;

Is going to break on what is most likely a natural heuristics where `\n` 
separates different lines

  LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
<< " foo=" << a << endl
<< " is less than "
<< " bar=" << b;
  
  LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
<< " foo=" << a << "\n"
<< " is less than "
<< " bar=" << b;

but this is also flawed depending on what precedes the newline

  LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
<< " foo=" << a << " and " << endl
<< " is less than "
<< " bar=" << b;
  
  LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
<< " foo=" << a << " and "
<< "\n"
<< " is less than "
<< " bar=" << b;

I guess these rules were a good first compromise.. and more likely you'd want 
different rules depending on how large the streaming operations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80950



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


[PATCH] D80896: [clang-tidy][misc-redundant-expression] Support for CXXFoldExpr

2020-06-04 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp:31
+struct Bar2 {
+  static_assert((... && (sizeof(Values) > 0)) || (... && (sizeof(Values) > 
0)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:47: warning: both sides of operator are 
equivalent [misc-redundant-expression]

See other comment but if you change this to use `==` instead of `||` you can 
move this all back to the bottom simplifying the changes in this PR.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp:196
 bool operator>(const MyStruct& lhs, MyStruct& rhs) { rhs.x--; return lhs.x > 
rhs.x; }
 bool operator||(MyStruct& lhs, const MyStruct& rhs) { lhs.x++; return lhs.x || 
rhs.x; }
 

This is why you aren't getting warnings issued when the test case is at the 
bottom. You have defined a `||` operator at global namespace level which I'm 
guessing leads to ambiguity when checking the `static_assert` operator in your 
test case - It'll have a dependent type.
Simple fix is to change the static_assert to use say `operator==` as that isn't 
defined globally.


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

https://reviews.llvm.org/D80896



___
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-06-04 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss updated this revision to Diff 268383.
danielkiss edited the summary of this revision.
danielkiss added a comment.

Patch is refactored, the new pass smooth out the attribute issues.
This version fixes issues with _clang_call_terminate, sanitisers and the CFI. 
New pass might need a new file, I'm not yet convinced myself.


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

https://reviews.llvm.org/D75181

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aarch64-branch-protection-attr.c
  clang/test/CodeGen/aarch64-sign-return-address.c
  clang/test/CodeGenCXX/aarch64-branch-target_clang_call_terminate.cpp
  clang/test/CodeGenCXX/aarch64-sign-return-address-static-ctor.cpp
  llvm/lib/Target/AArch64/AArch64.h
  llvm/lib/Target/AArch64/AArch64BranchTargets.cpp
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/test/CodeGen/AArch64/O0-pipeline.ll
  llvm/test/CodeGen/AArch64/O3-pipeline.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-2.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-3.ll

Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-3.ll
===
--- llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-3.ll
+++ llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-3.ll
@@ -8,10 +8,11 @@
   ret i32 0
 }
 
-!llvm.module.flags = !{!0, !1}
+!llvm.module.flags = !{!0, !1, !2}
 
 !0 = !{i32 4, !"branch-target-enforcement", i32 1}
 !1 = !{i32 4, !"sign-return-address", !"non-leaf"}
+!2 = !{i32 4, !"sign-return-address-key", !"a_key"}
 
 ; Both attribute present
 ; ASM:	.word	3221225472
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-2.ll
===
--- llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-2.ll
+++ llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-2.ll
@@ -8,9 +8,10 @@
   ret i32 0
 }
 
-!llvm.module.flags = !{!0}
+!llvm.module.flags = !{!0, !1}
 
 !0 = !{i32 4, !"sign-return-address", !"all"}
+!1 = !{i32 4, !"sign-return-address-key", !"a_key"}
 
 ; PAC attribute present
 ; ASM:	.word	3221225472
Index: llvm/test/CodeGen/AArch64/O3-pipeline.ll
===
--- llvm/test/CodeGen/AArch64/O3-pipeline.ll
+++ llvm/test/CodeGen/AArch64/O3-pipeline.ll
@@ -23,6 +23,8 @@
 ; CHECK-NEXT: Dominator Tree Construction
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Simplify the CFG
+; CHECK-NEXT: AArch64 Branch Protection
+; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
 ; CHECK-NEXT:   Lazy Branch Probability Analysis
Index: llvm/test/CodeGen/AArch64/O0-pipeline.ll
===
--- llvm/test/CodeGen/AArch64/O0-pipeline.ll
+++ llvm/test/CodeGen/AArch64/O0-pipeline.ll
@@ -16,6 +16,8 @@
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Expand Atomic instructions
+; CHECK-NEXT: AArch64 Branch Protection
+; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Module Verifier
 ; CHECK-NEXT:   Lower Garbage Collection Instructions
 ; CHECK-NEXT:   Shadow Stack GC Lowering
Index: llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
===
--- llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+++ llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
@@ -33,6 +33,7 @@
 #include "llvm/CodeGen/TargetPassConfig.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/Function.h"
+#include "llvm/IR/Metadata.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCTargetOptions.h"
@@ -454,6 +455,9 @@
   if (TM->getOptLevel() != CodeGenOpt::None && EnableAtomicTidy)
 addPass(createCFGSimplificationPass(1, true, true, false, true));
 
+  // Sets up the branch protection attributes for functions that added so far.
+  addPass(createAArch64BranchProtectionPass());
+
   // Run LoopDataPrefetch
   //
   // Run this before LSR to remove the multiplies involved in computing the
Index: llvm/lib/Target/AArch64/AArch64BranchTargets.cpp
===
--- llvm/lib/Target/AArch64/AArch64BranchTargets.cpp
+++ llvm/lib/Target/AArch64/AArch64BranchTargets.cpp
@@ -26,9 +26,57 @@
 using namespace llvm;
 
 #define DEBUG_TYPE "aarch64-branch-targets"
+#define AARCH64_BRANCH_PROTECTION_NAME "AArch64 Branch Protection"
 #define AARCH64_BRANCH_TARGETS_NAME "AArch64 Branch Targets"
 
 namespace {
+
+struct AArch64BranchProtection : public ModulePass {
+  static char ID;
+  AArch64BranchProtection() : ModulePass(ID) {
+initializeAArch64BranchProtectionPass(*PassRegistry::getPassRegistry());
+  }
+
+  bool runOnModule(Module &M) override {
+bool changed = false;
+const bo

[PATCH] D81107: Make syntax tree test print the line number when it fails

2020-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG06cf7adcc881: Make syntax tree test print the line number 
when it fails (authored by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81107

Files:
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -209,15 +209,22 @@
 return Root;
   }
 
-  void expectTreeDumpEqual(StringRef Code, StringRef Tree) {
+  ::testing::AssertionResult treeDumpEqual(StringRef Code, StringRef Tree) {
 SCOPED_TRACE(llvm::join(GetParam().getCommandLineArgs(), " "));
-SCOPED_TRACE(Code);
 
 auto *Root = buildTree(Code, GetParam());
-EXPECT_EQ(Diags->getClient()->getNumErrors(), 0u)
-<< "Source file has syntax errors, they were printed to the test log";
+if (Diags->getClient()->getNumErrors() != 0) {
+  return ::testing::AssertionFailure()
+ << "Source file has syntax errors, they were printed to the test "
+"log";
+}
 std::string Actual = std::string(StringRef(Root->dump(*Arena)).trim());
+// EXPECT_EQ shows the diff between the two strings if they are different.
 EXPECT_EQ(Tree.trim().str(), Actual);
+if (Actual != Tree.trim().str()) {
+  return ::testing::AssertionFailure();
+}
+return ::testing::AssertionSuccess();
   }
 
   // Adds a file to the test VFS.
@@ -266,11 +273,11 @@
 };
 
 TEST_P(SyntaxTreeTest, Simple) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 int main() {}
 void foo() {}
-)cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -293,15 +300,15 @@
   `-CompoundStatement
 |-{
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, SimpleVariable) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 int a;
 int b = 42;
-)cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -317,14 +324,14 @@
   | `-UnknownExpression
   |   `-42
   `-;
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, SimpleFunction) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void foo(int a, int b) {}
-)cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -346,17 +353,17 @@
   `-CompoundStatement
 |-{
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, If) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 int main() {
   if (1) {}
   if (1) {} else if (0) {}
 }
-)cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -397,11 +404,11 @@
 | |-{
 | `-}
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, For) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void test() {
   for (;;)  {}
@@ -428,21 +435,21 @@
 |   |-{
 |   `-}
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, RangeBasedFor) {
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void test() {
   int a[3];
   for (int x : a)
 ;
 }
-  )cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -479,12 +486,17 @@
 | `-EmptyStatement
 |   `-;
 `-}
-   )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, DeclarationStatement) {
-  expectTreeDumpEqual("void test() { int a = 10; }",
-  R"txt(
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+  int a = 10;
+}
+)cpp",
+  R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
   |-void
@@ -505,11 +517,11 @@
 | | `-10
 | `-;
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, Switch) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void test() {
   switch (1) {
@@ -549,11 +561,11 @@
 |   | `-;
 |   `-}
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, While) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 void test() {
   while (1) { continue; break; }
@@ -586,15 +598,20 @@
 |   | `-;
 |   `-}
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, UnhandledStatement) {
   // Unhandled statements should end up as 'unknown statement'.
   // This example uses a 'label statement', which does not yet have a syntax
   // counterpart.
-  expectTreeDumpEqual("int main() { foo: return 100; }",
-  R"txt(
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+int main() {
+  foo: return 100;
+}
+)cpp",
+  R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
   |-int
@@ -614,19 +631,19 @@
 |   | `-100
 |   `-;
 `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, Expressions) {
   // expressions should be wrapped in 'ExpressionStatement' when they appear
   // in a statem

[PATCH] D77644: [clangd] Handle additional includes while parsing ASTs

2020-06-04 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added inline comments.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:1034
   const PreambleData &Preamble;
-  const PreamblePatch &Patch;
+  llvm::Optional Patch;
   llvm::StringRef Contents;

Hi!

When compiling with gcc 7.4 I see a warning that I think originates from this 
line:

```
[4032/4668] Building CXX object 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/CodeComplete.cpp.o
In file included from /data/repo/master/llvm/include/llvm/ADT/STLExtras.h:19:0,
 from /data/repo/master/llvm/include/llvm/ADT/StringRef.h:12,
 from /data/repo/master/clang-tools-extra/clangd/URI.h:12,
 from /data/repo/master/clang-tools-extra/clangd/Protocol.h:26,
 from /data/repo/master/clang-tools-extra/clangd/Headers.h:12,
 from 
/data/repo/master/clang-tools-extra/clangd/CodeComplete.h:18,
 from 
/data/repo/master/clang-tools-extra/clangd/CodeComplete.cpp:20:
/data/repo/master/llvm/include/llvm/ADT/Optional.h: In instantiation of 'void 
llvm::optional_detail::OptionalStorage >::emplace(Args&& ...) 
[with Args = {const clang::clangd::PreamblePatch}; T = const 
clang::clangd::PreamblePatch; bool  = false]':
/data/repo/master/llvm/include/llvm/ADT/Optional.h:55:14:   required from 
'llvm::optional_detail::OptionalStorage 
>::OptionalStorage(llvm::optional_detail::OptionalStorage >&&) 
[with T = const clang::clangd::PreamblePatch; bool  = false]'
/data/repo/master/llvm/include/llvm/ADT/Optional.h:228:3:   required from here
/data/repo/master/llvm/include/llvm/ADT/Optional.h:89:12: warning: cast from 
type 'const clang::clangd::PreamblePatch*' to type 'void*' casts away 
qualifiers [-Wcast-qual]
 ::new ((void *)std::addressof(value)) T(std::forward(args)...);
^
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77644



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


[PATCH] D80950: [clang-format] [PR44542,38872] String << String always get a forced newline.

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

In D80950#2072926 , @MyDeveloperDay 
wrote:

> The same function with smaller variables isn't quite so readable
>
>   LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
> << " foo=" << a << " bar=" << b;
>


FWIW, this looks fine to me, it's the split between = and variable I was 
objecting to motsly.
We could still get unlucky depending on line lengths:

  LOG << "blah"
<< "foo=" << foo << " bar="
<< b;

In which case I'd probably split the space away from bar, writing the second 
line as `"<< "foo=" << foo << " "`...

> and there is inconsistency between
> 
>   LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
> << " foo=" << a << " is less than "
> << " bar=" << b;
> 
> 
> 
> 
>   std::string reason = " is less than ";
>   LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
> << " foo=" << a << reason << " bar=" << b;

Maybe I'm used to it, but that seems like a natural difference rather than an 
annoying inconsistency to me.
(The latter is clearly less readable with or without formatting, precisely 
*because* it's pasting together variables that we have to understand the 
semantics of to get any understanding).

>   std::string reason = " is less than ";
>   LOG_IF(DFATAL, a < b) << "=" << " foo=" << a << reason << " bar=" << b;
> 
> 
> because that actually looks a little better IMHO than
> 
>   std::string reason = " is less than ";
>   LOG_IF(DFATAL, a < b) << "="
> << " foo=" << a << reason << " bar=" << b;

This is clearly a question of taste :-)

An option seems attractive here. We haven't met the bar of multiple competing 
published style guides, but here the historical behaviour is idiosyncratic but 
long-standing and does some things people want...

I'd ask that we call the existing behavior something flexible like `Heuristic` 
or so... e.g. today we break after `endl`, and we should probably extend that 
to strings ending in `"\n"` since endl is often silly.
(If I was actually in a position to hack on clang-format more, I'd want to look 
at having a lower penalty when strings end in `=` etc, to encourage semantic 
breaks)

> But whatever we do I think we should leave the current one as the default.

I think we'd like to keep it for at least Google style. Feel less strongly 
about the others, but if an option is added we might as well separate the 
implementation from the flag-flip.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80950



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


[PATCH] D81136: Define rules for naming NodeRole and apply them.

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81136

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp

Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -120,18 +120,14 @@
 return OS << "IfStatement_elseKeyword";
   case syntax::NodeRole::IfStatement_elseStatement:
 return OS << "IfStatement_elseStatement";
-  case syntax::NodeRole::IntegerLiteralExpression_literalToken:
+  case syntax::NodeRole::LiteralToken:
 return OS << "IntegerLiteralExpression_literalToken";
-  case syntax::NodeRole::CxxNullPtrExpression_keyword:
-return OS << "CxxNullPtrExpression_keyword";
-  case syntax::NodeRole::UnaryOperatorExpression_operatorToken:
-return OS << "UnaryOperatorExpression_operatorToken";
+  case syntax::NodeRole::OperatorExpression_operatorToken:
+return OS << "OperatorExpression_operatorToken";
   case syntax::NodeRole::UnaryOperatorExpression_operand:
 return OS << "UnaryOperatorExpression_operand";
   case syntax::NodeRole::BinaryOperatorExpression_leftHandSide:
 return OS << "BinaryOperatorExpression_leftHandSide";
-  case syntax::NodeRole::BinaryOperatorExpression_operatorToken:
-return OS << "BinaryOperatorExpression_operatorToken";
   case syntax::NodeRole::BinaryOperatorExpression_rightHandSide:
 return OS << "BinaryOperatorExpression_rightHandSide";
   case syntax::NodeRole::ReturnStatement_value:
@@ -154,8 +150,8 @@
 return OS << "ExplicitTemplateInstantiation_declaration";
   case syntax::NodeRole::ArraySubscript_sizeExpression:
 return OS << "ArraySubscript_sizeExpression";
-  case syntax::NodeRole::TrailingReturnType_arrow:
-return OS << "TrailingReturnType_arrow";
+  case syntax::NodeRole::TrailingReturnType_arrowToken:
+return OS << "TrailingReturnType_arrowToken";
   case syntax::NodeRole::TrailingReturnType_declarator:
 return OS << "TrailingReturnType_declarator";
   case syntax::NodeRole::ParametersAndQualifiers_parameter:
@@ -168,12 +164,12 @@
 
 syntax::Leaf *syntax::IntegerLiteralExpression::literal() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::IntegerLiteralExpression_literalToken));
+  findChild(syntax::NodeRole::LiteralToken));
 }
 
 syntax::Leaf *syntax::CxxNullPtrExpression::nullPtrKeyword() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::CxxNullPtrExpression_keyword));
+  findChild(syntax::NodeRole::LiteralToken));
 }
 
 syntax::Expression *syntax::BinaryOperatorExpression::lhs() {
@@ -183,7 +179,7 @@
 
 syntax::Leaf *syntax::UnaryOperatorExpression::operatorToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::UnaryOperatorExpression_operatorToken));
+  findChild(syntax::NodeRole::OperatorExpression_operatorToken));
 }
 
 syntax::Expression *syntax::UnaryOperatorExpression::operand() {
@@ -193,7 +189,7 @@
 
 syntax::Leaf *syntax::BinaryOperatorExpression::operatorToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::BinaryOperatorExpression_operatorToken));
+  findChild(syntax::NodeRole::OperatorExpression_operatorToken));
 }
 
 syntax::Expression *syntax::BinaryOperatorExpression::rhs() {
@@ -402,7 +398,7 @@
 
 syntax::Leaf *syntax::TrailingReturnType::arrow() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::TrailingReturnType_arrow));
+  findChild(syntax::NodeRole::TrailingReturnType_arrowToken));
 }
 
 syntax::SimpleDeclarator *syntax::TrailingReturnType::declarator() {
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -609,26 +609,22 @@
   }
 
   bool WalkUpFromIntegerLiteral(IntegerLiteral *S) {
-Builder.markChildToken(
-S->getLocation(),
-syntax::NodeRole::IntegerLiteralExpression_literalToken);
+Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
 Builder.foldNode(Builder.getExprRange(S),
  new (allocator()) syntax::IntegerLiteralExpression, S);
 return true;
   }
 
   bool WalkUpFromCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *S) {
-Builder.markChildToken(S->getLocation(),
-   syntax::NodeRole::CxxNullPtrExpression_keyword);
+Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
 Builder.foldNode(Builder.getExprRange(S),
  new (allocator()) syntax::CxxNullPtrExpression, S);
 return true;
   }
 
   bool WalkUpFromUnaryOperator(UnaryOperator *S) {
-Builder.markChildToken(
-S->getOperatorLoc(),
-syntax::NodeRole::UnaryOperatorExpression_op

[PATCH] D80950: [clang-format] [PR44542,38872] String << String always get a forced newline.

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

I couldn't quite parse the last comment about \n, but yes the endl handling 
(didn't realize it also covered \n!) is implemented separately but falls under 
the same "heuristic formatting" umbrella I think.

>   LOG_IF(DFATAL, a < b) << "Equality condition can never be satisfied:"
><< " foo=" << a << " and "
><< "\n"
><< " is less than "
><< " bar=" << b;

This formatting seems fine to me: I'm not sure why you'd write `" and " << 
"\n"` separately if you didn't want a break there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80950



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


[PATCH] D81135: Add support for IntegerLiteral in SyntaxTree

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 268397.
eduucaldas added a comment.

answer comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81135

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp

Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -120,18 +120,14 @@
 return OS << "IfStatement_elseKeyword";
   case syntax::NodeRole::IfStatement_elseStatement:
 return OS << "IfStatement_elseStatement";
-  case syntax::NodeRole::IntegerLiteralExpression_literalToken:
+  case syntax::NodeRole::LiteralToken:
 return OS << "IntegerLiteralExpression_literalToken";
-  case syntax::NodeRole::CxxNullPtrExpression_keyword:
-return OS << "CxxNullPtrExpression_keyword";
-  case syntax::NodeRole::UnaryOperatorExpression_operatorToken:
-return OS << "UnaryOperatorExpression_operatorToken";
+  case syntax::NodeRole::OperatorExpression_operatorToken:
+return OS << "OperatorExpression_operatorToken";
   case syntax::NodeRole::UnaryOperatorExpression_operand:
 return OS << "UnaryOperatorExpression_operand";
   case syntax::NodeRole::BinaryOperatorExpression_leftHandSide:
 return OS << "BinaryOperatorExpression_leftHandSide";
-  case syntax::NodeRole::BinaryOperatorExpression_operatorToken:
-return OS << "BinaryOperatorExpression_operatorToken";
   case syntax::NodeRole::BinaryOperatorExpression_rightHandSide:
 return OS << "BinaryOperatorExpression_rightHandSide";
   case syntax::NodeRole::ReturnStatement_value:
@@ -154,8 +150,8 @@
 return OS << "ExplicitTemplateInstantiation_declaration";
   case syntax::NodeRole::ArraySubscript_sizeExpression:
 return OS << "ArraySubscript_sizeExpression";
-  case syntax::NodeRole::TrailingReturnType_arrow:
-return OS << "TrailingReturnType_arrow";
+  case syntax::NodeRole::TrailingReturnType_arrowToken:
+return OS << "TrailingReturnType_arrowToken";
   case syntax::NodeRole::TrailingReturnType_declarator:
 return OS << "TrailingReturnType_declarator";
   case syntax::NodeRole::ParametersAndQualifiers_parameter:
@@ -168,12 +164,12 @@
 
 syntax::Leaf *syntax::IntegerLiteralExpression::literal() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::IntegerLiteralExpression_literalToken));
+  findChild(syntax::NodeRole::LiteralToken));
 }
 
 syntax::Leaf *syntax::CxxNullPtrExpression::nullPtrKeyword() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::CxxNullPtrExpression_keyword));
+  findChild(syntax::NodeRole::LiteralToken));
 }
 
 syntax::Expression *syntax::BinaryOperatorExpression::lhs() {
@@ -183,7 +179,7 @@
 
 syntax::Leaf *syntax::UnaryOperatorExpression::operatorToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::UnaryOperatorExpression_operatorToken));
+  findChild(syntax::NodeRole::OperatorExpression_operatorToken));
 }
 
 syntax::Expression *syntax::UnaryOperatorExpression::operand() {
@@ -193,7 +189,7 @@
 
 syntax::Leaf *syntax::BinaryOperatorExpression::operatorToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::BinaryOperatorExpression_operatorToken));
+  findChild(syntax::NodeRole::OperatorExpression_operatorToken));
 }
 
 syntax::Expression *syntax::BinaryOperatorExpression::rhs() {
@@ -402,7 +398,7 @@
 
 syntax::Leaf *syntax::TrailingReturnType::arrow() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::TrailingReturnType_arrow));
+  findChild(syntax::NodeRole::TrailingReturnType_arrowToken));
 }
 
 syntax::SimpleDeclarator *syntax::TrailingReturnType::declarator() {
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -609,26 +609,22 @@
   }
 
   bool WalkUpFromIntegerLiteral(IntegerLiteral *S) {
-Builder.markChildToken(
-S->getLocation(),
-syntax::NodeRole::IntegerLiteralExpression_literalToken);
+Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
 Builder.foldNode(Builder.getExprRange(S),
  new (allocator()) syntax::IntegerLiteralExpression, S);
 return true;
   }
 
   bool WalkUpFromCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *S) {
-Builder.markChildToken(S->getLocation(),
-   syntax::NodeRole::CxxNullPtrExpression_keyword);
+Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
 Builder.foldNode(Builder.getExprRange(S),
  new (allocator()) syntax::CxxNullPtrExpression, S);
 return true;
   }
 
   bool WalkUpFromUnaryOperator(UnaryOperator *S) {
-Builder.markChildToken(
-S->getOperatorLoc(

[PATCH] D80950: [clang-format] [PR44542,38872] String << String always get a forced newline.

2020-06-04 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Another //weak// argument about why the current rule makes sense (break before 
`<<` between two string literals) is: suppose you don't want such a break. Then 
you can //change your code// to concatenate the two string literals into a 
single one, avoiding the problem altogether, if possible (this can be 
unacceptable in cases where the combined length of the two string literals is 
excessive, but at that point we will likely break because of the column limit; 
or when there is a chain of more than 2 string literals and the user wishes to 
keep them //fluently reflowing// as the code evolves.)

However, a similar argument applies in reverse: suppose clang-format did not 
force-break before `<<` between two string literals. Then you can force a line 
break by //adding an empty line comment//. That seems to me like an OK tradeoff 
between regularity, consistency with non-string literals cases, and flexibility 
to influence the formatting in cases that are better off with line breaks.

Maybe this at its core is more of a communication/documentation issue, as I can 
totally see how confusing this heuristic is for users of clang-format.

I'm very slightly against adding a style option for this -- it feels too niche 
(how will we name it?) and it will leave users with a choice between suboptimal 
(in my opinion) cases. However adding an option seems like the best tradeoff 
short of coming up with a good heuristic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80950



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


[clang-tools-extra] 4f4a8ae - [clangd] Fix build for gcc 7.4

2020-06-04 Thread Kadir Cetinkaya via cfe-commits
Author: Kadir Cetinkaya
Date: 2020-06-04T12:02:49+02:00
New Revision: 4f4a8ae72e95f2c7fa5e4ca56dd6b1a83a304680

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

LOG: [clangd] Fix build for gcc 7.4

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index d2ee41f36cf4..bc06199eb38f 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1031,7 +1031,7 @@ struct SemaCompleteInput {
   PathRef FileName;
   const tooling::CompileCommand &Command;
   const PreambleData &Preamble;
-  llvm::Optional Patch;
+  const llvm::Optional Patch;
   llvm::StringRef Contents;
   size_t Offset;
   llvm::IntrusiveRefCntPtr VFS;



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


Re: [PATCH] D77644: [clangd] Handle additional includes while parsing ASTs

2020-06-04 Thread Kadir Çetinkaya via cfe-commits
Hi Mikael,

sent out 4f4a8ae72e95f2c7fa5e4ca56dd6b1a83a304680, please let me know if it
helps!

On Thu, Jun 4, 2020 at 12:40 PM Mikael Holmén via Phabricator <
revi...@reviews.llvm.org> wrote:

> uabelho added inline comments.
>
>
> 
> Comment at: clang-tools-extra/clangd/CodeComplete.cpp:1034
>const PreambleData &Preamble;
> -  const PreamblePatch &Patch;
> +  llvm::Optional Patch;
>llvm::StringRef Contents;
> 
> Hi!
>
> When compiling with gcc 7.4 I see a warning that I think originates from
> this line:
>
> ```
> [4032/4668] Building CXX object
> tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/CodeComplete.cpp.o
> In file included from
> /data/repo/master/llvm/include/llvm/ADT/STLExtras.h:19:0,
>  from
> /data/repo/master/llvm/include/llvm/ADT/StringRef.h:12,
>  from /data/repo/master/clang-tools-extra/clangd/URI.h:12,
>  from
> /data/repo/master/clang-tools-extra/clangd/Protocol.h:26,
>  from
> /data/repo/master/clang-tools-extra/clangd/Headers.h:12,
>  from
> /data/repo/master/clang-tools-extra/clangd/CodeComplete.h:18,
>  from
> /data/repo/master/clang-tools-extra/clangd/CodeComplete.cpp:20:
> /data/repo/master/llvm/include/llvm/ADT/Optional.h: In instantiation of
> 'void llvm::optional_detail::OptionalStorage
> >::emplace(Args&& ...) [with Args = {const clang::clangd::PreamblePatch}; T
> = const clang::clangd::PreamblePatch; bool  = false]':
> /data/repo/master/llvm/include/llvm/ADT/Optional.h:55:14:   required from
> 'llvm::optional_detail::OptionalStorage
> >::OptionalStorage(llvm::optional_detail::OptionalStorage
> >&&) [with T = const clang::clangd::PreamblePatch; bool  =
> false]'
> /data/repo/master/llvm/include/llvm/ADT/Optional.h:228:3:   required from
> here
> /data/repo/master/llvm/include/llvm/ADT/Optional.h:89:12: warning: cast
> from type 'const clang::clangd::PreamblePatch*' to type 'void*' casts away
> qualifiers [-Wcast-qual]
>  ::new ((void *)std::addressof(value)) T(std::forward(args)...);
> ^
> ```
>
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D77644/new/
>
> https://reviews.llvm.org/D77644
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-06-04 Thread Alexandros Lamprineas via Phabricator via cfe-commits
labrinea added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:6989
+  false,
+  getTarget().hasBFloat16Type());
   llvm::Type *Ty = VTy;

shouldn't this be `getTargetHooks().getABIInfo().allowBFloatArgsAndRet()` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76077



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


[PATCH] D81135: Add support for IntegerLiteral in SyntaxTree

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 268403.
eduucaldas added a comment.

fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81135

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -314,7 +314,7 @@
   |-SimpleDeclarator
   | |-b
   | |-=
-  | `-UnknownExpression
+  | `-IntegerLiteralExpression
   |   `-42
   `-;
 )txt");
@@ -371,7 +371,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
@@ -380,7 +380,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | |-CompoundStatement
@@ -390,7 +390,7 @@
 | `-IfStatement
 |   |-if
 |   |-(
-|   |-UnknownExpression
+|   |-IntegerLiteralExpression
 |   | `-0
 |   |-)
 |   `-CompoundStatement
@@ -461,7 +461,7 @@
 | |   |-a
 | |   `-ArraySubscript
 | | |-[
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-3
 | | `-]
 | `-;
@@ -501,7 +501,7 @@
 | | `-SimpleDeclarator
 | |   |-a
 | |   |-=
-| |   `-UnknownExpression
+| |   `-IntegerLiteralExpression
 | | `-10
 | `-;
 `-}
@@ -532,14 +532,14 @@
 |-SwitchStatement
 | |-switch
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
 |   |-{
 |   |-CaseStatement
 |   | |-case
-|   | |-UnknownExpression
+|   | |-IntegerLiteralExpression
 |   | | `-0
 |   | |-:
 |   | `-DefaultStatement
@@ -573,7 +573,7 @@
 |-WhileStatement
 | |-while
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
@@ -610,7 +610,7 @@
 | |-:
 | `-ReturnStatement
 |   |-return
-|   |-UnknownExpression
+|   |-IntegerLiteralExpression
 |   | `-100
 |   `-;
 `-}
@@ -648,7 +648,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | |-ExpressionStatement
@@ -699,6 +699,32 @@
 )txt");
 }
 
+TEST_P(SyntaxTreeTest, IntegerLiteralExpression) {
+  expectTreeDumpEqual(
+  R"cpp(
+void test() {
+  42;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-42
+| `-;
+`-}
+)txt");
+}
+
 TEST_P(SyntaxTreeTest, PostfixUnaryOperator) {
   expectTreeDumpEqual(
   R"cpp(
@@ -914,18 +940,18 @@
 |-{
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-1
 | | |--
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-2
 | `-;
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-1
 | | |-==
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-2
 | `-;
 |-ExpressionStatement
@@ -933,7 +959,7 @@
 | | |-UnknownExpression
 | | | `-a
 | | |-=
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-1
 | `-;
 |-ExpressionStatement
@@ -941,23 +967,23 @@
 | | |-UnknownExpression
 | | | `-a
 | | |-<<=
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-1
 | `-;
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-1
 | | |-||
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-0
 | `-;
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-1
 | | |-&
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-2
 | `-;
 |-ExpressionStatement
@@ -965,7 +991,7 @@
 | | |-UnknownExpression
 | | | `-a
 | | |-^=
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression
 | |   `-3
 | `-;
 `-}
@@ -1018,10 +1044,10 @@
 | `-;
 |-ExpressionStatement
 | |-BinaryOperatorExpression
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-1
 | | |-bitand
-| | `-UnknownExpression
+| | `-IntegerLiteralExpression

[PATCH] D80961: WIP: Ignore template instantiations if not in AsIs mode

2020-06-04 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In D80961#2068865 , @ymandel wrote:

> Thank you for bringing up this issue. I think it highlights an underlying 
> problem -- editing templates is quite difficult -- that neither setting will 
> address, as Dmitri expanded on above. Given the parallel to macros, I'd say 
> your change is better than the status quo. Most clang tidies and other 
> rewriting tools that I've encountered simply skip code in macro expansions, 
> rather than reason about how to update the macro definition or whatnot. So, 
> by that reasoning, we should skip template instantations.


I've personally written quite a few tools that changed macro definitions. Do 
you have numbers on how many of the library team's tools generally want to 
match template instantiations?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80961



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


[PATCH] D80961: WIP: Ignore template instantiations if not in AsIs mode

2020-06-04 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

Without jumping into the discussion whether it should be the default, I think 
we should be able to control template instantiation visitation separately from 
other implicit nodes.
Having to put AsIs on a matcher every time you need to match template 
instantiations is a rather big change (suddenly you have to change all the 
matchers you've written so far).
I love the idea of being able to control visitation of template instantiation.
I am somewhat torn on whether it should be the default, and would like to see 
more data.
I feel more strongly about needing AsIs when I want to match template 
instantiations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80961



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


[PATCH] D80490: [clang-tidy] Check for rule of five and zero.

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

It would take more complex matching and diagnostics logic, but it would be so 
much nicer if the diagnostics were grouped. So instead of having a diagnostic 
about class `X` defining a copy construct and another about it defining a copy 
assignment operator, It could just say `X` defines a copy constructor and copy 
assignment operator without all 5 special members defined. The `optionally` 
matcher could be handy in implementing this.




Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/RuleOfFiveAndZeroCheck.cpp:22
+: ClangTidyCheck(Name, Context),
+  StrictCheck(Options.get("StrictCheck", false)) {}
+

You need to implement the `storeOptions` method to store this.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/RuleOfFiveAndZeroCheck.cpp:25-26
+void RuleOfFiveAndZeroCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus11)
+return;
+

move this to the `isLanguageVersionSupported` virtual function



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/RuleOfFiveAndZeroCheck.cpp:81
+  if (StrictCheck) {
+Finder->addMatcher(cxxRecordDecl(allOf(DefinesDestructor,
+   unless(DefinesAllSpecialMembers)))

You don't need to specify `allOf` here, top level matchers are implicitly 
`allOf` matchers. Same goes for all cases below.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-rule-of-five-and-zero-strict.cpp:18-22
+  DeletesEverything(const DeletesEverything &);
+  DeletesEverything &operator=(const DeletesEverything &);
+  DeletesEverything(DeletesEverything &&);
+  DeletesEverything &operator=(DeletesEverything &&);
+  ~DeletesEverything();

Probably doesn't affect the tests, but shouldn't these all be ` = delete;`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80490



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


[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-06-04 Thread Simon Moll via Phabricator via cfe-commits
simoll marked 2 inline comments as done.
simoll added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:4710
 if (!CGF.CGM.getCodeGenOpts().PreserveVec3Type) {
-  auto *Vec4Ty = llvm::FixedVectorType::get(
+  auto Vec4Ty = llvm::VectorType::get(
   cast(DstTy)->getElementType(), 4);

Accidental change. Will undo.



Comment at: clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:590
+  CharUnits Tail =
+  getSize(Prior->Data); // FIXME assumes `i8` multiples for boolean vector!
   for (std::vector::iterator Member = Prior + 1,

This is an old comment that is no longer helpful. Will remove.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083



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


[PATCH] D80928: [BFloat] Add convert/copy instrinsic support

2020-06-04 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added inline comments.



Comment at: llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp:4675
+  SDValue Ops[] = { Src, Pred, Reg0 };
+  CurDAG->SelectNodeTo(N, ARM::BF16_VCVT, MVT::v4i16, Ops);
+  return;

Why does it return `MVT::v4i16`, not `MVT::v4bf16`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80928



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


[clang] a7c6bec - [Sema] Remove unused matrix_begin/end helpers (NFC).

2020-06-04 Thread Florian Hahn via cfe-commits
Author: Florian Hahn
Date: 2020-06-04T11:29:01+01:00
New Revision: a7c6bec228ca28e9eee77433292ac86d77b67790

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

LOG: [Sema] Remove unused matrix_begin/end helpers (NFC).

The matrix_types() helper returning an iterator range is used instead.

Added: 


Modified: 
clang/lib/Sema/SemaOverload.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 9739e1511039..11b6e40e8cd4 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -7749,8 +7749,6 @@ class BuiltinCandidateTypeSet  {
   iterator vector_end() { return VectorTypes.end(); }
 
   llvm::iterator_range matrix_types() { return MatrixTypes; }
-  iterator matrix_begin() { return MatrixTypes.begin(); }
-  iterator matrix_end() { return MatrixTypes.end(); }
 
   bool containsMatrixType(QualType Ty) const { return MatrixTypes.count(Ty); }
   bool hasNonRecordTypes() { return HasNonRecordTypes; }



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


Re: [PATCH] D31702: Append -w when LLVM_ENABLE_WARNINGS is Off.

2020-06-04 Thread Vassil Vassilev via cfe-commits
On 6/4/20 6:58 AM, Sean Silva wrote:

Can we revert this?

In our downstream project we were bitten by this: 
https://github.com/google/mlir-npcomp/commit/cd7258dbd48bd9254c6741cab2d3f4e36cbd3c84


It seems that now by default anybody that depends on LLVM with CMake 
will globally get a `-w` passed to their compiler. That doesn't seem 
like good behavior.



  Wouldn't that be the case for all append clauses in that file?




-- Sean Silva

On Wed, Apr 12, 2017 at 1:56 PM Vassil Vassilev via Phabricator via 
llvm-commits > wrote:


v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r300100.


https://reviews.llvm.org/D31702



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



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


[PATCH] D80699: [Analyzer][StreamChecker] Add check for pointer escape.

2020-06-04 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:439-441
+  // Do not handle untracked stream. It is probably escaped.
+  if (!State->get(StreamSym))
+return;

How does this interact with D78280?



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:952-954
+  for (InvalidatedSymbols::const_iterator I = Escaped.begin(),
+  E = Escaped.end();
+   I != E; ++I) {

Foreach? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80699



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


[PATCH] D81138: [SemaOverload] Use iterator_range to iterate over VectorTypes (NFC).

2020-06-04 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
fhahn added reviewers: rjmccall, arphaman, jfb, Bigcheese.
Herald added a subscriber: dexonsmith.
Herald added a project: clang.

We can simplify the code a bit by using iterator_range instead of
plain iterators. Matrix type support here (added in 6f6e91d19337 
)
already uses an iterator_range.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81138

Files:
  clang/lib/Sema/SemaOverload.cpp

Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -7745,8 +7745,7 @@
   /// enumeration_end - Past the last enumeration type found;
   iterator enumeration_end() { return EnumerationTypes.end(); }
 
-  iterator vector_begin() { return VectorTypes.begin(); }
-  iterator vector_end() { return VectorTypes.end(); }
+  llvm::iterator_range vector_types() { return VectorTypes; }
 
   llvm::iterator_range matrix_types() { return MatrixTypes; }
 
@@ -8292,13 +8291,8 @@
 }
 
 // Extension: We also add these operators for vector types.
-for (BuiltinCandidateTypeSet::iterator
-  Vec = CandidateTypes[0].vector_begin(),
-   VecEnd = CandidateTypes[0].vector_end();
- Vec != VecEnd; ++Vec) {
-  QualType VecTy = *Vec;
+for (QualType VecTy : CandidateTypes[0].vector_types())
   S.AddBuiltinCandidate(&VecTy, Args, CandidateSet);
-}
   }
 
   // C++ [over.built]p8:
@@ -8332,13 +8326,8 @@
 }
 
 // Extension: We also add this operator for vector types.
-for (BuiltinCandidateTypeSet::iterator
-  Vec = CandidateTypes[0].vector_begin(),
-   VecEnd = CandidateTypes[0].vector_end();
- Vec != VecEnd; ++Vec) {
-  QualType VecTy = *Vec;
+for (QualType VecTy : CandidateTypes[0].vector_types())
   S.AddBuiltinCandidate(&VecTy, Args, CandidateSet);
-}
   }
 
   // C++ [over.match.oper]p16:
@@ -8569,18 +8558,11 @@
 
 // Extension: Add the binary operators ==, !=, <, <=, >=, >, *, /, and the
 // conditional operator for vector types.
-for (BuiltinCandidateTypeSet::iterator
-  Vec1 = CandidateTypes[0].vector_begin(),
-   Vec1End = CandidateTypes[0].vector_end();
- Vec1 != Vec1End; ++Vec1) {
-  for (BuiltinCandidateTypeSet::iterator
-Vec2 = CandidateTypes[1].vector_begin(),
- Vec2End = CandidateTypes[1].vector_end();
-   Vec2 != Vec2End; ++Vec2) {
-QualType LandR[2] = { *Vec1, *Vec2 };
+for (const QualType &Vec1Ty : CandidateTypes[0].vector_types())
+  for (const QualType &Vec2Ty : CandidateTypes[1].vector_types()) {
+QualType LandR[2] = {Vec1Ty, Vec2Ty};
 S.AddBuiltinCandidate(LandR, Args, CandidateSet);
   }
-}
   }
 
   /// Add binary operator overloads for each candidate matrix type M1, M2:
@@ -8861,30 +8843,23 @@
 }
 
 // Extension: Add the binary operators =, +=, -=, *=, /= for vector types.
-for (BuiltinCandidateTypeSet::iterator
-  Vec1 = CandidateTypes[0].vector_begin(),
-   Vec1End = CandidateTypes[0].vector_end();
- Vec1 != Vec1End; ++Vec1) {
-  for (BuiltinCandidateTypeSet::iterator
-Vec2 = CandidateTypes[1].vector_begin(),
- Vec2End = CandidateTypes[1].vector_end();
-   Vec2 != Vec2End; ++Vec2) {
+for (const QualType &Vec1Ty : CandidateTypes[0].vector_types())
+  for (const QualType &Vec2Ty : CandidateTypes[0].vector_types()) {
 QualType ParamTypes[2];
-ParamTypes[1] = *Vec2;
+ParamTypes[1] = Vec2Ty;
 // Add this built-in operator as a candidate (VQ is empty).
-ParamTypes[0] = S.Context.getLValueReferenceType(*Vec1);
+ParamTypes[0] = S.Context.getLValueReferenceType(Vec1Ty);
 S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
   /*IsAssignmentOperator=*/isEqualOp);
 
 // Add this built-in operator as a candidate (VQ is 'volatile').
 if (VisibleTypeConversionsQuals.hasVolatile()) {
-  ParamTypes[0] = S.Context.getVolatileType(*Vec1);
+  ParamTypes[0] = S.Context.getVolatileType(Vec1Ty);
   ParamTypes[0] = S.Context.getLValueReferenceType(ParamTypes[0]);
   S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
 /*IsAssignmentOperator=*/isEqualOp);
 }
   }
-}
   }
 
   // C++ [over.built]p22:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80725: [Analyzer][StreamChecker] Updated initialization of BugType's.

2020-06-04 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/D80725/new/

https://reviews.llvm.org/D80725



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


[PATCH] D78280: [Analyzer][StreamChecker] Track streams that were not found to be opened.

2020-06-04 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:36
+  /// (False if the stream was first encountered in a non-opening function.)
+  bool OpenEncountered;
 

baloghadamsoftware wrote:
> Maybe `SawOpened` or `ExplicitlyOpened`?
Shouldn't this be in `KindTy`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78280



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


[PATCH] D77062: [analyzer] Added check for unacceptable equality operation between Loc and NonLoc types

2020-06-04 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov marked 3 inline comments as done.
ASDenysPetrov added a comment.

@NoQ You concerns are absolutly justified. I agree with you. Let me tell what 
I'm thinking in inlines.

If you are interested in why the assertion happens, please, look D77062#1977613 





Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:273
   Optional val = V.getAs();
-  if (!val)
-return std::pair(state, state);
+  if (val && !V.getAs()) {
+ // return pair shall be {null, non-null} so reorder states

NoQ wrote:
> Basically `SVal::getAs<>` should not be used for discovering the type of the 
> value; only the exact representation that's used for the value of the type 
> that's already in your possession. Say, it's ok to use it to discriminate 
> between, say, compound value and lazy compound value. It's ok to use it to 
> discriminate between a concrete integer and a symbol. It's ok to use it do 
> discriminate between a known value and an unknown value. But if it's used for 
> discriminating between a compound value and a numeric symbol, i'm 99% sure 
> it's incorrect. You should already know the type from the AST before you even 
> obtain the value. It doesn't make sense to run the checker at all if the 
> function receives a structure. And if it doesn't receive the structure but 
> the run-time value is of structure type, then either the checker isn't 
> obtaining the value correctly or there's bug in path-sensitive analysis. 
> That's why i still believe you're only treating the symptoms. There's nothing 
> normal in the situation where "strcpy suddenly accepts a structure (or an 
> array) by value".
I'll remove `V.getAs()`. I mistakenly added this 
`V.getAs()` to keep code safe regardless of the 
checker intention and sanity. The point is that `state->assume(*val)` calls 
`ConstraintMgr->assumeDual` which finally calls 
`SimpleConstraintManager::assumeAux`. `assumeAux` handles all NonLoc kinds 
except **LazyCompoundValKind**and **CompoundValKind**(I missed to check it). In 
case of these two kinds it leads to `llvm_unreachable("'Assume' not implemented 
for this NonLoc");`. But for now I understand that I failed because 
**unreachable** means I might not have check for those kinds, since the 
function already takes on this work. 

However it is not an actual fix. The fix is `std::tie(states.second, 
states.first) = state->assume(*val);`. You can see the summary above.



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2270-2278
   // Pro-actively check that argument types are safe to do arithmetic upon.
   // We do not want to crash if someone accidentally passes a structure
   // into, say, a C++ overload of any of these functions. We could not check
   // that for std::copy because they may have arguments of other types.
   for (auto I : CE->arguments()) {
 QualType T = I->getType();
 if (!T->isIntegralOrEnumerationType() && !T->isPointerType())

This check prevents passing **structures**. From this point we are sure to work 
with **pointers **and **integral **types in arguments:
E.g. `char *strcpy(int i1, int i2);`, `char *strcpy(char *c1, char *c2);`, 
`char *strcpy(Kind t1, Kind t2);`
This confirms @NoQ's supposition that checker narrows argument types.
P.S. Honestly I'd narrow this more aggressively to just a **char pointer 
**type, anyway it doesn't relate to the bug and I wouldn't add this to a single 
patch.


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

https://reviews.llvm.org/D77062



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


[PATCH] D80300: [Driver] Add DEFAULT_DYLD_PREFIX and DEFAULT_RPATH to complement DEFAULT_SYSROOT

2020-06-04 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

According to https://clang.llvm.org/docs/CrossCompilation.html (under 
`Toolchain Options` option 2) it is quite likely that a user that desires to 
cross-compile will have the necessary toolchain installed into a directory that 
will not require the use of `--sysroot`.

So I think that letting `--target` override the default 
`--sysroot/--dyld-prefix/--rpath` is reasonable. What I am suggesting is that 
if `--target` is specified on the command line, it clears any default setting 
of these three options (i.e. clears them unless they were explicitly specified 
on the command line).

Namely, something along the lines of:

  diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
  index 5c726b2..9a85394 100644
  --- a/clang/lib/Driver/Driver.cpp
  +++ b/clang/lib/Driver/Driver.cpp
  @@ -1073,8 +1073,13 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
   T.setObjectFormat(llvm::Triple::COFF);
   TargetTriple = T.str();
 }
  -  if (const Arg *A = Args.getLastArg(options::OPT_target))
  +  if (const Arg *A = Args.getLastArg(options::OPT_target)) {
   TargetTriple = A->getValue();
  +if (!Args.getLastArg(options::OPT__sysroot_EQ))
  +  SysRoot = "";
  +if (!Args.getLastArg(options::OPT__dyld_prefix_EQ))
  +  DyldPrefix = "";
  +  }

And something similar for `DEFAULT_RPATH`.

Would something like this be satisfactory for everyone here? Or do others think 
this is the "worst of both worlds"? :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80300



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


[PATCH] D77598: Integral template argument suffix and cast printing

2020-06-04 Thread Pratyush Das via Phabricator via cfe-commits
reikdas updated this revision to Diff 268412.
reikdas marked an inline comment as done.
reikdas retitled this revision from "Integral template argument suffix 
printing" to "Integral template argument suffix and cast printing".
reikdas edited the summary of this revision.
reikdas added a comment.

Addresses @rsmith  's comments.


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

https://reviews.llvm.org/D77598

Files:
  clang/lib/AST/TemplateBase.cpp
  clang/test/CXX/dcl.decl/dcl.decomp/p3.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p12.cpp
  clang/test/CodeGenCXX/debug-info-template.cpp
  clang/test/Index/print-type.cpp
  clang/test/Misc/integer-literal-printing.cpp
  clang/test/Modules/lsv-debuginfo.cpp
  clang/test/SemaCXX/builtin-align-cxx.cpp
  clang/test/SemaCXX/cxx11-ast-print.cpp
  clang/test/SemaCXX/cxx11-call-to-deleted-constructor.cpp
  clang/test/SemaCXX/invalid-instantiated-field-decl.cpp
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/vector.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp
  clang/test/SemaTemplate/delegating-constructors.cpp
  clang/test/SemaTemplate/dependent-names.cpp
  clang/test/SemaTemplate/matrix-type.cpp
  clang/test/SemaTemplate/temp_arg_nontype.cpp

Index: clang/test/SemaTemplate/temp_arg_nontype.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -270,6 +270,24 @@
   void test_char_possibly_negative() { enable_if_char<'\x02'>::type i; } // expected-error{{enable_if_char<'\x02'>'; did you mean 'enable_if_char<'a'>::type'?}}
   void test_char_single_quote() { enable_if_char<'\''>::type i; } // expected-error{{enable_if_char<'\''>'; did you mean 'enable_if_char<'a'>::type'?}}
   void test_char_backslash() { enable_if_char<'\\'>::type i; } // expected-error{{enable_if_char<'\\'>'; did you mean 'enable_if_char<'a'>::type'?}}
+  
+  template  struct enable_if_int {};
+  template <> struct enable_if_int<1> { typedef int type; }; // expected-note{{'enable_if_int<1>::type' declared here}}
+  void test_int() { enable_if_int<2>::type i; } // expected-error{{enable_if_int<2>'; did you mean 'enable_if_int<1>::type'?}}
+
+  template  struct enable_if_unsigned_int {};
+  template <> struct enable_if_unsigned_int<1> { typedef int type; }; // expected-note{{'enable_if_unsigned_int<1>::type' declared here}}
+  void test_unsigned_int() { enable_if_unsigned_int<2>::type i; } // expected-error{{enable_if_unsigned_int<2U>'; did you mean 'enable_if_unsigned_int<1>::type'?}}
+
+
+  template  struct enable_if_unsigned_long_long {};
+  template <> struct enable_if_unsigned_long_long<1> { typedef int type; }; // expected-note{{'enable_if_unsigned_long_long<1>::type' declared here}}
+  void test_unsigned_long_long() { enable_if_unsigned_long_long<2>::type i; } // expected-error{{enable_if_unsigned_long_long<2ULL>'; did you mean 'enable_if_unsigned_long_long<1>::type'?}}
+
+  template  struct enable_if_long_long {};
+  template <> struct enable_if_long_long<1> { typedef int type; }; // expected-note{{'enable_if_long_long<1>::type' declared here}}
+  void test_long_long() { enable_if_long_long<2>::type i; } // expected-error{{enable_if_long_long<2LL>'; did you mean 'enable_if_long_long<1>::type'?}}
+
 }
 
 namespace PR10579 {
Index: clang/test/SemaTemplate/matrix-type.cpp
===
--- clang/test/SemaTemplate/matrix-type.cpp
+++ clang/test/SemaTemplate/matrix-type.cpp
@@ -17,7 +17,7 @@
 
 void instantiate_template_3() {
   matrix_template_3<1, 10>();
-  matrix_template_3<0, 10>(); // expected-note{{in instantiation of function template specialization 'matrix_template_3<0, 10>' requested here}}
+  matrix_template_3<0, 10>(); // expected-note{{in instantiation of function template specialization 'matrix_template_3<0U, 10U>' requested here}}
 }
 
 template 
@@ -27,7 +27,7 @@
 
 void instantiate_template_4() {
   matrix_template_4<2, 10>();
-  matrix_template_4<-3, 10>(); // expected-note{{in instantiation of function template specialization 'matrix_template_4<-3, 10>' requested here}}
+  matrix_template_4<-3, 10>(); // expected-note{{in instantiation of function template specialization 'matrix_template_4<-3, 10U>' requested here}}
 }
 
 template 
@@ -35,11 +35,11 @@
 
 template 
 void use_matrix(matrix &m) {}
-// expected-note@-1 {{candidate function [with T = float, R = 10]}}
+// expected-note@-1 {{candidate function [with T = float, R = 10UL]}}
 
 template 
 void use_matrix(matrix &m) {}
-// expected-note@-1 {{candidate function [with T = float, C = 10]}}
+// expected-note@-1 {{candidate function [with T = float, C = 10UL]}}
 
 void test_ambigous_deduction1() {
   matrix m;
@@ -64,17 +64,17 @@
 
 template 
 void use_matrix_2(matrix &m1, matrix &m2) {}
-// expected-note@-1 {{candidate function [with R = 3, C = 11] not viable: no known conversion from 'matrix' (aka 'int __att

Re: [PATCH] D77644: [clangd] Handle additional includes while parsing ASTs

2020-06-04 Thread Mikael Holmén via cfe-commits
On Thu, 2020-06-04 at 13:06 +0300, Kadir Çetinkaya wrote:
> Hi Mikael,
> 
> sent out 4f4a8ae72e95f2c7fa5e4ca56dd6b1a83a304680, please let me know
> if it helps!

Hi,

Yes, now it's silent. 

Thank you!
/Mikael

> 
> On Thu, Jun 4, 2020 at 12:40 PM Mikael Holmén via Phabricator <
> revi...@reviews.llvm.org> wrote:
> > uabelho added inline comments.
> > 
> > 
> > 
> > Comment at: clang-tools-extra/clangd/CodeComplete.cpp:1034
> >const PreambleData &Preamble;
> > -  const PreamblePatch &Patch;
> > +  llvm::Optional Patch;
> >llvm::StringRef Contents;
> > 
> > Hi!
> > 
> > When compiling with gcc 7.4 I see a warning that I think originates
> > from this line:
> > 
> > ```
> > [4032/4668] Building CXX object
> > tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/CodeC
> > omplete.cpp.o
> > In file included from
> > /data/repo/master/llvm/include/llvm/ADT/STLExtras.h:19:0,
> >  from
> > /data/repo/master/llvm/include/llvm/ADT/StringRef.h:12,
> >  from /data/repo/master/clang-tools-
> > extra/clangd/URI.h:12,
> >  from /data/repo/master/clang-tools-
> > extra/clangd/Protocol.h:26,
> >  from /data/repo/master/clang-tools-
> > extra/clangd/Headers.h:12,
> >  from /data/repo/master/clang-tools-
> > extra/clangd/CodeComplete.h:18,
> >  from /data/repo/master/clang-tools-
> > extra/clangd/CodeComplete.cpp:20:
> > /data/repo/master/llvm/include/llvm/ADT/Optional.h: In
> > instantiation of 'void llvm::optional_detail::OptionalStorage >  >::emplace(Args&& ...) [with Args = {const
> > clang::clangd::PreamblePatch}; T = const
> > clang::clangd::PreamblePatch; bool  = false]':
> > /data/repo/master/llvm/include/llvm/ADT/Optional.h:55:14: 
> >  required from 'llvm::optional_detail::OptionalStorage > 
> > >::OptionalStorage(llvm::optional_detail::OptionalStorage >  >&&) [with T = const clang::clangd::PreamblePatch; bool
> >  = false]'
> > /data/repo/master/llvm/include/llvm/ADT/Optional.h:228:3: 
> >  required from here
> > /data/repo/master/llvm/include/llvm/ADT/Optional.h:89:12: warning:
> > cast from type 'const clang::clangd::PreamblePatch*' to type
> > 'void*' casts away qualifiers [-Wcast-qual]
> >  ::new ((void *)std::addressof(value))
> > T(std::forward(args)...);
> > ^
> > ```
> > 
> > 
> > 
> > Repository:
> >   rG LLVM Github Monorepo
> > 
> > CHANGES SINCE LAST ACTION
> >   https://reviews.llvm.org/D77644/new/
> > 
> > https://reviews.llvm.org/D77644
> > 
> > 
> > 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81135: Add support for IntegerLiteral in SyntaxTree

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 268420.
eduucaldas added a comment.

answering comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81135

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -64,6 +64,11 @@
Language == Lang_CXX17 || Language == Lang_CXX20;
   }
 
+  bool isCXX14OrLater() const {
+return Language == Lang_CXX14 || Language == Lang_CXX17 ||
+   Language == Lang_CXX20;
+  }
+
   bool supportsCXXDynamicExceptionSpecification() const {
 return Language == Lang_CXX03 || Language == Lang_CXX11 ||
Language == Lang_CXX14;
@@ -314,7 +319,7 @@
   |-SimpleDeclarator
   | |-b
   | |-=
-  | `-UnknownExpression
+  | `-IntegerLiteralExpression
   |   `-42
   `-;
 )txt");
@@ -371,7 +376,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
@@ -380,7 +385,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | |-CompoundStatement
@@ -390,7 +395,7 @@
 | `-IfStatement
 |   |-if
 |   |-(
-|   |-UnknownExpression
+|   |-IntegerLiteralExpression
 |   | `-0
 |   |-)
 |   `-CompoundStatement
@@ -461,7 +466,7 @@
 | |   |-a
 | |   `-ArraySubscript
 | | |-[
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-3
 | | `-]
 | `-;
@@ -501,7 +506,7 @@
 | | `-SimpleDeclarator
 | |   |-a
 | |   |-=
-| |   `-UnknownExpression
+| |   `-IntegerLiteralExpression
 | | `-10
 | `-;
 `-}
@@ -532,14 +537,14 @@
 |-SwitchStatement
 | |-switch
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
 |   |-{
 |   |-CaseStatement
 |   | |-case
-|   | |-UnknownExpression
+|   | |-IntegerLiteralExpression
 |   | | `-0
 |   | |-:
 |   | `-DefaultStatement
@@ -573,7 +578,7 @@
 |-WhileStatement
 | |-while
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
@@ -610,7 +615,7 @@
 | |-:
 | `-ReturnStatement
 |   |-return
-|   |-UnknownExpression
+|   |-IntegerLiteralExpression
 |   | `-100
 |   `-;
 `-}
@@ -648,7 +653,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | |-ExpressionStatement
@@ -699,6 +704,149 @@
 )txt");
 }
 
+TEST_P(SyntaxTreeTest, IntegerLiteral) {
+  expectTreeDumpEqual(
+  R"cpp(
+void test() {
+  12;
+  12u;
+  12l;
+  12ul;
+  014;
+  0XC;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12u
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12l
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12ul
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-014
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-0XC
+| `-;
+`-}
+)txt");
+}
+
+TEST_P(SyntaxTreeTest, LongLongLiteral) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  expectTreeDumpEqual(
+  R"cpp(
+void test() {
+  12ll;
+  12ull;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12ll
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12ull
+| `-;
+`-}
+)txt");
+}
+
+TEST_P(SyntaxTreeTest, BinaryLiteral) {
+  if (!GetParam().isCXX14OrLater()) {
+return;
+  }
+  expectTreeDumpEqual(
+  R"cpp(
+void test() {
+  0b1100;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-0b1100
+| `-;
+`-}
+)txt");
+}
+
+TEST_P(SyntaxTreeTest, QuotedIntegerLiter

[PATCH] D81135: Add support for IntegerLiteral in SyntaxTree

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



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:718
+}
+)cpp",
+  R"txt(

Could you remove the whitespace in front of `)cpp"` for consistency with the 
rest of the file?



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:758
+
+TEST_P(SyntaxTreeTest, LongLongLiteral) {
+  if (!GetParam().isCXX11OrLater()) {

IntegerLiteralLongLong



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:792
+
+TEST_P(SyntaxTreeTest, BinaryLiteral) {
+  if (!GetParam().isCXX14OrLater()) {

IntegerLiteralBinary



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:821
+
+TEST_P(SyntaxTreeTest, QuotedIntegerLiteral) {
+  if (!GetParam().isCXX14OrLater()) {

IntegerLiteralWithDigitSeparators


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81135



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


[PATCH] D80941: [PowerPC][Power10] Implement Count Leading/Trailing Zeroes Builtins under bit Mask in LLVM/Clang

2020-06-04 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

Amy, I am really sorry. I initially did not read the description of the 
instructions in the ISA carefully. The semantics of these instructions are not 
actually `(op (and a, b))`. The mask is used to determine if a leading/trailing 
zero is counted or skipped.
Take for example the following two binary values:

  Mask:  100
  Value: 0010011

the result of `cntlzdm Value, Mask` should be `3` whereas the result of `(ctlz 
(and Value, Mask))` would be `5`. Namely, the instruction will count the first 
leading zero, ignore the next two bits and then count the next two zeros.

So you will need to revert back to the initial implementation. I am so sorry 
about going back and forth like this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80941



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


[PATCH] D81135: Add support for IntegerLiteral in SyntaxTree

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



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:642
   // TODO: add accessors for specifiers.
-  syntax::Leaf *arrow();
+  syntax::Leaf *arrowToken();
   syntax::SimpleDeclarator *declarator();

Could you move this change to a separate patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81135



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


[PATCH] D77062: [analyzer] Added check for unacceptable equality operation between Loc and NonLoc types

2020-06-04 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 268424.
ASDenysPetrov added a comment.

Removed `V.getAs()` from `if`.


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

https://reviews.llvm.org/D77062

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/string.c


Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -363,6 +363,14 @@
 strcpy(x, y); // no-warning
 }
 
+void *func_strcpy_no_assertion();
+char ***ptr_strcpy_no_assertion;
+void strcpy_no_assertion() {
+  *(unsigned char **)ptr_strcpy_no_assertion = (unsigned char 
*)(func_strcpy_no_assertion());
+  char c;
+  strcpy(**ptr_strcpy_no_assertion, &c); // no-assertion
+}
+
 //===--===
 // stpcpy()
 //===--===
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -282,13 +282,15 @@
 std::pair
 CStringChecker::assumeZero(CheckerContext &C, ProgramStateRef state, SVal V,
QualType Ty) {
+  auto states = std::make_pair(state, state);
+
   Optional val = V.getAs();
-  if (!val)
-return std::pair(state, state);
+  if (val) {
+// return pair shall be {null, non-null} so reorder states
+std::tie(states.second, states.first) = state->assume(*val);
+  }
 
-  SValBuilder &svalBuilder = C.getSValBuilder();
-  DefinedOrUnknownSVal zero = svalBuilder.makeZeroVal(Ty);
-  return state->assume(svalBuilder.evalEQ(state, *val, zero));
+  return states;
 }
 
 ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C,


Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -363,6 +363,14 @@
 strcpy(x, y); // no-warning
 }
 
+void *func_strcpy_no_assertion();
+char ***ptr_strcpy_no_assertion;
+void strcpy_no_assertion() {
+  *(unsigned char **)ptr_strcpy_no_assertion = (unsigned char *)(func_strcpy_no_assertion());
+  char c;
+  strcpy(**ptr_strcpy_no_assertion, &c); // no-assertion
+}
+
 //===--===
 // stpcpy()
 //===--===
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -282,13 +282,15 @@
 std::pair
 CStringChecker::assumeZero(CheckerContext &C, ProgramStateRef state, SVal V,
QualType Ty) {
+  auto states = std::make_pair(state, state);
+
   Optional val = V.getAs();
-  if (!val)
-return std::pair(state, state);
+  if (val) {
+// return pair shall be {null, non-null} so reorder states
+std::tie(states.second, states.first) = state->assume(*val);
+  }
 
-  SValBuilder &svalBuilder = C.getSValBuilder();
-  DefinedOrUnknownSVal zero = svalBuilder.makeZeroVal(Ty);
-  return state->assume(svalBuilder.evalEQ(state, *val, zero));
+  return states;
 }
 
 ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3b73969 - Add support for IntegerLiteral in SyntaxTree

2020-06-04 Thread Dmitri Gribenko via cfe-commits
Author: Eduardo Caldas
Date: 2020-06-04T14:05:31+02:00
New Revision: 3b739690b01e595f6da412316b58a0a291702049

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

LOG: Add support for IntegerLiteral in SyntaxTree

Reviewers: gribozavr2

Reviewed By: gribozavr2

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Tooling/Syntax/Nodes.h
clang/lib/Tooling/Syntax/BuildTree.cpp
clang/lib/Tooling/Syntax/Nodes.cpp
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/Nodes.h 
b/clang/include/clang/Tooling/Syntax/Nodes.h
index ce4dc35977f1..bf0308c95ba4 100644
--- a/clang/include/clang/Tooling/Syntax/Nodes.h
+++ b/clang/include/clang/Tooling/Syntax/Nodes.h
@@ -44,6 +44,7 @@ enum class NodeKind : uint16_t {
   PostfixUnaryOperatorExpression,
   BinaryOperatorExpression,
   CxxNullPtrExpression,
+  IntegerLiteralExpression,
 
   // Statements.
   UnknownStatement,
@@ -114,6 +115,7 @@ enum class NodeRole : uint8_t {
   BinaryOperatorExpression_operatorToken,
   BinaryOperatorExpression_rightHandSide,
   CxxNullPtrExpression_keyword,
+  IntegerLiteralExpression_literalToken,
   CaseStatement_value,
   IfStatement_thenStatement,
   IfStatement_elseKeyword,
@@ -178,6 +180,16 @@ class CxxNullPtrExpression final : public Expression {
   syntax::Leaf *nullPtrKeyword();
 };
 
+/// Expression for integer literals.
+class IntegerLiteralExpression final : public Expression {
+public:
+  IntegerLiteralExpression() : Expression(NodeKind::IntegerLiteralExpression) 
{}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::IntegerLiteralExpression;
+  }
+  syntax::Leaf *literalToken();
+};
+
 /// An abstract class for prefix and postfix unary operators.
 class UnaryOperatorExpression : public Expression {
 public:

diff  --git a/clang/lib/Tooling/Syntax/BuildTree.cpp 
b/clang/lib/Tooling/Syntax/BuildTree.cpp
index dcc7b3e19390..1f81cb4a12b0 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -608,6 +608,15 @@ class BuildTreeVisitor : public 
RecursiveASTVisitor {
 return true;
   }
 
+  bool WalkUpFromIntegerLiteral(IntegerLiteral *S) {
+Builder.markChildToken(
+S->getLocation(),
+syntax::NodeRole::IntegerLiteralExpression_literalToken);
+Builder.foldNode(Builder.getExprRange(S),
+ new (allocator()) syntax::IntegerLiteralExpression, S);
+return true;
+  }
+
   bool WalkUpFromCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *S) {
 Builder.markChildToken(S->getLocation(),
syntax::NodeRole::CxxNullPtrExpression_keyword);

diff  --git a/clang/lib/Tooling/Syntax/Nodes.cpp 
b/clang/lib/Tooling/Syntax/Nodes.cpp
index 3311b8df034c..d70b89b07200 100644
--- a/clang/lib/Tooling/Syntax/Nodes.cpp
+++ b/clang/lib/Tooling/Syntax/Nodes.cpp
@@ -20,6 +20,8 @@ llvm::raw_ostream &syntax::operator<<(llvm::raw_ostream &OS, 
NodeKind K) {
 return OS << "UnknownExpression";
   case NodeKind::CxxNullPtrExpression:
 return OS << "CxxNullPtrExpression";
+  case NodeKind::IntegerLiteralExpression:
+return OS << "IntegerLiteralExpression";
   case NodeKind::PrefixUnaryOperatorExpression:
 return OS << "PrefixUnaryOperatorExpression";
   case NodeKind::PostfixUnaryOperatorExpression:
@@ -118,6 +120,8 @@ llvm::raw_ostream &syntax::operator<<(llvm::raw_ostream 
&OS, NodeRole R) {
 return OS << "IfStatement_elseKeyword";
   case syntax::NodeRole::IfStatement_elseStatement:
 return OS << "IfStatement_elseStatement";
+  case syntax::NodeRole::IntegerLiteralExpression_literalToken:
+return OS << "IntegerLiteralExpression_literalToken";
   case syntax::NodeRole::CxxNullPtrExpression_keyword:
 return OS << "CxxNullPtrExpression_keyword";
   case syntax::NodeRole::UnaryOperatorExpression_operatorToken:
@@ -162,6 +166,11 @@ llvm::raw_ostream &syntax::operator<<(llvm::raw_ostream 
&OS, NodeRole R) {
   llvm_unreachable("invalid role");
 }
 
+syntax::Leaf *syntax::IntegerLiteralExpression::literalToken() {
+  return llvm::cast_or_null(
+  findChild(syntax::NodeRole::IntegerLiteralExpression_literalToken));
+}
+
 syntax::Leaf *syntax::CxxNullPtrExpression::nullPtrKeyword() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::CxxNullPtrExpression_keyword));

diff  --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp 
b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index c7a2b14b4f3f..49fdcb7a9c54 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -64,6 +64,11 @@ struct TestClangConfig {
Language == Lang_CXX17 || Language == Lang_CXX20;
   }

cfe-commits@lists.llvm.org

2020-06-04 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson added a comment.

Besides from rebasing to get @pratlucas changes upstream.

@stuij  please could you confirm if you are happy with this, so I can merge


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

https://reviews.llvm.org/D80716



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


[PATCH] D81135: Add support for IntegerLiteral in SyntaxTree

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 268428.
eduucaldas marked 4 inline comments as done.
eduucaldas added a comment.

Fix nits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81135

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -64,6 +64,11 @@
Language == Lang_CXX17 || Language == Lang_CXX20;
   }
 
+  bool isCXX14OrLater() const {
+return Language == Lang_CXX14 || Language == Lang_CXX17 ||
+   Language == Lang_CXX20;
+  }
+
   bool supportsCXXDynamicExceptionSpecification() const {
 return Language == Lang_CXX03 || Language == Lang_CXX11 ||
Language == Lang_CXX14;
@@ -314,7 +319,7 @@
   |-SimpleDeclarator
   | |-b
   | |-=
-  | `-UnknownExpression
+  | `-IntegerLiteralExpression
   |   `-42
   `-;
 )txt");
@@ -371,7 +376,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
@@ -380,7 +385,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | |-CompoundStatement
@@ -390,7 +395,7 @@
 | `-IfStatement
 |   |-if
 |   |-(
-|   |-UnknownExpression
+|   |-IntegerLiteralExpression
 |   | `-0
 |   |-)
 |   `-CompoundStatement
@@ -461,7 +466,7 @@
 | |   |-a
 | |   `-ArraySubscript
 | | |-[
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-3
 | | `-]
 | `-;
@@ -501,7 +506,7 @@
 | | `-SimpleDeclarator
 | |   |-a
 | |   |-=
-| |   `-UnknownExpression
+| |   `-IntegerLiteralExpression
 | | `-10
 | `-;
 `-}
@@ -532,14 +537,14 @@
 |-SwitchStatement
 | |-switch
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
 |   |-{
 |   |-CaseStatement
 |   | |-case
-|   | |-UnknownExpression
+|   | |-IntegerLiteralExpression
 |   | | `-0
 |   | |-:
 |   | `-DefaultStatement
@@ -573,7 +578,7 @@
 |-WhileStatement
 | |-while
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
@@ -610,7 +615,7 @@
 | |-:
 | `-ReturnStatement
 |   |-return
-|   |-UnknownExpression
+|   |-IntegerLiteralExpression
 |   | `-100
 |   `-;
 `-}
@@ -648,7 +653,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | |-ExpressionStatement
@@ -699,6 +704,149 @@
 )txt");
 }
 
+TEST_P(SyntaxTreeTest, IntegerLiteral) {
+  expectTreeDumpEqual(
+  R"cpp(
+void test() {
+  12;
+  12u;
+  12l;
+  12ul;
+  014;
+  0XC;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12u
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12l
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12ul
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-014
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-0XC
+| `-;
+`-}
+)txt");
+}
+
+TEST_P(SyntaxTreeTest, IntegerLiteralLongLong) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  expectTreeDumpEqual(
+  R"cpp(
+void test() {
+  12ll;
+  12ull;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12ll
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12ull
+| `-;
+`-}
+)txt");
+}
+
+TEST_P(SyntaxTreeTest, IntegerLiteralBinary) {
+  if (!GetParam().isCXX14OrLater()) {
+return;
+  }
+  expectTreeDumpEqual(
+  R"cpp(
+void test() {
+  0b1100;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-0b1100
+| `-;
+`-}
+)txt")

[PATCH] D80210: [analyzer] Turn off reports in system headers

2020-06-04 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Eg., suppress this report:

  // system_header.h
  int bar() {
int *x = NULL;
return *x;
  }
  // user_file.c
  void foo() {
bar();
  }

but don't suppress this report:

  // system_header.h
  int bar(int *x) {
return *x;
  }
  // user_file.c
  void foo() {
int *y = NULL;
bar(y);
  }

In the first example there are two interesting events: (1) `x = NULL`, (2) 
`return *x` but both of them are in the system header. In the second example 
the interesting event (1) `y = NULL` is not in the system header, so the report 
remains.

> That all other interesting stack frames are nested in it

I think this is the best take. A more aggressive suppression would be "all 
interesting things are in a system header", which would allow the suppressed 
bug report to temporarily leave the system header between interesting events.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80210



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


[PATCH] D81135: Add support for IntegerLiteral in SyntaxTree

2020-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3b739690b01e: Add support for IntegerLiteral in SyntaxTree 
(authored by eduucaldas, committed by gribozavr).

Changed prior to commit:
  https://reviews.llvm.org/D81135?vs=268428&id=268435#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81135

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -64,6 +64,11 @@
Language == Lang_CXX17 || Language == Lang_CXX20;
   }
 
+  bool isCXX14OrLater() const {
+return Language == Lang_CXX14 || Language == Lang_CXX17 ||
+   Language == Lang_CXX20;
+  }
+
   bool supportsCXXDynamicExceptionSpecification() const {
 return Language == Lang_CXX03 || Language == Lang_CXX11 ||
Language == Lang_CXX14;
@@ -321,7 +326,7 @@
   |-SimpleDeclarator
   | |-b
   | |-=
-  | `-UnknownExpression
+  | `-IntegerLiteralExpression
   |   `-42
   `-;
 )txt"));
@@ -378,7 +383,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
@@ -387,7 +392,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | |-CompoundStatement
@@ -397,7 +402,7 @@
 | `-IfStatement
 |   |-if
 |   |-(
-|   |-UnknownExpression
+|   |-IntegerLiteralExpression
 |   | `-0
 |   |-)
 |   `-CompoundStatement
@@ -468,7 +473,7 @@
 | |   |-a
 | |   `-ArraySubscript
 | | |-[
-| | |-UnknownExpression
+| | |-IntegerLiteralExpression
 | | | `-3
 | | `-]
 | `-;
@@ -513,7 +518,7 @@
 | | `-SimpleDeclarator
 | |   |-a
 | |   |-=
-| |   `-UnknownExpression
+| |   `-IntegerLiteralExpression
 | | `-10
 | `-;
 `-}
@@ -544,14 +549,14 @@
 |-SwitchStatement
 | |-switch
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
 |   |-{
 |   |-CaseStatement
 |   | |-case
-|   | |-UnknownExpression
+|   | |-IntegerLiteralExpression
 |   | | `-0
 |   | |-:
 |   | `-DefaultStatement
@@ -585,7 +590,7 @@
 |-WhileStatement
 | |-while
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | `-CompoundStatement
@@ -627,7 +632,7 @@
 | |-:
 | `-ReturnStatement
 |   |-return
-|   |-UnknownExpression
+|   |-IntegerLiteralExpression
 |   | `-100
 |   `-;
 `-}
@@ -665,7 +670,7 @@
 |-IfStatement
 | |-if
 | |-(
-| |-UnknownExpression
+| |-IntegerLiteralExpression
 | | `-1
 | |-)
 | |-ExpressionStatement
@@ -716,6 +721,149 @@
 )txt"));
 }
 
+TEST_P(SyntaxTreeTest, IntegerLiteral) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+  12;
+  12u;
+  12l;
+  12ul;
+  014;
+  0XC;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12u
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12l
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12ul
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-014
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-0XC
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, IntegerLiteralLongLong) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+  12ll;
+  12ull;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12ll
+| `-;
+|-ExpressionStatement
+| |-IntegerLiteralExpression
+| | `-12ull
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, IntegerLiteralBinary) {
+  if (!GetParam().isCXX14OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test() {
+  0b1100;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifi

[PATCH] D80947: Add to the Coding Standard our that single-line bodies omit braces

2020-06-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 268433.
erichkeane marked an inline comment as done.

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

https://reviews.llvm.org/D80947

Files:
  llvm/docs/CodingStandards.rst

Index: llvm/docs/CodingStandards.rst
===
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -669,15 +669,15 @@
 .. code-block:: c++
 
   // Typically there's no reason to copy.
-  for (const auto &Val : Container) { observe(Val); }
-  for (auto &Val : Container) { Val.change(); }
+  for (const auto &Val : Container) observe(Val);
+  for (auto &Val : Container) Val.change();
 
   // Remove the reference if you really want a new copy.
   for (auto Val : Container) { Val.change(); saveSomewhere(Val); }
 
   // Copy pointers, but make it clear that they're pointers.
-  for (const auto *Ptr : Container) { observe(*Ptr); }
-  for (auto *Ptr : Container) { Ptr->change(); }
+  for (const auto *Ptr : Container) observe(*Ptr);
+  for (auto *Ptr : Container) Ptr->change();
 
 Beware of non-determinism due to ordering of pointers
 ^
@@ -884,7 +884,7 @@
 .. code-block:: c++
 
   Value *doSomething(Instruction *I) {
-// Terminators never need 'something' done to them because ... 
+// Terminators never need 'something' done to them because ...
 if (I->isTerminator())
   return 0;
 
@@ -896,7 +896,7 @@
 // This is really just here for example.
 if (!doOtherThing(I))
   return 0;
-
+
 ... some long code 
   }
 
@@ -1000,7 +1000,7 @@
   Type = Context.getsigjmp_bufType();
 else
   Type = Context.getjmp_bufType();
-
+
 if (Type.isNull()) {
   Error = Signed ? ASTContext::GE_Missing_sigjmp_buf :
ASTContext::GE_Missing_jmp_buf;
@@ -1010,7 +1010,7 @@
 
 The idea is to reduce indentation and the amount of code you have to keep track
 of when reading the code.
-  
+
 Turn Predicate Loops into Predicate Functions
 ^
 
@@ -1081,7 +1081,7 @@
 * **Variable names** should be nouns (as they represent state).  The name should
   be camel case, and start with an upper case letter (e.g. ``Leader`` or
   ``Boats``).
-  
+
 * **Function names** should be verb phrases (as they represent actions), and
   command-like function should be imperative.  The name should be camel case,
   and start with a lower case letter (e.g. ``openFile()`` or ``isFoo()``).
@@ -1091,7 +1091,7 @@
   discriminator for a union, or an indicator of a subclass.  When an enum is
   used for something like this, it should have a ``Kind`` suffix
   (e.g. ``ValueKind``).
-  
+
 * **Enumerators** (e.g. ``enum { Foo, Bar }``) and **public member variables**
   should start with an upper-case letter, just like types.  Unless the
   enumerators are defined in their own small namespace or inside a class,
@@ -1107,7 +1107,7 @@
 MaxSize = 42,
 Density = 12
   };
-  
+
 As an exception, classes that mimic STL classes can have member names in STL's
 style of lower-case words separated by underscores (e.g. ``begin()``,
 ``push_back()``, and ``empty()``). Classes that provide multiple
@@ -1360,7 +1360,7 @@
 The use of ``#include `` in library files is hereby **forbidden**,
 because many common implementations transparently inject a `static constructor`_
 into every translation unit that includes it.
-  
+
 Note that using the other stream headers ( for example) is not
 problematic in this regard --- just . However, ``raw_ostream``
 provides various APIs that are better performing for almost every use than
@@ -1492,7 +1492,7 @@
   public:
 explicit Grokable() { ... }
 virtual ~Grokable() = 0;
-  
+
 ...
 
   };
@@ -1541,8 +1541,8 @@
   };
   } // end anonymous namespace
 
-  static void runHelper() { 
-... 
+  static void runHelper() {
+...
   }
 
   bool StringSort::operator<(const char *RHS) const {
@@ -1570,6 +1570,53 @@
 contrast, when the function is marked static, you don't need to cross-reference
 faraway places in the file to tell that the function is local.
 
+Don't Use Braces on Simple Single-Statement Bodies of if/else/loop Statements
+^
+
+When writing the body of an ``if``, ``else``, or loop statement, omit the braces to
+avoid unnecessary line noise. However, braces should be used in cases where the
+omission of braces harm the readability and maintainability of the code.
+
+Readability is harmed when a single statement is accompanied by a comment that loses
+its meaning if hoisted above the ``if`` or loop statement. Similarly, braces should
+be used when single-statement body is complex enough that it becomes difficult to see
+where the block containing the following statement began. An ``if``/``else`` chain or
+a loop is considered a single st

[PATCH] D81150: Use libClangTesting in the unittest for AST matchers

2020-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
Herald added subscribers: cfe-commits, sstefan1, mgorny.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

The unittest for AST matchers has its own way to specify language
standards. I unified it with the shared infrastructure from
libClangTesting.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81150

Files:
  clang/include/clang/Testing/CommandLineArgs.h
  clang/lib/Testing/CommandLineArgs.cpp
  clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTest.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
  clang/unittests/ASTMatchers/CMakeLists.txt
  clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
  clang/unittests/Sema/CMakeLists.txt

Index: clang/unittests/Sema/CMakeLists.txt
===
--- clang/unittests/Sema/CMakeLists.txt
+++ clang/unittests/Sema/CMakeLists.txt
@@ -18,6 +18,7 @@
   clangParse
   clangSema
   clangSerialization
+  clangTesting
   clangTooling
   )
 
Index: clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
===
--- clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
+++ clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
@@ -17,5 +17,6 @@
   clangDynamicASTMatchers
   clangFrontend
   clangSerialization
+  clangTesting
   clangTooling
   )
Index: clang/unittests/ASTMatchers/CMakeLists.txt
===
--- clang/unittests/ASTMatchers/CMakeLists.txt
+++ clang/unittests/ASTMatchers/CMakeLists.txt
@@ -27,6 +27,7 @@
   clangBasic
   clangFrontend
   clangSerialization
+  clangTesting
   clangTooling
   )
 
Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -951,13 +951,13 @@
   "template\n"
   "int Struct::field = 123;\n";
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("T")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("T")), langCxx14OrLater()));
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("T2")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("T2")), langCxx14OrLater()));
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("U")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("U")), langCxx14OrLater()));
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("U2")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("U2")), langCxx14OrLater()));
 }
 
 TEST(TemplateTypeParmDecl, ClassTemplatePartialSpecializationDecl) {
@@ -1487,18 +1487,18 @@
 TEST(Member, MatchesMemberAllocationFunction) {
   // Fails in C++11 mode
   EXPECT_TRUE(matchesConditionally(
-"namespace std { typedef typeof(sizeof(int)) size_t; }"
+  "namespace std { typedef typeof(sizeof(int)) size_t; }"
   "class X { void *operator new(std::size_t); };",
-cxxMethodDecl(ofClass(hasName("X"))), true, "-std=gnu++98"));
+  cxxMethodDecl(ofClass(hasName("X"))), true, {"-std=gnu++03"}));
 
   EXPECT_TRUE(matches("class X { void operator delete(void*); };",
   cxxMethodDecl(ofClass(hasName("X");
 
   // Fails in C++11 mode
   EXPECT_TRUE(matchesConditionally(
-"namespace std { typedef typeof(sizeof(int)) size_t; }"
+  "namespace std { typedef typeof(sizeof(int)) size_t; }"
   "class X { void operator delete[](void*, std::size_t); };",
-cxxMethodDecl(ofClass(hasName("X"))), true, "-std=gnu++98"));
+  cxxMethodDecl(ofClass(hasName("X"))), true, {"-std=gnu++03"}));
 }
 
 TEST(HasDestinationType, MatchesSimpleCase) {
@@ -1542,7 +1542,7 @@
   cxxOperatorCallExpr(hasArgument(
   1, callExpr(hasArgument(
  0, ignoringElidableConstructorCall(callExpr()),
-  LanguageMode::Cxx11OrLater));
+  langCxx11OrLater()));
   EXPECT_TRUE(
   matches("struct H {};"
   "template H B(T A);"
@@ -1553,7 +1553,7 @@
   cxxOperatorCallExpr(hasArgument(
   1, callExpr(hasArgument(0, ignoringElidableConstructorCall(
  integerLiteral()),
-  LanguageMode::Cxx11OrLater));
+  langCxx11OrLater()));
   EXPECT_TRUE(matches(
   "struct H {};"
   "H G();"
@@ -1563,7 +1563,7 @@
   varDecl(hasInitializer(anyOf(
   ignoringElidableConstructorCall(callExpr()),
   exprWithCleanups(has(ignoringElidableConstructorCall(callExpr())),
-  LanguageMode::Cxx11OrLater));
+  langCxx11OrLater()));

[clang] bd42582 - [analyzer] Ignore calculated indices of <= 0 in VLASizeChecker

2020-06-04 Thread via cfe-commits
Author: Vince Bridgers
Date: 2020-06-04T07:25:35-05:00
New Revision: bd425825411af1b340134b0e8c9c03733ee87d66

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

LOG: [analyzer] Ignore calculated indices of <= 0 in VLASizeChecker

Summary:
See https://bugs.llvm.org/show_bug.cgi?id=46128. The checker does not
yet comprehend constraints involving multiple symbols, so it's possible
to calculate a VLA size that's negative or 0. A LIT is added to catch
regressions, and this change simply bails if a VLA size of 0 or less is
calculated.

Reviewers: balazske, NoQ, martong, baloghadamsoftware, Szelethus, gamesh411

Reviewed By: balazske, NoQ, Szelethus

Subscribers: xazax.hun, szepet, rnkovacs, a.sidorin, mikhail.ramalho, 
donat.nagy, Charusso, ASDenysPetrov, cfe-commits, dkrupp

Tags: #clang

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
clang/test/Analysis/vla.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
index de487042fb8a..d76b2a06aba5 100644
--- a/clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
@@ -126,7 +126,12 @@ ProgramStateRef VLASizeChecker::checkVLA(CheckerContext &C,
   // Size overflow check does not work with symbolic expressions because a
   // overflow situation can not be detected easily.
   uint64_t IndexL = IndexLVal->getZExtValue();
-  assert(IndexL > 0 && "Index length should have been checked for zero.");
+  // FIXME: See https://reviews.llvm.org/D80903 for discussion of
+  // some 
diff erence in assume and getKnownValue that leads to
+  // unexpected behavior. Just bail on IndexL == 0 at this point.
+  if (IndexL == 0)
+return nullptr;
+
   if (KnownSize <= SizeMax / IndexL) {
 KnownSize *= IndexL;
   } else {

diff  --git a/clang/test/Analysis/vla.c b/clang/test/Analysis/vla.c
index a269ef334c32..457c14172310 100644
--- a/clang/test/Analysis/vla.c
+++ b/clang/test/Analysis/vla.c
@@ -137,3 +137,17 @@ void check_VLA_extent() {
   clang_analyzer_eval(clang_analyzer_getExtent(&vla3m) == 2 * x * 4 * 
sizeof(int));
   // expected-warning@-1{{TRUE}}
 }
+
+// https://bugs.llvm.org/show_bug.cgi?id=46128
+// analyzer doesn't handle more than simple symbolic expressions.
+// Just don't crash.
+extern void foo(void);
+int a;
+void b() {
+  int c = a + 1;
+  for (;;) {
+int d[c];
+for (; 0 < c;)
+  foo();
+  }
+} // no-crash



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


[clang] 4a4402f - [OpenCL] Add cl_khr_extended_subgroup extensions.

2020-06-04 Thread Anastasia Stulova via cfe-commits
Author: Anastasia Stulova
Date: 2020-06-04T13:29:30+01:00
New Revision: 4a4402f0d72167477a6252e4c3daf5089ebc8f9a

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

LOG: [OpenCL] Add cl_khr_extended_subgroup extensions.

Added extensions and their function declarations into
the standard header.

Patch by Piotr Fusik!

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/OpenCLExtensions.def
clang/lib/Headers/opencl-c.h
clang/test/SemaOpenCL/extension-version.cl

Removed: 




diff  --git a/clang/include/clang/Basic/OpenCLExtensions.def 
b/clang/include/clang/Basic/OpenCLExtensions.def
index 517481584313..1ae36b32fb0a 100644
--- a/clang/include/clang/Basic/OpenCLExtensions.def
+++ b/clang/include/clang/Basic/OpenCLExtensions.def
@@ -74,6 +74,13 @@ OPENCLEXT_INTERNAL(cl_khr_mipmap_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_subgroup_extended_types, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_subgroup_non_uniform_vote, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_subgroup_ballot, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_subgroup_non_uniform_arithmetic, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_subgroup_shuffle, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_subgroup_shuffle_relative, 200, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_subgroup_clustered_reduce, 200, ~0U)
 
 // Clang Extensions.
 OPENCLEXT_INTERNAL(cl_clang_storage_class_specifiers, 100, ~0U)

diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 6ac9f92d23a2..66e18bdd47bb 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -15460,6 +15460,674 @@ double  __ovld __conv 
sub_group_scan_inclusive_max(double x);
 
 #endif //cl_khr_subgroups cl_intel_subgroups
 
+#if defined(cl_khr_subgroup_extended_types)
+char __ovld __conv sub_group_broadcast( char value, uint index );
+char2 __ovld __conv sub_group_broadcast( char2 value, uint index );
+char3 __ovld __conv sub_group_broadcast( char3 value, uint index );
+char4 __ovld __conv sub_group_broadcast( char4 value, uint index );
+char8 __ovld __conv sub_group_broadcast( char8 value, uint index );
+char16 __ovld __conv sub_group_broadcast( char16 value, uint index );
+
+uchar __ovld __conv sub_group_broadcast( uchar value, uint index );
+uchar2 __ovld __conv sub_group_broadcast( uchar2 value, uint index );
+uchar3 __ovld __conv sub_group_broadcast( uchar3 value, uint index );
+uchar4 __ovld __conv sub_group_broadcast( uchar4 value, uint index );
+uchar8 __ovld __conv sub_group_broadcast( uchar8 value, uint index );
+uchar16 __ovld __conv sub_group_broadcast( uchar16 value, uint index );
+
+short __ovld __conv sub_group_broadcast( short value, uint index );
+short2 __ovld __conv sub_group_broadcast( short2 value, uint index );
+short3 __ovld __conv sub_group_broadcast( short3 value, uint index );
+short4 __ovld __conv sub_group_broadcast( short4 value, uint index );
+short8 __ovld __conv sub_group_broadcast( short8 value, uint index );
+short16 __ovld __conv sub_group_broadcast( short16 value, uint index );
+
+ushort __ovld __conv sub_group_broadcast( ushort value, uint index );
+ushort2 __ovld __conv sub_group_broadcast( ushort2 value, uint index );
+ushort3 __ovld __conv sub_group_broadcast( ushort3 value, uint index );
+ushort4 __ovld __conv sub_group_broadcast( ushort4 value, uint index );
+ushort8 __ovld __conv sub_group_broadcast( ushort8 value, uint index );
+ushort16 __ovld __conv sub_group_broadcast( ushort16 value, uint index );
+
+// scalar int broadcast is part of cl_khr_subgroups
+int2 __ovld __conv sub_group_broadcast( int2 value, uint index );
+int3 __ovld __conv sub_group_broadcast( int3 value, uint index );
+int4 __ovld __conv sub_group_broadcast( int4 value, uint index );
+int8 __ovld __conv sub_group_broadcast( int8 value, uint index );
+int16 __ovld __conv sub_group_broadcast( int16 value, uint index );
+
+// scalar uint broadcast is part of cl_khr_subgroups
+uint2 __ovld __conv sub_group_broadcast( uint2 value, uint index );
+uint3 __ovld __conv sub_group_broadcast( uint3 value, uint index );
+uint4 __ovld __conv sub_group_broadcast( uint4 value, uint index );
+uint8 __ovld __conv sub_group_broadcast( uint8 value, uint index );
+uint16 __ovld __conv sub_group_broadcast( uint16 value, uint index );
+
+// scalar long broadcast is part of cl_khr_subgroups
+long2 __ovld __conv sub_group_broadcast( long2 value, uint index );
+long3 __ovld __conv sub_group_broadcast( long3 value, uint index );
+long4 __ovld __conv sub_group_broadcast( long4 value, uint index );
+long8 __ovld __conv sub_group_broadcast( long8 value, uint ind

[PATCH] D80903: [analyzer] Ignore calculated indices of <= 0 in VLASizeChecker

2020-06-04 Thread Vince Bridgers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbd425825411a: [analyzer] Ignore calculated indices of <= 
0 in VLASizeChecker (authored by vabridgers, committed by einvbri 
).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80903

Files:
  clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  clang/test/Analysis/vla.c


Index: clang/test/Analysis/vla.c
===
--- clang/test/Analysis/vla.c
+++ clang/test/Analysis/vla.c
@@ -137,3 +137,17 @@
   clang_analyzer_eval(clang_analyzer_getExtent(&vla3m) == 2 * x * 4 * 
sizeof(int));
   // expected-warning@-1{{TRUE}}
 }
+
+// https://bugs.llvm.org/show_bug.cgi?id=46128
+// analyzer doesn't handle more than simple symbolic expressions.
+// Just don't crash.
+extern void foo(void);
+int a;
+void b() {
+  int c = a + 1;
+  for (;;) {
+int d[c];
+for (; 0 < c;)
+  foo();
+  }
+} // no-crash
Index: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
@@ -126,7 +126,12 @@
   // Size overflow check does not work with symbolic expressions because a
   // overflow situation can not be detected easily.
   uint64_t IndexL = IndexLVal->getZExtValue();
-  assert(IndexL > 0 && "Index length should have been checked for zero.");
+  // FIXME: See https://reviews.llvm.org/D80903 for discussion of
+  // some difference in assume and getKnownValue that leads to
+  // unexpected behavior. Just bail on IndexL == 0 at this point.
+  if (IndexL == 0)
+return nullptr;
+
   if (KnownSize <= SizeMax / IndexL) {
 KnownSize *= IndexL;
   } else {


Index: clang/test/Analysis/vla.c
===
--- clang/test/Analysis/vla.c
+++ clang/test/Analysis/vla.c
@@ -137,3 +137,17 @@
   clang_analyzer_eval(clang_analyzer_getExtent(&vla3m) == 2 * x * 4 * sizeof(int));
   // expected-warning@-1{{TRUE}}
 }
+
+// https://bugs.llvm.org/show_bug.cgi?id=46128
+// analyzer doesn't handle more than simple symbolic expressions.
+// Just don't crash.
+extern void foo(void);
+int a;
+void b() {
+  int c = a + 1;
+  for (;;) {
+int d[c];
+for (; 0 < c;)
+  foo();
+  }
+} // no-crash
Index: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
@@ -126,7 +126,12 @@
   // Size overflow check does not work with symbolic expressions because a
   // overflow situation can not be detected easily.
   uint64_t IndexL = IndexLVal->getZExtValue();
-  assert(IndexL > 0 && "Index length should have been checked for zero.");
+  // FIXME: See https://reviews.llvm.org/D80903 for discussion of
+  // some difference in assume and getKnownValue that leads to
+  // unexpected behavior. Just bail on IndexL == 0 at this point.
+  if (IndexL == 0)
+return nullptr;
+
   if (KnownSize <= SizeMax / IndexL) {
 KnownSize *= IndexL;
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79781: [OpenCL] Add cl_khr_extended_subgroup extensions

2020-06-04 Thread Anastasia Stulova via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4a4402f0d721: [OpenCL] Add cl_khr_extended_subgroup 
extensions. (authored by Anastasia).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79781

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/lib/Headers/opencl-c.h
  clang/test/SemaOpenCL/extension-version.cl

Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -333,3 +333,87 @@
 #endif
 #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : enable
 
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_subgroup_extended_types
+#error "Missing cl_khr_subgroup_extended_types"
+#endif
+#else
+#ifdef cl_khr_subgroup_extended_types
+#error "Incorrect cl_khr_subgroup_extended_types define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_extended_types' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_subgroup_extended_types : enable
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_subgroup_non_uniform_vote
+#error "Missing cl_khr_subgroup_non_uniform_vote"
+#endif
+#else
+#ifdef cl_khr_subgroup_non_uniform_vote
+#error "Incorrect cl_khr_subgroup_non_uniform_vote define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_non_uniform_vote' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_subgroup_non_uniform_vote : enable
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_subgroup_ballot
+#error "Missing cl_khr_subgroup_ballot"
+#endif
+#else
+#ifdef cl_khr_subgroup_ballot
+#error "Incorrect cl_khr_subgroup_ballot define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_ballot' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_subgroup_ballot : enable
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_subgroup_non_uniform_arithmetic
+#error "Missing cl_khr_subgroup_non_uniform_arithmetic"
+#endif
+#else
+#ifdef cl_khr_subgroup_non_uniform_arithmetic
+#error "Incorrect cl_khr_subgroup_non_uniform_arithmetic define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_non_uniform_arithmetic' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_subgroup_non_uniform_arithmetic : enable
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_subgroup_shuffle
+#error "Missing cl_khr_subgroup_shuffle"
+#endif
+#else
+#ifdef cl_khr_subgroup_shuffle
+#error "Incorrect cl_khr_subgroup_shuffle define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_shuffle' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_subgroup_shuffle : enable
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_subgroup_shuffle_relative
+#error "Missing cl_khr_subgroup_shuffle_relative"
+#endif
+#else
+#ifdef cl_khr_subgroup_shuffle_relative
+#error "Incorrect cl_khr_subgroup_shuffle_relative define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_shuffle_relative' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_subgroup_shuffle_relative : enable
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_subgroup_clustered_reduce
+#error "Missing cl_khr_subgroup_clustered_reduce"
+#endif
+#else
+#ifdef cl_khr_subgroup_clustered_reduce
+#error "Incorrect cl_khr_subgroup_clustered_reduce define"
+#endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroup_clustered_reduce' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_khr_subgroup_clustered_reduce : enable
+
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -15460,6 +15460,674 @@
 
 #endif //cl_khr_subgroups cl_intel_subgroups
 
+#if defined(cl_khr_subgroup_extended_types)
+char __ovld __conv sub_group_broadcast( char value, uint index );
+char2 __ovld __conv sub_group_broadcast( char2 value, uint index );
+char3 __ovld __conv sub_group_broadcast( char3 value, uint index );
+char4 __ovld __conv sub_group_broadcast( char4 value, uint index );
+char8 __ovld __conv sub_group_broadcast( char8 value, uint index );
+char16 __ovld __conv sub_group_broadcast( char16 value, uint index );
+
+uchar __ovld __conv sub_group_broadcast( uchar value, uint index );
+uchar2 __ovld __conv sub_group_broadcast( uchar2 value, uint index );
+uchar3 __ovld __conv sub_group_broadcast( uchar3 value, uint index );
+uchar4 __ovld __conv sub_group_broadcast( uchar4 value, uint index );
+uchar8 __ovld __conv su

[PATCH] D81154: [AST][RecoveryExpr] Populate the dependence bits from CompoundStmt result expr to StmtExpr.

2020-06-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: clang.

We lost errorBit for StmtExpr if a recoveryExpr is the result
expr of a CompoundStmt, which will lead to crashes.

  // `-StmtExpr
  //   `-CompoundStmt
  // `-RecoveryExp
  ({ invalid(); });


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81154

Files:
  clang/lib/AST/ComputeDependence.cpp
  clang/test/SemaCXX/invalid-constructor-init.cpp


Index: clang/test/SemaCXX/invalid-constructor-init.cpp
===
--- clang/test/SemaCXX/invalid-constructor-init.cpp
+++ clang/test/SemaCXX/invalid-constructor-init.cpp
@@ -14,6 +14,12 @@
   constexpr X2() {} // expected-error {{constexpr constructor never produces a 
constant expression}}
 };
 
+struct X3 {
+  int Y;
+  constexpr X3() // expected-error {{constexpr constructor never produces}}
+  : Y(({foo();})) {} // expected-error {{use of undeclared identifier 
'foo'}}
+};
+
 struct CycleDelegate {
   int Y;
   CycleDelegate(int)
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -136,6 +136,13 @@
   // lambda-expressions and GCC.
   if (TemplateDepth)
 D |= ExprDependence::ValueInstantiation;
+
+  // Populate dependence bits from the expr that consider to be the result
+  // of the compound statements.
+  if (const auto *CompoundExprResult =
+  dyn_cast_or_null(E->getSubStmt()->getStmtExprResult()))
+if (const Expr *ResultExpr = CompoundExprResult->getExprStmt())
+  D |= ResultExpr->getDependence();
   return D;
 }
 


Index: clang/test/SemaCXX/invalid-constructor-init.cpp
===
--- clang/test/SemaCXX/invalid-constructor-init.cpp
+++ clang/test/SemaCXX/invalid-constructor-init.cpp
@@ -14,6 +14,12 @@
   constexpr X2() {} // expected-error {{constexpr constructor never produces a constant expression}}
 };
 
+struct X3 {
+  int Y;
+  constexpr X3() // expected-error {{constexpr constructor never produces}}
+  : Y(({foo();})) {} // expected-error {{use of undeclared identifier 'foo'}}
+};
+
 struct CycleDelegate {
   int Y;
   CycleDelegate(int)
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -136,6 +136,13 @@
   // lambda-expressions and GCC.
   if (TemplateDepth)
 D |= ExprDependence::ValueInstantiation;
+
+  // Populate dependence bits from the expr that consider to be the result
+  // of the compound statements.
+  if (const auto *CompoundExprResult =
+  dyn_cast_or_null(E->getSubStmt()->getStmtExprResult()))
+if (const Expr *ResultExpr = CompoundExprResult->getExprStmt())
+  D |= ResultExpr->getDependence();
   return D;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80979: [clang] Implement VectorType logic not operator.

2020-06-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:2746
+  if (E->getType()->isVectorType() &&
+  E->getType()->castAs()->getVectorKind() ==
+  VectorType::GenericVector) {

erichkeane wrote:
> junparser wrote:
> > erichkeane wrote:
> > > Why limit this to just the base vector type?  Doesn't this remove the 
> > > ext-vector implementation?
> > > 
> > > 
> > the kind of ext-vector is  GenericVector as well. so it also includes 
> > ext-vector.
> "isVectorType" also includes ExtVectorType.  My question is which vector 
> types are you attempting to exclude here?
> 
> Can the ExtVectorKind ever be a AltiVec* or Neon Vector type?  If so, this 
> change would break code for those.
Just dug in and answered my own question, ExtVector is always created as 
Generic, see ASTContext::getExtVectorType.  So I think the check for 
GenericVector (here and in Sema) properly constrains this patch to only adding 
C++-mode standard vector-types.



Comment at: clang/test/CodeGen/vector-1.cpp:2
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+typedef __attribute__((__vector_size__(16))) float float4;

I don't think copying the whole test from the other file is the right idea. We 
already validate the rest of the operations on normal vectors in a number of 
places.  If any of those are C++ tests, just add your tests there.  Otherwise 
this test should only validate the logical-not operator.


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

https://reviews.llvm.org/D80979



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


[PATCH] D81150: Use libClangTesting in the unittest for AST matchers

2020-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr updated this revision to Diff 268440.
gribozavr added a comment.

Changed C++20-only tests to C++20-or-later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81150

Files:
  clang/include/clang/Testing/CommandLineArgs.h
  clang/lib/Testing/CommandLineArgs.cpp
  clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTest.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
  clang/unittests/ASTMatchers/CMakeLists.txt
  clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
  clang/unittests/Sema/CMakeLists.txt

Index: clang/unittests/Sema/CMakeLists.txt
===
--- clang/unittests/Sema/CMakeLists.txt
+++ clang/unittests/Sema/CMakeLists.txt
@@ -18,6 +18,7 @@
   clangParse
   clangSema
   clangSerialization
+  clangTesting
   clangTooling
   )
 
Index: clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
===
--- clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
+++ clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
@@ -17,5 +17,6 @@
   clangDynamicASTMatchers
   clangFrontend
   clangSerialization
+  clangTesting
   clangTooling
   )
Index: clang/unittests/ASTMatchers/CMakeLists.txt
===
--- clang/unittests/ASTMatchers/CMakeLists.txt
+++ clang/unittests/ASTMatchers/CMakeLists.txt
@@ -27,6 +27,7 @@
   clangBasic
   clangFrontend
   clangSerialization
+  clangTesting
   clangTooling
   )
 
Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -951,13 +951,13 @@
   "template\n"
   "int Struct::field = 123;\n";
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("T")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("T")), langCxx14OrLater()));
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("T2")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("T2")), langCxx14OrLater()));
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("U")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("U")), langCxx14OrLater()));
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("U2")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("U2")), langCxx14OrLater()));
 }
 
 TEST(TemplateTypeParmDecl, ClassTemplatePartialSpecializationDecl) {
@@ -1487,18 +1487,18 @@
 TEST(Member, MatchesMemberAllocationFunction) {
   // Fails in C++11 mode
   EXPECT_TRUE(matchesConditionally(
-"namespace std { typedef typeof(sizeof(int)) size_t; }"
+  "namespace std { typedef typeof(sizeof(int)) size_t; }"
   "class X { void *operator new(std::size_t); };",
-cxxMethodDecl(ofClass(hasName("X"))), true, "-std=gnu++98"));
+  cxxMethodDecl(ofClass(hasName("X"))), true, {"-std=gnu++03"}));
 
   EXPECT_TRUE(matches("class X { void operator delete(void*); };",
   cxxMethodDecl(ofClass(hasName("X");
 
   // Fails in C++11 mode
   EXPECT_TRUE(matchesConditionally(
-"namespace std { typedef typeof(sizeof(int)) size_t; }"
+  "namespace std { typedef typeof(sizeof(int)) size_t; }"
   "class X { void operator delete[](void*, std::size_t); };",
-cxxMethodDecl(ofClass(hasName("X"))), true, "-std=gnu++98"));
+  cxxMethodDecl(ofClass(hasName("X"))), true, {"-std=gnu++03"}));
 }
 
 TEST(HasDestinationType, MatchesSimpleCase) {
@@ -1542,7 +1542,7 @@
   cxxOperatorCallExpr(hasArgument(
   1, callExpr(hasArgument(
  0, ignoringElidableConstructorCall(callExpr()),
-  LanguageMode::Cxx11OrLater));
+  langCxx11OrLater()));
   EXPECT_TRUE(
   matches("struct H {};"
   "template H B(T A);"
@@ -1553,7 +1553,7 @@
   cxxOperatorCallExpr(hasArgument(
   1, callExpr(hasArgument(0, ignoringElidableConstructorCall(
  integerLiteral()),
-  LanguageMode::Cxx11OrLater));
+  langCxx11OrLater()));
   EXPECT_TRUE(matches(
   "struct H {};"
   "H G();"
@@ -1563,7 +1563,7 @@
   varDecl(hasInitializer(anyOf(
   ignoringElidableConstructorCall(callExpr()),
   exprWithCleanups(has(ignoringElidableConstructorCall(callExpr())),
-  LanguageMode::Cxx11OrLater));
+  langCxx11OrLater()));
 }
 
 TEST(Matcher, IgnoresElidableInReturn) {
@@ -1573,12 +1573,12 @@
   "  H g;"

[PATCH] D80979: [clang] Implement VectorType logic not operator.

2020-06-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:2746
+  if (E->getType()->isVectorType() &&
+  E->getType()->castAs()->getVectorKind() ==
+  VectorType::GenericVector) {

junparser wrote:
> erichkeane wrote:
> > Why limit this to just the base vector type?  Doesn't this remove the 
> > ext-vector implementation?
> > 
> > 
> the kind of ext-vector is  GenericVector as well. so it also includes 
> ext-vector.
"isVectorType" also includes ExtVectorType.  My question is which vector types 
are you attempting to exclude here?

Can the ExtVectorKind ever be a AltiVec* or Neon Vector type?  If so, this 
change would break code for those.


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

https://reviews.llvm.org/D80979



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


[PATCH] D81155: Rename arrow -> arrowToken for unified naming

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas added a reviewer: gribozavr2.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81155

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/Nodes.cpp


Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -400,7 +400,7 @@
   findChild(syntax::NodeRole::CloseParen));
 }
 
-syntax::Leaf *syntax::TrailingReturnType::arrow() {
+syntax::Leaf *syntax::TrailingReturnType::arrowToken() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::TrailingReturnType_arrow));
 }
Index: clang/include/clang/Tooling/Syntax/Nodes.h
===
--- clang/include/clang/Tooling/Syntax/Nodes.h
+++ clang/include/clang/Tooling/Syntax/Nodes.h
@@ -639,7 +639,7 @@
 return N->kind() == NodeKind::TrailingReturnType;
   }
   // TODO: add accessors for specifiers.
-  syntax::Leaf *arrow();
+  syntax::Leaf *arrowToken();
   syntax::SimpleDeclarator *declarator();
 };
 


Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -400,7 +400,7 @@
   findChild(syntax::NodeRole::CloseParen));
 }
 
-syntax::Leaf *syntax::TrailingReturnType::arrow() {
+syntax::Leaf *syntax::TrailingReturnType::arrowToken() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::TrailingReturnType_arrow));
 }
Index: clang/include/clang/Tooling/Syntax/Nodes.h
===
--- clang/include/clang/Tooling/Syntax/Nodes.h
+++ clang/include/clang/Tooling/Syntax/Nodes.h
@@ -639,7 +639,7 @@
 return N->kind() == NodeKind::TrailingReturnType;
   }
   // TODO: add accessors for specifiers.
-  syntax::Leaf *arrow();
+  syntax::Leaf *arrowToken();
   syntax::SimpleDeclarator *declarator();
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-04 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

> The only absolute paths that remain are: a. the compiler path 
> (`D:\llvm-project\buildninjaDebMSVC\bin\clang-cl.exe` in the yaml below) and 
> b. the `-internal-isystem` paths. However that is not an issue on our end, as 
> we're building with `-nostdinc` + nuget packages installed in a fixed dir on 
> all users' machines. Not sure how that works for you?

a. The compiler path is only absolute because it was absolute when put into 
argv[0] right? I don't see anything in the code that makes it absolute? I 
imagine most build systems will invoke the compiler using an absolute path so 
you'll get the desired result.

b. We pass -imsvc flags to specify relative paths to the msvc headers, so the 
-internal-isystem paths passed to cc1 are relative too.




Comment at: clang/test/CodeGen/debug-info-codeview-buildinfo.c:1
+// RUN: %clang_cl /c /Z7 %s /Fo%t.obj
+// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s

The %s arg needs to come after "--", otherwise it can be interpreted as a 
command line flag, e.g. on Mac files are often under /Users which will be 
interpreted as a /U flag (see other tests using %clang_cl for examples).



Comment at: clang/tools/driver/cc1_main.cpp:184
 
-int cc1_main(ArrayRef Argv, const char *Argv0, void *MainAddr) {
   ensureSufficientStack();

Maybe I'm missing something, but why is this changing? The current code with 
Argv0 and the rest of the args as separate parameters seems like it would fit 
in will with the rest of the patch?



Comment at: lld/COFF/PDB.cpp:1041
+  // Remap the contents of the LF_BUILDINFO record.
+  remapBuildInfo(tMerger.getIDTable());
+

Naive question because I'm not familiar with the PDB writing, but would it be 
possible to remap the LF_BUILDINFO entries earlier, e.g. when they're read in 
from the object files? It seems like a lot of code is now added to do the 
remapping "after the fact".



Comment at: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:840
+  erase_if(Vec, [&](StringRef Arg) {
+return Arg.data() == nullptr || Arg == MainFilename;
+  });

Does Arg.data() == nullptr really happen here?



Comment at: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:846
+#else
+  std::string FlatCmdLine = llvm::join(Vec, " ");
+#endif

I suppose this won't work with filenames that contain spaces.

I was hoping we could do whatever "clang -v" does when it prints arguments. It 
seems to do some basic quoting and escaping. Does it have some function we 
could call from here?



Comment at: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:873
   getStringIdTypeIdx(TypeTable, MainSourceFile->getFilename());
-  // FIXME: Path to compiler and command line. PDB is intentionally blank 
unless
-  // we implement /Zi type servers.
+  if (!StringRef(Asm->TM.Options.MCOptions.Argv0).empty() &&
+  !Asm->TM.Options.MCOptions.CommandLineArgs.empty()) {

Wouldn't it be simpler to just check Argv0 != nullptr here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



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


[clang] 3c191ae - [OPENMP]Fix PR45383: type dependent array subscripts are diagnosed erroneously.

2020-06-04 Thread Alexey Bataev via cfe-commits
Author: Alexey Bataev
Date: 2020-06-04T09:34:59-04:00
New Revision: 3c191ae555cce6896f40b75ca031eadf675c5fb8

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

LOG: [OPENMP]Fix PR45383: type dependent array subscripts are diagnosed 
erroneously.

Summary:
If the array subscript expression is type depent, its analysis must be
delayed before its instantiation.

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, caomhin, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/task_ast_print.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 17b585862639..a35cb2dcf687 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -16128,7 +16128,7 @@ Sema::ActOnOpenMPDependClause(Expr *DepModifier, 
OpenMPDependClauseKind DepKind,
 
 auto *ASE = dyn_cast(SimpleExpr);
 if (!RefExpr->IgnoreParenImpCasts()->isLValue() ||
-(ASE &&
+(ASE && !ASE->getBase()->isTypeDependent() &&
  !ASE->getBase()
   ->getType()
   .getNonReferenceType()

diff  --git a/clang/test/OpenMP/task_ast_print.cpp 
b/clang/test/OpenMP/task_ast_print.cpp
index b58dd02b9891..41e61dadc1ce 100644
--- a/clang/test/OpenMP/task_ast_print.cpp
+++ b/clang/test/OpenMP/task_ast_print.cpp
@@ -99,7 +99,8 @@ T tmain(T argc, T *argv) {
   T arr[argc];
   omp_depend_t x;
   omp_event_handle_t evt;
-#pragma omp task untied depend(in : argc, argv[b:argc], arr[:], 
([argc][sizeof(T)])argv) if (task : argc > 0) depend(depobj: x) detach(evt)
+  double *arr_double;
+#pragma omp task untied depend(in : argc, argv[b:argc], arr[:], 
([argc][sizeof(T)])argv, arr_double[argc]) if (task : argc > 0) depend(depobj: 
x) detach(evt)
   a = 2;
 #pragma omp task default(none), private(argc, b) firstprivate(argv) shared(d) 
if (argc > 0) final(S::TS > 0) priority(argc) affinity(argc, argv[b:argc], 
arr[:], ([argc][sizeof(T)])argv)
   foo();
@@ -116,7 +117,8 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: T arr[argc];
 // CHECK-NEXT: omp_depend_t x;
 // CHECK-NEXT: omp_event_handle_t evt;
-// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(T)])argv) if(task: argc > 0) 
depend(depobj : x) detach(evt)
+// CHECK-NEXT: double *arr_double;
+// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(T)])argv,arr_double[argc]) if(task: 
argc > 0) depend(depobj : x) detach(evt)
 // CHECK-NEXT: a = 2;
 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) 
firstprivate(argv) shared(d) if(argc > 0) final(S::TS > 0) priority(argc) 
affinity(argc,argv[b:argc],arr[:],([argc][sizeof(T)])argv)
 // CHECK-NEXT: foo()
@@ -130,7 +132,8 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: int arr[argc];
 // CHECK-NEXT: omp_depend_t x;
 // CHECK-NEXT: omp_event_handle_t evt;
-// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(int)])argv) if(task: argc > 0) 
depend(depobj : x) detach(evt)
+// CHECK-NEXT: double *arr_double;
+// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(int)])argv,arr_double[argc]) if(task: 
argc > 0) depend(depobj : x) detach(evt)
 // CHECK-NEXT: a = 2;
 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) 
firstprivate(argv) shared(d) if(argc > 0) final(S::TS > 0) priority(argc) 
affinity(argc,argv[b:argc],arr[:],([argc][sizeof(int)])argv)
 // CHECK-NEXT: foo()
@@ -144,7 +147,8 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: long arr[argc];
 // CHECK-NEXT: omp_depend_t x;
 // CHECK-NEXT: omp_event_handle_t evt;
-// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(long)])argv) if(task: argc > 0) 
depend(depobj : x) detach(evt)
+// CHECK-NEXT: double *arr_double;
+// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(long)])argv,arr_double[argc]) if(task: 
argc > 0) depend(depobj : x) detach(evt)
 // CHECK-NEXT: a = 2;
 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) 
firstprivate(argv) shared(d) if(argc > 0) final(S::TS > 0) priority(argc) 
affinity(argc,argv[b:argc],arr[:],([argc][sizeof(long)])argv)
 // CHECK-NEXT: foo()



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


[PATCH] D81157: Propose naming principle for NodeRole and apply it

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81157

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp

Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -120,18 +120,14 @@
 return OS << "IfStatement_elseKeyword";
   case syntax::NodeRole::IfStatement_elseStatement:
 return OS << "IfStatement_elseStatement";
-  case syntax::NodeRole::IntegerLiteralExpression_literalToken:
+  case syntax::NodeRole::LiteralToken:
 return OS << "IntegerLiteralExpression_literalToken";
-  case syntax::NodeRole::CxxNullPtrExpression_keyword:
-return OS << "CxxNullPtrExpression_keyword";
-  case syntax::NodeRole::UnaryOperatorExpression_operatorToken:
-return OS << "UnaryOperatorExpression_operatorToken";
+  case syntax::NodeRole::OperatorExpression_operatorToken:
+return OS << "OperatorExpression_operatorToken";
   case syntax::NodeRole::UnaryOperatorExpression_operand:
 return OS << "UnaryOperatorExpression_operand";
   case syntax::NodeRole::BinaryOperatorExpression_leftHandSide:
 return OS << "BinaryOperatorExpression_leftHandSide";
-  case syntax::NodeRole::BinaryOperatorExpression_operatorToken:
-return OS << "BinaryOperatorExpression_operatorToken";
   case syntax::NodeRole::BinaryOperatorExpression_rightHandSide:
 return OS << "BinaryOperatorExpression_rightHandSide";
   case syntax::NodeRole::ReturnStatement_value:
@@ -154,8 +150,8 @@
 return OS << "ExplicitTemplateInstantiation_declaration";
   case syntax::NodeRole::ArraySubscript_sizeExpression:
 return OS << "ArraySubscript_sizeExpression";
-  case syntax::NodeRole::TrailingReturnType_arrow:
-return OS << "TrailingReturnType_arrow";
+  case syntax::NodeRole::TrailingReturnType_arrowToken:
+return OS << "TrailingReturnType_arrowToken";
   case syntax::NodeRole::TrailingReturnType_declarator:
 return OS << "TrailingReturnType_declarator";
   case syntax::NodeRole::ParametersAndQualifiers_parameter:
@@ -168,12 +164,12 @@
 
 syntax::Leaf *syntax::IntegerLiteralExpression::literalToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::IntegerLiteralExpression_literalToken));
+  findChild(syntax::NodeRole::LiteralToken));
 }
 
 syntax::Leaf *syntax::CxxNullPtrExpression::nullPtrKeyword() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::CxxNullPtrExpression_keyword));
+  findChild(syntax::NodeRole::LiteralToken));
 }
 
 syntax::Expression *syntax::BinaryOperatorExpression::lhs() {
@@ -183,7 +179,7 @@
 
 syntax::Leaf *syntax::UnaryOperatorExpression::operatorToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::UnaryOperatorExpression_operatorToken));
+  findChild(syntax::NodeRole::OperatorExpression_operatorToken));
 }
 
 syntax::Expression *syntax::UnaryOperatorExpression::operand() {
@@ -193,7 +189,7 @@
 
 syntax::Leaf *syntax::BinaryOperatorExpression::operatorToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::BinaryOperatorExpression_operatorToken));
+  findChild(syntax::NodeRole::OperatorExpression_operatorToken));
 }
 
 syntax::Expression *syntax::BinaryOperatorExpression::rhs() {
@@ -402,7 +398,7 @@
 
 syntax::Leaf *syntax::TrailingReturnType::arrow() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::TrailingReturnType_arrow));
+  findChild(syntax::NodeRole::TrailingReturnType_arrowToken));
 }
 
 syntax::SimpleDeclarator *syntax::TrailingReturnType::declarator() {
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -609,26 +609,22 @@
   }
 
   bool WalkUpFromIntegerLiteral(IntegerLiteral *S) {
-Builder.markChildToken(
-S->getLocation(),
-syntax::NodeRole::IntegerLiteralExpression_literalToken);
+Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
 Builder.foldNode(Builder.getExprRange(S),
  new (allocator()) syntax::IntegerLiteralExpression, S);
 return true;
   }
 
   bool WalkUpFromCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *S) {
-Builder.markChildToken(S->getLocation(),
-   syntax::NodeRole::CxxNullPtrExpression_keyword);
+Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
 Builder.foldNode(Builder.getExprRange(S),
  new (allocator()) syntax::CxxNullPtrExpression, S);
 return true;
   }
 
   bool WalkUpFromUnaryOperator(UnaryOperator *S) {
-Builder.markChildToken(
-S->getOperatorLoc(),
-syntax::NodeRole::UnaryOperatorExpressi

[PATCH] D78637: [OPENMP]Fix PR45383: type dependent array subscripts are diagnosed erroneously.

2020-06-04 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3c191ae555cc: [OPENMP]Fix PR45383: type dependent array 
subscripts are diagnosed erroneously. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78637

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/task_ast_print.cpp


Index: clang/test/OpenMP/task_ast_print.cpp
===
--- clang/test/OpenMP/task_ast_print.cpp
+++ clang/test/OpenMP/task_ast_print.cpp
@@ -99,7 +99,8 @@
   T arr[argc];
   omp_depend_t x;
   omp_event_handle_t evt;
-#pragma omp task untied depend(in : argc, argv[b:argc], arr[:], 
([argc][sizeof(T)])argv) if (task : argc > 0) depend(depobj: x) detach(evt)
+  double *arr_double;
+#pragma omp task untied depend(in : argc, argv[b:argc], arr[:], 
([argc][sizeof(T)])argv, arr_double[argc]) if (task : argc > 0) depend(depobj: 
x) detach(evt)
   a = 2;
 #pragma omp task default(none), private(argc, b) firstprivate(argv) shared(d) 
if (argc > 0) final(S::TS > 0) priority(argc) affinity(argc, argv[b:argc], 
arr[:], ([argc][sizeof(T)])argv)
   foo();
@@ -116,7 +117,8 @@
 // CHECK-NEXT: T arr[argc];
 // CHECK-NEXT: omp_depend_t x;
 // CHECK-NEXT: omp_event_handle_t evt;
-// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(T)])argv) if(task: argc > 0) 
depend(depobj : x) detach(evt)
+// CHECK-NEXT: double *arr_double;
+// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(T)])argv,arr_double[argc]) if(task: 
argc > 0) depend(depobj : x) detach(evt)
 // CHECK-NEXT: a = 2;
 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) 
firstprivate(argv) shared(d) if(argc > 0) final(S::TS > 0) priority(argc) 
affinity(argc,argv[b:argc],arr[:],([argc][sizeof(T)])argv)
 // CHECK-NEXT: foo()
@@ -130,7 +132,8 @@
 // CHECK-NEXT: int arr[argc];
 // CHECK-NEXT: omp_depend_t x;
 // CHECK-NEXT: omp_event_handle_t evt;
-// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(int)])argv) if(task: argc > 0) 
depend(depobj : x) detach(evt)
+// CHECK-NEXT: double *arr_double;
+// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(int)])argv,arr_double[argc]) if(task: 
argc > 0) depend(depobj : x) detach(evt)
 // CHECK-NEXT: a = 2;
 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) 
firstprivate(argv) shared(d) if(argc > 0) final(S::TS > 0) priority(argc) 
affinity(argc,argv[b:argc],arr[:],([argc][sizeof(int)])argv)
 // CHECK-NEXT: foo()
@@ -144,7 +147,8 @@
 // CHECK-NEXT: long arr[argc];
 // CHECK-NEXT: omp_depend_t x;
 // CHECK-NEXT: omp_event_handle_t evt;
-// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(long)])argv) if(task: argc > 0) 
depend(depobj : x) detach(evt)
+// CHECK-NEXT: double *arr_double;
+// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(long)])argv,arr_double[argc]) if(task: 
argc > 0) depend(depobj : x) detach(evt)
 // CHECK-NEXT: a = 2;
 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) 
firstprivate(argv) shared(d) if(argc > 0) final(S::TS > 0) priority(argc) 
affinity(argc,argv[b:argc],arr[:],([argc][sizeof(long)])argv)
 // CHECK-NEXT: foo()
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -16128,7 +16128,7 @@
 
 auto *ASE = dyn_cast(SimpleExpr);
 if (!RefExpr->IgnoreParenImpCasts()->isLValue() ||
-(ASE &&
+(ASE && !ASE->getBase()->isTypeDependent() &&
  !ASE->getBase()
   ->getType()
   .getNonReferenceType()


Index: clang/test/OpenMP/task_ast_print.cpp
===
--- clang/test/OpenMP/task_ast_print.cpp
+++ clang/test/OpenMP/task_ast_print.cpp
@@ -99,7 +99,8 @@
   T arr[argc];
   omp_depend_t x;
   omp_event_handle_t evt;
-#pragma omp task untied depend(in : argc, argv[b:argc], arr[:], ([argc][sizeof(T)])argv) if (task : argc > 0) depend(depobj: x) detach(evt)
+  double *arr_double;
+#pragma omp task untied depend(in : argc, argv[b:argc], arr[:], ([argc][sizeof(T)])argv, arr_double[argc]) if (task : argc > 0) depend(depobj: x) detach(evt)
   a = 2;
 #pragma omp task default(none), private(argc, b) firstprivate(argv) shared(d) if (argc > 0) final(S::TS > 0) priority(argc) affinity(argc, argv[b:argc], arr[:], ([argc][sizeof(T)])argv)
   foo();
@@ -116,7 +117,8 @@
 // CHECK-NEXT: T arr[argc];
 // CHECK-NEXT: omp_depend_t x;
 // CHECK-NEXT: omp_event_handle_t evt;
-// CHECK-NEXT: #pragma omp task untied depend(in : argc,argv[b:argc],arr[:],([argc][sizeof(T)])argv) if(task: argc > 0) depend(depobj : x) detach(evt)
+

[PATCH] D80699: [Analyzer][StreamChecker] Add check for pointer escape.

2020-06-04 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 2 inline comments as done.
balazske added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:439-441
+  // Do not handle untracked stream. It is probably escaped.
+  if (!State->get(StreamSym))
+return;

Szelethus wrote:
> How does this interact with D78280?
That change needs to be updated after this. A new "escaped" stream state is 
needed to avoid recognizing an escaped stream again.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:952-954
+  for (InvalidatedSymbols::const_iterator I = Escaped.begin(),
+  E = Escaped.end();
+   I != E; ++I) {

Szelethus wrote:
> Foreach? 
The foreach type loop does work too, will be updated (this code is taken from 
another checker).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80699



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


[PATCH] D62922: [WebAssembly] Implement "Reactor" mode

2020-06-04 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added inline comments.



Comment at: clang/test/Driver/wasm-toolchain.c:116
+// CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+

This isn't working for me on redhat 7 servers. I get
```
 "wasm-ld" "-L/lib" "/lib/crt1.o" ...
```
No idea why I get the full patch to crt1.o. But it's not matching with the 
FileCheck pattern.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62922



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


[PATCH] D80932: [SYCL] Make default address space a superset of OpenCL address spaces.

2020-06-04 Thread Victor Lomuller via Phabricator via cfe-commits
Naghasan added a comment.

In D80932#2072064 , @Anastasia wrote:

> In D80932#2071321 , @bader wrote:
>
> > In D80932#2068863 , @Anastasia 
> > wrote:
> >
> > >
> >
> >
> >
> >
> > > Why? Can you explain what you are trying to achieve with this?
> >
> > I think @asavonic can provide more detailed answer, but IIRC we spent a lot 
> > time trying to marry template meta-programming with OpenCL address space 
> > deductions, but even simplest template functions from C++ standard library 
> > breaks compilation. It's important to note one important difference in 
> > design goals for SYCL and C++ for OpenCL. SYCL aims to enable compilation 
> > of regular C++ as much as possible where as one of the C++ for OpenCL goals 
> > is to keep compatibility with OpenCL C. These two goals might lead to 
> > different design decisions.
>
>
> I don't see a contradiction in those goals. We plan to support C++ libraries 
> with C++ for OpenCL of course with functionality that is accepted by 
> conformant OpenCL implementations. For example, libraries that use virtual 
> functions leading to function pointers are not going to work portably in 
> OpenCL devices. If SYCL aims to compile to conformant OpenCL devices then it 
> should not be very different I imagine?


There is a fundamental difference (given the direction taken for OpenCL), 
OpenCL mode actively modifies user's types  (C and C++ for OpenCL AFAIK). So 
inside a function, this:

  int var;

becomes

  VarDecl  var '__private int'

Which is fine in C where you can't really do much  with your types, but this 
has a massive and destructive effect in C++. For instance this does not compile 
in C++ for OpenCL:

  void foo() {
  int var; // '__private int' not 'int'
  int* ptr1 = &var; // '__generic int* __private' not 'int*'
  decltype(var)* ptr2 = ptr1; // error: cannot initialize a variable of 
type 'decltype(var) *__private' (aka '__private int *__private') with an lvalue 
of type '__generic int *__private'
  }



> We plan to support C++ libraries with C++ for OpenCL

With the direction taken so far, C++ for OpenCL can't properly implement or use 
basic C++ due to this. Trivial example using a `is_same` implementation 
(https://godbolt.org/z/CLFV6z):

  template
  struct is_same {
  static constexpr int value = 0;
  };
  
  template
  struct is_same {
  static constexpr int value = 1;
  };
  
  void foo(int p) {
  static_assert(is_same::value, "int is not an int?"); // 
Fails: p is '__private int' != 'int'
  static_assert(is_same::value, "int* is not an 
int*?");  // Fails: p is '__private int*' != '__generic int*'
  }

So yes, you could implement `std::is_same` but it won't work as one would 
expect.

That's the reason why SYCL actively tries to prevent changing any type, this 
would prevent the compilation of valid C++ code without a fundamental reason 
(e.g. the target is not able to support it).

> Default address space is a Clang concept that is generally used for an 
> automatic storage.

That's not true in CUDA. On the other hand they actively avoids using address 
space.
Plus in `isAddressSpaceSupersetOf` you have:

  // Consider pointer size address spaces to be equivalent to default.
  ((isPtrSizeAddressSpace(A) || A == LangAS::Default) &&
  (isPtrSizeAddressSpace(B) || B == LangAS::Default))

An alternative would be to clone the address space. But that would be shame to 
not find a way to reuse the opencl one as down the line, they map to the same 
thing.




Comment at: clang/include/clang/AST/Type.h:493
+other.getAddressSpace()) ||
+   (!hasAddressSpace() &&
+(other.getAddressSpace() == LangAS::opencl_private ||

Not sure how to make it better, but this may not be true depending on what is 
allowed by the language.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80932



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


[PATCH] D81150: Use libClangTesting in the unittest for AST matchers

2020-06-04 Thread Marcel Hlopko via Phabricator via cfe-commits
hlopko accepted this revision.
hlopko added a comment.
This revision is now accepted and ready to land.

Nice! :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81150



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


[PATCH] D80699: [Analyzer][StreamChecker] Add check for pointer escape.

2020-06-04 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 268459.
balazske added a comment.

Using range-based for loop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80699

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream.c

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -192,4 +192,51 @@
 rewind(f1); // expected-warning {{Stream might be invalid}}
 fclose(f1);
   }
-}
\ No newline at end of file
+}
+
+extern FILE *GlobalF;
+extern void takeFile(FILE *);
+
+void check_escape1() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+  GlobalF = F;
+  fwrite("1", 1, 1, F); // no warning
+}
+
+void check_escape2() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+  takeFile(F);
+  fwrite("1", 1, 1, F); // no warning
+}
+
+void check_escape3() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  takeFile(F);
+  F = freopen(0, "w", F);
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+  fwrite("1", 1, 1, F); // no warning
+}
+
+void check_escape4() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+
+  // no escape at (non-StreamChecker-handled) system call
+  // FIXME: all such calls should be handled by the checker
+  fprintf(F, "0");
+
+  fwrite("1", 1, 1, F); // expected-warning {{might be 'indeterminate'}}
+  fclose(F);
+}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -193,8 +193,8 @@
   return State;
 }
 
-class StreamChecker
-: public Checker {
+class StreamChecker : public Checker {
   mutable std::unique_ptr BT_nullfp, BT_illegalwhence,
   BT_UseAfterClose, BT_UseAfterOpenFailed, BT_ResourceLeak, BT_StreamEof,
   BT_IndeterminatePosition;
@@ -203,6 +203,10 @@
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
   bool evalCall(const CallEvent &Call, CheckerContext &C) const;
   void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
+  ProgramStateRef checkPointerEscape(ProgramStateRef State,
+ const InvalidatedSymbols &Escaped,
+ const CallEvent *Call,
+ PointerEscapeKind Kind) const;
 
   /// If true, evaluate special testing stream functions.
   bool TestMode = false;
@@ -428,10 +432,14 @@
 
   SymbolRef StreamSym = StreamVal->getAsSymbol();
   // Do not care about concrete values for stream ("(FILE *)0x12345"?).
-  // FIXME: Are stdin, stdout, stderr such values?
+  // FIXME: Can be stdin, stdout, stderr such values?
   if (!StreamSym)
 return;
 
+  // Do not handle untracked stream. It is probably escaped.
+  if (!State->get(StreamSym))
+return;
+
   // Generate state for non-failed case.
   // Return value is the passed stream pointer.
   // According to the documentations, the stream is closed first
@@ -932,6 +940,28 @@
   }
 }
 
+ProgramStateRef StreamChecker::checkPointerEscape(
+ProgramStateRef State, const InvalidatedSymbols &Escaped,
+const CallEvent *Call, PointerEscapeKind Kind) const {
+  // Check for file-handling system call that is not handled by the checker.
+  // FIXME: The checker should be updated to handle all system calls that take
+  // 'FILE*' argument. These are now ignored.
+  if (Kind == PSK_DirectEscapeOnCall && Call->isInSystemHeader())
+return State;
+
+  for (SymbolRef Sym : Escaped) {
+// The symbol escaped.
+// From now the stream can be manipulated in unknown way to the checker,
+// it is not possible to handle it any more.
+// Optimistically, assume that the corresponding file handle will be closed
+// somewhere else.
+// Remove symbol from state so the following stream calls on this symbol are
+// not handled by the checker.
+State = State->remove(Sym);
+  }
+  return State;
+}
+
 void ento::registerStreamChecker(CheckerManager &Mgr) {
   Mgr.registerChecker();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62922: [WebAssembly] Implement "Reactor" mode

2020-06-04 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added inline comments.



Comment at: clang/test/Driver/wasm-toolchain.c:116
+// CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+

bjope wrote:
> This isn't working for me on redhat 7 servers. I get
> ```
>  "wasm-ld" "-L/lib" "/lib/crt1.o" ...
> ```
> No idea why I get the full patch to crt1.o. But it's not matching with the 
> FileCheck pattern.
/full patch/full path/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62922



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


[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-06-04 Thread Sam Elliott via Phabricator via cfe-commits
lenary added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:473
+architectures.  The size parameter of a boolean vector type is the number of
+bits in the vector (for all non-bool vectors, the number refers to the number
+of bytes in the vector).

It would be nice if this aside about non-bool vectors was more prominently 
displayed - it's something I hadn't realised before.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083



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


[PATCH] D80725: [Analyzer][StreamChecker] Updated initialization of BugType's.

2020-06-04 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0bfd70bdad7e: [Analyzer][StreamChecker] Updated 
initialization of BugType's. (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80725

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

Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -195,9 +195,29 @@
 
 class StreamChecker
 : public Checker {
-  mutable std::unique_ptr BT_nullfp, BT_illegalwhence,
-  BT_UseAfterClose, BT_UseAfterOpenFailed, BT_ResourceLeak, BT_StreamEof,
-  BT_IndeterminatePosition;
+  BuiltinBug BT_FileNull{this, "NULL stream pointer",
+ "Stream pointer might be NULL."};
+  BuiltinBug BT_UseAfterClose{
+  this, "Closed stream",
+  "Stream might be already closed. Causes undefined behaviour."};
+  BuiltinBug BT_UseAfterOpenFailed{this, "Invalid stream",
+   "Stream might be invalid after "
+   "(re-)opening it has failed. "
+   "Can cause undefined behaviour."};
+  BuiltinBug BT_IndeterminatePosition{
+  this, "Invalid stream state",
+  "File position of the stream might be 'indeterminate' "
+  "after a failed operation. "
+  "Can cause undefined behavior."};
+  BuiltinBug BT_IllegalWhence{this, "Illegal whence argument",
+  "The whence argument to fseek() should be "
+  "SEEK_SET, SEEK_END, or SEEK_CUR."};
+  BuiltinBug BT_StreamEof{this, "Stream already in EOF",
+  "Read function called when stream is in EOF state. "
+  "Function has no effect."};
+  BuiltinBug BT_ResourceLeak{
+  this, "Resource Leak",
+  "Opened File never closed. Potential Resource leak."};
 
 public:
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
@@ -755,11 +775,8 @@
 
   if (!StateNotNull && StateNull) {
 if (ExplodedNode *N = C.generateErrorNode(StateNull)) {
-  if (!BT_nullfp)
-BT_nullfp.reset(new BuiltinBug(this, "NULL stream pointer",
-   "Stream pointer might be NULL."));
   C.emitReport(std::make_unique(
-  *BT_nullfp, BT_nullfp->getDescription(), N));
+  BT_FileNull, BT_FileNull.getDescription(), N));
 }
 return nullptr;
   }
@@ -783,12 +800,8 @@
 // according to cppreference.com .
 ExplodedNode *N = C.generateErrorNode();
 if (N) {
-  if (!BT_UseAfterClose)
-BT_UseAfterClose.reset(new BuiltinBug(this, "Closed stream",
-  "Stream might be already closed. "
-  "Causes undefined behaviour."));
   C.emitReport(std::make_unique(
-  *BT_UseAfterClose, BT_UseAfterClose->getDescription(), N));
+  BT_UseAfterClose, BT_UseAfterClose.getDescription(), N));
   return nullptr;
 }
 
@@ -802,14 +815,8 @@
 // failed to open.
 ExplodedNode *N = C.generateErrorNode();
 if (N) {
-  if (!BT_UseAfterOpenFailed)
-BT_UseAfterOpenFailed.reset(
-new BuiltinBug(this, "Invalid stream",
-   "Stream might be invalid after "
-   "(re-)opening it has failed. "
-   "Can cause undefined behaviour."));
   C.emitReport(std::make_unique(
-  *BT_UseAfterOpenFailed, BT_UseAfterOpenFailed->getDescription(), N));
+  BT_UseAfterOpenFailed, BT_UseAfterOpenFailed.getDescription(), N));
   return nullptr;
 }
 return State;
@@ -831,13 +838,6 @@
   assert(SS->isOpened() && "First ensure that stream is opened.");
 
   if (SS->FilePositionIndeterminate) {
-if (!BT_IndeterminatePosition)
-  BT_IndeterminatePosition.reset(
-  new BuiltinBug(this, "Invalid stream state",
- "File position of the stream might be 'indeterminate' "
- "after a failed operation. "
- "Can cause undefined behavior."));
-
 if (SS->ErrorState & ErrorFEof) {
   // The error is unknown but may be FEOF.
   // Continue analysis with the FEOF error state.
@@ -847,7 +847,7 @@
 return nullptr;
 
   C.emitReport(std::make_unique(
-  *BT_IndeterminatePosition, BT_IndeterminatePosition->getDescription(),
+  BT_IndeterminatePosition, BT_IndeterminatePosition.getDescription(),
   N));
   return State->set(
   Sym, StreamState::getOpened(SS->LastOperation, ErrorFEof, false));
@@ -858,7 +858,7 @@
 ExplodedNode *N = C.generateErrorNode(State);
 if (N)
   C.

[clang] 0bfd70b - [Analyzer][StreamChecker] Updated initialization of BugType's.

2020-06-04 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri
Date: 2020-06-04T16:06:07+02:00
New Revision: 0bfd70bdad7e4ac22d96503fa78a5dd55d4b430e

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

LOG: [Analyzer][StreamChecker] Updated initialization of BugType's.

Summary:
BugType objects are initialized in-class instead of by lazy initialization.
FuchsiaHandleChecker does this already.

Reviewers: Szelethus, baloghadamsoftware, martong

Reviewed By: Szelethus

Subscribers: rnkovacs, xazax.hun, baloghadamsoftware, szepet, a.sidorin, 
mikhail.ramalho, Szelethus, donat.nagy, dkrupp, gamesh411, Charusso, martong, 
ASDenysPetrov, cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 63ebfaf90dc8..bfb788c24e24 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -195,9 +195,29 @@ ProgramStateRef bindInt(uint64_t Value, ProgramStateRef 
State,
 
 class StreamChecker
 : public Checker {
-  mutable std::unique_ptr BT_nullfp, BT_illegalwhence,
-  BT_UseAfterClose, BT_UseAfterOpenFailed, BT_ResourceLeak, BT_StreamEof,
-  BT_IndeterminatePosition;
+  BuiltinBug BT_FileNull{this, "NULL stream pointer",
+ "Stream pointer might be NULL."};
+  BuiltinBug BT_UseAfterClose{
+  this, "Closed stream",
+  "Stream might be already closed. Causes undefined behaviour."};
+  BuiltinBug BT_UseAfterOpenFailed{this, "Invalid stream",
+   "Stream might be invalid after "
+   "(re-)opening it has failed. "
+   "Can cause undefined behaviour."};
+  BuiltinBug BT_IndeterminatePosition{
+  this, "Invalid stream state",
+  "File position of the stream might be 'indeterminate' "
+  "after a failed operation. "
+  "Can cause undefined behavior."};
+  BuiltinBug BT_IllegalWhence{this, "Illegal whence argument",
+  "The whence argument to fseek() should be "
+  "SEEK_SET, SEEK_END, or SEEK_CUR."};
+  BuiltinBug BT_StreamEof{this, "Stream already in EOF",
+  "Read function called when stream is in EOF state. "
+  "Function has no effect."};
+  BuiltinBug BT_ResourceLeak{
+  this, "Resource Leak",
+  "Opened File never closed. Potential Resource leak."};
 
 public:
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
@@ -755,11 +775,8 @@ StreamChecker::ensureStreamNonNull(SVal StreamVal, 
CheckerContext &C,
 
   if (!StateNotNull && StateNull) {
 if (ExplodedNode *N = C.generateErrorNode(StateNull)) {
-  if (!BT_nullfp)
-BT_nullfp.reset(new BuiltinBug(this, "NULL stream pointer",
-   "Stream pointer might be NULL."));
   C.emitReport(std::make_unique(
-  *BT_nullfp, BT_nullfp->getDescription(), N));
+  BT_FileNull, BT_FileNull.getDescription(), N));
 }
 return nullptr;
   }
@@ -783,12 +800,8 @@ ProgramStateRef StreamChecker::ensureStreamOpened(SVal 
StreamVal,
 // according to cppreference.com .
 ExplodedNode *N = C.generateErrorNode();
 if (N) {
-  if (!BT_UseAfterClose)
-BT_UseAfterClose.reset(new BuiltinBug(this, "Closed stream",
-  "Stream might be already closed. 
"
-  "Causes undefined behaviour."));
   C.emitReport(std::make_unique(
-  *BT_UseAfterClose, BT_UseAfterClose->getDescription(), N));
+  BT_UseAfterClose, BT_UseAfterClose.getDescription(), N));
   return nullptr;
 }
 
@@ -802,14 +815,8 @@ ProgramStateRef StreamChecker::ensureStreamOpened(SVal 
StreamVal,
 // failed to open.
 ExplodedNode *N = C.generateErrorNode();
 if (N) {
-  if (!BT_UseAfterOpenFailed)
-BT_UseAfterOpenFailed.reset(
-new BuiltinBug(this, "Invalid stream",
-   "Stream might be invalid after "
-   "(re-)opening it has failed. "
-   "Can cause undefined behaviour."));
   C.emitReport(std::make_unique(
-  *BT_UseAfterOpenFailed, BT_UseAfterOpenFailed->getDescription(), N));
+  BT_UseAfterOpenFailed, BT_UseAfterOpenFailed.getDescription(), N));
   return nullptr;
 }
 return State;
@@ -831,13 +838,6 @@ ProgramStateRef 
StreamChecker::ensureNoFilePositionIndeterminate(
   assert(SS->isOpened() && "First ensure that stream is opened.

[PATCH] D80947: Add to the Coding Standard our that single-line bodies omit braces

2020-06-04 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

This LGTM. I believe we have not heard back from @arsenm on the response to 
some of their comments though.




Comment at: llvm/docs/CodingStandards.rst:1603
+
+  // This should also omit braces.  The for loop contains only a single 
statement,
+  // so it shouldn't have braces.  The if also only contains a single 
statement (the

erichkeane wrote:
> arsenm wrote:
> > This loop should use braces. It covers multiple lines. Omitting braces 
> > invariably just increases diffs/merge conflicts when something else is 
> > added to the loop body.
> > 
> > This one isn't consistently applied and I've been enforcing the opposite
> This is how we've been enforcing the rule however, can you suggest a change 
> to the wording that you think would match our current enforcement?
Much as it may be seen to be "ideal" that conventions are uniform throughout 
the project, it is the case that different areas of the code have somewhat of a 
local convention. The example may lean towards not using braces as the general 
case, but the wording was done so that areas of code where the observed 
increase in diffs/merge conflicts occur frequently can use and enforce braces 
because said occurrences would be indicative of harm caused by the omission of 
braces.


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

https://reviews.llvm.org/D80947



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


[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-06-04 Thread Simon Moll via Phabricator via cfe-commits
simoll marked an inline comment as done.
simoll added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:473
+architectures.  The size parameter of a boolean vector type is the number of
+bits in the vector (for all non-bool vectors, the number refers to the number
+of bytes in the vector).

lenary wrote:
> It would be nice if this aside about non-bool vectors was more prominently 
> displayed - it's something I hadn't realised before.
Yep. that caught me by surprise too. I'll move that sentence to the paragraph 
about GCC vectors above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083



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


[clang] 62305f6 - Rename arrow -> arrowToken for unified naming

2020-06-04 Thread Dmitri Gribenko via cfe-commits
Author: Eduardo Caldas
Date: 2020-06-04T16:12:16+02:00
New Revision: 62305f6db4ed642c6b2b005dcb7951eb38342dca

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

LOG: Rename arrow -> arrowToken for unified naming

Reviewers: gribozavr2

Reviewed By: gribozavr2

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Tooling/Syntax/Nodes.h
clang/lib/Tooling/Syntax/Nodes.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/Nodes.h 
b/clang/include/clang/Tooling/Syntax/Nodes.h
index bf0308c95ba4..7d0c4439e279 100644
--- a/clang/include/clang/Tooling/Syntax/Nodes.h
+++ b/clang/include/clang/Tooling/Syntax/Nodes.h
@@ -639,7 +639,7 @@ class TrailingReturnType final : public Tree {
 return N->kind() == NodeKind::TrailingReturnType;
   }
   // TODO: add accessors for specifiers.
-  syntax::Leaf *arrow();
+  syntax::Leaf *arrowToken();
   syntax::SimpleDeclarator *declarator();
 };
 

diff  --git a/clang/lib/Tooling/Syntax/Nodes.cpp 
b/clang/lib/Tooling/Syntax/Nodes.cpp
index d70b89b07200..bad902b8c6d7 100644
--- a/clang/lib/Tooling/Syntax/Nodes.cpp
+++ b/clang/lib/Tooling/Syntax/Nodes.cpp
@@ -400,7 +400,7 @@ syntax::Leaf *syntax::ArraySubscript::rbracket() {
   findChild(syntax::NodeRole::CloseParen));
 }
 
-syntax::Leaf *syntax::TrailingReturnType::arrow() {
+syntax::Leaf *syntax::TrailingReturnType::arrowToken() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::TrailingReturnType_arrow));
 }



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


[PATCH] D81157: Propose naming principle for NodeRole and apply it

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



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:94
 /// a binary expression'. Used for implementing accessors.
+// How to name NodeRole:
+// If the child node is a token/keyword, end its name with 'Token'/'Keyword'

I'd suggest to make this into a doc comment, but phrase it in a way that is 
useful for users, so that they can understand the pattern too. For example:

Some roles describe parent/child relations that occur multiple times in 
language grammar. We define only one role to describe all instances of such 
recurring relations. For example, grammar for both "if" and "while" statements 
requires an opening paren and a closing paren. The opening paren token is 
assigned the `OpenParen` role regardless of whether it appears as a child of 
`IfStatement` or `WhileStatement` node. More generally, when grammar requires a 
certain fixed token (like a specific keyword, or an opening paren), we define a 
role for this token and use it across all grammar rules with the same 
requirement. Names of such reusable roles end with a `~Token` or a `~Keyword` 
suffix.

Some roles are assigned only to child nodes of one specific parent syntax node 
type. Names of such roles start with the name of the parent syntax tree node 
type. For example, a syntax node with a role 
`BinaryOperatorExpression_leftHandSide` can only appear as a child of a 
`BinaryOperatorExpression` node.





Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:124
   IfStatement_thenStatement,
   IfStatement_elseKeyword,
   IfStatement_elseStatement,

Shouldn't `elseKeyword` have no prefix?



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:133
   TemplateDeclaration_declaration,
   ExplicitTemplateInstantiation_externKeyword,
   ExplicitTemplateInstantiation_declaration,

Shouldn't `externKeyword` have no prefix?



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:136
   ArraySubscript_sizeExpression,
-  TrailingReturnType_arrow,
+  TrailingReturnType_arrowToken,
   TrailingReturnType_declarator,

Shouldn't `arrowToken` have no prefix?



Comment at: clang/lib/Tooling/Syntax/Nodes.cpp:124
+  case syntax::NodeRole::LiteralToken:
 return OS << "IntegerLiteralExpression_literalToken";
+  case syntax::NodeRole::OperatorExpression_operatorToken:

Please update the textual representations of roles that you renamed, and 
reorder the switch to correspond to the new declaration order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81157



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


[PATCH] D81163: [AST][RecoveryExpr] Preserve the AST for invalid conditions.

2020-06-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: clang.

Tested with enabling "-frecovery-ast", only 1 failure, which is
an improvement of secondary diagnostic.

  --
  error: 'error' diagnostics seen but not expected:
File /workspace/llvm-project/clang/test/SemaTemplate/instantiate-expr-3.cpp 
Line 68: invalid operands to binary expression ('N1::X' and 'int')
  1 error generated.
  
  --


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81163

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/ast-dump-recovery.cpp


Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -211,3 +211,30 @@
 } NoCrashOnInvalidInitList = {
   .abc = nullptr,
 };
+
+void InvalidCondition() {
+  // CHECK:  IfStmt {{.*}}
+  // CHECK-NEXT: |-RecoveryExpr {{.*}}  '' 
contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} 
+  if (invalid()) {}
+
+  // CHECK:  WhileStmt {{.*}}
+  // CHECK-NEXT: |-RecoveryExpr {{.*}}  '' 
contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} 
+  while (invalid()) {}
+
+  // CHECK:  SwitchStmt {{.*}}
+  // CHECK-NEXT: |-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} 
+  switch(invalid()) {
+case 1:
+  break;
+  }
+  // FIXME: figure out why the type of ConditionalOperator is not int.
+  // CHECK:  ConditionalOperator {{.*}} '' contains-errors
+  // CHECK-NEXT: |-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}}
+  // CHECK-NEXT: |-IntegerLiteral {{.*}} 'int' 1
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 2
+  invalid() ? 1 : 2;
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -18420,9 +18420,12 @@
 Cond = CheckSwitchCondition(Loc, SubExpr);
 break;
   }
-  if (Cond.isInvalid())
-return ConditionError();
-
+  if (Cond.isInvalid()) {
+Cond = CreateRecoveryExpr(SubExpr->getBeginLoc(), SubExpr->getEndLoc(),
+  {SubExpr});
+if (!Cond.get())
+  return ConditionError();
+  }
   // FIXME: FullExprArg doesn't have an invalid bit, so check nullness instead.
   FullExprArg FullExpr = MakeFullExpr(Cond.get(), Loc);
   if (!FullExpr.get())


Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -211,3 +211,30 @@
 } NoCrashOnInvalidInitList = {
   .abc = nullptr,
 };
+
+void InvalidCondition() {
+  // CHECK:  IfStmt {{.*}}
+  // CHECK-NEXT: |-RecoveryExpr {{.*}}  '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} 
+  if (invalid()) {}
+
+  // CHECK:  WhileStmt {{.*}}
+  // CHECK-NEXT: |-RecoveryExpr {{.*}}  '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} 
+  while (invalid()) {}
+
+  // CHECK:  SwitchStmt {{.*}}
+  // CHECK-NEXT: |-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} 
+  switch(invalid()) {
+case 1:
+  break;
+  }
+  // FIXME: figure out why the type of ConditionalOperator is not int.
+  // CHECK:  ConditionalOperator {{.*}} '' contains-errors
+  // CHECK-NEXT: |-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}}
+  // CHECK-NEXT: |-IntegerLiteral {{.*}} 'int' 1
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 2
+  invalid() ? 1 : 2;
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -18420,9 +18420,12 @@
 Cond = CheckSwitchCondition(Loc, SubExpr);
 break;
   }
-  if (Cond.isInvalid())
-return ConditionError();
-
+  if (Cond.isInvalid()) {
+Cond = CreateRecoveryExpr(SubExpr->getBeginLoc(), SubExpr->getEndLoc(),
+  {SubExpr});
+if (!Cond.get())
+  return ConditionError();
+  }
   // FIXME: FullExprArg doesn't have an invalid bit, so check nullness instead.
   FullExprArg FullExpr = MakeFullExpr(Cond.get(), Loc);
   if (!FullExpr.get())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81155: Rename arrow -> arrowToken for unified naming

2020-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG62305f6db4ed: Rename arrow -> arrowToken for unified 
naming (authored by eduucaldas, committed by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81155

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/Nodes.cpp


Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -400,7 +400,7 @@
   findChild(syntax::NodeRole::CloseParen));
 }
 
-syntax::Leaf *syntax::TrailingReturnType::arrow() {
+syntax::Leaf *syntax::TrailingReturnType::arrowToken() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::TrailingReturnType_arrow));
 }
Index: clang/include/clang/Tooling/Syntax/Nodes.h
===
--- clang/include/clang/Tooling/Syntax/Nodes.h
+++ clang/include/clang/Tooling/Syntax/Nodes.h
@@ -639,7 +639,7 @@
 return N->kind() == NodeKind::TrailingReturnType;
   }
   // TODO: add accessors for specifiers.
-  syntax::Leaf *arrow();
+  syntax::Leaf *arrowToken();
   syntax::SimpleDeclarator *declarator();
 };
 


Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -400,7 +400,7 @@
   findChild(syntax::NodeRole::CloseParen));
 }
 
-syntax::Leaf *syntax::TrailingReturnType::arrow() {
+syntax::Leaf *syntax::TrailingReturnType::arrowToken() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::TrailingReturnType_arrow));
 }
Index: clang/include/clang/Tooling/Syntax/Nodes.h
===
--- clang/include/clang/Tooling/Syntax/Nodes.h
+++ clang/include/clang/Tooling/Syntax/Nodes.h
@@ -639,7 +639,7 @@
 return N->kind() == NodeKind::TrailingReturnType;
   }
   // TODO: add accessors for specifiers.
-  syntax::Leaf *arrow();
+  syntax::Leaf *arrowToken();
   syntax::SimpleDeclarator *declarator();
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69987: [RISCV] Assemble/Disassemble v-ext instructions.

2020-06-04 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69987



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


[PATCH] D80735: [OpenMP][NFC] Reuse OMPIRBuilder `struct ident_t` handling in Clang

2020-06-04 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

The failure message is pretty much always this assertion as far as I can tell

  clang-11: 
/home/jhuber/Documents/llvm-project/llvm/lib/IR/Instructions.cpp:439: void 
llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, 
llvm::ArrayRef, 
llvm::ArrayRef >, const llvm::Twine&): 
Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == 
Args[i]->getType()) && "Calling a function with a bad signature!"' failed.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80735



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


[PATCH] D80735: [OpenMP][NFC] Reuse OMPIRBuilder `struct ident_t` handling in Clang

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

In D80735#2073639 , @jhuber6 wrote:

> The failure message is pretty much always this assertion as far as I can tell
>
>   clang-11: 
> /home/jhuber/Documents/llvm-project/llvm/lib/IR/Instructions.cpp:439: void 
> llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, 
> llvm::ArrayRef, 
> llvm::ArrayRef >, const llvm::Twine&): 
> Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == 
> Args[i]->getType()) && "Calling a function with a bad signature!"' failed.
>


Now we have to figure out what the types are and what is expected. Can you go 
back the stack trace and add some prints to this end?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80735



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


[clang] 9520bf1 - [clang-format] Update GoogleStyle for C# code to match Google's internal C# style guide

2020-06-04 Thread Jonathan Coe via cfe-commits
Author: Jonathan Coe
Date: 2020-06-04T15:48:00+01:00
New Revision: 9520bf146dd3baae8608755d7de0855db4664c77

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

LOG: [clang-format] Update GoogleStyle for C# code to match Google's internal 
C# style guide

Summary: Google's C# style guide is at 
https://google.github.io/styleguide/csharp-style.html

Reviewers: krasimir, MyDeveloperDay, sammccall

Reviewed By: MyDeveloperDay

Subscribers: cfe-commits, klimek

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index f3743921d52e..1f7a8029bac0 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/Format/Format.h"
 #include "AffectedRangeManager.h"
+#include "BreakableToken.h"
 #include "ContinuationIndenter.h"
 #include "FormatInternal.h"
 #include "FormatTokenLexer.h"
@@ -1068,6 +1069,12 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind 
Language) {
 // #imports, etc.)
 GoogleStyle.IncludeStyle.IncludeBlocks =
 tooling::IncludeStyle::IBS_Preserve;
+  } else if (Language == FormatStyle::LK_CSharp) {
+GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+GoogleStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
+GoogleStyle.BreakStringLiterals = false;
+GoogleStyle.ColumnLimit = 100;
+GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
   }
 
   return GoogleStyle;

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index 5567e19e5bdd..dd2ed292ccd8 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -583,8 +583,7 @@ TEST_F(FormatTestCSharp, CSharpNamedArguments) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   verifyFormat(R"(//
-PrintOrderDetails(orderNum: 31, productName: "Red Mug",
-  sellerName: "Gift Shop");)",
+PrintOrderDetails(orderNum: 31, productName: "Red Mug", sellerName: "Gift 
Shop");)",
Style);
 
   // Ensure that trailing comments do not cause problems.
@@ -641,8 +640,7 @@ class TimePeriod {
 get { return _seconds / 3600; }
 set {
   if (value < 0 || value > 24)
-throw new ArgumentOutOfRangeException(
-$"{nameof(value)} must be between 0 and 24.");
+throw new ArgumentOutOfRangeException($"{nameof(value)} must be 
between 0 and 24.");
   _seconds = value * 3600;
 }
   }
@@ -755,7 +753,9 @@ TEST_F(FormatTestCSharp, CSharpNullableTypes) {
 
   verifyFormat(R"(//
 public class A {
-  void foo() { int? value = some.bar(); }
+  void foo() {
+int? value = some.bar();
+  }
 })",
Style); // int? is nullable not a conditional expression.
 
@@ -800,16 +800,15 @@ class Dictionary
 where TKey : IComparable
 where TVal : IMyInterface {
   public void MyMethod(T t)
-  where T : IMyInterface { doThing(); }
+  where T : IMyInterface {
+doThing();
+  }
 })",
Style);
 
   verifyFormat(R"(//
 class ItemFactory
-where T : new(),
-  IAnInterface,
-  IAnotherInterface,
-  IAnotherInterfaceStill {})",
+where T : new(), IAnInterface, IAnotherInterface, 
IAnotherInterfaceStill {})",
Style);
 
   Style.ColumnLimit = 50; // Force lines to be wrapped.



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


[PATCH] D62922: [WebAssembly] Implement "Reactor" mode

2020-06-04 Thread Dan Gohman via Phabricator via cfe-commits
sunfish marked an inline comment as done.
sunfish added inline comments.



Comment at: clang/test/Driver/wasm-toolchain.c:116
+// CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+

bjope wrote:
> bjope wrote:
> > This isn't working for me on redhat 7 servers. I get
> > ```
> >  "wasm-ld" "-L/lib" "/lib/crt1.o" ...
> > ```
> > No idea why I get the full patch to crt1.o. But it's not matching with the 
> > FileCheck pattern.
> /full patch/full path/
Would you be able to test whether the following patch fixes it?

```diff
diff --git a/clang/test/Driver/wasm-toolchain.c 
b/clang/test/Driver/wasm-toolchain.c
index 8300a81614e..332e6048cc5 100644
--- a/clang/test/Driver/wasm-toolchain.c
+++ b/clang/test/Driver/wasm-toolchain.c
@@ -110,11 +110,11 @@

 // Basic exec-model tests.

-// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
-mexec-model=command 2>&1 \
+// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=%s/no-sysroot-there -mexec-model=command 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-COMMAND %s
 // CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"

-// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
-mexec-model=reactor 2>&1 \
+// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=%s/no-sysroot-there -mexec-model=reactor 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-REACTOR %s
 // CHECK-REACTOR: wasm-ld{{.*}}" {{.*}} "--entry" "_initialize" {{.*}}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62922



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


[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-04 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@zequanwu could you please update the release notes? thanks
https://github.com/llvm/llvm-project/blob/master/clang/docs/ReleaseNotes.rst


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79895



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


[PATCH] D80941: [PowerPC][Power10] Implement Count Leading/Trailing Zeroes Builtins under bit Mask in LLVM/Clang

2020-06-04 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 268470.
amyk added a comment.

Revert back to the initial implementation of the patch. Thanks Nemanja for 
clarifying.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80941

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10.c
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
  llvm/test/MC/Disassembler/PowerPC/p10insts.txt
  llvm/test/MC/PowerPC/p10.s

Index: llvm/test/MC/PowerPC/p10.s
===
--- llvm/test/MC/PowerPC/p10.s
+++ llvm/test/MC/PowerPC/p10.s
@@ -15,3 +15,15 @@
 # CHECK-BE: pextd 1, 2, 4 # encoding: [0x7c,0x41,0x21,0x78]
 # CHECK-LE: pextd 1, 2, 4 # encoding: [0x78,0x21,0x41,0x7c]
 pextd 1, 2, 4
+# CHECK-BE: vclzdm 1, 2, 3# encoding: [0x10,0x22,0x1f,0x84]
+# CHECK-LE: vclzdm 1, 2, 3# encoding: [0x84,0x1f,0x22,0x10]
+vclzdm 1, 2, 3
+# CHECK-BE: vctzdm 1, 2, 3# encoding: [0x10,0x22,0x1f,0xc4]
+# CHECK-LE: vctzdm 1, 2, 3# encoding: [0xc4,0x1f,0x22,0x10]
+vctzdm 1, 2, 3
+# CHECK-BE: cntlzdm 1, 3, 2   # encoding: [0x7c,0x61,0x10,0x76]
+# CHECK-LE: cntlzdm 1, 3, 2   # encoding: [0x76,0x10,0x61,0x7c]
+cntlzdm 1, 3, 2
+# CHECK-BE: cnttzdm 1, 3, 2   # encoding: [0x7c,0x61,0x14,0x76]
+# CHECK-LE: cnttzdm 1, 3, 2   # encoding: [0x76,0x14,0x61,0x7c]
+cnttzdm 1, 3, 2
Index: llvm/test/MC/Disassembler/PowerPC/p10insts.txt
===
--- llvm/test/MC/Disassembler/PowerPC/p10insts.txt
+++ llvm/test/MC/Disassembler/PowerPC/p10insts.txt
@@ -12,3 +12,15 @@
 
 # CHECK: pextd 1, 2, 4
 0x7c 0x41 0x21 0x78
+
+# CHECK: vclzdm 1, 2, 3
+0x10 0x22 0x1f 0x84
+
+# CHECK: vctzdm 1, 2, 3
+0x10 0x22 0x1f 0xc4
+
+# CHECK: cntlzdm 1, 3, 2
+0x7c 0x61 0x10 0x76
+
+# CHECK: cnttzdm 1, 3, 2
+0x7c 0x61 0x14 0x76
Index: llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
===
--- llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
+++ llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
@@ -9,6 +9,10 @@
 declare <2 x i64> @llvm.ppc.altivec.vpextd(<2 x i64>, <2 x i64>)
 declare i64 @llvm.ppc.pdepd(i64, i64)
 declare i64 @llvm.ppc.pextd(i64, i64)
+declare <2 x i64> @llvm.ppc.altivec.vclzdm(<2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.ppc.altivec.vctzdm(<2 x i64>, <2 x i64>)
+declare i64 @llvm.ppc.cntlzdm(i64, i64)
+declare i64 @llvm.ppc.cnttzdm(i64, i64)
 
 define <2 x i64> @test_vpdepd(<2 x i64> %a, <2 x i64> %b) {
 ; CHECK-LABEL: test_vpdepd:
@@ -49,3 +53,43 @@
   %tmp = tail call i64 @llvm.ppc.pextd(i64 %a, i64 %b)
   ret i64 %tmp
 }
+
+define <2 x i64> @test_vclzdm(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vclzdm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vclzdm v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call <2 x i64> @llvm.ppc.altivec.vclzdm(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %tmp
+}
+
+define <2 x i64> @test_vctzdm(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vctzdm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vctzdm v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call <2 x i64> @llvm.ppc.altivec.vctzdm(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %tmp
+}
+
+define i64 @test_cntlzdm(i64 %a, i64 %b) {
+; CHECK-LABEL: test_cntlzdm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:cntlzdm r3, r3, r4
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call i64 @llvm.ppc.cntlzdm(i64 %a, i64 %b)
+  ret i64 %tmp
+}
+
+define i64 @test_cnttzdm(i64 %a, i64 %b) {
+; CHECK-LABEL: test_cnttzdm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:cnttzdm r3, r3, r4
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call i64 @llvm.ppc.cnttzdm(i64 %a, i64 %b)
+  ret i64 %tmp
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -516,4 +516,20 @@
def PEXTD : XForm_6<31, 188, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
"pextd $rA, $rS, $rB", IIC_IntGeneral,
[(set i64:$rA, (int_ppc_pextd i64:$rS, i64:$rB))]>;
+   def VCLZDM : VXForm_1<1924, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
+ "vclzdm $vD, $vA, $vB", IIC_VecGeneral,
+ [(set v2i64:$vD,
+ (int_ppc_altivec_vclzdm v2i64:$vA, v2i64:$vB))]>;
+   def VCTZDM : VXForm_1<1988, (outs vrrc:$vD), (ins vrrc:$vA, vr

[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-06-04 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Can you add a test for the diagnostic firing after the correct number of 
initializations? This should include a few types of auto-init, including VLAs.




Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:489
+  "-ftrivial-auto-var-init-stop-after=* has been enabled to limit the number 
of times ftrivial-auto-var-init=zero/pattern gets applied.">,
+  InGroup>;
+

I don't think this is sufficiently clear: automatic variable initialization is 
now disabled because ftrivial-auto-var-init-stop-after has reached its limit.



Comment at: clang/lib/CodeGen/CGDecl.cpp:1684
+  if (CGM.stopAutoInit())
+return;
+  if (trivialAutoVarInit == LangOptions::TrivialAutoVarInitKind::Zero)

I'd rather repeat this than fallthrought and repeat the condition in if/else.



Comment at: clang/lib/CodeGen/CodeGenModule.h:1390
+  if (NumAutoVarInit >= StopAfter)
+return true;
+  ++NumAutoVarInit;

The first time this returns true is when the diagnostic should be emitted.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3092
+  Args.getLastArg(options::OPT_ftrivial_auto_var_init_stop_after)) {
+D.Diag(diag::warn_drv_trivial_auto_var_init_stop_after_enabled);
+A->claim();

Not here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168



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


[PATCH] D79781: [OpenCL] Add cl_khr_extended_subgroup extensions

2020-06-04 Thread Piotr Fusik via Phabricator via cfe-commits
PiotrFusik marked 2 inline comments as done.
PiotrFusik added inline comments.



Comment at: clang/lib/Headers/opencl-c.h:15594
+int __ovld sub_group_elect(void);
+int __ovld sub_group_non_uniform_all( int predicate );
+int __ovld sub_group_non_uniform_any( int predicate );

Anastasia wrote:
> PiotrFusik wrote:
> > Anastasia wrote:
> > > PiotrFusik wrote:
> > > > Anastasia wrote:
> > > > > PiotrFusik wrote:
> > > > > > Anastasia wrote:
> > > > > > > PiotrFusik wrote:
> > > > > > > > Anastasia wrote:
> > > > > > > > > Ideally `convergent` attribute was intended to be used in the 
> > > > > > > > > non-divergent scenarios. So I don't know if it's going to do 
> > > > > > > > > what is needed here. Did you look into this already?
> > > > > > > > > 
> > > > > > > > > If we look at the Clang documentation it says:
> > > > > > > > > 
> > > > > > > > > > In languages designed for SPMD/SIMT programming model, e.g. 
> > > > > > > > > > OpenCL or CUDA, the call instructions of a function with 
> > > > > > > > > > this attribute must be executed by all work items or 
> > > > > > > > > > threads in a work group or sub group.
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > I remember @nhaehnle  was looking at using `convergent` with 
> > > > > > > > > operations in the divergent control flow some time ago 
> > > > > > > > > https://reviews.llvm.org/D68994? I am not sure where this 
> > > > > > > > > thread ended up and whether we can expect this to work 
> > > > > > > > > currently?
> > > > > > > > Thanks for pointing this out! My understanding of the 
> > > > > > > > `convergent` attribute was that it's for uniform control flow, 
> > > > > > > > as per the documentation you cited.
> > > > > > > > A quick check shows that Intel Graphics Compiler doesn't suffer 
> > > > > > > > from this invalid optimization.
> > > > > > > > Yet I agree that the functions should be marked somehow. It is 
> > > > > > > > with `__conv` ?
> > > > > > > 
> > > > > > > > A quick check shows that Intel Graphics Compiler doesn't suffer 
> > > > > > > > from this invalid optimization.
> > > > > > > 
> > > > > > > Did you check on the examples that @nhaehnle provided in the 
> > > > > > > review?
> > > > > > > 
> > > > > > > > Yet I agree that the functions should be marked somehow. It is 
> > > > > > > > with __conv ?
> > > > > > > 
> > > > > > > I am not sure there is a solution to this in the upstream LLVM at 
> > > > > > > present. I am hoping @nhaehnle  can provide us more information. 
> > > > > > > Alternatively, we could run his examples against the latest LLVM 
> > > > > > > revision to see if the problem still remains or not. I am not 
> > > > > > > saying that it should block this review, I am ok that we commit 
> > > > > > > your patch but if we know already that this functionality can't 
> > > > > > > be fully supported it would be good to at least create a bug to 
> > > > > > > OpenCL component to record this.
> > > > > > The following example:
> > > > > > ```
> > > > > > kernel void test(global int *data)
> > > > > > {
> > > > > > uint id = (uint) get_global_id(0);
> > > > > > if (id < 4)
> > > > > > data[id] = sub_group_elect();
> > > > > > else
> > > > > > data[id] = sub_group_elect();
> > > > > > }
> > > > > > ```
> > > > > > with `clang -S -emit-llvm` emits invalid code both with and without 
> > > > > > the `convergent` attribute.
> > > > > > 
> > > > > > We don't have this problem in our Intel Graphics Compiler though. 
> > > > > > That's because we replace the subgroup functions with internal 
> > > > > > intrinsics early enough. These intrinsics are marked with both the 
> > > > > > `convergent` and `inaccessiblememonly` attributes. Then in the 
> > > > > > `SimplifyCFG` pass we prevent optimization if both of these 
> > > > > > attributes are present: 
> > > > > > https://github.com/intel/intel-graphics-compiler/blob/master/IGC/Compiler/GenTTI.cpp#L397
> > > > > > 
> > > > > > I don't understand what can go wrong in the second example (with 
> > > > > > the jump threading pass) ?
> > > > > > 
> > > > > Thanks for checking. Do you mind creating a bug to clang for now 
> > > > > under OpenCL component 
> > > > > https://bugs.llvm.org/enter_bug.cgi?product=clang although we might 
> > > > > reclassify this for a wider scope later on.
> > > > > 
> > > > > 
> > > > > 
> > > > > >  Then in the SimplifyCFG pass we prevent optimization if both of 
> > > > > > these attributes are present: 
> > > > > > https://github.com/intel/intel-graphics-compiler/blob/master/IGC/Compiler/GenTTI.cpp#L397
> > > > > 
> > > > > I see. Perhaps we need to come up with a new semantic of `convergent` 
> > > > > and update LLVM passes... or maybe we have to introduce a new 
> > > > > attribute. Not sure. I suggest we add a comment to 
> > > > > https://reviews.llvm.org/D68994 and see if it gets picked up.
> > > > > 
> > > > > 
> > > > Do you mean a bug for the invalid opti

[PATCH] D79715: [clang-format] Update GoogleStyle for C# code to match Google's internal C# style guide

2020-06-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9520bf146dd3: [clang-format] Update GoogleStyle for C# code 
to match Google's internal C#… (authored by Jonathan Coe 
).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79715

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -583,8 +583,7 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   verifyFormat(R"(//
-PrintOrderDetails(orderNum: 31, productName: "Red Mug",
-  sellerName: "Gift Shop");)",
+PrintOrderDetails(orderNum: 31, productName: "Red Mug", sellerName: "Gift 
Shop");)",
Style);
 
   // Ensure that trailing comments do not cause problems.
@@ -641,8 +640,7 @@
 get { return _seconds / 3600; }
 set {
   if (value < 0 || value > 24)
-throw new ArgumentOutOfRangeException(
-$"{nameof(value)} must be between 0 and 24.");
+throw new ArgumentOutOfRangeException($"{nameof(value)} must be 
between 0 and 24.");
   _seconds = value * 3600;
 }
   }
@@ -755,7 +753,9 @@
 
   verifyFormat(R"(//
 public class A {
-  void foo() { int? value = some.bar(); }
+  void foo() {
+int? value = some.bar();
+  }
 })",
Style); // int? is nullable not a conditional expression.
 
@@ -800,16 +800,15 @@
 where TKey : IComparable
 where TVal : IMyInterface {
   public void MyMethod(T t)
-  where T : IMyInterface { doThing(); }
+  where T : IMyInterface {
+doThing();
+  }
 })",
Style);
 
   verifyFormat(R"(//
 class ItemFactory
-where T : new(),
-  IAnInterface,
-  IAnotherInterface,
-  IAnotherInterfaceStill {})",
+where T : new(), IAnInterface, IAnotherInterface, 
IAnotherInterfaceStill {})",
Style);
 
   Style.ColumnLimit = 50; // Force lines to be wrapped.
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/Format/Format.h"
 #include "AffectedRangeManager.h"
+#include "BreakableToken.h"
 #include "ContinuationIndenter.h"
 #include "FormatInternal.h"
 #include "FormatTokenLexer.h"
@@ -1068,6 +1069,12 @@
 // #imports, etc.)
 GoogleStyle.IncludeStyle.IncludeBlocks =
 tooling::IncludeStyle::IBS_Preserve;
+  } else if (Language == FormatStyle::LK_CSharp) {
+GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+GoogleStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
+GoogleStyle.BreakStringLiterals = false;
+GoogleStyle.ColumnLimit = 100;
+GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
   }
 
   return GoogleStyle;


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -583,8 +583,7 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   verifyFormat(R"(//
-PrintOrderDetails(orderNum: 31, productName: "Red Mug",
-  sellerName: "Gift Shop");)",
+PrintOrderDetails(orderNum: 31, productName: "Red Mug", sellerName: "Gift Shop");)",
Style);
 
   // Ensure that trailing comments do not cause problems.
@@ -641,8 +640,7 @@
 get { return _seconds / 3600; }
 set {
   if (value < 0 || value > 24)
-throw new ArgumentOutOfRangeException(
-$"{nameof(value)} must be between 0 and 24.");
+throw new ArgumentOutOfRangeException($"{nameof(value)} must be between 0 and 24.");
   _seconds = value * 3600;
 }
   }
@@ -755,7 +753,9 @@
 
   verifyFormat(R"(//
 public class A {
-  void foo() { int? value = some.bar(); }
+  void foo() {
+int? value = some.bar();
+  }
 })",
Style); // int? is nullable not a conditional expression.
 
@@ -800,16 +800,15 @@
 where TKey : IComparable
 where TVal : IMyInterface {
   public void MyMethod(T t)
-  where T : IMyInterface { doThing(); }
+  where T : IMyInterface {
+doThing();
+  }
 })",
Style);
 
   verifyFormat(R"(//
 class ItemFactory
-where T : new(),
-  IAnInterface,
-  IAnotherInterface,
-  IAnotherInterfaceStill {})",
+where T : new(), IAnInterface, IAnotherInterface, IAnotherInterfaceStill {})",
Style);
 
   Style.ColumnLimit = 50; // Force lines to be wrapped.
Index: clang/lib/Format/Format.cpp
===
-

[PATCH] D81168: Add support for id-expression in SyntaxTree

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas added a subscriber: gribozavr2.
eduucaldas marked an inline comment as done.
eduucaldas added inline comments.
eduucaldas marked an inline comment as not done.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:829
+| | | | | `-::
+| | | | `-TypeSpecifier
+| | | |   |-S

Perhaps we shouldn't differ between specifiers as that is semantical information


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81168

Files:
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -692,6 +692,152 @@
 )txt"));
 }
 
+TEST_P(SyntaxTreeTest, UnqualifiedId) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test(int b) {
+  int a;
+  a = b;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-b
+  |   `-)
+  `-CompoundStatement
+|-{
+|-DeclarationStatement
+| |-SimpleDeclaration
+| | |-int
+| | `-SimpleDeclarator
+| |   `-a
+| `-;
+|-ExpressionStatement
+| |-BinaryOperatorExpression
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   `-a
+| | |-=
+| | `-IdExpression
+| |   `-UnqualifiedId
+| | `-b
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, QualifiedId) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+namespace a {
+  namespace b {
+struct S {
+  int i;
+  static void f(){}
+};
+  }
+}
+void test(int b) {
+  ::a::b::S::f();
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+|-NamespaceDefinition
+| |-namespace
+| |-a
+| |-{
+| |-NamespaceDefinition
+| | |-namespace
+| | |-b
+| | |-{
+| | |-SimpleDeclaration
+| | | |-struct
+| | | |-S
+| | | |-{
+| | | |-SimpleDeclaration
+| | | | |-int
+| | | | |-SimpleDeclarator
+| | | | | `-i
+| | | | `-;
+| | | |-SimpleDeclaration
+| | | | |-static
+| | | | |-void
+| | | | |-SimpleDeclarator
+| | | | | |-f
+| | | | | `-ParametersAndQualifiers
+| | | | |   |-(
+| | | | |   `-)
+| | | | `-CompoundStatement
+| | | |   |-{
+| | | |   `-}
+| | | |-}
+| | | `-;
+| | `-}
+| `-}
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-b
+  |   `-)
+  `-CompoundStatement
+|-{
+|-DeclarationStatement
+| |-SimpleDeclaration
+| | |-a
+| | |-::
+| | |-b
+| | |-::
+| | |-S
+| | `-SimpleDeclarator
+| |   `-UnknownExpression
+| | `-s
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | |-NameSpecifiers
+| | | | |-GlobalNamespaceSpecifier
+| | | | | `::
+| | | | |-NamespaceSpecifier
+| | | | | |-a
+| | | | | `-::
+| | | | |-NamespaceSpecifier
+| | | | | |-b
+| | | | | `-::
+| | | | `-TypeSpecifier
+| | | |   |-S
+| | | |   `-::
+| | | `-UnqualifiedId
+| | |   `-f
+| | |-(
+| | `-)
+| `-;
+`-}
+)txt"));
+}
+
 TEST_P(SyntaxTreeTest, CxxNullPtrLiteral) {
   if (!GetParam().isCXX11OrLater()) {
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62922: [WebAssembly] Implement "Reactor" mode

2020-06-04 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added inline comments.



Comment at: clang/test/Driver/wasm-toolchain.c:116
+// CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+

sunfish wrote:
> bjope wrote:
> > bjope wrote:
> > > This isn't working for me on redhat 7 servers. I get
> > > ```
> > >  "wasm-ld" "-L/lib" "/lib/crt1.o" ...
> > > ```
> > > No idea why I get the full patch to crt1.o. But it's not matching with 
> > > the FileCheck pattern.
> > /full patch/full path/
> Would you be able to test whether the following patch fixes it?
> 
> ```diff
> diff --git a/clang/test/Driver/wasm-toolchain.c 
> b/clang/test/Driver/wasm-toolchain.c
> index 8300a81614e..332e6048cc5 100644
> --- a/clang/test/Driver/wasm-toolchain.c
> +++ b/clang/test/Driver/wasm-toolchain.c
> @@ -110,11 +110,11 @@
> 
>  // Basic exec-model tests.
> 
> -// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
> -mexec-model=command 2>&1 \
> +// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
> --sysroot=%s/no-sysroot-there -mexec-model=command 2>&1 \
>  // RUN:   | FileCheck -check-prefix=CHECK-COMMAND %s
>  // CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
>  // CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" 
> "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
> 
> -// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
> -mexec-model=reactor 2>&1 \
> +// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
> --sysroot=%s/no-sysroot-there -mexec-model=reactor 2>&1 \
>  // RUN:   | FileCheck -check-prefix=CHECK-REACTOR %s
>  // CHECK-REACTOR: wasm-ld{{.*}}" {{.*}} "--entry" "_initialize" {{.*}}
> ```
Yes, that is working.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62922



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


[PATCH] D81168: Add support for id-expression in SyntaxTree

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a subscriber: gribozavr2.
eduucaldas marked an inline comment as done.
eduucaldas added inline comments.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:829
+| | | | | `-::
+| | | | `-TypeSpecifier
+| | | |   |-S

Perhaps we shouldn't differ between specifiers as that is semantical information


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81168



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


[clang] b5fc1de - Use libClangTesting in the unittest for AST matchers

2020-06-04 Thread Dmitri Gribenko via cfe-commits
Author: Dmitri Gribenko
Date: 2020-06-04T17:40:39+02:00
New Revision: b5fc1deb5ba1f3cd432ecb8b86c2536470463163

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

LOG: Use libClangTesting in the unittest for AST matchers

Summary:
The unittest for AST matchers has its own way to specify language
standards. I unified it with the shared infrastructure from
libClangTesting.

Reviewers: jdoerfert, hlopko

Reviewed By: hlopko

Subscribers: mgorny, sstefan1, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Testing/CommandLineArgs.h
clang/lib/Testing/CommandLineArgs.cpp
clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
clang/unittests/ASTMatchers/ASTMatchersTest.h
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
clang/unittests/ASTMatchers/CMakeLists.txt
clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
clang/unittests/Sema/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/Testing/CommandLineArgs.h 
b/clang/include/clang/Testing/CommandLineArgs.h
index 432a112b2e15..95979a2bfb80 100644
--- a/clang/include/clang/Testing/CommandLineArgs.h
+++ b/clang/include/clang/Testing/CommandLineArgs.h
@@ -13,6 +13,8 @@
 #ifndef LLVM_CLANG_TESTING_COMMANDLINEARGS_H
 #define LLVM_CLANG_TESTING_COMMANDLINEARGS_H
 
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/StringRef.h"
 #include 
 #include 
 
@@ -32,6 +34,8 @@ enum TestLanguage {
 
 std::vector getCommandLineArgsForTesting(TestLanguage Lang);
 
+StringRef getFilenameForTesting(TestLanguage Lang);
+
 } // end namespace clang
 
 #endif

diff  --git a/clang/lib/Testing/CommandLineArgs.cpp 
b/clang/lib/Testing/CommandLineArgs.cpp
index 1d12187494be..7375dbc6ee70 100644
--- a/clang/lib/Testing/CommandLineArgs.cpp
+++ b/clang/lib/Testing/CommandLineArgs.cpp
@@ -45,4 +45,25 @@ std::vector 
getCommandLineArgsForTesting(TestLanguage Lang) {
   return Args;
 }
 
+StringRef getFilenameForTesting(TestLanguage Lang) {
+  switch (Lang) {
+  case Lang_C89:
+  case Lang_C99:
+return "input.c";
+
+  case Lang_CXX03:
+  case Lang_CXX11:
+  case Lang_CXX14:
+  case Lang_CXX17:
+  case Lang_CXX20:
+return "input.cc";
+
+  case Lang_OpenCL:
+return "input.cl";
+
+  case Lang_OBJCXX:
+return "input.mm";
+  }
+}
+
 } // end namespace clang

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
index 2886481ea262..2354f45de409 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
@@ -212,18 +212,18 @@ TEST(Matcher, IsExpansionInMainFileMatcher) {
   M.push_back(std::make_pair("/other", "class X {};"));
   EXPECT_TRUE(matchesConditionally("#include \n",
recordDecl(isExpansionInMainFile()), false,
-   "-isystem/", M));
+   {"-isystem/"}, M));
 }
 
 TEST(Matcher, IsExpansionInSystemHeader) {
   FileContentMappings M;
   M.push_back(std::make_pair("/other", "class X {};"));
-  EXPECT_TRUE(matchesConditionally(
-  "#include \"other\"\n", recordDecl(isExpansionInSystemHeader()), true,
-  "-isystem/", M));
   EXPECT_TRUE(matchesConditionally("#include \"other\"\n",
recordDecl(isExpansionInSystemHeader()),
-   false, "-I/", M));
+   true, {"-isystem/"}, M));
+  EXPECT_TRUE(matchesConditionally("#include \"other\"\n",
+   recordDecl(isExpansionInSystemHeader()),
+   false, {"-I/"}, M));
   EXPECT_TRUE(notMatches("class X {};",
  recordDecl(isExpansionInSystemHeader(;
   EXPECT_TRUE(notMatches("", recordDecl(isExpansionInSystemHeader(;
@@ -238,13 +238,13 @@ TEST(Matcher, IsExpansionInFileMatching) {
   "#include \n"
   "class X {};",
   recordDecl(isExpansionInFileMatching("b.*"), hasName("B")), true,
-  "-isystem/", M));
+  {"-isystem/"}, M));
   EXPECT_TRUE(matchesConditionally(
   "#include \n"
   "#include \n"
   "class X {};",
   recordDecl(isExpansionInFileMatching("f.*"), hasName("X")), false,
-  "-isystem/", M));
+  {"-isystem/"}, M));
 }
 
 #endif // _WIN32

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 80eebf227a31..fa5c61eece29 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatcher

[PATCH] D81169: [clangd] Improve hover on arguments to function call

2020-06-04 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
adamcz added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

In cases like:

  foo(a, ^b);

We now additionally show the name and type of the parameter to foo that
corresponds that "b" is passed as.

The name should help with understanding what it's used for and type can
be useful to find out if call to foo() can mutate variable "b" or not
(i.e. if it is pass by value, reference, const reference, etc).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81169

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
@@ -696,6 +696,51 @@
  HI.Parameters->back().Name = "v";
  HI.AccessSpecifier = "public";
}},
+  {// Extra info for function call.
+   R"cpp(
+  void fun(int arg_a, int &arg_b) {};
+  void code() {
+int a = 1, b = 2;
+fun(a, [[^b]]);
+  }
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "b";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "int b = 2";
+ HI.LocalScope = "code::";
+ HI.Value = "2";
+ HI.Type = "int";
+ HI.CalleeArgInfo.emplace();
+ HI.CalleeArgInfo->Name = "arg_b";
+ HI.CalleeArgInfo->Type = "int &";
+   }},
+  {// Extra info for method call.
+   R"cpp(
+  class C {
+   public:
+void fun(int arg_a = 3, int arg_b = 4) {}
+  };
+  void code() {
+int a = 1, b = 2;
+C c;
+c.fun([[^a]], b);
+  }
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "a";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "int a = 1";
+ HI.LocalScope = "code::";
+ HI.Value = "1";
+ HI.Type = "int";
+ HI.CalleeArgInfo.emplace();
+ HI.CalleeArgInfo->Name = "arg_a";
+ HI.CalleeArgInfo->Type = "int";
+ HI.CalleeArgInfo->Default = "3";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
@@ -729,6 +774,7 @@
 EXPECT_EQ(H->Size, Expected.Size);
 EXPECT_EQ(H->Offset, Expected.Offset);
 EXPECT_EQ(H->AccessSpecifier, Expected.AccessSpecifier);
+EXPECT_EQ(H->CalleeArgInfo, Expected.CalleeArgInfo);
   }
 }
 
@@ -2022,6 +2068,29 @@
 
 // In namespace ns1
 private: union foo {})",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Variable;
+HI.Name = "foo";
+HI.Definition = "int foo = 3";
+HI.LocalScope = "test::Bar::";
+HI.Value = "3";
+HI.Type = "int";
+HI.CalleeArgInfo.emplace();
+HI.CalleeArgInfo->Name = "arg_a";
+HI.CalleeArgInfo->Type = "int";
+HI.CalleeArgInfo->Default = "7";
+  },
+  R"(variable foo
+
+Type: int
+Value = 3
+
+// In test::Bar
+int foo = 3
+
+Passed as int arg_a = 7)",
   }};
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/Hover.h
===
--- clang-tools-extra/clangd/Hover.h
+++ clang-tools-extra/clangd/Hover.h
@@ -77,6 +77,9 @@
   llvm::Optional Size;
   /// Contains the offset of fields within the enclosing class.
   llvm::Optional Offset;
+  // Set when symbol is inside function call. Contains information extracted
+  // from the callee definition about the argument this is passed as.
+  llvm::Optional CalleeArgInfo;
 
   /// 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
@@ -289,6 +289,26 @@
 : PVD->getDefaultArg();
 }
 
+void fillParam(const ParmVarDecl *PVD, HoverInfo::Param &Out,
+   const PrintingPolicy &Policy) {
+  if (!PVD->getType().isNull()) {
+Out.Type = printType(PVD->getType(), Policy);
+  } else {
+std::string Param;
+llvm::raw_string_ostream OS(Param);
+PVD->dump(OS);
+OS.flush();
+elog("Got param with null type: {0}", Param);
+  }
+  if (!PVD->getName().empty())
+Out.Name = PVD->getNameAsString();
+  if (const Expr *DefArg = getDefaultArg(PVD)) {
+Out.Default.emplace();
+llvm::raw_string_ostream OS(*Out.Default);
+DefArg->printPretty(OS, nullptr, Policy);
+  }
+}
+
 // Populates Type, ReturnType, and Parameters f

[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-06-04 Thread Simon Moll via Phabricator via cfe-commits
simoll updated this revision to Diff 268488.
simoll added a comment.

- Improved documentation for the size argument of vector_size.
- Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/vector.cpp

Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -331,8 +331,7 @@
 typedef __attribute__((ext_vector_type(4))) int vi4;
 const int &reference_to_vec_element = vi4(1).x;
 
-// PR12649
-typedef bool bad __attribute__((__vector_size__(16)));  // expected-error {{invalid vector element type 'bool'}}
+typedef bool good __attribute__((__vector_size__(16)));
 
 namespace Templates {
 template 
@@ -350,9 +349,7 @@
 void Init() {
   const TemplateVectorType::type Works = {};
   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 BoolWorks = {};
   // 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 = {};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2464,10 +2464,10 @@
 
 QualType Sema::BuildVectorType(QualType CurType, Expr *SizeExpr,
SourceLocation AttrLoc) {
-  // The base type must be integer (not Boolean or enumeration) or float, and
+  // The base type must be boolean or integer (not enumeration) or float, and
   // can't already be a vector.
   if (!CurType->isDependentType() &&
-  (!CurType->isBuiltinType() || CurType->isBooleanType() ||
+  (!CurType->isBuiltinType() ||
(!CurType->isIntegerType() && !CurType->isRealFloatingType( {
 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << CurType;
 return QualType();
@@ -2496,8 +2496,14 @@
 << SizeExpr->getSourceRange() << "vector";
 return QualType();
   }
-  uint64_t VectorSizeBits = VecSize.getZExtValue() * 8;
-  unsigned TypeSize = static_cast(Context.getTypeSize(CurType));
+
+  uint64_t VectorSizeBits =
+  CurType->isBooleanType()
+  ? VecSize.getZExtValue()
+  : VecSize.getZExtValue() * 8; // FIXME "bitsof(CharUnit)"
+  unsigned TypeSize = CurType->isBooleanType()
+  ? 1
+  : static_cast(Context.getTypeSize(CurType));
 
   if (VectorSizeBits == 0) {
 Diag(AttrLoc, diag::err_attribute_zero_size)
@@ -7549,13 +7555,13 @@
   T = Context.getAdjustedType(T, Wrapped);
 }
 
-/// HandleVectorSizeAttribute - this attribute is only applicable to integral
-/// and float scalars, although arrays, pointers, and function return values are
-/// allowed in conjunction with this construct. Aggregates with this attribute
-/// are invalid, even if they are of the same size as a corresponding scalar.
-/// The raw attribute should contain precisely 1 argument, the vector size for
-/// the variable, measured in bytes. If curType and rawAttr are well formed,
-/// this routine will return a new vector type.
+/// HandleVectorSizeAttribute - this attribute is only applicable to boolean,
+/// integral and float scalars, although arrays, pointers, and function return
+/// values are allowed in conjunction with this construct. Aggregates with this
+/// attribute are invalid, even if they are of the same size as a corresponding
+/// scalar. The raw attribute should contain precisely 1 argument, the vector
+/// size for the variable, measured in bytes. If curType and rawAttr are well
+/// formed, this routine will return a new vector type.
 static void HandleVectorSizeAttr(QualType &CurType, const ParsedAttr &Attr,
  Sema &S) {
   // Check the attribute arguments.
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -5947,7 +5947,8 @@
   } else if (LHSVT || RHSVT) {
 ResultType = CheckVectorOperands(
 LHS, RHS, Q

[PATCH] D80804: [AMDGPU] Introduce Clang builtins to be mapped to AMDGCN atomic inc/dec intrinsics

2020-06-04 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsAMDGPU.def:62-63
 BUILTIN(__builtin_amdgcn_fence, "vUicC*", "n")
+BUILTIN(__builtin_amdgcn_atomic_inc, "iiD*iUicC*", "n")
+BUILTIN(__builtin_amdgcn_atomic_dec, "iiD*iUicC*", "n")
 

My main concern is we should probably have both 32 and 64-bit variants


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80804



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


[PATCH] D80887: [clang-tidy] ignore builtin varargs from pro-type-vararg-check

2020-06-04 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, thank you for the fixes!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80887



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


[PATCH] D81150: Use libClangTesting in the unittest for AST matchers

2020-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb5fc1deb5ba1: Use libClangTesting in the unittest for AST 
matchers (authored by gribozavr).

Changed prior to commit:
  https://reviews.llvm.org/D81150?vs=268440&id=268495#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81150

Files:
  clang/include/clang/Testing/CommandLineArgs.h
  clang/lib/Testing/CommandLineArgs.cpp
  clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTest.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
  clang/unittests/ASTMatchers/CMakeLists.txt
  clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
  clang/unittests/Sema/CMakeLists.txt

Index: clang/unittests/Sema/CMakeLists.txt
===
--- clang/unittests/Sema/CMakeLists.txt
+++ clang/unittests/Sema/CMakeLists.txt
@@ -18,6 +18,7 @@
   clangParse
   clangSema
   clangSerialization
+  clangTesting
   clangTooling
   )
 
Index: clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
===
--- clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
+++ clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
@@ -17,5 +17,6 @@
   clangDynamicASTMatchers
   clangFrontend
   clangSerialization
+  clangTesting
   clangTooling
   )
Index: clang/unittests/ASTMatchers/CMakeLists.txt
===
--- clang/unittests/ASTMatchers/CMakeLists.txt
+++ clang/unittests/ASTMatchers/CMakeLists.txt
@@ -27,6 +27,7 @@
   clangBasic
   clangFrontend
   clangSerialization
+  clangTesting
   clangTooling
   )
 
Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -951,13 +951,13 @@
   "template\n"
   "int Struct::field = 123;\n";
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("T")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("T")), langCxx14OrLater()));
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("T2")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("T2")), langCxx14OrLater()));
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("U")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("U")), langCxx14OrLater()));
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("U2")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("U2")), langCxx14OrLater()));
 }
 
 TEST(TemplateTypeParmDecl, ClassTemplatePartialSpecializationDecl) {
@@ -1487,18 +1487,18 @@
 TEST(Member, MatchesMemberAllocationFunction) {
   // Fails in C++11 mode
   EXPECT_TRUE(matchesConditionally(
-"namespace std { typedef typeof(sizeof(int)) size_t; }"
+  "namespace std { typedef typeof(sizeof(int)) size_t; }"
   "class X { void *operator new(std::size_t); };",
-cxxMethodDecl(ofClass(hasName("X"))), true, "-std=gnu++98"));
+  cxxMethodDecl(ofClass(hasName("X"))), true, {"-std=gnu++03"}));
 
   EXPECT_TRUE(matches("class X { void operator delete(void*); };",
   cxxMethodDecl(ofClass(hasName("X");
 
   // Fails in C++11 mode
   EXPECT_TRUE(matchesConditionally(
-"namespace std { typedef typeof(sizeof(int)) size_t; }"
+  "namespace std { typedef typeof(sizeof(int)) size_t; }"
   "class X { void operator delete[](void*, std::size_t); };",
-cxxMethodDecl(ofClass(hasName("X"))), true, "-std=gnu++98"));
+  cxxMethodDecl(ofClass(hasName("X"))), true, {"-std=gnu++03"}));
 }
 
 TEST(HasDestinationType, MatchesSimpleCase) {
@@ -1542,7 +1542,7 @@
   cxxOperatorCallExpr(hasArgument(
   1, callExpr(hasArgument(
  0, ignoringElidableConstructorCall(callExpr()),
-  LanguageMode::Cxx11OrLater));
+  langCxx11OrLater()));
   EXPECT_TRUE(
   matches("struct H {};"
   "template H B(T A);"
@@ -1553,7 +1553,7 @@
   cxxOperatorCallExpr(hasArgument(
   1, callExpr(hasArgument(0, ignoringElidableConstructorCall(
  integerLiteral()),
-  LanguageMode::Cxx11OrLater));
+  langCxx11OrLater()));
   EXPECT_TRUE(matches(
   "struct H {};"
   "H G();"
@@ -1563,7 +1563,7 @@
   varDecl(hasInitializer(anyOf(
   ignoringElidableConstructorCall(callExpr()),
   exprWithCleanups(has(ignoringElidableConstructorCall(callExpr())),
-  LanguageMode::Cxx11OrLate

[PATCH] D80735: [OpenMP][NFC] Reuse OMPIRBuilder `struct ident_t` handling in Clang

2020-06-04 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

Here's one of the stack traces. Calling `InternalOMPBuilder.initialize()` is 
what triggers it to start failing, which is confusing because all that function 
does is initialize the named types from OMPConstants, which should be working 
or else the old solution wouldn't work. Unless the compiler is just straight up 
optimizing out the Irbuilder without the initialize call which I find highly 
unlikely.

   #0 0x7fc6b112701a llvm::sys::PrintStackTrace(llvm::raw_ostream&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libLLVMSupport.so.11git+0x1b301a)
   #1 0x7fc6b1124e54 llvm::sys::RunSignalHandlers() 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libLLVMSupport.so.11git+0x1b0e54)
   #2 0x7fc6b1124f98 SignalHandler(int) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libLLVMSupport.so.11git+0x1b0f98)
   #3 0x7fc6b517f800 __restore_rt (/usr/lib/libpthread.so.0+0x14800)
   #4 0x7fc6b0aa0ce5 raise (/usr/lib/libc.so.6+0x3bce5)
   #5 0x7fc6b0a8a857 abort (/usr/lib/libc.so.6+0x25857)
   #6 0x7fc6b0a8a727 _nl_load_domain.cold (/usr/lib/libc.so.6+0x25727)
   #7 0x7fc6b0a99426 (/usr/lib/libc.so.6+0x34426)
   #8 0x7fc6b148c223 llvm::CallInst::init(llvm::FunctionType*, 
llvm::Value*, llvm::ArrayRef, 
llvm::ArrayRef >, llvm::Twine const&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libLLVMCore.so.11git+0x1ce223)
   #9 0x7fc6b41dc007 llvm::IRBuilderBase::CreateCall(llvm::FunctionType*, 
llvm::Value*, llvm::ArrayRef, 
llvm::ArrayRef >, llvm::Twine const&, 
llvm::MDNode*) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x1c3007)
  #10 0x7fc6b41eb3d6 
clang::CodeGen::CodeGenFunction::EmitRuntimeCall(llvm::FunctionCallee, 
llvm::ArrayRef, llvm::Twine const&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x1d23d6)
  #11 0x7fc6b43acbf0 
clang::CodeGen::CGOpenMPRuntime::emitTaskInit(clang::CodeGen::CodeGenFunction&, 
clang::SourceLocation, clang::OMPExecutableDirective const&, llvm::Function*, 
clang::QualType, clang::CodeGen::Address, clang::CodeGen::OMPTaskDataTy const&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x393bf0)
  #12 0x7fc6b43afb67 
clang::CodeGen::CGOpenMPRuntime::emitTaskCall(clang::CodeGen::CodeGenFunction&, 
clang::SourceLocation, clang::OMPExecutableDirective const&, llvm::Function*, 
clang::QualType, clang::CodeGen::Address, clang::Expr const*, 
clang::CodeGen::OMPTaskDataTy const&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x396b67)
  #13 0x7fc6b43ff10d void llvm::function_ref::callback_fn(long, clang::CodeGen::CodeGenFunction&, 
llvm::Function*, clang::CodeGen::OMPTaskDataTy const&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3e610d)
  #14 0x7fc6b442facb 
clang::CodeGen::CodeGenFunction::EmitOMPTaskBasedDirective(clang::OMPExecutableDirective
 const&, llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&, 
llvm::function_ref const&, clang::CodeGen::OMPTaskDataTy&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x416acb)
  #15 0x7fc6b443034b 
clang::CodeGen::CodeGenFunction::EmitOMPTaskDirective(clang::OMPTaskDirective 
const&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x41734b)
  #16 0x7fc6b43f9b73 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt 
const*, llvm::ArrayRef) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3e0b73)
  #17 0x7fc6b43f9fd4 
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
 const&, bool, clang::CodeGen::AggValueSlot) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3e0fd4)
  #18 0x7fc6b43fa3cf 
clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&, 
bool, clang::CodeGen::AggValueSlot) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3e13cf)
  #19 0x7fc6b43fde5f 
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3e4e5f)
  #20 0x7fc6b43f97f2 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt 
const*, llvm::ArrayRef) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3e07f2)
  #21 0x7fc6b4402811 emitBody(clang::CodeGen::CodeGenFunction&, clang::Stmt 
const*, clang::Stmt const*, int, int) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3e9811)
  #22 0x7fc6b440ce23 
clang::CodeGen::CodeGenFunction::EmitOMPLoopBody(clang::OMPLoopDirective 
const&, clang::CodeGen::CodeGenFunction::JumpDest) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3f3e23)
  #23 0x7fc6b440d180 void llvm::function_ref::callback_fn (clang::CodeGen::CodeGenF

  1   2   3   >