[PATCH] D68377: [Builtins] Teach Clang about memccpy

2019-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 created this revision.
xbolva00 added a reviewer: aaron.ballman.
Herald added subscribers: cfe-commits, kristina.
Herald added a project: clang.

Hopefully, -fno-builtin-memccpy will work now.


Repository:
  rC Clang

https://reviews.llvm.org/D68377

Files:
  include/clang/Basic/Builtins.def


Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -480,6 +480,7 @@
 BUILTIN(__builtin_memchr, "v*vC*iz", "nF")
 BUILTIN(__builtin_memcmp, "ivC*vC*z", "nF")
 BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
+BUILTIN(__builtin_memccpy, "v*v*vC*iz", "nF")
 BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")
 BUILTIN(__builtin_mempcpy, "v*v*vC*z", "nF")
 BUILTIN(__builtin_memset, "v*v*iz", "nF")
@@ -899,6 +900,7 @@
 LIBBUILTIN(strtoull, "ULLicC*c**i", "f",   "stdlib.h", ALL_LANGUAGES)
 // C99 string.h
 LIBBUILTIN(memcpy, "v*v*vC*z","f", "string.h", ALL_LANGUAGES)
+LIBBUILTIN(memccpy, "v*v*vC*iz",  "f", "string.h", ALL_LANGUAGES)
 LIBBUILTIN(memcmp, "ivC*vC*z","f", "string.h", ALL_LANGUAGES)
 LIBBUILTIN(memmove, "v*v*vC*z",   "f", "string.h", ALL_LANGUAGES)
 LIBBUILTIN(strcpy, "c*c*cC*", "f", "string.h", ALL_LANGUAGES)


Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -480,6 +480,7 @@
 BUILTIN(__builtin_memchr, "v*vC*iz", "nF")
 BUILTIN(__builtin_memcmp, "ivC*vC*z", "nF")
 BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
+BUILTIN(__builtin_memccpy, "v*v*vC*iz", "nF")
 BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")
 BUILTIN(__builtin_mempcpy, "v*v*vC*z", "nF")
 BUILTIN(__builtin_memset, "v*v*iz", "nF")
@@ -899,6 +900,7 @@
 LIBBUILTIN(strtoull, "ULLicC*c**i", "f",   "stdlib.h", ALL_LANGUAGES)
 // C99 string.h
 LIBBUILTIN(memcpy, "v*v*vC*z","f", "string.h", ALL_LANGUAGES)
+LIBBUILTIN(memccpy, "v*v*vC*iz",  "f", "string.h", ALL_LANGUAGES)
 LIBBUILTIN(memcmp, "ivC*vC*z","f", "string.h", ALL_LANGUAGES)
 LIBBUILTIN(memmove, "v*v*vC*z",   "f", "string.h", ALL_LANGUAGES)
 LIBBUILTIN(strcpy, "c*c*cC*", "f", "string.h", ALL_LANGUAGES)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68377: [Builtins] Teach Clang about memccpy

2019-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.



Comment at: include/clang/Basic/Builtins.def:903
 LIBBUILTIN(memcpy, "v*v*vC*z","f", "string.h", ALL_LANGUAGES)
+LIBBUILTIN(memccpy, "v*v*vC*iz",  "f", "string.h", ALL_LANGUAGES)
 LIBBUILTIN(memcmp, "ivC*vC*z","f", "string.h", ALL_LANGUAGES)

Well, technically, C 20.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68377



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


[PATCH] D68379: FunctionDecl::isThisDeclarationADefinition is useless in ProcessDeclAttribute

2019-10-03 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is for illustration purposes and not to be submitted


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68379

Files:
  clang/lib/Sema/SemaDeclAttr.cpp


Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1798,12 +1798,12 @@
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str))
 return;
 
-  // Aliases should be on declarations, not definitions.
-  const auto *FD = cast(D);
-  if (FD->isThisDeclarationADefinition()) {
-S.Diag(AL.getLoc(), diag::err_alias_is_definition) << FD << 1;
-return;
-  }
+  // // Aliases should be on declarations, not definitions.
+  // const auto *FD = cast(D);
+  // if (FD->isThisDeclarationADefinition()) {
+  //   S.Diag(AL.getLoc(), diag::err_alias_is_definition) << FD << 1;
+  //   return;
+  // }
 
   D->addAttr(::new (S.Context) IFuncAttr(S.Context, AL, Str));
 }
@@ -1823,10 +1823,10 @@
 
   // Aliases should be on declarations, not definitions.
   if (const auto *FD = dyn_cast(D)) {
-if (FD->isThisDeclarationADefinition()) {
-  S.Diag(AL.getLoc(), diag::err_alias_is_definition) << FD << 0;
-  return;
-}
+// if (FD->isThisDeclarationADefinition()) {
+//   S.Diag(AL.getLoc(), diag::err_alias_is_definition) << FD << 0;
+//   return;
+// }
   } else {
 const auto *VD = cast(D);
 if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
@@ -5628,10 +5628,10 @@
   }
 
   auto *FD = cast(D);
-  if (FD->isThisDeclarationADefinition()) {
-S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0;
-return;
-  }
+  // if (FD->isThisDeclarationADefinition()) {
+  //   S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0;
+  //   return;
+  // }
 
   StringRef Str;
   SourceLocation ArgLoc;
@@ -5650,10 +5650,10 @@
   }
 
   auto *FD = cast(D);
-  if (FD->isThisDeclarationADefinition()) {
-S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0;
-return;
-  }
+  // if (FD->isThisDeclarationADefinition()) {
+  //   S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0;
+  //   return;
+  // }
 
   StringRef Str;
   SourceLocation ArgLoc;


Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1798,12 +1798,12 @@
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str))
 return;
 
-  // Aliases should be on declarations, not definitions.
-  const auto *FD = cast(D);
-  if (FD->isThisDeclarationADefinition()) {
-S.Diag(AL.getLoc(), diag::err_alias_is_definition) << FD << 1;
-return;
-  }
+  // // Aliases should be on declarations, not definitions.
+  // const auto *FD = cast(D);
+  // if (FD->isThisDeclarationADefinition()) {
+  //   S.Diag(AL.getLoc(), diag::err_alias_is_definition) << FD << 1;
+  //   return;
+  // }
 
   D->addAttr(::new (S.Context) IFuncAttr(S.Context, AL, Str));
 }
@@ -1823,10 +1823,10 @@
 
   // Aliases should be on declarations, not definitions.
   if (const auto *FD = dyn_cast(D)) {
-if (FD->isThisDeclarationADefinition()) {
-  S.Diag(AL.getLoc(), diag::err_alias_is_definition) << FD << 0;
-  return;
-}
+// if (FD->isThisDeclarationADefinition()) {
+//   S.Diag(AL.getLoc(), diag::err_alias_is_definition) << FD << 0;
+//   return;
+// }
   } else {
 const auto *VD = cast(D);
 if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
@@ -5628,10 +5628,10 @@
   }
 
   auto *FD = cast(D);
-  if (FD->isThisDeclarationADefinition()) {
-S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0;
-return;
-  }
+  // if (FD->isThisDeclarationADefinition()) {
+  //   S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0;
+  //   return;
+  // }
 
   StringRef Str;
   SourceLocation ArgLoc;
@@ -5650,10 +5650,10 @@
   }
 
   auto *FD = cast(D);
-  if (FD->isThisDeclarationADefinition()) {
-S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0;
-return;
-  }
+  // if (FD->isThisDeclarationADefinition()) {
+  //   S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0;
+  //   return;
+  // }
 
   StringRef Str;
   SourceLocation ArgLoc;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68380: [Driver] NFC: Remove duplicate call to getLibGccType

2019-10-03 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes created this revision.
c-rhodes added a reviewer: saugustine.

