[PATCH] D33029: [clang-format] add option for dangling parenthesis

2017-05-09 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Please read and address: 
https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options


https://reviews.llvm.org/D33029



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


[PATCH] D33029: [clang-format] add option for dangling parenthesis

2017-05-09 Thread Ryan Stringham via Phabricator via cfe-commits
stringham created this revision.
stringham added a project: clang-tools-extra.
Herald added a subscriber: klimek.

This adds an option to clang-format to support dangling parenthesis.

If you have a parameter list like

Foo(

  param1,
  param2,
  param3,

);

clang-format currently only supports putting the closing paren on the same line 
as param3:

Foo(

  param1,
  param2,
  param3, );

This makes it difficult to see the change from the function signature to the 
function body, for example:

class Foo extends Bar {

  constructor(
  param1,
  param2,
  param3, ) {
  super(param1, 'x');
  this.param2 = param2;
  }

}

would now be formatted like:

class Foo extends Bar {

  constructor(
  param1,
  param2,
  param3, 
  ) {
  super(param1, 'x');
  this.param2 = param2;
  }

}

and it is much easier to see the difference between the parameter list and the 
function body.


https://reviews.llvm.org/D33029

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -8757,6 +8757,7 @@
   CHECK_PARSE_BOOL(BreakStringLiterals);
   CHECK_PARSE_BOOL(BreakBeforeInheritanceComma)
   CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine);
+  CHECK_PARSE_BOOL(DanglingParenthesis);
   CHECK_PARSE_BOOL(DerivePointerAlignment);
   CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding");
   CHECK_PARSE_BOOL(DisableFormat);
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2652,7 +2652,10 @@
   if (Right.is(TT_ImplicitStringLiteral))
 return false;
 
-  if (Right.is(tok::r_paren) || Right.is(TT_TemplateCloser))
+  if (Right.is(tok::r_paren)) {
+return Style.DanglingParenthesis;
+  }
+  if (Right.is(TT_TemplateCloser))
 return false;
   if (Right.is(tok::r_square) && Right.MatchingParen &&
   Right.MatchingParen->is(TT_LambdaLSquare))
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -315,6 +315,7 @@
Style.BreakBeforeInheritanceComma);
 IO.mapOptional("ConstructorInitializerAllOnOneLineOrOnePerLine",
Style.ConstructorInitializerAllOnOneLineOrOnePerLine);
+IO.mapOptional("DanglingParenthesis", Style.DanglingParenthesis);
 IO.mapOptional("ConstructorInitializerIndentWidth",
Style.ConstructorInitializerIndentWidth);
 IO.mapOptional("ContinuationIndentWidth", Style.ContinuationIndentWidth);
@@ -541,6 +542,7 @@
   LLVMStyle.ColumnLimit = 80;
   LLVMStyle.CommentPragmas = "^ IWYU pragma:";
   LLVMStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = false;
+  LLVMStyle.DanglingParenthesis = false;
   LLVMStyle.ConstructorInitializerIndentWidth = 4;
   LLVMStyle.ContinuationIndentWidth = 4;
   LLVMStyle.Cpp11BracedListStyle = true;
@@ -606,6 +608,7 @@
   GoogleStyle.AlwaysBreakBeforeMultilineStrings = true;
   GoogleStyle.AlwaysBreakTemplateDeclarations = true;
   GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
+  GoogleStyle.DanglingParenthesis = false;
   GoogleStyle.DerivePointerAlignment = true;
   GoogleStyle.IncludeCategories = {{"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", 3}};
   GoogleStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -143,6 +143,12 @@
   State.Stack.back().NoLineBreakInOperand)
 return false;
 
+  if (Style.DanglingParenthesis && Current.is(tok::r_paren) &&
+  Current.MatchingParen &&
+  Current.MatchingParen->LastNewlineOffset ==
+  Current.MatchingParen->Next->LastNewlineOffset)
+return false;
+
   return !State.Stack.back().NoLineBreak;
 }
 
@@ -156,6 +162,11 @@
 return true;
   if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection)
 return true;
+  if (Style.DanglingParenthesis && Current.is(tok::r_paren) &&
+  Current.MatchingParen &&
+  Current.MatchingParen->LastNewlineOffset <
+  Current.MatchingParen->Next->LastNewlineOffset)
+return true;
   if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) ||
(Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) &&
 Style.isCpp() &&
@@ -674,6 +685,9 @@
   return State.Stack[State.Stack.size() - 2].LastSpace;
 return State.FirstIndent;
   }
