[clang-tools-extra] 2bb7774 - [clangd] Get rid of getBeginningOfIdentifier helper

2020-02-27 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-02-27T09:34:45+01:00
New Revision: 2bb7774ddf002668816fdb7c4a5b8da322fe284e

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

LOG: [clangd] Get rid of getBeginningOfIdentifier helper

Reviewers: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/SourceCode.h
clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 851d742711e5..ce0c6d11cada 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -27,7 +27,9 @@
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/Specifiers.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Index/IndexSymbol.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
@@ -523,24 +525,44 @@ llvm::Optional getHover(ParsedAST &AST, 
Position Pos,
format::FormatStyle Style,
const SymbolIndex *Index) {
   const SourceManager &SM = AST.getSourceManager();
-  llvm::Optional HI;
-  SourceLocation SourceLocationBeg = SM.getMacroArgExpandedLocation(
-  getBeginningOfIdentifier(Pos, SM, AST.getLangOpts()));
+  auto CurLoc = sourceLocationInMainFile(SM, Pos);
+  if (!CurLoc) {
+llvm::consumeError(CurLoc.takeError());
+return llvm::None;
+  }
+  auto TokensTouchingCursor =
+  syntax::spelledTokensTouching(*CurLoc, AST.getTokens());
+  if (TokensTouchingCursor.empty())
+return llvm::None;
 
-  if (auto Deduced = getDeducedType(AST.getASTContext(), SourceLocationBeg)) {
+  // In general we prefer the touching token that works over the one that
+  // doesn't, see SelectionTree::create(). The following locations are used 
only
+  // for triggering on macros and auto/decltype, so simply choosing the lone
+  // identifier-or-keyword token is equivalent.
+  SourceLocation IdentLoc;
+  SourceLocation AutoLoc;
+  for (const auto &Tok : TokensTouchingCursor) {
+if (Tok.kind() == tok::identifier)
+  IdentLoc = Tok.location();
+if (Tok.kind() == tok::kw_auto || Tok.kind() == tok::kw_decltype)
+  AutoLoc = Tok.location();
+  }
+
+  llvm::Optional HI;
+  if (auto Deduced = getDeducedType(AST.getASTContext(), AutoLoc)) {
 HI = getHoverContents(*Deduced, AST.getASTContext(), Index);
-  } else if (auto M = locateMacroAt(SourceLocationBeg, AST.getPreprocessor())) 
{
+HI->SymRange =
+getTokenRange(AST.getSourceManager(), AST.getLangOpts(), AutoLoc);
+  } else if (auto M = locateMacroAt(IdentLoc, AST.getPreprocessor())) {
 HI = getHoverContents(*M, AST);
+HI->SymRange =
+getTokenRange(AST.getSourceManager(), AST.getLangOpts(), IdentLoc);
   } else {
-auto Offset = positionToOffset(SM.getBufferData(SM.getMainFileID()), Pos);
-if (!Offset) {
-  llvm::consumeError(Offset.takeError());
-  return llvm::None;
-}
+auto Offset = SM.getFileOffset(*CurLoc);
 // Editors send the position on the left of the hovered character.
 // So our selection tree should be biased right. (Tested with VSCode).
 SelectionTree ST = SelectionTree::createRight(
-AST.getASTContext(), AST.getTokens(), *Offset, *Offset);
+AST.getASTContext(), AST.getTokens(), Offset, Offset);
 std::vector Result;
 if (const SelectionTree::Node *N = ST.commonAncestor()) {
   auto Decls = explicitReferenceTargets(N->ASTNode, DeclRelation::Alias);
@@ -565,9 +587,15 @@ llvm::Optional getHover(ParsedAST &AST, 
Position Pos,
   if (auto Formatted =
   tooling::applyAllReplacements(HI->Definition, Replacements))
 HI->Definition = *Formatted;
+  // FIXME: We should rather fill this with info coming from SelectionTree 
node.
+  if (!HI->SymRange) {
+SourceLocation ToHighlight = TokensTouchingCursor.front().location();
+if (IdentLoc.isValid())
+  ToHighlight = IdentLoc;
+HI->SymRange =
+getTokenRange(AST.getSourceManager(), AST.getLangOpts(), ToHighlight);
+  }
 
-  HI->SymRange = getTokenRange(AST.getSourceManager(), AST.getLangOpts(),
-   SourceLocationBeg);
   return HI;
 }
 

diff  --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index 5ac738055b54..2b0a857228bb 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/

[clang-tools-extra] f31fc10 - [clangd] Get rid of lexer usage in AST.cpp

2020-02-27 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-02-27T09:54:21+01:00
New Revision: f31fc1043d384e0b699fcb114694a5d8e1f51784

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

LOG: [clangd] Get rid of lexer usage in AST.cpp

Reviewers: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/AST.h

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index 836eb6a36459..021080c301f7 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -25,7 +25,6 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Index/USRGeneration.h"
-#include "clang/Lex/Lexer.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
@@ -417,16 +416,8 @@ class DeducedTypeVisitor : public 
RecursiveASTVisitor {
 
 llvm::Optional getDeducedType(ASTContext &ASTCtx,
 SourceLocation Loc) {
-  Token Tok;
-  // Only try to find a deduced type if the token is auto or decltype.
-  if (!Loc.isValid() ||
-  Lexer::getRawToken(Loc, Tok, ASTCtx.getSourceManager(),
- ASTCtx.getLangOpts(), false) ||
-  !Tok.is(tok::raw_identifier) ||
-  !(Tok.getRawIdentifier() == "auto" ||
-Tok.getRawIdentifier() == "decltype")) {
+  if (!Loc.isValid())
 return {};
-  }
   DeducedTypeVisitor V(Loc);
   V.TraverseAST(ASTCtx);
   if (V.DeducedType.isNull())

diff  --git a/clang-tools-extra/clangd/AST.h b/clang-tools-extra/clangd/AST.h
index a40aeaf32a77..c8b6008339e2 100644
--- a/clang-tools-extra/clangd/AST.h
+++ b/clang-tools-extra/clangd/AST.h
@@ -109,7 +109,6 @@ NestedNameSpecifierLoc getQualifierLoc(const NamedDecl &ND);
 QualType declaredType(const TypeDecl *D);
 
 /// Retrieves the deduced type at a given location (auto, decltype).
-/// Retuns None unless Loc starts an auto/decltype token.
 /// It will return the underlying type.
 llvm::Optional getDeducedType(ASTContext &, SourceLocation Loc);
 



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


[PATCH] D75229: Add signal-in-multithreaded-program check

2020-02-27 Thread Kocsis Ábel via Phabricator via cfe-commits
abelkocsis created this revision.
abelkocsis added reviewers: aaron.ballman, alexfh, hokein, jfb.
abelkocsis added projects: clang, clang-tools-extra.
Herald added subscribers: cfe-commits, mgehre, dexonsmith, mgorny.

According to 
https://wiki.sei.cmu.edu/confluence/display/c/CON37-C.+Do+not+call+signal%28%29+in+a+multithreaded+program
bugprone-signal-in-multithreaded-program check is created.
The check finds `signal` function call when the program is
multithreaded.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D75229

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SignalInMultithreadedProgramCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SignalInMultithreadedProgramCheck.h
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-signal-in-multithreaded-program.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-con37-c.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program.cpp
@@ -0,0 +1,36 @@
+// RUN: %check_clang_tidy %s bugprone-signal-in-multithreaded-program %t
+
+typedef unsigned long int thrd_t;
+typedef int (*thrd_start_t)(void *);
+typedef int sig_atomic_t;
+#define SIGUSR1 30
+#define NULL 0
+
+void (*signal(int sig, void (*handler)(int)))(int);
+
+int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) { return 0; };
+enum {
+  thrd_success = 0,
+};
+
+volatile sig_atomic_t flag = 0;
+
+void handler(int signum) {
+  flag = 1;
+}
+
+int func(void *data) {
+  while (!flag) {
+  }
+  return 0;
+}
+
+int main(void) {
+  signal(SIGUSR1, handler);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: singal function should not be called in a multithreaded program [bugprone-signal-in-multithreaded-program]
+  thrd_t tid;
+
+  if (thrd_success != thrd_create(&tid, func, NULL)) {
+  }
+  return 0;
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -73,6 +73,7 @@
`bugprone-parent-virtual-call `_, "Yes"
`bugprone-posix-return `_, "Yes"
`bugprone-reserved-identifier `_, "Yes"
+   `bugprone-signal-in-multithreaded-program `_,
`bugprone-signed-char-misuse `_,
`bugprone-sizeof-container `_,
`bugprone-sizeof-expression `_,
@@ -95,6 +96,7 @@
`bugprone-unused-return-value `_,
`bugprone-use-after-move `_,
`bugprone-virtual-near-miss `_, "Yes"
+   `cert-con37-c `_,
`cert-dcl21-cpp `_,
`cert-dcl50-cpp `_,
`cert-dcl58-cpp `_,
Index: clang-tools-extra/docs/clang-tidy/checks/cert-con37-c.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cert-con37-c.rst
@@ -0,0 +1,10 @@
+.. title:: clang-tidy - cert-con37-c
+.. meta::
+   :http-equiv=refresh: 5;URL=bugprone-signal-in-multithreaded-program.html
+
+cert-con37-c
+
+
+The cert-con37-c check is an alias, please see
+`bugprone-signal-in-multithreaded-program `_ 
+for more information.
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-signal-in-multithreaded-program.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-signal-in-multithreaded-program.rst
@@ -0,0 +1,19 @@
+.. title:: clang-tidy - bugprone-signal-in-multithreaded-program
+
+bugprone-signal-in-multithreaded-program
+
+
+Finds ``signal`` function calls when the program is multithreaded. It founds a
+program multithreaded when it finds at least one function call of the 
+following: ``thrd_create``, ``std::thread``, ``boost::thread``,
+``dlib::thread_function``, ``dlib::thread_pool``,
+``dlib::default_thread_pool``, ``pthread_t``.
+
+.. code-block: c
+
+signal(SIGUSR1, handler);
+thrd_t tid;
+
+This check corresponds to the CERT C++ Coding Standard rule
+`CON37-C. Do not call signal() in a multithreaded program
+`_.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -82,6 +82,15 @@
 
   Checks for usages of identifiers reserved for use by the implementation.
 
+- New :doc:`bugprone-signal-in-multithreaded-program
+  `

[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-02-27 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added inline comments.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:697-699
+  // The behavior is undefined if the value of the argument is not
+  // representable as unsigned char or is not equal to EOF. See e.g. C99
+  // 7.4.1.2 The isalpha function (p: 181-182).

martong wrote:
> Szelethus wrote:
> > This is true for the rest of the summaries as well, but shouldn't we 
> > retrieve the `unsigned char` size from `ASTContext`?
> Yes this is a good idea. I will do this.
> 
> What bothers me really much, however, is that we should handle EOF in a 
> platform dependent way as well ... and I have absolutely no idea how to do 
> that given that is defined by a macro in a platform specific header file. I 
> am desperately in need for help and ideas about how could we get the value of 
> EOF for the analysed platform.
If the EOF is not used in the TU analyzed, then there would be no way to find 
the specific `#define`.
Another approach would be to check if the value is defined by an expression 
that is the EOF define (maybe transitively?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898



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


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-02-27 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

It may be useful to make a "macro value map" kind of object. Some macros can be 
added to it as a string, and it is possible to lookup for an `Expr` if one of 
the added macros is used there. This can be done by checking the concrete 
(numeric) value of the `Expr` and compare to the value of the macro, or by 
checking if the expression comes from a macro and take this macro name (use 
string comparison). Such an object can be useful because the functionality is 
needed at more checkers, for example the ones I am working on (StreamChecker 
and ErrorReturnChecker too).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898



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


[PATCH] D75230: [clangd] Get rid of lexer usage in ObjCLocalizeStringLiteral tweak

2020-02-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75230

Files:
  clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp


Index: clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp
@@ -63,15 +63,19 @@
 
 Expected
 ObjCLocalizeStringLiteral::apply(const Selection &Inputs) {
-  auto &SM = Inputs.AST->getSourceManager();
-  auto &LangOpts = Inputs.AST->getASTContext().getLangOpts();
+  auto *AST = Inputs.AST;
+  auto &SM = AST->getSourceManager();
+  const auto &TB = AST->getTokens();
+  auto Toks = TB.spelledForExpanded(TB.expandedTokens(Str->getSourceRange()));
+  if (!Toks || Toks->empty())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Failed to find tokens to replace.");
+  // Insert `NSLocalizedString(` before the literal.
   auto Reps = tooling::Replacements(tooling::Replacement(
-  SM, CharSourceRange::getCharRange(Str->getBeginLoc()),
-  "NSLocalizedString(", LangOpts));
-  SourceLocation EndLoc = Lexer::getLocForEndOfToken(
-  Str->getEndLoc(), 0, Inputs.AST->getSourceManager(), LangOpts);
-  if (auto Err = Reps.add(tooling::Replacement(
-  SM, CharSourceRange::getCharRange(EndLoc), ", @\"\")", LangOpts)))
+  SM, Toks->front().location(), 0, "NSLocalizedString("));
+  // Insert `, @"")` after the literal.
+  if (auto Err = Reps.add(
+  tooling::Replacement(SM, Toks->back().endLocation(), 0, ", @\"\")")))
 return std::move(Err);
   return Effect::mainFileEdit(SM, std::move(Reps));
 }


Index: clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp
@@ -63,15 +63,19 @@
 
 Expected
 ObjCLocalizeStringLiteral::apply(const Selection &Inputs) {
-  auto &SM = Inputs.AST->getSourceManager();
-  auto &LangOpts = Inputs.AST->getASTContext().getLangOpts();
+  auto *AST = Inputs.AST;
+  auto &SM = AST->getSourceManager();
+  const auto &TB = AST->getTokens();
+  auto Toks = TB.spelledForExpanded(TB.expandedTokens(Str->getSourceRange()));
+  if (!Toks || Toks->empty())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Failed to find tokens to replace.");
+  // Insert `NSLocalizedString(` before the literal.
   auto Reps = tooling::Replacements(tooling::Replacement(
-  SM, CharSourceRange::getCharRange(Str->getBeginLoc()),
-  "NSLocalizedString(", LangOpts));
-  SourceLocation EndLoc = Lexer::getLocForEndOfToken(
-  Str->getEndLoc(), 0, Inputs.AST->getSourceManager(), LangOpts);
-  if (auto Err = Reps.add(tooling::Replacement(
-  SM, CharSourceRange::getCharRange(EndLoc), ", @\"\")", LangOpts)))
+  SM, Toks->front().location(), 0, "NSLocalizedString("));
+  // Insert `, @"")` after the literal.
+  if (auto Err = Reps.add(
+  tooling::Replacement(SM, Toks->back().endLocation(), 0, ", @\"\")")))
 return std::move(Err);
   return Effect::mainFileEdit(SM, std::move(Reps));
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8c26f42 - [clang, ARM, MVE] Remove redundant #includes in test file.

2020-02-27 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2020-02-27T09:39:35Z
New Revision: 8c26f42fe90e3f8612d2f57a3c9c5e7fcff5e91e

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

LOG: [clang,ARM,MVE] Remove redundant #includes in test file.

I made that file by pasting together several pieces, and forgot to
take out the #include  from the tops of the later ones, so
the test was pointlessly including the same header five times. NFC.

Added: 


Modified: 
clang/test/CodeGen/arm-mve-intrinsics/absneg.c

Removed: 




diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/absneg.c 
b/clang/test/CodeGen/arm-mve-intrinsics/absneg.c
index 94339c834809..4f888093d8b8 100644
--- a/clang/test/CodeGen/arm-mve-intrinsics/absneg.c
+++ b/clang/test/CodeGen/arm-mve-intrinsics/absneg.c
@@ -527,7 +527,6 @@ int32x4_t test_vqnegq_s32(int32x4_t a)
 return vqnegq_s32(a);
 #endif /* POLYMORPHIC */
 }
-#include 
 
 // CHECK-LABEL: @test_vnegq_m_f16(
 // CHECK-NEXT:  entry:
@@ -689,8 +688,6 @@ int32x4_t test_vnegq_x_s32(int32x4_t a, mve_pred16_t p)
 #endif /* POLYMORPHIC */
 }
 
-#include 
-
 // CHECK-LABEL: @test_vabsq_m_f16(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
@@ -851,8 +848,6 @@ int32x4_t test_vabsq_x_s32(int32x4_t a, mve_pred16_t p)
 #endif /* POLYMORPHIC */
 }
 
-#include 
-
 // CHECK-LABEL: @test_vqnegq_m_s8(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
@@ -901,8 +896,6 @@ int32x4_t test_vqnegq_m_s32(int32x4_t inactive, int32x4_t 
a, mve_pred16_t p)
 #endif /* POLYMORPHIC */
 }
 
-#include 
-
 // CHECK-LABEL: @test_vqabsq_m_s8(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = zext i16 [[P:%.*]] to i32



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


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-02-27 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

something like this:

  class MacroUsageDetector {
  public:
void addMacroName(StringRef MName);
bool isMacroUsed(StringRef MName, Expr *E, ???);
APSInt getMacroValue(StringRef MName);
  };

Or one that handles a single macro?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73898



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


[PATCH] D74973: [analyzer] StdLibraryFunctionsChecker refactor w/ inheritance

2020-02-27 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:151
+
+  using ValueConstraintPtr = std::shared_ptr;
+  /// The complete list of constraints that defines a single branch.

martong wrote:
> Note here, we need a copyable, polymorphic and default initializable type 
> (vector needs that). A raw pointer were good, however, we cannot default 
> initialize that. unique_ptr makes the Summary class non-copyable, therefore 
> not an option.
> Releasing the copyablitly requirement would render the initialization of the 
> Summary map infeasible.
> Perhaps we could come up with a [[ 
> https://www.youtube.com/watch?v=bIhUE5uUFOA | type erasure technique without 
> inheritance ]] once we consider the shared_ptr as restriction, but for now 
> that seems to be overkill.
std::variant (with std::monostate for the default constructibility) would also 
be an option  (if c++17 were supported). But this is not really an issue, i 
agree with that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74973



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


[PATCH] D75125: [Docs][OpenCL] Release 10.0 notes for OpenCL

2020-02-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

@hans, what is the current process for committing to the release branch? Would 
you be able to commit this or would you prefer that I commit myself?

Thank you!


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

https://reviews.llvm.org/D75125



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


[PATCH] D75125: [Docs][OpenCL] Release 10.0 notes for OpenCL

2020-02-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

> Thanks for writing notes! Go ahead and push directly to the branch when 
> you're ready.

Sorry. Missed this somehow!


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

https://reviews.llvm.org/D75125



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


[clang] 548e540 - [clang-format] Handle commas in [] in C#

2020-02-27 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-02-27T11:49:30Z
New Revision: 548e540d2ced9f5a596e0433f544c560a842a6a7

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

LOG: [clang-format] Handle commas in [] in C#

Summary:
Respect setting `SpacesInSquareBrackets` for commas in square brackets in C# 
code.

Reviewers: krasimir, MyDeveloperDay

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 04b20599638d..ff5827c8c4d4 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2893,6 +2893,10 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
 if (Left.is(TT_TemplateCloser) && Right.is(TT_StartOfName))
   return true;
 
+// space after comma in '[,]'.
+if (Left.is(tok::comma) && Right.is(tok::r_square))
+  return Style.SpacesInSquareBrackets;
+
 // space between keywords and paren e.g. "using ("
 if (Right.is(tok::l_paren))
   if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when))

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index 3bdaf3d5a9f3..0428de34728a 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -595,6 +595,10 @@ TEST_F(FormatTestCSharp, CSharpSpaces) {
   verifyFormat(R"(bool[] xs = { true, true };)", Style);
   verifyFormat(R"(taskContext.Factory.Run(async () => doThing(args);)", Style);
   verifyFormat(R"(catch (TestException) when (innerFinallyExecuted))", Style);
+  verifyFormat(R"(private float[,] Values;)", Style);
+
+  Style.SpacesInSquareBrackets = true;
+  verifyFormat(R"(private float[, ] Values;)", Style);
 }
 
 } // namespace format



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


[PATCH] D75125: [Docs][OpenCL] Release 10.0 notes for OpenCL

2020-02-27 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D75125#1895060 , @Anastasia wrote:

> @hans, what is the current process for committing to the release branch? 
> Would you be able to commit this or would you prefer that I commit myself?
>
> Thank you!


You can just push it to the branch when it's ready, or let me know and I can do 
it.


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

https://reviews.llvm.org/D75125



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


[PATCH] D75068: libclang: Add static build support for Windows

2020-02-27 Thread Cristian Adam via Phabricator via cfe-commits
cristian.adam added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75068



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


[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-02-27 Thread Thibault North via Phabricator via cfe-commits
tnorth added a comment.

Ping.


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326



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


[PATCH] D74910: [OpenCL] Remove spurious atomic_fetch_min/max builtins

2020-02-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

I would say if we are not aware of any test that this change breaks, let's go 
ahead and commit this?


Repository:
  rC Clang

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

https://reviews.llvm.org/D74910



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


[clang] 5122e82 - [driver][darwin] Don't use -platform_version flag by default (PR44813)

2020-02-27 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-02-27T13:48:26+01:00
New Revision: 5122e828701c88f8d53ee881bc68f3904454d154

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

LOG: [driver][darwin] Don't use -platform_version flag by default (PR44813)

The code in llvmorg-10-init-12188-g25ce33a6e4f is a breaking change for
users of older linkers who don't pass a version parameter, which
prevents a drop-in clang upgrade. Old tools can't know about what future
tools will do, so as a general principle the burden should be new tools
to be compatible by default. Also, for comparison, none of the other
tests of Version within AddLinkArgs add any new behaviors unless the
version is explicitly specified. Therefore, this patch changes the
-platform_version behavior from opt-out to opt-in.

Patch by David Major!

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-ld-platform-version-ios.c
clang/test/Driver/darwin-ld-platform-version-macos.c
clang/test/Driver/darwin-ld-platform-version-tvos.c
clang/test/Driver/darwin-ld-platform-version-watchos.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index b32fad791bd3..ab3a68b70f5d 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -335,7 +335,7 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const 
ArgList &Args,
   Args.AddAllArgs(CmdArgs, options::OPT_init);
 
   // Add the deployment target.
-  if (!Version[0] || Version[0] >= 520)
+  if (Version[0] >= 520)
 MachOTC.addPlatformVersionArgs(Args, CmdArgs);
   else
 MachOTC.addMinVersionArgs(Args, CmdArgs);

diff  --git a/clang/test/Driver/darwin-ld-platform-version-ios.c 
b/clang/test/Driver/darwin-ld-platform-version-ios.c
index 2255d3f990d7..05698032a326 100644
--- a/clang/test/Driver/darwin-ld-platform-version-ios.c
+++ b/clang/test/Driver/darwin-ld-platform-version-ios.c
@@ -1,9 +1,14 @@
 // RUN: touch %t.o
 
+// RUN: %clang -target arm64-apple-ios12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
+// RUN: %clang -target arm64-apple-ios12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: %clang -target arm64-apple-ios12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
-// RUN:   | FileCheck %s
+// RUN:   | FileCheck --check-prefix=LINKER-NEW  %s
 // RUN: %clang -target x86_64-apple-ios13-simulator -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=SIMUL %s
 
-// CHECK: "-platform_version" "ios" "12.3.0" "13.0"
+// LINKER-OLD: "-iphoneos_version_min" "12.3.0"
+// LINKER-NEW: "-platform_version" "ios" "12.3.0" "13.0"
 // SIMUL: "-platform_version" "ios-simulator" "13.0.0" "13.0"

diff  --git a/clang/test/Driver/darwin-ld-platform-version-macos.c 
b/clang/test/Driver/darwin-ld-platform-version-macos.c
index 1b849a6d2dfa..c1b940a3f35f 100644
--- a/clang/test/Driver/darwin-ld-platform-version-macos.c
+++ b/clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -1,11 +1,14 @@
 // RUN: touch %t.o
 
 // RUN: %clang -target x86_64-apple-macos10.13 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=0 -### %t.o 2>&1 \
-// RUN:   | FileCheck %s
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
+// RUN: %clang -target x86_64-apple-macos10.13 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: env SDKROOT=%S/Inputs/MacOSX10.14.sdk %clang -target 
x86_64-apple-macos10.13.0.1 -mlinker-version=520 -### %t.o 2>&1 \
-// RUN:   | FileCheck %s
+// RUN:   | FileCheck --check-prefix=LINKER-NEW %s
 
-// CHECK: "-platform_version" "macos" "10.13.0" "10.14"
+// LINKER-OLD: "-macosx_version_min" "10.13.0"
+// LINKER-NEW: "-platform_version" "macos" "10.13.0" "10.14"
 
 // RUN: %clang -target x86_64-apple-macos10.13  -mlinker-version=520 -### %t.o 
2>&1 \
 // RUN:   | FileCheck --check-prefix=NOSDK %s

diff  --git a/clang/test/Driver/darwin-ld-platform-version-tvos.c 
b/clang/test/Driver/darwin-ld-platform-version-tvos.c
index 1ef6a0b60004..39a2020cbb20 100644
--- a/clang/test/Driver/darwin-ld-platform-version-tvos.c
+++ b/clang/test/Driver/darwin-ld-platform-version-tvos.c
@@ -1,9 +1,14 @@
 // RUN: touch %t.o
 
+// RUN: %clang -target arm64-apple-tvos12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
+// RUN: %clang -target arm64-apple-tvos12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -m

[PATCH] D74784: [driver][darwin] Don't use -platform_version flag by default

2020-02-27 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D74784#1894484 , @dmajor wrote:

> Thanks! I'm still working on getting commit access, would one of you be able 
> to submit for me?


I've committed as 5122e828701c88f8d53ee881bc68f3904454d154 
 and 
pushed to 10.x as 38ee10d08cb5982bfc02dc4eea9a22743dccc6b6.


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

https://reviews.llvm.org/D74784



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


[PATCH] D75022: clang-format: Extend AllowShortLoopsOnASingleLine to do ... while loops.

2020-02-27 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar added a comment.

Not that I am aware of. Whoever ends up doing the merge will likely run the 
necessary tests before committing. If you've run as many as you can, then 
hopefully all will be fine.


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

https://reviews.llvm.org/D75022



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


[PATCH] D75163: [analyzer][StreamChecker] Adding precall and refactoring.

2020-02-27 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

To summarize, we're moving every stream check (illegal call to a stream 
management function with a null stream, or a closed stream, etc) to `preCall`, 
and leave only the modeling portions in `evalCall`. Makes sense!

You did an amazing job here! I like the new infrastructure and everything.




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:76-92
+  {{"fopen"}, {{}, &StreamChecker::evalFopen, ArgNone}},
+  {{"freopen", 3},
+   {&StreamChecker::preFreopen, &StreamChecker::evalFreopen, 2}},
+  {{"tmpfile"}, {{}, &StreamChecker::evalFopen, ArgNone}},
+  {{"fclose", 1},
+   {&StreamChecker::preDefault, &StreamChecker::evalFclose, 0}},
+  {{"fread", 4}, {&StreamChecker::preDefault, {}, 3}},

Hmm, all of these braces are kinda hard to navigate, but its not too bad. Could 
you check whether changing them to `nullptr` improves readability? I'll leave 
it to your judgement.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:109-114
+  ProgramStateRef ensureStreamNonNull(SVal StreamVal, CheckerContext &C,
+  ProgramStateRef State) const;
+  ProgramStateRef ensureFseekWhenceCorrect(SVal WhenceVal, CheckerContext &C,
+   ProgramStateRef State) const;
+  ProgramStateRef ensureStreamOpened(SVal StreamVal, CheckerContext &C,
+ ProgramStateRef State) const;

Could we add/move some comments for these? :)

```
Checks whether the stream is non-null. If it is null, an fatal bug report is 
emitted and the return value is nullptr. Otherwise in the returned state 
StreamVal is non-null.
```



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:161
+  ProgramStateRef State = C.getState();
+  SVal StreamVal = Call.getArgSVal(Desc->StreamArgNo);
+  State = ensureStreamNonNull(StreamVal, C, State);

This would assert in `Expr::getArg` if `Desc->StreamArgNo == ArgNone`, but that 
shouldn't ever happen in this function, correct? Could we add an assert here as 
well as a poor man's documentation?



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:192-194
+  // Do not allow NULL as passed stream pointer.
+  // This is not specified in the man page but may crash on some system.
+  // But allow a closed stream, is this correct?

According to my research, yes, closed streams are okay. Also, the rest of the 
comment can be removed as well -- it is for sure not okay to pass `NULL` to 
`freopen`, even if it doesn't crash on some systems.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:281-284
+  // Close the File Descriptor.
+  // Regardless if the close fails or not, stream becomes "closed"
+  // and can not be used any more.
+  State = State->set(Sym, StreamState::getClosed());

Ah, we're moving the closing of the stream from `checkDoubleClose` to here. 
Makes much more sense!



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:341-345
+// Check:
+// Using a stream pointer after 'fclose' causes undefined behavior
+// according to cppreference.com .
+// Using a stream that has failed to open is likely to cause problems, but not
+// explicitly mentioned in documentation.

