[PATCH] D25669: [Driver] Simplify ToolChain::GetCXXStdlibType (NFC)

2016-12-12 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289422: [Driver] Simplify ToolChain::GetCXXStdlibType (NFC) 
(authored by Hahnfeld).

Changed prior to commit:
  https://reviews.llvm.org/D25669?vs=74948&id=81053#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25669

Files:
  cfe/trunk/lib/Driver/ToolChain.cpp


Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -542,7 +542,7 @@
   const Arg* A = Args.getLastArg(options::OPT_rtlib_EQ);
   StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_RTLIB;
 
-  // "platform" is only used in tests to override CLANG_DEFAULT_RTLIB
+  // Only use "platform" in tests to override CLANG_DEFAULT_RTLIB!
   if (LibName == "compiler-rt")
 return ToolChain::RLT_CompilerRT;
   else if (LibName == "libgcc")
@@ -556,43 +556,22 @@
   return GetDefaultRuntimeLibType();
 }
 
-static bool ParseCXXStdlibType(const StringRef& Name,
-   ToolChain::CXXStdlibType& Type) {
-  if (Name == "libc++")
-Type = ToolChain::CST_Libcxx;
-  else if (Name == "libstdc++")
-Type = ToolChain::CST_Libstdcxx;
-  else
-return false;
-
-  return true;
-}
-
 ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) 
const{
-  ToolChain::CXXStdlibType Type;
-  bool HasValidType = false;
-  bool ForcePlatformDefault = false;
-
   const Arg *A = Args.getLastArg(options::OPT_stdlib_EQ);
-  if (A) {
-StringRef Value = A->getValue();
-HasValidType = ParseCXXStdlibType(Value, Type);
-
-// Only use in tests to override CLANG_DEFAULT_CXX_STDLIB!
-if (Value == "platform")
-  ForcePlatformDefault = true;
-else if (!HasValidType)
-  getDriver().Diag(diag::err_drv_invalid_stdlib_name)
-<< A->getAsString(Args);
-  }
-
-  // If no argument was provided or its value was invalid, look for the
-  // default unless forced or configured to take the platform default.
-  if (!HasValidType && (ForcePlatformDefault ||
-  !ParseCXXStdlibType(CLANG_DEFAULT_CXX_STDLIB, Type)))
-Type = GetDefaultCXXStdlibType();
+  StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_CXX_STDLIB;
+
+  // Only use "platform" in tests to override CLANG_DEFAULT_CXX_STDLIB!
+  if (LibName == "libc++")
+return ToolChain::CST_Libcxx;
+  else if (LibName == "libstdc++")
+return ToolChain::CST_Libstdcxx;
+  else if (LibName == "platform")
+return GetDefaultCXXStdlibType();
+
+  if (A)
+getDriver().Diag(diag::err_drv_invalid_stdlib_name) << 
A->getAsString(Args);
 
-  return Type;
+  return GetDefaultCXXStdlibType();
 }
 
 /// \brief Utility function to add a system include directory to CC1 arguments.


Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -542,7 +542,7 @@
   const Arg* A = Args.getLastArg(options::OPT_rtlib_EQ);
   StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_RTLIB;
 
-  // "platform" is only used in tests to override CLANG_DEFAULT_RTLIB
+  // Only use "platform" in tests to override CLANG_DEFAULT_RTLIB!
   if (LibName == "compiler-rt")
 return ToolChain::RLT_CompilerRT;
   else if (LibName == "libgcc")
@@ -556,43 +556,22 @@
   return GetDefaultRuntimeLibType();
 }
 
-static bool ParseCXXStdlibType(const StringRef& Name,
-   ToolChain::CXXStdlibType& Type) {
-  if (Name == "libc++")
-Type = ToolChain::CST_Libcxx;
-  else if (Name == "libstdc++")
-Type = ToolChain::CST_Libstdcxx;
-  else
-return false;
-
-  return true;
-}
-
 ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{
-  ToolChain::CXXStdlibType Type;
-  bool HasValidType = false;
-  bool ForcePlatformDefault = false;
-
   const Arg *A = Args.getLastArg(options::OPT_stdlib_EQ);
-  if (A) {
-StringRef Value = A->getValue();
-HasValidType = ParseCXXStdlibType(Value, Type);
-
-// Only use in tests to override CLANG_DEFAULT_CXX_STDLIB!
-if (Value == "platform")
-  ForcePlatformDefault = true;
-else if (!HasValidType)
-  getDriver().Diag(diag::err_drv_invalid_stdlib_name)
-<< A->getAsString(Args);
-  }
-
-  // If no argument was provided or its value was invalid, look for the
-  // default unless forced or configured to take the platform default.
-  if (!HasValidType && (ForcePlatformDefault ||
-  !ParseCXXStdlibType(CLANG_DEFAULT_CXX_STDLIB, Type)))
-Type = GetDefaultCXXStdlibType();
+  StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_CXX_STDLIB;
+
+  // Only use "platform" in tests to override CLANG_DEFAULT_CXX_STDLIB!
+  if (LibName == "libc++")
+return ToolChain::CST_Libcxx;
+  else if (LibName == "libstdc++")
+return ToolChain::CST_Libstdcxx;
+  else if (LibName == "platform")
+return GetDefaultCXXStdlibTyp

r289422 - [Driver] Simplify ToolChain::GetCXXStdlibType (NFC)

2016-12-12 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Mon Dec 12 01:53:47 2016
New Revision: 289422

URL: http://llvm.org/viewvc/llvm-project?rev=289422&view=rev
Log:
[Driver] Simplify ToolChain::GetCXXStdlibType (NFC)

I made the wrong assumption that execution would continue after an error Diag
which led to unneeded complex code.
This patch aligns with the better implementation of 
ToolChain::GetRuntimeLibType.

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

Modified:
cfe/trunk/lib/Driver/ToolChain.cpp

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=289422&r1=289421&r2=289422&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Dec 12 01:53:47 2016
@@ -542,7 +542,7 @@ ToolChain::RuntimeLibType ToolChain::Get
   const Arg* A = Args.getLastArg(options::OPT_rtlib_EQ);
   StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_RTLIB;
 
-  // "platform" is only used in tests to override CLANG_DEFAULT_RTLIB
+  // Only use "platform" in tests to override CLANG_DEFAULT_RTLIB!
   if (LibName == "compiler-rt")
 return ToolChain::RLT_CompilerRT;
   else if (LibName == "libgcc")
@@ -556,43 +556,22 @@ ToolChain::RuntimeLibType ToolChain::Get
   return GetDefaultRuntimeLibType();
 }
 
-static bool ParseCXXStdlibType(const StringRef& Name,
-   ToolChain::CXXStdlibType& Type) {
-  if (Name == "libc++")
-Type = ToolChain::CST_Libcxx;
-  else if (Name == "libstdc++")
-Type = ToolChain::CST_Libstdcxx;
-  else
-return false;
-
-  return true;
-}
-
 ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) 
const{
-  ToolChain::CXXStdlibType Type;
-  bool HasValidType = false;
-  bool ForcePlatformDefault = false;
-
   const Arg *A = Args.getLastArg(options::OPT_stdlib_EQ);
-  if (A) {
-StringRef Value = A->getValue();
-HasValidType = ParseCXXStdlibType(Value, Type);
-
-// Only use in tests to override CLANG_DEFAULT_CXX_STDLIB!
-if (Value == "platform")
-  ForcePlatformDefault = true;
-else if (!HasValidType)
-  getDriver().Diag(diag::err_drv_invalid_stdlib_name)
-<< A->getAsString(Args);
-  }
-
-  // If no argument was provided or its value was invalid, look for the
-  // default unless forced or configured to take the platform default.
-  if (!HasValidType && (ForcePlatformDefault ||
-  !ParseCXXStdlibType(CLANG_DEFAULT_CXX_STDLIB, Type)))
-Type = GetDefaultCXXStdlibType();
+  StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_CXX_STDLIB;
+
+  // Only use "platform" in tests to override CLANG_DEFAULT_CXX_STDLIB!
+  if (LibName == "libc++")
+return ToolChain::CST_Libcxx;
+  else if (LibName == "libstdc++")
+return ToolChain::CST_Libstdcxx;
+  else if (LibName == "platform")
+return GetDefaultCXXStdlibType();
+
+  if (A)
+getDriver().Diag(diag::err_drv_invalid_stdlib_name) << 
A->getAsString(Args);
 
-  return Type;
+  return GetDefaultCXXStdlibType();
 }
 
 /// \brief Utility function to add a system include directory to CC1 arguments.


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


[PATCH] D24933: Enable configuration files in clang

2016-12-12 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 81055.
sepavloff marked 4 inline comments as done.
sepavloff added a comment.

Updated patch.

- Directories which are searched for config files are now defined during 
project configuration process using special cmake options.
- Driver do not warn on unused arguments that come from config file.


https://reviews.llvm.org/D24933

Files:
  docs/UsersManual.rst
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Config/config.h.cmake
  include/clang/Driver/Driver.h
  lib/Driver/Driver.cpp
  test/Driver/Inputs/config-1.cfg
  test/Driver/Inputs/config-2.cfg
  test/Driver/Inputs/config-2a.cfg
  test/Driver/Inputs/config-3.cfg
  test/Driver/Inputs/config-4.cfg
  test/Driver/Inputs/config-5.cfg
  test/Driver/Inputs/config/config-4.cfg
  test/Driver/config-file.c
  test/Driver/config-file2.c
  test/Driver/lit.local.cfg
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -305,6 +305,41 @@
   return 1;
 }
 
+// Directories searched for configuration specified by option '--config'.
+static const ArrayRef SearchDirs = {
+#if defined(CLANG_CONFIG_FILE_USER_DIR)
+  CLANG_CONFIG_FILE_USER_DIR,
+#endif
+#if defined(CLANG_CONFIG_FILE_SYSTEM_DIR)
+  CLANG_CONFIG_FILE_SYSTEM_DIR
+#endif
+};
+
+/// Deduce configuration name if it is encoded in the executable name.
+///
+/// \param ConfigFile [out] Is assigned configuration file path.
+/// \param ProgramName [in] clang executable path.
+/// \return True if configuration file was found.
+///
+/// If clang executable is named e.g. 'armv7l-clang' the function tries to
+/// find config file 'armv7l.cfg'. If it is found, its path is put into
+/// ConfigFile and the function returns true.
+///
+static bool findConfigFileFromProgramName(
+llvm::SmallVectorImpl &ConfigFile, StringRef ProgramName) {
+  ConfigFile.clear();
+  StringRef PName = llvm::sys::path::stem(ProgramName);
+  size_t Pos = PName.find("-clang");
+  if (Pos != StringRef::npos) {
+ConfigFile.append(PName.begin(), PName.begin() + Pos);
+const StringRef Ext(".cfg");
+ConfigFile.append(Ext.begin(), Ext.end());
+std::string CName(ConfigFile.begin(), ConfigFile.size());
+return llvm::cl::searchForFile(ConfigFile, SearchDirs, ProgramName, CName);
+  }
+  return false;
+}
+
 int main(int argc_, const char **argv_) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv_[0]);
   llvm::PrettyStackTraceProgram X(argc_, argv_);
@@ -330,6 +365,31 @@
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
 
+  // Try reading options from configuration file.
+  llvm::SmallString<128> ConfigFile;
+  llvm::cl::SearchResult SRes;
+
+  // First try config file specified in command line. It has higher priority
+  // than any other way to specify configuration.
+  SRes = llvm::cl::findConfigFileFromArgs(ConfigFile, argv, SearchDirs, true);
+  if (llvm::cl::checkConfigFileSearchResult(SRes, ConfigFile, SearchDirs, true,
+ProgName))
+return 1;
+
+  // If config file is not specified explicitly, try to determine configuration
+  // implicitly. First try to deduce configuration from executable name. For
+  // instance, a file 'armv7l-clang' applies config file 'armv7l.cfg'. Second,
+  // try to find file 'clang.cfg'.
+  if (SRes == llvm::cl::SearchResult::NotSpecified) {
+if (findConfigFileFromProgramName(ConfigFile, ProgName))
+  SRes = llvm::cl::SearchResult::Successful;
+  }
+
+  // If config file is found, read options from it.
+  unsigned NumConfigOptions = 0;
+  if (SRes == llvm::cl::SearchResult::Successful)
+llvm::cl::readConfigFile(ConfigFile, Saver, argv, NumConfigOptions);
+
   // Parse response files using the GNU syntax, unless we're in CL mode. There
   // are two ways to put clang in CL compatibility mode: argv[0] is either
   // clang-cl or cl, or --driver-mode=cl is on the command line. The normal
@@ -400,8 +460,12 @@
   SmallVector PrependedOpts;
   getCLEnvVarOptions(OptCL.getValue(), Saver, PrependedOpts);
 
-  // Insert right after the program name to prepend to the argument list.
-  argv.insert(argv.begin() + 1, PrependedOpts.begin(), PrependedOpts.end());
+  // Insert right after the program name to prepend to the argument list. If
+  // there are options read from config file, put the options from "CL"
+  // after them, - config file is considered as a "patch" to compiler
+  // defaults.
+  argv.insert(argv.begin() + 1 + NumConfigOptions,
+  PrependedOpts.begin(), PrependedOpts.end());
 }
 // Arguments in "_CL_" are appended.
 llvm::Optional Opt_CL_ = llvm::sys::Process::GetEnv("_CL_");
@@ -446,6 +510,8 @@
   ProcessWarningOptions(Diags, *DiagOpts, /*ReportDiags=*/false);
 
   Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags);
+  if (!ConfigFile.empty())
+TheDriver.setConfi

[PATCH] D24933: Enable configuration files in clang

2016-12-12 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: lib/Driver/Driver.cpp:2695
 
+  // Claim all arguments that come from configuration file, - driver must not
+  // warn about unused argument on them.

Grammar here is a bit odd, how about:

  // Claim all arguments that come from a configuration file so that the driver 
does not warn on any that are unused.


https://reviews.llvm.org/D24933



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


[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples

2016-12-12 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

We already massage the triple in many cases, and what goes into IR is not 
always the same as what is used in Clang.

Examples are x86_64's "x32" extension to the ABI, ARM -> Thumb triples, adding 
compulsory dashes and unknowns (ex. x86_64--linux-gnu), etc.

You just have to find the right places.


https://reviews.llvm.org/D25686



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-12 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

The fixit construction looks overly complicated.
All you need to do is change a `,` to a `;` and insert a copy of the type:

  << FixItHint::CreateReplacement(CommaRange, ";")
  << FixItHint::CreateInsertionFromRange(VarLocation, TypeRange)

and insert some whitespace where needed.


https://reviews.llvm.org/D27621



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


[PATCH] D26887: [Driver] Fix finding multilib gcc install on Gentoo (with gcc-config)

2016-12-12 Thread Renato Golin via Phabricator via cfe-commits
rengolin resigned from this revision.
rengolin removed a reviewer: rengolin.
rengolin added a comment.

I don't know enough about x86_64's ABI to have a solid opinion.


https://reviews.llvm.org/D26887



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


[PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-12 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/misc/StringCompareCheck.cpp:25
+  callee(cxxMethodDecl(hasName("compare"),
+   ofClass(classTemplateSpecializationDecl(
+   hasName("::std::basic_string"),

malcolm.parsons wrote:
> malcolm.parsons wrote:
> > This needs to check that it's one of the single parameter overloads of 
> > compare.
> Add `parameterCountIs(1)`.
Actually, the `argumentCountIs(1)` below should be sufficient.


https://reviews.llvm.org/D27210



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


[PATCH] D24933: Enable configuration files in clang

2016-12-12 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 81057.
sepavloff added a comment.

Fixed grammar in comment, thanks to Hal Finkel.


https://reviews.llvm.org/D24933

Files:
  docs/UsersManual.rst
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Config/config.h.cmake
  include/clang/Driver/Driver.h
  lib/Driver/Driver.cpp
  test/Driver/Inputs/config-1.cfg
  test/Driver/Inputs/config-2.cfg
  test/Driver/Inputs/config-2a.cfg
  test/Driver/Inputs/config-3.cfg
  test/Driver/Inputs/config-4.cfg
  test/Driver/Inputs/config-5.cfg
  test/Driver/Inputs/config/config-4.cfg
  test/Driver/config-file.c
  test/Driver/config-file2.c
  test/Driver/lit.local.cfg
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -305,6 +305,41 @@
   return 1;
 }
 
+// Directories searched for configuration specified by option '--config'.
+static const ArrayRef SearchDirs = {
+#if defined(CLANG_CONFIG_FILE_USER_DIR)
+  CLANG_CONFIG_FILE_USER_DIR,
+#endif
+#if defined(CLANG_CONFIG_FILE_SYSTEM_DIR)
+  CLANG_CONFIG_FILE_SYSTEM_DIR
+#endif
+};
+
+/// Deduce configuration name if it is encoded in the executable name.
+///
+/// \param ConfigFile [out] Is assigned configuration file path.
+/// \param ProgramName [in] clang executable path.
+/// \return True if configuration file was found.
+///
+/// If clang executable is named e.g. 'armv7l-clang' the function tries to
+/// find config file 'armv7l.cfg'. If it is found, its path is put into
+/// ConfigFile and the function returns true.
+///
+static bool findConfigFileFromProgramName(
+llvm::SmallVectorImpl &ConfigFile, StringRef ProgramName) {
+  ConfigFile.clear();
+  StringRef PName = llvm::sys::path::stem(ProgramName);
+  size_t Pos = PName.find("-clang");
+  if (Pos != StringRef::npos) {
+ConfigFile.append(PName.begin(), PName.begin() + Pos);
+const StringRef Ext(".cfg");
+ConfigFile.append(Ext.begin(), Ext.end());
+std::string CName(ConfigFile.begin(), ConfigFile.size());
+return llvm::cl::searchForFile(ConfigFile, SearchDirs, ProgramName, CName);
+  }
+  return false;
+}
+
 int main(int argc_, const char **argv_) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv_[0]);
   llvm::PrettyStackTraceProgram X(argc_, argv_);
@@ -330,6 +365,31 @@
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
 
+  // Try reading options from configuration file.
+  llvm::SmallString<128> ConfigFile;
+  llvm::cl::SearchResult SRes;
+
+  // First try config file specified in command line. It has higher priority
+  // than any other way to specify configuration.
+  SRes = llvm::cl::findConfigFileFromArgs(ConfigFile, argv, SearchDirs, true);
+  if (llvm::cl::checkConfigFileSearchResult(SRes, ConfigFile, SearchDirs, true,
+ProgName))
+return 1;
+
+  // If config file is not specified explicitly, try to determine configuration
+  // implicitly. First try to deduce configuration from executable name. For
+  // instance, a file 'armv7l-clang' applies config file 'armv7l.cfg'. Second,
+  // try to find file 'clang.cfg'.
+  if (SRes == llvm::cl::SearchResult::NotSpecified) {
+if (findConfigFileFromProgramName(ConfigFile, ProgName))
+  SRes = llvm::cl::SearchResult::Successful;
+  }
+
+  // If config file is found, read options from it.
+  unsigned NumConfigOptions = 0;
+  if (SRes == llvm::cl::SearchResult::Successful)
+llvm::cl::readConfigFile(ConfigFile, Saver, argv, NumConfigOptions);
+
   // Parse response files using the GNU syntax, unless we're in CL mode. There
   // are two ways to put clang in CL compatibility mode: argv[0] is either
   // clang-cl or cl, or --driver-mode=cl is on the command line. The normal
@@ -400,8 +460,12 @@
   SmallVector PrependedOpts;
   getCLEnvVarOptions(OptCL.getValue(), Saver, PrependedOpts);
 
-  // Insert right after the program name to prepend to the argument list.
-  argv.insert(argv.begin() + 1, PrependedOpts.begin(), PrependedOpts.end());
+  // Insert right after the program name to prepend to the argument list. If
+  // there are options read from config file, put the options from "CL"
+  // after them, - config file is considered as a "patch" to compiler
+  // defaults.
+  argv.insert(argv.begin() + 1 + NumConfigOptions,
+  PrependedOpts.begin(), PrependedOpts.end());
 }
 // Arguments in "_CL_" are appended.
 llvm::Optional Opt_CL_ = llvm::sys::Process::GetEnv("_CL_");
@@ -446,6 +510,8 @@
   ProcessWarningOptions(Diags, *DiagOpts, /*ReportDiags=*/false);
 
   Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags);
+  if (!ConfigFile.empty())
+TheDriver.setConfigFile(ConfigFile.str(), NumConfigOptions);
   SetInstallDir(argv, TheDriver, CanonicalPrefixes);
 
   insertTargetAndModeArgs(TargetAndMode.first, TargetAndMode.second, argv,
Index: test/Driver/lit.local.cfg
==

[PATCH] D23610: [ARM] Add pre-defined macros for ROPI, RWPI and FPIC

2016-12-12 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

Was this abandoned?


Repository:
  rL LLVM

https://reviews.llvm.org/D23610



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


[PATCH] D16901: [Clang driver, ARM] Do not add +long-calls in PIC mode

2016-12-12 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

Was this abandoned?


Repository:
  rL LLVM

https://reviews.llvm.org/D16901



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


[PATCH] D24083: [CMake] Fix libc++abi __aeabi_idiv() link error.

2016-12-12 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

Was this abandoned? Merged?


https://reviews.llvm.org/D24083



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


[PATCH] D24084: [CMake] Cleanup libunwind lookup code.

2016-12-12 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

So, we found this issue with the different unwinds between Clang and libunwind:

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

Is this related?


https://reviews.llvm.org/D24084



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


[PATCH] D27576: [libcxx] libc++ changes necessary for the externally threaded libcxxabi variant

2016-12-12 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath added inline comments.



Comment at: include/__threading_support:193
+// Execute once
+int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
+  void (*init_routine)(void)) {

EricWF wrote:
> These should have `inline`. In fact all of the functions in this header must 
> be declared inline but have not been.
Actually, all the declarations on this header have 
`_LIBCPP_THREAD_ABI_VISIBILITY` , which includes the `inline` modifier. I've 
forgotten to include any context with this patch though, that might've made it 
bit unclear.


https://reviews.llvm.org/D27576



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


[PATCH] D27576: [libcxx] libc++ changes necessary for the externally threaded libcxxabi variant

2016-12-12 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath updated this revision to Diff 81059.

https://reviews.llvm.org/D27576

Files:
  CMakeLists.txt
  include/__threading_support
  test/CMakeLists.txt
  test/libcxx/test/config.py
  test/lit.site.cfg.in

Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -28,7 +28,7 @@
 config.use_libatomic= "@LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB@"
 
 config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@"
-config.libcxx_external_thread_api  = "@LIBCXX_HAS_EXTERNAL_THREAD_API@"
+config.cxx_ext_threads  = "@LIBCXX_HAS_EXTERNAL_THREAD_API@"
 
 # Let the main config do the real work.
 config.loaded_site_config = True
Index: test/libcxx/test/config.py
===
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -576,10 +576,6 @@
 self.cxx.link_flags += [abs_path]
 else:
 self.cxx.link_flags += ['-lc++']
-# This needs to come after -lc++ as we want its unresolved thread-api symbols
-# to be picked up from this one.
-if self.get_lit_bool('libcxx_external_thread_api', default=False):
-self.cxx.link_flags += ['-lc++external_threads']
 
 def configure_link_flags_abi_library(self):
 cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi')
@@ -608,6 +604,8 @@
 'C++ ABI setting %s unsupported for tests' % cxx_abi)
 
 def configure_extra_library_flags(self):
+if self.get_lit_bool('cxx_ext_threads', default=False):
+self.cxx.link_flags += ['-lc++external_threads']
 self.target_info.add_cxx_link_flags(self.cxx.link_flags)
 
 def configure_color_diagnostics(self):
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -56,17 +56,19 @@
   @ONLY)
 
 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
-  set(experimental_dep cxx_experimental)
+  set(LIBCXX_TEST_DEPS cxx_experimental)
+else()
+  set(LIBCXX_TEST_DEPS "")
 endif()
 
 if (LIBCXX_HAS_EXTERNAL_THREAD_API)
-  set(external_threads_dep cxx_external_threads)
+  list(APPEND LIBCXX_TEST_DEPS cxx_external_threads)
 endif()
 
 add_lit_testsuite(check-cxx
   "Running libcxx tests"
   ${CMAKE_CURRENT_BINARY_DIR}
-  DEPENDS cxx ${experimental_dep} ${external_threads_dep})
+  DEPENDS cxx ${LIBCXX_TEST_DEPS})
 
 add_custom_target(check-libcxx DEPENDS check-cxx)
 
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -71,7 +71,20 @@
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
 