https://reviews.llvm.org/D68380

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


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1186,7 +1186,6 @@
   case ToolChain::UNW_None:
 return;
   case ToolChain::UNW_Libgcc: {
-LibGccType LGT = getLibGccType(D, Args);
 if (LGT == LibGccType::StaticLibGcc)
   CmdArgs.push_back("-lgcc_eh");
 else


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1186,7 +1186,6 @@
   case ToolChain::UNW_None:
 return;
   case ToolChain::UNW_Libgcc: {
-LibGccType LGT = getLibGccType(D, Args);
 if (LGT == LibGccType::StaticLibGcc)
   CmdArgs.push_back("-lgcc_eh");
 else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-03 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet marked 3 inline comments as done.
gchatelet added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:1098-1099
+
+  if (D->hasAttr())
+D->dropAttr();
+

gchatelet wrote:
> aaron.ballman wrote:
> > Just making sure I understand the semantics you want: redeclarations do not 
> > have to have matching lists of builtins, but instead the definition will 
> > use a merged list? e.g.,
> > ```
> > [[clang::no_builtin("memset")]] void whatever();
> > [[clang::no_builtin("memcpy")]] void whatever();
> > 
> > [[clang::no_builtin("memmove")]] void whatever() {
> >  // Will not use memset, memcpy, or memmove builtins.
> > }
> > ```
> > That seems a bit strange, to me. In fact, being able to apply this 
> > attribute to a declaration seems a bit like a mistake -- this only impacts 
> > the definition of the function, and I can't imagine good things coming from 
> > hypothetical code like:
> > ```
> > [[clang::no_builtin("memset")]] void whatever();
> > #include "whatever.h" // Provides a library declaration of whatever() with 
> > no restrictions on it
> > ```
> > WDYT about restricting this attribute to only appear on definitions?
> That's a very good point. Thx for noticing.
> Indeed I think it only makes sense to have the attribute on the function 
> definition.
> 
> I've tried to to use `FunctionDecl->hasBody()` during attribute handling in 
> the Sema phase but it seems like the `FunctionDecl` is not complete at this 
> point.
> All calls to `hasBody()` return `false`, if I repeat the operation in 
> `CGCall` then `hasBody` returns `true` and I can see the `CompoundStatement`.
> 
> Do you have any recommendations on where to perform the check?
So after some investigations it turns out that 
`FunctionDecl::isThisDeclarationADefinition` is buggy (returns always `false`) 
when called from `ProcessDeclAttribute`.
I believe it's because the `CompoundStatement` is not parsed at this point.

As a matter of fact all code using this function in `ProcessDeclAttribute` is 
dead code (see D68379 which disables the dead code, tests are still passing)


I'm unsure of how to fix this, it may be possible of using 
`FunctionDecl::setWillHaveBody`in [[ 
https://github.com/llvm/llvm-project/blob/0577a0cedbc5be4cd4c20ba53d3dbdac6bff9a0a/clang/lib/Sema/SemaDecl.cpp#L8820
 | this switch ]].


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028



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


[PATCH] D63932: [GlobalDCE] Dead Virtual Function Elimination

2019-10-03 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63932



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


r373577 - [clang][NFC] Fix misspellings in ExternalASTMerger.h

2019-10-03 Thread Raphael Isemann via cfe-commits
Author: teemperor
Date: Thu Oct  3 02:55:13 2019
New Revision: 373577

URL: http://llvm.org/viewvc/llvm-project?rev=373577&view=rev
Log:
[clang][NFC] Fix misspellings in ExternalASTMerger.h

Modified:
cfe/trunk/include/clang/AST/ExternalASTMerger.h

Modified: cfe/trunk/include/clang/AST/ExternalASTMerger.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTMerger.h?rev=373577&r1=373576&r2=373577&view=diff
==
--- cfe/trunk/include/clang/AST/ExternalASTMerger.h (original)
+++ cfe/trunk/include/clang/AST/ExternalASTMerger.h Thu Oct  3 02:55:13 2019
@@ -23,7 +23,7 @@ namespace clang {
 /// ExternalASTSource implementation that merges information from several
 /// ASTContexts.
 ///
-/// ExtermalASTMerger maintains a vector of ASTImporters that it uses to import
+/// ExternalASTMerger maintains a vector of ASTImporters that it uses to import
 /// (potentially incomplete) Decls and DeclContexts from the source ASTContexts
 /// in response to ExternalASTSource API calls.
 ///
@@ -37,7 +37,7 @@ namespace clang {
 ///   lookup.  In this case, Origins contains an entry overriding lookup and
 ///   specifying the correct pair of DeclContext/ASTContext.
 ///
-/// - The DeclContext of origin was determined by another ExterenalASTMerger.
+/// - The DeclContext of origin was determined by another ExternalASTMerger.
 ///   (This is possible when the source ASTContext for one of the Importers has
 ///   its own ExternalASTMerger).  The origin must be properly forwarded in 
this
 ///   case.
@@ -94,7 +94,7 @@ public:
   };
 
 private:
-  /// The target for this ExtenralASTMerger.
+  /// The target for this ExternalASTMerger.
   ImporterTarget Target;
   /// ExternalASTMerger has multiple ASTImporters that import into the same
   /// TU. This is the shared state for all ASTImporters of this
@@ -158,7 +158,7 @@ public:
   /// OriginContext.
   bool HasImporterForOrigin(ASTContext &OriginContext);
 
-  /// Returns a reference to the ASTRImporter from Importers whose origin
+  /// Returns a reference to the ASTImporter from Importers whose origin
   /// is OriginContext.  This allows manual import of ASTs while preserving the
   /// OriginMap correctly.
   ASTImporter &ImporterForOrigin(ASTContext &OriginContext);


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


[PATCH] D67156: [Analyzer] Debug Checkers for Container and Iterator Inspection

2019-10-03 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 222984.
baloghadamsoftware added a comment.

Updated according to the comments.


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

https://reviews.llvm.org/D67156

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/debug-iterator-modeling.cpp

Index: test/Analysis/debug-iterator-modeling.cpp
===
--- /dev/null
+++ test/Analysis/debug-iterator-modeling.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_analyze_cc1 -std=c++11\
+// RUN: -analyzer-checker=core,cplusplus\
+// RUN: -analyzer-checker=debug.DebugIteratorModeling,debug.ExprInspection\
+// RUN: -analyzer-config aggressive-binary-operation-simplification=true\
+// RUN: -analyzer-config c++-container-inlining=false %s -verify
+
+// RUN: %clang_analyze_cc1 -std=c++11\
+// RUN: -analyzer-checker=core,cplusplus\
+// RUN: -analyzer-checker=debug.DebugIteratorModeling,debug.ExprInspection\
+// RUN: -analyzer-config aggressive-binary-operation-simplification=true\
+// RUN: -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+template 
+long clang_analyzer_container_begin(const Container&);
+template 
+long clang_analyzer_container_end(const Container&);
+template 
+long clang_analyzer_iterator_position(const Iterator&);
+template 
+void* clang_analyzer_iterator_container(const Iterator&);
+template 
+bool clang_analyzer_iterator_validity(const Iterator&);
+void clang_analyzer_denote(long, const char*);
+void clang_analyzer_express(long);
+void clang_analyzer_dump(const void*);
+void clang_analyzer_eval(bool);
+
+void iterator_position(const std::vector v0) {
+  auto b0 = v0.begin(), e0 = v0.end();
+
+  clang_analyzer_denote(clang_analyzer_iterator_position(b0), "$b0");
+  clang_analyzer_denote(clang_analyzer_iterator_position(e0), "$e0");
+
+  clang_analyzer_express(clang_analyzer_iterator_position(b0)); // expected-warning{{$b0}}
+  clang_analyzer_express(clang_analyzer_iterator_position(e0)); // expected-warning{{$e0}}
+
+  clang_analyzer_express(clang_analyzer_container_begin(v0)); // expected-warning{{$b0}}
+  clang_analyzer_express(clang_analyzer_container_end(v0)); // expected-warning{{$e0}}
+
+  ++b0;
+
+  clang_analyzer_express(clang_analyzer_iterator_position(b0)); // expected-warning{{$b0 + 1}}
+}
+
+void iterator_container(const std::vector v0) {
+  auto b0 = v0.begin();
+
+  clang_analyzer_dump(&v0); //expected-warning{{&v0}}
+  clang_analyzer_eval(clang_analyzer_iterator_container(b0) == &v0); // expected-warning{{TRUE}}
+}
+
+void iterator_validity(std::vector v0) {
+  auto b0 = v0.begin();
+  clang_analyzer_eval(clang_analyzer_iterator_validity(b0)); //expected-warning{{TRUE}}
+
+  v0.clear();
+
+  clang_analyzer_eval(clang_analyzer_iterator_validity(b0)); //expected-warning{{FALSE}}
+}
Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -173,11 +173,12 @@
 class IteratorChecker
 : public Checker, check::Bind,
- check::LiveSymbols, check::DeadSymbols> {
+ check::LiveSymbols, check::DeadSymbols, eval::Call> {
 
   std::unique_ptr OutOfRangeBugType;
   std::unique_ptr MismatchedBugType;
   std::unique_ptr InvalidatedBugType;
+  std::unique_ptr DebugMsgBugType;
 
   void handleComparison(CheckerContext &C, const Expr *CE, const SVal &RetVal,
 const SVal &LVal, const SVal &RVal,
@@ -236,7 +237,35 @@
ExplodedNode *ErrNode) const;
   void reportInvalidatedBug(const StringRef &Message, const SVal &Val,
 CheckerContext &C, ExplodedNode *ErrNode) const;
-
+  template 
+  void analyzerContainerDataField(const CallExpr *CE, CheckerContext &C,
+  Getter get) const;
+  void analyzerContainerBegin(const CallExpr *CE, CheckerContext &C) const;
+  void analyzerContainerEnd(const CallExpr *CE, CheckerContext &C) const;
+  template 
+  void analyzerIteratorDataField(const CallExpr *CE, CheckerContext &C,
+ Getter get, SVal Default) const;
+  void analyzerIteratorPosition(const CallExpr *CE, CheckerContext &C) const;
+  void analyzerIteratorContainer(const CallExpr *CE, CheckerContext &C) const;
+  void analyzerIteratorValidity(const CallExpr *CE, CheckerContext &C) const;
+  ExplodedNode *reportDebugMsg(llvm::StringRef Msg, CheckerContext &C) const;
+
+  typedef void (IteratorChecker::*FnCheck)(const CallExpr *,
+   CheckerContext &) const;
+
+  CallDescriptionMap Callbacks = {
+{{0, "clang_analyzer_container_begin", 1},
+ &IteratorChecker::analyzerContainerBegin},
+{{0, "clang_analyzer_container_e

[PATCH] D67156: [Analyzer] Debug Checkers for Container and Iterator Inspection

2019-10-03 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 6 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: include/clang/StaticAnalyzer/Checkers/Checkers.td:1328-1337
+def ContainerInspectionChecker : Checker<"ContainerInspection">,
+  HelpText<"Check the analyzer's understanding of C++ containers">,
+  Dependencies<[IteratorModeling]>,
+  Documentation;
+
+def IteratorInspectionChecker : Checker<"IteratorInspection">,
+  HelpText<"Check the analyzer's understanding of C++ iterators">,

Szelethus wrote:
> NoQ wrote:
> > Dunno, i would keep it all in one checker, just to save a few `// RUN:` 
> > lines :)
> I agree. Let's combine these into `DebugIteratorModeling`, because, as I 
> understand it, that is what we're doing!
I did it on the short term, but on the long term iterator and container 
modelling are planned to be two different things, where iterator modelling 
depends on container modelling, but the latter works alone as well to support 
container checkers, such as e.g. copying data into a container with 
insufficient size. Furthermore I do not really like the name 
`debug.DebugIteratorModeling`.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:243-244
+  Getter get) const;
+  void analyzerContainerBegin(const CallExpr *CE, CheckerContext &C) const;
+  void analyzerContainerEnd(const CallExpr *CE, CheckerContext &C) const;
+  template 

NoQ wrote:
> We usually define such getters for stuff that the programmer cannot obtain 
> otherwise during normal program execution. These two functions look like 
> they're probably equivalent to normal `.begin()` and `.end()` calls. I don't 
> really object but do we really ever need them other than for testing the 
> trivial implementations of `.begin()` and `.end()`?
Not exactly. These functions return the internal representation of their 
`.begin()` and `.end()`. These symbols are conjured by the iterator checker and 
are bound to the return value of `.begin()` and `.end()` in the container data 
map. It is an extra check to check whether they return the same internal symbol 
as `clang_analyzer_iterator_position()` for the return value of `.begin()` and 
`.end()`.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:1689
+  if (CE->getNumArgs() == 0) {
+reportDebugMsg("Missing container argument", C);
+return;

Szelethus wrote:
> Ah, right, so this would fire for `clang_analyzer_iterator_position()`?
Yes, and also for the other two.


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

https://reviews.llvm.org/D67156



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


r373584 - Silence static analyzer getAs null dereference warnings. NFCI.

2019-10-03 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Oct  3 04:22:48 2019
New Revision: 373584

URL: http://llvm.org/viewvc/llvm-project?rev=373584&view=rev
Log:
Silence static analyzer getAs null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these 
cases we should be able to use castAs directly and if not assert 
will fire for us.

Modified:
cfe/trunk/lib/AST/APValue.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/InheritViz.cpp
cfe/trunk/lib/AST/Interp/Program.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/JSONNodeDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp
cfe/trunk/lib/AST/VTTBuilder.cpp
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CGCXXABI.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
cfe/trunk/lib/Sema/SemaAccess.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/lib/AST/APValue.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/APValue.cpp?rev=373584&r1=373583&r2=373584&view=diff
==
--- cfe/trunk/lib/AST/APValue.cpp (original)
+++ cfe/trunk/lib/AST/APValue.cpp Thu Oct  3 04:22:48 2019
@@ -652,7 +652,7 @@ void APValue::printPretty(raw_ostream &O
   }
   case APValue::Struct: {
 Out << '{';
-const RecordDecl *RD = Ty->getAs()->getDecl();
+const RecordDecl *RD = Ty->castAs()->getDecl();
 bool First = true;
 if (unsigned N = getStructNumBases()) {
   const CXXRecordDecl *CD = cast(RD);

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=373584&r1=373583&r2=373584&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Thu Oct  3 04:22:48 2019
@@ -218,7 +218,7 @@ CXXRecordDecl::setBases(CXXBaseSpecifier
 if (BaseType->isDependentType())
   continue;
 auto *BaseClassDecl =
-cast(BaseType->getAs()->getDecl());
+cast(BaseType->castAs()->getDecl());
 
 // C++2a [class]p7:
 //   A standard-layout class is a class that:
@@ -1909,7 +1909,7 @@ bool CXXRecordDecl::mayBeAbstract() cons
 
   for (const auto &B : bases()) {
 const auto *BaseDecl =
-cast(B.getType()->getAs()->getDecl());
+cast(B.getType()->castAs()->getDecl());
 if (BaseDecl->isAbstract())
   return true;
   }

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=373584&r1=373583&r2=373584&view=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Oct  3 04:22:48 2019
@@ -85,8 +85,8 @@ const Expr *Expr::skipRValueSubobjectAdj
CE->getCastKind() == CK_UncheckedDerivedToBase) &&
   E->getType()->isRecordType()) {
 E = CE->getSubExpr();
-CXXRecordDecl *Derived
-  = cast(E->getType()->getAs()->getDecl());
+auto *Derived =
+cast(E->getType()->castAs()->getDecl());
 Adjustments.push_back(SubobjectAdjustment(CE, Derived));
 continue;
   }
@@ -3205,7 +3205,7 @@ bool Expr::isConstantInitializer(ASTCont
 
 if (ILE->getType()->isRecordType()) {
   unsigned ElementNo = 0;
-  RecordDecl *RD = ILE->getType()->getAs()->getDecl();
+  RecordDecl *RD = ILE->getType()->castAs()->getDecl();
   for (const auto *Field : RD->fields()) {
 // If this is a union, skip all the fields that aren't being 
initialized.
 if (RD->isUnion() && ILE->getInitializedFieldInUnion() != Field)

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=373584&r1=373583&r2=373584&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Oct  3 04:22:48 2019
@@ -7211,7 +7211,7 @@ public:
 
 const ValueDecl *MD = E->getMemberDecl();
 if (const FieldDecl *FD = dyn_cast(E->getMemberDecl())) {
-   

[PATCH] D67932: [analyzer] Fix accidentally skipping the call during inlined defensive check suppression.

2019-10-03 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso accepted this revision.
Charusso added a comment.

> [...] one reason why we can't simply use the error node may be that the 
> binding to that variable might have already disappeared from the state by the 
> time the bug is found.

Yes, that is pretty interesting. I have found error nodes which after the purge 
program point, so when we arbitrarily pick the last node to prevent false 
alarms we could pick the last node which has more information, 2-3 nodes 
earlier on the path. I am not sure whether this new approach would be useful 
here, other than that I like the idea.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67932



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


[PATCH] D68268: [Alignment][NFC] Remove StoreInst::setAlignment(unsigned)

2019-10-03 Thread Clement Courbet via Phabricator via cfe-commits
courbet added inline comments.



Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:189
+  L->setAlignment(
+  MaybeAlign(CopySrcAlign)); // Check if we can use Align instead.
   if (CopyMD)

FIXME



Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:203
+  S->setAlignment(
+  MaybeAlign(CopyDstAlign)); // Check if we can use Align instead.
   if (CopyMD)

ditto



Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:277
MI->isVolatile());
-S->setAlignment(Alignment);
+assert(Alignment && "Alignment must be set");
+S->setAlignment(Align(Alignment));

make it const + remove assert ?



Comment at: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:1367
+SI.setAlignment(
+MaybeAlign(KnownAlign)); // Check if we can use Align instead.
   else if (StoreAlign == 0)

`getOrEnforceKnownAlignment()` seems to always be returning >0



Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4027
 
-  ST->setAlignment(Alignment);
+  ST->setAlignment(Align(Alignment));
   Value *V = propagateMetadata(ST, E->Scalars);

I don't think there are any guarantees that `getABITypeAlignment` is non-zero 
for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68268



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


[PATCH] D68268: [Alignment][NFC] Remove StoreInst::setAlignment(unsigned)

2019-10-03 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 222991.
gchatelet marked 6 inline comments as done.
gchatelet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68268

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCleanup.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Instructions.h
  llvm/lib/CodeGen/AtomicExpandPass.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
  llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
  llvm/lib/Transforms/Scalar/GVNHoist.cpp
  llvm/lib/Transforms/Scalar/LICM.cpp
  llvm/lib/Transforms/Scalar/SROA.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  polly/lib/CodeGen/BlockGenerators.cpp

Index: polly/lib/CodeGen/BlockGenerators.cpp
===
--- polly/lib/CodeGen/BlockGenerators.cpp
+++ polly/lib/CodeGen/BlockGenerators.cpp
@@ -1209,7 +1209,7 @@
 StoreInst *Store = Builder.CreateStore(Vector, VectorPtr);
 
 if (!Aligned)
-  Store->setAlignment(8);
+  Store->setAlignment(Align(8));
   } else {
 for (unsigned i = 0; i < ScalarMaps.size(); i++) {
   Value *Scalar = Builder.CreateExtractElement(Vector, Builder.getInt32(i));
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -4024,7 +4024,7 @@
   if (!Alignment)
 Alignment = DL->getABITypeAlignment(SI->getValueOperand()->getType());
 
-  ST->setAlignment(Alignment);
+  ST->setAlignment(Align(Alignment));
   Value *V = propagateMetadata(ST, E->Scalars);
   if (NeedToShuffleReuses) {
 V = Builder.CreateShuffleVector(V, UndefValue::get(VecTy),
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -3087,15 +3087,15 @@
   // store that doesn't execute.
   if (MinAlignment != 0) {
 // Choose the minimum of all non-zero alignments.
-SI->setAlignment(MinAlignment);
+SI->setAlignment(Align(MinAlignment));
   } else if (MaxAlignment != 0) {
 // Choose the minimal alignment between the non-zero alignment and the ABI
 // default alignment for the type of the stored value.
-SI->setAlignment(std::min(MaxAlignment, TypeAlignment));
+SI->setAlignment(Align(std::min(MaxAlignment, TypeAlignment)));
   } else {
 // If both alignments are zero, use ABI default alignment for the type of
 // the stored value.
-SI->setAlignment(TypeAlignment);
+SI->setAlignment(Align(TypeAlignment));
   }
 
   QStore->eraseFromParent();
Index: llvm/lib/Transforms/Scalar/SROA.cpp
===
--- llvm/lib/Transforms/Scalar/SROA.cpp
+++ llvm/lib/Transforms/Scalar/SROA.cpp
@@ -3127,7 +3127,7 @@
   Value *Op = SI->getOperand(0);
   StoreAlign = DL.getABITypeAlignment(Op->getType());
 }
-SI->setAlignment(std::min(StoreAlign, getSliceAlign()));
+SI->setAlignment(MaybeAlign(std::min(StoreAlign, getSliceAlign(;
 continue;
   }
 
Index: llvm/lib/Transforms/Scalar/LICM.cpp
===
--- llvm/lib/Transforms/Scalar/LICM.cpp
+++ llvm/lib/Transforms/Scalar/LICM.cpp
@@ -1790,7 +1790,7 @@
   StoreInst *NewSI = new StoreInst(LiveInValue, Ptr, InsertPos);
   if (UnorderedAtomic)
 NewSI->setOrdering(AtomicOrdering::Unordered);
-  NewSI->setAlignment(Alignment);
+  NewSI->setAlignment(MaybeAlign(Alignment));
   NewSI->setDebugLoc(DL);
   if (AATags)
 NewSI->setAAMetadata(AATags);
Index: llvm/lib/Transforms/Scalar/GVNHoist.cpp
===
--- llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -894,8 +894,8 @@
   ++NumLoadsRemoved;
 } else if (auto *ReplacementStore = dyn_cast(Repl)) {
   ReplacementStore->setAlignment(
-  std::min(ReplacementStore->getAlignment(),
-   cast(I)->getAlignment()));
+  MaybeAlign(std::min(ReplacementStore->getAlignment(),
+  cast(I)->getAlignment(;
   ++NumStoresRemoved;
 } else if (auto *ReplacementAlloca = dyn_cast(Repl)) {
   ReplacementAlloca->setAlignment(
Index: llvm/lib/Transforms/Scalar/AlignmentFr

[PATCH] D68274: [Alignment][Clang][NFC] Add CharUnits::getAsAlign

2019-10-03 Thread Clement Courbet via Phabricator via cfe-commits
courbet added inline comments.



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:2021
   // of the string is via this class initializer.
-  GV->setAlignment(1);
+  GV->setAlignment(llvm::Align(1));
   Fields.addBitCast(GV, CGM.Int8PtrTy);

I think the semantic is None here.



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:6323
 GV->setSection("__DATA, __objc_data");
-  GV->setAlignment(
-  CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ClassnfABITy));
+  GV->setAlignment(llvm::Align(
+  CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ClassnfABITy)));

I don;t think `getABITypeAlignment` makes  any promisses on the return value.



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:6764
+  IvarOffsetGV->setAlignment(llvm::Align(
+  CGM.getDataLayout().getABITypeAlignment(ObjCTypes.IvarOffsetVarTy)));
 

ditto



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:6991
+  PTGV->setAlignment(llvm::Align(
+  CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ProtocolnfABIPtrTy)));
   PTGV->setSection(GetSectionName("__objc_protolist",

ditto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68274



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


[PATCH] D68268: [Alignment][NFC] Remove StoreInst::setAlignment(unsigned)

2019-10-03 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet added inline comments.



Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4027
 
-  ST->setAlignment(Alignment);
+  ST->setAlignment(Align(Alignment));
   Value *V = propagateMetadata(ST, E->Scalars);

courbet wrote:
> I don't think there are any guarantees that `getABITypeAlignment` is non-zero 
> for now.
Actually it is guaranteed to be an `Align`.
You can have a look at the current implementation: 
https://github.com/llvm/llvm-project/blob/18f805a7ea5f369ef523821693f1176b40bcfc7e/llvm/lib/IR/DataLayout.cpp#L752


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68268



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


[PATCH] D68274: [Alignment][Clang][NFC] Add CharUnits::getAsAlign

2019-10-03 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet marked 5 inline comments as done.
gchatelet added inline comments.



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:6323
 GV->setSection("__DATA, __objc_data");
-  GV->setAlignment(
-  CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ClassnfABITy));
+  GV->setAlignment(llvm::Align(
+  CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ClassnfABITy)));

courbet wrote:
> I don;t think `getABITypeAlignment` makes  any promisses on the return value.
It is, I posted a comment on the other patch 
https://reviews.llvm.org/D68268#inline-614898


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68274



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


[PATCH] D68274: [Alignment][Clang][NFC] Add CharUnits::getAsAlign

2019-10-03 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 222994.
gchatelet marked an inline comment as done.
gchatelet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68274

Files:
  clang/include/clang/AST/CharUnits.h
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGCleanup.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ConstantInitBuilder.cpp
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp

Index: clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
===
--- clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -279,7 +279,7 @@
 *M, Ty, /*constant*/ true, llvm::GlobalVariable::InternalLinkage, Data,
 "__clang_ast");
 // The on-disk hashtable needs to be aligned.
-ASTSym->setAlignment(8);
+ASTSym->setAlignment(llvm::Align(8));
 
 // Mach-O also needs a segment name.
 if (Triple.isOSBinFormatMachO())
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -2355,7 +2355,7 @@
   /*isConstant=*/false, llvm::GlobalVariable::ExternalLinkage,
   /*Initializer=*/nullptr, VarName,
   /*InsertBefore=*/nullptr, llvm::GlobalVariable::GeneralDynamicTLSModel);
-  GV->setAlignment(Align.getQuantity());
+  GV->setAlignment(Align.getAsAlign());
   return ConstantAddress(GV, Align);
 }
 
@@ -2498,7 +2498,7 @@
  GV->getLinkage(), Zero, GuardName.str());
 GuardVar->setVisibility(GV->getVisibility());
 GuardVar->setDLLStorageClass(GV->getDLLStorageClass());
-GuardVar->setAlignment(GuardAlign.getQuantity());
+GuardVar->setAlignment(GuardAlign.getAsAlign());
 if (GuardVar->isWeakForLinker())
   GuardVar->setComdat(
   CGM.getModule().getOrInsertComdat(GuardVar->getName()));
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2194,7 +2194,7 @@
 guard->setVisibility(var->getVisibility());
 // If the variable is thread-local, so is its guard variable.
 guard->setThreadLocalMode(var->getThreadLocalMode());
-guard->setAlignment(guardAlignment.getQuantity());
+guard->setAlignment(guardAlignment.getAsAlign());
 
 // The ABI says: "It is suggested that it be emitted in the same COMDAT
 // group as the associated data object." In practice, this doesn't work for
@@ -2547,7 +2547,7 @@
 Guard->setThreadLocal(true);
 
 CharUnits GuardAlign = CharUnits::One();
-Guard->setAlignment(GuardAlign.getQuantity());
+Guard->setAlignment(GuardAlign.getAsAlign());
 
 CodeGenFunction(CGM).GenerateCXXGlobalInitFunc(
 InitFunc, OrderedInits, ConstantAddress(Guard, GuardAlign));
@@ -3479,7 +3479,7 @@
 
   CharUnits Align =
   CGM.getContext().toCharUnitsFromBits(CGM.getTarget().getPointerAlign(0));
-  GV->setAlignment(Align.getQuantity());
+  GV->setAlignment(Align.getAsAlign());
 
   // The Itanium ABI specifies that type_info objects must be globally
   // unique, with one exception: if the type is an incomplete class
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1442,7 +1442,7 @@
   CovDataVal, llvm::getCoverageMappingVarName());
 
   CovData->setSection(getCoverageSection(CGM));
-  CovData->setAlignment(8);
+  CovData->setAlignment(llvm::Align(8));
 
   // Make sure the data doesn't get deleted.
   CGM.addUsedGlobal(CovData);
Index: clang/lib/CodeGen/ConstantInitBuilder.cpp
===
--- clang/lib/CodeGen/ConstantInitBuilder.cpp
+++ clang/lib/CodeGen/ConstantInitBuilder.cpp
@@ -79,7 +79,7 @@
  /*insert before*/ nullptr,
  llvm::GlobalValue::NotThreadLocal,
  addressSpace);
-  GV->setAlignment(alignment.getQuantity());
+  GV->setAlignment(alignment.getAsAlign());
   resolveSelfReferences(GV);
   return GV;
 }
Index:

r373593 - [libTooling] Add various Stencil combinators for expressions.

2019-10-03 Thread Yitzhak Mandelbaum via cfe-commits
Author: ymandel
Date: Thu Oct  3 06:01:00 2019
New Revision: 373593

URL: http://llvm.org/viewvc/llvm-project?rev=373593&view=rev
Log:
[libTooling] Add various Stencil combinators for expressions.

Summary:
This revision adds three new Stencil combinators:
* `expression`, which idiomatically constructs the source for an expression,
  including wrapping the expression's source in parentheses if needed.
* `deref`, which constructs an idiomatic dereferencing expression.
* `addressOf`, which constructs an idiomatic address-taking expression.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Tooling/Refactoring/Stencil.h
cfe/trunk/lib/Tooling/Refactoring/Stencil.cpp
cfe/trunk/unittests/Tooling/StencilTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/Stencil.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/Stencil.h?rev=373593&r1=373592&r2=373593&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/Stencil.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/Stencil.h Thu Oct  3 06:01:00 
2019
@@ -6,7 +6,7 @@
 //
 
//===--===//
 ///
-/// /file
+/// \file
 /// This file defines the *Stencil* abstraction: a code-generating object,
 /// parameterized by named references to (bound) AST nodes.  Given a match
 /// result, a stencil can be evaluated to a string of source code.
@@ -154,6 +154,21 @@ inline StencilPart node(llvm::StringRef
   return selection(tooling::node(Id));
 }
 
+/// Generates the source of the expression bound to \p Id, wrapping it in
+/// parentheses if it may parse differently depending on context. For example, 
a
+/// binary operation is always wrapped, while a variable reference is never
+/// wrapped.
+StencilPart expression(llvm::StringRef Id);
+
+/// Constructs an idiomatic dereferencing of the expression bound to \p ExprId.
+/// \p ExprId is wrapped in parentheses, if needed.
+StencilPart deref(llvm::StringRef ExprId);
+
+/// Constructs an expression that idiomatically takes the address of the
+/// expression bound to \p ExprId. \p ExprId is wrapped in parentheses, if
+/// needed.
+StencilPart addressOf(llvm::StringRef ExprId);
+
 /// Constructs a `MemberExpr` that accesses the named member (\p Member) of the
 /// object bound to \p BaseId. The access is constructed idiomatically: if \p
 /// BaseId is bound to `e` and \p Member identifies member `m`, then returns

Modified: cfe/trunk/lib/Tooling/Refactoring/Stencil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/Stencil.cpp?rev=373593&r1=373592&r2=373593&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/Stencil.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/Stencil.cpp Thu Oct  3 06:01:00 2019
@@ -24,6 +24,7 @@ using namespace clang;
 using namespace tooling;
 
 using ast_matchers::MatchFinder;
+using ast_type_traits::DynTypedNode;
 using llvm::errc;
 using llvm::Error;
 using llvm::Expected;
@@ -37,7 +38,7 @@ template  const D *down_cast
   return static_cast(P);
 }
 
-static llvm::Expected
+static llvm::Expected
 getNode(const ast_matchers::BoundNodes &Nodes, StringRef Id) {
   auto &NodesMap = Nodes.getMap();
   auto It = NodesMap.find(Id);
@@ -60,6 +61,21 @@ struct DebugPrintNodeData {
   std::string Id;
 };
 
+// Operators that take a single node Id as an argument.
+enum class UnaryNodeOperator {
+  Parens,
+  Deref,
+  Address,
+};
+
+// Generic container for stencil operations with a (single) node-id argument.
+struct UnaryOperationData {
+  UnaryOperationData(UnaryNodeOperator Op, std::string Id)
+  : Op(Op), Id(std::move(Id)) {}
+  UnaryNodeOperator Op;
+  std::string Id;
+};
+
 // The fragment of code corresponding to the selected range.
 struct SelectorData {
   explicit SelectorData(RangeSelector S) : Selector(std::move(S)) {}
@@ -91,6 +107,10 @@ bool isEqualData(const DebugPrintNodeDat
   return A.Id == B.Id;
 }
 
+bool isEqualData(const UnaryOperationData &A, const UnaryOperationData &B) {
+  return A.Op == B.Op && A.Id == B.Id;
+}
+
 // Equality is not (yet) defined for \c RangeSelector.
 bool isEqualData(const SelectorData &, const SelectorData &) { return false; }
 
@@ -130,6 +150,32 @@ Error evalData(const DebugPrintNodeData
   return Error::success();
 }
 
+Error evalData(const UnaryOperationData &Data,
+   const MatchFinder::MatchResult &Match, std::string *Result) {
+  const auto *E = Match.Nodes.getNodeAs(Data.Id);
+  if (E == nullptr)
+return llvm::make_error(
+errc::invalid_argument, "Id not bound or not Expr: " + Data.Id);
+  llvm::Optional Source;
+  switch (Data.Op) {
+  case UnaryNodeOperator::Parens:
+Source = buildParens(*E, *Match.Context);
+

r373592 - [Alignment][Clang][NFC] Add CharUnits::getAsAlign

2019-10-03 Thread Guillaume Chatelet via cfe-commits
Author: gchatelet
Date: Thu Oct  3 06:00:29 2019
New Revision: 373592

URL: http://llvm.org/viewvc/llvm-project?rev=373592&view=rev
Log:
[Alignment][Clang][NFC] Add CharUnits::getAsAlign

Summary:
This is a prerequisite to removing `llvm::GlobalObject::setAlignment(unsigned)`.
This is patch is part of a series to introduce an Alignment type.
See this thread for context: 
http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: jholewinski, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/AST/CharUnits.h
cfe/trunk/lib/CodeGen/CGCUDANV.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGCleanup.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/ConstantInitBuilder.cpp
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp

Modified: cfe/trunk/include/clang/AST/CharUnits.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CharUnits.h?rev=373592&r1=373591&r2=373592&view=diff
==
--- cfe/trunk/include/clang/AST/CharUnits.h (original)
+++ cfe/trunk/include/clang/AST/CharUnits.h Thu Oct  3 06:00:29 2019
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_AST_CHARUNITS_H
 
 #include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/Support/Alignment.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/MathExtras.h"
 
@@ -177,6 +178,10 @@ namespace clang {
   /// getQuantity - Get the raw integer representation of this quantity.
   QuantityType getQuantity() const { return Quantity; }
 
+  /// getAsAlign - Returns Quantity as a valid llvm::Align,
+  /// Beware llvm::Align assumes power of two 8-bit bytes.
+  llvm::Align getAsAlign() const { return llvm::Align(Quantity); }
+
   /// alignTo - Returns the next integer (mod 2**64) that is
   /// greater than or equal to this quantity and is a multiple of \p Align.
   /// Align must be non-zero.

Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=373592&r1=373591&r2=373592&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Thu Oct  3 06:00:29 2019
@@ -93,7 +93,7 @@ private:
   GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::None);
 }
 if (Alignment)
-  GV->setAlignment(Alignment);
+  GV->setAlignment(llvm::Align(Alignment));
 
 return llvm::ConstantExpr::getGetElementPtr(ConstStr.getElementType(),
 ConstStr.getPointer(), Zeros);
@@ -628,7 +628,7 @@ llvm::Function *CGNVCUDARuntime::makeMod
 Linkage,
 /*Initializer=*/llvm::ConstantPointerNull::get(VoidPtrPtrTy),
 "__hip_gpubin_handle");
-GpuBinaryHandle->setAlignment(CGM.getPointerAlign().getQuantity());
+GpuBinaryHandle->setAlignment(CGM.getPointerAlign().getAsAlign());
 // Prevent the weak symbol in different shared libraries being merged.
 if (Linkage != llvm::GlobalValue::InternalLinkage)
   GpuBinaryHandle->setVisibility(llvm::GlobalValue::HiddenVisibility);
@@ -669,7 +669,7 @@ llvm::Function *CGNVCUDARuntime::makeMod
 GpuBinaryHandle = new llvm::GlobalVariable(
 TheModule, VoidPtrPtrTy, false, llvm::GlobalValue::InternalLinkage,
 llvm::ConstantPointerNull::get(VoidPtrPtrTy), "__cuda_gpubin_handle");
-GpuBinaryHandle->setAlignment(CGM.getPointerAlign().getQuantity());
+GpuBinaryHandle->setAlignment(CGM.getPointerAlign().getAsAlign());
 CtorBuilder.CreateAlignedStore(RegisterFatbinCall, GpuBinaryHandle,
CGM.getPointerAlign());
 

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=373592&r1=373591&r2=373592&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Oct  3 06:00:29 2019
@@ -3841,7 +3841,7 @@ RValue CodeGenFunction::EmitCall(const C
   AI = CreateTempAlloca(ArgStruct, "argmem");
 }
 auto Align = CallInfo.getArgStructAlignm

[PATCH] D68315: [libTooling] Add various Stencil combinators for expressions.

2019-10-03 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
ymandel marked an inline comment as done.
Closed by commit rL373593: [libTooling] Add various Stencil combinators for 
expressions. (authored by ymandel, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68315?vs=222889&id=222997#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68315

Files:
  cfe/trunk/include/clang/Tooling/Refactoring/Stencil.h
  cfe/trunk/lib/Tooling/Refactoring/Stencil.cpp
  cfe/trunk/unittests/Tooling/StencilTest.cpp

Index: cfe/trunk/lib/Tooling/Refactoring/Stencil.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring/Stencil.cpp
+++ cfe/trunk/lib/Tooling/Refactoring/Stencil.cpp
@@ -24,6 +24,7 @@
 using namespace tooling;
 
 using ast_matchers::MatchFinder;
+using ast_type_traits::DynTypedNode;
 using llvm::errc;
 using llvm::Error;
 using llvm::Expected;
@@ -37,7 +38,7 @@
   return static_cast(P);
 }
 
-static llvm::Expected
+static llvm::Expected
 getNode(const ast_matchers::BoundNodes &Nodes, StringRef Id) {
   auto &NodesMap = Nodes.getMap();
   auto It = NodesMap.find(Id);
@@ -60,6 +61,21 @@
   std::string Id;
 };
 
+// Operators that take a single node Id as an argument.
+enum class UnaryNodeOperator {
+  Parens,
+  Deref,
+  Address,
+};
+
+// Generic container for stencil operations with a (single) node-id argument.
+struct UnaryOperationData {
+  UnaryOperationData(UnaryNodeOperator Op, std::string Id)
+  : Op(Op), Id(std::move(Id)) {}
+  UnaryNodeOperator Op;
+  std::string Id;
+};
+
 // The fragment of code corresponding to the selected range.
 struct SelectorData {
   explicit SelectorData(RangeSelector S) : Selector(std::move(S)) {}
@@ -91,6 +107,10 @@
   return A.Id == B.Id;
 }
 
+bool isEqualData(const UnaryOperationData &A, const UnaryOperationData &B) {
+  return A.Op == B.Op && A.Id == B.Id;
+}
+
 // Equality is not (yet) defined for \c RangeSelector.
 bool isEqualData(const SelectorData &, const SelectorData &) { return false; }
 
@@ -130,6 +150,32 @@
   return Error::success();
 }
 
+Error evalData(const UnaryOperationData &Data,
+   const MatchFinder::MatchResult &Match, std::string *Result) {
+  const auto *E = Match.Nodes.getNodeAs(Data.Id);
+  if (E == nullptr)
+return llvm::make_error(
+errc::invalid_argument, "Id not bound or not Expr: " + Data.Id);
+  llvm::Optional Source;
+  switch (Data.Op) {
+  case UnaryNodeOperator::Parens:
+Source = buildParens(*E, *Match.Context);
+break;
+  case UnaryNodeOperator::Deref:
+Source = buildDereference(*E, *Match.Context);
+break;
+  case UnaryNodeOperator::Address:
+Source = buildAddressOf(*E, *Match.Context);
+break;
+  }
+  if (!Source)
+return llvm::make_error(
+errc::invalid_argument,
+"Could not construct expression source from ID: " + Data.Id);
+  *Result += *Source;
+  return Error::success();
+}
+
 Error evalData(const SelectorData &Data, const MatchFinder::MatchResult &Match,
std::string *Result) {
   auto Range = Data.Selector(Match);
@@ -239,6 +285,21 @@
   return StencilPart(std::make_shared>(Id));
 }
 
+StencilPart stencil::expression(llvm::StringRef Id) {
+  return StencilPart(std::make_shared>(
+  UnaryNodeOperator::Parens, Id));
+}
+
+StencilPart stencil::deref(llvm::StringRef ExprId) {
+  return StencilPart(std::make_shared>(
+  UnaryNodeOperator::Deref, ExprId));
+}
+
+StencilPart stencil::addressOf(llvm::StringRef ExprId) {
+  return StencilPart(std::make_shared>(
+  UnaryNodeOperator::Address, ExprId));
+}
+
 StencilPart stencil::access(StringRef BaseId, StencilPart Member) {
   return StencilPart(
   std::make_shared>(BaseId, std::move(Member)));
Index: cfe/trunk/unittests/Tooling/StencilTest.cpp
===
--- cfe/trunk/unittests/Tooling/StencilTest.cpp
+++ cfe/trunk/unittests/Tooling/StencilTest.cpp
@@ -20,14 +20,19 @@
 using namespace ast_matchers;
 
 namespace {
+using ::llvm::Failed;
 using ::llvm::HasValue;
+using ::llvm::StringError;
 using ::testing::AllOf;
 using ::testing::Eq;
 using ::testing::HasSubstr;
 using MatchResult = MatchFinder::MatchResult;
 using stencil::access;
+using stencil::addressOf;
 using stencil::cat;
+using stencil::deref;
 using stencil::dPrint;
+using stencil::expression;
 using stencil::ifBound;
 using stencil::run;
 using stencil::text;
@@ -104,7 +109,7 @@
   ADD_FAILURE() << "Expected failure but succeeded: " << *ResultOrErr;
 } else {
   auto Err = llvm::handleErrors(ResultOrErr.takeError(),
-[&Matcher](const llvm::StringError &Err) {
+[&Matcher](const StringError &Err) {
   EXPECT_THAT(Err.getMessa

[PATCH] D68274: [Alignment][Clang][NFC] Add CharUnits::getAsAlign

2019-10-03 Thread Guillaume Chatelet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373592: [Alignment][Clang][NFC] Add CharUnits::getAsAlign 
(authored by gchatelet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68274?vs=222994&id=222996#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68274

Files:
  cfe/trunk/include/clang/AST/CharUnits.h
  cfe/trunk/lib/CodeGen/CGCUDANV.cpp
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/CodeGen/CGCleanup.cpp
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprAgg.cpp
  cfe/trunk/lib/CodeGen/CGExprCXX.cpp
  cfe/trunk/lib/CodeGen/CGExprConstant.cpp
  cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
  cfe/trunk/lib/CodeGen/CGObjCMac.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/ConstantInitBuilder.cpp
  cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp

Index: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -2355,7 +2355,7 @@
   /*isConstant=*/false, llvm::GlobalVariable::ExternalLinkage,
   /*Initializer=*/nullptr, VarName,
   /*InsertBefore=*/nullptr, llvm::GlobalVariable::GeneralDynamicTLSModel);
-  GV->setAlignment(Align.getQuantity());
+  GV->setAlignment(Align.getAsAlign());
   return ConstantAddress(GV, Align);
 }
 
@@ -2498,7 +2498,7 @@
  GV->getLinkage(), Zero, GuardName.str());
 GuardVar->setVisibility(GV->getVisibility());
 GuardVar->setDLLStorageClass(GV->getDLLStorageClass());
-GuardVar->setAlignment(GuardAlign.getQuantity());
+GuardVar->setAlignment(GuardAlign.getAsAlign());
 if (GuardVar->isWeakForLinker())
   GuardVar->setComdat(
   CGM.getModule().getOrInsertComdat(GuardVar->getName()));
Index: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp
@@ -907,7 +907,7 @@
  llvm::GlobalVariable::NotThreadLocal,
 CGM.getContext().getTargetAddressSpace(addressSpace));
   emitter.finalize(GV);
-  GV->setAlignment(Align.getQuantity());
+  GV->setAlignment(Align.getAsAlign());
   CGM.setAddrOfConstantCompoundLiteral(E, GV);
   return ConstantAddress(GV, Align);
 }
Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
===
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
@@ -1442,7 +1442,7 @@
   CovDataVal, llvm::getCoverageMappingVarName());
 
   CovData->setSection(getCoverageSection(CGM));
-  CovData->setAlignment(8);
+  CovData->setAlignment(llvm::Align(8));
 
   // Make sure the data doesn't get deleted.
   CGM.addUsedGlobal(CovData);
Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -3841,7 +3841,7 @@
   AI = CreateTempAlloca(ArgStruct, "argmem");
 }
 auto Align = CallInfo.getArgStructAlignment();
-AI->setAlignment(llvm::MaybeAlign(Align.getQuantity()));
+AI->setAlignment(Align.getAsAlign());
 AI->setUsedWithInAlloca(true);
 assert(AI->isUsedWithInAlloca() && !AI->isStaticAlloca());
 ArgMemory = Address(AI, Align);
Index: cfe/trunk/lib/CodeGen/ConstantInitBuilder.cpp
===
--- cfe/trunk/lib/CodeGen/ConstantInitBuilder.cpp
+++ cfe/trunk/lib/CodeGen/ConstantInitBuilder.cpp
@@ -79,7 +79,7 @@
  /*insert before*/ nullptr,
  llvm::GlobalValue::NotThreadLocal,
  addressSpace);
-  GV->setAlignment(alignment.getQuantity());
+  GV->setAlignment(alignment.getAsAlign());
   resolveSelfReferences(GV);
   return GV;
 }
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.h
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h
@@ -1034,7 +1034,7 @@
 assert(isInConditionalBranch());
 llvm::BasicBlock *block = OutermostConditional->getStartingBlock();
 auto store = new llvm::StoreInst(value, addr.getPointer(), &block->back());
-store->setAlignment(addr.getAlignment().getQuantity());
+store->s

[PATCH] D62525: [Analyzer] Add new visitor to the iterator checkers

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

In D62525#1609334 , @NoQ wrote:

> Ok, so is it problematic to define a lambda that checks whether an 
> interesting iterator is invalidated? Or is it difficult to return the note 
> tag from many stack frames in order to finally squeeze it into the transition?


Both. The lambda can iterator through all the iterator positions, but how could 
it know which one was just invalidated? Or incremented, decremented, reached 
the first position or the past-the end position? We do not keep history. 
Returning note tags and passing them through all the functions called, 
combining them is a nightmare. It makes the code totally unreadable and I am 
not even sure how to do it correctly. Note tags are great, but here a 
conventional visitor fits better.


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

https://reviews.llvm.org/D62525



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


r373595 - [Alignment][NFC] Remove StoreInst::setAlignment(unsigned)

2019-10-03 Thread Guillaume Chatelet via cfe-commits
Author: gchatelet
Date: Thu Oct  3 06:17:21 2019
New Revision: 373595

URL: http://llvm.org/viewvc/llvm-project?rev=373595&view=rev
Log:
[Alignment][NFC] Remove StoreInst::setAlignment(unsigned)

Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: 
http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet, bollu, jdoerfert

Subscribers: hiraditya, asbirlea, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=373595&r1=373594&r2=373595&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Oct  3 06:17:21 2019
@@ -11193,7 +11193,7 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 // Unaligned nontemporal store of the scalar value.
 StoreInst *SI = Builder.CreateDefaultAlignedStore(Src, BC);
 SI->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node);
-SI->setAlignment(1);
+SI->setAlignment(llvm::Align::None());
 return SI;
   }
   // Rotate is a special case of funnel shift - 1st 2 args are the same.


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


[PATCH] D68268: [Alignment][NFC] Remove StoreInst::setAlignment(unsigned)

2019-10-03 Thread Guillaume Chatelet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373595: [Alignment][NFC] Remove 
StoreInst::setAlignment(unsigned) (authored by gchatelet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D68268?vs=222991&id=223000#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68268

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  llvm/trunk/include/llvm/IR/IRBuilder.h
  llvm/trunk/include/llvm/IR/Instructions.h
  llvm/trunk/lib/CodeGen/AtomicExpandPass.cpp
  llvm/trunk/lib/IR/Core.cpp
  llvm/trunk/lib/IR/Instructions.cpp
  llvm/trunk/lib/Transforms/IPO/Attributor.cpp
  llvm/trunk/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp
  llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
  llvm/trunk/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
  llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
  llvm/trunk/lib/Transforms/Scalar/LICM.cpp
  llvm/trunk/lib/Transforms/Scalar/SROA.cpp
  llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
  polly/trunk/lib/CodeGen/BlockGenerators.cpp

Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -11193,7 +11193,7 @@
 // Unaligned nontemporal store of the scalar value.
 StoreInst *SI = Builder.CreateDefaultAlignedStore(Src, BC);
 SI->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node);
-SI->setAlignment(1);
+SI->setAlignment(llvm::Align::None());
 return SI;
   }
   // Rotate is a special case of funnel shift - 1st 2 args are the same.
Index: llvm/trunk/lib/Transforms/IPO/Attributor.cpp
===
--- llvm/trunk/lib/Transforms/IPO/Attributor.cpp
+++ llvm/trunk/lib/Transforms/IPO/Attributor.cpp
@@ -2467,7 +2467,7 @@
   if (SI->getAlignment() < getAssumedAlign()) {
 STATS_DECLTRACK(AAAlign, Store,
 "Number of times alignemnt added to a store");
-SI->setAlignment(getAssumedAlign());
+SI->setAlignment(Align(getAssumedAlign()));
 Changed = ChangeStatus::CHANGED;
   }
   } else if (auto *LI = dyn_cast(U.getUser())) {
Index: llvm/trunk/lib/Transforms/Scalar/SROA.cpp
===
--- llvm/trunk/lib/Transforms/Scalar/SROA.cpp
+++ llvm/trunk/lib/Transforms/Scalar/SROA.cpp
@@ -3127,7 +3127,7 @@
   Value *Op = SI->getOperand(0);
   StoreAlign = DL.getABITypeAlignment(Op->getType());
 }
-SI->setAlignment(std::min(StoreAlign, getSliceAlign()));
+SI->setAlignment(MaybeAlign(std::min(StoreAlign, getSliceAlign(;
 continue;
   }
 
Index: llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
===
--- llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
+++ llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
@@ -894,8 +894,8 @@
   ++NumLoadsRemoved;
 } else if (auto *ReplacementStore = dyn_cast(Repl)) {
   ReplacementStore->setAlignment(
-  std::min(ReplacementStore->getAlignment(),
-   cast(I)->getAlignment()));
+  MaybeAlign(std::min(ReplacementStore->getAlignment(),
+  cast(I)->getAlignment(;
   ++NumStoresRemoved;
 } else if (auto *ReplacementAlloca = dyn_cast(Repl)) {
   ReplacementAlloca->setAlignment(
Index: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
===
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp
@@ -1790,7 +1790,7 @@
   StoreInst *NewSI = new StoreInst(LiveInValue, Ptr, InsertPos);
   if (UnorderedAtomic)
 NewSI->setOrdering(AtomicOrdering::Unordered);
-  NewSI->setAlignment(Alignment);
+  NewSI->setAlignment(MaybeAlign(Alignment));
   NewSI->setDebugLoc(DL);
   if (AATags)
 NewSI->setAAMetadata(AATags);
Index: llvm/trunk/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
===
--- llvm/trunk/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
+++ llvm/trunk/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
@@ -329,7 +329,7 @@
 SI->getPointerOperand(), SE);
 
   if (NewAlignment > SI->getAlignment()) {
-SI->setAlignment(NewAlignment);
+SI->setAlignment(MaybeAlign(NewAlignment));
 ++NumStoreAlignChanged;
   }
 } else if (MemIntrinsic *MI = dyn_cast(J)) {
Index: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
===
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp

[PATCH] D68388: [PR41008][OpenCL] Support restrict keyword in C++ mode

2019-10-03 Thread Kévin Petit via Phabricator via cfe-commits
kpet created this revision.
kpet added a reviewer: Anastasia.
Herald added subscribers: cfe-commits, kristof.beyls, yaxunl.
Herald added a project: clang.

Just enable it in C++ for OpenCL but not in C++.

Signed-off-by: Kevin Petit 


Repository:
  rC Clang

https://reviews.llvm.org/D68388

Files:
  clang/include/clang/Basic/TokenKinds.def
  clang/test/CodeGenOpenCLCXX/kernel-arg-info.cl

Index: clang/test/CodeGenOpenCLCXX/kernel-arg-info.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/kernel-arg-info.cl
@@ -0,0 +1,130 @@
+// RUN: %clang_cc1 %s -cl-std=clc++ -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=clc++ -emit-llvm -o - -triple spir-unknown-unknown -cl-kernel-arg-info | FileCheck %s -check-prefix ARGINFO
+
+kernel void foo(global int * globalintp, global int * restrict globalintrestrictp,
+global const int * globalconstintp,
+global const int * restrict globalconstintrestrictp,
+constant int * constantintp, constant int * restrict constantintrestrictp,
+global const volatile int * globalconstvolatileintp,
+global const volatile int * restrict globalconstvolatileintrestrictp,
+global volatile int * globalvolatileintp,
+global volatile int * restrict globalvolatileintrestrictp,
+local int * localintp, local int * restrict localintrestrictp,
+local const int * localconstintp,
+local const int * restrict localconstintrestrictp,
+local const volatile int * localconstvolatileintp,
+local const volatile int * restrict localconstvolatileintrestrictp,
+local volatile int * localvolatileintp,
+local volatile int * restrict localvolatileintrestrictp,
+int X, const int constint, const volatile int constvolatileint,
+volatile int volatileint) {
+  *globalintrestrictp = constint + volatileint;
+}
+// CHECK: define spir_kernel void @foo{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[MD11:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD12:[0-9]+]]
+// CHECK: !kernel_arg_type ![[MD13:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[MD13]]
+// CHECK: !kernel_arg_type_qual ![[MD14:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[MD15:[0-9]+]]
+
+kernel void foo2(read_only image1d_t img1, image2d_t img2, write_only image2d_array_t img3, read_write image1d_t img4) {
+}
+// CHECK: define spir_kernel void @foo2{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[MD21:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD22:[0-9]+]]
+// CHECK: !kernel_arg_type ![[MD23:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[MD23]]
+// CHECK: !kernel_arg_type_qual ![[MD24:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[MD25:[0-9]+]]
+
+kernel void foo3(__global half * X) {
+}
+// CHECK: define spir_kernel void @foo3{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[MD31:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD32:[0-9]+]]
+// CHECK: !kernel_arg_type ![[MD33:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[MD33]]
+// CHECK: !kernel_arg_type_qual ![[MD34:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[MD35:[0-9]+]]
+
+typedef unsigned int myunsignedint;
+kernel void foo4(__global unsigned int * X, __global myunsignedint * Y) {
+}
+// CHECK: define spir_kernel void @foo4{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[MD41:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD42:[0-9]+]]
+// CHECK: !kernel_arg_type ![[MD43:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[MD44:[0-9]+]]
+// CHECK: !kernel_arg_type_qual ![[MD45:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[MD46:[0-9]+]]
+
+typedef image1d_t myImage;
+kernel void foo5(myImage img1, write_only image1d_t img2) {
+}
+// CHECK: define spir_kernel void @foo5{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[MD41:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD51:[0-9]+]]
+// CHECK: !kernel_arg_type ![[MD52:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[MD53:[0-9]+]]
+// CHECK: !kernel_arg_type_qual ![[MD45]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[MD54:[0-9]+]]
+
+typedef char char16 __attribute__((ext_vector_type(16)));
+__kernel void foo6(__global char16 arg[]) {}
+// CHECK: !kernel_arg_type ![[MD61:[0-9]+]]
+// ARGINFO: !kernel_arg_name ![[MD62:[0-9]+]]
+
+typedef read_only  image1d_t ROImage;
+typedef write_only image1d_t WOImage;
+typedef read_write image1d_t RWImage;
+kernel void foo7(ROImage ro, WOImage wo, RWImage rw) {
+}
+// CHECK: define spir_kernel void @foo7{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[MD71:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD72:[0-9]+]]
+// CHECK: !kernel_arg_type ![[MD73:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[MD74:[0-9]+]]
+// CHECK: !kernel_arg_type_qual ![[MD75:[0-9]+]

RE: r373247 - Teach CallGraph to look into Generic Lambdas.

2019-10-03 Thread Keane, Erich via cfe-commits
Yep, I agree.  I tend to figure if I can get it done in ~1-2 hours, that I 
could just fix it.  Note that this was 1:30 😊

From: Nico Weber 
Sent: Wednesday, October 2, 2019 4:37 PM
To: Keane, Erich 
Cc: cfe-commits 
Subject: Re: r373247 - Teach CallGraph to look into Generic Lambdas.

Thanks!

If it takes a few hours to investigate, I think it's better to revert first and 
then investigate while the tree is green.

On Mon, Sep 30, 2019 at 4:43 PM Keane, Erich 
mailto:erich.ke...@intel.com>> wrote:
Should be fixe din r373259

From: Nico Weber mailto:tha...@chromium.org>>
Sent: Monday, September 30, 2019 12:50 PM
To: Keane, Erich mailto:erich.ke...@intel.com>>
Cc: cfe-commits mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r373247 - Teach CallGraph to look into Generic Lambdas.

This broke a few clangd unit tests:

http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/38857/steps/ninja%20check%201/logs/FAIL%3A%20Clangd%20Unit%20Tests%3A%3AHover.Structured
http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/38857/steps/ninja%20check%201/logs/FAIL%3A%20Clangd%20Unit%20Tests%3A%3AHover.All
http://45.33.8.238/linux/680/step_7.txt

On Mon, Sep 30, 2019 at 3:10 PM Erich Keane via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: erichkeane
Date: Mon Sep 30 12:12:29 2019
New Revision: 373247

URL: http://llvm.org/viewvc/llvm-project?rev=373247&view=rev
Log:
Teach CallGraph to look into Generic Lambdas.

CallGraph visited LambdaExpr by getting the Call Operator from
CXXRecordDecl (LambdaExpr::getCallOperator calls
CXXRecordDecl::getLambdaCallOperator), which replaced generic lambda
call operators with the non-instantiated FunctionDecl.  The result was
that the CallGraph would only pick up non-dependent calls.

This patch does a few things:
1- Extend CXXRecordDecl to have a getDependentLambdaCallOperator, which
will get the FunctionTemplateDecl, rather than immediately getting the
TemplateDecl.
2- Define getLambdaCallOperator and getDependentLambdaCallOperator in
terms of a common function.
3- Extend LambdaExpr with a getDependentCallOperator, which just calls
the above function.
4- Changes CallGraph to handle Generic LambdaExprs.

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Analysis/CallGraph.cpp
cfe/trunk/test/Analysis/debug-CallGraph.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=373247&r1=373246&r2=373247&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Sep 30 12:12:29 2019
@@ -1172,6 +1172,10 @@ public:
   /// if this is a closure type.
   CXXMethodDecl *getLambdaCallOperator() const;

+  /// Retrieve the dependent lambda call operator of the closure type
+  /// if this is a templated closure type.
+  FunctionTemplateDecl *getDependentLambdaCallOperator() const;
+
   /// Retrieve the lambda static invoker, the address of which
   /// is returned by the conversion operator, and the body of which
   /// is forwarded to the lambda call operator.

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=373247&r1=373246&r2=373247&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Mon Sep 30 12:12:29 2019
@@ -1907,6 +1907,10 @@ public:
   /// lambda expression.
   CXXMethodDecl *getCallOperator() const;

+  /// Retrieve the function template call operator associated with this
+  /// lambda expression.
+  FunctionTemplateDecl *getDependentCallOperator() const;
+
   /// If this is a generic lambda expression, retrieve the template
   /// parameter list associated with it, or else return null.
   TemplateParameterList *getTemplateParameterList() const;

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=373247&r1=373246&r2=373247&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Mon Sep 30 12:12:29 2019
@@ -1399,17 +1399,25 @@ static bool allLookupResultsAreTheSame(c
 }
 #endif

-CXXMethodDecl* CXXRecordDecl::getLambdaCallOperator() const {
-  if (!isLambda()) return nullptr;
+NamedDecl* getLambdaCallOperatorHelper(const CXXRecordDecl &RD) {
+  if (!RD.isLambda()) return nullptr;
   DeclarationName Name =
-getASTContext().DeclarationNames.getCXXOperatorName(OO_Call);
-  DeclContext::lookup_result Calls = lookup(Name);
+RD.getASTContext().DeclarationNames.getCXXOperatorName(OO_Call);
+  DeclContext::lookup_result Calls = RD.lookup(Name)

[PATCH] D68388: [PR41008][OpenCL] Support restrict keyword in C++ mode

2019-10-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Is there a test that shows that that keyword is still not provided for C++ 
after this?


Repository:
  rC Clang

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

https://reviews.llvm.org/D68388



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


[PATCH] D67980: [WIP][CLANG][BPF] do compile-once run-everywhere relocation for bitfields

2019-10-03 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song marked 9 inline comments as done.
yonghong-song added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9321-9322
+  if (IsError)
+return IsBitField ? EmitLValue(Arg).getBitFieldPointer()
+  : EmitLValue(Arg).getPointer();
+

anakryiko wrote:
> move this under `if (!getDebugInfo)` above and ditch IsError completely?
yes. previously I have two case of errors. Now only have one, it makes sense to 
merge them.



Comment at: llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp:235
   report_fatal_error("Missing metadata for 
llvm.preserve.array.access.index intrinsic");
-AccessIndex = cast(Call->getArgOperand(2))
-  ->getZExtValue();
+AccessIndex = getConstant(Call->getArgOperand(2));
 return true;

anakryiko wrote:
> getConstant returns u64, but AccessIndex is u32, is that a concern?
it should be okay. the call is generated by clang where the access index will 
be in the range. Also, llvm ConstantInt class can only return 64bit values.
https://llvm.org/doxygen/classllvm_1_1ConstantInt.html
We just do the cast here. should be okay.



Comment at: llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp:254
+  }
+  if (GV->getName().startswith("llvm.bpf.get.field.info")) {
+Kind = BPFGetFieldInfoAI;

anakryiko wrote:
> just curious, why did you decide to not follow llvm.preserve.xxx pattern 
> here? E.g., llvm.preserve.field.info would read just fine, I guess?
previously i am using preserve.field.info and switch to get.field.info as it is 
indeed to return certain field info to the user. maybe we should get back to 
preserve.field.info to indicate that relocation is generated. will do.



Comment at: llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp:533
+  auto *MemberTy = cast(CTy->getElements()[AccessIndex]);
+  assert(MemberTy->isBitField());
+  uint64_t OffsetInBits = MemberTy->getOffsetInBits();

anakryiko wrote:
> is it possible to allow capturing same bitfield information for non-bitfield 
> integers?
> 
> E.g, if my current vmlinux.h has some field as plain integer, but I know that 
> some older kernel (or maybe future kernels?) had this field as a bitfield, I 
> won't have to do anything nasty just to handle this generically. The less 
> artificial restrictions we have, the better, IMO.
Yes, we can remove this restriction. Let us first get bitfield interface right 
and then extend them to nonbitfield.



Comment at: llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp:536
+  uint64_t SizeInBits = MemberTy->getSizeInBits();
+  assert(SizeInBits <= 63);
+  switch (InfoKind) {

anakryiko wrote:
> I think we should be generic here and allow up to 128 bits and let libbpf 
> handle its limitations separately (e.g., if we can't support >64 bits 
> initially, libbpf will reject the program; but if we ever extend the support, 
> at least we won't have to go back to Clang and fix it up).
We can do this.



Comment at: llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp:541-548
+  case BPFCoreSharedInfo::BTF_FIELD_BF_BYTE_OFFSET_64BIT_ALIGN:
+PatchImm = (OffsetInBits & ~0x3f) >> 3;
+break;
+  case BPFCoreSharedInfo::BTF_FIELD_BF_LSHIFT_64BIT_ALIGN:
+PatchImm = OffsetInBits & 0x3f;
+break;
+  case BPFCoreSharedInfo::BTF_FIELD_BF_RSHIFT_64BIT_ALIGN:

anakryiko wrote:
> I'll need to do some drawing and math to check how this is going to be 
> handled in big-endian and little-endian, I'll get back to you later with that.
sounds great.



Comment at: llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp:600
+
+  PatchImm += FirstIndex * Ty->getSizeInBits() >> 3;
   break;

anakryiko wrote:
> nit: I can't from the top of my head figure out what takes precedence: shift 
> or multiplication, maybe add parens to make it obvious?
sure.



Comment at: llvm/lib/Target/BPF/BTFDebug.cpp:1163
+// Emit "mov ri, " for patched immediate.
+int64_t Imm = PatchImms[GVar->getName().str()];
 OutMI.setOpcode(BPF::MOV_ri);

anakryiko wrote:
> why int64?
Will change to u32.



Comment at: llvm/lib/Target/BPF/BTFDebug.h:227
 /// Represent one offset relocation.
 struct BTFOffsetReloc {
   const MCSymbol *Label;  ///< MCSymbol identifying insn for the reloc

anakryiko wrote:
> nit: this is not BTFOffsetReloc anymore, more like BTFFieldReloc
Yes, it becomes FieldReloc now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67980



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


[PATCH] D67185: [RISCV] Add support for -ffixed-xX flags

2019-10-03 Thread Simon Cook via Phabricator via cfe-commits
simoncook updated this revision to Diff 223005.
simoncook added a reviewer: luismarques.
simoncook added a comment.

Rebase on top of tree, add @luismarques as reviewer


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67185

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-fixed-x-register.c
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/lib/Target/RISCV/RISCVRegisterInfo.h
  llvm/lib/Target/RISCV/RISCVSubtarget.cpp
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/reserved-reg-errors.ll
  llvm/test/CodeGen/RISCV/reserved-regs.ll

Index: llvm/test/CodeGen/RISCV/reserved-regs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/reserved-regs.ll
@@ -0,0 +1,130 @@
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x3 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X3
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x3 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X3
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x4 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X4
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x4 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X4
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x5 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X5
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x5 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X5
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x6 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X6
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x6 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X6
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x7 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X7
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x7 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X7
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x8 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X8
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x8 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X8
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x9 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X9
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x9 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X9
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x10 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X10
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x10 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X10
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x11 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X11
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x11 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X11
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x12 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X12
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x12 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X12
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x13 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X13
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x13 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X13
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x14 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X14
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x14 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X14
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x15 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X15
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x15 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X15
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x16 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X16
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x16 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X16
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x17 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X17
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x17 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X17
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x18 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X18
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x18 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X18
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x19 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X19
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x19 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X19
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x20 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X20
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x20 -verify-machineinstrs < %s | FileCheck %s -check-prefix=X20
+; RUN: llc -mtriple=riscv3

[PATCH] D68300: [HIP] Add option -fno-link-builtin-bitcode to disable linking device lib

2019-10-03 Thread Michael Liao via Phabricator via cfe-commits
hliao added inline comments.



Comment at: include/clang/Driver/Options.td:606
+def flink_builtin_bitcode : Flag<["-"], "flink-builtin-bitcode">,
+  Flags<[CC1Option]>, HelpText<"Link builtin bitcode for HIP device 
compilation.">;
+def fno_link_builtin_bitcode : Flag<["-"], "fno-link-builtin-bitcode">;

tra wrote:
> yaxunl wrote:
> > ashi1 wrote:
> > > Since this is a more generic approach, we won't need to specify HIP ?
> > this patch only implemented this option for HIP. If it is used for other 
> > languages, this help text should be updated.
> Hmm. Cuda currently uses `-nocudalib` for essentially the same purpose (Sort 
> of like `-nostdlib`, but for CUDA). Perhaps we should consolidate all these 
> into `-nogpulib` and alias `-nocudalib` to it. 
how about other relevant options, such as replacing cuda-device-only with 
gpu-device-only or hip-device-only to avoid confusing with CUDA.


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

https://reviews.llvm.org/D68300



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


[PATCH] D68391: [RISCV] Improve sysroot computation if no GCC install detected

2019-10-03 Thread Edward Jones via Phabricator via cfe-commits
edward-jones created this revision.
Herald added subscribers: cfe-commits, pzheng, simoncook, s.egerton, lenary, 
Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, 
rogfer01, zzheng, MaskRay, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, 
apazos, johnrusso, rbar, asb.
Herald added a project: clang.

If a GCC installed is not detected, the driver would default to the root of the 
filesystem. This is not ideal when this doesn't match the install directory of 
the toolchain and can cause undesireable behavior such as picking up system 
libraries or the system linker when cross-compiling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68391

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


Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -73,17 +73,20 @@
   if (!getDriver().SysRoot.empty())
 return getDriver().SysRoot;
 
-  if (!GCCInstallation.isValid())
-return std::string();
-
-  StringRef LibDir = GCCInstallation.getParentLibPath();
-  StringRef TripleStr = GCCInstallation.getTriple().str();
-  std::string SysRootDir = LibDir.str() + "/../" + TripleStr.str();
+  SmallString<128> SysRootDir;
+  if (GCCInstallation.isValid()) {
+StringRef LibDir = GCCInstallation.getParentLibPath();
+StringRef TripleStr = GCCInstallation.getTriple().str();
+llvm::sys::path::append(SysRootDir, LibDir, "..", TripleStr);
+  } else {
+llvm::sys::path::append(SysRootDir, getDriver().Dir, "..",
+getTriple().str());
+  }
 
   if (!llvm::sys::fs::exists(SysRootDir))
 return std::string();
 
-  return SysRootDir;
+  return SysRootDir.str();
 }
 
 void RISCV::Linker::ConstructJob(Compilation &C, const JobAction &JA,


Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -73,17 +73,20 @@
   if (!getDriver().SysRoot.empty())
 return getDriver().SysRoot;
 
-  if (!GCCInstallation.isValid())
-return std::string();
-
-  StringRef LibDir = GCCInstallation.getParentLibPath();
-  StringRef TripleStr = GCCInstallation.getTriple().str();
-  std::string SysRootDir = LibDir.str() + "/../" + TripleStr.str();
+  SmallString<128> SysRootDir;
+  if (GCCInstallation.isValid()) {
+StringRef LibDir = GCCInstallation.getParentLibPath();
+StringRef TripleStr = GCCInstallation.getTriple().str();
+llvm::sys::path::append(SysRootDir, LibDir, "..", TripleStr);
+  } else {
+llvm::sys::path::append(SysRootDir, getDriver().Dir, "..",
+getTriple().str());
+  }
 
   if (!llvm::sys::fs::exists(SysRootDir))
 return std::string();
 
-  return SysRootDir;
+  return SysRootDir.str();
 }
 
 void RISCV::Linker::ConstructJob(Compilation &C, const JobAction &JA,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68394: [HIP] Enable specifying different default gpu arch for HIP/CUDA.

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68394

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-default-gpu-arch.hip


Index: clang/test/Driver/hip-default-gpu-arch.hip
===
--- /dev/null
+++ clang/test/Driver/hip-default-gpu-arch.hip
@@ -0,0 +1,7 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -x hip -c %s 2>&1 | FileCheck %s
+
+// CHECK: {{.*}}clang{{.*}}"-target-cpu" "gfx600"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2329,6 +2329,10 @@
 
 /// Flag for -fgpu-rdc.
 bool Relocatable = false;
+
+/// Default GPU architecture if there's no one specified.
+CudaArch DefaultCudaArch = CudaArch::UNKNOWN;
+
   public:
 CudaActionBuilderBase(Compilation &C, DerivedArgList &Args,
   const Driver::InputList &Inputs,
@@ -2518,7 +2522,7 @@
   // supported GPUs.  sm_20 code should work correctly, if
   // suboptimally, on all newer GPUs.
   if (GpuArchList.empty())
-GpuArchList.push_back(CudaArch::SM_20);
+GpuArchList.push_back(DefaultCudaArch);
 
   return Error;
 }
@@ -2530,7 +2534,9 @@
   public:
 CudaActionBuilder(Compilation &C, DerivedArgList &Args,
   const Driver::InputList &Inputs)
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {
+  DefaultCudaArch = CudaArch::SM_20;
+}
 
 ActionBuilderReturnCode
 getDeviceDependences(OffloadAction::DeviceDependences &DA,
@@ -2645,7 +2651,9 @@
   public:
 HIPActionBuilder(Compilation &C, DerivedArgList &Args,
  const Driver::InputList &Inputs)
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {
+  DefaultCudaArch = CudaArch::GFX600;
+}
 
 bool canUseBundlerUnbundler() const override { return true; }
 


Index: clang/test/Driver/hip-default-gpu-arch.hip
===
--- /dev/null
+++ clang/test/Driver/hip-default-gpu-arch.hip
@@ -0,0 +1,7 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -x hip -c %s 2>&1 | FileCheck %s
+
+// CHECK: {{.*}}clang{{.*}}"-target-cpu" "gfx600"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2329,6 +2329,10 @@
 
 /// Flag for -fgpu-rdc.
 bool Relocatable = false;
+
+/// Default GPU architecture if there's no one specified.
+CudaArch DefaultCudaArch = CudaArch::UNKNOWN;
+
   public:
 CudaActionBuilderBase(Compilation &C, DerivedArgList &Args,
   const Driver::InputList &Inputs,
@@ -2518,7 +2522,7 @@
   // supported GPUs.  sm_20 code should work correctly, if
   // suboptimally, on all newer GPUs.
   if (GpuArchList.empty())
-GpuArchList.push_back(CudaArch::SM_20);
+GpuArchList.push_back(DefaultCudaArch);
 
   return Error;
 }
@@ -2530,7 +2534,9 @@
   public:
 CudaActionBuilder(Compilation &C, DerivedArgList &Args,
   const Driver::InputList &Inputs)
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {
+  DefaultCudaArch = CudaArch::SM_20;
+}
 
 ActionBuilderReturnCode
 getDeviceDependences(OffloadAction::DeviceDependences &DA,
@@ -2645,7 +2651,9 @@
   public:
 HIPActionBuilder(Compilation &C, DerivedArgList &Args,
  const Driver::InputList &Inputs)
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {
+  DefaultCudaArch = CudaArch::GFX600;
+}
 
 bool canUseBundlerUnbundler() const override { return true; }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68394: [HIP] Enable specifying different default gpu arch for HIP/CUDA.

2019-10-03 Thread Michael Liao via Phabricator via cfe-commits
hliao marked an inline comment as done.
hliao added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:2655
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {
+  DefaultCudaArch = CudaArch::GFX600;
+}

Sam, could you let me know which reasonable default arch should we use here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68394



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


[PATCH] D68165: [analyzer][MallocChecker][NFC] Split checkPostCall up, deploy CallDescriptionMap

2019-10-03 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:378-379
+
+  using CheckFn = void (MallocChecker::*)(CheckerContext &C, const CallExpr 
*CE,
+  ProgramStateRef State) const;
+

Szelethus wrote:
> Szelethus wrote:
> > NoQ wrote:
> > > Whenever i see a (`CE`, `State`) pair, it screams `CallEvent` to me. That 
> > > said, i'm worried that `State` in these callbacks isn't necessarily equal 
> > > to `C.getState()` (the latter, by the way, is always equal to the 
> > > `CallEvent`'s `.getState()` - that's a relief, right?), so if you'll ever 
> > > be in the mood to check that, that'd be great :)
> > It should be always equal to it. I'll change it.
> Hmmm, I tried making this take a (`CallEvent`, `CheckerContext`), but it 
> bloated the code for little gain, since every handler function would start 
> with the retrieval of the state and the call expression. That said, I could 
> cascade these down to `FreeMemAux`, `MallocMemAux`, etc, to also take this 
> pair instead, but I'll be honest, I don't see point until something actually 
> breaks.
This is the standard way in the checkers: almost every handler function starts 
with the retrieval of the state from the `CheckerContext`. The only reason for 
an extra `State` parameter is that sometimes we create more states in the lower 
level functions but only add the final one to the `CheckerContext` as a new 
transition. Does something like this happen here?



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:865
+  if (FreeingMemFnMap.lookup(Call))
 return true;
 

Maybe `return !!FreeingMemFnMap.lookup(Call)`?



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:879
+bool MallocChecker::isMemCall(const CallEvent &Call) const {
+  if (FreeingMemFnMap.lookup(Call) || NonFreeingMemFnMap.lookup(Call))
 return true;

Same here: why not just `return FreeingMemFnMap.lookup(Call) || 
NonFreeingMemFn.lookup(Call)`?


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

https://reviews.llvm.org/D68165



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


[PATCH] D68391: [RISCV] Improve sysroot computation if no GCC install detected

2019-10-03 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

Before falling back to returning the empty string this first looks for a 
directory with the triple name up one level from the driver.

This uses the Triple string in the path, however this Triple has been 
normalized so even if the user specifies "clang --target=riscv32-unknown-elf", 
it will use "riscv32-unknown-unknown-elf" when looking for the sysroot. I am 
wondering whether it would be sensible to do a more "intelligent" search for 
the sysroot here by iteratively stripping "unknown"s from the triple.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68391



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


[PATCH] D68377: [Builtins] Teach Clang about memccpy

2019-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 223017.

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

https://reviews.llvm.org/D68377

Files:
  include/clang/Basic/Builtins.def


Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -480,6 +480,7 @@
 BUILTIN(__builtin_memchr, "v*vC*iz", "nF")
 BUILTIN(__builtin_memcmp, "ivC*vC*z", "nF")
 BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
+BUILTIN(__builtin_memccpy, "v*v*vC*iz", "nF")
 BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")
 BUILTIN(__builtin_mempcpy, "v*v*vC*z", "nF")
 BUILTIN(__builtin_memset, "v*v*iz", "nF")
@@ -979,6 +980,7 @@
 // when these functions are used in non-GNU mode. PR16138.
 LIBBUILTIN(alloca, "v*z", "f", "stdlib.h", ALL_GNU_LANGUAGES)
 // POSIX string.h
+LIBBUILTIN(memccpy, "v*v*vC*iz",  "f", "string.h", ALL_GNU_LANGUAGES)
 LIBBUILTIN(stpcpy, "c*c*cC*", "f", "string.h", ALL_GNU_LANGUAGES)
 LIBBUILTIN(stpncpy, "c*c*cC*z",   "f", "string.h", ALL_GNU_LANGUAGES)
 LIBBUILTIN(strdup, "c*cC*",   "f", "string.h", ALL_GNU_LANGUAGES)


Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -480,6 +480,7 @@
 BUILTIN(__builtin_memchr, "v*vC*iz", "nF")
 BUILTIN(__builtin_memcmp, "ivC*vC*z", "nF")
 BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
+BUILTIN(__builtin_memccpy, "v*v*vC*iz", "nF")
 BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")
 BUILTIN(__builtin_mempcpy, "v*v*vC*z", "nF")
 BUILTIN(__builtin_memset, "v*v*iz", "nF")
@@ -979,6 +980,7 @@
 // when these functions are used in non-GNU mode. PR16138.
 LIBBUILTIN(alloca, "v*z", "f", "stdlib.h", ALL_GNU_LANGUAGES)
 // POSIX string.h
+LIBBUILTIN(memccpy, "v*v*vC*iz",  "f", "string.h", ALL_GNU_LANGUAGES)
 LIBBUILTIN(stpcpy, "c*c*cC*", "f", "string.h", ALL_GNU_LANGUAGES)
 LIBBUILTIN(stpncpy, "c*c*cC*z",   "f", "string.h", ALL_GNU_LANGUAGES)
 LIBBUILTIN(strdup, "c*cC*",   "f", "string.h", ALL_GNU_LANGUAGES)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68364: Prototype implementation of P0784R7: mark all members of std::allocator and std::allocator_traits as constexpr.

2019-10-03 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

Thanks for doing this, Richard.
A few things:

- Needs tests (as you said)
- The config macro stuff is all wrong (we build that file from a template)
- Use `__libcpp_is_constant_evaluated` instead of 
`__builtin_is_constant_evaluated` because it doesn't have to be `#ifdef`ed. 
(see r364873 and r364884)
- If we're in a consteval block, we shouldn't be testing for exceptions being 
disabled, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68364



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


[PATCH] D63960: [C++20] Add consteval-specific semantic for functions

2019-10-03 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 223021.
Tyker marked 16 inline comments as done.
Tyker added a comment.

i addressed almost all comments.


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

https://reviews.llvm.org/D63960

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -12,6 +12,7 @@
 }
 
 constexpr auto l_eval = [](int i) consteval {
+// expected-note@-1+ {{declared here}}
 
   return i;
 };
@@ -23,6 +24,7 @@
 
 struct A {
   consteval int f1(int i) const {
+// expected-note@-1 {{declared here}}
 return i;
   }
   consteval A(int i);
@@ -62,3 +64,203 @@
 consteval int main() { // expected-error {{'main' is not allowed to be declared consteval}}
   return 0;
 }
+
+consteval int f_eval(int i) {
+// expected-note@-1+ {{declared here}}
+  return i;
+}
+
+namespace taking_address {
+
+using func_type = int(int);
+
+func_type* p1 = (&f_eval);
+// expected-error@-1 {{take address}}
+func_type* p7 = __builtin_addressof(f_eval);
+// expected-error@-1 {{take address}}
+
+auto p = f_eval;
+// expected-error@-1 {{take address}}
+
+auto m1 = &basic_sema::A::f1;
+// expected-error@-1 {{take address}}
+auto l1 = &decltype(basic_sema::l_eval)::operator();
+// expected-error@-1 {{take address}}
+
+consteval int f(int i) {
+// expected-note@-1+ {{declared here}}
+  return i;
+}
+
+auto ptr = &f;
+// expected-error@-1 {{take address}}
+
+auto f1() {
+  return &f;
+// expected-error@-1 {{take address}}
+}
+
+}
+
+namespace invalid_function {
+using size_t = unsigned long;
+struct A {
+  consteval void *operator new(size_t count);
+  // expected-error@-1 {{'operator new' cannot be declared consteval}}
+  consteval void *operator new[](size_t count);
+  // expected-error@-1 {{'operator new[]' cannot be declared consteval}}
+  consteval void operator delete(void* ptr);
+  // expected-error@-1 {{'operator delete' cannot be declared consteval}}
+  consteval void operator delete[](void* ptr);
+  // expected-error@-1 {{'operator delete[]' cannot be declared consteval}}
+};
+
+}
+
+namespace nested {
+consteval int f() {
+  return 0;
+}
+
+consteval int f1(...) {
+  return 1;
+}
+
+enum E {};
+
+using T = int(&)();
+
+consteval auto operator+ (E, int(*a)()) {
+  return 0;
+}
+
+void d() {
+  auto i = f1(E() + &f);
+}
+
+auto l0 = [](auto) consteval {
+  return 0;
+};
+
+int i0 = l0(&f1);
+
+int i1 = f1(l0(4));
+
+int i2 = f1(&f1, &f1, &f1, &f1, &f1, &f1, &f1);
+
+int i3 = f1(f1(f1(&f1, &f1), f1(&f1, &f1), f1(f1(&f1, &f1), &f1)));
+
+}
+
+namespace user_defined_literal {
+
+consteval int operator"" _test(unsigned long long i) {
+// expected-note@-1+ {{declared here}}
+  return 0;
+}
+
+int i = 0_test;
+
+auto ptr = &operator"" _test;
+// expected-error@-1 {{take address}}
+
+}
+
+namespace return_address {
+
+consteval int f() {
+  return 0;
+}
+
+consteval int(*ret1(int i))() {
+  return &f;
+}
+
+auto ptr = ret1(0);
+// expected-error@-1 {{could not be evaluated}}
+// expected-note@-2 {{pointer to a consteval}}
+
+struct A {
+  consteval int f(int) {
+return 0;
+  }
+};
+
+using mem_ptr_type = int (A::*)(int);
+
+template
+struct C {};
+
+C<&A::f> c;
+// expected-error@-1 {{is not a constant expression}}
+// expected-note@-2 {{pointer to a consteval}}
+
+consteval mem_ptr_type ret2() {
+  return &A::f;
+}
+
+C c1;
+// expected-error@-1 {{is not a constant expression}}
+// expected-note@-2 {{pointer to a consteval}}
+
+}
+
+namespace context {
+
+int g_i;
+// expected-note@-1 {{declared here}}
+
+consteval int f(int) {
+  return 0;
+}
+
+constexpr int c_i = 0;
+
+int t1 = f(g_i);
+// expected-error@-1 {{could not be evaluated}}
+// expected-note@-2 {{read of non-const variable}}
+int t3 = f(c_i);
+
+constexpr int f_c(int i) {
+// expected-note@-1 {{declared here}}
+  int t = f(i);
+// expected-error@-1 {{could not be evaluated}}
+// expected-note@-2 {{read of non-const variable}}
+  return f(0);  
+}
+
+consteval int f_eval(int i) {
+  return f(i);
+}
+
+auto l0 = [](int i) consteval {
+  return f(i);
+};
+
+auto l1 = [](int i) constexpr {
+// expected-note@-1 {{declared here}}
+  int t = f(i);
+// expected-error@-1 {{could not be evaluated}}
+// expected-note@-2 {{read of non-const variable}}
+  return f(0);  
+};
+
+}
+
+namespace cleanup {
+
+struct A {
+  int *p = new int(42);
+  consteval int get() { ret

[PATCH] D63960: [C++20] Add consteval-specific semantic for functions

2019-10-03 Thread Tyker via Phabricator via cfe-commits
Tyker added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:11188-11189
 
+  ConstexprSpecKind ConstexprKind = DetermineSpecialMemberConstexprKind(
+  Constexpr, ClassDecl->hasDefaultedConstevalDefaultCtor());
+

rsmith wrote:
> I don't think this is necessary: implicit special members are never 
> `consteval`. (We use `DeclareImplicitDefaultConstructor` when there is no 
> user-declared default constructor, in which case there can't possibly be a 
> defaulted consteval default constructor.) I don't think you need any of the 
> `DetermineSpecialMemberConstexprKind` machinery, nor the tracking of 
> `DefaultedSpecialMemberIsConsteval` in `CXXRecordDecl`.
all the code you mention is to fixe an issue i saw while working on consteval.
the AST of
```
struct A {
consteval A() = default;
consteval A(int) { }
};
```
is
```
TranslationUnitDecl
`-CXXRecordDecl  line:1:8 struct A definition
  |-DefinitionData pass_in_registers empty standard_layout trivially_copyable 
trivial literal has_user_declared_ctor has_constexpr_non_copy_move_ctor 
can_const_default_init
  | |-DefaultConstructor exists trivial constexpr defaulted_is_constexpr
  | |-CopyConstructor simple trivial has_const_param needs_implicit 
implicit_has_const_param
  | |-MoveConstructor exists simple trivial needs_implicit
  | |-CopyAssignment trivial has_const_param needs_implicit 
implicit_has_const_param
  | |-MoveAssignment exists simple trivial needs_implicit
  | `-Destructor simple irrelevant trivial needs_implicit
  |-CXXRecordDecl  col:8 implicit referenced struct A
  |-CXXConstructorDecl  col:15 constexpr A 'void ()' default 
trivial noexcept-unevaluated 0x55585ae25160
  `-CXXConstructorDecl  col:15 consteval A 'void (int)'
|-ParmVarDecl  col:20 'int'
`-CompoundStmt 
```
[[ https://godbolt.org/z/oRx0Ss | godbolt ]]
notice that `A::A()` is marked as constexpr instead of consteval.
and `A::A(int)` is marked correctly.

this is because consteval defaulted special members are not marked as consteval.
those code changes are intended to fix that. with this patch both constructor 
are marked as consteval




Comment at: clang/lib/Sema/SemaExpr.cpp:15071
+llvm::PointerIntPair RHS) {
+  return LHS.getPointer()->getBeginLoc() < RHS.getPointer()->getBeginLoc();
+}

rsmith wrote:
> `<` on `SourceLocation` doesn't really mean anything. It's not correct to use 
> it here. Also, using source locations will not give you outer expressions 
> before inner ones. Consider:
> 
> ```
> enum E {};
> consteval E f();
> consteval int operator+(E, int);
> void g() {
>   f() + 1;
> }
> ```
> 
>  Here, the begin location of both the call to `f()` and the call to 
> `operator+` are in the same place: at the `f` token.
> 
> I don't think you need this sort at all: instead, you can process immediate 
> invocations in `ImmediateInvocationCandidates` in reverse order: 
> subexpressions must have been built before their enclosing expressions, so 
> walking in reverse order will guarantee that you process an outer candidate 
> before any inner ones.
the sort is used in combination with a lower_bounds in 
`ComplexRemove::TransformConstantExpr` to lookup in 
`ImmediateInvocationsCandidates` using binary search.
but i think your proposition is more efficient except in some very rare cases.




Comment at: clang/lib/Sema/SemaExpr.cpp:15102
+ExprCompType{});
+if (It != IISet.end()) {
+  It->setInt(1); // Mark as deleted

rsmith wrote:
> We should look for an exact match here, not merely for something nearby. 
> (Maybe: form a pointer set of immediate invocation pointer expressions, and 
> remove things from the set when you encounter them in this walk; then when 
> iterating over the immediate invocations, skip ones that have already been 
> erased from the set.)
the issue i had with a set is that we can't remove element during iteration as 
removing element invalidate iterators.
but to get an exact match we can use the pointer as "key", they are unique.


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

https://reviews.llvm.org/D63960



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


r373611 - Remove duplicate P->getAs() call. NFCI.

2019-10-03 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Oct  3 08:08:20 2019
New Revision: 373611

URL: http://llvm.org/viewvc/llvm-project?rev=373611&view=rev
Log:
Remove duplicate P->getAs() call. NFCI.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=373611&r1=373610&r2=373611&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Oct  3 08:08:20 2019
@@ -6851,8 +6851,8 @@ void ASTContext::getObjCEncodingForTypeI
   }
 } else if (Options.IsOutermostType()) {
   QualType P = PointeeTy;
-  while (P->getAs())
-P = P->getAs()->getPointeeType();
+  while (auto PT = P->getAs())
+P = PT->getPointeeType();
   if (P.isConstQualified()) {
 isReadOnly = true;
 S += 'r';


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


r373612 - ExprConstant - silence static analyzer getAs<> null dereference warnings. NFCI.

2019-10-03 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Oct  3 08:08:30 2019
New Revision: 373612

URL: http://llvm.org/viewvc/llvm-project?rev=373612&view=rev
Log:
ExprConstant - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these 
cases we should be able to use castAs<> directly and if not assert will fire 
for us.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=373612&r1=373611&r2=373612&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Oct  3 08:08:30 2019
@@ -6435,9 +6435,8 @@ class BufferToAPValueConverter {
 QualType RepresentationType = Ty->getDecl()->getIntegerType();
 assert(!RepresentationType.isNull() &&
"enum forward decl should be caught by Sema");
-const BuiltinType *AsBuiltin =
-RepresentationType.getCanonicalType()->getAs();
-assert(AsBuiltin && "non-integral enum underlying type?");
+const auto *AsBuiltin =
+RepresentationType.getCanonicalType()->castAs();
 // Recurse into the underlying type. Treat std::byte transparently as
 // unsigned char.
 return visit(AsBuiltin, Offset, /*EnumTy=*/Ty);
@@ -9360,7 +9359,7 @@ VectorExprEvaluator::VisitInitListExpr(c
 
 bool
 VectorExprEvaluator::ZeroInitialization(const Expr *E) {
-  const VectorType *VT = E->getType()->getAs();
+  const auto *VT = E->getType()->castAs();
   QualType EltTy = VT->getElementType();
   APValue ZeroElement;
   if (EltTy->isIntegerType())
@@ -11836,7 +11835,7 @@ bool IntExprEvaluator::VisitBinaryOperat
   Info.CCEDiag(E, diag::note_constexpr_pointer_subtraction_not_same_array);
 
 QualType Type = E->getLHS()->getType();
-QualType ElementType = Type->getAs()->getPointeeType();
+QualType ElementType = Type->castAs()->getPointeeType();
 
 CharUnits ElementSize;
 if (!HandleSizeof(Info, E->getExprLoc(), ElementType, ElementSize))
@@ -12733,9 +12732,9 @@ bool ComplexExprEvaluator::VisitCastExpr
 if (!Visit(E->getSubExpr()))
   return false;
 
-QualType To = E->getType()->getAs()->getElementType();
+QualType To = E->getType()->castAs()->getElementType();
 QualType From
-  = E->getSubExpr()->getType()->getAs()->getElementType();
+  = E->getSubExpr()->getType()->castAs()->getElementType();
 
 return HandleFloatToFloatCast(Info, E, From, To, Result.FloatReal) &&
HandleFloatToFloatCast(Info, E, From, To, Result.FloatImag);
@@ -12745,9 +12744,9 @@ bool ComplexExprEvaluator::VisitCastExpr
 if (!Visit(E->getSubExpr()))
   return false;
 
-QualType To = E->getType()->getAs()->getElementType();
+QualType To = E->getType()->castAs()->getElementType();
 QualType From
-  = E->getSubExpr()->getType()->getAs()->getElementType();
+  = E->getSubExpr()->getType()->castAs()->getElementType();
 Result.makeComplexInt();
 return HandleFloatToIntCast(Info, E, From, Result.FloatReal,
 To, Result.IntReal) &&
@@ -12769,9 +12768,9 @@ bool ComplexExprEvaluator::VisitCastExpr
 if (!Visit(E->getSubExpr()))
   return false;
 
-QualType To = E->getType()->getAs()->getElementType();
+QualType To = E->getType()->castAs()->getElementType();
 QualType From
-  = E->getSubExpr()->getType()->getAs()->getElementType();
+  = E->getSubExpr()->getType()->castAs()->getElementType();
 
 Result.IntReal = HandleIntToIntCast(Info, E, To, From, Result.IntReal);
 Result.IntImag = HandleIntToIntCast(Info, E, To, From, Result.IntImag);


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


[PATCH] D68300: [HIP] Use option -nogpulib to disable linking device lib

2019-10-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 223024.
yaxunl added a comment.

use -nogpuarch


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

https://reviews.llvm.org/D68300

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/HIP.cpp
  test/Driver/hip-no-device-libs.hip


Index: test/Driver/hip-no-device-libs.hip
===
--- /dev/null
+++ test/Driver/hip-no-device-libs.hip
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -nogpulib -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK-NOT: "-mlink-builtin-bitcode"
+
Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -289,6 +289,9 @@
 CC1Args.append({"-fvisibility", "hidden"});
 CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
+
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
+return;
   ArgStringList LibraryPaths;
 
   // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -121,7 +121,7 @@
   Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");
   }
 
-  bool NoCudaLib = Args.hasArg(options::OPT_nocudalib);
+  bool NoCudaLib = Args.hasArg(options::OPT_nogpulib);
 
   for (const auto &Candidate : Candidates) {
 InstallPath = Candidate.Path;
@@ -628,7 +628,7 @@
   CC1Args.push_back("-fgpu-rdc");
   }
 
-  if (DriverArgs.hasArg(options::OPT_nocudalib))
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;
 
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -2556,7 +2556,9 @@
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Disable builtin #include directories">;
 def nocudainc : Flag<["-"], "nocudainc">;
-def nocudalib : Flag<["-"], "nocudalib">;
+def nogpulib : Flag<["-"], "nogpulib">,
+  HelpText<"Do not link device library for CUDA/HIP device compilation">;
+def : Flag<["-"], "nocudalib">, Alias;
 def nodefaultlibs : Flag<["-"], "nodefaultlibs">;
 def nofixprebinding : Flag<["-"], "nofixprebinding">;
 def nolibc : Flag<["-"], "nolibc">;


Index: test/Driver/hip-no-device-libs.hip
===
--- /dev/null
+++ test/Driver/hip-no-device-libs.hip
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -nogpulib -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK-NOT: "-mlink-builtin-bitcode"
+
Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -289,6 +289,9 @@
 CC1Args.append({"-fvisibility", "hidden"});
 CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
+
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
+return;
   ArgStringList LibraryPaths;
 
   // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -121,7 +121,7 @@
   Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");
   }
 
-  bool NoCudaLib = Args.hasArg(options::OPT_nocudalib);
+  bool NoCudaLib = Args.hasArg(options::OPT_nogpulib);
 
   for (const auto &Candidate : Candidates) {
 InstallPath = Candidate.Path;
@@ -628,7 +628,7 @@
   CC1Args.push_back("-fgpu-rdc");
   }
 
-  if (DriverArgs.hasArg(options::OPT_nocudalib))
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;
 
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -2556,7 +2556,9 @@
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Disable builtin #include directories">;
 def nocudainc : Flag<["-"], "nocudainc">;
-def nocudalib : Flag<["-"], "nocudalib">;
+def nogpulib : Flag<["-"], "nogpulib">,
+  HelpText<"Do not link device library for CUDA/HIP device compilation">;
+def : Flag<["-"], "nocudalib">, 

r373613 - Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFCI.

2019-10-03 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Oct  3 08:10:47 2019
New Revision: 373613

URL: http://llvm.org/viewvc/llvm-project?rev=373613&view=rev
Log:
Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFCI.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=373613&r1=373612&r2=373613&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Oct  3 08:10:47 2019
@@ -1600,7 +1600,7 @@ void CodeGenModule::SetLLVMFunctionAttri
 
   if (!D->hasAttr())
 if (LangOpts.FunctionAlignment)
-  F->setAlignment(llvm::Align(1 << LangOpts.FunctionAlignment));
+  F->setAlignment(llvm::Align(1ull << LangOpts.FunctionAlignment));
 
   // Some C++ ABIs require 2-byte alignment for member functions, in order to
   // reserve a bit for differentiating between virtual and non-virtual member


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


r373614 - [Diagnostics] Bitwise negation of a boolean expr always evaluates to true; warn with -Wbool-operation

2019-10-03 Thread David Bolvansky via cfe-commits
Author: xbolva00
Date: Thu Oct  3 08:17:59 2019
New Revision: 373614

URL: http://llvm.org/viewvc/llvm-project?rev=373614&view=rev
Log:
[Diagnostics] Bitwise negation of a boolean expr always evaluates to true; warn 
with -Wbool-operation

Requested here:
http://lists.llvm.org/pipermail/cfe-dev/2019-October/063452.html


Added:
cfe/trunk/test/Sema/warn-bitwise-negation-bool.c
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=373614&r1=373613&r2=373614&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Oct  3 08:17:59 2019
@@ -13470,7 +13470,6 @@ ExprResult Sema::CreateBuiltinUnaryOp(So
 if (Input.isInvalid())
   return ExprError();
 resultType = Input.get()->getType();
-
 if (resultType->isDependentType())
   break;
 // C99 6.5.3.3p1. We allow complex int and float as a GCC extension.
@@ -13478,6 +13477,9 @@ ExprResult Sema::CreateBuiltinUnaryOp(So
   // C99 does not support '~' for complex conjugation.
   Diag(OpLoc, diag::ext_integer_complement_complex)
   << resultType << Input.get()->getSourceRange();
+else if (Input.get()->IgnoreParenImpCasts()->getType()->isBooleanType())
+  Diag(OpLoc, diag::warn_bitwise_negation_bool)
+  << FixItHint::CreateReplacement(OpLoc, "!");
 else if (resultType->hasIntegerRepresentation())
   break;
 else if (resultType->isExtVectorType() && Context.getLangOpts().OpenCL) {

Added: cfe/trunk/test/Sema/warn-bitwise-negation-bool.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-bitwise-negation-bool.c?rev=373614&view=auto
==
--- cfe/trunk/test/Sema/warn-bitwise-negation-bool.c (added)
+++ cfe/trunk/test/Sema/warn-bitwise-negation-bool.c Thu Oct  3 08:17:59 2019
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wbool-operation %s
+// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | 
FileCheck %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wbool-operation %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 
| FileCheck %s
+
+#ifdef __cplusplus
+typedef bool boolean;
+#else
+typedef _Bool boolean;
+#endif
+
+void test(boolean b, int i) {
+  b = ~b; // expected-warning {{bitwise negation of a boolean expression 
always evaluates to 'true'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:8}:"!"
+  b = ~(b); // expected-warning {{bitwise negation of a boolean expression 
always evaluates to 'true'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:8}:"!"
+  b = ~i;
+}


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


[PATCH] D68388: [PR41008][OpenCL] Support restrict keyword in C++ mode

2019-10-03 Thread Kévin Petit via Phabricator via cfe-commits
kpet added a comment.

There doesn't seem to be a test for this (enabling `restrict` in C++ doesn't 
make any existing test fail). I couldn't find any test checking that OpenCL or 
C++/OpenCL keywords generally aren't enabled in C or C++.  Doing this 
generically would essentially equate to writing unit tests for 
`getKeywordStatus`.

EDIT: I have verified that `restrict` is indeed rejected in C++.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68388



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


Re: r373614 - [Diagnostics] Bitwise negation of a boolean expr always evaluates to true; warn with -Wbool-operation

2019-10-03 Thread Nico Weber via cfe-commits
../../clang/lib/Sema/SemaExpr.cpp:13481:25: error: no member named
'warn_bitwise_negation_bool' in namespace 'clang::diag'
  Diag(OpLoc, diag::warn_bitwise_negation_bool)
  ~~^
1 error generated.

On Thu, Oct 3, 2019 at 11:16 AM David Bolvansky via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: xbolva00
> Date: Thu Oct  3 08:17:59 2019
> New Revision: 373614
>
> URL: http://llvm.org/viewvc/llvm-project?rev=373614&view=rev
> Log:
> [Diagnostics] Bitwise negation of a boolean expr always evaluates to true;
> warn with -Wbool-operation
>
> Requested here:
> http://lists.llvm.org/pipermail/cfe-dev/2019-October/063452.html
>
>
> Added:
> cfe/trunk/test/Sema/warn-bitwise-negation-bool.c
> Modified:
> cfe/trunk/lib/Sema/SemaExpr.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=373614&r1=373613&r2=373614&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Oct  3 08:17:59 2019
> @@ -13470,7 +13470,6 @@ ExprResult Sema::CreateBuiltinUnaryOp(So
>  if (Input.isInvalid())
>return ExprError();
>  resultType = Input.get()->getType();
> -
>  if (resultType->isDependentType())
>break;
>  // C99 6.5.3.3p1. We allow complex int and float as a GCC extension.
> @@ -13478,6 +13477,9 @@ ExprResult Sema::CreateBuiltinUnaryOp(So
>// C99 does not support '~' for complex conjugation.
>Diag(OpLoc, diag::ext_integer_complement_complex)
><< resultType << Input.get()->getSourceRange();
> +else if
> (Input.get()->IgnoreParenImpCasts()->getType()->isBooleanType())
> +  Diag(OpLoc, diag::warn_bitwise_negation_bool)
> +  << FixItHint::CreateReplacement(OpLoc, "!");
>  else if (resultType->hasIntegerRepresentation())
>break;
>  else if (resultType->isExtVectorType() &&
> Context.getLangOpts().OpenCL) {
>
> Added: cfe/trunk/test/Sema/warn-bitwise-negation-bool.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-bitwise-negation-bool.c?rev=373614&view=auto
>
> ==
> --- cfe/trunk/test/Sema/warn-bitwise-negation-bool.c (added)
> +++ cfe/trunk/test/Sema/warn-bitwise-negation-bool.c Thu Oct  3 08:17:59
> 2019
> @@ -0,0 +1,20 @@
> +// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wbool-operation %s
> +// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
> +// RUN: %clang_cc1 -x c -fsyntax-only -fdiagnostics-parseable-fixits %s
> 2>&1 | FileCheck %s
> +// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wbool-operation %s
> +// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s
> +// RUN: %clang_cc1 -x c++ -fsyntax-only -fdiagnostics-parseable-fixits %s
> 2>&1 | FileCheck %s
> +
> +#ifdef __cplusplus
> +typedef bool boolean;
> +#else
> +typedef _Bool boolean;
> +#endif
> +
> +void test(boolean b, int i) {
> +  b = ~b; // expected-warning {{bitwise negation of a boolean expression
> always evaluates to 'true'}}
> +  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:8}:"!"
> +  b = ~(b); // expected-warning {{bitwise negation of a boolean
> expression always evaluates to 'true'}}
> +  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:8}:"!"
> +  b = ~i;
> +}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r373616 - [NFC] Added missing changes for rL373614

2019-10-03 Thread David Bolvansky via cfe-commits
Author: xbolva00
Date: Thu Oct  3 08:26:26 2019
New Revision: 373616

URL: http://llvm.org/viewvc/llvm-project?rev=373616&view=rev
Log:
[NFC] Added missing changes for rL373614

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=373616&r1=373615&r2=373616&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct  3 08:26:26 
2019
@@ -6635,6 +6635,9 @@ def note_member_declared_here : Note<
   "member %0 declared here">;
 def note_member_first_declared_here : Note<
   "member %0 first declared here">;
+def warn_bitwise_negation_bool : Warning<
+  "bitwise negation of a boolean expression always evaluates to 'true'">,
+  InGroup>;
 def err_decrement_bool : Error<"cannot decrement expression of type bool">;
 def warn_increment_bool : Warning<
   "incrementing expression of type bool is deprecated and "


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


Re: r373614 - [Diagnostics] Bitwise negation of a boolean expr always evaluates to true; warn with -Wbool-operation

2019-10-03 Thread Dávid Bolvanský via cfe-commits
Fixed. I manually svncommited only specific files since I have other
changes and forgot to add that file too.
Sorry. Please evaluate this on Chromium. Since ~bool is always true, I
dont think we are gonna have any false positives..

št 3. 10. 2019 o 17:23 Nico Weber  napísal(a):
>
> ../../clang/lib/Sema/SemaExpr.cpp:13481:25: error: no member named 
> 'warn_bitwise_negation_bool' in namespace 'clang::diag'
>   Diag(OpLoc, diag::warn_bitwise_negation_bool)
>   ~~^
> 1 error generated.
>
> On Thu, Oct 3, 2019 at 11:16 AM David Bolvansky via cfe-commits 
>  wrote:
>>
>> Author: xbolva00
>> Date: Thu Oct  3 08:17:59 2019
>> New Revision: 373614
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=373614&view=rev
>> Log:
>> [Diagnostics] Bitwise negation of a boolean expr always evaluates to true; 
>> warn with -Wbool-operation
>>
>> Requested here:
>> http://lists.llvm.org/pipermail/cfe-dev/2019-October/063452.html
>>
>>
>> Added:
>> cfe/trunk/test/Sema/warn-bitwise-negation-bool.c
>> Modified:
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=373614&r1=373613&r2=373614&view=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Oct  3 08:17:59 2019
>> @@ -13470,7 +13470,6 @@ ExprResult Sema::CreateBuiltinUnaryOp(So
>>  if (Input.isInvalid())
>>return ExprError();
>>  resultType = Input.get()->getType();
>> -
>>  if (resultType->isDependentType())
>>break;
>>  // C99 6.5.3.3p1. We allow complex int and float as a GCC extension.
>> @@ -13478,6 +13477,9 @@ ExprResult Sema::CreateBuiltinUnaryOp(So
>>// C99 does not support '~' for complex conjugation.
>>Diag(OpLoc, diag::ext_integer_complement_complex)
>><< resultType << Input.get()->getSourceRange();
>> +else if (Input.get()->IgnoreParenImpCasts()->getType()->isBooleanType())
>> +  Diag(OpLoc, diag::warn_bitwise_negation_bool)
>> +  << FixItHint::CreateReplacement(OpLoc, "!");
>>  else if (resultType->hasIntegerRepresentation())
>>break;
>>  else if (resultType->isExtVectorType() && Context.getLangOpts().OpenCL) 
>> {
>>
>> Added: cfe/trunk/test/Sema/warn-bitwise-negation-bool.c
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-bitwise-negation-bool.c?rev=373614&view=auto
>> ==
>> --- cfe/trunk/test/Sema/warn-bitwise-negation-bool.c (added)
>> +++ cfe/trunk/test/Sema/warn-bitwise-negation-bool.c Thu Oct  3 08:17:59 2019
>> @@ -0,0 +1,20 @@
>> +// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wbool-operation %s
>> +// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
>> +// RUN: %clang_cc1 -x c -fsyntax-only -fdiagnostics-parseable-fixits %s 
>> 2>&1 | FileCheck %s
>> +// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wbool-operation %s
>> +// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s
>> +// RUN: %clang_cc1 -x c++ -fsyntax-only -fdiagnostics-parseable-fixits %s 
>> 2>&1 | FileCheck %s
>> +
>> +#ifdef __cplusplus
>> +typedef bool boolean;
>> +#else
>> +typedef _Bool boolean;
>> +#endif
>> +
>> +void test(boolean b, int i) {
>> +  b = ~b; // expected-warning {{bitwise negation of a boolean expression 
>> always evaluates to 'true'}}
>> +  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:8}:"!"
>> +  b = ~(b); // expected-warning {{bitwise negation of a boolean expression 
>> always evaluates to 'true'}}
>> +  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:8}:"!"
>> +  b = ~i;
>> +}
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r373614 - [Diagnostics] Bitwise negation of a boolean expr always evaluates to true; warn with -Wbool-operation

2019-10-03 Thread Nico Weber via cfe-commits
Thanks for the fix!

This seems like a very safe warning from a distance, so I too hope that it
won't fire. I'll let you know how it goes.

If you're very curious,
https://ci.chromium.org/p/chromium/g/chromium.clang/console are our bots
that build trunk clang and then chromium with it.

(Currently the LLLVM build is broken with gcc5.3 host compilers apparently,
hence lots of red.)

On Thu, Oct 3, 2019 at 11:26 AM Dávid Bolvanský 
wrote:

> Fixed. I manually svncommited only specific files since I have other
> changes and forgot to add that file too.
> Sorry. Please evaluate this on Chromium. Since ~bool is always true, I
> dont think we are gonna have any false positives..
>
> št 3. 10. 2019 o 17:23 Nico Weber  napísal(a):
> >
> > ../../clang/lib/Sema/SemaExpr.cpp:13481:25: error: no member named
> 'warn_bitwise_negation_bool' in namespace 'clang::diag'
> >   Diag(OpLoc, diag::warn_bitwise_negation_bool)
> >   ~~^
> > 1 error generated.
> >
> > On Thu, Oct 3, 2019 at 11:16 AM David Bolvansky via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>
> >> Author: xbolva00
> >> Date: Thu Oct  3 08:17:59 2019
> >> New Revision: 373614
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=373614&view=rev
> >> Log:
> >> [Diagnostics] Bitwise negation of a boolean expr always evaluates to
> true; warn with -Wbool-operation
> >>
> >> Requested here:
> >> http://lists.llvm.org/pipermail/cfe-dev/2019-October/063452.html
> >>
> >>
> >> Added:
> >> cfe/trunk/test/Sema/warn-bitwise-negation-bool.c
> >> Modified:
> >> cfe/trunk/lib/Sema/SemaExpr.cpp
> >>
> >> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=373614&r1=373613&r2=373614&view=diff
> >>
> ==
> >> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> >> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Oct  3 08:17:59 2019
> >> @@ -13470,7 +13470,6 @@ ExprResult Sema::CreateBuiltinUnaryOp(So
> >>  if (Input.isInvalid())
> >>return ExprError();
> >>  resultType = Input.get()->getType();
> >> -
> >>  if (resultType->isDependentType())
> >>break;
> >>  // C99 6.5.3.3p1. We allow complex int and float as a GCC
> extension.
> >> @@ -13478,6 +13477,9 @@ ExprResult Sema::CreateBuiltinUnaryOp(So
> >>// C99 does not support '~' for complex conjugation.
> >>Diag(OpLoc, diag::ext_integer_complement_complex)
> >><< resultType << Input.get()->getSourceRange();
> >> +else if
> (Input.get()->IgnoreParenImpCasts()->getType()->isBooleanType())
> >> +  Diag(OpLoc, diag::warn_bitwise_negation_bool)
> >> +  << FixItHint::CreateReplacement(OpLoc, "!");
> >>  else if (resultType->hasIntegerRepresentation())
> >>break;
> >>  else if (resultType->isExtVectorType() &&
> Context.getLangOpts().OpenCL) {
> >>
> >> Added: cfe/trunk/test/Sema/warn-bitwise-negation-bool.c
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-bitwise-negation-bool.c?rev=373614&view=auto
> >>
> ==
> >> --- cfe/trunk/test/Sema/warn-bitwise-negation-bool.c (added)
> >> +++ cfe/trunk/test/Sema/warn-bitwise-negation-bool.c Thu Oct  3
> 08:17:59 2019
> >> @@ -0,0 +1,20 @@
> >> +// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wbool-operation %s
> >> +// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
> >> +// RUN: %clang_cc1 -x c -fsyntax-only -fdiagnostics-parseable-fixits
> %s 2>&1 | FileCheck %s
> >> +// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wbool-operation %s
> >> +// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s
> >> +// RUN: %clang_cc1 -x c++ -fsyntax-only -fdiagnostics-parseable-fixits
> %s 2>&1 | FileCheck %s
> >> +
> >> +#ifdef __cplusplus
> >> +typedef bool boolean;
> >> +#else
> >> +typedef _Bool boolean;
> >> +#endif
> >> +
> >> +void test(boolean b, int i) {
> >> +  b = ~b; // expected-warning {{bitwise negation of a boolean
> expression always evaluates to 'true'}}
> >> +  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:8}:"!"
> >> +  b = ~(b); // expected-warning {{bitwise negation of a boolean
> expression always evaluates to 'true'}}
> >> +  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:7-[[@LINE-1]]:8}:"!"
> >> +  b = ~i;
> >> +}
> >>
> >>
> >> ___
> >> cfe-commits mailing list
> >> cfe-commits@lists.llvm.org
> >> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68401: [Hexagon] Fix clang driver to parse -mcpu/-mvXX and -march properly.

2019-10-03 Thread Sumanth Gundapaneni via Phabricator via cfe-commits
sgundapa created this revision.
sgundapa added reviewers: bcain, bcahoon.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Before this patch if we pass "-mcpu=hexagonv65 -march=hexagon" in this order,
the driver fails to figure out the correct cpu version. This patch fixed this
issue.


Repository:
  rC Clang

https://reviews.llvm.org/D68401

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


Index: clang/test/Driver/hexagon-toolchain-elf.c
===
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -121,6 +121,19 @@
 // CHECK028-NOT: "-ffp-contract=fast"
 // CHECK028: {{hexagon-link|ld}}
 
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv65 -march=hexagon\
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK029 %s
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mv65 -march=hexagon\
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK029 %s
+// CHECK029: "-cc1" {{.*}} "-target-cpu" "hexagonv65"
+// CHECK029: 
hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v65/crt0
+
 // 
-
 // Test Linker related args
 // 
-
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -574,7 +574,7 @@
 
 const StringRef HexagonToolChain::GetTargetCPUVersion(const ArgList &Args) {
   Arg *CpuArg = nullptr;
-  if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ, options::OPT_march_EQ))
+  if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
 CpuArg = A;
 
   StringRef CPU = CpuArg ? CpuArg->getValue() : GetDefaultCPU();


Index: clang/test/Driver/hexagon-toolchain-elf.c
===
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -121,6 +121,19 @@
 // CHECK028-NOT: "-ffp-contract=fast"
 // CHECK028: {{hexagon-link|ld}}
 
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv65 -march=hexagon\
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK029 %s
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mv65 -march=hexagon\
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK029 %s
+// CHECK029: "-cc1" {{.*}} "-target-cpu" "hexagonv65"
+// CHECK029: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v65/crt0
+
 // -
 // Test Linker related args
 // -
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -574,7 +574,7 @@
 
 const StringRef HexagonToolChain::GetTargetCPUVersion(const ArgList &Args) {
   Arg *CpuArg = nullptr;
-  if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ, options::OPT_march_EQ))
+  if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
 CpuArg = A;
 
   StringRef CPU = CpuArg ? CpuArg->getValue() : GetDefaultCPU();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68162: [analyzer][MallocChecker][NFC] Communicate the allocation family to auxiliary functions with parameters

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

I like this change. If we can retrieve something with a simple getter, then do 
not carry extra parameters all over the code. However, if we have to 
recalculate something over and over again then it is much better to determine 
it once and pass it around as a parameter. Especially in this case where we 
have the information statically at top level and do not have to calculate it 
all if we use that.




Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1860
+  // that.
+  assert(!RsBase || (RsBase && RsBase->getAllocationFamily() == Family));
+

Please add an `&& ""` to the assertion.


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

https://reviews.llvm.org/D68162



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


[PATCH] D68394: [HIP] Enable specifying different default gpu arch for HIP/CUDA.

2019-10-03 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:2538
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {
+  DefaultCudaArch = CudaArch::SM_20;
+}

This technically depends on the CUDA version.
We do have CUDA version info in `clang/lib/Driver/ToolChains/Cuda.h`
The default for NVCC has been sm_30 since CUDA-9.0.  In fact sm_20 is not 
supported at all by CUDA-9.0+ at all , so we should bump the default to sm_30 
for those versions.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68394



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


r373620 - [OPENMP]Improve diagnostics for not found declare target entries.

2019-10-03 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct  3 09:20:34 2019
New Revision: 373620

URL: http://llvm.org/viewvc/llvm-project?rev=373620&view=rev
Log:
[OPENMP]Improve diagnostics for not found declare target entries.

We can point to the target region + emit parent functions names/real var
names if they were not found in host module during device codegen.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/target_messages.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373620&r1=373619&r2=373620&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct  3 09:20:34 2019
@@ -4201,7 +4201,9 @@ void CGOpenMPRuntime::createOffloadEntri
 
   llvm::Module &M = CGM.getModule();
   llvm::LLVMContext &C = M.getContext();
-  SmallVector
+  SmallVector,
+  16>
   OrderedEntries(OffloadEntriesInfoManager.size());
   llvm::SmallVector ParentFunctions(
   OffloadEntriesInfoManager.size());
@@ -4219,7 +4221,8 @@ void CGOpenMPRuntime::createOffloadEntri
 
   // Create function that emits metadata for each target region entry;
   auto &&TargetRegionMetadataEmitter =
-  [&C, MD, &OrderedEntries, &ParentFunctions, &GetMDInt, &GetMDString](
+  [this, &C, MD, &OrderedEntries, &ParentFunctions, &GetMDInt,
+   &GetMDString](
   unsigned DeviceID, unsigned FileID, StringRef ParentName,
   unsigned Line,
   const OffloadEntriesInfoManagerTy::OffloadEntryInfoTargetRegion &E) {
@@ -4237,8 +4240,19 @@ void CGOpenMPRuntime::createOffloadEntri
  GetMDInt(FileID),  
GetMDString(ParentName),
  GetMDInt(Line),
GetMDInt(E.getOrder())};
 
+SourceLocation Loc;
+for (auto I = CGM.getContext().getSourceManager().fileinfo_begin(),
+  E = CGM.getContext().getSourceManager().fileinfo_end();
+ I != E; ++I) {
+  if (I->getFirst()->getUniqueID().getDevice() == DeviceID &&
+  I->getFirst()->getUniqueID().getFile() == FileID) {
+Loc = CGM.getContext().getSourceManager().translateFileLineCol(
+I->getFirst(), Line, 1);
+break;
+  }
+}
 // Save this entry in the right position of the ordered entries array.
-OrderedEntries[E.getOrder()] = &E;
+OrderedEntries[E.getOrder()] = std::make_tuple(&E, Loc, ParentName);
 ParentFunctions[E.getOrder()] = ParentName;
 
 // Add metadata to the named metadata node.
@@ -4266,7 +4280,8 @@ void CGOpenMPRuntime::createOffloadEntri
 GetMDInt(E.getFlags()), GetMDInt(E.getOrder())};
 
 // Save this entry in the right position of the ordered entries array.
-OrderedEntries[E.getOrder()] = &E;
+OrderedEntries[E.getOrder()] =
+std::make_tuple(&E, SourceLocation(), MangledName);
 
 // Add metadata to the named metadata node.
 MD->addOperand(llvm::MDNode::get(C, Ops));
@@ -4275,11 +4290,11 @@ void CGOpenMPRuntime::createOffloadEntri
   OffloadEntriesInfoManager.actOnDeviceGlobalVarEntriesInfo(
   DeviceGlobalVarMetadataEmitter);
 
-  for (const auto *E : OrderedEntries) {
-assert(E && "All ordered entries must exist!");
+  for (const auto &E : OrderedEntries) {
+assert(std::get<0>(E) && "All ordered entries must exist!");
 if (const auto *CE =
 
dyn_cast(
-E)) {
+std::get<0>(E))) {
   if (!CE->getID() || !CE->getAddress()) {
 // Do not blame the entry if the parent funtion is not emitted.
 StringRef FnName = ParentFunctions[CE->getOrder()];
@@ -4287,16 +4302,16 @@ void CGOpenMPRuntime::createOffloadEntri
   continue;
 unsigned DiagID = CGM.getDiags().getCustomDiagID(
 DiagnosticsEngine::Error,
-"Offloading entry for target region is incorrect: either the "
+"Offloading entry for target region in %0 is incorrect: either the 
"
 "address or the ID is invalid.");
-CGM.getDiags().Report(DiagID);
+CGM.getDiags().Report(std::get<1>(E), DiagID) << FnName;
 continue;
   }
   createOffloadEntry(CE->getID(), CE->getAddress(), /*Size=*/0,
  CE->getFlags(), llvm::GlobalValue::WeakAnyLinkage);
-} else if (const auto *CE =
-   dyn_cast(E)) {
+} else if (const auto *CE = dyn_cast(
+   std::get<0>(E))) {
   OffloadEntriesInfoManagerTy::OMPTargetGlobalVarEntryKind Flags =
   
static_cast(
   CE->getFlags());
@@ -4307,10 +4322,10 @@ void CGOpenMPRuntime::createOffloadEntri
   continue;
 if (!CE->getAddress()) {
   unsigned DiagID = CGM.getDiags().getCustomDiagID(
- 

[PATCH] D68403: [OpenCL] PR43145: preserve addrspace for class accesses

2019-10-03 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
Herald added subscribers: cfe-commits, yaxunl.
Herald added a project: clang.

PR43145 revealed two places where Clang was attempting to create a
bitcast without considering the address space of class types during
C++ class codegen.


Repository:
  rC Clang

https://reviews.llvm.org/D68403

Files:
  lib/CodeGen/CGClass.cpp
  test/CodeGenOpenCLCXX/addrspace-derived-base.cl


Index: test/CodeGenOpenCLCXX/addrspace-derived-base.cl
===
--- test/CodeGenOpenCLCXX/addrspace-derived-base.cl
+++ test/CodeGenOpenCLCXX/addrspace-derived-base.cl
@@ -11,6 +11,7 @@
 
 void foo() {
   D d;
+  //CHECK-LABEL: foo
   //CHECK: addrspacecast %class.D* %d to %class.D addrspace(4)*
   //CHECK: call spir_func i32 @_ZNU3AS41D5getmbEv(%class.D addrspace(4)*
   d.getmb();
@@ -20,3 +21,32 @@
 
 //CHECK: define linkonce_odr spir_func i32 @_ZNU3AS41D5getmbEv(%class.D 
addrspace(4)* %this)
 //CHECK: bitcast %class.D addrspace(4)* %this1 to %struct.B addrspace(4)*
+
+
+// Calling base method through multiple inheritance.
+
+class B2 {
+  public:
+void baseMethod() const {  }
+int bb;
+};
+
+class Derived : public B, public B2 {
+  public:
+void work() const { baseMethod(); }
+// CHECK-LABEL: work
+// CHECK: bitcast i8 addrspace(4)* %add.ptr to %class.B2 addrspace(4)*
+};
+
+void pr43145(const Derived *argDerived) {
+  argDerived->work();
+}
+
+// Casting from base to derived.
+
+void pr43145_2(B *argB) {
+  Derived *x = (Derived*)argB;
+}
+
+// CHECK-LABEL: @_Z9pr43145_2
+// CHECK: bitcast %struct.B addrspace(4)* %0 to %class.Derived addrspace(4)*
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -246,7 +246,8 @@
 
   // Apply the base offset.
   llvm::Value *ptr = addr.getPointer();
-  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8PtrTy);
+  unsigned AddrSpace = ptr->getType()->getPointerAddressSpace();
+  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8Ty->getPointerTo(AddrSpace));
   ptr = CGF.Builder.CreateInBoundsGEP(ptr, baseOffset, "add.ptr");
 
   // If we have a virtual component, the alignment of the result will
@@ -381,7 +382,9 @@
 
   QualType DerivedTy =
 getContext().getCanonicalType(getContext().getTagDeclType(Derived));
-  llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo();
+  unsigned AddrSpace =
+BaseAddr.getPointer()->getType()->getPointerAddressSpace();
+  llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo(AddrSpace);
 
   llvm::Value *NonVirtualOffset =
 CGM.GetNonVirtualBaseClassOffset(Derived, PathBegin, PathEnd);


Index: test/CodeGenOpenCLCXX/addrspace-derived-base.cl
===
--- test/CodeGenOpenCLCXX/addrspace-derived-base.cl
+++ test/CodeGenOpenCLCXX/addrspace-derived-base.cl
@@ -11,6 +11,7 @@
 
 void foo() {
   D d;
+  //CHECK-LABEL: foo
   //CHECK: addrspacecast %class.D* %d to %class.D addrspace(4)*
   //CHECK: call spir_func i32 @_ZNU3AS41D5getmbEv(%class.D addrspace(4)*
   d.getmb();
@@ -20,3 +21,32 @@
 
 //CHECK: define linkonce_odr spir_func i32 @_ZNU3AS41D5getmbEv(%class.D addrspace(4)* %this)
 //CHECK: bitcast %class.D addrspace(4)* %this1 to %struct.B addrspace(4)*
+
+
+// Calling base method through multiple inheritance.
+
+class B2 {
+  public:
+void baseMethod() const {  }
+int bb;
+};
+
+class Derived : public B, public B2 {
+  public:
+void work() const { baseMethod(); }
+// CHECK-LABEL: work
+// CHECK: bitcast i8 addrspace(4)* %add.ptr to %class.B2 addrspace(4)*
+};
+
+void pr43145(const Derived *argDerived) {
+  argDerived->work();
+}
+
+// Casting from base to derived.
+
+void pr43145_2(B *argB) {
+  Derived *x = (Derived*)argB;
+}
+
+// CHECK-LABEL: @_Z9pr43145_2
+// CHECK: bitcast %struct.B addrspace(4)* %0 to %class.Derived addrspace(4)*
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -246,7 +246,8 @@
 
   // Apply the base offset.
   llvm::Value *ptr = addr.getPointer();
-  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8PtrTy);
+  unsigned AddrSpace = ptr->getType()->getPointerAddressSpace();
+  ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8Ty->getPointerTo(AddrSpace));
   ptr = CGF.Builder.CreateInBoundsGEP(ptr, baseOffset, "add.ptr");
 
   // If we have a virtual component, the alignment of the result will
@@ -381,7 +382,9 @@
 
   QualType DerivedTy =
 getContext().getCanonicalType(getContext().getTagDeclType(Derived));
-  llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo();
+  unsigned AddrSpace =
+BaseAddr.getPointer()->getType()->getPointerAddressSpace();
+  llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo(AddrSpace);
 
   llvm::Value *NonVirtualOffset =
 CGM.GetNonVirtua

[PATCH] D68394: [HIP] Enable specifying different default gpu arch for HIP/CUDA.

2019-10-03 Thread Michael Liao via Phabricator via cfe-commits
hliao marked an inline comment as done.
hliao added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:2538
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {
+  DefaultCudaArch = CudaArch::SM_20;
+}

tra wrote:
> This technically depends on the CUDA version.
> We do have CUDA version info in `clang/lib/Driver/ToolChains/Cuda.h`
> The default for NVCC has been sm_30 since CUDA-9.0.  In fact sm_20 is not 
> supported at all by CUDA-9.0+ at all , so we should bump the default to sm_30 
> for those versions.
> 
unfortunately, when the action build is running, the CUDA is not detected yet, 
I probably revise the detection logic to update CUDA's default gpu arch after 
successful detection


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68394



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


[PATCH] D68300: [HIP] Use option -nogpulib to disable linking device lib

2019-10-03 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: include/clang/Driver/Options.td:606
+def flink_builtin_bitcode : Flag<["-"], "flink-builtin-bitcode">,
+  Flags<[CC1Option]>, HelpText<"Link builtin bitcode for HIP device 
compilation.">;
+def fno_link_builtin_bitcode : Flag<["-"], "fno-link-builtin-bitcode">;

hliao wrote:
> tra wrote:
> > yaxunl wrote:
> > > ashi1 wrote:
> > > > Since this is a more generic approach, we won't need to specify HIP ?
> > > this patch only implemented this option for HIP. If it is used for other 
> > > languages, this help text should be updated.
> > Hmm. Cuda currently uses `-nocudalib` for essentially the same purpose 
> > (Sort of like `-nostdlib`, but for CUDA). Perhaps we should consolidate all 
> > these into `-nogpulib` and alias `-nocudalib` to it. 
> how about other relevant options, such as replacing cuda-device-only with 
> gpu-device-only or hip-device-only to avoid confusing with CUDA.
We seem to be doing exactly that, only incrementally. In general it does make 
sense to consolidate the flags where the functionality is common.
`cuda-device-only`, `cuda_host_only`, `cuda_compile_host_device`  and 
`cuda-gpu-arch` could be generalized to `gpu-`. 

This should be a separate patch, though.


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

https://reviews.llvm.org/D68300



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


[PATCH] D68394: [HIP] Enable specifying different default gpu arch for HIP/CUDA.

2019-10-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:2655
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {
+  DefaultCudaArch = CudaArch::GFX600;
+}

hliao wrote:
> Sam, could you let me know which reasonable default arch should we use here?
I think it should be gfx803 since as far as I know it is the lowest one that 
supports HIP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68394



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


[PATCH] D68300: [HIP] Use option -nogpulib to disable linking device lib

2019-10-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: include/clang/Driver/Options.td:606
+def flink_builtin_bitcode : Flag<["-"], "flink-builtin-bitcode">,
+  Flags<[CC1Option]>, HelpText<"Link builtin bitcode for HIP device 
compilation.">;
+def fno_link_builtin_bitcode : Flag<["-"], "fno-link-builtin-bitcode">;

tra wrote:
> hliao wrote:
> > tra wrote:
> > > yaxunl wrote:
> > > > ashi1 wrote:
> > > > > Since this is a more generic approach, we won't need to specify HIP ?
> > > > this patch only implemented this option for HIP. If it is used for 
> > > > other languages, this help text should be updated.
> > > Hmm. Cuda currently uses `-nocudalib` for essentially the same purpose 
> > > (Sort of like `-nostdlib`, but for CUDA). Perhaps we should consolidate 
> > > all these into `-nogpulib` and alias `-nocudalib` to it. 
> > how about other relevant options, such as replacing cuda-device-only with 
> > gpu-device-only or hip-device-only to avoid confusing with CUDA.
> We seem to be doing exactly that, only incrementally. In general it does make 
> sense to consolidate the flags where the functionality is common.
> `cuda-device-only`, `cuda_host_only`, `cuda_compile_host_device`  and 
> `cuda-gpu-arch` could be generalized to `gpu-`. 
> 
> This should be a separate patch, though.
agree


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

https://reviews.llvm.org/D68300



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


r373624 - [OPENMP]Fix emission of the declare target variables in device mode.

2019-10-03 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct  3 09:46:49 2019
New Revision: 373624

URL: http://llvm.org/viewvc/llvm-project?rev=373624&view=rev
Log:
[OPENMP]Fix emission of the declare target variables in device mode.

Declare target variables must be emitted in device mode, target triples
can be empty in this case.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_target_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373624&r1=373623&r2=373624&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct  3 09:46:49 2019
@@ -2868,7 +2868,8 @@ llvm::Function *CGOpenMPRuntime::emitThr
 bool CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD,
  llvm::GlobalVariable 
*Addr,
  bool PerformInit) {
-  if (CGM.getLangOpts().OMPTargetTriples.empty())
+  if (CGM.getLangOpts().OMPTargetTriples.empty() &&
+  !CGM.getLangOpts().OpenMPIsDevice)
 return false;
   Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
@@ -9806,7 +9807,8 @@ CGOpenMPRuntime::registerTargetFirstpriv
 
 void CGOpenMPRuntime::registerTargetGlobalVariable(const VarDecl *VD,
llvm::Constant *Addr) {
-  if (CGM.getLangOpts().OMPTargetTriples.empty())
+  if (CGM.getLangOpts().OMPTargetTriples.empty() &&
+  !CGM.getLangOpts().OpenMPIsDevice)
 return;
   llvm::Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);

Modified: cfe/trunk/test/OpenMP/declare_target_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen.cpp?rev=373624&r1=373623&r2=373624&view=diff
==
--- cfe/trunk/test/OpenMP/declare_target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_codegen.cpp Thu Oct  3 09:46:49 2019
@@ -1,29 +1,22 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - 
| FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc 
-emit-pch -o %t
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc 
-include-pch %t -o - | FileCheck %s
 
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - 
-fopenmp-version=50 -DOMP5 | FileCheck %s --check-prefix HOST5
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc 
-fopenmp-version=50 -DOMP5
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fopenmp-version=50 -DOMP5 | 
FileCheck %s --check-prefix DEV5
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - 
-fopenmp-version=50 -DOMP5 | FileCheck %s --check-prefix DEV5
 
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -o - -fopenmp-version=50 -DOMP5 | FileCheck %s --check-prefix 
KMPC-ONLY
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm-bc %s -o %t-ppc-host.bc -fopenmp-version=50 -DOMP5
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - 
-fopenmp-version=50 -DOMP5 | Fi

[PATCH] D68394: [HIP] Enable specifying different default gpu arch for HIP/CUDA.

2019-10-03 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Driver/Driver.cpp:2538
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {
+  DefaultCudaArch = CudaArch::SM_20;
+}

hliao wrote:
> tra wrote:
> > This technically depends on the CUDA version.
> > We do have CUDA version info in `clang/lib/Driver/ToolChains/Cuda.h`
> > The default for NVCC has been sm_30 since CUDA-9.0.  In fact sm_20 is not 
> > supported at all by CUDA-9.0+ at all , so we should bump the default to 
> > sm_30 for those versions.
> > 
> unfortunately, when the action build is running, the CUDA is not detected 
> yet, I probably revise the detection logic to update CUDA's default gpu arch 
> after successful detection
OK. If there's no easy way to do it here, it's probably not worth doing it just 
to keep sm_20 as the default.
sm_20 has not been supported by the last two major CUDA releases and it makes 
little sense to have the default that does not work for the majority of current 
users.

I think we should just bump the default to sm_30 for all currently supported 
CUDA versions in a separate patch. I can do it once this patch lands.





Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68394



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


r373626 - DeclBase/DeclCXX/DeclTemplate - silence static analyzer getAs<> null dereference warnings. NFCI.

2019-10-03 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Oct  3 09:58:01 2019
New Revision: 373626

URL: http://llvm.org/viewvc/llvm-project?rev=373626&view=rev
Log:
DeclBase/DeclCXX/DeclTemplate - silence static analyzer getAs<> null 
dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these 
cases we should be able to use castAs<> directly and if not assert will fire 
for us.

Modified:
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=373626&r1=373625&r2=373626&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Thu Oct  3 09:58:01 2019
@@ -959,11 +959,11 @@ const FunctionType *Decl::getFunctionTyp
 return nullptr;
 
   if (Ty->isFunctionPointerType())
-Ty = Ty->getAs()->getPointeeType();
+Ty = Ty->castAs()->getPointeeType();
   else if (Ty->isFunctionReferenceType())
-Ty = Ty->getAs()->getPointeeType();
+Ty = Ty->castAs()->getPointeeType();
   else if (BlocksToo && Ty->isBlockPointerType())
-Ty = Ty->getAs()->getPointeeType();
+Ty = Ty->castAs()->getPointeeType();
 
   return Ty->getAs();
 }

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=373626&r1=373625&r2=373626&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Thu Oct  3 09:58:01 2019
@@ -2566,7 +2566,7 @@ bool CXXConstructorDecl::isConvertingCon
 return false;
 
   return (getNumParams() == 0 &&
-  getType()->getAs()->isVariadic()) ||
+  getType()->castAs()->isVariadic()) ||
  (getNumParams() == 1) ||
  (getNumParams() > 1 &&
   (getParamDecl(1)->hasDefaultArg() ||

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=373626&r1=373625&r2=373626&view=diff
==
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Thu Oct  3 09:58:01 2019
@@ -519,15 +519,15 @@ SourceRange TemplateTypeParmDecl::getSou
 }
 
 unsigned TemplateTypeParmDecl::getDepth() const {
-  return getTypeForDecl()->getAs()->getDepth();
+  return getTypeForDecl()->castAs()->getDepth();
 }
 
 unsigned TemplateTypeParmDecl::getIndex() const {
-  return getTypeForDecl()->getAs()->getIndex();
+  return getTypeForDecl()->castAs()->getIndex();
 }
 
 bool TemplateTypeParmDecl::isParameterPack() const {
-  return getTypeForDecl()->getAs()->isParameterPack();
+  return getTypeForDecl()->castAs()->isParameterPack();
 }
 
 
//===--===//


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


[libunwind] r373628 - [libunwind] Adjust libunwind_01.pass.cpp test for ARM EHABI

2019-10-03 Thread John Brawn via cfe-commits
Author: john.brawn
Date: Thu Oct  3 10:01:04 2019
New Revision: 373628

URL: http://llvm.org/viewvc/llvm-project?rev=373628&view=rev
Log:
[libunwind] Adjust libunwind_01.pass.cpp test for ARM EHABI

ARM EHABI unwinding tables only store the start address of each function, so the
last function is assumed to cover the entire address space after it. The test
picks an address on the stack assuming that it's in no function, but because of
the above it's actually resolved to the last function. Fix this by using address
0 instead.

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

Modified:
libunwind/trunk/test/libunwind_01.pass.cpp

Modified: libunwind/trunk/test/libunwind_01.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/test/libunwind_01.pass.cpp?rev=373628&r1=373627&r2=373628&view=diff
==
--- libunwind/trunk/test/libunwind_01.pass.cpp (original)
+++ libunwind/trunk/test/libunwind_01.pass.cpp Thu Oct  3 10:01:04 2019
@@ -48,7 +48,7 @@ void test_no_info() {
 abort();
 
   // Set the IP to an address clearly outside any function.
-  unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)&context);
+  unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)0);
 
   ret = unw_get_proc_info(&cursor, &info);
   if (ret != UNW_ENOINFO)


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


[PATCH] D20561: Warn when taking address of packed member

2019-10-03 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

I think I found a false negative with this where if the member is accessed from 
a packed struct type returned from a function, the warning does not appear:

  typedef struct {
uint8_t a;
uint32_t b; 
  } __attribute__((packed)) registers_t;
  
  registers_t *Class::method() { return registers_; }
  
  void Class::func() {
other_func(&method()->b);  // I think the warning should appear here?
  }


Repository:
  rL LLVM

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

https://reviews.llvm.org/D20561



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


[PATCH] D68407: [WIP][RISCV] Use compiler-rt if no GCC installation detected

2019-10-03 Thread Edward Jones via Phabricator via cfe-commits
edward-jones created this revision.
edward-jones added a reviewer: asb.
Herald added subscribers: cfe-commits, pzheng, simoncook, s.egerton, lenary, 
Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, 
rogfer01, zzheng, MaskRay, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, 
apazos, johnrusso, rbar, dberris.
Herald added a project: clang.

If a GCC installation is not detected, they this attempts to use compiler-rt 
and the compiler-rt crtbegin/crtend implementations as a fallback.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68407

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h


Index: clang/lib/Driver/ToolChains/RISCVToolchain.h
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -45,13 +45,18 @@
 namespace RISCV {
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain &TC) : GnuTool("RISCV::Linker", "ld", TC) {}
+  Linker(const ToolChain &TC, bool ShouldUseLibGCC)
+  : GnuTool("RISCV::Linker", "ld", TC),
+UseLibGCC(ShouldUseLibGCC) {}
   bool hasIntegratedCPP() const override { return false; }
   bool isLinkJob() const override { return true; }
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
+
+private:
+  bool UseLibGCC;
 };
 } // end namespace RISCV
 } // end namespace tools
Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -36,7 +36,8 @@
 }
 
 Tool *RISCVToolChain::buildLinker() const {
-  return new tools::RISCV::Linker(*this);
+  bool useLibGCC = GCCInstallation.isValid();
+  return new tools::RISCV::Linker(*this, useLibGCC);
 }
 
 void RISCVToolChain::addClangTargetOptions(
@@ -94,7 +95,7 @@
  const InputInfoList &Inputs,
  const ArgList &Args,
  const char *LinkingOutput) const {
-  const ToolChain &ToolChain = getToolChain();
+  const auto &ToolChain = getToolChain();
   const Driver &D = ToolChain.getDriver();
   ArgStringList CmdArgs;
 
@@ -106,9 +107,28 @@
   bool WantCRTs =
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
 
+  const char *crtbegin, *crtend, *rtlib;
+  if (UseLibGCC) {
+crtbegin = "crtbegin.o";
+crtend = "crtend.o";
+rtlib = "-lgcc";
+  } else {
+auto Arch = ToolChain.getTriple().getArch();
+if (Arch == llvm::Triple::ArchType::riscv32) {
+  crtbegin = "clang_rt.crtbegin-riscv32.o";
+  crtend = "clang_rt.crtend-riscv32.o";
+  rtlib = "-lclang_rt.builtins-riscv32";
+} else {
+  assert(Arch == llvm::Triple::ArchType::riscv64);
+  crtbegin = "clang_rt.crtbegin-riscv64.o";
+  crtend = "clang_rt.crtend-riscv64.o";
+  rtlib = "-lclang_rt.builtins-riscv64";
+}
+  }
+
   if (WantCRTs) {
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
   }
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
@@ -129,11 +149,11 @@
 CmdArgs.push_back("-lc");
 CmdArgs.push_back("-lgloss");
 CmdArgs.push_back("--end-group");
-CmdArgs.push_back("-lgcc");
+CmdArgs.push_back(rtlib);
   }
 
   if (WantCRTs)
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend)));
 
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());


Index: clang/lib/Driver/ToolChains/RISCVToolchain.h
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -45,13 +45,18 @@
 namespace RISCV {
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain &TC) : GnuTool("RISCV::Linker", "ld", TC) {}
+  Linker(const ToolChain &TC, bool ShouldUseLibGCC)
+  : GnuTool("RISCV::Linker", "ld", TC),
+UseLibGCC(ShouldUseLibGCC) {}
   bool hasIntegratedCPP() const override { return false; }
   bool isLinkJob() const override { return true; }
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
+
+private:
+  bool UseLibGCC;
 };
 } // end namespace RISCV
 } // end namespace tools