Could we move this to the declaration and start it with `///`?



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:349-355
+  SymbolRef Sym = StreamVal.getAsSymbol();
   if (!Sym)
-return State;
+return nullptr;
 
   const StreamState *SS = State->get(Sym);
-
-  // If the file stream is not tracked, return.
   if (!SS)
+return nullptr;

Previously, we only returned a `nullptr` after generating a fatal error node. 
Why do we need to change this?



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:363-364
+new BuiltinBug(this, "Stream used after close",
+   "File descriptor is used after it was closed. "
+   "Cause undefined behaviour."));
   C.emitReport(std::make_unique(

How about

"Closing an already closed file descriptor."



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:381-382
+new BuiltinBug(this, "Stream used after failed open",
+   "(Re-)Opening the file descriptor has failed. "
+   "Using it can cause undefined behaviour."));
+  C.emitReport(std::make_unique(

How about

"Using a file descriptor after (re-)opening it failed."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75163



___
cfe-commits mailing list

[PATCH] D75056: [Driver] Default to -fno-common for all targets

2020-02-27 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer updated this revision to Diff 246917.
SjoerdMeijer edited the summary of this revision.
SjoerdMeijer added a comment.

> Are there any tests remaining that check that with -fcommon, IR generation 
> creates "common" variables, now that all these tests have been modified?

I've added a RUN line to `clang/test/CodeGen/no-common.c` with `-fcommon` that 
should test this.

> Suggestion:

Therefore, C code that uses tentative definitions as definitions of a variable 
in multiple translation units will trigger multiple-definition linker errors. 
Generally, this occurs when the use of the extern keyword is neglected in the 
declaration of a variable in a header file. In some cases, no specific 
translation unit provides a definition of the variable. The previous behavior 
can be restored by specifying -fcommon.

Thanks for your suggestion. I've verbatim added this to the release note.


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

https://reviews.llvm.org/D75056

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
  clang/test/CodeGen/2009-10-20-GlobalDebug.c
  clang/test/CodeGen/aarch64-sve.c
  clang/test/CodeGen/address-space.c
  clang/test/CodeGen/alias.c
  clang/test/CodeGen/align-systemz.c
  clang/test/CodeGen/alignment.c
  clang/test/CodeGen/asm-label.c
  clang/test/CodeGen/attr-weak-import.c
  clang/test/CodeGen/attr-weakref2.c
  clang/test/CodeGen/attributes.c
  clang/test/CodeGen/blocks-windows.c
  clang/test/CodeGen/bool-convert.c
  clang/test/CodeGen/c11atomics.c
  clang/test/CodeGen/cfstring-elf-cfbuild-x86_64.c
  clang/test/CodeGen/cfstring-windows.c
  clang/test/CodeGen/default-address-space.c
  clang/test/CodeGen/dllexport-1.c
  clang/test/CodeGen/dllexport.c
  clang/test/CodeGen/dllimport.c
  clang/test/CodeGen/microsoft-no-common-align.c
  clang/test/CodeGen/no-common.c
  clang/test/CodeGen/pr25786.c
  clang/test/CodeGen/pragma-pack-1.c
  clang/test/CodeGen/pragma-weak.c
  clang/test/CodeGen/private-extern-redef.c
  clang/test/CodeGen/tentative-decls.c
  clang/test/CodeGen/tls-model.c
  clang/test/CodeGen/visibility.c
  clang/test/CodeGen/vlt_to_pointer.c
  clang/test/CodeGen/volatile-1.c
  clang/test/CodeGen/weak-global.c
  clang/test/CodeGen/windows-on-arm-dllimport-dllexport.c
  clang/test/CodeGenCXX/clang-sections-tentative.c
  clang/test/CodeGenObjC/constant-string-class.m
  clang/test/CodeGenObjC/tentative-cfconstantstring.m
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
  clang/test/Driver/apple-kext-mkernel.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fuchsia.c
  clang/test/Driver/no-common.c
  clang/test/Driver/xcore-opts.c
  clang/test/Frontend/ast-codegen.c
  clang/test/Headers/xmmintrin.c
  clang/test/PCH/chain-external-defs.c
  clang/test/PCH/external-defs.c
  clang/test/PCH/tentative-defs.c
  clang/test/Parser/pragma-visibility2.c

Index: clang/test/Parser/pragma-visibility2.c
===
--- clang/test/Parser/pragma-visibility2.c
+++ clang/test/Parser/pragma-visibility2.c
@@ -6,14 +6,14 @@
 #pragma GCC visibility push(hidden)
 
 int v1;
-// CHECK: @v1 = common hidden global i32 0, align 4
+// CHECK: @v1 = hidden global i32 0, align 4
 
 #pragma GCC visibility pop
 
 int v2;
-// CHECK: @v2 = common global i32 0, align 4
+// CHECK: @v2 = global i32 0, align 4
 
 _Pragma("GCC visibility push(hidden)");
 
 int v3;
-// CHECK: @v3 = common hidden global i32 0, align 4
+// CHECK: @v3 = hidden global i32 0, align 4
Index: clang/test/PCH/tentative-defs.c
===
--- clang/test/PCH/tentative-defs.c
+++ clang/test/PCH/tentative-defs.c
@@ -1,6 +1,6 @@
 // Test with pch.
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t.pch %S/tentative-defs.h
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t.pch -verify -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fcommon -emit-pch -o %t.pch %S/tentative-defs.h
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fcommon -include-pch %t.pch -verify -emit-llvm -o %t %s
 // REQUIRES: x86-registered-target
 
 // RUN: grep "@variable = common global i32 0" %t | count 1
Index: clang/test/PCH/external-defs.c
===
--- clang/test/PCH/external-defs.c
+++ clang/test/PCH/external-defs.c
@@ -3,16 +3,16 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t.pch %S/external-defs.h
 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t.pch -emit-llvm -o %t %s
 
-// RUN: grep "@x = common global i32 0" %t | count 1
+// RUN: grep "@x = global i32 0" %t | count 1
 // RUN: not grep "@z" %t
 
 // RUN: grep "@x2 = global i32 19" %t | count 1
 i

[PATCH] D75244: [clang-format] Recognize C# named argument colons as a token type

2020-02-27 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe created this revision.
jbcoe added a reviewer: krasimir.
jbcoe added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

No longer merge 'name' and ':' into a single token.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75244

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

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -546,6 +546,8 @@
 PrintOrderDetails(orderNum: 31, productName: "Red Mug",  // comment
   sellerName: "Gift Shop");)",
Style);
+
+  verifyFormat(R"(foreach (var tickCount in task.Begin(seed: 0)) {)", Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpPropertyAccessors) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -776,6 +776,11 @@
   Tok->Type = TT_JsTypeColon;
   break;
 }