+// Execute once
+typedef pthread_once_t __libcpp_exec_once_flag;
+#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
+  void (*init_routine)(void));
+
 // Thread id
+#if defined(__APPLE__) && !defined(__arm__)
+_LIBCPP_THREAD_ABI_VISIBILITY
+mach_port_t __libcpp_thread_get_port();
+#endif
+
 typedef pthread_t __libcpp_thread_id;
 _LIBCPP_THREAD_ABI_VISIBILITY
 bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
@@ -100,7 +113,7 @@
 _LIBCPP_THREAD_ABI_VISIBILITY
 void* __libcpp_tls_get(__libcpp_tls_key __key);
 _LIBCPP_THREAD_ABI_VISIBILITY
-void __libcpp_tls_set(__libcpp_tls_key __key, void* __p);
+int __libcpp_tls_set(__libcpp_tls_key __key, void* __p);
 
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || defined(_LIBCPP_BUILDING_EXTERNAL_THREADS)
 
@@ -176,6 +189,19 @@
 return pthread_cond_destroy(__cv);
 }
 
+// Execute once
+int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
+  void (*init_routine)(void)) {
+  return pthread_once(flag, init_routine);
+}
+
+// Thread id
+#if defined(__APPLE__) && !defined(__arm__)
+mach_port_t __libcpp_thread_get_port() {
+return pthread_mach_thread_np(pthread_self());
+}
+#endif
+
 // Returns non-zero if the thread ids are equal, otherwise 0
 bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
 {
@@ -230,9 +256,9 @@
 return pthread_getspecific(__key);
 }
 
-void __libcpp_tls_set(__libcpp_tls_key __key, void* __p)
+int __libcpp_tls_set(__libcpp_tls_key __key, void* __p)
 {
-pthread_setspecific(__key, __p);
+return pthread_setspecific(__key, __p);
 }
 
 #endif // _LIBCPP_HAS_THREAD_API_PTHREAD || _LIBCPP_BUILDING_EXTERNAL_THREADS
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -211,14 +211,21 @@
   " when LIBCXX_ENABLE_THREADS is also set to OFF.")
 endif()
 
-if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS)
-  message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"
-  

[PATCH] D27473: Bring back note about not supporting global register variables

2016-12-12 Thread Renato Golin via Phabricator via cfe-commits
rengolin accepted this revision.
rengolin added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


https://reviews.llvm.org/D27473



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


Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-12 Thread Mads Ravn via cfe-commits
Hi Malcolm,

I will look into fixing the two cases only.
argumentCountIs(1) is sufficient to narrow the matching to only string
compare with one argument.

Best regards,
Mads Ravn

On Mon, Dec 12, 2016 at 10:38 AM Malcolm Parsons via Phabricator <
revi...@reviews.llvm.org> wrote:

> malcolm.parsons added inline comments.
>
>
> 
> Comment at: clang-tidy/misc/StringCompareCheck.cpp:25
> +  callee(cxxMethodDecl(hasName("compare"),
> +   ofClass(classTemplateSpecializationDecl(
> +   hasName("::std::basic_string"),
> 
> malcolm.parsons wrote:
> > malcolm.parsons wrote:
> > > This needs to check that it's one of the single parameter overloads of
> compare.
> > Add `parameterCountIs(1)`.
> Actually, the `argumentCountIs(1)` below should be sufficient.
>
>
> https://reviews.llvm.org/D27210
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27575: [libcxxabi] Introduce an externally threaded libc++abi variant (take-2)

2016-12-12 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath added inline comments.



Comment at: CMakeLists.txt:121
 option(LIBCXXABI_HAS_PTHREAD_API "Ignore auto-detection and force use of 
pthread API" OFF)
+option(LIBCXXABI_HAS_EXTERNAL_THREAD_API
+  "Build libc++abi with an externalized threading API.

EricWF wrote:
> Maybe use a dependent option that sets it to the value of 
> `LIBCXX_ENABLE_THREADS` when it is defined?
Are you referring to `CMAKE_DEPENDENT_OPTION` macro? I don't see this macro 
used anywhere else in llvm, but I suppose that's not a concern?

Although, it would have to be something like:

```
CMAKE_DEPENDENT_OPTION(LIBCXXABI_HAS_EXTERNAL_THREAD_API "Externally Threaded 
libcxxabi" OFF  "LIBCXX_ENABLE_THREADS" OFF)
```

Because, `LIBCXX_ENABLE_THREADS=ON` should not mean 
`LIBCXXABI_HAS_EXTERNAL_THREAD_API=ON`.




Comment at: src/fallback_malloc.cpp:37
 class mutexor {
 public:

EricWF wrote:
> Can't we replace this class with `std::mutex` directly?
Again, I should've included more context to the patch :(

The `mutexor` here is supposed to degrade to a nop when threading is disabled. 
I think we cannot use `std::mutex` without threading support.

Will update the patch with more context.



Comment at: test/test_exception_storage.pass.cpp:42
 size_t thread_globals [ NUMTHREADS ] = { 0 };
-__libcxxabi_thread_t   threads[ NUMTHREADS ];
+std::__libcpp_thread_t   threads[ NUMTHREADS ];
 #endif

EricWF wrote:
> What happened to the initializer?
I don't think it needs one here?

`std::__licpp_thread_create()` does not require `std::__libcpp_thread_t` 
argument to be statically initialized.


https://reviews.llvm.org/D27575



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


[PATCH] D27575: [libcxxabi] Introduce an externally threaded libc++abi variant (take-2)

2016-12-12 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath updated this revision to Diff 81062.

https://reviews.llvm.org/D27575

Files:
  CMakeLists.txt
  src/config.h
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/cxa_thread_atexit.cpp
  src/fallback_malloc.cpp
  src/threading_support.h
  test/CMakeLists.txt
  test/libcxxabi/test/config.py
  test/lit.site.cfg.in
  test/test_exception_storage.pass.cpp
  test/test_fallback_malloc.pass.cpp

Index: test/test_fallback_malloc.pass.cpp
===
--- test/test_fallback_malloc.pass.cpp
+++ test/test_fallback_malloc.pass.cpp
@@ -10,7 +10,7 @@
 #include 
 #include 
 
-#include "../src/threading_support.h"
+#include <__threading_support>
 
 typedef std::deque container;
 
Index: test/test_exception_storage.pass.cpp
===
--- test/test_exception_storage.pass.cpp
+++ test/test_exception_storage.pass.cpp
@@ -12,7 +12,7 @@
 #include 
 #include 
 #include 
-#include "../src/threading_support.h"
+#include <__threading_support>
 #include 
 
 #include "../src/cxa_exception.hpp"
@@ -39,18 +39,18 @@
 #ifndef _LIBCXXABI_HAS_NO_THREADS
 #define NUMTHREADS  10
 size_t thread_globals [ NUMTHREADS ] = { 0 };
-__libcxxabi_thread_t   threads[ NUMTHREADS ];
+std::__libcpp_thread_t   threads[ NUMTHREADS ];
 #endif
 
 int main ( int argc, char *argv [] ) {
 int retVal = 0;
 
 #ifndef _LIBCXXABI_HAS_NO_THREADS
 //  Make the threads, let them run, and wait for them to finish
 for ( int i = 0; i < NUMTHREADS; ++i )
-__libcxxabi_thread_create ( threads + i, thread_code, (void *) (thread_globals + i));
+std::__libcpp_thread_create ( threads + i, thread_code, (void *) (thread_globals + i));
 for ( int i = 0; i < NUMTHREADS; ++i )
-__libcxxabi_thread_join ( &threads [ i ] );
+std::__libcpp_thread_join ( &threads [ i ] );
 
 for ( int i = 0; i < NUMTHREADS; ++i )
 if ( 0 == thread_globals [ i ] ) {
Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -19,6 +19,7 @@
 config.host_triple  = "@LLVM_HOST_TRIPLE@"
 config.target_triple= "@TARGET_TRIPLE@"
 config.use_target   = len("@LIBCXXABI_TARGET_TRIPLE@") > 0
+config.cxx_ext_threads  = "@LIBCXXABI_HAS_EXTERNAL_THREAD_API@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBCXXABI_SOURCE_DIR@/test/lit.cfg")
Index: test/libcxxabi/test/config.py
===
--- test/libcxxabi/test/config.py
+++ test/libcxxabi/test/config.py
@@ -42,6 +42,9 @@
 self.config.available_features.add('libcxxabi-no-exceptions')
 if not self.has_cpp_feature('noexcept_function_type', 201510):
 self.config.available_features.add('libcxxabi-no-noexcept-function-type')
+# test_exception_storage_nodynmem.pass.cpp fails under this specific configuration
+if self.get_lit_bool('cxx_ext_threads', False) and self.get_lit_bool('libcxxabi_shared', False):
+self.config.available_features.add('libcxxabi-shared-externally-threaded')
 
 def configure_compile_flags(self):
 self.cxx.compile_flags += ['-DLIBCXXABI_NO_TIMER']
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -17,6 +17,7 @@
 pythonize_bool(LIBCXXABI_ENABLE_THREADS)
 pythonize_bool(LIBCXXABI_ENABLE_EXCEPTIONS)
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
+pythonize_bool(LIBCXXABI_HAS_EXTERNAL_THREAD_API)
 set(LIBCXXABI_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
 "TargetInfo to use when setting up test environment.")
 set(LIBCXXABI_EXECUTOR "None" CACHE STRING
@@ -34,6 +35,10 @@
   set(LIBCXXABI_TEST_DEPS cxxabi_static)
 endif()
 
+if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
+  list(APPEND LIBCXXABI_TEST_DEPS cxx_external_threads)
+endif()
+
 if (NOT LIBCXXABI_STANDALONE_BUILD)
   list(APPEND LIBCXXABI_TEST_DEPS cxx)
   if (LIBCXXABI_USE_LLVM_UNWINDER)
Index: src/threading_support.h
===
--- src/threading_support.h
+++ /dev/null
@@ -1,107 +0,0 @@
-//=== threading_support.h -===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifndef _LIBCXXABI_THREADING_SUPPORT_H
-#define _LIBCXXABI_THREADING_SUPPORT_H
-
-#include "__cxxabi_config.h"
-#include "config.h"
-
-#ifndef _LIBCXXABI_HAS_NO_THREADS
-
-#if defined(_LIBCXXABI_USE_THREAD_API_PTHREAD)
-#include 
-
-#define _LIBCXXABI_THREAD_ABI_VISIBILITY inl

[PATCH] D27575: [libcxxabi] Introduce an externally threaded libc++abi variant (take-2)

2016-12-12 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath added a comment.

Patch updated with more context.


https://reviews.llvm.org/D27575



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


[PATCH] D27614: Mark tests as unsupported under libcpp-no-exceptions

2016-12-12 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath added a comment.

LGTM. Needs approval from @EricWF or @mclow.lists.


https://reviews.llvm.org/D27614



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


[PATCH] D27671: [OpenCL] Improve address space diagnostics.

2016-12-12 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
echuraev added a reviewer: Anastasia.
echuraev added subscribers: cfe-commits, yaxunl, bader.

https://reviews.llvm.org/D27671

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/SemaOpenCL/invalid-kernel.cl


Index: test/SemaOpenCL/invalid-kernel.cl
===
--- test/SemaOpenCL/invalid-kernel.cl
+++ test/SemaOpenCL/invalid-kernel.cl
@@ -1,10 +1,11 @@
 // RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -verify %s
 
-kernel void no_ptrptr(global int **i) { } // expected-error{{kernel parameter 
cannot be declared as a pointer to a pointer}}
+kernel void no_ptrptr(global int * global *i) { } // expected-error{{kernel 
parameter cannot be declared as a pointer to a pointer}}
 
-__kernel void no_privateptr(__private int *i) { } // expected-error {{kernel 
parameter cannot be declared as a pointer to the __private address space}}
+__kernel void no_privateptr(__private int *i) { } // expected-error {{pointer 
arguments to kernel functions must reside in '__global', '__constant' or 
'__local' address space}}
 
-__kernel void no_privatearray(__private int i[]) { } // expected-error 
{{kernel parameter cannot be declared as a pointer to the __private address 
space}}
+__kernel void no_privatearray(__private int i[]) { } // expected-error 
{{pointer arguments to kernel functions must reside in '__global', '__constant' 
or '__local' address space}}
 
 kernel int bar()  { // expected-error {{kernel must have void return type}}
   return 6;
@@ -29,3 +30,6 @@
 int* constant x(int* x) { // expected-error {{return value cannot be qualified 
with address space}}
   return x + 1;
 }
+
+__kernel void testKernel(int *ptr) { // expected-error {{pointer arguments to 
kernel functions must reside in '__global', '__constant' or '__local' address 
space}}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7586,7 +7586,7 @@
   ValidKernelParam,
   PtrPtrKernelParam,
   PtrKernelParam,
-  PrivatePtrKernelParam,
+  InvalidAddrSpacePtrKernelParam,
   InvalidKernelParam,
   RecordKernelParam
 };
@@ -7596,8 +7596,10 @@
 QualType PointeeType = PT->getPointeeType();
 if (PointeeType->isPointerType())
   return PtrPtrKernelParam;
-return PointeeType.getAddressSpace() == 0 ? PrivatePtrKernelParam
-  : PtrKernelParam;
+if (PointeeType.getAddressSpace() == LangAS::opencl_generic ||
+PointeeType.getAddressSpace() == 0)
+  return InvalidAddrSpacePtrKernelParam;
+return PtrKernelParam;
   }
 
   // TODO: Forbid the other integer types (size_t, ptrdiff_t...) when they can
@@ -7645,11 +7647,12 @@
 D.setInvalidType();
 return;
 
-  case PrivatePtrKernelParam:
-// OpenCL v1.2 s6.9.a:
-// A kernel function argument cannot be declared as a
-// pointer to the private address space.
-S.Diag(Param->getLocation(), diag::err_opencl_private_ptr_kernel_param);
+  case InvalidAddrSpacePtrKernelParam:
+// OpenCL v1.0 s6.5:
+// __kernel function arguments declared to be a pointer of a type can point
+// to one of the following address spaces only : __global, __local or
+// __constant.
+S.Diag(Param->getLocation(), diag::err_kernel_arg_address_space);
 D.setInvalidType();
 return;
 
@@ -7736,7 +7739,7 @@
   // do not allow OpenCL objects to be passed as elements of the struct or
   // union.
   if (ParamType == PtrKernelParam || ParamType == PtrPtrKernelParam ||
-  ParamType == PrivatePtrKernelParam) {
+  ParamType == InvalidAddrSpacePtrKernelParam) {
 S.Diag(Param->getLocation(),
diag::err_record_with_pointers_kernel_param)
   << PT->isUnionType()
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8076,8 +8076,9 @@
   "kernel functions cannot be declared static">;
 def err_opencl_ptrptr_kernel_param : Error<
   "kernel parameter cannot be declared as a pointer to a pointer">;
-def err_opencl_private_ptr_kernel_param : Error<
-  "kernel parameter cannot be declared as a pointer to the __private address 
space">;
+def err_kernel_arg_address_space : Error<
+  "pointer arguments to kernel functions must reside in '__global', "
+  "'__constant' or '__local' address space">;
 def err_opencl_function_variable : Error<
   "%select{non-kernel function|function scope}0 variable cannot be declared in 
%1 address space">;
 def err_static_function_scope : Error<


Index: test/SemaOpenCL/invalid-kernel.cl
===
--- test/SemaOpenCL/invalid-kernel.cl
+++ test/SemaOpenCL/invalid-kernel.cl
@@ -1,10 +1,11 @@
 // RUN: %clang_cc1 -ver

r289428 - clang-format: Separate out a language kind for ObjC.

2016-12-12 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Dec 12 06:42:29 2016
New Revision: 289428

URL: http://llvm.org/viewvc/llvm-project?rev=289428&view=rev
Log:
clang-format: Separate out a language kind for ObjC.

While C(++) and ObjC are generally formatted the same way and can be
mixed, people might want to choose different styles based on the
language. This patch recognizes .m and .mm files as ObjC and also
implements a very crude detection of whether or not a .h file contains
ObjC code. This can be improved over time.

Also move most of the ObjC tests into their own test file to keep file
size maintainable.

Added:
cfe/trunk/unittests/Format/FormatTestObjC.cpp
Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/FormatTokenLexer.cpp
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/tools/clang-format/ClangFormat.cpp
cfe/trunk/unittests/Format/CMakeLists.txt
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Tooling/ReplacementTest.h

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=289428&r1=289427&r2=289428&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Mon Dec 12 06:42:29 2016
@@ -465,6 +465,8 @@ struct FormatStyle {
 LK_Java,
 /// Should be used for JavaScript.
 LK_JavaScript,
+/// Should be used for ObjC code.
+LK_ObjC,
 /// Should be used for Protocol Buffers
 /// (https://developers.google.com/protocol-buffers/).
 LK_Proto,
@@ -852,13 +854,16 @@ extern const char *StyleOptionHelpDescri
 /// == "file".
 /// \param[in] FallbackStyle The name of a predefined style used to fallback to
 /// in case the style can't be determined from \p StyleName.
+/// \param[in] Code The actual code to be formatted. Used to determine the
+/// language if the filename isn't sufficient.
 /// \param[in] FS The underlying file system, in which the file resides. By
 /// default, the file system is the real file system.
 ///
 /// \returns FormatStyle as specified by ``StyleName``. If no style could be
 /// determined, the default is LLVM Style (see ``getLLVMStyle()``).
 FormatStyle getStyle(StringRef StyleName, StringRef FileName,
- StringRef FallbackStyle, vfs::FileSystem *FS = nullptr);
+ StringRef FallbackStyle, StringRef Code = "",
+ vfs::FileSystem *FS = nullptr);
 
 // \brief Returns a string representation of ``Language``.
 inline StringRef getLanguageName(FormatStyle::LanguageKind Language) {

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=289428&r1=289427&r2=289428&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Dec 12 06:42:29 2016
@@ -560,6 +560,7 @@ unsigned ContinuationIndenter::addTokenO
   // and we need to avoid bin packing there.
   bool NestedBlockSpecialCase =
   Style.Language != FormatStyle::LK_Cpp &&
+  Style.Language != FormatStyle::LK_ObjC &&
   Current.is(tok::r_brace) && State.Stack.size() > 1 &&
   State.Stack[State.Stack.size() - 2].NestedBlockInlined;
   if (!NestedBlockSpecialCase)

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=289428&r1=289427&r2=289428&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Dec 12 06:42:29 2016
@@ -52,6 +52,7 @@ template <> struct ScalarEnumerationTrai
 IO.enumCase(Value, "Cpp", FormatStyle::LK_Cpp);
 IO.enumCase(Value, "Java", FormatStyle::LK_Java);
 IO.enumCase(Value, "JavaScript", FormatStyle::LK_JavaScript);
+IO.enumCase(Value, "ObjC", FormatStyle::LK_ObjC);
 IO.enumCase(Value, "Proto", FormatStyle::LK_Proto);
 IO.enumCase(Value, "TableGen", FormatStyle::LK_TableGen);
   }
@@ -623,6 +624,8 @@ FormatStyle getGoogleStyle(FormatStyle::
   } else if (Language == FormatStyle::LK_Proto) {
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
 GoogleStyle.SpacesInContainerLiterals = false;
+  } else if (Language == FormatStyle::LK_ObjC) {
+GoogleStyle.ColumnLimit = 100;
   }
 
   return GoogleStyle;
@@ -1861,6 +1864,8 @@ static FormatStyle::LanguageKind getLang
 return FormatStyle::LK_Java;
   if (FileName.endswith_lower(".js") || FileName.endswith_lower(".ts"))
 return FormatStyle::LK_JavaScript; // JavaScript or TypeScript.
+  if (FileName.endswith(".m") || FileName.endswith(".mm"))
+return FormatStyle::L

[PATCH] D27557: Update the default of the Mozilla coding style

2016-12-12 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D27557



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-12 Thread Firat Kasmis via Phabricator via cfe-commits
firolino added a comment.

In https://reviews.llvm.org/D27621#619649, @malcolm.parsons wrote:

> The fixit construction looks overly complicated.
>  All you need to do is change a `,` to a `;` and insert a copy of the type:
>
>   << FixItHint::CreateReplacement(CommaRange, ";")
>   << FixItHint::CreateInsertionFromRange(VarLocation, TypeRange)
>
>
> and insert some whitespace where needed.


I could do CommaRange = findToken(tok:comma) an do a in-place replacment and 
thus, get rid of the workaround part as well. But for the TypeRange, I didn't 
find a proper way to get only the type part. For example, 
getTypeSourceInfo()->getTypeLoc().getSourceRange() for

  const int a(1), b(2);
  int const c(3), d(4);

will be

  const int
  int

I am not able to get the qualifier as well. I even saw something in the source 
like "we do not provide SourceRange for Qualifiers...". I would like to get rid 
of getUserWrittenType, but didn't find a way. It gets also dirty for 
MemberFunctionPointers:

  int S::*p = &S::a, S::* const q = &S::a;
  const int S::*r = &S::b, S::*t;
  int const CS :: * pp = &CS::a, CS::* const qq = &CS::a;

TypeRange will be

  int S
  int S
  int const CS


https://reviews.llvm.org/D27621



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


[PATCH] D27669: [clang-move] Use appendArgumentsAdjuster for adding extra arguments

2016-12-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM, Thanks!




Comment at: clang-move/tool/ClangMoveMain.cpp:109
 OptionsParser.getSourcePathList());