Ind

[PATCH] D68407: [WIP][RISCV] Use compiler-rt if no GCC installation detected

2019-10-03 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

Work in progress because this needs tests (and probably clang-format too).

My assumption is that libgcc should be used in preference if it is available. 
At the moment this either uses libgcc and libgcc's crtbegin/crtend, or the 
Clang equivalents. Potentially a user might want to mix compiler-rt builtins 
with libgcc's crt*.o files, but for now that's not possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68407



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


[PATCH] D68300: [HIP] Use option -nogpulib to disable linking device lib

2019-10-03 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 accepted this revision.
ashi1 added a comment.

LGTM - Thanks for generalizing


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

https://reviews.llvm.org/D68300



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


r373634 - [HIP] Enable specifying different default gpu arch for HIP/CUDA.

2019-10-03 Thread Michael Liao via cfe-commits
Author: hliao
Date: Thu Oct  3 10:49:20 2019
New Revision: 373634

URL: http://llvm.org/viewvc/llvm-project?rev=373634&view=rev
Log:
[HIP] Enable specifying different default gpu arch for HIP/CUDA.

Reviewers: tra, yaxunl

Subscribers: cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Driver/hip-default-gpu-arch.hip
Modified:
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=373634&r1=373633&r2=373634&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Oct  3 10:49:20 2019
@@ -2329,6 +2329,10 @@ class OffloadingActionBuilder final {
 
 /// Flag for -fgpu-rdc.
 bool Relocatable = false;
+
+/// Default GPU architecture if there's no one specified.
+CudaArch DefaultCudaArch = CudaArch::UNKNOWN;
+
   public:
 CudaActionBuilderBase(Compilation &C, DerivedArgList &Args,
   const Driver::InputList &Inputs,
@@ -2518,7 +2522,7 @@ class OffloadingActionBuilder final {
   // supported GPUs.  sm_20 code should work correctly, if
   // suboptimally, on all newer GPUs.
   if (GpuArchList.empty())
-GpuArchList.push_back(CudaArch::SM_20);
+GpuArchList.push_back(DefaultCudaArch);
 
   return Error;
 }
@@ -2530,7 +2534,9 @@ class OffloadingActionBuilder final {
   public:
 CudaActionBuilder(Compilation &C, DerivedArgList &Args,
   const Driver::InputList &Inputs)
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {
+  DefaultCudaArch = CudaArch::SM_20;
+}
 
 ActionBuilderReturnCode
 getDeviceDependences(OffloadAction::DeviceDependences &DA,
@@ -2645,7 +2651,9 @@ class OffloadingActionBuilder final {
   public:
 HIPActionBuilder(Compilation &C, DerivedArgList &Args,
  const Driver::InputList &Inputs)
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {
+  DefaultCudaArch = CudaArch::GFX803;
+}
 
 bool canUseBundlerUnbundler() const override { return true; }
 

Added: cfe/trunk/test/Driver/hip-default-gpu-arch.hip
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-default-gpu-arch.hip?rev=373634&view=auto
==
--- cfe/trunk/test/Driver/hip-default-gpu-arch.hip (added)
+++ cfe/trunk/test/Driver/hip-default-gpu-arch.hip Thu Oct  3 10:49:20 2019
@@ -0,0 +1,7 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -x hip -c %s 2>&1 | FileCheck %s
+
+// CHECK: {{.*}}clang{{.*}}"-target-cpu" "gfx803"


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


[PATCH] D68394: [HIP] Enable specifying different default gpu arch for HIP/CUDA.

2019-10-03 Thread Michael Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373634: [HIP] Enable specifying different default gpu arch 
for HIP/CUDA. (authored by hliao, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68394?vs=223015&id=223055#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68394

Files:
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/hip-default-gpu-arch.hip


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -2329,6 +2329,10 @@
 
 /// Flag for -fgpu-rdc.
 bool Relocatable = false;
+
+/// Default GPU architecture if there's no one specified.
+CudaArch DefaultCudaArch = CudaArch::UNKNOWN;
+
   public:
 CudaActionBuilderBase(Compilation &C, DerivedArgList &Args,
   const Driver::InputList &Inputs,
@@ -2518,7 +2522,7 @@
   // supported GPUs.  sm_20 code should work correctly, if
   // suboptimally, on all newer GPUs.
   if (GpuArchList.empty())
-GpuArchList.push_back(CudaArch::SM_20);
+GpuArchList.push_back(DefaultCudaArch);
 
   return Error;
 }
@@ -2530,7 +2534,9 @@
   public:
 CudaActionBuilder(Compilation &C, DerivedArgList &Args,
   const Driver::InputList &Inputs)
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {
+  DefaultCudaArch = CudaArch::SM_20;
+}
 
 ActionBuilderReturnCode
 getDeviceDependences(OffloadAction::DeviceDependences &DA,
@@ -2645,7 +2651,9 @@
   public:
 HIPActionBuilder(Compilation &C, DerivedArgList &Args,
  const Driver::InputList &Inputs)
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {
+  DefaultCudaArch = CudaArch::GFX803;
+}
 
 bool canUseBundlerUnbundler() const override { return true; }
 
Index: cfe/trunk/test/Driver/hip-default-gpu-arch.hip
===
--- cfe/trunk/test/Driver/hip-default-gpu-arch.hip
+++ cfe/trunk/test/Driver/hip-default-gpu-arch.hip
@@ -0,0 +1,7 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -x hip -c %s 2>&1 | FileCheck %s
+
+// CHECK: {{.*}}clang{{.*}}"-target-cpu" "gfx803"


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -2329,6 +2329,10 @@
 
 /// Flag for -fgpu-rdc.
 bool Relocatable = false;
+
+/// Default GPU architecture if there's no one specified.
+CudaArch DefaultCudaArch = CudaArch::UNKNOWN;
+
   public:
 CudaActionBuilderBase(Compilation &C, DerivedArgList &Args,
   const Driver::InputList &Inputs,
@@ -2518,7 +2522,7 @@
   // supported GPUs.  sm_20 code should work correctly, if
   // suboptimally, on all newer GPUs.
   if (GpuArchList.empty())
-GpuArchList.push_back(CudaArch::SM_20);
+GpuArchList.push_back(DefaultCudaArch);
 
   return Error;
 }
@@ -2530,7 +2534,9 @@
   public:
 CudaActionBuilder(Compilation &C, DerivedArgList &Args,
   const Driver::InputList &Inputs)
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {
+  DefaultCudaArch = CudaArch::SM_20;
+}
 
 ActionBuilderReturnCode
 getDeviceDependences(OffloadAction::DeviceDependences &DA,
@@ -2645,7 +2651,9 @@
   public:
 HIPActionBuilder(Compilation &C, DerivedArgList &Args,
  const Driver::InputList &Inputs)
-: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {}
+: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {
+  DefaultCudaArch = CudaArch::GFX803;
+}
 
 bool canUseBundlerUnbundler() const override { return true; }
 
Index: cfe/trunk/test/Driver/hip-default-gpu-arch.hip
===
--- cfe/trunk/test/Driver/hip-default-gpu-arch.hip
+++ cfe/trunk/test/Driver/hip-default-gpu-arch.hip
@@ -0,0 +1,7 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -x hip -c %s 2>&1 | FileCheck %s
+
+// CHECK: {{.*}}clang{{.*}}"-target-cpu" "gfx803"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r373643 - PR43547: substitute into the type of a non-type template parameter if

2019-10-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  3 11:24:40 2019
New Revision: 373643

URL: http://llvm.org/viewvc/llvm-project?rev=373643&view=rev
Log:
PR43547: substitute into the type of a non-type template parameter if
it's instantiation-dependent, even if it's not dependent.

There might be a SFINAE check in the parameter type.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=373643&r1=373642&r2=373643&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Oct  3 11:24:40 2019
@@ -4922,9 +4922,7 @@ bool Sema::CheckTemplateArgument(NamedDe
 if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack())
   NTTPType = NTTP->getExpansionType(ArgumentPackIndex);
 
-// FIXME: Do we need to substitute into parameters here if they're
-// instantiation-dependent but not dependent?
-if (NTTPType->isDependentType() &&
+if (NTTPType->isInstantiationDependentType() &&
 !isa(Template) &&
 !Template->getDeclContext()->isDependentContext()) {
   // Do substitution on the type of the non-type template parameter.

Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp?rev=373643&r1=373642&r2=373643&view=diff
==
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Thu Oct  3 11:24:40 2019
@@ -482,3 +482,15 @@ namespace dependent_backreference {
   template void a() { X x; }
   template void b() { X x; } // expected-note 
{{substituting}}
 }
+
+namespace instantiation_dependent {
+  template void f(int);
+  template int &f(...);
+  int &rf = f(0);
+
+  // FIXME: This fails because we mishandle instantiation-dependent array 
bounds :(
+  int arr[sizeof(sizeof(int))];
+  template void g(int);
+  template int &g(...);
+  int &rg = g(0); // expected-error {{cannot bind}}
+}


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


[PATCH] D68296: [clang-format] Add ability to wrap braces after multi-line control statements

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar updated this revision to Diff 223058.
mitchell-stellar added a comment.

Rebased against master, and also added test case for 'do' statements.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68296

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestObjC.cpp

Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -207,7 +207,7 @@
"  f();\n"
"}\n");
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
-  Style.BraceWrapping.AfterControlStatement = true;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
   verifyFormat("@autoreleasepool\n"
"{\n"
"  f();\n"
@@ -237,7 +237,7 @@
"  f();\n"
"}\n");
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
-  Style.BraceWrapping.AfterControlStatement = true;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
   verifyFormat("@synchronized(self)\n"
"{\n"
"  f();\n"
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -644,7 +644,8 @@
   AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine =
   FormatStyle::SIS_WithoutElse;
   AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine = true;
-  AllowSimpleBracedStatements.BraceWrapping.AfterControlStatement = true;
+  AllowSimpleBracedStatements.BraceWrapping.AfterControlStatement =
+  FormatStyle::BWACS_Always;
 
   verifyFormat("if (true) {}", AllowSimpleBracedStatements);
   verifyFormat("if constexpr (true) {}", AllowSimpleBracedStatements);
@@ -1168,7 +1169,7 @@
   Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterCaseLabel = true;
-  Style.BraceWrapping.AfterControlStatement = true;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
   EXPECT_EQ("switch (n)\n"
 "{\n"
 "  case 0:\n"
@@ -1370,7 +1371,7 @@
   Style.AllowShortCaseLabelsOnASingleLine = true;
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterCaseLabel = true;
-  Style.BraceWrapping.AfterControlStatement = true;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
   EXPECT_EQ("switch (n)\n"
 "{\n"
 "  case 0:\n"
@@ -1441,6 +1442,131 @@
"}");
 }
 
+TEST_F(FormatTest, MultiLineControlStatements) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BraceBreakingStyle::BS_Custom;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_MultiLine;
+  Style.ColumnLimit = 20;
+  // Short lines should keep opening brace on same line.
+  EXPECT_EQ("if (foo) {\n"
+"  bar();\n"
+"}",
+format("if(foo){bar();}", Style));
+  EXPECT_EQ("if (foo) {\n"
+"  bar();\n"
+"} else {\n"
+"  baz();\n"
+"}",
+format("if(foo){bar();}else{baz();}", Style));
+  EXPECT_EQ("if (foo && bar) {\n"
+"  baz();\n"
+"}",
+format("if(foo&&bar){baz();}", Style));
+  EXPECT_EQ("if (foo) {\n"
+"  bar();\n"
+"} else if (baz) {\n"
+"  quux();\n"
+"}",
+format("if(foo){bar();}else if(baz){quux();}", Style));
+  EXPECT_EQ(
+  "if (foo) {\n"
+  "  bar();\n"
+  "} else if (baz) {\n"
+  "  quux();\n"
+  "} else {\n"
+  "  foobar();\n"
+  "}",
+  format("if(foo){bar();}else if(baz){quux();}else{foobar();}", Style));
+  EXPECT_EQ("for (;;) {\n"
+"  foo();\n"
+"}",
+format("for(;;){foo();}"));
+  EXPECT_EQ("while (1) {\n"
+"  foo();\n"
+"}",
+format("while(1){foo();}", Style));
+  EXPECT_EQ("switch (foo) {\n"
+"case bar:\n"
+"  return;\n"
+"}",
+format("switch(foo){case bar:return;}", Style));
+  EXPECT_EQ("try {\n"
+"  foo();\n"
+"} catch (...) {\n"
+"  bar();\n"
+"}",
+format("try{foo();}catch(...){bar();}", Style));
+  EXPECT_EQ("do {\n"
+"  foo();\n"
+"} while (bar &&\n"
+" baz);",
+format("do{foo();}while(bar&&baz);", Style));
+  // Long lines should put opening brace on new line.
+  EX

[PATCH] D68242: [clang-format] [PR42417] clang-format inserts a space after '->' for operator->() overloading

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar added a comment.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D68242



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


[PATCH] D68410: [AttrDocs] document always_inline

2019-10-03 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added reviewers: chandlerc, rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

GNU documentaion for always_inline:
https://gcc.gnu.org/onlinedocs/gcc/Inline.html

GNU documentation for function attributes:
https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Function-Attributes.html

Microsoft documentation for __force_inline:
https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68410

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4391,3 +4391,13 @@
 
 }];
 }
+
+
+def AlwaysInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Hint that inline substitution should be attempted when optimizations are
+disabled. Does not guarantee that inline substitution actually occurs.
+}];
+  let Heading = "always_inline";
+}
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -636,7 +636,7 @@
 def AlwaysInline : InheritableAttr {
   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [AlwaysInlineDocs];
 }
 
 def Artificial : InheritableAttr {


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4391,3 +4391,13 @@
 
 }];
 }
+
+
+def AlwaysInlineDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Hint that inline substitution should be attempted when optimizations are
+disabled. Does not guarantee that inline substitution actually occurs.
+}];
+  let Heading = "always_inline";
+}
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -636,7 +636,7 @@
 def AlwaysInline : InheritableAttr {
   let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">];
   let Subjects = SubjectList<[Function]>;
-  let Documentation = [Undocumented];
+  let Documentation = [AlwaysInlineDocs];
 }
 
 def Artificial : InheritableAttr {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r373647 - [clang-format] Add ability to wrap braces after multi-line control statements

2019-10-03 Thread Paul Hoad via cfe-commits
Author: paulhoad
Date: Thu Oct  3 11:42:31 2019
New Revision: 373647

URL: http://llvm.org/viewvc/llvm-project?rev=373647&view=rev
Log:
[clang-format] Add ability to wrap braces after multi-line control statements

Summary:
Change the BraceWrappingFlags' AfterControlStatement from a bool to an enum 
with three values:

* "Never": This is the default, and does not do any brace wrapping after 
control statements.
* "MultiLine": This only wraps braces after multi-line control statements (this 
really only happens when a ColumnLimit is specified).
* "Always": This always wraps braces after control statements.

The first and last options are backwards-compatible with "false" and "true", 
respectively.

The new "MultiLine" option is useful for when a wrapped control statement's 
indentation matches the subsequent block's indentation. It makes it easier to 
see at a glance where the control statement ends and where the block's code 
begins. For example:

```
if (
  foo
  && bar )
{
  baz();
}
```

vs.

```
if (
  foo
  && bar ) {
  baz();
}
```

Short control statements (1 line) do not wrap the brace to the next line, e.g.

```
if (foo) {
  bar();
} else {
  baz();
}
```

Reviewers: sammccall, owenpan, reuk, MyDeveloperDay, klimek

Reviewed By: MyDeveloperDay

Subscribers: MyDeveloperDay, cfe-commits

Patch By: mitchell-stellar

Tags: #clang-format, #clang, #clang-tools-extra

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

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/FormatTestObjC.cpp

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=373647&r1=373646&r2=373647&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Thu Oct  3 11:42:31 2019
@@ -778,24 +778,46 @@ the configuration (without a prefix: ``A
   class foo
   {};
 
-  * ``bool AfterControlStatement`` Wrap control statements 
(``if``/``for``/``while``/``switch``/..).
+  * ``BraceWrappingAfterControlStatementStyle AfterControlStatement``
+Wrap control statements (``if``/``for``/``while``/``switch``/..).
 
-.. code-block:: c++
+Possible values:
 
-  true:
-  if (foo())
-  {
-  } else
-  {}
-  for (int i = 0; i < 10; ++i)
-  {}
-
-  false:
-  if (foo()) {
-  } else {
-  }
-  for (int i = 0; i < 10; ++i) {
-  }
+* ``BWACS_Never`` (in configuration: ``Never``)
+  Never wrap braces after a control statement.
+
+  .. code-block:: c++
+
+if (foo()) {
+} else {
+}
+for (int i = 0; i < 10; ++i) {
+}
+
+* ``BWACS_MultiLine`` (in configuration: ``MultiLine``)
+  Only wrap braces after a multi-line control statement.
+
+  .. code-block:: c++
+
+if (foo && bar &&
+baz)
+{
+  quux();
+}
+while (foo || bar) {
+}
+
+* ``BWACS_Always`` (in configuration: ``Always``)
+  Always wrap braces after a control statement.
+
+  .. code-block:: c++
+
+if (foo())
+{
+} else
+{}
+for (int i = 0; i < 10; ++i)
+{}
 
   * ``bool AfterEnum`` Wrap enum definitions.
 

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=373647&r1=373646&r2=373647&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Thu Oct  3 11:42:31 2019
@@ -782,6 +782,40 @@ struct FormatStyle {
   /// The brace breaking style to use.
   BraceBreakingStyle BreakBeforeBraces;
 
+  // Different ways to wrap braces after control statements.
+  enum BraceWrappingAfterControlStatementStyle {
+/// Never wrap braces after a control statement.
+/// \code
+///   if (foo()) {
+///   } else {
+///   }
+///   for (int i = 0; i < 10; ++i) {
+///   }
+/// \endcode
+BWACS_Never,
+/// Only wrap braces after a multi-line control statement.
+/// \code
+///   if (foo && bar &&
+///   baz)
+///   {
+/// quux();
+///   }
+///   while (foo || bar) {
+///   }
+/// \endcode
+BWACS_MultiLine,
+/// Always wrap braces after a control statement.
+/// \code
+///   if (foo())
+///   {
+///   } else
+///   {}
+///   for (int i = 0; i < 10; ++i)
+///   {}
+/// \endcode
+BWACS_Always
+  };
+
   /// Precise control over the wrapping of braces.
   /// \code
   /// 

[PATCH] D68410: [AttrDocs] document always_inline

2019-10-03 Thread James Y Knight via Phabricator via cfe-commits
jyknight added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4399-4400
+  let Content = [{
+Hint that inline substitution should be attempted when optimizations are
+disabled. Does not guarantee that inline substitution actually occurs.
+}];

I believe the semantics are stronger than this. It should get inlined unless it 
cannot be.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68410



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


[PATCH] D68413: [clang] [cmake] Add distribution install targets for remaining components

2019-10-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: compnerd, phosek, smeenai, beanz, tstellar.

Add install targets as necessary to install bash-autocomplete,
scan-build and scan-view via LLVM_DISTRIBUTION_TARGETS.


https://reviews.llvm.org/D68413

Files:
  clang/CMakeLists.txt
  clang/tools/scan-build/CMakeLists.txt
  clang/tools/scan-view/CMakeLists.txt

Index: clang/tools/scan-view/CMakeLists.txt
===
--- clang/tools/scan-view/CMakeLists.txt
+++ clang/tools/scan-view/CMakeLists.txt
@@ -21,7 +21,9 @@
  ${CMAKE_BINARY_DIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
-install(PROGRAMS bin/${BinFile} DESTINATION bin)
+install(PROGRAMS bin/${BinFile}
+DESTINATION bin
+COMPONENT scan-view)
   endforeach()
 
   foreach(ShareFile ${ShareFiles})
@@ -33,9 +35,17 @@
  ${CMAKE_BINARY_DIR}/share/scan-view/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/${ShareFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-view/${ShareFile})
-install(FILES share/${ShareFile} DESTINATION share/scan-view)
+install(FILES share/${ShareFile}
+DESTINATION share/scan-view
+COMPONENT scan-view)
   endforeach()
 
   add_custom_target(scan-view ALL DEPENDS ${Depends})
   set_target_properties(scan-view PROPERTIES FOLDER "Misc")
+
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets("install-scan-view"
+ DEPENDS scan-view
+ COMPONENT scan-view)
+  endif()
 endif()
Index: clang/tools/scan-build/CMakeLists.txt
===
--- clang/tools/scan-build/CMakeLists.txt
+++ clang/tools/scan-build/CMakeLists.txt
@@ -41,7 +41,9 @@
  ${CMAKE_BINARY_DIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
-install(PROGRAMS bin/${BinFile} DESTINATION bin)
+install(PROGRAMS bin/${BinFile}
+DESTINATION bin
+COMPONENT scan-build)
   endforeach()
 
   foreach(LibexecFile ${LibexecFiles})
@@ -53,7 +55,9 @@
  ${CMAKE_BINARY_DIR}/libexec/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${LibexecFile})
-install(PROGRAMS libexec/${LibexecFile} DESTINATION libexec)
+install(PROGRAMS libexec/${LibexecFile}
+DESTINATION libexec
+COMPONENT scan-build)
   endforeach()
 
   foreach(ManPage ${ManPages})
@@ -65,7 +69,9 @@
  ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage})
-install(PROGRAMS man/${ManPage} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
+install(PROGRAMS man/${ManPage}
+DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
+COMPONENT scan-build)
   endforeach()
 
   foreach(ShareFile ${ShareFiles})
@@ -77,9 +83,17 @@
  ${CMAKE_BINARY_DIR}/share/scan-build/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile})
 list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile})