+  if (Style.DanglingParenthesis && Current.is(tok::r_paren) && State.Stack.size() > 1) {
+

[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend

2017-05-09 Thread wangrunan via Phabricator via cfe-commits
iris added a comment.

How can I make z3constraintmanager.cpp work in the command line?Or how to make 
z3 work?


Repository:
  rL LLVM

https://reviews.llvm.org/D28952



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


Re: [PATCH] D24933: Enable configuration files in clang

2017-05-09 Thread Serge Pavlov via cfe-commits
2017-05-10 3:46 GMT+07:00 Richard Smith :

> On 1 March 2017 at 02:50, Serge Pavlov via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>>
>> Format of configuration file is similar to file used in the construct
>> `@file`, it is a set of options. Configuration file have advantage over
>> this construct:
>>
>> - it is searched for in well-known places rather than in current
>> directory,
>>
>
> This (and suppressing unused-argument warnings) might well be sufficient
> to justify a different command-line syntax rather than @file...
>

Construct `@file` in this implementation is used only to read parts of
config file inside containing file. Driver knows that it processes config
file and can adjust treatment of `@file`. On the other hand, driver might
parse config files in a more complicated way, for instance, it could treat
line `# include(file_name)` as a command to include another file.


>
>> - it may contain comments, long options may be split between lines using
>> trailing backslashes,
>> - other files may be included by `@file` and they will be resolved
>> relative to the including file,
>>
>
> ... but I think we should just add these extensions to our @file handling,
> and then use the exact same syntax and code to handle config files and
> @file files. That is, the difference between @ and --config would be that
> the latter looks in a different directory and suppresses "unused argument"
> warnings, but they would otherwise be identical.
>

Changing treatment of `@file` can cause compatibility issues, in
particular, both libiberty and cl resolves file name relative to current
directory. So driver must deduce that `@file` is used to load config file
rather than merely to organize arguments. Another difference is that
`@file` inserts its content in the place where it occurs, while `--config`
always puts arguments before user specified options. The following
invocations:

clang --config a.cfg -opt1 -opt2 file1.cpp
clang -opt1 -opt2 file1.cpp --config a.cfg

are equivalent, but variants with `@file` can have different effect.


> - the file may be encoded in executable name,
>> - unused options from configuration file do not produce warnings.
>>
>>
>> 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] D33013: Driver must return non-zero code on errors in command line

2017-05-09 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 98395.
sepavloff added a comment.

Addressed reviewer's notes.


https://reviews.llvm.org/D33013

Files:
  lib/Driver/Driver.cpp
  test/Driver/aarch64-cpus.c
  test/Driver/amdgpu-features.c
  test/Driver/arm-darwin-builtin.c
  test/Driver/arm-default-build-attributes.s
  test/Driver/cl-outputs.c
  test/Driver/clang_f_opts.c
  test/Driver/debug-options.c
  test/Driver/gfortran.f90
  test/Driver/split-debug.h
  test/Driver/unknown-arg.c
  test/Index/index-attrs.c
  test/Index/index-attrs.cpp
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -454,40 +454,41 @@
   SetBackdoorDriverOutputsFromEnvVars(TheDriver);
 
   std::unique_ptr C(TheDriver.BuildCompilation(argv));
-  int Res = 0;
-  SmallVector, 4> FailingCommands;
-  if (C.get())
+  int Res = 1;
+  if (C.get()) {
+SmallVector, 4> FailingCommands;
 Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
 
-  // Force a crash to test the diagnostics.
-  if (TheDriver.GenReproducer) {
-Diags.Report(diag::err_drv_force_crash)
+// Force a crash to test the diagnostics.
+if (TheDriver.GenReproducer) {
+  Diags.Report(diag::err_drv_force_crash)
 << !::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH");
 
-// Pretend that every command failed.
-FailingCommands.clear();
-for (const auto  : C->getJobs())
-  if (const Command *C = dyn_cast())
-FailingCommands.push_back(std::make_pair(-1, C));
-  }
+  // Pretend that every command failed.
+  FailingCommands.clear();
+  for (const auto  : C->getJobs())
+if (const Command *C = dyn_cast())
+  FailingCommands.push_back(std::make_pair(-1, C));
+}
 
-  for (const auto  : FailingCommands) {
-int CommandRes = P.first;
-const Command *FailingCommand = P.second;
-if (!Res)
-  Res = CommandRes;
-
-// If result status is < 0, then the driver command signalled an error.
-// If result status is 70, then the driver command reported a fatal error.
-// On Windows, abort will return an exit code of 3.  In these cases,
-// generate additional diagnostic information if possible.
-bool DiagnoseCrash = CommandRes < 0 || CommandRes == 70;
+for (const auto  : FailingCommands) {
+  int CommandRes = P.first;
+  const Command *FailingCommand = P.second;
+  if (!Res)
+Res = CommandRes;
+
+  // If result status is < 0, then the driver command signalled an error.
+  // If result status is 70, then the driver command reported a fatal error.
+  // On Windows, abort will return an exit code of 3.  In these cases,
+  // generate additional diagnostic information if possible.
+  bool DiagnoseCrash = CommandRes < 0 || CommandRes == 70;
 #ifdef LLVM_ON_WIN32
-DiagnoseCrash |= CommandRes == 3;
+  DiagnoseCrash |= CommandRes == 3;
 #endif
-if (DiagnoseCrash) {
-  TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);
-  break;
+  if (DiagnoseCrash) {
+TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);
+break;
+  }
 }
   }
 
Index: test/Index/index-attrs.cpp
===
--- test/Index/index-attrs.cpp
+++ test/Index/index-attrs.cpp
@@ -1,4 +1,4 @@
-// RUN: c-index-test -index-file -check-prefix CHECK %s -target armv7-windows-gnu -fdeclspec
+// RUN: c-index-test -index-file %s -target armv7-windows-gnu -fdeclspec | FileCheck %s
 
 struct __declspec(dllexport) export_s {
   void m();
@@ -19,32 +19,32 @@
 class __attribute__((dllexport)) export_gnu_s {
   void m();
 };
-// CHECK: [indexDeclaration]: kind: struct | name: export_gnu_s | {{.*}} | lang: C++
+// CHECK: [indexDeclaration]: kind: c++-class | name: export_gnu_s | {{.*}} | lang: C++
 // CHECK: : attribute(dllexport)
 // CHECK: [indexDeclaration]: kind: c++-instance-method | name: m | {{.*}} | lang: C++
 // CHECK: : attribute(dllexport)
 
 class __attribute__((dllimport)) import_gnu_s {
   void m();
 };
-// CHECK: [indexDeclaration]: kind: struct | name: import_gnu_s | {{.*}} | lang: C++
+// CHECK: [indexDeclaration]: kind: c++-class | name: import_gnu_s | {{.*}} | lang: C++
 // CHECK: : attribute(dllimport)
 // CHECK: [indexDeclaration]: kind: c++-instance-method | name: m | {{.*}} | lang: C++
 // CHECK: : attribute(dllimport)
 
 extern "C" void __declspec(dllexport) export_function(void) {}
-// CHECK: [indexDeclaraton]: kind: function | name: export_function | {{.*}} | lang: C
+// CHECK: [indexDeclaration]: kind: function | name: export_function | {{.*}} | lang: C
 // CHECK: : attribute(dllexport)
 extern "C" void __attribute__((dllexport)) export_gnu_function(void) {}
-// CHECK: [indexDeclaraton]: kind: function | name: export_gnu_function | {{.*}} | lang: C
+// CHECK: [indexDeclaration]: 

[PATCH] D30909: [Analyzer] Finish taint propagation to derived symbols of tainted regions

2017-05-09 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich updated this revision to Diff 98390.
vlad.tsyrklevich marked 3 inline comments as done.
vlad.tsyrklevich added a comment.
Herald added a subscriber: xazax.hun.

- Update the logic to move the LCV symbol logic into 
ProgramState::addTaint(SVal) out of the GenericTaintChecker. This allows us to 
no longer have to synthesize a new SymbolDerived from a LazyCompoundVal. This 
also required adding a new addPartialTaint() function.
- Update TaintedSymRegions name to TaintedSubRegions per @NoQ's comment.
- I realized that the new partial taint logic did not respect the idea of 
TaintTagTypes, so I updated TaintSubRegion to include a TaintTagType and added 
appropriate logic to add/check them.


https://reviews.llvm.org/D30909

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/taint-generic.c

Index: test/Analysis/taint-generic.c
===
--- test/Analysis/taint-generic.c
+++ test/Analysis/taint-generic.c
@@ -192,20 +192,41 @@
 
 void testStructArray() {
   struct {
-char buf[16];
-struct {
-  int length;
-} st[1];
-  } tainted;
+int length;
+  } tainted[4];
 
-  char buffer[16];
+  char dstbuf[16], srcbuf[16];
   int sock;
 
   sock = socket(AF_INET, SOCK_STREAM, 0);
-  read(sock, [0], sizeof(tainted.buf));
-  read(sock, [0], sizeof(tainted.st));
-  // FIXME: tainted.st[0].length should be marked tainted
-  __builtin_memcpy(buffer, tainted.buf, tainted.st[0].length); // no-warning
+  __builtin_memset(srcbuf, 0, sizeof(srcbuf));
+
+  read(sock, [0], sizeof(tainted));
+  __builtin_memcpy(dstbuf, srcbuf, tainted[0].length); // expected-warning {{Untrusted data is used to specify the buffer size}}
+
+  __builtin_memset(, 0, sizeof(tainted));
+  read(sock, , sizeof(tainted));
+  __builtin_memcpy(dstbuf, srcbuf, tainted[0].length); // expected-warning {{Untrusted data is used to specify the buffer size}}
+
+  __builtin_memset(, 0, sizeof(tainted));
+  // If we taint element 1, we should not raise an alert on taint for element 0 or element 2
+  read(sock, [1], sizeof(tainted));
+  __builtin_memcpy(dstbuf, srcbuf, tainted[0].length); // no-warning
+  __builtin_memcpy(dstbuf, srcbuf, tainted[2].length); // no-warning
+}
+
+void testUnion() {
+  union {
+int x;
+char y[4];
+  } tainted;
+
+  char buffer[4];
+
+  int sock = socket(AF_INET, SOCK_STREAM, 0);
+  read(sock, , sizeof(tainted.y));
+  // FIXME: overlapping regions aren't detected by isTainted yet
+  __builtin_memcpy(buffer, tainted.y, tainted.x);
 }
 
 int testDivByZero() {
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -496,7 +496,10 @@
 
   Optional getDefaultBinding(Store S, const MemRegion *R) override {
 RegionBindingsRef B = getRegionBindings(S);
-return B.getDefaultBinding(R);
+// Default bindings are always applied over a base region so look up the
+// base region's default binding, otherwise the lookup will fail when R
+// is at an offset from R->getBaseRegion().
+return B.getDefaultBinding(R->getBaseRegion());
   }
 
   SVal getBinding(RegionBindingsConstRef B, Loc L, QualType T = QualType());
Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -644,15 +644,36 @@
   if (const Expr *E = dyn_cast_or_null(S))
 S = E->IgnoreParens();
 
-  SymbolRef Sym = getSVal(S, LCtx).getAsSymbol();
+  return addTaint(getSVal(S, LCtx), Kind);
+}
+
+ProgramStateRef ProgramState::addTaint(SVal V,
+   TaintTagType Kind) const {
+  SymbolRef Sym = V.getAsSymbol();
   if (Sym)
 return addTaint(Sym, Kind);
 
-  const MemRegion *R = getSVal(S, LCtx).getAsRegion();
-  addTaint(R, Kind);
+  // If the SVal is a LazyCompoundVal it might only cover sub-region of a given
+  // symbol. For example, the LCV might represent a field in an uninitialized
+  // struct. In this case, the LCV encapsulates a conjured symbol and reference
+  // to the sub-region representing the struct field.
+  if (auto LCV = V.getAs()) {
+Optional binding = getStateManager().StoreMgr->getDefaultBinding(*LCV);
+if (binding) {
+  SymbolRef Sym = binding->getAsSymbol();
+  if (Sym) {
+// If the LCV covers an entire base region, taint the symbol
+if (LCV->getRegion() == LCV->getRegion()->getBaseRegion())
+  return addTaint(Sym, Kind);
+
+// Otherwise, only taint the sub-region covered by the LCV
+return addPartialTaint(Sym, 

[libcxx] r302619 - Rename Appveyor install helper script.

2017-05-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  9 21:43:02 2017
New Revision: 302619

URL: http://llvm.org/viewvc/llvm-project?rev=302619=rev
Log:
Rename Appveyor install helper script.

I'm really lazy and the old name for the helper script
killed 2 letter tab completion for the include directory.
This patch renames it to avoid that problem and enable
lazyness.

Added:
libcxx/trunk/appveyor-reqs-install.cmd
  - copied, changed from r302617, libcxx/trunk/install-appveyor-reqs.cmd
Removed:
libcxx/trunk/install-appveyor-reqs.cmd
Modified:
libcxx/trunk/appveyor.yml

Copied: libcxx/trunk/appveyor-reqs-install.cmd (from r302617, 
libcxx/trunk/install-appveyor-reqs.cmd)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/appveyor-reqs-install.cmd?p2=libcxx/trunk/appveyor-reqs-install.cmd=libcxx/trunk/install-appveyor-reqs.cmd=302617=302619=302619=diff
==
(empty)

Modified: libcxx/trunk/appveyor.yml
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/appveyor.yml?rev=302619=302618=302619=diff
==
--- libcxx/trunk/appveyor.yml (original)
+++ libcxx/trunk/appveyor.yml Tue May  9 21:43:02 2017
@@ -36,7 +36,7 @@ install:
   
   # All external dependencies are installed in C:\projects\deps
   
-  - call "%APPVEYOR_BUILD_FOLDER%\\install-appveyor-reqs.cmd"
+  - call "%APPVEYOR_BUILD_FOLDER%\\appveyor-reqs-install.cmd"
 
 before_build:
   - if DEFINED MSVC_SETUP_PATH call "%MSVC_SETUP_PATH%" %MSVC_SETUP_ARG%

Removed: libcxx/trunk/install-appveyor-reqs.cmd
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/install-appveyor-reqs.cmd?rev=302618=auto
==
--- libcxx/trunk/install-appveyor-reqs.cmd (original)
+++ libcxx/trunk/install-appveyor-reqs.cmd (removed)
@@ -1,53 +0,0 @@
-@echo on
-
-if NOT EXIST C:\projects\deps (
-  mkdir C:\projects\deps
-)
-cd C:\projects\deps
-
-::###
-:: Setup Compiler
-::###
-if NOT EXIST llvm-installer.exe (
-  appveyor DownloadFile 
http://llvm.org/pre-releases/win-snapshots/LLVM-5.0.0-r301646-win32.exe 
-FileName llvm-installer.exe
-)
-if "%CLANG_VERSION%"=="ToT" (
-START /WAIT llvm-installer.exe /S /D=C:\"Program Files\LLVM"
-)
-if DEFINED CLANG_VERSION  @set PATH="C:\Program Files\LLVM\bin";%PATH%
-if DEFINED CLANG_VERSION  clang-cl -v
-
-if DEFINED MINGW_PATH rename "C:\Program Files\Git\usr\bin\sh.exe" 
"sh-ignored.exe"
-if DEFINED MINGW_PATH @set "PATH=%PATH:C:\Program Files (x86)\Git\bin=%"
-if DEFINED MINGW_PATH @set "PATH=%PATH%;%MINGW_PATH%"
-if DEFINED MINGW_PATH g++ -v
-
-::###
-:: Install a recent CMake
-::###
-if NOT EXIST cmake (
-  appveyor DownloadFile https://cmake.org/files/v3.7/cmake-3.7.2-win64-x64.zip 
-FileName cmake.zip
-  7z x cmake.zip -oC:\projects\deps > nul
-  move C:\projects\deps\cmake-* C:\projects\deps\cmake
-  rm cmake.zip
-)
-@set PATH=C:\projects\deps\cmake\bin;%PATH%
-cmake --version
-
-::###
-:: Install Ninja
-::###
-if NOT EXIST ninja (
-  appveyor DownloadFile 
https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip 
-FileName ninja.zip
-  7z x ninja.zip -oC:\projects\deps\ninja > nul
-  rm ninja.zip
-)
-@set PATH=C:\projects\deps\ninja;%PATH%
-ninja --version
-
-::###
-:: Setup the cached copy of LLVM
-::###
-git clone --depth=1 http://llvm.org/git/llvm.git
-
-@echo off


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


[libcxx] r302617 - Support using MinGW POSIX threads on Windows

2017-05-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  9 21:36:48 2017
New Revision: 302617

URL: http://llvm.org/viewvc/llvm-project?rev=302617=rev
Log:
Support using MinGW POSIX threads on Windows

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=302617=302616=302617=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Tue May  9 21:36:48 2017
@@ -987,7 +987,8 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 defined(__linux__) || \
 defined(__APPLE__) || \
 defined(__CloudABI__) || \
-defined(__sun__)
+defined(__sun__) || \
+defined(__WINPTHREADS_VERSION)
 #   define _LIBCPP_HAS_THREAD_API_PTHREAD
 # elif defined(_LIBCPP_WIN32API)
 #  define _LIBCPP_HAS_THREAD_API_WIN32


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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

2017-05-09 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:388
+
+  // add paths specified in LIBRARY_PATH environment variable as -L options.
+  addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");

Comment sentences should start with a capital letter (here and below).



Comment at: lib/Driver/ToolChains/Cuda.cpp:407
+  // the target details to the driver and maybe we do not want to do
+  // that
+  for (const auto  : Inputs) {

Add period at the end of the sentence.



Comment at: lib/Driver/ToolChains/Cuda.cpp:409
+  for (const auto  : Inputs) {
+
+if (II.getType() == types::TY_LLVM_IR ||

Remove this blank line.



Comment at: lib/Driver/ToolChains/Cuda.cpp:420
+// Currently, we only pass the input files to the linker, we do not pass
+// any libraries that may be valid only for the host.
+if (!II.isFilename())

Can you please explain how this works for libraries specified by file name 
(e.g. /path/to/foo.so or /path/to/foo.a) or why these should be treated 
differently? Maybe I'm misunderstanding what this check does.


Repository:
  rL LLVM

https://reviews.llvm.org/D29654



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


[libcxx] r302616 - attempt to fix appveyor syntax error

2017-05-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  9 21:34:56 2017
New Revision: 302616

URL: http://llvm.org/viewvc/llvm-project?rev=302616=rev
Log:
attempt to fix appveyor syntax error

Modified:
libcxx/trunk/appveyor.yml

Modified: libcxx/trunk/appveyor.yml
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/appveyor.yml?rev=302616=302615=302616=diff
==
--- libcxx/trunk/appveyor.yml (original)
+++ libcxx/trunk/appveyor.yml Tue May  9 21:34:56 2017
@@ -62,7 +62,7 @@ build_script:
   - "%MAKE_PROGRAM%"
 
 test_script:
-  - "%MAKE_PROGRAM%" check-cxx
+  - "%MAKE_PROGRAM% check-cxx"
 
 on_failure:
   - appveyor PushArtifact CMakeFiles/CMakeOutput.log


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


r302615 - When we see a '<' operator, check whether it's a probable typo for a template-id.

2017-05-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue May  9 21:30:28 2017
New Revision: 302615

URL: http://llvm.org/viewvc/llvm-project?rev=302615=rev
Log:
When we see a '<' operator, check whether it's a probable typo for a 
template-id.

The heuristic that we use here is:
 * the left-hand side must be a simple identifier or a class member access
 * the right-hand side must be '<' followed by either a '>' or by a type-id that
   cannot be an expression (in particular, not followed by '(' or '{')
 * there is a '>' token matching the '<' token

The second condition guarantees the expression would otherwise be ill-formed.

If we're confident that the user intended the name before the '<' to be
interpreted as a template, diagnose the fact that we didn't interpret it
that way, rather than diagnosing that the template arguments are not valid
expressions.

Added:
cfe/trunk/test/SemaTemplate/typo-template-name.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=302615=302614=302615=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May  9 21:30:28 
2017
@@ -8191,6 +8191,15 @@ def err_undeclared_var_use_suggest : Err
 def err_no_template_suggest : Error<"no template named %0; did you mean %1?">;
 def err_no_member_template_suggest : Error<
   "no template named %0 in %1; did you mean %select{|simply }2%3?">;
+def err_non_template_in_template_id : Error<
+  "%0 does not name a template but is followed by template arguments">;
+def err_non_template_in_template_id_suggest : Error<
+  "%0 does not name a template but is followed by template arguments; "
+  "did you mean %1?">;
+def err_non_template_in_member_template_id_suggest : Error<
+  "member %0 of %1 is not a template; did you mean %select{|simply }2%3?">;
+def note_non_template_in_template_id_found : Note<
+  "non-template declaration found by name lookup">;
 def err_mem_init_not_member_or_class_suggest : Error<
   "initializer %0 does not name a non-static data member or base "
   "class; did you mean the %select{base class|member}1 %2?">;

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=302615=302614=302615=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue May  9 21:30:28 2017
@@ -1488,6 +1488,8 @@ private:
 K == tok::plusplus || K == tok::minusminus);
   }
 
+  bool diagnoseUnknownTemplateId(ExprResult TemplateName, SourceLocation Less);
+
   ExprResult ParsePostfixExpressionSuffix(ExprResult LHS);
   ExprResult ParseUnaryExprOrTypeTraitExpression();
   ExprResult ParseBuiltinPrimaryExpression();

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=302615=302614=302615=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue May  9 21:30:28 2017
@@ -1738,6 +1738,23 @@ public:
   TemplateNameKindForDiagnostics
   getTemplateNameKindForDiagnostics(TemplateName Name);
 
+  /// Determine whether it's plausible that E was intended to be a
+  /// template-name.
+  bool mightBeIntendedToBeTemplateName(ExprResult E) {
+if (!getLangOpts().CPlusPlus || E.isInvalid())
+  return false;
+if (auto *DRE = dyn_cast(E.get()))
+  return !DRE->hasExplicitTemplateArgs();
+if (auto *ME = dyn_cast(E.get()))
+  return !ME->hasExplicitTemplateArgs();
+// Any additional cases recognized here should also be handled by
+// diagnoseExprIntendedAsTemplateName.
+return false;
+  }
+  void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName,
+  SourceLocation Less,
+  SourceLocation Greater);
+
   Decl *ActOnDeclarator(Scope *S, Declarator );
 
   NamedDecl *HandleDeclarator(Scope *S, Declarator ,

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=302615=302614=302615=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue May  9 21:30:28 2017
@@ -235,6 +235,30 @@ bool Parser::isNotExpressionStart() {
   

[libcxx] r302614 - Add MinGW64 builder to Appveyor.

2017-05-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  9 21:30:16 2017
New Revision: 302614

URL: http://llvm.org/viewvc/llvm-project?rev=302614=rev
Log:
Add MinGW64 builder to Appveyor.

With the amount of work happening on Windows we should
have a MinGW bot to make sure we don't regress that functionality.
Currently it doesn't build :-(

Modified:
libcxx/trunk/appveyor.yml
libcxx/trunk/install-appveyor-reqs.cmd

Modified: libcxx/trunk/appveyor.yml
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/appveyor.yml?rev=302614=302613=302614=diff
==
--- libcxx/trunk/appveyor.yml (original)
+++ libcxx/trunk/appveyor.yml Tue May  9 21:30:16 2017
@@ -11,14 +11,25 @@ configuration:
 environment:
   matrix:
 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
+  CMAKE_OPTIONS: -DCMAKE_C_COMPILER=clang-cl.exe 
-DCMAKE_CXX_COMPILER=clang-cl.exe
   CLANG_VERSION: ToT
   MSVC_SETUP_PATH: C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat
   MSVC_SETUP_ARG: x86
+  GENERATOR: Ninja
+  MAKE_PROGRAM: ninja
   APPVEYOR_SAVE_CACHE_ON_ERROR: true
 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
+  CMAKE_OPTIONS: -DCMAKE_C_COMPILER=clang-cl.exe 
-DCMAKE_CXX_COMPILER=clang-cl.exe
   CLANG_VERSION: 4
   MSVC_SETUP_PATH: C:\Program Files (x86)\Microsoft Visual Studio 
14.0\VC\vcvarsall.bat
   MSVC_SETUP_ARG: x86_amd64
+  GENERATOR: Ninja
+  MAKE_PROGRAM: ninja
+  APPVEYOR_SAVE_CACHE_ON_ERROR: true
+- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
+  MINGW_PATH: C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32\bin
+  GENERATOR: MinGW Makefiles
+  MAKE_PROGRAM: mingw32-make
   APPVEYOR_SAVE_CACHE_ON_ERROR: true
 
 install:
@@ -28,7 +39,7 @@ install:
   - call "%APPVEYOR_BUILD_FOLDER%\\install-appveyor-reqs.cmd"
 
 before_build:
-  - call "%MSVC_SETUP_PATH%" %MSVC_SETUP_ARG%
+  - if DEFINED MSVC_SETUP_PATH call "%MSVC_SETUP_PATH%" %MSVC_SETUP_ARG%
   - cd %APPVEYOR_BUILD_FOLDER%
 
 build_script:
@@ -39,8 +50,7 @@ build_script:
   #
   # Configuration Step
   #
-  - cmake -G Ninja %extra_cmake_flags%
--DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe
+  - cmake -G "%GENERATOR%" %CMAKE_OPTIONS%
 "-DCMAKE_BUILD_TYPE=%configuration%"
 "-DLLVM_PATH=C:\projects\deps\llvm" 
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF
 -DLLVM_LIT_ARGS="-sv --show-xfail --show-unsupported"
@@ -49,10 +59,10 @@ build_script:
   #
   # Build Step
   #
-  - ninja
+  - "%MAKE_PROGRAM%"
 
 test_script:
-  - ninja check-cxx
+  - "%MAKE_PROGRAM%" check-cxx
 
 on_failure:
   - appveyor PushArtifact CMakeFiles/CMakeOutput.log

Modified: libcxx/trunk/install-appveyor-reqs.cmd
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/install-appveyor-reqs.cmd?rev=302614=302613=302614=diff
==
--- libcxx/trunk/install-appveyor-reqs.cmd (original)
+++ libcxx/trunk/install-appveyor-reqs.cmd Tue May  9 21:30:16 2017
@@ -1,11 +1,12 @@
 @echo on
+
 if NOT EXIST C:\projects\deps (
   mkdir C:\projects\deps
 )
 cd C:\projects\deps
 
 ::###
-:: Setup the path to Clang-cl
+:: Setup Compiler
 ::###
 if NOT EXIST llvm-installer.exe (
   appveyor DownloadFile 
http://llvm.org/pre-releases/win-snapshots/LLVM-5.0.0-r301646-win32.exe 
-FileName llvm-installer.exe
@@ -13,8 +14,13 @@ if NOT EXIST llvm-installer.exe (
 if "%CLANG_VERSION%"=="ToT" (
 START /WAIT llvm-installer.exe /S /D=C:\"Program Files\LLVM"
 )
-@set PATH="C:\Program Files\LLVM\bin";%PATH%
-clang-cl -v
+if DEFINED CLANG_VERSION  @set PATH="C:\Program Files\LLVM\bin";%PATH%
+if DEFINED CLANG_VERSION  clang-cl -v
+
+if DEFINED MINGW_PATH rename "C:\Program Files\Git\usr\bin\sh.exe" 
"sh-ignored.exe"
+if DEFINED MINGW_PATH @set "PATH=%PATH:C:\Program Files (x86)\Git\bin=%"
+if DEFINED MINGW_PATH @set "PATH=%PATH%;%MINGW_PATH%"
+if DEFINED MINGW_PATH g++ -v
 
 ::###
 :: Install a recent CMake


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


[libcxx] r302607 - Improve how LIT reports the added environment variables

2017-05-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  9 19:23:58 2017
New Revision: 302607

URL: http://llvm.org/viewvc/llvm-project?rev=302607=rev
Log:
Improve how LIT reports the added environment variables

Modified:
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=302607=302606=302607=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Tue May  9 19:23:58 2017
@@ -160,7 +160,11 @@ class Configuration(object):
 # Print as list to prevent "set([...])" from being printed.
 self.lit_config.note('Using available_features: %s' %
  list(self.config.available_features))
-self.lit_config.note('Using environment: %r' % self.exec_env)
+show_env_vars = {}
+for k,v in self.exec_env.items():
+if k not in os.environ or os.environ[k] != v:
+show_env_vars[k] = v
+self.lit_config.note('Adding environment variables: %r' % 
show_env_vars)
 sys.stderr.flush()  # Force flushing to avoid broken output on Windows
 
 def get_test_format(self):


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


[PATCH] D32988: [libc++] Refactor Windows support headers.

2017-05-09 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/__config:232-235
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+

compnerd wrote:
> bcraig wrote:
> > I can see this helping when we are build libc++, but I don't think it helps 
> > client apps.  They could have included windows.h before including our 
> > headers.
> > 
> > Don't get me wrong, I dislike the min and max macros, and bear no hard 
> > feelings towards people that define this project wide on the command line, 
> > I'm just not sure it will get things done right here.
> > 
> > In the past, I've just surrounded my min and max declarations with 
> > parenthesis to suppress macro expansion.
> Yeah, I don't think that this should be defined in `__config`.  Can we do 
> something like `#pragma push_macro` and `#pragma pop_macro` in the necessary 
> files?
Alright I'll remove the `NOMINMAX` define in `__config` and start to sprinkle 
the `__undef_min_max` include where it's currently needed.

@compnerd, using `push_macro` and `pop_macro` are going to be the correct way 
to handle this, but that's a change for another patch.



Comment at: include/support/win32/msvc_builtin_support.h:33
+
+_LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int x)
+{

majnemer wrote:
> compnerd wrote:
> > I think I prefer the following implementation:
> > 
> > _LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int value) {
> >   return __popcnt(value);
> > }
> I think it'd be better not to call it `__builtin_anything`. MSVC uses the 
> __builtin_ namespace too, see https://godbolt.org/g/HwMskX
> 
> Maybe create a wrapper called `__libcpp_popcount`?
That's a change for another patch, one that's just meant to restructure the 
headers.

This patch simply moves this code to another file.



Comment at: include/support/win32/msvc_builtin_support.h:33-51
+_LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int x)
+{
+  // Binary: 0101...
+  static const unsigned int m1 = 0x;
+  // Binary: 00110011..
+  static const unsigned int m2 = 0x;
+  // Binary:  4 zeros,  4 ones ...

EricWF wrote:
> majnemer wrote:
> > compnerd wrote:
> > > I think I prefer the following implementation:
> > > 
> > > _LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int value) {
> > >   return __popcnt(value);
> > > }
> > I think it'd be better not to call it `__builtin_anything`. MSVC uses the 
> > __builtin_ namespace too, see https://godbolt.org/g/HwMskX
> > 
> > Maybe create a wrapper called `__libcpp_popcount`?
> That's a change for another patch, one that's just meant to restructure the 
> headers.
> 
> This patch simply moves this code to another file.
That's a change for another patch, one that's just meant to restructure the 
headers.

This patch simply moves this code to another file.



Comment at: src/string.cpp:430
 #else
-return static_cast(swprintf);
+return static_cast(_snwprintf);
 #endif

compnerd wrote:
> This seems scary.  Why do we need to cast the function?
No idea.


https://reviews.llvm.org/D32988



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


[PATCH] D33021: [libcxx] [test] libc++ test changes for CWG 2094

2017-05-09 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal updated this revision to Diff 98376.
BillyONeal added a comment.

Bill got confused.


https://reviews.llvm.org/D33021

Files:
  
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp


Index: 
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
===
--- 
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
+++ 
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
@@ -20,15 +20,15 @@
 template 
 void test_is_trivially_copyable()
 {
-static_assert( std::is_trivially_copyable::value, "");
-static_assert( std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
 #if TEST_STD_VER > 14
-static_assert( std::is_trivially_copyable_v, "");
-static_assert( std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
 #endif
 }
 


Index: test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
===
--- test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
+++ test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
@@ -20,15 +20,15 @@
 template 
 void test_is_trivially_copyable()
 {
-static_assert( std::is_trivially_copyable::value, "");
-static_assert( std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
 #if TEST_STD_VER > 14
-static_assert( std::is_trivially_copyable_v, "");
-static_assert( std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
 #endif
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r302604 - Attempt to unbreak Libc++ test configuration

2017-05-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  9 19:05:04 2017
New Revision: 302604

URL: http://llvm.org/viewvc/llvm-project?rev=302604=rev
Log:
Attempt to unbreak Libc++ test configuration

Modified:
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=302604=302603=302604=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Tue May  9 19:05:04 2017
@@ -67,10 +67,7 @@ class Configuration(object):
 self.abi_library_root = None
 self.link_shared = self.get_lit_bool('enable_shared', default=True)
 self.debug_build = self.get_lit_bool('debug_build',   default=False)
-# FIXME: Some tests on Windows require we copy all of the environment
-# variables into the runtime environment. Should we do this on other
-# platforms too?
-self.exec_env = {} if not self.is_windows else dict(os.environ)
+self.exec_env = dict(os.environ)
 self.use_target = False
 self.use_system_cxx_lib = False
 self.use_clang_verify = False


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


r302603 - When instantiating a friend function template, don't forget to inherit default template arguments from other declarations.

2017-05-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue May  9 19:01:13 2017
New Revision: 302603

URL: http://llvm.org/viewvc/llvm-project?rev=302603=rev
Log:
When instantiating a friend function template, don't forget to inherit default 
template arguments from other declarations.

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaTemplate/default-arguments.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=302603=302602=302603=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue May  9 19:01:13 2017
@@ -1849,6 +1849,19 @@ Decl *TemplateDeclInstantiator::VisitFun
 }
   }
 }
+
+// Check the template parameter list against the previous declaration. The
+// goal here is to pick up default arguments added since the friend was
+// declared; we know the template parameter lists match, since otherwise
+// we would not have picked this template as the previous declaration.
+if (TemplateParams && FunctionTemplate->getPreviousDecl()) {
+  SemaRef.CheckTemplateParameterList(
+  TemplateParams,
+  FunctionTemplate->getPreviousDecl()->getTemplateParameters(),
+  Function->isThisDeclarationADefinition()
+  ? Sema::TPC_FriendFunctionTemplateDefinition
+  : Sema::TPC_FriendFunctionTemplate);
+}
   }
 
   if (Function->isLocalExternDecl() && !Function->getPreviousDecl())

Modified: cfe/trunk/test/SemaTemplate/default-arguments.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-arguments.cpp?rev=302603=302602=302603=diff
==
--- cfe/trunk/test/SemaTemplate/default-arguments.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-arguments.cpp Tue May  9 19:01:13 2017
@@ -207,3 +207,19 @@ Y y2;
 
 } // end ns1
 } // end ns PR26134
+
+namespace friends {
+  namespace ns {
+template struct A {
+  template friend void f();
+  template friend struct X;
+};
+template void f(); // expected-warning 0-1{{extension}}
+template struct X;
+A a;
+  }
+  namespace ns {
+void g() { f(); }
+X *p;
+  }
+}


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


[libcxx] r302602 - Fix test runtime environment on Windows

2017-05-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  9 18:57:22 2017
New Revision: 302602

URL: http://llvm.org/viewvc/llvm-project?rev=302602=rev
Log:
Fix test runtime environment on Windows

Modified:
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=302602=302601=302602=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Tue May  9 18:57:22 2017
@@ -67,7 +67,10 @@ class Configuration(object):
 self.abi_library_root = None
 self.link_shared = self.get_lit_bool('enable_shared', default=True)
 self.debug_build = self.get_lit_bool('debug_build',   default=False)
-self.exec_env = {}
+# FIXME: Some tests on Windows require we copy all of the environment
+# variables into the runtime environment. Should we do this on other
+# platforms too?
+self.exec_env = {} if not self.is_windows else dict(os.environ)
 self.use_target = False
 self.use_system_cxx_lib = False
 self.use_clang_verify = False


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


[PATCH] D32724: [Modules] Handle sanitizer feature mismatches when importing modules

2017-05-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 98371.
vsk marked 2 inline comments as done.
vsk added a comment.

Address comments from Adrian. (I settled on renaming 'getModularSanitizers' to 
'getPPTransparentSanitizers'.)


https://reviews.llvm.org/D32724

Files:
  include/clang/Basic/Sanitizers.h
  lib/Basic/LangOptions.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Serialization/ASTReader.cpp
  test/Modules/Inputs/check-for-sanitizer-feature/check.h
  test/Modules/Inputs/check-for-sanitizer-feature/map
  test/Modules/check-for-sanitizer-feature.cpp

Index: test/Modules/check-for-sanitizer-feature.cpp
===
--- /dev/null
+++ test/Modules/check-for-sanitizer-feature.cpp
@@ -0,0 +1,66 @@
+// RUN: rm -rf %t.1 %t.2
+// RUN: mkdir %t.1 %t.2
+
+// Build and use an ASan-enabled module.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 2
+
+// Force a module rebuild by disabling ASan.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Enable ASan again: check that there is no import failure, and no rebuild.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Some sanitizers can not affect AST generation when enabled. Check that
+// module rebuilds don't occur when these sanitizers are enabled.
+//
+// First, build without any sanitization.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+//
+// Next, build with sanitization, and check that a new module isn't built.
+// RUN: %clang_cc1 -fsanitize=cfi-vcall,unsigned-integer-overflow,nullability-arg,null -fmodules \
+// RUN:   -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+
+// Finally, test that including enabled sanitizers in the module hash isn't
+// required to ensure correctness of module imports.
+//
+// Emit a PCH with ASan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=address %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.asan_pch
+//
+// Import the PCH without ASan enabled (we expect an error).
+// RUN: not %clang_cc1 -x c -include-pch %t.asan_pch %s -verify 2>&1 | FileCheck %s --check-prefix=PCH_MISMATCH
+// PCH_MISMATCH: AST file was compiled with the target feature'-fsanitize=address' but the current translation unit is not
+//
+// Emit a PCH with UBSan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=null %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.ubsan_pch
+//
+// Import the PCH without UBSan enabled (should work just fine).
+// RUN: %clang_cc1 -x c -include-pch %t.ubsan_pch %s -I %S/Inputs/check-for-sanitizer-feature -verify
+
+#include "check.h"
+
+#if __has_feature(address_sanitizer)
+#if HAS_ASAN != 1
+#error Module doesn't have the address_sanitizer feature, but main program does.
+#endif
+#else
+#if HAS_ASAN != 0
+#error Module has the address_sanitizer feature, but main program doesn't.
+#endif
+#endif
+
+// expected-no-diagnostics
Index: test/Modules/Inputs/check-for-sanitizer-feature/map
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/map
@@ -0,0 +1,3 @@
+module check_feature {
+  header "check.h"
+}
Index: test/Modules/Inputs/check-for-sanitizer-feature/check.h
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/check.h
@@ -0,0 +1,5 @@
+#if __has_feature(address_sanitizer)
+#define HAS_ASAN 1
+#else
+#define HAS_ASAN 0
+#endif
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -292,6 +292,33 @@
 return true;
   }
 
+  // Sanitizer feature mismatches are treated as compatible differences. If
+  // compatible differences aren't allowed, we still only want to check for
+  // mismatches of non-modular sanitizers (the only ones which can affect AST
+  // generation).
+  if (!AllowCompatibleDifferences) {
+SanitizerMask ModularSanitizers = getPPTransparentSanitizers();
+SanitizerSet ExistingSanitizers = ExistingLangOpts.Sanitize;
+SanitizerSet ImportedSanitizers = LangOpts.Sanitize;
+

[libcxx] r302600 - Fix misspelling of environment throughout libc++

2017-05-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  9 18:47:20 2017
New Revision: 302600

URL: http://llvm.org/viewvc/llvm-project?rev=302600=rev
Log:
Fix misspelling of environment throughout libc++

Modified:
libcxx/trunk/docs/TestingLibcxx.rst
libcxx/trunk/test/support/filesystem_dynamic_test_helper.py
libcxx/trunk/test/support/filesystem_test_helper.hpp
libcxx/trunk/utils/libcxx/test/format.py

Modified: libcxx/trunk/docs/TestingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/TestingLibcxx.rst?rev=302600=302599=302600=diff
==
--- libcxx/trunk/docs/TestingLibcxx.rst (original)
+++ libcxx/trunk/docs/TestingLibcxx.rst Tue May  9 18:47:20 2017
@@ -119,7 +119,7 @@ configuration. Passing the option on the
 .. option:: libcxx_site_config=
 
   Specify the site configuration to use when running the tests.  This option
-  overrides the enviroment variable LIBCXX_SITE_CONFIG.
+  overrides the environment variable LIBCXX_SITE_CONFIG.
 
 .. option:: cxx_headers=
 

Modified: libcxx/trunk/test/support/filesystem_dynamic_test_helper.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/filesystem_dynamic_test_helper.py?rev=302600=302599=302600=diff
==
--- libcxx/trunk/test/support/filesystem_dynamic_test_helper.py (original)
+++ libcxx/trunk/test/support/filesystem_dynamic_test_helper.py Tue May  9 
18:47:20 2017
@@ -25,7 +25,7 @@ def sanitize(p):
 
 """
 Some of the tests restrict permissions to induce failures.
-Before we delete the test enviroment, we have to walk it and re-raise the
+Before we delete the test environment, we have to walk it and re-raise the
 permissions.
 """
 def clean_recursive(root_p):

Modified: libcxx/trunk/test/support/filesystem_test_helper.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/filesystem_test_helper.hpp?rev=302600=302599=302600=diff
==
--- libcxx/trunk/test/support/filesystem_test_helper.hpp (original)
+++ libcxx/trunk/test/support/filesystem_test_helper.hpp Tue May  9 18:47:20 
2017
@@ -227,7 +227,7 @@ private:
 }
 
 static inline void fs_helper_run(std::string const& raw_cmd) {
-// check that the fs test root in the enviroment matches what we were
+// check that the fs test root in the environment matches what we were
 // compiled with.
 static bool checked = checkDynamicTestRoot();
 ((void)checked);
@@ -246,7 +246,7 @@ private:
 std::abort();
 }
 if (std::string(fs_root) != LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT) {
-std::printf("ERROR: LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT enviroment 
variable"
+std::printf("ERROR: LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT 
environment variable"
 " must have the same value as when the test was 
compiled.\n");
 std::printf("   Current Value:  '%s'\n", fs_root);
 std::printf("   Expected Value: '%s'\n", 
LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT);

Modified: libcxx/trunk/utils/libcxx/test/format.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/format.py?rev=302600=302599=302600=diff
==
--- libcxx/trunk/utils/libcxx/test/format.py (original)
+++ libcxx/trunk/utils/libcxx/test/format.py Tue May  9 18:47:20 2017
@@ -139,7 +139,7 @@ class LibcxxTestFormat(object):
 # We can't run ShTest tests with a executor yet.
 # For now, bail on trying to run them
 return lit.Test.UNSUPPORTED, 'ShTest format not yet supported'
-test.config.enviroment = dict(self.exec_env)
+test.config.environment = dict(self.exec_env)
 return lit.TestRunner._runShTest(test, lit_config,
  self.execute_external, script,
  tmpBase)


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


[PATCH] D33021: [libcxx] [test] libc++ test changes for CWG 2094

2017-05-09 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal updated this revision to Diff 98370.
BillyONeal edited the summary of this revision.
BillyONeal added a comment.

Eric asked to just nuke the offending lines.


https://reviews.llvm.org/D33021

Files:
  
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp


Index: 
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
===
--- 
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
+++ 
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
@@ -20,15 +20,11 @@
 template 
 void test_is_trivially_copyable()
 {
-static_assert( std::is_trivially_copyable::value, "");
-static_assert( std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
 #if TEST_STD_VER > 14
-static_assert( std::is_trivially_copyable_v, "");
-static_assert( std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
 #endif
 }
 


Index: test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
===
--- test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
+++ test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
@@ -20,15 +20,11 @@
 template 
 void test_is_trivially_copyable()
 {
-static_assert( std::is_trivially_copyable::value, "");
-static_assert( std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
 #if TEST_STD_VER > 14
-static_assert( std::is_trivially_copyable_v, "");
-static_assert( std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
 #endif
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32724: [Modules] Handle sanitizer feature mismatches when importing modules

2017-05-09 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: include/clang/Basic/Sanitizers.h:64
 
-  /// \brief Disable all sanitizers.
-  void clear() { Mask = 0; }
+  /// \brief Disable the sanitizers specified in \p K (by default, disable
+  /// all sanitizers).

Might as well delete the `\brief` while you are modifying the comment.



Comment at: include/clang/Basic/Sanitizers.h:85
+/// AST generation.
+static inline SanitizerMask getModularSanitizers() {
+  return SanitizerKind::CFI | SanitizerKind::Integer |

getModularSanitizers is a bit misleading. How about 
`getASTTransparentSanitizers` or something along those lines?


https://reviews.llvm.org/D32724



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


[PATCH] D33021: [libcxx] [test] libc++ test changes for CWG 2094

2017-05-09 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal added inline comments.



Comment at: 
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp:25
+  #define IMPLEMENTS_CWG_2094 false
+ #endif /* defined(_MSC_VER) && _MSC_VER >= 1911 */
+#endif

Whoops, I fat fingered the closing comment. Will change this to just say 
"compiler version"


https://reviews.llvm.org/D33021



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


[PATCH] D32988: [libc++] Refactor Windows support headers.

2017-05-09 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: include/support/win32/msvc_builtin_support.h:33
+
+_LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int x)
+{

compnerd wrote:
> I think I prefer the following implementation:
> 
> _LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int value) {
>   return __popcnt(value);
> }
I think it'd be better not to call it `__builtin_anything`. MSVC uses the 
__builtin_ namespace too, see https://godbolt.org/g/HwMskX

Maybe create a wrapper called `__libcpp_popcount`?


https://reviews.llvm.org/D32988



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


[PATCH] D33021: [libcxx] [test] libc++ test changes for CWG 2094

2017-05-09 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal created this revision.

Update is_trivially_copyable tests with CWG 2094

Clang 5.0 implements this here: 
https://github.com/llvm-mirror/clang/commit/87cd035326a39523eeb1b295ad36cff337141ef9
MSVC++ will implement it in the first toolset update for VS 2017.


https://reviews.llvm.org/D33021

Files:
  
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp


Index: 
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
===
--- 
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
+++ 
test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
@@ -17,18 +17,26 @@
 #include 
 #include "test_macros.h"
 
+#ifndef IMPLEMENTS_CWG_2094
+ #if (defined(__clang_major__) && __clang_major__ >= 5) || (defined(_MSC_VER) 
&& _MSC_VER >= 1911)
+  #define IMPLEMENTS_CWG_2094 true
+ #else /* ^^^ Clang 5.0 or later, MSVC++ 19.11 or later ^^^ // vvv Others vvv 
*/
+  #define IMPLEMENTS_CWG_2094 false
+ #endif /* defined(_MSC_VER) && _MSC_VER >= 1911 */
+#endif
+
 template 
 void test_is_trivially_copyable()
 {
-static_assert( std::is_trivially_copyable::value, "");
-static_assert( std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value == 
IMPLEMENTS_CWG_2094, "");
+static_assert(std::is_trivially_copyable::value == 
IMPLEMENTS_CWG_2094, "");
 #if TEST_STD_VER > 14
-static_assert( std::is_trivially_copyable_v, "");
-static_assert( std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v == 
IMPLEMENTS_CWG_2094, "");
+static_assert(std::is_trivially_copyable_v == 
IMPLEMENTS_CWG_2094, "");
 #endif
 }
 


Index: test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
===
--- test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
+++ test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
@@ -17,18 +17,26 @@
 #include 
 #include "test_macros.h"
 
+#ifndef IMPLEMENTS_CWG_2094
+ #if (defined(__clang_major__) && __clang_major__ >= 5) || (defined(_MSC_VER) && _MSC_VER >= 1911)
+  #define IMPLEMENTS_CWG_2094 true
+ #else /* ^^^ Clang 5.0 or later, MSVC++ 19.11 or later ^^^ // vvv Others vvv */
+  #define IMPLEMENTS_CWG_2094 false
+ #endif /* defined(_MSC_VER) && _MSC_VER >= 1911 */
+#endif
+
 template 
 void test_is_trivially_copyable()
 {
-static_assert( std::is_trivially_copyable::value, "");
-static_assert( std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
-static_assert(!std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value, "");
+static_assert(std::is_trivially_copyable::value == IMPLEMENTS_CWG_2094, "");
+static_assert(std::is_trivially_copyable::value == IMPLEMENTS_CWG_2094, "");
 #if TEST_STD_VER > 14
-static_assert( std::is_trivially_copyable_v, "");
-static_assert( std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
-static_assert(!std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v, "");
+static_assert(std::is_trivially_copyable_v == IMPLEMENTS_CWG_2094, "");
+static_assert(std::is_trivially_copyable_v == IMPLEMENTS_CWG_2094, "");
 #endif
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302598 - [ubsan] Mark overflow checks with !nosanitize

2017-05-09 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Tue May  9 18:34:49 2017
New Revision: 302598

URL: http://llvm.org/viewvc/llvm-project?rev=302598=rev
Log:
[ubsan] Mark overflow checks with !nosanitize

Sanitizer instrumentation generally needs to be marked with !nosanitize,
but we're not doing this properly for ubsan's overflow checks.

r213291 has more information about why this is needed.

Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGen/sanitize-recover.c

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=302598=302597=302598=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue May  9 18:34:49 2017
@@ -2552,6 +2552,7 @@ Value *ScalarExprEmitter::EmitOverflowCh
   if (isSigned)
 OpID |= 1;
 
+  CodeGenFunction::SanitizerScope SanScope();
   llvm::Type *opTy = CGF.CGM.getTypes().ConvertType(Ops.Ty);
 
   llvm::Function *intrinsic = CGF.CGM.getIntrinsic(IID, opTy);
@@ -2567,7 +2568,6 @@ Value *ScalarExprEmitter::EmitOverflowCh
 // If the signed-integer-overflow sanitizer is enabled, emit a call to its
 // runtime. Otherwise, this is a -ftrapv check, so just emit a trap.
 if (!isSigned || CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) {
-  CodeGenFunction::SanitizerScope SanScope();
   llvm::Value *NotOverflow = Builder.CreateNot(overflow);
   SanitizerMask Kind = isSigned ? SanitizerKind::SignedIntegerOverflow
   : SanitizerKind::UnsignedIntegerOverflow;

Modified: cfe/trunk/test/CodeGen/sanitize-recover.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sanitize-recover.c?rev=302598=302597=302598=diff
==
--- cfe/trunk/test/CodeGen/sanitize-recover.c (original)
+++ cfe/trunk/test/CodeGen/sanitize-recover.c Tue May  9 18:34:49 2017
@@ -7,12 +7,12 @@
 void test() {
   extern volatile unsigned x, y, z;
 
-  // RECOVER: uadd.with.overflow.i32
-  // RECOVER: ubsan_handle_add_overflow(
+  // RECOVER: uadd.with.overflow.i32{{.*}}, !nosanitize
+  // RECOVER: ubsan_handle_add_overflow({{.*}}, !nosanitize
   // RECOVER-NOT: unreachable
-  // ABORT: uadd.with.overflow.i32
-  // ABORT: ubsan_handle_add_overflow_abort(
-  // ABORT: unreachable
+  // ABORT: uadd.with.overflow.i32{{.*}}, !nosanitize
+  // ABORT: ubsan_handle_add_overflow_abort({{.*}}, !nosanitize
+  // ABORT: unreachable{{.*}}, !nosanitize
   x = y + z;
 }
 


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


[PATCH] D33020: [Myriad] Pass -Xclang and -mllvm flags to moviCompile

2017-05-09 Thread Walter Lee via Phabricator via cfe-commits
waltl updated this revision to Diff 98369.

https://reviews.llvm.org/D33020

Files:
  lib/Driver/ToolChains/Myriad.cpp
  test/Driver/myriad-toolchain.c


Index: test/Driver/myriad-toolchain.c
===
--- test/Driver/myriad-toolchain.c
+++ test/Driver/myriad-toolchain.c
@@ -54,9 +54,11 @@
 // -fno-split-dwarf-inlining is consumed but not passed to moviCompile.
 // RUN: %clang -target shave-myriad -c -### %s -g -fno-inline-functions \
 // RUN: -fno-inline-functions-called-once -Os -Wall -MF dep.d 
-fno-split-dwarf-inlining \
-// RUN: -ffunction-sections 2>&1 | FileCheck %s -check-prefix=PASSTHRU_OPTIONS
+// RUN: -ffunction-sections -Xclang -xclangflag -mllvm -llvm-flag 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=PASSTHRU_OPTIONS
 // PASSTHRU_OPTIONS: "-g" "-fno-inline-functions" 
"-fno-inline-functions-called-once"
 // PASSTHRU_OPTIONS: "-Os" "-Wall" "-MF" "dep.d" "-ffunction-sections"
+// PASSTHRU_OPTIONS: "-Xclang" "-xclangflag" "-mllvm" "-llvm-flag"
 
 // RUN: %clang -target shave-myriad -c %s -o foo.o -### -MD -MF dep.d 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MDMF
Index: lib/Driver/ToolChains/Myriad.cpp
===
--- lib/Driver/ToolChains/Myriad.cpp
+++ lib/Driver/ToolChains/Myriad.cpp
@@ -43,15 +43,17 @@
   }
   CmdArgs.push_back("-DMYRIAD2");
 
-  // Append all -I, -iquote, -isystem paths, defines/undefines,
-  // 'f' flags, optimize flags, and warning options.
+  // Append all -I, -iquote, -isystem paths, defines/undefines, 'f'
+  // flags, 'g' flags, 'M' flags, optimize flags, warning options,
+  // mcpu flags, mllvm flags, and Xclang flags.
   // These are spelled the same way in clang and moviCompile.
   Args.AddAllArgsExcept(
   CmdArgs,
   {options::OPT_I_Group, options::OPT_clang_i_Group, options::OPT_std_EQ,
options::OPT_D, options::OPT_U, options::OPT_f_Group,
options::OPT_f_clang_Group, options::OPT_g_Group, options::OPT_M_Group,
-   options::OPT_O_Group, options::OPT_W_Group, options::OPT_mcpu_EQ},
+   options::OPT_O_Group, options::OPT_W_Group, options::OPT_mcpu_EQ,
+   options::OPT_mllvm, options::OPT_Xclang},
   {options::OPT_fno_split_dwarf_inlining});
   Args.hasArg(options::OPT_fno_split_dwarf_inlining); // Claim it if present.
 


Index: test/Driver/myriad-toolchain.c
===
--- test/Driver/myriad-toolchain.c
+++ test/Driver/myriad-toolchain.c
@@ -54,9 +54,11 @@
 // -fno-split-dwarf-inlining is consumed but not passed to moviCompile.
 // RUN: %clang -target shave-myriad -c -### %s -g -fno-inline-functions \
 // RUN: -fno-inline-functions-called-once -Os -Wall -MF dep.d -fno-split-dwarf-inlining \
-// RUN: -ffunction-sections 2>&1 | FileCheck %s -check-prefix=PASSTHRU_OPTIONS
+// RUN: -ffunction-sections -Xclang -xclangflag -mllvm -llvm-flag 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=PASSTHRU_OPTIONS
 // PASSTHRU_OPTIONS: "-g" "-fno-inline-functions" "-fno-inline-functions-called-once"
 // PASSTHRU_OPTIONS: "-Os" "-Wall" "-MF" "dep.d" "-ffunction-sections"
+// PASSTHRU_OPTIONS: "-Xclang" "-xclangflag" "-mllvm" "-llvm-flag"
 
 // RUN: %clang -target shave-myriad -c %s -o foo.o -### -MD -MF dep.d 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MDMF
Index: lib/Driver/ToolChains/Myriad.cpp
===
--- lib/Driver/ToolChains/Myriad.cpp
+++ lib/Driver/ToolChains/Myriad.cpp
@@ -43,15 +43,17 @@
   }
   CmdArgs.push_back("-DMYRIAD2");
 
-  // Append all -I, -iquote, -isystem paths, defines/undefines,
-  // 'f' flags, optimize flags, and warning options.
+  // Append all -I, -iquote, -isystem paths, defines/undefines, 'f'
+  // flags, 'g' flags, 'M' flags, optimize flags, warning options,
+  // mcpu flags, mllvm flags, and Xclang flags.
   // These are spelled the same way in clang and moviCompile.
   Args.AddAllArgsExcept(
   CmdArgs,
   {options::OPT_I_Group, options::OPT_clang_i_Group, options::OPT_std_EQ,
options::OPT_D, options::OPT_U, options::OPT_f_Group,
options::OPT_f_clang_Group, options::OPT_g_Group, options::OPT_M_Group,
-   options::OPT_O_Group, options::OPT_W_Group, options::OPT_mcpu_EQ},
+   options::OPT_O_Group, options::OPT_W_Group, options::OPT_mcpu_EQ,
+   options::OPT_mllvm, options::OPT_Xclang},
   {options::OPT_fno_split_dwarf_inlining});
   Args.hasArg(options::OPT_fno_split_dwarf_inlining); // Claim it if present.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33020: [Myriad] Pass -Xclang and -mllvm flags to moviCompile

2017-05-09 Thread Walter Lee via Phabricator via cfe-commits
waltl created this revision.

https://reviews.llvm.org/D33020

Files:
  lib/Driver/ToolChains/Myriad.cpp
  test/Driver/myriad-toolchain.c


Index: test/Driver/myriad-toolchain.c
===
--- test/Driver/myriad-toolchain.c
+++ test/Driver/myriad-toolchain.c
@@ -54,9 +54,11 @@
 // -fno-split-dwarf-inlining is consumed but not passed to moviCompile.
 // RUN: %clang -target shave-myriad -c -### %s -g -fno-inline-functions \
 // RUN: -fno-inline-functions-called-once -Os -Wall -MF dep.d 
-fno-split-dwarf-inlining \
-// RUN: -ffunction-sections 2>&1 | FileCheck %s -check-prefix=PASSTHRU_OPTIONS
+// RUN: -ffunction-sections -Xclang -xclangflag -mllvm -llvm-flag 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=PASSTHRU_OPTIONS
 // PASSTHRU_OPTIONS: "-g" "-fno-inline-functions" 
"-fno-inline-functions-called-once"
 // PASSTHRU_OPTIONS: "-Os" "-Wall" "-MF" "dep.d" "-ffunction-sections"
+// PASSTHRU_OPTIONS: "-Xclang" "-xclangflag" "-mllvm" "-llvm-flag"
 
 // RUN: %clang -target shave-myriad -c %s -o foo.o -### -MD -MF dep.d 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MDMF
Index: lib/Driver/ToolChains/Myriad.cpp
===
--- lib/Driver/ToolChains/Myriad.cpp
+++ lib/Driver/ToolChains/Myriad.cpp
@@ -43,15 +43,16 @@
   }
   CmdArgs.push_back("-DMYRIAD2");
 
-  // Append all -I, -iquote, -isystem paths, defines/undefines,
-  // 'f' flags, optimize flags, and warning options.
-  // These are spelled the same way in clang and moviCompile.
+  // Append all -I, -iquote, -isystem paths, defines/undefines, 'f'
+  // flags, 'g' flags, 'M' flags, optimize flags, warning options,
+  // mcpu flags, mllvm flags, and Xclang flags.
   Args.AddAllArgsExcept(
   CmdArgs,
   {options::OPT_I_Group, options::OPT_clang_i_Group, options::OPT_std_EQ,
options::OPT_D, options::OPT_U, options::OPT_f_Group,
options::OPT_f_clang_Group, options::OPT_g_Group, options::OPT_M_Group,
-   options::OPT_O_Group, options::OPT_W_Group, options::OPT_mcpu_EQ},
+   options::OPT_O_Group, options::OPT_W_Group, options::OPT_mcpu_EQ,
+   options::OPT_mllvm, options::OPT_Xclang},
   {options::OPT_fno_split_dwarf_inlining});
   Args.hasArg(options::OPT_fno_split_dwarf_inlining); // Claim it if present.
 


Index: test/Driver/myriad-toolchain.c
===
--- test/Driver/myriad-toolchain.c
+++ test/Driver/myriad-toolchain.c
@@ -54,9 +54,11 @@
 // -fno-split-dwarf-inlining is consumed but not passed to moviCompile.
 // RUN: %clang -target shave-myriad -c -### %s -g -fno-inline-functions \
 // RUN: -fno-inline-functions-called-once -Os -Wall -MF dep.d -fno-split-dwarf-inlining \
-// RUN: -ffunction-sections 2>&1 | FileCheck %s -check-prefix=PASSTHRU_OPTIONS
+// RUN: -ffunction-sections -Xclang -xclangflag -mllvm -llvm-flag 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=PASSTHRU_OPTIONS
 // PASSTHRU_OPTIONS: "-g" "-fno-inline-functions" "-fno-inline-functions-called-once"
 // PASSTHRU_OPTIONS: "-Os" "-Wall" "-MF" "dep.d" "-ffunction-sections"
+// PASSTHRU_OPTIONS: "-Xclang" "-xclangflag" "-mllvm" "-llvm-flag"
 
 // RUN: %clang -target shave-myriad -c %s -o foo.o -### -MD -MF dep.d 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MDMF
Index: lib/Driver/ToolChains/Myriad.cpp
===
--- lib/Driver/ToolChains/Myriad.cpp
+++ lib/Driver/ToolChains/Myriad.cpp
@@ -43,15 +43,16 @@
   }
   CmdArgs.push_back("-DMYRIAD2");
 
-  // Append all -I, -iquote, -isystem paths, defines/undefines,
-  // 'f' flags, optimize flags, and warning options.
-  // These are spelled the same way in clang and moviCompile.
+  // Append all -I, -iquote, -isystem paths, defines/undefines, 'f'
+  // flags, 'g' flags, 'M' flags, optimize flags, warning options,
+  // mcpu flags, mllvm flags, and Xclang flags.
   Args.AddAllArgsExcept(
   CmdArgs,
   {options::OPT_I_Group, options::OPT_clang_i_Group, options::OPT_std_EQ,
options::OPT_D, options::OPT_U, options::OPT_f_Group,
options::OPT_f_clang_Group, options::OPT_g_Group, options::OPT_M_Group,
-   options::OPT_O_Group, options::OPT_W_Group, options::OPT_mcpu_EQ},
+   options::OPT_O_Group, options::OPT_W_Group, options::OPT_mcpu_EQ,
+   options::OPT_mllvm, options::OPT_Xclang},
   {options::OPT_fno_split_dwarf_inlining});
   Args.hasArg(options::OPT_fno_split_dwarf_inlining); // Claim it if present.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32988: [libc++] Refactor Windows support headers.

2017-05-09 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd requested changes to this revision.
compnerd added inline comments.



Comment at: include/__config:232-235
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+

bcraig wrote:
> I can see this helping when we are build libc++, but I don't think it helps 
> client apps.  They could have included windows.h before including our headers.
> 
> Don't get me wrong, I dislike the min and max macros, and bear no hard 
> feelings towards people that define this project wide on the command line, 
> I'm just not sure it will get things done right here.
> 
> In the past, I've just surrounded my min and max declarations with 
> parenthesis to suppress macro expansion.
Yeah, I don't think that this should be defined in `__config`.  Can we do 
something like `#pragma push_macro` and `#pragma pop_macro` in the necessary 
files?



Comment at: include/stdio.h:113-118
 #if defined(_LIBCPP_MSVCRT)
-extern "C++" {
-#include "support/win32/support.h"
+extern "C" {
+int vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
+int asprintf(char **sptr, const char *__restrict fmt, ...);
 }
 #endif

Should this be hoisted above the `#ifdef __cplusplus`?  This seems like it 
should be defined by `stdio.h` but isn't in msvcrt?



Comment at: include/support/win32/locale_win32.h:24
+#define LC_MESSAGES_MASK _M_MESSAGES
+#define LC_ALL_MASK (  LC_COLLATE_MASK \
+ | LC_CTYPE_MASK \

Can you please clang-format this block?



Comment at: include/support/win32/msvc_builtin_support.h:33-51
+_LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int x)
+{
+  // Binary: 0101...
+  static const unsigned int m1 = 0x;
+  // Binary: 00110011..
+  static const unsigned int m2 = 0x;
+  // Binary:  4 zeros,  4 ones ...

I think I prefer the following implementation:

_LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int value) {
  return __popcnt(value);
}



Comment at: include/support/win32/msvc_builtin_support.h:58-76
+_LIBCPP_ALWAYS_INLINE int __builtin_popcountll(unsigned long long x)
+{
+  // Binary: 0101...
+  static const unsigned long long m1 = 0x;
+  // Binary: 00110011..
+  static const unsigned long long m2 = 0x;
+  // Binary:  4 zeros,  4 ones ...

I think I prefer the following implementation:

_LIBCPP_ALWAYS_INLINE int __builtin_popcountll(unsigned long long value) {
  return __popcnt64(value);
}



Comment at: src/string.cpp:430
 #else
-return static_cast(swprintf);
+return static_cast(_snwprintf);
 #endif

This seems scary.  Why do we need to cast the function?


https://reviews.llvm.org/D32988



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


r302596 - Don't mark a member as a member specialization until we know we're keeping the specialization.

2017-05-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue May  9 18:02:10 2017
New Revision: 302596

URL: http://llvm.org/viewvc/llvm-project?rev=302596=rev
Log:
Don't mark a member as a member specialization until we know we're keeping the 
specialization.

This improves our behavior in a few ways:

 * We now guarantee that if a member is marked as being a member
   specialization, there will actually be a member specialization declaration
   somewhere on its redeclaration chain. This fixes a crash in modules builds
   where we would try to check that there was a visible declaration of the
   member specialization and be surprised to not find any declaration of it at
   all.

 * We don't set the source location of the in-class declaration of the member
   specialization to the out-of-line declaration's location until we have
   actually finished merging them. This fixes some very silly looking
   diagnostics, where we'd point a "previous declaration is here" note at the
   same declaration we're complaining about. Ideally we wouldn't mess with the
   prior declaration's location at all, but too much code assumes that the
   first declaration of an entity is a reasonable thing to use as an indication
   of where it was declared, and that's not really true for a member
   specialization unless we fake it like this.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/PCH/cxx-templates.cpp
cfe/trunk/test/PCH/cxx-templates.h
cfe/trunk/test/SemaTemplate/explicit-specialization-member.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=302596=302595=302596=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue May  9 18:02:10 2017
@@ -6085,6 +6085,7 @@ public:
  TemplateArgumentListInfo *ExplicitTemplateArgs,
LookupResult );
   bool CheckMemberSpecialization(NamedDecl *Member, LookupResult );
+  void CompleteMemberSpecialization(NamedDecl *Member, LookupResult );
 
   DeclResult
   ActOnExplicitInstantiation(Scope *S,

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=302596=302595=302596=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue May  9 18:02:10 2017
@@ -1488,6 +1488,11 @@ bool Sema::ShouldWarnIfUnusedFileScopedD
   if (const FunctionDecl *FD = dyn_cast(D)) {
 if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
   return false;
+// A non-out-of-line declaration of a member specialization was implicitly
+// instantiated; it's the out-of-line declaration that we're interested in.
+if (FD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization &&
+FD->getMemberSpecializationInfo() && !FD->isOutOfLine())
+  return false;
 
 if (const CXXMethodDecl *MD = dyn_cast(FD)) {
   if (MD->isVirtual() || IsDisallowedCopyOrAssign(MD))
@@ -1514,6 +1519,10 @@ bool Sema::ShouldWarnIfUnusedFileScopedD
 if (VD->isStaticDataMember() &&
 VD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
   return false;
+if (VD->isStaticDataMember() &&
+VD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization &&
+VD->getMemberSpecializationInfo() && !VD->isOutOfLine())
+  return false;
 
 if (VD->isInline() && !isMainFileLoc(*this, VD->getLocation()))
   return false;
@@ -6706,6 +6715,9 @@ NamedDecl *Sema::ActOnVariableDeclarator
 return NewTemplate;
   }
 
+  if (IsMemberSpecialization && !NewVD->isInvalidDecl())
+CompleteMemberSpecialization(NewVD, Previous);
+
   return NewVD;
 }
 
@@ -8919,13 +8931,17 @@ Sema::ActOnFunctionDeclarator(Scope *S,
 }
   }
 
+  MarkUnusedFileScopedDecl(NewFD);
+
   if (getLangOpts().CPlusPlus) {
 if (FunctionTemplate) {
   if (NewFD->isInvalidDecl())
 FunctionTemplate->setInvalidDecl();
-  MarkUnusedFileScopedDecl(NewFD);
   return FunctionTemplate;
 }
+
+if (isMemberSpecialization && !NewFD->isInvalidDecl())
+  CompleteMemberSpecialization(NewFD, Previous);
   }
 
   if (NewFD->hasAttr()) {
@@ -8965,8 +8981,6 @@ Sema::ActOnFunctionDeclarator(Scope *S,
 }
   }
 
-  MarkUnusedFileScopedDecl(NewFD);
-
   // Here we have an function template explicit specialization at class scope.
   // The actually specialization will be postponed to template instatiation
   // time via the ClassScopeFunctionSpecializationDecl node.
@@ -9183,7 +9197,9 @@ bool Sema::CheckFunctionDeclaration(Scop
 if (OldTemplateDecl->getTemplatedDecl()->isDeleted()) {
   FunctionDecl *const OldTemplatedDecl =

[PATCH] D32724: [Modules] Handle sanitizer feature mismatches when importing modules

2017-05-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 98363.
vsk added a comment.

I've uploaded the correct diff this time, sorry for the confusion.


https://reviews.llvm.org/D32724

Files:
  include/clang/Basic/Sanitizers.h
  lib/Basic/LangOptions.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Serialization/ASTReader.cpp
  test/Modules/Inputs/check-for-sanitizer-feature/check.h
  test/Modules/Inputs/check-for-sanitizer-feature/map
  test/Modules/check-for-sanitizer-feature.cpp

Index: test/Modules/check-for-sanitizer-feature.cpp
===
--- /dev/null
+++ test/Modules/check-for-sanitizer-feature.cpp
@@ -0,0 +1,66 @@
+// RUN: rm -rf %t.1 %t.2
+// RUN: mkdir %t.1 %t.2
+
+// Build and use an ASan-enabled module.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 2
+
+// Force a module rebuild by disabling ASan.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Enable ASan again: check that there is no import failure, and no rebuild.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Some sanitizers can not affect AST generation when enabled. Check that
+// module rebuilds don't occur when these sanitizers are enabled.
+//
+// First, build without any sanitization.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+//
+// Next, build with sanitization, and check that a new module isn't built.
+// RUN: %clang_cc1 -fsanitize=cfi-vcall,unsigned-integer-overflow,nullability-arg,null -fmodules \
+// RUN:   -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+
+// Finally, test that including enabled sanitizers in the module hash isn't
+// required to ensure correctness of module imports.
+//
+// Emit a PCH with ASan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=address %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.asan_pch
+//
+// Import the PCH without ASan enabled (we expect an error).
+// RUN: not %clang_cc1 -x c -include-pch %t.asan_pch %s -verify 2>&1 | FileCheck %s --check-prefix=PCH_MISMATCH
+// PCH_MISMATCH: AST file was compiled with the target feature'-fsanitize=address' but the current translation unit is not
+//
+// Emit a PCH with UBSan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=null %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.ubsan_pch
+//
+// Import the PCH without UBSan enabled (should work just fine).
+// RUN: %clang_cc1 -x c -include-pch %t.ubsan_pch %s -I %S/Inputs/check-for-sanitizer-feature -verify
+
+#include "check.h"
+
+#if __has_feature(address_sanitizer)
+#if HAS_ASAN != 1
+#error Module doesn't have the address_sanitizer feature, but main program does.
+#endif
+#else
+#if HAS_ASAN != 0
+#error Module has the address_sanitizer feature, but main program doesn't.
+#endif
+#endif
+
+// expected-no-diagnostics
Index: test/Modules/Inputs/check-for-sanitizer-feature/map
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/map
@@ -0,0 +1,3 @@
+module check_feature {
+  header "check.h"
+}
Index: test/Modules/Inputs/check-for-sanitizer-feature/check.h
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/check.h
@@ -0,0 +1,5 @@
+#if __has_feature(address_sanitizer)
+#define HAS_ASAN 1
+#else
+#define HAS_ASAN 0
+#endif
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -292,6 +292,33 @@
 return true;
   }
 
+  // Sanitizer feature mismatches are treated as compatible differences. If
+  // compatible differences aren't allowed, we still only want to check for
+  // mismatches of non-modular sanitizers (the only ones which can affect AST
+  // generation).
+  if (!AllowCompatibleDifferences) {
+SanitizerMask ModularSanitizers = getModularSanitizers();
+SanitizerSet ExistingSanitizers = ExistingLangOpts.Sanitize;
+SanitizerSet ImportedSanitizers = LangOpts.Sanitize;
+ExistingSanitizers.clear(ModularSanitizers);
+ImportedSanitizers.clear(ModularSanitizers);
+

r302594 - Fix clang_cl argument in fsanitize.c driver test.

2017-05-09 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Tue May  9 17:28:57 2017
New Revision: 302594

URL: http://llvm.org/viewvc/llvm-project?rev=302594=rev
Log:
Fix clang_cl argument in fsanitize.c driver test.

Modified:
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=302594=302593=302594=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Tue May  9 17:28:57 2017
@@ -128,8 +128,8 @@
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-globals-dead-stripping %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-ASAN-GLOBALS
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-NO-ASAN-GLOBALS
-// RUN: %clang_cl -target x86_64-windows-msvc -fsanitize=address 
-fsanitize-address-globals-dead-stripping -### -- %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-ASAN-GLOBALS
-// RUN: %clang_cl -target x86_64-windows-msvc -fsanitize=address -### -- %s 
2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// RUN: %clang_cl --target=x86_64-windows-msvc -fsanitize=address 
-fsanitize-address-globals-dead-stripping -### -- %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-ASAN-GLOBALS
+// RUN: %clang_cl --target=x86_64-windows-msvc -fsanitize=address -### -- %s 
2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
 // CHECK-ASAN-GLOBALS: -cc1{{.*}}-fsanitize-address-globals-dead-stripping
 // CHECK-NO-ASAN-GLOBALS-NOT: 
-cc1{{.*}}-fsanitize-address-globals-dead-stripping
 


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


r302593 - [Sema] Implement Core 2094: Trivial copy/move constructor for class with volatile member

2017-05-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  9 17:21:24 2017
New Revision: 302593

URL: http://llvm.org/viewvc/llvm-project?rev=302593=rev
Log:
[Sema] Implement Core 2094: Trivial copy/move constructor for class with 
volatile member

Summary: This patch implements 
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094 which reverts 
Core 496.

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/CXX/drs/dr20xx.cpp
Modified:
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/test/CXX/drs/dr4xx.cpp
cfe/trunk/test/SemaCXX/type-traits.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=302593=302592=302593=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue May  9 17:21:24 2017
@@ -2114,18 +2114,15 @@ bool QualType::isTriviallyCopyableType(c
   if (hasNonTrivialObjCLifetime())
 return false;
 
-  // C++11 [basic.types]p9
+  // C++11 [basic.types]p9 - See Core 2094
   //   Scalar types, trivially copyable class types, arrays of such types, and
-  //   non-volatile const-qualified versions of these types are collectively
+  //   cv-qualified versions of these types are collectively
   //   called trivially copyable types.
 
   QualType CanonicalType = getCanonicalType();
   if (CanonicalType->isDependentType())
 return false;
 
-  if (CanonicalType.isVolatileQualified())
-return false;
-
   // Return false for incomplete types after skipping any incomplete array 
types
   // which are expressly allowed by the standard and thus our API.
   if (CanonicalType->isIncompleteType())

Added: cfe/trunk/test/CXX/drs/dr20xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr20xx.cpp?rev=302593=auto
==
--- cfe/trunk/test/CXX/drs/dr20xx.cpp (added)
+++ cfe/trunk/test/CXX/drs/dr20xx.cpp Tue May  9 17:21:24 2017
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors \
+// RUN:-Wno-variadic-macros -Wno-c11-extensions
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+
+// expected-no-diagnostics
+
+#if __cplusplus < 201103L
+#define static_assert(...) _Static_assert(__VA_ARGS__)
+#endif
+
+namespace dr2094 { // dr2094: 5.0
+  struct A { int n; };
+  struct B { volatile int n; };
+  static_assert(__is_trivially_copyable(volatile int), "");
+  static_assert(__is_trivially_copyable(const volatile int), "");
+  static_assert(__is_trivially_copyable(const volatile int[]), "");
+  static_assert(__is_trivially_copyable(A), "");
+  static_assert(__is_trivially_copyable(volatile A), "");
+  static_assert(__is_trivially_copyable(const volatile A), "");
+  static_assert(__is_trivially_copyable(const volatile A[]), "");
+  static_assert(__is_trivially_copyable(B), "");
+
+  static_assert(__is_trivially_constructible(A, A const&), "");
+  static_assert(__is_trivially_constructible(B, B const&), "");
+
+  static_assert(__is_trivially_assignable(A, const A&), "");
+  static_assert(__is_trivially_assignable(B, const B&), "");
+}

Modified: cfe/trunk/test/CXX/drs/dr4xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr4xx.cpp?rev=302593=302592=302593=diff
==
--- cfe/trunk/test/CXX/drs/dr4xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr4xx.cpp Tue May  9 17:21:24 2017
@@ -1202,16 +1202,15 @@ namespace dr495 { // dr495: 3.5
   long n2 = s2;
 }
 
-namespace dr496 { // dr496: no
+namespace dr496 { // dr496: sup dr2094
   struct A { int n; };
   struct B { volatile int n; };
   int check1[ __is_trivially_copyable(const int) ? 1 : -1];
-  int check2[!__is_trivially_copyable(volatile int) ? 1 : -1];
+  // This checks the dr2094 behavior, not dr496
+  int check2[ __is_trivially_copyable(volatile int) ? 1 : -1];
   int check3[ __is_trivially_constructible(A, const A&) ? 1 : -1];
-  // FIXME: This is wrong.
   int check4[ __is_trivially_constructible(B, const B&) ? 1 : -1];
   int check5[ __is_trivially_assignable(A, const A&) ? 1 : -1];
-  // FIXME: This is wrong.
   int check6[ __is_trivially_assignable(B, const B&) ? 1 : -1];
 }
 

Modified: cfe/trunk/test/SemaCXX/type-traits.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/type-traits.cpp?rev=302593=302592=302593=diff

[PATCH] D32984: [Sema] Implement Core 2094: Trivial copy/move constructor for class with volatile member

2017-05-09 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 98359.
EricWF added a comment.

- Remove unrelated issues list changes.


https://reviews.llvm.org/D32984

Files:
  lib/AST/Type.cpp
  test/CXX/drs/dr20xx.cpp
  test/CXX/drs/dr4xx.cpp
  test/SemaCXX/type-traits.cpp
  www/cxx_dr_status.html

Index: www/cxx_dr_status.html
===
--- www/cxx_dr_status.html
+++ www/cxx_dr_status.html
@@ -3017,7 +3017,7 @@
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#496;>496
 CD3
 Is a volatile-qualified type really a POD?
-No
+Superseded by dr2094
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#497;>497
@@ -12379,7 +12379,7 @@
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094;>2094
 DR
 Trivial copy/move constructor for class with volatile member
-Unknown
+Clang 5.0
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2095;>2095
Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -1256,7 +1256,7 @@
   int t33[F(__is_trivially_copyable(ExtDefaulted))];
 
   int t34[T(__is_trivially_copyable(const int))];
-  int t35[F(__is_trivially_copyable(volatile int))];
+  int t35[T(__is_trivially_copyable(volatile int))];
 }
 
 struct CStruct {
Index: test/CXX/drs/dr4xx.cpp
===
--- test/CXX/drs/dr4xx.cpp
+++ test/CXX/drs/dr4xx.cpp
@@ -1202,16 +1202,15 @@
   long n2 = s2;
 }
 
-namespace dr496 { // dr496: no
+namespace dr496 { // dr496: sup dr2094
   struct A { int n; };
   struct B { volatile int n; };
   int check1[ __is_trivially_copyable(const int) ? 1 : -1];
-  int check2[!__is_trivially_copyable(volatile int) ? 1 : -1];
+  // This checks the dr2094 behavior, not dr496
+  int check2[ __is_trivially_copyable(volatile int) ? 1 : -1];
   int check3[ __is_trivially_constructible(A, const A&) ? 1 : -1];
-  // FIXME: This is wrong.
   int check4[ __is_trivially_constructible(B, const B&) ? 1 : -1];
   int check5[ __is_trivially_assignable(A, const A&) ? 1 : -1];
-  // FIXME: This is wrong.
   int check6[ __is_trivially_assignable(B, const B&) ? 1 : -1];
 }
 
Index: test/CXX/drs/dr20xx.cpp
===
--- /dev/null
+++ test/CXX/drs/dr20xx.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors \
+// RUN:-Wno-variadic-macros -Wno-c11-extensions
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+
+// expected-no-diagnostics
+
+#if __cplusplus < 201103L
+#define static_assert(...) _Static_assert(__VA_ARGS__)
+#endif
+
+namespace dr2094 { // dr2094: 5.0
+  struct A { int n; };
+  struct B { volatile int n; };
+  static_assert(__is_trivially_copyable(volatile int), "");
+  static_assert(__is_trivially_copyable(const volatile int), "");
+  static_assert(__is_trivially_copyable(const volatile int[]), "");
+  static_assert(__is_trivially_copyable(A), "");
+  static_assert(__is_trivially_copyable(volatile A), "");
+  static_assert(__is_trivially_copyable(const volatile A), "");
+  static_assert(__is_trivially_copyable(const volatile A[]), "");
+  static_assert(__is_trivially_copyable(B), "");
+
+  static_assert(__is_trivially_constructible(A, A const&), "");
+  static_assert(__is_trivially_constructible(B, B const&), "");
+
+  static_assert(__is_trivially_assignable(A, const A&), "");
+  static_assert(__is_trivially_assignable(B, const B&), "");
+}
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2114,18 +2114,15 @@
   if (hasNonTrivialObjCLifetime())
 return false;
 
-  // C++11 [basic.types]p9
+  // C++11 [basic.types]p9 - See Core 2094
   //   Scalar types, trivially copyable class types, arrays of such types, and
-  //   non-volatile const-qualified versions of these types are collectively
+  //   cv-qualified versions of these types are collectively
   //   called trivially copyable types.
 
   QualType CanonicalType = getCanonicalType();
   if (CanonicalType->isDependentType())
 return false;
 
-  if (CanonicalType.isVolatileQualified())
-return false;
-
   // Return false for incomplete types after skipping any incomplete array types
   // which are expressly allowed by the standard and thus our API.
   if (CanonicalType->isIncompleteType())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r302592 - Update Clang C++ DR documentation for new issue list

2017-05-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  9 17:17:23 2017
New Revision: 302592

URL: http://llvm.org/viewvc/llvm-project?rev=302592=rev
Log:
Update Clang C++ DR documentation for new issue list

Modified:
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/www/cxx_dr_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=302592=302591=302592=diff
==
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Tue May  9 17:17:23 2017
@@ -589,7 +589,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#92;>92
-WP
+CD4
 Should exception-specifications be part of the type system?
 Clang 4 (C++17 onwards)
   
@@ -935,11 +935,11 @@
 Accessibility and ambiguity
 N/A
   
-  
-http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#150;>150
-open
+  
+http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#150;>150
+DR
 Template template parameters and default arguments
-Not resolved
+Unknown
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#151;>151
@@ -1310,7 +1310,7 @@ accessible?
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#212;>212
-DR
+CD4
 Implicit instantiation is not described clearly enough
 Unknown
   
@@ -1466,7 +1466,7 @@ accessible?
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#238;>238
-DR
+CD4
 Precision and accuracy constraints on floating point
 Unknown
   
@@ -1490,7 +1490,7 @@ accessible?
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#242;>242
-DR
+CD4
 Interpretation of old-style casts
 Unknown
   
@@ -2019,7 +2019,7 @@ of class templates
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#330;>330
-DRWP
+CD4
 Qualification conversions and pointers to arrays of pointers
 Unknown
   
@@ -2397,7 +2397,7 @@ of class templates
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#393;>393
-DRWP
+CD4
 Pointer to array of unknown bound in template argument list in 
parameter
 Unknown
   
@@ -3587,7 +3587,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#591;>591
-DRWP
+CD4
 When a dependent base class is the current instantiation
 No
   
@@ -3695,7 +3695,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#609;>609
-DRWP
+CD4
 What is a top-level cv-qualifier?
 Unknown
   
@@ -5735,7 +5735,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#987;>987
-DRWP
+CD4
 Which declarations introduce namespace members?
 Unknown
   
@@ -5939,7 +5939,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1021;>1021
-DRWP
+CD4
 Definitions of namespace members
 Unknown
   
@@ -6509,7 +6509,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1116;>1116
-DRWP
+CD4
 Aliasing of union members
 Unknown
   
@@ -7295,7 +7295,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1247;>1247
-DRWP
+CD4
 Restriction on alias name appearing in type-id
 Unknown
   
@@ -7457,7 +7457,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1274;>1274
-DRWP
+CD4
 Common nonterminal for expression and 
braced-init-list
 Unknown
   
@@ -7517,7 +7517,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1284;>1284
-DR
+CD4
 Should the lifetime of an array be independent of that of its 
elements?
 Unknown
   
@@ -7565,7 +7565,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1292;>1292
-DRWP
+CD4
 Dependent calls with braced-init-lists containing a pack 
expansion
 Unknown
   
@@ -7667,7 +7667,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1309;>1309
-DRWP
+CD4
 Incorrect note regarding lookup of a member of the current 
instantiation
 Unknown
   
@@ -7703,7 +7703,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1315;>1315
-DR
+CD4
 Restrictions on non-type template arguments in partial 
specializations
 Partial
   
@@ -7841,7 +7841,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1338;>1338
-DRWP
+CD4
 Aliasing and allocation functions
 Unknown
   
@@ -7870,8 +7870,8 @@ and POD class
 Not resolved
   
   
-http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1343;>1343
-tentatively ready
+

[PATCH] D32977: [OpenCL] Emit function-scope variable in constant address space as static variable

2017-05-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:7129
+NewVD->getType().getAddressSpace() != LangAS::opencl_constant) ||
 NewVD->hasExternalStorage()) {
   if (!T->isSamplerT() &&

Seeing criteria like this, and a lot of the other things you've modified, makes 
me feel like we should just have a VarDecl::getStorageDuration().



Comment at: lib/Sema/SemaDecl.cpp:10286
+  // these variables must be a compile time constant.
+  VDecl->getType().getAddressSpace() == LangAS::opencl_constant)
 CheckForConstantInitializer(Init, DclT);

Should this rule apply even in C++ mode?  I can't remember if there are any 
OpenCL/C++ hybrids.


https://reviews.llvm.org/D32977



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


[PATCH] D32886: [asan] A clang flag to enable ELF globals-gc

2017-05-09 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis closed this revision.
eugenis added a comment.

r302591, thanks for the review!


Repository:
  rL LLVM

https://reviews.llvm.org/D32886



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


r302590 - Remove unnecessary calls to MakeArgString.

2017-05-09 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Tue May  9 16:57:39 2017
New Revision: 302590

URL: http://llvm.org/viewvc/llvm-project?rev=302590=rev
Log:
Remove unnecessary calls to MakeArgString.

Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=302590=302589=302590=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Tue May  9 16:57:39 2017
@@ -633,7 +633,7 @@ void SanitizerArgs::addArgs(const ToolCh
 std::make_pair(CoverageNoPrune, "-fsanitize-coverage-no-prune")};
   for (auto F : CoverageFlags) {
 if (CoverageFeatures & F.first)
-  CmdArgs.push_back(Args.MakeArgString(F.second));
+  CmdArgs.push_back(F.second);
   }
 
   if (TC.getTriple().isOSWindows() && needsUbsanRt()) {
@@ -686,7 +686,7 @@ void SanitizerArgs::addArgs(const ToolCh
  llvm::utostr(MsanTrackOrigins)));
 
   if (MsanUseAfterDtor)
-CmdArgs.push_back(Args.MakeArgString("-fsanitize-memory-use-after-dtor"));
+CmdArgs.push_back("-fsanitize-memory-use-after-dtor");
 
   // FIXME: Pass these parameters as function attributes, not as -llvm flags.
   if (!TsanMemoryAccess) {
@@ -705,17 +705,17 @@ void SanitizerArgs::addArgs(const ToolCh
   }
 
   if (CfiCrossDso)
-CmdArgs.push_back(Args.MakeArgString("-fsanitize-cfi-cross-dso"));
+CmdArgs.push_back("-fsanitize-cfi-cross-dso");
 
   if (Stats)
-CmdArgs.push_back(Args.MakeArgString("-fsanitize-stats"));
+CmdArgs.push_back("-fsanitize-stats");
 
   if (AsanFieldPadding)
 CmdArgs.push_back(Args.MakeArgString("-fsanitize-address-field-padding=" +
  llvm::utostr(AsanFieldPadding)));
 
   if (AsanUseAfterScope)
-
CmdArgs.push_back(Args.MakeArgString("-fsanitize-address-use-after-scope"));
+CmdArgs.push_back("-fsanitize-address-use-after-scope");
 
   // MSan: Workaround for PR16386.
   // ASan: This is mainly to help LSan with cases such as
@@ -723,7 +723,7 @@ void SanitizerArgs::addArgs(const ToolCh
   // We can't make this conditional on -fsanitize=leak, as that flag shouldn't
   // affect compilation.
   if (Sanitizers.has(Memory) || Sanitizers.has(Address))
-CmdArgs.push_back(Args.MakeArgString("-fno-assume-sane-operator-new"));
+CmdArgs.push_back("-fno-assume-sane-operator-new");
 
   // Require -fvisibility= flag on non-Windows when compiling if vptr CFI is
   // enabled.

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=302590=302589=302590=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Tue May  9 16:57:39 2017
@@ -282,18 +282,18 @@ void mips::getMIPSTargetFeatures(const D
   if (Arg *A = Args.getLastArg(options::OPT_mfp32, options::OPT_mfpxx,
options::OPT_mfp64)) {
 if (A->getOption().matches(options::OPT_mfp32))
-  Features.push_back(Args.MakeArgString("-fp64"));
+  Features.push_back("-fp64");
 else if (A->getOption().matches(options::OPT_mfpxx)) {
-  Features.push_back(Args.MakeArgString("+fpxx"));
-  Features.push_back(Args.MakeArgString("+nooddspreg"));
+  Features.push_back("+fpxx");
+  Features.push_back("+nooddspreg");
 } else
-  Features.push_back(Args.MakeArgString("+fp64"));
+  Features.push_back("+fp64");
   } else if (mips::shouldUseFPXX(Args, Triple, CPUName, ABIName, FloatABI)) {
-Features.push_back(Args.MakeArgString("+fpxx"));
-Features.push_back(Args.MakeArgString("+nooddspreg"));
+Features.push_back("+fpxx");
+Features.push_back("+nooddspreg");
   } else if (mips::isFP64ADefault(Triple, CPUName)) {
-Features.push_back(Args.MakeArgString("+fp64"));
-Features.push_back(Args.MakeArgString("+nooddspreg"));
+Features.push_back("+fp64");
+Features.push_back("+nooddspreg");
   }
 
   AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,


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


r302591 - [asan] A clang flag to enable ELF globals-gc.

2017-05-09 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Tue May  9 16:57:43 2017
New Revision: 302591

URL: http://llvm.org/viewvc/llvm-project?rev=302591=rev
Log:
[asan] A clang flag to enable ELF globals-gc.

This feature is subtly broken when the linker is gold 2.26 or
earlier. See the following bug for details:
  https://sourceware.org/bugzilla/show_bug.cgi?id=19002

Since the decision needs to be made at compilation time, we can not
test the linker version. The flag is off by default on ELF targets,
and on otherwise.

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/asan-globals-gc.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=302591=302590=302591=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue May  9 16:57:43 2017
@@ -827,6 +827,9 @@ def fno_sanitize_address_use_after_scope
Group,
Flags<[CoreOption, DriverOption]>,
HelpText<"Disable use-after-scope 
detection in AddressSanitizer">;
+def fsanitize_address_globals_dead_stripping : Flag<["-"], 
"fsanitize-address-globals-dead-stripping">,
+Group,
+HelpText<"Enable linker dead stripping 
of globals in AddressSanitizer">;
 def fsanitize_recover : Flag<["-"], "fsanitize-recover">, Group;
 def fno_sanitize_recover : Flag<["-"], "fno-sanitize-recover">,
Flags<[CoreOption, DriverOption]>,

Modified: cfe/trunk/include/clang/Driver/SanitizerArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/SanitizerArgs.h?rev=302591=302590=302591=diff
==
--- cfe/trunk/include/clang/Driver/SanitizerArgs.h (original)
+++ cfe/trunk/include/clang/Driver/SanitizerArgs.h Tue May  9 16:57:43 2017
@@ -35,6 +35,7 @@ class SanitizerArgs {
   int AsanFieldPadding = 0;
   bool AsanSharedRuntime = false;
   bool AsanUseAfterScope = true;
+  bool AsanGlobalsDeadStripping = false;
   bool LinkCXXRuntimes = false;
   bool NeedPIE = false;
   bool Stats = false;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=302591=302590=302591=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Tue May  9 16:57:43 2017
@@ -137,6 +137,8 @@ CODEGENOPT(StructPathTBAA, 1, 0) ///
 CODEGENOPT(SaveTempLabels, 1, 0) ///< Save temporary labels.
 CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0) ///< Enable use-after-scope 
detection
 ///< in AddressSanitizer
+CODEGENOPT(SanitizeAddressGlobalsDeadStripping, 1, 0) ///< Enable linker dead 
stripping
+  ///< of globals in 
AddressSanitizer
 CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0) ///< Enable tracking origins in
  ///< MemorySanitizer
 CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete 
detection

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=302591=302590=302591=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue May  9 16:57:43 2017
@@ -194,6 +194,8 @@ static void addSanitizerCoveragePass(con
 // where this is not a factor). Also, on ELF this feature requires an assembler
 // extension that only works with -integrated-as at the moment.
 static bool asanUseGlobalsGC(const Triple , const CodeGenOptions ) {
+  if (!CGOpts.SanitizeAddressGlobalsDeadStripping)
+return false;
   switch (T.getObjectFormat()) {
   case Triple::MachO:
   case Triple::COFF:

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=302591=302590=302591=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Tue May  9 16:57:43 2017
@@ -566,6 +566,13 @@ SanitizerArgs::SanitizerArgs(const ToolC
 

[PATCH] D16171: Warning on redeclaring with a conflicting asm label

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith requested changes to this revision.
rsmith added a comment.
This revision now requires changes to proceed.

In https://reviews.llvm.org/D16171#540261, @phabricss wrote:

>   ../include/sys/stat.h:16:15: error: cannot apply asm label to function 
> after its first use
>   hidden_proto (__fxstat)
>   ~~^
>   ./../include/libc-symbols.h:420:19: note: expanded from macro 'hidden_proto'
> __hidden_proto (name, , __GI_##name, ##attrs)
> ^
>   ./../include/libc-symbols.h:424:33: note: expanded from macro 
> '__hidden_proto'
> extern thread __typeof (name) name __asm__ (__hidden_asmname (#internal)) 
> \
>


This patch does nothing about that error. This patch is dealing with a case 
where two distinct asm labels are provided for the same declaration, which 
would simply be a bug in the code. Given that we are not seeing that error any 
more, and that nicholas suggests that the reason is that the glibc maintainers 
applied a patch to fix it, this change seems unnecessary and deleterious.

As for the above change, we could theoretically accept such shenanigans, but it 
would require a much more invasive approach than the one in this patch -- in 
particular, it would require rewriting any code we've already emitted using the 
old name, changing it to use the new name instead. And even then, that is 
fundamentally not possible for some use cases of Clang (where we might have 
already, say, created machine code and started running it, possibly on a 
different machine, before we reach this asm label).

I would strongly suggest pushing back hard on the glibc maintainers and 
suggesting they don't rely on this working.




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4275-4276
   "use of %0 with tag type that does not match previous declaration">;
+def warn_different_asm_label : Warning<"conflicting asm label">,
+InGroup;
 def warn_struct_class_tag_mismatch : Warning<

Move this earlier so that it's adjacent to the error form.

Please also use a different diagnostic group. This makes no sense in 
`-Wmismatched-tags`. Please also make this `DefaultError`; allowing it to be 
turned off might be OK, but this code pattern is still horribly broken, and we 
should not accept it by default.



Comment at: lib/Sema/SemaDecl.cpp:2388
 // This redeclaration changes __asm__ label.
-Diag(New->getLocation(), diag::err_different_asm_label);
+if (New->isUsed())
+  Diag(New->getLocation(), diag::err_different_asm_label);

This looks wrong. How could `New` already be used here, since it's new? Should 
this say `Old` instead?

Please also make sure we have test coverage for this. None of the tests below 
use the declaration before adding the conflicting label.


https://reviews.llvm.org/D16171



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


[PATCH] D16171: Warning on redeclaring with a conflicting asm label

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

Er, please ignore the inline review comments; those predated the realisation 
that this doesn't actually fix the glibc build problem.


https://reviews.llvm.org/D16171



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


[PATCH] D32886: [asan] A clang flag to enable ELF globals-gc

2017-05-09 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

I'll fix the other unnecessary MakeArgString calls in a separate commit


Repository:
  rL LLVM

https://reviews.llvm.org/D32886



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


[PATCH] D32886: [asan] A clang flag to enable ELF globals-gc

2017-05-09 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis updated this revision to Diff 98354.
eugenis marked an inline comment as done.

Repository:
  rL LLVM

https://reviews.llvm.org/D32886

Files:
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/asan-globals-gc.cpp
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -126,6 +126,13 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE
 // CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE: -cc1{{.*}}address-use-after-scope
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-globals-dead-stripping %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ASAN-GLOBALS
+// RUN: %clang_cl -target x86_64-windows-msvc -fsanitize=address -fsanitize-address-globals-dead-stripping -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// RUN: %clang_cl -target x86_64-windows-msvc -fsanitize=address -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// CHECK-ASAN-GLOBALS: -cc1{{.*}}-fsanitize-address-globals-dead-stripping
+// CHECK-NO-ASAN-GLOBALS-NOT: -cc1{{.*}}-fsanitize-address-globals-dead-stripping
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-TRACK-ORIGINS
 // CHECK-ONLY-TRACK-ORIGINS: warning: argument unused during compilation: '-fsanitize-memory-track-origins'
 
Index: test/CodeGen/asan-globals-gc.cpp
===
--- test/CodeGen/asan-globals-gc.cpp
+++ test/CodeGen/asan-globals-gc.cpp
@@ -1,5 +1,16 @@
-// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
-// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc -fdata-sections %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-integrated-as -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-integrated-as -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-data-sections -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fdata-sections -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITHOUT-GC
+
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-data-sections -emit-llvm -o - -triple x86_64-apple-macosx11 %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fdata-sections -emit-llvm -o - -triple x86_64-apple-macosx11 %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-apple-macosx11 %s | FileCheck %s --check-prefix=WITHOUT-GC
 
 int global;
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -778,6 +778,8 @@
 Opts.SanitizeAddressUseAfterScope =
 A->getOption().getID() == OPT_fsanitize_address_use_after_scope;
   }
+  Opts.SanitizeAddressGlobalsDeadStripping =
+  Args.hasArg(OPT_fsanitize_address_globals_dead_stripping);
   Opts.SSPBufferSize =
   getLastArgIntValue(Args, OPT_stack_protector_buffer_size, 8, Diags);
   Opts.StackRealignment = Args.hasArg(OPT_mstackrealign);
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -566,6 +566,13 @@
 

[PATCH] D33013: Driver must return non-zero code on errors in command line

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

Thank you, some of these test typos are ... alarming. =)

A couple of the test updates don't look quite right, but this mostly looks 
great.




Comment at: test/Driver/amdgpu-features.c:1
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-abi=0.0 %s -o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-0-0 %s

This should say `-o -`



Comment at: test/Driver/amdgpu-features.c:5
 
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-abi=1.0 %s -o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-1-0 %s

Likewise.



Comment at: test/Driver/split-debug.h:6-13
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -fmodules 
-emit-module -fno-implicit-modules -fno-implicit-module-maps -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s
 //
 // FIXME: This should fail using clang, except that the type of the output for
 // an object output with modules is given as clang::driver::types::TY_PCH
 // rather than TY_Object.
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -fmodules 
-### %s 2> %t

These parts of the test don't make sense: the `-fmodule-format=obj` and 
`-emit-module` are `-cc1` options, so testing how the driver deals with them 
doesn't really make a lot of sense. I would suggest deleting the highlighted 
region of this test rather than making it test the same thing three times.


https://reviews.llvm.org/D33013



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


r302588 - Fix CGObjCGNU::init bug introduced by r302572

2017-05-09 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue May  9 16:19:44 2017
New Revision: 302588

URL: http://llvm.org/viewvc/llvm-project?rev=302588=rev
Log:
Fix CGObjCGNU::init bug introduced by r302572

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

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=302588=302587=302588=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Tue May  9 16:19:44 2017
@@ -63,8 +63,13 @@ public:
 CGM = Mod;
 FunctionName = name;
 Function = nullptr;
-std::vector ArgTys{{Types...}};
-FTy = llvm::FunctionType::get(RetTy, ArgTys, false);
+if(sizeof...(Tys)) {
+  SmallVector ArgTys({Types...});
+  FTy = llvm::FunctionType::get(RetTy, ArgTys, false);
+}
+else {
+  FTy = llvm::FunctionType::get(RetTy, None, false);
+}
   }
 
   llvm::FunctionType *getType() { return FTy; }


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


Re: [PATCH] D24933: Enable configuration files in clang

2017-05-09 Thread Richard Smith via cfe-commits
On 1 March 2017 at 02:50, Serge Pavlov via Phabricator <
revi...@reviews.llvm.org> wrote:

> sepavloff added a comment.
>
> Glad to know that someone is interested in this feature!
> Below is actual proposal.
>
> **Adding named configuration files to clang driver**
>
> A configuration file is a collection of driver options, which are inserted
> into command line before other options specified in the clang invocation.
> It groups related options together and allows specifying them in simpler,
> more flexible and less error prone way than just listing the options
> somewhere in build scripts. Configuration file may be thought as a "macro"
> that names an option set and is expanded when the driver is called.  This
> feature must be helpful when a user need to specify many options, cross
> compilation is likely to be such case.
>
> Configuration file can be specified by either of two methods:
>
> - by command line option `--config `, or
> - by using special executable file names, such as `armv7l-clang`.
>
> If the option `--config` is used, its argument is treated as a path to
> configuration file if it contains a directory separator, otherwise the file
> is searched for in the set of directories described below. If option
> `--config` is absent and clang executable has name in the form
> `armv7l-clang`, driver will search for file `armv7l.cfg` in the same set of
> directories. Similar encoding is already used by clang to specify target.
>
> The set of directories where configuration files are searched for consists
> of at most three directories, checked in this order:
>
> - user directory (like `~/.llvm`),
> - system directory (like `/etc/llvm`),
> - the directory where clang executable resides.
>
> User and system directories are optional, they are reserved for
> distribution or SDK suppliers. By default they are absent, corresponding
> directories can be specified by cmake arguments
> `CLANG_CONFIG_FILE_SYSTEM_DIR` and `CLANG_CONFIG_FILE_USER_DIR`. The first
> found file is used.
>
> Format of configuration file is similar to file used in the construct
> `@file`, it is a set of options. Configuration file have advantage over
> this construct:
>
> - it is searched for in well-known places rather than in current directory,
>

This (and suppressing unused-argument warnings) might well be sufficient to
justify a different command-line syntax rather than @file...


> - it may contain comments, long options may be split between lines using
> trailing backslashes,
> - other files may be included by `@file` and they will be resolved
> relative to the including file,
>

... but I think we should just add these extensions to our @file handling,
and then use the exact same syntax and code to handle config files and
@file files. That is, the difference between @ and --config would be that
the latter looks in a different directory and suppresses "unused argument"
warnings, but they would otherwise be identical.

- the file may be encoded in executable name,
> - unused options from configuration file do not produce warnings.
>
>
> 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] D32724: [Modules] Handle sanitizer feature mismatches when importing modules

2017-05-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 98349.
vsk marked 7 inline comments as done.
vsk added a comment.

Add a comment explaining how and why ASTReader checks for sanitizer feature 
mismatches.


https://reviews.llvm.org/D32724

Files:
  include/clang/Basic/Sanitizers.h
  lib/Basic/LangOptions.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Serialization/ASTReader.cpp
  test/Modules/Inputs/check-for-sanitizer-feature/check.h
  test/Modules/Inputs/check-for-sanitizer-feature/map
  test/Modules/check-for-sanitizer-feature.cpp

Index: test/Modules/check-for-sanitizer-feature.cpp
===
--- /dev/null
+++ test/Modules/check-for-sanitizer-feature.cpp
@@ -0,0 +1,66 @@
+// RUN: rm -rf %t.1 %t.2
+// RUN: mkdir %t.1 %t.2
+
+// Build and use an ASan-enabled module.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 2
+
+// Force a module rebuild by disabling ASan.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Enable ASan again: check that there is no import failure, and no rebuild.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Some sanitizers can not affect AST generation when enabled. Check that
+// module rebuilds don't occur when these sanitizers are enabled.
+//
+// First, build without any sanitization.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+//
+// Next, build with sanitization, and check that a new module isn't built.
+// RUN: %clang_cc1 -fsanitize=cfi-vcall,unsigned-integer-overflow,nullability-arg,null -fmodules \
+// RUN:   -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+
+// Finally, test that including enabled sanitizers in the module hash isn't
+// required to ensure correctness of module imports.
+//
+// Emit a PCH with ASan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=address %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.asan_pch
+//
+// Import the PCH without ASan enabled (we expect an error).
+// RUN: not %clang_cc1 -x c -include-pch %t.asan_pch %s -verify 2>&1 | FileCheck %s --check-prefix=PCH_MISMATCH
+// PCH_MISMATCH: AST file was compiled with the target feature'-fsanitize=address' but the current translation unit is not
+//
+// Emit a PCH with UBSan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=null %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.ubsan_pch
+//
+// Import the PCH without UBSan enabled (should work just fine).
+// RUN: %clang_cc1 -x c -include-pch %t.ubsan_pch %s -I %S/Inputs/check-for-sanitizer-feature -verify
+
+#include "check.h"
+
+#if __has_feature(address_sanitizer)
+#if HAS_ASAN != 1
+#error Module doesn't have the address_sanitizer feature, but main program does.
+#endif
+#else
+#if HAS_ASAN != 0
+#error Module has the address_sanitizer feature, but main program doesn't.
+#endif
+#endif
+
+// expected-no-diagnostics
Index: test/Modules/Inputs/check-for-sanitizer-feature/map
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/map
@@ -0,0 +1,3 @@
+module check_feature {
+  header "check.h"
+}
Index: test/Modules/Inputs/check-for-sanitizer-feature/check.h
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/check.h
@@ -0,0 +1,5 @@
+#if __has_feature(address_sanitizer)
+#define HAS_ASAN 1
+#else
+#define HAS_ASAN 0
+#endif
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -292,6 +292,33 @@
 return true;
   }
 
+  // Sanitizer feature mismatches are treated as compatible differences. If
+  // compatible differences aren't allowed, we still only want to check for
+  // mismatches of non-modular sanitizers (the only ones which can affect AST
+  // generation).
+  if (!AllowCompatibleDifferences) {
+SanitizerMask ModularSanitizers = getModularSanitizers();
+SanitizerSet 

[PATCH] D32743: [clang-tidy] Add new cert-dcl21-cpp check.

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

LGTM!


https://reviews.llvm.org/D32743



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


[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302580: clang-format: [JS] Don't indent JavaScript IIFEs. 
(authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D32989?vs=98332=98344#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32989

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -476,6 +476,24 @@
   return I->Tok->is(tok::l_paren);
 }
 
+static bool isIIFE(const UnwrappedLine ,
+   const AdditionalKeywords ) {
+  // Look for the start of an immediately invoked anonymous function.
+  // https://en.wikipedia.org/wiki/Immediately-invoked_function_expression
+  // This is commonly done in JavaScript to create a new, anonymous scope.
+  // Example: (function() { ... })()
+  if (Line.Tokens.size() < 3)
+return false;
+  auto I = Line.Tokens.begin();
+  if (I->Tok->isNot(tok::l_paren))
+return false;
+  ++I;
+  if (I->Tok->isNot(Keywords.kw_function))
+return false;
+  ++I;
+  return I->Tok->is(tok::l_paren);
+}
+
 static bool ShouldBreakBeforeBrace(const FormatStyle ,
const FormatToken ) {
   if (InitialToken.is(tok::kw_namespace))
@@ -493,15 +511,16 @@
   FormatTok->BlockKind = BK_Block;
   nextToken();
   {
-bool GoogScope =
-Style.Language == FormatStyle::LK_JavaScript && isGoogScope(*Line);
+bool SkipIndent =
+(Style.Language == FormatStyle::LK_JavaScript &&
+ (isGoogScope(*Line) || isIIFE(*Line, Keywords)));
 ScopedLineState LineState(*this);
 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
 /*MustBeDeclaration=*/false);
-Line->Level += GoogScope ? 0 : 1;
+Line->Level += SkipIndent ? 0 : 1;
 parseLevel(/*HasOpeningBrace=*/true);
 flushComments(isOnNewLine(*FormatTok));
-Line->Level -= GoogScope ? 0 : 1;
+Line->Level -= SkipIndent ? 0 : 1;
   }
   nextToken();
 }
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -367,6 +367,25 @@
"});");
 }
 
+TEST_F(FormatTestJS, IIFEs) {
+  // Internal calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"
+   "}())");
+  // External calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var b = 2;\n"
+   "})()");
+  // Internal calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var c = 3;\n"
+   "}());");
+  // External calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var d = 4;\n"
+   "})();");
+}
+
 TEST_F(FormatTestJS, GoogModules) {
   verifyFormat("goog.module('this.is.really.absurdly.long');",
getGoogleJSStyleWithColumns(40));


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -476,6 +476,24 @@
   return I->Tok->is(tok::l_paren);
 }
 
+static bool isIIFE(const UnwrappedLine ,
+   const AdditionalKeywords ) {
+  // Look for the start of an immediately invoked anonymous function.
+  // https://en.wikipedia.org/wiki/Immediately-invoked_function_expression
+  // This is commonly done in JavaScript to create a new, anonymous scope.
+  // Example: (function() { ... })()
+  if (Line.Tokens.size() < 3)
+return false;
+  auto I = Line.Tokens.begin();
+  if (I->Tok->isNot(tok::l_paren))
+return false;
+  ++I;
+  if (I->Tok->isNot(Keywords.kw_function))
+return false;
+  ++I;
+  return I->Tok->is(tok::l_paren);
+}
+
 static bool ShouldBreakBeforeBrace(const FormatStyle ,
const FormatToken ) {
   if (InitialToken.is(tok::kw_namespace))
@@ -493,15 +511,16 @@
   FormatTok->BlockKind = BK_Block;
   nextToken();
   {
-bool GoogScope =
-Style.Language == FormatStyle::LK_JavaScript && isGoogScope(*Line);
+bool SkipIndent =
+(Style.Language == FormatStyle::LK_JavaScript &&
+ (isGoogScope(*Line) || isIIFE(*Line, Keywords)));
 ScopedLineState LineState(*this);
 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
 /*MustBeDeclaration=*/false);
-Line->Level += GoogScope ? 0 : 1;
+Line->Level += SkipIndent ? 0 : 1;
 parseLevel(/*HasOpeningBrace=*/true);
 flushComments(isOnNewLine(*FormatTok));
-Line->Level -= GoogScope ? 0 : 1;
+Line->Level -= 

r302580 - clang-format: [JS] Don't indent JavaScript IIFEs.

2017-05-09 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Tue May  9 15:04:09 2017
New Revision: 302580

URL: http://llvm.org/viewvc/llvm-project?rev=302580=rev
Log:
clang-format: [JS] Don't indent JavaScript IIFEs.

Because IIFEs[1] are often used like an anonymous namespace around large
sections of JavaScript code, it's useful not to indent to them (which
effectively reduces the column limit by the indent amount needlessly).

It's also common for developers to wrap these around entire files or
libraries. When adopting clang-format, changing the indent entire file
can reduce the usefulness of the blame annotations.

Patch by danbeam, thanks!

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=302580=302579=302580=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue May  9 15:04:09 2017
@@ -476,6 +476,24 @@ static bool isGoogScope(const UnwrappedL
   return I->Tok->is(tok::l_paren);
 }
 
+static bool isIIFE(const UnwrappedLine ,
+   const AdditionalKeywords ) {
+  // Look for the start of an immediately invoked anonymous function.
+  // https://en.wikipedia.org/wiki/Immediately-invoked_function_expression
+  // This is commonly done in JavaScript to create a new, anonymous scope.
+  // Example: (function() { ... })()
+  if (Line.Tokens.size() < 3)
+return false;
+  auto I = Line.Tokens.begin();
+  if (I->Tok->isNot(tok::l_paren))
+return false;
+  ++I;
+  if (I->Tok->isNot(Keywords.kw_function))
+return false;
+  ++I;
+  return I->Tok->is(tok::l_paren);
+}
+
 static bool ShouldBreakBeforeBrace(const FormatStyle ,
const FormatToken ) {
   if (InitialToken.is(tok::kw_namespace))
@@ -493,15 +511,16 @@ void UnwrappedLineParser::parseChildBloc
   FormatTok->BlockKind = BK_Block;
   nextToken();
   {
-bool GoogScope =
-Style.Language == FormatStyle::LK_JavaScript && isGoogScope(*Line);
+bool SkipIndent =
+(Style.Language == FormatStyle::LK_JavaScript &&
+ (isGoogScope(*Line) || isIIFE(*Line, Keywords)));
 ScopedLineState LineState(*this);
 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
 /*MustBeDeclaration=*/false);
-Line->Level += GoogScope ? 0 : 1;
+Line->Level += SkipIndent ? 0 : 1;
 parseLevel(/*HasOpeningBrace=*/true);
 flushComments(isOnNewLine(*FormatTok));
-Line->Level -= GoogScope ? 0 : 1;
+Line->Level -= SkipIndent ? 0 : 1;
   }
   nextToken();
 }

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=302580=302579=302580=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue May  9 15:04:09 2017
@@ -367,6 +367,25 @@ TEST_F(FormatTestJS, GoogScopes) {
"});");
 }
 
+TEST_F(FormatTestJS, IIFEs) {
+  // Internal calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"
+   "}())");
+  // External calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var b = 2;\n"
+   "})()");
+  // Internal calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var c = 3;\n"
+   "}());");
+  // External calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var d = 4;\n"
+   "})();");
+}
+
 TEST_F(FormatTestJS, GoogModules) {
   verifyFormat("goog.module('this.is.really.absurdly.long');",
getGoogleJSStyleWithColumns(40));


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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

2017-05-09 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

ping


Repository:
  rL LLVM

https://reviews.llvm.org/D29654



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


[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
mprobst accepted this revision.
mprobst added inline comments.
This revision is now accepted and ready to land.



Comment at: unittests/Format/FormatTestJS.cpp:371
+TEST_F(FormatTestJS, IIFE) {
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"

danbeam wrote:
> mprobst wrote:
> > consider adding a test with comments between the tokens (which should work 
> > with `startsSequence`).
> not done yet, but seems uncommon.
> 
> do you want me to add a FIXME?
I think that's OK the way it is.


https://reviews.llvm.org/D32989



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


[PATCH] D32896: [OpenCL] Make CLK_NULL_RESERVE_ID invalid reserve id.

2017-05-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Headers/opencl-c.h:16020
+// The macro CLK_NULL_RESERVE_ID refers to an invalid reservation ID.
+#define CLK_NULL_RESERVE_ID (__builtin_astype((void *)0, reserve_id_t))
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);

Anastasia wrote:
> Looks good from my side.
> 
> @yaxunl , since you originally committed this. Could you please verify that 
> changing from `SIZE_MAX` to `0` would be fine.
> 
> Btw, we have a similar definition for `CLK_NULL_EVENT`.
`__PIPE_RESERVE_ID_VALID_BIT` is implementation detail and not part of the 
spec. I would suggest to remove it from this header file.

The spec only requires CLK_NULL_RESERVE_ID to be defined but does not define 
its value. Naturally a valid id starts from 0 and increases. I don't see 
significant advantage to change CLK_NULL_RESERVE_ID from __SIZE_MAX to 0.

Is there any reason that this change is needed?


https://reviews.llvm.org/D32896



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


r302577 - Update testcase for upstream LLVM changes (r302469).

2017-05-09 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue May  9 14:47:41 2017
New Revision: 302577

URL: http://llvm.org/viewvc/llvm-project?rev=302577=rev
Log:
Update testcase for upstream LLVM changes (r302469).

Modified:
cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp

Modified: cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp?rev=302577=302576=302577=diff
==
--- cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp Tue May  9 
14:47:41 2017
@@ -12,8 +12,10 @@ void Derived::VariadicFunction(...) { }
 
 // CHECK: define void @_ZN7Derived16VariadicFunctionEz({{.*}} !dbg 
![[SP:[0-9]+]]
 // CHECK: ret void, !dbg ![[LOC:[0-9]+]]
-// CHECK-LABEL: define void @_ZT{{.+}}N7Derived16VariadicFunctionEz(
-// CHECK: ret void, !dbg ![[LOC:[0-9]+]]
+// CHECK: define void @_ZT{{.+}}N7Derived16VariadicFunctionEz({{.*}} !dbg 
![[SP_I:[0-9]+]]
+// CHECK: ret void, !dbg ![[LOC_I:[0-9]+]]
 //
 // CHECK: ![[SP]] = distinct !DISubprogram(name: "VariadicFunction"
 // CHECK: ![[LOC]] = !DILocation({{.*}}scope: ![[SP]])
+// CHECK: ![[SP_I]] = distinct !DISubprogram(name: "VariadicFunction"
+// CHECK: ![[LOC_I]] = !DILocation({{.*}}scope: ![[SP_I]])


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


[PATCH] D32724: [Modules] Handle sanitizer feature mismatches when importing modules

2017-05-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 98343.
vsk retitled this revision from "[Modules] Include the enabled sanitizers in 
the module hash" to "[Modules] Handle sanitizer feature mismatches when 
importing modules".
vsk edited the summary of this revision.
vsk added a comment.

If compatible differences between a CU's lang opts and an imported module's 
lang opts are not allowed, issue an error when there is a mismatch in the set 
of enabled, non-modular sanitizers.


https://reviews.llvm.org/D32724

Files:
  include/clang/Basic/Sanitizers.h
  lib/Basic/LangOptions.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Serialization/ASTReader.cpp
  test/Modules/Inputs/check-for-sanitizer-feature/check.h
  test/Modules/Inputs/check-for-sanitizer-feature/map
  test/Modules/check-for-sanitizer-feature.cpp

Index: test/Modules/check-for-sanitizer-feature.cpp
===
--- /dev/null
+++ test/Modules/check-for-sanitizer-feature.cpp
@@ -0,0 +1,66 @@
+// RUN: rm -rf %t.1 %t.2
+// RUN: mkdir %t.1 %t.2
+
+// Build and use an ASan-enabled module.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 2
+
+// Force a module rebuild by disabling ASan.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Enable ASan again: check that there is no import failure, and no rebuild.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Some sanitizers can not affect AST generation when enabled. Check that
+// module rebuilds don't occur when these sanitizers are enabled.
+//
+// First, build without any sanitization.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+//
+// Next, build with sanitization, and check that a new module isn't built.
+// RUN: %clang_cc1 -fsanitize=cfi-vcall,unsigned-integer-overflow,nullability-arg,null -fmodules \
+// RUN:   -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+
+// Finally, test that including enabled sanitizers in the module hash isn't
+// required to ensure correctness of module imports.
+//
+// Emit a PCH with ASan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=address %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.asan_pch
+//
+// Import the PCH without ASan enabled (we expect an error).
+// RUN: not %clang_cc1 -x c -include-pch %t.asan_pch %s -verify 2>&1 | FileCheck %s --check-prefix=PCH_MISMATCH
+// PCH_MISMATCH: AST file was compiled with the target feature'-fsanitize=address' but the current translation unit is not
+//
+// Emit a PCH with UBSan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=null %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.ubsan_pch
+//
+// Import the PCH without UBSan enabled (should work just fine).
+// RUN: %clang_cc1 -x c -include-pch %t.ubsan_pch %s -I %S/Inputs/check-for-sanitizer-feature -verify
+
+#include "check.h"
+
+#if __has_feature(address_sanitizer)
+#if HAS_ASAN != 1
+#error Module doesn't have the address_sanitizer feature, but main program does.
+#endif
+#else
+#if HAS_ASAN != 0
+#error Module has the address_sanitizer feature, but main program doesn't.
+#endif
+#endif
+
+// expected-no-diagnostics
Index: test/Modules/Inputs/check-for-sanitizer-feature/map
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/map
@@ -0,0 +1,3 @@
+module check_feature {
+  header "check.h"
+}
Index: test/Modules/Inputs/check-for-sanitizer-feature/check.h
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/check.h
@@ -0,0 +1,5 @@
+#if __has_feature(address_sanitizer)
+#define HAS_ASAN 1
+#else
+#define HAS_ASAN 0
+#endif
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -292,6 +292,29 @@
 return true;
   }
 
+  SanitizerMask ModularSanitizers = getModularSanitizers();
+  SanitizerSet ExistingSanitizers = ExistingLangOpts.Sanitize;
+  SanitizerSet ImportedSanitizers = LangOpts.Sanitize;
+  ExistingSanitizers.clear(ModularSanitizers);
+  

[PATCH] D32984: [Sema] Implement Core 2094: Trivial copy/move constructor for class with volatile member

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Please first check in a change that just regenerates cxx_dr_status without your 
changes, to separate out the changes due to the new issues list from the 
changes due to this patch. (You can go ahead and do that with no review.)


https://reviews.llvm.org/D32984



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


r302572 - Suppress all uses of LLVM_END_WITH_NULL. NFC.

2017-05-09 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue May  9 14:31:30 2017
New Revision: 302572

URL: http://llvm.org/viewvc/llvm-project?rev=302572=rev
Log:
Suppress all uses of LLVM_END_WITH_NULL. NFC.

Use variadic templates instead of relying on  + sentinel.

This enforces better type checking and makes code more readable.

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

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCUDANV.cpp
cfe/trunk/lib/CodeGen/CGCleanup.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=302572=302571=302572=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue May  9 14:31:30 2017
@@ -961,9 +961,8 @@ llvm::Type *CodeGenModule::getBlockDescr
   //   const char *signature;   // the block signature
   //   const char *layout;  // reserved
   // };
-  BlockDescriptorType =
-llvm::StructType::create("struct.__block_descriptor",
- UnsignedLongTy, UnsignedLongTy, nullptr);
+  BlockDescriptorType = llvm::StructType::create(
+  "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy);
 
   // Now form a pointer to that.
   unsigned AddrSpace = 0;
@@ -987,9 +986,8 @@ llvm::Type *CodeGenModule::getGenericBlo
   //   struct __block_descriptor *__descriptor;
   // };
   GenericBlockLiteralType =
-llvm::StructType::create("struct.__block_literal_generic",
- VoidPtrTy, IntTy, IntTy, VoidPtrTy,
- BlockDescPtrTy, nullptr);
+  llvm::StructType::create("struct.__block_literal_generic", VoidPtrTy,
+   IntTy, IntTy, VoidPtrTy, BlockDescPtrTy);
 
   return GenericBlockLiteralType;
 }

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=302572=302571=302572=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue May  9 14:31:30 2017
@@ -4571,7 +4571,7 @@ Value *CodeGenFunction::EmitARMBuiltinEx
 Function *F = CGM.getIntrinsic(BuiltinID == ARM::BI__builtin_arm_stlex
? Intrinsic::arm_stlexd
: Intrinsic::arm_strexd);
-llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty, nullptr);
+llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty);
 
 Address Tmp = CreateMemTemp(E->getArg(0)->getType());
 Value *Val = EmitScalarExpr(E->getArg(0));
@@ -5401,7 +5401,7 @@ Value *CodeGenFunction::EmitAArch64Built
 Function *F = CGM.getIntrinsic(BuiltinID == AArch64::BI__builtin_arm_stlex
? Intrinsic::aarch64_stlxp
: Intrinsic::aarch64_stxp);
-llvm::Type *STy = llvm::StructType::get(Int64Ty, Int64Ty, nullptr);
+llvm::Type *STy = llvm::StructType::get(Int64Ty, Int64Ty);
 
 Address Tmp = CreateMemTemp(E->getArg(0)->getType());
 EmitAnyExprToMem(E->getArg(0), Tmp, Qualifiers(), /*init*/ true);
@@ -7373,8 +7373,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 // unsigned int __cpu_type;
 // unsigned int __cpu_subtype;
 // unsigned int __cpu_features[1];
-llvm::Type *STy = llvm::StructType::get(
-Int32Ty, Int32Ty, Int32Ty, llvm::ArrayType::get(Int32Ty, 1), nullptr);
+llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty, Int32Ty,
+llvm::ArrayType::get(Int32Ty, 1));
 
 // Grab the global __cpu_model.
 llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");

Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=302572=302571=302572=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Tue May  9 14:31:30 2017
@@ -265,7 +265,7 @@ llvm::Function *CGNVCUDARuntime::makeMod
   

[PATCH] D32550: Supress all uses of LLVM_END_WITH_NULL

2017-05-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302572: Suppress all uses of LLVM_END_WITH_NULL. NFC. 
(authored by serge_sans_paille).

Changed prior to commit:
  https://reviews.llvm.org/D32550?vs=96798=98339#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32550

Files:
  cfe/trunk/lib/CodeGen/CGBlocks.cpp
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/CodeGen/CGCUDANV.cpp
  cfe/trunk/lib/CodeGen/CGCleanup.cpp
  cfe/trunk/lib/CodeGen/CGException.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprConstant.cpp
  cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
  cfe/trunk/lib/CodeGen/CGObjCMac.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h

Index: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
@@ -490,7 +490,7 @@
 llvm_unreachable("Unexpected undeduced type!");
   case Type::Complex: {
 llvm::Type *EltTy = ConvertType(cast(Ty)->getElementType());
-ResultType = llvm::StructType::get(EltTy, EltTy, nullptr);
+ResultType = llvm::StructType::get(EltTy, EltTy);
 break;
   }
   case Type::LValueReference:
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -2859,9 +2859,9 @@
   EmitTrapCheck(DataIsNotNullPtr);
 
   llvm::StructType *SourceLocationTy =
-  llvm::StructType::get(VoidPtrTy, Int32Ty, Int32Ty, nullptr);
+  llvm::StructType::get(VoidPtrTy, Int32Ty, Int32Ty);
   llvm::StructType *CfiCheckFailDataTy =
-  llvm::StructType::get(Int8Ty, SourceLocationTy, VoidPtrTy, nullptr);
+  llvm::StructType::get(Int8Ty, SourceLocationTy, VoidPtrTy);
 
   llvm::Value *V = Builder.CreateConstGEP2_32(
   CfiCheckFailDataTy,
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -4571,7 +4571,7 @@
 Function *F = CGM.getIntrinsic(BuiltinID == ARM::BI__builtin_arm_stlex
? Intrinsic::arm_stlexd
: Intrinsic::arm_strexd);
-llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty, nullptr);
+llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty);
 
 Address Tmp = CreateMemTemp(E->getArg(0)->getType());
 Value *Val = EmitScalarExpr(E->getArg(0));
@@ -5401,7 +5401,7 @@
 Function *F = CGM.getIntrinsic(BuiltinID == AArch64::BI__builtin_arm_stlex
? Intrinsic::aarch64_stlxp
: Intrinsic::aarch64_stxp);
-llvm::Type *STy = llvm::StructType::get(Int64Ty, Int64Ty, nullptr);
+llvm::Type *STy = llvm::StructType::get(Int64Ty, Int64Ty);
 
 Address Tmp = CreateMemTemp(E->getArg(0)->getType());
 EmitAnyExprToMem(E->getArg(0), Tmp, Qualifiers(), /*init*/ true);
@@ -7373,8 +7373,8 @@
 // unsigned int __cpu_type;
 // unsigned int __cpu_subtype;
 // unsigned int __cpu_features[1];
-llvm::Type *STy = llvm::StructType::get(
-Int32Ty, Int32Ty, Int32Ty, llvm::ArrayType::get(Int32Ty, 1), nullptr);
+llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty, Int32Ty,
+llvm::ArrayType::get(Int32Ty, 1));
 
 // Grab the global __cpu_model.
 llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");
Index: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp
@@ -1361,9 +1361,8 @@
 Value.getComplexIntImag());
 
 // FIXME: the target may want to specify that this is packed.
-llvm::StructType *STy = llvm::StructType::get(Complex[0]->getType(),
-  Complex[1]->getType(),
-  nullptr);
+llvm::StructType *STy =
+llvm::StructType::get(Complex[0]->getType(), Complex[1]->getType());
 return llvm::ConstantStruct::get(STy, Complex);
   }
   case APValue::Float: {
@@ -1384,9 +1383,8 @@
Value.getComplexFloatImag());
 
 // FIXME: the target may want to specify that this is packed.