+  // Add "-fparse-all-comments" compile option to make clang parse all comments
+  Tool.appendArgumentsAdjuster(tooling::getInsertArgumentAdjuster(

Nit: Missing a trailing `.`.


Repository:
  rL LLVM

https://reviews.llvm.org/D27669



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


[PATCH] D27673: [clang-move] Only move used helper declarations.

2016-12-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.
Herald added a subscriber: mgorny.

Instead of moving all the helper declarations blindly, this patch
implement an AST-based call graph solution to make clang-move only move used
helper decls to new.cc and remove unused decls in old.cc.


https://reviews.llvm.org/D27673

Files:
  clang-move/CMakeLists.txt
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/UsedHelperDeclFinder.cpp
  clang-move/UsedHelperDeclFinder.h
  test/clang-move/Inputs/helper_decls_test.cpp
  test/clang-move/Inputs/helper_decls_test.h
  test/clang-move/Inputs/multiple_class_test.cpp
  test/clang-move/move-multiple-classes.cpp
  test/clang-move/move-used-helper-decls.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -73,13 +73,21 @@
   "\n"
   "// comment5\n"
   "// comment5\n"
-  "void Foo::f() { f1(); }\n"
+  "void Foo::f() {\n"
+  "  f1();\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
+  "}\n"
   "\n"
   "/\n"
   "// comment //\n"
   "/\n"
   "int Foo::b = 2;\n"
   "int Foo2::f() {\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
   "  f1();\n"
   "  return 1;\n"
   "}\n"
@@ -119,6 +127,9 @@
   "}\n"
   "\n"
   "int Foo2::f() {\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
   "  f1();\n"
   "  return 1;\n"
   "}\n"
@@ -154,6 +165,7 @@
  "namespace {\n"
  "// comment1.\n"
  "void f1() {}\n"
+ "\n"
  "/// comment2.\n"
  "int kConstInt1 = 0;\n"
  "} // namespace\n"
@@ -170,7 +182,12 @@
  "\n"
  "// comment5\n"
  "// comment5\n"
- "void Foo::f() { f1(); }\n"
+ "void Foo::f() {\n"
+ "  f1();\n"
+ "  kConstInt1;\n"
+ "  kConstInt2;\n"
+ "  help();\n"
+ "}\n"
  "\n"
  "/\n"
  "// comment //\n"
Index: test/clang-move/move-used-helper-decls.cpp
===
--- /dev/null
+++ test/clang-move/move-used-helper-decls.cpp
@@ -0,0 +1,130 @@
+// RUN: mkdir -p %T/used-helper-decls
+// RUN: cp %S/Inputs/helper_decls_test*  %T/used-helper-decls/
+// RUN: cd %T/used-helper-decls
+
+// RUN: clang-move -names="a::Class1" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CLASS1-CPP %s
+// RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-CLASS1-CPP %s
+
+// CHECK-NEW-CLASS1-CPP: #include "{{.*}}new_helper_decls_test.h"
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: namespace {
+// CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun1() {}
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun2() { HelperFun1(); }
+// CHECK-NEW-CLASS1-CPP-NEXT: } // namespace
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: namespace a {
+// CHECK-NEW-CLASS1-CPP-NEXT: void Class1::f() { HelperFun2(); }
+// CHECK-NEW-CLASS1-CPP-NEXT: } // namespace a
+//
+// CHECK-OLD-CLASS1-CPP: void HelperFun1() {}
+// CHECK-OLD-CLASS1-CPP-NOT: void HelperFun2() { HelperFun1(); }
+// CHECK-OLD-CLASS1-CPP-NOT: void Class1::f() { HelperFun2(); }
+// CHECK-OLD-CLASS1-CPP: void Class2::f() {
+// CHECK-OLD-CLASS1-CPP:   HelperFun1();
+
+// RUN: cp %S/Inputs/helper_decls_te

[PATCH] D27674: [StaticAnalysis] Remove unnecessary parameter in CallGraphNode::addCallee.

2016-12-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: bkramer.
hokein added subscribers: ioeric, cfe-commits.

Remove the CallGraph in addCallee as it is not used in addCallee.
It decouples addCallee from CallGraph, so that we can use CallGraphNode
within our customized CallGraph.


https://reviews.llvm.org/D27674

Files:
  include/clang/Analysis/CallGraph.h
  lib/Analysis/CallGraph.cpp


Index: lib/Analysis/CallGraph.cpp
===
--- lib/Analysis/CallGraph.cpp
+++ lib/Analysis/CallGraph.cpp
@@ -55,7 +55,7 @@
   void addCalledDecl(Decl *D) {
 if (G->includeInGraph(D)) {
   CallGraphNode *CalleeNode = G->getOrInsertNode(D);
-  CallerNode->addCallee(CalleeNode, G);
+  CallerNode->addCallee(CalleeNode);
 }
   }
 
@@ -154,7 +154,7 @@
   Node = llvm::make_unique(F);
   // Make Root node a parent of all functions to make sure all are reachable.
   if (F)
-Root->addCallee(Node.get(), this);
+Root->addCallee(Node.get());
   return Node.get();
 }
 
Index: include/clang/Analysis/CallGraph.h
===
--- include/clang/Analysis/CallGraph.h
+++ include/clang/Analysis/CallGraph.h
@@ -157,7 +157,7 @@
   inline bool empty() const {return CalledFunctions.empty(); }
   inline unsigned size() const {return CalledFunctions.size(); }
 
-  void addCallee(CallGraphNode *N, CallGraph *CG) {
+  void addCallee(CallGraphNode *N) {
 CalledFunctions.push_back(N);
   }
 


Index: lib/Analysis/CallGraph.cpp
===
--- lib/Analysis/CallGraph.cpp
+++ lib/Analysis/CallGraph.cpp
@@ -55,7 +55,7 @@
   void addCalledDecl(Decl *D) {
 if (G->includeInGraph(D)) {
   CallGraphNode *CalleeNode = G->getOrInsertNode(D);
-  CallerNode->addCallee(CalleeNode, G);
+  CallerNode->addCallee(CalleeNode);
 }
   }
 
@@ -154,7 +154,7 @@
   Node = llvm::make_unique(F);
   // Make Root node a parent of all functions to make sure all are reachable.
   if (F)
-Root->addCallee(Node.get(), this);
+Root->addCallee(Node.get());
   return Node.get();
 }
 
Index: include/clang/Analysis/CallGraph.h
===
--- include/clang/Analysis/CallGraph.h
+++ include/clang/Analysis/CallGraph.h
@@ -157,7 +157,7 @@
   inline bool empty() const {return CalledFunctions.empty(); }
   inline unsigned size() const {return CalledFunctions.size(); }
 
-  void addCallee(CallGraphNode *N, CallGraph *CG) {
+  void addCallee(CallGraphNode *N) {
 CalledFunctions.push_back(N);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27673: [clang-move] Only move used helper declarations.

2016-12-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 81079.
hokein added a comment.

Fix code style.


https://reviews.llvm.org/D27673

Files:
  clang-move/CMakeLists.txt
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/UsedHelperDeclFinder.cpp
  clang-move/UsedHelperDeclFinder.h
  test/clang-move/Inputs/helper_decls_test.cpp
  test/clang-move/Inputs/helper_decls_test.h
  test/clang-move/Inputs/multiple_class_test.cpp
  test/clang-move/move-multiple-classes.cpp
  test/clang-move/move-used-helper-decls.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -73,13 +73,21 @@
   "\n"
   "// comment5\n"
   "// comment5\n"
-  "void Foo::f() { f1(); }\n"
+  "void Foo::f() {\n"
+  "  f1();\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
+  "}\n"
   "\n"
   "/\n"
   "// comment //\n"
   "/\n"
   "int Foo::b = 2;\n"
   "int Foo2::f() {\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
   "  f1();\n"
   "  return 1;\n"
   "}\n"
@@ -119,6 +127,9 @@
   "}\n"
   "\n"
   "int Foo2::f() {\n"
+  "  kConstInt1;\n"
+  "  kConstInt2;\n"
+  "  help();\n"
   "  f1();\n"
   "  return 1;\n"
   "}\n"
@@ -154,6 +165,7 @@
  "namespace {\n"
  "// comment1.\n"
  "void f1() {}\n"
+ "\n"
  "/// comment2.\n"
  "int kConstInt1 = 0;\n"
  "} // namespace\n"
@@ -170,7 +182,12 @@
  "\n"
  "// comment5\n"
  "// comment5\n"
- "void Foo::f() { f1(); }\n"
+ "void Foo::f() {\n"
+ "  f1();\n"
+ "  kConstInt1;\n"
+ "  kConstInt2;\n"
+ "  help();\n"
+ "}\n"
  "\n"
  "/\n"
  "// comment //\n"
Index: test/clang-move/move-used-helper-decls.cpp
===
--- /dev/null
+++ test/clang-move/move-used-helper-decls.cpp
@@ -0,0 +1,130 @@
+// RUN: mkdir -p %T/used-helper-decls
+// RUN: cp %S/Inputs/helper_decls_test*  %T/used-helper-decls/
+// RUN: cd %T/used-helper-decls
+
+// RUN: clang-move -names="a::Class1" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CLASS1-CPP %s
+// RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-CLASS1-CPP %s
+
+// CHECK-NEW-CLASS1-CPP: #include "{{.*}}new_helper_decls_test.h"
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: namespace {
+// CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun1() {}
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun2() { HelperFun1(); }
+// CHECK-NEW-CLASS1-CPP-NEXT: } // namespace
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}
+// CHECK-NEW-CLASS1-CPP-NEXT: namespace a {
+// CHECK-NEW-CLASS1-CPP-NEXT: void Class1::f() { HelperFun2(); }
+// CHECK-NEW-CLASS1-CPP-NEXT: } // namespace a
+//
+// CHECK-OLD-CLASS1-CPP: void HelperFun1() {}
+// CHECK-OLD-CLASS1-CPP-NOT: void HelperFun2() { HelperFun1(); }
+// CHECK-OLD-CLASS1-CPP-NOT: void Class1::f() { HelperFun2(); }
+// CHECK-OLD-CLASS1-CPP: void Class2::f() {
+// CHECK-OLD-CLASS1-CPP:   HelperFun1();
+
+// RUN: cp %S/Inputs/helper_decls_test*  %T/used-helper-decls/
+// RUN: clang-move -names="a::Class2" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper

r289431 - [StaticAnalysis] Remove unnecessary parameter in CallGraphNode::addCallee.

2016-12-12 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Dec 12 08:12:10 2016
New Revision: 289431

URL: http://llvm.org/viewvc/llvm-project?rev=289431&view=rev
Log:
[StaticAnalysis] Remove unnecessary parameter in CallGraphNode::addCallee.

Summary:
Remove the CallGraph in addCallee as it is not used in addCallee.
It decouples addCallee from CallGraph, so that we can use CallGraphNode
within our customized CallGraph.

Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

Modified:
cfe/trunk/include/clang/Analysis/CallGraph.h
cfe/trunk/lib/Analysis/CallGraph.cpp

Modified: cfe/trunk/include/clang/Analysis/CallGraph.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CallGraph.h?rev=289431&r1=289430&r2=289431&view=diff
==
--- cfe/trunk/include/clang/Analysis/CallGraph.h (original)
+++ cfe/trunk/include/clang/Analysis/CallGraph.h Mon Dec 12 08:12:10 2016
@@ -157,7 +157,7 @@ public:
   inline bool empty() const {return CalledFunctions.empty(); }
   inline unsigned size() const {return CalledFunctions.size(); }
 
-  void addCallee(CallGraphNode *N, CallGraph *CG) {
+  void addCallee(CallGraphNode *N) {
 CalledFunctions.push_back(N);
   }
 

Modified: cfe/trunk/lib/Analysis/CallGraph.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CallGraph.cpp?rev=289431&r1=289430&r2=289431&view=diff
==
--- cfe/trunk/lib/Analysis/CallGraph.cpp (original)
+++ cfe/trunk/lib/Analysis/CallGraph.cpp Mon Dec 12 08:12:10 2016
@@ -55,7 +55,7 @@ public:
   void addCalledDecl(Decl *D) {
 if (G->includeInGraph(D)) {
   CallGraphNode *CalleeNode = G->getOrInsertNode(D);
-  CallerNode->addCallee(CalleeNode, G);
+  CallerNode->addCallee(CalleeNode);
 }
   }
 
@@ -154,7 +154,7 @@ CallGraphNode *CallGraph::getOrInsertNod
   Node = llvm::make_unique(F);
   // Make Root node a parent of all functions to make sure all are reachable.
   if (F)
-Root->addCallee(Node.get(), this);
+Root->addCallee(Node.get());
   return Node.get();
 }
 


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


[PATCH] D27674: [StaticAnalysis] Remove unnecessary parameter in CallGraphNode::addCallee.

2016-12-12 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289431: [StaticAnalysis] Remove unnecessary parameter in 
CallGraphNode::addCallee. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D27674?vs=81078&id=81081#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27674

Files:
  cfe/trunk/include/clang/Analysis/CallGraph.h
  cfe/trunk/lib/Analysis/CallGraph.cpp


Index: cfe/trunk/include/clang/Analysis/CallGraph.h
===
--- cfe/trunk/include/clang/Analysis/CallGraph.h
+++ cfe/trunk/include/clang/Analysis/CallGraph.h
@@ -157,7 +157,7 @@
   inline bool empty() const {return CalledFunctions.empty(); }
   inline unsigned size() const {return CalledFunctions.size(); }
 
-  void addCallee(CallGraphNode *N, CallGraph *CG) {
+  void addCallee(CallGraphNode *N) {
 CalledFunctions.push_back(N);
   }
 
Index: cfe/trunk/lib/Analysis/CallGraph.cpp
===
--- cfe/trunk/lib/Analysis/CallGraph.cpp
+++ cfe/trunk/lib/Analysis/CallGraph.cpp
@@ -55,7 +55,7 @@
   void addCalledDecl(Decl *D) {
 if (G->includeInGraph(D)) {
   CallGraphNode *CalleeNode = G->getOrInsertNode(D);
-  CallerNode->addCallee(CalleeNode, G);
+  CallerNode->addCallee(CalleeNode);
 }
   }
 
@@ -154,7 +154,7 @@
   Node = llvm::make_unique(F);
   // Make Root node a parent of all functions to make sure all are reachable.
   if (F)
-Root->addCallee(Node.get(), this);
+Root->addCallee(Node.get());
   return Node.get();
 }
 


Index: cfe/trunk/include/clang/Analysis/CallGraph.h
===
--- cfe/trunk/include/clang/Analysis/CallGraph.h
+++ cfe/trunk/include/clang/Analysis/CallGraph.h
@@ -157,7 +157,7 @@
   inline bool empty() const {return CalledFunctions.empty(); }
   inline unsigned size() const {return CalledFunctions.size(); }
 
-  void addCallee(CallGraphNode *N, CallGraph *CG) {
+  void addCallee(CallGraphNode *N) {
 CalledFunctions.push_back(N);
   }
 
Index: cfe/trunk/lib/Analysis/CallGraph.cpp
===
--- cfe/trunk/lib/Analysis/CallGraph.cpp
+++ cfe/trunk/lib/Analysis/CallGraph.cpp
@@ -55,7 +55,7 @@
   void addCalledDecl(Decl *D) {
 if (G->includeInGraph(D)) {
   CallGraphNode *CalleeNode = G->getOrInsertNode(D);
-  CallerNode->addCallee(CalleeNode, G);
+  CallerNode->addCallee(CalleeNode);
 }
   }
 
@@ -154,7 +154,7 @@
   Node = llvm::make_unique(F);
   // Make Root node a parent of all functions to make sure all are reachable.
   if (F)
-Root->addCallee(Node.get(), this);
+Root->addCallee(Node.get());
   return Node.get();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r289433 - Use function_ref to avoid allocation in std::function. NFC.

2016-12-12 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Dec 12 08:41:19 2016
New Revision: 289433

URL: http://llvm.org/viewvc/llvm-project?rev=289433&view=rev
Log:
Use function_ref to avoid allocation in std::function. NFC.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=289433&r1=289432&r2=289433&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Dec 12 08:41:19 2016
@@ -10029,7 +10029,8 @@ public:
   /// local diagnostics like in reference binding.
   void RefersToMemberWithReducedAlignment(
   Expr *E,
-  std::function 
Action);
+  llvm::function_ref
+  Action);
 };
 
 /// \brief RAII object that enters a new expression evaluation context.

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=289433&r1=289432&r2=289433&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Dec 12 08:41:19 2016
@@ -11816,7 +11816,8 @@ void Sema::DiscardMisalignedMemberAddres
 
 void Sema::RefersToMemberWithReducedAlignment(
 Expr *E,
-std::function Action) {
+llvm::function_ref
+Action) {
   const auto *ME = dyn_cast(E);
   if (!ME)
 return;


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


[PATCH] D27501: clang-format-vsix: add command to format document

2016-12-12 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG. I also think it makes the code nicer by breaking out the right functions. 
Thanks!




Comment at: tools/clang-format-vs/ClangFormat/ClangFormat.vsct:76
+
+  Clang Format Document
+

amaiorano wrote:
> klimek wrote:
> > hans wrote:
> > > amaiorano wrote:
> > > > hans wrote:
> > > > > I think File would be better than Document when referring to source 
> > > > > code.
> > > > > 
> > > > > But it seems a little annoying to need two menu alternatives. Could 
> > > > > we make the regular "Clang Format" option just format the whole file 
> > > > > if there is currently no selection, or would that be confusing?
> > > > The reason I chose "Document" is that it mimics the existing 
> > > > functionality in Visual Studio:
> > > > {F2661117}
> > > > 
> > > > As you can see, "Ctrl+K, Ctrl+F" is bound to format selection by 
> > > > default; which I assumed is the reason "Ctrl+R, Ctrl+F" was used for 
> > > > Clang Format (Selection). So along the same lines, I bound "Ctrl + R, 
> > > > Ctrl + D" to Clang Format Document.
> > > > 
> > > > I don't really have a problem with having multiple menu options, 
> > > > although we could have both of them underneath a "Clang Format" top 
> > > > menu, with "Format Selection" and "Format Document" as sub menu items.
> > > > 
> > > > As for annoyance in menus, I think most developers would reach for 
> > > > keyboard shortcuts in this case anyway. Furthermore, the next feature I 
> > > > want to add, building on top of this one, is allowing the user to 
> > > > enable "Format on Save", which would make this even easier to use.
> > > I see, I didn't realize they call it documents. And if they also have 
> > > separate commands for formating selection and formating the whole file, 
> > > maybe that makes sense for us too.
> > > 
> > > Right, I also imagine folks would use this from the keyboard, but there 
> > > too it's annoying to have two shortcuts for the same thing. But again, if 
> > > that's how it's generally done in VS...
> > > 
> > > I'd like to hear from Manuel on this patch too, though.
> > Clang-format currently formats the current line / statement if there is no 
> > selection, and that's how most people I know use it.
> > Formatting the whole file by default is not what clang-format is optimized 
> > for, and highly disruptive (eclipse does that, and it's annoying).
> > I'm more wondering why we need a setting for this at all - isn't 
> > ctrl-a,ctrl-k,ctrl-f equivalent to formatting the whole file?
> @klimek My own experience, which also seems to match those of others online, 
> is that clang-format is a fantastic tool for making sure your code-base 
> follows a strict formatting standard. What many people do is install Git 
> pre-stage hooks, for instance, to run clang-format across entire source 
> files, to ensure they're formatted properly. So even if it's not optimized 
> for that, it works very well :)
> 
> Using clang-format to format only the current line doesn't guarantee that 
> everything will be formatted accordingly. My own experience is that it 
> sometimes formats the line differently than if you format the entire 
> document. Or perhaps you end up writing a few lines of code, and formatting 
> current line doesn't pick up all the lines you've modified. As for 
> ctrl-a,ctrl-r-ctrl-f, the problem with it is that you lose your cursor 
> position, as ctrl-a will place it at the end of the file.
> 
> You also mention that formatting the entire file is "highly disruptive" like 
> in eclipse. I'm not sure how eclipse handles that, but so far VS seems to do 
> a pretty good job. It manages to maintain breakpoint positions quite well, it 
> manages to keep the cursor in the same place, and it manages to keep the 
> relative location of the code where the cursor is at visible on screen. I 
> suspect part of the reason it works well in VS is because Microsoft made sure 
> it worked for their own format document feature (ctrl-k,ctrl-d).
> 
> As I mentioned earlier, this is a stepping stone towards adding a feature to 
> "format on save", for which I'd like to offer the ability to choose "current 
> line/selection" and "document". [[ 
> https://github.com/Elders/VSE-FormatDocumentOnSave | Here's an example ]] of 
> an extension that offers this feature, but for VS's built-in formatting.
Note: with "highly disruptive" I meant only if the default behavior without any 
selection is to format the whole file, as that basically kills the workflow; 
that was what Hans suggested.

I'm not opposed to having an extra key binding if enough folks want it and 
there is enough benefit - the argument to not move your cursor is a good point.


https://reviews.llvm.org/D27501



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

[PATCH] D26887: [Driver] Fix finding multilib gcc install on Gentoo (with gcc-config)

2016-12-12 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

I believe this is fine.


https://reviews.llvm.org/D26887



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


[PATCH] D27535: [analyzer] Add ObjCPropertyChecker - check for autosynthesized copy-properties of mutable types.

2016-12-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 81083.
NoQ added a comment.

- Fix crashes on checking properties in categories.
- Address both comments.


https://reviews.llvm.org/D27535

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
  test/Analysis/ObjCPropertiesSyntaxChecks.m

Index: test/Analysis/ObjCPropertiesSyntaxChecks.m
===
--- /dev/null
+++ test/Analysis/ObjCPropertiesSyntaxChecks.m
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -w -fblocks -analyze -analyzer-checker=osx.ObjCProperty %s -verify
+
+#include "Inputs/system-header-simulator-objc.h"
+
+@interface I : NSObject {
+  NSMutableString *_mutableExplicitStr;
+  NSMutableString *_trulyMutableStr;
+  NSMutableString *_trulyMutableExplicitStr;
+}
+@property(copy) NSString *str; // no-warning
+@property(copy) NSMutableString *mutableStr; // expected-warning{{Property of mutable type 'NSMutableString' has 'copy' attribute; an immutable object will be stored instead}}
+@property(copy) NSMutableString *mutableExplicitStr; // expected-warning{{Property of mutable type 'NSMutableString' has 'copy' attribute; an immutable object will be stored instead}}
+@property(copy, readonly) NSMutableString *mutableReadonlyStr; // no-warning
+@property(copy, readonly) NSMutableString *mutableReadonlyStrOverriddenInChild; // no-warning
+@property(copy, readonly) NSMutableString *mutableReadonlyStrOverriddenInCategory; // no-warning
+@property(copy) NSMutableString *trulyMutableStr; // no-warning
+@property(copy) NSMutableString *trulyMutableExplicitStr; // no-warning
+@property(copy) NSMutableString *trulyMutableStrWithSynthesizedStorage; // no-warning
+@end
+
+@interface I () {}
+@property(copy) NSMutableString *mutableStrInCategory; // expected-warning{{Property of mutable type 'NSMutableString' has 'copy' attribute; an immutable object will be stored instead}}
+@property (copy, readwrite) NSMutableString *mutableReadonlyStrOverriddenInCategory; // expected-warning{{Property of mutable type 'NSMutableString' has 'copy' attribute; an immutable object will be stored instead}}
+@end
+
+@implementation I
+@synthesize mutableExplicitStr = _mutableExplicitStr;
+- (NSMutableString *)trulyMutableStr {
+  return _trulyMutableStr;
+}
+- (void)setTrulyMutableStr: (NSMutableString *) S {
+  _trulyMutableStr = [S mutableCopy];
+}
+@dynamic trulyMutableExplicitStr;
+- (NSMutableString *)trulyMutableExplicitStr {
+  return _trulyMutableExplicitStr;
+}
+- (void)setTrulyMutableExplicitStr: (NSMutableString *) S {
+  _trulyMutableExplicitStr = [S mutableCopy];
+}
+@synthesize trulyMutableStrWithSynthesizedStorage;
+- (NSMutableString *)trulyMutableStrWithSynthesizedStorage {
+  return trulyMutableStrWithSynthesizedStorage;
+}
+- (void)setTrulyMutableStrWithSynthesizedStorage: (NSMutableString *) S {
+  trulyMutableStrWithSynthesizedStorage = [S mutableCopy];
+}
+@end
+
+@interface J : I {}
+@property (copy, readwrite) NSMutableString *mutableReadonlyStrOverriddenInChild; // expected-warning{{Property of mutable type 'NSMutableString' has 'copy' attribute; an immutable object will be stored instead}}
+@end
+
+@implementation J
+@end
+
+// If we do not see the implementation then we do not want to warn,
+// because we may miss a user-defined setter that works correctly.
+@interface IWithoutImpl : NSObject {}
+@property(copy) NSMutableString *mutableStr; // no-warning
+@end
Index: lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
@@ -0,0 +1,82 @@
+//==- ObjCPropertyChecker.cpp - Check ObjC properties *- C++ -*-==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This checker finds issues with Objective-C properties.
+//  Currently finds only one kind of issue:
+//  - Find synthesized properties with copy attribute of mutable NS collection
+//types. Calling -copy on such collections produces an immutable copy,
+//which contradicts the type of the property.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class ObjCPropertyChecker
+: public Checker> {
+  void checkCopyMutable(const ObjCPropertyDecl *D, BugReporter &BR) const;
+
+public:
+  void checkASTDecl(const ObjCPropertyDecl *D, AnalysisManager &Mgr,
+BugReporter &BR) const;
+};
+} // end anonymous namespace.
+
+void ObjCPropertyCheck

r289436 - [Driver] Fix finding multilib gcc install on Gentoo (with gcc-config)

2016-12-12 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Mon Dec 12 09:07:43 2016
New Revision: 289436

URL: http://llvm.org/viewvc/llvm-project?rev=289436&view=rev
Log:
[Driver] Fix finding multilib gcc install on Gentoo (with gcc-config)

Fix the gcc-config code to support multilib gcc installs properly. This
solves two problems: -mx32 using the 64-bit gcc directory (due to matching
installation triple), and -m32 not respecting gcc-config at all (due to
mismatched installation triple).

In order to fix the former issue, split the multilib scan out of
Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple() (the code
is otherwise unchanged), and call it for each installation found via
gcc-config.

In order to fix the latter issue, split the gcc-config processing out of
Generic_GCC::GCCInstallationDetector::init() and repeat it for all
triples, including extra and biarch triples. The only change
in the gcc-config code itself is adding the call to multilib scan.

Convert the gentoo_linux_gcc_multi_version_tree test input to multilib
x86_64+32+x32 install, and add appropriate tests to linux-header-search
and linux-ld.

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

Added:

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32/crtbegin.o

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/x32/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/x32/crtbegin.o

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/crtbegin.o

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/x32/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/x32/crtbegin.o
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/test/Driver/linux-header-search.cpp
cfe/trunk/test/Driver/linux-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=289436&r1=289435&r2=289436&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Dec 12 09:07:43 2016
@@ -1457,35 +1457,17 @@ void Generic_GCC::GCCInstallationDetecto
   // in /usr. This avoids accidentally enforcing the system GCC version
   // when using a custom toolchain.
   if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+for (StringRef CandidateTriple : ExtraTripleAliases) {
+  if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple))
+return;
+}
 for (StringRef CandidateTriple : CandidateTripleAliases) {
-  llvm::ErrorOr> File =
-  D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/config-" +
-  CandidateTriple.str());
-  if (File) {
-SmallVector Lines;
-File.get()->getBuffer().split(Lines, "\n");
-for (StringRef Line : Lines) {
-  // CURRENT=triple-version
-  if (Line.consume_front("CURRENT=")) {
-const std::pair ActiveVersion =
-  Line.rsplit('-');
-// Note: Strictly speaking, we should be reading
-// /etc/env.d/gcc/${CURRENT} now. However, the file doesn't
-// contain anything new or especially useful to us.
-const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" +
-   ActiveVersion.first.str() + "/" +
-   ActiveVersion.second.str();
-if (D.getVFS().exists(GentooPath + "/crtbegin.o")) {
-  Version = GCCVersion::Parse(ActiveVersion.second);
-  GCCInstallPath = GentooPath;
-  GCCParentLibPath = GentooPath + "/../../..";
-  GCCTriple.setTriple(ActiveVersion.first);
-  IsValid = true;
-  return;
-}
-  }
-}
-  }
+  if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple))
+return;
+}
+for (StringRef CandidateTriple : CandidateBiarchTripleAliases) {
+  if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple, true))
+return;
 }
   }
 