-install(FILES share/scan-build/${ShareFile} DESTINATION share/scan-build)
+install(FILES share/scan-build/${ShareFile}
+DESTINATION share/scan-build
+COMPONENT scan-build)
   endforeach()
 
   add_custom_target(scan-build ALL DEPENDS ${Depends})
   set_target_properties(scan-build PROPERTIES FOLDER "Misc")
+
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets("install-scan-build"
+ DEPENDS scan-build
+ COMPONENT scan-build)
+  endif()
 endif()
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -442,9 +442,15 @@
  COMPONENT clang-headers)
   endif()
 
+  add_custom_target(bash-autocomplete DEPENDS utils/bash-autocomplete.sh)
   install(PROGRAMS utils/bash-autocomplete.sh
-DESTINATION share/clang
-)
+  DESTINATION share/clang
+  COMPONENT bash-autocomplete)
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-bash-autocomplete
+ DEPENDS bash-autocomplete
+ COMPONENT bash-autocomplete)
+  endif()
 endif()
 
 add_definitions( -D_GNU_SOURCE )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68410: [AttrDocs] document always_inline

2019-10-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a reviewer: aaron.ballman.
lebedev.ri added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4394-4395
 }
+
+
+def AlwaysInlineDocs : Documentation {

One too many lines


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68410



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


[PATCH] D68412: [clang] [cmake] Support LLVM_DISTRIBUTION_COMPONENTS in stand-alone build

2019-10-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: compnerd, tstellar, phosek, beanz, smeenai.

https://reviews.llvm.org/D68412

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -114,6 +114,7 @@
   include(TableGen)
   include(HandleLLVMOptions)
   include(VersionFromVCS)
+  include(LLVMDistributionSupport)
 
   set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
 
@@ -852,6 +853,10 @@
 endif()
 add_subdirectory(utils/hmaptool)
 
+if(CLANG_BUILT_STANDALONE)
+  llvm_distribution_add_targets()
+endif()
+
 configure_file(
   ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake
   ${CLANG_BINARY_DIR}/include/clang/Config/config.h)


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -114,6 +114,7 @@
   include(TableGen)
   include(HandleLLVMOptions)
   include(VersionFromVCS)
+  include(LLVMDistributionSupport)
 
   set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
 
@@ -852,6 +853,10 @@
 endif()
 add_subdirectory(utils/hmaptool)
 
+if(CLANG_BUILT_STANDALONE)
+  llvm_distribution_add_targets()
+endif()
+
 configure_file(
   ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake
   ${CLANG_BINARY_DIR}/include/clang/Config/config.h)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68296: [clang-format] Add ability to wrap braces after multi-line control statements

2019-10-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373647: [clang-format] Add ability to wrap braces after 
multi-line control statements (authored by paulhoad, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68296?vs=223058&id=223066#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68296

Files:
  cfe/trunk/docs/ClangFormatStyleOptions.rst
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp
  cfe/trunk/unittests/Format/FormatTestObjC.cpp

Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -782,6 +782,40 @@
   /// The brace breaking style to use.
   BraceBreakingStyle BreakBeforeBraces;
 
+  // Different ways to wrap braces after control statements.
+  enum BraceWrappingAfterControlStatementStyle {
+/// Never wrap braces after a control statement.
+/// \code
+///   if (foo()) {
+///   } else {
+///   }
+///   for (int i = 0; i < 10; ++i) {
+///   }
+/// \endcode
+BWACS_Never,
+/// Only wrap braces after a multi-line control statement.
+/// \code
+///   if (foo && bar &&
+///   baz)
+///   {
+/// quux();
+///   }
+///   while (foo || bar) {
+///   }
+/// \endcode
+BWACS_MultiLine,
+/// Always wrap braces after a control statement.
+/// \code
+///   if (foo())
+///   {
+///   } else
+///   {}
+///   for (int i = 0; i < 10; ++i)
+///   {}
+/// \endcode
+BWACS_Always
+  };
+
   /// Precise control over the wrapping of braces.
   /// \code
   ///   # Should be declared this way:
@@ -817,23 +851,7 @@
 /// \endcode
 bool AfterClass;
 /// Wrap control statements (``if``/``for``/``while``/``switch``/..).
-/// \code
-///   true:
-///   if (foo())
-///   {
-///   } else
-///   {}
-///   for (int i = 0; i < 10; ++i)
-///   {}
-///
-///   false:
-///   if (foo()) {
-///   } else {
-///   }
-///   for (int i = 0; i < 10; ++i) {
-///   }
-/// \endcode
-bool AfterControlStatement;
+BraceWrappingAfterControlStatementStyle AfterControlStatement;
 /// Wrap enum definitions.
 /// \code
 ///   true:
Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
@@ -306,8 +306,24 @@
 }
 // Try to merge a control statement block with left brace wrapped
 if (I[1]->First->is(tok::l_brace) &&
-TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for)) {
-  return Style.BraceWrapping.AfterControlStatement
+(TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for,
+ tok::kw_switch, tok::kw_try, tok::kw_do) ||
+ (TheLine->First->is(tok::r_brace) && TheLine->First->Next &&
+  TheLine->First->Next->isOneOf(tok::kw_else, tok::kw_catch))) &&
+Style.BraceWrapping.AfterControlStatement ==
+FormatStyle::BWACS_MultiLine) {
+  // If possible, merge the next line's wrapped left brace with the current
+  // line. Otherwise, leave it on the next line, as this is a multi-line
+  // control statement.
+  return (Style.ColumnLimit == 0 ||
+  TheLine->Last->TotalLength <= Style.ColumnLimit)
+ ? 1
+ : 0;
+} else if (I[1]->First->is(tok::l_brace) &&
+   TheLine->First->isOneOf(tok::kw_if, tok::kw_while,
+   tok::kw_for)) {
+  return (Style.BraceWrapping.AfterControlStatement ==
+  FormatStyle::BWACS_Always)
  ? tryMergeSimpleBlock(I, E, Limit)
  : 0;
 }