-llvm::StructType *STy = 

[PATCH] D32724: [Modules] Include the enabled sanitizers in the module hash

2017-05-09 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In https://reviews.llvm.org/D32724#750074, @vsk wrote:

> In https://reviews.llvm.org/D32724#749868, @dexonsmith wrote:
>
> > In https://reviews.llvm.org/D32724#747728, @aprantl wrote:
> >
> > > Is it the right solution to use the module hash for correctness, or 
> > > should the mismatch of the serialized langopts trigger a module rebuild 
> > > and the module hash is only there to tune the performance/disk size 
> > > tradeoff?
> >
> >
> > I'm not sure if there is (or should be) a hard-and-fast rule, but certainly 
> > in this case changing the hash SGTM.  Otherwise, users toggling back and 
> > forth between build configurations would have to rebuild the modules each 
> > time.
>
>
> Great, it looks like changing the module hash is acceptable. However, I'm not 
> sure whether it's OK to make sanitizer feature mismatches errors for explicit 
> modules. @aprantl suggests checking for language option mismatches early on 
> instead of just relying on the module hash, but @rsmith mentioned:
>
> > I would expect this [sanitizer features] to be permitted to differ between 
> > an explicit module build and its use. (Ideally we would apply the 
> > sanitization settings from the module build to the code generated for its 
> > inline functions in that case, but that can wait.)