@@ -2716,6 +2698,33 @@ void Generic_GCC::GCCInstallationDetecto
   }
 }
 
+bool Generic_GCC::GCCInstallationDetector::ScanGCCForMultilibs(
+const llvm::Triple &TargetTriple, const ArgList &Args,
+StringRef Path, bool NeedsBiarchSuffix) {
+  llvm::Triple::ArchType TargetArch = TargetTriple.getArch();
+  DetectedMultilib

[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-12 Thread Firat Kasmis via Phabricator via cfe-commits
firolino added a comment.

In https://reviews.llvm.org/D27621#619649, @malcolm.parsons wrote:

> The fixit construction looks overly complicated.


Yes, you were right. I have changed a couple of things. It looks better now. 
Still working on a better getUserWrittenType.


https://reviews.llvm.org/D27621



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


[PATCH] D26887: [Driver] Fix finding multilib gcc install on Gentoo (with gcc-config)

2016-12-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Thanks for the review. Committed now.


https://reviews.llvm.org/D26887



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


[PATCH] D26887: [Driver] Fix finding multilib gcc install on Gentoo (with gcc-config)

2016-12-12 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289436: [Driver] Fix finding multilib gcc install on Gentoo 
(with gcc-config) (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D26887?vs=78623&id=81086#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26887

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32/crtbegin.o
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/x32/crtbegin.o
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/crtbegin.o
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/x32/crtbegin.o
  cfe/trunk/test/Driver/linux-header-search.cpp
  cfe/trunk/test/Driver/linux-ld.c

Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -196,6 +196,11 @@
  SmallVectorImpl &BiarchLibDirs,
  SmallVectorImpl &BiarchTripleAliases);
 
+bool ScanGCCForMultilibs(const llvm::Triple &TargetTriple,
+ const llvm::opt::ArgList &Args,
+ StringRef Path,
+ bool NeedsBiarchSuffix = false);
+
 void ScanLibDirForGCCTriple(const llvm::Triple &TargetArch,
 const llvm::opt::ArgList &Args,
 const std::string &LibDir,
@@ -207,6 +212,11 @@
const std::string &LibDir,
StringRef CandidateTriple,
bool NeedsBiarchSuffix = false);
+
+bool ScanGentooGccConfig(const llvm::Triple &TargetTriple,
+ const llvm::opt::ArgList &Args,
+ StringRef CandidateTriple,
+ bool NeedsBiarchSuffix = false);
   };
 
 protected:
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1457,35 +1457,17 @@
   // in /usr. This avoids accidentally enforcing the system GCC version
   // when using a custom toolchain.
   if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+for (StringRef CandidateTriple : ExtraTripleAliases) {
+  if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple))
+return;
+}
 for (StringRef CandidateTriple : CandidateTripleAliases) {
-  llvm::ErrorOr> File =
-  D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/config-" +
-  CandidateTriple.str());
-  if (File) {
-SmallVector Lines;
-File.get()->getBuffer().split(Lines, "\n");
-for (StringRef Line : Lines) {
-  // CURRENT=triple-version
-  if (Line.consume_front("CURRENT=")) {
-const std::pair ActiveVersion =
-  Line.rsplit('-');
-// Note: Strictly speaking, we should be reading
-// /etc/env.d/gcc/${CURRENT} now. However, the file doesn't
-// contain anything new or especially useful to us.
-const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" +
-   ActiveVersion.first.str() + "/" +
-   ActiveVersion.second.str();
-if (D.getVFS().exists(GentooPath + "/crtbegin.o")) {
-  Version = GCCVersion::Parse(ActiveVersion.second);
-  GCCInstallPath = GentooPath;
-  GCCParentLibPath = GentooPath + "/../../..";
-  GCCTriple.setTriple(ActiveVersion.first);
-  IsValid = true;
-  return;
-}
-  }
-}
-  }
+  if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple))
+return;
+}
+for (StringRef CandidateTriple : CandidateBiarchTripleAliases) {
+  if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple, true))
+return;
 }
   }
 
@@ -2716,6 +2698,33 @@
   }
 }
 
+bool Generic_GCC::GCCInstallationDetector::ScanGCCForMultilibs(
+const llvm::Triple &TargetTriple, const ArgList &Args,
+StringRef Path, bool NeedsBiarchSuffix) {
+  llvm::Triple::ArchType TargetArch = TargetTriple.getArch();
+  DetectedMultilibs Detected;
+
+  // Android standalone toolchain could have multilibs for ARM and Thumb.
+  // Debian mips multilibs behave more like the rest of the biarch ones,
+  // so handle them there
+  if (isArmOrThumbArch(TargetArch) && TargetTriple.isAndroid()) {
+// It should also work without 

[PATCH] D27501: clang-format-vsix: add command to format document

2016-12-12 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added inline comments.



Comment at: tools/clang-format-vs/ClangFormat/ClangFormat.vsct:76
+
+  Clang Format Document
+

klimek wrote:
> amaiorano wrote:
> > klimek wrote:
> > > hans wrote:
> > > > amaiorano wrote:
> > > > > hans wrote:
> > > > > > I think File would be better than Document when referring to source 
> > > > > > code.
> > > > > > 
> > > > > > But it seems a little annoying to need two menu alternatives. Could 
> > > > > > we make the regular "Clang Format" option just format the whole 
> > > > > > file if there is currently no selection, or would that be confusing?
> > > > > The reason I chose "Document" is that it mimics the existing 
> > > > > functionality in Visual Studio:
> > > > > {F2661117}
> > > > > 
> > > > > As you can see, "Ctrl+K, Ctrl+F" is bound to format selection by 
> > > > > default; which I assumed is the reason "Ctrl+R, Ctrl+F" was used for 
> > > > > Clang Format (Selection). So along the same lines, I bound "Ctrl + R, 
> > > > > Ctrl + D" to Clang Format Document.
> > > > > 
> > > > > I don't really have a problem with having multiple menu options, 
> > > > > although we could have both of them underneath a "Clang Format" top 
> > > > > menu, with "Format Selection" and "Format Document" as sub menu items.
> > > > > 
> > > > > As for annoyance in menus, I think most developers would reach for 
> > > > > keyboard shortcuts in this case anyway. Furthermore, the next feature 
> > > > > I want to add, building on top of this one, is allowing the user to 
> > > > > enable "Format on Save", which would make this even easier to use.
> > > > I see, I didn't realize they call it documents. And if they also have 
> > > > separate commands for formating selection and formating the whole file, 
> > > > maybe that makes sense for us too.
> > > > 
> > > > Right, I also imagine folks would use this from the keyboard, but there 
> > > > too it's annoying to have two shortcuts for the same thing. But again, 
> > > > if that's how it's generally done in VS...
> > > > 
> > > > I'd like to hear from Manuel on this patch too, though.
> > > Clang-format currently formats the current line / statement if there is 
> > > no selection, and that's how most people I know use it.
> > > Formatting the whole file by default is not what clang-format is 
> > > optimized for, and highly disruptive (eclipse does that, and it's 
> > > annoying).
> > > I'm more wondering why we need a setting for this at all - isn't 
> > > ctrl-a,ctrl-k,ctrl-f equivalent to formatting the whole file?
> > @klimek My own experience, which also seems to match those of others 
> > online, is that clang-format is a fantastic tool for making sure your 
> > code-base follows a strict formatting standard. What many people do is 
> > install Git pre-stage hooks, for instance, to run clang-format across 
> > entire source files, to ensure they're formatted properly. So even if it's 
> > not optimized for that, it works very well :)
> > 
> > Using clang-format to format only the current line doesn't guarantee that 
> > everything will be formatted accordingly. My own experience is that it 
> > sometimes formats the line differently than if you format the entire 
> > document. Or perhaps you end up writing a few lines of code, and formatting 
> > current line doesn't pick up all the lines you've modified. As for 
> > ctrl-a,ctrl-r-ctrl-f, the problem with it is that you lose your cursor 
> > position, as ctrl-a will place it at the end of the file.
> > 
> > You also mention that formatting the entire file is "highly disruptive" 
> > like in eclipse. I'm not sure how eclipse handles that, but so far VS seems 
> > to do a pretty good job. It manages to maintain breakpoint positions quite 
> > well, it manages to keep the cursor in the same place, and it manages to 
> > keep the relative location of the code where the cursor is at visible on 
> > screen. I suspect part of the reason it works well in VS is because 
> > Microsoft made sure it worked for their own format document feature 
> > (ctrl-k,ctrl-d).
> > 
> > As I mentioned earlier, this is a stepping stone towards adding a feature 
> > to "format on save", for which I'd like to offer the ability to choose 
> > "current line/selection" and "document". [[ 
> > https://github.com/Elders/VSE-FormatDocumentOnSave | Here's an example ]] 
> > of an extension that offers this feature, but for VS's built-in formatting.
> Note: with "highly disruptive" I meant only if the default behavior without 
> any selection is to format the whole file, as that basically kills the 
> workflow; that was what Hans suggested.
> 
> I'm not opposed to having an extra key binding if enough folks want it and 
> there is enough benefit - the argument to not move your cursor is a good 
> point.
Thanks! Now I just need to get my svn submit working. Chris Latner created my 
account, etc. but when I tried to submit another accepted change, it didn

[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples

2016-12-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny abandoned this revision.
mgorny added a comment.

I give up. I'm just going to complain to Gentoo ARM people a lot and maybe 
they'll fix their triples.


https://reviews.llvm.org/D25686



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-12 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:133
+VariableLocation.setBegin(tidy::utils::lexer::findLocationAfterToken(
+VariableLocation.getEnd(), Tokens, *Result.Context));
+  }

If you use `ArrayRef` in `findLocationAfterToken` then you won't need to create 
a `std::vector` here as you should be able to pass in a constant array 
`{tok::semi, tok::comma}`



Comment at: clang-tidy/utils/LexerUtils.h:32
+SourceLocation findLocationAfterToken(SourceLocation Loc,
+  const std::vector 
&Tokens,
+  ASTContext &Context);

You can use `ArrayRef` here.


https://reviews.llvm.org/D27621



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-12 Thread Firat Kasmis via Phabricator via cfe-commits
firolino marked 2 inline comments as done.
firolino added inline comments.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:133
+VariableLocation.setBegin(tidy::utils::lexer::findLocationAfterToken(
+VariableLocation.getEnd(), Tokens, *Result.Context));
+  }

arphaman wrote:
> If you use `ArrayRef` in `findLocationAfterToken` then you won't need to 
> create a `std::vector` here as you should be able to pass in a constant array 
> `{tok::semi, tok::comma}`
This should even work with std::vector, since we have initializer_lists. I have 
created Token because of [[ 
http://llvm.org/docs/CodingStandards.html#do-not-use-braced-initializer-lists-to-call-a-constructor
 | Do not use Braced Initializer Lists to Call a Constructor ]] and readability 
reasons.

Anyway, this function isn't included in the newest version :)


https://reviews.llvm.org/D27621



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


[PATCH] D21698: [OpenCL] Allow disabling types and declarations associated with extensions

2016-12-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8127
   "invalid prototype, variadic arguments are not allowed in OpenCL">;
+def err_requires_extension : Error<
+  "use of %select{declaration|type }0%1 requires %2 extension to be enabled">;

Could we rename err_requires_extension -> err_opencl_requires_extension



Comment at: lib/Parse/ParsePragma.cpp:461
+  };
+  typedef std::pair OpenCLExtData;
 }

yaxunl wrote:
> Anastasia wrote:
> > yaxunl wrote:
> > > Anastasia wrote:
> > > > Could we use PointerIntPair still but with 2 bits?
> > > Using PointerIntPair with 2 bits requires IdentifierInfo to be aligned at 
> > > 4 bytes, however this is not true. IdentifierInfo has no explicit 
> > > alignment specifier, therefore it can only hold 1 bit in PointerIntPair.
> > Based on its structure with having a pointer member I think it's reasonable 
> > to assume at least 4 bytes alignment... Although this doesn't seem to 
> > affect the performance anyways.
> You are right. The alignment of IdentifierInfo should be 8 on most systems.
> 
> However in IdentifierTable.h there is
> 
> 
> ```
> // Provide PointerLikeTypeTraits for IdentifierInfo pointers, which
> // are not guaranteed to be 8-byte aligned.
> template<>
> class PointerLikeTypeTraits {
> public:
>   static inline void *getAsVoidPointer(clang::IdentifierInfo* P) {
> return P;
>   }
>   static inline clang::IdentifierInfo *getFromVoidPointer(void *P) {
> return static_cast(P);
>   }
>   enum { NumLowBitsAvailable = 1 };
> };
> 
> ```
> Due to the above code there is only 1 bit available for when using 
> PointerIntPair with IdentifierInfo*. My guess is that alignment of 
> IdentifierInfo is not 8 on certain systems so some one intentionally defined 
> the above code to prevent using PointerIntPair with IdentifierInfo* for more 
> than 1 bit.
> 
Not too critical, but it's certainly not 8 byte aligned for 32 bit 
architectures. It should although be at least 4 bytes aligned in my opinion.

This code seems to be old, and the comment is not very precise to be honest. 