@@ -410,7 +426,8 @@
   SmallVectorImpl::const_iterator E, unsigned Limit) {
 if (Limit == 0)
   return 0;
-if (Style.BraceWrapping.AfterControlStatement &&
+if (Style.BraceWrapping.AfterControlStatement ==
+FormatStyle::BWACS_Always &&
 I[1]->First->is(tok::l_brace) &&
 Style.AllowShortBlocksOnASingleLine == FormatStyle::SBS_Never)
   return 0;
@@ -523,8 +540,9 @@
 return 0;
   if (!Style.AllowShortIfStatementsOnASingleLine &&
   Line.startsWith(tok::kw_if) &&
-  Style.BraceWrapping.AfterControlStatement && I + 2 != E &&
-  !I[2]->First->is(tok::r_brace))
+  Style.BraceWrapping.AfterControlStatement ==
+  FormatStyle::BWACS_Alway

[PATCH] D68410: [AttrDocs] document always_inline

2019-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4400
+Hint that inline substitution should be attempted when optimizations are
+disabled. Does not guarantee that inline substitution actually occurs.
+}];

It may make sense to link back to MSDN and GCC if we're honoring their 
semantics. We seem to do this for MSDN regularly, but a bit less common for the 
GCC docs.



Comment at: clang/include/clang/Basic/AttrDocs.td:4402
+}];
+  let Heading = "always_inline";
+}