+  } else if (Style.isCSharp()) {
+if (Contexts.back().ContextKind == tok::l_paren) {
+  Tok->Type = TT_CSharpNamedArgumentColon;
+  break;
+}
   }
   if (Contexts.back().ColonIsDictLiteral ||
   Style.Language == FormatStyle::LK_Proto ||
@@ -3052,6 +3057,8 @@
   return Style.SpacesInContainerLiterals;
 if (Right.is(TT_AttributeColon))
   return false;
+if (Right.is(TT_CSharpNamedArgumentColon))
+  return false;
 return true;
   }
   if (Left.is(TT_UnaryOperator)) {
@@ -3200,7 +3207,11 @@
   if (Right.NewlinesBefore > 1 && Style.MaxEmptyLinesToKeep > 0)
 return true;
 
-  if (Style.Language == FormatStyle::LK_JavaScript) {
+  if (Style.isCSharp()) {
+if (Right.is(TT_CSharpNamedArgumentColon) ||
+Left.is(TT_CSharpNamedArgumentColon))
+  return false;
+  } else if (Style.Language == FormatStyle::LK_JavaScript) {
 // FIXME: This might apply to other languages and token kinds.
 if (Right.is(tok::string_literal) && Left.is(tok::plus) && Left.Previous &&
 Left.Previous->is(tok::string_literal))
@@ -3485,7 +3496,11 @@
 bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
 const FormatToken &Right) {
   const FormatToken &Left = *Right.Previous;
-
+  if (Style.isCSharp()) {
+if (Left.is(TT_CSharpNamedArgumentColon) ||
+Right.is(TT_CSharpNamedArgumentColon))
+  return false;
+  }
   // Language-specific stuff.
   if (Style.Language == FormatStyle::LK_Java) {
 if (Left.isOneOf(Keywords.kw_throws, Keywords.kw_extends,
Index: clang/lib/Format/FormatTokenLexer.h
===
--- clang/lib/Format/FormatTokenLexer.h
+++ clang/lib/Format/FormatTokenLexer.h
@@ -56,7 +56,6 @@
   bool tryMergeCSharpDoubleQuestion();
   bool tryTransformCSharpForEach();
   bool tryMergeCSharpAttributeAndTarget();
-  bool tryMergeCSharpNamedArgument();
 
   bool tryMergeTokens(ArrayRef Kinds, TokenType NewType);
 
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -76,8 +76,6 @@
 return;
 
   if (Style.isCSharp()) {
-if (tryMergeCSharpNamedArgument())
-  return;
 if (tryMergeCSharpAttributeAndTarget())
   return;
 if (tryMergeCSharpKeywordVariables())
@@ -186,39 +184,6 @@
   return true;
 }
 
-// Merge 'argName' and ':' into a single token in `foo(argName: bar)`.
-bool FormatTokenLexer::tryMergeCSharpNamedArgument() {
-  if (Tokens.size() < 2)
-return false;
-  auto &Colon = *(Tokens.end() - 1);
-  if (!Colon->is(tok::colon))
-return false;
-
-  auto &Name = *(Tokens.end() - 2);
-  if (!Name->is(tok::identifier))
-return false;
-
-  const FormatToken *CommaOrLeftParen = nullptr;
-  for (auto I = Tokens.rbegin() + 2, E = Tokens.rend(); I != E; ++I) {
-// NB: Because previous pointers are not initialized yet, this cannot use
-// Token.getPreviousNonComment.
-if ((*I)->isNot(tok::comment)) {
-  CommaOrLeftParen = *I;
-  break;
-}
-  }
-
-  if (!CommaOrLeftParen || !CommaOrLeftParen->isOneOf(tok::l_paren, tok::comma))
-return false;
-
-  Name->TokenText = StringRef(Name->TokenText.begin(),
-  Colon->TokenText.end() - Name->TokenText.begin());
-  Name->ColumnWidth += Colon->ColumnWidth;
-  Name->Type = TT_CSharpNamedArgument;
-  Tokens.erase(Tokens.end() - 1);
-  return true;
-}
-
 // Search for verbatim or interpolated string literals @"ABC" or
 // $"a{abc}a" i and mark the token as TT_CSharpStringLi

[PATCH] D75244: [clang-format] Recognize C# named argument colons as a token type

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

This is very nice! Brings the C# handling of the colon closer to other 
languages.




Comment at: clang/lib/Format/TokenAnnotator.cpp:3499
   const FormatToken &Left = *Right.Previous;
-
+  if (Style.isCSharp()) {
+if (Left.is(TT_CSharpNamedArgumentColon) ||

nit: please put this as an else if into the "// Language-specific stuff" 
section below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75244



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


[PATCH] D74387: [SYCL] Do not diagnose use of __float128

2020-02-27 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added a comment.

@rjmccall, Thank you very much for so detailed response, It really helps. I 
started working on implementation and I have a couple of questions/problems 
with this particular appoach.

> - If `foo` uses `__float128` (whether in its signature or internally), that 
> is invalid in device mode, but the diagnostic will be delayed by the 
> forbidden-type mechanism, meaning that it will become an `unavailable` 
> attribute on `foo`.

So, for example if some variable is declared with `__float128` type, we are 
adding to parent function Unavaliable attribute, right?

> - If `bar` uses `foo`, that use is invalid in device mode (because of the 
> `unavailable` attribute), but the diagnostic will be delayed via the standard 
> CUDA/OMP mechanism because we don't know yet whether `bar` should be emitted 
> as a device function.
> - If `kernel` uses `bar`, that will trigger the emission of the delayed 
> diagnostics of `bar`, including the use-of-`unavailable`-function diagnostic 
> where it uses `foo`.  It should be straightforward to specialize this 
> diagnostic so that it reports the error by actually diagnosing the use of 
> `__float128` at the original location (which is recorded in the `unavailable` 
> attribute) and then just adding a note about how `foo` is used by `bar`.

Consider following example (this is absolutely valid SYCL code, except 
__float128 usage):

  // Host code:
  __float128 A;
  // Everything what lambda passed to `single_task` calls becomes device code. 
Capturing of host variables means that these variables will be passed to device 
by value, so using of A in this lambda is invalid.
  sycl_kernel([=]() {auto B = A});

In this case we add unavailable attribute to parent function for variable `A` 
declaration. But this function is not called from device code. Please correct 
me if I'm wrong but it seems that we need to diagnose not only functions, but 
also  usages of any declarations with unavailable attribute including variable 
declarations, right?

In addition, there are a couple of problems with this approach, for example 
with unevaluated `sizeof` context, i.e. code like this:

  sycl_kernel([=]() {int A = sizeof(__float128);});

is diagnosed too, which IMO shouldn't be diagnosed.

I can upload what I have now to this review if it will help better (or maybe we 
will understand that I'm doing something wrong).

I'm also thinking about a bit another approach:

- If some declaration uses `__float128` it will become an unavailable attribute 
on this declaration. That means we don't always add unavailable attribute to 
the function which uses `__float128` internally.
- In the place where clang actually emits `use-of-unavailable-declaration` 
diagnostics (somewhere in `DoEmitAvailabilityWarning` function, defined in 
`SemaAvailability.cpp`) for SYCL, we make these diagnostics deferred using 
CUDA/OMP deferred diagnostics mechanism (using SYCL-specific analog of function 
like `diagIfOpenMPDeviceCode`/`CUDADiagIfDeviceCode`).

But this won't emit diagnostics for simple declarations which has __float128 
type, but is not used anywhere in code.

I'm also curious about OpenMP handling of this "unsupported type" problem. 
@ABataev , Am I right that in OpenMP such diagnostics are emitted only if 
forbidden type is used in some arithmetical operations? Is it enough to prevent 
problems on various GPU devices which don't support this type?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74387



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


[clang] 7ea9a6e - Revert "make -fmodules-codegen and -fmodules-debuginfo work also with PCHs"

2020-02-27 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-02-27T14:33:43+01:00
New Revision: 7ea9a6e0220da36ff2fd1fbc29c2755be23e5166

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

LOG: Revert "make -fmodules-codegen and -fmodules-debuginfo work also with PCHs"

This caused PR44953. See also the discussion on D74846.

This reverts commit cbc9d22e49b434b6ceb2eb94b67079d02e0a7b74.

Added: 


Modified: 
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/Modules/Inputs/codegen-flags/foo.h

Removed: 
clang/test/PCH/codegen.cpp



diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 29abb9c65a9d..a74ccc9ed179 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -3224,8 +3224,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned 
ClientLoadCapabilities) {
 case MODULAR_CODEGEN_DECLS:
   // FIXME: Skip reading this record if our ASTConsumer doesn't care about
   // them (ie: if we're not codegenerating this module).
-  if (F.Kind == MK_MainFile ||
-  getContext().getLangOpts().BuildingPCHWithObjectFile)
+  if (F.Kind == MK_MainFile)
 for (unsigned I = 0, N = Record.size(); I != N; ++I)
   EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
   break;

diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 091bf566a670..362d3eaebdd2 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -502,12 +502,8 @@ uint64_t ASTDeclReader::GetCurrentCursorOffset() {
 }
 
 void ASTDeclReader::ReadFunctionDefinition(FunctionDecl *FD) {
-  if (Record.readInt()) {
+  if (Record.readInt())
 Reader.DefinitionSource[FD] = Loc.F->Kind == ModuleKind::MK_MainFile;
-if (Reader.getContext().getLangOpts().BuildingPCHWithObjectFile &&
-Reader.DeclIsFromPCHWithObjectFile(FD))
-  Reader.DefinitionSource[FD] = true;
-  }
   if (auto *CD = dyn_cast(FD)) {
 CD->setNumCtorInitializers(Record.readInt());
 if (CD->getNumCtorInitializers())
@@ -1422,12 +1418,8 @@ ASTDeclReader::RedeclarableResult 
ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
   Reader.getContext().setBlockVarCopyInit(VD, CopyExpr, Record.readInt());
   }
 
-  if (VD->getStorageDuration() == SD_Static && Record.readInt()) {
+  if (VD->getStorageDuration() == SD_Static && Record.readInt())
 Reader.DefinitionSource[VD] = Loc.F->Kind == ModuleKind::MK_MainFile;
-if (Reader.getContext().getLangOpts().BuildingPCHWithObjectFile &&
-Reader.DeclIsFromPCHWithObjectFile(VD))
-  Reader.DefinitionSource[VD] = true;
-  }
 
   enum VarKind {
 VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
@@ -1686,12 +1678,8 @@ void ASTDeclReader::ReadCXXDefinitionData(
   Data.ODRHash = Record.readInt();
   Data.HasODRHash = true;
 
-  if (Record.readInt()) {
+  if (Record.readInt())
 Reader.DefinitionSource[D] = Loc.F->Kind == ModuleKind::MK_MainFile;
-if (Reader.getContext().getLangOpts().BuildingPCHWithObjectFile &&
-Reader.DeclIsFromPCHWithObjectFile(D))
-  Reader.DefinitionSource[D] = true;
-  }
 
   Data.NumBases = Record.readInt();
   if (Data.NumBases)

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 159ebe1c01ac..6f77d4f5d115 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -5596,8 +5596,8 @@ void ASTRecordWriter::AddCXXDefinitionData(const 
CXXRecordDecl *D) {
 
   // getODRHash will compute the ODRHash if it has not been previously 
computed.
   Record->push_back(D->getODRHash());
-  bool ModulesDebugInfo =
-  Writer->Context->getLangOpts().ModulesDebugInfo && !D->isDependentType();
+  bool ModulesDebugInfo = Writer->Context->getLangOpts().ModulesDebugInfo &&
+  Writer->WritingModule && !D->isDependentType();
   Record->push_back(ModulesDebugInfo);
   if (ModulesDebugInfo)
 Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(D));

diff  --git a/clang/lib/Serialization/ASTWriterDecl.cpp 
b/clang/lib/Serialization/ASTWriterDecl.cpp
index 472136d99a13..92d566fc7854 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1011,16 +1011,15 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
 
   if (D->getStorageDuration() == SD_Static) {
 bool ModulesCodegen = false;
-if (!D->getDescribedVarTemplate() && !D->getMemberSpecializationInfo() &&
+if (Writer.WritingModule &&
+!D->getDescribedVarTemplate() && !D->getMemberSpecia

[PATCH] D74846: fix -fcodegen-modules code when used with PCH (PR44953)

2020-02-27 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I've reverted cbc9d22e49b434b6ceb2eb94b67079d02e0a7b74 
 on master 
in 7ea9a6e0220da36ff2fd1fbc29c2755be23e5166 
 until it 
can be resolved properly.

The revert was also pushed to 10.x as a8684e93a347b5a7ecbb07bad40301f1699a813a 
.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74846



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


[PATCH] D75244: [clang-format] Recognize C# named argument colons as a token type

2020-02-27 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe updated this revision to Diff 246924.
jbcoe added a comment.

Consolidate if blocks following review comment.


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

https://reviews.llvm.org/D75244

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

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -546,6 +546,8 @@
 PrintOrderDetails(orderNum: 31, productName: "Red Mug",  // comment
   sellerName: "Gift Shop");)",
Style);
+
+  verifyFormat(R"(foreach (var tickCount in task.Begin(seed: 0)) {)", Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpPropertyAccessors) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -776,6 +776,11 @@
   Tok->Type = TT_JsTypeColon;
   break;
 }
+  } else if (Style.isCSharp()) {
+if (Contexts.back().ContextKind == tok::l_paren) {
+  Tok->Type = TT_CSharpNamedArgumentColon;
+  break;
+}
   }
   if (Contexts.back().ColonIsDictLiteral ||
   Style.Language == FormatStyle::LK_Proto ||
@@ -3052,6 +3057,8 @@
   return Style.SpacesInContainerLiterals;
 if (Right.is(TT_AttributeColon))
   return false;
+if (Right.is(TT_CSharpNamedArgumentColon))
+  return false;
 return true;
   }
   if (Left.is(TT_UnaryOperator)) {
@@ -3200,7 +3207,11 @@
   if (Right.NewlinesBefore > 1 && Style.MaxEmptyLinesToKeep > 0)
 return true;
 
-  if (Style.Language == FormatStyle::LK_JavaScript) {
+  if (Style.isCSharp()) {
+if (Right.is(TT_CSharpNamedArgumentColon) ||
+Left.is(TT_CSharpNamedArgumentColon))
+  return false;
+  } else if (Style.Language == FormatStyle::LK_JavaScript) {
 // FIXME: This might apply to other languages and token kinds.
 if (Right.is(tok::string_literal) && Left.is(tok::plus) && Left.Previous &&
 Left.Previous->is(tok::string_literal))
@@ -3485,9 +3496,12 @@
 bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
 const FormatToken &Right) {
   const FormatToken &Left = *Right.Previous;
-
   // Language-specific stuff.
-  if (Style.Language == FormatStyle::LK_Java) {
+  if (Style.isCSharp()) {
+if (Left.is(TT_CSharpNamedArgumentColon) ||
+Right.is(TT_CSharpNamedArgumentColon))
+  return false;
+  } else if (Style.Language == FormatStyle::LK_Java) {
 if (Left.isOneOf(Keywords.kw_throws, Keywords.kw_extends,
  Keywords.kw_implements))
   return false;
Index: clang/lib/Format/FormatTokenLexer.h
===
--- clang/lib/Format/FormatTokenLexer.h
+++ clang/lib/Format/FormatTokenLexer.h
@@ -56,7 +56,6 @@
   bool tryMergeCSharpDoubleQuestion();
   bool tryTransformCSharpForEach();
   bool tryMergeCSharpAttributeAndTarget();
-  bool tryMergeCSharpNamedArgument();
 
   bool tryMergeTokens(ArrayRef Kinds, TokenType NewType);
 
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -76,8 +76,6 @@
 return;
 
   if (Style.isCSharp()) {
-if (tryMergeCSharpNamedArgument())
-  return;
 if (tryMergeCSharpAttributeAndTarget())
   return;
 if (tryMergeCSharpKeywordVariables())
@@ -186,39 +184,6 @@
   return true;
 }
 
-// Merge 'argName' and ':' into a single token in `foo(argName: bar)`.
-bool FormatTokenLexer::tryMergeCSharpNamedArgument() {
-  if (Tokens.size() < 2)
-return false;
-  auto &Colon = *(Tokens.end() - 1);
-  if (!Colon->is(tok::colon))
-return false;
-
-  auto &Name = *(Tokens.end() - 2);
-  if (!Name->is(tok::identifier))
-return false;
-
-  const FormatToken *CommaOrLeftParen = nullptr;
-  for (auto I = Tokens.rbegin() + 2, E = Tokens.rend(); I != E; ++I) {
-// NB: Because previous pointers are not initialized yet, this cannot use
-// Token.getPreviousNonComment.
-if ((*I)->isNot(tok::comment)) {
-  CommaOrLeftParen = *I;
-  break;
-}
-  }
-
-  if (!CommaOrLeftParen || !CommaOrLeftParen->isOneOf(tok::l_paren, tok::comma))
-return false;
-
-  Name->TokenText = StringRef(Name->TokenText.begin(),
-  Colon->TokenText.end() - Name->TokenText.begin());
-  Name->ColumnWidth += Colon->ColumnWidth;
-  Name->Type = TT_CSharpNamedArgument;
-  Tokens.erase(Tokens.end() - 1);
-  return true;
-}
-
 // Search for verbatim or interpolated string literals @"ABC" or
 // $"a{abc}a" i a

[clang] 7dfe0cc - [clang-format] Recognize C# named argument colons as a token type

2020-02-27 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-02-27T13:47:29Z
New Revision: 7dfe0cc7f5765dc729685a0aa468cdf54a265a11

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

LOG: [clang-format] Recognize C# named argument colons as a token type

Summary:
No longer merge 'name' and ':' into a single token.

Ensure that line breaks cannot be placed before or after a named-argument colon.

Ensure that no space is inserted before a named-argument colon.

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: cfe-commits, MyDeveloperDay

Tags: #clang-format, #clang

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 6bbfdcf37f93..bab513a03a33 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -103,7 +103,7 @@ namespace format {
   TYPE(UnaryOperator)  
\
   TYPE(CSharpStringLiteral)
\
   TYPE(CSharpNullCoalescing)   
\
-  TYPE(CSharpNamedArgument)
\
+  TYPE(CSharpNamedArgumentColon)   
\
   TYPE(Unknown)
 
 enum TokenType {

diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index 8acae56e2232..aa8cf427d468 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -76,8 +76,6 @@ void FormatTokenLexer::tryMergePreviousTokens() {
 return;
 
   if (Style.isCSharp()) {
-if (tryMergeCSharpNamedArgument())
-  return;
 if (tryMergeCSharpAttributeAndTarget())
   return;
 if (tryMergeCSharpKeywordVariables())
@@ -186,39 +184,6 @@ bool FormatTokenLexer::tryMergeJSPrivateIdentifier() {
   return true;
 }
 
-// Merge 'argName' and ':' into a single token in `foo(argName: bar)`.
-bool FormatTokenLexer::tryMergeCSharpNamedArgument() {
-  if (Tokens.size() < 2)
-return false;
-  auto &Colon = *(Tokens.end() - 1);
-  if (!Colon->is(tok::colon))
-return false;
-
-  auto &Name = *(Tokens.end() - 2);
-  if (!Name->is(tok::identifier))
-return false;
-
-  const FormatToken *CommaOrLeftParen = nullptr;
-  for (auto I = Tokens.rbegin() + 2, E = Tokens.rend(); I != E; ++I) {
-// NB: Because previous pointers are not initialized yet, this cannot use
-// Token.getPreviousNonComment.
-if ((*I)->isNot(tok::comment)) {
-  CommaOrLeftParen = *I;
-  break;
-}
-  }
-
-  if (!CommaOrLeftParen || !CommaOrLeftParen->isOneOf(tok::l_paren, 
tok::comma))
-return false;
-
-  Name->TokenText = StringRef(Name->TokenText.begin(),
-  Colon->TokenText.end() - 
Name->TokenText.begin());
-  Name->ColumnWidth += Colon->ColumnWidth;
-  Name->Type = TT_CSharpNamedArgument;
-  Tokens.erase(Tokens.end() - 1);
-  return true;
-}
-
 // Search for verbatim or interpolated string literals @"ABC" or
 // $"a{abc}a" i and mark the token as TT_CSharpStringLiteral, and to
 // prevent splitting of @, $ and ".
@@ -609,7 +574,7 @@ void 
FormatTokenLexer::handleCSharpVerbatimAndInterpolatedStrings() {
   size_t LastBreak = LiteralText.rfind('\n');
   if (LastBreak != StringRef::npos) {
 CSharpStringLiteral->IsMultiline = true;
-unsigned StartColumn = 0; // The template tail spans the entire line.
+unsigned StartColumn = 0;
 CSharpStringLiteral->LastLineColumnWidth = encoding::columnWidthWithTabs(
 LiteralText.substr(LastBreak + 1, LiteralText.size()), StartColumn,
 Style.TabWidth, Encoding);

diff  --git a/clang/lib/Format/FormatTokenLexer.h 
b/clang/lib/Format/FormatTokenLexer.h
index 1f930d75e805..4fffb36272f7 100644
--- a/clang/lib/Format/FormatTokenLexer.h
+++ b/clang/lib/Format/FormatTokenLexer.h
@@ -56,7 +56,6 @@ class FormatTokenLexer {
   bool tryMergeCSharpDoubleQuestion();
   bool tryTransformCSharpForEach();
   bool tryMergeCSharpAttributeAndTarget();
-  bool tryMergeCSharpNamedArgument();
 
   bool tryMergeTokens(ArrayRef Kinds, TokenType NewType);
 

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index ff5827c8c4d4..fb60b8fb7b58 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -776,6 +776,11 @@ class AnnotatingParser {
   Tok->Type = TT_JsTypeColon;
   break;
 }
+  } else if (Style.isCSharp()) {
+if (Contexts.back().

[clang-tools-extra] aa324c5 - [clangd][NFC] Don't query the index if the rename symbol is function

2020-02-27 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-02-27T15:04:51+01:00
New Revision: aa324c5441f229bd1ff07407affeab95740328fe

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

LOG: [clangd][NFC] Don't query the index if the rename symbol is function
local.

This would save an unnecessary index query when renaming a function
local symbol in cross-file rename mode.

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index fd2146eb4fb7..d31af9c2adf1 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -531,8 +531,9 @@ llvm::Expected rename(const RenameInputs 
&RInputs) {
   if (!MainFileRenameEdit)
 return MainFileRenameEdit.takeError();
 
-  if (!Opts.AllowCrossFile) {
-// Within-file rename: just return the main file results.
+  // return the main file edit if this is a within-file rename or the symbol
+  // being renamed is function local.
+  if (!Opts.AllowCrossFile || RenameDecl.getParentFunctionOrMethod()) {
 return FileEdits(
 {std::make_pair(RInputs.MainFilePath,
 Edit{MainFileCode, std::move(*MainFileRenameEdit)})});



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


[PATCH] D75249: [clangd] Use tokenize instead of raw lexer in SourceCode/lex

2020-02-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: hokein, sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75249

Files:
  clang-tools-extra/clangd/SourceCode.cpp

Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -23,6 +23,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Token.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
@@ -612,31 +613,26 @@
 
 static void
 lex(llvm::StringRef Code, const LangOptions &LangOpts,
-llvm::function_ref
+llvm::function_ref
 Action) {
   // FIXME: InMemoryFileAdapter crashes unless the buffer is null terminated!
   std::string NullTerminatedCode = Code.str();
   SourceManagerForFile FileSM("dummy.cpp", NullTerminatedCode);
   auto &SM = FileSM.get();
-  auto FID = SM.getMainFileID();
-  // Create a raw lexer (with no associated preprocessor object).
-  Lexer Lex(FID, SM.getBuffer(FID), SM, LangOpts);
-  Token Tok;
-
-  while (!Lex.LexFromRawLexer(Tok))
+  for (const auto &Tok : syntax::tokenize(SM.getMainFileID(), SM, LangOpts))
 Action(Tok, SM);
-  // LexFromRawLexer returns true after it lexes last token, so we still have
-  // one more token to report.
-  Action(Tok, SM);
 }
 
 llvm::StringMap collectIdentifiers(llvm::StringRef Content,
  const format::FormatStyle &Style) {
   llvm::StringMap Identifiers;
   auto LangOpt = format::getFormattingLangOpts(Style);
-  lex(Content, LangOpt, [&](const clang::Token &Tok, const SourceManager &) {
-if (Tok.getKind() == tok::raw_identifier)
-  ++Identifiers[Tok.getRawIdentifier()];
+  lex(Content, LangOpt, [&](const syntax::Token &Tok, const SourceManager &SM) {
+if (Tok.kind() == tok::identifier)
+  ++Identifiers[Tok.text(SM)];
+// FIXME: Should this function really return keywords too ?
+else if (auto *Keyword = tok::getKeywordSpelling(Tok.kind()))
+  ++Identifiers[Keyword];
   });
   return Identifiers;
 }
@@ -645,16 +641,13 @@
llvm::StringRef Content,
const LangOptions &LangOpts) {
   std::vector Ranges;
-  lex(Content, LangOpts, [&](const clang::Token &Tok, const SourceManager &SM) {
-if (Tok.getKind() != tok::raw_identifier)
-  return;
-if (Tok.getRawIdentifier() != Identifier)
-  return;
-auto Range = getTokenRange(SM, LangOpts, Tok.getLocation());
-if (!Range)
-  return;
-Ranges.push_back(*Range);
-  });
+  lex(Content, LangOpts,
+  [&](const syntax::Token &Tok, const SourceManager &SM) {
+if (Tok.kind() != tok::identifier || Tok.text(SM) != Identifier)
+  return;
+if (auto Range = getTokenRange(SM, LangOpts, Tok.location()))
+  Ranges.push_back(*Range);
+  });
   return Ranges;
 }
 
@@ -691,97 +684,116 @@
 
   NamespaceEvent Event;
   lex(Code, format::getFormattingLangOpts(Style),
-  [&](const clang::Token &Tok,const SourceManager &SM) {
-Event.Pos = sourceLocToPosition(SM, Tok.getLocation());
-switch (Tok.getKind()) {
-case tok::raw_identifier:
-  // In raw mode, this could be a keyword or a name.
-  switch (State) {
-  case UsingNamespace:
-  case UsingNamespaceName:
-NSName.append(std::string(Tok.getRawIdentifier()));
-State = UsingNamespaceName;
-break;
-  case Namespace:
-  case NamespaceName:
-NSName.append(std::string(Tok.getRawIdentifier()));
-State = NamespaceName;
-break;
-  case Using:
-State =
-(Tok.getRawIdentifier() == "namespace") ? UsingNamespace : Default;
-break;
-  case Default:
-NSName.clear();
-if (Tok.getRawIdentifier() == "namespace")
-  State = Namespace;
-else if (Tok.getRawIdentifier() == "using")
-  State = Using;
-break;
-  }
-  break;
-case tok::coloncolon:
-  // This can come at the beginning or in the middle of a namespace name.
-  switch (State) {
-  case UsingNamespace:
-  case UsingNamespaceName:
-NSName.append("::");
-State = UsingNamespaceName;
-break;
-  case NamespaceName:
-NSName.append("::");
-State = NamespaceName;
-break;
-  case Namespace: // Not legal here.
-  case Using:
-  case Default:
-State = Default;
-break;
-  }
-  break;
-case tok::l_brace:
-  // Record which { started a namespace, so we know when } ends one.
-  if (State == NamespaceName) {
-// Parsed: namespace  {

[PATCH] D74846: fix -fcodegen-modules code when used with PCH (PR44953)

2020-02-27 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Thanks @hans! Nevertheless I think this is a good change and we should push it 
for 11.0. I was indeed seeing better timings on our end with what @llunak was 
proposing, we are heavy users of PCH headers (and migrating to modules is not 
trivial in our case, lots of code branching & integrations)


Repository:
  rC Clang

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

https://reviews.llvm.org/D74846



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


[PATCH] D75229: [clang-tidy] Add signal-in-multithreaded-program check

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

Will be good idea to make callers function list configurable through option. 
See other checks as example.




Comment at: 
clang-tools-extra/clang-tidy/bugprone/SignalInMultithreadedProgramCheck.cpp:20
+void SignalInMultithreadedProgramCheck::registerMatchers(MatchFinder *Finder) {
+
+  auto signalCall =

Unnecessary empty line.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:112
 ^
+- New alias :doc:`cert-con37-c
+  ` to

Please add empty line above.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-signal-in-multithreaded-program.rst:12
+
+.. code-block: c
+

Should be double colon.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-signal-in-multithreaded-program.rst:18
+This check corresponds to the CERT C++ Coding Standard rule
+`CON37-C. Do not call signal() in a multithreaded program
+`_.

Please enclose signal() in double back-ticks.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D75229



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


RE: r355698 - Re-fix _lrotl/_lrotr to always take Long, no matter the platform.

2020-02-27 Thread Keane, Erich via cfe-commits
Right, the intent was to get this to match Microsoft’s behavior better while 
still making sense on other platforms.  IIRC this was in order to fix a codegen 
bug due to type mismatches, though I don’t completely remember (as it was 
nearly a year ago).

From: James Y Knight 
Sent: Wednesday, February 26, 2020 8:39 PM
To: Michael Spencer 
Cc: Keane, Erich ; cfe-commits 

Subject: Re: r355698 - Re-fix _lrotl/_lrotr to always take Long, no matter the 
platform.

I'm not clear as to what you're saying is broken.

On MS platforms, long is 32-bit, so either way this function takes a 32bit 
value, right? And, Microsoft's docs say this function takes a long.


On Wed, Feb 26, 2020, 5:09 PM Michael Spencer via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
I believe this commit is wrong. These intrinsics were originally implemented to 
support Windows code which expects _lrot{l,r}'s first argument to be 32 bits, 
it's a breaking change to change these definitions. I'm fine with adding the 
Intel version of these intrinsics, but you can't just break the Microsoft 
version of them.

- Michael Spencer

On Fri, Mar 8, 2019 at 7:09 AM Erich Keane via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: erichkeane
Date: Fri Mar  8 07:10:07 2019
New Revision: 355698

URL: http://llvm.org/viewvc/llvm-project?rev=355698&view=rev
Log:
Re-fix _lrotl/_lrotr to always take Long, no matter the platform.

r355322 fixed this, however is being reverted due to concerns with
enabling it in other modes.

Change-Id: I6a939b7469b8fa196d5871a627eb2330dbd30f29

Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=355698&r1=355697&r2=355698&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Fri Mar  8 07:10:07 2019
@@ -831,12 +831,12 @@ LANGBUILTIN(_ReturnAddress, "v*", "n", A
 LANGBUILTIN(_rotl8,  "UcUcUc","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_rotl16, "UsUsUc","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_rotl,   "UiUii", "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_lrotl,  "UNiUNii",   "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_lrotl,  "ULiULii",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_rotl64, "UWiUWii",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_rotr8,  "UcUcUc","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_rotr16, "UsUsUc","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_rotr,   "UiUii", "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_lrotr,  "UNiUNii",   "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_lrotr,  "ULiULii",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_rotr64, "UWiUWii",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__va_start,   "vc**.", "nt", ALL_MS_LANGUAGES)
 LANGBUILTIN(__fastfail, "vUi","nr", ALL_MS_LANGUAGES)

Modified: cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c?rev=355698&r1=355697&r2=355698&view=diff
==
--- cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c (original)
+++ cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c Fri Mar  8 07:10:07 2019
@@ -12,17 +12,10 @@
 // RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple x86_64--linux -emit-llvm %s -o - \
-// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
+// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
 // RUN: %clang_cc1 -ffreestanding -fms-extensions \
 // RUN: -triple x86_64--darwin -emit-llvm %s -o - \
-// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
-
-// LP64 targets use 'long' as 'int' for MS intrinsics (-fms-extensions)
-#ifdef __LP64__
-#define LONG int
-#else
-#define LONG long
-#endif
+// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG

 // rotate left

@@ -47,12 +40,15 @@ unsigned int test_rotl(unsigned int valu
 // CHECK:   [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 
[[Y:%.*]])
 // CHECK:   ret i32 [[R]]

-unsigned LONG test_lrotl(unsigned LONG value, int shift) {
+unsigned long test_lrotl(unsigned long value, int shift) {
   return _lrotl(value, shift);
 }
 // CHECK-32BIT-LONG: i32 @test_lrotl
 // CHECK-32BIT-LONG:   [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 
[[X]], i32 [[Y:%.*]])
 // CHECK-32BIT-LONG:   ret i32 [[R]]
+// CHECK-64BIT-LONG: i64 @test_lrotl
+// CHECK-64BIT-LONG:   [[R:%.*]] = call i64 @llvm.fshl.i64(i64 [[X:%.*]], i64 
[[X]], i64 [[Y:%.*]])
+// CHECK-64BIT-LONG:   ret i64 [[R]]

 unsigned __int64 test_rotl64(unsigned __int64 value, int shift) {
   return _rotl64(value, shift);
@@ -84,12 +80,1

[PATCH] D75153: [ThinLTO] Allow usage of all SMT threads in the system

2020-02-27 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

If a simpler (more yucky?) patch is needed to fix what @thakis was suggesting 
in https://reviews.llvm.org/D71775#1891709, and if we don't want this extra new 
flag, we can also check the CPU brand for "AMD Opteron", and keep the old 
behavior in that case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75153



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


Re: r329762 - Introduce a new builtin, __builtin_dump_struct, that is useful for dumping structure contents at runtime in circumstances where debuggers may not be easily available (such as in kernel w

2020-02-27 Thread Aaron Ballman via cfe-commits
On Wed, Feb 26, 2020 at 1:48 PM Aaron Ballman  wrote:
>
> On Tue, Feb 25, 2020 at 4:36 PM Richard Smith  wrote:
> >
> > It looks like we forgot to document this builtin. Can some documentation be 
> > added?
>
> If Paul doesn't get to it first, I can try to stub some out.

I added some basic documentation in f35f59ac36db3c5fe636f6899d98ac690126a4f7

~Aaron

>
> ~Aaron
>
> >
> > On Tue, 10 Apr 2018 at 15:01, Aaron Ballman via cfe-commits 
> >  wrote:
> >>
> >> Author: aaronballman
> >> Date: Tue Apr 10 14:58:13 2018
> >> New Revision: 329762
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=329762&view=rev
> >> Log:
> >> Introduce a new builtin, __builtin_dump_struct, that is useful for dumping 
> >> structure contents at runtime in circumstances where debuggers may not be 
> >> easily available (such as in kernel work).
> >>
> >> Patch by Paul Semel.
> >>
> >> Added:
> >> cfe/trunk/test/CodeGen/dump-struct-builtin.c
> >> cfe/trunk/test/Sema/builtin-dump-struct.c
> >> Modified:
> >> cfe/trunk/include/clang/Basic/Builtins.def
> >> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> >> cfe/trunk/lib/Sema/SemaChecking.cpp
> >>
> >> Modified: cfe/trunk/include/clang/Basic/Builtins.def
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=329762&r1=329761&r2=329762&view=diff
> >> ==
> >> --- cfe/trunk/include/clang/Basic/Builtins.def (original)
> >> +++ cfe/trunk/include/clang/Basic/Builtins.def Tue Apr 10 14:58:13 2018
> >> @@ -1374,6 +1374,7 @@ BUILTIN(__builtin_addressof, "v*v&", "nc
> >>  BUILTIN(__builtin_operator_new, "v*z", "tc")
> >>  BUILTIN(__builtin_operator_delete, "vv*", "tn")
> >>  BUILTIN(__builtin_char_memchr, "c*cC*iz", "n")
> >> +BUILTIN(__builtin_dump_struct, "ivC*v*", "tn")
> >>
> >>  // Safestack builtins
> >>  BUILTIN(__builtin___get_unsafe_stack_start, "v*", "Fn")
> >>
> >> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=329762&r1=329761&r2=329762&view=diff
> >> ==
> >> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> >> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Apr 10 14:58:13 2018
> >> @@ -14,6 +14,7 @@
> >>  #include "CGCXXABI.h"
> >>  #include "CGObjCRuntime.h"
> >>  #include "CGOpenCLRuntime.h"
> >> +#include "CGRecordLayout.h"
> >>  #include "CodeGenFunction.h"
> >>  #include "CodeGenModule.h"
> >>  #include "ConstantEmitter.h"
> >> @@ -930,6 +931,93 @@ EmitCheckedMixedSignMultiply(CodeGenFunc
> >>return RValue::get(Overflow);
> >>  }
> >>
> >> +static llvm::Value *dumpRecord(CodeGenFunction &CGF, QualType RType,
> >> +   Value *&RecordPtr, CharUnits Align, Value 
> >> *Func,
> >> +   int Lvl) {
> >> +  const auto *RT = RType->getAs();
> >> +  ASTContext &Context = CGF.getContext();
> >> +  RecordDecl *RD = RT->getDecl()->getDefinition();
> >> +  ASTContext &Ctx = RD->getASTContext();
> >> +  const ASTRecordLayout &RL = Ctx.getASTRecordLayout(RD);
> >> +  std::string Pad = std::string(Lvl * 4, ' ');
> >> +
> >> +  Value *GString =
> >> +  CGF.Builder.CreateGlobalStringPtr(RType.getAsString() + " {\n");
> >> +  Value *Res = CGF.Builder.CreateCall(Func, {GString});
> >> +
> >> +  static llvm::DenseMap Types;
> >> +  if (Types.empty()) {
> >> +Types[Context.CharTy] = "%c";
> >> +Types[Context.BoolTy] = "%d";
> >> +Types[Context.IntTy] = "%d";
> >> +Types[Context.UnsignedIntTy] = "%u";
> >> +Types[Context.LongTy] = "%ld";
> >> +Types[Context.UnsignedLongTy] = "%lu";
> >> +Types[Context.LongLongTy] = "%lld";
> >> +Types[Context.UnsignedLongLongTy] = "%llu";
> >> +Types[Context.ShortTy] = "%hd";
> >> +Types[Context.UnsignedShortTy] = "%hu";
> >> +Types[Context.VoidPtrTy] = "%p";
> >> +Types[Context.FloatTy] = "%f";
> >> +Types[Context.DoubleTy] = "%f";
> >> +Types[Context.LongDoubleTy] = "%Lf";
> >> +Types[Context.getPointerType(Context.CharTy)] = "%s";
> >> +  }
> >> +
> >> +  for (const auto *FD : RD->fields()) {
> >> +uint64_t Off = RL.getFieldOffset(FD->getFieldIndex());
> >> +Off = Ctx.toCharUnitsFromBits(Off).getQuantity();
> >> +
> >> +Value *FieldPtr = RecordPtr;
> >> +if (RD->isUnion())
> >> +  FieldPtr = CGF.Builder.CreatePointerCast(
> >> +  FieldPtr, 
> >> CGF.ConvertType(Context.getPointerType(FD->getType(;
> >> +else
> >> +  FieldPtr = CGF.Builder.CreateStructGEP(CGF.ConvertType(RType), 
> >> FieldPtr,
> >> + FD->getFieldIndex());
> >> +
> >> +GString = CGF.Builder.CreateGlobalStringPtr(
> >> +llvm::Twine(Pad)
> >> +.concat(FD->getType().getAsString())
> >> +.concat(llvm::Twine(' '))
> >> +.concat(FD->getNameAsString())
> >> +

[PATCH] D73967: Implement _ExtInt as an extended int type specifier.

2020-02-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Ping!  I believe this should be ready for review and does everything requested 
in the CFEDev conversation.


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

https://reviews.llvm.org/D73967



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


[clang] f35f59a - Adding some documentation for __builtin_dump_struct.

2020-02-27 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-02-27T09:30:17-05:00
New Revision: f35f59ac36db3c5fe636f6899d98ac690126a4f7

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

LOG: Adding some documentation for __builtin_dump_struct.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index a15bf50f7c08..4c7af39e93e2 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1783,6 +1783,52 @@ controlled state.
 
 .. _langext-__builtin_shufflevector:
 
+``__builtin_dump_struct``
+-
+
+**Syntax**:
+
+.. code-block:: c++
+
+ __builtin_dump_struct(&some_struct, &some_printf_func);
+
+**Examples**:
+
+.. code-block:: c++
+
+ struct S {
+   int x, y;
+   float f;
+   struct T {
+ int i;
+   } t;
+ };
+
+ void func(struct S *s) {
+   __builtin_dump_struct(s, &printf);
+ }
+
+Example output:
+
+.. code-block:: none
+
+ struct S {
+ int i : 100
+ int j : 42
+ float f : 3.14159
+ struct T t : struct T {
+ int i : 1997
+ }
+ }
+
+**Description**:
+
+The '``__builtin_dump_struct``' function is used to print the fields of a 
simple
+structure and their values for debugging purposes. The builtin accepts a 
pointer
+to a structure to dump the fields of, and a pointer to a formatted output
+function whose signature must be: ``int (*)(const char *, ...)`` and must
+support the format specifiers used by ``printf()``.
+
 ``__builtin_shufflevector``
 ---
 



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


[PATCH] D75251: [clangd] Move the format rename edits from clangdserver to rename API, NFC.

2020-02-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kbobyrev.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

would make the rename API more nature, respecting the parameter 
Options.WantFormat.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75251

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -712,7 +712,7 @@
   clangd::RenameOptions RenameOpts;
   // Shall we allow to custimize the file limit?
   RenameOpts.AllowCrossFile = CrossFileRename;
-
+  RenameOpts.WantFormat = true;
   ClangdLSPServer LSPServer(
   *TransportLayer, FSProvider, CCOpts, RenameOpts, CompileCommandsDirPath,
   /*UseDirBasedCDB=*/CompileArgsFrom == FilesystemCompileArgs,
Index: clang-tools-extra/clangd/refactor/Rename.h
===
--- clang-tools-extra/clangd/refactor/Rename.h
+++ clang-tools-extra/clangd/refactor/Rename.h
@@ -34,7 +34,7 @@
   /// when AllowCrossFile = true.
   /// If the actual number exceeds the limit, rename is forbidden.
   size_t LimitFiles = 50;
-  /// If true, format the rename edits, only meaningful in ClangdServer layer.
+  /// If true, format the rename edits.
   bool WantFormat = false;
 };
 
@@ -55,7 +55,7 @@
   DirtyBufferGetter GetDirtyBuffer = nullptr;
 };
 
-/// Renames all occurrences of the symbol. The result edits are unformatted.
+/// Renames all occurrences of the symbol.
 /// If AllowCrossFile is false, returns an error if rename a symbol that's used
 /// in another file (per the index).
 llvm::Expected rename(const RenameInputs &RInputs);
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -18,6 +18,7 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Format/Format.h"
 #include "clang/Tooling/Refactoring/Rename/USRFindingAction.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
@@ -462,6 +463,16 @@
LexedIndex + 1, Fuel, MatchedCB);
 }
 
+llvm::Expected formatEdits(FileEdits FE,
+  const format::FormatStyle Style) {
+  llvm::Error Err = llvm::Error::success();
+  for (auto &E : FE)
+Err = llvm::joinErrors(reformatEdit(E.getValue(), Style), std::move(Err));
+  if (Err)
+return std::move(Err);
+  return FE;
+}
+
 } // namespace
 
 llvm::Expected rename(const RenameInputs &RInputs) {
@@ -470,6 +481,9 @@
   ParsedAST &AST = RInputs.AST;
   const SourceManager &SM = AST.getSourceManager();
   llvm::StringRef MainFileCode = SM.getBufferData(SM.getMainFileID());
+  const auto FormatStyle =
+  getFormatStyleForFile(RInputs.MainFilePath, MainFileCode,
+&SM.getFileManager().getVirtualFileSystem());
   auto GetFileContent = [&RInputs,
  &SM](PathRef AbsPath) -> llvm::Expected {
 llvm::Optional DirtyBuffer;
@@ -534,9 +548,11 @@
   // return the main file edit if this is a within-file rename or the symbol
   // being renamed is function local.
   if (!Opts.AllowCrossFile || RenameDecl.getParentFunctionOrMethod()) {
-return FileEdits(
+auto MainFileEdit = FileEdits(
 {std::make_pair(RInputs.MainFilePath,
 Edit{MainFileCode, std::move(*MainFileRenameEdit)})});
+return RInputs.Opts.WantFormat ? formatEdits(MainFileEdit, FormatStyle)
+   : MainFileEdit;
   }
 
   FileEdits Results;
@@ -555,7 +571,7 @@
   // Attach the rename edits for the main file.
   Results.try_emplace(RInputs.MainFilePath, MainFileCode,
   std::move(*MainFileRenameEdit));
-  return Results;
+  return RInputs.Opts.WantFormat ? formatEdits(Results, FormatStyle) : Results;
 }
 
 llvm::Expected buildRenameEdit(llvm::StringRef AbsFilePath,
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -259,7 +259,7 @@
 
   /// Rename all occurrences of the symbol at the \p Pos in \p File to
   /// \p NewName.
-  /// If WantFormat is false, the final TextEdit will be not formatted,
+  /// If Opts.WantFormat is false, the final TextEdit will be not formatted,
   /// embedders could use this method to get all occurrences of the symbol (e.g.
   /// highlighting them in prep

[PATCH] D75057: Syndicate, test and fix base64 implementation

2020-02-27 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

Up?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75057



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


[PATCH] D75107: [clang-tidy] hicpp-signed-bitwise IgnorePositiveIntegerLiterals now partially recursive

2020-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

What about bit shifting operations? e.g., `~(1 << 2)` or `8 >> (1 << 2)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75107



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


[PATCH] D74692: [clang-tidy][bugprone-use-after-move] Warn on std::move for consts

2020-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp:399-400
+Check->diag(MoveArgLoc,
+"std::move of the const expression has no effect; "
+"remove std::move() or make the variable non-const",
+DiagnosticIDs::Note);

I don't think this diagnostic makes sense on the location of the declaration -- 
the diagnostic is talking about expressions but the code the user is looking at 
is a declaration. I think it may make more sense to change the diagnostic at 
the use location to read `'%0' used after it was moved; move of a 'const' 
argument has no effect` and then this note can read `variable '%0' declared 
const here` (so long as you get the correct declaration location -- the lambda 
example in the test below would be incorrect, for instance).



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp:329
   // CHECK-NOTES: [[@LINE-3]]:7: note: move occurred here
+  // CHECK-NOTES: [[@LINE-6]]:7: note: std::move of the const expression 
{{.*}}
 };

zinovy.nis wrote:
> Quuxplusone wrote:
> > It continues to seem silly to me that you give an extra note here saying 
> > that line 325 doesn't do anything, when of course line 336 doesn't do 
> > anything either (and you don't give any extra note there).
> > 
> > This clang-tidy warning isn't supposed to be about what //physically 
> > happens// in the machine code during any particular compilation run; it's 
> > supposed to be about helping the user avoid //semantic// bugs by cleaning 
> > up their codebase's //logical// behavior. The rule is "don't use things 
> > after moving from them," period.
> > 
> > Analogously, if there were a clang-tidy warning to say "always indent four 
> > spaces after an `if`," and you proposed to add a note to some cases that 
> > said "...but here a three-space indent is OK, because C++ is 
> > whitespace-insensitive" — I'd also find //that// note to be mildly 
> > objectionable. We want to train people to do the right thing, not to do the 
> > right thing "except in this case because hey, it doesn't matter to the 
> > machine."
> Thanks for the feedback. I got your point. But my note (may be expressed with 
> wrong words) is about that there're 2 ways to fix the issue: either get rid 
> of 'std::move' or somehow remove 'const'. That was the main purpose of my 
> commit.
In this particular instance, I find the new note to be perplexing -- the 
constant expression being referenced is the original declaration of `a` which 
is not `const` (the captured `a` within the lambda is what's `const`).


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

https://reviews.llvm.org/D74692



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


[PATCH] D75252: [ARM,MVE] Add ACLE intrinsics for VQMOV[U]N family.

2020-02-27 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: MarkMurrayARM, dmgreen, miyuki, ostannard.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

These instructions work like VMOVN (narrowing a vector of wide values
to half size, and overwriting every other lane of an output register
with the result), except that the narrowing conversion is saturating.
They come in three signedness flavours: signed to signed, unsigned to
unsigned, and signed to unsigned. All are represented in IR by a
target-specific intrinsic that takes two separate 'unsigned' flags.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75252

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vqmovn.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vqmovn.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vqmovn.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vqmovn.ll
@@ -0,0 +1,299 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vqmovnbq_s16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vqmovnbq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqmovnb.s16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <16 x i8> @llvm.arm.mve.vqmovn.v16i8.v8i16(<16 x i8> %a, <8 x i16> %b, i32 0, i32 0, i32 0)
+  ret <16 x i8> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vqmovnbq_s32(<8 x i16> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vqmovnbq_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqmovnb.s32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vqmovn.v8i16.v4i32(<8 x i16> %a, <4 x i32> %b, i32 0, i32 0, i32 0)
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vqmovnbq_u16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vqmovnbq_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqmovnb.u16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <16 x i8> @llvm.arm.mve.vqmovn.v16i8.v8i16(<16 x i8> %a, <8 x i16> %b, i32 1, i32 1, i32 0)
+  ret <16 x i8> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vqmovnbq_u32(<8 x i16> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vqmovnbq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqmovnb.u32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vqmovn.v8i16.v4i32(<8 x i16> %a, <4 x i32> %b, i32 1, i32 1, i32 0)
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vqmovntq_s16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vqmovntq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqmovnt.s16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <16 x i8> @llvm.arm.mve.vqmovn.v16i8.v8i16(<16 x i8> %a, <8 x i16> %b, i32 0, i32 0, i32 1)
+  ret <16 x i8> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vqmovntq_s32(<8 x i16> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vqmovntq_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqmovnt.s32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vqmovn.v8i16.v4i32(<8 x i16> %a, <4 x i32> %b, i32 0, i32 0, i32 1)
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vqmovntq_u16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vqmovntq_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqmovnt.u16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <16 x i8> @llvm.arm.mve.vqmovn.v16i8.v8i16(<16 x i8> %a, <8 x i16> %b, i32 1, i32 1, i32 1)
+  ret <16 x i8> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vqmovntq_u32(<8 x i16> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vqmovntq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqmovnt.u32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vqmovn.v8i16.v4i32(<8 x i16> %a, <4 x i32> %b, i32 1, i32 1, i32 1)
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vqmovunbq_s16(<16 x i8> %a, <8 x i16> %b) {
+; CHECK-LABEL: test_vqmovunbq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqmovunb.s16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <16 x i8> @llvm.arm.mve.vqmovn.v16i8.v8i16(<16 x i8> %a, <8 x i16> %b, i32 1, i32 0, i32 0)
+  ret <16 x i8> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vqmovunbq_s32(<8 x i16> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vqmovunbq_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqmovunb.s32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vqmovn.v8i16.v4i32(<8 x i16> %a, <4 x i32> %b, i32 1, i32 0, i32 0)
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vqmovuntq_s16(<16 x i8> 

[PATCH] D75254: [ARM,MVE] Add ACLE intrinsics for VCVT.F32.F16 family.

2020-02-27 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: MarkMurrayARM, dmgreen, miyuki, ostannard.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

These instructions make a vector of `<4 x float>` by widening every
other lane of a vector of `<8 x half>`.

I wondered about representing these using standard IR, along the lines
of a shufflevector to extract elements of the input into a `<4 x half>`
followed by an `fpext` to turn that into `<4 x float>`. But it looks as
if that would take a lot of work in isel lowering to make it match any
pattern I could sensibly write in Tablegen, and also I haven't been
able to think of any other case where that pattern might be generated
in IR, so there wouldn't be any extra code generation win from doing
it that way.

Therefore, I've just used another target-specific intrinsic. We can
always change it to the other way later if anyone thinks of a good
reason.

(In order to put the intrinsic definition near similar things in
`IntrinsicsARM.td`, I've also lifted the definition of the
`MVEMXPredicated` multiclass higher up the file, without changing it.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75254

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vcvt.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vcvt.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vcvt.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/vcvt.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vcvt.ll
@@ -6,6 +6,8 @@
 
 declare <8 x half> @llvm.arm.mve.vcvt.narrow(<8 x half>, <4 x float>, i32)
 declare <8 x half> @llvm.arm.mve.vcvt.narrow.predicated(<8 x half>, <4 x float>, i32, <4 x i1>)
+declare <4 x float> @llvm.arm.mve.vcvt.widen(<8 x half>, i32)
+declare <4 x float> @llvm.arm.mve.vcvt.widen.predicated(<4 x float>, <8 x half>, i32, <4 x i1>)
 
 declare <8 x half> @llvm.arm.mve.vcvt.fix.v8f16.v8i16(i32, <8 x i16>, i32)
 declare <4 x float> @llvm.arm.mve.vcvt.fix.v4f32.v4i32(i32, <4 x i32>, i32)
@@ -367,3 +369,51 @@
   %2 = call <4 x i32> @llvm.arm.mve.vcvt.fix.predicated.v4i32.v4f32.v4i1(i32 1, <4 x i32> undef, <4 x float> %a, i32 32, <4 x i1> %1)
   ret <4 x i32> %2
 }
+
+define arm_aapcs_vfpcc <4 x float> @test_vcvtbq_f32_f16(<8 x half> %a) {
+; CHECK-LABEL: test_vcvtbq_f32_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcvtb.f32.f16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x float> @llvm.arm.mve.vcvt.widen(<8 x half> %a, i32 0)
+  ret <4 x float> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vcvttq_f32_f16(<8 x half> %a) {
+; CHECK-LABEL: test_vcvttq_f32_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcvtt.f32.f16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x float> @llvm.arm.mve.vcvt.widen(<8 x half> %a, i32 1)
+  ret <4 x float> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vcvtbq_m_f32_f16(<4 x float> %inactive, <8 x half> %a, i16 zeroext %p) {
+; CHECK-LABEL: test_vcvtbq_m_f32_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vcvtbt.f32.f16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = tail call <4 x float> @llvm.arm.mve.vcvt.widen.predicated(<4 x float> %inactive, <8 x half> %a, i32 0, <4 x i1> %1)
+  ret <4 x float> %2
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vcvttq_m_f32_f16(<4 x float> %inactive, <8 x half> %a, i16 zeroext %p) {
+; CHECK-LABEL: test_vcvttq_m_f32_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vcvttt.f32.f16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = tail call <4 x float> @llvm.arm.mve.vcvt.widen.predicated(<4 x float> %inactive, <8 x half> %a, i32 1, <4 x i1> %1)
+  ret <4 x float> %2
+}
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -4486,6 +4486,17 @@
 
 multiclass MVE_VCVT_h2f_m {
   def "": MVE_VCVT_ff;
+  defvar Inst = !cast(NAME);
+
+  let Predicates = [HasMVEFloat] in {
+def : Pat<(v4f32 (int_arm_mve_vcvt_widen (v8f16 MQPR:$Qm), (i32 half))),
+  (v4f32 (Inst (v8f16 MQPR:$Qm)))>;
+def : Pat<(v4f32 (int_arm_mve_vcvt_widen_predicated
+ (v4f32 MQPR:$inactive), (v8f16 MQPR:$Qm), (i32 half),
+ (v4i1 VCCR:$mask))),
+  (v4f32 (Inst (v8f16 MQPR:$Qm), ARMVCCThen,
+   (v4i1 VCCR:$mask), (v4f32 MQPR:$inactive)))>;
+  }
 }
 
 defm MVE_VCVTf16f32bh : MVE_VCVT_f2h_m<"vcvtb", 0b0>;
Index: llvm/include

[PATCH] D75255: [ARM,MVE] Add ACLE intrinsics for VCVT[ANPM] family.

2020-02-27 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: MarkMurrayARM, dmgreen, miyuki, ostannard.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

These instructions convert a vector of floats to a vector of integers
of the same size, with assorted non-default rounding modes.
Implemented in IR as target-specific intrinsics, because as far as I
can see there are no matches for that functionality in the standard IR
intrinsics list.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75255

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vcvt_anpm.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vcvt_anpm.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vcvt_anpm.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vcvt_anpm.ll
@@ -0,0 +1,631 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <8 x i16> @test_vcvtaq_s16_f16(<8 x half> %a) {
+; CHECK-LABEL: test_vcvtaq_s16_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcvta.s16.f16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vcvta.v8i16.v8f16(i32 0, <8 x half> %a)
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vcvtaq_s32_f32(<4 x float> %a) {
+; CHECK-LABEL: test_vcvtaq_s32_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcvta.s32.f32 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vcvta.v4i32.v4f32(i32 0, <4 x float> %a)
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vcvtaq_u16_f16(<8 x half> %a) {
+; CHECK-LABEL: test_vcvtaq_u16_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcvta.u16.f16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vcvta.v8i16.v8f16(i32 1, <8 x half> %a)
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vcvtaq_u32_f32(<4 x float> %a) {
+; CHECK-LABEL: test_vcvtaq_u32_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcvta.u32.f32 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vcvta.v4i32.v4f32(i32 1, <4 x float> %a)
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vcvtmq_s16_f16(<8 x half> %a) {
+; CHECK-LABEL: test_vcvtmq_s16_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcvtm.s16.f16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vcvtm.v8i16.v8f16(i32 0, <8 x half> %a)
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vcvtmq_s32_f32(<4 x float> %a) {
+; CHECK-LABEL: test_vcvtmq_s32_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcvtm.s32.f32 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vcvtm.v4i32.v4f32(i32 0, <4 x float> %a)
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vcvtmq_u16_f16(<8 x half> %a) {
+; CHECK-LABEL: test_vcvtmq_u16_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcvtm.u16.f16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vcvtm.v8i16.v8f16(i32 1, <8 x half> %a)
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vcvtmq_u32_f32(<4 x float> %a) {
+; CHECK-LABEL: test_vcvtmq_u32_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcvtm.u32.f32 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vcvtm.v4i32.v4f32(i32 1, <4 x float> %a)
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vcvtnq_s16_f16(<8 x half> %a) {
+; CHECK-LABEL: test_vcvtnq_s16_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcvtn.s16.f16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vcvtn.v8i16.v8f16(i32 0, <8 x half> %a)
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vcvtnq_s32_f32(<4 x float> %a) {
+; CHECK-LABEL: test_vcvtnq_s32_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcvtn.s32.f32 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vcvtn.v4i32.v4f32(i32 0, <4 x float> %a)
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vcvtnq_u16_f16(<8 x half> %a) {
+; CHECK-LABEL: test_vcvtnq_u16_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcvtn.u16.f16 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vcvtn.v8i16.v8f16(i32 1, <8 x half> %a)
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vcvtnq_u32_f32(<4 x float> %a) {
+; CHECK-LABEL: test_vcvtnq_u32_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vcvtn.u32.f32 q0, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @ll

[clang] 4569b3a - Revert "Devirtualize a call on alloca without waiting for post inline cleanup and next"

2020-02-27 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-02-27T15:58:39+01:00
New Revision: 4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43

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

LOG: Revert "Devirtualize a call on alloca without waiting for post inline 
cleanup and next"

This reverts commit 59fb9cde7a4a96fe8485a80d9010e4420ffdca82.

The patch caused internal miscompilations.

Added: 


Modified: 
clang/test/CodeGenCXX/member-function-pointer-calls.cpp
llvm/lib/Transforms/IPO/Inliner.cpp

Removed: 
llvm/test/Transforms/Inline/devirtualize-4.ll



diff  --git a/clang/test/CodeGenCXX/member-function-pointer-calls.cpp 
b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
index 232b1f06df89..0e98b12e6e9d 100644
--- a/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
+++ b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
@@ -11,8 +11,12 @@ int f(A* a, int (A::*fp)()) {
 }
 
 // CHECK-LABEL: define i32 @_Z2g1v()
-// CHECK-NOT: }
-// CHECK: ret i32 1
+// CHECK-LEGACY: ret i32 1
+// CHECK-NEWPM: [[A:%.*]] = alloca %struct.A, align 8
+// CHECK-NEWPM: [[TMP:%.*]] = getelementptr inbounds %struct.A, %struct.A* %a, 
i64 0, i32 0
+// CHECK-NEWPM: store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 x 
i8*] }, { [4 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), 
i32 (...)*** [[TMP]], align 8
+// CHECK-NEWPM: [[RET:%.*]] = call i32 @_ZN1A3vf1Ev(%struct.A* nonnull %a) #2
+// CHECK-NEWPM: ret i32 [[RET]]
 // MINGW64-LABEL: define dso_local i32 @_Z2g1v()
 // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})
 int g1() {
@@ -21,7 +25,6 @@ int g1() {
 }
 
 // CHECK-LABEL: define i32 @_Z2g2v()
-// CHECK-NOT: }
 // CHECK: ret i32 2
 // MINGW64-LABEL: define dso_local i32 @_Z2g2v()
 // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})

diff  --git a/llvm/lib/Transforms/IPO/Inliner.cpp 
b/llvm/lib/Transforms/IPO/Inliner.cpp
index 55753d979b2c..4f9f4bd1cd04 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -35,7 +35,6 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Transforms/Utils/Local.h"
-#include "llvm/Transforms/Utils/CallPromotionUtils.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CallSite.h"
@@ -1101,20 +1100,10 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC 
&InitialC,
   if (!IFI.InlinedCallSites.empty()) {
 int NewHistoryID = InlineHistory.size();
 InlineHistory.push_back({&Callee, InlineHistoryID});
-for (CallSite &CS : reverse(IFI.InlinedCallSites)) {
-  Function *NewCallee = CS.getCalledFunction();
-  if (!NewCallee) {
-// Try to promote an indirect (virtual) call without waiting for 
the
-// post-inline cleanup and the next DevirtSCCRepeatedPass iteration
-// because the next iteration may not happen and we may miss
-// inlining it.
-if (tryPromoteCall(CS))
-  NewCallee = CS.getCalledFunction();
-  }
-  if (NewCallee)
+for (CallSite &CS : reverse(IFI.InlinedCallSites))
+  if (Function *NewCallee = CS.getCalledFunction())
 if (!NewCallee->isDeclaration())
   Calls.push_back({CS, NewHistoryID});
-}
   }
 
   if (InlinerFunctionImportStats != InlinerFunctionImportStatsOpts::No)

diff  --git a/llvm/test/Transforms/Inline/devirtualize-4.ll 
b/llvm/test/Transforms/Inline/devirtualize-4.ll
deleted file mode 100644
index 2205dae7aa23..
--- a/llvm/test/Transforms/Inline/devirtualize-4.ll
+++ /dev/null
@@ -1,214 +0,0 @@
-; RUN: opt < %s -passes='cgscc(devirt<4>(inline)),function(sroa,early-cse)' -S 
| FileCheck %s
-; RUN: opt < %s -passes='default' -S | FileCheck %s
-
-; Check that DoNotOptimize is inlined into Test.
-; CHECK: @_Z4Testv()
-; CHECK-NOT: ret void
-; CHECK: call void asm
-; CHECK: ret void
-
-;template 
-;void DoNotOptimize(const T& var) {
-;  asm volatile("" : "+m"(const_cast(var)));
-;}
-;
-;class Interface {
-; public:
-;  virtual void Run() = 0;
-;};
-;
-;class Impl : public Interface {
-; public:
-;  Impl() : f(3) {}
-;  void Run() { DoNotOptimize(this); }
-;
-; private:
-;  int f;
-;};
-;
-;static void IndirectRun(Interface& o) { o.Run(); }
-;
-;void Test() {
-;  Impl o;
-;  IndirectRun(o);
-;}
-
-%class.Impl = type <{ %class.Interface, i32, [4 x i8] }>
-%class.Interface = type { i32 (...)** }
-
-@_ZTV4Impl = linkonce_odr dso_local unnamed_addr constant { [3 x i8*] } { [3 x 
i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTI4Impl to i8*), i8* bitcast 
(void (%class.Impl*)* @_ZN4Impl3RunEv to i8*)] }, align 8
-@_ZTVN10__cxxabiv120__si_class_

[PATCH] D75159: [clang-tidy] Fix PR#37210 'Out-of-class template constructor only half-fixed with modernize-pass-by-value'

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75159



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


Re: [clang] 4569b3a - Revert "Devirtualize a call on alloca without waiting for post inline cleanup and next"

2020-02-27 Thread Roman Lebedev via cfe-commits
Is there a reproducer in progress?

On Thu, Feb 27, 2020 at 5:59 PM Kirill Bobyrev via cfe-commits
 wrote:
>
>
> Author: Kirill Bobyrev
> Date: 2020-02-27T15:58:39+01:00
> New Revision: 4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43
>
> URL: 
> https://github.com/llvm/llvm-project/commit/4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43
> DIFF: 
> https://github.com/llvm/llvm-project/commit/4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43.diff
>
> LOG: Revert "Devirtualize a call on alloca without waiting for post inline 
> cleanup and next"
>
> This reverts commit 59fb9cde7a4a96fe8485a80d9010e4420ffdca82.
>
> The patch caused internal miscompilations.
>
> Added:
>
>
> Modified:
> clang/test/CodeGenCXX/member-function-pointer-calls.cpp
> llvm/lib/Transforms/IPO/Inliner.cpp
>
> Removed:
> llvm/test/Transforms/Inline/devirtualize-4.ll
>
>
> 
> diff  --git a/clang/test/CodeGenCXX/member-function-pointer-calls.cpp 
> b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
> index 232b1f06df89..0e98b12e6e9d 100644
> --- a/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
> +++ b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
> @@ -11,8 +11,12 @@ int f(A* a, int (A::*fp)()) {
>  }
>
>  // CHECK-LABEL: define i32 @_Z2g1v()
> -// CHECK-NOT: }
> -// CHECK: ret i32 1
> +// CHECK-LEGACY: ret i32 1
> +// CHECK-NEWPM: [[A:%.*]] = alloca %struct.A, align 8
> +// CHECK-NEWPM: [[TMP:%.*]] = getelementptr inbounds %struct.A, %struct.A* 
> %a, i64 0, i32 0
> +// CHECK-NEWPM: store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 
> x i8*] }, { [4 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 
> (...)**), i32 (...)*** [[TMP]], align 8
> +// CHECK-NEWPM: [[RET:%.*]] = call i32 @_ZN1A3vf1Ev(%struct.A* nonnull %a) #2
> +// CHECK-NEWPM: ret i32 [[RET]]
>  // MINGW64-LABEL: define dso_local i32 @_Z2g1v()
>  // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* 
> %{{.*}})
>  int g1() {
> @@ -21,7 +25,6 @@ int g1() {
>  }
>
>  // CHECK-LABEL: define i32 @_Z2g2v()
> -// CHECK-NOT: }
>  // CHECK: ret i32 2
>  // MINGW64-LABEL: define dso_local i32 @_Z2g2v()
>  // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* 
> %{{.*}})
>
> diff  --git a/llvm/lib/Transforms/IPO/Inliner.cpp 
> b/llvm/lib/Transforms/IPO/Inliner.cpp
> index 55753d979b2c..4f9f4bd1cd04 100644
> --- a/llvm/lib/Transforms/IPO/Inliner.cpp
> +++ b/llvm/lib/Transforms/IPO/Inliner.cpp
> @@ -35,7 +35,6 @@
>  #include "llvm/Analysis/TargetLibraryInfo.h"
>  #include "llvm/Analysis/TargetTransformInfo.h"
>  #include "llvm/Transforms/Utils/Local.h"
> -#include "llvm/Transforms/Utils/CallPromotionUtils.h"
>  #include "llvm/IR/Attributes.h"
>  #include "llvm/IR/BasicBlock.h"
>  #include "llvm/IR/CallSite.h"
> @@ -1101,20 +1100,10 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC 
> &InitialC,
>if (!IFI.InlinedCallSites.empty()) {
>  int NewHistoryID = InlineHistory.size();
>  InlineHistory.push_back({&Callee, InlineHistoryID});
> -for (CallSite &CS : reverse(IFI.InlinedCallSites)) {
> -  Function *NewCallee = CS.getCalledFunction();
> -  if (!NewCallee) {
> -// Try to promote an indirect (virtual) call without waiting for 
> the
> -// post-inline cleanup and the next DevirtSCCRepeatedPass 
> iteration
> -// because the next iteration may not happen and we may miss
> -// inlining it.
> -if (tryPromoteCall(CS))
> -  NewCallee = CS.getCalledFunction();
> -  }
> -  if (NewCallee)
> +for (CallSite &CS : reverse(IFI.InlinedCallSites))
> +  if (Function *NewCallee = CS.getCalledFunction())
>  if (!NewCallee->isDeclaration())
>Calls.push_back({CS, NewHistoryID});
> -}
>}
>
>if (InlinerFunctionImportStats != InlinerFunctionImportStatsOpts::No)
>
> diff  --git a/llvm/test/Transforms/Inline/devirtualize-4.ll 
> b/llvm/test/Transforms/Inline/devirtualize-4.ll
> deleted file mode 100644
> index 2205dae7aa23..
> --- a/llvm/test/Transforms/Inline/devirtualize-4.ll
> +++ /dev/null
> @@ -1,214 +0,0 @@
> -; RUN: opt < %s -passes='cgscc(devirt<4>(inline)),function(sroa,early-cse)' 
> -S | FileCheck %s
> -; RUN: opt < %s -passes='default' -S | FileCheck %s
> -
> -; Check that DoNotOptimize is inlined into Test.
> -; CHECK: @_Z4Testv()
> -; CHECK-NOT: ret void
> -; CHECK: call void asm
> -; CHECK: ret void
> -
> -;template 
> -;void DoNotOptimize(const T& var) {
> -;  asm volatile("" : "+m"(const_cast(var)));
> -;}
> -;
> -;class Interface {
> -; public:
> -;  virtual void Run() = 0;
> -;};
> -;
> -;class Impl : public Interface {
> -; public:
> -;  Impl() : f(3) {}
> -;  void Run() { DoNotOptimize(this); }
> -;
> -; private:
> -;  int f;
> -;};
> -;
> -;static void IndirectRun(Interface& o) { o.Run(); }
> -;
> -;void Test() {
> -;  Impl o;
> -;  I

[PATCH] D73967: Implement _ExtInt as an extended int type specifier.

2020-02-27 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

Added a couple inline comments




Comment at: clang/docs/ReleaseNotes.rst:62
+  permit non-power of 2 integers, exposing the LLVM integer types. Since a 
major
+  motivating use case for these types is to limit 'bit' useage, these types 
don't
+  automatically promote to 'int' when operations are done between two 
``ExtInt(N)``

^useage^usage^ -- please also correct spelling in the code



Comment at: clang/include/clang/AST/ASTContext.h:1215
 
+  /// Return an extended integer type with the specified underlying type and 
bit
+  /// count.

Is this comment correct? "with the specified underlying type"


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

https://reviews.llvm.org/D73967



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


[PATCH] D31338: Move ParsedAttrInfos into a registry and point to one in ParsedAttr

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

I like this approach much better, thank you for working on it! LGTM




Comment at: clang/include/clang/Basic/AttributeCommonInfo.h:140
+  /// will be normalized to gnu::attr).
+  std::string getFullName() const;
+

This should probably be `getNormalizedFullName()` -- the full by itself implies 
we don't normalize, to me.



Comment at: clang/include/clang/Sema/ParsedAttr.h:66
+AttributeCommonInfo::Syntax Syntax;
+std::string FullName;
+  };

`NormalizedFullName`?


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

https://reviews.llvm.org/D31338



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


Re: [clang] 4569b3a - Revert "Devirtualize a call on alloca without waiting for post inline cleanup and next"

2020-02-27 Thread Kirill Bobyrev via cfe-commits
I've messaged the author internally and pointed to the failing targets.

On Thu, Feb 27, 2020 at 4:04 PM Roman Lebedev  wrote:

> Is there a reproducer in progress?
>
> On Thu, Feb 27, 2020 at 5:59 PM Kirill Bobyrev via cfe-commits
>  wrote:
> >
> >
> > Author: Kirill Bobyrev
> > Date: 2020-02-27T15:58:39+01:00
> > New Revision: 4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43
> >
> > URL:
> https://github.com/llvm/llvm-project/commit/4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43
> > DIFF:
> https://github.com/llvm/llvm-project/commit/4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43.diff
> >
> > LOG: Revert "Devirtualize a call on alloca without waiting for post
> inline cleanup and next"
> >
> > This reverts commit 59fb9cde7a4a96fe8485a80d9010e4420ffdca82.
> >
> > The patch caused internal miscompilations.
> >
> > Added:
> >
> >
> > Modified:
> > clang/test/CodeGenCXX/member-function-pointer-calls.cpp
> > llvm/lib/Transforms/IPO/Inliner.cpp
> >
> > Removed:
> > llvm/test/Transforms/Inline/devirtualize-4.ll
> >
> >
> >
> 
> > diff  --git a/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
> b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
> > index 232b1f06df89..0e98b12e6e9d 100644
> > --- a/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
> > +++ b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
> > @@ -11,8 +11,12 @@ int f(A* a, int (A::*fp)()) {
> >  }
> >
> >  // CHECK-LABEL: define i32 @_Z2g1v()
> > -// CHECK-NOT: }
> > -// CHECK: ret i32 1
> > +// CHECK-LEGACY: ret i32 1
> > +// CHECK-NEWPM: [[A:%.*]] = alloca %struct.A, align 8
> > +// CHECK-NEWPM: [[TMP:%.*]] = getelementptr inbounds %struct.A,
> %struct.A* %a, i64 0, i32 0
> > +// CHECK-NEWPM: store i32 (...)** bitcast (i8** getelementptr inbounds
> ({ [4 x i8*] }, { [4 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32
> (...)**), i32 (...)*** [[TMP]], align 8
> > +// CHECK-NEWPM: [[RET:%.*]] = call i32 @_ZN1A3vf1Ev(%struct.A* nonnull
> %a) #2
> > +// CHECK-NEWPM: ret i32 [[RET]]
> >  // MINGW64-LABEL: define dso_local i32 @_Z2g1v()
> >  // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }*
> %{{.*}})
> >  int g1() {
> > @@ -21,7 +25,6 @@ int g1() {
> >  }
> >
> >  // CHECK-LABEL: define i32 @_Z2g2v()
> > -// CHECK-NOT: }
> >  // CHECK: ret i32 2
> >  // MINGW64-LABEL: define dso_local i32 @_Z2g2v()
> >  // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }*
> %{{.*}})
> >
> > diff  --git a/llvm/lib/Transforms/IPO/Inliner.cpp
> b/llvm/lib/Transforms/IPO/Inliner.cpp
> > index 55753d979b2c..4f9f4bd1cd04 100644
> > --- a/llvm/lib/Transforms/IPO/Inliner.cpp
> > +++ b/llvm/lib/Transforms/IPO/Inliner.cpp
> > @@ -35,7 +35,6 @@
> >  #include "llvm/Analysis/TargetLibraryInfo.h"
> >  #include "llvm/Analysis/TargetTransformInfo.h"
> >  #include "llvm/Transforms/Utils/Local.h"
> > -#include "llvm/Transforms/Utils/CallPromotionUtils.h"
> >  #include "llvm/IR/Attributes.h"
> >  #include "llvm/IR/BasicBlock.h"
> >  #include "llvm/IR/CallSite.h"
> > @@ -1101,20 +1100,10 @@ PreservedAnalyses
> InlinerPass::run(LazyCallGraph::SCC &InitialC,
> >if (!IFI.InlinedCallSites.empty()) {
> >  int NewHistoryID = InlineHistory.size();
> >  InlineHistory.push_back({&Callee, InlineHistoryID});
> > -for (CallSite &CS : reverse(IFI.InlinedCallSites)) {
> > -  Function *NewCallee = CS.getCalledFunction();
> > -  if (!NewCallee) {
> > -// Try to promote an indirect (virtual) call without
> waiting for the
> > -// post-inline cleanup and the next DevirtSCCRepeatedPass
> iteration
> > -// because the next iteration may not happen and we may miss
> > -// inlining it.
> > -if (tryPromoteCall(CS))
> > -  NewCallee = CS.getCalledFunction();
> > -  }
> > -  if (NewCallee)
> > +for (CallSite &CS : reverse(IFI.InlinedCallSites))
> > +  if (Function *NewCallee = CS.getCalledFunction())
> >  if (!NewCallee->isDeclaration())
> >Calls.push_back({CS, NewHistoryID});
> > -}
> >}
> >
> >if (InlinerFunctionImportStats !=
> InlinerFunctionImportStatsOpts::No)
> >
> > diff  --git a/llvm/test/Transforms/Inline/devirtualize-4.ll
> b/llvm/test/Transforms/Inline/devirtualize-4.ll
> > deleted file mode 100644
> > index 2205dae7aa23..
> > --- a/llvm/test/Transforms/Inline/devirtualize-4.ll
> > +++ /dev/null
> > @@ -1,214 +0,0 @@
> > -; RUN: opt < %s
> -passes='cgscc(devirt<4>(inline)),function(sroa,early-cse)' -S | FileCheck
> %s
> > -; RUN: opt < %s -passes='default' -S | FileCheck %s
> > -
> > -; Check that DoNotOptimize is inlined into Test.
> > -; CHECK: @_Z4Testv()
> > -; CHECK-NOT: ret void
> > -; CHECK: call void asm
> > -; CHECK: ret void
> > -
> > -;template 
> > -;void DoNotOptimize(const T& var) {
> > -;  asm volatile("" : "+m"(const_cast(var)));

[PATCH] D71775: [ThreadPool] On Windows, extend usage to all CPU sockets and all NUMA groups

2020-02-27 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked an inline comment as done.
aganea added inline comments.



Comment at: llvm/lib/Support/Threading.cpp:94
+  // uselessly induce more context-switching and cache eviction.
+  if (!ThreadsRequested || ThreadsRequested > (unsigned)MaxThreadCount)
+return MaxThreadCount;

@mehdi_amini You mean this? Testing was showing degraded performance if 
ThreadsRequested > MaxThreadCount, so I thought it'd maybe better to prevent 
that situation. More soft threads than hardware threads means you'd pay for 
context switching, for the cache eviction and for extra memory pressure (even 
more if the allocator has per-thread pools).
Do you see a cases where not having this test would be valuable? Providing 
`--threads=50`, and creating 50-threads ThreadPool when your CPU only supports 
12 hardware threads? The only case I can think of is usage of async operations 
in threads, but then your ThreadPool sounds more like a queue, and maybe it's 
not the right hammer for the nail? Should we support that case and explicitly 
tag the ThreadPool constructor in client code with something like 
ThreadPool(50, AcknowledgeDegradedPerformance)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71775



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


[clang] ee1b2e7 - [Hexagon] Do not use init_arrays by default

2020-02-27 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2020-02-27T09:16:25-06:00
New Revision: ee1b2e7ded12ef6e11ce35bb9929490ac9e7fa4f

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

LOG: [Hexagon] Do not use init_arrays by default

Added: 


Modified: 
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/test/Driver/hexagon-toolchain-elf.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Hexagon.cpp 
b/clang/lib/Driver/ToolChains/Hexagon.cpp
index 25e9f1b6c222..88523cd4bb1c 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -523,6 +523,13 @@ unsigned HexagonToolChain::getOptimizationLevel(
 void HexagonToolChain::addClangTargetOptions(const ArgList &DriverArgs,
  ArgStringList &CC1Args,
  Action::OffloadKind) const {
+  bool UseInitArrayDefault = false;
+
+  if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
+  options::OPT_fno_use_init_array,
+  UseInitArrayDefault))
+CC1Args.push_back("-fno-use-init-array");
+
   if (DriverArgs.hasArg(options::OPT_ffixed_r19)) {
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+reserved-r19");

diff  --git a/clang/test/Driver/hexagon-toolchain-elf.c 
b/clang/test/Driver/hexagon-toolchain-elf.c
index a0bf8cac9668..0a6c86424955 100644
--- a/clang/test/Driver/hexagon-toolchain-elf.c
+++ b/clang/test/Driver/hexagon-toolchain-elf.c
@@ -588,3 +588,12 @@
 // RUN:   | FileCheck -check-prefix=CHECK083 %s
 // CHECK083:  "-isysroot" "/hexagon"
 // CHECK083:  "-internal-externc-isystem" "/hexagon{{/|}}include"
+// 
-
+// Passing -fno-use-init-array
+// 
-
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK084 %s
+// CHECK084:  "-fno-use-init-array"



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


[clang] bd97704 - [SYCL] Driver option to select SYCL version

2020-02-27 Thread Alexey Bader via cfe-commits

Author: Ruyman
Date: 2020-02-27T15:08:42+03:00
New Revision: bd97704eb5a95ecb048ce343c1a4be5d94e5

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

LOG: [SYCL] Driver option to select SYCL version

Summary:
User can select the version of SYCL the compiler will
use via the flag -sycl-std, similar to -cl-std.

The flag defines the LangOpts.SYCLVersion option to the
version of SYCL. The default value is undefined.
If driver is building SYCL code, flag is set to the default SYCL
version (1.2.1)

The preprocessor uses this variable to define CL_SYCL_LANGUAGE_VERSION macro,
which should be defined according to SYCL 1.2.1 standard.

Only valid value at this point for the flag is 1.2.1.

Co-Authored-By: David Wood 
Signed-off-by: Ruyman Reyes 

Subscribers: ebevhan, Anastasia, cfe-commits

Tags: #clang

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

Signed-off-by: Alexey Bader 

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/Driver/sycl.c
clang/test/Frontend/sycl-aux-triple.cpp
clang/test/Preprocessor/sycl-macro.cpp
clang/test/SemaSYCL/kernel-attribute.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 3cc7c384ac10..53b87b737568 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -230,7 +230,9 @@ LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate 
relocatable device code")
 LANGOPT(GPUAllowDeviceInit, 1, 0, "allowing device side global init functions 
for HIP")
 LANGOPT(GPUMaxThreadsPerBlock, 32, 256, "default max threads per block for 
kernel launch bounds for HIP")
 
+LANGOPT(SYCL  , 1, 0, "SYCL")
 LANGOPT(SYCLIsDevice  , 1, 0, "Generate code for SYCL device")
+LANGOPT(SYCLVersion   , 32, 0, "Version of the SYCL standard used")
 
 LANGOPT(HIPUseNewLaunchAPI, 1, 0, "Use new kernel launching API for HIP")
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f1801e3e89e7..36626342e364 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3420,10 +3420,12 @@ defm underscoring : BooleanFFlag<"underscoring">, 
Group;
 defm whole_file : BooleanFFlag<"whole-file">, Group;
 
 // C++ SYCL options
-def fsycl : Flag<["-"], "fsycl">, Group,
+def fsycl : Flag<["-"], "fsycl">, Group, Flags<[CC1Option, 
CoreOption]>,
   HelpText<"Enable SYCL kernels compilation for device">;
-def fno_sycl : Flag<["-"], "fno-sycl">, Group,
+def fno_sycl : Flag<["-"], "fno-sycl">, Group, Flags<[CoreOption]>,
   HelpText<"Disable SYCL kernels compilation for device">;
+def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, 
Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
+  HelpText<"SYCL language standard to compile for.">, Values<"2017, 121, 
1.2.1, sycl-1.2.1">;
 
 include "CC1Options.td"
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index d387a1dc2079..87596dd19c5a 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4040,9 +4040,18 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 CmdArgs.push_back(Args.MakeArgString(NormalizedTriple));
   }
 
-  if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false))
+  if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) {
+CmdArgs.push_back("-fsycl");
 CmdArgs.push_back("-fsycl-is-device");
 
+if (Arg *A = Args.getLastArg(options::OPT_sycl_std_EQ)) {
+  A->render(Args, CmdArgs);
+} else {
+  // Ensure the default version in SYCL mode is 1.2.1 (aka 2017)
+  CmdArgs.push_back("-sycl-std=2017");
+}
+  }
+
   if (IsOpenMPDevice) {
 // We have to pass the triple of the host if compiling for an OpenMP 
device.
 std::string NormalizedTriple =

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 9cc41c9d96f8..76f63d065017 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2535,6 +2535,24 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   LangStd = OpenCLLangStd;
   }
 
+  Opts.SYCL = Args.hasArg(options::OPT_fsycl);
+  Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
+  if (Opts.SYCL) {
+// -sycl-std applies to any SYCL source, not only those containing kernels,
+// but also those using the SYCL API
+if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) {
+  

[PATCH] D75249: [clangd] Use tokenize instead of raw lexer in SourceCode/lex

2020-02-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:728
+  case Default:
+llvm_unreachable("Using and Default handled above.");
+  }

why not inline the above `if` here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75249



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


[PATCH] D75184: [clang-tidy] Optional inheritance of file configs from parent directories 

2020-02-27 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 246944.
DmitryPolukhin added a comment.

Fix issue with config inheritance and caching configs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75184

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
  clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp


Index: clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -7,6 +7,9 @@
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/2/- -- | FileCheck %s 
-check-prefix=CHECK-CHILD2
 // CHECK-CHILD2: Checks: {{.*}}from-parent
 // CHECK-CHILD2: HeaderFilterRegex: parent
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/3/- -- | FileCheck %s 
-check-prefix=CHECK-CHILD3
+// CHECK-CHILD3: Checks: {{.*}}from-parent,from-child3
+// CHECK-CHILD3: HeaderFilterRegex: child3
 // RUN: clang-tidy -dump-config -checks='from-command-line' 
-header-filter='from command line' %S/Inputs/config-files/- -- | FileCheck %s 
-check-prefix=CHECK-COMMAND-LINE
 // CHECK-COMMAND-LINE: Checks: {{.*}}from-parent,from-command-line
 // CHECK-COMMAND-LINE: HeaderFilterRegex: from command line
Index: 
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
@@ -0,0 +1,3 @@
+InheritParentConfig: true
+Checks: 'from-child3'
+HeaderFilterRegex: 'child3'
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -106,6 +106,10 @@
 
   /// Add extra compilation arguments to the start of the list.
   llvm::Optional ExtraArgsBefore;
+
+  /// Config flag for FileOptionsProvider to also include config from parent
+  /// dir.
+  llvm::Optional InheritParentConfig;
 };
 
 /// Abstract interface for retrieving various ClangTidy options.
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -92,6 +92,7 @@
 IO.mapOptional("CheckOptions", NOpts->Options);
 IO.mapOptional("ExtraArgs", Options.ExtraArgs);
 IO.mapOptional("ExtraArgsBefore", Options.ExtraArgsBefore);
+IO.mapOptional("InheritParentConfig", Options.InheritParentConfig);
   }
 };
 
@@ -237,6 +238,7 @@
   DefaultOptionsProvider::getRawOptions(AbsoluteFilePath.str());
   OptionsSource CommandLineOptions(OverrideOptions,
OptionsSourceTypeCheckCommandLineOption);
+  size_t FirstFileConfig = RawOptions.size();
   // Look for a suitable configuration file in all parent directories of the
   // file. Start with the immediate parent directory and move up.
   StringRef Path = llvm::sys::path::parent_path(AbsoluteFilePath.str());
@@ -256,15 +258,21 @@
   while (Path != CurrentPath) {
 LLVM_DEBUG(llvm::dbgs()
<< "Caching configuration for path " << Path << ".\n");
-CachedOptions[Path] = *Result;
+if (!CachedOptions.count(Path))
+  CachedOptions[Path] = *Result;
 Path = llvm::sys::path::parent_path(Path);
   }
   CachedOptions[Path] = *Result;
 
   RawOptions.push_back(*Result);
-  break;
+  if (!Result->first.InheritParentConfig ||
+  !*Result->first.InheritParentConfig)
+break;
 }
   }
+  // Reverse order of file configs because closer configs should have higher
+  // priority.
+  std::reverse(RawOptions.begin() + FirstFileConfig, RawOptions.end());
   RawOptions.push_back(CommandLineOptions);
   return RawOptions;
 }


Index: clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -7,6 +7,9 @@
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/2/- -- | FileCheck %s -check-prefix=CHECK-CHILD2
 // CHECK-CHILD2: Checks: {{.*}}from-parent
 // CHECK-CHILD2: HeaderFilterRegex: parent
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/3/- -- | FileCheck %s -check-prefix=CHECK-CHILD3
+// CHECK-CHILD3: Checks: {{.*}}from-parent,from-child3
+// CHECK-CHILD3: HeaderFilterRegex: child3
 // RUN: clang-tidy -dump-config -checks='from-co

[PATCH] D73967: Implement _ExtInt as an extended int type specifier.

2020-02-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 2 inline comments as done.
erichkeane added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:1215
 
+  /// Return an extended integer type with the specified underlying type and 
bit
+  /// count.

mibintc wrote:
> Is this comment correct? "with the specified underlying type"
probably should be 'signedness', will update.


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

https://reviews.llvm.org/D73967



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


[PATCH] D75259: [clangd] Get rid of unnecssary source transformations in locateMacroAt

2020-02-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: sammccall, hokein.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

All callers are already passing spelling locations to locateMacroAt.
Also there's no point at looking at macro expansion for figuring out undefs as
it is forbidden to have PP directives inside macro bodies.
Also fixes a bug when the previous sourcelocation is unavailable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75259

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp


Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -436,6 +436,20 @@
   EXPECT_THAT(*Result, MacroName("MACRO"));
 }
 
+TEST(SourceCodeTests, WorksAtBeginOfFile) {
+  Annotations Code("^MACRO;");
+  TestTU TU = TestTU::withCode(Code.code());
+  TU.HeaderCode = "#define MACRO int x;";
+  auto AST = TU.build();
+  auto CurLoc = sourceLocationInMainFile(AST.getSourceManager(), Code.point());
+  ASSERT_TRUE(bool(CurLoc));
+  const auto *Id = syntax::spelledIdentifierTouching(*CurLoc, AST.getTokens());
+  ASSERT_TRUE(Id);
+  auto Result = locateMacroAt(Id->location(), AST.getPreprocessor());
+  ASSERT_TRUE(Result);
+  EXPECT_THAT(*Result, MacroName("MACRO"));
+}
+
 TEST(SourceCodeTests, IsInsideMainFile){
   TestTU TU;
   TU.HeaderCode = R"cpp(
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -281,7 +281,8 @@
   llvm::StringRef Name;
   const MacroInfo *Info;
 };
-/// Gets the macro at a specified \p Loc.
+/// Gets the macro at a specified \p Loc. It must be a spelling location and
+/// point to the beginning of identifier.
 llvm::Optional locateMacroAt(SourceLocation Loc,
Preprocessor &PP);
 
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -896,10 +896,11 @@
 
 llvm::Optional locateMacroAt(SourceLocation Loc,
Preprocessor &PP) {
+  assert(Loc.isFileID());
   const auto &SM = PP.getSourceManager();
   const auto &LangOpts = PP.getLangOpts();
   Token Result;
-  if (Lexer::getRawToken(SM.getSpellingLoc(Loc), Result, SM, LangOpts, false))
+  if (Lexer::getRawToken(Loc, Result, SM, LangOpts, false))
 return None;
   if (Result.is(tok::raw_identifier))
 PP.LookUpIdentifierInfo(Result);
@@ -907,14 +908,12 @@
   if (!IdentifierInfo || !IdentifierInfo->hadMacroDefinition())
 return None;
 
-  std::pair DecLoc = SM.getDecomposedExpansionLoc(Loc);
   // Get the definition just before the searched location so that a macro
-  // referenced in a '#undef MACRO' can still be found.
-  SourceLocation BeforeSearchedLocation =
-  SM.getMacroArgExpandedLocation(SM.getLocForStartOfFile(DecLoc.first)
- .getLocWithOffset(DecLoc.second - 1));
-  MacroDefinition MacroDef =
-  PP.getMacroDefinitionAtLoc(IdentifierInfo, BeforeSearchedLocation);
+  // referenced in a '#undef MACRO' can still be found. Note that we only do
+  // that if Loc is not pointing at start of file.
+  if (SM.getLocForStartOfFile(SM.getFileID(Loc)) != Loc)
+Loc = Loc.getLocWithOffset(-1);
+  MacroDefinition MacroDef = PP.getMacroDefinitionAtLoc(IdentifierInfo, Loc);
   if (auto *MI = MacroDef.getMacroInfo())
 return DefinedMacro{IdentifierInfo->getName(), MI};
   return None;


Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -436,6 +436,20 @@
   EXPECT_THAT(*Result, MacroName("MACRO"));
 }
 
+TEST(SourceCodeTests, WorksAtBeginOfFile) {
+  Annotations Code("^MACRO;");
+  TestTU TU = TestTU::withCode(Code.code());
+  TU.HeaderCode = "#define MACRO int x;";
+  auto AST = TU.build();
+  auto CurLoc = sourceLocationInMainFile(AST.getSourceManager(), Code.point());
+  ASSERT_TRUE(bool(CurLoc));
+  const auto *Id = syntax::spelledIdentifierTouching(*CurLoc, AST.getTokens());
+  ASSERT_TRUE(Id);
+  auto Result = locateMacroAt(Id->location(), AST.getPreprocessor());
+  ASSERT_TRUE(Result);
+  EXPECT_THAT(*Result, MacroName("MACRO"));
+}
+
 TEST(SourceCodeTests, IsInsideMainFile){
   TestTU TU;
   TU.HeaderCode = R"cpp(
Index: clang-tools-extra/clangd/SourceCode.h
===
--- cl

[PATCH] D73967: Implement _ExtInt as an extended int type specifier.

2020-02-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 246947.
erichkeane added a comment.

@mibintc 's comments


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

https://reviews.llvm.org/D73967

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Basic/TypeNodes.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/TypeBitCodes.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenTBAA.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/CodeGenTypes.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGen/ext-int-sanitizer.cpp
  clang/test/CodeGen/ext-int.cpp
  clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp
  clang/test/CodeGenOpenCL/ext-int-shift.cl
  clang/test/SemaCXX/ext-int.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1804,6 +1804,8 @@
 DEFAULT_TYPELOC_IMPL(SubstTemplateTypeParm, Type)
 DEFAULT_TYPELOC_IMPL(SubstTemplateTypeParmPack, Type)
 DEFAULT_TYPELOC_IMPL(Auto, Type)
+DEFAULT_TYPELOC_IMPL(ExtInt, Type)
+DEFAULT_TYPELOC_IMPL(DependentExtInt, Type)
 
 bool CursorVisitor::VisitCXXRecordDecl(CXXRecordDecl *D) {
   // Visit the nested-name-specifier, if present.
Index: clang/test/SemaCXX/ext-int.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/ext-int.cpp
@@ -0,0 +1,266 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template
+struct HasExtInt {
+  _ExtInt(Bounds) b;
+  unsigned _ExtInt(Bounds) b2;
+};
+
+// Delcaring variables:
+_ExtInt(33) Declarations(_ExtInt(48) &Param) { // Useable in params and returns.
+  short _ExtInt(43) a; // expected-error {{'short _ExtInt' is invalid}}
+  _ExtInt(43) long b;  // expected-error {{'long _ExtInt' is invalid}}
+
+  // These should all be fine:
+  const _ExtInt(5) c = 3;
+  const unsigned _ExtInt(5) d; // expected-error {{default initialization of an object of const type 'const unsigned _ExtInt(5)'}}
+  unsigned _ExtInt(5) e = 5;
+  _ExtInt(5) unsigned f;
+
+  _ExtInt(-3) g; // expected-error{{signed _ExtInt must have a size of at least 2}}
+  _ExtInt(0) h; // expected-error{{signed _ExtInt must have a size of at least 2}}
+  _ExtInt(1) i; // expected-error{{signed _ExtInt must have a size of at least 2}}
+  _ExtInt(2) j;;
+  unsigned _ExtInt(0) k;// expected-error{{unsigned _ExtInt must have a size of at least 1}}
+  unsigned _ExtInt(1) l;
+  signed _ExtInt(1) m; // expected-error{{signed _ExtInt must have a size of at least 2}}
+
+  constexpr _ExtInt(6) n = 33; // expected-warning{{implicit conversion from 'int' to 'const _ExtInt(6)' changes value from 33 to -31}}
+  constexpr _ExtInt(7) o = 33;
+
+  // Check LLVM imposed max size.
+  _ExtInt(0xFF) p; // expected-error {{signed _ExtInt of sizes greater than 16777215 not supported}}
+  unsigned _ExtInt(0xFF) q; // expected-error {{unsigned _ExtInt of sizes greater than 16777215 not supported}}
+
+// Ensure template params are instantiated correctly.
+  // expected-error@5{{signed _ExtInt must have a size of at least 2}}
+  // expected-error@6{{unsigned _ExtInt must have a size of at least 1}}
+  // expected-note@+1{{in instantiation of template class }}
+  HasExtInt<-1> r;
+  // expected-error@5{{signed _ExtInt must have a size of at least 2}}
+  // expected-error@6{{unsigned _ExtInt must have a size of at least 1}}
+  // expected-note@+1{{in instantiation of template class }}
+  HasExtInt<0> s;
+  // expected-erro

[clang] 00072c0 - [WebAssembly] Mangle the argc/argv `main` as `__wasm_argc_argv`.

2020-02-27 Thread Dan Gohman via cfe-commits

Author: Dan Gohman
Date: 2020-02-27T07:55:36-08:00
New Revision: 00072c08c75050ae2c835b7bb0e505475dbcd7b9

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

LOG: [WebAssembly] Mangle the argc/argv `main` as `__wasm_argc_argv`.

WebAssembly enforces a rule that caller and callee signatures must
match. This means that the traditional technique of passing `main`
`argc` and `argv` even when it doesn't need them doesn't work.

Currently the backend renames `main` to `__original_main`, however this
doesn't interact well with LTO'ing libc, and the name isn't intuitive.
This patch allows us to transition to `__main_argc_argv` instead.

This implements the proposal in
https://github.com/WebAssembly/tool-conventions/pull/134
with a flag to disable it when targeting Emscripten, though this is
expected to be temporary, as discussed in the proposal comments.

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

Added: 
clang/test/CodeGen/wasm-call-main.c
clang/test/CodeGen/wasm-main.c
clang/test/CodeGen/wasm-main_argc_argv.c

Modified: 
clang/lib/AST/Mangle.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/Frontend/InitHeaderSearch.cpp

Removed: 




diff  --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp
index 6fd1840905b3..1a2cb29f0ec7 100644
--- a/clang/lib/AST/Mangle.cpp
+++ b/clang/lib/AST/Mangle.cpp
@@ -50,7 +50,8 @@ enum CCMangling {
   CCM_Fast,
   CCM_RegCall,
   CCM_Vector,
-  CCM_Std
+  CCM_Std,
+  CCM_WasmMainArgcArgv
 };
 
 static bool isExternC(const NamedDecl *ND) {
@@ -63,6 +64,16 @@ static CCMangling getCallingConvMangling(const ASTContext 
&Context,
  const NamedDecl *ND) {
   const TargetInfo &TI = Context.getTargetInfo();
   const llvm::Triple &Triple = TI.getTriple();
+
+  // On wasm, the argc/argv form of "main" is renamed so that the startup code
+  // can call it with the correct function signature.
+  // On Emscripten, users may be exporting "main" and expecting to call it
+  // themselves, so we can't mangle it.
+  if (Triple.isWasm() && !Triple.isOSEmscripten())
+if (const FunctionDecl *FD = dyn_cast(ND))
+  if (FD->isMain() && FD->hasPrototype() && FD->param_size() == 2)
+return CCM_WasmMainArgcArgv;
+
   if (!Triple.isOSWindows() || !Triple.isX86())
 return CCM_Other;
 
@@ -143,6 +154,12 @@ void MangleContext::mangleName(const NamedDecl *D, 
raw_ostream &Out) {
 
   const ASTContext &ASTContext = getASTContext();
   CCMangling CC = getCallingConvMangling(ASTContext, D);
+
+  if (CC == CCM_WasmMainArgcArgv) {
+Out << "__main_argc_argv";
+return;
+  }
+
   bool MCXX = shouldMangleCXXName(D);
   const TargetInfo &TI = Context.getTargetInfo();
   if (CC == CCM_Other || (MCXX && TI.getCXXABI() == TargetCXXABI::Microsoft)) {

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 652efd857064..faff623a2973 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -448,6 +448,10 @@ void CodeGenModule::Release() {
 CodeGenFunction(*this).EmitCfiCheckStub();
   }
   emitAtAvailableLinkGuard();
+  if (Context.getTargetInfo().getTriple().isWasm() &&
+  !Context.getTargetInfo().getTriple().isOSEmscripten()) {
+EmitMainVoidAlias();
+  }
   emitLLVMUsed();
   if (SanStats)
 SanStats->finish();
@@ -5600,6 +5604,17 @@ void CodeGenModule::EmitDeferredUnusedCoverageMappings() 
{
   }
 }
 
+void CodeGenModule::EmitMainVoidAlias() {
+  // In order to transition away from "__original_main" gracefully, emit an
+  // alias for "main" in the no-argument case so that libc can detect when
+  // new-style no-argument main is in used.
+  if (llvm::Function *F = getModule().getFunction("main")) {
+if (!F->isDeclaration() && F->arg_size() == 0 && !F->isVarArg() &&
+F->getReturnType()->isIntegerTy(Context.getTargetInfo().getIntWidth()))
+  addUsedGlobal(llvm::GlobalAlias::create("__main_void", F));
+  }
+}
+
 /// Turns the given pointer into a constant.
 static llvm::Constant *GetPointerConstant(llvm::LLVMContext &Context,
   const void *Ptr) {

diff  --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index e8162fcfc0cd..48a3938ceeec 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1023,6 +1023,9 @@ class CodeGenModule : public CodeGenTypeCache {
   /// for the uninstrumented functions.
   void EmitDeferredUnusedCoverageMappings();
 
+  /// Emit an alias for "main" if it has no arguments (needed for wasm).
+  void EmitMainVoidAlias();
+
   /// Tell the consumer that this variable has been instantiated.
   void HandleCXXStaticMemberVarInstantiation

[PATCH] D75057: Syndicate, test and fix base64 implementation

2020-02-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

thanks for doing this! didn't look into details yet. Could you explain what was 
the bug in the previous code? since this patch contains some refactoring 
changes, it is not quite straightforward to spot it.




Comment at: llvm/unittests/Support/Base64Test.cpp:1
+//===- llvm/unittest/Support/Base64.cpp - Base64 tests 
===//
+//

nit: Base64Test.cpp.



Comment at: llvm/unittests/Support/Base64Test.cpp:30
+  // from: https://tools.ietf.org/html/rfc4648#section-10
+  TestBase64("", "");
+  TestBase64("f", "Zg==");

nit: i would just inline the `TestBase64`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75057



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


[PATCH] D75139: [hexagon] Pickup the default crt and libs when the musl target is selected

2020-02-27 Thread Brian Cain via Phabricator via cfe-commits
bcain accepted this revision.
bcain added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: ormris.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75139



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


[PATCH] D75261: [clang-format] Recognize C# nullable types

2020-02-27 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe created this revision.
jbcoe added a reviewer: krasimir.
jbcoe added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Do not confuse C# nullable types with conditional expressions.

Do not put a space before the `?` in `[access-modifier] Type? variableName;`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75261

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


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -175,7 +175,7 @@
   Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
 
   verifyFormat(
-  "public Person(string firstName, string lastName, int? age=null)");
+  "public Person(string firstName, string lastName, int? age = null)");
 
   verifyFormat("foo () {\n"
"  switch (args?.Length) {}\n"
@@ -603,5 +603,11 @@
   verifyFormat(R"(private float[, ] Values;)", Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpNullableTypes) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat(R"(public float? Value;)", Style); // no space before `?`.
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -987,6 +987,10 @@
   if (Line.MustBeDeclaration && !Contexts.back().IsExpression &&
   Style.Language == FormatStyle::LK_JavaScript)
 break;
+  if (Style.isCSharp() && Line.MustBeDeclaration) {
+Tok->Type = TT_CSharpNullableTypeQuestionMark;
+break;
+  }
   parseConditional();
   break;
 case tok::kw_template:
@@ -2902,6 +2906,10 @@
 if (Left.is(tok::comma) && Right.is(tok::r_square))
   return Style.SpacesInSquareBrackets;
 
+// No space before ? in nullable types.
+if (Right.is(TT_CSharpNullableTypeQuestionMark))
+  return false;
+
 // space between keywords and paren e.g. "using ("
 if (Right.is(tok::l_paren))
   if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when))
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -104,6 +104,7 @@
   TYPE(CSharpStringLiteral)
\
   TYPE(CSharpNullCoalescing)   
\
   TYPE(CSharpNamedArgumentColon)   
\
+  TYPE(CSharpNullableTypeQuestionMark) 
\
   TYPE(Unknown)
 
 enum TokenType {


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -175,7 +175,7 @@
   Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
 
   verifyFormat(
-  "public Person(string firstName, string lastName, int? age=null)");
+  "public Person(string firstName, string lastName, int? age = null)");
 
   verifyFormat("foo () {\n"
"  switch (args?.Length) {}\n"
@@ -603,5 +603,11 @@
   verifyFormat(R"(private float[, ] Values;)", Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpNullableTypes) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat(R"(public float? Value;)", Style); // no space before `?`.
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -987,6 +987,10 @@
   if (Line.MustBeDeclaration && !Contexts.back().IsExpression &&
   Style.Language == FormatStyle::LK_JavaScript)
 break;
+  if (Style.isCSharp() && Line.MustBeDeclaration) {
+Tok->Type = TT_CSharpNullableTypeQuestionMark;
+break;
+  }
   parseConditional();
   break;
 case tok::kw_template:
@@ -2902,6 +2906,10 @@
 if (Left.is(tok::comma) && Right.is(tok::r_square))
   return Style.SpacesInSquareBrackets;
 
+// No space before ? in nullable types.
+if (Right.is(TT_CSharpNullableTypeQuestionMark))
+  return false;
+
 // space between keywords and paren e.g. "using ("
 if (Right.is(tok::l_paren))
   if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when))
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -104,6 +104,7 @@
   TYPE(CSharpStringLiteral)   

[PATCH] D75163: [analyzer][StreamChecker] Adding precall and refactoring.

2020-02-27 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 246955.
balazske added a comment.

- Improved comments in the code.
- Added function to get stream arg.
- Changed error messages.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75163

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

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -108,19 +108,56 @@
 
 void f_double_close(void) {
   FILE *p = fopen("foo", "r");
-  fclose(p); 
-  fclose(p); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour}}
+  if (!p)
+return;
+  fclose(p);
+  fclose(p); // expected-warning {{Stream might be already closed}}
 }
 
 void f_double_close_alias(void) {
   FILE *p1 = fopen("foo", "r");
+  if (!p1)
+return;
   FILE *p2 = p1;
   fclose(p1);
-  fclose(p2); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour}}
+  fclose(p2); // expected-warning {{Stream might be already closed}}
+}
+
+void f_use_after_close(void) {
+  FILE *p = fopen("foo", "r");
+  if (!p)
+return;
+  fclose(p);
+  clearerr(p); // expected-warning {{Stream might be already closed}}
+}
+
+void f_open_after_close(void) {
+  FILE *p = fopen("foo", "r");
+  if (!p)
+return;
+  fclose(p);
+  p = fopen("foo", "r");
+  if (!p)
+return;
+  fclose(p);
+}
+
+void f_reopen_after_close(void) {
+  FILE *p = fopen("foo", "r");
+  if (!p)
+return;
+  fclose(p);
+  // Allow reopen after close.
+  p = freopen("foo", "w", p);
+  if (!p)
+return;
+  fclose(p);
 }
 
 void f_leak(int c) {
   FILE *p = fopen("foo.c", "r");
+  if (!p)
+return;
   if(c)
 return; // expected-warning {{Opened File never closed. Potential Resource leak}}
   fclose(p);
@@ -155,13 +192,13 @@
 if (f2) {
   // Check if f1 and f2 point to the same stream.
   fclose(f1);
-  fclose(f2); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour}}
+  fclose(f2); // expected-warning {{Stream might be already closed.}}
 } else {
   // Reopen failed.
-  // f1 points now to a possibly invalid stream but this condition is currently not checked.
-  // f2 is NULL.
-  rewind(f1);
-  rewind(f2); // expected-warning {{Stream pointer might be NULL}}
+  // f1 is non-NULL but points to a possibly invalid stream.
+  rewind(f1); // expected-warning {{Stream might be invalid}}
+  // f2 is NULL but the previous error stops the checker.
+  rewind(f2);
 }
   }
 }
@@ -170,9 +207,9 @@
   FILE *f1 = fopen("foo.c", "r");
   if (f1) {
 // Unchecked result of freopen.
-// The f1 may be invalid after this call (not checked by the checker).
+// The f1 may be invalid after this call.
 freopen(0, "w", f1);
-rewind(f1);
+rewind(f1); // expected-warning {{Stream might be invalid}}
 fclose(f1);
   }
 }
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -34,8 +34,8 @@
 
   bool isOpened() const { return K == Opened; }
   bool isClosed() const { return K == Closed; }
-  //bool isOpenFailed() const { return K == OpenFailed; }
-  //bool isEscaped() const { return K == Escaped; }
+  bool isOpenFailed() const { return K == OpenFailed; }
+  // bool isEscaped() const { return K == Escaped; }
 
   bool operator==(const StreamState &X) const { return K == X.K; }
 
@@ -44,104 +44,183 @@
   static StreamState getOpenFailed() { return StreamState(OpenFailed); }
   static StreamState getEscaped() { return StreamState(Escaped); }
 
-  void Profile(llvm::FoldingSetNodeID &ID) const {
-ID.AddInteger(K);
-  }
+  void Profile(llvm::FoldingSetNodeID &ID) const { ID.AddInteger(K); }
 };
 
 class StreamChecker;
+struct FnDescription;
+using FnCheck = std::function;
 
-using FnCheck = std::function;
+using ArgNoTy = unsigned int;
+static const ArgNoTy ArgNone = std::numeric_limits::max();
 
 struct FnDescription {
+  FnCheck PreFn;
   FnCheck EvalFn;
+  ArgNoTy StreamArgNo;
 };
 
-class StreamChecker : public Checker {
+/// Get the value of the stream argument out of the passed call event.
+/// The call should contain a function that is described by Desc.
+SVal getStreamArg(const FnDescription *Desc, const CallEvent &Call) {
+  assert(Desc && Desc->StreamArgNo != ArgNone &&
+ "Try to get a non-existing stream argument.");
+  return Call.getArgSVal(Desc->StreamArgNo);
+}
+
+class StreamChecker
+: public Checker {
   mutable std::unique_ptr BT_nullfp, BT_illegalwhence,
-  BT_doubleclose, BT_ResourceLeak;
+  BT_UseAfterClose, BT_UseAfterOpenFailed, BT_ResourceLeak;
 
 public:
+

[PATCH] D73967: Implement _ExtInt as an extended int type specifier.

2020-02-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/Type.h:6196
 
+// A fixed int type of a specified bitwidth.
+class ExtIntType : public Type, public llvm::FoldingSetNode {

Use `///` style



Comment at: clang/include/clang/AST/Type.h:6197
+// A fixed int type of a specified bitwidth.
+class ExtIntType : public Type, public llvm::FoldingSetNode {
+  friend class ASTContext;

`final` class



Comment at: clang/include/clang/AST/Type.h:6225
+
+class DependentExtIntType : public Type, public llvm::FoldingSetNode {
+  friend class ASTContext;

`final` class



Comment at: clang/include/clang/AST/TypeLoc.h:2453-2457
+class ExtIntTypeLoc
+: public InheritingConcreteTypeLoc {};
+class DependentExtIntTypeLoc
+: public InheritingConcreteTypeLoc(T)) {
+return 0 + (EIT->getNumBits() << 3);
+  }

No need for braces here.



Comment at: clang/lib/AST/Type.cpp:2117-2118
 return STK_IntegralComplex;
-  }
+  } else if (isExtIntType())
+return STK_Integral;
 

Enclose substatement in braces to follow the coding style used for other 
substatements.


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

https://reviews.llvm.org/D73967



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


[PATCH] D74910: [OpenCL] Remove spurious atomic_fetch_min/max builtins

2020-02-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74910



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


[PATCH] D75163: [analyzer][StreamChecker] Adding precall and refactoring.

2020-02-27 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 10 inline comments as done.
balazske added a comment.

Error messages are now in similar form as the null stream pointer case.




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:76-92
+  {{"fopen"}, {{}, &StreamChecker::evalFopen, ArgNone}},
+  {{"freopen", 3},
+   {&StreamChecker::preFreopen, &StreamChecker::evalFreopen, 2}},
+  {{"tmpfile"}, {{}, &StreamChecker::evalFopen, ArgNone}},
+  {{"fclose", 1},
+   {&StreamChecker::preDefault, &StreamChecker::evalFclose, 0}},
+  {{"fread", 4}, {&StreamChecker::preDefault, {}, 3}},

Szelethus wrote:
> Hmm, all of these braces are kinda hard to navigate, but its not too bad. 
> Could you check whether changing them to `nullptr` improves readability? I'll 
> leave it to your judgement.
`nullptr` looks better. (Missing value at "fseek" will be updated.)



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:349-355
+  SymbolRef Sym = StreamVal.getAsSymbol();
   if (!Sym)
-return State;
+return nullptr;
 
   const StreamState *SS = State->get(Sym);
-
-  // If the file stream is not tracked, return.
   if (!SS)
+return nullptr;

Szelethus wrote:
> Previously, we only returned a `nullptr` after generating a fatal error node. 
> Why do we need to change this?
This is fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75163



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


[PATCH] D31342: Add ParsedAttrInfo::handleDeclAttribute

2020-02-27 Thread John Brawn via Phabricator via cfe-commits
john.brawn marked 2 inline comments as done.
john.brawn added inline comments.



Comment at: clang/docs/ClangPlugins.rst:74
+
+  class ExampleAttrInfo : public ParsedAttrInfo {
+  public:

aaron.ballman wrote:
> We should be documenting the fields of `ParsedAttrInfo` that the user would 
> be interacting with. We should also consider whether we are introducing a new 
> stability guarantee with that interface and document accordingly. I think we 
> should not promise that this structure will be stable from release to 
> release, but it will be stable within a given release (e.g., the type can 
> change between Clang 11 -> Clang 12, but the type will not change between 
> Clang 11 -> Clang 11.0.1).
I'll add documentation of the relevant fields. As to API stability, looking at 
Tooling.rst it says only libclang has a stable API (or rather, it says libclang 
has a stable API, says libtooling doesn't, and says nothing about plugins).



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6701-6702
 
+  if (AL.getInfo().handleDeclAttribute(S, D, AL))
+return;
+

aaron.ballman wrote:
> I think this might make more logical sense as part of the `default` label in 
> the `switch` statement.
Sounds reasonable, I'll do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31342



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


[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

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

This landed here: 
https://github.com/llvm/llvm-project/commit/bd97704eb5a95ecb048ce343c1a4be5d94e5

It broke tests on mac: http://45.33.8.238/mac/9011/step_7.txt

Please take a look, and if it takes a while please revert while you investigate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857



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


[Diffusion] rG396b7253944e: [OpenMP][Opt] Combine `struct ident_t*` during deduplication

2020-02-27 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.

BRANCHES
  master

/clang/test/OpenMP/PR44893.c:3 A test with no CHECK lines also passes if you 
symlink /bin/true to clang :-)
It also doesn't indicate what is being relevant and when it comes to 
maintaining / updating the test we won't know what is important to keep.
The fact that there was a crash that wasn't hit by the test suite indicates 
that there was some behavior that wasn't tested before, so we should really try 
to check that behavior.

Users:
  jdoerfert (Author)

https://reviews.llvm.org/rG396b7253944e



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


[PATCH] D73967: Implement _ExtInt as an extended int type specifier.

2020-02-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 246958.
erichkeane marked 8 inline comments as done.
erichkeane added a comment.

Changes requested by @ABataev


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

https://reviews.llvm.org/D73967

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Basic/TypeNodes.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/TypeBitCodes.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenTBAA.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/CodeGenTypes.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGen/ext-int-sanitizer.cpp
  clang/test/CodeGen/ext-int.cpp
  clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp
  clang/test/CodeGenOpenCL/ext-int-shift.cl
  clang/test/SemaCXX/ext-int.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1804,6 +1804,8 @@
 DEFAULT_TYPELOC_IMPL(SubstTemplateTypeParm, Type)
 DEFAULT_TYPELOC_IMPL(SubstTemplateTypeParmPack, Type)
 DEFAULT_TYPELOC_IMPL(Auto, Type)
+DEFAULT_TYPELOC_IMPL(ExtInt, Type)
+DEFAULT_TYPELOC_IMPL(DependentExtInt, Type)
 
 bool CursorVisitor::VisitCXXRecordDecl(CXXRecordDecl *D) {
   // Visit the nested-name-specifier, if present.
Index: clang/test/SemaCXX/ext-int.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/ext-int.cpp
@@ -0,0 +1,266 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template
+struct HasExtInt {
+  _ExtInt(Bounds) b;
+  unsigned _ExtInt(Bounds) b2;
+};
+
+// Delcaring variables:
+_ExtInt(33) Declarations(_ExtInt(48) &Param) { // Useable in params and returns.
+  short _ExtInt(43) a; // expected-error {{'short _ExtInt' is invalid}}
+  _ExtInt(43) long b;  // expected-error {{'long _ExtInt' is invalid}}
+
+  // These should all be fine:
+  const _ExtInt(5) c = 3;
+  const unsigned _ExtInt(5) d; // expected-error {{default initialization of an object of const type 'const unsigned _ExtInt(5)'}}
+  unsigned _ExtInt(5) e = 5;
+  _ExtInt(5) unsigned f;
+
+  _ExtInt(-3) g; // expected-error{{signed _ExtInt must have a size of at least 2}}
+  _ExtInt(0) h; // expected-error{{signed _ExtInt must have a size of at least 2}}
+  _ExtInt(1) i; // expected-error{{signed _ExtInt must have a size of at least 2}}
+  _ExtInt(2) j;;
+  unsigned _ExtInt(0) k;// expected-error{{unsigned _ExtInt must have a size of at least 1}}
+  unsigned _ExtInt(1) l;
+  signed _ExtInt(1) m; // expected-error{{signed _ExtInt must have a size of at least 2}}
+
+  constexpr _ExtInt(6) n = 33; // expected-warning{{implicit conversion from 'int' to 'const _ExtInt(6)' changes value from 33 to -31}}
+  constexpr _ExtInt(7) o = 33;
+
+  // Check LLVM imposed max size.
+  _ExtInt(0xFF) p; // expected-error {{signed _ExtInt of sizes greater than 16777215 not supported}}
+  unsigned _ExtInt(0xFF) q; // expected-error {{unsigned _ExtInt of sizes greater than 16777215 not supported}}
+
+// Ensure template params are instantiated correctly.
+  // expected-error@5{{signed _ExtInt must have a size of at least 2}}
+  // expected-error@6{{unsigned _ExtInt must have a size of at least 1}}
+  // expected-note@+1{{in instantiation of template class }}
+  HasExtInt<-1> r;
+  // expected-error@5{{signed _ExtInt must have a size of at least 2}}
+  // expected-error@6{{unsigned _ExtInt must have a size of at least 1}}
+  // expected-note@+1{{in instantiation of te

[clang] 740ed61 - Revert "[SYCL] Driver option to select SYCL version"

2020-02-27 Thread Alexey Bader via cfe-commits

Author: Alexey Bader
Date: 2020-02-27T16:23:54+03:00
New Revision: 740ed617f7d4d16e7883636c5eff994f8be7eba4

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

LOG: Revert "[SYCL] Driver option to select SYCL version"

This reverts commit bd97704eb5a95ecb048ce343c1a4be5d94e5.

It broke tests on mac: http://45.33.8.238/mac/9011/step_7.txt

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/Driver/sycl.c
clang/test/Frontend/sycl-aux-triple.cpp
clang/test/Preprocessor/sycl-macro.cpp
clang/test/SemaSYCL/kernel-attribute.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 53b87b737568..3cc7c384ac10 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -230,9 +230,7 @@ LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate 
relocatable device code")
 LANGOPT(GPUAllowDeviceInit, 1, 0, "allowing device side global init functions 
for HIP")
 LANGOPT(GPUMaxThreadsPerBlock, 32, 256, "default max threads per block for 
kernel launch bounds for HIP")
 
-LANGOPT(SYCL  , 1, 0, "SYCL")
 LANGOPT(SYCLIsDevice  , 1, 0, "Generate code for SYCL device")
-LANGOPT(SYCLVersion   , 32, 0, "Version of the SYCL standard used")
 
 LANGOPT(HIPUseNewLaunchAPI, 1, 0, "Use new kernel launching API for HIP")
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 36626342e364..f1801e3e89e7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3420,12 +3420,10 @@ defm underscoring : BooleanFFlag<"underscoring">, 
Group;
 defm whole_file : BooleanFFlag<"whole-file">, Group;
 
 // C++ SYCL options
-def fsycl : Flag<["-"], "fsycl">, Group, Flags<[CC1Option, 
CoreOption]>,
+def fsycl : Flag<["-"], "fsycl">, Group,
   HelpText<"Enable SYCL kernels compilation for device">;
-def fno_sycl : Flag<["-"], "fno-sycl">, Group, Flags<[CoreOption]>,
+def fno_sycl : Flag<["-"], "fno-sycl">, Group,
   HelpText<"Disable SYCL kernels compilation for device">;
-def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, 
Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
-  HelpText<"SYCL language standard to compile for.">, Values<"2017, 121, 
1.2.1, sycl-1.2.1">;
 
 include "CC1Options.td"
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 87596dd19c5a..d387a1dc2079 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4040,18 +4040,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 CmdArgs.push_back(Args.MakeArgString(NormalizedTriple));
   }
 
-  if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) {
-CmdArgs.push_back("-fsycl");
+  if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false))
 CmdArgs.push_back("-fsycl-is-device");
 
-if (Arg *A = Args.getLastArg(options::OPT_sycl_std_EQ)) {
-  A->render(Args, CmdArgs);
-} else {
-  // Ensure the default version in SYCL mode is 1.2.1 (aka 2017)
-  CmdArgs.push_back("-sycl-std=2017");
-}
-  }
-
   if (IsOpenMPDevice) {
 // We have to pass the triple of the host if compiling for an OpenMP 
device.
 std::string NormalizedTriple =

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 76f63d065017..9cc41c9d96f8 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2535,24 +2535,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   LangStd = OpenCLLangStd;
   }
 
-  Opts.SYCL = Args.hasArg(options::OPT_fsycl);
-  Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
-  if (Opts.SYCL) {
-// -sycl-std applies to any SYCL source, not only those containing kernels,
-// but also those using the SYCL API
-if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) {
-  Opts.SYCLVersion = llvm::StringSwitch(A->getValue())
- .Cases("2017", "1.2.1", "121", "sycl-1.2.1", 2017)
- .Default(0U);
-
-  if (Opts.SYCLVersion == 0U) {
-// User has passed an invalid value to the flag, this is an error
-Diags.Report(diag::err_drv_invalid_value)
-<< A->getAsString(Args) << A->getValue();
-  }
-}
-  }
-
   Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
   Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_ope

[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-02-27 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

In D72857#1895625 , @thakis wrote:

> This landed here: 
> https://github.com/llvm/llvm-project/commit/bd97704eb5a95ecb048ce343c1a4be5d94e5
>
> It broke tests on mac: http://45.33.8.238/mac/9011/step_7.txt
>
> Please take a look, and if it takes a while please revert while you 
> investigate.


@thakis, thank for letting me know. I've reverted it at 
740ed617f7d4d16e7883636c5eff994f8be7eba4 
. Sorry 
for inconvenience.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857



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


[PATCH] D75125: [Docs][OpenCL] Release 10.0 notes for OpenCL

2020-02-27 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh closed this revision.
svenvh added a comment.

Committed in e5cb70267e7 
.


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

https://reviews.llvm.org/D75125



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


[PATCH] D75261: [clang-format] Recognize C# nullable types

2020-02-27 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe marked an inline comment as done.
jbcoe added inline comments.



Comment at: clang/unittests/Format/FormatTestCSharp.cpp:178
   verifyFormat(
-  "public Person(string firstName, string lastName, int? age=null)");
+  "public Person(string firstName, string lastName, int? age = null)");
 

This will be formatted as 

public Person(string firstName, string lastName, int age = null);

without the Nullable Type.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75261



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


[PATCH] D75130: Remove BinaryOperator::CreateFNeg

2020-02-27 Thread Simon Moll via Phabricator via cfe-commits
simoll updated this revision to Diff 246974.
simoll added a comment.

- rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75130

Files:
  clang/test/CodeGen/complex-math.c
  llvm/include/llvm/IR/InstrTypes.h
  llvm/lib/IR/Instructions.cpp
  llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/lib/Transforms/Scalar/Reassociate.cpp
  llvm/test/Transforms/InstCombine/cos-sin-intrinsic.ll
  llvm/test/Transforms/InstCombine/fast-math.ll
  llvm/test/Transforms/InstCombine/fmul.ll
  llvm/test/Transforms/InstCombine/fneg.ll
  llvm/test/Transforms/InstCombine/fpcast.ll
  llvm/test/Transforms/InstCombine/fsub.ll
  llvm/test/Transforms/InstCombine/maximum.ll
  llvm/test/Transforms/InstCombine/maxnum.ll
  llvm/test/Transforms/InstCombine/minimum.ll
  llvm/test/Transforms/InstCombine/minmax-fp.ll
  llvm/test/Transforms/InstCombine/minnum.ll
  llvm/test/Transforms/InstCombine/pow-1.ll
  llvm/test/Transforms/Reassociate/fast-basictest.ll
  llvm/test/Transforms/Reassociate/fp-expr.ll

Index: llvm/test/Transforms/Reassociate/fp-expr.ll
===
--- llvm/test/Transforms/Reassociate/fp-expr.ll
+++ llvm/test/Transforms/Reassociate/fp-expr.ll
@@ -4,7 +4,7 @@
 define void @test1() {
 ; CHECK-LABEL: @test1(
 ; CHECK-NEXT:[[T1:%.*]] = tail call <4 x float> @blam()
-; CHECK-NEXT:[[T1_NEG:%.*]] = fsub fast <4 x float> , [[T1]]
+; CHECK-NEXT:[[T1_NEG:%.*]] = fneg fast <4 x float> [[T1]]
 ; CHECK-NEXT:[[T24:%.*]] = fadd fast <4 x float> [[T1_NEG]], undef
 ; CHECK-NEXT:tail call void @wombat(<4 x float> [[T24]])
 ; CHECK-NEXT:ret void
@@ -19,7 +19,7 @@
 define half @test2() {
 ; CHECK-LABEL: @test2(
 ; CHECK-NEXT:[[T15:%.*]] = fsub fast half undef, undef
-; CHECK-NEXT:[[T15_NEG:%.*]] = fsub fast half 0xH8000, [[T15]]
+; CHECK-NEXT:[[T15_NEG:%.*]] = fneg fast half [[T15]]
 ; CHECK-NEXT:[[T18:%.*]] = fadd fast half [[T15_NEG]], undef
 ; CHECK-NEXT:ret half [[T18]]
 ;
Index: llvm/test/Transforms/Reassociate/fast-basictest.ll
===
--- llvm/test/Transforms/Reassociate/fast-basictest.ll
+++ llvm/test/Transforms/Reassociate/fast-basictest.ll
@@ -4,7 +4,7 @@
 ; With reassociation, constant folding can eliminate the 12 and -12 constants.
 define float @test1(float %arg) {
 ; CHECK-LABEL: @test1(
-; CHECK-NEXT:[[ARG_NEG:%.*]] = fsub fast float -0.00e+00, [[ARG:%.*]]
+; CHECK-NEXT:[[ARG_NEG:%.*]] = fneg fast float [[ARG:%.*]]
 ; CHECK-NEXT:ret float [[ARG_NEG]]
 ;
   %t1 = fsub fast float -1.20e+01, %arg
@@ -16,7 +16,7 @@
 ; Both 'reassoc' and 'nsz' are required.
 define float @test1_minimal(float %arg) {
 ; CHECK-LABEL: @test1_minimal(
-; CHECK-NEXT:[[TMP1:%.*]] = fsub reassoc nsz float -0.00e+00, [[ARG:%.*]]
+; CHECK-NEXT:[[TMP1:%.*]] = fneg reassoc nsz float [[ARG:%.*]]
 ; CHECK-NEXT:ret float [[TMP1]]
 ;
   %t1 = fsub reassoc nsz float -1.20e+01, %arg
Index: llvm/test/Transforms/InstCombine/pow-1.ll
===
--- llvm/test/Transforms/InstCombine/pow-1.ll
+++ llvm/test/Transforms/InstCombine/pow-1.ll
@@ -170,7 +170,7 @@
 
 define <2 x float> @test_simplify4vn(<2 x float> %x) {
 ; CHECK-LABEL: @test_simplify4vn(
-; ANY-NEXT:[[MUL:%.*]] = fsub <2 x float> , [[X:%.*]]
+; ANY-NEXT:[[MUL:%.*]] = fneg <2 x float> [[X:%.*]]
 ; ANY-NEXT:[[EXP2:%.*]] = call <2 x float> @llvm.exp2.v2f32(<2 x float> [[MUL]])
 ; ANY-NEXT:ret <2 x float> [[EXP2]]
 ; MSVC-NEXT:   [[POW:%.*]] = call <2 x float> @llvm.pow.v2f32(<2 x float> , <2 x float> [[X:%.*]])
Index: llvm/test/Transforms/InstCombine/minnum.ll
===
--- llvm/test/Transforms/InstCombine/minnum.ll
+++ llvm/test/Transforms/InstCombine/minnum.ll
@@ -247,7 +247,7 @@
 define double @neg_neg(double %x, double %y) {
 ; CHECK-LABEL: @neg_neg(
 ; CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double [[Y:%.*]])
-; CHECK-NEXT:[[R:%.*]] = fsub double -0.00e+00, [[TMP1]]
+; CHECK-NEXT:[[R:%.*]] = fneg double [[TMP1]]
 ; CHECK-NEXT:ret double [[R]]
 ;
   %negx = fsub double -0.0, %x
@@ -259,7 +259,7 @@
 define double @unary_neg_neg(double %x, double %y) {
 ; CHECK-LABEL: @unary_neg_neg(
 ; CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double [[Y:%.*]])
-; CHECK-NEXT:[[R:%.*]] = fsub double -0.00e+00, [[TMP1]]
+; CHECK-NEXT:[[R:%.*]] = fneg double [[TMP1]]
 ; CHECK-NEXT:ret double [[R]]
 ;
   %negx = fneg double %x
@@ -274,7 +274,7 @@
 define <2 x double> @neg_neg_vec_fmf(<2 x

[clang] ddd1127 - Remove BinaryOperator::CreateFNeg

2020-02-27 Thread Simon Moll via cfe-commits

Author: Simon Moll
Date: 2020-02-27T09:06:03-08:00
New Revision: ddd11273d9d0807e25a34181e5978e3307d78dc2

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

LOG: Remove BinaryOperator::CreateFNeg

Use UnaryOperator::CreateFNeg instead.

Summary:
With the introduction of the native fneg instruction, the
fsub -0.0, %x idiom is obsolete. This patch makes LLVM
emit fneg instead of the idiom in all places.

Reviewed By: cameron.mcinally

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

Added: 


Modified: 
clang/test/CodeGen/complex-math.c
llvm/include/llvm/IR/InstrTypes.h
llvm/lib/IR/Instructions.cpp
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/lib/Transforms/Scalar/Reassociate.cpp
llvm/test/Transforms/InstCombine/cos-sin-intrinsic.ll
llvm/test/Transforms/InstCombine/fast-math.ll
llvm/test/Transforms/InstCombine/fmul.ll
llvm/test/Transforms/InstCombine/fneg.ll
llvm/test/Transforms/InstCombine/fpcast.ll
llvm/test/Transforms/InstCombine/fsub.ll
llvm/test/Transforms/InstCombine/maximum.ll
llvm/test/Transforms/InstCombine/maxnum.ll
llvm/test/Transforms/InstCombine/minimum.ll
llvm/test/Transforms/InstCombine/minmax-fp.ll
llvm/test/Transforms/InstCombine/minnum.ll
llvm/test/Transforms/InstCombine/pow-1.ll
llvm/test/Transforms/Reassociate/fast-basictest.ll
llvm/test/Transforms/Reassociate/fp-expr.ll

Removed: 




diff  --git a/clang/test/CodeGen/complex-math.c 
b/clang/test/CodeGen/complex-math.c
index 54dee473a364..6f81ff2ff285 100644
--- a/clang/test/CodeGen/complex-math.c
+++ b/clang/test/CodeGen/complex-math.c
@@ -149,7 +149,7 @@ float _Complex div_float_rc(float a, float _Complex b) {
   // AARCH64-FASTMATH: [[CCpDD:%.*]] = fadd fast float [[CC]], [[DD]]
   //
   // BC = 0
-  // AARCH64-FASTMATH: [[NEGA:%.*]] = fsub fast float -0.00e+00, %a
+  // AARCH64-FASTMATH: [[NEGA:%.*]] = fneg fast float %a
   // AARCH64-FASTMATH: [[AD:%.*]] = fmul fast float  [[D]], [[NEGA]]
   //
   // AARCH64-FASTMATH: fdiv fast float [[AC]], [[CCpDD]]
@@ -327,7 +327,7 @@ double _Complex div_double_rc(double a, double _Complex b) {
   // AARCH64-FASTMATH: [[CCpDD:%.*]] = fadd fast double [[CC]], [[DD]]
   //
   // BC = 0
-  // AARCH64-FASTMATH: [[NEGA:%.*]] = fsub fast double -0.00e+00, %a
+  // AARCH64-FASTMATH: [[NEGA:%.*]] = fneg fast double %a
   // AARCH64-FASTMATH: [[AD:%.*]] = fmul fast double [[D]], [[NEGA]]
   //
   // AARCH64-FASTMATH: fdiv fast double [[AC]], [[CCpDD]]
@@ -523,7 +523,7 @@ long double _Complex div_long_double_rc(long double a, long 
double _Complex b) {
   // AARCH64-FASTMATH: [[CCpDD:%.*]] = fadd fast fp128 [[CC]], [[DD]]
   //
   // BC = 0
-  // AARCH64-FASTMATH: [[NEGA:%.*]] = fsub fast fp128 
0xL8000, %a
+  // AARCH64-FASTMATH: [[NEGA:%.*]] = fneg fast fp128 %a
   // AARCH64-FASTMATH: [[AD:%.*]] = fmul fast fp128 [[D]], [[NEGA]]
   //
   // AARCH64-FASTMATH: fdiv fast fp128 [[AC]], [[CCpDD]]

diff  --git a/llvm/include/llvm/IR/InstrTypes.h 
b/llvm/include/llvm/IR/InstrTypes.h
index 2828a7d0d92d..3c87257b8c02 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -154,18 +154,20 @@ class UnaryOperator : public UnaryInstruction {
   }
 #include "llvm/IR/Instruction.def"
 
-  static UnaryOperator *CreateWithCopiedFlags(UnaryOps Opc,
-  Value *V,
-  Instruction *CopyO,
-  const Twine &Name = "") {
-UnaryOperator *UO = Create(Opc, V, Name);
+  static UnaryOperator *
+  CreateWithCopiedFlags(UnaryOps Opc, Value *V, Instruction *CopyO,
+const Twine &Name = "",
+Instruction *InsertBefore = nullptr) {
+UnaryOperator *UO = Create(Opc, V, Name, InsertBefore);
 UO->copyIRFlags(CopyO);
 return UO;
   }
 
   static UnaryOperator *CreateFNegFMF(Value *Op, Instruction *FMFSource,
-  const Twine &Name = "") {
-return CreateWithCopiedFlags(Instruction::FNeg, Op, FMFSource, Name);
+  const Twine &Name = "",
+  Instruction *InsertBefore = nullptr) {
+return CreateWithCopiedFlags(Instruction::FNeg, Op, FMFSource, Name,
+ InsertBefore);
   }
 
   UnaryOps getOpcode() const {
@@ -280,11 +282,6 @@ class BinaryOperator : public Instruction {
 

[PATCH] D74846: fix -fcodegen-modules code when used with PCH (PR44953)

2020-02-27 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D74846#1895319 , @aganea wrote:

> Thanks @hans! Nevertheless I think this is a good change and we should push 
> it for 11.0. I was indeed seeing better timings on our end with what @llunak 
> was proposing, we are heavy users of PCH headers (and migrating to modules is 
> not trivial in our case, lots of code branching & integrations)


Right, I have no objections against this re-landing on master once the problem 
in PR44953 is understood and fixed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74846



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


[PATCH] D75271: [Analyzer][NFC] Add AnalyzerOptions parameter to shouldRegisterXXX() functions

2020-02-27 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: Szelethus, NoQ.
baloghadamsoftware added a project: clang.
Herald added subscribers: martong, steakhal, phosek, Charusso, gamesh411, 
donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.
Herald added a reviewer: teemperor.

Some checkers may not only depend on language options but also analyzer 
options. To make this possible this patch adds a new parameter to the 
`shouldregisterXXX()` functions with type `const AnalyzerOptions &` to be able 
to query the analyzer options when deciding whether the checker should be 
registered.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75271

Files:
  clang/include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h
  clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp
  clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
  clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp
  clang/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugIteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
  clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  clang/lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/InvalidatedIteratorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCa

[clang] 75d4d4b - Add an attribute registry so plugins can add attributes

2020-02-27 Thread John Brawn via cfe-commits

Author: John Brawn
Date: 2020-02-27T17:23:16Z
New Revision: 75d4d4bd028f6a5f24ef41dbbc45bed65b2305cf

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

LOG: Add an attribute registry so plugins can add attributes

When constructing a ParsedAttr the ParsedAttrInfo gets looked up in the
AttrInfoMap, which is auto-generated using tablegen. If that lookup fails then
we look through the ParsedAttrInfos that plugins have added to the registry and
check if any has a spelling that matches.

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

Added: 


Modified: 
clang/include/clang/Basic/AttributeCommonInfo.h
clang/include/clang/Sema/ParsedAttr.h
clang/lib/Basic/Attributes.cpp
clang/lib/Sema/ParsedAttr.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/AttributeCommonInfo.h 
b/clang/include/clang/Basic/AttributeCommonInfo.h
index 545e7e9a2b47..f4a5db84aa9f 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -134,6 +134,11 @@ class AttributeCommonInfo {
   const IdentifierInfo *getScopeName() const { return ScopeName; }
   SourceLocation getScopeLoc() const { return ScopeLoc; }
 
+  /// Gets the normalized full name, which consists of both scope and name and
+  /// with surrounding underscores removed as appropriate (e.g.
+  /// __gnu__::__attr__ will be normalized to gnu::attr).
+  std::string getNormalizedFullName() const;
+
   bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; }
   bool isMicrosoftAttribute() const { return SyntaxUsed == AS_Microsoft; }
 

diff  --git a/clang/include/clang/Sema/ParsedAttr.h 
b/clang/include/clang/Sema/ParsedAttr.h
index d9d8585970d9..0e0d5cce6d3c 100644
--- a/clang/include/clang/Sema/ParsedAttr.h
+++ b/clang/include/clang/Sema/ParsedAttr.h
@@ -24,6 +24,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/Support/Allocator.h"
+#include "llvm/Support/Registry.h"
 #include "llvm/Support/VersionTuple.h"
 #include 
 #include 
@@ -37,6 +38,72 @@ class Decl;
 class Expr;
 class IdentifierInfo;
 class LangOptions;
+class ParsedAttr;
+class Sema;
+
+struct ParsedAttrInfo {
+  /// Corresponds to the Kind enum.
+  unsigned AttrKind : 16;
+  /// The number of required arguments of this attribute.
+  unsigned NumArgs : 4;
+  /// The number of optional arguments of this attributes.
+  unsigned OptArgs : 4;
+  /// True if the parsing does not match the semantic content.
+  unsigned HasCustomParsing : 1;
+  /// True if this attribute is only available for certain targets.
+  unsigned IsTargetSpecific : 1;
+  /// True if this attribute applies to types.
+  unsigned IsType : 1;
+  /// True if this attribute applies to statements.
+  unsigned IsStmt : 1;
+  /// True if this attribute has any spellings that are known to gcc.
+  unsigned IsKnownToGCC : 1;
+  /// True if this attribute is supported by #pragma clang attribute.
+  unsigned IsSupportedByPragmaAttribute : 1;
+  /// The syntaxes supported by this attribute and how they're spelled.
+  struct Spelling {
+AttributeCommonInfo::Syntax Syntax;
+std::string NormalizedFullName;
+  };
+  std::vector Spellings;
+
+  ParsedAttrInfo(AttributeCommonInfo::Kind AttrKind =
+ AttributeCommonInfo::UnknownAttribute)
+  : AttrKind(AttrKind), NumArgs(0), OptArgs(0), HasCustomParsing(0),
+IsTargetSpecific(0), IsType(0), IsStmt(0), IsKnownToGCC(0),
+IsSupportedByPragmaAttribute(0) {}
+
+  virtual ~ParsedAttrInfo() = default;
+
+  /// Check if this attribute appertains to D, and issue a diagnostic if not.
+  virtual bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr,
+const Decl *D) const {
+return true;
+  }
+  /// Check if this attribute is allowed by the language we are compiling, and
+  /// issue a diagnostic if not.
+  virtual bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const {
+return true;
+  }
+  /// Check if this attribute is allowed when compiling for the given target.
+  virtual bool existsInTarget(const TargetInfo &Target) const {
+return true;
+  }
+  /// Convert the spelling index of Attr to a semantic spelling enum value.
+  virtual unsigned
+  spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const {
+return UINT_MAX;
+  }
+  /// Populate Rules with the match rules of this attribute.
+  virtual void getPragmaAttributeMatchRules(
+  llvm::SmallVectorImpl> &Rules,
+  const LangOptions &LangOpts) const {
+  }
+
+  static const ParsedAttrInfo &get(const AttributeCommonInfo &A);
+};
+
+typedef llvm::Registry ParsedAttrInfoRegistry;
 
 /// Represents information about a change in availability for
 /// an enti

[PATCH] D31342: Add ParsedAttrInfo::handleDeclAttribute

2020-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith.
aaron.ballman added a subscriber: rsmith.
aaron.ballman added a comment.

Adding @rsmith for questions about stability guarantees.




Comment at: clang/docs/ClangPlugins.rst:74
+
+  class ExampleAttrInfo : public ParsedAttrInfo {
+  public:

john.brawn wrote:
> aaron.ballman wrote:
> > We should be documenting the fields of `ParsedAttrInfo` that the user would 
> > be interacting with. We should also consider whether we are introducing a 
> > new stability guarantee with that interface and document accordingly. I 
> > think we should not promise that this structure will be stable from release 
> > to release, but it will be stable within a given release (e.g., the type 
> > can change between Clang 11 -> Clang 12, but the type will not change 
> > between Clang 11 -> Clang 11.0.1).
> I'll add documentation of the relevant fields. As to API stability, looking 
> at Tooling.rst it says only libclang has a stable API (or rather, it says 
> libclang has a stable API, says libtooling doesn't, and says nothing about 
> plugins).
We may want to bump this out into a larger discussion and it shouldn't impact 
the ability to move forward with this patch while we discuss.

I think that for practical purposes we should be guaranteeing ABI stability for 
plugins during a patch releases (10.0 -> 10.0.1) or otherwise patch releases 
become a major compiler upgrade as opposed to an incremental one. I thought 
that we had already promised such stability for things like the AST 
serialization format for similar reasons, but maybe I'm mis-remembering. 
@rsmith -- do you have thoughts?

To be clear about the situation I'm concerned with -- it would be a shame to 
have a working attribute plugin in Clang 10.0 that either fails to load or 
silently behaves differently in Clang 10.0.1 because we generally want 
developers to be able to move to the latest patch release without undue burden.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31342



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


[PATCH] D75271: [Analyzer][NFC] Add AnalyzerOptions parameter to shouldRegisterXXX() functions

2020-02-27 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

I am so sorry to mention, but we need the `AnalysisManager` to pass around 
which manages the analysis, therefore it knows both the `LangOptions` and 
`AnalyzerOptions`. Also this entire callback should be removed ideally: it has 
to be a virtual function defaulting to `return true;` and if someone needs this 
feature could rewrite the behavior. I guess there was some debate whether it 
should be on by default or not, but for a checker writer and future changes 
this patch shows that how weak this API is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75271



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


[PATCH] D31342: Add ParsedAttrInfo::handleDeclAttribute

2020-02-27 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 246987.
john.brawn added a comment.

Update based on review comments.


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

https://reviews.llvm.org/D31342

Files:
  clang/docs/ClangPlugins.rst
  clang/docs/InternalsManual.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3583,6 +3583,20 @@
   OS << "}\n\n";
 }
 
+static void GenerateHandleDeclAttribute(const Record &Attr, raw_ostream &OS) {
+  // Only generate if Attr can be handled simply.
+  if (!Attr.getValueAsBit("SimpleHandler"))
+return;
+
+  // Generate a function which just converts from ParsedAttr to the Attr type.
+  OS << "virtual bool handleDeclAttribute(Sema &S, Decl *D,";
+  OS << "const ParsedAttr &Attr) const {\n";
+  OS << "  D->addAttr(::new (S.Context) " << Attr.getName();
+  OS << "Attr(S.Context, Attr));\n";
+  OS << "  return true;\n";
+  OS << "}\n\n";
+}
+
 static bool IsKnownToGCC(const Record &Attr) {
   // Look at the spellings for this subject; if there are any spellings which
   // claim to be known to GCC, the attribute is known to GCC.
@@ -3664,6 +3678,7 @@
 GenerateTargetRequirements(Attr, Dupes, OS);
 GenerateSpellingIndexToSemanticSpelling(Attr, OS);
 PragmaAttributeSupport.generateStrictConformsTo(*I->second, OS);
+GenerateHandleDeclAttribute(Attr, OS);
 OS << "static const ParsedAttrInfo" << I->first << " Instance;\n";
 OS << "};\n";
 OS << "const ParsedAttrInfo" << I->first << " ParsedAttrInfo" << I->first
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6694,6 +6694,8 @@
 
   switch (AL.getKind()) {
   default:
+if (AL.getInfo().handleDeclAttribute(S, D, AL))
+  break;
 if (!AL.isStmtAttr()) {
   // Type attributes are handled elsewhere; silently move on.
   assert(AL.isTypeAttr() && "Non-type attribute not handled");
@@ -6716,15 +6718,9 @@
 handleSimpleAttributeWithExclusions(S, D, AL);
 break;
-  case ParsedAttr::AT_NoMips16:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_MicroMips:
 handleSimpleAttributeWithExclusions(S, D, AL);
 break;
-  case ParsedAttr::AT_NoMicroMips:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_MipsLongCall:
 handleSimpleAttributeWithExclusions(
 S, D, AL);
@@ -6760,9 +6756,6 @@
   case ParsedAttr::AT_WebAssemblyImportName:
 handleWebAssemblyImportNameAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_IBAction:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_IBOutlet:
 handleIBOutlet(S, D, AL);
 break;
@@ -6787,9 +6780,6 @@
   case ParsedAttr::AT_AlwaysInline:
 handleAlwaysInlineAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_Artificial:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_AnalyzerNoReturn:
 handleAnalyzerNoReturnAttr(S, D, AL);
 break;
@@ -6821,9 +6811,6 @@
   case ParsedAttr::AT_Constructor:
 handleConstructorAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_CXX11NoReturn:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_Deprecated:
 handleDeprecatedAttr(S, D, AL);
 break;
@@ -6851,15 +6838,9 @@
   case ParsedAttr::AT_OptimizeNone:
 handleOptimizeNoneAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_FlagEnum:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_EnumExtensibility:
 handleEnumExtensibilityAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_Flatten:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_SYCLKernel:
 handleSYCLKernelAttr(S, D, AL);
 break;
@@ -6895,27 +6876,9 @@
   case ParsedAttr::AT_Restrict:
 handleRestrictAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_LifetimeBound:
-handleSimpleAttribute(S, D, AL);
-break;
-  case ParsedAttr::AT_MayAlias:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_Mode:
 handleModeAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_NoAlias:
-handleSimpleAttribute(S, D, AL);
-break;
-  case ParsedAttr::AT_NoCommon:
-handleSimpleAttribute(S, D, AL);
-break;
-  case ParsedAttr::AT_NoSplitStack:
-handleSimpleAttribute(S, D, AL);
-break;
-  case ParsedAttr::AT_NoUniqueAddress:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_NonNull:
 if (auto *PVD = dyn_cast(D))
   handleNonNullAttrParameter(S, PVD, AL);
@@ -6934,9 +6897,6 @@
   case ParsedAttr::AT_AllocAlign:
 handleAllocAlignAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_O

[PATCH] D69591: Devirtualize a call on alloca without waiting for post inline cleanup and next DevirtSCCRepeatedPass iteration.

2020-02-27 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

This was reverted due to some internal compilation crashes as 
https://github.com/llvm/llvm-project/commit/4569b3a86f8a4b1b8ad28fe2321f936f9d7ffd43


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69591



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


[PATCH] D75271: [Analyzer][NFC] Add AnalyzerOptions parameter to shouldRegisterXXX() functions

2020-02-27 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

PS: The `CheckerManager` also could serve this behavior as `registerXXX()` 
already passing around that manager, but I believe the `AnalysisManager` 
supposed to manage the analysis.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75271



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


[PATCH] D66564: [clang-tidy] new altera struct pack align check

2020-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Are you aware of plans that you or others have for adding additional checks to 
the new `altera` module?


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

https://reviews.llvm.org/D66564



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


[PATCH] D31343: Add an attribute plugin example

2020-02-27 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 246989.
john.brawn marked an inline comment as done.
john.brawn added a comment.

Update based on review comments.


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

https://reviews.llvm.org/D31343

Files:
  clang/examples/Attribute/Attribute.cpp
  clang/examples/Attribute/CMakeLists.txt
  clang/examples/CMakeLists.txt
  clang/test/CMakeLists.txt
  clang/test/Frontend/plugin-attribute.cpp

Index: clang/test/Frontend/plugin-attribute.cpp
===
--- /dev/null
+++ clang/test/Frontend/plugin-attribute.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -S %s -o - 2>&1 | FileCheck %s --check-prefix=ATTRIBUTE
+// RUN: not %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -DBAD_ATTRIBUTE -S %s -o - 2>&1 | FileCheck %s --check-prefix=BADATTRIBUTE
+// REQUIRES: plugins, examples
+
+void fn1a() __attribute__((example)) { }
+[[example]] void fn1b() { }
+[[plugin::example]] void fn1c() { }
+void fn2() __attribute__((example("somestring"))) { }
+// ATTRIBUTE: warning: 'example' attribute only applies to functions
+int var1 __attribute__((example("otherstring"))) = 1;
+
+// ATTRIBUTE: [[STR1_VAR:@.+]] = private unnamed_addr constant [10 x i8] c"example()\00"
+// ATTRIBUTE: [[STR2_VAR:@.+]] = private unnamed_addr constant [20 x i8] c"example(somestring)\00"
+// ATTRIBUTE: @llvm.global.annotations = {{.*}}@{{.*}}fn1a{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1b{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1c{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn2{{.*}}[[STR2_VAR]]
+
+#ifdef BAD_ATTRIBUTE
+class Example {
+  // BADATTRIBUTE: error: 'example' attribute only allowed at file scope
+  void __attribute__((example)) fn3();
+};
+// BADATTRIBUTE: error: 'example' attribute requires a string
+void fn4() __attribute__((example(123))) { }
+// BADATTRIBUTE: error: 'example' attribute takes no more than 1 argument
+void fn5() __attribute__((example("a","b"))) { }
+#endif
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -72,6 +72,7 @@
 
 if (CLANG_BUILD_EXAMPLES)
   list(APPEND CLANG_TEST_DEPS
+Attribute
 AnnotateFunctions
 clang-interpreter
 PrintFunctionNames
Index: clang/examples/CMakeLists.txt
===
--- clang/examples/CMakeLists.txt
+++ clang/examples/CMakeLists.txt
@@ -6,3 +6,4 @@
 add_subdirectory(clang-interpreter)
 add_subdirectory(PrintFunctionNames)
 add_subdirectory(AnnotateFunctions)
+add_subdirectory(Attribute)
Index: clang/examples/Attribute/CMakeLists.txt
===
--- /dev/null
+++ clang/examples/Attribute/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  target_link_libraries(AnnotateFunctions ${cmake_2_8_12_PRIVATE}
+clangAST
+clangBasic
+clangFrontend
+clangLex
+LLVMSupport
+)
+endif()
Index: clang/examples/Attribute/Attribute.cpp
===
--- /dev/null
+++ clang/examples/Attribute/Attribute.cpp
@@ -0,0 +1,81 @@
+//===- Attribute.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Example clang plugin which adds an an annotation to file-scope declarations
+// with the 'example' attribute.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Attr.h"
+#include "clang/Sema/ParsedAttr.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/SemaDiagnostic.h"
+#include "llvm/IR/Attributes.h"
+using namespace clang;
+
+namespace {
+
+struct ExampleAttrInfo : public ParsedAttrInfo {
+  ExampleAttrInfo() {
+// Set the kind to NoSemaHandlerAttribute to make sure clang doesn't assume
+// anything about what it does.
+AttrKind = ParsedAttr::NoSemaHandlerAttribute;
+// Can take an optional string argument (the check that the argument
+// actually is a string happens in handleDeclAttribute).
+OptArgs = 1;
+// GNU-style __attribute__(("example")) and C++-style [[example]] and
+// [[plugin::example]] supported.
+Spellings.push_back({ParsedAttr::AS_GNU, "example"});
+Spellings.push_back({ParsedAttr::AS_CXX11, "::example"});
+Spellings.push_back({ParsedAttr::AS_CXX11, "plugin::example"});
+  }
+
+  virtual bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr,
+const Decl *D) const {
+//

[PATCH] D75171: [Analyzer] Fix for incorrect use of container and iterator checkers

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

In D75171#1893811 , @Szelethus wrote:

> Im sorry, i though we talked about internal code and we're stuck with the 
> checker interface -- this should definitely be solved by changing the 
> parameter of the `shouldRegister` function to `CheckerManager`. If you want 
> to emit errors for incorrect file, there is an example in 
> `UninitializedObjectChecker` and maybe in `GenericTaintChecker`.


Sorry, but it does not work. It is impossible to use `CheckerManager` as 
parameter for `shouldRegisterXXX()` because `CheckerRegistry` does not have it. 
If I add `CheckerManager` to `CheckerRegistry` then the `printXXX()` functions 
will not work because they do not have `CheckerManager` at all.  I tried to add 
`AnalyzerOptions` as a second parameter (see D75271 
), but it does not help in printing error 
message. I need a way to solve 44998 
 by rejecting the checker if the 
option is disabled **and** printing an error message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75171



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


[PATCH] D31343: Add an attribute plugin example

2020-02-27 Thread John Brawn via Phabricator via cfe-commits
john.brawn marked 5 inline comments as done.
john.brawn added inline comments.



Comment at: clang/examples/Attribute/Attribute.cpp:25
+struct ExampleAttrInfo : public ParsedAttrInfo {
+  ExampleAttrInfo() {
+// Set the kind to NoSemaHandlerAttribute to make sure clang doesn't assume

aaron.ballman wrote:
> It would be really handy for the example to show how to list subjects for the 
> declaration attribute, as that's a very common need.
This is done via diagAppertainsToDecl.



Comment at: clang/examples/Attribute/Attribute.cpp:35
+  }
+  virtual bool handleDeclAttribute(Sema &S, Decl *D,
+   const ParsedAttr &Attr) const {

aaron.ballman wrote:
> It is unclear to me how a user would add an attribute that needs to follow 
> the merge pattern we use in `mergeDeclAttribute()`.
I'm guessing it's probably not possible, from a quick look at 
mergeDeclAttribute.



Comment at: clang/examples/Attribute/Attribute.cpp:53
+  } else {
+S.Diag(ArgExpr->getExprLoc(), diag::err_attribute_argument_type)
+<< Attr.getAttrName() << AANT_ArgumentString;

aaron.ballman wrote:
> Do we have a way for plugin authors to introduce their own diagnostics, or 
> are they limited to just what diagnostics we already provide?
Custom diagnostics can be done with getCustomDiagID, and there's an example on 
line 54.


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

https://reviews.llvm.org/D31343



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


[PATCH] D75176: [clangd] Get rid of getBeginningOfIdentifier helper

2020-02-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
kadircet marked 2 inline comments as done.
Closed by commit rG2bb7774ddf00: [clangd] Get rid of getBeginningOfIdentifier 
helper (authored by kadircet).

Changed prior to commit:
  https://reviews.llvm.org/D75176?vs=246729&id=246994#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75176

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -312,60 +312,6 @@
   }
 }
 
-TEST(SourceCodeTests, GetBeginningOfIdentifier) {
-  std::string Preamble = R"cpp(
-struct Bar { int func(); };
-#define MACRO(X) void f() { X; }
-Bar* bar;
-  )cpp";
-  // First ^ is the expected beginning, last is the search position.
-  for (const std::string &Text : std::vector{
-   "int ^f^oo();", // inside identifier
-   "int ^foo();",  // beginning of identifier
-   "int ^foo^();", // end of identifier
-   "int foo(^);",  // non-identifier
-   "^int foo();",  // beginning of file (can't back up)
-   "int ^f0^0();", // after a digit (lexing at N-1 is wrong)
-   "/^/ comments", // non-interesting token
-   "void f(int abc) { abc ^ ++; }",// whitespace
-   "void f(int abc) { ^abc^++; }", // range of identifier
-   "void f(int abc) { ++^abc^; }", // range of identifier
-   "void f(int abc) { ++^abc; }",  // range of identifier
-   "void f(int abc) { ^+^+abc; }", // range of operator
-   "void f(int abc) { ^abc^ ++; }",// range of identifier
-   "void f(int abc) { abc ^++^; }",// range of operator
-   "void f(int abc) { ^++^ abc; }",// range of operator
-   "void f(int abc) { ++ ^abc^; }",// range of identifier
-   "void f(int abc) { ^++^/**/abc; }", // range of operator
-   "void f(int abc) { ++/**/^abc; }",  // range of identifier
-   "void f(int abc) { ^abc^/**/++; }", // range of identifier
-   "void f(int abc) { abc/**/^++; }",  // range of operator
-   "void f() {^ }", // outside of identifier and operator
-   "int ^λλ^λ();",  // UTF-8 handled properly when backing up
-
-   // identifier in macro arg
-   "MACRO(bar->^func())",  // beginning of identifier
-   "MACRO(bar->^fun^c())", // inside identifier
-   "MACRO(bar->^func^())", // end of identifier
-   "MACRO(^bar->func())",  // begin identifier
-   "MACRO(^bar^->func())", // end identifier
-   "^MACRO(bar->func())",  // beginning of macro name
-   "^MAC^RO(bar->func())", // inside macro name
-   "^MACRO^(bar->func())", // end of macro name
-   }) {
-std::string WithPreamble = Preamble + Text;
-Annotations TestCase(WithPreamble);
-auto AST = TestTU::withCode(TestCase.code()).build();
-const auto &SourceMgr = AST.getSourceManager();
-SourceLocation Actual = getBeginningOfIdentifier(
-TestCase.points().back(), SourceMgr, AST.getLangOpts());
-Position ActualPos = offsetToPosition(
-TestCase.code(),
-SourceMgr.getFileOffset(SourceMgr.getSpellingLoc(Actual)));
-EXPECT_EQ(TestCase.points().front(), ActualPos) << Text;
-  }
-}
-
 TEST(SourceCodeTests, CollectIdentifiers) {
   auto Style = format::getLLVMStyle();
   auto IDs = collectIdentifiers(R"cpp(
@@ -481,9 +427,11 @@
)cpp");
   TestTU TU = TestTU::withCode(Code.code());
   auto AST = TU.build();
-  auto Loc = getBeginningOfIdentifier(Code.point(), AST.getSourceManager(),
-  AST.getLangOpts());
-  auto Result = locateMacroAt(Loc, AST.getPreprocessor());
+  auto CurLoc = sourceLocationInMainFile(AST.getSourceManager(), Code.point());
+  ASSERT_TRUE(bool(CurLoc));
+  const auto *Id = syntax::spelledIdentifierTouching(*CurLoc, AST.getTokens());
+  ASSERT_TRUE(Id);
+  auto Result = locateMacroAt(Id->location(), AST.getPreprocessor());
   ASSERT_TRUE(Result);
   EXPECT_THAT(*Result, MacroName("MACRO"));
 }
Index: clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
===
--- clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
+++ clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
@@ -87,9 +87,9 @@
   if (ExpectedRefs.empty())
 break;
 
-  auto Loc = getBeginningOfIdentifier(ExpectedRefs.begin()->start, SM,
-  AST.getLangOpts());
-  auto Ma

[PATCH] D75271: [Analyzer][NFC] Add AnalyzerOptions parameter to shouldRegisterXXX() functions

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

It is impossible to use `CheckerManager` as parameter for `shouldRegisterXXX()` 
because `CheckerRegistry` does not have it. If I add `CheckerManager` to 
`CheckerRegistry` then the `printXXX()` functions will not work because they do 
not have `CheckerManager` at all. This patch does not help in printing error 
message, see D75171 . I need a way to solve 
44998  by rejecting the checker if 
the option is disabled **and** printing an error message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75271



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


[PATCH] D75193: [clangd] Get rid of lexer usage in AST.cpp

2020-02-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf31fc1043d38: [clangd] Get rid of lexer usage in AST.cpp 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75193

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h


Index: clang-tools-extra/clangd/AST.h
===
--- clang-tools-extra/clangd/AST.h
+++ clang-tools-extra/clangd/AST.h
@@ -109,7 +109,6 @@
 QualType declaredType(const TypeDecl *D);
 
 /// Retrieves the deduced type at a given location (auto, decltype).
-/// Retuns None unless Loc starts an auto/decltype token.
 /// It will return the underlying type.
 llvm::Optional getDeducedType(ASTContext &, SourceLocation Loc);
 
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -25,7 +25,6 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Index/USRGeneration.h"
-#include "clang/Lex/Lexer.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
@@ -417,16 +416,8 @@
 
 llvm::Optional getDeducedType(ASTContext &ASTCtx,
 SourceLocation Loc) {
-  Token Tok;
-  // Only try to find a deduced type if the token is auto or decltype.
-  if (!Loc.isValid() ||
-  Lexer::getRawToken(Loc, Tok, ASTCtx.getSourceManager(),
- ASTCtx.getLangOpts(), false) ||
-  !Tok.is(tok::raw_identifier) ||
-  !(Tok.getRawIdentifier() == "auto" ||
-Tok.getRawIdentifier() == "decltype")) {
+  if (!Loc.isValid())
 return {};
-  }
   DeducedTypeVisitor V(Loc);
   V.TraverseAST(ASTCtx);
   if (V.DeducedType.isNull())


Index: clang-tools-extra/clangd/AST.h
===
--- clang-tools-extra/clangd/AST.h
+++ clang-tools-extra/clangd/AST.h
@@ -109,7 +109,6 @@
 QualType declaredType(const TypeDecl *D);
 
 /// Retrieves the deduced type at a given location (auto, decltype).
-/// Retuns None unless Loc starts an auto/decltype token.
 /// It will return the underlying type.
 llvm::Optional getDeducedType(ASTContext &, SourceLocation Loc);
 
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -25,7 +25,6 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Index/USRGeneration.h"
-#include "clang/Lex/Lexer.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
@@ -417,16 +416,8 @@
 
 llvm::Optional getDeducedType(ASTContext &ASTCtx,
 SourceLocation Loc) {
-  Token Tok;
-  // Only try to find a deduced type if the token is auto or decltype.
-  if (!Loc.isValid() ||
-  Lexer::getRawToken(Loc, Tok, ASTCtx.getSourceManager(),
- ASTCtx.getLangOpts(), false) ||
-  !Tok.is(tok::raw_identifier) ||
-  !(Tok.getRawIdentifier() == "auto" ||
-Tok.getRawIdentifier() == "decltype")) {
+  if (!Loc.isValid())
 return {};
-  }
   DeducedTypeVisitor V(Loc);
   V.TraverseAST(ASTCtx);
   if (V.DeducedType.isNull())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75182: [clang-format] Handle commas in [] in C#

2020-02-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG548e540d2ced: [clang-format] Handle commas in [] in C# 
(authored by Jonathan Coe ).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75182

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


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -595,6 +595,10 @@
   verifyFormat(R"(bool[] xs = { true, true };)", Style);
   verifyFormat(R"(taskContext.Factory.Run(async () => doThing(args);)", Style);
   verifyFormat(R"(catch (TestException) when (innerFinallyExecuted))", Style);
+  verifyFormat(R"(private float[,] Values;)", Style);
+
+  Style.SpacesInSquareBrackets = true;
+  verifyFormat(R"(private float[, ] Values;)", Style);
 }
 
 } // namespace format
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2893,6 +2893,10 @@
 if (Left.is(TT_TemplateCloser) && Right.is(TT_StartOfName))
   return true;
 
+// space after comma in '[,]'.
+if (Left.is(tok::comma) && Right.is(tok::r_square))
+  return Style.SpacesInSquareBrackets;
+
 // space between keywords and paren e.g. "using ("
 if (Right.is(tok::l_paren))
   if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when))


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -595,6 +595,10 @@
   verifyFormat(R"(bool[] xs = { true, true };)", Style);
   verifyFormat(R"(taskContext.Factory.Run(async () => doThing(args);)", Style);
   verifyFormat(R"(catch (TestException) when (innerFinallyExecuted))", Style);
+  verifyFormat(R"(private float[,] Values;)", Style);
+
+  Style.SpacesInSquareBrackets = true;
+  verifyFormat(R"(private float[, ] Values;)", Style);
 }
 
 } // namespace format
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2893,6 +2893,10 @@
 if (Left.is(TT_TemplateCloser) && Right.is(TT_StartOfName))
   return true;
 
+// space after comma in '[,]'.
+if (Left.is(tok::comma) && Right.is(tok::r_square))
+  return Style.SpacesInSquareBrackets;
+
 // space between keywords and paren e.g. "using ("
 if (Right.is(tok::l_paren))
   if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66564: [clang-tidy] new altera struct pack align check

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

In D66564#1895916 , @aaron.ballman 
wrote:

> Are you aware of plans that you or others have for adding additional checks 
> to the new `altera` module?


There are several patches for `altera` module already.


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

https://reviews.llvm.org/D66564



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


[PATCH] D74784: [driver][darwin] Don't use -platform_version flag by default

2020-02-27 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5122e828701c: [driver][darwin] Don't use 
-platform_version flag by default (PR44813) (authored by hans).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74784

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-ld-platform-version-ios.c
  clang/test/Driver/darwin-ld-platform-version-macos.c
  clang/test/Driver/darwin-ld-platform-version-tvos.c
  clang/test/Driver/darwin-ld-platform-version-watchos.c


Index: clang/test/Driver/darwin-ld-platform-version-watchos.c
===
--- clang/test/Driver/darwin-ld-platform-version-watchos.c
+++ clang/test/Driver/darwin-ld-platform-version-watchos.c
@@ -1,9 +1,14 @@
 // RUN: touch %t.o
 
+// RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot 
%S/Inputs/WatchOS6.0.sdk -mlinker-version=0 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
+// RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot 
%S/Inputs/WatchOS6.0.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot 
%S/Inputs/WatchOS6.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
-// RUN:   | FileCheck %s
+// RUN:   | FileCheck --check-prefix=LINKER-NEW %s
 // RUN: %clang -target x86_64-apple-watchos6-simulator -isysroot 
%S/Inputs/WatchOS6.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=SIMUL %s
 
-// CHECK: "-platform_version" "watchos" "5.2.0" "6.0.0"
+// LINKER-OLD: "-watchos_version_min" "5.2.0"
+// LINKER-NEW: "-platform_version" "watchos" "5.2.0" "6.0.0"
 // SIMUL: "-platform_version" "watchos-simulator" "6.0.0" "6.0.0"
Index: clang/test/Driver/darwin-ld-platform-version-tvos.c
===
--- clang/test/Driver/darwin-ld-platform-version-tvos.c
+++ clang/test/Driver/darwin-ld-platform-version-tvos.c
@@ -1,9 +1,14 @@
 // RUN: touch %t.o
 
+// RUN: %clang -target arm64-apple-tvos12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
+// RUN: %clang -target arm64-apple-tvos12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: %clang -target arm64-apple-tvos12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
-// RUN:   | FileCheck %s
+// RUN:   | FileCheck --check-prefix=LINKER-NEW %s
 // RUN: %clang -target x86_64-apple-tvos13-simulator -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=SIMUL %s
 
-// CHECK: "-platform_version" "tvos" "12.3.0" "13.0"
+// LINKER-OLD: "-tvos_version_min" "12.3.0"
+// LINKER-NEW: "-platform_version" "tvos" "12.3.0" "13.0"
 // SIMUL: "-platform_version" "tvos-simulator" "13.0.0" "13.0"
Index: clang/test/Driver/darwin-ld-platform-version-macos.c
===
--- clang/test/Driver/darwin-ld-platform-version-macos.c
+++ clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -1,11 +1,14 @@
 // RUN: touch %t.o
 
 // RUN: %clang -target x86_64-apple-macos10.13 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=0 -### %t.o 2>&1 \
-// RUN:   | FileCheck %s
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
+// RUN: %clang -target x86_64-apple-macos10.13 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: env SDKROOT=%S/Inputs/MacOSX10.14.sdk %clang -target 
x86_64-apple-macos10.13.0.1 -mlinker-version=520 -### %t.o 2>&1 \
-// RUN:   | FileCheck %s
+// RUN:   | FileCheck --check-prefix=LINKER-NEW %s
 
-// CHECK: "-platform_version" "macos" "10.13.0" "10.14"
+// LINKER-OLD: "-macosx_version_min" "10.13.0"
+// LINKER-NEW: "-platform_version" "macos" "10.13.0" "10.14"
 
 // RUN: %clang -target x86_64-apple-macos10.13  -mlinker-version=520 -### %t.o 
2>&1 \
 // RUN:   | FileCheck --check-prefix=NOSDK %s
Index: clang/test/Driver/darwin-ld-platform-version-ios.c
===
--- clang/test/Driver/darwin-ld-platform-version-ios.c
+++ clang/test/Driver/darwin-ld-platform-version-ios.c
@@ -1,9 +1,14 @@
 // RUN: touch %t.o
 
+// RUN: %clang -target arm64-apple-ios12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
+// RUN: %clang -target arm64-apple-ios12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: %clang -target arm64-apple-ios12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
-// RUN:   | 

[PATCH] D75244: [clang-format] Recognize C# named argument colons as a token type

2020-02-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7dfe0cc7f576: [clang-format] Recognize C# named argument 
colons as a token type (authored by Jonathan Coe ).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75244

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

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -546,6 +546,8 @@
 PrintOrderDetails(orderNum: 31, productName: "Red Mug",  // comment
   sellerName: "Gift Shop");)",
Style);
+
+  verifyFormat(R"(foreach (var tickCount in task.Begin(seed: 0)) {)", Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpPropertyAccessors) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -776,6 +776,11 @@
   Tok->Type = TT_JsTypeColon;
   break;
 }
+  } else if (Style.isCSharp()) {
+if (Contexts.back().ContextKind == tok::l_paren) {
+  Tok->Type = TT_CSharpNamedArgumentColon;
+  break;
+}
   }
   if (Contexts.back().ColonIsDictLiteral ||
   Style.Language == FormatStyle::LK_Proto ||
@@ -3052,6 +3057,8 @@
   return Style.SpacesInContainerLiterals;
 if (Right.is(TT_AttributeColon))
   return false;
+if (Right.is(TT_CSharpNamedArgumentColon))
+  return false;
 return true;
   }
   if (Left.is(TT_UnaryOperator)) {
@@ -3200,7 +3207,11 @@
   if (Right.NewlinesBefore > 1 && Style.MaxEmptyLinesToKeep > 0)
 return true;
 
-  if (Style.Language == FormatStyle::LK_JavaScript) {
+  if (Style.isCSharp()) {
+if (Right.is(TT_CSharpNamedArgumentColon) ||
+Left.is(TT_CSharpNamedArgumentColon))
+  return false;
+  } else if (Style.Language == FormatStyle::LK_JavaScript) {
 // FIXME: This might apply to other languages and token kinds.
 if (Right.is(tok::string_literal) && Left.is(tok::plus) && Left.Previous &&
 Left.Previous->is(tok::string_literal))
@@ -3485,9 +3496,12 @@
 bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
 const FormatToken &Right) {
   const FormatToken &Left = *Right.Previous;
-
   // Language-specific stuff.
-  if (Style.Language == FormatStyle::LK_Java) {
+  if (Style.isCSharp()) {
+if (Left.is(TT_CSharpNamedArgumentColon) ||
+Right.is(TT_CSharpNamedArgumentColon))
+  return false;
+  } else if (Style.Language == FormatStyle::LK_Java) {
 if (Left.isOneOf(Keywords.kw_throws, Keywords.kw_extends,
  Keywords.kw_implements))
   return false;
Index: clang/lib/Format/FormatTokenLexer.h
===
--- clang/lib/Format/FormatTokenLexer.h
+++ clang/lib/Format/FormatTokenLexer.h
@@ -56,7 +56,6 @@
   bool tryMergeCSharpDoubleQuestion();
   bool tryTransformCSharpForEach();
   bool tryMergeCSharpAttributeAndTarget();
-  bool tryMergeCSharpNamedArgument();
 
   bool tryMergeTokens(ArrayRef Kinds, TokenType NewType);
 
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -76,8 +76,6 @@
 return;
 
   if (Style.isCSharp()) {
-if (tryMergeCSharpNamedArgument())
-  return;
 if (tryMergeCSharpAttributeAndTarget())
   return;
 if (tryMergeCSharpKeywordVariables())
@@ -186,39 +184,6 @@
   return true;
 }
 
-// Merge 'argName' and ':' into a single token in `foo(argName: bar)`.
-bool FormatTokenLexer::tryMergeCSharpNamedArgument() {
-  if (Tokens.size() < 2)
-return false;
-  auto &Colon = *(Tokens.end() - 1);
-  if (!Colon->is(tok::colon))
-return false;
-
-  auto &Name = *(Tokens.end() - 2);
-  if (!Name->is(tok::identifier))
-return false;
-
-  const FormatToken *CommaOrLeftParen = nullptr;
-  for (auto I = Tokens.rbegin() + 2, E = Tokens.rend(); I != E; ++I) {
-// NB: Because previous pointers are not initialized yet, this cannot use
-// Token.getPreviousNonComment.
-if ((*I)->isNot(tok::comment)) {
-  CommaOrLeftParen = *I;
-  break;
-}
-  }
-
-  if (!CommaOrLeftParen || !CommaOrLeftParen->isOneOf(tok::l_paren, tok::comma))
-return false;
-
-  Name->TokenText = StringRef(Name->TokenText.begin(),
-  Colon->TokenText.end() - Name->TokenText.begin());
-  Name->ColumnWidth += Colon->ColumnWidth;
-  Name->Type = TT_CSharpNamedArgument;
-  To

[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-02-27 Thread Alexey Bader via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbd97704e: [SYCL] Driver option to select SYCL version 
(authored by Ruyk, committed by bader).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Driver/sycl.c
  clang/test/Frontend/sycl-aux-triple.cpp
  clang/test/Preprocessor/sycl-macro.cpp
  clang/test/SemaSYCL/kernel-attribute.cpp

Index: clang/test/SemaSYCL/kernel-attribute.cpp
===
--- clang/test/SemaSYCL/kernel-attribute.cpp
+++ clang/test/SemaSYCL/kernel-attribute.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl -fsycl-is-device -verify %s
 
 // Only function templates
 [[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
Index: clang/test/Preprocessor/sycl-macro.cpp
===
--- clang/test/Preprocessor/sycl-macro.cpp
+++ clang/test/Preprocessor/sycl-macro.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 %s -E -dM | FileCheck %s
-// RUN: %clang_cc1 %s -fsycl-is-device -E -dM | FileCheck --check-prefix=CHECK-SYCL %s
+// RUN: %clang_cc1 %s -fsycl -sycl-std=2017 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
+// RUN: %clang_cc1 %s -fsycl -fsycl-is-device -sycl-std=1.2.1 -E -dM | FileCheck --check-prefix=CHECK-SYCL-STD %s
+// RUN: %clang_cc1 %s -fsycl -fsycl-is-device -E -dM | FileCheck --check-prefixes=CHECK-SYCL %s
 
 // CHECK-NOT:#define __SYCL_DEVICE_ONLY__ 1
+// CHECK-NOT:#define CL_SYCL_LANGUAGE_VERSION 121
+// CHECK-SYCL-STD:#define CL_SYCL_LANGUAGE_VERSION 121
 // CHECK-SYCL:#define __SYCL_DEVICE_ONLY__ 1
Index: clang/test/Frontend/sycl-aux-triple.cpp
===
--- clang/test/Frontend/sycl-aux-triple.cpp
+++ clang/test/Frontend/sycl-aux-triple.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -triple spir -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck %s
-// RUN: %clang_cc1 %s -fsycl-is-device -triple spir -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck --check-prefix=CHECK-SYCL %s
+// RUN: %clang_cc1 %s -fsycl -fsycl-is-device -triple spir -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck --check-prefix=CHECK-SYCL %s
 
 // CHECK-NOT:#define __x86_64__ 1
 // CHECK-SYCL:#define __x86_64__ 1
Index: clang/test/Driver/sycl.c
===
--- clang/test/Driver/sycl.c
+++ clang/test/Driver/sycl.c
@@ -1,10 +1,20 @@
 // RUN: %clang -### -fsycl -c %s 2>&1 | FileCheck %s --check-prefix=ENABLED
 // RUN: %clang -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -fsycl -sycl-std=1.2.1 %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -fsycl -sycl-std=121 %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -fsycl -sycl-std=2017 %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -fsycl -sycl-std=sycl-1.2.1 %s 2>&1 | FileCheck %s --check-prefix=ENABLED
 // RUN: %clang -### -fno-sycl -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang -### -sycl-std=2017 %s 2>&1 | FileCheck %s --check-prefix=DISABLED
 // RUN: %clangxx -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED
 // RUN: %clangxx -### -fno-sycl %s 2>&1 | FileCheck %s --check-prefix=DISABLED
 // RUN: %clangxx -### -fsycl -fno-sycl %s 2>&1 | FileCheck %s --check-prefix=DISABLED
 // RUN: %clangxx -### %s 2>&1 | FileCheck %s --check-prefix=DISABLED
+// RUN: %clang_cl -### -fsycl -sycl-std=2017 %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang_cl -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED
+// RUN: %clang_cl -### %s 2>&1 | FileCheck %s --check-prefix=DISABLED
 
 // ENABLED: "-cc1"{{.*}} "-fsycl-is-device"
+// ENABLED-SAME: "-sycl-std={{[-.sycl0-9]+}}"
 // DISABLED-NOT: "-fsycl-is-device"
+// DISABLED-NOT: "-sycl-std="
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -460,6 +460,13 @@
 if (LangOpts.FastRelaxedMath)
   Builder.defineMacro("__FAST_RELAXED_MATH__");
   }
+
+  if (LangOpts.SYCL) {
+// SYCL Version is set to a value when building SYCL applications
+if (LangOpts.SYCLVersion == 2017)
+  Builder.defineMacro("CL_SYCL_LANGUAGE_VERSION", "121");
+  }
+
   // Not "standard" per se, but available even with the -undef flag.
   if (LangOpts.AsmPreprocessor)
 Builder.defineMacro("__ASSEMBLER__");
Inde

[PATCH] D70700: [WebAssembly] Mangle the argc/argv `main` as `__main_argc_argv`

2020-02-27 Thread sunfishcode via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG00072c08c750: [WebAssembly] Mangle the argc/argv `main` as 
`__wasm_argc_argv`. (authored by sunfishcode).

Changed prior to commit:
  https://reviews.llvm.org/D70700?vs=234942&id=247011#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70700

Files:
  clang/lib/AST/Mangle.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Frontend/InitHeaderSearch.cpp
  clang/test/CodeGen/wasm-call-main.c
  clang/test/CodeGen/wasm-main.c
  clang/test/CodeGen/wasm-main_argc_argv.c

Index: clang/test/CodeGen/wasm-main_argc_argv.c
===
--- /dev/null
+++ clang/test/CodeGen/wasm-main_argc_argv.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple wasm32 -o - -emit-llvm %s | FileCheck %s
+
+// Mangle the argc/argv form of main.
+
+int main(int argc, char **argv) {
+  return 0;
+}
+
+// CHECK-LABEL: define i32 @__main_argc_argv(i32 %argc, i8** %argv)
Index: clang/test/CodeGen/wasm-main.c
===
--- /dev/null
+++ clang/test/CodeGen/wasm-main.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple wasm32 -o - -emit-llvm %s | FileCheck %s
+
+// Don't mangle the no-arg form of main.
+
+int main(void) {
+  return 0;
+}
+
+// CHECK-LABEL: define i32 @main()
Index: clang/test/CodeGen/wasm-call-main.c
===
--- /dev/null
+++ clang/test/CodeGen/wasm-call-main.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple wasm32 -o - -emit-llvm %s | FileCheck %s
+
+// Mangle argc/argv main even when it's not defined in this TU.
+
+#include 
+
+int main(int argc, char *argv[]);
+
+int foo(void) {
+return main(0, NULL);
+}
+
+// CHECK: call i32 @__main_argc_argv(
Index: clang/lib/Frontend/InitHeaderSearch.cpp
===
--- clang/lib/Frontend/InitHeaderSearch.cpp
+++ clang/lib/Frontend/InitHeaderSearch.cpp
@@ -433,8 +433,7 @@
 break;
 
   case llvm::Triple::UnknownOS:
-if (triple.getArch() == llvm::Triple::wasm32 ||
-triple.getArch() == llvm::Triple::wasm64)
+if (triple.isWasm())
   return;
 break;
   }
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1023,6 +1023,9 @@
   /// for the uninstrumented functions.
   void EmitDeferredUnusedCoverageMappings();
 
+  /// Emit an alias for "main" if it has no arguments (needed for wasm).
+  void EmitMainVoidAlias();
+
   /// Tell the consumer that this variable has been instantiated.
   void HandleCXXStaticMemberVarInstantiation(VarDecl *VD);
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -448,6 +448,10 @@
 CodeGenFunction(*this).EmitCfiCheckStub();
   }
   emitAtAvailableLinkGuard();
+  if (Context.getTargetInfo().getTriple().isWasm() &&
+  !Context.getTargetInfo().getTriple().isOSEmscripten()) {
+EmitMainVoidAlias();
+  }
   emitLLVMUsed();
   if (SanStats)
 SanStats->finish();
@@ -5600,6 +5604,17 @@
   }
 }
 
+void CodeGenModule::EmitMainVoidAlias() {
+  // In order to transition away from "__original_main" gracefully, emit an
+  // alias for "main" in the no-argument case so that libc can detect when
+  // new-style no-argument main is in used.
+  if (llvm::Function *F = getModule().getFunction("main")) {
+if (!F->isDeclaration() && F->arg_size() == 0 && !F->isVarArg() &&
+F->getReturnType()->isIntegerTy(Context.getTargetInfo().getIntWidth()))
+  addUsedGlobal(llvm::GlobalAlias::create("__main_void", F));
+  }
+}
+
 /// Turns the given pointer into a constant.
 static llvm::Constant *GetPointerConstant(llvm::LLVMContext &Context,
   const void *Ptr) {
Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -50,7 +50,8 @@
   CCM_Fast,
   CCM_RegCall,
   CCM_Vector,
-  CCM_Std
+  CCM_Std,
+  CCM_WasmMainArgcArgv
 };
 
 static bool isExternC(const NamedDecl *ND) {
@@ -63,6 +64,16 @@
  const NamedDecl *ND) {
   const TargetInfo &TI = Context.getTargetInfo();
   const llvm::Triple &Triple = TI.getTriple();
+
+  // On wasm, the argc/argv form of "main" is renamed so that the startup code
+  // can call it with the correct function signature.
+  // On Emscripten, users may be exporting "main" and expecting to call it
+  // themselves, so we can't mangle it.
+  if (Triple.isWasm() && !Triple.isOSEmscripten())
+if (const FunctionDecl *FD = dyn_cast(ND))

[PATCH] D75130: Remove BinaryOperator::CreateFNeg

2020-02-27 Thread Simon Moll via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGddd11273d9d0: Remove BinaryOperator::CreateFNeg (authored by 
simoll).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75130

Files:
  clang/test/CodeGen/complex-math.c
  llvm/include/llvm/IR/InstrTypes.h
  llvm/lib/IR/Instructions.cpp
  llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/lib/Transforms/Scalar/Reassociate.cpp
  llvm/test/Transforms/InstCombine/cos-sin-intrinsic.ll
  llvm/test/Transforms/InstCombine/fast-math.ll
  llvm/test/Transforms/InstCombine/fmul.ll
  llvm/test/Transforms/InstCombine/fneg.ll
  llvm/test/Transforms/InstCombine/fpcast.ll
  llvm/test/Transforms/InstCombine/fsub.ll
  llvm/test/Transforms/InstCombine/maximum.ll
  llvm/test/Transforms/InstCombine/maxnum.ll
  llvm/test/Transforms/InstCombine/minimum.ll
  llvm/test/Transforms/InstCombine/minmax-fp.ll
  llvm/test/Transforms/InstCombine/minnum.ll
  llvm/test/Transforms/InstCombine/pow-1.ll
  llvm/test/Transforms/Reassociate/fast-basictest.ll
  llvm/test/Transforms/Reassociate/fp-expr.ll

Index: llvm/test/Transforms/Reassociate/fp-expr.ll
===
--- llvm/test/Transforms/Reassociate/fp-expr.ll
+++ llvm/test/Transforms/Reassociate/fp-expr.ll
@@ -4,7 +4,7 @@
 define void @test1() {
 ; CHECK-LABEL: @test1(
 ; CHECK-NEXT:[[T1:%.*]] = tail call <4 x float> @blam()
-; CHECK-NEXT:[[T1_NEG:%.*]] = fsub fast <4 x float> , [[T1]]
+; CHECK-NEXT:[[T1_NEG:%.*]] = fneg fast <4 x float> [[T1]]
 ; CHECK-NEXT:[[T24:%.*]] = fadd fast <4 x float> [[T1_NEG]], undef
 ; CHECK-NEXT:tail call void @wombat(<4 x float> [[T24]])
 ; CHECK-NEXT:ret void
@@ -19,7 +19,7 @@
 define half @test2() {
 ; CHECK-LABEL: @test2(
 ; CHECK-NEXT:[[T15:%.*]] = fsub fast half undef, undef
-; CHECK-NEXT:[[T15_NEG:%.*]] = fsub fast half 0xH8000, [[T15]]
+; CHECK-NEXT:[[T15_NEG:%.*]] = fneg fast half [[T15]]
 ; CHECK-NEXT:[[T18:%.*]] = fadd fast half [[T15_NEG]], undef
 ; CHECK-NEXT:ret half [[T18]]
 ;
Index: llvm/test/Transforms/Reassociate/fast-basictest.ll
===
--- llvm/test/Transforms/Reassociate/fast-basictest.ll
+++ llvm/test/Transforms/Reassociate/fast-basictest.ll
@@ -4,7 +4,7 @@
 ; With reassociation, constant folding can eliminate the 12 and -12 constants.
 define float @test1(float %arg) {
 ; CHECK-LABEL: @test1(
-; CHECK-NEXT:[[ARG_NEG:%.*]] = fsub fast float -0.00e+00, [[ARG:%.*]]
+; CHECK-NEXT:[[ARG_NEG:%.*]] = fneg fast float [[ARG:%.*]]
 ; CHECK-NEXT:ret float [[ARG_NEG]]
 ;
   %t1 = fsub fast float -1.20e+01, %arg
@@ -16,7 +16,7 @@
 ; Both 'reassoc' and 'nsz' are required.
 define float @test1_minimal(float %arg) {
 ; CHECK-LABEL: @test1_minimal(
-; CHECK-NEXT:[[TMP1:%.*]] = fsub reassoc nsz float -0.00e+00, [[ARG:%.*]]
+; CHECK-NEXT:[[TMP1:%.*]] = fneg reassoc nsz float [[ARG:%.*]]
 ; CHECK-NEXT:ret float [[TMP1]]
 ;
   %t1 = fsub reassoc nsz float -1.20e+01, %arg
Index: llvm/test/Transforms/InstCombine/pow-1.ll
===
--- llvm/test/Transforms/InstCombine/pow-1.ll
+++ llvm/test/Transforms/InstCombine/pow-1.ll
@@ -170,7 +170,7 @@
 
 define <2 x float> @test_simplify4vn(<2 x float> %x) {
 ; CHECK-LABEL: @test_simplify4vn(
-; ANY-NEXT:[[MUL:%.*]] = fsub <2 x float> , [[X:%.*]]
+; ANY-NEXT:[[MUL:%.*]] = fneg <2 x float> [[X:%.*]]
 ; ANY-NEXT:[[EXP2:%.*]] = call <2 x float> @llvm.exp2.v2f32(<2 x float> [[MUL]])
 ; ANY-NEXT:ret <2 x float> [[EXP2]]
 ; MSVC-NEXT:   [[POW:%.*]] = call <2 x float> @llvm.pow.v2f32(<2 x float> , <2 x float> [[X:%.*]])
Index: llvm/test/Transforms/InstCombine/minnum.ll
===
--- llvm/test/Transforms/InstCombine/minnum.ll
+++ llvm/test/Transforms/InstCombine/minnum.ll
@@ -247,7 +247,7 @@
 define double @neg_neg(double %x, double %y) {
 ; CHECK-LABEL: @neg_neg(
 ; CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double [[Y:%.*]])
-; CHECK-NEXT:[[R:%.*]] = fsub double -0.00e+00, [[TMP1]]
+; CHECK-NEXT:[[R:%.*]] = fneg double [[TMP1]]
 ; CHECK-NEXT:ret double [[R]]
 ;
   %negx = fsub double -0.0, %x
@@ -259,7 +259,7 @@
 define double @unary_neg_neg(double %x, double %y) {
 ; CHECK-LABEL: @unary_neg_neg(
 ; CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double [[Y:%.*]])
-; CHECK-NEXT:[[R:%.*]] = fsub double -0.00e+00, [[TMP1]]
+; CHECK-NEXT:[[R:%.*]] = fneg double [[TMP1]]
 ; CHECK-NEXT:ret double [[R]]
 ;
   %n

[PATCH] D31338: Move ParsedAttrInfos into a registry and point to one in ParsedAttr

2020-02-27 Thread John Brawn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG75d4d4bd028f: Add an attribute registry so plugins can add 
attributes (authored by john.brawn).

Changed prior to commit:
  https://reviews.llvm.org/D31338?vs=246763&id=247014#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31338

Files:
  clang/include/clang/Basic/AttributeCommonInfo.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Basic/Attributes.cpp
  clang/lib/Sema/ParsedAttr.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3625,9 +3625,11 @@
 
 // We need to generate struct instances based off ParsedAttrInfo from
 // ParsedAttr.cpp.
+const std::string &AttrName = I->first;
 const Record &Attr = *I->second;
 OS << "struct ParsedAttrInfo" << I->first << " : public ParsedAttrInfo {\n";
 OS << "  ParsedAttrInfo" << I->first << "() {\n";
+OS << "AttrKind = ParsedAttr::AT_" << AttrName << ";\n";
 emitArgInfo(Attr, OS);
 OS << "HasCustomParsing = ";
 OS << Attr.getValueAsBit("HasCustomParsing") << ";\n";
@@ -3642,6 +3644,20 @@
 OS << IsKnownToGCC(Attr) << ";\n";
 OS << "IsSupportedByPragmaAttribute = ";
 OS << PragmaAttributeSupport.isAttributedSupported(*I->second) << ";\n";
+for (const auto &S : GetFlattenedSpellings(Attr)) {
+  const std::string &RawSpelling = S.name();
+  std::string Spelling;
+  if (S.variety() == "CXX11" || S.variety() == "C2x") {
+Spelling += S.nameSpace();
+Spelling += "::";
+  }
+  if (S.variety() == "GNU")
+Spelling += NormalizeGNUAttrSpelling(RawSpelling);
+  else
+Spelling += RawSpelling;
+  OS << "Spellings.push_back({AttributeCommonInfo::AS_" << S.variety();
+  OS << ",\"" << Spelling << "\"});\n";
+}
 OS << "  }\n";
 GenerateAppertainsTo(Attr, OS);
 GenerateLangOptRequirements(Attr, OS);
Index: clang/lib/Sema/ParsedAttr.cpp
===
--- clang/lib/Sema/ParsedAttr.cpp
+++ clang/lib/Sema/ParsedAttr.cpp
@@ -25,6 +25,8 @@
 
 using namespace clang;
 
+LLVM_INSTANTIATE_REGISTRY(ParsedAttrInfoRegistry)
+
 IdentifierLoc *IdentifierLoc::create(ASTContext &Ctx, SourceLocation Loc,
  IdentifierInfo *Ident) {
   IdentifierLoc *Result = new (Ctx) IdentifierLoc;
@@ -100,66 +102,58 @@
   pool.Attrs.clear();
 }
 
-struct ParsedAttrInfo {
-  unsigned NumArgs : 4;
-  unsigned OptArgs : 4;
-  unsigned HasCustomParsing : 1;
-  unsigned IsTargetSpecific : 1;
-  unsigned IsType : 1;
-  unsigned IsStmt : 1;
-  unsigned IsKnownToGCC : 1;
-  unsigned IsSupportedByPragmaAttribute : 1;
-
-  virtual ~ParsedAttrInfo() = default;
-
-  virtual bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr,
-const Decl *) const {
-return true;
-  }
-  virtual bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const {
-return true;
-  }
-  virtual bool existsInTarget(const TargetInfo &Target) const {
-return true;
-  }
-  virtual unsigned
-  spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const {
-return UINT_MAX;
-  }
-  virtual void getPragmaAttributeMatchRules(
-llvm::SmallVectorImpl> &Rules,
-const LangOptions &LangOpts) const {
-  }
-};
-
 namespace {
 
 #include "clang/Sema/AttrParsedAttrImpl.inc"
 
 } // namespace
 
-static const ParsedAttrInfo &getInfo(const ParsedAttr &A) {
-  // If we have a ParsedAttrInfo for this ParsedAttr then return that,
-  // otherwise return a default ParsedAttrInfo.
-  if (A.getKind() < llvm::array_lengthof(AttrInfoMap))
-return *AttrInfoMap[A.getKind()];
-
+const ParsedAttrInfo &ParsedAttrInfo::get(const AttributeCommonInfo &A) {
+  // If we have a ParsedAttrInfo for this ParsedAttr then return that.
+  if (A.getParsedKind() < llvm::array_lengthof(AttrInfoMap))
+return *AttrInfoMap[A.getParsedKind()];
+
+  // If this is an ignored attribute then return an appropriate ParsedAttrInfo.
+  static ParsedAttrInfo IgnoredParsedAttrInfo(
+  AttributeCommonInfo::IgnoredAttribute);
+  if (A.getParsedKind() == AttributeCommonInfo::IgnoredAttribute)
+return IgnoredParsedAttrInfo;
+
+  // Otherwise this may be an attribute defined by a plugin. First instantiate
+  // all plugin attributes if we haven't already done so.
+  static std::list> PluginAttrInstances;
+  if (PluginAttrInstances.empty())
+for (auto It : ParsedAttrInfoRegistry::entries())
+  PluginAttrInstances.emplace_back(It.instantiate());
+
+  // Search for a ParsedAttrInfo whose name and syntax match.
+  std::string FullName = A.getNormalizedFullName();
+  AttributeCommonInfo::Syntax SyntaxUsed = A.getSy

[PATCH] D75139: [hexagon] Pickup the default crt and libs when the musl target is selected

2020-02-27 Thread Sid Manning via Phabricator via cfe-commits
sidneym marked an inline comment as done.
sidneym added inline comments.



Comment at: clang/lib/Driver/ToolChains/Hexagon.cpp:290
+}
+if (!Args.hasArg(options::OPT_shared))
+  CmdArgs.push_back("-dynamic-linker=/lib/ld-musl-hexagon.so.1");

the default selection of the dynamic-linker needs to move above AddAllArgs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75139



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


  1   2   3   >