Ah, interesting.  That does seem ideal.

> Should we diagnose sanitizer feature mismatches in ASTReader 
> (checkLanguageOptions) as warnings, errors, or not at all?

Either warning or error seems fine with me; only compiler engineers are going 
to see this anyway (because implicit users are protected by the hash).  As long 
as it's overridable... there's a -cc1 flag to allow configuration mismatches, 
right?

Once the flag can be changed after the fact (i.e., in a post-Richard's-plan 
world), we should remove the error/warning, and possibly do something like: 
always build the module without sanitizers.


https://reviews.llvm.org/D32724



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


[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/Sema/Sema.h:1464
 
+  /// Determine if \p D abd \p Suggested have a structurally compatibale
+  /// layout as described in C11 6.2.7/1.

rsmith wrote:
> Typo 'abd'
Typo 'compatibale' =)



Comment at: lib/Parse/ParseDecl.cpp:4307
+Decl *D = SkipBody.CheckSameAsPrevious ? SkipBody.New : TagDecl;
+//ParseEnumBody(StartLoc, D);
+ParseEnumBody(StartLoc, D,

Commented-out code, please remove.



Comment at: lib/Parse/ParseDecl.cpp:4313-4321
+if (SkipBody.CheckSameAsPrevious) {
+  if (!Actions.hasStructuralCompatLayout(TagDecl, SkipBody.New)) {
+// Bail out.
+DS.SetTypeSpecError();
+return;
+  }
+  // Make the previous decl visible.

The parser shouldn't be doing this itself, please move this to a function on 
`Sema` (`ActOnDuplicateDefinition` or something) and call that from here.



Comment at: lib/Sema/SemaExpr.cpp:2198-2209
+  if (R.isAmbiguous()) {
+if (!IgnorePrevDef)
+  return ExprError();
+// We already know that there's a hidden decl included in the lookup,
+// ignore it and only use the first found (the local) one...
+auto RF = R.makeFilter();
+NamedDecl *ND = R.getRepresentativeDecl();

bruno wrote:
> rsmith wrote:
> > This is gross. In order to make this work, you'd need to propagate the 
> > `IgnorePrevDef` flag through the entire expression parsing machinery.
> > 
> > Instead of this, how about deferring making the old definition visible 
> > until after you complete parsing the new one and do the structural 
> > comparison?
> Thanks for pointing it out, I totally missed this approach. Your suggestion 
> works and I'll change the patch accordingly. However, `IgnorePrevDef` still 
> needs to be threaded in `ParseEnumBody` and `ActOnEnumConstant` in order to 
> prevent the latter to emit `err_redefinition_of_enumerator`-like diagnostics.
I think the problem is that we don't take module visibility into account when 
doing redefinition checking for enumerators. Instead of passing through this 
flag, we should probably just ignore hidden declarations when checking for a 
redefinition of an enumerator.


https://reviews.llvm.org/D31778



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


[PATCH] D32724: [Modules] Include the enabled sanitizers in the module hash

2017-05-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

In https://reviews.llvm.org/D32724#749868, @dexonsmith wrote:

> In https://reviews.llvm.org/D32724#747728, @aprantl wrote:
>
> > Is it the right solution to use the module hash for correctness, or should 
> > the mismatch of the serialized langopts trigger a module rebuild and the 
> > module hash is only there to tune the performance/disk size tradeoff?
>
>
> I'm not sure if there is (or should be) a hard-and-fast rule, but certainly 
> in this case changing the hash SGTM.  Otherwise, users toggling back and 
> forth between build configurations would have to rebuild the modules each 
> time.


Great, it looks like changing the module hash is acceptable. However, I'm not 
sure whether it's OK to make sanitizer feature mismatches errors for explicit 
modules. @aprantl suggests checking for language option mismatches early on 
instead of just relying on the module hash, but @rsmith mentioned:

> I would expect this [sanitizer features] to be permitted to differ between an 
> explicit module build and its use. (Ideally we would apply the sanitization 
> settings from the module build to the code generated for its inline functions 
> in that case, but that can wait.)

Should we diagnose sanitizer feature mismatches in ASTReader 
(checkLanguageOptions) as warnings, errors, or not at all?


https://reviews.llvm.org/D32724



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


[PATCH] D32828: [Modules] Fix conservative assertion for import diagnostics

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaLookup.cpp:4971-4972
   assert(Owner && "definition of hidden declaration is not in a module");
+  assert((!isVisible(Decl) || VisibleModules.isVisible(Owner)) &&
+ "missing import for non-hidden decl?");
 

`Decl` could also now be visible due to its lexically-enclosing context having 
a visible merged definition. I think this assertion should either be removed or 
changed to something like
```
assert(!isVisible(Decl) || );
```


https://reviews.llvm.org/D32828



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


r302569 - [WebAssembly] Fix failing wasm-toolchain test

2017-05-09 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Tue May  9 13:44:23 2017
New Revision: 302569

URL: http://llvm.org/viewvc/llvm-project?rev=302569=rev
Log:
[WebAssembly] Fix failing wasm-toolchain test

This test was broken in r302558.

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

Modified:
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=302569=302568=302569=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Tue May  9 13:44:23 2017
@@ -27,18 +27,18 @@
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "ld" "-L/foo/lib32" "crt1.o" "crti.o" "[[temp]]" 
"-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib32" "crt1.o" "crti.o" 
"[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
 
 // A basic C link command-line with optimization. WebAssembly is somewhat
 // special in enabling --gc-sections by default.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "ld" "--gc-sections" "-L/foo/lib32" "crt1.o" 
"crti.o" "[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "--gc-sections" "-L/foo/lib32" 
"crt1.o" "crti.o" "[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
 
 // Ditto, but ensure that a user --no-gc-sections comes after the
 // default --gc-sections.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -Wl,--no-gc-sections %s 2>&1 | FileCheck 
-check-prefix=NO_GC_SECTIONS %s
 // NO_GC_SECTIONS: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// NO_GC_SECTIONS: lld{{.*}}" "-flavor" "ld" "--gc-sections" "-L/foo/lib32" 
"crt1.o" "crti.o" "--no-gc-sections" "[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" 
"-o" "a.out"
+// NO_GC_SECTIONS: lld{{.*}}" "-flavor" "wasm" "--gc-sections" "-L/foo/lib32" 
"crt1.o" "crti.o" "--no-gc-sections" "[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" 
"-o" "a.out"


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


[PATCH] D29951: Load lazily the template specialization in multi-module setups.

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Serialization/ASTReaderDecl.cpp:213-215
+  assert(isa(D) ||
+ isa(D) &&
+ "Decl doesn't have specializations.");

Can this ever fail at runtime? I'd expect the below code to not compile if `D` 
isn't one of these types.



Comment at: lib/Serialization/ASTReaderDecl.cpp:3911-3924
+case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: {
+  // It will be added to the template's lazy specialization set when 
loaded.
+  SmallVector SpecID;
+  SpecID.push_back(ReadDeclID());
+  if (auto *CTD = dyn_cast(D))
+AddLazySpecializations(CTD, SpecID);
+  else if (auto *FTD = dyn_cast(D))

This will end up being quadratic time and using quadratic storage if a module 
adds N specializations to a template; instead, please move the SmallVector out 
of the loop and call `AddLazySpecializations` once after reading all the update 
records for the declaration. (It's probably best to move it all the way out to 
`loadDeclUpdateRecords`, in case we have a large number of modules each adding 
some specializations -- eg, if module A imports std::vector and declares A, 
module B declares B and uses vector, module C declares C and uses vector, 
..., we again should avoid quadratic behavior.)


https://reviews.llvm.org/D29951



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


[PATCH] D29951: Load lazily the template specialization in multi-module setups.

2017-05-09 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 98333.
v.g.vassilev marked an inline comment as done.
v.g.vassilev added a comment.

Reduce code duplication. Use llvm_unreachable.


https://reviews.llvm.org/D29951

Files:
  lib/Serialization/ASTReaderDecl.cpp

Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -206,6 +206,30 @@
 DeclContext *DC);
 FindExistingResult findExisting(NamedDecl *D);
 
+template 
+void AddLazySpecializations(T *D,
+SmallVectorImpl& IDs) {
+  assert(!IDs.empty() && "no IDs to add to list");
+  assert(isa(D) ||
+ isa(D) &&
+ "Decl doesn't have specializations.");
+
+  auto *CommonPtr = D->getCommonPtr();
+  ASTContext  = Reader.getContext();
+
+  if (auto  = CommonPtr->LazySpecializations) {
+IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
+std::sort(IDs.begin(), IDs.end());
+IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
+  }
+
+  auto *Result = new (C) DeclID[1 + IDs.size()];
+  *Result = IDs.size();
+  std::copy(IDs.begin(), IDs.end(), Result + 1);
+
+  CommonPtr->LazySpecializations = Result;
+}
+
   public:
 ASTDeclReader(ASTReader , ASTRecordReader ,
   ASTReader::RecordLocation Loc,
@@ -1951,21 +1975,6 @@
   return Redecl;
 }
 
-static DeclID *newDeclIDList(ASTContext , DeclID *Old,
- SmallVectorImpl ) {
-  assert(!IDs.empty() && "no IDs to add to list");
-  if (Old) {
-IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
-std::sort(IDs.begin(), IDs.end());
-IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
-  }
-
-  auto *Result = new (Context) DeclID[1 + IDs.size()];
-  *Result = IDs.size();
-  std::copy(IDs.begin(), IDs.end(), Result + 1);
-  return Result;
-}
-
 void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) {
   RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
 
@@ -1975,11 +1984,8 @@
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
 
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+if (!SpecIDs.empty())
+  AddLazySpecializations(D, SpecIDs);
   }
 
   if (D->getTemplatedDecl()->TemplateOrInstantiation) {
@@ -2007,11 +2013,8 @@
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
 
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+if (!SpecIDs.empty())
+  AddLazySpecializations(D, SpecIDs);
   }
 }
 
@@ -2118,11 +2121,8 @@
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
 
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+if (!SpecIDs.empty())
+  AddLazySpecializations(D, SpecIDs);
   }
 }
 