Comment at: lib/Sema/Sema.cpp:1614
+Decl = TagT->getDecl();
+  auto DL = OpenCLDeclExtMap.find(Decl);
+  if (DL != OpenCLDeclExtMap.end()) {

this bit (up to line 1623) seems to be repeated in multiple places... wondering 
if we could use a helper function instead perhaps with the templates?



Comment at: lib/Serialization/ASTReader.cpp:3170
+OpenCLExtensions.OptMap[Name] = {
+  static_cast(Record[I++]),
+  static_cast(Record[I++]),

Can you put a comment explaining which element each line corresponds to?


https://reviews.llvm.org/D21698



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


r289440 - [Driver] Attempt to fix new linux-ld tests on Windows

2016-12-12 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Mon Dec 12 10:04:37 2016
New Revision: 289440

URL: http://llvm.org/viewvc/llvm-project?rev=289440&view=rev
Log:
[Driver] Attempt to fix new linux-ld tests on Windows

(broken by r289436)

Modified:
cfe/trunk/test/Driver/linux-ld.c

Modified: cfe/trunk/test/Driver/linux-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=289440&r1=289439&r2=289440&view=diff
==
--- cfe/trunk/test/Driver/linux-ld.c (original)
+++ cfe/trunk/test/Driver/linux-ld.c Mon Dec 12 10:04:37 2016
@@ -1674,7 +1674,7 @@
 // CHECK-LD-GENTOO: "--eh-frame-hdr"
 // CHECK-LD-GENTOO: "-m" "elf_x86_64"
 // CHECK-LD-GENTOO: "-dynamic-linker"
-// CHECK-LD-GENTOO: "{{.*}}/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o"
+// CHECK-LD-GENTOO: 
"{{.*}}/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3{{/|}}crtbegin.o"
 // CHECK-LD-GENTOO: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3"
 // CHECK-LD-GENTOO: 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/lib"
 // CHECK-LD-GENTOO: 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../.."
@@ -1691,7 +1691,7 @@
 // CHECK-LD-GENTOO-32: "--eh-frame-hdr"
 // CHECK-LD-GENTOO-32: "-m" "elf_i386"
 // CHECK-LD-GENTOO-32: "-dynamic-linker"
-// CHECK-LD-GENTOO-32: 
"{{.*}}/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32/crtbegin.o"
+// CHECK-LD-GENTOO-32: 
"{{.*}}/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32{{/|}}crtbegin.o"
 // CHECK-LD-GENTOO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32"
 // CHECK-LD-GENTOO-32: 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/lib"
 // CHECK-LD-GENTOO-32: 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../.."
@@ -1708,7 +1708,7 @@
 // CHECK-LD-GENTOO-X32: "--eh-frame-hdr"
 // CHECK-LD-GENTOO-X32: "-m" "elf32_x86_64"
 // CHECK-LD-GENTOO-X32: "-dynamic-linker"
-// CHECK-LD-GENTOO-X32: 
"{{.*}}/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/x32/crtbegin.o"
+// CHECK-LD-GENTOO-X32: 
"{{.*}}/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/x32{{/|}}crtbegin.o"
 // CHECK-LD-GENTOO-X32: 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/x32"
 // CHECK-LD-GENTOO-X32: 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/lib"
 // CHECK-LD-GENTOO-X32: 
"-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../.."


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


[PATCH] D27671: [OpenCL] Improve address space diagnostics.

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

LGTM! Thanks!


https://reviews.llvm.org/D27671



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


r289444 - [clang] Version support for UBSan handlers

2016-12-12 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Mon Dec 12 10:18:40 2016
New Revision: 289444

URL: http://llvm.org/viewvc/llvm-project?rev=289444&view=rev
Log:
[clang] Version support for UBSan handlers

This adds a way for us to version any UBSan handler by itself.
The patch overrides D21289 for a better implementation (we're able to
rev up a single handler).

After this, then we can land a slight modification of D19667+D19668.

We probably don't want to keep all the versions in compiler-rt (maybe we
want to deprecate on one release and remove the old handler on the next
one?), but with this patch we will loudly fail to compile when mixing
incompatible handler calls, instead of silently compiling and then
providing bad error messages.

Reviewers: kcc, samsonov, rsmith, vsk

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=289444&r1=289443&r2=289444&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Dec 12 10:18:40 2016
@@ -959,8 +959,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   SanitizerScope SanScope(this);
   EmitCheck(std::make_pair(static_cast(Builder.getFalse()),
SanitizerKind::Unreachable),
-"builtin_unreachable", 
EmitCheckSourceLocation(E->getExprLoc()),
-None);
+SanitizerHandler::BuiltinUnreachable,
+EmitCheckSourceLocation(E->getExprLoc()), None);
 } else
   Builder.CreateUnreachable();
 

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=289444&r1=289443&r2=289444&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Dec 12 10:18:40 2016
@@ -2862,7 +2862,7 @@ void CodeGenFunction::EmitFunctionEpilog
 EmitCheckSourceLocation(RetNNAttr->getLocation()),
 };
 EmitCheck(std::make_pair(Cond, SanitizerKind::ReturnsNonnullAttribute),
-  "nonnull_return", StaticData, None);
+  SanitizerHandler::NonnullReturn, StaticData, None);
   }
 }
 Ret = Builder.CreateRet(RV);
@@ -3202,7 +3202,7 @@ void CodeGenFunction::EmitNonNullArgChec
   llvm::ConstantInt::get(Int32Ty, ArgNo + 1),
   };
   EmitCheck(std::make_pair(Cond, SanitizerKind::NonnullAttribute),
-"nonnull_arg", StaticData, None);
+SanitizerHandler::NonnullArg, StaticData, None);
 }
 
 void CodeGenFunction::EmitCallArgs(

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=289444&r1=289443&r2=289444&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Mon Dec 12 10:18:40 2016
@@ -2802,8 +2802,8 @@ void CodeGenFunction::EmitVTablePtrCheck
   llvm::MDString::get(CGM.getLLVMContext(), "all-vtables"));
   llvm::Value *ValidVtable = Builder.CreateCall(
   CGM.getIntrinsic(llvm::Intrinsic::type_test), {CastedVTable, 
AllVtables});
-  EmitCheck(std::make_pair(TypeTest, M), "cfi_check_fail", StaticData,
-{CastedVTable, ValidVtable});
+  EmitCheck(std::make_pair(TypeTest, M), SanitizerHandler::CFICheckFail,
+StaticData, {CastedVTable, ValidVtable});
 }
 
 bool CodeGenFunction::ShouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *RD) 
{
@@ -2835,7 +2835,7 @@ llvm::Value *CodeGenFunction::EmitVTable
   llvm::Value *CheckResult = Builder.CreateExtractValue(CheckedLoad, 1);
 
   EmitCheck(std::make_pair(CheckResult, SanitizerKind::CFIVCall),
-"cfi_check_fail", nullptr, nullptr);
+SanitizerHandler::CFICheckFail, nullptr, nullptr);
 
   return Builder.CreateBitCast(
   Builder.CreateExtractValue(CheckedLoad, 0),

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=289444&r1=289443&r2=289444&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Dec 12 10:18:40 2016
@@ -608,7 +608,7 @@ void CodeGenFunction::EmitTypeCheck(Type
   llvm::ConstantInt::get(SizeTy, AlignVal),
   llvm::ConstantInt::get(Int8Ty, TCK)
 };
-EmitCheck(Checks, "type_mismatch", Static

[PATCH] D21695: [clang] Version support for UBSan handlers

2016-12-12 Thread Filipe Cabecinhas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289444: [clang] Version support for UBSan handlers (authored 
by filcab).

Changed prior to commit:
  https://reviews.llvm.org/D21695?vs=61817&id=81089#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21695

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/CodeGen/CGClass.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h

Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -608,7 +608,7 @@
   llvm::ConstantInt::get(SizeTy, AlignVal),
   llvm::ConstantInt::get(Int8Ty, TCK)
 };
-EmitCheck(Checks, "type_mismatch", StaticData, Ptr);
+EmitCheck(Checks, SanitizerHandler::TypeMismatch, StaticData, Ptr);
   }
 
   // If possible, check that the vptr indicates that there is a subobject of
@@ -676,7 +676,8 @@
   };
   llvm::Value *DynamicData[] = { Ptr, Hash };
   EmitCheck(std::make_pair(EqualHash, SanitizerKind::Vptr),
-"dynamic_type_cache_miss", StaticData, DynamicData);
+SanitizerHandler::DynamicTypeCacheMiss, StaticData,
+DynamicData);
 }
   }
 
@@ -766,8 +767,8 @@
   };
   llvm::Value *Check = Accessed ? Builder.CreateICmpULT(IndexVal, BoundVal)
 : Builder.CreateICmpULE(IndexVal, BoundVal);
-  EmitCheck(std::make_pair(Check, SanitizerKind::ArrayBounds), "out_of_bounds",
-StaticData, Index);
+  EmitCheck(std::make_pair(Check, SanitizerKind::ArrayBounds),
+SanitizerHandler::OutOfBounds, StaticData, Index);
 }
 
 
@@ -1339,8 +1340,8 @@
 EmitCheckTypeDescriptor(Ty)
   };
   SanitizerMask Kind = NeedsEnumCheck ? SanitizerKind::Enum : SanitizerKind::Bool;
-  EmitCheck(std::make_pair(Check, Kind), "load_invalid_value", StaticArgs,
-EmitCheckValue(Load));
+  EmitCheck(std::make_pair(Check, Kind), SanitizerHandler::LoadInvalidValue,
+StaticArgs, EmitCheckValue(Load));
 }
   } else if (CGM.getCodeGenOpts().OptimizationLevel > 0)
 if (llvm::MDNode *RangeInfo = getRangeForLoadFromType(Ty))
@@ -2500,17 +2501,35 @@
   }
 }
 
+namespace {
+struct SanitizerHandlerInfo {
+  char const *const Name;
+  unsigned Version;
+};
+};
+
+const SanitizerHandlerInfo SanitizerHandlers[] = {
+#define SANITIZER_CHECK(Enum, Name, Version) {#Name, Version},
+LIST_SANITIZER_CHECKS
+#undef SANITIZER_CHECK
+};
+
 static void emitCheckHandlerCall(CodeGenFunction &CGF,
  llvm::FunctionType *FnType,
  ArrayRef FnArgs,
- StringRef CheckName,
+ SanitizerHandler CheckHandler,
  CheckRecoverableKind RecoverKind, bool IsFatal,
  llvm::BasicBlock *ContBB) {
   assert(IsFatal || RecoverKind != CheckRecoverableKind::Unrecoverable);
   bool NeedsAbortSuffix =
   IsFatal && RecoverKind != CheckRecoverableKind::Unrecoverable;
-  std::string FnName = ("__ubsan_handle_" + CheckName +
-(NeedsAbortSuffix ? "_abort" : "")).str();
+  const SanitizerHandlerInfo &CheckInfo = SanitizerHandlers[CheckHandler];
+  const StringRef CheckName = CheckInfo.Name;
+  std::string FnName =
+  ("__ubsan_handle_" + CheckName +
+   (CheckInfo.Version ? "_v" + std::to_string(CheckInfo.Version) : "") +
+   (NeedsAbortSuffix ? "_abort" : ""))
+  .str();
   bool MayReturn =
   !IsFatal || RecoverKind == CheckRecoverableKind::AlwaysRecoverable;
 
@@ -2536,10 +2555,13 @@
 
 void CodeGenFunction::EmitCheck(
 ArrayRef> Checked,
-StringRef CheckName, ArrayRef StaticArgs,
+SanitizerHandler CheckHandler, ArrayRef StaticArgs,
 ArrayRef DynamicArgs) {
   assert(IsSanitizerScope);
   assert(Checked.size() > 0);
+  assert(CheckHandler >= 0 &&
+ CheckHandler < sizeof(SanitizerHandlers) / sizeof(*SanitizerHandlers));
+  const StringRef CheckName = SanitizerHandlers[CheckHandler].Name;
 
   llvm::Value *FatalCond = nullptr;
   llvm::Value *RecoverableCond = nullptr;
@@ -2619,7 +2641,7 @@
   if (!FatalCond || !RecoverableCond) {
 // Simple case: we need to generate a single handler call, either
 // fatal, or non-fatal.
-emitCheckHandlerCall(*this, FnType, Args, CheckName, RecoverKind,
+emitCheckHandlerCall(*this, FnType, Args, CheckHandler, RecoverKind,
  (FatalCond != nullptr), Cont);
   } else {
 // Emit two handler calls: first one for set of unrecoverable checks,
@@ -2629,10 +2651,10 @@
 llvm::BasicBlock *FatalHandlerBB = createBasicBlock("fatal." + CheckName);
 Builder.CreateCondBr(FatalCond,

[PATCH] D27569: [OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.

2016-12-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:9624
 
+  if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200) {
+if (LHSIsNull && RHSType->isQueueT()) {

getLangOpts().OpenCL is redundant because getLangOpts().OpenCLVersion is only 
set for OpenCL.

I would like us to minimize number of this checks in the future.



Comment at: test/CodeGenOpenCL/null_queue.cl:7
+bool f() {
+  return CLK_NULL_QUEUE == get_default_queue() &&
+ get_default_queue() == CLK_NULL_QUEUE;

I think this doesn't handle initialization yet:
  queue_t q = 0;
which should also be possible! 



Comment at: test/CodeGenOpenCL/null_queue.cl:8
+  return CLK_NULL_QUEUE == get_default_queue() &&
+ get_default_queue() == CLK_NULL_QUEUE;
+  // CHECK: icmp eq %opencl.queue_t* null, %{{.*}}

could we just compare directly to 0 to make it simpler?



Comment at: test/CodeGenOpenCL/null_queue.cl:9
+ get_default_queue() == CLK_NULL_QUEUE;
+  // CHECK: icmp eq %opencl.queue_t* null, %{{.*}}
+}

Could we check for exactly two occurrences of icmp?


https://reviews.llvm.org/D27569



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


[PATCH] D27627: Allow target to specify default address space for codegen

2016-12-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

> Because, notably, if you do that, then an attempt to pass &x as an int* will 
> fail, which means this isn't really C++ anymore... and yet that appears to be 
> exactly what you want.

How about when generating alloca instruction, I insert addrspacecast to the 
default address space, then everything is in default address space.


https://reviews.llvm.org/D27627



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


[PATCH] D21453: Add support for attribute "overallocated"

2016-12-12 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 81090.
ahatanak added a comment.

Address review comments.

- Arrays marked "flexible_array" are now treated as flexible arrays.
- __builtin_object_size returns a more accurate numbers for normal C99 flexible 
arrays (see test/CodeGen/object-size.c).

Note that a couple of tests fail with this patch applied since this patch 
depends on https://reviews.llvm.org/D24999.


https://reviews.llvm.org/D21453

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGExpr.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/object-size.c
  test/CodeGenCXX/catch-undef-behavior.cpp
  test/SemaCXX/flexible-array-attr.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2653,6 +2653,7 @@
 case GenericRecord:
   return "(S.getLangOpts().CPlusPlus ? ExpectedStructOrUnionOrClass : "
"ExpectedStructOrUnion)";
+case Field: return "ExpectedField";
 case Func | ObjCMethod | Block: return "ExpectedFunctionMethodOrBlock";
 case Func | ObjCMethod | Class: return "ExpectedFunctionMethodOrClass";
 case Func | Param:
Index: test/SemaCXX/flexible-array-attr.cpp
===
--- /dev/null
+++ test/SemaCXX/flexible-array-attr.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+int g0[16] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to fields}}
+
+struct S0 {
+  int a[4];
+  int foo1() __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to fields}}
+};
+
+struct S1 {
+  int a[4];
+  int *b __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to a non-flexible array member}}
+};
+
+struct S2 {
+  int a[4];
+  int b[4] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to the last member of a struct}}
+  int c[4];
+};
+
+struct S3 {
+  int a[4];
+  int b[] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to a non-flexible array member}}
+};
+
+struct S4 {
+  int a[4];
+  int b[0] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to an array member that has at least one element}}
+};
+
+template
+struct S5 {
+  int a[4];
+  int b[N] __attribute__((flexible_array)); // expected-error {{'flexible_array' attribute only applies to a non-flexible array member}}
+};
+
+struct S6 {
+  int a[4];
+  int b[2] __attribute__((flexible_array));
+};
+
+struct S7 : S6 { // expected-error {{base class 'S6' has a flexible array member}}
+};
+
+int lambda_capture(S6 a) { // expected-note {{'a' declared here}}
+  return [a](){ return 0; }(); // expected-error {{variable 'a' with flexible array member cannot be captured in a lambda expression}}
+}
+
+void pointer_arithmetic(S6 *s6) {
+  int *p = &s6->b[4]; // No warnings.
+}
Index: test/CodeGenCXX/catch-undef-behavior.cpp
===
--- test/CodeGenCXX/catch-undef-behavior.cpp
+++ test/CodeGenCXX/catch-undef-behavior.cpp
@@ -327,6 +327,17 @@
   return incomplete[n];
 }
 
+struct FlexibleArray {
+  int a1[4];
+  int a2[4] __attribute__((flexible_array));
+};
+
+// CHECK-LABEL: @_Z14flexible_array
+int flexible_array(FlexibleArray *p, int n) {
+  // CHECK-NOT: call void @__ubsan_handle_out_of_bounds(
+  return p->a2[n];
+}
+
 typedef __attribute__((ext_vector_type(4))) int V4I;
 // CHECK-LABEL: @_Z12vector_index
 int vector_index(V4I v, int n) {
Index: test/CodeGen/object-size.c
===
--- test/CodeGen/object-size.c
+++ test/CodeGen/object-size.c
@@ -425,6 +425,15 @@
   gi = __builtin_object_size(dv->snd, 3);
 
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(dv->fst, 0);
+  // CHECK: store i32 16
+  gi = __builtin_object_size(dv->fst, 1);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
+  gi = __builtin_object_size(dv->fst, 2);
+  // CHECK: store i32 16
+  gi = __builtin_object_size(d0->fst, 3);
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
   gi = __builtin_object_size(d0->snd, 0);
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
   gi = __builtin_object_size(d0->snd, 1);
@@ -518,6 +527,22 @@
   gi = __builtin_object_size(&dsv[9].snd[0], 1);
 }
 
+struct S0 {
+  int a[16];
+  int b[16] __attribute__((flexible_array));
+};
+
+// CHECK-LABEL: @t

r289446 - [Fix] Add missing include from r289444.

2016-12-12 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Mon Dec 12 10:43:40 2016
New Revision: 289446

URL: http://llvm.org/viewvc/llvm-project?rev=289446&view=rev
Log:
[Fix] Add missing include from r289444.

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

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=289446&r1=289445&r2=289446&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Dec 12 10:43:40 2016
@@ -37,6 +37,8 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Transforms/Utils/SanitizerStats.h"
 
+#include 
+
 using namespace clang;
 using namespace CodeGen;
 


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


[PATCH] D26167: [Clang-tidy] check for malloc, realloc and free calls

2016-12-12 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tidy/cppcoreguidelines/NoMallocCheck.cpp:54
+
+void NoMallocCheck::handleAquisition(const CallExpr *AquisitionCall) {
+  diag(AquisitionCall->getLocStart(),

The handle.* methods now just add more bulk and bring no benefit. With a single 
statement in each function they might as well be inlined and the `check`method 
would be still quite compact:
```
CallExpr Call = nullptr;
StringRef Recommendation;
if ((Call = Result.Nodes.getNodeAs("aquisition")))
  Recommendation = "consider a container or smartpointer";
else if ((Call = ...))
  ...;

assert(Call && "Unhandled binding in the matcher);

diag(Call->getLocStart(),
 "do not allocate memory manually; %0")
  << Recommendation
  << SourceRange(...);
```



Comment at: clang-tidy/cppcoreguidelines/NoMallocCheck.cpp:56
+  diag(AquisitionCall->getLocStart(),
+   "do not allocate memory manually; consider a container or smartpointer")
+  << SourceRange{AquisitionCall->getLocStart(),

"smart pointer" is two words.



Comment at: clang-tidy/cppcoreguidelines/NoMallocCheck.cpp:57
+   "do not allocate memory manually; consider a container or smartpointer")
+  << SourceRange{AquisitionCall->getLocStart(),
+ AquisitionCall->getLocEnd()};

Please use parentheses instead of curly braces for constructor calls 
(`SourceRange(x, y)`), it's more common in LLVM code.


Repository:
  rL LLVM

https://reviews.llvm.org/D26167



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


[PATCH] D27641: DebugInfo: Added support for Checksum debug info feature (Clang part)

2016-12-12 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/Basic/SourceManager.cpp:1447
 
+void SourceManager::getChecksumMD5(FileID FID, std::string &Checksum) const {
+  bool Invalid;

Let's move this whole thing to CGDebugInfo::getOrCreateFile. SourceManager 
isn't caching or managing MD5 checksums at all in this CL.



Comment at: lib/Basic/SourceManager.cpp:1450-1451
+
+  llvm::MemoryBuffer *MemBuffer = getBuffer(FID, &Invalid);
+  if (Invalid) return;
+

If this can fail, we should not pretend to have an MD5 checksum in the debug 
info.



Comment at: lib/Basic/SourceManager.cpp:1461
+
+  for (unsigned i = 0; i < sizeof(Result); i++)
+OS << llvm::format("%02x", Result[i]);

This can use SmallString and stringifyResult() to avoid heap allocations.



Comment at: lib/CodeGen/CGDebugInfo.cpp:350
+  std::string Checksum;
+  SM.getChecksumMD5(SM.getFileID(Loc), Checksum);
+

We should only do this if `CGM.getCodeGenOpts().EmitCodeView`, or we will 
regress compile time on other platforms without any added functionality.


https://reviews.llvm.org/D27641



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


[PATCH] D26768: [analyzer] Improve VirtualCallChecker diagnostics and move to optin package.

2016-12-12 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

In https://reviews.llvm.org/D26768#619222, @malcolm.parsons wrote:

> In https://reviews.llvm.org/D26768#618651, @dcoughlin wrote:
>
> > The definite false positives were cases where the programmer seemed aware 
> > of the semantics of virtual calls during construction/destruction and had 
> > each subclass explicitly call its own version of the virtual method in 
> > question.
>
>
> How is this avoiding the check for a qualifier on the call?
>
>   if (CME->getQualifier())
> callIsNonVirtual = true;
>


They didn't use the qualified version. Rather, each class had duplication of 
the same logic calling the virtual method its individual 
constructor/destructor. In the cases I examined either the virtual method 
didn't call super (most common pattern) or it did and was idempotent if called 
multiple times.

>> The likely false positives were cases where there was no subclass of the 
>> constructed class that overrode the method in question.
> 
> I'd like to be told about these so that the class can be marked final.

I agree, but this produces too many alarms to be on by default in the analyzer. 
I put the check in it in the 'optin' package so individual projects can decide 
whether they want to enforce this rule or not.


Repository:
  rL LLVM

https://reviews.llvm.org/D26768



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


[PATCH] D26846: __uuidof() and declspec(uuid("...")) should be allowed on enumeration types

2016-12-12 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.

This looks good to me, I'll merge this today unless I hear otherwise.


Repository:
  rL LLVM

https://reviews.llvm.org/D26846



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-12 Thread Firat Kasmis via Phabricator via cfe-commits
firolino updated this revision to Diff 81101.
firolino marked an inline comment as done.
firolino added a comment.

Simplified fix-it hint generation.


https://reviews.llvm.org/D27621

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/OneNamePerDeclarationCheck.cpp
  clang-tidy/readability/OneNamePerDeclarationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-one-name-per-declaration.rst
  test/clang-tidy/readability-one-name-per-declaration-complex.cpp
  test/clang-tidy/readability-one-name-per-declaration-modern.cpp
  test/clang-tidy/readability-one-name-per-declaration-simple.cpp

Index: test/clang-tidy/readability-one-name-per-declaration-simple.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-one-name-per-declaration-simple.cpp
@@ -0,0 +1,132 @@
+// RUN: %check_clang_tidy %s readability-one-name-per-declaration %t
+
+int cantTouchA, cantTouchB;
+
+void simple() 
+{
+int dontTouchC;
+
+long empty;
+long long1 = 11, *long2 = &empty, * long3 = ∅
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long long1 = 11;
+// CHECK-FIXES: {{^}}long *long2 = ∅
+// CHECK-FIXES: {{^}}long * long3 = ∅
+
+long ** lint1, lint2 = 0, * lint3, **linn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long ** lint1;
+// CHECK-FIXES: {{^}}long lint2 = 0;
+// CHECK-FIXES: {{^}}long * lint3;
+// CHECK-FIXES: {{^}}long **linn;
+
+	long int* lint4, *lint5,  lint6;
+	// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+	// CHECK-FIXES: {{^	}}long int* lint4;
+	// CHECK-FIXES: {{^	}}long int *lint5;
+	// CHECK-FIXES: {{^	}}long int lint6;
+
+unsigned int uint1 = 0,uint2 = 44u, uint3, uint4=4;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}unsigned int uint1 = 0;
+// CHECK-FIXES: {{^}}unsigned int uint2 = 44u;
+// CHECK-FIXES: {{^}}unsigned int uint3;
+// CHECK-FIXES: {{^}}unsigned int uint4=4;
+
+double darray1[] = {}, darray2[] = {1,	2},dv1 = 3,dv2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}double darray1[] = {};
+// CHECK-FIXES: {{^}}double darray2[] = {1,	2};
+// CHECK-FIXES: {{^}}double dv1 = 3;
+// CHECK-FIXES: {{^}}double dv2;
+
+int notransform[] =   {
+  1,
+  2
+  };
+
+const int cx = 1, cy = 2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}const int cx = 1;
+// CHECK-FIXES: {{^}}const int cy = 2;
+
+volatile int vx, vy;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}volatile int vx;
+// CHECK-FIXES: {{^}}volatile int vy;
+
+signed char sc1 = 'h', sc2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}signed char sc1 = 'h';
+// CHECK-FIXES: {{^}}signed char sc2;
+
+long long ll1, ll2, ***ft;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long long ll1;
+// CHECK-FIXES: {{^}}long long ll2;
+// CHECK-FIXES: {{^}}long long ***ft;
+
+const char *cstr1 = "str1", *cstr2="str2";
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}const char *cstr1 = "str1";
+// CHECK-FIXES: {{^}}const char *cstr2="str2";
+
+const char *literal1 = "clang"		"test" \
+   "one",
+   *literal2 = "empty", literal3[] = "three";
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: declaration statement can be

