[PATCH] D98459: [CodeCompletion] Don't track preferred types if code completion is disabled.

2021-03-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 330163.
sammccall added a comment.

Omit narrower, now-redundant check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98459

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseInit.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaCodeComplete.cpp

Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -381,6 +381,8 @@
 } // namespace
 
 void PreferredTypeBuilder::enterReturn(Sema &S, SourceLocation Tok) {
+  if (!Enabled)
+return;
   if (isa(S.CurContext)) {
 if (sema::BlockScopeInfo *BSI = S.getCurBlock()) {
   ComputeType = nullptr;
@@ -399,6 +401,8 @@
 }
 
 void PreferredTypeBuilder::enterVariableInit(SourceLocation Tok, Decl *D) {
+  if (!Enabled)
+return;
   auto *VD = llvm::dyn_cast_or_null(D);
   ComputeType = nullptr;
   Type = VD ? VD->getType() : QualType();
@@ -410,6 +414,8 @@
 void PreferredTypeBuilder::enterDesignatedInitializer(SourceLocation Tok,
   QualType BaseType,
   const Designation &D) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = getDesignatedType(BaseType, D);
   ExpectedLoc = Tok;
@@ -417,6 +423,8 @@
 
 void PreferredTypeBuilder::enterFunctionArgument(
 SourceLocation Tok, llvm::function_ref ComputeType) {
+  if (!Enabled)
+return;
   this->ComputeType = ComputeType;
   Type = QualType();
   ExpectedLoc = Tok;
@@ -424,6 +432,8 @@
 
 void PreferredTypeBuilder::enterParenExpr(SourceLocation Tok,
   SourceLocation LParLoc) {
+  if (!Enabled)
+return;
   // expected type for parenthesized expression does not change.
   if (ExpectedLoc == LParLoc)
 ExpectedLoc = Tok;
@@ -541,6 +551,8 @@
 
 void PreferredTypeBuilder::enterBinary(Sema &S, SourceLocation Tok, Expr *LHS,
tok::TokenKind Op) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = getPreferredTypeOfBinaryRHS(S, LHS, Op);
   ExpectedLoc = Tok;
@@ -548,7 +560,7 @@
 
 void PreferredTypeBuilder::enterMemAccess(Sema &S, SourceLocation Tok,
   Expr *Base) {
-  if (!Base)
+  if (!Enabled || !Base)
 return;
   // Do we have expected type for Base?
   if (ExpectedLoc != Base->getBeginLoc())
@@ -561,6 +573,8 @@
 void PreferredTypeBuilder::enterUnary(Sema &S, SourceLocation Tok,
   tok::TokenKind OpKind,
   SourceLocation OpLoc) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = getPreferredTypeOfUnaryArg(S, this->get(OpLoc), OpKind);
   ExpectedLoc = Tok;
@@ -568,6 +582,8 @@
 
 void PreferredTypeBuilder::enterSubscript(Sema &S, SourceLocation Tok,
   Expr *LHS) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = S.getASTContext().IntTy;
   ExpectedLoc = Tok;
@@ -575,12 +591,16 @@
 
 void PreferredTypeBuilder::enterTypeCast(SourceLocation Tok,
  QualType CastType) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = !CastType.isNull() ? CastType.getCanonicalType() : QualType();
   ExpectedLoc = Tok;
 }
 
 void PreferredTypeBuilder::enterCondition(Sema &S, SourceLocation Tok) {
+  if (!Enabled)
+return;
   ComputeType = nullptr;
   Type = S.getASTContext().BoolTy;
   ExpectedLoc = Tok;
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -49,10 +49,10 @@
 }
 
 Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies)
-  : PP(pp), Actions(actions), Diags(PP.getDiagnostics()),
-GreaterThanIsOperator(true), ColonIsSacred(false),
-InMessageExpression(false), TemplateParameterDepth(0),
-ParsingInObjCContainer(false) {
+: PP(pp), PreferredType(pp.isCodeCompletionEnabled()), Actions(actions),
+  Diags(PP.getDiagnostics()), GreaterThanIsOperator(true),
+  ColonIsSacred(false), InMessageExpression(false),
+  TemplateParameterDepth(0), ParsingInObjCContainer(false) {
   SkipFunctionBodies = pp.isCodeCompletionEnabled() || skipFunctionBodies;
   Tok.startToken();
   Tok.setKind(tok::eof);
Index: clang/lib/Parse/ParseInit.cpp
===
--- clang/lib/Parse/ParseInit.cpp
+++ clang/lib/Parse/ParseInit.cpp
@@ -160,9 +160,6 @@
 /// \p CodeCompleteCB is called with Designation parsed so far.
 ExprResult Parser::ParseInitializerWithPotentialDesignator(
 DesignatorCompletionInfo DesignatorCompletion) {
-  if (!getPreprocessor().isCodeComplet

[PATCH] D98483: [clang] Mark re-injected tokens appropriately during pragma handling

2021-03-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added a subscriber: usaxena95.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang.

This hides such tokens from TokenWatcher, preventing crashes in clients
trying to match spelled and expanded tokens.

Fixes https://github.com/clangd/clangd/issues/712


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98483

Files:
  clang/lib/Parse/ParsePragma.cpp


Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -2607,6 +2607,7 @@
   Token EoF, AnnotTok;
   EoF.startToken();
   EoF.setKind(tok::eof);
+  EoF.setFlag(clang::Token::IsReinjected);
   AnnotTok.startToken();
   AnnotTok.setKind(tok::annot_pragma_ms_pragma);
   AnnotTok.setLocation(Tok.getLocation());
@@ -2614,6 +2615,7 @@
   SmallVector TokenVector;
   // Suck up all of the tokens before the eod.
   for (; Tok.isNot(tok::eod); PP.Lex(Tok)) {
+Tok.setFlag(clang::Token::IsReinjected);
 TokenVector.push_back(Tok);
 AnnotTok.setAnnotationEndLoc(Tok.getLocation());
   }
@@ -3159,6 +3161,7 @@
 break;
 }
 
+Tok.setFlag(clang::Token::IsReinjected);
 ValueList.push_back(Tok);
 PP.Lex(Tok);
   }
@@ -3174,6 +3177,7 @@
 
   Token EOFTok;
   EOFTok.startToken();
+  EOFTok.setFlag(clang::Token::IsReinjected);
   EOFTok.setKind(tok::eof);
   EOFTok.setLocation(Tok.getLocation());
   ValueList.push_back(EOFTok); // Terminates expression for parsing.
@@ -3612,6 +3616,7 @@
   break;
   }
 
+  Tok.setFlag(clang::Token::IsReinjected);
   AttributeTokens.push_back(Tok);
   PP.Lex(Tok);
 }
@@ -3632,6 +3637,7 @@
 EOFTok.startToken();
 EOFTok.setKind(tok::eof);
 EOFTok.setLocation(EndLoc);
+EOFTok.setFlag(clang::Token::IsReinjected);
 AttributeTokens.push_back(EOFTok);
 
 Info->Tokens =


Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -2607,6 +2607,7 @@
   Token EoF, AnnotTok;
   EoF.startToken();
   EoF.setKind(tok::eof);
+  EoF.setFlag(clang::Token::IsReinjected);
   AnnotTok.startToken();
   AnnotTok.setKind(tok::annot_pragma_ms_pragma);
   AnnotTok.setLocation(Tok.getLocation());
@@ -2614,6 +2615,7 @@
   SmallVector TokenVector;
   // Suck up all of the tokens before the eod.
   for (; Tok.isNot(tok::eod); PP.Lex(Tok)) {
+Tok.setFlag(clang::Token::IsReinjected);
 TokenVector.push_back(Tok);
 AnnotTok.setAnnotationEndLoc(Tok.getLocation());
   }
@@ -3159,6 +3161,7 @@
 break;
 }
 
+Tok.setFlag(clang::Token::IsReinjected);
 ValueList.push_back(Tok);
 PP.Lex(Tok);
   }
@@ -3174,6 +3177,7 @@
 
   Token EOFTok;
   EOFTok.startToken();
+  EOFTok.setFlag(clang::Token::IsReinjected);
   EOFTok.setKind(tok::eof);
   EOFTok.setLocation(Tok.getLocation());
   ValueList.push_back(EOFTok); // Terminates expression for parsing.
@@ -3612,6 +3616,7 @@
   break;
   }
 
+  Tok.setFlag(clang::Token::IsReinjected);
   AttributeTokens.push_back(Tok);
   PP.Lex(Tok);
 }
@@ -3632,6 +3637,7 @@
 EOFTok.startToken();
 EOFTok.setKind(tok::eof);
 EOFTok.setLocation(EndLoc);