@@ -3908,9 +3908,19 @@
   break;
 }
 
-case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION:
-  // It will be added to the template's specializations set when loaded.
-  (void)Record.readDecl();
+case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: {
+  // It will be added to the template's lazy specialization set when loaded.
+  SmallVector SpecID;
+  SpecID.push_back(ReadDeclID());
+  if (auto *CTD = dyn_cast(D))
+AddLazySpecializations(CTD, SpecID);
+  else if (auto *FTD = dyn_cast(D))
+AddLazySpecializations(FTD, SpecID);
+  else if (auto *VTD = dyn_cast(D))
+AddLazySpecializations(VTD, SpecID);
+  else // TypeAliasTemplateDecl
+llvm_unreachable("TypeAliasTemplateDecl doesn't have specs!");
+}
   break;
 
 case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Dan Beam via Phabricator via cfe-commits
danbeam added inline comments.



Comment at: lib/Format/UnwrappedLineParser.cpp:2353
+  // expressions?
+  if (Line->Tokens.size() < 5)
+return false;

mprobst wrote:
> There's a `startsSequenceInternal` on `Line` that might come in handy here?
it wasn't on `Line` and unfortunately some of the state that `startsSequence` 
relies on isn't set up yet (at least as far as I know, I'm in a foreign land)