[PATCH] D27680: [CodeGen] Move lifetime.start of a variable when goto jumps back past its declaration

2016-12-12 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a subscriber: cfe-commits.
ahatanak added a comment.

Add cfe-commits.


https://reviews.llvm.org/D27680



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


[PATCH] D27555: [libcxx] [test] Fix MSVC warning C6001 "Using uninitialized memory".

2016-12-12 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

Hmm, would a pragma guarded by _MSC_VER be better? I can easily do that. I've 
tried to avoid cluttering the test with VC-specific pragmas, but I understand 
your concern about initializing too much memory.


https://reviews.llvm.org/D27555



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-12 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:86
+
+  Diag << FixItHint::CreateReplacement(CommaRange, ";")
+   << FixItHint::CreateReplacement(AfterCommaToVarNameRange,

A `SourceLocation` can be implicitly converted to a `SourceRange`.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:87
+  Diag << FixItHint::CreateReplacement(CommaRange, ";")
+   << FixItHint::CreateReplacement(AfterCommaToVarNameRange,
+   "\n" + CurrentIndent +

Is an insert simpler?
```
FixItHint::CreateInsertion(CommaLocation.getLocWithOffset(1),
   "\n" + CurrentIndent + UserWrittenType + " ");
```


https://reviews.llvm.org/D27621



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


[PATCH] D27270: [libcxx] [test] Fix MSVC x64 warning C4267 "conversion from 'size_t' to 'int' [or 'unsigned int'], possible loss of data", part 4/4.

2016-12-12 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

Yeah, users are free to do this, which also triggers conversion warnings for 
us. I think I'll need to investigate actually fixing/suppressing them in our 
sources and abandoning this patch; leaving it open for now as a todo.


https://reviews.llvm.org/D27270



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


[PATCH] D26167: [Clang-tidy] check for malloc, realloc and free calls

2016-12-12 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked 3 inline comments as done.
JonasToth added a comment.

removed the function calls, a little doc tidy as well


Repository:
  rL LLVM

https://reviews.llvm.org/D26167



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


[PATCH] D26167: [Clang-tidy] check for malloc, realloc and free calls

2016-12-12 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 81103.
JonasToth added a comment.

fixes last review comments from alex


Repository:
  rL LLVM

https://reviews.llvm.org/D26167

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/NoMallocCheck.cpp
  clang-tidy/cppcoreguidelines/NoMallocCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-no-malloc.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-no-malloc.cpp

Index: test/clang-tidy/cppcoreguidelines-no-malloc.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-no-malloc.cpp
@@ -0,0 +1,42 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-no-malloc %t
+
+using size_t = unsigned long;
+
+void *malloc(size_t size);
+void *calloc(size_t num, size_t size);
+void *realloc(void *ptr, size_t size);
+void free(void *ptr);
+
+void malloced_array() {
+  int *array0 = (int *)malloc(sizeof(int) * 20);
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not manage memory manually; consider a container or smart pointer [cppcoreguidelines-no-malloc]
+
+  int *zeroed = (int *)calloc(20, sizeof(int));
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not manage memory manually; consider a container or smart pointer [cppcoreguidelines-no-malloc]
+
+  // reallocation memory, std::vector shall be used
+  char *realloced = (char *)realloc(array0, 50 * sizeof(int));
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: do not manage memory manually; consider std::vector or std::string [cppcoreguidelines-no-malloc]
+
+  // freeing memory the bad way
+  free(realloced);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not manage memory manually; use RAII [cppcoreguidelines-no-malloc]
+
+  // check if a call to malloc as function argument is found as well
+  free(malloc(20));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not manage memory manually; use RAII [cppcoreguidelines-no-malloc]
+  // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: do not manage memory manually; consider a container or smart pointer [cppcoreguidelines-no-malloc]
+}
+
+/// newing an array is still not good, but not relevant to this checker
+void newed_array() {
+  int *new_array = new int[10]; // OK(1)
+}
+
+void arbitrary_call() {
+  // we dont want every function to raise the warning even if malloc is in the name
+  malloced_array(); // OK(2)
+
+  // completly unrelated function call to malloc
+  newed_array(); // OK(3)
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -22,6 +22,7 @@
cert-msc50-cpp
cert-oop11-cpp (redirects to misc-move-constructor-init) 
cppcoreguidelines-interfaces-global-init
+   cppcoreguidelines-no-malloc
cppcoreguidelines-pro-bounds-array-to-pointer-decay
cppcoreguidelines-pro-bounds-constant-array-index
cppcoreguidelines-pro-bounds-pointer-arithmetic
Index: docs/clang-tidy/checks/cppcoreguidelines-no-malloc.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-no-malloc.rst
@@ -0,0 +1,27 @@
+.. title:: clang-tidy - cppcoreguidelines-no-malloc
+
+cppcoreguidelines-no-malloc
+===
+
+This check handles C-Style memory management using ``malloc()``, ``realloc()``, 
+``calloc()`` and ``free()``. It warns about its use and tries to suggest the use 
+of an appropriate RAII object.
+See `C++ Core Guidelines
+`
+
+There is no attempt made to provide fixit hints, since manual resource management isn't
+easily transformed automatically into RAII.
+
+.. code-block:: c++
+
+  // Warns each of the following lines.
+  // Containers like std::vector or std::string should be used.
+  char* some_string = (char*) malloc(sizeof(char) * 20); 
+  char* some_string = (char*) realloc(sizeof(char) * 30);
+  free(some_string);
+
+  int* int_array = (int*) calloc(30, sizeof(int)); 
+
+  // Rather use a smartpointer or stack variable.
+  struct some_struct* = (struct some_struct*) malloc(sizeof(struct some_struct));
+
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -81,6 +81,10 @@
   Warns if an object is used after it has been moved, without an intervening
   reinitialization.
 
+- New `cppcoreguidelines-no-malloc 
+  `_ check
+  warns if C-style memory management is used and suggests the use of RAII.
+
 - `modernize-make-unique
   `_
   and `modernize-make-shared
Index: clang-tidy/cppcoreguidelines/NoMallocCheck.h
=

r289450 - Fix format and a few typos in comments.

2016-12-12 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Mon Dec 12 12:00:20 2016
New Revision: 289450

URL: http://llvm.org/viewvc/llvm-project?rev=289450&view=rev
Log:
Fix format and a few typos in comments.

Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=289450&r1=289449&r2=289450&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Mon Dec 12 12:00:20 2016
@@ -326,7 +326,7 @@ clang_isFileMultipleIncludeGuarded(CXTra
  *
  * \param tu the translation unit
  *
-* \param file_name the name of the file.
+ * \param file_name the name of the file.
  *
  * \returns the file handle for the named file in the translation unit \p tu,
  * or a NULL file handle if the file was not a part of this translation unit.

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=289450&r1=289449&r2=289450&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon Dec 12 12:00:20 2016
@@ -490,7 +490,7 @@ enum OpenMPSchedType {
   OMP_sch_runtime = 37,
   OMP_sch_auto = 38,
   /// static with chunk adjustment (e.g., simd)
-  OMP_sch_static_balanced_chunked   = 45,
+  OMP_sch_static_balanced_chunked = 45,
   /// \brief Lower bound for 'ordered' versions.
   OMP_ord_lower = 64,
   OMP_ord_static_chunked = 65,
@@ -2930,8 +2930,8 @@ void CGOpenMPRuntime::createOffloadEntry
 
 void CGOpenMPRuntime::createOffloadEntriesAndInfoMetadata() {
   // Emit the offloading entries and metadata so that the device codegen side
-  // can
-  // easily figure out what to emit. The produced metadata looks like this:
+  // can easily figure out what to emit. The produced metadata looks like
+  // this:
   //
   // !omp_offload.info = !{!1, ...}
   //
@@ -,9 +,8 @@ void CGOpenMPRuntime::emitReduction(Code
   auto *IdentTLoc = emitUpdateLocation(CGF, Loc, OMP_ATOMIC_REDUCE);
   auto *ThreadId = getThreadID(CGF, Loc);
   auto *ReductionArrayTySize = CGF.getTypeSize(ReductionArrayTy);
-  auto *RL =
-CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(ReductionList.getPointer(),
-CGF.VoidPtrTy);
+  auto *RL = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
+  ReductionList.getPointer(), CGF.VoidPtrTy);
   llvm::Value *Args[] = {
   IdentTLoc, // ident_t *
   ThreadId,  // i32 

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=289450&r1=289449&r2=289450&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Dec 12 12:00:20 2016
@@ -326,8 +326,8 @@ public:
   Scope *getCurScope() { return Stack.back().CurScope; }
   SourceLocation getConstructLoc() { return Stack.back().ConstructLoc; }
 
-  // Do the check specified in \a Check to all component lists and return true
-  // if any issue is found.
+  /// Do the check specified in \a Check to all component lists and return true
+  /// if any issue is found.
   bool checkMappableExprComponentListsForDecl(
   ValueDecl *VD, bool CurrentRegionOnly,
   const llvm::function_ref<
@@ -355,8 +355,8 @@ public:
 return false;
   }
 
-  // Create a new mappable expression component list associated with a given
-  // declaration and initialize it with the provided list of components.
+  /// Create a new mappable expression component list associated with a given
+  /// declaration and initialize it with the provided list of components.
   void addMappableExpressionComponents(
   ValueDecl *VD,
   OMPClauseMappableExprCommon::MappableExprComponentListRef Components,
@@ -919,7 +919,7 @@ bool Sema::IsOpenMPCapturedByRef(ValueDe
 OpenMPClauseKind WhereFoundClauseKind) {
   // Only the map clause information influences how a variable is
   // captured. E.g. is_device_ptr does not require changing the default
-  // behaviour.
+  // behavior.
   if (WhereFoundClauseKind != OMPC_map)
 return false;
 
@@ -3359,7 +3359,7 @@ Expr *OpenMPIterationSpaceChecker::Build
   return nullptr;
 }
 
-/// \brief Build instillation of the counter be used for codegen.
+/// \brief Build initialization of the counter to be used for codegen.
 Expr *OpenMPIterationSpaceChecker::BuildCounterInit() const { return LB; }
 
 /// \brief Build step of the counter be used for codegen.
@@ -6124,11 +6124,10 @@ StmtResult Sema::ActOnOpenMPTeamsDis

[PATCH] D27555: [libcxx] [test] Fix MSVC warning C6001 "Using uninitialized memory".

2016-12-12 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

Actually, the compiler bug was resolved as fixed earlier today.  Verifying...


https://reviews.llvm.org/D27555



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


[PATCH] D21695: [clang] Version support for UBSan handlers

2016-12-12 Thread Andrew Ford via Phabricator via cfe-commits
andrewford added a comment.

This broke the build on android due to use of std::to_string. Would someone 
mind changing it to llvm::to_string, I don't have commit access to change it 
myself. Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D21695



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


Re: r289285 - Fix unused variable warnings. NFCI.

2016-12-12 Thread David Blaikie via cfe-commits
On Fri, Dec 9, 2016 at 2:55 PM Simon Pilgrim via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rksimon
> Date: Fri Dec  9 16:45:21 2016
> New Revision: 289285
>
> URL: http://llvm.org/viewvc/llvm-project?rev=289285&view=rev
> Log:
> Fix unused variable warnings. NFCI.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGExprConstant.cpp
> cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=289285&r1=289284&r2=289285&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Fri Dec  9 16:45:21 2016
> @@ -1617,9 +1617,9 @@ static llvm::Constant *EmitNullConstantF
>  }
>
>  llvm::Constant *CodeGenModule::EmitNullConstant(QualType T) {
> -  if (auto PT = T->getAs())
> -return
> getNullPointer(cast(getTypes().ConvertTypeForMem(T)),
> -  T);
> +  if (T->getAs())
>

isa(*T) ?


> +return getNullPointer(
> +cast(getTypes().ConvertTypeForMem(T)), T);
>
>if (getTypes().isZeroInitializable(T))
>  return llvm::Constant::getNullValue(getTypes().ConvertTypeForMem(T));
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=289285&r1=289284&r2=289285&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Fri Dec  9 16:45:21 2016
> @@ -742,7 +742,7 @@ bool CodeGenTypes::isPointerZeroInitiali
>  }
>
>  bool CodeGenTypes::isZeroInitializable(QualType T) {
> -  if (auto PT = T->getAs())
> +  if (T->getAs())
>

Similarly here.


>  return Context.getTargetNullPointerValue(T) == 0;
>
>if (const auto *AT = Context.getAsArrayType(T)) {
>
>
> ___
> 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] D27669: [clang-move] Use appendArgumentsAdjuster for adding extra arguments

2016-12-12 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added inline comments.



Comment at: clang-move/tool/ClangMoveMain.cpp:109
 OptionsParser.getSourcePathList());
+  // Add "-fparse-all-comments" compile option to make clang parse all comments
+  Tool.appendArgumentsAdjuster(tooling::getInsertArgumentAdjuster(

hokein wrote:
> Nit: Missing a trailing `.`.
yeah, will add before the commit.


Repository:
  rL LLVM

https://reviews.llvm.org/D27669



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


r289452 - Avoid use of std::to_string. NFC.

2016-12-12 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Mon Dec 12 12:47:33 2016
New Revision: 289452

URL: http://llvm.org/viewvc/llvm-project?rev=289452&view=rev
Log:
Avoid use of std::to_string. NFC.

Apparently this routine isn't available on some Android platforms. See
the mailing list thread re: D21695.

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

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=289452&r1=289451&r2=289452&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Dec 12 12:47:33 2016
@@ -2529,7 +2529,7 @@ static void emitCheckHandlerCall(CodeGen
   const StringRef CheckName = CheckInfo.Name;
   std::string FnName =
   ("__ubsan_handle_" + CheckName +
-   (CheckInfo.Version ? "_v" + std::to_string(CheckInfo.Version) : "") +
+   (CheckInfo.Version ? "_v" + llvm::utostr(CheckInfo.Version) : "") +
(NeedsAbortSuffix ? "_abort" : ""))
   .str();
   bool MayReturn =


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


Re: [PATCH] D21695: [clang] Version support for UBSan handlers

2016-12-12 Thread Vedant Kumar via cfe-commits

> On Dec 12, 2016, at 10:17 AM, Andrew Ford via Phabricator 
>  wrote:
> 
> andrewford added a comment.
> 
> This broke the build on android due to use of std::to_string. Would someone 
> mind changing it to llvm::to_string, I don't have commit access to change it 
> myself. Thanks!

Should be done with r289452.

vedant

> 
> 
> Repository:
>  rL LLVM
> 
> https://reviews.llvm.org/D21695
> 
> 
> 

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


Re: [PATCH] D21695: [clang] Version support for UBSan handlers

2016-12-12 Thread Filipe Cabecinhas via cfe-commits
Thanks Vedant!
Andrew: does Android not support C++11? I don't understand why it wouldn't
have these funcions.

Thank you,

 Filipe

On Mon, 12 Dec 2016 at 18:58, Vedant Kumar  wrote:

>
>
> > On Dec 12, 2016, at 10:17 AM, Andrew Ford via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
> >
>
> > andrewford added a comment.
>
> >
>
> > This broke the build on android due to use of std::to_string. Would
> someone mind changing it to llvm::to_string, I don't have commit access to
> change it myself. Thanks!
>
>
>
> Should be done with r289452.
>
>
>
> vedant
>
>
>
> >
>
> >
>
> > Repository:
>
> >  rL LLVM
>
> >
>
> > https://reviews.llvm.org/D21695
>
> >
>
> >
>
> >
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24933: Enable configuration files in clang

2016-12-12 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added inline comments.



Comment at: include/clang/Driver/Driver.h:287
+  const std::string &getConfigFile() const { return ConfigFile; }
+  void setConfigFile(StringRef x, unsigned N) {
+ConfigFile = x;

x -> FileName



Comment at: lib/Driver/Driver.cpp:172
+NumConfigArgs = static_cast(NumCfgArgs);
+  }
+

If `NumCfgArgs == 0` it would be nice to warn that the config file is empty?



Comment at: lib/Driver/Driver.cpp:2698
+  for (unsigned I = 0; I < NumConfigArgs; ++I)
+C.getArgs().getArgs()[I]->claim();
+

Why shouldn't we warn about those? Should clang warn and point to the config 
file instead?



Comment at: tools/driver/driver.cpp:318
+
+/// Deduce configuration name if it is encoded in the executable name.
+///

Use  `\brief` here?



Comment at: tools/driver/driver.cpp:333
+  size_t Pos = PName.find("-clang");
+  if (Pos != StringRef::npos) {
+ConfigFile.append(PName.begin(), PName.begin() + Pos);

You can early `return false` here if `Pos == StringRef::npos`


https://reviews.llvm.org/D24933



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


[PATCH] D27473: Bring back note about not supporting global register variables

2016-12-12 Thread Michael Kuperstein via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289455: Bring back note about not supporting global register 
variables. (authored by mkuper).

Changed prior to commit:
  https://reviews.llvm.org/D27473?vs=80450&id=81113#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27473

Files:
  cfe/trunk/docs/UsersManual.rst


Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -1830,6 +1830,10 @@
  ...
  local_function(1);
 
+-  clang only supports global register variables when the register specified
+   is non-allocatable (e.g. the stack pointer). Support for general global
+   register variables is unlikely to be implemented soon because it requires
+   additional LLVM backend support.
 -  clang does not support static initialization of flexible array
members. This appears to be a rarely used extension, but could be
implemented pending user demand.


Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -1830,6 +1830,10 @@
  ...
  local_function(1);
 
+-  clang only supports global register variables when the register specified
+   is non-allocatable (e.g. the stack pointer). Support for general global
+   register variables is unlikely to be implemented soon because it requires
+   additional LLVM backend support.
 -  clang does not support static initialization of flexible array
members. This appears to be a rarely used extension, but could be
implemented pending user demand.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r289455 - Bring back note about not supporting global register variables.

2016-12-12 Thread Michael Kuperstein via cfe-commits
Author: mkuper
Date: Mon Dec 12 13:11:39 2016
New Revision: 289455

URL: http://llvm.org/viewvc/llvm-project?rev=289455&view=rev
Log:
Bring back note about not supporting global register variables.

This was accidentally removed in r260506, even though we only support
non-allocatable global register variables. The general (allocatable) case
is explicitly not supported.

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

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=289455&r1=289454&r2=289455&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon Dec 12 13:11:39 2016
@@ -1830,6 +1830,10 @@ extensions are not implemented yet:
  ...
  local_function(1);
 
+-  clang only supports global register variables when the register specified
+   is non-allocatable (e.g. the stack pointer). Support for general global
+   register variables is unlikely to be implemented soon because it requires
+   additional LLVM backend support.
 -  clang does not support static initialization of flexible array
members. This appears to be a rarely used extension, but could be
implemented pending user demand.


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


Re: [PATCH] D27597: [DebugInfo] Restore test case for long double constants.

2016-12-12 Thread David Blaikie via cfe-commits
While it's possible to do arbitrary script things - we prefer nto to to
ensure the tests are portable. (we have some custom implementations of
common unix utilities for portability of those).

In this case, can you xfail this on platforms that don't have the feature
you want? rather than trying to detect it at test-execution time. (or say
"requires" to opt the test in only on platforms you know have the thing you
want)

On Fri, Dec 9, 2016 at 4:00 AM David Gross via Phabricator via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> dgross added a comment.
>
> I don't know exactly what the RUN syntax supported by lit is.  What I've
> done here looks complex, but it does work for Linux.  What about other
> platforms?
>
> Is there some better way of writing a test case where the checks to be
> done by FileCheck depend on some property of the file being analyzed (here,
> the size of long double, as embedded in the debug metadata)?  I don't see
> any support for conditions in FileCheck.
>
> Maybe I'm going about this completely the wrong way?
>
>
> https://reviews.llvm.org/D27597
>
>
>
> ___
> 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] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.

2016-12-12 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

@alexfh , friendly ping.  I'm not in a huge rush on this or anything, but I 
don't want one or both of us to lose all context here...


https://reviews.llvm.org/D27284



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


r289458 - Fix typo and remove unnecessary statement.

2016-12-12 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Mon Dec 12 13:26:31 2016
New Revision: 289458

URL: http://llvm.org/viewvc/llvm-project?rev=289458&view=rev
Log:
Fix typo and remove unnecessary statement.

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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=289458&r1=289457&r2=289458&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon Dec 12 13:26:31 2016
@@ -2769,7 +2769,6 @@ createOffloadingBinaryDescriptorFunction
   Args.push_back(&DummyPtr);
 
   CodeGenFunction CGF(CGM);
-  GlobalDecl();
   auto &FI = CGM.getTypes().arrangeBuiltinFunctionDeclaration(C.VoidTy, Args);
   auto FTy = CGM.getTypes().GetFunctionType(FI);
   auto *Fn =
@@ -6142,7 +6141,7 @@ bool CGOpenMPRuntime::emitTargetFunction
   // Try to detect target regions in the function.
   scanForTargetRegionsFunctions(FD.getBody(), CGM.getMangledName(GD));
 
-  // We should not emit any function othen that the ones created during the
+  // We should not emit any function other that the ones created during the
   // scanning. Therefore, we signal that this function is completely dealt
   // with.
   return true;


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


r289459 - [Frontend] Use vfs for directory iteration while searching PCHs. NFCI

2016-12-12 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Dec 12 13:28:21 2016
New Revision: 289459

URL: http://llvm.org/viewvc/llvm-project?rev=289459&view=rev
Log:
[Frontend] Use vfs for directory iteration while searching PCHs. NFCI

Use the vfs lookup instead of real filesytem and handle the case where
-include-pch is a directory and this dir is searched for a PCH.

Modified:
cfe/trunk/lib/Frontend/FrontendAction.cpp

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=289459&r1=289458&r2=289459&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Mon Dec 12 13:28:21 2016
@@ -288,14 +288,15 @@ bool FrontendAction::BeginSourceFile(Com
   SmallString<128> DirNative;
   llvm::sys::path::native(PCHDir->getName(), DirNative);
   bool Found = false;
-  for (llvm::sys::fs::directory_iterator Dir(DirNative, EC), DirEnd;
+  vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
+  for (vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {
 // Check whether this is an acceptable AST file.
 if (ASTReader::isAcceptableASTFile(
-Dir->path(), FileMgr, CI.getPCHContainerReader(),
+Dir->getName(), FileMgr, CI.getPCHContainerReader(),
 CI.getLangOpts(), CI.getTargetOpts(), CI.getPreprocessorOpts(),
 SpecificModuleCachePath)) {
-  PPOpts.ImplicitPCHInclude = Dir->path();
+  PPOpts.ImplicitPCHInclude = Dir->getName();
   Found = true;
   break;
 }


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


r289460 - [CrashReproducer] Collect PCH included via -include-pch

2016-12-12 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Dec 12 13:28:25 2016
New Revision: 289460

URL: http://llvm.org/viewvc/llvm-project?rev=289460&view=rev
Log:
[CrashReproducer] Collect PCH included via -include-pch

Collect the necessary input PCH files.

Do not try to validate the AST before copying it out because if the
crash is in this path, we won't be able to collect it. Instead only
check if it's a file containg an AST.

rdar://problem/27913709

Added:
cfe/trunk/test/Modules/crash-vfs-include-pch.m
Modified:
cfe/trunk/lib/Driver/Job.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/lib/Driver/Job.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Job.cpp?rev=289460&r1=289459&r2=289460&view=diff
==
--- cfe/trunk/lib/Driver/Job.cpp (original)
+++ cfe/trunk/lib/Driver/Job.cpp Mon Dec 12 13:28:25 2016
@@ -50,9 +50,8 @@ static bool skipArgs(const char *Flag, b
   bool ShouldSkip = llvm::StringSwitch(Flag)
 .Cases("-MF", "-MT", "-MQ", "-serialize-diagnostic-file", true)
 .Cases("-o", "-coverage-file", "-dependency-file", true)
-.Cases("-fdebug-compilation-dir", "-include-pch", true)
+.Cases("-fdebug-compilation-dir", "-diagnostic-log-file", true)
 .Cases("-dwarf-debug-flags", "-ivfsoverlay", true)
-.Case("-diagnostic-log-file", true)
 .Default(false);
   if (ShouldSkip)
 return true;
@@ -64,7 +63,7 @@ static bool skipArgs(const char *Flag, b
 .Cases("-internal-externc-isystem", "-iprefix", true)
 .Cases("-iwithprefixbefore", "-isystem", "-iquote", true)
 .Cases("-isysroot", "-I", "-F", "-resource-dir", true)
-.Case("-iframework", true)
+.Cases("-iframework", "-include-pch", true)
 .Default(false);
   if (IsInclude)
 return HaveCrashVFS ? false : true;

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=289460&r1=289459&r2=289460&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Dec 12 13:28:25 2016
@@ -149,6 +149,38 @@ static void collectHeaderMaps(const Head
 MDC->addFile(Name);
 }
 
+static void collectIncludePCH(CompilerInstance &CI,
+  std::shared_ptr MDC) {
+  const PreprocessorOptions &PPOpts = CI.getPreprocessorOpts();
+  if (PPOpts.ImplicitPCHInclude.empty())
+return;
+
+  StringRef PCHInclude = PPOpts.ImplicitPCHInclude;
+  FileManager &FileMgr = CI.getFileManager();
+  const DirectoryEntry *PCHDir = FileMgr.getDirectory(PCHInclude);
+  if (!PCHDir) {
+MDC->addFile(PCHInclude);
+return;
+  }
+
+  std::error_code EC;
+  SmallString<128> DirNative;
+  llvm::sys::path::native(PCHDir->getName(), DirNative);
+  vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
+  SimpleASTReaderListener Validator(CI.getPreprocessor());
+  for (vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd;
+   Dir != DirEnd && !EC; Dir.increment(EC)) {
+// Check whether this is an AST file. ASTReader::isAcceptableASTFile is not
+// used here since we're not interested in validating the PCH at this time,
+// but only to check whether this is a file containing an AST.
+if (!ASTReader::readASTFileControlBlock(
+Dir->getName(), FileMgr, CI.getPCHContainerReader(),
+/*FindModuleFileExtensions=*/false, Validator,
+/*ValidateDiagnosticOptions=*/false))
+  MDC->addFile(Dir->getName());
+  }
+}
+
 // Diagnostics
 static void SetUpDiagnosticLog(DiagnosticOptions *DiagOpts,
const CodeGenOptions *CodeGenOpts,
@@ -379,6 +411,7 @@ void CompilerInstance::createPreprocesso
   if (ModuleDepCollector) {
 addDependencyCollector(ModuleDepCollector);
 collectHeaderMaps(PP->getHeaderSearchInfo(), ModuleDepCollector);
+collectIncludePCH(*this, ModuleDepCollector);
   }
 
   for (auto &Listener : DependencyCollectors)

Added: 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=289460&view=auto
==
--- cfe/trunk/test/Modules/crash-vfs-include-pch.m (added)
+++ cfe/trunk/test/Modules/crash-vfs-include-pch.m Mon Dec 12 13:28:25 2016
@@ -0,0 +1,43 @@
+// REQUIRES: crash-recovery, shell, system-darwin
+//
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/m %t/out
+
+// RUN: %clang_cc1 -x objective-c-header -emit-pch %S/Inputs/pch-used.h \
+// RUN: -o %t/out/pch-used.h.pch -fmodules -fimplicit-module-maps \
+// RUN: -fmodules-cache-path=%t/cache -O0 \
+// RUN: -isystem %S/Inputs/System/usr/include
+
+// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
+// RUN: %clang %s -E -include-pch %t/out/pch-used.h.pch -fmodules -n

[PATCH] D27520: [clang-tidy] Add check for redundant function pointer dereferences

2016-12-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Nice, the patch looks good to me.




Comment at: 
docs/clang-tidy/checks/readability-redundant-function-ptr-dereference.rst:25
+  int i = (*p)(10, 50);
+

Nit: an extra blank line.


https://reviews.llvm.org/D27520



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


Re: r289308 - [clang-format] Another attempt at python 3 compatibility

2016-12-12 Thread Vedant Kumar via cfe-commits
Thanks for double-checking this. I realized that there's a problem with my
patch: skipping the encoding step when using Python 3 could cause problems when
we use difflib.SequenceMatcher.

I don't know how to fix this, since the strings in vim.current.buffer appear to
be 'raw'. They are not encoded in any valid way. This happens with both the
python 2/3 vim interfaces. You can test this by creating a buffer with an emoji
in it ('😀') and then running:

  :set fileencoding=utf8
  :python import vim
  :python print(len(vim.current.buffer[0]))
  4

That makes us responsible for picking an encoding and using it consistently [*].
However, I don't know how to properly encode an invalid string in Python 3. Is
there some way to 'reinterpret_cast' it to a bytes object?

vedant

[*] I'd rather get rid of the encoding/decoding steps entirely, but I don't 
think
this is possible, because that would prevent us from using the JSON module.

> On Dec 10, 2016, at 6:16 AM, Nico Weber  wrote:
> 
> Shouldn't this at least use >=? (But it feels like there is probably a way 
> that doesn't have to do UA sniffing, so to speak)
> 
> On Dec 9, 2016 8:04 PM, "Vedant Kumar via cfe-commits" 
>  wrote:
> Author: vedantk
> Date: Fri Dec  9 18:54:13 2016
> New Revision: 289308
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=289308&view=rev
> Log:
> [clang-format] Another attempt at python 3 compatibility
> 
> The entries in vim.current.buffer appear to be decoded strings, which
> means that python3 won't allow invoking 'decode' on them. Keep the old
> behavior when running under python2, but skip the error-inducing decode
> step with python3..
> 
> Modified:
> cfe/trunk/tools/clang-format/clang-format.py
> 
> Modified: cfe/trunk/tools/clang-format/clang-format.py
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.py?rev=289308&r1=289307&r2=289308&view=diff
> ==
> --- cfe/trunk/tools/clang-format/clang-format.py (original)
> +++ cfe/trunk/tools/clang-format/clang-format.py Fri Dec  9 18:54:13 2016
> @@ -29,6 +29,7 @@ from __future__ import print_function
> 
>  import difflib
>  import json
> +import platform
>  import subprocess
>  import sys
>  import vim
> @@ -48,10 +49,15 @@ fallback_style = None
>  if vim.eval('exists("g:clang_format_fallback_style")') == "1":
>fallback_style = vim.eval('g:clang_format_fallback_style')
> 
> +def get_buffer(encoding):
> +  if platform.python_version_tuple()[0] == '3':
> +return vim.current.buffer
> +  return [ line.decode(encoding) for line in vim.current.buffer ]
> +
>  def main():
># Get the current text.
>encoding = vim.eval("&encoding")
> -  buf = [ line.decode(encoding) for line in vim.current.buffer ]
> +  buf = get_buffer(encoding)
>text = '\n'.join(buf)
> 
># Determine range to format.
> 
> 
> ___
> 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


[libcxx] r289463 - [libcxx] [test] Change ifstream constructor tests to handle read-only files.

2016-12-12 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Mon Dec 12 13:50:22 2016
New Revision: 289463

URL: http://llvm.org/viewvc/llvm-project?rev=289463&view=rev
Log:
[libcxx] [test] Change ifstream constructor tests to handle read-only files.

Certain source control systems like to set the read-only bit on their files,
which interferes with opening "test.dat" for both input and output.
Fortunately, we can work around this without losing test coverage.
Now, the ifstream.cons tests have comments referring to the ofstream.cons tests.
There, we're creating writable files (not checked into source control),
where the ifstream constructor tests will succeed.

Fixes D26814.

Modified:

libcxx/trunk/test/std/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp

libcxx/trunk/test/std/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp

libcxx/trunk/test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp

libcxx/trunk/test/std/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp

Modified: 
libcxx/trunk/test/std/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp?rev=289463&r1=289462&r2=289463&view=diff
==
--- 
libcxx/trunk/test/std/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp
 Mon Dec 12 13:50:22 2016
@@ -25,22 +25,16 @@ int main()
 fs >> x;
 assert(x == 3.25);
 }
-{
-std::ifstream fs("test.dat", std::ios_base::out);
-double x = 0;
-fs >> x;
-assert(x == 3.25);
-}
+// std::ifstream(const char*, std::ios_base::openmode) is tested in
+// 
test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp
+// which creates writable files.
 {
 std::wifstream fs("test.dat");
 double x = 0;
 fs >> x;
 assert(x == 3.25);
 }
-{
-std::wifstream fs("test.dat", std::ios_base::out);
-double x = 0;
-fs >> x;
-assert(x == 3.25);
-}
+// std::wifstream(const char*, std::ios_base::openmode) is tested in
+// 
test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp
+// which creates writable files.
 }

Modified: 
libcxx/trunk/test/std/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp?rev=289463&r1=289462&r2=289463&view=diff
==
--- 
libcxx/trunk/test/std/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp
 Mon Dec 12 13:50:22 2016
@@ -25,22 +25,16 @@ int main()
 fs >> x;
 assert(x == 3.25);
 }
-{
-std::ifstream fs(std::string("test.dat"), std::ios_base::out);
-double x = 0;
-fs >> x;
-assert(x == 3.25);
-}
+// std::ifstream(const std::string&, std::ios_base::openmode) is tested in
+// 
test/std/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp
+// which creates writable files.
 {
 std::wifstream fs(std::string("test.dat"));
 double x = 0;
 fs >> x;
 assert(x == 3.25);
 }
-{
-std::wifstream fs(std::string("test.dat"), std::ios_base::out);
-double x = 0;
-fs >> x;
-assert(x == 3.25);
-}
+// std::wifstream(const std::string&, std::ios_base::openmode) is tested in
+// 
test/std/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp
+// which creates writable files.
 }

Modified: 
libcxx/trunk/test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp?rev=289463&r1=289462&r2=289463&view=diff
==
--- 
libcxx/trunk/test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp
 Mon Dec 12 13:50:22 2016
@@ -31,6 +31,12 @@ int main()
 fs >> x;
 assert(x == 3.25);
 }
+{
+std::ifstream fs(temp.c_str(), std::ios_base::out);
+double x = 0;
+fs >> x;
+assert(x == 3.25);
+}
 std::remove(temp.c_str());
 {
 std::wofstream fs(temp.c_str());
@@ -41,6 +47,12 @@ int main()
 double x = 0;
 fs >> x;
 assert(x == 3.25);
+}
+{
+st

[libcxx] r289462 - [libcxx] [test] Fix an improper assumption about Null Forward Iterators.

2016-12-12 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Mon Dec 12 13:50:14 2016
New Revision: 289462

URL: http://llvm.org/viewvc/llvm-project?rev=289462&view=rev
Log:
[libcxx] [test] Fix an improper assumption about Null Forward Iterators.

Value-initialized iterators still can't be compared to those with parents.

Fixes D26626.

Modified:
libcxx/trunk/test/std/containers/sequences/list/iterators.pass.cpp

Modified: libcxx/trunk/test/std/containers/sequences/list/iterators.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/iterators.pass.cpp?rev=289462&r1=289461&r2=289462&view=diff
==
--- libcxx/trunk/test/std/containers/sequences/list/iterators.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/sequences/list/iterators.pass.cpp Mon Dec 
12 13:50:14 2016
@@ -138,7 +138,6 @@ int main()
 #endif
 #if TEST_STD_VER > 11
 {
-std::list c;
 std::list::iterator ii1{}, ii2{};
 std::list::iterator ii4 = ii1;
 std::list::const_iterator cii{};
@@ -151,9 +150,6 @@ int main()
 assert ( (cii == ii1 ));
 assert (!(ii1 != cii ));
 assert (!(cii != ii1 ));
-
-assert ( ii1 != c.cbegin());
-assert ( cii != c.begin());
 }
 #endif
 


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


[clang-tools-extra] r289464 - [clang-move] Use appendArgumentsAdjuster for adding extra arguments

2016-12-12 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Mon Dec 12 13:56:37 2016
New Revision: 289464

URL: http://llvm.org/viewvc/llvm-project?rev=289464&view=rev
Log:
[clang-move] Use appendArgumentsAdjuster for adding extra arguments

1. Remove some boilerplate code for appending -fparse-all-comments to the list 
of arguments.
2. Run clang-format -i against ClangMoveMain.cpp.

Test plan: make check-all

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

Modified:
clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp

Modified: clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp?rev=289464&r1=289463&r2=289464&view=diff
==
--- clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp (original)
+++ clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp Mon Dec 12 
13:56:37 2016
@@ -61,19 +61,19 @@ cl::opt
 NewCC("new_cc", cl::desc("The relative/absolute file path of new cc."),
   cl::cat(ClangMoveCategory));
 
-cl::opt OldDependOnNew(
-"old_depend_on_new",
-cl::desc(
-"Whether old header will depend on new header. If true, clang-move 
will "
-"add #include of new header to old header."),
-cl::init(false), cl::cat(ClangMoveCategory));
-
-cl::opt NewDependOnOld(
-"new_depend_on_old",
-cl::desc(
-"Whether new header will depend on old header. If true, clang-move 
will "
-"add #include of old header to new header."),
-cl::init(false), cl::cat(ClangMoveCategory));
+cl::opt
+OldDependOnNew("old_depend_on_new",
+   cl::desc("Whether old header will depend on new header. If "
+"true, clang-move will "
+"add #include of new header to old header."),
+   cl::init(false), cl::cat(ClangMoveCategory));
+
+cl::opt
+NewDependOnOld("new_depend_on_old",
+   cl::desc("Whether new header will depend on old header. If "
+"true, clang-move will "
+"add #include of old header to new header."),
+   cl::init(false), cl::cat(ClangMoveCategory));
 
 cl::opt
 Style("style",
@@ -95,18 +95,7 @@ cl::opt DumpDecls(
 
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
-  // Add "-fparse-all-comments" compile option to make clang parse all 
comments,
-  // otherwise, ordinary comments like "//" and "/*" won't get parsed (This is
-  // a bit of hacky).
-  std::vector ExtraArgs(argv, argv + argc);
-  ExtraArgs.insert(ExtraArgs.begin() + 1, "-extra-arg=-fparse-all-comments");
-  std::unique_ptr RawExtraArgs(
-  new const char *[ExtraArgs.size()]);
-  for (size_t i = 0; i < ExtraArgs.size(); ++i)
-RawExtraArgs[i] = ExtraArgs[i].c_str();
-  int Argc = argc + 1;
-  tooling::CommonOptionsParser OptionsParser(Argc, RawExtraArgs.get(),
- ClangMoveCategory);
+  tooling::CommonOptionsParser OptionsParser(argc, argv, ClangMoveCategory);
 
   if (OldDependOnNew && NewDependOnOld) {
 llvm::errs() << "Provide either --old_depend_on_new or "
@@ -117,6 +106,9 @@ int main(int argc, const char **argv) {
 
   tooling::RefactoringTool Tool(OptionsParser.getCompilations(),
 OptionsParser.getSourcePathList());
+  // Add "-fparse-all-comments" compile option to make clang parse all 
comments.
+  Tool.appendArgumentsAdjuster(tooling::getInsertArgumentAdjuster(
+  "-fparse-all-comments", ArgumentInsertPosition::BEGIN));
   move::MoveDefinitionSpec Spec;
   Spec.Names = {Names.begin(), Names.end()};
   Spec.OldHeader = OldHeader;


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


[PATCH] D27669: [clang-move] Use appendArgumentsAdjuster for adding extra arguments

2016-12-12 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289464: [clang-move] Use appendArgumentsAdjuster for adding 
extra arguments (authored by alexshap).

Changed prior to commit:
  https://reviews.llvm.org/D27669?vs=81052&id=81124#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27669

Files:
  clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp


Index: clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
===
--- clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
+++ clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
@@ -61,19 +61,19 @@
 NewCC("new_cc", cl::desc("The relative/absolute file path of new cc."),
   cl::cat(ClangMoveCategory));
 
-cl::opt OldDependOnNew(
-"old_depend_on_new",
-cl::desc(
-"Whether old header will depend on new header. If true, clang-move 
will "
-"add #include of new header to old header."),
-cl::init(false), cl::cat(ClangMoveCategory));
-
-cl::opt NewDependOnOld(
-"new_depend_on_old",
-cl::desc(
-"Whether new header will depend on old header. If true, clang-move 
will "
-"add #include of old header to new header."),
-cl::init(false), cl::cat(ClangMoveCategory));
+cl::opt
+OldDependOnNew("old_depend_on_new",
+   cl::desc("Whether old header will depend on new header. If "
+"true, clang-move will "
+"add #include of new header to old header."),
+   cl::init(false), cl::cat(ClangMoveCategory));
+
+cl::opt
+NewDependOnOld("new_depend_on_old",
+   cl::desc("Whether new header will depend on old header. If "
+"true, clang-move will "
+"add #include of old header to new header."),
+   cl::init(false), cl::cat(ClangMoveCategory));
 
 cl::opt
 Style("style",
@@ -95,18 +95,7 @@
 
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
-  // Add "-fparse-all-comments" compile option to make clang parse all 
comments,
-  // otherwise, ordinary comments like "//" and "/*" won't get parsed (This is
-  // a bit of hacky).
-  std::vector ExtraArgs(argv, argv + argc);
-  ExtraArgs.insert(ExtraArgs.begin() + 1, "-extra-arg=-fparse-all-comments");
-  std::unique_ptr RawExtraArgs(
-  new const char *[ExtraArgs.size()]);
-  for (size_t i = 0; i < ExtraArgs.size(); ++i)
-RawExtraArgs[i] = ExtraArgs[i].c_str();
-  int Argc = argc + 1;
-  tooling::CommonOptionsParser OptionsParser(Argc, RawExtraArgs.get(),
- ClangMoveCategory);
+  tooling::CommonOptionsParser OptionsParser(argc, argv, ClangMoveCategory);
 
   if (OldDependOnNew && NewDependOnOld) {
 llvm::errs() << "Provide either --old_depend_on_new or "
@@ -117,6 +106,9 @@
 
   tooling::RefactoringTool Tool(OptionsParser.getCompilations(),
 OptionsParser.getSourcePathList());
+  // Add "-fparse-all-comments" compile option to make clang parse all 
comments.
+  Tool.appendArgumentsAdjuster(tooling::getInsertArgumentAdjuster(
+  "-fparse-all-comments", ArgumentInsertPosition::BEGIN));
   move::MoveDefinitionSpec Spec;
   Spec.Names = {Names.begin(), Names.end()};
   Spec.OldHeader = OldHeader;


Index: clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
===
--- clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
+++ clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
@@ -61,19 +61,19 @@
 NewCC("new_cc", cl::desc("The relative/absolute file path of new cc."),
   cl::cat(ClangMoveCategory));
 
-cl::opt OldDependOnNew(
-"old_depend_on_new",
-cl::desc(
-"Whether old header will depend on new header. If true, clang-move will "
-"add #include of new header to old header."),
-cl::init(false), cl::cat(ClangMoveCategory));
-
-cl::opt NewDependOnOld(
-"new_depend_on_old",
-cl::desc(
-"Whether new header will depend on old header. If true, clang-move will "
-"add #include of old header to new header."),
-cl::init(false), cl::cat(ClangMoveCategory));
+cl::opt
+OldDependOnNew("old_depend_on_new",
+   cl::desc("Whether old header will depend on new header. If "
+"true, clang-move will "
+"add #include of new header to old header."),
+   cl::init(false), cl::cat(ClangMoveCategory));
+
+cl::opt
+NewDependOnOld("new_depend_on_old",
+   cl::desc("Whether new header will depend on old header. If "
+"true, clang-move will "
+"add #include of old header to new header."),
+   cl::init(false), cl::cat(ClangMoveCategory));
 
 cl::opt
 

[PATCH] D27424: Add the diagnose_if attribute to clang.

2016-12-12 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

Glad you like it!

> The second thing that would be amazing if this attribute was late parsed so 
> it the ability to reference this when applied to member functions

That seems like a good idea; I'll look into what that would take. (In the 
meantime, reviews would be appreciated. :) )

> If the condition could be evaluated as-if it were part of the function body 
> (during constexpr evaluation) that would be incredibly powerful. Especially 
> within the STL where everything is constexpr.

Honestly, if we could take this attribute and turn it into a full-fledged 
precondition attribute (that optionally acts as if it's a part of the function, 
optionally emits dynamic checks, ...), I'd be thrilled. If the community thinks 
that'd be a good idea, I'm happy to poke at it + incrementally build off of 
this in order to make that*. That said, I think all of that is going to require 
a fair bit more code and design thought to get right, and `diagnose_if` is 
useful enough as-is to stand on its own IMO.

IOW, we need to start somewhere, and this is a minimial-ish feature set that I 
think would be useful.

∗ - We can do this in a non-breaking way by either introducing an independent 
`precondition` attribute that heavily piggybacks off of `diagnose_if`, or we 
can add diagnostic modes + flags to `diagnose_if` (e.g. can have `warning`, 
`error`, `static-precondition`, `dynamic-precondition`, ...).


https://reviews.llvm.org/D27424



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


[clang-tools-extra] r289465 - [clang-move] Fix buildbot failures

2016-12-12 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Mon Dec 12 14:24:44 2016
New Revision: 289465

URL: http://llvm.org/viewvc/llvm-project?rev=289465&view=rev
Log:
[clang-move] Fix buildbot failures

Fix the buildbot failures introduced by D27669

Modified:
clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp

Modified: clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp?rev=289465&r1=289464&r2=289465&view=diff
==
--- clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp (original)
+++ clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp Mon Dec 12 
14:24:44 2016
@@ -10,6 +10,7 @@
 #include "ClangMove.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/Tooling.h"
@@ -108,7 +109,7 @@ int main(int argc, const char **argv) {
 OptionsParser.getSourcePathList());
   // Add "-fparse-all-comments" compile option to make clang parse all 
comments.
   Tool.appendArgumentsAdjuster(tooling::getInsertArgumentAdjuster(
-  "-fparse-all-comments", ArgumentInsertPosition::BEGIN));
+  "-fparse-all-comments", tooling::ArgumentInsertPosition::BEGIN));
   move::MoveDefinitionSpec Spec;
   Spec.Names = {Names.begin(), Names.end()};
   Spec.OldHeader = OldHeader;


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


[PATCH] D27555: [libcxx] [test] Fix MSVC warning C6001 "Using uninitialized memory".

2016-12-12 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT abandoned this revision.
STL_MSFT added a comment.

Verified compiler fix. Abandoning this patch - nothing has been committed.


https://reviews.llvm.org/D27555



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


[PATCH] D26623: [libcxx] [test] Swapping non-equal non-POCS allocators is UB.

2016-12-12 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT abandoned this revision.
STL_MSFT added a comment.

r289358 fixes everything for me, thanks! Abandoning this revision.


https://reviews.llvm.org/D26623



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


[PATCH] D22057: Prevent devirtualization of calls to un-instantiated functions.

2016-12-12 Thread Sunil Srivastava via Phabricator via cfe-commits
Sunil_Srivastava added a comment.

A friendly ping.


https://reviews.llvm.org/D22057



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


Re: [PATCH] D27597: [DebugInfo] Restore test case for long double constants.

2016-12-12 Thread David Gross via cfe-commits
I looked at what's supported by "requires", and couldn't find anything
appropriate.

The problem is that I want the test to be sensitive to the size of long
double -- either no greater than 64 bits, or greater than 64 bits.  It does
not seem practical to list all platforms (so I suspect your "xfail"
suggestion would not be suitable).  I'd like to find some way to make the
determination programmatically in the test suite.  It's certainly possible
that the answer is that there's no good way to do it.


On Mon, Dec 12, 2016 at 11:31 AM, David Blaikie  wrote:

> While it's possible to do arbitrary script things - we prefer nto to to
> ensure the tests are portable. (we have some custom implementations of
> common unix utilities for portability of those).
>
> In this case, can you xfail this on platforms that don't have the feature
> you want? rather than trying to detect it at test-execution time. (or say
> "requires" to opt the test in only on platforms you know have the thing you
> want)
>
> On Fri, Dec 9, 2016 at 4:00 AM David Gross via Phabricator via cfe-commits
>  wrote:
>
>> dgross added a comment.
>>
>> I don't know exactly what the RUN syntax supported by lit is.  What I've
>> done here looks complex, but it does work for Linux.  What about other
>> platforms?
>>
>> Is there some better way of writing a test case where the checks to be
>> done by FileCheck depend on some property of the file being analyzed (here,
>> the size of long double, as embedded in the debug metadata)?  I don't see
>> any support for conditions in FileCheck.
>>
>> Maybe I'm going about this completely the wrong way?
>>
>>
>> https://reviews.llvm.org/D27597
>>
>>
>>
>> ___
>> 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] D27546: [ASTReader] Sort RawComments before merging

2016-12-12 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Ping!


https://reviews.llvm.org/D27546



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


[PATCH] D27680: [CodeGen] Move lifetime.start of a variable when goto jumps back past its declaration

2016-12-12 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: lib/CodeGen/CodeGenFunction.h:619
+bool hasLabel(const LabelDecl *LD) const {
+  return std::find(Labels.begin(), Labels.end(), LD) != Labels.end();
+}

This can be written as `llvm::is_contained(Labels, LD);`


https://reviews.llvm.org/D27680



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


[PATCH] D27383: Add a new clang-format style option ObjCBlockResetsIndent.

2016-12-12 Thread Sean Lu via Phabricator via cfe-commits
yixiang added a comment.

Ping.

For the additional requirements of adding a style options:

- be used in a project of significant size (have dozens of contributors)
  - Yes, it's been used by almost all the iOS projects inside Google, including 
Google Maps.
- have a publicly accessible style guide
  - https://google.github.io/styleguide/objcguide.xml
- have a person willing to contribute and maintain patches
  - I'm willing to do the maintenance, I'm confident that I can find backup 
contributors too.


https://reviews.llvm.org/D27383



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


[PATCH] D21698: [OpenCL] Allow disabling types and declarations associated with extensions

2016-12-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 81142.
yaxunl marked 9 inline comments as done.
yaxunl added a comment.

Revised by Anastasia's comments.


https://reviews.llvm.org/D21698

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenCLImageTypes.def
  include/clang/Basic/OpenCLOptions.h
  include/clang/Basic/TargetInfo.h
  include/clang/Sema/Overload.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTReader.h
  lib/Basic/Targets.cpp
  lib/Frontend/InitPreprocessor.cpp
  lib/Headers/opencl-c.h
  lib/Parse/ParsePragma.cpp
  lib/Parse/Parser.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/CodeGenOpenCL/extension-begin.cl
  test/Parser/opencl-atomics-cl20.cl
  test/Parser/opencl-pragma.cl
  test/SemaOpenCL/extension-begin.cl
  test/SemaOpenCL/extensions.cl

Index: test/SemaOpenCL/extensions.cl
===
--- test/SemaOpenCL/extensions.cl
+++ test/SemaOpenCL/extensions.cl
@@ -21,8 +21,6 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64 -cl-ext=+cl_khr_fp16 -cl-ext=-cl_khr_fp64 -DNOFP64
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64,-cl_khr_fp64,+cl_khr_fp16 -DNOFP64
 
-
-
 void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
Index: test/SemaOpenCL/extension-begin.cl
===
--- /dev/null
+++ test/SemaOpenCL/extension-begin.cl
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
+
+#pragma OPENCL EXTENSION all : begin // expected-warning {{expected 'disable' - ignoring}}
+#pragma OPENCL EXTENSION all : end // expected-warning {{expected 'disable' - ignoring}}
+
+#pragma OPENCL EXTENSION my_ext : begin 
+
+struct A {
+  int a;
+};
+
+typedef struct A TypedefOfA;
+typedef const TypedefOfA* PointerOfA;
+
+void f(void);
+
+__attribute__((overloadable)) void g(long x);
+
+#pragma OPENCL EXTENSION my_ext : end
+#pragma OPENCL EXTENSION my_ext : end // expected-warning {{OpenCL extension end directive mismatches begin directive - ignoring}}
+
+__attribute__((overloadable)) void g(void);
+
+#pragma OPENCL EXTENSION my_ext : enable
+void test_f1(void) {
+  struct A test_A1;
+  f();
+  g(0);
+}
+
+#pragma OPENCL EXTENSION my_ext : disable 
+void test_f2(void) {
+  struct A test_A2; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}}
+  const struct A test_A_local; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}}
+  TypedefOfA test_typedef_A; // expected-error {{use of type 'TypedefOfA' (aka 'struct A') requires my_ext extension to be enabled}}
+  PointerOfA test_A_pointer; // expected-error {{use of type 'PointerOfA' (aka 'const struct A *') requires my_ext extension to be enabled}}
+  f(); // expected-error {{use of declaration requires my_ext extension to be enabled}}
+  g(0); // expected-error {{no matching function for call to 'g'}}
+// expected-note@-22 {{candidate disabled due to OpenCL extension}}
+// expected-note@-18 {{candidate function not viable: requires 0 arguments, but 1 was provided}}
+}
Index: test/Parser/opencl-pragma.cl
===
--- test/Parser/opencl-pragma.cl
+++ test/Parser/opencl-pragma.cl
@@ -5,9 +5,9 @@
 #pragma OPENCL EXTENSION cl_no_such_extension : disable /* expected-warning {{unknown OpenCL extension 'cl_no_such_extension' - ignoring}} */
 
 #pragma OPENCL EXTENSION all : disable
-#pragma OPENCL EXTENSION all : enable /* expected-warning {{unknown OpenCL extension 'all' - ignoring}} */
+#pragma OPENCL EXTENSION all : enable /* expected-warning {{expected 'disable' - ignoring}} */
 
-#pragma OPENCL EXTENSION cl_khr_fp64 : on /* expected-warning {{expected 'enable' or 'disable' - ignoring}} */
+#pragma OPENCL EXTENSION cl_khr_fp64 : on /* expected-warning {{expected 'enable', 'disable', 'begin' or 'end' - ignoring}} */
 
 #pragma OPENCL FP_CONTRACT ON
 #pragma OPENCL FP_CONTRACT OFF
Index: test/Parser/opencl-atomics-cl20.cl
===
--- test/Parser/opencl-atomics-cl20.cl
+++ test/Parser/opencl-atomics-cl20.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20
+// RUN: %clang_cc1 %s

Re: [PATCH] D27597: [DebugInfo] Restore test case for long double constants.

2016-12-12 Thread David Blaikie via cfe-commits
On Mon, Dec 12, 2016 at 1:11 PM David Gross  wrote:

> I looked at what's supported by "requires", and couldn't find anything
> appropriate.
>
> The problem is that I want the test to be sensitive to the size of long
> double -- either no greater than 64 bits, or greater than 64 bits.  It does
> not seem practical to list all platforms (so I suspect your "xfail"
> suggestion would not be suitable).  I'd like to find some way to make the
> determination programmatically in the test suite.  It's certainly possible
> that the answer is that there's no good way to do it.
>

I doubt there's a good way to do that.

I'd probably just write it for one target (I assume this is the case on
x86? A pretty good/stable/ubiquitous target - and we have a lot of DWARF
test coverage that's x86-only) and move on.


>
>
> On Mon, Dec 12, 2016 at 11:31 AM, David Blaikie 
> wrote:
>
> While it's possible to do arbitrary script things - we prefer nto to to
> ensure the tests are portable. (we have some custom implementations of
> common unix utilities for portability of those).
>
> In this case, can you xfail this on platforms that don't have the feature
> you want? rather than trying to detect it at test-execution time. (or say
> "requires" to opt the test in only on platforms you know have the thing you
> want)
>
> On Fri, Dec 9, 2016 at 4:00 AM David Gross via Phabricator via cfe-commits
>  wrote:
>
> dgross added a comment.
>
> I don't know exactly what the RUN syntax supported by lit is.  What I've
> done here looks complex, but it does work for Linux.  What about other
> platforms?
>
> Is there some better way of writing a test case where the checks to be
> done by FileCheck depend on some property of the file being analyzed (here,
> the size of long double, as embedded in the debug metadata)?  I don't see
> any support for conditions in FileCheck.
>
> Maybe I'm going about this completely the wrong way?
>
>
> https://reviews.llvm.org/D27597
>
>
>
> ___
> 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] D27068: Improve string::find

2016-12-12 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added a comment.

Ping


https://reviews.llvm.org/D27068



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


r289478 - [Modules] Make header inclusion order from umbrella dirs deterministic

2016-12-12 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Dec 12 16:41:20 2016
New Revision: 289478

URL: http://llvm.org/viewvc/llvm-project?rev=289478&view=rev
Log:
[Modules] Make header inclusion order from umbrella dirs deterministic

Sort the headers by name before adding the includes in
collectModuleHeaderIncludes. This makes the include order for building
umbrellas deterministic across different filesystems and also guarantees
that the ASTWriter always dump top headers in the same order.

There's currently no good way to test for this behavior.

rdar://problem/28116411

Modified:
cfe/trunk/lib/Frontend/FrontendActions.cpp

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=289478&r1=289477&r2=289478&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Mon Dec 12 16:41:20 2016
@@ -233,6 +233,7 @@ collectModuleHeaderIncludes(const LangOp
 llvm::sys::path::native(UmbrellaDir.Entry->getName(), DirNative);
 
 vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
+SmallVector, 8> Headers;
 for (vfs::recursive_directory_iterator Dir(FS, DirNative, EC), End;
  Dir != End && !EC; Dir.increment(EC)) {
   // Check whether this entry has an extension typically associated with 
@@ -263,13 +264,20 @@ collectModuleHeaderIncludes(const LangOp
++It)
 llvm::sys::path::append(RelativeHeader, *It);
 
-  // Include this header as part of the umbrella directory.
-  Module->addTopHeader(Header);
-  addHeaderInclude(RelativeHeader, Includes, LangOpts, Module->IsExternC);
+  Headers.push_back(std::make_pair(RelativeHeader.str(), Header));
 }
 
 if (EC)
   return EC;
+
+// Sort header paths and make the header inclusion order deterministic
+// across different OSs and filesystems.
+llvm::array_pod_sort(Headers.begin(), Headers.end());
+for (auto &H : Headers) {
+  // Include this header as part of the umbrella directory.
+  Module->addTopHeader(H.second);
+  addHeaderInclude(H.first, Includes, LangOpts, Module->IsExternC);
+}
   }
 
   // Recurse into submodules.


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


[PATCH] D27689: Module: hash the pcm content and use it as SIGNATURE for implicit modules.

2016-12-12 Thread Manman Ren via Phabricator via cfe-commits
manmanren created this revision.
manmanren added reviewers: rsmith, benlangmuir, aprantl.
manmanren added subscribers: bruno, cfe-commits, dexonsmith.

We change ASTFileSignature from a random 32-bit number to the actual SHA hash 
of the pcm content.

1> Definition of ASTFileSignature is moved to Basic/Module.h so Module and 
ASTSourceDescriptor can use it. Before this patch both are using uint64_t as 
the type of the signature.
2> Add DIAGNOSTIC_OPTIONS_BLOCK and make sure it is the last block of the pcm 
file. This block contains DIAGNOSTIC_OPTIONS and SIGNATURE.
We are using this patch to solve a PCH+Modules issue: PCH are handled by the 
build system and modules are handled by the compiler, when the compiler 
overwrites a pcm file with the same content except the diagnostic differences, 
we can still treat the PCH as valid and continue using it. This requires us not 
hashing the diagnostic differences. Moving the diagnostic differences to the 
end of the pcm makes the task easy:

  In a few records, we save bit positions in the pcm file, if the size of the 
diagnostic options is different, the bit positions can be off.
  We only need to hash the content till the start of the 
DIAGNOSTIC_OPTIONS_BLOCK.

3> When we hash the pcm content, there is no point in saving the file size and 
modification time for the imported module file. The patch will use 0 for both. 
And the validation will not check the size differences or the modification time 
differences.
4> In GlobalModuleIndexBuilder, when the signature is non-zero, we check the 
signature instead of file size/modification time for imported modules.
5> Debug info has a 64-bit slot for dwo id, this patch uses the lower 64 bits 
of the SHA hash.

I want to gather some feedback on the general direction of this. Given that 
this is a big patch, I am open to separate it into smaller patches.

Cheers,
Manman


https://reviews.llvm.org/D27689

Files:
  include/clang/AST/ExternalASTSource.h
  include/clang/Basic/Module.h
  include/clang/Frontend/PCHContainerOperations.h
  include/clang/Serialization/ASTBitCodes.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ASTWriter.h
  include/clang/Serialization/Module.h
  lib/Basic/Module.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/GeneratePCH.cpp
  lib/Serialization/GlobalModuleIndex.cpp
  lib/Serialization/Module.cpp
  lib/Serialization/ModuleManager.cpp
  test/Modules/diagnostic-options-out-of-date.m
  test/Modules/explicit-build.cpp
  test/Modules/module_file_info.m
  test/Modules/rebuild.m

Index: test/Modules/rebuild.m
===
--- test/Modules/rebuild.m
+++ test/Modules/rebuild.m
@@ -19,11 +19,10 @@
 // RUN: diff %t/Module.size %t/Module.size.saved
 // RUN: cp %t/Module.pcm %t/Module.pcm.saved.2
 
-// But the signature at least is expected to change, so we rebuild DependsOnModule.
-// NOTE: if we change how the signature is created, this test may need updating.
+// The signature is the hash of the PCM content, we will not rebuild rebuild DependsOnModule.
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s
 // RUN: diff %t/Module.pcm %t/Module.pcm.saved.2
-// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
+// RUN: diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
 
 // Rebuild Module, reset its timestamp, and verify its size hasn't changed
 // RUN: rm %t/Module.pcm
@@ -34,10 +33,9 @@
 // RUN: cp %t/Module.pcm %t/Module.pcm.saved.2
 
 // Verify again with Module pre-imported.
-// NOTE: if we change how the signature is created, this test may need updating.
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s
 // RUN: diff %t/Module.pcm %t/Module.pcm.saved.2
-// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
+// RUN: diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
 
 #ifdef PREIMPORT
 @import Module;
Index: test/Modules/module_file_info.m
===
--- test/Modules/module_file_info.m
+++ test/Modules/module_file_info.m
@@ -29,11 +29,6 @@
 // CHECK: CPU:
 // CHECK: ABI:
 
-// CHECK: Diagnostic options:
-// CHECK:   IgnoreWarnings: Yes
-// CHECK:   Diagnostic flags:
-// CHECK: -Wunused
-
 // CHECK: Header search options:
 // CHECK:   System root [-isysroot=]: '/'
 // CHECK:   Use builtin include directories [-nobuiltininc]: Yes
@@ -47,3 +42,8 @@
 // CHECK:   Predefined macros:
 // CHECK: -DBLARG
 // CHECK: -DWIBBLE=WOBBLE
+
+// CHECK: Diagnostic options:
+// CHECK:   IgnoreWarnings: Yes
+// CHECK:   Diagnostic flags:
+// CHECK: -Wunused
Index: test/Modules/explicit-build.cpp
===

[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-12 Thread Firat Kasmis via Phabricator via cfe-commits
firolino marked an inline comment as done.
firolino added inline comments.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:87
+  Diag << FixItHint::CreateReplacement(CommaRange, ";")
+   << FixItHint::CreateReplacement(AfterCommaToVarNameRange,
+   "\n" + CurrentIndent +

malcolm.parsons wrote:
> Is an insert simpler?
> ```
> FixItHint::CreateInsertion(CommaLocation.getLocWithOffset(1),
>"\n" + CurrentIndent + UserWrittenType + " ");
> ```
Won't work, if there are whitespaces between comma and variable name. I need to 
get those first and ltrim() them.

The insert would give for:
```
int a,b;

int aa, bb;

int xk = 1,
yk = 2;
```

->

```
int a;
int b;

int aa;
int  bb;

int xk = 1;
int 
yk = 2;
```


https://reviews.llvm.org/D27621



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


  1   2   >