+EOFTok.setFlag(clang::Token::IsReinjected);
 AttributeTokens.push_back(EOFTok);
 
 Info->Tokens =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 840643b - [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Anton Zabaznov via cfe-commits

Author: Anton Zabaznov
Date: 2021-03-12T11:43:53+03:00
New Revision: 840643bbe1d25c88b0832f93c8bf3b2c451c7b14

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

LOG: [OpenCL] Refactor diagnostic for OpenCL extension/feature

There is no need to check for enabled pragma for core or optional core features,
thus this check is removed

Reviewed By: Anastasia

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenCLOptions.h
clang/lib/Basic/OpenCLOptions.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParsePragma.cpp
clang/lib/Sema/DeclSpec.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Parser/opencl-atomics-cl20.cl
clang/test/SemaOpenCL/access-qualifier.cl
clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
clang/test/SemaOpenCL/extension-begin.cl
clang/test/SemaOpenCL/extensions.cl
clang/test/SemaOpenCL/intel-subgroup-avc-ext-types.cl

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 5f3389f96397..d4578c5263a0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9923,7 +9923,7 @@ def warn_opencl_attr_deprecated_ignored : Warning <
 def err_opencl_variadic_function : Error<
   "invalid prototype, variadic arguments are not allowed in OpenCL">;
 def err_opencl_requires_extension : Error<
-  "use of %select{type|declaration}0 %1 requires %2 extension to be enabled">;
+  "use of %select{type|declaration}0 %1 requires %2 support">;
 def warn_opencl_generic_address_space_arg : Warning<
   "passing non-generic address space pointer to %0"
   " may cause dynamic conversion affecting performance">,

diff  --git a/clang/include/clang/Basic/OpenCLOptions.h 
b/clang/include/clang/Basic/OpenCLOptions.h
index 0f7cffb262c0..9ad3a5681054 100644
--- a/clang/include/clang/Basic/OpenCLOptions.h
+++ b/clang/include/clang/Basic/OpenCLOptions.h
@@ -112,7 +112,10 @@ class OpenCLOptions {
 
   bool isKnown(llvm::StringRef Ext) const;
 
-  bool isEnabled(llvm::StringRef Ext) const;
+  // For core or optional core feature check that it is supported
+  // by a target, for any other option (extension) check that it is
+  // enabled via pragma
+  bool isAvailableOption(llvm::StringRef Ext, const LangOptions &LO) const;
 
   bool isWithPragma(llvm::StringRef Ext) const;
 
@@ -160,15 +163,15 @@ class OpenCLOptions {
   // Disable all extensions
   void disableAll();
 
-  // Enable supported core and optional core features
-  void enableSupportedCore(const LangOptions &LO);
-
   friend class ASTWriter;
   friend class ASTReader;
 
   using OpenCLOptionInfoMap = llvm::StringMap;
 
 private:
+  // Option is enabled via pragma
+  bool isEnabled(llvm::StringRef Ext) const;
+
   OpenCLOptionInfoMap OptMap;
 };
 

diff  --git a/clang/lib/Basic/OpenCLOptions.cpp 
b/clang/lib/Basic/OpenCLOptions.cpp
index 2ca1ee064729..78b7493855e6 100644
--- a/clang/lib/Basic/OpenCLOptions.cpp
+++ b/clang/lib/Basic/OpenCLOptions.cpp
@@ -14,9 +14,21 @@ bool OpenCLOptions::isKnown(llvm::StringRef Ext) const {
   return OptMap.find(Ext) != OptMap.end();
 }
 
+bool OpenCLOptions::isAvailableOption(llvm::StringRef Ext,
+  const LangOptions &LO) const {
+  if (!isKnown(Ext))
+return false;
+
+  auto &OptInfo = OptMap.find(Ext)->getValue();
+  if (OptInfo.isCoreIn(LO) || OptInfo.isOptionalCoreIn(LO))
+return isSupported(Ext, LO);
+
+  return isEnabled(Ext);
+}
+
 bool OpenCLOptions::isEnabled(llvm::StringRef Ext) const {
-  auto E = OptMap.find(Ext);
-  return E != OptMap.end() && E->second.Enabled;
+  auto I = OptMap.find(Ext);
+  return I != OptMap.end() && I->getValue().Enabled;
 }
 
 bool OpenCLOptions::isWithPragma(llvm::StringRef Ext) const {
@@ -26,32 +38,23 @@ bool OpenCLOptions::isWithPragma(llvm::StringRef Ext) const 
{
 
 bool OpenCLOptions::isSupported(llvm::StringRef Ext,
 const LangOptions &LO) const {
-  auto E = OptMap.find(Ext);
-  if (E == OptMap.end()) {
-return false;
-  }
-  auto I = OptMap.find(Ext)->getValue();
-  return I.Supported && I.isAvailableIn(LO);
+  auto I = OptMap.find(Ext);
+  return I != OptMap.end() && I->getValue().Supported &&
+ I->getValue().isAvailableIn(LO);
 }
 
 bool OpenCLOptions::isSupportedCore(llvm::StringRef Ext,
 const LangOptions &LO) const {
-  auto E = O

[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Anton Zabaznov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG840643bbe1d2: [OpenCL] Refactor diagnostic for OpenCL 
extension/feature (authored by azabaznov).

Changed prior to commit:
  https://reviews.llvm.org/D97058?vs=329560&id=330173#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OpenCLOptions.h
  clang/lib/Basic/OpenCLOptions.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Parser/opencl-atomics-cl20.cl
  clang/test/SemaOpenCL/access-qualifier.cl
  clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
  clang/test/SemaOpenCL/extension-begin.cl
  clang/test/SemaOpenCL/extensions.cl
  clang/test/SemaOpenCL/intel-subgroup-avc-ext-types.cl

Index: clang/test/SemaOpenCL/intel-subgroup-avc-ext-types.cl
===
--- clang/test/SemaOpenCL/intel-subgroup-avc-ext-types.cl
+++ clang/test/SemaOpenCL/intel-subgroup-avc-ext-types.cl
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -cl-ext=+cl_intel_device_side_avc_motion_estimation -fsyntax-only -verify %s
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -cl-ext=+cl_intel_device_side_avc_motion_estimation -fsyntax-only -verify -DEXT %s
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -cl-ext=-cl_intel_device_side_avc_motion_estimation -fsyntax-only -verify  %s
 
+#ifdef cl_intel_device_side_avc_motion_estimation
 #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : enable
+#endif
 
 // All intel_sub_group_avc_* types can only be used as argument or return value
 // of built-in functions defined in the extension.
@@ -16,55 +19,77 @@
 // negative test cases for initializers
 void foo(char c, float f, void* v, struct st ss) {
   intel_sub_group_avc_mce_payload_t payload_mce = 0; // No zero initializer for mce types
-  // expected-error@-1 {{initializing '__private intel_sub_group_avc_mce_payload_t' with an expression of incompatible type 'int'}}
   intel_sub_group_avc_ime_payload_t payload_ime = 1; // No literal initializer for *payload_t types
-  // expected-error@-1 {{initializing '__private intel_sub_group_avc_ime_payload_t' with an expression of incompatible type 'int'}}
   intel_sub_group_avc_ref_payload_t payload_ref = f;
-  // expected-error@-1 {{initializing '__private intel_sub_group_avc_ref_payload_t' with an expression of incompatible type '__private float'}}
   intel_sub_group_avc_sic_payload_t payload_sic = ss;
-  // expected-error@-1 {{initializing '__private intel_sub_group_avc_sic_payload_t' with an expression of incompatible type '__private struct st'}}
-
   intel_sub_group_avc_mce_result_t result_mce = 0; // No zero initializer for mce types
-  // expected-error@-1 {{initializing '__private intel_sub_group_avc_mce_result_t' with an expression of incompatible type 'int'}}
   intel_sub_group_avc_ime_result_t result_ime = 1; // No literal initializer for *result_t types
-  // expected-error@-1 {{initializing '__private intel_sub_group_avc_ime_result_t' with an expression of incompatible type 'int'}}
   intel_sub_group_avc_ref_result_t result_ref = f;
-  // expected-error@-1 {{initializing '__private intel_sub_group_avc_ref_result_t' with an expression of incompatible type '__private float'}}
   intel_sub_group_avc_sic_result_t result_sic = ss;
-  // expected-error@-1 {{initializing '__private intel_sub_group_avc_sic_result_t' with an expression of incompatible type '__private struct st'}}
-
   intel_sub_group_avc_ime_result_single_reference_streamout_t sstreamout = v;
-  // expected-error@-1 {{initializing '__private intel_sub_group_avc_ime_result_single_reference_streamout_t' with an expression of incompatible type '__private void *__private'}}
-
   intel_sub_group_avc_ime_result_dual_reference_streamout_t dstreamin_list = {0x0, 0x1};
-  // expected-warning@-1 {{excess elements in struct initializer}}
   intel_sub_group_avc_ime_dual_reference_streamin_t dstreamin_list2 = {};
-  // expected-error@-1 {{scalar initializer cannot be empty}}
   intel_sub_group_avc_ime_single_reference_streamin_t dstreamin_list3 = {c};
-  // expected-error@-1 {{initializing '__private intel_sub_group_avc_ime_single_reference_streamin_t' with an expression of incompatible type '__private char'}}
   intel_sub_group_avc_ime_dual_reference_streamin_t dstreamin_list4 = {1};
-  // expected-error@-1 {{initializing '__private intel_sub_group_avc_ime_dual_reference_streamin_t' with

[PATCH] D98459: [CodeCompletion] Don't track preferred types if code completion is disabled.

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

thanks, lgtm!




Comment at: clang/include/clang/Parse/Parser.h:944
   public:
-explicit TentativeParsingAction(Parser& p) : P(p) {
-  PrevPreferredType = P.PreferredType;
+explicit TentativeParsingAction(Parser &p)
+: P(p), PrevPreferredType(P.PreferredType) {

while here `s/p/P/`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98459

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


[clang] 194861f - [Matrix] Add missing newline to appease sphinx.

2021-03-12 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2021-03-12T09:33:36Z
New Revision: 194861fa1bdfa852f18cb5690509ac0f05219ba1

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

LOG: [Matrix] Add missing newline to appease sphinx.

Added: 


Modified: 
clang/docs/MatrixTypes.rst

Removed: 




diff  --git a/clang/docs/MatrixTypes.rst b/clang/docs/MatrixTypes.rst
index f0abede1ca3d..616c88f8a474 100644
--- a/clang/docs/MatrixTypes.rst
+++ b/clang/docs/MatrixTypes.rst
@@ -128,6 +128,7 @@ You can test for the availability of this feature with
 ``__has_extension(matrix_types_scalar_division)``.
 
 For the expression ``M1 BIN_OP M2`` where
+
 * ``BIN_OP`` is one of ``+`` or ``-``, one of ``M1`` and ``M2`` is of matrix
   type, and the other is of matrix type or real type; or
 * ``BIN_OP`` is ``*``, one of ``M1`` and ``M2`` is of matrix type, and the



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


[PATCH] D97085: [OpenMP] libomp: implement OpenMP 5.1 inoutset task dependence type

2021-03-12 Thread Joachim Protze via Phabricator via cfe-commits
protze.joachim added inline comments.



Comment at: openmp/runtime/src/kmp_taskdeps.cpp:344-346
+// link node as successor of all nodes in the prev_set if any
+npredecessors +=
+__kmp_depnode_link_successor(gtid, thread, task, node, prev_set);

If I understand this code right, this has O(n^2) complexity for two sets of 
size n?

Consider:
```
for (int i=0; ihttps://reviews.llvm.org/D97085/new/

https://reviews.llvm.org/D97085

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


[PATCH] D98483: [clang] Mark re-injected tokens appropriately during pragma handling

2021-03-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 330184.
kadircet added a comment.

- Add test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98483

Files:
  clang/lib/Parse/ParsePragma.cpp
  clang/unittests/Tooling/Syntax/TokensTest.cpp


Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -1037,4 +1037,13 @@
   IsEmpty());
 }
 
+TEST_F(TokenCollectorTest, Pragmas) {
+  // Tokens coming from concatenations.
+  recordTokens(R"cpp(
+void foo() {
+  #pragma unroll 4
+  for(int i=0;i<4;++i);
+}
+  )cpp");
+}
 } // namespace
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -2607,6 +2607,7 @@
   Token EoF, AnnotTok;
   EoF.startToken();
   EoF.setKind(tok::eof);
+  EoF.setFlag(clang::Token::IsReinjected);
   AnnotTok.startToken();
   AnnotTok.setKind(tok::annot_pragma_ms_pragma);
   AnnotTok.setLocation(Tok.getLocation());
@@ -2614,6 +2615,7 @@
   SmallVector TokenVector;
   // Suck up all of the tokens before the eod.
   for (; Tok.isNot(tok::eod); PP.Lex(Tok)) {
+Tok.setFlag(clang::Token::IsReinjected);
 TokenVector.push_back(Tok);
 AnnotTok.setAnnotationEndLoc(Tok.getLocation());
   }
@@ -3159,6 +3161,7 @@
 break;
 }
 
+Tok.setFlag(clang::Token::IsReinjected);
 ValueList.push_back(Tok);
 PP.Lex(Tok);
   }
@@ -3174,6 +3177,7 @@
 
   Token EOFTok;
   EOFTok.startToken();
+  EOFTok.setFlag(clang::Token::IsReinjected);
   EOFTok.setKind(tok::eof);
   EOFTok.setLocation(Tok.getLocation());
   ValueList.push_back(EOFTok); // Terminates expression for parsing.
@@ -3612,6 +3616,7 @@
   break;
   }
 
+  Tok.setFlag(clang::Token::IsReinjected);
   AttributeTokens.push_back(Tok);
   PP.Lex(Tok);
 }
@@ -3632,6 +3637,7 @@
 EOFTok.startToken();
 EOFTok.setKind(tok::eof);
 EOFTok.setLocation(EndLoc);
+EOFTok.setFlag(clang::Token::IsReinjected);
 AttributeTokens.push_back(EOFTok);
 
 Info->Tokens =


Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -1037,4 +1037,13 @@
   IsEmpty());
 }
 
+TEST_F(TokenCollectorTest, Pragmas) {
+  // Tokens coming from concatenations.
+  recordTokens(R"cpp(
+void foo() {
+  #pragma unroll 4
+  for(int i=0;i<4;++i);
+}
+  )cpp");
+}
 } // namespace
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -2607,6 +2607,7 @@
   Token EoF, AnnotTok;
   EoF.startToken();
   EoF.setKind(tok::eof);
+  EoF.setFlag(clang::Token::IsReinjected);
   AnnotTok.startToken();
   AnnotTok.setKind(tok::annot_pragma_ms_pragma);
   AnnotTok.setLocation(Tok.getLocation());
@@ -2614,6 +2615,7 @@
   SmallVector TokenVector;
   // Suck up all of the tokens before the eod.
   for (; Tok.isNot(tok::eod); PP.Lex(Tok)) {
+Tok.setFlag(clang::Token::IsReinjected);
 TokenVector.push_back(Tok);
 AnnotTok.setAnnotationEndLoc(Tok.getLocation());
   }
@@ -3159,6 +3161,7 @@
 break;
 }
 
+Tok.setFlag(clang::Token::IsReinjected);
 ValueList.push_back(Tok);
 PP.Lex(Tok);
   }
@@ -3174,6 +3177,7 @@
 
   Token EOFTok;
   EOFTok.startToken();
+  EOFTok.setFlag(clang::Token::IsReinjected);
   EOFTok.setKind(tok::eof);
   EOFTok.setLocation(Tok.getLocation());
   ValueList.push_back(EOFTok); // Terminates expression for parsing.
@@ -3612,6 +3616,7 @@
   break;
   }
 
+  Tok.setFlag(clang::Token::IsReinjected);
   AttributeTokens.push_back(Tok);
   PP.Lex(Tok);
 }
@@ -3632,6 +3637,7 @@
 EOFTok.startToken();
 EOFTok.setKind(tok::eof);
 EOFTok.setLocation(EndLoc);
+EOFTok.setFlag(clang::Token::IsReinjected);
 AttributeTokens.push_back(EOFTok);
 
 Info->Tokens =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-12 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:364
+  if (HasRandGen)
+Builder.defineMacro("__ARM_FEATURE_RNG", "1");
+

This needs a clang preprocessor test: both a check for its presence and absence.
Have a look/grep where these others predefined macros are tested.



Comment at: clang/test/CodeGen/arm_acle.c:908
+#if __ARM_64BIT_STATE && defined(__ARM_FEATURE_RNG)
+// AArch64-v8_3-LABEL: @test_rndr(
+// AArch64-v8_3-NEXT:  entry:

Not sure if I am surprised that this works This is (re)using tag 
`AArch64-v8_3` and for the other tests that use this and don't have RNG set, I 
was expecting FileCheck to complain about this, not sure if I am missing 
something though.



Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.td:610
 def AArch64tbl : SDNode<"AArch64ISD::TBL", SDT_AArch64TBL>;
-
+// MRS from CodeGen.
+def AArch64mrs : SDNode<"AArch64ISD::MRS",

Nit: for this comment to be informative, please expand it, or just remove it if 
there's not much to say about it.


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

https://reviews.llvm.org/D98264

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

@azabaznov This has broken some buildbots 
http://lab.llvm.org:8011/#/builders/105/builds/6855 - can you take a look 
please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D94621: [clang-tidy] add concurrency-async-fs

2021-03-12 Thread Vasily Kulikov via Phabricator via cfe-commits
segoon abandoned this revision.
segoon added a comment.

see https://reviews.llvm.org/D94622#2617417


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

https://reviews.llvm.org/D94621

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


[PATCH] D93940: [clang-tidy] Add a check for blocking types and functions.

2021-03-12 Thread Vasily Kulikov via Phabricator via cfe-commits
segoon abandoned this revision.
segoon added a comment.

see https://reviews.llvm.org/D94622#2617417


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

https://reviews.llvm.org/D93940

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


[PATCH] D98411: [OpenCL] Respect calling convention for builtin

2021-03-12 Thread Luke Drummond via Phabricator via cfe-commits
ldrumm added a subscriber: svenvh.
ldrumm added a comment.

@Anastasia @svenvh is this already covered by https://reviews.llvm.org/D98039 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98411

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


[PATCH] D98487: [AArch64][SVE/NEON] Add support for FROUNDEVEN for both NEON and fixed length SVE

2021-03-12 Thread Bradley Smith via Phabricator via cfe-commits
bsmith created this revision.
bsmith added reviewers: paulwalker-arm, peterwaller-arm, joechrisellis, 
CarolineConcatto, dmgreen.
Herald added subscribers: hiraditya, kristof.beyls, tschuett.
bsmith requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Previously NEON used a target specific intrinsic for frintn, given that
the FROUNDEVEN ISD node now exists, move over to that instead and add
codegen support for that node for both NEON and fixed length SVE.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98487

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-intrinsics.c
  clang/test/CodeGen/aarch64-neon-misc.c
  clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
  clang/test/CodeGen/arm-neon-directed-rounding.c
  clang/test/CodeGen/arm64-vrnd.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/include/llvm/Target/TargetSelectionDAG.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/arm64-vcvt.ll
  llvm/test/CodeGen/AArch64/arm64-vfloatintrinsics.ll
  llvm/test/CodeGen/AArch64/f16-instructions.ll
  llvm/test/CodeGen/AArch64/fp-intrinsics.ll
  llvm/test/CodeGen/AArch64/sve-fixed-length-fp-rounding.ll
  llvm/test/CodeGen/AArch64/vec-libcalls.ll

Index: llvm/test/CodeGen/AArch64/vec-libcalls.ll
===
--- llvm/test/CodeGen/AArch64/vec-libcalls.ll
+++ llvm/test/CodeGen/AArch64/vec-libcalls.ll
@@ -29,6 +29,7 @@
 declare <3 x float> @llvm.nearbyint.v3f32(<3 x float>)
 declare <3 x float> @llvm.rint.v3f32(<3 x float>)
 declare <3 x float> @llvm.round.v3f32(<3 x float>)
+declare <3 x float> @llvm.roundeven.v3f32(<3 x float>)
 declare <3 x float> @llvm.sqrt.v3f32(<3 x float>)
 declare <3 x float> @llvm.trunc.v3f32(<3 x float>)
 
@@ -478,6 +479,15 @@
   ret <3 x float> %r
 }
 
+define <3 x float> @roundeven_v3f32(<3 x float> %x) nounwind {
+; CHECK-LABEL: roundeven_v3f32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:frintn v0.4s, v0.4s
+; CHECK-NEXT:ret
+  %r = call <3 x float> @llvm.roundeven.v3f32(<3 x float> %x)
+  ret <3 x float> %r
+}
+
 define <3 x float> @sqrt_v3f32(<3 x float> %x) nounwind {
 ; CHECK-LABEL: sqrt_v3f32:
 ; CHECK:   // %bb.0:
Index: llvm/test/CodeGen/AArch64/sve-fixed-length-fp-rounding.ll
===
--- llvm/test/CodeGen/AArch64/sve-fixed-length-fp-rounding.ll
+++ llvm/test/CodeGen/AArch64/sve-fixed-length-fp-rounding.ll
@@ -1255,6 +1255,253 @@
   ret void
 }
 
+;
+; ROUNDEVEN -> FRINTN
+;
+
+; Don't use SVE for 64-bit vectors.
+define <4 x half> @frintn_v4f16(<4 x half> %op) #0 {
+; CHECK-LABEL: frintn_v4f16:
+; CHECK: frintn v0.4h, v0.4h
+; CHECK-NEXT: ret
+  %res = call <4 x half> @llvm.roundeven.v4f16(<4 x half> %op)
+  ret <4 x half> %res
+}
+
+; Don't use SVE for 128-bit vectors.
+define <8 x half> @frintn_v8f16(<8 x half> %op) #0 {
+; CHECK-LABEL: frintn_v8f16:
+; CHECK: frintn v0.8h, v0.8h
+; CHECK-NEXT: ret
+  %res = call <8 x half> @llvm.roundeven.v8f16(<8 x half> %op)
+  ret <8 x half> %res
+}
+
+define void @frintn_v16f16(<16 x half>* %a) #0 {
+; CHECK-LABEL: frintn_v16f16:
+; CHECK: ptrue [[PG:p[0-9]+]].h, vl16
+; CHECK-DAG: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
+; CHECK-NEXT: frintn [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
+; CHECK-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
+; CHECK-NEXT: ret
+  %op = load <16 x half>, <16 x half>* %a
+  %res = call <16 x half> @llvm.roundeven.v16f16(<16 x half> %op)
+  store <16 x half> %res, <16 x half>* %a
+  ret void
+}
+
+define void @frintn_v32f16(<32 x half>* %a) #0 {
+; CHECK-LABEL: frintn_v32f16:
+; VBITS_GE_512: ptrue [[PG:p[0-9]+]].h, vl32
+; VBITS_GE_512-DAG: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
+; VBITS_GE_512-NEXT: frintn [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
+; VBITS_GE_512-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
+; VBITS_GE_512-NEXT: ret
+
+; Ensure sensible type legalisation.
+; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].h, vl16
+; VBITS_EQ_256-DAG: add x[[A_HI:[0-9]+]], x0, #32
+; VBITS_EQ_256-DAG: ld1h { [[OP_LO:z[0-9]+]].h }, [[PG]]/z, [x0]
+; VBITS_EQ_256-DAG: ld1h { [[OP_HI:z[0-9]+]].h }, [[PG]]/z, [x[[A_HI]]]
+; VBITS_EQ_256-DAG: frintn [[RES_LO:z[0-9]+]].h, [[PG]]/m, [[OP_LO]].h
+; VBITS_EQ_256-DAG: frintn [[RES_HI:z[0-9]+]].h, [[PG]]/m, [[OP_HI]].h
+; VBITS_EQ_256-DAG: st1h { [[RES_LO]].h }, [[PG]], [x0]
+; VBITS_EQ_256-DAG: st1h { [[RES_HI]].h }, [[PG]], [x[[A_HI]]
+; VBITS_EQ_256-NEXT: ret
+  %op = load <32 x half>, <32 x half>* %a
+  %res = call <32 x half> @llvm.roundeven.v32f16(<32 x half> %op)
+  store <32 x half> %res, <32 x half>* %a
+  ret void
+}
+
+define void @frintn_v64f16(<64 x half>* %a) #0 {
+; CHECK-LABEL: frintn_v64f16:
+; VBITS_GE_1024: ptrue [[PG:p[0-9]+]].h, vl64
+; VBITS_GE_1024-DAG: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
+; VBITS_GE_1

[PATCH] D98488: [CodeCompletion] Avoid spurious signature help for init-list args

2021-03-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
sammccall requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Somewhat surprisingly, signature help is emitted as a side-effect of
computing the expected type of a function argument.
The reason is that both actions require enumerating the possible
function signatures and running partial overload resolution, and doing
this twice would be wasteful and complicated.

Change #1: document this, it's subtle :-)

However, sometimes we need to compute the expected type without having
reached the code completion cursor yet - in particular to allow
completion of designators.
eb4ab3358cd4dc834a761191b5531b38114f7b13 
 did this 
but introduced a
regression - it emits signature help in the wrong location as a side-effect.

Change #2: only emit signature help if the code completion cursor was reached.

Currently there is PP.isCodeCompletionReached(), but we can't use it
because it's set *after* running code completion.
It'd be nice to set this implicitly when the completion token is lexed,
but ConsumeCodeCompletionToken() makes this complicated.

Change #3: call cutOffParsing() *first* when seeing a completion token.

After this, the fact that the Sema::Produce*SignatureHelp() functions
are even more confusing, as they only sometimes do that.
I don't want to rename them in this patch as it's another large
mechanical change, but we should soon.

Change #4: prepare to rename ProduceSignatureHelp() to GuessArgumentType() etc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98488

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Sema/Sema.h
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseInit.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/desig-init.cpp

Index: clang/test/CodeCompletion/desig-init.cpp
===
--- clang/test/CodeCompletion/desig-init.cpp
+++ clang/test/CodeCompletion/desig-init.cpp
@@ -62,3 +62,18 @@
   Test X{.x = T(2)};
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:62:14 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s
 }
+
+namespace signature_regression {
+  // Verify that an old bug is gone: passing an init-list as a constructor arg
+  // would emit overloads as a side-effect.
+  struct S{int x;};
+  int wrongFunction(S);
+  int rightFunction();
+  int dummy = wrongFunction({1});
+  int x = rightFunction();
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:73:25 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-SIGNATURE-REGRESSION %s
+  // CHECK-SIGNATURE-REGRESSION-NOT: OVERLOAD: [#int#]wrongFunction
+  // CHECK-SIGNATURE-REGRESSION: OVERLOAD: [#int#]rightFunction
+  // CHECK-SIGNATURE-REGRESSION-NOT: OVERLOAD: [#int#]wrongFunction
+}
+
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -5691,8 +5691,9 @@
  unsigned CurrentArg, SourceLocation OpenParLoc) {
   if (Candidates.empty())
 return QualType();
-  SemaRef.CodeCompleter->ProcessOverloadCandidates(
-  SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc);
+  if (SemaRef.getPreprocessor().isCodeCompletionReached())
+SemaRef.CodeCompleter->ProcessOverloadCandidates(
+SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc);
   return getParamType(SemaRef, Candidates, CurrentArg);
 }
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -870,6 +870,7 @@
 SingleDecl = ParseObjCMethodDefinition();
 break;
   case tok::code_completion:
+cutOffParsing();
 if (CurParsedObjCImpl) {
   // Code-complete Objective-C methods even without leading '-'/'+' prefix.
   Actions.CodeCompleteObjCMethodDecl(getCurScope(),
@@ -879,7 +880,6 @@
 Actions.CodeCompleteOrdinaryName(
 getCurScope(),
 CurParsedObjCImpl ? Sema::PCC_ObjCImplementation : Sema::PCC_Namespace);
-cutOffParsing();
 return nullptr;
   case tok::kw_import:
 SingleDecl = ParseModuleImport(SourceLocation());
@@ -2114,21 +2114,21 @@
 
   for (Scope *S = getCurScope(); S; S = S->getParent()) {
 if (S->getFlags() & Scope::FnScope) {
+  cutOffParsing();
   Actions.CodeCompleteOrdinaryNa

[PATCH] D98030: [IR] Add vscale_range IR function attribute

2021-03-12 Thread Bradley Smith via Phabricator via cfe-commits
bsmith updated this revision to Diff 330205.
bsmith marked 3 inline comments as done.
bsmith added a comment.

- State what lack of vscale_range attribute means in LangRef
- Minor formatting change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98030

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/arm-sve-vector-bits-vscale-range.c
  llvm/docs/BitCodeFormat.rst
  llvm/docs/LangRef.rst
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLParser.h
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/AttributeImpl.h
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Bitcode/attributes.ll
  llvm/test/Verifier/vscale_range.ll

Index: llvm/test/Verifier/vscale_range.ll
===
--- /dev/null
+++ llvm/test/Verifier/vscale_range.ll
@@ -0,0 +1,7 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+; CHECK-NOT: 'vscale_range' minimum cannot be greater than maximum
+declare i8* @a(i32) vscale_range(1, 0)
+
+; CHECK: 'vscale_range' minimum cannot be greater than maximum
+declare i8* @b(i32*) vscale_range(8, 1)
Index: llvm/test/Bitcode/attributes.ll
===
--- llvm/test/Bitcode/attributes.ll
+++ llvm/test/Bitcode/attributes.ll
@@ -422,6 +422,18 @@
   ret void
 }
 
+; CHECK: define void @f72() #45
+define void @f72() vscale_range(8)
+{
+  ret void
+}
+
+; CHECK: define void @f73() #46
+define void @f73() vscale_range(1,8)
+{
+  ret void
+}
+
 ; CHECK: attributes #0 = { noreturn }
 ; CHECK: attributes #1 = { nounwind }
 ; CHECK: attributes #2 = { readnone }
@@ -467,4 +479,6 @@
 ; CHECK: attributes #42 = { nocallback }
 ; CHECK: attributes #43 = { cold }
 ; CHECK: attributes #44 = { hot }
+; CHECK: attributes #45 = { vscale_range(8,8) }
+; CHECK: attributes #46 = { vscale_range(1,8) }
 ; CHECK: attributes #[[NOBUILTIN]] = { nobuiltin }
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -970,6 +970,7 @@
   case Attribute::StackProtectStrong:
   case Attribute::StrictFP:
   case Attribute::UWTable:
+  case Attribute::VScaleRange:
   case Attribute::NoCfCheck:
   case Attribute::MustProgress:
   case Attribute::NoProfile:
Index: llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
===
--- llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
+++ llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
@@ -73,6 +73,7 @@
   .Case("sspstrong", Attribute::StackProtectStrong)
   .Case("strictfp", Attribute::StrictFP)
   .Case("uwtable", Attribute::UWTable)
+  .Case("vscale_range", Attribute::VScaleRange)
   .Default(Attribute::None);
 }
 
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1629,6 +1629,7 @@
   case Attribute::InlineHint:
   case Attribute::StackAlignment:
   case Attribute::UWTable:
+  case Attribute::VScaleRange:
   case Attribute::NonLazyBind:
   case Attribute::ReturnsTwice:
   case Attribute::SanitizeAddress:
@@ -1987,6 +1988,14 @@
   return;
   }
 
+  if (Attrs.hasFnAttribute(Attribute::VScaleRange)) {
+std::pair Args =
+Attrs.getVScaleRangeArgs(AttributeList::FunctionIndex);
+
+if (Args.first > Args.second && Args.second != 0)
+  CheckFailed("'vscale_range' minimum cannot be greater than maximum", V);
+  }
+
   if (Attrs.hasFnAttribute("frame-pointer")) {
 StringRef FP = Attrs.getAttribute(AttributeList::FunctionIndex,
   "frame-pointer").getValueAsString();
Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -78,6 +78,17 @@
   return std::make_pair(ElemSizeArg, NumElemsArg);
 }
 
+static uint64_t packVScaleRangeArgs(unsigned MinValue, unsigned MaxValue) {
+  return uint64_t(MinValue) << 32 | MaxValue;
+}
+
+static std::pair unpackVScaleRangeArgs(uint64_t Value) {
+  unsigned MaxValue = Value & std::numeric_limits::max();
+  unsigned MinValue = Value >> 32;
+
+  return std::make_pair(MinValue, MaxValue);
+}
+
 Attribute Attribute::get(LLVMContext &Context, Attribute::AttrKind Kind,
  uint64_t Val) {
   LLVMContextImpl *pImpl = Context.pImpl;
@@ -192,6 +203,12 @@
   return get(Con

[PATCH] D98030: [IR] Add vscale_range IR function attribute

2021-03-12 Thread Bradley Smith via Phabricator via cfe-commits
bsmith added inline comments.



Comment at: llvm/lib/IR/Attributes.cpp:570
+Result += utostr(MinValue);
+Result += ',';
+Result += utostr(MaxValue);

peterwaller-arm wrote:
> Nit: The only other precedent I can see for this is `allocsize`. Grepping the 
> code I found this is always written in tests as `allocsize(x, y)`, however, 
> it prints as `allocsize(x,y)` (no space) when done with `-emit-llvm`, 
> regardless of how it was formatted as input. I figure that is an oversight 
> and this should have the space.
I'm reluctant to change `allocsize` and given that is the only other example of 
multiple parameters to an attribute like this, I'm inclined to stay consistent 
with it. I also think there is an argument to be made about not intruding extra 
spaces in a potentially already cluttered attributes section.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98030

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


[clang] e448310 - Add support for digit separators in C2x.

2021-03-12 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-03-12T07:21:03-05:00
New Revision: e448310059053d69fbdd6c66dd95ad5d3cfc6243

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

LOG: Add support for digit separators in C2x.

WG14 adopted N2626 at the meetings this week. This commit adds support
for using ' as a digit separator in a numeric literal which is
compatible with the C++ feature.

Added: 
clang/test/Lexer/c2x_digit_separators.c
clang/test/Sema/pre-c2x-compat.c

Modified: 
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/lib/Lex/Lexer.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 130e7687bad2..64026a1ee922 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -179,6 +179,9 @@ def err_invalid_suffix_constant : Error<
 def warn_cxx11_compat_digit_separator : Warning<
   "digit separators are incompatible with C++ standards before C++14">,
   InGroup, DefaultIgnore;
+def warn_c2x_compat_digit_separator : Warning<
+  "digit separators are incompatible with C standards before C2x">,
+  InGroup, DefaultIgnore;
 def err_digit_separator_not_between_digits : Error<
   "digit separator cannot appear at %select{start|end}0 of digit sequence">;
 def warn_extraneous_char_constant : Warning<

diff  --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 34732b659771..e63574e306fb 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -1788,12 +1788,14 @@ bool Lexer::LexNumericConstant(Token &Result, const 
char *CurPtr) {
   }
 
   // If we have a digit separator, continue.
-  if (C == '\'' && getLangOpts().CPlusPlus14) {
+  if (C == '\'' && (getLangOpts().CPlusPlus14 || getLangOpts().C2x)) {
 unsigned NextSize;
 char Next = getCharAndSizeNoWarn(CurPtr + Size, NextSize, getLangOpts());
 if (isIdentifierBody(Next)) {
   if (!isLexingRawMode())
-Diag(CurPtr, diag::warn_cxx11_compat_digit_separator);
+Diag(CurPtr, getLangOpts().CPlusPlus
+ ? diag::warn_cxx11_compat_digit_separator
+ : diag::warn_c2x_compat_digit_separator);
   CurPtr = ConsumeChar(CurPtr, Size, Result);
   CurPtr = ConsumeChar(CurPtr, NextSize, Result);
   return LexNumericConstant(Result, CurPtr);

diff  --git a/clang/test/Lexer/c2x_digit_separators.c 
b/clang/test/Lexer/c2x_digit_separators.c
new file mode 100644
index ..3eff8f7cf700
--- /dev/null
+++ b/clang/test/Lexer/c2x_digit_separators.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -std=c2x -verify %s
+
+_Static_assert(1'2'3 == 12'3, "");
+_Static_assert(1'000'000 == 0xf'4240, "");
+_Static_assert(0'004'000'000 == 0x10', "");
+_Static_assert(0b0101'0100 == 0x54, "");
+
+int a0 = 123'; //'; // expected-error {{expected ';'}}
+int b0 = 0'xff; // expected-error {{digit separator cannot appear at end of 
digit sequence}} expected-error {{suffix 'xff' on integer}}
+int c0 = 0x'ff; // expected-error {{suffix 'x'ff' on integer}}
+int d0 = 0'1234; // ok, octal
+int e0 = 0'b1010; // expected-error {{digit 'b' in octal constant}}
+int f0 = 0b'1010; // expected-error {{invalid digit 'b' in octal}}
+int h0 = 0x1e+1; // expected-error {{invalid suffix '+1' on integer constant}}
+int i0 = 0x1'e+1; // ok, 'e+' is not recognized after a digit separator
+
+float a1 = 1'e1; // expected-error {{digit separator cannot appear at end of 
digit sequence}}
+float b1 = 1'0e1;
+float c1 = 1.'0e1; // expected-error {{digit separator cannot appear at start 
of digit sequence}}
+float d1 = 1.0'e1; // expected-error {{digit separator cannot appear at end of 
digit sequence}}
+float e1 = 1e'1; // expected-error {{digit separator cannot appear at start of 
digit sequence}}
+float g1 = 0.'0; // expected-error {{digit separator cannot appear at start of 
digit sequence}}
+float h1 = .'0; // '; // expected-error {{expected expression}}, lexed as . 
followed by character literal
+float i1 = 0x.'0p0; // expected-error {{digit separator cannot appear at start 
of digit sequence}}
+float j1 = 0x'0.0p0; // expected-error {{invalid suffix 'x'0.0p0'}}
+float k1 = 0x0'.0p0; // '; // expected-error {{expected ';'}}
+float l1 = 0x0.'0p0; // expected-error {{digit separator cannot appear at 
start of digit sequence}}
+float m1 = 0x0.0'p0; // expected-error {{digit separator cannot appear at end 
of digit sequence}}
+float n1 = 0x0.0p'0; // expected-error {{digit separator cannot appear at 
start of digit sequence}}
+float p1 = 0'e1; // expected-error {{digit separator cannot appear at end of 
digit sequence}}
+float q1 = 0'0e1;
+float r1 = 0.'0e1; // expected-error {{digit separator cannot appear at start 
of digit sequence}}
+float s1 = 0.

[PATCH] D98337: Add support for digit separators in C2x

2021-03-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thanks for the review, I've commit in e448310059053d69fbdd6c66dd95ad5d3cfc6243 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98337

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


[PATCH] D98030: [IR] Add vscale_range IR function attribute

2021-03-12 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

Looks fine to me, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98030

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


[PATCH] D95458: [PowerPC] Exploit xxsplti32dx (constant materialization) for scalars

2021-03-12 Thread Stefan Pintilie via Phabricator via cfe-commits
stefanp accepted this revision.
stefanp added a comment.
This revision is now accepted and ready to land.

Thank you for adding this!
Other than one minor nit I think this LGTM.

Feel free to address nits on commits.




Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:8834
+   &LosesInfo);
+  bool Success = (!LosesInfo && !APFloatToConvert.isDenormal());
+

nit:
You can just inline this. It is only used in one place.


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

https://reviews.llvm.org/D95458

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


[PATCH] D97411: [DebugInfo] Add an attribute to force type info to be emitted for types that are required to be complete.

2021-03-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM with a small, technical nit to be fixed.




Comment at: clang/include/clang/Basic/Attr.td:1664
+def StandaloneDebug : InheritableAttr {
+  let Spellings = [Clang<"standalone_debug">];
+  let Subjects = SubjectList<[CXXRecord]>;

I think this should be `Clang<"standalone_debug", /*allowInC*/0>` so that 
`__has_c_attribute` reports `false` for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97411

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


[PATCH] D97411: [DebugInfo] Add an attribute to force type info to be emitted for types that are required to be complete.

2021-03-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I should note, you need to also fix the CI build failures: 
https://reviews.llvm.org/harbormaster/unit/view/421174/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97411

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


[PATCH] D95244: [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

2021-03-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

This looks like a reasonable solution to me -- if we don't know the function 
call result type (e.g. dependent-type callExpr in template context), modeling 
it as a dependent type.




Comment at: clang/lib/AST/Expr.cpp:1387
+
+  auto CreateDependentType = [&Ctx]() {
+ASTContext::GetBuiltinTypeError Error;

this can be removed, dependent type is a builtin type, so you could just use 
`Ctx.DependentTy`.



Comment at: clang/lib/AST/Expr.cpp:1403
 CalleeType = Expr::findBoundMemberType(Callee);
+if (CalleeType.isNull())
+  return CreateDependentType();

The only case is `UnresolvedMemberExpr`, I think we'd keep the previous comment 
and special-case the UnresolvedMemberExpr (like the `CXXPseudoDestructorExpr` 
above).

```
if (isa(...))
  return Ctx.DependentTy;

 // This should never be overloaded and so should never return null.
 CalleeType = Expr::findBoundMemberType(Callee);
 CHECK(!CalleeType.isNull());
```



Comment at: clang/unittests/Tooling/SourceCodeTest.cpp:630
+  f(t);
+  // CalleeType in getCallReturntype is Overload and dependent
+}

CalleeType is not a specific term in `getCallReturnType`, just `CalleeType is 
overload and dependent`, I think we can also verify this in the Visitor.OnCall 
callback. 

IIUC, the patch fixes three different crashes
- calling getCallReturntype on the `f(t)` expr 
- calling getCallReturntype on the `f_overload()` expr 
- calling getCallReturntype on the `a.f_overload(p);` expr

I think it would be much clear to express them in the `OnCall` callback (rather 
than calling `getCallReturnType` on every Expr). One option is to use the 
annotation, and identify the expression by location like below. An other 
benefit is that we can unify the test code (instead of duplicating them) 
without hurting the code readability.

```
template
void templ(const T& t, F f) {
  $crash1[[f]](t);
  // CalleeType in getCallReturntype is Overload and dependent
}

struct A {
  void f_overload(int);
  void f_overload(double);
};

void f() {
  int i = 0;
  templ(i, [](const auto &p) {
$crash2[[f_overload]](p); // UnresolvedLookupExpr
// CalleeType in getCallReturntype is Overload and not dependent
  });

  templ(i, [](const auto &p) {
A a;
a.$crash3[[f_overload]](p); // UnresolvedMemberExpr
// CalleeType in getCallReturntype is BoundMember and has overloads
  });
  
}
```
 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95244

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-03-12 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz added a comment.

I think this makes good progress. I found two details in the test code that 
need attention. The stdout issue might be done now or in a follow-up patch some 
time soon. Otherwise, this seems to get ready to land.

@teemperor What about your notes. Are there any open issues remaining?




Comment at: clang/lib/Interpreter/Interpreter.cpp:93
+   "Initialization failed. "
+   "Unable to create diagnostics engine");
+

It looks like `clang-repl` always dumps errors to stdout currently. This is 
fine for the interactive use case, but it will be impractical for input/output 
tests. As a result unit tests e.g. dump:
```
Note: Google Test filter = InterpreterTest.Errors
[==] Running 1 test from 1 test case.
[--] Global test environment set-up.
[--] 1 test from InterpreterTest
[ RUN  ] InterpreterTest.Errors
In file included from :0:
input_line_0:1:1: error: unknown type name 'intentional_error'
intentional_error v1 = 42; 
^
[   OK ] InterpreterTest.Errors (9024 ms)
[--] 1 test from InterpreterTest (9024 ms total)

[--] Global test environment tear-down
[==] 1 test from 1 test case ran. (9025 ms total)
[  PASSED  ] 1 test.
```

It would be useful to have an option for streaming diagnostics to an in-memory 
buffer (and maybe append them to returned llvm::Error instances in the future). 
Instead of `createDiagnostics()` you could pass a TextDiagnosticPrinter via 
`setDiagnostics()` here to accomplish it.

Not insisting on having it in this review, but it would be a good follow-up 
task at least.



Comment at: clang/test/Interpreter/execute.c:9
+
+struct S { float f = 1.0; S *m = nullptr;} s;
+auto r2 = printf("S[f=%f, m=%p]\n", s.f, s.m);

*nit* this should be a cpp file right? Otherwise, you should write `struct S *m 
= nullptr;` here. Also, C doesn't understand the `extern "C"` above :)



Comment at: clang/test/Interpreter/execute.c:11
+auto r2 = printf("S[f=%f, m=%p]\n", s.f, s.m);
+// CHECK-NEXT: S[f=1.00, m=(nil)]
+

The `%p` format placeholder in printf is implementation-defined, so the output 
here varies. Maybe you can do something like this instead:

```
auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, (unsigned long long)s.m);
// CHECK-NEXT: S[f=1.00, m=(0x0)]
```

Or reinterpret_cast(s.m) if you go the C++ way.



Comment at: clang/test/lit.cfg.py:105
+config.available_features.add('host-supports-jit')
+
 if config.clang_staticanalyzer:

I couldn't test this on a host that doesn't support JIT, but it looks like a 
nice "duck typing" way of testing for the feature.


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

https://reviews.llvm.org/D96033

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


[PATCH] D98450: [clang] store an identifer instead of declref for ns_error_domain attribute

2021-03-12 Thread Michael Forster via Phabricator via cfe-commits
MForster added a comment.

That's ok for me. I'd suggest to wait for Aaron's feedback, because IIRC it was 
his suggestion in the first place to go to declref.


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

https://reviews.llvm.org/D98450

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


[clang] f50aef7 - Revert "[InstrProfiling] Don't generate __llvm_profile_runtime_user"

2021-03-12 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-03-12T13:53:46+01:00
New Revision: f50aef745c3ba981f3d0bf118b809d0c3880a490

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

LOG: Revert "[InstrProfiling] Don't generate __llvm_profile_runtime_user"

This broke the check-profile tests on Mac, see comment on the code
review.

> This is no longer needed, we can add __llvm_profile_runtime directly
> to llvm.compiler.used or llvm.used to achieve the same effect.
>
> Differential Revision: https://reviews.llvm.org/D98325

This reverts commit c7712087cbb505d324e1149fa224f607c91a8c6a.

Also reverting the dependent follow-up commit:

Revert "[InstrProfiling] Generate runtime hook for ELF platforms"

> When using -fprofile-list to selectively apply instrumentation only
> to certain files or functions, we may end up with a binary that doesn't
> have any counters in the case where no files were selected. However,
> because on Linux and Fuchsia, we pass -u__llvm_profile_runtime, the
> runtime would still be pulled in and incur some non-trivial overhead,
> especially in the case when the continuous or runtime counter relocation
> mode is being used. A better way would be to pull in the profile runtime
> only when needed by declaring the __llvm_profile_runtime symbol in the
> translation unit only when needed.
>
> This approach was already used prior to 9a041a75221ca, but we changed it
> to always generate the __llvm_profile_runtime due to a TAPI limitation.
> Since TAPI is only used on Mach-O platforms, we could use the early
> emission of __llvm_profile_runtime there, and on other platforms we
> could change back to the earlier approach where the symbol is generated
> later only when needed. We can stop passing -u__llvm_profile_runtime to
> the linker on Linux and Fuchsia since the generated undefined symbol in
> each translation unit that needed it serves the same purpose.
>
> Differential Revision: https://reviews.llvm.org/D98061

This reverts commit 87fd09b25f8892e07b7ba11525baa9c3ec3e5d3f.

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/lib/Driver/ToolChains/Fuchsia.h
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/Linux.h
clang/test/Driver/coverage-ld.c
clang/test/Driver/fuchsia.c
llvm/include/llvm/ProfileData/InstrProf.h
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/test/Instrumentation/InstrProfiling/linkage.ll
llvm/test/Instrumentation/InstrProfiling/profiling.ll

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 8a369c88c2a5..28de4e3aac6f 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2301,14 +2301,6 @@ In these cases, you can use the flag 
``-fno-profile-instr-generate`` (or
 Note that these flags should appear after the corresponding profile
 flags to have an effect.
 
-.. note::
-
-  When none of the translation units inside a binary is instrumented, in the
-  case of ELF and COFF binary format the profile runtime will not be linked
-  into the binary and no profile will be produced, while in the case of Mach-O
-  the profile runtime will be linked and profile will be produced but there
-  will not be any counters.
-
 Instrumenting only selected files or functions
 ^^
 

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 4b27a102f218..8e086010a984 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -394,3 +394,13 @@ SanitizerMask Fuchsia::getDefaultSanitizers() const {
   }
   return Res;
 }
+
+void Fuchsia::addProfileRTLibs(const llvm::opt::ArgList &Args,
+   llvm::opt::ArgStringList &CmdArgs) const {
+  // Add linker option -u__llvm_profile_runtime to cause runtime
+  // initialization module to be linked in.
+  if (needsProfileRT(Args))
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
+  ToolChain::addProfileRTLibs(Args, CmdArgs);
+}

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.h 
b/clang/lib/Driver/ToolChains/Fuchsia.h
index 1a0263ce3393..07adf9b7101d 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.h
+++ b/clang/lib/Driver/ToolChains/Fuchsia.h
@@ -71,6 +71,9 @@ class LLVM_LIBRARY_VISIBILITY Fuchsia : public ToolChain {
   SanitizerMask getSupportedSanitizers() const override;
   SanitizerMask getDefaultSanitizers() const override;
 
+  void addProfileRTLibs(const llvm::opt::ArgList &Args,
+llvm::opt::ArgStringList &CmdArgs) const override;
+
   RuntimeLibType
   GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
   CXXStdlibType

di

[clang] 6dc1523 - [analyzer][solver] Prevent infeasible states (PR49490)

2021-03-12 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2021-03-12T15:56:48+03:00
New Revision: 6dc152350824d0abcf4e1836c2846f8f9256779c

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

LOG: [analyzer][solver] Prevent infeasible states (PR49490)

This patch fixes the situation when our knowledge of disequalities
can help us figuring out that some assumption is infeasible, but
the solver still produces a state with inconsistent constraints.

Additionally, this patch adds a couple of assertions to catch this
type of problems easier.

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

Added: 
clang/test/Analysis/PR49490.cpp

Modified: 
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index a481bde1651b..95e61f9c8c61 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -19,6 +19,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -1395,12 +1397,23 @@ class RangeConstraintManager : public 
RangedConstraintManager {
 return EquivalenceClass::merge(getBasicVals(), F, State, LHS, RHS);
   }
 
-  LLVM_NODISCARD inline ProgramStateRef setConstraint(ProgramStateRef State,
-  EquivalenceClass Class,
-  RangeSet Constraint) {
+  LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
+  areFeasible(ConstraintRangeTy Constraints) {
+return llvm::none_of(
+Constraints,
+[](const std::pair &ClassConstraint) {
+  return ClassConstraint.second.isEmpty();
+});
+  }
+
+  LLVM_NODISCARD ProgramStateRef setConstraint(ProgramStateRef State,
+   EquivalenceClass Class,
+   RangeSet Constraint) {
 ConstraintRangeTy Constraints = State->get();
 ConstraintRangeTy::Factory &CF = State->get_context();
 
+assert(!Constraint.isEmpty() && "New constraint should not be empty");
+
 // Add new constraint.
 Constraints = CF.add(Constraints, Class, Constraint);
 
@@ -1413,9 +1426,18 @@ class RangeConstraintManager : public 
RangedConstraintManager {
   for (EquivalenceClass DisequalClass : Class.getDisequalClasses(State)) {
 RangeSet UpdatedConstraint =
 getRange(State, DisequalClass).Delete(getBasicVals(), F, *Point);
+
+// If we end up with at least one of the disequal classes to be
+// constrainted with an empty range-set, the state is infeasible.
+if (UpdatedConstraint.isEmpty())
+  return nullptr;
+
 Constraints = CF.add(Constraints, DisequalClass, UpdatedConstraint);
   }
 
+assert(areFeasible(Constraints) && "Constraint manager shouldn't produce "
+   "a state with infeasible constraints");
+
 return State->set(Constraints);
   }
 

diff  --git a/clang/test/Analysis/PR49490.cpp b/clang/test/Analysis/PR49490.cpp
new file mode 100644
index ..3254355013a6
--- /dev/null
+++ b/clang/test/Analysis/PR49490.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+
+struct toggle {
+  bool value;
+};
+
+toggle global_toggle;
+toggle get_global_toggle() { return global_toggle; }
+
+int oob_access();
+
+bool compare(toggle one, bool other) {
+  if (one.value != other)
+return true;
+
+  if (one.value)
+oob_access();
+  return true;
+}
+
+bool coin();
+
+void bar() {
+  bool left = coin();
+  bool right = coin();
+  for (;;)
+compare(get_global_toggle(), left) && compare(get_global_toggle(), right);
+}



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


[PATCH] D98341: [analyzer][solver] Prevent infeasible states (PR49490)

2021-03-12 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6dc152350824: [analyzer][solver] Prevent infeasible states 
(PR49490) (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98341

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/PR49490.cpp


Index: clang/test/Analysis/PR49490.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR49490.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+
+struct toggle {
+  bool value;
+};
+
+toggle global_toggle;
+toggle get_global_toggle() { return global_toggle; }
+
+int oob_access();
+
+bool compare(toggle one, bool other) {
+  if (one.value != other)
+return true;
+
+  if (one.value)
+oob_access();
+  return true;
+}
+
+bool coin();
+
+void bar() {
+  bool left = coin();
+  bool right = coin();
+  for (;;)
+compare(get_global_toggle(), left) && compare(get_global_toggle(), right);
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -19,6 +19,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -1395,12 +1397,23 @@
 return EquivalenceClass::merge(getBasicVals(), F, State, LHS, RHS);
   }
 
-  LLVM_NODISCARD inline ProgramStateRef setConstraint(ProgramStateRef State,
-  EquivalenceClass Class,
-  RangeSet Constraint) {
+  LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
+  areFeasible(ConstraintRangeTy Constraints) {
+return llvm::none_of(
+Constraints,
+[](const std::pair &ClassConstraint) {
+  return ClassConstraint.second.isEmpty();
+});
+  }
+
+  LLVM_NODISCARD ProgramStateRef setConstraint(ProgramStateRef State,
+   EquivalenceClass Class,
+   RangeSet Constraint) {
 ConstraintRangeTy Constraints = State->get();
 ConstraintRangeTy::Factory &CF = State->get_context();
 
+assert(!Constraint.isEmpty() && "New constraint should not be empty");
+
 // Add new constraint.
 Constraints = CF.add(Constraints, Class, Constraint);
 
@@ -1413,9 +1426,18 @@
   for (EquivalenceClass DisequalClass : Class.getDisequalClasses(State)) {
 RangeSet UpdatedConstraint =
 getRange(State, DisequalClass).Delete(getBasicVals(), F, *Point);
+
+// If we end up with at least one of the disequal classes to be
+// constrainted with an empty range-set, the state is infeasible.
+if (UpdatedConstraint.isEmpty())
+  return nullptr;
+
 Constraints = CF.add(Constraints, DisequalClass, UpdatedConstraint);
   }
 
+assert(areFeasible(Constraints) && "Constraint manager shouldn't produce "
+   "a state with infeasible constraints");
+
 return State->set(Constraints);
   }
 


Index: clang/test/Analysis/PR49490.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR49490.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+
+struct toggle {
+  bool value;
+};
+
+toggle global_toggle;
+toggle get_global_toggle() { return global_toggle; }
+
+int oob_access();
+
+bool compare(toggle one, bool other) {
+  if (one.value != other)
+return true;
+
+  if (one.value)
+oob_access();
+  return true;
+}
+
+bool coin();
+
+void bar() {
+  bool left = coin();
+  bool right = coin();
+  for (;;)
+compare(get_global_toggle(), left) && compare(get_global_toggle(), right);
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -19,6 +19,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -1395,12 +1397,23 @@
 return EquivalenceClass::merge(getBasicVals(), F, State, LHS, RHS);
   }
 
-  LLVM_NODISCARD inline ProgramS

[PATCH] D98483: [clang] Mark re-injected tokens appropriately during pragma handling

2021-03-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Parse/ParsePragma.cpp:2610
   EoF.setKind(tok::eof);
+  EoF.setFlag(clang::Token::IsReinjected);
   AnnotTok.startToken();

It was surprisingly hard for me to see that the changes here were just marking 
everything in TokenArray as reinjected.

Could you do that directly with a loop at the end instead? (It's hard to 
imagine a significant performance difference)

(And the same in all the other modified sites)



Comment at: clang/lib/Parse/ParsePragma.cpp:2618
   for (; Tok.isNot(tok::eod); PP.Lex(Tok)) {
+Tok.setFlag(clang::Token::IsReinjected);
 TokenVector.push_back(Tok);

as discussed offline, it wasn't clear to me that this was "in time" as we're 
not trying to affect the behavior of the subsequent PP.Lex call, not the 
previous one.

Maybe we could extract a function to mark an ArrayRef as reinject with a name 
that makes this clear.
`markAsReinjectedForRelexing()` or something...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98483

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


[PATCH] D98450: [clang] store an identifer instead of declref for ns_error_domain attribute

2021-03-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D98450#2621877 , @MForster wrote:

> That's ok for me. I'd suggest to wait for Aaron's feedback, because IIRC it 
> was his suggestion in the first place to go to declref.

I have the same concerns with this patch as I did with the initial one, see 
https://reviews.llvm.org/D84005#inline-775391 -- basically, we're doing a 
lookup here in SemaDeclAttr.cpp and saying "I found the identifier, 
everything's good", then storing the identifier into the attribute so we can 
look it up again later, at which point looking up the identifier may find 
something totally unrelated to what was found in SemaDeclAttr.cpp.

> The attribute with declref is incompatible with Apple's SDKs, as the declref 
> at the point of use in the attribute might not be available due to the 
> availability annotations on the domain declaration.

Can you help me to understand why this isn't the expected behavior? If you name 
something that's not available, it seems surprising to me that it would then be 
available but only as one particular attribute argument.


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

https://reviews.llvm.org/D98450

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


[PATCH] D98493: [WoA][MSVC] Use default linker setting in MSVC-compatible driver

2021-03-12 Thread Maxim Kuvyrkov via Phabricator via cfe-commits
maxim-kuvyrkov created this revision.
maxim-kuvyrkov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

At the moment "link.exe" is hard-coded as default linker in MSVC.cpp,
so there's no way to use LLD as default linker for MSVC driver.

This patch adds checking of CLANG_DEFAULT_LINKER to MSVC.cpp.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98493

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


Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -577,7 +577,9 @@
   // translate 'lld' into 'lld-link', and in the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "link");
+  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ, 
CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
   if (Linker.equals_lower("lld"))
 Linker = "lld-link";
 


Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -577,7 +577,9 @@
   // translate 'lld' into 'lld-link', and in the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "link");
+  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
   if (Linker.equals_lower("lld"))
 Linker = "lld-link";
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98494: [NFC] Minor cleanup to use default setting of getLastArg()

2021-03-12 Thread Maxim Kuvyrkov via Phabricator via cfe-commits
maxim-kuvyrkov created this revision.
maxim-kuvyrkov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Noticed this while I was looking at linker defaults.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98494

Files:
  clang/lib/Driver/ToolChain.cpp


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -571,8 +571,7 @@
 
   // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= 
is
   // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
-  const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
-  StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+  StringRef UseLinker = Args.getLastArg(options::OPT_fuse_ld_EQ, 
CLANG_DEFAULT_LINKER);
 
   // --ld-path= takes precedence over -fuse-ld= and specifies the executable
   // name. -B, COMPILER_PATH and PATH and consulted if the value does not


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -571,8 +571,7 @@
 
   // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= is
   // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
-  const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
-  StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+  StringRef UseLinker = Args.getLastArg(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER);
 
   // --ld-path= takes precedence over -fuse-ld= and specifies the executable
   // name. -B, COMPILER_PATH and PATH and consulted if the value does not
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98411: [OpenCL] Respect calling convention for builtin

2021-03-12 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh accepted this revision.
svenvh added a comment.

In D98411#2621736 , @ldrumm wrote:

> @Anastasia @svenvh is this already covered by https://reviews.llvm.org/D98039 
> ?

D98039  adds the calling convention for OpenCL 
language builtins during Sema, so it should not affect code generation of calls 
to `__translate_sampler_initializer`.

Your fix LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98411

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


[PATCH] D98488: [CodeCompletion] Avoid spurious signature help for init-list args

2021-03-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 330218.
sammccall added a comment.

oops, enable clangd test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98488

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Sema/Sema.h
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseInit.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/desig-init.cpp

Index: clang/test/CodeCompletion/desig-init.cpp
===
--- clang/test/CodeCompletion/desig-init.cpp
+++ clang/test/CodeCompletion/desig-init.cpp
@@ -62,3 +62,18 @@
   Test X{.x = T(2)};
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:62:14 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s
 }
+
+namespace signature_regression {
+  // Verify that an old bug is gone: passing an init-list as a constructor arg
+  // would emit overloads as a side-effect.
+  struct S{int x;};
+  int wrongFunction(S);
+  int rightFunction();
+  int dummy = wrongFunction({1});
+  int x = rightFunction();
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:73:25 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-SIGNATURE-REGRESSION %s
+  // CHECK-SIGNATURE-REGRESSION-NOT: OVERLOAD: [#int#]wrongFunction
+  // CHECK-SIGNATURE-REGRESSION: OVERLOAD: [#int#]rightFunction
+  // CHECK-SIGNATURE-REGRESSION-NOT: OVERLOAD: [#int#]wrongFunction
+}
+
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -5691,8 +5691,9 @@
  unsigned CurrentArg, SourceLocation OpenParLoc) {
   if (Candidates.empty())
 return QualType();
-  SemaRef.CodeCompleter->ProcessOverloadCandidates(
-  SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc);
+  if (SemaRef.getPreprocessor().isCodeCompletionReached())
+SemaRef.CodeCompleter->ProcessOverloadCandidates(
+SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc);
   return getParamType(SemaRef, Candidates, CurrentArg);
 }
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -870,6 +870,7 @@
 SingleDecl = ParseObjCMethodDefinition();
 break;
   case tok::code_completion:
+cutOffParsing();
 if (CurParsedObjCImpl) {
   // Code-complete Objective-C methods even without leading '-'/'+' prefix.
   Actions.CodeCompleteObjCMethodDecl(getCurScope(),
@@ -879,7 +880,6 @@
 Actions.CodeCompleteOrdinaryName(
 getCurScope(),
 CurParsedObjCImpl ? Sema::PCC_ObjCImplementation : Sema::PCC_Namespace);
-cutOffParsing();
 return nullptr;
   case tok::kw_import:
 SingleDecl = ParseModuleImport(SourceLocation());
@@ -2114,21 +2114,21 @@
 
   for (Scope *S = getCurScope(); S; S = S->getParent()) {
 if (S->getFlags() & Scope::FnScope) {
+  cutOffParsing();
   Actions.CodeCompleteOrdinaryName(getCurScope(),
Sema::PCC_RecoveryInFunction);
-  cutOffParsing();
   return PrevTokLocation;
 }
 
 if (S->getFlags() & Scope::ClassScope) {
-  Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Class);
   cutOffParsing();
+  Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Class);
   return PrevTokLocation;
 }
   }
 
-  Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Namespace);
   cutOffParsing();
+  Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Namespace);
   return PrevTokLocation;
 }
 
@@ -2452,8 +2452,8 @@
   while (true) {
 if (!Tok.is(tok::identifier)) {
   if (Tok.is(tok::code_completion)) {
-Actions.CodeCompleteModuleImport(UseLoc, Path);
 cutOffParsing();
+Actions.CodeCompleteModuleImport(UseLoc, Path);
 return true;
   }
 
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -178,8 +178,8 @@
 }
 
   case tok::code_completion:
-Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Statement);
 cutOffParsing();
+Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Statement);
 return StmtError();
 
   case tok::identifier: {
@@ -726,8 +726,8 @@
 ColonLoc = SourceLocation();
 
 if (Tok.is(tok::code_completion)) {
-  Actions.CodeCompleteCase(getCurScope());

[PATCH] D98497: [ASTMatchers] Don't forward matchers in MapAnyOf

2021-03-12 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, steveire, klimek.
njames93 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Forwarding these means that if an r-value reference is passed, the matcher will 
be moved. However it appears this happens for each mapped node matcher, 
resulting in use-after-move issues.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98497

Files:
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h


Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1386,8 +1386,7 @@
 internal::DynTypedMatcher::VO_AnyOf},
 applyMatcher(
 [&](auto... Matcher) {
-  return std::make_tuple(Matcher(
-  std::forward(InnerMatcher)...)...);
+  return std::make_tuple(Matcher(InnerMatcher...)...);
 },
 std::tuple<
 VariadicDynCastAllOfMatcher...>(;


Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1386,8 +1386,7 @@
 internal::DynTypedMatcher::VO_AnyOf},
 applyMatcher(
 [&](auto... Matcher) {
-  return std::make_tuple(Matcher(
-  std::forward(InnerMatcher)...)...);
+  return std::make_tuple(Matcher(InnerMatcher...)...);
 },
 std::tuple<
 VariadicDynCastAllOfMatcher...>(;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98498: [clangd] Enable modules to contribute tweaks.

2021-03-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

First patch to enable diagnostic fix generation through modules. The
workflow will look like:

- ASTWorker letting modules know about diagnostics while building AST,

modules can read clang::Diagnostic and mutate clangd::Diagnostic through
that hook.

- Modules can implement and expose tweaks to fix diagnostics or act as

general refactorings.

- Tweak::Selection will contain information about the diagnostic

associated with the codeAction request to enable modules to fail their
diagnostic fixing tweakson prepare if need be.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98498

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/FeatureModule.h
  clang-tools-extra/clangd/refactor/Tweak.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
@@ -75,7 +75,7 @@
 Range.second, [&](SelectionTree ST) {
   Tweak::Selection S(Index, AST, Range.first,
  Range.second, std::move(ST));
-  if (auto T = prepareTweak(TweakID, S)) {
+  if (auto T = prepareTweak(TweakID, S, nullptr)) {
 Result = (*T)->apply(S);
 return true;
   } else {
Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -206,7 +206,8 @@
   auto Tree = SelectionTree::createRight(AST->getASTContext(),
  AST->getTokens(), Start, End);
   Tweak::Selection Selection(&Index, *AST, Start, End, std::move(Tree));
-  for (const auto &T : prepareTweaks(Selection, Opts.TweakFilter)) {
+  for (const auto &T :
+   prepareTweaks(Opts.FeatureModules, Selection, Opts.TweakFilter)) {
 auto Result = T->apply(Selection);
 if (!Result) {
   elog("tweak: {0} ==> FAIL: {1}", T->id(), Result.takeError());
Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- clang-tools-extra/clangd/refactor/Tweak.h
+++ clang-tools-extra/clangd/refactor/Tweak.h
@@ -127,14 +127,15 @@
 /// Calls prepare() on all tweaks that satisfy the filter, returning those that
 /// can run on the selection.
 std::vector>
-prepareTweaks(const Tweak::Selection &S,
+prepareTweaks(const class FeatureModuleSet *Modules, const Tweak::Selection &S,
   llvm::function_ref Filter);
 
 // Calls prepare() on the tweak with a given ID.
 // If prepare() returns false, returns an error.
 // If prepare() returns true, returns the corresponding tweak.
-llvm::Expected> prepareTweak(StringRef TweakID,
-const Tweak::Selection &S);
+llvm::Expected>
+prepareTweak(StringRef ID, const Tweak::Selection &S,
+ const class FeatureModuleSet *Modules);
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/refactor/Tweak.cpp
===
--- clang-tools-extra/clangd/refactor/Tweak.cpp
+++ clang-tools-extra/clangd/refactor/Tweak.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 #include "Tweak.h"
+#include "FeatureModule.h"
 #include "SourceCode.h"
 #include "index/Index.h"
 #include "support/Logger.h"
@@ -20,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 LLVM_INSTANTIATE_REGISTRY(llvm::Registry)
 
@@ -43,6 +45,18 @@
   }
 #endif
 }
+
+std::vector>
+getAllTweaks(const FeatureModuleSet *Modules) {
+  std::vector> All;
+  for (const auto &E : TweakRegistry::entries())
+All.emplace_back(E.instantiate());
+  if (!Modules)
+return All;
+  for (auto &M : *Modules)
+M.contributeTweaks(All);
+  return All;
+}
 } // namespace
 
 Tweak::Selection::Selection(const SymbolIndex *Index, ParsedAST &AST,
@@ -56,13 +70,12 @@
 }
 
 std::vector>
-prepareTweaks(const Tweak::Selection &S,
+prepareTweaks(const FeatureModuleSet *Modules, const Tweak::Selection &S,
   llvm::function_ref Filter) {
   validateRegistry();
 
   std::vector> Available;
-  for (const auto &E : TweakRegistry::entries()) {
-std::unique_ptr

[PATCH] D98499: [clangd] Introduce ASTHooks to FeatureModules

2021-03-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman, javed.absar.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

These can be invoked at different stages while building an AST to let
FeatureModules implement features on top of it. The patch also
introduces a sawDiagnostic hook, which can mutate the final clangd::Diag
while reading a clang::Diagnostic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98499

Files:
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/FeatureModule.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestTU.h

Index: clang-tools-extra/clangd/unittests/TestTU.h
===
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -25,6 +25,7 @@
 #include "support/Path.h"
 #include "llvm/ADT/StringMap.h"
 #include "gtest/gtest.h"
+#include 
 #include 
 #include 
 #include 
@@ -76,6 +77,8 @@
   // to eliminate this option some day.
   bool OverlayRealFileSystemForModules = false;
 
+  std::vector> Hooks;
+
   // By default, build() will report Error diagnostics as GTest errors.
   // Suppress this behavior by adding an 'error-ok' comment to the code.
   ParsedAST build() const;
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -36,6 +36,7 @@
   FS.Files[ImportThunk] = ThunkContents;
 
   ParseInputs Inputs;
+  Inputs.ASTHooks = Hooks;
   auto &Argv = Inputs.CompileCommand.CommandLine;
   Argv = {"clang"};
   // FIXME: this shouldn't need to be conditional, but it breaks a
@@ -97,6 +98,7 @@
   MockFS FS;
   auto Inputs = inputs(FS);
   StoreDiags Diags;
+  Diags.setASTHooks(Inputs.ASTHooks);
   auto CI = buildCompilerInvocation(Inputs, Diags);
   assert(CI && "Failed to build compilation invocation.");
   if (OverlayRealFileSystemForModules)
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1346,6 +1346,24 @@
  });
 }
 
+TEST(ParsedASTTest, ModuleSawDiag) {
+  static constexpr const llvm::StringLiteral KDiagMsg = "StampedDiag";
+  struct Hooks : public FeatureModule::ParseASTHooks {
+void sawDiagnostic(const clang::Diagnostic &Info,
+   clangd::Diag &Diag) override {
+  Diag.Message = KDiagMsg.str();
+}
+  };
+
+  Annotations Code("[[test]]; /* error-ok */");
+  TestTU TU;
+  TU.Code = Code.code().str();
+  TU.Hooks.emplace_back(new Hooks);
+
+  auto AST = TU.build();
+  EXPECT_THAT(AST.getDiagnostics(),
+  testing::Contains(Diag(Code.range(), KDiagMsg.str(;
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -46,6 +46,7 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Path.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -119,13 +120,17 @@
   }
 
   // Prepare inputs and build CompilerInvocation (parsed compile command).
-  bool buildInvocation(const ThreadsafeFS &TFS,
-   llvm::Optional Contents) {
-StoreDiags CaptureInvocationDiags;
+  bool buildInvocation(
+  const ThreadsafeFS &TFS, llvm::Optional Contents,
+  llvm::ArrayRef> Hooks) {
 std::vector CC1Args;
 Inputs.CompileCommand = Cmd;
 Inputs.TFS = &TFS;
 Inputs.ClangTidyProvider = Opts.ClangTidyProvider;
+Inputs.ASTHooks = Hooks;
+
+StoreDiags CaptureInvocationDiags;
+CaptureInvocationDiags.setASTHooks(Hooks);
 if (Contents.hasValue()) {
   Inputs.Contents = *Contents;
   log("Imaginary source file contents:\n{0}", Inputs.Contents);
@@ -252,7 +257,15 @@
   Opts.ConfigProvider, nullptr);
   WithContext Ctx(ContextProvider(""));
   Checker C(File, Opts);
-  if (!C.buildCommand(TFS) || !C.buildInvocation(TFS, Contents) ||
+  std::vector> Hooks;
+  if (Opts.FeatureModules) {
+for (auto &M : *Opts.FeatureModules) {
+  if (auto H = M.astHooks())
+Hooks.push_back(std::move(H));
+}
+  }
+
+  if (!C.buildCommand(TFS) || !C.bui

[PATCH] D98128: [clang][clangd] Avoid inconsistent target creation

2021-03-12 Thread Tommy Chiang via Phabricator via cfe-commits
oToToT added a comment.

Kindly ping.

Maybe I should add a test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98128

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


[PATCH] D96976: [analyzer] Fix reinterpret_cast handling for pointer-to-member

2021-03-12 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

@steakhal, your views?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96976

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


[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-12 Thread Tim Keith via Phabricator via cfe-commits
tskeith added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:293
+  driverPath = driverPath.substr(0, driverPath.size() - 9);
+  return driverPath.append("/../tools/flang/include/flang/");
+}

arnamoy10 wrote:
> tskeith wrote:
> > Does this work for an install? I think there the path would be 
> > `include/flang` rather than `tools/flang/include/flang`.
> You are probably right, I am giving the path w.r.t a build.  Can we make the 
> assumption that there should be always an install?  Or do we determine if we 
> flang-new is coming from build or install (by checking if a module file is 
> present through ls)  and then set the path accordingly?
I think it should work in a build or an install. The `flang/tools/f18/flang` 
script checks for `include/flang` first and if that doesn't exist it uses 
`tools/flang/include/flang` so you could do the same. It would be good if we 
could fix the build or install so that the location is consistent.


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

https://reviews.llvm.org/D97080

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


[PATCH] D98502: [clang][Checkers] Extend PthreadLockChecker state dump (NFC).

2021-03-12 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: martong, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: Szelethus.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add printing of map 'DestroyRetVal'.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98502

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


Index: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -302,7 +302,6 @@
   state = state->set(lockR, LockState::getUnlocked());
   } else
 state = state->set(lockR, LockState::getDestroyed());
-
   // Removing the map entry (lockR, sym) from DestroyRetVal as the lock state 
is
   // now resolved.
   state = state->remove(lockR);
@@ -339,7 +338,16 @@
 }
   }
 
-  // TODO: Dump destroyed mutex symbols?
+  DestroyRetValTy DRV = State->get();
+  if (!DRV.isEmpty()) {
+Out << Sep << "Mutex destroys with unknown result:" << NL;
+for (auto I : DRV) {
+  I.first->dumpToStream(Out);
+  Out << ": ";
+  I.second->dumpToStream(Out);
+  Out << NL;
+}
+  }
 }
 
 void PthreadLockChecker::AcquirePthreadLock(const CallEvent &Call,


Index: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -302,7 +302,6 @@
   state = state->set(lockR, LockState::getUnlocked());
   } else
 state = state->set(lockR, LockState::getDestroyed());
-
   // Removing the map entry (lockR, sym) from DestroyRetVal as the lock state is
   // now resolved.
   state = state->remove(lockR);
@@ -339,7 +338,16 @@
 }
   }
 
-  // TODO: Dump destroyed mutex symbols?
+  DestroyRetValTy DRV = State->get();
+  if (!DRV.isEmpty()) {
+Out << Sep << "Mutex destroys with unknown result:" << NL;
+for (auto I : DRV) {
+  I.first->dumpToStream(Out);
+  Out << ": ";
+  I.second->dumpToStream(Out);
+  Out << NL;
+}
+  }
 }
 
 void PthreadLockChecker::AcquirePthreadLock(const CallEvent &Call,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-12 Thread Stelios Ioannou via Phabricator via cfe-commits
stelios-arm updated this revision to Diff 330230.
stelios-arm marked an inline comment as done.
stelios-arm added a comment.

1. Removed a redundant comment
2. Removed the changes made in the `test/CodeGen/arm_acle.c`, since the test is 
disabled.
3. Added a clang preprocessor test to check the presence and absence of the 
`__ARM_FEATURE_RNG` macro.


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

https://reviews.llvm.org/D98264

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/builtins-arm64.c
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/rand.ll
  llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir

Index: llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
===
--- llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
+++ llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
@@ -100,11 +100,11 @@
   bb.0:
 liveins: $x0
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 renamable $x8 = MOVZXi 15309, 0
 renamable $x8 = MOVKXi renamable $x8, 26239, 16
 STRXui renamable $x8, renamable $x0, 0, implicit killed $x8 :: (store 8)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRXui killed renamable  $x8, renamable killed $x0, 1, implicit killed $x8 :: (store 8)
 RET undef $lr
 
@@ -134,9 +134,9 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 STRXui renamable $x8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRXui killed renamable  $x8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
@@ -166,9 +166,9 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 STRWui renamable $w8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRWui killed renamable $w8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
@@ -275,10 +275,10 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 renamable $w8 = ORRWrs $wzr, killed renamable $w8, 0, implicit-def $x8
 STRWui renamable $w8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRWui killed renamable $w8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
Index: llvm/test/CodeGen/AArch64/rand.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/rand.ll
@@ -0,0 +1,38 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64 -mcpu=neoverse-v1 -mattr=+rand %s -o - | FileCheck %s
+
+define  i32 @rndr(i64* %__addr) {
+; CHECK-LABEL: rndr:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mrs x8, RNDR
+; CHECK-NEXT:cset w9, eq
+; CHECK-NEXT:str x8, [x0]
+; CHECK-NEXT:and w0, w9, #0x1
+; CHECK-NEXT:ret
+  %1 = tail call { i64, i1 } @llvm.aarch64.rndr()
+  %2 = extractvalue { i64, i1 } %1, 0
+  %3 = extractvalue { i64, i1 } %1, 1
+  store i64 %2, i64* %__addr, align 8
+  %4 = zext i1 %3 to i32
+  ret i32 %4
+}
+
+
+define  i32 @rndrrs(i64*  %__addr) {
+; CHECK-LABEL: rndrrs:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mrs x8, RNDRRS
+; CHECK-NEXT:cset w9, eq
+; CHECK-NEXT:str x8, [x0]
+; CHECK-NEXT:and w0, w9, #0x1
+; CHECK-NEXT:ret
+  %1 = tail call { i64, i1 } @llvm.aarch64.rndrrs()
+  %2 = extractvalue { i64, i1 } %1, 0
+  %3 = extractvalue { i64, i1 } %1, 1
+  store i64 %2, i64* %__addr, align 8
+  %4 = zext i1 %3 to i32
+  ret i32 %4
+}
+
+declare { i64, i1 } @llvm.aarch64.rndr()
+declare { i64, i1 } @llvm.aarch64.rndrrs()
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -607,7 +607,9 @@
 def AArch64stnp : SDNode<"AArch64ISD::STNP", SDT_AArch64stnp, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
 
 def AArch64tbl : SDNode<"AArch64ISD::TBL", SDT_AArch64TBL>;
-
+def AArch64mrs : SDNode<"AArch64ISD::MRS",
+SDTypeProfile<1, 1, [SDTCisVT<0, i64>, SDTCisVT<1, i32>]>,
+

[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-12 Thread Stelios Ioannou via Phabricator via cfe-commits
stelios-arm added inline comments.



Comment at: clang/test/CodeGen/arm_acle.c:908
+#if __ARM_64BIT_STATE && defined(__ARM_FEATURE_RNG)
+// AArch64-v8_3-LABEL: @test_rndr(
+// AArch64-v8_3-NEXT:  entry:

SjoerdMeijer wrote:
> Not sure if I am surprised that this works This is (re)using tag 
> `AArch64-v8_3` and for the other tests that use this and don't have RNG set, 
> I was expecting FileCheck to complain about this, not sure if I am missing 
> something though.
It turns out that this test is disabled 
(https://github.com/llvm/llvm-project/commit/6fcd4e080f09c9765d6e0ea03b1da91669c8509a).
 I am going to remove the changes in this file. 


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

https://reviews.llvm.org/D98264

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


[PATCH] D98504: [clang][Checkers] Fix state cleanup at dead symbol.

2021-03-12 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: martong, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: Szelethus.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It is possible that an entry in 'DestroyRetVal' lives longer
than an entry in 'LockMap' if not removed at checkDeadSymbols.
The added test case demonstrates this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98504

Files:
  clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
  clang/test/Analysis/pthreadlock.c


Index: clang/test/Analysis/pthreadlock.c
===
--- clang/test/Analysis/pthreadlock.c
+++ clang/test/Analysis/pthreadlock.c
@@ -513,3 +513,9 @@
   fake_system_function();
   pthread_mutex_lock(pmtx); // expected-warning{{This lock has already been 
acquired}}
 }
+
+void nocrash1(pthread_mutex_t *mutex) {
+  int ret = pthread_mutex_destroy(mutex);
+  if (ret == 0) // no crash
+;
+}
Index: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -646,8 +646,10 @@
 
   for (auto I : State->get()) {
 // Stop tracking dead mutex regions as well.
-if (!SymReaper.isLiveRegion(I.first))
+if (!SymReaper.isLiveRegion(I.first)) {
   State = State->remove(I.first);
+  State = State->remove(I.first);
+}
   }
 
   // TODO: We probably need to clean up the lock stack as well.


Index: clang/test/Analysis/pthreadlock.c
===
--- clang/test/Analysis/pthreadlock.c
+++ clang/test/Analysis/pthreadlock.c
@@ -513,3 +513,9 @@
   fake_system_function();
   pthread_mutex_lock(pmtx); // expected-warning{{This lock has already been acquired}}
 }
+
+void nocrash1(pthread_mutex_t *mutex) {
+  int ret = pthread_mutex_destroy(mutex);
+  if (ret == 0) // no crash
+;
+}
Index: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -646,8 +646,10 @@
 
   for (auto I : State->get()) {
 // Stop tracking dead mutex regions as well.
-if (!SymReaper.isLiveRegion(I.first))
+if (!SymReaper.isLiveRegion(I.first)) {
   State = State->remove(I.first);
+  State = State->remove(I.first);
+}
   }
 
   // TODO: We probably need to clean up the lock stack as well.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98505: [clangd] Propagate data in diagnostics

2021-03-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98505

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/refactor/Tweak.h

Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- clang-tools-extra/clangd/refactor/Tweak.h
+++ clang-tools-extra/clangd/refactor/Tweak.h
@@ -26,6 +26,7 @@
 #include "index/Index.h"
 #include "support/Path.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
@@ -64,6 +65,8 @@
 unsigned SelectionEnd;
 /// The AST nodes that were selected.
 SelectionTree ASTSelection;
+/// Diagnostics related to this selection.
+llvm::ArrayRef Diags;
 // FIXME: provide a way to get sources and ASTs for other files.
   };
 
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -406,6 +406,12 @@
   /// textDocument.publishDiagnostics.relatedInformation.
   bool DiagnosticRelatedInformation = false;
 
+  /// Whether the client supports the `data` property which is preserved between
+  /// a `textDocument/publishDiagnostics` and * `textDocument/codeAction`
+  /// request.
+  /// textDocument.publishDiagnostics.dataSupport
+  bool DiagnosticDataSupport = false;
+
   /// Whether the client accepts diagnostics with category attached to it
   /// using the "category" extension.
   /// textDocument.publishDiagnostics.categorySupport
@@ -840,6 +846,12 @@
   /// Only with capability textDocument.publishDiagnostics.codeActionsInline.
   /// (These actions can also be obtained using textDocument/codeAction).
   llvm::Optional> codeActions;
+
+  /// A data entry field that is preserved between a
+  /// `textDocument/publishDiagnostics` notification
+  /// and`textDocument/codeAction` request.
+  /// For clangd, this is always an array, with possibly zero elements.
+  llvm::json::Array data;
 };
 llvm::json::Value toJSON(const Diagnostic &);
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -331,6 +331,8 @@
 R.DiagnosticFixes = *CodeActions;
   if (auto RelatedInfo = Diagnostics->getBoolean("relatedInformation"))
 R.DiagnosticRelatedInformation = *RelatedInfo;
+  if (auto DataSupport = Diagnostics->getBoolean("dataSupport"))
+R.DiagnosticDataSupport = *DataSupport;
 }
 if (auto *Completion = TextDocument->getObject("completion")) {
   if (auto *Item = Completion->getObject("completionItem")) {
@@ -593,6 +595,8 @@
 Diag["source"] = D.source;
   if (D.relatedInformation)
 Diag["relatedInformation"] = *D.relatedInformation;
+  if (!D.data.empty())
+Diag["data"] = llvm::json::Array(D.data);
   // FIXME: workaround for older gcc/clang
   return std::move(Diag);
 }
@@ -600,7 +604,11 @@
 bool fromJSON(const llvm::json::Value &Params, Diagnostic &R,
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Params, P);
-  return O && O.map("range", R.range) && O.map("message", R.message) &&
+  if (!O)
+return false;
+  if (auto *Data = Params.getAsObject()->getArray("data"))
+R.data = *Data;
+  return O.map("range", R.range) && O.map("message", R.message) &&
  mapOptOrNull(Params, "severity", R.severity, P) &&
  mapOptOrNull(Params, "category", R.category, P) &&
  mapOptOrNull(Params, "code", R.code, P) &&
Index: clang-tools-extra/clangd/Diagnostics.h
===
--- clang-tools-extra/clangd/Diagnostics.h
+++ clang-tools-extra/clangd/Diagnostics.h
@@ -21,10 +21,12 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSet.h"
+#include "llvm/Support/JSON.h"
 #include "llvm/Support/SourceMgr.h"
 #include 
 #include 
 #include 
+#include 
 
 namespace clang {
 namespace tidy {
@@ -51,6 +53,11 @@
   /// If true, Clangd will add a number of available fixes to the diagnostic's
   /// message.
   bool DisplayFixesCount = true;
+
+  /// If true, Clangd will populate the data field in LSP diagnostic
+  /// representation. This is used to prevent extra data transfer with old
+  /// clients that doesn't support data field.
+  bool PreserveData = true;
 }

[clang] 731b3d7 - [clang] Use Constant::getAllOnesValue helper. NFCI.

2021-03-12 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-03-12T15:16:36Z
New Revision: 731b3d766420ce05726174ff0e1527dca8a63791

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

LOG: [clang] Use Constant::getAllOnesValue helper. NFCI.

Avoid -1ULL which MSVC tends to complain about

Added: 


Modified: 
clang/lib/CodeGen/CGExprScalar.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 4774f92a2eed..ef3e27ecec99 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -3125,7 +3125,7 @@ void 
ScalarExprEmitter::EmitUndefinedBehaviorIntegerDivAndRemCheck(
 
 llvm::Value *IntMin =
   Builder.getInt(llvm::APInt::getSignedMinValue(Ty->getBitWidth()));
-llvm::Value *NegOne = llvm::ConstantInt::get(Ty, -1ULL);
+llvm::Value *NegOne = llvm::Constant::getAllOnesValue(Ty);
 
 llvm::Value *LHSCmp = Builder.CreateICmpNE(Ops.LHS, IntMin);
 llvm::Value *RHSCmp = Builder.CreateICmpNE(Ops.RHS, NegOne);



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


[PATCH] D98504: [clang][Checkers] Fix state cleanup at dead symbol.

2021-03-12 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 330243.
balazske added a comment.

Improved commit message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98504

Files:
  clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
  clang/test/Analysis/pthreadlock.c


Index: clang/test/Analysis/pthreadlock.c
===
--- clang/test/Analysis/pthreadlock.c
+++ clang/test/Analysis/pthreadlock.c
@@ -513,3 +513,9 @@
   fake_system_function();
   pthread_mutex_lock(pmtx); // expected-warning{{This lock has already been 
acquired}}
 }
+
+void nocrash1(pthread_mutex_t *mutex) {
+  int ret = pthread_mutex_destroy(mutex);
+  if (ret == 0) // no crash
+;
+}
Index: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -646,8 +646,10 @@
 
   for (auto I : State->get()) {
 // Stop tracking dead mutex regions as well.
-if (!SymReaper.isLiveRegion(I.first))
+if (!SymReaper.isLiveRegion(I.first)) {
   State = State->remove(I.first);
+  State = State->remove(I.first);
+}
   }
 
   // TODO: We probably need to clean up the lock stack as well.


Index: clang/test/Analysis/pthreadlock.c
===
--- clang/test/Analysis/pthreadlock.c
+++ clang/test/Analysis/pthreadlock.c
@@ -513,3 +513,9 @@
   fake_system_function();
   pthread_mutex_lock(pmtx); // expected-warning{{This lock has already been acquired}}
 }
+
+void nocrash1(pthread_mutex_t *mutex) {
+  int ret = pthread_mutex_destroy(mutex);
+  if (ret == 0) // no crash
+;
+}
Index: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -646,8 +646,10 @@
 
   for (auto I : State->get()) {
 // Stop tracking dead mutex regions as well.
-if (!SymReaper.isLiveRegion(I.first))
+if (!SymReaper.isLiveRegion(I.first)) {
   State = State->remove(I.first);
+  State = State->remove(I.first);
+}
   }
 
   // TODO: We probably need to clean up the lock stack as well.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98277: [release][docs] List all cores Arm has added support for in LLVM 12.

2021-03-12 Thread Kristof Beyls via Phabricator via cfe-commits
kristof.beyls accepted this revision.
kristof.beyls added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98277

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


[PATCH] D98514: [RGT] Fix ASTMatchersTest so all assertions are executed

2021-03-12 Thread Paul Robinson via Phabricator via cfe-commits
probinson created this revision.
probinson added a reviewer: Prazek.
probinson requested review of this revision.
Herald added a project: clang.

Some 'if' conditions turn out always to be false, so change test
expectations to match.

Found by the Rotten Green Tests project.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98514

Files:
  clang/unittests/ASTMatchers/ASTMatchersTest.h


Index: clang/unittests/ASTMatchers/ASTMatchersTest.h
===
--- clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -372,12 +372,8 @@
 ExpectedName(std::string(ExpectedName)) {}
 
   void onEndOfTranslationUnit() override {
-if (ExpectedCount != -1) {
-  EXPECT_EQ(ExpectedCount, Count);
-}
-if (!ExpectedName.empty()) {
-  EXPECT_EQ(ExpectedName, Name);
-}
+EXPECT_EQ(ExpectedCount, -1);
+EXPECT_TRUE(ExpectedName.empty());
 Count = 0;
 Name.clear();
   }
@@ -389,25 +385,21 @@
 
   bool run(const BoundNodes *Nodes) override {
 const BoundNodes::IDToNodeMap &M = Nodes->getMap();
-if (Nodes->getNodeAs(Id)) {
-  ++Count;
-  if (const NamedDecl *Named = Nodes->getNodeAs(Id)) {
-Name = Named->getNameAsString();
-  } else if (const NestedNameSpecifier *NNS =
- Nodes->getNodeAs(Id)) {
-llvm::raw_string_ostream OS(Name);
-NNS->print(OS, PrintingPolicy(LangOptions()));
-  }
-  BoundNodes::IDToNodeMap::const_iterator I = M.find(Id);
-  EXPECT_NE(M.end(), I);
-  if (I != M.end()) {
-EXPECT_EQ(Nodes->getNodeAs(Id), I->second.get());
-  }
-  return true;
+EXPECT_NE(Nodes->getNodeAs(Id), nullptr);
+++Count;
+if (const NamedDecl *Named = Nodes->getNodeAs(Id)) {
+  Name = Named->getNameAsString();
+} else if (const NestedNameSpecifier *NNS =
+   Nodes->getNodeAs(Id)) {
+  llvm::raw_string_ostream OS(Name);
+  NNS->print(OS, PrintingPolicy(LangOptions()));
+}
+BoundNodes::IDToNodeMap::const_iterator I = M.find(Id);
+EXPECT_NE(M.end(), I);
+if (I != M.end()) {
+  EXPECT_EQ(Nodes->getNodeAs(Id), I->second.get());
 }
-EXPECT_TRUE(M.count(Id) == 0 ||
-M.find(Id)->second.template get() == nullptr);
-return false;
+return true;
   }
 
   bool run(const BoundNodes *Nodes, ASTContext *Context) override {


Index: clang/unittests/ASTMatchers/ASTMatchersTest.h
===
--- clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -372,12 +372,8 @@
 ExpectedName(std::string(ExpectedName)) {}
 
   void onEndOfTranslationUnit() override {
-if (ExpectedCount != -1) {
-  EXPECT_EQ(ExpectedCount, Count);
-}
-if (!ExpectedName.empty()) {
-  EXPECT_EQ(ExpectedName, Name);
-}
+EXPECT_EQ(ExpectedCount, -1);
+EXPECT_TRUE(ExpectedName.empty());
 Count = 0;
 Name.clear();
   }
@@ -389,25 +385,21 @@
 
   bool run(const BoundNodes *Nodes) override {
 const BoundNodes::IDToNodeMap &M = Nodes->getMap();
-if (Nodes->getNodeAs(Id)) {
-  ++Count;
-  if (const NamedDecl *Named = Nodes->getNodeAs(Id)) {
-Name = Named->getNameAsString();
-  } else if (const NestedNameSpecifier *NNS =
- Nodes->getNodeAs(Id)) {
-llvm::raw_string_ostream OS(Name);
-NNS->print(OS, PrintingPolicy(LangOptions()));
-  }
-  BoundNodes::IDToNodeMap::const_iterator I = M.find(Id);
-  EXPECT_NE(M.end(), I);
-  if (I != M.end()) {
-EXPECT_EQ(Nodes->getNodeAs(Id), I->second.get());
-  }
-  return true;
+EXPECT_NE(Nodes->getNodeAs(Id), nullptr);
+++Count;
+if (const NamedDecl *Named = Nodes->getNodeAs(Id)) {
+  Name = Named->getNameAsString();
+} else if (const NestedNameSpecifier *NNS =
+   Nodes->getNodeAs(Id)) {
+  llvm::raw_string_ostream OS(Name);
+  NNS->print(OS, PrintingPolicy(LangOptions()));
+}
+BoundNodes::IDToNodeMap::const_iterator I = M.find(Id);
+EXPECT_NE(M.end(), I);
+if (I != M.end()) {
+  EXPECT_EQ(Nodes->getNodeAs(Id), I->second.get());
 }
-EXPECT_TRUE(M.count(Id) == 0 ||
-M.find(Id)->second.template get() == nullptr);
-return false;
+return true;
   }
 
   bool run(const BoundNodes *Nodes, ASTContext *Context) override {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96976: [analyzer] Fix reinterpret_cast handling for pointer-to-member

2021-03-12 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D96976#2622039 , @RedDocMD wrote:

> @steakhal, your views?

I'm somewhat busy. If it's not urgent, I would postpone this.
Ping me in a few weeks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96976

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


[PATCH] D98499: [clangd] Introduce ASTHooks to FeatureModules

2021-03-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 330258.
kadircet added a comment.

- Add tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98499

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/FeatureModule.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestTU.h

Index: clang-tools-extra/clangd/unittests/TestTU.h
===
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -25,6 +25,7 @@
 #include "support/Path.h"
 #include "llvm/ADT/StringMap.h"
 #include "gtest/gtest.h"
+#include 
 #include 
 #include 
 #include 
@@ -76,6 +77,8 @@
   // to eliminate this option some day.
   bool OverlayRealFileSystemForModules = false;
 
+  std::vector> Hooks;
+
   // By default, build() will report Error diagnostics as GTest errors.
   // Suppress this behavior by adding an 'error-ok' comment to the code.
   ParsedAST build() const;
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -36,6 +36,7 @@
   FS.Files[ImportThunk] = ThunkContents;
 
   ParseInputs Inputs;
+  Inputs.ASTHooks = Hooks;
   auto &Argv = Inputs.CompileCommand.CommandLine;
   Argv = {"clang"};
   // FIXME: this shouldn't need to be conditional, but it breaks a
@@ -97,6 +98,7 @@
   MockFS FS;
   auto Inputs = inputs(FS);
   StoreDiags Diags;
+  Diags.setASTHooks(Inputs.ASTHooks);
   auto CI = buildCompilerInvocation(Inputs, Diags);
   assert(CI && "Failed to build compilation invocation.");
   if (OverlayRealFileSystemForModules)
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1346,6 +1346,24 @@
  });
 }
 
+TEST(ParsedASTTest, ModuleSawDiag) {
+  static constexpr const llvm::StringLiteral KDiagMsg = "StampedDiag";
+  struct Hooks : public FeatureModule::ParseASTHooks {
+void sawDiagnostic(const clang::Diagnostic &Info,
+   clangd::Diag &Diag) override {
+  Diag.Message = KDiagMsg.str();
+}
+  };
+
+  Annotations Code("[[test]]; /* error-ok */");
+  TestTU TU;
+  TU.Code = Code.code().str();
+  TU.Hooks.emplace_back(new Hooks);
+
+  auto AST = TU.build();
+  EXPECT_THAT(AST.getDiagnostics(),
+  testing::Contains(Diag(Code.range(), KDiagMsg.str(;
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -365,6 +365,27 @@
   // And immediately shut down. FeatureModule destructor verifies we blocked.
 }
 
+TEST_F(LSPTest, DiagModuleTest) {
+  static constexpr llvm::StringLiteral DiagMsg = "DiagMsg";
+  class DiagModule final : public FeatureModule {
+struct DiagHooks : public ParseASTHooks {
+  void sawDiagnostic(const clang::Diagnostic &, clangd::Diag &D) override {
+D.Message = DiagMsg.str();
+  }
+};
+
+  public:
+std::unique_ptr astHooks() override {
+  return std::make_unique();
+}
+  };
+  FeatureModules.add(std::make_unique());
+
+  auto &Client = start();
+  Client.didOpen("foo.cpp", "test;");
+  EXPECT_THAT(Client.diagnostics("foo.cpp"),
+  llvm::ValueIs(testing::ElementsAre(DiagMessage(DiagMsg;
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -46,6 +46,7 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Path.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -119,13 +120,17 @@
   }
 
   // Prepare inputs and build CompilerInvocation (parsed compile command).
-  bool buildInvocation(const ThreadsafeFS &TFS,
-   llvm::Optional Contents) {
-StoreDiags CaptureInvocationDiags;
+  bool buildInvocation(
+  const Thre

[clang] b5fae4b - [PowerPC] Add more missing overloads to altivec.h

2021-03-12 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-03-12T10:51:57-06:00
New Revision: b5fae4b9b2fd0ac8f0ad99178f876dc78ba5613f

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

LOG: [PowerPC] Add more missing overloads to altivec.h

We are missing more predicate forms for 'vector double' and some
tests. This adds the missing overloads and completes the set of
test cases for them.

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-vsx.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 55f04d0efbd6..ee39b521c0ca 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -16364,10 +16364,18 @@ static __inline__ int __ATTRS_o_ai vec_any_lt(vector 
unsigned __int128 __a,
 
 /* vec_any_nan */
 
-static __inline__ int __attribute__((__always_inline__))
-vec_any_nan(vector float __a) {
+static __inline__ int __ATTRS_o_ai vec_any_nan(vector float __a) {
+#ifdef __VSX__
+  return __builtin_vsx_xvcmpeqsp_p(__CR6_LT_REV, __a, __a);
+#else
   return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, __a, __a);
+#endif
 }
+#ifdef __VSX__
+static __inline__ int __ATTRS_o_ai vec_any_nan(vector double __a) {
+  return __builtin_vsx_xvcmpeqdp_p(__CR6_LT_REV, __a, __a);
+}
+#endif
 
 /* vec_any_ne */
 
@@ -16571,38 +16579,91 @@ static __inline__ int __ATTRS_o_ai vec_any_ne(vector 
unsigned __int128 __a,
 
 /* vec_any_nge */
 
-static __inline__ int __attribute__((__always_inline__))
-vec_any_nge(vector float __a, vector float __b) {
+static __inline__ int __ATTRS_o_ai vec_any_nge(vector float __a,
+   vector float __b) {
+#ifdef __VSX__
+  return __builtin_vsx_xvcmpgesp_p(__CR6_LT_REV, __a, __b);
+#else
   return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, __a, __b);
+#endif
+}
+
+#ifdef __VSX__
+static __inline__ int __ATTRS_o_ai vec_any_nge(vector double __a,
+   vector double __b) {
+  return __builtin_vsx_xvcmpgedp_p(__CR6_LT_REV, __a, __b);
 }
+#endif
 
 /* vec_any_ngt */
 
-static __inline__ int __attribute__((__always_inline__))
-vec_any_ngt(vector float __a, vector float __b) {
+static __inline__ int __ATTRS_o_ai vec_any_ngt(vector float __a,
+   vector float __b) {
+#ifdef __VSX__
+  return __builtin_vsx_xvcmpgtsp_p(__CR6_LT_REV, __a, __b);
+#else
   return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, __a, __b);
+#endif
 }
 
+#ifdef __VSX__
+static __inline__ int __ATTRS_o_ai vec_any_ngt(vector double __a,
+   vector double __b) {
+  return __builtin_vsx_xvcmpgtdp_p(__CR6_LT_REV, __a, __b);
+}
+#endif
+
 /* vec_any_nle */
 
-static __inline__ int __attribute__((__always_inline__))
-vec_any_nle(vector float __a, vector float __b) {
+static __inline__ int __ATTRS_o_ai vec_any_nle(vector float __a,
+   vector float __b) {
+#ifdef __VSX__
+  return __builtin_vsx_xvcmpgesp_p(__CR6_LT_REV, __b, __a);
+#else
   return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, __b, __a);
+#endif
+}
+
+#ifdef __VSX__
+static __inline__ int __ATTRS_o_ai vec_any_nle(vector double __a,
+   vector double __b) {
+  return __builtin_vsx_xvcmpgedp_p(__CR6_LT_REV, __b, __a);
 }
+#endif
 
 /* vec_any_nlt */
 
-static __inline__ int __attribute__((__always_inline__))
-vec_any_nlt(vector float __a, vector float __b) {
+static __inline__ int __ATTRS_o_ai vec_any_nlt(vector float __a,
+   vector float __b) {
+#ifdef __VSX__
+  return __builtin_vsx_xvcmpgtsp_p(__CR6_LT_REV, __b, __a);
+#else
   return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, __b, __a);
+#endif
 }
 
+#ifdef __VSX__
+static __inline__ int __ATTRS_o_ai vec_any_nlt(vector double __a,
+   vector double __b) {
+  return __builtin_vsx_xvcmpgtdp_p(__CR6_LT_REV, __b, __a);
+}
+#endif
+
 /* vec_any_numeric */
 
-static __inline__ int __attribute__((__always_inline__))
-vec_any_numeric(vector float __a) {
+static __inline__ int __ATTRS_o_ai vec_any_numeric(vector float __a) {
+#ifdef __VSX__
+  return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ_REV, __a, __a);
+#else
   return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, __a, __a);
+#endif
+}
+
+#ifdef __VSX__
+static __inline__ int __ATTRS_o_ai vec_any_numeric(vector double __a) {
+  return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ_REV, __a, __a);
 }
+#endif
 
 /* vec_any_out */
 

diff  --git a/clang/test/CodeGen/builtins-ppc-vsx.c 
b/clang/test/CodeGen/builtins-ppc-vsx.c
index 398a5023eaf3..e13f1ee1c058 100644
--- a/clang/test/CodeGen/builtins-ppc-vsx.c
+++ b/clang/test/CodeGen/builtins-ppc-vsx.c
@@ -93,6 +93,74 @@ v

[PATCH] D98488: [CodeCompletion] Avoid spurious signature help for init-list args

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

thanks, lgtm!




Comment at: clang/lib/Parse/Parser.cpp:2117
 if (S->getFlags() & Scope::FnScope) {
+  cutOffParsing();
   Actions.CodeCompleteOrdinaryName(getCurScope(),

i know you are keeping it as is, but what about just calling cutoffparsing 
before entering the loop once, rather than in 3 places.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98488

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


[PATCH] D98388: [RISCV][Clang] Add RVV vle/vse intrinsic functions.

2021-03-12 Thread Zakk Chen via Phabricator via cfe-commits
khchen marked 6 inline comments as done.
khchen added inline comments.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:689
+  skew = 1;
+for (unsigned i = 0; i < PermuteOperands.size(); ++i) {
+  if (i != PermuteOperands[i])

rogfer01 wrote:
> These are only suggestions of sanity checks we could do here:
> - I understand `PermuteOperand.size()` should be `<=` than 
> `CTypeOrder.size()`. 
> - Also `PermuteOperands[i] + skew` should be `<` than `CTypeOrder.size()`. 
> right?
> - We could check the result is indeed a permutation (e.g. sorting a copy of 
> `CTypeOrder` is equivalent to the iota above). This one might be expensive 
> although the sequences are short, not sure.
> Also PermuteOperands[i] + skew should be < than CTypeOrder.size(). right
Yes.
I did the different way to do sanity checks, maybe it's better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98388

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


[PATCH] D98483: [clang] Mark re-injected tokens appropriately during pragma handling

2021-03-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 330266.
kadircet added a comment.

- Introduce a helper to mark tokens as reinjected


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98483

Files:
  clang/lib/Parse/ParsePragma.cpp
  clang/unittests/Tooling/Syntax/TokensTest.cpp


Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -1037,4 +1037,13 @@
   IsEmpty());
 }
 
+TEST_F(TokenCollectorTest, Pragmas) {
+  // Tokens coming from concatenations.
+  recordTokens(R"cpp(
+void foo() {
+  #pragma unroll 4
+  for(int i=0;i<4;++i);
+}
+  )cpp");
+}
 } // namespace
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -14,11 +14,13 @@
 #include "clang/Basic/PragmaKinds.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/Token.h"
 #include "clang/Parse/LoopHint.h"
 #include "clang/Parse/ParseDiagnostic.h"
 #include "clang/Parse/Parser.h"
 #include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/Scope.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringSwitch.h"
 using namespace clang;
 
@@ -292,6 +294,10 @@
 Token &FirstToken) override;
 };
 
+void markAsReinjectedForRelexing(llvm::MutableArrayRef Toks) {
+  for (auto &T : Toks)
+T.setFlag(clang::Token::IsReinjected);
+}
 }  // end namespace
 
 void Parser::initializePragmaHandlers() {
@@ -2621,6 +2627,7 @@
   TokenVector.push_back(EoF);
   // We must allocate this array with new because EnterTokenStream is going to
   // delete it later.
+  markAsReinjectedForRelexing(TokenVector);
   auto TokenArray = std::make_unique(TokenVector.size());
   std::copy(TokenVector.begin(), TokenVector.end(), TokenArray.get());
   auto Value = new (PP.getPreprocessorAllocator())
@@ -3178,6 +3185,7 @@
   EOFTok.setLocation(Tok.getLocation());
   ValueList.push_back(EOFTok); // Terminates expression for parsing.
 
+  markAsReinjectedForRelexing(ValueList);
   Info.Toks = 
llvm::makeArrayRef(ValueList).copy(PP.getPreprocessorAllocator());
 
   Info.PragmaName = PragmaName;
@@ -3634,6 +3642,7 @@
 EOFTok.setLocation(EndLoc);
 AttributeTokens.push_back(EOFTok);
 
+markAsReinjectedForRelexing(AttributeTokens);
 Info->Tokens =
 
llvm::makeArrayRef(AttributeTokens).copy(PP.getPreprocessorAllocator());
   }


Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -1037,4 +1037,13 @@
   IsEmpty());
 }
 
+TEST_F(TokenCollectorTest, Pragmas) {
+  // Tokens coming from concatenations.
+  recordTokens(R"cpp(
+void foo() {
+  #pragma unroll 4
+  for(int i=0;i<4;++i);
+}
+  )cpp");
+}
 } // namespace
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -14,11 +14,13 @@
 #include "clang/Basic/PragmaKinds.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/Token.h"
 #include "clang/Parse/LoopHint.h"
 #include "clang/Parse/ParseDiagnostic.h"
 #include "clang/Parse/Parser.h"
 #include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/Scope.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringSwitch.h"
 using namespace clang;
 
@@ -292,6 +294,10 @@
 Token &FirstToken) override;
 };
 
+void markAsReinjectedForRelexing(llvm::MutableArrayRef Toks) {
+  for (auto &T : Toks)
+T.setFlag(clang::Token::IsReinjected);
+}
 }  // end namespace
 
 void Parser::initializePragmaHandlers() {
@@ -2621,6 +2627,7 @@
   TokenVector.push_back(EoF);
   // We must allocate this array with new because EnterTokenStream is going to
   // delete it later.
+  markAsReinjectedForRelexing(TokenVector);
   auto TokenArray = std::make_unique(TokenVector.size());
   std::copy(TokenVector.begin(), TokenVector.end(), TokenArray.get());
   auto Value = new (PP.getPreprocessorAllocator())
@@ -3178,6 +3185,7 @@
   EOFTok.setLocation(Tok.getLocation());
   ValueList.push_back(EOFTok); // Terminates expression for parsing.
 
+  markAsReinjectedForRelexing(ValueList);
   Info.Toks = llvm::makeArrayRef(ValueList).copy(PP.getPreprocessorAllocator());
 
   Info.PragmaName = PragmaName;
@@ -3634,6 +3642,7 @@
 EOFTok.setLocation(EndLoc);
 AttributeTokens.push_back(EOFTok);
 
+markAsReinjectedForRelexing(AttributeTokens);
 Info->Tokens =
 llvm::makeArrayRef(AttributeTokens).copy(PP.getPreprocessorAllocator());

[PATCH] D98520: [OpenCL] Remove spurious atomic_fetch tablegen builtins

2021-03-12 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
svenvh added a project: clang.
Herald added subscribers: jfb, yaxunl.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.

The `int` and `long` versions of these builtins already provide the
necessary overloads for `intptr_t` and `uintptr_t` arguments, as
`ASTContext` defines `atomic_(u)intptr_t` in terms of the `int` or
`long` types.

Prior to this patch, calls to those builtins with particular argument
types resulted in call-is-ambiguous errors.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98520

Files:
  clang/lib/Sema/OpenCLBuiltins.td
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -39,6 +39,9 @@
 typedef unsigned long ulong;
 typedef unsigned short ushort;
 typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+typedef __INTPTR_TYPE__ intptr_t;
+typedef __UINTPTR_TYPE__ uintptr_t;
 typedef char char2 __attribute__((ext_vector_type(2)));
 typedef char char4 __attribute__((ext_vector_type(4)));
 typedef uchar uchar4 __attribute__((ext_vector_type(4)));
@@ -98,6 +101,24 @@
   size_t ws[2] = {2, 8};
   ndrange_t r = ndrange_2D(ws);
 }
+
+// Check that atomic_fetch_ functions can be called with (u)intptr_t arguments,
+// despite OpenCLBuiltins.td not providing explicit overloads for those types.
+void test_atomic_fetch(volatile __generic atomic_int *a_int,
+   volatile __generic atomic_intptr_t *a_intptr,
+   volatile __generic atomic_uintptr_t *a_uintptr) {
+  int i;
+  intptr_t ip;
+  uintptr_t uip;
+  ptrdiff_t ptrdiff;
+
+  i = atomic_fetch_add(a_int, i);
+  ip = atomic_fetch_add(a_intptr, ptrdiff);
+  uip = atomic_fetch_add(a_uintptr, ptrdiff);
+
+  ip = atomic_fetch_or(a_intptr, ip);
+  uip = atomic_fetch_or(a_uintptr, uip);
+}
 #endif
 
 kernel void basic_conversion() {
Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -1100,7 +1100,6 @@
 
   foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
   [AtomicLong, Long, Long], [AtomicULong, ULong, ULong],
-  [AtomicIntPtr, IntPtr, PtrDiff],
   [AtomicUIntPtr, UIntPtr, PtrDiff]] in {
 foreach ModOp = ["add", "sub"] in {
   def : Builtin<"atomic_fetch_" # ModOp,
@@ -1112,9 +,7 @@
 }
   }
   foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
-  [AtomicLong, Long, Long], [AtomicULong, ULong, ULong],
-  [AtomicIntPtr, IntPtr, IntPtr],
-  [AtomicUIntPtr, UIntPtr, UIntPtr]] in {
+  [AtomicLong, Long, Long], [AtomicULong, ULong, ULong]] 
in {
 foreach ModOp = ["or", "xor", "and", "min", "max"] in {
   def : Builtin<"atomic_fetch_" # ModOp,
   [TypePair[1], PointerType, GenericAS>, 
TypePair[2]]>;


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -39,6 +39,9 @@
 typedef unsigned long ulong;
 typedef unsigned short ushort;
 typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+typedef __INTPTR_TYPE__ intptr_t;
+typedef __UINTPTR_TYPE__ uintptr_t;
 typedef char char2 __attribute__((ext_vector_type(2)));
 typedef char char4 __attribute__((ext_vector_type(4)));
 typedef uchar uchar4 __attribute__((ext_vector_type(4)));
@@ -98,6 +101,24 @@
   size_t ws[2] = {2, 8};
   ndrange_t r = ndrange_2D(ws);
 }
+
+// Check that atomic_fetch_ functions can be called with (u)intptr_t arguments,
+// despite OpenCLBuiltins.td not providing explicit overloads for those types.
+void test_atomic_fetch(volatile __generic atomic_int *a_int,
+   volatile __generic atomic_intptr_t *a_intptr,
+   volatile __generic atomic_uintptr_t *a_uintptr) {
+  int i;
+  intptr_t ip;
+  uintptr_t uip;
+  ptrdiff_t ptrdiff;
+
+  i = atomic_fetch_add(a_int, i);
+  ip = atomic_fetch_add(a_intptr, ptrdiff);
+  uip = atomic_fetch_add(a_uintptr, ptrdiff);
+
+  ip = atomic_fetch_or(a_intptr, ip);
+  uip = atomic_fetch_or(a_uintptr, uip);
+}
 #endif
 
 kernel void basic_conversion() {
Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -1100,7 +1100,6 @@
 
   foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
   [AtomicLong, Long, Long], [AtomicULong, ULong, ULong]

[clang] f43ff34 - [clang] Mark re-injected tokens appropriately during pragma handling

2021-03-12 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-03-12T18:18:17+01:00
New Revision: f43ff34ae67a6557fe9fd1ba0e992da18bd102f7

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

LOG: [clang] Mark re-injected tokens appropriately during pragma handling

This hides such tokens from TokenWatcher, preventing crashes in clients
trying to match spelled and expanded tokens.

Fixes https://github.com/clangd/clangd/issues/712

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

Added: 


Modified: 
clang/lib/Parse/ParsePragma.cpp
clang/unittests/Tooling/Syntax/TokensTest.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index b9cdcf471d44..4ce8e4c4bb9d 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -14,11 +14,13 @@
 #include "clang/Basic/PragmaKinds.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/Token.h"
 #include "clang/Parse/LoopHint.h"
 #include "clang/Parse/ParseDiagnostic.h"
 #include "clang/Parse/Parser.h"
 #include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/Scope.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringSwitch.h"
 using namespace clang;
 
@@ -292,6 +294,10 @@ struct PragmaMaxTokensTotalHandler : public PragmaHandler {
 Token &FirstToken) override;
 };
 
+void markAsReinjectedForRelexing(llvm::MutableArrayRef Toks) {
+  for (auto &T : Toks)
+T.setFlag(clang::Token::IsReinjected);
+}
 }  // end namespace
 
 void Parser::initializePragmaHandlers() {
@@ -2619,6 +2625,7 @@ void PragmaMSPragma::HandlePragma(Preprocessor &PP,
   TokenVector.push_back(EoF);
   // We must allocate this array with new because EnterTokenStream is going to
   // delete it later.
+  markAsReinjectedForRelexing(TokenVector);
   auto TokenArray = std::make_unique(TokenVector.size());
   std::copy(TokenVector.begin(), TokenVector.end(), TokenArray.get());
   auto Value = new (PP.getPreprocessorAllocator())
@@ -3176,6 +3183,7 @@ static bool ParseLoopHintValue(Preprocessor &PP, Token 
&Tok, Token PragmaName,
   EOFTok.setLocation(Tok.getLocation());
   ValueList.push_back(EOFTok); // Terminates expression for parsing.
 
+  markAsReinjectedForRelexing(ValueList);
   Info.Toks = 
llvm::makeArrayRef(ValueList).copy(PP.getPreprocessorAllocator());
 
   Info.PragmaName = PragmaName;
@@ -3632,6 +3640,7 @@ void PragmaAttributeHandler::HandlePragma(Preprocessor 
&PP,
 EOFTok.setLocation(EndLoc);
 AttributeTokens.push_back(EOFTok);
 
+markAsReinjectedForRelexing(AttributeTokens);
 Info->Tokens =
 
llvm::makeArrayRef(AttributeTokens).copy(PP.getPreprocessorAllocator());
   }

diff  --git a/clang/unittests/Tooling/Syntax/TokensTest.cpp 
b/clang/unittests/Tooling/Syntax/TokensTest.cpp
index 7d5943bf2520..6a21be632d42 100644
--- a/clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -1037,4 +1037,13 @@ TEST_F(TokenBufferTest, ExpandedBySpelled) {
   IsEmpty());
 }
 
+TEST_F(TokenCollectorTest, Pragmas) {
+  // Tokens coming from concatenations.
+  recordTokens(R"cpp(
+void foo() {
+  #pragma unroll 4
+  for(int i=0;i<4;++i);
+}
+  )cpp");
+}
 } // namespace



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


[PATCH] D98483: [clang] Mark re-injected tokens appropriately during pragma handling

2021-03-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf43ff34ae67a: [clang] Mark re-injected tokens appropriately 
during pragma handling (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98483

Files:
  clang/lib/Parse/ParsePragma.cpp
  clang/unittests/Tooling/Syntax/TokensTest.cpp


Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -1037,4 +1037,13 @@
   IsEmpty());
 }
 
+TEST_F(TokenCollectorTest, Pragmas) {
+  // Tokens coming from concatenations.
+  recordTokens(R"cpp(
+void foo() {
+  #pragma unroll 4
+  for(int i=0;i<4;++i);
+}
+  )cpp");
+}
 } // namespace
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -14,11 +14,13 @@
 #include "clang/Basic/PragmaKinds.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/Token.h"
 #include "clang/Parse/LoopHint.h"
 #include "clang/Parse/ParseDiagnostic.h"
 #include "clang/Parse/Parser.h"
 #include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/Scope.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringSwitch.h"
 using namespace clang;
 
@@ -292,6 +294,10 @@
 Token &FirstToken) override;
 };
 
+void markAsReinjectedForRelexing(llvm::MutableArrayRef Toks) {
+  for (auto &T : Toks)
+T.setFlag(clang::Token::IsReinjected);
+}
 }  // end namespace
 
 void Parser::initializePragmaHandlers() {
@@ -2619,6 +2625,7 @@
   TokenVector.push_back(EoF);
   // We must allocate this array with new because EnterTokenStream is going to
   // delete it later.
+  markAsReinjectedForRelexing(TokenVector);
   auto TokenArray = std::make_unique(TokenVector.size());
   std::copy(TokenVector.begin(), TokenVector.end(), TokenArray.get());
   auto Value = new (PP.getPreprocessorAllocator())
@@ -3176,6 +3183,7 @@
   EOFTok.setLocation(Tok.getLocation());
   ValueList.push_back(EOFTok); // Terminates expression for parsing.
 
+  markAsReinjectedForRelexing(ValueList);
   Info.Toks = 
llvm::makeArrayRef(ValueList).copy(PP.getPreprocessorAllocator());
 
   Info.PragmaName = PragmaName;
@@ -3632,6 +3640,7 @@
 EOFTok.setLocation(EndLoc);
 AttributeTokens.push_back(EOFTok);
 
+markAsReinjectedForRelexing(AttributeTokens);
 Info->Tokens =
 
llvm::makeArrayRef(AttributeTokens).copy(PP.getPreprocessorAllocator());
   }


Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -1037,4 +1037,13 @@
   IsEmpty());
 }
 
+TEST_F(TokenCollectorTest, Pragmas) {
+  // Tokens coming from concatenations.
+  recordTokens(R"cpp(
+void foo() {
+  #pragma unroll 4
+  for(int i=0;i<4;++i);
+}
+  )cpp");
+}
 } // namespace
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -14,11 +14,13 @@
 #include "clang/Basic/PragmaKinds.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/Token.h"
 #include "clang/Parse/LoopHint.h"
 #include "clang/Parse/ParseDiagnostic.h"
 #include "clang/Parse/Parser.h"
 #include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/Scope.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringSwitch.h"
 using namespace clang;
 
@@ -292,6 +294,10 @@
 Token &FirstToken) override;
 };
 
+void markAsReinjectedForRelexing(llvm::MutableArrayRef Toks) {
+  for (auto &T : Toks)
+T.setFlag(clang::Token::IsReinjected);
+}
 }  // end namespace
 
 void Parser::initializePragmaHandlers() {
@@ -2619,6 +2625,7 @@
   TokenVector.push_back(EoF);
   // We must allocate this array with new because EnterTokenStream is going to
   // delete it later.
+  markAsReinjectedForRelexing(TokenVector);
   auto TokenArray = std::make_unique(TokenVector.size());
   std::copy(TokenVector.begin(), TokenVector.end(), TokenArray.get());
   auto Value = new (PP.getPreprocessorAllocator())
@@ -3176,6 +3183,7 @@
   EOFTok.setLocation(Tok.getLocation());
   ValueList.push_back(EOFTok); // Terminates expression for parsing.
 
+  markAsReinjectedForRelexing(ValueList);
   Info.Toks = llvm::makeArrayRef(ValueList).copy(PP.getPreprocessorAllocator());
 
   Info.PragmaName = PragmaName;
@@ -3632,6 +3640,7 @@
 EOFTok.setLocation(EndLoc);
 AttributeTokens.push_back(EOFTok);
 
+markAsReinjecte

[PATCH] D98493: [WoA][MSVC] Use default linker setting in MSVC-compatible driver

2021-03-12 Thread Maxim Kuvyrkov via Phabricator via cfe-commits
maxim-kuvyrkov updated this revision to Diff 330272.
maxim-kuvyrkov added a comment.

Added missing header to pull in definition of CLANG_DEFAULT_LINKER.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98493

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


Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -11,6 +11,7 @@
 #include "Darwin.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -577,7 +578,10 @@
   // translate 'lld' into 'lld-link', and in the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "link");
+  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ,
+ CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
   if (Linker.equals_lower("lld"))
 Linker = "lld-link";
 


Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -11,6 +11,7 @@
 #include "Darwin.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -577,7 +578,10 @@
   // translate 'lld' into 'lld-link', and in the case of the regular msvc
   // linker, we need to use a special search algorithm.
   llvm::SmallString<128> linkPath;
-  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "link");
+  StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ,
+	  CLANG_DEFAULT_LINKER);
+  if (Linker.empty())
+Linker = "link";
   if (Linker.equals_lower("lld"))
 Linker = "lld-link";
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98494: [NFC] Minor cleanup to use default setting of getLastArg()

2021-03-12 Thread Maxim Kuvyrkov via Phabricator via cfe-commits
maxim-kuvyrkov updated this revision to Diff 330273.
maxim-kuvyrkov added a comment.

Fixed thinko: GetLastArg -> GetLastArgValue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98494

Files:
  clang/lib/Driver/ToolChain.cpp


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -571,8 +571,8 @@
 
   // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= 
is
   // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
-  const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
-  StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+  StringRef UseLinker = Args.getLastArgValue(options::OPT_fuse_ld_EQ,
+CLANG_DEFAULT_LINKER);
 
   // --ld-path= takes precedence over -fuse-ld= and specifies the executable
   // name. -B, COMPILER_PATH and PATH and consulted if the value does not


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -571,8 +571,8 @@
 
   // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= is
   // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
-  const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
-  StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+  StringRef UseLinker = Args.getLastArgValue(options::OPT_fuse_ld_EQ,
+	 CLANG_DEFAULT_LINKER);
 
   // --ld-path= takes precedence over -fuse-ld= and specifies the executable
   // name. -B, COMPILER_PATH and PATH and consulted if the value does not
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98521: [clang-tidy] Fix readability-identifer-naming duplicating prefix or suffix for replacements.

2021-03-12 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, alexfh.
Herald added a subscriber: xazax.hun.
njames93 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If a identifier has a correct prefix/suffix but a bad case, the fix won't strip 
them when computing the correct case, leading to duplication when the are added 
back.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98521

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -148,6 +148,10 @@
 int g_twice_global3 = ADD_TO_SELF(global3);
 // CHECK-FIXES: {{^}}int g_twice_global3 = ADD_TO_SELF(g_global3);{{$}}
 
+int g_Global4;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global 
variable 'g_Global4'
+// CHECK-FIXES: {{^}}int g_global4;{{$}}
+
 enum my_enumeration {
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for enum 
'my_enumeration'
 // CHECK-FIXES: {{^}}enum EMyEnumeration {{{$}}
@@ -544,6 +548,9 @@
 // CHECK-FIXES: {{^}}unsigned const MY_CONST_GLOBAL_ARRAY[] = {1,2,3};{{$}}
 
 int * MyGlobal_Ptr;// -> ok
+int * my_second_global_Ptr;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global 
pointer 'my_second_global_Ptr'
+// CHECK-FIXES: {{^}}int * MySecondGlobal_Ptr;{{$}}
 int * const MyConstantGlobalPointer = nullptr;
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global 
constant pointer 'MyConstantGlobalPointer'
 // CHECK-FIXES: {{^}}int * const MY_CONSTANT_GLOBAL_POINTER_Ptr = nullptr;{{$}}
Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -407,6 +407,8 @@
 static std::string
 fixupWithStyle(StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style) {
+  Name.consume_front(Style.Prefix);
+  Name.consume_back(Style.Suffix);
   const std::string Fixed = fixupWithCase(
   Name, 
Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase));
   StringRef Mid = StringRef(Fixed).trim("_");


Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -148,6 +148,10 @@
 int g_twice_global3 = ADD_TO_SELF(global3);
 // CHECK-FIXES: {{^}}int g_twice_global3 = ADD_TO_SELF(g_global3);{{$}}
 
+int g_Global4;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'g_Global4'
+// CHECK-FIXES: {{^}}int g_global4;{{$}}
+
 enum my_enumeration {
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for enum 'my_enumeration'
 // CHECK-FIXES: {{^}}enum EMyEnumeration {{{$}}
@@ -544,6 +548,9 @@
 // CHECK-FIXES: {{^}}unsigned const MY_CONST_GLOBAL_ARRAY[] = {1,2,3};{{$}}
 
 int * MyGlobal_Ptr;// -> ok
+int * my_second_global_Ptr;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global pointer 'my_second_global_Ptr'
+// CHECK-FIXES: {{^}}int * MySecondGlobal_Ptr;{{$}}
 int * const MyConstantGlobalPointer = nullptr;
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global constant pointer 'MyConstantGlobalPointer'
 // CHECK-FIXES: {{^}}int * const MY_CONSTANT_GLOBAL_POINTER_Ptr = nullptr;{{$}}
Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -407,6 +407,8 @@
 static std::string
 fixupWithStyle(StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style) {
+  Name.consume_front(Style.Prefix);
+  Name.consume_back(Style.Suffix);
   const std::string Fixed = fixupWithCase(
   Name, Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase));
   StringRef Mid = StringRef(Fixed).trim("_");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97224: Use Address for CGBuilder's CreateAtomicRMW and CreateAtomicCmpXchg.

2021-03-12 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

In D97224#2621328 , @rjmccall wrote:

> In D97224#2604537 , @jyknight wrote:
>
>>> I'm less certain about what to do with the `__atomic_*` builtins
>>
>> The `__atomic` builtins have already been supporting under-aligned pointers 
>> all along -- and that behavior is unchanged by this patch.
>
> How so?  Clang hasn't been passing down an alignment, which means that it's 
> been building `atomicrmw` instructions with the natural alignment for the IR 
> type, which means we've been assuming that all pointers have a least that 
> alignment.  The LLVM documentation even says that `atomicrmw` doesn't allow 
> under-alignment.

We construct a libcall to `__atomic_*` routines in the frontend upon seeing an 
underaligned argument, instead of letting the backend handle it -- there's a 
bunch of code at 
https://github.com/llvm/llvm-project/blob/bc4a5bdce4af82a5522869d8a154e9e15cf809df/clang/lib/CodeGen/CGAtomic.cpp#L790
 to handle that. I'd like to rip most of that out in the future, and just let 
the backend handle it in more cases.

E.g.

  typedef int __attribute__((aligned(1))) unaligned_int;
  bool cmpxchg_u(unaligned_int *x) {
  int expected = 2;
  return __atomic_compare_exchange_n(x, &expected, 2, false, 
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
  }

generates a libcall to `__atomic_compare_exchange_4` (in IR, generated in the 
Clang code), instead of creating a cmpxchg IR instruction, due to the 
under-alignment. (Although, sigh, I've only just noticed we actually have a 
problem here -- the `__atomic_*_SIZE` libcalls are supposed to require an 
aligned argument -- so we should be using `__atomic_compare_exchange` (without 
size suffix) instead. Gah.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97224

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


[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-12 Thread Tim Keith via Phabricator via cfe-commits
tskeith added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:293
+  driverPath = driverPath.substr(0, driverPath.size() - 9);
+  return driverPath.append("/../tools/flang/include/flang/");
+}

tskeith wrote:
> arnamoy10 wrote:
> > tskeith wrote:
> > > Does this work for an install? I think there the path would be 
> > > `include/flang` rather than `tools/flang/include/flang`.
> > You are probably right, I am giving the path w.r.t a build.  Can we make 
> > the assumption that there should be always an install?  Or do we determine 
> > if we flang-new is coming from build or install (by checking if a module 
> > file is present through ls)  and then set the path accordingly?
> I think it should work in a build or an install. The `flang/tools/f18/flang` 
> script checks for `include/flang` first and if that doesn't exist it uses 
> `tools/flang/include/flang` so you could do the same. It would be good if we 
> could fix the build or install so that the location is consistent.
I've created D98522 to make the relative path be `include/flang` in both build 
and install. If no one objects, that should make it so you don't need 
conditional code here, just use `"/../include/flang"`.


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

https://reviews.llvm.org/D97080

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


[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-12 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:293
+  driverPath = driverPath.substr(0, driverPath.size() - 9);
+  return driverPath.append("/../tools/flang/include/flang/");
+}

tskeith wrote:
> tskeith wrote:
> > arnamoy10 wrote:
> > > tskeith wrote:
> > > > Does this work for an install? I think there the path would be 
> > > > `include/flang` rather than `tools/flang/include/flang`.
> > > You are probably right, I am giving the path w.r.t a build.  Can we make 
> > > the assumption that there should be always an install?  Or do we 
> > > determine if we flang-new is coming from build or install (by checking if 
> > > a module file is present through ls)  and then set the path accordingly?
> > I think it should work in a build or an install. The 
> > `flang/tools/f18/flang` script checks for `include/flang` first and if that 
> > doesn't exist it uses `tools/flang/include/flang` so you could do the same. 
> > It would be good if we could fix the build or install so that the location 
> > is consistent.
> I've created D98522 to make the relative path be `include/flang` in both 
> build and install. If no one objects, that should make it so you don't need 
> conditional code here, just use `"/../include/flang"`.
Thanks for doing this


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

https://reviews.llvm.org/D97080

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Hi,

this breaks check-clang on arm macs: http://45.33.8.238/macm1/5421/step_6.txt

(The `fatal error: 'opencl-c-base.h' file not found` bit is printed when the 
test passes too, and is unrelated.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

Hi!

Yeah,  I'm looking into it, but I can't reproduce it locally: the test passes 
at x86_64 linux system. I'll revert the change if it takes too much time to 
investigate what's going on. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Does it repro if you add `-target arm64-apple-macosx` as arg to c-index-test on 
the RUN line of that test?

Here's the output of that RUN line on an arm mac when the test fails: 
http://pastie.org/p/1go1Y9WXjs5T371RtyJ3Gi

Let's revert for now, things have been broken for over 9 hours already.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

In D97058#2622669 , @thakis wrote:

> Does it repro if you add `-target arm64-apple-macosx` as arg to c-index-test 
> on the RUN line of that test?

I also had trouble reproducing the failure locally, but by specifying this 
target I can reproduce the failure.

That means the fix is simple then? Simply add `-target spir` to the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

It repros for me with this local diff

  % git diff
  diff --git a/clang/test/Index/opencl-types.cl 
b/clang/test/Index/opencl-types.cl
  index 496f38752fa2..13f6058864b5 100644
  --- a/clang/test/Index/opencl-types.cl
  +++ b/clang/test/Index/opencl-types.cl
  @@ -1,4 +1,4 @@
  -// RUN: c-index-test -test-print-type %s -cl-std=CL2.0 | FileCheck %s
  +// RUN: c-index-test -test-print-type %s -cl-std=CL2.0 -target 
arm64-apple-macosx | FileCheck %s
  
   #pragma OPENCL EXTENSION cl_khr_fp16 : enable
   #pragma OPENCL EXTENSION cl_khr_fp64 : enable

The failure goes away if I locally revert the change.

I don't know if it's expected that the test added in 
https://reviews.llvm.org/D51484 starts failing after this change for arm 
triples. If it is, then just adding a fixed triple is fine. If it's unexpected, 
the let's revert and analyze async, with a green tree.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D97058#2622681 , @svenvh wrote:

> In D97058#2622669 , @thakis wrote:
>
>> Does it repro if you add `-target arm64-apple-macosx` as arg to c-index-test 
>> on the RUN line of that test?
>
> I also had trouble reproducing the failure locally, but by specifying this 
> target I can reproduce the failure.
>
> That means the fix is simple then? Simply add `-target spir` to the test.

I can't get how this test could even work for other targets since it is using 
Intel's extension successfully. My guess is that `-target spir` might indeed be 
a proper fix. However, I am confused why it only started failing on this commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

Thanks guys,

I'm on way to trying that, just building clang from scratch.

>   If it is, then just adding a fixed triple is fine.

Yeah, it is expected as this change removes types which require extension from 
parsers state. X86 and SPIR support all extensions by default, so that's why 
`mce_payload` is there. I'll provide the fix to the test once I'll try that 
locally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.



> (The `fatal error: 'opencl-c-base.h' file not found` bit is printed when the 
> test passes too, and is unrelated.)

I can't reproduce this locally neither with nor without this commit.

I think there is something wrong with the way this test runs, this might 
explain why it didn't show up as failing even though it could not have been 
parsed successfully with Arm or Amd triples.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In case it's useful, here's the output of the RUN line on an m1 mac with this 
patch locally reverted (where the test passes): 
http://pastie.org/p/2F3Y0xUMtH5RP9TVRzG4LI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D97058#2622717 , @thakis wrote:

> In case it's useful, here's the output of the RUN line on an m1 mac with this 
> patch locally reverted (where the test passes): 
> http://pastie.org/p/2F3Y0xUMtH5RP9TVRzG4LI

Thanks, this seems strange as we are not supposed to have Intel specific 
extensions exposed for Arm:

  VarDecl=mce_payload:131:37 (Definition) (invalid) [type=__private 
intel_sub_group_avc_mce_payload_t] [typekind=Typedef] [canonicaltype=__private 
intel_sub_group_avc_mce_payload_t] 
[canonicaltypekind=OCLIntelSubgroupAVCMcePayload] [isPOD=1] [isAnonRecDecl=0]
  TypeRef=intel_sub_group_avc_mce_payload_t:0:0 
[type=intel_sub_group_avc_mce_payload_t] [typekind=Typedef] 
[canonicaltype=intel_sub_group_avc_mce_payload_t] 
[canonicaltypekind=OCLIntelSubgroupAVCMcePayload] [isPOD=1] [isAnonRecDecl=0]

It feels like we aren't doing something right either in default headers or in 
the frontend setup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D97058#2622750 , @Anastasia wrote:

> In D97058#2622717 , @thakis wrote:
>
>> In case it's useful, here's the output of the RUN line on an m1 mac with 
>> this patch locally reverted (where the test passes): 
>> http://pastie.org/p/2F3Y0xUMtH5RP9TVRzG4LI
>
> Thanks, this seems strange as we are not supposed to have Intel specific 
> extensions exposed for Arm:
>
>   VarDecl=mce_payload:131:37 (Definition) (invalid) [type=__private 
> intel_sub_group_avc_mce_payload_t] [typekind=Typedef] 
> [canonicaltype=__private intel_sub_group_avc_mce_payload_t] 
> [canonicaltypekind=OCLIntelSubgroupAVCMcePayload] [isPOD=1] [isAnonRecDecl=0]
>   TypeRef=intel_sub_group_avc_mce_payload_t:0:0 
> [type=intel_sub_group_avc_mce_payload_t] [typekind=Typedef] 
> [canonicaltype=intel_sub_group_avc_mce_payload_t] 
> [canonicaltypekind=OCLIntelSubgroupAVCMcePayload] [isPOD=1] [isAnonRecDecl=0]
>
> It feels like we aren't doing something right either in default headers or in 
> the frontend setup.

Oh, I just realized that I already have a fix for this 
https://reviews.llvm.org/D92244. I better commit this on Monday though. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

I can't find why and how `opencl-c-base.h` is used for the test. But it feels 
it is adding the random noise to the testing as it is not expected to be used. 
I don't feel that this commit is affecting the header though, so it is 
something that might have already been broken and hasn't been noticed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D96976: [analyzer] Fix reinterpret_cast handling for pointer-to-member

2021-03-12 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

In D96976#2622342 , @steakhal wrote:

> I'm somewhat busy. If it's not urgent, I would postpone this.
> Ping me in a few weeks.

Sure ok. Is it okay if I tell someone else to take a look at this in the 
meanwhile?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96976

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


[PATCH] D98538: [clangd] Perform merging for stale symbols in MergeIndex

2021-03-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Clangd drops symbols from static index whenever the dynamic index is
authoritative for the file. This results in regressions when static and
dynamic index contains different set of information, e.g.
IncludeHeaders.

After this patch, we'll choose to merge symbols from static index with
dynamic one rather than just dropping. This implies correctness problems
when the definition/documentation of the symbol is deleted. But seems
like it is worth having in more cases.

We still drop symbols if dynamic index owns the file and didn't report
the symbol, which means symbol is deleted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98538

Files:
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp

Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "Annotations.h"
+#include "SyncAPI.h"
 #include "TestIndex.h"
 #include "TestTU.h"
 #include "index/FileIndex.h"
@@ -17,6 +18,7 @@
 #include "clang/Index/IndexSymbol.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 
 using ::testing::_;
 using ::testing::AllOf;
@@ -312,16 +314,26 @@
   AST = Test.build();
   DynamicIndex.updateMain(testPath(Test.Filename), AST);
 
-  // Merged index should not return the symbol definition if this definition
-  // location is inside a file from the dynamic index.
+  // Even though the definition is actually deleted in the newer version of the
+  // file, we still chose to merge with information coming from static index.
   LookupRequest LookupReq;
   LookupReq.IDs = {Foo.ID};
   unsigned SymbolCounter = 0;
   Merge.lookup(LookupReq, [&](const Symbol &Sym) {
 ++SymbolCounter;
-EXPECT_FALSE(Sym.Definition);
+EXPECT_TRUE(Sym.Definition);
   });
   EXPECT_EQ(SymbolCounter, 1u);
+
+  // Drop the symbol completely.
+  Test.Code = "class Bar {};";
+  AST = Test.build();
+  DynamicIndex.updateMain(testPath(Test.Filename), AST);
+
+  // Now we don't expect to see the symbol at all.
+  SymbolCounter = 0;
+  Merge.lookup(LookupReq, [&](const Symbol &Sym) { ++SymbolCounter; });
+  EXPECT_EQ(SymbolCounter, 0u);
 }
 
 TEST(MergeIndexTest, FuzzyFind) {
@@ -585,6 +597,44 @@
IncludeHeaderWithRef("new", 1u)));
 }
 
+TEST(MergeIndexTest, IncludeHeadersMerged) {
+  auto S = symbol("Z");
+  S.Definition.FileURI = "unittest:///foo.cc";
+
+  SymbolSlab::Builder DynB;
+  S.IncludeHeaders.clear();
+  DynB.insert(S);
+  SymbolSlab DynSymbols = std::move(DynB).build();
+  RefSlab DynRefs;
+  auto DynSize = DynSymbols.bytes() + DynRefs.bytes();
+  auto DynData = std::make_pair(std::move(DynSymbols), std::move(DynRefs));
+  llvm::StringSet<> DynFiles = {S.Definition.FileURI};
+  MemIndex DynIndex(std::move(DynData.first), std::move(DynData.second),
+RelationSlab(), std::move(DynFiles), IndexContents::Symbols,
+std::move(DynData), DynSize);
+
+  SymbolSlab::Builder StaticB;
+  S.IncludeHeaders.push_back({"", 0});
+  StaticB.insert(S);
+  auto StaticIndex =
+  MemIndex::build(std::move(StaticB).build(), RefSlab(), RelationSlab());
+  MergedIndex Merge(&DynIndex, StaticIndex.get());
+
+  EXPECT_THAT(runFuzzyFind(Merge, S.Name),
+  ElementsAre(testing::Field(
+  &Symbol::IncludeHeaders,
+  ElementsAre(IncludeHeaderWithRef("", 0u);
+
+  LookupRequest Req;
+  Req.IDs = {S.ID};
+  std::string IncludeHeader;
+  Merge.lookup(Req, [&](const Symbol &S) {
+EXPECT_TRUE(IncludeHeader.empty());
+ASSERT_EQ(S.IncludeHeaders.size(), 1u);
+IncludeHeader = S.IncludeHeaders.front().IncludeHeader.str();
+  });
+  EXPECT_EQ(IncludeHeader, "");
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/Merge.cpp
===
--- clang-tools-extra/clangd/index/Merge.cpp
+++ clang-tools-extra/clangd/index/Merge.cpp
@@ -43,30 +43,40 @@
   });
   SymbolSlab Dyn = std::move(DynB).build();
 
-  llvm::DenseSet SeenDynamicSymbols;
+  llvm::DenseSet ReportedDynSymbols;
   {
 auto DynamicContainsFile = Dynamic->indexedFiles();
 More |= Static->fuzzyFind(Req, [&](const Symbol &S) {
-  // We expect the definition to see the canonical declaration, so it seems
-  // to be enough to check only the definition if it exists.
-  if ((DynamicContainsFile(S.Definition ? S.Definition.FileURI
+  auto DynS = Dyn.find(S.ID);
+

[PATCH] D98539: [OpenCL] Set target as spir for c-index-test for OpenCL

2021-03-12 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov created this revision.
azabaznov added reviewers: Anastasia, svenvh, thakis.
Herald added subscribers: arphaman, yaxunl.
azabaznov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Otherwise (for other targets) testing may be non-determistic as
targets support different extension/feature set, but SPIR target
support all extensions/features by default


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98539

Files:
  clang/test/Index/cxx.cl
  clang/test/Index/opencl-types.cl


Index: clang/test/Index/opencl-types.cl
===
--- clang/test/Index/opencl-types.cl
+++ clang/test/Index/opencl-types.cl
@@ -1,4 +1,4 @@
-// RUN: c-index-test -test-print-type %s -cl-std=CL2.0 | FileCheck %s
+// RUN: c-index-test -test-print-type %s -cl-std=CL2.0 -target spir | 
FileCheck %s
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
Index: clang/test/Index/cxx.cl
===
--- clang/test/Index/cxx.cl
+++ clang/test/Index/cxx.cl
@@ -3,5 +3,5 @@
   addrspace_cast<__global int*>(ptr);
 }
 
-// RUN: c-index-test -test-load-source all %s -cl-std=clc++ | FileCheck %s
+// RUN: c-index-test -test-load-source all %s -cl-std=clc++ -target spir | 
FileCheck %s
 // CHECK: cxx.cl:3:3: CXXAddrspaceCastExpr


Index: clang/test/Index/opencl-types.cl
===
--- clang/test/Index/opencl-types.cl
+++ clang/test/Index/opencl-types.cl
@@ -1,4 +1,4 @@
-// RUN: c-index-test -test-print-type %s -cl-std=CL2.0 | FileCheck %s
+// RUN: c-index-test -test-print-type %s -cl-std=CL2.0 -target spir | FileCheck %s
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
Index: clang/test/Index/cxx.cl
===
--- clang/test/Index/cxx.cl
+++ clang/test/Index/cxx.cl
@@ -3,5 +3,5 @@
   addrspace_cast<__global int*>(ptr);
 }
 
-// RUN: c-index-test -test-load-source all %s -cl-std=clc++ | FileCheck %s
+// RUN: c-index-test -test-load-source all %s -cl-std=clc++ -target spir | FileCheck %s
 // CHECK: cxx.cl:3:3: CXXAddrspaceCastExpr
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

Yes, I was able to reproduce the failure with `-target arm64-apple-macosx` 
flag, I provided the fix to set explicit target: 
https://reviews.llvm.org/D98539.

@Anastasia, I tried to cherry-pick https://reviews.llvm.org/D92244, but the 
error is still reproducible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D98539: [OpenCL] Set target as spir for c-index-test for OpenCL

2021-03-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! I can't see why we would need to tests anything target-specific here 
anyway, so I think the change is reasonable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98539

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D97058#2622883 , @azabaznov wrote:

> Yes, I was able to reproduce the failure with `-target arm64-apple-macosx` 
> flag, I provided the fix to set explicit target: 
> https://reviews.llvm.org/D98539.

I have approved it. Thanks!

> @Anastasia, I tried to cherry-pick https://reviews.llvm.org/D92244, but the 
> error is still reproducible.

Do you also get `fatal error: 'opencl-c-base.h' file not found`? If so, we 
might need at least to file a clang bug that we should look at before the next 
release.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D98457: [WebAssembly] Remove unimplemented-simd target features

2021-03-12 Thread Derek Schuff via Phabricator via cfe-commits
dschuff accepted this revision.
dschuff added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/docs/ClangCommandLineReference.rst:3801
 Pass -z  to the linker
-

extraneous change?



Comment at: clang/include/clang/Basic/BuiltinsWebAssembly.def:191
 
-TARGET_BUILTIN(__builtin_wasm_qfma_f32x4, "V4fV4fV4fV4f", "nc", 
"unimplemented-simd128")
-TARGET_BUILTIN(__builtin_wasm_qfms_f32x4, "V4fV4fV4fV4f", "nc", 
"unimplemented-simd128")
-TARGET_BUILTIN(__builtin_wasm_qfma_f64x2, "V2dV2dV2dV2d", "nc", 
"unimplemented-simd128")
-TARGET_BUILTIN(__builtin_wasm_qfms_f64x2, "V2dV2dV2dV2d", "nc", 
"unimplemented-simd128")
+TARGET_BUILTIN(__builtin_wasm_qfma_f32x4, "V4fV4fV4fV4f", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_qfms_f32x4, "V4fV4fV4fV4f", "nc", "simd128")

is QFMA actually in MVP simd? I thought it was non-deterministic?



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:1712
 };
-  } else if (NumConstantLanes >= NumSplatLanes &&
- Subtarget->hasUnimplementedSIMD128()) {
-// If we support v128.const, emit it directly
+  } else if (NumConstantLanes >= NumSplatLanes) {
 SmallVector ConstLanes;

out of curiosity, are there any cases where a splat could be smaller than a 
v128 const, since the consts are pretty big?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98457

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


[PATCH] D98466: [WebAssembly] Remove experimental SIMD instructions

2021-03-12 Thread Derek Schuff via Phabricator via cfe-commits
dschuff accepted this revision.
dschuff added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Basic/BuiltinsWebAssembly.def:191
 
-TARGET_BUILTIN(__builtin_wasm_qfma_f32x4, "V4fV4fV4fV4f", "nc", "simd128")
-TARGET_BUILTIN(__builtin_wasm_qfms_f32x4, "V4fV4fV4fV4f", "nc", "simd128")

I guess this answers my question from the previous review :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98466

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


[clang] 5ae949a - [Clang][ARM] Reenable arm_acle.c test.

2021-03-12 Thread David Green via cfe-commits

Author: David Green
Date: 2021-03-12T19:21:21Z
New Revision: 5ae949a9276542b46f41374fbe7aee01e480d9d6

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

LOG: [Clang][ARM] Reenable arm_acle.c test.

This test was apparently disabled in 6fcd4e080f09c9765d6, without any
sign of how it was going to be reenabled. This patch rewrites the test
to use update_cc_test_checks, with midend optimizations other that
mem2reg disabled.

Added: 


Modified: 
clang/test/CodeGen/arm_acle.c

Removed: 




diff  --git a/clang/test/CodeGen/arm_acle.c b/clang/test/CodeGen/arm_acle.c
index 9f0ad22bda4f..7e85c767c301 100644
--- a/clang/test/CodeGen/arm_acle.c
+++ b/clang/test/CodeGen/arm_acle.c
@@ -1,125 +1,229 @@
-// RUN: %clang_cc1 -ffreestanding -triple armv8-eabi -target-cpu cortex-a57 
-O2  -fno-experimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
-check-prefix=ARM -check-prefix=AArch32 -check-prefix=ARM-LEGACY 
-check-prefix=AArch32-LEGACY
-// RUN: %clang_cc1 -ffreestanding -triple armv8-eabi -target-cpu cortex-a57 
-O2  -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
-check-prefix=ARM -check-prefix=AArch32 -check-prefix=ARM-NEWPM 
-check-prefix=AArch32-NEWPM
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +neon -target-feature +crc -target-feature +crypto -O2 
-fno-experimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
-check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-LEGACY 
-check-prefix=AArch64-LEGACY
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +neon -target-feature +crc -target-feature +crypto -O2 
-fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
-check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-NEWPM 
-check-prefix=AArch64-NEWPM
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.3a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix=AArch64-v8_3
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.4a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix=AArch64-v8_3
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.5a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix=AArch64-v8_3
-
-// REQUIRES: rewrite
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -ffreestanding -triple armv8-eabi -target-cpu cortex-a57 
-O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s 
-check-prefixes=ARM,AArch32
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +neon -target-feature +crc -target-feature +crypto -O0 
-disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s 
-check-prefixes=ARM,AArch64
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.3a -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S 
-mem2reg | FileCheck %s -check-prefixes=ARM,AArch64,AArch6483
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.5a -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S 
-mem2reg | FileCheck %s -check-prefixes=ARM,AArch64,AArch6483
 
 #include 
 
 /* 8 SYNCHRONIZATION, BARRIER AND HINT INTRINSICS */
 /* 8.3 Memory Barriers */
-// ARM-LABEL: test_dmb
-// AArch32: call void @llvm.arm.dmb(i32 1)
-// AArch64: call void @llvm.aarch64.dmb(i32 1)
+
+// AArch32-LABEL: @test_dmb(
+// AArch32-NEXT:  entry:
+// AArch32-NEXT:call void @llvm.arm.dmb(i32 1)
+// AArch32-NEXT:ret void
+//
+// AArch64-LABEL: @test_dmb(
+// AArch64-NEXT:  entry:
+// AArch64-NEXT:call void @llvm.aarch64.dmb(i32 1)
+// AArch64-NEXT:ret void
+//
 void test_dmb(void) {
   __dmb(1);
 }
 
-// ARM-LABEL: test_dsb
-// AArch32: call void @llvm.arm.dsb(i32 2)
-// AArch64: call void @llvm.aarch64.dsb(i32 2)
+// AArch32-LABEL: @test_dsb(
+// AArch32-NEXT:  entry:
+// AArch32-NEXT:call void @llvm.arm.dsb(i32 2)
+// AArch32-NEXT:ret void
+//
+// AArch64-LABEL: @test_dsb(
+// AArch64-NEXT:  entry:
+// AArch64-NEXT:call void @llvm.aarch64.dsb(i32 2)
+// AArch64-NEXT:ret void
+//
 void test_dsb(void) {
   __dsb(2);
 }
 
-// ARM-LABEL: test_isb
-// AArch32: call void @llvm.arm.isb(i32 3)
-// AArch64: call void @llvm.aarch64.isb(i32 3)
+// AArch32-LABEL: @test_isb(
+// AArch32-NEXT:  entry:
+// AArch32-NEXT:call void @llvm.arm.isb(i32 3)
+// AArch32-NEXT:ret void
+//
+// AArch64-LABEL: @test_isb(
+// AArch64-NEXT:  entry:
+// AArch64-NEXT:call void @llv

[PATCH] D97411: [DebugInfo] Add an attribute to force type info to be emitted for types that are required to be complete.

2021-03-12 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 330316.
akhuang added a comment.
Herald added a subscriber: jdoerfert.

update test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97411

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/standalone-debug-attribute.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-standalonedebug.cpp

Index: clang/test/Sema/attr-standalonedebug.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-standalonedebug.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// RUN: %clang_cc1 %s -verify -fsyntax-only -x c
+
+#ifdef __cplusplus
+int a __attribute__((standalone_debug)); // expected-warning {{'standalone_debug' attribute only applies to classes}}
+
+void __attribute__((standalone_debug)) b(); // expected-warning {{'standalone_debug' attribute only applies to classes}}
+
+struct __attribute__((standalone_debug(1))) c {}; // expected-error {{'standalone_debug' attribute takes no arguments}}
+
+#else
+// Check that attribute only works in C++.
+struct __attribute__((standalone_debug)) a {}; // expected-warning {{'standalone_debug' attribute ignored}}
+#endif
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -154,6 +154,7 @@
 // CHECK-NEXT: Section (SubjectMatchRule_function, SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
 // CHECK-NEXT: SetTypestate (SubjectMatchRule_function_is_member)
 // CHECK-NEXT: SpeculativeLoadHardening (SubjectMatchRule_function, SubjectMatchRule_objc_method)
+// CHECK-NEXT: StandaloneDebug (SubjectMatchRule_record)
 // CHECK-NEXT: SwiftAsync (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: SwiftAsyncError (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: SwiftAsyncName (SubjectMatchRule_objc_method, SubjectMatchRule_function)
Index: clang/test/CodeGenCXX/standalone-debug-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/standalone-debug-attribute.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -DSETATTR=0 -triple x86_64-unknown-linux-gnu -emit-llvm -debug-info-kind=constructor %s -o - | FileCheck %s --check-prefix=DEBUG
+// RUN: %clang_cc1 -DSETATTR=1 -triple x86_64-unknown-linux-gnu -emit-llvm -debug-info-kind=constructor %s -o - | FileCheck %s --check-prefix=WITHATTR
+// Use -debug-info-kind=constructor because it includes all the optimizations.
+
+#if SETATTR
+#define STANDALONEDEBUGATTR __attribute__((standalone_debug))
+#else
+#define STANDALONEDEBUGATTR
+#endif
+
+struct STANDALONEDEBUGATTR StructWithConstructor {
+  StructWithConstructor() {}
+};
+void f(StructWithConstructor s) {}
+// DEBUG:  !DICompositeType({{.*}}name: "StructWithConstructor"
+// DEBUG-SAME:  flags: {{.*}}DIFlagFwdDecl
+// WITHATTR: !DICompositeType({{.*}}name: "StructWithConstructor"
+// WITHATTR-NOT: DIFlagFwdDecl
+
+union STANDALONEDEBUGATTR UnionWithConstructor {
+  UnionWithConstructor() {}
+};
+void f(UnionWithConstructor u) {}
+// DEBUG:  !DICompositeType({{.*}}name: "UnionWithConstructor"
+// DEBUG-SAME:  flags: {{.*}}DIFlagFwdDecl
+// WITHATTR: !DICompositeType({{.*}}name: "UnionWithConstructor"
+// WITHATTR-NOT: DIFlagFwdDecl
+
+template  struct ExternTemplate {
+  ExternTemplate() {}
+  T x;
+};
+extern template struct STANDALONEDEBUGATTR ExternTemplate;
+void f(ExternTemplate s) {}
+// DEBUG: !DICompositeType({{.*}}name: "ExternTemplate"
+// DEBUG-SAME: flags: {{.*}}DIFlagFwdDecl
+// WITHATTR: !DICompositeType({{.*}}name: "ExternTemplate"
+// WITHATTR-NOT: DIFlagFwdDecl
+
+struct STANDALONEDEBUGATTR CompleteTypeRequired {};
+void f(CompleteTypeRequired &s) {}
+// DEBUG: !DICompositeType({{.*}}name: "CompleteTypeRequired"
+// DEBUG-SAME: flags: {{.*}}DIFlagFwdDecl
+// WITHATTR: !DICompositeType({{.*}}name: "CompleteTypeRequired"
+// WITHATTR-NOT: DIFlagFwdDecl
+
+struct STANDALONEDEBUGATTR Redecl;
+struct Redecl {};
+void f(Redecl &s) {}
+// DEBUG: !DICompositeType({{.*}}name: "Redecl"
+// DEBUG-SAME: flags: {{.*}}DIFlagFwdDecl
+// WITHATTR: !DICompositeType({{.*}}name: "Redecl"
+// WITHATTR-NOT: DIFlagFwdDecl
+
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2385,7 +2385,8 @@
   if (DebugKind == codegenoptions::DebugLineTablesOnly)
 return true;
 
-  if (DebugKind > codegenoptions::LimitedD

[PATCH] D98277: [release][docs] List all cores Arm has added support for in LLVM 12.

2021-03-12 Thread Amilendra Kodithuwakku via Phabricator via cfe-commits
amilendra closed this revision.
amilendra added a comment.

Commited to LLVM Release 12.x branch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98277

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


[clang] d7b7e20 - Revert "[Clang][ARM] Reenable arm_acle.c test."

2021-03-12 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-03-12T14:37:37-05:00
New Revision: d7b7e2026b0a8b575df9ee7c4042ecff450f6549

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

LOG: Revert "[Clang][ARM] Reenable arm_acle.c test."

This reverts commit 5ae949a9276542b46f41374fbe7aee01e480d9d6.
Test fails everywhere.

Added: 


Modified: 
clang/test/CodeGen/arm_acle.c

Removed: 




diff  --git a/clang/test/CodeGen/arm_acle.c b/clang/test/CodeGen/arm_acle.c
index 7e85c767c301..9f0ad22bda4f 100644
--- a/clang/test/CodeGen/arm_acle.c
+++ b/clang/test/CodeGen/arm_acle.c
@@ -1,229 +1,125 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -ffreestanding -triple armv8-eabi -target-cpu cortex-a57 
-O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s 
-check-prefixes=ARM,AArch32
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +neon -target-feature +crc -target-feature +crypto -O0 
-disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s 
-check-prefixes=ARM,AArch64
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.3a -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S 
-mem2reg | FileCheck %s -check-prefixes=ARM,AArch64,AArch6483
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.5a -O0 -disable-O0-optnone -S -emit-llvm -o - %s | opt -S 
-mem2reg | FileCheck %s -check-prefixes=ARM,AArch64,AArch6483
+// RUN: %clang_cc1 -ffreestanding -triple armv8-eabi -target-cpu cortex-a57 
-O2  -fno-experimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
-check-prefix=ARM -check-prefix=AArch32 -check-prefix=ARM-LEGACY 
-check-prefix=AArch32-LEGACY
+// RUN: %clang_cc1 -ffreestanding -triple armv8-eabi -target-cpu cortex-a57 
-O2  -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
-check-prefix=ARM -check-prefix=AArch32 -check-prefix=ARM-NEWPM 
-check-prefix=AArch32-NEWPM
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +neon -target-feature +crc -target-feature +crypto -O2 
-fno-experimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
-check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-LEGACY 
-check-prefix=AArch64-LEGACY
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +neon -target-feature +crc -target-feature +crypto -O2 
-fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
-check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-NEWPM 
-check-prefix=AArch64-NEWPM
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.3a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix=AArch64-v8_3
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.4a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix=AArch64-v8_3
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.5a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix=AArch64-v8_3
+
+// REQUIRES: rewrite
 
 #include 
 
 /* 8 SYNCHRONIZATION, BARRIER AND HINT INTRINSICS */
 /* 8.3 Memory Barriers */
-
-// AArch32-LABEL: @test_dmb(
-// AArch32-NEXT:  entry:
-// AArch32-NEXT:call void @llvm.arm.dmb(i32 1)
-// AArch32-NEXT:ret void
-//
-// AArch64-LABEL: @test_dmb(
-// AArch64-NEXT:  entry:
-// AArch64-NEXT:call void @llvm.aarch64.dmb(i32 1)
-// AArch64-NEXT:ret void
-//
+// ARM-LABEL: test_dmb
+// AArch32: call void @llvm.arm.dmb(i32 1)
+// AArch64: call void @llvm.aarch64.dmb(i32 1)
 void test_dmb(void) {
   __dmb(1);
 }
 
-// AArch32-LABEL: @test_dsb(
-// AArch32-NEXT:  entry:
-// AArch32-NEXT:call void @llvm.arm.dsb(i32 2)
-// AArch32-NEXT:ret void
-//
-// AArch64-LABEL: @test_dsb(
-// AArch64-NEXT:  entry:
-// AArch64-NEXT:call void @llvm.aarch64.dsb(i32 2)
-// AArch64-NEXT:ret void
-//
+// ARM-LABEL: test_dsb
+// AArch32: call void @llvm.arm.dsb(i32 2)
+// AArch64: call void @llvm.aarch64.dsb(i32 2)
 void test_dsb(void) {
   __dsb(2);
 }
 
-// AArch32-LABEL: @test_isb(
-// AArch32-NEXT:  entry:
-// AArch32-NEXT:call void @llvm.arm.isb(i32 3)
-// AArch32-NEXT:ret void
-//
-// AArch64-LABEL: @test_isb(
-// AArch64-NEXT:  entry:
-// AArch64-NEXT:call void @llvm.aarch64.isb(i32 3)
-// AArch64-NEXT:ret void
-//
+// ARM-LABEL: test_isb
+// AArch32: call void @llvm.arm.isb(i32 3)
+// AArch64: call void @llvm.aarch64.isb(i32 3)
 void test_isb(void) {
   __isb(3);
 }
 
 /* 8.4 Hints */
-// AArch32-LAB

[PATCH] D98539: [OpenCL] Set target as spir for c-index-test for OpenCL

2021-03-12 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Can we get this landed asap please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98539

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


[PATCH] D98277: [release][docs] List all cores Arm has added support for in LLVM 12.

2021-03-12 Thread Amilendra Kodithuwakku via Phabricator via cfe-commits
amilendra reopened this revision.
amilendra added a comment.
This revision is now accepted and ready to land.

Reopening to add a missing empty line before starting the level-2 list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98277

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


[PATCH] D98504: [clang][Checkers] Fix PthreadLockChecker state cleanup at dead symbol.

2021-03-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

Hi, @balazske




Comment at: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp:290-304
   // Existence in DestroyRetVal ensures existence in LockMap.
   // Existence in Destroyed also ensures that the lock state for lockR is 
either
   // UntouchedAndPossiblyDestroyed or UnlockedAndPossiblyDestroyed.
   assert(lstate->isUntouchedAndPossiblyDestroyed() ||
  lstate->isUnlockedAndPossiblyDestroyed());
 
   ConstraintManager &CMgr = state->getConstraintManager();

I'm just wondering, did you think about such way of fixing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98504

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


[PATCH] D98457: [WebAssembly] Remove unimplemented-simd target features

2021-03-12 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsWebAssembly.def:191
 
-TARGET_BUILTIN(__builtin_wasm_qfma_f32x4, "V4fV4fV4fV4f", "nc", 
"unimplemented-simd128")
-TARGET_BUILTIN(__builtin_wasm_qfms_f32x4, "V4fV4fV4fV4f", "nc", 
"unimplemented-simd128")
-TARGET_BUILTIN(__builtin_wasm_qfma_f64x2, "V2dV2dV2dV2d", "nc", 
"unimplemented-simd128")
-TARGET_BUILTIN(__builtin_wasm_qfms_f64x2, "V2dV2dV2dV2d", "nc", 
"unimplemented-simd128")
+TARGET_BUILTIN(__builtin_wasm_qfma_f32x4, "V4fV4fV4fV4f", "nc", "simd128")
+TARGET_BUILTIN(__builtin_wasm_qfms_f32x4, "V4fV4fV4fV4f", "nc", "simd128")

dschuff wrote:
> is QFMA actually in MVP simd? I thought it was non-deterministic?
No, as you discovered, it's removed in the next patch. I kind of ended up with 
these patches in the wrong order, but I think it should be ok.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:1712
 };
-  } else if (NumConstantLanes >= NumSplatLanes &&
- Subtarget->hasUnimplementedSIMD128()) {
-// If we support v128.const, emit it directly
+  } else if (NumConstantLanes >= NumSplatLanes) {
 SmallVector ConstLanes;

dschuff wrote:
> out of curiosity, are there any cases where a splat could be smaller than a 
> v128 const, since the consts are pretty big?
Yes, for sure. In fact, this code used to find the const lowering that resulted 
in the fewest bytes emitted. Our users much prefer to have the fewest 
instructions emitted, though, since this lowering is often critical for 
performance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98457

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


[PATCH] D98457: [WebAssembly] Remove unimplemented-simd target features

2021-03-12 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:3801
 Pass -z  to the linker
-

dschuff wrote:
> extraneous change?
Yes, will revert, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98457

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


[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-12 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 330337.
arnamoy10 edited the summary of this revision.
arnamoy10 added a comment.

Update the path based on the patch D98522 


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

https://reviews.llvm.org/D97080

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/Inputs/ieee_arithmetic.mod
  flang/test/Driver/Inputs/iso_fortran_env.mod
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/intrinsic_module_path.f90

Index: flang/test/Driver/intrinsic_module_path.f90
===
--- /dev/null
+++ flang/test/Driver/intrinsic_module_path.f90
@@ -0,0 +1,35 @@
+! Ensure argument -fintrinsic-modules-path works as expected.
+! WITHOUT the option, the default location for the module is checked and no error generated.
+! With the option GIVEN, the module with the same name is PREPENDED, and considered over the
+! default one, causing a CHECKSUM error.
+
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fsyntax-only -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fc1 -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: 'ieee_arithmetic.mod' was not found
+! WITHOUT-NOT: 'iso_fortran_env.mod' was not found
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: error: Cannot read module file for module 'ieee_arithmetic': File has invalid checksum
+! GIVEN: error: Cannot read module file for module 'iso_fortran_env': File has invalid checksum
+
+
+program test_intrinsic_module_path
+   use ieee_arithmetic, only: ieee_round_type
+   use iso_fortran_env, only: team_type, event_type, lock_type
+end program
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -35,6 +35,8 @@
 ! HELP-NEXT: -ffree-formProcess source files in free form
 ! HELP-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-NEXT: -fintrinsic-modules-path 
+! HELP-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
@@ -82,6 +84,8 @@
 ! HELP-FC1-NEXT: -ffree-formProcess source files in free form
 ! HELP-FC1-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-FC1-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-FC1-NEXT: -fintrinsic-modules-path 
+! HELP-FC1-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -35,6 +35,8 @@
 ! CHECK-NEXT: -ffree-formProcess source files in free form
 ! CHECK-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! CHECK-NEXT: -finput-charset= Specify the default character set for source files
+! CHECK-NEXT: -fintrinsic-modules-path 
+! CHECK-NEXT:Specify where to find the compiled intrinsic modules
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
Index: flang/test/Driver/Inputs/iso_fortran_env.mod
===
--- /dev/null
+

[clang] 42eb658 - [OpaquePtrs] Remove some uses of type-less CreateGEP() (NFC)

2021-03-12 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-03-12T21:01:16+01:00
New Revision: 42eb658f656c43ee63e25222f32acb86ad7b

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

LOG: [OpaquePtrs] Remove some uses of type-less CreateGEP() (NFC)

This removes some (but not all) uses of type-less CreateGEP()
and CreateInBoundsGEP() APIs, which are incompatible with opaque
pointers.

There are a still a number of tricky uses left, as well as many
more variation APIs for CreateGEP.

Added: 


Modified: 
clang/lib/CodeGen/CGBuilder.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprCXX.cpp
clang/lib/CodeGen/CGNonTrivialStruct.cpp
clang/lib/CodeGen/CGObjCRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/lib/CodeGen/TargetInfo.cpp
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/lib/Transforms/Scalar/SROA.cpp
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
polly/lib/CodeGen/RuntimeDebugBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuilder.h b/clang/lib/CodeGen/CGBuilder.h
index 4e22db67c57e..e79d72885e54 100644
--- a/clang/lib/CodeGen/CGBuilder.h
+++ b/clang/lib/CodeGen/CGBuilder.h
@@ -213,7 +213,7 @@ class CGBuilderTy : public CGBuilderBaseTy {
 CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy->getElementType()));
 
 return Address(
-CreateInBoundsGEP(Addr.getPointer(),
+CreateInBoundsGEP(Addr.getElementType(), Addr.getPointer(),
   {getSize(CharUnits::Zero()), getSize(Index)}, Name),
 Addr.getAlignment().alignmentAtOffset(Index * EltSize));
   }
@@ -254,7 +254,8 @@ class CGBuilderTy : public CGBuilderBaseTy {
   Address CreateConstInBoundsByteGEP(Address Addr, CharUnits Offset,
  const llvm::Twine &Name = "") {
 assert(Addr.getElementType() == TypeCache.Int8Ty);
-return Address(CreateInBoundsGEP(Addr.getPointer(), getSize(Offset), Name),
+return Address(CreateInBoundsGEP(Addr.getElementType(), Addr.getPointer(),
+ getSize(Offset), Name),
Addr.getAlignment().alignmentAtOffset(Offset));
   }
   Address CreateConstByteGEP(Address Addr, CharUnits Offset,

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index a3a33e46583b..ed43e5fd091f 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3251,7 +3251,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 Builder.CreateMemCpy(Dest, Src, SizeVal, false);
 if (BuiltinID == Builtin::BImempcpy ||
 BuiltinID == Builtin::BI__builtin_mempcpy)
-  return RValue::get(Builder.CreateInBoundsGEP(Dest.getPointer(), 
SizeVal));
+  return RValue::get(Builder.CreateInBoundsGEP(Dest.getElementType(),
+   Dest.getPointer(), 
SizeVal));
 else
   return RValue::get(Dest.getPointer());
   }
@@ -4682,7 +4683,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   auto *Zero = llvm::ConstantInt::get(IntTy, 0);
   for (unsigned I = First; I < NumArgs; ++I) {
 auto *Index = llvm::ConstantInt::get(IntTy, I - First);
-auto *GEP = Builder.CreateGEP(TmpPtr, {Zero, Index});
+auto *GEP = Builder.CreateGEP(Tmp.getElementType(), TmpPtr,
+  {Zero, Index});
 if (I == First)
   ElemPtr = GEP;
 auto *V =
@@ -8984,7 +8986,7 @@ Value 
*CodeGenFunction::EmitAArch64SVEBuiltinExpr(unsigned BuiltinID,
 for (unsigned I = 0; I < NumOpnds; ++I)
   Builder.CreateDefaultAlignedStore(
   IsBoolTy ? Builder.CreateZExt(Ops[I], EltTy) : Ops[I],
-  Builder.CreateGEP(Alloca.getPointer(),
+  Builder.CreateGEP(Alloca.getElementType(), Alloca.getPointer(),
 {Builder.getInt64(0), Builder.getInt64(I)}));
 
 SVETypeFlags TypeFlags(Builtin->TypeModifier);
@@ -8993,7 +8995,8 @@ Value 
*CodeGenFunction::EmitAArch64SVEBuiltinExpr(unsigned BuiltinID,
 llvm::Type *OverloadedTy = getSVEVectorForElementType(EltTy);
 Function *F = CGM.getIntrinsic(Intrinsic::aarch64_sve_ld1rq, OverloadedTy);
 Value *Alloca0 = Builder.CreateGEP(
-Alloca.getPointer(), {Builder.getInt64(0), Builder.getInt64(0)});
+Alloca.getElementType(), Alloca.getPointer(),
+{Builder.getInt64(0), Builder.getInt64(0)});
 Value *LD1RQ = Builder.CreateCall(F, {Pred,

[PATCH] D98546: [PowerPC] Add __PCREL__ when PC Relative is enabled.

2021-03-12 Thread Stefan Pintilie via Phabricator via cfe-commits
stefanp created this revision.
stefanp added a reviewer: nemanjai.
Herald added subscribers: shchenz, kbarton.
stefanp requested review of this revision.
Herald added a project: clang.

This patch adds the __PCREL__ define when PC Relative addressing is enabled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98546

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/Preprocessor/init-ppc64.c


Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -633,6 +633,7 @@
 // PPCPOWER10:#define _ARCH_PWR8 1
 // PPCPOWER10:#define _ARCH_PWR9 1
 // PPCPOWER10:#define __MMA__ 1
+// PPCPOWER10:#define __PCREL__ 1
 // PPCPOWER10-NOT:#define __ROP_PROTECTION__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-cpu future -fno-signed-char < /dev/null | FileCheck -match-full-lines 
-check-prefix PPCFUTURE %s
@@ -652,6 +653,7 @@
 // PPCFUTURE:#define _ARCH_PWR9 1
 // PPCFUTURE:#define _ARCH_PWR_FUTURE 1
 // PPCFUTURE:#define __MMA__ 1
+// PPCFUTURE:#define __PCREL__ 1
 // PPCFUTURE-NOT:#define __ROP_PROTECTION__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-feature +mma -target-cpu power10 -fno-signed-char < /dev/null | 
FileCheck -check-prefix PPC-MMA %s
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -199,6 +199,8 @@
 Builder.defineMacro("__ROP_PROTECTION__");
   if (HasP10Vector)
 Builder.defineMacro("__POWER10_VECTOR__");
+  if (HasPCRelativeMemops)
+Builder.defineMacro("__PCREL__");
 
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");


Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -633,6 +633,7 @@
 // PPCPOWER10:#define _ARCH_PWR8 1
 // PPCPOWER10:#define _ARCH_PWR9 1
 // PPCPOWER10:#define __MMA__ 1
+// PPCPOWER10:#define __PCREL__ 1
 // PPCPOWER10-NOT:#define __ROP_PROTECTION__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu future -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCFUTURE %s
@@ -652,6 +653,7 @@
 // PPCFUTURE:#define _ARCH_PWR9 1
 // PPCFUTURE:#define _ARCH_PWR_FUTURE 1
 // PPCFUTURE:#define __MMA__ 1
+// PPCFUTURE:#define __PCREL__ 1
 // PPCFUTURE-NOT:#define __ROP_PROTECTION__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-feature +mma -target-cpu power10 -fno-signed-char < /dev/null | FileCheck -check-prefix PPC-MMA %s
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -199,6 +199,8 @@
 Builder.defineMacro("__ROP_PROTECTION__");
   if (HasP10Vector)
 Builder.defineMacro("__POWER10_VECTOR__");
+  if (HasPCRelativeMemops)
+Builder.defineMacro("__PCREL__");
 
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] eed88e9 - [OpenCL] Use spir target for CIndex tests for OpenCL.

2021-03-12 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-03-12T20:11:26Z
New Revision: eed88e91f331d158d3d0c91e91fca408c9f1d1e1

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

LOG: [OpenCL] Use spir target for CIndex tests for OpenCL.

This fixes failing bots.

Patch by azabaznov (Anton Zabaznov)!

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

Added: 


Modified: 
clang/test/Index/cxx.cl
clang/test/Index/opencl-types.cl

Removed: 




diff  --git a/clang/test/Index/cxx.cl b/clang/test/Index/cxx.cl
index f4b03d78740e..997d4288669f 100644
--- a/clang/test/Index/cxx.cl
+++ b/clang/test/Index/cxx.cl
@@ -3,5 +3,5 @@ void test(int *ptr) {
   addrspace_cast<__global int*>(ptr);
 }
 
-// RUN: c-index-test -test-load-source all %s -cl-std=clc++ | FileCheck %s
+// RUN: c-index-test -test-load-source all %s -cl-std=clc++ -target spir | 
FileCheck %s
 // CHECK: cxx.cl:3:3: CXXAddrspaceCastExpr

diff  --git a/clang/test/Index/opencl-types.cl 
b/clang/test/Index/opencl-types.cl
index 496f38752fa2..485060167d21 100644
--- a/clang/test/Index/opencl-types.cl
+++ b/clang/test/Index/opencl-types.cl
@@ -1,4 +1,4 @@
-// RUN: c-index-test -test-print-type %s -cl-std=CL2.0 | FileCheck %s
+// RUN: c-index-test -test-print-type %s -cl-std=CL2.0 -target spir | 
FileCheck %s
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable



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


[PATCH] D98539: [OpenCL] Set target as spir for c-index-test for OpenCL

2021-03-12 Thread Anastasia Stulova via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeed88e91f331: [OpenCL] Use spir target for CIndex tests for 
OpenCL. (authored by Anastasia).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98539

Files:
  clang/test/Index/cxx.cl
  clang/test/Index/opencl-types.cl


Index: clang/test/Index/opencl-types.cl
===
--- clang/test/Index/opencl-types.cl
+++ clang/test/Index/opencl-types.cl
@@ -1,4 +1,4 @@
-// RUN: c-index-test -test-print-type %s -cl-std=CL2.0 | FileCheck %s
+// RUN: c-index-test -test-print-type %s -cl-std=CL2.0 -target spir | 
FileCheck %s
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
Index: clang/test/Index/cxx.cl
===
--- clang/test/Index/cxx.cl
+++ clang/test/Index/cxx.cl
@@ -3,5 +3,5 @@
   addrspace_cast<__global int*>(ptr);
 }
 
-// RUN: c-index-test -test-load-source all %s -cl-std=clc++ | FileCheck %s
+// RUN: c-index-test -test-load-source all %s -cl-std=clc++ -target spir | 
FileCheck %s
 // CHECK: cxx.cl:3:3: CXXAddrspaceCastExpr


Index: clang/test/Index/opencl-types.cl
===
--- clang/test/Index/opencl-types.cl
+++ clang/test/Index/opencl-types.cl
@@ -1,4 +1,4 @@
-// RUN: c-index-test -test-print-type %s -cl-std=CL2.0 | FileCheck %s
+// RUN: c-index-test -test-print-type %s -cl-std=CL2.0 -target spir | FileCheck %s
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
Index: clang/test/Index/cxx.cl
===
--- clang/test/Index/cxx.cl
+++ clang/test/Index/cxx.cl
@@ -3,5 +3,5 @@
   addrspace_cast<__global int*>(ptr);
 }
 
-// RUN: c-index-test -test-load-source all %s -cl-std=clc++ | FileCheck %s
+// RUN: c-index-test -test-load-source all %s -cl-std=clc++ -target spir | FileCheck %s
 // CHECK: cxx.cl:3:3: CXXAddrspaceCastExpr
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-12 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I'm going to revert this in 30 minutes. The tree has been red for 12h due to 
this then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


  1   2   >