r345237 - [CodeGen] Always emit the 'min-legal-vector-width' attribute even when the value is 0.

2018-10-24 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Oct 24 22:04:35 2018
New Revision: 345237

URL: http://llvm.org/viewvc/llvm-project?rev=345237=rev
Log:
[CodeGen] Always emit the 'min-legal-vector-width' attribute even when the 
value is 0.

The X86 backend will need to see the attribute to make decisions. If it isn't 
present the backend will have to assume large vectors may be present.

Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/test/CodeGen/aarch64-neon-ldst-one.c
cfe/trunk/test/CodeGen/aarch64-poly64.c

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=345237=345236=345237=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Oct 24 22:04:35 2018
@@ -448,9 +448,7 @@ void CodeGenFunction::FinishFunction(Sou
   // 4. Width of vector arguments and return types for this function.
   // 5. Width of vector aguments and return types for functions called by this
   //function.
-  if (LargestVectorWidth != 0)
-CurFn->addFnAttr("min-legal-vector-width",
- llvm::utostr(LargestVectorWidth));
+  CurFn->addFnAttr("min-legal-vector-width", llvm::utostr(LargestVectorWidth));
 }
 
 /// ShouldInstrumentFunction - Return true if the current function should be

Modified: cfe/trunk/test/CodeGen/aarch64-neon-ldst-one.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-ldst-one.c?rev=345237=345236=345237=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-ldst-one.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-ldst-one.c Wed Oct 24 22:04:35 2018
@@ -6800,4 +6800,4 @@ void test_vst4_lane_p64(poly64_t  *a, po
 
 // CHECK: attributes #0 ={{.*}}"min-legal-vector-width"="128"
 // CHECK: attributes #1 ={{.*}}"min-legal-vector-width"="64"
-// CHECK-NOT: attributes #2 ={{.*}}"min-legal-vector-width"
+// CHECK: attributes #2 ={{.*}}"min-legal-vector-width"="0"

Modified: cfe/trunk/test/CodeGen/aarch64-poly64.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-poly64.c?rev=345237=345236=345237=diff
==
--- cfe/trunk/test/CodeGen/aarch64-poly64.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-poly64.c Wed Oct 24 22:04:35 2018
@@ -614,4 +614,4 @@ poly64x2_t test_vsriq_n_p64(poly64x2_t a
 
 // CHECK: attributes #0 ={{.*}}"min-legal-vector-width"="64"
 // CHECK: attributes #1 ={{.*}}"min-legal-vector-width"="128"
-// CHECK-NOT: attributes #2 ={{.*}}"min-legal-vector-width"
+// CHECK: attributes #2 ={{.*}}"min-legal-vector-width"="0"


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


[PATCH] D53076: [analyzer] Enhance ConditionBRVisitor to write out more information

2018-10-24 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added inline comments.



Comment at: 
include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h:202
+  void finalizeConstraints() {
+Constraints.clear();
+  }

george.karpenkov wrote:
> These constraints are conceptually part of the visitor, not part of the 
> constraint manager. Could they be simply stored in the visitor?
My idea was to have a generic constraint map as @NoQ mentioned, then we could 
attach this to other places to reduce noisy reports. But probably this is the 
best place for now.



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:244
+if (I == Constraints.end() || !Message.equals(I->second)) {
+  Constraints[Cond] = Message;
+  return true;

george.karpenkov wrote:
> Isn't that equivalent to `Constraints.insert(make_pair(Cond, 
> Message)).second` ?
> I think I have written that before.
We have multiple messages at the same place so we have to update the message. 
The problem with your code is `insert` operates with disjunct keys, not values.


https://reviews.llvm.org/D53076



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


[clang-tools-extra] r345235 - [clangd] Clean up LSP structs around configuration. NFC, no protocol changes.

2018-10-24 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Oct 24 21:22:52 2018
New Revision: 345235

URL: http://llvm.org/viewvc/llvm-project?rev=345235=rev
Log:
[clangd] Clean up LSP structs around configuration. NFC, no protocol changes.

 - align struct names/comments with LSP, remove redundant "clangd" prefixes.
 - don't map config structs as Optional<> when their presence/absence
   doesn't signal anything and all fields must have sensible "absent" values
 - be more lax around parsing of 'any'-typed messages

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=345235=345234=345235=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Oct 24 21:22:52 2018
@@ -303,15 +303,14 @@ void ClangdLSPServer::onInitialize(const
   if (Server)
 return Reply(make_error("server already initialized",
   ErrorCode::InvalidRequest));
-  if (Params.initializationOptions)
-CompileCommandsDir = Params.initializationOptions->compilationDatabasePath;
+  if (const auto  = Params.initializationOptions.compilationDatabasePath)
+CompileCommandsDir = Dir;
   CDB.emplace(UseInMemoryCDB
   ? CompilationDB::makeInMemory()
   : CompilationDB::makeDirectoryBased(CompileCommandsDir));
   Server.emplace(CDB->getCDB(), FSProvider,
  static_cast(*this), ClangdServerOpts);
-  if (Params.initializationOptions)
-applyConfiguration(Params.initializationOptions->ParamsChange);
+  applyConfiguration(Params.initializationOptions.ConfigSettings);
 
   CCOpts.EnableSnippets = Params.capabilities.CompletionSnippets;
   DiagOpts.EmbedFixesInDiagnostics = Params.capabilities.DiagnosticFixes;
@@ -654,25 +653,22 @@ void ClangdLSPServer::onHover(const Text
 }
 
 void ClangdLSPServer::applyConfiguration(
-const ClangdConfigurationParamsChange ) {
+const ConfigurationSettings ) {
   // Per-file update to the compilation database.
-  if (Params.compilationDatabaseChanges) {
-const auto  = *Params.compilationDatabaseChanges;
-bool ShouldReparseOpenFiles = false;
-for (auto  : CompileCommandUpdates) {
-  /// The opened files need to be reparsed only when some existing
-  /// entries are changed.
-  PathRef File = Entry.first;
-  if (!CDB->setCompilationCommandForFile(
-  File, tooling::CompileCommand(
-std::move(Entry.second.workingDirectory), File,
-std::move(Entry.second.compilationCommand),
-/*Output=*/"")))
-ShouldReparseOpenFiles = true;
-}
-if (ShouldReparseOpenFiles)
-  reparseOpenedFiles();
+  bool ShouldReparseOpenFiles = false;
+  for (auto  : Settings.compilationDatabaseChanges) {
+/// The opened files need to be reparsed only when some existing
+/// entries are changed.
+PathRef File = Entry.first;
+if (!CDB->setCompilationCommandForFile(
+File, tooling::CompileCommand(
+  std::move(Entry.second.workingDirectory), File,
+  std::move(Entry.second.compilationCommand),
+  /*Output=*/"")))
+  ShouldReparseOpenFiles = true;
   }
+  if (ShouldReparseOpenFiles)
+reparseOpenedFiles();
 }
 
 // FIXME: This function needs to be properly tested.

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=345235=345234=345235=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Wed Oct 24 21:22:52 2018
@@ -93,7 +93,7 @@ private:
   /// may be very expensive.  This method is normally called when the
   /// compilation database is changed.
   void reparseOpenedFiles();
-  void applyConfiguration(const ClangdConfigurationParamsChange );
+  void applyConfiguration(const ConfigurationSettings );
 
   /// Used to indicate that the 'shutdown' request was received from the
   /// Language Server client.

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=345235=345234=345235=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Wed Oct 24 21:22:52 2018
@@ -663,20 +663,22 @@ bool fromJSON(const json::Value ,
  

[PATCH] D53688: [clangd] Add fallbackFlags initialization extension.

2018-10-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ioeric.

This allows customizing the flags used when no compile database is
available. It addresses some uses of the old extraFlags extension.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53688

Files:
  clangd/ClangdLSPServer.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h


Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -367,6 +367,10 @@
   ClangdConfigurationParamsChange ParamsChange;
 
   llvm::Optional compilationDatabasePath;
+  // Additional flags to be included in the "fallback command" used when
+  // the compilation database doesn't describe an opened file.
+  // The command used will be approximately `clang $FILE $fallbackFlags`.
+  std::vector fallbackFlags;
 };
 bool fromJSON(const llvm::json::Value &, ClangdInitializationOptions &);
 
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -667,7 +667,10 @@
   }
 
   json::ObjectMapper O(Params);
-  return O && O.map("compilationDatabasePath", Opts.compilationDatabasePath);
+  if (!O && !O.map("compilationDatabasePath", Opts.compilationDatabasePath))
+return false;
+  O.map("fallbackFlags", Opts.fallbackFlags);
+  return true;
 }
 
 bool fromJSON(const json::Value , ReferenceParams ) {
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -303,12 +303,15 @@
   if (Server)
 return Reply(make_error("server already initialized",
   ErrorCode::InvalidRequest));
-  if (Params.initializationOptions)
+  std::vector FallbackFlags;
+  if (Params.initializationOptions) {
 CompileCommandsDir = Params.initializationOptions->compilationDatabasePath;
+FallbackFlags = Params.initializationOptions->fallbackFlags;
+  }
   if (UseDirBasedCDB)
 BaseCDB = llvm::make_unique(
 CompileCommandsDir);
-  CDB.emplace(BaseCDB.get());
+  CDB.emplace(BaseCDB.get(), std::move(FallbackFlags));
   Server.emplace(*CDB, FSProvider, static_cast(*this),
  ClangdServerOpts);
   if (Params.initializationOptions)


Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -367,6 +367,10 @@
   ClangdConfigurationParamsChange ParamsChange;
 
   llvm::Optional compilationDatabasePath;
+  // Additional flags to be included in the "fallback command" used when
+  // the compilation database doesn't describe an opened file.
+  // The command used will be approximately `clang $FILE $fallbackFlags`.
+  std::vector fallbackFlags;
 };
 bool fromJSON(const llvm::json::Value &, ClangdInitializationOptions &);
 
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -667,7 +667,10 @@
   }
 
   json::ObjectMapper O(Params);
-  return O && O.map("compilationDatabasePath", Opts.compilationDatabasePath);
+  if (!O && !O.map("compilationDatabasePath", Opts.compilationDatabasePath))
+return false;
+  O.map("fallbackFlags", Opts.fallbackFlags);
+  return true;
 }
 
 bool fromJSON(const json::Value , ReferenceParams ) {
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -303,12 +303,15 @@
   if (Server)
 return Reply(make_error("server already initialized",
   ErrorCode::InvalidRequest));
-  if (Params.initializationOptions)
+  std::vector FallbackFlags;
+  if (Params.initializationOptions) {
 CompileCommandsDir = Params.initializationOptions->compilationDatabasePath;
+FallbackFlags = Params.initializationOptions->fallbackFlags;
+  }
   if (UseDirBasedCDB)
 BaseCDB = llvm::make_unique(
 CompileCommandsDir);
-  CDB.emplace(BaseCDB.get());
+  CDB.emplace(BaseCDB.get(), std::move(FallbackFlags));
   Server.emplace(*CDB, FSProvider, static_cast(*this),
  ClangdServerOpts);
   if (Params.initializationOptions)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53687: [clangd] Make in-memory CDB always available as an overlay, refactor.

2018-10-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ioeric.

The new implementation is a GlobalCompilationDatabase that overlays a base.
Normally this is the directory-based CDB.
To preserve the behavior of compile_args_from=LSP, the base may be null.

The OverlayCDB is always present, and so the extensions to populate it
are always supported.

It also allows overriding the flags of the fallback command. This is
just unit-tested for now, but the plan is to expose this as an extension
on the initialize message. This addresses use cases like
https://github.com/thomasjo/atom-ide-cpp/issues/16


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53687

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  unittests/clangd/GlobalCompilationDatabaseTests.cpp

Index: unittests/clangd/GlobalCompilationDatabaseTests.cpp
===
--- unittests/clangd/GlobalCompilationDatabaseTests.cpp
+++ unittests/clangd/GlobalCompilationDatabaseTests.cpp
@@ -33,6 +33,61 @@
testPath("foo/bar.h")));
 }
 
+static tooling::CompileCommand cmd(StringRef File, StringRef Arg) {
+  return tooling::CompileCommand(testRoot(), File, {"clang", Arg, File}, "");
+}
+
+class OverlayCDBTest : public ::testing::Test {
+  class BaseCDB : public GlobalCompilationDatabase {
+  public:
+Optional
+getCompileCommand(StringRef File) const override {
+  if (File == testPath("foo.cc"))
+return cmd(File, "-DA=1");
+  return None;
+}
+
+tooling::CompileCommand getFallbackCommand(StringRef File) const override {
+  return cmd(File, "-DA=2");
+}
+  };
+
+protected:
+  OverlayCDBTest() : Base(llvm::make_unique()) {}
+  std::unique_ptr Base;
+};
+
+TEST_F(OverlayCDBTest, GetCompileCommand) {
+  OverlayCDB CDB(Base.get());
+  EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")),
+Base->getCompileCommand(testPath("foo.cc")));
+  EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
+
+  auto Override = cmd(testPath("foo.cc"), "-DA=3");
+  CDB.setCompileCommand(testPath("foo.cc"), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
+  CDB.setCompileCommand(testPath("missing.cc"), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), Override);
+}
+
+TEST_F(OverlayCDBTest, GetFallbackCommand) {
+  OverlayCDB CDB(Base.get(), {"-DA=4"});
+  EXPECT_THAT(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine,
+  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4"));
+}
+
+TEST_F(OverlayCDBTest, NoBase) {
+  OverlayCDB CDB(nullptr, {"-DA=6"});
+  EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), None);
+  auto Override = cmd(testPath("bar.cc"), "-DA=5");
+  CDB.setCompileCommand(testPath("bar.cc"), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), Override);
+
+  EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine,
+  ElementsAre("clang", testPath("foo.cc"), "-DA=6"));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -74,23 +74,30 @@
   llvm::Optional CompileCommandsDir;
 };
 
-/// Gets compile args from an in-memory mapping based on a filepath. Typically
-/// used by clients who provide the compile commands themselves.
-class InMemoryCompilationDb : public GlobalCompilationDatabase {
+/// Wraps another compilation database, and supports overriding the commands
+/// using an in-memory mapping.
+class OverlayCDB : public GlobalCompilationDatabase {
 public:
-  /// Gets compile command for \p File from the stored mapping.
+  // Base may be null, in which case no entries are inherited.
+  // FallbackFlags are added to the fallback compile command.
+  OverlayCDB(const GlobalCompilationDatabase *Base,
+ std::vector FallbackFlags = {})
+  : Base(Base), FallbackFlags(std::move(FallbackFlags)) {}
+
   llvm::Optional
   getCompileCommand(PathRef File) const override;
+  tooling::CompileCommand getFallbackCommand(PathRef File) const override;
 
-  /// Sets the compilation command for a particular file.
-  ///
-  /// \returns True if the File had no compilation command before.
-  bool setCompilationCommandForFile(PathRef File,
-tooling::CompileCommand CompilationCommand);
+  /// Sets or clears the compilation command for a particular file.
+  void
+  setCompileCommand(PathRef File,
+llvm::Optional CompilationCommand);
 
 private:
   mutable std::mutex Mutex;
   

[PATCH] D53685: [WebAssembly] Bitselect and min/max builtins

2018-10-24 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: include/clang/Basic/BuiltinsWebAssembly.def:85
 
+BUILTIN(__builtin_wasm_bitselect, "V4iV4iV4iV4i", "nc")
+

aheejin wrote:
> Do you think we need to provide this builtin also for other vector types?
This builtin is interesting because there is basically no reason for the mask 
to be the same type as the vectors. So we could have 36 versions of this, one 
for each pair of vector types. Or if we required the mask to be a vector of 
integers we could cut that down to just 24 versions. But no matter what types 
you use, this builtin does the exact same thing to the bits. So in the end it 
seems simpler to have just one version and have users convert between vector 
types. Without the `-fno-lax-vector-conversions` flag, clang will silently 
convert between vector types for you anyway, so there's no real ergonomic loss 
either (not that ergonomics really matter for builtins).


Repository:
  rC Clang

https://reviews.llvm.org/D53685



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


[PATCH] D53685: [WebAssembly] Bitselect and min/max builtins

2018-10-24 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



Comment at: include/clang/Basic/BuiltinsWebAssembly.def:85
 
+BUILTIN(__builtin_wasm_bitselect, "V4iV4iV4iV4i", "nc")
+

Do you think we need to provide this builtin also for other vector types?


Repository:
  rC Clang

https://reviews.llvm.org/D53685



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


[clang-tools-extra] r345233 - [clangd] Remove unused CDB function. NFC

2018-10-24 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Oct 24 19:25:44 2018
New Revision: 345233

URL: http://llvm.org/viewvc/llvm-project?rev=345233=rev
Log:
[clangd] Remove unused CDB function. NFC

Modified:
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=345233=345232=345233=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Wed Oct 24 
19:25:44 2018
@@ -59,12 +59,6 @@ DirectoryBasedGlobalCompilationDatabase:
   return C;
 }
 
-void DirectoryBasedGlobalCompilationDatabase::setCompileCommandsDir(Path P) {
-  std::lock_guard Lock(Mutex);
-  CompileCommandsDir = P;
-  CompilationDatabases.clear();
-}
-
 void DirectoryBasedGlobalCompilationDatabase::setExtraFlagsForFile(
 PathRef File, std::vector ExtraFlags) {
   std::lock_guard Lock(Mutex);

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h?rev=345233=345232=345233=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h Wed Oct 24 
19:25:44 2018
@@ -62,9 +62,6 @@ public:
   /// Uses the default fallback command, adding any extra flags.
   tooling::CompileCommand getFallbackCommand(PathRef File) const override;
 
-  /// Set the compile commands directory to \p P.
-  void setCompileCommandsDir(Path P);
-
   /// Sets the extra flags that should be added to a file.
   void setExtraFlagsForFile(PathRef File, std::vector ExtraFlags);
 


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


[clang-tools-extra] r345232 - [clangd] Fix -compile-commands-dir flag, broken in r345031

2018-10-24 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Oct 24 19:22:53 2018
New Revision: 345232

URL: http://llvm.org/viewvc/llvm-project?rev=345232=rev
Log:
[clangd] Fix -compile-commands-dir flag, broken in r345031

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=345232=345231=345232=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Oct 24 19:22:53 2018
@@ -303,7 +303,6 @@ void ClangdLSPServer::onInitialize(const
   if (Server)
 return Reply(make_error("server already initialized",
   ErrorCode::InvalidRequest));
-  Optional CompileCommandsDir;
   if (Params.initializationOptions)
 CompileCommandsDir = Params.initializationOptions->compilationDatabasePath;
   CDB.emplace(UseInMemoryCDB
@@ -696,7 +695,9 @@ ClangdLSPServer::ClangdLSPServer(class T
 : Transp(Transp), MsgHandler(new MessageHandler(*this)), CCOpts(CCOpts),
   SupportedSymbolKinds(defaultSymbolKinds()),
   SupportedCompletionItemKinds(defaultCompletionItemKinds()),
-  UseInMemoryCDB(ShouldUseInMemoryCDB), ClangdServerOpts(Opts) {
+  UseInMemoryCDB(ShouldUseInMemoryCDB),
+  CompileCommandsDir(std::move(CompileCommandsDir)),
+  ClangdServerOpts(Opts) {
   // clang-format off
   MsgHandler->bind("initialize", ::onInitialize);
   MsgHandler->bind("shutdown", ::onShutdown);

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=345232=345231=345232=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Wed Oct 24 19:22:53 2018
@@ -169,6 +169,7 @@ private:
 
   // The CDB is created by the "initialize" LSP method.
   bool UseInMemoryCDB; // FIXME: make this a capability.
+  llvm::Optional CompileCommandsDir; // FIXME: merge with capability?
   llvm::Optional CDB;
   // The ClangdServer is created by the "initialize" LSP method.
   // It is destroyed before run() returns, to ensure worker threads exit.


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


[PATCH] D53642: [clangd] Don't invalidate LSP-set compile commands when closing a file.

2018-10-24 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE345231: [clangd] Dont invalidate LSP-set compile 
commands when closing a file. (authored by sammccall, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53642?vs=170861=171033#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53642

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h


Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -135,10 +135,5 @@
   return false;
 }
 
-void InMemoryCompilationDb::invalidate(PathRef File) {
-  std::unique_lock Lock(Mutex);
-  Commands.erase(File);
-}
-
 } // namespace clangd
 } // namespace clang
Index: clangd/ClangdLSPServer.h
===
--- clangd/ClangdLSPServer.h
+++ clangd/ClangdLSPServer.h
@@ -113,8 +113,6 @@
 static CompilationDB
 makeDirectoryBased(llvm::Optional CompileCommandsDir);
 
-void invalidate(PathRef File);
-
 /// Sets the compilation command for a particular file.
 /// Only valid for in-memory CDB, no-op and error log on DirectoryBasedCDB.
 ///
Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -100,10 +100,6 @@
   bool setCompilationCommandForFile(PathRef File,
 tooling::CompileCommand 
CompilationCommand);
 
-  /// Removes the compilation command for \p File if it's present in the
-  /// mapping.
-  void invalidate(PathRef File);
-
 private:
   mutable std::mutex Mutex;
   llvm::StringMap Commands; /* GUARDED_BY(Mut) */
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -393,7 +393,6 @@
 // fail rather than giving wrong results.
 DraftMgr.removeDraft(File);
 Server->removeDocument(File);
-CDB->invalidate(File);
 elog("Failed to update {0}: {1}", File, Contents.takeError());
 return;
   }
@@ -489,7 +488,6 @@
   PathRef File = Params.textDocument.uri.file();
   DraftMgr.removeDraft(File);
   Server->removeDocument(File);
-  CDB->invalidate(File);
 }
 
 void ClangdLSPServer::onDocumentOnTypeFormatting(
@@ -804,11 +802,6 @@
/*IsDirectoryBased=*/true);
 }
 
-void ClangdLSPServer::CompilationDB::invalidate(PathRef File) {
-  if (!IsDirectoryBased)
-static_cast(CDB.get())->invalidate(File);
-}
-
 bool ClangdLSPServer::CompilationDB::setCompilationCommandForFile(
 PathRef File, tooling::CompileCommand CompilationCommand) {
   if (IsDirectoryBased) {


Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -135,10 +135,5 @@
   return false;
 }
 
-void InMemoryCompilationDb::invalidate(PathRef File) {
-  std::unique_lock Lock(Mutex);
-  Commands.erase(File);
-}
-
 } // namespace clangd
 } // namespace clang
Index: clangd/ClangdLSPServer.h
===
--- clangd/ClangdLSPServer.h
+++ clangd/ClangdLSPServer.h
@@ -113,8 +113,6 @@
 static CompilationDB
 makeDirectoryBased(llvm::Optional CompileCommandsDir);
 
-void invalidate(PathRef File);
-
 /// Sets the compilation command for a particular file.
 /// Only valid for in-memory CDB, no-op and error log on DirectoryBasedCDB.
 ///
Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -100,10 +100,6 @@
   bool setCompilationCommandForFile(PathRef File,
 tooling::CompileCommand CompilationCommand);
 
-  /// Removes the compilation command for \p File if it's present in the
-  /// mapping.
-  void invalidate(PathRef File);
-
 private:
   mutable std::mutex Mutex;
   llvm::StringMap Commands; /* GUARDED_BY(Mut) */
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -393,7 +393,6 @@
 // fail rather than giving wrong results.
 DraftMgr.removeDraft(File);
 Server->removeDocument(File);
-CDB->invalidate(File);
 elog("Failed to update {0}: {1}", File, Contents.takeError());
 return;
   }
@@ -489,7 +488,6 @@
   PathRef File = Params.textDocument.uri.file();
   DraftMgr.removeDraft(File);
   Server->removeDocument(File);
-  CDB->invalidate(File);
 }
 
 void ClangdLSPServer::onDocumentOnTypeFormatting(
@@ -804,11 

[clang-tools-extra] r345231 - [clangd] Don't invalidate LSP-set compile commands when closing a file.

2018-10-24 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed Oct 24 19:04:30 2018
New Revision: 345231

URL: http://llvm.org/viewvc/llvm-project?rev=345231=rev
Log:
[clangd] Don't invalidate LSP-set compile commands when closing a file.

Summary:
It doesn't make much sense: setting them is not coupled to opening the file,
it's an asynchronous notification.

I don't think this is a breaking change - this behavior is hard to observe!

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=345231=345230=345231=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Oct 24 19:04:30 2018
@@ -393,7 +393,6 @@ void ClangdLSPServer::onDocumentDidChang
 // fail rather than giving wrong results.
 DraftMgr.removeDraft(File);
 Server->removeDocument(File);
-CDB->invalidate(File);
 elog("Failed to update {0}: {1}", File, Contents.takeError());
 return;
   }
@@ -489,7 +488,6 @@ void ClangdLSPServer::onDocumentDidClose
   PathRef File = Params.textDocument.uri.file();
   DraftMgr.removeDraft(File);
   Server->removeDocument(File);
-  CDB->invalidate(File);
 }
 
 void ClangdLSPServer::onDocumentOnTypeFormatting(
@@ -804,11 +802,6 @@ ClangdLSPServer::CompilationDB::makeDire
/*IsDirectoryBased=*/true);
 }
 
-void ClangdLSPServer::CompilationDB::invalidate(PathRef File) {
-  if (!IsDirectoryBased)
-static_cast(CDB.get())->invalidate(File);
-}
-
 bool ClangdLSPServer::CompilationDB::setCompilationCommandForFile(
 PathRef File, tooling::CompileCommand CompilationCommand) {
   if (IsDirectoryBased) {

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=345231=345230=345231=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Wed Oct 24 19:04:30 2018
@@ -113,8 +113,6 @@ private:
 static CompilationDB
 makeDirectoryBased(llvm::Optional CompileCommandsDir);
 
-void invalidate(PathRef File);
-
 /// Sets the compilation command for a particular file.
 /// Only valid for in-memory CDB, no-op and error log on DirectoryBasedCDB.
 ///

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=345231=345230=345231=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Wed Oct 24 
19:04:30 2018
@@ -135,10 +135,5 @@ bool InMemoryCompilationDb::setCompilati
   return false;
 }
 
-void InMemoryCompilationDb::invalidate(PathRef File) {
-  std::unique_lock Lock(Mutex);
-  Commands.erase(File);
-}
-
 } // namespace clangd
 } // namespace clang

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h?rev=345231=345230=345231=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h Wed Oct 24 
19:04:30 2018
@@ -100,10 +100,6 @@ public:
   bool setCompilationCommandForFile(PathRef File,
 tooling::CompileCommand 
CompilationCommand);
 
-  /// Removes the compilation command for \p File if it's present in the
-  /// mapping.
-  void invalidate(PathRef File);
-
 private:
   mutable std::mutex Mutex;
   llvm::StringMap Commands; /* GUARDED_BY(Mut) */


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


[PATCH] D53685: [WebAssembly] Bitselect and min/max intrinsics

2018-10-24 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added reviewers: aheejin, dschuff.
Herald added subscribers: cfe-commits, sunfish, jgravelle-google, sbc100.

Repository:
  rC Clang

https://reviews.llvm.org/D53685

Files:
  include/clang/Basic/BuiltinsWebAssembly.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtins-wasm.c

Index: test/CodeGen/builtins-wasm.c
===
--- test/CodeGen/builtins-wasm.c
+++ test/CodeGen/builtins-wasm.c
@@ -131,6 +131,31 @@
   // WEBASSEMBLY-NEXT: ret
 }
 
+float min_f32(float x, float y) {
+  return __builtin_wasm_min_f32(x, y);
+  // WEBASSEMBLY: call float @llvm.minimum.f32(float %x, float %y)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+float max_f32(float x, float y) {
+  return __builtin_wasm_max_f32(x, y);
+  // WEBASSEMBLY: call float @llvm.maximum.f32(float %x, float %y)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+double min_f64(double x, double y) {
+  return __builtin_wasm_min_f64(x, y);
+  // WEBASSEMBLY: call double @llvm.minimum.f64(double %x, double %y)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+double max_f64(double x, double y) {
+  return __builtin_wasm_max_f64(x, y);
+  // WEBASSEMBLY: call double @llvm.maximum.f64(double %x, double %y)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+
 int extract_lane_s_i8x16(i8x16 v) {
   return __builtin_wasm_extract_lane_s_i8x16(v, 13);
   // WEBASSEMBLY: extractelement <16 x i8> %v, i32 13
@@ -277,6 +302,13 @@
   // WEBASSEMBLY-NEXT: ret
 }
 
+i32x4 bitselect(i32x4 x, i32x4 y, i32x4 c) {
+  return __builtin_wasm_bitselect(x, y, c);
+  // WEBASSEMBLY: call <4 x i32> @llvm.wasm.bitselect.v4i32(
+  // WEBASSEMBLY-SAME: <4 x i32> %x, <4 x i32> %y, <4 x i32> %c)
+  // WEBASSEMBLY-NEXT: ret
+}
+
 int any_true_i8x16(i8x16 x) {
   return __builtin_wasm_any_true_i8x16(x);
   // WEBASSEMBLY: call i32 @llvm.wasm.anytrue.v16i8(<16 x i8> %x)
@@ -337,6 +369,34 @@
   // WEBASSEMBLY: ret
 }
 
+f32x4 min_f32x4(f32x4 x, f32x4 y) {
+  return __builtin_wasm_min_f32x4(x, y);
+  // WEBASSEMBLY: call <4 x float> @llvm.minimum.v4f32(
+  // WEBASSEMBLY-SAME: <4 x float> %x, <4 x float> %y)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+f32x4 max_f32x4(f32x4 x, f32x4 y) {
+  return __builtin_wasm_max_f32x4(x, y);
+  // WEBASSEMBLY: call <4 x float> @llvm.maximum.v4f32(
+  // WEBASSEMBLY-SAME: <4 x float> %x, <4 x float> %y)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+f64x2 min_f64x2(f64x2 x, f64x2 y) {
+  return __builtin_wasm_min_f64x2(x, y);
+  // WEBASSEMBLY: call <2 x double> @llvm.minimum.v2f64(
+  // WEBASSEMBLY-SAME: <2 x double> %x, <2 x double> %y)
+  // WEBASSEMBLY-NEXT: ret
+}
+
+f64x2 max_f64x2(f64x2 x, f64x2 y) {
+  return __builtin_wasm_max_f64x2(x, y);
+  // WEBASSEMBLY: call <2 x double> @llvm.maximum.v2f64(
+  // WEBASSEMBLY-SAME: <2 x double> %x, <2 x double> %y)
+  // WEBASSEMBLY-NEXT: ret
+}
+
 f32x4 sqrt_f32x4(f32x4 x) {
   return __builtin_wasm_sqrt_f32x4(x);
   // WEBASSEMBLY: call <4 x float> @llvm.sqrt.v4f32(<4 x float> %x)
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -12544,6 +12544,26 @@
  {ResT, Src->getType()});
 return Builder.CreateCall(Callee, {Src});
   }
+  case WebAssembly::BI__builtin_wasm_min_f32:
+  case WebAssembly::BI__builtin_wasm_min_f64:
+  case WebAssembly::BI__builtin_wasm_min_f32x4:
+  case WebAssembly::BI__builtin_wasm_min_f64x2: {
+Value *LHS = EmitScalarExpr(E->getArg(0));
+Value *RHS = EmitScalarExpr(E->getArg(1));
+Value *Callee = CGM.getIntrinsic(Intrinsic::minimum,
+ ConvertType(E->getType()));
+return Builder.CreateCall(Callee, {LHS, RHS});
+  }
+  case WebAssembly::BI__builtin_wasm_max_f32:
+  case WebAssembly::BI__builtin_wasm_max_f64:
+  case WebAssembly::BI__builtin_wasm_max_f32x4:
+  case WebAssembly::BI__builtin_wasm_max_f64x2: {
+Value *LHS = EmitScalarExpr(E->getArg(0));
+Value *RHS = EmitScalarExpr(E->getArg(1));
+Value *Callee = CGM.getIntrinsic(Intrinsic::maximum,
+ ConvertType(E->getType()));
+return Builder.CreateCall(Callee, {LHS, RHS});
+  }
   case WebAssembly::BI__builtin_wasm_extract_lane_s_i8x16:
   case WebAssembly::BI__builtin_wasm_extract_lane_u_i8x16:
   case WebAssembly::BI__builtin_wasm_extract_lane_s_i16x8:
@@ -12636,6 +12656,14 @@
 Value *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {LHS, RHS});
   }
+  case WebAssembly::BI__builtin_wasm_bitselect: {
+Value *V1 = EmitScalarExpr(E->getArg(0));
+Value *V2 = EmitScalarExpr(E->getArg(1));
+Value *C = EmitScalarExpr(E->getArg(2));
+Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_bitselect,
+ ConvertType(E->getType()));
+return Builder.CreateCall(Callee, {V1, V2, C});
+  }
   case WebAssembly::BI__builtin_wasm_any_true_i8x16:
   case 

[clang-tools-extra] r345229 - Fix test to work on Windows.

2018-10-24 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Wed Oct 24 18:21:08 2018
New Revision: 345229

URL: http://llvm.org/viewvc/llvm-project?rev=345229=rev
Log:
Fix test to work on Windows.

Modified:
clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp?rev=345229=345228=345229=diff
==
--- clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp Wed Oct 24 
18:21:08 2018
@@ -199,7 +199,13 @@ main.cpp:2:3: error: something terrible
   // Transform dianostics and check the results.
   std::vector>> 
LSPDiags;
   toLSPDiags(
-  D, URIForFile("/path/to/foo/bar/main.cpp"), ClangdDiagnosticOptions(),
+  D,
+#ifdef _WIN32
+  URIForFile("c:\\path\\to\\foo\\bar\\main.cpp"),
+#else
+  URIForFile("/path/to/foo/bar/main.cpp"),
+#endif
+  ClangdDiagnosticOptions(),
   [&](clangd::Diagnostic LSPDiag, ArrayRef Fixes) {
 LSPDiags.push_back(
 {std::move(LSPDiag),


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


[PATCH] D53609: [AST] Don't store data for GNU range case statement if not needed.

2018-10-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/AST/Stmt.h:956
+  //   with a range. Present if and only if caseStmtIsGNURange() is true.
+  enum { LHS, SUBSTMT, RHS, ELLIPSISLOC };
+  enum { NumMandatoryStmtPtr = 2 };

ELLIPSISLOC is dead.

Much like the other patch, I'm not sure it's okay to reorder the children here. 
 Using a dynamic offset for extracting the sub-statement is probably fine.  If 
you're worried about that cost, `StmtIterator` is already pretty complicated, 
and it's not frequently-used by the compiler; I think it would be fine to find 
ways to get it to visit the elements of an array out of order.


Repository:
  rC Clang

https://reviews.llvm.org/D53609



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


r345228 - [Sema] Fix -Wcomma for C89

2018-10-24 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Oct 24 18:08:00 2018
New Revision: 345228

URL: http://llvm.org/viewvc/llvm-project?rev=345228=rev
Log:
[Sema] Fix -Wcomma for C89

There is a small difference in the scope flags for C89 versus the other C/C++
dialects.  This change ensures that the -Wcomma warning won't be duplicated or
issued in the wrong location.  Also, the test case is refactored into C and C++
parts, with the C++ parts guarded by a #ifdef to allow the test to run in both
modes.

https://bugs.llvm.org/show_bug.cgi?id=32370

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/SemaCXX/warn-comma-operator.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=345228=345227=345228=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Oct 24 18:08:00 2018
@@ -11309,8 +11309,11 @@ void Sema::DiagnoseCommaOperator(const E
   // The whitelisted locations are the initialization and increment portions
   // of a for loop.  The additional checks are on the condition of
   // if statements, do/while loops, and for loops.
+  // Differences in scope flags for C89 mode requires the extra logic.
   const unsigned ForIncrementFlags =
-  Scope::ControlScope | Scope::ContinueScope | Scope::BreakScope;
+  getLangOpts().C99 || getLangOpts().CPlusPlus
+  ? Scope::ControlScope | Scope::ContinueScope | Scope::BreakScope
+  : Scope::ContinueScope | Scope::BreakScope;
   const unsigned ForInitFlags = Scope::ControlScope | Scope::DeclScope;
   const unsigned ScopeFlags = getCurScope()->getFlags();
   if ((ScopeFlags & ForIncrementFlags) == ForIncrementFlags ||

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=345228=345227=345228=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Oct 24 18:08:00 2018
@@ -551,8 +551,9 @@ Sema::ActOnIfStmt(SourceLocation IfLoc,
 false);
 
   Expr *CondExpr = Cond.get().second;
-  if (!Diags.isIgnored(diag::warn_comma_operator,
-   CondExpr->getExprLoc()))
+  // Only call the CommaVisitor when not C89 due to differences in scope flags.
+  if ((getLangOpts().C99 || getLangOpts().CPlusPlus) &&
+  !Diags.isIgnored(diag::warn_comma_operator, CondExpr->getExprLoc()))
 CommaVisitor(*this).Visit(CondExpr);
 
   if (!elseStmt)
@@ -1328,6 +1329,11 @@ Sema::ActOnDoStmt(SourceLocation DoLoc,
 return StmtError();
   Cond = CondResult.get();
 
+  // Only call the CommaVisitor for C89 due to differences in scope flags.
+  if (Cond && !getLangOpts().C99 && !getLangOpts().CPlusPlus &&
+  !Diags.isIgnored(diag::warn_comma_operator, Cond->getExprLoc()))
+CommaVisitor(*this).Visit(Cond);
+
   DiagnoseUnusedExprResult(Body);
 
   return new (Context) DoStmt(Body, Cond, DoLoc, WhileLoc, CondRParen);

Modified: cfe/trunk/test/SemaCXX/warn-comma-operator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-comma-operator.cpp?rev=345228=345227=345228=diff
==
--- cfe/trunk/test/SemaCXX/warn-comma-operator.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-comma-operator.cpp Wed Oct 24 18:08:00 2018
@@ -1,8 +1,16 @@
 // RUN: %clang_cc1 -fsyntax-only -Wcomma -std=c++11 -verify %s
 // RUN: %clang_cc1 -fsyntax-only -Wcomma -std=c++11 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
+// RUN: %clang_cc1 -fsyntax-only -Wcomma -x c -std=c89 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wcomma -x c -std=c99 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wcomma -x c -std=c11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wcomma -x c -std=c17 -verify %s
+
+// int returning function
+int return_four() { return 5; }
+
 // Test builtin operators
-void test1() {
+void test_builtin() {
   int x = 0, y = 0;
   for (; y < 10; x++, y++) {}
   for (; y < 10; ++x, y++) {}
@@ -23,6 +31,116 @@ void test1() {
   for (; y < 10; x ^= 5, ++y) {}
 }
 
+// Test nested comma operators
+void test_nested() {
+  int x1, x2, x3;
+  int y1, *y2 = 0, y3 = 5;
+
+#if __STDC_VERSION >= 199901L
+  for (int z1 = 5, z2 = 4, z3 = 3; x1 <4; ++x1) {}
+#endif
+}
+
+// Confusing "," for "=="
+void test_compare() {
+  if (return_four(), 5) {}
+  // expected-warning@-1{{comma operator}}
+  // expected-note@-2{{cast expression to void}}
+  // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:7-[[@LINE-3]]:7}:"static_cast("
+  // CHECK: fix-it:{{.*}}:{[[@LINE-4]]:20-[[@LINE-4]]:20}:")"
+
+  if (return_four() == 5) {}
+}
+
+// Confusing "," for "+"
+int test_plus() {
+  return return_four(), return_four();
+  // expected-warning@-1{{comma operator}}
+  // expected-note@-2{{cast expression to void}}
+  // 

[PATCH] D53684: [COFF, ARM64] Change setjmp for AArch64 Windows to use Intrinsic.sponentry

2018-10-24 Thread Yin Ma via Phabricator via cfe-commits
yinma created this revision.
Herald added subscribers: cfe-commits, chrib, kristof.beyls, javed.absar.

ARM64 setjmp expects sp on entry instead of framepointer.


Repository:
  rC Clang

https://reviews.llvm.org/D53684

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/ms-setjmp.c


Index: test/CodeGen/ms-setjmp.c
===
--- test/CodeGen/ms-setjmp.c
+++ test/CodeGen/ms-setjmp.c
@@ -25,7 +25,7 @@
   // X64-NEXT:  ret i32 %[[call]]
 
   // AARCH64-LABEL: define dso_local i32 @test_setjmp
-  // AARCH64:   %[[addr:.*]] = call i8* @llvm.frameaddress(i32 0)
+  // AARCH64:   %[[addr:.*]] = call i8* @llvm.sponentry()
   // AARCH64:   %[[call:.*]] = call i32 @_setjmpex(i8* getelementptr 
inbounds ([1 x i8], [1 x i8]* @jb, i32 0, i32 0), i8* %[[addr]])
   // AARCH64-NEXT:  ret i32 %[[call]]
 }
@@ -38,7 +38,8 @@
   // X64-NEXT:  ret i32 %[[call]]
 
   // AARCH64-LABEL: define dso_local i32 @test_setjmpex
-  // AARCH64:   %[[addr:.*]] = call i8* @llvm.frameaddress(i32 0)
+  // AARCH64:   %[[addr:.*]] = call i8* @llvm.sponentry()
   // AARCH64:   %[[call:.*]] = call i32 @_setjmpex(i8* getelementptr 
inbounds ([1 x i8], [1 x i8]* @jb, i32 0, i32 0), i8* %[[addr]])
   // AARCH64-NEXT:  ret i32 %[[call]]
+  // AARCH64:  "no-frame-pointer-elim"="true"
 }
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -711,8 +711,12 @@
   } else {
 Name = SJKind == MSVCSetJmpKind::_setjmp ? "_setjmp" : "_setjmpex";
 Arg1Ty = CGF.Int8PtrTy;
-Arg1 = 
CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::frameaddress),
-  llvm::ConstantInt::get(CGF.Int32Ty, 0));
+if (CGF.getTarget().getTriple().getArch() == llvm::Triple::aarch64) {
+  Arg1 = 
CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::sponentry));
+  CGF.CurFn->addFnAttr("no-frame-pointer-elim", "true");
+} else
+  Arg1 = 
CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::frameaddress),
+llvm::ConstantInt::get(CGF.Int32Ty, 0));
   }
 
   // Mark the call site and declaration with ReturnsTwice.


Index: test/CodeGen/ms-setjmp.c
===
--- test/CodeGen/ms-setjmp.c
+++ test/CodeGen/ms-setjmp.c
@@ -25,7 +25,7 @@
   // X64-NEXT:  ret i32 %[[call]]
 
   // AARCH64-LABEL: define dso_local i32 @test_setjmp
-  // AARCH64:   %[[addr:.*]] = call i8* @llvm.frameaddress(i32 0)
+  // AARCH64:   %[[addr:.*]] = call i8* @llvm.sponentry()
   // AARCH64:   %[[call:.*]] = call i32 @_setjmpex(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @jb, i32 0, i32 0), i8* %[[addr]])
   // AARCH64-NEXT:  ret i32 %[[call]]
 }
@@ -38,7 +38,8 @@
   // X64-NEXT:  ret i32 %[[call]]
 
   // AARCH64-LABEL: define dso_local i32 @test_setjmpex
-  // AARCH64:   %[[addr:.*]] = call i8* @llvm.frameaddress(i32 0)
+  // AARCH64:   %[[addr:.*]] = call i8* @llvm.sponentry()
   // AARCH64:   %[[call:.*]] = call i32 @_setjmpex(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @jb, i32 0, i32 0), i8* %[[addr]])
   // AARCH64-NEXT:  ret i32 %[[call]]
+  // AARCH64:  "no-frame-pointer-elim"="true"
 }
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -711,8 +711,12 @@
   } else {
 Name = SJKind == MSVCSetJmpKind::_setjmp ? "_setjmp" : "_setjmpex";
 Arg1Ty = CGF.Int8PtrTy;
-Arg1 = CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::frameaddress),
-  llvm::ConstantInt::get(CGF.Int32Ty, 0));
+if (CGF.getTarget().getTriple().getArch() == llvm::Triple::aarch64) {
+  Arg1 = CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::sponentry));
+  CGF.CurFn->addFnAttr("no-frame-pointer-elim", "true");
+} else
+  Arg1 = CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::frameaddress),
+llvm::ConstantInt::get(CGF.Int32Ty, 0));
   }
 
   // Mark the call site and declaration with ReturnsTwice.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53674: [CodeGen] Fix assertion on referencing constexpr Obj-C object with ARC.

2018-10-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGObjC.cpp:2480
+ SuppressResultRetain);
   }
 

This switch is just checking what you already computed as 
`SuppressResultRetain`.  Please just assert in the second case that the 
qualifier is `OCL_Weak`.

Also, please stay consistent with the surrounding capitalization of local 
variables.



Comment at: clang/lib/CodeGen/CGObjC.cpp:2527
+  return TryEmitResult(CGF.EmitScalarExpr(e),
+   !shouldRetainObjCLifetime(type.getObjCLifetime()));
+  }

Can we test constant-evaluability directly instead of only applying this when 
the declaration isn't otherwise used?


https://reviews.llvm.org/D53674



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


[PATCH] D53607: [AST] Only store the needed data in IfStmt.

2018-10-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Yeah, I agree that changing child order is problematic.


Repository:
  rC Clang

https://reviews.llvm.org/D53607



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


[PATCH] D53610: [AST] Check that GNU range case statements are correctly imported.

2018-10-24 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D53610



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


[PATCH] D53605: [AST] Pack PredefinedExpr

2018-10-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/AST/Expr.h:1687
+  // "Stmt *" for the predefined identifier. It is present if and only if
+  // hasFunctionName() is true and is in fact a "StringLiteral *".
+

"always" would be clearer than "in fact".



Comment at: include/clang/AST/Stmt.h:279
+/// in PredefinedExpr::IdentType.
+unsigned Type : 4;
+

Since you're changing this around anyway, please make it a "kind" rather than a 
"type".  Even if it's just the field name for now, it's progress.



Comment at: include/clang/AST/Stmt.h:283
+/// for the predefined identifier.
+unsigned HasFnName : 1;
+

Not sure why this is abbreviated.



Comment at: lib/AST/Expr.cpp:470
+ "IdentType do not fit in PredefinedExprBitfields!");
+  bool HasFunctionName = !!SL;
+  PredefinedExprBits.HasFnName = HasFunctionName;

`!= nullptr` is clearer.


Repository:
  rC Clang

https://reviews.llvm.org/D53605



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


[PATCH] D53604: [AST] Widen the bit-fields of Stmt to 8 bytes

2018-10-24 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D53604



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


[PATCH] D52578: Thread safety analysis: Allow scoped releasing of capabilities

2018-10-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 171026.
aaronpuchert added a comment.

Negative capabilities don't need a LockKind.


Repository:
  rC Clang

https://reviews.llvm.org/D52578

Files:
  lib/Analysis/ThreadSafety.cpp
  test/SemaCXX/warn-thread-safety-analysis.cpp

Index: test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- test/SemaCXX/warn-thread-safety-analysis.cpp
+++ test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -2787,6 +2787,110 @@
 } // end namespace RelockableScopedLock
 
 
+namespace ScopedUnlock {
+
+class SCOPED_LOCKABLE MutexUnlock {
+public:
+  MutexUnlock(Mutex *mu) EXCLUSIVE_UNLOCK_FUNCTION(mu);
+  ~MutexUnlock() EXCLUSIVE_UNLOCK_FUNCTION();
+
+  void Lock() EXCLUSIVE_UNLOCK_FUNCTION();
+  void Unlock() EXCLUSIVE_LOCK_FUNCTION();
+};
+
+class SCOPED_LOCKABLE ReaderMutexUnlock {
+public:
+  ReaderMutexUnlock(Mutex *mu) SHARED_UNLOCK_FUNCTION(mu);
+  ~ReaderMutexUnlock() EXCLUSIVE_UNLOCK_FUNCTION();
+
+  void Lock() EXCLUSIVE_UNLOCK_FUNCTION();
+  void Unlock() EXCLUSIVE_LOCK_FUNCTION();
+};
+
+Mutex mu;
+int x GUARDED_BY(mu);
+bool c;
+void print(int);
+
+void simple() EXCLUSIVE_LOCKS_REQUIRED(mu) {
+  x = 1;
+  MutexUnlock scope();
+  x = 2; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+}
+
+void simpleShared() SHARED_LOCKS_REQUIRED(mu) {
+  print(x);
+  ReaderMutexUnlock scope();
+  print(x); // expected-warning {{reading variable 'x' requires holding mutex 'mu'}}
+}
+
+void innerUnlock() {
+  MutexLock outer();
+  if (x == 0) {
+MutexUnlock inner();
+x = 1; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+  }
+  x = 2;
+}
+
+void innerUnlockShared() {
+  ReaderMutexLock outer();
+  if (x == 0) {
+ReaderMutexUnlock inner();
+print(x); // expected-warning {{reading variable 'x' requires holding mutex 'mu'}}
+  }
+  print(x);
+}
+
+void manual() EXCLUSIVE_LOCKS_REQUIRED(mu) {
+  MutexUnlock scope();
+  scope.Lock();
+  x = 2;
+  scope.Unlock();
+  x = 3; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+}
+
+void join() EXCLUSIVE_LOCKS_REQUIRED(mu) {
+  MutexUnlock scope();
+  if (c) {
+scope.Lock(); // expected-note{{mutex acquired here}}
+  }
+  // expected-warning@+1{{mutex 'mu' is not held on every path through here}}
+  scope.Lock();
+}
+
+void doubleLock() EXCLUSIVE_LOCKS_REQUIRED(mu) {
+  MutexUnlock scope();
+  scope.Lock();
+  scope.Lock(); // expected-warning {{acquiring mutex 'mu' that is already held}}
+}
+
+void doubleUnlock() EXCLUSIVE_LOCKS_REQUIRED(mu) {
+  MutexUnlock scope();
+  scope.Unlock(); // expected-warning {{releasing mutex 'mu' that was not held}}
+}
+
+class SCOPED_LOCKABLE MutexLockUnlock {
+public:
+  MutexLockUnlock(Mutex *mu1, Mutex *mu2) EXCLUSIVE_UNLOCK_FUNCTION(mu1) EXCLUSIVE_LOCK_FUNCTION(mu2);
+  ~MutexLockUnlock() EXCLUSIVE_UNLOCK_FUNCTION();
+
+  void Release() EXCLUSIVE_UNLOCK_FUNCTION();
+  void Acquire() EXCLUSIVE_LOCK_FUNCTION();
+};
+
+Mutex other;
+void fn() EXCLUSIVE_LOCKS_REQUIRED(other);
+
+void lockUnlock() EXCLUSIVE_LOCKS_REQUIRED(mu) {
+  MutexLockUnlock scope(, );
+  fn();
+  x = 1; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+}
+
+} // end namespace ScopedUnlock
+
+
 namespace TrylockFunctionTest {
 
 class Foo {
Index: lib/Analysis/ThreadSafety.cpp
===
--- lib/Analysis/ThreadSafety.cpp
+++ lib/Analysis/ThreadSafety.cpp
@@ -42,6 +42,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/ImmutableMap.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -890,80 +891,112 @@
 
 class ScopedLockableFactEntry : public FactEntry {
 private:
-  SmallVector UnderlyingMutexes;
+  enum UnderlyingCapabilityKind {
+UCK_Acquired,  ///< Any kind of acquired capability.
+UCK_ReleasedShared,///< Shared capability that was released.
+UCK_ReleasedExclusive, ///< Exclusive capability that was released.
+  };
+
+  using UnderlyingCapability =
+  llvm::PointerIntPair;
+
+  SmallVector UnderlyingMutexes;
 
 public:
   ScopedLockableFactEntry(const CapabilityExpr , SourceLocation Loc,
-  const CapExprSet , const CapExprSet )
+  const CapExprSet , const CapExprSet ,
+  const CapExprSet , const CapExprSet )
   : FactEntry(CE, LK_Exclusive, Loc, false) {
 for (const auto  : Excl)
-  UnderlyingMutexes.push_back(M.sexpr());
+  UnderlyingMutexes.emplace_back(M.sexpr(), UCK_Acquired);
 for (const auto  : Shrd)
-  UnderlyingMutexes.push_back(M.sexpr());
+  UnderlyingMutexes.emplace_back(M.sexpr(), UCK_Acquired);
+for (const auto  : ExclRel)
+  UnderlyingMutexes.emplace_back(M.sexpr(), UCK_ReleasedExclusive);

r345225 - Revert "[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03"

2018-10-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Oct 24 16:47:04 2018
New Revision: 345225

URL: http://llvm.org/viewvc/llvm-project?rev=345225=rev
Log:
Revert "[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03"

This reverts commit 6f47cdd51341344c0e32630e19e72c94cd25f34e.

Removed:
cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=345225=345224=345225=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Oct 24 16:47:04 2018
@@ -1515,9 +1515,8 @@ namespace {
   if (FD->getNumParams() == NumBaseParams + 2)
 HasAlignValT = HasSizeT = true;
   else if (FD->getNumParams() == NumBaseParams + 1) {
-QualType ParamTy = FD->getParamDecl(NumBaseParams)->getType();
-HasAlignValT = ParamTy->isAlignValT();
-HasSizeT = !HasAlignValT && ParamTy->isIntegerType();
+HasSizeT = FD->getParamDecl(NumBaseParams)->getType()->isIntegerType();
+HasAlignValT = !HasSizeT;
   }
 
   // In CUDA, determine how much we'd like / dislike to call this.

Removed: cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp?rev=345224=auto
==
--- cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp (removed)
@@ -1,21 +0,0 @@
-// RUN: %clang_cc1 -std=c++03 %s -faligned-allocation \
-// RUN:   -emit-llvm -o - | FileCheck %s
-
-// Ensure Clang doesn't confuse std::align_val_t with the sized deallocation
-// parameter when the enum type is unscoped. Libc++ does this in C++03 in order
-// to support aligned allocation in that dialect.
-
-using size_t = __decltype(sizeof(0));
-
-namespace std {
-enum align_val_t { zero = size_t(0),
-   max = size_t(-1) };
-}
-
-// CHECK-LABEL: define void @_Z1fPi(
-void f(int *p) {
-  // CHECK-NOT: call void @_ZdlPvSt11align_val_t(
-  // CHECK: call void @_ZdlPv(
-  // CHECK: ret void
-  delete p;
-}


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


[PATCH] D53586: Implement Function Multiversioning for Non-ELF Systems.

2018-10-24 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/CodeGen/CodeGenFunction.cpp:2395
+
+  llvm::CallInst *Result = Builder.CreateCall(FuncToReturn, Args);
+

rnk wrote:
> erichkeane wrote:
> > erichkeane wrote:
> > > rnk wrote:
> > > > This approach is... not going to work in the general case. Consider, 
> > > > for example, varargs. Then consider 32-bit x86 inalloca, which is quite 
> > > > widespread. Any non-trivially copyable object is not going to be 
> > > > passable through such a thunk. You might consider looking at 
> > > > CodeGenFunction::EmitMustTailThunk instead.
> > > Oh dear... 
> > > I'm unfamiliar with EmitMustTailThunk, is it self explanatory?  Any 
> > > chance you can expound?  Should I call/use that function, or copy out of 
> > > it?
> > I looked through that function, and it seems to do very similar things to 
> > this...
> > 
> > It FIRST does the small-vector conversion to a value* array like I do.
> > 
> > Second, it 'adjusts' the 'this' parameter.  This doesn't seem like it needs 
> > to happen, because the type isn't changing, right?  my 'this' pointer is 
> > still pass-on-able.
> > 
> > Third, it creates the call, then marks it TCK_MustTail.
> > 
> > Forth, it sets the attributes/calling convention of the 'call' object, but 
> > I'd expect that to come from the llvm::Function object in the 'CreateCall', 
> > right?  I can add them after the fact I guess, if we see value.*(see below)
> > 
> > Finally, it does the CreateRetVoid/CreateRet like this function does below. 
> > 
> > *I DO have a test that claims that my IR is broken if I set the call 
> > attributes.  Curiously only 1 of my tests, but the error is:
> > "cannot guarantee tail call due to mismatched ABI impacting function 
> > attributes"
> > 
> > The only difference in attributes is target-features and target-cpu though, 
> > so I don't know what causes this.
> Right, the this-adjustment is definitely unnecessary for this kind of CPU 
> dispatch thunk.
> 
> The important thing is that marking the call as `musttail` ensures that you 
> get perfect forwarding of all arguments, even varargs and inalloca. Maybe 
> it's enough to just mark the call you are creating that way. I think the code 
> you are generating obeys all the musttail invariants, so that might be best.
> 
> The "cannot guarantee tail call due to mismatched ABI impacting function 
> attributes" verifier check is only supposed to fire when parameter attributes 
> like `byval` and `inreg` differ between the call site and the dispatcher 
> function. It shouldn't care about target-cpu or target-features.
It's probably worth adding a test that uses inalloca, since that's why we're 
doing this nonsense. It would look like:
```
struct Foo {
  Foo();
  Foo(const Foo );
  ~Foo();
  int x;
};
int __attribute__((target("default"))) bar(Foo o) { return o.x; }
int __attribute__((target("sse4.2"))) bar(Foo o) { return o.x + 1; }
int __attribute__((target("arch=ivybridge"))) bar(Foo o) { return o.x + 2; }
```

Targetting i686-windows-msvc.


https://reviews.llvm.org/D53586



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


r345222 - Driver, CodeGen: introduce support for Swift CFString layout

2018-10-24 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Oct 24 16:28:28 2018
New Revision: 345222

URL: http://llvm.org/viewvc/llvm-project?rev=345222=rev
Log:
Driver,CodeGen: introduce support for Swift CFString layout

Add a new driver level flag `-fcf-runtime-abi=` that allows one to specify the
runtime ABI for CoreFoundation.  This controls the language interoperability.
In particular, this is relevant for generating the CFConstantString classes
(primarily through the `__builtin___CFStringMakeConstantString` builtin) which
construct a reference to the "CFObject"'s `isa` field.  This type differs
between swift 4.1 and 4.2+.

Valid values for the new option include:
  - objc [default behaviour] - enable ObjectiveC interoperability
  - swift-4.1 - enable interoperability with swift 4.1
  - swift-4.2 - enable interoperability with swift 4.2
  - swift-5.0 - enable interoperability with swift 5.0
  - swift [alias] - target the latest swift ABI

Furthermore, swift 4.2+ changed the layout for the CFString when building
CoreFoundation *without* ObjectiveC interoperability.  In such a case, a field
was added to the CFObject base type changing it from: <{ const int*, int }> to
<{ uintptr_t, uintptr_t, uint64_t }>.

In swift 5.0, the CFString type will be further adjusted to change the length
from a uint32_t on everything but BE LP64 targets to uint64_t.

Note that the default behaviour for clang remains unchanged and the new layout
must be explicitly opted into via `-fcf-runtime-abi=swift*`.

Added:
cfe/trunk/test/CodeGen/cf-runtime-abi.c
cfe/trunk/test/Driver/cf-runtime-abi.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=345222=345221=345222=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Oct 24 16:28:28 
2018
@@ -190,6 +190,9 @@ def err_drv_mg_requires_m_or_mm : Error<
   "option '-MG' requires '-M' or '-MM'">;
 def err_drv_unknown_objc_runtime : Error<
   "unknown or ill-formed Objective-C runtime '%0'">;
+def err_drv_invalid_cf_runtime_abi
+  : Error<"invalid CoreFoundation Runtime ABI '%0'; must be one of "
+  "'objc', 'standalone', 'swift', 'swift-5.0', 'swift-4.2', 
'swift-4.1'">;
 def err_drv_gnustep_objc_runtime_incompatible_binary : Error<
   "GNUstep Objective-C runtime version %0 incompatible with target binary 
format">;
 def err_drv_emit_llvm_link : Error<

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=345222=345221=345222=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Wed Oct 24 16:28:28 2018
@@ -129,6 +129,23 @@ public:
 Latest
   };
 
+  enum class CoreFoundationABI {
+/// No interoperability ABI has been specified
+Unspecified,
+/// CoreFoundation does not have any language interoperability
+Standalone,
+/// Interoperability with the ObjectiveC runtime
+ObjectiveC,
+/// Interoperability with the latest known version of the Swift runtime
+Swift,
+/// Interoperability with the Swift 5.0 runtime
+Swift5_0,
+/// Interoperability with the Swift 4.2 runtime
+Swift4_2,
+/// Interoperability with the Swift 4.1 runtime
+Swift4_1,
+  };
+
   enum FPContractModeKind {
 // Form fused FP ops only where result will not be affected.
 FPC_Off,
@@ -175,6 +192,8 @@ public:
 
   clang::ObjCRuntime ObjCRuntime;
 
+  CoreFoundationABI CFRuntime = CoreFoundationABI::Unspecified;
+
   std::string ObjCConstantStringClass;
 
   /// The name of the handler function to be called when -ftrapv is

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=345222=345221=345222=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Oct 24 16:28:28 2018
@@ -805,6 +805,8 @@ def fcomplete_member_pointers : Flag<["-
 def fno_complete_member_pointers : Flag<["-"], 
"fno-complete-member-pointers">, Group,
Flags<[CoreOption]>,
HelpText<"Do not require member pointer base types to be complete if they 
would be significant under the Microsoft ABI">;
+def fcf_runtime_abi_EQ : Joined<["-"], 

[PATCH] D52578: Thread safety analysis: Allow scoped releasing of capabilities

2018-10-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 171019.
aaronpuchert added a comment.

Introduced helper functions to clarify lock handling.

The previous version was too tightly coupled, and the introduction of AddCp and 
RemoveCp didn't help readability.


Repository:
  rC Clang

https://reviews.llvm.org/D52578

Files:
  lib/Analysis/ThreadSafety.cpp
  test/SemaCXX/warn-thread-safety-analysis.cpp

Index: test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- test/SemaCXX/warn-thread-safety-analysis.cpp
+++ test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -2787,6 +2787,110 @@
 } // end namespace RelockableScopedLock
 
 
+namespace ScopedUnlock {
+
+class SCOPED_LOCKABLE MutexUnlock {
+public:
+  MutexUnlock(Mutex *mu) EXCLUSIVE_UNLOCK_FUNCTION(mu);
+  ~MutexUnlock() EXCLUSIVE_UNLOCK_FUNCTION();
+
+  void Lock() EXCLUSIVE_UNLOCK_FUNCTION();
+  void Unlock() EXCLUSIVE_LOCK_FUNCTION();
+};
+
+class SCOPED_LOCKABLE ReaderMutexUnlock {
+public:
+  ReaderMutexUnlock(Mutex *mu) SHARED_UNLOCK_FUNCTION(mu);
+  ~ReaderMutexUnlock() EXCLUSIVE_UNLOCK_FUNCTION();
+
+  void Lock() EXCLUSIVE_UNLOCK_FUNCTION();
+  void Unlock() EXCLUSIVE_LOCK_FUNCTION();
+};
+
+Mutex mu;
+int x GUARDED_BY(mu);
+bool c;
+void print(int);
+
+void simple() EXCLUSIVE_LOCKS_REQUIRED(mu) {
+  x = 1;
+  MutexUnlock scope();
+  x = 2; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+}
+
+void simpleShared() SHARED_LOCKS_REQUIRED(mu) {
+  print(x);
+  ReaderMutexUnlock scope();
+  print(x); // expected-warning {{reading variable 'x' requires holding mutex 'mu'}}
+}
+
+void innerUnlock() {
+  MutexLock outer();
+  if (x == 0) {
+MutexUnlock inner();
+x = 1; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+  }
+  x = 2;
+}
+
+void innerUnlockShared() {
+  ReaderMutexLock outer();
+  if (x == 0) {
+ReaderMutexUnlock inner();
+print(x); // expected-warning {{reading variable 'x' requires holding mutex 'mu'}}
+  }
+  print(x);
+}
+
+void manual() EXCLUSIVE_LOCKS_REQUIRED(mu) {
+  MutexUnlock scope();
+  scope.Lock();
+  x = 2;
+  scope.Unlock();
+  x = 3; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+}
+
+void join() EXCLUSIVE_LOCKS_REQUIRED(mu) {
+  MutexUnlock scope();
+  if (c) {
+scope.Lock(); // expected-note{{mutex acquired here}}
+  }
+  // expected-warning@+1{{mutex 'mu' is not held on every path through here}}
+  scope.Lock();
+}
+
+void doubleLock() EXCLUSIVE_LOCKS_REQUIRED(mu) {
+  MutexUnlock scope();
+  scope.Lock();
+  scope.Lock(); // expected-warning {{acquiring mutex 'mu' that is already held}}
+}
+
+void doubleUnlock() EXCLUSIVE_LOCKS_REQUIRED(mu) {
+  MutexUnlock scope();
+  scope.Unlock(); // expected-warning {{releasing mutex 'mu' that was not held}}
+}
+
+class SCOPED_LOCKABLE MutexLockUnlock {
+public:
+  MutexLockUnlock(Mutex *mu1, Mutex *mu2) EXCLUSIVE_UNLOCK_FUNCTION(mu1) EXCLUSIVE_LOCK_FUNCTION(mu2);
+  ~MutexLockUnlock() EXCLUSIVE_UNLOCK_FUNCTION();
+
+  void Release() EXCLUSIVE_UNLOCK_FUNCTION();
+  void Acquire() EXCLUSIVE_LOCK_FUNCTION();
+};
+
+Mutex other;
+void fn() EXCLUSIVE_LOCKS_REQUIRED(other);
+
+void lockUnlock() EXCLUSIVE_LOCKS_REQUIRED(mu) {
+  MutexLockUnlock scope(, );
+  fn();
+  x = 1; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+}
+
+} // end namespace ScopedUnlock
+
+
 namespace TrylockFunctionTest {
 
 class Foo {
Index: lib/Analysis/ThreadSafety.cpp
===
--- lib/Analysis/ThreadSafety.cpp
+++ lib/Analysis/ThreadSafety.cpp
@@ -42,6 +42,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/ImmutableMap.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -890,80 +891,115 @@
 
 class ScopedLockableFactEntry : public FactEntry {
 private:
-  SmallVector UnderlyingMutexes;
+  enum UnderlyingCapabilityKind {
+UCK_Acquired,  ///< Any kind of acquired capability.
+UCK_ReleasedShared,///< Shared capability that was released.
+UCK_ReleasedExclusive, ///< Exclusive capability that was released.
+  };
+
+  using UnderlyingCapability =
+  llvm::PointerIntPair;
+
+  SmallVector UnderlyingMutexes;
 
 public:
   ScopedLockableFactEntry(const CapabilityExpr , SourceLocation Loc,
-  const CapExprSet , const CapExprSet )
+  const CapExprSet , const CapExprSet ,
+  const CapExprSet , const CapExprSet )
   : FactEntry(CE, LK_Exclusive, Loc, false) {
 for (const auto  : Excl)
-  UnderlyingMutexes.push_back(M.sexpr());
+  UnderlyingMutexes.emplace_back(M.sexpr(), UCK_Acquired);
 for (const auto  : Shrd)
-  UnderlyingMutexes.push_back(M.sexpr());
+  

[PATCH] D18860: [analyzer] Fix the "Zombie symbols" issue.

2018-10-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/simple-stream-checks.c:96
+  fp = 0;
+} // expected-warning {{Opened file is never closed; potential resource leak}}

george.karpenkov wrote:
> Woo-hoo, were we losing this case before?
Yes, this is the whole point of the patch.


https://reviews.llvm.org/D18860



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


[PATCH] D18860: [analyzer] Fix the "Zombie symbols" issue.

2018-10-24 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added inline comments.
This revision is now accepted and ready to land.



Comment at: test/Analysis/self-assign.cpp:42
   str = rhs.str;
-  rhs.str = nullptr; // FIXME: An improved leak checker should warn here
+  rhs.str = nullptr; // expected-warning{{Potential memory leak}} 
expected-note{{Potential memory leak}}
   return *this;

Woo-hoo!



Comment at: test/Analysis/simple-stream-checks.c:96
+  fp = 0;
+} // expected-warning {{Opened file is never closed; potential resource leak}}

Woo-hoo, were we losing this case before?


https://reviews.llvm.org/D18860



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


[PATCH] D18860: [analyzer] Fix the "Zombie symbols" issue.

2018-10-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Core/Environment.cpp:180
-  for (; SI != SE; ++SI)
-SymReaper.maybeDead(*SI);
 }

zaks.anna wrote:
> We are removing this because the maybeDead is no longer used, correct?
Yup.



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:390
-
-  } else {
-// Call checkers with the non-cleaned state so that they could query the

zaks.anna wrote:
> This removes an optimization to address the following issue: 
> "removeDeadBindings is not run right after the last reference to the object 
> is lost, which leads to imprecise error reports and failure to report the 
> leak in some cases. It's because of how hasDeadSymbols() is implemented. That 
> problem is solved if we disable the optimization, but I do not know how that 
> effects performance. Maybe we can come up with something more clever.
> "
> I suspect the removal of this optimization causes the performance regression. 
> In the patch I sent to the list, this was just a hack to demonstrate what 
> causes the issue. I am not sure we should not just remove the optimization... 
> The best proposal I have is to trigger remove dead bindings at the end of 
> every basic block. This would degrade diagnostics (you will see leaks only at 
> the end of the basic block), but should give us performance back or even 
> improve performance.
> 
> Artem and Devin, WDYT?
> 
> Artem, can you experiment with this and investigate if the diagnostics become 
> much worse? Maybe send a couple of examples? I suggest we implement this mode 
> behind a flag as a separate patch.
This cannot be kept around because `.hasDeadSymbols()` cannot be implemented 
correctly.



Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:2452
-SymReaper.maybeDead(*SI);
-}
   }

zaks.anna wrote:
> Looks like we are saying that we should no longer add to maybeDead because 
> it's not used.
Yup.


https://reviews.llvm.org/D18860



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


[PATCH] D18860: [analyzer] Fix the "Zombie symbols" issue.

2018-10-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 171006.
NoQ marked 2 inline comments as done.
NoQ added a comment.
Herald added subscribers: dkrupp, donat.nagy, Szelethus, mikhail.ramalho.

Rebase!

Changes on large codebase runs still look mild and reasonable, with much less 
slowdown than before. Even if there's in fact a 5-10% slowdown, i believe we 
can live with that, as there doesn't seem to be a better solution for the 
purposes of correctness.

The most important consequence of the rebase was the conflict that lead to test 
failure in `MacOSKeychainAPIChecker` on the `radar_19196494()` test. The story 
here is that https://reviews.llvm.org/D28330 unconsciously adds a suppression 
that relies on zombie symbols. I replaced this suppression with another ugly 
suppression that should be at least a tiny bit in the right direction.


https://reviews.llvm.org/D18860

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  lib/StaticAnalyzer/Core/Environment.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  lib/StaticAnalyzer/Core/SymbolManager.cpp
  test/Analysis/keychainAPI.m
  test/Analysis/pr22954.c
  test/Analysis/self-assign.cpp
  test/Analysis/simple-stream-checks.c
  test/Analysis/unions.cpp

Index: test/Analysis/unions.cpp
===
--- test/Analysis/unions.cpp
+++ test/Analysis/unions.cpp
@@ -90,9 +90,8 @@
 char str[] = "abc";
 vv.s = str;
 
-// FIXME: This is a leak of uu.s.
 uu = vv;
-  }
+  } // expected-warning{{leak}}
 
   void testIndirectInvalidation() {
 IntOrString uu;
Index: test/Analysis/simple-stream-checks.c
===
--- test/Analysis/simple-stream-checks.c
+++ test/Analysis/simple-stream-checks.c
@@ -89,3 +89,8 @@
   fs.p = fopen("myfile.txt", "w");
   fakeSystemHeaderCall(); // invalidates fs, making fs.p unreachable
 }  // no-warning
+
+void testOverwrite() {
+  FILE *fp = fopen("myfile.txt", "w");
+  fp = 0;
+} // expected-warning {{Opened file is never closed; potential resource leak}}
Index: test/Analysis/self-assign.cpp
===
--- test/Analysis/self-assign.cpp
+++ test/Analysis/self-assign.cpp
@@ -32,13 +32,14 @@
   clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}} expected-note{{TRUE}} expected-note{{UNKNOWN}}
   free(str); // expected-note{{Memory is released}}
   str = strdup(rhs.str); // expected-warning{{Use of memory after it is freed}}  expected-note{{Use of memory after it is freed}}
+// expected-note@-1{{Memory is allocated}}
   return *this;
 }
 
 StringUsed& StringUsed::operator=(StringUsed &) { // expected-note{{Assuming rhs == *this}} expected-note{{Assuming rhs != *this}}
   clang_analyzer_eval(*this == rhs); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}} expected-note{{TRUE}} expected-note{{UNKNOWN}}
   str = rhs.str;
-  rhs.str = nullptr; // FIXME: An improved leak checker should warn here
+  rhs.str = nullptr; // expected-warning{{Potential memory leak}} expected-note{{Potential memory leak}}
   return *this;
 }
 
@@ -83,7 +84,7 @@
 
 int main() {
   StringUsed s1 ("test"), s2;
-  s2 = s1;
-  s2 = std::move(s1);
+  s2 = s1; // expected-note{{Calling copy assignment operator for 'StringUsed'}} // expected-note{{Returned allocated memory}}
+  s2 = std::move(s1); // expected-note{{Calling move assignment operator for 'StringUsed'}}
   return 0;
 }
Index: test/Analysis/pr22954.c
===
--- test/Analysis/pr22954.c
+++ test/Analysis/pr22954.c
@@ -585,7 +585,7 @@
   m28[j].s3[k] = 1;
   struct ll * l28 = (struct ll*)([1]);
   l28->s1[l] = 2;
-  char input[] = {'a', 'b', 'c', 'd'};
+  char input[] = {'a', 'b', 'c', 'd'}; // expected-warning{{Potential leak of memory pointed to by field 's4'}}
   memcpy(l28->s1, input, 4);
   clang_analyzer_eval(m28[0].s3[0] == 1); // expected-warning{{UNKNOWN}}
   clang_analyzer_eval(m28[0].s3[1] == 1); // expected-warning{{UNKNOWN}}
Index: test/Analysis/keychainAPI.m
===
--- test/Analysis/keychainAPI.m
+++ test/Analysis/keychainAPI.m
@@ -212,7 +212,7 @@
 if (st == noErr)
   SecKeychainItemFreeContent(ptr, outData[3]);
   }
-  if (length) { // TODO: We do not 

Re: r345211 - [SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03

2018-10-24 Thread Richard Smith via cfe-commits
On Wed, 24 Oct 2018 at 15:40, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Wed Oct 24 15:38:49 2018
> New Revision: 345211
>
> URL: http://llvm.org/viewvc/llvm-project?rev=345211=rev
> Log:
> [SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03
>
> Summary:
> When -faligned-allocation is specified in C++03 libc++ defines
> std::align_val_t as an unscoped enumeration type (because Clang didn't
> provide scoped enumerations as an extension until 8.0).
> Unfortunately Clang confuses the `align_val_t` overloads of delete with
> the sized deallocation overloads which aren't enabled. This caused Clang to
> call the aligned deallocation function as if it were the sized deallocation
> overload.
>
> For example: https://godbolt.org/z/xXJELh
>
> This patch fixes the confusion.
>
> Reviewers: rsmith, EricWF
>
> Reviewed By: EricWF
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D53508
>
> Added:
> cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
> Modified:
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=345211=345210=345211=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Oct 24 15:38:49 2018
> @@ -1515,8 +1515,9 @@ namespace {
>if (FD->getNumParams() == NumBaseParams + 2)
>  HasAlignValT = HasSizeT = true;
>else if (FD->getNumParams() == NumBaseParams + 1) {
> -HasSizeT =
> FD->getParamDecl(NumBaseParams)->getType()->isIntegerType();
> -HasAlignValT = !HasSizeT;
> +QualType ParamTy = FD->getParamDecl(NumBaseParams)->getType();
> +HasAlignValT = ParamTy->isAlignValT();
> +HasSizeT = !HasAlignValT && ParamTy->isIntegerType();
>

The isIntegerType() check here is redundant, and should probably be an
assert. If we think we have a usual deallocation function but the parameter
is neither align_val_t nor an integral type, something has gone wrong.


>}
>
>// In CUDA, determine how much we'd like / dislike to call this.
>
> Added: cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp?rev=345211=auto
>
> ==
> --- cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
> (added)
> +++ cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp Wed
> Oct 24 15:38:49 2018
> @@ -0,0 +1,21 @@
> +// RUN: %clang_cc1 -std=c++03 %s -faligned-allocation \
> +// RUN:   -emit-llvm -o - | FileCheck %s
> +
> +// Ensure Clang doesn't confuse std::align_val_t with the sized
> deallocation
> +// parameter when the enum type is unscoped. Libc++ does this in C++03 in
> order
> +// to support aligned allocation in that dialect.
> +
> +using size_t = __decltype(sizeof(0));
> +
> +namespace std {
> +enum align_val_t { zero = size_t(0),
> +   max = size_t(-1) };
> +}
> +
> +// CHECK-LABEL: define void @_Z1fPi(
> +void f(int *p) {
> +  // CHECK-NOT: call void @_ZdlPvSt11align_val_t(
> +  // CHECK: call void @_ZdlPv(
> +  // CHECK: ret void
> +  delete p;
> +}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53228: [VFS] Remove 'ignore-non-existent-contents' attribute for YAML-based VFS.

2018-10-24 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the review.


Repository:
  rC Clang

https://reviews.llvm.org/D53228



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


[PATCH] D53228: [VFS] Remove 'ignore-non-existent-contents' attribute for YAML-based VFS.

2018-10-24 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC345212: [VFS] Remove 
ignore-non-existent-contents attribute for YAML-based VFS. 
(authored by vsapsai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53228?vs=169520=171010#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53228

Files:
  lib/Frontend/ModuleDependencyCollector.cpp
  test/Modules/crash-vfs-headermaps.m
  test/Modules/crash-vfs-include-pch.m
  test/Modules/crash-vfs-ivfsoverlay.m
  test/Modules/crash-vfs-relative-incdir.m
  test/Modules/crash-vfs-run-reproducer.m
  test/VFS/Inputs/MissingVFS/vfsoverlay.yaml
  test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
  test/VFS/Inputs/bar-headers.yaml
  test/VFS/Inputs/vfsoverlay2.yaml

Index: test/Modules/crash-vfs-include-pch.m
===
--- test/Modules/crash-vfs-include-pch.m
+++ test/Modules/crash-vfs-include-pch.m
@@ -33,7 +33,6 @@
 // CHECKYAML: 'case-sensitive':
 // CHECKYAML-NEXT: 'use-external-names': 'false',
 // CHECKYAML-NEXT: 'overlay-relative': 'true',
-// CHECKYAML-NEXT: 'ignore-non-existent-contents': 'false'
 // CHECKYAML: 'type': 'directory'
 // CHECKYAML: 'name': "/[[PATH:.*]]/out",
 // CHECKYAML-NEXT: 'contents': [
Index: test/Modules/crash-vfs-relative-incdir.m
===
--- test/Modules/crash-vfs-relative-incdir.m
+++ test/Modules/crash-vfs-relative-incdir.m
@@ -36,7 +36,6 @@
 // CHECKYAML: 'case-sensitive':
 // CHECKYAML-NEXT: 'use-external-names': 'false',
 // CHECKYAML-NEXT: 'overlay-relative': 'true',
-// CHECKYAML-NEXT: 'ignore-non-existent-contents': 'false'
 // CHECKYAML: 'type': 'directory'
 // CHECKYAML: 'name': "/[[PATH:.*]]/Inputs/crash-recovery/usr/include",
 // CHECKYAML-NEXT: 'contents': [
Index: test/Modules/crash-vfs-headermaps.m
===
--- test/Modules/crash-vfs-headermaps.m
+++ test/Modules/crash-vfs-headermaps.m
@@ -32,7 +32,6 @@
 // CHECKYAML: 'case-sensitive':
 // CHECKYAML-NEXT: 'use-external-names': 'false',
 // CHECKYAML-NEXT: 'overlay-relative': 'true',
-// CHECKYAML-NEXT: 'ignore-non-existent-contents': 'false'
 // CHECKYAML: 'type': 'directory'
 // CHECKYAML: 'name': "/[[PATH:.*]]/Foo.framework/Headers",
 // CHECKYAML-NEXT: 'contents': [
Index: test/Modules/crash-vfs-run-reproducer.m
===
--- test/Modules/crash-vfs-run-reproducer.m
+++ test/Modules/crash-vfs-run-reproducer.m
@@ -36,7 +36,6 @@
 // CHECKYAML: 'case-sensitive':
 // CHECKYAML-NEXT: 'use-external-names': 'false',
 // CHECKYAML-NEXT: 'overlay-relative': 'true',
-// CHECKYAML-NEXT: 'ignore-non-existent-contents': 'false'
 // CHECKYAML: 'type': 'directory'
 // CHECKYAML: 'name': "/[[PATH:.*]]/Inputs/crash-recovery/usr/include",
 // CHECKYAML-NEXT: 'contents': [
Index: test/Modules/crash-vfs-ivfsoverlay.m
===
--- test/Modules/crash-vfs-ivfsoverlay.m
+++ test/Modules/crash-vfs-ivfsoverlay.m
@@ -36,7 +36,6 @@
 // CHECKYAML: 'case-sensitive':
 // CHECKYAML-NEXT: 'use-external-names': 'false',
 // CHECKYAML-NEXT: 'overlay-relative': 'true',
-// CHECKYAML-NEXT: 'ignore-non-existent-contents': 'false'
 // CHECKYAML: 'type': 'directory'
 // CHECKYAML: 'name': "/[[PATH:.*]]/example"
 // CHECKYAML: 'contents': [
Index: test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
===
--- test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
+++ test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
@@ -1,7 +1,6 @@
 {
   'version': 0,
   'case-sensitive': 'false',
-  'ignore-non-existent-contents': 'true',
   'roots': [
 {
   'type': 'directory',
Index: test/VFS/Inputs/bar-headers.yaml
===
--- test/VFS/Inputs/bar-headers.yaml
+++ test/VFS/Inputs/bar-headers.yaml
@@ -1,7 +1,6 @@
 {
   'version': 0,
   'case-sensitive': 'false',
-  'ignore-non-existent-contents': 'true',
   'roots': [
 {
   'type': 'directory',
Index: test/VFS/Inputs/MissingVFS/vfsoverlay.yaml
===
--- test/VFS/Inputs/MissingVFS/vfsoverlay.yaml
+++ test/VFS/Inputs/MissingVFS/vfsoverlay.yaml
@@ -1,6 +1,5 @@
 {
   'version': 0,
-  'ignore-non-existent-contents': false,
   'roots': [
 { 'name': 'INPUT_DIR', 'type': 'directory',
   'contents': [
Index: test/VFS/Inputs/vfsoverlay2.yaml
===
--- test/VFS/Inputs/vfsoverlay2.yaml
+++ test/VFS/Inputs/vfsoverlay2.yaml
@@ -1,6 +1,5 @@
 {
   'version': 0,
-  'ignore-non-existent-contents': false,
   'roots': [
 { 'name': 'OUT_DIR', 'type': 'directory',
   'contents': [
Index: lib/Frontend/ModuleDependencyCollector.cpp

r345212 - [VFS] Remove 'ignore-non-existent-contents' attribute for YAML-based VFS.

2018-10-24 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Wed Oct 24 15:39:38 2018
New Revision: 345212

URL: http://llvm.org/viewvc/llvm-project?rev=345212=rev
Log:
[VFS] Remove 'ignore-non-existent-contents' attribute for YAML-based VFS.

'ignore-non-existent-contents' stopped working after r342232 in a way
that the actual attribute value isn't used and it works as if it is
always `true`.

Common use case for VFS iteration is iterating through files in umbrella
directories for modules. Ability to detect if some VFS entries point to
non-existing files is nice but non-critical. Instead of adding back
support for `'ignore-non-existent-contents': false` I am removing the
attribute, because such scenario isn't used widely enough and stricter
checks don't provide enough value to justify the maintenance.

rdar://problem/45176119

Reviewers: bruno

Reviewed By: bruno

Subscribers: hiraditya, dexonsmith, sammccall, cfe-commits

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

Modified:
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
cfe/trunk/test/Modules/crash-vfs-headermaps.m
cfe/trunk/test/Modules/crash-vfs-include-pch.m
cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m
cfe/trunk/test/Modules/crash-vfs-relative-incdir.m
cfe/trunk/test/Modules/crash-vfs-run-reproducer.m
cfe/trunk/test/VFS/Inputs/MissingVFS/vfsoverlay.yaml
cfe/trunk/test/VFS/Inputs/Nonmodular/nonmodular-headers.yaml
cfe/trunk/test/VFS/Inputs/bar-headers.yaml
cfe/trunk/test/VFS/Inputs/vfsoverlay2.yaml

Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=345212=345211=345212=diff
==
--- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original)
+++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Wed Oct 24 15:39:38 
2018
@@ -156,10 +156,6 @@ void ModuleDependencyCollector::writeFil
   // allows crash reproducer scripts to work across machines.
   VFSWriter.setOverlayDir(VFSDir);
 
-  // Do not ignore non existent contents otherwise we might skip something
-  // that should have been collected here.
-  VFSWriter.setIgnoreNonExistentContents(false);
-
   // Explicitly set case sensitivity for the YAML writer. For that, find out
   // the sensitivity at the path where the headers all collected to.
   VFSWriter.setCaseSensitivity(isCaseSensitivePath(VFSDir));

Modified: cfe/trunk/test/Modules/crash-vfs-headermaps.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-headermaps.m?rev=345212=345211=345212=diff
==
--- cfe/trunk/test/Modules/crash-vfs-headermaps.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-headermaps.m Wed Oct 24 15:39:38 2018
@@ -32,7 +32,6 @@
 // CHECKYAML: 'case-sensitive':
 // CHECKYAML-NEXT: 'use-external-names': 'false',
 // CHECKYAML-NEXT: 'overlay-relative': 'true',
-// CHECKYAML-NEXT: 'ignore-non-existent-contents': 'false'
 // CHECKYAML: 'type': 'directory'
 // CHECKYAML: 'name': "/[[PATH:.*]]/Foo.framework/Headers",
 // CHECKYAML-NEXT: 'contents': [

Modified: cfe/trunk/test/Modules/crash-vfs-include-pch.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-include-pch.m?rev=345212=345211=345212=diff
==
--- cfe/trunk/test/Modules/crash-vfs-include-pch.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-include-pch.m Wed Oct 24 15:39:38 2018
@@ -33,7 +33,6 @@ void g() { double x = DBL_MAX; }
 // CHECKYAML: 'case-sensitive':
 // CHECKYAML-NEXT: 'use-external-names': 'false',
 // CHECKYAML-NEXT: 'overlay-relative': 'true',
-// CHECKYAML-NEXT: 'ignore-non-existent-contents': 'false'
 // CHECKYAML: 'type': 'directory'
 // CHECKYAML: 'name': "/[[PATH:.*]]/out",
 // CHECKYAML-NEXT: 'contents': [

Modified: cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m?rev=345212=345211=345212=diff
==
--- cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m Wed Oct 24 15:39:38 2018
@@ -36,7 +36,6 @@
 // CHECKYAML: 'case-sensitive':
 // CHECKYAML-NEXT: 'use-external-names': 'false',
 // CHECKYAML-NEXT: 'overlay-relative': 'true',
-// CHECKYAML-NEXT: 'ignore-non-existent-contents': 'false'
 // CHECKYAML: 'type': 'directory'
 // CHECKYAML: 'name': "/[[PATH:.*]]/example"
 // CHECKYAML: 'contents': [

Modified: cfe/trunk/test/Modules/crash-vfs-relative-incdir.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-relative-incdir.m?rev=345212=345211=345212=diff
==
--- cfe/trunk/test/Modules/crash-vfs-relative-incdir.m (original)
+++ 

[PATCH] D53508: [SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03

2018-10-24 Thread Eric Fiselier via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC345211: [SemaCXX] Unconfuse Clang when std::align_val_t is 
unscoped in C++03 (authored by EricWF, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D53508

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp


Index: test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
===
--- test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
+++ test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++03 %s -faligned-allocation \
+// RUN:   -emit-llvm -o - | FileCheck %s
+
+// Ensure Clang doesn't confuse std::align_val_t with the sized deallocation
+// parameter when the enum type is unscoped. Libc++ does this in C++03 in order
+// to support aligned allocation in that dialect.
+
+using size_t = __decltype(sizeof(0));
+
+namespace std {
+enum align_val_t { zero = size_t(0),
+   max = size_t(-1) };
+}
+
+// CHECK-LABEL: define void @_Z1fPi(
+void f(int *p) {
+  // CHECK-NOT: call void @_ZdlPvSt11align_val_t(
+  // CHECK: call void @_ZdlPv(
+  // CHECK: ret void
+  delete p;
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -1515,8 +1515,9 @@
   if (FD->getNumParams() == NumBaseParams + 2)
 HasAlignValT = HasSizeT = true;
   else if (FD->getNumParams() == NumBaseParams + 1) {
-HasSizeT = FD->getParamDecl(NumBaseParams)->getType()->isIntegerType();
-HasAlignValT = !HasSizeT;
+QualType ParamTy = FD->getParamDecl(NumBaseParams)->getType();
+HasAlignValT = ParamTy->isAlignValT();
+HasSizeT = !HasAlignValT && ParamTy->isIntegerType();
   }
 
   // In CUDA, determine how much we'd like / dislike to call this.


Index: test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
===
--- test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
+++ test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++03 %s -faligned-allocation \
+// RUN:   -emit-llvm -o - | FileCheck %s
+
+// Ensure Clang doesn't confuse std::align_val_t with the sized deallocation
+// parameter when the enum type is unscoped. Libc++ does this in C++03 in order
+// to support aligned allocation in that dialect.
+
+using size_t = __decltype(sizeof(0));
+
+namespace std {
+enum align_val_t { zero = size_t(0),
+   max = size_t(-1) };
+}
+
+// CHECK-LABEL: define void @_Z1fPi(
+void f(int *p) {
+  // CHECK-NOT: call void @_ZdlPvSt11align_val_t(
+  // CHECK: call void @_ZdlPv(
+  // CHECK: ret void
+  delete p;
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -1515,8 +1515,9 @@
   if (FD->getNumParams() == NumBaseParams + 2)
 HasAlignValT = HasSizeT = true;
   else if (FD->getNumParams() == NumBaseParams + 1) {
-HasSizeT = FD->getParamDecl(NumBaseParams)->getType()->isIntegerType();
-HasAlignValT = !HasSizeT;
+QualType ParamTy = FD->getParamDecl(NumBaseParams)->getType();
+HasAlignValT = ParamTy->isAlignValT();
+HasSizeT = !HasAlignValT && ParamTy->isIntegerType();
   }
 
   // In CUDA, determine how much we'd like / dislike to call this.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r345211 - [SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03

2018-10-24 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Oct 24 15:38:49 2018
New Revision: 345211

URL: http://llvm.org/viewvc/llvm-project?rev=345211=rev
Log:
[SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03

Summary:
When -faligned-allocation is specified in C++03 libc++ defines std::align_val_t 
as an unscoped enumeration type (because Clang didn't provide scoped 
enumerations as an extension until 8.0).
Unfortunately Clang confuses the `align_val_t` overloads of delete with the 
sized deallocation overloads which aren't enabled. This caused Clang to call 
the aligned deallocation function as if it were the sized deallocation overload.

For example: https://godbolt.org/z/xXJELh

This patch fixes the confusion.

Reviewers: rsmith, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=345211=345210=345211=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Oct 24 15:38:49 2018
@@ -1515,8 +1515,9 @@ namespace {
   if (FD->getNumParams() == NumBaseParams + 2)
 HasAlignValT = HasSizeT = true;
   else if (FD->getNumParams() == NumBaseParams + 1) {
-HasSizeT = FD->getParamDecl(NumBaseParams)->getType()->isIntegerType();
-HasAlignValT = !HasSizeT;
+QualType ParamTy = FD->getParamDecl(NumBaseParams)->getType();
+HasAlignValT = ParamTy->isAlignValT();
+HasSizeT = !HasAlignValT && ParamTy->isIntegerType();
   }
 
   // In CUDA, determine how much we'd like / dislike to call this.

Added: cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp?rev=345211=auto
==
--- cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp (added)
+++ cfe/trunk/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp Wed Oct 
24 15:38:49 2018
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++03 %s -faligned-allocation \
+// RUN:   -emit-llvm -o - | FileCheck %s
+
+// Ensure Clang doesn't confuse std::align_val_t with the sized deallocation
+// parameter when the enum type is unscoped. Libc++ does this in C++03 in order
+// to support aligned allocation in that dialect.
+
+using size_t = __decltype(sizeof(0));
+
+namespace std {
+enum align_val_t { zero = size_t(0),
+   max = size_t(-1) };
+}
+
+// CHECK-LABEL: define void @_Z1fPi(
+void f(int *p) {
+  // CHECK-NOT: call void @_ZdlPvSt11align_val_t(
+  // CHECK: call void @_ZdlPv(
+  // CHECK: ret void
+  delete p;
+}


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


[PATCH] D53508: [SemaCXX] Unconfuse Clang when std::align_val_t is unscoped in C++03

2018-10-24 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

Accepting. This is a good candidate for post-commit review.


Repository:
  rC Clang

https://reviews.llvm.org/D53508



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


[PATCH] D53665: [X86] Add a common-avx512 CPU to match icc's -xCOMMON-AVX512 option

2018-10-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper abandoned this revision.
craig.topper added a comment.

Abandoning after an internal conversation.


https://reviews.llvm.org/D53665



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


[PATCH] D53207: Fix bug 26547 - alignof should return ABI alignment, not preferred alignment

2018-10-24 Thread Nicole Mazzuca via Phabricator via cfe-commits
ubsan updated this revision to Diff 170994.
ubsan added a comment.

Add ABI breakage information and reflow


Repository:
  rC Clang

https://reviews.llvm.org/D53207

Files:
  docs/ReleaseNotes.rst
  include/clang/AST/Stmt.h
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/LangOptions.h
  include/clang/Basic/TypeTraits.h
  lib/AST/ASTDumper.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  test/Headers/thumbv7-apple-ios-types.cpp
  test/Sema/align-x86-abi7.c
  test/Sema/align-x86.c
  test/SemaCXX/align-x86-abi7.cpp
  test/SemaCXX/align-x86.cpp
  test/SemaCXX/alignof.cpp

Index: test/SemaCXX/alignof.cpp
===
--- test/SemaCXX/alignof.cpp
+++ test/SemaCXX/alignof.cpp
@@ -4,14 +4,14 @@
 
 struct S0 {
   int x;
-  static const int test0 = __alignof__(x); // expected-error {{invalid application of 'alignof' to a field of a class still being defined}}
-  static const int test1 = __alignof__(S0::x); // expected-error {{invalid application of 'alignof' to a field of a class still being defined}}
-  auto test2() -> char(&)[__alignof__(x)]; // expected-error {{invalid application of 'alignof' to a field of a class still being defined}}
+  static const int test0 = __alignof__(x); // expected-error {{invalid application of '__alignof' to a field of a class still being defined}}
+  static const int test1 = __alignof__(S0::x); // expected-error {{invalid application of '__alignof' to a field of a class still being defined}}
+  auto test2() -> char(&)[__alignof__(x)]; // expected-error {{invalid application of '__alignof' to a field of a class still being defined}}
 };
 
 struct S1; // expected-note 6 {{forward declaration}}
 extern S1 s1;
-const int test3 = __alignof__(s1); // expected-error {{invalid application of 'alignof' to an incomplete type 'S1'}}
+const int test3 = __alignof__(s1); // expected-error {{invalid application of '__alignof' to an incomplete type 'S1'}}
 
 struct S2 {
   S2();
@@ -19,11 +19,11 @@
   int x;
 
   int test4 = __alignof__(x); // ok
-  int test5 = __alignof__(s); // expected-error {{invalid application of 'alignof' to an incomplete type 'S1'}}
+  int test5 = __alignof__(s); // expected-error {{invalid application of '__alignof' to an incomplete type 'S1'}}
 };
 
 const int test6 = __alignof__(S2::x);
-const int test7 = __alignof__(S2::s); // expected-error {{invalid application of 'alignof' to an incomplete type 'S1'}}
+const int test7 = __alignof__(S2::s); // expected-error {{invalid application of '__alignof' to an incomplete type 'S1'}}
 
 // Arguably, these should fail like the S1 cases do: the alignment of
 // 's2.x' should depend on the alignment of both x-within-S2 and
@@ -34,10 +34,10 @@
   S2 s2;
 
   static const int test8 = __alignof__(s2.x);
-  static const int test9 = __alignof__(s2.s); // expected-error {{invalid application of 'alignof' to an incomplete type 'S1'}}
+  static const int test9 = __alignof__(s2.s); // expected-error {{invalid application of '__alignof' to an incomplete type 'S1'}}
   auto test10() -> char(&)[__alignof__(s2.x)];
   static const int test11 = __alignof__(S3::s2.x);
-  static const int test12 = __alignof__(S3::s2.s); // expected-error {{invalid application of 'alignof' to an incomplete type 'S1'}}
+  static const int test12 = __alignof__(S3::s2.s); // expected-error {{invalid application of '__alignof' to an incomplete type 'S1'}}
   auto test13() -> char(&)[__alignof__(s2.x)];
 };
 
@@ -59,9 +59,9 @@
 };
 const int test8 = __alignof__(S5::x);
 
-long long int test14[2];
+int test14[2];
 
-static_assert(alignof(test14) == 8, "foo"); // expected-warning {{'alignof' applied to an expression is a GNU extension}}
+static_assert(alignof(test14) == 4, "foo"); // expected-warning {{'alignof' applied to an expression is a GNU extension}}
 
 // PR19992
 static_assert(alignof(int[]) == alignof(int), ""); // ok
Index: test/SemaCXX/align-x86.cpp
===
--- /dev/null
+++ test/SemaCXX/align-x86.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -std=c++11 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+using size_t = decltype(sizeof(0));
+
+struct complex_double {
+  double real;
+  double imag;
+};
+
+template 
+struct check_alignment {
+  using type = T;
+  static type value;
+
+  static_assert(__alignof__(value) == Preferred, "__alignof__(value) != Preferred");
+  static_assert(__alignof__(type) == Preferred, "__alignof__(type) != Preferred");
+  static_assert(alignof(type) == ABI, "alignof(type) != ABI");
+};
+
+// PR3433
+template struct check_alignment;
+template struct check_alignment;
+template struct check_alignment;
+template struct check_alignment;
+
+// PR6362
+struct 

[PATCH] D53586: Implement Function Multiversioning for Non-ELF Systems.

2018-10-24 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

All of the target specific stuff looks fine to me. I'm going to defer to rnk 
about the windows side of things and aaron for the attributes.


https://reviews.llvm.org/D53586



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


[PATCH] D53674: [CodeGen] Fix assertion on referencing constexpr Obj-C object with ARC.

2018-10-24 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: ahatanak, rjmccall.
Herald added a subscriber: dexonsmith.

Failed assertion is

> Assertion failed: ((ND->isUsed(false) || !isa(ND) || 
> !E->getLocation().isValid()) && "Should not use decl without marking it 
> used!"), function EmitDeclRefLValue, file 
> llvm-project/clang/lib/CodeGen/CGExpr.cpp, line 2437.

`EmitDeclRefLValue` mentions

> // A DeclRefExpr for a reference initialized by a constant expression can
>  // appear without being odr-used. Directly emit the constant initializer.

The fix is in using the similar approach for non-references of
non-odr-used variables. `EmitScalarExpr` will try to emit constant if
possible and we can use resulting `llvm::Value *` without performing
`EmitLValue`.

rdar://problem/40650504


https://reviews.llvm.org/D53674

Files:
  clang/lib/CodeGen/CGObjC.cpp
  clang/test/CodeGenObjCXX/arc-constexpr.mm

Index: clang/test/CodeGenObjCXX/arc-constexpr.mm
===
--- clang/test/CodeGenObjCXX/arc-constexpr.mm
+++ clang/test/CodeGenObjCXX/arc-constexpr.mm
@@ -1,18 +1,50 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -o - -std=c++11 %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-runtime-has-weak -o - -std=c++11 %s | FileCheck %s
 
 // CHECK: %[[TYPE:[a-z0-9]+]] = type opaque
 // CHECK: @[[CFSTRING:[a-z0-9_]+]] = private global %struct.__NSConstantString_tag
+@class NSString;
 
-// CHECK: define void @_Z5test1v
+// CHECK-LABEL: define void @_Z5test1v
 // CHECK:   %[[ALLOCA:[A-Z]+]] = alloca %[[TYPE]]*
 // CHECK:   %[[V0:[0-9]+]] = call i8* @objc_retain(i8* bitcast (%struct.__NSConstantString_tag* @[[CFSTRING]]
 // CHECK:   %[[V1:[0-9]+]] = bitcast i8* %[[V0]] to %[[TYPE]]*
 // CHECK:   store %[[TYPE]]* %[[V1]], %[[TYPE]]** %[[ALLOCA]]
 // CHECK:   %[[V2:[0-9]+]] = bitcast %[[TYPE]]** %[[ALLOCA]]
 // CHECK:   call void @objc_storeStrong(i8** %[[V2]], i8* null)
-
-@class NSString;
-
 void test1() {
   constexpr NSString *S = @"abc";
 }
+
+// CHECK-LABEL: define void @_Z5test2v
+// CHECK:  %[[CONST:[a-zA-Z]+]] = alloca %[[TYPE]]*
+// CHECK:  %[[REF_CONST:[a-zA-Z]+]] = alloca %[[TYPE]]*
+// CHECK:  %[[V0:[0-9]+]] = call i8* @objc_retain(i8* bitcast (%struct.__NSConstantString_tag* @[[CFSTRING]]
+// CHECK-NEXT: %[[V1:[0-9]+]] = bitcast i8* %[[V0]] to %[[TYPE]]*
+// CHECK-NEXT: store %[[TYPE]]* %[[V1]], %[[TYPE]]** %[[CONST]]
+// CHECK:  %[[V2:[0-9]+]] = call i8* @objc_retain(i8* bitcast (%struct.__NSConstantString_tag* @[[CFSTRING]]
+// CHECK-NEXT: %[[V3:[0-9]+]] = bitcast i8* %[[V2]] to %[[TYPE]]*
+// CHECK-NEXT: store %[[TYPE]]* %[[V3]], %[[TYPE]]** %[[REF_CONST]]
+// CHECK:  %[[V4:[0-9]+]] = bitcast %[[TYPE]]** %[[REF_CONST]]
+// CHECK-NEXT: call void @objc_storeStrong(i8** %[[V4]], i8* null)
+// CHECK:  %[[V5:[0-9]+]] = bitcast %[[TYPE]]** %[[CONST]]
+// CHECK-NEXT: call void @objc_storeStrong(i8** %[[V5]], i8* null)
+void test2() {
+  constexpr NSString *Const = @"abc";
+  // Initialize RefConst with Const initializer instead of reading from variable.
+  NSString* RefConst = Const;
+}
+
+// CHECK-LABEL: define void @_Z5test3v
+// CHECK:  %[[WEAK_CONST:[a-zA-Z]+]] = alloca %[[TYPE]]*
+// CHECK:  %[[REF_WEAK_CONST:[a-zA-Z]+]] = alloca %[[TYPE]]*
+// CHECK:  %[[V0:[0-9]+]] = bitcast %[[TYPE]]** %[[WEAK_CONST]]
+// CHECK-NEXT: %[[V1:[0-9]+]] = call i8* @objc_initWeak(i8** %[[V0]], i8* bitcast (%struct.__NSConstantString_tag* @[[CFSTRING]]
+// CHECK:  store %[[TYPE]]* bitcast (%struct.__NSConstantString_tag* @[[CFSTRING]] to %[[TYPE]]*), %[[TYPE]]** %[[REF_WEAK_CONST]]
+// CHECK:  %[[V2:[0-9]+]] = bitcast %[[TYPE]]** %[[REF_WEAK_CONST]]
+// CHECK-NEXT: call void @objc_storeStrong(i8** %[[V2]], i8* null)
+// CHECK:  %[[V3:[0-9]+]] = bitcast %[[TYPE]]** %[[WEAK_CONST]]
+// CHECK-NEXT: call void @objc_destroyWeak(i8** %[[V3]])
+void test3() {
+  __weak constexpr NSString *WeakConst = @"abc";
+  NSString* RefWeakConst = WeakConst;
+}
Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -2446,21 +2446,37 @@
 EHStack.pushCleanup(NormalCleanup, Ptr);
 }
 
+static bool shouldRetainObjCLifetime(Qualifiers::ObjCLifetime Lifetime) {
+  switch (Lifetime) {
+  case Qualifiers::OCL_None:
+  case Qualifiers::OCL_ExplicitNone:
+  case Qualifiers::OCL_Strong:
+  case Qualifiers::OCL_Autoreleasing:
+return true;
+
+  case Qualifiers::OCL_Weak:
+return false;
+  }
+
+  llvm_unreachable("impossible lifetime!");
+}
+
 static TryEmitResult tryEmitARCRetainLoadOfScalar(CodeGenFunction ,
   LValue lvalue,
   QualType type) {
+  bool SuppressResultRetain = !shouldRetainObjCLifetime(type.getObjCLifetime());
   switch (type.getObjCLifetime()) 

[PATCH] D53066: [Driver] Use forward slashes in most linker arguments

2018-10-24 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 170989.
mstorsjo added a comment.

Changed so that we only rewrite paths if targeting a non-windows OS, or 
cygwin/mingw. Since convert_to_slash is a no-op when running on anything else 
than windows, this should hit exactly the cases where converting to forward 
slashes should make sense.


https://reviews.llvm.org/D53066

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/Gnu.cpp

Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1699,7 +1699,7 @@
 if (GCCToolchainDir.back() == '/')
   GCCToolchainDir = GCCToolchainDir.drop_back(); // remove the /
 
-Prefixes.push_back(GCCToolchainDir);
+Prefixes.push_back(llvm::sys::path::convert_to_slash(GCCToolchainDir));
   } else {
 // If we have a SysRoot, try that first.
 if (!D.SysRoot.empty()) {
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -163,7 +163,7 @@
 
 // Add filenames immediately.
 if (II.isFilename()) {
-  CmdArgs.push_back(II.getFilename());
+  CmdArgs.push_back(Args.MakeArgString(TC.normalizePath(II.getFilename(;
   continue;
 }
 
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3496,7 +3496,8 @@
 for (const auto  : Inputs) {
   addDashXForInput(Args, II, CmdArgs);
   if (II.isFilename())
-CmdArgs.push_back(II.getFilename());
+CmdArgs.push_back(
+Args.MakeArgString(TC.normalizePath(II.getFilename(;
   else
 II.getInputArg().renderAsInput(Args, CmdArgs);
 }
@@ -4878,7 +4879,8 @@
 // Handled with other dependency code.
   } else if (Output.isFilename()) {
 CmdArgs.push_back("-o");
-CmdArgs.push_back(Output.getFilename());
+CmdArgs.push_back(
+Args.MakeArgString(TC.normalizePath(Output.getFilename(;
   } else {
 assert(Output.isNothing() && "Invalid output.");
   }
@@ -4893,7 +4895,8 @@
 
   for (const InputInfo  : FrontendInputs) {
 if (Input.isFilename())
-  CmdArgs.push_back(Input.getFilename());
+  CmdArgs.push_back(
+  Args.MakeArgString(TC.normalizePath(Input.getFilename(;
 else
   Input.getInputArg().renderAsInput(Args, CmdArgs);
   }
@@ -5586,9 +5589,10 @@
   assert(Inputs.size() == 1 && "Unexpected number of inputs.");
   const InputInfo  = Inputs[0];
 
-  const llvm::Triple  = getToolChain().getEffectiveTriple();
+  const ToolChain  = getToolChain();
+  const llvm::Triple  = TC.getEffectiveTriple();
   const std::string  = Triple.getTriple();
-  const auto  = getToolChain().getDriver();
+  const auto  = TC.getDriver();
 
   // Don't warn about "clang -w -c foo.s"
   Args.ClaimAllArgs(options::OPT_w);
@@ -5762,7 +5766,7 @@
 
   assert(Output.isFilename() && "Unexpected lipo output.");
   CmdArgs.push_back("-o");
-  CmdArgs.push_back(Output.getFilename());
+  CmdArgs.push_back(Args.MakeArgString(TC.normalizePath(Output.getFilename(;
 
   const llvm::Triple  = getToolChain().getTriple();
   if (Args.hasArg(options::OPT_gsplit_dwarf) &&
@@ -5772,7 +5776,7 @@
   }
 
   assert(Input.isFilename() && "Invalid input.");
-  CmdArgs.push_back(Input.getFilename());
+  CmdArgs.push_back(Args.MakeArgString(TC.normalizePath(Input.getFilename(;
 
   const char *Exec = getToolChain().getDriver().getClangProgramPath();
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -376,17 +376,18 @@
 
   for (const auto  : getLibraryPaths()) {
 SmallString<128> P(LibPath);
-llvm::sys::path::append(P, Prefix + Twine("clang_rt.") + Component + Suffix);
+llvm::sys::path::append(P,
+Prefix + Twine("clang_rt.") + Component + Suffix);
 if (getVFS().exists(P))
-  return P.str();
+  return normalizePath(P);
   }
 
   StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
   const char *Env = TT.isAndroid() ? "-android" : "";
   SmallString<128> Path(getCompilerRTPath());
   llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
 Arch + Env + Suffix);
-  return Path.str();
+  return normalizePath(Path);
 }
 
 const char *ToolChain::getCompilerRTArgString(const llvm::opt::ArgList ,
@@ -425,7 +426,7 @@
 }
 
 std::string ToolChain::GetFilePath(const char *Name) const {
-  return D.GetFilePath(Name, *this);
+  return 

[PATCH] D53586: Implement Function Multiversioning for Non-ELF Systems.

2018-10-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 170987.
erichkeane added a comment.

did everything suggested by @rnk as far as I know.  Thanks again for the 
reviews!


https://reviews.llvm.org/D53586

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/TargetInfo.h
  lib/AST/Decl.cpp
  lib/Basic/Targets/X86.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGen/attr-cpuspecific.c
  test/CodeGen/attr-target-mv-func-ptrs.c
  test/CodeGen/attr-target-mv-va-args.c
  test/CodeGen/attr-target-mv.c
  test/CodeGenCXX/attr-target-mv-diff-ns.cpp
  test/CodeGenCXX/attr-target-mv-func-ptrs.cpp
  test/CodeGenCXX/attr-target-mv-member-funcs.cpp
  test/CodeGenCXX/attr-target-mv-out-of-line-defs.cpp
  test/CodeGenCXX/attr-target-mv-overloads.cpp
  test/Sema/attr-target-mv-bad-target.c

Index: test/Sema/attr-target-mv-bad-target.c
===
--- test/Sema/attr-target-mv-bad-target.c
+++ test/Sema/attr-target-mv-bad-target.c
@@ -1,4 +1,3 @@
-// RUN: %clang_cc1 -triple x86_64-windows-pc  -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple arm-none-eabi  -fsyntax-only -verify %s
 
 int __attribute__((target("sse4.2"))) redecl1(void) { return 1; }
Index: test/CodeGenCXX/attr-target-mv-overloads.cpp
===
--- test/CodeGenCXX/attr-target-mv-overloads.cpp
+++ test/CodeGenCXX/attr-target-mv-overloads.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=LINUX
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefix=WINDOWS
 
 int __attribute__((target("sse4.2"))) foo_overload(int) { return 0; }
 int __attribute__((target("arch=sandybridge"))) foo_overload(int);
@@ -13,38 +14,69 @@
   return foo_overload() + foo_overload(1);
 }
 
-// CHECK: @_Z12foo_overloadv.ifunc = ifunc i32 (), i32 ()* ()* @_Z12foo_overloadv.resolver
-// CHECK: @_Z12foo_overloadi.ifunc = ifunc i32 (i32), i32 (i32)* ()* @_Z12foo_overloadi.resolver
-
-
-// CHECK: define i32 @_Z12foo_overloadi.sse4.2(i32)
-// CHECK: ret i32 0
-// CHECK: define i32 @_Z12foo_overloadi.arch_ivybridge(i32)
-// CHECK: ret i32 1
-// CHECK: define i32 @_Z12foo_overloadi(i32)
-// CHECK: ret i32 2
-// CHECK: define i32 @_Z12foo_overloadv.sse4.2()
-// CHECK: ret i32 0
-// CHECK: define i32 @_Z12foo_overloadv.arch_ivybridge()
-// CHECK: ret i32 1
-// CHECK: define i32 @_Z12foo_overloadv()
-// CHECK: ret i32 2
-
-// CHECK: define i32 @_Z4bar2v()
-// CHECK: call i32 @_Z12foo_overloadv.ifunc()
-// CHECK: call i32 @_Z12foo_overloadi.ifunc(i32 1)
-
-// CHECK: define i32 ()* @_Z12foo_overloadv.resolver() comdat
-// CHECK: ret i32 ()* @_Z12foo_overloadv.arch_sandybridge
-// CHECK: ret i32 ()* @_Z12foo_overloadv.arch_ivybridge
-// CHECK: ret i32 ()* @_Z12foo_overloadv.sse4.2
-// CHECK: ret i32 ()* @_Z12foo_overloadv
-
-// CHECK: define i32 (i32)* @_Z12foo_overloadi.resolver() comdat
-// CHECK: ret i32 (i32)* @_Z12foo_overloadi.arch_sandybridge
-// CHECK: ret i32 (i32)* @_Z12foo_overloadi.arch_ivybridge
-// CHECK: ret i32 (i32)* @_Z12foo_overloadi.sse4.2
-// CHECK: ret i32 (i32)* @_Z12foo_overloadi
-
-// CHECK: declare i32 @_Z12foo_overloadv.arch_sandybridge()
-// CHECK: declare i32 @_Z12foo_overloadi.arch_sandybridge(i32)
+// LINUX: @_Z12foo_overloadv.ifunc = ifunc i32 (), i32 ()* ()* @_Z12foo_overloadv.resolver
+// LINUX: @_Z12foo_overloadi.ifunc = ifunc i32 (i32), i32 (i32)* ()* @_Z12foo_overloadi.resolver
+
+// LINUX: define i32 @_Z12foo_overloadi.sse4.2(i32)
+// LINUX: ret i32 0
+// LINUX: define i32 @_Z12foo_overloadi.arch_ivybridge(i32)
+// LINUX: ret i32 1
+// LINUX: define i32 @_Z12foo_overloadi(i32)
+// LINUX: ret i32 2
+// LINUX: define i32 @_Z12foo_overloadv.sse4.2()
+// LINUX: ret i32 0
+// LINUX: define i32 @_Z12foo_overloadv.arch_ivybridge()
+// LINUX: ret i32 1
+// LINUX: define i32 @_Z12foo_overloadv()
+// LINUX: ret i32 2
+
+// WINDOWS: define dso_local i32 @"?foo_overload@@YAHH@Z.sse4.2"(i32)
+// WINDOWS: ret i32 0
+// WINDOWS: define dso_local i32 @"?foo_overload@@YAHH@Z.arch_ivybridge"(i32)
+// WINDOWS: ret i32 1
+// WINDOWS: define dso_local i32 @"?foo_overload@@YAHH@Z"(i32)
+// WINDOWS: ret i32 2
+// WINDOWS: define dso_local i32 @"?foo_overload@@YAHXZ.sse4.2"()
+// WINDOWS: ret i32 0
+// WINDOWS: define dso_local i32 @"?foo_overload@@YAHXZ.arch_ivybridge"()
+// WINDOWS: ret i32 1
+// WINDOWS: define dso_local i32 @"?foo_overload@@YAHXZ"()
+// WINDOWS: ret i32 2
+
+// LINUX: define i32 @_Z4bar2v()
+// LINUX: call i32 @_Z12foo_overloadv.ifunc()
+// LINUX: call i32 @_Z12foo_overloadi.ifunc(i32 1)
+
+// WINDOWS: define dso_local i32 @"?bar2@@YAHXZ"()
+// WINDOWS: call i32 @"?foo_overload@@YAHXZ.resolver"()
+// WINDOWS: call i32 

[PATCH] D53207: Fix bug 26547 - alignof should return ABI alignment, not preferred alignment

2018-10-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks! Can you also write something for the release notes 
(docs/ReleaseNotes.rst) describing the ABI change?




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5478
 def ext_sizeof_alignof_function_type : Extension<
-  "invalid application of '%select{sizeof|alignof|vec_step}0' to a "
+  "invalid application of 
'%select{sizeof|alignof|vec_step|__builtin_omp_required_simd_align|__alignof}0' 
to a "
   "function type">, InGroup;

Please factor out this repeated %select and use a %sub instead.



Comment at: lib/Sema/SemaExpr.cpp:3772
   //   is the alignment of the element type.
-  if (ExprKind == UETT_AlignOf || ExprKind == UETT_OpenMPRequiredSimdAlign)
+  if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf || 
ExprKind == UETT_OpenMPRequiredSimdAlign)
 ExprType = Context.getBaseElementType(ExprType);

Please reflow this to under 80 columns.


Repository:
  rC Clang

https://reviews.llvm.org/D53207



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


r345198 - Add gfx909 to GPU Arch

2018-10-24 Thread Tim Renouf via cfe-commits
Author: tpr
Date: Wed Oct 24 14:19:02 2018
New Revision: 345198

URL: http://llvm.org/viewvc/llvm-project?rev=345198=rev
Log:
Add gfx909 to GPU Arch

Subscribers: jholewinski, cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/Cuda.h
cfe/trunk/lib/Basic/Cuda.cpp
cfe/trunk/lib/Basic/Targets/NVPTX.cpp

Modified: cfe/trunk/include/clang/Basic/Cuda.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Cuda.h?rev=345198=345197=345198=diff
==
--- cfe/trunk/include/clang/Basic/Cuda.h (original)
+++ cfe/trunk/include/clang/Basic/Cuda.h Wed Oct 24 14:19:02 2018
@@ -64,6 +64,7 @@ enum class CudaArch {
   GFX902,
   GFX904,
   GFX906,
+  GFX909,
   LAST,
 };
 const char *CudaArchToString(CudaArch A);

Modified: cfe/trunk/lib/Basic/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Cuda.cpp?rev=345198=345197=345198=diff
==
--- cfe/trunk/lib/Basic/Cuda.cpp (original)
+++ cfe/trunk/lib/Basic/Cuda.cpp Wed Oct 24 14:19:02 2018
@@ -94,6 +94,8 @@ const char *CudaArchToString(CudaArch A)
 return "gfx904";
   case CudaArch::GFX906: // TBA
 return "gfx906";
+  case CudaArch::GFX909: // TBA
+return "gfx909";
   }
   llvm_unreachable("invalid enum");
 }
@@ -130,6 +132,7 @@ CudaArch StringToCudaArch(llvm::StringRe
   .Case("gfx902", CudaArch::GFX902)
   .Case("gfx904", CudaArch::GFX904)
   .Case("gfx906", CudaArch::GFX906)
+  .Case("gfx909", CudaArch::GFX909)
   .Default(CudaArch::UNKNOWN);
 }
 
@@ -241,6 +244,7 @@ CudaVirtualArch VirtualArchForCudaArch(C
   case CudaArch::GFX902:
   case CudaArch::GFX904:
   case CudaArch::GFX906:
+  case CudaArch::GFX909:
 return CudaVirtualArch::COMPUTE_AMDGCN;
   }
   llvm_unreachable("invalid enum");
@@ -287,6 +291,7 @@ CudaVersion MinVersionForCudaArch(CudaAr
   case CudaArch::GFX902:
   case CudaArch::GFX904:
   case CudaArch::GFX906:
+  case CudaArch::GFX909:
 return CudaVersion::CUDA_70;
   }
   llvm_unreachable("invalid enum");

Modified: cfe/trunk/lib/Basic/Targets/NVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/NVPTX.cpp?rev=345198=345197=345198=diff
==
--- cfe/trunk/lib/Basic/Targets/NVPTX.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/NVPTX.cpp Wed Oct 24 14:19:02 2018
@@ -190,6 +190,7 @@ void NVPTXTargetInfo::getTargetDefines(c
   case CudaArch::GFX902:
   case CudaArch::GFX904:
   case CudaArch::GFX906:
+  case CudaArch::GFX909:
   case CudaArch::LAST:
 break;
   case CudaArch::UNKNOWN:


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


[PATCH] D53586: Implement Function Multiversioning for Non-ELF Systems.

2018-10-24 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/CodeGen/CodeGenFunction.cpp:2391-2393
+  llvm::SmallVector Args;
+  llvm::for_each(Resolver->args(),
+ [&](llvm::Argument ) { Args.push_back(); });

erichkeane wrote:
> rnk wrote:
> > Surely this would be simpler as a range for or `Args{Resolver->arg_begin() 
> > ...};`
> Surely... Unfortunately the types don't match.  Resolver Args are an array of 
> Arguments (so the iterator is a Arg*).
> 
> HOWEVER, "Args" here needs to be an array ref to Value*, so the iterator 
> would have to be a Value** (not a Arg*/Value*).  The point of this small 
> vector is to create an array of _pointers_ from the array of Arguments.
Right. :)



Comment at: lib/CodeGen/CodeGenFunction.cpp:2395
+
+  llvm::CallInst *Result = Builder.CreateCall(FuncToReturn, Args);
+

erichkeane wrote:
> erichkeane wrote:
> > rnk wrote:
> > > This approach is... not going to work in the general case. Consider, for 
> > > example, varargs. Then consider 32-bit x86 inalloca, which is quite 
> > > widespread. Any non-trivially copyable object is not going to be passable 
> > > through such a thunk. You might consider looking at 
> > > CodeGenFunction::EmitMustTailThunk instead.
> > Oh dear... 
> > I'm unfamiliar with EmitMustTailThunk, is it self explanatory?  Any chance 
> > you can expound?  Should I call/use that function, or copy out of it?
> I looked through that function, and it seems to do very similar things to 
> this...
> 
> It FIRST does the small-vector conversion to a value* array like I do.
> 
> Second, it 'adjusts' the 'this' parameter.  This doesn't seem like it needs 
> to happen, because the type isn't changing, right?  my 'this' pointer is 
> still pass-on-able.
> 
> Third, it creates the call, then marks it TCK_MustTail.
> 
> Forth, it sets the attributes/calling convention of the 'call' object, but 
> I'd expect that to come from the llvm::Function object in the 'CreateCall', 
> right?  I can add them after the fact I guess, if we see value.*(see below)
> 
> Finally, it does the CreateRetVoid/CreateRet like this function does below. 
> 
> *I DO have a test that claims that my IR is broken if I set the call 
> attributes.  Curiously only 1 of my tests, but the error is:
> "cannot guarantee tail call due to mismatched ABI impacting function 
> attributes"
> 
> The only difference in attributes is target-features and target-cpu though, 
> so I don't know what causes this.
Right, the this-adjustment is definitely unnecessary for this kind of CPU 
dispatch thunk.

The important thing is that marking the call as `musttail` ensures that you get 
perfect forwarding of all arguments, even varargs and inalloca. Maybe it's 
enough to just mark the call you are creating that way. I think the code you 
are generating obeys all the musttail invariants, so that might be best.

The "cannot guarantee tail call due to mismatched ABI impacting function 
attributes" verifier check is only supposed to fire when parameter attributes 
like `byval` and `inreg` differ between the call site and the dispatcher 
function. It shouldn't care about target-cpu or target-features.



Comment at: test/CodeGenCXX/attr-target-mv-overloads.cpp:74
+// WINDOWS: define dso_local i32 @"?foo_overload@@YAHH@Z.resolver"(i32) comdat
+// WINDOWS: call i32 @"?foo_overload@@YAHH@Z.arch_sandybridge"
+// WINDOWS: call i32 @"?foo_overload@@YAHH@Z.arch_ivybridge"

erichkeane wrote:
> rnk wrote:
> > Does dumpbin demangle these names correctly? Just curious.
> I don't know, I'd suspect not.  However, demangler.com (not sure what it 
> uses?) seems to demangle them ignoring everything after the '.'.
Neat.


Repository:
  rC Clang

https://reviews.llvm.org/D53586



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


[PATCH] D53558: Add gfx909 to GPU Arch

2018-10-24 Thread Tim Renouf via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345198: Add gfx909 to GPU Arch (authored by tpr, committed 
by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D53558

Files:
  cfe/trunk/include/clang/Basic/Cuda.h
  cfe/trunk/lib/Basic/Cuda.cpp
  cfe/trunk/lib/Basic/Targets/NVPTX.cpp


Index: cfe/trunk/lib/Basic/Cuda.cpp
===
--- cfe/trunk/lib/Basic/Cuda.cpp
+++ cfe/trunk/lib/Basic/Cuda.cpp
@@ -94,6 +94,8 @@
 return "gfx904";
   case CudaArch::GFX906: // TBA
 return "gfx906";
+  case CudaArch::GFX909: // TBA
+return "gfx909";
   }
   llvm_unreachable("invalid enum");
 }
@@ -130,6 +132,7 @@
   .Case("gfx902", CudaArch::GFX902)
   .Case("gfx904", CudaArch::GFX904)
   .Case("gfx906", CudaArch::GFX906)
+  .Case("gfx909", CudaArch::GFX909)
   .Default(CudaArch::UNKNOWN);
 }
 
@@ -241,6 +244,7 @@
   case CudaArch::GFX902:
   case CudaArch::GFX904:
   case CudaArch::GFX906:
+  case CudaArch::GFX909:
 return CudaVirtualArch::COMPUTE_AMDGCN;
   }
   llvm_unreachable("invalid enum");
@@ -287,6 +291,7 @@
   case CudaArch::GFX902:
   case CudaArch::GFX904:
   case CudaArch::GFX906:
+  case CudaArch::GFX909:
 return CudaVersion::CUDA_70;
   }
   llvm_unreachable("invalid enum");
Index: cfe/trunk/lib/Basic/Targets/NVPTX.cpp
===
--- cfe/trunk/lib/Basic/Targets/NVPTX.cpp
+++ cfe/trunk/lib/Basic/Targets/NVPTX.cpp
@@ -190,6 +190,7 @@
   case CudaArch::GFX902:
   case CudaArch::GFX904:
   case CudaArch::GFX906:
+  case CudaArch::GFX909:
   case CudaArch::LAST:
 break;
   case CudaArch::UNKNOWN:
Index: cfe/trunk/include/clang/Basic/Cuda.h
===
--- cfe/trunk/include/clang/Basic/Cuda.h
+++ cfe/trunk/include/clang/Basic/Cuda.h
@@ -64,6 +64,7 @@
   GFX902,
   GFX904,
   GFX906,
+  GFX909,
   LAST,
 };
 const char *CudaArchToString(CudaArch A);


Index: cfe/trunk/lib/Basic/Cuda.cpp
===
--- cfe/trunk/lib/Basic/Cuda.cpp
+++ cfe/trunk/lib/Basic/Cuda.cpp
@@ -94,6 +94,8 @@
 return "gfx904";
   case CudaArch::GFX906: // TBA
 return "gfx906";
+  case CudaArch::GFX909: // TBA
+return "gfx909";
   }
   llvm_unreachable("invalid enum");
 }
@@ -130,6 +132,7 @@
   .Case("gfx902", CudaArch::GFX902)
   .Case("gfx904", CudaArch::GFX904)
   .Case("gfx906", CudaArch::GFX906)
+  .Case("gfx909", CudaArch::GFX909)
   .Default(CudaArch::UNKNOWN);
 }
 
@@ -241,6 +244,7 @@
   case CudaArch::GFX902:
   case CudaArch::GFX904:
   case CudaArch::GFX906:
+  case CudaArch::GFX909:
 return CudaVirtualArch::COMPUTE_AMDGCN;
   }
   llvm_unreachable("invalid enum");
@@ -287,6 +291,7 @@
   case CudaArch::GFX902:
   case CudaArch::GFX904:
   case CudaArch::GFX906:
+  case CudaArch::GFX909:
 return CudaVersion::CUDA_70;
   }
   llvm_unreachable("invalid enum");
Index: cfe/trunk/lib/Basic/Targets/NVPTX.cpp
===
--- cfe/trunk/lib/Basic/Targets/NVPTX.cpp
+++ cfe/trunk/lib/Basic/Targets/NVPTX.cpp
@@ -190,6 +190,7 @@
   case CudaArch::GFX902:
   case CudaArch::GFX904:
   case CudaArch::GFX906:
+  case CudaArch::GFX909:
   case CudaArch::LAST:
 break;
   case CudaArch::UNKNOWN:
Index: cfe/trunk/include/clang/Basic/Cuda.h
===
--- cfe/trunk/include/clang/Basic/Cuda.h
+++ cfe/trunk/include/clang/Basic/Cuda.h
@@ -64,6 +64,7 @@
   GFX902,
   GFX904,
   GFX906,
+  GFX909,
   LAST,
 };
 const char *CudaArchToString(CudaArch A);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53441: [ms] Prevent explicit constructor name lookup if scope is missing

2018-10-24 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm, thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D53441



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


[PATCH] D53280: [analyzer] Emit a warning for unknown -analyzer-config options

2018-10-24 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus planned changes to this revision.
Szelethus added a comment.

Since I've dug myself quite deep into the refactoring effort, I realized that 
there are more elegant ways of achieving this, should I hammer 
`AnalyzerOptions` for long enough. I'll probably change everything but the 
revision title.


https://reviews.llvm.org/D53280



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


[PATCH] D53608: [builtins] Build float128 soft float builtins for x86_64.

2018-10-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Yes, that looks right.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D53608



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


[PATCH] D53501: [clang-query] Refactor Output settings to booleans

2018-10-24 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345194: [clang-query] Refactor Output settings to booleans 
(authored by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53501?vs=170431=170976#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53501

Files:
  clang-tools-extra/trunk/clang-query/Query.cpp
  clang-tools-extra/trunk/clang-query/Query.h
  clang-tools-extra/trunk/clang-query/QueryParser.cpp
  clang-tools-extra/trunk/clang-query/QuerySession.h
  clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp
  clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp

Index: clang-tools-extra/trunk/clang-query/Query.cpp
===
--- clang-tools-extra/trunk/clang-query/Query.cpp
+++ clang-tools-extra/trunk/clang-query/Query.cpp
@@ -107,8 +107,7 @@
 
   for (auto BI = MI->getMap().begin(), BE = MI->getMap().end(); BI != BE;
++BI) {
-switch (QS.OutKind) {
-case OK_Diag: {
+if (QS.DiagOutput) {
   clang::SourceRange R = BI->second.getSourceRange();
   if (R.isValid()) {
 TextDiagnostic TD(OS, AST->getASTContext().getLangOpts(),
@@ -118,20 +117,16 @@
 DiagnosticsEngine::Note, "\"" + BI->first + "\" binds here",
 CharSourceRange::getTokenRange(R), None);
   }
-  break;
 }
-case OK_Print: {
+if (QS.PrintOutput) {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.print(OS, AST->getASTContext().getPrintingPolicy());
   OS << "\n";
-  break;
 }
-case OK_DetailedAST: {
+if (QS.DetailedASTOutput) {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.dump(OS, AST->getSourceManager());
   OS << "\n";
-  break;
-}
 }
   }
 
Index: clang-tools-extra/trunk/clang-query/QueryParser.cpp
===
--- clang-tools-extra/trunk/clang-query/QueryParser.cpp
+++ clang-tools-extra/trunk/clang-query/QueryParser.cpp
@@ -119,7 +119,17 @@
 "expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
 "'");
   }
-  return new SetQuery(::OutKind, OutputKind(OutKind));
+
+  switch (OutKind) {
+  case OK_DetailedAST:
+return new SetExclusiveOutputQuery(::DetailedASTOutput);
+  case OK_Diag:
+return new SetExclusiveOutputQuery(::DiagOutput);
+  case OK_Print:
+return new SetExclusiveOutputQuery(::PrintOutput);
+  }
+
+  llvm_unreachable("Invalid output kind");
 }
 
 QueryRef QueryParser::endQuery(QueryRef Q) {
Index: clang-tools-extra/trunk/clang-query/QuerySession.h
===
--- clang-tools-extra/trunk/clang-query/QuerySession.h
+++ clang-tools-extra/trunk/clang-query/QuerySession.h
@@ -25,11 +25,16 @@
 class QuerySession {
 public:
   QuerySession(llvm::ArrayRef> ASTs)
-  : ASTs(ASTs), OutKind(OK_Diag), BindRoot(true), PrintMatcher(false),
+  : ASTs(ASTs), PrintOutput(false), DiagOutput(true),
+DetailedASTOutput(false), BindRoot(true), PrintMatcher(false),
 Terminate(false) {}
 
   llvm::ArrayRef> ASTs;
-  OutputKind OutKind;
+
+  bool PrintOutput;
+  bool DiagOutput;
+  bool DetailedASTOutput;
+
   bool BindRoot;
   bool PrintMatcher;
   bool Terminate;
Index: clang-tools-extra/trunk/clang-query/Query.h
===
--- clang-tools-extra/trunk/clang-query/Query.h
+++ clang-tools-extra/trunk/clang-query/Query.h
@@ -10,6 +10,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_H
 
+#include "QuerySession.h"
 #include "clang/ASTMatchers/Dynamic/VariantValue.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/Optional.h"
@@ -133,6 +134,23 @@
   T Value;
 };
 
+// Implements the exclusive 'set output dump|diag|print' options.
+struct SetExclusiveOutputQuery : Query {
+  SetExclusiveOutputQuery(bool QuerySession::*Var)
+  : Query(QK_SetOutputKind), Var(Var) {}
+  bool run(llvm::raw_ostream , QuerySession ) const override {
+QS.DiagOutput = false;
+QS.DetailedASTOutput = false;
+QS.PrintOutput = false;
+QS.*Var = true;
+return true;
+  }
+
+  static bool classof(const Query *Q) { return Q->Kind == QK_SetOutputKind; }
+
+  bool QuerySession::*Var;
+};
+
 } // namespace query
 } // namespace clang
 
Index: clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp
===
--- clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp
+++ clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp
@@ -83,14 +83,12 @@
 cast(Q)->ErrStr);
 
   Q = parse("set output dump");
-  

[PATCH] D53501: [clang-query] Refactor Output settings to booleans

2018-10-24 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE345194: [clang-query] Refactor Output settings to booleans 
(authored by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53501?vs=170431=170975#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53501

Files:
  clang-query/Query.cpp
  clang-query/Query.h
  clang-query/QueryParser.cpp
  clang-query/QuerySession.h
  unittests/clang-query/QueryEngineTest.cpp
  unittests/clang-query/QueryParserTest.cpp

Index: clang-query/Query.h
===
--- clang-query/Query.h
+++ clang-query/Query.h
@@ -10,6 +10,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_H
 
+#include "QuerySession.h"
 #include "clang/ASTMatchers/Dynamic/VariantValue.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/Optional.h"
@@ -133,6 +134,23 @@
   T Value;
 };
 
+// Implements the exclusive 'set output dump|diag|print' options.
+struct SetExclusiveOutputQuery : Query {
+  SetExclusiveOutputQuery(bool QuerySession::*Var)
+  : Query(QK_SetOutputKind), Var(Var) {}
+  bool run(llvm::raw_ostream , QuerySession ) const override {
+QS.DiagOutput = false;
+QS.DetailedASTOutput = false;
+QS.PrintOutput = false;
+QS.*Var = true;
+return true;
+  }
+
+  static bool classof(const Query *Q) { return Q->Kind == QK_SetOutputKind; }
+
+  bool QuerySession::*Var;
+};
+
 } // namespace query
 } // namespace clang
 
Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -107,8 +107,7 @@
 
   for (auto BI = MI->getMap().begin(), BE = MI->getMap().end(); BI != BE;
++BI) {
-switch (QS.OutKind) {
-case OK_Diag: {
+if (QS.DiagOutput) {
   clang::SourceRange R = BI->second.getSourceRange();
   if (R.isValid()) {
 TextDiagnostic TD(OS, AST->getASTContext().getLangOpts(),
@@ -118,20 +117,16 @@
 DiagnosticsEngine::Note, "\"" + BI->first + "\" binds here",
 CharSourceRange::getTokenRange(R), None);
   }
-  break;
 }
-case OK_Print: {
+if (QS.PrintOutput) {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.print(OS, AST->getASTContext().getPrintingPolicy());
   OS << "\n";
-  break;
 }
-case OK_DetailedAST: {
+if (QS.DetailedASTOutput) {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.dump(OS, AST->getSourceManager());
   OS << "\n";
-  break;
-}
 }
   }
 
Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -119,7 +119,17 @@
 "expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
 "'");
   }
-  return new SetQuery(::OutKind, OutputKind(OutKind));
+
+  switch (OutKind) {
+  case OK_DetailedAST:
+return new SetExclusiveOutputQuery(::DetailedASTOutput);
+  case OK_Diag:
+return new SetExclusiveOutputQuery(::DiagOutput);
+  case OK_Print:
+return new SetExclusiveOutputQuery(::PrintOutput);
+  }
+
+  llvm_unreachable("Invalid output kind");
 }
 
 QueryRef QueryParser::endQuery(QueryRef Q) {
Index: clang-query/QuerySession.h
===
--- clang-query/QuerySession.h
+++ clang-query/QuerySession.h
@@ -25,11 +25,16 @@
 class QuerySession {
 public:
   QuerySession(llvm::ArrayRef> ASTs)
-  : ASTs(ASTs), OutKind(OK_Diag), BindRoot(true), PrintMatcher(false),
+  : ASTs(ASTs), PrintOutput(false), DiagOutput(true),
+DetailedASTOutput(false), BindRoot(true), PrintMatcher(false),
 Terminate(false) {}
 
   llvm::ArrayRef> ASTs;
-  OutputKind OutKind;
+
+  bool PrintOutput;
+  bool DiagOutput;
+  bool DetailedASTOutput;
+
   bool BindRoot;
   bool PrintMatcher;
   bool Terminate;
Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -83,14 +83,12 @@
 cast(Q)->ErrStr);
 
   Q = parse("set output dump");
-  ASSERT_TRUE(isa >(Q));
-  EXPECT_EQ(::OutKind, cast >(Q)->Var);
-  EXPECT_EQ(OK_DetailedAST, cast>(Q)->Value);
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ(::DetailedASTOutput, cast(Q)->Var);
 
   Q = parse("set output detailed-ast");
-  ASSERT_TRUE(isa>(Q));
-  EXPECT_EQ(::OutKind, cast>(Q)->Var);
-  EXPECT_EQ(OK_DetailedAST, cast>(Q)->Value);
+  ASSERT_TRUE(isa(Q));
+  EXPECT_EQ(::DetailedASTOutput, cast(Q)->Var);
 
   Q = parse("set bind-root foo");
   ASSERT_TRUE(isa(Q));
Index: unittests/clang-query/QueryEngineTest.cpp

[PATCH] D53500: Add 'detailed-ast' output as an alias for 'dump'

2018-10-24 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345193: [clang-query] Add detailed-ast output as 
an alias for dump (authored by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53500?vs=170427=170974#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53500

Files:
  clang-tools-extra/trunk/clang-query/Query.cpp
  clang-tools-extra/trunk/clang-query/Query.h
  clang-tools-extra/trunk/clang-query/QueryParser.cpp
  clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp
  clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp

Index: clang-tools-extra/trunk/clang-query/QueryParser.cpp
===
--- clang-tools-extra/trunk/clang-query/QueryParser.cpp
+++ clang-tools-extra/trunk/clang-query/QueryParser.cpp
@@ -111,11 +111,13 @@
   unsigned OutKind = LexOrCompleteWord(this, ValStr)
  .Case("diag", OK_Diag)
  .Case("print", OK_Print)
- .Case("dump", OK_Dump)
+ .Case("detailed-ast", OK_DetailedAST)
+ .Case("dump", OK_DetailedAST)
  .Default(~0u);
   if (OutKind == ~0u) {
-return new InvalidQuery("expected 'diag', 'print' or 'dump', got '" +
-ValStr + "'");
+return new InvalidQuery(
+"expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
+"'");
   }
   return new SetQuery(::OutKind, OutputKind(OutKind));
 }
Index: clang-tools-extra/trunk/clang-query/Query.h
===
--- clang-tools-extra/trunk/clang-query/Query.h
+++ clang-tools-extra/trunk/clang-query/Query.h
@@ -18,7 +18,7 @@
 namespace clang {
 namespace query {
 
-enum OutputKind { OK_Diag, OK_Print, OK_Dump };
+enum OutputKind { OK_Diag, OK_Print, OK_DetailedAST };
 
 enum QueryKind {
   QK_Invalid,
Index: clang-tools-extra/trunk/clang-query/Query.cpp
===
--- clang-tools-extra/trunk/clang-query/Query.cpp
+++ clang-tools-extra/trunk/clang-query/Query.cpp
@@ -53,8 +53,10 @@
 "Pretty-print bound nodes.\n"
 "  diag  "
 "Diagnostic location for bound nodes.\n"
+"  detailed-ast  "
+"Detailed AST output for bound nodes.\n"
 "  dump  "
-"Detailed AST output for bound nodes.\n\n";
+"Detailed AST output for bound nodes (alias of detailed-ast).\n\n";
   return true;
 }
 
@@ -124,7 +126,7 @@
   OS << "\n";
   break;
 }
-case OK_Dump: {
+case OK_DetailedAST: {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.dump(OS, AST->getSourceManager());
   OS << "\n";
Index: clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp
===
--- clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp
+++ clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp
@@ -103,7 +103,8 @@
 
   Str.clear();
 
-  EXPECT_TRUE(SetQuery(::OutKind, OK_Dump).run(OS, S));
+  EXPECT_TRUE(
+  SetQuery(::OutKind, OK_DetailedAST).run(OS, S));
   EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
 
   EXPECT_TRUE(OS.str().find("FunctionDecl") != std::string::npos);
Index: clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp
===
--- clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp
+++ clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp
@@ -70,22 +70,27 @@
 
   Q = parse("set output");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got ''",
+  EXPECT_EQ("expected 'diag', 'print', 'detailed-ast' or 'dump', got ''",
 cast(Q)->ErrStr);
 
   Q = parse("set bind-root true foo");
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unexpected extra input: ' foo'", cast(Q)->ErrStr);
 
   Q = parse("set output foo");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got 'foo'",
+  EXPECT_EQ("expected 'diag', 'print', 'detailed-ast' or 'dump', got 'foo'",
 cast(Q)->ErrStr);
 
   Q = parse("set output dump");
   ASSERT_TRUE(isa >(Q));
   EXPECT_EQ(::OutKind, cast >(Q)->Var);
-  EXPECT_EQ(OK_Dump, cast >(Q)->Value);
+  EXPECT_EQ(OK_DetailedAST, cast>(Q)->Value);
+
+  Q = parse("set output detailed-ast");
+  ASSERT_TRUE(isa>(Q));
+  EXPECT_EQ(::OutKind, cast>(Q)->Var);
+  EXPECT_EQ(OK_DetailedAST, cast>(Q)->Value);
 
   Q = parse("set bind-root foo");
   ASSERT_TRUE(isa(Q));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D53500: Add 'detailed-ast' output as an alias for 'dump'

2018-10-24 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE345193: [clang-query] Add detailed-ast output 
as an alias for dump (authored by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53500?vs=170427=170973#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53500

Files:
  clang-query/Query.cpp
  clang-query/Query.h
  clang-query/QueryParser.cpp
  unittests/clang-query/QueryEngineTest.cpp
  unittests/clang-query/QueryParserTest.cpp

Index: unittests/clang-query/QueryParserTest.cpp
===
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -70,22 +70,27 @@
 
   Q = parse("set output");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got ''",
+  EXPECT_EQ("expected 'diag', 'print', 'detailed-ast' or 'dump', got ''",
 cast(Q)->ErrStr);
 
   Q = parse("set bind-root true foo");
   ASSERT_TRUE(isa(Q));
   EXPECT_EQ("unexpected extra input: ' foo'", cast(Q)->ErrStr);
 
   Q = parse("set output foo");
   ASSERT_TRUE(isa(Q));
-  EXPECT_EQ("expected 'diag', 'print' or 'dump', got 'foo'",
+  EXPECT_EQ("expected 'diag', 'print', 'detailed-ast' or 'dump', got 'foo'",
 cast(Q)->ErrStr);
 
   Q = parse("set output dump");
   ASSERT_TRUE(isa >(Q));
   EXPECT_EQ(::OutKind, cast >(Q)->Var);
-  EXPECT_EQ(OK_Dump, cast >(Q)->Value);
+  EXPECT_EQ(OK_DetailedAST, cast>(Q)->Value);
+
+  Q = parse("set output detailed-ast");
+  ASSERT_TRUE(isa>(Q));
+  EXPECT_EQ(::OutKind, cast>(Q)->Var);
+  EXPECT_EQ(OK_DetailedAST, cast>(Q)->Value);
 
   Q = parse("set bind-root foo");
   ASSERT_TRUE(isa(Q));
Index: unittests/clang-query/QueryEngineTest.cpp
===
--- unittests/clang-query/QueryEngineTest.cpp
+++ unittests/clang-query/QueryEngineTest.cpp
@@ -103,7 +103,8 @@
 
   Str.clear();
 
-  EXPECT_TRUE(SetQuery(::OutKind, OK_Dump).run(OS, S));
+  EXPECT_TRUE(
+  SetQuery(::OutKind, OK_DetailedAST).run(OS, S));
   EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
 
   EXPECT_TRUE(OS.str().find("FunctionDecl") != std::string::npos);
Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -53,8 +53,10 @@
 "Pretty-print bound nodes.\n"
 "  diag  "
 "Diagnostic location for bound nodes.\n"
+"  detailed-ast  "
+"Detailed AST output for bound nodes.\n"
 "  dump  "
-"Detailed AST output for bound nodes.\n\n";
+"Detailed AST output for bound nodes (alias of detailed-ast).\n\n";
   return true;
 }
 
@@ -124,7 +126,7 @@
   OS << "\n";
   break;
 }
-case OK_Dump: {
+case OK_DetailedAST: {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.dump(OS, AST->getSourceManager());
   OS << "\n";
Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -111,11 +111,13 @@
   unsigned OutKind = LexOrCompleteWord(this, ValStr)
  .Case("diag", OK_Diag)
  .Case("print", OK_Print)
- .Case("dump", OK_Dump)
+ .Case("detailed-ast", OK_DetailedAST)
+ .Case("dump", OK_DetailedAST)
  .Default(~0u);
   if (OutKind == ~0u) {
-return new InvalidQuery("expected 'diag', 'print' or 'dump', got '" +
-ValStr + "'");
+return new InvalidQuery(
+"expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
+"'");
   }
   return new SetQuery(::OutKind, OutputKind(OutKind));
 }
Index: clang-query/Query.h
===
--- clang-query/Query.h
+++ clang-query/Query.h
@@ -18,7 +18,7 @@
 namespace clang {
 namespace query {
 
-enum OutputKind { OK_Diag, OK_Print, OK_Dump };
+enum OutputKind { OK_Diag, OK_Print, OK_DetailedAST };
 
 enum QueryKind {
   QK_Invalid,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r345193 - [clang-query] Add 'detailed-ast' output as an alias for 'dump'

2018-10-24 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Oct 24 13:33:45 2018
New Revision: 345193

URL: http://llvm.org/viewvc/llvm-project?rev=345193=rev
Log:
[clang-query] Add 'detailed-ast' output as an alias for 'dump'

Summary: Future development can then dump other content than AST.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-query/Query.cpp
clang-tools-extra/trunk/clang-query/Query.h
clang-tools-extra/trunk/clang-query/QueryParser.cpp
clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp
clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp

Modified: clang-tools-extra/trunk/clang-query/Query.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.cpp?rev=345193=345192=345193=diff
==
--- clang-tools-extra/trunk/clang-query/Query.cpp (original)
+++ clang-tools-extra/trunk/clang-query/Query.cpp Wed Oct 24 13:33:45 2018
@@ -53,8 +53,10 @@ bool HelpQuery::run(llvm::raw_ostream 
 "Pretty-print bound nodes.\n"
 "  diag  "
 "Diagnostic location for bound nodes.\n"
+"  detailed-ast  "
+"Detailed AST output for bound nodes.\n"
 "  dump  "
-"Detailed AST output for bound nodes.\n\n";
+"Detailed AST output for bound nodes (alias of detailed-ast).\n\n";
   return true;
 }
 
@@ -124,7 +126,7 @@ bool MatchQuery::run(llvm::raw_ostream &
   OS << "\n";
   break;
 }
-case OK_Dump: {
+case OK_DetailedAST: {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.dump(OS, AST->getSourceManager());
   OS << "\n";

Modified: clang-tools-extra/trunk/clang-query/Query.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.h?rev=345193=345192=345193=diff
==
--- clang-tools-extra/trunk/clang-query/Query.h (original)
+++ clang-tools-extra/trunk/clang-query/Query.h Wed Oct 24 13:33:45 2018
@@ -18,7 +18,7 @@
 namespace clang {
 namespace query {
 
-enum OutputKind { OK_Diag, OK_Print, OK_Dump };
+enum OutputKind { OK_Diag, OK_Print, OK_DetailedAST };
 
 enum QueryKind {
   QK_Invalid,

Modified: clang-tools-extra/trunk/clang-query/QueryParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QueryParser.cpp?rev=345193=345192=345193=diff
==
--- clang-tools-extra/trunk/clang-query/QueryParser.cpp (original)
+++ clang-tools-extra/trunk/clang-query/QueryParser.cpp Wed Oct 24 13:33:45 2018
@@ -111,11 +111,13 @@ QueryRef QueryParser::parseSetOutputKind
   unsigned OutKind = LexOrCompleteWord(this, ValStr)
  .Case("diag", OK_Diag)
  .Case("print", OK_Print)
- .Case("dump", OK_Dump)
+ .Case("detailed-ast", OK_DetailedAST)
+ .Case("dump", OK_DetailedAST)
  .Default(~0u);
   if (OutKind == ~0u) {
-return new InvalidQuery("expected 'diag', 'print' or 'dump', got '" +
-ValStr + "'");
+return new InvalidQuery(
+"expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
+"'");
   }
   return new SetQuery(::OutKind, OutputKind(OutKind));
 }

Modified: clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp?rev=345193=345192=345193=diff
==
--- clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp Wed Oct 
24 13:33:45 2018
@@ -103,7 +103,8 @@ TEST_F(QueryEngineTest, Basic) {
 
   Str.clear();
 
-  EXPECT_TRUE(SetQuery(::OutKind, OK_Dump).run(OS, 
S));
+  EXPECT_TRUE(
+  SetQuery(::OutKind, OK_DetailedAST).run(OS, S));
   EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
 
   EXPECT_TRUE(OS.str().find("FunctionDecl") != std::string::npos);

Modified: clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp?rev=345193=345192=345193=diff
==
--- clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp Wed Oct 
24 13:33:45 2018
@@ -70,7 +70,7 @@ TEST_F(QueryParserTest, Set) {
 
   Q = parse("set output");
   

[clang-tools-extra] r345194 - [clang-query] Refactor Output settings to booleans

2018-10-24 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Oct 24 13:33:55 2018
New Revision: 345194

URL: http://llvm.org/viewvc/llvm-project?rev=345194=rev
Log:
[clang-query] Refactor Output settings to booleans

Summary: This will make it possible to add non-exclusive mode output.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-query/Query.cpp
clang-tools-extra/trunk/clang-query/Query.h
clang-tools-extra/trunk/clang-query/QueryParser.cpp
clang-tools-extra/trunk/clang-query/QuerySession.h
clang-tools-extra/trunk/unittests/clang-query/QueryEngineTest.cpp
clang-tools-extra/trunk/unittests/clang-query/QueryParserTest.cpp

Modified: clang-tools-extra/trunk/clang-query/Query.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.cpp?rev=345194=345193=345194=diff
==
--- clang-tools-extra/trunk/clang-query/Query.cpp (original)
+++ clang-tools-extra/trunk/clang-query/Query.cpp Wed Oct 24 13:33:55 2018
@@ -107,8 +107,7 @@ bool MatchQuery::run(llvm::raw_ostream &
 
   for (auto BI = MI->getMap().begin(), BE = MI->getMap().end(); BI != BE;
++BI) {
-switch (QS.OutKind) {
-case OK_Diag: {
+if (QS.DiagOutput) {
   clang::SourceRange R = BI->second.getSourceRange();
   if (R.isValid()) {
 TextDiagnostic TD(OS, AST->getASTContext().getLangOpts(),
@@ -118,20 +117,16 @@ bool MatchQuery::run(llvm::raw_ostream &
 DiagnosticsEngine::Note, "\"" + BI->first + "\" binds here",
 CharSourceRange::getTokenRange(R), None);
   }
-  break;
 }
-case OK_Print: {
+if (QS.PrintOutput) {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.print(OS, AST->getASTContext().getPrintingPolicy());
   OS << "\n";
-  break;
 }
-case OK_DetailedAST: {
+if (QS.DetailedASTOutput) {
   OS << "Binding for \"" << BI->first << "\":\n";
   BI->second.dump(OS, AST->getSourceManager());
   OS << "\n";
-  break;
-}
 }
   }
 

Modified: clang-tools-extra/trunk/clang-query/Query.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.h?rev=345194=345193=345194=diff
==
--- clang-tools-extra/trunk/clang-query/Query.h (original)
+++ clang-tools-extra/trunk/clang-query/Query.h Wed Oct 24 13:33:55 2018
@@ -10,6 +10,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_H
 
+#include "QuerySession.h"
 #include "clang/ASTMatchers/Dynamic/VariantValue.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/Optional.h"
@@ -133,6 +134,23 @@ template  struct SetQuery :
   T Value;
 };
 
+// Implements the exclusive 'set output dump|diag|print' options.
+struct SetExclusiveOutputQuery : Query {
+  SetExclusiveOutputQuery(bool QuerySession::*Var)
+  : Query(QK_SetOutputKind), Var(Var) {}
+  bool run(llvm::raw_ostream , QuerySession ) const override {
+QS.DiagOutput = false;
+QS.DetailedASTOutput = false;
+QS.PrintOutput = false;
+QS.*Var = true;
+return true;
+  }
+
+  static bool classof(const Query *Q) { return Q->Kind == QK_SetOutputKind; }
+
+  bool QuerySession::*Var;
+};
+
 } // namespace query
 } // namespace clang
 

Modified: clang-tools-extra/trunk/clang-query/QueryParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QueryParser.cpp?rev=345194=345193=345194=diff
==
--- clang-tools-extra/trunk/clang-query/QueryParser.cpp (original)
+++ clang-tools-extra/trunk/clang-query/QueryParser.cpp Wed Oct 24 13:33:55 2018
@@ -119,7 +119,17 @@ QueryRef QueryParser::parseSetOutputKind
 "expected 'diag', 'print', 'detailed-ast' or 'dump', got '" + ValStr +
 "'");
   }
-  return new SetQuery(::OutKind, OutputKind(OutKind));
+
+  switch (OutKind) {
+  case OK_DetailedAST:
+return new SetExclusiveOutputQuery(::DetailedASTOutput);
+  case OK_Diag:
+return new SetExclusiveOutputQuery(::DiagOutput);
+  case OK_Print:
+return new SetExclusiveOutputQuery(::PrintOutput);
+  }
+
+  llvm_unreachable("Invalid output kind");
 }
 
 QueryRef QueryParser::endQuery(QueryRef Q) {

Modified: clang-tools-extra/trunk/clang-query/QuerySession.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QuerySession.h?rev=345194=345193=345194=diff
==
--- clang-tools-extra/trunk/clang-query/QuerySession.h (original)
+++ clang-tools-extra/trunk/clang-query/QuerySession.h Wed Oct 24 13:33:55 2018
@@ -25,11 +25,16 @@ namespace 

[PATCH] D53498: Re-word command help for clang-query

2018-10-24 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE345192: [clang-query] Re-word command help (authored by 
steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53498?vs=170419=170972#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53498

Files:
  clang-query/Query.cpp


Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -43,12 +43,18 @@
 "Set whether to bind the root matcher to \"root\".\n"
 "  set print-matcher (true|false)"
 "Set whether to print the current matcher,\n"
-"  set output (diag|print|dump)  "
-"Set whether to print bindings as diagnostics,\n"
-""
-"AST pretty prints or AST dumps.\n"
+"  set output   "
+"Set whether to output only  content.\n"
 "  quit, q   "
-"Terminates the query session.\n\n";
+"Terminates the query session.\n\n"
+"Several commands accept a  parameter. The available features 
"
+"are:\n\n"
+"  print "
+"Pretty-print bound nodes.\n"
+"  diag  "
+"Diagnostic location for bound nodes.\n"
+"  dump  "
+"Detailed AST output for bound nodes.\n\n";
   return true;
 }
 


Index: clang-query/Query.cpp
===
--- clang-query/Query.cpp
+++ clang-query/Query.cpp
@@ -43,12 +43,18 @@
 "Set whether to bind the root matcher to \"root\".\n"
 "  set print-matcher (true|false)"
 "Set whether to print the current matcher,\n"
-"  set output (diag|print|dump)  "
-"Set whether to print bindings as diagnostics,\n"
-""
-"AST pretty prints or AST dumps.\n"
+"  set output   "
+"Set whether to output only  content.\n"
 "  quit, q   "
-"Terminates the query session.\n\n";
+"Terminates the query session.\n\n"
+"Several commands accept a  parameter. The available features "
+"are:\n\n"
+"  print "
+"Pretty-print bound nodes.\n"
+"  diag  "
+"Diagnostic location for bound nodes.\n"
+"  dump  "
+"Detailed AST output for bound nodes.\n\n";
   return true;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r345192 - [clang-query] Re-word command help

2018-10-24 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Oct 24 13:33:14 2018
New Revision: 345192

URL: http://llvm.org/viewvc/llvm-project?rev=345192=rev
Log:
[clang-query] Re-word command help

Summary:
This will make it possible to easily

* Add new commands which accept  parameters
* Extend the list of features

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-query/Query.cpp

Modified: clang-tools-extra/trunk/clang-query/Query.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/Query.cpp?rev=345192=345191=345192=diff
==
--- clang-tools-extra/trunk/clang-query/Query.cpp (original)
+++ clang-tools-extra/trunk/clang-query/Query.cpp Wed Oct 24 13:33:14 2018
@@ -43,12 +43,18 @@ bool HelpQuery::run(llvm::raw_ostream 
 "Set whether to bind the root matcher to \"root\".\n"
 "  set print-matcher (true|false)"
 "Set whether to print the current matcher,\n"
-"  set output (diag|print|dump)  "
-"Set whether to print bindings as diagnostics,\n"
-""
-"AST pretty prints or AST dumps.\n"
+"  set output   "
+"Set whether to output only  content.\n"
 "  quit, q   "
-"Terminates the query session.\n\n";
+"Terminates the query session.\n\n"
+"Several commands accept a  parameter. The available features 
"
+"are:\n\n"
+"  print "
+"Pretty-print bound nodes.\n"
+"  diag  "
+"Diagnostic location for bound nodes.\n"
+"  dump  "
+"Detailed AST output for bound nodes.\n\n";
   return true;
 }
 


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


[PATCH] D53608: [builtins] Build float128 soft float builtins for x86_64.

2018-10-24 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Took another look and seems like long double is hardcoded in many of the 
builtins. So I think the current patch needs to rename a lot of places using 
long double to __float128 type.

Some examples where I think __float128 type (propagating the type in fp_lib.h) 
should be used instead of long double:

./extenddftf2.c:  COMPILER_RT_ABI long double __extenddftf2(double a) {
./trunctfsf2.c:  COMPILER_RT_ABI float __trunctfsf2(long double a) {
./extendsftf2.c:  COMPILER_RT_ABI long double __extendsftf2(float a) {

@efriedma what do you think?


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D53608



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


[clang-tools-extra] r345191 - [clant-tidy] abseil: Add clangTooling to CMakeLists.txt

2018-10-24 Thread Heejin Ahn via cfe-commits
Author: aheejin
Date: Wed Oct 24 13:31:58 2018
New Revision: 345191

URL: http://llvm.org/viewvc/llvm-project?rev=345191=rev
Log:
[clant-tidy] abseil: Add clangTooling to CMakeLists.txt

Without this, builds with `-DBUILD_SHARED_LIBS=ON` fail.

Modified:
clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt?rev=345191=345190=345191=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt Wed Oct 24 
13:31:58 2018
@@ -18,4 +18,5 @@ add_clang_library(clangTidyAbseilModule
   clangLex
   clangTidy
   clangTidyUtils
+  clangTooling
   )


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


[PATCH] D53666: [Tests] Updated tests for D53342

2018-10-24 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 170963.

https://reviews.llvm.org/D53666

Files:
  test/CodeGen/tbaa-struct.cpp


Index: test/CodeGen/tbaa-struct.cpp
===
--- test/CodeGen/tbaa-struct.cpp
+++ test/CodeGen/tbaa-struct.cpp
@@ -17,7 +17,7 @@
 
 void copy(A *a1, A *a2) {
 // CHECK-LABEL: _Z4copyP1AS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 
4 %{{.*}}, i64 16, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %{{.*}}, 
i8* nonnull align 4 %{{.*}}, i64 16, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_A:![0-9]*]]
   *a1 = *a2;
@@ -31,7 +31,7 @@
 
 void copy2(B *b1, B *b2) {
 // CHECK-LABEL: _Z5copy2P1BS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 
4 %{{.*}}, i64 24, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %{{.*}}, 
i8* nonnull align 4 %{{.*}}, i64 24, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS2:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_B:![0-9]*]]
   *b1 = *b2;
@@ -49,7 +49,7 @@
 
 void copy3(U *u1, U *u2) {
 // CHECK-LABEL: _Z5copy3P1US0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 
4 %{{.*}}, i64 12, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %{{.*}}, 
i8* nonnull align 4 %{{.*}}, i64 12, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS3:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_U:![0-9]*]]
   *u1 = *u2;
@@ -65,7 +65,7 @@
 
 void copy4(C *c1, C *c2) {
 // CHECK-LABEL: _Z5copy4P1CS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 3, 
i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull {{.*}}, i8* nonnull 
{{.*}}, i64 3, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS4:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_C:![0-9]*]]
   *c1 = *c2;
@@ -80,23 +80,23 @@
 
 void copy5(D *d1, D *d2) {
 // CHECK-LABEL: _Z5copy5P1DS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 6, 
i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull {{.*}}, i8* nonnull 
{{.*}}, i64 6, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS5:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_D:![0-9]*]]
   *d1 = *d2;
 }
 
 void copy6(AA *a1, A *a2) {
 // CHECK-LABEL: _Z5copy6P1AS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 
4 %{{.*}}, i64 16, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %{{.*}}, 
i8* nonnull align 4 %{{.*}}, i64 16, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS]]
 // CHECK-NEW-SAME: !tbaa [[TAG_char:![0-9]*]]
   *a1 = *a2;
 }
 
 void copy7(A *a1, AA *a2) {
 // CHECK-LABEL: _Z5copy7P1AS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 
4 %{{.*}}, i64 16, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %{{.*}}, 
i8* nonnull align 4 %{{.*}}, i64 16, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS]]
 // CHECK-NEW-SAME: !tbaa [[TAG_char]]
   *a1 = *a2;


Index: test/CodeGen/tbaa-struct.cpp
===
--- test/CodeGen/tbaa-struct.cpp
+++ test/CodeGen/tbaa-struct.cpp
@@ -17,7 +17,7 @@
 
 void copy(A *a1, A *a2) {
 // CHECK-LABEL: _Z4copyP1AS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i64 16, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %{{.*}}, i8* nonnull align 4 %{{.*}}, i64 16, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_A:![0-9]*]]
   *a1 = *a2;
@@ -31,7 +31,7 @@
 
 void copy2(B *b1, B *b2) {
 // CHECK-LABEL: _Z5copy2P1BS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i64 24, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %{{.*}}, i8* nonnull align 4 %{{.*}}, i64 24, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS2:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_B:![0-9]*]]
   *b1 = *b2;
@@ -49,7 +49,7 @@
 
 void copy3(U *u1, U *u2) {
 // CHECK-LABEL: _Z5copy3P1US0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i64 12, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %{{.*}}, i8* nonnull align 4 %{{.*}}, i64 12, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS3:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_U:![0-9]*]]
   *u1 = *u2;
@@ -65,7 +65,7 @@
 
 void copy4(C *c1, C *c2) {
 // CHECK-LABEL: _Z5copy4P1CS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 3, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull {{.*}}, i8* nonnull {{.*}}, i64 3, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS4:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_C:![0-9]*]]
   *c1 = *c2;
@@ -80,23 +80,23 @@
 
 void copy5(D *d1, D *d2) {
 // CHECK-LABEL: _Z5copy5P1DS0_
-// CHECK: call void 

[PATCH] D53666: [Tests] Updated tests for D53342

2018-10-24 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: test/CodeGenOpenCL/amdgpu-nullptr.cl:513
 // CHECK-LABEL: test_memset_private
-// CHECK: call void @llvm.memset.p5i8.i64(i8 addrspace(5)* align 8 {{.*}}, i8 
0, i64 40, i1 false)
+// CHECK: call void @llvm.memset.p5i8.i64(i8 addrspace(5)* nonnull align 8 
{{.*}}, i8 0, i64 40, i1 false)
 void test_memset_private(private StructTy3 *ptr) {

efriedma wrote:
> This shouldn't change.  "null" pointers are potentially valid in non-zero 
> address-spaces.  (Sorry, I should have spotted this sooner.)
Thanks, I will fix this case.


Repository:
  rC Clang

https://reviews.llvm.org/D53666



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


[PATCH] D53666: [Tests] Updated tests for D53342

2018-10-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: test/CodeGenOpenCL/amdgpu-nullptr.cl:513
 // CHECK-LABEL: test_memset_private
-// CHECK: call void @llvm.memset.p5i8.i64(i8 addrspace(5)* align 8 {{.*}}, i8 
0, i64 40, i1 false)
+// CHECK: call void @llvm.memset.p5i8.i64(i8 addrspace(5)* nonnull align 8 
{{.*}}, i8 0, i64 40, i1 false)
 void test_memset_private(private StructTy3 *ptr) {

This shouldn't change.  "null" pointers are potentially valid in non-zero 
address-spaces.  (Sorry, I should have spotted this sooner.)


Repository:
  rC Clang

https://reviews.llvm.org/D53666



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


[PATCH] D53223: AMDGPU: Add sram-ecc feature options

2018-10-24 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

ping


https://reviews.llvm.org/D53223



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


[PATCH] D53666: [Tests] Updated tests for D53342

2018-10-24 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 created this revision.
Herald added subscribers: cfe-commits, nhaehnle, jvesely.

Repository:
  rC Clang

https://reviews.llvm.org/D53666

Files:
  test/CodeGen/tbaa-struct.cpp
  test/CodeGenOpenCL/amdgpu-nullptr.cl


Index: test/CodeGenOpenCL/amdgpu-nullptr.cl
===
--- test/CodeGenOpenCL/amdgpu-nullptr.cl
+++ test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -510,7 +510,7 @@
 } StructTy3;
 
 // CHECK-LABEL: test_memset_private
-// CHECK: call void @llvm.memset.p5i8.i64(i8 addrspace(5)* align 8 {{.*}}, i8 
0, i64 40, i1 false)
+// CHECK: call void @llvm.memset.p5i8.i64(i8 addrspace(5)* nonnull align 8 
{{.*}}, i8 0, i64 40, i1 false)
 void test_memset_private(private StructTy3 *ptr) {
   StructTy3 S3 = {0, 0, 0, 0, 0};
   *ptr = S3;
Index: test/CodeGen/tbaa-struct.cpp
===
--- test/CodeGen/tbaa-struct.cpp
+++ test/CodeGen/tbaa-struct.cpp
@@ -17,7 +17,7 @@
 
 void copy(A *a1, A *a2) {
 // CHECK-LABEL: _Z4copyP1AS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 
4 %{{.*}}, i64 16, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %{{.*}}, 
i8* nonnull align 4 %{{.*}}, i64 16, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_A:![0-9]*]]
   *a1 = *a2;
@@ -31,7 +31,7 @@
 
 void copy2(B *b1, B *b2) {
 // CHECK-LABEL: _Z5copy2P1BS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 
4 %{{.*}}, i64 24, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %{{.*}}, 
i8* nonnull align 4 %{{.*}}, i64 24, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS2:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_B:![0-9]*]]
   *b1 = *b2;
@@ -49,7 +49,7 @@
 
 void copy3(U *u1, U *u2) {
 // CHECK-LABEL: _Z5copy3P1US0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 
4 %{{.*}}, i64 12, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %{{.*}}, 
i8* nonnull align 4 %{{.*}}, i64 12, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS3:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_U:![0-9]*]]
   *u1 = *u2;
@@ -65,7 +65,7 @@
 
 void copy4(C *c1, C *c2) {
 // CHECK-LABEL: _Z5copy4P1CS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 3, 
i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull {{.*}}, i8* nonnull 
{{.*}}, i64 3, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS4:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_C:![0-9]*]]
   *c1 = *c2;
@@ -80,23 +80,23 @@
 
 void copy5(D *d1, D *d2) {
 // CHECK-LABEL: _Z5copy5P1DS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 6, 
i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull {{.*}}, i8* nonnull 
{{.*}}, i64 6, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS5:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_D:![0-9]*]]
   *d1 = *d2;
 }
 
 void copy6(AA *a1, A *a2) {
 // CHECK-LABEL: _Z5copy6P1AS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 
4 %{{.*}}, i64 16, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %{{.*}}, 
i8* nonnull align 4 %{{.*}}, i64 16, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS]]
 // CHECK-NEW-SAME: !tbaa [[TAG_char:![0-9]*]]
   *a1 = *a2;
 }
 
 void copy7(A *a1, AA *a2) {
 // CHECK-LABEL: _Z5copy7P1AS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 
4 %{{.*}}, i64 16, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %{{.*}}, 
i8* nonnull align 4 %{{.*}}, i64 16, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS]]
 // CHECK-NEW-SAME: !tbaa [[TAG_char]]
   *a1 = *a2;


Index: test/CodeGenOpenCL/amdgpu-nullptr.cl
===
--- test/CodeGenOpenCL/amdgpu-nullptr.cl
+++ test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -510,7 +510,7 @@
 } StructTy3;
 
 // CHECK-LABEL: test_memset_private
-// CHECK: call void @llvm.memset.p5i8.i64(i8 addrspace(5)* align 8 {{.*}}, i8 0, i64 40, i1 false)
+// CHECK: call void @llvm.memset.p5i8.i64(i8 addrspace(5)* nonnull align 8 {{.*}}, i8 0, i64 40, i1 false)
 void test_memset_private(private StructTy3 *ptr) {
   StructTy3 S3 = {0, 0, 0, 0, 0};
   *ptr = S3;
Index: test/CodeGen/tbaa-struct.cpp
===
--- test/CodeGen/tbaa-struct.cpp
+++ test/CodeGen/tbaa-struct.cpp
@@ -17,7 +17,7 @@
 
 void copy(A *a1, A *a2) {
 // CHECK-LABEL: _Z4copyP1AS0_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i64 16, i1 false)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %{{.*}}, i8* nonnull align 4 %{{.*}}, i64 16, i1 false)
 // CHECK-OLD-SAME: !tbaa.struct [[TS:!.*]]
 // CHECK-NEW-SAME: !tbaa [[TAG_A:![0-9]*]]
   *a1 = *a2;
@@ -31,7 +31,7 @@
 
 void copy2(B *b1, B *b2) {
 // 

[clang-tools-extra] r345184 - Fix MSVC "truncation from 'double' to 'float'" warnings. NFCI.

2018-10-24 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Wed Oct 24 12:31:24 2018
New Revision: 345184

URL: http://llvm.org/viewvc/llvm-project?rev=345184=rev
Log:
Fix MSVC "truncation from 'double' to 'float'" warnings. NFCI.

Modified:
clang-tools-extra/trunk/clangd/Quality.cpp

Modified: clang-tools-extra/trunk/clangd/Quality.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Quality.cpp?rev=345184=345183=345184=diff
==
--- clang-tools-extra/trunk/clangd/Quality.cpp (original)
+++ clang-tools-extra/trunk/clangd/Quality.cpp Wed Oct 24 12:31:24 2018
@@ -373,15 +373,15 @@ float SymbolRelevanceSignals::evaluate()
   if (!IsInstanceMember &&
   (Context == CodeCompletionContext::CCC_DotMemberAccess ||
Context == CodeCompletionContext::CCC_ArrowMemberAccess)) {
-Score *= 0.2;
+Score *= 0.2f;
   }
 
   if (InBaseClass)
-Score *= 0.5;
+Score *= 0.5f;
 
   // Penalize for FixIts.
   if (NeedsFixIts)
-Score *= 0.5;
+Score *= 0.5f;
 
   return Score;
 }


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


[PATCH] D50250: [clang][ubsan] Implicit Conversion Sanitizer - integer sign change - clang part

2018-10-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 170952.
lebedev.ri marked 4 inline comments as done.
lebedev.ri added a comment.

In https://reviews.llvm.org/D50250#1273415, @rsmith wrote:

> Just some minor nits.


YES! Thank you for the [long-awaited] review!

Addressed review notes.
The compiler-rt part https://reviews.llvm.org/D50251 still needs a review 
before this can finally go in.

There is now a problem with `SanitizerOrdinal` - it's out of bits :)
After this, there isn't a single bit available.
I even had to drop one new sanitizer group that wasn't *strictly* needed just 
yet.
I should probably file a bug so this knowledge will not be lost.


Repository:
  rC Clang

https://reviews.llvm.org/D50250

Files:
  docs/ReleaseNotes.rst
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Basic/Sanitizers.def
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/catch-implicit-conversions-basics.c
  test/CodeGen/catch-implicit-integer-arithmetic-value-change-basics.c
  test/CodeGen/catch-implicit-integer-conversions-basics.c
  test/CodeGen/catch-implicit-integer-sign-changes-basics.c
  test/CodeGen/catch-implicit-integer-sign-changes-true-negatives.c
  test/CodeGen/catch-implicit-integer-sign-changes.c
  test/CodeGen/catch-implicit-signed-integer-truncation-or-sign-change.c
  test/CodeGenCXX/catch-implicit-integer-sign-changes-true-negatives.cpp
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -31,22 +31,37 @@
 // CHECK-COVERAGE-WIN64: "--dependent-lib={{[^"]*}}ubsan_standalone-x86_64.lib"
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=integer %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INTEGER -implicit-check-not="-fsanitize-address-use-after-scope"
-// CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){7}"}}
+// CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|implicit-unsigned-integer-truncation|implicit-signed-integer-truncation|implicit-integer-sign-change),?){8}"}}
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-RECOVER
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion -fsanitize-recover=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-RECOVER
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion -fno-sanitize-recover=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-NORECOVER
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion -fsanitize-trap=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-TRAP
-// CHECK-implicit-conversion: "-fsanitize={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
-// CHECK-implicit-conversion-RECOVER: "-fsanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
-// CHECK-implicit-conversion-RECOVER-NOT: "-fno-sanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
-// CHECK-implicit-conversion-RECOVER-NOT: "-fsanitize-trap={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
-// CHECK-implicit-conversion-NORECOVER-NOT: "-fno-sanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}} // ???
-// CHECK-implicit-conversion-NORECOVER-NOT: "-fsanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
-// CHECK-implicit-conversion-NORECOVER-NOT: "-fsanitize-trap={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
-// CHECK-implicit-conversion-TRAP: "-fsanitize-trap={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
-// CHECK-implicit-conversion-TRAP-NOT: "-fsanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
-// CHECK-implicit-conversion-TRAP-NOT: "-fno-sanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion: "-fsanitize={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation|implicit-integer-sign-change),?){3}"}}
+// CHECK-implicit-conversion-RECOVER: "-fsanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation|implicit-integer-sign-change),?){3}"}}
+// CHECK-implicit-conversion-RECOVER-NOT: 

[PATCH] D50250: [clang][ubsan] Implicit Conversion Sanitizer - integer sign change - clang part

2018-10-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: lib/CodeGen/CGExprScalar.cpp:1036
+return;
+  // That's it. We can't rule out any more cases with the data we have.
+

rsmith wrote:
> lebedev.ri wrote:
> > rsmith wrote:
> > > rsmith wrote:
> > > > lebedev.ri wrote:
> > > > > rsmith wrote:
> > > > > > I don't like the overlap between the implicit truncation check and 
> > > > > > this check. I think you should aim for exactly one of those checks 
> > > > > > to fire for any given integer conversion. There are the following 
> > > > > > cases:
> > > > > > 
> > > > > >  * Dst is smaller than Src: if the value changes at all (with sign 
> > > > > > change or without), then the truncation check already catches it, 
> > > > > > and catching it here does not seem useful
> > > > > >  * Dst is the same size as Src or larger: sign change is the only 
> > > > > > problem, and is only possible if exactly one of Src and Dst is 
> > > > > > signed
> > > > > > 
> > > > > > So I think you should bail out of this function if either Src and 
> > > > > > Dst are both unsigned or both are signed, and also if Src is larger 
> > > > > > than Dst (because we treat that case as a lossy truncation rather 
> > > > > > than as a sign change).
> > > > > > 
> > > > > > And when you do emit a check here, the only thing you need to check 
> > > > > > is if the signed value is negative (if so, you definitely changed 
> > > > > > the sign, and if not, you definitely didn't -- except in the 
> > > > > > truncation cases that the truncation sanitizer catches).
> > > > > To be clear: we want to skip emitting in those cases if the other 
> > > > > check (truncation) is enabled, right?
> > > > > It does seem to make sense, (and i did thought about that a bit), but 
> > > > > i need to think about it more..
> > > > I think we want to skip emitting those checks always (regardless of 
> > > > whether the other sanitizer is enabled). One way to think of it: this 
> > > > sanitizer checks for non-truncating implicit integer conversions that 
> > > > change the value of the result. The other sanitizer checks for 
> > > > truncating implicit integer conversions that change the value of the 
> > > > result.
> > > > 
> > > > I don't see any point in allowing the user to ask to sanitize 
> > > > sign-changing truncation but not other value-changing truncations. That 
> > > > would lead to this:
> > > > ```
> > > > int a = 0x17fff; // no sanitizer warning
> > > > int b = 0x18000; // sanitizer warning
> > > > int c = 0x1; // sanitizer warning
> > > > int d = 0x2; // no sanitizer warning
> > > > ```
> > > > ... which I think makes no sense.
> > > Hmm, wait, the "truncation" sanitizer doesn't catch this:
> > > 
> > > `int a = 0x8000u;`
> > > 
> > > ... does it? (Because it looks for cases where the value doesn't 
> > > round-trip, not for cases where the value was changed by the truncation.)
> > > 
> > > 
> > > I've thought a bit more about the user model and use cases for these 
> > > sanitizers, and I think what we want is:
> > > 
> > >  * a sanitizer that checks for implicit conversions with data loss (the 
> > > existing truncation sanitizer)
> > >  * a sanitizer that checks for implicit conversions that change the 
> > > value, where either the source or destination was signed (approximately 
> > > what this sanitizer is doing)
> > > 
> > > The difference between that and what you have here is that I think the 
> > > new sanitizer should catch all of these cases:
> > > 
> > > ```
> > > int a = 0x17fff;
> > > int b = 0x18000;
> > > int c = 0x1;
> > > int d = 0x2;
> > > ```
> > > 
> > > ... because while the initializations of `a` and `d` don't change the 
> > > sign of the result, that's only because they wrap around *past* a sign 
> > > change.
> > > 
> > > So, I think what you have here is fine for the SrcBits <= DstBits case, 
> > > but for the SrcBits > DstBits case, you should also check whether the 
> > > value is the same as the original (that is, perform the truncation check).
> > > 
> > > In order to avoid duplicating work when both sanitizers are enabled, it'd 
> > > make sense to combine the two sanitizer functions into a single function 
> > > and reuse the checks.
> > Yep, makes sense. I don't think i have followed the recommendations to the 
> > letter,
> > but i think the end result is not worse than suggested. Added tests shows 
> > how it works now.
> OK, so to be clear I'm following:
> 
>  * Any implicit conversion that truncates and changes the value triggers the 
> truncation sanitizer (unsigned if both source and destination are unsigned, 
> signed otherwise)
>  * Any implicit conversion that results in a sign change triggers the sign 
> change sanitizer
>  * Any implicit conversion that triggers both sanitizers produces a single 
> warning classified as ICCK_SignedIntegerTruncationOrSignChange (eg, the 
> truncation changed the value, and the 

[PATCH] D50251: [compiler-rt][ubsan] Implicit Conversion Sanitizer - integer sign change - compiler-rt part

2018-10-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 170953.
lebedev.ri added a comment.
Herald added a subscriber: cfe-commits.

Rebased.
The clang part https://reviews.llvm.org/D50250 finally got reviewed, so i'm 
wondering if someone could review this, please? :)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50251

Files:
  lib/ubsan/ubsan_checks.inc
  lib/ubsan/ubsan_handlers.cc
  lib/ubsan/ubsan_handlers.h
  test/fuzzer/ImplicitIntegerSignChangeTest.cpp
  test/fuzzer/ImplicitSignedIntegerTruncationOrSignChangeTest.cpp
  test/fuzzer/fuzzer-implicit-integer-sign-change.test
  test/fuzzer/fuzzer-implicit-signed-integer-truncation-or-sign-change.test
  test/ubsan/TestCases/ImplicitConversion/integer-arithmetic-value-change.c
  test/ubsan/TestCases/ImplicitConversion/integer-conversion.c
  test/ubsan/TestCases/ImplicitConversion/integer-sign-change-blacklist.c
  test/ubsan/TestCases/ImplicitConversion/integer-sign-change-summary.cpp
  test/ubsan/TestCases/ImplicitConversion/integer-sign-change.c
  
test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-blacklist.c
  
test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-summary.cpp
  test/ubsan_minimal/TestCases/implicit-integer-sign-change.c
  
test/ubsan_minimal/TestCases/implicit-signed-integer-truncation-or-sign-change.c

Index: test/ubsan_minimal/TestCases/implicit-signed-integer-truncation-or-sign-change.c
===
--- /dev/null
+++ test/ubsan_minimal/TestCases/implicit-signed-integer-truncation-or-sign-change.c
@@ -0,0 +1,17 @@
+// RUN: %clang -fsanitize=implicit-signed-integer-truncation,implicit-integer-sign-change %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+
+#include 
+
+int main() {
+// CHECK-NOT: implicit-conversion
+
+  // Explicitly casting hides it,
+  int8_t n0 = (int8_t)((uint32_t)-1);
+
+  // Positive tests.
+  int8_t t0 = (uint32_t)-1;
+// CHECK: implicit-conversion
+// CHECK-NOT: implicit-conversion
+
+  return 0;
+}
Index: test/ubsan_minimal/TestCases/implicit-integer-sign-change.c
===
--- /dev/null
+++ test/ubsan_minimal/TestCases/implicit-integer-sign-change.c
@@ -0,0 +1,17 @@
+// RUN: %clang -fsanitize=implicit-integer-sign-change %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+
+#include 
+
+int main() {
+// CHECK-NOT: implicit-conversion
+
+  // Explicitly casting hides it,
+  int32_t n0 = (int32_t)(~((uint32_t)0));
+
+  // Positive tests.
+  int32_t t0 = (~((uint32_t)0));
+// CHECK: implicit-conversion
+// CHECK-NOT: implicit-conversion
+
+  return 0;
+}
Index: test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-summary.cpp
===
--- /dev/null
+++ test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-summary.cpp
@@ -0,0 +1,13 @@
+// RUN: %clangxx -fsanitize=implicit-signed-integer-truncation,implicit-integer-sign-change %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NOTYPE
+// RUN: %env_ubsan_opts=report_error_type=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-TYPE
+// REQUIRES: !ubsan-standalone && !ubsan-standalone-static
+
+#include 
+
+int main() {
+  int8_t t0 = (~(uint32_t(0)));
+  // CHECK-NOTYPE: SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior {{.*}}summary.cpp:[[@LINE-1]]:15
+  // CHECK-TYPE: SUMMARY: UndefinedBehaviorSanitizer: implicit-signed-integer-truncation-or-sign-change {{.*}}summary.cpp:[[@LINE-2]]:15
+  return 0;
+}
Index: test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-blacklist.c
===
--- /dev/null
+++ test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-blacklist.c
@@ -0,0 +1,56 @@
+// FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316
+// I'm not sure this is actually *that* issue, but this seems oddly similar to the other XFAIL'ed cases.
+// XFAIL: android
+// UNSUPPORTED: ios
+
+// All of these don't actually silence it:
+
+// RUN: %clang -fsanitize=implicit-signed-integer-truncation,implicit-integer-sign-change -fno-sanitize-recover=implicit-signed-integer-truncation,implicit-integer-sign-change   -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion"
+// RUN: %clang -fsanitize=implicit-signed-integer-truncation,implicit-integer-sign-change -fno-sanitize-recover=implicit-signed-integer-truncation,implicit-integer-sign-change   -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion"
+// RUN: %clang -fsanitize=implicit-signed-integer-truncation,implicit-integer-sign-change -fno-sanitize-recover=implicit-signed-integer-truncation,implicit-integer-sign-change  

[PATCH] D53558: Add gfx909 to GPU Arch

2018-10-24 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

In https://reviews.llvm.org/D53558#1272673, @kzhuravl wrote:

> Are changes for 
> https://github.com/llvm-mirror/clang/blob/master/lib/Basic/Targets/AMDGPU.cpp#L137
>  in a separate review? (I could not locate it).


https://reviews.llvm.org/rC345181


Repository:
  rC Clang

https://reviews.llvm.org/D53558



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


r345181 - AMDGPU: Handle gfx909 in AMDGPUTargetInfo::initFeatureMap

2018-10-24 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Wed Oct 24 12:07:56 2018
New Revision: 345181

URL: http://llvm.org/viewvc/llvm-project?rev=345181=rev
Log:
AMDGPU: Handle gfx909 in AMDGPUTargetInfo::initFeatureMap

+ add required tests

Modified:
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/test/Driver/amdgpu-macros.cl
cfe/trunk/test/Driver/amdgpu-mcpu.cl

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=345181=345180=345181=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Wed Oct 24 12:07:56 2018
@@ -138,6 +138,7 @@ bool AMDGPUTargetInfo::initFeatureMap(
 case GK_GFX906:
   Features["dl-insts"] = true;
   LLVM_FALLTHROUGH;
+case GK_GFX909:
 case GK_GFX904:
 case GK_GFX902:
 case GK_GFX900:

Modified: cfe/trunk/test/Driver/amdgpu-macros.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-macros.cl?rev=345181=345180=345181=diff
==
--- cfe/trunk/test/Driver/amdgpu-macros.cl (original)
+++ cfe/trunk/test/Driver/amdgpu-macros.cl Wed Oct 24 12:07:56 2018
@@ -175,6 +175,7 @@
 // RUN: %clang -E -dM -target amdgcn -mcpu=gfx902 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX902 %s
 // RUN: %clang -E -dM -target amdgcn -mcpu=gfx904 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX904 %s
 // RUN: %clang -E -dM -target amdgcn -mcpu=gfx906 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX906 %s
+// RUN: %clang -E -dM -target amdgcn -mcpu=gfx909 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX909 %s
 
 // GFX600-DAG: #define FP_FAST_FMA 1
 // GFX601-DAG: #define FP_FAST_FMA 1
@@ -191,6 +192,7 @@
 // GFX902-DAG: #define FP_FAST_FMA 1
 // GFX904-DAG: #define FP_FAST_FMA 1
 // GFX906-DAG: #define FP_FAST_FMA 1
+// GFX909-DAG: #define FP_FAST_FMA 1
 
 // GFX600-DAG: #define FP_FAST_FMAF 1
 // GFX601-NOT: #define FP_FAST_FMAF 1
@@ -207,6 +209,7 @@
 // GFX902-DAG: #define FP_FAST_FMAF 1
 // GFX904-DAG: #define FP_FAST_FMAF 1
 // GFX906-DAG: #define FP_FAST_FMAF 1
+// GFX909-DAG: #define FP_FAST_FMAF 1
 
 // ARCH-GCN-DAG: #define __AMDGCN__ 1
 // ARCH-GCN-DAG: #define __AMDGPU__ 1
@@ -227,6 +230,7 @@
 // GFX902-DAG: #define __HAS_FMAF__ 1
 // GFX904-DAG: #define __HAS_FMAF__ 1
 // GFX906-DAG: #define __HAS_FMAF__ 1
+// GFX909-DAG: #define __HAS_FMAF__ 1
 
 // GFX600-DAG: #define __HAS_FP64__ 1
 // GFX601-DAG: #define __HAS_FP64__ 1
@@ -243,6 +247,7 @@
 // GFX902-DAG: #define __HAS_FP64__ 1
 // GFX904-DAG: #define __HAS_FP64__ 1
 // GFX906-DAG: #define __HAS_FP64__ 1
+// GFX909-DAG: #define __HAS_FP64__ 1
 
 // GFX600-DAG: #define __HAS_LDEXPF__ 1
 // GFX601-DAG: #define __HAS_LDEXPF__ 1
@@ -259,6 +264,7 @@
 // GFX902-DAG: #define __HAS_LDEXPF__ 1
 // GFX904-DAG: #define __HAS_LDEXPF__ 1
 // GFX906-DAG: #define __HAS_LDEXPF__ 1
+// GFX909-DAG: #define __HAS_LDEXPF__ 1
 
 // GFX600-DAG: #define __gfx600__ 1
 // GFX601-DAG: #define __gfx601__ 1
@@ -275,3 +281,4 @@
 // GFX902-DAG: #define __gfx902__ 1
 // GFX904-DAG: #define __gfx904__ 1
 // GFX906-DAG: #define __gfx906__ 1
+// GFX909-DAG: #define __gfx909__ 1

Modified: cfe/trunk/test/Driver/amdgpu-mcpu.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-mcpu.cl?rev=345181=345180=345181=diff
==
--- cfe/trunk/test/Driver/amdgpu-mcpu.cl (original)
+++ cfe/trunk/test/Driver/amdgpu-mcpu.cl Wed Oct 24 12:07:56 2018
@@ -84,6 +84,7 @@
 // RUN: %clang -### -target amdgcn -mcpu=gfx902 %s 2>&1 | FileCheck 
--check-prefix=GFX902 %s
 // RUN: %clang -### -target amdgcn -mcpu=gfx904 %s 2>&1 | FileCheck 
--check-prefix=GFX904 %s
 // RUN: %clang -### -target amdgcn -mcpu=gfx906 %s 2>&1 | FileCheck 
--check-prefix=GFX906 %s
+// RUN: %clang -### -target amdgcn -mcpu=gfx909 %s 2>&1 | FileCheck 
--check-prefix=GFX909 %s
 
 // GFX600:"-target-cpu" "gfx600"
 // TAHITI:"-target-cpu" "tahiti"
@@ -117,3 +118,4 @@
 // GFX902:"-target-cpu" "gfx902"
 // GFX904:"-target-cpu" "gfx904"
 // GFX906:"-target-cpu" "gfx906"
+// GFX909:"-target-cpu" "gfx909"


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


[PATCH] D53636: Do not always request an implicit taskgroup region inside the kmpc_taskloop function

2018-10-24 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC345180: Do not always request an implicit taskgroup region 
inside the kmpc_taskloop… (authored by ABataev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D53636

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  test/OpenMP/taskloop_codegen.cpp
  test/OpenMP/taskloop_firstprivate_codegen.cpp
  test/OpenMP/taskloop_lastprivate_codegen.cpp
  test/OpenMP/taskloop_private_codegen.cpp
  test/OpenMP/taskloop_reduction_codegen.cpp
  test/OpenMP/taskloop_simd_codegen.cpp
  test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
  test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
  test/OpenMP/taskloop_simd_private_codegen.cpp
  test/OpenMP/taskloop_simd_reduction_codegen.cpp

Index: test/OpenMP/taskloop_simd_private_codegen.cpp
===
--- test/OpenMP/taskloop_simd_private_codegen.cpp
+++ test/OpenMP/taskloop_simd_private_codegen.cpp
@@ -65,7 +65,7 @@
   // LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](
   // LAMBDA: [[RES:%.+]] = call i8* @__kmpc_omp_task_alloc(%{{[^ ]+}} @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i64 96, i64 1, i32 (i32, i8*)* bitcast (i32 (i32, %{{[^*]+}}*)* [[TASK_ENTRY:@[^ ]+]] to i32 (i32, i8*)*))
 // LAMBDA: [[PRIVATES:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i{{.+}} 0, i{{.+}} 1
-// LAMBDA: call void @__kmpc_taskloop(%{{.+}}* @{{.+}}, i32 %{{.+}}, i8* [[RES]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 0, i32 0, i64 0, i8* null)
+// LAMBDA: call void @__kmpc_taskloop(%{{.+}}* @{{.+}}, i32 %{{.+}}, i8* [[RES]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, i8* null)
 // LAMBDA: ret
 #pragma omp taskloop simd private(g, sivar)
   for (int i = 0; i < 10; ++i) {
@@ -101,7 +101,7 @@
   // BLOCKS: define{{.*}} internal{{.*}} void {{.+}}(i8*
   // BLOCKS: [[RES:%.+]] = call i8* @__kmpc_omp_task_alloc(%{{[^ ]+}} @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i64 96, i64 1, i32 (i32, i8*)* bitcast (i32 (i32, %{{[^*]+}}*)* [[TASK_ENTRY:@[^ ]+]] to i32 (i32, i8*)*))
   // BLOCKS: [[PRIVATES:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i{{.+}} 0, i{{.+}} 1
-  // BLOCKS: call void @__kmpc_taskloop(%{{.+}}* @{{.+}}, i32 %{{.+}}, i8* [[RES]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 0, i32 0, i64 0, i8* null)
+  // BLOCKS: call void @__kmpc_taskloop(%{{.+}}* @{{.+}}, i32 %{{.+}}, i8* [[RES]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, i8* null)
   // BLOCKS: ret
 #pragma omp taskloop simd private(g, sivar)
   for (int i = 0; i < 10; ++i) {
@@ -193,7 +193,7 @@
 // CHECK: store i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_MAIN_TY]]*)* [[DESTRUCTORS:@.+]] to i32 (i32, i8*)*), i32 (i32, i8*)** [[DESTRUCTORS_PTR]],
 
 // Start task.
-// CHECK: call void @__kmpc_taskloop([[LOC]], i32 [[GTID]], i8* [[RES]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 0, i32 0, i64 0, i8* bitcast (void ([[KMP_TASK_MAIN_TY]]*, [[KMP_TASK_MAIN_TY]]*, i32)* [[MAIN_DUP:@.+]] to i8*))
+// CHECK: call void @__kmpc_taskloop([[LOC]], i32 [[GTID]], i8* [[RES]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, i8* bitcast (void ([[KMP_TASK_MAIN_TY]]*, [[KMP_TASK_MAIN_TY]]*, i32)* [[MAIN_DUP:@.+]] to i8*))
 // CHECK: call i32 @__kmpc_omp_task([[LOC]], i32 [[GTID]], i8*
 
 // CHECK: = call i{{.+}} [[TMAIN_INT:@.+]]()
@@ -324,7 +324,7 @@
 // CHECK: store i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_TMAIN_TY]]*)* [[DESTRUCTORS:@.+]] to i32 (i32, i8*)*), i32 (i32, i8*)** [[DESTRUCTORS_PTR]],
 
 // Start task.
-// CHECK: call void @__kmpc_taskloop([[LOC]], i32 [[GTID]], i8* [[RES]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 0, i32 0, i64 0, i8* bitcast (void ([[KMP_TASK_TMAIN_TY]]*, [[KMP_TASK_TMAIN_TY]]*, i32)* [[TMAIN_DUP:@.+]] to i8*))
+// CHECK: call void @__kmpc_taskloop([[LOC]], i32 [[GTID]], i8* [[RES]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, i8* bitcast (void ([[KMP_TASK_TMAIN_TY]]*, [[KMP_TASK_TMAIN_TY]]*, i32)* [[TMAIN_DUP:@.+]] to i8*))
 
 // No destructors must be called for private copies of s_arr and var.
 // CHECK-NOT: getelementptr inbounds [[PRIVATES_TMAIN_TY]], [[PRIVATES_TMAIN_TY]]* [[PRIVATES]], i{{.+}} 0, i{{.+}} 2
Index: test/OpenMP/taskloop_private_codegen.cpp
===
--- test/OpenMP/taskloop_private_codegen.cpp
+++ test/OpenMP/taskloop_private_codegen.cpp
@@ -65,7 +65,7 @@
   // LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](
   // LAMBDA: [[RES:%.+]] = call i8* @__kmpc_omp_task_alloc(%{{[^ ]+}} @{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i64 96, i64 1, i32 (i32, i8*)* bitcast (i32 (i32, %{{[^*]+}}*)* [[TASK_ENTRY:@[^ ]+]] to i32 (i32, i8*)*))
 // LAMBDA: [[PRIVATES:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i{{.+}} 0, i{{.+}} 1
-// LAMBDA: call void @__kmpc_taskloop(%{{.+}}* @{{.+}}, i32 %{{.+}}, i8* [[RES]], i32 1, i64* 

[PATCH] D53069: [analyzer][www] Update avaible_checks.html

2018-10-24 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus marked 2 inline comments as done.
Szelethus added inline comments.



Comment at: www/analyzer/available_checks.html:1119
+
+
+

george.karpenkov wrote:
> Top of the checker file has a somewhat reasonable description:
> 
> // A checker for detecting leaks resulting from allocating temporary
> // autoreleased objects before starting the main run loop.
> //
> // Checks for two antipatterns:
> // 1. ObjCMessageExpr followed by [[NSRunLoop mainRunLoop] run] in the same
> // autorelease pool.
> // 2. ObjCMessageExpr followed by [[NSRunLoop mainRunLoop] run] in no
> // autorelease pool.
> //
> // Any temporary objects autoreleased in code called in those expressions
> // will not be deallocated until the program exits, and are effectively leaks.
> 
Should be come up with an example for this one too then?


https://reviews.llvm.org/D53069



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


r345180 - Do not always request an implicit taskgroup region inside the kmpc_taskloop function

2018-10-24 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Oct 24 12:06:37 2018
New Revision: 345180

URL: http://llvm.org/viewvc/llvm-project?rev=345180=rev
Log:
Do not always request an implicit taskgroup region inside the kmpc_taskloop 
function

Summary:
For the following code:
```
int i;
#pragma omp taskloop
for (i = 0; i < 100; ++i)
{}

#pragma omp taskloop nogroup
for (i = 0; i < 100; ++i)
{}
```

Clang emits the following LLVM IR:

```
 ...
  call void @__kmpc_taskgroup(%struct.ident_t* @0, i32 %0)
  %2 = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @0, i32 %0, i32 1, i64 
80, i64 8, i32 (i32, i8*)* bitcast (i32 (i32, 
%struct.kmp_task_t_with_privates*)* @.omp_task_entry. to i32 (i32, i8*)*))
  ...
  call void @__kmpc_taskloop(%struct.ident_t* @0, i32 %0, i8* %2, i32 1, i64* 
%8, i64* %9, i64 %13, i32 0, i32 0, i64 0, i8* null)
  call void @__kmpc_end_taskgroup(%struct.ident_t* @0, i32 %0)

  ...
  %15 = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @0, i32 %0, i32 1, i64 