Comment at: lib/Format/UnwrappedLineParser.cpp:2362
+  ++I;
+  if (I->Tok->isNot(tok::l_paren))
+return false;

mprobst wrote:
> One more - do we want to support IIFEs that take arguments?
> 
> 
> ```
> (function(global) {
>   ...
> }(window));
> ```
"Less is more"



Comment at: unittests/Format/FormatTestJS.cpp:371
+TEST_F(FormatTestJS, IIFE) {
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"

mprobst wrote:
> consider adding a test with comments between the tokens (which should work 
> with `startsSequence`).
not done yet, but seems uncommon.

do you want me to add a FIXME?


https://reviews.llvm.org/D32989



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


[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Dan Beam via Phabricator via cfe-commits
danbeam updated this revision to Diff 98332.
danbeam marked 4 inline comments as done.
danbeam added a comment.

mprobst@ review


https://reviews.llvm.org/D32989

Files:
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -367,6 +367,25 @@
"});");
 }
 
+TEST_F(FormatTestJS, IIFEs) {
+  // Internal calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"
+   "}())");
+  // External calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var b = 2;\n"
+   "})()");
+  // Internal calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var c = 3;\n"
+   "}());");
+  // External calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var d = 4;\n"
+   "})();");
+}
+
 TEST_F(FormatTestJS, GoogModules) {
   verifyFormat("goog.module('this.is.really.absurdly.long');",
getGoogleJSStyleWithColumns(40));
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -476,6 +476,24 @@
   return I->Tok->is(tok::l_paren);
 }
 
+static bool isIIFE(const UnwrappedLine ,
+   const AdditionalKeywords ) {
+  // Look for the start of an immediately invoked anonymous function.
+  // https://en.wikipedia.org/wiki/Immediately-invoked_function_expression
+  // This is commonly done in JavaScript to create a new, anonymous scope.
+  // Example: (function() { ... })()
+  if (Line.Tokens.size() < 3)
+return false;
+  auto I = Line.Tokens.begin();
+  if (I->Tok->isNot(tok::l_paren))
+return false;
+  ++I;
+  if (I->Tok->isNot(Keywords.kw_function))
+return false;
+  ++I;
+  return I->Tok->is(tok::l_paren);
+}
+
 static bool ShouldBreakBeforeBrace(const FormatStyle ,
const FormatToken ) {
   if (InitialToken.is(tok::kw_namespace))
@@ -493,15 +511,16 @@
   FormatTok->BlockKind = BK_Block;
   nextToken();
   {
-bool GoogScope =
-Style.Language == FormatStyle::LK_JavaScript && isGoogScope(*Line);
+bool SkipIndent =
+(Style.Language == FormatStyle::LK_JavaScript &&
+ (isGoogScope(*Line) || isIIFE(*Line, Keywords)));
 ScopedLineState LineState(*this);
 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
 /*MustBeDeclaration=*/false);
-Line->Level += GoogScope ? 0 : 1;
+Line->Level += SkipIndent ? 0 : 1;
 parseLevel(/*HasOpeningBrace=*/true);
 flushComments(isOnNewLine(*FormatTok));
-Line->Level -= GoogScope ? 0 : 1;
+Line->Level -= SkipIndent ? 0 : 1;
   }
   nextToken();
 }


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -367,6 +367,25 @@
"});");
 }
 
+TEST_F(FormatTestJS, IIFEs) {
+  // Internal calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"
+   "}())");
+  // External calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var b = 2;\n"
+   "})()");
+  // Internal calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var c = 3;\n"
+   "}());");
+  // External calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var d = 4;\n"
+   "})();");
+}
+
 TEST_F(FormatTestJS, GoogModules) {
   verifyFormat("goog.module('this.is.really.absurdly.long');",
getGoogleJSStyleWithColumns(40));
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -476,6 +476,24 @@
   return I->Tok->is(tok::l_paren);
 }
 
+static bool isIIFE(const UnwrappedLine ,
+   const AdditionalKeywords ) {
+  // Look for the start of an immediately invoked anonymous function.
+  // https://en.wikipedia.org/wiki/Immediately-invoked_function_expression
+  // This is commonly done in JavaScript to create a new, anonymous scope.
+  // Example: (function() { ... })()
+  if (Line.Tokens.size() < 3)
+return false;
+  auto I = Line.Tokens.begin();
+  if (I->Tok->isNot(tok::l_paren))
+return false;
+  ++I;
+  if (I->Tok->isNot(Keywords.kw_function))
+return false;
+  ++I;
+  return I->Tok->is(tok::l_paren);
+}
+
 static bool ShouldBreakBeforeBrace(const FormatStyle ,
const FormatToken ) {
   if (InitialToken.is(tok::kw_namespace))
@@ -493,15 +511,16 @@
   

[PATCH] D24933: Enable configuration files in clang

2017-05-09 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 98330.
sepavloff added a comment.
Herald added subscribers: krytarowski, rengolin.

Updated patch


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
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Tooling/Tooling.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-errs.c
  test/Driver/config-file.c
  test/Driver/config-file2.c
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -199,23 +199,19 @@
 extern int cc1as_main(ArrayRef Argv, const char *Argv0,
   void *MainAddr);
 
-static void insertTargetAndModeArgs(StringRef Target, StringRef Mode,
+static void insertTargetAndModeArgs(const ParsedClangName ,
 SmallVectorImpl ,
 std::set ) {
-  if (!Mode.empty()) {
+  if (!NameParts.ModeSuffix.empty()) {
 // Add the mode flag to the arguments.
-auto it = ArgVector.begin();
-if (it != ArgVector.end())
-  ++it;
-ArgVector.insert(it, GetStableCStr(SavedStrings, Mode));
+ArgVector.insert(ArgVector.end(),
+ GetStableCStr(SavedStrings, NameParts.ModeSuffix));
   }
 
-  if (!Target.empty()) {
-auto it = ArgVector.begin();
-if (it != ArgVector.end())
-  ++it;
-const char *arr[] = {"-target", GetStableCStr(SavedStrings, Target)};
-ArgVector.insert(it, std::begin(arr), std::end(arr));
+  if (NameParts.TargetIsValid) {
+const char *arr[] = {"-target", GetStableCStr(SavedStrings,
+  NameParts.TargetPrefix)};
+ArgVector.insert(ArgVector.end(), std::begin(arr), std::end(arr));
   }
 }
 
@@ -323,9 +319,7 @@
   }
 
   llvm::InitializeAllTargets();
-  std::string ProgName = argv[0];
-  std::pair TargetAndMode =
-  ToolChain::getTargetAndModeFromProgramName(ProgName);
+  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(argv[0]);
 
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
@@ -338,7 +332,7 @@
   // Finally, our -cc1 tools don't care which tokenization mode we use because
   // response files written by clang will tokenize the same way in either mode.
   bool ClangCLMode = false;
-  if (TargetAndMode.second == "--driver-mode=cl" ||
+  if (TargetAndMode.ModeSuffix == "--driver-mode=cl" ||
   std::find_if(argv.begin(), argv.end(), [](const char *F) {
 return F && strcmp(F, "--driver-mode=cl") == 0;
   }) != argv.end()) {
@@ -447,9 +441,9 @@
 
   Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags);
   SetInstallDir(argv, TheDriver, CanonicalPrefixes);
+  TheDriver.setTargetAndMode(TargetAndMode);
 
-  insertTargetAndModeArgs(TargetAndMode.first, TargetAndMode.second, argv,
-  SavedStrings);
+  insertTargetAndModeArgs(TargetAndMode, argv, SavedStrings);
 
   SetBackdoorDriverOutputsFromEnvVars(TheDriver);
 
@@ -491,7 +485,6 @@
   }
 }
   }
-
   Diags.getClient()->finish();
 
   // If any timers were active but haven't been destroyed yet, print their
Index: test/Driver/config-file2.c
===
--- /dev/null
+++ test/Driver/config-file2.c
@@ -0,0 +1,107 @@
+// REQUIRES: shell
+
+//--- Invocation qqq-clang tries to find config file qqq.cfg
+//
+// RUN: mkdir -p %T/testbin
+// RUN: [ ! -s %T/testbin/qqq-clang ] || rm %T/testbin/qqq-clang
+// RUN: ln -s %clang %T/testbin/qqq-clang
+// RUN: echo "-Wundefined-func-template" > %T/testbin/qqq.cfg
+//
+// RUN: %T/testbin/qqq-clang -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s
+//
+// CHECK: Configuration file: {{.*}}/testbin/qqq.cfg
+// CHECK: -Wundefined-func-template
+
+
+//--- Config files are searched for in binary directory as well.
+//
+// RUN: [ ! -s %T/testbin/clang ] || rm %T/testbin/clang
+// RUN: ln -s %clang %T/testbin/clang
+// RUN: echo "-Werror" > %T/testbin/aaa.cfg
+//
+// RUN: %T/testbin/clang --config aaa.cfg -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-BIN
+//
+// CHECK-BIN: Configuration file: {{.*}}/testbin/aaa.cfg
+// CHECK-BIN: -Werror
+
+
+//--- If config file is specified by relative path (workdir/cfg-s2), it is searched for by
+//that path.
+//
+// RUN: mkdir -p %T/workdir
+// RUN: echo "@subdir/cfg-s2" > %T/workdir/cfg-1
+// RUN: mkdir -p %T/workdir/subdir
+// RUN: echo "-Wundefined-var-template" > %T/workdir/subdir/cfg-s2
+//
+// RUN: ( cd %T 

[PATCH] D33013: Driver must return non-zero code on errors in command line

2017-05-09 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
Herald added subscribers: krytarowski, javed.absar, nhaehnle, rengolin, 
aemerson.

Now if clang driver is given wrong arguments, in some cases it
continues execution and returns zero code. This change fixes this
behavior.

The fix revealed some errors in clang test set.

File test/Driver/gfortran.f90 added in r118203 checks forwarding
gfortran flags to GCC. Now driver reports error on this file, because
the option -working-directory implemented in clang differs from the
option with the same name implemented in gfortran, in clang the option
requires argument, in gfortran does not.

In the file test/Driver/arm-darwin-builtin.c clang is called with
options -fbuiltin-strcat and -fbuiltin-strcpy. These option were removed
in r191435 and now clang reports error on this test.

File arm-default-build-attributes.s uses option -verify, which is not
supported by driver, it is cc1 option.

Similarly, the file split-debug.h uses options -fmodules-embed-all-files
and -fmodule-format=obj, which are not supported by driver.

Other revealed errors are mainly mistypes.


https://reviews.llvm.org/D33013

Files:
  lib/Driver/Driver.cpp
  test/Driver/aarch64-cpus.c
  test/Driver/amdgpu-features.c
  test/Driver/arm-darwin-builtin.c
  test/Driver/arm-default-build-attributes.s
  test/Driver/cl-outputs.c
  test/Driver/clang_f_opts.c
  test/Driver/debug-options.c
  test/Driver/gfortran.f90
  test/Driver/split-debug.h
  test/Driver/unknown-arg.c
  test/Index/index-attrs.c
  test/Index/index-attrs.cpp
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -454,40 +454,41 @@
   SetBackdoorDriverOutputsFromEnvVars(TheDriver);
 
   std::unique_ptr C(TheDriver.BuildCompilation(argv));
-  int Res = 0;
-  SmallVector, 4> FailingCommands;
-  if (C.get())
+  int Res = 1;
+  if (C.get()) {
+SmallVector, 4> FailingCommands;
 Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
 
-  // Force a crash to test the diagnostics.
-  if (TheDriver.GenReproducer) {
-Diags.Report(diag::err_drv_force_crash)
+// Force a crash to test the diagnostics.
+if (TheDriver.GenReproducer) {
+  Diags.Report(diag::err_drv_force_crash)
 << !::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH");
 
-// Pretend that every command failed.
-FailingCommands.clear();
-for (const auto  : C->getJobs())
-  if (const Command *C = dyn_cast())
-FailingCommands.push_back(std::make_pair(-1, C));
-  }
+  // Pretend that every command failed.
+  FailingCommands.clear();
+  for (const auto  : C->getJobs())
+if (const Command *C = dyn_cast())
+  FailingCommands.push_back(std::make_pair(-1, C));
+}
 
-  for (const auto  : FailingCommands) {
-int CommandRes = P.first;
-const Command *FailingCommand = P.second;
-if (!Res)
-  Res = CommandRes;
-
-// If result status is < 0, then the driver command signalled an error.
-// If result status is 70, then the driver command reported a fatal error.
-// On Windows, abort will return an exit code of 3.  In these cases,
-// generate additional diagnostic information if possible.
-bool DiagnoseCrash = CommandRes < 0 || CommandRes == 70;
+for (const auto  : FailingCommands) {
+  int CommandRes = P.first;
+  const Command *FailingCommand = P.second;
+  if (!Res)
+Res = CommandRes;
+
+  // If result status is < 0, then the driver command signalled an error.
+  // If result status is 70, then the driver command reported a fatal error.
+  // On Windows, abort will return an exit code of 3.  In these cases,
+  // generate additional diagnostic information if possible.
+  bool DiagnoseCrash = CommandRes < 0 || CommandRes == 70;
 #ifdef LLVM_ON_WIN32
-DiagnoseCrash |= CommandRes == 3;
+  DiagnoseCrash |= CommandRes == 3;
 #endif
-if (DiagnoseCrash) {
-  TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);
-  break;
+  if (DiagnoseCrash) {
+TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);
+break;
+  }
 }
   }
 
Index: test/Index/index-attrs.cpp
===
--- test/Index/index-attrs.cpp
+++ test/Index/index-attrs.cpp
@@ -1,4 +1,4 @@
-// RUN: c-index-test -index-file -check-prefix CHECK %s -target armv7-windows-gnu -fdeclspec
+// RUN: c-index-test -index-file %s -target armv7-windows-gnu -fdeclspec | FileCheck %s
 
 struct __declspec(dllexport) export_s {
   void m();
@@ -19,32 +19,32 @@
 class __attribute__((dllexport)) export_gnu_s {
   void m();
 };
-// CHECK: [indexDeclaration]: kind: struct | name: export_gnu_s | {{.*}} | lang: C++
+// CHECK: [indexDeclaration]: kind: c++-class | name: export_gnu_s | {{.*}} | lang: C++
 // CHECK: : 

[PATCH] D29951: Load lazily the template specialization in multi-module setups.

2017-05-09 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: lib/Serialization/ASTReaderDecl.cpp:3814
+  } else // TypeAliasTemplateDecl
+assert(0 && "TypeAliasTemplateDecl doesn't have specs!");
+}

