[PATCH] D61950: [PowerPC64] adds ABI parsing when specified on target triple

2019-05-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Will FreeBSD 13 or future releases support ELFv1? If not, it may be cleaner to 
not invent `-elfv2` `-elfv1` triples, but rather dispatch on the major version, 
e.g. `powerpc64-unknown-freebsd13.0` could mean ELFv2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61950



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


[PATCH] D61970: [CodeGen][ObjC] Call objc_autoreleaseReturnValue and objc_retainAutoreleasedReturnValue instead of objc_autorelease and objc_retain in MRR

2019-05-15 Thread David Kilzer via Phabricator via cfe-commits
ddkilzer added a comment.

Had a couple questions about using `objc_retainAutoreleasedReturnValue` without 
a `return` statement.  (I'm just reading this from a layman's point of view; it 
may not actually matter in practice.)




Comment at: test/CodeGenObjC/convert-messages-to-runtime-calls.m:32
   // CALLS: {{call.*@objc_allocWithZone}}
-  // CALLS: {{call.*@objc_retain}}
+  // CALLS-ARC-INTRINSICS: {{call.*@llvm.objc.retainAutoreleasedReturnValue}}
+  // CALLS-NO-ARC-INTRINSICS: {{call.*@objc_retain}}

Silly question:  Should `objc_retainAutoreleasedReturnValue` really be called 
here when the value is not used in a `return` statement?



Comment at: test/CodeGenObjC/convert-messages-to-runtime-calls.m:169
   // MSGS: {{call.*@objc_msgSend}}
-  // CALLS: {{call.*@objc_retain}}
+  // CALLS-ARC-INTRINSICS: {{call.*@llvm.objc.retainAutoreleasedReturnValue}}
+  // CALLS-NO-ARC-INTRINSICS: {{call.*@objc_retain}}

Same silly question:  Should `objc_retainAutoreleasedReturnValue` really be 
called here when the value is not used in a `return` statement?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61970



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


[PATCH] D61756: Add a __FILE_NAME__ macro.

2019-05-15 Thread Kristina Brooks via Phabricator via cfe-commits
kristina reopened this revision.
kristina added a comment.
This revision is now accepted and ready to land.

Reverted in rL360842  as Windows bots were 
failing.

I suspect the `MSVCCompat` case may need to be handled differently depending on 
the host OS similar to `PPDirectives.cpp`:

if (LangOpts.MSVCCompat) {
  NormalizedPath = Filename.str();
  #ifndef _WIN32
  llvm::sys::path::native(NormalizedPath);
  #endif
}

Reopening this for now, will try to get a local Windows builder set up and work 
out what the problem is before relanding.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61756



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


[PATCH] D61989: [clang-tidy] enable modernize-concat-nested-namespaces on header files

2019-05-15 Thread Xiao Shi via Phabricator via cfe-commits
shixiao created this revision.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

For header files that pass the -header-filter, the
modernize-concat-nested-namespaces check does not generate the expected
warning and fix for un-concatenated namespaces. This diff fixes it.

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

Test Plan:

a.h
---

namespace foo {
namespace bar {
namespace baz {
struct S {};
}
}

}
=

a.cpp
-

namespace foo {
namespace bar {
namespace baz {
void foo(const S&) {}
}
}
}

int main () {

  return 0;

}
=

$ /clang-tidy -p sample/compile_commands.json 
-checks="modernize-concat-nested-namespaces" -header-filter="a.h" sample/a.cpp

  4 warnings generated.
  sample/a.h:5:1: warning: nested namespaces can be concatenated 
[modernize-concat-nested-namespaces]
  namespace foo {
  ^~~
  namespace foo::bar::baz
  sample/a.cpp:5:1: warning: nested namespaces can be concatenated 
[modernize-concat-nested-namespaces]
  namespace foo {
  ^~~
  namespace foo::bar::baz


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61989

Files:
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst

Index: clang-tools-extra/docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst
@@ -47,3 +47,13 @@
   }
   }
 
+Options
+---
+
+.. option:: HeaderFileExtensions
+
+   A comma-separated list of filename extensions of header files (the filename
+   extensions should not contain "." prefix). Default is "h,hh,hpp,hxx".
+   For header files without an extension, use an empty string (if there are no
+   other desired extensions) or leave an empty element in the list. e.g.,
+   "h,hh,hpp,hxx," (note the trailing comma).
Index: clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
===
--- clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
+++ clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_CONCATNESTEDNAMESPACESCHECK_H
 
 #include "../ClangTidyCheck.h"
+#include "../utils/HeaderFileExtensionsUtils.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 
@@ -17,10 +18,16 @@
 namespace tidy {
 namespace modernize {
 
+/// The check supports these options:
+///   - `HeaderFileExtensions`: a comma-separated list of filename extensions of
+/// header files (The filename extensions should not contain "." prefix).
+/// "h,hh,hpp,hxx" by default.
+/// For extension-less header files, using an empty string or leaving an
+/// empty string between "," if there are other filename extensions.
 class ConcatNestedNamespacesCheck : public ClangTidyCheck {
 public:
-  ConcatNestedNamespacesCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  ConcatNestedNamespacesCheck(StringRef Name, ClangTidyContext *Context);
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 
@@ -32,6 +39,8 @@
 const SourceRange );
   NamespaceString concatNamespaces();
   NamespaceContextVec Namespaces;
+  const std::string RawStringHeaderFileExtensions;
+  utils::HeaderFileExtensionsSet HeaderFileExtensions;
 };
 } // namespace modernize
 } // namespace tidy
Index: clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
@@ -61,6 +61,23 @@
   return Result;
 }
 