80, i64 8, i32 (i32, i8*)* bitcast (i32 (i32, 
%struct.kmp_task_t_with_privates.1*)* @.omp_task_entry..2 to i32 (i32, i8*)*))
  ...
  call void @__kmpc_taskloop(%struct.ident_t* @0, i32 %0, i8* %15, i32 1, i64* 
%21, i64* %22, i64 %26, i32 0, i32 0, i64 0, i8* null)

```

The first set of instructions corresponds to the first taskloop construct. It 
is important to note that the implicit taskgroup region associated with the 
taskloop construct has been materialized in our IR:  the `__kmpc_taskloop` 
occurs inside a taskgroup region. Note also that this taskgroup region does not 
exist in our second taskloop because we are using the `nogroup` clause.

The issue here is the 4th argument of the kmpc_taskloop call, starting from the 
end,  is always a zero. Checking the LLVM OpenMP RT implementation, we see that 
this argument corresponds to the nogroup parameter:

```
void __kmpc_taskloop(ident_t *loc, int gtid, kmp_task_t *task, int if_val,
 kmp_uint64 *lb, kmp_uint64 *ub, kmp_int64 st, int nogroup,
 int sched, kmp_uint64 grainsize, void *task_dup);
```

So basically we always tell to the RT to do another taskgroup region. For the 
first taskloop, this means that we create two taskgroup regions. For the second 
example, it means that despite the fact we had a nogroup clause we are going to 
have a taskgroup region, so we unnecessary wait until all descendant tasks have 
been executed.

Reviewers: ABataev

Reviewed By: ABataev

Subscribers: rogfer01, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/taskloop_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_lastprivate_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_private_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_private_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=345180=345179=345180=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Oct 24 12:06:37 2018
@@ -5246,8 +5246,8 @@ void CGOpenMPRuntime::emitTaskLoopCall(C
   LBLVal.getPointer(),
   UBLVal.getPointer(),
   CGF.EmitLoadOfScalar(StLVal, Loc),
-  llvm::ConstantInt::getNullValue(
-  CGF.IntTy), // Always 0 because taskgroup emitted by the compiler
+  llvm::ConstantInt::getSigned(
+  CGF.IntTy, 1), // Always 1 because taskgroup emitted by the 
compiler
   llvm::ConstantInt::getSigned(
   CGF.IntTy, Data.Schedule.getPointer()
  ? Data.Schedule.getInt() ? NumTasks : Grainsize

Modified: cfe/trunk/test/OpenMP/taskloop_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_codegen.cpp?rev=345180=345179=345180=diff
==
--- cfe/trunk/test/OpenMP/taskloop_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_codegen.cpp Wed Oct 24 12:06:37 2018
@@ -28,7 +28,7 @@ int main(int argc, char **argv) {
 // CHECK: [[ST:%.+]] = getelementptr inbounds [[TD_TY]], [[TD_TY]]* 
[[TASK_DATA]], i32 0, i32 7
 // CHECK: store i64 1, i64* [[ST]],
 // CHECK: [[ST_VAL:%.+]] = load i64, i64* [[ST]],
-// CHECK: call void @__kmpc_taskloop(%struct.ident_t* [[DEFLOC]], i32 
[[GTID]], i8* [[TASKV]], i32 1, i64* [[DOWN]], i64* [[UP]], i64 [[ST_VAL]], i32 
0, i32 0, i64 0, i8* null)
+// CHECK: call void 

[PATCH] D53665: [X86] Add a common-avx512 CPU to match icc's -xCOMMON-AVX512 option

2018-10-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel.

This adds a common-avx512 CPU to target the avx512 features common between 
skylake-avx512 and knl.

This is the clang version of https://reviews.llvm.org/D53663


https://reviews.llvm.org/D53665

Files:
  include/clang/Basic/X86Target.def
  lib/Basic/Targets/X86.cpp
  test/Frontend/x86-target-cpu.c
  test/Misc/target-invalid-cpu-note.c
  test/Preprocessor/predefined-arch-macros.c

Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -648,6 +648,73 @@
 // CHECK_BROADWELL_M64: #define __x86_64 1
 // CHECK_BROADWELL_M64: #define __x86_64__ 1
 
+// RUN: %clang -march=common-avx512 -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COMMONAVX512_M32
+// CHECK_COMMONAVX512_M32: #define __ADX__ 1
+// CHECK_COMMONAVX512_M32: #define __AVX2__ 1
+// CHECK_COMMONAVX512_M32: #define __AVX512CD__ 1
+// CHECK_COMMONAVX512_M32: #define __AVX512F__ 1
+// CHECK_COMMONAVX512_M32: #define __AVX__ 1
+// CHECK_COMMONAVX512_M32: #define __BMI2__ 1
+// CHECK_COMMONAVX512_M32: #define __BMI__ 1
+// CHECK_COMMONAVX512_M32: #define __F16C__ 1
+// CHECK_COMMONAVX512_M32: #define __FMA__ 1
+// CHECK_COMMONAVX512_M32: #define __LZCNT__ 1
+// CHECK_COMMONAVX512_M32: #define __MMX__ 1
+// CHECK_COMMONAVX512_M32: #define __MOVBE__ 1
+// CHECK_COMMONAVX512_M32: #define __PCLMUL__ 1
+// CHECK_COMMONAVX512_M32: #define __POPCNT__ 1
+// CHECK_COMMONAVX512_M32: #define __PRFCHW__ 1
+// CHECK_COMMONAVX512_M32: #define __RDRND__ 1
+// CHECK_COMMONAVX512_M32: #define __RDSEED__ 1
+// CHECK_COMMONAVX512_M32: #define __SSE2__ 1
+// CHECK_COMMONAVX512_M32: #define __SSE3__ 1
+// CHECK_COMMONAVX512_M32: #define __SSE4_1__ 1
+// CHECK_COMMONAVX512_M32: #define __SSE4_2__ 1
+// CHECK_COMMONAVX512_M32: #define __SSE__ 1
+// CHECK_COMMONAVX512_M32: #define __SSSE3__ 1
+// CHECK_COMMONAVX512_M32: #define __XSAVEOPT__ 1
+// CHECK_COMMONAVX512_M32: #define __XSAVE__ 1
+// CHECK_COMMONAVX512_M32: #define __i386 1
+// CHECK_COMMONAVX512_M32: #define __i386__ 1
+// CHECK_COMMONAVX512_M32: #define i386 1
+
+// RUN: %clang -march=common-avx512 -m64 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_COMMONAVX512_M64
+// CHECK_COMMONAVX512_M64: #define __ADX__ 1
+// CHECK_COMMONAVX512_M64: #define __AVX2__ 1
+// CHECK_COMMONAVX512_M64: #define __AVX512CD__ 1
+// CHECK_COMMONAVX512_M64: #define __AVX512F__ 1
+// CHECK_COMMONAVX512_M64: #define __AVX__ 1
+// CHECK_COMMONAVX512_M64: #define __BMI2__ 1
+// CHECK_COMMONAVX512_M64: #define __BMI__ 1
+// CHECK_COMMONAVX512_M64: #define __F16C__ 1
+// CHECK_COMMONAVX512_M64: #define __FMA__ 1
+// CHECK_COMMONAVX512_M64: #define __LZCNT__ 1
+// CHECK_COMMONAVX512_M64: #define __MMX__ 1
+// CHECK_COMMONAVX512_M64: #define __MOVBE__ 1
+// CHECK_COMMONAVX512_M64: #define __PCLMUL__ 1
+// CHECK_COMMONAVX512_M64: #define __POPCNT__ 1
+// CHECK_COMMONAVX512_M64: #define __PRFCHW__ 1
+// CHECK_COMMONAVX512_M64: #define __RDRND__ 1
+// CHECK_COMMONAVX512_M64: #define __RDSEED__ 1
+// CHECK_COMMONAVX512_M64: #define __SSE2_MATH__ 1
+// CHECK_COMMONAVX512_M64: #define __SSE2__ 1
+// CHECK_COMMONAVX512_M64: #define __SSE3__ 1
+// CHECK_COMMONAVX512_M64: #define __SSE4_1__ 1
+// CHECK_COMMONAVX512_M64: #define __SSE4_2__ 1
+// CHECK_COMMONAVX512_M64: #define __SSE_MATH__ 1
+// CHECK_COMMONAVX512_M64: #define __SSE__ 1
+// CHECK_COMMONAVX512_M64: #define __SSSE3__ 1
+// CHECK_COMMONAVX512_M64: #define __XSAVEOPT__ 1
+// CHECK_COMMONAVX512_M64: #define __XSAVE__ 1
+// CHECK_COMMONAVX512_M64: #define __amd64 1
+// CHECK_COMMONAVX512_M64: #define __amd64__ 1
+// CHECK_COMMONAVX512_M64: #define __x86_64 1
+// CHECK_COMMONAVX512_M64: #define __x86_64__ 1
+
 // RUN: %clang -march=skylake -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SKL_M32
Index: test/Misc/target-invalid-cpu-note.c
===
--- test/Misc/target-invalid-cpu-note.c
+++ test/Misc/target-invalid-cpu-note.c
@@ -15,7 +15,7 @@
 // X86-SAME: pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott,
 // X86-SAME: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont,
 // X86-SAME: nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge,
-// X86-SAME: core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512,
+// X86-SAME: core-avx-i, haswell, core-avx2, broadwell, common-avx512, skylake, skylake-avx512,
 // X86-SAME: skx, cannonlake, icelake-client, icelake-server, knl, knm, lakemont, k6, k6-2, k6-3,
 // X86-SAME: athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64,
 // 

[PATCH] D53543: [analyzer] MallocChecker: pr39348: Realize that sized delete isn't a custom delete.

2018-10-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:727
 
-  // Skip all operator new/delete methods.
-  if (isa(FD))
-return false;
-
-  // Return true if tested operator is a standard placement nothrow operator.
-  if (FD->getNumParams() == 2) {
-QualType T = FD->getParamDecl(1)->getType();
-if (const IdentifierInfo *II = T.getBaseTypeIdentifier())
-  return II->getName().equals("nothrow_t");
-  }
-
-  // Skip placement operators.
-  if (FD->getNumParams() != 1 || FD->isVariadic())
-return false;
-
-  // One of the standard new/new[]/delete/delete[] non-placement operators.
-  return true;
+  // This is standard iff it's not defined in a user file.
+  SourceLocation L = FD->getLocation();

Szelethus wrote:
> typo: if
https://en.wikipedia.org/wiki/If_and_only_if

Thx for pointing out that it's not an entirely common jargon!



Comment at: test/Analysis/NewDelete-custom.cpp:3-4
 // RUN: %clang_analyze_cc1 
-analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc 
-std=c++11 -analyzer-config c++-allocator-inlining=false -DLEAKS=1 -fblocks 
-verify %s
 // RUN: %clang_analyze_cc1 
-analyzer-checker=core,cplusplus.NewDelete,unix.Malloc -std=c++11 
-DALLOCATOR_INLINING=1 -fblocks -verify %s
 // RUN: %clang_analyze_cc1 
-analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc 
-std=c++11 -DLEAKS=1 -DALLOCATOR_INLINING=1 -fblocks -verify %s
 #include "Inputs/system-header-simulator-cxx.h"

Szelethus wrote:
> Do we still need `-DLEAKS=1` and ` -DALLOCATOR_INLINING=1`?
I guess i'll just remove the no-leaks run-lines because they didn't make sense 
in the first place.


https://reviews.llvm.org/D53543



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


[PATCH] D53543: [analyzer] MallocChecker: pr39348: Realize that sized delete isn't a custom delete.

2018-10-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 170946.
NoQ added a comment.

Address comments!


https://reviews.llvm.org/D53543

Files:
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  test/Analysis/NewDelete-custom.cpp
  test/Analysis/NewDelete-sized-deallocation.cpp

Index: test/Analysis/NewDelete-sized-deallocation.cpp
===
--- /dev/null
+++ test/Analysis/NewDelete-sized-deallocation.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -fsized-deallocation
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -DINCLUDE_INCLUDES
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -DINCLUDE_INCLUDES -fsized-deallocation
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -DINCLUDE_INCLUDES -DTEST_INLINABLE_ALLOCATORS
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -DINCLUDE_INCLUDES -DTEST_INLINABLE_ALLOCATORS -fsized-deallocation
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -std=c++14
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -std=c++14 -fsized-deallocation
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -std=c++14 -DINCLUDE_INCLUDES
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -std=c++14 -DINCLUDE_INCLUDES -fsized-deallocation
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -std=c++14 -DINCLUDE_INCLUDES -DTEST_INLINABLE_ALLOCATORS
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -std=c++14 -DINCLUDE_INCLUDES -DTEST_INLINABLE_ALLOCATORS -fsized-deallocation
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -std=c++17
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -std=c++17 -fsized-deallocation
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -std=c++17 -DINCLUDE_INCLUDES
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -std=c++17 -DINCLUDE_INCLUDES -fsized-deallocation
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -std=c++17 -DINCLUDE_INCLUDES -DTEST_INLINABLE_ALLOCATORS
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus -verify -analyzer-output=text %s -std=c++17 -DINCLUDE_INCLUDES -DTEST_INLINABLE_ALLOCATORS -fsized-deallocation
+
+// Test all three: undeclared operator delete, operator delete forward-declared
+// in the system header, operator delete defined in system header.
+#ifdef INCLUDE_INCLUDES
+// TEST_INLINABLE_ALLOCATORS is used within this include.
+#include "Inputs/system-header-simulator-cxx.h"
+#endif
+
+void leak() {
+  int *x = new int; // expected-note{{Memory is allocated}}
+} // expected-warning{{Potential leak of memory pointed to by 'x'}}
+  // expected-note@-1{{Potential leak of memory pointed to by 'x'}}
+
+// This function was incorrectly diagnosed as leak under -fsized-deallocation
+// because the sized operator delete was mistaken for a custom delete.
+void no_leak() {
+  int *x = new int; // no-note
+  delete x;
+} // no-warning
Index: test/Analysis/NewDelete-custom.cpp
===
--- test/Analysis/NewDelete-custom.cpp
+++ test/Analysis/NewDelete-custom.cpp
@@ -1,12 +1,8 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,unix.Malloc -std=c++11 -analyzer-config c++-allocator-inlining=false -fblocks -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -analyzer-config c++-allocator-inlining=false -DLEAKS=1 -fblocks -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,unix.Malloc -std=c++11 -DALLOCATOR_INLINING=1 -fblocks -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -DLEAKS=1 -DALLOCATOR_INLINING=1 -fblocks -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -fblocks -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -fblocks -verify %s -analyzer-config c++-allocator-inlining=false
 #include "Inputs/system-header-simulator-cxx.h"
 
-#if !(LEAKS && !ALLOCATOR_INLINING)
 // expected-no-diagnostics
-#endif
 
 
 void *allocator(std::size_t size);
@@ -24,50 +20,37 @@
 

[PATCH] D53633: [AArch64] Implement FP16FML intrinsics

2018-10-24 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc added a comment.

In https://reviews.llvm.org/D53633#1274621, @t.p.northover wrote:

> I think this is reasonable.


Thanks Tim. Could you also review https://reviews.llvm.org/D53632, which is the 
LLVM part of this implementation?


Repository:
  rC Clang

https://reviews.llvm.org/D53633



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


r345177 - [OPENMP]Fix PR39366: do not try to private field if it is not captured.

2018-10-24 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Oct 24 11:53:12 2018
New Revision: 345177

URL: http://llvm.org/viewvc/llvm-project?rev=345177=rev
Log:
[OPENMP]Fix PR39366: do not try to private field if it is not captured.

The compiler is crashing if we trying to post-capture the fields
implicitly captured inside of the task constructs. Seems, this kind of
processing is not supported and such fields should not be
firstprivatized.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/task_codegen.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=345177=345176=345177=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Oct 24 11:53:12 2018
@@ -2181,8 +2181,14 @@ public:
   // Define implicit data-sharing attributes for task.
   DVar = Stack->getImplicitDSA(FD, /*FromParent=*/false);
   if (isOpenMPTaskingDirective(DKind) && DVar.CKind != OMPC_shared &&
-  !Stack->isLoopControlVariable(FD).first)
-ImplicitFirstprivate.push_back(E);
+  !Stack->isLoopControlVariable(FD).first) {
+// Check if there is a captured expression for the current field in the
+// region. Do not mark it as firstprivate unless there is no captured
+// expression.
+// TODO: try to make it firstprivate.
+if (DVar.CKind != OMPC_unknown)
+  ImplicitFirstprivate.push_back(E);
+  }
   return;
 }
 if (isOpenMPTargetExecutionDirective(DKind)) {

Modified: cfe/trunk/test/OpenMP/task_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/task_codegen.cpp?rev=345177=345176=345177=diff
==
--- cfe/trunk/test/OpenMP/task_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/task_codegen.cpp Wed Oct 24 11:53:12 2018
@@ -278,5 +278,18 @@ int main() {
 // CHECK: load i32*, i32** %
 // CHECK: store i32 4, i32* %
 // CHECK: call i32 @__kmpc_omp_task(%
+
+struct S1 {
+  int a;
+  S1() { taskinit(); }
+  void taskinit() {
+#pragma omp task
+a = 0;
+  }
+} s1;
+
+// CHECK-LABEL: taskinit
+// CHECK: call i8* @__kmpc_omp_task_alloc(
+
 #endif
 


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


r345176 - [CodeGen] Update test checks missed in r345168.

2018-10-24 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Oct 24 11:45:44 2018
New Revision: 345176

URL: http://llvm.org/viewvc/llvm-project?rev=345176=rev
Log:
[CodeGen] Update test checks missed in r345168.

These tests don't run unless the aarch64 target is registered and my testing 
had been on an x86 only build directory.

Modified:
cfe/trunk/test/CodeGen/aarch64-neon-extract.c
cfe/trunk/test/CodeGen/aarch64-poly128.c

Modified: cfe/trunk/test/CodeGen/aarch64-neon-extract.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-extract.c?rev=345176=345175=345176=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-extract.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-extract.c Wed Oct 24 11:45:44 2018
@@ -46,14 +46,14 @@ int64x1_t test_vext_s64(int64x1_t a, int
   return vext_s64(a, b, 0);
 }
 
-// CHECK-LABEL: define <16 x i8> @test_vextq_s8(<16 x i8> %a, <16 x i8> %b) #0 
{
+// CHECK-LABEL: define <16 x i8> @test_vextq_s8(<16 x i8> %a, <16 x i8> %b) #1 
{
 // CHECK:   [[VEXT:%.*]] = shufflevector <16 x i8> %a, <16 x i8> %b, <16 x 
i32> 
 // CHECK:   ret <16 x i8> [[VEXT]]
 int8x16_t test_vextq_s8(int8x16_t a, int8x16_t b) {
   return vextq_s8(a, b, 2);
 }
 
-// CHECK-LABEL: define <8 x i16> @test_vextq_s16(<8 x i16> %a, <8 x i16> %b) 
#0 {
+// CHECK-LABEL: define <8 x i16> @test_vextq_s16(<8 x i16> %a, <8 x i16> %b) 
#1 {
 // CHECK:   [[TMP0:%.*]] = bitcast <8 x i16> %a to <16 x i8>
 // CHECK:   [[TMP1:%.*]] = bitcast <8 x i16> %b to <16 x i8>
 // CHECK:   [[TMP2:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x i16>
@@ -64,7 +64,7 @@ int16x8_t test_vextq_s16(int16x8_t a, in
   return vextq_s16(a, b, 3);
 }
 
-// CHECK-LABEL: define <4 x i32> @test_vextq_s32(<4 x i32> %a, <4 x i32> %b) 
#0 {
+// CHECK-LABEL: define <4 x i32> @test_vextq_s32(<4 x i32> %a, <4 x i32> %b) 
#1 {
 // CHECK:   [[TMP0:%.*]] = bitcast <4 x i32> %a to <16 x i8>
 // CHECK:   [[TMP1:%.*]] = bitcast <4 x i32> %b to <16 x i8>
 // CHECK:   [[TMP2:%.*]] = bitcast <16 x i8> [[TMP0]] to <4 x i32>
@@ -75,7 +75,7 @@ int32x4_t test_vextq_s32(int32x4_t a, in
   return vextq_s32(a, b, 1);
 }
 
-// CHECK-LABEL: define <2 x i64> @test_vextq_s64(<2 x i64> %a, <2 x i64> %b) 
#0 {
+// CHECK-LABEL: define <2 x i64> @test_vextq_s64(<2 x i64> %a, <2 x i64> %b) 
#1 {
 // CHECK:   [[TMP0:%.*]] = bitcast <2 x i64> %a to <16 x i8>
 // CHECK:   [[TMP1:%.*]] = bitcast <2 x i64> %b to <16 x i8>
 // CHECK:   [[TMP2:%.*]] = bitcast <16 x i8> [[TMP0]] to <2 x i64>
@@ -126,14 +126,14 @@ uint64x1_t test_vext_u64(uint64x1_t a, u
   return vext_u64(a, b, 0);
 }
 
-// CHECK-LABEL: define <16 x i8> @test_vextq_u8(<16 x i8> %a, <16 x i8> %b) #0 
{
+// CHECK-LABEL: define <16 x i8> @test_vextq_u8(<16 x i8> %a, <16 x i8> %b) #1 
{
 // CHECK:   [[VEXT:%.*]] = shufflevector <16 x i8> %a, <16 x i8> %b, <16 x 
i32> 
 // CHECK:   ret <16 x i8> [[VEXT]]
 uint8x16_t test_vextq_u8(uint8x16_t a, uint8x16_t b) {
   return vextq_u8(a, b, 2);
 }
 
-// CHECK-LABEL: define <8 x i16> @test_vextq_u16(<8 x i16> %a, <8 x i16> %b) 
#0 {
+// CHECK-LABEL: define <8 x i16> @test_vextq_u16(<8 x i16> %a, <8 x i16> %b) 
#1 {
 // CHECK:   [[TMP0:%.*]] = bitcast <8 x i16> %a to <16 x i8>
 // CHECK:   [[TMP1:%.*]] = bitcast <8 x i16> %b to <16 x i8>
 // CHECK:   [[TMP2:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x i16>
@@ -144,7 +144,7 @@ uint16x8_t test_vextq_u16(uint16x8_t a,
   return vextq_u16(a, b, 3);
 }
 
-// CHECK-LABEL: define <4 x i32> @test_vextq_u32(<4 x i32> %a, <4 x i32> %b) 
#0 {
+// CHECK-LABEL: define <4 x i32> @test_vextq_u32(<4 x i32> %a, <4 x i32> %b) 
#1 {
 // CHECK:   [[TMP0:%.*]] = bitcast <4 x i32> %a to <16 x i8>
 // CHECK:   [[TMP1:%.*]] = bitcast <4 x i32> %b to <16 x i8>
 // CHECK:   [[TMP2:%.*]] = bitcast <16 x i8> [[TMP0]] to <4 x i32>
@@ -155,7 +155,7 @@ uint32x4_t test_vextq_u32(uint32x4_t a,
   return vextq_u32(a, b, 1);
 }
 
-// CHECK-LABEL: define <2 x i64> @test_vextq_u64(<2 x i64> %a, <2 x i64> %b) 
#0 {
+// CHECK-LABEL: define <2 x i64> @test_vextq_u64(<2 x i64> %a, <2 x i64> %b) 
#1 {
 // CHECK:   [[TMP0:%.*]] = bitcast <2 x i64> %a to <16 x i8>
 // CHECK:   [[TMP1:%.*]] = bitcast <2 x i64> %b to <16 x i8>
 // CHECK:   [[TMP2:%.*]] = bitcast <16 x i8> [[TMP0]] to <2 x i64>
@@ -188,7 +188,7 @@ float64x1_t test_vext_f64(float64x1_t a,
   return vext_f64(a, b, 0);
 }
 
-// CHECK-LABEL: define <4 x float> @test_vextq_f32(<4 x float> %a, <4 x float> 
%b) #0 {
+// CHECK-LABEL: define <4 x float> @test_vextq_f32(<4 x float> %a, <4 x float> 
%b) #1 {
 // CHECK:   [[TMP0:%.*]] = bitcast <4 x float> %a to <16 x i8>
 // CHECK:   [[TMP1:%.*]] = bitcast <4 x float> %b to <16 x i8>
 // CHECK:   [[TMP2:%.*]] = bitcast <16 x i8> [[TMP0]] to <4 x float>
@@ -199,7 +199,7 @@ float32x4_t test_vextq_f32(float32x4_t a
   return vextq_f32(a, b, 1);
 }
 
-// CHECK-LABEL: define <2 x double> @test_vextq_f64(<2 x double> %a, <2 x 
double> %b) #0 {
+// CHECK-LABEL: define <2 x double> @test_vextq_f64(<2 x double> 

[PATCH] D53339: [clang-tidy] Add the abseil-duration-factory-float check

2018-10-24 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D53339#1274561, @hwright wrote:

> @JonasToth I don't actually have commit privileges, so somebody else will 
> have to commit for me.  :)


You should definitely ask commit access.


Repository:
  rL LLVM

https://reviews.llvm.org/D53339



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


[PATCH] D53636: Do not always request an implicit taskgroup region inside the kmpc_taskloop function

2018-10-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In https://reviews.llvm.org/D53636#1274673, @smateo wrote:

> Hi Alexey,
>
> Thanks for the prompt review!
>
> I don't have commit access yet, do you mind to commit it for me?
>
> Thanks!


Sure, no problems, thanks for the patch!


Repository:
  rC Clang

https://reviews.llvm.org/D53636



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


[PATCH] D53636: Do not always request an implicit taskgroup region inside the kmpc_taskloop function

2018-10-24 Thread Sergi Mateo via Phabricator via cfe-commits
smateo added a comment.

Hi Alexey,

Thanks for the prompt review!

I don't have commit access yet, do you mind to commit it for me?

Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D53636



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


[PATCH] D53066: [Driver] Use forward slashes in most linker arguments

2018-10-24 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D53066#1274288, @zturner wrote:

> It seems like some combination of checking the target triple, host triple,
>  and driver mode and putting the conversions behind those checks could work?


Sounds ok, I can give it a shot. There's probably no need to explicitly check 
the host here, as the `convert_to_slash` function is a no-op on anything else 
than windows.

> For paths like resource dir that are going into debug info it should be
>  driver mode.

Why is that? Wouldn't one want the same behaviour when building with the clang 
driver with an msvc target triple? Also, what kind of paths do you get in the 
PDB when crosscompiling from unix with clang-cl?


https://reviews.llvm.org/D53066



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


[PATCH] D53206: Allow padding checker to traverse simple class hierarchies

2018-10-24 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

I'll try to take a look this week.


Repository:
  rC Clang

https://reviews.llvm.org/D53206



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


[PATCH] D53206: Allow padding checker to traverse simple class hierarchies

2018-10-24 Thread Max Bernstein via Phabricator via cfe-commits
tekknolagi added a comment.

Ping @NoQ @george.karpenkov


Repository:
  rC Clang

https://reviews.llvm.org/D53206



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


r345170 - [Hexagon] Flip hexagon-autohvx to be true by default

2018-10-24 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Wed Oct 24 10:55:18 2018
New Revision: 345170

URL: http://llvm.org/viewvc/llvm-project?rev=345170=rev
Log:
[Hexagon] Flip hexagon-autohvx to be true by default

This will allow other generators of LLVM IR to use the auto-vectorizer
without having to change that flag.

Note: on its own, this patch will disable auto-vectorization on Hexagon
in all cases, regardless of the -fvectorize flag. There is a companion
LLVM patch that together with this one forms an NFC for clang users.

Modified:
cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
cfe/trunk/test/Driver/hexagon-vectorize.c

Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp?rev=345170=345169=345170=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp Wed Oct 24 10:55:18 2018
@@ -516,9 +516,9 @@ void HexagonToolChain::addClangTargetOpt
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+reserved-r19");
   }
-  if (isAutoHVXEnabled(DriverArgs)) {
+  if (!isAutoHVXEnabled(DriverArgs)) {
 CC1Args.push_back("-mllvm");
-CC1Args.push_back("-hexagon-autohvx");
+CC1Args.push_back("-hexagon-autohvx=0");
   }
 }
 

Modified: cfe/trunk/test/Driver/hexagon-vectorize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-vectorize.c?rev=345170=345169=345170=diff
==
--- cfe/trunk/test/Driver/hexagon-vectorize.c (original)
+++ cfe/trunk/test/Driver/hexagon-vectorize.c Wed Oct 24 10:55:18 2018
@@ -3,7 +3,7 @@
 // RUN: %clang -target hexagon -fvectorize -fno-vectorize -### %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-NOVECTOR
 // RUN: %clang -target hexagon -fvectorize -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-NEEDHVX
 
-// CHECK-DEFAULT-NOT: hexagon-autohvx
-// CHECK-VECTOR: "-mllvm" "-hexagon-autohvx"
-// CHECK-NOVECTOR-NOT: hexagon-autohvx
+// CHECK-DEFAULT: -hexagon-autohvx={{false|0}}
+// CHECK-VECTOR-NOT: -hexagon-autohvx={{false|0}}
+// CHECK-NOVECTOR: -hexagon-autohvx={{false|0}}
 // CHECK-NEEDHVX: warning: auto-vectorization requires HVX, use -mhvx to 
enable it


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


[PATCH] D53633: [AArch64] Implement FP16FML intrinsics

2018-10-24 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover accepted this revision.
t.p.northover added a comment.
This revision is now accepted and ready to land.

I think this is reasonable.


Repository:
  rC Clang

https://reviews.llvm.org/D53633



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


[PATCH] D53339: [clang-tidy] Add the abseil-duration-factory-float check

2018-10-24 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Thanks for the patch!


Repository:
  rL LLVM

https://reviews.llvm.org/D53339



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


[PATCH] D53339: [clang-tidy] Add the abseil-duration-factory-float check

2018-10-24 Thread Jonas Toth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345167: [clang-tidy] Add the abseil-duration-factory-float 
check (authored by JonasToth, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53339?vs=170912=170932#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53339

Files:
  clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryFloatCheck.cpp
  clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryFloatCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-duration-factory-float.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/abseil-duration-factory-float.cpp

Index: clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryFloatCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryFloatCheck.h
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryFloatCheck.h
@@ -0,0 +1,38 @@
+//===--- DurationFactoryFloatCheck.h - clang-tidy ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_DURATIONFACTORYFLOATCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_DURATIONFACTORYFLOATCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace abseil {
+
+/// This check finds cases where `Duration` factories are being called with
+/// floating point arguments, but could be called using integer arguments.
+/// It handles explicit casts and floating point literals with no fractional
+/// component.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/abseil-duration-factory-float.html
+class DurationFactoryFloatCheck : public ClangTidyCheck {
+public:
+  DurationFactoryFloatCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace abseil
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_DURATIONFACTORYFLOATCHECK_H
Index: clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryFloatCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryFloatCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryFloatCheck.cpp
@@ -0,0 +1,106 @@
+//===--- DurationFactoryFloatCheck.cpp - clang-tidy ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DurationFactoryFloatCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/FixIt.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace abseil {
+
+// Returns an integer if the fractional part of a `FloatingLiteral` is `0`.
+static llvm::Optional
+truncateIfIntegral(const FloatingLiteral ) {
+  double Value = FloatLiteral.getValueAsApproximateDouble();
+  if (std::fmod(Value, 1) == 0) {
+if (Value >= static_cast(1u << 31))
+  return llvm::None;
+
+return llvm::APSInt::get(static_cast(Value));
+  }
+  return llvm::None;
+}
+
+// Returns `true` if `Range` is inside a macro definition.
+static bool InsideMacroDefinition(const MatchFinder::MatchResult ,
+  SourceRange Range) {
+  return !clang::Lexer::makeFileCharRange(
+  clang::CharSourceRange::getCharRange(Range),
+  *Result.SourceManager, Result.Context->getLangOpts())
+  .isValid();
+}
+
+void DurationFactoryFloatCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  callExpr(
+  callee(functionDecl(hasAnyName(
+  "absl::Nanoseconds", "absl::Microseconds", "absl::Milliseconds",
+  "absl::Seconds", "absl::Minutes", "absl::Hours"))),
+  hasArgument(0,
+  anyOf(cxxStaticCastExpr(
+hasDestinationType(realFloatingPointType()),
+hasSourceExpression(expr().bind("cast_arg"))),
+cStyleCastExpr(
+ 

[clang-tools-extra] r345167 - [clang-tidy] Add the abseil-duration-factory-float check

2018-10-24 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Wed Oct 24 10:40:50 2018
New Revision: 345167

URL: http://llvm.org/viewvc/llvm-project?rev=345167=rev
Log:
[clang-tidy] Add the abseil-duration-factory-float check

Summary:
This check finds cases where calls to an absl::Duration factory could use the 
more efficient integer overload.

For example:
// Original - Providing a floating-point literal.
absl::Duration d = absl::Seconds(10.0);

// Suggested - Use an integer instead.
absl::Duration d = absl::Seconds(10);

Patch by hwright.

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: hokein, JonasToth

Subscribers: zturner, xazax.hun, Eugene.Zelenko, mgorny, cfe-commits

Tags: #clang-tools-extra

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

Added:
clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryFloatCheck.cpp
clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryFloatCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-duration-factory-float.rst
clang-tools-extra/trunk/test/clang-tidy/abseil-duration-factory-float.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp?rev=345167=345166=345167=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp Wed Oct 24 
10:40:50 2018
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "DurationDivisionCheck.h"
+#include "DurationFactoryFloatCheck.h"
 #include "FasterStrsplitDelimiterCheck.h"
 #include "NoInternalDependenciesCheck.h"
 #include "NoNamespaceCheck.h"
@@ -27,6 +28,8 @@ public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
 CheckFactories.registerCheck(
 "abseil-duration-division");
+CheckFactories.registerCheck(
+"abseil-duration-factory-float");
 CheckFactories.registerCheck(
 "abseil-faster-strsplit-delimiter");
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt?rev=345167=345166=345167=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt Wed Oct 24 
10:40:50 2018
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS support)
 add_clang_library(clangTidyAbseilModule
   AbseilTidyModule.cpp
   DurationDivisionCheck.cpp
+  DurationFactoryFloatCheck.cpp
   FasterStrsplitDelimiterCheck.cpp
   NoInternalDependenciesCheck.cpp
   NoNamespaceCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryFloatCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryFloatCheck.cpp?rev=345167=auto
==
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryFloatCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryFloatCheck.cpp Wed 
Oct 24 10:40:50 2018
@@ -0,0 +1,106 @@
+//===--- DurationFactoryFloatCheck.cpp - clang-tidy 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DurationFactoryFloatCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/FixIt.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace abseil {
+
+// Returns an integer if the fractional part of a `FloatingLiteral` is `0`.
+static llvm::Optional
+truncateIfIntegral(const FloatingLiteral ) {
+  double Value = FloatLiteral.getValueAsApproximateDouble();
+  if (std::fmod(Value, 1) == 0) {
+if (Value >= static_cast(1u << 31))
+  return llvm::None;
+
+return llvm::APSInt::get(static_cast(Value));
+  }
+  return llvm::None;
+}
+
+// Returns `true` if `Range` is inside a macro definition.
+static bool InsideMacroDefinition(const MatchFinder::MatchResult ,
+  SourceRange Range) {
+  return !clang::Lexer::makeFileCharRange(
+  clang::CharSourceRange::getCharRange(Range),
+  *Result.SourceManager, Result.Context->getLangOpts())
+  

[PATCH] D53076: [analyzer] Enhance ConditionBRVisitor to write out more information

2018-10-24 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov requested changes to this revision.
george.karpenkov added inline comments.
This revision now requires changes to proceed.



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:80
   typedef llvm::ImmutableMap GenericDataMap;
+  typedef llvm::DenseMap  ConstraintMap;
 

Generally, `StringRef`'s shouldn't be stored in containers, as containers might 
outlive them.
It might be fine in this case, but I would prefer to be on the safe side and 
just use `std::string`



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:238
+  /// message on that constraint being changed.
+  bool isChangedOrInsertConstraint(ConstraintMap , const Stmt 
*Cond,
+   StringRef Message) const {

whisperity wrote:
> `insertOrUpdateContraintMessage`
> 
> and mention in the documentation that it returns whether or not the actual 
> insertion or update change took place
If constraints is now a property of the visitor, shouldn't this method with the 
typedef above be moved to the visitor as well?



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:244
+if (I == Constraints.end() || !Message.equals(I->second)) {
+  Constraints[Cond] = Message;
+  return true;

Isn't that equivalent to `Constraints.insert(make_pair(Cond, Message)).second` ?
I think I have written that before.



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:2232
+ const ExplodedNode *N, BugReport ) 
{
+  Constraints.clear();
+}

It does not seem necessary, because a new copy of the visitor is created for 
each new bug report.


https://reviews.llvm.org/D53076



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


[PATCH] D53339: [clang-tidy] Add the abseil-duration-factory-float check

2018-10-24 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added a comment.

In https://reviews.llvm.org/D53339#1274478, @JonasToth wrote:

> I think accepted now? :)
>  If you want I can commit for you and monitor the buildbot, if there are 
> bigger problems I would come back to you.


@JonasToth I don't actually have commit privileges, so somebody else will have 
to commit for me.  :)


https://reviews.llvm.org/D53339



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


[PATCH] D53069: [analyzer][www] Update avaible_checks.html

2018-10-24 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov requested changes to this revision.
george.karpenkov added a comment.
This revision now requires changes to proceed.

Good to go provided you will add an example.
If we want to be serious about this page, it really has to be auto-generated 
(like clang-tidy one), but I understand that this is a larger undertaking.




Comment at: www/analyzer/available_checks.html:496
+
+
+

Szelethus wrote:
> george.karpenkov wrote:
> > If we don't have a description, let's just drop it.
> I added a description, I'd strongly prefer keeping this in.
Also would need a short example. Usually one can be found in tests.


https://reviews.llvm.org/D53069



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


[PATCH] D53655: [ASTImporter] Fix redecl chain of classes and class templates

2018-10-24 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

I can't add anything meaningful to the conversation, but I spotted some nits, 
so here they are.




Comment at: include/clang/ASTMatchers/ASTMatchers.h:1150
+/// \endcode
+/// fieldDecl()
+///   matches 'a'.

Did you mean to write `indirectFieldDecl()`?



Comment at: lib/AST/ASTImporter.cpp:2667
   ConflictingDecls.push_back(FoundDecl);
-}
+} // for
 

Hah. We should do this more often.



Comment at: lib/AST/DeclBase.cpp:1469
 assert(Pos != Map->end() && "no lookup entry for decl");
-if (Pos->second.getAsVector() || Pos->second.getAsDecl() == ND)
+// Remove the decl only if it is contained.
+if ((Pos->second.getAsVector() && Pos->second.containsInVector(ND)) ||

Contained in?


Repository:
  rC Clang

https://reviews.llvm.org/D53655



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


r345160 - CodeGen: extract some local variables in CFConstantString creation (NFC)

2018-10-24 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Oct 24 09:56:36 2018
New Revision: 345160

URL: http://llvm.org/viewvc/llvm-project?rev=345160=rev
Log:
CodeGen: extract some local variables in CFConstantString creation (NFC)

Extract the reference to the ASTContext and Triple and use them throughout the
function.  This is simply a cosmetic cleanup while in the area.  NFC.

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=345160=345159=345160=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Oct 24 09:56:36 2018
@@ -4121,6 +4121,9 @@ CodeGenModule::GetAddrOfConstantCFString
   llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty);
   llvm::Constant *Zeros[] = { Zero, Zero };
 
+  const ASTContext  = getContext();
+  const llvm::Triple  = getTriple();
+
   // If we don't already have it, get __CFConstantStringClassReference.
   if (!CFConstantStringClassRef) {
 llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
@@ -4128,12 +4131,12 @@ CodeGenModule::GetAddrOfConstantCFString
 llvm::Constant *C =
 CreateRuntimeVariable(Ty, "__CFConstantStringClassReference");
 
-if (getTriple().isOSBinFormatELF() || getTriple().isOSBinFormatCOFF()) {
+if (Triple.isOSBinFormatELF() || Triple.isOSBinFormatCOFF()) {
   llvm::GlobalValue *GV = nullptr;
 
   if ((GV = dyn_cast(C))) {
-IdentifierInfo  = getContext().Idents.get(GV->getName());
-TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl();
+IdentifierInfo  = Context.Idents.get(GV->getName());
+TranslationUnitDecl *TUDecl = Context.getTranslationUnitDecl();
 DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
 
 const VarDecl *VD = nullptr;
@@ -4141,18 +4144,15 @@ CodeGenModule::GetAddrOfConstantCFString
   if ((VD = dyn_cast(Result)))
 break;
 
-if (getTriple().isOSBinFormatELF()) {
+if (Triple.isOSBinFormatELF()) {
   if (!VD)
 GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
-}
-else {
-  if (!VD || !VD->hasAttr()) {
+} else {
+  GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
+  if (!VD || !VD->hasAttr())
 GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
-GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
-  } else {
+  else
 GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
-GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
-  }
 }
 
 setDSOLocal(GV);
@@ -4164,7 +4164,7 @@ CodeGenModule::GetAddrOfConstantCFString
 llvm::ConstantExpr::getGetElementPtr(Ty, C, Zeros);
   }
 
-  QualType CFTy = getContext().getCFConstantStringType();
+  QualType CFTy = Context.getCFConstantStringType();
 
   auto *STy = cast(getTypes().ConvertType(CFTy));
 
@@ -4196,20 +4196,19 @@ CodeGenModule::GetAddrOfConstantCFString
   GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
   // Don't enforce the target's minimum global alignment, since the only use
   // of the string is via this class initializer.
-  CharUnits Align = isUTF16
-? 
getContext().getTypeAlignInChars(getContext().ShortTy)
-: 
getContext().getTypeAlignInChars(getContext().CharTy);
+  CharUnits Align = isUTF16 ? Context.getTypeAlignInChars(Context.ShortTy)
+: Context.getTypeAlignInChars(Context.CharTy);
   GV->setAlignment(Align.getQuantity());
 
   // FIXME: We set the section explicitly to avoid a bug in ld64 224.1.
   // Without it LLVM can merge the string with a non unnamed_addr one during
   // LTO.  Doing that changes the section it ends in, which surprises ld64.
-  if (getTriple().isOSBinFormatMachO())
+  if (Triple.isOSBinFormatMachO())
 GV->setSection(isUTF16 ? "__TEXT,__ustring"
: "__TEXT,__cstring,cstring_literals");
   // Make sure the literal ends up in .rodata to allow for safe ICF and for
   // the static linker to adjust permissions to read-only later on.
-  else if (getTriple().isOSBinFormatELF())
+  else if (Triple.isOSBinFormatELF())
 GV->setSection(".rodata");
 
   // String.
@@ -4222,7 +4221,7 @@ CodeGenModule::GetAddrOfConstantCFString
   Fields.add(Str);
 
   // String length.
-  auto Ty = getTypes().ConvertType(getContext().LongTy);
+  auto Ty = getTypes().ConvertType(Context.LongTy);
   Fields.addInt(cast(Ty), StringLength);
 
   CharUnits Alignment = getPointerAlign();
@@ -4231,7 +4230,7 @@ CodeGenModule::GetAddrOfConstantCFString
   GV = Fields.finishAndCreateGlobal("_unnamed_cfstring_", Alignment,
 /*isConstant=*/false,
   

[PATCH] D53642: [clangd] Don't invalidate LSP-set compile commands when closing a file.

2018-10-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM. Good catch!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53642



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


[PATCH] D53524: [ThinLTO] Enable LTOUnit only when it is needed

2018-10-24 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D53524#1271387, @tejohnson wrote:

> In https://reviews.llvm.org/D53524#1271357, @pcc wrote:
>
> > The reason why LTO unit is always enabled is so that you can link 
> > translation units compiled with `-fsanitize=cfi` and/or 
> > `-fwhole-program-vtables` against translation units compiled without 
> > CFI/WPD. With this change we will see miscompiles in the translation units 
> > compiled with CFI/WPD if they use vtables in the translation units compiled 
> > without CFI/WPD. If we really need this option I think it should be an opt 
> > out.
>
>
> Is there an important use case for support thing mixing and matching? The 
> issue is that it comes at a cost to all ThinLTO compiles for codes with 
> vtables by requiring them all to process IR during the thin link.


Ping on the question of why this mode needs to be default. If it was a matter 
of a few percent overhead that would be one thing, but we're talking a *huge* 
overhead (as noted off-patch for my app I'm seeing >20x thin link time 
currently, and with improvements to the hashing to always get successful 
splitting we could potentially get down to closer to 2x - still a big 
overhead). This kind of overhead should be opt-in. The average ThinLTO user is 
not going to realize they are paying a big overhead because CFI is always 
pre-enabled.

> Can we detect that TUs compiled with -flto-unit are being mixed with those 
> not built without -flto-unit at the thin link time and issue an error?

This would be doable pretty easily. E.g. add a flag at the index level that the 
module would have been split but wasn't. Users who get the error and want to 
support always-enabled CFI could opt in via -flto-unit.


Repository:
  rC Clang

https://reviews.llvm.org/D53524



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


[PATCH] D53635: [CodeComplete] Expose InBaseClass signal in code completion results.

2018-10-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Sema/CodeCompleteConsumer.cpp:557
+  if (!Tags.empty())
+OS << " (" << llvm::join(Tags, ",") << ")";
+  if (CodeCompletionString *CCS = Results[I].CreateCodeCompletionString(

ioeric wrote:
> ilya-biryukov wrote:
> > NIT: Maybe add a space between the items, i.e. join with `", "` as a 
> > separator?
> Considering we put everything in one line, I think it's reasonable to drop 
> the spaces to keep the output compact. These tags are more expected to be 
> read by tests than human after all.
I would argue this output is also read by humans, therefore we should add a 
space.
We do "grep" the results with FileCheck in tests and technically it does not 
matter if we have a space or not. But the users still look at the output when 
(1) something goes wrong or (2) they read through the test cases.


Repository:
  rL LLVM

https://reviews.llvm.org/D53635



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


[PATCH] D53641: [clangd] Remove didOpen extraFlags extension.

2018-10-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks for cleaning this up.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53641



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


  1   2   3   >