llvm_unreachable()


Repository:
  rL LLVM

https://reviews.llvm.org/D29951



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


[PATCH] D32898: [OpenCL] Handle OpenCL specific subelement types

2017-05-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added inline comments.
This revision is now accepted and ready to land.



Comment at: test/SemaOpenCL/array-init.cl:4
+
+__kernel void k2(queue_t q1, queue_t q2) {
+  queue_t q[] = {q1, q2};

Minor thing - I would use sequential numeration of kernel names i.e. k1, k2, 
k3...


https://reviews.llvm.org/D32898



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


[PATCH] D32897: [OpenCL] Added checking OpenCL version for cl_khr_mipmap_image built-ins

2017-05-09 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! It's a pity we are not testing anything here.


https://reviews.llvm.org/D32897



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


[PATCH] D32896: [OpenCL] Make CLK_NULL_RESERVE_ID invalid reserve id.

2017-05-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Headers/opencl-c.h:16020
+// The macro CLK_NULL_RESERVE_ID refers to an invalid reservation ID.
+#define CLK_NULL_RESERVE_ID (__builtin_astype((void *)0, reserve_id_t))
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);

Looks good from my side.

@yaxunl , since you originally committed this. Could you please verify that 
changing from `SIZE_MAX` to `0` would be fine.

Btw, we have a similar definition for `CLK_NULL_EVENT`.


https://reviews.llvm.org/D32896



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


r302559 - [X86][LWP] Remove MSVC LWP intrinsics stubs.

2017-05-09 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue May  9 12:50:16 2017
New Revision: 302559

URL: http://llvm.org/viewvc/llvm-project?rev=302559=rev
Log:
[X86][LWP] Remove MSVC LWP intrinsics stubs.

Now provided in lwpintrin.h

Modified:
cfe/trunk/lib/Headers/intrin.h

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=302559=302558=302559=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Tue May  9 12:50:16 2017
@@ -85,9 +85,6 @@ void __inwordstring(unsigned short, unsi
 void __lidt(void *);
 unsigned __int64 __ll_lshift(unsigned __int64, int);
 __int64 __ll_rshift(__int64, int);
-void __llwpcb(void *);
-unsigned char __lwpins32(unsigned int, unsigned int, unsigned int);
-void __lwpval32(unsigned int, unsigned int, unsigned int);
 unsigned int __lzcnt(unsigned int);
 unsigned short __lzcnt16(unsigned short);
 static __inline__
@@ -126,7 +123,6 @@ unsigned __int64 __readmsr(unsigned long
 unsigned __int64 __readpmc(unsigned long);
 unsigned long __segmentlimit(unsigned long);
 void __sidt(void *);
-void *__slwpcb(void);
 static __inline__
 void __stosb(unsigned char *, unsigned char, size_t);
 static __inline__
@@ -227,8 +223,6 @@ void __incgsbyte(unsigned long);
 void __incgsdword(unsigned long);
 void __incgsqword(unsigned long);
 void __incgsword(unsigned long);
-unsigned char __lwpins64(unsigned __int64, unsigned int, unsigned int);
-void __lwpval64(unsigned __int64, unsigned int, unsigned int);
 unsigned __int64 __lzcnt64(unsigned __int64);
 static __inline__
 void __movsq(unsigned long long *, unsigned long long const *, size_t);


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


r302558 - [WebAssembly] Fix location and -flavor when running lld

2017-05-09 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Tue May  9 12:47:50 2017
New Revision: 302558

URL: http://llvm.org/viewvc/llvm-project?rev=302558=rev
Log:
[WebAssembly] Fix location and -flavor when running lld

Add the toolchain installation directory to the program
path so that lld can be found.

Change -flavor to wasm.  Although this new flavor hasn't
yet landed in upstream lld yet there are no point in
passing wasm objects the gnu flavor.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=302558=302557=302558=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Tue May  9 12:47:50 2017
@@ -42,7 +42,7 @@ void wasm::Linker::ConstructJob(Compilat
   const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
   ArgStringList CmdArgs;
   CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("ld");
+  CmdArgs.push_back("wasm");
 
   // Enable garbage collection of unused input sections by default, since code
   // size is of particular importance. This is significantly facilitated by
@@ -101,6 +101,9 @@ WebAssembly::WebAssembly(const Driver 
   : ToolChain(D, Triple, Args) {
 
   assert(Triple.isArch32Bit() != Triple.isArch64Bit());
+
+  getProgramPaths().push_back(getDriver().getInstalledDir());
+
   getFilePaths().push_back(
   getDriver().SysRoot + "/lib" + (Triple.isArch32Bit() ? "32" : "64"));
 }


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


r302557 - [X86][LWP] Removing LWP todo comment. NFCI.

2017-05-09 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue May  9 12:43:16 2017
New Revision: 302557

URL: http://llvm.org/viewvc/llvm-project?rev=302557=rev
Log:
[X86][LWP] Removing LWP todo comment. NFCI.

LWP / lwpintrin.h is now supported

Modified:
cfe/trunk/lib/Headers/x86intrin.h

Modified: cfe/trunk/lib/Headers/x86intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/x86intrin.h?rev=302557=302556=302557=diff
==
--- cfe/trunk/lib/Headers/x86intrin.h (original)
+++ cfe/trunk/lib/Headers/x86intrin.h Tue May  9 12:43:16 2017
@@ -88,6 +88,4 @@
 #include 
 #endif
 
-/* FIXME: LWP */
-
 #endif /* __X86INTRIN_H */


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


r302556 - Build the Apple-style stage2 with modules

2017-05-09 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue May  9 12:27:03 2017
New Revision: 302556

URL: http://llvm.org/viewvc/llvm-project?rev=302556=rev
Log:
Build the Apple-style stage2 with modules

Green dragon had a green stage2 modules bot for a long time now[1] and
it is time to retire it and make a modules build the default for
Apple-style stage2 builds.

This patch turns on LLVM_ENABLE_MODULES.

[1] http://green.lab.llvm.org/green/job/clang-stage2-cmake-modulesRDA_build/
rdar://problem/28672159

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

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=302556=302555=302556=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Tue May  9 12:27:03 2017
@@ -13,6 +13,7 @@ set(CLANG_LINKS_TO_CREATE clang++ cc c++
 set(CMAKE_MACOSX_RPATH ON CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/; CACHE STRING "")


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


[PATCH] D32603: Build the Apple-style stage2 with modules and full debug info

2017-05-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302556: Build the Apple-style stage2 with modules (authored 
by adrian).

Changed prior to commit:
  https://reviews.llvm.org/D32603?vs=96952=98320#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32603

Files:
  cfe/trunk/cmake/caches/Apple-stage2.cmake


Index: cfe/trunk/cmake/caches/Apple-stage2.cmake
===
--- cfe/trunk/cmake/caches/Apple-stage2.cmake
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake
@@ -13,6 +13,7 @@
 set(CMAKE_MACOSX_RPATH ON CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/; CACHE STRING "")


Index: cfe/trunk/cmake/caches/Apple-stage2.cmake
===
--- cfe/trunk/cmake/caches/Apple-stage2.cmake
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake
@@ -13,6 +13,7 @@
 set(CMAKE_MACOSX_RPATH ON CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/; CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r302547 - [mips] Impose a threshold for coercion of aggregates

2017-05-09 Thread Petar Jovanovic via cfe-commits
Reverted in r302555.

From: hwennb...@google.com [hwennb...@google.com] on behalf of Hans Wennborg 
[h...@chromium.org]
Sent: Tuesday, May 09, 2017 7:18 PM
To: Petar Jovanovic
Cc: cfe-commits
Subject: Re: r302547 - [mips] Impose a threshold for coercion of aggregates

On Tue, May 9, 2017 at 9:24 AM, Petar Jovanovic via cfe-commits
 wrote:
> Author: petarj
> Date: Tue May  9 11:24:03 2017
> New Revision: 302547
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302547=rev
> Log:
> [mips] Impose a threshold for coercion of aggregates
>
> Modified MipsABIInfo::classifyArgumentType so that it now coerces aggregate
> structures only if the size of said aggregate is less than 16/64 bytes,
> depending on the ABI.
>
> Patch by Stefan Maksimovic.
>
> Differential Revision: https://reviews.llvm.org/D32900
>
> Added:
> cfe/trunk/test/CodeGen/mips-aggregate-arg.c
> Modified:
> cfe/trunk/lib/CodeGen/TargetInfo.cpp

Looks like a test is failing due to this:
http://bb.pgr.jp/builders/test-clang-x86_64-linux-R/builds/1932/steps/test_clang/logs/Clang%20%3A%3A%20CodeGen__mips-aggregate-arg.c
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302555 - Revert r302547 ([mips] Impose a threshold for coercion of aggregates)

2017-05-09 Thread Petar Jovanovic via cfe-commits
Author: petarj
Date: Tue May  9 12:20:06 2017
New Revision: 302555

URL: http://llvm.org/viewvc/llvm-project?rev=302555=rev
Log:
Revert r302547 ([mips] Impose a threshold for coercion of aggregates)

Reverting
  Modified MipsABIInfo::classifyArgumentType so that it now coerces
  aggregate structures only if the size of said aggregate is less than 16/64
  bytes, depending on the ABI.
as it broke clang-with-lto-ubuntu builder.

Removed:
cfe/trunk/test/CodeGen/mips-aggregate-arg.c
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=302555=302554=302555=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue May  9 12:20:06 2017
@@ -6695,14 +6695,6 @@ MipsABIInfo::classifyArgumentType(QualTy
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
-// Use indirect if the aggregate cannot fit into registers for
-// passing arguments according to the ABI
-unsigned Threshold = IsO32 ? 16 : 64;
-
-if(getContext().getTypeSizeInChars(Ty) > 
CharUnits::fromQuantity(Threshold))
-  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
- getContext().getTypeAlign(Ty) / 8 > 
Align);
-
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.

Removed: cfe/trunk/test/CodeGen/mips-aggregate-arg.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-aggregate-arg.c?rev=302554=auto
==
--- cfe/trunk/test/CodeGen/mips-aggregate-arg.c (original)
+++ cfe/trunk/test/CodeGen/mips-aggregate-arg.c (removed)
@@ -1,38 +0,0 @@
-// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | 
FileCheck -check-prefix=O32 %s
-// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n32 | FileCheck -check-prefix=N32-N64 %s
-// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n64 | FileCheck -check-prefix=N32-N64 %s
-
-struct t1 {
-  char t1[10];
-};
-
-struct t2 {
-  char t2[20];
-};
-
-struct t3 {
-  char t3[65];
-};
-
-extern struct t1 g1;
-extern struct t2 g2;
-extern struct t3 g3;
-extern void f1(struct t1);
-extern void f2(struct t2);
-extern void f3(struct t3);
-
-void f() {
-
-// O32:  call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7)
-// O32:  call void @f2(%struct.t2* byval align 4 %tmp)
-// O32:  call void @f3(%struct.t3* byval align 4 %tmp1)
-
-// N32-N64:  call void @f1(i64 inreg %3, i16 inreg %5)
-// N32-N64:  call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13)
-// N32-N64:  call void @f3(%struct.t3* byval align 8 %tmp)
-
-  f1(g1);
-  f2(g2);
-  f3(g3);
-}
-


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


[PATCH] D31269: [Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

This makes a lot of sense to me. See also r302463: I think we probably want 
three levels of shadowing here: the main input shadows -fmodule-map-file, which 
shadows module maps loaded implicitly. (There's also a question of what we do 
with module map information loaded from an AST file: currently when that 
happens, we ignore the tokens for the parsed module map entirely. It might make 
more sense to have the module loaded from the AST file shadow the module from 
the module map, especially for an explicit module build, now that we have that 
functionality.)




Comment at: lib/Lex/ModuleMap.cpp:2574-2575
 
+  llvm::SaveAndRestore OldExplicit(CurrentModuleMapIsExplicitlyProvided);
+  CurrentModuleMapIsExplicitlyProvided |= IsExplicitlyProvided;
+

It would seem cleaner to make this a member of `ModuleMapParser` (and 
explicitly pass down the flag when parsing an `extern module` declaration). Is 
there a reason to use (essentially) global state for this?


https://reviews.llvm.org/D31269



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


Re: r302547 - [mips] Impose a threshold for coercion of aggregates

2017-05-09 Thread Hans Wennborg via cfe-commits
On Tue, May 9, 2017 at 9:24 AM, Petar Jovanovic via cfe-commits
 wrote:
> Author: petarj
> Date: Tue May  9 11:24:03 2017
> New Revision: 302547
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302547=rev
> Log:
> [mips] Impose a threshold for coercion of aggregates
>
> Modified MipsABIInfo::classifyArgumentType so that it now coerces aggregate
> structures only if the size of said aggregate is less than 16/64 bytes,
> depending on the ABI.
>
> Patch by Stefan Maksimovic.
>
> Differential Revision: https://reviews.llvm.org/D32900
>
> Added:
> cfe/trunk/test/CodeGen/mips-aggregate-arg.c
> Modified:
> cfe/trunk/lib/CodeGen/TargetInfo.cpp

Looks like a test is failing due to this:
http://bb.pgr.jp/builders/test-clang-x86_64-linux-R/builds/1932/steps/test_clang/logs/Clang%20%3A%3A%20CodeGen__mips-aggregate-arg.c
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32724: [Modules] Include the enabled sanitizers in the module hash

2017-05-09 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In https://reviews.llvm.org/D32724#747728, @aprantl wrote:

> Is it the right solution to use the module hash for correctness, or should 
> the mismatch of the serialized langopts trigger a module rebuild and the 
> module hash is only there to tune the performance/disk size tradeoff?


I'm not sure if there is (or should be) a hard-and-fast rule, but certainly in 
this case changing the hash SGTM.  Otherwise, users toggling back and forth 
between build configurations would have to rebuild the modules each time.


https://reviews.llvm.org/D32724



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


[PATCH] D32499: Further delay calling DeclMustBeEmitted until it's safe.

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Let's go ahead with this. I've been unable to find a testcase that triggers the 
problem, but we shouldn't keep a known latent bug around just because we don't 
know how to expose it yet.


https://reviews.llvm.org/D32499



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


[PATCH] D32248: CodeGen: Cast alloca to expected address space

2017-05-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 98314.
yaxunl added a comment.

Revised by reviewers' comments.


https://reviews.llvm.org/D32248

Files:
  include/clang/AST/Type.h
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGen/address-space.c
  test/CodeGenCXX/amdgcn-automatic-variable.cpp
  test/CodeGenOpenCL/amdgcn-automatic-variable.cl

Index: test/CodeGenOpenCL/amdgcn-automatic-variable.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgcn-automatic-variable.cl
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL1.2 -triple amdgcn---amdgiz -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL12 %s
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn---amdgiz -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL20 %s
+
+// CL12-LABEL: define void @func1(i32 addrspace(5)* %x)
+// CL20-LABEL: define void @func1(i32* %x)
+void func1(int *x) {
+  // CL12: %[[x_addr:.*]] = alloca i32 addrspace(5)*{{.*}}addrspace(5)
+  // CL12: store i32 addrspace(5)* %x, i32 addrspace(5)* addrspace(5)* %[[x_addr]]
+  // CL12: %[[r0:.*]] = load i32 addrspace(5)*, i32 addrspace(5)* addrspace(5)* %[[x_addr]]
+  // CL12: store i32 1, i32 addrspace(5)* %[[r0]]
+  // CL20: %[[x_addr:.*]] = alloca i32*{{.*}}addrspace(5)
+  // CL20: store i32* %x, i32* addrspace(5)* %[[x_addr]]
+  // CL20: %[[r0:.*]] = load i32*, i32* addrspace(5)* %[[x_addr]]
+  // CL20: store i32 1, i32* %[[r0]]
+  *x = 1;
+}
+
+// CHECK-LABEL: define void @func2()
+void func2(void) {
+  // CHECK: %lv1 = alloca i32, align 4, addrspace(5)
+  // CHECK: %lv2 = alloca i32, align 4, addrspace(5)
+  // CHECK: %la = alloca [100 x i32], align 4, addrspace(5)
+  // CL12: %lp1 = alloca i32 addrspace(5)*, align 4, addrspace(5)
+  // CL12: %lp2 = alloca i32 addrspace(5)*, align 4, addrspace(5)
+  // CL20: %lp1 = alloca i32*, align 4, addrspace(5)
+  // CL20: %lp2 = alloca i32*, align 4, addrspace(5)
+  // CHECK: %lvc = alloca i32, align 4, addrspace(5)
+
+  // CHECK: store i32 1, i32 addrspace(5)* %lv1
+  int lv1;
+  lv1 = 1;
+  // CHECK: store i32 2, i32 addrspace(5)* %lv2
+  int lv2 = 2;
+
+  // CHECK: %[[arrayidx:.*]] = getelementptr inbounds [100 x i32], [100 x i32] addrspace(5)* %la, i64 0, i64 0
+  // CHECK: store i32 3, i32 addrspace(5)* %[[arrayidx]], align 4
+  int la[100];
+  la[0] = 3;
+
+  // CL12: store i32 addrspace(5)* %lv1, i32 addrspace(5)* addrspace(5)* %lp1, align 4
+  // CL20: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
+  // CL20: store i32* %[[r0]], i32* addrspace(5)* %lp1, align 4
+  int *lp1 = 
+
+  // CHECK: %[[arraydecay:.*]] = getelementptr inbounds [100 x i32], [100 x i32] addrspace(5)* %la, i32 0, i32 0
+  // CL12: store i32 addrspace(5)* %[[arraydecay]], i32 addrspace(5)* addrspace(5)* %lp2, align 4
+  // CL20: %[[r1:.*]] = addrspacecast i32 addrspace(5)* %[[arraydecay]] to i32*
+  // CL20: store i32* %[[r1]], i32* addrspace(5)* %lp2, align 4
+  int *lp2 = la;
+
+  // CL12: call void @func1(i32 addrspace(5)* %lv1)
+  // CL20: %[[r2:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
+  // CL20: call void @func1(i32* %[[r2]])
+  func1();
+
+  // CHECK: store i32 4, i32 addrspace(5)* %lvc
+  // CHECK: store i32 4, i32 addrspace(5)* %lv1
+  const int lvc = 4;
+  lv1 = lvc;
+}
Index: test/CodeGenCXX/amdgcn-automatic-variable.cpp
===
--- /dev/null
+++ test/CodeGenCXX/amdgcn-automatic-variable.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -O0 -triple amdgcn---amdgiz -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: define void @_Z5func1Pi(i32* %x)
+void func1(int *x) {
+  // CHECK: %[[x_addr:.*]] = alloca i32*{{.*}}addrspace(5)
+  // CHECK: store i32* %x, i32* addrspace(5)* %[[x_addr]]
+  // CHECK: %[[r0:.*]] = load i32*, i32* addrspace(5)* %[[x_addr]]
+  // CHECK: store i32 1, i32* %[[r0]]
+  *x = 1;
+}
+
+// CHECK-LABEL: define void @_Z5func2v()
+void func2(void) {
+  // CHECK: %lv1 = alloca i32, align 4, addrspace(5)
+  // CHECK: %lv2 = alloca i32, align 4, addrspace(5)
+  // CHECK: %la = alloca [100 x i32], align 4, addrspace(5)
+  // CHECK: %lp1 = alloca i32*, align 4, addrspace(5)
+  // CHECK: %lp2 = alloca i32*, align 4, addrspace(5)
+  // CHECK: %lvc = alloca i32, align 4, addrspace(5)
+
+  // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
+  // CHECK: store i32 1, i32* %[[r0]]
+  int lv1;
+  lv1 = 1;
+  // CHECK: store i32 2, i32 addrspace(5)* %lv2
+  int lv2 = 2;
+
+  // CHECK: %[[r2:.*]] = addrspacecast [100 x i32] addrspace(5)* %la to [100 x i32]*
+  // CHECK: %[[arrayidx:.*]] = getelementptr inbounds [100 x i32], [100 x i32]* %[[r2]], i64 0, i64 0
+  // CHECK: store i32 3, i32* %[[arrayidx]], align 4
+  int la[100];
+  la[0] = 3;
+
+  // CHECK: store i32* %[[r0]], i32* addrspace(5)* %lp1, align 4
+  int *lp1 = 
+
+  // CHECK: %[[arraydecay:.*]] = getelementptr inbounds [100 x i32], [100 x i32]* %[[r2]], i32 0, i32 

[PATCH] D31839: make -Winteger-overflow find overflows in function arguments

2017-05-09 Thread Nick Lewycky via Phabricator via cfe-commits
nlewycky added a comment.

Ping!


https://reviews.llvm.org/D31839



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


r302547 - [mips] Impose a threshold for coercion of aggregates

2017-05-09 Thread Petar Jovanovic via cfe-commits
Author: petarj
Date: Tue May  9 11:24:03 2017
New Revision: 302547

URL: http://llvm.org/viewvc/llvm-project?rev=302547=rev
Log:
[mips] Impose a threshold for coercion of aggregates

Modified MipsABIInfo::classifyArgumentType so that it now coerces aggregate
structures only if the size of said aggregate is less than 16/64 bytes,
depending on the ABI.

Patch by Stefan Maksimovic.

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

Added:
cfe/trunk/test/CodeGen/mips-aggregate-arg.c
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=302547=302546=302547=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue May  9 11:24:03 2017
@@ -6695,6 +6695,14 @@ MipsABIInfo::classifyArgumentType(QualTy
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
+// Use indirect if the aggregate cannot fit into registers for
+// passing arguments according to the ABI
+unsigned Threshold = IsO32 ? 16 : 64;
+
+if(getContext().getTypeSizeInChars(Ty) > 
CharUnits::fromQuantity(Threshold))
+  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
+ getContext().getTypeAlign(Ty) / 8 > 
Align);
+
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.

Added: cfe/trunk/test/CodeGen/mips-aggregate-arg.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-aggregate-arg.c?rev=302547=auto
==
--- cfe/trunk/test/CodeGen/mips-aggregate-arg.c (added)
+++ cfe/trunk/test/CodeGen/mips-aggregate-arg.c Tue May  9 11:24:03 2017
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | 
FileCheck -check-prefix=O32 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n32 | FileCheck -check-prefix=N32-N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n64 | FileCheck -check-prefix=N32-N64 %s
+
+struct t1 {
+  char t1[10];
+};
+
+struct t2 {
+  char t2[20];
+};
+
+struct t3 {
+  char t3[65];
+};
+
+extern struct t1 g1;
+extern struct t2 g2;
+extern struct t3 g3;
+extern void f1(struct t1);
+extern void f2(struct t2);
+extern void f3(struct t3);
+
+void f() {
+
+// O32:  call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7)
+// O32:  call void @f2(%struct.t2* byval align 4 %tmp)
+// O32:  call void @f3(%struct.t3* byval align 4 %tmp1)
+
+// N32-N64:  call void @f1(i64 inreg %3, i16 inreg %5)
+// N32-N64:  call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13)
+// N32-N64:  call void @f3(%struct.t3* byval align 8 %tmp)
+
+  f1(g1);
+  f2(g2);
+  f3(g3);
+}
+


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


[PATCH] D32900: [mips] Impose a threshold for coercion of aggregates

2017-05-09 Thread Petar Jovanovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302547: [mips] Impose a threshold for coercion of aggregates 
(authored by petarj).

Changed prior to commit:
  https://reviews.llvm.org/D32900?vs=98269=98304#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32900

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGen/mips-aggregate-arg.c


Index: cfe/trunk/test/CodeGen/mips-aggregate-arg.c
===
--- cfe/trunk/test/CodeGen/mips-aggregate-arg.c
+++ cfe/trunk/test/CodeGen/mips-aggregate-arg.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | 
FileCheck -check-prefix=O32 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n32 | FileCheck -check-prefix=N32-N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n64 | FileCheck -check-prefix=N32-N64 %s
+
+struct t1 {
+  char t1[10];
+};
+
+struct t2 {
+  char t2[20];
+};
+
+struct t3 {
+  char t3[65];
+};
+
+extern struct t1 g1;
+extern struct t2 g2;
+extern struct t3 g3;
+extern void f1(struct t1);
+extern void f2(struct t2);
+extern void f3(struct t3);
+
+void f() {
+
+// O32:  call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7)
+// O32:  call void @f2(%struct.t2* byval align 4 %tmp)
+// O32:  call void @f3(%struct.t3* byval align 4 %tmp1)
+
+// N32-N64:  call void @f1(i64 inreg %3, i16 inreg %5)
+// N32-N64:  call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13)
+// N32-N64:  call void @f3(%struct.t3* byval align 8 %tmp)
+
+  f1(g1);
+  f2(g2);
+  f3(g3);
+}
+
Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -6695,6 +6695,14 @@
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
+// Use indirect if the aggregate cannot fit into registers for
+// passing arguments according to the ABI
+unsigned Threshold = IsO32 ? 16 : 64;
+
+if(getContext().getTypeSizeInChars(Ty) > 
CharUnits::fromQuantity(Threshold))
+  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
+ getContext().getTypeAlign(Ty) / 8 > 
Align);
+
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.


Index: cfe/trunk/test/CodeGen/mips-aggregate-arg.c
===
--- cfe/trunk/test/CodeGen/mips-aggregate-arg.c
+++ cfe/trunk/test/CodeGen/mips-aggregate-arg.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=O32 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  -target-abi n32 | FileCheck -check-prefix=N32-N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  -target-abi n64 | FileCheck -check-prefix=N32-N64 %s
+
+struct t1 {
+  char t1[10];
+};
+
+struct t2 {
+  char t2[20];
+};
+
+struct t3 {
+  char t3[65];
+};
+
+extern struct t1 g1;
+extern struct t2 g2;
+extern struct t3 g3;
+extern void f1(struct t1);
+extern void f2(struct t2);
+extern void f3(struct t3);
+
+void f() {
+
+// O32:  call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7)
+// O32:  call void @f2(%struct.t2* byval align 4 %tmp)
+// O32:  call void @f3(%struct.t3* byval align 4 %tmp1)
+
+// N32-N64:  call void @f1(i64 inreg %3, i16 inreg %5)
+// N32-N64:  call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13)
+// N32-N64:  call void @f3(%struct.t3* byval align 8 %tmp)
+
+  f1(g1);
+  f2(g2);
+  f3(g3);
+}
+
Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -6695,6 +6695,14 @@
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
+// Use indirect if the aggregate cannot fit into registers for
+// passing arguments according to the ABI
+unsigned Threshold = IsO32 ? 16 : 64;
+
+if(getContext().getTypeSizeInChars(Ty) > CharUnits::fromQuantity(Threshold))
+  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
+ getContext().getTypeAlign(Ty) / 8 > Align);
+
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30837: [libcxx] Support for shared_ptr<T()>

2017-05-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Ping! @mclow.lists: Do you have any thoughts here?


https://reviews.llvm.org/D30837



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


[PATCH] D32972: [index] Index simple dependent declaration references

2017-05-09 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir accepted this revision.
benlangmuir added a comment.
This revision is now accepted and ready to land.

A couple of minor comments, but otherwise LGTM.




Comment at: include/clang/AST/DeclCXX.h:1569
+  bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths ,
+ bool LookupInDependent = false) const;
 

Since the other params are documented above, this should be too.



Comment at: lib/AST/CXXInheritance.cpp:281
+}
+  } else
+BaseRecord = cast(

Please put `{}` around this else.  The first two times I read this I thought 
the following if was nested inside this else.


Repository:
  rL LLVM

https://reviews.llvm.org/D32972



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


r302545 - [CodeCompletion] Complete platform names in @available expressions

2017-05-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue May  9 11:05:04 2017
New Revision: 302545

URL: http://llvm.org/viewvc/llvm-project?rev=302545=rev
Log:
[CodeCompletion] Complete platform names in @available expressions

rdar://32074504

Added:
cfe/trunk/test/Index/complete-available.m
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=302545=302544=302545=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue May  9 11:05:04 2017
@@ -10009,6 +10009,7 @@ public:
  MacroInfo *MacroInfo,
  unsigned Argument);
   void CodeCompleteNaturalLanguage();
+  void CodeCompleteAvailabilityPlatformName();
   void GatherGlobalCodeCompletions(CodeCompletionAllocator ,
CodeCompletionTUInfo ,
   SmallVectorImpl );

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=302545=302544=302545=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue May  9 11:05:04 2017
@@ -2989,6 +2989,11 @@ Optional Parser::Parse
 return AvailabilitySpec(ConsumeToken());
   } else {
 // Parse the platform name.
+if (Tok.is(tok::code_completion)) {
+  Actions.CodeCompleteAvailabilityPlatformName();
+  cutOffParsing();
+  return None;
+}
 if (Tok.isNot(tok::identifier)) {
   Diag(Tok, diag::err_avail_query_expected_platform_name);
   return None;

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=302545=302544=302545=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue May  9 11:05:04 2017
@@ -7811,6 +7811,23 @@ void Sema::CodeCompleteNaturalLanguage()
 nullptr, 0);
 }
 
+void Sema::CodeCompleteAvailabilityPlatformName() {
+  ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+CodeCompleter->getCodeCompletionTUInfo(),
+CodeCompletionContext::CCC_Other);
+  Results.EnterNewScope();
+  static const char *Platforms[] = {"macOS", "iOS", "watchOS", "tvOS"};
+  for (const char *Platform : llvm::makeArrayRef(Platforms)) {
+Results.AddResult(CodeCompletionResult(Platform));
+Results.AddResult(CodeCompletionResult(Results.getAllocator().CopyString(
+Twine(Platform) + "ApplicationExtension")));
+  }
+  Results.ExitScope();
+  HandleCodeCompleteResults(this, CodeCompleter,
+CodeCompletionContext::CCC_Other, Results.data(),
+Results.size());
+}
+
 void Sema::GatherGlobalCodeCompletions(CodeCompletionAllocator ,
CodeCompletionTUInfo ,
  SmallVectorImpl ) {

Added: cfe/trunk/test/Index/complete-available.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-available.m?rev=302545=auto
==
--- cfe/trunk/test/Index/complete-available.m (added)
+++ cfe/trunk/test/Index/complete-available.m Tue May  9 11:05:04 2017
@@ -0,0 +1,20 @@
+/* The run lines are below, because this test is line- and
+   column-number sensitive. */
+void atAvailable() {
+  if (@available(macOS 10.10, *)) {
+
+  }
+  if (__builtin_available(iOS 8, *)) {
+  }
+}
+
+// RUN: c-index-test -code-completion-at=%s:4:18 %s | FileCheck 
-check-prefix=CHECK %s
+// RUN: c-index-test -code-completion-at=%s:7:27 %s | FileCheck 
-check-prefix=CHECK %s
+// CHECK: {TypedText iOS} (40)
+// CHECK: {TypedText iOSApplicationExtension} (40)
+// CHECK: {TypedText macOS} (40)
+// CHECK: {TypedText macOSApplicationExtension} (40)
+// CHECK: {TypedText tvOS} (40)
+// CHECK: {TypedText tvOSApplicationExtension} (40)
+// CHECK: {TypedText watchOS} (40)
+// CHECK: {TypedText watchOSApplicationExtension} (40)


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


[PATCH] D32988: [libc++] Refactor Windows support headers.

2017-05-09 Thread Ben Craig via Phabricator via cfe-commits
bcraig added inline comments.



Comment at: include/__config:232-235
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+

I can see this helping when we are build libc++, but I don't think it helps 
client apps.  They could have included windows.h before including our headers.

Don't get me wrong, I dislike the min and max macros, and bear no hard feelings 
towards people that define this project wide on the command line, I'm just not 
sure it will get things done right here.

In the past, I've just surrounded my min and max declarations with parenthesis 
to suppress macro expansion.


https://reviews.llvm.org/D32988



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


r302542 - Revert r302476 "Update testcase for upstream LLVM changes."

2017-05-09 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue May  9 10:55:39 2017
New Revision: 302542

URL: http://llvm.org/viewvc/llvm-project?rev=302542=rev
Log:
Revert r302476 "Update testcase for upstream LLVM changes."

That test update was for r302469, which was reverted in r302533 due to PR32977.

Modified:
cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp

Modified: cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp?rev=302542=302541=302542=diff
==
--- cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp Tue May  9 
10:55:39 2017
@@ -12,10 +12,8 @@ void Derived::VariadicFunction(...) { }
 
 // CHECK: define void @_ZN7Derived16VariadicFunctionEz({{.*}} !dbg 
![[SP:[0-9]+]]
 // CHECK: ret void, !dbg ![[LOC:[0-9]+]]
-// CHECK: define void @_ZT{{.+}}N7Derived16VariadicFunctionEz({{.*}} !dbg 
![[SP_I:[0-9]+]]
-// CHECK: ret void, !dbg ![[LOC_I:[0-9]+]]
+// CHECK-LABEL: define void @_ZT{{.+}}N7Derived16VariadicFunctionEz(
+// CHECK: ret void, !dbg ![[LOC:[0-9]+]]
 //
 // CHECK: ![[SP]] = distinct !DISubprogram(name: "VariadicFunction"
 // CHECK: ![[LOC]] = !DILocation({{.*}}scope: ![[SP]])
-// CHECK: ![[SP_I]] = distinct !DISubprogram(name: "VariadicFunction"
-// CHECK: ![[LOC_I]] = !DILocation({{.*}}scope: ![[SP_I]])


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


[PATCH] D33000: Add support for pretty platform names to `@available`/`__builtin_available`

2017-05-09 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302540: Add support for pretty platform names to 
`@available`/ (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D33000?vs=98276=98297#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33000

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/FixIt/fixit-availability.c
  cfe/trunk/test/FixIt/fixit-availability.mm
  cfe/trunk/test/Parser/objc-available.m
  cfe/trunk/test/SemaObjC/unguarded-availability.m

Index: cfe/trunk/test/Parser/objc-available.m
===
--- cfe/trunk/test/Parser/objc-available.m
+++ cfe/trunk/test/Parser/objc-available.m
@@ -21,6 +21,12 @@
   (void)@available; // expected-error{{expected '('}}
 }
 
+void prettyPlatformNames() {
+  (void)@available(iOS 8, tvOS 10, watchOS 3, macOS 10.11, *);
+  (void)__builtin_available(iOSApplicationExtension 8, tvOSApplicationExtension 10,
+   watchOSApplicationExtension 3, macOSApplicationExtension 10.11, *);
+}
+
 #if __has_builtin(__builtin_available)
 #error expected
 // expected-error@-1 {{expected}}
Index: cfe/trunk/test/SemaObjC/unguarded-availability.m
===
--- cfe/trunk/test/SemaObjC/unguarded-availability.m
+++ cfe/trunk/test/SemaObjC/unguarded-availability.m
@@ -48,7 +48,7 @@
   } else
 func_10_11(); // expected-warning{{'func_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'func_10_11' in an @available check to silence this warning}}
 
-  if (@available(macos 10.11, *)) {
+  if (@available(macOS 10.11, *)) {
 if (@available(ios 8, *)) {
   func_10_11();
   func_10_12(); // expected-warning{{'func_10_12' is only available on macOS 10.12 or newer}} expected-note{{enclose}}
@@ -176,7 +176,7 @@
 }
 
 int instantiate_availability() {
-  if (@available(macos 10.12, *))
+  if (@available(macOS 10.12, *))
 with_availability_attr();
   else
 with_availability_attr(); // expected-warning{{'with_availability_attr' is only available on macOS 10.11 or newer}} expected-warning{{'int_10_12' is only available on macOS 10.12 or newer}} expected-note 2 {{enclose}}
Index: cfe/trunk/test/FixIt/fixit-availability.c
===
--- cfe/trunk/test/FixIt/fixit-availability.c
+++ cfe/trunk/test/FixIt/fixit-availability.c
@@ -5,6 +5,6 @@
 
 void use() {
   function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (__builtin_available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (__builtin_available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:14-[[@LINE-2]]:14}:"\n  } else {\n  // Fallback on earlier versions\n  }"
 }
Index: cfe/trunk/test/FixIt/fixit-availability.mm
===
--- cfe/trunk/test/FixIt/fixit-availability.mm
+++ cfe/trunk/test/FixIt/fixit-availability.mm
@@ -7,58 +7,58 @@
 
 int use() {
   function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:14-[[@LINE-2]]:14}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   int y = function(), x = 0;
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:29-[[@LINE-2]]:29}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   x += function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:19-[[@LINE-2]]:19}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   if (1) {
 x = function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:20-[[@LINE-2]]:20}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   }
   anotherFunction(function());
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:31-[[@LINE-2]]:31}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   if (function()) {
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if 

r302540 - Add support for pretty platform names to `@available`/

2017-05-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue May  9 10:34:46 2017
New Revision: 302540

URL: http://llvm.org/viewvc/llvm-project?rev=302540=rev
Log:
Add support for pretty platform names to `@available`/
`__builtin_available`

This commit allows us to use the macOS/iOS/tvOS/watchOS platform names in
`@available`/`__builtin_available`.

rdar://32067795

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/FixIt/fixit-availability.c
cfe/trunk/test/FixIt/fixit-availability.mm
cfe/trunk/test/Parser/objc-available.m
cfe/trunk/test/SemaObjC/unguarded-availability.m

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=302540=302539=302540=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue May  9 10:34:46 2017
@@ -652,6 +652,30 @@ def Availability : InheritableAttr {
  .Case("tvos_app_extension", "tvOS (App Extension)")
  .Case("watchos_app_extension", "watchOS (App Extension)")
  .Default(llvm::StringRef());
+}
+static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) 
{
+return llvm::StringSwitch(Platform)
+ .Case("ios", "iOS")
+ .Case("macos", "macOS")
+ .Case("tvos", "tvOS")
+ .Case("watchos", "watchOS")
+ .Case("ios_app_extension", "iOSApplicationExtension")
+ .Case("macos_app_extension", "macOSApplicationExtension")
+ .Case("tvos_app_extension", "tvOSApplicationExtension")
+ .Case("watchos_app_extension", "watchOSApplicationExtension")
+ .Default(Platform);
+}
+static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
+return llvm::StringSwitch(Platform)
+ .Case("iOS", "ios")
+ .Case("macOS", "macos")
+ .Case("tvOS", "tvos")
+ .Case("watchOS", "watchos")
+ .Case("iOSApplicationExtension", "ios_app_extension")
+ .Case("macOSApplicationExtension", "macos_app_extension")
+ .Case("tvOSApplicationExtension", "tvos_app_extension")
+ .Case("watchOSApplicationExtension", "watchos_app_extension")
+ .Default(Platform);
 } }];
   let HasCustomParsing = 1;
   let DuplicatesAllowedWhileMerging = 1;

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=302540=302539=302540=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue May  9 10:34:46 2017
@@ -3001,12 +3001,14 @@ Optional Parser::Parse
 if (Version.empty())
   return None;
 