+ConcatNestedNamespacesCheck::ConcatNestedNamespacesCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
+  "HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
+  if (!utils::parseHeaderFileExtensions(RawStringHeaderFileExtensions,
+HeaderFileExtensions, ',')) {
+llvm::errs() << "Invalid header file extension: "
+ << RawStringHeaderFileExtensions << "\n";
+  }
+}
+
+void ConcatNestedNamespacesCheck::storeOptions(
+ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "HeaderFileExtensions", RawStringHeaderFileExtensions);
+}
+
 void ConcatNestedNamespacesCheck::registerMatchers(

r360842 - Revert r360833 until I can work out the issue with Win32 bots

2019-05-15 Thread Kristina Brooks via cfe-commits
Author: kristina
Date: Wed May 15 20:30:08 2019
New Revision: 360842

URL: http://llvm.org/viewvc/llvm-project?rev=360842=rev
Log:
Revert r360833 until I can work out the issue with Win32 bots

This reverts "r360833: [Clang][PP] Add the __FILE_NAME__ builtin macro."

The tests are failing on Windows bots, reverting the patchset until I can
work out why.


Removed:
cfe/trunk/test/Preprocessor/Inputs/include-subdir/
cfe/trunk/test/Preprocessor/file_name_macro.c
Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/PPMacroExpansion.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=360842=360841=360842=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed May 15 20:30:08 2019
@@ -147,7 +147,6 @@ class Preprocessor {
   IdentifierInfo *Ident__DATE__, *Ident__TIME__;   // __DATE__, __TIME__
   IdentifierInfo *Ident__INCLUDE_LEVEL__;  // __INCLUDE_LEVEL__
   IdentifierInfo *Ident__BASE_FILE__;  // __BASE_FILE__
-  IdentifierInfo *Ident__FILE_NAME__;  // __FILE_NAME__
   IdentifierInfo *Ident__TIMESTAMP__;  // __TIMESTAMP__
   IdentifierInfo *Ident__COUNTER__;// __COUNTER__
   IdentifierInfo *Ident_Pragma, *Ident__pragma;// _Pragma, __pragma

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=360842=360841=360842=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed May 15 20:30:08 2019
@@ -363,7 +363,6 @@ void Preprocessor::RegisterBuiltinMacros
   }
 
   // Clang Extensions.
-  Ident__FILE_NAME__  = RegisterBuiltinMacro(*this, "__FILE_NAME__");
   Ident__has_feature  = RegisterBuiltinMacro(*this, "__has_feature");
   Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension");
   Ident__has_builtin  = RegisterBuiltinMacro(*this, "__has_builtin");
@@ -1475,8 +1474,7 @@ void Preprocessor::ExpandBuiltinMacro(To
 // __LINE__ expands to a simple numeric value.
 OS << (PLoc.isValid()? PLoc.getLine() : 1);
 Tok.setKind(tok::numeric_constant);
-  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ ||
- II == Ident__FILE_NAME__) {
+  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) {
 // C99 6.10.8: "__FILE__: The presumed name of the current source file (a
 // character string literal)". This can be affected by #line.
 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
@@ -1497,27 +1495,7 @@ void Preprocessor::ExpandBuiltinMacro(To
 // Escape this filename.  Turn '\' -> '\\' '"' -> '\"'
 SmallString<128> FN;
 if (PLoc.isValid()) {
-  // __FILE_NAME__ is a Clang-specific extension that expands to the
-  // the last part of __FILE__.
-  if (II == Ident__FILE_NAME__) {
-// Try to get the last path component.
-StringRef PLFileName = PLoc.getFilename();
-size_t LastSep = PLFileName.find_last_of('/');
-#ifdef _WIN32
-// On Windows targets, absolute paths can be normalized to use
-// backslashes instead - handle this potential case here.
-if (LastSep == StringRef::npos)
-  LastSep = PLFileName.find_last_of('\\');
-#endif
-// Skip the separator and get the last part, otherwise fall back on
-// returning the original full filename.
-if (LastSep != StringRef::npos)
-  FN += PLFileName.substr(LastSep+1);
-else
-  FN += PLFileName;
-  } else {
-FN += PLoc.getFilename();
-  }
+  FN += PLoc.getFilename();
   Lexer::Stringify(FN);
   OS << '"' << FN << '"';
 }

Removed: cfe/trunk/test/Preprocessor/file_name_macro.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/file_name_macro.c?rev=360841=auto
==
--- cfe/trunk/test/Preprocessor/file_name_macro.c (original)
+++ cfe/trunk/test/Preprocessor/file_name_macro.c (removed)
@@ -1,44 +0,0 @@
-// RUN: %clang_cc1 -E %s -I%S/Inputs | FileCheck -strict-whitespace %s
-// RUN: %clang_cc1 -fms-compatibility -DMS -E %s -I%S/Inputs | FileCheck 
-check-prefix=CHECK-MS -strict-whitespace %s 
-// RUN: %clang_cc1 -E %s -I%S/Inputs -DBADINC -verify
-
-#ifdef BADINC
-
-// Paranoia.
-
-__FILE_NAME__
-#include  // expected-error {{file not found}}
-__FILE_NAME__
-
-#else
-
-// Reference.
-1: "file_name_macro.c"
-
-// Ensure it expands correctly for this file.
-2: __FILE_NAME__
-
-// CHECK: {{^}}1: "file_name_macro.c"
-// CHECK: {{^}}2: "file_name_macro.c"
-
-// Test if inclusion works right.
-#ifdef MS
-#include 
-// MS 

r360839 - Fix assumption about Win32 paths in r360833

2019-05-15 Thread Kristina Brooks via cfe-commits
Author: kristina
Date: Wed May 15 19:46:12 2019
New Revision: 360839

URL: http://llvm.org/viewvc/llvm-project?rev=360839=rev
Log:
Fix assumption about Win32 paths in r360833

Attempt to fix Windows buildbots due to differences in
path handling (caused by r360833).


Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=360839=360838=360839=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed May 15 19:46:12 2019
@@ -1501,8 +1501,14 @@ void Preprocessor::ExpandBuiltinMacro(To
   // the last part of __FILE__.
   if (II == Ident__FILE_NAME__) {
 // Try to get the last path component.
-StringRef PLFileName = PLoc.getFilename(); 
-size_t LastSep = PLFileName.find_last_of('/');
+StringRef PLFileName = PLoc.getFilename();
+size_t LastSep = PLFileName.find_last_of('/');
+#ifdef _WIN32
+// On Windows targets, absolute paths can be normalized to use
+// backslashes instead - handle this potential case here.
+if (LastSep == StringRef::npos)
+  LastSep = PLFileName.find_last_of('\\');
+#endif
 // Skip the separator and get the last part, otherwise fall back on
 // returning the original full filename.
 if (LastSep != StringRef::npos)


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


Re: r360833 - [Clang][PP] Add the __FILE_NAME__ builtin macro.

2019-05-15 Thread Kristina Brooks via cfe-commits
Yes, sorry about that, I did notice, just re-testing it, should have a fix
for Windows bots in a few minutes.

On Thu, May 16, 2019 at 3:26 AM  wrote:

> Hi Kristina,
>
> Your change does not seem to be working on Windows. Can you take a look?
>
> http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/6860
>
> FAIL: Clang :: Preprocessor/file_name_macro.c (7959 of 14753)
>  TEST 'Clang :: Preprocessor/file_name_macro.c' FAILED
> 
> Script:
> --
> : 'RUN: at line 1';
>  c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\clang.exe -cc1
> -internal-isystem
> c:\b\slave\clang-x64-windows-msvc\build\build\stage1\lib\clang\9.0.0\include
> -nostdsysteminc -E
> C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c
> -IC:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor/Inputs
> | c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\filecheck.exe
> -strict-whitespace
> C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c
> : 'RUN: at line 2';
>  c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\clang.exe -cc1
> -internal-isystem
> c:\b\slave\clang-x64-windows-msvc\build\build\stage1\lib\clang\9.0.0\include
> -nostdsysteminc -fms-compatibility -DMS -E
> C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c
> -IC:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor/Inputs
> | c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\filecheck.exe
> -check-prefix=CHECK-MS -strict-whitespace
> C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c
> : 'RUN: at line 3';
>  c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\clang.exe -cc1
> -internal-isystem
> c:\b\slave\clang-x64-windows-msvc\build\build\stage1\lib\clang\9.0.0\include
> -nostdsysteminc -E
> C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c
> -IC:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor/Inputs
> -DBADINC -verify
> --
> Exit Code: 1
>
> Command Output (stdout):
> --
> $ ":" "RUN: at line 1"
> $ "c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\clang.exe"
> "-cc1" "-internal-isystem"
> "c:\b\slave\clang-x64-windows-msvc\build\build\stage1\lib\clang\9.0.0\include"
> "-nostdsysteminc" "-E"
> "C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c"
> "-IC:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor/Inputs"
> $ "c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\filecheck.exe"
> "-strict-whitespace"
> "C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c"
> # command stderr:
> C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c:22:11:
> error: CHECK: expected string not found in input
>
> // CHECK: {{^}}2: "file_name_macro.c"
>
>   ^
>
> :12:1: note: scanning from here
>
> 2:
> "C:\\b\\slave\\clang-x64-windows-msvc\\build\\llvm.src\\tools\\clang\\test\\Preprocessor\\file_name_macro.c"
>
> ^
>
> :12:87: note: possible intended match here
>
> 2:
> "C:\\b\\slave\\clang-x64-windows-msvc\\build\\llvm.src\\tools\\clang\\test\\Preprocessor\\file_name_macro.c"
>
>
> ^
>
>
> error: command failed with exit status: 1
>
> Douglas Yung
>
> -Original Message-
> From: cfe-commits  On Behalf Of
> Kristina Brooks via cfe-commits
> Sent: Wednesday, May 15, 2019 17:53
> To: cfe-commits@lists.llvm.org
> Subject: r360833 - [Clang][PP] Add the __FILE_NAME__ builtin macro.
>
> Author: kristina
> Date: Wed May 15 17:52:41 2019
> New Revision: 360833
>
> URL: http://llvm.org/viewvc/llvm-project?rev=360833=rev
> Log:
> [Clang][PP] Add the __FILE_NAME__ builtin macro.
>
> This patch adds the `__FILE_NAME__` macro that expands to the last
> component of the path, similar to `__FILE__` except with a guarantee that
> only the last path component (without the
> separator) will be rendered.
>
> I intend to follow through with discussion of this with WG14 as a
> potential inclusion in the C standard or failing that, try to discuss this
> with GCC developers since this extension is desired by GCC and Clang
> users/developers alike.
>
> Differential Revision: https://reviews.llvm.org/D61756
>
>
> Added:
> cfe/trunk/test/Preprocessor/Inputs/include-subdir/
>
> cfe/trunk/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
> cfe/trunk/test/Preprocessor/Inputs/include-subdir/h
> cfe/trunk/test/Preprocessor/Inputs/include-subdir/subdir1/
> cfe/trunk/test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h
> cfe/trunk/test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h
> cfe/trunk/test/Preprocessor/file_name_macro.c
> Modified:
> cfe/trunk/include/clang/Lex/Preprocessor.h
> 

RE: r360833 - [Clang][PP] Add the __FILE_NAME__ builtin macro.

2019-05-15 Thread via cfe-commits
Hi Kristina,

Your change does not seem to be working on Windows. Can you take a look?

http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/6860

FAIL: Clang :: Preprocessor/file_name_macro.c (7959 of 14753)
 TEST 'Clang :: Preprocessor/file_name_macro.c' FAILED 

Script:
--
: 'RUN: at line 1';   
c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\clang.exe -cc1 
-internal-isystem 
c:\b\slave\clang-x64-windows-msvc\build\build\stage1\lib\clang\9.0.0\include 
-nostdsysteminc -E 
C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c
 
-IC:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor/Inputs
 | c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\filecheck.exe 
-strict-whitespace 
C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c
: 'RUN: at line 2';   
c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\clang.exe -cc1 
-internal-isystem 
c:\b\slave\clang-x64-windows-msvc\build\build\stage1\lib\clang\9.0.0\include 
-nostdsysteminc -fms-compatibility -DMS -E 
C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c
 
-IC:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor/Inputs
 | c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\filecheck.exe 
-check-prefix=CHECK-MS -strict-whitespace 
C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c
: 'RUN: at line 3';   
c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\clang.exe -cc1 
-internal-isystem 
c:\b\slave\clang-x64-windows-msvc\build\build\stage1\lib\clang\9.0.0\include 
-nostdsysteminc -E 
C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c
 
-IC:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor/Inputs
 -DBADINC -verify
--
Exit Code: 1

Command Output (stdout):
--
$ ":" "RUN: at line 1"
$ "c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\clang.exe" "-cc1" 
"-internal-isystem" 
"c:\b\slave\clang-x64-windows-msvc\build\build\stage1\lib\clang\9.0.0\include" 
"-nostdsysteminc" "-E" 
"C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c"
 
"-IC:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor/Inputs"
$ "c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\filecheck.exe" 
"-strict-whitespace" 
"C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c"
# command stderr:
C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c:22:11:
 error: CHECK: expected string not found in input

// CHECK: {{^}}2: "file_name_macro.c"

  ^

:12:1: note: scanning from here

2: 
"C:\\b\\slave\\clang-x64-windows-msvc\\build\\llvm.src\\tools\\clang\\test\\Preprocessor\\file_name_macro.c"

^

:12:87: note: possible intended match here

2: 
"C:\\b\\slave\\clang-x64-windows-msvc\\build\\llvm.src\\tools\\clang\\test\\Preprocessor\\file_name_macro.c"


  ^


error: command failed with exit status: 1

Douglas Yung

-Original Message-
From: cfe-commits  On Behalf Of Kristina 
Brooks via cfe-commits
Sent: Wednesday, May 15, 2019 17:53
To: cfe-commits@lists.llvm.org
Subject: r360833 - [Clang][PP] Add the __FILE_NAME__ builtin macro.

Author: kristina
Date: Wed May 15 17:52:41 2019
New Revision: 360833

URL: http://llvm.org/viewvc/llvm-project?rev=360833=rev
Log:
[Clang][PP] Add the __FILE_NAME__ builtin macro.

This patch adds the `__FILE_NAME__` macro that expands to the last component of 
the path, similar to `__FILE__` except with a guarantee that only the last path 
component (without the
separator) will be rendered.

I intend to follow through with discussion of this with WG14 as a potential 
inclusion in the C standard or failing that, try to discuss this with GCC 
developers since this extension is desired by GCC and Clang users/developers 
alike.

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


Added:
cfe/trunk/test/Preprocessor/Inputs/include-subdir/
cfe/trunk/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
cfe/trunk/test/Preprocessor/Inputs/include-subdir/h
cfe/trunk/test/Preprocessor/Inputs/include-subdir/subdir1/
cfe/trunk/test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h
cfe/trunk/test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h
cfe/trunk/test/Preprocessor/file_name_macro.c
Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/PPMacroExpansion.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=360833=360832=360833=diff

r360837 - Fix regression in r360311 caused by reversed bool arguments.

2019-05-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed May 15 19:06:16 2019
New Revision: 360837

URL: http://llvm.org/viewvc/llvm-project?rev=360837=rev
Log:
Fix regression in r360311 caused by reversed bool arguments.

Added:
cfe/trunk/test/CXX/over/over.match/over.match.funcs/over.match.ref/p1.cpp
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=360837=360836=360837=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed May 15 19:06:16 2019
@@ -9003,8 +9003,9 @@ Sema::AddArgumentDependentLookupCandidat
 
   AddOverloadCandidate(FD, FoundDecl, Args, CandidateSet,
/*SupressUserConversions=*/false, 
PartialOverloading,
+   /*AllowExplicit*/ true,
/*AllowExplicitConversions*/ false,
-   /*AllowExplicit*/ true, ADLCallKind::UsesADL);
+   ADLCallKind::UsesADL);
 } else {
   AddTemplateOverloadCandidate(
   cast(*I), FoundDecl, ExplicitTemplateArgs, 
Args,

Added: cfe/trunk/test/CXX/over/over.match/over.match.funcs/over.match.ref/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/over/over.match/over.match.funcs/over.match.ref/p1.cpp?rev=360837=auto
==
--- cfe/trunk/test/CXX/over/over.match/over.match.funcs/over.match.ref/p1.cpp 
(added)
+++ cfe/trunk/test/CXX/over/over.match/over.match.funcs/over.match.ref/p1.cpp 
Wed May 15 19:06:16 2019
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -verify
+// expected-no-diagnostics
+
+namespace r360311_regression {
+  struct string {};
+  struct string_view {
+explicit operator string() const;
+  };
+
+  namespace ns {
+struct Base {};
+class Derived : public Base {};
+void f(string_view s, Base *c);
+void f(const string , Derived *c);
+  } // namespace ns
+
+  void g(string_view s) {
+ns::Derived d;
+f(s, );
+  }
+  } // namespace r360311_regression


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


[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-05-15 Thread Jan Korous via Phabricator via cfe-commits
jkorous updated this revision to Diff 199712.
jkorous added a comment.

A major clean-up.

changelog
=

**general**

- specification, documentation, tests
- returning only filenames instead of paths (or empty string when the event is 
related to the watched dir itself)
- removed unsound event deduplication during/right after the initial scan
- simplified how is OS-specific implementation selected

**linux**

- properly terminating threads
- added pthreads to fix shared libs build
- handle IN_DELETE_SELF, IN_IGNORED
- IN_EXCL_UNLINK

**macos**

- simplified synchronization by removing semaphores
- workarounds in FSEvents use

I am not entirely happy about my tests - since we're handling notifications 
from kernel asynchronously it's hard to write a deterministic test. I just use 
some 100 ms sleeps as a workaround. Happy to use something more robust if 
anyone has some ideas. Tests seem fine with msan & tsan on linux and tsan on 
macos but given their scope it doesn't mean that much.


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

https://reviews.llvm.org/D58418

Files:
  clang/cmake/modules/AddClang.cmake
  clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
  clang/lib/CMakeLists.txt
  clang/lib/DirectoryWatcher/CMakeLists.txt
  clang/lib/DirectoryWatcher/DirectoryScanner.cpp
  clang/lib/DirectoryWatcher/DirectoryScanner.h
  clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
  clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
  clang/unittests/CMakeLists.txt
  clang/unittests/DirectoryWatcher/CMakeLists.txt
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- /dev/null
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -0,0 +1,359 @@
+//===- unittests/DirectoryWatcher/DirectoryWatcherTest.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/DirectoryWatcher/DirectoryWatcher.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Mutex.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace llvm::sys;
+using namespace llvm::sys::fs;
+using namespace clang;
+
+namespace clang {
+static bool operator==(const DirectoryWatcher::Event ,
+   const DirectoryWatcher::Event ) {
+  return lhs.Filename == rhs.Filename &&
+ static_cast(lhs.Kind) == static_cast(rhs.Kind);
+}
+} // namespace clang
+
+namespace {
+
+// Intentionally trivial - expecting just a very small numbers of events.
+class TestEventConsumer {
+  std::vector InitialEvents;
+  std::vector NonInitialEvents;
+  sys::Mutex Mtx;
+
+  // Expecting only very small sets - don't bother with anything smart.
+  static bool
+  AreExpectedPresent(const std::vector ,
+ const std::vector ) {
+for (const auto  : expected) {
+  if (std::find(actual.begin(), actual.end(), e) == actual.end())
+return false;
+}
+return true;
+  }
+
+public:
+  void push(llvm::ArrayRef Events, bool isInitial) {
+sys::ScopedLock L(Mtx);
+if (isInitial) {
+  for (const auto  : Events)
+InitialEvents.push_back(E);
+} else {
+  for (const auto  : Events)
+NonInitialEvents.push_back(E);
+}
+  }
+
+  std::vector getInitialEvents() {
+sys::ScopedLock L(Mtx);
+return InitialEvents;
+  }
+  std::vector getNonInitialEvents() {
+sys::ScopedLock L(Mtx);
+return NonInitialEvents;
+  }
+
+  // Fool-proof way how to compare.
+  bool AreExpectedPresentInInitial(
+  const std::vector ) {
+sys::ScopedLock L(Mtx);
+return AreExpectedPresent(InitialEvents, expected);
+  }
+
+  // Fool-proof way how to compare.
+  bool AreExpectedPresentInNonInitial(
+  const std::vector ) {
+sys::ScopedLock L(Mtx);
+return AreExpectedPresent(NonInitialEvents, expected);
+  }
+};
+
+struct DirectoryWatcherTestFixture {
+  std::string TestRootDir;
+  std::string TestWatchedDir;
+
+  DirectoryWatcherTestFixture() {
+SmallString<128> pathBuf;
+assert(!createUniqueDirectory("dirwatcher", pathBuf));
+TestRootDir = pathBuf.str();
+path::append(pathBuf, "watch");
+TestWatchedDir = pathBuf.str();
+assert(!create_directory(TestWatchedDir, false));
+  }
+
+  ~DirectoryWatcherTestFixture() { remove_directories(TestRootDir); }
+
+  SmallString<128> getPathInWatched(const std::string ) {
+SmallString<128> pathBuf;
+pathBuf = TestWatchedDir;
+path::append(pathBuf, testFile);
+return pathBuf;
+  }
+
+  void addFile(const std::string ) {
+

[PATCH] D61974: [ObjC] Fix encoding of ObjC pointer types that are pointers to typedefs

2019-05-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rjmccall, theraven.
ahatanak added a project: clang.
Herald added subscribers: dexonsmith, jkorous.

clang currently emits different strings for `s0` and `s1` in the following code 
because pointers to typedefs are encoded as "^{PointeeClassName=#}" while ObjC 
pointer types that aren't pointers to typedefs are encoded as "@".

  @class Class1;
  
  typedef NSArray MyArray;
  
  void foo1(void) {
const char *s0 = @encode(MyArray *); // "^{NSArray=#}"
const char *s1 = @encode(NSArray *); // "@" 
  }

It seems that this was a deliberate choice made in r61387 to make clang 
compatible with gcc (see 
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20081222/010465.html), 
but it causes apple's runtime to crash. This patch fixes the bug by checking 
whether the runtime is one of the GNU runtimes before using the special 
encoding for typedefs.

rdar://problem/50563529


Repository:
  rC Clang

https://reviews.llvm.org/D61974

Files:
  lib/AST/ASTContext.cpp
  test/CodeGenObjC/encode-test-6.m
  test/CodeGenObjC/encode-test.m
  test/CodeGenObjCXX/encode.mm

Index: test/CodeGenObjCXX/encode.mm
===
--- test/CodeGenObjCXX/encode.mm
+++ test/CodeGenObjCXX/encode.mm
@@ -242,6 +242,6 @@
 @end
 
 const char *expand_struct() {
-  // CHECK: @{{.*}} = private unnamed_addr constant [16 x i8] c"{N={S=^{N}}}\00"
+  // CHECK: @{{.*}} = private unnamed_addr constant [13 x i8] c"{N={S=@}}\00"
   return @encode(N);
 }
Index: test/CodeGenObjC/encode-test.m
===
--- test/CodeGenObjC/encode-test.m
+++ test/CodeGenObjC/encode-test.m
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -triple i686-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s
-// RUN: FileCheck < %t %s
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s |  FileCheck -check-prefix=MACOSX -check-prefix=CHECK %s
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -fobjc-runtime=gnustep-1.7 -emit-llvm -o - %s |  FileCheck -check-prefix=GNUSTEP -check-prefix=CHECK %s
+
 //
-// CHECK: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant [16 x i8] c"v12@0:4[3[4@]]8\00"
+// MACOSX: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant [16 x i8] c"v12@0:4[3[4@]]8\00"
 
 @class Int1;
 
@@ -95,7 +96,8 @@
 // CHECK: @g0 = constant [15 x i8] c"{Innermost=CC}\00"
 const char g0[] = @encode(struct Innermost);
 
-// CHECK: @g1 = constant [38 x i8] c"{Derived=#ib32b8b3b8sb16b8b8b2b8ccb6}\00"
+// MACOSX: @g1 = constant [38 x i8] c"{Derived=#ib32b8b3b8sb16b8b8b2b8ccb6}\00"
+// GNUSTEP: @g1 = constant [83 x i8] c"{Derived=#ib96i32b128i8b136i3b139I8sb176I16b192i8b200i8b208i2b210i8ccb240i6b248c0}\00"
 const char g1[] = @encode(Derived);
 
 // CHECK: @g2 = constant [9 x i8] c"{B1=#@c}\00"
@@ -107,7 +109,8 @@
 // CHECK: @g4 = constant [6 x i8] c"{S=i}\00"
 const char g4[] = @encode(const struct S);
 
-// CHECK: @g5 = constant [12 x i8] c"^{Object=#}\00"
+// MACOSX: @g5 = constant [2 x i8] c"@\00"
+// GNUSTEP: @g5 = constant [12 x i8] c"^{Object=#}\00"
 const char g5[] = @encode(MyObj * const);
 
 
@@ -133,10 +136,12 @@
 
 @implementation Derived1X @end
 
-// CHECK: @g6 = constant [18 x i8] c"{Base1X=b2b3b4b5}\00"
+// MACOSX: @g6 = constant [18 x i8] c"{Base1X=b2b3b4b5}\00"
+// GNUSTEP: @g6 = constant [31 x i8] c"{Base1X=b0I2b2i3b5i4b9I5b16c0}\00"
 const char g6[] = @encode(Base1X);
 
-// CHECK: @g7 = constant [27 x i8] c"{Derived1X=b2b3b4b5b5b4b3}\00"
+// MACOSX: @g7 = constant [27 x i8] c"{Derived1X=b2b3b4b5b5b4b3}\00"
+// GNUSTEP: @g7 = constant [54 x i8] c"{Derived1X=b0I2b2i3b5i4b9I5b16c0b16i5b21i4b25i3b32c0}\00"
 const char g7[] = @encode(Derived1X);
 
 // CHECK: @g8 = constant [7 x i8] c"{s8=D}\00"
@@ -184,10 +189,10 @@
 typedef typeof(sizeof(int)) size_t;
 size_t strlen(const char *s);
 
-// CHECK-LABEL: @test_strlen(
-// CHECK: %[[i:.*]] = alloca i32
-// CHECK: %[[call:.*]] = call i32 @strlen
-// CHECK: store i32 %[[call]], i32* %[[i]]
+// MACOSX-LABEL: @test_strlen(
+// MACOSX: %[[i:.*]] = alloca i32
+// MACOSX: %[[call:.*]] = call i32 @strlen
+// MACOSX: store i32 %[[call]], i32* %[[i]]
 void test_strlen() {
   const char array[] = @encode(int);
   int i = strlen(array);
Index: test/CodeGenObjC/encode-test-6.m
===
--- test/CodeGenObjC/encode-test-6.m
+++ test/CodeGenObjC/encode-test-6.m
@@ -34,7 +34,7 @@
 @synthesize property = _property;
 @end
 
-// CHECK: private unnamed_addr constant [24 x i8] c"^{BABugExample=@}16
+// CHECK: private unnamed_addr constant [8 x i8] c"@16
 
 // rdar://14408244
 @class SCNCamera;
@@ -52,7 +52,7 @@
 C3DCameraStorage _storage;
 }
 @end
-// CHECK: private unnamed_addr constant [39 x i8] c"{?=\22presentationInstance\22^{SCNCamera}}\00"
+// CHECK: private unnamed_addr constant [39 x i8] 

[PATCH] D58920: [Modules][PR39287] Consolidate multiple std's

2019-05-15 Thread Brian Gesiak via Phabricator via cfe-commits
modocache updated this revision to Diff 199709.
modocache added a comment.

Oops, sent the patch from the wrong repository.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58920

Files:
  lib/Serialization/ASTReaderDecl.cpp
  test/Modules/Inputs/mod-virtual-destructor-bug-two/a.h
  test/Modules/Inputs/mod-virtual-destructor-bug-two/module.modulemap
  test/Modules/Inputs/mod-virtual-destructor-bug/a.h
  test/Modules/Inputs/mod-virtual-destructor-bug/module.modulemap
  test/Modules/mod-virtual-destructor-bug-two.cpp
  test/Modules/mod-virtual-destructor-bug.cpp


Index: test/Modules/mod-virtual-destructor-bug.cpp
===
--- /dev/null
+++ test/Modules/mod-virtual-destructor-bug.cpp
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++17 -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -I %S/Inputs/mod-virtual-destructor-bug %s -verify
+
+class A {
+  virtual ~A() {}
+};
+
+#include "a.h"
+
+namespace std { class type_info; }
+
+void foo() {
+  typeid(foo); // expected-warning {{expression result unused}}
+}
Index: test/Modules/mod-virtual-destructor-bug-two.cpp
===
--- /dev/null
+++ test/Modules/mod-virtual-destructor-bug-two.cpp
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++17 -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -I %S/Inputs/mod-virtual-destructor-bug-two %s -verify
+
+class A {
+  virtual ~A() {}
+};
+
+#include "a.h"
+
+void foo() {
+  typeid(foo); // expected-warning {{expression result unused}}
+}
Index: test/Modules/Inputs/mod-virtual-destructor-bug/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/mod-virtual-destructor-bug/module.modulemap
@@ -0,0 +1,3 @@
+module "a.h" {
+  header "a.h"
+}
Index: test/Modules/Inputs/mod-virtual-destructor-bug/a.h
===
--- /dev/null
+++ test/Modules/Inputs/mod-virtual-destructor-bug/a.h
@@ -0,0 +1 @@
+namespace std {}
Index: test/Modules/Inputs/mod-virtual-destructor-bug-two/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/mod-virtual-destructor-bug-two/module.modulemap
@@ -0,0 +1,3 @@
+module "a.h" {
+  header "a.h"
+}
Index: test/Modules/Inputs/mod-virtual-destructor-bug-two/a.h
===
--- /dev/null
+++ test/Modules/Inputs/mod-virtual-destructor-bug-two/a.h
@@ -0,0 +1 @@
+namespace std { class type_info; }
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -47,6 +47,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Sema/IdentifierResolver.h"
+#include "clang/Sema/Sema.h"
 #include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/ContinuousRangeMap.h"
@@ -3401,6 +3402,14 @@
   return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
 TypedefNameForLinkage);
 }
+if (isa(D) && D->getName() == "std") {
+  auto StdPtr = Reader.getSema()->StdNamespace;
+  if (StdPtr.isValid() && !StdPtr.isOffset())
+if (auto *Std = cast_or_null(StdPtr.get(nullptr)))
+  if (isSameEntity(Std, D))
+return FindExistingResult(Reader, D, Std, AnonymousDeclNumber,
+  TypedefNameForLinkage);
+}
   } else {
 // Not in a mergeable context.
 return FindExistingResult(Reader);


Index: test/Modules/mod-virtual-destructor-bug.cpp
===
--- /dev/null
+++ test/Modules/mod-virtual-destructor-bug.cpp
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++17 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/mod-virtual-destructor-bug %s -verify
+
+class A {
+  virtual ~A() {}
+};
+
+#include "a.h"
+
+namespace std { class type_info; }
+
+void foo() {
+  typeid(foo); // expected-warning {{expression result unused}}
+}
Index: test/Modules/mod-virtual-destructor-bug-two.cpp
===
--- /dev/null
+++ test/Modules/mod-virtual-destructor-bug-two.cpp
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++17 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/mod-virtual-destructor-bug-two %s -verify
+
+class A {
+  virtual ~A() {}
+};
+
+#include "a.h"
+
+void foo() {
+  typeid(foo); // expected-warning {{expression result unused}}
+}
Index: test/Modules/Inputs/mod-virtual-destructor-bug/module.modulemap

[PATCH] D58920: [Modules][PR39287] Consolidate multiple std's

2019-05-15 Thread Brian Gesiak via Phabricator via cfe-commits
modocache updated this revision to Diff 199708.
modocache added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Thanks for the help, @rsmith! Your suggestions were spot-on. (It took me a 
little while to figure out why, even using the `LazyDeclPtr` directly, I was 
still triggering deserialization. It turns out `dump()` causes deserialization 
too -- whoops!)

> You should also change `FindExistingResult::~FindExistingResult` to update 
> `Sema::StdNamespace` to point to your newly-deserialized namespace if you 
> didn't find a prior declaration of it, so that `Sema::getStdNamespace()` 
> finds the deserialized namespace.

I haven't done this yet. I'm trying to think of a test case that would fail if 
this were not done properly -- or would there not be one?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58920

Files:
  lib/Target/X86/X86ISelLowering.cpp
  test/CodeGen/X86/vector-reduce-mul-widen.ll
  test/CodeGen/X86/vector-reduce-mul.ll

Index: test/CodeGen/X86/vector-reduce-mul.ll
===
--- test/CodeGen/X86/vector-reduce-mul.ll
+++ test/CodeGen/X86/vector-reduce-mul.ll
@@ -2465,36 +2465,37 @@
 ; AVX512BW-NEXT:vpandq %zmm3, %zmm0, %zmm0
 ; AVX512BW-NEXT:vpackuswb %zmm2, %zmm0, %zmm0
 ; AVX512BW-NEXT:vextracti128 $1, %ymm0, %xmm1
-; AVX512BW-NEXT:vpunpckhbw {{.*#+}} zmm2 = zmm0[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,24,24,25,25,26,26,27,27,28,28,29,29,30,30,31,31,40,40,41,41,42,42,43,43,44,44,45,45,46,46,47,47,56,56,57,57,58,58,59,59,60,60,61,61,62,62,63,63]
-; AVX512BW-NEXT:vpunpckhbw {{.*#+}} zmm4 = zmm1[8],zmm0[8],zmm1[9],zmm0[9],zmm1[10],zmm0[10],zmm1[11],zmm0[11],zmm1[12],zmm0[12],zmm1[13],zmm0[13],zmm1[14],zmm0[14],zmm1[15],zmm0[15],zmm1[24],zmm0[24],zmm1[25],zmm0[25],zmm1[26],zmm0[26],zmm1[27],zmm0[27],zmm1[28],zmm0[28],zmm1[29],zmm0[29],zmm1[30],zmm0[30],zmm1[31],zmm0[31],zmm1[40],zmm0[40],zmm1[41],zmm0[41],zmm1[42],zmm0[42],zmm1[43],zmm0[43],zmm1[44],zmm0[44],zmm1[45],zmm0[45],zmm1[46],zmm0[46],zmm1[47],zmm0[47],zmm1[56],zmm0[56],zmm1[57],zmm0[57],zmm1[58],zmm0[58],zmm1[59],zmm0[59],zmm1[60],zmm0[60],zmm1[61],zmm0[61],zmm1[62],zmm0[62],zmm1[63],zmm0[63]
-; AVX512BW-NEXT:vpmullw %zmm4, %zmm2, %zmm2
-; AVX512BW-NEXT:vpandq %zmm3, %zmm2, %zmm2
-; AVX512BW-NEXT:vpunpcklbw {{.*#+}} zmm0 = zmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,32,32,33,33,34,34,35,35,36,36,37,37,38,38,39,39,48,48,49,49,50,50,51,51,52,52,53,53,54,54,55,55]
-; AVX512BW-NEXT:vpunpcklbw {{.*#+}} zmm1 = zmm1[0],zmm0[0],zmm1[1],zmm0[1],zmm1[2],zmm0[2],zmm1[3],zmm0[3],zmm1[4],zmm0[4],zmm1[5],zmm0[5],zmm1[6],zmm0[6],zmm1[7],zmm0[7],zmm1[16],zmm0[16],zmm1[17],zmm0[17],zmm1[18],zmm0[18],zmm1[19],zmm0[19],zmm1[20],zmm0[20],zmm1[21],zmm0[21],zmm1[22],zmm0[22],zmm1[23],zmm0[23],zmm1[32],zmm0[32],zmm1[33],zmm0[33],zmm1[34],zmm0[34],zmm1[35],zmm0[35],zmm1[36],zmm0[36],zmm1[37],zmm0[37],zmm1[38],zmm0[38],zmm1[39],zmm0[39],zmm1[48],zmm0[48],zmm1[49],zmm0[49],zmm1[50],zmm0[50],zmm1[51],zmm0[51],zmm1[52],zmm0[52],zmm1[53],zmm0[53],zmm1[54],zmm0[54],zmm1[55],zmm0[55]
-; AVX512BW-NEXT:vpmullw %zmm1, %zmm0, %zmm0
-; AVX512BW-NEXT:vpandq %zmm3, %zmm0, %zmm0
-; AVX512BW-NEXT:vpackuswb %zmm2, %zmm0, %zmm0
-; AVX512BW-NEXT:vpunpckhbw {{.*#+}} zmm1 = zmm0[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,24,24,25,25,26,26,27,27,28,28,29,29,30,30,31,31,40,40,41,41,42,42,43,43,44,44,45,45,46,46,47,47,56,56,57,57,58,58,59,59,60,60,61,61,62,62,63,63]
-; AVX512BW-NEXT:vpunpcklbw {{.*#+}} zmm0 = zmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,32,32,33,33,34,34,35,35,36,36,37,37,38,38,39,39,48,48,49,49,50,50,51,51,52,52,53,53,54,54,55,55]
-; AVX512BW-NEXT:vpmullw %zmm1, %zmm0, %zmm0
-; AVX512BW-NEXT:vpandq %zmm3, %zmm0, %zmm0
+; AVX512BW-NEXT:vpunpckhbw {{.*#+}} xmm2 = xmm0[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
+; AVX512BW-NEXT:vpunpckhbw {{.*#+}} xmm3 = xmm1[8],xmm0[8],xmm1[9],xmm0[9],xmm1[10],xmm0[10],xmm1[11],xmm0[11],xmm1[12],xmm0[12],xmm1[13],xmm0[13],xmm1[14],xmm0[14],xmm1[15],xmm0[15]
+; AVX512BW-NEXT:vpmullw %xmm3, %xmm2, %xmm2
+; AVX512BW-NEXT:vmovdqa {{.*#+}} xmm3 = [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]
+; AVX512BW-NEXT:vpand %xmm3, %xmm2, %xmm2
+; AVX512BW-NEXT:vpmovzxbw {{.*#+}} xmm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero
+; AVX512BW-NEXT:vpmovzxbw {{.*#+}} xmm1 = xmm1[0],zero,xmm1[1],zero,xmm1[2],zero,xmm1[3],zero,xmm1[4],zero,xmm1[5],zero,xmm1[6],zero,xmm1[7],zero
+; AVX512BW-NEXT:vpmullw %xmm1, %xmm0, %xmm0
+; AVX512BW-NEXT:vpand %xmm3, %xmm0, %xmm0
+; AVX512BW-NEXT:vpackuswb %xmm2, %xmm0, %xmm0
+; AVX512BW-NEXT:vpunpckhbw {{.*#+}} xmm1 = 

[PATCH] D61722: [AST] Add RecoveryExpr; produce it on overload resolution failure and missing member.

2019-05-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I expect we'll want a `ContainsErrors` bit on `Stmt`, propagated similarly to 
the existing `InstantiationDependent` / `ContainsUnexpandedParameterPack` / ... 
bits. For example, the constant evaluator will want to quickly bail out of 
evaluating expressions and statements containing errors, and the error recovery 
`TreeTransform` that we perform to fix typos will want that too (and maybe 
could be able to fix other kinds of errors for which we build these error nodes 
eventually?).




Comment at: include/clang/AST/BuiltinTypes.def:265
+// a template.
+BUILTIN_TYPE(Recovery, RecoveryTy)
+

erik.pilkington wrote:
> Why are you creating a new type as opposed to just using DependentTy (sorta 
> like TypoExpr does)? It seems like if you want to recycle all the 
> dependence-propagating code in Sema, then you need to fall back to 
> DependentTy anyways, i.e. `1 + ` will have dependent type with 
> this patch, right?
> 
> 
Using `DependentTy` for `TypoExpr` is a mistake; it leads to all sorts of bad 
follow-on diagnostics incorrectly claiming that constructs have dependent types.

Rather than calling this `RecoveryTy`, I'd prefer to call it something a bit 
more general like `ErrorTy`, with the intent being that we eventually use it 
for `TypoExpr` too.



Comment at: include/clang/AST/Expr.h:5801-5809
+/// RecoveryExpr - a broken expression that we couldn't construct an AST for,
+/// e.g. because overload resolution failed.
+/// We capture:
+///  - the kind of expression that would have been produced
+///  - the valid subexpressions
+///  - the type, if known. If unknown, it is the built-in RecoveryTy, which
+///is dependent (and so generally suppresses further diagnostics etc).

Do we need this at all, if we have a properly-propagated `ErrorTy` anyway? 
Instead of using this, it would seem that we could model an ill-formed 
expression as the corresponding AST node but with its type set to `ErrorTy`. 
Presumably the latter is what  we'll do when we find a subexpression containing 
an error, rather than creating a `RecoveryExpr` at every enclosing syntactic 
level, so AST clients will need to deal with that anyway.



Comment at: include/clang/AST/Type.h:2423-2424
+  : Type(Builtin, QualType(),
+ /*Dependent=*/(K == Dependent || K == Recovery),
+ /*InstantiationDependent=*/(K == Dependent || K == Recovery),
  /*VariablyModified=*/false,

Experience with `TypoExpr` suggests that treating non-dependent constructs as 
dependent is a mistake in the long term.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61722



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


[PATCH] D61756: Add a __FILE_NAME__ macro.

2019-05-15 Thread Kristina Brooks via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360833: [Clang][PP] Add the __FILE_NAME__ builtin macro. 
(authored by kristina, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D61756

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/PPMacroExpansion.cpp
  test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
  test/Preprocessor/Inputs/include-subdir/h
  test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h
  test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h
  test/Preprocessor/file_name_macro.c

Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -363,6 +363,7 @@
   }
 
   // Clang Extensions.
+  Ident__FILE_NAME__  = RegisterBuiltinMacro(*this, "__FILE_NAME__");
   Ident__has_feature  = RegisterBuiltinMacro(*this, "__has_feature");
   Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension");
   Ident__has_builtin  = RegisterBuiltinMacro(*this, "__has_builtin");
@@ -1474,7 +1475,8 @@
 // __LINE__ expands to a simple numeric value.
 OS << (PLoc.isValid()? PLoc.getLine() : 1);
 Tok.setKind(tok::numeric_constant);
-  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) {
+  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ ||
+ II == Ident__FILE_NAME__) {
 // C99 6.10.8: "__FILE__: The presumed name of the current source file (a
 // character string literal)". This can be affected by #line.
 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
@@ -1495,7 +1497,21 @@
 // Escape this filename.  Turn '\' -> '\\' '"' -> '\"'
 SmallString<128> FN;
 if (PLoc.isValid()) {
-  FN += PLoc.getFilename();
+  // __FILE_NAME__ is a Clang-specific extension that expands to the
+  // the last part of __FILE__.
+  if (II == Ident__FILE_NAME__) {
+// Try to get the last path component.
+StringRef PLFileName = PLoc.getFilename(); 
+size_t LastSep = PLFileName.find_last_of('/');
+// Skip the separator and get the last part, otherwise fall back on
+// returning the original full filename.
+if (LastSep != StringRef::npos)
+  FN += PLFileName.substr(LastSep+1);
+else
+  FN += PLFileName;
+  } else {
+FN += PLoc.getFilename();
+  }
   Lexer::Stringify(FN);
   OS << '"' << FN << '"';
 }
Index: include/clang/Lex/Preprocessor.h
===
--- include/clang/Lex/Preprocessor.h
+++ include/clang/Lex/Preprocessor.h
@@ -147,6 +147,7 @@
   IdentifierInfo *Ident__DATE__, *Ident__TIME__;   // __DATE__, __TIME__
   IdentifierInfo *Ident__INCLUDE_LEVEL__;  // __INCLUDE_LEVEL__
   IdentifierInfo *Ident__BASE_FILE__;  // __BASE_FILE__
+  IdentifierInfo *Ident__FILE_NAME__;  // __FILE_NAME__
   IdentifierInfo *Ident__TIMESTAMP__;  // __TIMESTAMP__
   IdentifierInfo *Ident__COUNTER__;// __COUNTER__
   IdentifierInfo *Ident_Pragma, *Ident__pragma;// _Pragma, __pragma
Index: test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h
===
--- test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h
+++ test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h
@@ -0,0 +1 @@
+8: __FILE_NAME__
Index: test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h
===
--- test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h
+++ test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h
@@ -0,0 +1 @@
+7: __FILE_NAME__
Index: test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
===
--- test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
+++ test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
@@ -0,0 +1,6 @@
+3: __FILE_NAME__
+4: "file_name_macro_include.h"
+#ifdef MS
+// Should be the same even when included with backslash.
+5: __FILE_NAME__
+#endif
Index: test/Preprocessor/Inputs/include-subdir/h
===
--- test/Preprocessor/Inputs/include-subdir/h
+++ test/Preprocessor/Inputs/include-subdir/h
@@ -0,0 +1 @@
+6: __FILE_NAME__
Index: test/Preprocessor/file_name_macro.c
===
--- test/Preprocessor/file_name_macro.c
+++ test/Preprocessor/file_name_macro.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -E %s -I%S/Inputs | FileCheck -strict-whitespace %s
+// RUN: %clang_cc1 -fms-compatibility -DMS -E %s -I%S/Inputs | FileCheck -check-prefix=CHECK-MS -strict-whitespace %s 
+// RUN: %clang_cc1 -E %s -I%S/Inputs -DBADINC -verify
+
+#ifdef 

r360833 - [Clang][PP] Add the __FILE_NAME__ builtin macro.

2019-05-15 Thread Kristina Brooks via cfe-commits
Author: kristina
Date: Wed May 15 17:52:41 2019
New Revision: 360833

URL: http://llvm.org/viewvc/llvm-project?rev=360833=rev
Log:
[Clang][PP] Add the __FILE_NAME__ builtin macro.

This patch adds the `__FILE_NAME__` macro that expands to the
last component of the path, similar to `__FILE__` except with
a guarantee that only the last path component (without the
separator) will be rendered.

I intend to follow through with discussion of this with WG14
as a potential inclusion in the C standard or failing that,
try to discuss this with GCC developers since this extension
is desired by GCC and Clang users/developers alike.

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


Added:
cfe/trunk/test/Preprocessor/Inputs/include-subdir/
cfe/trunk/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
cfe/trunk/test/Preprocessor/Inputs/include-subdir/h
cfe/trunk/test/Preprocessor/Inputs/include-subdir/subdir1/
cfe/trunk/test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h
cfe/trunk/test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h
cfe/trunk/test/Preprocessor/file_name_macro.c
Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/PPMacroExpansion.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=360833=360832=360833=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed May 15 17:52:41 2019
@@ -147,6 +147,7 @@ class Preprocessor {
   IdentifierInfo *Ident__DATE__, *Ident__TIME__;   // __DATE__, __TIME__
   IdentifierInfo *Ident__INCLUDE_LEVEL__;  // __INCLUDE_LEVEL__
   IdentifierInfo *Ident__BASE_FILE__;  // __BASE_FILE__
+  IdentifierInfo *Ident__FILE_NAME__;  // __FILE_NAME__
   IdentifierInfo *Ident__TIMESTAMP__;  // __TIMESTAMP__
   IdentifierInfo *Ident__COUNTER__;// __COUNTER__
   IdentifierInfo *Ident_Pragma, *Ident__pragma;// _Pragma, __pragma

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=360833=360832=360833=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed May 15 17:52:41 2019
@@ -363,6 +363,7 @@ void Preprocessor::RegisterBuiltinMacros
   }
 
   // Clang Extensions.
+  Ident__FILE_NAME__  = RegisterBuiltinMacro(*this, "__FILE_NAME__");
   Ident__has_feature  = RegisterBuiltinMacro(*this, "__has_feature");
   Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension");
   Ident__has_builtin  = RegisterBuiltinMacro(*this, "__has_builtin");
@@ -1474,7 +1475,8 @@ void Preprocessor::ExpandBuiltinMacro(To
 // __LINE__ expands to a simple numeric value.
 OS << (PLoc.isValid()? PLoc.getLine() : 1);
 Tok.setKind(tok::numeric_constant);
-  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) {
+  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ ||
+ II == Ident__FILE_NAME__) {
 // C99 6.10.8: "__FILE__: The presumed name of the current source file (a
 // character string literal)". This can be affected by #line.
 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
@@ -1495,7 +1497,21 @@ void Preprocessor::ExpandBuiltinMacro(To
 // Escape this filename.  Turn '\' -> '\\' '"' -> '\"'
 SmallString<128> FN;
 if (PLoc.isValid()) {
-  FN += PLoc.getFilename();
+  // __FILE_NAME__ is a Clang-specific extension that expands to the
+  // the last part of __FILE__.
+  if (II == Ident__FILE_NAME__) {
+// Try to get the last path component.
+StringRef PLFileName = PLoc.getFilename(); 
+size_t LastSep = PLFileName.find_last_of('/');
+// Skip the separator and get the last part, otherwise fall back on
+// returning the original full filename.
+if (LastSep != StringRef::npos)
+  FN += PLFileName.substr(LastSep+1);
+else
+  FN += PLFileName;
+  } else {
+FN += PLoc.getFilename();
+  }
   Lexer::Stringify(FN);
   OS << '"' << FN << '"';
 }

Added: 
cfe/trunk/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h?rev=360833=auto
==
--- cfe/trunk/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h 
(added)
+++ cfe/trunk/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h 
Wed May 15 17:52:41 2019
@@ -0,0 +1,6 @@
+3: __FILE_NAME__
+4: "file_name_macro_include.h"
+#ifdef MS
+// Should be the same 

Re: r360637 - PR41817: Fix regression in r359260 that caused the MS compatibility

2019-05-15 Thread Richard Smith via cfe-commits
On Wed, 15 May 2019 at 15:54, Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> *From: *Hans Wennborg 
> *Date: *Wed, May 15, 2019 at 1:22 AM
>
>> On Tue, May 14, 2019 at 6:35 PM Richard Smith 
>> wrote:
>> > Yep, I'm not at all surprised. Perhaps we should stop claiming to
>> support this extension, given that it fundamentally violates assumptions
>> made by clang (that linkage doesn't change after the first declaration).
>> Presumably we instead used to miscompile the example you give above (and
>> after the revert, miscompile it again now)?
>>
>> Maybe rnk has opinions too, but if we can get away with it, I think it
>> would be nice if we could not claim to support this, maybe not error
>> but dropping the static redeclaration of 'a' above with a warning. We
>> could fix Chromium's code, maybe we can poke MS to fix the midl
>> generated code, and maybe Firefox and others can work around the
>> duplicate symbol error in PR41871 by passing "/client none" to
>> midl.exe in the meantime.
>>
>> For my reduction above, I think we used to:
>> - in clang 8, emit a with internal linkage (getting it right through
>> luck somehow?)
>> - after r359259, emit it with external linkage (causing PR41871,
>> breaking Firefox)
>> - after r360637, assert
>>
>
> The files are generated by the most up to date MIDL compiler, 8.0.1, and I
> think it would be good to maintain compatibility with it until it a bug fix
> is released.
>
> It looks like MSVC gives an extern global turned-static static linkage in
> C mode, and external linkage in C++ mode. It doesn't even agree with
> itself. =/
>
> $ cat t.cpp
> typedef struct Foo { int x,y; } Foo;
> extern const Foo my_global;
> static const Foo my_global = { 1, 2 };
>
> $ cl -nologo -TC -c t.cpp && dumpbin -symbols t.obj | grep my_global
> t.cpp
> 008  SECT3  notype   Static   | my_global
>
> $ cl -nologo -TP -c t.cpp && dumpbin -symbols t.obj | grep my_global
> t.cpp
> 008  SECT3  notype   External | ?my_global@@3UFoo@@B
> (struct Foo const my_global)
>
> So, I think in C++ mode, MSVC just ignores the second static.
>
> We could probably re-land Richard's change (although it's quite a lot of
> code...), but... drop the conflicting `static` on the floor
> if hasLinkageBeenComputed() returns true. That would work around the
> assert, right?
>

Yes, that seems like it could work, though I really don't like our
generated code depending on when we happen to compute linkage. In the MIDL
case, are there any uses of the global between the 'extern' declaration and
the 'static' declaration?


> Those are the best ideas I have so far. :)
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61756: Add a __FILE_NAME__ macro.

2019-05-15 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

Landing this as discussed on IRC, will try to push it forward with WG14.

I think having something like this as part of the standard would benefit a lot, 
since currently the "unofficial" way of doing this for either GCC or Clang 
involves several nonstandard builtins and `__FILE__` which causes difficulties 
in reproducible builds as code emitted in read only data sections may still 
differ depending on optimization levels and other factors. This macro on the 
other hand provides a guarantee that only the last path component is rendered.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61756



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


[PATCH] D61970: [CodeGen][ObjC] Call objc_autoreleaseReturnValue and objc_retainAutoreleasedReturnValue instead of objc_autorelease and objc_retain in MRR

2019-05-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: pete, rjmccall, erik.pilkington.
ahatanak added a project: clang.
Herald added subscribers: dexonsmith, jkorous.

This patch makes IRGen emit ObjC runtime functions 
(`objc_autoreleaseReturnValue` and `objc_retainAutoreleasedReturnValue`) that 
were previously emitted only in ARC mode. This enables retain message sends in 
MRR code to participate in the retainRV/autoreleaseRV handshake, which keeps 
returned objects out of the autorelease pool. Also, it enables the ARC 
optimizer and ARC contract pass to remove retain/autorelease pairs and mark 
autorelease message sends converted to autoreleaseRV calls as tail calls, which 
is necessary for the retainRV/autoreleaseRV handshake to succeed.

rdar://problem/50353574


Repository:
  rC Clang

https://reviews.llvm.org/D61970

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Driver/Options.td
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenObjC/convert-messages-to-runtime-calls.m

Index: test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- test/CodeGenObjC/convert-messages-to-runtime-calls.m
+++ test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -1,12 +1,13 @@
 // RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s -fno-objc-convert-messages-to-runtime-calls -fobjc-exceptions -fexceptions | FileCheck %s --check-prefix=MSGS
-// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s -fobjc-exceptions -fexceptions | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s -fobjc-exceptions -fexceptions | FileCheck %s --check-prefix=CALLS --check-prefix=CALLS-ARC-INTRINSICS
 // RUN: %clang_cc1 -fobjc-runtime=macosx-10.9.0 -emit-llvm -o - %s -fobjc-exceptions -fexceptions | FileCheck %s --check-prefix=MSGS
 // RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.10.0 -emit-llvm -o - %s -fobjc-exceptions -fexceptions | FileCheck %s --check-prefix=MSGS
-// RUN: %clang_cc1 -fobjc-runtime=ios-8.0 -emit-llvm -o - %s -fobjc-exceptions -fexceptions | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=ios-8.0 -emit-llvm -o - %s -fobjc-exceptions -fexceptions | FileCheck %s --check-prefix=CALLS --check-prefix=CALLS-ARC-INTRINSICS
 // RUN: %clang_cc1 -fobjc-runtime=ios-7.0 -emit-llvm -o - %s -fobjc-exceptions -fexceptions | FileCheck %s --check-prefix=MSGS
 // Note: This line below is for tvos for which the driver passes through to use the ios9.0 runtime.
-// RUN: %clang_cc1 -fobjc-runtime=ios-9.0 -emit-llvm -o - %s -fobjc-exceptions -fexceptions | FileCheck %s --check-prefix=CALLS
-// RUN: %clang_cc1 -fobjc-runtime=watchos-2.0 -emit-llvm -o - %s -fobjc-exceptions -fexceptions | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=ios-9.0 -emit-llvm -o - %s -fobjc-exceptions -fexceptions | FileCheck %s --check-prefix=CALLS --check-prefix=CALLS-ARC-INTRINSICS
+// RUN: %clang_cc1 -fobjc-runtime=watchos-2.0 -emit-llvm -o - %s -fobjc-exceptions -fexceptions | FileCheck %s --check-prefix=CALLS --check-prefix=CALLS-ARC-INTRINSICS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s -fobjc-exceptions -fexceptions -fobjc-no-builtin-retain-release | FileCheck %s --check-prefix=CALLS --check-prefix=CALLS-NO-ARC-INTRINSICS
 
 #define nil (id)0
 
@@ -28,9 +29,11 @@
   // MSGS: {{call.*@objc_msgSend}}
   // CALLS: {{call.*@objc_alloc}}
   // CALLS: {{call.*@objc_allocWithZone}}
-  // CALLS: {{call.*@objc_retain}}
+  // CALLS-ARC-INTRINSICS: {{call.*@llvm.objc.retainAutoreleasedReturnValue}}
+  // CALLS-NO-ARC-INTRINSICS: {{call.*@objc_retain}}
   // CALLS: {{call.*@objc_release}}
-  // CALLS: {{call.*@objc_autorelease}}
+  // CALLS-ARC-INTRINSICS: {{call.*@llvm.objc.autoreleaseReturnValue}}
+  // CALLS-NO-ARC-INTRINSICS: {{call.*@objc_autorelease}}
   [NSObject alloc];
   [NSObject allocWithZone:nil];
   [x retain];
@@ -111,7 +114,8 @@
 // call will return i8* which we have to cast to A*
 // CHECK-LABEL: define {{.*}}void @test_retain_class_ptr
 A* test_retain_class_ptr(B *b) {
-  // CALLS: {{call.*@objc_retain}}
+  // CALLS-ARC-INTRINSICS: {{call.*@llvm.objc.retainAutoreleasedReturnValue}}
+  // CALLS-NO-ARC-INTRINSICS: {{call.*@objc_retain}}
   // CALLS-NEXT: bitcast i8*
   // CALLS-NEXT: ret
   return [b retain];
@@ -121,7 +125,8 @@
 // call will return i8* which we have to cast to A*
 // CHECK-LABEL: define {{.*}}void @test_autorelease_class_ptr
 A* test_autorelease_class_ptr(B *b) {
-  // CALLS: {{call.*@objc_autorelease}}
+  // CALLS-ARC-INTRINSICS: {{call.*@llvm.objc.autoreleaseReturnValue}}
+  // CALLS-NO-ARC-INTRINSICS: {{call.*@objc_autorelease}}
   // CALLS-NEXT: bitcast i8*
   // CALLS-NEXT: ret
   return [b autorelease];
@@ -161,7 +166,8 @@
 // CHECK-LABEL: define {{.*}}void @retain_self
 + (void)retain_self {
   // MSGS: 

[PATCH] D61756: Add a __FILE_NAME__ macro.

2019-05-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a subscriber: alexr.
rsmith added a comment.

Generally, I think this is a good, useful feature, but there's one point from 
http://clang.llvm.org/get_involved.html 's checklist for accepting language 
extensions on which its case is weak, as reflected by this feedback from @alexr 
on D17741 :

> I don't think we want to add a fundamental new preprocessor feature like 
> `__FILE_BASENAME__` without at least getting some early buy-in from the WG14 
> and WG21 committees.

Specifically: have you suggested this feature on the WG14 or WG21 mailing 
lists? I'm not especially opposed to carrying this feature as a Clang 
extension, but from http://clang.llvm.org/get_involved.html, "Clang should 
drive the standard, not diverge from it", and we should at least try to push 
for standardizing this if we think it's worthwhile as an alternative to 
`__FILE__`.

Failing that, have you asked the GCC developers whether they'd be amenable to 
providing this functionality?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61756



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


[PATCH] D61722: [AST] Add RecoveryExpr; produce it on overload resolution failure and missing member.

2019-05-15 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a reviewer: erik.pilkington.
erik.pilkington added inline comments.
Herald added a subscriber: dexonsmith.



Comment at: include/clang/AST/BuiltinTypes.def:265
+// a template.
+BUILTIN_TYPE(Recovery, RecoveryTy)
+

Why are you creating a new type as opposed to just using DependentTy (sorta 
like TypoExpr does)? It seems like if you want to recycle all the 
dependence-propagating code in Sema, then you need to fall back to DependentTy 
anyways, i.e. `1 + ` will have dependent type with this patch, 
right?





Comment at: lib/Sema/SemaOverload.cpp:12248
+  SubExprs.append(Args.begin(), Args.end());
+  if (auto RE = RecoveryExpr::Create(
+ SemaRef.Context, chooseRecoveryType(*CandidateSet, Best),

Have you also considered handling this like delayed typos, where we try to 
TreeTransform into different possible recoveries later, in order to find out 
what the best fix is? You might be able to make a better guess as to what the 
right function to pick (or how to recover in general) is if you can see how the 
recovery would be used, but deciding here means you have a lot less information.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61722



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


r360827 - Make tentative parsing to detect template-argument-lists less aggressive

2019-05-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed May 15 16:36:14 2019
New Revision: 360827

URL: http://llvm.org/viewvc/llvm-project?rev=360827=rev
Log:
Make tentative parsing to detect template-argument-lists less aggressive
(and less wrong).

It's not correct to assume that X is always a
template-id; there are a few cases where the comma takes us into a
non-expression syntactic context in which 'Type' might be permissible.
Stop doing that.

This slightly regresses our error recovery on the cases where the
construct is intended to be a template-id. We typically do still manage
to diagnose a missing 'template' keyword, but we realize this too late
to properly recover from the error.

This fixes a regression introduced by r360308.

Modified:
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/test/Parser/cxx-template-argument.cpp
cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp

Modified: cfe/trunk/lib/Parse/ParseTentative.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=360827=360826=360827=diff
==
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Wed May 15 16:36:14 2019
@@ -2065,33 +2065,31 @@ Parser::TPResult Parser::isTemplateArgum
   if (!TryConsumeToken(tok::less))
 return TPResult::False;
 
+  // We can't do much to tell an expression apart from a template-argument,
+  // but one good distinguishing factor is that a "decl-specifier" not
+  // followed by '(' or '{' can't appear in an expression.
   bool InvalidAsTemplateArgumentList = false;
-  while (true) {
-// We can't do much to tell an expression apart from a template-argument,
-// but one good distinguishing factor is that a "decl-specifier" not
-// followed by '(' or '{' can't appear in an expression.
-if (isCXXDeclarationSpecifier(
-TPResult::False, ) == TPResult::True)
-  return TPResult::True;
-
-// That didn't help, try the next template-argument.
-SkipUntil({tok::comma, tok::greater, tok::greatergreater,
-   tok::greatergreatergreater},
-  StopAtSemi | StopBeforeMatch);
-switch (Tok.getKind()) {
-case tok::comma:
-  ConsumeToken();
-  break;
+  if (isCXXDeclarationSpecifier(TPResult::False,
+   ) ==
+ TPResult::True)
+return TPResult::True;
+  if (InvalidAsTemplateArgumentList)
+return TPResult::False;
 
-case tok::greater:
-case tok::greatergreater:
-case tok::greatergreatergreater:
-  if (InvalidAsTemplateArgumentList)
-return TPResult::False;
-  return TPResult::Ambiguous;
+  // FIXME: In many contexts, X can only be a
+  // template-argument-list. But that's not true in general:
+  //
+  // using b = int;
+  // void f() {
+  //   int a = AD; // OK, declares b, not a template-id.
+  //
+  // X // ', int>' might be end of X's template argument list
+  //
+  // We might be able to disambiguate a few more cases if we're careful.
 
-default:
-  return TPResult::False;
-}
-  }
+  // A template-argument-list must be terminated by a '>'.
+  if (SkipUntil({tok::greater, tok::greatergreater, 
tok::greatergreatergreater},
+StopAtSemi | StopBeforeMatch))
+return TPResult::Ambiguous;
+  return TPResult::False;
 }

Modified: cfe/trunk/test/Parser/cxx-template-argument.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-template-argument.cpp?rev=360827=360826=360827=diff
==
--- cfe/trunk/test/Parser/cxx-template-argument.cpp (original)
+++ cfe/trunk/test/Parser/cxx-template-argument.cpp Wed May 15 16:36:14 2019
@@ -127,3 +127,14 @@ namespace PR18793 {
   template struct S {};
   template int g(S *);
 }
+
+namespace r360308_regression {
+  template struct S1 { static int const n = 0; };
+  template struct S2 { typedef int t; };
+  template struct S3 { typename S2::n < 0, int>::t n; };
+
+  template bool f(FT p) {
+const bool a = p.firstFT(0);
+return a == b;
+  }
+}

Modified: cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp?rev=360827=360826=360827=diff
==
--- cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp (original)
+++ cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp Wed May 15 
16:36:14 2019
@@ -7,7 +7,7 @@ struct X {
 
 t->operator+(1); // expected-error{{use 'template' keyword to 
treat 'operator +' as a dependent template name}}
 t->f1(1); // expected-error{{use 'template' keyword to treat 
'f1' as a dependent template name}}
-t->f1<3, int const>(1); // expected-error{{use 'template' keyword to treat 
'f1' as a dependent template name}}
+t->f1<3, int const>(1); // 

[PATCH] D58321: Support for relative vtables

2019-05-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:531
+/// \brief Whether the class uses the relative C++ vtable ABI.
+unsigned IsRelativeCXXABI : 1;
+

pcc wrote:
> rjmccall wrote:
> > Should we proactively generalize this as a "CXXABIVariant" enum, which for 
> > now can just be "Standard" and "RelativeVTables"?
> > 
> > Also, I don't want to pre-empt your secret plans, but if Fuchsia is just 
> > going to use this as its system C++ ABI, maybe we should plan for that, too.
> At this point I probably would remove this bitfield entirely. This 
> implementation does not support enabling the ABI on a per-class basis, so 
> everywhere that we are currently checking this field we should just be able 
> to check `RelativeCXXABIVTables` in `LangOptions`.
The goal for us is to just enable this for all vtables so we don't need this on 
a per-class basis. Removed the bitfield.



Comment at: clang/include/clang/Basic/LangOptions.def:329
+"Whether to use clang's relative C++ ABI "
+"for classes with vtables")
+

rjmccall wrote:
> Yeah, see, this plays into the question above.  I would not want to provide 
> this as a language option for general use.  The attribute seems good enough 
> for testing, and if you want a -cc1 option to apply the attribute by default 
> for experimentation during Fuchsia bring-up that's fair, but I don't want 
> something that suggests to users that it's okay to pass this attribute and 
> change the system default.
Ok. So is this the reason for the white list approach mentioned in D17893? As 
an alternative, would you also be ok with creating a `FuchsiaCXXABI` that 
subclasses `ItaniumCXXABI`, similar to the ARM and WebAssembly ones? This way 
it doesn't change the system default.



Comment at: clang/include/clang/Sema/Sema.h:10976
+  /// Determine if this class can use the relative vtable ABI.
+  void checkClassABI(CXXRecordDecl *RD);
+

rjmccall wrote:
> Comment / method-name mismatch?
Removed this method since the bitfield we set here is removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58321



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


[PATCH] D58321: Support for relative vtables

2019-05-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 199696.
leonardchan marked 5 inline comments as done.
leonardchan added a reviewer: rjmccall.
leonardchan removed a subscriber: rjmccall.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58321

Files:
  clang/include/clang/AST/VTableBuilder.h
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/DeclCXX.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CGVTables.h
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/debug-info-virtual-fn-relative.cpp
  clang/test/CodeGenCXX/vtable-relative-abi.cpp
  llvm/lib/IR/Constants.cpp

Index: llvm/lib/IR/Constants.cpp
===
--- llvm/lib/IR/Constants.cpp
+++ llvm/lib/IR/Constants.cpp
@@ -495,6 +495,35 @@
   return false;
 }
 
+/// Returns true if this constant mathes the relative referencing for virtual
+/// functions introduced in the relative ABI. This is the difference between a
+/// function and its corresponding vtable entry.
+///
+/// i64 sub (
+///   i64 ptrtoint (i8* obj to i64),
+//i64 ptrtoint (
+//  i32* getelementptr inbounds (%object_vtable, %object_vtable*
+//@_ZTV12derived_virt, i32 0, i32 0, i32 2) to i64)
+static bool MatchesRelativeOffset(const Constant *C) {
+  const auto *CE = dyn_cast(C);
+  if (!CE || CE->getOpcode() != Instruction::Sub)
+return false;
+
+  const auto *LHS = dyn_cast(CE->getOperand(0));
+  const auto *RHS = dyn_cast(CE->getOperand(1));
+  if (!LHS || !RHS || LHS->getOpcode() != Instruction::PtrToInt ||
+  RHS->getOpcode() != Instruction::PtrToInt)
+return false;
+
+  RHS = dyn_cast(RHS->getOperand(0));
+  if (!RHS)
+return false;
+
+  return (isa(LHS->getOperand(0)) &&
+  RHS->getOpcode() == Instruction::GetElementPtr &&
+  isa(RHS->getOperand(0)));
+}
+
 bool Constant::needsRelocation() const {
   if (isa(this))
 return true; // Global reference.
@@ -519,6 +548,10 @@
 return false;
 }
 
+  // This results in an R_PLT_PC reloc which can be computed at link time.
+  if (MatchesRelativeOffset(this))
+return false;
+
   bool Result = false;
   for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
 Result |= cast(getOperand(i))->needsRelocation();
Index: clang/test/CodeGenCXX/vtable-relative-abi.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/vtable-relative-abi.cpp
@@ -0,0 +1,117 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -fexperimental-relative-c++-abi-vtables -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ITANIUM %s
+// RUN: %clang_cc1 %s -triple x86_64-unknown-windows-msvc -fexperimental-relative-c++-abi-vtables -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MS %s
+
+// CHECK-ITANIUM: @_ZTV1S = unnamed_addr constant { { i8*, i8*, i32, i32 } } { { i8*, i8*, i32, i32 } { i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1S to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f1Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i8*, i32, i32 } }, { { i8*, i8*, i32, i32 } }* @_ZTV1S, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f2Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i8*, i32, i32 } }, { { i8*, i8*, i32, i32 } }* @_ZTV1S, i32 0, i32 0, i32 2) to i64)) to i32) } }, align 8
+// CHECK-MS: @0 = private unnamed_addr constant { { i8*, i32, i32 } } { { i8*, i32, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"??_R4S@@6B@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"?f1@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i32, i32 } }, { { i8*, i32, i32 } }* @0, i32 0, i32 0, i32 1) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"?f2@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i32, i32 } }, { { i8*, i32, i32 } }* @0, i32 0, i32 0, i32 1) to i64)) to i32) } }, comdat($"??_7S@@6B@")
+
+struct S {
+  S();
+  virtual void f1();
+  virtual void f2();
+};
+
+// CHECK-ITANIUM: @_ZTV1T = unnamed_addr constant { { i8*, i8*, i32 } } { { i8*, i8*, i32 } { i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1T to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @_ZN1T1gEv to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i8*, i32 } }, { { i8*, i8*, i32 } }* @_ZTV1T, i32 0, i32 0, i32 2) to i64)) to i32) } }, align 8
+// CHECK-MS: @1 = private unnamed_addr constant { { i8*, i32 } } { { i8*, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"??_R4T@@6B@" to i8*), i32 trunc (i64 

[PATCH] D61967: [clang-tidy] Add a close-on-exec check on pipe() in Android module.

2019-05-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst:4
+android-cloexec-pipe
+==
+

Please make same length as name above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61967



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


[PATCH] D61967: [clang-tidy] Add a close-on-exec check on pipe() in Android module.

2019-05-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst:6
+
+The usage of ``pipe()`` is not recommended, it's better to use ``pipe2()``.
+Without this flag, an opened sensitive file descriptor would remain open across

Please make first sentence same as in Release Notes.



Comment at: clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst:8
+Without this flag, an opened sensitive file descriptor would remain open across
+a fork+exec to a lower-privileged SELinux domain.
+

I think will be good idea to highlight fork and exec with double back-ticks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61967



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


[PATCH] D61967: [clang-tidy] Add a close-on-exec check on pipe() in Android module.

2019-05-15 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

Thanks for this!

I don't have great context on tidy, so I can't stamp this, but I do have a few 
drive-by nits for you.




Comment at: clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp:22
+   functionDecl(returns(isInteger()), hasName("pipe"),
+//hasParameter(0, 
hasType(constantArrayType(hasElementType(isInteger()), hasSize(2)
+hasParameter(0, 
hasType(pointsTo(isInteger());

We probably don't want to commit commented out code



Comment at: clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp:27
+void CloexecPipeCheck::check(const MatchFinder::MatchResult ) {
+  const std::string  =
+  (Twine("pipe2(") + getSpellingArg(Result, 0) + ", O_CLOEXEC)").str();

simplicity nit: can this be a `std::string`?



Comment at: clang-tools-extra/clang-tidy/android/CloexecPipeCheck.h:18
+
+/// accept() is better to be replaced by accept4().
+///

nit: should probably update this comment



Comment at: clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp:9
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer pipe2() to pipe() because 
pipe2() allows O_CLOEXEC [android-cloexec-pipe]
+  // CHECK-FIXES: pipe2(pipefd, O_CLOEXEC);
+}

(Do we have a CHECK-FIXES-NOT or CHECK-MESSAGES-NOT to apply to the things 
below? Or are the CHECKs here meant to be complete like clang's `-verify`?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61967



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


Re: r360637 - PR41817: Fix regression in r359260 that caused the MS compatibility

2019-05-15 Thread Reid Kleckner via cfe-commits
*From: *Hans Wennborg 
*Date: *Wed, May 15, 2019 at 1:22 AM

> On Tue, May 14, 2019 at 6:35 PM Richard Smith 
> wrote:
> > Yep, I'm not at all surprised. Perhaps we should stop claiming to
> support this extension, given that it fundamentally violates assumptions
> made by clang (that linkage doesn't change after the first declaration).
> Presumably we instead used to miscompile the example you give above (and
> after the revert, miscompile it again now)?
>
> Maybe rnk has opinions too, but if we can get away with it, I think it
> would be nice if we could not claim to support this, maybe not error
> but dropping the static redeclaration of 'a' above with a warning. We
> could fix Chromium's code, maybe we can poke MS to fix the midl
> generated code, and maybe Firefox and others can work around the
> duplicate symbol error in PR41871 by passing "/client none" to
> midl.exe in the meantime.
>
> For my reduction above, I think we used to:
> - in clang 8, emit a with internal linkage (getting it right through
> luck somehow?)
> - after r359259, emit it with external linkage (causing PR41871,
> breaking Firefox)
> - after r360637, assert
>

The files are generated by the most up to date MIDL compiler, 8.0.1, and I
think it would be good to maintain compatibility with it until it a bug fix
is released.

It looks like MSVC gives an extern global turned-static static linkage in C
mode, and external linkage in C++ mode. It doesn't even agree with itself.
=/

$ cat t.cpp
typedef struct Foo { int x,y; } Foo;
extern const Foo my_global;
static const Foo my_global = { 1, 2 };

$ cl -nologo -TC -c t.cpp && dumpbin -symbols t.obj | grep my_global
t.cpp
008  SECT3  notype   Static   | my_global

$ cl -nologo -TP -c t.cpp && dumpbin -symbols t.obj | grep my_global
t.cpp
008  SECT3  notype   External | ?my_global@@3UFoo@@B
(struct Foo const my_global)

So, I think in C++ mode, MSVC just ignores the second static.

We could probably re-land Richard's change (although it's quite a lot of
code...), but... drop the conflicting `static` on the floor
if hasLinkageBeenComputed() returns true. That would work around the
assert, right?

Those are the best ideas I have so far. :)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61967: [clang-tidy] Add a close-on-exec check on pipe() in Android module.

2019-05-15 Thread Jian Cai via Phabricator via cfe-commits
jcai19 created this revision.
jcai19 added reviewers: alexfh, chh.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.
Herald added a project: clang.

pipe() is better to be replaced by pipe2() with O_CLOEXEC flag to avoid file 
descriptor leakage.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61967

Files:
  clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp
  clang-tools-extra/clang-tidy/android/CMakeLists.txt
  clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp
  clang-tools-extra/clang-tidy/android/CloexecPipeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp

Index: clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s android-cloexec-pipe %t
+
+extern "C" int pipe(int pipefd[2]);
+
+void f() {
+  int pipefd[2];
+  pipe(pipefd);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer pipe2() to pipe() because pipe2() allows O_CLOEXEC [android-cloexec-pipe]
+  // CHECK-FIXES: pipe2(pipefd, O_CLOEXEC);
+}
+
+namespace i {
+int pipe(int pipefd[2]);
+void g() {
+  int pipefd[2];
+  pipe(pipefd);
+}
+} // namespace i
+
+class C {
+public:
+  int pipe(int pipefd[2]);
+  void h() {
+int pipefd[2];
+pipe(pipefd);
+  }
+};
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -32,6 +32,7 @@
android-cloexec-inotify-init1
android-cloexec-memfd-create
android-cloexec-open
+   android-cloexec-pipe
android-cloexec-socket
android-comparison-in-temp-failure-retry
boost-use-to-string
Index: clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-pipe
+
+android-cloexec-pipe
+==
+
+The usage of ``pipe()`` is not recommended, it's better to use ``pipe2()``.
+Without this flag, an opened sensitive file descriptor would remain open across
+a fork+exec to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  pipe(pipefd);
+
+  // becomes
+
+  pipe2(pipefd, O_CLOEXEC);
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -101,6 +101,11 @@
   Finds and fixes ``absl::Time`` subtraction expressions to do subtraction
   in the Time domain instead of the numeric domain.
 
+- New :doc:`android-cloexec-pipe
+  ` check.
+
+  Detects usage of ``pipe()``.
+
 - New :doc:`bugprone-unhandled-self-assignment
   ` check.
 
Index: clang-tools-extra/clang-tidy/android/CloexecPipeCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/android/CloexecPipeCheck.h
@@ -0,0 +1,34 @@
+//===--- CloexecPipeCheck.h - clang-tidy---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// accept() is better to be replaced by accept4().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-accept.html
+class CloexecPipeCheck : public CloexecCheck {
+public:
+  CloexecPipeCheck(StringRef Name, ClangTidyContext *Context)
+  : CloexecCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
Index: clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp
@@ -0,0 +1,38 @@
+//===--- CloexecPipeCheck.cpp - clang-tidy---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with 

[PATCH] D61756: Add a __FILE_NAME__ macro.

2019-05-15 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

@rsmith Ping.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61756



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


[PATCH] D59702: Unbreak the build of compiler-rt on Linux/mips64el

2019-05-15 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added a comment.

I hope the rL360825  fixes the problem so 
this patch can be switch to the `abandoned` state.


Repository:
  rCRT Compiler Runtime

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

https://reviews.llvm.org/D59702



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


[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-15 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D61909#1503642 , @winksaville wrote:

> Sorry, maybe I didn't make myself clear.


I understood you fine. I don't think you understand the guidance for building 
distributions of LLVM.

Distributions only get libclang_shared if they run the `install` target which 
installs all of LLVM & Clang. The point of `LLVM_DISTRIBUTION_COMPONENTS` is to 
allow people constructing distributions to choose which pieces they want to 
install without introducing a whole lot of overhead in the build system. The 
old method of passing dozens of flags to enable and disable individual pieces 
of the build resulted in a combinatoric explosion in build settings which are 
confusing and ill understood. The new method is one setting that is much 
cleaner to use.

Anyone constructing a distribution should be specifying 
`LLVM_DISTRIBUTION_COMPONENTS` and running the `install-distribution` target.

Given that your comment:

> What I meant was that this change currently uses `if(UNIX)` to generate 
> `libclang_shared.so`, which means "all linux distors" will have both 
> `libclang*.a` and `libclang_shared.so`.

Is only true if the distribution is choosing to run the `install` target, which 
doesn't grant control over all the individual pieces of LLVM & Clang to 
install, and is not the recommended way to construct a distribution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61909



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


[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-15 Thread Wink Saville via Phabricator via cfe-commits
winksaville added a comment.

In D61909#1503483 , @beanz wrote:

> In D61909#1503433 , @winksaville 
> wrote:
>
> > IMHO "`BUILD_CLANG_DYLIB`" is needed. As you have it now libclang_shared.so 
> > is always builds on UNIX systems, which I believe means that all linux 
> > distros would have both increasing their sizes.
>
>
> Distributions shouldn't be installing `all` unless they really want 
> everything and the kitchen sink. We have the `LLVM_DISTRIBUTION_COMPONENTS` 
> so that distributions can decide which pieces of the LLVM & Clang 
> distributions they want to install. That is the cleanest mechanism for 
> curating an install.


Sorry, maybe I didn't make myself clear. I didn't mean distros installing "all" 
of LLVM. What I meant was that this change currently uses `if(UNIX)` to 
generate `libclang_shared.so`, which means "all linux distors" will have both 
`libclang*.a` and `libclang_shared.so`. Therefore, I'm suggesting the need for 
something like "`BUILD_CLANG_DYLIB`" so that `libclang_shared.so` is only 
created when "`BUILD_CLANG_DYLIB`" is `ON` and the default is `OFF`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61909



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


[PATCH] D61722: Prototype of RecoveryExpr. Here, it's emitted when overload resolution fails.

2019-05-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 199678.
sammccall added a comment.
Herald added a subscriber: arphaman.

This should work for real now: handle types properly, make tests pass, add some 
tests.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61722

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/AST/Expr.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/Stmt.h
  include/clang/AST/TextNodeDumper.h
  include/clang/AST/Type.h
  include/clang/Basic/StmtNodes.td
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Stmt.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/AST/TextNodeDumper.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaPseudoObject.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
  test/CodeCompletion/member-access.cpp
  test/Index/getcursor-recovery.cpp
  test/SemaCXX/constructor-initializer.cpp
  test/SemaCXX/enable_if.cpp
  test/SemaTemplate/dependent-names.cpp
  test/SemaTemplate/instantiate-function-params.cpp
  test/SemaTemplate/instantiate-init.cpp
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -288,6 +288,7 @@
   case Stmt::ObjCDictionaryLiteralClass:
   case Stmt::ObjCBoxedExprClass:
   case Stmt::ObjCSubscriptRefExprClass:
+  case Stmt::RecoveryExprClass:
 K = CXCursor_UnexposedExpr;
 break;
 
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1516,6 +1516,7 @@
   case BuiltinType::Void:
   case BuiltinType::NullPtr:
   case BuiltinType::Dependent:
+  case BuiltinType::Recovery:
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
   case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
Index: test/SemaTemplate/instantiate-init.cpp
===
--- test/SemaTemplate/instantiate-init.cpp
+++ test/SemaTemplate/instantiate-init.cpp
@@ -100,9 +100,9 @@
 integral_c<1> ic1 = array_lengthof(Description::data);
 (void)sizeof(array_lengthof(Description::data));
 
-sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
-  Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}}
-  ));
+(void)sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
+Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}}
+));
 
 array_lengthof(Description::data); // expected-error{{no matching function for call to 'array_lengthof'}}
   }
Index: test/SemaTemplate/instantiate-function-params.cpp
===
--- test/SemaTemplate/instantiate-function-params.cpp
+++ test/SemaTemplate/instantiate-function-params.cpp
@@ -3,7 +3,7 @@
 // PR6619
 template struct if_c { };
 template struct if_ {
-  typedef if_c< static_cast(T1::value)> almost_type_; // expected-note 5{{in instantiation}}
+  typedef if_c< static_cast(T1::value)> type; // expected-note 5{{in instantiation}}
 };
 template  struct wrap_constraints { };
 template  
@@ -17,7 +17,9 @@
 template  struct requirement_;
 template  struct instantiate {
 };
-template  struct requirement_   : if_<   not_satisfied >::type { // expected-note 5{{in instantiation}}
+template 
+struct requirement_ : if_>::type { // expected-note 5{{in instantiation}}
+  static void failed();
 };
 template  struct usage_requirements {
 };
Index: test/SemaTemplate/dependent-names.cpp
===
--- test/SemaTemplate/dependent-names.cpp
+++ test/SemaTemplate/dependent-names.cpp
@@ -176,7 +176,7 @@
 void f(char&); // expected-note {{candidate function not viable}}
 
 template struct C {
-  static const int n = f(T()); // 

[PATCH] D61963: [clang][Darwin] Refactor header search path logic into the driver

2019-05-15 Thread Louis Dionne via Phabricator via cfe-commits
ldionne created this revision.
ldionne added reviewers: jfb, arphaman.
Herald added subscribers: cfe-commits, jsji, dexonsmith, jkorous, christof, 
kbarton, javed.absar, nemanjai.
Herald added a project: clang.

This commit moves the logic for determining system, resource and C++
header search paths from CC1 to the driver. This refactor has already
been made for several platforms, but Darwin had been left behind.

This refactor tries to implement the previous search path logic with
perfect accuracy. In particular, the order of all include paths inside
CC1 and all paths that were skipped because nonexistent are conserved
after the refactor. This change was also tested against a code base
of significant size and revealed no problems.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61963

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Frontend/InitHeaderSearch.cpp
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_aarch64/usr/include/c++/4.2.1/arm64-apple-darwin10/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_aarch64/usr/lib/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/include/c++/4.2.1/arm-apple-darwin10/v6/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/include/c++/4.2.1/arm-apple-darwin10/v7/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/lib/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/c++/4.0.0/powerpc-apple-darwin10/ppc64/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/c++/4.2.1/powerpc-apple-darwin10/ppc64/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/lib/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/include/c++/4.0.0/i686-apple-darwin8/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_no_libcxx/usr/include/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_no_libcxx/usr/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_no_libstdcxx/usr/include/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_no_libstdcxx/usr/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr/usr/include/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr/usr/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_and_usr_local/usr/include/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_and_usr_local/usr/lib/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_usr_and_usr_local/usr/local/include/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_usr_and_usr_local/usr/local/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_local/usr/local/include/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_local/usr/local/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_toolchain/usr/bin/.keep
  clang/test/Driver/Inputs/basic_darwin_toolchain/usr/include/c++/v1/.keep
  clang/test/Driver/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin/.keep
  clang/test/Driver/darwin-header-search-libcxx.cpp
  clang/test/Driver/darwin-header-search-libstdcxx.cpp
  clang/test/Driver/darwin-header-search-system.cpp
  clang/test/Driver/darwin-stdlib.cpp
  clang/test/Frontend/warning-stdlibcxx-darwin.cpp

Index: clang/test/Frontend/warning-stdlibcxx-darwin.cpp
===
--- clang/test/Frontend/warning-stdlibcxx-darwin.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-// RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist %s 2>&1 | FileCheck %s
-// RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist -stdlib=libc++ %s -verify
-// RUN: %clang -cc1 -x c++-cpp-output -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist %s -verify
-// CHECK: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead
-
-// expected-no-diagnostics
Index: clang/test/Driver/darwin-stdlib.cpp
===
--- clang/test/Driver/darwin-stdlib.cpp
+++ clang/test/Driver/darwin-stdlib.cpp
@@ -9,13 +9,6 @@
 // RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
 // RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7k %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
 
-// The purpose of this test is that the libc++ headers should be found
-// properly. We also pass -stdlib=libc++ to make sure the logic to add the
-// optional absolute include for libc++ from InitHeaderSearch.cpp also fires.
-
 // CHECK-LIBCXX: 

[PATCH] D61333: [ASTImporter] Fix LLDB lookup in transparent ctx and with ext src

2019-05-15 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I ran `check-lldb` and I hit one regression in `TestFormatters.py`, part of 
what I am seeing is as follows:

  AssertionError: False is not True : FileCheck'ing result of `expression 
--show-types -- *(new foo(47))`
  Error output:
  error: no matching constructor for initialization of 'foo'
  candidate constructor (the implicit copy constructor) not viable: no known 
conversion from 'int' to 'const foo' for 1st argument
  candidate constructor (the implicit move constructor) not viable: no known 
conversion from 'int' to 'foo' for 1st argument




Comment at: clang/lib/AST/ASTImporter.cpp:1818
+  // The class will have DefinitionData, but no members.  Then,
+  // importDefinition is called from LLDB, which tries to get the members, se
+  // when we get here, the class already has the DefinitionData set, so we must

se -> so?



Comment at: lldb/source/Symbol/ClangASTImporter.cpp:922
+
+  Log *log_ast(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_AST));
+  if (log_ast) {

I am going to say that the logging change is an excellent additions and stands 
alone from this change. Although I realize the test depends on this new 
feature. It makes sense to add the logging in a separate PR.

I also say this b/c I found a regression and it would be nice to get the 
logging in while we resolve the regression.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61333



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


[PATCH] D61281: [clang-format] Fixed self assignment

2019-05-15 Thread Dávid Bolvanský via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360810: [clang-format] Fixed self assignment (authored by 
xbolva00, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D61281

Files:
  lib/Format/FormatTokenLexer.cpp


Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -246,7 +246,6 @@
   StringRef(Identifier->TokenText.begin(),
 Question->TokenText.end() - Identifier->TokenText.begin());
   Identifier->ColumnWidth += Question->ColumnWidth;
-  Identifier->Type = Identifier->Type;
   Tokens.erase(Tokens.end() - 1);
   return true;
 }


Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -246,7 +246,6 @@
   StringRef(Identifier->TokenText.begin(),
 Question->TokenText.end() - Identifier->TokenText.begin());
   Identifier->ColumnWidth += Question->ColumnWidth;
-  Identifier->Type = Identifier->Type;
   Tokens.erase(Tokens.end() - 1);
   return true;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r360810 - [clang-format] Fixed self assignment

2019-05-15 Thread David Bolvansky via cfe-commits
Author: xbolva00
Date: Wed May 15 13:29:33 2019
New Revision: 360810

URL: http://llvm.org/viewvc/llvm-project?rev=360810=rev
Log:
[clang-format] Fixed self assignment

Reviewers: MyDeveloperDay, RKSimon

Reviewed By: MyDeveloperDay

Subscribers: RKSimon, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Format/FormatTokenLexer.cpp

Modified: cfe/trunk/lib/Format/FormatTokenLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatTokenLexer.cpp?rev=360810=360809=360810=diff
==
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp (original)
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp Wed May 15 13:29:33 2019
@@ -246,7 +246,6 @@ bool FormatTokenLexer::tryMergeCSharpNul
   StringRef(Identifier->TokenText.begin(),
 Question->TokenText.end() - Identifier->TokenText.begin());
   Identifier->ColumnWidth += Question->ColumnWidth;
-  Identifier->Type = Identifier->Type;
   Tokens.erase(Tokens.end() - 1);
   return true;
 }


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


[PATCH] D61959: [OpenMP][Bugfix] Move double and float versions of abs under c++ macro

2019-05-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360809: [OpenMP][Bugfix] Move double and float versions of 
abs under c++ macro (authored by gbercea, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D61959

Files:
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions.c
  test/Headers/nvptx_device_cmath_functions.cpp
  test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  test/Headers/nvptx_device_math_functions.c
  test/Headers/nvptx_device_math_functions.cpp
  test/Headers/nvptx_device_math_functions_cxx17.cpp

Index: test/Headers/nvptx_device_cmath_functions.c
===
--- test/Headers/nvptx_device_cmath_functions.c
+++ test/Headers/nvptx_device_cmath_functions.c
@@ -17,5 +17,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/Inputs/include/cstdlib
===
--- test/Headers/Inputs/include/cstdlib
+++ test/Headers/Inputs/include/cstdlib
@@ -3,9 +3,11 @@
 #if __cplusplus >= 201703L
 extern int abs (int __x) throw()  __attribute__ ((__const__)) ;
 extern long int labs (long int __x) throw() __attribute__ ((__const__)) ;
+extern float fabs (float __x) throw() __attribute__ ((__const__)) ;
 #else
 extern int abs (int __x) __attribute__ ((__const__)) ;
 extern long int labs (long int __x) __attribute__ ((__const__)) ;
+extern float fabs (float __x) __attribute__ ((__const__)) ;
 #endif
 
 namespace std
Index: test/Headers/nvptx_device_math_functions.c
===
--- test/Headers/nvptx_device_math_functions.c
+++ test/Headers/nvptx_device_math_functions.c
@@ -17,5 +17,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_cmath_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_cmath_functions_cxx17.cpp
+++ test/Headers/nvptx_device_cmath_functions_cxx17.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_math_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_math_functions_cxx17.cpp
+++ test/Headers/nvptx_device_math_functions_cxx17.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_cmath_functions.cpp
===
--- test/Headers/nvptx_device_cmath_functions.cpp
+++ test/Headers/nvptx_device_cmath_functions.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_math_functions.cpp
===
--- test/Headers/nvptx_device_math_functions.cpp
+++ test/Headers/nvptx_device_math_functions.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -48,9 +48,9 @@
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
 __DEVICE__ long abs(long __n) { return ::labs(__n); }
-#endif
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fabs(__x); }
+#endif

r360809 - [OpenMP][Bugfix] Move double and float versions of abs under c++ macro

2019-05-15 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Wed May 15 13:28:23 2019
New Revision: 360809

URL: http://llvm.org/viewvc/llvm-project?rev=360809=rev
Log:
[OpenMP][Bugfix] Move double and float versions of abs under c++ macro

Summary:
This is a fix for the reported bug:

[[ https://bugs.llvm.org/show_bug.cgi?id=41861 | 41861 ]]

abs functions need to be moved under the c++ macro to avoid conflicts with 
included headers.

Reviewers: tra, jdoerfert, hfinkel, ABataev, caomhin

Reviewed By: jdoerfert

Subscribers: guansong, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_cmath.h
cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h
cfe/trunk/test/Headers/Inputs/include/cstdlib
cfe/trunk/test/Headers/nvptx_device_cmath_functions.c
cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp
cfe/trunk/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
cfe/trunk/test/Headers/nvptx_device_math_functions.c
cfe/trunk/test/Headers/nvptx_device_math_functions.cpp
cfe/trunk/test/Headers/nvptx_device_math_functions_cxx17.cpp

Modified: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_cmath.h?rev=360809=360808=360809=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h Wed May 15 13:28:23 2019
@@ -48,9 +48,9 @@
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
 __DEVICE__ long abs(long __n) { return ::labs(__n); }
-#endif
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fabs(__x); }
+#endif
 __DEVICE__ float acos(float __x) { return ::acosf(__x); }
 __DEVICE__ float asin(float __x) { return ::asinf(__x); }
 __DEVICE__ float atan(float __x) { return ::atanf(__x); }

Modified: cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h?rev=360809=360808=360809=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h Wed May 15 
13:28:23 2019
@@ -39,10 +39,10 @@
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);
-#endif
-__DEVICE__ int abs(int) __NOEXCEPT;
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
+#endif
+__DEVICE__ int abs(int) __NOEXCEPT;
 __DEVICE__ double acos(double);
 __DEVICE__ float acos(float);
 __DEVICE__ double acosh(double);

Modified: cfe/trunk/test/Headers/Inputs/include/cstdlib
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/Inputs/include/cstdlib?rev=360809=360808=360809=diff
==
--- cfe/trunk/test/Headers/Inputs/include/cstdlib (original)
+++ cfe/trunk/test/Headers/Inputs/include/cstdlib Wed May 15 13:28:23 2019
@@ -3,9 +3,11 @@
 #if __cplusplus >= 201703L
 extern int abs (int __x) throw()  __attribute__ ((__const__)) ;
 extern long int labs (long int __x) throw() __attribute__ ((__const__)) ;
+extern float fabs (float __x) throw() __attribute__ ((__const__)) ;
 #else
 extern int abs (int __x) __attribute__ ((__const__)) ;
 extern long int labs (long int __x) __attribute__ ((__const__)) ;
+extern float fabs (float __x) __attribute__ ((__const__)) ;
 #endif
 
 namespace std

Modified: cfe/trunk/test/Headers/nvptx_device_cmath_functions.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/nvptx_device_cmath_functions.c?rev=360809=360808=360809=diff
==
--- cfe/trunk/test/Headers/nvptx_device_cmath_functions.c (original)
+++ cfe/trunk/test/Headers/nvptx_device_cmath_functions.c Wed May 15 13:28:23 
2019
@@ -17,5 +17,9 @@ void test_sqrt(double a1) {
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }

Modified: cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp?rev=360809=360808=360809=diff
==
--- cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp (original)
+++ cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp Wed May 15 13:28:23 
2019
@@ -18,5 +18,9 @@ void test_sqrt(double a1) {
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = 

[PATCH] D59464: [analyzer] Add an example plugin for checker dependency handling

2019-05-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus reopened this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

Ugh. Reverted in rC360805 . Buildbots don't 
seem to be able to find the new plugins.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59464



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


r360806 - [c++20] For P1327R1: support dynamic_cast in constant expression

2019-05-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed May 15 13:22:21 2019
New Revision: 360806

URL: http://llvm.org/viewvc/llvm-project?rev=360806=rev
Log:
[c++20] For P1327R1: support dynamic_cast in constant expression
evaluation.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=360806=360805=360806=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Wed May 15 13:22:21 2019
@@ -34,8 +34,15 @@ def note_constexpr_virtual_call : Note<
   "cannot evaluate call to virtual function in a constant expression">;
 def note_constexpr_pure_virtual_call : Note<
   "pure virtual function %q0 called">;
-def note_constexpr_virtual_out_of_lifetime : Note<
-  "virtual function called on object '%0' whose dynamic type is not constant">;
+def note_constexpr_polymorphic_unknown_dynamic_type : Note<
+  "%select{virtual function called on|dynamic_cast applied to}0 "
+  "object '%1' whose dynamic type is not constant">;
+def note_constexpr_dynamic_cast_to_reference_failed : Note<
+  "reference dynamic_cast failed: %select{"
+  "static type %1 of operand is a non-public base class of dynamic type %2|"
+  "dynamic type %2 of operand does not have a base class of type %3|"
+  "%3 is an ambiguous base class of dynamic type %2 of operand|"
+  "%3 is a non-public base class of dynamic type %2 of operand}0">;
 def note_constexpr_virtual_base : Note<
   "cannot construct object of type %0 with virtual base class "
   "in a constant expression">;
@@ -100,10 +107,12 @@ def note_constexpr_this : Note<
   "%select{|implicit }0use of 'this' pointer is only allowed within the "
   "evaluation of a call to a 'constexpr' member function">;
 def note_constexpr_lifetime_ended : Note<
-  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on|"
+  "dynamic_cast of}0 "
   "%select{temporary|variable}1 whose lifetime has ended">;
 def note_constexpr_access_uninit : Note<
-  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on|"
+  "dynamic_cast of}0 "
   "object outside its lifetime is not allowed in a constant expression">;
 def note_constexpr_use_uninit_reference : Note<
   "use of reference outside its lifetime "
@@ -112,11 +121,11 @@ def note_constexpr_modify_const_type : N
   "modification of object of const-qualified type %0 is not allowed "
   "in a constant expression">;
 def note_constexpr_access_volatile_type : Note<
-  "%select{read of|assignment to|increment of|decrement of|}0 "
+  "%select{read of|assignment to|increment of|decrement of||}0 "
   "volatile-qualified type %1 is not allowed in a constant expression">;
 def note_constexpr_access_volatile_obj : Note<
-  "%select{read of|assignment to|increment of|decrement of|}0 volatile "
-  "%select{temporary|object %2|member %2}1 is not allowed in "
+  "%select{read of|assignment to|increment of|decrement of||}0 "
+  "volatile %select{temporary|object %2|member %2}1 is not allowed in "
   "a constant expression">;
 def note_constexpr_volatile_here : Note<
   "volatile %select{temporary created|object declared|member declared}0 here">;
@@ -129,21 +138,26 @@ def note_constexpr_ltor_non_constexpr :
 def note_constexpr_ltor_incomplete_type : Note<
   "read of incomplete type %0 is not allowed in a constant expression">;
 def note_constexpr_access_null : Note<
-  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on|"
+  "dynamic_cast of}0 "
   "dereferenced null pointer is not allowed in a constant expression">;
 def note_constexpr_access_past_end : Note<
-  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on|"
+  "dynamic_cast of}0 "
   "dereferenced one-past-the-end pointer is not allowed in a constant 
expression">;
 def note_constexpr_access_unsized_array : Note<
-  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on|"
+  "dynamic_cast of}0 "
   "element of array without known bound "
   "is not allowed in a constant expression">;
 def note_constexpr_access_inactive_union_member : Note<
-  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on|"
+  "dynamic_cast of}0 "
   "member %1 of union with %select{active 

[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360804: [OpenMP][bugfix] Fix issues with C++ 17 compilation 
when handling math functions (authored by gbercea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61949?vs=199662=199668#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61949

Files:
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  test/Headers/nvptx_device_math_functions_cxx17.cpp

Index: test/Headers/Inputs/include/cstdlib
===
--- test/Headers/Inputs/include/cstdlib
+++ test/Headers/Inputs/include/cstdlib
@@ -1,7 +1,12 @@
 #pragma once
 
+#if __cplusplus >= 201703L
+extern int abs (int __x) throw()  __attribute__ ((__const__)) ;
+extern long int labs (long int __x) throw() __attribute__ ((__const__)) ;
+#else
 extern int abs (int __x) __attribute__ ((__const__)) ;
 extern long int labs (long int __x) __attribute__ ((__const__)) ;
+#endif
 
 namespace std
 {
Index: test/Headers/nvptx_device_cmath_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_cmath_functions_cxx17.cpp
+++ test/Headers/nvptx_device_cmath_functions_cxx17.cpp
@@ -0,0 +1,22 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, );
+  }
+}
Index: test/Headers/nvptx_device_math_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_math_functions_cxx17.cpp
+++ test/Headers/nvptx_device_math_functions_cxx17.cpp
@@ -0,0 +1,22 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -include cstdlib -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, );
+  }
+}
Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -36,6 +36,15 @@
 #define __DEVICE__ static __device__ __inline__ __attribute__((always_inline))
 #endif
 
+// For C++ 17 we need to include noexcept attribute to be compatible
+// with the header-defined version. This may be removed once
+// variant is supported.
+#if defined(_OPENMP) && defined(__cplusplus) && __cplusplus >= 201703L
+#define __NOEXCEPT noexcept
+#else
+#define __NOEXCEPT
+#endif
+
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
 __DEVICE__ long abs(long __n) { return ::labs(__n); }
@@ -50,7 +59,7 @@
 __DEVICE__ float cos(float __x) { 

r360805 - Revert "[analyzer] Add a test for plugins using checker dependencies"

2019-05-15 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Wed May 15 13:19:51 2019
New Revision: 360805

URL: http://llvm.org/viewvc/llvm-project?rev=360805=rev
Log:
Revert "[analyzer] Add a test for plugins using checker dependencies"

Buildbots don't seem to find the new plugin.

Added:
cfe/trunk/examples/analyzer-plugin/
  - copied from r360798, cfe/trunk/examples/analyzer-plugin/
Removed:
cfe/trunk/test/Analysis/plugins/
Modified:
cfe/trunk/examples/CMakeLists.txt
cfe/trunk/test/Analysis/checker-plugins.c
cfe/trunk/test/Analysis/lit.local.cfg
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/examples/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/CMakeLists.txt?rev=360805=360804=360805=diff
==
--- cfe/trunk/examples/CMakeLists.txt (original)
+++ cfe/trunk/examples/CMakeLists.txt Wed May 15 13:19:51 2019
@@ -3,6 +3,9 @@ if(NOT CLANG_BUILD_EXAMPLES)
   set(EXCLUDE_FROM_ALL ON)
 endif()
 
+if(CLANG_ENABLE_STATIC_ANALYZER)
+add_subdirectory(analyzer-plugin)
+endif()
 add_subdirectory(clang-interpreter)
 add_subdirectory(PrintFunctionNames)
 add_subdirectory(AnnotateFunctions)

Modified: cfe/trunk/test/Analysis/checker-plugins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/checker-plugins.c?rev=360805=360804=360805=diff
==
--- cfe/trunk/test/Analysis/checker-plugins.c (original)
+++ cfe/trunk/test/Analysis/checker-plugins.c Wed May 15 13:19:51 2019
@@ -1,8 +1,5 @@
-// RUN: %clang_analyze_cc1 -verify %s \
-// RUN:   -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext \
-// RUN:   -analyzer-checker='example.MainCallChecker'
-
-// REQUIRES: plugins
+// RUN: %clang_analyze_cc1 -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext 
-analyzer-checker='example.MainCallChecker' -verify %s
+// REQUIRES: plugins, examples
 
 // Test that the MainCallChecker example analyzer plugin loads and runs.
 
@@ -11,22 +8,3 @@ int main();
 void caller() {
   main(); // expected-warning {{call to main}}
 }
-
-// RUN: %clang_analyze_cc1 %s \
-// RUN:   -load 
%llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
-// RUN:   -analyzer-checker=example.DependendentChecker \
-// RUN:   -analyzer-list-enabled-checkers \
-// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-ENABLED
-
-// CHECK-IMPLICITLY-ENABLED: example.Dependency
-// CHECK-IMPLICITLY-ENABLED: example.DependendentChecker
-
-// RUN: %clang_analyze_cc1 %s \
-// RUN:   -load 
%llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
-// RUN:   -analyzer-checker=example.DependendentChecker \
-// RUN:   -analyzer-disable-checker=example.Dependency \
-// RUN:   -analyzer-list-enabled-checkers \
-// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-DISABLED
-
-// CHECK-IMPLICITLY-DISABLED-NOT: example.Dependency
-// CHECK-IMPLICITLY-DISABLED-NOT: example.DependendentChecker

Modified: cfe/trunk/test/Analysis/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lit.local.cfg?rev=360805=360804=360805=diff
==
--- cfe/trunk/test/Analysis/lit.local.cfg (original)
+++ cfe/trunk/test/Analysis/lit.local.cfg Wed May 15 13:19:51 2019
@@ -18,7 +18,5 @@ config.substitutions.append(('%diff_plis
 config.substitutions.append(('%diff_sarif',
 '''diff -U1 -w -I ".*file:.*%basename_t" -I '"version":' -I 
"2\.0\.0\-csd\.[0-9]*\.beta\."'''))
 
-config.excludes.add('plugins')
-
 if not config.root.clang_staticanalyzer:
 config.unsupported = True

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=360805=360804=360805=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Wed May 15 13:19:51 2019
@@ -139,15 +139,13 @@ if (CLANG_ENABLE_STATIC_ANALYZER)
   # check-all would launch those tests via check-clang.
   set(EXCLUDE_FROM_ALL ON)
 
-  add_subdirectory(Analysis/plugins)
-  list(APPEND CLANG_TEST_DEPS clang-analyzer-plugin)
-
   add_lit_testsuite(check-clang-analyzer "Running the Clang analyzer tests"
 ${CMAKE_CURRENT_BINARY_DIR}/Analysis
 PARAMS ${ANALYZER_TEST_PARAMS}
 DEPENDS ${CLANG_TEST_DEPS})
   set_target_properties(check-clang-analyzer PROPERTIES FOLDER "Clang tests")
 
+
   if (LLVM_WITH_Z3)
 add_lit_testsuite(check-clang-analyzer-z3 "Running the Clang analyzer 
tests, using Z3 as a solver"
   ${CMAKE_CURRENT_BINARY_DIR}/Analysis


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


r360804 - [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Wed May 15 13:18:21 2019
New Revision: 360804

URL: http://llvm.org/viewvc/llvm-project?rev=360804=rev
Log:
[OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

Summary: In OpenMP device offloading we must ensure that unde C++ 17, the 
inclusion of cstdlib will works correctly.

Reviewers: ABataev, tra, jdoerfert, hfinkel, caomhin

Reviewed By: jdoerfert

Subscribers: Hahnfeld, guansong, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
cfe/trunk/test/Headers/nvptx_device_math_functions_cxx17.cpp
Modified:
cfe/trunk/lib/Headers/__clang_cuda_cmath.h
cfe/trunk/lib/Headers/__clang_cuda_device_functions.h
cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h
cfe/trunk/test/Headers/Inputs/include/cstdlib

Modified: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_cmath.h?rev=360804=360803=360804=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h Wed May 15 13:18:21 2019
@@ -36,6 +36,15 @@
 #define __DEVICE__ static __device__ __inline__ __attribute__((always_inline))
 #endif
 
+// For C++ 17 we need to include noexcept attribute to be compatible
+// with the header-defined version. This may be removed once
+// variant is supported.
+#if defined(_OPENMP) && defined(__cplusplus) && __cplusplus >= 201703L
+#define __NOEXCEPT noexcept
+#else
+#define __NOEXCEPT
+#endif
+
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
 __DEVICE__ long abs(long __n) { return ::labs(__n); }
@@ -50,7 +59,7 @@ __DEVICE__ float ceil(float __x) { retur
 __DEVICE__ float cos(float __x) { return ::cosf(__x); }
 __DEVICE__ float cosh(float __x) { return ::coshf(__x); }
 __DEVICE__ float exp(float __x) { return ::expf(__x); }
-__DEVICE__ float fabs(float __x) { return ::fabsf(__x); }
+__DEVICE__ float fabs(float __x) __NOEXCEPT { return ::fabsf(__x); }
 __DEVICE__ float floor(float __x) { return ::floorf(__x); }
 __DEVICE__ float fmod(float __x, float __y) { return ::fmodf(__x, __y); }
 // TODO: remove when variant is supported
@@ -465,6 +474,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 #endif
 
+#undef __NOEXCEPT
 #undef __DEVICE__
 
 #endif

Modified: cfe/trunk/lib/Headers/__clang_cuda_device_functions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_device_functions.h?rev=360804=360803=360804=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_device_functions.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_device_functions.h Wed May 15 13:18:21 
2019
@@ -37,6 +37,15 @@
 #define __FAST_OR_SLOW(fast, slow) slow
 #endif
 
+// For C++ 17 we need to include noexcept attribute to be compatible
+// with the header-defined version. This may be removed once
+// variant is supported.
+#if defined(_OPENMP) && defined(__cplusplus) && __cplusplus >= 201703L
+#define __NOEXCEPT noexcept
+#else
+#define __NOEXCEPT
+#endif
+
 __DEVICE__ int __all(int __a) { return __nvvm_vote_all(__a); }
 __DEVICE__ int __any(int __a) { return __nvvm_vote_any(__a); }
 __DEVICE__ unsigned int __ballot(int __a) { return __nvvm_vote_ballot(__a); }
@@ -1474,7 +1483,8 @@ __DEVICE__ unsigned int __vsubus4(unsign
   return r;
 }
 #endif // CUDA_VERSION >= 9020
-__DEVICE__ int abs(int __a) { return __nv_abs(__a); }
+__DEVICE__ int abs(int __a) __NOEXCEPT { return __nv_abs(__a); }
+__DEVICE__ double fabs(double __a) __NOEXCEPT { return __nv_fabs(__a); }
 __DEVICE__ double acos(double __a) { return __nv_acos(__a); }
 __DEVICE__ float acosf(float __a) { return __nv_acosf(__a); }
 __DEVICE__ double acosh(double __a) { return __nv_acosh(__a); }
@@ -1533,7 +1543,6 @@ __DEVICE__ float exp2f(float __a) { retu
 __DEVICE__ float expf(float __a) { return __nv_expf(__a); }
 __DEVICE__ double expm1(double __a) { return __nv_expm1(__a); }
 __DEVICE__ float expm1f(float __a) { return __nv_expm1f(__a); }
-__DEVICE__ double fabs(double __a) { return __nv_fabs(__a); }
 __DEVICE__ float fabsf(float __a) { return __nv_fabsf(__a); }
 __DEVICE__ double fdim(double __a, double __b) { return __nv_fdim(__a, __b); }
 __DEVICE__ float fdimf(float __a, float __b) { return __nv_fdimf(__a, __b); }
@@ -1572,15 +1581,15 @@ __DEVICE__ float j1f(float __a) { return
 __DEVICE__ double jn(int __n, double __a) { return __nv_jn(__n, __a); }
 __DEVICE__ float jnf(int __n, float __a) { return __nv_jnf(__n, __a); }
 #if defined(__LP64__) || defined(_WIN64)
-__DEVICE__ long labs(long __a) { return __nv_llabs(__a); };
+__DEVICE__ long labs(long __a) __NOEXCEPT { return __nv_llabs(__a); };
 #else
-__DEVICE__ long labs(long __a) { return __nv_abs(__a); };

[PATCH] D61957: [CodeGenObjC] invoke objc_autorelease, objc_retain when necessary

2019-05-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360802: [CodeGenObjC] invoke objc_autorelease, objc_retain 
when necessary (authored by epilk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61957?vs=199640=199666#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61957

Files:
  lib/CodeGen/CGObjC.cpp
  test/CodeGenObjC/convert-messages-to-runtime-calls.m
  test/CodeGenObjC/objc-alloc-init.m

Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2059,7 +2059,7 @@
llvm::Value *value,
llvm::Type *returnType,
llvm::FunctionCallee ,
-   StringRef fnName, bool MayThrow) {
+   StringRef fnName) {
   if (isa(value))
 return value;
 
@@ -2079,11 +2079,7 @@
   value = CGF.Builder.CreateBitCast(value, CGF.Int8PtrTy);
 
   // Call the function.
-  llvm::CallBase *Inst = nullptr;
-  if (MayThrow)
-Inst = CGF.EmitCallOrInvoke(fn, value);
-  else
-Inst = CGF.EmitNounwindRuntimeCall(fn, value);
+  llvm::CallBase *Inst = CGF.EmitCallOrInvoke(fn, value);
 
   // Cast the result back to the original type.
   return CGF.Builder.CreateBitCast(Inst, origType);
@@ -2536,7 +2532,7 @@
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_alloc,
-"objc_alloc", /*MayThrow=*/true);
+"objc_alloc");
 }
 
 /// Allocate the given objc object.
@@ -2545,14 +2541,14 @@
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_allocWithZone,
-"objc_allocWithZone", /*MayThrow=*/true);
+"objc_allocWithZone");
 }
 
 llvm::Value *CodeGenFunction::EmitObjCAllocInit(llvm::Value *value,
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_alloc_init,
-"objc_alloc_init", /*MayThrow=*/true);
+"objc_alloc_init");
 }
 
 /// Produce the code to do a primitive release.
@@ -2596,7 +2592,7 @@
   return emitObjCValueOperation(
   *this, value, returnType,
   CGM.getObjCEntrypoints().objc_autoreleaseRuntimeFunction,
-  "objc_autorelease", /*MayThrow=*/false);
+  "objc_autorelease");
 }
 
 /// Retain the given object, with normal retain semantics.
@@ -2605,8 +2601,7 @@
  llvm::Type *returnType) {
   return emitObjCValueOperation(
   *this, value, returnType,
-  CGM.getObjCEntrypoints().objc_retainRuntimeFunction, "objc_retain",
-  /*MayThrow=*/false);
+  CGM.getObjCEntrypoints().objc_retainRuntimeFunction, "objc_retain");
 }
 
 /// Release the given object.
Index: test/CodeGenObjC/objc-alloc-init.m
===
--- test/CodeGenObjC/objc-alloc-init.m
+++ test/CodeGenObjC/objc-alloc-init.m
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 %s -fobjc-runtime=macosx-10.14.4 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER
-// RUN: %clang_cc1 %s -fobjc-runtime=macosx-10.14.3 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=NOT_OPTIMIZED --check-prefix=EITHER
-// RUN: %clang_cc1 %s -fobjc-runtime=ios-12.2 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER
-// RUN: %clang_cc1 %s -fobjc-runtime=ios-12.1 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=NOT_OPTIMIZED --check-prefix=EITHER
+// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=macosx-10.14.4 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER
+// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=macosx-10.14.3 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=NOT_OPTIMIZED --check-prefix=EITHER
+// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=ios-12.2 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER
+// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=ios-12.1 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=NOT_OPTIMIZED --check-prefix=EITHER
 
 @interface X
 +(X *)alloc;
@@ -12,6 +12,13 @@
   [[X alloc] init];
   // OPTIMIZED: call i8* @objc_alloc_init(
   // NOT_OPTIMIZED: call i8* @objc_alloc(
+
+  @try {
+[[X alloc] 

[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2019-05-15 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn marked an inline comment as done.
kpn added a comment.

I'm waiting for a signoff from at least one front-end guy. I hope the mode 
setting that allows us to keep front ends from having to touch every use of the 
IRBuilder is something that works for clang. But I haven't heard anything from 
@rsmith or any other front-end person.




Comment at: include/llvm/IR/IRBuilder.h:228
+  /// Enable/Disable use of constrained floating point math
+  void setIsConstrainedFP(bool IsCon) { IsFPConstrained = IsCon; }
+

kbarton wrote:
> This is a minor quibble, but the method is setIsConstrainedFP, while the 
> member is IsFPConstrained. 
> I'm not sure if that is intentionally different, or an oversight. 
Yeah, that's an oversight. Fixed.


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

https://reviews.llvm.org/D53157



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


r360802 - [CodeGenObjC] invoke objc_autorelease, objc_retain when necessary

2019-05-15 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Wed May 15 13:15:01 2019
New Revision: 360802

URL: http://llvm.org/viewvc/llvm-project?rev=360802=rev
Log:
[CodeGenObjC] invoke objc_autorelease, objc_retain when necessary

Any of these methods can be overridden, so we need to invoke these functions.

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

Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
cfe/trunk/test/CodeGenObjC/objc-alloc-init.m

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=360802=360801=360802=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Wed May 15 13:15:01 2019
@@ -2059,7 +2059,7 @@ static llvm::Value *emitObjCValueOperati
llvm::Value *value,
llvm::Type *returnType,
llvm::FunctionCallee ,
-   StringRef fnName, bool MayThrow) {
+   StringRef fnName) {
   if (isa(value))
 return value;
 
@@ -2079,11 +2079,7 @@ static llvm::Value *emitObjCValueOperati
   value = CGF.Builder.CreateBitCast(value, CGF.Int8PtrTy);
 
   // Call the function.
-  llvm::CallBase *Inst = nullptr;
-  if (MayThrow)
-Inst = CGF.EmitCallOrInvoke(fn, value);
-  else
-Inst = CGF.EmitNounwindRuntimeCall(fn, value);
+  llvm::CallBase *Inst = CGF.EmitCallOrInvoke(fn, value);
 
   // Cast the result back to the original type.
   return CGF.Builder.CreateBitCast(Inst, origType);
@@ -2536,7 +2532,7 @@ llvm::Value *CodeGenFunction::EmitObjCAl
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_alloc,
-"objc_alloc", /*MayThrow=*/true);
+"objc_alloc");
 }
 
 /// Allocate the given objc object.
@@ -2545,14 +2541,14 @@ llvm::Value *CodeGenFunction::EmitObjCAl
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_allocWithZone,
-"objc_allocWithZone", /*MayThrow=*/true);
+"objc_allocWithZone");
 }
 
 llvm::Value *CodeGenFunction::EmitObjCAllocInit(llvm::Value *value,
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_alloc_init,
-"objc_alloc_init", /*MayThrow=*/true);
+"objc_alloc_init");
 }
 
 /// Produce the code to do a primitive release.
@@ -2596,7 +2592,7 @@ llvm::Value *CodeGenFunction::EmitObjCAu
   return emitObjCValueOperation(
   *this, value, returnType,
   CGM.getObjCEntrypoints().objc_autoreleaseRuntimeFunction,
-  "objc_autorelease", /*MayThrow=*/false);
+  "objc_autorelease");
 }
 
 /// Retain the given object, with normal retain semantics.
@@ -2605,8 +2601,7 @@ llvm::Value *CodeGenFunction::EmitObjCRe
  llvm::Type *returnType) {
   return emitObjCValueOperation(
   *this, value, returnType,
-  CGM.getObjCEntrypoints().objc_retainRuntimeFunction, "objc_retain",
-  /*MayThrow=*/false);
+  CGM.getObjCEntrypoints().objc_retainRuntimeFunction, "objc_retain");
 }
 
 /// Release the given object.

Modified: cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m?rev=360802=360801=360802=diff
==
--- cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m (original)
+++ cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m Wed May 15 
13:15:01 2019
@@ -177,8 +177,8 @@ float test_cannot_message_return_float(C
 
 @class Ety;
 
-// CHECK-LABEL: define {{.*}}void @testException
-void testException(NSObject *a) {
+// CHECK-LABEL: define {{.*}}void @testException_release
+void testException_release(NSObject *a) {
   // MSGS: {{invoke.*@objc_msgSend}}
   // CALLS: invoke{{.*}}void @objc_release(i8* %
   @try {
@@ -186,3 +186,44 @@ void testException(NSObject *a) {
   } @catch (Ety *e) {
   }
 }
+
+// CHECK-LABEL: define {{.*}}void @testException_autorelease
+void testException_autorelease(NSObject *a) {
+  @try {
+// MSGS: {{invoke.*@objc_msgSend}}
+// CALLS: invoke{{.*}}objc_autorelease(i8* %
+[a autorelease];
+  } @catch (Ety *e) {
+  }
+}
+
+// CHECK-LABEL: define 

[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2019-05-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea abandoned this revision.
gtbercea added a comment.

Replaced by: D61399 


Repository:
  rC Clang

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

https://reviews.llvm.org/D47849



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


[PATCH] D60907: [OpenMP] Add math functions support in OpenMP offloading

2019-05-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea abandoned this revision.
gtbercea marked an inline comment as done.
gtbercea added a comment.

Replaced by: D61399 


Repository:
  rC Clang

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

https://reviews.llvm.org/D60907



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


[PATCH] D61959: [OpenMP][Bugfix] Move double and float versions of abs under c++ macro

2019-05-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: tra, jdoerfert, hfinkel, ABataev, caomhin.
Herald added subscribers: cfe-commits, guansong.
Herald added a project: clang.

This is a fix for the reported bug:

41861 

abs functions need to be moved under the c++ macro to avoid conflicts with 
included headers.


Repository:
  rC Clang

https://reviews.llvm.org/D61959

Files:
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions.c
  test/Headers/nvptx_device_cmath_functions.cpp
  test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  test/Headers/nvptx_device_math_functions.c
  test/Headers/nvptx_device_math_functions.cpp
  test/Headers/nvptx_device_math_functions_cxx17.cpp

Index: test/Headers/nvptx_device_math_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_math_functions_cxx17.cpp
+++ test/Headers/nvptx_device_math_functions_cxx17.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_math_functions.cpp
===
--- test/Headers/nvptx_device_math_functions.cpp
+++ test/Headers/nvptx_device_math_functions.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_math_functions.c
===
--- test/Headers/nvptx_device_math_functions.c
+++ test/Headers/nvptx_device_math_functions.c
@@ -17,5 +17,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_cmath_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_cmath_functions_cxx17.cpp
+++ test/Headers/nvptx_device_cmath_functions_cxx17.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_cmath_functions.cpp
===
--- test/Headers/nvptx_device_cmath_functions.cpp
+++ test/Headers/nvptx_device_cmath_functions.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_cmath_functions.c
===
--- test/Headers/nvptx_device_cmath_functions.c
+++ test/Headers/nvptx_device_cmath_functions.c
@@ -17,5 +17,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, );
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/Inputs/include/cstdlib
===
--- test/Headers/Inputs/include/cstdlib
+++ test/Headers/Inputs/include/cstdlib
@@ -3,9 +3,11 @@
 #if __cplusplus >= 201703L
 extern int abs (int __x) throw()  __attribute__ ((__const__)) ;
 extern long int labs (long int __x) throw() __attribute__ ((__const__)) ;
+extern float fabs (float __x) throw() __attribute__ ((__const__)) ;
 #else
 extern int abs (int __x) __attribute__ ((__const__)) ;
 extern long int labs (long int __x) __attribute__ ((__const__)) ;
+extern float fabs (float __x) __attribute__ ((__const__)) ;
 #endif
 
 namespace std
Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -39,10 +39,10 @@
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);
-#endif
-__DEVICE__ int abs(int) __NOEXCEPT;
 

[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 199662.
gtbercea marked an inline comment as done.
gtbercea added a comment.

- Remove included headers.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949

Files:
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  test/Headers/nvptx_device_math_functions_cxx17.cpp

Index: test/Headers/nvptx_device_math_functions_cxx17.cpp
===
--- /dev/null
+++ test/Headers/nvptx_device_math_functions_cxx17.cpp
@@ -0,0 +1,22 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -include cstdlib -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, );
+  }
+}
Index: test/Headers/nvptx_device_cmath_functions_cxx17.cpp
===
--- /dev/null
+++ test/Headers/nvptx_device_cmath_functions_cxx17.cpp
@@ -0,0 +1,22 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, );
+  }
+}
Index: test/Headers/Inputs/include/cstdlib
===
--- test/Headers/Inputs/include/cstdlib
+++ test/Headers/Inputs/include/cstdlib
@@ -1,7 +1,12 @@
 #pragma once
 
+#if __cplusplus >= 201703L
+extern int abs (int __x) throw()  __attribute__ ((__const__)) ;
+extern long int labs (long int __x) throw() __attribute__ ((__const__)) ;
+#else
 extern int abs (int __x) __attribute__ ((__const__)) ;
 extern long int labs (long int __x) __attribute__ ((__const__)) ;
+#endif
 
 namespace std
 {
Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -27,11 +27,20 @@
   static __inline__ __attribute__((always_inline)) __attribute__((device))
 #endif
 
+// For C++ 17 we need to include noexcept attribute to be compatible
+// with the header-defined version. This may be removed once
+// variant is supported.
+#if defined(_OPENMP) && defined(__cplusplus) && __cplusplus >= 201703L
+#define __NOEXCEPT noexcept
+#else
+#define __NOEXCEPT
+#endif
+
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);
 #endif
-__DEVICE__ int abs(int);
+__DEVICE__ int abs(int) __NOEXCEPT;
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
 __DEVICE__ double acos(double);
@@ -68,8 +77,8 @@
 __DEVICE__ float exp(float);
 __DEVICE__ double expm1(double);
 __DEVICE__ float expm1(float);
-__DEVICE__ double 

[PATCH] D59464: [analyzer] Add an example plugin for checker dependency handling

2019-05-15 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360799: [analyzer] Add a test for plugins using checker 
dependencies (authored by Szelethus, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59464?vs=196083=199663#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59464

Files:
  cfe/trunk/examples/CMakeLists.txt
  cfe/trunk/examples/analyzer-plugin/CMakeLists.txt
  cfe/trunk/examples/analyzer-plugin/MainCallChecker.cpp
  cfe/trunk/examples/analyzer-plugin/SampleAnalyzerPlugin.exports
  cfe/trunk/test/Analysis/checker-plugins.c
  cfe/trunk/test/Analysis/lit.local.cfg
  cfe/trunk/test/Analysis/plugins/CMakeLists.txt
  cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
  
cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp
  
cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
  cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
  cfe/trunk/test/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp
  cfe/trunk/test/Analysis/plugins/SampleAnalyzer/SampleAnalyzerPlugin.exports
  cfe/trunk/test/CMakeLists.txt

Index: cfe/trunk/test/CMakeLists.txt
===
--- cfe/trunk/test/CMakeLists.txt
+++ cfe/trunk/test/CMakeLists.txt
@@ -139,13 +139,15 @@
   # check-all would launch those tests via check-clang.
   set(EXCLUDE_FROM_ALL ON)
 
+  add_subdirectory(Analysis/plugins)
+  list(APPEND CLANG_TEST_DEPS clang-analyzer-plugin)
+
   add_lit_testsuite(check-clang-analyzer "Running the Clang analyzer tests"
 ${CMAKE_CURRENT_BINARY_DIR}/Analysis
 PARAMS ${ANALYZER_TEST_PARAMS}
 DEPENDS ${CLANG_TEST_DEPS})
   set_target_properties(check-clang-analyzer PROPERTIES FOLDER "Clang tests")
 
-
   if (LLVM_WITH_Z3)
 add_lit_testsuite(check-clang-analyzer-z3 "Running the Clang analyzer tests, using Z3 as a solver"
   ${CMAKE_CURRENT_BINARY_DIR}/Analysis
Index: cfe/trunk/test/Analysis/checker-plugins.c
===
--- cfe/trunk/test/Analysis/checker-plugins.c
+++ cfe/trunk/test/Analysis/checker-plugins.c
@@ -1,5 +1,8 @@
-// RUN: %clang_analyze_cc1 -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext -analyzer-checker='example.MainCallChecker' -verify %s
-// REQUIRES: plugins, examples
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext \
+// RUN:   -analyzer-checker='example.MainCallChecker'
+
+// REQUIRES: plugins
 
 // Test that the MainCallChecker example analyzer plugin loads and runs.
 
@@ -8,3 +11,22 @@
 void caller() {
   main(); // expected-warning {{call to main}}
 }
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -load %llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
+// RUN:   -analyzer-checker=example.DependendentChecker \
+// RUN:   -analyzer-list-enabled-checkers \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-ENABLED
+
+// CHECK-IMPLICITLY-ENABLED: example.Dependency
+// CHECK-IMPLICITLY-ENABLED: example.DependendentChecker
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -load %llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
+// RUN:   -analyzer-checker=example.DependendentChecker \
+// RUN:   -analyzer-disable-checker=example.Dependency \
+// RUN:   -analyzer-list-enabled-checkers \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-DISABLED
+
+// CHECK-IMPLICITLY-DISABLED-NOT: example.Dependency
+// CHECK-IMPLICITLY-DISABLED-NOT: example.DependendentChecker
Index: cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
===
--- cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
+++ cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
@@ -0,0 +1,2 @@
+clang_registerCheckers
+clang_analyzerAPIVersionString
Index: cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
===
--- cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
+++ cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
@@ -0,0 +1,11 @@
+set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CheckerDependencyHandlingAnalyzerPlugin.exports)
+add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE CheckerDependencyHandling.cpp PLUGIN_TOOL clang)
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  target_link_libraries(CheckerDependencyHandlingAnalyzerPlugin PRIVATE
+clangAnalysis
+clangAST
+clangStaticAnalyzerCore
+LLVMSupport
+)

r360799 - [analyzer] Add a test for plugins using checker dependencies

2019-05-15 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Wed May 15 12:47:26 2019
New Revision: 360799

URL: http://llvm.org/viewvc/llvm-project?rev=360799=rev
Log:
[analyzer] Add a test for plugins using checker dependencies

Also, I moved the existing analyzer plugin to test/ as well, in order not to
give the illusion that the analyzer supports plugins -- it's capable of handling
them, but does not _support_ them.

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


Added:
cfe/trunk/test/Analysis/plugins/
cfe/trunk/test/Analysis/plugins/CMakeLists.txt
cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/
cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt

cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp

cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
cfe/trunk/test/Analysis/plugins/SampleAnalyzer/
cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
cfe/trunk/test/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp
cfe/trunk/test/Analysis/plugins/SampleAnalyzer/SampleAnalyzerPlugin.exports
Removed:
cfe/trunk/examples/analyzer-plugin/
Modified:
cfe/trunk/examples/CMakeLists.txt
cfe/trunk/test/Analysis/checker-plugins.c
cfe/trunk/test/Analysis/lit.local.cfg
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/examples/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/CMakeLists.txt?rev=360799=360798=360799=diff
==
--- cfe/trunk/examples/CMakeLists.txt (original)
+++ cfe/trunk/examples/CMakeLists.txt Wed May 15 12:47:26 2019
@@ -3,9 +3,6 @@ if(NOT CLANG_BUILD_EXAMPLES)
   set(EXCLUDE_FROM_ALL ON)
 endif()
 
-if(CLANG_ENABLE_STATIC_ANALYZER)
-add_subdirectory(analyzer-plugin)
-endif()
 add_subdirectory(clang-interpreter)
 add_subdirectory(PrintFunctionNames)
 add_subdirectory(AnnotateFunctions)

Modified: cfe/trunk/test/Analysis/checker-plugins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/checker-plugins.c?rev=360799=360798=360799=diff
==
--- cfe/trunk/test/Analysis/checker-plugins.c (original)
+++ cfe/trunk/test/Analysis/checker-plugins.c Wed May 15 12:47:26 2019
@@ -1,5 +1,8 @@
-// RUN: %clang_analyze_cc1 -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext 
-analyzer-checker='example.MainCallChecker' -verify %s
-// REQUIRES: plugins, examples
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext \
+// RUN:   -analyzer-checker='example.MainCallChecker'
+
+// REQUIRES: plugins
 
 // Test that the MainCallChecker example analyzer plugin loads and runs.
 
@@ -8,3 +11,22 @@ int main();
 void caller() {
   main(); // expected-warning {{call to main}}
 }
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -load 
%llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
+// RUN:   -analyzer-checker=example.DependendentChecker \
+// RUN:   -analyzer-list-enabled-checkers \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-ENABLED
+
+// CHECK-IMPLICITLY-ENABLED: example.Dependency
+// CHECK-IMPLICITLY-ENABLED: example.DependendentChecker
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -load 
%llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
+// RUN:   -analyzer-checker=example.DependendentChecker \
+// RUN:   -analyzer-disable-checker=example.Dependency \
+// RUN:   -analyzer-list-enabled-checkers \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-DISABLED
+
+// CHECK-IMPLICITLY-DISABLED-NOT: example.Dependency
+// CHECK-IMPLICITLY-DISABLED-NOT: example.DependendentChecker

Modified: cfe/trunk/test/Analysis/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lit.local.cfg?rev=360799=360798=360799=diff
==
--- cfe/trunk/test/Analysis/lit.local.cfg (original)
+++ cfe/trunk/test/Analysis/lit.local.cfg Wed May 15 12:47:26 2019
@@ -18,5 +18,7 @@ config.substitutions.append(('%diff_plis
 config.substitutions.append(('%diff_sarif',
 '''diff -U1 -w -I ".*file:.*%basename_t" -I '"version":' -I 
"2\.0\.0\-csd\.[0-9]*\.beta\."'''))
 
+config.excludes.add('plugins')
+
 if not config.root.clang_staticanalyzer:
 config.unsupported = True

Added: cfe/trunk/test/Analysis/plugins/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/plugins/CMakeLists.txt?rev=360799=auto
==
--- cfe/trunk/test/Analysis/plugins/CMakeLists.txt (added)
+++ cfe/trunk/test/Analysis/plugins/CMakeLists.txt Wed May 15 12:47:26 2019
@@ -0,0 +1,10 @@
+add_subdirectory(SampleAnalyzer)
+add_subdirectory(CheckerDependencyHandling)
+
+set(CLANG_ANALYZER_PLUGIN_DEPS
+  SampleAnalyzerPlugin
+  

[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-15 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D61909#1503433 , @winksaville wrote:

> IMHO "`BUILD_CLANG_DYLIB`" is needed. As you have it now libclang_shared.so 
> is always builds on UNIX systems, which I believe means that all linux 
> distros would have both increasing their sizes.


Distributions shouldn't be installing `all` unless they really want everything 
and the kitchen sink. We have the `LLVM_DISTRIBUTION_COMPONENTS` so that 
distributions can decide which pieces of the LLVM & Clang distributions they 
want to install. That is the cleanest mechanism for curating an install.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61909



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


[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-05-15 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 199659.
aganea marked 3 inline comments as done.
aganea added a comment.

In D60283#1503256 , @probinson wrote:

> Minor stuff.  This solution is surprisingly simple, the main question being 
> (and I don't have an answer) whether increasing the size of PresumedLoc is 
> okay.


Thanks Paul! `PresumedLoc` seems to be used only as a temporary (on the stack).


Repository:
  rC Clang

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

https://reviews.llvm.org/D60283

Files:
  include/clang/Basic/SourceLocation.h
  lib/Basic/SourceManager.cpp
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
  test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
  test/CodeGen/debug-info-file-checksum.c

Index: test/CodeGen/debug-info-file-checksum.c
===
--- test/CodeGen/debug-info-file-checksum.c
+++ test/CodeGen/debug-info-file-checksum.c
@@ -4,3 +4,15 @@
 // Check that "checksum" is created correctly for the compiled file.
 
 // CHECK: !DIFile(filename:{{.*}}, directory:{{.*}}, checksumkind: CSK_MD5, checksum: "a3b7d27af071accdeccaa933fc603608")
+
+// Ensure #line directives (in already pre-processed files) do not emit checksums
+// RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-pre.cpp -o - | FileCheck %s --check-prefix NOCHECKSUM
+
+// NOCHECKSUM: !DIFile(filename: "{{.*}}code-coverage-filter1.h", directory: "{{[^"]*}}")
+// NOCHECKSUM: !DIFile(filename: "{{.*}}code-coverage-filter2.h", directory: "{{[^"]*}}")
+// NOCHECKSUM: !DIFile(filename: "{{.*}}debug-info-file-checksum.c", directory: "{{[^"]*}}")
+
+// Ensure #line directives without name do emit checksums
+// RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-line.cpp -o - | FileCheck %s --check-prefix CHECKSUM
+
+// CHECKSUM: !DIFile(filename: "{{.*}}debug-info-file-checksum-line.cpp", directory:{{.*}}, checksumkind: CSK_MD5, checksum: "7b568574d0e3c56c28e5e0234d1f4a06")
Index: test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
===
--- test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
+++ test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
@@ -0,0 +1,10 @@
+#line 1 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter1.h"
+void test1() {}
+#line 2 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter2.h"
+void test2() {}
+#line 3 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+int foo(int x) {
+  return x+1;
+}
Index: test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
===
--- test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
+++ test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
@@ -0,0 +1,9 @@
+int foo(int x) {
+  return x+1;
+}
+
+#line 100
+void test1() {}
+
+#line 200
+void test2() {}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -422,8 +422,12 @@
   }
 
   SmallString<32> Checksum;
+
+  // Compute the checksum if possible. If the location is affected by a #line
+  // directive that refers to a file, PLoc will have an invalid FileID, and we
+  // will correctly get no checksum.
   Optional CSKind =
-  computeChecksum(SM.getFileID(Loc), Checksum);
+  computeChecksum(PLoc.getFileID(), Checksum);
   Optional> CSInfo;
   if (CSKind)
 CSInfo.emplace(*CSKind, Checksum);
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -1430,6 +1430,7 @@
   // To get the source name, first consult the FileEntry (if one exists)
   // before the MemBuffer as this will avoid unnecessarily paging in the
   // MemBuffer.
+  FileID FID = LocInfo.first;
   StringRef Filename;
   if (C->OrigEntry)
 Filename = C->OrigEntry->getName();
@@ -1453,8 +1454,12 @@
 if (const LineEntry *Entry =
   LineTable->FindNearestLineEntry(LocInfo.first, LocInfo.second)) {
   // If the LineEntry indicates a filename, use it.
-  if (Entry->FilenameID != -1)
+  if (Entry->FilenameID != -1) {
 Filename = LineTable->getFilename(Entry->FilenameID);
+// The contents of files referenced by #line are not in the
+// SourceManager
+FID = FileID::get(0);
+  }
 
   // Use the line number specified by the LineEntry.  This line number may
   // be multiple lines down from the line entry.  Add the difference in
@@ -1473,7 +1478,7 @@
 }
   }
 
-  return PresumedLoc(Filename.data(), LineNo, ColNo, IncludeLoc);
+  return 

[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert requested changes to this revision.
jdoerfert added inline comments.
This revision now requires changes to proceed.



Comment at: lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h:24
+  #include 
+  #include 
 #endif

jdoerfert wrote:
> I ask this question again and again, do we need them now? Why?
Why did you add these includes?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949



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


[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

LGTM.




Comment at: lib/Headers/__clang_cuda_cmath.h:42
+// variant is supported.
+#if defined(_OPENMP) && defined(__cplusplus) && __cplusplus >= 201703L
+#define __NOEXCEPT noexcept

I think the change is useful for CUDA, too, but I'm OK keeping it 
OpenMP-specific for now. I can enable it for CUDA later.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949



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


[PATCH] D61957: [CodeGenObjC] invoke objc_autorelease, objc_retain when necessary

2019-05-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m:208
+  }
+}

Can you add tests for `objc_alloc`, `objc_allocWithZone` and `objc_alloc_init` 
too?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61957



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


[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-15 Thread Wink Saville via Phabricator via cfe-commits
winksaville added a comment.

IMHO "`BUILD_CLANG_DYLIB`" is needed. As you have it now libclang_shared.so is 
always builds on UNIX systems, which I believe means that all linux distros 
would have both increasing their sizes. I think the default should be "always" 
`build libclang*.a` as it is now, and optionally build `libclang_shared.so` 
using some flag.

And adding "`LINK_CLANG_DYLIB`" in a future patch SGTM.




Comment at: clang/tools/CMakeLists.txt:16
 add_clang_subdirectory(clang-refactor)
+if(UNIX)
+  add_clang_subdirectory(clang-shlib)

It seems to me we should put creating clang-shlib in the users control and 
default to off.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61909



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


[PATCH] D60956: [Sema] Fix the lookup for a declaration conflicting with an enumerator

2019-05-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

Ping :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D60956



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


[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2019-05-15 Thread Kit Barton via Phabricator via cfe-commits
kbarton added a comment.

I think this looks straightforward, as long as people agree to have a separate 
CreateConstrained* version of these functions. I'm not qualified to weigh in on 
that as I don't know Clang at all and can't comment about the tradeoffs 
(although I think they have been well articulated in the discussion). From what 
I can see, that is the only thing blocking this from getting approved  (unless 
there is something else I missed while reading the discussion).

The only other comment I have is there was some very good description about the 
intention here from @uweigand, @cameron.mcinally and @andrew.w.kaylor and @kpn. 
I think it would be good if that discussion is extracted from this review and 
put somewhere (perhaps the language ref) to indicate precisely what the 
semantics are we are trying to achieve with FENV_ACCESS ON/OFF.




Comment at: include/llvm/IR/IRBuilder.h:228
+  /// Enable/Disable use of constrained floating point math
+  void setIsConstrainedFP(bool IsCon) { IsFPConstrained = IsCon; }
+

This is a minor quibble, but the method is setIsConstrainedFP, while the member 
is IsFPConstrained. 
I'm not sure if that is intentionally different, or an oversight. 


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

https://reviews.llvm.org/D53157



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


[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: lib/Headers/__clang_cuda_device_functions.h:1477
 #endif // CUDA_VERSION >= 9020
+#if __cplusplus >= 201703L
+__DEVICE__ int abs(int __a) noexcept { return __nv_abs(__a); }

tra wrote:
> jdoerfert wrote:
> > Hahnfeld wrote:
> > > If I recall correctly, `__cplusplus` is not defined in C mode, so both 
> > > GCC and Clang will issue a warning with `-Wundef`.
> > > 
> > > Maybe this can be solved with something similar to:
> > > ```lang=c
> > > #ifdef __cplusplus
> > > #define cpp_version __cplusplus
> > > #else
> > > #define cpp_version 0
> > > #endif
> > > ```
> > > (to avoid repetition of `#if defined(__cplusplus) && __cplusplus >= 
> > > 201703L`)
> > I dislike defining the version and advice to repeating `#if 
> > defined(__cplusplus) && __cplusplus >= 201703L)`
> > 
> I agree with @jdoerfert.
> If that's needed too often, we can move c++-only functions under one global 
> `#if defined(__cplusplus)`.
> 
@tra is this closer to what you want?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949



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


[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 199651.
gtbercea added a comment.

- Refactor.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949

Files:
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  test/Headers/nvptx_device_math_functions_cxx17.cpp

Index: test/Headers/nvptx_device_math_functions_cxx17.cpp
===
--- /dev/null
+++ test/Headers/nvptx_device_math_functions_cxx17.cpp
@@ -0,0 +1,22 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -include cstdlib -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, );
+  }
+}
Index: test/Headers/nvptx_device_cmath_functions_cxx17.cpp
===
--- /dev/null
+++ test/Headers/nvptx_device_cmath_functions_cxx17.cpp
@@ -0,0 +1,22 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, );
+  }
+}
Index: test/Headers/Inputs/include/cstdlib
===
--- test/Headers/Inputs/include/cstdlib
+++ test/Headers/Inputs/include/cstdlib
@@ -1,7 +1,12 @@
 #pragma once
 
+#if __cplusplus >= 201703L
+extern int abs (int __x) throw()  __attribute__ ((__const__)) ;
+extern long int labs (long int __x) throw() __attribute__ ((__const__)) ;
+#else
 extern int abs (int __x) __attribute__ ((__const__)) ;
 extern long int labs (long int __x) __attribute__ ((__const__)) ;
+#endif
 
 namespace std
 {
Index: lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
===
--- lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
+++ lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
@@ -20,6 +20,8 @@
 
 #if defined(__cplusplus)
   #include <__clang_cuda_math_forward_declares.h>
+  #include 
+  #include 
 #endif
 
 /// Include declarations for libdevice functions.
Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -27,11 +27,20 @@
   static __inline__ __attribute__((always_inline)) __attribute__((device))
 #endif
 
+// For C++ 17 we need to include noexcept attribute to be compatible
+// with the header-defined version. This may be removed once
+// variant is supported.
+#if defined(_OPENMP) && defined(__cplusplus) && __cplusplus >= 201703L
+#define __NOEXCEPT noexcept
+#else

[PATCH] D61845: [builtin] Fixed definitions of builtins that rely on the int/long long type is 32/64 bits

2019-05-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D61845



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


[PATCH] D61958: [analyzer] RetainCount: Fix a crash when os_returns_retained_on_zero (_nonzero) is applied to functions that return weird stuff.

2019-05-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360790: [analyzer] RetainCount: Fix 
os_returns_retained_on_zero with weird return types. (authored by dergachev, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61958?vs=199647=199650#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61958

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  test/Analysis/osobject-retain-release.cpp


Index: test/Analysis/osobject-retain-release.cpp
===
--- test/Analysis/osobject-retain-release.cpp
+++ test/Analysis/osobject-retain-release.cpp
@@ -702,3 +702,16 @@
   // returning from it at +0.
   return table; // no-warning
 }
+
+namespace weird_result {
+struct WeirdResult {
+  int x, y, z;
+};
+
+WeirdResult outParamWithWeirdResult(OS_RETURNS_RETAINED_ON_ZERO OSObject 
**obj);
+
+WeirdResult testOutParamWithWeirdResult() {
+  OSObject *obj;
+  return outParamWithWeirdResult(); // no-warning
+}
+} // namespace weird_result
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -537,6 +537,11 @@
   ProgramStateRef AssumeZeroReturn = State;
 
   if (SplitNecessary) {
+if (!CE.getResultType()->isScalarType()) {
+  // Structures cannot be assumed. This probably deserves
+  // a compiler warning for invalid annotations.
+  return {State};
+}
 if (auto DL = L.getAs()) {
   AssumeNonZeroReturn = AssumeNonZeroReturn->assume(*DL, true);
   AssumeZeroReturn = AssumeZeroReturn->assume(*DL, false);


Index: test/Analysis/osobject-retain-release.cpp
===
--- test/Analysis/osobject-retain-release.cpp
+++ test/Analysis/osobject-retain-release.cpp
@@ -702,3 +702,16 @@
   // returning from it at +0.
   return table; // no-warning
 }
+
+namespace weird_result {
+struct WeirdResult {
+  int x, y, z;
+};
+
+WeirdResult outParamWithWeirdResult(OS_RETURNS_RETAINED_ON_ZERO OSObject **obj);
+
+WeirdResult testOutParamWithWeirdResult() {
+  OSObject *obj;
+  return outParamWithWeirdResult(); // no-warning
+}
+} // namespace weird_result
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -537,6 +537,11 @@
   ProgramStateRef AssumeZeroReturn = State;
 
   if (SplitNecessary) {
+if (!CE.getResultType()->isScalarType()) {
+  // Structures cannot be assumed. This probably deserves
+  // a compiler warning for invalid annotations.
+  return {State};
+}
 if (auto DL = L.getAs()) {
   AssumeNonZeroReturn = AssumeNonZeroReturn->assume(*DL, true);
   AssumeZeroReturn = AssumeZeroReturn->assume(*DL, false);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r360790 - [analyzer] RetainCount: Fix os_returns_retained_on_zero with weird return types.

2019-05-15 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed May 15 11:41:32 2019
New Revision: 360790

URL: http://llvm.org/viewvc/llvm-project?rev=360790=rev
Log:
[analyzer] RetainCount: Fix os_returns_retained_on_zero with weird return types.

The checker was crashing when it was trying to assume a structure
to be null or non-null so that to evaluate the effect of the annotation.

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

Modified:

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
cfe/trunk/test/Analysis/osobject-retain-release.cpp

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=360790=360789=360790=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
Wed May 15 11:41:32 2019
@@ -537,6 +537,11 @@ updateOutParameters(ProgramStateRef Stat
   ProgramStateRef AssumeZeroReturn = State;
 
   if (SplitNecessary) {
+if (!CE.getResultType()->isScalarType()) {
+  // Structures cannot be assumed. This probably deserves
+  // a compiler warning for invalid annotations.
+  return {State};
+}
 if (auto DL = L.getAs()) {
   AssumeNonZeroReturn = AssumeNonZeroReturn->assume(*DL, true);
   AssumeZeroReturn = AssumeZeroReturn->assume(*DL, false);

Modified: cfe/trunk/test/Analysis/osobject-retain-release.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/osobject-retain-release.cpp?rev=360790=360789=360790=diff
==
--- cfe/trunk/test/Analysis/osobject-retain-release.cpp (original)
+++ cfe/trunk/test/Analysis/osobject-retain-release.cpp Wed May 15 11:41:32 2019
@@ -702,3 +702,16 @@ OSObject *testSuppressionForMethodsEndin
   // returning from it at +0.
   return table; // no-warning
 }
+
+namespace weird_result {
+struct WeirdResult {
+  int x, y, z;
+};
+
+WeirdResult outParamWithWeirdResult(OS_RETURNS_RETAINED_ON_ZERO OSObject 
**obj);
+
+WeirdResult testOutParamWithWeirdResult() {
+  OSObject *obj;
+  return outParamWithWeirdResult(); // no-warning
+}
+} // namespace weird_result


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


[PATCH] D61958: [analyzer] RetainCount: Fix a crash when os_returns_retained_on_zero (_nonzero) is applied to functions that return weird stuff.

2019-05-15 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Looks good do me. Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D61958



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


[PATCH] D59885: [Lex] Allow to consume tokens while preprocessing

2019-05-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Lex/PPDirectives.cpp:1521
   Tok[0].setAnnotationValue(AnnotationVal);
-  EnterTokenStream(std::move(Tok), 1, true);
+  EnterTokenStream(std::move(Tok), 1, true, /*IsReinject*/ true);
 }

I think it'd be more useful to treat this as a new token. But that's not a 
strong preference.



Comment at: clang/lib/Lex/Pragma.cpp:370
   // Push the tokens onto the stack.
-  EnterTokenStream(TokArray, PragmaToks.size(), true, true);
+  EnterTokenStream(TokArray, PragmaToks.size(), true, true,
+   /*IsReinject*/ false);

I think this case is a reinjection; we've copied some tokens inside __pragma 
out into a duplicate position in the token stream. But I guess it doesn't 
matter because the tokens never escape the outer Lex function anyway.



Comment at: clang/lib/Lex/Preprocessor.cpp:1136
 EnterTokenStream(std::move(ToksCopy), Toks.size(),
- /*DisableMacroExpansion*/ true);
+ /*DisableMacroExpansion*/ true, IsReinject);
   };

I think this should always be `false`: the tokens we're producing here have 
never been emitted at `LexLevel` 0 before.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59885



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


[PATCH] D61958: [analyzer] RetainCount: Fix a crash when os_returns_retained_on_zero (_nonzero) is applied to functions that return weird stuff.

2019-05-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added a reviewer: dcoughlin.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

The checker crashes when it tries to assume a structure to be null or non-null 
so that to evaluate the effect of the annotation.


Repository:
  rC Clang

https://reviews.llvm.org/D61958

Files:
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  clang/test/Analysis/osobject-retain-release.cpp


Index: clang/test/Analysis/osobject-retain-release.cpp
===
--- clang/test/Analysis/osobject-retain-release.cpp
+++ clang/test/Analysis/osobject-retain-release.cpp
@@ -702,3 +702,16 @@
   // returning from it at +0.
   return table; // no-warning
 }
+
+namespace weird_result {
+struct WeirdResult {
+  int x, y, z;
+};
+
+WeirdResult outParamWithWeirdResult(OS_RETURNS_RETAINED_ON_ZERO OSObject 
**obj);
+
+WeirdResult testOutParamWithWeirdResult() {
+  OSObject *obj;
+  return outParamWithWeirdResult(); // no-warning
+}
+} // namespace weird_result
Index: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -537,6 +537,11 @@
   ProgramStateRef AssumeZeroReturn = State;
 
   if (SplitNecessary) {
+if (!CE.getResultType()->isScalarType()) {
+  // Structures cannot be assumed. This probably deserves
+  // a compiler warning for invalid annotations.
+  return {State};
+}
 if (auto DL = L.getAs()) {
   AssumeNonZeroReturn = AssumeNonZeroReturn->assume(*DL, true);
   AssumeZeroReturn = AssumeZeroReturn->assume(*DL, false);


Index: clang/test/Analysis/osobject-retain-release.cpp
===
--- clang/test/Analysis/osobject-retain-release.cpp
+++ clang/test/Analysis/osobject-retain-release.cpp
@@ -702,3 +702,16 @@
   // returning from it at +0.
   return table; // no-warning
 }
+
+namespace weird_result {
+struct WeirdResult {
+  int x, y, z;
+};
+
+WeirdResult outParamWithWeirdResult(OS_RETURNS_RETAINED_ON_ZERO OSObject **obj);
+
+WeirdResult testOutParamWithWeirdResult() {
+  OSObject *obj;
+  return outParamWithWeirdResult(); // no-warning
+}
+} // namespace weird_result
Index: clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -537,6 +537,11 @@
   ProgramStateRef AssumeZeroReturn = State;
 
   if (SplitNecessary) {
+if (!CE.getResultType()->isScalarType()) {
+  // Structures cannot be assumed. This probably deserves
+  // a compiler warning for invalid annotations.
+  return {State};
+}
 if (auto DL = L.getAs()) {
   AssumeNonZeroReturn = AssumeNonZeroReturn->assume(*DL, true);
   AssumeZeroReturn = AssumeZeroReturn->assume(*DL, false);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61957: [CodeGenObjC] invoke objc_autorelease, objc_retain when necessary

2019-05-15 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: ahatanak, rjmccall.
Herald added subscribers: dexonsmith, jkorous.
Herald added a project: clang.

Any of these methods can be overridden, so we always need to conservatively 
`invoke` these calls.


Repository:
  rC Clang

https://reviews.llvm.org/D61957

Files:
  clang/lib/CodeGen/CGObjC.cpp
  clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m

Index: clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m
+++ clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -177,8 +177,8 @@
 
 @class Ety;
 
-// CHECK-LABEL: define {{.*}}void @testException
-void testException(NSObject *a) {
+// CHECK-LABEL: define {{.*}}void @testException_release
+void testException_release(NSObject *a) {
   // MSGS: {{invoke.*@objc_msgSend}}
   // CALLS: invoke{{.*}}void @objc_release(i8* %
   @try {
@@ -186,3 +186,23 @@
   } @catch (Ety *e) {
   }
 }
+
+// CHECK-LABEL: define {{.*}}void @testException_autorelease
+void testException_autorelease(NSObject *a) {
+  @try {
+// MSGS: {{invoke.*@objc_msgSend}}
+// CALLS: invoke{{.*}}objc_autorelease(i8* %
+[a autorelease];
+  } @catch (Ety *e) {
+  }
+}
+
+// CHECK-LABEL: define {{.*}}void @testException_retain
+void testException_retain(NSObject *a) {
+  @try {
+// MSGS: {{invoke.*@objc_msgSend}}
+// CALLS: invoke{{.*}}@objc_retain(i8* %
+[a retain];
+  } @catch (Ety *e) {
+  }
+}
Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -2059,7 +2059,7 @@
llvm::Value *value,
llvm::Type *returnType,
llvm::FunctionCallee ,
-   StringRef fnName, bool MayThrow) {
+   StringRef fnName) {
   if (isa(value))
 return value;
 
@@ -2080,10 +2080,7 @@
 
   // Call the function.
   llvm::CallBase *Inst = nullptr;
-  if (MayThrow)
-Inst = CGF.EmitCallOrInvoke(fn, value);
-  else
-Inst = CGF.EmitNounwindRuntimeCall(fn, value);
+  Inst = CGF.EmitCallOrInvoke(fn, value);
 
   // Cast the result back to the original type.
   return CGF.Builder.CreateBitCast(Inst, origType);
@@ -2536,7 +2533,7 @@
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_alloc,
-"objc_alloc", /*MayThrow=*/true);
+"objc_alloc");
 }
 
 /// Allocate the given objc object.
@@ -2545,14 +2542,14 @@
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_allocWithZone,
-"objc_allocWithZone", /*MayThrow=*/true);
+"objc_allocWithZone");
 }
 
 llvm::Value *CodeGenFunction::EmitObjCAllocInit(llvm::Value *value,
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_alloc_init,
-"objc_alloc_init", /*MayThrow=*/true);
+"objc_alloc_init");
 }
 
 /// Produce the code to do a primitive release.
@@ -2596,7 +2593,7 @@
   return emitObjCValueOperation(
   *this, value, returnType,
   CGM.getObjCEntrypoints().objc_autoreleaseRuntimeFunction,
-  "objc_autorelease", /*MayThrow=*/false);
+  "objc_autorelease");
 }
 
 /// Retain the given object, with normal retain semantics.
@@ -2605,8 +2602,7 @@
  llvm::Type *returnType) {
   return emitObjCValueOperation(
   *this, value, returnType,
-  CGM.getObjCEntrypoints().objc_retainRuntimeFunction, "objc_retain",
-  /*MayThrow=*/false);
+  CGM.getObjCEntrypoints().objc_retainRuntimeFunction, "objc_retain");
 }
 
 /// Release the given object.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-15 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D61909#1502446 , @winksaville wrote:

> Questions:
>
> - Should we only build `libclang_shared.so` if `LLVM_BUILD_LLVM_DYLIB` is ON?


`LLVM_BUILD_LLVM_DYLIB` is actually not the important option to think about 
because it has no impact on this, rather `LLVM_LINK_LLVM_DYLIB`. That really 
depends on what tradeoffs you want. With that option off LLVM will be linked 
statically into the Clang library, which in the common case is fine because you 
can resolve all the LLVM & Clang APIs against it. That will be faster to load, 
but a larger binary distribution. With the option on, libclang_shared will link 
libLLVM, which will result in slower loading times, but smaller distributions. 
Both are workable situations.

> - Should we use link clang-9 to libclang_shared.so when 
> `LLVM_LINK_LLVM_DYLIB` is ON?

No. If we want to support that it should be through its own option which we can 
add in a subsequent patch.

> - Or maybe we should define `BUILD_CLANG_DYLIB` and `LINK_CLANG_DYLIB` or ... 
> ?

I'm not sure there is value in a `BUILD_CLANG_DYLIB` option (and frankly 
`LLVM_BUILD_LLVM_DYLIB` should probably go too). Between when I added the 
support for building libLLVM and now I've shifted my mindset about build system 
functionality. Optimizing the build time of the `all` target seems way less 
worthwhile to me than reducing complication in the build system. Most 
developers iterate by running `check*` targets over and over again rather than 
building `all`, and as long as the dependencies are properly set up adding 
additional targets has little impact on iteration time or perceived build time.

A `CLANG_LINK_CLANG_DYLIB` option probably does make sense to add in order to 
support smaller binary distributions, although I am concerned about 
communicating the impact of that and the `LLVM_LINK_LLVM_DYLIB` options. In the 
past I've seen people do compile-time performance comparisons between GCC and 
Clang using the `BUILD_SHARED_LIBS` option when building Clang, and it leads to 
really misleading results. I would be very frustrated to see a pile of blog 
posts saying that Clang is getting slower just because people are deciding to 
make clang dynamically link its components.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61909



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


[PATCH] D59885: [Lex] Allow to consume tokens while preprocessing

2019-05-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/lib/Lex/Preprocessor.cpp:955
   --LexLevel;
+  if (OnToken && LexLevel == 0 && !Result.getFlag(Token::IsReinjected))
+OnToken(Result);

Could probably remove the `IsReinjected` check from here. It's fine to check 
this on the client side.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59885



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


[PATCH] D59885: [Lex] Allow to consume tokens while preprocessing

2019-05-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 199639.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Improve comment, remove redundant braces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59885

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Lex/Token.h
  clang/include/clang/Lex/TokenLexer.h
  clang/include/clang/Parse/Parser.h
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/lib/Lex/MacroArgs.cpp
  clang/lib/Lex/PPCaching.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Lex/TokenLexer.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Rewrite/HTMLRewrite.cpp

Index: clang/lib/Rewrite/HTMLRewrite.cpp
===
--- clang/lib/Rewrite/HTMLRewrite.cpp
+++ clang/lib/Rewrite/HTMLRewrite.cpp
@@ -572,7 +572,7 @@
 
   // Enter the tokens we just lexed.  This will cause them to be macro expanded
   // but won't enter sub-files (because we removed #'s).
-  TmpPP.EnterTokenStream(TokenStream, false);
+  TmpPP.EnterTokenStream(TokenStream, false, /*IsReinject=*/false);
 
   TokenConcatenation ConcatInfo(TmpPP);
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1545,7 +1545,7 @@
   if (PP.isBacktrackEnabled())
 PP.RevertCachedTokens(1);
   else
-PP.EnterToken(Tok);
+PP.EnterToken(Tok, /*IsReinject=*/true);
   Tok.setKind(tok::annot_cxxscope);
   Tok.setAnnotationValue(Actions.SaveNestedNameSpecifierAnnotation(SS));
   Tok.setAnnotationRange(SS.getRange());
@@ -1764,7 +1764,7 @@
   Token TypedefToken;
   PP.Lex(TypedefToken);
   bool Result = TryAnnotateTypeOrScopeToken();
-  PP.EnterToken(Tok);
+  PP.EnterToken(Tok, /*IsReinject=*/true);
   Tok = TypedefToken;
   if (!Result)
 Diag(Tok.getLocation(), diag::warn_expected_qualified_after_typename);
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -919,7 +919,7 @@
 PrevTokLocation = RAngleLoc;
   } else {
 PrevTokLocation = TokBeforeGreaterLoc;
-PP.EnterToken(Tok);
+PP.EnterToken(Tok, /*IsReinject=*/true);
 Tok = Greater;
   }
 
@@ -1402,7 +1402,7 @@
   // Append the current token at the end of the new token stream so that it
   // doesn't get lost.
   LPT.Toks.push_back(Tok);
-  PP.EnterTokenStream(LPT.Toks, true);
+  PP.EnterTokenStream(LPT.Toks, true, /*IsReinject*/true);
 
   // Consume the previously pushed token.
   ConsumeAnyToken(/*ConsumeCodeCompletionTok=*/true);
Index: clang/lib/Parse/ParseStmtAsm.cpp
===
--- clang/lib/Parse/ParseStmtAsm.cpp
+++ clang/lib/Parse/ParseStmtAsm.cpp
@@ -213,7 +213,8 @@
   // Also copy the current token over.
   LineToks.push_back(Tok);
 
-  PP.EnterTokenStream(LineToks, /*DisableMacroExpansions*/ true);
+  PP.EnterTokenStream(LineToks, /*DisableMacroExpansions*/ true,
+  /*IsReinject*/ true);
 
   // Clear the current token and advance to the first token in LineToks.
   ConsumeAnyToken();
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -117,7 +117,8 @@
 Toks[0].setAnnotationEndLoc(Tok.getLocation());
 Toks[0].setAnnotationValue(reinterpret_cast(
static_cast(OOS)));
-PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true);
+PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true,
+/*IsReinject=*/false);
   }
 };
 
@@ -739,7 +740,8 @@
   // Grab the tokens out of the annotation and enter them into the stream.
   auto TheTokens =
   (std::pair, size_t> *)Tok.getAnnotationValue();
-  PP.EnterTokenStream(std::move(TheTokens->first), TheTokens->second, true);
+  PP.EnterTokenStream(std::move(TheTokens->first), TheTokens->second, true,
+  /*IsReinject=*/true);
   SourceLocation PragmaLocation = ConsumeAnnotationToken();
   assert(Tok.isAnyIdentifier());
   StringRef PragmaName = Tok.getIdentifierInfo()->getName();
@@ -,7 +1113,8 @@
 Hint.StateLoc = IdentifierLoc::create(Actions.Context, StateLoc, StateInfo);
   } else {
 // 

[clang-tools-extra] r360788 - [clang-tidy] Recommit r360785 "modernize-loop-convert: impl const cast iter" with correct attribution

2019-05-15 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Wed May 15 10:47:51 2019
New Revision: 360788

URL: http://llvm.org/viewvc/llvm-project?rev=360788=rev
Log:
[clang-tidy] Recommit r360785 "modernize-loop-convert: impl const cast iter" 
with correct attribution

Summary:
modernize-loop-convert was not detecting implicit casts to
const_iterator as convertible to range-based loops:

std::vector vec{1,2,3,4}
for(std::vector::const_iterator i = vec.begin();
i != vec.end();
++i) { }

Thanks to Don Hinton for advice.

As well, this change adds a note for this check's applicability to code
targeting OpenMP prior version 5 as this check will continue breaking
compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this
out.

Fixes PR#35082

Patch by Torbjörn Klatt!

Reviewed By: hintonda

Tags: #clang-tools-extra, #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=360788=360787=360788=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Wed May 
15 10:47:51 2019
@@ -791,11 +791,6 @@ bool LoopConvertCheck::isConvertible(AST
   CanonicalBeginType->getPointeeType(),
   CanonicalInitVarType->getPointeeType()))
 return false;
-} else if (!Context->hasSameType(CanonicalInitVarType,
- CanonicalBeginType)) {
-  // Check for qualified types to avoid conversions from non-const to const
-  // iterator types.
-  return false;
 }
   } else if (FixerKind == LFK_PseudoArray) {
 // This call is required to obtain the container.

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst?rev=360788=360787=360788=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst 
Wed May 15 10:47:51 2019
@@ -253,3 +253,15 @@ below ends up being performed at the `sa
   flag = true;
 }
   }
+
+OpenMP
+^^
+
+As range-based for loops are only available since OpenMP 5, this check should
+not been used on code with a compatibility requirements of OpenMP prior to
+version 5. It is **intentional** that this check does not make any attempts to
+exclude incorrect diagnostics on OpenMP for loops prior to OpenMP 5.
+
+To prevent this check to be applied (and to break) OpenMP for loops but still 
be
+applied to non-OpenMP for loops the usage of ``NOLINT`` (see
+:ref:`clang-tidy-nolint`) on the specific for loops is recommended.

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=360788=360787=360788=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Wed May 15 10:47:51 2019
@@ -258,6 +258,8 @@ An overview of all the command-line opti
   value:   'some value'
   ...
 
+.. _clang-tidy-nolint:
+
 Suppressing Undesired Diagnostics
 =
 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp?rev=360788=360787=360788=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
Wed May 15 10:47:51 2019
@@ -369,7 +369,7 @@ void f() {
 // CHECK-FIXES: for (auto Val_int_ptr : Val_int_ptrs)
   }
 
-  // This container uses an iterator where the derefence type is a typedef of
+  // This container uses an iterator where the dereference type is a typedef of
   // a reference type. Make sure non-const auto & is still used. A failure here
   // means canonical types aren't being tested.
   {
@@ -431,19 +431,22 @@ void different_type() {
   // CHECK-FIXES: for 

[PATCH] D61923: [GWP-ASan] Mutex implementation [2].

2019-05-15 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

In D61923#1503272 , @jfb wrote:

> Have you asked on libcxx-dev whether a stand-alone base is something of 
> interest to them?


No, but I will follow up on that.

> Kinda... but your answer really sounds like this is a Google-only project, 
> with intended uses only for some Google applications. That's not necessarily 
> a bad thing, but it's really weird: my impression was that GWP and Scudo were 
> intended to be generally usable elsewhere. Is that not the case?
> 
> Not that I expect *you* to do any porting work, but the direction you're 
> setting just sounds like "well, we're our only users and we'll take the path 
> that'll work for us". None of the reasoning seems to be truly technical, it's 
> more "these projects we want to integrate into build this way, so we should 
> fit in that way". i.e. it's more about implementation convenience than 
> anything else. Is that the case? Implementation convenience is sometimes a 
> good reason, but as I've outlined above I think you need to provide more 
> thoughtful reasoning.

I definitely don't want that to be the case, or to have it come across that 
way. We want a reference implementation that's available for any allocator to 
drop in and use, with minor tweaking. As part of that, our goal is to make the 
requirements to support GWP-ASan as low as possible, preferably as simple as 
"merge this into your codebase somewhere, and you're good to go". We inherit 
the restrictions of each allocator's build system, which means more restrictive 
environment for us, but we can be drop-in supported pretty much everywhere. Our 
plans for this reference implementation is to use it in Android and Fuchsia, 
but we would love to collaborate with other interested projects to hear about 
what their requirements would be as well.

We discussed at length whether to have GWP-ASan be a standalone GitHub project 
(similar to Scudo standalone), or as part of compiler-rt. We decided to put it 
into compiler-rt because we can then exercise LLVM's extensive 
build/test/review infrastructure and open-source licensing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61923



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


[PATCH] D59885: [Lex] Allow to consume tokens while preprocessing

2019-05-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

I've added a new parameter to `EnterToken` and `EnterTokenStream`. There are a 
bunch of interesting cases.

`Preprocessor::AnnotateCachedTokens` is one. It consumes some `CachedTokens` 
(which are always considered re-injected) and replaces them with a single 
annotation token (which we normally don't consider re-injected).
So we end up with an annotation token that is re-injected (and therefore never 
reported). That's ok for our current use-cases, so I won't try to fix it in 
this change. If this actually turns out important at any moment, can fix in a 
follow-up.

Another interesting case is parser "tweaking" tokens and re-introducing them, 
e.g. `FixDigraph` that turns a digraph token into two or various recoveries 
turning `::` into `:` or introducing ephemeral `;` and `}` tokens.
I've decided to mark those as re-injected for the time being, that is fine for 
now and I'm happy to reconsider later if it turns out we need them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59885



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


[PATCH] D59885: [Lex] Allow to consume tokens while preprocessing

2019-05-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 199637.
ilya-biryukov added a comment.
Herald added a subscriber: eraman.

- Properly mark tokens as reinjected where necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59885

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Lex/Token.h
  clang/include/clang/Lex/TokenLexer.h
  clang/include/clang/Parse/Parser.h
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/lib/Lex/MacroArgs.cpp
  clang/lib/Lex/PPCaching.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Lex/TokenLexer.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Rewrite/HTMLRewrite.cpp

Index: clang/lib/Rewrite/HTMLRewrite.cpp
===
--- clang/lib/Rewrite/HTMLRewrite.cpp
+++ clang/lib/Rewrite/HTMLRewrite.cpp
@@ -572,7 +572,7 @@
 
   // Enter the tokens we just lexed.  This will cause them to be macro expanded
   // but won't enter sub-files (because we removed #'s).
-  TmpPP.EnterTokenStream(TokenStream, false);
+  TmpPP.EnterTokenStream(TokenStream, false, /*IsReinject=*/false);
 
   TokenConcatenation ConcatInfo(TmpPP);
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1545,7 +1545,7 @@
   if (PP.isBacktrackEnabled())
 PP.RevertCachedTokens(1);
   else
-PP.EnterToken(Tok);
+PP.EnterToken(Tok, /*IsReinject=*/true);
   Tok.setKind(tok::annot_cxxscope);
   Tok.setAnnotationValue(Actions.SaveNestedNameSpecifierAnnotation(SS));
   Tok.setAnnotationRange(SS.getRange());
@@ -1764,7 +1764,7 @@
   Token TypedefToken;
   PP.Lex(TypedefToken);
   bool Result = TryAnnotateTypeOrScopeToken();
-  PP.EnterToken(Tok);
+  PP.EnterToken(Tok, /*IsReinject=*/true);
   Tok = TypedefToken;
   if (!Result)
 Diag(Tok.getLocation(), diag::warn_expected_qualified_after_typename);
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -919,7 +919,7 @@
 PrevTokLocation = RAngleLoc;
   } else {
 PrevTokLocation = TokBeforeGreaterLoc;
-PP.EnterToken(Tok);
+PP.EnterToken(Tok, /*IsReinject=*/true);
 Tok = Greater;
   }
 
@@ -1402,7 +1402,7 @@
   // Append the current token at the end of the new token stream so that it
   // doesn't get lost.
   LPT.Toks.push_back(Tok);
-  PP.EnterTokenStream(LPT.Toks, true);
+  PP.EnterTokenStream(LPT.Toks, true, /*IsReinject*/true);
 
   // Consume the previously pushed token.
   ConsumeAnyToken(/*ConsumeCodeCompletionTok=*/true);
Index: clang/lib/Parse/ParseStmtAsm.cpp
===
--- clang/lib/Parse/ParseStmtAsm.cpp
+++ clang/lib/Parse/ParseStmtAsm.cpp
@@ -213,7 +213,8 @@
   // Also copy the current token over.
   LineToks.push_back(Tok);
 
-  PP.EnterTokenStream(LineToks, /*DisableMacroExpansions*/ true);
+  PP.EnterTokenStream(LineToks, /*DisableMacroExpansions*/ true,
+  /*IsReinject*/ true);
 
   // Clear the current token and advance to the first token in LineToks.
   ConsumeAnyToken();
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -117,7 +117,8 @@
 Toks[0].setAnnotationEndLoc(Tok.getLocation());
 Toks[0].setAnnotationValue(reinterpret_cast(
static_cast(OOS)));
-PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true);
+PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true,
+/*IsReinject=*/false);
   }
 };
 
@@ -739,7 +740,8 @@
   // Grab the tokens out of the annotation and enter them into the stream.
   auto TheTokens =
   (std::pair, size_t> *)Tok.getAnnotationValue();
-  PP.EnterTokenStream(std::move(TheTokens->first), TheTokens->second, true);
+  PP.EnterTokenStream(std::move(TheTokens->first), TheTokens->second, true,
+  /*IsReinject=*/true);
   SourceLocation PragmaLocation = ConsumeAnnotationToken();
   assert(Tok.isAnyIdentifier());
   StringRef PragmaName = Tok.getIdentifierInfo()->getName();
@@ -,7 +1113,8 @@
 Hint.StateLoc = IdentifierLoc::create(Actions.Context, StateLoc, StateInfo);
   } else {
 // 

[clang-tools-extra] r360787 - Revert [clang-tidy] modernize-loop-convert: impl const cast iter

2019-05-15 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Wed May 15 10:36:54 2019
New Revision: 360787

URL: http://llvm.org/viewvc/llvm-project?rev=360787=rev
Log:
Revert [clang-tidy] modernize-loop-convert: impl const cast iter

This reverts r360785 (git commit 42d28be802fe5beab18bc1a27f89894c0a290d44)

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=360787=360786=360787=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Wed May 
15 10:36:54 2019
@@ -791,6 +791,11 @@ bool LoopConvertCheck::isConvertible(AST
   CanonicalBeginType->getPointeeType(),
   CanonicalInitVarType->getPointeeType()))
 return false;
+} else if (!Context->hasSameType(CanonicalInitVarType,
+ CanonicalBeginType)) {
+  // Check for qualified types to avoid conversions from non-const to const
+  // iterator types.
+  return false;
 }
   } else if (FixerKind == LFK_PseudoArray) {
 // This call is required to obtain the container.

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst?rev=360787=360786=360787=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst 
Wed May 15 10:36:54 2019
@@ -253,15 +253,3 @@ below ends up being performed at the `sa
   flag = true;
 }
   }
-
-OpenMP
-^^
-
-As range-based for loops are only available since OpenMP 5, this check should
-not been used on code with a compatibility requirements of OpenMP prior to
-version 5. It is **intentional** that this check does not make any attempts to
-exclude incorrect diagnostics on OpenMP for loops prior to OpenMP 5.
-
-To prevent this check to be applied (and to break) OpenMP for loops but still 
be
-applied to non-OpenMP for loops the usage of ``NOLINT`` (see
-:ref:`clang-tidy-nolint`) on the specific for loops is recommended.

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=360787=360786=360787=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Wed May 15 10:36:54 2019
@@ -258,8 +258,6 @@ An overview of all the command-line opti
   value:   'some value'
   ...
 
-.. _clang-tidy-nolint:
-
 Suppressing Undesired Diagnostics
 =
 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp?rev=360787=360786=360787=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
Wed May 15 10:36:54 2019
@@ -369,7 +369,7 @@ void f() {
 // CHECK-FIXES: for (auto Val_int_ptr : Val_int_ptrs)
   }
 
-  // This container uses an iterator where the dereference type is a typedef of
+  // This container uses an iterator where the derefence type is a typedef of
   // a reference type. Make sure non-const auto & is still used. A failure here
   // means canonical types aren't being tested.
   {
@@ -431,22 +431,19 @@ void different_type() {
   // CHECK-FIXES: for (auto P : *Ps)
   // CHECK-FIXES-NEXT: printf("s has value %d\n", P.X);
 
+  // V.begin() returns a user-defined type 'iterator' which, since it's
+  // different from const_iterator, disqualifies these loops from
+  // transformation.
   dependent V;
   for (dependent::const_iterator It = V.begin(), E = V.end();
It != E; ++It) {
 printf("Fibonacci number is %d\n", *It);
   }
-  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int It : V)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
 
   for (dependent::const_iterator 

[PATCH] D61747: [clang-tidy] remove default header-filter for run-clang-tidy

2019-05-15 Thread Don Hinton via Phabricator via cfe-commits
hintonda added a comment.

I've also had issues with this behavior.  It's a bad default, as the PR notes, 
but is there a way to provide a better one and still respect the config file?

Also, could you add a test for this?  Perhaps in 
`clang-tools-extra/test//clang-tidy/run-clang-tidy.cpp`.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61747



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


[PATCH] D61950: [PowerPC64] adds ABI parsing when specified on target triple

2019-05-15 Thread Alfredo Dal'Ava Júnior via Phabricator via cfe-commits
adalava marked 3 inline comments as done.
adalava added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:217
   case Triple::ppc64:
-return PPCTargetMachine::PPC_ABI_ELFv1;
+// if ELFv2 on target triple i.e. powerpc64-unknown-freebsd12.0-elfv2
+if (TT.getEnvironment() == llvm::Triple::ELFv2)

MaskRay wrote:
> The initial word should be capitalized and the sentence should end with a 
> period. At least this part of the comment (`if ELFv2 on target triple `) is 
> redundant. I don't know if the other half 
> `powerpc64-unknown-freebsd12.0-elfv2` is useful...
yeah, sounds like code clears explains itself. I'm removing the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61950



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


[PATCH] D61950: [PowerPC64] adds ABI parsing when specified on target triple

2019-05-15 Thread Alfredo Dal'Ava Júnior via Phabricator via cfe-commits
adalava updated this revision to Diff 199633.
adalava added a comment.

- remove redundant comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61950

Files:
  clang/lib/Basic/Targets/PPC.h
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
  llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll


Index: llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
===
--- llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
+++ llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
@@ -5,6 +5,14 @@
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu 
-target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu 
-target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
 
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd < %s | 
FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd 
-target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd 
-target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd-elfv1  < 
%s | FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd-elfv2  < 
%s | FileCheck %s -check-prefix=CHECK-ELFv2
+
+
+
 ; CHECK-ELFv2: .abiversion 2
 ; CHECK-ELFv1-NOT: .abiversion 2
 
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
===
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -214,7 +214,10 @@
   case Triple::ppc64le:
 return PPCTargetMachine::PPC_ABI_ELFv2;
   case Triple::ppc64:
-return PPCTargetMachine::PPC_ABI_ELFv1;
+if (TT.getEnvironment() == llvm::Triple::ELFv2)
+  return PPCTargetMachine::PPC_ABI_ELFv2;
+else
+  return PPCTargetMachine::PPC_ABI_ELFv1;
   default:
 return PPCTargetMachine::PPC_ABI_UNKNOWN;
   }
Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -232,6 +232,8 @@
   case Musl: return "musl";
   case MuslEABI: return "musleabi";
   case MuslEABIHF: return "musleabihf";
+  case ELFv1: return "elfv1";
+  case ELFv2: return "elfv2";
   case MSVC: return "msvc";
   case Itanium: return "itanium";
   case Cygnus: return "cygnus";
@@ -532,6 +534,8 @@
 .StartsWith("musleabihf", Triple::MuslEABIHF)
 .StartsWith("musleabi", Triple::MuslEABI)
 .StartsWith("musl", Triple::Musl)
+.StartsWith("elfv1", Triple::ELFv1)
+.StartsWith("elfv2", Triple::ELFv2)
 .StartsWith("msvc", Triple::MSVC)
 .StartsWith("itanium", Triple::Itanium)
 .StartsWith("cygnus", Triple::Cygnus)
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -206,6 +206,8 @@
 Musl,
 MuslEABI,
 MuslEABIHF,
+ELFv1,
+ELFv2,
 
 MSVC,
 Itanium,
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -379,13 +379,11 @@
 
 if ((Triple.getArch() == llvm::Triple::ppc64le)) {
   resetDataLayout("e-m:e-i64:64-n32:64");
-  ABI = "elfv2";
 } else {
   resetDataLayout("E-m:e-i64:64-n32:64");
-  ABI = "elfv1";
 }
 
-switch (getTriple().getOS()) {
+switch (Triple.getOS()) {
 case llvm::Triple::FreeBSD:
   LongDoubleWidth = LongDoubleAlign = 64;
   LongDoubleFormat = ::APFloat::IEEEdouble();


Index: llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
===
--- llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
+++ llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
@@ -5,6 +5,14 @@
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
 
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd < %s | FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd -target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd -target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd-elfv1  < %s | FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc 

[PATCH] D61950: [PowerPC64] adds ABI parsing when specified on target triple

2019-05-15 Thread Alfredo Dal'Ava Júnior via Phabricator via cfe-commits
adalava marked an inline comment as done.
adalava added inline comments.



Comment at: clang/lib/Basic/Targets/PPC.h:382
   resetDataLayout("e-m:e-i64:64-n32:64");
-  ABI = "elfv2";
 } else {

MaskRay wrote:
> MaskRay wrote:
> > Have you researched how GNU as chooses the default ABI?
> > 
> > I think the change may break some Linux ppc64le users as they expect the 
> > default elfv2.
> Sorry, it won't :) Then I think it is fine.
I didn't look the code, but behavior on GNU is the same as LLVM too:
-  powerpc64-* and elfv2 if "powerpc64le-*" and last

I found setting the ABI value here is useless so I decided to remove to keep it 
consistent with it's  "sister" X86 class and checked that no tests are broken 
after this, but would be nice if someone with more LLVm experience could give 
another look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61950



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


[PATCH] D61923: [GWP-ASan] Mutex implementation [2].

2019-05-15 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

> In D61923#1502404 , @jfb wrote:
> 
>> > We can't use `std::mutex` as we must be C-compatible
>>
>> Can you clarify what you mean by this? I don't understand.
>>  Have you asked on libcxx-dev? Is there interest in the libc++ community for 
>> a stand-alone base?
> 
> 
> Sorry, poor choice of wording. Our archive must be able to be statically 
> linked into the supporting allocators. At this stage, the plans are to 
> implement GWP-ASan into Scudo and Android's bionic libc. This means we have 
> to be compatible with the the most restrictive aspects of each allocator's 
> build environment, simultaneously.
> 
> In practice, we can't use `std::mutex` because Scudo specifies `-nostdlib++ 
> -nodefaultlibs`, and if any part of the implementation of `std::mutex` (and 
> likewise `mtx_t`) falls outside of the header file, we will fail to link (as 
> is the case with libc++).

Have you asked on libcxx-dev whether a stand-alone base is something of 
interest to them?

>>> We also are trying to stay independent of `pthread` for 
>>> platform-independentness.
>> 
>> The code I see is clearly not platform independent. Please clarify your 
>> reasoning. I can understand if you don't want pthread for a valid reason, 
>> but "platform-independence" doesn't make sense here.
> 
> My view was that small stubs to implement the architecture-dependent and 
> OS-dependent functionality is much easier to manage. If we use `pthread` on 
> unix, and `CreateMutex` on Windows, we still have to have OS-dependent 
> ifdefs, but we then pass on the requirement to the supporting allocator to 
> ensure our dependencies are there (which could be a huge pain point both for 
> Scudo+fuchsia and Android).
> 
>>> We also can't use a `sanitizer_common` variant as we don't want to pull in 
>>> the entirety `sanitizer_common` as a dependency.
>> 
>> What's the restriction that makes it unacceptable?
> 
> Scudo (standalone) can't pull in the entirety of sanitizer_common (code size 
> + maintainability for fuchsia). It's also a much easier track to get Android 
> supported if we don't have to pull in and build the entirety of 
> sanitizer_common.
> 
>>> Basically, the roadmap is to create a shared mutex library for 
>>> `sanitizer_common`, `gwp_asan` and `scudo` to all use.
>> 
>> I'm asking all these question because they should be in the commit message, 
>> and would hopefully have surfaced from the RFC about GWP / Scudo. If those 
>> weren't in the RFC that's fine, they should still be in the commit message 
>> and you'll want to update the RFC with "while reviewing code we realized 
>> *stuff*".
> 
> Ack.
> 
>>> I think the idea is that implementing our own spinlock is not much harder 
>>> than having 3 platform-specific implementations (posix, window, fuchsia).
>> 
>> Your concerns are backwards. Implementation is a one-time thing, maintenance 
>> is an ongoing concern and it way overshadows implementation concerns. In 
>> particular, a variety of multicore code that does its own locking is much 
>> harder to tune at the system-wide level compared to a single thing that's 
>> tuned for each application. I'm not saying a separate mutex doesn't make 
>> sense, what I'm saying is that experience shows your above reasoning to be 
>> generally invalid. I'm totally willing to believe that there's a very good 
>> reason to have your own mutex here, but you gotta explain it.
> 
> Hopefully above helps to clarify :)

Kinda... but your answer really sounds like this is a Google-only project, with 
intended uses only for some Google applications. That's not necessarily a bad 
thing, but it's really weird: my impression was that GWP and Scudo were 
intended to be generally usable elsewhere. Is that not the case?

Not that I expect *you* to do any porting work, but the direction you're 
setting just sounds like "well, we're our only users and we'll take the path 
that'll work for us". None of the reasoning seems to be truly technical, it's 
more "these projects we want to integrate into build this way, so we should fit 
in that way". i.e. it's more about implementation convenience than anything 
else. Is that the case? Implementation convenience is sometimes a good reason, 
but as I've outlined above I think you need to provide more thoughtful 
reasoning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61923



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


Re: [clang-tools-extra] r360785 - [clang-tidy] modernize-loop-convert: impl const cast iter

2019-05-15 Thread Don Hinton via cfe-commits
Just wanted to note that this patch was contributed by Torbjörn Klatt, and
I failed to add the following line to the commit message:

Patch by Torbjörn Klatt!

Sorry about that Torbjörn.

On Wed, May 15, 2019 at 9:56 AM Don Hinton via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: dhinton
> Date: Wed May 15 09:58:58 2019
> New Revision: 360785
>
> URL: http://llvm.org/viewvc/llvm-project?rev=360785=rev
> Log:
> [clang-tidy] modernize-loop-convert: impl const cast iter
>
> Summary:
> modernize-loop-convert was not detecting implicit casts to
> const_iterator as convertible to range-based loops:
>
> std::vector vec{1,2,3,4}
> for(std::vector::const_iterator i = vec.begin();
> i != vec.end();
> ++i) { }
>
> Thanks to Don Hinton for advice.
>
> As well, this change adds a note for this check's applicability to code
> targeting OpenMP prior to version 5 as this check will continue breaking
> compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this
> out.
>
> Fixes PR#35082
>
> Reviewed By: hintonda
>
> Tags: #clang-tools-extra, #clang
>
> Differential Revision: https://reviews.llvm.org/D61827
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
>
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
> clang-tools-extra/trunk/docs/clang-tidy/index.rst
>
> clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
>
> clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
>
> Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=360785=360784=360785=diff
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Wed
> May 15 09:58:58 2019
> @@ -791,11 +791,6 @@ bool LoopConvertCheck::isConvertible(AST
>CanonicalBeginType->getPointeeType(),
>CanonicalInitVarType->getPointeeType()))
>  return false;
> -} else if (!Context->hasSameType(CanonicalInitVarType,
> - CanonicalBeginType)) {
> -  // Check for qualified types to avoid conversions from non-const to
> const
> -  // iterator types.
> -  return false;
>  }
>} else if (FixerKind == LFK_PseudoArray) {
>  // This call is required to obtain the container.
>
> Modified:
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst?rev=360785=360784=360785=diff
>
> ==
> ---
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
> (original)
> +++
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
> Wed May 15 09:58:58 2019
> @@ -253,3 +253,15 @@ below ends up being performed at the `sa
>flag = true;
>  }
>}
> +
> +OpenMP
> +^^
> +
> +As range-based for loops are only available since OpenMP 5, this check
> should
> +not been used on code with a compatibility requirements of OpenMP prior to
> +version 5. It is **intentional** that this check does not make any
> attempts to
> +exclude incorrect diagnostics on OpenMP for loops prior to OpenMP 5.
> +
> +To prevent this check to be applied (and to break) OpenMP for loops but
> still be
> +applied to non-OpenMP for loops the usage of ``NOLINT`` (see
> +:ref:`clang-tidy-nolint`) on the specific for loops is recommended.
>
> Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=360785=360784=360785=diff
>
> ==
> --- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
> +++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Wed May 15 09:58:58
> 2019
> @@ -258,6 +258,8 @@ An overview of all the command-line opti
>value:   'some value'
>...
>
> +.. _clang-tidy-nolint:
> +
>  Suppressing Undesired Diagnostics
>  =
>
>
> Modified:
> clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp?rev=360785=360784=360785=diff
>
> ==
> ---
> clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
> (original)
> +++
> clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
> Wed May 15 09:58:58 2019
> @@ -369,7 +369,7 @@ void f() {
> 

[PATCH] D61923: [GWP-ASan] Mutex implementation [2].

2019-05-15 Thread Mitch Phillips via Phabricator via cfe-commits
hctim updated this revision to Diff 199632.
hctim marked 2 inline comments as done.
hctim added a comment.

In D61923#1502988 , @cryptoad wrote:

> Is the question why do Scudo has its own as opposed to rely on platform 
> specific ones?


Yes, I have assumptions about why, but would love to hear right from the 
horse's mouth :)

In D61923#1502404 , @jfb wrote:

> > We can't use `std::mutex` as we must be C-compatible
>
> Can you clarify what you mean by this? I don't understand.
>  Have you asked on libcxx-dev? Is there interest in the libc++ community for 
> a stand-alone base?


Sorry, poor choice of wording. Our archive must be able to be statically linked 
into the supporting allocators. At this stage, the plans are to implement 
GWP-ASan into Scudo and Android's bionic libc. This means we have to be 
compatible with the the most restrictive aspects of each allocator's build 
environment, simultaneously.

In practice, we can't use `std::mutex` because Scudo specifies `-nostdlib++ 
-nodefaultlibs`, and if any part of the implementation of `std::mutex` (and 
likewise `mtx_t`) falls outside of the header file, we will fail to link (as is 
the case with libc++).

>> We also are trying to stay independent of `pthread` for 
>> platform-independentness.
> 
> The code I see is clearly not platform independent. Please clarify your 
> reasoning. I can understand if you don't want pthread for a valid reason, but 
> "platform-independence" doesn't make sense here.

My view was that small stubs to implement the architecture-dependent and 
OS-dependent functionality is much easier to manage. If we use `pthread` on 
unix, and `CreateMutex` on Windows, we still have to have OS-dependent ifdefs, 
but we then pass on the requirement to the supporting allocator to ensure our 
dependencies are there (which could be a huge pain point both for Scudo+fuchsia 
and Android).

>> We also can't use a `sanitizer_common` variant as we don't want to pull in 
>> the entirety `sanitizer_common` as a dependency.
> 
> What's the restriction that makes it unacceptable?

Scudo (standalone) can't pull in the entirety of sanitizer_common (code size + 
maintainability for fuchsia). It's also a much easier track to get Android 
supported if we don't have to pull in and build the entirety of 
sanitizer_common.

>> Basically, the roadmap is to create a shared mutex library for 
>> `sanitizer_common`, `gwp_asan` and `scudo` to all use.
> 
> I'm asking all these question because they should be in the commit message, 
> and would hopefully have surfaced from the RFC about GWP / Scudo. If those 
> weren't in the RFC that's fine, they should still be in the commit message 
> and you'll want to update the RFC with "while reviewing code we realized 
> *stuff*".

Ack.

>> I think the idea is that implementing our own spinlock is not much harder 
>> than having 3 platform-specific implementations (posix, window, fuchsia).
> 
> Your concerns are backwards. Implementation is a one-time thing, maintenance 
> is an ongoing concern and it way overshadows implementation concerns. In 
> particular, a variety of multicore code that does its own locking is much 
> harder to tune at the system-wide level compared to a single thing that's 
> tuned for each application. I'm not saying a separate mutex doesn't make 
> sense, what I'm saying is that experience shows your above reasoning to be 
> generally invalid. I'm totally willing to believe that there's a very good 
> reason to have your own mutex here, but you gotta explain it.

Hopefully above helps to clarify :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61923

Files:
  clang/runtime/CMakeLists.txt
  compiler-rt/lib/gwp_asan/CMakeLists.txt
  compiler-rt/lib/gwp_asan/definitions.h
  compiler-rt/lib/gwp_asan/mutex.h
  compiler-rt/lib/gwp_asan/tests/CMakeLists.txt
  compiler-rt/lib/gwp_asan/tests/driver.cpp
  compiler-rt/lib/gwp_asan/tests/mutex_test.cpp
  compiler-rt/test/gwp_asan/CMakeLists.txt
  compiler-rt/test/gwp_asan/dummy_test.cc
  compiler-rt/test/gwp_asan/lit.cfg
  compiler-rt/test/gwp_asan/lit.site.cfg.in
  compiler-rt/test/gwp_asan/unit/lit.site.cfg.in

Index: compiler-rt/test/gwp_asan/unit/lit.site.cfg.in
===
--- /dev/null
+++ compiler-rt/test/gwp_asan/unit/lit.site.cfg.in
@@ -0,0 +1,9 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+config.name = "GwpAsan-Unittest"
+# Load common config for all compiler-rt unit tests.
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured")
+
+config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@",
+ "lib", "gwp_asan", "tests")
+config.test_source_root = config.test_exec_root
Index: compiler-rt/test/gwp_asan/lit.site.cfg.in

[PATCH] D61804: Support building shared and static libraries simultaneously

2019-05-15 Thread Wink Saville via Phabricator via cfe-commits
winksaville abandoned this revision.
winksaville added a comment.

Abandoning, @beanz has proposed a better solution, D61909 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61804



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


[PATCH] D61827: [clang-tidy] modernize-loop-convert: impl const cast iter

2019-05-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE360785: [clang-tidy] modernize-loop-convert: impl const 
cast iter (authored by dhinton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61827?vs=199496=199631#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61827

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  docs/clang-tidy/checks/modernize-loop-convert.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/modernize-loop-convert-basic.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp

Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -776,17 +776,20 @@
   // CHECK-FIXES: for (auto P : *Ps)
   // CHECK-FIXES-NEXT: printf("s has value %d\n", P.X);
 
-  // V.begin() returns a user-defined type 'iterator' which, since it's
-  // different from const_iterator, disqualifies these loops from
-  // transformation.
   dependent V;
   for (dependent::const_iterator It = V.begin(); It != V.end(); ++It) {
 printf("Fibonacci number is %d\n", *It);
   }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int It : V)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
 
   for (dependent::const_iterator It(V.begin()); It != V.end(); ++It) {
 printf("Fibonacci number is %d\n", *It);
   }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int It : V)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
 }
 
 } // namespace SingleIterator
@@ -991,18 +994,26 @@
   // CHECK-FIXES: for (int & I : Dep)
   // CHECK-FIXES-NEXT: auto H2 = [&]() { int R = I + 2; };
 
-  // FIXME: It doesn't work with const iterators.
   for (dependent::const_iterator I = Dep.begin(), E = Dep.end();
I != E; ++I)
 auto H3 = [I]() { int R = *I; };
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int I : Dep)
+  // CHECK-FIXES-NEXT: auto H3 = []() { int R = I; };
 
   for (dependent::const_iterator I = Dep.begin(), E = Dep.end();
I != E; ++I)
 auto H4 = [&]() { int R = *I + 1; };
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int I : Dep)
+  // CHECK-FIXES-NEXT: auto H4 = [&]() { int R = I + 1; };
 
   for (dependent::const_iterator I = Dep.begin(), E = Dep.end();
I != E; ++I)
 auto H5 = [=]() { int R = *I; };
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int R : Dep)
+  // CHECK-FIXES-NEXT: auto H5 = [=]() { };
 }
 
 void captureByValue() {
Index: test/clang-tidy/modernize-loop-convert-basic.cpp
===
--- test/clang-tidy/modernize-loop-convert-basic.cpp
+++ test/clang-tidy/modernize-loop-convert-basic.cpp
@@ -369,7 +369,7 @@
 // CHECK-FIXES: for (auto Val_int_ptr : Val_int_ptrs)
   }
 
-  // This container uses an iterator where the derefence type is a typedef of
+  // This container uses an iterator where the dereference type is a typedef of
   // a reference type. Make sure non-const auto & is still used. A failure here
   // means canonical types aren't being tested.
   {
@@ -431,19 +431,22 @@
   // CHECK-FIXES: for (auto P : *Ps)
   // CHECK-FIXES-NEXT: printf("s has value %d\n", P.X);
 
-  // V.begin() returns a user-defined type 'iterator' which, since it's
-  // different from const_iterator, disqualifies these loops from
-  // transformation.
   dependent V;
   for (dependent::const_iterator It = V.begin(), E = V.end();
It != E; ++It) {
 printf("Fibonacci number is %d\n", *It);
   }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int It : V)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
 
   for (dependent::const_iterator It(V.begin()), E = V.end();
It != E; ++It) {
 printf("Fibonacci number is %d\n", *It);
   }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int It : V)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
 }
 
 // Tests to ensure that an implicit 'this' is picked up as the container.
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -791,11 +791,6 @@
   CanonicalBeginType->getPointeeType(),
   CanonicalInitVarType->getPointeeType()))
 return false;
-} else if (!Context->hasSameType(CanonicalInitVarType,
-  

[clang-tools-extra] r360785 - [clang-tidy] modernize-loop-convert: impl const cast iter

2019-05-15 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Wed May 15 09:58:58 2019
New Revision: 360785

URL: http://llvm.org/viewvc/llvm-project?rev=360785=rev
Log:
[clang-tidy] modernize-loop-convert: impl const cast iter

Summary:
modernize-loop-convert was not detecting implicit casts to
const_iterator as convertible to range-based loops:

std::vector vec{1,2,3,4}
for(std::vector::const_iterator i = vec.begin();
i != vec.end();
++i) { }

Thanks to Don Hinton for advice.

As well, this change adds a note for this check's applicability to code
targeting OpenMP prior to version 5 as this check will continue breaking
compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this
out.

Fixes PR#35082

Reviewed By: hintonda

Tags: #clang-tools-extra, #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=360785=360784=360785=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Wed May 
15 09:58:58 2019
@@ -791,11 +791,6 @@ bool LoopConvertCheck::isConvertible(AST
   CanonicalBeginType->getPointeeType(),
   CanonicalInitVarType->getPointeeType()))
 return false;
-} else if (!Context->hasSameType(CanonicalInitVarType,
- CanonicalBeginType)) {
-  // Check for qualified types to avoid conversions from non-const to const
-  // iterator types.
-  return false;
 }
   } else if (FixerKind == LFK_PseudoArray) {
 // This call is required to obtain the container.

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst?rev=360785=360784=360785=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst 
Wed May 15 09:58:58 2019
@@ -253,3 +253,15 @@ below ends up being performed at the `sa
   flag = true;
 }
   }
+
+OpenMP
+^^
+
+As range-based for loops are only available since OpenMP 5, this check should
+not been used on code with a compatibility requirements of OpenMP prior to
+version 5. It is **intentional** that this check does not make any attempts to
+exclude incorrect diagnostics on OpenMP for loops prior to OpenMP 5.
+
+To prevent this check to be applied (and to break) OpenMP for loops but still 
be
+applied to non-OpenMP for loops the usage of ``NOLINT`` (see
+:ref:`clang-tidy-nolint`) on the specific for loops is recommended.

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=360785=360784=360785=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Wed May 15 09:58:58 2019
@@ -258,6 +258,8 @@ An overview of all the command-line opti
   value:   'some value'
   ...
 
+.. _clang-tidy-nolint:
+
 Suppressing Undesired Diagnostics
 =
 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp?rev=360785=360784=360785=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
Wed May 15 09:58:58 2019
@@ -369,7 +369,7 @@ void f() {
 // CHECK-FIXES: for (auto Val_int_ptr : Val_int_ptrs)
   }
 
-  // This container uses an iterator where the derefence type is a typedef of
+  // This container uses an iterator where the dereference type is a typedef of
   // a reference type. Make sure non-const auto & is still used. A failure here
   // means canonical types aren't being tested.
   {
@@ -431,19 +431,22 @@ void different_type() {
   // CHECK-FIXES: for (auto P : *Ps)
   // CHECK-FIXES-NEXT: printf("s has value %d\n", 

[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-05-15 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Minor stuff.  This solution is surprisingly simple, the main question being 
(and I don't have an answer) whether increasing the size of PresumedLoc is okay.




Comment at: lib/Basic/SourceManager.cpp:1460
+FID = FileID::get(0); // contents of files referenced by #line aren't 
in
+  // the SourceManager
+  }

The comment would work better as a proper sentence, and on the line before the 
statement.



Comment at: lib/CodeGen/CGDebugInfo.cpp:429
+  // all the files referred by #line. Instead the checksum remains empty,
+  // leaving to the debugger to open the file without checksum validation.
   Optional CSKind =

While the comment describes the desirable result, it is actually not describing 
what is happening right here.  Maybe something like this:

Compute the checksum if possible.  If the location is affected by a #line 
directive that refers to a file, PLoc will have an invalid FileID, and we will 
correctly get no checksum.



Comment at: test/CodeGen/debug-info-file-checksum.c:13
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}code-coverage-filter2.h", 
directory: "{{[^"]*}}")
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}debug-info-file-checksum.c", 
directory: "{{[^"]*}}")
+

These directives don't need the -LABEL suffix.


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

https://reviews.llvm.org/D60283



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


[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Headers/__clang_cuda_device_functions.h:1477
 #endif // CUDA_VERSION >= 9020
+#if __cplusplus >= 201703L
+__DEVICE__ int abs(int __a) noexcept { return __nv_abs(__a); }

jdoerfert wrote:
> Hahnfeld wrote:
> > If I recall correctly, `__cplusplus` is not defined in C mode, so both GCC 
> > and Clang will issue a warning with `-Wundef`.
> > 
> > Maybe this can be solved with something similar to:
> > ```lang=c
> > #ifdef __cplusplus
> > #define cpp_version __cplusplus
> > #else
> > #define cpp_version 0
> > #endif
> > ```
> > (to avoid repetition of `#if defined(__cplusplus) && __cplusplus >= 
> > 201703L`)
> I dislike defining the version and advice to repeating `#if 
> defined(__cplusplus) && __cplusplus >= 201703L)`
> 
I agree with @jdoerfert.
If that's needed too often, we can move c++-only functions under one global 
`#if defined(__cplusplus)`.




Comment at: lib/Headers/__clang_cuda_device_functions.h:1579-1586
+#if __cplusplus >= 201703L
+__DEVICE__ long labs(long __a) noexcept { return __nv_llabs(__a); };
+#else
 __DEVICE__ long labs(long __a) { return __nv_llabs(__a); };
+#endif
+#else
+#if __cplusplus >= 201703L

This is typically dealt with by defining and using a macro which would expand 
to `noexcept` or to nothing.
E.g. something like [[ 
https://github.com/llvm-mirror/libcxx/blob/dbd4f51025003a7c869c4e5267ab8780e91367d5/include/__config#L848
 | what libcxx does ]].

This should reduce the number of needed `#if`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949



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


[PATCH] D44100: [ASTImporter] Reorder fields after structure import is finished

2019-05-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: lib/AST/ASTImporter.cpp:1643
+if (!ImportedOrErr) {
+  // For RecordDecls, failed import of a field will break the layout of the
+  // structure. Handle it as an error.

shafik wrote:
> What cases are failed import of a field ok? Is that because we will get the 
> field later on by another path?
The decl context of which we import the contained decls (`FromDC`) may be a 
namespace, it is not necessarily a RecordDecl.
I guess it would be too drastic if a whole namespace is rendered as erroneous 
if just one contained decl import failed.



Comment at: lib/AST/ASTImporter.cpp:1655
+  // Reorder declarations in RecordDecls because they may have another
+  // order. Keeping field order is vitable because it determines structure
+  // layout.

shafik wrote:
> vitable?
My guess is `vital`.



Comment at: lib/AST/ASTImporter.cpp:1674
+  Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
+  assert(ToRD == ToD->getDeclContext() && ToRD->containsDecl(ToD));
+  ToRD->removeDecl(ToD);

shafik wrote:
> Are we sure `ToD` is never a `nullptr` b/c you are unconditionally 
> derefenecing it here.
Yes, I agree. Added `assert(ToD)` because we had imported all contained decls 
previously without errors.



Comment at: lib/AST/ASTImporter.cpp:1674
+  Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
+  assert(ToRD == ToD->getDeclContext() && ToRD->containsDecl(ToD));
+  ToRD->removeDecl(ToD);

martong wrote:
> shafik wrote:
> > Are we sure `ToD` is never a `nullptr` b/c you are unconditionally 
> > derefenecing it here.
> Yes, I agree. Added `assert(ToD)` because we had imported all contained decls 
> previously without errors.
`assert(ToRD == ToD->getDeclContext()` is not correct here, because friends 
semantic decl context may not be the befriending class. Changed to compare 
against the lexical DC.



Comment at: lib/AST/ASTImporter.cpp:1679
+
+  if (!ToRD->hasExternalLexicalStorage())
+assert(ToRD->field_empty());

shafik wrote:
> Can you add a comment explaining why if the Decl has ExternalLexicalStorage 
> the fields might not be empty even though we just removed them?
We removed only those fields which we have imported from the `FromDC`. We did 
not remove all the decls of `ToRD`. And we don't want to remove any fields 
which may be loaded from an external storage.
The reason is that `field_empty` would call `field_begin` which would call 
`LoadFieldsFromExternalStorage` which in turn would call `ASTImporter::Import`. 
This is because the ExternalASTSource interface in LLDB is implemented by the 
means of the ASTImporter. However, calling an import at this point would result 
in an uncontrolled import, we must avoid that.



Comment at: lib/AST/ASTImporter.cpp:1686
+  assert(ToD);
+  assert(ToRD == ToD->getDeclContext());
+  assert(ToRD == ToD->getLexicalDeclContext());

I removed this assert, because friends most usually have a different semantic 
context than the befriending class.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44100



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


r360783 - Test commit

2019-05-15 Thread Kevin Petit via cfe-commits
Author: kpet
Date: Wed May 15 09:39:28 2019
New Revision: 360783

URL: http://llvm.org/viewvc/llvm-project?rev=360783=rev
Log:
Test commit

Remove stray space.

Signed-off-by: Kevin Petit 

Modified:
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=360783=360782=360783=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed May 15 09:39:28 2019
@@ -7561,7 +7561,7 @@ static void processTypeAttrs(TypeProcess
 state.getDeclarator().isPrototypeContext() &&
 !hasOuterPointerLikeChunk(state.getDeclarator(), endIndex);
 if (checkNullabilityTypeSpecifier(
-  state, 
+  state,
   type,
   attr,
   allowOnArrayType)) {


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


[PATCH] D44100: [ASTImporter] Reorder fields after structure import is finished

2019-05-15 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 199629.
martong marked 13 inline comments as done.
martong added a comment.

- Address Shafik's comments and update assertions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44100

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1371,7 +1371,7 @@
 }
 
 TEST_P(ASTImporterOptionSpecificTestBase,
-   DISABLED_CXXRecordDeclFieldOrderShouldNotDependOnImportOrder) {
+   CXXRecordDeclFieldOrderShouldNotDependOnImportOrder) {
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(
   // The original recursive algorithm of ASTImporter first imports 'c' then
@@ -4626,5 +4626,16 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportVariables,
 DefaultTestValuesForRunOptions, );
 
+TEST_P(ImportDecl, ImportFieldOrder) {
+  MatchVerifier Verifier;
+  testImport("struct declToImport {"
+ "  int b = a + 2;"
+ "  int a = 5;"
+ "};",
+ Lang_CXX11, "", Lang_CXX11, Verifier,
+ recordDecl(hasFieldOrder({"b", "a"})));
+}
+
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -1632,13 +1632,77 @@
 auto ToDCOrErr = Importer.ImportContext(FromDC);
 return ToDCOrErr.takeError();
   }
-  llvm::SmallVector ImportedDecls;
+
+  const auto *FromRD = dyn_cast(FromDC);
   for (auto *From : FromDC->decls()) {
 ExpectedDecl ImportedOrErr = import(From);
-if (!ImportedOrErr)
+if (!ImportedOrErr) {
+  // For RecordDecls, failed import of a field will break the layout of the
+  // structure. Handle it as an error.
+  if (FromRD)
+return ImportedOrErr.takeError();
   // Ignore the error, continue with next Decl.
   // FIXME: Handle this case somehow better.
-  consumeError(ImportedOrErr.takeError());
+  else
+consumeError(ImportedOrErr.takeError());
+}
+  }
+
+  if (!FromRD)
+return Error::success();
+
+  // We reorder declarations in RecordDecls because they may have another order
+  // in the "to" context than they have in the "from" context. This may happen
+  // e.g when we import a class like this:
+  //struct declToImport {
+  //int a = c + b;
+  //int b = 1;
+  //int c = 2;
+  //};
+  // During the import of `a` we import first the dependencies in sequence,
+  // thus the order would be `c`, `b`, `a`. We will get the normal order by
+  // first removing the already imported members and then adding them in the
+  // order as they apper in the "from" context.
+  //
+  // Keeping field order is vital because it determines structure layout.
+  //
+  // Here and below, we cannot call field_begin() method and its callers
+  // on ToRD if it has an external storage. Calling field_begin() will
+  // automatically load all the fields by calling
+  // LoadFieldsFromExternalStorage().
+  auto ImportedDC = import(cast(FromDC));
+  assert(ImportedDC);
+  auto *ToRD = cast(*ImportedDC);
+  for (auto *D : FromRD->decls()) {
+if (isa(D) || isa(D)) {
+  assert(D && "DC has a contained decl which is null?");
+  Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
+  assert(ToD && "We already imported all the contained decls of the DC");
+  assert(ToRD == ToD->getLexicalDeclContext() && ToRD->containsDecl(ToD));
+  ToRD->removeDecl(ToD);
+}
+  }
+
+  // We removed only those fields which we have imported from the FromDC. We
+  // did not remove all the decls of ToRD. And we don't want to remove any
+  // fields which may be loaded from an external storage. The reason is that
+  // field_empty would call field_begin which would call
+  // LoadFieldsFromExternalStorage which in turn would call
+  // ASTImporter::Import. This is because the ExternalASTSource interface in
+  // LLDB is implemented by the means of the ASTImporter. However, calling an
+  // import at this point would result in an uncontrolled import, we must avoid
+  // that.
+  if (!ToRD->hasExternalLexicalStorage())
+assert(ToRD->field_empty());
+
+  for (auto *D : FromRD->decls()) {
+if (isa(D) || isa(D)) {
+  Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
+  assert(ToD);
+  assert(ToRD == ToD->getLexicalDeclContext());
+  assert(ToRD->hasExternalLexicalStorage() || !ToRD->containsDecl(ToD));
+  ToRD->addDeclInternal(ToD);
+}
   }
 
   return Error::success();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

Re: r360308 - [c++20] Implement P0846R0: allow (ADL-only) calls to template-ids whose

2019-05-15 Thread Stephan Bergmann via cfe-commits

The below commit started to cause the following failure:


$ cat test.cc
template struct S1 { static int const n = 0; };
template struct S2 { typedef int t; };
template struct S3 { typename S2::n < 0, int>::t n; };

$ clang++ -fsyntax-only test.cc
test.cc:3:53: error: use 'template' keyword to treat 'n' as a dependent
  template name
template struct S3 { typename S2::n < 0, int>::t n; };
^
template 
test.cc:3:46: error: missing 'typename' prior to dependent type name

  'S1::S1::n<0, int>::t'
template struct S3 { typename S2::n < 0, int>::t n; };
 ^
 typename 
test.cc:3:68: error: expected '>'

template struct S3 { typename S2::n < 0, int>::t n; };
   ^
3 errors generated.



On 09/05/2019 05:31, Richard Smith via cfe-commits wrote:

Author: rsmith
Date: Wed May  8 20:31:27 2019
New Revision: 360308

URL: http://llvm.org/viewvc/llvm-project?rev=360308=rev
Log:
[c++20] Implement P0846R0: allow (ADL-only) calls to template-ids whose
template name is not visible to unqualified lookup.

In order to support this without a severe degradation in our ability to
diagnose typos in template names, this change significantly restructures
the way we handle template-id-shaped syntax for which lookup of the
template name finds nothing.

Instead of eagerly diagnosing an undeclared template name, we now form a
placeholder template-name representing a name that is known to not find
any templates. When the parser sees such a name, it attempts to
disambiguate whether we have a less-than comparison or a template-id.
Any diagnostics or typo-correction for the name are delayed until its
point of use.

The upshot should be a small improvement of our diagostic quality
overall: we now take more syntactic context into account when trying to
resolve an undeclared identifier on the left hand side of a '<'. In
fact, this works well enough that the backwards-compatible portion (for
an undeclared identifier rather than a lookup that finds functions but
no function templates) is enabled in all language modes.

Added:
 cfe/trunk/test/SemaCXX/cxx2a-adl-only-template-id.cpp
Modified:
 cfe/trunk/include/clang/AST/ASTContext.h
 cfe/trunk/include/clang/AST/DeclarationName.h
 cfe/trunk/include/clang/AST/TemplateName.h
 cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
 cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
 cfe/trunk/include/clang/Basic/TemplateKinds.h
 cfe/trunk/include/clang/Parse/Parser.h
 cfe/trunk/include/clang/Sema/Sema.h
 cfe/trunk/lib/AST/ASTContext.cpp
 cfe/trunk/lib/AST/ASTImporter.cpp
 cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
 cfe/trunk/lib/AST/ItaniumMangle.cpp
 cfe/trunk/lib/AST/ODRHash.cpp
 cfe/trunk/lib/AST/TemplateName.cpp
 cfe/trunk/lib/Parse/ParseDecl.cpp
 cfe/trunk/lib/Parse/ParseDeclCXX.cpp
 cfe/trunk/lib/Parse/ParseExprCXX.cpp
 cfe/trunk/lib/Parse/ParseTemplate.cpp
 cfe/trunk/lib/Parse/ParseTentative.cpp
 cfe/trunk/lib/Parse/Parser.cpp
 cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
 cfe/trunk/lib/Sema/SemaDecl.cpp
 cfe/trunk/lib/Sema/SemaDeclCXX.cpp
 cfe/trunk/lib/Sema/SemaExpr.cpp
 cfe/trunk/lib/Sema/SemaExprCXX.cpp
 cfe/trunk/lib/Sema/SemaOverload.cpp
 cfe/trunk/lib/Sema/SemaTemplate.cpp
 cfe/trunk/lib/Serialization/ASTReader.cpp
 cfe/trunk/lib/Serialization/ASTWriter.cpp
 cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp
 cfe/trunk/test/CXX/drs/dr2xx.cpp
 cfe/trunk/test/CXX/drs/dr6xx.cpp
 cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p5.cpp
 cfe/trunk/test/FixIt/typo-crash.cpp
 cfe/trunk/test/Misc/diag-template-diffing.cpp
 cfe/trunk/test/Modules/module-private.cpp
 cfe/trunk/test/Modules/submodules-merge-defs.cpp
 cfe/trunk/test/Parser/cxx-ambig-init-templ.cpp
 cfe/trunk/test/Parser/cxx-template-argument.cpp
 cfe/trunk/test/Parser/cxx-template-decl.cpp
 cfe/trunk/test/SemaCXX/alias-template.cpp
 cfe/trunk/test/SemaCXX/class.cpp
 cfe/trunk/test/SemaCXX/destructor.cpp
 cfe/trunk/test/SemaCXX/invalid-member-expr.cpp
 cfe/trunk/test/SemaCXX/typo-correction.cpp
 cfe/trunk/test/SemaTemplate/dependent-base-classes.cpp
 cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp
 cfe/trunk/test/SemaTemplate/rdar9173693.cpp
 cfe/trunk/test/SemaTemplate/recovery-crash.cpp
 cfe/trunk/tools/libclang/CIndex.cpp
 cfe/trunk/www/cxx_status.html

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


[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Missing `defined(__cplusplus)` to avoid warnings and we have to resolve the two 
new includes. Otherwise, this looks good. So, if you "fix" both go ahead and 
commit, if not, lets discuss.




Comment at: lib/Headers/__clang_cuda_device_functions.h:1477
 #endif // CUDA_VERSION >= 9020
+#if __cplusplus >= 201703L
+__DEVICE__ int abs(int __a) noexcept { return __nv_abs(__a); }

Hahnfeld wrote:
> If I recall correctly, `__cplusplus` is not defined in C mode, so both GCC 
> and Clang will issue a warning with `-Wundef`.
> 
> Maybe this can be solved with something similar to:
> ```lang=c
> #ifdef __cplusplus
> #define cpp_version __cplusplus
> #else
> #define cpp_version 0
> #endif
> ```
> (to avoid repetition of `#if defined(__cplusplus) && __cplusplus >= 201703L`)
I dislike defining the version and advice to repeating `#if 
defined(__cplusplus) && __cplusplus >= 201703L)`




Comment at: lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h:24
+  #include 
+  #include 
 #endif

I ask this question again and again, do we need them now? Why?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949



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


[PATCH] D61950: [PowerPC64] adds ABI parsing when specified on target triple

2019-05-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:217
   case Triple::ppc64:
-return PPCTargetMachine::PPC_ABI_ELFv1;
+// if ELFv2 on target triple i.e. powerpc64-unknown-freebsd12.0-elfv2
+if (TT.getEnvironment() == llvm::Triple::ELFv2)

The initial word should be capitalized and the sentence should end with a 
period. At least this part of the comment (`if ELFv2 on target triple `) is 
redundant. I don't know if the other half `powerpc64-unknown-freebsd12.0-elfv2` 
is useful...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61950



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


[PATCH] D61950: [PowerPC64] adds ABI parsing when specified on target triple

2019-05-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Basic/Targets/PPC.h:382
   resetDataLayout("e-m:e-i64:64-n32:64");
-  ABI = "elfv2";
 } else {

MaskRay wrote:
> Have you researched how GNU as chooses the default ABI?
> 
> I think the change may break some Linux ppc64le users as they expect the 
> default elfv2.
Sorry, it won't :) Then I think it is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61950



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


[PATCH] D61950: [PowerPC64] adds ABI parsing when specified on target triple

2019-05-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Basic/Targets/PPC.h:382
   resetDataLayout("e-m:e-i64:64-n32:64");
-  ABI = "elfv2";
 } else {

Have you researched how GNU as chooses the default ABI?

I think the change may break some Linux ppc64le users as they expect the 
default elfv2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61950



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


[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/Headers/__clang_cuda_device_functions.h:1477
 #endif // CUDA_VERSION >= 9020
+#if __cplusplus >= 201703L
+__DEVICE__ int abs(int __a) noexcept { return __nv_abs(__a); }

If I recall correctly, `__cplusplus` is not defined in C mode, so both GCC and 
Clang will issue a warning with `-Wundef`.

Maybe this can be solved with something similar to:
```lang=c
#ifdef __cplusplus
#define cpp_version __cplusplus
#else
#define cpp_version 0
#endif
```
(to avoid repetition of `#if defined(__cplusplus) && __cplusplus >= 201703L`)


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949



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


  1   2   >