Can you add the various spellings to this heading?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68410



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


[PATCH] D67660: [clang-format] [PR43338] C# clang format has space issues betweern C# only keywords

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar accepted this revision.
mitchell-stellar added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D67660



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


r373648 - Check for qualified function types after substituting into the operand

2019-10-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct  3 11:55:23 2019
New Revision: 373648

URL: http://llvm.org/viewvc/llvm-project?rev=373648&view=rev
Log:
Check for qualified function types after substituting into the operand
of 'typeid'.

This is a rare place where it's valid for a function type to be
substituted but not valid for a qualified function type to be
substituted, so needs a special check.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=373648&r1=373647&r2=373648&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct  3 11:55:23 
2019
@@ -6211,6 +6211,8 @@ def err_invalid_qualified_function_type
 def err_compound_qualified_function_type : Error<
   "%select{block pointer|pointer|reference}0 to function type %select{%2 |}1"
   "cannot have '%3' qualifier">;
+def err_qualified_function_typeid : Error<
+  "type operand %0 of 'typeid' cannot have '%1' qualifier">;
 
 def err_ref_qualifier_overload : Error<
   "cannot overload a member function %select{without a ref-qualifier|with "

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=373648&r1=373647&r2=373648&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Oct  3 11:55:23 2019
@@ -1522,6 +1522,8 @@ public:
   QualType BuildAddressSpaceAttr(QualType &T, Expr *AddrSpace,
  SourceLocation AttrLoc);
 