-StringRef Platform = PlatformIdentifier->Ident->getName();
+StringRef GivenPlatform = PlatformIdentifier->Ident->getName();
+StringRef Platform =
+AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
 
 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty()) {
   Diag(PlatformIdentifier->Loc,
diag::err_avail_query_unrecognized_platform_name)
-  << Platform;
+  << GivenPlatform;
   return None;
 }
 

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=302540=302539=302540=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue May  9 10:34:46 2017
@@ -7346,7 +7346,9 @@ void DiagnoseUnguardedAvailability::Diag
 llvm::raw_string_ostream FixItOS(FixItString);
 FixItOS << "if (" << (SemaRef.getLangOpts().ObjC1 ? "@available"
   : "__builtin_available")
-<< "(" << SemaRef.getASTContext().getTargetInfo().getPlatformName()
+<< "("
+<< AvailabilityAttr::getPlatformNameSourceSpelling(
+   SemaRef.getASTContext().getTargetInfo().getPlatformName())
 << " " << Introduced.getAsString() << ", *)) {\n"
 << Indentation << ExtraIndentation;
 FixitDiag << FixItHint::CreateInsertion(IfInsertionLoc, FixItOS.str());

Modified: cfe/trunk/test/FixIt/fixit-availability.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-availability.c?rev=302540=302539=302540=diff
==
--- cfe/trunk/test/FixIt/fixit-availability.c (original)
+++ cfe/trunk/test/FixIt/fixit-availability.c Tue May  9 10:34:46 2017
@@ -5,6 +5,6 @@ int function(void);
 
 void use() {
   function();
-// CHECK: 

[clang-tools-extra] r302536 - [clang-tidy] Allow disabling compatibility check for generated fixes.

2017-05-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue May  9 10:10:26 2017
New Revision: 302536

URL: http://llvm.org/viewvc/llvm-project?rev=302536=rev
Log:
[clang-tidy] Allow disabling compatibility check for generated fixes.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=302536=302535=302536=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Tue May  
9 10:10:26 2017
@@ -237,9 +237,11 @@ StringRef ClangTidyContext::getCheckName
   return "";
 }
 
-ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(ClangTidyContext )
-: Context(Ctx), LastErrorRelatesToUserCode(false),
-  LastErrorPassesLineFilter(false), LastErrorWasIgnored(false) {
+ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(
+ClangTidyContext , bool RemoveIncompatibleErrors)
+: Context(Ctx), RemoveIncompatibleErrors(RemoveIncompatibleErrors),
+  LastErrorRelatesToUserCode(false), LastErrorPassesLineFilter(false),
+  LastErrorWasIgnored(false) {
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
   Diags.reset(new DiagnosticsEngine(
   IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts, this,
@@ -611,7 +613,9 @@ void ClangTidyDiagnosticConsumer::finish
   std::sort(Errors.begin(), Errors.end(), LessClangTidyError());
   Errors.erase(std::unique(Errors.begin(), Errors.end(), 
EqualClangTidyError()),
Errors.end());
-  removeIncompatibleErrors(Errors);
+
+  if (RemoveIncompatibleErrors)
+removeIncompatibleErrors(Errors);
 
   for (const ClangTidyError  : Errors)
 Context.storeError(Error);

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h?rev=302536=302535=302536=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h Tue May  9 
10:10:26 2017
@@ -223,7 +223,8 @@ private:
 // implementation file.
 class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
 public:
-  ClangTidyDiagnosticConsumer(ClangTidyContext );
+  ClangTidyDiagnosticConsumer(ClangTidyContext ,
+  bool RemoveIncompatibleErrors = true);
 
   // FIXME: The concept of converting between FixItHints and Replacements is
   // more generic and should be pulled out into a more useful Diagnostics
@@ -249,6 +250,7 @@ private:
   bool passesLineFilter(StringRef FileName, unsigned LineNumber) const;
 
   ClangTidyContext 
+  bool RemoveIncompatibleErrors;
   std::unique_ptr Diags;
   SmallVector Errors;
   std::unique_ptr HeaderFilter;


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


[PATCH] D33004: getIdentifierInfo now updates the returned information by default

2017-05-09 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor planned changes to this revision.
teemperor added a comment.

Work in progress patch. We probably also need to update a few other places 
where we call this.


https://reviews.llvm.org/D33004



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


[PATCH] D33004: getIdentifierInfo now updates the returned information by default

2017-05-09 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.

Calling `Preprocessor::getIdentifierInfo` is not automatically updating the 
returned identifier at the moment. This patch adds a flag that is ensuring by 
default that the returned IdentifierInfo is updated. The flag is true by 
default because that seems like the most logical behavior for this method. Can 
be turned off for performance reasons


https://reviews.llvm.org/D33004

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/Preprocessor.cpp


Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -245,6 +245,27 @@
   llvm::errs() << ">";
 }
 
+IdentifierInfo *Preprocessor::getIdentifierInfo(StringRef Name,
+bool CheckOutOfDate) const {
+  IdentifierInfo  = Identifiers.get(Name);
+  // If the information about this identifier is out of date, update it from
+  // the external source.
+  // We have to treat __VA_ARGS__ in a special way, since it gets
+  // serialized with isPoisoned = true, but our preprocessor may have
+  // unpoisoned it if we're defining a C99 macro.
+  if (CheckOutOfDate && II.isOutOfDate()) {
+bool CurrentIsPoisoned = false;
+if ( == Ident__VA_ARGS__)
+  CurrentIsPoisoned = Ident__VA_ARGS__->isPoisoned();
+
+updateOutOfDateIdentifier(II);
+
+if ( == Ident__VA_ARGS__)
+  II.setIsPoisoned(CurrentIsPoisoned);
+  }
+  return 
+}
+
 void Preprocessor::DumpLocation(SourceLocation Loc) const {
   Loc.dump(SourceMgr);
 }
@@ -646,23 +667,8 @@
 
   IdentifierInfo  = *Identifier.getIdentifierInfo();
 
-  // If the information about this identifier is out of date, update it from
-  // the external source.
-  // We have to treat __VA_ARGS__ in a special way, since it gets
-  // serialized with isPoisoned = true, but our preprocessor may have
-  // unpoisoned it if we're defining a C99 macro.
-  if (II.isOutOfDate()) {
-bool CurrentIsPoisoned = false;
-if ( == Ident__VA_ARGS__)
-  CurrentIsPoisoned = Ident__VA_ARGS__->isPoisoned();
-
-updateOutOfDateIdentifier(II);
-Identifier.setKind(II.getTokenID());
+  Identifier.setKind(II.getTokenID());
 
-if ( == Ident__VA_ARGS__)
-  II.setIsPoisoned(CurrentIsPoisoned);
-  }
-  
   // If this identifier was poisoned, and if it was not produced from a macro
   // expansion, emit an error.
   if (II.isPoisoned() && CurPPLexer) {
Index: include/clang/Lex/Preprocessor.h
===
--- include/clang/Lex/Preprocessor.h
+++ include/clang/Lex/Preprocessor.h
@@ -939,11 +939,11 @@
   void setPredefines(const char *P) { Predefines = P; }
   void setPredefines(StringRef P) { Predefines = P; }
 
-  /// Return information about the specified preprocessor
-  /// identifier token.
-  IdentifierInfo *getIdentifierInfo(StringRef Name) const {
-return (Name);
-  }
+  /// Return information about the specified preprocessor identifier token.
+  /// If \p CheckOutOfDate is true, then the returned information is ensured
+  /// to be not out of date.
+  IdentifierInfo *getIdentifierInfo(StringRef Name,
+bool CheckOutOfDate = true) const;
 
   /// \brief Add the specified pragma handler to this preprocessor.
   ///


Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -245,6 +245,27 @@
   llvm::errs() << ">";
 }
 
+IdentifierInfo *Preprocessor::getIdentifierInfo(StringRef Name,
+bool CheckOutOfDate) const {
+  IdentifierInfo  = Identifiers.get(Name);
+  // If the information about this identifier is out of date, update it from
+  // the external source.
+  // We have to treat __VA_ARGS__ in a special way, since it gets
+  // serialized with isPoisoned = true, but our preprocessor may have
+  // unpoisoned it if we're defining a C99 macro.
+  if (CheckOutOfDate && II.isOutOfDate()) {
+bool CurrentIsPoisoned = false;
+if ( == Ident__VA_ARGS__)
+  CurrentIsPoisoned = Ident__VA_ARGS__->isPoisoned();
+
+updateOutOfDateIdentifier(II);
+
+if ( == Ident__VA_ARGS__)
+  II.setIsPoisoned(CurrentIsPoisoned);
+  }
+  return 
+}
+
 void Preprocessor::DumpLocation(SourceLocation Loc) const {
   Loc.dump(SourceMgr);
 }
@@ -646,23 +667,8 @@
 
   IdentifierInfo  = *Identifier.getIdentifierInfo();
 
-  // If the information about this identifier is out of date, update it from
-  // the external source.
-  // We have to treat __VA_ARGS__ in a special way, since it gets
-  // serialized with isPoisoned = true, but our preprocessor may have
-  // unpoisoned it if we're defining a C99 macro.
-  if (II.isOutOfDate()) {
-bool CurrentIsPoisoned = false;
-if ( == Ident__VA_ARGS__)
-  CurrentIsPoisoned = Ident__VA_ARGS__->isPoisoned();
-
-updateOutOfDateIdentifier(II);
-

[clang-tools-extra] r302534 - Change EOL style to LF. NFC

2017-05-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue May  9 09:56:28 2017
New Revision: 302534

URL: http://llvm.org/viewvc/llvm-project?rev=302534=rev
Log:
Change EOL style to LF. NFC

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-non-copyable-objects.c
clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.c

clang-tools-extra/trunk/test/clang-tidy/misc-undelegated-constructor-cxx98.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=302534=302533=302534=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Tue May  
9 09:56:28 2017
@@ -1,619 +1,619 @@
-//===--- tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp --=== 
//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-///
-///  \file This file implements ClangTidyDiagnosticConsumer, ClangTidyContext
-///  and ClangTidyError classes.
-///
-///  This tool uses the Clang Tooling infrastructure, see
-///http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
-///  for details on setting it up with LLVM source tree.
-///
-//===--===//
-
-#include "ClangTidyDiagnosticConsumer.h"
-#include "ClangTidyOptions.h"
-#include "clang/AST/ASTDiagnostic.h"
-#include "clang/Basic/DiagnosticOptions.h"
-#include "clang/Frontend/DiagnosticRenderer.h"
-#include "llvm/ADT/SmallString.h"
-#include 
-#include 
-using namespace clang;
-using namespace tidy;
-
-namespace {
-class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
-public:
-  ClangTidyDiagnosticRenderer(const LangOptions ,
-  DiagnosticOptions *DiagOpts,
-  ClangTidyError )
-  : DiagnosticRenderer(LangOpts, DiagOpts), Error(Error) {}
-
-protected:
-  void emitDiagnosticMessage(SourceLocation Loc, PresumedLoc PLoc,
- DiagnosticsEngine::Level Level, StringRef Message,
- ArrayRef Ranges,
- const SourceManager *SM,
- DiagOrStoredDiag Info) override {
-// Remove check name from the message.
-// FIXME: Remove this once there's a better way to pass check names than
-// appending the check name to the message in ClangTidyContext::diag and
-// using getCustomDiagID.
-std::string CheckNameInMessage = " [" + Error.DiagnosticName + "]";
-if (Message.endswith(CheckNameInMessage))
-  Message = Message.substr(0, Message.size() - CheckNameInMessage.size());
-
-auto TidyMessage = Loc.isValid()
-   ? tooling::DiagnosticMessage(Message, *SM, Loc)
-   : tooling::DiagnosticMessage(Message);
-if (Level == DiagnosticsEngine::Note) {
-  Error.Notes.push_back(TidyMessage);
-  return;
-}
-assert(Error.Message.Message.empty() && "Overwriting a diagnostic 
message");
-Error.Message = TidyMessage;
-  }
-
-  void emitDiagnosticLoc(SourceLocation Loc, PresumedLoc PLoc,
- DiagnosticsEngine::Level Level,
- ArrayRef Ranges,
- const SourceManager ) override {}
-
-  void emitCodeContext(SourceLocation Loc, DiagnosticsEngine::Level Level,
-   SmallVectorImpl ,
-   ArrayRef Hints,
-   const SourceManager ) override {
-assert(Loc.isValid());
-for (const auto  : Hints) {
-  CharSourceRange Range = FixIt.RemoveRange;
-  assert(Range.getBegin().isValid() && Range.getEnd().isValid() &&
- "Invalid range in the fix-it hint.");
-  assert(Range.getBegin().isFileID() && Range.getEnd().isFileID() &&
- "Only file locations supported in fix-it hints.");
-
-  tooling::Replacement Replacement(SM, Range, FixIt.CodeToInsert);
-  llvm::Error Err = Error.Fix[Replacement.getFilePath()].add(Replacement);
-  // FIXME: better error handling (at least, don't let other replacements 
be
-  // applied).
-  if (Err) {
-llvm::errs() << "Fix conflicts with existing fix! "
- << llvm::toString(std::move(Err)) << "\n";
-assert(false && "Fix conflicts with existing fix!");
-  }
-}
-  }
-
-  void emitIncludeLocation(SourceLocation Loc, PresumedLoc PLoc,
-   const SourceManager ) 

[PATCH] D33000: Add support for pretty platform names to `@available`/`__builtin_available`

2017-05-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for working on this!


Repository:
  rL LLVM

https://reviews.llvm.org/D33000



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


  1   2   >