+  bool CheckQualifiedFunctionForTypeId(QualType T, SourceLocation Loc);
+
   bool CheckFunctionReturnType(QualType T, SourceLocation Loc);
 
   /// Build a function type.

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=373648&r1=373647&r2=373648&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Oct  3 11:55:23 2019
@@ -453,6 +453,9 @@ ExprResult Sema::BuildCXXTypeId(QualType
   if (T->isVariablyModifiedType())
 return ExprError(Diag(TypeidLoc, diag::err_variably_modified_typeid) << T);
 
+  if (CheckQualifiedFunctionForTypeId(T, TypeidLoc))
+return ExprError();
+
   return new (Context) CXXTypeidExpr(TypeInfoType.withConst(), Operand,
  SourceRange(TypeidLoc, RParenLoc));
 }

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=373648&r1=373647&r2=373648&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Oct  3 11:55:23 2019
@@ -1955,7 +1955,8 @@ static bool checkQualifiedFunction(Sema
QualifiedFunctionKind QFK) {
   // Does T refer to a function type with a cv-qualifier or a ref-qualifier?
   const FunctionProtoType *FPT = T->getAs();
-  if (!FPT || (FPT->getMethodQuals().empty() && FPT->getRefQualifier() == 
RQ_None))
+  if (!FPT ||
+  (FPT->getMethodQuals().empty() && FPT->getRefQualifier() == RQ_None))
 return false;
 
   S.Diag(Loc, diag::err_compound_qualified_function_type)
@@ -1964,6 +1965,17 @@ static bool checkQualifiedFunction(Sema
   return true;
 }
 
+bool Sema::CheckQualifiedFunctionForTypeId(QualType T, SourceLocation Loc) {
+  const FunctionProtoType *FPT = T->getAs();
+  if (!FPT ||
+  (FPT->getMethodQuals().empty() && FPT->getRefQualifier() == RQ_None))
+return false;
+
+  Diag(Loc, diag::err_qualified_function_typeid)
+  << T << getFunctionQualifiersAsString(FPT);
+  return true;
+}
+
 /// Build a pointer type.
 ///
 /// \param T The type to which we'll be building a pointer.

Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp?rev=373648&r1=373647&r2=373648&view=diff
==
--- cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp Thu Oct  3 11:55:23 2019
@@ -192,6 +192,13 @@ struct TypeId0 {
   }
 };
 
+template
+struct TypeId1 {
+  const std::type_info &f() {
+return typeid(T); // expected-error-re 2{{type operand 'void () 
{{const|&}}' of 'typeid' cannot have '{{const|&}}'

r373649 - [HIP] Use option -nogpulib to disable linking device lib

2019-10-03 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Thu Oct  3 11:59:56 2019
New Revision: 373649

URL: http://llvm.org/viewvc/llvm-project?rev=373649&view=rev
Log:
[HIP] Use option -nogpulib to disable linking device lib

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

Added:
cfe/trunk/test/Driver/hip-no-device-libs.hip
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/lib/Driver/ToolChains/HIP.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=373649&r1=373648&r2=373649&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Oct  3 11:59:56 2019
@@ -2556,7 +2556,9 @@ def no__dead__strip__inits__and__terms :
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Disable builtin #include directories">;
 def nocudainc : Flag<["-"], "nocudainc">;
-def nocudalib : Flag<["-"], "nocudalib">;
+def nogpulib : Flag<["-"], "nogpulib">,
+  HelpText<"Do not link device library for CUDA/HIP device compilation">;
+def : Flag<["-"], "nocudalib">, Alias;
 def nodefaultlibs : Flag<["-"], "nodefaultlibs">;
 def nofixprebinding : Flag<["-"], "nofixprebinding">;
 def nolibc : Flag<["-"], "nolibc">;

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=373649&r1=373648&r2=373649&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Thu Oct  3 11:59:56 2019
@@ -121,7 +121,7 @@ CudaInstallationDetector::CudaInstallati
   Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");
   }
 
-  bool NoCudaLib = Args.hasArg(options::OPT_nocudalib);
+  bool NoCudaLib = Args.hasArg(options::OPT_nogpulib);
 
   for (const auto &Candidate : Candidates) {
 InstallPath = Candidate.Path;
@@ -628,7 +628,7 @@ void CudaToolChain::addClangTargetOption
   CC1Args.push_back("-fgpu-rdc");
   }
 
-  if (DriverArgs.hasArg(options::OPT_nocudalib))
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;
 
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);

Modified: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/HIP.cpp?rev=373649&r1=373648&r2=373649&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp Thu Oct  3 11:59:56 2019
@@ -286,6 +286,9 @@ void HIPToolChain::addClangTargetOptions
 CC1Args.append({"-fvisibility", "hidden"});
 CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
+
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
+return;
   ArgStringList LibraryPaths;
 
   // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.

Added: cfe/trunk/test/Driver/hip-no-device-libs.hip
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-no-device-libs.hip?rev=373649&view=auto
==
--- cfe/trunk/test/Driver/hip-no-device-libs.hip (added)
+++ cfe/trunk/test/Driver/hip-no-device-libs.hip Thu Oct  3 11:59:56 2019
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -nogpulib -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK-NOT: "-mlink-builtin-bitcode"
+


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


[PATCH] D68300: [HIP] Use option -nogpulib to disable linking device lib

2019-10-03 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373649: [HIP] Use option -nogpulib to disable linking device 
lib (authored by yaxunl, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68300?vs=223024&id=223068#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68300

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
  cfe/trunk/lib/Driver/ToolChains/HIP.cpp
  cfe/trunk/test/Driver/hip-no-device-libs.hip


Index: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp
@@ -286,6 +286,9 @@
 CC1Args.append({"-fvisibility", "hidden"});
 CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
+
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
+return;
   ArgStringList LibraryPaths;
 
   // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
Index: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
@@ -121,7 +121,7 @@
   Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");
   }
 
-  bool NoCudaLib = Args.hasArg(options::OPT_nocudalib);
+  bool NoCudaLib = Args.hasArg(options::OPT_nogpulib);
 
   for (const auto &Candidate : Candidates) {
 InstallPath = Candidate.Path;
@@ -628,7 +628,7 @@
   CC1Args.push_back("-fgpu-rdc");
   }
 
-  if (DriverArgs.hasArg(options::OPT_nocudalib))
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;
 
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2556,7 +2556,9 @@
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Disable builtin #include directories">;
 def nocudainc : Flag<["-"], "nocudainc">;
-def nocudalib : Flag<["-"], "nocudalib">;
+def nogpulib : Flag<["-"], "nogpulib">,
+  HelpText<"Do not link device library for CUDA/HIP device compilation">;
+def : Flag<["-"], "nocudalib">, Alias;
 def nodefaultlibs : Flag<["-"], "nodefaultlibs">;
 def nofixprebinding : Flag<["-"], "nofixprebinding">;
 def nolibc : Flag<["-"], "nolibc">;
Index: cfe/trunk/test/Driver/hip-no-device-libs.hip
===
--- cfe/trunk/test/Driver/hip-no-device-libs.hip
+++ cfe/trunk/test/Driver/hip-no-device-libs.hip
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -nogpulib -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK-NOT: "-mlink-builtin-bitcode"
+


Index: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp
@@ -286,6 +286,9 @@
 CC1Args.append({"-fvisibility", "hidden"});
 CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
+
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
+return;
   ArgStringList LibraryPaths;
 
   // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
Index: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
@@ -121,7 +121,7 @@
   Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");
   }
 
-  bool NoCudaLib = Args.hasArg(options::OPT_nocudalib);
+  bool NoCudaLib = Args.hasArg(options::OPT_nogpulib);
 
   for (const auto &Candidate : Candidates) {
 InstallPath = Candidate.Path;
@@ -628,7 +628,7 @@
   CC1Args.push_back("-fgpu-rdc");
   }
 
-  if (DriverArgs.hasArg(options::OPT_nocudalib))
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;
 
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2556,7 +2556,9 @@
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Disable builtin #include directories">;
 def nocudainc : Flag<["-"], "nocudainc">;
-def nocudalib : Flag<["-"], "nocudalib">;
+def nogpulib : Flag<["-"], "nogpulib">,
+  HelpText<"Do not link device library for CUDA/HIP

[PATCH] D67629: [clang-format] [PR43333] Fix C# breaking before function name when using Attributes

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar accepted this revision.
mitchell-stellar added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D67629



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


[PATCH] D67159: [clang] New __attribute__((__clang_arm_mve_alias)).

2019-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked 2 inline comments as done.
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Decl.cpp:3082
+static bool ArmMveAliasValid(unsigned BuiltinID, StringRef AliasName) {
+  // This will be filled in by Tablegen which isn't written yet
+  return false;

simon_tatham wrote:
> aaron.ballman wrote:
> > Comment should have a `FIXME` prefix, but tbh, I'm a little uncomfortable 
> > adopting the attribute without this being implemented. I assume the plan is 
> > to tablegen a header file that gets included here to provide the lookup?
> Yes: D67161, which I intend to commit as part of the same patch series once 
> everything in it is approved, fills in this function with tablegen output.
> 
> I could roll both into the same monolithic patch, but I thought it would be 
> better to break it up into manageable pieces as far as possible, especially 
> when some of them (like this one) would need to be reviewed by people with 
> significantly different expertise from the rest.
Ah, I didn't realize that was so involved; keeping them split makes sense.



Comment at: clang/lib/AST/Decl.cpp:3107
+if (!ArmMveAliasValid(BuiltinID, getIdentifier()->getName())) {
+  getASTContext().getDiagnostics().Report(
+getLocation(), diag::err_attribute_arm_mve_alias);

simon_tatham wrote:
> aaron.ballman wrote:
> > I'm not certain how comfortable I am with having this function produce a 
> > diagnostic. That seems like unexpected behavior for a function attempting 
> > to get a builtin ID. I think this should be the responsibility of the 
> > caller.
> The //caller//? But there are many possible callers of this function. You 
> surely didn't mean to suggest duplicating the diagnostic at all those call 
> sites.
> 
> Perhaps it would make more sense to have all the calculation in this 
> `getBuiltinID` method move into a function called once, early in the 
> `FunctionDecl`'s lifetime, which figures out the builtin ID (if any) and 
> stashes it in a member variable? Then //that// would issue the diagnostic, if 
> any (and it would be called from a context where that was a sensible thing to 
> do), and `getBuiltinID` itself would become a mere accessor function.
> The caller? But there are many possible callers of this function. You surely 
> didn't mean to suggest duplicating the diagnostic at all those call sites.

Yes, I did. :-) No caller is going to expect that calling a `const` function 
that gets a builtin ID is going to issue diagnostics and so this runs the risk 
of generating diagnostics in surprising situations, such as from AST matchers.

> Perhaps it would make more sense to have all the calculation in this 
> getBuiltinID method move into a function called once, early in the 
> FunctionDecl's lifetime, which figures out the builtin ID (if any) and 
> stashes it in a member variable? Then that would issue the diagnostic, if any 
> (and it would be called from a context where that was a sensible thing to 
> do), and getBuiltinID itself would become a mere accessor function.

That might make sense, but I don't have a good idea of what performance 
concerns that might raise. If there are a lot of functions and we never need to 
check if they have a builtin ID, that could be expensive for little gain.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:7442
+  case ParsedAttr::AT_ClangBuiltinOverride:
+handleClangBuiltinOverrideAttribute(S, D, AL);
+break;

simon_tatham wrote:
> aaron.ballman wrote:
> > You should be able to call 
> > `handleSimpleAttribute()` instead.
> Oh, nearly forgot: apparently I can't, because that template expects the 
> attribute to have a constructor that takes only an `ASTContext` and an 
> `AttributeCommonInfo`. But the constructor for my attribute also takes an 
> `IdentifierInfo` giving the builtin name.
Ah, good point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67159



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


[PATCH] D68415: [clang-format] C++11 braced lists should respect the SpacesInParentheses setting

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar created this revision.
mitchell-stellar added reviewers: MyDeveloperDay, reuk, owenpan.
mitchell-stellar added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

According to the clang-format documentation, "Fundamentally, C++11 braced lists 
are formatted exactly like function calls would be formatted in their place. If 
the braced list follows a name (e.g. a type or variable name), clang-format 
formats as if the `{}` were the parentheses of a function call with that name."

This patch furthers the treatment of C++11 braced list braces as parentheses by 
respecting the `SpacesInParentheses` setting.


Repository:
  rC Clang

https://reviews.llvm.org/D68415

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8210,6 +8210,31 @@
   SpaceBeforeBrace.SpaceBeforeCpp11BracedList = true;
   verifyFormat("vector x {1, 2, 3, 4};", SpaceBeforeBrace);
   verifyFormat("f({}, {{}, {}}, MyMap[{k, v}]);", SpaceBeforeBrace);
+
+  FormatStyle SpaceBetweenBraces = getLLVMStyle();
+  SpaceBetweenBraces.SpacesInAngles = true;
+  SpaceBetweenBraces.SpacesInParentheses = true;
+  SpaceBetweenBraces.SpacesInSquareBrackets = true;
+  verifyFormat("vector< int > x{ 1, 2, 3, 4 };", SpaceBetweenBraces);
+  verifyFormat("f( {}, { {}, {} }, MyMap[ { k, v } ] );", SpaceBetweenBraces);
+  verifyFormat("vector< int > x{ // comment 1\n"
+   " 1, 2, 3, 4 };",
+   SpaceBetweenBraces);
+  SpaceBetweenBraces.ColumnLimit = 20;
+  EXPECT_EQ("vector< int > x{\n"
+"1, 2, 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  SpaceBetweenBraces.ColumnLimit = 24;
+  EXPECT_EQ("vector< int > x{ 1, 2,\n"
+" 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  EXPECT_EQ("vector< int > x{\n"
+"1,\n"
+"2,\n"
+"3,\n"
+"4,\n"
+"};",
+format("vectorx{1,2,3,4,};", SpaceBetweenBraces));
 }
 
 TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2188,7 +2188,8 @@
 if (Current->is(TT_LineComment)) {
   if (Current->Previous->BlockKind == BK_BracedInit &&
   Current->Previous->opensScope())
-Current->SpacesRequiredBefore = Style.Cpp11BracedListStyle ? 0 : 1;
+Current->SpacesRequiredBefore =
+(Style.Cpp11BracedListStyle && !Style.SpacesInParentheses) ? 0 : 1;
   else
 Current->SpacesRequiredBefore = Style.SpacesBeforeTrailingComments;
 
@@ -2628,7 +2629,7 @@
   if ((Left.is(tok::l_brace) && Left.BlockKind != BK_Block) ||
   (Right.is(tok::r_brace) && Right.MatchingParen &&
Right.MatchingParen->BlockKind != BK_Block))
-return !Style.Cpp11BracedListStyle;
+return Style.Cpp11BracedListStyle ? Style.SpacesInParentheses : true;
   if (Left.is(TT_BlockComment))
 // No whitespace in x(/*foo=*/1), except for JavaScript.
 return Style.Language == FormatStyle::LK_JavaScript ||


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8210,6 +8210,31 @@
   SpaceBeforeBrace.SpaceBeforeCpp11BracedList = true;
   verifyFormat("vector x {1, 2, 3, 4};", SpaceBeforeBrace);
   verifyFormat("f({}, {{}, {}}, MyMap[{k, v}]);", SpaceBeforeBrace);
+
+  FormatStyle SpaceBetweenBraces = getLLVMStyle();
+  SpaceBetweenBraces.SpacesInAngles = true;
+  SpaceBetweenBraces.SpacesInParentheses = true;
+  SpaceBetweenBraces.SpacesInSquareBrackets = true;
+  verifyFormat("vector< int > x{ 1, 2, 3, 4 };", SpaceBetweenBraces);
+  verifyFormat("f( {}, { {}, {} }, MyMap[ { k, v } ] );", SpaceBetweenBraces);
+  verifyFormat("vector< int > x{ // comment 1\n"
+   " 1, 2, 3, 4 };",
+   SpaceBetweenBraces);
+  SpaceBetweenBraces.ColumnLimit = 20;
+  EXPECT_EQ("vector< int > x{\n"
+"1, 2, 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  SpaceBetweenBraces.ColumnLimit = 24;
+  EXPECT_EQ("vector< int > x{ 1, 2,\n"
+" 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  EXPECT_EQ("vector< int > x{\n"
+"1,\n"
+"2,\n"
+"3,\n"
+"4,\n"
+"};",
+format("vectorx{1,2,3,4,};", SpaceBetweenBraces));
 }
 
 TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
Index: clang/li

[PATCH] D68410: [AttrDocs] document always_inline

2019-10-03 Thread Miguel Ojeda via Phabricator via cfe-commits
ojeda added a comment.

Note that the latest GCC docs (rather than 4.1.2) are at: 
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

For reference, this was triggered from: 
https://lore.kernel.org/lkml/cakwvodm_gouedjayxtqctuvdl+9vwvfeofhv06mlmyva75c...@mail.gmail.com/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68410



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


[PATCH] D67775: [Sema] Split out -Wformat-type-confusion from -Wformat-pedantic

2019-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D67775#1691999 , @erik.pilkington 
wrote:

> Ping!


Sorry for the delayed review -- thank you for working on clearing this up!




Comment at: clang/include/clang/AST/FormatString.h:259
+NoMatch = 0,
+/// The conversion specifier and the argument type are compatible.
+Match = 1,

Can you add: `For instance, "%d" and _Bool.`



Comment at: clang/lib/Sema/SemaChecking.cpp:8165
+if (ImplicitMatch == ArgType::NoMatchTypeConfusion)
+  Match = ArgType::NoMatchTypeConfusion;
   }

How about:
```
if (ImplicitMatch == ArgType::NoMatchPedantic ||
ImplicitMatch == ArgType::NoMatchTypeConfusion)
  Match = ImplicitMatch;
```



Comment at: clang/test/Sema/format-strings-pedantic.c:1
-// RUN: %clang_cc1 -fsyntax-only -verify -Wformat -Wformat-pedantic -isystem 
%S/Inputs %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat -Wformat-type-confusion %s
 

Are we losing test coverage for `-Wformat-pedantic`, or do we have other tests 
covering that elsewhere? I would have expected this test file's contents to 
exercise pedantic cases.



Comment at: clang/test/Sema/format-type-confusion.c:13
+ b, // expected-warning {{format specifies type 'unsigned short' but 
the argument has type '_Bool'}}
+ b, b, b, b, b);
+

Just double-checking, but the reason we don't diagnose the `%c` here is because 
of `-Wno-format`?


Repository:
  rC Clang

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

https://reviews.llvm.org/D67775



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


[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a subscriber: rsmith.
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:1072
+NoBuiltinAttr *
+Sema::mergeNoBuiltinAttr(Sema &S, Decl *D, const AttributeCommonInfo &CI,
+ llvm::ArrayRef FunctionNames) {

gchatelet wrote:
> aaron.ballman wrote:
> > You're missing a call to this function within `mergeDeclAttribute()` in 
> > SemaDecl.cpp.
> Thx, I rearranged the signature a bit, do you happen to know how 
> `mergeDeclAttribute` is tested?
Through redeclarations, e.g.,
```
[[some_attr]] void func();
[[some_other_attr]] void func();

[[a_third_attr, some_attr]] void func() {
}
```



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:1086-1089
+  if (FunctionNamesSet.count(Wildcard) > 0) {
+FunctionNamesSet.clear();
+FunctionNamesSet.insert(Wildcard);
+  }

gchatelet wrote:
> aaron.ballman wrote:
> > Rather than walking the entire set like this, would it make more sense to 
> > look for the wildcard in the above loop before inserting the name, and set 
> > a local variable if found, so that you can do the clear without having to 
> > rescan the entire list?
> This is is conflict with the `llvm::copy` suggestion above. Which one do you 
> prefer?
Walking the list and not calling `llvm::copy`.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:1098-1099
+
+  if (D->hasAttr())
+D->dropAttr();
+

gchatelet wrote:
> gchatelet wrote:
> > aaron.ballman wrote:
> > > Just making sure I understand the semantics you want: redeclarations do 
> > > not have to have matching lists of builtins, but instead the definition 
> > > will use a merged list? e.g.,
> > > ```
> > > [[clang::no_builtin("memset")]] void whatever();
> > > [[clang::no_builtin("memcpy")]] void whatever();
> > > 
> > > [[clang::no_builtin("memmove")]] void whatever() {
> > >  // Will not use memset, memcpy, or memmove builtins.
> > > }
> > > ```
> > > That seems a bit strange, to me. In fact, being able to apply this 
> > > attribute to a declaration seems a bit like a mistake -- this only 
> > > impacts the definition of the function, and I can't imagine good things 
> > > coming from hypothetical code like:
> > > ```
> > > [[clang::no_builtin("memset")]] void whatever();
> > > #include "whatever.h" // Provides a library declaration of whatever() 
> > > with no restrictions on it
> > > ```
> > > WDYT about restricting this attribute to only appear on definitions?
> > That's a very good point. Thx for noticing.
> > Indeed I think it only makes sense to have the attribute on the function 
> > definition.
> > 
> > I've tried to to use `FunctionDecl->hasBody()` during attribute handling in 
> > the Sema phase but it seems like the `FunctionDecl` is not complete at this 
> > point.
> > All calls to `hasBody()` return `false`, if I repeat the operation in 
> > `CGCall` then `hasBody` returns `true` and I can see the 
> > `CompoundStatement`.
> > 
> > Do you have any recommendations on where to perform the check?
> So after some investigations it turns out that 
> `FunctionDecl::isThisDeclarationADefinition` is buggy (returns always 
> `false`) when called from `ProcessDeclAttribute`.
> I believe it's because the `CompoundStatement` is not parsed at this point.
> 
> As a matter of fact all code using this function in `ProcessDeclAttribute` is 
> dead code (see D68379 which disables the dead code, tests are still passing)
> 
> 
> I'm unsure of how to fix this, it may be possible of using 
> `FunctionDecl::setWillHaveBody`in [[ 
> https://github.com/llvm/llvm-project/blob/0577a0cedbc5be4cd4c20ba53d3dbdac6bff9a0a/clang/lib/Sema/SemaDecl.cpp#L8820
>  | this switch ]].
> So after some investigations it turns out that 
> FunctionDecl::isThisDeclarationADefinition is buggy (returns always false) 
> when called from ProcessDeclAttribute.

That is a bit odd to me; we call it in a half dozen places in SemaDeclAttr.cpp, 
all of which get called from `ProcessDeclAttribute`. Are ALL of those uses 
broken currently?!

> As a matter of fact all code using this function in ProcessDeclAttribute is 
> dead code (see D68379 which disables the dead code, tests are still passing)

You got four of the six. What about the use in 
`handleObjCSuppresProtocolAttr()` and the second use in `handleAliasAttr()`?

> I'm unsure of how to fix this, it may be possible of using 
> FunctionDecl::setWillHaveBodyin this switch.

I'm also unsure of a good way forward. @rsmith may have ideas too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028



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


[PATCH] D67847: [Support] make report_fatal_error `abort` instead of `exit`

2019-10-03 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

The `abort()` function raises SIGABRT, for which the default behavior is to 
trigger a coredump. Do we actually want that behavior?

Either `_exit()` (long available extension, which lld already uses) or 
`quick_exit()` (the new C standard way) seem possibly preferable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67847



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


[PATCH] D68377: [Builtins] Teach Clang about memccpy

2019-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Test cases?




Comment at: include/clang/Basic/Builtins.def:483
 BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
+BUILTIN(__builtin_memccpy, "v*v*vC*iz", "nF")
 BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")

GCC doesn't seem to have `__builtin_memccpy`? https://godbolt.org/z/jbthQ3


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

https://reviews.llvm.org/D68377



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


[PATCH] D67847: [Support] make report_fatal_error `abort` instead of `exit`

2019-10-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D67847#1691898 , @jyknight wrote:

> The `abort()` function raises SIGABRT, for which the default behavior is to 
> trigger a coredump. Do we actually want that behavior?
>
> Either `_exit()` (long available extension, which lld already uses) or 
> `quick_exit()` (the new C standard way) seem possibly preferable?


I think this patch is more for the purpose of making error handling better than 
for fixing PR35547. Fixing PR35547 is probably just a side effect. Apologies 
that I should have updated the summary to reflect that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67847



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


[PATCH] D68332: [clang-format] [PR43531] clang-format damages "alternative representations" for operators

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar requested changes to this revision.
mitchell-stellar added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2892
+  if (Left.is(TT_UnaryOperator)) {
+// Don't combine the unary operators !~ into "compl5" and "not5"
+// when using alternative operators "compl" and "not"

Without context, "compl5" and "not5" do not make sense. Can you try to rephrase 
this comment?



Comment at: clang/lib/Format/TokenAnnotator.cpp:2896
+if (!Right.is(tok::l_paren)) {
+  if (Left.is(tok::exclaim) && Left.TokenText.equals("not"))
+return true;

For consistency, `Left.TokenText == "not"` may be better. I cannot find another 
instance of `.equals()`.



Comment at: clang/unittests/Format/FormatTest.cpp:14445
+TEST_F(FormatTest, AlternativeOperators) {
+  // Test case for bug https://bugs.llvm.org/show_bug.cgi?id=43531
+  verifyFormat("int a and b;");

Instead of using a URL link, perhaps describe in words what this test is 
supposed to do?


Repository:
  rC Clang

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

https://reviews.llvm.org/D68332



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


[PATCH] D68415: [clang-format] C++11 braced lists should respect the SpacesInParentheses setting

2019-10-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Should we have  `SpacesInBraces`?  as a first class formatting option, given 
that we have?

  SpaceBetweenBraces.SpacesInAngles = true;
  SpaceBetweenBraces.SpacesInParentheses = true;
  SpaceBetweenBraces.SpacesInSquareBrackets = true;


Repository:
  rC Clang

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

https://reviews.llvm.org/D68415



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


[PATCH] D68415: [clang-format] C++11 braced lists should respect the SpacesInParentheses setting

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar added a comment.

I don't think that's a good idea, considering the fact that braces can mean 
different things in different contexts, and it would cause trouble for existing 
clang-format settings.

If a hypothetical `SpacesInBraces` were `false` by default, then you could have 
clang-format output something like:

`[](int foo) {bar(foo);}`

Currently, it is `[](int foo) { bar(foo); }`.

If a hypothetical `SpacesInBraces` were `true` by default, then you could have 
clang-format output something like:

`vector x{ 1, 2, 3, 4 };`

Currently, it is `vector x{1, 2, 3, 4};`.

This patch is minimally invasive and adheres to the existing documentation.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68415



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


[PATCH] D68377: [Builtins] Teach Clang about memccpy

2019-10-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added a comment.

It is not very obvious for me what kind of test should be done here. I would be 
grateful if you could show me an example in tree.




Comment at: include/clang/Basic/Builtins.def:483
 BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
+BUILTIN(__builtin_memccpy, "v*v*vC*iz", "nF")
 BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")

aaron.ballman wrote:
> GCC doesn't seem to have `__builtin_memccpy`? https://godbolt.org/z/jbthQ3
Ok, I will drop it.


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

https://reviews.llvm.org/D68377



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


[PATCH] D68415: [clang-format] C++11 braced lists should respect the SpacesInParentheses setting

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar updated this revision to Diff 223077.
mitchell-stellar added a comment.

Added additional unit tests to verify that the `SpaceInEmptyParentheses` 
setting is also correctly adhered to.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68415

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8210,6 +8210,34 @@
   SpaceBeforeBrace.SpaceBeforeCpp11BracedList = true;
   verifyFormat("vector x {1, 2, 3, 4};", SpaceBeforeBrace);
   verifyFormat("f({}, {{}, {}}, MyMap[{k, v}]);", SpaceBeforeBrace);
+
+  FormatStyle SpaceBetweenBraces = getLLVMStyle();
+  SpaceBetweenBraces.SpacesInAngles = true;
+  SpaceBetweenBraces.SpacesInParentheses = true;
+  SpaceBetweenBraces.SpacesInSquareBrackets = true;
+  verifyFormat("vector< int > x{ 1, 2, 3, 4 };", SpaceBetweenBraces);
+  verifyFormat("f( {}, { {}, {} }, MyMap[ { k, v } ] );", SpaceBetweenBraces);
+  verifyFormat("vector< int > x{ // comment 1\n"
+   " 1, 2, 3, 4 };",
+   SpaceBetweenBraces);
+  SpaceBetweenBraces.ColumnLimit = 20;
+  EXPECT_EQ("vector< int > x{\n"
+"1, 2, 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  SpaceBetweenBraces.ColumnLimit = 24;
+  EXPECT_EQ("vector< int > x{ 1, 2,\n"
+" 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  EXPECT_EQ("vector< int > x{\n"
+"1,\n"
+"2,\n"
+"3,\n"
+"4,\n"
+"};",
+format("vectorx{1,2,3,4,};", SpaceBetweenBraces));
+  verifyFormat("vector< int > x{};", SpaceBetweenBraces);
+  SpaceBetweenBraces.SpaceInEmptyParentheses = true;
+  verifyFormat("vector< int > x{ };", SpaceBetweenBraces);
 }
 
 TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2188,7 +2188,8 @@
 if (Current->is(TT_LineComment)) {
   if (Current->Previous->BlockKind == BK_BracedInit &&
   Current->Previous->opensScope())
-Current->SpacesRequiredBefore = Style.Cpp11BracedListStyle ? 0 : 1;
+Current->SpacesRequiredBefore =
+(Style.Cpp11BracedListStyle && !Style.SpacesInParentheses) ? 0 : 1;
   else
 Current->SpacesRequiredBefore = Style.SpacesBeforeTrailingComments;
 
@@ -2628,7 +2629,7 @@
   if ((Left.is(tok::l_brace) && Left.BlockKind != BK_Block) ||
   (Right.is(tok::r_brace) && Right.MatchingParen &&
Right.MatchingParen->BlockKind != BK_Block))
-return !Style.Cpp11BracedListStyle;
+return Style.Cpp11BracedListStyle ? Style.SpacesInParentheses : true;
   if (Left.is(TT_BlockComment))
 // No whitespace in x(/*foo=*/1), except for JavaScript.
 return Style.Language == FormatStyle::LK_JavaScript ||


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8210,6 +8210,34 @@
   SpaceBeforeBrace.SpaceBeforeCpp11BracedList = true;
   verifyFormat("vector x {1, 2, 3, 4};", SpaceBeforeBrace);
   verifyFormat("f({}, {{}, {}}, MyMap[{k, v}]);", SpaceBeforeBrace);
+
+  FormatStyle SpaceBetweenBraces = getLLVMStyle();
+  SpaceBetweenBraces.SpacesInAngles = true;
+  SpaceBetweenBraces.SpacesInParentheses = true;
+  SpaceBetweenBraces.SpacesInSquareBrackets = true;
+  verifyFormat("vector< int > x{ 1, 2, 3, 4 };", SpaceBetweenBraces);
+  verifyFormat("f( {}, { {}, {} }, MyMap[ { k, v } ] );", SpaceBetweenBraces);
+  verifyFormat("vector< int > x{ // comment 1\n"
+   " 1, 2, 3, 4 };",
+   SpaceBetweenBraces);
+  SpaceBetweenBraces.ColumnLimit = 20;
+  EXPECT_EQ("vector< int > x{\n"
+"1, 2, 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  SpaceBetweenBraces.ColumnLimit = 24;
+  EXPECT_EQ("vector< int > x{ 1, 2,\n"
+" 3, 4 };",
+format("vectorx{1,2,3,4};", SpaceBetweenBraces));
+  EXPECT_EQ("vector< int > x{\n"
+"1,\n"
+"2,\n"
+"3,\n"
+"4,\n"
+"};",
+format("vectorx{1,2,3,4,};", SpaceBetweenBraces));
+  verifyFormat("vector< int > x{};", SpaceBetweenBraces);
+  SpaceBetweenBraces.SpaceInEmptyParentheses = true;
+  verifyFormat("vector< int > x{ };", SpaceBetweenBraces);
 }
 
 TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
Index: clang/lib/Format/TokenAnnotator.cpp
==

[PATCH] D68346: [clang-format] Add new option to add spaces around conditions

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar requested changes to this revision.
mitchell-stellar added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2290
 
+**SpacesAroundConditions** (``bool``)
+  If ``true``, spaces will be inserted around if/for/while (and similar) 
conditions.

`SpacesInConditionalStatement` is probably a better name, remaining consistent 
with existing `SpacesIn*` options, as well as indicating it only affects the 
entire conditional statement, and not individual conditions within the 
statement.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2511
+  return t->isOneOf(tok::kw_if, tok::pp_elif, tok::kw_for, tok::kw_while,
+tok::kw_switch, tok::kw_constexpr, TT_ForEachMacro);
+};

It seems that you are mixing statement tokens `if`, `while`, etc. with 
preprocessor and macro tokens. Going by the documentation, this is unexpected.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2919
+  if (Right.is(tok::coloncolon) &&
+  !Left.isOneOf(tok::l_brace, tok::comment, tok::l_paren))
 return (Left.is(TT_TemplateOpener) &&

MyDeveloperDay wrote:
> I'm not sure I understand this change so you added a `tok::l_paren` here? but 
> its not just for your style, so something else must have changed. Did you run 
> all FormatTests?
> 
> one of the tests you add need to test why you added this here
This is not covered by your tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68346



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


[PATCH] D68415: [clang-format] C++11 braced lists should respect the SpacesInParentheses setting

2019-10-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

what if you have this

  vector{1, 2, 3};
  new int[3]{1, 2, 3};
  foo(int f);

but want this:

  vector{ 1, 2, 3 };
  new int[3]{ 1, 2, 3 };
  foo(int f);

wouldn't turning on  `SpacesInParentheses: true` now mean you get

  vector{ 1, 2, 3 };
  new int[3]{ 1, 2, 3 };
  foo( int f );

so there is no way of still having `foo(int f);` without a space before the int 
and after the f?

Sorry did I miss something? Generally, I agree that the change is good for the 
braced case I just don't want to break everyones functions


Repository:
  rC Clang

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

https://reviews.llvm.org/D68415



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


[PATCH] D68415: [clang-format] C++11 braced lists should respect the SpacesInParentheses setting

2019-10-03 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar added a comment.

If you want spaces in your C++11 initializers and nothing else, then you don't 
want the `Cpp11BracedListStyle` setting enabled. Turning it off gives you 
spaces inside without affecting anything else.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68415



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


  1   2   >